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 LOAD_INITIAL_DOCUMENT_URI 0x80000
43 #define NS_IOSERVICE_CLASSNAME "nsIOService"
44 #define NS_IOSERVICE_CONTRACTID "@mozilla.org/network/io-service;1"
46 static const IID NS_IOSERVICE_CID
=
47 {0x9ac9e770, 0x18bc, 0x11d3, {0x93, 0x37, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40}};
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 nsIWineURIVtbl
*lpWineURIVtbl
;
61 NSContainer
*container
;
62 windowref_t
*window_ref
;
68 #define NSURI(x) ((nsIURI*) &(x)->lpWineURIVtbl)
69 #define NSWINEURI(x) ((nsIWineURI*) &(x)->lpWineURIVtbl)
71 static nsresult
create_uri(nsIURI
*,HTMLWindow
*,NSContainer
*,nsIWineURI
**);
73 static const char *debugstr_nsacstr(const nsACString
*nsstr
)
77 nsACString_GetData(nsstr
, &data
);
78 return debugstr_a(data
);
81 HRESULT
nsuri_to_url(LPCWSTR nsuri
, BOOL ret_empty
, BSTR
*ret
)
83 const WCHAR
*ptr
= nsuri
;
85 static const WCHAR wine_prefixW
[] = {'w','i','n','e',':'};
87 if(!strncmpW(nsuri
, wine_prefixW
, sizeof(wine_prefixW
)/sizeof(WCHAR
)))
88 ptr
+= sizeof(wine_prefixW
)/sizeof(WCHAR
);
90 if(*ptr
|| ret_empty
) {
91 *ret
= SysAllocString(ptr
);
98 TRACE("%s -> %s\n", debugstr_w(nsuri
), debugstr_w(*ret
));
102 static BOOL
exec_shldocvw_67(HTMLDocumentObj
*doc
, LPCWSTR url
)
104 IOleCommandTarget
*cmdtrg
= NULL
;
107 hres
= IOleClientSite_QueryInterface(doc
->client
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
108 if(SUCCEEDED(hres
)) {
109 VARIANT varUrl
, varRes
;
111 V_VT(&varUrl
) = VT_BSTR
;
112 V_BSTR(&varUrl
) = SysAllocString(url
);
113 V_VT(&varRes
) = VT_BOOL
;
115 hres
= IOleCommandTarget_Exec(cmdtrg
, &CGID_ShellDocView
, 67, 0, &varUrl
, &varRes
);
117 IOleCommandTarget_Release(cmdtrg
);
118 SysFreeString(V_BSTR(&varUrl
));
120 if(SUCCEEDED(hres
) && !V_BOOL(&varRes
)) {
121 TRACE("got VARIANT_FALSE, do not load\n");
129 static BOOL
before_async_open(nsChannel
*channel
, NSContainer
*container
)
131 HTMLDocumentObj
*doc
= container
->doc
;
136 nsIWineURI_GetWineURL(channel
->uri
, &uri
);
138 ERR("GetWineURL returned NULL\n");
143 NSContainer
*container_iter
= container
;
145 hlnf
= HLNF_OPENINNEWWINDOW
;
146 while(!container_iter
->doc
)
147 container_iter
= container_iter
->parent
;
148 doc
= container_iter
->doc
;
154 if(!hlnf
&& !exec_shldocvw_67(doc
, uri
))
157 hres
= hlink_frame_navigate(&doc
->basedoc
, uri
, channel
->post_data_stream
, hlnf
);
161 #define NSCHANNEL_THIS(iface) DEFINE_THIS(nsChannel, HttpChannel, iface)
163 static nsresult NSAPI
nsChannel_QueryInterface(nsIHttpChannel
*iface
, nsIIDRef riid
, nsQIResult result
)
165 nsChannel
*This
= NSCHANNEL_THIS(iface
);
167 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
168 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
169 *result
= NSCHANNEL(This
);
170 }else if(IsEqualGUID(&IID_nsIRequest
, riid
)) {
171 TRACE("(%p)->(IID_nsIRequest %p)\n", This
, result
);
172 *result
= NSCHANNEL(This
);
173 }else if(IsEqualGUID(&IID_nsIChannel
, riid
)) {
174 TRACE("(%p)->(IID_nsIChannel %p)\n", This
, result
);
175 *result
= NSCHANNEL(This
);
176 }else if(IsEqualGUID(&IID_nsIHttpChannel
, riid
)) {
177 TRACE("(%p)->(IID_nsIHttpChannel %p)\n", This
, result
);
178 *result
= This
->http_channel
? NSHTTPCHANNEL(This
) : NULL
;
179 }else if(IsEqualGUID(&IID_nsIUploadChannel
, riid
)) {
180 TRACE("(%p)->(IID_nsIUploadChannel %p)\n", This
, result
);
181 *result
= NSUPCHANNEL(This
);
182 }else if(IsEqualGUID(&IID_nsIHttpChannelInternal
, riid
)) {
183 TRACE("(%p)->(IID_nsIHttpChannelInternal %p)\n", This
, result
);
184 *result
= This
->http_channel_internal
? NSHTTPINTERNAL(This
) : NULL
;
186 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), result
);
191 nsIChannel_AddRef(NSCHANNEL(This
));
195 return NS_NOINTERFACE
;
198 static nsrefcnt NSAPI
nsChannel_AddRef(nsIHttpChannel
*iface
)
200 nsChannel
*This
= NSCHANNEL_THIS(iface
);
201 nsrefcnt ref
= InterlockedIncrement(&This
->ref
);
203 TRACE("(%p) ref=%d\n", This
, ref
);
208 static nsrefcnt NSAPI
nsChannel_Release(nsIHttpChannel
*iface
)
210 nsChannel
*This
= NSCHANNEL_THIS(iface
);
211 LONG ref
= InterlockedDecrement(&This
->ref
);
214 nsIWineURI_Release(This
->uri
);
216 nsIChannel_Release(This
->channel
);
217 if(This
->http_channel
)
218 nsIHttpChannel_Release(This
->http_channel
);
219 if(This
->http_channel_internal
)
220 nsIHttpChannel_Release(This
->http_channel_internal
);
222 nsISupports_Release(This
->owner
);
223 if(This
->post_data_stream
)
224 nsIInputStream_Release(This
->post_data_stream
);
226 nsILoadGroup_Release(This
->load_group
);
227 if(This
->notif_callback
)
228 nsIInterfaceRequestor_Release(This
->notif_callback
);
229 if(This
->original_uri
)
230 nsIURI_Release(This
->original_uri
);
231 heap_free(This
->content_type
);
232 heap_free(This
->charset
);
239 static nsresult NSAPI
nsChannel_GetName(nsIHttpChannel
*iface
, nsACString
*aName
)
241 nsChannel
*This
= NSCHANNEL_THIS(iface
);
243 TRACE("(%p)->(%p)\n", This
, aName
);
246 return nsIChannel_GetName(This
->channel
, aName
);
248 return NS_ERROR_NOT_IMPLEMENTED
;
251 static nsresult NSAPI
nsChannel_IsPending(nsIHttpChannel
*iface
, PRBool
*_retval
)
253 nsChannel
*This
= NSCHANNEL_THIS(iface
);
255 TRACE("(%p)->(%p)\n", This
, _retval
);
258 return nsIChannel_IsPending(This
->channel
, _retval
);
260 FIXME("default action not implemented\n");
261 return NS_ERROR_NOT_IMPLEMENTED
;
264 static nsresult NSAPI
nsChannel_GetStatus(nsIHttpChannel
*iface
, nsresult
*aStatus
)
266 nsChannel
*This
= NSCHANNEL_THIS(iface
);
268 TRACE("(%p)->(%p)\n", This
, aStatus
);
271 return nsIChannel_GetStatus(This
->channel
, aStatus
);
273 TRACE("returning NS_OK\n");
274 return *aStatus
= NS_OK
;
277 static nsresult NSAPI
nsChannel_Cancel(nsIHttpChannel
*iface
, nsresult aStatus
)
279 nsChannel
*This
= NSCHANNEL_THIS(iface
);
281 TRACE("(%p)->(%08x)\n", This
, aStatus
);
284 return nsIChannel_Cancel(This
->channel
, aStatus
);
286 FIXME("default action not implemented\n");
287 return NS_ERROR_NOT_IMPLEMENTED
;
290 static nsresult NSAPI
nsChannel_Suspend(nsIHttpChannel
*iface
)
292 nsChannel
*This
= NSCHANNEL_THIS(iface
);
294 TRACE("(%p)\n", This
);
297 return nsIChannel_Suspend(This
->channel
);
299 FIXME("default action not implemented\n");
300 return NS_ERROR_NOT_IMPLEMENTED
;
303 static nsresult NSAPI
nsChannel_Resume(nsIHttpChannel
*iface
)
305 nsChannel
*This
= NSCHANNEL_THIS(iface
);
307 TRACE("(%p)\n", This
);
310 return nsIChannel_Resume(This
->channel
);
312 FIXME("default action not implemented\n");
313 return NS_ERROR_NOT_IMPLEMENTED
;
316 static nsresult NSAPI
nsChannel_GetLoadGroup(nsIHttpChannel
*iface
, nsILoadGroup
**aLoadGroup
)
318 nsChannel
*This
= NSCHANNEL_THIS(iface
);
320 TRACE("(%p)->(%p)\n", This
, aLoadGroup
);
323 nsILoadGroup_AddRef(This
->load_group
);
325 *aLoadGroup
= This
->load_group
;
329 static nsresult NSAPI
nsChannel_SetLoadGroup(nsIHttpChannel
*iface
, nsILoadGroup
*aLoadGroup
)
331 nsChannel
*This
= NSCHANNEL_THIS(iface
);
333 TRACE("(%p)->(%p)\n", This
, aLoadGroup
);
336 nsILoadGroup_Release(This
->load_group
);
338 nsILoadGroup_AddRef(aLoadGroup
);
340 This
->load_group
= aLoadGroup
;
343 return nsIChannel_SetLoadGroup(This
->channel
, aLoadGroup
);
347 static nsresult NSAPI
nsChannel_GetLoadFlags(nsIHttpChannel
*iface
, nsLoadFlags
*aLoadFlags
)
349 nsChannel
*This
= NSCHANNEL_THIS(iface
);
351 TRACE("(%p)->(%p)\n", This
, aLoadFlags
);
353 *aLoadFlags
= This
->load_flags
;
357 static nsresult NSAPI
nsChannel_SetLoadFlags(nsIHttpChannel
*iface
, nsLoadFlags aLoadFlags
)
359 nsChannel
*This
= NSCHANNEL_THIS(iface
);
361 TRACE("(%p)->(%08x)\n", This
, aLoadFlags
);
363 This
->load_flags
= aLoadFlags
;
366 return nsIChannel_SetLoadFlags(This
->channel
, aLoadFlags
);
370 static nsresult NSAPI
nsChannel_GetOriginalURI(nsIHttpChannel
*iface
, nsIURI
**aOriginalURI
)
372 nsChannel
*This
= NSCHANNEL_THIS(iface
);
374 TRACE("(%p)->(%p)\n", This
, aOriginalURI
);
376 if(This
->original_uri
)
377 nsIURI_AddRef(This
->original_uri
);
379 *aOriginalURI
= This
->original_uri
;
383 static nsresult NSAPI
nsChannel_SetOriginalURI(nsIHttpChannel
*iface
, nsIURI
*aOriginalURI
)
385 nsChannel
*This
= NSCHANNEL_THIS(iface
);
387 TRACE("(%p)->(%p)\n", This
, aOriginalURI
);
389 if(This
->original_uri
)
390 nsIURI_Release(This
->original_uri
);
392 nsIURI_AddRef(aOriginalURI
);
393 This
->original_uri
= aOriginalURI
;
396 return nsIChannel_SetOriginalURI(This
->channel
, aOriginalURI
);
400 static nsresult NSAPI
nsChannel_GetURI(nsIHttpChannel
*iface
, nsIURI
**aURI
)
402 nsChannel
*This
= NSCHANNEL_THIS(iface
);
404 TRACE("(%p)->(%p)\n", This
, aURI
);
406 nsIWineURI_AddRef(This
->uri
);
407 *aURI
= (nsIURI
*)This
->uri
;
412 static nsresult NSAPI
nsChannel_GetOwner(nsIHttpChannel
*iface
, nsISupports
**aOwner
)
414 nsChannel
*This
= NSCHANNEL_THIS(iface
);
416 TRACE("(%p)->(%p)\n", This
, aOwner
);
419 return nsIChannel_GetOwner(This
->channel
, aOwner
);
422 nsISupports_AddRef(This
->owner
);
423 *aOwner
= This
->owner
;
428 static nsresult NSAPI
nsChannel_SetOwner(nsIHttpChannel
*iface
, nsISupports
*aOwner
)
430 nsChannel
*This
= NSCHANNEL_THIS(iface
);
432 TRACE("(%p)->(%p)\n", This
, aOwner
);
435 return nsIChannel_SetOwner(This
->channel
, aOwner
);
438 nsISupports_AddRef(aOwner
);
440 nsISupports_Release(This
->owner
);
441 This
->owner
= aOwner
;
446 static nsresult NSAPI
nsChannel_GetNotificationCallbacks(nsIHttpChannel
*iface
,
447 nsIInterfaceRequestor
**aNotificationCallbacks
)
449 nsChannel
*This
= NSCHANNEL_THIS(iface
);
451 TRACE("(%p)->(%p)\n", This
, aNotificationCallbacks
);
453 if(This
->notif_callback
)
454 nsIInterfaceRequestor_AddRef(This
->notif_callback
);
455 *aNotificationCallbacks
= This
->notif_callback
;
460 static nsresult NSAPI
nsChannel_SetNotificationCallbacks(nsIHttpChannel
*iface
,
461 nsIInterfaceRequestor
*aNotificationCallbacks
)
463 nsChannel
*This
= NSCHANNEL_THIS(iface
);
465 TRACE("(%p)->(%p)\n", This
, aNotificationCallbacks
);
467 if(This
->notif_callback
)
468 nsIInterfaceRequestor_Release(This
->notif_callback
);
469 if(aNotificationCallbacks
)
470 nsIInterfaceRequestor_AddRef(aNotificationCallbacks
);
472 This
->notif_callback
= aNotificationCallbacks
;
475 return nsIChannel_SetNotificationCallbacks(This
->channel
, aNotificationCallbacks
);
479 static nsresult NSAPI
nsChannel_GetSecurityInfo(nsIHttpChannel
*iface
, nsISupports
**aSecurityInfo
)
481 nsChannel
*This
= NSCHANNEL_THIS(iface
);
483 TRACE("(%p)->(%p)\n", This
, aSecurityInfo
);
486 return nsIChannel_GetSecurityInfo(This
->channel
, aSecurityInfo
);
488 FIXME("default action not implemented\n");
489 return NS_ERROR_NOT_IMPLEMENTED
;
492 static nsresult NSAPI
nsChannel_GetContentType(nsIHttpChannel
*iface
, nsACString
*aContentType
)
494 nsChannel
*This
= NSCHANNEL_THIS(iface
);
496 TRACE("(%p)->(%p)\n", This
, aContentType
);
498 if(This
->content_type
) {
499 nsACString_SetData(aContentType
, This
->content_type
);
504 return nsIChannel_GetContentType(This
->channel
, aContentType
);
506 WARN("unknown type\n");
507 return NS_ERROR_FAILURE
;
510 static nsresult NSAPI
nsChannel_SetContentType(nsIHttpChannel
*iface
,
511 const nsACString
*aContentType
)
513 nsChannel
*This
= NSCHANNEL_THIS(iface
);
514 const char *content_type
;
516 TRACE("(%p)->(%p)\n", This
, aContentType
);
518 nsACString_GetData(aContentType
, &content_type
);
520 TRACE("content_type %s\n", content_type
);
522 heap_free(This
->content_type
);
523 This
->content_type
= heap_strdupA(content_type
);
526 return nsIChannel_SetContentType(This
->channel
, aContentType
);
531 static nsresult NSAPI
nsChannel_GetContentCharset(nsIHttpChannel
*iface
,
532 nsACString
*aContentCharset
)
534 nsChannel
*This
= NSCHANNEL_THIS(iface
);
536 TRACE("(%p)->(%p)\n", This
, aContentCharset
);
539 nsACString_SetData(aContentCharset
, This
->charset
);
544 nsresult nsres
= nsIChannel_GetContentCharset(This
->channel
, aContentCharset
);
546 nsACString_GetData(aContentCharset
, &ch
);
550 nsACString_SetData(aContentCharset
, "");
554 static nsresult NSAPI
nsChannel_SetContentCharset(nsIHttpChannel
*iface
,
555 const nsACString
*aContentCharset
)
557 nsChannel
*This
= NSCHANNEL_THIS(iface
);
559 TRACE("(%p)->(%p)\n", This
, aContentCharset
);
562 return nsIChannel_SetContentCharset(This
->channel
, aContentCharset
);
564 FIXME("default action not implemented\n");
565 return NS_ERROR_NOT_IMPLEMENTED
;
568 static nsresult NSAPI
nsChannel_GetContentLength(nsIHttpChannel
*iface
, PRInt32
*aContentLength
)
570 nsChannel
*This
= NSCHANNEL_THIS(iface
);
572 TRACE("(%p)->(%p)\n", This
, aContentLength
);
575 return nsIChannel_GetContentLength(This
->channel
, aContentLength
);
577 FIXME("default action not implemented\n");
578 return NS_ERROR_NOT_IMPLEMENTED
;
581 static nsresult NSAPI
nsChannel_SetContentLength(nsIHttpChannel
*iface
, PRInt32 aContentLength
)
583 nsChannel
*This
= NSCHANNEL_THIS(iface
);
585 TRACE("(%p)->(%d)\n", This
, aContentLength
);
588 return nsIChannel_SetContentLength(This
->channel
, aContentLength
);
590 FIXME("default action not implemented\n");
591 return NS_ERROR_NOT_IMPLEMENTED
;
594 static nsresult NSAPI
nsChannel_Open(nsIHttpChannel
*iface
, nsIInputStream
**_retval
)
596 nsChannel
*This
= NSCHANNEL_THIS(iface
);
598 TRACE("(%p)->(%p)\n", This
, _retval
);
601 return nsIChannel_Open(This
->channel
, _retval
);
603 FIXME("default action not implemented\n");
604 return NS_ERROR_NOT_IMPLEMENTED
;
607 static HRESULT
create_mon_for_nschannel(nsChannel
*channel
, IMoniker
**mon
)
609 nsIWineURI
*wine_uri
;
614 if(!channel
->original_uri
) {
615 ERR("original_uri == NULL\n");
619 nsres
= nsIURI_QueryInterface(channel
->original_uri
, &IID_nsIWineURI
, (void**)&wine_uri
);
620 if(NS_FAILED(nsres
)) {
621 ERR("Could not get nsIWineURI: %08x\n", nsres
);
625 nsIWineURI_GetWineURL(wine_uri
, &wine_url
);
626 nsIWineURI_Release(wine_uri
);
628 TRACE("wine_url == NULL\n");
632 hres
= CreateURLMoniker(NULL
, wine_url
, mon
);
634 WARN("CreateURLMoniker failed: %08x\n", hres
);
639 static HTMLWindow
*get_window_from_load_group(nsChannel
*This
)
644 nsIWineURI
*wine_uri
;
648 nsres
= nsILoadGroup_GetDefaultLoadRequest(This
->load_group
, &req
);
649 if(NS_FAILED(nsres
)) {
650 ERR("GetDefaultLoadRequest failed: %08x\n", nsres
);
657 nsres
= nsIRequest_QueryInterface(req
, &IID_nsIChannel
, (void**)&channel
);
658 nsIRequest_Release(req
);
659 if(NS_FAILED(nsres
)) {
660 WARN("Could not get nsIChannel interface: %08x\n", nsres
);
664 nsres
= nsIChannel_GetURI(channel
, &uri
);
665 nsIChannel_Release(channel
);
666 if(NS_FAILED(nsres
)) {
667 ERR("GetURI failed: %08x\n", nsres
);
671 nsres
= nsIURI_QueryInterface(uri
, &IID_nsIWineURI
, (void**)&wine_uri
);
673 if(NS_FAILED(nsres
)) {
674 TRACE("Could not get nsIWineURI: %08x\n", nsres
);
678 nsIWineURI_GetWindow(wine_uri
, &window
);
679 nsIWineURI_Release(wine_uri
);
684 static HTMLWindow
*get_channel_window(nsChannel
*This
)
686 nsIRequestObserver
*req_observer
;
687 nsIWebProgress
*web_progress
;
688 nsIDOMWindow
*nswindow
;
692 if(!This
->load_group
) {
693 ERR("NULL load_group\n");
697 nsres
= nsILoadGroup_GetGroupObserver(This
->load_group
, &req_observer
);
698 if(NS_FAILED(nsres
) || !req_observer
) {
699 ERR("GetGroupObserver failed: %08x\n", nsres
);
703 nsres
= nsIRequestObserver_QueryInterface(req_observer
, &IID_nsIWebProgress
, (void**)&web_progress
);
704 nsIRequestObserver_Release(req_observer
);
705 if(NS_FAILED(nsres
)) {
706 ERR("Could not get nsIWebProgress iface: %08x\n", nsres
);
710 nsres
= nsIWebProgress_GetDOMWindow(web_progress
, &nswindow
);
711 nsIWebProgress_Release(web_progress
);
712 if(NS_FAILED(nsres
) || !nswindow
) {
713 ERR("GetDOMWindow failed: %08x\n", nsres
);
717 window
= nswindow_to_window(nswindow
);
718 nsIDOMWindow_Release(nswindow
);
721 IHTMLWindow2_AddRef(HTMLWINDOW2(window
));
723 FIXME("NULL window for %p\n", nswindow
);
729 HTMLDocumentNode
*doc
;
730 nsChannelBSC
*bscallback
;
731 } start_binding_task_t
;
733 static void start_binding_proc(task_t
*_task
)
735 start_binding_task_t
*task
= (start_binding_task_t
*)_task
;
737 start_binding(NULL
, task
->doc
, (BSCallback
*)task
->bscallback
, NULL
);
743 nsChannelBSC
*bscallback
;
744 } start_doc_binding_task_t
;
746 static void start_doc_binding_proc(task_t
*_task
)
748 start_doc_binding_task_t
*task
= (start_doc_binding_task_t
*)_task
;
750 start_binding(task
->window
, NULL
, (BSCallback
*)task
->bscallback
, NULL
);
751 IUnknown_Release((IUnknown
*)task
->bscallback
);
754 static nsresult
async_open(nsChannel
*This
, HTMLWindow
*window
, BOOL is_doc_channel
, nsIStreamListener
*listener
,
755 nsISupports
*context
)
757 nsChannelBSC
*bscallback
;
758 IMoniker
*mon
= NULL
;
761 hres
= create_mon_for_nschannel(This
, &mon
);
763 return NS_ERROR_UNEXPECTED
;
766 set_current_mon(window
, mon
);
768 bscallback
= create_channelbsc(mon
);
769 IMoniker_Release(mon
);
771 channelbsc_set_channel(bscallback
, This
, listener
, context
);
774 start_doc_binding_task_t
*task
;
776 set_window_bscallback(window
, bscallback
);
778 task
= heap_alloc(sizeof(start_doc_binding_task_t
));
779 task
->window
= window
;
780 task
->bscallback
= bscallback
;
781 push_task(&task
->header
, start_doc_binding_proc
, window
->task_magic
);
783 start_binding_task_t
*task
= heap_alloc(sizeof(start_binding_task_t
));
785 task
->doc
= window
->doc
;
786 task
->bscallback
= bscallback
;
787 push_task(&task
->header
, start_binding_proc
, window
->doc
->basedoc
.task_magic
);
793 static nsresult NSAPI
nsChannel_AsyncOpen(nsIHttpChannel
*iface
, nsIStreamListener
*aListener
,
794 nsISupports
*aContext
)
796 nsChannel
*This
= NSCHANNEL_THIS(iface
);
797 HTMLWindow
*window
= NULL
;
800 nsresult nsres
= NS_OK
;
802 TRACE("(%p)->(%p %p)\n", This
, aListener
, aContext
);
804 if(TRACE_ON(mshtml
)) {
807 nsIWineURI_GetWineURL(This
->uri
, &url
);
808 TRACE("opening %s\n", debugstr_w(url
));
811 nsIWineURI_GetIsDocumentURI(This
->uri
, &is_doc_uri
);
813 window
= get_channel_window(This
);
815 nsIWineURI_SetWindow(This
->uri
, window
);
817 NSContainer
*nscontainer
;
819 nsIWineURI_GetNSContainer(This
->uri
, &nscontainer
);
823 /* nscontainer->doc should be NULL which means navigation to a new window */
825 FIXME("nscontainer->doc = %p\n", nscontainer
->doc
);
827 b
= before_async_open(This
, nscontainer
);
828 nsIWebBrowserChrome_Release(NSWBCHROME(nscontainer
));
830 FIXME("Navigation not cancelled\n");
831 return NS_ERROR_UNEXPECTED
;
837 nsIWineURI_GetWindow(This
->uri
, &window
);
839 if(!window
&& This
->load_group
) {
840 window
= get_window_from_load_group(This
);
842 nsIWineURI_SetWindow(This
->uri
, window
);
847 TRACE("window = NULL\n");
849 ? nsIChannel_AsyncOpen(This
->channel
, aListener
, aContext
)
850 : NS_ERROR_UNEXPECTED
;
853 if(is_doc_uri
&& (This
->load_flags
& LOAD_INITIAL_DOCUMENT_URI
)) {
854 if(window
->doc_obj
->nscontainer
->bscallback
) {
855 NSContainer
*nscontainer
= window
->doc_obj
->nscontainer
;
857 channelbsc_set_channel(nscontainer
->bscallback
, This
, aListener
, aContext
);
859 if(nscontainer
->doc
->mime
) {
860 heap_free(This
->content_type
);
861 This
->content_type
= heap_strdupWtoA(nscontainer
->doc
->mime
);
866 open
= before_async_open(This
, window
->doc_obj
->nscontainer
);
869 nsres
= NS_ERROR_UNEXPECTED
;
875 nsres
= async_open(This
, window
, is_doc_uri
, aListener
, aContext
);
878 IHTMLWindow2_Release(HTMLWINDOW2(window
));
882 static nsresult NSAPI
nsChannel_GetRequestMethod(nsIHttpChannel
*iface
, nsACString
*aRequestMethod
)
884 nsChannel
*This
= NSCHANNEL_THIS(iface
);
886 TRACE("(%p)->(%p)\n", This
, aRequestMethod
);
888 if(This
->http_channel
)
889 return nsIHttpChannel_GetRequestMethod(This
->http_channel
, aRequestMethod
);
891 return NS_ERROR_NOT_IMPLEMENTED
;
894 static nsresult NSAPI
nsChannel_SetRequestMethod(nsIHttpChannel
*iface
,
895 const nsACString
*aRequestMethod
)
897 nsChannel
*This
= NSCHANNEL_THIS(iface
);
899 TRACE("(%p)->(%p)\n", This
, aRequestMethod
);
901 if(This
->http_channel
)
902 return nsIHttpChannel_SetRequestMethod(This
->http_channel
, aRequestMethod
);
904 return NS_ERROR_NOT_IMPLEMENTED
;
907 static nsresult NSAPI
nsChannel_GetReferrer(nsIHttpChannel
*iface
, nsIURI
**aReferrer
)
909 nsChannel
*This
= NSCHANNEL_THIS(iface
);
911 TRACE("(%p)->(%p)\n", This
, aReferrer
);
913 if(This
->http_channel
)
914 return nsIHttpChannel_GetReferrer(This
->http_channel
, aReferrer
);
916 return NS_ERROR_NOT_IMPLEMENTED
;
919 static nsresult NSAPI
nsChannel_SetReferrer(nsIHttpChannel
*iface
, nsIURI
*aReferrer
)
921 nsChannel
*This
= NSCHANNEL_THIS(iface
);
923 TRACE("(%p)->(%p)\n", This
, aReferrer
);
925 if(This
->http_channel
)
926 return nsIHttpChannel_SetReferrer(This
->http_channel
, aReferrer
);
928 return NS_ERROR_NOT_IMPLEMENTED
;
931 static nsresult NSAPI
nsChannel_GetRequestHeader(nsIHttpChannel
*iface
,
932 const nsACString
*aHeader
, nsACString
*_retval
)
934 nsChannel
*This
= NSCHANNEL_THIS(iface
);
936 TRACE("(%p)->(%p %p)\n", This
, aHeader
, _retval
);
938 if(This
->http_channel
)
939 return nsIHttpChannel_GetRequestHeader(This
->http_channel
, aHeader
, _retval
);
941 return NS_ERROR_NOT_IMPLEMENTED
;
944 static nsresult NSAPI
nsChannel_SetRequestHeader(nsIHttpChannel
*iface
,
945 const nsACString
*aHeader
, const nsACString
*aValue
, PRBool aMerge
)
947 nsChannel
*This
= NSCHANNEL_THIS(iface
);
949 TRACE("(%p)->(%p %p %x)\n", This
, aHeader
, aValue
, aMerge
);
951 if(This
->http_channel
)
952 return nsIHttpChannel_SetRequestHeader(This
->http_channel
, aHeader
, aValue
, aMerge
);
954 return NS_ERROR_NOT_IMPLEMENTED
;
957 static nsresult NSAPI
nsChannel_VisitRequestHeaders(nsIHttpChannel
*iface
,
958 nsIHttpHeaderVisitor
*aVisitor
)
960 nsChannel
*This
= NSCHANNEL_THIS(iface
);
962 TRACE("(%p)->(%p)\n", This
, aVisitor
);
964 if(This
->http_channel
)
965 return nsIHttpChannel_VisitRequestHeaders(This
->http_channel
, aVisitor
);
967 return NS_ERROR_NOT_IMPLEMENTED
;
970 static nsresult NSAPI
nsChannel_GetAllowPipelining(nsIHttpChannel
*iface
, PRBool
*aAllowPipelining
)
972 nsChannel
*This
= NSCHANNEL_THIS(iface
);
974 TRACE("(%p)->(%p)\n", This
, aAllowPipelining
);
976 if(This
->http_channel
)
977 return nsIHttpChannel_GetAllowPipelining(This
->http_channel
, aAllowPipelining
);
979 return NS_ERROR_NOT_IMPLEMENTED
;
982 static nsresult NSAPI
nsChannel_SetAllowPipelining(nsIHttpChannel
*iface
, PRBool aAllowPipelining
)
984 nsChannel
*This
= NSCHANNEL_THIS(iface
);
986 TRACE("(%p)->(%x)\n", This
, aAllowPipelining
);
988 if(This
->http_channel
)
989 return nsIHttpChannel_SetAllowPipelining(This
->http_channel
, aAllowPipelining
);
991 return NS_ERROR_NOT_IMPLEMENTED
;
994 static nsresult NSAPI
nsChannel_GetRedirectionLimit(nsIHttpChannel
*iface
, PRUint32
*aRedirectionLimit
)
996 nsChannel
*This
= NSCHANNEL_THIS(iface
);
998 TRACE("(%p)->(%p)\n", This
, aRedirectionLimit
);
1000 if(This
->http_channel
)
1001 return nsIHttpChannel_GetRedirectionLimit(This
->http_channel
, aRedirectionLimit
);
1003 return NS_ERROR_NOT_IMPLEMENTED
;
1006 static nsresult NSAPI
nsChannel_SetRedirectionLimit(nsIHttpChannel
*iface
, PRUint32 aRedirectionLimit
)
1008 nsChannel
*This
= NSCHANNEL_THIS(iface
);
1010 TRACE("(%p)->(%u)\n", This
, aRedirectionLimit
);
1012 if(This
->http_channel
)
1013 return nsIHttpChannel_SetRedirectionLimit(This
->http_channel
, aRedirectionLimit
);
1015 return NS_ERROR_NOT_IMPLEMENTED
;
1018 static nsresult NSAPI
nsChannel_GetResponseStatus(nsIHttpChannel
*iface
, PRUint32
*aResponseStatus
)
1020 nsChannel
*This
= NSCHANNEL_THIS(iface
);
1022 TRACE("(%p)->(%p)\n", This
, aResponseStatus
);
1024 if(This
->response_status
) {
1025 *aResponseStatus
= This
->response_status
;
1029 if(This
->http_channel
)
1030 return nsIHttpChannel_GetResponseStatus(This
->http_channel
, aResponseStatus
);
1032 return NS_ERROR_UNEXPECTED
;
1035 static nsresult NSAPI
nsChannel_GetResponseStatusText(nsIHttpChannel
*iface
,
1036 nsACString
*aResponseStatusText
)
1038 nsChannel
*This
= NSCHANNEL_THIS(iface
);
1040 TRACE("(%p)->(%p)\n", This
, aResponseStatusText
);
1042 if(This
->http_channel
)
1043 return nsIHttpChannel_GetResponseStatusText(This
->http_channel
, aResponseStatusText
);
1045 return NS_ERROR_NOT_IMPLEMENTED
;
1048 static nsresult NSAPI
nsChannel_GetRequestSucceeded(nsIHttpChannel
*iface
,
1049 PRBool
*aRequestSucceeded
)
1051 nsChannel
*This
= NSCHANNEL_THIS(iface
);
1053 TRACE("(%p)->(%p)\n", This
, aRequestSucceeded
);
1055 if(This
->http_channel
)
1056 return nsIHttpChannel_GetRequestSucceeded(This
->http_channel
, aRequestSucceeded
);
1058 return NS_ERROR_NOT_IMPLEMENTED
;
1061 static nsresult NSAPI
nsChannel_GetResponseHeader(nsIHttpChannel
*iface
,
1062 const nsACString
*header
, nsACString
*_retval
)
1064 nsChannel
*This
= NSCHANNEL_THIS(iface
);
1066 TRACE("(%p)->(%p %p)\n", This
, header
, _retval
);
1068 if(This
->http_channel
)
1069 return nsIHttpChannel_GetResponseHeader(This
->http_channel
, header
, _retval
);
1071 return NS_ERROR_NOT_IMPLEMENTED
;
1074 static nsresult NSAPI
nsChannel_SetResponseHeader(nsIHttpChannel
*iface
,
1075 const nsACString
*header
, const nsACString
*value
, PRBool merge
)
1077 nsChannel
*This
= NSCHANNEL_THIS(iface
);
1079 TRACE("(%p)->(%p %p %x)\n", This
, header
, value
, merge
);
1081 if(This
->http_channel
)
1082 return nsIHttpChannel_SetResponseHeader(This
->http_channel
, header
, value
, merge
);
1084 return NS_ERROR_NOT_IMPLEMENTED
;
1087 static nsresult NSAPI
nsChannel_VisitResponseHeaders(nsIHttpChannel
*iface
,
1088 nsIHttpHeaderVisitor
*aVisitor
)
1090 nsChannel
*This
= NSCHANNEL_THIS(iface
);
1092 TRACE("(%p)->(%p)\n", This
, aVisitor
);
1094 if(This
->http_channel
)
1095 return nsIHttpChannel_VisitResponseHeaders(This
->http_channel
, aVisitor
);
1097 return NS_ERROR_NOT_IMPLEMENTED
;
1100 static nsresult NSAPI
nsChannel_IsNoStoreResponse(nsIHttpChannel
*iface
, PRBool
*_retval
)
1102 nsChannel
*This
= NSCHANNEL_THIS(iface
);
1104 TRACE("(%p)->(%p)\n", This
, _retval
);
1106 if(This
->http_channel
)
1107 return nsIHttpChannel_IsNoStoreResponse(This
->http_channel
, _retval
);
1109 return NS_ERROR_NOT_IMPLEMENTED
;
1112 static nsresult NSAPI
nsChannel_IsNoCacheResponse(nsIHttpChannel
*iface
, PRBool
*_retval
)
1114 nsChannel
*This
= NSCHANNEL_THIS(iface
);
1116 TRACE("(%p)->(%p)\n", This
, _retval
);
1118 if(This
->http_channel
)
1119 return nsIHttpChannel_IsNoCacheResponse(This
->http_channel
, _retval
);
1121 return NS_ERROR_NOT_IMPLEMENTED
;
1124 #undef NSCHANNEL_THIS
1126 static const nsIHttpChannelVtbl nsChannelVtbl
= {
1127 nsChannel_QueryInterface
,
1131 nsChannel_IsPending
,
1132 nsChannel_GetStatus
,
1136 nsChannel_GetLoadGroup
,
1137 nsChannel_SetLoadGroup
,
1138 nsChannel_GetLoadFlags
,
1139 nsChannel_SetLoadFlags
,
1140 nsChannel_GetOriginalURI
,
1141 nsChannel_SetOriginalURI
,
1145 nsChannel_GetNotificationCallbacks
,
1146 nsChannel_SetNotificationCallbacks
,
1147 nsChannel_GetSecurityInfo
,
1148 nsChannel_GetContentType
,
1149 nsChannel_SetContentType
,
1150 nsChannel_GetContentCharset
,
1151 nsChannel_SetContentCharset
,
1152 nsChannel_GetContentLength
,
1153 nsChannel_SetContentLength
,
1155 nsChannel_AsyncOpen
,
1156 nsChannel_GetRequestMethod
,
1157 nsChannel_SetRequestMethod
,
1158 nsChannel_GetReferrer
,
1159 nsChannel_SetReferrer
,
1160 nsChannel_GetRequestHeader
,
1161 nsChannel_SetRequestHeader
,
1162 nsChannel_VisitRequestHeaders
,
1163 nsChannel_GetAllowPipelining
,
1164 nsChannel_SetAllowPipelining
,
1165 nsChannel_GetRedirectionLimit
,
1166 nsChannel_SetRedirectionLimit
,
1167 nsChannel_GetResponseStatus
,
1168 nsChannel_GetResponseStatusText
,
1169 nsChannel_GetRequestSucceeded
,
1170 nsChannel_GetResponseHeader
,
1171 nsChannel_SetResponseHeader
,
1172 nsChannel_VisitResponseHeaders
,
1173 nsChannel_IsNoStoreResponse
,
1174 nsChannel_IsNoCacheResponse
1177 #define NSUPCHANNEL_THIS(iface) DEFINE_THIS(nsChannel, UploadChannel, iface)
1179 static nsresult NSAPI
nsUploadChannel_QueryInterface(nsIUploadChannel
*iface
, nsIIDRef riid
,
1182 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1183 return nsIChannel_QueryInterface(NSCHANNEL(This
), riid
, result
);
1186 static nsrefcnt NSAPI
nsUploadChannel_AddRef(nsIUploadChannel
*iface
)
1188 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1189 return nsIChannel_AddRef(NSCHANNEL(This
));
1192 static nsrefcnt NSAPI
nsUploadChannel_Release(nsIUploadChannel
*iface
)
1194 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1195 return nsIChannel_Release(NSCHANNEL(This
));
1198 static nsresult NSAPI
nsUploadChannel_SetUploadStream(nsIUploadChannel
*iface
,
1199 nsIInputStream
*aStream
, const nsACString
*aContentType
, PRInt32 aContentLength
)
1201 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1202 const char *content_type
;
1205 TRACE("(%p)->(%p %p %d)\n", This
, aStream
, aContentType
, aContentLength
);
1207 if(This
->post_data_stream
)
1208 nsIInputStream_Release(This
->post_data_stream
);
1211 nsACString_GetData(aContentType
, &content_type
);
1213 FIXME("Unsupported aContentType argument: %s\n", debugstr_a(content_type
));
1216 if(aContentLength
!= -1)
1217 FIXME("Unsupported acontentLength = %d\n", aContentLength
);
1219 if(This
->post_data_stream
)
1220 nsIInputStream_Release(This
->post_data_stream
);
1221 This
->post_data_stream
= aStream
;
1223 nsIInputStream_AddRef(aStream
);
1225 if(This
->post_data_stream
) {
1226 nsIUploadChannel
*upload_channel
;
1228 nsres
= nsIChannel_QueryInterface(This
->channel
, &IID_nsIUploadChannel
,
1229 (void**)&upload_channel
);
1230 if(NS_SUCCEEDED(nsres
)) {
1231 nsres
= nsIUploadChannel_SetUploadStream(upload_channel
, aStream
, aContentType
, aContentLength
);
1232 nsIUploadChannel_Release(upload_channel
);
1233 if(NS_FAILED(nsres
))
1234 WARN("SetUploadStream failed: %08x\n", nsres
);
1242 static nsresult NSAPI
nsUploadChannel_GetUploadStream(nsIUploadChannel
*iface
,
1243 nsIInputStream
**aUploadStream
)
1245 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1247 TRACE("(%p)->(%p)\n", This
, aUploadStream
);
1249 if(This
->post_data_stream
)
1250 nsIInputStream_AddRef(This
->post_data_stream
);
1252 *aUploadStream
= This
->post_data_stream
;
1256 #undef NSUPCHANNEL_THIS
1258 static const nsIUploadChannelVtbl nsUploadChannelVtbl
= {
1259 nsUploadChannel_QueryInterface
,
1260 nsUploadChannel_AddRef
,
1261 nsUploadChannel_Release
,
1262 nsUploadChannel_SetUploadStream
,
1263 nsUploadChannel_GetUploadStream
1266 #define NSHTTPINTERNAL_THIS(iface) DEFINE_THIS(nsChannel, IHttpChannelInternal, iface)
1268 static nsresult NSAPI
nsHttpChannelInternal_QueryInterface(nsIHttpChannelInternal
*iface
, nsIIDRef riid
,
1271 nsChannel
*This
= NSHTTPINTERNAL_THIS(iface
);
1272 return nsIChannel_QueryInterface(NSCHANNEL(This
), riid
, result
);
1275 static nsrefcnt NSAPI
nsHttpChannelInternal_AddRef(nsIHttpChannelInternal
*iface
)
1277 nsChannel
*This
= NSHTTPINTERNAL_THIS(iface
);
1278 return nsIChannel_AddRef(NSCHANNEL(This
));
1281 static nsrefcnt NSAPI
nsHttpChannelInternal_Release(nsIHttpChannelInternal
*iface
)
1283 nsChannel
*This
= NSHTTPINTERNAL_THIS(iface
);
1284 return nsIChannel_Release(NSCHANNEL(This
));
1287 static nsresult NSAPI
nsHttpChannelInternal_GetDocumentURI(nsIHttpChannelInternal
*iface
, nsIURI
**aDocumentURI
)
1289 nsChannel
*This
= NSHTTPINTERNAL_THIS(iface
);
1291 TRACE("(%p)->()\n", This
);
1293 if(This
->http_channel_internal
)
1294 return nsIHttpChannelInternal_GetDocumentURI(This
->http_channel_internal
, aDocumentURI
);
1295 return NS_ERROR_NOT_IMPLEMENTED
;
1298 static nsresult NSAPI
nsHttpChannelInternal_SetDocumentURI(nsIHttpChannelInternal
*iface
, nsIURI
*aDocumentURI
)
1300 nsChannel
*This
= NSHTTPINTERNAL_THIS(iface
);
1302 TRACE("(%p)->()\n", This
);
1304 if(This
->http_channel_internal
)
1305 return nsIHttpChannelInternal_SetDocumentURI(This
->http_channel_internal
, aDocumentURI
);
1306 return NS_ERROR_NOT_IMPLEMENTED
;
1309 static nsresult NSAPI
nsHttpChannelInternal_GetRequestVersion(nsIHttpChannelInternal
*iface
, PRUint32
*major
, PRUint32
*minor
)
1311 nsChannel
*This
= NSHTTPINTERNAL_THIS(iface
);
1313 TRACE("(%p)->()\n", This
);
1315 if(This
->http_channel_internal
)
1316 return nsIHttpChannelInternal_GetRequestVersion(This
->http_channel_internal
, major
, minor
);
1317 return NS_ERROR_NOT_IMPLEMENTED
;
1320 static nsresult NSAPI
nsHttpChannelInternal_GetResponseVersion(nsIHttpChannelInternal
*iface
, PRUint32
*major
, PRUint32
*minor
)
1322 nsChannel
*This
= NSHTTPINTERNAL_THIS(iface
);
1324 TRACE("(%p)->()\n", This
);
1326 if(This
->http_channel_internal
)
1327 return nsIHttpChannelInternal_GetResponseVersion(This
->http_channel_internal
, major
, minor
);
1328 return NS_ERROR_NOT_IMPLEMENTED
;
1331 static nsresult NSAPI
nsHttpChannelInternal_SetCookie(nsIHttpChannelInternal
*iface
, const char *aCookieHeader
)
1333 nsChannel
*This
= NSHTTPINTERNAL_THIS(iface
);
1335 TRACE("(%p)->()\n", This
);
1337 if(This
->http_channel_internal
)
1338 return nsIHttpChannelInternal_SetCookie(This
->http_channel_internal
, aCookieHeader
);
1339 return NS_ERROR_NOT_IMPLEMENTED
;
1342 static nsresult NSAPI
nsHttpChannelInternal_SetupFallbackChannel(nsIHttpChannelInternal
*iface
, const char *aFallbackKey
)
1344 nsChannel
*This
= NSHTTPINTERNAL_THIS(iface
);
1346 TRACE("(%p)->()\n", This
);
1348 if(This
->http_channel_internal
)
1349 return nsIHttpChannelInternal_SetupFallbackChannel(This
->http_channel_internal
, aFallbackKey
);
1350 return NS_ERROR_NOT_IMPLEMENTED
;
1353 static nsresult NSAPI
nsHttpChannelInternal_GetForceAllowThirdPartyCookie(nsIHttpChannelInternal
*iface
, PRBool
*aForceThirdPartyCookie
)
1355 nsChannel
*This
= NSHTTPINTERNAL_THIS(iface
);
1357 TRACE("(%p)->()\n", This
);
1359 if(This
->http_channel_internal
)
1360 return nsIHttpChannelInternal_GetForceAllowThirdPartyCookie(This
->http_channel_internal
, aForceThirdPartyCookie
);
1361 return NS_ERROR_NOT_IMPLEMENTED
;
1364 static nsresult NSAPI
nsHttpChannelInternal_SetForceAllowThirdPartyCookie(nsIHttpChannelInternal
*iface
, PRBool aForceThirdPartyCookie
)
1366 nsChannel
*This
= NSHTTPINTERNAL_THIS(iface
);
1368 TRACE("(%p)->()\n", This
);
1370 if(This
->http_channel_internal
)
1371 return nsIHttpChannelInternal_SetForceAllowThirdPartyCookie(This
->http_channel_internal
, aForceThirdPartyCookie
);
1372 return NS_ERROR_NOT_IMPLEMENTED
;
1375 #undef NSHTTPINTERNAL_THIS
1377 static const nsIHttpChannelInternalVtbl nsHttpChannelInternalVtbl
= {
1378 nsHttpChannelInternal_QueryInterface
,
1379 nsHttpChannelInternal_AddRef
,
1380 nsHttpChannelInternal_Release
,
1381 nsHttpChannelInternal_GetDocumentURI
,
1382 nsHttpChannelInternal_SetDocumentURI
,
1383 nsHttpChannelInternal_GetRequestVersion
,
1384 nsHttpChannelInternal_GetResponseVersion
,
1385 nsHttpChannelInternal_SetCookie
,
1386 nsHttpChannelInternal_SetupFallbackChannel
,
1387 nsHttpChannelInternal_GetForceAllowThirdPartyCookie
,
1388 nsHttpChannelInternal_SetForceAllowThirdPartyCookie
1391 #define NSURI_THIS(iface) DEFINE_THIS(nsURI, WineURI, iface)
1393 static nsresult NSAPI
nsURI_QueryInterface(nsIWineURI
*iface
, nsIIDRef riid
, nsQIResult result
)
1395 nsURI
*This
= NSURI_THIS(iface
);
1399 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
1400 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
1401 *result
= NSURI(This
);
1402 }else if(IsEqualGUID(&IID_nsIURI
, riid
)) {
1403 TRACE("(%p)->(IID_nsIURI %p)\n", This
, result
);
1404 *result
= NSURI(This
);
1405 }else if(IsEqualGUID(&IID_nsIURL
, riid
)) {
1406 TRACE("(%p)->(IID_nsIURL %p)\n", This
, result
);
1407 *result
= NSURI(This
);
1408 }else if(IsEqualGUID(&IID_nsIWineURI
, riid
)) {
1409 TRACE("(%p)->(IID_nsIWineURI %p)\n", This
, result
);
1410 *result
= NSURI(This
);
1414 nsIURI_AddRef(NSURI(This
));
1418 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), result
);
1419 return This
->uri
? nsIURI_QueryInterface(This
->uri
, riid
, result
) : NS_NOINTERFACE
;
1422 static nsrefcnt NSAPI
nsURI_AddRef(nsIWineURI
*iface
)
1424 nsURI
*This
= NSURI_THIS(iface
);
1425 LONG ref
= InterlockedIncrement(&This
->ref
);
1427 TRACE("(%p) ref=%d\n", This
, ref
);
1432 static nsrefcnt NSAPI
nsURI_Release(nsIWineURI
*iface
)
1434 nsURI
*This
= NSURI_THIS(iface
);
1435 LONG ref
= InterlockedDecrement(&This
->ref
);
1437 TRACE("(%p) ref=%d\n", This
, ref
);
1440 if(This
->window_ref
)
1441 windowref_release(This
->window_ref
);
1443 nsIWebBrowserChrome_Release(NSWBCHROME(This
->container
));
1445 nsIURL_Release(This
->nsurl
);
1447 nsIURI_Release(This
->uri
);
1448 heap_free(This
->wine_url
);
1455 static nsresult NSAPI
nsURI_GetSpec(nsIWineURI
*iface
, nsACString
*aSpec
)
1457 nsURI
*This
= NSURI_THIS(iface
);
1459 TRACE("(%p)->(%p)\n", This
, aSpec
);
1461 if(This
->use_wine_url
) {
1462 char speca
[INTERNET_MAX_URL_LENGTH
] = "wine:";
1463 WideCharToMultiByte(CP_ACP
, 0, This
->wine_url
, -1, speca
+5, sizeof(speca
)-5, NULL
, NULL
);
1464 nsACString_SetData(aSpec
, speca
);
1470 return nsIURI_GetSpec(This
->uri
, aSpec
);
1472 TRACE("returning error\n");
1473 return NS_ERROR_NOT_IMPLEMENTED
;
1477 static nsresult NSAPI
nsURI_SetSpec(nsIWineURI
*iface
, const nsACString
*aSpec
)
1479 nsURI
*This
= NSURI_THIS(iface
);
1481 TRACE("(%p)->(%p)\n", This
, aSpec
);
1484 return nsIURI_SetSpec(This
->uri
, aSpec
);
1486 FIXME("default action not implemented\n");
1487 return NS_ERROR_NOT_IMPLEMENTED
;
1490 static nsresult NSAPI
nsURI_GetPrePath(nsIWineURI
*iface
, nsACString
*aPrePath
)
1492 nsURI
*This
= NSURI_THIS(iface
);
1494 TRACE("(%p)->(%p)\n", This
, aPrePath
);
1497 return nsIURI_GetPrePath(This
->uri
, aPrePath
);
1499 FIXME("default action not implemented\n");
1500 return NS_ERROR_NOT_IMPLEMENTED
;
1503 static nsresult NSAPI
nsURI_GetScheme(nsIWineURI
*iface
, nsACString
*aScheme
)
1505 nsURI
*This
= NSURI_THIS(iface
);
1507 TRACE("(%p)->(%p)\n", This
, aScheme
);
1509 if(This
->use_wine_url
&& strcmpW(This
->wine_url
, about_blankW
)) {
1511 * For Gecko we set scheme to unknown so it won't be handled
1512 * as any special case.
1514 nsACString_SetData(aScheme
, "wine");
1519 return nsIURI_GetScheme(This
->uri
, aScheme
);
1521 TRACE("returning error\n");
1522 return NS_ERROR_NOT_IMPLEMENTED
;
1525 static nsresult NSAPI
nsURI_SetScheme(nsIWineURI
*iface
, const nsACString
*aScheme
)
1527 nsURI
*This
= NSURI_THIS(iface
);
1529 TRACE("(%p)->(%p)\n", This
, aScheme
);
1532 return nsIURI_SetScheme(This
->uri
, aScheme
);
1534 FIXME("default action not implemented\n");
1535 return NS_ERROR_NOT_IMPLEMENTED
;
1538 static nsresult NSAPI
nsURI_GetUserPass(nsIWineURI
*iface
, nsACString
*aUserPass
)
1540 nsURI
*This
= NSURI_THIS(iface
);
1542 TRACE("(%p)->(%p)\n", This
, aUserPass
);
1545 return nsIURI_GetUserPass(This
->uri
, aUserPass
);
1547 FIXME("default action not implemented\n");
1548 return NS_ERROR_NOT_IMPLEMENTED
;
1551 static nsresult NSAPI
nsURI_SetUserPass(nsIWineURI
*iface
, const nsACString
*aUserPass
)
1553 nsURI
*This
= NSURI_THIS(iface
);
1555 TRACE("(%p)->(%p)\n", This
, aUserPass
);
1558 return nsIURI_SetUserPass(This
->uri
, aUserPass
);
1560 FIXME("default action not implemented\n");
1561 return NS_ERROR_NOT_IMPLEMENTED
;
1564 static nsresult NSAPI
nsURI_GetUsername(nsIWineURI
*iface
, nsACString
*aUsername
)
1566 nsURI
*This
= NSURI_THIS(iface
);
1568 TRACE("(%p)->(%p)\n", This
, aUsername
);
1571 return nsIURI_GetUsername(This
->uri
, aUsername
);
1573 FIXME("default action not implemented\n");
1574 return NS_ERROR_NOT_IMPLEMENTED
;
1577 static nsresult NSAPI
nsURI_SetUsername(nsIWineURI
*iface
, const nsACString
*aUsername
)
1579 nsURI
*This
= NSURI_THIS(iface
);
1581 TRACE("(%p)->(%p)\n", This
, aUsername
);
1584 return nsIURI_SetUsername(This
->uri
, aUsername
);
1586 FIXME("default action not implemented\n");
1587 return NS_ERROR_NOT_IMPLEMENTED
;
1590 static nsresult NSAPI
nsURI_GetPassword(nsIWineURI
*iface
, nsACString
*aPassword
)
1592 nsURI
*This
= NSURI_THIS(iface
);
1594 TRACE("(%p)->(%p)\n", This
, aPassword
);
1597 return nsIURI_GetPassword(This
->uri
, aPassword
);
1599 FIXME("default action not implemented\n");
1600 return NS_ERROR_NOT_IMPLEMENTED
;
1603 static nsresult NSAPI
nsURI_SetPassword(nsIWineURI
*iface
, const nsACString
*aPassword
)
1605 nsURI
*This
= NSURI_THIS(iface
);
1607 TRACE("(%p)->(%p)\n", This
, aPassword
);
1610 return nsIURI_SetPassword(This
->uri
, aPassword
);
1612 FIXME("default action not implemented\n");
1613 return NS_ERROR_NOT_IMPLEMENTED
;
1616 static nsresult NSAPI
nsURI_GetHostPort(nsIWineURI
*iface
, nsACString
*aHostPort
)
1618 nsURI
*This
= NSURI_THIS(iface
);
1620 TRACE("(%p)->(%p)\n", This
, aHostPort
);
1623 return nsIURI_GetHostPort(This
->uri
, aHostPort
);
1625 FIXME("default action not implemented\n");
1626 return NS_ERROR_NOT_IMPLEMENTED
;
1629 static nsresult NSAPI
nsURI_SetHostPort(nsIWineURI
*iface
, const nsACString
*aHostPort
)
1631 nsURI
*This
= NSURI_THIS(iface
);
1633 TRACE("(%p)->(%p)\n", This
, aHostPort
);
1636 return nsIURI_SetHostPort(This
->uri
, aHostPort
);
1638 FIXME("default action not implemented\n");
1639 return NS_ERROR_NOT_IMPLEMENTED
;
1642 static nsresult NSAPI
nsURI_GetHost(nsIWineURI
*iface
, nsACString
*aHost
)
1644 nsURI
*This
= NSURI_THIS(iface
);
1646 TRACE("(%p)->(%p)\n", This
, aHost
);
1649 return nsIURI_GetHost(This
->uri
, aHost
);
1651 FIXME("default action not implemented\n");
1652 return NS_ERROR_NOT_IMPLEMENTED
;
1655 static nsresult NSAPI
nsURI_SetHost(nsIWineURI
*iface
, const nsACString
*aHost
)
1657 nsURI
*This
= NSURI_THIS(iface
);
1659 TRACE("(%p)->(%p)\n", This
, aHost
);
1662 return nsIURI_SetHost(This
->uri
, aHost
);
1664 FIXME("default action not implemented\n");
1665 return NS_ERROR_NOT_IMPLEMENTED
;
1668 static nsresult NSAPI
nsURI_GetPort(nsIWineURI
*iface
, PRInt32
*aPort
)
1670 nsURI
*This
= NSURI_THIS(iface
);
1672 TRACE("(%p)->(%p)\n", This
, aPort
);
1675 return nsIURI_GetPort(This
->uri
, aPort
);
1677 FIXME("default action not implemented\n");
1678 return NS_ERROR_NOT_IMPLEMENTED
;
1681 static nsresult NSAPI
nsURI_SetPort(nsIWineURI
*iface
, PRInt32 aPort
)
1683 nsURI
*This
= NSURI_THIS(iface
);
1685 TRACE("(%p)->(%d)\n", This
, aPort
);
1688 return nsIURI_SetPort(This
->uri
, aPort
);
1690 FIXME("default action not implemented\n");
1691 return NS_ERROR_NOT_IMPLEMENTED
;
1694 static nsresult NSAPI
nsURI_GetPath(nsIWineURI
*iface
, nsACString
*aPath
)
1696 nsURI
*This
= NSURI_THIS(iface
);
1698 TRACE("(%p)->(%p)\n", This
, aPath
);
1701 return nsIURI_GetPath(This
->uri
, aPath
);
1703 FIXME("default action not implemented\n");
1704 return NS_ERROR_NOT_IMPLEMENTED
;
1707 static nsresult NSAPI
nsURI_SetPath(nsIWineURI
*iface
, const nsACString
*aPath
)
1709 nsURI
*This
= NSURI_THIS(iface
);
1712 nsACString_GetData(aPath
, &path
);
1713 TRACE("(%p)->(%p(%s))\n", This
, aPath
, debugstr_a(path
));
1716 if(This
->wine_url
) {
1717 WCHAR new_url
[INTERNET_MAX_URL_LENGTH
];
1718 DWORD size
= sizeof(new_url
)/sizeof(WCHAR
);
1722 pathw
= heap_strdupAtoW(path
);
1723 hres
= UrlCombineW(This
->wine_url
, pathw
, new_url
, &size
, 0);
1726 nsIWineURI_SetWineURL(NSWINEURI(This
), new_url
);
1728 WARN("UrlCombine failed: %08x\n", hres
);
1734 return nsIURI_SetPath(This
->uri
, aPath
);
1737 static nsresult NSAPI
nsURI_Equals(nsIWineURI
*iface
, nsIURI
*other
, PRBool
*_retval
)
1739 nsURI
*This
= NSURI_THIS(iface
);
1740 nsIWineURI
*wine_uri
;
1741 LPCWSTR other_url
= NULL
;
1744 TRACE("(%p)->(%p %p)\n", This
, other
, _retval
);
1747 return nsIURI_Equals(This
->uri
, other
, _retval
);
1749 nsres
= nsIURI_QueryInterface(other
, &IID_nsIWineURI
, (void**)&wine_uri
);
1750 if(NS_FAILED(nsres
)) {
1751 TRACE("Could not get nsIWineURI interface\n");
1756 nsIWineURI_GetWineURL(wine_uri
, &other_url
);
1757 *_retval
= other_url
&& !UrlCompareW(This
->wine_url
, other_url
, TRUE
);
1758 nsIWineURI_Release(wine_uri
);
1763 static nsresult NSAPI
nsURI_SchemeIs(nsIWineURI
*iface
, const char *scheme
, PRBool
*_retval
)
1765 nsURI
*This
= NSURI_THIS(iface
);
1767 TRACE("(%p)->(%s %p)\n", This
, debugstr_a(scheme
), _retval
);
1769 if(This
->use_wine_url
) {
1770 WCHAR buf
[INTERNET_MAX_SCHEME_LENGTH
];
1771 int len
= MultiByteToWideChar(CP_ACP
, 0, scheme
, -1, buf
, sizeof(buf
)/sizeof(WCHAR
))-1;
1773 *_retval
= lstrlenW(This
->wine_url
) > len
1774 && This
->wine_url
[len
] == ':'
1775 && !memcmp(buf
, This
->wine_url
, len
*sizeof(WCHAR
));
1780 return nsIURI_SchemeIs(This
->uri
, scheme
, _retval
);
1782 TRACE("returning error\n");
1783 return NS_ERROR_NOT_IMPLEMENTED
;
1786 static nsresult NSAPI
nsURI_Clone(nsIWineURI
*iface
, nsIURI
**_retval
)
1788 nsURI
*This
= NSURI_THIS(iface
);
1789 nsIURI
*nsuri
= NULL
;
1790 nsIWineURI
*wine_uri
;
1793 TRACE("(%p)->(%p)\n", This
, _retval
);
1796 nsres
= nsIURI_Clone(This
->uri
, &nsuri
);
1797 if(NS_FAILED(nsres
)) {
1798 WARN("Clone failed: %08x\n", nsres
);
1803 nsres
= create_uri(nsuri
, This
->window_ref
? This
->window_ref
->window
: NULL
, This
->container
, &wine_uri
);
1804 if(NS_FAILED(nsres
)) {
1805 WARN("create_uri failed: %08x\n", nsres
);
1809 *_retval
= (nsIURI
*)wine_uri
;
1810 return nsIWineURI_SetWineURL(wine_uri
, This
->wine_url
);
1813 static nsresult NSAPI
nsURI_Resolve(nsIWineURI
*iface
, const nsACString
*arelativePath
,
1814 nsACString
*_retval
)
1816 nsURI
*This
= NSURI_THIS(iface
);
1818 TRACE("(%p)->(%p %p)\n", This
, arelativePath
, _retval
);
1821 return nsIURI_Resolve(This
->uri
, arelativePath
, _retval
);
1823 FIXME("default action not implemented\n");
1824 return NS_ERROR_NOT_IMPLEMENTED
;
1827 static nsresult NSAPI
nsURI_GetAsciiSpec(nsIWineURI
*iface
, nsACString
*aAsciiSpec
)
1829 nsURI
*This
= NSURI_THIS(iface
);
1831 TRACE("(%p)->(%p)\n", This
, aAsciiSpec
);
1833 if(This
->use_wine_url
)
1834 return nsIURI_GetSpec(NSURI(This
), aAsciiSpec
);
1837 return nsIURI_GetAsciiSpec(This
->uri
, aAsciiSpec
);
1839 TRACE("returning error\n");
1840 return NS_ERROR_NOT_IMPLEMENTED
;
1843 static nsresult NSAPI
nsURI_GetAsciiHost(nsIWineURI
*iface
, nsACString
*aAsciiHost
)
1845 nsURI
*This
= NSURI_THIS(iface
);
1847 TRACE("(%p)->(%p)\n", This
, aAsciiHost
);
1850 return nsIURI_GetAsciiHost(This
->uri
, aAsciiHost
);
1852 FIXME("default action not implemented\n");
1853 return NS_ERROR_NOT_IMPLEMENTED
;
1856 static nsresult NSAPI
nsURI_GetOriginCharset(nsIWineURI
*iface
, nsACString
*aOriginCharset
)
1858 nsURI
*This
= NSURI_THIS(iface
);
1860 TRACE("(%p)->(%p)\n", This
, aOriginCharset
);
1863 return nsIURI_GetOriginCharset(This
->uri
, aOriginCharset
);
1865 FIXME("default action not implemented\n");
1866 return NS_ERROR_NOT_IMPLEMENTED
;
1869 static nsresult NSAPI
nsURL_GetFilePath(nsIWineURI
*iface
, nsACString
*aFilePath
)
1871 nsURI
*This
= NSURI_THIS(iface
);
1873 TRACE("(%p)->(%p)\n", This
, aFilePath
);
1876 return nsIURL_GetFilePath(This
->nsurl
, aFilePath
);
1878 FIXME("default action not implemented\n");
1879 return NS_ERROR_NOT_IMPLEMENTED
;
1882 static nsresult NSAPI
nsURL_SetFilePath(nsIWineURI
*iface
, const nsACString
*aFilePath
)
1884 nsURI
*This
= NSURI_THIS(iface
);
1886 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aFilePath
));
1889 return nsIURL_SetFilePath(This
->nsurl
, aFilePath
);
1891 FIXME("default action not implemented\n");
1892 return NS_ERROR_NOT_IMPLEMENTED
;
1895 static nsresult NSAPI
nsURL_GetParam(nsIWineURI
*iface
, nsACString
*aParam
)
1897 nsURI
*This
= NSURI_THIS(iface
);
1899 TRACE("(%p)->(%p)\n", This
, aParam
);
1902 return nsIURL_GetParam(This
->nsurl
, aParam
);
1904 FIXME("default action not implemented\n");
1905 return NS_ERROR_NOT_IMPLEMENTED
;
1908 static nsresult NSAPI
nsURL_SetParam(nsIWineURI
*iface
, const nsACString
*aParam
)
1910 nsURI
*This
= NSURI_THIS(iface
);
1912 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aParam
));
1915 return nsIURL_SetParam(This
->nsurl
, aParam
);
1917 FIXME("default action not implemented\n");
1918 return NS_ERROR_NOT_IMPLEMENTED
;
1921 static nsresult NSAPI
nsURL_GetQuery(nsIWineURI
*iface
, nsACString
*aQuery
)
1923 nsURI
*This
= NSURI_THIS(iface
);
1925 TRACE("(%p)->(%p)\n", This
, aQuery
);
1928 return nsIURL_GetQuery(This
->nsurl
, aQuery
);
1930 FIXME("default action not implemented\n");
1931 return NS_ERROR_NOT_IMPLEMENTED
;
1934 static nsresult NSAPI
nsURL_SetQuery(nsIWineURI
*iface
, const nsACString
*aQuery
)
1936 nsURI
*This
= NSURI_THIS(iface
);
1937 const WCHAR
*ptr1
, *ptr2
;
1939 WCHAR
*new_url
, *ptr
;
1942 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aQuery
));
1945 nsIURL_SetQuery(This
->nsurl
, aQuery
);
1950 nsACString_GetData(aQuery
, &query
);
1951 size
= len
= MultiByteToWideChar(CP_ACP
, 0, query
, -1, NULL
, 0);
1952 ptr1
= strchrW(This
->wine_url
, '?');
1954 size
+= ptr1
-This
->wine_url
;
1955 ptr2
= strchrW(ptr1
, '#');
1957 size
+= strlenW(ptr2
);
1959 ptr1
= This
->wine_url
+ strlenW(This
->wine_url
);
1961 size
+= strlenW(This
->wine_url
);
1967 new_url
= heap_alloc(size
*sizeof(WCHAR
));
1968 memcpy(new_url
, This
->wine_url
, (ptr1
-This
->wine_url
)*sizeof(WCHAR
));
1969 ptr
= new_url
+ (ptr1
-This
->wine_url
);
1972 MultiByteToWideChar(CP_ACP
, 0, query
, -1, ptr
, len
);
1980 TRACE("setting %s\n", debugstr_w(new_url
));
1982 heap_free(This
->wine_url
);
1983 This
->wine_url
= new_url
;
1987 static nsresult NSAPI
nsURL_GetRef(nsIWineURI
*iface
, nsACString
*aRef
)
1989 nsURI
*This
= NSURI_THIS(iface
);
1991 TRACE("(%p)->(%p)\n", This
, aRef
);
1994 return nsIURL_GetRef(This
->nsurl
, aRef
);
1996 FIXME("default action not implemented\n");
1997 return NS_ERROR_NOT_IMPLEMENTED
;
2000 static nsresult NSAPI
nsURL_SetRef(nsIWineURI
*iface
, const nsACString
*aRef
)
2002 nsURI
*This
= NSURI_THIS(iface
);
2005 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aRef
));
2008 return nsIURL_SetRef(This
->nsurl
, aRef
);
2010 nsACString_GetData(aRef
, &refa
);
2014 FIXME("default action not implemented\n");
2015 return NS_ERROR_NOT_IMPLEMENTED
;
2018 static nsresult NSAPI
nsURL_GetDirectory(nsIWineURI
*iface
, nsACString
*aDirectory
)
2020 nsURI
*This
= NSURI_THIS(iface
);
2022 TRACE("(%p)->(%p)\n", This
, aDirectory
);
2025 return nsIURL_GetDirectory(This
->nsurl
, aDirectory
);
2027 FIXME("default action not implemented\n");
2028 return NS_ERROR_NOT_IMPLEMENTED
;
2031 static nsresult NSAPI
nsURL_SetDirectory(nsIWineURI
*iface
, const nsACString
*aDirectory
)
2033 nsURI
*This
= NSURI_THIS(iface
);
2035 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aDirectory
));
2038 return nsIURL_SetDirectory(This
->nsurl
, aDirectory
);
2040 FIXME("default action not implemented\n");
2041 return NS_ERROR_NOT_IMPLEMENTED
;
2044 static nsresult NSAPI
nsURL_GetFileName(nsIWineURI
*iface
, nsACString
*aFileName
)
2046 nsURI
*This
= NSURI_THIS(iface
);
2048 TRACE("(%p)->(%p)\n", This
, aFileName
);
2051 return nsIURL_GetFileName(This
->nsurl
, aFileName
);
2053 FIXME("default action not implemented\n");
2054 return NS_ERROR_NOT_IMPLEMENTED
;
2057 static nsresult NSAPI
nsURL_SetFileName(nsIWineURI
*iface
, const nsACString
*aFileName
)
2059 nsURI
*This
= NSURI_THIS(iface
);
2061 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aFileName
));
2064 return nsIURL_SetFileName(This
->nsurl
, aFileName
);
2066 FIXME("default action not implemented\n");
2067 return NS_ERROR_NOT_IMPLEMENTED
;
2070 static nsresult NSAPI
nsURL_GetFileBaseName(nsIWineURI
*iface
, nsACString
*aFileBaseName
)
2072 nsURI
*This
= NSURI_THIS(iface
);
2074 TRACE("(%p)->(%p)\n", This
, aFileBaseName
);
2077 return nsIURL_GetFileBaseName(This
->nsurl
, aFileBaseName
);
2079 FIXME("default action not implemented\n");
2080 return NS_ERROR_NOT_IMPLEMENTED
;
2083 static nsresult NSAPI
nsURL_SetFileBaseName(nsIWineURI
*iface
, const nsACString
*aFileBaseName
)
2085 nsURI
*This
= NSURI_THIS(iface
);
2087 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aFileBaseName
));
2090 return nsIURL_SetFileBaseName(This
->nsurl
, aFileBaseName
);
2092 FIXME("default action not implemented\n");
2093 return NS_ERROR_NOT_IMPLEMENTED
;
2096 static nsresult NSAPI
nsURL_GetFileExtension(nsIWineURI
*iface
, nsACString
*aFileExtension
)
2098 nsURI
*This
= NSURI_THIS(iface
);
2100 TRACE("(%p)->(%p)\n", This
, aFileExtension
);
2103 return nsIURL_GetFileExtension(This
->nsurl
, aFileExtension
);
2105 FIXME("default action not implemented\n");
2106 return NS_ERROR_NOT_IMPLEMENTED
;
2109 static nsresult NSAPI
nsURL_SetFileExtension(nsIWineURI
*iface
, const nsACString
*aFileExtension
)
2111 nsURI
*This
= NSURI_THIS(iface
);
2113 TRACE("(%p)->(%s)\n", This
, debugstr_nsacstr(aFileExtension
));
2116 return nsIURL_SetFileExtension(This
->nsurl
, aFileExtension
);
2118 FIXME("default action not implemented\n");
2119 return NS_ERROR_NOT_IMPLEMENTED
;
2122 static nsresult NSAPI
nsURL_GetCommonBaseSpec(nsIWineURI
*iface
, nsIURI
*aURIToCompare
, nsACString
*_retval
)
2124 nsURI
*This
= NSURI_THIS(iface
);
2126 TRACE("(%p)->(%p %p)\n", This
, aURIToCompare
, _retval
);
2129 return nsIURL_GetCommonBaseSpec(This
->nsurl
, aURIToCompare
, _retval
);
2131 FIXME("default action not implemented\n");
2132 return NS_ERROR_NOT_IMPLEMENTED
;
2135 static nsresult NSAPI
nsURL_GetRelativeSpec(nsIWineURI
*iface
, nsIURI
*aURIToCompare
, nsACString
*_retval
)
2137 nsURI
*This
= NSURI_THIS(iface
);
2139 TRACE("(%p)->(%p %p)\n", This
, aURIToCompare
, _retval
);
2142 return nsIURL_GetRelativeSpec(This
->nsurl
, aURIToCompare
, _retval
);
2144 FIXME("default action not implemented\n");
2145 return NS_ERROR_NOT_IMPLEMENTED
;
2148 static nsresult NSAPI
nsURI_GetNSContainer(nsIWineURI
*iface
, NSContainer
**aContainer
)
2150 nsURI
*This
= NSURI_THIS(iface
);
2152 TRACE("(%p)->(%p)\n", This
, aContainer
);
2155 nsIWebBrowserChrome_AddRef(NSWBCHROME(This
->container
));
2156 *aContainer
= This
->container
;
2161 static nsresult NSAPI
nsURI_SetNSContainer(nsIWineURI
*iface
, NSContainer
*aContainer
)
2163 nsURI
*This
= NSURI_THIS(iface
);
2165 TRACE("(%p)->(%p)\n", This
, aContainer
);
2167 if(This
->container
) {
2168 if(This
->container
== aContainer
)
2170 TRACE("Changing %p -> %p\n", This
->container
, aContainer
);
2171 nsIWebBrowserChrome_Release(NSWBCHROME(This
->container
));
2175 nsIWebBrowserChrome_AddRef(NSWBCHROME(aContainer
));
2176 This
->container
= aContainer
;
2181 static nsresult NSAPI
nsURI_GetWindow(nsIWineURI
*iface
, HTMLWindow
**aHTMLWindow
)
2183 nsURI
*This
= NSURI_THIS(iface
);
2185 TRACE("(%p)->(%p)\n", This
, aHTMLWindow
);
2187 if(This
->window_ref
&& This
->window_ref
->window
) {
2188 IHTMLWindow2_AddRef(HTMLWINDOW2(This
->window_ref
->window
));
2189 *aHTMLWindow
= This
->window_ref
->window
;
2191 *aHTMLWindow
= NULL
;
2197 static nsresult NSAPI
nsURI_SetWindow(nsIWineURI
*iface
, HTMLWindow
*aHTMLWindow
)
2199 nsURI
*This
= NSURI_THIS(iface
);
2201 TRACE("(%p)->(%p)\n", This
, aHTMLWindow
);
2203 if(This
->window_ref
) {
2204 if(This
->window_ref
->window
== aHTMLWindow
)
2206 TRACE("Changing %p -> %p\n", This
->window_ref
->window
, aHTMLWindow
);
2207 windowref_release(This
->window_ref
);
2211 windowref_addref(aHTMLWindow
->window_ref
);
2212 This
->window_ref
= aHTMLWindow
->window_ref
;
2214 if(aHTMLWindow
->doc_obj
)
2215 nsIWineURI_SetNSContainer(NSWINEURI(This
), aHTMLWindow
->doc_obj
->nscontainer
);
2217 This
->window_ref
= NULL
;
2223 static nsresult NSAPI
nsURI_GetIsDocumentURI(nsIWineURI
*iface
, PRBool
*aIsDocumentURI
)
2225 nsURI
*This
= NSURI_THIS(iface
);
2227 TRACE("(%p)->(%p)\n", This
, aIsDocumentURI
);
2229 *aIsDocumentURI
= This
->is_doc_uri
;
2233 static nsresult NSAPI
nsURI_SetIsDocumentURI(nsIWineURI
*iface
, PRBool aIsDocumentURI
)
2235 nsURI
*This
= NSURI_THIS(iface
);
2237 TRACE("(%p)->(%x)\n", This
, aIsDocumentURI
);
2239 This
->is_doc_uri
= aIsDocumentURI
;
2243 static nsresult NSAPI
nsURI_GetWineURL(nsIWineURI
*iface
, LPCWSTR
*aURL
)
2245 nsURI
*This
= NSURI_THIS(iface
);
2247 TRACE("(%p)->(%p)\n", This
, aURL
);
2249 *aURL
= This
->wine_url
;
2253 static nsresult NSAPI
nsURI_SetWineURL(nsIWineURI
*iface
, LPCWSTR aURL
)
2255 nsURI
*This
= NSURI_THIS(iface
);
2257 static const WCHAR wszFtp
[] = {'f','t','p',':'};
2258 static const WCHAR wszHttp
[] = {'h','t','t','p',':'};
2259 static const WCHAR wszHttps
[] = {'h','t','t','p','s',':'};
2261 TRACE("(%p)->(%s)\n", This
, debugstr_w(aURL
));
2263 heap_free(This
->wine_url
);
2266 int len
= strlenW(aURL
)+1;
2267 This
->wine_url
= heap_alloc(len
*sizeof(WCHAR
));
2268 memcpy(This
->wine_url
, aURL
, len
*sizeof(WCHAR
));
2270 /* FIXME: Always use wine url */
2271 This
->use_wine_url
=
2272 strncmpW(aURL
, wszFtp
, sizeof(wszFtp
)/sizeof(WCHAR
))
2273 && strncmpW(aURL
, wszHttp
, sizeof(wszHttp
)/sizeof(WCHAR
))
2274 && strncmpW(aURL
, wszHttps
, sizeof(wszHttps
)/sizeof(WCHAR
));
2276 This
->wine_url
= NULL
;
2277 This
->use_wine_url
= FALSE
;
2285 static const nsIWineURIVtbl nsWineURIVtbl
= {
2286 nsURI_QueryInterface
,
2314 nsURI_GetOriginCharset
,
2327 nsURL_GetFileBaseName
,
2328 nsURL_SetFileBaseName
,
2329 nsURL_GetFileExtension
,
2330 nsURL_SetFileExtension
,
2331 nsURL_GetCommonBaseSpec
,
2332 nsURL_GetRelativeSpec
,
2333 nsURI_GetNSContainer
,
2334 nsURI_SetNSContainer
,
2337 nsURI_GetIsDocumentURI
,
2338 nsURI_SetIsDocumentURI
,
2343 static nsresult
create_uri(nsIURI
*uri
, HTMLWindow
*window
, NSContainer
*container
, nsIWineURI
**_retval
)
2345 nsURI
*ret
= heap_alloc_zero(sizeof(nsURI
));
2347 ret
->lpWineURIVtbl
= &nsWineURIVtbl
;
2351 nsIWineURI_SetNSContainer(NSWINEURI(ret
), container
);
2352 nsIWineURI_SetWindow(NSWINEURI(ret
), window
);
2355 nsIURI_QueryInterface(uri
, &IID_nsIURL
, (void**)&ret
->nsurl
);
2359 TRACE("retval=%p\n", ret
);
2360 *_retval
= NSWINEURI(ret
);
2365 const nsIProtocolHandlerVtbl
*lpProtocolHandlerVtbl
;
2369 nsIProtocolHandler
*nshandler
;
2370 } nsProtocolHandler
;
2372 #define NSPROTHANDLER(x) ((nsIProtocolHandler*) &(x)->lpProtocolHandlerVtbl)
2374 #define NSPROTHANDLER_THIS(iface) DEFINE_THIS(nsProtocolHandler, ProtocolHandler, iface)
2376 static nsresult NSAPI
nsProtocolHandler_QueryInterface(nsIProtocolHandler
*iface
, nsIIDRef riid
,
2379 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
2383 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
2384 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
2385 *result
= NSPROTHANDLER(This
);
2386 }else if(IsEqualGUID(&IID_nsIProtocolHandler
, riid
)) {
2387 TRACE("(%p)->(IID_nsIProtocolHandler %p)\n", This
, result
);
2388 *result
= NSPROTHANDLER(This
);
2389 }else if(IsEqualGUID(&IID_nsIExternalProtocolHandler
, riid
)) {
2390 TRACE("(%p)->(IID_nsIExternalProtocolHandler %p), returning NULL\n", This
, result
);
2391 return NS_NOINTERFACE
;
2395 nsISupports_AddRef((nsISupports
*)*result
);
2399 WARN("(%s %p)\n", debugstr_guid(riid
), result
);
2400 return NS_NOINTERFACE
;
2403 static nsrefcnt NSAPI
nsProtocolHandler_AddRef(nsIProtocolHandler
*iface
)
2405 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
2406 LONG ref
= InterlockedIncrement(&This
->ref
);
2408 TRACE("(%p) ref=%d\n", This
, ref
);
2413 static nsrefcnt NSAPI
nsProtocolHandler_Release(nsIProtocolHandler
*iface
)
2415 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
2416 LONG ref
= InterlockedDecrement(&This
->ref
);
2418 TRACE("(%p) ref=%d\n", This
, ref
);
2422 nsIProtocolHandler_Release(This
->nshandler
);
2429 static nsresult NSAPI
nsProtocolHandler_GetScheme(nsIProtocolHandler
*iface
, nsACString
*aScheme
)
2431 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
2433 TRACE("(%p)->(%p)\n", This
, aScheme
);
2436 return nsIProtocolHandler_GetScheme(This
->nshandler
, aScheme
);
2437 return NS_ERROR_NOT_IMPLEMENTED
;
2440 static nsresult NSAPI
nsProtocolHandler_GetDefaultPort(nsIProtocolHandler
*iface
,
2441 PRInt32
*aDefaultPort
)
2443 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
2445 TRACE("(%p)->(%p)\n", This
, aDefaultPort
);
2448 return nsIProtocolHandler_GetDefaultPort(This
->nshandler
, aDefaultPort
);
2449 return NS_ERROR_NOT_IMPLEMENTED
;
2452 static nsresult NSAPI
nsProtocolHandler_GetProtocolFlags(nsIProtocolHandler
*iface
,
2453 PRUint32
*aProtocolFlags
)
2455 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
2457 TRACE("(%p)->(%p)\n", This
, aProtocolFlags
);
2460 return nsIProtocolHandler_GetProtocolFlags(This
->nshandler
, aProtocolFlags
);
2461 return NS_ERROR_NOT_IMPLEMENTED
;
2464 static nsresult NSAPI
nsProtocolHandler_NewURI(nsIProtocolHandler
*iface
,
2465 const nsACString
*aSpec
, const char *aOriginCharset
, nsIURI
*aBaseURI
, nsIURI
**_retval
)
2467 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
2469 TRACE("((%p)->%p %s %p %p)\n", This
, aSpec
, debugstr_a(aOriginCharset
), aBaseURI
, _retval
);
2472 return nsIProtocolHandler_NewURI(This
->nshandler
, aSpec
, aOriginCharset
, aBaseURI
, _retval
);
2473 return NS_ERROR_NOT_IMPLEMENTED
;
2476 static nsresult NSAPI
nsProtocolHandler_NewChannel(nsIProtocolHandler
*iface
,
2477 nsIURI
*aURI
, nsIChannel
**_retval
)
2479 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
2481 TRACE("(%p)->(%p %p)\n", This
, aURI
, _retval
);
2484 return nsIProtocolHandler_NewChannel(This
->nshandler
, aURI
, _retval
);
2485 return NS_ERROR_NOT_IMPLEMENTED
;
2488 static nsresult NSAPI
nsProtocolHandler_AllowPort(nsIProtocolHandler
*iface
,
2489 PRInt32 port
, const char *scheme
, PRBool
*_retval
)
2491 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
2493 TRACE("(%p)->(%d %s %p)\n", This
, port
, debugstr_a(scheme
), _retval
);
2496 return nsIProtocolHandler_AllowPort(This
->nshandler
, port
, scheme
, _retval
);
2497 return NS_ERROR_NOT_IMPLEMENTED
;
2500 #undef NSPROTHANDLER_THIS
2502 static const nsIProtocolHandlerVtbl nsProtocolHandlerVtbl
= {
2503 nsProtocolHandler_QueryInterface
,
2504 nsProtocolHandler_AddRef
,
2505 nsProtocolHandler_Release
,
2506 nsProtocolHandler_GetScheme
,
2507 nsProtocolHandler_GetDefaultPort
,
2508 nsProtocolHandler_GetProtocolFlags
,
2509 nsProtocolHandler_NewURI
,
2510 nsProtocolHandler_NewChannel
,
2511 nsProtocolHandler_AllowPort
2514 static nsIProtocolHandler
*create_protocol_handler(nsIProtocolHandler
*nshandler
)
2516 nsProtocolHandler
*ret
= heap_alloc(sizeof(nsProtocolHandler
));
2518 ret
->lpProtocolHandlerVtbl
= &nsProtocolHandlerVtbl
;
2520 ret
->nshandler
= nshandler
;
2522 return NSPROTHANDLER(ret
);
2525 static nsresult NSAPI
nsIOService_QueryInterface(nsIIOService
*,nsIIDRef
,nsQIResult
);
2527 static nsrefcnt NSAPI
nsIOService_AddRef(nsIIOService
*iface
)
2532 static nsrefcnt NSAPI
nsIOService_Release(nsIIOService
*iface
)
2537 static nsresult NSAPI
nsIOService_GetProtocolHandler(nsIIOService
*iface
, const char *aScheme
,
2538 nsIProtocolHandler
**_retval
)
2540 nsIExternalProtocolHandler
*nsexthandler
;
2541 nsIProtocolHandler
*nshandler
;
2544 TRACE("(%s %p)\n", debugstr_a(aScheme
), _retval
);
2546 nsres
= nsIIOService_GetProtocolHandler(nsio
, aScheme
, &nshandler
);
2547 if(NS_FAILED(nsres
)) {
2548 WARN("GetProtocolHandler failed: %08x\n", nsres
);
2552 nsres
= nsIProtocolHandler_QueryInterface(nshandler
, &IID_nsIExternalProtocolHandler
,
2553 (void**)&nsexthandler
);
2554 if(NS_FAILED(nsres
)) {
2555 *_retval
= nshandler
;
2559 nsIExternalProtocolHandler_Release(nsexthandler
);
2560 *_retval
= create_protocol_handler(nshandler
);
2561 TRACE("return %p\n", *_retval
);
2565 static nsresult NSAPI
nsIOService_GetProtocolFlags(nsIIOService
*iface
, const char *aScheme
,
2568 TRACE("(%s %p)\n", debugstr_a(aScheme
), _retval
);
2569 return nsIIOService_GetProtocolFlags(nsio
, aScheme
, _retval
);
2572 static BOOL
is_gecko_special_uri(const char *spec
)
2574 static const char *special_schemes
[] = {"chrome:", "jar:", "resource:", "javascript:", "wyciwyg:"};
2577 for(i
=0; i
< sizeof(special_schemes
)/sizeof(*special_schemes
); i
++) {
2578 if(!strncasecmp(spec
, special_schemes
[i
], strlen(special_schemes
[i
])))
2585 static nsresult NSAPI
nsIOService_NewURI(nsIIOService
*iface
, const nsACString
*aSpec
,
2586 const char *aOriginCharset
, nsIURI
*aBaseURI
, nsIURI
**_retval
)
2588 const char *spec
= NULL
;
2589 HTMLWindow
*window
= NULL
;
2591 LPCWSTR base_wine_url
= NULL
;
2592 nsIWineURI
*base_wine_uri
= NULL
, *wine_uri
;
2593 BOOL is_wine_uri
= FALSE
;
2596 nsACString_GetData(aSpec
, &spec
);
2598 TRACE("(%p(%s) %s %p %p)\n", aSpec
, debugstr_a(spec
), debugstr_a(aOriginCharset
),
2601 if(is_gecko_special_uri(spec
))
2602 return nsIIOService_NewURI(nsio
, aSpec
, aOriginCharset
, aBaseURI
, _retval
);
2604 if(!strncmp(spec
, "wine:", 5)) {
2610 nsACString base_uri_str
;
2611 const char *base_uri
= NULL
;
2613 nsACString_Init(&base_uri_str
, NULL
);
2615 nsres
= nsIURI_GetSpec(aBaseURI
, &base_uri_str
);
2616 if(NS_SUCCEEDED(nsres
)) {
2617 nsACString_GetData(&base_uri_str
, &base_uri
);
2618 TRACE("base_uri=%s\n", debugstr_a(base_uri
));
2620 ERR("GetSpec failed: %08x\n", nsres
);
2623 nsACString_Finish(&base_uri_str
);
2626 nsres
= nsIIOService_NewURI(nsio
, aSpec
, aOriginCharset
, aBaseURI
, &uri
);
2627 if(NS_FAILED(nsres
))
2628 TRACE("NewURI failed: %08x\n", nsres
);
2631 nsres
= nsIURI_QueryInterface(aBaseURI
, &IID_nsIWineURI
, (void**)&base_wine_uri
);
2632 if(NS_SUCCEEDED(nsres
)) {
2633 nsIWineURI_GetWindow(base_wine_uri
, &window
);
2634 nsIWineURI_GetWineURL(base_wine_uri
, &base_wine_url
);
2636 TRACE("Could not get base nsIWineURI: %08x\n", nsres
);
2640 TRACE("window = %p\n", window
);
2642 nsres
= create_uri(uri
, window
, NULL
, &wine_uri
);
2643 *_retval
= (nsIURI
*)wine_uri
;
2646 IHTMLWindow2_Release(HTMLWINDOW2(window
));
2649 WCHAR url
[INTERNET_MAX_URL_LENGTH
], rel_url
[INTERNET_MAX_URL_LENGTH
];
2653 MultiByteToWideChar(CP_ACP
, 0, spec
, -1, rel_url
, sizeof(rel_url
)/sizeof(WCHAR
));
2655 hres
= CoInternetCombineUrl(base_wine_url
, rel_url
,
2656 URL_ESCAPE_SPACES_ONLY
|URL_DONT_ESCAPE_EXTRA_INFO
,
2657 url
, sizeof(url
)/sizeof(WCHAR
), &len
, 0);
2659 nsIWineURI_SetWineURL(wine_uri
, url
);
2661 WARN("CoCombineUrl failed: %08x\n", hres
);
2662 }else if(is_wine_uri
) {
2663 WCHAR url
[INTERNET_MAX_URL_LENGTH
];
2665 MultiByteToWideChar(CP_ACP
, 0, spec
, -1, url
, sizeof(url
)/sizeof(WCHAR
));
2666 nsIWineURI_SetWineURL(wine_uri
, url
);
2670 nsIWineURI_Release(base_wine_uri
);
2675 static nsresult NSAPI
nsIOService_NewFileURI(nsIIOService
*iface
, nsIFile
*aFile
,
2678 TRACE("(%p %p)\n", aFile
, _retval
);
2679 return nsIIOService_NewFileURI(nsio
, aFile
, _retval
);
2682 static nsresult NSAPI
nsIOService_NewChannelFromURI(nsIIOService
*iface
, nsIURI
*aURI
,
2683 nsIChannel
**_retval
)
2685 nsIChannel
*channel
= NULL
;
2687 nsIWineURI
*wine_uri
;
2690 TRACE("(%p %p)\n", aURI
, _retval
);
2692 nsres
= nsIIOService_NewChannelFromURI(nsio
, aURI
, &channel
);
2693 if(NS_FAILED(nsres
) && nsres
!= NS_ERROR_UNKNOWN_PROTOCOL
) {
2694 WARN("NewChannelFromURI failed: %08x\n", nsres
);
2699 nsres
= nsIURI_QueryInterface(aURI
, &IID_nsIWineURI
, (void**)&wine_uri
);
2700 if(NS_FAILED(nsres
)) {
2701 WARN("Could not get nsIWineURI: %08x\n", nsres
);
2703 return channel
? NS_OK
: NS_ERROR_UNEXPECTED
;
2706 ret
= heap_alloc_zero(sizeof(nsChannel
));
2708 ret
->lpHttpChannelVtbl
= &nsChannelVtbl
;
2709 ret
->lpUploadChannelVtbl
= &nsUploadChannelVtbl
;
2710 ret
->lpIHttpChannelInternalVtbl
= &nsHttpChannelInternalVtbl
;
2712 ret
->channel
= channel
;
2713 ret
->uri
= wine_uri
;
2715 nsIURI_AddRef(aURI
);
2716 ret
->original_uri
= aURI
;
2719 nsIChannel_QueryInterface(channel
, &IID_nsIHttpChannel
, (void**)&ret
->http_channel
);
2720 nsIChannel_QueryInterface(channel
, &IID_nsIHttpChannelInternal
, (void**)&ret
->http_channel_internal
);
2723 *_retval
= NSCHANNEL(ret
);
2727 static nsresult NSAPI
nsIOService_NewChannel(nsIIOService
*iface
, const nsACString
*aSpec
,
2728 const char *aOriginCharset
, nsIURI
*aBaseURI
, nsIChannel
**_retval
)
2730 TRACE("(%p %s %p %p)\n", aSpec
, debugstr_a(aOriginCharset
), aBaseURI
, _retval
);
2731 return nsIIOService_NewChannel(nsio
, aSpec
, aOriginCharset
, aBaseURI
, _retval
);
2734 static nsresult NSAPI
nsIOService_GetOffline(nsIIOService
*iface
, PRBool
*aOffline
)
2736 TRACE("(%p)\n", aOffline
);
2737 return nsIIOService_GetOffline(nsio
, aOffline
);
2740 static nsresult NSAPI
nsIOService_SetOffline(nsIIOService
*iface
, PRBool aOffline
)
2742 TRACE("(%x)\n", aOffline
);
2743 return nsIIOService_SetOffline(nsio
, aOffline
);
2746 static nsresult NSAPI
nsIOService_AllowPort(nsIIOService
*iface
, PRInt32 aPort
,
2747 const char *aScheme
, PRBool
*_retval
)
2749 TRACE("(%d %s %p)\n", aPort
, debugstr_a(aScheme
), _retval
);
2750 return nsIIOService_AllowPort(nsio
, aPort
, debugstr_a(aScheme
), _retval
);
2753 static nsresult NSAPI
nsIOService_ExtractScheme(nsIIOService
*iface
, const nsACString
*urlString
,
2754 nsACString
* _retval
)
2756 TRACE("(%p %p)\n", urlString
, _retval
);
2757 return nsIIOService_ExtractScheme(nsio
, urlString
, _retval
);
2760 static const nsIIOServiceVtbl nsIOServiceVtbl
= {
2761 nsIOService_QueryInterface
,
2763 nsIOService_Release
,
2764 nsIOService_GetProtocolHandler
,
2765 nsIOService_GetProtocolFlags
,
2767 nsIOService_NewFileURI
,
2768 nsIOService_NewChannelFromURI
,
2769 nsIOService_NewChannel
,
2770 nsIOService_GetOffline
,
2771 nsIOService_SetOffline
,
2772 nsIOService_AllowPort
,
2773 nsIOService_ExtractScheme
2776 static nsIIOService nsIOService
= { &nsIOServiceVtbl
};
2778 static nsresult NSAPI
nsNetUtil_QueryInterface(nsINetUtil
*iface
, nsIIDRef riid
,
2781 return nsIIOService_QueryInterface(&nsIOService
, riid
, result
);
2784 static nsrefcnt NSAPI
nsNetUtil_AddRef(nsINetUtil
*iface
)
2789 static nsrefcnt NSAPI
nsNetUtil_Release(nsINetUtil
*iface
)
2794 static nsresult NSAPI
nsNetUtil_ParseContentType(nsINetUtil
*iface
, const nsACString
*aTypeHeader
,
2795 nsACString
*aCharset
, PRBool
*aHadCharset
, nsACString
*aContentType
)
2797 TRACE("(%p %p %p %p)\n", aTypeHeader
, aCharset
, aHadCharset
, aContentType
);
2799 return nsINetUtil_ParseContentType(net_util
, aTypeHeader
, aCharset
, aHadCharset
, aContentType
);
2802 static nsresult NSAPI
nsNetUtil_ProtocolHasFlags(nsINetUtil
*iface
, nsIURI
*aURI
, PRUint32 aFlags
, PRBool
*_retval
)
2806 return nsINetUtil_ProtocolHasFlags(net_util
, aURI
, aFlags
, _retval
);
2809 static nsresult NSAPI
nsNetUtil_URIChainHasFlags(nsINetUtil
*iface
, nsIURI
*aURI
, PRUint32 aFlags
, PRBool
*_retval
)
2811 TRACE("(%p %08x %p)\n", aURI
, aFlags
, _retval
);
2813 if(aFlags
== (1<<11)) {
2818 return nsINetUtil_URIChainHasFlags(net_util
, aURI
, aFlags
, _retval
);
2821 static nsresult NSAPI
nsNetUtil_ToImmutableURI(nsINetUtil
*iface
, nsIURI
*aURI
, nsIURI
**_retval
)
2823 TRACE("(%p %p)\n", aURI
, _retval
);
2825 return nsINetUtil_ToImmutableURI(net_util
, aURI
, _retval
);
2828 static nsresult NSAPI
nsNetUtil_EscapeString(nsINetUtil
*iface
, const nsACString
*aString
,
2829 PRUint32 aEscapeType
, nsACString
*_retval
)
2831 TRACE("(%p %x %p)\n", aString
, aEscapeType
, _retval
);
2833 return nsINetUtil_EscapeString(net_util
, aString
, aEscapeType
, _retval
);
2836 static nsresult NSAPI
nsNetUtil_EscapeURL(nsINetUtil
*iface
, const nsACString
*aStr
, PRUint32 aFlags
,
2837 nsACString
*_retval
)
2839 TRACE("(%p %08x %p)\n", aStr
, aFlags
, _retval
);
2841 return nsINetUtil_EscapeURL(net_util
, aStr
, aFlags
, _retval
);
2844 static nsresult NSAPI
nsNetUtil_UnescapeString(nsINetUtil
*iface
, const nsACString
*aStr
,
2845 PRUint32 aFlags
, nsACString
*_retval
)
2847 TRACE("(%p %08x %p)\n", aStr
, aFlags
, _retval
);
2849 return nsINetUtil_UnescapeString(net_util
, aStr
, aFlags
, _retval
);
2852 static nsresult NSAPI
nsNetUtil_ExtractCharsetFromContentType(nsINetUtil
*iface
, const nsACString
*aTypeHeader
,
2853 nsACString
*aCharset
, PRInt32
*aCharsetStart
, PRInt32
*aCharsetEnd
, PRBool
*_retval
)
2855 TRACE("(%p %p %p %p %p)\n", aTypeHeader
, aCharset
, aCharsetStart
, aCharsetEnd
, _retval
);
2857 return nsINetUtil_ExtractCharsetFromContentType(net_util
, aTypeHeader
, aCharset
, aCharsetStart
, aCharsetEnd
, _retval
);
2860 static const nsINetUtilVtbl nsNetUtilVtbl
= {
2861 nsNetUtil_QueryInterface
,
2864 nsNetUtil_ParseContentType
,
2865 nsNetUtil_ProtocolHasFlags
,
2866 nsNetUtil_URIChainHasFlags
,
2867 nsNetUtil_ToImmutableURI
,
2868 nsNetUtil_EscapeString
,
2869 nsNetUtil_EscapeURL
,
2870 nsNetUtil_UnescapeString
,
2871 nsNetUtil_ExtractCharsetFromContentType
2874 static nsINetUtil nsNetUtil
= { &nsNetUtilVtbl
};
2876 static nsresult NSAPI
nsIOService_QueryInterface(nsIIOService
*iface
, nsIIDRef riid
,
2881 if(IsEqualGUID(&IID_nsISupports
, riid
))
2882 *result
= &nsIOService
;
2883 else if(IsEqualGUID(&IID_nsIIOService
, riid
))
2884 *result
= &nsIOService
;
2885 else if(IsEqualGUID(&IID_nsINetUtil
, riid
))
2886 *result
= &nsNetUtil
;
2889 nsISupports_AddRef((nsISupports
*)*result
);
2893 FIXME("(%s %p)\n", debugstr_guid(riid
), result
);
2894 return NS_NOINTERFACE
;
2897 static nsresult NSAPI
nsIOServiceFactory_QueryInterface(nsIFactory
*iface
, nsIIDRef riid
,
2902 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
2903 TRACE("(IID_nsISupports %p)\n", result
);
2905 }else if(IsEqualGUID(&IID_nsIFactory
, riid
)) {
2906 TRACE("(IID_nsIFactory %p)\n", result
);
2911 nsIFactory_AddRef(iface
);
2915 WARN("(%s %p)\n", debugstr_guid(riid
), result
);
2916 return NS_NOINTERFACE
;
2919 static nsrefcnt NSAPI
nsIOServiceFactory_AddRef(nsIFactory
*iface
)
2924 static nsrefcnt NSAPI
nsIOServiceFactory_Release(nsIFactory
*iface
)
2929 static nsresult NSAPI
nsIOServiceFactory_CreateInstance(nsIFactory
*iface
,
2930 nsISupports
*aOuter
, const nsIID
*iid
, void **result
)
2932 return nsIIOService_QueryInterface(&nsIOService
, iid
, result
);
2935 static nsresult NSAPI
nsIOServiceFactory_LockFactory(nsIFactory
*iface
, PRBool lock
)
2937 WARN("(%x)\n", lock
);
2941 static const nsIFactoryVtbl nsIOServiceFactoryVtbl
= {
2942 nsIOServiceFactory_QueryInterface
,
2943 nsIOServiceFactory_AddRef
,
2944 nsIOServiceFactory_Release
,
2945 nsIOServiceFactory_CreateInstance
,
2946 nsIOServiceFactory_LockFactory
2949 static nsIFactory nsIOServiceFactory
= { &nsIOServiceFactoryVtbl
};
2951 void init_nsio(nsIComponentManager
*component_manager
, nsIComponentRegistrar
*registrar
)
2953 nsIFactory
*old_factory
= NULL
;
2956 nsres
= nsIComponentManager_GetClassObject(component_manager
, &NS_IOSERVICE_CID
,
2957 &IID_nsIFactory
, (void**)&old_factory
);
2958 if(NS_FAILED(nsres
)) {
2959 ERR("Could not get factory: %08x\n", nsres
);
2963 nsres
= nsIFactory_CreateInstance(old_factory
, NULL
, &IID_nsIIOService
, (void**)&nsio
);
2964 if(NS_FAILED(nsres
)) {
2965 ERR("Couldn not create nsIOService instance %08x\n", nsres
);
2966 nsIFactory_Release(old_factory
);
2970 nsres
= nsIIOService_QueryInterface(nsio
, &IID_nsINetUtil
, (void**)&net_util
);
2971 if(NS_FAILED(nsres
)) {
2972 WARN("Could not get nsINetUtil interface: %08x\n", nsres
);
2973 nsIIOService_Release(nsio
);
2977 nsres
= nsIComponentRegistrar_UnregisterFactory(registrar
, &NS_IOSERVICE_CID
, old_factory
);
2978 nsIFactory_Release(old_factory
);
2979 if(NS_FAILED(nsres
))
2980 ERR("UnregisterFactory failed: %08x\n", nsres
);
2982 nsres
= nsIComponentRegistrar_RegisterFactory(registrar
, &NS_IOSERVICE_CID
,
2983 NS_IOSERVICE_CLASSNAME
, NS_IOSERVICE_CONTRACTID
, &nsIOServiceFactory
);
2984 if(NS_FAILED(nsres
))
2985 ERR("RegisterFactory failed: %08x\n", nsres
);
2988 void release_nsio(void)
2991 nsINetUtil_Release(net_util
);
2996 nsIIOService_Release(nsio
);