Release 990225.
[wine.git] / ole / itemmoniker.c
blob7c2a18491b9cac3bd20e8a4bb9ef0389c1ff7173
1 /***************************************************************************************
2 * ItemMonikers 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 ItemMonikerImpl{
20 ICOM_VTABLE(IMoniker)* lpvtbl;
22 ULONG ref;
24 } ItemMonikerImpl;
26 static HRESULT WINAPI ItemMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject);
27 static ULONG WINAPI ItemMonikerImpl_AddRef(IMoniker* iface);
28 static ULONG WINAPI ItemMonikerImpl_Release(IMoniker* iface);
29 static HRESULT WINAPI ItemMonikerImpl_GetClassID(const IMoniker* iface, CLSID *pClassID);
30 static HRESULT WINAPI ItemMonikerImpl_IsDirty(IMoniker* iface);
31 static HRESULT WINAPI ItemMonikerImpl_Load(IMoniker* iface, IStream32* pStm);
32 static HRESULT WINAPI ItemMonikerImpl_Save(IMoniker* iface, IStream32* pStm, BOOL32 fClearDirty);
33 static HRESULT WINAPI ItemMonikerImpl_GetSizeMax(IMoniker* iface, ULARGE_INTEGER* pcbSize);
34 static HRESULT WINAPI ItemMonikerImpl_BindToObject(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult);
35 static HRESULT WINAPI ItemMonikerImpl_BindToStorage(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult);
36 static HRESULT WINAPI ItemMonikerImpl_Reduce(IMoniker* iface,IBindCtx* pbc, DWORD dwReduceHowFar,IMoniker** ppmkToLeft, IMoniker** ppmkReduced);
37 static HRESULT WINAPI ItemMonikerImpl_ComposeWith(IMoniker* iface,IMoniker* pmkRight,BOOL32 fOnlyIfNotGeneric, IMoniker** ppmkComposite);
38 static HRESULT WINAPI ItemMonikerImpl_Enum(IMoniker* iface,BOOL32 fForward, IEnumMoniker** ppenumMoniker);
39 static HRESULT WINAPI ItemMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker);
40 static HRESULT WINAPI ItemMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash);
41 static HRESULT WINAPI ItemMonikerImpl_IsRunning(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, IMoniker* pmkNewlyRunning);
42 static HRESULT WINAPI ItemMonikerImpl_GetTimeOfLastChange(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft, FILETIME* pItemTime);
43 static HRESULT WINAPI ItemMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk);
44 static HRESULT WINAPI ItemMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther, IMoniker** ppmkPrefix);
45 static HRESULT WINAPI ItemMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath);
46 static HRESULT WINAPI ItemMonikerImpl_GetDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, LPOLESTR32 *ppszDisplayName);
47 static HRESULT WINAPI ItemMonikerImpl_ParseDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, LPOLESTR32 pszDisplayName, ULONG* pchEaten, IMoniker** ppmkOut);
48 static HRESULT WINAPI ItemMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys);
50 static HRESULT WINAPI ItemMonikerImpl_Construct(ItemMonikerImpl* iface, LPCOLESTR32 lpszDelim,LPCOLESTR32 lpszItem);
51 static HRESULT WINAPI ItemMonikerImpl_Destroy(ItemMonikerImpl* iface);
53 // Virtual function table for the ItemMonikerImpl class.
54 static ICOM_VTABLE(IMoniker) VT_ItemMonikerImpl =
56 ItemMonikerImpl_QueryInterface,
57 ItemMonikerImpl_AddRef,
58 ItemMonikerImpl_Release,
59 ItemMonikerImpl_GetClassID,
60 ItemMonikerImpl_IsDirty,
61 ItemMonikerImpl_Load,
62 ItemMonikerImpl_Save,
63 ItemMonikerImpl_GetSizeMax,
64 ItemMonikerImpl_BindToObject,
65 ItemMonikerImpl_BindToStorage,
66 ItemMonikerImpl_Reduce,
67 ItemMonikerImpl_ComposeWith,
68 ItemMonikerImpl_Enum,
69 ItemMonikerImpl_IsEqual,
70 ItemMonikerImpl_Hash,
71 ItemMonikerImpl_IsRunning,
72 ItemMonikerImpl_GetTimeOfLastChange,
73 ItemMonikerImpl_Inverse,
74 ItemMonikerImpl_CommonPrefixWith,
75 ItemMonikerImpl_RelativePathTo,
76 ItemMonikerImpl_GetDisplayName,
77 ItemMonikerImpl_ParseDisplayName,
78 ItemMonikerImpl_IsSystemMoniker
81 /*******************************************************************************
82 * ItemMoniker_QueryInterface
83 *******************************************************************************/
84 HRESULT WINAPI ItemMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
86 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
88 TRACE(ole,"(%p,%p,%p)\n",This,riid,ppvObject);
90 // Perform a sanity check on the parameters.
91 if ( (This==0) || (ppvObject==0) ) return E_INVALIDARG;
93 // Initialize the return parameter.
94 *ppvObject = 0;
96 // Compare the riid with the interface IDs implemented by this object.
97 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
98 *ppvObject = (IMoniker*)This;
99 else
100 if (memcmp(&IID_IPersist, riid, sizeof(IID_IPersist)) == 0)
101 *ppvObject = (IMoniker*)This;
102 else
103 if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0)
104 *ppvObject = (IMoniker*)This;
105 else
106 if (memcmp(&IID_IMoniker, riid, sizeof(IID_IMoniker)) == 0)
107 *ppvObject = (IMoniker*)This;
109 // Check that we obtained an interface.
110 if ((*ppvObject)==0) return E_NOINTERFACE;
112 // Query Interface always increases the reference count by one when it is successful
113 ItemMonikerImpl_AddRef(iface);
115 return S_OK;
118 /******************************************************************************
119 * ItemMoniker_AddRef
120 ******************************************************************************/
121 ULONG WINAPI ItemMonikerImpl_AddRef(IMoniker* iface)
123 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
125 TRACE(ole,"(%p)\n",This);
127 return ++(This->ref);
130 /******************************************************************************
131 * ItemMoniker_Release
132 ******************************************************************************/
133 ULONG WINAPI ItemMonikerImpl_Release(IMoniker* iface)
135 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
137 TRACE(ole,"(%p),stub!\n",This);
139 This->ref--;
141 if (This->ref==0){
142 ItemMonikerImpl_Destroy(This);
143 return 0;
146 return This->ref;
149 /******************************************************************************
150 * ItemMoniker_GetClassID
151 ******************************************************************************/
152 HRESULT WINAPI ItemMonikerImpl_GetClassID(const IMoniker* iface, CLSID *pClassID)//Pointer to CLSID of object
154 FIXME(ole,"(%p),stub!\n",pClassID);
155 return E_NOTIMPL;
158 /******************************************************************************
159 * ItemMoniker_IsDirty
160 ******************************************************************************/
161 HRESULT WINAPI ItemMonikerImpl_IsDirty(IMoniker* iface)
163 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
165 FIXME(ole,"(%p),stub!\n",This);
166 return E_NOTIMPL;
169 /******************************************************************************
170 * ItemMoniker_Load
171 ******************************************************************************/
172 HRESULT WINAPI ItemMonikerImpl_Load(
173 IMoniker* iface,
174 IStream32* pStm)
176 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
178 FIXME(ole,"(%p,%p),stub!\n",This,pStm);
179 return E_NOTIMPL;
182 /******************************************************************************
183 * ItemMoniker_Save
184 ******************************************************************************/
185 HRESULT WINAPI ItemMonikerImpl_Save(
186 IMoniker* iface,
187 IStream32* pStm,
188 BOOL32 fClearDirty)
190 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
192 FIXME(ole,"(%p,%p,%d),stub!\n",This,pStm,fClearDirty);
193 return E_NOTIMPL;
196 /******************************************************************************
197 * ItemMoniker_GetSizeMax
198 ******************************************************************************/
199 HRESULT WINAPI ItemMonikerImpl_GetSizeMax(
200 IMoniker* iface,
201 ULARGE_INTEGER* pcbSize)
203 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
205 FIXME(ole,"(%p,%p),stub!\n",This,pcbSize);
206 return E_NOTIMPL;
209 /******************************************************************************
210 * ItemMoniker_Construct
211 *******************************************************************************/
212 HRESULT WINAPI ItemMonikerImpl_Construct(ItemMonikerImpl* This, LPCOLESTR32 lpszDelim,LPCOLESTR32 lpszItem){
214 FIXME(ole,"(%p,%p,%p),stub!\n",This,lpszDelim,lpszItem);
216 memset(This, 0, sizeof(ItemMonikerImpl));
218 //Initialize the virtual fgunction table.
219 This->lpvtbl = &VT_ItemMonikerImpl;
220 return S_OK;
223 /******************************************************************************
224 * ItemMoniker_Destroy
225 *******************************************************************************/
226 HRESULT WINAPI ItemMonikerImpl_Destroy(ItemMonikerImpl* This){
228 FIXME(ole,"(%p),stub!\n",This);
230 SEGPTR_FREE(This);
231 return S_OK;
234 /******************************************************************************
235 * ItemMoniker_BindToObject
236 ******************************************************************************/
237 HRESULT WINAPI ItemMonikerImpl_BindToObject(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft,
238 REFIID riid, VOID** ppvResult)
240 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
242 FIXME(ole,"(%p,%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,riid,ppvResult);
243 return E_NOTIMPL;
246 /******************************************************************************
247 * ItemMoniker_BindToStorage
248 ******************************************************************************/
249 HRESULT WINAPI ItemMonikerImpl_BindToStorage(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft,
250 REFIID riid, VOID** ppvResult)
252 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
254 FIXME(ole,"(%p,%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,riid,ppvResult);
255 return E_NOTIMPL;
258 /******************************************************************************
259 * ItemMoniker_Reduce
260 ******************************************************************************/
261 HRESULT WINAPI ItemMonikerImpl_Reduce(IMoniker* iface,IBindCtx* pbc, DWORD dwReduceHowFar,
262 IMoniker** ppmkToLeft, IMoniker** ppmkReduced)
264 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
266 FIXME(ole,"(%p,%p,%ld,%p,%p),stub!\n",This,pbc,dwReduceHowFar,ppmkToLeft,ppmkReduced);
267 return E_NOTIMPL;
270 /******************************************************************************
271 * ItemMoniker_ComposeWith
272 ******************************************************************************/
273 HRESULT WINAPI ItemMonikerImpl_ComposeWith(IMoniker* iface,IMoniker* pmkRight,BOOL32 fOnlyIfNotGeneric,
274 IMoniker** ppmkComposite)
276 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
278 FIXME(ole,"(%p,%p,%d,%p),stub!\n",This,pmkRight,fOnlyIfNotGeneric,ppmkComposite);
279 return E_NOTIMPL;
282 /******************************************************************************
283 * ItemMoniker_Enum
284 ******************************************************************************/
285 HRESULT WINAPI ItemMonikerImpl_Enum(IMoniker* iface,BOOL32 fForward, IEnumMoniker** ppenumMoniker)
287 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
289 FIXME(ole,"(%p,%d,%p),stub!\n",This,fForward,ppenumMoniker);
290 return E_NOTIMPL;
294 /******************************************************************************
295 * ItemMoniker_IsEqual
296 ******************************************************************************/
297 HRESULT WINAPI ItemMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
299 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
301 FIXME(ole,"(%p,%p),stub!\n",This,pmkOtherMoniker);
302 return E_NOTIMPL;
305 /******************************************************************************
306 * ItemMoniker_Hash
307 ******************************************************************************/
308 HRESULT WINAPI ItemMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash)
310 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
312 FIXME(ole,"(%p,%p),stub!\n",This,pdwHash);
313 return E_NOTIMPL;
316 /******************************************************************************
317 * ItemMoniker_IsRunning
318 ******************************************************************************/
319 HRESULT WINAPI ItemMonikerImpl_IsRunning(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft,
320 IMoniker* pmkNewlyRunning)
322 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
324 FIXME(ole,"(%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,pmkNewlyRunning);
325 return E_NOTIMPL;
328 /******************************************************************************
329 * ItemMoniker_GetTimeOfLastChange
330 ******************************************************************************/
331 HRESULT WINAPI ItemMonikerImpl_GetTimeOfLastChange(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft,
332 FILETIME* pFileTime)
334 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
336 FIXME(ole,"(%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,pFileTime);
337 return E_NOTIMPL;
340 /******************************************************************************
341 * ItemMoniker_Inverse
342 ******************************************************************************/
343 HRESULT WINAPI ItemMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk)
345 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
347 FIXME(ole,"(%p,%p),stub!\n",This,ppmk);
348 return E_NOTIMPL;
351 /******************************************************************************
352 * ItemMoniker_CommonPrefixWith
353 ******************************************************************************/
354 HRESULT WINAPI ItemMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,
355 IMoniker** ppmkPrefix)
357 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
359 FIXME(ole,"(%p,%p,%p),stub!\n",This,pmkOther,ppmkPrefix);
360 return E_NOTIMPL;
363 /******************************************************************************
364 * ItemMoniker_RelativePathTo
365 ******************************************************************************/
366 HRESULT WINAPI ItemMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath)
368 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
370 FIXME(ole,"(%p,%p,%p),stub!\n",This,pmOther,ppmkRelPath);
371 return E_NOTIMPL;
374 /******************************************************************************
375 * ItemMoniker_GetDisplayName
376 ******************************************************************************/
377 HRESULT WINAPI ItemMonikerImpl_GetDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft,
378 LPOLESTR32 *ppszDisplayName)
380 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
382 FIXME(ole,"(%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,ppszDisplayName);
383 return E_NOTIMPL;
386 /******************************************************************************
387 * ItemMoniker_ParseDisplayName
388 ******************************************************************************/
389 HRESULT WINAPI ItemMonikerImpl_ParseDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft,
390 LPOLESTR32 pszDisplayName, ULONG* pchEaten, IMoniker** ppmkOut)
392 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
394 FIXME(ole,"(%p,%p,%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,pszDisplayName,pchEaten,ppmkOut);
395 return E_NOTIMPL;
398 /******************************************************************************
399 * ItemMoniker_IsSystemMonker
400 ******************************************************************************/
401 HRESULT WINAPI ItemMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys)
403 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
405 FIXME(ole,"(%p,%p),stub!\n",This,pwdMksys);
406 return E_NOTIMPL;
409 /******************************************************************************
410 * CreateItemMoniker16 [OLE2.28]
411 ******************************************************************************/
412 HRESULT WINAPI CreateItemMoniker16(LPCOLESTR16 lpszDelim,LPCOLESTR32 lpszItem,LPMONIKER* ppmk){// [in] pathname [out] new moniker object
414 FIXME(ole,"(%s,%p),stub!\n",lpszDelim,ppmk);
415 *ppmk = NULL;
416 return E_NOTIMPL;
419 /******************************************************************************
420 * CreateItemMoniker32 [OLE32.55]
421 ******************************************************************************/
422 HRESULT WINAPI CreateItemMoniker32(LPCOLESTR32 lpszDelim,LPCOLESTR32 lpszItem, LPMONIKER * ppmk)
425 ItemMonikerImpl* newItemMoniker = 0;
426 HRESULT hr = S_OK;
428 TRACE(ole,"(%p,%p,%p)\n",lpszDelim,lpszItem,ppmk);
430 newItemMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(ItemMonikerImpl));
432 if (newItemMoniker == 0)
433 return STG_E_INSUFFICIENTMEMORY;
435 hr = ItemMonikerImpl_Construct(newItemMoniker,lpszDelim,lpszItem);
437 if (FAILED(hr))
438 return hr;
440 hr = ItemMonikerImpl_QueryInterface((IMoniker*)newItemMoniker,&IID_IMoniker,(void**)ppmk);
442 return hr;