2 * Copyright 2010 Jacek Caban for CodeWeavers
3 * Copyright 2010 Thomas Mullaly
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "urlmon_main.h"
21 #include "wine/debug.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(urlmon
);
26 const IUriVtbl
*lpIUriVtbl
;
31 const IUriBuilderVtbl
*lpIUriBuilderVtbl
;
35 #define URI(x) ((IUri*) &(x)->lpIUriVtbl)
36 #define URIBUILDER(x) ((IUriBuilder*) &(x)->lpIUriBuilderVtbl)
38 #define URI_THIS(iface) DEFINE_THIS(Uri, IUri, iface)
40 static HRESULT WINAPI
Uri_QueryInterface(IUri
*iface
, REFIID riid
, void **ppv
)
42 Uri
*This
= URI_THIS(iface
);
44 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
45 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
47 }else if(IsEqualGUID(&IID_IUri
, riid
)) {
48 TRACE("(%p)->(IID_IUri %p)\n", This
, ppv
);
51 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
56 IUnknown_AddRef((IUnknown
*)*ppv
);
60 static ULONG WINAPI
Uri_AddRef(IUri
*iface
)
62 Uri
*This
= URI_THIS(iface
);
63 LONG ref
= InterlockedIncrement(&This
->ref
);
65 TRACE("(%p) ref=%d\n", This
, ref
);
70 static ULONG WINAPI
Uri_Release(IUri
*iface
)
72 Uri
*This
= URI_THIS(iface
);
73 LONG ref
= InterlockedDecrement(&This
->ref
);
75 TRACE("(%p) ref=%d\n", This
, ref
);
83 static HRESULT WINAPI
Uri_GetPropertyBSTR(IUri
*iface
, Uri_PROPERTY uriProp
, BSTR
*pbstrProperty
, DWORD dwFlags
)
85 Uri
*This
= URI_THIS(iface
);
86 FIXME("(%p)->(%d %p %x)\n", This
, uriProp
, pbstrProperty
, dwFlags
);
90 static HRESULT WINAPI
Uri_GetPropertyLength(IUri
*iface
, Uri_PROPERTY uriProp
, DWORD
*pcchProperty
, DWORD dwFlags
)
92 Uri
*This
= URI_THIS(iface
);
93 FIXME("(%p)->(%d %p %x)\n", This
, uriProp
, pcchProperty
, dwFlags
);
97 static HRESULT WINAPI
Uri_GetPropertyDWORD(IUri
*iface
, Uri_PROPERTY uriProp
, DWORD
*pcchProperty
, DWORD dwFlags
)
99 Uri
*This
= URI_THIS(iface
);
100 FIXME("(%p)->(%d %p %x)\n", This
, uriProp
, pcchProperty
, dwFlags
);
105 /* Microsoft's implementation for the ZONE property of a URI seems to be lacking...
106 * From what I can tell, instead of checking which URLZONE the URI belongs to it
107 * simply assigns URLZONE_INVALID and returns E_NOTIMPL. This also applies to the GetZone
110 if(uriProp
== Uri_PROPERTY_ZONE
) {
111 *pcchProperty
= URLZONE_INVALID
;
118 static HRESULT WINAPI
Uri_HasProperty(IUri
*iface
, Uri_PROPERTY uriProp
, BOOL
*pfHasProperty
)
120 Uri
*This
= URI_THIS(iface
);
121 FIXME("(%p)->()\n", This
);
125 static HRESULT WINAPI
Uri_GetAbsoluteUri(IUri
*iface
, BSTR
*pstrAbsoluteUri
)
127 Uri
*This
= URI_THIS(iface
);
128 FIXME("(%p)->(%p)\n", This
, pstrAbsoluteUri
);
136 static HRESULT WINAPI
Uri_GetAuthority(IUri
*iface
, BSTR
*pstrAuthority
)
138 Uri
*This
= URI_THIS(iface
);
139 FIXME("(%p)->(%p)\n", This
, pstrAuthority
);
147 static HRESULT WINAPI
Uri_GetDisplayUri(IUri
*iface
, BSTR
*pstrDisplayUri
)
149 Uri
*This
= URI_THIS(iface
);
150 FIXME("(%p)->(%p)\n", This
, pstrDisplayUri
);
158 static HRESULT WINAPI
Uri_GetDomain(IUri
*iface
, BSTR
*pstrDomain
)
160 Uri
*This
= URI_THIS(iface
);
161 FIXME("(%p)->(%p)\n", This
, pstrDomain
);
169 static HRESULT WINAPI
Uri_GetExtension(IUri
*iface
, BSTR
*pstrExtension
)
171 Uri
*This
= URI_THIS(iface
);
172 FIXME("(%p)->(%p)\n", This
, pstrExtension
);
180 static HRESULT WINAPI
Uri_GetFragment(IUri
*iface
, BSTR
*pstrFragment
)
182 Uri
*This
= URI_THIS(iface
);
183 FIXME("(%p)->(%p)\n", This
, pstrFragment
);
191 static HRESULT WINAPI
Uri_GetHost(IUri
*iface
, BSTR
*pstrHost
)
193 Uri
*This
= URI_THIS(iface
);
194 FIXME("(%p)->(%p)\n", This
, pstrHost
);
198 static HRESULT WINAPI
Uri_GetPassword(IUri
*iface
, BSTR
*pstrPassword
)
200 Uri
*This
= URI_THIS(iface
);
201 FIXME("(%p)->(%p)\n", This
, pstrPassword
);
209 static HRESULT WINAPI
Uri_GetPath(IUri
*iface
, BSTR
*pstrPath
)
211 Uri
*This
= URI_THIS(iface
);
212 FIXME("(%p)->(%p)\n", This
, pstrPath
);
220 static HRESULT WINAPI
Uri_GetPathAndQuery(IUri
*iface
, BSTR
*pstrPathAndQuery
)
222 Uri
*This
= URI_THIS(iface
);
223 FIXME("(%p)->(%p)\n", This
, pstrPathAndQuery
);
225 if(!pstrPathAndQuery
)
231 static HRESULT WINAPI
Uri_GetQuery(IUri
*iface
, BSTR
*pstrQuery
)
233 Uri
*This
= URI_THIS(iface
);
234 FIXME("(%p)->(%p)\n", This
, pstrQuery
);
242 static HRESULT WINAPI
Uri_GetRawUri(IUri
*iface
, BSTR
*pstrRawUri
)
244 Uri
*This
= URI_THIS(iface
);
245 FIXME("(%p)->(%p)\n", This
, pstrRawUri
);
253 static HRESULT WINAPI
Uri_GetSchemeName(IUri
*iface
, BSTR
*pstrSchemeName
)
255 Uri
*This
= URI_THIS(iface
);
256 FIXME("(%p)->(%p)\n", This
, pstrSchemeName
);
264 static HRESULT WINAPI
Uri_GetUserInfo(IUri
*iface
, BSTR
*pstrUserInfo
)
266 Uri
*This
= URI_THIS(iface
);
267 FIXME("(%p)->(%p)\n", This
, pstrUserInfo
);
275 static HRESULT WINAPI
Uri_GetUserName(IUri
*iface
, BSTR
*pstrUserName
)
277 Uri
*This
= URI_THIS(iface
);
278 FIXME("(%p)->(%p)\n", This
, pstrUserName
);
286 static HRESULT WINAPI
Uri_GetHostType(IUri
*iface
, DWORD
*pdwHostType
)
288 Uri
*This
= URI_THIS(iface
);
289 FIXME("(%p)->(%p)\n", This
, pdwHostType
);
297 static HRESULT WINAPI
Uri_GetPort(IUri
*iface
, DWORD
*pdwPort
)
299 Uri
*This
= URI_THIS(iface
);
300 FIXME("(%p)->(%p)\n", This
, pdwPort
);
308 static HRESULT WINAPI
Uri_GetScheme(IUri
*iface
, DWORD
*pdwScheme
)
310 Uri
*This
= URI_THIS(iface
);
311 FIXME("(%p)->(%p)\n", This
, pdwScheme
);
319 static HRESULT WINAPI
Uri_GetZone(IUri
*iface
, DWORD
*pdwZone
)
321 Uri
*This
= URI_THIS(iface
);
322 FIXME("(%p)->(%p)\n", This
, pdwZone
);
327 /* Microsoft doesn't seem to have this implemented yet... See
328 * the comment in Uri_GetPropertyDWORD for more about this.
330 *pdwZone
= URLZONE_INVALID
;
334 static HRESULT WINAPI
Uri_GetProperties(IUri
*iface
, DWORD
*pdwProperties
)
336 Uri
*This
= URI_THIS(iface
);
337 FIXME("(%p)->(%p)\n", This
, pdwProperties
);
341 static HRESULT WINAPI
Uri_IsEqual(IUri
*iface
, IUri
*pUri
, BOOL
*pfEqual
)
343 Uri
*This
= URI_THIS(iface
);
344 FIXME("(%p)->(%p %p)\n", This
, pUri
, pfEqual
);
350 static const IUriVtbl UriVtbl
= {
355 Uri_GetPropertyLength
,
356 Uri_GetPropertyDWORD
,
381 /***********************************************************************
382 * CreateUri (urlmon.@)
384 HRESULT WINAPI
CreateUri(LPCWSTR pwzURI
, DWORD dwFlags
, DWORD_PTR dwReserved
, IUri
**ppURI
)
388 TRACE("(%s %x %x %p)\n", debugstr_w(pwzURI
), dwFlags
, (DWORD
)dwReserved
, ppURI
);
398 ret
= heap_alloc(sizeof(Uri
));
400 return E_OUTOFMEMORY
;
402 ret
->lpIUriVtbl
= &UriVtbl
;
409 #define URIBUILDER_THIS(iface) DEFINE_THIS(UriBuilder, IUriBuilder, iface)
411 static HRESULT WINAPI
UriBuilder_QueryInterface(IUriBuilder
*iface
, REFIID riid
, void **ppv
)
413 UriBuilder
*This
= URIBUILDER_THIS(iface
);
415 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
416 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
417 *ppv
= URIBUILDER(This
);
418 }else if(IsEqualGUID(&IID_IUriBuilder
, riid
)) {
419 TRACE("(%p)->(IID_IUri %p)\n", This
, ppv
);
420 *ppv
= URIBUILDER(This
);
422 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
424 return E_NOINTERFACE
;
427 IUnknown_AddRef((IUnknown
*)*ppv
);
431 static ULONG WINAPI
UriBuilder_AddRef(IUriBuilder
*iface
)
433 UriBuilder
*This
= URIBUILDER_THIS(iface
);
434 LONG ref
= InterlockedIncrement(&This
->ref
);
436 TRACE("(%p) ref=%d\n", This
, ref
);
441 static ULONG WINAPI
UriBuilder_Release(IUriBuilder
*iface
)
443 UriBuilder
*This
= URIBUILDER_THIS(iface
);
444 LONG ref
= InterlockedDecrement(&This
->ref
);
446 TRACE("(%p) ref=%d\n", This
, ref
);
454 static HRESULT WINAPI
UriBuilder_CreateUriSimple(IUriBuilder
*iface
,
455 DWORD dwAllowEncodingPropertyMask
,
456 DWORD_PTR dwReserved
,
459 UriBuilder
*This
= URIBUILDER_THIS(iface
);
460 FIXME("(%p)->(%d %d %p)\n", This
, dwAllowEncodingPropertyMask
, (DWORD
)dwReserved
, ppIUri
);
464 static HRESULT WINAPI
UriBuilder_CreateUri(IUriBuilder
*iface
,
466 DWORD dwAllowEncodingPropertyMask
,
467 DWORD_PTR dwReserved
,
470 UriBuilder
*This
= URIBUILDER_THIS(iface
);
471 FIXME("(%p)->(0x%08x %d %d %p)\n", This
, dwCreateFlags
, dwAllowEncodingPropertyMask
, (DWORD
)dwReserved
, ppIUri
);
475 static HRESULT WINAPI
UriBuilder_CreateUriWithFlags(IUriBuilder
*iface
,
477 DWORD dwUriBuilderFlags
,
478 DWORD dwAllowEncodingPropertyMask
,
479 DWORD_PTR dwReserved
,
482 UriBuilder
*This
= URIBUILDER_THIS(iface
);
483 FIXME("(%p)->(0x%08x 0x%08x %d %d %p)\n", This
, dwCreateFlags
, dwUriBuilderFlags
,
484 dwAllowEncodingPropertyMask
, (DWORD
)dwReserved
, ppIUri
);
488 static HRESULT WINAPI
UriBuilder_GetIUri(IUriBuilder
*iface
, IUri
**ppIUri
)
490 UriBuilder
*This
= URIBUILDER_THIS(iface
);
491 FIXME("(%p)->(%p)\n", This
, ppIUri
);
495 static HRESULT WINAPI
UriBuilder_SetIUri(IUriBuilder
*iface
, IUri
*pIUri
)
497 UriBuilder
*This
= URIBUILDER_THIS(iface
);
498 FIXME("(%p)->(%p)\n", This
, pIUri
);
502 static HRESULT WINAPI
UriBuilder_GetFragment(IUriBuilder
*iface
, DWORD
*pcchFragment
, LPCWSTR
*ppwzFragment
)
504 UriBuilder
*This
= URIBUILDER_THIS(iface
);
505 FIXME("(%p)->(%p %p)\n", This
, pcchFragment
, ppwzFragment
);
509 static HRESULT WINAPI
UriBuilder_GetHost(IUriBuilder
*iface
, DWORD
*pcchHost
, LPCWSTR
*ppwzHost
)
511 UriBuilder
*This
= URIBUILDER_THIS(iface
);
512 FIXME("(%p)->(%p %p)\n", This
, pcchHost
, ppwzHost
);
516 static HRESULT WINAPI
UriBuilder_GetPassword(IUriBuilder
*iface
, DWORD
*pcchPassword
, LPCWSTR
*ppwzPassword
)
518 UriBuilder
*This
= URIBUILDER_THIS(iface
);
519 FIXME("(%p)->(%p %p)\n", This
, pcchPassword
, ppwzPassword
);
523 static HRESULT WINAPI
UriBuilder_GetPath(IUriBuilder
*iface
, DWORD
*pcchPath
, LPCWSTR
*ppwzPath
)
525 UriBuilder
*This
= URIBUILDER_THIS(iface
);
526 FIXME("(%p)->(%p %p)\n", This
, pcchPath
, ppwzPath
);
530 static HRESULT WINAPI
UriBuilder_GetPort(IUriBuilder
*iface
, BOOL
*pfHasPort
, DWORD
*pdwPort
)
532 UriBuilder
*This
= URIBUILDER_THIS(iface
);
533 FIXME("(%p)->(%p %p)\n", This
, pfHasPort
, pdwPort
);
537 static HRESULT WINAPI
UriBuilder_GetQuery(IUriBuilder
*iface
, DWORD
*pcchQuery
, LPCWSTR
*ppwzQuery
)
539 UriBuilder
*This
= URIBUILDER_THIS(iface
);
540 FIXME("(%p)->(%p %p)\n", This
, pcchQuery
, ppwzQuery
);
544 static HRESULT WINAPI
UriBuilder_GetSchemeName(IUriBuilder
*iface
, DWORD
*pcchSchemeName
, LPCWSTR
*ppwzSchemeName
)
546 UriBuilder
*This
= URIBUILDER_THIS(iface
);
547 FIXME("(%p)->(%p %p)\n", This
, pcchSchemeName
, ppwzSchemeName
);
551 static HRESULT WINAPI
UriBuilder_GetUserName(IUriBuilder
*iface
, DWORD
*pcchUserName
, LPCWSTR
*ppwzUserName
)
553 UriBuilder
*This
= URIBUILDER_THIS(iface
);
554 FIXME("(%p)->(%p %p)\n", This
, pcchUserName
, ppwzUserName
);
558 static HRESULT WINAPI
UriBuilder_SetFragment(IUriBuilder
*iface
, LPCWSTR pwzNewValue
)
560 UriBuilder
*This
= URIBUILDER_THIS(iface
);
561 FIXME("(%p)->(%s)\n", This
, debugstr_w(pwzNewValue
));
565 static HRESULT WINAPI
UriBuilder_SetHost(IUriBuilder
*iface
, LPCWSTR pwzNewValue
)
567 UriBuilder
*This
= URIBUILDER_THIS(iface
);
568 FIXME("(%p)->(%s)\n", This
, debugstr_w(pwzNewValue
));
572 static HRESULT WINAPI
UriBuilder_SetPassword(IUriBuilder
*iface
, LPCWSTR pwzNewValue
)
574 UriBuilder
*This
= URIBUILDER_THIS(iface
);
575 FIXME("(%p)->(%s)\n", This
, debugstr_w(pwzNewValue
));
579 static HRESULT WINAPI
UriBuilder_SetPath(IUriBuilder
*iface
, LPCWSTR pwzNewValue
)
581 UriBuilder
*This
= URIBUILDER_THIS(iface
);
582 FIXME("(%p)->(%s)\n", This
, debugstr_w(pwzNewValue
));
586 static HRESULT WINAPI
UriBuilder_SetPort(IUriBuilder
*iface
, BOOL fHasPort
, DWORD dwNewValue
)
588 UriBuilder
*This
= URIBUILDER_THIS(iface
);
589 FIXME("(%p)->(%d %d)\n", This
, fHasPort
, dwNewValue
);
593 static HRESULT WINAPI
UriBuilder_SetQuery(IUriBuilder
*iface
, LPCWSTR pwzNewValue
)
595 UriBuilder
*This
= URIBUILDER_THIS(iface
);
596 FIXME("(%p)->(%s)\n", This
, debugstr_w(pwzNewValue
));
600 static HRESULT WINAPI
UriBuilder_SetSchemeName(IUriBuilder
*iface
, LPCWSTR pwzNewValue
)
602 UriBuilder
*This
= URIBUILDER_THIS(iface
);
603 FIXME("(%p)->(%s)\n", This
, debugstr_w(pwzNewValue
));
607 static HRESULT WINAPI
UriBuilder_SetUserName(IUriBuilder
*iface
, LPCWSTR pwzNewValue
)
609 UriBuilder
*This
= URIBUILDER_THIS(iface
);
610 FIXME("(%p)->(%s)\n", This
, debugstr_w(pwzNewValue
));
614 static HRESULT WINAPI
UriBuilder_RemoveProperties(IUriBuilder
*iface
, DWORD dwPropertyMask
)
616 UriBuilder
*This
= URIBUILDER_THIS(iface
);
617 FIXME("(%p)->(0x%08x)\n", This
, dwPropertyMask
);
621 static HRESULT WINAPI
UriBuilder_HasBeenModified(IUriBuilder
*iface
, BOOL
*pfModified
)
623 UriBuilder
*This
= URIBUILDER_THIS(iface
);
624 FIXME("(%p)->(%p)\n", This
, pfModified
);
628 #undef URIBUILDER_THIS
630 static const IUriBuilderVtbl UriBuilderVtbl
= {
631 UriBuilder_QueryInterface
,
634 UriBuilder_CreateUriSimple
,
635 UriBuilder_CreateUri
,
636 UriBuilder_CreateUriWithFlags
,
639 UriBuilder_GetFragment
,
641 UriBuilder_GetPassword
,
645 UriBuilder_GetSchemeName
,
646 UriBuilder_GetUserName
,
647 UriBuilder_SetFragment
,
649 UriBuilder_SetPassword
,
653 UriBuilder_SetSchemeName
,
654 UriBuilder_SetUserName
,
655 UriBuilder_RemoveProperties
,
656 UriBuilder_HasBeenModified
,
659 /***********************************************************************
660 * CreateIUriBuilder (urlmon.@)
662 HRESULT WINAPI
CreateIUriBuilder(IUri
*pIUri
, DWORD dwFlags
, DWORD_PTR dwReserved
, IUriBuilder
**ppIUriBuilder
)
666 TRACE("(%p %x %x %p)\n", pIUri
, dwFlags
, (DWORD
)dwReserved
, ppIUriBuilder
);
668 ret
= heap_alloc(sizeof(UriBuilder
));
670 return E_OUTOFMEMORY
;
672 ret
->lpIUriBuilderVtbl
= &UriBuilderVtbl
;
675 *ppIUriBuilder
= URIBUILDER(ret
);