Thomas Mullaly : urlmon: Implemented functionality for retrieving the RAW_URI property of a IUri.

Alexandre Julliard julliard at winehq.org
Mon Jul 19 11:05:34 CDT 2010


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

Author: Thomas Mullaly <thomas.mullaly at gmail.com>
Date:   Tue Jul  6 16:19:58 2010 -0400

urlmon: Implemented functionality for retrieving the RAW_URI property of a IUri.

---

 dlls/urlmon/tests/uri.c |   24 ++++++++--------
 dlls/urlmon/uri.c       |   67 ++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 69 insertions(+), 22 deletions(-)

diff --git a/dlls/urlmon/tests/uri.c b/dlls/urlmon/tests/uri.c
index 31f22a5..a89e5c6 100644
--- a/dlls/urlmon/tests/uri.c
+++ b/dlls/urlmon/tests/uri.c
@@ -104,7 +104,7 @@ static const uri_properties uri_tests[] = {
             {"/",S_OK,TRUE},                                            /* PATH */
             {"/",S_OK,TRUE},                                            /* PATH_AND_QUERY */
             {"",S_FALSE,TRUE},                                          /* QUERY */
-            {"http://www.winehq.org/tests/../tests/../..",S_OK,TRUE},   /* RAW_URI */
+            {"http://www.winehq.org/tests/../tests/../..",S_OK,FALSE},  /* RAW_URI */
             {"http",S_OK,TRUE},                                         /* SCHEME_NAME */
             {"",S_FALSE,TRUE},                                          /* USER_INFO */
             {"",S_FALSE,TRUE}                                           /* USER_NAME */
@@ -133,7 +133,7 @@ static const uri_properties uri_tests[] = {
             {"/tests",S_OK,TRUE},
             {"/tests",S_OK,TRUE},
             {"",S_FALSE,TRUE},
-            {"http://winehq.org/tests/.././tests",S_OK,TRUE},
+            {"http://winehq.org/tests/.././tests",S_OK,FALSE},
             {"http",S_OK,TRUE},
             {"",S_FALSE,TRUE},
             {"",S_FALSE,TRUE}
@@ -162,7 +162,7 @@ static const uri_properties uri_tests[] = {
             {"/",S_OK,TRUE},
             {"/?query=x&return=y",S_OK,TRUE},
             {"?query=x&return=y",S_OK,TRUE},
-            {"HtTp://www.winehq.org/tests/..?query=x&return=y",S_OK,TRUE},
+            {"HtTp://www.winehq.org/tests/..?query=x&return=y",S_OK,FALSE},
             {"http",S_OK,TRUE},
             {"",S_FALSE,TRUE},
             {"",S_FALSE,TRUE}
@@ -191,7 +191,7 @@ static const uri_properties uri_tests[] = {
             {"/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,TRUE},
             {"/path/a/Forbidden'%3C%7C%3E%20Characters",S_OK,TRUE},
             {"",S_FALSE,TRUE},
-            {"hTTp://us%45r%3Ainfo@examp%4CE.com:80/path/a/b/./c/../%2E%2E/Forbidden'<|> Characters",S_OK,TRUE},
+            {"hTTp://us%45r%3Ainfo@examp%4CE.com:80/path/a/b/./c/../%2E%2E/Forbidden'<|> Characters",S_OK,FALSE},
             {"http",S_OK,TRUE},
             {"usEr%3Ainfo",S_OK,TRUE},
             {"usEr%3Ainfo",S_OK,TRUE}
@@ -221,7 +221,7 @@ static const uri_properties uri_tests[] = {
             {"/dir/foo%20bar.txt",S_OK,TRUE},
             {"/dir/foo%20bar.txt",S_OK,TRUE},
             {"",S_FALSE,TRUE},
-            {"ftp://winepass:[email protected]:9999/dir/foo bar.txt",S_OK,TRUE},
+            {"ftp://winepass:[email protected]:9999/dir/foo bar.txt",S_OK,FALSE},
             {"ftp",S_OK,TRUE},
             {"winepass:wine",S_OK,TRUE},
             {"winepass",S_OK,TRUE}
@@ -249,7 +249,7 @@ static const uri_properties uri_tests[] = {
             {"/c:/tests/foo%2520bar.mp3",S_OK,TRUE},
             {"/c:/tests/foo%2520bar.mp3",S_OK,TRUE},
             {"",S_FALSE,TRUE},
-            {"file://c:\\tests\\../tests/foo%20bar.mp3",S_OK,TRUE},
+            {"file://c:\\tests\\../tests/foo%20bar.mp3",S_OK,FALSE},
             {"file",S_OK,TRUE},
             {"",S_FALSE,TRUE},
             {"",S_FALSE,TRUE}
@@ -277,7 +277,7 @@ static const uri_properties uri_tests[] = {
             {"/tests/test%20file.README.txt",S_OK,TRUE},
             {"/tests/test%20file.README.txt",S_OK,TRUE},
             {"",S_FALSE,TRUE},
-            {"FILE://localhost/test dir\\../tests/test%20file.README.txt",S_OK,TRUE},
+            {"FILE://localhost/test dir\\../tests/test%20file.README.txt",S_OK,FALSE},
             {"file",S_OK,TRUE},
             {"",S_FALSE,TRUE},
             {"",S_FALSE,TRUE}
@@ -305,7 +305,7 @@ static const uri_properties uri_tests[] = {
             {"nothing:should:happen here",S_OK,TRUE},
             {"nothing:should:happen here",S_OK,TRUE},
             {"",S_FALSE,TRUE},
-            {"urn:nothing:should:happen here",S_OK,TRUE},
+            {"urn:nothing:should:happen here",S_OK,FALSE},
             {"urn",S_OK,TRUE},
             {"",S_FALSE,TRUE},
             {"",S_FALSE,TRUE}
@@ -334,7 +334,7 @@ static const uri_properties uri_tests[] = {
             {"/test%20dir/test.txt",S_OK,TRUE},
             {"/test%20dir/test.txt",S_OK,TRUE},
             {"",S_FALSE,TRUE},
-            {"http://127.0.0.1/tests/../test dir/./test.txt",S_OK,TRUE},
+            {"http://127.0.0.1/tests/../test dir/./test.txt",S_OK,FALSE},
             {"http",S_OK,TRUE},
             {"",S_FALSE,TRUE},
             {"",S_FALSE,TRUE}
@@ -363,7 +363,7 @@ static const uri_properties uri_tests[] = {
             {"/",S_OK,TRUE},
             {"/",S_OK,TRUE},
             {"",S_FALSE,TRUE},
-            {"http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]",S_OK,TRUE},
+            {"http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]",S_OK,FALSE},
             {"http",S_OK,TRUE},
             {"",S_FALSE,TRUE},
             {"",S_FALSE,TRUE}
@@ -392,7 +392,7 @@ static const uri_properties uri_tests[] = {
             {"/",S_OK,TRUE},
             {"/",S_OK,TRUE},
             {"",S_FALSE,TRUE},
-            {"ftp://[::13.1.68.3]",S_OK,TRUE},
+            {"ftp://[::13.1.68.3]",S_OK,FALSE},
             {"ftp",S_OK,TRUE},
             {"",S_FALSE,TRUE},
             {"",S_FALSE,TRUE}
@@ -421,7 +421,7 @@ static const uri_properties uri_tests[] = {
             {"/",S_OK,TRUE},
             {"/",S_OK,TRUE},
             {"",S_FALSE,TRUE},
-            {"http://[FEDC:BA98:0:0:0:0:0:3210]",S_OK,TRUE},
+            {"http://[FEDC:BA98:0:0:0:0:0:3210]",S_OK,FALSE},
             {"http",S_OK,TRUE},
             {"",S_FALSE,TRUE},
             {"",S_FALSE,TRUE},
diff --git a/dlls/urlmon/uri.c b/dlls/urlmon/uri.c
index df5ca8b..732ec44 100644
--- a/dlls/urlmon/uri.c
+++ b/dlls/urlmon/uri.c
@@ -25,6 +25,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
 typedef struct {
     const IUriVtbl  *lpIUriVtbl;
     LONG ref;
+
+    BSTR raw_uri;
 } Uri;
 
 typedef struct {
@@ -74,8 +76,10 @@ static ULONG WINAPI Uri_Release(IUri *iface)
 
     TRACE("(%p) ref=%d\n", This, ref);
 
-    if(!ref)
+    if(!ref) {
+        SysFreeString(This->raw_uri);
         heap_free(This);
+    }
 
     return ref;
 }
@@ -83,7 +87,8 @@ static ULONG WINAPI Uri_Release(IUri *iface)
 static HRESULT WINAPI Uri_GetPropertyBSTR(IUri *iface, Uri_PROPERTY uriProp, BSTR *pbstrProperty, DWORD dwFlags)
 {
     Uri *This = URI_THIS(iface);
-    FIXME("(%p)->(%d %p %x)\n", This, uriProp, pbstrProperty, dwFlags);
+    HRESULT hres;
+    TRACE("(%p)->(%d %p %x)\n", This, uriProp, pbstrProperty, dwFlags);
 
     if(!pbstrProperty)
         return E_POINTER;
@@ -99,13 +104,33 @@ static HRESULT WINAPI Uri_GetPropertyBSTR(IUri *iface, Uri_PROPERTY uriProp, BST
             return S_OK;
     }
 
-    return E_NOTIMPL;
+    /* Don't have support for flags yet. */
+    if(dwFlags) {
+        FIXME("(%p)->(%d %p %x)\n", This, uriProp, pbstrProperty, dwFlags);
+        return E_NOTIMPL;
+    }
+
+    switch(uriProp) {
+    case Uri_PROPERTY_RAW_URI:
+        *pbstrProperty = SysAllocString(This->raw_uri);
+        if(!(*pbstrProperty))
+            hres = E_OUTOFMEMORY;
+        else
+            hres = S_OK;
+        break;
+    default:
+        FIXME("(%p)->(%d %p %x)\n", This, uriProp, pbstrProperty, dwFlags);
+        hres = E_NOTIMPL;
+    }
+
+    return hres;
 }
 
 static HRESULT WINAPI Uri_GetPropertyLength(IUri *iface, Uri_PROPERTY uriProp, DWORD *pcchProperty, DWORD dwFlags)
 {
     Uri *This = URI_THIS(iface);
-    FIXME("(%p)->(%d %p %x)\n", This, uriProp, pcchProperty, dwFlags);
+    HRESULT hres;
+    TRACE("(%p)->(%d %p %x)\n", This, uriProp, pcchProperty, dwFlags);
 
     if(!pcchProperty)
         return E_INVALIDARG;
@@ -114,7 +139,23 @@ static HRESULT WINAPI Uri_GetPropertyLength(IUri *iface, Uri_PROPERTY uriProp, D
     if(uriProp > Uri_PROPERTY_STRING_LAST)
         return E_INVALIDARG;
 
-    return E_NOTIMPL;
+    /* Don't have support for flags yet. */
+    if(dwFlags) {
+        FIXME("(%p)->(%d %p %x)\n", This, uriProp, pcchProperty, dwFlags);
+        return E_NOTIMPL;
+    }
+
+    switch(uriProp) {
+    case Uri_PROPERTY_RAW_URI:
+        *pcchProperty = SysStringLen(This->raw_uri);
+        hres = S_OK;
+        break;
+    default:
+        FIXME("(%p)->(%d %p %x)\n", This, uriProp, pcchProperty, dwFlags);
+        hres = E_NOTIMPL;
+    }
+
+    return hres;
 }
 
 static HRESULT WINAPI Uri_GetPropertyDWORD(IUri *iface, Uri_PROPERTY uriProp, DWORD *pcchProperty, DWORD dwFlags)
@@ -278,12 +319,10 @@ static HRESULT WINAPI Uri_GetQuery(IUri *iface, BSTR *pstrQuery)
 static HRESULT WINAPI Uri_GetRawUri(IUri *iface, BSTR *pstrRawUri)
 {
     Uri *This = URI_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, pstrRawUri);
-
-    if(!pstrRawUri)
-        return E_POINTER;
+    TRACE("(%p)->(%p)\n", This, pstrRawUri);
 
-    return E_NOTIMPL;
+    /* Just forward the call to GetPropertyBSTR. */
+    return Uri_GetPropertyBSTR(iface, Uri_PROPERTY_RAW_URI, pstrRawUri, 0);
 }
 
 static HRESULT WINAPI Uri_GetSchemeName(IUri *iface, BSTR *pstrSchemeName)
@@ -454,6 +493,14 @@ HRESULT WINAPI CreateUri(LPCWSTR pwzURI, DWORD dwFlags, DWORD_PTR dwReserved, IU
     ret->lpIUriVtbl = &UriVtbl;
     ret->ref = 1;
 
+    /* Create a copy of pwzURI and store it as the raw_uri. */
+    ret->raw_uri = SysAllocString(pwzURI);
+
+    if(!ret->raw_uri) {
+        heap_free(ret);
+        return E_OUTOFMEMORY;
+    }
+
     *ppURI = URI(ret);
     return S_OK;
 }




More information about the wine-cvs mailing list