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);
|
|
|
|
|
2011-01-10 18:25:44 +01:00
|
|
|
typedef void (*task_proc_t)(BindProtocol*,task_header_t*);
|
2009-05-11 21:59:31 +02:00
|
|
|
|
2011-01-10 18:25:44 +01:00
|
|
|
struct _task_header_t {
|
2009-05-11 21:59:31 +02:00
|
|
|
task_proc_t proc;
|
2011-01-10 18:25:44 +01:00
|
|
|
task_header_t *next;
|
2009-05-11 21:59:31 +02:00
|
|
|
};
|
2007-01-23 19:33:30 +01:00
|
|
|
|
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)
|
|
|
|
|
2012-09-03 13:58:30 +02:00
|
|
|
static void process_tasks(BindProtocol *This)
|
2009-05-11 21:59:31 +02:00
|
|
|
{
|
2012-09-03 13:58:30 +02:00
|
|
|
task_header_t *task;
|
2009-05-11 22:02:35 +02:00
|
|
|
|
2012-09-03 13:58:30 +02:00
|
|
|
while(1) {
|
|
|
|
EnterCriticalSection(&This->section);
|
2009-05-11 22:02:35 +02:00
|
|
|
|
2012-09-03 13:58:30 +02:00
|
|
|
task = This->task_queue_head;
|
|
|
|
if(task) {
|
|
|
|
This->task_queue_head = task->next;
|
|
|
|
if(!This->task_queue_head)
|
|
|
|
This->task_queue_tail = NULL;
|
|
|
|
}
|
2009-05-11 22:02:35 +02:00
|
|
|
|
2012-09-03 13:58:30 +02:00
|
|
|
LeaveCriticalSection(&This->section);
|
2009-05-11 22:02:35 +02:00
|
|
|
|
2012-09-03 13:58:30 +02:00
|
|
|
if(!task)
|
|
|
|
break;
|
2009-05-11 22:02:35 +02:00
|
|
|
|
2012-09-03 13:58:30 +02:00
|
|
|
This->continue_call++;
|
|
|
|
task->proc(This, task);
|
|
|
|
This->continue_call--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT WINAPI notif_wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch(msg) {
|
|
|
|
case WM_MK_CONTINUE: {
|
|
|
|
BindProtocol *This = (BindProtocol*)lParam;
|
|
|
|
|
|
|
|
process_tasks(This);
|
2009-05-11 21:59:31 +02:00
|
|
|
|
2011-01-12 00:43:44 +01:00
|
|
|
IInternetProtocolEx_Release(&This->IInternetProtocolEx_iface);
|
2009-05-11 22:02:35 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2014-02-13 18:02:24 +01:00
|
|
|
static ATOM notif_wnd_class;
|
|
|
|
|
|
|
|
static BOOL WINAPI register_notif_wnd_class(INIT_ONCE *once, void *param, void **context)
|
|
|
|
{
|
|
|
|
static WNDCLASSEXW wndclass = {
|
|
|
|
sizeof(wndclass), 0, notif_wnd_proc, 0, 0,
|
|
|
|
NULL, NULL, NULL, NULL, NULL,
|
2020-12-03 00:32:46 +01:00
|
|
|
L"URL Moniker Notification Window", NULL
|
2014-02-13 18:02:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
wndclass.hInstance = hProxyDll;
|
|
|
|
notif_wnd_class = RegisterClassExW(&wndclass);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void unregister_notif_wnd_class(void)
|
|
|
|
{
|
|
|
|
if(notif_wnd_class)
|
|
|
|
UnregisterClassW(MAKEINTRESOURCEW(notif_wnd_class), hProxyDll);
|
|
|
|
}
|
|
|
|
|
2009-05-11 22:02:35 +02:00
|
|
|
HWND get_notif_hwnd(void)
|
|
|
|
{
|
|
|
|
tls_data_t *tls_data;
|
2009-05-11 21:59:31 +02:00
|
|
|
|
2014-02-13 18:02:24 +01:00
|
|
|
static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
|
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
|
|
|
}
|
|
|
|
|
2014-02-13 18:02:24 +01:00
|
|
|
InitOnceExecuteOnce(&init_once, register_notif_wnd_class, NULL, NULL);
|
|
|
|
if(!notif_wnd_class)
|
|
|
|
return NULL;
|
2009-05-11 22:02:35 +02:00
|
|
|
|
2014-02-13 18:02:24 +01:00
|
|
|
tls_data->notif_hwnd = CreateWindowExW(0, MAKEINTRESOURCEW(notif_wnd_class),
|
2020-12-03 00:32:46 +01:00
|
|
|
L"URL Moniker Notification Window", 0, 0, 0, 0, 0, HWND_MESSAGE,
|
2010-04-08 19:24:04 +02:00
|
|
|
NULL, hProxyDll, NULL);
|
2009-05-11 22:02:35 +02:00
|
|
|
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;
|
2009-11-16 23:58:05 +01:00
|
|
|
do_post = !This->continue_call;
|
2009-05-11 21:59:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&This->section);
|
|
|
|
|
|
|
|
if(do_post) {
|
2011-01-12 00:43:44 +01:00
|
|
|
IInternetProtocolEx_AddRef(&This->IInternetProtocolEx_iface);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-03 13:58:55 +02:00
|
|
|
static inline BOOL is_apartment_thread(BindProtocol *This)
|
|
|
|
{
|
|
|
|
return This->apartment_thread == GetCurrentThreadId();
|
|
|
|
}
|
|
|
|
|
2009-05-18 21:07:41 +02:00
|
|
|
static inline BOOL do_direct_notif(BindProtocol *This)
|
2009-05-11 21:59:31 +02:00
|
|
|
{
|
2012-09-03 13:58:55 +02:00
|
|
|
return !(This->pi & PI_APARTMENTTHREADED) || (is_apartment_thread(This) && !This->continue_call);
|
2009-05-11 21:59:31 +02:00
|
|
|
}
|
|
|
|
|
2012-03-16 15:00:29 +01:00
|
|
|
static HRESULT handle_mime_filter(BindProtocol *This, IInternetProtocol *mime_filter)
|
2009-05-18 18:35:32 +02:00
|
|
|
{
|
|
|
|
PROTOCOLFILTERDATA filter_data = { sizeof(PROTOCOLFILTERDATA), NULL, NULL, NULL, 0 };
|
|
|
|
HRESULT hres;
|
|
|
|
|
2012-03-16 15:00:29 +01:00
|
|
|
hres = IInternetProtocol_QueryInterface(mime_filter, &IID_IInternetProtocolSink, (void**)&This->protocol_sink_handler);
|
2009-05-18 18:35:32 +02:00
|
|
|
if(FAILED(hres)) {
|
2012-03-16 15:00:29 +01:00
|
|
|
This->protocol_sink_handler = &This->default_protocol_handler.IInternetProtocolSink_iface;
|
2009-05-18 18:35:32 +02:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
IInternetProtocol_AddRef(mime_filter);
|
|
|
|
This->protocol_handler = mime_filter;
|
|
|
|
|
2012-03-16 15:00:29 +01:00
|
|
|
filter_data.pProtocol = &This->default_protocol_handler.IInternetProtocol_iface;
|
|
|
|
hres = IInternetProtocol_Start(mime_filter, This->mime, &This->default_protocol_handler.IInternetProtocolSink_iface,
|
2011-01-12 00:47:19 +01:00
|
|
|
&This->IInternetBindInfo_iface, PI_FILTER_MODE|PI_FORCE_ASYNC,
|
|
|
|
(HANDLE_PTR)&filter_data);
|
2009-05-18 18:35:32 +02:00
|
|
|
if(FAILED(hres)) {
|
2012-03-16 15:00:29 +01:00
|
|
|
IInternetProtocolSink_Release(This->protocol_sink_handler);
|
|
|
|
IInternetProtocol_Release(This->protocol_handler);
|
|
|
|
This->protocol_sink_handler = &This->default_protocol_handler.IInternetProtocolSink_iface;
|
|
|
|
This->protocol_handler = &This->default_protocol_handler.IInternetProtocol_iface;
|
2009-05-18 18:35:32 +02:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2013-11-20 23:39:28 +01:00
|
|
|
/* NOTE: IE9 calls it on the new protocol_sink. It doesn't make sense so it seems to be a bug there. */
|
2012-03-16 15:00:29 +01:00
|
|
|
IInternetProtocolSink_ReportProgress(This->protocol_sink, BINDSTATUS_LOADINGMIMEHANDLER, NULL);
|
2009-05-18 18:35:32 +02:00
|
|
|
|
|
|
|
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);
|
2012-03-16 15:00:29 +01:00
|
|
|
This->mime = heap_strdupW(mime);
|
2009-05-18 18:30:12 +02:00
|
|
|
|
2012-03-16 15:00:29 +01:00
|
|
|
if(This->protocol_handler==&This->default_protocol_handler.IInternetProtocol_iface
|
|
|
|
&& (mime_filter = get_mime_filter(mime))) {
|
2009-05-18 18:35:32 +02:00
|
|
|
TRACE("Got mime filter for %s\n", debugstr_w(mime));
|
2009-05-18 18:30:12 +02:00
|
|
|
|
2012-03-16 15:00:29 +01:00
|
|
|
hres = handle_mime_filter(This, mime_filter);
|
2009-05-18 18:35:32 +02:00
|
|
|
IInternetProtocol_Release(mime_filter);
|
|
|
|
if(FAILED(hres))
|
2022-02-18 09:18:16 +01:00
|
|
|
FIXME("MIME filter failed: %08lx\n", hres);
|
2012-03-16 15:00:29 +01:00
|
|
|
}
|
2009-05-18 18:35:32 +02:00
|
|
|
|
2012-03-16 15:00:29 +01:00
|
|
|
if(This->reported_mime || verified || !(This->pi & PI_MIMEVERIFICATION)) {
|
|
|
|
This->reported_mime = TRUE;
|
|
|
|
IInternetProtocolSink_ReportProgress(This->protocol_sink, BINDSTATUS_MIMETYPEAVAILABLE, mime);
|
2009-05-18 18:30:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-12 00:43:44 +01:00
|
|
|
static inline BindProtocol *impl_from_IInternetProtocolEx(IInternetProtocolEx *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BindProtocol, IInternetProtocolEx_iface);
|
|
|
|
}
|
2007-01-23 19:33:30 +01:00
|
|
|
|
2010-11-10 13:23:34 +01:00
|
|
|
static HRESULT WINAPI BindProtocol_QueryInterface(IInternetProtocolEx *iface, REFIID riid, void **ppv)
|
2007-01-23 19:33:30 +01:00
|
|
|
{
|
2011-01-12 00:43:44 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2007-01-23 19:33:30 +01:00
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
2011-01-12 00:43:44 +01:00
|
|
|
*ppv = &This->IInternetProtocolEx_iface;
|
2007-01-23 19:33:30 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv);
|
2011-01-12 00:43:44 +01:00
|
|
|
*ppv = &This->IInternetProtocolEx_iface;
|
2007-01-23 19:33:30 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv);
|
2011-01-12 00:43:44 +01:00
|
|
|
*ppv = &This->IInternetProtocolEx_iface;
|
2010-11-10 13:23:34 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IInternetProtocolEx, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetProtocolEx %p)\n", This, ppv);
|
2011-01-12 00:43:44 +01:00
|
|
|
*ppv = &This->IInternetProtocolEx_iface;
|
2007-01-23 19:33:30 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IInternetBindInfo, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetBindInfo %p)\n", This, ppv);
|
2011-01-12 00:47:19 +01:00
|
|
|
*ppv = &This->IInternetBindInfo_iface;
|
2007-01-23 19:34:00 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IInternetPriority, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetPriority %p)\n", This, ppv);
|
2011-01-12 00:47:19 +01:00
|
|
|
*ppv = &This->IInternetPriority_iface;
|
2007-01-23 19:34:00 +01:00
|
|
|
}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);
|
2011-01-12 00:47:19 +01:00
|
|
|
*ppv = &This->IServiceProvider_iface;
|
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);
|
2011-01-12 00:47:19 +01:00
|
|
|
*ppv = &This->IInternetProtocolSink_iface;
|
2018-05-09 14:58:59 +02:00
|
|
|
}else if(This->protocol_unk) {
|
|
|
|
HRESULT hres;
|
|
|
|
hres = IUnknown_QueryInterface(This->protocol_unk, riid, ppv);
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p) aggregated handler returned %08lx for %s\n", This, hres, debugstr_guid(riid));
|
2018-05-09 14:58:59 +02:00
|
|
|
return hres;
|
2009-08-21 00:14:41 +02:00
|
|
|
}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
|
|
|
}
|
|
|
|
|
2010-11-10 13:23:34 +01:00
|
|
|
static ULONG WINAPI BindProtocol_AddRef(IInternetProtocolEx *iface)
|
2007-01-23 19:33:30 +01:00
|
|
|
{
|
2011-01-12 00:43:44 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2007-01-23 19:33:30 +01:00
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p) ref=%ld\n", This, ref);
|
2007-01-23 19:33:30 +01:00
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2017-06-06 17:15:40 +02:00
|
|
|
static void release_protocol_handler(BindProtocol *This)
|
|
|
|
{
|
|
|
|
if(This->protocol) {
|
|
|
|
IInternetProtocol_Release(This->protocol);
|
|
|
|
This->protocol = NULL;
|
|
|
|
}
|
|
|
|
if(This->protocol_handler && This->protocol_handler != &This->default_protocol_handler.IInternetProtocol_iface) {
|
|
|
|
IInternetProtocol_Release(This->protocol_handler);
|
|
|
|
This->protocol_handler = &This->default_protocol_handler.IInternetProtocol_iface;
|
|
|
|
}
|
|
|
|
if(This->protocol_sink_handler &&
|
|
|
|
This->protocol_sink_handler != &This->default_protocol_handler.IInternetProtocolSink_iface) {
|
|
|
|
IInternetProtocolSink_Release(This->protocol_sink_handler);
|
|
|
|
This->protocol_sink_handler = &This->default_protocol_handler.IInternetProtocolSink_iface;
|
|
|
|
}
|
2018-05-22 10:13:59 +02:00
|
|
|
if(This->protocol_unk) {
|
|
|
|
IUnknown_Release(This->protocol_unk);
|
|
|
|
This->protocol_unk = NULL;
|
|
|
|
}
|
2017-06-06 17:15:40 +02:00
|
|
|
}
|
|
|
|
|
2010-11-10 13:23:34 +01:00
|
|
|
static ULONG WINAPI BindProtocol_Release(IInternetProtocolEx *iface)
|
2007-01-23 19:33:30 +01:00
|
|
|
{
|
2011-01-12 00:43:44 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2007-01-23 19:33:30 +01:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p) ref=%ld\n", This, ref);
|
2007-01-23 19:33:30 +01:00
|
|
|
|
|
|
|
if(!ref) {
|
2017-06-06 17:15:40 +02:00
|
|
|
release_protocol_handler(This);
|
|
|
|
if(This->redirect_callback)
|
|
|
|
IBindCallbackRedirect_Release(This->redirect_callback);
|
2007-01-23 19:36:09 +01:00
|
|
|
if(This->bind_info)
|
|
|
|
IInternetBindInfo_Release(This->bind_info);
|
2010-11-10 13:23:34 +01:00
|
|
|
if(This->uri)
|
|
|
|
IUri_Release(This->uri);
|
2012-01-20 14:52:16 +01:00
|
|
|
SysFreeString(This->display_uri);
|
2007-01-23 19:36:09 +01:00
|
|
|
|
2011-01-10 18:25:44 +01:00
|
|
|
set_binding_sink(This, NULL, NULL);
|
2009-05-11 21:59:31 +02:00
|
|
|
|
|
|
|
if(This->notif_hwnd)
|
|
|
|
release_notif_hwnd(This->notif_hwnd);
|
2011-11-14 15:09:42 +01:00
|
|
|
This->section.DebugInfo->Spare[0] = 0;
|
2009-05-11 21:59:31 +02:00
|
|
|
DeleteCriticalSection(&This->section);
|
2009-05-14 00:49:01 +02:00
|
|
|
|
|
|
|
heap_free(This->mime);
|
2007-11-29 22:12:34 +01:00
|
|
|
heap_free(This);
|
2007-01-23 19:33:30 +01:00
|
|
|
|
|
|
|
URLMON_UnlockModule();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2010-11-10 13:23:34 +01:00
|
|
|
static HRESULT WINAPI BindProtocol_Start(IInternetProtocolEx *iface, LPCWSTR szUrl,
|
2007-01-23 19:33:30 +01:00
|
|
|
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
|
|
|
{
|
2011-01-12 00:43:44 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2010-11-15 12:36:01 +01:00
|
|
|
IUri *uri;
|
|
|
|
HRESULT hres;
|
2009-05-18 18:29:24 +02:00
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p)->(%s %p %p %08lx %Ix)\n", This, debugstr_w(szUrl), pOIProtSink,
|
2009-05-18 18:29:24 +02:00
|
|
|
pOIBindInfo, grfPI, dwReserved);
|
|
|
|
|
2010-11-15 12:36:01 +01:00
|
|
|
hres = CreateUri(szUrl, Uri_CREATE_FILE_USE_DOS_PATH, 0, &uri);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2011-01-12 00:43:44 +01:00
|
|
|
hres = IInternetProtocolEx_StartEx(&This->IInternetProtocolEx_iface, uri, pOIProtSink,
|
|
|
|
pOIBindInfo, grfPI, (HANDLE*)dwReserved);
|
2010-11-10 13:23:34 +01:00
|
|
|
|
2010-11-15 12:36:01 +01:00
|
|
|
IUri_Release(uri);
|
|
|
|
return hres;
|
2009-05-18 18:29:24 +02:00
|
|
|
}
|
|
|
|
|
2010-11-10 13:23:34 +01:00
|
|
|
static HRESULT WINAPI BindProtocol_Continue(IInternetProtocolEx *iface, PROTOCOLDATA *pProtocolData)
|
2009-05-18 18:29:24 +02:00
|
|
|
{
|
2011-01-12 00:43:44 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2009-05-18 18:29:24 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pProtocolData);
|
|
|
|
|
|
|
|
return IInternetProtocol_Continue(This->protocol_handler, pProtocolData);
|
|
|
|
}
|
|
|
|
|
2010-11-10 13:23:34 +01:00
|
|
|
static HRESULT WINAPI BindProtocol_Abort(IInternetProtocolEx *iface, HRESULT hrReason,
|
2009-05-18 18:29:24 +02:00
|
|
|
DWORD dwOptions)
|
|
|
|
{
|
2011-01-12 00:43:44 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2010-10-04 14:00:48 +02:00
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p)->(%08lx %08lx)\n", This, hrReason, dwOptions);
|
2010-10-04 14:00:48 +02:00
|
|
|
|
|
|
|
return IInternetProtocol_Abort(This->protocol_handler, hrReason, dwOptions);
|
2009-05-18 18:29:24 +02:00
|
|
|
}
|
|
|
|
|
2010-11-10 13:23:34 +01:00
|
|
|
static HRESULT WINAPI BindProtocol_Terminate(IInternetProtocolEx *iface, DWORD dwOptions)
|
2009-05-18 18:29:24 +02:00
|
|
|
{
|
2011-01-12 00:43:44 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2009-05-18 18:29:24 +02:00
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p)->(%08lx)\n", This, dwOptions);
|
2009-05-18 18:29:24 +02:00
|
|
|
|
|
|
|
return IInternetProtocol_Terminate(This->protocol_handler, dwOptions);
|
|
|
|
}
|
|
|
|
|
2010-11-10 13:23:34 +01:00
|
|
|
static HRESULT WINAPI BindProtocol_Suspend(IInternetProtocolEx *iface)
|
2009-05-18 18:29:24 +02:00
|
|
|
{
|
2011-01-12 00:43:44 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2009-05-18 18:29:24 +02:00
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2010-11-10 13:23:34 +01:00
|
|
|
static HRESULT WINAPI BindProtocol_Resume(IInternetProtocolEx *iface)
|
2009-05-18 18:29:24 +02:00
|
|
|
{
|
2011-01-12 00:43:44 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2009-05-18 18:29:24 +02:00
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2010-11-10 13:23:34 +01:00
|
|
|
static HRESULT WINAPI BindProtocol_Read(IInternetProtocolEx *iface, void *pv,
|
2009-05-18 18:29:24 +02:00
|
|
|
ULONG cb, ULONG *pcbRead)
|
|
|
|
{
|
2011-01-12 00:43:44 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2009-05-18 18:29:24 +02:00
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p)->(%p %lu %p)\n", This, pv, cb, pcbRead);
|
2009-05-18 18:29:24 +02:00
|
|
|
|
|
|
|
if(pcbRead)
|
|
|
|
*pcbRead = 0;
|
|
|
|
return IInternetProtocol_Read(This->protocol_handler, pv, cb, pcbRead);
|
|
|
|
}
|
|
|
|
|
2010-11-10 13:23:34 +01:00
|
|
|
static HRESULT WINAPI BindProtocol_Seek(IInternetProtocolEx *iface, LARGE_INTEGER dlibMove,
|
2009-05-18 18:29:24 +02:00
|
|
|
DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
|
|
|
|
{
|
2011-01-12 00:43:44 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2022-02-18 09:18:16 +01:00
|
|
|
FIXME("(%p)->(%ld %ld %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
|
2009-05-18 18:29:24 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2010-11-10 13:23:34 +01:00
|
|
|
static HRESULT WINAPI BindProtocol_LockRequest(IInternetProtocolEx *iface, DWORD dwOptions)
|
2009-05-18 18:29:24 +02:00
|
|
|
{
|
2011-01-12 00:43:44 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2009-05-18 18:29:24 +02:00
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p)->(%08lx)\n", This, dwOptions);
|
2009-05-18 18:29:24 +02:00
|
|
|
|
|
|
|
return IInternetProtocol_LockRequest(This->protocol_handler, dwOptions);
|
|
|
|
}
|
|
|
|
|
2010-11-10 13:23:34 +01:00
|
|
|
static HRESULT WINAPI BindProtocol_UnlockRequest(IInternetProtocolEx *iface)
|
2009-05-18 18:29:24 +02:00
|
|
|
{
|
2011-01-12 00:43:44 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2009-05-18 18:29:24 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
return IInternetProtocol_UnlockRequest(This->protocol_handler);
|
|
|
|
}
|
|
|
|
|
2010-11-10 13:23:34 +01:00
|
|
|
static HRESULT WINAPI BindProtocol_StartEx(IInternetProtocolEx *iface, IUri *pUri,
|
|
|
|
IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
|
|
|
|
DWORD grfPI, HANDLE *dwReserved)
|
|
|
|
{
|
2011-01-12 00:43:44 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2010-11-15 12:36:20 +01:00
|
|
|
IInternetProtocol *protocol = NULL;
|
|
|
|
IInternetProtocolEx *protocolex;
|
|
|
|
IInternetPriority *priority;
|
|
|
|
IServiceProvider *service_provider;
|
|
|
|
CLSID clsid = IID_NULL;
|
2018-05-08 18:18:06 +02:00
|
|
|
IUnknown *protocol_unk = NULL;
|
2010-11-15 12:36:20 +01:00
|
|
|
LPOLESTR clsid_str;
|
|
|
|
HRESULT hres;
|
2010-11-10 13:23:34 +01:00
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p)->(%p %p %p %08lx %p)\n", This, pUri, pOIProtSink, pOIBindInfo, grfPI, dwReserved);
|
2010-11-10 13:23:34 +01:00
|
|
|
|
2010-11-15 12:36:20 +01:00
|
|
|
if(!pUri || !pOIProtSink || !pOIBindInfo)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
This->pi = grfPI;
|
|
|
|
|
2017-06-06 17:15:32 +02:00
|
|
|
if(This->uri) {
|
2017-07-07 17:15:12 +02:00
|
|
|
SysFreeString(This->display_uri);
|
2017-06-06 17:15:32 +02:00
|
|
|
IUri_Release(This->uri);
|
|
|
|
}
|
2010-11-15 12:36:20 +01:00
|
|
|
IUri_AddRef(pUri);
|
|
|
|
This->uri = pUri;
|
|
|
|
|
|
|
|
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);
|
2010-11-10 13:23:34 +01:00
|
|
|
}
|
|
|
|
|
2010-11-15 12:36:20 +01:00
|
|
|
if(!protocol) {
|
|
|
|
IClassFactory *cf;
|
|
|
|
|
2018-05-08 18:18:17 +02:00
|
|
|
hres = get_protocol_handler(pUri, &clsid, &cf);
|
2010-11-15 12:36:20 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2018-05-09 14:58:49 +02:00
|
|
|
hres = IClassFactory_CreateInstance(cf, (IUnknown*)&This->IInternetBindInfo_iface,
|
|
|
|
&IID_IUnknown, (void**)&protocol_unk);
|
2019-05-22 15:32:12 +02:00
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
hres = IUnknown_QueryInterface(protocol_unk, &IID_IInternetProtocol, (void**)&protocol);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
This->protocol_unk = protocol_unk;
|
|
|
|
else
|
|
|
|
IUnknown_Release(protocol_unk);
|
|
|
|
}
|
|
|
|
else if(hres == CLASS_E_NOAGGREGATION)
|
|
|
|
hres = IClassFactory_CreateInstance(cf, NULL, &IID_IInternetProtocol, (void**)&protocol);
|
|
|
|
|
2018-05-09 14:58:49 +02:00
|
|
|
IClassFactory_Release(cf);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2010-11-15 12:36:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
StringFromCLSID(&clsid, &clsid_str);
|
|
|
|
IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_PROTOCOLCLASSID, clsid_str);
|
|
|
|
CoTaskMemFree(clsid_str);
|
|
|
|
|
2018-05-08 18:18:06 +02:00
|
|
|
This->protocol_unk = protocol_unk;
|
2010-11-15 12:36:20 +01:00
|
|
|
This->protocol = protocol;
|
|
|
|
|
2018-05-09 14:58:27 +02:00
|
|
|
if(!protocol_unk)
|
|
|
|
protocol_unk = (IUnknown*)protocol;
|
|
|
|
|
2011-01-10 18:25:44 +01:00
|
|
|
set_binding_sink(This, pOIProtSink, pOIBindInfo);
|
2010-11-15 12:36:20 +01:00
|
|
|
|
2018-05-09 14:58:27 +02:00
|
|
|
hres = IUnknown_QueryInterface(protocol_unk, &IID_IInternetPriority, (void**)&priority);
|
2010-11-15 12:36:20 +01:00
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
IInternetPriority_SetPriority(priority, This->priority);
|
|
|
|
IInternetPriority_Release(priority);
|
|
|
|
}
|
|
|
|
|
2018-05-09 14:58:27 +02:00
|
|
|
hres = IUnknown_QueryInterface(protocol_unk, &IID_IInternetProtocolEx, (void**)&protocolex);
|
2010-11-15 12:36:20 +01:00
|
|
|
if(SUCCEEDED(hres)) {
|
2011-01-12 00:47:19 +01:00
|
|
|
hres = IInternetProtocolEx_StartEx(protocolex, pUri, &This->IInternetProtocolSink_iface,
|
|
|
|
&This->IInternetBindInfo_iface, 0, NULL);
|
2010-11-15 12:36:20 +01:00
|
|
|
IInternetProtocolEx_Release(protocolex);
|
|
|
|
}else {
|
2012-01-20 14:52:16 +01:00
|
|
|
hres = IUri_GetDisplayUri(pUri, &This->display_uri);
|
2010-11-15 12:36:20 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2012-01-20 14:52:16 +01:00
|
|
|
hres = IInternetProtocol_Start(protocol, This->display_uri, &This->IInternetProtocolSink_iface,
|
2011-01-12 00:47:19 +01:00
|
|
|
&This->IInternetBindInfo_iface, 0, 0);
|
2010-11-15 12:36:20 +01:00
|
|
|
}
|
|
|
|
|
2012-09-03 13:58:30 +02:00
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
process_tasks(This);
|
2010-11-15 12:36:20 +01:00
|
|
|
return hres;
|
2010-11-10 13:23:34 +01:00
|
|
|
}
|
|
|
|
|
2011-01-10 18:25:44 +01:00
|
|
|
void set_binding_sink(BindProtocol *This, IInternetProtocolSink *sink, IInternetBindInfo *bind_info)
|
2009-05-18 18:29:24 +02:00
|
|
|
{
|
|
|
|
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);
|
2010-10-01 13:56:56 +02:00
|
|
|
|
|
|
|
if(bind_info)
|
|
|
|
IInternetBindInfo_AddRef(bind_info);
|
|
|
|
bind_info = InterlockedExchangePointer((void**)&This->bind_info, bind_info);
|
|
|
|
if(bind_info)
|
|
|
|
IInternetBindInfo_Release(bind_info);
|
2009-05-18 18:29:24 +02:00
|
|
|
}
|
|
|
|
|
2010-11-10 13:23:34 +01:00
|
|
|
static const IInternetProtocolExVtbl BindProtocolVtbl = {
|
2009-05-18 18:29:24 +02:00
|
|
|
BindProtocol_QueryInterface,
|
|
|
|
BindProtocol_AddRef,
|
|
|
|
BindProtocol_Release,
|
|
|
|
BindProtocol_Start,
|
|
|
|
BindProtocol_Continue,
|
|
|
|
BindProtocol_Abort,
|
|
|
|
BindProtocol_Terminate,
|
|
|
|
BindProtocol_Suspend,
|
|
|
|
BindProtocol_Resume,
|
|
|
|
BindProtocol_Read,
|
|
|
|
BindProtocol_Seek,
|
|
|
|
BindProtocol_LockRequest,
|
2010-11-10 13:23:34 +01:00
|
|
|
BindProtocol_UnlockRequest,
|
|
|
|
BindProtocol_StartEx
|
2009-05-18 18:29:24 +02:00
|
|
|
};
|
|
|
|
|
2010-11-30 12:40:08 +01:00
|
|
|
static inline BindProtocol *impl_from_IInternetProtocol(IInternetProtocol *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BindProtocol, default_protocol_handler.IInternetProtocol_iface);
|
|
|
|
}
|
2009-05-18 18:29:24 +02:00
|
|
|
|
2010-11-15 12:36:41 +01:00
|
|
|
static HRESULT WINAPI ProtocolHandler_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
|
2009-05-18 18:29:24 +02:00
|
|
|
{
|
2012-03-16 15:00:29 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocol(iface);
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
|
|
|
*ppv = &This->default_protocol_handler.IInternetProtocol_iface;
|
|
|
|
}else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv);
|
|
|
|
*ppv = &This->default_protocol_handler.IInternetProtocol_iface;
|
|
|
|
}else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv);
|
|
|
|
*ppv = &This->default_protocol_handler.IInternetProtocol_iface;
|
|
|
|
}else if(IsEqualGUID(&IID_IInternetProtocolSink, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetProtocolSink %p)\n", This, ppv);
|
|
|
|
*ppv = &This->default_protocol_handler.IInternetProtocolSink_iface;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppv) {
|
|
|
|
IInternetProtocol_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("not supported interface %s\n", debugstr_guid(riid));
|
2009-05-18 18:29:24 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2010-11-15 12:36:41 +01:00
|
|
|
static ULONG WINAPI ProtocolHandler_AddRef(IInternetProtocol *iface)
|
2009-05-18 18:29:24 +02:00
|
|
|
{
|
2010-11-30 12:40:08 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocol(iface);
|
2011-01-12 00:43:44 +01:00
|
|
|
return IInternetProtocolEx_AddRef(&This->IInternetProtocolEx_iface);
|
2009-05-18 18:29:24 +02:00
|
|
|
}
|
|
|
|
|
2010-11-15 12:36:41 +01:00
|
|
|
static ULONG WINAPI ProtocolHandler_Release(IInternetProtocol *iface)
|
2009-05-18 18:29:24 +02:00
|
|
|
{
|
2010-11-30 12:40:08 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocol(iface);
|
2011-01-12 00:43:44 +01:00
|
|
|
return IInternetProtocolEx_Release(&This->IInternetProtocolEx_iface);
|
2009-05-18 18:29:24 +02:00
|
|
|
}
|
|
|
|
|
2010-11-15 12:36:41 +01:00
|
|
|
static HRESULT WINAPI ProtocolHandler_Start(IInternetProtocol *iface, LPCWSTR szUrl,
|
2009-05-18 18:29:24 +02:00
|
|
|
IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
|
|
|
|
DWORD grfPI, HANDLE_PTR dwReserved)
|
|
|
|
{
|
2010-11-15 12:36:01 +01:00
|
|
|
ERR("Should not be called\n");
|
|
|
|
return E_NOTIMPL;
|
2007-01-23 19:33:30 +01:00
|
|
|
}
|
|
|
|
|
2010-11-15 12:36:41 +01:00
|
|
|
static HRESULT WINAPI ProtocolHandler_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData)
|
2007-01-23 19:33:30 +01:00
|
|
|
{
|
2010-11-30 12:40:08 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocol(iface);
|
2018-05-22 10:13:59 +02:00
|
|
|
IInternetProtocol *protocol = NULL;
|
2009-06-04 22:50:23 +02:00
|
|
|
HRESULT hres;
|
2007-12-24 12:42:45 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pProtocolData);
|
|
|
|
|
2018-05-08 18:18:22 +02:00
|
|
|
/* FIXME: This should not be needed. */
|
2018-05-22 10:13:59 +02:00
|
|
|
if(!This->protocol) {
|
|
|
|
if(!This->protocol_unk)
|
|
|
|
return E_FAIL;
|
2018-05-08 18:18:22 +02:00
|
|
|
hres = IUnknown_QueryInterface(This->protocol_unk, &IID_IInternetProtocol, (void**)&protocol);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2018-05-22 10:13:59 +02:00
|
|
|
hres = IInternetProtocol_Continue(protocol ? protocol : This->protocol, pProtocolData);
|
2009-06-04 22:50:23 +02:00
|
|
|
|
|
|
|
heap_free(pProtocolData);
|
2018-05-22 10:13:59 +02:00
|
|
|
if(protocol)
|
|
|
|
IInternetProtocol_Release(protocol);
|
2009-06-04 22:50:23 +02:00
|
|
|
return hres;
|
2007-01-23 19:33:30 +01:00
|
|
|
}
|
|
|
|
|
2010-11-15 12:36:41 +01:00
|
|
|
static HRESULT WINAPI ProtocolHandler_Abort(IInternetProtocol *iface, HRESULT hrReason,
|
2007-01-23 19:33:30 +01:00
|
|
|
DWORD dwOptions)
|
|
|
|
{
|
2010-11-30 12:40:08 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocol(iface);
|
2010-10-04 14:00:48 +02:00
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p)->(%08lx %08lx)\n", This, hrReason, dwOptions);
|
2010-10-04 14:00:48 +02:00
|
|
|
|
|
|
|
if(This->protocol && !This->reported_result)
|
|
|
|
return IInternetProtocol_Abort(This->protocol, hrReason, dwOptions);
|
|
|
|
|
|
|
|
return S_OK;
|
2007-01-23 19:33:30 +01:00
|
|
|
}
|
|
|
|
|
2010-11-15 12:36:41 +01:00
|
|
|
static HRESULT WINAPI ProtocolHandler_Terminate(IInternetProtocol *iface, DWORD dwOptions)
|
2007-01-23 19:33:30 +01:00
|
|
|
{
|
2010-11-30 12:40:08 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocol(iface);
|
2007-01-23 19:36:09 +01:00
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p)->(%08lx)\n", This, dwOptions);
|
2007-01-23 19:36:09 +01:00
|
|
|
|
2007-12-28 14:54:22 +01:00
|
|
|
if(!This->reported_result)
|
|
|
|
return E_FAIL;
|
|
|
|
|
2014-05-15 18:56:51 +02:00
|
|
|
/* This may get released in Terminate call. */
|
|
|
|
IInternetProtocolEx_AddRef(&This->IInternetProtocolEx_iface);
|
|
|
|
|
2018-05-08 18:18:22 +02:00
|
|
|
if(This->protocol) {
|
|
|
|
IInternetProtocol_Terminate(This->protocol, 0);
|
2019-05-22 15:32:12 +02:00
|
|
|
|
|
|
|
if (This->protocol_unk) {
|
|
|
|
IInternetProtocol_Release(This->protocol);
|
|
|
|
This->protocol = NULL;
|
|
|
|
}
|
2018-05-08 18:18:22 +02:00
|
|
|
}
|
2007-12-28 14:54:22 +01:00
|
|
|
|
2011-01-10 18:25:44 +01:00
|
|
|
set_binding_sink(This, NULL, NULL);
|
2007-12-28 14:54:22 +01:00
|
|
|
|
|
|
|
if(This->bind_info) {
|
|
|
|
IInternetBindInfo_Release(This->bind_info);
|
|
|
|
This->bind_info = NULL;
|
|
|
|
}
|
|
|
|
|
2017-06-06 17:15:55 +02:00
|
|
|
if(This->redirect_callback) {
|
|
|
|
IBindCallbackRedirect_Release(This->redirect_callback);
|
|
|
|
This->redirect_callback = NULL;
|
|
|
|
}
|
|
|
|
|
2014-05-15 18:56:51 +02:00
|
|
|
IInternetProtocolEx_Release(&This->IInternetProtocolEx_iface);
|
2007-01-23 19:36:09 +01:00
|
|
|
return S_OK;
|
2007-01-23 19:33:30 +01:00
|
|
|
}
|
|
|
|
|
2010-11-15 12:36:41 +01:00
|
|
|
static HRESULT WINAPI ProtocolHandler_Suspend(IInternetProtocol *iface)
|
2007-01-23 19:33:30 +01:00
|
|
|
{
|
2010-11-30 12:40:08 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocol(iface);
|
2007-01-23 19:33:30 +01:00
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2010-11-15 12:36:41 +01:00
|
|
|
static HRESULT WINAPI ProtocolHandler_Resume(IInternetProtocol *iface)
|
2007-01-23 19:33:30 +01:00
|
|
|
{
|
2010-11-30 12:40:08 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocol(iface);
|
2007-01-23 19:33:30 +01:00
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2010-11-15 12:36:41 +01:00
|
|
|
static HRESULT WINAPI ProtocolHandler_Read(IInternetProtocol *iface, void *pv,
|
2007-01-23 19:33:30 +01:00
|
|
|
ULONG cb, ULONG *pcbRead)
|
|
|
|
{
|
2010-11-30 12:40:08 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocol(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
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p)->(%p %lu %p)\n", This, pv, cb, pcbRead);
|
2007-01-23 19:36:09 +01:00
|
|
|
|
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) {
|
2018-05-08 18:18:22 +02:00
|
|
|
IInternetProtocol *protocol;
|
2009-05-14 00:49:01 +02:00
|
|
|
ULONG cread = 0;
|
|
|
|
|
2018-05-08 18:18:22 +02:00
|
|
|
/* FIXME: We shouldn't need it, but out binding code currently depends on it. */
|
|
|
|
if(!This->protocol && This->protocol_unk) {
|
|
|
|
hres = IUnknown_QueryInterface(This->protocol_unk, &IID_IInternetProtocol,
|
|
|
|
(void**)&protocol);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return E_ABORT;
|
|
|
|
}else {
|
|
|
|
protocol = This->protocol;
|
|
|
|
}
|
|
|
|
|
2012-09-03 13:58:55 +02:00
|
|
|
if(is_apartment_thread(This))
|
|
|
|
This->continue_call++;
|
2018-05-08 18:18:22 +02:00
|
|
|
hres = IInternetProtocol_Read(protocol, (BYTE*)pv+read, cb-read, &cread);
|
2012-09-03 13:58:55 +02:00
|
|
|
if(is_apartment_thread(This))
|
|
|
|
This->continue_call--;
|
2009-05-14 00:49:01 +02:00
|
|
|
read += cread;
|
2018-05-08 18:18:22 +02:00
|
|
|
|
|
|
|
if(!This->protocol)
|
|
|
|
IInternetProtocol_Release(protocol);
|
2009-05-14 00:49:01 +02:00
|
|
|
}
|
2007-01-23 19:36:09 +01:00
|
|
|
|
|
|
|
*pcbRead = read;
|
|
|
|
return hres;
|
2007-01-23 19:33:30 +01:00
|
|
|
}
|
|
|
|
|
2010-11-15 12:36:41 +01:00
|
|
|
static HRESULT WINAPI ProtocolHandler_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
|
2007-01-23 19:33:30 +01:00
|
|
|
DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
|
|
|
|
{
|
2010-11-30 12:40:08 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocol(iface);
|
2022-02-18 09:18:16 +01:00
|
|
|
FIXME("(%p)->(%ld %ld %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
|
2007-01-23 19:33:30 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2010-11-15 12:36:41 +01:00
|
|
|
static HRESULT WINAPI ProtocolHandler_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
|
2007-01-23 19:33:30 +01:00
|
|
|
{
|
2010-11-30 12:40:08 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocol(iface);
|
2007-12-24 12:43:01 +01:00
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p)->(%08lx)\n", This, dwOptions);
|
2007-12-24 12:43:01 +01:00
|
|
|
|
|
|
|
return IInternetProtocol_LockRequest(This->protocol, dwOptions);
|
2007-01-23 19:33:30 +01:00
|
|
|
}
|
|
|
|
|
2010-11-15 12:36:41 +01:00
|
|
|
static HRESULT WINAPI ProtocolHandler_UnlockRequest(IInternetProtocol *iface)
|
2007-01-23 19:33:30 +01:00
|
|
|
{
|
2010-11-30 12:40:08 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocol(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
|
|
|
}
|
|
|
|
|
2010-11-15 12:36:41 +01:00
|
|
|
static const IInternetProtocolVtbl InternetProtocolHandlerVtbl = {
|
2009-05-18 18:29:24 +02:00
|
|
|
ProtocolHandler_QueryInterface,
|
|
|
|
ProtocolHandler_AddRef,
|
|
|
|
ProtocolHandler_Release,
|
|
|
|
ProtocolHandler_Start,
|
|
|
|
ProtocolHandler_Continue,
|
|
|
|
ProtocolHandler_Abort,
|
|
|
|
ProtocolHandler_Terminate,
|
|
|
|
ProtocolHandler_Suspend,
|
|
|
|
ProtocolHandler_Resume,
|
|
|
|
ProtocolHandler_Read,
|
|
|
|
ProtocolHandler_Seek,
|
|
|
|
ProtocolHandler_LockRequest,
|
2010-11-15 12:36:41 +01:00
|
|
|
ProtocolHandler_UnlockRequest
|
2007-01-23 19:33:30 +01:00
|
|
|
};
|
|
|
|
|
2012-03-16 15:00:29 +01:00
|
|
|
static inline BindProtocol *impl_from_IInternetProtocolSinkHandler(IInternetProtocolSink *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BindProtocol, default_protocol_handler.IInternetProtocolSink_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProtocolSinkHandler_QueryInterface(IInternetProtocolSink *iface,
|
|
|
|
REFIID riid, void **ppvObject)
|
|
|
|
{
|
|
|
|
BindProtocol *This = impl_from_IInternetProtocolSinkHandler(iface);
|
|
|
|
return IInternetProtocol_QueryInterface(&This->default_protocol_handler.IInternetProtocol_iface,
|
|
|
|
riid, ppvObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ProtocolSinkHandler_AddRef(IInternetProtocolSink *iface)
|
|
|
|
{
|
|
|
|
BindProtocol *This = impl_from_IInternetProtocolSinkHandler(iface);
|
|
|
|
return IInternetProtocolEx_AddRef(&This->IInternetProtocolEx_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ProtocolSinkHandler_Release(IInternetProtocolSink *iface)
|
|
|
|
{
|
|
|
|
BindProtocol *This = impl_from_IInternetProtocolSinkHandler(iface);
|
|
|
|
return IInternetProtocolEx_Release(&This->IInternetProtocolEx_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProtocolSinkHandler_Switch(IInternetProtocolSink *iface,
|
|
|
|
PROTOCOLDATA *pProtocolData)
|
|
|
|
{
|
|
|
|
BindProtocol *This = impl_from_IInternetProtocolSinkHandler(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pProtocolData);
|
|
|
|
|
|
|
|
if(!This->protocol_sink) {
|
|
|
|
IInternetProtocol_Continue(This->protocol_handler, pProtocolData);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return IInternetProtocolSink_Switch(This->protocol_sink, pProtocolData);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProtocolSinkHandler_ReportProgress(IInternetProtocolSink *iface,
|
|
|
|
ULONG status_code, LPCWSTR status_text)
|
|
|
|
{
|
|
|
|
BindProtocol *This = impl_from_IInternetProtocolSinkHandler(iface);
|
|
|
|
|
2012-09-03 13:58:18 +02:00
|
|
|
TRACE("(%p)->(%s %s)\n", This, debugstr_bindstatus(status_code), debugstr_w(status_text));
|
2012-03-16 15:00:29 +01:00
|
|
|
|
|
|
|
if(!This->protocol_sink)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
switch(status_code) {
|
|
|
|
case BINDSTATUS_FINDINGRESOURCE:
|
|
|
|
case BINDSTATUS_CONNECTING:
|
|
|
|
case BINDSTATUS_REDIRECTING:
|
|
|
|
case BINDSTATUS_SENDINGREQUEST:
|
|
|
|
case BINDSTATUS_CACHEFILENAMEAVAILABLE:
|
|
|
|
case BINDSTATUS_DIRECTBIND:
|
|
|
|
case BINDSTATUS_ACCEPTRANGES:
|
|
|
|
case BINDSTATUS_DECODING:
|
|
|
|
IInternetProtocolSink_ReportProgress(This->protocol_sink, status_code, status_text);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BINDSTATUS_BEGINDOWNLOADDATA:
|
|
|
|
IInternetProtocolSink_ReportData(This->protocol_sink, This->bscf, This->progress, This->progress_max);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BINDSTATUS_MIMETYPEAVAILABLE:
|
|
|
|
mime_available(This, status_text, FALSE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE:
|
|
|
|
mime_available(This, status_text, TRUE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2022-02-18 09:18:16 +01:00
|
|
|
FIXME("unsupported ulStatusCode %lu\n", status_code);
|
2012-03-16 15:00:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2022-01-06 19:30:37 +01:00
|
|
|
static HRESULT report_data(BindProtocol *This)
|
2012-03-16 15:00:29 +01:00
|
|
|
{
|
2022-01-06 19:30:37 +01:00
|
|
|
DWORD bscf = This->bscf;
|
|
|
|
HRESULT hres;
|
2012-03-16 15:00:29 +01:00
|
|
|
|
|
|
|
if((This->pi & PI_MIMEVERIFICATION) && !This->reported_mime) {
|
|
|
|
BYTE buf[BUFFER_SIZE];
|
|
|
|
DWORD read = 0;
|
|
|
|
LPWSTR mime;
|
|
|
|
|
|
|
|
do {
|
|
|
|
read = 0;
|
|
|
|
hres = IInternetProtocol_Read(This->protocol, buf,
|
|
|
|
sizeof(buf)-This->buf_size, &read);
|
|
|
|
if(FAILED(hres) && hres != E_PENDING)
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
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);
|
|
|
|
This->buf_size += read;
|
|
|
|
}while(This->buf_size < MIME_TEST_SIZE && hres == S_OK);
|
|
|
|
|
|
|
|
if(This->buf_size < MIME_TEST_SIZE && hres != S_FALSE)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
bscf = BSCF_FIRSTDATANOTIFICATION;
|
|
|
|
if(hres == S_FALSE)
|
|
|
|
bscf |= BSCF_LASTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE;
|
|
|
|
|
|
|
|
if(!This->reported_mime) {
|
|
|
|
BSTR raw_uri;
|
|
|
|
|
|
|
|
hres = IUri_GetRawUri(This->uri, &raw_uri);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = FindMimeFromData(NULL, raw_uri, This->buf, min(This->buf_size, MIME_TEST_SIZE),
|
|
|
|
This->mime, 0, &mime, 0);
|
|
|
|
SysFreeString(raw_uri);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
heap_free(This->mime);
|
|
|
|
This->mime = heap_strdupW(mime);
|
|
|
|
CoTaskMemFree(mime);
|
|
|
|
This->reported_mime = TRUE;
|
|
|
|
if(This->protocol_sink)
|
|
|
|
IInternetProtocolSink_ReportProgress(This->protocol_sink, BINDSTATUS_MIMETYPEAVAILABLE, This->mime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!This->protocol_sink)
|
|
|
|
return S_OK;
|
|
|
|
|
2022-01-06 19:30:37 +01:00
|
|
|
return IInternetProtocolSink_ReportData(This->protocol_sink, bscf, This->progress, This->progress_max);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ProtocolSinkHandler_ReportData(IInternetProtocolSink *iface,
|
|
|
|
DWORD bscf, ULONG progress, ULONG progress_max)
|
|
|
|
{
|
|
|
|
BindProtocol *This = impl_from_IInternetProtocolSinkHandler(iface);
|
|
|
|
HRESULT hres;
|
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p)->(%lx %lu %lu)\n", This, bscf, progress, progress_max);
|
2022-01-06 19:30:37 +01:00
|
|
|
|
|
|
|
This->bscf = bscf;
|
|
|
|
This->progress = progress;
|
|
|
|
This->progress_max = progress_max;
|
|
|
|
|
|
|
|
if(!This->protocol_sink)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
if(is_apartment_thread(This))
|
|
|
|
This->continue_call++;
|
|
|
|
|
|
|
|
hres = report_data(This);
|
|
|
|
|
|
|
|
if(is_apartment_thread(This)) {
|
|
|
|
This->continue_call--;
|
|
|
|
process_tasks(This);
|
|
|
|
}
|
|
|
|
return hres;
|
2012-03-16 15:00:29 +01:00
|
|
|
}
|
|
|
|
|
2017-06-06 17:15:55 +02:00
|
|
|
static HRESULT handle_redirect(BindProtocol *This, const WCHAR *url)
|
|
|
|
{
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(This->redirect_callback) {
|
|
|
|
VARIANT_BOOL cancel = VARIANT_FALSE;
|
|
|
|
IBindCallbackRedirect_Redirect(This->redirect_callback, url, &cancel);
|
|
|
|
if(cancel)
|
|
|
|
return INET_E_REDIRECT_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(This->protocol_sink) {
|
|
|
|
hres = IInternetProtocolSink_ReportProgress(This->protocol_sink, BINDSTATUS_REDIRECTING, url);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
IInternetProtocol_Terminate(This->protocol, 0); /* should this be done in StartEx? */
|
|
|
|
release_protocol_handler(This);
|
|
|
|
|
|
|
|
return IInternetProtocolEx_Start(&This->IInternetProtocolEx_iface, url, This->protocol_sink, This->bind_info, This->pi, 0);
|
|
|
|
}
|
|
|
|
|
2012-03-16 15:00:29 +01:00
|
|
|
static HRESULT WINAPI ProtocolSinkHandler_ReportResult(IInternetProtocolSink *iface,
|
|
|
|
HRESULT hrResult, DWORD dwError, LPCWSTR szResult)
|
|
|
|
{
|
|
|
|
BindProtocol *This = impl_from_IInternetProtocolSinkHandler(iface);
|
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p)->(%08lx %ld %s)\n", This, hrResult, dwError, debugstr_w(szResult));
|
2012-03-16 15:00:29 +01:00
|
|
|
|
2017-06-06 17:15:55 +02:00
|
|
|
if(hrResult == INET_E_REDIRECT_FAILED) {
|
|
|
|
hrResult = handle_redirect(This, szResult);
|
|
|
|
if(hrResult == S_OK)
|
|
|
|
return S_OK;
|
|
|
|
szResult = NULL;
|
|
|
|
}
|
|
|
|
|
2012-03-16 15:00:29 +01:00
|
|
|
if(This->protocol_sink)
|
|
|
|
return IInternetProtocolSink_ReportResult(This->protocol_sink, hrResult, dwError, szResult);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IInternetProtocolSinkVtbl InternetProtocolSinkHandlerVtbl = {
|
|
|
|
ProtocolSinkHandler_QueryInterface,
|
|
|
|
ProtocolSinkHandler_AddRef,
|
|
|
|
ProtocolSinkHandler_Release,
|
|
|
|
ProtocolSinkHandler_Switch,
|
|
|
|
ProtocolSinkHandler_ReportProgress,
|
|
|
|
ProtocolSinkHandler_ReportData,
|
|
|
|
ProtocolSinkHandler_ReportResult
|
|
|
|
};
|
|
|
|
|
2011-01-12 00:47:19 +01:00
|
|
|
static inline BindProtocol *impl_from_IInternetBindInfo(IInternetBindInfo *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BindProtocol, IInternetBindInfo_iface);
|
|
|
|
}
|
2007-01-23 19:33:30 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI BindInfo_QueryInterface(IInternetBindInfo *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-12 00:47:19 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetBindInfo(iface);
|
2011-01-12 00:43:44 +01:00
|
|
|
return IInternetProtocolEx_QueryInterface(&This->IInternetProtocolEx_iface, riid, ppv);
|
2007-01-23 19:33:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BindInfo_AddRef(IInternetBindInfo *iface)
|
|
|
|
{
|
2011-01-12 00:47:19 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetBindInfo(iface);
|
2011-01-12 00:43:44 +01:00
|
|
|
return IInternetProtocolEx_AddRef(&This->IInternetProtocolEx_iface);
|
2007-01-23 19:33:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BindInfo_Release(IInternetBindInfo *iface)
|
|
|
|
{
|
2011-01-12 00:47:19 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetBindInfo(iface);
|
2011-01-12 00:43:44 +01:00
|
|
|
return IInternetProtocolEx_Release(&This->IInternetProtocolEx_iface);
|
2007-01-23 19:33:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindInfo_GetBindInfo(IInternetBindInfo *iface,
|
|
|
|
DWORD *grfBINDF, BINDINFO *pbindinfo)
|
|
|
|
{
|
2011-01-12 00:47:19 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetBindInfo(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)) {
|
2022-02-18 09:18:16 +01:00
|
|
|
WARN("GetBindInfo failed: %08lx\n", hres);
|
2007-01-23 19:36:09 +01:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2017-06-06 17:15:55 +02:00
|
|
|
if((pbindinfo->dwOptions & BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS) && !This->redirect_callback) {
|
|
|
|
IServiceProvider *service_provider;
|
|
|
|
|
|
|
|
hres = IInternetProtocolSink_QueryInterface(This->protocol_sink, &IID_IServiceProvider, (void**)&service_provider);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
hres = IServiceProvider_QueryService(service_provider, &IID_IBindCallbackRedirect, &IID_IBindCallbackRedirect,
|
|
|
|
(void**)&This->redirect_callback);
|
|
|
|
IServiceProvider_Release(service_provider);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-23 19:36:09 +01:00
|
|
|
*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)
|
|
|
|
{
|
2011-01-12 00:47:19 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetBindInfo(iface);
|
2007-12-24 12:42:09 +01:00
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p)->(%ld %p %ld %p)\n", This, ulStringType, ppwzStr, cEl, pcElFetched);
|
2007-12-24 12:42:09 +01:00
|
|
|
|
|
|
|
return IInternetBindInfo_GetBindString(This->bind_info, ulStringType, ppwzStr, cEl, pcElFetched);
|
2007-01-23 19:33:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IInternetBindInfoVtbl InternetBindInfoVtbl = {
|
|
|
|
BindInfo_QueryInterface,
|
|
|
|
BindInfo_AddRef,
|
|
|
|
BindInfo_Release,
|
|
|
|
BindInfo_GetBindInfo,
|
|
|
|
BindInfo_GetBindString
|
|
|
|
};
|
|
|
|
|
2011-01-12 00:47:19 +01:00
|
|
|
static inline BindProtocol *impl_from_IInternetPriority(IInternetPriority *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BindProtocol, IInternetPriority_iface);
|
|
|
|
}
|
2007-01-23 19:34:00 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI InternetPriority_QueryInterface(IInternetPriority *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-12 00:47:19 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetPriority(iface);
|
2011-01-12 00:43:44 +01:00
|
|
|
return IInternetProtocolEx_QueryInterface(&This->IInternetProtocolEx_iface, riid, ppv);
|
2007-01-23 19:34:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InternetPriority_AddRef(IInternetPriority *iface)
|
|
|
|
{
|
2011-01-12 00:47:19 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetPriority(iface);
|
2011-01-12 00:43:44 +01:00
|
|
|
return IInternetProtocolEx_AddRef(&This->IInternetProtocolEx_iface);
|
2007-01-23 19:34:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InternetPriority_Release(IInternetPriority *iface)
|
|
|
|
{
|
2011-01-12 00:47:19 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetPriority(iface);
|
2011-01-12 00:43:44 +01:00
|
|
|
return IInternetProtocolEx_Release(&This->IInternetProtocolEx_iface);
|
2007-01-23 19:34:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InternetPriority_SetPriority(IInternetPriority *iface, LONG nPriority)
|
|
|
|
{
|
2011-01-12 00:47:19 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetPriority(iface);
|
2007-01-23 23:33:38 +01:00
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p)->(%ld)\n", This, nPriority);
|
2007-01-23 23:33:38 +01:00
|
|
|
|
|
|
|
This->priority = nPriority;
|
|
|
|
return S_OK;
|
2007-01-23 19:34:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InternetPriority_GetPriority(IInternetPriority *iface, LONG *pnPriority)
|
|
|
|
{
|
2011-01-12 00:47:19 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetPriority(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
|
|
|
}
|
|
|
|
|
|
|
|
static const IInternetPriorityVtbl InternetPriorityVtbl = {
|
|
|
|
InternetPriority_QueryInterface,
|
|
|
|
InternetPriority_AddRef,
|
|
|
|
InternetPriority_Release,
|
|
|
|
InternetPriority_SetPriority,
|
|
|
|
InternetPriority_GetPriority
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2011-01-12 00:47:19 +01:00
|
|
|
static inline BindProtocol *impl_from_IInternetProtocolSink(IInternetProtocolSink *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, 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)
|
|
|
|
{
|
2011-01-12 00:47:19 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocolSink(iface);
|
2011-01-12 00:43:44 +01:00
|
|
|
return IInternetProtocolEx_QueryInterface(&This->IInternetProtocolEx_iface, riid, ppv);
|
2007-01-23 19:45:27 +01:00
|
|
|
}
|
|
|
|
|
2007-12-28 02:00:53 +01:00
|
|
|
static ULONG WINAPI BPInternetProtocolSink_AddRef(IInternetProtocolSink *iface)
|
2007-01-23 19:45:27 +01:00
|
|
|
{
|
2011-01-12 00:47:19 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocolSink(iface);
|
2011-01-12 00:43:44 +01:00
|
|
|
return IInternetProtocolEx_AddRef(&This->IInternetProtocolEx_iface);
|
2007-01-23 19:45:27 +01:00
|
|
|
}
|
|
|
|
|
2007-12-28 02:00:53 +01:00
|
|
|
static ULONG WINAPI BPInternetProtocolSink_Release(IInternetProtocolSink *iface)
|
2007-01-23 19:45:27 +01:00
|
|
|
{
|
2011-01-12 00:47:19 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocolSink(iface);
|
2011-01-12 00:43:44 +01:00
|
|
|
return IInternetProtocolEx_Release(&This->IInternetProtocolEx_iface);
|
2007-01-23 19:45:27 +01:00
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2011-01-12 00:47:19 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocolSink(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);
|
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("flags %lx state %lx data %p cb %lu\n", pProtocolData->grfFlags, pProtocolData->dwState,
|
2007-12-28 14:54:22 +01:00
|
|
|
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));
|
|
|
|
|
2012-01-20 14:52:34 +01:00
|
|
|
if((This->pi&PI_APARTMENTTHREADED && pProtocolData->grfFlags&PI_FORCE_ASYNC)
|
|
|
|
|| !do_direct_notif(This)) {
|
2009-05-11 21:59:31 +02:00
|
|
|
switch_task_t *task;
|
|
|
|
|
|
|
|
task = heap_alloc(sizeof(switch_task_t));
|
|
|
|
if(!task)
|
2012-10-28 16:17:03 +01:00
|
|
|
{
|
|
|
|
heap_free(data);
|
2009-05-11 21:59:31 +02:00
|
|
|
return E_OUTOFMEMORY;
|
2012-10-28 16:17:03 +01:00
|
|
|
}
|
2009-05-11 21:59:31 +02:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-03-16 15:00:29 +01:00
|
|
|
return IInternetProtocolSink_Switch(This->protocol_sink_handler, data);
|
2009-05-14 00:49:01 +02:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2012-03-16 15:00:29 +01:00
|
|
|
IInternetProtocolSink_ReportProgress(This->protocol_sink_handler, 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
|
|
|
{
|
2011-01-12 00:47:19 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocolSink(iface);
|
2009-05-14 00:49:01 +02:00
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p)->(%lu %s)\n", This, ulStatusCode, debugstr_w(szStatusText));
|
2009-05-14 00:49:01 +02:00
|
|
|
|
2009-05-11 21:59:54 +02:00
|
|
|
if(do_direct_notif(This)) {
|
2012-03-16 15:00:29 +01:00
|
|
|
IInternetProtocolSink_ReportProgress(This->protocol_sink_handler, 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-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;
|
|
|
|
|
2012-03-16 15:00:29 +01:00
|
|
|
IInternetProtocolSink_ReportData(This->protocol_sink_handler,
|
|
|
|
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)
|
|
|
|
{
|
2011-01-12 00:47:19 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocolSink(iface);
|
2007-01-23 19:36:09 +01:00
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p)->(%lx %lu %lu)\n", This, grfBSCF, ulProgress, ulProgressMax);
|
2007-01-23 19:36:09 +01:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-03-16 15:00:29 +01:00
|
|
|
return IInternetProtocolSink_ReportData(This->protocol_sink_handler,
|
|
|
|
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;
|
|
|
|
|
2012-03-16 15:00:29 +01:00
|
|
|
IInternetProtocolSink_ReportResult(This->protocol_sink_handler, task->hres, task->err, task->str);
|
2009-05-11 22:00:26 +02:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2011-01-12 00:47:19 +01:00
|
|
|
BindProtocol *This = impl_from_IInternetProtocolSink(iface);
|
2007-01-23 19:36:09 +01:00
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p)->(%08lx %ld %s)\n", This, hrResult, dwError, debugstr_w(szResult));
|
2007-01-23 19:36:09 +01:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-03-16 15:00:29 +01:00
|
|
|
return IInternetProtocolSink_ReportResult(This->protocol_sink_handler, hrResult, dwError, szResult);
|
2007-01-23 19:45:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2011-01-12 00:47:19 +01:00
|
|
|
static inline BindProtocol *impl_from_IServiceProvider(IServiceProvider *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BindProtocol, IServiceProvider_iface);
|
|
|
|
}
|
2007-12-24 12:42:22 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI BPServiceProvider_QueryInterface(IServiceProvider *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-12 00:47:19 +01:00
|
|
|
BindProtocol *This = impl_from_IServiceProvider(iface);
|
2011-01-12 00:43:44 +01:00
|
|
|
return IInternetProtocolEx_QueryInterface(&This->IInternetProtocolEx_iface, riid, ppv);
|
2007-12-24 12:42:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BPServiceProvider_AddRef(IServiceProvider *iface)
|
|
|
|
{
|
2011-01-12 00:47:19 +01:00
|
|
|
BindProtocol *This = impl_from_IServiceProvider(iface);
|
2011-01-12 00:43:44 +01:00
|
|
|
return IInternetProtocolEx_AddRef(&This->IInternetProtocolEx_iface);
|
2007-12-24 12:42:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BPServiceProvider_Release(IServiceProvider *iface)
|
|
|
|
{
|
2011-01-12 00:47:19 +01:00
|
|
|
BindProtocol *This = impl_from_IServiceProvider(iface);
|
2011-01-12 00:43:44 +01:00
|
|
|
return IInternetProtocolEx_Release(&This->IInternetProtocolEx_iface);
|
2007-12-24 12:42:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BPServiceProvider_QueryService(IServiceProvider *iface,
|
|
|
|
REFGUID guidService, REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-12 00:47:19 +01:00
|
|
|
BindProtocol *This = impl_from_IServiceProvider(iface);
|
2007-12-24 12:42:22 +01:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IServiceProviderVtbl ServiceProviderVtbl = {
|
|
|
|
BPServiceProvider_QueryInterface,
|
|
|
|
BPServiceProvider_AddRef,
|
|
|
|
BPServiceProvider_Release,
|
|
|
|
BPServiceProvider_QueryService
|
|
|
|
};
|
|
|
|
|
2018-05-09 14:58:49 +02:00
|
|
|
HRESULT create_binding_protocol(BindProtocol **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
|
|
|
|
2011-01-12 00:43:44 +01:00
|
|
|
ret->IInternetProtocolEx_iface.lpVtbl = &BindProtocolVtbl;
|
2011-01-12 00:47:19 +01:00
|
|
|
ret->IInternetBindInfo_iface.lpVtbl = &InternetBindInfoVtbl;
|
|
|
|
ret->IInternetPriority_iface.lpVtbl = &InternetPriorityVtbl;
|
|
|
|
ret->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
|
|
|
|
ret->IInternetProtocolSink_iface.lpVtbl = &InternetProtocolSinkVtbl;
|
2007-01-23 19:36:09 +01:00
|
|
|
|
2010-11-30 12:40:08 +01:00
|
|
|
ret->default_protocol_handler.IInternetProtocol_iface.lpVtbl = &InternetProtocolHandlerVtbl;
|
2012-03-16 15:00:29 +01:00
|
|
|
ret->default_protocol_handler.IInternetProtocolSink_iface.lpVtbl = &InternetProtocolSinkHandlerVtbl;
|
2010-11-30 12:40:08 +01:00
|
|
|
|
2007-01-23 19:33:30 +01:00
|
|
|
ret->ref = 1;
|
2009-05-11 21:59:31 +02:00
|
|
|
ret->apartment_thread = GetCurrentThreadId();
|
|
|
|
ret->notif_hwnd = get_notif_hwnd();
|
2010-11-30 12:40:08 +01:00
|
|
|
ret->protocol_handler = &ret->default_protocol_handler.IInternetProtocol_iface;
|
2012-03-16 15:00:29 +01:00
|
|
|
ret->protocol_sink_handler = &ret->default_protocol_handler.IInternetProtocolSink_iface;
|
2009-05-11 21:59:31 +02:00
|
|
|
InitializeCriticalSection(&ret->section);
|
2011-11-14 15:09:42 +01:00
|
|
|
ret->section.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": BindProtocol.section");
|
2007-01-23 19:33:30 +01:00
|
|
|
|
2007-07-24 07:15:19 +02:00
|
|
|
URLMON_LockModule();
|
|
|
|
|
2011-01-10 18:25:44 +01:00
|
|
|
*protocol = ret;
|
2007-01-23 19:33:30 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|