urlmon: Implemented IUriBuilder_{Get/Set}Fragment.
This commit is contained in:
parent
d3c4106d6f
commit
6aa90a2dce
@ -4266,7 +4266,7 @@ typedef struct _uri_builder_test {
|
|||||||
static const uri_builder_test uri_builder_tests[] = {
|
static const uri_builder_test uri_builder_tests[] = {
|
||||||
{ "http://google.com/",0,S_OK,FALSE,
|
{ "http://google.com/",0,S_OK,FALSE,
|
||||||
{
|
{
|
||||||
{TRUE,"#fragment",NULL,Uri_PROPERTY_FRAGMENT,S_OK,TRUE},
|
{TRUE,"#fragment",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE},
|
||||||
{TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,TRUE},
|
{TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,TRUE},
|
||||||
{TRUE,"?query=x",NULL,Uri_PROPERTY_QUERY,S_OK,TRUE},
|
{TRUE,"?query=x",NULL,Uri_PROPERTY_QUERY,S_OK,TRUE},
|
||||||
{TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,TRUE}
|
{TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,TRUE}
|
||||||
@ -4295,6 +4295,24 @@ static const uri_builder_test uri_builder_tests[] = {
|
|||||||
"http://[::192.2.3.4]/",0,S_OK,TRUE,
|
"http://[::192.2.3.4]/",0,S_OK,TRUE,
|
||||||
"http://[::192.2.3.4]/",0,S_OK,TRUE,
|
"http://[::192.2.3.4]/",0,S_OK,TRUE,
|
||||||
"http://[::192.2.3.4]/",0,0,0,S_OK,TRUE
|
"http://[::192.2.3.4]/",0,0,0,S_OK,TRUE
|
||||||
|
},
|
||||||
|
{ "http://google.com/",0,S_OK,FALSE,
|
||||||
|
{
|
||||||
|
{TRUE,"Frag","#Frag",Uri_PROPERTY_FRAGMENT,S_OK,FALSE}
|
||||||
|
},
|
||||||
|
{FALSE},
|
||||||
|
"http://google.com/#Frag",0,S_OK,TRUE,
|
||||||
|
"http://google.com/#Frag",0,S_OK,TRUE,
|
||||||
|
"http://google.com/#Frag",0,0,0,S_OK,TRUE
|
||||||
|
},
|
||||||
|
{ "http://google.com/",0,S_OK,FALSE,
|
||||||
|
{
|
||||||
|
{TRUE,"","#",Uri_PROPERTY_FRAGMENT,S_OK,FALSE},
|
||||||
|
},
|
||||||
|
{FALSE},
|
||||||
|
"http://google.com/#",0,S_OK,TRUE,
|
||||||
|
"http://google.com/#",0,S_OK,TRUE,
|
||||||
|
"http://google.com/#",0,0,0,S_OK,TRUE
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -5819,7 +5837,7 @@ static void test_IUriBuilder_CreateInvalidArgs(void) {
|
|||||||
if(uri) IUri_Release(uri);
|
if(uri) IUri_Release(uri);
|
||||||
|
|
||||||
hr = IUriBuilder_SetFragment(builder, NULL);
|
hr = IUriBuilder_SetFragment(builder, NULL);
|
||||||
todo_wine { ok(hr == S_OK, "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x.\n", hr, S_OK); }
|
ok(hr == S_OK, "Error: IUriBuilder_SetFragment returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
|
||||||
|
|
||||||
/* The IUriBuilder is changed, so it returns E_NOTIMPL again. */
|
/* The IUriBuilder is changed, so it returns E_NOTIMPL again. */
|
||||||
uri = (void*) 0xdeadbeef;
|
uri = (void*) 0xdeadbeef;
|
||||||
|
@ -77,7 +77,11 @@ typedef struct {
|
|||||||
const IUriBuilderVtbl *lpIUriBuilderVtbl;
|
const IUriBuilderVtbl *lpIUriBuilderVtbl;
|
||||||
LONG ref;
|
LONG ref;
|
||||||
|
|
||||||
IUri *uri;
|
Uri *uri;
|
||||||
|
DWORD modified_props;
|
||||||
|
|
||||||
|
WCHAR *fragment;
|
||||||
|
DWORD fragment_len;
|
||||||
} UriBuilder;
|
} UriBuilder;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -3243,6 +3247,76 @@ static HRESULT canonicalize_uri(const parse_data *data, Uri *uri, DWORD flags) {
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HRESULT get_builder_component(LPWSTR *component, DWORD *component_len,
|
||||||
|
LPCWSTR source, DWORD source_len,
|
||||||
|
LPCWSTR *output, DWORD *output_len)
|
||||||
|
{
|
||||||
|
if(!output_len) {
|
||||||
|
if(output)
|
||||||
|
*output = NULL;
|
||||||
|
return E_POINTER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!output) {
|
||||||
|
*output_len = 0;
|
||||||
|
return E_POINTER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!(*component) && source) {
|
||||||
|
/* Allocate 'component', and copy the contents from 'source'
|
||||||
|
* into the new allocation.
|
||||||
|
*/
|
||||||
|
*component = heap_alloc((source_len+1)*sizeof(WCHAR));
|
||||||
|
if(!(*component))
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
memcpy(*component, source, source_len*sizeof(WCHAR));
|
||||||
|
(*component)[source_len] = '\0';
|
||||||
|
*component_len = source_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
*output = *component;
|
||||||
|
*output_len = *component_len;
|
||||||
|
return *output ? S_OK : S_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocates 'component' and copies the string from 'new_value' into 'component'.
|
||||||
|
* If 'prefix' is set and 'new_value' isn't NULL, then it checks if 'new_value'
|
||||||
|
* starts with 'prefix'. If it doesn't then 'prefix' is prepended to 'component'.
|
||||||
|
*/
|
||||||
|
static HRESULT set_builder_component(LPWSTR *component, DWORD *component_len, LPCWSTR new_value,
|
||||||
|
WCHAR prefix)
|
||||||
|
{
|
||||||
|
if(*component)
|
||||||
|
heap_free(*component);
|
||||||
|
|
||||||
|
if(!new_value) {
|
||||||
|
*component = NULL;
|
||||||
|
*component_len = 0;
|
||||||
|
} else {
|
||||||
|
BOOL add_prefix = FALSE;
|
||||||
|
DWORD len = lstrlenW(new_value);
|
||||||
|
DWORD pos = 0;
|
||||||
|
|
||||||
|
if(prefix && *new_value != prefix) {
|
||||||
|
add_prefix = TRUE;
|
||||||
|
*component = heap_alloc((len+2)*sizeof(WCHAR));
|
||||||
|
} else
|
||||||
|
*component = heap_alloc((len+1)*sizeof(WCHAR));
|
||||||
|
|
||||||
|
if(!(*component))
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
if(add_prefix)
|
||||||
|
(*component)[pos++] = prefix;
|
||||||
|
|
||||||
|
memcpy(*component+pos, new_value, (len+1)*sizeof(WCHAR));
|
||||||
|
*component_len = len+pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
#define URI(x) ((IUri*) &(x)->lpIUriVtbl)
|
#define URI(x) ((IUri*) &(x)->lpIUriVtbl)
|
||||||
#define URIBUILDER(x) ((IUriBuilder*) &(x)->lpIUriBuilderVtbl)
|
#define URIBUILDER(x) ((IUriBuilder*) &(x)->lpIUriBuilderVtbl)
|
||||||
|
|
||||||
@ -4234,7 +4308,8 @@ static ULONG WINAPI UriBuilder_Release(IUriBuilder *iface)
|
|||||||
TRACE("(%p) ref=%d\n", This, ref);
|
TRACE("(%p) ref=%d\n", This, ref);
|
||||||
|
|
||||||
if(!ref) {
|
if(!ref) {
|
||||||
if(This->uri) IUri_Release(This->uri);
|
if(This->uri) IUri_Release(URI(This->uri));
|
||||||
|
heap_free(This->fragment);
|
||||||
heap_free(This);
|
heap_free(This);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4353,19 +4428,11 @@ static HRESULT WINAPI UriBuilder_GetFragment(IUriBuilder *iface, DWORD *pcchFrag
|
|||||||
UriBuilder *This = URIBUILDER_THIS(iface);
|
UriBuilder *This = URIBUILDER_THIS(iface);
|
||||||
TRACE("(%p)->(%p %p)\n", This, pcchFragment, ppwzFragment);
|
TRACE("(%p)->(%p %p)\n", This, pcchFragment, ppwzFragment);
|
||||||
|
|
||||||
if(!pcchFragment) {
|
if(!This->uri || This->uri->fragment_start == -1 || This->modified_props & Uri_HAS_FRAGMENT)
|
||||||
if(ppwzFragment)
|
return get_builder_component(&This->fragment, &This->fragment_len, NULL, 0, ppwzFragment, pcchFragment);
|
||||||
*ppwzFragment = NULL;
|
else
|
||||||
return E_POINTER;
|
return get_builder_component(&This->fragment, &This->fragment_len, This->uri->canon_uri+This->uri->fragment_start,
|
||||||
}
|
This->uri->fragment_len, ppwzFragment, pcchFragment);
|
||||||
|
|
||||||
if(!ppwzFragment) {
|
|
||||||
*pcchFragment = 0;
|
|
||||||
return E_POINTER;
|
|
||||||
}
|
|
||||||
|
|
||||||
FIXME("(%p)->(%p %p)\n", This, pcchFragment, ppwzFragment);
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI UriBuilder_GetHost(IUriBuilder *iface, DWORD *pcchHost, LPCWSTR *ppwzHost)
|
static HRESULT WINAPI UriBuilder_GetHost(IUriBuilder *iface, DWORD *pcchHost, LPCWSTR *ppwzHost)
|
||||||
@ -4511,8 +4578,10 @@ static HRESULT WINAPI UriBuilder_GetUserName(IUriBuilder *iface, DWORD *pcchUser
|
|||||||
static HRESULT WINAPI UriBuilder_SetFragment(IUriBuilder *iface, LPCWSTR pwzNewValue)
|
static HRESULT WINAPI UriBuilder_SetFragment(IUriBuilder *iface, LPCWSTR pwzNewValue)
|
||||||
{
|
{
|
||||||
UriBuilder *This = URIBUILDER_THIS(iface);
|
UriBuilder *This = URIBUILDER_THIS(iface);
|
||||||
FIXME("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
|
TRACE("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
|
||||||
return E_NOTIMPL;
|
|
||||||
|
This->modified_props |= Uri_HAS_FRAGMENT;
|
||||||
|
return set_builder_component(&This->fragment, &This->fragment_len, pwzNewValue, '#');
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI UriBuilder_SetHost(IUriBuilder *iface, LPCWSTR pwzNewValue)
|
static HRESULT WINAPI UriBuilder_SetHost(IUriBuilder *iface, LPCWSTR pwzNewValue)
|
||||||
@ -4626,16 +4695,27 @@ HRESULT WINAPI CreateIUriBuilder(IUri *pIUri, DWORD dwFlags, DWORD_PTR dwReserve
|
|||||||
if(!ppIUriBuilder)
|
if(!ppIUriBuilder)
|
||||||
return E_POINTER;
|
return E_POINTER;
|
||||||
|
|
||||||
ret = heap_alloc(sizeof(UriBuilder));
|
ret = heap_alloc_zero(sizeof(UriBuilder));
|
||||||
if(!ret)
|
if(!ret)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
ret->lpIUriBuilderVtbl = &UriBuilderVtbl;
|
ret->lpIUriBuilderVtbl = &UriBuilderVtbl;
|
||||||
ret->ref = 1;
|
ret->ref = 1;
|
||||||
|
|
||||||
ret->uri = pIUri;
|
if(pIUri) {
|
||||||
if(pIUri)
|
Uri *uri;
|
||||||
IUri_AddRef(pIUri);
|
|
||||||
|
if((uri = get_uri_obj(pIUri))) {
|
||||||
|
IUri_AddRef(pIUri);
|
||||||
|
ret->uri = uri;
|
||||||
|
} else {
|
||||||
|
heap_free(ret);
|
||||||
|
*ppIUriBuilder = NULL;
|
||||||
|
FIXME("(%p %x %x %p): Unknown IUri types not supported yet.\n", pIUri, dwFlags,
|
||||||
|
(DWORD)dwReserved, ppIUriBuilder);
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*ppIUriBuilder = URIBUILDER(ret);
|
*ppIUriBuilder = URIBUILDER(ret);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user