Sync with trunk head.
[reactos.git] / dll / win32 / urlmon / uri.c
1 /*
2 * Copyright 2010 Jacek Caban for CodeWeavers
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19 #include "urlmon_main.h"
20 #include "wine/debug.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
23
24 typedef struct {
25 const IUriVtbl *lpIUriVtbl;
26 LONG ref;
27 } Uri;
28
29 typedef struct {
30 const IUriBuilderVtbl *lpIUriBuilderVtbl;
31 LONG ref;
32 } UriBuilder;
33
34 #define URI(x) ((IUri*) &(x)->lpIUriVtbl)
35 #define URIBUILDER(x) ((IUriBuilder*) &(x)->lpIUriBuilderVtbl)
36
37 #define URI_THIS(iface) DEFINE_THIS(Uri, IUri, iface)
38
39 static HRESULT WINAPI Uri_QueryInterface(IUri *iface, REFIID riid, void **ppv)
40 {
41 Uri *This = URI_THIS(iface);
42
43 if(IsEqualGUID(&IID_IUnknown, riid)) {
44 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
45 *ppv = URI(This);
46 }else if(IsEqualGUID(&IID_IUri, riid)) {
47 TRACE("(%p)->(IID_IUri %p)\n", This, ppv);
48 *ppv = URI(This);
49 }else {
50 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
51 *ppv = NULL;
52 return E_NOINTERFACE;
53 }
54
55 IUnknown_AddRef((IUnknown*)*ppv);
56 return S_OK;
57 }
58
59 static ULONG WINAPI Uri_AddRef(IUri *iface)
60 {
61 Uri *This = URI_THIS(iface);
62 LONG ref = InterlockedIncrement(&This->ref);
63
64 TRACE("(%p) ref=%d\n", This, ref);
65
66 return ref;
67 }
68
69 static ULONG WINAPI Uri_Release(IUri *iface)
70 {
71 Uri *This = URI_THIS(iface);
72 LONG ref = InterlockedDecrement(&This->ref);
73
74 TRACE("(%p) ref=%d\n", This, ref);
75
76 if(!ref)
77 heap_free(This);
78
79 return ref;
80 }
81
82 static HRESULT WINAPI Uri_GetPropertyBSTR(IUri *iface, Uri_PROPERTY uriProp, BSTR *pbstrProperty, DWORD dwFlags)
83 {
84 Uri *This = URI_THIS(iface);
85 FIXME("(%p)->(%d %p %x)\n", This, uriProp, pbstrProperty, dwFlags);
86 return E_NOTIMPL;
87 }
88
89 static HRESULT WINAPI Uri_GetPropertyLength(IUri *iface, Uri_PROPERTY uriProp, DWORD *pcchProperty, DWORD dwFlags)
90 {
91 Uri *This = URI_THIS(iface);
92 FIXME("(%p)->(%d %p %x)\n", This, uriProp, pcchProperty, dwFlags);
93 return E_NOTIMPL;
94 }
95
96 static HRESULT WINAPI Uri_GetPropertyDWORD(IUri *iface, Uri_PROPERTY uriProp, DWORD *pcchProperty, DWORD dwFlags)
97 {
98 Uri *This = URI_THIS(iface);
99 FIXME("(%p)->(%d %p %x)\n", This, uriProp, pcchProperty, dwFlags);
100 return E_NOTIMPL;
101 }
102
103 static HRESULT WINAPI Uri_HasProperty(IUri *iface, Uri_PROPERTY uriProp, BOOL *pfHasProperty)
104 {
105 Uri *This = URI_THIS(iface);
106 FIXME("(%p)->()\n", This);
107 return E_NOTIMPL;
108 }
109
110 static HRESULT WINAPI Uri_GetAbsoluteUri(IUri *iface, BSTR *pstrAbsoluteUri)
111 {
112 Uri *This = URI_THIS(iface);
113 FIXME("(%p)->(%p)\n", This, pstrAbsoluteUri);
114 return E_NOTIMPL;
115 }
116
117 static HRESULT WINAPI Uri_GetAuthority(IUri *iface, BSTR *pstrAuthority)
118 {
119 Uri *This = URI_THIS(iface);
120 FIXME("(%p)->(%p)\n", This, pstrAuthority);
121 return E_NOTIMPL;
122 }
123
124 static HRESULT WINAPI Uri_GetDisplayUri(IUri *iface, BSTR *pstrDisplayUri)
125 {
126 Uri *This = URI_THIS(iface);
127 FIXME("(%p)->(%p)\n", This, pstrDisplayUri);
128 return E_NOTIMPL;
129 }
130
131 static HRESULT WINAPI Uri_GetDomain(IUri *iface, BSTR *pstrDomain)
132 {
133 Uri *This = URI_THIS(iface);
134 FIXME("(%p)->(%p)\n", This, pstrDomain);
135 return E_NOTIMPL;
136 }
137
138 static HRESULT WINAPI Uri_GetExtension(IUri *iface, BSTR *pstrExtension)
139 {
140 Uri *This = URI_THIS(iface);
141 FIXME("(%p)->(%p)\n", This, pstrExtension);
142 return E_NOTIMPL;
143 }
144
145 static HRESULT WINAPI Uri_GetFragment(IUri *iface, BSTR *pstrFragment)
146 {
147 Uri *This = URI_THIS(iface);
148 FIXME("(%p)->(%p)\n", This, pstrFragment);
149 return E_NOTIMPL;
150 }
151
152 static HRESULT WINAPI Uri_GetHost(IUri *iface, BSTR *pstrHost)
153 {
154 Uri *This = URI_THIS(iface);
155 FIXME("(%p)->(%p)\n", This, pstrHost);
156 return E_NOTIMPL;
157 }
158
159 static HRESULT WINAPI Uri_GetPassword(IUri *iface, BSTR *pstrPassword)
160 {
161 Uri *This = URI_THIS(iface);
162 FIXME("(%p)->(%p)\n", This, pstrPassword);
163 return E_NOTIMPL;
164 }
165
166 static HRESULT WINAPI Uri_GetPath(IUri *iface, BSTR *pstrPath)
167 {
168 Uri *This = URI_THIS(iface);
169 FIXME("(%p)->(%p)\n", This, pstrPath);
170 return E_NOTIMPL;
171 }
172
173 static HRESULT WINAPI Uri_GetPathAndQuery(IUri *iface, BSTR *pstrPathAndQuery)
174 {
175 Uri *This = URI_THIS(iface);
176 FIXME("(%p)->(%p)\n", This, pstrPathAndQuery);
177 return E_NOTIMPL;
178 }
179
180 static HRESULT WINAPI Uri_GetQuery(IUri *iface, BSTR *pstrQuery)
181 {
182 Uri *This = URI_THIS(iface);
183 FIXME("(%p)->(%p)\n", This, pstrQuery);
184 return E_NOTIMPL;
185 }
186
187 static HRESULT WINAPI Uri_GetRawUri(IUri *iface, BSTR *pstrRawUri)
188 {
189 Uri *This = URI_THIS(iface);
190 FIXME("(%p)->(%p)\n", This, pstrRawUri);
191 return E_NOTIMPL;
192 }
193
194 static HRESULT WINAPI Uri_GetSchemeName(IUri *iface, BSTR *pstrSchemeName)
195 {
196 Uri *This = URI_THIS(iface);
197 FIXME("(%p)->(%p)\n", This, pstrSchemeName);
198 return E_NOTIMPL;
199 }
200
201 static HRESULT WINAPI Uri_GetUserInfo(IUri *iface, BSTR *pstrUserInfo)
202 {
203 Uri *This = URI_THIS(iface);
204 FIXME("(%p)->(%p)\n", This, pstrUserInfo);
205 return E_NOTIMPL;
206 }
207
208 static HRESULT WINAPI Uri_GetUserName(IUri *iface, BSTR *pstrUserName)
209 {
210 Uri *This = URI_THIS(iface);
211 FIXME("(%p)->(%p)\n", This, pstrUserName);
212 return E_NOTIMPL;
213 }
214
215 static HRESULT WINAPI Uri_GetHostType(IUri *iface, DWORD *pdwHostType)
216 {
217 Uri *This = URI_THIS(iface);
218 FIXME("(%p)->(%p)\n", This, pdwHostType);
219 return E_NOTIMPL;
220 }
221
222 static HRESULT WINAPI Uri_GetPort(IUri *iface, DWORD *pdwPort)
223 {
224 Uri *This = URI_THIS(iface);
225 FIXME("(%p)->(%p)\n", This, pdwPort);
226 return E_NOTIMPL;
227 }
228
229 static HRESULT WINAPI Uri_GetScheme(IUri *iface, DWORD *pdwScheme)
230 {
231 Uri *This = URI_THIS(iface);
232 FIXME("(%p)->(%p)\n", This, pdwScheme);
233 return E_NOTIMPL;
234 }
235
236 static HRESULT WINAPI Uri_GetZone(IUri *iface, DWORD *pdwZone)
237 {
238 Uri *This = URI_THIS(iface);
239 FIXME("(%p)->(%p)\n", This, pdwZone);
240 return E_NOTIMPL;
241 }
242
243 static HRESULT WINAPI Uri_GetProperties(IUri *iface, DWORD *pdwProperties)
244 {
245 Uri *This = URI_THIS(iface);
246 FIXME("(%p)->(%p)\n", This, pdwProperties);
247 return E_NOTIMPL;
248 }
249
250 static HRESULT WINAPI Uri_IsEqual(IUri *iface, IUri *pUri, BOOL *pfEqual)
251 {
252 Uri *This = URI_THIS(iface);
253 FIXME("(%p)->(%p %p)\n", This, pUri, pfEqual);
254 return E_NOTIMPL;
255 }
256
257 #undef URI_THIS
258
259 static const IUriVtbl UriVtbl = {
260 Uri_QueryInterface,
261 Uri_AddRef,
262 Uri_Release,
263 Uri_GetPropertyBSTR,
264 Uri_GetPropertyLength,
265 Uri_GetPropertyDWORD,
266 Uri_HasProperty,
267 Uri_GetAbsoluteUri,
268 Uri_GetAuthority,
269 Uri_GetDisplayUri,
270 Uri_GetDomain,
271 Uri_GetExtension,
272 Uri_GetFragment,
273 Uri_GetHost,
274 Uri_GetPassword,
275 Uri_GetPath,
276 Uri_GetPathAndQuery,
277 Uri_GetQuery,
278 Uri_GetRawUri,
279 Uri_GetSchemeName,
280 Uri_GetUserInfo,
281 Uri_GetUserName,
282 Uri_GetHostType,
283 Uri_GetPort,
284 Uri_GetScheme,
285 Uri_GetZone,
286 Uri_GetProperties,
287 Uri_IsEqual
288 };
289
290 /***********************************************************************
291 * CreateUri (urlmon.@)
292 */
293 HRESULT WINAPI CreateUri(LPCWSTR pwzURI, DWORD dwFlags, DWORD_PTR dwReserved, IUri **ppURI)
294 {
295 Uri *ret;
296
297 TRACE("(%s %x %x %p)\n", debugstr_w(pwzURI), dwFlags, (DWORD)dwReserved, ppURI);
298
299 ret = heap_alloc(sizeof(Uri));
300 if(!ret)
301 return E_OUTOFMEMORY;
302
303 ret->lpIUriVtbl = &UriVtbl;
304 ret->ref = 1;
305
306 *ppURI = URI(ret);
307 return S_OK;
308 }
309
310 #define URIBUILDER_THIS(iface) DEFINE_THIS(UriBuilder, IUriBuilder, iface)
311
312 static HRESULT WINAPI UriBuilder_QueryInterface(IUriBuilder *iface, REFIID riid, void **ppv)
313 {
314 UriBuilder *This = URIBUILDER_THIS(iface);
315
316 if(IsEqualGUID(&IID_IUnknown, riid)) {
317 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
318 *ppv = URIBUILDER(This);
319 }else if(IsEqualGUID(&IID_IUriBuilder, riid)) {
320 TRACE("(%p)->(IID_IUri %p)\n", This, ppv);
321 *ppv = URIBUILDER(This);
322 }else {
323 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
324 *ppv = NULL;
325 return E_NOINTERFACE;
326 }
327
328 IUnknown_AddRef((IUnknown*)*ppv);
329 return S_OK;
330 }
331
332 static ULONG WINAPI UriBuilder_AddRef(IUriBuilder *iface)
333 {
334 UriBuilder *This = URIBUILDER_THIS(iface);
335 LONG ref = InterlockedIncrement(&This->ref);
336
337 TRACE("(%p) ref=%d\n", This, ref);
338
339 return ref;
340 }
341
342 static ULONG WINAPI UriBuilder_Release(IUriBuilder *iface)
343 {
344 UriBuilder *This = URIBUILDER_THIS(iface);
345 LONG ref = InterlockedDecrement(&This->ref);
346
347 TRACE("(%p) ref=%d\n", This, ref);
348
349 if(!ref)
350 heap_free(This);
351
352 return ref;
353 }
354
355 static HRESULT WINAPI UriBuilder_CreateUriSimple(IUriBuilder *iface,
356 DWORD dwAllowEncodingPropertyMask,
357 DWORD_PTR dwReserved,
358 IUri **ppIUri)
359 {
360 UriBuilder *This = URIBUILDER_THIS(iface);
361 FIXME("(%p)->(%d %d %p)\n", This, dwAllowEncodingPropertyMask, (DWORD)dwReserved, ppIUri);
362 return E_NOTIMPL;
363 }
364
365 static HRESULT WINAPI UriBuilder_CreateUri(IUriBuilder *iface,
366 DWORD dwCreateFlags,
367 DWORD dwAllowEncodingPropertyMask,
368 DWORD_PTR dwReserved,
369 IUri **ppIUri)
370 {
371 UriBuilder *This = URIBUILDER_THIS(iface);
372 FIXME("(%p)->(0x%08x %d %d %p)\n", This, dwCreateFlags, dwAllowEncodingPropertyMask, (DWORD)dwReserved, ppIUri);
373 return E_NOTIMPL;
374 }
375
376 static HRESULT WINAPI UriBuilder_CreateUriWithFlags(IUriBuilder *iface,
377 DWORD dwCreateFlags,
378 DWORD dwUriBuilderFlags,
379 DWORD dwAllowEncodingPropertyMask,
380 DWORD_PTR dwReserved,
381 IUri **ppIUri)
382 {
383 UriBuilder *This = URIBUILDER_THIS(iface);
384 FIXME("(%p)->(0x%08x 0x%08x %d %d %p)\n", This, dwCreateFlags, dwUriBuilderFlags,
385 dwAllowEncodingPropertyMask, (DWORD)dwReserved, ppIUri);
386 return E_NOTIMPL;
387 }
388
389 static HRESULT WINAPI UriBuilder_GetIUri(IUriBuilder *iface, IUri **ppIUri)
390 {
391 UriBuilder *This = URIBUILDER_THIS(iface);
392 FIXME("(%p)->(%p)\n", This, ppIUri);
393 return E_NOTIMPL;
394 }
395
396 static HRESULT WINAPI UriBuilder_SetIUri(IUriBuilder *iface, IUri *pIUri)
397 {
398 UriBuilder *This = URIBUILDER_THIS(iface);
399 FIXME("(%p)->(%p)\n", This, pIUri);
400 return E_NOTIMPL;
401 }
402
403 static HRESULT WINAPI UriBuilder_GetFragment(IUriBuilder *iface, DWORD *pcchFragment, LPCWSTR *ppwzFragment)
404 {
405 UriBuilder *This = URIBUILDER_THIS(iface);
406 FIXME("(%p)->(%p %p)\n", This, pcchFragment, ppwzFragment);
407 return E_NOTIMPL;
408 }
409
410 static HRESULT WINAPI UriBuilder_GetHost(IUriBuilder *iface, DWORD *pcchHost, LPCWSTR *ppwzHost)
411 {
412 UriBuilder *This = URIBUILDER_THIS(iface);
413 FIXME("(%p)->(%p %p)\n", This, pcchHost, ppwzHost);
414 return E_NOTIMPL;
415 }
416
417 static HRESULT WINAPI UriBuilder_GetPassword(IUriBuilder *iface, DWORD *pcchPassword, LPCWSTR *ppwzPassword)
418 {
419 UriBuilder *This = URIBUILDER_THIS(iface);
420 FIXME("(%p)->(%p %p)\n", This, pcchPassword, ppwzPassword);
421 return E_NOTIMPL;
422 }
423
424 static HRESULT WINAPI UriBuilder_GetPath(IUriBuilder *iface, DWORD *pcchPath, LPCWSTR *ppwzPath)
425 {
426 UriBuilder *This = URIBUILDER_THIS(iface);
427 FIXME("(%p)->(%p %p)\n", This, pcchPath, ppwzPath);
428 return E_NOTIMPL;
429 }
430
431 static HRESULT WINAPI UriBuilder_GetPort(IUriBuilder *iface, BOOL *pfHasPort, DWORD *pdwPort)
432 {
433 UriBuilder *This = URIBUILDER_THIS(iface);
434 FIXME("(%p)->(%p %p)\n", This, pfHasPort, pdwPort);
435 return E_NOTIMPL;
436 }
437
438 static HRESULT WINAPI UriBuilder_GetQuery(IUriBuilder *iface, DWORD *pcchQuery, LPCWSTR *ppwzQuery)
439 {
440 UriBuilder *This = URIBUILDER_THIS(iface);
441 FIXME("(%p)->(%p %p)\n", This, pcchQuery, ppwzQuery);
442 return E_NOTIMPL;
443 }
444
445 static HRESULT WINAPI UriBuilder_GetSchemeName(IUriBuilder *iface, DWORD *pcchSchemeName, LPCWSTR *ppwzSchemeName)
446 {
447 UriBuilder *This = URIBUILDER_THIS(iface);
448 FIXME("(%p)->(%p %p)\n", This, pcchSchemeName, ppwzSchemeName);
449 return E_NOTIMPL;
450 }
451
452 static HRESULT WINAPI UriBuilder_GetUserName(IUriBuilder *iface, DWORD *pcchUserName, LPCWSTR *ppwzUserName)
453 {
454 UriBuilder *This = URIBUILDER_THIS(iface);
455 FIXME("(%p)->(%p %p)\n", This, pcchUserName, ppwzUserName);
456 return E_NOTIMPL;
457 }
458
459 static HRESULT WINAPI UriBuilder_SetFragment(IUriBuilder *iface, LPCWSTR pwzNewValue)
460 {
461 UriBuilder *This = URIBUILDER_THIS(iface);
462 FIXME("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
463 return E_NOTIMPL;
464 }
465
466 static HRESULT WINAPI UriBuilder_SetHost(IUriBuilder *iface, LPCWSTR pwzNewValue)
467 {
468 UriBuilder *This = URIBUILDER_THIS(iface);
469 FIXME("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
470 return E_NOTIMPL;
471 }
472
473 static HRESULT WINAPI UriBuilder_SetPassword(IUriBuilder *iface, LPCWSTR pwzNewValue)
474 {
475 UriBuilder *This = URIBUILDER_THIS(iface);
476 FIXME("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
477 return E_NOTIMPL;
478 }
479
480 static HRESULT WINAPI UriBuilder_SetPath(IUriBuilder *iface, LPCWSTR pwzNewValue)
481 {
482 UriBuilder *This = URIBUILDER_THIS(iface);
483 FIXME("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
484 return E_NOTIMPL;
485 }
486
487 static HRESULT WINAPI UriBuilder_SetPort(IUriBuilder *iface, BOOL fHasPort, DWORD dwNewValue)
488 {
489 UriBuilder *This = URIBUILDER_THIS(iface);
490 FIXME("(%p)->(%d %d)\n", This, fHasPort, dwNewValue);
491 return E_NOTIMPL;
492 }
493
494 static HRESULT WINAPI UriBuilder_SetQuery(IUriBuilder *iface, LPCWSTR pwzNewValue)
495 {
496 UriBuilder *This = URIBUILDER_THIS(iface);
497 FIXME("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
498 return E_NOTIMPL;
499 }
500
501 static HRESULT WINAPI UriBuilder_SetSchemeName(IUriBuilder *iface, LPCWSTR pwzNewValue)
502 {
503 UriBuilder *This = URIBUILDER_THIS(iface);
504 FIXME("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
505 return E_NOTIMPL;
506 }
507
508 static HRESULT WINAPI UriBuilder_SetUserName(IUriBuilder *iface, LPCWSTR pwzNewValue)
509 {
510 UriBuilder *This = URIBUILDER_THIS(iface);
511 FIXME("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
512 return E_NOTIMPL;
513 }
514
515 static HRESULT WINAPI UriBuilder_RemoveProperties(IUriBuilder *iface, DWORD dwPropertyMask)
516 {
517 UriBuilder *This = URIBUILDER_THIS(iface);
518 FIXME("(%p)->(0x%08x)\n", This, dwPropertyMask);
519 return E_NOTIMPL;
520 }
521
522 static HRESULT WINAPI UriBuilder_HasBeenModified(IUriBuilder *iface, BOOL *pfModified)
523 {
524 UriBuilder *This = URIBUILDER_THIS(iface);
525 FIXME("(%p)->(%p)\n", This, pfModified);
526 return E_NOTIMPL;
527 }
528
529 #undef URIBUILDER_THIS
530
531 static const IUriBuilderVtbl UriBuilderVtbl = {
532 UriBuilder_QueryInterface,
533 UriBuilder_AddRef,
534 UriBuilder_Release,
535 UriBuilder_CreateUriSimple,
536 UriBuilder_CreateUri,
537 UriBuilder_CreateUriWithFlags,
538 UriBuilder_GetIUri,
539 UriBuilder_SetIUri,
540 UriBuilder_GetFragment,
541 UriBuilder_GetHost,
542 UriBuilder_GetPassword,
543 UriBuilder_GetPath,
544 UriBuilder_GetPort,
545 UriBuilder_GetQuery,
546 UriBuilder_GetSchemeName,
547 UriBuilder_GetUserName,
548 UriBuilder_SetFragment,
549 UriBuilder_SetHost,
550 UriBuilder_SetPassword,
551 UriBuilder_SetPath,
552 UriBuilder_SetPort,
553 UriBuilder_SetQuery,
554 UriBuilder_SetSchemeName,
555 UriBuilder_SetUserName,
556 UriBuilder_RemoveProperties,
557 UriBuilder_HasBeenModified,
558 };
559
560 /***********************************************************************
561 * CreateIUriBuilder (urlmon.@)
562 */
563 HRESULT WINAPI CreateIUriBuilder(IUri *pIUri, DWORD dwFlags, DWORD_PTR dwReserved, IUriBuilder **ppIUriBuilder)
564 {
565 UriBuilder *ret;
566
567 TRACE("(%p %x %x %p)\n", pIUri, dwFlags, (DWORD)dwReserved, ppIUriBuilder);
568
569 ret = heap_alloc(sizeof(UriBuilder));
570 if(!ret)
571 return E_OUTOFMEMORY;
572
573 ret->lpIUriBuilderVtbl = &UriBuilderVtbl;
574 ret->ref = 1;
575
576 *ppIUriBuilder = URIBUILDER(ret);
577 return S_OK;
578 }