Release 990226.
[wine/gsoc-2012-control.git] / ole / filemoniker.c
blob50de54425ce1792a13e0aa89d66216d1f30db79e
1 /***************************************************************************************
2 * FileMonikers 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 FileMonikerImpl{
20 ICOM_VTABLE(IMoniker)* lpvtbl;
22 ULONG ref;
24 } FileMonikerImpl;
26 static HRESULT WINAPI FileMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject);
27 static ULONG WINAPI FileMonikerImpl_AddRef(IMoniker* iface);
28 static ULONG WINAPI FileMonikerImpl_Release(IMoniker* iface);
29 static HRESULT WINAPI FileMonikerImpl_GetClassID(const IMoniker* iface, CLSID *pClassID);
30 static HRESULT WINAPI FileMonikerImpl_IsDirty(IMoniker* iface);
31 static HRESULT WINAPI FileMonikerImpl_Load(IMoniker* iface, IStream* pStm);
32 static HRESULT WINAPI FileMonikerImpl_Save(IMoniker* iface, IStream* pStm, BOOL fClearDirty);
33 static HRESULT WINAPI FileMonikerImpl_GetSizeMax(IMoniker* iface, ULARGE_INTEGER* pcbSize);
34 static HRESULT WINAPI FileMonikerImpl_BindToObject(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult);
35 static HRESULT WINAPI FileMonikerImpl_BindToStorage(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult);
36 static HRESULT WINAPI FileMonikerImpl_Reduce(IMoniker* iface,IBindCtx* pbc, DWORD dwReduceHowFar,IMoniker** ppmkToLeft, IMoniker** ppmkReduced);
37 static HRESULT WINAPI FileMonikerImpl_ComposeWith(IMoniker* iface,IMoniker* pmkRight,BOOL fOnlyIfNotGeneric, IMoniker** ppmkComposite);
38 static HRESULT WINAPI FileMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker);
39 static HRESULT WINAPI FileMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker);
40 static HRESULT WINAPI FileMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash);
41 static HRESULT WINAPI FileMonikerImpl_IsRunning(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, IMoniker* pmkNewlyRunning);
42 static HRESULT WINAPI FileMonikerImpl_GetTimeOfLastChange(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft, FILETIME* pFileTime);
43 static HRESULT WINAPI FileMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk);
44 static HRESULT WINAPI FileMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther, IMoniker** ppmkPrefix);
45 static HRESULT WINAPI FileMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath);
46 static HRESULT WINAPI FileMonikerImpl_GetDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, LPOLESTR *ppszDisplayName);
47 static HRESULT WINAPI FileMonikerImpl_ParseDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, LPOLESTR pszDisplayName, ULONG* pchEaten, IMoniker** ppmkOut);
48 static HRESULT WINAPI FileMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys);
50 static HRESULT WINAPI FileMonikerImpl_Construct(FileMonikerImpl* iface, LPCOLESTR lpszPathName);
51 static HRESULT WINAPI FileMonikerImpl_Destroy(FileMonikerImpl* iface);
53 // Virtual function table for the FileMonikerImpl class.
54 static ICOM_VTABLE(IMoniker) VT_FileMonikerImpl =
56 FileMonikerImpl_QueryInterface,
57 FileMonikerImpl_AddRef,
58 FileMonikerImpl_Release,
59 FileMonikerImpl_GetClassID,
60 FileMonikerImpl_IsDirty,
61 FileMonikerImpl_Load,
62 FileMonikerImpl_Save,
63 FileMonikerImpl_GetSizeMax,
64 FileMonikerImpl_BindToObject,
65 FileMonikerImpl_BindToStorage,
66 FileMonikerImpl_Reduce,
67 FileMonikerImpl_ComposeWith,
68 FileMonikerImpl_Enum,
69 FileMonikerImpl_IsEqual,
70 FileMonikerImpl_Hash,
71 FileMonikerImpl_IsRunning,
72 FileMonikerImpl_GetTimeOfLastChange,
73 FileMonikerImpl_Inverse,
74 FileMonikerImpl_CommonPrefixWith,
75 FileMonikerImpl_RelativePathTo,
76 FileMonikerImpl_GetDisplayName,
77 FileMonikerImpl_ParseDisplayName,
78 FileMonikerImpl_IsSystemMoniker
81 /*******************************************************************************
82 * FileMoniker_QueryInterface
83 *******************************************************************************/
84 HRESULT WINAPI FileMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
86 FileMonikerImpl* This=(FileMonikerImpl*)iface;
87 TRACE(ole,"(%p,%p,%p)\n",This,riid,ppvObject);
89 // Perform a sanity check on the parameters.
90 if ( (This==0) || (ppvObject==0) ) return E_INVALIDARG;
92 // Initialize the return parameter.
93 *ppvObject = 0;
95 // Compare the riid with the interface IDs implemented by this object.
96 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
97 *ppvObject = (IMoniker*)This;
98 else
99 if (memcmp(&IID_IPersist, riid, sizeof(IID_IPersist)) == 0)
100 *ppvObject = (IMoniker*)This;
101 else
102 if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0)
103 *ppvObject = (IMoniker*)This;
104 else
105 if (memcmp(&IID_IMoniker, riid, sizeof(IID_IMoniker)) == 0)
106 *ppvObject = (IMoniker*)This;
108 // Check that we obtained an interface.
109 if ((*ppvObject)==0) return E_NOINTERFACE;
111 // Query Interface always increases the reference count by one when it is successful
112 FileMonikerImpl_AddRef(iface);
114 return S_OK;;
117 /******************************************************************************
118 * FileMoniker_AddRef
119 ******************************************************************************/
120 ULONG WINAPI FileMonikerImpl_AddRef(IMoniker* iface)
122 FileMonikerImpl* This=(FileMonikerImpl*)iface;
124 TRACE(ole,"(%p)\n",This);
126 return ++(This->ref);
129 /******************************************************************************
130 * FileMoniker_Release
131 ******************************************************************************/
132 ULONG WINAPI FileMonikerImpl_Release(IMoniker* iface)
134 FileMonikerImpl* This=(FileMonikerImpl*)iface;
136 TRACE(ole,"(%p)\n",This);
138 This->ref--;
140 if (This->ref==0){
141 FileMonikerImpl_Destroy(This);
142 return 0;
144 return This->ref;;
147 /******************************************************************************
148 * FileMoniker_GetClassID
149 ******************************************************************************/
150 HRESULT WINAPI FileMonikerImpl_GetClassID(const IMoniker* iface, CLSID *pClassID)//Pointer to CLSID of object
152 FileMonikerImpl* This=(FileMonikerImpl*)iface;
154 FIXME(ole,"(%p,%p),stub!\n",This,pClassID);
156 return E_NOTIMPL;
159 /******************************************************************************
160 * FileMoniker_IsDirty
161 ******************************************************************************/
162 HRESULT WINAPI FileMonikerImpl_IsDirty(IMoniker* iface)
164 FileMonikerImpl* This=(FileMonikerImpl*)iface;
166 FIXME(ole,"(%p),stub!\n",This);
168 return E_NOTIMPL;
171 /******************************************************************************
172 * FileMoniker_Load
173 ******************************************************************************/
174 HRESULT WINAPI FileMonikerImpl_Load(
175 IMoniker* iface,
176 IStream* pStm)
178 FileMonikerImpl* This=(FileMonikerImpl*)iface;
180 FIXME(ole,"(%p,%p),stub!\n",This,pStm);
182 return E_NOTIMPL;
185 /******************************************************************************
186 * FileMoniker_Save
187 ******************************************************************************/
188 HRESULT WINAPI FileMonikerImpl_Save(
189 IMoniker* iface,
190 IStream* pStm,
191 BOOL fClearDirty)
193 FileMonikerImpl* This=(FileMonikerImpl*)iface;
195 FIXME(ole,"(%p,%p,%d),stub!\n",This,pStm,fClearDirty);
197 return E_NOTIMPL;
200 /******************************************************************************
201 * FileMoniker_GetSizeMax
202 ******************************************************************************/
203 HRESULT WINAPI FileMonikerImpl_GetSizeMax(
204 IMoniker* iface,
205 ULARGE_INTEGER* pcbSize)
207 FileMonikerImpl* This=(FileMonikerImpl*)iface;
209 FIXME(ole,"(%p,%p),stub!\n",This,pcbSize);
211 return E_NOTIMPL;
214 /******************************************************************************
215 * FileMoniker_Construct
216 *******************************************************************************/
217 HRESULT WINAPI FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPathName){
219 FIXME(ole,"(%p,%p),stub!\n",This,lpszPathName);
221 memset(This, 0, sizeof(FileMonikerImpl));
223 //Initialize the virtual fgunction table.
224 This->lpvtbl = &VT_FileMonikerImpl;
225 return S_OK;
228 /******************************************************************************
229 * FileMoniker_Destroy
230 *******************************************************************************/
231 HRESULT WINAPI FileMonikerImpl_Destroy(FileMonikerImpl* This){
233 FIXME(ole,"(%p),stub!\n",This);
235 SEGPTR_FREE(This);
236 return S_OK;
239 /******************************************************************************
240 * FileMoniker_BindToObject
241 ******************************************************************************/
242 HRESULT WINAPI FileMonikerImpl_BindToObject(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft,
243 REFIID riid, VOID** ppvResult)
245 FileMonikerImpl* This=(FileMonikerImpl*)iface;
247 FIXME(ole,"(%p,%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,riid,ppvResult);
249 return E_NOTIMPL;
252 /******************************************************************************
253 * FileMoniker_BindToStorage
254 ******************************************************************************/
255 HRESULT WINAPI FileMonikerImpl_BindToStorage(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft,
256 REFIID riid, VOID** ppvResult)
258 FileMonikerImpl* This=(FileMonikerImpl*)iface;
260 FIXME(ole,"(%p,%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,riid,ppvResult);
262 return E_NOTIMPL;
265 /******************************************************************************
266 * FileMoniker_Reduce
267 ******************************************************************************/
268 HRESULT WINAPI FileMonikerImpl_Reduce(IMoniker* iface,IBindCtx* pbc, DWORD dwReduceHowFar,
269 IMoniker** ppmkToLeft, IMoniker** ppmkReduced)
271 FileMonikerImpl* This=(FileMonikerImpl*)iface;
273 FIXME(ole,"(%p,%p,%ld,%p,%p),stub!\n",This,pbc,dwReduceHowFar,ppmkToLeft,ppmkReduced);
275 return E_NOTIMPL;
278 /******************************************************************************
279 * FileMoniker_ComposeWith
280 ******************************************************************************/
281 HRESULT WINAPI FileMonikerImpl_ComposeWith(IMoniker* iface,IMoniker* pmkRight,BOOL fOnlyIfNotGeneric,
282 IMoniker** ppmkComposite)
284 FileMonikerImpl* This=(FileMonikerImpl*)iface;
286 FIXME(ole,"(%p,%p,%d,%p),stub!\n",This,pmkRight,fOnlyIfNotGeneric,ppmkComposite);
288 return E_NOTIMPL;
291 /******************************************************************************
292 * FileMoniker_Enum
293 ******************************************************************************/
294 HRESULT WINAPI FileMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker)
296 FileMonikerImpl* This=(FileMonikerImpl*)iface;
298 FIXME(ole,"(%p,%d,%p),stub!\n",This,fForward,ppenumMoniker);
300 return E_NOTIMPL;
304 /******************************************************************************
305 * FileMoniker_IsEqual
306 ******************************************************************************/
307 HRESULT WINAPI FileMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
309 FileMonikerImpl* This=(FileMonikerImpl*)iface;
311 FIXME(ole,"(%p,%p),stub!\n",This,pmkOtherMoniker);
313 return E_NOTIMPL;
316 /******************************************************************************
317 * FileMoniker_Hash
318 ******************************************************************************/
319 HRESULT WINAPI FileMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash)
321 FileMonikerImpl* This=(FileMonikerImpl*)iface;
323 FIXME(ole,"(%p,%p),stub!\n",This,pdwHash);
325 return E_NOTIMPL;
328 /******************************************************************************
329 * FileMoniker_IsRunning
330 ******************************************************************************/
331 HRESULT WINAPI FileMonikerImpl_IsRunning(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft,
332 IMoniker* pmkNewlyRunning)
334 FileMonikerImpl* This=(FileMonikerImpl*)iface;
336 FIXME(ole,"(%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,pmkNewlyRunning);
338 return E_NOTIMPL;
341 /******************************************************************************
342 * FileMoniker_GetTimeOfLastChange
343 ******************************************************************************/
344 HRESULT WINAPI FileMonikerImpl_GetTimeOfLastChange(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft,
345 FILETIME* pFileTime)
347 FileMonikerImpl* This=(FileMonikerImpl*)iface;
349 FIXME(ole,"(%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,pFileTime);
351 return E_NOTIMPL;
354 /******************************************************************************
355 * FileMoniker_Inverse
356 ******************************************************************************/
357 HRESULT WINAPI FileMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk)
359 FileMonikerImpl* This=(FileMonikerImpl*)iface;
361 FIXME(ole,"(%p,%p),stub!\n",This,ppmk);
363 return E_NOTIMPL;
366 /******************************************************************************
367 * FileMoniker_CommonPrefixWith
368 ******************************************************************************/
369 HRESULT WINAPI FileMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,
370 IMoniker** ppmkPrefix)
372 FileMonikerImpl* This=(FileMonikerImpl*)iface;
374 FIXME(ole,"(%p,%p,%p),stub!\n",This,pmkOther,ppmkPrefix);
376 return E_NOTIMPL;
379 /******************************************************************************
380 * FileMoniker_RelativePathTo
381 ******************************************************************************/
382 HRESULT WINAPI FileMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath)
384 FileMonikerImpl* This=(FileMonikerImpl*)iface;
386 FIXME(ole,"(%p,%p,%p),stub!\n",This,pmOther,ppmkRelPath);
388 return E_NOTIMPL;
391 /******************************************************************************
392 * FileMoniker_GetDisplayName
393 ******************************************************************************/
394 HRESULT WINAPI FileMonikerImpl_GetDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft,
395 LPOLESTR *ppszDisplayName)
397 FileMonikerImpl* This=(FileMonikerImpl*)iface;
399 FIXME(ole,"(%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,ppszDisplayName);
401 return E_NOTIMPL;
404 /******************************************************************************
405 * FileMoniker_ParseDisplayName
406 ******************************************************************************/
407 HRESULT WINAPI FileMonikerImpl_ParseDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft,
408 LPOLESTR pszDisplayName, ULONG* pchEaten, IMoniker** ppmkOut)
410 FileMonikerImpl* This=(FileMonikerImpl*)iface;
412 FIXME(ole,"(%p,%p,%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,pszDisplayName,pchEaten,ppmkOut);
414 return E_NOTIMPL;
417 /******************************************************************************
418 * FileMoniker_IsSystemMonker
419 ******************************************************************************/
420 HRESULT WINAPI FileMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys)
422 FileMonikerImpl* This=(FileMonikerImpl*)iface;
424 FIXME(ole,"(%p,%p),stub!\n",This,pwdMksys);
426 return E_NOTIMPL;
429 /******************************************************************************
430 * CreateFileMoniker16
431 ******************************************************************************/
432 HRESULT WINAPI CreateFileMoniker16(LPCOLESTR16 lpszPathName,LPMONIKER* ppmk){
434 FIXME(ole,"(%s,%p),stub!\n",lpszPathName,ppmk);
436 return E_NOTIMPL;
439 /******************************************************************************
440 * CreateFileMoniker32
441 ******************************************************************************/
442 HRESULT WINAPI CreateFileMoniker(LPCOLESTR lpszPathName, LPMONIKER * ppmk)
444 FileMonikerImpl* newFileMoniker = 0;
445 HRESULT hr = S_OK;
447 TRACE(ole,"(%p,%p)\n",lpszPathName,ppmk);
449 newFileMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(FileMonikerImpl));
451 if (newFileMoniker == 0)
452 return STG_E_INSUFFICIENTMEMORY;
454 hr = FileMonikerImpl_Construct(newFileMoniker,lpszPathName);
456 if (FAILED(hr))
457 return hr;
459 hr = FileMonikerImpl_QueryInterface((IMoniker*)newFileMoniker,&IID_IMoniker,(void**)ppmk);
461 return hr;