Thomas Mullaly : urlmon: Implemented IUriBuilder_{Get/Set}Host.

Alexandre Julliard julliard at winehq.org
Mon Sep 6 13:53:12 CDT 2010


Module: wine
Branch: master
Commit: 1e5040eca144e8824a4879e66f816bec08a0171c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=1e5040eca144e8824a4879e66f816bec08a0171c

Author: Thomas Mullaly <thomas.mullaly at gmail.com>
Date:   Sat Sep  4 21:09:46 2010 -0400

urlmon: Implemented IUriBuilder_{Get/Set}Host.

---

 dlls/urlmon/tests/uri.c |    8 +++-----
 dlls/urlmon/uri.c       |   32 ++++++++++++++++++--------------
 2 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/dlls/urlmon/tests/uri.c b/dlls/urlmon/tests/uri.c
index 1ce6dfa..154bdff 100644
--- a/dlls/urlmon/tests/uri.c
+++ b/dlls/urlmon/tests/uri.c
@@ -4288,7 +4288,7 @@ static const uri_builder_test uri_builder_tests[] = {
     {   "/Test/test dir",Uri_CREATE_ALLOW_RELATIVE,S_OK,FALSE,
         {
             {TRUE,"http",NULL,Uri_PROPERTY_SCHEME_NAME,S_OK,TRUE},
-            {TRUE,"::192.2.3.4",NULL,Uri_PROPERTY_HOST,S_OK,TRUE},
+            {TRUE,"::192.2.3.4",NULL,Uri_PROPERTY_HOST,S_OK,FALSE},
             {TRUE,NULL,NULL,Uri_PROPERTY_PATH,S_OK,TRUE}
         },
         {FALSE},
@@ -6920,10 +6920,8 @@ static void test_IUriBuilder_HasBeenModified(void) {
             hr, E_POINTER);
 
         hr = IUriBuilder_SetHost(builder, hostW);
-        todo_wine {
-            ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n",
-                hr, S_OK);
-        }
+        ok(hr == S_OK, "Error: IUriBuilder_SetHost returned 0x%08x, expected 0x%08x.\n",
+            hr, S_OK);
 
         hr = IUriBuilder_HasBeenModified(builder, &received);
         todo_wine {
diff --git a/dlls/urlmon/uri.c b/dlls/urlmon/uri.c
index c6b496b..195786c 100644
--- a/dlls/urlmon/uri.c
+++ b/dlls/urlmon/uri.c
@@ -82,6 +82,9 @@ typedef struct {
 
     WCHAR   *fragment;
     DWORD   fragment_len;
+
+    WCHAR   *host;
+    DWORD   host_len;
 } UriBuilder;
 
 typedef struct {
@@ -4310,6 +4313,7 @@ static ULONG WINAPI UriBuilder_Release(IUriBuilder *iface)
     if(!ref) {
         if(This->uri) IUri_Release(URI(This->uri));
         heap_free(This->fragment);
+        heap_free(This->host);
         heap_free(This);
     }
 
@@ -4440,19 +4444,17 @@ static HRESULT WINAPI UriBuilder_GetHost(IUriBuilder *iface, DWORD *pcchHost, LP
     UriBuilder *This = URIBUILDER_THIS(iface);
     TRACE("(%p)->(%p %p)\n", This, pcchHost, ppwzHost);
 
-    if(!pcchHost) {
-        if(ppwzHost)
-            *ppwzHost = NULL;
-        return E_POINTER;
-    }
-
-    if(!ppwzHost) {
-        *pcchHost = 0;
-        return E_POINTER;
+    if(!This->uri || This->uri->host_start == -1 || This->modified_props & Uri_HAS_HOST)
+        return get_builder_component(&This->host, &This->host_len, NULL, 0, ppwzHost, pcchHost);
+    else {
+        if(This->uri->host_type == Uri_HOST_IPV6)
+            /* Don't include the '[' and ']' around the address. */
+            return get_builder_component(&This->host, &This->host_len, This->uri->canon_uri+This->uri->host_start+1,
+                                         This->uri->host_len-2, ppwzHost, pcchHost);
+        else
+            return get_builder_component(&This->host, &This->host_len, This->uri->canon_uri+This->uri->host_start,
+                                         This->uri->host_len, ppwzHost, pcchHost);
     }
-
-    FIXME("(%p)->(%p %p)\n", This, pcchHost, ppwzHost);
-    return E_NOTIMPL;
 }
 
 static HRESULT WINAPI UriBuilder_GetPassword(IUriBuilder *iface, DWORD *pcchPassword, LPCWSTR *ppwzPassword)
@@ -4587,8 +4589,10 @@ static HRESULT WINAPI UriBuilder_SetFragment(IUriBuilder *iface, LPCWSTR pwzNewV
 static HRESULT WINAPI UriBuilder_SetHost(IUriBuilder *iface, LPCWSTR pwzNewValue)
 {
     UriBuilder *This = URIBUILDER_THIS(iface);
-    FIXME("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
-    return E_NOTIMPL;
+    TRACE("(%p)->(%s)\n", This, debugstr_w(pwzNewValue));
+
+    This->modified_props |= Uri_HAS_HOST;
+    return set_builder_component(&This->host, &This->host_len, pwzNewValue, 0);
 }
 
 static HRESULT WINAPI UriBuilder_SetPassword(IUriBuilder *iface, LPCWSTR pwzNewValue)




More information about the wine-cvs mailing list