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
23 #define NONAMELESSUNION
24 #define NONAMELESSSTRUCT
32 #include "urlmon_main.h"
34 #include "wine/debug.h"
35 #include "wine/unicode.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
40 const IBindCtxVtbl *lpBindCtxVtbl;
47 #define BINDCTX(x) ((IBindCtx*) &(x)->lpBindCtxVtbl)
49 #define BINDCTX_THIS(iface) DEFINE_THIS(AsyncBindCtx, BindCtx, iface)
51 static HRESULT WINAPI AsyncBindCtx_QueryInterface(IBindCtx *iface, REFIID riid, void **ppv)
53 AsyncBindCtx *This = BINDCTX_THIS(iface);
57 if(IsEqualGUID(riid, &IID_IUnknown)) {
58 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
60 }else if(IsEqualGUID(riid, &IID_IBindCtx)) {
61 TRACE("(%p)->(IID_IBindCtx %p)\n", This, ppv);
63 }else if(IsEqualGUID(riid, &IID_IAsyncBindCtx)) {
64 TRACE("(%p)->(IID_IAsyncBindCtx %p)\n", This, ppv);
69 IUnknown_AddRef((IUnknown*)*ppv);
73 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
77 static ULONG WINAPI AsyncBindCtx_AddRef(IBindCtx *iface)
79 AsyncBindCtx *This = BINDCTX_THIS(iface);
80 LONG ref = InterlockedIncrement(&This->ref);
82 TRACE("(%p) ref=%d\n", This, ref);
87 static ULONG WINAPI AsyncBindCtx_Release(IBindCtx *iface)
89 AsyncBindCtx *This = BINDCTX_THIS(iface);
90 LONG ref = InterlockedDecrement(&This->ref);
92 TRACE("(%p) ref=%d\n", This, ref);
95 IBindCtx_Release(This->bindctx);
96 HeapFree(GetProcessHeap(), 0, This);
102 static HRESULT WINAPI AsyncBindCtx_RegisterObjectBound(IBindCtx *iface, IUnknown *punk)
104 AsyncBindCtx *This = BINDCTX_THIS(iface);
106 TRACE("(%p)->(%p)\n", This, punk);
108 return IBindCtx_RegisterObjectBound(This->bindctx, punk);
111 static HRESULT WINAPI AsyncBindCtx_RevokeObjectBound(IBindCtx *iface, IUnknown *punk)
113 AsyncBindCtx *This = BINDCTX_THIS(iface);
115 TRACE("(%p %p)\n", This, punk);
117 return IBindCtx_RevokeObjectBound(This->bindctx, punk);
120 static HRESULT WINAPI AsyncBindCtx_ReleaseBoundObjects(IBindCtx *iface)
122 AsyncBindCtx *This = BINDCTX_THIS(iface);
124 TRACE("(%p)\n", This);
126 return IBindCtx_ReleaseBoundObjects(This->bindctx);
129 static HRESULT WINAPI AsyncBindCtx_SetBindOptions(IBindCtx *iface, BIND_OPTS *pbindopts)
131 AsyncBindCtx *This = BINDCTX_THIS(iface);
133 TRACE("(%p)->(%p)\n", This, pbindopts);
135 return IBindCtx_SetBindOptions(This->bindctx, pbindopts);
138 static HRESULT WINAPI AsyncBindCtx_GetBindOptions(IBindCtx *iface, BIND_OPTS *pbindopts)
140 AsyncBindCtx *This = BINDCTX_THIS(iface);
142 TRACE("(%p)->(%p)\n", This, pbindopts);
144 return IBindCtx_GetBindOptions(This->bindctx, pbindopts);
147 static HRESULT WINAPI AsyncBindCtx_GetRunningObjectTable(IBindCtx *iface, IRunningObjectTable **pprot)
149 AsyncBindCtx *This = BINDCTX_THIS(iface);
151 TRACE("(%p)->(%p)\n", This, pprot);
153 return IBindCtx_GetRunningObjectTable(This->bindctx, pprot);
156 static HRESULT WINAPI AsyncBindCtx_RegisterObjectParam(IBindCtx *iface, LPOLESTR pszkey, IUnknown *punk)
158 AsyncBindCtx *This = BINDCTX_THIS(iface);
160 TRACE("(%p)->(%s %p)\n", This, debugstr_w(pszkey), punk);
162 return IBindCtx_RegisterObjectParam(This->bindctx, pszkey, punk);
165 static HRESULT WINAPI AsyncBindCtx_GetObjectParam(IBindCtx* iface, LPOLESTR pszkey, IUnknown **punk)
167 AsyncBindCtx *This = BINDCTX_THIS(iface);
169 TRACE("(%p)->(%s %p)\n", This, debugstr_w(pszkey), punk);
171 return IBindCtx_GetObjectParam(This->bindctx, pszkey, punk);
174 static HRESULT WINAPI AsyncBindCtx_RevokeObjectParam(IBindCtx *iface, LPOLESTR ppenum)
176 AsyncBindCtx *This = BINDCTX_THIS(iface);
178 TRACE("(%p)->(%p)\n", This, ppenum);
180 return IBindCtx_RevokeObjectParam(This->bindctx, ppenum);
183 static HRESULT WINAPI AsyncBindCtx_EnumObjectParam(IBindCtx *iface, IEnumString **pszkey)
185 AsyncBindCtx *This = BINDCTX_THIS(iface);
187 TRACE("(%p)->(%p)\n", This, pszkey);
189 return IBindCtx_EnumObjectParam(This->bindctx, pszkey);
194 static const IBindCtxVtbl AsyncBindCtxVtbl =
196 AsyncBindCtx_QueryInterface,
198 AsyncBindCtx_Release,
199 AsyncBindCtx_RegisterObjectBound,
200 AsyncBindCtx_RevokeObjectBound,
201 AsyncBindCtx_ReleaseBoundObjects,
202 AsyncBindCtx_SetBindOptions,
203 AsyncBindCtx_GetBindOptions,
204 AsyncBindCtx_GetRunningObjectTable,
205 AsyncBindCtx_RegisterObjectParam,
206 AsyncBindCtx_GetObjectParam,
207 AsyncBindCtx_EnumObjectParam,
208 AsyncBindCtx_RevokeObjectParam
211 static HRESULT init_bindctx(IBindCtx *bindctx, DWORD options,
212 IBindStatusCallback *callback, IEnumFORMATETC *format)
218 FIXME("not supported options %08x\n", options);
220 FIXME("format is not supported\n");
222 bindopts.cbStruct = sizeof(BIND_OPTS);
223 bindopts.grfFlags = BIND_MAYBOTHERUSER;
224 bindopts.grfMode = STGM_READWRITE | STGM_SHARE_EXCLUSIVE;
225 bindopts.dwTickCountDeadline = 0;
227 hres = IBindCtx_SetBindOptions(bindctx, &bindopts);
232 hres = RegisterBindStatusCallback(bindctx, callback, NULL, 0);
240 /***********************************************************************
241 * CreateAsyncBindCtx (urlmon.@)
243 HRESULT WINAPI CreateAsyncBindCtx(DWORD reserved, IBindStatusCallback *callback,
244 IEnumFORMATETC *format, IBindCtx **pbind)
249 TRACE("(%08x %p %p %p)\n", reserved, callback, format, pbind);
251 if(!pbind || !callback)
254 hres = CreateBindCtx(0, &bindctx);
258 hres = init_bindctx(bindctx, 0, callback, format);
260 IBindCtx_Release(bindctx);
268 /***********************************************************************
269 * CreateAsyncBindCtxEx (urlmon.@)
271 * Create an asynchronous bind context.
273 HRESULT WINAPI CreateAsyncBindCtxEx(IBindCtx *ibind, DWORD options,
274 IBindStatusCallback *callback, IEnumFORMATETC *format, IBindCtx** pbind,
281 TRACE("(%p %08x %p %p %p %d)\n", ibind, options, callback, format, pbind, reserved);
287 WARN("reserved=%d\n", reserved);
289 hres = CreateBindCtx(0, &bindctx);
293 ret = HeapAlloc(GetProcessHeap(), 0, sizeof(AsyncBindCtx));
295 ret->lpBindCtxVtbl = &AsyncBindCtxVtbl;
297 ret->bindctx = bindctx;
299 hres = init_bindctx(BINDCTX(ret), options, callback, format);
301 IBindCtx_Release(BINDCTX(ret));
305 *pbind = BINDCTX(ret);