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
);
91 if(uriProp
> Uri_PROPERTY_STRING_LAST
) {
92 /* Windows allocates an empty BSTR for invalid Uri_PROPERTY's. */
93 *pbstrProperty
= SysAllocStringLen(NULL
, 0);
95 /* It only returns S_FALSE for the ZONE property... */
96 if(uriProp
== Uri_PROPERTY_ZONE
)
105 static HRESULT WINAPI
Uri_GetPropertyLength(IUri
*iface
, Uri_PROPERTY uriProp
, DWORD
*pcchProperty
, DWORD dwFlags
)
107 Uri
*This
= URI_THIS(iface
);
108 FIXME("(%p)->(%d %p %x)\n", This
, uriProp
, pcchProperty
, dwFlags
);
113 /* Can only return a length for a property if it's a string. */
114 if(uriProp
> Uri_PROPERTY_STRING_LAST
)
120 static HRESULT WINAPI
Uri_GetPropertyDWORD(IUri
*iface
, Uri_PROPERTY uriProp
, DWORD
*pcchProperty
, DWORD dwFlags
)
122 Uri
*This
= URI_THIS(iface
);
123 FIXME("(%p)->(%d %p %x)\n", This
, uriProp
, pcchProperty
, dwFlags
);
128 /* Microsoft's implementation for the ZONE property of a URI seems to be lacking...
129 * From what I can tell, instead of checking which URLZONE the URI belongs to it
130 * simply assigns URLZONE_INVALID and returns E_NOTIMPL. This also applies to the GetZone
133 if(uriProp
== Uri_PROPERTY_ZONE
) {
134 *pcchProperty
= URLZONE_INVALID
;
138 if(uriProp
< Uri_PROPERTY_DWORD_START
) {
146 static HRESULT WINAPI
Uri_HasProperty(IUri
*iface
, Uri_PROPERTY uriProp
, BOOL
*pfHasProperty
)
148 Uri
*This
= URI_THIS(iface
);
149 FIXME("(%p)->(%d %p)\n", This
, uriProp
, pfHasProperty
);
157 static HRESULT WINAPI
Uri_GetAbsoluteUri(IUri
*iface
, BSTR
*pstrAbsoluteUri
)
159 Uri
*This
= URI_THIS(iface
);
160 FIXME("(%p)->(%p)\n", This
, pstrAbsoluteUri
);
168 static HRESULT WINAPI
Uri_GetAuthority(IUri
*iface
, BSTR
*pstrAuthority
)
170 Uri
*This
= URI_THIS(iface
);
171 FIXME("(%p)->(%p)\n", This
, pstrAuthority
);
179 static HRESULT WINAPI
Uri_GetDisplayUri(IUri
*iface
, BSTR
*pstrDisplayUri
)
181 Uri
*This
= URI_THIS(iface
);
182 FIXME("(%p)->(%p)\n", This
, pstrDisplayUri
);
190 static HRESULT WINAPI
Uri_GetDomain(IUri
*iface
, BSTR
*pstrDomain
)
192 Uri
*This
= URI_THIS(iface
);
193 FIXME("(%p)->(%p)\n", This
, pstrDomain
);
201 static HRESULT WINAPI
Uri_GetExtension(IUri
*iface
, BSTR
*pstrExtension
)
203 Uri
*This
= URI_THIS(iface
);
204 FIXME("(%p)->(%p)\n", This
, pstrExtension
);
212 static HRESULT WINAPI
Uri_GetFragment(IUri
*iface
, BSTR
*pstrFragment
)
214 Uri
*This
= URI_THIS(iface
);
215 FIXME("(%p)->(%p)\n", This
, pstrFragment
);
223 static HRESULT WINAPI
Uri_GetHost(IUri
*iface
, BSTR
*pstrHost
)
225 Uri
*This
= URI_THIS(iface
);
226 FIXME("(%p)->(%p)\n", This
, pstrHost
);
234 static HRESULT WINAPI
Uri_GetPassword(IUri
*iface
, BSTR
*pstrPassword
)
236 Uri
*This
= URI_THIS(iface
);
237 FIXME("(%p)->(%p)\n", This
, pstrPassword
);
245 static HRESULT WINAPI
Uri_GetPath(IUri
*iface
, BSTR
*pstrPath
)
247 Uri
*This
= URI_THIS(iface
);
248 FIXME("(%p)->(%p)\n", This
, pstrPath
);
256 static HRESULT WINAPI
Uri_GetPathAndQuery(IUri
*iface
, BSTR
*pstrPathAndQuery
)
258 Uri
*This
= URI_THIS(iface
);
259 FIXME("(%p)->(%p)\n", This
, pstrPathAndQuery
);
261 if(!pstrPathAndQuery
)
267 static HRESULT WINAPI
Uri_GetQuery(IUri
*iface
, BSTR
*pstrQuery
)
269 Uri
*This
= URI_THIS(iface
);
270 FIXME("(%p)->(%p)\n", This
, pstrQuery
);
278 static HRESULT WINAPI
Uri_GetRawUri(IUri
*iface
, BSTR
*pstrRawUri
)
280 Uri
*This
= URI_THIS(iface
);
281 FIXME("(%p)->(%p)\n", This
, pstrRawUri
);
289 static HRESULT WINAPI
Uri_GetSchemeName(IUri
*iface
, BSTR
*pstrSchemeName
)
291 Uri
*This
= URI_THIS(iface
);
292 FIXME("(%p)->(%p)\n", This
, pstrSchemeName
);
300 static HRESULT WINAPI
Uri_GetUserInfo(IUri
*iface
, BSTR
*pstrUserInfo
)
302 Uri
*This
= URI_THIS(iface
);
303 FIXME("(%p)->(%p)\n", This
, pstrUserInfo
);
311 static HRESULT WINAPI
Uri_GetUserName(IUri
*iface
, BSTR
*pstrUserName
)
313 Uri
*This
= URI_THIS(iface
);
314 FIXME("(%p)->(%p)\n", This
, pstrUserName
);
322 static HRESULT WINAPI
Uri_GetHostType(IUri
*iface
, DWORD
*pdwHostType
)
324 Uri
*This
= URI_THIS(iface
);
325 FIXME("(%p)->(%p)\n", This
, pdwHostType
);
333 static HRESULT WINAPI
Uri_GetPort(IUri
*iface
, DWORD
*pdwPort
)
335 Uri
*This
= URI_THIS(iface
);
336 FIXME("(%p)->(%p)\n", This
, pdwPort
);
344 static HRESULT WINAPI
Uri_GetScheme(IUri
*iface
, DWORD
*pdwScheme
)
346 Uri
*This
= URI_THIS(iface
);
347 FIXME("(%p)->(%p)\n", This
, pdwScheme
);
355 static HRESULT WINAPI
Uri_GetZone(IUri
*iface
, DWORD
*pdwZone
)
357 Uri
*This
= URI_THIS(iface
);
358 FIXME("(%p)->(%p)\n", This
, pdwZone
);
363 /* Microsoft doesn't seem to have this implemented yet... See
364 * the comment in Uri_GetPropertyDWORD for more about this.
366 *pdwZone
= URLZONE_INVALID
;
370 static HRESULT WINAPI
Uri_GetProperties(IUri
*iface
, DWORD
*pdwProperties
)
372 Uri
*This
= URI_THIS(iface
);
373 FIXME("(%p)->(%p)\n", This
, pdwProperties
);
381 static HRESULT WINAPI
Uri_IsEqual(IUri
*iface
, IUri
*pUri
, BOOL
*pfEqual
)
383 Uri
*This
= URI_THIS(iface
);
384 TRACE("(%p)->(%p %p)\n", This
, pUri
, pfEqual
);
392 /* For some reason Windows returns S_OK here... */
396 FIXME("(%p)->(%p %p)\n", This
, pUri
, pfEqual
);
402 static const IUriVtbl UriVtbl
= {
407 Uri_GetPropertyLength
,
408 Uri_GetPropertyDWORD
,
433 /***********************************************************************
434 * CreateUri (urlmon.@)
436 HRESULT WINAPI
CreateUri(LPCWSTR pwzURI
, DWORD dwFlags
, DWORD_PTR dwReserved
, IUri
**ppURI
)
440 TRACE("(%s %x %x %p)\n", debugstr_w(pwzURI
), dwFlags
, (DWORD
)dwReserved
, ppURI
);
450 ret
= heap_alloc(sizeof(Uri
));
452 return E_OUTOFMEMORY
;
454 ret
->lpIUriVtbl
= &UriVtbl
;
461 #define URIBUILDER_THIS(iface) DEFINE_THIS(UriBuilder, IUriBuilder, iface)
463 static HRESULT WINAPI
UriBuilder_QueryInterface(IUriBuilder
*iface
, REFIID riid
, void **ppv
)
465 UriBuilder
*This
= URIBUILDER_THIS(iface
);
467 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
468 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
469 *ppv
= URIBUILDER(This
);
470 }else if(IsEqualGUID(&IID_IUriBuilder
, riid
)) {
471 TRACE("(%p)->(IID_IUri %p)\n", This
, ppv
);
472 *ppv
= URIBUILDER(This
);
474 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
476 return E_NOINTERFACE
;
479 IUnknown_AddRef((IUnknown
*)*ppv
);
483 static ULONG WINAPI
UriBuilder_AddRef(IUriBuilder
*iface
)
485 UriBuilder
*This
= URIBUILDER_THIS(iface
);
486 LONG ref
= InterlockedIncrement(&This
->ref
);
488 TRACE("(%p) ref=%d\n", This
, ref
);
493 static ULONG WINAPI
UriBuilder_Release(IUriBuilder
*iface
)
495 UriBuilder
*This
= URIBUILDER_THIS(iface
);
496 LONG ref
= InterlockedDecrement(&This
->ref
);
498 TRACE("(%p) ref=%d\n", This
, ref
);
506 static HRESULT WINAPI
UriBuilder_CreateUriSimple(IUriBuilder
*iface
,
507 DWORD dwAllowEncodingPropertyMask
,
508 DWORD_PTR dwReserved
,
511 UriBuilder
*This
= URIBUILDER_THIS(iface
);
512 FIXME("(%p)->(%d %d %p)\n", This
, dwAllowEncodingPropertyMask
, (DWORD
)dwReserved
, ppIUri
);
516 static HRESULT WINAPI
UriBuilder_CreateUri(IUriBuilder
*iface
,
518 DWORD dwAllowEncodingPropertyMask
,
519 DWORD_PTR dwReserved
,
522 UriBuilder
*This
= URIBUILDER_THIS(iface
);
523 FIXME("(%p)->(0x%08x %d %d %p)\n", This
, dwCreateFlags
, dwAllowEncodingPropertyMask
, (DWORD
)dwReserved
, ppIUri
);
527 static HRESULT WINAPI
UriBuilder_CreateUriWithFlags(IUriBuilder
*iface
,
529 DWORD dwUriBuilderFlags
,
530 DWORD dwAllowEncodingPropertyMask
,
531 DWORD_PTR dwReserved
,
534 UriBuilder
*This
= URIBUILDER_THIS(iface
);
535 FIXME("(%p)->(0x%08x 0x%08x %d %d %p)\n", This
, dwCreateFlags
, dwUriBuilderFlags
,
536 dwAllowEncodingPropertyMask
, (DWORD
)dwReserved
, ppIUri
);
540 static HRESULT WINAPI
UriBuilder_GetIUri(IUriBuilder
*iface
, IUri
**ppIUri
)
542 UriBuilder
*This
= URIBUILDER_THIS(iface
);
543 FIXME("(%p)->(%p)\n", This
, ppIUri
);
547 static HRESULT WINAPI
UriBuilder_SetIUri(IUriBuilder
*iface
, IUri
*pIUri
)
549 UriBuilder
*This
= URIBUILDER_THIS(iface
);
550 FIXME("(%p)->(%p)\n", This
, pIUri
);
554 static HRESULT WINAPI
UriBuilder_GetFragment(IUriBuilder
*iface
, DWORD
*pcchFragment
, LPCWSTR
*ppwzFragment
)
556 UriBuilder
*This
= URIBUILDER_THIS(iface
);
557 FIXME("(%p)->(%p %p)\n", This
, pcchFragment
, ppwzFragment
);
561 static HRESULT WINAPI
UriBuilder_GetHost(IUriBuilder
*iface
, DWORD
*pcchHost
, LPCWSTR
*ppwzHost
)
563 UriBuilder
*This
= URIBUILDER_THIS(iface
);
564 FIXME("(%p)->(%p %p)\n", This
, pcchHost
, ppwzHost
);
568 static HRESULT WINAPI
UriBuilder_GetPassword(IUriBuilder
*iface
, DWORD
*pcchPassword
, LPCWSTR
*ppwzPassword
)
570 UriBuilder
*This
= URIBUILDER_THIS(iface
);
571 FIXME("(%p)->(%p %p)\n", This
, pcchPassword
, ppwzPassword
);
575 static HRESULT WINAPI
UriBuilder_GetPath(IUriBuilder
*iface
, DWORD
*pcchPath
, LPCWSTR
*ppwzPath
)
577 UriBuilder
*This
= URIBUILDER_THIS(iface
);
578 FIXME("(%p)->(%p %p)\n", This
, pcchPath
, ppwzPath
);
582 static HRESULT WINAPI
UriBuilder_GetPort(IUriBuilder
*iface
, BOOL
*pfHasPort
, DWORD
*pdwPort
)
584 UriBuilder
*This
= URIBUILDER_THIS(iface
);
585 FIXME("(%p)->(%p %p)\n", This
, pfHasPort
, pdwPort
);
589 static HRESULT WINAPI
UriBuilder_GetQuery(IUriBuilder
*iface
, DWORD
*pcchQuery
, LPCWSTR
*ppwzQuery
)
591 UriBuilder
*This
= URIBUILDER_THIS(iface
);
592 FIXME("(%p)->(%p %p)\n", This
, pcchQuery
, ppwzQuery
);
596 static HRESULT WINAPI
UriBuilder_GetSchemeName(IUriBuilder
*iface
, DWORD
*pcchSchemeName
, LPCWSTR
*ppwzSchemeName
)
598 UriBuilder
*This
= URIBUILDER_THIS(iface
);
599 FIXME("(%p)->(%p %p)\n", This
, pcchSchemeName
, ppwzSchemeName
);
603 static HRESULT WINAPI
UriBuilder_GetUserName(IUriBuilder
*iface
, DWORD
*pcchUserName
, LPCWSTR
*ppwzUserName
)
605 UriBuilder
*This
= URIBUILDER_THIS(iface
);
606 FIXME("(%p)->(%p %p)\n", This
, pcchUserName
, ppwzUserName
);
610 static HRESULT WINAPI
UriBuilder_SetFragment(IUriBuilder
*iface
, LPCWSTR pwzNewValue
)
612 UriBuilder
*This
= URIBUILDER_THIS(iface
);
613 FIXME("(%p)->(%s)\n", This
, debugstr_w(pwzNewValue
));
617 static HRESULT WINAPI
UriBuilder_SetHost(IUriBuilder
*iface
, LPCWSTR pwzNewValue
)
619 UriBuilder
*This
= URIBUILDER_THIS(iface
);
620 FIXME("(%p)->(%s)\n", This
, debugstr_w(pwzNewValue
));
624 static HRESULT WINAPI
UriBuilder_SetPassword(IUriBuilder
*iface
, LPCWSTR pwzNewValue
)
626 UriBuilder
*This
= URIBUILDER_THIS(iface
);
627 FIXME("(%p)->(%s)\n", This
, debugstr_w(pwzNewValue
));
631 static HRESULT WINAPI
UriBuilder_SetPath(IUriBuilder
*iface
, LPCWSTR pwzNewValue
)
633 UriBuilder
*This
= URIBUILDER_THIS(iface
);
634 FIXME("(%p)->(%s)\n", This
, debugstr_w(pwzNewValue
));
638 static HRESULT WINAPI
UriBuilder_SetPort(IUriBuilder
*iface
, BOOL fHasPort
, DWORD dwNewValue
)
640 UriBuilder
*This
= URIBUILDER_THIS(iface
);
641 FIXME("(%p)->(%d %d)\n", This
, fHasPort
, dwNewValue
);
645 static HRESULT WINAPI
UriBuilder_SetQuery(IUriBuilder
*iface
, LPCWSTR pwzNewValue
)
647 UriBuilder
*This
= URIBUILDER_THIS(iface
);
648 FIXME("(%p)->(%s)\n", This
, debugstr_w(pwzNewValue
));
652 static HRESULT WINAPI
UriBuilder_SetSchemeName(IUriBuilder
*iface
, LPCWSTR pwzNewValue
)
654 UriBuilder
*This
= URIBUILDER_THIS(iface
);
655 FIXME("(%p)->(%s)\n", This
, debugstr_w(pwzNewValue
));
659 static HRESULT WINAPI
UriBuilder_SetUserName(IUriBuilder
*iface
, LPCWSTR pwzNewValue
)
661 UriBuilder
*This
= URIBUILDER_THIS(iface
);
662 FIXME("(%p)->(%s)\n", This
, debugstr_w(pwzNewValue
));
666 static HRESULT WINAPI
UriBuilder_RemoveProperties(IUriBuilder
*iface
, DWORD dwPropertyMask
)
668 UriBuilder
*This
= URIBUILDER_THIS(iface
);
669 FIXME("(%p)->(0x%08x)\n", This
, dwPropertyMask
);
673 static HRESULT WINAPI
UriBuilder_HasBeenModified(IUriBuilder
*iface
, BOOL
*pfModified
)
675 UriBuilder
*This
= URIBUILDER_THIS(iface
);
676 FIXME("(%p)->(%p)\n", This
, pfModified
);
680 #undef URIBUILDER_THIS
682 static const IUriBuilderVtbl UriBuilderVtbl
= {
683 UriBuilder_QueryInterface
,
686 UriBuilder_CreateUriSimple
,
687 UriBuilder_CreateUri
,
688 UriBuilder_CreateUriWithFlags
,
691 UriBuilder_GetFragment
,
693 UriBuilder_GetPassword
,
697 UriBuilder_GetSchemeName
,
698 UriBuilder_GetUserName
,
699 UriBuilder_SetFragment
,
701 UriBuilder_SetPassword
,
705 UriBuilder_SetSchemeName
,
706 UriBuilder_SetUserName
,
707 UriBuilder_RemoveProperties
,
708 UriBuilder_HasBeenModified
,
711 /***********************************************************************
712 * CreateIUriBuilder (urlmon.@)
714 HRESULT WINAPI
CreateIUriBuilder(IUri
*pIUri
, DWORD dwFlags
, DWORD_PTR dwReserved
, IUriBuilder
**ppIUriBuilder
)
718 TRACE("(%p %x %x %p)\n", pIUri
, dwFlags
, (DWORD
)dwReserved
, ppIUriBuilder
);
720 ret
= heap_alloc(sizeof(UriBuilder
));
722 return E_OUTOFMEMORY
;
724 ret
->lpIUriBuilderVtbl
= &UriBuilderVtbl
;
727 *ppIUriBuilder
= URIBUILDER(ret
);