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

Alexandre Julliard julliard at winehq.org
Tue Sep 7 11:22:56 CDT 2010


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

Author: Thomas Mullaly <thomas.mullaly at gmail.com>
Date:   Mon Sep  6 17:55:23 2010 -0400

urlmon: Implemented IUriBuilder_{Get/Set}UserName.

---

 dlls/urlmon/tests/uri.c |   34 +++++++++++++++++++++++++++++++++-
 dlls/urlmon/uri.c       |   34 +++++++++++++++++++++-------------
 2 files changed, 54 insertions(+), 14 deletions(-)

diff --git a/dlls/urlmon/tests/uri.c b/dlls/urlmon/tests/uri.c
index 4c8f358..8517046 100644
--- a/dlls/urlmon/tests/uri.c
+++ b/dlls/urlmon/tests/uri.c
@@ -4433,7 +4433,7 @@ static const uri_builder_test uri_builder_tests[] = {
             {TRUE,"#fragment",NULL,Uri_PROPERTY_FRAGMENT,S_OK,FALSE},
             {TRUE,"password",NULL,Uri_PROPERTY_PASSWORD,S_OK,FALSE},
             {TRUE,"?query=x",NULL,Uri_PROPERTY_QUERY,S_OK,FALSE},
-            {TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,TRUE}
+            {TRUE,"username",NULL,Uri_PROPERTY_USER_NAME,S_OK,FALSE}
         },
         {FALSE},
         0,S_OK,TRUE,
@@ -4856,6 +4856,38 @@ static const uri_builder_test uri_builder_tests[] = {
             {URL_SCHEME_HTTP,S_OK},
             {URLZONE_INVALID,E_NOTIMPL}
         }
+    },
+    {   "http://:[email protected]/",0,S_OK,FALSE,
+        {
+            {FALSE},
+        },
+        {FALSE},
+        0,S_OK,TRUE,
+        0,S_OK,TRUE,
+        0,0,0,S_OK,TRUE,
+        {
+            {"http://:[email protected]/",S_OK},
+            {":password at google.com",S_OK},
+            {"http://google.com/",S_OK},
+            {"google.com",S_OK},
+            {"",S_FALSE},
+            {"",S_FALSE},
+            {"google.com",S_OK},
+            {"password",S_OK},
+            {"/",S_OK},
+            {"/",S_OK},
+            {"",S_FALSE},
+            {"http://:[email protected]/",S_OK},
+            {"http",S_OK},
+            {":password",S_OK},
+            {"",S_FALSE}
+        },
+        {
+            {Uri_HOST_DNS,S_OK},
+            {80,S_OK},
+            {URL_SCHEME_HTTP,S_OK},
+            {URLZONE_INVALID,E_NOTIMPL}
+        }
     }
 };
 
diff --git a/dlls/urlmon/uri.c b/dlls/urlmon/uri.c
index 283c649..94be29b 100644
--- a/dlls/urlmon/uri.c
+++ b/dlls/urlmon/uri.c
@@ -100,6 +100,9 @@ typedef struct {
 
     WCHAR   *scheme;
     DWORD   scheme_len;
+
+    WCHAR   *username;
+    DWORD   username_len;
 } UriBuilder;
 
 typedef struct {
@@ -4383,6 +4386,7 @@ static ULONG WINAPI UriBuilder_Release(IUriBuilder *iface)
         heap_free(This->path);
         heap_free(This->query);
         heap_free(This->scheme);
+        heap_free(This->username);
         heap_free(This);
     }
 
@@ -4602,19 +4606,22 @@ static HRESULT WINAPI UriBuilder_GetUserName(IUriBuilder *iface, DWORD *pcchUser
     UriBuilder *This = URIBUILDER_THIS(iface);
     TRACE("(%p)->(%p %p)\n", This, pcchUserName, ppwzUserName);
 
-    if(!pcchUserName) {
-        if(ppwzUserName)
-            *ppwzUserName = NULL;
-        return E_POINTER;
-    }
+    if(!This->uri || This->uri->userinfo_start == -1 ||
+       This->uri->userinfo_start == This->uri->userinfo_split ||
+       This->modified_props & Uri_HAS_USER_NAME)
+        return get_builder_component(&This->username, &This->username_len, NULL, 0, ppwzUserName, pcchUserName);
+    else {
+        const WCHAR *start = This->uri->canon_uri+This->uri->userinfo_start;
 
-    if(!ppwzUserName) {
-        *pcchUserName = 0;
-        return E_POINTER;
+        /* Check if there's a password in the userinfo section. */
+        if(This->uri->userinfo_split > -1)
+            /* Don't include the password. */
+            return get_builder_component(&This->username, &This->username_len, start,
+                                         This->uri->userinfo_split, ppwzUserName, pcchUserName);
+        else
+            return get_builder_component(&This->username, &This->username_len, start,
+                                         This->uri->userinfo_len, ppwzUserName, pcchUserName);
     }
-
-    FIXME("(%p)->(%p %p)\n", This, pcchUserName, ppwzUserName);
-    return E_NOTIMPL;
 }
 
 static HRESULT WINAPI UriBuilder_SetFragment(IUriBuilder *iface, LPCWSTR pwzNewValue)
@@ -4679,8 +4686,9 @@ static HRESULT WINAPI UriBuilder_SetSchemeName(IUriBuilder *iface, LPCWSTR pwzNe
 static HRESULT WINAPI UriBuilder_SetUserName(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));
+    return set_builder_component(&This->username, &This->username_len, pwzNewValue, 0,
+                                 &This->modified_props, Uri_HAS_USER_NAME);
 }
 
 static HRESULT WINAPI UriBuilder_RemoveProperties(IUriBuilder *iface, DWORD dwPropertyMask)




More information about the wine-cvs mailing list