From 8a669c9a1905c33af6dacd7ce116d024a3072a51 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 28 Dec 2007 02:00:10 +0100 Subject: [PATCH] urlmon: Added [Un]RegisterMimeFilter implementation. --- dlls/urlmon/session.c | 53 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/dlls/urlmon/session.c b/dlls/urlmon/session.c index f5a644f4cb3..a63509c9b2a 100644 --- a/dlls/urlmon/session.c +++ b/dlls/urlmon/session.c @@ -31,7 +31,16 @@ typedef struct name_space { struct name_space *next; } name_space; +typedef struct mime_filter { + IClassFactory *cf; + CLSID clsid; + LPWSTR mime; + + struct mime_filter *next; +} mime_filter; + static name_space *name_space_list = NULL; +static mime_filter *mime_filter_list = NULL; static name_space *find_name_space(LPCWSTR protocol) { @@ -200,8 +209,8 @@ static HRESULT WINAPI InternetSession_RegisterNameSpace(IInternetSession *iface, IClassFactory_AddRef(pCF); new_name_space->cf = pCF; - new_name_space->protocol = heap_strdupW(pwzProtocol); new_name_space->clsid = *rclsid; + new_name_space->protocol = heap_strdupW(pwzProtocol); new_name_space->next = name_space_list; name_space_list = new_name_space; @@ -242,15 +251,49 @@ static HRESULT WINAPI InternetSession_UnregisterNameSpace(IInternetSession *ifac static HRESULT WINAPI InternetSession_RegisterMimeFilter(IInternetSession *iface, IClassFactory *pCF, REFCLSID rclsid, LPCWSTR pwzType) { - FIXME("(%p %s %s)\n", pCF, debugstr_guid(rclsid), debugstr_w(pwzType)); - return E_NOTIMPL; + mime_filter *filter; + + TRACE("(%p %s %s)\n", pCF, debugstr_guid(rclsid), debugstr_w(pwzType)); + + filter = heap_alloc(sizeof(mime_filter)); + + IClassFactory_AddRef(pCF); + filter->cf = pCF; + filter->clsid = *rclsid; + filter->mime = heap_strdupW(pwzType); + + filter->next = mime_filter_list; + mime_filter_list = filter; + + return S_OK; } static HRESULT WINAPI InternetSession_UnregisterMimeFilter(IInternetSession *iface, IClassFactory *pCF, LPCWSTR pwzType) { - FIXME("(%p %s)\n", pCF, debugstr_w(pwzType)); - return E_NOTIMPL; + mime_filter *iter, *prev = NULL; + + TRACE("(%p %s)\n", pCF, debugstr_w(pwzType)); + + for(iter = mime_filter_list; iter; iter = iter->next) { + if(iter->cf == pCF && !strcmpW(iter->mime, pwzType)) + break; + prev = iter; + } + + if(!iter) + return S_OK; + + if(prev) + prev->next = iter->next; + else + mime_filter_list = iter->next; + + IClassFactory_Release(iter->cf); + heap_free(iter->mime); + heap_free(iter); + + return S_OK; } static HRESULT WINAPI InternetSession_CreateBinding(IInternetSession *iface,