2007-01-23 19:33:30 +01:00
|
|
|
/*
|
2009-05-18 18:35:32 +02:00
|
|
|
* Copyright 2007-2009 Jacek Caban for CodeWeavers
|
2007-01-23 19:33:30 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "urlmon_main.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
|
|
|
|
|
2009-05-11 21:59:31 +02:00
|
|
|
typedef struct BindProtocol BindProtocol;
|
|
|
|
|
|
|
|
struct _task_header_t;
|
|
|
|
|
|
|
|
typedef void (*task_proc_t)(BindProtocol*,struct _task_header_t*);
|
|
|
|
|
|
|
|
typedef struct _task_header_t {
|
|
|
|
task_proc_t proc;
|
|
|
|
struct _task_header_t *next;
|
|
|
|
} task_header_t;
|
|
|
|
|
|
|
|
struct BindProtocol {
|
2009-05-18 18:31:03 +02:00
|
|
|
const IInternetProtocolVtbl *lpIInternetProtocolVtbl;
|
|
|
|
const IInternetBindInfoVtbl *lpInternetBindInfoVtbl;
|
|
|
|
const IInternetPriorityVtbl *lpInternetPriorityVtbl;
|
|
|
|
const IServiceProviderVtbl *lpServiceProviderVtbl;
|
|
|
|
const IInternetProtocolSinkVtbl *lpIInternetProtocolSinkVtbl;
|
2009-08-21 00:14:41 +02:00
|
|
|
const IWinInetHttpInfoVtbl *lpIWinInetHttpInfoVtbl;
|
2007-01-23 19:33:30 +01:00
|
|
|
|
2009-05-18 18:29:24 +02:00
|
|
|
const IInternetProtocolVtbl *lpIInternetProtocolHandlerVtbl;
|
|
|
|
|
2007-01-23 19:33:30 +01:00
|
|
|
LONG ref;
|
2007-01-23 19:36:09 +01:00
|
|
|
|
|
|
|
IInternetProtocol *protocol;
|
2009-05-18 18:29:24 +02:00
|
|
|
IInternetProtocol *protocol_handler;
|
2007-01-23 19:36:09 +01:00
|
|
|
IInternetBindInfo *bind_info;
|
|
|
|
IInternetProtocolSink *protocol_sink;
|
2007-12-24 12:42:22 +01:00
|
|
|
IServiceProvider *service_provider;
|
2009-03-29 21:31:15 +02:00
|
|
|
IWinInetInfo *wininet_info;
|
2007-01-23 23:33:38 +01:00
|
|
|
|
|
|
|
LONG priority;
|
2007-12-28 14:54:22 +01:00
|
|
|
|
|
|
|
BOOL reported_result;
|
2009-05-14 00:49:01 +02:00
|
|
|
BOOL reported_mime;
|
2007-12-30 17:40:26 +01:00
|
|
|
BOOL from_urlmon;
|
2009-05-11 21:59:31 +02:00
|
|
|
DWORD pi;
|
|
|
|
|
|
|
|
DWORD apartment_thread;
|
|
|
|
HWND notif_hwnd;
|
|
|
|
DWORD continue_call;
|
|
|
|
|
|
|
|
CRITICAL_SECTION section;
|
|
|
|
task_header_t *task_queue_head, *task_queue_tail;
|
2009-05-14 00:49:01 +02:00
|
|
|
|
|
|
|
BYTE *buf;
|
|
|
|
DWORD buf_size;
|
|
|
|
LPWSTR mime;
|
|
|
|
LPWSTR url;
|
2009-05-18 18:35:32 +02:00
|
|
|
ProtocolProxy *filter_proxy;
|
2009-05-11 21:59:31 +02:00
|
|
|
};
|
2007-01-23 19:33:30 +01:00
|
|
|
|
|
|
|
#define BINDINFO(x) ((IInternetBindInfo*) &(x)->lpInternetBindInfoVtbl)
|
2007-01-23 19:34:00 +01:00
|
|
|
#define PRIORITY(x) ((IInternetPriority*) &(x)->lpInternetPriorityVtbl)
|
2009-08-21 00:14:41 +02:00
|
|
|
#define HTTPINFO(x) ((IWinInetHttpInfo*) &(x)->lpIWinInetHttpInfoVtbl)
|
2007-12-24 12:42:22 +01:00
|
|
|
#define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl)
|
2007-01-23 19:33:30 +01:00
|
|
|
|
2009-05-18 18:29:24 +02:00
|
|
|
#define PROTOCOLHANDLER(x) ((IInternetProtocol*) &(x)->lpIInternetProtocolHandlerVtbl)
|
|
|
|
|
2009-05-14 00:49:01 +02:00
|
|
|
#define BUFFER_SIZE 2048
|
|
|
|
#define MIME_TEST_SIZE 255
|
|
|
|
|
2009-05-11 22:02:35 +02:00
|
|
|
#define WM_MK_CONTINUE (WM_USER+101)
|
|
|
|
#define WM_MK_RELEASE (WM_USER+102)
|
|
|
|
|
|
|
|
static LRESULT WINAPI notif_wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
2009-05-11 21:59:31 +02:00
|
|
|
{
|
2009-05-11 22:02:35 +02:00
|
|
|
switch(msg) {
|
|
|
|
case WM_MK_CONTINUE: {
|
|
|
|
BindProtocol *This = (BindProtocol*)lParam;
|
|
|
|
task_header_t *task;
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
EnterCriticalSection(&This->section);
|
|
|
|
|
|
|
|
task = This->task_queue_head;
|
|
|
|
if(task) {
|
|
|
|
This->task_queue_head = task->next;
|
|
|
|
if(!This->task_queue_head)
|
|
|
|
This->task_queue_tail = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&This->section);
|
|
|
|
|
|
|
|
if(!task)
|
|
|
|
break;
|
|
|
|
|
|
|
|
This->continue_call++;
|
|
|
|
task->proc(This, task);
|
|
|
|
This->continue_call--;
|
|
|
|
}
|
2009-05-11 21:59:31 +02:00
|
|
|
|
2009-05-11 22:02:35 +02:00
|
|
|
IInternetProtocol_Release(PROTOCOL(This));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
case WM_MK_RELEASE: {
|
|
|
|
tls_data_t *data = get_tls_data();
|
2009-05-11 21:59:31 +02:00
|
|
|
|
2009-05-11 22:02:35 +02:00
|
|
|
if(!--data->notif_hwnd_cnt) {
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
data->notif_hwnd = NULL;
|
2009-05-11 21:59:31 +02:00
|
|
|
}
|
2009-05-11 22:02:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return DefWindowProcW(hwnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
HWND get_notif_hwnd(void)
|
|
|
|
{
|
|
|
|
static ATOM wnd_class = 0;
|
|
|
|
tls_data_t *tls_data;
|
2009-05-11 21:59:31 +02:00
|
|
|
|
2009-05-11 22:02:35 +02:00
|
|
|
static const WCHAR wszURLMonikerNotificationWindow[] =
|
|
|
|
{'U','R','L',' ','M','o','n','i','k','e','r',' ',
|
|
|
|
'N','o','t','i','f','i','c','a','t','i','o','n',' ','W','i','n','d','o','w',0};
|
2009-05-11 21:59:31 +02:00
|
|
|
|
2009-05-11 22:02:35 +02:00
|
|
|
tls_data = get_tls_data();
|
|
|
|
if(!tls_data)
|
|
|
|
return NULL;
|
2009-05-11 21:59:31 +02:00
|
|
|
|
2009-05-11 22:02:35 +02:00
|
|
|
if(tls_data->notif_hwnd_cnt) {
|
|
|
|
tls_data->notif_hwnd_cnt++;
|
|
|
|
return tls_data->notif_hwnd;
|
2009-05-11 21:59:31 +02:00
|
|
|
}
|
|
|
|
|
2009-05-11 22:02:35 +02:00
|
|
|
if(!wnd_class) {
|
|
|
|
static WNDCLASSEXW wndclass = {
|
|
|
|
sizeof(wndclass), 0,
|
|
|
|
notif_wnd_proc, 0, 0,
|
|
|
|
NULL, NULL, NULL, NULL, NULL,
|
|
|
|
wszURLMonikerNotificationWindow,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
wndclass.hInstance = URLMON_hInstance;
|
|
|
|
|
|
|
|
wnd_class = RegisterClassExW(&wndclass);
|
|
|
|
if (!wnd_class && GetLastError() == ERROR_CLASS_ALREADY_EXISTS)
|
|
|
|
wnd_class = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
tls_data->notif_hwnd = CreateWindowExW(0, wszURLMonikerNotificationWindow,
|
|
|
|
wszURLMonikerNotificationWindow, 0, 0, 0, 0, 0, HWND_MESSAGE,
|
|
|
|
NULL, URLMON_hInstance, NULL);
|
|
|
|
if(tls_data->notif_hwnd)
|
|
|
|
tls_data->notif_hwnd_cnt++;
|
|
|
|
|
|
|
|
TRACE("hwnd = %p\n", tls_data->notif_hwnd);
|
|
|
|
|
|
|
|
return tls_data->notif_hwnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
void release_notif_hwnd(HWND hwnd)
|
|
|
|
{
|
|
|
|
tls_data_t *data = get_tls_data();
|
|
|
|
|
2009-05-15 09:44:34 +02:00
|
|
|
if(!data)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if(data->notif_hwnd != hwnd) {
|
2009-05-11 22:02:35 +02:00
|
|
|
PostMessageW(data->notif_hwnd, WM_MK_RELEASE, 0, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!--data->notif_hwnd_cnt) {
|
|
|
|
DestroyWindow(data->notif_hwnd);
|
|
|
|
data->notif_hwnd = NULL;
|
|
|
|
}
|
2009-05-11 21:59:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void push_task(BindProtocol *This, task_header_t *task, task_proc_t proc)
|
|
|
|
{
|
|
|
|
BOOL do_post = FALSE;
|
|
|
|
|
|
|
|
task->proc = proc;
|
|
|
|
task->next = NULL;
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->section);
|
|
|
|
|
|
|
|
if(This->task_queue_tail) {
|
|
|
|
This->task_queue_tail->next = task;
|
|
|
|
This->task_queue_tail = task;
|
|
|
|
}else {
|
|
|
|
This->task_queue_tail = This->task_queue_head = task;
|
|
|
|
do_post = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&This->section);
|
|
|
|
|
|
|
|
if(do_post) {
|
|
|
|
IInternetProtocol_AddRef(PROTOCOL(This));
|
2009-05-11 22:02:35 +02:00
|
|
|
PostMessageW(This->notif_hwnd, WM_MK_CONTINUE, 0, (LPARAM)This);
|
2009-05-11 21:59:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-18 21:07:41 +02:00
|
|
|
static inline BOOL do_direct_notif(BindProtocol *This)
|
2009-05-11 21:59:31 +02:00
|
|
|
{
|
|
|
|
return !(This->pi & PI_APARTMENTTHREADED) || (This->apartment_thread == GetCurrentThreadId() && !This->continue_call);
|
|
|
|
}
|
|
|
|
|
2009-05-18 18:35:32 +02:00
|
|
|
static HRESULT handle_mime_filter(BindProtocol *This, IInternetProtocol *mime_filter, LPCWSTR mime)
|
|
|
|
{
|
|
|
|
PROTOCOLFILTERDATA filter_data = { sizeof(PROTOCOLFILTERDATA), NULL, NULL, NULL, 0 };
|
|
|
|
IInternetProtocolSink *protocol_sink, *old_sink;
|
|
|
|
ProtocolProxy *filter_proxy;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IInternetProtocol_QueryInterface(mime_filter, &IID_IInternetProtocolSink, (void**)&protocol_sink);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = create_protocol_proxy(PROTOCOLHANDLER(This), This->protocol_sink, &filter_proxy);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
IInternetProtocolSink_Release(protocol_sink);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
old_sink = This->protocol_sink;
|
|
|
|
This->protocol_sink = protocol_sink;
|
|
|
|
This->filter_proxy = filter_proxy;
|
|
|
|
|
|
|
|
IInternetProtocol_AddRef(mime_filter);
|
|
|
|
This->protocol_handler = mime_filter;
|
|
|
|
|
|
|
|
filter_data.pProtocol = PROTOCOL(filter_proxy);
|
|
|
|
hres = IInternetProtocol_Start(mime_filter, mime, PROTSINK(filter_proxy), BINDINFO(This),
|
|
|
|
PI_FILTER_MODE|PI_FORCE_ASYNC, (HANDLE_PTR)&filter_data);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
IInternetProtocolSink_Release(old_sink);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
IInternetProtocolSink_ReportProgress(old_sink, BINDSTATUS_LOADINGMIMEHANDLER, NULL);
|
|
|
|
IInternetProtocolSink_Release(old_sink);
|
|
|
|
|
|
|
|
This->pi &= ~PI_MIMEVERIFICATION; /* FIXME: more tests */
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-05-18 18:30:12 +02:00
|
|
|
static void mime_available(BindProtocol *This, LPCWSTR mime, BOOL verified)
|
|
|
|
{
|
2009-05-18 18:35:32 +02:00
|
|
|
IInternetProtocol *mime_filter;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2009-05-18 18:30:12 +02:00
|
|
|
heap_free(This->mime);
|
|
|
|
This->mime = NULL;
|
|
|
|
|
2009-05-18 18:35:32 +02:00
|
|
|
mime_filter = get_mime_filter(mime);
|
|
|
|
if(mime_filter) {
|
|
|
|
TRACE("Got mime filter for %s\n", debugstr_w(mime));
|
2009-05-18 18:30:12 +02:00
|
|
|
|
2009-05-18 18:35:32 +02:00
|
|
|
hres = handle_mime_filter(This, mime_filter, mime);
|
|
|
|
IInternetProtocol_Release(mime_filter);
|
|
|
|
if(FAILED(hres))
|
|
|
|
FIXME("MIME filter failed: %08x\n", hres);
|
|
|
|
}else {
|
|
|
|
This->mime = heap_strdupW(mime);
|
|
|
|
|
|
|
|
if(verified || !(This->pi & PI_MIMEVERIFICATION)) {
|
|
|
|
This->reported_mime = TRUE;
|
|
|
|
|
|
|
|
if(This->protocol_sink)
|
|
|
|
IInternetProtocolSink_ReportProgress(This->protocol_sink, BINDSTATUS_MIMETYPEAVAILABLE, mime);
|
|
|
|
}
|
2009-05-18 18:30:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-18 18:31:03 +02:00
|
|
|
#define PROTOCOL_THIS(iface) DEFINE_THIS(BindProtocol, IInternetProtocol, iface)
|
2007-01-23 19:33:30 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI BindProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PROTOCOL_THIS(iface);
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
|
|
|
*ppv = PROTOCOL(This);
|
|
|
|
}else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv);
|
|
|
|
*ppv = PROTOCOL(This);
|
|
|
|
}else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv);
|
|
|
|
*ppv = PROTOCOL(This);
|
|
|
|
}else if(IsEqualGUID(&IID_IInternetBindInfo, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetBindInfo %p)\n", This, ppv);
|
|
|
|
*ppv = BINDINFO(This);
|
2007-01-23 19:34:00 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IInternetPriority, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetPriority %p)\n", This, ppv);
|
|
|
|
*ppv = PRIORITY(This);
|
|
|
|
}else if(IsEqualGUID(&IID_IAuthenticate, riid)) {
|
|
|
|
FIXME("(%p)->(IID_IAuthenticate %p)\n", This, ppv);
|
2007-01-23 19:45:27 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
|
2007-12-24 12:42:22 +01:00
|
|
|
TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
|
|
|
|
*ppv = SERVPROV(This);
|
2007-01-23 19:34:00 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IInternetProtocolSink, riid)) {
|
2007-01-23 19:45:27 +01:00
|
|
|
TRACE("(%p)->(IID_IInternetProtocolSink %p)\n", This, ppv);
|
|
|
|
*ppv = PROTSINK(This);
|
2009-08-21 00:14:41 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IWinInetInfo, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IWinInetInfo %p)\n", This, ppv);
|
2007-01-23 19:33:30 +01:00
|
|
|
|
2009-08-21 00:14:41 +02:00
|
|
|
if(This->protocol) {
|
|
|
|
IWinInetInfo *inet_info;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IInternetProtocol_QueryInterface(This->protocol, &IID_IWinInetInfo, (void**)&inet_info);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
*ppv = HTTPINFO(This);
|
|
|
|
IWinInetInfo_Release(inet_info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else if(IsEqualGUID(&IID_IWinInetHttpInfo, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IWinInetHttpInfo %p)\n", This, ppv);
|
|
|
|
|
|
|
|
if(This->protocol) {
|
|
|
|
IWinInetHttpInfo *http_info;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IInternetProtocol_QueryInterface(This->protocol, &IID_IWinInetHttpInfo, (void**)&http_info);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
*ppv = HTTPINFO(This);
|
|
|
|
IWinInetHttpInfo_Release(http_info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
WARN("not supported interface %s\n", debugstr_guid(riid));
|
2007-01-23 19:33:30 +01:00
|
|
|
}
|
|
|
|
|
2009-08-21 00:14:41 +02:00
|
|
|
if(!*ppv)
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
2007-01-23 19:33:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BindProtocol_AddRef(IInternetProtocol *iface)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PROTOCOL_THIS(iface);
|
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BindProtocol_Release(IInternetProtocol *iface)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PROTOCOL_THIS(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
if(!ref) {
|
2009-03-29 21:31:15 +02:00
|
|
|
if(This->wininet_info)
|
|
|
|
IWinInetInfo_Release(This->wininet_info);
|
2007-01-23 19:36:09 +01:00
|
|
|
if(This->protocol)
|
|
|
|
IInternetProtocol_Release(This->protocol);
|
|
|
|
if(This->bind_info)
|
|
|
|
IInternetBindInfo_Release(This->bind_info);
|
2009-05-18 18:29:24 +02:00
|
|
|
if(This->protocol_handler && This->protocol_handler != PROTOCOLHANDLER(This))
|
|
|
|
IInternetProtocol_Release(This->protocol_handler);
|
2009-05-18 18:35:32 +02:00
|
|
|
if(This->filter_proxy)
|
|
|
|
IInternetProtocol_Release(PROTOCOL(This->filter_proxy));
|
2007-01-23 19:36:09 +01:00
|
|
|
|
2007-12-28 14:53:25 +01:00
|
|
|
set_binding_sink(PROTOCOL(This), NULL);
|
2009-05-11 21:59:31 +02:00
|
|
|
|
|
|
|
if(This->notif_hwnd)
|
|
|
|
release_notif_hwnd(This->notif_hwnd);
|
|
|
|
DeleteCriticalSection(&This->section);
|
2009-05-14 00:49:01 +02:00
|
|
|
|
|
|
|
heap_free(This->mime);
|
|
|
|
heap_free(This->url);
|
2007-11-29 22:12:34 +01:00
|
|
|
heap_free(This);
|
2007-01-23 19:33:30 +01:00
|
|
|
|
|
|
|
URLMON_UnlockModule();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
|
|
|
|
IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
|
2009-04-01 03:42:37 +02:00
|
|
|
DWORD grfPI, HANDLE_PTR dwReserved)
|
2007-01-23 19:33:30 +01:00
|
|
|
{
|
|
|
|
BindProtocol *This = PROTOCOL_THIS(iface);
|
2009-05-18 18:29:24 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p %p %08x %lx)\n", This, debugstr_w(szUrl), pOIProtSink,
|
|
|
|
pOIBindInfo, grfPI, dwReserved);
|
|
|
|
|
|
|
|
return IInternetProtocol_Start(This->protocol_handler, szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PROTOCOL_THIS(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pProtocolData);
|
|
|
|
|
|
|
|
return IInternetProtocol_Continue(This->protocol_handler, pProtocolData);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
|
|
|
|
DWORD dwOptions)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PROTOCOL_THIS(iface);
|
|
|
|
FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PROTOCOL_THIS(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%08x)\n", This, dwOptions);
|
|
|
|
|
|
|
|
return IInternetProtocol_Terminate(This->protocol_handler, dwOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindProtocol_Suspend(IInternetProtocol *iface)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PROTOCOL_THIS(iface);
|
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindProtocol_Resume(IInternetProtocol *iface)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PROTOCOL_THIS(iface);
|
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindProtocol_Read(IInternetProtocol *iface, void *pv,
|
|
|
|
ULONG cb, ULONG *pcbRead)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PROTOCOL_THIS(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead);
|
|
|
|
|
|
|
|
if(pcbRead)
|
|
|
|
*pcbRead = 0;
|
|
|
|
return IInternetProtocol_Read(This->protocol_handler, pv, cb, pcbRead);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
|
|
|
|
DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PROTOCOL_THIS(iface);
|
|
|
|
FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PROTOCOL_THIS(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%08x)\n", This, dwOptions);
|
|
|
|
|
|
|
|
return IInternetProtocol_LockRequest(This->protocol_handler, dwOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindProtocol_UnlockRequest(IInternetProtocol *iface)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PROTOCOL_THIS(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
return IInternetProtocol_UnlockRequest(This->protocol_handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_binding_sink(IInternetProtocol *bind_protocol, IInternetProtocolSink *sink)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PROTOCOL_THIS(bind_protocol);
|
|
|
|
IInternetProtocolSink *prev_sink;
|
|
|
|
IServiceProvider *service_provider = NULL;
|
|
|
|
|
|
|
|
if(sink)
|
|
|
|
IInternetProtocolSink_AddRef(sink);
|
|
|
|
prev_sink = InterlockedExchangePointer((void**)&This->protocol_sink, sink);
|
|
|
|
if(prev_sink)
|
|
|
|
IInternetProtocolSink_Release(prev_sink);
|
|
|
|
|
|
|
|
if(sink)
|
|
|
|
IInternetProtocolSink_QueryInterface(sink, &IID_IServiceProvider, (void**)&service_provider);
|
|
|
|
service_provider = InterlockedExchangePointer((void**)&This->service_provider, service_provider);
|
|
|
|
if(service_provider)
|
|
|
|
IServiceProvider_Release(service_provider);
|
|
|
|
}
|
|
|
|
|
|
|
|
IWinInetInfo *get_wininet_info(IInternetProtocol *bind_protocol)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PROTOCOL_THIS(bind_protocol);
|
|
|
|
|
|
|
|
return This->wininet_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PROTOCOL_THIS
|
|
|
|
|
|
|
|
static const IInternetProtocolVtbl BindProtocolVtbl = {
|
|
|
|
BindProtocol_QueryInterface,
|
|
|
|
BindProtocol_AddRef,
|
|
|
|
BindProtocol_Release,
|
|
|
|
BindProtocol_Start,
|
|
|
|
BindProtocol_Continue,
|
|
|
|
BindProtocol_Abort,
|
|
|
|
BindProtocol_Terminate,
|
|
|
|
BindProtocol_Suspend,
|
|
|
|
BindProtocol_Resume,
|
|
|
|
BindProtocol_Read,
|
|
|
|
BindProtocol_Seek,
|
|
|
|
BindProtocol_LockRequest,
|
|
|
|
BindProtocol_UnlockRequest
|
|
|
|
};
|
|
|
|
|
|
|
|
#define PROTOCOLHANDLER_THIS(iface) DEFINE_THIS(BindProtocol, IInternetProtocolHandler, iface)
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProtocolHandler_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
ERR("should not be called\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ProtocolHandler_AddRef(IInternetProtocol *iface)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PROTOCOLHANDLER_THIS(iface);
|
|
|
|
return IInternetProtocol_AddRef(PROTOCOL(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ProtocolHandler_Release(IInternetProtocol *iface)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PROTOCOLHANDLER_THIS(iface);
|
|
|
|
return IInternetProtocol_Release(PROTOCOL(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProtocolHandler_Start(IInternetProtocol *iface, LPCWSTR szUrl,
|
|
|
|
IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
|
|
|
|
DWORD grfPI, HANDLE_PTR dwReserved)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PROTOCOLHANDLER_THIS(iface);
|
2007-01-23 19:36:09 +01:00
|
|
|
IInternetProtocol *protocol = NULL;
|
2007-01-23 23:33:38 +01:00
|
|
|
IInternetPriority *priority;
|
2007-01-23 19:36:09 +01:00
|
|
|
IServiceProvider *service_provider;
|
2009-03-29 21:31:15 +02:00
|
|
|
BOOL urlmon_protocol = FALSE;
|
2007-01-23 19:36:09 +01:00
|
|
|
CLSID clsid = IID_NULL;
|
|
|
|
LPOLESTR clsid_str;
|
|
|
|
HRESULT hres;
|
2007-01-23 19:33:30 +01:00
|
|
|
|
2009-04-01 03:42:37 +02:00
|
|
|
TRACE("(%p)->(%s %p %p %08x %lx)\n", This, debugstr_w(szUrl), pOIProtSink,
|
2007-01-23 19:33:30 +01:00
|
|
|
pOIBindInfo, grfPI, dwReserved);
|
|
|
|
|
|
|
|
if(!szUrl || !pOIProtSink || !pOIBindInfo)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2009-05-11 21:59:31 +02:00
|
|
|
This->pi = grfPI;
|
2009-05-14 00:49:01 +02:00
|
|
|
This->url = heap_strdupW(szUrl);
|
2009-05-11 21:59:31 +02:00
|
|
|
|
2007-01-23 19:36:09 +01:00
|
|
|
hres = IInternetProtocolSink_QueryInterface(pOIProtSink, &IID_IServiceProvider,
|
|
|
|
(void**)&service_provider);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
/* FIXME: What's protocol CLSID here? */
|
|
|
|
IServiceProvider_QueryService(service_provider, &IID_IInternetProtocol,
|
|
|
|
&IID_IInternetProtocol, (void**)&protocol);
|
|
|
|
IServiceProvider_Release(service_provider);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!protocol) {
|
|
|
|
IClassFactory *cf;
|
|
|
|
IUnknown *unk;
|
|
|
|
|
2009-03-29 21:31:15 +02:00
|
|
|
hres = get_protocol_handler(szUrl, &clsid, &urlmon_protocol, &cf);
|
2007-01-23 19:36:09 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2007-12-30 17:40:26 +01:00
|
|
|
if(This->from_urlmon) {
|
|
|
|
hres = IClassFactory_CreateInstance(cf, NULL, &IID_IInternetProtocol, (void**)&protocol);
|
|
|
|
IClassFactory_Release(cf);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}else {
|
|
|
|
hres = IClassFactory_CreateInstance(cf, (IUnknown*)BINDINFO(This),
|
|
|
|
&IID_IUnknown, (void**)&unk);
|
|
|
|
IClassFactory_Release(cf);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocol, (void**)&protocol);
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
2007-01-23 19:36:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
StringFromCLSID(&clsid, &clsid_str);
|
|
|
|
IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_PROTOCOLCLASSID, clsid_str);
|
|
|
|
CoTaskMemFree(clsid_str);
|
|
|
|
|
|
|
|
This->protocol = protocol;
|
|
|
|
|
2009-03-29 21:31:15 +02:00
|
|
|
if(urlmon_protocol)
|
|
|
|
IInternetProtocol_QueryInterface(protocol, &IID_IWinInetInfo, (void**)&This->wininet_info);
|
|
|
|
|
2007-01-23 19:36:09 +01:00
|
|
|
IInternetBindInfo_AddRef(pOIBindInfo);
|
|
|
|
This->bind_info = pOIBindInfo;
|
|
|
|
|
2007-12-28 14:53:25 +01:00
|
|
|
set_binding_sink(PROTOCOL(This), pOIProtSink);
|
2007-12-24 12:42:22 +01:00
|
|
|
|
2007-01-23 23:33:38 +01:00
|
|
|
hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetPriority, (void**)&priority);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
IInternetPriority_SetPriority(priority, This->priority);
|
|
|
|
IInternetPriority_Release(priority);
|
|
|
|
}
|
|
|
|
|
2007-01-23 19:36:09 +01:00
|
|
|
return IInternetProtocol_Start(protocol, szUrl, PROTSINK(This), BINDINFO(This), 0, 0);
|
2007-01-23 19:33:30 +01:00
|
|
|
}
|
|
|
|
|
2009-05-18 18:29:24 +02:00
|
|
|
static HRESULT WINAPI ProtocolHandler_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData)
|
2007-01-23 19:33:30 +01:00
|
|
|
{
|
2009-05-18 18:29:24 +02:00
|
|
|
BindProtocol *This = PROTOCOLHANDLER_THIS(iface);
|
2009-06-04 22:50:23 +02:00
|
|
|
HRESULT hres;
|
2007-12-24 12:42:45 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pProtocolData);
|
|
|
|
|
2009-06-04 22:50:23 +02:00
|
|
|
hres = IInternetProtocol_Continue(This->protocol, pProtocolData);
|
|
|
|
|
|
|
|
heap_free(pProtocolData);
|
|
|
|
return hres;
|
2007-01-23 19:33:30 +01:00
|
|
|
}
|
|
|
|
|
2009-05-18 18:29:24 +02:00
|
|
|
static HRESULT WINAPI ProtocolHandler_Abort(IInternetProtocol *iface, HRESULT hrReason,
|
2007-01-23 19:33:30 +01:00
|
|
|
DWORD dwOptions)
|
|
|
|
{
|
2009-05-18 18:29:24 +02:00
|
|
|
BindProtocol *This = PROTOCOLHANDLER_THIS(iface);
|
2007-01-23 19:33:30 +01:00
|
|
|
FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-05-18 18:29:24 +02:00
|
|
|
static HRESULT WINAPI ProtocolHandler_Terminate(IInternetProtocol *iface, DWORD dwOptions)
|
2007-01-23 19:33:30 +01:00
|
|
|
{
|
2009-05-18 18:29:24 +02:00
|
|
|
BindProtocol *This = PROTOCOLHANDLER_THIS(iface);
|
2007-01-23 19:36:09 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%08x)\n", This, dwOptions);
|
|
|
|
|
2007-12-28 14:54:22 +01:00
|
|
|
if(!This->reported_result)
|
|
|
|
return E_FAIL;
|
|
|
|
|
2007-01-23 19:36:09 +01:00
|
|
|
IInternetProtocol_Terminate(This->protocol, 0);
|
2007-12-28 14:54:22 +01:00
|
|
|
|
2009-05-18 18:35:32 +02:00
|
|
|
if(This->filter_proxy) {
|
|
|
|
IInternetProtocol_Release(PROTOCOL(This->filter_proxy));
|
|
|
|
This->filter_proxy = NULL;
|
|
|
|
}
|
|
|
|
|
2007-12-28 14:54:22 +01:00
|
|
|
set_binding_sink(PROTOCOL(This), NULL);
|
|
|
|
|
|
|
|
if(This->bind_info) {
|
|
|
|
IInternetBindInfo_Release(This->bind_info);
|
|
|
|
This->bind_info = NULL;
|
|
|
|
}
|
|
|
|
|
2007-01-23 19:36:09 +01:00
|
|
|
return S_OK;
|
2007-01-23 19:33:30 +01:00
|
|
|
}
|
|
|
|
|
2009-05-18 18:29:24 +02:00
|
|
|
static HRESULT WINAPI ProtocolHandler_Suspend(IInternetProtocol *iface)
|
2007-01-23 19:33:30 +01:00
|
|
|
{
|
2009-05-18 18:29:24 +02:00
|
|
|
BindProtocol *This = PROTOCOLHANDLER_THIS(iface);
|
2007-01-23 19:33:30 +01:00
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-05-18 18:29:24 +02:00
|
|
|
static HRESULT WINAPI ProtocolHandler_Resume(IInternetProtocol *iface)
|
2007-01-23 19:33:30 +01:00
|
|
|
{
|
2009-05-18 18:29:24 +02:00
|
|
|
BindProtocol *This = PROTOCOLHANDLER_THIS(iface);
|
2007-01-23 19:33:30 +01:00
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-05-18 18:29:24 +02:00
|
|
|
static HRESULT WINAPI ProtocolHandler_Read(IInternetProtocol *iface, void *pv,
|
2007-01-23 19:33:30 +01:00
|
|
|
ULONG cb, ULONG *pcbRead)
|
|
|
|
{
|
2009-05-18 18:29:24 +02:00
|
|
|
BindProtocol *This = PROTOCOLHANDLER_THIS(iface);
|
2007-01-23 19:36:09 +01:00
|
|
|
ULONG read = 0;
|
2009-05-14 00:49:01 +02:00
|
|
|
HRESULT hres = S_OK;
|
2007-01-23 19:36:09 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead);
|
|
|
|
|
2009-08-21 00:14:59 +02:00
|
|
|
if(This->buf_size) {
|
2009-05-14 00:49:01 +02:00
|
|
|
read = min(cb, This->buf_size);
|
|
|
|
memcpy(pv, This->buf, read);
|
|
|
|
|
|
|
|
if(read == This->buf_size) {
|
|
|
|
heap_free(This->buf);
|
|
|
|
This->buf = NULL;
|
|
|
|
}else {
|
|
|
|
memmove(This->buf, This->buf+cb, This->buf_size-cb);
|
|
|
|
}
|
|
|
|
|
|
|
|
This->buf_size -= read;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(read < cb) {
|
|
|
|
ULONG cread = 0;
|
|
|
|
|
2009-05-18 18:29:54 +02:00
|
|
|
hres = IInternetProtocol_Read(This->protocol, (BYTE*)pv+read, cb-read, &cread);
|
2009-05-14 00:49:01 +02:00
|
|
|
read += cread;
|
|
|
|
}
|
2007-01-23 19:36:09 +01:00
|
|
|
|
|
|
|
*pcbRead = read;
|
|
|
|
return hres;
|
2007-01-23 19:33:30 +01:00
|
|
|
}
|
|
|
|
|
2009-05-18 18:29:24 +02:00
|
|
|
static HRESULT WINAPI ProtocolHandler_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
|
2007-01-23 19:33:30 +01:00
|
|
|
DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
|
|
|
|
{
|
2009-05-18 18:29:24 +02:00
|
|
|
BindProtocol *This = PROTOCOLHANDLER_THIS(iface);
|
2007-01-23 19:33:30 +01:00
|
|
|
FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-05-18 18:29:24 +02:00
|
|
|
static HRESULT WINAPI ProtocolHandler_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
|
2007-01-23 19:33:30 +01:00
|
|
|
{
|
2009-05-18 18:29:24 +02:00
|
|
|
BindProtocol *This = PROTOCOLHANDLER_THIS(iface);
|
2007-12-24 12:43:01 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%08x)\n", This, dwOptions);
|
|
|
|
|
|
|
|
return IInternetProtocol_LockRequest(This->protocol, dwOptions);
|
2007-01-23 19:33:30 +01:00
|
|
|
}
|
|
|
|
|
2009-05-18 18:29:24 +02:00
|
|
|
static HRESULT WINAPI ProtocolHandler_UnlockRequest(IInternetProtocol *iface)
|
2007-01-23 19:33:30 +01:00
|
|
|
{
|
2009-05-18 18:29:24 +02:00
|
|
|
BindProtocol *This = PROTOCOLHANDLER_THIS(iface);
|
2007-12-24 12:43:01 +01:00
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
return IInternetProtocol_UnlockRequest(This->protocol);
|
2007-01-23 19:33:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef PROTOCOL_THIS
|
|
|
|
|
2009-05-18 18:29:24 +02:00
|
|
|
static const IInternetProtocolVtbl InternetProtocolHandlerVtbl = {
|
|
|
|
ProtocolHandler_QueryInterface,
|
|
|
|
ProtocolHandler_AddRef,
|
|
|
|
ProtocolHandler_Release,
|
|
|
|
ProtocolHandler_Start,
|
|
|
|
ProtocolHandler_Continue,
|
|
|
|
ProtocolHandler_Abort,
|
|
|
|
ProtocolHandler_Terminate,
|
|
|
|
ProtocolHandler_Suspend,
|
|
|
|
ProtocolHandler_Resume,
|
|
|
|
ProtocolHandler_Read,
|
|
|
|
ProtocolHandler_Seek,
|
|
|
|
ProtocolHandler_LockRequest,
|
|
|
|
ProtocolHandler_UnlockRequest
|
2007-01-23 19:33:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#define BINDINFO_THIS(iface) DEFINE_THIS(BindProtocol, InternetBindInfo, iface)
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindInfo_QueryInterface(IInternetBindInfo *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
BindProtocol *This = BINDINFO_THIS(iface);
|
|
|
|
return IInternetProtocol_QueryInterface(PROTOCOL(This), riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BindInfo_AddRef(IInternetBindInfo *iface)
|
|
|
|
{
|
|
|
|
BindProtocol *This = BINDINFO_THIS(iface);
|
|
|
|
return IBinding_AddRef(PROTOCOL(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BindInfo_Release(IInternetBindInfo *iface)
|
|
|
|
{
|
|
|
|
BindProtocol *This = BINDINFO_THIS(iface);
|
|
|
|
return IBinding_Release(PROTOCOL(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindInfo_GetBindInfo(IInternetBindInfo *iface,
|
|
|
|
DWORD *grfBINDF, BINDINFO *pbindinfo)
|
|
|
|
{
|
|
|
|
BindProtocol *This = BINDINFO_THIS(iface);
|
2007-01-23 19:36:09 +01:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p)\n", This, grfBINDF, pbindinfo);
|
|
|
|
|
|
|
|
hres = IInternetBindInfo_GetBindInfo(This->bind_info, grfBINDF, pbindinfo);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("GetBindInfo failed: %08x\n", hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
*grfBINDF |= BINDF_FROMURLMON;
|
|
|
|
return hres;
|
2007-01-23 19:33:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindInfo_GetBindString(IInternetBindInfo *iface,
|
|
|
|
ULONG ulStringType, LPOLESTR *ppwzStr, ULONG cEl, ULONG *pcElFetched)
|
|
|
|
{
|
|
|
|
BindProtocol *This = BINDINFO_THIS(iface);
|
2007-12-24 12:42:09 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%d %p %d %p)\n", This, ulStringType, ppwzStr, cEl, pcElFetched);
|
|
|
|
|
|
|
|
return IInternetBindInfo_GetBindString(This->bind_info, ulStringType, ppwzStr, cEl, pcElFetched);
|
2007-01-23 19:33:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef BINDFO_THIS
|
|
|
|
|
|
|
|
static const IInternetBindInfoVtbl InternetBindInfoVtbl = {
|
|
|
|
BindInfo_QueryInterface,
|
|
|
|
BindInfo_AddRef,
|
|
|
|
BindInfo_Release,
|
|
|
|
BindInfo_GetBindInfo,
|
|
|
|
BindInfo_GetBindString
|
|
|
|
};
|
|
|
|
|
2007-01-23 19:34:00 +01:00
|
|
|
#define PRIORITY_THIS(iface) DEFINE_THIS(BindProtocol, InternetPriority, iface)
|
|
|
|
|
|
|
|
static HRESULT WINAPI InternetPriority_QueryInterface(IInternetPriority *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PRIORITY_THIS(iface);
|
|
|
|
return IInternetProtocol_QueryInterface(PROTOCOL(This), riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InternetPriority_AddRef(IInternetPriority *iface)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PRIORITY_THIS(iface);
|
|
|
|
return IInternetProtocol_AddRef(PROTOCOL(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InternetPriority_Release(IInternetPriority *iface)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PRIORITY_THIS(iface);
|
|
|
|
return IInternetProtocol_Release(PROTOCOL(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InternetPriority_SetPriority(IInternetPriority *iface, LONG nPriority)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PRIORITY_THIS(iface);
|
2007-01-23 23:33:38 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", This, nPriority);
|
|
|
|
|
|
|
|
This->priority = nPriority;
|
|
|
|
return S_OK;
|
2007-01-23 19:34:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InternetPriority_GetPriority(IInternetPriority *iface, LONG *pnPriority)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PRIORITY_THIS(iface);
|
2007-01-23 23:33:38 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pnPriority);
|
|
|
|
|
|
|
|
*pnPriority = This->priority;
|
|
|
|
return S_OK;
|
2007-01-23 19:34:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef PRIORITY_THIS
|
|
|
|
|
|
|
|
static const IInternetPriorityVtbl InternetPriorityVtbl = {
|
|
|
|
InternetPriority_QueryInterface,
|
|
|
|
InternetPriority_AddRef,
|
|
|
|
InternetPriority_Release,
|
|
|
|
InternetPriority_SetPriority,
|
|
|
|
InternetPriority_GetPriority
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2009-05-18 18:31:03 +02:00
|
|
|
#define PROTSINK_THIS(iface) DEFINE_THIS(BindProtocol, IInternetProtocolSink, iface)
|
2007-01-23 19:45:27 +01:00
|
|
|
|
2007-12-28 02:00:53 +01:00
|
|
|
static HRESULT WINAPI BPInternetProtocolSink_QueryInterface(IInternetProtocolSink *iface,
|
2007-01-23 19:45:27 +01:00
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PROTSINK_THIS(iface);
|
|
|
|
return IInternetProtocol_QueryInterface(PROTOCOL(This), riid, ppv);
|
|
|
|
}
|
|
|
|
|
2007-12-28 02:00:53 +01:00
|
|
|
static ULONG WINAPI BPInternetProtocolSink_AddRef(IInternetProtocolSink *iface)
|
2007-01-23 19:45:27 +01:00
|
|
|
{
|
|
|
|
BindProtocol *This = PROTSINK_THIS(iface);
|
|
|
|
return IInternetProtocol_AddRef(PROTOCOL(This));
|
|
|
|
}
|
|
|
|
|
2007-12-28 02:00:53 +01:00
|
|
|
static ULONG WINAPI BPInternetProtocolSink_Release(IInternetProtocolSink *iface)
|
2007-01-23 19:45:27 +01:00
|
|
|
{
|
|
|
|
BindProtocol *This = PROTSINK_THIS(iface);
|
|
|
|
return IInternetProtocol_Release(PROTOCOL(This));
|
|
|
|
}
|
|
|
|
|
2009-05-11 21:59:31 +02:00
|
|
|
typedef struct {
|
|
|
|
task_header_t header;
|
2009-06-04 22:50:23 +02:00
|
|
|
PROTOCOLDATA *data;
|
2009-05-11 21:59:31 +02:00
|
|
|
} switch_task_t;
|
|
|
|
|
|
|
|
static void switch_proc(BindProtocol *bind, task_header_t *t)
|
|
|
|
{
|
|
|
|
switch_task_t *task = (switch_task_t*)t;
|
|
|
|
|
2009-06-04 22:50:23 +02:00
|
|
|
IInternetProtocol_Continue(bind->protocol_handler, task->data);
|
2009-05-11 21:59:31 +02:00
|
|
|
|
|
|
|
heap_free(task);
|
|
|
|
}
|
|
|
|
|
2007-12-28 02:00:53 +01:00
|
|
|
static HRESULT WINAPI BPInternetProtocolSink_Switch(IInternetProtocolSink *iface,
|
2007-01-23 19:45:27 +01:00
|
|
|
PROTOCOLDATA *pProtocolData)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PROTSINK_THIS(iface);
|
2009-06-04 22:50:23 +02:00
|
|
|
PROTOCOLDATA *data;
|
2007-12-24 12:42:32 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pProtocolData);
|
|
|
|
|
2007-12-28 14:54:22 +01:00
|
|
|
TRACE("flags %x state %x data %p cb %u\n", pProtocolData->grfFlags, pProtocolData->dwState,
|
|
|
|
pProtocolData->pData, pProtocolData->cbData);
|
|
|
|
|
2009-06-04 22:50:23 +02:00
|
|
|
data = heap_alloc(sizeof(PROTOCOLDATA));
|
|
|
|
if(!data)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
memcpy(data, pProtocolData, sizeof(PROTOCOLDATA));
|
|
|
|
|
2009-05-11 21:59:31 +02:00
|
|
|
if(!do_direct_notif(This)) {
|
|
|
|
switch_task_t *task;
|
|
|
|
|
|
|
|
task = heap_alloc(sizeof(switch_task_t));
|
|
|
|
if(!task)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2009-06-04 22:50:23 +02:00
|
|
|
task->data = data;
|
2009-05-11 21:59:31 +02:00
|
|
|
|
|
|
|
push_task(This, &task->header, switch_proc);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-12-28 14:54:22 +01:00
|
|
|
if(!This->protocol_sink) {
|
2009-06-04 22:50:23 +02:00
|
|
|
IInternetProtocol_Continue(This->protocol_handler, data);
|
2007-12-28 14:54:22 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-06-04 22:50:23 +02:00
|
|
|
return IInternetProtocolSink_Switch(This->protocol_sink, data);
|
2007-01-23 19:45:27 +01:00
|
|
|
}
|
|
|
|
|
2009-05-14 00:49:01 +02:00
|
|
|
static void report_progress(BindProtocol *This, ULONG status_code, LPCWSTR status_text)
|
|
|
|
{
|
|
|
|
switch(status_code) {
|
|
|
|
case BINDSTATUS_FINDINGRESOURCE:
|
|
|
|
case BINDSTATUS_CONNECTING:
|
|
|
|
case BINDSTATUS_BEGINDOWNLOADDATA:
|
|
|
|
case BINDSTATUS_SENDINGREQUEST:
|
|
|
|
case BINDSTATUS_CACHEFILENAMEAVAILABLE:
|
|
|
|
case BINDSTATUS_DIRECTBIND:
|
|
|
|
case BINDSTATUS_ACCEPTRANGES:
|
|
|
|
if(This->protocol_sink)
|
|
|
|
IInternetProtocolSink_ReportProgress(This->protocol_sink, status_code, status_text);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BINDSTATUS_MIMETYPEAVAILABLE:
|
2009-05-18 18:30:12 +02:00
|
|
|
mime_available(This, status_text, FALSE);
|
2009-05-14 00:49:01 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE:
|
2009-05-18 18:30:12 +02:00
|
|
|
mime_available(This, status_text, TRUE);
|
2009-05-14 00:49:01 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("unsupported ulStatusCode %u\n", status_code);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-11 21:59:54 +02:00
|
|
|
typedef struct {
|
|
|
|
task_header_t header;
|
|
|
|
|
|
|
|
ULONG status_code;
|
|
|
|
LPWSTR status_text;
|
|
|
|
} on_progress_task_t;
|
|
|
|
|
|
|
|
static void on_progress_proc(BindProtocol *This, task_header_t *t)
|
|
|
|
{
|
|
|
|
on_progress_task_t *task = (on_progress_task_t*)t;
|
|
|
|
|
2009-05-14 00:49:01 +02:00
|
|
|
report_progress(This, task->status_code, task->status_text);
|
2009-05-11 21:59:54 +02:00
|
|
|
|
|
|
|
heap_free(task->status_text);
|
|
|
|
heap_free(task);
|
|
|
|
}
|
|
|
|
|
2009-05-14 00:49:01 +02:00
|
|
|
static HRESULT WINAPI BPInternetProtocolSink_ReportProgress(IInternetProtocolSink *iface,
|
|
|
|
ULONG ulStatusCode, LPCWSTR szStatusText)
|
2009-05-11 21:59:54 +02:00
|
|
|
{
|
2009-05-14 00:49:01 +02:00
|
|
|
BindProtocol *This = PROTSINK_THIS(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u %s)\n", This, ulStatusCode, debugstr_w(szStatusText));
|
|
|
|
|
2009-05-11 21:59:54 +02:00
|
|
|
if(do_direct_notif(This)) {
|
2009-05-14 00:49:01 +02:00
|
|
|
report_progress(This, ulStatusCode, szStatusText);
|
2009-05-11 21:59:54 +02:00
|
|
|
}else {
|
|
|
|
on_progress_task_t *task;
|
|
|
|
|
|
|
|
task = heap_alloc(sizeof(on_progress_task_t));
|
|
|
|
|
2009-05-14 00:49:01 +02:00
|
|
|
task->status_code = ulStatusCode;
|
|
|
|
task->status_text = heap_strdupW(szStatusText);
|
2009-05-11 21:59:54 +02:00
|
|
|
|
|
|
|
push_task(This, &task->header, on_progress_proc);
|
|
|
|
}
|
2009-05-14 00:49:01 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2009-05-11 21:59:54 +02:00
|
|
|
}
|
|
|
|
|
2009-05-14 00:49:01 +02:00
|
|
|
static HRESULT report_data(BindProtocol *This, DWORD bscf, ULONG progress, ULONG progress_max)
|
2007-01-23 19:45:27 +01:00
|
|
|
{
|
2009-05-14 00:49:01 +02:00
|
|
|
if(!This->protocol_sink)
|
|
|
|
return S_OK;
|
2007-01-23 19:36:09 +01:00
|
|
|
|
2009-05-14 00:49:01 +02:00
|
|
|
if((This->pi & PI_MIMEVERIFICATION) && !This->reported_mime) {
|
2009-08-21 00:14:59 +02:00
|
|
|
BYTE buf[BUFFER_SIZE];
|
2009-05-14 00:49:01 +02:00
|
|
|
DWORD read = 0;
|
|
|
|
LPWSTR mime;
|
|
|
|
HRESULT hres;
|
2007-01-23 19:36:09 +01:00
|
|
|
|
2009-05-14 00:49:01 +02:00
|
|
|
do {
|
|
|
|
read = 0;
|
2009-08-21 00:14:59 +02:00
|
|
|
hres = IInternetProtocol_Read(This->protocol, buf,
|
|
|
|
sizeof(buf)-This->buf_size, &read);
|
2009-05-20 16:47:32 +02:00
|
|
|
if(FAILED(hres) && hres != E_PENDING)
|
|
|
|
return hres;
|
2009-08-21 00:14:59 +02:00
|
|
|
|
|
|
|
if(!This->buf) {
|
|
|
|
This->buf = heap_alloc(BUFFER_SIZE);
|
|
|
|
if(!This->buf)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}else if(read + This->buf_size > BUFFER_SIZE) {
|
|
|
|
BYTE *tmp;
|
|
|
|
|
|
|
|
tmp = heap_realloc(This->buf, read+This->buf_size);
|
|
|
|
if(!tmp)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
This->buf = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(This->buf+This->buf_size, buf, read);
|
2009-05-14 00:49:01 +02:00
|
|
|
This->buf_size += read;
|
2009-05-20 16:47:32 +02:00
|
|
|
}while(This->buf_size < MIME_TEST_SIZE && hres == S_OK);
|
2009-05-14 00:49:01 +02:00
|
|
|
|
|
|
|
if(This->buf_size < MIME_TEST_SIZE && hres != S_FALSE)
|
2007-12-28 14:53:38 +01:00
|
|
|
return S_OK;
|
2009-05-11 21:59:54 +02:00
|
|
|
|
2009-08-21 00:15:14 +02:00
|
|
|
bscf = BSCF_FIRSTDATANOTIFICATION;
|
|
|
|
if(hres == S_FALSE)
|
|
|
|
bscf |= BSCF_LASTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE;
|
|
|
|
|
2009-08-21 00:14:59 +02:00
|
|
|
if(!This->reported_mime) {
|
|
|
|
hres = FindMimeFromData(NULL, This->url, This->buf, min(This->buf_size, MIME_TEST_SIZE),
|
|
|
|
This->mime, 0, &mime, 0);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2009-05-14 00:49:01 +02:00
|
|
|
|
2009-08-21 00:14:59 +02:00
|
|
|
mime_available(This, mime, TRUE);
|
|
|
|
CoTaskMemFree(mime);
|
|
|
|
}
|
2007-01-23 19:36:09 +01:00
|
|
|
}
|
|
|
|
|
2009-08-21 00:14:59 +02:00
|
|
|
if(!This->protocol_sink)
|
|
|
|
return S_OK;
|
|
|
|
|
2009-05-14 00:49:01 +02:00
|
|
|
return IInternetProtocolSink_ReportData(This->protocol_sink, bscf, progress, progress_max);
|
2007-01-23 19:45:27 +01:00
|
|
|
}
|
|
|
|
|
2009-05-11 22:00:13 +02:00
|
|
|
typedef struct {
|
|
|
|
task_header_t header;
|
|
|
|
DWORD bscf;
|
|
|
|
ULONG progress;
|
|
|
|
ULONG progress_max;
|
|
|
|
} report_data_task_t;
|
|
|
|
|
|
|
|
static void report_data_proc(BindProtocol *This, task_header_t *t)
|
|
|
|
{
|
|
|
|
report_data_task_t *task = (report_data_task_t*)t;
|
|
|
|
|
2009-05-14 00:49:01 +02:00
|
|
|
report_data(This, task->bscf, task->progress, task->progress_max);
|
2009-05-11 22:00:13 +02:00
|
|
|
heap_free(task);
|
|
|
|
}
|
|
|
|
|
2007-12-28 02:00:53 +01:00
|
|
|
static HRESULT WINAPI BPInternetProtocolSink_ReportData(IInternetProtocolSink *iface,
|
2007-01-23 19:45:27 +01:00
|
|
|
DWORD grfBSCF, ULONG ulProgress, ULONG ulProgressMax)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PROTSINK_THIS(iface);
|
2007-01-23 19:36:09 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%d %u %u)\n", This, grfBSCF, ulProgress, ulProgressMax);
|
|
|
|
|
2007-12-28 14:54:22 +01:00
|
|
|
if(!This->protocol_sink)
|
|
|
|
return S_OK;
|
|
|
|
|
2009-05-11 22:00:13 +02:00
|
|
|
if(!do_direct_notif(This)) {
|
|
|
|
report_data_task_t *task;
|
|
|
|
|
|
|
|
task = heap_alloc(sizeof(report_data_task_t));
|
|
|
|
if(!task)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
task->bscf = grfBSCF;
|
|
|
|
task->progress = ulProgress;
|
|
|
|
task->progress_max = ulProgressMax;
|
|
|
|
|
|
|
|
push_task(This, &task->header, report_data_proc);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-05-14 00:49:01 +02:00
|
|
|
return report_data(This, grfBSCF, ulProgress, ulProgressMax);
|
2007-01-23 19:45:27 +01:00
|
|
|
}
|
|
|
|
|
2009-05-11 22:00:26 +02:00
|
|
|
typedef struct {
|
|
|
|
task_header_t header;
|
|
|
|
|
|
|
|
HRESULT hres;
|
|
|
|
DWORD err;
|
|
|
|
LPWSTR str;
|
|
|
|
} report_result_task_t;
|
|
|
|
|
|
|
|
static void report_result_proc(BindProtocol *This, task_header_t *t)
|
|
|
|
{
|
|
|
|
report_result_task_t *task = (report_result_task_t*)t;
|
|
|
|
|
|
|
|
if(This->protocol_sink)
|
|
|
|
IInternetProtocolSink_ReportResult(This->protocol_sink, task->hres, task->err, task->str);
|
|
|
|
|
|
|
|
heap_free(task->str);
|
|
|
|
heap_free(task);
|
|
|
|
}
|
|
|
|
|
2007-12-28 02:00:53 +01:00
|
|
|
static HRESULT WINAPI BPInternetProtocolSink_ReportResult(IInternetProtocolSink *iface,
|
2007-01-23 19:45:27 +01:00
|
|
|
HRESULT hrResult, DWORD dwError, LPCWSTR szResult)
|
|
|
|
{
|
|
|
|
BindProtocol *This = PROTSINK_THIS(iface);
|
2007-01-23 19:36:09 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%08x %d %s)\n", This, hrResult, dwError, debugstr_w(szResult));
|
|
|
|
|
2007-12-28 14:54:22 +01:00
|
|
|
if(!This->protocol_sink)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
This->reported_result = TRUE;
|
|
|
|
|
2009-05-11 22:00:26 +02:00
|
|
|
if(!do_direct_notif(This)) {
|
|
|
|
report_result_task_t *task;
|
|
|
|
|
|
|
|
task = heap_alloc(sizeof(report_result_task_t));
|
|
|
|
if(!task)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
task->hres = hrResult;
|
|
|
|
task->err = dwError;
|
|
|
|
task->str = heap_strdupW(szResult);
|
|
|
|
|
|
|
|
push_task(This, &task->header, report_result_proc);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-01-23 19:36:09 +01:00
|
|
|
return IInternetProtocolSink_ReportResult(This->protocol_sink, hrResult, dwError, szResult);
|
2007-01-23 19:45:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef PROTSINK_THIS
|
|
|
|
|
|
|
|
static const IInternetProtocolSinkVtbl InternetProtocolSinkVtbl = {
|
2007-12-28 02:00:53 +01:00
|
|
|
BPInternetProtocolSink_QueryInterface,
|
|
|
|
BPInternetProtocolSink_AddRef,
|
|
|
|
BPInternetProtocolSink_Release,
|
|
|
|
BPInternetProtocolSink_Switch,
|
|
|
|
BPInternetProtocolSink_ReportProgress,
|
|
|
|
BPInternetProtocolSink_ReportData,
|
|
|
|
BPInternetProtocolSink_ReportResult
|
2007-01-23 19:45:27 +01:00
|
|
|
};
|
|
|
|
|
2009-08-21 00:14:41 +02:00
|
|
|
#define INETINFO_THIS(iface) DEFINE_THIS(BindProtocol, IWinInetHttpInfo, iface)
|
|
|
|
|
|
|
|
static HRESULT WINAPI WinInetHttpInfo_QueryInterface(IWinInetHttpInfo *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
BindProtocol *This = INETINFO_THIS(iface);
|
|
|
|
return IInternetProtocol_QueryInterface(PROTOCOL(This), riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI WinInetHttpInfo_AddRef(IWinInetHttpInfo *iface)
|
|
|
|
{
|
|
|
|
BindProtocol *This = INETINFO_THIS(iface);
|
|
|
|
return IInternetProtocol_AddRef(PROTOCOL(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI WinInetHttpInfo_Release(IWinInetHttpInfo *iface)
|
|
|
|
{
|
|
|
|
BindProtocol *This = INETINFO_THIS(iface);
|
|
|
|
return IInternetProtocol_Release(PROTOCOL(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI WinInetHttpInfo_QueryOption(IWinInetHttpInfo *iface, DWORD dwOption,
|
|
|
|
void *pBuffer, DWORD *pcbBuffer)
|
|
|
|
{
|
|
|
|
BindProtocol *This = INETINFO_THIS(iface);
|
|
|
|
FIXME("(%p)->(%x %p %p)\n", This, dwOption, pBuffer, pcbBuffer);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI WinInetHttpInfo_QueryInfo(IWinInetHttpInfo *iface, DWORD dwOption,
|
|
|
|
void *pBuffer, DWORD *pcbBuffer, DWORD *pdwFlags, DWORD *pdwReserved)
|
|
|
|
{
|
|
|
|
BindProtocol *This = INETINFO_THIS(iface);
|
|
|
|
FIXME("(%p)->(%x %p %p %p %p)\n", This, dwOption, pBuffer, pcbBuffer, pdwFlags, pdwReserved);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef INETINFO_THIS
|
|
|
|
|
|
|
|
static const IWinInetHttpInfoVtbl WinInetHttpInfoVtbl = {
|
|
|
|
WinInetHttpInfo_QueryInterface,
|
|
|
|
WinInetHttpInfo_AddRef,
|
|
|
|
WinInetHttpInfo_Release,
|
|
|
|
WinInetHttpInfo_QueryOption,
|
|
|
|
WinInetHttpInfo_QueryInfo
|
|
|
|
};
|
|
|
|
|
2007-12-24 12:42:22 +01:00
|
|
|
#define SERVPROV_THIS(iface) DEFINE_THIS(BindProtocol, ServiceProvider, iface)
|
|
|
|
|
|
|
|
static HRESULT WINAPI BPServiceProvider_QueryInterface(IServiceProvider *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
BindProtocol *This = SERVPROV_THIS(iface);
|
|
|
|
return IInternetProtocol_QueryInterface(PROTOCOL(This), riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BPServiceProvider_AddRef(IServiceProvider *iface)
|
|
|
|
{
|
|
|
|
BindProtocol *This = SERVPROV_THIS(iface);
|
|
|
|
return IInternetProtocol_AddRef(PROTOCOL(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BPServiceProvider_Release(IServiceProvider *iface)
|
|
|
|
{
|
|
|
|
BindProtocol *This = SERVPROV_THIS(iface);
|
|
|
|
return IInternetProtocol_Release(PROTOCOL(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BPServiceProvider_QueryService(IServiceProvider *iface,
|
|
|
|
REFGUID guidService, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
BindProtocol *This = SERVPROV_THIS(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
if(!This->service_provider)
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
|
|
|
return IServiceProvider_QueryService(This->service_provider, guidService, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef SERVPROV_THIS
|
|
|
|
|
|
|
|
static const IServiceProviderVtbl ServiceProviderVtbl = {
|
|
|
|
BPServiceProvider_QueryInterface,
|
|
|
|
BPServiceProvider_AddRef,
|
|
|
|
BPServiceProvider_Release,
|
|
|
|
BPServiceProvider_QueryService
|
|
|
|
};
|
|
|
|
|
2007-12-30 17:40:26 +01:00
|
|
|
HRESULT create_binding_protocol(LPCWSTR url, BOOL from_urlmon, IInternetProtocol **protocol)
|
2007-01-23 19:33:30 +01:00
|
|
|
{
|
2007-12-28 02:00:37 +01:00
|
|
|
BindProtocol *ret = heap_alloc_zero(sizeof(BindProtocol));
|
2007-01-23 19:33:30 +01:00
|
|
|
|
2009-05-18 18:31:03 +02:00
|
|
|
ret->lpIInternetProtocolVtbl = &BindProtocolVtbl;
|
|
|
|
ret->lpInternetBindInfoVtbl = &InternetBindInfoVtbl;
|
|
|
|
ret->lpInternetPriorityVtbl = &InternetPriorityVtbl;
|
|
|
|
ret->lpServiceProviderVtbl = &ServiceProviderVtbl;
|
|
|
|
ret->lpIInternetProtocolSinkVtbl = &InternetProtocolSinkVtbl;
|
2009-05-18 18:29:24 +02:00
|
|
|
ret->lpIInternetProtocolHandlerVtbl = &InternetProtocolHandlerVtbl;
|
2009-08-21 00:14:41 +02:00
|
|
|
ret->lpIWinInetHttpInfoVtbl = &WinInetHttpInfoVtbl;
|
2007-01-23 19:36:09 +01:00
|
|
|
|
2007-01-23 19:33:30 +01:00
|
|
|
ret->ref = 1;
|
2007-12-30 17:40:26 +01:00
|
|
|
ret->from_urlmon = from_urlmon;
|
2009-05-11 21:59:31 +02:00
|
|
|
ret->apartment_thread = GetCurrentThreadId();
|
|
|
|
ret->notif_hwnd = get_notif_hwnd();
|
2009-05-18 18:29:24 +02:00
|
|
|
ret->protocol_handler = PROTOCOLHANDLER(ret);
|
2009-05-11 21:59:31 +02:00
|
|
|
InitializeCriticalSection(&ret->section);
|
2007-01-23 19:33:30 +01:00
|
|
|
|
2007-07-24 07:15:19 +02:00
|
|
|
URLMON_LockModule();
|
|
|
|
|
2007-01-23 19:33:30 +01:00
|
|
|
*protocol = PROTOCOL(ret);
|
|
|
|
return S_OK;
|
|
|
|
}
|