2 * Copyright 2006-2007 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
34 #include "wine/debug.h"
35 #include "wine/unicode.h"
37 #include "mshtml_private.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
41 #define NS_IOSERVICE_CLASSNAME "nsIOService"
42 #define NS_IOSERVICE_CONTRACTID "@mozilla.org/network/io-service;1"
44 static const IID NS_IOSERVICE_CID
=
45 {0x9ac9e770, 0x18bc, 0x11d3, {0x93, 0x37, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40}};
46 static const IID IID_nsWineURI
=
47 {0x5088272e, 0x900b, 0x11da, {0xc6,0x87, 0x00,0x0f,0xea,0x57,0xf2,0x1a}};
49 static nsIIOService
*nsio
= NULL
;
50 static nsINetUtil
*net_util
;
52 static const WCHAR about_blankW
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
55 const nsIURLVtbl
*lpIURLVtbl
;
61 NSContainer
*container
;
62 windowref_t
*window_ref
;
63 nsChannelBSC
*channel_bsc
;
69 #define NSURI(x) ((nsIURI*) &(x)->lpIURLVtbl)
70 #define NSURL(x) ((nsIURL*) &(x)->lpIURLVtbl)
72 static nsresult
create_uri(nsIURI
*,HTMLWindow
*,NSContainer
*,nsWineURI
**);
74 static const char *debugstr_nsacstr(const nsACString
*nsstr
)
78 nsACString_GetData(nsstr
, &data
);
79 return debugstr_a(data
);
82 HRESULT
nsuri_to_url(LPCWSTR nsuri
, BOOL ret_empty
, BSTR
*ret
)
84 const WCHAR
*ptr
= nsuri
;
86 static const WCHAR wine_prefixW
[] = {'w','i','n','e',':'};
88 if(!strncmpW(nsuri
, wine_prefixW
, sizeof(wine_prefixW
)/sizeof(WCHAR
)))
89 ptr
+= sizeof(wine_prefixW
)/sizeof(WCHAR
);
91 if(*ptr
|| ret_empty
) {
92 *ret
= SysAllocString(ptr
);
99 TRACE("%s -> %s\n", debugstr_w(nsuri
), debugstr_w(*ret
));
103 static BOOL
exec_shldocvw_67(HTMLDocumentObj
*doc
, LPCWSTR url
)
105 IOleCommandTarget
*cmdtrg
= NULL
;
108 hres
= IOleClientSite_QueryInterface(doc
->client
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
109 if(SUCCEEDED(hres
)) {
110 VARIANT varUrl
, varRes
;
112 V_VT(&varUrl
) = VT_BSTR
;
113 V_BSTR(&varUrl
) = SysAllocString(url
);
114 V_VT(&varRes
) = VT_BOOL
;
116 hres
= IOleCommandTarget_Exec(cmdtrg
, &CGID_ShellDocView
, 67, 0, &varUrl
, &varRes
);
118 IOleCommandTarget_Release(cmdtrg
);
119 SysFreeString(V_BSTR(&varUrl
));
121 if(SUCCEEDED(hres
) && !V_BOOL(&varRes
)) {
122 TRACE("got VARIANT_FALSE, do not load\n");
130 static BOOL
before_async_open(nsChannel
*channel
, NSContainer
*container
)
132 HTMLDocumentObj
*doc
= container
->doc
;
138 NSContainer
*container_iter
= container
;
140 hlnf
= HLNF_OPENINNEWWINDOW
;
141 while(!container_iter
->doc
)
142 container_iter
= container_iter
->parent
;
143 doc
= container_iter
->doc
;
149 if(!hlnf
&& !exec_shldocvw_67(doc
, channel
->uri
->wine_url
))
152 hres
= hlink_frame_navigate(&doc
->basedoc
, channel
->uri
->wine_url
, channel
->post_data_stream
, hlnf
, &cancel
);
153 return FAILED(hres
) || cancel
;
156 HRESULT
load_nsuri(HTMLWindow
*window
, nsWineURI
*uri
, nsChannelBSC
*channelbsc
, DWORD flags
)
158 nsIWebNavigation
*web_navigation
;
159 nsIDocShell
*doc_shell
;
162 nsres
= get_nsinterface((nsISupports
*)window
->nswindow
, &IID_nsIWebNavigation
, (void**)&web_navigation
);
163 if(NS_FAILED(nsres
)) {
164 ERR("Could not get nsIWebNavigation interface: %08x\n", nsres
);
168 nsres
= nsIWebNavigation_QueryInterface(web_navigation
, &IID_nsIDocShell
, (void**)&doc_shell
);
169 nsIWebNavigation_Release(web_navigation
);
170 if(NS_FAILED(nsres
)) {
171 ERR("Could not get nsIDocShell: %08x\n", nsres
);
176 uri
->channel_bsc
= channelbsc
;
177 nsres
= nsIDocShell_LoadURI(doc_shell
, NSURI(uri
), NULL
, flags
, FALSE
);
178 uri
->channel_bsc
= NULL
;
179 nsIDocShell_Release(doc_shell
);
180 if(NS_FAILED(nsres
)) {
181 WARN("LoadURI failed: %08x\n", nsres
);
188 static BOOL
translate_url(HTMLDocumentObj
*doc
, nsWineURI
*uri
)
190 OLECHAR
*new_url
= NULL
, *url
;
197 url
= heap_strdupW(uri
->wine_url
);
198 hres
= IDocHostUIHandler_TranslateUrl(doc
->hostui
, 0, url
, &new_url
);
199 if(hres
== S_OK
&& new_url
) {
200 if(strcmpW(url
, new_url
)) {
201 FIXME("TranslateUrl returned new URL %s -> %s\n", debugstr_w(url
), debugstr_w(new_url
));
204 CoTaskMemFree(new_url
);
211 nsresult
on_start_uri_open(NSContainer
*nscontainer
, nsIURI
*uri
, PRBool
*_retval
)
218 nsres
= nsIURI_QueryInterface(uri
, &IID_nsWineURI
, (void**)&wine_uri
);
219 if(NS_FAILED(nsres
)) {
220 WARN("Could not get nsWineURI: %08x\n", nsres
);
221 return NS_ERROR_NOT_IMPLEMENTED
;
224 if(!wine_uri
->is_doc_uri
) {
225 if(!wine_uri
->container
) {
226 nsIWebBrowserChrome_AddRef(NSWBCHROME(nscontainer
));
227 wine_uri
->container
= nscontainer
;
230 wine_uri
->is_doc_uri
= TRUE
;
231 *_retval
= translate_url(nscontainer
->doc
->basedoc
.doc_obj
, wine_uri
);
234 nsIURI_Release(NSURI(wine_uri
));
238 HRESULT
set_wine_url(nsWineURI
*This
, LPCWSTR url
)
240 static const WCHAR wszFtp
[] = {'f','t','p',':'};
241 static const WCHAR wszHttp
[] = {'h','t','t','p',':'};
242 static const WCHAR wszHttps
[] = {'h','t','t','p','s',':'};
244 TRACE("(%p)->(%s)\n", This
, debugstr_w(url
));
249 new_url
= heap_strdupW(url
);
251 return E_OUTOFMEMORY
;
252 heap_free(This
->wine_url
);
253 This
->wine_url
= new_url
;
256 /* FIXME: Always use wine url */
258 strncmpW(url
, wszFtp
, sizeof(wszFtp
)/sizeof(WCHAR
))
259 && strncmpW(url
, wszHttp
, sizeof(wszHttp
)/sizeof(WCHAR
))
260 && strncmpW(url
, wszHttps
, sizeof(wszHttps
)/sizeof(WCHAR
));
262 This
->use_wine_url
= TRUE
;
265 heap_free(This
->wine_url
);
266 This
->wine_url
= NULL
;
267 This
->use_wine_url
= FALSE
;
273 static void set_uri_nscontainer(nsWineURI
*This
, NSContainer
*nscontainer
)
275 if(This
->container
) {
276 if(This
->container
== nscontainer
)
278 TRACE("Changing %p -> %p\n", This
->container
, nscontainer
);
279 nsIWebBrowserChrome_Release(NSWBCHROME(This
->container
));
283 nsIWebBrowserChrome_AddRef(NSWBCHROME(nscontainer
));
284 This
->container
= nscontainer
;
287 static void set_uri_window(nsWineURI
*This
, HTMLWindow
*window
)
289 if(This
->window_ref
) {
290 if(This
->window_ref
->window
== window
)
292 TRACE("Changing %p -> %p\n", This
->window_ref
->window
, window
);
293 windowref_release(This
->window_ref
);
297 windowref_addref(window
->window_ref
);
298 This
->window_ref
= window
->window_ref
;
301 set_uri_nscontainer(This
, window
->doc_obj
->nscontainer
);
303 This
->window_ref
= NULL
;
307 static inline BOOL
is_http_channel(nsChannel
*This
)
309 return This
->url_scheme
== URL_SCHEME_HTTP
|| This
->url_scheme
== URL_SCHEME_HTTPS
;
312 #define NSCHANNEL_THIS(iface) DEFINE_THIS(nsChannel, HttpChannel, iface)
314 static nsresult NSAPI
nsChannel_QueryInterface(nsIHttpChannel
*iface
, nsIIDRef riid
, nsQIResult result
)
316 nsChannel
*This
= NSCHANNEL_THIS(iface
);
318 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
319 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
320 *result
= NSCHANNEL(This
);
321 }else if(IsEqualGUID(&IID_nsIRequest
, riid
)) {
322 TRACE("(%p)->(IID_nsIRequest %p)\n", This
, result
);
323 *result
= NSCHANNEL(This
);
324 }else if(IsEqualGUID(&IID_nsIChannel
, riid
)) {
325 TRACE("(%p)->(IID_nsIChannel %p)\n", This
, result
);
326 *result
= NSCHANNEL(This
);
327 }else if(IsEqualGUID(&IID_nsIHttpChannel
, riid
)) {
328 TRACE("(%p)->(IID_nsIHttpChannel %p)\n", This
, result
);
329 *result
= is_http_channel(This
) ? NSHTTPCHANNEL(This
) : NULL
;
330 }else if(IsEqualGUID(&IID_nsIUploadChannel
, riid
)) {
331 TRACE("(%p)->(IID_nsIUploadChannel %p)\n", This
, result
);
332 *result
= NSUPCHANNEL(This
);
333 }else if(IsEqualGUID(&IID_nsIHttpChannelInternal
, riid
)) {
334 TRACE("(%p)->(IID_nsIHttpChannelInternal %p)\n", This
, result
);
335 *result
= is_http_channel(This
) ? NSHTTPINTERNAL(This
) : NULL
;
337 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), result
);
342 nsIChannel_AddRef(NSCHANNEL(This
));
346 return NS_NOINTERFACE
;
349 static nsrefcnt NSAPI
nsChannel_AddRef(nsIHttpChannel
*iface
)
351 nsChannel
*This
= NSCHANNEL_THIS(iface
);
352 nsrefcnt ref
= InterlockedIncrement(&This
->ref
);
354 TRACE("(%p) ref=%d\n", This
, ref
);
359 static nsrefcnt NSAPI
nsChannel_Release(nsIHttpChannel
*iface
)
361 nsChannel
*This
= NSCHANNEL_THIS(iface
);
362 LONG ref
= InterlockedDecrement(&This
->ref
);
365 struct ResponseHeader
*header
, *next_hdr
;
367 nsIURI_Release(NSURI(This
->uri
));
369 nsISupports_Release(This
->owner
);
370 if(This
->post_data_stream
)
371 nsIInputStream_Release(This
->post_data_stream
);
373 nsILoadGroup_Release(This
->load_group
);
374 if(This
->notif_callback
)
375 nsIInterfaceRequestor_Release(This
->notif_callback
);
376 if(This
->original_uri
)
377 nsIURI_Release(This
->original_uri
);
378 heap_free(This
->content_type
);
379 heap_free(This
->charset
);
381 LIST_FOR_EACH_ENTRY_SAFE(header
, next_hdr
, &This
->response_headers
, struct ResponseHeader
, entry
) {
382 list_remove(&header
->entry
);
383 heap_free(header
->header
);
384 heap_free(header
->data
);
394 static nsresult NSAPI
nsChannel_GetName(nsIHttpChannel
*iface
, nsACString
*aName
)
396 nsChannel
*This
= NSCHANNEL_THIS(iface
);
398 FIXME("(%p)->(%p)\n", This
, aName
);
400 return NS_ERROR_NOT_IMPLEMENTED
;
403 static nsresult NSAPI
nsChannel_IsPending(nsIHttpChannel
*iface
, PRBool
*_retval
)
405 nsChannel
*This
= NSCHANNEL_THIS(iface
);
407 FIXME("(%p)->(%p)\n", This
, _retval
);
409 return NS_ERROR_NOT_IMPLEMENTED
;
412 static nsresult NSAPI
nsChannel_GetStatus(nsIHttpChannel
*iface
, nsresult
*aStatus
)
414 nsChannel
*This
= NSCHANNEL_THIS(iface
);
416 WARN("(%p)->(%p) returning NS_OK\n", This
, aStatus
);
418 return *aStatus
= NS_OK
;
421 static nsresult NSAPI
nsChannel_Cancel(nsIHttpChannel
*iface
, nsresult aStatus
)
423 nsChannel
*This
= NSCHANNEL_THIS(iface
);
425 FIXME("(%p)->(%08x)\n", This
, aStatus
);
427 return NS_ERROR_NOT_IMPLEMENTED
;
430 static nsresult NSAPI
nsChannel_Suspend(nsIHttpChannel
*iface
)
432 nsChannel
*This
= NSCHANNEL_THIS(iface
);
434 FIXME("(%p)\n", This
);
436 return NS_ERROR_NOT_IMPLEMENTED
;
439 static nsresult NSAPI
nsChannel_Resume(nsIHttpChannel
*iface
)
441 nsChannel
*This
= NSCHANNEL_THIS(iface
);
443 FIXME("(%p)\n", This
);
445 return NS_ERROR_NOT_IMPLEMENTED
;
448 static nsresult NSAPI
nsChannel_GetLoadGroup(nsIHttpChannel
*iface
, nsILoadGroup
**aLoadGroup
)
450 nsChannel
*This
= NSCHANNEL_THIS(iface
);
452 TRACE("(%p)->(%p)\n", This
, aLoadGroup
);
455 nsILoadGroup_AddRef(This
->load_group
);
457 *aLoadGroup
= This
->load_group
;
461 static nsresult NSAPI
nsChannel_SetLoadGroup(nsIHttpChannel
*iface
, nsILoadGroup
*aLoadGroup
)
463 nsChannel
*This
= NSCHANNEL_THIS(iface
);
465 TRACE("(%p)->(%p)\n", This
, aLoadGroup
);
468 nsILoadGroup_Release(This
->load_group
);
470 nsILoadGroup_AddRef(aLoadGroup
);
471 This
->load_group
= aLoadGroup
;
476 static nsresult NSAPI
nsChannel_GetLoadFlags(nsIHttpChannel
*iface
, nsLoadFlags
*aLoadFlags
)
478 nsChannel
*This
= NSCHANNEL_THIS(iface
);
480 TRACE("(%p)->(%p)\n", This
, aLoadFlags
);
482 *aLoadFlags
= This
->load_flags
;
486 static nsresult NSAPI
nsChannel_SetLoadFlags(nsIHttpChannel
*iface
, nsLoadFlags aLoadFlags
)
488 nsChannel
*This
= NSCHANNEL_THIS(iface
);
490 TRACE("(%p)->(%08x)\n", This
, aLoadFlags
);
492 This
->load_flags
= aLoadFlags
;
496 static nsresult NSAPI
nsChannel_GetOriginalURI(nsIHttpChannel
*iface
, nsIURI
**aOriginalURI
)
498 nsChannel
*This
= NSCHANNEL_THIS(iface
);
500 TRACE("(%p)->(%p)\n", This
, aOriginalURI
);
502 if(This
->original_uri
)
503 nsIURI_AddRef(This
->original_uri
);
505 *aOriginalURI
= This
->original_uri
;
509 static nsresult NSAPI
nsChannel_SetOriginalURI(nsIHttpChannel
*iface
, nsIURI
*aOriginalURI
)
511 nsChannel
*This
= NSCHANNEL_THIS(iface
);
513 TRACE("(%p)->(%p)\n", This
, aOriginalURI
);
515 if(This
->original_uri
)
516 nsIURI_Release(This
->original_uri
);
518 nsIURI_AddRef(aOriginalURI
);
519 This
->original_uri
= aOriginalURI
;
523 static nsresult NSAPI
nsChannel_GetURI(nsIHttpChannel
*iface
, nsIURI
**aURI
)
525 nsChannel
*This
= NSCHANNEL_THIS(iface
);
527 TRACE("(%p)->(%p)\n", This
, aURI
);
529 nsIURI_AddRef(NSURI(This
->uri
));
530 *aURI
= (nsIURI
*)This
->uri
;
535 static nsresult NSAPI
nsChannel_GetOwner(nsIHttpChannel
*iface
, nsISupports
**aOwner
)
537 nsChannel
*This
= NSCHANNEL_THIS(iface
);
539 TRACE("(%p)->(%p)\n", This
, aOwner
);
542 nsISupports_AddRef(This
->owner
);
543 *aOwner
= This
->owner
;
548 static nsresult NSAPI
nsChannel_SetOwner(nsIHttpChannel
*iface
, nsISupports
*aOwner
)
550 nsChannel
*This
= NSCHANNEL_THIS(iface
);
552 TRACE("(%p)->(%p)\n", This
, aOwner
);
555 nsISupports_AddRef(aOwner
);
557 nsISupports_Release(This
->owner
);
558 This
->owner
= aOwner
;
563 static nsresult NSAPI
nsChannel_GetNotificationCallbacks(nsIHttpChannel
*iface
,
564 nsIInterfaceRequestor
**aNotificationCallbacks
)
566 nsChannel
*This
= NSCHANNEL_THIS(iface
);
568 TRACE("(%p)->(%p)\n", This
, aNotificationCallbacks
);
570 if(This
->notif_callback
)
571 nsIInterfaceRequestor_AddRef(This
->notif_callback
);
572 *aNotificationCallbacks
= This
->notif_callback
;
577 static nsresult NSAPI
nsChannel_SetNotificationCallbacks(nsIHttpChannel
*iface
,
578 nsIInterfaceRequestor
*aNotificationCallbacks
)
580 nsChannel
*This
= NSCHANNEL_THIS(iface
);
582 TRACE("(%p)->(%p)\n", This
, aNotificationCallbacks
);
584 if(This
->notif_callback
)
585 nsIInterfaceRequestor_Release(This
->notif_callback
);
586 if(aNotificationCallbacks
)
587 nsIInterfaceRequestor_AddRef(aNotificationCallbacks
);
589 This
->notif_callback
= aNotificationCallbacks
;
594 static nsresult NSAPI
nsChannel_GetSecurityInfo(nsIHttpChannel
*iface
, nsISupports
**aSecurityInfo
)
596 nsChannel
*This
= NSCHANNEL_THIS(iface
);
598 TRACE("(%p)->(%p)\n", This
, aSecurityInfo
);
600 return NS_ERROR_NOT_IMPLEMENTED
;
603 static nsresult NSAPI
nsChannel_GetContentType(nsIHttpChannel
*iface
, nsACString
*aContentType
)
605 nsChannel
*This
= NSCHANNEL_THIS(iface
);
607 TRACE("(%p)->(%p)\n", This
, aContentType
);
609 if(This
->content_type
) {
610 nsACString_SetData(aContentType
, This
->content_type
);
614 WARN("unknown type\n");
615 return NS_ERROR_FAILURE
;
618 static nsresult NSAPI
nsChannel_SetContentType(nsIHttpChannel
*iface
,
619 const nsACString
*aContentType
)
621 nsChannel
*This
= NSCHANNEL_THIS(iface
);
622 const char *content_type
;
624 TRACE("(%p)->(%p)\n", This
, aContentType
);
626 nsACString_GetData(aContentType
, &content_type
);
628 TRACE("content_type %s\n", content_type
);
630 heap_free(This
->content_type
);
631 This
->content_type
= heap_strdupA(content_type
);
636 static nsresult NSAPI
nsChannel_GetContentCharset(nsIHttpChannel
*iface
,
637 nsACString
*aContentCharset
)
639 nsChannel
*This
= NSCHANNEL_THIS(iface
);
641 TRACE("(%p)->(%p)\n", This
, aContentCharset
);
644 nsACString_SetData(aContentCharset
, This
->charset
);
648 nsACString_SetData(aContentCharset
, "");
652 static nsresult NSAPI
nsChannel_SetContentCharset(nsIHttpChannel
*iface
,
653 const nsACString
*aContentCharset
)
655 nsChannel
*This
= NSCHANNEL_THIS(iface
);
657 FIXME("(%p)->(%p)\n", This
, aContentCharset
);
659 return NS_ERROR_NOT_IMPLEMENTED
;
662 static nsresult NSAPI
nsChannel_GetContentLength(nsIHttpChannel
*iface
, PRInt32
*aContentLength
)
664 nsChannel
*This
= NSCHANNEL_THIS(iface
);
666 FIXME("(%p)->(%p)\n", This
, aContentLength
);
668 return NS_ERROR_NOT_IMPLEMENTED
;
671 static nsresult NSAPI
nsChannel_SetContentLength(nsIHttpChannel
*iface
, PRInt32 aContentLength
)
673 nsChannel
*This
= NSCHANNEL_THIS(iface
);
675 FIXME("(%p)->(%d)\n", This
, aContentLength
);
677 return NS_ERROR_NOT_IMPLEMENTED
;
680 static nsresult NSAPI
nsChannel_Open(nsIHttpChannel
*iface
, nsIInputStream
**_retval
)
682 nsChannel
*This
= NSCHANNEL_THIS(iface
);
684 FIXME("(%p)->(%p)\n", This
, _retval
);
686 return NS_ERROR_NOT_IMPLEMENTED
;
689 static HRESULT
create_mon_for_nschannel(nsChannel
*channel
, IMoniker
**mon
)
695 if(!channel
->original_uri
) {
696 ERR("original_uri == NULL\n");
700 nsres
= nsIURI_QueryInterface(channel
->original_uri
, &IID_nsWineURI
, (void**)&wine_uri
);
701 if(NS_FAILED(nsres
)) {
702 ERR("Could not get nsWineURI: %08x\n", nsres
);
706 if(wine_uri
->wine_url
) {
707 hres
= CreateURLMoniker(NULL
, wine_uri
->wine_url
, mon
);
709 WARN("CreateURLMoniker failed: %08x\n", hres
);
711 TRACE("wine_url == NULL\n");
715 nsIURI_Release(NSURI(wine_uri
));
720 static HTMLWindow
*get_window_from_load_group(nsChannel
*This
)
729 nsres
= nsILoadGroup_GetDefaultLoadRequest(This
->load_group
, &req
);
730 if(NS_FAILED(nsres
)) {
731 ERR("GetDefaultLoadRequest failed: %08x\n", nsres
);
738 nsres
= nsIRequest_QueryInterface(req
, &IID_nsIChannel
, (void**)&channel
);
739 nsIRequest_Release(req
);
740 if(NS_FAILED(nsres
)) {
741 WARN("Could not get nsIChannel interface: %08x\n", nsres
);
745 nsres
= nsIChannel_GetURI(channel
, &uri
);
746 nsIChannel_Release(channel
);
747 if(NS_FAILED(nsres
)) {
748 ERR("GetURI failed: %08x\n", nsres
);
752 nsres
= nsIURI_QueryInterface(uri
, &IID_nsWineURI
, (void**)&wine_uri
);
754 if(NS_FAILED(nsres
)) {
755 TRACE("Could not get nsWineURI: %08x\n", nsres
);
759 window
= wine_uri
->window_ref
? wine_uri
->window_ref
->window
: NULL
;
761 IHTMLWindow2_AddRef(HTMLWINDOW2(window
));
762 nsIURI_Release(NSURI(wine_uri
));
767 static HTMLWindow
*get_channel_window(nsChannel
*This
)
769 nsIRequestObserver
*req_observer
;
770 nsIWebProgress
*web_progress
;
771 nsIDOMWindow
*nswindow
;
775 if(!This
->load_group
) {
776 ERR("NULL load_group\n");
780 nsres
= nsILoadGroup_GetGroupObserver(This
->load_group
, &req_observer
);
781 if(NS_FAILED(nsres
) || !req_observer
) {
782 ERR("GetGroupObserver failed: %08x\n", nsres
);
786 nsres
= nsIRequestObserver_QueryInterface(req_observer
, &IID_nsIWebProgress
, (void**)&web_progress
);
787 nsIRequestObserver_Release(req_observer
);
788 if(NS_FAILED(nsres
)) {
789 ERR("Could not get nsIWebProgress iface: %08x\n", nsres
);
793 nsres
= nsIWebProgress_GetDOMWindow(web_progress
, &nswindow
);
794 nsIWebProgress_Release(web_progress
);
795 if(NS_FAILED(nsres
) || !nswindow
) {
796 ERR("GetDOMWindow failed: %08x\n", nsres
);
800 window
= nswindow_to_window(nswindow
);
801 nsIDOMWindow_Release(nswindow
);
804 IHTMLWindow2_AddRef(HTMLWINDOW2(window
));
806 FIXME("NULL window for %p\n", nswindow
);
812 HTMLDocumentNode
*doc
;
813 nsChannelBSC
*bscallback
;
814 } start_binding_task_t
;
816 static void start_binding_proc(task_t
*_task
)
818 start_binding_task_t
*task
= (start_binding_task_t
*)_task
;
820 start_binding(NULL
, task
->doc
, (BSCallback
*)task
->bscallback
, NULL
);
822 IUnknown_Release((IUnknown
*)task
->bscallback
);
825 static nsresult
async_open(nsChannel
*This
, HTMLWindow
*window
, BOOL is_doc_channel
, nsIStreamListener
*listener
,
826 nsISupports
*context
)
828 nsChannelBSC
*bscallback
;
829 IMoniker
*mon
= NULL
;
832 hres
= create_mon_for_nschannel(This
, &mon
);
834 return NS_ERROR_UNEXPECTED
;
837 set_current_mon(window
, mon
);
839 hres
= create_channelbsc(mon
, NULL
, NULL
, 0, &bscallback
);
840 IMoniker_Release(mon
);
842 return NS_ERROR_UNEXPECTED
;
844 channelbsc_set_channel(bscallback
, This
, listener
, context
);
847 set_window_bscallback(window
, bscallback
);
848 async_start_doc_binding(window
, bscallback
);
849 IUnknown_Release((IUnknown
*)bscallback
);
851 start_binding_task_t
*task
= heap_alloc(sizeof(start_binding_task_t
));
853 task
->doc
= window
->doc
;
854 task
->bscallback
= bscallback
;
855 push_task(&task
->header
, start_binding_proc
, window
->doc
->basedoc
.task_magic
);
861 static nsresult NSAPI
nsChannel_AsyncOpen(nsIHttpChannel
*iface
, nsIStreamListener
*aListener
,
862 nsISupports
*aContext
)
864 nsChannel
*This
= NSCHANNEL_THIS(iface
);
865 HTMLWindow
*window
= NULL
;
867 nsresult nsres
= NS_OK
;
869 TRACE("(%p)->(%p %p) opening %s\n", This
, aListener
, aContext
, debugstr_w(This
->uri
->wine_url
));
871 if(This
->uri
->is_doc_uri
) {
872 window
= get_channel_window(This
);
874 set_uri_window(This
->uri
, window
);
875 }else if(This
->uri
->container
) {
878 /* nscontainer->doc should be NULL which means navigation to a new window */
879 if(This
->uri
->container
->doc
)
880 FIXME("nscontainer->doc = %p\n", This
->uri
->container
->doc
);
882 b
= before_async_open(This
, This
->uri
->container
);
884 FIXME("Navigation not cancelled\n");
885 return NS_ERROR_UNEXPECTED
;
890 if(This
->uri
->window_ref
&& This
->uri
->window_ref
->window
) {
891 window
= This
->uri
->window_ref
->window
;
892 IHTMLWindow2_AddRef(HTMLWINDOW2(window
));
893 }else if(This
->load_group
) {
894 window
= get_window_from_load_group(This
);
896 set_uri_window(This
->uri
, window
);
901 ERR("window = NULL\n");
902 return NS_ERROR_UNEXPECTED
;
905 if(This
->uri
->is_doc_uri
&& window
== window
->doc_obj
->basedoc
.window
) {
906 if(This
->uri
->channel_bsc
) {
907 channelbsc_set_channel(This
->uri
->channel_bsc
, This
, aListener
, aContext
);
909 if(window
->doc_obj
->mime
) {
910 heap_free(This
->content_type
);
911 This
->content_type
= heap_strdupWtoA(window
->doc_obj
->mime
);
916 open
= !before_async_open(This
, window
->doc_obj
->nscontainer
);
919 nsres
= NS_ERROR_UNEXPECTED
;
925 nsres
= async_open(This
, window
, This
->uri
->is_doc_uri
, aListener
, aContext
);
927 IHTMLWindow2_Release(HTMLWINDOW2(window
));
931 static nsresult NSAPI
nsChannel_GetRequestMethod(nsIHttpChannel
*iface
, nsACString
*aRequestMethod
)
933 nsChannel
*This
= NSCHANNEL_THIS(iface
);
935 FIXME("(%p)->(%p)\n", This
, aRequestMethod
);
937 return NS_ERROR_NOT_IMPLEMENTED
;
940 static nsresult NSAPI
nsChannel_SetRequestMethod(nsIHttpChannel
*iface
,
941 const nsACString
*aRequestMethod
)
943 nsChannel
*This
= NSCHANNEL_THIS(iface
);
945 TRACE("(%p)->(%p): Returning NS_OK\n", This
, aRequestMethod
);
950 static nsresult NSAPI
nsChannel_GetReferrer(nsIHttpChannel
*iface
, nsIURI
**aReferrer
)
952 nsChannel
*This
= NSCHANNEL_THIS(iface
);
954 FIXME("(%p)->(%p)\n", This
, aReferrer
);
956 return NS_ERROR_NOT_IMPLEMENTED
;
959 static nsresult NSAPI
nsChannel_SetReferrer(nsIHttpChannel
*iface
, nsIURI
*aReferrer
)
961 nsChannel
*This
= NSCHANNEL_THIS(iface
);
963 FIXME("(%p)->(%p)\n", This
, aReferrer
);
968 static nsresult NSAPI
nsChannel_GetRequestHeader(nsIHttpChannel
*iface
,
969 const nsACString
*aHeader
, nsACString
*_retval
)
971 nsChannel
*This
= NSCHANNEL_THIS(iface
);
973 FIXME("(%p)->(%p %p)\n", This
, aHeader
, _retval
);
975 return NS_ERROR_NOT_IMPLEMENTED
;
978 static nsresult NSAPI
nsChannel_SetRequestHeader(nsIHttpChannel
*iface
,
979 const nsACString
*aHeader
, const nsACString
*aValue
, PRBool aMerge
)
981 nsChannel
*This
= NSCHANNEL_THIS(iface
);
983 FIXME("(%p)->(%p %p %x)\n", This
, aHeader
, aValue
, aMerge
);
988 static nsresult NSAPI
nsChannel_VisitRequestHeaders(nsIHttpChannel
*iface
,
989 nsIHttpHeaderVisitor
*aVisitor
)
991 nsChannel
*This
= NSCHANNEL_THIS(iface
);
993 FIXME("(%p)->(%p)\n", This
, aVisitor
);
995 return NS_ERROR_NOT_IMPLEMENTED
;
998 static nsresult NSAPI
nsChannel_GetAllowPipelining(nsIHttpChannel
*iface
, PRBool
*aAllowPipelining
)
1000 nsChannel
*This
= NSCHANNEL_THIS(iface
);
1002 FIXME("(%p)->(%p)\n", This
, aAllowPipelining
);
1004 return NS_ERROR_NOT_IMPLEMENTED
;
1007 static nsresult NSAPI
nsChannel_SetAllowPipelining(nsIHttpChannel
*iface
, PRBool aAllowPipelining
)
1009 nsChannel
*This
= NSCHANNEL_THIS(iface
);
1011 FIXME("(%p)->(%x)\n", This
, aAllowPipelining
);
1013 return NS_ERROR_NOT_IMPLEMENTED
;
1016 static nsresult NSAPI
nsChannel_GetRedirectionLimit(nsIHttpChannel
*iface
, PRUint32
*aRedirectionLimit
)
1018 nsChannel
*This
= NSCHANNEL_THIS(iface
);
1020 FIXME("(%p)->(%p)\n", This
, aRedirectionLimit
);
1022 return NS_ERROR_NOT_IMPLEMENTED
;
1025 static nsresult NSAPI
nsChannel_SetRedirectionLimit(nsIHttpChannel
*iface
, PRUint32 aRedirectionLimit
)
1027 nsChannel
*This
= NSCHANNEL_THIS(iface
);
1029 FIXME("(%p)->(%u)\n", This
, aRedirectionLimit
);
1031 return NS_ERROR_NOT_IMPLEMENTED
;
1034 static nsresult NSAPI
nsChannel_GetResponseStatus(nsIHttpChannel
*iface
, PRUint32
*aResponseStatus
)
1036 nsChannel
*This
= NSCHANNEL_THIS(iface
);
1038 TRACE("(%p)->(%p)\n", This
, aResponseStatus
);
1040 if(This
->response_status
) {
1041 *aResponseStatus
= This
->response_status
;
1045 WARN("No response status\n");
1046 return NS_ERROR_UNEXPECTED
;
1049 static nsresult NSAPI
nsChannel_GetResponseStatusText(nsIHttpChannel
*iface
,
1050 nsACString
*aResponseStatusText
)
1052 nsChannel
*This
= NSCHANNEL_THIS(iface
);
1054 FIXME("(%p)->(%p)\n", This
, aResponseStatusText
);
1056 return NS_ERROR_NOT_IMPLEMENTED
;
1059 static nsresult NSAPI
nsChannel_GetRequestSucceeded(nsIHttpChannel
*iface
,
1060 PRBool
*aRequestSucceeded
)
1062 nsChannel
*This
= NSCHANNEL_THIS(iface
);
1064 TRACE("(%p)->(%p)\n", This
, aRequestSucceeded
);
1066 if(!This
->response_status
)
1067 return NS_ERROR_NOT_AVAILABLE
;
1069 *aRequestSucceeded
= This
->response_status
/100 == 2;
1074 static nsresult NSAPI
nsChannel_GetResponseHeader(nsIHttpChannel
*iface
,
1075 const nsACString
*header
, nsACString
*_retval
)
1077 nsChannel
*This
= NSCHANNEL_THIS(iface
);
1078 const char *header_str
;
1080 struct ResponseHeader
*this_header
;
1082 nsACString_GetData(header
, &header_str
);
1083 TRACE("(%p)->(%p(%s) %p)\n", This
, header
, header_str
, _retval
);
1085 header_wstr
= heap_strdupAtoW(header_str
);
1087 return NS_ERROR_UNEXPECTED
;
1089 LIST_FOR_EACH_ENTRY(this_header
, &This
->response_headers
, struct ResponseHeader
, entry
) {
1090 if(!strcmpW(this_header
->header
, header_wstr
)) {
1091 char *data
= heap_strdupWtoA(this_header
->data
);
1093 heap_free(header_wstr
);
1094 return NS_ERROR_UNEXPECTED
;
1096 nsACString_SetData(_retval
, data
);
1098 heap_free(header_wstr
);
1103 heap_free(header_wstr
);
1105 return NS_ERROR_NOT_AVAILABLE
;
1108 static nsresult NSAPI
nsChannel_SetResponseHeader(nsIHttpChannel
*iface
,
1109 const nsACString
*header
, const nsACString
*value
, PRBool merge
)
1111 nsChannel
*This
= NSCHANNEL_THIS(iface
);
1113 FIXME("(%p)->(%p %p %x)\n", This
, header
, value
, merge
);
1115 return NS_ERROR_NOT_IMPLEMENTED
;
1118 static nsresult NSAPI
nsChannel_VisitResponseHeaders(nsIHttpChannel
*iface
,
1119 nsIHttpHeaderVisitor
*aVisitor
)
1121 nsChannel
*This
= NSCHANNEL_THIS(iface
);
1123 FIXME("(%p)->(%p)\n", This
, aVisitor
);
1125 return NS_ERROR_NOT_IMPLEMENTED
;
1128 static nsresult NSAPI
nsChannel_IsNoStoreResponse(nsIHttpChannel
*iface
, PRBool
*_retval
)
1130 nsChannel
*This
= NSCHANNEL_THIS(iface
);
1132 FIXME("(%p)->(%p)\n", This
, _retval
);
1134 return NS_ERROR_NOT_IMPLEMENTED
;
1137 static nsresult NSAPI
nsChannel_IsNoCacheResponse(nsIHttpChannel
*iface
, PRBool
*_retval
)
1139 nsChannel
*This
= NSCHANNEL_THIS(iface
);
1141 FIXME("(%p)->(%p)\n", This
, _retval
);
1143 return NS_ERROR_NOT_IMPLEMENTED
;
1146 #undef NSCHANNEL_THIS
1148 static const nsIHttpChannelVtbl nsChannelVtbl
= {
1149 nsChannel_QueryInterface
,
1153 nsChannel_IsPending
,
1154 nsChannel_GetStatus
,
1158 nsChannel_GetLoadGroup
,
1159 nsChannel_SetLoadGroup
,
1160 nsChannel_GetLoadFlags
,
1161 nsChannel_SetLoadFlags
,
1162 nsChannel_GetOriginalURI
,
1163 nsChannel_SetOriginalURI
,
1167 nsChannel_GetNotificationCallbacks
,
1168 nsChannel_SetNotificationCallbacks
,
1169 nsChannel_GetSecurityInfo
,
1170 nsChannel_GetContentType
,
1171 nsChannel_SetContentType
,
1172 nsChannel_GetContentCharset
,
1173 nsChannel_SetContentCharset
,
1174 nsChannel_GetContentLength
,
1175 nsChannel_SetContentLength
,
1177 nsChannel_AsyncOpen
,
1178 nsChannel_GetRequestMethod
,
1179 nsChannel_SetRequestMethod
,
1180 nsChannel_GetReferrer
,
1181 nsChannel_SetReferrer
,
1182 nsChannel_GetRequestHeader
,
1183 nsChannel_SetRequestHeader
,
1184 nsChannel_VisitRequestHeaders
,
1185 nsChannel_GetAllowPipelining
,
1186 nsChannel_SetAllowPipelining
,
1187 nsChannel_GetRedirectionLimit
,
1188 nsChannel_SetRedirectionLimit
,
1189 nsChannel_GetResponseStatus
,
1190 nsChannel_GetResponseStatusText
,
1191 nsChannel_GetRequestSucceeded
,
1192 nsChannel_GetResponseHeader
,
1193 nsChannel_SetResponseHeader
,
1194 nsChannel_VisitResponseHeaders
,
1195 nsChannel_IsNoStoreResponse
,
1196 nsChannel_IsNoCacheResponse
1199 #define NSUPCHANNEL_THIS(iface) DEFINE_THIS(nsChannel, UploadChannel, iface)
1201 static nsresult NSAPI
nsUploadChannel_QueryInterface(nsIUploadChannel
*iface
, nsIIDRef riid
,
1204 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1205 return nsIChannel_QueryInterface(NSCHANNEL(This
), riid
, result
);
1208 static nsrefcnt NSAPI
nsUploadChannel_AddRef(nsIUploadChannel
*iface
)
1210 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1211 return nsIChannel_AddRef(NSCHANNEL(This
));
1214 static nsrefcnt NSAPI
nsUploadChannel_Release(nsIUploadChannel
*iface
)
1216 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1217 return nsIChannel_Release(NSCHANNEL(This
));
1220 static nsresult NSAPI
nsUploadChannel_SetUploadStream(nsIUploadChannel
*iface
,
1221 nsIInputStream
*aStream
, const nsACString
*aContentType
, PRInt32 aContentLength
)
1223 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1224 const char *content_type
;
1226 TRACE("(%p)->(%p %p %d)\n", This
, aStream
, aContentType
, aContentLength
);
1228 if(This
->post_data_stream
)
1229 nsIInputStream_Release(This
->post_data_stream
);
1232 nsACString_GetData(aContentType
, &content_type
);
1234 FIXME("Unsupported aContentType argument: %s\n", debugstr_a(content_type
));
1237 if(aContentLength
!= -1)
1238 FIXME("Unsupported acontentLength = %d\n", aContentLength
);
1240 if(This
->post_data_stream
)
1241 nsIInputStream_Release(This
->post_data_stream
);
1242 This
->post_data_stream
= aStream
;
1244 nsIInputStream_AddRef(aStream
);
1249 static nsresult NSAPI
nsUploadChannel_GetUploadStream(nsIUploadChannel
*iface
,
1250 nsIInputStream
**aUploadStream
)
1252 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1254 TRACE("(%p)->(%p)\n", This
, aUploadStream
);
1256 if(This
->post_data_stream
)
1257 nsIInputStream_AddRef(This
->post_data_stream
);
1259 *aUploadStream
= This
->post_data_stream
;
1263 #undef NSUPCHANNEL_THIS
1265 static const nsIUploadChannelVtbl nsUploadChannelVtbl
= {
1266 nsUploadChannel_QueryInterface
,
1267 nsUploadChannel_AddRef
,
1268 nsUploadChannel_Release
,
1269 nsUploadChannel_SetUploadStream
,
1270 nsUploadChannel_GetUploadStream
1273 #define NSHTTPINTERNAL_THIS(iface) DEFINE_THIS(nsChannel, IHttpChannelInternal, iface)
1275 static nsresult NSAPI
nsHttpChannelInternal_QueryInterface(nsIHttpChannelInternal
*iface
, nsIIDRef riid
,
1278 nsChannel
*This
= NSHTTPINTERNAL_THIS(iface
);
1279 return nsIChannel_QueryInterface(NSCHANNEL(This
), riid
, result
);
1282 static nsrefcnt NSAPI
nsHttpChannelInternal_AddRef(nsIHttpChannelInternal
*iface
)
1284 nsChannel
*This
= NSHTTPINTERNAL_THIS(iface
);
1285 return nsIChannel_AddRef(NSCHANNEL(This
));
1288 static nsrefcnt NSAPI
nsHttpChannelInternal_Release(nsIHttpChannelInternal
*iface
)
1290 nsChannel
*This
= NSHTTPINTERNAL_THIS(iface
);
1291 return nsIChannel_Release(NSCHANNEL(This
));
1294 static nsresult NSAPI
nsHttpChannelInternal_GetDocumentURI(nsIHttpChannelInternal
*iface
, nsIURI
**aDocumentURI
)
1296 nsChannel
*This
= NSHTTPINTERNAL_THIS(iface
);
1298 FIXME("(%p)->()\n", This
);
1300 return NS_ERROR_NOT_IMPLEMENTED
;
1303 static nsresult NSAPI
nsHttpChannelInternal_SetDocumentURI(nsIHttpChannelInternal
*iface
, nsIURI
*aDocumentURI
)
1305 nsChannel
*This
= NSHTTPINTERNAL_THIS(iface
);
1307 FIXME("(%p)->()\n", This
);
1309 return NS_ERROR_NOT_IMPLEMENTED
;
1312 static nsresult NSAPI
nsHttpChannelInternal_GetRequestVersion(nsIHttpChannelInternal
*iface
, PRUint32
*major
, PRUint32
*minor
)
1314 nsChannel
*This
= NSHTTPINTERNAL_THIS(iface
);
1316 FIXME("(%p)->()\n", This
);
1318 return NS_ERROR_NOT_IMPLEMENTED
;
1321 static nsresult NSAPI
nsHttpChannelInternal_GetResponseVersion(nsIHttpChannelInternal
*iface
, PRUint32
*major
, PRUint32
*minor
)
1323 nsChannel
*This
= NSHTTPINTERNAL_THIS(iface
);
1325 FIXME("(%p)->()\n", This
);
1327 return NS_ERROR_NOT_IMPLEMENTED
;
1330 static nsresult NSAPI
nsHttpChannelInternal_SetCookie(nsIHttpChannelInternal
*iface
, const char *aCookieHeader
)
1332 nsChannel
*This
= NSHTTPINTERNAL_THIS(iface
);
1334 FIXME("(%p)->()\n", This
);
1336 return NS_ERROR_NOT_IMPLEMENTED
;
1339 static nsresult NSAPI
nsHttpChannelInternal_SetupFallbackChannel(nsIHttpChannelInternal
*iface
, const char *aFallbackKey
)
1341 nsChannel
*This
= NSHTTPINTERNAL_THIS(iface
);
1343 FIXME("(%p)->()\n", This
);
1345 return NS_ERROR_NOT_IMPLEMENTED
;
1348 static nsresult NSAPI
nsHttpChannelInternal_GetForceAllowThirdPartyCookie(nsIHttpChannelInternal
*iface
, PRBool
*aForceThirdPartyCookie
)
1350 nsChannel
*This
= NSHTTPINTERNAL_THIS(iface
);
1352 FIXME("(%p)->()\n", This
);
1354 return NS_ERROR_NOT_IMPLEMENTED
;
1357 static nsresult NSAPI
nsHttpChannelInternal_SetForceAllowThirdPartyCookie(nsIHttpChannelInternal
*iface
, PRBool aForceThirdPartyCookie
)
1359 nsChannel
*This
= NSHTTPINTERNAL_THIS(iface
);
1361 FIXME("(%p)->()\n", This
);
1363 return NS_ERROR_NOT_IMPLEMENTED
;
1366 #undef NSHTTPINTERNAL_THIS
1368 static const nsIHttpChannelInternalVtbl nsHttpChannelInternalVtbl
= {
1369 nsHttpChannelInternal_QueryInterface
,
1370 nsHttpChannelInternal_AddRef
,
1371 nsHttpChannelInternal_Release
,
1372 nsHttpChannelInternal_GetDocumentURI
,
1373 nsHttpChannelInternal_SetDocumentURI
,
1374 nsHttpChannelInternal_GetRequestVersion
,
1375 nsHttpChannelInternal_GetResponseVersion
,
1376 nsHttpChannelInternal_SetCookie
,
1377 nsHttpChannelInternal_SetupFallbackChannel
,
1378 nsHttpChannelInternal_GetForceAllowThirdPartyCookie
,
1379 nsHttpChannelInternal_SetForceAllowThirdPartyCookie
1382 #define NSURI_THIS(iface) DEFINE_THIS(nsWineURI, IURL, iface)
1384 static nsresult NSAPI
nsURI_QueryInterface(nsIURL
*iface
, nsIIDRef riid
, nsQIResult result
)
1386 nsWineURI
*This
= NSURI_THIS(iface
);
1390 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
1391 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
1392 *result
= NSURI(This
);
1393 }else if(IsEqualGUID(&IID_nsIURI
, riid
)) {
1394 TRACE("(%p)->(IID_nsIURI %p)\n", This
, result
);
1395 *result
= NSURI(This
);
1396 }else if(IsEqualGUID(&IID_nsIURL
, riid
)) {
1397 TRACE("(%p)->(IID_nsIURL %p)\n", This
, result
);
1398 *result
= NSURL(This
);
1399 }else if(IsEqualGUID(&IID_nsWineURI
, riid
)) {
1400 TRACE("(%p)->(IID_nsWineURI %p)\n", This
, result
);
1405 nsIURI_AddRef(NSURI(This
));
1409 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), result
);
1410 return This
->uri
? nsIURI_QueryInterface(This
->uri
, riid
, result
) : NS_NOINTERFACE
;
1413 static nsrefcnt NSAPI
nsURI_AddRef(nsIURL
*iface
)
1415 nsWineURI
*This
= NSURI_THIS(iface
);
1416 LONG ref
= InterlockedIncrement(&This
->ref
);
1418 TRACE("(%p) ref=%d\n", This
, ref
);
1423 static nsrefcnt NSAPI
nsURI_Release(nsIURL
*iface
)
1425 nsWineURI
*This
= NSURI_THIS(iface
);
1426 LONG ref
= InterlockedDecrement(&This
->ref
);
1428 TRACE("(%p) ref=%d\n", This
, ref
);
1431 if(This
->window_ref
)
1432 windowref_release(This
->window_ref
);
1434 nsIWebBrowserChrome_Release(NSWBCHROME(This
->container
));
1436 nsIURL_Release(This
->nsurl
);
1438 nsIURI_Release(This
->uri
);
1439 heap_free(This
->wine_url
);
1446 static nsresult NSAPI
nsURI_GetSpec(nsIURL
*iface
, nsACString
*aSpec
)
1448 nsWineURI
*This
= NSURI_THIS(iface
);
1450 TRACE("(%p)->(%p)\n", This
, aSpec
);
1452 if(This
->use_wine_url
) {
1453 char speca
[INTERNET_MAX_URL_LENGTH
] = "wine:";
1454 WideCharToMultiByte(CP_ACP
, 0, This
->wine_url
, -1, speca
+5, sizeof(speca
)-5, NULL
, NULL
);
1455 nsACString_SetData(aSpec
, speca
);
1461 return nsIURI_GetSpec(This
->uri
, aSpec
);
1463 TRACE("returning error\n");
1464 return NS_ERROR_NOT_IMPLEMENTED
;
1468 static nsresult NSAPI
nsURI_SetSpec(nsIURL
*iface
, const nsACString
*aSpec
)
1470 nsWineURI
*This
= NSURI_THIS(iface
);
1472 TRACE("(%p)->(%p)\n", This
, aSpec
);
1475 return nsIURI_SetSpec(This
->uri
, aSpec
);
1477 FIXME("default action not implemented\n");
1478 return NS_ERROR_NOT_IMPLEMENTED
;
1481 static nsresult NSAPI
nsURI_GetPrePath(nsIURL
*iface
, nsACString
*aPrePath
)
1483 nsWineURI
*This
= NSURI_THIS(iface
);
1485 TRACE("(%p)->(%p)\n", This
, aPrePath
);
1488 return nsIURI_GetPrePath(This
->uri
, aPrePath
);
1490 FIXME("default action not implemented\n");
1491 return NS_ERROR_NOT_IMPLEMENTED
;
1494 static nsresult NSAPI
nsURI_GetScheme(nsIURL
*iface
, nsACString
*aScheme
)
1496 nsWineURI
*This
= NSURI_THIS(iface
);
1498 TRACE("(%p)->(%p)\n", This
, aScheme
);
1500 if(This
->use_wine_url
) {
1502 * For Gecko we set scheme to unknown so it won't be handled
1503 * as any special case.
1505 nsACString_SetData(aScheme
, "wine");
1510 return nsIURI_GetScheme(This
->uri
, aScheme
);
1512 TRACE("returning error\n");
1513 return NS_ERROR_NOT_IMPLEMENTED
;
1516 static nsresult NSAPI
nsURI_SetScheme(nsIURL
*iface
, const nsACString
*aScheme
)
1518 nsWineURI
*This
= NSURI_THIS(iface
);
1520 TRACE("(%p)->(%p)\n", This
, aScheme
);
1523 return nsIURI_SetScheme(This
->uri
, aScheme
);
1525 FIXME("default action not implemented\n");
1526 return NS_ERROR_NOT_IMPLEMENTED
;
1529 static nsresult NSAPI
nsURI_GetUserPass(nsIURL
*iface
, nsACString
*aUserPass
)
1531 nsWineURI
*This
= NSURI_THIS(iface
);
1533 TRACE("(%p)->(%p)\n", This
, aUserPass
);
1536 return nsIURI_GetUserPass(This
->uri
, aUserPass
);
1538 FIXME("default action not implemented\n");
1539 return NS_ERROR_NOT_IMPLEMENTED
;
1542 static nsresult NSAPI
nsURI_SetUserPass(nsIURL
*iface
, const nsACString
*aUserPass
)
1544 nsWineURI
*This
= NSURI_THIS(iface
);
1546 TRACE("(%p)->(%p)\n", This
, aUserPass
);
1549 return nsIURI_SetUserPass(This
->uri
, aUserPass
);
1551 FIXME("default action not implemented\n");
1552 return NS_ERROR_NOT_IMPLEMENTED
;
1555 static nsresult NSAPI
nsURI_GetUsername(nsIURL
*iface
, nsACString
*aUsername
)
1557 nsWineURI
*This
= NSURI_THIS(iface
);
1559 TRACE("(%p)->(%p)\n", This
, aUsername
);
1562 return nsIURI_GetUsername(This
->uri
, aUsername
);
1564 FIXME("default action not implemented\n");
1565 return NS_ERROR_NOT_IMPLEMENTED
;
1568 static nsresult NSAPI
nsURI_SetUsername(nsIURL
*iface
, const nsACString
*aUsername
)
1570 nsWineURI
*This
= NSURI_THIS(iface
);
1572 TRACE("(%p)->(%p)\n", This
, aUsername
);
1575 return nsIURI_SetUsername(This
->uri
, aUsername
);
1577 FIXME("default action not implemented\n");
1578 return NS_ERROR_NOT_IMPLEMENTED
;
1581 static nsresult NSAPI
nsURI_GetPassword(nsIURL
*iface
, nsACString
*aPassword
)
1583 nsWineURI
*This
= NSURI_THIS(iface
);
1585 TRACE("(%p)->(%p)\n", This
, aPassword
);
1588 return nsIURI_GetPassword(This
->uri
, aPassword
);
1590 FIXME("default action not implemented\n");
1591 return NS_ERROR_NOT_IMPLEMENTED
;
1594 static nsresult NSAPI
nsURI_SetPassword(nsIURL
*iface
, const nsACString
*aPassword
)
1596 nsWineURI
*This
= NSURI_THIS(iface
);
1598 TRACE("(%p)->(%p)\n", This
, aPassword
);
1601 return nsIURI_SetPassword(This
->uri
, aPassword
);
1603 FIXME("default action not implemented\n");
1604 return NS_ERROR_NOT_IMPLEMENTED
;
1607 static nsresult NSAPI
nsURI_GetHostPort(nsIURL
*iface
, nsACString
*aHostPort
)
1609 nsWineURI
*This
= NSURI_THIS(iface
);
1611 TRACE("(%p)->(%p)\n", This
, aHostPort
);
1614 return nsIURI_GetHostPort(This
->uri
, aHostPort
);
1616 FIXME("default action not implemented\n");
1617 return NS_ERROR_NOT_IMPLEMENTED
;
1620 static nsresult NSAPI
nsURI_SetHostPort(nsIURL
*iface
, const nsACString
*aHostPort
)
1622 nsWineURI
*This
= NSURI_THIS(iface
);
1624 TRACE("(%p)->(%p)\n", This
, aHostPort
);
1627 return nsIURI_SetHostPort(This
->uri
, aHostPort
);
1629 FIXME("default action not implemented\n");
1630 return NS_ERROR_NOT_IMPLEMENTED
;
1633 static nsresult NSAPI
nsURI_GetHost(nsIURL
*iface
, nsACString
*aHost
)
1635 nsWineURI
*This
= NSURI_THIS(iface
);
1637 TRACE("(%p)->(%p)\n", This
, aHost
);
1640 return nsIURI_GetHost(This
->uri
, aHost
);
1642 FIXME("default action not implemented\n");
1643 return NS_ERROR_NOT_IMPLEMENTED
;
1646 static nsresult NSAPI
nsURI_SetHost(nsIURL
*iface
, const nsACString
*aHost
)
1648 nsWineURI
*This
= NSURI_THIS(iface
);
1650 TRACE("(%p)->(%p)\n", This
, aHost
);
1653 return nsIURI_SetHost(This
->uri
, aHost
);
1655 FIXME("default action not implemented\n");
1656 return NS_ERROR_NOT_IMPLEMENTED
;
1659 static nsresult NSAPI
nsURI_GetPort(nsIURL
*iface
, PRInt32
*aPort
)
1661 nsWineURI
*This
= NSURI_THIS(iface
);
1663 TRACE("(%p)->(%p)\n", This
, aPort
);
1666 return nsIURI_GetPort(This
->uri
, aPort
);
1668 FIXME("default action not implemented\n");
1669 return NS_ERROR_NOT_IMPLEMENTED
;
1672 static nsresult NSAPI
nsURI_SetPort(nsIURL
*iface
, PRInt32 aPort
)
1674 nsWineURI
*This
= NSURI_THIS(iface
);
1676 TRACE("(%p)->(%d)\n", This
, aPort
);
1679 return nsIURI_SetPort(This
->uri
, aPort
);
1681 FIXME("default action not implemented\n");
1682 return NS_ERROR_NOT_IMPLEMENTED
;
1685 static nsresult NSAPI
nsURI_GetPath(nsIURL
*iface
, nsACString
*aPath
)
1687 nsWineURI
*This
= NSURI_THIS(iface
);
1689 TRACE("(%p)->(%p)\n", This
, aPath
);
1692 return nsIURI_GetPath(This
->uri
, aPath
);
1694 FIXME("default action not implemented\n");
1695 return NS_ERROR_NOT_IMPLEMENTED
;
1698 static nsresult NSAPI
nsURI_SetPath(nsIURL
*iface
, const nsACString
*aPath
)
1700 nsWineURI
*This
= NSURI_THIS(iface
);
1703 nsACString_GetData(aPath
, &path
);
1704 TRACE("(%p)->(%p(%s))\n", This
, aPath
, debugstr_a(path
));
1707 if(This
->wine_url
) {
1708 WCHAR new_url
[INTERNET_MAX_URL_LENGTH
];
1709 DWORD size
= sizeof(new_url
)/sizeof(WCHAR
);
1713 pathw
= heap_strdupAtoW(path
);
1714 hres
= UrlCombineW(This
->wine_url
, pathw
, new_url
, &size
, 0);
1717 set_wine_url(This
, new_url
);
1719 WARN("UrlCombine failed: %08x\n", hres
);
1725 return nsIURI_SetPath(This
->uri
, aPath
);
1728 static nsresult NSAPI
nsURI_Equals(nsIURL
*iface
, nsIURI
*other
, PRBool
*_retval
)
1730 nsWineURI
*This
= NSURI_THIS(iface
);
1731 nsWineURI
*wine_uri
;
1734 TRACE("(%p)->(%p %p)\n", This
, other
, _retval
);
1737 return nsIURI_Equals(This
->uri
, other
, _retval
);
1739 nsres
= nsIURI_QueryInterface(other
, &IID_nsWineURI
, (void**)&wine_uri
);
1740 if(NS_FAILED(nsres
)) {
1741 TRACE("Could not get nsWineURI interface\n");
1746 *_retval
= wine_uri
->wine_url
&& !UrlCompareW(This
->wine_url
, wine_uri
->wine_url
, TRUE
);
1747 nsIURI_Release(NSURI(wine_uri
));
1752 static nsresult NSAPI
nsURI_SchemeIs(nsIURL
*iface
, const char *scheme
, PRBool
*_retval
)
1754 nsWineURI
*This
= NSURI_THIS(iface
);
1756 TRACE("(%p)->(%s %p)\n", This
, debugstr_a(scheme
), _retval
);
1758 if(This
->use_wine_url
) {
1759 WCHAR buf
[INTERNET_MAX_SCHEME_LENGTH
];
1760 int len
= MultiByteToWideChar(CP_ACP
, 0, scheme
, -1, buf
, sizeof(buf
)/sizeof(WCHAR
))-1;
1762 *_retval
= lstrlenW(This
->wine_url
) > len
1763 && This
->wine_url
[len
] == ':'
1764 && !memcmp(buf
, This
->wine_url
, len
*sizeof(WCHAR
));
1769 return nsIURI_SchemeIs(This
->uri
, scheme
, _retval
);
1771 TRACE("returning error\n");
1772 return NS_ERROR_NOT_IMPLEMENTED
;
1775 static nsresult NSAPI
nsURI_Clone(nsIURL
*iface
, nsIURI
**_retval
)
1777 nsWineURI
*This
= NSURI_THIS(iface
);
1778 nsIURI
*nsuri
= NULL
;
1779 nsWineURI
*wine_uri
;
1782 TRACE("(%p)->(%p)\n", This
, _retval
);
1785 nsres
= nsIURI_Clone(This
->uri
, &nsuri
);
1786 if(NS_FAILED(nsres
)) {
1787 WARN("Clone failed: %08x\n", nsres
);
1792 nsres
= create_uri(nsuri
, This
->window_ref
? This
->window_ref
->window
: NULL
, This
->container
, &wine_uri
);
1793 if(NS_FAILED(nsres
)) {
1794 WARN("create_uri failed: %08x\n", nsres
);
1798 set_wine_url(wine_uri
, This
->wine_url
);
1800 *_retval
= NSURI(wine_uri
);
1804 static nsresult NSAPI
nsURI_Resolve(nsIURL
*iface
, const nsACString
*arelativePath
,
1805 nsACString
*_retval
)
1807 nsWineURI
*This
= NSURI_THIS(iface
);
1809 TRACE("(%p)->(%p %p)\n", This
, arelativePath
, _retval
);
1812 return nsIURI_Resolve(This
->uri
, arelativePath
, _retval
);
1814 FIXME("default action not implemented\n");
1815 return NS_ERROR_NOT_IMPLEMENTED
;
1818 static nsresult NSAPI
nsURI_GetAsciiSpec(nsIURL
*iface
, nsACString
*aAsciiSpec
)
1820 nsWineURI
*This
= NSURI_THIS(iface
);
1822 TRACE("(%p)->(%p)\n", This
, aAsciiSpec
);
1824 if(This
->use_wine_url
)
1825 return nsIURI_GetSpec(NSURI(This
), aAsciiSpec
);
1828 return nsIURI_GetAsciiSpec(This
->uri
, aAsciiSpec
);
1830 TRACE("returning error\n");
1831 return NS_ERROR_NOT_IMPLEMENTED
;
1834 static nsresult NSAPI
nsURI_GetAsciiHost(nsIURL
*iface
, nsACString
*aAsciiHost
)
1836 nsWineURI
*This
= NSURI_THIS(iface
);
1838 TRACE("(%p)->(%p)\n", This
, aAsciiHost
);
1841 return nsIURI_GetAsciiHost(This
->uri
, aAsciiHost
);
1843 FIXME("default action not implemented\n");
1844 return NS_ERROR_NOT_IMPLEMENTED
;
1847 static nsresult NSAPI
nsURI_GetOriginCharset(nsIURL
*iface
, nsACString
*aOriginCharset
)
1849 nsWineURI
*This
= NSURI_THIS(iface
);
1851 TRACE("(%p)->(%p)\n", This
, aOriginCharset
);
1854 return nsIURI_GetOriginCharset(This
->uri
, aOriginCharset
);
1856 FIXME("default action not implemented\n");
1857 return NS_ERROR_NOT_IMPLEMENTED
;
1860 static nsresult NSAPI
nsURL_GetFilePath(nsIURL
*iface
, nsACString
*aFilePath
)
1862 nsWineURI
*This
= NSURI_THIS(iface
);
1864 TRACE("(%p)->(%p)\n", This
, aFilePath
);
1867 return nsIURL_GetFilePath(This
->nsurl
, aFilePath
);
1869 FIXME("default action not implemented\n");
1870 return NS_ERROR_NOT_IMPLEMENTED
;
1873 static nsresult NSAPI
nsURL_SetFilePath(nsIURL
*iface
, const nsACString
*aFilePath
)
1875 nsWineURI
*This
= NSURI_THIS(iface
);
1877 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aFilePath
));
1880 return nsIURL_SetFilePath(This
->nsurl
, aFilePath
);
1882 FIXME("default action not implemented\n");
1883 return NS_ERROR_NOT_IMPLEMENTED
;
1886 static nsresult NSAPI
nsURL_GetParam(nsIURL
*iface
, nsACString
*aParam
)
1888 nsWineURI
*This
= NSURI_THIS(iface
);
1890 TRACE("(%p)->(%p)\n", This
, aParam
);
1893 return nsIURL_GetParam(This
->nsurl
, aParam
);
1895 FIXME("default action not implemented\n");
1896 return NS_ERROR_NOT_IMPLEMENTED
;
1899 static nsresult NSAPI
nsURL_SetParam(nsIURL
*iface
, const nsACString
*aParam
)
1901 nsWineURI
*This
= NSURI_THIS(iface
);
1903 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aParam
));
1906 return nsIURL_SetParam(This
->nsurl
, aParam
);
1908 FIXME("default action not implemented\n");
1909 return NS_ERROR_NOT_IMPLEMENTED
;
1912 static nsresult NSAPI
nsURL_GetQuery(nsIURL
*iface
, nsACString
*aQuery
)
1914 nsWineURI
*This
= NSURI_THIS(iface
);
1916 TRACE("(%p)->(%p)\n", This
, aQuery
);
1919 return nsIURL_GetQuery(This
->nsurl
, aQuery
);
1921 FIXME("default action not implemented\n");
1922 return NS_ERROR_NOT_IMPLEMENTED
;
1925 static nsresult NSAPI
nsURL_SetQuery(nsIURL
*iface
, const nsACString
*aQuery
)
1927 nsWineURI
*This
= NSURI_THIS(iface
);
1928 const WCHAR
*ptr1
, *ptr2
;
1930 WCHAR
*new_url
, *ptr
;
1933 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aQuery
));
1936 nsIURL_SetQuery(This
->nsurl
, aQuery
);
1941 nsACString_GetData(aQuery
, &query
);
1942 size
= len
= MultiByteToWideChar(CP_ACP
, 0, query
, -1, NULL
, 0);
1943 ptr1
= strchrW(This
->wine_url
, '?');
1945 size
+= ptr1
-This
->wine_url
;
1946 ptr2
= strchrW(ptr1
, '#');
1948 size
+= strlenW(ptr2
);
1950 ptr1
= This
->wine_url
+ strlenW(This
->wine_url
);
1952 size
+= strlenW(This
->wine_url
);
1958 new_url
= heap_alloc(size
*sizeof(WCHAR
));
1959 memcpy(new_url
, This
->wine_url
, (ptr1
-This
->wine_url
)*sizeof(WCHAR
));
1960 ptr
= new_url
+ (ptr1
-This
->wine_url
);
1963 MultiByteToWideChar(CP_ACP
, 0, query
, -1, ptr
, len
);
1971 TRACE("setting %s\n", debugstr_w(new_url
));
1973 heap_free(This
->wine_url
);
1974 This
->wine_url
= new_url
;
1978 static nsresult NSAPI
nsURL_GetRef(nsIURL
*iface
, nsACString
*aRef
)
1980 nsWineURI
*This
= NSURI_THIS(iface
);
1982 TRACE("(%p)->(%p)\n", This
, aRef
);
1985 return nsIURL_GetRef(This
->nsurl
, aRef
);
1987 FIXME("default action not implemented\n");
1988 return NS_ERROR_NOT_IMPLEMENTED
;
1991 static nsresult NSAPI
nsURL_SetRef(nsIURL
*iface
, const nsACString
*aRef
)
1993 nsWineURI
*This
= NSURI_THIS(iface
);
1996 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aRef
));
1999 return nsIURL_SetRef(This
->nsurl
, aRef
);
2001 nsACString_GetData(aRef
, &refa
);
2005 FIXME("default action not implemented\n");
2006 return NS_ERROR_NOT_IMPLEMENTED
;
2009 static nsresult NSAPI
nsURL_GetDirectory(nsIURL
*iface
, nsACString
*aDirectory
)
2011 nsWineURI
*This
= NSURI_THIS(iface
);
2013 TRACE("(%p)->(%p)\n", This
, aDirectory
);
2016 return nsIURL_GetDirectory(This
->nsurl
, aDirectory
);
2018 FIXME("default action not implemented\n");
2019 return NS_ERROR_NOT_IMPLEMENTED
;
2022 static nsresult NSAPI
nsURL_SetDirectory(nsIURL
*iface
, const nsACString
*aDirectory
)
2024 nsWineURI
*This
= NSURI_THIS(iface
);
2026 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aDirectory
));
2029 return nsIURL_SetDirectory(This
->nsurl
, aDirectory
);
2031 FIXME("default action not implemented\n");
2032 return NS_ERROR_NOT_IMPLEMENTED
;
2035 static nsresult NSAPI
nsURL_GetFileName(nsIURL
*iface
, nsACString
*aFileName
)
2037 nsWineURI
*This
= NSURI_THIS(iface
);
2039 TRACE("(%p)->(%p)\n", This
, aFileName
);
2042 return nsIURL_GetFileName(This
->nsurl
, aFileName
);
2044 FIXME("default action not implemented\n");
2045 return NS_ERROR_NOT_IMPLEMENTED
;
2048 static nsresult NSAPI
nsURL_SetFileName(nsIURL
*iface
, const nsACString
*aFileName
)
2050 nsWineURI
*This
= NSURI_THIS(iface
);
2052 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aFileName
));
2055 return nsIURL_SetFileName(This
->nsurl
, aFileName
);
2057 FIXME("default action not implemented\n");
2058 return NS_ERROR_NOT_IMPLEMENTED
;
2061 static nsresult NSAPI
nsURL_GetFileBaseName(nsIURL
*iface
, nsACString
*aFileBaseName
)
2063 nsWineURI
*This
= NSURI_THIS(iface
);
2065 TRACE("(%p)->(%p)\n", This
, aFileBaseName
);
2068 return nsIURL_GetFileBaseName(This
->nsurl
, aFileBaseName
);
2070 FIXME("default action not implemented\n");
2071 return NS_ERROR_NOT_IMPLEMENTED
;
2074 static nsresult NSAPI
nsURL_SetFileBaseName(nsIURL
*iface
, const nsACString
*aFileBaseName
)
2076 nsWineURI
*This
= NSURI_THIS(iface
);
2078 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aFileBaseName
));
2081 return nsIURL_SetFileBaseName(This
->nsurl
, aFileBaseName
);
2083 FIXME("default action not implemented\n");
2084 return NS_ERROR_NOT_IMPLEMENTED
;
2087 static nsresult NSAPI
nsURL_GetFileExtension(nsIURL
*iface
, nsACString
*aFileExtension
)
2089 nsWineURI
*This
= NSURI_THIS(iface
);
2091 TRACE("(%p)->(%p)\n", This
, aFileExtension
);
2094 return nsIURL_GetFileExtension(This
->nsurl
, aFileExtension
);
2096 FIXME("default action not implemented\n");
2097 return NS_ERROR_NOT_IMPLEMENTED
;
2100 static nsresult NSAPI
nsURL_SetFileExtension(nsIURL
*iface
, const nsACString
*aFileExtension
)
2102 nsWineURI
*This
= NSURI_THIS(iface
);
2104 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aFileExtension
));
2107 return nsIURL_SetFileExtension(This
->nsurl
, aFileExtension
);
2109 FIXME("default action not implemented\n");
2110 return NS_ERROR_NOT_IMPLEMENTED
;
2113 static nsresult NSAPI
nsURL_GetCommonBaseSpec(nsIURL
*iface
, nsIURI
*aURIToCompare
, nsACString
*_retval
)
2115 nsWineURI
*This
= NSURI_THIS(iface
);
2117 TRACE("(%p)->(%p %p)\n", This
, aURIToCompare
, _retval
);
2120 return nsIURL_GetCommonBaseSpec(This
->nsurl
, aURIToCompare
, _retval
);
2122 FIXME("default action not implemented\n");
2123 return NS_ERROR_NOT_IMPLEMENTED
;
2126 static nsresult NSAPI
nsURL_GetRelativeSpec(nsIURL
*iface
, nsIURI
*aURIToCompare
, nsACString
*_retval
)
2128 nsWineURI
*This
= NSURI_THIS(iface
);
2130 TRACE("(%p)->(%p %p)\n", This
, aURIToCompare
, _retval
);
2133 return nsIURL_GetRelativeSpec(This
->nsurl
, aURIToCompare
, _retval
);
2135 FIXME("default action not implemented\n");
2136 return NS_ERROR_NOT_IMPLEMENTED
;
2141 static const nsIURLVtbl nsURLVtbl
= {
2142 nsURI_QueryInterface
,
2170 nsURI_GetOriginCharset
,
2183 nsURL_GetFileBaseName
,
2184 nsURL_SetFileBaseName
,
2185 nsURL_GetFileExtension
,
2186 nsURL_SetFileExtension
,
2187 nsURL_GetCommonBaseSpec
,
2188 nsURL_GetRelativeSpec
2191 static nsresult
create_uri(nsIURI
*uri
, HTMLWindow
*window
, NSContainer
*container
, nsWineURI
**_retval
)
2193 nsWineURI
*ret
= heap_alloc_zero(sizeof(nsWineURI
));
2195 ret
->lpIURLVtbl
= &nsURLVtbl
;
2199 set_uri_nscontainer(ret
, container
);
2200 set_uri_window(ret
, window
);
2203 nsIURI_QueryInterface(uri
, &IID_nsIURL
, (void**)&ret
->nsurl
);
2205 TRACE("retval=%p\n", ret
);
2210 HRESULT
create_doc_uri(HTMLWindow
*window
, WCHAR
*url
, nsWineURI
**ret
)
2215 nsres
= create_uri(NULL
, window
, window
->doc_obj
->nscontainer
, &uri
);
2216 if(NS_FAILED(nsres
))
2219 set_wine_url(uri
, url
);
2220 uri
->is_doc_uri
= TRUE
;
2227 const nsIProtocolHandlerVtbl
*lpProtocolHandlerVtbl
;
2231 nsIProtocolHandler
*nshandler
;
2232 } nsProtocolHandler
;
2234 #define NSPROTHANDLER(x) ((nsIProtocolHandler*) &(x)->lpProtocolHandlerVtbl)
2236 #define NSPROTHANDLER_THIS(iface) DEFINE_THIS(nsProtocolHandler, ProtocolHandler, iface)
2238 static nsresult NSAPI
nsProtocolHandler_QueryInterface(nsIProtocolHandler
*iface
, nsIIDRef riid
,
2241 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
2245 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
2246 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
2247 *result
= NSPROTHANDLER(This
);
2248 }else if(IsEqualGUID(&IID_nsIProtocolHandler
, riid
)) {
2249 TRACE("(%p)->(IID_nsIProtocolHandler %p)\n", This
, result
);
2250 *result
= NSPROTHANDLER(This
);
2251 }else if(IsEqualGUID(&IID_nsIExternalProtocolHandler
, riid
)) {
2252 TRACE("(%p)->(IID_nsIExternalProtocolHandler %p), returning NULL\n", This
, result
);
2253 return NS_NOINTERFACE
;
2257 nsISupports_AddRef((nsISupports
*)*result
);
2261 WARN("(%s %p)\n", debugstr_guid(riid
), result
);
2262 return NS_NOINTERFACE
;
2265 static nsrefcnt NSAPI
nsProtocolHandler_AddRef(nsIProtocolHandler
*iface
)
2267 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
2268 LONG ref
= InterlockedIncrement(&This
->ref
);
2270 TRACE("(%p) ref=%d\n", This
, ref
);
2275 static nsrefcnt NSAPI
nsProtocolHandler_Release(nsIProtocolHandler
*iface
)
2277 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
2278 LONG ref
= InterlockedDecrement(&This
->ref
);
2280 TRACE("(%p) ref=%d\n", This
, ref
);
2284 nsIProtocolHandler_Release(This
->nshandler
);
2291 static nsresult NSAPI
nsProtocolHandler_GetScheme(nsIProtocolHandler
*iface
, nsACString
*aScheme
)
2293 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
2295 TRACE("(%p)->(%p)\n", This
, aScheme
);
2298 return nsIProtocolHandler_GetScheme(This
->nshandler
, aScheme
);
2299 return NS_ERROR_NOT_IMPLEMENTED
;
2302 static nsresult NSAPI
nsProtocolHandler_GetDefaultPort(nsIProtocolHandler
*iface
,
2303 PRInt32
*aDefaultPort
)
2305 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
2307 TRACE("(%p)->(%p)\n", This
, aDefaultPort
);
2310 return nsIProtocolHandler_GetDefaultPort(This
->nshandler
, aDefaultPort
);
2311 return NS_ERROR_NOT_IMPLEMENTED
;
2314 static nsresult NSAPI
nsProtocolHandler_GetProtocolFlags(nsIProtocolHandler
*iface
,
2315 PRUint32
*aProtocolFlags
)
2317 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
2319 TRACE("(%p)->(%p)\n", This
, aProtocolFlags
);
2322 return nsIProtocolHandler_GetProtocolFlags(This
->nshandler
, aProtocolFlags
);
2323 return NS_ERROR_NOT_IMPLEMENTED
;
2326 static nsresult NSAPI
nsProtocolHandler_NewURI(nsIProtocolHandler
*iface
,
2327 const nsACString
*aSpec
, const char *aOriginCharset
, nsIURI
*aBaseURI
, nsIURI
**_retval
)
2329 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
2331 TRACE("((%p)->%p %s %p %p)\n", This
, aSpec
, debugstr_a(aOriginCharset
), aBaseURI
, _retval
);
2334 return nsIProtocolHandler_NewURI(This
->nshandler
, aSpec
, aOriginCharset
, aBaseURI
, _retval
);
2335 return NS_ERROR_NOT_IMPLEMENTED
;
2338 static nsresult NSAPI
nsProtocolHandler_NewChannel(nsIProtocolHandler
*iface
,
2339 nsIURI
*aURI
, nsIChannel
**_retval
)
2341 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
2343 TRACE("(%p)->(%p %p)\n", This
, aURI
, _retval
);
2346 return nsIProtocolHandler_NewChannel(This
->nshandler
, aURI
, _retval
);
2347 return NS_ERROR_NOT_IMPLEMENTED
;
2350 static nsresult NSAPI
nsProtocolHandler_AllowPort(nsIProtocolHandler
*iface
,
2351 PRInt32 port
, const char *scheme
, PRBool
*_retval
)
2353 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
2355 TRACE("(%p)->(%d %s %p)\n", This
, port
, debugstr_a(scheme
), _retval
);
2358 return nsIProtocolHandler_AllowPort(This
->nshandler
, port
, scheme
, _retval
);
2359 return NS_ERROR_NOT_IMPLEMENTED
;
2362 #undef NSPROTHANDLER_THIS
2364 static const nsIProtocolHandlerVtbl nsProtocolHandlerVtbl
= {
2365 nsProtocolHandler_QueryInterface
,
2366 nsProtocolHandler_AddRef
,
2367 nsProtocolHandler_Release
,
2368 nsProtocolHandler_GetScheme
,
2369 nsProtocolHandler_GetDefaultPort
,
2370 nsProtocolHandler_GetProtocolFlags
,
2371 nsProtocolHandler_NewURI
,
2372 nsProtocolHandler_NewChannel
,
2373 nsProtocolHandler_AllowPort
2376 static nsIProtocolHandler
*create_protocol_handler(nsIProtocolHandler
*nshandler
)
2378 nsProtocolHandler
*ret
= heap_alloc(sizeof(nsProtocolHandler
));
2380 ret
->lpProtocolHandlerVtbl
= &nsProtocolHandlerVtbl
;
2382 ret
->nshandler
= nshandler
;
2384 return NSPROTHANDLER(ret
);
2387 static nsresult NSAPI
nsIOService_QueryInterface(nsIIOService
*,nsIIDRef
,nsQIResult
);
2389 static nsrefcnt NSAPI
nsIOService_AddRef(nsIIOService
*iface
)
2394 static nsrefcnt NSAPI
nsIOService_Release(nsIIOService
*iface
)
2399 static nsresult NSAPI
nsIOService_GetProtocolHandler(nsIIOService
*iface
, const char *aScheme
,
2400 nsIProtocolHandler
**_retval
)
2402 nsIExternalProtocolHandler
*nsexthandler
;
2403 nsIProtocolHandler
*nshandler
;
2406 TRACE("(%s %p)\n", debugstr_a(aScheme
), _retval
);
2408 nsres
= nsIIOService_GetProtocolHandler(nsio
, aScheme
, &nshandler
);
2409 if(NS_FAILED(nsres
)) {
2410 WARN("GetProtocolHandler failed: %08x\n", nsres
);
2414 nsres
= nsIProtocolHandler_QueryInterface(nshandler
, &IID_nsIExternalProtocolHandler
,
2415 (void**)&nsexthandler
);
2416 if(NS_FAILED(nsres
)) {
2417 *_retval
= nshandler
;
2421 nsIExternalProtocolHandler_Release(nsexthandler
);
2422 *_retval
= create_protocol_handler(nshandler
);
2423 TRACE("return %p\n", *_retval
);
2427 static nsresult NSAPI
nsIOService_GetProtocolFlags(nsIIOService
*iface
, const char *aScheme
,
2430 TRACE("(%s %p)\n", debugstr_a(aScheme
), _retval
);
2431 return nsIIOService_GetProtocolFlags(nsio
, aScheme
, _retval
);
2434 static BOOL
is_gecko_special_uri(const char *spec
)
2436 static const char *special_schemes
[] = {"chrome:", "jar:", "resource:", "javascript:", "wyciwyg:"};
2439 for(i
=0; i
< sizeof(special_schemes
)/sizeof(*special_schemes
); i
++) {
2440 if(!strncasecmp(spec
, special_schemes
[i
], strlen(special_schemes
[i
])))
2447 static nsresult NSAPI
nsIOService_NewURI(nsIIOService
*iface
, const nsACString
*aSpec
,
2448 const char *aOriginCharset
, nsIURI
*aBaseURI
, nsIURI
**_retval
)
2450 nsWineURI
*wine_uri
, *base_wine_uri
= NULL
;
2451 const char *spec
= NULL
;
2452 HTMLWindow
*window
= NULL
;
2454 LPCWSTR base_wine_url
= NULL
;
2455 nsACString spec_str
;
2458 nsACString_GetData(aSpec
, &spec
);
2460 TRACE("(%p(%s) %s %p %p)\n", aSpec
, debugstr_a(spec
), debugstr_a(aOriginCharset
),
2463 if(is_gecko_special_uri(spec
))
2464 return nsIIOService_NewURI(nsio
, aSpec
, aOriginCharset
, aBaseURI
, _retval
);
2466 if(!strncmp(spec
, "wine:", 5))
2470 PARSEDURLA parsed_url
= {sizeof(PARSEDURLA
)};
2472 nsres
= nsIURI_QueryInterface(aBaseURI
, &IID_nsWineURI
, (void**)&base_wine_uri
);
2473 if(NS_SUCCEEDED(nsres
)) {
2474 base_wine_url
= base_wine_uri
->wine_url
;
2475 if(base_wine_uri
->window_ref
&& base_wine_uri
->window_ref
->window
) {
2476 window
= base_wine_uri
->window_ref
->window
;
2477 IHTMLWindow2_AddRef(HTMLWINDOW2(window
));
2479 TRACE("base url: %s window: %p\n", debugstr_w(base_wine_url
), window
);
2480 }else if(FAILED(ParseURLA(spec
, &parsed_url
))) {
2481 TRACE("not wraping\n");
2482 return nsIIOService_NewURI(nsio
, aSpec
, aOriginCharset
, aBaseURI
, _retval
);
2484 WARN("Could not get base nsWineURI: %08x\n", nsres
);
2488 nsACString_InitDepend(&spec_str
, spec
);
2489 nsres
= nsIIOService_NewURI(nsio
, aSpec
, aOriginCharset
, aBaseURI
, &uri
);
2490 nsACString_Finish(&spec_str
);
2491 if(NS_FAILED(nsres
))
2492 TRACE("NewURI failed: %08x\n", nsres
);
2494 nsres
= create_uri(uri
, window
, NULL
, &wine_uri
);
2495 *_retval
= (nsIURI
*)wine_uri
;
2498 IHTMLWindow2_Release(HTMLWINDOW2(window
));
2501 WCHAR url
[INTERNET_MAX_URL_LENGTH
], rel_url
[INTERNET_MAX_URL_LENGTH
];
2505 MultiByteToWideChar(CP_ACP
, 0, spec
, -1, rel_url
, sizeof(rel_url
)/sizeof(WCHAR
));
2507 hres
= CoInternetCombineUrl(base_wine_url
, rel_url
,
2508 URL_ESCAPE_SPACES_ONLY
|URL_DONT_ESCAPE_EXTRA_INFO
,
2509 url
, sizeof(url
)/sizeof(WCHAR
), &len
, 0);
2511 set_wine_url(wine_uri
, url
);
2513 WARN("CoCombineUrl failed: %08x\n", hres
);
2515 WCHAR url
[INTERNET_MAX_URL_LENGTH
];
2517 MultiByteToWideChar(CP_ACP
, 0, spec
, -1, url
, sizeof(url
)/sizeof(WCHAR
));
2518 set_wine_url(wine_uri
, url
);
2522 nsIURI_Release(NSURI(base_wine_uri
));
2527 static nsresult NSAPI
nsIOService_NewFileURI(nsIIOService
*iface
, nsIFile
*aFile
,
2530 TRACE("(%p %p)\n", aFile
, _retval
);
2531 return nsIIOService_NewFileURI(nsio
, aFile
, _retval
);
2534 static nsresult NSAPI
nsIOService_NewChannelFromURI(nsIIOService
*iface
, nsIURI
*aURI
,
2535 nsIChannel
**_retval
)
2537 PARSEDURLW parsed_url
= {sizeof(PARSEDURLW
)};
2539 nsWineURI
*wine_uri
;
2542 TRACE("(%p %p)\n", aURI
, _retval
);
2544 nsres
= nsIURI_QueryInterface(aURI
, &IID_nsWineURI
, (void**)&wine_uri
);
2545 if(NS_FAILED(nsres
)) {
2546 TRACE("Could not get nsWineURI: %08x\n", nsres
);
2547 return nsIIOService_NewChannelFromURI(nsio
, aURI
, _retval
);
2550 ret
= heap_alloc_zero(sizeof(nsChannel
));
2552 ret
->lpHttpChannelVtbl
= &nsChannelVtbl
;
2553 ret
->lpUploadChannelVtbl
= &nsUploadChannelVtbl
;
2554 ret
->lpIHttpChannelInternalVtbl
= &nsHttpChannelInternalVtbl
;
2556 ret
->uri
= wine_uri
;
2557 list_init(&ret
->response_headers
);
2559 nsIURI_AddRef(aURI
);
2560 ret
->original_uri
= aURI
;
2561 ret
->url_scheme
= wine_uri
->wine_url
&& SUCCEEDED(ParseURLW(wine_uri
->wine_url
, &parsed_url
))
2562 ? parsed_url
.nScheme
: URL_SCHEME_UNKNOWN
;
2564 *_retval
= NSCHANNEL(ret
);
2568 static nsresult NSAPI
nsIOService_NewChannel(nsIIOService
*iface
, const nsACString
*aSpec
,
2569 const char *aOriginCharset
, nsIURI
*aBaseURI
, nsIChannel
**_retval
)
2571 TRACE("(%p %s %p %p)\n", aSpec
, debugstr_a(aOriginCharset
), aBaseURI
, _retval
);
2572 return nsIIOService_NewChannel(nsio
, aSpec
, aOriginCharset
, aBaseURI
, _retval
);
2575 static nsresult NSAPI
nsIOService_GetOffline(nsIIOService
*iface
, PRBool
*aOffline
)
2577 TRACE("(%p)\n", aOffline
);
2578 return nsIIOService_GetOffline(nsio
, aOffline
);
2581 static nsresult NSAPI
nsIOService_SetOffline(nsIIOService
*iface
, PRBool aOffline
)
2583 TRACE("(%x)\n", aOffline
);
2584 return nsIIOService_SetOffline(nsio
, aOffline
);
2587 static nsresult NSAPI
nsIOService_AllowPort(nsIIOService
*iface
, PRInt32 aPort
,
2588 const char *aScheme
, PRBool
*_retval
)
2590 TRACE("(%d %s %p)\n", aPort
, debugstr_a(aScheme
), _retval
);
2591 return nsIIOService_AllowPort(nsio
, aPort
, debugstr_a(aScheme
), _retval
);
2594 static nsresult NSAPI
nsIOService_ExtractScheme(nsIIOService
*iface
, const nsACString
*urlString
,
2595 nsACString
* _retval
)
2597 TRACE("(%p %p)\n", urlString
, _retval
);
2598 return nsIIOService_ExtractScheme(nsio
, urlString
, _retval
);
2601 static const nsIIOServiceVtbl nsIOServiceVtbl
= {
2602 nsIOService_QueryInterface
,
2604 nsIOService_Release
,
2605 nsIOService_GetProtocolHandler
,
2606 nsIOService_GetProtocolFlags
,
2608 nsIOService_NewFileURI
,
2609 nsIOService_NewChannelFromURI
,
2610 nsIOService_NewChannel
,
2611 nsIOService_GetOffline
,
2612 nsIOService_SetOffline
,
2613 nsIOService_AllowPort
,
2614 nsIOService_ExtractScheme
2617 static nsIIOService nsIOService
= { &nsIOServiceVtbl
};
2619 static nsresult NSAPI
nsNetUtil_QueryInterface(nsINetUtil
*iface
, nsIIDRef riid
,
2622 return nsIIOService_QueryInterface(&nsIOService
, riid
, result
);
2625 static nsrefcnt NSAPI
nsNetUtil_AddRef(nsINetUtil
*iface
)
2630 static nsrefcnt NSAPI
nsNetUtil_Release(nsINetUtil
*iface
)
2635 static nsresult NSAPI
nsNetUtil_ParseContentType(nsINetUtil
*iface
, const nsACString
*aTypeHeader
,
2636 nsACString
*aCharset
, PRBool
*aHadCharset
, nsACString
*aContentType
)
2638 TRACE("(%p %p %p %p)\n", aTypeHeader
, aCharset
, aHadCharset
, aContentType
);
2640 return nsINetUtil_ParseContentType(net_util
, aTypeHeader
, aCharset
, aHadCharset
, aContentType
);
2643 static nsresult NSAPI
nsNetUtil_ProtocolHasFlags(nsINetUtil
*iface
, nsIURI
*aURI
, PRUint32 aFlags
, PRBool
*_retval
)
2647 return nsINetUtil_ProtocolHasFlags(net_util
, aURI
, aFlags
, _retval
);
2650 static nsresult NSAPI
nsNetUtil_URIChainHasFlags(nsINetUtil
*iface
, nsIURI
*aURI
, PRUint32 aFlags
, PRBool
*_retval
)
2652 TRACE("(%p %08x %p)\n", aURI
, aFlags
, _retval
);
2654 if(aFlags
== (1<<11)) {
2659 return nsINetUtil_URIChainHasFlags(net_util
, aURI
, aFlags
, _retval
);
2662 static nsresult NSAPI
nsNetUtil_ToImmutableURI(nsINetUtil
*iface
, nsIURI
*aURI
, nsIURI
**_retval
)
2664 TRACE("(%p %p)\n", aURI
, _retval
);
2666 return nsINetUtil_ToImmutableURI(net_util
, aURI
, _retval
);
2669 static nsresult NSAPI
nsNetUtil_EscapeString(nsINetUtil
*iface
, const nsACString
*aString
,
2670 PRUint32 aEscapeType
, nsACString
*_retval
)
2672 TRACE("(%p %x %p)\n", aString
, aEscapeType
, _retval
);
2674 return nsINetUtil_EscapeString(net_util
, aString
, aEscapeType
, _retval
);
2677 static nsresult NSAPI
nsNetUtil_EscapeURL(nsINetUtil
*iface
, const nsACString
*aStr
, PRUint32 aFlags
,
2678 nsACString
*_retval
)
2680 TRACE("(%p %08x %p)\n", aStr
, aFlags
, _retval
);
2682 return nsINetUtil_EscapeURL(net_util
, aStr
, aFlags
, _retval
);
2685 static nsresult NSAPI
nsNetUtil_UnescapeString(nsINetUtil
*iface
, const nsACString
*aStr
,
2686 PRUint32 aFlags
, nsACString
*_retval
)
2688 TRACE("(%p %08x %p)\n", aStr
, aFlags
, _retval
);
2690 return nsINetUtil_UnescapeString(net_util
, aStr
, aFlags
, _retval
);
2693 static nsresult NSAPI
nsNetUtil_ExtractCharsetFromContentType(nsINetUtil
*iface
, const nsACString
*aTypeHeader
,
2694 nsACString
*aCharset
, PRInt32
*aCharsetStart
, PRInt32
*aCharsetEnd
, PRBool
*_retval
)
2696 TRACE("(%p %p %p %p %p)\n", aTypeHeader
, aCharset
, aCharsetStart
, aCharsetEnd
, _retval
);
2698 return nsINetUtil_ExtractCharsetFromContentType(net_util
, aTypeHeader
, aCharset
, aCharsetStart
, aCharsetEnd
, _retval
);
2701 static const nsINetUtilVtbl nsNetUtilVtbl
= {
2702 nsNetUtil_QueryInterface
,
2705 nsNetUtil_ParseContentType
,
2706 nsNetUtil_ProtocolHasFlags
,
2707 nsNetUtil_URIChainHasFlags
,
2708 nsNetUtil_ToImmutableURI
,
2709 nsNetUtil_EscapeString
,
2710 nsNetUtil_EscapeURL
,
2711 nsNetUtil_UnescapeString
,
2712 nsNetUtil_ExtractCharsetFromContentType
2715 static nsINetUtil nsNetUtil
= { &nsNetUtilVtbl
};
2717 static nsresult NSAPI
nsIOService_QueryInterface(nsIIOService
*iface
, nsIIDRef riid
,
2722 if(IsEqualGUID(&IID_nsISupports
, riid
))
2723 *result
= &nsIOService
;
2724 else if(IsEqualGUID(&IID_nsIIOService
, riid
))
2725 *result
= &nsIOService
;
2726 else if(IsEqualGUID(&IID_nsINetUtil
, riid
))
2727 *result
= &nsNetUtil
;
2730 nsISupports_AddRef((nsISupports
*)*result
);
2734 FIXME("(%s %p)\n", debugstr_guid(riid
), result
);
2735 return NS_NOINTERFACE
;
2738 static nsresult NSAPI
nsIOServiceFactory_QueryInterface(nsIFactory
*iface
, nsIIDRef riid
,
2743 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
2744 TRACE("(IID_nsISupports %p)\n", result
);
2746 }else if(IsEqualGUID(&IID_nsIFactory
, riid
)) {
2747 TRACE("(IID_nsIFactory %p)\n", result
);
2752 nsIFactory_AddRef(iface
);
2756 WARN("(%s %p)\n", debugstr_guid(riid
), result
);
2757 return NS_NOINTERFACE
;
2760 static nsrefcnt NSAPI
nsIOServiceFactory_AddRef(nsIFactory
*iface
)
2765 static nsrefcnt NSAPI
nsIOServiceFactory_Release(nsIFactory
*iface
)
2770 static nsresult NSAPI
nsIOServiceFactory_CreateInstance(nsIFactory
*iface
,
2771 nsISupports
*aOuter
, const nsIID
*iid
, void **result
)
2773 return nsIIOService_QueryInterface(&nsIOService
, iid
, result
);
2776 static nsresult NSAPI
nsIOServiceFactory_LockFactory(nsIFactory
*iface
, PRBool lock
)
2778 WARN("(%x)\n", lock
);
2782 static const nsIFactoryVtbl nsIOServiceFactoryVtbl
= {
2783 nsIOServiceFactory_QueryInterface
,
2784 nsIOServiceFactory_AddRef
,
2785 nsIOServiceFactory_Release
,
2786 nsIOServiceFactory_CreateInstance
,
2787 nsIOServiceFactory_LockFactory
2790 static nsIFactory nsIOServiceFactory
= { &nsIOServiceFactoryVtbl
};
2792 void init_nsio(nsIComponentManager
*component_manager
, nsIComponentRegistrar
*registrar
)
2794 nsIFactory
*old_factory
= NULL
;
2797 nsres
= nsIComponentManager_GetClassObject(component_manager
, &NS_IOSERVICE_CID
,
2798 &IID_nsIFactory
, (void**)&old_factory
);
2799 if(NS_FAILED(nsres
)) {
2800 ERR("Could not get factory: %08x\n", nsres
);
2804 nsres
= nsIFactory_CreateInstance(old_factory
, NULL
, &IID_nsIIOService
, (void**)&nsio
);
2805 if(NS_FAILED(nsres
)) {
2806 ERR("Couldn not create nsIOService instance %08x\n", nsres
);
2807 nsIFactory_Release(old_factory
);
2811 nsres
= nsIIOService_QueryInterface(nsio
, &IID_nsINetUtil
, (void**)&net_util
);
2812 if(NS_FAILED(nsres
)) {
2813 WARN("Could not get nsINetUtil interface: %08x\n", nsres
);
2814 nsIIOService_Release(nsio
);
2818 nsres
= nsIComponentRegistrar_UnregisterFactory(registrar
, &NS_IOSERVICE_CID
, old_factory
);
2819 nsIFactory_Release(old_factory
);
2820 if(NS_FAILED(nsres
))
2821 ERR("UnregisterFactory failed: %08x\n", nsres
);
2823 nsres
= nsIComponentRegistrar_RegisterFactory(registrar
, &NS_IOSERVICE_CID
,
2824 NS_IOSERVICE_CLASSNAME
, NS_IOSERVICE_CONTRACTID
, &nsIOServiceFactory
);
2825 if(NS_FAILED(nsres
))
2826 ERR("RegisterFactory failed: %08x\n", nsres
);
2829 void release_nsio(void)
2832 nsINetUtil_Release(net_util
);
2837 nsIIOService_Release(nsio
);