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;
42 #define STATUSCLB(x) ((IBindStatusCallback*) &(x)->lpBindStatusCallbackVtbl)
43 #define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl)
44 #define HTTPNEG2(x) ((IHttpNegotiate2*) &(x)->lpHttpNegotiate2Vtbl)
45 #define AUTHENTICATE(x) ((IAuthenticate*) &(x)->lpAuthenticateVtbl)
47 static void *get_callback_iface(BindStatusCallback *This, REFIID riid)
52 hres = IBindStatusCallback_QueryInterface(This->callback, riid, (void**)&ret);
53 if(FAILED(hres) && This->serv_prov)
54 hres = IServiceProvider_QueryService(This->serv_prov, riid, riid, &ret);
56 return SUCCEEDED(hres) ? ret : NULL;
59 #define STATUSCLB_THIS(iface) DEFINE_THIS(BindStatusCallback, BindStatusCallback, iface)
61 static HRESULT WINAPI BindStatusCallback_QueryInterface(IBindStatusCallback *iface,
62 REFIID riid, void **ppv)
64 BindStatusCallback *This = STATUSCLB_THIS(iface);
68 if(IsEqualGUID(&IID_IUnknown, riid)) {
69 TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppv);
70 *ppv = STATUSCLB(This);
71 }else if(IsEqualGUID(&IID_IBindStatusCallback, riid)) {
72 TRACE("(%p)->(IID_IBindStatusCallback, %p)\n", This, ppv);
73 *ppv = STATUSCLB(This);
74 }else if(IsEqualGUID(&IID_IBindStatusCallbackHolder, riid)) {
75 TRACE("(%p)->(IID_IBindStatusCallbackHolder, %p)\n", This, ppv);
77 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
78 TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppv);
79 *ppv = SERVPROV(This);
80 }else if(IsEqualGUID(&IID_IHttpNegotiate, riid)) {
81 TRACE("(%p)->(IID_IHttpNegotiate, %p)\n", This, ppv);
82 *ppv = HTTPNEG2(This);
83 }else if(IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
84 TRACE("(%p)->(IID_IHttpNegotiate2, %p)\n", This, ppv);
85 *ppv = HTTPNEG2(This);
86 }else if(IsEqualGUID(&IID_IAuthenticate, riid)) {
87 TRACE("(%p)->(IID_IAuthenticate, %p)\n", This, ppv);
88 *ppv = AUTHENTICATE(This);
92 IBindStatusCallback_AddRef((IUnknown*)*ppv);
96 TRACE("Unsupported riid = %s\n", debugstr_guid(riid));
100 static ULONG WINAPI BindStatusCallback_AddRef(IBindStatusCallback *iface)
102 BindStatusCallback *This = STATUSCLB_THIS(iface);
103 LONG ref = InterlockedIncrement(&This->ref);
105 TRACE("(%p) ref = %d\n", This, ref);
110 static ULONG WINAPI BindStatusCallback_Release(IBindStatusCallback *iface)
112 BindStatusCallback *This = STATUSCLB_THIS(iface);
113 LONG ref = InterlockedDecrement(&This->ref);
115 TRACE("(%p) ref = %d\n", This, ref);
119 IServiceProvider_Release(This->serv_prov);
120 IBindStatusCallback_Release(This->callback);
127 static HRESULT WINAPI BindStatusCallback_OnStartBinding(IBindStatusCallback *iface,
128 DWORD dwReserved, IBinding *pbind)
130 BindStatusCallback *This = STATUSCLB_THIS(iface);
132 TRACE("(%p)->(%d %p)\n", This, dwReserved, pbind);
134 return IBindStatusCallback_OnStartBinding(This->callback, 0xff, pbind);
137 static HRESULT WINAPI BindStatusCallback_GetPriority(IBindStatusCallback *iface, LONG *pnPriority)
139 BindStatusCallback *This = STATUSCLB_THIS(iface);
141 TRACE("(%p)->(%p)\n", This, pnPriority);
143 return IBindStatusCallback_GetPriority(This->callback, pnPriority);
146 static HRESULT WINAPI BindStatusCallback_OnLowResource(IBindStatusCallback *iface, DWORD reserved)
148 BindStatusCallback *This = STATUSCLB_THIS(iface);
150 TRACE("(%p)->(%d)\n", This, reserved);
152 return IBindStatusCallback_OnLowResource(This->callback, reserved);
155 static HRESULT WINAPI BindStatusCallback_OnProgress(IBindStatusCallback *iface, ULONG ulProgress,
156 ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
158 BindStatusCallback *This = STATUSCLB_THIS(iface);
160 TRACE("%p)->(%u %u %u %s)\n", This, ulProgress, ulProgressMax, ulStatusCode,
161 debugstr_w(szStatusText));
163 return IBindStatusCallback_OnProgress(This->callback, ulProgress,
164 ulProgressMax, ulStatusCode, szStatusText);
167 static HRESULT WINAPI BindStatusCallback_OnStopBinding(IBindStatusCallback *iface,
168 HRESULT hresult, LPCWSTR szError)
170 BindStatusCallback *This = STATUSCLB_THIS(iface);
172 TRACE("(%p)->(%08x %s)\n", This, hresult, debugstr_w(szError));
174 return IBindStatusCallback_OnStopBinding(This->callback, hresult, szError);
177 static HRESULT WINAPI BindStatusCallback_GetBindInfo(IBindStatusCallback *iface,
178 DWORD *grfBINDF, BINDINFO *pbindinfo)
180 BindStatusCallback *This = STATUSCLB_THIS(iface);
182 TRACE("(%p)->(%p %p)\n", This, grfBINDF, pbindinfo);
184 return IBindStatusCallback_GetBindInfo(This->callback, grfBINDF, pbindinfo);
187 static HRESULT WINAPI BindStatusCallback_OnDataAvailable(IBindStatusCallback *iface,
188 DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
190 BindStatusCallback *This = STATUSCLB_THIS(iface);
192 TRACE("(%p)->(%08x %d %p %p)\n", This, grfBSCF, dwSize, pformatetc, pstgmed);
194 return IBindStatusCallback_OnDataAvailable(This->callback, grfBSCF, dwSize, pformatetc, pstgmed);
197 static HRESULT WINAPI BindStatusCallback_OnObjectAvailable(IBindStatusCallback *iface,
198 REFIID riid, IUnknown *punk)
200 BindStatusCallback *This = STATUSCLB_THIS(iface);
202 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), punk);
204 return IBindStatusCallback_OnObjectAvailable(This->callback, riid, punk);
207 #undef STATUSCLB_THIS
209 static const IBindStatusCallbackVtbl BindStatusCallbackVtbl = {
210 BindStatusCallback_QueryInterface,
211 BindStatusCallback_AddRef,
212 BindStatusCallback_Release,
213 BindStatusCallback_OnStartBinding,
214 BindStatusCallback_GetPriority,
215 BindStatusCallback_OnLowResource,
216 BindStatusCallback_OnProgress,
217 BindStatusCallback_OnStopBinding,
218 BindStatusCallback_GetBindInfo,
219 BindStatusCallback_OnDataAvailable,
220 BindStatusCallback_OnObjectAvailable
223 #define SERVPROV_THIS(iface) DEFINE_THIS(BindStatusCallback, ServiceProvider, iface)
225 static HRESULT WINAPI BSCServiceProvider_QueryInterface(IServiceProvider *iface,
226 REFIID riid, void **ppv)
228 BindStatusCallback *This = SERVPROV_THIS(iface);
229 return IBindStatusCallback_QueryInterface(STATUSCLB(This), riid, ppv);
232 static ULONG WINAPI BSCServiceProvider_AddRef(IServiceProvider *iface)
234 BindStatusCallback *This = SERVPROV_THIS(iface);
235 return IBindStatusCallback_AddRef(STATUSCLB(This));
238 static ULONG WINAPI BSCServiceProvider_Release(IServiceProvider *iface)
240 BindStatusCallback *This = SERVPROV_THIS(iface);
241 return IBindStatusCallback_Release(STATUSCLB(This));
244 static HRESULT WINAPI BSCServiceProvider_QueryService(IServiceProvider *iface,
245 REFGUID guidService, REFIID riid, void **ppv)
247 BindStatusCallback *This = SERVPROV_THIS(iface);
250 if(IsEqualGUID(&IID_IHttpNegotiate, guidService)) {
251 TRACE("(%p)->(IID_IHttpNegotiate %s %p)\n", This, debugstr_guid(riid), ppv);
252 return IBindStatusCallback_QueryInterface(STATUSCLB(This), riid, ppv);
255 if(IsEqualGUID(&IID_IHttpNegotiate2, guidService)) {
256 TRACE("(%p)->(IID_IHttpNegotiate2 %s %p)\n", This, debugstr_guid(riid), ppv);
257 return IBindStatusCallback_QueryInterface(STATUSCLB(This), riid, ppv);
260 if(IsEqualGUID(&IID_IAuthenticate, guidService)) {
261 TRACE("(%p)->(IID_IAuthenticate %s %p)\n", This, debugstr_guid(riid), ppv);
262 return IBindStatusCallback_QueryInterface(STATUSCLB(This), riid, ppv);
265 TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
267 hres = IBindStatusCallback_QueryInterface(This->callback, riid, ppv);
271 if(This->serv_prov) {
272 hres = IServiceProvider_QueryService(This->serv_prov, guidService, riid, ppv);
277 return E_NOINTERFACE;
282 static const IServiceProviderVtbl BSCServiceProviderVtbl = {
283 BSCServiceProvider_QueryInterface,
284 BSCServiceProvider_AddRef,
285 BSCServiceProvider_Release,
286 BSCServiceProvider_QueryService
289 #define HTTPNEG2_THIS(iface) DEFINE_THIS(BindStatusCallback, HttpNegotiate2, iface)
291 static HRESULT WINAPI BSCHttpNegotiate_QueryInterface(IHttpNegotiate2 *iface,
292 REFIID riid, void **ppv)
294 BindStatusCallback *This = HTTPNEG2_THIS(iface);
295 return IBindStatusCallback_QueryInterface(STATUSCLB(This), riid, ppv);
298 static ULONG WINAPI BSCHttpNegotiate_AddRef(IHttpNegotiate2 *iface)
300 BindStatusCallback *This = HTTPNEG2_THIS(iface);
301 return IBindStatusCallback_AddRef(STATUSCLB(This));
304 static ULONG WINAPI BSCHttpNegotiate_Release(IHttpNegotiate2 *iface)
306 BindStatusCallback *This = HTTPNEG2_THIS(iface);
307 return IBindStatusCallback_Release(STATUSCLB(This));
310 static HRESULT WINAPI BSCHttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface,
311 LPCWSTR szURL, LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
313 BindStatusCallback *This = HTTPNEG2_THIS(iface);
314 IHttpNegotiate *http_negotiate;
317 TRACE("(%p)->(%s %s %d %p)\n", This, debugstr_w(szURL), debugstr_w(szHeaders), dwReserved,
318 pszAdditionalHeaders);
320 *pszAdditionalHeaders = NULL;
322 http_negotiate = get_callback_iface(This, &IID_IHttpNegotiate);
324 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, szURL, szHeaders,
325 dwReserved, pszAdditionalHeaders);
326 IHttpNegotiate_Release(http_negotiate);
332 static HRESULT WINAPI BSCHttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode,
333 LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders,
334 LPWSTR *pszAdditionalRequestHeaders)
336 BindStatusCallback *This = HTTPNEG2_THIS(iface);
337 LPWSTR additional_headers = NULL;
338 IHttpNegotiate *http_negotiate;
341 TRACE("(%p)->(%d %s %s %p)\n", This, dwResponseCode, debugstr_w(szResponseHeaders),
342 debugstr_w(szRequestHeaders), pszAdditionalRequestHeaders);
344 http_negotiate = get_callback_iface(This, &IID_IHttpNegotiate);
346 hres = IHttpNegotiate_OnResponse(http_negotiate, dwResponseCode, szResponseHeaders,
347 szRequestHeaders, &additional_headers);
348 IHttpNegotiate_Release(http_negotiate);
351 if(pszAdditionalRequestHeaders)
352 *pszAdditionalRequestHeaders = additional_headers;
353 else if(additional_headers)
354 CoTaskMemFree(additional_headers);
359 static HRESULT WINAPI BSCHttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface,
360 BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
362 BindStatusCallback *This = HTTPNEG2_THIS(iface);
363 IHttpNegotiate2 *http_negotiate2;
364 HRESULT hres = E_FAIL;
366 TRACE("(%p)->(%p %p %ld)\n", This, pbSecurityId, pcbSecurityId, dwReserved);
368 http_negotiate2 = get_callback_iface(This, &IID_IHttpNegotiate2);
369 if(http_negotiate2) {
370 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, pbSecurityId,
371 pcbSecurityId, dwReserved);
372 IHttpNegotiate2_Release(http_negotiate2);
380 static const IHttpNegotiate2Vtbl BSCHttpNegotiateVtbl = {
381 BSCHttpNegotiate_QueryInterface,
382 BSCHttpNegotiate_AddRef,
383 BSCHttpNegotiate_Release,
384 BSCHttpNegotiate_BeginningTransaction,
385 BSCHttpNegotiate_OnResponse,
386 BSCHttpNegotiate_GetRootSecurityId
389 #define AUTHENTICATE_THIS(iface) DEFINE_THIS(BindStatusCallback, Authenticate, iface)
391 static HRESULT WINAPI BSCAuthenticate_QueryInterface(IAuthenticate *iface, REFIID riid, void **ppv)
393 BindStatusCallback *This = AUTHENTICATE_THIS(iface);
394 return IBindStatusCallback_QueryInterface(AUTHENTICATE(This), riid, ppv);
397 static ULONG WINAPI BSCAuthenticate_AddRef(IAuthenticate *iface)
399 BindStatusCallback *This = AUTHENTICATE_THIS(iface);
400 return IBindStatusCallback_AddRef(STATUSCLB(This));
403 static ULONG WINAPI BSCAuthenticate_Release(IAuthenticate *iface)
405 BindStatusCallback *This = AUTHENTICATE_THIS(iface);
406 return IBindStatusCallback_Release(STATUSCLB(This));
409 static HRESULT WINAPI BSCAuthenticate_Authenticate(IAuthenticate *iface,
410 HWND *phwnd, LPWSTR *pszUsername, LPWSTR *pszPassword)
412 BindStatusCallback *This = AUTHENTICATE_THIS(iface);
413 FIXME("(%p)->(%p %p %p)\n", This, phwnd, pszUsername, pszPassword);
417 #undef AUTHENTICATE_THIS
419 static const IAuthenticateVtbl BSCAuthenticateVtbl = {
420 BSCAuthenticate_QueryInterface,
421 BSCAuthenticate_AddRef,
422 BSCAuthenticate_Release,
423 BSCAuthenticate_Authenticate
426 static IBindStatusCallback *create_bsc(IBindStatusCallback *bsc)
428 BindStatusCallback *ret = heap_alloc_zero(sizeof(BindStatusCallback));
430 ret->lpBindStatusCallbackVtbl = &BindStatusCallbackVtbl;
431 ret->lpServiceProviderVtbl = &BSCServiceProviderVtbl;
432 ret->lpHttpNegotiate2Vtbl = &BSCHttpNegotiateVtbl;
433 ret->lpAuthenticateVtbl = &BSCAuthenticateVtbl;
437 IBindStatusCallback_AddRef(bsc);
440 IBindStatusCallback_QueryInterface(bsc, &IID_IServiceProvider, (void**)&ret->serv_prov);
442 return STATUSCLB(ret);
445 /***********************************************************************
446 * RegisterBindStatusCallback (urlmon.@)
448 * Register a bind status callback.
451 * pbc [I] Binding context
452 * pbsc [I] Callback to register
453 * ppbscPrevious [O] Destination for previous callback
454 * dwReserved [I] Reserved, must be 0.
458 * Failure: E_INVALIDARG, if any argument is invalid, or
459 * E_OUTOFMEMORY if memory allocation fails.
461 HRESULT WINAPI RegisterBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pbsc,
462 IBindStatusCallback **ppbscPrevious, DWORD dwReserved)
464 BindStatusCallback *holder;
465 IBindStatusCallback *bsc, *prev = NULL;
469 TRACE("(%p %p %p %x)\n", pbc, pbsc, ppbscPrevious, dwReserved);
474 hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, &unk);
475 if(SUCCEEDED(hres)) {
476 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&bsc);
477 if(SUCCEEDED(hres)) {
478 hres = IBindStatusCallback_QueryInterface(bsc, &IID_IBindStatusCallbackHolder, (void**)&holder);
479 if(SUCCEEDED(hres)) {
480 prev = holder->callback;
481 IBindStatusCallback_AddRef(prev);
482 IBindStatusCallback_Release(bsc);
483 IBindStatusCallback_Release(STATUSCLB(holder));
489 IUnknown_Release(unk);
490 IBindCtx_RevokeObjectParam(pbc, BSCBHolder);
493 bsc = create_bsc(pbsc);
494 hres = IBindCtx_RegisterObjectParam(pbc, BSCBHolder, (IUnknown*)bsc);
495 IBindStatusCallback_Release(bsc);
498 IBindStatusCallback_Release(prev);
503 *ppbscPrevious = prev;
507 /***********************************************************************
508 * RevokeBindStatusCallback (URLMON.@)
510 * Unregister a bind status callback.
512 * pbc [I] Binding context
513 * pbsc [I] Callback to unregister
517 * Failure: E_INVALIDARG, if any argument is invalid
519 HRESULT WINAPI RevokeBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pbsc)
521 BindStatusCallback *holder;
522 IBindStatusCallback *callback;
524 BOOL dorevoke = FALSE;
527 TRACE("(%p %p)\n", pbc, pbsc);
532 hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, &unk);
536 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&callback);
537 IUnknown_Release(unk);
541 hres = IBindStatusCallback_QueryInterface(callback, &IID_IBindStatusCallbackHolder, (void**)&holder);
542 if(SUCCEEDED(hres)) {
543 if(pbsc == holder->callback)
545 IBindStatusCallback_Release(STATUSCLB(holder));
546 }else if(pbsc == callback) {
549 IBindStatusCallback_Release(callback);
552 IBindCtx_RevokeObjectParam(pbc, BSCBHolder);
558 const IBindCtxVtbl *lpBindCtxVtbl;
565 #define BINDCTX(x) ((IBindCtx*) &(x)->lpBindCtxVtbl)
567 #define BINDCTX_THIS(iface) DEFINE_THIS(AsyncBindCtx, BindCtx, iface)
569 static HRESULT WINAPI AsyncBindCtx_QueryInterface(IBindCtx *iface, REFIID riid, void **ppv)
571 AsyncBindCtx *This = BINDCTX_THIS(iface);
575 if(IsEqualGUID(riid, &IID_IUnknown)) {
576 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
577 *ppv = BINDCTX(This);
578 }else if(IsEqualGUID(riid, &IID_IBindCtx)) {
579 TRACE("(%p)->(IID_IBindCtx %p)\n", This, ppv);
580 *ppv = BINDCTX(This);
581 }else if(IsEqualGUID(riid, &IID_IAsyncBindCtx)) {
582 TRACE("(%p)->(IID_IAsyncBindCtx %p)\n", This, ppv);
583 *ppv = BINDCTX(This);
587 IUnknown_AddRef((IUnknown*)*ppv);
591 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
592 return E_NOINTERFACE;
595 static ULONG WINAPI AsyncBindCtx_AddRef(IBindCtx *iface)
597 AsyncBindCtx *This = BINDCTX_THIS(iface);
598 LONG ref = InterlockedIncrement(&This->ref);
600 TRACE("(%p) ref=%d\n", This, ref);
605 static ULONG WINAPI AsyncBindCtx_Release(IBindCtx *iface)
607 AsyncBindCtx *This = BINDCTX_THIS(iface);
608 LONG ref = InterlockedDecrement(&This->ref);
610 TRACE("(%p) ref=%d\n", This, ref);
613 IBindCtx_Release(This->bindctx);
620 static HRESULT WINAPI AsyncBindCtx_RegisterObjectBound(IBindCtx *iface, IUnknown *punk)
622 AsyncBindCtx *This = BINDCTX_THIS(iface);
624 TRACE("(%p)->(%p)\n", This, punk);
626 return IBindCtx_RegisterObjectBound(This->bindctx, punk);
629 static HRESULT WINAPI AsyncBindCtx_RevokeObjectBound(IBindCtx *iface, IUnknown *punk)
631 AsyncBindCtx *This = BINDCTX_THIS(iface);
633 TRACE("(%p %p)\n", This, punk);
635 return IBindCtx_RevokeObjectBound(This->bindctx, punk);
638 static HRESULT WINAPI AsyncBindCtx_ReleaseBoundObjects(IBindCtx *iface)
640 AsyncBindCtx *This = BINDCTX_THIS(iface);
642 TRACE("(%p)\n", This);
644 return IBindCtx_ReleaseBoundObjects(This->bindctx);
647 static HRESULT WINAPI AsyncBindCtx_SetBindOptions(IBindCtx *iface, BIND_OPTS *pbindopts)
649 AsyncBindCtx *This = BINDCTX_THIS(iface);
651 TRACE("(%p)->(%p)\n", This, pbindopts);
653 return IBindCtx_SetBindOptions(This->bindctx, pbindopts);
656 static HRESULT WINAPI AsyncBindCtx_GetBindOptions(IBindCtx *iface, BIND_OPTS *pbindopts)
658 AsyncBindCtx *This = BINDCTX_THIS(iface);
660 TRACE("(%p)->(%p)\n", This, pbindopts);
662 return IBindCtx_GetBindOptions(This->bindctx, pbindopts);
665 static HRESULT WINAPI AsyncBindCtx_GetRunningObjectTable(IBindCtx *iface, IRunningObjectTable **pprot)
667 AsyncBindCtx *This = BINDCTX_THIS(iface);
669 TRACE("(%p)->(%p)\n", This, pprot);
671 return IBindCtx_GetRunningObjectTable(This->bindctx, pprot);
674 static HRESULT WINAPI AsyncBindCtx_RegisterObjectParam(IBindCtx *iface, LPOLESTR pszkey, IUnknown *punk)
676 AsyncBindCtx *This = BINDCTX_THIS(iface);
678 TRACE("(%p)->(%s %p)\n", This, debugstr_w(pszkey), punk);
680 return IBindCtx_RegisterObjectParam(This->bindctx, pszkey, punk);
683 static HRESULT WINAPI AsyncBindCtx_GetObjectParam(IBindCtx* iface, LPOLESTR pszkey, IUnknown **punk)
685 AsyncBindCtx *This = BINDCTX_THIS(iface);
687 TRACE("(%p)->(%s %p)\n", This, debugstr_w(pszkey), punk);
689 return IBindCtx_GetObjectParam(This->bindctx, pszkey, punk);
692 static HRESULT WINAPI AsyncBindCtx_RevokeObjectParam(IBindCtx *iface, LPOLESTR pszkey)
694 AsyncBindCtx *This = BINDCTX_THIS(iface);
696 TRACE("(%p)->(%s)\n", This, debugstr_w(pszkey));
698 return IBindCtx_RevokeObjectParam(This->bindctx, pszkey);
701 static HRESULT WINAPI AsyncBindCtx_EnumObjectParam(IBindCtx *iface, IEnumString **pszkey)
703 AsyncBindCtx *This = BINDCTX_THIS(iface);
705 TRACE("(%p)->(%p)\n", This, pszkey);
707 return IBindCtx_EnumObjectParam(This->bindctx, pszkey);
712 static const IBindCtxVtbl AsyncBindCtxVtbl =
714 AsyncBindCtx_QueryInterface,
716 AsyncBindCtx_Release,
717 AsyncBindCtx_RegisterObjectBound,
718 AsyncBindCtx_RevokeObjectBound,
719 AsyncBindCtx_ReleaseBoundObjects,
720 AsyncBindCtx_SetBindOptions,
721 AsyncBindCtx_GetBindOptions,
722 AsyncBindCtx_GetRunningObjectTable,
723 AsyncBindCtx_RegisterObjectParam,
724 AsyncBindCtx_GetObjectParam,
725 AsyncBindCtx_EnumObjectParam,
726 AsyncBindCtx_RevokeObjectParam
729 static HRESULT init_bindctx(IBindCtx *bindctx, DWORD options,
730 IBindStatusCallback *callback, IEnumFORMATETC *format)
736 FIXME("not supported options %08x\n", options);
738 FIXME("format is not supported\n");
740 bindopts.cbStruct = sizeof(BIND_OPTS);
741 bindopts.grfFlags = BIND_MAYBOTHERUSER;
742 bindopts.grfMode = STGM_READWRITE | STGM_SHARE_EXCLUSIVE;
743 bindopts.dwTickCountDeadline = 0;
745 hres = IBindCtx_SetBindOptions(bindctx, &bindopts);
750 hres = RegisterBindStatusCallback(bindctx, callback, NULL, 0);
758 /***********************************************************************
759 * CreateAsyncBindCtx (urlmon.@)
761 HRESULT WINAPI CreateAsyncBindCtx(DWORD reserved, IBindStatusCallback *callback,
762 IEnumFORMATETC *format, IBindCtx **pbind)
767 TRACE("(%08x %p %p %p)\n", reserved, callback, format, pbind);
769 if(!pbind || !callback)
772 hres = CreateBindCtx(0, &bindctx);
776 hres = init_bindctx(bindctx, 0, callback, format);
778 IBindCtx_Release(bindctx);
786 /***********************************************************************
787 * CreateAsyncBindCtxEx (urlmon.@)
789 * Create an asynchronous bind context.
791 HRESULT WINAPI CreateAsyncBindCtxEx(IBindCtx *ibind, DWORD options,
792 IBindStatusCallback *callback, IEnumFORMATETC *format, IBindCtx** pbind,
799 TRACE("(%p %08x %p %p %p %d)\n", ibind, options, callback, format, pbind, reserved);
805 WARN("reserved=%d\n", reserved);
808 IBindCtx_AddRef(ibind);
811 hres = CreateBindCtx(0, &bindctx);
816 ret = heap_alloc(sizeof(AsyncBindCtx));
818 ret->lpBindCtxVtbl = &AsyncBindCtxVtbl;
820 ret->bindctx = bindctx;
822 hres = init_bindctx(BINDCTX(ret), options, callback, format);
824 IBindCtx_Release(BINDCTX(ret));
828 *pbind = BINDCTX(ret);