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
;
52 const nsIWineURIVtbl
*lpWineURIVtbl
;
57 NSContainer
*container
;
63 #define NSURI(x) ((nsIURI*) &(x)->lpWineURIVtbl)
64 #define NSWINEURI(x) ((nsIWineURI*) &(x)->lpWineURIVtbl)
66 static nsresult
create_uri(nsIURI
*,NSContainer
*,nsIWineURI
**);
68 static BOOL
exec_shldocvw_67(HTMLDocument
*doc
, LPCWSTR url
)
70 IOleCommandTarget
*cmdtrg
= NULL
;
73 hres
= IOleClientSite_QueryInterface(doc
->client
, &IID_IOleCommandTarget
,
76 VARIANT varUrl
, varRes
;
78 V_VT(&varUrl
) = VT_BSTR
;
79 V_BSTR(&varUrl
) = SysAllocString(url
);
80 V_VT(&varRes
) = VT_BOOL
;
82 hres
= IOleCommandTarget_Exec(cmdtrg
, &CGID_ShellDocView
, 67, 0, &varUrl
, &varRes
);
84 IOleCommandTarget_Release(cmdtrg
);
85 SysFreeString(V_BSTR(&varUrl
));
87 if(SUCCEEDED(hres
) && !V_BOOL(&varRes
)) {
88 TRACE("got VARIANT_FALSE, do not load\n");
96 static BOOL
before_async_open(nsChannel
*channel
, NSContainer
*container
)
98 IServiceProvider
*service_provider
;
99 HTMLDocument
*doc
= container
->doc
;
104 nsIWineURI_GetWineURL(channel
->uri
, &uri
);
106 ERR("GetWineURL returned NULL\n");
111 NSContainer
*container_iter
= container
;
113 hlnf
= HLNF_OPENINNEWWINDOW
;
114 while(!container_iter
->doc
)
115 container_iter
= container_iter
->parent
;
116 doc
= container_iter
->doc
;
122 if(!hlnf
&& !exec_shldocvw_67(doc
, uri
))
125 hres
= IOleClientSite_QueryInterface(doc
->client
, &IID_IServiceProvider
,
126 (void**)&service_provider
);
127 if(SUCCEEDED(hres
)) {
128 IHlinkFrame
*hlink_frame
;
130 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHlinkFrame
,
131 &IID_IHlinkFrame
, (void**)&hlink_frame
);
132 IServiceProvider_Release(service_provider
);
133 if(SUCCEEDED(hres
)) {
134 hlink_frame_navigate(doc
, hlink_frame
, uri
, channel
->post_data_stream
, hlnf
);
135 IHlinkFrame_Release(hlink_frame
);
144 #define NSCHANNEL_THIS(iface) DEFINE_THIS(nsChannel, HttpChannel, iface)
146 static nsresult NSAPI
nsChannel_QueryInterface(nsIHttpChannel
*iface
, nsIIDRef riid
, nsQIResult result
)
148 nsChannel
*This
= NSCHANNEL_THIS(iface
);
152 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
153 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
154 *result
= NSCHANNEL(This
);
155 }else if(IsEqualGUID(&IID_nsIRequest
, riid
)) {
156 TRACE("(%p)->(IID_nsIRequest %p)\n", This
, result
);
157 *result
= NSCHANNEL(This
);
158 }else if(IsEqualGUID(&IID_nsIChannel
, riid
)) {
159 TRACE("(%p)->(IID_nsIChannel %p)\n", This
, result
);
160 *result
= NSCHANNEL(This
);
161 }else if(This
->http_channel
&& IsEqualGUID(&IID_nsIHttpChannel
, riid
)) {
162 TRACE("(%p)->(IID_nsIHttpChannel %p)\n", This
, result
);
163 *result
= NSHTTPCHANNEL(This
);
164 }else if(IsEqualGUID(&IID_nsIUploadChannel
, riid
)) {
165 TRACE("(%p)->(IID_nsIUploadChannel %p)\n", This
, result
);
166 *result
= NSUPCHANNEL(This
);
170 nsIChannel_AddRef(NSCHANNEL(This
));
174 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), result
);
177 return nsIChannel_QueryInterface(This
->channel
, riid
, result
);
178 return NS_NOINTERFACE
;
181 static nsrefcnt NSAPI
nsChannel_AddRef(nsIHttpChannel
*iface
)
183 nsChannel
*This
= NSCHANNEL_THIS(iface
);
184 nsrefcnt ref
= InterlockedIncrement(&This
->ref
);
186 TRACE("(%p) ref=%d\n", This
, ref
);
191 static nsrefcnt NSAPI
nsChannel_Release(nsIHttpChannel
*iface
)
193 nsChannel
*This
= NSCHANNEL_THIS(iface
);
194 LONG ref
= InterlockedDecrement(&This
->ref
);
197 nsIWineURI_Release(This
->uri
);
199 nsIChannel_Release(This
->channel
);
200 if(This
->http_channel
)
201 nsIHttpChannel_Release(This
->http_channel
);
202 if(This
->post_data_stream
)
203 nsIInputStream_Release(This
->post_data_stream
);
205 nsILoadGroup_Release(This
->load_group
);
206 if(This
->notif_callback
)
207 nsIInterfaceRequestor_Release(This
->notif_callback
);
208 if(This
->original_uri
)
209 nsIURI_Release(This
->original_uri
);
210 heap_free(This
->content
);
211 heap_free(This
->charset
);
218 static nsresult NSAPI
nsChannel_GetName(nsIHttpChannel
*iface
, nsACString
*aName
)
220 nsChannel
*This
= NSCHANNEL_THIS(iface
);
222 TRACE("(%p)->(%p)\n", This
, aName
);
225 return nsIChannel_GetName(This
->channel
, aName
);
227 return NS_ERROR_NOT_IMPLEMENTED
;
230 static nsresult NSAPI
nsChannel_IsPending(nsIHttpChannel
*iface
, PRBool
*_retval
)
232 nsChannel
*This
= NSCHANNEL_THIS(iface
);
234 TRACE("(%p)->(%p)\n", This
, _retval
);
237 return nsIChannel_IsPending(This
->channel
, _retval
);
239 FIXME("default action not implemented\n");
240 return NS_ERROR_NOT_IMPLEMENTED
;
243 static nsresult NSAPI
nsChannel_GetStatus(nsIHttpChannel
*iface
, nsresult
*aStatus
)
245 nsChannel
*This
= NSCHANNEL_THIS(iface
);
247 TRACE("(%p)->(%p)\n", This
, aStatus
);
250 return nsIChannel_GetStatus(This
->channel
, aStatus
);
252 TRACE("returning NS_OK\n");
253 return *aStatus
= NS_OK
;
256 static nsresult NSAPI
nsChannel_Cancel(nsIHttpChannel
*iface
, nsresult aStatus
)
258 nsChannel
*This
= NSCHANNEL_THIS(iface
);
260 TRACE("(%p)->(%08x)\n", This
, aStatus
);
263 return nsIChannel_Cancel(This
->channel
, aStatus
);
265 FIXME("default action not implemented\n");
266 return NS_ERROR_NOT_IMPLEMENTED
;
269 static nsresult NSAPI
nsChannel_Suspend(nsIHttpChannel
*iface
)
271 nsChannel
*This
= NSCHANNEL_THIS(iface
);
273 TRACE("(%p)\n", This
);
276 return nsIChannel_Suspend(This
->channel
);
278 FIXME("default action not implemented\n");
279 return NS_ERROR_NOT_IMPLEMENTED
;
282 static nsresult NSAPI
nsChannel_Resume(nsIHttpChannel
*iface
)
284 nsChannel
*This
= NSCHANNEL_THIS(iface
);
286 TRACE("(%p)\n", This
);
289 return nsIChannel_Resume(This
->channel
);
291 FIXME("default action not implemented\n");
292 return NS_ERROR_NOT_IMPLEMENTED
;
295 static nsresult NSAPI
nsChannel_GetLoadGroup(nsIHttpChannel
*iface
, nsILoadGroup
**aLoadGroup
)
297 nsChannel
*This
= NSCHANNEL_THIS(iface
);
299 TRACE("(%p)->(%p)\n", This
, aLoadGroup
);
302 nsILoadGroup_AddRef(This
->load_group
);
304 *aLoadGroup
= This
->load_group
;
308 static nsresult NSAPI
nsChannel_SetLoadGroup(nsIHttpChannel
*iface
, nsILoadGroup
*aLoadGroup
)
310 nsChannel
*This
= NSCHANNEL_THIS(iface
);
312 TRACE("(%p)->(%p)\n", This
, aLoadGroup
);
315 nsILoadGroup_Release(This
->load_group
);
317 nsILoadGroup_AddRef(aLoadGroup
);
319 This
->load_group
= aLoadGroup
;
322 return nsIChannel_SetLoadGroup(This
->channel
, aLoadGroup
);
326 static nsresult NSAPI
nsChannel_GetLoadFlags(nsIHttpChannel
*iface
, nsLoadFlags
*aLoadFlags
)
328 nsChannel
*This
= NSCHANNEL_THIS(iface
);
330 TRACE("(%p)->(%p)\n", This
, aLoadFlags
);
332 *aLoadFlags
= This
->load_flags
;
336 static nsresult NSAPI
nsChannel_SetLoadFlags(nsIHttpChannel
*iface
, nsLoadFlags aLoadFlags
)
338 nsChannel
*This
= NSCHANNEL_THIS(iface
);
340 TRACE("(%p)->(%08x)\n", This
, aLoadFlags
);
342 This
->load_flags
= aLoadFlags
;
345 return nsIChannel_SetLoadFlags(This
->channel
, aLoadFlags
);
349 static nsresult NSAPI
nsChannel_GetOriginalURI(nsIHttpChannel
*iface
, nsIURI
**aOriginalURI
)
351 nsChannel
*This
= NSCHANNEL_THIS(iface
);
353 TRACE("(%p)->(%p)\n", This
, aOriginalURI
);
355 if(This
->original_uri
)
356 nsIURI_AddRef(This
->original_uri
);
358 *aOriginalURI
= This
->original_uri
;
362 static nsresult NSAPI
nsChannel_SetOriginalURI(nsIHttpChannel
*iface
, nsIURI
*aOriginalURI
)
364 nsChannel
*This
= NSCHANNEL_THIS(iface
);
366 TRACE("(%p)->(%p)\n", This
, aOriginalURI
);
368 if(This
->original_uri
)
369 nsIURI_Release(This
->original_uri
);
371 nsIURI_AddRef(aOriginalURI
);
372 This
->original_uri
= aOriginalURI
;
375 return nsIChannel_SetOriginalURI(This
->channel
, aOriginalURI
);
379 static nsresult NSAPI
nsChannel_GetURI(nsIHttpChannel
*iface
, nsIURI
**aURI
)
381 nsChannel
*This
= NSCHANNEL_THIS(iface
);
383 TRACE("(%p)->(%p)\n", This
, aURI
);
385 nsIWineURI_AddRef(This
->uri
);
386 *aURI
= (nsIURI
*)This
->uri
;
391 static nsresult NSAPI
nsChannel_GetOwner(nsIHttpChannel
*iface
, nsISupports
**aOwner
)
393 nsChannel
*This
= NSCHANNEL_THIS(iface
);
395 TRACE("(%p)->(%p)\n", This
, aOwner
);
398 return nsIChannel_GetOwner(This
->channel
, aOwner
);
400 FIXME("default action not implemented\n");
401 return NS_ERROR_NOT_IMPLEMENTED
;
404 static nsresult NSAPI
nsChannel_SetOwner(nsIHttpChannel
*iface
, nsISupports
*aOwner
)
406 nsChannel
*This
= NSCHANNEL_THIS(iface
);
408 TRACE("(%p)->(%p)\n", This
, aOwner
);
411 return nsIChannel_SetOwner(This
->channel
, aOwner
);
413 FIXME("default action not implemented\n");
414 return NS_ERROR_NOT_IMPLEMENTED
;
417 static nsresult NSAPI
nsChannel_GetNotificationCallbacks(nsIHttpChannel
*iface
,
418 nsIInterfaceRequestor
**aNotificationCallbacks
)
420 nsChannel
*This
= NSCHANNEL_THIS(iface
);
422 TRACE("(%p)->(%p)\n", This
, aNotificationCallbacks
);
424 if(This
->notif_callback
)
425 nsIInterfaceRequestor_AddRef(This
->notif_callback
);
426 *aNotificationCallbacks
= This
->notif_callback
;
431 static nsresult NSAPI
nsChannel_SetNotificationCallbacks(nsIHttpChannel
*iface
,
432 nsIInterfaceRequestor
*aNotificationCallbacks
)
434 nsChannel
*This
= NSCHANNEL_THIS(iface
);
436 TRACE("(%p)->(%p)\n", This
, aNotificationCallbacks
);
438 if(This
->notif_callback
)
439 nsIInterfaceRequestor_Release(This
->notif_callback
);
440 if(aNotificationCallbacks
)
441 nsIInterfaceRequestor_AddRef(aNotificationCallbacks
);
443 This
->notif_callback
= aNotificationCallbacks
;
446 return nsIChannel_SetNotificationCallbacks(This
->channel
, aNotificationCallbacks
);
450 static nsresult NSAPI
nsChannel_GetSecurityInfo(nsIHttpChannel
*iface
, nsISupports
**aSecurityInfo
)
452 nsChannel
*This
= NSCHANNEL_THIS(iface
);
454 TRACE("(%p)->(%p)\n", This
, aSecurityInfo
);
457 return nsIChannel_GetSecurityInfo(This
->channel
, aSecurityInfo
);
459 FIXME("default action not implemented\n");
460 return NS_ERROR_NOT_IMPLEMENTED
;
463 static nsresult NSAPI
nsChannel_GetContentType(nsIHttpChannel
*iface
, nsACString
*aContentType
)
465 nsChannel
*This
= NSCHANNEL_THIS(iface
);
467 TRACE("(%p)->(%p)\n", This
, aContentType
);
470 nsACString_SetData(aContentType
, This
->content
);
475 return nsIChannel_GetContentType(This
->channel
, aContentType
);
477 TRACE("returning default text/html\n");
478 nsACString_SetData(aContentType
, "text/html");
482 static nsresult NSAPI
nsChannel_SetContentType(nsIHttpChannel
*iface
,
483 const nsACString
*aContentType
)
485 nsChannel
*This
= NSCHANNEL_THIS(iface
);
487 TRACE("(%p)->(%p)\n", This
, aContentType
);
490 return nsIChannel_SetContentType(This
->channel
, aContentType
);
492 FIXME("default action not implemented\n");
493 return NS_ERROR_NOT_IMPLEMENTED
;
496 static nsresult NSAPI
nsChannel_GetContentCharset(nsIHttpChannel
*iface
,
497 nsACString
*aContentCharset
)
499 nsChannel
*This
= NSCHANNEL_THIS(iface
);
501 TRACE("(%p)->(%p)\n", This
, aContentCharset
);
504 nsACString_SetData(aContentCharset
, This
->charset
);
509 nsresult nsres
= nsIChannel_GetContentCharset(This
->channel
, aContentCharset
);
511 nsACString_GetData(aContentCharset
, &ch
);
515 nsACString_SetData(aContentCharset
, "");
519 static nsresult NSAPI
nsChannel_SetContentCharset(nsIHttpChannel
*iface
,
520 const nsACString
*aContentCharset
)
522 nsChannel
*This
= NSCHANNEL_THIS(iface
);
524 TRACE("(%p)->(%p)\n", This
, aContentCharset
);
527 return nsIChannel_SetContentCharset(This
->channel
, aContentCharset
);
529 FIXME("default action not implemented\n");
530 return NS_ERROR_NOT_IMPLEMENTED
;
533 static nsresult NSAPI
nsChannel_GetContentLength(nsIHttpChannel
*iface
, PRInt32
*aContentLength
)
535 nsChannel
*This
= NSCHANNEL_THIS(iface
);
537 TRACE("(%p)->(%p)\n", This
, aContentLength
);
540 return nsIChannel_GetContentLength(This
->channel
, aContentLength
);
542 FIXME("default action not implemented\n");
543 return NS_ERROR_NOT_IMPLEMENTED
;
546 static nsresult NSAPI
nsChannel_SetContentLength(nsIHttpChannel
*iface
, PRInt32 aContentLength
)
548 nsChannel
*This
= NSCHANNEL_THIS(iface
);
550 TRACE("(%p)->(%d)\n", This
, aContentLength
);
553 return nsIChannel_SetContentLength(This
->channel
, aContentLength
);
555 FIXME("default action not implemented\n");
556 return NS_ERROR_NOT_IMPLEMENTED
;
559 static nsresult NSAPI
nsChannel_Open(nsIHttpChannel
*iface
, nsIInputStream
**_retval
)
561 nsChannel
*This
= NSCHANNEL_THIS(iface
);
563 TRACE("(%p)->(%p)\n", This
, _retval
);
566 return nsIChannel_Open(This
->channel
, _retval
);
568 FIXME("default action not implemented\n");
569 return NS_ERROR_NOT_IMPLEMENTED
;
572 static BOOL
do_load_from_moniker_hack(nsChannel
*This
)
574 nsACString scheme_str
;
579 * We should always load the page from IMoniker, but Wine is not yet
580 * ready for this. This function is a heuristic, that decides which
581 * way of loading is better (Gecko implementation or IMoniker). The
582 * aim is to always return TRUE.
585 /* Load from moniker if there is no Gecko channel available */
589 nsACString_Init(&scheme_str
, NULL
);
590 nsres
= nsIWineURI_GetScheme(This
->uri
, &scheme_str
);
592 if(NS_SUCCEEDED(nsres
)) {
595 nsACString_GetData(&scheme_str
, &scheme
);
596 ret
= !strcmp(scheme
, "wine");
599 nsACString_Finish(&scheme_str
);
603 static HRESULT
create_mon_for_nschannel(nsChannel
*channel
, IMoniker
**mon
)
605 nsIWineURI
*wine_uri
;
610 if(!channel
->original_uri
) {
611 ERR("original_uri == NULL\n");
615 nsres
= nsIURI_QueryInterface(channel
->original_uri
, &IID_nsIWineURI
, (void**)&wine_uri
);
616 if(NS_FAILED(nsres
)) {
617 ERR("Could not get nsIWineURI: %08x\n", nsres
);
621 nsIWineURI_GetWineURL(wine_uri
, &wine_url
);
622 nsIWineURI_Release(wine_uri
);
624 TRACE("wine_url == NULL\n");
628 hres
= CreateURLMoniker(NULL
, wine_url
, mon
);
630 WARN("CreateURLMonikrer failed: %08x\n", hres
);
635 static nsresult
async_open_doc_uri(nsChannel
*This
, NSContainer
*container
,
636 nsIStreamListener
*listener
, nsISupports
*context
, BOOL
*open
)
643 if(container
->bscallback
) {
644 nsIChannel_AddRef(NSCHANNEL(This
));
645 container
->bscallback
->nschannel
= This
;
647 nsIStreamListener_AddRef(listener
);
648 container
->bscallback
->nslistener
= listener
;
651 nsISupports_AddRef(context
);
652 container
->bscallback
->nscontext
= context
;
655 if(container
->doc
&& container
->doc
->mime
) {
658 heap_free(This
->content
);
660 len
= WideCharToMultiByte(CP_ACP
, 0, container
->doc
->mime
, -1, NULL
, 0, NULL
, NULL
);
661 This
->content
= heap_alloc(len
);
662 WideCharToMultiByte(CP_ACP
, 0, container
->doc
->mime
, -1, This
->content
, -1, NULL
, NULL
);
665 if(do_load_from_moniker_hack(This
))
666 return WINE_NS_LOAD_FROM_MONIKER
;
668 BOOL cont
= before_async_open(This
, container
);
672 return NS_ERROR_UNEXPECTED
;
675 if(!container
->doc
) {
677 ? nsIChannel_AsyncOpen(This
->channel
, listener
, context
)
678 : NS_ERROR_UNEXPECTED
;
681 hres
= create_mon_for_nschannel(This
, &mon
);
683 return NS_ERROR_UNEXPECTED
;
685 set_current_mon(container
->doc
, mon
);
692 static nsresult
async_open(nsChannel
*This
, NSContainer
*container
, nsIStreamListener
*listener
,
693 nsISupports
*context
)
695 BSCallback
*bscallback
;
696 IMoniker
*mon
= NULL
;
702 if(This
->post_data_stream
) {
703 nsIUploadChannel
*upload_channel
;
705 nsres
= nsIChannel_QueryInterface(This
->channel
, &IID_nsIUploadChannel
,
706 (void**)&upload_channel
);
707 if(NS_SUCCEEDED(nsres
)) {
708 nsACString empty_string
;
709 nsACString_Init(&empty_string
, "");
711 nsres
= nsIUploadChannel_SetUploadStream(upload_channel
, This
->post_data_stream
,
713 nsIUploadChannel_Release(upload_channel
);
715 WARN("SetUploadStream failed: %08x\n", nsres
);
717 nsACString_Finish(&empty_string
);
721 nsres
= nsIChannel_AsyncOpen(This
->channel
, listener
, context
);
724 IMoniker_Release(mon
);
726 if(NS_FAILED(nsres
) && (This
->load_flags
& LOAD_INITIAL_DOCUMENT_URI
))
727 return WINE_NS_LOAD_FROM_MONIKER
;
731 TRACE("channel == NULL\n");
733 hres
= create_mon_for_nschannel(This
, &mon
);
735 return NS_ERROR_UNEXPECTED
;
737 bscallback
= create_bscallback(mon
);
738 IMoniker_Release(mon
);
740 nsIChannel_AddRef(NSCHANNEL(This
));
741 bscallback
->nschannel
= This
;
743 nsIStreamListener_AddRef(listener
);
744 bscallback
->nslistener
= listener
;
747 nsISupports_AddRef(context
);
748 bscallback
->nscontext
= context
;
751 task
= heap_alloc(sizeof(task_t
));
753 task
->doc
= container
->doc
;
754 task
->task_id
= TASK_START_BINDING
;
756 task
->bscallback
= bscallback
;
763 static nsresult NSAPI
nsChannel_AsyncOpen(nsIHttpChannel
*iface
, nsIStreamListener
*aListener
,
764 nsISupports
*aContext
)
766 nsChannel
*This
= NSCHANNEL_THIS(iface
);
767 NSContainer
*container
;
770 nsresult nsres
= NS_OK
;
772 TRACE("(%p)->(%p %p)\n", This
, aListener
, aContext
);
774 nsIWineURI_GetNSContainer(This
->uri
, &container
);
776 TRACE("container = NULL\n");
778 ? nsIChannel_AsyncOpen(This
->channel
, aListener
, aContext
)
779 : NS_ERROR_UNEXPECTED
;
782 nsIWineURI_GetIsDocumentURI(This
->uri
, &is_doc_uri
);
784 if(is_doc_uri
&& (This
->load_flags
& LOAD_INITIAL_DOCUMENT_URI
))
785 nsres
= async_open_doc_uri(This
, container
, aListener
, aContext
, &open
);
788 nsres
= async_open(This
, container
, aListener
, aContext
);
790 nsIWebBrowserChrome_Release(NSWBCHROME(container
));
794 static nsresult NSAPI
nsChannel_GetRequestMethod(nsIHttpChannel
*iface
, nsACString
*aRequestMethod
)
796 nsChannel
*This
= NSCHANNEL_THIS(iface
);
798 TRACE("(%p)->(%p)\n", This
, aRequestMethod
);
800 if(This
->http_channel
)
801 return nsIHttpChannel_GetRequestMethod(This
->http_channel
, aRequestMethod
);
803 return NS_ERROR_NOT_IMPLEMENTED
;
806 static nsresult NSAPI
nsChannel_SetRequestMethod(nsIHttpChannel
*iface
,
807 const nsACString
*aRequestMethod
)
809 nsChannel
*This
= NSCHANNEL_THIS(iface
);
811 TRACE("(%p)->(%p)\n", This
, aRequestMethod
);
813 if(This
->http_channel
)
814 return nsIHttpChannel_SetRequestMethod(This
->http_channel
, aRequestMethod
);
816 return NS_ERROR_NOT_IMPLEMENTED
;
819 static nsresult NSAPI
nsChannel_GetReferrer(nsIHttpChannel
*iface
, nsIURI
**aReferrer
)
821 nsChannel
*This
= NSCHANNEL_THIS(iface
);
823 TRACE("(%p)->(%p)\n", This
, aReferrer
);
825 if(This
->http_channel
)
826 return nsIHttpChannel_GetReferrer(This
->http_channel
, aReferrer
);
828 return NS_ERROR_NOT_IMPLEMENTED
;
831 static nsresult NSAPI
nsChannel_SetReferrer(nsIHttpChannel
*iface
, nsIURI
*aReferrer
)
833 nsChannel
*This
= NSCHANNEL_THIS(iface
);
835 TRACE("(%p)->(%p)\n", This
, aReferrer
);
837 if(This
->http_channel
)
838 return nsIHttpChannel_SetReferrer(This
->http_channel
, aReferrer
);
840 return NS_ERROR_NOT_IMPLEMENTED
;
843 static nsresult NSAPI
nsChannel_GetRequestHeader(nsIHttpChannel
*iface
,
844 const nsACString
*aHeader
, nsACString
*_retval
)
846 nsChannel
*This
= NSCHANNEL_THIS(iface
);
848 TRACE("(%p)->(%p %p)\n", This
, aHeader
, _retval
);
850 if(This
->http_channel
)
851 return nsIHttpChannel_GetRequestHeader(This
->http_channel
, aHeader
, _retval
);
853 return NS_ERROR_NOT_IMPLEMENTED
;
856 static nsresult NSAPI
nsChannel_SetRequestHeader(nsIHttpChannel
*iface
,
857 const nsACString
*aHeader
, const nsACString
*aValue
, PRBool aMerge
)
859 nsChannel
*This
= NSCHANNEL_THIS(iface
);
861 TRACE("(%p)->(%p %p %x)\n", This
, aHeader
, aValue
, aMerge
);
863 if(This
->http_channel
)
864 return nsIHttpChannel_SetRequestHeader(This
->http_channel
, aHeader
, aValue
, aMerge
);
866 return NS_ERROR_NOT_IMPLEMENTED
;
869 static nsresult NSAPI
nsChannel_VisitRequestHeaders(nsIHttpChannel
*iface
,
870 nsIHttpHeaderVisitor
*aVisitor
)
872 nsChannel
*This
= NSCHANNEL_THIS(iface
);
874 TRACE("(%p)->(%p)\n", This
, aVisitor
);
876 if(This
->http_channel
)
877 return nsIHttpChannel_VisitRequestHeaders(This
->http_channel
, aVisitor
);
879 return NS_ERROR_NOT_IMPLEMENTED
;
882 static nsresult NSAPI
nsChannel_GetAllowPipelining(nsIHttpChannel
*iface
, PRBool
*aAllowPipelining
)
884 nsChannel
*This
= NSCHANNEL_THIS(iface
);
886 TRACE("(%p)->(%p)\n", This
, aAllowPipelining
);
888 if(This
->http_channel
)
889 return nsIHttpChannel_GetAllowPipelining(This
->http_channel
, aAllowPipelining
);
891 return NS_ERROR_NOT_IMPLEMENTED
;
894 static nsresult NSAPI
nsChannel_SetAllowPipelining(nsIHttpChannel
*iface
, PRBool aAllowPipelining
)
896 nsChannel
*This
= NSCHANNEL_THIS(iface
);
898 TRACE("(%p)->(%x)\n", This
, aAllowPipelining
);
900 if(This
->http_channel
)
901 return nsIHttpChannel_SetAllowPipelining(This
->http_channel
, aAllowPipelining
);
903 return NS_ERROR_NOT_IMPLEMENTED
;
906 static nsresult NSAPI
nsChannel_GetRedirectionLimit(nsIHttpChannel
*iface
, PRUint32
*aRedirectionLimit
)
908 nsChannel
*This
= NSCHANNEL_THIS(iface
);
910 TRACE("(%p)->(%p)\n", This
, aRedirectionLimit
);
912 if(This
->http_channel
)
913 return nsIHttpChannel_GetRedirectionLimit(This
->http_channel
, aRedirectionLimit
);
915 return NS_ERROR_NOT_IMPLEMENTED
;
918 static nsresult NSAPI
nsChannel_SetRedirectionLimit(nsIHttpChannel
*iface
, PRUint32 aRedirectionLimit
)
920 nsChannel
*This
= NSCHANNEL_THIS(iface
);
922 TRACE("(%p)->(%u)\n", This
, aRedirectionLimit
);
924 if(This
->http_channel
)
925 return nsIHttpChannel_SetRedirectionLimit(This
->http_channel
, aRedirectionLimit
);
927 return NS_ERROR_NOT_IMPLEMENTED
;
930 static nsresult NSAPI
nsChannel_GetResponseStatus(nsIHttpChannel
*iface
, PRUint32
*aResponseStatus
)
932 nsChannel
*This
= NSCHANNEL_THIS(iface
);
934 TRACE("(%p)->(%p)\n", This
, aResponseStatus
);
936 if(This
->http_channel
)
937 return nsIHttpChannel_GetResponseStatus(This
->http_channel
, aResponseStatus
);
939 return NS_ERROR_NOT_IMPLEMENTED
;
942 static nsresult NSAPI
nsChannel_GetResponseStatusText(nsIHttpChannel
*iface
,
943 nsACString
*aResponseStatusText
)
945 nsChannel
*This
= NSCHANNEL_THIS(iface
);
947 TRACE("(%p)->(%p)\n", This
, aResponseStatusText
);
949 if(This
->http_channel
)
950 return nsIHttpChannel_GetResponseStatusText(This
->http_channel
, aResponseStatusText
);
952 return NS_ERROR_NOT_IMPLEMENTED
;
955 static nsresult NSAPI
nsChannel_GetRequestSucceeded(nsIHttpChannel
*iface
,
956 PRBool
*aRequestSucceeded
)
958 nsChannel
*This
= NSCHANNEL_THIS(iface
);
960 TRACE("(%p)->(%p)\n", This
, aRequestSucceeded
);
962 if(This
->http_channel
)
963 return nsIHttpChannel_GetRequestSucceeded(This
->http_channel
, aRequestSucceeded
);
965 return NS_ERROR_NOT_IMPLEMENTED
;
968 static nsresult NSAPI
nsChannel_GetResponseHeader(nsIHttpChannel
*iface
,
969 const nsACString
*header
, nsACString
*_retval
)
971 nsChannel
*This
= NSCHANNEL_THIS(iface
);
973 TRACE("(%p)->(%p %p)\n", This
, header
, _retval
);
975 if(This
->http_channel
)
976 return nsIHttpChannel_GetResponseHeader(This
->http_channel
, header
, _retval
);
978 return NS_ERROR_NOT_IMPLEMENTED
;
981 static nsresult NSAPI
nsChannel_SetResponseHeader(nsIHttpChannel
*iface
,
982 const nsACString
*header
, const nsACString
*value
, PRBool merge
)
984 nsChannel
*This
= NSCHANNEL_THIS(iface
);
986 TRACE("(%p)->(%p %p %x)\n", This
, header
, value
, merge
);
988 if(This
->http_channel
)
989 return nsIHttpChannel_SetResponseHeader(This
->http_channel
, header
, value
, merge
);
991 return NS_ERROR_NOT_IMPLEMENTED
;
994 static nsresult NSAPI
nsChannel_VisitResponseHeaders(nsIHttpChannel
*iface
,
995 nsIHttpHeaderVisitor
*aVisitor
)
997 nsChannel
*This
= NSCHANNEL_THIS(iface
);
999 TRACE("(%p)->(%p)\n", This
, aVisitor
);
1001 if(This
->http_channel
)
1002 return nsIHttpChannel_VisitResponseHeaders(This
->http_channel
, aVisitor
);
1004 return NS_ERROR_NOT_IMPLEMENTED
;
1007 static nsresult NSAPI
nsChannel_IsNoStoreResponse(nsIHttpChannel
*iface
, PRBool
*_retval
)
1009 nsChannel
*This
= NSCHANNEL_THIS(iface
);
1011 TRACE("(%p)->(%p)\n", This
, _retval
);
1013 if(This
->http_channel
)
1014 return nsIHttpChannel_IsNoStoreResponse(This
->http_channel
, _retval
);
1016 return NS_ERROR_NOT_IMPLEMENTED
;
1019 static nsresult NSAPI
nsChannel_IsNoCacheResponse(nsIHttpChannel
*iface
, PRBool
*_retval
)
1021 nsChannel
*This
= NSCHANNEL_THIS(iface
);
1023 TRACE("(%p)->(%p)\n", This
, _retval
);
1025 if(This
->http_channel
)
1026 return nsIHttpChannel_IsNoCacheResponse(This
->http_channel
, _retval
);
1028 return NS_ERROR_NOT_IMPLEMENTED
;
1031 #undef NSCHANNEL_THIS
1033 static const nsIHttpChannelVtbl nsChannelVtbl
= {
1034 nsChannel_QueryInterface
,
1038 nsChannel_IsPending
,
1039 nsChannel_GetStatus
,
1043 nsChannel_GetLoadGroup
,
1044 nsChannel_SetLoadGroup
,
1045 nsChannel_GetLoadFlags
,
1046 nsChannel_SetLoadFlags
,
1047 nsChannel_GetOriginalURI
,
1048 nsChannel_SetOriginalURI
,
1052 nsChannel_GetNotificationCallbacks
,
1053 nsChannel_SetNotificationCallbacks
,
1054 nsChannel_GetSecurityInfo
,
1055 nsChannel_GetContentType
,
1056 nsChannel_SetContentType
,
1057 nsChannel_GetContentCharset
,
1058 nsChannel_SetContentCharset
,
1059 nsChannel_GetContentLength
,
1060 nsChannel_SetContentLength
,
1062 nsChannel_AsyncOpen
,
1063 nsChannel_GetRequestMethod
,
1064 nsChannel_SetRequestMethod
,
1065 nsChannel_GetReferrer
,
1066 nsChannel_SetReferrer
,
1067 nsChannel_GetRequestHeader
,
1068 nsChannel_SetRequestHeader
,
1069 nsChannel_VisitRequestHeaders
,
1070 nsChannel_GetAllowPipelining
,
1071 nsChannel_SetAllowPipelining
,
1072 nsChannel_GetRedirectionLimit
,
1073 nsChannel_SetRedirectionLimit
,
1074 nsChannel_GetResponseStatus
,
1075 nsChannel_GetResponseStatusText
,
1076 nsChannel_GetRequestSucceeded
,
1077 nsChannel_GetResponseHeader
,
1078 nsChannel_SetResponseHeader
,
1079 nsChannel_VisitResponseHeaders
,
1080 nsChannel_IsNoStoreResponse
,
1081 nsChannel_IsNoCacheResponse
1084 #define NSUPCHANNEL_THIS(iface) DEFINE_THIS(nsChannel, UploadChannel, iface)
1086 static nsresult NSAPI
nsUploadChannel_QueryInterface(nsIUploadChannel
*iface
, nsIIDRef riid
,
1089 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1090 return nsIChannel_QueryInterface(NSCHANNEL(This
), riid
, result
);
1093 static nsrefcnt NSAPI
nsUploadChannel_AddRef(nsIUploadChannel
*iface
)
1095 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1096 return nsIChannel_AddRef(NSCHANNEL(This
));
1099 static nsrefcnt NSAPI
nsUploadChannel_Release(nsIUploadChannel
*iface
)
1101 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1102 return nsIChannel_Release(NSCHANNEL(This
));
1105 static nsresult NSAPI
nsUploadChannel_SetUploadStream(nsIUploadChannel
*iface
,
1106 nsIInputStream
*aStream
, const nsACString
*aContentType
, PRInt32 aContentLength
)
1108 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1109 const char *content_type
;
1111 TRACE("(%p)->(%p %p %d)\n", This
, aStream
, aContentType
, aContentLength
);
1113 if(This
->post_data_stream
)
1114 nsIInputStream_Release(This
->post_data_stream
);
1117 nsACString_GetData(aContentType
, &content_type
);
1119 FIXME("Unsupported aContentType argument: %s\n", debugstr_a(content_type
));
1122 if(aContentLength
!= -1)
1123 FIXME("Unsupported acontentLength = %d\n", aContentLength
);
1126 nsIInputStream_AddRef(aStream
);
1127 This
->post_data_stream
= aStream
;
1132 static nsresult NSAPI
nsUploadChannel_GetUploadStream(nsIUploadChannel
*iface
,
1133 nsIInputStream
**aUploadStream
)
1135 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1137 TRACE("(%p)->(%p)\n", This
, aUploadStream
);
1139 if(This
->post_data_stream
)
1140 nsIInputStream_AddRef(This
->post_data_stream
);
1142 *aUploadStream
= This
->post_data_stream
;
1146 #undef NSUPCHANNEL_THIS
1148 static const nsIUploadChannelVtbl nsUploadChannelVtbl
= {
1149 nsUploadChannel_QueryInterface
,
1150 nsUploadChannel_AddRef
,
1151 nsUploadChannel_Release
,
1152 nsUploadChannel_SetUploadStream
,
1153 nsUploadChannel_GetUploadStream
1156 #define NSURI_THIS(iface) DEFINE_THIS(nsURI, WineURI, iface)
1158 static nsresult NSAPI
nsURI_QueryInterface(nsIWineURI
*iface
, nsIIDRef riid
, nsQIResult result
)
1160 nsURI
*This
= NSURI_THIS(iface
);
1164 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
1165 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
1166 *result
= NSURI(This
);
1167 }else if(IsEqualGUID(&IID_nsIURI
, riid
)) {
1168 TRACE("(%p)->(IID_nsIURI %p)\n", This
, result
);
1169 *result
= NSURI(This
);
1170 }else if(IsEqualGUID(&IID_nsIWineURI
, riid
)) {
1171 TRACE("(%p)->(IID_nsIWineURI %p)\n", This
, result
);
1172 *result
= NSURI(This
);
1176 nsIURI_AddRef(NSURI(This
));
1180 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), result
);
1181 return This
->uri
? nsIURI_QueryInterface(This
->uri
, riid
, result
) : NS_NOINTERFACE
;
1184 static nsrefcnt NSAPI
nsURI_AddRef(nsIWineURI
*iface
)
1186 nsURI
*This
= NSURI_THIS(iface
);
1187 LONG ref
= InterlockedIncrement(&This
->ref
);
1189 TRACE("(%p) ref=%d\n", This
, ref
);
1194 static nsrefcnt NSAPI
nsURI_Release(nsIWineURI
*iface
)
1196 nsURI
*This
= NSURI_THIS(iface
);
1197 LONG ref
= InterlockedDecrement(&This
->ref
);
1199 TRACE("(%p) ref=%d\n", This
, ref
);
1203 nsIWebBrowserChrome_Release(NSWBCHROME(This
->container
));
1205 nsIURI_Release(This
->uri
);
1206 heap_free(This
->wine_url
);
1213 static nsresult NSAPI
nsURI_GetSpec(nsIWineURI
*iface
, nsACString
*aSpec
)
1215 nsURI
*This
= NSURI_THIS(iface
);
1217 TRACE("(%p)->(%p)\n", This
, aSpec
);
1219 if(This
->use_wine_url
) {
1220 char speca
[INTERNET_MAX_URL_LENGTH
] = "wine:";
1221 WideCharToMultiByte(CP_ACP
, 0, This
->wine_url
, -1, speca
+5, sizeof(speca
)-5, NULL
, NULL
);
1222 nsACString_SetData(aSpec
, speca
);
1228 return nsIURI_GetSpec(This
->uri
, aSpec
);
1230 TRACE("returning error\n");
1231 return NS_ERROR_NOT_IMPLEMENTED
;
1235 static nsresult NSAPI
nsURI_SetSpec(nsIWineURI
*iface
, const nsACString
*aSpec
)
1237 nsURI
*This
= NSURI_THIS(iface
);
1239 TRACE("(%p)->(%p)\n", This
, aSpec
);
1242 return nsIURI_SetSpec(This
->uri
, aSpec
);
1244 FIXME("default action not implemented\n");
1245 return NS_ERROR_NOT_IMPLEMENTED
;
1248 static nsresult NSAPI
nsURI_GetPrePath(nsIWineURI
*iface
, nsACString
*aPrePath
)
1250 nsURI
*This
= NSURI_THIS(iface
);
1252 TRACE("(%p)->(%p)\n", This
, aPrePath
);
1255 return nsIURI_GetPrePath(This
->uri
, aPrePath
);
1257 FIXME("default action not implemented\n");
1258 return NS_ERROR_NOT_IMPLEMENTED
;
1261 static nsresult NSAPI
nsURI_GetScheme(nsIWineURI
*iface
, nsACString
*aScheme
)
1263 nsURI
*This
= NSURI_THIS(iface
);
1265 TRACE("(%p)->(%p)\n", This
, aScheme
);
1267 if(This
->use_wine_url
) {
1269 * For Gecko we set scheme to unknown so it won't be handled
1270 * as any special case.
1272 nsACString_SetData(aScheme
, "wine");
1277 return nsIURI_GetScheme(This
->uri
, aScheme
);
1279 TRACE("returning error\n");
1280 return NS_ERROR_NOT_IMPLEMENTED
;
1283 static nsresult NSAPI
nsURI_SetScheme(nsIWineURI
*iface
, const nsACString
*aScheme
)
1285 nsURI
*This
= NSURI_THIS(iface
);
1287 TRACE("(%p)->(%p)\n", This
, aScheme
);
1290 return nsIURI_SetScheme(This
->uri
, aScheme
);
1292 FIXME("default action not implemented\n");
1293 return NS_ERROR_NOT_IMPLEMENTED
;
1296 static nsresult NSAPI
nsURI_GetUserPass(nsIWineURI
*iface
, nsACString
*aUserPass
)
1298 nsURI
*This
= NSURI_THIS(iface
);
1300 TRACE("(%p)->(%p)\n", This
, aUserPass
);
1303 return nsIURI_GetUserPass(This
->uri
, aUserPass
);
1305 FIXME("default action not implemented\n");
1306 return NS_ERROR_NOT_IMPLEMENTED
;
1309 static nsresult NSAPI
nsURI_SetUserPass(nsIWineURI
*iface
, const nsACString
*aUserPass
)
1311 nsURI
*This
= NSURI_THIS(iface
);
1313 TRACE("(%p)->(%p)\n", This
, aUserPass
);
1316 return nsIURI_SetUserPass(This
->uri
, aUserPass
);
1318 FIXME("default action not implemented\n");
1319 return NS_ERROR_NOT_IMPLEMENTED
;
1322 static nsresult NSAPI
nsURI_GetUsername(nsIWineURI
*iface
, nsACString
*aUsername
)
1324 nsURI
*This
= NSURI_THIS(iface
);
1326 TRACE("(%p)->(%p)\n", This
, aUsername
);
1329 return nsIURI_GetUsername(This
->uri
, aUsername
);
1331 FIXME("default action not implemented\n");
1332 return NS_ERROR_NOT_IMPLEMENTED
;
1335 static nsresult NSAPI
nsURI_SetUsername(nsIWineURI
*iface
, const nsACString
*aUsername
)
1337 nsURI
*This
= NSURI_THIS(iface
);
1339 TRACE("(%p)->(%p)\n", This
, aUsername
);
1342 return nsIURI_SetUsername(This
->uri
, aUsername
);
1344 FIXME("default action not implemented\n");
1345 return NS_ERROR_NOT_IMPLEMENTED
;
1348 static nsresult NSAPI
nsURI_GetPassword(nsIWineURI
*iface
, nsACString
*aPassword
)
1350 nsURI
*This
= NSURI_THIS(iface
);
1352 TRACE("(%p)->(%p)\n", This
, aPassword
);
1355 return nsIURI_GetPassword(This
->uri
, aPassword
);
1357 FIXME("default action not implemented\n");
1358 return NS_ERROR_NOT_IMPLEMENTED
;
1361 static nsresult NSAPI
nsURI_SetPassword(nsIWineURI
*iface
, const nsACString
*aPassword
)
1363 nsURI
*This
= NSURI_THIS(iface
);
1365 TRACE("(%p)->(%p)\n", This
, aPassword
);
1368 return nsIURI_SetPassword(This
->uri
, aPassword
);
1370 FIXME("default action not implemented\n");
1371 return NS_ERROR_NOT_IMPLEMENTED
;
1374 static nsresult NSAPI
nsURI_GetHostPort(nsIWineURI
*iface
, nsACString
*aHostPort
)
1376 nsURI
*This
= NSURI_THIS(iface
);
1378 TRACE("(%p)->(%p)\n", This
, aHostPort
);
1381 return nsIURI_GetHostPort(This
->uri
, aHostPort
);
1383 FIXME("default action not implemented\n");
1384 return NS_ERROR_NOT_IMPLEMENTED
;
1387 static nsresult NSAPI
nsURI_SetHostPort(nsIWineURI
*iface
, const nsACString
*aHostPort
)
1389 nsURI
*This
= NSURI_THIS(iface
);
1391 TRACE("(%p)->(%p)\n", This
, aHostPort
);
1394 return nsIURI_SetHostPort(This
->uri
, aHostPort
);
1396 FIXME("default action not implemented\n");
1397 return NS_ERROR_NOT_IMPLEMENTED
;
1400 static nsresult NSAPI
nsURI_GetHost(nsIWineURI
*iface
, nsACString
*aHost
)
1402 nsURI
*This
= NSURI_THIS(iface
);
1404 TRACE("(%p)->(%p)\n", This
, aHost
);
1407 return nsIURI_GetHost(This
->uri
, aHost
);
1409 FIXME("default action not implemented\n");
1410 return NS_ERROR_NOT_IMPLEMENTED
;
1413 static nsresult NSAPI
nsURI_SetHost(nsIWineURI
*iface
, const nsACString
*aHost
)
1415 nsURI
*This
= NSURI_THIS(iface
);
1417 TRACE("(%p)->(%p)\n", This
, aHost
);
1420 return nsIURI_SetHost(This
->uri
, aHost
);
1422 FIXME("default action not implemented\n");
1423 return NS_ERROR_NOT_IMPLEMENTED
;
1426 static nsresult NSAPI
nsURI_GetPort(nsIWineURI
*iface
, PRInt32
*aPort
)
1428 nsURI
*This
= NSURI_THIS(iface
);
1430 TRACE("(%p)->(%p)\n", This
, aPort
);
1433 return nsIURI_GetPort(This
->uri
, aPort
);
1435 FIXME("default action not implemented\n");
1436 return NS_ERROR_NOT_IMPLEMENTED
;
1439 static nsresult NSAPI
nsURI_SetPort(nsIWineURI
*iface
, PRInt32 aPort
)
1441 nsURI
*This
= NSURI_THIS(iface
);
1443 TRACE("(%p)->(%d)\n", This
, aPort
);
1446 return nsIURI_SetPort(This
->uri
, aPort
);
1448 FIXME("default action not implemented\n");
1449 return NS_ERROR_NOT_IMPLEMENTED
;
1452 static nsresult NSAPI
nsURI_GetPath(nsIWineURI
*iface
, nsACString
*aPath
)
1454 nsURI
*This
= NSURI_THIS(iface
);
1456 TRACE("(%p)->(%p)\n", This
, aPath
);
1459 return nsIURI_GetPath(This
->uri
, aPath
);
1461 FIXME("default action not implemented\n");
1462 return NS_ERROR_NOT_IMPLEMENTED
;
1465 static nsresult NSAPI
nsURI_SetPath(nsIWineURI
*iface
, const nsACString
*aPath
)
1467 nsURI
*This
= NSURI_THIS(iface
);
1470 nsACString_GetData(aPath
, &path
);
1471 TRACE("(%p)->(%p(%s))\n", This
, aPath
, debugstr_a(path
));
1474 if(This
->wine_url
) {
1475 WCHAR new_url
[INTERNET_MAX_URL_LENGTH
];
1476 DWORD size
= sizeof(new_url
)/sizeof(WCHAR
);
1480 pathw
= heap_strdupAtoW(path
);
1481 hres
= UrlCombineW(This
->wine_url
, pathw
, new_url
, &size
, 0);
1484 nsIWineURI_SetWineURL(NSWINEURI(This
), new_url
);
1486 WARN("UrlCombine failed: %08x\n", hres
);
1492 return nsIURI_SetPath(This
->uri
, aPath
);
1495 static nsresult NSAPI
nsURI_Equals(nsIWineURI
*iface
, nsIURI
*other
, PRBool
*_retval
)
1497 nsURI
*This
= NSURI_THIS(iface
);
1499 TRACE("(%p)->(%p %p)\n", This
, other
, _retval
);
1502 return nsIURI_Equals(This
->uri
, other
, _retval
);
1504 FIXME("default action not implemented\n");
1505 return NS_ERROR_NOT_IMPLEMENTED
;
1508 static nsresult NSAPI
nsURI_SchemeIs(nsIWineURI
*iface
, const char *scheme
, PRBool
*_retval
)
1510 nsURI
*This
= NSURI_THIS(iface
);
1512 TRACE("(%p)->(%s %p)\n", This
, debugstr_a(scheme
), _retval
);
1514 if(This
->use_wine_url
) {
1515 WCHAR buf
[INTERNET_MAX_SCHEME_LENGTH
];
1516 int len
= MultiByteToWideChar(CP_ACP
, 0, scheme
, -1, buf
, sizeof(buf
)/sizeof(WCHAR
))-1;
1518 *_retval
= strlenW(This
->wine_url
) > len
1519 && This
->wine_url
[len
] == ':'
1520 && !memcmp(buf
, This
->wine_url
, len
*sizeof(WCHAR
));
1525 return nsIURI_SchemeIs(This
->uri
, scheme
, _retval
);
1527 TRACE("returning error\n");
1528 return NS_ERROR_NOT_IMPLEMENTED
;
1531 static nsresult NSAPI
nsURI_Clone(nsIWineURI
*iface
, nsIURI
**_retval
)
1533 nsURI
*This
= NSURI_THIS(iface
);
1535 TRACE("(%p)->(%p)\n", This
, _retval
);
1539 nsIWineURI
*wine_uri
;
1542 nsres
= nsIURI_Clone(This
->uri
, &uri
);
1543 if(NS_FAILED(nsres
)) {
1544 WARN("Clone failed: %08x\n", nsres
);
1548 nsres
= create_uri(uri
, This
->container
, &wine_uri
);
1549 *_retval
= (nsIURI
*)wine_uri
;
1550 if(NS_SUCCEEDED(nsres
))
1551 return nsIWineURI_SetWineURL(wine_uri
, This
->wine_url
);
1555 FIXME("default action not implemented\n");
1556 return NS_ERROR_NOT_IMPLEMENTED
;
1559 static nsresult NSAPI
nsURI_Resolve(nsIWineURI
*iface
, const nsACString
*arelativePath
,
1560 nsACString
*_retval
)
1562 nsURI
*This
= NSURI_THIS(iface
);
1564 TRACE("(%p)->(%p %p)\n", This
, arelativePath
, _retval
);
1567 return nsIURI_Resolve(This
->uri
, arelativePath
, _retval
);
1569 FIXME("default action not implemented\n");
1570 return NS_ERROR_NOT_IMPLEMENTED
;
1573 static nsresult NSAPI
nsURI_GetAsciiSpec(nsIWineURI
*iface
, nsACString
*aAsciiSpec
)
1575 nsURI
*This
= NSURI_THIS(iface
);
1577 TRACE("(%p)->(%p)\n", This
, aAsciiSpec
);
1579 if(This
->use_wine_url
)
1580 return nsIURI_GetSpec(NSURI(This
), aAsciiSpec
);
1583 return nsIURI_GetAsciiSpec(This
->uri
, aAsciiSpec
);
1585 TRACE("returning error\n");
1586 return NS_ERROR_NOT_IMPLEMENTED
;
1589 static nsresult NSAPI
nsURI_GetAsciiHost(nsIWineURI
*iface
, nsACString
*aAsciiHost
)
1591 nsURI
*This
= NSURI_THIS(iface
);
1593 TRACE("(%p)->(%p)\n", This
, aAsciiHost
);
1596 return nsIURI_GetAsciiHost(This
->uri
, aAsciiHost
);
1598 FIXME("default action not implemented\n");
1599 return NS_ERROR_NOT_IMPLEMENTED
;
1602 static nsresult NSAPI
nsURI_GetOriginCharset(nsIWineURI
*iface
, nsACString
*aOriginCharset
)
1604 nsURI
*This
= NSURI_THIS(iface
);
1606 TRACE("(%p)->(%p)\n", This
, aOriginCharset
);
1609 return nsIURI_GetOriginCharset(This
->uri
, aOriginCharset
);
1611 FIXME("default action not implemented\n");
1612 return NS_ERROR_NOT_IMPLEMENTED
;
1615 static nsresult NSAPI
nsURI_GetNSContainer(nsIWineURI
*iface
, NSContainer
**aContainer
)
1617 nsURI
*This
= NSURI_THIS(iface
);
1619 TRACE("(%p)->(%p)\n", This
, aContainer
);
1622 nsIWebBrowserChrome_AddRef(NSWBCHROME(This
->container
));
1623 *aContainer
= This
->container
;
1628 static nsresult NSAPI
nsURI_SetNSContainer(nsIWineURI
*iface
, NSContainer
*aContainer
)
1630 nsURI
*This
= NSURI_THIS(iface
);
1632 TRACE("(%p)->(%p)\n", This
, aContainer
);
1634 if(This
->container
) {
1635 if(This
->container
== aContainer
)
1637 TRACE("Changing %p -> %p\n", This
->container
, aContainer
);
1638 nsIWebBrowserChrome_Release(NSWBCHROME(This
->container
));
1642 nsIWebBrowserChrome_AddRef(NSWBCHROME(aContainer
));
1643 This
->container
= aContainer
;
1648 static nsresult NSAPI
nsURI_GetIsDocumentURI(nsIWineURI
*iface
, PRBool
*aIsDocumentURI
)
1650 nsURI
*This
= NSURI_THIS(iface
);
1652 TRACE("(%p)->(%p)\n", This
, aIsDocumentURI
);
1654 *aIsDocumentURI
= This
->is_doc_uri
;
1658 static nsresult NSAPI
nsURI_SetIsDocumentURI(nsIWineURI
*iface
, PRBool aIsDocumentURI
)
1660 nsURI
*This
= NSURI_THIS(iface
);
1662 TRACE("(%p)->(%x)\n", This
, aIsDocumentURI
);
1664 This
->is_doc_uri
= aIsDocumentURI
;
1668 static nsresult NSAPI
nsURI_GetWineURL(nsIWineURI
*iface
, LPCWSTR
*aURL
)
1670 nsURI
*This
= NSURI_THIS(iface
);
1672 TRACE("(%p)->(%p)\n", This
, aURL
);
1674 *aURL
= This
->wine_url
;
1678 static nsresult NSAPI
nsURI_SetWineURL(nsIWineURI
*iface
, LPCWSTR aURL
)
1680 nsURI
*This
= NSURI_THIS(iface
);
1682 static const WCHAR wszFtp
[] = {'f','t','p',':'};
1683 static const WCHAR wszHttp
[] = {'h','t','t','p',':'};
1684 static const WCHAR wszHttps
[] = {'h','t','t','p','s',':'};
1686 TRACE("(%p)->(%s)\n", This
, debugstr_w(aURL
));
1688 heap_free(This
->wine_url
);
1691 int len
= strlenW(aURL
)+1;
1692 This
->wine_url
= heap_alloc(len
*sizeof(WCHAR
));
1693 memcpy(This
->wine_url
, aURL
, len
*sizeof(WCHAR
));
1695 /* FIXME: Always use wine url */
1696 This
->use_wine_url
=
1697 strncmpW(aURL
, wszFtp
, sizeof(wszFtp
)/sizeof(WCHAR
))
1698 && strncmpW(aURL
, wszHttp
, sizeof(wszHttp
)/sizeof(WCHAR
))
1699 && strncmpW(aURL
, wszHttps
, sizeof(wszHttps
)/sizeof(WCHAR
));
1701 This
->wine_url
= NULL
;
1702 This
->use_wine_url
= FALSE
;
1710 static const nsIWineURIVtbl nsWineURIVtbl
= {
1711 nsURI_QueryInterface
,
1739 nsURI_GetOriginCharset
,
1740 nsURI_GetNSContainer
,
1741 nsURI_SetNSContainer
,
1742 nsURI_GetIsDocumentURI
,
1743 nsURI_SetIsDocumentURI
,
1748 static nsresult
create_uri(nsIURI
*uri
, NSContainer
*container
, nsIWineURI
**_retval
)
1750 nsURI
*ret
= heap_alloc(sizeof(nsURI
));
1752 ret
->lpWineURIVtbl
= &nsWineURIVtbl
;
1755 ret
->container
= container
;
1756 ret
->wine_url
= NULL
;
1757 ret
->is_doc_uri
= FALSE
;
1758 ret
->use_wine_url
= FALSE
;
1761 nsIWebBrowserChrome_AddRef(NSWBCHROME(container
));
1763 TRACE("retval=%p\n", ret
);
1764 *_retval
= NSWINEURI(ret
);
1769 const nsIProtocolHandlerVtbl
*lpProtocolHandlerVtbl
;
1773 nsIProtocolHandler
*nshandler
;
1774 } nsProtocolHandler
;
1776 #define NSPROTHANDLER(x) ((nsIProtocolHandler*) &(x)->lpProtocolHandlerVtbl)
1778 #define NSPROTHANDLER_THIS(iface) DEFINE_THIS(nsProtocolHandler, ProtocolHandler, iface)
1780 static nsresult NSAPI
nsProtocolHandler_QueryInterface(nsIProtocolHandler
*iface
, nsIIDRef riid
,
1783 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
1787 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
1788 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
1789 *result
= NSPROTHANDLER(This
);
1790 }else if(IsEqualGUID(&IID_nsIProtocolHandler
, riid
)) {
1791 TRACE("(%p)->(IID_nsIProtocolHandler %p)\n", This
, result
);
1792 *result
= NSPROTHANDLER(This
);
1793 }else if(IsEqualGUID(&IID_nsIExternalProtocolHandler
, riid
)) {
1794 TRACE("(%p)->(IID_nsIExternalProtocolHandler %p), returning NULL\n", This
, result
);
1795 return NS_NOINTERFACE
;
1799 nsISupports_AddRef((nsISupports
*)*result
);
1803 WARN("(%s %p)\n", debugstr_guid(riid
), result
);
1804 return NS_NOINTERFACE
;
1807 static nsrefcnt NSAPI
nsProtocolHandler_AddRef(nsIProtocolHandler
*iface
)
1809 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
1810 LONG ref
= InterlockedIncrement(&This
->ref
);
1812 TRACE("(%p) ref=%d\n", This
, ref
);
1817 static nsrefcnt NSAPI
nsProtocolHandler_Release(nsIProtocolHandler
*iface
)
1819 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
1820 LONG ref
= InterlockedDecrement(&This
->ref
);
1822 TRACE("(%p) ref=%d\n", This
, ref
);
1826 nsIProtocolHandler_Release(This
->nshandler
);
1833 static nsresult NSAPI
nsProtocolHandler_GetScheme(nsIProtocolHandler
*iface
, nsACString
*aScheme
)
1835 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
1837 TRACE("(%p)->(%p)\n", This
, aScheme
);
1840 return nsIProtocolHandler_GetScheme(This
->nshandler
, aScheme
);
1841 return NS_ERROR_NOT_IMPLEMENTED
;
1844 static nsresult NSAPI
nsProtocolHandler_GetDefaultPort(nsIProtocolHandler
*iface
,
1845 PRInt32
*aDefaultPort
)
1847 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
1849 TRACE("(%p)->(%p)\n", This
, aDefaultPort
);
1852 return nsIProtocolHandler_GetDefaultPort(This
->nshandler
, aDefaultPort
);
1853 return NS_ERROR_NOT_IMPLEMENTED
;
1856 static nsresult NSAPI
nsProtocolHandler_GetProtocolFlags(nsIProtocolHandler
*iface
,
1857 PRUint32
*aProtocolFlags
)
1859 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
1861 TRACE("(%p)->(%p)\n", This
, aProtocolFlags
);
1864 return nsIProtocolHandler_GetProtocolFlags(This
->nshandler
, aProtocolFlags
);
1865 return NS_ERROR_NOT_IMPLEMENTED
;
1868 static nsresult NSAPI
nsProtocolHandler_NewURI(nsIProtocolHandler
*iface
,
1869 const nsACString
*aSpec
, const char *aOriginCharset
, nsIURI
*aBaseURI
, nsIURI
**_retval
)
1871 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
1873 TRACE("((%p)->%p %s %p %p)\n", This
, aSpec
, debugstr_a(aOriginCharset
), aBaseURI
, _retval
);
1876 return nsIProtocolHandler_NewURI(This
->nshandler
, aSpec
, aOriginCharset
, aBaseURI
, _retval
);
1877 return NS_ERROR_NOT_IMPLEMENTED
;
1880 static nsresult NSAPI
nsProtocolHandler_NewChannel(nsIProtocolHandler
*iface
,
1881 nsIURI
*aURI
, nsIChannel
**_retval
)
1883 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
1885 TRACE("(%p)->(%p %p)\n", This
, aURI
, _retval
);
1888 return nsIProtocolHandler_NewChannel(This
->nshandler
, aURI
, _retval
);
1889 return NS_ERROR_NOT_IMPLEMENTED
;
1892 static nsresult NSAPI
nsProtocolHandler_AllowPort(nsIProtocolHandler
*iface
,
1893 PRInt32 port
, const char *scheme
, PRBool
*_retval
)
1895 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
1897 TRACE("(%p)->(%d %s %p)\n", This
, port
, debugstr_a(scheme
), _retval
);
1900 return nsIProtocolHandler_AllowPort(This
->nshandler
, port
, scheme
, _retval
);
1901 return NS_ERROR_NOT_IMPLEMENTED
;
1904 #undef NSPROTHANDLER_THIS
1906 static const nsIProtocolHandlerVtbl nsProtocolHandlerVtbl
= {
1907 nsProtocolHandler_QueryInterface
,
1908 nsProtocolHandler_AddRef
,
1909 nsProtocolHandler_Release
,
1910 nsProtocolHandler_GetScheme
,
1911 nsProtocolHandler_GetDefaultPort
,
1912 nsProtocolHandler_GetProtocolFlags
,
1913 nsProtocolHandler_NewURI
,
1914 nsProtocolHandler_NewChannel
,
1915 nsProtocolHandler_AllowPort
1918 static nsIProtocolHandler
*create_protocol_handler(nsIProtocolHandler
*nshandler
)
1920 nsProtocolHandler
*ret
= heap_alloc(sizeof(nsProtocolHandler
));
1922 ret
->lpProtocolHandlerVtbl
= &nsProtocolHandlerVtbl
;
1924 ret
->nshandler
= nshandler
;
1926 return NSPROTHANDLER(ret
);
1929 static nsresult NSAPI
nsIOService_QueryInterface(nsIIOService
*iface
, nsIIDRef riid
,
1934 if(IsEqualGUID(&IID_nsISupports
, riid
)
1935 || IsEqualGUID(&IID_nsIIOService
, riid
)) {
1937 nsIIOService_AddRef(iface
);
1941 WARN("(%s %p)\n", debugstr_guid(riid
), result
);
1942 return NS_NOINTERFACE
;
1945 static nsrefcnt NSAPI
nsIOService_AddRef(nsIIOService
*iface
)
1950 static nsrefcnt NSAPI
nsIOService_Release(nsIIOService
*iface
)
1955 static nsresult NSAPI
nsIOService_GetProtocolHandler(nsIIOService
*iface
, const char *aScheme
,
1956 nsIProtocolHandler
**_retval
)
1958 nsIExternalProtocolHandler
*nsexthandler
;
1959 nsIProtocolHandler
*nshandler
;
1962 TRACE("(%s %p)\n", debugstr_a(aScheme
), _retval
);
1964 nsres
= nsIIOService_GetProtocolHandler(nsio
, aScheme
, &nshandler
);
1965 if(NS_FAILED(nsres
)) {
1966 WARN("GetProtocolHandler failed: %08x\n", nsres
);
1970 nsres
= nsIProtocolHandler_QueryInterface(nshandler
, &IID_nsIExternalProtocolHandler
,
1971 (void**)&nsexthandler
);
1972 if(NS_FAILED(nsres
)) {
1973 *_retval
= nshandler
;
1977 nsIExternalProtocolHandler_Release(nsexthandler
);
1978 *_retval
= create_protocol_handler(nshandler
);
1979 TRACE("return %p\n", *_retval
);
1983 static nsresult NSAPI
nsIOService_GetProtocolFlags(nsIIOService
*iface
, const char *aScheme
,
1986 TRACE("(%s %p)\n", debugstr_a(aScheme
), _retval
);
1987 return nsIIOService_GetProtocolFlags(nsio
, aScheme
, _retval
);
1990 static BOOL
is_gecko_special_uri(const char *spec
)
1992 static const char chromeW
[] = "chrome:";
1993 static const char jarW
[] = "jar:";
1994 static const char resourceW
[] = "resource:";
1995 static const char javascriptW
[] = "javascript:";
1997 return !strncasecmp(spec
, chromeW
, sizeof(chromeW
)-1)
1998 || !strncasecmp(spec
, resourceW
, sizeof(resourceW
)-1)
1999 || !strncasecmp(spec
, jarW
, sizeof(jarW
)-1)
2000 || !strncasecmp(spec
, javascriptW
, sizeof(javascriptW
)-1);
2003 static nsresult NSAPI
nsIOService_NewURI(nsIIOService
*iface
, const nsACString
*aSpec
,
2004 const char *aOriginCharset
, nsIURI
*aBaseURI
, nsIURI
**_retval
)
2006 const char *spec
= NULL
;
2007 nsACString spec_str
;
2008 NSContainer
*nscontainer
= NULL
;
2010 LPCWSTR base_wine_url
= NULL
;
2011 nsIWineURI
*base_wine_uri
= NULL
, *wine_uri
;
2012 BOOL is_wine_uri
= FALSE
;
2015 nsACString_GetData(aSpec
, &spec
);
2017 TRACE("(%p(%s) %s %p %p)\n", aSpec
, debugstr_a(spec
), debugstr_a(aOriginCharset
),
2020 if(is_gecko_special_uri(spec
))
2021 return nsIIOService_NewURI(nsio
, aSpec
, aOriginCharset
, aBaseURI
, _retval
);
2023 if(!strncmp(spec
, "wine:", 5)) {
2029 nsACString base_uri_str
;
2030 const char *base_uri
= NULL
;
2032 nsACString_Init(&base_uri_str
, NULL
);
2034 nsres
= nsIURI_GetSpec(aBaseURI
, &base_uri_str
);
2035 if(NS_SUCCEEDED(nsres
)) {
2036 nsACString_GetData(&base_uri_str
, &base_uri
);
2037 TRACE("base_uri=%s\n", debugstr_a(base_uri
));
2039 ERR("GetSpec failed: %08x\n", nsres
);
2042 nsACString_Finish(&base_uri_str
);
2045 nsACString_Init(&spec_str
, spec
);
2046 nsres
= nsIIOService_NewURI(nsio
, aSpec
, aOriginCharset
, aBaseURI
, &uri
);
2047 nsACString_Finish(&spec_str
);
2048 if(NS_FAILED(nsres
))
2049 TRACE("NewURI failed: %08x\n", nsres
);
2052 nsres
= nsIURI_QueryInterface(aBaseURI
, &IID_nsIWineURI
, (void**)&base_wine_uri
);
2053 if(NS_SUCCEEDED(nsres
)) {
2054 nsIWineURI_GetNSContainer(base_wine_uri
, &nscontainer
);
2055 nsIWineURI_GetWineURL(base_wine_uri
, &base_wine_url
);
2057 TRACE("Could not get base nsIWineURI: %08x\n", nsres
);
2061 nsres
= create_uri(uri
, nscontainer
, &wine_uri
);
2062 *_retval
= (nsIURI
*)wine_uri
;
2065 nsIWebBrowserChrome_Release(NSWBCHROME(nscontainer
));
2068 WCHAR url
[INTERNET_MAX_URL_LENGTH
], rel_url
[INTERNET_MAX_URL_LENGTH
];
2072 MultiByteToWideChar(CP_ACP
, 0, spec
, -1, rel_url
, sizeof(rel_url
)/sizeof(WCHAR
));
2074 hres
= CoInternetCombineUrl(base_wine_url
, rel_url
,
2075 URL_ESCAPE_SPACES_ONLY
|URL_DONT_ESCAPE_EXTRA_INFO
,
2076 url
, sizeof(url
)/sizeof(WCHAR
), &len
, 0);
2078 nsIWineURI_SetWineURL(wine_uri
, url
);
2080 WARN("CoCombineUrl failed: %08x\n", hres
);
2081 }else if(is_wine_uri
) {
2082 WCHAR url
[INTERNET_MAX_URL_LENGTH
];
2084 MultiByteToWideChar(CP_ACP
, 0, spec
, -1, url
, sizeof(url
)/sizeof(WCHAR
));
2085 nsIWineURI_SetWineURL(wine_uri
, url
);
2089 nsIWineURI_Release(base_wine_uri
);
2094 static nsresult NSAPI
nsIOService_NewFileURI(nsIIOService
*iface
, nsIFile
*aFile
,
2097 TRACE("(%p %p)\n", aFile
, _retval
);
2098 return nsIIOService_NewFileURI(nsio
, aFile
, _retval
);
2101 static nsresult NSAPI
nsIOService_NewChannelFromURI(nsIIOService
*iface
, nsIURI
*aURI
,
2102 nsIChannel
**_retval
)
2104 nsIChannel
*channel
= NULL
;
2106 nsIWineURI
*wine_uri
;
2109 TRACE("(%p %p)\n", aURI
, _retval
);
2111 nsres
= nsIIOService_NewChannelFromURI(nsio
, aURI
, &channel
);
2112 if(NS_FAILED(nsres
) && nsres
!= NS_ERROR_UNKNOWN_PROTOCOL
) {
2113 WARN("NewChannelFromURI failed: %08x\n", nsres
);
2118 nsres
= nsIURI_QueryInterface(aURI
, &IID_nsIWineURI
, (void**)&wine_uri
);
2119 if(NS_FAILED(nsres
)) {
2120 WARN("Could not get nsIWineURI: %08x\n", nsres
);
2122 return channel
? NS_OK
: NS_ERROR_UNEXPECTED
;
2125 ret
= heap_alloc(sizeof(nsChannel
));
2127 ret
->lpHttpChannelVtbl
= &nsChannelVtbl
;
2128 ret
->lpUploadChannelVtbl
= &nsUploadChannelVtbl
;
2130 ret
->channel
= channel
;
2131 ret
->http_channel
= NULL
;
2132 ret
->uri
= wine_uri
;
2133 ret
->post_data_stream
= NULL
;
2134 ret
->load_group
= NULL
;
2135 ret
->notif_callback
= NULL
;
2136 ret
->load_flags
= 0;
2137 ret
->content
= NULL
;
2138 ret
->charset
= NULL
;
2140 nsIURI_AddRef(aURI
);
2141 ret
->original_uri
= aURI
;
2144 nsIChannel_QueryInterface(channel
, &IID_nsIHttpChannel
, (void**)&ret
->http_channel
);
2146 *_retval
= NSCHANNEL(ret
);
2150 static nsresult NSAPI
nsIOService_NewChannel(nsIIOService
*iface
, const nsACString
*aSpec
,
2151 const char *aOriginCharset
, nsIURI
*aBaseURI
, nsIChannel
**_retval
)
2153 TRACE("(%p %s %p %p)\n", aSpec
, debugstr_a(aOriginCharset
), aBaseURI
, _retval
);
2154 return nsIIOService_NewChannel(nsio
, aSpec
, aOriginCharset
, aBaseURI
, _retval
);
2157 static nsresult NSAPI
nsIOService_GetOffline(nsIIOService
*iface
, PRBool
*aOffline
)
2159 TRACE("(%p)\n", aOffline
);
2160 return nsIIOService_GetOffline(nsio
, aOffline
);
2163 static nsresult NSAPI
nsIOService_SetOffline(nsIIOService
*iface
, PRBool aOffline
)
2165 TRACE("(%x)\n", aOffline
);
2166 return nsIIOService_SetOffline(nsio
, aOffline
);
2169 static nsresult NSAPI
nsIOService_AllowPort(nsIIOService
*iface
, PRInt32 aPort
,
2170 const char *aScheme
, PRBool
*_retval
)
2172 TRACE("(%d %s %p)\n", aPort
, debugstr_a(aScheme
), _retval
);
2173 return nsIIOService_AllowPort(nsio
, aPort
, debugstr_a(aScheme
), _retval
);
2176 static nsresult NSAPI
nsIOService_ExtractScheme(nsIIOService
*iface
, const nsACString
*urlString
,
2177 nsACString
* _retval
)
2179 TRACE("(%p %p)\n", urlString
, _retval
);
2180 return nsIIOService_ExtractScheme(nsio
, urlString
, _retval
);
2183 static const nsIIOServiceVtbl nsIOServiceVtbl
= {
2184 nsIOService_QueryInterface
,
2186 nsIOService_Release
,
2187 nsIOService_GetProtocolHandler
,
2188 nsIOService_GetProtocolFlags
,
2190 nsIOService_NewFileURI
,
2191 nsIOService_NewChannelFromURI
,
2192 nsIOService_NewChannel
,
2193 nsIOService_GetOffline
,
2194 nsIOService_SetOffline
,
2195 nsIOService_AllowPort
,
2196 nsIOService_ExtractScheme
2199 static nsIIOService nsIOService
= { &nsIOServiceVtbl
};
2201 static nsresult NSAPI
nsIOServiceFactory_QueryInterface(nsIFactory
*iface
, nsIIDRef riid
,
2206 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
2207 TRACE("(IID_nsISupports %p)\n", result
);
2209 }else if(IsEqualGUID(&IID_nsIFactory
, riid
)) {
2210 TRACE("(IID_nsIFactory %p)\n", result
);
2215 nsIFactory_AddRef(iface
);
2219 WARN("(%s %p)\n", debugstr_guid(riid
), result
);
2220 return NS_NOINTERFACE
;
2223 static nsrefcnt NSAPI
nsIOServiceFactory_AddRef(nsIFactory
*iface
)
2228 static nsrefcnt NSAPI
nsIOServiceFactory_Release(nsIFactory
*iface
)
2233 static nsresult NSAPI
nsIOServiceFactory_CreateInstance(nsIFactory
*iface
,
2234 nsISupports
*aOuter
, const nsIID
*iid
, void **result
)
2236 return nsIIOService_QueryInterface(&nsIOService
, iid
, result
);
2239 static nsresult NSAPI
nsIOServiceFactory_LockFactory(nsIFactory
*iface
, PRBool lock
)
2241 WARN("(%x)\n", lock
);
2245 static const nsIFactoryVtbl nsIOServiceFactoryVtbl
= {
2246 nsIOServiceFactory_QueryInterface
,
2247 nsIOServiceFactory_AddRef
,
2248 nsIOServiceFactory_Release
,
2249 nsIOServiceFactory_CreateInstance
,
2250 nsIOServiceFactory_LockFactory
2253 static nsIFactory nsIOServiceFactory
= { &nsIOServiceFactoryVtbl
};
2255 void init_nsio(nsIComponentManager
*component_manager
, nsIComponentRegistrar
*registrar
)
2257 nsIFactory
*old_factory
= NULL
;
2260 nsres
= nsIComponentManager_GetClassObject(component_manager
, &NS_IOSERVICE_CID
,
2261 &IID_nsIFactory
, (void**)&old_factory
);
2262 if(NS_FAILED(nsres
)) {
2263 ERR("Could not get factory: %08x\n", nsres
);
2267 nsres
= nsIFactory_CreateInstance(old_factory
, NULL
, &IID_nsIIOService
, (void**)&nsio
);
2268 if(NS_FAILED(nsres
)) {
2269 ERR("Couldn not create nsIOService instance %08x\n", nsres
);
2270 nsIFactory_Release(old_factory
);
2274 nsres
= nsIComponentRegistrar_UnregisterFactory(registrar
, &NS_IOSERVICE_CID
, old_factory
);
2275 nsIFactory_Release(old_factory
);
2276 if(NS_FAILED(nsres
))
2277 ERR("UnregisterFactory failed: %08x\n", nsres
);
2279 nsres
= nsIComponentRegistrar_RegisterFactory(registrar
, &NS_IOSERVICE_CID
,
2280 NS_IOSERVICE_CLASSNAME
, NS_IOSERVICE_CONTRACTID
, &nsIOServiceFactory
);
2281 if(NS_FAILED(nsres
))
2282 ERR("RegisterFactory failed: %08x\n", nsres
);