From 7ea9c7d3e182928ef996c14e0878b8dfc90b9f54 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 20 Feb 2008 21:30:51 +0100 Subject: [PATCH] mshtml: Added nsINetUtil interface to nsIOService. --- dlls/mshtml/nsiface.idl | 12 ++++++ dlls/mshtml/nsio.c | 82 +++++++++++++++++++++++++++++++++-------- 2 files changed, 79 insertions(+), 15 deletions(-) diff --git a/dlls/mshtml/nsiface.idl b/dlls/mshtml/nsiface.idl index ad2ab235fbf..2f60cdaa852 100644 --- a/dlls/mshtml/nsiface.idl +++ b/dlls/mshtml/nsiface.idl @@ -1701,6 +1701,18 @@ interface nsIIOService : nsISupports nsresult ExtractScheme(const nsACString *urlString, nsACString * _retval); } +[ + object, + uuid(f0c5dddb-4713-4603-af2d-bf671838996b), + local, + /* NOT_FROZEN */ +] +interface nsINetUtil : nsISupports +{ + nsresult ParseContentType(const nsACString *aTypeHeader, nsACString *aCharset, + PRBool *aHadCharset, nsACString *aContentType); +} + [ object, uuid(9c5d3c58-1dd1-11b2-a1c9-f3699284657a), diff --git a/dlls/mshtml/nsio.c b/dlls/mshtml/nsio.c index 2e62a44bf5b..89fe6eca18b 100644 --- a/dlls/mshtml/nsio.c +++ b/dlls/mshtml/nsio.c @@ -1926,21 +1926,7 @@ static nsIProtocolHandler *create_protocol_handler(nsIProtocolHandler *nshandler return NSPROTHANDLER(ret); } -static nsresult NSAPI nsIOService_QueryInterface(nsIIOService *iface, nsIIDRef riid, - nsQIResult result) -{ - *result = NULL; - - if(IsEqualGUID(&IID_nsISupports, riid) - || IsEqualGUID(&IID_nsIIOService, riid)) { - *result = iface; - nsIIOService_AddRef(iface); - return S_OK; - } - - WARN("(%s %p)\n", debugstr_guid(riid), result); - return NS_NOINTERFACE; -} +static nsresult NSAPI nsIOService_QueryInterface(nsIIOService*,nsIIDRef,nsQIResult); static nsrefcnt NSAPI nsIOService_AddRef(nsIIOService *iface) { @@ -2198,6 +2184,72 @@ static const nsIIOServiceVtbl nsIOServiceVtbl = { static nsIIOService nsIOService = { &nsIOServiceVtbl }; +static nsresult NSAPI nsNetUtil_QueryInterface(nsINetUtil *iface, nsIIDRef riid, + nsQIResult result) +{ + return nsIIOService_QueryInterface(&nsIOService, riid, result); +} + +static nsrefcnt NSAPI nsNetUtil_AddRef(nsINetUtil *iface) +{ + return 2; +} + +static nsrefcnt NSAPI nsNetUtil_Release(nsINetUtil *iface) +{ + return 1; +} + +static nsresult NSAPI nsNetUtil_ParseContentType(nsINetUtil *iface, const nsACString *aTypeHeader, + nsACString *aCharset, PRBool *aHadCharset, nsACString *aContentType) +{ + nsINetUtil *net_util; + nsresult nsres; + + TRACE("(%p %p %p %p)\n", aTypeHeader, aCharset, aHadCharset, aContentType); + + nsres = nsIIOService_QueryInterface(nsio, &IID_nsINetUtil, (void**)&net_util); + if(NS_FAILED(nsres)) { + WARN("Could not get nsINetUtil interface: %08x\n", nsres); + return nsres; + } + + nsres = nsINetUtil_ParseContentType(net_util, aTypeHeader, aCharset, aHadCharset, aContentType); + + nsINetUtil_Release(net_util); + return nsres; +} + +static const nsINetUtilVtbl nsNetUtilVtbl = { + nsNetUtil_QueryInterface, + nsNetUtil_AddRef, + nsNetUtil_Release, + nsNetUtil_ParseContentType +}; + +static nsINetUtil nsNetUtil = { &nsNetUtilVtbl }; + +static nsresult NSAPI nsIOService_QueryInterface(nsIIOService *iface, nsIIDRef riid, + nsQIResult result) +{ + *result = NULL; + + if(IsEqualGUID(&IID_nsISupports, riid)) + *result = &nsIOService; + else if(IsEqualGUID(&IID_nsIIOService, riid)) + *result = &nsIOService; + else if(IsEqualGUID(&IID_nsINetUtil, riid)) + *result = &nsNetUtil; + + if(*result) { + nsISupports_AddRef((nsISupports*)*result); + return NS_OK; + } + + FIXME("(%s %p)\n", debugstr_guid(riid), result); + return NS_NOINTERFACE; +} + static nsresult NSAPI nsIOServiceFactory_QueryInterface(nsIFactory *iface, nsIIDRef riid, nsQIResult result) {