2 * Copyright 2007-2009 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "urlmon_main.h"
20 #include "wine/debug.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(urlmon
);
24 typedef void (*task_proc_t
)(BindProtocol
*,task_header_t
*);
26 struct _task_header_t
{
31 #define BUFFER_SIZE 2048
32 #define MIME_TEST_SIZE 255
34 #define WM_MK_CONTINUE (WM_USER+101)
35 #define WM_MK_RELEASE (WM_USER+102)
37 static void process_tasks(BindProtocol
*This
)
42 EnterCriticalSection(&This
->section
);
44 task
= This
->task_queue_head
;
46 This
->task_queue_head
= task
->next
;
47 if(!This
->task_queue_head
)
48 This
->task_queue_tail
= NULL
;
51 LeaveCriticalSection(&This
->section
);
56 This
->continue_call
++;
57 task
->proc(This
, task
);
58 This
->continue_call
--;
62 static LRESULT WINAPI
notif_wnd_proc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
65 case WM_MK_CONTINUE
: {
66 BindProtocol
*This
= (BindProtocol
*)lParam
;
70 IInternetProtocolEx_Release(&This
->IInternetProtocolEx_iface
);
74 tls_data_t
*data
= get_tls_data();
76 if(!--data
->notif_hwnd_cnt
) {
78 data
->notif_hwnd
= NULL
;
83 return DefWindowProcW(hwnd
, msg
, wParam
, lParam
);
86 static const WCHAR wszURLMonikerNotificationWindow
[] =
87 {'U','R','L',' ','M','o','n','i','k','e','r',' ',
88 'N','o','t','i','f','i','c','a','t','i','o','n',' ','W','i','n','d','o','w',0};
90 static ATOM notif_wnd_class
;
92 static BOOL WINAPI
register_notif_wnd_class(INIT_ONCE
*once
, void *param
, void **context
)
94 static WNDCLASSEXW wndclass
= {
95 sizeof(wndclass
), 0, notif_wnd_proc
, 0, 0,
96 NULL
, NULL
, NULL
, NULL
, NULL
,
97 wszURLMonikerNotificationWindow
, NULL
100 wndclass
.hInstance
= hProxyDll
;
101 notif_wnd_class
= RegisterClassExW(&wndclass
);
105 void unregister_notif_wnd_class(void)
108 UnregisterClassW(MAKEINTRESOURCEW(notif_wnd_class
), hProxyDll
);
111 HWND
get_notif_hwnd(void)
113 tls_data_t
*tls_data
;
115 static INIT_ONCE init_once
= INIT_ONCE_STATIC_INIT
;
117 tls_data
= get_tls_data();
121 if(tls_data
->notif_hwnd_cnt
) {
122 tls_data
->notif_hwnd_cnt
++;
123 return tls_data
->notif_hwnd
;
126 InitOnceExecuteOnce(&init_once
, register_notif_wnd_class
, NULL
, NULL
);
130 tls_data
->notif_hwnd
= CreateWindowExW(0, MAKEINTRESOURCEW(notif_wnd_class
),
131 wszURLMonikerNotificationWindow
, 0, 0, 0, 0, 0, HWND_MESSAGE
,
132 NULL
, hProxyDll
, NULL
);
133 if(tls_data
->notif_hwnd
)
134 tls_data
->notif_hwnd_cnt
++;
136 TRACE("hwnd = %p\n", tls_data
->notif_hwnd
);
138 return tls_data
->notif_hwnd
;
141 void release_notif_hwnd(HWND hwnd
)
143 tls_data_t
*data
= get_tls_data();
148 if(data
->notif_hwnd
!= hwnd
) {
149 PostMessageW(data
->notif_hwnd
, WM_MK_RELEASE
, 0, 0);
153 if(!--data
->notif_hwnd_cnt
) {
154 DestroyWindow(data
->notif_hwnd
);
155 data
->notif_hwnd
= NULL
;
159 static void push_task(BindProtocol
*This
, task_header_t
*task
, task_proc_t proc
)
161 BOOL do_post
= FALSE
;
166 EnterCriticalSection(&This
->section
);
168 if(This
->task_queue_tail
) {
169 This
->task_queue_tail
->next
= task
;
170 This
->task_queue_tail
= task
;
172 This
->task_queue_tail
= This
->task_queue_head
= task
;
173 do_post
= !This
->continue_call
;
176 LeaveCriticalSection(&This
->section
);
179 IInternetProtocolEx_AddRef(&This
->IInternetProtocolEx_iface
);
180 PostMessageW(This
->notif_hwnd
, WM_MK_CONTINUE
, 0, (LPARAM
)This
);
184 static inline BOOL
is_apartment_thread(BindProtocol
*This
)
186 return This
->apartment_thread
== GetCurrentThreadId();
189 static inline BOOL
do_direct_notif(BindProtocol
*This
)
191 return !(This
->pi
& PI_APARTMENTTHREADED
) || (is_apartment_thread(This
) && !This
->continue_call
);
194 static HRESULT
handle_mime_filter(BindProtocol
*This
, IInternetProtocol
*mime_filter
)
196 PROTOCOLFILTERDATA filter_data
= { sizeof(PROTOCOLFILTERDATA
), NULL
, NULL
, NULL
, 0 };
199 hres
= IInternetProtocol_QueryInterface(mime_filter
, &IID_IInternetProtocolSink
, (void**)&This
->protocol_sink_handler
);
201 This
->protocol_sink_handler
= &This
->default_protocol_handler
.IInternetProtocolSink_iface
;
205 IInternetProtocol_AddRef(mime_filter
);
206 This
->protocol_handler
= mime_filter
;
208 filter_data
.pProtocol
= &This
->default_protocol_handler
.IInternetProtocol_iface
;
209 hres
= IInternetProtocol_Start(mime_filter
, This
->mime
, &This
->default_protocol_handler
.IInternetProtocolSink_iface
,
210 &This
->IInternetBindInfo_iface
, PI_FILTER_MODE
|PI_FORCE_ASYNC
,
211 (HANDLE_PTR
)&filter_data
);
213 IInternetProtocolSink_Release(This
->protocol_sink_handler
);
214 IInternetProtocol_Release(This
->protocol_handler
);
215 This
->protocol_sink_handler
= &This
->default_protocol_handler
.IInternetProtocolSink_iface
;
216 This
->protocol_handler
= &This
->default_protocol_handler
.IInternetProtocol_iface
;
220 /* NOTE: IE9 calls it on the new protocol_sink. It doesn't make sense so it seems to be a bug there. */
221 IInternetProtocolSink_ReportProgress(This
->protocol_sink
, BINDSTATUS_LOADINGMIMEHANDLER
, NULL
);
226 static void mime_available(BindProtocol
*This
, LPCWSTR mime
, BOOL verified
)
228 IInternetProtocol
*mime_filter
;
231 heap_free(This
->mime
);
232 This
->mime
= heap_strdupW(mime
);
234 if(This
->protocol_handler
==&This
->default_protocol_handler
.IInternetProtocol_iface
235 && (mime_filter
= get_mime_filter(mime
))) {
236 TRACE("Got mime filter for %s\n", debugstr_w(mime
));
238 hres
= handle_mime_filter(This
, mime_filter
);
239 IInternetProtocol_Release(mime_filter
);
241 FIXME("MIME filter failed: %08x\n", hres
);
244 if(This
->reported_mime
|| verified
|| !(This
->pi
& PI_MIMEVERIFICATION
)) {
245 This
->reported_mime
= TRUE
;
246 IInternetProtocolSink_ReportProgress(This
->protocol_sink
, BINDSTATUS_MIMETYPEAVAILABLE
, mime
);
250 static inline BindProtocol
*impl_from_IInternetProtocolEx(IInternetProtocolEx
*iface
)
252 return CONTAINING_RECORD(iface
, BindProtocol
, IInternetProtocolEx_iface
);
255 static HRESULT WINAPI
BindProtocol_QueryInterface(IInternetProtocolEx
*iface
, REFIID riid
, void **ppv
)
257 BindProtocol
*This
= impl_from_IInternetProtocolEx(iface
);
260 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
261 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
262 *ppv
= &This
->IInternetProtocolEx_iface
;
263 }else if(IsEqualGUID(&IID_IInternetProtocolRoot
, riid
)) {
264 TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This
, ppv
);
265 *ppv
= &This
->IInternetProtocolEx_iface
;
266 }else if(IsEqualGUID(&IID_IInternetProtocol
, riid
)) {
267 TRACE("(%p)->(IID_IInternetProtocol %p)\n", This
, ppv
);
268 *ppv
= &This
->IInternetProtocolEx_iface
;
269 }else if(IsEqualGUID(&IID_IInternetProtocolEx
, riid
)) {
270 TRACE("(%p)->(IID_IInternetProtocolEx %p)\n", This
, ppv
);
271 *ppv
= &This
->IInternetProtocolEx_iface
;
272 }else if(IsEqualGUID(&IID_IInternetBindInfo
, riid
)) {
273 TRACE("(%p)->(IID_IInternetBindInfo %p)\n", This
, ppv
);
274 *ppv
= &This
->IInternetBindInfo_iface
;
275 }else if(IsEqualGUID(&IID_IInternetPriority
, riid
)) {
276 TRACE("(%p)->(IID_IInternetPriority %p)\n", This
, ppv
);
277 *ppv
= &This
->IInternetPriority_iface
;
278 }else if(IsEqualGUID(&IID_IAuthenticate
, riid
)) {
279 FIXME("(%p)->(IID_IAuthenticate %p)\n", This
, ppv
);
280 }else if(IsEqualGUID(&IID_IServiceProvider
, riid
)) {
281 TRACE("(%p)->(IID_IServiceProvider %p)\n", This
, ppv
);
282 *ppv
= &This
->IServiceProvider_iface
;
283 }else if(IsEqualGUID(&IID_IInternetProtocolSink
, riid
)) {
284 TRACE("(%p)->(IID_IInternetProtocolSink %p)\n", This
, ppv
);
285 *ppv
= &This
->IInternetProtocolSink_iface
;
286 }else if(IsEqualGUID(&IID_IWinInetInfo
, riid
)) {
287 TRACE("(%p)->(IID_IWinInetInfo %p)\n", This
, ppv
);
290 IWinInetInfo
*inet_info
;
293 hres
= IInternetProtocol_QueryInterface(This
->protocol
, &IID_IWinInetInfo
, (void**)&inet_info
);
294 if(SUCCEEDED(hres
)) {
295 *ppv
= &This
->IWinInetHttpInfo_iface
;
296 IWinInetInfo_Release(inet_info
);
299 }else if(IsEqualGUID(&IID_IWinInetHttpInfo
, riid
)) {
300 TRACE("(%p)->(IID_IWinInetHttpInfo %p)\n", This
, ppv
);
303 IWinInetHttpInfo
*http_info
;
306 hres
= IInternetProtocol_QueryInterface(This
->protocol
, &IID_IWinInetHttpInfo
, (void**)&http_info
);
307 if(SUCCEEDED(hres
)) {
308 *ppv
= &This
->IWinInetHttpInfo_iface
;
309 IWinInetHttpInfo_Release(http_info
);
313 WARN("not supported interface %s\n", debugstr_guid(riid
));
317 return E_NOINTERFACE
;
319 IUnknown_AddRef((IUnknown
*)*ppv
);
323 static ULONG WINAPI
BindProtocol_AddRef(IInternetProtocolEx
*iface
)
325 BindProtocol
*This
= impl_from_IInternetProtocolEx(iface
);
326 LONG ref
= InterlockedIncrement(&This
->ref
);
327 TRACE("(%p) ref=%d\n", This
, ref
);
331 static ULONG WINAPI
BindProtocol_Release(IInternetProtocolEx
*iface
)
333 BindProtocol
*This
= impl_from_IInternetProtocolEx(iface
);
334 LONG ref
= InterlockedDecrement(&This
->ref
);
336 TRACE("(%p) ref=%d\n", This
, ref
);
339 if(This
->wininet_info
)
340 IWinInetInfo_Release(This
->wininet_info
);
341 if(This
->wininet_http_info
)
342 IWinInetHttpInfo_Release(This
->wininet_http_info
);
344 IInternetProtocol_Release(This
->protocol
);
346 IInternetBindInfo_Release(This
->bind_info
);
347 if(This
->protocol_handler
&& This
->protocol_handler
!= &This
->default_protocol_handler
.IInternetProtocol_iface
)
348 IInternetProtocol_Release(This
->protocol_handler
);
349 if(This
->protocol_sink_handler
&&
350 This
->protocol_sink_handler
!= &This
->default_protocol_handler
.IInternetProtocolSink_iface
)
351 IInternetProtocolSink_Release(This
->protocol_sink_handler
);
353 IUri_Release(This
->uri
);
354 SysFreeString(This
->display_uri
);
356 set_binding_sink(This
, NULL
, NULL
);
359 release_notif_hwnd(This
->notif_hwnd
);
360 This
->section
.DebugInfo
->Spare
[0] = 0;
361 DeleteCriticalSection(&This
->section
);
363 heap_free(This
->mime
);
366 URLMON_UnlockModule();
372 static HRESULT WINAPI
BindProtocol_Start(IInternetProtocolEx
*iface
, LPCWSTR szUrl
,
373 IInternetProtocolSink
*pOIProtSink
, IInternetBindInfo
*pOIBindInfo
,
374 DWORD grfPI
, HANDLE_PTR dwReserved
)
376 BindProtocol
*This
= impl_from_IInternetProtocolEx(iface
);
380 TRACE("(%p)->(%s %p %p %08x %lx)\n", This
, debugstr_w(szUrl
), pOIProtSink
,
381 pOIBindInfo
, grfPI
, dwReserved
);
383 hres
= CreateUri(szUrl
, Uri_CREATE_FILE_USE_DOS_PATH
, 0, &uri
);
387 hres
= IInternetProtocolEx_StartEx(&This
->IInternetProtocolEx_iface
, uri
, pOIProtSink
,
388 pOIBindInfo
, grfPI
, (HANDLE
*)dwReserved
);
394 static HRESULT WINAPI
BindProtocol_Continue(IInternetProtocolEx
*iface
, PROTOCOLDATA
*pProtocolData
)
396 BindProtocol
*This
= impl_from_IInternetProtocolEx(iface
);
398 TRACE("(%p)->(%p)\n", This
, pProtocolData
);
400 return IInternetProtocol_Continue(This
->protocol_handler
, pProtocolData
);
403 static HRESULT WINAPI
BindProtocol_Abort(IInternetProtocolEx
*iface
, HRESULT hrReason
,
406 BindProtocol
*This
= impl_from_IInternetProtocolEx(iface
);
408 TRACE("(%p)->(%08x %08x)\n", This
, hrReason
, dwOptions
);
410 return IInternetProtocol_Abort(This
->protocol_handler
, hrReason
, dwOptions
);
413 static HRESULT WINAPI
BindProtocol_Terminate(IInternetProtocolEx
*iface
, DWORD dwOptions
)
415 BindProtocol
*This
= impl_from_IInternetProtocolEx(iface
);
417 TRACE("(%p)->(%08x)\n", This
, dwOptions
);
419 return IInternetProtocol_Terminate(This
->protocol_handler
, dwOptions
);
422 static HRESULT WINAPI
BindProtocol_Suspend(IInternetProtocolEx
*iface
)
424 BindProtocol
*This
= impl_from_IInternetProtocolEx(iface
);
425 FIXME("(%p)\n", This
);
429 static HRESULT WINAPI
BindProtocol_Resume(IInternetProtocolEx
*iface
)
431 BindProtocol
*This
= impl_from_IInternetProtocolEx(iface
);
432 FIXME("(%p)\n", This
);
436 static HRESULT WINAPI
BindProtocol_Read(IInternetProtocolEx
*iface
, void *pv
,
437 ULONG cb
, ULONG
*pcbRead
)
439 BindProtocol
*This
= impl_from_IInternetProtocolEx(iface
);
441 TRACE("(%p)->(%p %u %p)\n", This
, pv
, cb
, pcbRead
);
445 return IInternetProtocol_Read(This
->protocol_handler
, pv
, cb
, pcbRead
);
448 static HRESULT WINAPI
BindProtocol_Seek(IInternetProtocolEx
*iface
, LARGE_INTEGER dlibMove
,
449 DWORD dwOrigin
, ULARGE_INTEGER
*plibNewPosition
)
451 BindProtocol
*This
= impl_from_IInternetProtocolEx(iface
);
452 FIXME("(%p)->(%d %d %p)\n", This
, dlibMove
.u
.LowPart
, dwOrigin
, plibNewPosition
);
456 static HRESULT WINAPI
BindProtocol_LockRequest(IInternetProtocolEx
*iface
, DWORD dwOptions
)
458 BindProtocol
*This
= impl_from_IInternetProtocolEx(iface
);
460 TRACE("(%p)->(%08x)\n", This
, dwOptions
);
462 return IInternetProtocol_LockRequest(This
->protocol_handler
, dwOptions
);
465 static HRESULT WINAPI
BindProtocol_UnlockRequest(IInternetProtocolEx
*iface
)
467 BindProtocol
*This
= impl_from_IInternetProtocolEx(iface
);
469 TRACE("(%p)\n", This
);
471 return IInternetProtocol_UnlockRequest(This
->protocol_handler
);
474 static HRESULT WINAPI
BindProtocol_StartEx(IInternetProtocolEx
*iface
, IUri
*pUri
,
475 IInternetProtocolSink
*pOIProtSink
, IInternetBindInfo
*pOIBindInfo
,
476 DWORD grfPI
, HANDLE
*dwReserved
)
478 BindProtocol
*This
= impl_from_IInternetProtocolEx(iface
);
479 IInternetProtocol
*protocol
= NULL
;
480 IInternetProtocolEx
*protocolex
;
481 IInternetPriority
*priority
;
482 IServiceProvider
*service_provider
;
483 BOOL urlmon_protocol
= FALSE
;
484 CLSID clsid
= IID_NULL
;
488 TRACE("(%p)->(%p %p %p %08x %p)\n", This
, pUri
, pOIProtSink
, pOIBindInfo
, grfPI
, dwReserved
);
490 if(!pUri
|| !pOIProtSink
|| !pOIBindInfo
)
498 hres
= IInternetProtocolSink_QueryInterface(pOIProtSink
, &IID_IServiceProvider
,
499 (void**)&service_provider
);
500 if(SUCCEEDED(hres
)) {
501 /* FIXME: What's protocol CLSID here? */
502 IServiceProvider_QueryService(service_provider
, &IID_IInternetProtocol
,
503 &IID_IInternetProtocol
, (void**)&protocol
);
504 IServiceProvider_Release(service_provider
);
511 hres
= get_protocol_handler(pUri
, &clsid
, &urlmon_protocol
, &cf
);
515 if(This
->from_urlmon
) {
516 hres
= IClassFactory_CreateInstance(cf
, NULL
, &IID_IInternetProtocol
, (void**)&protocol
);
517 IClassFactory_Release(cf
);
521 hres
= IClassFactory_CreateInstance(cf
, (IUnknown
*)&This
->IInternetBindInfo_iface
,
522 &IID_IUnknown
, (void**)&unk
);
523 IClassFactory_Release(cf
);
527 hres
= IUnknown_QueryInterface(unk
, &IID_IInternetProtocol
, (void**)&protocol
);
528 IUnknown_Release(unk
);
534 StringFromCLSID(&clsid
, &clsid_str
);
535 IInternetProtocolSink_ReportProgress(pOIProtSink
, BINDSTATUS_PROTOCOLCLASSID
, clsid_str
);
536 CoTaskMemFree(clsid_str
);
538 This
->protocol
= protocol
;
540 if(urlmon_protocol
) {
541 IInternetProtocol_QueryInterface(protocol
, &IID_IWinInetInfo
, (void**)&This
->wininet_info
);
542 IInternetProtocol_QueryInterface(protocol
, &IID_IWinInetHttpInfo
, (void**)&This
->wininet_http_info
);
545 set_binding_sink(This
, pOIProtSink
, pOIBindInfo
);
547 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IInternetPriority
, (void**)&priority
);
548 if(SUCCEEDED(hres
)) {
549 IInternetPriority_SetPriority(priority
, This
->priority
);
550 IInternetPriority_Release(priority
);
553 hres
= IInternetProtocol_QueryInterface(protocol
, &IID_IInternetProtocolEx
, (void**)&protocolex
);
554 if(SUCCEEDED(hres
)) {
555 hres
= IInternetProtocolEx_StartEx(protocolex
, pUri
, &This
->IInternetProtocolSink_iface
,
556 &This
->IInternetBindInfo_iface
, 0, NULL
);
557 IInternetProtocolEx_Release(protocolex
);
559 hres
= IUri_GetDisplayUri(pUri
, &This
->display_uri
);
563 hres
= IInternetProtocol_Start(protocol
, This
->display_uri
, &This
->IInternetProtocolSink_iface
,
564 &This
->IInternetBindInfo_iface
, 0, 0);
572 void set_binding_sink(BindProtocol
*This
, IInternetProtocolSink
*sink
, IInternetBindInfo
*bind_info
)
574 IInternetProtocolSink
*prev_sink
;
575 IServiceProvider
*service_provider
= NULL
;
578 IInternetProtocolSink_AddRef(sink
);
579 prev_sink
= InterlockedExchangePointer((void**)&This
->protocol_sink
, sink
);
581 IInternetProtocolSink_Release(prev_sink
);
584 IInternetProtocolSink_QueryInterface(sink
, &IID_IServiceProvider
, (void**)&service_provider
);
585 service_provider
= InterlockedExchangePointer((void**)&This
->service_provider
, service_provider
);
587 IServiceProvider_Release(service_provider
);
590 IInternetBindInfo_AddRef(bind_info
);
591 bind_info
= InterlockedExchangePointer((void**)&This
->bind_info
, bind_info
);
593 IInternetBindInfo_Release(bind_info
);
596 static const IInternetProtocolExVtbl BindProtocolVtbl
= {
597 BindProtocol_QueryInterface
,
599 BindProtocol_Release
,
601 BindProtocol_Continue
,
603 BindProtocol_Terminate
,
604 BindProtocol_Suspend
,
608 BindProtocol_LockRequest
,
609 BindProtocol_UnlockRequest
,
613 static inline BindProtocol
*impl_from_IInternetProtocol(IInternetProtocol
*iface
)
615 return CONTAINING_RECORD(iface
, BindProtocol
, default_protocol_handler
.IInternetProtocol_iface
);
618 static HRESULT WINAPI
ProtocolHandler_QueryInterface(IInternetProtocol
*iface
, REFIID riid
, void **ppv
)
620 BindProtocol
*This
= impl_from_IInternetProtocol(iface
);
623 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
624 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
625 *ppv
= &This
->default_protocol_handler
.IInternetProtocol_iface
;
626 }else if(IsEqualGUID(&IID_IInternetProtocolRoot
, riid
)) {
627 TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This
, ppv
);
628 *ppv
= &This
->default_protocol_handler
.IInternetProtocol_iface
;
629 }else if(IsEqualGUID(&IID_IInternetProtocol
, riid
)) {
630 TRACE("(%p)->(IID_IInternetProtocol %p)\n", This
, ppv
);
631 *ppv
= &This
->default_protocol_handler
.IInternetProtocol_iface
;
632 }else if(IsEqualGUID(&IID_IInternetProtocolSink
, riid
)) {
633 TRACE("(%p)->(IID_IInternetProtocolSink %p)\n", This
, ppv
);
634 *ppv
= &This
->default_protocol_handler
.IInternetProtocolSink_iface
;
638 IInternetProtocol_AddRef(iface
);
642 WARN("not supported interface %s\n", debugstr_guid(riid
));
643 return E_NOINTERFACE
;
646 static ULONG WINAPI
ProtocolHandler_AddRef(IInternetProtocol
*iface
)
648 BindProtocol
*This
= impl_from_IInternetProtocol(iface
);
649 return IInternetProtocolEx_AddRef(&This
->IInternetProtocolEx_iface
);
652 static ULONG WINAPI
ProtocolHandler_Release(IInternetProtocol
*iface
)
654 BindProtocol
*This
= impl_from_IInternetProtocol(iface
);
655 return IInternetProtocolEx_Release(&This
->IInternetProtocolEx_iface
);
658 static HRESULT WINAPI
ProtocolHandler_Start(IInternetProtocol
*iface
, LPCWSTR szUrl
,
659 IInternetProtocolSink
*pOIProtSink
, IInternetBindInfo
*pOIBindInfo
,
660 DWORD grfPI
, HANDLE_PTR dwReserved
)
662 ERR("Should not be called\n");
666 static HRESULT WINAPI
ProtocolHandler_Continue(IInternetProtocol
*iface
, PROTOCOLDATA
*pProtocolData
)
668 BindProtocol
*This
= impl_from_IInternetProtocol(iface
);
671 TRACE("(%p)->(%p)\n", This
, pProtocolData
);
673 hres
= IInternetProtocol_Continue(This
->protocol
, pProtocolData
);
675 heap_free(pProtocolData
);
679 static HRESULT WINAPI
ProtocolHandler_Abort(IInternetProtocol
*iface
, HRESULT hrReason
,
682 BindProtocol
*This
= impl_from_IInternetProtocol(iface
);
684 TRACE("(%p)->(%08x %08x)\n", This
, hrReason
, dwOptions
);
686 if(This
->protocol
&& !This
->reported_result
)
687 return IInternetProtocol_Abort(This
->protocol
, hrReason
, dwOptions
);
692 static HRESULT WINAPI
ProtocolHandler_Terminate(IInternetProtocol
*iface
, DWORD dwOptions
)
694 BindProtocol
*This
= impl_from_IInternetProtocol(iface
);
696 TRACE("(%p)->(%08x)\n", This
, dwOptions
);
698 if(!This
->reported_result
)
701 IInternetProtocol_Terminate(This
->protocol
, 0);
703 set_binding_sink(This
, NULL
, NULL
);
705 if(This
->bind_info
) {
706 IInternetBindInfo_Release(This
->bind_info
);
707 This
->bind_info
= NULL
;
713 static HRESULT WINAPI
ProtocolHandler_Suspend(IInternetProtocol
*iface
)
715 BindProtocol
*This
= impl_from_IInternetProtocol(iface
);
716 FIXME("(%p)\n", This
);
720 static HRESULT WINAPI
ProtocolHandler_Resume(IInternetProtocol
*iface
)
722 BindProtocol
*This
= impl_from_IInternetProtocol(iface
);
723 FIXME("(%p)\n", This
);
727 static HRESULT WINAPI
ProtocolHandler_Read(IInternetProtocol
*iface
, void *pv
,
728 ULONG cb
, ULONG
*pcbRead
)
730 BindProtocol
*This
= impl_from_IInternetProtocol(iface
);
734 TRACE("(%p)->(%p %u %p)\n", This
, pv
, cb
, pcbRead
);
737 read
= min(cb
, This
->buf_size
);
738 memcpy(pv
, This
->buf
, read
);
740 if(read
== This
->buf_size
) {
741 heap_free(This
->buf
);
744 memmove(This
->buf
, This
->buf
+cb
, This
->buf_size
-cb
);
747 This
->buf_size
-= read
;
753 if(is_apartment_thread(This
))
754 This
->continue_call
++;
755 hres
= IInternetProtocol_Read(This
->protocol
, (BYTE
*)pv
+read
, cb
-read
, &cread
);
756 if(is_apartment_thread(This
))
757 This
->continue_call
--;
765 static HRESULT WINAPI
ProtocolHandler_Seek(IInternetProtocol
*iface
, LARGE_INTEGER dlibMove
,
766 DWORD dwOrigin
, ULARGE_INTEGER
*plibNewPosition
)
768 BindProtocol
*This
= impl_from_IInternetProtocol(iface
);
769 FIXME("(%p)->(%d %d %p)\n", This
, dlibMove
.u
.LowPart
, dwOrigin
, plibNewPosition
);
773 static HRESULT WINAPI
ProtocolHandler_LockRequest(IInternetProtocol
*iface
, DWORD dwOptions
)
775 BindProtocol
*This
= impl_from_IInternetProtocol(iface
);
777 TRACE("(%p)->(%08x)\n", This
, dwOptions
);
779 return IInternetProtocol_LockRequest(This
->protocol
, dwOptions
);
782 static HRESULT WINAPI
ProtocolHandler_UnlockRequest(IInternetProtocol
*iface
)
784 BindProtocol
*This
= impl_from_IInternetProtocol(iface
);
786 TRACE("(%p)\n", This
);
788 return IInternetProtocol_UnlockRequest(This
->protocol
);
791 static const IInternetProtocolVtbl InternetProtocolHandlerVtbl
= {
792 ProtocolHandler_QueryInterface
,
793 ProtocolHandler_AddRef
,
794 ProtocolHandler_Release
,
795 ProtocolHandler_Start
,
796 ProtocolHandler_Continue
,
797 ProtocolHandler_Abort
,
798 ProtocolHandler_Terminate
,
799 ProtocolHandler_Suspend
,
800 ProtocolHandler_Resume
,
801 ProtocolHandler_Read
,
802 ProtocolHandler_Seek
,
803 ProtocolHandler_LockRequest
,
804 ProtocolHandler_UnlockRequest
807 static inline BindProtocol
*impl_from_IInternetProtocolSinkHandler(IInternetProtocolSink
*iface
)
809 return CONTAINING_RECORD(iface
, BindProtocol
, default_protocol_handler
.IInternetProtocolSink_iface
);
812 static HRESULT WINAPI
ProtocolSinkHandler_QueryInterface(IInternetProtocolSink
*iface
,
813 REFIID riid
, void **ppvObject
)
815 BindProtocol
*This
= impl_from_IInternetProtocolSinkHandler(iface
);
816 return IInternetProtocol_QueryInterface(&This
->default_protocol_handler
.IInternetProtocol_iface
,
820 static ULONG WINAPI
ProtocolSinkHandler_AddRef(IInternetProtocolSink
*iface
)
822 BindProtocol
*This
= impl_from_IInternetProtocolSinkHandler(iface
);
823 return IInternetProtocolEx_AddRef(&This
->IInternetProtocolEx_iface
);
826 static ULONG WINAPI
ProtocolSinkHandler_Release(IInternetProtocolSink
*iface
)
828 BindProtocol
*This
= impl_from_IInternetProtocolSinkHandler(iface
);
829 return IInternetProtocolEx_Release(&This
->IInternetProtocolEx_iface
);
832 static HRESULT WINAPI
ProtocolSinkHandler_Switch(IInternetProtocolSink
*iface
,
833 PROTOCOLDATA
*pProtocolData
)
835 BindProtocol
*This
= impl_from_IInternetProtocolSinkHandler(iface
);
837 TRACE("(%p)->(%p)\n", This
, pProtocolData
);
839 if(!This
->protocol_sink
) {
840 IInternetProtocol_Continue(This
->protocol_handler
, pProtocolData
);
844 return IInternetProtocolSink_Switch(This
->protocol_sink
, pProtocolData
);
847 static HRESULT WINAPI
ProtocolSinkHandler_ReportProgress(IInternetProtocolSink
*iface
,
848 ULONG status_code
, LPCWSTR status_text
)
850 BindProtocol
*This
= impl_from_IInternetProtocolSinkHandler(iface
);
852 TRACE("(%p)->(%s %s)\n", This
, debugstr_bindstatus(status_code
), debugstr_w(status_text
));
854 if(!This
->protocol_sink
)
857 switch(status_code
) {
858 case BINDSTATUS_FINDINGRESOURCE
:
859 case BINDSTATUS_CONNECTING
:
860 case BINDSTATUS_REDIRECTING
:
861 case BINDSTATUS_SENDINGREQUEST
:
862 case BINDSTATUS_CACHEFILENAMEAVAILABLE
:
863 case BINDSTATUS_DIRECTBIND
:
864 case BINDSTATUS_ACCEPTRANGES
:
865 case BINDSTATUS_DECODING
:
866 IInternetProtocolSink_ReportProgress(This
->protocol_sink
, status_code
, status_text
);
869 case BINDSTATUS_BEGINDOWNLOADDATA
:
870 IInternetProtocolSink_ReportData(This
->protocol_sink
, This
->bscf
, This
->progress
, This
->progress_max
);
873 case BINDSTATUS_MIMETYPEAVAILABLE
:
874 mime_available(This
, status_text
, FALSE
);
877 case BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE
:
878 mime_available(This
, status_text
, TRUE
);
882 FIXME("unsupported ulStatusCode %u\n", status_code
);
888 static HRESULT WINAPI
ProtocolSinkHandler_ReportData(IInternetProtocolSink
*iface
,
889 DWORD bscf
, ULONG progress
, ULONG progress_max
)
891 BindProtocol
*This
= impl_from_IInternetProtocolSinkHandler(iface
);
893 TRACE("(%p)->(%x %u %u)\n", This
, bscf
, progress
, progress_max
);
896 This
->progress
= progress
;
897 This
->progress_max
= progress_max
;
899 if(!This
->protocol_sink
)
902 if((This
->pi
& PI_MIMEVERIFICATION
) && !This
->reported_mime
) {
903 BYTE buf
[BUFFER_SIZE
];
910 if(is_apartment_thread(This
))
911 This
->continue_call
++;
912 hres
= IInternetProtocol_Read(This
->protocol
, buf
,
913 sizeof(buf
)-This
->buf_size
, &read
);
914 if(is_apartment_thread(This
))
915 This
->continue_call
--;
916 if(FAILED(hres
) && hres
!= E_PENDING
)
920 This
->buf
= heap_alloc(BUFFER_SIZE
);
922 return E_OUTOFMEMORY
;
923 }else if(read
+ This
->buf_size
> BUFFER_SIZE
) {
926 tmp
= heap_realloc(This
->buf
, read
+This
->buf_size
);
928 return E_OUTOFMEMORY
;
932 memcpy(This
->buf
+This
->buf_size
, buf
, read
);
933 This
->buf_size
+= read
;
934 }while(This
->buf_size
< MIME_TEST_SIZE
&& hres
== S_OK
);
936 if(This
->buf_size
< MIME_TEST_SIZE
&& hres
!= S_FALSE
)
939 bscf
= BSCF_FIRSTDATANOTIFICATION
;
941 bscf
|= BSCF_LASTDATANOTIFICATION
|BSCF_DATAFULLYAVAILABLE
;
943 if(!This
->reported_mime
) {
946 hres
= IUri_GetRawUri(This
->uri
, &raw_uri
);
950 hres
= FindMimeFromData(NULL
, raw_uri
, This
->buf
, min(This
->buf_size
, MIME_TEST_SIZE
),
951 This
->mime
, 0, &mime
, 0);
952 SysFreeString(raw_uri
);
956 heap_free(This
->mime
);
957 This
->mime
= heap_strdupW(mime
);
959 This
->reported_mime
= TRUE
;
960 if(This
->protocol_sink
)
961 IInternetProtocolSink_ReportProgress(This
->protocol_sink
, BINDSTATUS_MIMETYPEAVAILABLE
, This
->mime
);
965 if(!This
->protocol_sink
)
968 return IInternetProtocolSink_ReportData(This
->protocol_sink
, bscf
, progress
, progress_max
);
971 static HRESULT WINAPI
ProtocolSinkHandler_ReportResult(IInternetProtocolSink
*iface
,
972 HRESULT hrResult
, DWORD dwError
, LPCWSTR szResult
)
974 BindProtocol
*This
= impl_from_IInternetProtocolSinkHandler(iface
);
976 TRACE("(%p)->(%08x %d %s)\n", This
, hrResult
, dwError
, debugstr_w(szResult
));
978 if(This
->protocol_sink
)
979 return IInternetProtocolSink_ReportResult(This
->protocol_sink
, hrResult
, dwError
, szResult
);
983 static const IInternetProtocolSinkVtbl InternetProtocolSinkHandlerVtbl
= {
984 ProtocolSinkHandler_QueryInterface
,
985 ProtocolSinkHandler_AddRef
,
986 ProtocolSinkHandler_Release
,
987 ProtocolSinkHandler_Switch
,
988 ProtocolSinkHandler_ReportProgress
,
989 ProtocolSinkHandler_ReportData
,
990 ProtocolSinkHandler_ReportResult
993 static inline BindProtocol
*impl_from_IInternetBindInfo(IInternetBindInfo
*iface
)
995 return CONTAINING_RECORD(iface
, BindProtocol
, IInternetBindInfo_iface
);
998 static HRESULT WINAPI
BindInfo_QueryInterface(IInternetBindInfo
*iface
,
999 REFIID riid
, void **ppv
)
1001 BindProtocol
*This
= impl_from_IInternetBindInfo(iface
);
1002 return IInternetProtocolEx_QueryInterface(&This
->IInternetProtocolEx_iface
, riid
, ppv
);
1005 static ULONG WINAPI
BindInfo_AddRef(IInternetBindInfo
*iface
)
1007 BindProtocol
*This
= impl_from_IInternetBindInfo(iface
);
1008 return IInternetProtocolEx_AddRef(&This
->IInternetProtocolEx_iface
);
1011 static ULONG WINAPI
BindInfo_Release(IInternetBindInfo
*iface
)
1013 BindProtocol
*This
= impl_from_IInternetBindInfo(iface
);
1014 return IInternetProtocolEx_Release(&This
->IInternetProtocolEx_iface
);
1017 static HRESULT WINAPI
BindInfo_GetBindInfo(IInternetBindInfo
*iface
,
1018 DWORD
*grfBINDF
, BINDINFO
*pbindinfo
)
1020 BindProtocol
*This
= impl_from_IInternetBindInfo(iface
);
1023 TRACE("(%p)->(%p %p)\n", This
, grfBINDF
, pbindinfo
);
1025 hres
= IInternetBindInfo_GetBindInfo(This
->bind_info
, grfBINDF
, pbindinfo
);
1027 WARN("GetBindInfo failed: %08x\n", hres
);
1031 *grfBINDF
|= BINDF_FROMURLMON
;
1035 static HRESULT WINAPI
BindInfo_GetBindString(IInternetBindInfo
*iface
,
1036 ULONG ulStringType
, LPOLESTR
*ppwzStr
, ULONG cEl
, ULONG
*pcElFetched
)
1038 BindProtocol
*This
= impl_from_IInternetBindInfo(iface
);
1040 TRACE("(%p)->(%d %p %d %p)\n", This
, ulStringType
, ppwzStr
, cEl
, pcElFetched
);
1042 return IInternetBindInfo_GetBindString(This
->bind_info
, ulStringType
, ppwzStr
, cEl
, pcElFetched
);
1045 static const IInternetBindInfoVtbl InternetBindInfoVtbl
= {
1046 BindInfo_QueryInterface
,
1049 BindInfo_GetBindInfo
,
1050 BindInfo_GetBindString
1053 static inline BindProtocol
*impl_from_IInternetPriority(IInternetPriority
*iface
)
1055 return CONTAINING_RECORD(iface
, BindProtocol
, IInternetPriority_iface
);
1058 static HRESULT WINAPI
InternetPriority_QueryInterface(IInternetPriority
*iface
,
1059 REFIID riid
, void **ppv
)
1061 BindProtocol
*This
= impl_from_IInternetPriority(iface
);
1062 return IInternetProtocolEx_QueryInterface(&This
->IInternetProtocolEx_iface
, riid
, ppv
);
1065 static ULONG WINAPI
InternetPriority_AddRef(IInternetPriority
*iface
)
1067 BindProtocol
*This
= impl_from_IInternetPriority(iface
);
1068 return IInternetProtocolEx_AddRef(&This
->IInternetProtocolEx_iface
);
1071 static ULONG WINAPI
InternetPriority_Release(IInternetPriority
*iface
)
1073 BindProtocol
*This
= impl_from_IInternetPriority(iface
);
1074 return IInternetProtocolEx_Release(&This
->IInternetProtocolEx_iface
);
1077 static HRESULT WINAPI
InternetPriority_SetPriority(IInternetPriority
*iface
, LONG nPriority
)
1079 BindProtocol
*This
= impl_from_IInternetPriority(iface
);
1081 TRACE("(%p)->(%d)\n", This
, nPriority
);
1083 This
->priority
= nPriority
;
1087 static HRESULT WINAPI
InternetPriority_GetPriority(IInternetPriority
*iface
, LONG
*pnPriority
)
1089 BindProtocol
*This
= impl_from_IInternetPriority(iface
);
1091 TRACE("(%p)->(%p)\n", This
, pnPriority
);
1093 *pnPriority
= This
->priority
;
1097 static const IInternetPriorityVtbl InternetPriorityVtbl
= {
1098 InternetPriority_QueryInterface
,
1099 InternetPriority_AddRef
,
1100 InternetPriority_Release
,
1101 InternetPriority_SetPriority
,
1102 InternetPriority_GetPriority
1106 static inline BindProtocol
*impl_from_IInternetProtocolSink(IInternetProtocolSink
*iface
)
1108 return CONTAINING_RECORD(iface
, BindProtocol
, IInternetProtocolSink_iface
);
1111 static HRESULT WINAPI
BPInternetProtocolSink_QueryInterface(IInternetProtocolSink
*iface
,
1112 REFIID riid
, void **ppv
)
1114 BindProtocol
*This
= impl_from_IInternetProtocolSink(iface
);
1115 return IInternetProtocolEx_QueryInterface(&This
->IInternetProtocolEx_iface
, riid
, ppv
);
1118 static ULONG WINAPI
BPInternetProtocolSink_AddRef(IInternetProtocolSink
*iface
)
1120 BindProtocol
*This
= impl_from_IInternetProtocolSink(iface
);
1121 return IInternetProtocolEx_AddRef(&This
->IInternetProtocolEx_iface
);
1124 static ULONG WINAPI
BPInternetProtocolSink_Release(IInternetProtocolSink
*iface
)
1126 BindProtocol
*This
= impl_from_IInternetProtocolSink(iface
);
1127 return IInternetProtocolEx_Release(&This
->IInternetProtocolEx_iface
);
1131 task_header_t header
;
1135 static void switch_proc(BindProtocol
*bind
, task_header_t
*t
)
1137 switch_task_t
*task
= (switch_task_t
*)t
;
1139 IInternetProtocol_Continue(bind
->protocol_handler
, task
->data
);
1144 static HRESULT WINAPI
BPInternetProtocolSink_Switch(IInternetProtocolSink
*iface
,
1145 PROTOCOLDATA
*pProtocolData
)
1147 BindProtocol
*This
= impl_from_IInternetProtocolSink(iface
);
1150 TRACE("(%p)->(%p)\n", This
, pProtocolData
);
1152 TRACE("flags %x state %x data %p cb %u\n", pProtocolData
->grfFlags
, pProtocolData
->dwState
,
1153 pProtocolData
->pData
, pProtocolData
->cbData
);
1155 data
= heap_alloc(sizeof(PROTOCOLDATA
));
1157 return E_OUTOFMEMORY
;
1158 memcpy(data
, pProtocolData
, sizeof(PROTOCOLDATA
));
1160 if((This
->pi
&PI_APARTMENTTHREADED
&& pProtocolData
->grfFlags
&PI_FORCE_ASYNC
)
1161 || !do_direct_notif(This
)) {
1162 switch_task_t
*task
;
1164 task
= heap_alloc(sizeof(switch_task_t
));
1168 return E_OUTOFMEMORY
;
1173 push_task(This
, &task
->header
, switch_proc
);
1177 return IInternetProtocolSink_Switch(This
->protocol_sink_handler
, data
);
1181 task_header_t header
;
1185 } on_progress_task_t
;
1187 static void on_progress_proc(BindProtocol
*This
, task_header_t
*t
)
1189 on_progress_task_t
*task
= (on_progress_task_t
*)t
;
1191 IInternetProtocolSink_ReportProgress(This
->protocol_sink_handler
, task
->status_code
, task
->status_text
);
1193 heap_free(task
->status_text
);
1197 static HRESULT WINAPI
BPInternetProtocolSink_ReportProgress(IInternetProtocolSink
*iface
,
1198 ULONG ulStatusCode
, LPCWSTR szStatusText
)
1200 BindProtocol
*This
= impl_from_IInternetProtocolSink(iface
);
1202 TRACE("(%p)->(%u %s)\n", This
, ulStatusCode
, debugstr_w(szStatusText
));
1204 if(do_direct_notif(This
)) {
1205 IInternetProtocolSink_ReportProgress(This
->protocol_sink_handler
, ulStatusCode
, szStatusText
);
1207 on_progress_task_t
*task
;
1209 task
= heap_alloc(sizeof(on_progress_task_t
));
1211 task
->status_code
= ulStatusCode
;
1212 task
->status_text
= heap_strdupW(szStatusText
);
1214 push_task(This
, &task
->header
, on_progress_proc
);
1221 task_header_t header
;
1225 } report_data_task_t
;
1227 static void report_data_proc(BindProtocol
*This
, task_header_t
*t
)
1229 report_data_task_t
*task
= (report_data_task_t
*)t
;
1231 IInternetProtocolSink_ReportData(This
->protocol_sink_handler
,
1232 task
->bscf
, task
->progress
, task
->progress_max
);
1237 static HRESULT WINAPI
BPInternetProtocolSink_ReportData(IInternetProtocolSink
*iface
,
1238 DWORD grfBSCF
, ULONG ulProgress
, ULONG ulProgressMax
)
1240 BindProtocol
*This
= impl_from_IInternetProtocolSink(iface
);
1242 TRACE("(%p)->(%x %u %u)\n", This
, grfBSCF
, ulProgress
, ulProgressMax
);
1244 if(!This
->protocol_sink
)
1247 if(!do_direct_notif(This
)) {
1248 report_data_task_t
*task
;
1250 task
= heap_alloc(sizeof(report_data_task_t
));
1252 return E_OUTOFMEMORY
;
1254 task
->bscf
= grfBSCF
;
1255 task
->progress
= ulProgress
;
1256 task
->progress_max
= ulProgressMax
;
1258 push_task(This
, &task
->header
, report_data_proc
);
1262 return IInternetProtocolSink_ReportData(This
->protocol_sink_handler
,
1263 grfBSCF
, ulProgress
, ulProgressMax
);
1267 task_header_t header
;
1272 } report_result_task_t
;
1274 static void report_result_proc(BindProtocol
*This
, task_header_t
*t
)
1276 report_result_task_t
*task
= (report_result_task_t
*)t
;
1278 IInternetProtocolSink_ReportResult(This
->protocol_sink_handler
, task
->hres
, task
->err
, task
->str
);
1280 heap_free(task
->str
);
1284 static HRESULT WINAPI
BPInternetProtocolSink_ReportResult(IInternetProtocolSink
*iface
,
1285 HRESULT hrResult
, DWORD dwError
, LPCWSTR szResult
)
1287 BindProtocol
*This
= impl_from_IInternetProtocolSink(iface
);
1289 TRACE("(%p)->(%08x %d %s)\n", This
, hrResult
, dwError
, debugstr_w(szResult
));
1291 if(!This
->protocol_sink
)
1293 This
->reported_result
= TRUE
;
1295 if(!do_direct_notif(This
)) {
1296 report_result_task_t
*task
;
1298 task
= heap_alloc(sizeof(report_result_task_t
));
1300 return E_OUTOFMEMORY
;
1302 task
->hres
= hrResult
;
1303 task
->err
= dwError
;
1304 task
->str
= heap_strdupW(szResult
);
1306 push_task(This
, &task
->header
, report_result_proc
);
1310 return IInternetProtocolSink_ReportResult(This
->protocol_sink_handler
, hrResult
, dwError
, szResult
);
1313 static const IInternetProtocolSinkVtbl InternetProtocolSinkVtbl
= {
1314 BPInternetProtocolSink_QueryInterface
,
1315 BPInternetProtocolSink_AddRef
,
1316 BPInternetProtocolSink_Release
,
1317 BPInternetProtocolSink_Switch
,
1318 BPInternetProtocolSink_ReportProgress
,
1319 BPInternetProtocolSink_ReportData
,
1320 BPInternetProtocolSink_ReportResult
1323 static inline BindProtocol
*impl_from_IWinInetHttpInfo(IWinInetHttpInfo
*iface
)
1325 return CONTAINING_RECORD(iface
, BindProtocol
, IWinInetHttpInfo_iface
);
1328 static HRESULT WINAPI
WinInetHttpInfo_QueryInterface(IWinInetHttpInfo
*iface
, REFIID riid
, void **ppv
)
1330 BindProtocol
*This
= impl_from_IWinInetHttpInfo(iface
);
1331 return IInternetProtocolEx_QueryInterface(&This
->IInternetProtocolEx_iface
, riid
, ppv
);
1334 static ULONG WINAPI
WinInetHttpInfo_AddRef(IWinInetHttpInfo
*iface
)
1336 BindProtocol
*This
= impl_from_IWinInetHttpInfo(iface
);
1337 return IInternetProtocolEx_AddRef(&This
->IInternetProtocolEx_iface
);
1340 static ULONG WINAPI
WinInetHttpInfo_Release(IWinInetHttpInfo
*iface
)
1342 BindProtocol
*This
= impl_from_IWinInetHttpInfo(iface
);
1343 return IInternetProtocolEx_Release(&This
->IInternetProtocolEx_iface
);
1346 static HRESULT WINAPI
WinInetHttpInfo_QueryOption(IWinInetHttpInfo
*iface
, DWORD dwOption
,
1347 void *pBuffer
, DWORD
*pcbBuffer
)
1349 BindProtocol
*This
= impl_from_IWinInetHttpInfo(iface
);
1350 FIXME("(%p)->(%x %p %p)\n", This
, dwOption
, pBuffer
, pcbBuffer
);
1354 static HRESULT WINAPI
WinInetHttpInfo_QueryInfo(IWinInetHttpInfo
*iface
, DWORD dwOption
,
1355 void *pBuffer
, DWORD
*pcbBuffer
, DWORD
*pdwFlags
, DWORD
*pdwReserved
)
1357 BindProtocol
*This
= impl_from_IWinInetHttpInfo(iface
);
1358 FIXME("(%p)->(%x %p %p %p %p)\n", This
, dwOption
, pBuffer
, pcbBuffer
, pdwFlags
, pdwReserved
);
1362 static const IWinInetHttpInfoVtbl WinInetHttpInfoVtbl
= {
1363 WinInetHttpInfo_QueryInterface
,
1364 WinInetHttpInfo_AddRef
,
1365 WinInetHttpInfo_Release
,
1366 WinInetHttpInfo_QueryOption
,
1367 WinInetHttpInfo_QueryInfo
1370 static inline BindProtocol
*impl_from_IServiceProvider(IServiceProvider
*iface
)
1372 return CONTAINING_RECORD(iface
, BindProtocol
, IServiceProvider_iface
);
1375 static HRESULT WINAPI
BPServiceProvider_QueryInterface(IServiceProvider
*iface
,
1376 REFIID riid
, void **ppv
)
1378 BindProtocol
*This
= impl_from_IServiceProvider(iface
);
1379 return IInternetProtocolEx_QueryInterface(&This
->IInternetProtocolEx_iface
, riid
, ppv
);
1382 static ULONG WINAPI
BPServiceProvider_AddRef(IServiceProvider
*iface
)
1384 BindProtocol
*This
= impl_from_IServiceProvider(iface
);
1385 return IInternetProtocolEx_AddRef(&This
->IInternetProtocolEx_iface
);
1388 static ULONG WINAPI
BPServiceProvider_Release(IServiceProvider
*iface
)
1390 BindProtocol
*This
= impl_from_IServiceProvider(iface
);
1391 return IInternetProtocolEx_Release(&This
->IInternetProtocolEx_iface
);
1394 static HRESULT WINAPI
BPServiceProvider_QueryService(IServiceProvider
*iface
,
1395 REFGUID guidService
, REFIID riid
, void **ppv
)
1397 BindProtocol
*This
= impl_from_IServiceProvider(iface
);
1399 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_guid(guidService
), debugstr_guid(riid
), ppv
);
1401 if(!This
->service_provider
)
1402 return E_NOINTERFACE
;
1404 return IServiceProvider_QueryService(This
->service_provider
, guidService
, riid
, ppv
);
1407 static const IServiceProviderVtbl ServiceProviderVtbl
= {
1408 BPServiceProvider_QueryInterface
,
1409 BPServiceProvider_AddRef
,
1410 BPServiceProvider_Release
,
1411 BPServiceProvider_QueryService
1414 HRESULT
create_binding_protocol(BOOL from_urlmon
, BindProtocol
**protocol
)
1416 BindProtocol
*ret
= heap_alloc_zero(sizeof(BindProtocol
));
1418 ret
->IInternetProtocolEx_iface
.lpVtbl
= &BindProtocolVtbl
;
1419 ret
->IInternetBindInfo_iface
.lpVtbl
= &InternetBindInfoVtbl
;
1420 ret
->IInternetPriority_iface
.lpVtbl
= &InternetPriorityVtbl
;
1421 ret
->IServiceProvider_iface
.lpVtbl
= &ServiceProviderVtbl
;
1422 ret
->IInternetProtocolSink_iface
.lpVtbl
= &InternetProtocolSinkVtbl
;
1423 ret
->IWinInetHttpInfo_iface
.lpVtbl
= &WinInetHttpInfoVtbl
;
1425 ret
->default_protocol_handler
.IInternetProtocol_iface
.lpVtbl
= &InternetProtocolHandlerVtbl
;
1426 ret
->default_protocol_handler
.IInternetProtocolSink_iface
.lpVtbl
= &InternetProtocolSinkHandlerVtbl
;
1429 ret
->from_urlmon
= from_urlmon
;
1430 ret
->apartment_thread
= GetCurrentThreadId();
1431 ret
->notif_hwnd
= get_notif_hwnd();
1432 ret
->protocol_handler
= &ret
->default_protocol_handler
.IInternetProtocol_iface
;
1433 ret
->protocol_sink_handler
= &ret
->default_protocol_handler
.IInternetProtocolSink_iface
;
1434 InitializeCriticalSection(&ret
->section
);
1435 ret
->section
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": BindProtocol.section");
1437 URLMON_LockModule();