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
);
230 static HRESULT WINAPI
Uri_GetPassword(IUri
*iface
, BSTR
*pstrPassword
)
232 Uri
*This
= URI_THIS(iface
);
233 FIXME("(%p)->(%p)\n", This
, pstrPassword
);
241 static HRESULT WINAPI
Uri_GetPath(IUri
*iface
, BSTR
*pstrPath
)
243 Uri
*This
= URI_THIS(iface
);
244 FIXME("(%p)->(%p)\n", This
, pstrPath
);
252 static HRESULT WINAPI
Uri_GetPathAndQuery(IUri
*iface
, BSTR
*pstrPathAndQuery
)
254 Uri
*This
= URI_THIS(iface
);
255 FIXME("(%p)->(%p)\n", This
, pstrPathAndQuery
);
257 if(!pstrPathAndQuery
)
263 static HRESULT WINAPI
Uri_GetQuery(IUri
*iface
, BSTR
*pstrQuery
)
265 Uri
*This
= URI_THIS(iface
);
266 FIXME("(%p)->(%p)\n", This
, pstrQuery
);
274 static HRESULT WINAPI
Uri_GetRawUri(IUri
*iface
, BSTR
*pstrRawUri
)
276 Uri
*This
= URI_THIS(iface
);
277 FIXME("(%p)->(%p)\n", This
, pstrRawUri
);
285 static HRESULT WINAPI
Uri_GetSchemeName(IUri
*iface
, BSTR
*pstrSchemeName
)
287 Uri
*This
= URI_THIS(iface
);
288 FIXME("(%p)->(%p)\n", This
, pstrSchemeName
);
296 static HRESULT WINAPI
Uri_GetUserInfo(IUri
*iface
, BSTR
*pstrUserInfo
)
298 Uri
*This
= URI_THIS(iface
);
299 FIXME("(%p)->(%p)\n", This
, pstrUserInfo
);
307 static HRESULT WINAPI
Uri_GetUserName(IUri
*iface
, BSTR
*pstrUserName
)
309 Uri
*This
= URI_THIS(iface
);
310 FIXME("(%p)->(%p)\n", This
, pstrUserName
);
318 static HRESULT WINAPI
Uri_GetHostType(IUri
*iface
, DWORD
*pdwHostType
)
320 Uri
*This
= URI_THIS(iface
);
321 FIXME("(%p)->(%p)\n", This
, pdwHostType
);
329 static HRESULT WINAPI
Uri_GetPort(IUri
*iface
, DWORD
*pdwPort
)
331 Uri
*This
= URI_THIS(iface
);
332 FIXME("(%p)->(%p)\n", This
, pdwPort
);
340 static HRESULT WINAPI
Uri_GetScheme(IUri
*iface
, DWORD
*pdwScheme
)
342 Uri
*This
= URI_THIS(iface
);
343 FIXME("(%p)->(%p)\n", This
, pdwScheme
);
351 static HRESULT WINAPI
Uri_GetZone(IUri
*iface
, DWORD
*pdwZone
)
353 Uri
*This
= URI_THIS(iface
);
354 FIXME("(%p)->(%p)\n", This
, pdwZone
);
359 /* Microsoft doesn't seem to have this implemented yet... See
360 * the comment in Uri_GetPropertyDWORD for more about this.
362 *pdwZone
= URLZONE_INVALID
;
366 static HRESULT WINAPI
Uri_GetProperties(IUri
*iface
, DWORD
*pdwProperties
)
368 Uri
*This
= URI_THIS(iface
);
369 FIXME("(%p)->(%p)\n", This
, pdwProperties
);
377 static HRESULT WINAPI
Uri_IsEqual(IUri
*iface
, IUri
*pUri
, BOOL
*pfEqual
)
379 Uri
*This
= URI_THIS(iface
);
380 FIXME("(%p)->(%p %p)\n", This
, pUri
, pfEqual
);
386 static const IUriVtbl UriVtbl
= {
391 Uri_GetPropertyLength
,
392 Uri_GetPropertyDWORD
,
417 /***********************************************************************
418 * CreateUri (urlmon.@)
420 HRESULT WINAPI
CreateUri(LPCWSTR pwzURI
, DWORD dwFlags
, DWORD_PTR dwReserved
, IUri
**ppURI
)
424 TRACE("(%s %x %x %p)\n", debugstr_w(pwzURI
), dwFlags
, (DWORD
)dwReserved
, ppURI
);
434 ret
= heap_alloc(sizeof(Uri
));
436 return E_OUTOFMEMORY
;
438 ret
->lpIUriVtbl
= &UriVtbl
;
445 #define URIBUILDER_THIS(iface) DEFINE_THIS(UriBuilder, IUriBuilder, iface)
447 static HRESULT WINAPI
UriBuilder_QueryInterface(IUriBuilder
*iface
, REFIID riid
, void **ppv
)
449 UriBuilder
*This
= URIBUILDER_THIS(iface
);
451 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
452 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
453 *ppv
= URIBUILDER(This
);
454 }else if(IsEqualGUID(&IID_IUriBuilder
, riid
)) {
455 TRACE("(%p)->(IID_IUri %p)\n", This
, ppv
);
456 *ppv
= URIBUILDER(This
);
458 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
460 return E_NOINTERFACE
;
463 IUnknown_AddRef((IUnknown
*)*ppv
);
467 static ULONG WINAPI
UriBuilder_AddRef(IUriBuilder
*iface
)
469 UriBuilder
*This
= URIBUILDER_THIS(iface
);
470 LONG ref
= InterlockedIncrement(&This
->ref
);
472 TRACE("(%p) ref=%d\n", This
, ref
);
477 static ULONG WINAPI
UriBuilder_Release(IUriBuilder
*iface
)
479 UriBuilder
*This
= URIBUILDER_THIS(iface
);
480 LONG ref
= InterlockedDecrement(&This
->ref
);
482 TRACE("(%p) ref=%d\n", This
, ref
);
490 static HRESULT WINAPI
UriBuilder_CreateUriSimple(IUriBuilder
*iface
,
491 DWORD dwAllowEncodingPropertyMask
,
492 DWORD_PTR dwReserved
,
495 UriBuilder
*This
= URIBUILDER_THIS(iface
);
496 FIXME("(%p)->(%d %d %p)\n", This
, dwAllowEncodingPropertyMask
, (DWORD
)dwReserved
, ppIUri
);
500 static HRESULT WINAPI
UriBuilder_CreateUri(IUriBuilder
*iface
,
502 DWORD dwAllowEncodingPropertyMask
,
503 DWORD_PTR dwReserved
,
506 UriBuilder
*This
= URIBUILDER_THIS(iface
);
507 FIXME("(%p)->(0x%08x %d %d %p)\n", This
, dwCreateFlags
, dwAllowEncodingPropertyMask
, (DWORD
)dwReserved
, ppIUri
);
511 static HRESULT WINAPI
UriBuilder_CreateUriWithFlags(IUriBuilder
*iface
,
513 DWORD dwUriBuilderFlags
,
514 DWORD dwAllowEncodingPropertyMask
,
515 DWORD_PTR dwReserved
,
518 UriBuilder
*This
= URIBUILDER_THIS(iface
);
519 FIXME("(%p)->(0x%08x 0x%08x %d %d %p)\n", This
, dwCreateFlags
, dwUriBuilderFlags
,
520 dwAllowEncodingPropertyMask
, (DWORD
)dwReserved
, ppIUri
);
524 static HRESULT WINAPI
UriBuilder_GetIUri(IUriBuilder
*iface
, IUri
**ppIUri
)
526 UriBuilder
*This
= URIBUILDER_THIS(iface
);
527 FIXME("(%p)->(%p)\n", This
, ppIUri
);
531 static HRESULT WINAPI
UriBuilder_SetIUri(IUriBuilder
*iface
, IUri
*pIUri
)
533 UriBuilder
*This
= URIBUILDER_THIS(iface
);
534 FIXME("(%p)->(%p)\n", This
, pIUri
);
538 static HRESULT WINAPI
UriBuilder_GetFragment(IUriBuilder
*iface
, DWORD
*pcchFragment
, LPCWSTR
*ppwzFragment
)
540 UriBuilder
*This
= URIBUILDER_THIS(iface
);
541 FIXME("(%p)->(%p %p)\n", This
, pcchFragment
, ppwzFragment
);
545 static HRESULT WINAPI
UriBuilder_GetHost(IUriBuilder
*iface
, DWORD
*pcchHost
, LPCWSTR
*ppwzHost
)
547 UriBuilder
*This
= URIBUILDER_THIS(iface
);
548 FIXME("(%p)->(%p %p)\n", This
, pcchHost
, ppwzHost
);
552 static HRESULT WINAPI
UriBuilder_GetPassword(IUriBuilder
*iface
, DWORD
*pcchPassword
, LPCWSTR
*ppwzPassword
)
554 UriBuilder
*This
= URIBUILDER_THIS(iface
);
555 FIXME("(%p)->(%p %p)\n", This
, pcchPassword
, ppwzPassword
);
559 static HRESULT WINAPI
UriBuilder_GetPath(IUriBuilder
*iface
, DWORD
*pcchPath
, LPCWSTR
*ppwzPath
)
561 UriBuilder
*This
= URIBUILDER_THIS(iface
);
562 FIXME("(%p)->(%p %p)\n", This
, pcchPath
, ppwzPath
);
566 static HRESULT WINAPI
UriBuilder_GetPort(IUriBuilder
*iface
, BOOL
*pfHasPort
, DWORD
*pdwPort
)
568 UriBuilder
*This
= URIBUILDER_THIS(iface
);
569 FIXME("(%p)->(%p %p)\n", This
, pfHasPort
, pdwPort
);
573 static HRESULT WINAPI
UriBuilder_GetQuery(IUriBuilder
*iface
, DWORD
*pcchQuery
, LPCWSTR
*ppwzQuery
)
575 UriBuilder
*This
= URIBUILDER_THIS(iface
);
576 FIXME("(%p)->(%p %p)\n", This
, pcchQuery
, ppwzQuery
);
580 static HRESULT WINAPI
UriBuilder_GetSchemeName(IUriBuilder
*iface
, DWORD
*pcchSchemeName
, LPCWSTR
*ppwzSchemeName
)
582 UriBuilder
*This
= URIBUILDER_THIS(iface
);
583 FIXME("(%p)->(%p %p)\n", This
, pcchSchemeName
, ppwzSchemeName
);
587 static HRESULT WINAPI
UriBuilder_GetUserName(IUriBuilder
*iface
, DWORD
*pcchUserName
, LPCWSTR
*ppwzUserName
)
589 UriBuilder
*This
= URIBUILDER_THIS(iface
);
590 FIXME("(%p)->(%p %p)\n", This
, pcchUserName
, ppwzUserName
);
594 static HRESULT WINAPI
UriBuilder_SetFragment(IUriBuilder
*iface
, LPCWSTR pwzNewValue
)
596 UriBuilder
*This
= URIBUILDER_THIS(iface
);
597 FIXME("(%p)->(%s)\n", This
, debugstr_w(pwzNewValue
));
601 static HRESULT WINAPI
UriBuilder_SetHost(IUriBuilder
*iface
, LPCWSTR pwzNewValue
)
603 UriBuilder
*This
= URIBUILDER_THIS(iface
);
604 FIXME("(%p)->(%s)\n", This
, debugstr_w(pwzNewValue
));
608 static HRESULT WINAPI
UriBuilder_SetPassword(IUriBuilder
*iface
, LPCWSTR pwzNewValue
)
610 UriBuilder
*This
= URIBUILDER_THIS(iface
);
611 FIXME("(%p)->(%s)\n", This
, debugstr_w(pwzNewValue
));
615 static HRESULT WINAPI
UriBuilder_SetPath(IUriBuilder
*iface
, LPCWSTR pwzNewValue
)
617 UriBuilder
*This
= URIBUILDER_THIS(iface
);
618 FIXME("(%p)->(%s)\n", This
, debugstr_w(pwzNewValue
));
622 static HRESULT WINAPI
UriBuilder_SetPort(IUriBuilder
*iface
, BOOL fHasPort
, DWORD dwNewValue
)
624 UriBuilder
*This
= URIBUILDER_THIS(iface
);
625 FIXME("(%p)->(%d %d)\n", This
, fHasPort
, dwNewValue
);
629 static HRESULT WINAPI
UriBuilder_SetQuery(IUriBuilder
*iface
, LPCWSTR pwzNewValue
)
631 UriBuilder
*This
= URIBUILDER_THIS(iface
);
632 FIXME("(%p)->(%s)\n", This
, debugstr_w(pwzNewValue
));
636 static HRESULT WINAPI
UriBuilder_SetSchemeName(IUriBuilder
*iface
, LPCWSTR pwzNewValue
)
638 UriBuilder
*This
= URIBUILDER_THIS(iface
);
639 FIXME("(%p)->(%s)\n", This
, debugstr_w(pwzNewValue
));
643 static HRESULT WINAPI
UriBuilder_SetUserName(IUriBuilder
*iface
, LPCWSTR pwzNewValue
)
645 UriBuilder
*This
= URIBUILDER_THIS(iface
);
646 FIXME("(%p)->(%s)\n", This
, debugstr_w(pwzNewValue
));
650 static HRESULT WINAPI
UriBuilder_RemoveProperties(IUriBuilder
*iface
, DWORD dwPropertyMask
)
652 UriBuilder
*This
= URIBUILDER_THIS(iface
);
653 FIXME("(%p)->(0x%08x)\n", This
, dwPropertyMask
);
657 static HRESULT WINAPI
UriBuilder_HasBeenModified(IUriBuilder
*iface
, BOOL
*pfModified
)
659 UriBuilder
*This
= URIBUILDER_THIS(iface
);
660 FIXME("(%p)->(%p)\n", This
, pfModified
);
664 #undef URIBUILDER_THIS
666 static const IUriBuilderVtbl UriBuilderVtbl
= {
667 UriBuilder_QueryInterface
,
670 UriBuilder_CreateUriSimple
,
671 UriBuilder_CreateUri
,
672 UriBuilder_CreateUriWithFlags
,
675 UriBuilder_GetFragment
,
677 UriBuilder_GetPassword
,
681 UriBuilder_GetSchemeName
,
682 UriBuilder_GetUserName
,
683 UriBuilder_SetFragment
,
685 UriBuilder_SetPassword
,
689 UriBuilder_SetSchemeName
,
690 UriBuilder_SetUserName
,
691 UriBuilder_RemoveProperties
,
692 UriBuilder_HasBeenModified
,
695 /***********************************************************************
696 * CreateIUriBuilder (urlmon.@)
698 HRESULT WINAPI
CreateIUriBuilder(IUri
*pIUri
, DWORD dwFlags
, DWORD_PTR dwReserved
, IUriBuilder
**ppIUriBuilder
)
702 TRACE("(%p %x %x %p)\n", pIUri
, dwFlags
, (DWORD
)dwReserved
, ppIUriBuilder
);
704 ret
= heap_alloc(sizeof(UriBuilder
));
706 return E_OUTOFMEMORY
;
708 ret
->lpIUriBuilderVtbl
= &UriBuilderVtbl
;
711 *ppIUriBuilder
= URIBUILDER(ret
);