2 * Copyright 2006-2010 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
35 #include "wine/debug.h"
37 #include "mshtml_private.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
42 #define NS_IOSERVICE_CLASSNAME "nsIOService"
43 #define NS_IOSERVICE_CONTRACTID "@mozilla.org/network/io-service;1"
45 static const IID NS_IOSERVICE_CID
=
46 {0x9ac9e770, 0x18bc, 0x11d3, {0x93, 0x37, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40}};
47 static const IID IID_nsWineURI
=
48 {0x5088272e, 0x900b, 0x11da, {0xc6,0x87, 0x00,0x0f,0xea,0x57,0xf2,0x1a}};
50 static nsIIOService
*nsio
= NULL
;
51 static nsINetUtil
*net_util
;
53 static const char *request_method_strings
[] = {"GET", "PUT", "POST"};
57 nsIStandardURL nsIStandardURL_iface
;
63 NSContainer
*container
;
64 windowref_t
*window_ref
;
65 nsChannelBSC
*channel_bsc
;
67 IUriBuilder
*uri_builder
;
72 static BOOL
ensure_uri(nsWineURI
*This
)
76 assert(This
->uri
|| This
->uri_builder
);
79 hres
= IUriBuilder_CreateUriSimple(This
->uri_builder
, 0, 0, &This
->uri
);
81 WARN("CreateUriSimple failed: %08x\n", hres
);
89 IUri
*nsuri_get_uri(nsWineURI
*nsuri
)
91 if(!ensure_uri(nsuri
))
94 IUri_AddRef(nsuri
->uri
);
98 static IUri
*get_uri_nofrag(IUri
*uri
)
100 IUriBuilder
*uri_builder
;
105 hres
= IUri_HasProperty(uri
, Uri_PROPERTY_FRAGMENT
, &b
);
106 if(SUCCEEDED(hres
) && !b
) {
111 hres
= CreateIUriBuilder(uri
, 0, 0, &uri_builder
);
115 hres
= IUriBuilder_RemoveProperties(uri_builder
, Uri_HAS_FRAGMENT
);
117 hres
= IUriBuilder_CreateUriSimple(uri_builder
, 0, 0, &ret
);
118 IUriBuilder_Release(uri_builder
);
125 BOOL
compare_ignoring_frag(IUri
*uri1
, IUri
*uri2
)
127 IUri
*uri_nofrag1
, *uri_nofrag2
;
130 uri_nofrag1
= get_uri_nofrag(uri1
);
134 uri_nofrag2
= get_uri_nofrag(uri2
);
136 IUri_IsEqual(uri_nofrag1
, uri_nofrag2
, &ret
);
137 IUri_Release(uri_nofrag2
);
140 IUri_Release(uri_nofrag1
);
144 static nsresult
create_nsuri(IUri
*,nsIURI
*,HTMLWindow
*,NSContainer
*,nsWineURI
**);
146 static const char *debugstr_nsacstr(const nsACString
*nsstr
)
150 nsACString_GetData(nsstr
, &data
);
151 return debugstr_a(data
);
154 HRESULT
nsuri_to_url(LPCWSTR nsuri
, BOOL ret_empty
, BSTR
*ret
)
156 const WCHAR
*ptr
= nsuri
;
158 static const WCHAR wine_prefixW
[] = {'w','i','n','e',':'};
160 if(!strncmpW(nsuri
, wine_prefixW
, sizeof(wine_prefixW
)/sizeof(WCHAR
)))
161 ptr
+= sizeof(wine_prefixW
)/sizeof(WCHAR
);
163 if(*ptr
|| ret_empty
) {
164 *ret
= SysAllocString(ptr
);
166 return E_OUTOFMEMORY
;
171 TRACE("%s -> %s\n", debugstr_w(nsuri
), debugstr_w(*ret
));
175 static BOOL
exec_shldocvw_67(HTMLDocumentObj
*doc
, BSTR url
)
177 IOleCommandTarget
*cmdtrg
= NULL
;
180 hres
= IOleClientSite_QueryInterface(doc
->client
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
181 if(SUCCEEDED(hres
)) {
182 VARIANT varUrl
, varRes
;
184 V_VT(&varUrl
) = VT_BSTR
;
185 V_BSTR(&varUrl
) = url
;
186 V_VT(&varRes
) = VT_BOOL
;
188 hres
= IOleCommandTarget_Exec(cmdtrg
, &CGID_ShellDocView
, 67, 0, &varUrl
, &varRes
);
190 IOleCommandTarget_Release(cmdtrg
);
192 if(SUCCEEDED(hres
) && !V_BOOL(&varRes
)) {
193 TRACE("got VARIANT_FALSE, do not load\n");
201 static nsresult
before_async_open(nsChannel
*channel
, NSContainer
*container
, BOOL
*cancel
)
203 HTMLDocumentObj
*doc
= container
->doc
;
209 NSContainer
*container_iter
= container
;
211 hlnf
= HLNF_OPENINNEWWINDOW
;
212 while(!container_iter
->doc
)
213 container_iter
= container_iter
->parent
;
214 doc
= container_iter
->doc
;
222 hres
= IUri_GetDisplayUri(channel
->uri
->uri
, &display_uri
);
224 return NS_ERROR_FAILURE
;
229 b
= !exec_shldocvw_67(doc
, display_uri
);
231 SysFreeString(display_uri
);
237 hres
= hlink_frame_navigate(&doc
->basedoc
, display_uri
, channel
, hlnf
, cancel
);
238 SysFreeString(display_uri
);
244 HRESULT
load_nsuri(HTMLWindow
*window
, nsWineURI
*uri
, nsChannelBSC
*channelbsc
, DWORD flags
)
246 nsIWebNavigation
*web_navigation
;
247 nsIDocShell
*doc_shell
;
248 HTMLDocumentNode
*doc
;
251 nsres
= get_nsinterface((nsISupports
*)window
->nswindow
, &IID_nsIWebNavigation
, (void**)&web_navigation
);
252 if(NS_FAILED(nsres
)) {
253 ERR("Could not get nsIWebNavigation interface: %08x\n", nsres
);
257 nsres
= nsIWebNavigation_QueryInterface(web_navigation
, &IID_nsIDocShell
, (void**)&doc_shell
);
258 nsIWebNavigation_Release(web_navigation
);
259 if(NS_FAILED(nsres
)) {
260 ERR("Could not get nsIDocShell: %08x\n", nsres
);
264 uri
->channel_bsc
= channelbsc
;
266 doc
->skip_mutation_notif
= TRUE
;
267 nsres
= nsIDocShell_LoadURI(doc_shell
, (nsIURI
*)&uri
->nsIURL_iface
, NULL
, flags
, FALSE
);
268 if(doc
== window
->doc
)
269 doc
->skip_mutation_notif
= FALSE
;
270 uri
->channel_bsc
= NULL
;
271 nsIDocShell_Release(doc_shell
);
272 if(NS_FAILED(nsres
)) {
273 WARN("LoadURI failed: %08x\n", nsres
);
280 static void set_uri_nscontainer(nsWineURI
*This
, NSContainer
*nscontainer
)
282 if(This
->container
) {
283 if(This
->container
== nscontainer
)
285 TRACE("Changing %p -> %p\n", This
->container
, nscontainer
);
286 nsIWebBrowserChrome_Release(&This
->container
->nsIWebBrowserChrome_iface
);
290 nsIWebBrowserChrome_AddRef(&nscontainer
->nsIWebBrowserChrome_iface
);
291 This
->container
= nscontainer
;
294 static void set_uri_window(nsWineURI
*This
, HTMLWindow
*window
)
296 if(This
->window_ref
) {
297 if(This
->window_ref
->window
== window
)
299 TRACE("Changing %p -> %p\n", This
->window_ref
->window
, window
);
300 windowref_release(This
->window_ref
);
304 windowref_addref(window
->window_ref
);
305 This
->window_ref
= window
->window_ref
;
308 set_uri_nscontainer(This
, window
->doc_obj
->nscontainer
);
310 This
->window_ref
= NULL
;
314 static inline BOOL
is_http_channel(nsChannel
*This
)
316 return This
->url_scheme
== URL_SCHEME_HTTP
|| This
->url_scheme
== URL_SCHEME_HTTPS
;
319 static http_header_t
*find_http_header(struct list
*headers
, const WCHAR
*name
, int len
)
323 LIST_FOR_EACH_ENTRY(iter
, headers
, http_header_t
, entry
) {
324 if(!strcmpiW(iter
->header
, name
))
331 static nsresult
get_channel_http_header(struct list
*headers
, const nsACString
*header_name_str
,
334 const char *header_namea
;
335 http_header_t
*header
;
339 nsACString_GetData(header_name_str
, &header_namea
);
340 header_name
= heap_strdupAtoW(header_namea
);
342 return NS_ERROR_UNEXPECTED
;
344 header
= find_http_header(headers
, header_name
, strlenW(header_name
));
345 heap_free(header_name
);
347 return NS_ERROR_NOT_AVAILABLE
;
349 data
= heap_strdupWtoA(header
->data
);
351 return NS_ERROR_UNEXPECTED
;
353 TRACE("%s -> %s\n", debugstr_a(header_namea
), debugstr_a(data
));
354 nsACString_SetData(_retval
, data
);
359 HRESULT
set_http_header(struct list
*headers
, const WCHAR
*name
, int name_len
,
360 const WCHAR
*value
, int value_len
)
362 http_header_t
*header
;
364 TRACE("%s: %s\n", debugstr_wn(name
, name_len
), debugstr_wn(value
, value_len
));
366 header
= find_http_header(headers
, name
, name_len
);
370 new_data
= heap_strndupW(value
, value_len
);
372 return E_OUTOFMEMORY
;
374 heap_free(header
->data
);
375 header
->data
= new_data
;
377 header
= heap_alloc(sizeof(http_header_t
));
379 return E_OUTOFMEMORY
;
381 header
->header
= heap_strndupW(name
, name_len
);
382 header
->data
= heap_strndupW(value
, value_len
);
383 if(!header
->header
|| !header
->data
) {
384 heap_free(header
->header
);
385 heap_free(header
->data
);
387 return E_OUTOFMEMORY
;
390 list_add_tail(headers
, &header
->entry
);
396 static nsresult
set_channel_http_header(struct list
*headers
, const nsACString
*name_str
,
397 const nsACString
*value_str
)
399 const char *namea
, *valuea
;
403 nsACString_GetData(name_str
, &namea
);
404 name
= heap_strdupAtoW(namea
);
406 return NS_ERROR_UNEXPECTED
;
408 nsACString_GetData(value_str
, &valuea
);
409 value
= heap_strdupAtoW(valuea
);
412 return NS_ERROR_UNEXPECTED
;
415 hres
= set_http_header(headers
, name
, strlenW(name
), value
, strlenW(value
));
419 return SUCCEEDED(hres
) ? NS_OK
: NS_ERROR_UNEXPECTED
;
422 static nsresult
visit_http_headers(struct list
*headers
, nsIHttpHeaderVisitor
*visitor
)
424 nsACString header_str
, value_str
;
425 char *header
, *value
;
429 LIST_FOR_EACH_ENTRY(iter
, headers
, http_header_t
, entry
) {
430 header
= heap_strdupWtoA(iter
->header
);
432 return NS_ERROR_OUT_OF_MEMORY
;
434 value
= heap_strdupWtoA(iter
->data
);
437 return NS_ERROR_OUT_OF_MEMORY
;
440 nsACString_InitDepend(&header_str
, header
);
441 nsACString_InitDepend(&value_str
, value
);
442 nsres
= nsIHttpHeaderVisitor_VisitHeader(visitor
, &header_str
, &value_str
);
443 nsACString_Finish(&header_str
);
444 nsACString_Finish(&value_str
);
454 static void free_http_headers(struct list
*list
)
456 http_header_t
*iter
, *iter_next
;
458 LIST_FOR_EACH_ENTRY_SAFE(iter
, iter_next
, list
, http_header_t
, entry
) {
459 list_remove(&iter
->entry
);
460 heap_free(iter
->header
);
461 heap_free(iter
->data
);
466 static inline nsChannel
*impl_from_nsIHttpChannel(nsIHttpChannel
*iface
)
468 return CONTAINING_RECORD(iface
, nsChannel
, nsIHttpChannel_iface
);
471 static nsresult NSAPI
nsChannel_QueryInterface(nsIHttpChannel
*iface
, nsIIDRef riid
, void **result
)
473 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
475 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
476 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
477 *result
= &This
->nsIHttpChannel_iface
;
478 }else if(IsEqualGUID(&IID_nsIRequest
, riid
)) {
479 TRACE("(%p)->(IID_nsIRequest %p)\n", This
, result
);
480 *result
= &This
->nsIHttpChannel_iface
;
481 }else if(IsEqualGUID(&IID_nsIChannel
, riid
)) {
482 TRACE("(%p)->(IID_nsIChannel %p)\n", This
, result
);
483 *result
= &This
->nsIHttpChannel_iface
;
484 }else if(IsEqualGUID(&IID_nsIHttpChannel
, riid
)) {
485 TRACE("(%p)->(IID_nsIHttpChannel %p)\n", This
, result
);
486 *result
= is_http_channel(This
) ? &This
->nsIHttpChannel_iface
: NULL
;
487 }else if(IsEqualGUID(&IID_nsIUploadChannel
, riid
)) {
488 TRACE("(%p)->(IID_nsIUploadChannel %p)\n", This
, result
);
489 *result
= &This
->nsIUploadChannel_iface
;
490 }else if(IsEqualGUID(&IID_nsIHttpChannelInternal
, riid
)) {
491 TRACE("(%p)->(IID_nsIHttpChannelInternal %p)\n", This
, result
);
492 *result
= is_http_channel(This
) ? &This
->nsIHttpChannelInternal_iface
: NULL
;
494 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), result
);
499 nsIChannel_AddRef(&This
->nsIHttpChannel_iface
);
503 return NS_NOINTERFACE
;
506 static nsrefcnt NSAPI
nsChannel_AddRef(nsIHttpChannel
*iface
)
508 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
509 nsrefcnt ref
= InterlockedIncrement(&This
->ref
);
511 TRACE("(%p) ref=%d\n", This
, ref
);
516 static nsrefcnt NSAPI
nsChannel_Release(nsIHttpChannel
*iface
)
518 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
519 LONG ref
= InterlockedDecrement(&This
->ref
);
522 nsIURI_Release(&This
->uri
->nsIURL_iface
);
524 nsISupports_Release(This
->owner
);
525 if(This
->post_data_stream
)
526 nsIInputStream_Release(This
->post_data_stream
);
528 nsILoadGroup_Release(This
->load_group
);
529 if(This
->notif_callback
)
530 nsIInterfaceRequestor_Release(This
->notif_callback
);
531 if(This
->original_uri
)
532 nsIURI_Release(This
->original_uri
);
534 nsIURI_Release(This
->referrer
);
536 free_http_headers(&This
->response_headers
);
537 free_http_headers(&This
->request_headers
);
539 heap_free(This
->content_type
);
540 heap_free(This
->charset
);
547 static nsresult NSAPI
nsChannel_GetName(nsIHttpChannel
*iface
, nsACString
*aName
)
549 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
551 TRACE("(%p)->(%p)\n", This
, aName
);
553 return nsIURI_GetSpec(&This
->uri
->nsIURL_iface
, aName
);
556 static nsresult NSAPI
nsChannel_IsPending(nsIHttpChannel
*iface
, PRBool
*_retval
)
558 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
560 FIXME("(%p)->(%p)\n", This
, _retval
);
562 return NS_ERROR_NOT_IMPLEMENTED
;
565 static nsresult NSAPI
nsChannel_GetStatus(nsIHttpChannel
*iface
, nsresult
*aStatus
)
567 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
569 WARN("(%p)->(%p) returning NS_OK\n", This
, aStatus
);
571 return *aStatus
= NS_OK
;
574 static nsresult NSAPI
nsChannel_Cancel(nsIHttpChannel
*iface
, nsresult aStatus
)
576 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
578 FIXME("(%p)->(%08x)\n", This
, aStatus
);
580 return NS_ERROR_NOT_IMPLEMENTED
;
583 static nsresult NSAPI
nsChannel_Suspend(nsIHttpChannel
*iface
)
585 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
587 FIXME("(%p)\n", This
);
589 return NS_ERROR_NOT_IMPLEMENTED
;
592 static nsresult NSAPI
nsChannel_Resume(nsIHttpChannel
*iface
)
594 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
596 FIXME("(%p)\n", This
);
598 return NS_ERROR_NOT_IMPLEMENTED
;
601 static nsresult NSAPI
nsChannel_GetLoadGroup(nsIHttpChannel
*iface
, nsILoadGroup
**aLoadGroup
)
603 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
605 TRACE("(%p)->(%p)\n", This
, aLoadGroup
);
608 nsILoadGroup_AddRef(This
->load_group
);
610 *aLoadGroup
= This
->load_group
;
614 static nsresult NSAPI
nsChannel_SetLoadGroup(nsIHttpChannel
*iface
, nsILoadGroup
*aLoadGroup
)
616 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
618 TRACE("(%p)->(%p)\n", This
, aLoadGroup
);
621 nsILoadGroup_Release(This
->load_group
);
623 nsILoadGroup_AddRef(aLoadGroup
);
624 This
->load_group
= aLoadGroup
;
629 static nsresult NSAPI
nsChannel_GetLoadFlags(nsIHttpChannel
*iface
, nsLoadFlags
*aLoadFlags
)
631 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
633 TRACE("(%p)->(%p)\n", This
, aLoadFlags
);
635 *aLoadFlags
= This
->load_flags
;
639 static nsresult NSAPI
nsChannel_SetLoadFlags(nsIHttpChannel
*iface
, nsLoadFlags aLoadFlags
)
641 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
643 TRACE("(%p)->(%08x)\n", This
, aLoadFlags
);
645 This
->load_flags
= aLoadFlags
;
649 static nsresult NSAPI
nsChannel_GetOriginalURI(nsIHttpChannel
*iface
, nsIURI
**aOriginalURI
)
651 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
653 TRACE("(%p)->(%p)\n", This
, aOriginalURI
);
655 if(This
->original_uri
)
656 nsIURI_AddRef(This
->original_uri
);
658 *aOriginalURI
= This
->original_uri
;
662 static nsresult NSAPI
nsChannel_SetOriginalURI(nsIHttpChannel
*iface
, nsIURI
*aOriginalURI
)
664 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
666 TRACE("(%p)->(%p)\n", This
, aOriginalURI
);
668 if(This
->original_uri
)
669 nsIURI_Release(This
->original_uri
);
671 nsIURI_AddRef(aOriginalURI
);
672 This
->original_uri
= aOriginalURI
;
676 static nsresult NSAPI
nsChannel_GetURI(nsIHttpChannel
*iface
, nsIURI
**aURI
)
678 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
680 TRACE("(%p)->(%p)\n", This
, aURI
);
682 nsIURI_AddRef(&This
->uri
->nsIURL_iface
);
683 *aURI
= (nsIURI
*)This
->uri
;
688 static nsresult NSAPI
nsChannel_GetOwner(nsIHttpChannel
*iface
, nsISupports
**aOwner
)
690 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
692 TRACE("(%p)->(%p)\n", This
, aOwner
);
695 nsISupports_AddRef(This
->owner
);
696 *aOwner
= This
->owner
;
701 static nsresult NSAPI
nsChannel_SetOwner(nsIHttpChannel
*iface
, nsISupports
*aOwner
)
703 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
705 TRACE("(%p)->(%p)\n", This
, aOwner
);
708 nsISupports_AddRef(aOwner
);
710 nsISupports_Release(This
->owner
);
711 This
->owner
= aOwner
;
716 static nsresult NSAPI
nsChannel_GetNotificationCallbacks(nsIHttpChannel
*iface
,
717 nsIInterfaceRequestor
**aNotificationCallbacks
)
719 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
721 TRACE("(%p)->(%p)\n", This
, aNotificationCallbacks
);
723 if(This
->notif_callback
)
724 nsIInterfaceRequestor_AddRef(This
->notif_callback
);
725 *aNotificationCallbacks
= This
->notif_callback
;
730 static nsresult NSAPI
nsChannel_SetNotificationCallbacks(nsIHttpChannel
*iface
,
731 nsIInterfaceRequestor
*aNotificationCallbacks
)
733 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
735 TRACE("(%p)->(%p)\n", This
, aNotificationCallbacks
);
737 if(This
->notif_callback
)
738 nsIInterfaceRequestor_Release(This
->notif_callback
);
739 if(aNotificationCallbacks
)
740 nsIInterfaceRequestor_AddRef(aNotificationCallbacks
);
742 This
->notif_callback
= aNotificationCallbacks
;
747 static nsresult NSAPI
nsChannel_GetSecurityInfo(nsIHttpChannel
*iface
, nsISupports
**aSecurityInfo
)
749 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
751 TRACE("(%p)->(%p)\n", This
, aSecurityInfo
);
753 return NS_ERROR_NOT_IMPLEMENTED
;
756 static nsresult NSAPI
nsChannel_GetContentType(nsIHttpChannel
*iface
, nsACString
*aContentType
)
758 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
760 TRACE("(%p)->(%p)\n", This
, aContentType
);
762 if(This
->content_type
) {
763 nsACString_SetData(aContentType
, This
->content_type
);
767 WARN("unknown type\n");
768 return NS_ERROR_FAILURE
;
771 static nsresult NSAPI
nsChannel_SetContentType(nsIHttpChannel
*iface
,
772 const nsACString
*aContentType
)
774 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
775 const char *content_type
;
777 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aContentType
));
779 nsACString_GetData(aContentType
, &content_type
);
780 heap_free(This
->content_type
);
781 This
->content_type
= heap_strdupA(content_type
);
786 static nsresult NSAPI
nsChannel_GetContentCharset(nsIHttpChannel
*iface
,
787 nsACString
*aContentCharset
)
789 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
791 TRACE("(%p)->(%p)\n", This
, aContentCharset
);
794 nsACString_SetData(aContentCharset
, This
->charset
);
798 nsACString_SetData(aContentCharset
, "");
802 static nsresult NSAPI
nsChannel_SetContentCharset(nsIHttpChannel
*iface
,
803 const nsACString
*aContentCharset
)
805 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
809 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aContentCharset
));
811 nsACString_GetData(aContentCharset
, &data
);
812 charset
= heap_strdupA(data
);
814 return NS_ERROR_OUT_OF_MEMORY
;
816 heap_free(This
->charset
);
817 This
->charset
= charset
;
821 static nsresult NSAPI
nsChannel_GetContentLength(nsIHttpChannel
*iface
, PRInt32
*aContentLength
)
823 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
825 FIXME("(%p)->(%p)\n", This
, aContentLength
);
827 return NS_ERROR_NOT_IMPLEMENTED
;
830 static nsresult NSAPI
nsChannel_SetContentLength(nsIHttpChannel
*iface
, PRInt32 aContentLength
)
832 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
834 FIXME("(%p)->(%d)\n", This
, aContentLength
);
836 return NS_ERROR_NOT_IMPLEMENTED
;
839 static nsresult NSAPI
nsChannel_Open(nsIHttpChannel
*iface
, nsIInputStream
**_retval
)
841 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
843 FIXME("(%p)->(%p)\n", This
, _retval
);
845 return NS_ERROR_NOT_IMPLEMENTED
;
848 static HTMLWindow
*get_window_from_load_group(nsChannel
*This
)
857 nsres
= nsILoadGroup_GetDefaultLoadRequest(This
->load_group
, &req
);
858 if(NS_FAILED(nsres
)) {
859 ERR("GetDefaultLoadRequest failed: %08x\n", nsres
);
866 nsres
= nsIRequest_QueryInterface(req
, &IID_nsIChannel
, (void**)&channel
);
867 nsIRequest_Release(req
);
868 if(NS_FAILED(nsres
)) {
869 WARN("Could not get nsIChannel interface: %08x\n", nsres
);
873 nsres
= nsIChannel_GetURI(channel
, &uri
);
874 nsIChannel_Release(channel
);
875 if(NS_FAILED(nsres
)) {
876 ERR("GetURI failed: %08x\n", nsres
);
880 nsres
= nsIURI_QueryInterface(uri
, &IID_nsWineURI
, (void**)&wine_uri
);
882 if(NS_FAILED(nsres
)) {
883 TRACE("Could not get nsWineURI: %08x\n", nsres
);
887 window
= wine_uri
->window_ref
? wine_uri
->window_ref
->window
: NULL
;
889 IHTMLWindow2_AddRef(&window
->IHTMLWindow2_iface
);
890 nsIURI_Release(&wine_uri
->nsIURL_iface
);
895 static HTMLWindow
*get_channel_window(nsChannel
*This
)
897 nsIWebProgress
*web_progress
;
898 nsIDOMWindow
*nswindow
;
902 if(This
->load_group
) {
903 nsIRequestObserver
*req_observer
;
905 nsres
= nsILoadGroup_GetGroupObserver(This
->load_group
, &req_observer
);
906 if(NS_FAILED(nsres
) || !req_observer
) {
907 ERR("GetGroupObserver failed: %08x\n", nsres
);
911 nsres
= nsIRequestObserver_QueryInterface(req_observer
, &IID_nsIWebProgress
, (void**)&web_progress
);
912 nsIRequestObserver_Release(req_observer
);
913 if(NS_FAILED(nsres
)) {
914 ERR("Could not get nsIWebProgress iface: %08x\n", nsres
);
917 }else if(This
->notif_callback
) {
918 nsres
= nsIInterfaceRequestor_GetInterface(This
->notif_callback
, &IID_nsIWebProgress
, (void**)&web_progress
);
919 if(NS_FAILED(nsres
)) {
920 ERR("GetInterface(IID_nsIWebProgress failed: %08x\n", nsres
);
924 ERR("no load group nor notif callback\n");
928 nsres
= nsIWebProgress_GetDOMWindow(web_progress
, &nswindow
);
929 nsIWebProgress_Release(web_progress
);
930 if(NS_FAILED(nsres
) || !nswindow
) {
931 ERR("GetDOMWindow failed: %08x\n", nsres
);
935 window
= nswindow_to_window(nswindow
);
936 nsIDOMWindow_Release(nswindow
);
939 IHTMLWindow2_AddRef(&window
->IHTMLWindow2_iface
);
941 FIXME("NULL window for %p\n", nswindow
);
947 HTMLDocumentNode
*doc
;
948 nsChannelBSC
*bscallback
;
949 } start_binding_task_t
;
951 static void start_binding_proc(task_t
*_task
)
953 start_binding_task_t
*task
= (start_binding_task_t
*)_task
;
955 start_binding(NULL
, task
->doc
, (BSCallback
*)task
->bscallback
, NULL
);
958 static void start_binding_task_destr(task_t
*_task
)
960 start_binding_task_t
*task
= (start_binding_task_t
*)_task
;
962 IBindStatusCallback_Release(&task
->bscallback
->bsc
.IBindStatusCallback_iface
);
966 static nsresult
async_open(nsChannel
*This
, HTMLWindow
*window
, BOOL is_doc_channel
, nsIStreamListener
*listener
,
967 nsISupports
*context
)
969 nsChannelBSC
*bscallback
;
970 IMoniker
*mon
= NULL
;
973 hres
= CreateURLMonikerEx2(NULL
, This
->uri
->uri
, &mon
, 0);
975 WARN("CreateURLMoniker failed: %08x\n", hres
);
976 return NS_ERROR_UNEXPECTED
;
980 set_current_mon(window
, mon
);
982 hres
= create_channelbsc(mon
, NULL
, NULL
, 0, &bscallback
);
983 IMoniker_Release(mon
);
985 return NS_ERROR_UNEXPECTED
;
987 channelbsc_set_channel(bscallback
, This
, listener
, context
);
990 set_window_bscallback(window
, bscallback
);
991 async_start_doc_binding(window
, bscallback
);
992 IUnknown_Release((IUnknown
*)bscallback
);
994 start_binding_task_t
*task
= heap_alloc(sizeof(start_binding_task_t
));
996 task
->doc
= window
->doc
;
997 task
->bscallback
= bscallback
;
998 push_task(&task
->header
, start_binding_proc
, start_binding_task_destr
, window
->doc
->basedoc
.task_magic
);
1004 static nsresult NSAPI
nsChannel_AsyncOpen(nsIHttpChannel
*iface
, nsIStreamListener
*aListener
,
1005 nsISupports
*aContext
)
1007 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1008 HTMLWindow
*window
= NULL
;
1009 BOOL cancel
= FALSE
;
1010 nsresult nsres
= NS_OK
;
1012 TRACE("(%p)->(%p %p)\n", This
, aListener
, aContext
);
1014 if(!ensure_uri(This
->uri
))
1015 return NS_ERROR_FAILURE
;
1017 if(TRACE_ON(mshtml
)) {
1019 IUri_GetDisplayUri(This
->uri
->uri
, &uri_str
);
1020 TRACE("opening %s\n", debugstr_w(uri_str
));
1021 SysFreeString(uri_str
);
1024 if(This
->uri
->is_doc_uri
) {
1025 window
= get_channel_window(This
);
1027 set_uri_window(This
->uri
, window
);
1028 }else if(This
->uri
->container
) {
1031 /* nscontainer->doc should be NULL which means navigation to a new window */
1032 if(This
->uri
->container
->doc
)
1033 FIXME("nscontainer->doc = %p\n", This
->uri
->container
->doc
);
1035 nsres
= before_async_open(This
, This
->uri
->container
, &b
);
1036 if(NS_FAILED(nsres
))
1039 FIXME("Navigation not cancelled\n");
1040 return NS_ERROR_UNEXPECTED
;
1045 if(This
->uri
->window_ref
&& This
->uri
->window_ref
->window
) {
1046 window
= This
->uri
->window_ref
->window
;
1047 IHTMLWindow2_AddRef(&window
->IHTMLWindow2_iface
);
1049 /* FIXME: Analyze removing get_window_from_load_group call */
1050 if(This
->load_group
)
1051 window
= get_window_from_load_group(This
);
1053 window
= get_channel_window(This
);
1055 set_uri_window(This
->uri
, window
);
1060 ERR("window = NULL\n");
1061 return NS_ERROR_UNEXPECTED
;
1064 if(This
->uri
->is_doc_uri
&& window
== window
->doc_obj
->basedoc
.window
) {
1065 if(This
->uri
->channel_bsc
) {
1066 channelbsc_set_channel(This
->uri
->channel_bsc
, This
, aListener
, aContext
);
1068 if(window
->doc_obj
->mime
) {
1069 heap_free(This
->content_type
);
1070 This
->content_type
= heap_strdupWtoA(window
->doc_obj
->mime
);
1075 nsres
= before_async_open(This
, window
->doc_obj
->nscontainer
, &cancel
);
1076 if(NS_SUCCEEDED(nsres
) && cancel
) {
1077 TRACE("canceled\n");
1078 nsres
= NS_BINDING_ABORTED
;
1084 nsres
= async_open(This
, window
, This
->uri
->is_doc_uri
, aListener
, aContext
);
1086 if(NS_SUCCEEDED(nsres
) && This
->load_group
) {
1087 nsres
= nsILoadGroup_AddRequest(This
->load_group
, (nsIRequest
*)&This
->nsIHttpChannel_iface
,
1089 if(NS_FAILED(nsres
))
1090 ERR("AddRequest failed: %08x\n", nsres
);
1093 IHTMLWindow2_Release(&window
->IHTMLWindow2_iface
);
1097 static nsresult NSAPI
nsChannel_GetRequestMethod(nsIHttpChannel
*iface
, nsACString
*aRequestMethod
)
1099 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1101 TRACE("(%p)->(%p)\n", This
, aRequestMethod
);
1103 nsACString_SetData(aRequestMethod
, request_method_strings
[This
->request_method
]);
1107 static nsresult NSAPI
nsChannel_SetRequestMethod(nsIHttpChannel
*iface
,
1108 const nsACString
*aRequestMethod
)
1110 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1114 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aRequestMethod
));
1116 nsACString_GetData(aRequestMethod
, &method
);
1117 for(i
=0; i
< sizeof(request_method_strings
)/sizeof(*request_method_strings
); i
++) {
1118 if(!strcasecmp(method
, request_method_strings
[i
])) {
1119 This
->request_method
= i
;
1124 ERR("Invalid method %s\n", debugstr_a(method
));
1125 return NS_ERROR_UNEXPECTED
;
1128 static nsresult NSAPI
nsChannel_GetReferrer(nsIHttpChannel
*iface
, nsIURI
**aReferrer
)
1130 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1132 TRACE("(%p)->(%p)\n", This
, aReferrer
);
1135 nsIURI_AddRef(This
->referrer
);
1136 *aReferrer
= This
->referrer
;
1140 static nsresult NSAPI
nsChannel_SetReferrer(nsIHttpChannel
*iface
, nsIURI
*aReferrer
)
1142 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1144 TRACE("(%p)->(%p)\n", This
, aReferrer
);
1147 nsIURI_AddRef(aReferrer
);
1149 nsIURI_Release(This
->referrer
);
1150 This
->referrer
= aReferrer
;
1154 static nsresult NSAPI
nsChannel_GetRequestHeader(nsIHttpChannel
*iface
,
1155 const nsACString
*aHeader
, nsACString
*_retval
)
1157 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1159 TRACE("(%p)->(%s %p)\n", This
, debugstr_nsacstr(aHeader
), _retval
);
1161 return get_channel_http_header(&This
->request_headers
, aHeader
, _retval
);
1164 static nsresult NSAPI
nsChannel_SetRequestHeader(nsIHttpChannel
*iface
,
1165 const nsACString
*aHeader
, const nsACString
*aValue
, PRBool aMerge
)
1167 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1169 TRACE("(%p)->(%s %s %x)\n", This
, debugstr_nsacstr(aHeader
), debugstr_nsacstr(aValue
), aMerge
);
1172 FIXME("aMerge not supported\n");
1174 return set_channel_http_header(&This
->request_headers
, aHeader
, aValue
);
1177 static nsresult NSAPI
nsChannel_VisitRequestHeaders(nsIHttpChannel
*iface
,
1178 nsIHttpHeaderVisitor
*aVisitor
)
1180 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1182 FIXME("(%p)->(%p)\n", This
, aVisitor
);
1184 return NS_ERROR_NOT_IMPLEMENTED
;
1187 static nsresult NSAPI
nsChannel_GetAllowPipelining(nsIHttpChannel
*iface
, PRBool
*aAllowPipelining
)
1189 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1191 FIXME("(%p)->(%p)\n", This
, aAllowPipelining
);
1193 return NS_ERROR_NOT_IMPLEMENTED
;
1196 static nsresult NSAPI
nsChannel_SetAllowPipelining(nsIHttpChannel
*iface
, PRBool aAllowPipelining
)
1198 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1200 FIXME("(%p)->(%x)\n", This
, aAllowPipelining
);
1202 return NS_ERROR_NOT_IMPLEMENTED
;
1205 static nsresult NSAPI
nsChannel_GetRedirectionLimit(nsIHttpChannel
*iface
, PRUint32
*aRedirectionLimit
)
1207 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1209 FIXME("(%p)->(%p)\n", This
, aRedirectionLimit
);
1211 return NS_ERROR_NOT_IMPLEMENTED
;
1214 static nsresult NSAPI
nsChannel_SetRedirectionLimit(nsIHttpChannel
*iface
, PRUint32 aRedirectionLimit
)
1216 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1218 FIXME("(%p)->(%u)\n", This
, aRedirectionLimit
);
1220 return NS_ERROR_NOT_IMPLEMENTED
;
1223 static nsresult NSAPI
nsChannel_GetResponseStatus(nsIHttpChannel
*iface
, PRUint32
*aResponseStatus
)
1225 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1227 TRACE("(%p)->(%p)\n", This
, aResponseStatus
);
1229 if(This
->response_status
) {
1230 *aResponseStatus
= This
->response_status
;
1234 WARN("No response status\n");
1235 return NS_ERROR_UNEXPECTED
;
1238 static nsresult NSAPI
nsChannel_GetResponseStatusText(nsIHttpChannel
*iface
,
1239 nsACString
*aResponseStatusText
)
1241 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1243 FIXME("(%p)->(%p)\n", This
, aResponseStatusText
);
1245 return NS_ERROR_NOT_IMPLEMENTED
;
1248 static nsresult NSAPI
nsChannel_GetRequestSucceeded(nsIHttpChannel
*iface
,
1249 PRBool
*aRequestSucceeded
)
1251 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1253 TRACE("(%p)->(%p)\n", This
, aRequestSucceeded
);
1255 if(!This
->response_status
)
1256 return NS_ERROR_NOT_AVAILABLE
;
1258 *aRequestSucceeded
= This
->response_status
/100 == 2;
1263 static nsresult NSAPI
nsChannel_GetResponseHeader(nsIHttpChannel
*iface
,
1264 const nsACString
*header
, nsACString
*_retval
)
1266 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1268 TRACE("(%p)->(%s %p)\n", This
, debugstr_nsacstr(header
), _retval
);
1270 return get_channel_http_header(&This
->response_headers
, header
, _retval
);
1273 static nsresult NSAPI
nsChannel_SetResponseHeader(nsIHttpChannel
*iface
,
1274 const nsACString
*header
, const nsACString
*value
, PRBool merge
)
1276 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1278 FIXME("(%p)->(%s %s %x)\n", This
, debugstr_nsacstr(header
), debugstr_nsacstr(value
), merge
);
1280 return NS_ERROR_NOT_IMPLEMENTED
;
1283 static nsresult NSAPI
nsChannel_VisitResponseHeaders(nsIHttpChannel
*iface
,
1284 nsIHttpHeaderVisitor
*aVisitor
)
1286 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1288 TRACE("(%p)->(%p)\n", This
, aVisitor
);
1290 return visit_http_headers(&This
->response_headers
, aVisitor
);
1293 static nsresult NSAPI
nsChannel_IsNoStoreResponse(nsIHttpChannel
*iface
, PRBool
*_retval
)
1295 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1296 http_header_t
*header
;
1298 static const WCHAR cache_controlW
[] = {'C','a','c','h','e','-','C','o','n','t','r','o','l'};
1299 static const WCHAR no_storeW
[] = {'n','o','-','s','t','o','r','e',0};
1301 TRACE("(%p)->(%p)\n", This
, _retval
);
1303 header
= find_http_header(&This
->response_headers
, cache_controlW
, sizeof(cache_controlW
)/sizeof(WCHAR
));
1304 *_retval
= header
&& !strcmpiW(header
->data
, no_storeW
);
1308 static nsresult NSAPI
nsChannel_IsNoCacheResponse(nsIHttpChannel
*iface
, PRBool
*_retval
)
1310 nsChannel
*This
= impl_from_nsIHttpChannel(iface
);
1312 FIXME("(%p)->(%p)\n", This
, _retval
);
1314 return NS_ERROR_NOT_IMPLEMENTED
;
1317 static const nsIHttpChannelVtbl nsChannelVtbl
= {
1318 nsChannel_QueryInterface
,
1322 nsChannel_IsPending
,
1323 nsChannel_GetStatus
,
1327 nsChannel_GetLoadGroup
,
1328 nsChannel_SetLoadGroup
,
1329 nsChannel_GetLoadFlags
,
1330 nsChannel_SetLoadFlags
,
1331 nsChannel_GetOriginalURI
,
1332 nsChannel_SetOriginalURI
,
1336 nsChannel_GetNotificationCallbacks
,
1337 nsChannel_SetNotificationCallbacks
,
1338 nsChannel_GetSecurityInfo
,
1339 nsChannel_GetContentType
,
1340 nsChannel_SetContentType
,
1341 nsChannel_GetContentCharset
,
1342 nsChannel_SetContentCharset
,
1343 nsChannel_GetContentLength
,
1344 nsChannel_SetContentLength
,
1346 nsChannel_AsyncOpen
,
1347 nsChannel_GetRequestMethod
,
1348 nsChannel_SetRequestMethod
,
1349 nsChannel_GetReferrer
,
1350 nsChannel_SetReferrer
,
1351 nsChannel_GetRequestHeader
,
1352 nsChannel_SetRequestHeader
,
1353 nsChannel_VisitRequestHeaders
,
1354 nsChannel_GetAllowPipelining
,
1355 nsChannel_SetAllowPipelining
,
1356 nsChannel_GetRedirectionLimit
,
1357 nsChannel_SetRedirectionLimit
,
1358 nsChannel_GetResponseStatus
,
1359 nsChannel_GetResponseStatusText
,
1360 nsChannel_GetRequestSucceeded
,
1361 nsChannel_GetResponseHeader
,
1362 nsChannel_SetResponseHeader
,
1363 nsChannel_VisitResponseHeaders
,
1364 nsChannel_IsNoStoreResponse
,
1365 nsChannel_IsNoCacheResponse
1368 static inline nsChannel
*impl_from_nsIUploadChannel(nsIUploadChannel
*iface
)
1370 return CONTAINING_RECORD(iface
, nsChannel
, nsIUploadChannel_iface
);
1373 static nsresult NSAPI
nsUploadChannel_QueryInterface(nsIUploadChannel
*iface
, nsIIDRef riid
,
1376 nsChannel
*This
= impl_from_nsIUploadChannel(iface
);
1377 return nsIChannel_QueryInterface(&This
->nsIHttpChannel_iface
, riid
, result
);
1380 static nsrefcnt NSAPI
nsUploadChannel_AddRef(nsIUploadChannel
*iface
)
1382 nsChannel
*This
= impl_from_nsIUploadChannel(iface
);
1383 return nsIChannel_AddRef(&This
->nsIHttpChannel_iface
);
1386 static nsrefcnt NSAPI
nsUploadChannel_Release(nsIUploadChannel
*iface
)
1388 nsChannel
*This
= impl_from_nsIUploadChannel(iface
);
1389 return nsIChannel_Release(&This
->nsIHttpChannel_iface
);
1392 static nsresult NSAPI
nsUploadChannel_SetUploadStream(nsIUploadChannel
*iface
,
1393 nsIInputStream
*aStream
, const nsACString
*aContentType
, PRInt32 aContentLength
)
1395 nsChannel
*This
= impl_from_nsIUploadChannel(iface
);
1396 const char *content_type
;
1398 static const WCHAR content_typeW
[] =
1399 {'C','o','n','t','e','n','t','-','T','y','p','e',0};
1401 TRACE("(%p)->(%p %s %d)\n", This
, aStream
, debugstr_nsacstr(aContentType
), aContentLength
);
1403 This
->post_data_contains_headers
= TRUE
;
1406 nsACString_GetData(aContentType
, &content_type
);
1410 ct
= heap_strdupAtoW(content_type
);
1412 return NS_ERROR_UNEXPECTED
;
1414 set_http_header(&This
->request_headers
, content_typeW
,
1415 sizeof(content_typeW
)/sizeof(WCHAR
), ct
, strlenW(ct
));
1417 This
->post_data_contains_headers
= FALSE
;
1421 if(This
->post_data_stream
)
1422 nsIInputStream_Release(This
->post_data_stream
);
1424 if(aContentLength
!= -1)
1425 FIXME("Unsupported acontentLength = %d\n", aContentLength
);
1427 if(This
->post_data_stream
)
1428 nsIInputStream_Release(This
->post_data_stream
);
1429 This
->post_data_stream
= aStream
;
1431 nsIInputStream_AddRef(aStream
);
1433 This
->request_method
= METHOD_POST
;
1437 static nsresult NSAPI
nsUploadChannel_GetUploadStream(nsIUploadChannel
*iface
,
1438 nsIInputStream
**aUploadStream
)
1440 nsChannel
*This
= impl_from_nsIUploadChannel(iface
);
1442 TRACE("(%p)->(%p)\n", This
, aUploadStream
);
1444 if(This
->post_data_stream
)
1445 nsIInputStream_AddRef(This
->post_data_stream
);
1447 *aUploadStream
= This
->post_data_stream
;
1451 static const nsIUploadChannelVtbl nsUploadChannelVtbl
= {
1452 nsUploadChannel_QueryInterface
,
1453 nsUploadChannel_AddRef
,
1454 nsUploadChannel_Release
,
1455 nsUploadChannel_SetUploadStream
,
1456 nsUploadChannel_GetUploadStream
1459 static inline nsChannel
*impl_from_nsIHttpChannelInternal(nsIHttpChannelInternal
*iface
)
1461 return CONTAINING_RECORD(iface
, nsChannel
, nsIHttpChannelInternal_iface
);
1464 static nsresult NSAPI
nsHttpChannelInternal_QueryInterface(nsIHttpChannelInternal
*iface
, nsIIDRef riid
,
1467 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1468 return nsIChannel_QueryInterface(&This
->nsIHttpChannel_iface
, riid
, result
);
1471 static nsrefcnt NSAPI
nsHttpChannelInternal_AddRef(nsIHttpChannelInternal
*iface
)
1473 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1474 return nsIChannel_AddRef(&This
->nsIHttpChannel_iface
);
1477 static nsrefcnt NSAPI
nsHttpChannelInternal_Release(nsIHttpChannelInternal
*iface
)
1479 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1480 return nsIChannel_Release(&This
->nsIHttpChannel_iface
);
1483 static nsresult NSAPI
nsHttpChannelInternal_GetDocumentURI(nsIHttpChannelInternal
*iface
, nsIURI
**aDocumentURI
)
1485 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1487 FIXME("(%p)->()\n", This
);
1489 return NS_ERROR_NOT_IMPLEMENTED
;
1492 static nsresult NSAPI
nsHttpChannelInternal_SetDocumentURI(nsIHttpChannelInternal
*iface
, nsIURI
*aDocumentURI
)
1494 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1496 FIXME("(%p)->()\n", This
);
1498 return NS_ERROR_NOT_IMPLEMENTED
;
1501 static nsresult NSAPI
nsHttpChannelInternal_GetRequestVersion(nsIHttpChannelInternal
*iface
, PRUint32
*major
, PRUint32
*minor
)
1503 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1505 FIXME("(%p)->()\n", This
);
1507 return NS_ERROR_NOT_IMPLEMENTED
;
1510 static nsresult NSAPI
nsHttpChannelInternal_GetResponseVersion(nsIHttpChannelInternal
*iface
, PRUint32
*major
, PRUint32
*minor
)
1512 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1514 FIXME("(%p)->()\n", This
);
1516 return NS_ERROR_NOT_IMPLEMENTED
;
1519 static nsresult NSAPI
nsHttpChannelInternal_SetCookie(nsIHttpChannelInternal
*iface
, const char *aCookieHeader
)
1521 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1523 FIXME("(%p)->()\n", This
);
1525 return NS_ERROR_NOT_IMPLEMENTED
;
1528 static nsresult NSAPI
nsHttpChannelInternal_SetupFallbackChannel(nsIHttpChannelInternal
*iface
, const char *aFallbackKey
)
1530 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1532 FIXME("(%p)->()\n", This
);
1534 return NS_ERROR_NOT_IMPLEMENTED
;
1537 static nsresult NSAPI
nsHttpChannelInternal_GetForceAllowThirdPartyCookie(nsIHttpChannelInternal
*iface
, PRBool
*aForceThirdPartyCookie
)
1539 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1541 FIXME("(%p)->()\n", This
);
1543 return NS_ERROR_NOT_IMPLEMENTED
;
1546 static nsresult NSAPI
nsHttpChannelInternal_SetForceAllowThirdPartyCookie(nsIHttpChannelInternal
*iface
, PRBool aForceThirdPartyCookie
)
1548 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1550 FIXME("(%p)->()\n", This
);
1552 return NS_ERROR_NOT_IMPLEMENTED
;
1555 static nsresult NSAPI
nsHttpChannelInternal_GetCanceled(nsIHttpChannelInternal
*iface
, PRBool
*aCanceled
)
1557 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1559 FIXME("(%p)->(%p)\n", This
, aCanceled
);
1561 return NS_ERROR_NOT_IMPLEMENTED
;
1564 static nsresult NSAPI
nsHttpChannelInternal_GetChannelIsForDownload(nsIHttpChannelInternal
*iface
, PRBool
*aCanceled
)
1566 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1568 FIXME("(%p)->(%p)\n", This
, aCanceled
);
1570 return NS_ERROR_NOT_IMPLEMENTED
;
1573 static nsresult NSAPI
nsHttpChannelInternal_SetChannelIsForDownload(nsIHttpChannelInternal
*iface
, PRBool aCanceled
)
1575 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1577 FIXME("(%p)->(%x)\n", This
, aCanceled
);
1579 return NS_ERROR_NOT_IMPLEMENTED
;
1582 static nsresult NSAPI
nsHttpChannelInternal_GetLocalAddress(nsIHttpChannelInternal
*iface
, nsACString
*aLocalAddress
)
1584 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1586 FIXME("(%p)->(%p)\n", This
, aLocalAddress
);
1588 return NS_ERROR_NOT_IMPLEMENTED
;
1591 static nsresult NSAPI
nsHttpChannelInternal_GetLocalPort(nsIHttpChannelInternal
*iface
, PRInt32
*aLocalPort
)
1593 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1595 FIXME("(%p)->(%p)\n", This
, aLocalPort
);
1597 return NS_ERROR_NOT_IMPLEMENTED
;
1600 static nsresult NSAPI
nsHttpChannelInternal_GetRemoteAddress(nsIHttpChannelInternal
*iface
, nsACString
*aRemoteAddress
)
1602 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1604 FIXME("(%p)->(%p)\n", This
, aRemoteAddress
);
1606 return NS_ERROR_NOT_IMPLEMENTED
;
1609 static nsresult NSAPI
nsHttpChannelInternal_GetRemotePort(nsIHttpChannelInternal
*iface
, PRInt32
*aRemotePort
)
1611 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1613 FIXME("(%p)->(%p)\n", This
, aRemotePort
);
1615 return NS_ERROR_NOT_IMPLEMENTED
;
1618 static nsresult NSAPI
nsHttpChannelInternal_SetCacheKeysRedirectChain(nsIHttpChannelInternal
*iface
, void *cacheKeys
)
1620 nsChannel
*This
= impl_from_nsIHttpChannelInternal(iface
);
1622 FIXME("(%p)->(%p)\n", This
, cacheKeys
);
1624 return NS_ERROR_NOT_IMPLEMENTED
;
1627 static const nsIHttpChannelInternalVtbl nsHttpChannelInternalVtbl
= {
1628 nsHttpChannelInternal_QueryInterface
,
1629 nsHttpChannelInternal_AddRef
,
1630 nsHttpChannelInternal_Release
,
1631 nsHttpChannelInternal_GetDocumentURI
,
1632 nsHttpChannelInternal_SetDocumentURI
,
1633 nsHttpChannelInternal_GetRequestVersion
,
1634 nsHttpChannelInternal_GetResponseVersion
,
1635 nsHttpChannelInternal_SetCookie
,
1636 nsHttpChannelInternal_SetupFallbackChannel
,
1637 nsHttpChannelInternal_GetForceAllowThirdPartyCookie
,
1638 nsHttpChannelInternal_SetForceAllowThirdPartyCookie
,
1639 nsHttpChannelInternal_GetCanceled
,
1640 nsHttpChannelInternal_GetChannelIsForDownload
,
1641 nsHttpChannelInternal_SetChannelIsForDownload
,
1642 nsHttpChannelInternal_GetLocalAddress
,
1643 nsHttpChannelInternal_GetLocalPort
,
1644 nsHttpChannelInternal_GetRemoteAddress
,
1645 nsHttpChannelInternal_GetRemotePort
,
1646 nsHttpChannelInternal_SetCacheKeysRedirectChain
1650 static void invalidate_uri(nsWineURI
*This
)
1653 IUri_Release(This
->uri
);
1658 static BOOL
ensure_uri_builder(nsWineURI
*This
)
1660 if(!This
->is_mutable
) {
1661 WARN("Not mutable URI\n");
1665 if(!This
->uri_builder
) {
1668 if(!ensure_uri(This
))
1671 hres
= CreateIUriBuilder(This
->uri
, 0, 0, &This
->uri_builder
);
1673 WARN("CreateIUriBuilder failed: %08x\n", hres
);
1678 invalidate_uri(This
);
1682 static nsresult
get_uri_string(nsWineURI
*This
, Uri_PROPERTY prop
, nsACString
*ret
)
1688 if(!ensure_uri(This
))
1689 return NS_ERROR_UNEXPECTED
;
1691 hres
= IUri_GetPropertyBSTR(This
->uri
, prop
, &val
, 0);
1693 WARN("GetPropertyBSTR failed: %08x\n", hres
);
1694 return NS_ERROR_UNEXPECTED
;
1697 vala
= heap_strdupWtoA(val
);
1700 return NS_ERROR_OUT_OF_MEMORY
;
1702 TRACE("ret %s\n", debugstr_a(vala
));
1703 nsACString_SetData(ret
, vala
);
1708 static inline nsWineURI
*impl_from_nsIURL(nsIURL
*iface
)
1710 return CONTAINING_RECORD(iface
, nsWineURI
, nsIURL_iface
);
1713 static nsresult NSAPI
nsURI_QueryInterface(nsIURL
*iface
, nsIIDRef riid
, void **result
)
1715 nsWineURI
*This
= impl_from_nsIURL(iface
);
1719 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
1720 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
1721 *result
= &This
->nsIURL_iface
;
1722 }else if(IsEqualGUID(&IID_nsIURI
, riid
)) {
1723 TRACE("(%p)->(IID_nsIURI %p)\n", This
, result
);
1724 *result
= &This
->nsIURL_iface
;
1725 }else if(IsEqualGUID(&IID_nsIURL
, riid
)) {
1726 TRACE("(%p)->(IID_nsIURL %p)\n", This
, result
);
1727 *result
= &This
->nsIURL_iface
;
1728 }else if(IsEqualGUID(&IID_nsIMutable
, riid
)) {
1729 TRACE("(%p)->(IID_nsIMutable %p)\n", This
, result
);
1730 *result
= &This
->nsIStandardURL_iface
;
1731 }else if(IsEqualGUID(&IID_nsIStandardURL
, riid
)) {
1732 TRACE("(%p)->(IID_nsIStandardURL %p)\n", This
, result
);
1733 *result
= &This
->nsIStandardURL_iface
;
1734 }else if(IsEqualGUID(&IID_nsWineURI
, riid
)) {
1735 TRACE("(%p)->(IID_nsWineURI %p)\n", This
, result
);
1740 nsIURI_AddRef(&This
->nsIURL_iface
);
1744 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), result
);
1745 return This
->nsuri
? nsIURI_QueryInterface(This
->nsuri
, riid
, result
) : NS_NOINTERFACE
;
1748 static nsrefcnt NSAPI
nsURI_AddRef(nsIURL
*iface
)
1750 nsWineURI
*This
= impl_from_nsIURL(iface
);
1751 LONG ref
= InterlockedIncrement(&This
->ref
);
1753 TRACE("(%p) ref=%d\n", This
, ref
);
1758 static nsrefcnt NSAPI
nsURI_Release(nsIURL
*iface
)
1760 nsWineURI
*This
= impl_from_nsIURL(iface
);
1761 LONG ref
= InterlockedDecrement(&This
->ref
);
1763 TRACE("(%p) ref=%d\n", This
, ref
);
1766 if(This
->window_ref
)
1767 windowref_release(This
->window_ref
);
1769 nsIWebBrowserChrome_Release(&This
->container
->nsIWebBrowserChrome_iface
);
1771 nsIURL_Release(This
->nsurl
);
1773 nsIURI_Release(This
->nsuri
);
1775 IUri_Release(This
->uri
);
1782 static nsresult NSAPI
nsURI_GetSpec(nsIURL
*iface
, nsACString
*aSpec
)
1784 nsWineURI
*This
= impl_from_nsIURL(iface
);
1786 TRACE("(%p)->(%p)\n", This
, aSpec
);
1788 return get_uri_string(This
, Uri_PROPERTY_DISPLAY_URI
, aSpec
);
1791 static nsresult NSAPI
nsURI_SetSpec(nsIURL
*iface
, const nsACString
*aSpec
)
1793 nsWineURI
*This
= impl_from_nsIURL(iface
);
1799 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aSpec
));
1801 if(!This
->is_mutable
)
1802 return NS_ERROR_UNEXPECTED
;
1804 nsACString_GetData(aSpec
, &speca
);
1805 spec
= heap_strdupAtoW(speca
);
1807 return NS_ERROR_OUT_OF_MEMORY
;
1809 hres
= CreateUri(spec
, 0, 0, &uri
);
1812 WARN("CreateUri failed: %08x\n", hres
);
1813 return NS_ERROR_FAILURE
;
1816 invalidate_uri(This
);
1817 if(This
->uri_builder
) {
1818 IUriBuilder_Release(This
->uri_builder
);
1819 This
->uri_builder
= NULL
;
1826 static nsresult NSAPI
nsURI_GetPrePath(nsIURL
*iface
, nsACString
*aPrePath
)
1828 nsWineURI
*This
= impl_from_nsIURL(iface
);
1830 TRACE("(%p)->(%p)\n", This
, aPrePath
);
1833 return nsIURI_GetPrePath(This
->nsuri
, aPrePath
);
1835 FIXME("default action not implemented\n");
1836 return NS_ERROR_NOT_IMPLEMENTED
;
1839 static nsresult NSAPI
nsURI_GetScheme(nsIURL
*iface
, nsACString
*aScheme
)
1841 nsWineURI
*This
= impl_from_nsIURL(iface
);
1845 TRACE("(%p)->(%p)\n", This
, aScheme
);
1847 if(!ensure_uri(This
))
1848 return NS_ERROR_UNEXPECTED
;
1850 hres
= IUri_GetScheme(This
->uri
, &scheme
);
1852 WARN("GetScheme failed: %08x\n", hres
);
1853 return NS_ERROR_UNEXPECTED
;
1856 if(scheme
== URL_SCHEME_ABOUT
) {
1857 nsACString_SetData(aScheme
, "wine");
1861 return get_uri_string(This
, Uri_PROPERTY_SCHEME_NAME
, aScheme
);
1864 static nsresult NSAPI
nsURI_SetScheme(nsIURL
*iface
, const nsACString
*aScheme
)
1866 nsWineURI
*This
= impl_from_nsIURL(iface
);
1867 const char *schemea
;
1871 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aScheme
));
1873 if(!ensure_uri_builder(This
))
1874 return NS_ERROR_UNEXPECTED
;
1876 nsACString_GetData(aScheme
, &schemea
);
1877 scheme
= heap_strdupAtoW(schemea
);
1879 return NS_ERROR_OUT_OF_MEMORY
;
1881 hres
= IUriBuilder_SetSchemeName(This
->uri_builder
, scheme
);
1884 return NS_ERROR_UNEXPECTED
;
1889 static nsresult NSAPI
nsURI_GetUserPass(nsIURL
*iface
, nsACString
*aUserPass
)
1891 nsWineURI
*This
= impl_from_nsIURL(iface
);
1895 TRACE("(%p)->(%p)\n", This
, aUserPass
);
1897 if(!ensure_uri(This
))
1898 return NS_ERROR_UNEXPECTED
;
1900 hres
= IUri_GetUserName(This
->uri
, &user
);
1902 return NS_ERROR_FAILURE
;
1904 hres
= IUri_GetPassword(This
->uri
, &pass
);
1906 SysFreeString(user
);
1907 return NS_ERROR_FAILURE
;
1910 if(*user
|| *pass
) {
1911 FIXME("Construct user:pass string\n");
1913 nsACString_SetData(aUserPass
, "");
1916 SysFreeString(user
);
1917 SysFreeString(pass
);
1921 static nsresult NSAPI
nsURI_SetUserPass(nsIURL
*iface
, const nsACString
*aUserPass
)
1923 nsWineURI
*This
= impl_from_nsIURL(iface
);
1924 WCHAR
*user
= NULL
, *pass
= NULL
, *buf
= NULL
;
1925 const char *user_pass
;
1928 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aUserPass
));
1930 if(!ensure_uri_builder(This
))
1931 return NS_ERROR_UNEXPECTED
;
1933 nsACString_GetData(aUserPass
, &user_pass
);
1937 buf
= heap_strdupAtoW(user_pass
);
1939 return NS_ERROR_OUT_OF_MEMORY
;
1941 ptr
= strchrW(buf
, ':');
1944 }else if(ptr
!= buf
) {
1954 hres
= IUriBuilder_SetUserName(This
->uri_builder
, user
);
1956 hres
= IUriBuilder_SetPassword(This
->uri_builder
, pass
);
1959 return SUCCEEDED(hres
) ? NS_OK
: NS_ERROR_FAILURE
;
1962 static nsresult NSAPI
nsURI_GetUsername(nsIURL
*iface
, nsACString
*aUsername
)
1964 nsWineURI
*This
= impl_from_nsIURL(iface
);
1966 TRACE("(%p)->(%p)\n", This
, aUsername
);
1968 return get_uri_string(This
, Uri_PROPERTY_USER_NAME
, aUsername
);
1971 static nsresult NSAPI
nsURI_SetUsername(nsIURL
*iface
, const nsACString
*aUsername
)
1973 nsWineURI
*This
= impl_from_nsIURL(iface
);
1978 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aUsername
));
1980 if(!ensure_uri_builder(This
))
1981 return NS_ERROR_UNEXPECTED
;
1983 nsACString_GetData(aUsername
, &usera
);
1984 user
= heap_strdupAtoW(usera
);
1986 return NS_ERROR_OUT_OF_MEMORY
;
1988 hres
= IUriBuilder_SetUserName(This
->uri_builder
, user
);
1991 return NS_ERROR_UNEXPECTED
;
1996 static nsresult NSAPI
nsURI_GetPassword(nsIURL
*iface
, nsACString
*aPassword
)
1998 nsWineURI
*This
= impl_from_nsIURL(iface
);
2000 TRACE("(%p)->(%p)\n", This
, aPassword
);
2002 return get_uri_string(This
, Uri_PROPERTY_PASSWORD
, aPassword
);
2005 static nsresult NSAPI
nsURI_SetPassword(nsIURL
*iface
, const nsACString
*aPassword
)
2007 nsWineURI
*This
= impl_from_nsIURL(iface
);
2012 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aPassword
));
2014 if(!ensure_uri_builder(This
))
2015 return NS_ERROR_UNEXPECTED
;
2017 nsACString_GetData(aPassword
, &passa
);
2018 pass
= heap_strdupAtoW(passa
);
2020 return NS_ERROR_OUT_OF_MEMORY
;
2022 hres
= IUriBuilder_SetPassword(This
->uri_builder
, pass
);
2025 return NS_ERROR_UNEXPECTED
;
2030 static nsresult NSAPI
nsURI_GetHostPort(nsIURL
*iface
, nsACString
*aHostPort
)
2032 nsWineURI
*This
= impl_from_nsIURL(iface
);
2038 TRACE("(%p)->(%p)\n", This
, aHostPort
);
2040 if(!ensure_uri(This
))
2041 return NS_ERROR_UNEXPECTED
;
2043 hres
= IUri_GetAuthority(This
->uri
, &val
);
2045 WARN("GetAuthority failed: %08x\n", hres
);
2046 return NS_ERROR_UNEXPECTED
;
2049 ptr
= strchrW(val
, '@');
2053 vala
= heap_strdupWtoA(ptr
);
2056 return NS_ERROR_OUT_OF_MEMORY
;
2058 TRACE("ret %s\n", debugstr_a(vala
));
2059 nsACString_SetData(aHostPort
, vala
);
2064 static nsresult NSAPI
nsURI_SetHostPort(nsIURL
*iface
, const nsACString
*aHostPort
)
2066 nsWineURI
*This
= impl_from_nsIURL(iface
);
2068 WARN("(%p)->(%s)\n", This
, debugstr_nsacstr(aHostPort
));
2070 /* Not implemented by Gecko */
2071 return NS_ERROR_NOT_IMPLEMENTED
;
2074 static nsresult NSAPI
nsURI_GetHost(nsIURL
*iface
, nsACString
*aHost
)
2076 nsWineURI
*This
= impl_from_nsIURL(iface
);
2078 TRACE("(%p)->(%p)\n", This
, aHost
);
2080 return get_uri_string(This
, Uri_PROPERTY_HOST
, aHost
);
2083 static nsresult NSAPI
nsURI_SetHost(nsIURL
*iface
, const nsACString
*aHost
)
2085 nsWineURI
*This
= impl_from_nsIURL(iface
);
2090 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aHost
));
2092 if(!ensure_uri_builder(This
))
2093 return NS_ERROR_UNEXPECTED
;
2095 nsACString_GetData(aHost
, &hosta
);
2096 host
= heap_strdupAtoW(hosta
);
2098 return NS_ERROR_OUT_OF_MEMORY
;
2100 hres
= IUriBuilder_SetHost(This
->uri_builder
, host
);
2103 return NS_ERROR_UNEXPECTED
;
2108 static nsresult NSAPI
nsURI_GetPort(nsIURL
*iface
, PRInt32
*aPort
)
2110 nsWineURI
*This
= impl_from_nsIURL(iface
);
2114 TRACE("(%p)->(%p)\n", This
, aPort
);
2116 if(!ensure_uri(This
))
2117 return NS_ERROR_UNEXPECTED
;
2119 hres
= IUri_GetPort(This
->uri
, &port
);
2121 WARN("GetPort failed: %08x\n", hres
);
2122 return NS_ERROR_UNEXPECTED
;
2125 *aPort
= port
? port
: -1;
2129 static nsresult NSAPI
nsURI_SetPort(nsIURL
*iface
, PRInt32 aPort
)
2131 nsWineURI
*This
= impl_from_nsIURL(iface
);
2134 TRACE("(%p)->(%d)\n", This
, aPort
);
2136 if(!ensure_uri_builder(This
))
2137 return NS_ERROR_UNEXPECTED
;
2139 hres
= IUriBuilder_SetPort(This
->uri_builder
, aPort
!= -1, aPort
);
2140 return SUCCEEDED(hres
) ? NS_OK
: NS_ERROR_FAILURE
;
2143 static nsresult NSAPI
nsURI_GetPath(nsIURL
*iface
, nsACString
*aPath
)
2145 nsWineURI
*This
= impl_from_nsIURL(iface
);
2147 TRACE("(%p)->(%p)\n", This
, aPath
);
2149 return get_uri_string(This
, Uri_PROPERTY_PATH
, aPath
);
2152 static nsresult NSAPI
nsURI_SetPath(nsIURL
*iface
, const nsACString
*aPath
)
2154 nsWineURI
*This
= impl_from_nsIURL(iface
);
2159 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aPath
));
2161 if(!ensure_uri_builder(This
))
2162 return NS_ERROR_UNEXPECTED
;
2164 nsACString_GetData(aPath
, &patha
);
2165 path
= heap_strdupAtoW(patha
);
2167 return NS_ERROR_OUT_OF_MEMORY
;
2169 hres
= IUriBuilder_SetPath(This
->uri_builder
, path
);
2172 return NS_ERROR_UNEXPECTED
;
2177 static nsresult NSAPI
nsURL_GetRef(nsIURL
*iface
, nsACString
*aRef
)
2179 nsWineURI
*This
= impl_from_nsIURL(iface
);
2184 TRACE("(%p)->(%p)\n", This
, aRef
);
2186 if(!ensure_uri(This
))
2187 return NS_ERROR_UNEXPECTED
;
2189 hres
= IUri_GetFragment(This
->uri
, &ref
);
2191 return NS_ERROR_UNEXPECTED
;
2193 refa
= heap_strdupWtoA(ref
);
2196 return NS_ERROR_OUT_OF_MEMORY
;
2198 nsACString_SetData(aRef
, refa
&& *refa
== '#' ? refa
+1 : refa
);
2203 static nsresult NSAPI
nsURL_SetRef(nsIURL
*iface
, const nsACString
*aRef
)
2205 nsWineURI
*This
= impl_from_nsIURL(iface
);
2210 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aRef
));
2212 if(!ensure_uri_builder(This
))
2213 return NS_ERROR_UNEXPECTED
;
2215 nsACString_GetData(aRef
, &refa
);
2216 ref
= heap_strdupAtoW(refa
);
2218 return NS_ERROR_OUT_OF_MEMORY
;
2220 hres
= IUriBuilder_SetFragment(This
->uri_builder
, ref
);
2223 return NS_ERROR_UNEXPECTED
;
2228 static nsresult NSAPI
nsURI_Equals(nsIURL
*iface
, nsIURI
*other
, PRBool
*_retval
)
2230 nsWineURI
*This
= impl_from_nsIURL(iface
);
2231 nsWineURI
*other_obj
;
2235 TRACE("(%p)->(%p %p)\n", This
, other
, _retval
);
2237 nsres
= nsIURI_QueryInterface(other
, &IID_nsWineURI
, (void**)&other_obj
);
2238 if(NS_FAILED(nsres
)) {
2239 TRACE("Could not get nsWineURI interface\n");
2244 if(ensure_uri(This
) && ensure_uri(other_obj
)) {
2247 hres
= IUri_IsEqual(This
->uri
, other_obj
->uri
, &b
);
2248 if(SUCCEEDED(hres
)) {
2252 nsres
= NS_ERROR_FAILURE
;
2255 nsres
= NS_ERROR_UNEXPECTED
;
2258 nsIURI_Release(&other_obj
->nsIURL_iface
);
2262 static nsresult NSAPI
nsURI_SchemeIs(nsIURL
*iface
, const char *scheme
, PRBool
*_retval
)
2264 nsWineURI
*This
= impl_from_nsIURL(iface
);
2265 WCHAR buf
[INTERNET_MAX_SCHEME_LENGTH
];
2269 TRACE("(%p)->(%s %p)\n", This
, debugstr_a(scheme
), _retval
);
2271 if(!ensure_uri(This
))
2272 return NS_ERROR_UNEXPECTED
;
2274 hres
= IUri_GetSchemeName(This
->uri
, &scheme_name
);
2276 return NS_ERROR_UNEXPECTED
;
2278 MultiByteToWideChar(CP_ACP
, 0, scheme
, -1, buf
, sizeof(buf
)/sizeof(WCHAR
));
2279 *_retval
= !strcmpW(scheme_name
, buf
);
2280 SysFreeString(scheme_name
);
2284 static nsresult NSAPI
nsURI_Clone(nsIURL
*iface
, nsIURI
**_retval
)
2286 nsWineURI
*This
= impl_from_nsIURL(iface
);
2287 nsIURI
*nsuri
= NULL
;
2288 nsWineURI
*wine_uri
;
2291 TRACE("(%p)->(%p)\n", This
, _retval
);
2293 if(!ensure_uri(This
))
2294 return NS_ERROR_UNEXPECTED
;
2297 nsres
= nsIURI_Clone(This
->nsuri
, &nsuri
);
2298 if(NS_FAILED(nsres
)) {
2299 WARN("Clone failed: %08x\n", nsres
);
2304 nsres
= create_nsuri(This
->uri
, nsuri
, This
->window_ref
? This
->window_ref
->window
: NULL
, This
->container
, &wine_uri
);
2305 if(NS_FAILED(nsres
)) {
2306 WARN("create_nsuri failed: %08x\n", nsres
);
2310 *_retval
= (nsIURI
*)&wine_uri
->nsIURL_iface
;
2314 static nsresult NSAPI
nsURI_Resolve(nsIURL
*iface
, const nsACString
*aRelativePath
,
2315 nsACString
*_retval
)
2317 nsWineURI
*This
= impl_from_nsIURL(iface
);
2325 TRACE("(%p)->(%s %p)\n", This
, debugstr_nsacstr(aRelativePath
), _retval
);
2327 if(!ensure_uri(This
))
2328 return NS_ERROR_UNEXPECTED
;
2330 nsACString_GetData(aRelativePath
, &patha
);
2331 path
= heap_strdupAtoW(patha
);
2333 return NS_ERROR_OUT_OF_MEMORY
;
2335 hres
= CoInternetCombineUrlEx(This
->uri
, path
, URL_ESCAPE_SPACES_ONLY
|URL_DONT_ESCAPE_EXTRA_INFO
, &new_uri
, 0);
2338 ERR("CoIntenetCombineUrlEx failed: %08x\n", hres
);
2339 return NS_ERROR_FAILURE
;
2342 hres
= IUri_GetDisplayUri(new_uri
, &ret
);
2343 IUri_Release(new_uri
);
2345 return NS_ERROR_FAILURE
;
2347 reta
= heap_strdupWtoA(ret
);
2350 return NS_ERROR_OUT_OF_MEMORY
;
2352 TRACE("returning %s\n", debugstr_a(reta
));
2353 nsACString_SetData(_retval
, reta
);
2358 static nsresult NSAPI
nsURI_GetAsciiSpec(nsIURL
*iface
, nsACString
*aAsciiSpec
)
2360 nsWineURI
*This
= impl_from_nsIURL(iface
);
2362 TRACE("(%p)->(%p)\n", This
, aAsciiSpec
);
2364 return nsIURI_GetSpec(&This
->nsIURL_iface
, aAsciiSpec
);
2367 static nsresult NSAPI
nsURI_GetAsciiHost(nsIURL
*iface
, nsACString
*aAsciiHost
)
2369 nsWineURI
*This
= impl_from_nsIURL(iface
);
2371 WARN("(%p)->(%p) FIXME: Use Uri_PUNYCODE_IDN_HOST flag\n", This
, aAsciiHost
);
2373 return get_uri_string(This
, Uri_PROPERTY_HOST
, aAsciiHost
);
2376 static nsresult NSAPI
nsURI_GetOriginCharset(nsIURL
*iface
, nsACString
*aOriginCharset
)
2378 nsWineURI
*This
= impl_from_nsIURL(iface
);
2380 TRACE("(%p)->(%p)\n", This
, aOriginCharset
);
2383 return nsIURI_GetOriginCharset(This
->nsuri
, aOriginCharset
);
2385 FIXME("default action not implemented\n");
2386 return NS_ERROR_NOT_IMPLEMENTED
;
2389 static nsresult NSAPI
nsURI_EqualsExceptRef(nsIURL
*iface
, nsIURI
*other
, PRBool
*_retval
)
2391 nsWineURI
*This
= impl_from_nsIURL(iface
);
2392 nsWineURI
*other_obj
;
2395 TRACE("(%p)->(%p %p)\n", This
, other
, _retval
);
2397 nsres
= nsIURI_QueryInterface(other
, &IID_nsWineURI
, (void**)&other_obj
);
2398 if(NS_FAILED(nsres
)) {
2399 TRACE("Could not get nsWineURI interface\n");
2404 if(ensure_uri(This
) && ensure_uri(other_obj
)) {
2405 *_retval
= compare_ignoring_frag(This
->uri
, other_obj
->uri
);
2408 nsres
= NS_ERROR_UNEXPECTED
;
2411 nsIURI_Release(&other_obj
->nsIURL_iface
);
2415 static nsresult NSAPI
nsURI_CloneIgnoreRef(nsIURL
*iface
, nsIURI
**_retval
)
2417 nsWineURI
*This
= impl_from_nsIURL(iface
);
2418 nsWineURI
*wine_uri
;
2422 TRACE("(%p)->(%p)\n", This
, _retval
);
2424 if(!ensure_uri(This
))
2425 return NS_ERROR_UNEXPECTED
;
2427 uri
= get_uri_nofrag(This
->uri
);
2429 return NS_ERROR_FAILURE
;
2431 nsres
= create_nsuri(uri
, NULL
, This
->window_ref
? This
->window_ref
->window
: NULL
, This
->container
, &wine_uri
);
2433 if(NS_FAILED(nsres
)) {
2434 WARN("create_nsuri failed: %08x\n", nsres
);
2438 *_retval
= (nsIURI
*)&wine_uri
->nsIURL_iface
;
2442 static nsresult NSAPI
nsURI_GetSpecIgnoringRef(nsIURL
*iface
, nsACString
*aSpecIgnoringRef
)
2444 nsWineURI
*This
= impl_from_nsIURL(iface
);
2446 FIXME("(%p)->(%p)\n", This
, aSpecIgnoringRef
);
2448 return nsIURL_GetSpec(&This
->nsIURL_iface
, aSpecIgnoringRef
);
2451 static nsresult NSAPI
nsURI_GetHasRef(nsIURL
*iface
, PRBool
*aHasRef
)
2453 nsWineURI
*This
= impl_from_nsIURL(iface
);
2457 TRACE("(%p)->(%p)\n", This
, aHasRef
);
2459 if(!ensure_uri(This
))
2460 return NS_ERROR_UNEXPECTED
;
2462 hres
= IUri_HasProperty(This
->uri
, Uri_PROPERTY_FRAGMENT
, &b
);
2464 return NS_ERROR_FAILURE
;
2470 static nsresult NSAPI
nsURL_GetFilePath(nsIURL
*iface
, nsACString
*aFilePath
)
2472 nsWineURI
*This
= impl_from_nsIURL(iface
);
2474 TRACE("(%p)->(%p)\n", This
, aFilePath
);
2476 return nsIURL_GetPath(&This
->nsIURL_iface
, aFilePath
);
2479 static nsresult NSAPI
nsURL_SetFilePath(nsIURL
*iface
, const nsACString
*aFilePath
)
2481 nsWineURI
*This
= impl_from_nsIURL(iface
);
2483 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aFilePath
));
2485 if(!This
->is_mutable
)
2486 return NS_ERROR_UNEXPECTED
;
2488 return nsIURL_SetPath(&This
->nsIURL_iface
, aFilePath
);
2491 static nsresult NSAPI
nsURL_GetParam(nsIURL
*iface
, nsACString
*aParam
)
2493 nsWineURI
*This
= impl_from_nsIURL(iface
);
2495 WARN("(%p)->(%p)\n", This
, aParam
);
2497 /* This is a leftover of ';' special handling in URLs. It will be removed from Gecko soon */
2498 nsACString_SetData(aParam
, "");
2502 static nsresult NSAPI
nsURL_SetParam(nsIURL
*iface
, const nsACString
*aParam
)
2504 nsWineURI
*This
= impl_from_nsIURL(iface
);
2506 WARN("(%p)->(%s)\n", This
, debugstr_nsacstr(aParam
));
2508 /* Not implemented by Gecko */
2509 return NS_ERROR_NOT_IMPLEMENTED
;
2512 static nsresult NSAPI
nsURL_GetQuery(nsIURL
*iface
, nsACString
*aQuery
)
2514 nsWineURI
*This
= impl_from_nsIURL(iface
);
2516 TRACE("(%p)->(%p)\n", This
, aQuery
);
2518 return get_uri_string(This
, Uri_PROPERTY_QUERY
, aQuery
);
2521 static nsresult NSAPI
nsURL_SetQuery(nsIURL
*iface
, const nsACString
*aQuery
)
2523 nsWineURI
*This
= impl_from_nsIURL(iface
);
2528 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aQuery
));
2530 if(!ensure_uri_builder(This
))
2531 return NS_ERROR_UNEXPECTED
;
2533 nsACString_GetData(aQuery
, &querya
);
2534 query
= heap_strdupAtoW(querya
);
2536 return NS_ERROR_OUT_OF_MEMORY
;
2538 hres
= IUriBuilder_SetQuery(This
->uri_builder
, query
);
2541 return NS_ERROR_UNEXPECTED
;
2546 static nsresult NSAPI
nsURL_GetDirectory(nsIURL
*iface
, nsACString
*aDirectory
)
2548 nsWineURI
*This
= impl_from_nsIURL(iface
);
2554 TRACE("(%p)->(%p)\n", This
, aDirectory
);
2556 if(!ensure_uri(This
))
2557 return NS_ERROR_UNEXPECTED
;
2559 hres
= IUri_GetPath(This
->uri
, &path
);
2561 return NS_ERROR_FAILURE
;
2563 ptr
= strrchrW(path
, '/');
2567 dir
= heap_strdupWtoA(path
);
2569 SysFreeString(path
);
2570 return NS_ERROR_OUT_OF_MEMORY
;
2574 SysFreeString(path
);
2575 TRACE("ret %s\n", debugstr_a(dir
));
2576 nsACString_SetData(aDirectory
, dir
? dir
: "");
2581 static nsresult NSAPI
nsURL_SetDirectory(nsIURL
*iface
, const nsACString
*aDirectory
)
2583 nsWineURI
*This
= impl_from_nsIURL(iface
);
2585 WARN("(%p)->(%s)\n", This
, debugstr_nsacstr(aDirectory
));
2587 /* Not implemented by Gecko */
2588 return NS_ERROR_NOT_IMPLEMENTED
;
2591 static nsresult NSAPI
nsURL_GetFileName(nsIURL
*iface
, nsACString
*aFileName
)
2593 nsWineURI
*This
= impl_from_nsIURL(iface
);
2595 TRACE("(%p)->(%p)\n", This
, aFileName
);
2598 return nsIURL_GetFileName(This
->nsurl
, aFileName
);
2600 FIXME("default action not implemented\n");
2601 return NS_ERROR_NOT_IMPLEMENTED
;
2604 static nsresult NSAPI
nsURL_SetFileName(nsIURL
*iface
, const nsACString
*aFileName
)
2606 nsWineURI
*This
= impl_from_nsIURL(iface
);
2608 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aFileName
));
2610 if(!This
->is_mutable
)
2611 return NS_ERROR_UNEXPECTED
;
2614 invalidate_uri(This
);
2615 return nsIURL_SetFileName(This
->nsurl
, aFileName
);
2618 FIXME("default action not implemented\n");
2619 return NS_ERROR_NOT_IMPLEMENTED
;
2622 static nsresult NSAPI
nsURL_GetFileBaseName(nsIURL
*iface
, nsACString
*aFileBaseName
)
2624 nsWineURI
*This
= impl_from_nsIURL(iface
);
2626 TRACE("(%p)->(%p)\n", This
, aFileBaseName
);
2629 return nsIURL_GetFileBaseName(This
->nsurl
, aFileBaseName
);
2631 FIXME("default action not implemented\n");
2632 return NS_ERROR_NOT_IMPLEMENTED
;
2635 static nsresult NSAPI
nsURL_SetFileBaseName(nsIURL
*iface
, const nsACString
*aFileBaseName
)
2637 nsWineURI
*This
= impl_from_nsIURL(iface
);
2639 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aFileBaseName
));
2641 if(!This
->is_mutable
)
2642 return NS_ERROR_UNEXPECTED
;
2645 invalidate_uri(This
);
2646 return nsIURL_SetFileBaseName(This
->nsurl
, aFileBaseName
);
2649 FIXME("default action not implemented\n");
2650 return NS_ERROR_NOT_IMPLEMENTED
;
2653 static nsresult NSAPI
nsURL_GetFileExtension(nsIURL
*iface
, nsACString
*aFileExtension
)
2655 nsWineURI
*This
= impl_from_nsIURL(iface
);
2657 TRACE("(%p)->(%p)\n", This
, aFileExtension
);
2659 return get_uri_string(This
, Uri_PROPERTY_EXTENSION
, aFileExtension
);
2662 static nsresult NSAPI
nsURL_SetFileExtension(nsIURL
*iface
, const nsACString
*aFileExtension
)
2664 nsWineURI
*This
= impl_from_nsIURL(iface
);
2666 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aFileExtension
));
2668 if(!This
->is_mutable
)
2669 return NS_ERROR_UNEXPECTED
;
2672 invalidate_uri(This
);
2673 return nsIURL_SetFileExtension(This
->nsurl
, aFileExtension
);
2676 FIXME("default action not implemented\n");
2677 return NS_ERROR_NOT_IMPLEMENTED
;
2680 static nsresult NSAPI
nsURL_GetCommonBaseSpec(nsIURL
*iface
, nsIURI
*aURIToCompare
, nsACString
*_retval
)
2682 nsWineURI
*This
= impl_from_nsIURL(iface
);
2684 TRACE("(%p)->(%p %p)\n", This
, aURIToCompare
, _retval
);
2687 return nsIURL_GetCommonBaseSpec(This
->nsurl
, aURIToCompare
, _retval
);
2689 FIXME("default action not implemented\n");
2690 return NS_ERROR_NOT_IMPLEMENTED
;
2693 static nsresult NSAPI
nsURL_GetRelativeSpec(nsIURL
*iface
, nsIURI
*aURIToCompare
, nsACString
*_retval
)
2695 nsWineURI
*This
= impl_from_nsIURL(iface
);
2697 TRACE("(%p)->(%p %p)\n", This
, aURIToCompare
, _retval
);
2700 return nsIURL_GetRelativeSpec(This
->nsurl
, aURIToCompare
, _retval
);
2702 FIXME("default action not implemented\n");
2703 return NS_ERROR_NOT_IMPLEMENTED
;
2706 static const nsIURLVtbl nsURLVtbl
= {
2707 nsURI_QueryInterface
,
2735 nsURI_GetOriginCharset
,
2738 nsURI_EqualsExceptRef
,
2739 nsURI_CloneIgnoreRef
,
2740 nsURI_GetSpecIgnoringRef
,
2752 nsURL_GetFileBaseName
,
2753 nsURL_SetFileBaseName
,
2754 nsURL_GetFileExtension
,
2755 nsURL_SetFileExtension
,
2756 nsURL_GetCommonBaseSpec
,
2757 nsURL_GetRelativeSpec
2760 static inline nsWineURI
*impl_from_nsIStandardURL(nsIStandardURL
*iface
)
2762 return CONTAINING_RECORD(iface
, nsWineURI
, nsIStandardURL_iface
);
2765 static nsresult NSAPI
nsStandardURL_QueryInterface(nsIStandardURL
*iface
, nsIIDRef riid
,
2768 nsWineURI
*This
= impl_from_nsIStandardURL(iface
);
2769 return nsIURL_QueryInterface(&This
->nsIURL_iface
, riid
, result
);
2772 static nsrefcnt NSAPI
nsStandardURL_AddRef(nsIStandardURL
*iface
)
2774 nsWineURI
*This
= impl_from_nsIStandardURL(iface
);
2775 return nsIURL_AddRef(&This
->nsIURL_iface
);
2778 static nsrefcnt NSAPI
nsStandardURL_Release(nsIStandardURL
*iface
)
2780 nsWineURI
*This
= impl_from_nsIStandardURL(iface
);
2781 return nsIURL_Release(&This
->nsIURL_iface
);
2784 static nsresult NSAPI
nsStandardURL_GetMutable(nsIStandardURL
*iface
, PRBool
*aMutable
)
2786 nsWineURI
*This
= impl_from_nsIStandardURL(iface
);
2788 TRACE("(%p)->(%p)\n", This
, aMutable
);
2790 *aMutable
= This
->is_mutable
;
2794 static nsresult NSAPI
nsStandardURL_SetMutable(nsIStandardURL
*iface
, PRBool aMutable
)
2796 nsWineURI
*This
= impl_from_nsIStandardURL(iface
);
2798 TRACE("(%p)->(%x)\n", This
, aMutable
);
2800 This
->is_mutable
= aMutable
;
2804 static nsresult NSAPI
nsStandardURL_Init(nsIStandardURL
*iface
, PRUint32 aUrlType
, PRInt32 aDefaultPort
,
2805 const nsACString
*aSpec
, const char *aOriginCharset
, nsIURI
*aBaseURI
)
2807 nsWineURI
*This
= impl_from_nsIStandardURL(iface
);
2808 FIXME("(%p)->(%d %d %s %s %p)\n", This
, aUrlType
, aDefaultPort
, debugstr_nsacstr(aSpec
), debugstr_a(aOriginCharset
), aBaseURI
);
2809 return NS_ERROR_NOT_IMPLEMENTED
;
2812 static const nsIStandardURLVtbl nsStandardURLVtbl
= {
2813 nsStandardURL_QueryInterface
,
2814 nsStandardURL_AddRef
,
2815 nsStandardURL_Release
,
2816 nsStandardURL_GetMutable
,
2817 nsStandardURL_SetMutable
,
2821 static nsresult
create_nsuri(IUri
*iuri
, nsIURI
*nsuri
, HTMLWindow
*window
, NSContainer
*container
, nsWineURI
**_retval
)
2823 nsWineURI
*ret
= heap_alloc_zero(sizeof(nsWineURI
));
2825 ret
->nsIURL_iface
.lpVtbl
= &nsURLVtbl
;
2826 ret
->nsIStandardURL_iface
.lpVtbl
= &nsStandardURLVtbl
;
2829 ret
->is_mutable
= TRUE
;
2831 set_uri_nscontainer(ret
, container
);
2832 set_uri_window(ret
, window
);
2838 nsIURI_QueryInterface(nsuri
, &IID_nsIURL
, (void**)&ret
->nsurl
);
2840 TRACE("retval=%p\n", ret
);
2845 HRESULT
create_doc_uri(HTMLWindow
*window
, WCHAR
*url
, nsWineURI
**ret
)
2852 hres
= CreateUri(url
, 0, 0, &iuri
);
2856 nsres
= create_nsuri(iuri
, NULL
, window
, window
->doc_obj
->nscontainer
, &uri
);
2858 if(NS_FAILED(nsres
))
2861 uri
->is_doc_uri
= TRUE
;
2867 static nsresult
create_nschannel(nsWineURI
*uri
, nsChannel
**ret
)
2872 if(!ensure_uri(uri
))
2873 return NS_ERROR_UNEXPECTED
;
2875 channel
= heap_alloc_zero(sizeof(nsChannel
));
2877 return NS_ERROR_OUT_OF_MEMORY
;
2879 channel
->nsIHttpChannel_iface
.lpVtbl
= &nsChannelVtbl
;
2880 channel
->nsIUploadChannel_iface
.lpVtbl
= &nsUploadChannelVtbl
;
2881 channel
->nsIHttpChannelInternal_iface
.lpVtbl
= &nsHttpChannelInternalVtbl
;
2883 channel
->request_method
= METHOD_GET
;
2884 list_init(&channel
->response_headers
);
2885 list_init(&channel
->request_headers
);
2887 nsIURL_AddRef(&uri
->nsIURL_iface
);
2890 hres
= IUri_GetScheme(uri
->uri
, &channel
->url_scheme
);
2892 channel
->url_scheme
= URL_SCHEME_UNKNOWN
;
2898 HRESULT
create_redirect_nschannel(const WCHAR
*url
, nsChannel
*orig_channel
, nsChannel
**ret
)
2900 HTMLWindow
*window
= NULL
;
2907 hres
= CreateUri(url
, 0, 0, &iuri
);
2911 if(orig_channel
->uri
->window_ref
)
2912 window
= orig_channel
->uri
->window_ref
->window
;
2913 nsres
= create_nsuri(iuri
, NULL
, window
, NULL
, &uri
);
2915 if(NS_FAILED(nsres
))
2918 nsres
= create_nschannel(uri
, &channel
);
2919 nsIURL_Release(&uri
->nsIURL_iface
);
2920 if(NS_FAILED(nsres
))
2923 if(orig_channel
->load_group
) {
2924 nsILoadGroup_AddRef(orig_channel
->load_group
);
2925 channel
->load_group
= orig_channel
->load_group
;
2928 if(orig_channel
->notif_callback
) {
2929 nsIInterfaceRequestor_AddRef(orig_channel
->notif_callback
);
2930 channel
->notif_callback
= orig_channel
->notif_callback
;
2933 channel
->load_flags
= orig_channel
->load_flags
| LOAD_REPLACE
;
2935 if(orig_channel
->request_method
== METHOD_POST
)
2936 FIXME("unsupported POST method\n");
2938 if(orig_channel
->original_uri
) {
2939 nsIURI_AddRef(orig_channel
->original_uri
);
2940 channel
->original_uri
= orig_channel
->original_uri
;
2943 if(orig_channel
->referrer
) {
2944 nsIURI_AddRef(orig_channel
->referrer
);
2945 channel
->referrer
= orig_channel
->referrer
;
2953 nsIProtocolHandler nsIProtocolHandler_iface
;
2957 nsIProtocolHandler
*nshandler
;
2958 } nsProtocolHandler
;
2960 static inline nsProtocolHandler
*impl_from_nsIProtocolHandler(nsIProtocolHandler
*iface
)
2962 return CONTAINING_RECORD(iface
, nsProtocolHandler
, nsIProtocolHandler_iface
);
2965 static nsresult NSAPI
nsProtocolHandler_QueryInterface(nsIProtocolHandler
*iface
, nsIIDRef riid
,
2968 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
2972 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
2973 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
2974 *result
= &This
->nsIProtocolHandler_iface
;
2975 }else if(IsEqualGUID(&IID_nsIProtocolHandler
, riid
)) {
2976 TRACE("(%p)->(IID_nsIProtocolHandler %p)\n", This
, result
);
2977 *result
= &This
->nsIProtocolHandler_iface
;
2978 }else if(IsEqualGUID(&IID_nsIExternalProtocolHandler
, riid
)) {
2979 TRACE("(%p)->(IID_nsIExternalProtocolHandler %p), returning NULL\n", This
, result
);
2980 return NS_NOINTERFACE
;
2984 nsISupports_AddRef((nsISupports
*)*result
);
2988 WARN("(%s %p)\n", debugstr_guid(riid
), result
);
2989 return NS_NOINTERFACE
;
2992 static nsrefcnt NSAPI
nsProtocolHandler_AddRef(nsIProtocolHandler
*iface
)
2994 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
2995 LONG ref
= InterlockedIncrement(&This
->ref
);
2997 TRACE("(%p) ref=%d\n", This
, ref
);
3002 static nsrefcnt NSAPI
nsProtocolHandler_Release(nsIProtocolHandler
*iface
)
3004 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3005 LONG ref
= InterlockedDecrement(&This
->ref
);
3007 TRACE("(%p) ref=%d\n", This
, ref
);
3011 nsIProtocolHandler_Release(This
->nshandler
);
3018 static nsresult NSAPI
nsProtocolHandler_GetScheme(nsIProtocolHandler
*iface
, nsACString
*aScheme
)
3020 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3022 TRACE("(%p)->(%p)\n", This
, aScheme
);
3025 return nsIProtocolHandler_GetScheme(This
->nshandler
, aScheme
);
3026 return NS_ERROR_NOT_IMPLEMENTED
;
3029 static nsresult NSAPI
nsProtocolHandler_GetDefaultPort(nsIProtocolHandler
*iface
,
3030 PRInt32
*aDefaultPort
)
3032 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3034 TRACE("(%p)->(%p)\n", This
, aDefaultPort
);
3037 return nsIProtocolHandler_GetDefaultPort(This
->nshandler
, aDefaultPort
);
3038 return NS_ERROR_NOT_IMPLEMENTED
;
3041 static nsresult NSAPI
nsProtocolHandler_GetProtocolFlags(nsIProtocolHandler
*iface
,
3042 PRUint32
*aProtocolFlags
)
3044 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3046 TRACE("(%p)->(%p)\n", This
, aProtocolFlags
);
3049 return nsIProtocolHandler_GetProtocolFlags(This
->nshandler
, aProtocolFlags
);
3050 return NS_ERROR_NOT_IMPLEMENTED
;
3053 static nsresult NSAPI
nsProtocolHandler_NewURI(nsIProtocolHandler
*iface
,
3054 const nsACString
*aSpec
, const char *aOriginCharset
, nsIURI
*aBaseURI
, nsIURI
**_retval
)
3056 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3058 TRACE("((%p)->%s %s %p %p)\n", This
, debugstr_nsacstr(aSpec
), debugstr_a(aOriginCharset
),
3062 return nsIProtocolHandler_NewURI(This
->nshandler
, aSpec
, aOriginCharset
, aBaseURI
, _retval
);
3063 return NS_ERROR_NOT_IMPLEMENTED
;
3066 static nsresult NSAPI
nsProtocolHandler_NewChannel(nsIProtocolHandler
*iface
,
3067 nsIURI
*aURI
, nsIChannel
**_retval
)
3069 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3071 TRACE("(%p)->(%p %p)\n", This
, aURI
, _retval
);
3074 return nsIProtocolHandler_NewChannel(This
->nshandler
, aURI
, _retval
);
3075 return NS_ERROR_NOT_IMPLEMENTED
;
3078 static nsresult NSAPI
nsProtocolHandler_AllowPort(nsIProtocolHandler
*iface
,
3079 PRInt32 port
, const char *scheme
, PRBool
*_retval
)
3081 nsProtocolHandler
*This
= impl_from_nsIProtocolHandler(iface
);
3083 TRACE("(%p)->(%d %s %p)\n", This
, port
, debugstr_a(scheme
), _retval
);
3086 return nsIProtocolHandler_AllowPort(This
->nshandler
, port
, scheme
, _retval
);
3087 return NS_ERROR_NOT_IMPLEMENTED
;
3090 static const nsIProtocolHandlerVtbl nsProtocolHandlerVtbl
= {
3091 nsProtocolHandler_QueryInterface
,
3092 nsProtocolHandler_AddRef
,
3093 nsProtocolHandler_Release
,
3094 nsProtocolHandler_GetScheme
,
3095 nsProtocolHandler_GetDefaultPort
,
3096 nsProtocolHandler_GetProtocolFlags
,
3097 nsProtocolHandler_NewURI
,
3098 nsProtocolHandler_NewChannel
,
3099 nsProtocolHandler_AllowPort
3102 static nsIProtocolHandler
*create_protocol_handler(nsIProtocolHandler
*nshandler
)
3104 nsProtocolHandler
*ret
= heap_alloc(sizeof(nsProtocolHandler
));
3106 ret
->nsIProtocolHandler_iface
.lpVtbl
= &nsProtocolHandlerVtbl
;
3108 ret
->nshandler
= nshandler
;
3110 return &ret
->nsIProtocolHandler_iface
;
3113 static nsresult NSAPI
nsIOService_QueryInterface(nsIIOService
*,nsIIDRef
,void**);
3115 static nsrefcnt NSAPI
nsIOService_AddRef(nsIIOService
*iface
)
3120 static nsrefcnt NSAPI
nsIOService_Release(nsIIOService
*iface
)
3125 static nsresult NSAPI
nsIOService_GetProtocolHandler(nsIIOService
*iface
, const char *aScheme
,
3126 nsIProtocolHandler
**_retval
)
3128 nsIExternalProtocolHandler
*nsexthandler
;
3129 nsIProtocolHandler
*nshandler
;
3132 TRACE("(%s %p)\n", debugstr_a(aScheme
), _retval
);
3134 nsres
= nsIIOService_GetProtocolHandler(nsio
, aScheme
, &nshandler
);
3135 if(NS_FAILED(nsres
)) {
3136 WARN("GetProtocolHandler failed: %08x\n", nsres
);
3140 nsres
= nsIProtocolHandler_QueryInterface(nshandler
, &IID_nsIExternalProtocolHandler
,
3141 (void**)&nsexthandler
);
3142 if(NS_FAILED(nsres
)) {
3143 *_retval
= nshandler
;
3147 nsIExternalProtocolHandler_Release(nsexthandler
);
3148 *_retval
= create_protocol_handler(nshandler
);
3149 TRACE("return %p\n", *_retval
);
3153 static nsresult NSAPI
nsIOService_GetProtocolFlags(nsIIOService
*iface
, const char *aScheme
,
3156 TRACE("(%s %p)\n", debugstr_a(aScheme
), _retval
);
3157 return nsIIOService_GetProtocolFlags(nsio
, aScheme
, _retval
);
3160 static BOOL
is_gecko_special_uri(const char *spec
)
3162 static const char *special_schemes
[] = {"chrome:", "jar:", "moz-safe-about", "resource:", "javascript:", "wyciwyg:"};
3165 for(i
=0; i
< sizeof(special_schemes
)/sizeof(*special_schemes
); i
++) {
3166 if(!strncasecmp(spec
, special_schemes
[i
], strlen(special_schemes
[i
])))
3170 if(!strncasecmp(spec
, "file:", 5)) {
3171 const char *ptr
= spec
+5;
3174 return is_gecko_path(ptr
);
3180 static nsresult NSAPI
nsIOService_NewURI(nsIIOService
*iface
, const nsACString
*aSpec
,
3181 const char *aOriginCharset
, nsIURI
*aBaseURI
, nsIURI
**_retval
)
3183 nsWineURI
*wine_uri
, *base_wine_uri
= NULL
;
3184 WCHAR new_spec
[INTERNET_MAX_URL_LENGTH
];
3185 HTMLWindow
*window
= NULL
;
3186 const char *spec
= NULL
;
3192 TRACE("(%s %s %p %p)\n", debugstr_nsacstr(aSpec
), debugstr_a(aOriginCharset
),
3195 nsACString_GetData(aSpec
, &spec
);
3196 if(is_gecko_special_uri(spec
))
3197 return nsIIOService_NewURI(nsio
, aSpec
, aOriginCharset
, aBaseURI
, _retval
);
3199 if(!strncmp(spec
, "wine:", 5))
3203 nsres
= nsIURI_QueryInterface(aBaseURI
, &IID_nsWineURI
, (void**)&base_wine_uri
);
3204 if(NS_SUCCEEDED(nsres
)) {
3205 if(!ensure_uri(base_wine_uri
))
3206 return NS_ERROR_UNEXPECTED
;
3207 if(base_wine_uri
->window_ref
)
3208 window
= base_wine_uri
->window_ref
->window
;
3210 WARN("Could not get base nsWineURI: %08x\n", nsres
);
3214 MultiByteToWideChar(CP_ACP
, 0, spec
, -1, new_spec
, sizeof(new_spec
)/sizeof(WCHAR
));
3217 hres
= CoInternetCombineUrlEx(base_wine_uri
->uri
, new_spec
, URL_ESCAPE_SPACES_ONLY
|URL_DONT_ESCAPE_EXTRA_INFO
,
3220 WARN("CoInternetCombineUrlEx failed: %08x\n", hres
);
3222 hres
= CreateUri(new_spec
, 0, 0, &urlmon_uri
);
3224 WARN("CreateUri failed: %08x\n", hres
);
3227 nsres
= nsIIOService_NewURI(nsio
, aSpec
, aOriginCharset
, aBaseURI
, &uri
);
3228 if(NS_FAILED(nsres
))
3229 TRACE("NewURI failed: %08x\n", nsres
);
3236 nsres
= create_nsuri(urlmon_uri
, uri
, window
, NULL
, &wine_uri
);
3237 IUri_Release(urlmon_uri
);
3239 nsIURI_Release(&base_wine_uri
->nsIURL_iface
);
3240 if(NS_FAILED(nsres
))
3243 *_retval
= (nsIURI
*)&wine_uri
->nsIURL_iface
;
3247 static nsresult NSAPI
nsIOService_NewFileURI(nsIIOService
*iface
, nsIFile
*aFile
,
3250 TRACE("(%p %p)\n", aFile
, _retval
);
3251 return nsIIOService_NewFileURI(nsio
, aFile
, _retval
);
3254 static nsresult NSAPI
nsIOService_NewChannelFromURI(nsIIOService
*iface
, nsIURI
*aURI
,
3255 nsIChannel
**_retval
)
3257 nsWineURI
*wine_uri
;
3261 TRACE("(%p %p)\n", aURI
, _retval
);
3263 nsres
= nsIURI_QueryInterface(aURI
, &IID_nsWineURI
, (void**)&wine_uri
);
3264 if(NS_FAILED(nsres
)) {
3265 TRACE("Could not get nsWineURI: %08x\n", nsres
);
3266 return nsIIOService_NewChannelFromURI(nsio
, aURI
, _retval
);
3269 nsres
= create_nschannel(wine_uri
, &ret
);
3270 nsIURL_Release(&wine_uri
->nsIURL_iface
);
3271 if(NS_FAILED(nsres
))
3274 nsIURI_AddRef(aURI
);
3275 ret
->original_uri
= aURI
;
3277 *_retval
= (nsIChannel
*)&ret
->nsIHttpChannel_iface
;
3281 static nsresult NSAPI
nsIOService_NewChannel(nsIIOService
*iface
, const nsACString
*aSpec
,
3282 const char *aOriginCharset
, nsIURI
*aBaseURI
, nsIChannel
**_retval
)
3284 TRACE("(%s %s %p %p)\n", debugstr_nsacstr(aSpec
), debugstr_a(aOriginCharset
), aBaseURI
, _retval
);
3285 return nsIIOService_NewChannel(nsio
, aSpec
, aOriginCharset
, aBaseURI
, _retval
);
3288 static nsresult NSAPI
nsIOService_GetOffline(nsIIOService
*iface
, PRBool
*aOffline
)
3290 TRACE("(%p)\n", aOffline
);
3291 return nsIIOService_GetOffline(nsio
, aOffline
);
3294 static nsresult NSAPI
nsIOService_SetOffline(nsIIOService
*iface
, PRBool aOffline
)
3296 TRACE("(%x)\n", aOffline
);
3297 return nsIIOService_SetOffline(nsio
, aOffline
);
3300 static nsresult NSAPI
nsIOService_AllowPort(nsIIOService
*iface
, PRInt32 aPort
,
3301 const char *aScheme
, PRBool
*_retval
)
3303 TRACE("(%d %s %p)\n", aPort
, debugstr_a(aScheme
), _retval
);
3304 return nsIIOService_AllowPort(nsio
, aPort
, debugstr_a(aScheme
), _retval
);
3307 static nsresult NSAPI
nsIOService_ExtractScheme(nsIIOService
*iface
, const nsACString
*urlString
,
3308 nsACString
* _retval
)
3310 TRACE("(%s %p)\n", debugstr_nsacstr(urlString
), _retval
);
3311 return nsIIOService_ExtractScheme(nsio
, urlString
, _retval
);
3314 static const nsIIOServiceVtbl nsIOServiceVtbl
= {
3315 nsIOService_QueryInterface
,
3317 nsIOService_Release
,
3318 nsIOService_GetProtocolHandler
,
3319 nsIOService_GetProtocolFlags
,
3321 nsIOService_NewFileURI
,
3322 nsIOService_NewChannelFromURI
,
3323 nsIOService_NewChannel
,
3324 nsIOService_GetOffline
,
3325 nsIOService_SetOffline
,
3326 nsIOService_AllowPort
,
3327 nsIOService_ExtractScheme
3330 static nsIIOService nsIOService
= { &nsIOServiceVtbl
};
3332 static nsresult NSAPI
nsNetUtil_QueryInterface(nsINetUtil
*iface
, nsIIDRef riid
,
3335 return nsIIOService_QueryInterface(&nsIOService
, riid
, result
);
3338 static nsrefcnt NSAPI
nsNetUtil_AddRef(nsINetUtil
*iface
)
3343 static nsrefcnt NSAPI
nsNetUtil_Release(nsINetUtil
*iface
)
3348 static nsresult NSAPI
nsNetUtil_ParseContentType(nsINetUtil
*iface
, const nsACString
*aTypeHeader
,
3349 nsACString
*aCharset
, PRBool
*aHadCharset
, nsACString
*aContentType
)
3351 TRACE("(%s %p %p %p)\n", debugstr_nsacstr(aTypeHeader
), aCharset
, aHadCharset
, aContentType
);
3353 return nsINetUtil_ParseContentType(net_util
, aTypeHeader
, aCharset
, aHadCharset
, aContentType
);
3356 static nsresult NSAPI
nsNetUtil_ProtocolHasFlags(nsINetUtil
*iface
, nsIURI
*aURI
, PRUint32 aFlags
, PRBool
*_retval
)
3360 return nsINetUtil_ProtocolHasFlags(net_util
, aURI
, aFlags
, _retval
);
3363 static nsresult NSAPI
nsNetUtil_URIChainHasFlags(nsINetUtil
*iface
, nsIURI
*aURI
, PRUint32 aFlags
, PRBool
*_retval
)
3365 TRACE("(%p %08x %p)\n", aURI
, aFlags
, _retval
);
3367 if(aFlags
== (1<<11)) {
3372 return nsINetUtil_URIChainHasFlags(net_util
, aURI
, aFlags
, _retval
);
3375 static nsresult NSAPI
nsNetUtil_ToImmutableURI(nsINetUtil
*iface
, nsIURI
*aURI
, nsIURI
**_retval
)
3377 TRACE("(%p %p)\n", aURI
, _retval
);
3379 return nsINetUtil_ToImmutableURI(net_util
, aURI
, _retval
);
3382 static nsresult NSAPI
nsNetUtil_NewSimpleNestedURI(nsINetUtil
*iface
, nsIURI
*aURI
, nsIURI
**_retval
)
3384 TRACE("(%p %p)\n", aURI
, _retval
);
3386 return nsINetUtil_NewSimpleNestedURI(net_util
, aURI
, _retval
);
3389 static nsresult NSAPI
nsNetUtil_EscapeString(nsINetUtil
*iface
, const nsACString
*aString
,
3390 PRUint32 aEscapeType
, nsACString
*_retval
)
3392 TRACE("(%s %x %p)\n", debugstr_nsacstr(aString
), aEscapeType
, _retval
);
3394 return nsINetUtil_EscapeString(net_util
, aString
, aEscapeType
, _retval
);
3397 static nsresult NSAPI
nsNetUtil_EscapeURL(nsINetUtil
*iface
, const nsACString
*aStr
, PRUint32 aFlags
,
3398 nsACString
*_retval
)
3400 TRACE("(%s %08x %p)\n", debugstr_nsacstr(aStr
), aFlags
, _retval
);
3402 return nsINetUtil_EscapeURL(net_util
, aStr
, aFlags
, _retval
);
3405 static nsresult NSAPI
nsNetUtil_UnescapeString(nsINetUtil
*iface
, const nsACString
*aStr
,
3406 PRUint32 aFlags
, nsACString
*_retval
)
3408 TRACE("(%s %08x %p)\n", debugstr_nsacstr(aStr
), aFlags
, _retval
);
3410 return nsINetUtil_UnescapeString(net_util
, aStr
, aFlags
, _retval
);
3413 static nsresult NSAPI
nsNetUtil_ExtractCharsetFromContentType(nsINetUtil
*iface
, const nsACString
*aTypeHeader
,
3414 nsACString
*aCharset
, PRInt32
*aCharsetStart
, PRInt32
*aCharsetEnd
, PRBool
*_retval
)
3416 TRACE("(%s %p %p %p %p)\n", debugstr_nsacstr(aTypeHeader
), aCharset
, aCharsetStart
,
3417 aCharsetEnd
, _retval
);
3419 return nsINetUtil_ExtractCharsetFromContentType(net_util
, aTypeHeader
, aCharset
, aCharsetStart
, aCharsetEnd
, _retval
);
3422 static const nsINetUtilVtbl nsNetUtilVtbl
= {
3423 nsNetUtil_QueryInterface
,
3426 nsNetUtil_ParseContentType
,
3427 nsNetUtil_ProtocolHasFlags
,
3428 nsNetUtil_URIChainHasFlags
,
3429 nsNetUtil_ToImmutableURI
,
3430 nsNetUtil_NewSimpleNestedURI
,
3431 nsNetUtil_EscapeString
,
3432 nsNetUtil_EscapeURL
,
3433 nsNetUtil_UnescapeString
,
3434 nsNetUtil_ExtractCharsetFromContentType
3437 static nsINetUtil nsNetUtil
= { &nsNetUtilVtbl
};
3439 static nsresult NSAPI
nsIOService_QueryInterface(nsIIOService
*iface
, nsIIDRef riid
,
3444 if(IsEqualGUID(&IID_nsISupports
, riid
))
3445 *result
= &nsIOService
;
3446 else if(IsEqualGUID(&IID_nsIIOService
, riid
))
3447 *result
= &nsIOService
;
3448 else if(IsEqualGUID(&IID_nsINetUtil
, riid
))
3449 *result
= &nsNetUtil
;
3452 nsISupports_AddRef((nsISupports
*)*result
);
3456 FIXME("(%s %p)\n", debugstr_guid(riid
), result
);
3457 return NS_NOINTERFACE
;
3460 static nsresult NSAPI
nsIOServiceFactory_QueryInterface(nsIFactory
*iface
, nsIIDRef riid
,
3465 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
3466 TRACE("(IID_nsISupports %p)\n", result
);
3468 }else if(IsEqualGUID(&IID_nsIFactory
, riid
)) {
3469 TRACE("(IID_nsIFactory %p)\n", result
);
3474 nsIFactory_AddRef(iface
);
3478 WARN("(%s %p)\n", debugstr_guid(riid
), result
);
3479 return NS_NOINTERFACE
;
3482 static nsrefcnt NSAPI
nsIOServiceFactory_AddRef(nsIFactory
*iface
)
3487 static nsrefcnt NSAPI
nsIOServiceFactory_Release(nsIFactory
*iface
)
3492 static nsresult NSAPI
nsIOServiceFactory_CreateInstance(nsIFactory
*iface
,
3493 nsISupports
*aOuter
, const nsIID
*iid
, void **result
)
3495 return nsIIOService_QueryInterface(&nsIOService
, iid
, result
);
3498 static nsresult NSAPI
nsIOServiceFactory_LockFactory(nsIFactory
*iface
, PRBool lock
)
3500 WARN("(%x)\n", lock
);
3504 static const nsIFactoryVtbl nsIOServiceFactoryVtbl
= {
3505 nsIOServiceFactory_QueryInterface
,
3506 nsIOServiceFactory_AddRef
,
3507 nsIOServiceFactory_Release
,
3508 nsIOServiceFactory_CreateInstance
,
3509 nsIOServiceFactory_LockFactory
3512 static nsIFactory nsIOServiceFactory
= { &nsIOServiceFactoryVtbl
};
3514 static BOOL
translate_url(HTMLDocumentObj
*doc
, nsWineURI
*uri
)
3516 OLECHAR
*new_url
= NULL
;
3521 if(!doc
->hostui
|| !ensure_uri(uri
))
3524 hres
= IUri_GetDisplayUri(uri
->uri
, &url
);
3528 hres
= IDocHostUIHandler_TranslateUrl(doc
->hostui
, 0, url
, &new_url
);
3529 if(hres
== S_OK
&& new_url
) {
3530 if(strcmpW(url
, new_url
)) {
3531 FIXME("TranslateUrl returned new URL %s -> %s\n", debugstr_w(url
), debugstr_w(new_url
));
3534 CoTaskMemFree(new_url
);
3541 nsresult
on_start_uri_open(NSContainer
*nscontainer
, nsIURI
*uri
, PRBool
*_retval
)
3543 nsWineURI
*wine_uri
;
3548 nsres
= nsIURI_QueryInterface(uri
, &IID_nsWineURI
, (void**)&wine_uri
);
3549 if(NS_FAILED(nsres
)) {
3550 WARN("Could not get nsWineURI: %08x\n", nsres
);
3551 return NS_ERROR_NOT_IMPLEMENTED
;
3554 if(!wine_uri
->is_doc_uri
) {
3555 wine_uri
->is_doc_uri
= TRUE
;
3557 if(!wine_uri
->container
) {
3558 nsIWebBrowserChrome_AddRef(&nscontainer
->nsIWebBrowserChrome_iface
);
3559 wine_uri
->container
= nscontainer
;
3562 if(nscontainer
->doc
)
3563 *_retval
= translate_url(nscontainer
->doc
, wine_uri
);
3566 nsIURI_Release(&wine_uri
->nsIURL_iface
);
3570 void init_nsio(nsIComponentManager
*component_manager
, nsIComponentRegistrar
*registrar
)
3572 nsIFactory
*old_factory
= NULL
;
3575 nsres
= nsIComponentManager_GetClassObject(component_manager
, &NS_IOSERVICE_CID
,
3576 &IID_nsIFactory
, (void**)&old_factory
);
3577 if(NS_FAILED(nsres
)) {
3578 ERR("Could not get factory: %08x\n", nsres
);
3582 nsres
= nsIFactory_CreateInstance(old_factory
, NULL
, &IID_nsIIOService
, (void**)&nsio
);
3583 if(NS_FAILED(nsres
)) {
3584 ERR("Couldn not create nsIOService instance %08x\n", nsres
);
3585 nsIFactory_Release(old_factory
);
3589 nsres
= nsIIOService_QueryInterface(nsio
, &IID_nsINetUtil
, (void**)&net_util
);
3590 if(NS_FAILED(nsres
)) {
3591 WARN("Could not get nsINetUtil interface: %08x\n", nsres
);
3592 nsIIOService_Release(nsio
);
3596 nsres
= nsIComponentRegistrar_UnregisterFactory(registrar
, &NS_IOSERVICE_CID
, old_factory
);
3597 nsIFactory_Release(old_factory
);
3598 if(NS_FAILED(nsres
))
3599 ERR("UnregisterFactory failed: %08x\n", nsres
);
3601 nsres
= nsIComponentRegistrar_RegisterFactory(registrar
, &NS_IOSERVICE_CID
,
3602 NS_IOSERVICE_CLASSNAME
, NS_IOSERVICE_CONTRACTID
, &nsIOServiceFactory
);
3603 if(NS_FAILED(nsres
))
3604 ERR("RegisterFactory failed: %08x\n", nsres
);
3607 void release_nsio(void)
3610 nsINetUtil_Release(net_util
);
3615 nsIIOService_Release(nsio
);