Jacek Caban : urlmon: Make get_protocol_handler IUri-based.

Alexandre Julliard julliard at winehq.org
Mon Nov 15 13:28:54 CST 2010


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Nov 15 12:37:35 2010 +0100

urlmon: Make get_protocol_handler IUri-based.

---

 dlls/urlmon/bindprot.c    |    9 +--------
 dlls/urlmon/session.c     |   29 ++++++++++++++++-------------
 dlls/urlmon/urlmon_main.h |    2 +-
 3 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/dlls/urlmon/bindprot.c b/dlls/urlmon/bindprot.c
index 4acef40..68e1dec 100644
--- a/dlls/urlmon/bindprot.c
+++ b/dlls/urlmon/bindprot.c
@@ -541,15 +541,8 @@ static HRESULT WINAPI BindProtocol_StartEx(IInternetProtocolEx *iface, IUri *pUr
     if(!protocol) {
         IClassFactory *cf;
         IUnknown *unk;
-        BSTR raw_uri;
 
-        /* FIXME: Avoid GetRawUri here */
-        hres = IUri_GetRawUri(pUri, &raw_uri);
-        if(FAILED(hres))
-            return hres;
-
-        hres = get_protocol_handler(raw_uri, &clsid, &urlmon_protocol, &cf);
-        SysFreeString(raw_uri);
+        hres = get_protocol_handler(pUri, &clsid, &urlmon_protocol, &cf);
         if(FAILED(hres))
             return hres;
 
diff --git a/dlls/urlmon/session.c b/dlls/urlmon/session.c
index 4c9281a..72a3e2a 100644
--- a/dlls/urlmon/session.c
+++ b/dlls/urlmon/session.c
@@ -236,23 +236,22 @@ IInternetProtocolInfo *get_protocol_info(LPCWSTR url)
     return ret;
 }
 
-HRESULT get_protocol_handler(LPCWSTR url, CLSID *clsid, BOOL *urlmon_protocol, IClassFactory **ret)
+HRESULT get_protocol_handler(IUri *uri, CLSID *clsid, BOOL *urlmon_protocol, IClassFactory **ret)
 {
     name_space *ns;
-    WCHAR schema[64];
-    DWORD schema_len;
+    BSTR scheme;
     HRESULT hres;
 
     *ret = NULL;
 
-    hres = CoInternetParseUrl(url, PARSE_SCHEMA, 0, schema, sizeof(schema)/sizeof(schema[0]),
-            &schema_len, 0);
-    if(FAILED(hres) || !schema_len)
-        return schema_len ? hres : MK_E_SYNTAX;
+    /* FIXME: Avoid GetSchemeName call for known schemes */
+    hres = IUri_GetSchemeName(uri, &scheme);
+    if(FAILED(hres))
+        return hres;
 
     EnterCriticalSection(&session_cs);
 
-    ns = find_name_space(schema);
+    ns = find_name_space(scheme);
     if(ns) {
         *ret = ns->cf;
         IClassFactory_AddRef(*ret);
@@ -264,12 +263,16 @@ HRESULT get_protocol_handler(LPCWSTR url, CLSID *clsid, BOOL *urlmon_protocol, I
 
     LeaveCriticalSection(&session_cs);
 
-    if(*ret)
-        return S_OK;
+    if(*ret) {
+        hres = S_OK;
+    }else {
+        if(urlmon_protocol)
+            *urlmon_protocol = FALSE;
+        hres = get_protocol_cf(scheme, SysStringLen(scheme), clsid, ret);
+    }
 
-    if(urlmon_protocol)
-        *urlmon_protocol = FALSE;
-    return get_protocol_cf(schema, schema_len, clsid, ret);
+    SysFreeString(scheme);
+    return hres;
 }
 
 IInternetProtocol *get_mime_filter(LPCWSTR mime)
diff --git a/dlls/urlmon/urlmon_main.h b/dlls/urlmon/urlmon_main.h
index 239182e..2d719cb 100644
--- a/dlls/urlmon/urlmon_main.h
+++ b/dlls/urlmon/urlmon_main.h
@@ -66,7 +66,7 @@ static inline void URLMON_UnlockModule(void) { InterlockedDecrement( &URLMON_ref
 #define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface)
 
 IInternetProtocolInfo *get_protocol_info(LPCWSTR);
-HRESULT get_protocol_handler(LPCWSTR,CLSID*,BOOL*,IClassFactory**);
+HRESULT get_protocol_handler(IUri*,CLSID*,BOOL*,IClassFactory**);
 IInternetProtocol *get_mime_filter(LPCWSTR);
 BOOL is_registered_protocol(LPCWSTR);
 void register_urlmon_namespace(IClassFactory*,REFIID,LPCWSTR,BOOL);




More information about the wine-cvs mailing list