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
handle_uri(NSContainer
*container
, nsChannel
*channel
, LPCWSTR uri
)
98 IServiceProvider
*service_provider
;
99 HTMLDocument
*doc
= container
->doc
;
104 NSContainer
*container_iter
= container
;
106 hlnf
= HLNF_OPENINNEWWINDOW
;
107 while(!container_iter
->doc
)
108 container_iter
= container_iter
->parent
;
109 doc
= container_iter
->doc
;
112 if(!hlnf
&& !exec_shldocvw_67(doc
, uri
))
115 hres
= IOleClientSite_QueryInterface(doc
->client
, &IID_IServiceProvider
,
116 (void**)&service_provider
);
117 if(SUCCEEDED(hres
)) {
118 IHlinkFrame
*hlink_frame
;
120 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHlinkFrame
,
121 &IID_IHlinkFrame
, (void**)&hlink_frame
);
122 IServiceProvider_Release(service_provider
);
123 if(SUCCEEDED(hres
)) {
124 hlink_frame_navigate(doc
, hlink_frame
, uri
, channel
->post_data_stream
, hlnf
);
125 IHlinkFrame_Release(hlink_frame
);
134 static BOOL
before_async_open(nsChannel
*channel
, NSContainer
*container
)
142 nsACString_Init(&uri_str
, NULL
);
143 nsIWineURI_GetSpec(channel
->uri
, &uri_str
);
144 nsACString_GetData(&uri_str
, &uria
, NULL
);
145 len
= MultiByteToWideChar(CP_ACP
, 0, uria
, -1, NULL
, 0);
146 uri
= mshtml_alloc(len
*sizeof(WCHAR
));
147 MultiByteToWideChar(CP_ACP
, 0, uria
, -1, uri
, len
);
148 nsACString_Finish(&uri_str
);
150 ret
= handle_uri(container
, channel
, uri
);
157 #define NSCHANNEL_THIS(iface) DEFINE_THIS(nsChannel, HttpChannel, iface)
159 static nsresult NSAPI
nsChannel_QueryInterface(nsIHttpChannel
*iface
, nsIIDRef riid
, nsQIResult result
)
161 nsChannel
*This
= NSCHANNEL_THIS(iface
);
165 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
166 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
167 *result
= NSCHANNEL(This
);
168 }else if(IsEqualGUID(&IID_nsIRequest
, riid
)) {
169 TRACE("(%p)->(IID_nsIRequest %p)\n", This
, result
);
170 *result
= NSCHANNEL(This
);
171 }else if(IsEqualGUID(&IID_nsIChannel
, riid
)) {
172 TRACE("(%p)->(IID_nsIChannel %p)\n", This
, result
);
173 *result
= NSCHANNEL(This
);
174 }else if(This
->http_channel
&& IsEqualGUID(&IID_nsIHttpChannel
, riid
)) {
175 TRACE("(%p)->(IID_nsIHttpChannel %p)\n", This
, result
);
176 *result
= NSHTTPCHANNEL(This
);
177 }else if(IsEqualGUID(&IID_nsIUploadChannel
, riid
)) {
178 TRACE("(%p)->(IID_nsIUploadChannel %p)\n", This
, result
);
179 *result
= NSUPCHANNEL(This
);
183 nsIChannel_AddRef(NSCHANNEL(This
));
187 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), result
);
190 return nsIChannel_QueryInterface(This
->channel
, riid
, result
);
191 return NS_NOINTERFACE
;
194 static nsrefcnt NSAPI
nsChannel_AddRef(nsIHttpChannel
*iface
)
196 nsChannel
*This
= NSCHANNEL_THIS(iface
);
197 nsrefcnt ref
= InterlockedIncrement(&This
->ref
);
199 TRACE("(%p) ref=%d\n", This
, ref
);
204 static nsrefcnt NSAPI
nsChannel_Release(nsIHttpChannel
*iface
)
206 nsChannel
*This
= NSCHANNEL_THIS(iface
);
207 LONG ref
= InterlockedDecrement(&This
->ref
);
210 nsIWineURI_Release(This
->uri
);
212 nsIChannel_Release(This
->channel
);
213 if(This
->http_channel
)
214 nsIHttpChannel_Release(This
->http_channel
);
215 if(This
->post_data_stream
)
216 nsIInputStream_Release(This
->post_data_stream
);
218 nsILoadGroup_Release(This
->load_group
);
219 if(This
->notif_callback
)
220 nsIInterfaceRequestor_Release(This
->notif_callback
);
221 if(This
->original_uri
)
222 nsIURI_Release(This
->original_uri
);
223 mshtml_free(This
->content
);
224 mshtml_free(This
->charset
);
231 static nsresult NSAPI
nsChannel_GetName(nsIHttpChannel
*iface
, nsACString
*aName
)
233 nsChannel
*This
= NSCHANNEL_THIS(iface
);
235 TRACE("(%p)->(%p)\n", This
, aName
);
238 return nsIChannel_GetName(This
->channel
, aName
);
240 return NS_ERROR_NOT_IMPLEMENTED
;
243 static nsresult NSAPI
nsChannel_IsPending(nsIHttpChannel
*iface
, PRBool
*_retval
)
245 nsChannel
*This
= NSCHANNEL_THIS(iface
);
247 TRACE("(%p)->(%p)\n", This
, _retval
);
250 return nsIChannel_IsPending(This
->channel
, _retval
);
252 FIXME("default action not implemented\n");
253 return NS_ERROR_NOT_IMPLEMENTED
;
256 static nsresult NSAPI
nsChannel_GetStatus(nsIHttpChannel
*iface
, nsresult
*aStatus
)
258 nsChannel
*This
= NSCHANNEL_THIS(iface
);
260 TRACE("(%p)->(%p)\n", This
, aStatus
);
263 return nsIChannel_GetStatus(This
->channel
, aStatus
);
265 TRACE("returning NS_OK\n");
266 return *aStatus
= NS_OK
;
269 static nsresult NSAPI
nsChannel_Cancel(nsIHttpChannel
*iface
, nsresult aStatus
)
271 nsChannel
*This
= NSCHANNEL_THIS(iface
);
273 TRACE("(%p)->(%08x)\n", This
, aStatus
);
276 return nsIChannel_Cancel(This
->channel
, aStatus
);
278 FIXME("default action not implemented\n");
279 return NS_ERROR_NOT_IMPLEMENTED
;
282 static nsresult NSAPI
nsChannel_Suspend(nsIHttpChannel
*iface
)
284 nsChannel
*This
= NSCHANNEL_THIS(iface
);
286 TRACE("(%p)\n", This
);
289 return nsIChannel_Suspend(This
->channel
);
291 FIXME("default action not implemented\n");
292 return NS_ERROR_NOT_IMPLEMENTED
;
295 static nsresult NSAPI
nsChannel_Resume(nsIHttpChannel
*iface
)
297 nsChannel
*This
= NSCHANNEL_THIS(iface
);
299 TRACE("(%p)\n", This
);
302 return nsIChannel_Resume(This
->channel
);
304 FIXME("default action not implemented\n");
305 return NS_ERROR_NOT_IMPLEMENTED
;
308 static nsresult NSAPI
nsChannel_GetLoadGroup(nsIHttpChannel
*iface
, nsILoadGroup
**aLoadGroup
)
310 nsChannel
*This
= NSCHANNEL_THIS(iface
);
312 TRACE("(%p)->(%p)\n", This
, aLoadGroup
);
315 nsILoadGroup_AddRef(This
->load_group
);
317 *aLoadGroup
= This
->load_group
;
321 static nsresult NSAPI
nsChannel_SetLoadGroup(nsIHttpChannel
*iface
, nsILoadGroup
*aLoadGroup
)
323 nsChannel
*This
= NSCHANNEL_THIS(iface
);
325 TRACE("(%p)->(%p)\n", This
, aLoadGroup
);
328 nsILoadGroup_Release(This
->load_group
);
330 nsILoadGroup_AddRef(aLoadGroup
);
332 This
->load_group
= aLoadGroup
;
335 return nsIChannel_SetLoadGroup(This
->channel
, aLoadGroup
);
339 static nsresult NSAPI
nsChannel_GetLoadFlags(nsIHttpChannel
*iface
, nsLoadFlags
*aLoadFlags
)
341 nsChannel
*This
= NSCHANNEL_THIS(iface
);
343 TRACE("(%p)->(%p)\n", This
, aLoadFlags
);
345 *aLoadFlags
= This
->load_flags
;
349 static nsresult NSAPI
nsChannel_SetLoadFlags(nsIHttpChannel
*iface
, nsLoadFlags aLoadFlags
)
351 nsChannel
*This
= NSCHANNEL_THIS(iface
);
353 TRACE("(%p)->(%08x)\n", This
, aLoadFlags
);
355 This
->load_flags
= aLoadFlags
;
358 return nsIChannel_SetLoadFlags(This
->channel
, aLoadFlags
);
362 static nsresult NSAPI
nsChannel_GetOriginalURI(nsIHttpChannel
*iface
, nsIURI
**aOriginalURI
)
364 nsChannel
*This
= NSCHANNEL_THIS(iface
);
366 TRACE("(%p)->(%p)\n", This
, aOriginalURI
);
368 if(This
->original_uri
)
369 nsIURI_AddRef(This
->original_uri
);
371 *aOriginalURI
= This
->original_uri
;
375 static nsresult NSAPI
nsChannel_SetOriginalURI(nsIHttpChannel
*iface
, nsIURI
*aOriginalURI
)
377 nsChannel
*This
= NSCHANNEL_THIS(iface
);
379 TRACE("(%p)->(%p)\n", This
, aOriginalURI
);
381 if(This
->original_uri
)
382 nsIURI_Release(This
->original_uri
);
384 nsIURI_AddRef(aOriginalURI
);
385 This
->original_uri
= aOriginalURI
;
388 return nsIChannel_SetOriginalURI(This
->channel
, aOriginalURI
);
392 static nsresult NSAPI
nsChannel_GetURI(nsIHttpChannel
*iface
, nsIURI
**aURI
)
394 nsChannel
*This
= NSCHANNEL_THIS(iface
);
396 TRACE("(%p)->(%p)\n", This
, aURI
);
398 nsIWineURI_AddRef(This
->uri
);
399 *aURI
= (nsIURI
*)This
->uri
;
404 static nsresult NSAPI
nsChannel_GetOwner(nsIHttpChannel
*iface
, nsISupports
**aOwner
)
406 nsChannel
*This
= NSCHANNEL_THIS(iface
);
408 TRACE("(%p)->(%p)\n", This
, aOwner
);
411 return nsIChannel_GetOwner(This
->channel
, aOwner
);
413 FIXME("default action not implemented\n");
414 return NS_ERROR_NOT_IMPLEMENTED
;
417 static nsresult NSAPI
nsChannel_SetOwner(nsIHttpChannel
*iface
, nsISupports
*aOwner
)
419 nsChannel
*This
= NSCHANNEL_THIS(iface
);
421 TRACE("(%p)->(%p)\n", This
, aOwner
);
424 return nsIChannel_SetOwner(This
->channel
, aOwner
);
426 FIXME("default action not implemented\n");
427 return NS_ERROR_NOT_IMPLEMENTED
;
430 static nsresult NSAPI
nsChannel_GetNotificationCallbacks(nsIHttpChannel
*iface
,
431 nsIInterfaceRequestor
**aNotificationCallbacks
)
433 nsChannel
*This
= NSCHANNEL_THIS(iface
);
435 TRACE("(%p)->(%p)\n", This
, aNotificationCallbacks
);
437 if(This
->notif_callback
)
438 nsIInterfaceRequestor_AddRef(This
->notif_callback
);
439 *aNotificationCallbacks
= This
->notif_callback
;
444 static nsresult NSAPI
nsChannel_SetNotificationCallbacks(nsIHttpChannel
*iface
,
445 nsIInterfaceRequestor
*aNotificationCallbacks
)
447 nsChannel
*This
= NSCHANNEL_THIS(iface
);
449 TRACE("(%p)->(%p)\n", This
, aNotificationCallbacks
);
451 if(This
->notif_callback
)
452 nsIInterfaceRequestor_Release(This
->notif_callback
);
453 if(aNotificationCallbacks
)
454 nsIInterfaceRequestor_AddRef(aNotificationCallbacks
);
456 This
->notif_callback
= aNotificationCallbacks
;
459 return nsIChannel_SetNotificationCallbacks(This
->channel
, aNotificationCallbacks
);
463 static nsresult NSAPI
nsChannel_GetSecurityInfo(nsIHttpChannel
*iface
, nsISupports
**aSecurityInfo
)
465 nsChannel
*This
= NSCHANNEL_THIS(iface
);
467 TRACE("(%p)->(%p)\n", This
, aSecurityInfo
);
470 return nsIChannel_GetSecurityInfo(This
->channel
, aSecurityInfo
);
472 FIXME("default action not implemented\n");
473 return NS_ERROR_NOT_IMPLEMENTED
;
476 static nsresult NSAPI
nsChannel_GetContentType(nsIHttpChannel
*iface
, nsACString
*aContentType
)
478 nsChannel
*This
= NSCHANNEL_THIS(iface
);
480 TRACE("(%p)->(%p)\n", This
, aContentType
);
483 nsACString_SetData(aContentType
, This
->content
);
488 return nsIChannel_GetContentType(This
->channel
, aContentType
);
490 TRACE("returning default text/html\n");
491 nsACString_SetData(aContentType
, "text/html");
495 static nsresult NSAPI
nsChannel_SetContentType(nsIHttpChannel
*iface
,
496 const nsACString
*aContentType
)
498 nsChannel
*This
= NSCHANNEL_THIS(iface
);
500 TRACE("(%p)->(%p)\n", This
, aContentType
);
503 return nsIChannel_SetContentType(This
->channel
, aContentType
);
505 FIXME("default action not implemented\n");
506 return NS_ERROR_NOT_IMPLEMENTED
;
509 static nsresult NSAPI
nsChannel_GetContentCharset(nsIHttpChannel
*iface
,
510 nsACString
*aContentCharset
)
512 nsChannel
*This
= NSCHANNEL_THIS(iface
);
514 TRACE("(%p)->(%p)\n", This
, aContentCharset
);
517 nsACString_SetData(aContentCharset
, This
->charset
);
522 nsresult nsres
= nsIChannel_GetContentCharset(This
->channel
, aContentCharset
);
524 nsACString_GetData(aContentCharset
, &ch
, NULL
);
528 nsACString_SetData(aContentCharset
, "");
532 static nsresult NSAPI
nsChannel_SetContentCharset(nsIHttpChannel
*iface
,
533 const nsACString
*aContentCharset
)
535 nsChannel
*This
= NSCHANNEL_THIS(iface
);
537 TRACE("(%p)->(%p)\n", This
, aContentCharset
);
540 return nsIChannel_SetContentCharset(This
->channel
, aContentCharset
);
542 FIXME("default action not implemented\n");
543 return NS_ERROR_NOT_IMPLEMENTED
;
546 static nsresult NSAPI
nsChannel_GetContentLength(nsIHttpChannel
*iface
, PRInt32
*aContentLength
)
548 nsChannel
*This
= NSCHANNEL_THIS(iface
);
550 TRACE("(%p)->(%p)\n", This
, aContentLength
);
553 return nsIChannel_GetContentLength(This
->channel
, aContentLength
);
555 FIXME("default action not implemented\n");
556 return NS_ERROR_NOT_IMPLEMENTED
;
559 static nsresult NSAPI
nsChannel_SetContentLength(nsIHttpChannel
*iface
, PRInt32 aContentLength
)
561 nsChannel
*This
= NSCHANNEL_THIS(iface
);
563 TRACE("(%p)->(%d)\n", This
, aContentLength
);
566 return nsIChannel_SetContentLength(This
->channel
, aContentLength
);
568 FIXME("default action not implemented\n");
569 return NS_ERROR_NOT_IMPLEMENTED
;
572 static nsresult NSAPI
nsChannel_Open(nsIHttpChannel
*iface
, nsIInputStream
**_retval
)
574 nsChannel
*This
= NSCHANNEL_THIS(iface
);
576 TRACE("(%p)->(%p)\n", This
, _retval
);
579 return nsIChannel_Open(This
->channel
, _retval
);
581 FIXME("default action not implemented\n");
582 return NS_ERROR_NOT_IMPLEMENTED
;
585 static BOOL
do_load_from_moniker_hack(nsChannel
*This
)
590 * We should always load the page from IMoniker, but Wine is not yet
591 * ready for this. This function is a heuristic, that decides which
592 * way of loading is better (Gecko implementation or IMoniker). The
593 * aim is to always return TRUE.
596 /* Load from moniker if there is no Gecko channel available */
600 /* Load about protocol from moniker */
601 nsIWineURI_SchemeIs(This
->uri
, "about", &b
);
608 static nsresult NSAPI
nsChannel_AsyncOpen(nsIHttpChannel
*iface
, nsIStreamListener
*aListener
,
609 nsISupports
*aContext
)
611 nsChannel
*This
= NSCHANNEL_THIS(iface
);
612 BSCallback
*bscallback
;
613 nsIWineURI
*wine_uri
;
621 TRACE("(%p)->(%p %p)\n", This
, aListener
, aContext
);
623 nsIWineURI_GetIsDocumentURI(This
->uri
, &is_doc_uri
);
625 if(is_doc_uri
&& (This
->load_flags
& LOAD_INITIAL_DOCUMENT_URI
)) {
626 NSContainer
*container
;
628 nsIWineURI_GetNSContainer(This
->uri
, &container
);
630 TRACE("container = NULL\n");
631 return nsIChannel_AsyncOpen(This
->channel
, aListener
, aContext
);
634 if(container
->bscallback
) {
635 nsIChannel_AddRef(NSCHANNEL(This
));
636 container
->bscallback
->nschannel
= This
;
638 nsIStreamListener_AddRef(aListener
);
639 container
->bscallback
->nslistener
= aListener
;
642 nsISupports_AddRef(aContext
);
643 container
->bscallback
->nscontext
= aContext
;
646 nsIWebBrowserChrome_Release(NSWBCHROME(container
));
648 if(do_load_from_moniker_hack(This
))
649 return WINE_NS_LOAD_FROM_MONIKER
;
650 }else if(container
->doc
) {
651 BOOL cont
= before_async_open(This
, container
);
652 nsIWebBrowserChrome_Release(NSWBCHROME(container
));
656 return NS_ERROR_UNEXPECTED
;
659 nsIWebBrowserChrome_Release(NSWBCHROME(container
));
661 ? nsIChannel_AsyncOpen(This
->channel
, aListener
, aContext
)
662 : NS_ERROR_UNEXPECTED
;
667 if(This
->post_data_stream
) {
668 nsIUploadChannel
*upload_channel
;
670 nsres
= nsIChannel_QueryInterface(This
->channel
, &IID_nsIUploadChannel
,
671 (void**)&upload_channel
);
672 if(NS_SUCCEEDED(nsres
)) {
673 nsACString empty_string
;
674 nsACString_Init(&empty_string
, "");
676 nsres
= nsIUploadChannel_SetUploadStream(upload_channel
, This
->post_data_stream
,
678 nsIUploadChannel_Release(upload_channel
);
680 WARN("SetUploadStream failed: %08x\n", nsres
);
682 nsACString_Finish(&empty_string
);
686 nsres
= nsIChannel_AsyncOpen(This
->channel
, aListener
, aContext
);
688 if(NS_FAILED(nsres
) && (This
->load_flags
& LOAD_INITIAL_DOCUMENT_URI
))
689 return WINE_NS_LOAD_FROM_MONIKER
;
693 TRACE("channel == NULL\n");
695 if(!This
->original_uri
) {
696 ERR("original_uri == NULL\n");
697 return NS_ERROR_UNEXPECTED
;
700 nsres
= nsIURI_QueryInterface(This
->original_uri
, &IID_nsIWineURI
, (void**)&wine_uri
);
701 if(NS_FAILED(nsres
)) {
702 ERR("Could not get nsIWineURI: %08x\n", nsres
);
703 return NS_ERROR_UNEXPECTED
;
706 nsIWineURI_GetWineURL(wine_uri
, &wine_url
);
708 TRACE("wine_url == NULL\n");
709 return NS_ERROR_UNEXPECTED
;
712 hres
= CreateURLMoniker(NULL
, wine_url
, &mon
);
714 WARN("CreateURLMonikrer failed: %08x\n", hres
);
715 return NS_ERROR_UNEXPECTED
;
718 bscallback
= create_bscallback(mon
);
719 IMoniker_Release(mon
);
721 nsIChannel_AddRef(NSCHANNEL(This
));
722 bscallback
->nschannel
= This
;
724 nsIStreamListener_AddRef(aListener
);
725 bscallback
->nslistener
= aListener
;
728 nsISupports_AddRef(aContext
);
729 bscallback
->nscontext
= aContext
;
732 task
= mshtml_alloc(sizeof(task_t
));
734 task
->doc
= bscallback
->doc
;
735 task
->task_id
= TASK_START_BINDING
;
737 task
->bscallback
= bscallback
;
744 static nsresult NSAPI
nsChannel_GetRequestMethod(nsIHttpChannel
*iface
, nsACString
*aRequestMethod
)
746 nsChannel
*This
= NSCHANNEL_THIS(iface
);
748 TRACE("(%p)->(%p)\n", This
, aRequestMethod
);
750 if(This
->http_channel
)
751 return nsIHttpChannel_GetRequestMethod(This
->http_channel
, aRequestMethod
);
753 return NS_ERROR_NOT_IMPLEMENTED
;
756 static nsresult NSAPI
nsChannel_SetRequestMethod(nsIHttpChannel
*iface
,
757 const nsACString
*aRequestMethod
)
759 nsChannel
*This
= NSCHANNEL_THIS(iface
);
761 TRACE("(%p)->(%p)\n", This
, aRequestMethod
);
763 if(This
->http_channel
)
764 return nsIHttpChannel_SetRequestMethod(This
->http_channel
, aRequestMethod
);
766 return NS_ERROR_NOT_IMPLEMENTED
;
769 static nsresult NSAPI
nsChannel_GetReferrer(nsIHttpChannel
*iface
, nsIURI
**aReferrer
)
771 nsChannel
*This
= NSCHANNEL_THIS(iface
);
773 TRACE("(%p)->(%p)\n", This
, aReferrer
);
775 if(This
->http_channel
)
776 return nsIHttpChannel_GetReferrer(This
->http_channel
, aReferrer
);
778 return NS_ERROR_NOT_IMPLEMENTED
;
781 static nsresult NSAPI
nsChannel_SetReferrer(nsIHttpChannel
*iface
, nsIURI
*aReferrer
)
783 nsChannel
*This
= NSCHANNEL_THIS(iface
);
785 TRACE("(%p)->(%p)\n", This
, aReferrer
);
787 if(This
->http_channel
)
788 return nsIHttpChannel_SetReferrer(This
->http_channel
, aReferrer
);
790 return NS_ERROR_NOT_IMPLEMENTED
;
793 static nsresult NSAPI
nsChannel_GetRequestHeader(nsIHttpChannel
*iface
,
794 const nsACString
*aHeader
, nsACString
*_retval
)
796 nsChannel
*This
= NSCHANNEL_THIS(iface
);
798 TRACE("(%p)->(%p %p)\n", This
, aHeader
, _retval
);
800 if(This
->http_channel
)
801 return nsIHttpChannel_GetRequestHeader(This
->http_channel
, aHeader
, _retval
);
803 return NS_ERROR_NOT_IMPLEMENTED
;
806 static nsresult NSAPI
nsChannel_SetRequestHeader(nsIHttpChannel
*iface
,
807 const nsACString
*aHeader
, const nsACString
*aValue
, PRBool aMerge
)
809 nsChannel
*This
= NSCHANNEL_THIS(iface
);
811 TRACE("(%p)->(%p %p %x)\n", This
, aHeader
, aValue
, aMerge
);
813 if(This
->http_channel
)
814 return nsIHttpChannel_SetRequestHeader(This
->http_channel
, aHeader
, aValue
, aMerge
);
816 return NS_ERROR_NOT_IMPLEMENTED
;
819 static nsresult NSAPI
nsChannel_VisitRequestHeaders(nsIHttpChannel
*iface
,
820 nsIHttpHeaderVisitor
*aVisitor
)
822 nsChannel
*This
= NSCHANNEL_THIS(iface
);
824 TRACE("(%p)->(%p)\n", This
, aVisitor
);
826 if(This
->http_channel
)
827 return nsIHttpChannel_VisitRequestHeaders(This
->http_channel
, aVisitor
);
829 return NS_ERROR_NOT_IMPLEMENTED
;
832 static nsresult NSAPI
nsChannel_GetAllowPipelining(nsIHttpChannel
*iface
, PRBool
*aAllowPipelining
)
834 nsChannel
*This
= NSCHANNEL_THIS(iface
);
836 TRACE("(%p)->(%p)\n", This
, aAllowPipelining
);
838 if(This
->http_channel
)
839 return nsIHttpChannel_GetAllowPipelining(This
->http_channel
, aAllowPipelining
);
841 return NS_ERROR_NOT_IMPLEMENTED
;
844 static nsresult NSAPI
nsChannel_SetAllowPipelining(nsIHttpChannel
*iface
, PRBool aAllowPipelining
)
846 nsChannel
*This
= NSCHANNEL_THIS(iface
);
848 TRACE("(%p)->(%x)\n", This
, aAllowPipelining
);
850 if(This
->http_channel
)
851 return nsIHttpChannel_SetAllowPipelining(This
->http_channel
, aAllowPipelining
);
853 return NS_ERROR_NOT_IMPLEMENTED
;
856 static nsresult NSAPI
nsChannel_GetRedirectionLimit(nsIHttpChannel
*iface
, PRUint32
*aRedirectionLimit
)
858 nsChannel
*This
= NSCHANNEL_THIS(iface
);
860 TRACE("(%p)->(%p)\n", This
, aRedirectionLimit
);
862 if(This
->http_channel
)
863 return nsIHttpChannel_GetRedirectionLimit(This
->http_channel
, aRedirectionLimit
);
865 return NS_ERROR_NOT_IMPLEMENTED
;
868 static nsresult NSAPI
nsChannel_SetRedirectionLimit(nsIHttpChannel
*iface
, PRUint32 aRedirectionLimit
)
870 nsChannel
*This
= NSCHANNEL_THIS(iface
);
872 TRACE("(%p)->(%u)\n", This
, aRedirectionLimit
);
874 if(This
->http_channel
)
875 return nsIHttpChannel_SetRedirectionLimit(This
->http_channel
, aRedirectionLimit
);
877 return NS_ERROR_NOT_IMPLEMENTED
;
880 static nsresult NSAPI
nsChannel_GetResponseStatus(nsIHttpChannel
*iface
, PRUint32
*aResponseStatus
)
882 nsChannel
*This
= NSCHANNEL_THIS(iface
);
884 TRACE("(%p)->(%p)\n", This
, aResponseStatus
);
886 if(This
->http_channel
)
887 return nsIHttpChannel_GetResponseStatus(This
->http_channel
, aResponseStatus
);
889 return NS_ERROR_NOT_IMPLEMENTED
;
892 static nsresult NSAPI
nsChannel_GetResponseStatusText(nsIHttpChannel
*iface
,
893 nsACString
*aResponseStatusText
)
895 nsChannel
*This
= NSCHANNEL_THIS(iface
);
897 TRACE("(%p)->(%p)\n", This
, aResponseStatusText
);
899 if(This
->http_channel
)
900 return nsIHttpChannel_GetResponseStatusText(This
->http_channel
, aResponseStatusText
);
902 return NS_ERROR_NOT_IMPLEMENTED
;
905 static nsresult NSAPI
nsChannel_GetRequestSucceeded(nsIHttpChannel
*iface
,
906 PRBool
*aRequestSucceeded
)
908 nsChannel
*This
= NSCHANNEL_THIS(iface
);
910 TRACE("(%p)->(%p)\n", This
, aRequestSucceeded
);
912 if(This
->http_channel
)
913 return nsIHttpChannel_GetRequestSucceeded(This
->http_channel
, aRequestSucceeded
);
915 return NS_ERROR_NOT_IMPLEMENTED
;
918 static nsresult NSAPI
nsChannel_GetResponseHeader(nsIHttpChannel
*iface
,
919 const nsACString
*header
, nsACString
*_retval
)
921 nsChannel
*This
= NSCHANNEL_THIS(iface
);
923 TRACE("(%p)->(%p %p)\n", This
, header
, _retval
);
925 if(This
->http_channel
)
926 return nsIHttpChannel_GetResponseHeader(This
->http_channel
, header
, _retval
);
928 return NS_ERROR_NOT_IMPLEMENTED
;
931 static nsresult NSAPI
nsChannel_SetResponseHeader(nsIHttpChannel
*iface
,
932 const nsACString
*header
, const nsACString
*value
, PRBool merge
)
934 nsChannel
*This
= NSCHANNEL_THIS(iface
);
936 TRACE("(%p)->(%p %p %x)\n", This
, header
, value
, merge
);
938 if(This
->http_channel
)
939 return nsIHttpChannel_SetResponseHeader(This
->http_channel
, header
, value
, merge
);
941 return NS_ERROR_NOT_IMPLEMENTED
;
944 static nsresult NSAPI
nsChannel_VisitResponseHeaders(nsIHttpChannel
*iface
,
945 nsIHttpHeaderVisitor
*aVisitor
)
947 nsChannel
*This
= NSCHANNEL_THIS(iface
);
949 TRACE("(%p)->(%p)\n", This
, aVisitor
);
951 if(This
->http_channel
)
952 return nsIHttpChannel_VisitResponseHeaders(This
->http_channel
, aVisitor
);
954 return NS_ERROR_NOT_IMPLEMENTED
;
957 static nsresult NSAPI
nsChannel_IsNoStoreResponse(nsIHttpChannel
*iface
, PRBool
*_retval
)
959 nsChannel
*This
= NSCHANNEL_THIS(iface
);
961 TRACE("(%p)->(%p)\n", This
, _retval
);
963 if(This
->http_channel
)
964 return nsIHttpChannel_IsNoStoreResponse(This
->http_channel
, _retval
);
966 return NS_ERROR_NOT_IMPLEMENTED
;
969 static nsresult NSAPI
nsChannel_IsNoCacheResponse(nsIHttpChannel
*iface
, PRBool
*_retval
)
971 nsChannel
*This
= NSCHANNEL_THIS(iface
);
973 TRACE("(%p)->(%p)\n", This
, _retval
);
975 if(This
->http_channel
)
976 return nsIHttpChannel_IsNoCacheResponse(This
->http_channel
, _retval
);
978 return NS_ERROR_NOT_IMPLEMENTED
;
981 #undef NSCHANNEL_THIS
983 static const nsIHttpChannelVtbl nsChannelVtbl
= {
984 nsChannel_QueryInterface
,
993 nsChannel_GetLoadGroup
,
994 nsChannel_SetLoadGroup
,
995 nsChannel_GetLoadFlags
,
996 nsChannel_SetLoadFlags
,
997 nsChannel_GetOriginalURI
,
998 nsChannel_SetOriginalURI
,
1002 nsChannel_GetNotificationCallbacks
,
1003 nsChannel_SetNotificationCallbacks
,
1004 nsChannel_GetSecurityInfo
,
1005 nsChannel_GetContentType
,
1006 nsChannel_SetContentType
,
1007 nsChannel_GetContentCharset
,
1008 nsChannel_SetContentCharset
,
1009 nsChannel_GetContentLength
,
1010 nsChannel_SetContentLength
,
1012 nsChannel_AsyncOpen
,
1013 nsChannel_GetRequestMethod
,
1014 nsChannel_SetRequestMethod
,
1015 nsChannel_GetReferrer
,
1016 nsChannel_SetReferrer
,
1017 nsChannel_GetRequestHeader
,
1018 nsChannel_SetRequestHeader
,
1019 nsChannel_VisitRequestHeaders
,
1020 nsChannel_GetAllowPipelining
,
1021 nsChannel_SetAllowPipelining
,
1022 nsChannel_GetRedirectionLimit
,
1023 nsChannel_SetRedirectionLimit
,
1024 nsChannel_GetResponseStatus
,
1025 nsChannel_GetResponseStatusText
,
1026 nsChannel_GetRequestSucceeded
,
1027 nsChannel_GetResponseHeader
,
1028 nsChannel_SetResponseHeader
,
1029 nsChannel_VisitResponseHeaders
,
1030 nsChannel_IsNoStoreResponse
,
1031 nsChannel_IsNoCacheResponse
1034 #define NSUPCHANNEL_THIS(iface) DEFINE_THIS(nsChannel, UploadChannel, iface)
1036 static nsresult NSAPI
nsUploadChannel_QueryInterface(nsIUploadChannel
*iface
, nsIIDRef riid
,
1039 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1040 return nsIChannel_QueryInterface(NSCHANNEL(This
), riid
, result
);
1043 static nsrefcnt NSAPI
nsUploadChannel_AddRef(nsIUploadChannel
*iface
)
1045 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1046 return nsIChannel_AddRef(NSCHANNEL(This
));
1049 static nsrefcnt NSAPI
nsUploadChannel_Release(nsIUploadChannel
*iface
)
1051 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1052 return nsIChannel_Release(NSCHANNEL(This
));
1055 static nsresult NSAPI
nsUploadChannel_SetUploadStream(nsIUploadChannel
*iface
,
1056 nsIInputStream
*aStream
, const nsACString
*aContentType
, PRInt32 aContentLength
)
1058 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1059 const char *content_type
;
1061 TRACE("(%p)->(%p %p %d)\n", This
, aStream
, aContentType
, aContentLength
);
1063 if(This
->post_data_stream
)
1064 nsIInputStream_Release(This
->post_data_stream
);
1067 nsACString_GetData(aContentType
, &content_type
, NULL
);
1069 FIXME("Unsupported aContentType argument: %s\n", debugstr_a(content_type
));
1072 if(aContentLength
!= -1)
1073 FIXME("Unsupported acontentLength = %d\n", aContentLength
);
1076 nsIInputStream_AddRef(aStream
);
1077 This
->post_data_stream
= aStream
;
1082 static nsresult NSAPI
nsUploadChannel_GetUploadStream(nsIUploadChannel
*iface
,
1083 nsIInputStream
**aUploadStream
)
1085 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1087 TRACE("(%p)->(%p)\n", This
, aUploadStream
);
1089 if(This
->post_data_stream
)
1090 nsIInputStream_AddRef(This
->post_data_stream
);
1092 *aUploadStream
= This
->post_data_stream
;
1096 #undef NSUPCHANNEL_THIS
1098 static const nsIUploadChannelVtbl nsUploadChannelVtbl
= {
1099 nsUploadChannel_QueryInterface
,
1100 nsUploadChannel_AddRef
,
1101 nsUploadChannel_Release
,
1102 nsUploadChannel_SetUploadStream
,
1103 nsUploadChannel_GetUploadStream
1106 #define NSURI_THIS(iface) DEFINE_THIS(nsURI, WineURI, iface)
1108 static nsresult NSAPI
nsURI_QueryInterface(nsIWineURI
*iface
, nsIIDRef riid
, nsQIResult result
)
1110 nsURI
*This
= NSURI_THIS(iface
);
1114 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
1115 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
1116 *result
= NSURI(This
);
1117 }else if(IsEqualGUID(&IID_nsIURI
, riid
)) {
1118 TRACE("(%p)->(IID_nsIURI %p)\n", This
, result
);
1119 *result
= NSURI(This
);
1120 }else if(IsEqualGUID(&IID_nsIWineURI
, riid
)) {
1121 TRACE("(%p)->(IID_nsIWineURI %p)\n", This
, result
);
1122 *result
= NSURI(This
);
1126 nsIURI_AddRef(NSURI(This
));
1130 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), result
);
1131 return This
->uri
? nsIURI_QueryInterface(This
->uri
, riid
, result
) : NS_NOINTERFACE
;
1134 static nsrefcnt NSAPI
nsURI_AddRef(nsIWineURI
*iface
)
1136 nsURI
*This
= NSURI_THIS(iface
);
1137 LONG ref
= InterlockedIncrement(&This
->ref
);
1139 TRACE("(%p) ref=%d\n", This
, ref
);
1144 static nsrefcnt NSAPI
nsURI_Release(nsIWineURI
*iface
)
1146 nsURI
*This
= NSURI_THIS(iface
);
1147 LONG ref
= InterlockedDecrement(&This
->ref
);
1149 TRACE("(%p) ref=%d\n", This
, ref
);
1153 nsIWebBrowserChrome_Release(NSWBCHROME(This
->container
));
1155 nsIURI_Release(This
->uri
);
1156 mshtml_free(This
->wine_url
);
1163 static nsresult NSAPI
nsURI_GetSpec(nsIWineURI
*iface
, nsACString
*aSpec
)
1165 nsURI
*This
= NSURI_THIS(iface
);
1167 TRACE("(%p)->(%p)\n", This
, aSpec
);
1169 if(This
->use_wine_url
) {
1170 char speca
[INTERNET_MAX_URL_LENGTH
];
1171 WideCharToMultiByte(CP_ACP
, 0, This
->wine_url
, -1, speca
, sizeof(speca
), NULL
, NULL
);
1172 nsACString_SetData(aSpec
, speca
);
1178 return nsIURI_GetSpec(This
->uri
, aSpec
);
1180 TRACE("returning error\n");
1181 return NS_ERROR_NOT_IMPLEMENTED
;
1185 static nsresult NSAPI
nsURI_SetSpec(nsIWineURI
*iface
, const nsACString
*aSpec
)
1187 nsURI
*This
= NSURI_THIS(iface
);
1189 TRACE("(%p)->(%p)\n", This
, aSpec
);
1192 return nsIURI_SetSpec(This
->uri
, aSpec
);
1194 FIXME("default action not implemented\n");
1195 return NS_ERROR_NOT_IMPLEMENTED
;
1198 static nsresult NSAPI
nsURI_GetPrePath(nsIWineURI
*iface
, nsACString
*aPrePath
)
1200 nsURI
*This
= NSURI_THIS(iface
);
1202 TRACE("(%p)->(%p)\n", This
, aPrePath
);
1205 return nsIURI_GetPrePath(This
->uri
, aPrePath
);
1207 FIXME("default action not implemented\n");
1208 return NS_ERROR_NOT_IMPLEMENTED
;
1211 static nsresult NSAPI
nsURI_GetScheme(nsIWineURI
*iface
, nsACString
*aScheme
)
1213 nsURI
*This
= NSURI_THIS(iface
);
1215 TRACE("(%p)->(%p)\n", This
, aScheme
);
1217 if(This
->use_wine_url
) {
1219 * For Gecko we set scheme to unknown so it won't be handled
1220 * as any special case.
1222 nsACString_SetData(aScheme
, "wine");
1227 return nsIURI_GetScheme(This
->uri
, aScheme
);
1229 TRACE("returning error\n");
1230 return NS_ERROR_NOT_IMPLEMENTED
;
1233 static nsresult NSAPI
nsURI_SetScheme(nsIWineURI
*iface
, const nsACString
*aScheme
)
1235 nsURI
*This
= NSURI_THIS(iface
);
1237 TRACE("(%p)->(%p)\n", This
, aScheme
);
1240 return nsIURI_SetScheme(This
->uri
, aScheme
);
1242 FIXME("default action not implemented\n");
1243 return NS_ERROR_NOT_IMPLEMENTED
;
1246 static nsresult NSAPI
nsURI_GetUserPass(nsIWineURI
*iface
, nsACString
*aUserPass
)
1248 nsURI
*This
= NSURI_THIS(iface
);
1250 TRACE("(%p)->(%p)\n", This
, aUserPass
);
1253 return nsIURI_GetUserPass(This
->uri
, aUserPass
);
1255 FIXME("default action not implemented\n");
1256 return NS_ERROR_NOT_IMPLEMENTED
;
1259 static nsresult NSAPI
nsURI_SetUserPass(nsIWineURI
*iface
, const nsACString
*aUserPass
)
1261 nsURI
*This
= NSURI_THIS(iface
);
1263 TRACE("(%p)->(%p)\n", This
, aUserPass
);
1266 return nsIURI_SetUserPass(This
->uri
, aUserPass
);
1268 FIXME("default action not implemented\n");
1269 return NS_ERROR_NOT_IMPLEMENTED
;
1272 static nsresult NSAPI
nsURI_GetUsername(nsIWineURI
*iface
, nsACString
*aUsername
)
1274 nsURI
*This
= NSURI_THIS(iface
);
1276 TRACE("(%p)->(%p)\n", This
, aUsername
);
1279 return nsIURI_GetUsername(This
->uri
, aUsername
);
1281 FIXME("default action not implemented\n");
1282 return NS_ERROR_NOT_IMPLEMENTED
;
1285 static nsresult NSAPI
nsURI_SetUsername(nsIWineURI
*iface
, const nsACString
*aUsername
)
1287 nsURI
*This
= NSURI_THIS(iface
);
1289 TRACE("(%p)->(%p)\n", This
, aUsername
);
1292 return nsIURI_SetUsername(This
->uri
, aUsername
);
1294 FIXME("default action not implemented\n");
1295 return NS_ERROR_NOT_IMPLEMENTED
;
1298 static nsresult NSAPI
nsURI_GetPassword(nsIWineURI
*iface
, nsACString
*aPassword
)
1300 nsURI
*This
= NSURI_THIS(iface
);
1302 TRACE("(%p)->(%p)\n", This
, aPassword
);
1305 return nsIURI_GetPassword(This
->uri
, aPassword
);
1307 FIXME("default action not implemented\n");
1308 return NS_ERROR_NOT_IMPLEMENTED
;
1311 static nsresult NSAPI
nsURI_SetPassword(nsIWineURI
*iface
, const nsACString
*aPassword
)
1313 nsURI
*This
= NSURI_THIS(iface
);
1315 TRACE("(%p)->(%p)\n", This
, aPassword
);
1318 return nsIURI_SetPassword(This
->uri
, aPassword
);
1320 FIXME("default action not implemented\n");
1321 return NS_ERROR_NOT_IMPLEMENTED
;
1324 static nsresult NSAPI
nsURI_GetHostPort(nsIWineURI
*iface
, nsACString
*aHostPort
)
1326 nsURI
*This
= NSURI_THIS(iface
);
1328 TRACE("(%p)->(%p)\n", This
, aHostPort
);
1331 return nsIURI_GetHostPort(This
->uri
, aHostPort
);
1333 FIXME("default action not implemented\n");
1334 return NS_ERROR_NOT_IMPLEMENTED
;
1337 static nsresult NSAPI
nsURI_SetHostPort(nsIWineURI
*iface
, const nsACString
*aHostPort
)
1339 nsURI
*This
= NSURI_THIS(iface
);
1341 TRACE("(%p)->(%p)\n", This
, aHostPort
);
1344 return nsIURI_SetHostPort(This
->uri
, aHostPort
);
1346 FIXME("default action not implemented\n");
1347 return NS_ERROR_NOT_IMPLEMENTED
;
1350 static nsresult NSAPI
nsURI_GetHost(nsIWineURI
*iface
, nsACString
*aHost
)
1352 nsURI
*This
= NSURI_THIS(iface
);
1354 TRACE("(%p)->(%p)\n", This
, aHost
);
1357 return nsIURI_GetHost(This
->uri
, aHost
);
1359 FIXME("default action not implemented\n");
1360 return NS_ERROR_NOT_IMPLEMENTED
;
1363 static nsresult NSAPI
nsURI_SetHost(nsIWineURI
*iface
, const nsACString
*aHost
)
1365 nsURI
*This
= NSURI_THIS(iface
);
1367 TRACE("(%p)->(%p)\n", This
, aHost
);
1370 return nsIURI_SetHost(This
->uri
, aHost
);
1372 FIXME("default action not implemented\n");
1373 return NS_ERROR_NOT_IMPLEMENTED
;
1376 static nsresult NSAPI
nsURI_GetPort(nsIWineURI
*iface
, PRInt32
*aPort
)
1378 nsURI
*This
= NSURI_THIS(iface
);
1380 TRACE("(%p)->(%p)\n", This
, aPort
);
1383 return nsIURI_GetPort(This
->uri
, aPort
);
1385 FIXME("default action not implemented\n");
1386 return NS_ERROR_NOT_IMPLEMENTED
;
1389 static nsresult NSAPI
nsURI_SetPort(nsIWineURI
*iface
, PRInt32 aPort
)
1391 nsURI
*This
= NSURI_THIS(iface
);
1393 TRACE("(%p)->(%d)\n", This
, aPort
);
1396 return nsIURI_SetPort(This
->uri
, aPort
);
1398 FIXME("default action not implemented\n");
1399 return NS_ERROR_NOT_IMPLEMENTED
;
1402 static nsresult NSAPI
nsURI_GetPath(nsIWineURI
*iface
, nsACString
*aPath
)
1404 nsURI
*This
= NSURI_THIS(iface
);
1406 TRACE("(%p)->(%p)\n", This
, aPath
);
1409 return nsIURI_GetPath(This
->uri
, aPath
);
1411 FIXME("default action not implemented\n");
1412 return NS_ERROR_NOT_IMPLEMENTED
;
1415 static nsresult NSAPI
nsURI_SetPath(nsIWineURI
*iface
, const nsACString
*aPath
)
1417 nsURI
*This
= NSURI_THIS(iface
);
1419 TRACE("(%p)->(%p)\n", This
, aPath
);
1422 return nsIURI_SetPath(This
->uri
, aPath
);
1424 FIXME("default action not implemented\n");
1425 return NS_ERROR_NOT_IMPLEMENTED
;
1428 static nsresult NSAPI
nsURI_Equals(nsIWineURI
*iface
, nsIURI
*other
, PRBool
*_retval
)
1430 nsURI
*This
= NSURI_THIS(iface
);
1432 TRACE("(%p)->(%p %p)\n", This
, other
, _retval
);
1435 return nsIURI_Equals(This
->uri
, other
, _retval
);
1437 FIXME("default action not implemented\n");
1438 return NS_ERROR_NOT_IMPLEMENTED
;
1441 static nsresult NSAPI
nsURI_SchemeIs(nsIWineURI
*iface
, const char *scheme
, PRBool
*_retval
)
1443 nsURI
*This
= NSURI_THIS(iface
);
1445 TRACE("(%p)->(%s %p)\n", This
, debugstr_a(scheme
), _retval
);
1447 if(This
->use_wine_url
) {
1448 WCHAR buf
[INTERNET_MAX_SCHEME_LENGTH
];
1449 int len
= MultiByteToWideChar(CP_ACP
, 0, scheme
, -1, buf
, sizeof(buf
)/sizeof(WCHAR
))-1;
1451 *_retval
= strlenW(This
->wine_url
) > len
1452 && This
->wine_url
[len
] == ':'
1453 && !memcmp(buf
, This
->wine_url
, len
*sizeof(WCHAR
));
1458 return nsIURI_SchemeIs(This
->uri
, scheme
, _retval
);
1460 TRACE("returning error\n");
1461 return NS_ERROR_NOT_IMPLEMENTED
;
1464 static nsresult NSAPI
nsURI_Clone(nsIWineURI
*iface
, nsIURI
**_retval
)
1466 nsURI
*This
= NSURI_THIS(iface
);
1468 TRACE("(%p)->(%p)\n", This
, _retval
);
1472 nsIWineURI
*wine_uri
;
1475 nsres
= nsIURI_Clone(This
->uri
, &uri
);
1476 if(NS_FAILED(nsres
)) {
1477 WARN("Clone failed: %08x\n", nsres
);
1481 nsres
= create_uri(uri
, This
->container
, &wine_uri
);
1482 *_retval
= (nsIURI
*)wine_uri
;
1483 if(NS_SUCCEEDED(nsres
))
1484 return nsIWineURI_SetWineURL(wine_uri
, This
->wine_url
);
1488 FIXME("default action not implemented\n");
1489 return NS_ERROR_NOT_IMPLEMENTED
;
1492 static nsresult NSAPI
nsURI_Resolve(nsIWineURI
*iface
, const nsACString
*arelativePath
,
1493 nsACString
*_retval
)
1495 nsURI
*This
= NSURI_THIS(iface
);
1497 TRACE("(%p)->(%p %p)\n", This
, arelativePath
, _retval
);
1500 return nsIURI_Resolve(This
->uri
, arelativePath
, _retval
);
1502 FIXME("default action not implemented\n");
1503 return NS_ERROR_NOT_IMPLEMENTED
;
1506 static nsresult NSAPI
nsURI_GetAsciiSpec(nsIWineURI
*iface
, nsACString
*aAsciiSpec
)
1508 nsURI
*This
= NSURI_THIS(iface
);
1510 TRACE("(%p)->(%p)\n", This
, aAsciiSpec
);
1513 return nsIURI_GetSpec(NSURI(This
), aAsciiSpec
);
1516 return nsIURI_GetAsciiSpec(This
->uri
, aAsciiSpec
);
1518 TRACE("returning error\n");
1519 return NS_ERROR_NOT_IMPLEMENTED
;
1522 static nsresult NSAPI
nsURI_GetAsciiHost(nsIWineURI
*iface
, nsACString
*aAsciiHost
)
1524 nsURI
*This
= NSURI_THIS(iface
);
1526 TRACE("(%p)->(%p)\n", This
, aAsciiHost
);
1529 return nsIURI_GetAsciiHost(This
->uri
, aAsciiHost
);
1531 FIXME("default action not implemented\n");
1532 return NS_ERROR_NOT_IMPLEMENTED
;
1535 static nsresult NSAPI
nsURI_GetOriginCharset(nsIWineURI
*iface
, nsACString
*aOriginCharset
)
1537 nsURI
*This
= NSURI_THIS(iface
);
1539 TRACE("(%p)->(%p)\n", This
, aOriginCharset
);
1542 return nsIURI_GetOriginCharset(This
->uri
, aOriginCharset
);
1544 FIXME("default action not implemented\n");
1545 return NS_ERROR_NOT_IMPLEMENTED
;
1548 static nsresult NSAPI
nsURI_GetNSContainer(nsIWineURI
*iface
, NSContainer
**aContainer
)
1550 nsURI
*This
= NSURI_THIS(iface
);
1552 TRACE("(%p)->(%p)\n", This
, aContainer
);
1555 nsIWebBrowserChrome_AddRef(NSWBCHROME(This
->container
));
1556 *aContainer
= This
->container
;
1561 static nsresult NSAPI
nsURI_SetNSContainer(nsIWineURI
*iface
, NSContainer
*aContainer
)
1563 nsURI
*This
= NSURI_THIS(iface
);
1565 TRACE("(%p)->(%p)\n", This
, aContainer
);
1567 if(This
->container
) {
1568 if(This
->container
== aContainer
)
1570 WARN("Container already set: %p\n", This
->container
);
1571 nsIWebBrowserChrome_Release(NSWBCHROME(This
->container
));
1575 nsIWebBrowserChrome_AddRef(NSWBCHROME(aContainer
));
1576 This
->container
= aContainer
;
1581 static nsresult NSAPI
nsURI_GetIsDocumentURI(nsIWineURI
*iface
, PRBool
*aIsDocumentURI
)
1583 nsURI
*This
= NSURI_THIS(iface
);
1585 TRACE("(%p)->(%p)\n", This
, aIsDocumentURI
);
1587 *aIsDocumentURI
= This
->is_doc_uri
;
1591 static nsresult NSAPI
nsURI_SetIsDocumentURI(nsIWineURI
*iface
, PRBool aIsDocumentURI
)
1593 nsURI
*This
= NSURI_THIS(iface
);
1595 TRACE("(%p)->(%x)\n", This
, aIsDocumentURI
);
1597 This
->is_doc_uri
= aIsDocumentURI
;
1601 static nsresult NSAPI
nsURI_GetWineURL(nsIWineURI
*iface
, LPCWSTR
*aURL
)
1603 nsURI
*This
= NSURI_THIS(iface
);
1605 TRACE("(%p)->(%p)\n", This
, aURL
);
1607 *aURL
= This
->wine_url
;
1611 static nsresult NSAPI
nsURI_SetWineURL(nsIWineURI
*iface
, LPCWSTR aURL
)
1613 nsURI
*This
= NSURI_THIS(iface
);
1615 static const WCHAR wszFtp
[] = {'f','t','p',':'};
1616 static const WCHAR wszHttp
[] = {'h','t','t','p',':'};
1617 static const WCHAR wszHttps
[] = {'h','t','t','p','s',':'};
1619 TRACE("(%p)->(%s)\n", This
, debugstr_w(aURL
));
1621 mshtml_free(This
->wine_url
);
1624 int len
= strlenW(aURL
)+1;
1625 This
->wine_url
= mshtml_alloc(len
*sizeof(WCHAR
));
1626 memcpy(This
->wine_url
, aURL
, len
*sizeof(WCHAR
));
1628 /* FIXME: Always use wine url */
1629 This
->use_wine_url
=
1630 strncmpW(aURL
, wszFtp
, sizeof(wszFtp
)/sizeof(WCHAR
))
1631 && strncmpW(aURL
, wszHttp
, sizeof(wszHttp
)/sizeof(WCHAR
))
1632 && strncmpW(aURL
, wszHttps
, sizeof(wszHttps
)/sizeof(WCHAR
));
1634 This
->wine_url
= NULL
;
1635 This
->use_wine_url
= FALSE
;
1643 static const nsIWineURIVtbl nsWineURIVtbl
= {
1644 nsURI_QueryInterface
,
1672 nsURI_GetOriginCharset
,
1673 nsURI_GetNSContainer
,
1674 nsURI_SetNSContainer
,
1675 nsURI_GetIsDocumentURI
,
1676 nsURI_SetIsDocumentURI
,
1681 static nsresult
create_uri(nsIURI
*uri
, NSContainer
*container
, nsIWineURI
**_retval
)
1683 nsURI
*ret
= mshtml_alloc(sizeof(nsURI
));
1685 ret
->lpWineURIVtbl
= &nsWineURIVtbl
;
1688 ret
->container
= container
;
1689 ret
->wine_url
= NULL
;
1690 ret
->is_doc_uri
= FALSE
;
1691 ret
->use_wine_url
= FALSE
;
1694 nsIWebBrowserChrome_AddRef(NSWBCHROME(container
));
1696 TRACE("retval=%p\n", ret
);
1697 *_retval
= NSWINEURI(ret
);
1702 const nsIProtocolHandlerVtbl
*lpProtocolHandlerVtbl
;
1706 nsIProtocolHandler
*nshandler
;
1707 } nsProtocolHandler
;
1709 #define NSPROTHANDLER(x) ((nsIProtocolHandler*) &(x)->lpProtocolHandlerVtbl)
1711 #define NSPROTHANDLER_THIS(iface) DEFINE_THIS(nsProtocolHandler, ProtocolHandler, iface)
1713 static nsresult NSAPI
nsProtocolHandler_QueryInterface(nsIProtocolHandler
*iface
, nsIIDRef riid
,
1716 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
1720 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
1721 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
1722 *result
= NSPROTHANDLER(This
);
1723 }else if(IsEqualGUID(&IID_nsIProtocolHandler
, riid
)) {
1724 TRACE("(%p)->(IID_nsIProtocolHandler %p)\n", This
, result
);
1725 *result
= NSPROTHANDLER(This
);
1726 }else if(IsEqualGUID(&IID_nsIExternalProtocolHandler
, riid
)) {
1727 TRACE("(%p)->(IID_nsIExternalProtocolHandler %p), returning NULL\n", This
, result
);
1728 return NS_NOINTERFACE
;
1732 nsISupports_AddRef((nsISupports
*)*result
);
1736 WARN("(%s %p)\n", debugstr_guid(riid
), result
);
1737 return NS_NOINTERFACE
;
1740 static nsrefcnt NSAPI
nsProtocolHandler_AddRef(nsIProtocolHandler
*iface
)
1742 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
1743 LONG ref
= InterlockedIncrement(&This
->ref
);
1745 TRACE("(%p) ref=%d\n", This
, ref
);
1750 static nsrefcnt NSAPI
nsProtocolHandler_Release(nsIProtocolHandler
*iface
)
1752 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
1753 LONG ref
= InterlockedDecrement(&This
->ref
);
1755 TRACE("(%p) ref=%d\n", This
, ref
);
1759 nsIProtocolHandler_Release(This
->nshandler
);
1766 static nsresult NSAPI
nsProtocolHandler_GetScheme(nsIProtocolHandler
*iface
, nsACString
*aScheme
)
1768 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
1770 TRACE("(%p)->(%p)\n", This
, aScheme
);
1773 return nsIProtocolHandler_GetScheme(This
->nshandler
, aScheme
);
1774 return NS_ERROR_NOT_IMPLEMENTED
;
1777 static nsresult NSAPI
nsProtocolHandler_GetDefaultPort(nsIProtocolHandler
*iface
,
1778 PRInt32
*aDefaultPort
)
1780 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
1782 TRACE("(%p)->(%p)\n", This
, aDefaultPort
);
1785 return nsIProtocolHandler_GetDefaultPort(This
->nshandler
, aDefaultPort
);
1786 return NS_ERROR_NOT_IMPLEMENTED
;
1789 static nsresult NSAPI
nsProtocolHandler_GetProtocolFlags(nsIProtocolHandler
*iface
,
1790 PRUint32
*aProtocolFlags
)
1792 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
1794 TRACE("(%p)->(%p)\n", This
, aProtocolFlags
);
1797 return nsIProtocolHandler_GetProtocolFlags(This
->nshandler
, aProtocolFlags
);
1798 return NS_ERROR_NOT_IMPLEMENTED
;
1801 static nsresult NSAPI
nsProtocolHandler_NewURI(nsIProtocolHandler
*iface
,
1802 const nsACString
*aSpec
, const char *aOriginCharset
, nsIURI
*aBaseURI
, nsIURI
**_retval
)
1804 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
1806 TRACE("((%p)->%p %s %p %p)\n", This
, aSpec
, debugstr_a(aOriginCharset
), aBaseURI
, _retval
);
1809 return nsIProtocolHandler_NewURI(This
->nshandler
, aSpec
, aOriginCharset
, aBaseURI
, _retval
);
1810 return NS_ERROR_NOT_IMPLEMENTED
;
1813 static nsresult NSAPI
nsProtocolHandler_NewChannel(nsIProtocolHandler
*iface
,
1814 nsIURI
*aURI
, nsIChannel
**_retval
)
1816 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
1818 TRACE("(%p)->(%p %p)\n", This
, aURI
, _retval
);
1821 return nsIProtocolHandler_NewChannel(This
->nshandler
, aURI
, _retval
);
1822 return NS_ERROR_NOT_IMPLEMENTED
;
1825 static nsresult NSAPI
nsProtocolHandler_AllowPort(nsIProtocolHandler
*iface
,
1826 PRInt32 port
, const char *scheme
, PRBool
*_retval
)
1828 nsProtocolHandler
*This
= NSPROTHANDLER_THIS(iface
);
1830 TRACE("(%p)->(%d %s %p)\n", This
, port
, debugstr_a(scheme
), _retval
);
1833 return nsIProtocolHandler_AllowPort(This
->nshandler
, port
, scheme
, _retval
);
1834 return NS_ERROR_NOT_IMPLEMENTED
;
1837 #undef NSPROTHANDLER_THIS
1839 static const nsIProtocolHandlerVtbl nsProtocolHandlerVtbl
= {
1840 nsProtocolHandler_QueryInterface
,
1841 nsProtocolHandler_AddRef
,
1842 nsProtocolHandler_Release
,
1843 nsProtocolHandler_GetScheme
,
1844 nsProtocolHandler_GetDefaultPort
,
1845 nsProtocolHandler_GetProtocolFlags
,
1846 nsProtocolHandler_NewURI
,
1847 nsProtocolHandler_NewChannel
,
1848 nsProtocolHandler_AllowPort
1851 static nsIProtocolHandler
*create_protocol_handler(nsIProtocolHandler
*nshandler
)
1853 nsProtocolHandler
*ret
= mshtml_alloc(sizeof(nsProtocolHandler
));
1855 ret
->lpProtocolHandlerVtbl
= &nsProtocolHandlerVtbl
;
1857 ret
->nshandler
= nshandler
;
1859 return NSPROTHANDLER(ret
);
1862 static nsresult NSAPI
nsIOService_QueryInterface(nsIIOService
*iface
, nsIIDRef riid
,
1867 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
1868 TRACE("(IID_nsISupports %p)\n", result
);
1870 }else if(IsEqualGUID(&IID_nsIIOService
, riid
)) {
1871 TRACE("(IID_nsIIOService %p)\n", result
);
1876 nsIIOService_AddRef(iface
);
1880 WARN("(%s %p)\n", debugstr_guid(riid
), result
);
1881 return NS_NOINTERFACE
;
1884 static nsrefcnt NSAPI
nsIOService_AddRef(nsIIOService
*iface
)
1889 static nsrefcnt NSAPI
nsIOService_Release(nsIIOService
*iface
)
1894 static nsresult NSAPI
nsIOService_GetProtocolHandler(nsIIOService
*iface
, const char *aScheme
,
1895 nsIProtocolHandler
**_retval
)
1897 nsIExternalProtocolHandler
*nsexthandler
;
1898 nsIProtocolHandler
*nshandler
;
1901 TRACE("(%s %p)\n", debugstr_a(aScheme
), _retval
);
1903 nsres
= nsIIOService_GetProtocolHandler(nsio
, aScheme
, &nshandler
);
1904 if(NS_FAILED(nsres
)) {
1905 WARN("GetProtocolHandler failed: %08x\n", nsres
);
1909 nsres
= nsIProtocolHandler_QueryInterface(nshandler
, &IID_nsIExternalProtocolHandler
,
1910 (void**)&nsexthandler
);
1911 if(NS_FAILED(nsres
)) {
1912 *_retval
= nshandler
;
1916 nsIExternalProtocolHandler_Release(nsexthandler
);
1917 *_retval
= create_protocol_handler(nshandler
);
1918 TRACE("return %p\n", *_retval
);
1922 static nsresult NSAPI
nsIOService_GetProtocolFlags(nsIIOService
*iface
, const char *aScheme
,
1925 TRACE("(%s %p)\n", debugstr_a(aScheme
), _retval
);
1926 return nsIIOService_GetProtocolFlags(nsio
, aScheme
, _retval
);
1929 static nsresult NSAPI
nsIOService_NewURI(nsIIOService
*iface
, const nsACString
*aSpec
,
1930 const char *aOriginCharset
, nsIURI
*aBaseURI
, nsIURI
**_retval
)
1932 const char *spec
= NULL
;
1933 NSContainer
*nscontainer
= NULL
;
1935 PRBool is_javascript
= FALSE
;
1936 LPCWSTR base_wine_url
= NULL
;
1937 nsIWineURI
*base_wine_uri
= NULL
, *wine_uri
;
1940 nsACString_GetData(aSpec
, &spec
, NULL
);
1942 TRACE("(%p(%s) %s %p %p)\n", aSpec
, debugstr_a(spec
), debugstr_a(aOriginCharset
),
1946 nsACString base_uri_str
;
1947 const char *base_uri
= NULL
;
1949 static const char szChrome
[] = "chrome:";
1950 static const char szResource
[] = "resource:";
1952 nsACString_Init(&base_uri_str
, NULL
);
1954 nsres
= nsIURI_GetSpec(aBaseURI
, &base_uri_str
);
1955 if(NS_SUCCEEDED(nsres
)) {
1956 nsACString_GetData(&base_uri_str
, &base_uri
, NULL
);
1957 TRACE("base_uri=%s\n", debugstr_a(base_uri
));
1959 ERR("GetSpec failed: %08x\n", nsres
);
1962 nsACString_Finish(&base_uri_str
);
1964 if(!strncmp(spec
, szChrome
, sizeof(szChrome
)-1)
1965 || !strncmp(spec
, szResource
, sizeof(szResource
)-1))
1969 nsres
= nsIIOService_NewURI(nsio
, aSpec
, aOriginCharset
, aBaseURI
, &uri
);
1970 if(NS_FAILED(nsres
))
1971 TRACE("NewURI failed: %08x\n", nsres
);
1974 nsIURI_SchemeIs(uri
, "javascript", &is_javascript
);
1976 TRACE("returning javascript uri: %p\n", uri
);
1983 nsres
= nsIURI_QueryInterface(aBaseURI
, &IID_nsIWineURI
, (void**)&base_wine_uri
);
1984 if(NS_SUCCEEDED(nsres
)) {
1985 nsIWineURI_GetNSContainer(base_wine_uri
, &nscontainer
);
1986 nsIWineURI_GetWineURL(base_wine_uri
, &base_wine_url
);
1988 ERR("Could not get nsIWineURI: %08x\n", nsres
);
1992 nsres
= create_uri(uri
, nscontainer
, &wine_uri
);
1993 *_retval
= (nsIURI
*)wine_uri
;
1996 nsIWebBrowserChrome_Release(NSWBCHROME(nscontainer
));
1999 WCHAR url
[INTERNET_MAX_URL_LENGTH
], rel_url
[INTERNET_MAX_URL_LENGTH
];
2004 nsACString_GetData(aSpec
, &speca
, NULL
);
2005 MultiByteToWideChar(CP_ACP
, 0, speca
, -1, rel_url
, sizeof(rel_url
)/sizeof(WCHAR
));
2007 hres
= CoInternetCombineUrl(base_wine_url
, rel_url
,
2008 URL_ESCAPE_SPACES_ONLY
|URL_DONT_ESCAPE_EXTRA_INFO
,
2009 url
, sizeof(url
)/sizeof(WCHAR
), &len
, 0);
2011 nsIWineURI_SetWineURL(wine_uri
, url
);
2013 WARN("CoCombineUrl failed: %08x\n", hres
);
2017 nsIWineURI_Release(base_wine_uri
);
2022 static nsresult NSAPI
nsIOService_NewFileURI(nsIIOService
*iface
, nsIFile
*aFile
,
2025 TRACE("(%p %p)\n", aFile
, _retval
);
2026 return nsIIOService_NewFileURI(nsio
, aFile
, _retval
);
2029 static nsresult NSAPI
nsIOService_NewChannelFromURI(nsIIOService
*iface
, nsIURI
*aURI
,
2030 nsIChannel
**_retval
)
2032 nsIChannel
*channel
= NULL
;
2034 nsIWineURI
*wine_uri
;
2037 TRACE("(%p %p)\n", aURI
, _retval
);
2039 nsres
= nsIIOService_NewChannelFromURI(nsio
, aURI
, &channel
);
2040 if(NS_FAILED(nsres
) && nsres
!= NS_ERROR_UNKNOWN_PROTOCOL
) {
2041 WARN("NewChannelFromURI failed: %08x\n", nsres
);
2046 nsres
= nsIURI_QueryInterface(aURI
, &IID_nsIWineURI
, (void**)&wine_uri
);
2047 if(NS_FAILED(nsres
)) {
2048 WARN("Could not get nsIWineURI: %08x\n", nsres
);
2050 return channel
? NS_OK
: NS_ERROR_UNEXPECTED
;
2053 ret
= mshtml_alloc(sizeof(nsChannel
));
2055 ret
->lpHttpChannelVtbl
= &nsChannelVtbl
;
2056 ret
->lpUploadChannelVtbl
= &nsUploadChannelVtbl
;
2058 ret
->channel
= channel
;
2059 ret
->http_channel
= NULL
;
2060 ret
->uri
= wine_uri
;
2061 ret
->post_data_stream
= NULL
;
2062 ret
->load_group
= NULL
;
2063 ret
->notif_callback
= NULL
;
2064 ret
->load_flags
= 0;
2065 ret
->content
= NULL
;
2066 ret
->charset
= NULL
;
2068 nsIURI_AddRef(aURI
);
2069 ret
->original_uri
= aURI
;
2072 nsIChannel_QueryInterface(channel
, &IID_nsIHttpChannel
, (void**)&ret
->http_channel
);
2074 *_retval
= NSCHANNEL(ret
);
2078 static nsresult NSAPI
nsIOService_NewChannel(nsIIOService
*iface
, const nsACString
*aSpec
,
2079 const char *aOriginCharset
, nsIURI
*aBaseURI
, nsIChannel
**_retval
)
2081 TRACE("(%p %s %p %p)\n", aSpec
, debugstr_a(aOriginCharset
), aBaseURI
, _retval
);
2082 return nsIIOService_NewChannel(nsio
, aSpec
, aOriginCharset
, aBaseURI
, _retval
);
2085 static nsresult NSAPI
nsIOService_GetOffline(nsIIOService
*iface
, PRBool
*aOffline
)
2087 TRACE("(%p)\n", aOffline
);
2088 return nsIIOService_GetOffline(nsio
, aOffline
);
2091 static nsresult NSAPI
nsIOService_SetOffline(nsIIOService
*iface
, PRBool aOffline
)
2093 TRACE("(%x)\n", aOffline
);
2094 return nsIIOService_SetOffline(nsio
, aOffline
);
2097 static nsresult NSAPI
nsIOService_AllowPort(nsIIOService
*iface
, PRInt32 aPort
,
2098 const char *aScheme
, PRBool
*_retval
)
2100 TRACE("(%d %s %p)\n", aPort
, debugstr_a(aScheme
), _retval
);
2101 return nsIIOService_AllowPort(nsio
, aPort
, debugstr_a(aScheme
), _retval
);
2104 static nsresult NSAPI
nsIOService_ExtractScheme(nsIIOService
*iface
, const nsACString
*urlString
,
2105 nsACString
* _retval
)
2107 TRACE("(%p %p)\n", urlString
, _retval
);
2108 return nsIIOService_ExtractScheme(nsio
, urlString
, _retval
);
2111 static const nsIIOServiceVtbl nsIOServiceVtbl
= {
2112 nsIOService_QueryInterface
,
2114 nsIOService_Release
,
2115 nsIOService_GetProtocolHandler
,
2116 nsIOService_GetProtocolFlags
,
2118 nsIOService_NewFileURI
,
2119 nsIOService_NewChannelFromURI
,
2120 nsIOService_NewChannel
,
2121 nsIOService_GetOffline
,
2122 nsIOService_SetOffline
,
2123 nsIOService_AllowPort
,
2124 nsIOService_ExtractScheme
2127 static nsIIOService nsIOService
= { &nsIOServiceVtbl
};
2129 static nsresult NSAPI
nsIOServiceFactory_QueryInterface(nsIFactory
*iface
, nsIIDRef riid
,
2134 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
2135 TRACE("(IID_nsISupoprts %p)\n", result
);
2137 }else if(IsEqualGUID(&IID_nsIFactory
, riid
)) {
2138 TRACE("(IID_nsIFactory %p)\n", result
);
2143 nsIFactory_AddRef(iface
);
2147 WARN("(%s %p)\n", debugstr_guid(riid
), result
);
2148 return NS_NOINTERFACE
;
2151 static nsrefcnt NSAPI
nsIOServiceFactory_AddRef(nsIFactory
*iface
)
2156 static nsrefcnt NSAPI
nsIOServiceFactory_Release(nsIFactory
*iface
)
2161 static nsresult NSAPI
nsIOServiceFactory_CreateInstance(nsIFactory
*iface
,
2162 nsISupports
*aOuter
, const nsIID
*iid
, void **result
)
2164 return nsIIOService_QueryInterface(&nsIOService
, iid
, result
);
2167 static nsresult NSAPI
nsIOServiceFactory_LockFactory(nsIFactory
*iface
, PRBool lock
)
2169 WARN("(%x)\n", lock
);
2173 static const nsIFactoryVtbl nsIOServiceFactoryVtbl
= {
2174 nsIOServiceFactory_QueryInterface
,
2175 nsIOServiceFactory_AddRef
,
2176 nsIOServiceFactory_Release
,
2177 nsIOServiceFactory_CreateInstance
,
2178 nsIOServiceFactory_LockFactory
2181 static nsIFactory nsIOServiceFactory
= { &nsIOServiceFactoryVtbl
};
2183 void init_nsio(nsIComponentManager
*component_manager
, nsIComponentRegistrar
*registrar
)
2185 nsIFactory
*old_factory
= NULL
;
2188 nsres
= nsIComponentManager_GetClassObject(component_manager
, &NS_IOSERVICE_CID
,
2189 &IID_nsIFactory
, (void**)&old_factory
);
2190 if(NS_FAILED(nsres
)) {
2191 ERR("Could not get factory: %08x\n", nsres
);
2192 nsIFactory_Release(old_factory
);
2196 nsres
= nsIFactory_CreateInstance(old_factory
, NULL
, &IID_nsIIOService
, (void**)&nsio
);
2197 if(NS_FAILED(nsres
)) {
2198 ERR("Couldn not create nsIOService instance %08x\n", nsres
);
2199 nsIFactory_Release(old_factory
);
2203 nsres
= nsIComponentRegistrar_UnregisterFactory(registrar
, &NS_IOSERVICE_CID
, old_factory
);
2204 nsIFactory_Release(old_factory
);
2205 if(NS_FAILED(nsres
))
2206 ERR("UnregisterFactory failed: %08x\n", nsres
);
2208 nsres
= nsIComponentRegistrar_RegisterFactory(registrar
, &NS_IOSERVICE_CID
,
2209 NS_IOSERVICE_CLASSNAME
, NS_IOSERVICE_CONTRACTID
, &nsIOServiceFactory
);
2210 if(NS_FAILED(nsres
))
2211 ERR("RegisterFactory failed: %08x\n", nsres
);