1 /***************************************************************************************
2 * FileMonikers implementation
4 * Copyright 1999 Noomen Hamza
5 ***************************************************************************************/
12 #include "wine/obj_base.h"
13 #include "wine/obj_storage.h"
14 #include "wine/obj_moniker.h"
18 typedef struct FileMonikerImpl
{
20 ICOM_VTABLE(IMoniker
)* lpvtbl
;
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
,
63 FileMonikerImpl_GetSizeMax
,
64 FileMonikerImpl_BindToObject
,
65 FileMonikerImpl_BindToStorage
,
66 FileMonikerImpl_Reduce
,
67 FileMonikerImpl_ComposeWith
,
69 FileMonikerImpl_IsEqual
,
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.
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
;
99 if (memcmp(&IID_IPersist
, riid
, sizeof(IID_IPersist
)) == 0)
100 *ppvObject
= (IMoniker
*)This
;
102 if (memcmp(&IID_IPersistStream
, riid
, sizeof(IID_IPersistStream
)) == 0)
103 *ppvObject
= (IMoniker
*)This
;
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
);
117 /******************************************************************************
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
);
141 FileMonikerImpl_Destroy(This
);
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
);
159 /******************************************************************************
160 * FileMoniker_IsDirty
161 ******************************************************************************/
162 HRESULT WINAPI
FileMonikerImpl_IsDirty(IMoniker
* iface
)
164 FileMonikerImpl
* This
=(FileMonikerImpl
*)iface
;
166 FIXME(ole
,"(%p),stub!\n",This
);
171 /******************************************************************************
173 ******************************************************************************/
174 HRESULT WINAPI
FileMonikerImpl_Load(
178 FileMonikerImpl
* This
=(FileMonikerImpl
*)iface
;
180 FIXME(ole
,"(%p,%p),stub!\n",This
,pStm
);
185 /******************************************************************************
187 ******************************************************************************/
188 HRESULT WINAPI
FileMonikerImpl_Save(
193 FileMonikerImpl
* This
=(FileMonikerImpl
*)iface
;
195 FIXME(ole
,"(%p,%p,%d),stub!\n",This
,pStm
,fClearDirty
);
200 /******************************************************************************
201 * FileMoniker_GetSizeMax
202 ******************************************************************************/
203 HRESULT WINAPI
FileMonikerImpl_GetSizeMax(
205 ULARGE_INTEGER
* pcbSize
)
207 FileMonikerImpl
* This
=(FileMonikerImpl
*)iface
;
209 FIXME(ole
,"(%p,%p),stub!\n",This
,pcbSize
);
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
;
228 /******************************************************************************
229 * FileMoniker_Destroy
230 *******************************************************************************/
231 HRESULT WINAPI
FileMonikerImpl_Destroy(FileMonikerImpl
* This
){
233 FIXME(ole
,"(%p),stub!\n",This
);
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
);
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
);
265 /******************************************************************************
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
);
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
);
291 /******************************************************************************
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
);
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
);
316 /******************************************************************************
318 ******************************************************************************/
319 HRESULT WINAPI
FileMonikerImpl_Hash(IMoniker
* iface
,DWORD
* pdwHash
)
321 FileMonikerImpl
* This
=(FileMonikerImpl
*)iface
;
323 FIXME(ole
,"(%p,%p),stub!\n",This
,pdwHash
);
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
);
341 /******************************************************************************
342 * FileMoniker_GetTimeOfLastChange
343 ******************************************************************************/
344 HRESULT WINAPI
FileMonikerImpl_GetTimeOfLastChange(IMoniker
* iface
, IBindCtx
* pbc
, IMoniker
* pmkToLeft
,
347 FileMonikerImpl
* This
=(FileMonikerImpl
*)iface
;
349 FIXME(ole
,"(%p,%p,%p,%p),stub!\n",This
,pbc
,pmkToLeft
,pFileTime
);
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
);
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
);
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
);
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
);
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
);
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
);
429 /******************************************************************************
430 * CreateFileMoniker16
431 ******************************************************************************/
432 HRESULT WINAPI
CreateFileMoniker16(LPCOLESTR16 lpszPathName
,LPMONIKER
* ppmk
){
434 FIXME(ole
,"(%s,%p),stub!\n",lpszPathName
,ppmk
);
439 /******************************************************************************
440 * CreateFileMoniker32
441 ******************************************************************************/
442 HRESULT WINAPI
CreateFileMoniker(LPCOLESTR lpszPathName
, LPMONIKER
* ppmk
)
444 FileMonikerImpl
* newFileMoniker
= 0;
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
);
459 hr
= FileMonikerImpl_QueryInterface((IMoniker
*)newFileMoniker
,&IID_IMoniker
,(void**)ppmk
);