Adapted to cursor/icon handling changes.
[wine/multimedia.git] / ole / bindctx.c
blob68f3fc90c6438467c4ca9c6f1e371bbcd5c91754
1 /***************************************************************************************
2 * BindCtx implementation
4 * Copyright 1999 Noomen Hamza
5 ***************************************************************************************/
7 #include <ctype.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <assert.h>
11 #include "winerror.h"
12 #include "wine/obj_moniker.h"
13 #include "debug.h"
14 #include "heap.h"
16 typedef struct BindCtxImpl{
18 ICOM_VTABLE(IBindCtx)* lpvtbl;
20 ULONG ref;
22 } BindCtxImpl;
25 HRESULT WINAPI BindCtxImpl_QueryInterface(IBindCtx* iface,REFIID riid,void** ppvObject);
26 ULONG WINAPI BindCtxImpl_AddRef(IBindCtx* iface);
27 ULONG WINAPI BindCtxImpl_Release(IBindCtx* iface);
28 HRESULT WINAPI BindCtxImpl_RegisterObjectBound(IBindCtx* iface,IUnknown* punk);
29 HRESULT WINAPI BindCtxImpl_RevokeObjectBound(IBindCtx* iface, IUnknown* punk);
30 HRESULT WINAPI BindCtxImpl_ReleaseObjects(IBindCtx* iface);
31 HRESULT WINAPI BindCtxImpl_SetBindOptions(IBindCtx* iface,LPBIND_OPTS2 pbindopts);
32 HRESULT WINAPI BindCtxImpl_GetBindOptions(IBindCtx* iface,LPBIND_OPTS2 pbindopts);
33 HRESULT WINAPI BindCtxImpl_GetRunningObjectTable(IBindCtx* iface,IRunningObjectTable** pprot);
34 HRESULT WINAPI BindCtxImpl_RegisterObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown* punk);
35 HRESULT WINAPI BindCtxImpl_GetObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown* punk);
36 HRESULT WINAPI BindCtxImpl_EnumObjectParam(IBindCtx* iface,IEnumString** ppenum);
37 HRESULT WINAPI BindCtxImpl_RevokeObjectParam(IBindCtx* iface,LPOLESTR pszkey);
39 HRESULT WINAPI CreateBindCtx16(DWORD reserved, LPBC * ppbc);
40 HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC * ppbc);
42 HRESULT WINAPI BindCtxImpl_Construct(BindCtxImpl* This);
43 HRESULT WINAPI BindCtxImpl_Destroy(BindCtxImpl* This);
45 // Virtual function table for the BindCtx class.
46 static ICOM_VTABLE(IBindCtx) VT_BindCtxImpl =
48 BindCtxImpl_QueryInterface,
49 BindCtxImpl_AddRef,
50 BindCtxImpl_Release,
51 BindCtxImpl_RegisterObjectBound,
52 BindCtxImpl_RevokeObjectBound,
53 BindCtxImpl_ReleaseObjects,
54 BindCtxImpl_SetBindOptions,
55 BindCtxImpl_GetBindOptions,
56 BindCtxImpl_GetRunningObjectTable,
57 BindCtxImpl_RegisterObjectParam,
58 BindCtxImpl_GetObjectParam,
59 BindCtxImpl_EnumObjectParam,
60 BindCtxImpl_RevokeObjectParam
63 /*******************************************************************************
64 * BindCtx_QueryInterface
65 *******************************************************************************/
66 HRESULT WINAPI BindCtxImpl_QueryInterface(IBindCtx* iface,REFIID riid,void** ppvObject)
68 ICOM_THIS(BindCtxImpl,iface);
69 TRACE(ole,"(%p,%p,%p)\n",This,riid,ppvObject);
70 // Perform a sanity check on the parameters.
71 if ( (This==0) || (ppvObject==0) ) return E_INVALIDARG;
73 // Initialize the return parameter.
74 *ppvObject = 0;
76 // Compare the riid with the interface IDs implemented by this object.
77 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
78 *ppvObject = (IBindCtx*)This;
79 else
80 if (memcmp(&IID_IBindCtx, riid, sizeof(IID_IBindCtx)) == 0)
81 *ppvObject = (IBindCtx*)This;
83 // Check that we obtained an interface.
84 if ((*ppvObject)==0) return E_NOINTERFACE;
86 // Query Interface always increases the reference count by one when it is successful
87 BindCtxImpl_AddRef(iface);
89 return S_OK;
92 /******************************************************************************
93 * BindCtx_ _AddRef
94 ******************************************************************************/
95 ULONG WINAPI BindCtxImpl_AddRef(IBindCtx* iface)
97 ICOM_THIS(BindCtxImpl,iface);
98 TRACE(ole,"(%p)\n",This);
100 return ++(This->ref);
103 /******************************************************************************
104 * BindCtx_Release
105 ******************************************************************************/
106 ULONG WINAPI BindCtxImpl_Release(IBindCtx* iface)
108 ICOM_THIS(BindCtxImpl,iface);
109 TRACE(ole,"(%p)\n",This);
111 This->ref--;
113 if (This->ref==0){
114 BindCtxImpl_Destroy(This);
115 return 0;
117 return This->ref;;
121 /******************************************************************************
122 * BindCtx_Construct
123 *******************************************************************************/
124 HRESULT WINAPI BindCtxImpl_Construct(BindCtxImpl* This)
126 FIXME(ole,"(%p),stub!\n",This);
128 memset(This, 0, sizeof(BindCtxImpl));
130 //Initialize the virtual fgunction table.
131 This->lpvtbl = &VT_BindCtxImpl;
133 return E_NOTIMPL;
136 /******************************************************************************
137 * BindCtx_Destroy
138 *******************************************************************************/
139 HRESULT WINAPI BindCtxImpl_Destroy(BindCtxImpl* This)
141 FIXME(ole,"(%p),stub!\n",This);
143 SEGPTR_FREE(This);
145 return S_OK;
149 /******************************************************************************
150 * BindCtx_RegisterObjectBound
151 ******************************************************************************/
152 HRESULT WINAPI BindCtxImpl_RegisterObjectBound(IBindCtx* iface,IUnknown* punk)
154 ICOM_THIS(BindCtxImpl,iface);
155 FIXME(ole,"(%p,%p),stub!\n",This,punk);
157 return E_NOTIMPL;
160 /******************************************************************************
161 * BindCtx_RevokeObjectBound
162 ******************************************************************************/
163 HRESULT WINAPI BindCtxImpl_RevokeObjectBound(IBindCtx* iface, IUnknown* punk)
165 ICOM_THIS(BindCtxImpl,iface);
166 FIXME(ole,"(%p,%p),stub!\n",This,punk);
168 return E_NOTIMPL;
171 /******************************************************************************
172 * BindCtx_ReleaseObjects
173 ******************************************************************************/
174 HRESULT WINAPI BindCtxImpl_ReleaseObjects(IBindCtx* iface)
176 ICOM_THIS(BindCtxImpl,iface);
177 FIXME(ole,"(%p),stub!\n",This);
179 return E_NOTIMPL;
182 /******************************************************************************
183 * BindCtx_SetBindOptions
184 ******************************************************************************/
185 HRESULT WINAPI BindCtxImpl_SetBindOptions(IBindCtx* iface,LPBIND_OPTS2 pbindopts)
187 ICOM_THIS(BindCtxImpl,iface);
188 FIXME(ole,"(%p,%p),stub!\n",This,pbindopts);
190 return E_NOTIMPL;
193 /******************************************************************************
194 * BindCtx_GetBindOptions
195 ******************************************************************************/
196 HRESULT WINAPI BindCtxImpl_GetBindOptions(IBindCtx* iface,LPBIND_OPTS2 pbindopts)
198 ICOM_THIS(BindCtxImpl,iface);
199 FIXME(ole,"(%p,%p),stub!\n",This,pbindopts);
201 return E_NOTIMPL;
204 /******************************************************************************
205 * BindCtx_GetRunningObjectTable
206 ******************************************************************************/
207 HRESULT WINAPI BindCtxImpl_GetRunningObjectTable(IBindCtx* iface,IRunningObjectTable** pprot)
209 ICOM_THIS(BindCtxImpl,iface);
210 FIXME(ole,"(%p,%p),stub!\n",This,pprot);
212 return E_NOTIMPL;
215 /******************************************************************************
216 * BindCtx_RegisterObjectParam
217 ******************************************************************************/
218 HRESULT WINAPI BindCtxImpl_RegisterObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown* punk)
220 ICOM_THIS(BindCtxImpl,iface);
221 FIXME(ole,"(%p,%p,%p),stub!\n",This,pszkey,punk);
223 return E_NOTIMPL;
226 /******************************************************************************
227 * BindCtx_GetObjectParam
228 ******************************************************************************/
229 HRESULT WINAPI BindCtxImpl_GetObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown* punk)
231 ICOM_THIS(BindCtxImpl,iface);
232 FIXME(ole,"(%p,%p,%p),stub!\n",This,pszkey,punk);
234 return E_NOTIMPL;
237 /******************************************************************************
238 * BindCtx_EnumObjectParam
239 ******************************************************************************/
240 HRESULT WINAPI BindCtxImpl_EnumObjectParam(IBindCtx* iface,IEnumString** ppenum)
242 ICOM_THIS(BindCtxImpl,iface);
243 FIXME(ole,"(%p,%p),stub!\n",This,ppenum);
245 return E_NOTIMPL;
248 /******************************************************************************
249 * BindCtx_RevokeObjectParam
250 ******************************************************************************/
251 HRESULT WINAPI BindCtxImpl_RevokeObjectParam(IBindCtx* iface,LPOLESTR pszkey)
253 ICOM_THIS(BindCtxImpl,iface);
254 FIXME(ole,"(%p,%p),stub!\n",This,pszkey);
256 return E_NOTIMPL;
260 /******************************************************************************
261 * CreateBindCtx16
262 ******************************************************************************/
263 HRESULT WINAPI CreateBindCtx16(DWORD reserved, LPBC * ppbc)
265 FIXME(ole,"(%ld,%p),stub!\n",reserved,ppbc);
267 return E_NOTIMPL;
270 /******************************************************************************
271 * CreateBindCtx32
272 ******************************************************************************/
273 HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC * ppbc)
275 BindCtxImpl* newBindCtx = 0;
276 HRESULT hr = S_OK;
278 TRACE(ole,"(%ld,%p)\n",reserved,ppbc);
280 newBindCtx = HeapAlloc(GetProcessHeap(), 0, sizeof(BindCtxImpl));
282 if (newBindCtx == 0)
283 return STG_E_INSUFFICIENTMEMORY;
285 hr = BindCtxImpl_Construct(newBindCtx);
287 if (FAILED(hr))
288 return hr;
290 hr = BindCtxImpl_QueryInterface((IBindCtx*)newBindCtx,&IID_IBindCtx,(void**)ppbc);
292 return hr;