2 * Copyright 2007 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
21 #include "urlmon_main.h"
22 #include "wine/debug.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
26 static WCHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
28 extern IID IID_IBindStatusCallbackHolder;
31 const IBindStatusCallbackVtbl *lpBindStatusCallbackVtbl;
32 const IServiceProviderVtbl *lpServiceProviderVtbl;
33 const IHttpNegotiate2Vtbl *lpHttpNegotiate2Vtbl;
34 const IAuthenticateVtbl *lpAuthenticateVtbl;
38 IBindStatusCallback *callback;
39 IServiceProvider *serv_prov;
41 IHttpNegotiate *http_negotiate;
42 BOOL init_http_negotiate;
43 IHttpNegotiate2 *http_negotiate2;
44 BOOL init_http_negotiate2;
45 IAuthenticate *authenticate;
46 BOOL init_authenticate;
49 #define STATUSCLB(x) ((IBindStatusCallback*) &(x)->lpBindStatusCallbackVtbl)
50 #define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl)
51 #define HTTPNEG2(x) ((IHttpNegotiate2*) &(x)->lpHttpNegotiate2Vtbl)
52 #define AUTHENTICATE(x) ((IAuthenticate*) &(x)->lpAuthenticateVtbl)
54 #define STATUSCLB_THIS(iface) DEFINE_THIS(BindStatusCallback, BindStatusCallback, iface)
56 static HRESULT WINAPI BindStatusCallback_QueryInterface(IBindStatusCallback *iface,
57 REFIID riid, void **ppv)
59 BindStatusCallback *This = STATUSCLB_THIS(iface);
63 if(IsEqualGUID(&IID_IUnknown, riid)) {
64 TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppv);
65 *ppv = STATUSCLB(This);
66 }else if(IsEqualGUID(&IID_IBindStatusCallback, riid)) {
67 TRACE("(%p)->(IID_IBindStatusCallback, %p)\n", This, ppv);
68 *ppv = STATUSCLB(This);
69 }else if(IsEqualGUID(&IID_IBindStatusCallbackHolder, riid)) {
70 TRACE("(%p)->(IID_IBindStatusCallbackHolder, %p)\n", This, ppv);
72 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
73 TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppv);
74 *ppv = SERVPROV(This);
75 }else if(IsEqualGUID(&IID_IHttpNegotiate, riid)) {
76 TRACE("(%p)->(IID_IHttpNegotiate, %p)\n", This, ppv);
77 *ppv = HTTPNEG2(This);
78 }else if(IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
79 TRACE("(%p)->(IID_IHttpNegotiate2, %p)\n", This, ppv);
80 *ppv = HTTPNEG2(This);
81 }else if(IsEqualGUID(&IID_IAuthenticate, riid)) {
82 TRACE("(%p)->(IID_IAuthenticate, %p)\n", This, ppv);
83 *ppv = AUTHENTICATE(This);
87 IBindStatusCallback_AddRef((IUnknown*)*ppv);
91 TRACE("Unsupported riid = %s\n", debugstr_guid(riid));
95 static ULONG WINAPI BindStatusCallback_AddRef(IBindStatusCallback *iface)
97 BindStatusCallback *This = STATUSCLB_THIS(iface);
98 LONG ref = InterlockedIncrement(&This->ref);
100 TRACE("(%p) ref = %d\n", This, ref);
105 static ULONG WINAPI BindStatusCallback_Release(IBindStatusCallback *iface)
107 BindStatusCallback *This = STATUSCLB_THIS(iface);
108 LONG ref = InterlockedDecrement(&This->ref);
110 TRACE("(%p) ref = %d\n", This, ref);
114 IServiceProvider_Release(This->serv_prov);
115 if(This->http_negotiate)
116 IHttpNegotiate_Release(This->http_negotiate);
117 if(This->http_negotiate2)
118 IHttpNegotiate2_Release(This->http_negotiate2);
119 if(This->authenticate)
120 IAuthenticate_Release(This->authenticate);
121 IBindStatusCallback_Release(This->callback);
128 static HRESULT WINAPI BindStatusCallback_OnStartBinding(IBindStatusCallback *iface,
129 DWORD dwReserved, IBinding *pbind)
131 BindStatusCallback *This = STATUSCLB_THIS(iface);
133 TRACE("(%p)->(%d %p)\n", This, dwReserved, pbind);
135 return IBindStatusCallback_OnStartBinding(This->callback, 0xff, pbind);
138 static HRESULT WINAPI BindStatusCallback_GetPriority(IBindStatusCallback *iface, LONG *pnPriority)
140 BindStatusCallback *This = STATUSCLB_THIS(iface);
142 TRACE("(%p)->(%p)\n", This, pnPriority);
144 return IBindStatusCallback_GetPriority(This->callback, pnPriority);
147 static HRESULT WINAPI BindStatusCallback_OnLowResource(IBindStatusCallback *iface, DWORD reserved)
149 BindStatusCallback *This = STATUSCLB_THIS(iface);
151 TRACE("(%p)->(%d)\n", This, reserved);
153 return IBindStatusCallback_OnLowResource(This->callback, reserved);
156 static HRESULT WINAPI BindStatusCallback_OnProgress(IBindStatusCallback *iface, ULONG ulProgress,
157 ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
159 BindStatusCallback *This = STATUSCLB_THIS(iface);
161 TRACE("%p)->(%u %u %u %s)\n", This, ulProgress, ulProgressMax, ulStatusCode,
162 debugstr_w(szStatusText));
164 return IBindStatusCallback_OnProgress(This->callback, ulProgress,
165 ulProgressMax, ulStatusCode, szStatusText);
168 static HRESULT WINAPI BindStatusCallback_OnStopBinding(IBindStatusCallback *iface,
169 HRESULT hresult, LPCWSTR szError)
171 BindStatusCallback *This = STATUSCLB_THIS(iface);
173 TRACE("(%p)->(%08x %s)\n", This, hresult, debugstr_w(szError));
175 return IBindStatusCallback_OnStopBinding(This->callback, hresult, szError);
178 static HRESULT WINAPI BindStatusCallback_GetBindInfo(IBindStatusCallback *iface,
179 DWORD *grfBINDF, BINDINFO *pbindinfo)
181 BindStatusCallback *This = STATUSCLB_THIS(iface);
183 TRACE("(%p)->(%p %p)\n", This, grfBINDF, pbindinfo);
185 return IBindStatusCallback_GetBindInfo(This->callback, grfBINDF, pbindinfo);
188 static HRESULT WINAPI BindStatusCallback_OnDataAvailable(IBindStatusCallback *iface,
189 DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
191 BindStatusCallback *This = STATUSCLB_THIS(iface);
193 TRACE("(%p)->(%08x %d %p %p)\n", This, grfBSCF, dwSize, pformatetc, pstgmed);
195 return IBindStatusCallback_OnDataAvailable(This->callback, grfBSCF, dwSize, pformatetc, pstgmed);
198 static HRESULT WINAPI BindStatusCallback_OnObjectAvailable(IBindStatusCallback *iface,
199 REFIID riid, IUnknown *punk)
201 BindStatusCallback *This = STATUSCLB_THIS(iface);
203 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), punk);
205 return IBindStatusCallback_OnObjectAvailable(This->callback, riid, punk);
208 #undef STATUSCLB_THIS
210 static const IBindStatusCallbackVtbl BindStatusCallbackVtbl = {
211 BindStatusCallback_QueryInterface,
212 BindStatusCallback_AddRef,
213 BindStatusCallback_Release,
214 BindStatusCallback_OnStartBinding,
215 BindStatusCallback_GetPriority,
216 BindStatusCallback_OnLowResource,
217 BindStatusCallback_OnProgress,
218 BindStatusCallback_OnStopBinding,
219 BindStatusCallback_GetBindInfo,
220 BindStatusCallback_OnDataAvailable,
221 BindStatusCallback_OnObjectAvailable
224 #define SERVPROV_THIS(iface) DEFINE_THIS(BindStatusCallback, ServiceProvider, iface)
226 static HRESULT WINAPI BSCServiceProvider_QueryInterface(IServiceProvider *iface,
227 REFIID riid, void **ppv)
229 BindStatusCallback *This = SERVPROV_THIS(iface);
230 return IBindStatusCallback_QueryInterface(STATUSCLB(This), riid, ppv);
233 static ULONG WINAPI BSCServiceProvider_AddRef(IServiceProvider *iface)
235 BindStatusCallback *This = SERVPROV_THIS(iface);
236 return IBindStatusCallback_AddRef(STATUSCLB(This));
239 static ULONG WINAPI BSCServiceProvider_Release(IServiceProvider *iface)
241 BindStatusCallback *This = SERVPROV_THIS(iface);
242 return IBindStatusCallback_Release(STATUSCLB(This));
245 static HRESULT WINAPI BSCServiceProvider_QueryService(IServiceProvider *iface,
246 REFGUID guidService, REFIID riid, void **ppv)
248 BindStatusCallback *This = SERVPROV_THIS(iface);
251 if(IsEqualGUID(&IID_IHttpNegotiate, guidService)) {
252 TRACE("(%p)->(IID_IHttpNegotiate %s %p)\n", This, debugstr_guid(riid), ppv);
254 if(!This->init_http_negotiate) {
255 This->init_http_negotiate = TRUE;
256 hres = IBindStatusCallback_QueryInterface(This->callback, &IID_IHttpNegotiate,
257 (void**)&This->http_negotiate);
258 if(FAILED(hres) && This->serv_prov)
259 IServiceProvider_QueryService(This->serv_prov, &IID_IHttpNegotiate,
260 &IID_IHttpNegotiate, (void**)&This->http_negotiate);
263 return IBindStatusCallback_QueryInterface(STATUSCLB(This), riid, ppv);
266 if(IsEqualGUID(&IID_IHttpNegotiate2, guidService)) {
267 TRACE("(%p)->(IID_IHttpNegotiate2 %s %p)\n", This, debugstr_guid(riid), ppv);
269 if(!This->init_http_negotiate2) {
270 This->init_http_negotiate2 = TRUE;
271 hres = IBindStatusCallback_QueryInterface(This->callback, &IID_IHttpNegotiate2,
272 (void**)&This->http_negotiate2);
273 if(FAILED(hres) && This->serv_prov)
274 IServiceProvider_QueryService(This->serv_prov, &IID_IHttpNegotiate2,
275 &IID_IHttpNegotiate2, (void**)&This->http_negotiate2);
278 return IBindStatusCallback_QueryInterface(STATUSCLB(This), riid, ppv);
281 if(IsEqualGUID(&IID_IAuthenticate, guidService)) {
282 TRACE("(%p)->(IID_IAuthenticate %s %p)\n", This, debugstr_guid(riid), ppv);
284 if(!This->init_authenticate) {
285 This->init_authenticate = TRUE;
286 hres = IBindStatusCallback_QueryInterface(This->callback, &IID_IAuthenticate,
287 (void**)&This->authenticate);
288 if(FAILED(hres) && This->serv_prov)
289 IServiceProvider_QueryService(This->serv_prov, &IID_IAuthenticate,
290 &IID_IAuthenticate, (void**)&This->authenticate);
293 return IBindStatusCallback_QueryInterface(STATUSCLB(This), riid, ppv);
296 TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
298 hres = IBindStatusCallback_QueryInterface(This->callback, riid, ppv);
302 if(This->serv_prov) {
303 hres = IServiceProvider_QueryService(This->serv_prov, guidService, riid, ppv);
308 return E_NOINTERFACE;
313 static const IServiceProviderVtbl BSCServiceProviderVtbl = {
314 BSCServiceProvider_QueryInterface,
315 BSCServiceProvider_AddRef,
316 BSCServiceProvider_Release,
317 BSCServiceProvider_QueryService
320 #define HTTPNEG2_THIS(iface) DEFINE_THIS(BindStatusCallback, HttpNegotiate2, iface)
322 static HRESULT WINAPI BSCHttpNegotiate_QueryInterface(IHttpNegotiate2 *iface,
323 REFIID riid, void **ppv)
325 BindStatusCallback *This = HTTPNEG2_THIS(iface);
326 return IBindStatusCallback_QueryInterface(STATUSCLB(This), riid, ppv);
329 static ULONG WINAPI BSCHttpNegotiate_AddRef(IHttpNegotiate2 *iface)
331 BindStatusCallback *This = HTTPNEG2_THIS(iface);
332 return IBindStatusCallback_AddRef(STATUSCLB(This));
335 static ULONG WINAPI BSCHttpNegotiate_Release(IHttpNegotiate2 *iface)
337 BindStatusCallback *This = HTTPNEG2_THIS(iface);
338 return IBindStatusCallback_Release(STATUSCLB(This));
341 static HRESULT WINAPI BSCHttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface,
342 LPCWSTR szURL, LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
344 BindStatusCallback *This = HTTPNEG2_THIS(iface);
346 TRACE("(%p)->(%s %s %d %p)\n", This, debugstr_w(szURL), debugstr_w(szHeaders), dwReserved,
347 pszAdditionalHeaders);
349 *pszAdditionalHeaders = NULL;
351 if(!This->http_negotiate)
354 return IHttpNegotiate_BeginningTransaction(This->http_negotiate, szURL, szHeaders,
355 dwReserved, pszAdditionalHeaders);
358 static HRESULT WINAPI BSCHttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode,
359 LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders,
360 LPWSTR *pszAdditionalRequestHeaders)
362 BindStatusCallback *This = HTTPNEG2_THIS(iface);
363 LPWSTR additional_headers = NULL;
366 TRACE("(%p)->(%d %s %s %p)\n", This, dwResponseCode, debugstr_w(szResponseHeaders),
367 debugstr_w(szRequestHeaders), pszAdditionalRequestHeaders);
369 if(This->http_negotiate)
370 hres = IHttpNegotiate_OnResponse(This->http_negotiate, dwResponseCode, szResponseHeaders,
371 szRequestHeaders, &additional_headers);
373 if(pszAdditionalRequestHeaders)
374 *pszAdditionalRequestHeaders = additional_headers;
375 else if(additional_headers)
376 CoTaskMemFree(additional_headers);
381 static HRESULT WINAPI BSCHttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface,
382 BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
384 BindStatusCallback *This = HTTPNEG2_THIS(iface);
386 TRACE("(%p)->(%p %p %ld)\n", This, pbSecurityId, pcbSecurityId, dwReserved);
388 if(!This->http_negotiate2)
391 return IHttpNegotiate2_GetRootSecurityId(This->http_negotiate2, pbSecurityId,
392 pcbSecurityId, dwReserved);
397 static const IHttpNegotiate2Vtbl BSCHttpNegotiateVtbl = {
398 BSCHttpNegotiate_QueryInterface,
399 BSCHttpNegotiate_AddRef,
400 BSCHttpNegotiate_Release,
401 BSCHttpNegotiate_BeginningTransaction,
402 BSCHttpNegotiate_OnResponse,
403 BSCHttpNegotiate_GetRootSecurityId
406 #define AUTHENTICATE_THIS(iface) DEFINE_THIS(BindStatusCallback, Authenticate, iface)
408 static HRESULT WINAPI BSCAuthenticate_QueryInterface(IAuthenticate *iface, REFIID riid, void **ppv)
410 BindStatusCallback *This = AUTHENTICATE_THIS(iface);
411 return IBindStatusCallback_QueryInterface(AUTHENTICATE(This), riid, ppv);
414 static ULONG WINAPI BSCAuthenticate_AddRef(IAuthenticate *iface)
416 BindStatusCallback *This = AUTHENTICATE_THIS(iface);
417 return IBindStatusCallback_AddRef(STATUSCLB(This));
420 static ULONG WINAPI BSCAuthenticate_Release(IAuthenticate *iface)
422 BindStatusCallback *This = AUTHENTICATE_THIS(iface);
423 return IBindStatusCallback_Release(STATUSCLB(This));
426 static HRESULT WINAPI BSCAuthenticate_Authenticate(IAuthenticate *iface,
427 HWND *phwnd, LPWSTR *pszUsername, LPWSTR *pszPassword)
429 BindStatusCallback *This = AUTHENTICATE_THIS(iface);
430 FIXME("(%p)->(%p %p %p)\n", This, phwnd, pszUsername, pszPassword);
434 #undef AUTHENTICATE_THIS
436 static const IAuthenticateVtbl BSCAuthenticateVtbl = {
437 BSCAuthenticate_QueryInterface,
438 BSCAuthenticate_AddRef,
439 BSCAuthenticate_Release,
440 BSCAuthenticate_Authenticate
443 static IBindStatusCallback *create_bsc(IBindStatusCallback *bsc)
445 BindStatusCallback *ret = heap_alloc_zero(sizeof(BindStatusCallback));
447 ret->lpBindStatusCallbackVtbl = &BindStatusCallbackVtbl;
448 ret->lpServiceProviderVtbl = &BSCServiceProviderVtbl;
449 ret->lpHttpNegotiate2Vtbl = &BSCHttpNegotiateVtbl;
450 ret->lpAuthenticateVtbl = &BSCAuthenticateVtbl;
454 IBindStatusCallback_AddRef(bsc);
457 IBindStatusCallback_QueryInterface(bsc, &IID_IServiceProvider, (void**)&ret->serv_prov);
459 return STATUSCLB(ret);
462 /***********************************************************************
463 * RegisterBindStatusCallback (urlmon.@)
465 * Register a bind status callback.
468 * pbc [I] Binding context
469 * pbsc [I] Callback to register
470 * ppbscPrevious [O] Destination for previous callback
471 * dwReserved [I] Reserved, must be 0.
475 * Failure: E_INVALIDARG, if any argument is invalid, or
476 * E_OUTOFMEMORY if memory allocation fails.
478 HRESULT WINAPI RegisterBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pbsc,
479 IBindStatusCallback **ppbscPrevious, DWORD dwReserved)
481 BindStatusCallback *holder;
482 IBindStatusCallback *bsc, *prev = NULL;
486 TRACE("(%p %p %p %x)\n", pbc, pbsc, ppbscPrevious, dwReserved);
491 hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, &unk);
492 if(SUCCEEDED(hres)) {
493 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&bsc);
494 if(SUCCEEDED(hres)) {
495 hres = IBindStatusCallback_QueryInterface(bsc, &IID_IBindStatusCallbackHolder, (void**)&holder);
496 if(SUCCEEDED(hres)) {
497 prev = holder->callback;
498 IBindStatusCallback_AddRef(prev);
499 IBindStatusCallback_Release(bsc);
500 IBindStatusCallback_Release(STATUSCLB(holder));
506 IUnknown_Release(unk);
507 IBindCtx_RevokeObjectParam(pbc, BSCBHolder);
510 bsc = create_bsc(pbsc);
511 hres = IBindCtx_RegisterObjectParam(pbc, BSCBHolder, (IUnknown*)bsc);
512 IBindStatusCallback_Release(bsc);
515 IBindStatusCallback_Release(prev);
520 *ppbscPrevious = prev;
524 /***********************************************************************
525 * RevokeBindStatusCallback (URLMON.@)
527 * Unregister a bind status callback.
529 * pbc [I] Binding context
530 * pbsc [I] Callback to unregister
534 * Failure: E_INVALIDARG, if any argument is invalid
536 HRESULT WINAPI RevokeBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pbsc)
538 BindStatusCallback *holder;
539 IBindStatusCallback *callback;
541 BOOL dorevoke = FALSE;
544 TRACE("(%p %p)\n", pbc, pbsc);
549 hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, &unk);
553 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&callback);
554 IUnknown_Release(unk);
558 hres = IBindStatusCallback_QueryInterface(callback, &IID_IBindStatusCallbackHolder, (void**)&holder);
559 if(SUCCEEDED(hres)) {
560 if(pbsc == holder->callback)
562 IBindStatusCallback_Release(STATUSCLB(holder));
563 }else if(pbsc == callback) {
566 IBindStatusCallback_Release(callback);
569 IBindCtx_RevokeObjectParam(pbc, BSCBHolder);
575 const IBindCtxVtbl *lpBindCtxVtbl;
582 #define BINDCTX(x) ((IBindCtx*) &(x)->lpBindCtxVtbl)
584 #define BINDCTX_THIS(iface) DEFINE_THIS(AsyncBindCtx, BindCtx, iface)
586 static HRESULT WINAPI AsyncBindCtx_QueryInterface(IBindCtx *iface, REFIID riid, void **ppv)
588 AsyncBindCtx *This = BINDCTX_THIS(iface);
592 if(IsEqualGUID(riid, &IID_IUnknown)) {
593 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
594 *ppv = BINDCTX(This);
595 }else if(IsEqualGUID(riid, &IID_IBindCtx)) {
596 TRACE("(%p)->(IID_IBindCtx %p)\n", This, ppv);
597 *ppv = BINDCTX(This);
598 }else if(IsEqualGUID(riid, &IID_IAsyncBindCtx)) {
599 TRACE("(%p)->(IID_IAsyncBindCtx %p)\n", This, ppv);
600 *ppv = BINDCTX(This);
604 IUnknown_AddRef((IUnknown*)*ppv);
608 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
609 return E_NOINTERFACE;
612 static ULONG WINAPI AsyncBindCtx_AddRef(IBindCtx *iface)
614 AsyncBindCtx *This = BINDCTX_THIS(iface);
615 LONG ref = InterlockedIncrement(&This->ref);
617 TRACE("(%p) ref=%d\n", This, ref);
622 static ULONG WINAPI AsyncBindCtx_Release(IBindCtx *iface)
624 AsyncBindCtx *This = BINDCTX_THIS(iface);
625 LONG ref = InterlockedDecrement(&This->ref);
627 TRACE("(%p) ref=%d\n", This, ref);
630 IBindCtx_Release(This->bindctx);
637 static HRESULT WINAPI AsyncBindCtx_RegisterObjectBound(IBindCtx *iface, IUnknown *punk)
639 AsyncBindCtx *This = BINDCTX_THIS(iface);
641 TRACE("(%p)->(%p)\n", This, punk);
643 return IBindCtx_RegisterObjectBound(This->bindctx, punk);
646 static HRESULT WINAPI AsyncBindCtx_RevokeObjectBound(IBindCtx *iface, IUnknown *punk)
648 AsyncBindCtx *This = BINDCTX_THIS(iface);
650 TRACE("(%p %p)\n", This, punk);
652 return IBindCtx_RevokeObjectBound(This->bindctx, punk);
655 static HRESULT WINAPI AsyncBindCtx_ReleaseBoundObjects(IBindCtx *iface)
657 AsyncBindCtx *This = BINDCTX_THIS(iface);
659 TRACE("(%p)\n", This);
661 return IBindCtx_ReleaseBoundObjects(This->bindctx);
664 static HRESULT WINAPI AsyncBindCtx_SetBindOptions(IBindCtx *iface, BIND_OPTS *pbindopts)
666 AsyncBindCtx *This = BINDCTX_THIS(iface);
668 TRACE("(%p)->(%p)\n", This, pbindopts);
670 return IBindCtx_SetBindOptions(This->bindctx, pbindopts);
673 static HRESULT WINAPI AsyncBindCtx_GetBindOptions(IBindCtx *iface, BIND_OPTS *pbindopts)
675 AsyncBindCtx *This = BINDCTX_THIS(iface);
677 TRACE("(%p)->(%p)\n", This, pbindopts);
679 return IBindCtx_GetBindOptions(This->bindctx, pbindopts);
682 static HRESULT WINAPI AsyncBindCtx_GetRunningObjectTable(IBindCtx *iface, IRunningObjectTable **pprot)
684 AsyncBindCtx *This = BINDCTX_THIS(iface);
686 TRACE("(%p)->(%p)\n", This, pprot);
688 return IBindCtx_GetRunningObjectTable(This->bindctx, pprot);
691 static HRESULT WINAPI AsyncBindCtx_RegisterObjectParam(IBindCtx *iface, LPOLESTR pszkey, IUnknown *punk)
693 AsyncBindCtx *This = BINDCTX_THIS(iface);
695 TRACE("(%p)->(%s %p)\n", This, debugstr_w(pszkey), punk);
697 return IBindCtx_RegisterObjectParam(This->bindctx, pszkey, punk);
700 static HRESULT WINAPI AsyncBindCtx_GetObjectParam(IBindCtx* iface, LPOLESTR pszkey, IUnknown **punk)
702 AsyncBindCtx *This = BINDCTX_THIS(iface);
704 TRACE("(%p)->(%s %p)\n", This, debugstr_w(pszkey), punk);
706 return IBindCtx_GetObjectParam(This->bindctx, pszkey, punk);
709 static HRESULT WINAPI AsyncBindCtx_RevokeObjectParam(IBindCtx *iface, LPOLESTR pszkey)
711 AsyncBindCtx *This = BINDCTX_THIS(iface);
713 TRACE("(%p)->(%s)\n", This, debugstr_w(pszkey));
715 return IBindCtx_RevokeObjectParam(This->bindctx, pszkey);
718 static HRESULT WINAPI AsyncBindCtx_EnumObjectParam(IBindCtx *iface, IEnumString **pszkey)
720 AsyncBindCtx *This = BINDCTX_THIS(iface);
722 TRACE("(%p)->(%p)\n", This, pszkey);
724 return IBindCtx_EnumObjectParam(This->bindctx, pszkey);
729 static const IBindCtxVtbl AsyncBindCtxVtbl =
731 AsyncBindCtx_QueryInterface,
733 AsyncBindCtx_Release,
734 AsyncBindCtx_RegisterObjectBound,
735 AsyncBindCtx_RevokeObjectBound,
736 AsyncBindCtx_ReleaseBoundObjects,
737 AsyncBindCtx_SetBindOptions,
738 AsyncBindCtx_GetBindOptions,
739 AsyncBindCtx_GetRunningObjectTable,
740 AsyncBindCtx_RegisterObjectParam,
741 AsyncBindCtx_GetObjectParam,
742 AsyncBindCtx_EnumObjectParam,
743 AsyncBindCtx_RevokeObjectParam
746 static HRESULT init_bindctx(IBindCtx *bindctx, DWORD options,
747 IBindStatusCallback *callback, IEnumFORMATETC *format)
753 FIXME("not supported options %08x\n", options);
755 FIXME("format is not supported\n");
757 bindopts.cbStruct = sizeof(BIND_OPTS);
758 bindopts.grfFlags = BIND_MAYBOTHERUSER;
759 bindopts.grfMode = STGM_READWRITE | STGM_SHARE_EXCLUSIVE;
760 bindopts.dwTickCountDeadline = 0;
762 hres = IBindCtx_SetBindOptions(bindctx, &bindopts);
767 hres = RegisterBindStatusCallback(bindctx, callback, NULL, 0);
775 /***********************************************************************
776 * CreateAsyncBindCtx (urlmon.@)
778 HRESULT WINAPI CreateAsyncBindCtx(DWORD reserved, IBindStatusCallback *callback,
779 IEnumFORMATETC *format, IBindCtx **pbind)
784 TRACE("(%08x %p %p %p)\n", reserved, callback, format, pbind);
786 if(!pbind || !callback)
789 hres = CreateBindCtx(0, &bindctx);
793 hres = init_bindctx(bindctx, 0, callback, format);
795 IBindCtx_Release(bindctx);
803 /***********************************************************************
804 * CreateAsyncBindCtxEx (urlmon.@)
806 * Create an asynchronous bind context.
808 HRESULT WINAPI CreateAsyncBindCtxEx(IBindCtx *ibind, DWORD options,
809 IBindStatusCallback *callback, IEnumFORMATETC *format, IBindCtx** pbind,
816 TRACE("(%p %08x %p %p %p %d)\n", ibind, options, callback, format, pbind, reserved);
822 WARN("reserved=%d\n", reserved);
825 IBindCtx_AddRef(ibind);
828 hres = CreateBindCtx(0, &bindctx);
833 ret = heap_alloc(sizeof(AsyncBindCtx));
835 ret->lpBindCtxVtbl = &AsyncBindCtxVtbl;
837 ret->bindctx = bindctx;
839 hres = init_bindctx(BINDCTX(ret), options, callback, format);
841 IBindCtx_Release(BINDCTX(ret));
845 *pbind = BINDCTX(ret);