Large-scale renaming of all Win32 functions and types to use the
[wine/multimedia.git] / ole / bindctx.c
blob923ad7309a664b9976eff5a3bbcf7a30f1a2be71
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_base.h"
13 #include "wine/obj_storage.h"
14 #include "wine/obj_moniker.h"
15 #include "debug.h"
16 #include "heap.h"
18 typedef struct BindCtxImpl{
20 ICOM_VTABLE(IBindCtx)* lpvtbl;
22 ULONG ref;
24 } BindCtxImpl;
27 HRESULT WINAPI BindCtxImpl_QueryInterface(IBindCtx* iface,REFIID riid,void** ppvObject);
28 ULONG WINAPI BindCtxImpl_AddRef(IBindCtx* iface);
29 ULONG WINAPI BindCtxImpl_Release(IBindCtx* iface);
30 HRESULT WINAPI BindCtxImpl_RegisterObjectBound(IBindCtx* iface,IUnknown* punk);
31 HRESULT WINAPI BindCtxImpl_RevokeObjectBound(IBindCtx* iface, IUnknown* punk);
32 HRESULT WINAPI BindCtxImpl_ReleaseObjects(IBindCtx* iface);
33 HRESULT WINAPI BindCtxImpl_SetBindOptions(IBindCtx* iface,LPBIND_OPTS2 pbindopts);
34 HRESULT WINAPI BindCtxImpl_GetBindOptions(IBindCtx* iface,LPBIND_OPTS2 pbindopts);
35 HRESULT WINAPI BindCtxImpl_GetRunningObjectTable(IBindCtx* iface,IRunningObjectTable** pprot);
36 HRESULT WINAPI BindCtxImpl_RegisterObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown* punk);
37 HRESULT WINAPI BindCtxImpl_GetObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown* punk);
38 HRESULT WINAPI BindCtxImpl_EnumObjectParam(IBindCtx* iface,IEnumString** ppenum);
39 HRESULT WINAPI BindCtxImpl_RevokeObjectParam(IBindCtx* iface,LPOLESTR pszkey);
41 HRESULT WINAPI CreateBindCtx16(DWORD reserved, LPBC * ppbc);
42 HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC * ppbc);
44 HRESULT WINAPI BindCtxImpl_Construct(BindCtxImpl* This);
45 HRESULT WINAPI BindCtxImpl_Destroy(BindCtxImpl* This);
47 // Virtual function table for the BindCtx class.
48 static ICOM_VTABLE(IBindCtx) VT_BindCtxImpl =
50 BindCtxImpl_QueryInterface,
51 BindCtxImpl_AddRef,
52 BindCtxImpl_Release,
53 BindCtxImpl_RegisterObjectBound,
54 BindCtxImpl_RevokeObjectBound,
55 BindCtxImpl_ReleaseObjects,
56 BindCtxImpl_SetBindOptions,
57 BindCtxImpl_GetBindOptions,
58 BindCtxImpl_GetRunningObjectTable,
59 BindCtxImpl_RegisterObjectParam,
60 BindCtxImpl_GetObjectParam,
61 BindCtxImpl_EnumObjectParam,
62 BindCtxImpl_RevokeObjectParam
65 /*******************************************************************************
66 * BindCtx_QueryInterface
67 *******************************************************************************/
68 HRESULT WINAPI BindCtxImpl_QueryInterface(IBindCtx* iface,REFIID riid,void** ppvObject)
70 ICOM_THIS(BindCtxImpl,iface);
71 TRACE(ole,"(%p,%p,%p)\n",This,riid,ppvObject);
72 // Perform a sanity check on the parameters.
73 if ( (This==0) || (ppvObject==0) ) return E_INVALIDARG;
75 // Initialize the return parameter.
76 *ppvObject = 0;
78 // Compare the riid with the interface IDs implemented by this object.
79 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
80 *ppvObject = (IBindCtx*)This;
81 else
82 if (memcmp(&IID_IBindCtx, riid, sizeof(IID_IBindCtx)) == 0)
83 *ppvObject = (IBindCtx*)This;
85 // Check that we obtained an interface.
86 if ((*ppvObject)==0) return E_NOINTERFACE;
88 // Query Interface always increases the reference count by one when it is successful
89 BindCtxImpl_AddRef(iface);
91 return S_OK;
94 /******************************************************************************
95 * BindCtx_ _AddRef
96 ******************************************************************************/
97 ULONG WINAPI BindCtxImpl_AddRef(IBindCtx* iface)
99 ICOM_THIS(BindCtxImpl,iface);
100 TRACE(ole,"(%p)\n",This);
102 return ++(This->ref);
105 /******************************************************************************
106 * BindCtx_Release
107 ******************************************************************************/
108 ULONG WINAPI BindCtxImpl_Release(IBindCtx* iface)
110 ICOM_THIS(BindCtxImpl,iface);
111 TRACE(ole,"(%p)\n",This);
113 This->ref--;
115 if (This->ref==0){
116 BindCtxImpl_Destroy(This);
117 return 0;
119 return This->ref;;
123 /******************************************************************************
124 * BindCtx_Construct
125 *******************************************************************************/
126 HRESULT WINAPI BindCtxImpl_Construct(BindCtxImpl* This)
128 FIXME(ole,"(%p),stub!\n",This);
130 memset(This, 0, sizeof(BindCtxImpl));
132 //Initialize the virtual fgunction table.
133 This->lpvtbl = &VT_BindCtxImpl;
135 return E_NOTIMPL;
138 /******************************************************************************
139 * BindCtx_Destroy
140 *******************************************************************************/
141 HRESULT WINAPI BindCtxImpl_Destroy(BindCtxImpl* This)
143 FIXME(ole,"(%p),stub!\n",This);
145 SEGPTR_FREE(This);
147 return S_OK;
151 /******************************************************************************
152 * BindCtx_RegisterObjectBound
153 ******************************************************************************/
154 HRESULT WINAPI BindCtxImpl_RegisterObjectBound(IBindCtx* iface,IUnknown* punk)
156 ICOM_THIS(BindCtxImpl,iface);
157 FIXME(ole,"(%p,%p),stub!\n",This,punk);
159 return E_NOTIMPL;
162 /******************************************************************************
163 * BindCtx_RevokeObjectBound
164 ******************************************************************************/
165 HRESULT WINAPI BindCtxImpl_RevokeObjectBound(IBindCtx* iface, IUnknown* punk)
167 ICOM_THIS(BindCtxImpl,iface);
168 FIXME(ole,"(%p,%p),stub!\n",This,punk);
170 return E_NOTIMPL;
173 /******************************************************************************
174 * BindCtx_ReleaseObjects
175 ******************************************************************************/
176 HRESULT WINAPI BindCtxImpl_ReleaseObjects(IBindCtx* iface)
178 ICOM_THIS(BindCtxImpl,iface);
179 FIXME(ole,"(%p),stub!\n",This);
181 return E_NOTIMPL;
184 /******************************************************************************
185 * BindCtx_SetBindOptions
186 ******************************************************************************/
187 HRESULT WINAPI BindCtxImpl_SetBindOptions(IBindCtx* iface,LPBIND_OPTS2 pbindopts)
189 ICOM_THIS(BindCtxImpl,iface);
190 FIXME(ole,"(%p,%p),stub!\n",This,pbindopts);
192 return E_NOTIMPL;
195 /******************************************************************************
196 * BindCtx_GetBindOptions
197 ******************************************************************************/
198 HRESULT WINAPI BindCtxImpl_GetBindOptions(IBindCtx* iface,LPBIND_OPTS2 pbindopts)
200 ICOM_THIS(BindCtxImpl,iface);
201 FIXME(ole,"(%p,%p),stub!\n",This,pbindopts);
203 return E_NOTIMPL;
206 /******************************************************************************
207 * BindCtx_GetRunningObjectTable
208 ******************************************************************************/
209 HRESULT WINAPI BindCtxImpl_GetRunningObjectTable(IBindCtx* iface,IRunningObjectTable** pprot)
211 ICOM_THIS(BindCtxImpl,iface);
212 FIXME(ole,"(%p,%p),stub!\n",This,pprot);
214 return E_NOTIMPL;
217 /******************************************************************************
218 * BindCtx_RegisterObjectParam
219 ******************************************************************************/
220 HRESULT WINAPI BindCtxImpl_RegisterObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown* punk)
222 ICOM_THIS(BindCtxImpl,iface);
223 FIXME(ole,"(%p,%p,%p),stub!\n",This,pszkey,punk);
225 return E_NOTIMPL;
228 /******************************************************************************
229 * BindCtx_GetObjectParam
230 ******************************************************************************/
231 HRESULT WINAPI BindCtxImpl_GetObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown* punk)
233 ICOM_THIS(BindCtxImpl,iface);
234 FIXME(ole,"(%p,%p,%p),stub!\n",This,pszkey,punk);
236 return E_NOTIMPL;
239 /******************************************************************************
240 * BindCtx_EnumObjectParam
241 ******************************************************************************/
242 HRESULT WINAPI BindCtxImpl_EnumObjectParam(IBindCtx* iface,IEnumString** ppenum)
244 ICOM_THIS(BindCtxImpl,iface);
245 FIXME(ole,"(%p,%p),stub!\n",This,ppenum);
247 return E_NOTIMPL;
250 /******************************************************************************
251 * BindCtx_RevokeObjectParam
252 ******************************************************************************/
253 HRESULT WINAPI BindCtxImpl_RevokeObjectParam(IBindCtx* iface,LPOLESTR pszkey)
255 ICOM_THIS(BindCtxImpl,iface);
256 FIXME(ole,"(%p,%p),stub!\n",This,pszkey);
258 return E_NOTIMPL;
262 /******************************************************************************
263 * CreateBindCtx16
264 ******************************************************************************/
265 HRESULT WINAPI CreateBindCtx16(DWORD reserved, LPBC * ppbc)
267 FIXME(ole,"(%ld,%p),stub!\n",reserved,ppbc);
269 return E_NOTIMPL;
272 /******************************************************************************
273 * CreateBindCtx32
274 ******************************************************************************/
275 HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC * ppbc)
277 BindCtxImpl* newBindCtx = 0;
278 HRESULT hr = S_OK;
280 TRACE(ole,"(%ld,%p)\n",reserved,ppbc);
282 newBindCtx = HeapAlloc(GetProcessHeap(), 0, sizeof(BindCtxImpl));
284 if (newBindCtx == 0)
285 return STG_E_INSUFFICIENTMEMORY;
287 hr = BindCtxImpl_Construct(newBindCtx);
289 if (FAILED(hr))
290 return hr;
292 hr = BindCtxImpl_QueryInterface((IBindCtx*)newBindCtx,&IID_IBindCtx,(void**)ppbc);
294 return hr;