Adapted to cursor/icon handling changes.
[wine/multimedia.git] / ole / itemmoniker.c
blob1312e19a43ad0a36a7b220e9439b09fd7e27b0d7
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_moniker.h"
13 #include "debug.h"
14 #include "heap.h"
16 typedef struct ItemMonikerImpl{
18 ICOM_VTABLE(IMoniker)* lpvtbl;
20 ULONG ref;
22 } ItemMonikerImpl;
24 static HRESULT WINAPI ItemMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject);
25 static ULONG WINAPI ItemMonikerImpl_AddRef(IMoniker* iface);
26 static ULONG WINAPI ItemMonikerImpl_Release(IMoniker* iface);
27 static HRESULT WINAPI ItemMonikerImpl_GetClassID(const IMoniker* iface, CLSID *pClassID);
28 static HRESULT WINAPI ItemMonikerImpl_IsDirty(IMoniker* iface);
29 static HRESULT WINAPI ItemMonikerImpl_Load(IMoniker* iface, IStream* pStm);
30 static HRESULT WINAPI ItemMonikerImpl_Save(IMoniker* iface, IStream* pStm, BOOL fClearDirty);
31 static HRESULT WINAPI ItemMonikerImpl_GetSizeMax(IMoniker* iface, ULARGE_INTEGER* pcbSize);
32 static HRESULT WINAPI ItemMonikerImpl_BindToObject(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult);
33 static HRESULT WINAPI ItemMonikerImpl_BindToStorage(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult);
34 static HRESULT WINAPI ItemMonikerImpl_Reduce(IMoniker* iface,IBindCtx* pbc, DWORD dwReduceHowFar,IMoniker** ppmkToLeft, IMoniker** ppmkReduced);
35 static HRESULT WINAPI ItemMonikerImpl_ComposeWith(IMoniker* iface,IMoniker* pmkRight,BOOL fOnlyIfNotGeneric, IMoniker** ppmkComposite);
36 static HRESULT WINAPI ItemMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker);
37 static HRESULT WINAPI ItemMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker);
38 static HRESULT WINAPI ItemMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash);
39 static HRESULT WINAPI ItemMonikerImpl_IsRunning(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, IMoniker* pmkNewlyRunning);
40 static HRESULT WINAPI ItemMonikerImpl_GetTimeOfLastChange(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft, FILETIME* pItemTime);
41 static HRESULT WINAPI ItemMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk);
42 static HRESULT WINAPI ItemMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther, IMoniker** ppmkPrefix);
43 static HRESULT WINAPI ItemMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath);
44 static HRESULT WINAPI ItemMonikerImpl_GetDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, LPOLESTR *ppszDisplayName);
45 static HRESULT WINAPI ItemMonikerImpl_ParseDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, LPOLESTR pszDisplayName, ULONG* pchEaten, IMoniker** ppmkOut);
46 static HRESULT WINAPI ItemMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys);
48 static HRESULT WINAPI ItemMonikerImpl_Construct(ItemMonikerImpl* iface, LPCOLESTR lpszDelim,LPCOLESTR lpszItem);
49 static HRESULT WINAPI ItemMonikerImpl_Destroy(ItemMonikerImpl* iface);
51 // Virtual function table for the ItemMonikerImpl class.
52 static ICOM_VTABLE(IMoniker) VT_ItemMonikerImpl =
54 ItemMonikerImpl_QueryInterface,
55 ItemMonikerImpl_AddRef,
56 ItemMonikerImpl_Release,
57 ItemMonikerImpl_GetClassID,
58 ItemMonikerImpl_IsDirty,
59 ItemMonikerImpl_Load,
60 ItemMonikerImpl_Save,
61 ItemMonikerImpl_GetSizeMax,
62 ItemMonikerImpl_BindToObject,
63 ItemMonikerImpl_BindToStorage,
64 ItemMonikerImpl_Reduce,
65 ItemMonikerImpl_ComposeWith,
66 ItemMonikerImpl_Enum,
67 ItemMonikerImpl_IsEqual,
68 ItemMonikerImpl_Hash,
69 ItemMonikerImpl_IsRunning,
70 ItemMonikerImpl_GetTimeOfLastChange,
71 ItemMonikerImpl_Inverse,
72 ItemMonikerImpl_CommonPrefixWith,
73 ItemMonikerImpl_RelativePathTo,
74 ItemMonikerImpl_GetDisplayName,
75 ItemMonikerImpl_ParseDisplayName,
76 ItemMonikerImpl_IsSystemMoniker
79 /*******************************************************************************
80 * ItemMoniker_QueryInterface
81 *******************************************************************************/
82 HRESULT WINAPI ItemMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
84 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
86 TRACE(ole,"(%p,%p,%p)\n",This,riid,ppvObject);
88 // Perform a sanity check on the parameters.
89 if ( (This==0) || (ppvObject==0) ) return E_INVALIDARG;
91 // Initialize the return parameter.
92 *ppvObject = 0;
94 // Compare the riid with the interface IDs implemented by this object.
95 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
96 *ppvObject = (IMoniker*)This;
97 else
98 if (memcmp(&IID_IPersist, riid, sizeof(IID_IPersist)) == 0)
99 *ppvObject = (IMoniker*)This;
100 else
101 if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0)
102 *ppvObject = (IMoniker*)This;
103 else
104 if (memcmp(&IID_IMoniker, riid, sizeof(IID_IMoniker)) == 0)
105 *ppvObject = (IMoniker*)This;
107 // Check that we obtained an interface.
108 if ((*ppvObject)==0) return E_NOINTERFACE;
110 // Query Interface always increases the reference count by one when it is successful
111 ItemMonikerImpl_AddRef(iface);
113 return S_OK;
116 /******************************************************************************
117 * ItemMoniker_AddRef
118 ******************************************************************************/
119 ULONG WINAPI ItemMonikerImpl_AddRef(IMoniker* iface)
121 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
123 TRACE(ole,"(%p)\n",This);
125 return ++(This->ref);
128 /******************************************************************************
129 * ItemMoniker_Release
130 ******************************************************************************/
131 ULONG WINAPI ItemMonikerImpl_Release(IMoniker* iface)
133 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
135 TRACE(ole,"(%p),stub!\n",This);
137 This->ref--;
139 if (This->ref==0){
140 ItemMonikerImpl_Destroy(This);
141 return 0;
144 return This->ref;
147 /******************************************************************************
148 * ItemMoniker_GetClassID
149 ******************************************************************************/
150 HRESULT WINAPI ItemMonikerImpl_GetClassID(const IMoniker* iface, CLSID *pClassID)//Pointer to CLSID of object
152 FIXME(ole,"(%p),stub!\n",pClassID);
153 return E_NOTIMPL;
156 /******************************************************************************
157 * ItemMoniker_IsDirty
158 ******************************************************************************/
159 HRESULT WINAPI ItemMonikerImpl_IsDirty(IMoniker* iface)
161 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
163 FIXME(ole,"(%p),stub!\n",This);
164 return E_NOTIMPL;
167 /******************************************************************************
168 * ItemMoniker_Load
169 ******************************************************************************/
170 HRESULT WINAPI ItemMonikerImpl_Load(
171 IMoniker* iface,
172 IStream* pStm)
174 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
176 FIXME(ole,"(%p,%p),stub!\n",This,pStm);
177 return E_NOTIMPL;
180 /******************************************************************************
181 * ItemMoniker_Save
182 ******************************************************************************/
183 HRESULT WINAPI ItemMonikerImpl_Save(
184 IMoniker* iface,
185 IStream* pStm,
186 BOOL fClearDirty)
188 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
190 FIXME(ole,"(%p,%p,%d),stub!\n",This,pStm,fClearDirty);
191 return E_NOTIMPL;
194 /******************************************************************************
195 * ItemMoniker_GetSizeMax
196 ******************************************************************************/
197 HRESULT WINAPI ItemMonikerImpl_GetSizeMax(
198 IMoniker* iface,
199 ULARGE_INTEGER* pcbSize)
201 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
203 FIXME(ole,"(%p,%p),stub!\n",This,pcbSize);
204 return E_NOTIMPL;
207 /******************************************************************************
208 * ItemMoniker_Construct
209 *******************************************************************************/
210 HRESULT WINAPI ItemMonikerImpl_Construct(ItemMonikerImpl* This, LPCOLESTR lpszDelim,LPCOLESTR lpszItem){
212 FIXME(ole,"(%p,%p,%p),stub!\n",This,lpszDelim,lpszItem);
214 memset(This, 0, sizeof(ItemMonikerImpl));
216 //Initialize the virtual fgunction table.
217 This->lpvtbl = &VT_ItemMonikerImpl;
218 return S_OK;
221 /******************************************************************************
222 * ItemMoniker_Destroy
223 *******************************************************************************/
224 HRESULT WINAPI ItemMonikerImpl_Destroy(ItemMonikerImpl* This){
226 FIXME(ole,"(%p),stub!\n",This);
228 SEGPTR_FREE(This);
229 return S_OK;
232 /******************************************************************************
233 * ItemMoniker_BindToObject
234 ******************************************************************************/
235 HRESULT WINAPI ItemMonikerImpl_BindToObject(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft,
236 REFIID riid, VOID** ppvResult)
238 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
240 FIXME(ole,"(%p,%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,riid,ppvResult);
241 return E_NOTIMPL;
244 /******************************************************************************
245 * ItemMoniker_BindToStorage
246 ******************************************************************************/
247 HRESULT WINAPI ItemMonikerImpl_BindToStorage(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft,
248 REFIID riid, VOID** ppvResult)
250 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
252 FIXME(ole,"(%p,%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,riid,ppvResult);
253 return E_NOTIMPL;
256 /******************************************************************************
257 * ItemMoniker_Reduce
258 ******************************************************************************/
259 HRESULT WINAPI ItemMonikerImpl_Reduce(IMoniker* iface,IBindCtx* pbc, DWORD dwReduceHowFar,
260 IMoniker** ppmkToLeft, IMoniker** ppmkReduced)
262 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
264 FIXME(ole,"(%p,%p,%ld,%p,%p),stub!\n",This,pbc,dwReduceHowFar,ppmkToLeft,ppmkReduced);
265 return E_NOTIMPL;
268 /******************************************************************************
269 * ItemMoniker_ComposeWith
270 ******************************************************************************/
271 HRESULT WINAPI ItemMonikerImpl_ComposeWith(IMoniker* iface,IMoniker* pmkRight,BOOL fOnlyIfNotGeneric,
272 IMoniker** ppmkComposite)
274 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
276 FIXME(ole,"(%p,%p,%d,%p),stub!\n",This,pmkRight,fOnlyIfNotGeneric,ppmkComposite);
277 return E_NOTIMPL;
280 /******************************************************************************
281 * ItemMoniker_Enum
282 ******************************************************************************/
283 HRESULT WINAPI ItemMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker)
285 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
287 FIXME(ole,"(%p,%d,%p),stub!\n",This,fForward,ppenumMoniker);
288 return E_NOTIMPL;
292 /******************************************************************************
293 * ItemMoniker_IsEqual
294 ******************************************************************************/
295 HRESULT WINAPI ItemMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
297 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
299 FIXME(ole,"(%p,%p),stub!\n",This,pmkOtherMoniker);
300 return E_NOTIMPL;
303 /******************************************************************************
304 * ItemMoniker_Hash
305 ******************************************************************************/
306 HRESULT WINAPI ItemMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash)
308 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
310 FIXME(ole,"(%p,%p),stub!\n",This,pdwHash);
311 return E_NOTIMPL;
314 /******************************************************************************
315 * ItemMoniker_IsRunning
316 ******************************************************************************/
317 HRESULT WINAPI ItemMonikerImpl_IsRunning(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft,
318 IMoniker* pmkNewlyRunning)
320 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
322 FIXME(ole,"(%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,pmkNewlyRunning);
323 return E_NOTIMPL;
326 /******************************************************************************
327 * ItemMoniker_GetTimeOfLastChange
328 ******************************************************************************/
329 HRESULT WINAPI ItemMonikerImpl_GetTimeOfLastChange(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft,
330 FILETIME* pFileTime)
332 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
334 FIXME(ole,"(%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,pFileTime);
335 return E_NOTIMPL;
338 /******************************************************************************
339 * ItemMoniker_Inverse
340 ******************************************************************************/
341 HRESULT WINAPI ItemMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk)
343 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
345 FIXME(ole,"(%p,%p),stub!\n",This,ppmk);
346 return E_NOTIMPL;
349 /******************************************************************************
350 * ItemMoniker_CommonPrefixWith
351 ******************************************************************************/
352 HRESULT WINAPI ItemMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,
353 IMoniker** ppmkPrefix)
355 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
357 FIXME(ole,"(%p,%p,%p),stub!\n",This,pmkOther,ppmkPrefix);
358 return E_NOTIMPL;
361 /******************************************************************************
362 * ItemMoniker_RelativePathTo
363 ******************************************************************************/
364 HRESULT WINAPI ItemMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath)
366 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
368 FIXME(ole,"(%p,%p,%p),stub!\n",This,pmOther,ppmkRelPath);
369 return E_NOTIMPL;
372 /******************************************************************************
373 * ItemMoniker_GetDisplayName
374 ******************************************************************************/
375 HRESULT WINAPI ItemMonikerImpl_GetDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft,
376 LPOLESTR *ppszDisplayName)
378 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
380 FIXME(ole,"(%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,ppszDisplayName);
381 return E_NOTIMPL;
384 /******************************************************************************
385 * ItemMoniker_ParseDisplayName
386 ******************************************************************************/
387 HRESULT WINAPI ItemMonikerImpl_ParseDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft,
388 LPOLESTR pszDisplayName, ULONG* pchEaten, IMoniker** ppmkOut)
390 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
392 FIXME(ole,"(%p,%p,%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,pszDisplayName,pchEaten,ppmkOut);
393 return E_NOTIMPL;
396 /******************************************************************************
397 * ItemMoniker_IsSystemMonker
398 ******************************************************************************/
399 HRESULT WINAPI ItemMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys)
401 ItemMonikerImpl* This=(ItemMonikerImpl*)iface;
403 FIXME(ole,"(%p,%p),stub!\n",This,pwdMksys);
404 return E_NOTIMPL;
407 /******************************************************************************
408 * CreateItemMoniker16 [OLE2.28]
409 ******************************************************************************/
410 HRESULT WINAPI CreateItemMoniker16(LPCOLESTR16 lpszDelim,LPCOLESTR lpszItem,LPMONIKER* ppmk){// [in] pathname [out] new moniker object
412 FIXME(ole,"(%s,%p),stub!\n",lpszDelim,ppmk);
413 *ppmk = NULL;
414 return E_NOTIMPL;
417 /******************************************************************************
418 * CreateItemMoniker32 [OLE32.55]
419 ******************************************************************************/
420 HRESULT WINAPI CreateItemMoniker(LPCOLESTR lpszDelim,LPCOLESTR lpszItem, LPMONIKER * ppmk)
423 ItemMonikerImpl* newItemMoniker = 0;
424 HRESULT hr = S_OK;
426 TRACE(ole,"(%p,%p,%p)\n",lpszDelim,lpszItem,ppmk);
428 newItemMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(ItemMonikerImpl));
430 if (newItemMoniker == 0)
431 return STG_E_INSUFFICIENTMEMORY;
433 hr = ItemMonikerImpl_Construct(newItemMoniker,lpszDelim,lpszItem);
435 if (FAILED(hr))
436 return hr;
438 hr = ItemMonikerImpl_QueryInterface((IMoniker*)newItemMoniker,&IID_IMoniker,(void**)ppmk);
440 return hr;