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
;
62 #define NSURI(x) ((nsIURI*) &(x)->lpWineURIVtbl)
63 #define NSWINEURI(x) ((nsIWineURI*) &(x)->lpWineURIVtbl)
65 static nsresult
create_uri(nsIURI
*,NSContainer
*,nsIWineURI
**);
67 static BOOL
exec_shldocvw_67(HTMLDocument
*doc
, LPCWSTR url
)
69 IOleCommandTarget
*cmdtrg
= NULL
;
72 hres
= IOleClientSite_QueryInterface(doc
->client
, &IID_IOleCommandTarget
,
75 VARIANT varUrl
, varRes
;
77 V_VT(&varUrl
) = VT_BSTR
;
78 V_BSTR(&varUrl
) = SysAllocString(url
);
79 V_VT(&varRes
) = VT_BOOL
;
81 hres
= IOleCommandTarget_Exec(cmdtrg
, &CGID_ShellDocView
, 67, 0, &varUrl
, &varRes
);
83 IOleCommandTarget_Release(cmdtrg
);
84 SysFreeString(V_BSTR(&varUrl
));
86 if(SUCCEEDED(hres
) && !V_BOOL(&varRes
)) {
87 TRACE("got VARIANT_FALSE, do not load\n");
95 static BOOL
handle_uri(NSContainer
*container
, nsChannel
*channel
, LPCWSTR uri
)
97 IServiceProvider
*service_provider
;
98 HTMLDocument
*doc
= container
->doc
;
103 NSContainer
*container_iter
= container
;
105 hlnf
= HLNF_OPENINNEWWINDOW
;
106 while(!container_iter
->doc
)
107 container_iter
= container_iter
->parent
;
108 doc
= container_iter
->doc
;
111 if(!hlnf
&& !exec_shldocvw_67(doc
, uri
))
114 hres
= IOleClientSite_QueryInterface(doc
->client
, &IID_IServiceProvider
,
115 (void**)&service_provider
);
116 if(SUCCEEDED(hres
)) {
117 IHlinkFrame
*hlink_frame
;
119 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHlinkFrame
,
120 &IID_IHlinkFrame
, (void**)&hlink_frame
);
121 IServiceProvider_Release(service_provider
);
122 if(SUCCEEDED(hres
)) {
123 hlink_frame_navigate(doc
, hlink_frame
, uri
, channel
->post_data_stream
, hlnf
);
124 IHlinkFrame_Release(hlink_frame
);
133 static BOOL
before_async_open(nsChannel
*channel
, NSContainer
*container
)
141 nsACString_Init(&uri_str
, NULL
);
142 nsIWineURI_GetSpec(channel
->uri
, &uri_str
);
143 nsACString_GetData(&uri_str
, &uria
, NULL
);
144 len
= MultiByteToWideChar(CP_ACP
, 0, uria
, -1, NULL
, 0);
145 uri
= mshtml_alloc(len
*sizeof(WCHAR
));
146 MultiByteToWideChar(CP_ACP
, 0, uria
, -1, uri
, len
);
147 nsACString_Finish(&uri_str
);
149 ret
= handle_uri(container
, channel
, uri
);
156 #define NSCHANNEL_THIS(iface) DEFINE_THIS(nsChannel, HttpChannel, iface)
158 static nsresult NSAPI
nsChannel_QueryInterface(nsIHttpChannel
*iface
, nsIIDRef riid
, nsQIResult result
)
160 nsChannel
*This
= NSCHANNEL_THIS(iface
);
164 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
165 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
166 *result
= NSCHANNEL(This
);
167 }else if(IsEqualGUID(&IID_nsIRequest
, riid
)) {
168 TRACE("(%p)->(IID_nsIRequest %p)\n", This
, result
);
169 *result
= NSCHANNEL(This
);
170 }else if(IsEqualGUID(&IID_nsIChannel
, riid
)) {
171 TRACE("(%p)->(IID_nsIChannel %p)\n", This
, result
);
172 *result
= NSCHANNEL(This
);
173 }else if(This
->http_channel
&& IsEqualGUID(&IID_nsIHttpChannel
, riid
)) {
174 TRACE("(%p)->(IID_nsIHttpChannel %p)\n", This
, result
);
175 *result
= NSHTTPCHANNEL(This
);
176 }else if(IsEqualGUID(&IID_nsIUploadChannel
, riid
)) {
177 TRACE("(%p)->(IID_nsIUploadChannel %p)\n", This
, result
);
178 *result
= NSUPCHANNEL(This
);
182 nsIChannel_AddRef(NSCHANNEL(This
));
186 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), result
);
189 return nsIChannel_QueryInterface(This
->channel
, riid
, result
);
190 return NS_NOINTERFACE
;
193 static nsrefcnt NSAPI
nsChannel_AddRef(nsIHttpChannel
*iface
)
195 nsChannel
*This
= NSCHANNEL_THIS(iface
);
196 nsrefcnt ref
= InterlockedIncrement(&This
->ref
);
198 TRACE("(%p) ref=%d\n", This
, ref
);
203 static nsrefcnt NSAPI
nsChannel_Release(nsIHttpChannel
*iface
)
205 nsChannel
*This
= NSCHANNEL_THIS(iface
);
206 LONG ref
= InterlockedDecrement(&This
->ref
);
209 nsIWineURI_Release(This
->uri
);
211 nsIChannel_Release(This
->channel
);
212 if(This
->http_channel
)
213 nsIHttpChannel_Release(This
->http_channel
);
214 if(This
->post_data_stream
)
215 nsIInputStream_Release(This
->post_data_stream
);
217 nsILoadGroup_Release(This
->load_group
);
218 if(This
->notif_callback
)
219 nsIInterfaceRequestor_Release(This
->notif_callback
);
220 if(This
->original_uri
)
221 nsIURI_Release(This
->original_uri
);
222 mshtml_free(This
->content
);
229 static nsresult NSAPI
nsChannel_GetName(nsIHttpChannel
*iface
, nsACString
*aName
)
231 nsChannel
*This
= NSCHANNEL_THIS(iface
);
233 TRACE("(%p)->(%p)\n", This
, aName
);
236 return nsIChannel_GetName(This
->channel
, aName
);
238 FIXME("default action not implemented\n");
239 return NS_ERROR_NOT_IMPLEMENTED
;
242 static nsresult NSAPI
nsChannel_IsPending(nsIHttpChannel
*iface
, PRBool
*_retval
)
244 nsChannel
*This
= NSCHANNEL_THIS(iface
);
246 TRACE("(%p)->(%p)\n", This
, _retval
);
249 return nsIChannel_IsPending(This
->channel
, _retval
);
251 FIXME("default action not implemented\n");
252 return NS_ERROR_NOT_IMPLEMENTED
;
255 static nsresult NSAPI
nsChannel_GetStatus(nsIHttpChannel
*iface
, nsresult
*aStatus
)
257 nsChannel
*This
= NSCHANNEL_THIS(iface
);
259 TRACE("(%p)->(%p)\n", This
, aStatus
);
262 return nsIChannel_GetStatus(This
->channel
, aStatus
);
264 TRACE("returning NS_OK\n");
265 return *aStatus
= NS_OK
;
268 static nsresult NSAPI
nsChannel_Cancel(nsIHttpChannel
*iface
, nsresult aStatus
)
270 nsChannel
*This
= NSCHANNEL_THIS(iface
);
272 TRACE("(%p)->(%08x)\n", This
, aStatus
);
275 return nsIChannel_Cancel(This
->channel
, aStatus
);
277 FIXME("default action not implemented\n");
278 return NS_ERROR_NOT_IMPLEMENTED
;
281 static nsresult NSAPI
nsChannel_Suspend(nsIHttpChannel
*iface
)
283 nsChannel
*This
= NSCHANNEL_THIS(iface
);
285 TRACE("(%p)\n", This
);
288 return nsIChannel_Suspend(This
->channel
);
290 FIXME("default action not implemented\n");
291 return NS_ERROR_NOT_IMPLEMENTED
;
294 static nsresult NSAPI
nsChannel_Resume(nsIHttpChannel
*iface
)
296 nsChannel
*This
= NSCHANNEL_THIS(iface
);
298 TRACE("(%p)\n", This
);
301 return nsIChannel_Resume(This
->channel
);
303 FIXME("default action not implemented\n");
304 return NS_ERROR_NOT_IMPLEMENTED
;
307 static nsresult NSAPI
nsChannel_GetLoadGroup(nsIHttpChannel
*iface
, nsILoadGroup
**aLoadGroup
)
309 nsChannel
*This
= NSCHANNEL_THIS(iface
);
311 TRACE("(%p)->(%p)\n", This
, aLoadGroup
);
314 nsILoadGroup_AddRef(This
->load_group
);
316 *aLoadGroup
= This
->load_group
;
320 static nsresult NSAPI
nsChannel_SetLoadGroup(nsIHttpChannel
*iface
, nsILoadGroup
*aLoadGroup
)
322 nsChannel
*This
= NSCHANNEL_THIS(iface
);
324 TRACE("(%p)->(%p)\n", This
, aLoadGroup
);
327 nsILoadGroup_Release(This
->load_group
);
329 nsILoadGroup_AddRef(aLoadGroup
);
331 This
->load_group
= aLoadGroup
;
334 return nsIChannel_SetLoadGroup(This
->channel
, aLoadGroup
);
338 static nsresult NSAPI
nsChannel_GetLoadFlags(nsIHttpChannel
*iface
, nsLoadFlags
*aLoadFlags
)
340 nsChannel
*This
= NSCHANNEL_THIS(iface
);
342 TRACE("(%p)->(%p)\n", This
, aLoadFlags
);
344 *aLoadFlags
= This
->load_flags
;
348 static nsresult NSAPI
nsChannel_SetLoadFlags(nsIHttpChannel
*iface
, nsLoadFlags aLoadFlags
)
350 nsChannel
*This
= NSCHANNEL_THIS(iface
);
352 TRACE("(%p)->(%08x)\n", This
, aLoadFlags
);
354 This
->load_flags
= aLoadFlags
;
357 return nsIChannel_SetLoadFlags(This
->channel
, aLoadFlags
);
361 static nsresult NSAPI
nsChannel_GetOriginalURI(nsIHttpChannel
*iface
, nsIURI
**aOriginalURI
)
363 nsChannel
*This
= NSCHANNEL_THIS(iface
);
365 TRACE("(%p)->(%p)\n", This
, aOriginalURI
);
367 if(This
->original_uri
)
368 nsIURI_AddRef(This
->original_uri
);
370 *aOriginalURI
= This
->original_uri
;
374 static nsresult NSAPI
nsChannel_SetOriginalURI(nsIHttpChannel
*iface
, nsIURI
*aOriginalURI
)
376 nsChannel
*This
= NSCHANNEL_THIS(iface
);
378 TRACE("(%p)->(%p)\n", This
, aOriginalURI
);
380 if(This
->original_uri
)
381 nsIURI_Release(This
->original_uri
);
383 nsIURI_AddRef(aOriginalURI
);
384 This
->original_uri
= aOriginalURI
;
387 return nsIChannel_SetOriginalURI(This
->channel
, aOriginalURI
);
391 static nsresult NSAPI
nsChannel_GetURI(nsIHttpChannel
*iface
, nsIURI
**aURI
)
393 nsChannel
*This
= NSCHANNEL_THIS(iface
);
395 TRACE("(%p)->(%p)\n", This
, aURI
);
397 nsIWineURI_AddRef(This
->uri
);
398 *aURI
= (nsIURI
*)This
->uri
;
403 static nsresult NSAPI
nsChannel_GetOwner(nsIHttpChannel
*iface
, nsISupports
**aOwner
)
405 nsChannel
*This
= NSCHANNEL_THIS(iface
);
407 TRACE("(%p)->(%p)\n", This
, aOwner
);
410 return nsIChannel_GetOwner(This
->channel
, aOwner
);
412 FIXME("default action not implemented\n");
413 return NS_ERROR_NOT_IMPLEMENTED
;
416 static nsresult NSAPI
nsChannel_SetOwner(nsIHttpChannel
*iface
, nsISupports
*aOwner
)
418 nsChannel
*This
= NSCHANNEL_THIS(iface
);
420 TRACE("(%p)->(%p)\n", This
, aOwner
);
423 return nsIChannel_SetOwner(This
->channel
, aOwner
);
425 FIXME("default action not implemented\n");
426 return NS_ERROR_NOT_IMPLEMENTED
;
429 static nsresult NSAPI
nsChannel_GetNotificationCallbacks(nsIHttpChannel
*iface
,
430 nsIInterfaceRequestor
**aNotificationCallbacks
)
432 nsChannel
*This
= NSCHANNEL_THIS(iface
);
434 TRACE("(%p)->(%p)\n", This
, aNotificationCallbacks
);
436 if(This
->notif_callback
)
437 nsIInterfaceRequestor_AddRef(This
->notif_callback
);
438 *aNotificationCallbacks
= This
->notif_callback
;
443 static nsresult NSAPI
nsChannel_SetNotificationCallbacks(nsIHttpChannel
*iface
,
444 nsIInterfaceRequestor
*aNotificationCallbacks
)
446 nsChannel
*This
= NSCHANNEL_THIS(iface
);
448 TRACE("(%p)->(%p)\n", This
, aNotificationCallbacks
);
450 if(This
->notif_callback
)
451 nsIInterfaceRequestor_Release(This
->notif_callback
);
452 if(aNotificationCallbacks
)
453 nsIInterfaceRequestor_AddRef(aNotificationCallbacks
);
455 This
->notif_callback
= aNotificationCallbacks
;
458 return nsIChannel_SetNotificationCallbacks(This
->channel
, aNotificationCallbacks
);
462 static nsresult NSAPI
nsChannel_GetSecurityInfo(nsIHttpChannel
*iface
, nsISupports
**aSecurityInfo
)
464 nsChannel
*This
= NSCHANNEL_THIS(iface
);
466 TRACE("(%p)->(%p)\n", This
, aSecurityInfo
);
469 return nsIChannel_GetSecurityInfo(This
->channel
, aSecurityInfo
);
471 FIXME("default action not implemented\n");
472 return NS_ERROR_NOT_IMPLEMENTED
;
475 static nsresult NSAPI
nsChannel_GetContentType(nsIHttpChannel
*iface
, nsACString
*aContentType
)
477 nsChannel
*This
= NSCHANNEL_THIS(iface
);
479 TRACE("(%p)->(%p)\n", This
, aContentType
);
482 nsACString_SetData(aContentType
, This
->content
);
487 return nsIChannel_GetContentType(This
->channel
, aContentType
);
489 TRACE("returning default text/html\n");
490 nsACString_SetData(aContentType
, "text/html");
494 static nsresult NSAPI
nsChannel_SetContentType(nsIHttpChannel
*iface
,
495 const nsACString
*aContentType
)
497 nsChannel
*This
= NSCHANNEL_THIS(iface
);
499 TRACE("(%p)->(%p)\n", This
, aContentType
);
502 return nsIChannel_SetContentType(This
->channel
, aContentType
);
504 FIXME("default action not implemented\n");
505 return NS_ERROR_NOT_IMPLEMENTED
;
508 static nsresult NSAPI
nsChannel_GetContentCharset(nsIHttpChannel
*iface
,
509 nsACString
*aContentCharset
)
511 nsChannel
*This
= NSCHANNEL_THIS(iface
);
513 TRACE("(%p)->(%p)\n", This
, aContentCharset
);
516 return nsIChannel_GetContentCharset(This
->channel
, aContentCharset
);
518 FIXME("default action not implemented\n");
519 return NS_ERROR_NOT_IMPLEMENTED
;
522 static nsresult NSAPI
nsChannel_SetContentCharset(nsIHttpChannel
*iface
,
523 const nsACString
*aContentCharset
)
525 nsChannel
*This
= NSCHANNEL_THIS(iface
);
527 TRACE("(%p)->(%p)\n", This
, aContentCharset
);
530 return nsIChannel_SetContentCharset(This
->channel
, aContentCharset
);
532 FIXME("default action not implemented\n");
533 return NS_ERROR_NOT_IMPLEMENTED
;
536 static nsresult NSAPI
nsChannel_GetContentLength(nsIHttpChannel
*iface
, PRInt32
*aContentLength
)
538 nsChannel
*This
= NSCHANNEL_THIS(iface
);
540 TRACE("(%p)->(%p)\n", This
, aContentLength
);
543 return nsIChannel_GetContentLength(This
->channel
, aContentLength
);
545 FIXME("default action not implemented\n");
546 return NS_ERROR_NOT_IMPLEMENTED
;
549 static nsresult NSAPI
nsChannel_SetContentLength(nsIHttpChannel
*iface
, PRInt32 aContentLength
)
551 nsChannel
*This
= NSCHANNEL_THIS(iface
);
553 TRACE("(%p)->(%d)\n", This
, aContentLength
);
556 return nsIChannel_SetContentLength(This
->channel
, aContentLength
);
558 FIXME("default action not implemented\n");
559 return NS_ERROR_NOT_IMPLEMENTED
;
562 static nsresult NSAPI
nsChannel_Open(nsIHttpChannel
*iface
, nsIInputStream
**_retval
)
564 nsChannel
*This
= NSCHANNEL_THIS(iface
);
566 TRACE("(%p)->(%p)\n", This
, _retval
);
569 return nsIChannel_Open(This
->channel
, _retval
);
571 FIXME("default action not implemented\n");
572 return NS_ERROR_NOT_IMPLEMENTED
;
575 static BOOL
do_load_from_moniker_hack(nsChannel
*This
)
580 * We should always load the page from IMoniker, but Wine is not yet
581 * ready for this. This function is a heuristic, that decides which
582 * way of loading is better (Gecko implementation or IMoniker). The
583 * aim is to always return TRUE.
586 /* Load from moniker if there is no Gecko channel available */
590 /* Load about protocol from moniker */
591 nsIWineURI_SchemeIs(This
->uri
, "about", &b
);
598 static nsresult NSAPI
nsChannel_AsyncOpen(nsIHttpChannel
*iface
, nsIStreamListener
*aListener
,
599 nsISupports
*aContext
)
601 nsChannel
*This
= NSCHANNEL_THIS(iface
);
602 BSCallback
*bscallback
;
603 nsIWineURI
*wine_uri
;
611 TRACE("(%p)->(%p %p)\n", This
, aListener
, aContext
);
613 nsIWineURI_GetIsDocumentURI(This
->uri
, &is_doc_uri
);
615 if(is_doc_uri
&& (This
->load_flags
& LOAD_INITIAL_DOCUMENT_URI
)) {
616 NSContainer
*container
;
618 nsIWineURI_GetNSContainer(This
->uri
, &container
);
620 TRACE("container = NULL\n");
621 return nsIChannel_AsyncOpen(This
->channel
, aListener
, aContext
);
624 if(container
->bscallback
) {
625 nsIChannel_AddRef(NSCHANNEL(This
));
626 container
->bscallback
->nschannel
= This
;
628 nsIStreamListener_AddRef(aListener
);
629 container
->bscallback
->nslistener
= aListener
;
632 nsISupports_AddRef(aContext
);
633 container
->bscallback
->nscontext
= aContext
;
636 nsIWebBrowserChrome_Release(NSWBCHROME(container
));
638 if(do_load_from_moniker_hack(This
))
639 return WINE_NS_LOAD_FROM_MONIKER
;
640 }else if(container
->doc
) {
641 BOOL cont
= before_async_open(This
, container
);
642 nsIWebBrowserChrome_Release(NSWBCHROME(container
));
646 return NS_ERROR_UNEXPECTED
;
649 nsIWebBrowserChrome_Release(NSWBCHROME(container
));
651 ? nsIChannel_AsyncOpen(This
->channel
, aListener
, aContext
)
652 : NS_ERROR_UNEXPECTED
;
657 if(This
->post_data_stream
) {
658 nsIUploadChannel
*upload_channel
;
660 nsres
= nsIChannel_QueryInterface(This
->channel
, &IID_nsIUploadChannel
,
661 (void**)&upload_channel
);
662 if(NS_SUCCEEDED(nsres
)) {
663 nsACString empty_string
;
664 nsACString_Init(&empty_string
, "");
666 nsres
= nsIUploadChannel_SetUploadStream(upload_channel
, This
->post_data_stream
,
668 nsIUploadChannel_Release(upload_channel
);
670 WARN("SetUploadStream failed: %08x\n", nsres
);
672 nsACString_Finish(&empty_string
);
676 nsres
= nsIChannel_AsyncOpen(This
->channel
, aListener
, aContext
);
678 if(NS_FAILED(nsres
) && (This
->load_flags
& LOAD_INITIAL_DOCUMENT_URI
))
679 return WINE_NS_LOAD_FROM_MONIKER
;
683 TRACE("channel == NULL\n");
685 if(!This
->original_uri
) {
686 ERR("original_uri == NULL\n");
687 return NS_ERROR_UNEXPECTED
;
690 nsres
= nsIURI_QueryInterface(This
->original_uri
, &IID_nsIWineURI
, (void**)&wine_uri
);
691 if(NS_FAILED(nsres
)) {
692 ERR("Could not get nsIWineURI: %08x\n", nsres
);
693 return NS_ERROR_UNEXPECTED
;
696 nsIWineURI_GetWineURL(wine_uri
, &wine_url
);
698 TRACE("wine_url == NULL\n");
699 return NS_ERROR_UNEXPECTED
;
702 hres
= CreateURLMoniker(NULL
, wine_url
, &mon
);
704 WARN("CreateURLMonikrer failed: %08x\n", hres
);
705 return NS_ERROR_UNEXPECTED
;
708 bscallback
= create_bscallback(mon
);
709 IMoniker_Release(mon
);
711 nsIChannel_AddRef(NSCHANNEL(This
));
712 bscallback
->nschannel
= This
;
714 nsIStreamListener_AddRef(aListener
);
715 bscallback
->nslistener
= aListener
;
718 nsISupports_AddRef(aContext
);
719 bscallback
->nscontext
= aContext
;
722 task
= mshtml_alloc(sizeof(task_t
));
724 task
->doc
= bscallback
->doc
;
725 task
->task_id
= TASK_START_BINDING
;
727 task
->bscallback
= bscallback
;
734 static nsresult NSAPI
nsChannel_GetRequestMethod(nsIHttpChannel
*iface
, nsACString
*aRequestMethod
)
736 nsChannel
*This
= NSCHANNEL_THIS(iface
);
738 TRACE("(%p)->(%p)\n", This
, aRequestMethod
);
740 if(This
->http_channel
)
741 return nsIHttpChannel_GetRequestMethod(This
->http_channel
, aRequestMethod
);
743 return NS_ERROR_NOT_IMPLEMENTED
;
746 static nsresult NSAPI
nsChannel_SetRequestMethod(nsIHttpChannel
*iface
,
747 const nsACString
*aRequestMethod
)
749 nsChannel
*This
= NSCHANNEL_THIS(iface
);
751 TRACE("(%p)->(%p)\n", This
, aRequestMethod
);
753 if(This
->http_channel
)
754 return nsIHttpChannel_SetRequestMethod(This
->http_channel
, aRequestMethod
);
756 return NS_ERROR_NOT_IMPLEMENTED
;
759 static nsresult NSAPI
nsChannel_GetReferrer(nsIHttpChannel
*iface
, nsIURI
**aReferrer
)
761 nsChannel
*This
= NSCHANNEL_THIS(iface
);
763 TRACE("(%p)->(%p)\n", This
, aReferrer
);
765 if(This
->http_channel
)
766 return nsIHttpChannel_GetReferrer(This
->http_channel
, aReferrer
);
768 return NS_ERROR_NOT_IMPLEMENTED
;
771 static nsresult NSAPI
nsChannel_SetReferrer(nsIHttpChannel
*iface
, nsIURI
*aReferrer
)
773 nsChannel
*This
= NSCHANNEL_THIS(iface
);
775 TRACE("(%p)->(%p)\n", This
, aReferrer
);
777 if(This
->http_channel
)
778 return nsIHttpChannel_SetReferrer(This
->http_channel
, aReferrer
);
780 return NS_ERROR_NOT_IMPLEMENTED
;
783 static nsresult NSAPI
nsChannel_GetRequestHeader(nsIHttpChannel
*iface
,
784 const nsACString
*aHeader
, nsACString
*_retval
)
786 nsChannel
*This
= NSCHANNEL_THIS(iface
);
788 TRACE("(%p)->(%p %p)\n", This
, aHeader
, _retval
);
790 if(This
->http_channel
)
791 return nsIHttpChannel_GetRequestHeader(This
->http_channel
, aHeader
, _retval
);
793 return NS_ERROR_NOT_IMPLEMENTED
;
796 static nsresult NSAPI
nsChannel_SetRequestHeader(nsIHttpChannel
*iface
,
797 const nsACString
*aHeader
, const nsACString
*aValue
, PRBool aMerge
)
799 nsChannel
*This
= NSCHANNEL_THIS(iface
);
801 TRACE("(%p)->(%p %p %x)\n", This
, aHeader
, aValue
, aMerge
);
803 if(This
->http_channel
)
804 return nsIHttpChannel_SetRequestHeader(This
->http_channel
, aHeader
, aValue
, aMerge
);
806 return NS_ERROR_NOT_IMPLEMENTED
;
809 static nsresult NSAPI
nsChannel_VisitRequestHeaders(nsIHttpChannel
*iface
,
810 nsIHttpHeaderVisitor
*aVisitor
)
812 nsChannel
*This
= NSCHANNEL_THIS(iface
);
814 TRACE("(%p)->(%p)\n", This
, aVisitor
);
816 if(This
->http_channel
)
817 return nsIHttpChannel_VisitRequestHeaders(This
->http_channel
, aVisitor
);
819 return NS_ERROR_NOT_IMPLEMENTED
;
822 static nsresult NSAPI
nsChannel_GetAllowPipelining(nsIHttpChannel
*iface
, PRBool
*aAllowPipelining
)
824 nsChannel
*This
= NSCHANNEL_THIS(iface
);
826 TRACE("(%p)->(%p)\n", This
, aAllowPipelining
);
828 if(This
->http_channel
)
829 return nsIHttpChannel_GetAllowPipelining(This
->http_channel
, aAllowPipelining
);
831 return NS_ERROR_NOT_IMPLEMENTED
;
834 static nsresult NSAPI
nsChannel_SetAllowPipelining(nsIHttpChannel
*iface
, PRBool aAllowPipelining
)
836 nsChannel
*This
= NSCHANNEL_THIS(iface
);
838 TRACE("(%p)->(%x)\n", This
, aAllowPipelining
);
840 if(This
->http_channel
)
841 return nsIHttpChannel_SetAllowPipelining(This
->http_channel
, aAllowPipelining
);
843 return NS_ERROR_NOT_IMPLEMENTED
;
846 static nsresult NSAPI
nsChannel_GetRedirectionLimit(nsIHttpChannel
*iface
, PRUint32
*aRedirectionLimit
)
848 nsChannel
*This
= NSCHANNEL_THIS(iface
);
850 TRACE("(%p)->(%p)\n", This
, aRedirectionLimit
);
852 if(This
->http_channel
)
853 return nsIHttpChannel_GetRedirectionLimit(This
->http_channel
, aRedirectionLimit
);
855 return NS_ERROR_NOT_IMPLEMENTED
;
858 static nsresult NSAPI
nsChannel_SetRedirectionLimit(nsIHttpChannel
*iface
, PRUint32 aRedirectionLimit
)
860 nsChannel
*This
= NSCHANNEL_THIS(iface
);
862 TRACE("(%p)->(%u)\n", This
, aRedirectionLimit
);
864 if(This
->http_channel
)
865 return nsIHttpChannel_SetRedirectionLimit(This
->http_channel
, aRedirectionLimit
);
867 return NS_ERROR_NOT_IMPLEMENTED
;
870 static nsresult NSAPI
nsChannel_GetResponseStatus(nsIHttpChannel
*iface
, PRUint32
*aResponseStatus
)
872 nsChannel
*This
= NSCHANNEL_THIS(iface
);
874 TRACE("(%p)->(%p)\n", This
, aResponseStatus
);
876 if(This
->http_channel
)
877 return nsIHttpChannel_GetResponseStatus(This
->http_channel
, aResponseStatus
);
879 return NS_ERROR_NOT_IMPLEMENTED
;
882 static nsresult NSAPI
nsChannel_GetResponseStatusText(nsIHttpChannel
*iface
,
883 nsACString
*aResponseStatusText
)
885 nsChannel
*This
= NSCHANNEL_THIS(iface
);
887 TRACE("(%p)->(%p)\n", This
, aResponseStatusText
);
889 if(This
->http_channel
)
890 return nsIHttpChannel_GetResponseStatusText(This
->http_channel
, aResponseStatusText
);
892 return NS_ERROR_NOT_IMPLEMENTED
;
895 static nsresult NSAPI
nsChannel_GetRequestSucceeded(nsIHttpChannel
*iface
,
896 PRBool
*aRequestSucceeded
)
898 nsChannel
*This
= NSCHANNEL_THIS(iface
);
900 TRACE("(%p)->(%p)\n", This
, aRequestSucceeded
);
902 if(This
->http_channel
)
903 return nsIHttpChannel_GetRequestSucceeded(This
->http_channel
, aRequestSucceeded
);
905 return NS_ERROR_NOT_IMPLEMENTED
;
908 static nsresult NSAPI
nsChannel_GetResponseHeader(nsIHttpChannel
*iface
,
909 const nsACString
*header
, nsACString
*_retval
)
911 nsChannel
*This
= NSCHANNEL_THIS(iface
);
913 TRACE("(%p)->(%p %p)\n", This
, header
, _retval
);
915 if(This
->http_channel
)
916 return nsIHttpChannel_GetResponseHeader(This
->http_channel
, header
, _retval
);
918 return NS_ERROR_NOT_IMPLEMENTED
;
921 static nsresult NSAPI
nsChannel_SetResponseHeader(nsIHttpChannel
*iface
,
922 const nsACString
*header
, const nsACString
*value
, PRBool merge
)
924 nsChannel
*This
= NSCHANNEL_THIS(iface
);
926 TRACE("(%p)->(%p %p %x)\n", This
, header
, value
, merge
);
928 if(This
->http_channel
)
929 return nsIHttpChannel_SetResponseHeader(This
->http_channel
, header
, value
, merge
);
931 return NS_ERROR_NOT_IMPLEMENTED
;
934 static nsresult NSAPI
nsChannel_VisitResponseHeaders(nsIHttpChannel
*iface
,
935 nsIHttpHeaderVisitor
*aVisitor
)
937 nsChannel
*This
= NSCHANNEL_THIS(iface
);
939 TRACE("(%p)->(%p)\n", This
, aVisitor
);
941 if(This
->http_channel
)
942 return nsIHttpChannel_VisitResponseHeaders(This
->http_channel
, aVisitor
);
944 return NS_ERROR_NOT_IMPLEMENTED
;
947 static nsresult NSAPI
nsChannel_IsNoStoreResponse(nsIHttpChannel
*iface
, PRBool
*_retval
)
949 nsChannel
*This
= NSCHANNEL_THIS(iface
);
951 TRACE("(%p)->(%p)\n", This
, _retval
);
953 if(This
->http_channel
)
954 return nsIHttpChannel_IsNoStoreResponse(This
->http_channel
, _retval
);
956 return NS_ERROR_NOT_IMPLEMENTED
;
959 static nsresult NSAPI
nsChannel_IsNoCacheResponse(nsIHttpChannel
*iface
, PRBool
*_retval
)
961 nsChannel
*This
= NSCHANNEL_THIS(iface
);
963 TRACE("(%p)->(%p)\n", This
, _retval
);
965 if(This
->http_channel
)
966 return nsIHttpChannel_IsNoCacheResponse(This
->http_channel
, _retval
);
968 return NS_ERROR_NOT_IMPLEMENTED
;
971 #undef NSCHANNEL_THIS
973 static const nsIHttpChannelVtbl nsChannelVtbl
= {
974 nsChannel_QueryInterface
,
983 nsChannel_GetLoadGroup
,
984 nsChannel_SetLoadGroup
,
985 nsChannel_GetLoadFlags
,
986 nsChannel_SetLoadFlags
,
987 nsChannel_GetOriginalURI
,
988 nsChannel_SetOriginalURI
,
992 nsChannel_GetNotificationCallbacks
,
993 nsChannel_SetNotificationCallbacks
,
994 nsChannel_GetSecurityInfo
,
995 nsChannel_GetContentType
,
996 nsChannel_SetContentType
,
997 nsChannel_GetContentCharset
,
998 nsChannel_SetContentCharset
,
999 nsChannel_GetContentLength
,
1000 nsChannel_SetContentLength
,
1002 nsChannel_AsyncOpen
,
1003 nsChannel_GetRequestMethod
,
1004 nsChannel_SetRequestMethod
,
1005 nsChannel_GetReferrer
,
1006 nsChannel_SetReferrer
,
1007 nsChannel_GetRequestHeader
,
1008 nsChannel_SetRequestHeader
,
1009 nsChannel_VisitRequestHeaders
,
1010 nsChannel_GetAllowPipelining
,
1011 nsChannel_SetAllowPipelining
,
1012 nsChannel_GetRedirectionLimit
,
1013 nsChannel_SetRedirectionLimit
,
1014 nsChannel_GetResponseStatus
,
1015 nsChannel_GetResponseStatusText
,
1016 nsChannel_GetRequestSucceeded
,
1017 nsChannel_GetResponseHeader
,
1018 nsChannel_SetResponseHeader
,
1019 nsChannel_VisitResponseHeaders
,
1020 nsChannel_IsNoStoreResponse
,
1021 nsChannel_IsNoCacheResponse
1024 #define NSUPCHANNEL_THIS(iface) DEFINE_THIS(nsChannel, UploadChannel, iface)
1026 static nsresult NSAPI
nsUploadChannel_QueryInterface(nsIUploadChannel
*iface
, nsIIDRef riid
,
1029 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1030 return nsIChannel_QueryInterface(NSCHANNEL(This
), riid
, result
);
1033 static nsrefcnt NSAPI
nsUploadChannel_AddRef(nsIUploadChannel
*iface
)
1035 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1036 return nsIChannel_AddRef(NSCHANNEL(This
));
1039 static nsrefcnt NSAPI
nsUploadChannel_Release(nsIUploadChannel
*iface
)
1041 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1042 return nsIChannel_Release(NSCHANNEL(This
));
1045 static nsresult NSAPI
nsUploadChannel_SetUploadStream(nsIUploadChannel
*iface
,
1046 nsIInputStream
*aStream
, const nsACString
*aContentType
, PRInt32 aContentLength
)
1048 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1049 const char *content_type
;
1051 TRACE("(%p)->(%p %p %d)\n", This
, aStream
, aContentType
, aContentLength
);
1053 if(This
->post_data_stream
)
1054 nsIInputStream_Release(This
->post_data_stream
);
1057 nsACString_GetData(aContentType
, &content_type
, NULL
);
1059 FIXME("Unsupported aContentType argument: %s\n", debugstr_a(content_type
));
1062 if(aContentLength
!= -1)
1063 FIXME("Unsupported acontentLength = %d\n", aContentLength
);
1066 nsIInputStream_AddRef(aStream
);
1067 This
->post_data_stream
= aStream
;
1072 static nsresult NSAPI
nsUploadChannel_GetUploadStream(nsIUploadChannel
*iface
,
1073 nsIInputStream
**aUploadStream
)
1075 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
1077 TRACE("(%p)->(%p)\n", This
, aUploadStream
);
1079 if(This
->post_data_stream
)
1080 nsIInputStream_AddRef(This
->post_data_stream
);
1082 *aUploadStream
= This
->post_data_stream
;
1086 #undef NSUPCHANNEL_THIS
1088 static const nsIUploadChannelVtbl nsUploadChannelVtbl
= {
1089 nsUploadChannel_QueryInterface
,
1090 nsUploadChannel_AddRef
,
1091 nsUploadChannel_Release
,
1092 nsUploadChannel_SetUploadStream
,
1093 nsUploadChannel_GetUploadStream
1096 #define NSURI_THIS(iface) DEFINE_THIS(nsURI, WineURI, iface)
1098 static nsresult NSAPI
nsURI_QueryInterface(nsIWineURI
*iface
, nsIIDRef riid
, nsQIResult result
)
1100 nsURI
*This
= NSURI_THIS(iface
);
1104 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
1105 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
1106 *result
= NSURI(This
);
1107 }else if(IsEqualGUID(&IID_nsIURI
, riid
)) {
1108 TRACE("(%p)->(IID_nsIURI %p)\n", This
, result
);
1109 *result
= NSURI(This
);
1110 }else if(IsEqualGUID(&IID_nsIWineURI
, riid
)) {
1111 TRACE("(%p)->(IID_nsIWineURI %p)\n", This
, result
);
1112 *result
= NSURI(This
);
1116 nsIURI_AddRef(NSURI(This
));
1120 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), result
);
1121 return This
->uri
? nsIURI_QueryInterface(This
->uri
, riid
, result
) : NS_NOINTERFACE
;
1124 static nsrefcnt NSAPI
nsURI_AddRef(nsIWineURI
*iface
)
1126 nsURI
*This
= NSURI_THIS(iface
);
1127 LONG ref
= InterlockedIncrement(&This
->ref
);
1129 TRACE("(%p) ref=%d\n", This
, ref
);
1134 static nsrefcnt NSAPI
nsURI_Release(nsIWineURI
*iface
)
1136 nsURI
*This
= NSURI_THIS(iface
);
1137 LONG ref
= InterlockedDecrement(&This
->ref
);
1139 TRACE("(%p) ref=%d\n", This
, ref
);
1143 nsIWebBrowserChrome_Release(NSWBCHROME(This
->container
));
1145 nsIURI_Release(This
->uri
);
1146 mshtml_free(This
->wine_url
);
1153 static nsresult NSAPI
nsURI_GetSpec(nsIWineURI
*iface
, nsACString
*aSpec
)
1155 nsURI
*This
= NSURI_THIS(iface
);
1157 TRACE("(%p)->(%p)\n", This
, aSpec
);
1160 return nsIURI_GetSpec(This
->uri
, aSpec
);
1162 if(This
->wine_url
) {
1163 char speca
[INTERNET_MAX_URL_LENGTH
];
1164 WideCharToMultiByte(CP_ACP
, 0, This
->wine_url
, -1, speca
, sizeof(speca
), NULL
, NULL
);
1165 nsACString_SetData(aSpec
, speca
);
1170 WARN("mon and uri are NULL\n");
1171 return NS_ERROR_NOT_IMPLEMENTED
;
1175 static nsresult NSAPI
nsURI_SetSpec(nsIWineURI
*iface
, const nsACString
*aSpec
)
1177 nsURI
*This
= NSURI_THIS(iface
);
1179 TRACE("(%p)->(%p)\n", This
, aSpec
);
1182 return nsIURI_SetSpec(This
->uri
, aSpec
);
1184 FIXME("default action not implemented\n");
1185 return NS_ERROR_NOT_IMPLEMENTED
;
1188 static nsresult NSAPI
nsURI_GetPrePath(nsIWineURI
*iface
, nsACString
*aPrePath
)
1190 nsURI
*This
= NSURI_THIS(iface
);
1192 TRACE("(%p)->(%p)\n", This
, aPrePath
);
1195 return nsIURI_GetPrePath(This
->uri
, aPrePath
);
1197 FIXME("default action not implemented\n");
1198 return NS_ERROR_NOT_IMPLEMENTED
;
1201 static nsresult NSAPI
nsURI_GetScheme(nsIWineURI
*iface
, nsACString
*aScheme
)
1203 nsURI
*This
= NSURI_THIS(iface
);
1205 TRACE("(%p)->(%p)\n", This
, aScheme
);
1208 return nsIURI_GetScheme(This
->uri
, aScheme
);
1210 FIXME("default action not implemented\n");
1211 return NS_ERROR_NOT_IMPLEMENTED
;
1214 static nsresult NSAPI
nsURI_SetScheme(nsIWineURI
*iface
, const nsACString
*aScheme
)
1216 nsURI
*This
= NSURI_THIS(iface
);
1218 TRACE("(%p)->(%p)\n", This
, aScheme
);
1221 return nsIURI_SetScheme(This
->uri
, aScheme
);
1223 FIXME("default action not implemented\n");
1224 return NS_ERROR_NOT_IMPLEMENTED
;
1227 static nsresult NSAPI
nsURI_GetUserPass(nsIWineURI
*iface
, nsACString
*aUserPass
)
1229 nsURI
*This
= NSURI_THIS(iface
);
1231 TRACE("(%p)->(%p)\n", This
, aUserPass
);
1234 return nsIURI_GetUserPass(This
->uri
, aUserPass
);
1236 FIXME("default action not implemented\n");
1237 return NS_ERROR_NOT_IMPLEMENTED
;
1240 static nsresult NSAPI
nsURI_SetUserPass(nsIWineURI
*iface
, const nsACString
*aUserPass
)
1242 nsURI
*This
= NSURI_THIS(iface
);
1244 TRACE("(%p)->(%p)\n", This
, aUserPass
);
1247 return nsIURI_SetUserPass(This
->uri
, aUserPass
);
1249 FIXME("default action not implemented\n");
1250 return NS_ERROR_NOT_IMPLEMENTED
;
1253 static nsresult NSAPI
nsURI_GetUsername(nsIWineURI
*iface
, nsACString
*aUsername
)
1255 nsURI
*This
= NSURI_THIS(iface
);
1257 TRACE("(%p)->(%p)\n", This
, aUsername
);
1260 return nsIURI_GetUsername(This
->uri
, aUsername
);
1262 FIXME("default action not implemented\n");
1263 return NS_ERROR_NOT_IMPLEMENTED
;
1266 static nsresult NSAPI
nsURI_SetUsername(nsIWineURI
*iface
, const nsACString
*aUsername
)
1268 nsURI
*This
= NSURI_THIS(iface
);
1270 TRACE("(%p)->(%p)\n", This
, aUsername
);
1273 return nsIURI_SetUsername(This
->uri
, aUsername
);
1275 FIXME("default action not implemented\n");
1276 return NS_ERROR_NOT_IMPLEMENTED
;
1279 static nsresult NSAPI
nsURI_GetPassword(nsIWineURI
*iface
, nsACString
*aPassword
)
1281 nsURI
*This
= NSURI_THIS(iface
);
1283 TRACE("(%p)->(%p)\n", This
, aPassword
);
1286 return nsIURI_GetPassword(This
->uri
, aPassword
);
1288 FIXME("default action not implemented\n");
1289 return NS_ERROR_NOT_IMPLEMENTED
;
1292 static nsresult NSAPI
nsURI_SetPassword(nsIWineURI
*iface
, const nsACString
*aPassword
)
1294 nsURI
*This
= NSURI_THIS(iface
);
1296 TRACE("(%p)->(%p)\n", This
, aPassword
);
1299 return nsIURI_SetPassword(This
->uri
, aPassword
);
1301 FIXME("default action not implemented\n");
1302 return NS_ERROR_NOT_IMPLEMENTED
;
1305 static nsresult NSAPI
nsURI_GetHostPort(nsIWineURI
*iface
, nsACString
*aHostPort
)
1307 nsURI
*This
= NSURI_THIS(iface
);
1309 TRACE("(%p)->(%p)\n", This
, aHostPort
);
1312 return nsIURI_GetHostPort(This
->uri
, aHostPort
);
1314 FIXME("default action not implemented\n");
1315 return NS_ERROR_NOT_IMPLEMENTED
;
1318 static nsresult NSAPI
nsURI_SetHostPort(nsIWineURI
*iface
, const nsACString
*aHostPort
)
1320 nsURI
*This
= NSURI_THIS(iface
);
1322 TRACE("(%p)->(%p)\n", This
, aHostPort
);
1325 return nsIURI_SetHostPort(This
->uri
, aHostPort
);
1327 FIXME("default action not implemented\n");
1328 return NS_ERROR_NOT_IMPLEMENTED
;
1331 static nsresult NSAPI
nsURI_GetHost(nsIWineURI
*iface
, nsACString
*aHost
)
1333 nsURI
*This
= NSURI_THIS(iface
);
1335 TRACE("(%p)->(%p)\n", This
, aHost
);
1338 return nsIURI_GetHost(This
->uri
, aHost
);
1340 FIXME("default action not implemented\n");
1341 return NS_ERROR_NOT_IMPLEMENTED
;
1344 static nsresult NSAPI
nsURI_SetHost(nsIWineURI
*iface
, const nsACString
*aHost
)
1346 nsURI
*This
= NSURI_THIS(iface
);
1348 TRACE("(%p)->(%p)\n", This
, aHost
);
1351 return nsIURI_SetHost(This
->uri
, aHost
);
1353 FIXME("default action not implemented\n");
1354 return NS_ERROR_NOT_IMPLEMENTED
;
1357 static nsresult NSAPI
nsURI_GetPort(nsIWineURI
*iface
, PRInt32
*aPort
)
1359 nsURI
*This
= NSURI_THIS(iface
);
1361 TRACE("(%p)->(%p)\n", This
, aPort
);
1364 return nsIURI_GetPort(This
->uri
, aPort
);
1366 FIXME("default action not implemented\n");
1367 return NS_ERROR_NOT_IMPLEMENTED
;
1370 static nsresult NSAPI
nsURI_SetPort(nsIWineURI
*iface
, PRInt32 aPort
)
1372 nsURI
*This
= NSURI_THIS(iface
);
1374 TRACE("(%p)->(%d)\n", This
, aPort
);
1377 return nsIURI_SetPort(This
->uri
, aPort
);
1379 FIXME("default action not implemented\n");
1380 return NS_ERROR_NOT_IMPLEMENTED
;
1383 static nsresult NSAPI
nsURI_GetPath(nsIWineURI
*iface
, nsACString
*aPath
)
1385 nsURI
*This
= NSURI_THIS(iface
);
1387 TRACE("(%p)->(%p)\n", This
, aPath
);
1390 return nsIURI_GetPath(This
->uri
, aPath
);
1392 FIXME("default action not implemented\n");
1393 return NS_ERROR_NOT_IMPLEMENTED
;
1396 static nsresult NSAPI
nsURI_SetPath(nsIWineURI
*iface
, const nsACString
*aPath
)
1398 nsURI
*This
= NSURI_THIS(iface
);
1400 TRACE("(%p)->(%p)\n", This
, aPath
);
1403 return nsIURI_SetPath(This
->uri
, aPath
);
1405 FIXME("default action not implemented\n");
1406 return NS_ERROR_NOT_IMPLEMENTED
;
1409 static nsresult NSAPI
nsURI_Equals(nsIWineURI
*iface
, nsIURI
*other
, PRBool
*_retval
)
1411 nsURI
*This
= NSURI_THIS(iface
);
1413 TRACE("(%p)->(%p %p)\n", This
, other
, _retval
);
1416 return nsIURI_Equals(This
->uri
, other
, _retval
);
1418 FIXME("default action not implemented\n");
1419 return NS_ERROR_NOT_IMPLEMENTED
;
1422 static nsresult NSAPI
nsURI_SchemeIs(nsIWineURI
*iface
, const char *scheme
, PRBool
*_retval
)
1424 nsURI
*This
= NSURI_THIS(iface
);
1426 TRACE("(%p)->(%s %p)\n", This
, debugstr_a(scheme
), _retval
);
1429 return nsIURI_SchemeIs(This
->uri
, scheme
, _retval
);
1431 FIXME("default action not implemented\n");
1432 return NS_ERROR_NOT_IMPLEMENTED
;
1435 static nsresult NSAPI
nsURI_Clone(nsIWineURI
*iface
, nsIURI
**_retval
)
1437 nsURI
*This
= NSURI_THIS(iface
);
1439 TRACE("(%p)->(%p)\n", This
, _retval
);
1443 nsIWineURI
*wine_uri
;
1446 nsres
= nsIURI_Clone(This
->uri
, &uri
);
1447 if(NS_FAILED(nsres
)) {
1448 WARN("Clone failed: %08x\n", nsres
);
1452 nsres
= create_uri(uri
, This
->container
, &wine_uri
);
1453 *_retval
= (nsIURI
*)wine_uri
;
1454 if(NS_SUCCEEDED(nsres
))
1455 return nsIWineURI_SetWineURL(wine_uri
, This
->wine_url
);
1459 FIXME("default action not implemented\n");
1460 return NS_ERROR_NOT_IMPLEMENTED
;
1463 static nsresult NSAPI
nsURI_Resolve(nsIWineURI
*iface
, const nsACString
*arelativePath
,
1464 nsACString
*_retval
)
1466 nsURI
*This
= NSURI_THIS(iface
);
1468 TRACE("(%p)->(%p %p)\n", This
, arelativePath
, _retval
);
1471 return nsIURI_Resolve(This
->uri
, arelativePath
, _retval
);
1473 FIXME("default action not implemented\n");
1474 return NS_ERROR_NOT_IMPLEMENTED
;
1477 static nsresult NSAPI
nsURI_GetAsciiSpec(nsIWineURI
*iface
, nsACString
*aAsciiSpec
)
1479 nsURI
*This
= NSURI_THIS(iface
);
1481 TRACE("(%p)->(%p)\n", This
, aAsciiSpec
);
1484 return nsIURI_GetAsciiSpec(This
->uri
, aAsciiSpec
);
1486 FIXME("default action not implemented\n");
1487 return NS_ERROR_NOT_IMPLEMENTED
;
1490 static nsresult NSAPI
nsURI_GetAsciiHost(nsIWineURI
*iface
, nsACString
*aAsciiHost
)
1492 nsURI
*This
= NSURI_THIS(iface
);
1494 TRACE("(%p)->(%p)\n", This
, aAsciiHost
);
1497 return nsIURI_GetAsciiHost(This
->uri
, aAsciiHost
);
1499 FIXME("default action not implemented\n");
1500 return NS_ERROR_NOT_IMPLEMENTED
;
1503 static nsresult NSAPI
nsURI_GetOriginCharset(nsIWineURI
*iface
, nsACString
*aOriginCharset
)
1505 nsURI
*This
= NSURI_THIS(iface
);
1507 TRACE("(%p)->(%p)\n", This
, aOriginCharset
);
1510 return nsIURI_GetOriginCharset(This
->uri
, aOriginCharset
);
1512 FIXME("default action not implemented\n");
1513 return NS_ERROR_NOT_IMPLEMENTED
;
1516 static nsresult NSAPI
nsURI_GetNSContainer(nsIWineURI
*iface
, NSContainer
**aContainer
)
1518 nsURI
*This
= NSURI_THIS(iface
);
1520 TRACE("(%p)->(%p)\n", This
, aContainer
);
1523 nsIWebBrowserChrome_AddRef(NSWBCHROME(This
->container
));
1524 *aContainer
= This
->container
;
1529 static nsresult NSAPI
nsURI_SetNSContainer(nsIWineURI
*iface
, NSContainer
*aContainer
)
1531 nsURI
*This
= NSURI_THIS(iface
);
1533 TRACE("(%p)->(%p)\n", This
, aContainer
);
1535 if(This
->container
) {
1536 if(This
->container
== aContainer
)
1538 WARN("Container already set: %p\n", This
->container
);
1539 nsIWebBrowserChrome_Release(NSWBCHROME(This
->container
));
1543 nsIWebBrowserChrome_AddRef(NSWBCHROME(aContainer
));
1544 This
->container
= aContainer
;
1549 static nsresult NSAPI
nsURI_GetIsDocumentURI(nsIWineURI
*iface
, PRBool
*aIsDocumentURI
)
1551 nsURI
*This
= NSURI_THIS(iface
);
1553 TRACE("(%p)->(%p)\n", This
, aIsDocumentURI
);
1555 *aIsDocumentURI
= This
->is_doc_uri
;
1559 static nsresult NSAPI
nsURI_SetIsDocumentURI(nsIWineURI
*iface
, PRBool aIsDocumentURI
)
1561 nsURI
*This
= NSURI_THIS(iface
);
1563 TRACE("(%p)->(%x)\n", This
, aIsDocumentURI
);
1565 This
->is_doc_uri
= aIsDocumentURI
;
1569 static nsresult NSAPI
nsURI_GetWineURL(nsIWineURI
*iface
, LPCWSTR
*aURL
)
1571 nsURI
*This
= NSURI_THIS(iface
);
1573 TRACE("(%p)->(%p)\n", This
, aURL
);
1575 *aURL
= This
->wine_url
;
1579 static nsresult NSAPI
nsURI_SetWineURL(nsIWineURI
*iface
, LPCWSTR aURL
)
1581 nsURI
*This
= NSURI_THIS(iface
);
1583 TRACE("(%p)->(%s)\n", This
, debugstr_w(aURL
));
1585 mshtml_free(This
->wine_url
);
1588 int len
= strlenW(aURL
)+1;
1589 This
->wine_url
= mshtml_alloc(len
*sizeof(WCHAR
));
1590 memcpy(This
->wine_url
, aURL
, len
*sizeof(WCHAR
));
1592 This
->wine_url
= NULL
;
1600 static const nsIWineURIVtbl nsWineURIVtbl
= {
1601 nsURI_QueryInterface
,
1629 nsURI_GetOriginCharset
,
1630 nsURI_GetNSContainer
,
1631 nsURI_SetNSContainer
,
1632 nsURI_GetIsDocumentURI
,
1633 nsURI_SetIsDocumentURI
,
1638 static nsresult
create_uri(nsIURI
*uri
, NSContainer
*container
, nsIWineURI
**_retval
)
1640 nsURI
*ret
= mshtml_alloc(sizeof(nsURI
));
1642 ret
->lpWineURIVtbl
= &nsWineURIVtbl
;
1645 ret
->container
= container
;
1646 ret
->wine_url
= NULL
;
1647 ret
->is_doc_uri
= FALSE
;
1650 nsIWebBrowserChrome_AddRef(NSWBCHROME(container
));
1652 TRACE("retval=%p\n", ret
);
1653 *_retval
= NSWINEURI(ret
);
1657 static nsresult NSAPI
nsIOService_QueryInterface(nsIIOService
*iface
, nsIIDRef riid
,
1662 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
1663 TRACE("(IID_nsISupports %p)\n", result
);
1665 }else if(IsEqualGUID(&IID_nsIIOService
, riid
)) {
1666 TRACE("(IID_nsIIOService %p)\n", result
);
1671 nsIIOService_AddRef(iface
);
1675 WARN("(%s %p)\n", debugstr_guid(riid
), result
);
1676 return NS_NOINTERFACE
;
1679 static nsrefcnt NSAPI
nsIOService_AddRef(nsIIOService
*iface
)
1684 static nsrefcnt NSAPI
nsIOService_Release(nsIIOService
*iface
)
1689 static nsresult NSAPI
nsIOService_GetProtocolHandler(nsIIOService
*iface
, const char *aScheme
,
1690 nsIProtocolHandler
**_retval
)
1692 TRACE("(%s %p)\n", debugstr_a(aScheme
), _retval
);
1693 return nsIIOService_GetProtocolHandler(nsio
, aScheme
, _retval
);
1696 static nsresult NSAPI
nsIOService_GetProtocolFlags(nsIIOService
*iface
, const char *aScheme
,
1699 TRACE("(%s %p)\n", debugstr_a(aScheme
), _retval
);
1700 return nsIIOService_GetProtocolFlags(nsio
, aScheme
, _retval
);
1703 static nsresult NSAPI
nsIOService_NewURI(nsIIOService
*iface
, const nsACString
*aSpec
,
1704 const char *aOriginCharset
, nsIURI
*aBaseURI
, nsIURI
**_retval
)
1706 const char *spec
= NULL
;
1707 NSContainer
*nscontainer
= NULL
;
1709 PRBool is_javascript
= FALSE
;
1710 LPCWSTR base_wine_url
= NULL
;
1711 nsIWineURI
*base_wine_uri
= NULL
, *wine_uri
;
1714 nsACString_GetData(aSpec
, &spec
, NULL
);
1716 TRACE("(%p(%s) %s %p %p)\n", aSpec
, debugstr_a(spec
), debugstr_a(aOriginCharset
),
1720 nsACString base_uri_str
;
1721 const char *base_uri
= NULL
;
1723 static const char szChrome
[] = "chrome:";
1725 nsACString_Init(&base_uri_str
, NULL
);
1727 nsres
= nsIURI_GetSpec(aBaseURI
, &base_uri_str
);
1728 if(NS_SUCCEEDED(nsres
)) {
1729 nsACString_GetData(&base_uri_str
, &base_uri
, NULL
);
1730 TRACE("base_uri=%s\n", debugstr_a(base_uri
));
1732 ERR("GetSpec failed: %08x\n", nsres
);
1735 nsACString_Finish(&base_uri_str
);
1737 if(!strncmp(spec
, szChrome
, sizeof(szChrome
)-1))
1741 nsres
= nsIIOService_NewURI(nsio
, aSpec
, aOriginCharset
, aBaseURI
, &uri
);
1742 if(NS_FAILED(nsres
))
1743 TRACE("NewURI failed: %08x\n", nsres
);
1746 nsIURI_SchemeIs(uri
, "javascript", &is_javascript
);
1748 TRACE("returning javascript uri: %p\n", uri
);
1755 nsres
= nsIURI_QueryInterface(aBaseURI
, &IID_nsIWineURI
, (void**)&base_wine_uri
);
1756 if(NS_SUCCEEDED(nsres
)) {
1757 nsIWineURI_GetNSContainer(base_wine_uri
, &nscontainer
);
1758 nsIWineURI_GetWineURL(base_wine_uri
, &base_wine_url
);
1760 ERR("Could not get nsIWineURI: %08x\n", nsres
);
1764 nsres
= create_uri(uri
, nscontainer
, &wine_uri
);
1765 *_retval
= (nsIURI
*)wine_uri
;
1768 nsIWebBrowserChrome_Release(NSWBCHROME(nscontainer
));
1771 WCHAR url
[INTERNET_MAX_URL_LENGTH
], rel_url
[INTERNET_MAX_URL_LENGTH
];
1776 nsACString_GetData(aSpec
, &speca
, NULL
);
1777 MultiByteToWideChar(CP_ACP
, 0, speca
, -1, rel_url
, sizeof(rel_url
)/sizeof(WCHAR
));
1779 hres
= CoInternetCombineUrl(base_wine_url
, rel_url
,
1780 URL_ESCAPE_SPACES_ONLY
|URL_DONT_ESCAPE_EXTRA_INFO
,
1781 url
, sizeof(url
)/sizeof(WCHAR
), &len
, 0);
1783 nsIWineURI_SetWineURL(wine_uri
, url
);
1785 WARN("CoCombineUrl failed: %08x\n", hres
);
1789 nsIWineURI_Release(base_wine_uri
);
1794 static nsresult NSAPI
nsIOService_NewFileURI(nsIIOService
*iface
, nsIFile
*aFile
,
1797 TRACE("(%p %p)\n", aFile
, _retval
);
1798 return nsIIOService_NewFileURI(nsio
, aFile
, _retval
);
1801 static nsresult NSAPI
nsIOService_NewChannelFromURI(nsIIOService
*iface
, nsIURI
*aURI
,
1802 nsIChannel
**_retval
)
1804 nsIChannel
*channel
= NULL
;
1806 nsIWineURI
*wine_uri
;
1809 TRACE("(%p %p)\n", aURI
, _retval
);
1811 nsres
= nsIIOService_NewChannelFromURI(nsio
, aURI
, &channel
);
1812 if(NS_FAILED(nsres
) && nsres
!= NS_ERROR_UNKNOWN_PROTOCOL
) {
1813 WARN("NewChannelFromURI failed: %08x\n", nsres
);
1818 nsres
= nsIURI_QueryInterface(aURI
, &IID_nsIWineURI
, (void**)&wine_uri
);
1819 if(NS_FAILED(nsres
)) {
1820 WARN("Could not get nsIWineURI: %08x\n", nsres
);
1822 return channel
? NS_OK
: NS_ERROR_UNEXPECTED
;
1825 ret
= mshtml_alloc(sizeof(nsChannel
));
1827 ret
->lpHttpChannelVtbl
= &nsChannelVtbl
;
1828 ret
->lpUploadChannelVtbl
= &nsUploadChannelVtbl
;
1830 ret
->channel
= channel
;
1831 ret
->http_channel
= NULL
;
1832 ret
->uri
= wine_uri
;
1833 ret
->post_data_stream
= NULL
;
1834 ret
->load_group
= NULL
;
1835 ret
->notif_callback
= NULL
;
1836 ret
->load_flags
= 0;
1837 ret
->content
= NULL
;
1839 nsIURI_AddRef(aURI
);
1840 ret
->original_uri
= aURI
;
1843 nsIChannel_QueryInterface(channel
, &IID_nsIHttpChannel
, (void**)&ret
->http_channel
);
1845 *_retval
= NSCHANNEL(ret
);
1849 static nsresult NSAPI
nsIOService_NewChannel(nsIIOService
*iface
, const nsACString
*aSpec
,
1850 const char *aOriginCharset
, nsIURI
*aBaseURI
, nsIChannel
**_retval
)
1852 TRACE("(%p %s %p %p)\n", aSpec
, debugstr_a(aOriginCharset
), aBaseURI
, _retval
);
1853 return nsIIOService_NewChannel(nsio
, aSpec
, aOriginCharset
, aBaseURI
, _retval
);
1856 static nsresult NSAPI
nsIOService_GetOffline(nsIIOService
*iface
, PRBool
*aOffline
)
1858 TRACE("(%p)\n", aOffline
);
1859 return nsIIOService_GetOffline(nsio
, aOffline
);
1862 static nsresult NSAPI
nsIOService_SetOffline(nsIIOService
*iface
, PRBool aOffline
)
1864 TRACE("(%x)\n", aOffline
);
1865 return nsIIOService_SetOffline(nsio
, aOffline
);
1868 static nsresult NSAPI
nsIOService_AllowPort(nsIIOService
*iface
, PRInt32 aPort
,
1869 const char *aScheme
, PRBool
*_retval
)
1871 TRACE("(%d %s %p)\n", aPort
, debugstr_a(aScheme
), _retval
);
1872 return nsIIOService_AllowPort(nsio
, aPort
, debugstr_a(aScheme
), _retval
);
1875 static nsresult NSAPI
nsIOService_ExtractScheme(nsIIOService
*iface
, const nsACString
*urlString
,
1876 nsACString
* _retval
)
1878 TRACE("(%p %p)\n", urlString
, _retval
);
1879 return nsIIOService_ExtractScheme(nsio
, urlString
, _retval
);
1882 static const nsIIOServiceVtbl nsIOServiceVtbl
= {
1883 nsIOService_QueryInterface
,
1885 nsIOService_Release
,
1886 nsIOService_GetProtocolHandler
,
1887 nsIOService_GetProtocolFlags
,
1889 nsIOService_NewFileURI
,
1890 nsIOService_NewChannelFromURI
,
1891 nsIOService_NewChannel
,
1892 nsIOService_GetOffline
,
1893 nsIOService_SetOffline
,
1894 nsIOService_AllowPort
,
1895 nsIOService_ExtractScheme
1898 static nsIIOService nsIOService
= { &nsIOServiceVtbl
};
1900 static nsresult NSAPI
nsIOServiceFactory_QueryInterface(nsIFactory
*iface
, nsIIDRef riid
,
1905 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
1906 TRACE("(IID_nsISupoprts %p)\n", result
);
1908 }else if(IsEqualGUID(&IID_nsIFactory
, riid
)) {
1909 TRACE("(IID_nsIFactory %p)\n", result
);
1914 nsIFactory_AddRef(iface
);
1918 WARN("(%s %p)\n", debugstr_guid(riid
), result
);
1919 return NS_NOINTERFACE
;
1922 static nsrefcnt NSAPI
nsIOServiceFactory_AddRef(nsIFactory
*iface
)
1927 static nsrefcnt NSAPI
nsIOServiceFactory_Release(nsIFactory
*iface
)
1932 static nsresult NSAPI
nsIOServiceFactory_CreateInstance(nsIFactory
*iface
,
1933 nsISupports
*aOuter
, const nsIID
*iid
, void **result
)
1935 return nsIIOService_QueryInterface(&nsIOService
, iid
, result
);
1938 static nsresult NSAPI
nsIOServiceFactory_LockFactory(nsIFactory
*iface
, PRBool lock
)
1940 WARN("(%x)\n", lock
);
1944 static const nsIFactoryVtbl nsIOServiceFactoryVtbl
= {
1945 nsIOServiceFactory_QueryInterface
,
1946 nsIOServiceFactory_AddRef
,
1947 nsIOServiceFactory_Release
,
1948 nsIOServiceFactory_CreateInstance
,
1949 nsIOServiceFactory_LockFactory
1952 static nsIFactory nsIOServiceFactory
= { &nsIOServiceFactoryVtbl
};
1954 void init_nsio(nsIComponentManager
*component_manager
, nsIComponentRegistrar
*registrar
)
1956 nsIFactory
*old_factory
= NULL
;
1959 nsres
= nsIComponentManager_GetClassObject(component_manager
, &NS_IOSERVICE_CID
,
1960 &IID_nsIFactory
, (void**)&old_factory
);
1961 if(NS_FAILED(nsres
)) {
1962 ERR("Could not get factory: %08x\n", nsres
);
1963 nsIFactory_Release(old_factory
);
1967 nsres
= nsIFactory_CreateInstance(old_factory
, NULL
, &IID_nsIIOService
, (void**)&nsio
);
1968 if(NS_FAILED(nsres
)) {
1969 ERR("Couldn not create nsIOService instance %08x\n", nsres
);
1970 nsIFactory_Release(old_factory
);
1974 nsres
= nsIComponentRegistrar_UnregisterFactory(registrar
, &NS_IOSERVICE_CID
, old_factory
);
1975 nsIFactory_Release(old_factory
);
1976 if(NS_FAILED(nsres
))
1977 ERR("UnregisterFactory failed: %08x\n", nsres
);
1979 nsres
= nsIComponentRegistrar_RegisterFactory(registrar
, &NS_IOSERVICE_CID
,
1980 NS_IOSERVICE_CLASSNAME
, NS_IOSERVICE_CONTRACTID
, &nsIOServiceFactory
);
1981 if(NS_FAILED(nsres
))
1982 ERR("RegisterFactory failed: %08x\n", nsres
);