Faster serial speed cases for non Linux systems.
[wine] / dlls / urlmon / moniker.c
1 /*
2  * URL Moniker
3  *
4  * FIXME - stub
5  *
6  * Copyright (C) 2002 Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  *
22  */
23
24 #include "config.h"
25
26 #include "windef.h"
27 #include "winerror.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "winuser.h"
31 #include "ole2.h"
32 #include "urlmon.h"
33
34 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(comimpl);
36
37 #include "comimpl.h"
38
39
40 /*
41  * NOTE:
42  *      URL Moniker supports the following protocols(at least):
43  *
44  * CLSID_HttpProtocol
45  * CLSID_FtpProtocol
46  * CLSID_GopherProtocol
47  * CLSID_HttpSProtocol
48  * CLSID_FileProtocol
49  *
50  */
51
52 typedef struct CURLMonikerImpl
53 {
54         COMIMPL_IUnkImpl vfunk;
55         struct { ICOM_VFIELD(IMoniker); } moniker;
56         struct { ICOM_VFIELD(IROTData); } rotd;
57
58         /* IMoniker stuffs */
59 } CURLMonikerImpl;
60
61 #define CURLMonikerImpl_THIS(iface,member) CURLMonikerImpl* This = ((CURLMonikerImpl*)(((char*)iface)-offsetof(CURLMonikerImpl,member)))
62
63
64 static HRESULT WINAPI
65 IMoniker_fnQueryInterface(IMoniker* iface,REFIID riid,void** ppobj)
66 {
67         CURLMonikerImpl_THIS(iface,moniker);
68
69         TRACE("(%p)->()\n",This);
70
71         return IUnknown_QueryInterface(This->vfunk.punkControl,riid,ppobj);
72 }
73
74 static ULONG WINAPI
75 IMoniker_fnAddRef(IMoniker* iface)
76 {
77         CURLMonikerImpl_THIS(iface,moniker);
78
79         TRACE("(%p)->()\n",This);
80
81         return IUnknown_AddRef(This->vfunk.punkControl);
82 }
83
84 static ULONG WINAPI
85 IMoniker_fnRelease(IMoniker* iface)
86 {
87         CURLMonikerImpl_THIS(iface,moniker);
88
89         TRACE("(%p)->()\n",This);
90
91         return IUnknown_Release(This->vfunk.punkControl);
92 }
93
94 static HRESULT WINAPI IMoniker_fnGetClassID(IMoniker* iface, CLSID *pClassID)
95 {
96         CURLMonikerImpl_THIS(iface,moniker);
97
98         FIXME("(%p)->() stub\n",This);
99
100         return E_NOTIMPL;
101 #if 0
102         TRACE("(%p)->()\n",This);
103
104         if ( pClassID == NULL )
105                 return E_POINTER;
106         memcpy( pClassID, &CLSID_StdURLMoniker, sizeof(CLSID) );
107
108         return NOERROR;
109 #endif
110 }
111
112 static HRESULT WINAPI IMoniker_fnIsDirty(IMoniker* iface)
113 {
114         CURLMonikerImpl_THIS(iface,moniker);
115
116         FIXME("(%p)->() stub!\n",This);
117
118         return E_NOTIMPL;
119 }
120
121 static HRESULT WINAPI IMoniker_fnLoad(IMoniker* iface, IStream* pStm)
122 {
123         CURLMonikerImpl_THIS(iface,moniker);
124
125         FIXME("(%p)->() stub!\n",This);
126
127         return E_NOTIMPL;
128 }
129
130 static HRESULT WINAPI IMoniker_fnSave(IMoniker* iface, IStream* pStm, BOOL fClearDirty)
131 {
132         CURLMonikerImpl_THIS(iface,moniker);
133
134         FIXME("(%p)->() stub!\n",This);
135
136         return E_NOTIMPL;
137 }
138
139 static HRESULT WINAPI IMoniker_fnGetSizeMax(IMoniker* iface, ULARGE_INTEGER* pcbSize)
140 {
141         CURLMonikerImpl_THIS(iface,moniker);
142
143         FIXME("(%p)->() stub!\n",This);
144
145         return E_NOTIMPL;
146 }
147
148 static HRESULT WINAPI IMoniker_fnBindToObject(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult)
149 {
150         CURLMonikerImpl_THIS(iface,moniker);
151
152         FIXME("(%p)->(%p,%p,%s,%p)\n",This,
153                 pbc,pmkToLeft,debugstr_guid(riid),ppvResult);
154
155         return E_NOTIMPL;
156 }
157
158 static HRESULT WINAPI IMoniker_fnBindToStorage(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, REFIID riid, VOID** ppvResult)
159 {
160         CURLMonikerImpl_THIS(iface,moniker);
161
162         FIXME("(%p)->(%p,%p,%s,%p)\n",This,
163                 pbc,pmkToLeft,debugstr_guid(riid),ppvResult);
164
165         return E_NOTIMPL;
166 }
167
168 static HRESULT WINAPI IMoniker_fnReduce(IMoniker* iface,IBindCtx* pbc, DWORD dwReduceHowFar,IMoniker** ppmkToLeft, IMoniker** ppmkReduced)
169 {
170         CURLMonikerImpl_THIS(iface,moniker);
171
172         FIXME("(%p)->() stub!\n",This);
173
174         return E_NOTIMPL;
175 }
176
177 static HRESULT WINAPI IMoniker_fnComposeWith(IMoniker* iface,IMoniker* pmkRight,BOOL fOnlyIfNotGeneric, IMoniker** ppmkComposite)
178 {
179         CURLMonikerImpl_THIS(iface,moniker);
180
181         FIXME("(%p)->() stub!\n",This);
182
183         return E_NOTIMPL;
184 }
185
186 static HRESULT WINAPI IMoniker_fnEnum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker)
187 {
188         CURLMonikerImpl_THIS(iface,moniker);
189
190         FIXME("(%p)->() stub!\n",This);
191
192         return E_NOTIMPL;
193 }
194
195 static HRESULT WINAPI IMoniker_fnIsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
196 {
197         CURLMonikerImpl_THIS(iface,moniker);
198
199         FIXME("(%p)->() stub!\n",This);
200
201         return E_NOTIMPL;
202 }
203
204 static HRESULT WINAPI IMoniker_fnHash(IMoniker* iface,DWORD* pdwHash)
205 {
206         CURLMonikerImpl_THIS(iface,moniker);
207
208         FIXME("(%p)->() stub!\n",This);
209
210         return E_NOTIMPL;
211 }
212
213 static HRESULT WINAPI IMoniker_fnIsRunning(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, IMoniker* pmkNewlyRunning)
214 {
215         CURLMonikerImpl_THIS(iface,moniker);
216
217         FIXME("(%p)->() stub!\n",This);
218
219         return E_NOTIMPL;
220 }
221
222 static HRESULT WINAPI IMoniker_fnGetTimeOfLastChange(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft, FILETIME* pCompositeTime)
223 {
224         CURLMonikerImpl_THIS(iface,moniker);
225
226         FIXME("(%p)->() stub!\n",This);
227
228         return E_NOTIMPL;
229 }
230
231 static HRESULT WINAPI IMoniker_fnInverse(IMoniker* iface,IMoniker** ppmk)
232 {
233         CURLMonikerImpl_THIS(iface,moniker);
234
235         FIXME("(%p)->() stub!\n",This);
236
237         return E_NOTIMPL;
238 }
239
240 static HRESULT WINAPI IMoniker_fnCommonPrefixWith(IMoniker* iface,IMoniker* pmkOther, IMoniker** ppmkPrefix)
241 {
242         CURLMonikerImpl_THIS(iface,moniker);
243
244         FIXME("(%p)->() stub!\n",This);
245
246         return E_NOTIMPL;
247 }
248
249 static HRESULT WINAPI IMoniker_fnRelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath)
250 {
251         CURLMonikerImpl_THIS(iface,moniker);
252
253         FIXME("(%p)->() stub!\n",This);
254
255         return E_NOTIMPL;
256 }
257
258 static HRESULT WINAPI IMoniker_fnGetDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, LPOLESTR *ppszDisplayName)
259 {
260         CURLMonikerImpl_THIS(iface,moniker);
261
262         FIXME("(%p)->() stub!\n",This);
263
264         return E_NOTIMPL;
265 }
266
267 static HRESULT WINAPI IMoniker_fnParseDisplayName(IMoniker* iface,IBindCtx* pbc, IMoniker* pmkToLeft, LPOLESTR pszDisplayName, ULONG* pchEaten, IMoniker** ppmkOut)
268 {
269         CURLMonikerImpl_THIS(iface,moniker);
270
271         FIXME("(%p)->() stub!\n",This);
272
273         return E_NOTIMPL;
274 }
275
276 static HRESULT WINAPI IMoniker_fnIsSystemMoniker(IMoniker* iface,DWORD* pdwMksys)
277 {
278         CURLMonikerImpl_THIS(iface,moniker);
279
280         FIXME("(%p)->() stub!\n",This);
281
282         return E_NOTIMPL;
283 }
284
285
286 static ICOM_VTABLE(IMoniker) imoniker =
287 {
288         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
289         /* IUnknown fields */
290         IMoniker_fnQueryInterface,
291         IMoniker_fnAddRef,
292         IMoniker_fnRelease,
293         /* IPersist fields */
294         IMoniker_fnGetClassID,
295         /* IPersistStream fields */
296         IMoniker_fnIsDirty,
297         IMoniker_fnLoad,
298         IMoniker_fnSave,
299         IMoniker_fnGetSizeMax,
300         /* IMoniker fields */
301         IMoniker_fnBindToObject,
302         IMoniker_fnBindToStorage,
303         IMoniker_fnReduce,
304         IMoniker_fnComposeWith,
305         IMoniker_fnEnum,
306         IMoniker_fnIsEqual,
307         IMoniker_fnHash,
308         IMoniker_fnIsRunning,
309         IMoniker_fnGetTimeOfLastChange,
310         IMoniker_fnInverse,
311         IMoniker_fnCommonPrefixWith,
312         IMoniker_fnRelativePathTo,
313         IMoniker_fnGetDisplayName,
314         IMoniker_fnParseDisplayName,
315         IMoniker_fnIsSystemMoniker,
316 };
317
318
319
320
321 static HRESULT WINAPI
322 IROTData_fnQueryInterface(IROTData* iface,REFIID riid,void** ppobj)
323 {
324         CURLMonikerImpl_THIS(iface,rotd);
325
326         TRACE("(%p)->()\n",This);
327
328         return IUnknown_QueryInterface(This->vfunk.punkControl,riid,ppobj);
329 }
330
331 static ULONG WINAPI
332 IROTData_fnAddRef(IROTData* iface)
333 {
334         CURLMonikerImpl_THIS(iface,rotd);
335
336         TRACE("(%p)->()\n",This);
337
338         return IUnknown_AddRef(This->vfunk.punkControl);
339 }
340
341 static ULONG WINAPI
342 IROTData_fnRelease(IROTData* iface)
343 {
344         CURLMonikerImpl_THIS(iface,rotd);
345
346         TRACE("(%p)->()\n",This);
347
348         return IUnknown_Release(This->vfunk.punkControl);
349 }
350
351 static HRESULT WINAPI IROTData_fnGetComparisonData(IROTData* iface,BYTE* pbData,ULONG cbMax,ULONG* pcbData)
352 {
353         CURLMonikerImpl_THIS(iface,rotd);
354
355         FIXME("(%p)->() stub!\n",This);
356
357         return E_NOTIMPL;
358 }
359
360
361
362 static ICOM_VTABLE(IROTData) irotdata =
363 {
364         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
365         /* IUnknown fields */
366         IROTData_fnQueryInterface,
367         IROTData_fnAddRef,
368         IROTData_fnRelease,
369         /* IROTData fields */
370         IROTData_fnGetComparisonData,
371 };
372
373
374
375 static COMIMPL_IFEntry IFEntries[] =
376 {
377         { &IID_IPersist, offsetof(CURLMonikerImpl,moniker)-offsetof(CURLMonikerImpl,vfunk) },
378         { &IID_IPersistStream, offsetof(CURLMonikerImpl,moniker)-offsetof(CURLMonikerImpl,vfunk) },
379         { &IID_IMoniker, offsetof(CURLMonikerImpl,moniker)-offsetof(CURLMonikerImpl,vfunk) },
380         { &IID_IROTData, offsetof(CURLMonikerImpl,rotd)-offsetof(CURLMonikerImpl,vfunk) },
381 };
382
383 static void CURLMonikerImpl_Destructor(IUnknown* iface)
384 {
385         CURLMonikerImpl_THIS(iface,vfunk);
386
387         TRACE("(%p)\n",This);
388 }
389
390 static HRESULT CURLMonikerImpl_AllocObj(
391         void** ppobj,
392         IMoniker* pmonContext,
393         LPCWSTR lpwszURL )
394 {
395         CURLMonikerImpl* This;
396
397         This = (CURLMonikerImpl*)COMIMPL_AllocObj( sizeof(CURLMonikerImpl) );
398         if ( This == NULL ) return E_OUTOFMEMORY;
399         COMIMPL_IUnkInit( &This->vfunk, NULL );
400         This->vfunk.pEntries = IFEntries;
401         This->vfunk.dwEntries = sizeof(IFEntries)/sizeof(IFEntries[0]);
402         This->vfunk.pOnFinalRelease = CURLMonikerImpl_Destructor;
403
404         ICOM_VTBL(&This->moniker) = &imoniker;
405         ICOM_VTBL(&This->rotd) = &irotdata;
406
407         *ppobj = (void*)(&This->vfunk);
408
409         return S_OK;
410 }
411
412
413 /***********************************************************************
414  *
415  *      CreateURLMoniker (URLMON.@)
416  *
417  *      S_OK           success
418  *      E_OUTOFMEMORY  out of memory
419  *      MK_E_SYNTAX    not a valid url
420  *
421  */
422
423 HRESULT WINAPI CreateURLMoniker(
424         IMoniker* pmonContext,
425         LPCWSTR lpwszURL,
426         IMoniker** ppmon )
427 {
428         HRESULT hr;
429         IUnknown* punk = NULL;
430
431         FIXME("(%p,%s,%p)\n",pmonContext,debugstr_w(lpwszURL),ppmon);
432
433         if ( ppmon == NULL )
434                 return E_POINTER;
435         *ppmon = NULL;
436
437         hr = CURLMonikerImpl_AllocObj( (void**)&punk, pmonContext, lpwszURL );
438         if ( FAILED(hr) )
439                 return hr;
440
441         hr = IUnknown_QueryInterface( punk, &IID_IMoniker, (void**)ppmon );
442         IUnknown_Release( punk );
443
444         return hr;
445 }
446