From 9fb647ef006512530c58007dbbe63b525487f05b Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 24 May 2006 17:59:07 +0200 Subject: [PATCH] urlmon: Added [Un]RegisterNamespace implementation. --- dlls/urlmon/session.c | 67 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 5 deletions(-) diff --git a/dlls/urlmon/session.c b/dlls/urlmon/session.c index 4cc38a1986c..4a1a9b302ca 100644 --- a/dlls/urlmon/session.c +++ b/dlls/urlmon/session.c @@ -29,9 +29,19 @@ #include "urlmon_main.h" #include "wine/debug.h" +#include "wine/unicode.h" WINE_DEFAULT_DEBUG_CHANNEL(urlmon); +typedef struct name_space { + LPWSTR protocol; + IClassFactory *cf; + + struct name_space *next; +} name_space; + +static name_space *name_space_list = NULL; + HRESULT get_protocol_iface(LPCWSTR url, IUnknown **ret) { WCHAR schema[64], str_clsid[64]; @@ -111,16 +121,63 @@ static HRESULT WINAPI InternetSession_RegisterNameSpace(IInternetSession *iface, IClassFactory *pCF, REFCLSID rclsid, LPCWSTR pwzProtocol, ULONG cPatterns, const LPCWSTR *ppwzPatterns, DWORD dwReserved) { - FIXME("(%p %s %s %ld %p %ld)\n", pCF, debugstr_guid(rclsid), debugstr_w(pwzProtocol), - cPatterns, ppwzPatterns, dwReserved); - return E_NOTIMPL; + name_space *new_name_space; + int size; + + TRACE("(%p %s %s %ld %p %ld)\n", pCF, debugstr_guid(rclsid), debugstr_w(pwzProtocol), + cPatterns, ppwzPatterns, dwReserved); + + if(cPatterns || ppwzPatterns) + FIXME("patterns not supported\n"); + if(dwReserved) + WARN("dwReserved = %ld\n", dwReserved); + + if(!pCF || !pwzProtocol) + return E_INVALIDARG; + + new_name_space = HeapAlloc(GetProcessHeap(), 0, sizeof(name_space)); + + size = (strlenW(pwzProtocol)+1)*sizeof(WCHAR); + new_name_space->protocol = HeapAlloc(GetProcessHeap(), 0, size); + memcpy(new_name_space->protocol, pwzProtocol, size); + + IClassFactory_AddRef(pCF); + new_name_space->cf = pCF; + + new_name_space->next = name_space_list; + name_space_list = new_name_space; + return S_OK; } static HRESULT WINAPI InternetSession_UnregisterNameSpace(IInternetSession *iface, IClassFactory *pCF, LPCWSTR pszProtocol) { - FIXME("(%p %s)\n", pCF, debugstr_w(pszProtocol)); - return E_NOTIMPL; + name_space *iter, *last = NULL; + + TRACE("(%p %s)\n", pCF, debugstr_w(pszProtocol)); + + if(!pCF || !pszProtocol) + return E_INVALIDARG; + + for(iter = name_space_list; iter; iter = iter->next) { + if(iter->cf == pCF && !strcmpW(iter->protocol, pszProtocol)) + break; + last = iter; + } + + if(!iter) + return S_OK; + + if(last) + last->next = iter->next; + else + name_space_list = iter->next; + + IClassFactory_Release(iter->cf); + HeapFree(GetProcessHeap(), 0, iter->protocol); + HeapFree(GetProcessHeap(), 0, iter); + + return S_OK; } static HRESULT WINAPI InternetSession_RegisterMimeFilter(IInternetSession *iface,