1 | /* $Id: bindctx.cpp,v 1.3 2000-05-05 18:21:36 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * BindCtx implementation
|
---|
4 | *
|
---|
5 | * 20/9/99
|
---|
6 | *
|
---|
7 | * Copyright 1999 David J. Raison
|
---|
8 | *
|
---|
9 | * Direct port of Wine Implementation
|
---|
10 | * Copyright 1999 Noomen Hamza
|
---|
11 | */
|
---|
12 |
|
---|
13 | #include "ole32.h"
|
---|
14 | #include "heapstring.h"
|
---|
15 | #include "debugtools.h"
|
---|
16 |
|
---|
17 | DEFAULT_DEBUG_CHANNEL(ole)
|
---|
18 |
|
---|
19 | /* represent the first size table and it's increment block size */
|
---|
20 | #define BLOCK_TAB_SIZE 10
|
---|
21 | #define MAX_TAB_SIZE 0xFFFFFFFF
|
---|
22 |
|
---|
23 | /* data structure of the BindCtx table elements */
|
---|
24 | typedef struct BindCtxObject{
|
---|
25 |
|
---|
26 | IUnknown* pObj; /* point on a bound object */
|
---|
27 |
|
---|
28 | LPOLESTR pkeyObj; /* key associated to this bound object */
|
---|
29 |
|
---|
30 | BYTE regType; /* registration type: 1 if RegisterObjectParam and 0 if RegisterObjectBound */
|
---|
31 |
|
---|
32 | } BindCtxObject;
|
---|
33 |
|
---|
34 | /* BindCtx data strucrture */
|
---|
35 | typedef struct BindCtxImpl{
|
---|
36 |
|
---|
37 | ICOM_VFIELD(IBindCtx); /* VTable relative to the IBindCtx interface.*/
|
---|
38 |
|
---|
39 | ULONG ref; /* reference counter for this object */
|
---|
40 |
|
---|
41 | BindCtxObject* bindCtxTable; /* this is a table in witch all bounded objects are stored*/
|
---|
42 | DWORD bindCtxTableLastIndex; /* first free index in the table */
|
---|
43 | DWORD bindCtxTableSize; /* size table */
|
---|
44 |
|
---|
45 | BIND_OPTS2 bindOption2; /* a structure witch contains the bind options*/
|
---|
46 |
|
---|
47 | } BindCtxImpl;
|
---|
48 |
|
---|
49 | /* IBindCtx prototype functions : */
|
---|
50 |
|
---|
51 | /* IUnknown functions*/
|
---|
52 | static HRESULT WINAPI BindCtxImpl_QueryInterface(IBindCtx* iface,REFIID riid,void** ppvObject);
|
---|
53 | static ULONG WINAPI BindCtxImpl_AddRef(IBindCtx* iface);
|
---|
54 | static ULONG WINAPI BindCtxImpl_Release(IBindCtx* iface);
|
---|
55 | /* IBindCtx functions */
|
---|
56 | static HRESULT WINAPI BindCtxImpl_RegisterObjectBound(IBindCtx* iface,IUnknown* punk);
|
---|
57 | static HRESULT WINAPI BindCtxImpl_RevokeObjectBound(IBindCtx* iface, IUnknown* punk);
|
---|
58 | static HRESULT WINAPI BindCtxImpl_ReleaseBoundObjects(IBindCtx* iface);
|
---|
59 | static HRESULT WINAPI BindCtxImpl_SetBindOptions(IBindCtx* iface,LPBIND_OPTS2 pbindopts);
|
---|
60 | static HRESULT WINAPI BindCtxImpl_GetBindOptions(IBindCtx* iface,LPBIND_OPTS2 pbindopts);
|
---|
61 | static HRESULT WINAPI BindCtxImpl_GetRunningObjectTable(IBindCtx* iface,IRunningObjectTable** pprot);
|
---|
62 | static HRESULT WINAPI BindCtxImpl_RegisterObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown* punk);
|
---|
63 | static HRESULT WINAPI BindCtxImpl_GetObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown** punk);
|
---|
64 | static HRESULT WINAPI BindCtxImpl_EnumObjectParam(IBindCtx* iface,IEnumString** ppenum);
|
---|
65 | static HRESULT WINAPI BindCtxImpl_RevokeObjectParam(IBindCtx* iface,LPOLESTR pszkey);
|
---|
66 | /* Local functions*/
|
---|
67 | HRESULT WINAPI BindCtxImpl_Construct(BindCtxImpl* This);
|
---|
68 | HRESULT WINAPI BindCtxImpl_Destroy(BindCtxImpl* This);
|
---|
69 | HRESULT WINAPI BindCtxImpl_GetObjectIndex(BindCtxImpl* This,IUnknown* punk,LPOLESTR pszkey,DWORD *index);
|
---|
70 |
|
---|
71 | /* Virtual function table for the BindCtx class. */
|
---|
72 | static ICOM_VTABLE(IBindCtx) VT_BindCtxImpl =
|
---|
73 | {
|
---|
74 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
---|
75 | BindCtxImpl_QueryInterface,
|
---|
76 | BindCtxImpl_AddRef,
|
---|
77 | BindCtxImpl_Release,
|
---|
78 | BindCtxImpl_RegisterObjectBound,
|
---|
79 | BindCtxImpl_RevokeObjectBound,
|
---|
80 | BindCtxImpl_ReleaseBoundObjects,
|
---|
81 | BindCtxImpl_SetBindOptions,
|
---|
82 | BindCtxImpl_GetBindOptions,
|
---|
83 | BindCtxImpl_GetRunningObjectTable,
|
---|
84 | BindCtxImpl_RegisterObjectParam,
|
---|
85 | BindCtxImpl_GetObjectParam,
|
---|
86 | BindCtxImpl_EnumObjectParam,
|
---|
87 | BindCtxImpl_RevokeObjectParam
|
---|
88 | };
|
---|
89 |
|
---|
90 | /*******************************************************************************
|
---|
91 | * BindCtx_QueryInterface
|
---|
92 | *******************************************************************************/
|
---|
93 | HRESULT WINAPI BindCtxImpl_QueryInterface(IBindCtx* iface,REFIID riid,void** ppvObject)
|
---|
94 | {
|
---|
95 | ICOM_THIS(BindCtxImpl,iface);
|
---|
96 |
|
---|
97 | TRACE("(%p,%p,%p)\n",This,riid,ppvObject);
|
---|
98 |
|
---|
99 | /* Perform a sanity check on the parameters.*/
|
---|
100 | if ( (This==0) || (ppvObject==0) )
|
---|
101 | return E_INVALIDARG;
|
---|
102 |
|
---|
103 | /* Initialize the return parameter.*/
|
---|
104 | *ppvObject = 0;
|
---|
105 |
|
---|
106 | /* Compare the riid with the interface IDs implemented by this object.*/
|
---|
107 | if (IsEqualIID(&IID_IUnknown, riid))
|
---|
108 | *ppvObject = (IBindCtx*)This;
|
---|
109 | else
|
---|
110 | if (IsEqualIID(&IID_IBindCtx, riid))
|
---|
111 | *ppvObject = (IBindCtx*)This;
|
---|
112 |
|
---|
113 | /* Check that we obtained an interface.*/
|
---|
114 | if ((*ppvObject)==0)
|
---|
115 | return E_NOINTERFACE;
|
---|
116 |
|
---|
117 | /* Query Interface always increases the reference count by one when it is successful */
|
---|
118 | BindCtxImpl_AddRef(iface);
|
---|
119 |
|
---|
120 | return S_OK;
|
---|
121 | }
|
---|
122 |
|
---|
123 | /******************************************************************************
|
---|
124 | * BindCtx_AddRef
|
---|
125 | ******************************************************************************/
|
---|
126 | ULONG WINAPI BindCtxImpl_AddRef(IBindCtx* iface)
|
---|
127 | {
|
---|
128 | ICOM_THIS(BindCtxImpl,iface);
|
---|
129 |
|
---|
130 | TRACE("(%p)\n",This);
|
---|
131 |
|
---|
132 | return ++(This->ref);
|
---|
133 | }
|
---|
134 |
|
---|
135 | /******************************************************************************
|
---|
136 | * BindCtx_Release
|
---|
137 | ******************************************************************************/
|
---|
138 | ULONG WINAPI BindCtxImpl_Release(IBindCtx* iface)
|
---|
139 | {
|
---|
140 | ICOM_THIS(BindCtxImpl,iface);
|
---|
141 |
|
---|
142 | TRACE("(%p)\n",This);
|
---|
143 |
|
---|
144 | This->ref--;
|
---|
145 |
|
---|
146 | if (This->ref==0){
|
---|
147 |
|
---|
148 | /* release all registred objects */
|
---|
149 | BindCtxImpl_ReleaseBoundObjects((IBindCtx*)This);
|
---|
150 |
|
---|
151 | BindCtxImpl_Destroy(This);
|
---|
152 |
|
---|
153 | return 0;
|
---|
154 | }
|
---|
155 | return This->ref;;
|
---|
156 | }
|
---|
157 |
|
---|
158 |
|
---|
159 | /******************************************************************************
|
---|
160 | * BindCtx_Construct (local function)
|
---|
161 | *******************************************************************************/
|
---|
162 | HRESULT WINAPI BindCtxImpl_Construct(BindCtxImpl* This)
|
---|
163 | {
|
---|
164 | TRACE("(%p)\n",This);
|
---|
165 |
|
---|
166 | /* Initialize the virtual function table.*/
|
---|
167 | ICOM_VTBL(This) = &VT_BindCtxImpl;
|
---|
168 | This->ref = 0;
|
---|
169 |
|
---|
170 | /* Initialize the BIND_OPTS2 structure */
|
---|
171 | This->bindOption2.cbStruct = sizeof(BIND_OPTS2);
|
---|
172 | This->bindOption2.grfFlags = 0;
|
---|
173 | This->bindOption2.grfMode = STGM_READWRITE;
|
---|
174 | This->bindOption2.dwTickCountDeadline = 0;
|
---|
175 |
|
---|
176 | This->bindOption2.dwTrackFlags = 0;
|
---|
177 | This->bindOption2.dwClassContext = CLSCTX_SERVER;
|
---|
178 | This->bindOption2.locale = 1033;
|
---|
179 | This->bindOption2.pServerInfo = 0;
|
---|
180 |
|
---|
181 | /* Initialize the bindctx table */
|
---|
182 | This->bindCtxTableSize=BLOCK_TAB_SIZE;
|
---|
183 | This->bindCtxTableLastIndex=0;
|
---|
184 | This->bindCtxTable= (BindCtxObject *)HeapAlloc(GetProcessHeap(), 0,This->bindCtxTableSize*sizeof(BindCtxObject));
|
---|
185 |
|
---|
186 | if (This->bindCtxTable==NULL)
|
---|
187 | return E_OUTOFMEMORY;
|
---|
188 |
|
---|
189 | return S_OK;
|
---|
190 | }
|
---|
191 |
|
---|
192 | /******************************************************************************
|
---|
193 | * BindCtx_Destroy (local function)
|
---|
194 | *******************************************************************************/
|
---|
195 | HRESULT WINAPI BindCtxImpl_Destroy(BindCtxImpl* This)
|
---|
196 | {
|
---|
197 | TRACE("(%p)\n",This);
|
---|
198 |
|
---|
199 | /* free the table space memory */
|
---|
200 | HeapFree(GetProcessHeap(),0,This->bindCtxTable);
|
---|
201 |
|
---|
202 | /* free the bindctx structure */
|
---|
203 | HeapFree(GetProcessHeap(),0,This);
|
---|
204 |
|
---|
205 | return S_OK;
|
---|
206 | }
|
---|
207 |
|
---|
208 |
|
---|
209 | /******************************************************************************
|
---|
210 | * BindCtx_RegisterObjectBound
|
---|
211 | ******************************************************************************/
|
---|
212 | HRESULT WINAPI BindCtxImpl_RegisterObjectBound(IBindCtx* iface,IUnknown* punk)
|
---|
213 | {
|
---|
214 |
|
---|
215 | ICOM_THIS(BindCtxImpl,iface);
|
---|
216 | DWORD lastIndex=This->bindCtxTableLastIndex;
|
---|
217 | BindCtxObject cell;
|
---|
218 |
|
---|
219 | TRACE("(%p,%p)\n",This,punk);
|
---|
220 |
|
---|
221 | if (punk==NULL)
|
---|
222 | return E_POINTER;
|
---|
223 |
|
---|
224 | IUnknown_AddRef(punk);
|
---|
225 |
|
---|
226 | /* put the object in the first free element in the table */
|
---|
227 | This->bindCtxTable[lastIndex].pObj = punk;
|
---|
228 | This->bindCtxTable[lastIndex].pkeyObj = NULL;
|
---|
229 | This->bindCtxTable[lastIndex].regType = 0;
|
---|
230 | cell=This->bindCtxTable[lastIndex];
|
---|
231 | lastIndex= ++This->bindCtxTableLastIndex;
|
---|
232 |
|
---|
233 | if (lastIndex == This->bindCtxTableSize){ /* the table is full so it must be resized */
|
---|
234 |
|
---|
235 | if (This->bindCtxTableSize > (MAX_TAB_SIZE-BLOCK_TAB_SIZE)){
|
---|
236 | FIXME("This->bindCtxTableSize: %ld is out of data limite \n",This->bindCtxTableSize);
|
---|
237 | return E_FAIL;
|
---|
238 | }
|
---|
239 |
|
---|
240 | This->bindCtxTableSize+=BLOCK_TAB_SIZE; /* new table size */
|
---|
241 |
|
---|
242 | This->bindCtxTable =
|
---|
243 | (BindCtxObject *)HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,This->bindCtxTable,
|
---|
244 | This->bindCtxTableSize * sizeof(BindCtxObject));
|
---|
245 | if (!This->bindCtxTable)
|
---|
246 | return E_OUTOFMEMORY;
|
---|
247 | }
|
---|
248 | return S_OK;
|
---|
249 | }
|
---|
250 |
|
---|
251 | /******************************************************************************
|
---|
252 | * BindCtx_RevokeObjectBound
|
---|
253 | ******************************************************************************/
|
---|
254 | HRESULT WINAPI BindCtxImpl_RevokeObjectBound(IBindCtx* iface, IUnknown* punk)
|
---|
255 | {
|
---|
256 | DWORD index,j;
|
---|
257 |
|
---|
258 | ICOM_THIS(BindCtxImpl,iface);
|
---|
259 |
|
---|
260 | TRACE("(%p,%p)\n",This,punk);
|
---|
261 |
|
---|
262 | /* check if the object was registred or not */
|
---|
263 | if (BindCtxImpl_GetObjectIndex(This,punk,NULL,&index)==S_FALSE)
|
---|
264 |
|
---|
265 | return MK_E_NOTBOUND;
|
---|
266 |
|
---|
267 | IUnknown_Release(This->bindCtxTable[index].pObj);
|
---|
268 |
|
---|
269 | /* left-shift all elements in the rigth side of the curent revoked object */
|
---|
270 | for(j=index; j<This->bindCtxTableLastIndex-1; j++)
|
---|
271 | This->bindCtxTable[j]= This->bindCtxTable[j+1];
|
---|
272 |
|
---|
273 | This->bindCtxTableLastIndex--;
|
---|
274 |
|
---|
275 | return S_OK;
|
---|
276 | }
|
---|
277 |
|
---|
278 | /******************************************************************************
|
---|
279 | * BindCtx_ReleaseBoundObjects
|
---|
280 | ******************************************************************************/
|
---|
281 | HRESULT WINAPI BindCtxImpl_ReleaseBoundObjects(IBindCtx* iface)
|
---|
282 | {
|
---|
283 | DWORD i;
|
---|
284 |
|
---|
285 | ICOM_THIS(BindCtxImpl,iface);
|
---|
286 |
|
---|
287 | TRACE("(%p)\n",This);
|
---|
288 |
|
---|
289 | for(i=0;i<This->bindCtxTableLastIndex;i++)
|
---|
290 | IUnknown_Release(This->bindCtxTable[i].pObj);
|
---|
291 |
|
---|
292 | This->bindCtxTableLastIndex = 0;
|
---|
293 |
|
---|
294 | return S_OK;
|
---|
295 | }
|
---|
296 |
|
---|
297 | /******************************************************************************
|
---|
298 | * BindCtx_SetBindOptions
|
---|
299 | ******************************************************************************/
|
---|
300 | HRESULT WINAPI BindCtxImpl_SetBindOptions(IBindCtx* iface,LPBIND_OPTS2 pbindopts)
|
---|
301 | {
|
---|
302 | ICOM_THIS(BindCtxImpl,iface);
|
---|
303 |
|
---|
304 | TRACE("(%p,%p)\n",This,pbindopts);
|
---|
305 |
|
---|
306 | if (pbindopts==NULL)
|
---|
307 | return E_POINTER;
|
---|
308 |
|
---|
309 | if (pbindopts->cbStruct > sizeof(BIND_OPTS2))
|
---|
310 | {
|
---|
311 | WARN("invalid size");
|
---|
312 | return E_INVALIDARG; /* FIXME : not verified */
|
---|
313 | }
|
---|
314 | memcpy(&This->bindOption2, pbindopts, pbindopts->cbStruct);
|
---|
315 |
|
---|
316 | return S_OK;
|
---|
317 | }
|
---|
318 |
|
---|
319 | /******************************************************************************
|
---|
320 | * BindCtx_GetBindOptions
|
---|
321 | ******************************************************************************/
|
---|
322 | HRESULT WINAPI BindCtxImpl_GetBindOptions(IBindCtx* iface,LPBIND_OPTS2 pbindopts)
|
---|
323 | {
|
---|
324 | ICOM_THIS(BindCtxImpl,iface);
|
---|
325 |
|
---|
326 | TRACE("(%p,%p)\n",This,pbindopts);
|
---|
327 |
|
---|
328 | if (pbindopts==NULL)
|
---|
329 | return E_POINTER;
|
---|
330 |
|
---|
331 | if (pbindopts->cbStruct > sizeof(BIND_OPTS2))
|
---|
332 | {
|
---|
333 | WARN("invalid size");
|
---|
334 | return E_INVALIDARG; /* FIXME : not verified */
|
---|
335 | }
|
---|
336 | memcpy(pbindopts, &This->bindOption2, pbindopts->cbStruct);
|
---|
337 |
|
---|
338 | return S_OK;
|
---|
339 | }
|
---|
340 |
|
---|
341 | /******************************************************************************
|
---|
342 | * BindCtx_GetRunningObjectTable
|
---|
343 | ******************************************************************************/
|
---|
344 | HRESULT WINAPI BindCtxImpl_GetRunningObjectTable(IBindCtx* iface,IRunningObjectTable** pprot)
|
---|
345 | {
|
---|
346 | HRESULT res;
|
---|
347 |
|
---|
348 | ICOM_THIS(BindCtxImpl,iface);
|
---|
349 |
|
---|
350 | TRACE("(%p,%p)\n",This,pprot);
|
---|
351 |
|
---|
352 | if (pprot==NULL)
|
---|
353 | return E_POINTER;
|
---|
354 |
|
---|
355 | res=GetRunningObjectTable(0, pprot);
|
---|
356 |
|
---|
357 | return res;
|
---|
358 | }
|
---|
359 |
|
---|
360 | /******************************************************************************
|
---|
361 | * BindCtx_RegisterObjectParam
|
---|
362 | ******************************************************************************/
|
---|
363 | HRESULT WINAPI BindCtxImpl_RegisterObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown* punk)
|
---|
364 | {
|
---|
365 | ICOM_THIS(BindCtxImpl,iface);
|
---|
366 |
|
---|
367 | TRACE("(%p,%p,%p)\n",This,pszkey,punk);
|
---|
368 |
|
---|
369 | if (punk==NULL)
|
---|
370 | return E_INVALIDARG;
|
---|
371 |
|
---|
372 | IUnknown_AddRef(punk);
|
---|
373 |
|
---|
374 | This->bindCtxTable[This->bindCtxTableLastIndex].pObj = punk;
|
---|
375 | This->bindCtxTable[This->bindCtxTableLastIndex].regType = 1;
|
---|
376 |
|
---|
377 | if (pszkey==NULL)
|
---|
378 |
|
---|
379 | This->bindCtxTable[This->bindCtxTableLastIndex].pkeyObj=NULL;
|
---|
380 |
|
---|
381 | else{
|
---|
382 |
|
---|
383 | This->bindCtxTable[This->bindCtxTableLastIndex].pkeyObj=
|
---|
384 | (WCHAR *)HeapAlloc(GetProcessHeap(),0,(sizeof(WCHAR)*(1+lstrlenW(pszkey))));
|
---|
385 |
|
---|
386 | if (This->bindCtxTable[This->bindCtxTableLastIndex].pkeyObj==NULL)
|
---|
387 | return E_OUTOFMEMORY;
|
---|
388 | lstrcpyW(This->bindCtxTable[This->bindCtxTableLastIndex].pkeyObj,pszkey);
|
---|
389 | }
|
---|
390 |
|
---|
391 | This->bindCtxTableLastIndex++;
|
---|
392 |
|
---|
393 | if (This->bindCtxTableLastIndex == This->bindCtxTableSize){ /* table is full ! must be resized */
|
---|
394 |
|
---|
395 | This->bindCtxTableSize+=BLOCK_TAB_SIZE; /* new table size */
|
---|
396 |
|
---|
397 | if (This->bindCtxTableSize > (MAX_TAB_SIZE-BLOCK_TAB_SIZE)){
|
---|
398 | FIXME("This->bindCtxTableSize: %ld is out of data limite \n",This->bindCtxTableSize);
|
---|
399 | return E_FAIL;
|
---|
400 | }
|
---|
401 | This->bindCtxTable =
|
---|
402 | (BindCtxObject *)HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,This->bindCtxTable,
|
---|
403 | This->bindCtxTableSize * sizeof(BindCtxObject));
|
---|
404 | if (!This->bindCtxTable)
|
---|
405 | return E_OUTOFMEMORY;
|
---|
406 | }
|
---|
407 | return S_OK;
|
---|
408 | }
|
---|
409 | /******************************************************************************
|
---|
410 | * BindCtx_GetObjectParam
|
---|
411 | ******************************************************************************/
|
---|
412 | HRESULT WINAPI BindCtxImpl_GetObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown** punk)
|
---|
413 | {
|
---|
414 | DWORD index;
|
---|
415 | ICOM_THIS(BindCtxImpl,iface);
|
---|
416 |
|
---|
417 | TRACE("(%p,%p,%p)\n",This,pszkey,punk);
|
---|
418 |
|
---|
419 | if (punk==NULL)
|
---|
420 | return E_POINTER;
|
---|
421 |
|
---|
422 | *punk=0;
|
---|
423 |
|
---|
424 | if (BindCtxImpl_GetObjectIndex(This,NULL,pszkey,&index)==S_FALSE)
|
---|
425 | return E_FAIL;
|
---|
426 |
|
---|
427 | IUnknown_AddRef(This->bindCtxTable[index].pObj);
|
---|
428 |
|
---|
429 | *punk = This->bindCtxTable[index].pObj;
|
---|
430 |
|
---|
431 | return S_OK;
|
---|
432 | }
|
---|
433 |
|
---|
434 | /******************************************************************************
|
---|
435 | * BindCtx_RevokeObjectParam
|
---|
436 | ******************************************************************************/
|
---|
437 | HRESULT WINAPI BindCtxImpl_RevokeObjectParam(IBindCtx* iface,LPOLESTR ppenum)
|
---|
438 | {
|
---|
439 | DWORD index,j;
|
---|
440 |
|
---|
441 | ICOM_THIS(BindCtxImpl,iface);
|
---|
442 |
|
---|
443 | TRACE("(%p,%p)\n",This,ppenum);
|
---|
444 |
|
---|
445 | if (BindCtxImpl_GetObjectIndex(This,NULL,ppenum,&index)==S_FALSE)
|
---|
446 | return E_FAIL;
|
---|
447 |
|
---|
448 | /* release the object if it's found */
|
---|
449 | IUnknown_Release(This->bindCtxTable[index].pObj);
|
---|
450 |
|
---|
451 | /* remove the object from the table with a left-shifting of all objects in the right side */
|
---|
452 | for(j=index; j<This->bindCtxTableLastIndex-1; j++)
|
---|
453 | This->bindCtxTable[j]= This->bindCtxTable[j+1];
|
---|
454 |
|
---|
455 | This->bindCtxTableLastIndex--;
|
---|
456 |
|
---|
457 | return S_OK;
|
---|
458 | }
|
---|
459 |
|
---|
460 | /******************************************************************************
|
---|
461 | * BindCtx_EnumObjectParam
|
---|
462 | ******************************************************************************/
|
---|
463 | HRESULT WINAPI BindCtxImpl_EnumObjectParam(IBindCtx* iface,IEnumString** pszkey)
|
---|
464 | {
|
---|
465 | FIXME("(%p,%p),stub!\n",iface,pszkey);
|
---|
466 | return E_NOTIMPL;
|
---|
467 | }
|
---|
468 |
|
---|
469 | /********************************************************************************
|
---|
470 | * GetObjectIndex (local function)
|
---|
471 | ********************************************************************************/
|
---|
472 | HRESULT WINAPI BindCtxImpl_GetObjectIndex(BindCtxImpl* This,
|
---|
473 | IUnknown* punk,
|
---|
474 | LPOLESTR pszkey,
|
---|
475 | DWORD *index)
|
---|
476 | {
|
---|
477 |
|
---|
478 | DWORD i;
|
---|
479 | BYTE found=0;
|
---|
480 |
|
---|
481 | TRACE("(%p,%p,%p,%p)\n",This,punk,pszkey,index);
|
---|
482 |
|
---|
483 | if (punk==NULL)
|
---|
484 | /* search object identified by a register key */
|
---|
485 | for(i=0; ( (i<This->bindCtxTableLastIndex) && (!found));i++){
|
---|
486 |
|
---|
487 | if(This->bindCtxTable[i].regType==1){
|
---|
488 |
|
---|
489 | if ( ( (This->bindCtxTable[i].pkeyObj==NULL) && (pszkey==NULL) ) ||
|
---|
490 | ( (This->bindCtxTable[i].pkeyObj!=NULL) &&
|
---|
491 | (pszkey!=NULL) &&
|
---|
492 | (lstrcmpW(This->bindCtxTable[i].pkeyObj,pszkey)==0)
|
---|
493 | )
|
---|
494 | )
|
---|
495 |
|
---|
496 | found=1;
|
---|
497 | }
|
---|
498 | }
|
---|
499 | else
|
---|
500 | /* search object identified by a moniker*/
|
---|
501 | for(i=0; ( (i<This->bindCtxTableLastIndex) && (!found));i++)
|
---|
502 | if(This->bindCtxTable[i].pObj==punk)
|
---|
503 | found=1;
|
---|
504 |
|
---|
505 | if (index != NULL)
|
---|
506 | *index=i-1;
|
---|
507 |
|
---|
508 | if (found)
|
---|
509 | return S_OK;
|
---|
510 | else
|
---|
511 | return S_FALSE;
|
---|
512 | }
|
---|
513 |
|
---|
514 | /******************************************************************************
|
---|
515 | * CreateBindCtx16
|
---|
516 | ******************************************************************************/
|
---|
517 | HRESULT WINAPI CreateBindCtx16(DWORD reserved, LPBC * ppbc)
|
---|
518 | {
|
---|
519 | FIXME("(%ld,%p),stub!\n",reserved,ppbc);
|
---|
520 | return E_NOTIMPL;
|
---|
521 | }
|
---|
522 |
|
---|
523 | /******************************************************************************
|
---|
524 | * CreateBindCtx
|
---|
525 | ******************************************************************************/
|
---|
526 | HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC * ppbc)
|
---|
527 | {
|
---|
528 | BindCtxImpl* newBindCtx = 0;
|
---|
529 | HRESULT hr;
|
---|
530 | IID riid=IID_IBindCtx;
|
---|
531 |
|
---|
532 | TRACE("(%ld,%p)\n",reserved,ppbc);
|
---|
533 |
|
---|
534 | newBindCtx = (BindCtxImpl *)HeapAlloc(GetProcessHeap(), 0, sizeof(BindCtxImpl));
|
---|
535 |
|
---|
536 | if (newBindCtx == 0)
|
---|
537 | return E_OUTOFMEMORY;
|
---|
538 |
|
---|
539 | hr = BindCtxImpl_Construct(newBindCtx);
|
---|
540 |
|
---|
541 | if (FAILED(hr)){
|
---|
542 |
|
---|
543 | HeapFree(GetProcessHeap(),0,newBindCtx);
|
---|
544 | return hr;
|
---|
545 | }
|
---|
546 |
|
---|
547 | hr = BindCtxImpl_QueryInterface((IBindCtx*)newBindCtx,&riid,(void**)ppbc);
|
---|
548 |
|
---|
549 | return hr;
|
---|
550 | }
|
---|