Wrong access on server handle was demanded (GENERIC_READ instead of
[wine/multimedia.git] / ole / itemmoniker.c
blobb44472fc2272dfc14623548d34f7c177a636a2cd
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 HRESULT WINAPI ItemMonikerImpl_QueryInterface(ItemMonikerImpl* This,REFIID riid,void** ppvObject);
27 ULONG WINAPI ItemMonikerImpl_AddRef(ItemMonikerImpl* This);
28 ULONG WINAPI ItemMonikerImpl_Release(ItemMonikerImpl* This);
29 HRESULT WINAPI ItemMonikerImpl_GetClassID(ItemMonikerImpl* This, CLSID *pClassID);
30 HRESULT WINAPI ItemMonikerImpl_IsDirty(ItemMonikerImpl* This);
31 HRESULT WINAPI ItemMonikerImpl_Load(ItemMonikerImpl* This,LPCOLESTR32 pszItemName,DWORD dwMode);
32 HRESULT WINAPI ItemMonikerImpl_Save(ItemMonikerImpl* This,LPCOLESTR32 pszItemName,BOOL32 fRemember);
33 HRESULT WINAPI ItemMonikerImpl_GetSizeMax(ItemMonikerImpl* This,LPOLESTR32 *ppszItemName);
34 HRESULT WINAPI ItemMonikerImpl_Construct(ItemMonikerImpl* This, LPCOLESTR32 lpszDelim,LPCOLESTR32 lpszItem);
35 HRESULT WINAPI ItemMonikerImpl_destroy(ItemMonikerImpl* This);
36 HRESULT WINAPI ItemMonikerImpl_BindToObject(ItemMonikerImpl* This,IBindCtx* pbc, IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult);
37 HRESULT WINAPI ItemMonikerImpl_BindToStorage(ItemMonikerImpl* This,IBindCtx* pbc, IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult);
38 HRESULT WINAPI ItemMonikerImpl_Reduce(ItemMonikerImpl* This,IBindCtx* pbc, DWORD dwReduceHowFar,IMoniker** ppmkToLeft, IMoniker** ppmkReduced);
39 HRESULT WINAPI ItemMonikerImpl_ComposeWith(ItemMonikerImpl* This,IMoniker* pmkRight,BOOL32 fOnlyIfNotGeneric, IMoniker** ppmkComposite);
40 HRESULT WINAPI ItemMonikerImpl_Enum(ItemMonikerImpl* This,BOOL32 fForward, IEnumMoniker** ppenumMoniker);
41 HRESULT WINAPI ItemMonikerImpl_IsEqual(ItemMonikerImpl* This,IMoniker* pmkOtherMoniker);
42 HRESULT WINAPI ItemMonikerImpl_Hash(ItemMonikerImpl* This,DWORD* pdwHash);
43 HRESULT WINAPI ItemMonikerImpl_IsRunning(ItemMonikerImpl* This,IBindCtx* pbc, IMoniker* pmkToLeft, IMoniker* pmkNewlyRunning);
44 HRESULT WINAPI ItemMonikerImpl_GetTimeOfLastChange(ItemMonikerImpl* This, IBindCtx* pbc, IMoniker* pmkToLeft, FILETIME* pItemTime);
45 HRESULT WINAPI ItemMonikerImpl_Inverse(ItemMonikerImpl* This,IMoniker** ppmk);
46 HRESULT WINAPI ItemMonikerImpl_CommonPrefixWith(ItemMonikerImpl* This,IMoniker* pmkOther, IMoniker** ppmkPrefix);
47 HRESULT WINAPI ItemMonikerImpl_RelativePathTo(ItemMonikerImpl* This,IMoniker* pmOther, IMoniker** ppmkRelPath);
48 HRESULT WINAPI ItemMonikerImpl_GetDisplayName(ItemMonikerImpl* This,IBindCtx* pbc, IMoniker* pmkToLeft, LPOLESTR32 *ppszDisplayName);
49 HRESULT WINAPI ItemMonikerImpl_ParseDisplayName(ItemMonikerImpl* This,IBindCtx* pbc, IMoniker* pmkToLeft, LPOLESTR32 pszDisplayName, ULONG* pchEaten, IMoniker** ppmkOut);
50 HRESULT WINAPI ItemMonikerImpl_IsSystemMoniker(ItemMonikerImpl* This,DWORD* pwdMksys);
51 HRESULT WINAPI CreateItemMoniker16(LPCOLESTR16 lpszDelim,LPCOLESTR32 lpszItem,LPMONIKER * ppmk);
52 HRESULT WINAPI CreateItemMoniker32(LPCOLESTR32 lpszDelim,LPCOLESTR32 lpszItem,LPMONIKER * ppmk);
54 #define VTABLE_FUNC(a) (void*)(a)
55 // Virtual function table for the ItemMonikerImpl class.
56 static ICOM_VTABLE(IMoniker) VT_ItemMonikerImpl =
61 VTABLE_FUNC(ItemMonikerImpl_QueryInterface),
62 VTABLE_FUNC(ItemMonikerImpl_AddRef),
63 VTABLE_FUNC(ItemMonikerImpl_Release)
65 VTABLE_FUNC(ItemMonikerImpl_GetClassID)
67 VTABLE_FUNC(ItemMonikerImpl_IsDirty),
68 VTABLE_FUNC(ItemMonikerImpl_Load),
69 VTABLE_FUNC(ItemMonikerImpl_Save),
70 VTABLE_FUNC(ItemMonikerImpl_GetSizeMax)
72 VTABLE_FUNC(ItemMonikerImpl_BindToObject),
73 VTABLE_FUNC(ItemMonikerImpl_BindToStorage),
74 VTABLE_FUNC(ItemMonikerImpl_Reduce),
75 VTABLE_FUNC(ItemMonikerImpl_ComposeWith),
76 VTABLE_FUNC(ItemMonikerImpl_Enum),
77 VTABLE_FUNC(ItemMonikerImpl_IsEqual),
78 VTABLE_FUNC(ItemMonikerImpl_Hash),
79 VTABLE_FUNC(ItemMonikerImpl_IsRunning),
80 VTABLE_FUNC(ItemMonikerImpl_GetTimeOfLastChange),
81 VTABLE_FUNC(ItemMonikerImpl_Inverse),
82 VTABLE_FUNC(ItemMonikerImpl_CommonPrefixWith),
83 VTABLE_FUNC(ItemMonikerImpl_RelativePathTo),
84 VTABLE_FUNC(ItemMonikerImpl_GetDisplayName),
85 VTABLE_FUNC(ItemMonikerImpl_ParseDisplayName),
86 VTABLE_FUNC(ItemMonikerImpl_IsSystemMoniker)
89 /*******************************************************************************
90 * ItemMoniker_QueryInterface
91 *******************************************************************************/
92 HRESULT WINAPI ItemMonikerImpl_QueryInterface(ItemMonikerImpl* This,REFIID riid,void** ppvObject){
94 TRACE(ole,"(%p,%p,%p)\n",This,riid,ppvObject);
96 // Perform a sanity check on the parameters.
97 if ( (This==0) || (ppvObject==0) ) return E_INVALIDARG;
99 // Initialize the return parameter.
100 *ppvObject = 0;
102 // Compare the riid with the interface IDs implemented by this object.
103 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
104 *ppvObject = (IMoniker*)This;
105 else
106 if (memcmp(&IID_IPersist, riid, sizeof(IID_IPersist)) == 0)
107 *ppvObject = (IMoniker*)This;
108 else
109 if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0)
110 *ppvObject = (IMoniker*)This;
111 else
112 if (memcmp(&IID_IMoniker, riid, sizeof(IID_IMoniker)) == 0)
113 *ppvObject = (IMoniker*)This;
115 // Check that we obtained an interface.
116 if ((*ppvObject)==0) return E_NOINTERFACE;
118 // Query Interface always increases the reference count by one when it is successful
119 ItemMonikerImpl_AddRef(This);
121 return S_OK;;
124 /******************************************************************************
125 * ItemMoniker_AddRef
126 ******************************************************************************/
127 ULONG WINAPI ItemMonikerImpl_AddRef(ItemMonikerImpl* This){
129 TRACE(ole,"(%p)\n",This);
131 return ++(This->ref);
134 /******************************************************************************
135 * ItemMoniker_Release
136 ******************************************************************************/
137 ULONG WINAPI ItemMonikerImpl_Release(ItemMonikerImpl* This){
139 TRACE(ole,"(%p),stub!\n",This);
141 This->ref--;
143 if (This->ref==0){
144 ItemMonikerImpl_destroy(This);
145 return 0;
148 return This->ref;;
151 /******************************************************************************
152 * ItemMoniker_GetClassID
153 ******************************************************************************/
154 HRESULT WINAPI ItemMonikerImpl_GetClassID(ItemMonikerImpl* This, CLSID *pClassID){//Pointer to CLSID of object
156 FIXME(ole,"(%p),stub!\n",pClassID);
157 return E_NOTIMPL;
160 /******************************************************************************
161 * ItemMoniker_IsDirty
162 ******************************************************************************/
163 HRESULT WINAPI ItemMonikerImpl_IsDirty(ItemMonikerImpl* This)
165 FIXME(ole,"(%p),stub!\n",This);
166 return E_NOTIMPL;
169 /******************************************************************************
170 * ItemMoniker_Load
171 ******************************************************************************/
172 HRESULT WINAPI ItemMonikerImpl_Load(
173 ItemMonikerImpl* This,
174 LPCOLESTR32 pszFileName,//Pointer to absolute path of the file to open
175 DWORD dwMode) //Specifies the access mode from the STGM enumeration
177 FIXME(ole,"(%p,%ld),stub!\n",pszFileName,dwMode);
178 return E_NOTIMPL;
181 /******************************************************************************
182 * ItemMoniker_save
183 ******************************************************************************/
184 HRESULT WINAPI ItemMonikerImpl_Save(
185 ItemMonikerImpl* This,
186 LPCOLESTR32 pszFileName, //Pointer to absolute path of the file where the object is saved
187 BOOL32 fRemember) //Specifies whether the file is to be the current working file or not
189 FIXME(ole,"(%p,%d),stub!\n",pszFileName,fRemember);
190 return E_NOTIMPL;
193 /******************************************************************************
194 * ItemMoniker_GetSizeMax
195 ******************************************************************************/
196 HRESULT WINAPI ItemMonikerImpl_GetSizeMax(
197 ItemMonikerImpl* This,
198 LPOLESTR32 *ppszFileName) //Pointer to the path for the current file or the default save prompt
200 FIXME(ole,"(%p),stub!\n",ppszFileName);
201 return E_NOTIMPL;
204 /******************************************************************************
205 * ItemMoniker_Constructor
206 *******************************************************************************/
207 HRESULT WINAPI ItemMonikerImpl_Construct(ItemMonikerImpl* This, LPCOLESTR32 lpszDelim,LPCOLESTR32 lpszItem){
209 FIXME(ole,"(%p,%p,%p),stub!\n",This,lpszDelim,lpszItem);
211 memset(This, 0, sizeof(ItemMonikerImpl));
213 //Initialize the virtual fgunction table.
214 This->lpvtbl = &VT_ItemMonikerImpl;
215 return S_OK;
218 /******************************************************************************
219 * ItemMoniker_destructor
220 *******************************************************************************/
221 HRESULT WINAPI ItemMonikerImpl_destroy(ItemMonikerImpl* This){
223 FIXME(ole,"(%p),stub!\n",This);
225 SEGPTR_FREE(This);
226 return S_OK;
229 /******************************************************************************
230 * ItemMoniker_BindToObject
231 ******************************************************************************/
232 HRESULT WINAPI ItemMonikerImpl_BindToObject(ItemMonikerImpl* This,IBindCtx* pbc, IMoniker* pmkToLeft,
233 REFIID riid, VOID** ppvResult){
235 FIXME(ole,"(%p,%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,riid,ppvResult);
236 return E_NOTIMPL;
239 /******************************************************************************
240 * ItemMoniker_BindToStorage
241 ******************************************************************************/
242 HRESULT WINAPI ItemMonikerImpl_BindToStorage(ItemMonikerImpl* This,IBindCtx* pbc, IMoniker* pmkToLeft,
243 REFIID riid, VOID** ppvResult){
245 FIXME(ole,"(%p,%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,riid,ppvResult);
246 return E_NOTIMPL;
249 /******************************************************************************
250 * ItemMoniker_Reduce
251 ******************************************************************************/
252 HRESULT WINAPI ItemMonikerImpl_Reduce(ItemMonikerImpl* This,IBindCtx* pbc, DWORD dwReduceHowFar,
253 IMoniker** ppmkToLeft, IMoniker** ppmkReduced){
255 FIXME(ole,"(%p,%p,%ld,%p,%p),stub!\n",This,pbc,dwReduceHowFar,ppmkToLeft,ppmkReduced);
256 return E_NOTIMPL;
259 /******************************************************************************
260 * ItemMoniker_ComposeWith
261 ******************************************************************************/
262 HRESULT WINAPI ItemMonikerImpl_ComposeWith(ItemMonikerImpl* This,IMoniker* pmkRight,BOOL32 fOnlyIfNotGeneric,
263 IMoniker** ppmkComposite){
265 FIXME(ole,"(%p,%p,%d,%p),stub!\n",This,pmkRight,fOnlyIfNotGeneric,ppmkComposite);
266 return E_NOTIMPL;
269 /******************************************************************************
270 * ItemMoniker_Enum
271 ******************************************************************************/
272 HRESULT WINAPI ItemMonikerImpl_Enum(ItemMonikerImpl* This,BOOL32 fForward, IEnumMoniker** ppenumMoniker){
274 FIXME(ole,"(%p,%d,%p),stub!\n",This,fForward,ppenumMoniker);
275 return E_NOTIMPL;
279 /******************************************************************************
280 * ItemMoniker_IsEqual
281 ******************************************************************************/
282 HRESULT WINAPI ItemMonikerImpl_IsEqual(ItemMonikerImpl* This,IMoniker* pmkOtherMoniker){
284 FIXME(ole,"(%p,%p),stub!\n",This,pmkOtherMoniker);
285 return E_NOTIMPL;
288 /******************************************************************************
289 * ItemMoniker_Hash
290 ******************************************************************************/
291 HRESULT WINAPI ItemMonikerImpl_Hash(ItemMonikerImpl* This,DWORD* pdwHash){
293 FIXME(ole,"(%p,%p),stub!\n",This,pdwHash);
294 return E_NOTIMPL;
297 /******************************************************************************
298 * ItemMoniker_IsRunning
299 ******************************************************************************/
300 HRESULT WINAPI ItemMonikerImpl_IsRunning(ItemMonikerImpl* This,IBindCtx* pbc, IMoniker* pmkToLeft,
301 IMoniker* pmkNewlyRunning){
303 FIXME(ole,"(%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,pmkNewlyRunning);
304 return E_NOTIMPL;
307 /******************************************************************************
308 * ItemMoniker_GetTimeOfLastChange
309 ******************************************************************************/
310 HRESULT WINAPI ItemMonikerImpl_GetTimeOfLastChange(ItemMonikerImpl* This, IBindCtx* pbc, IMoniker* pmkToLeft,
311 FILETIME* pFileTime){
313 FIXME(ole,"(%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,pFileTime);
314 return E_NOTIMPL;
317 /******************************************************************************
318 * ItemMoniker_Inverse
319 ******************************************************************************/
320 HRESULT WINAPI ItemMonikerImpl_Inverse(ItemMonikerImpl* This,IMoniker** ppmk){
322 FIXME(ole,"(%p,%p),stub!\n",This,ppmk);
323 return E_NOTIMPL;
326 /******************************************************************************
327 * ItemMoniker_CommonPrefixWith
328 ******************************************************************************/
329 HRESULT WINAPI ItemMonikerImpl_CommonPrefixWith(ItemMonikerImpl* This,IMoniker* pmkOther,
330 IMoniker** ppmkPrefix){
332 FIXME(ole,"(%p,%p,%p),stub!\n",This,pmkOther,ppmkPrefix);
333 return E_NOTIMPL;
336 /******************************************************************************
337 * ItemMoniker_RelativePathTo
338 ******************************************************************************/
339 HRESULT WINAPI ItemMonikerImpl_RelativePathTo(ItemMonikerImpl* This,IMoniker* pmOther, IMoniker** ppmkRelPath){
341 FIXME(ole,"(%p,%p,%p),stub!\n",This,pmOther,ppmkRelPath);
342 return E_NOTIMPL;
345 /******************************************************************************
346 * ItemMoniker_GetDisplayName
347 ******************************************************************************/
348 HRESULT WINAPI ItemMonikerImpl_GetDisplayName(ItemMonikerImpl* This,IBindCtx* pbc, IMoniker* pmkToLeft,
349 LPOLESTR32 *ppszDisplayName){
351 FIXME(ole,"(%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,ppszDisplayName);
352 return E_NOTIMPL;
355 /******************************************************************************
356 * ItemMoniker_ParseDisplayName
357 ******************************************************************************/
358 HRESULT WINAPI ItemMonikerImpl_ParseDisplayName(ItemMonikerImpl* This,IBindCtx* pbc, IMoniker* pmkToLeft,
359 LPOLESTR32 pszDisplayName, ULONG* pchEaten, IMoniker** ppmkOut){
361 FIXME(ole,"(%p,%p,%p,%p,%p,%p),stub!\n",This,pbc,pmkToLeft,pszDisplayName,pchEaten,ppmkOut);
362 return E_NOTIMPL;
365 /******************************************************************************
366 * ItemMoniker_IsSystemMonker
367 ******************************************************************************/
368 HRESULT WINAPI ItemMonikerImpl_IsSystemMoniker(ItemMonikerImpl* This,DWORD* pwdMksys){
370 FIXME(ole,"(%p,%p),stub!\n",This,pwdMksys);
371 return E_NOTIMPL;
374 /******************************************************************************
375 * CreateItemMoniker16 [OLE2.28]
376 ******************************************************************************/
377 HRESULT WINAPI CreateItemMoniker16(LPCOLESTR16 lpszDelim,LPCOLESTR32 lpszItem,LPMONIKER* ppmk){// [in] pathname [out] new moniker object
379 FIXME(ole,"(%s,%p),stub!\n",lpszDelim,ppmk);
380 *ppmk = NULL;
381 return E_NOTIMPL;
384 /******************************************************************************
385 * CreateItemMoniker32 [OLE32.55]
386 ******************************************************************************/
387 HRESULT WINAPI CreateItemMoniker32(LPCOLESTR32 lpszDelim,LPCOLESTR32 lpszItem, LPMONIKER * ppmk)
390 ItemMonikerImpl* newItemMoniker = 0;
391 HRESULT hr = S_OK;
393 TRACE(ole,"(%p,%p,%p)\n",lpszDelim,lpszItem,ppmk);
395 newItemMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(ItemMonikerImpl));
397 if (newItemMoniker == 0)
398 return STG_E_INSUFFICIENTMEMORY;
400 hr = ItemMonikerImpl_Construct(newItemMoniker,lpszDelim,lpszItem);
402 if (FAILED(hr))
403 return hr;
405 hr = ItemMonikerImpl_QueryInterface(newItemMoniker,&IID_IMoniker,(void**)ppmk);
407 return hr;