2 * Copyright 2006 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
31 #include "wine/debug.h"
32 #include "wine/unicode.h"
34 #include "mshtml_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
38 #define LOAD_INITIAL_DOCUMENT_URI 0x80000
40 #define NS_IOSERVICE_CLASSNAME "nsIOService"
41 #define NS_IOSERVICE_CONTRACTID "@mozilla.org/network/io-service;1"
43 static const IID NS_IOSERVICE_CID
=
44 {0x9ac9e770, 0x18bc, 0x11d3, {0x93, 0x37, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40}};
46 static nsIIOService
*nsio
= NULL
;
49 const nsIWineURIVtbl
*lpWineURIVtbl
;
54 NSContainer
*container
;
57 #define NSURI(x) ((nsIURI*) &(x)->lpWineURIVtbl)
59 static nsresult
create_uri(nsIURI
*,NSContainer
*,nsIURI
**);
61 static BOOL
exec_shldocvw_67(HTMLDocument
*doc
, LPCWSTR url
)
63 IOleCommandTarget
*cmdtrg
= NULL
;
66 hres
= IOleClientSite_QueryInterface(doc
->client
, &IID_IOleCommandTarget
,
69 VARIANT varUrl
, varRes
;
71 V_VT(&varUrl
) = VT_BSTR
;
72 V_BSTR(&varUrl
) = SysAllocString(url
);
73 V_VT(&varRes
) = VT_BOOL
;
75 hres
= IOleCommandTarget_Exec(cmdtrg
, &CGID_ShellDocView
, 67, 0, &varUrl
, &varRes
);
77 IOleCommandTarget_Release(cmdtrg
);
78 SysFreeString(V_BSTR(&varUrl
));
80 if(SUCCEEDED(hres
) && !V_BOOL(&varRes
)) {
81 TRACE("got VARIANT_FALSE, do not load\n");
89 static BOOL
handle_uri(NSContainer
*container
, nsChannel
*channel
, LPCWSTR uri
)
91 IServiceProvider
*service_provider
;
92 HTMLDocument
*doc
= container
->doc
;
97 NSContainer
*container_iter
= container
;
99 hlnf
= HLNF_OPENINNEWWINDOW
;
100 while(!container_iter
->doc
)
101 container_iter
= container_iter
->parent
;
102 doc
= container_iter
->doc
;
105 if(!hlnf
&& !exec_shldocvw_67(doc
, uri
))
108 hres
= IOleClientSite_QueryInterface(doc
->client
, &IID_IServiceProvider
,
109 (void**)&service_provider
);
110 if(SUCCEEDED(hres
)) {
111 IHlinkFrame
*hlink_frame
;
113 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHlinkFrame
,
114 &IID_IHlinkFrame
, (void**)&hlink_frame
);
115 IServiceProvider_Release(service_provider
);
116 if(SUCCEEDED(hres
)) {
117 hlink_frame_navigate(doc
, hlink_frame
, uri
, channel
->post_data_stream
, hlnf
);
118 IHlinkFrame_Release(hlink_frame
);
127 static BOOL
before_async_open(nsChannel
*channel
, NSContainer
*container
)
135 nsACString_Init(&uri_str
, NULL
);
136 nsIWineURI_GetSpec(channel
->uri
, &uri_str
);
137 nsACString_GetData(&uri_str
, &uria
, NULL
);
138 len
= MultiByteToWideChar(CP_ACP
, 0, uria
, -1, NULL
, 0);
139 uri
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
140 MultiByteToWideChar(CP_ACP
, 0, uria
, -1, uri
, len
);
141 nsACString_Finish(&uri_str
);
143 ret
= handle_uri(container
, channel
, uri
);
145 HeapFree(GetProcessHeap(), 0, uri
);
150 #define NSCHANNEL_THIS(iface) DEFINE_THIS(nsChannel, HttpChannel, iface)
152 static nsresult NSAPI
nsChannel_QueryInterface(nsIHttpChannel
*iface
, nsIIDRef riid
, nsQIResult result
)
154 nsChannel
*This
= NSCHANNEL_THIS(iface
);
158 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
159 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
160 *result
= NSCHANNEL(This
);
161 }else if(IsEqualGUID(&IID_nsIRequest
, riid
)) {
162 TRACE("(%p)->(IID_nsIRequest %p)\n", This
, result
);
163 *result
= NSCHANNEL(This
);
164 }else if(IsEqualGUID(&IID_nsIChannel
, riid
)) {
165 TRACE("(%p)->(IID_nsIChannel %p)\n", This
, result
);
166 *result
= NSCHANNEL(This
);
167 }else if(This
->http_channel
&& IsEqualGUID(&IID_nsIHttpChannel
, riid
)) {
168 TRACE("(%p)->(IID_nsIHttpChannel %p)\n", This
, result
);
169 *result
= NSHTTPCHANNEL(This
);
170 }else if(IsEqualGUID(&IID_nsIUploadChannel
, riid
)) {
171 TRACE("(%p)->(IID_nsIUploadChannel %p)\n", This
, result
);
172 *result
= NSUPCHANNEL(This
);
176 nsIChannel_AddRef(NSCHANNEL(This
));
180 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), result
);
183 return nsIChannel_QueryInterface(This
->channel
, riid
, result
);
184 return NS_NOINTERFACE
;
187 static nsrefcnt NSAPI
nsChannel_AddRef(nsIHttpChannel
*iface
)
189 nsChannel
*This
= NSCHANNEL_THIS(iface
);
190 nsrefcnt ref
= InterlockedIncrement(&This
->ref
);
192 TRACE("(%p) ref=%ld\n", This
, ref
);
197 static nsrefcnt NSAPI
nsChannel_Release(nsIHttpChannel
*iface
)
199 nsChannel
*This
= NSCHANNEL_THIS(iface
);
200 LONG ref
= InterlockedDecrement(&This
->ref
);
203 nsIWineURI_Release(This
->uri
);
205 nsIChannel_Release(This
->channel
);
206 if(This
->http_channel
)
207 nsIHttpChannel_Release(This
->http_channel
);
208 if(This
->post_data_stream
)
209 nsIInputStream_Release(This
->post_data_stream
);
211 nsILoadGroup_Release(This
->load_group
);
212 if(This
->notif_callback
)
213 nsIInterfaceRequestor_Release(This
->notif_callback
);
214 if(This
->original_uri
)
215 nsIURI_Release(This
->original_uri
);
216 HeapFree(GetProcessHeap(), 0, This
->content
);
217 HeapFree(GetProcessHeap(), 0, This
);
223 static nsresult NSAPI
nsChannel_GetName(nsIHttpChannel
*iface
, nsACString
*aName
)
225 nsChannel
*This
= NSCHANNEL_THIS(iface
);
227 TRACE("(%p)->(%p)\n", This
, aName
);
230 return nsIChannel_GetName(This
->channel
, aName
);
232 FIXME("default action not implemented\n");
233 return NS_ERROR_NOT_IMPLEMENTED
;
236 static nsresult NSAPI
nsChannel_IsPending(nsIHttpChannel
*iface
, PRBool
*_retval
)
238 nsChannel
*This
= NSCHANNEL_THIS(iface
);
240 TRACE("(%p)->(%p)\n", This
, _retval
);
243 return nsIChannel_IsPending(This
->channel
, _retval
);
245 FIXME("default action not implemented\n");
246 return NS_ERROR_NOT_IMPLEMENTED
;
249 static nsresult NSAPI
nsChannel_GetStatus(nsIHttpChannel
*iface
, nsresult
*aStatus
)
251 nsChannel
*This
= NSCHANNEL_THIS(iface
);
253 TRACE("(%p)->(%p)\n", This
, aStatus
);
256 return nsIChannel_GetStatus(This
->channel
, aStatus
);
258 FIXME("default action not implemented\n");
259 return NS_ERROR_NOT_IMPLEMENTED
;
262 static nsresult NSAPI
nsChannel_Cancel(nsIHttpChannel
*iface
, nsresult aStatus
)
264 nsChannel
*This
= NSCHANNEL_THIS(iface
);
266 TRACE("(%p)->(%08lx)\n", This
, aStatus
);
269 return nsIChannel_Cancel(This
->channel
, aStatus
);
271 FIXME("default action not implemented\n");
272 return NS_ERROR_NOT_IMPLEMENTED
;
275 static nsresult NSAPI
nsChannel_Suspend(nsIHttpChannel
*iface
)
277 nsChannel
*This
= NSCHANNEL_THIS(iface
);
279 TRACE("(%p)\n", This
);
282 return nsIChannel_Suspend(This
->channel
);
284 FIXME("default action not implemented\n");
285 return NS_ERROR_NOT_IMPLEMENTED
;
288 static nsresult NSAPI
nsChannel_Resume(nsIHttpChannel
*iface
)
290 nsChannel
*This
= NSCHANNEL_THIS(iface
);
292 TRACE("(%p)\n", This
);
295 return nsIChannel_Resume(This
->channel
);
297 FIXME("default action not implemented\n");
298 return NS_ERROR_NOT_IMPLEMENTED
;
301 static nsresult NSAPI
nsChannel_GetLoadGroup(nsIHttpChannel
*iface
, nsILoadGroup
**aLoadGroup
)
303 nsChannel
*This
= NSCHANNEL_THIS(iface
);
305 TRACE("(%p)->(%p)\n", This
, aLoadGroup
);
308 nsILoadGroup_AddRef(This
->load_group
);
310 *aLoadGroup
= This
->load_group
;
314 static nsresult NSAPI
nsChannel_SetLoadGroup(nsIHttpChannel
*iface
, nsILoadGroup
*aLoadGroup
)
316 nsChannel
*This
= NSCHANNEL_THIS(iface
);
318 TRACE("(%p)->(%p)\n", This
, aLoadGroup
);
321 nsILoadGroup_Release(This
->load_group
);
323 nsILoadGroup_AddRef(aLoadGroup
);
325 This
->load_group
= aLoadGroup
;
328 return nsIChannel_SetLoadGroup(This
->channel
, aLoadGroup
);
332 static nsresult NSAPI
nsChannel_GetLoadFlags(nsIHttpChannel
*iface
, nsLoadFlags
*aLoadFlags
)
334 nsChannel
*This
= NSCHANNEL_THIS(iface
);
336 TRACE("(%p)->(%p)\n", This
, aLoadFlags
);
338 *aLoadFlags
= This
->load_flags
;
342 static nsresult NSAPI
nsChannel_SetLoadFlags(nsIHttpChannel
*iface
, nsLoadFlags aLoadFlags
)
344 nsChannel
*This
= NSCHANNEL_THIS(iface
);
346 TRACE("(%p)->(%08lx)\n", This
, aLoadFlags
);
348 This
->load_flags
= aLoadFlags
;
351 return nsIChannel_SetLoadFlags(This
->channel
, aLoadFlags
);
355 static nsresult NSAPI
nsChannel_GetOriginalURI(nsIHttpChannel
*iface
, nsIURI
**aOriginalURI
)
357 nsChannel
*This
= NSCHANNEL_THIS(iface
);
359 TRACE("(%p)->(%p)\n", This
, aOriginalURI
);
361 if(This
->original_uri
)
362 nsIURI_AddRef(This
->original_uri
);
364 *aOriginalURI
= This
->original_uri
;
368 static nsresult NSAPI
nsChannel_SetOriginalURI(nsIHttpChannel
*iface
, nsIURI
*aOriginalURI
)
370 nsChannel
*This
= NSCHANNEL_THIS(iface
);
372 TRACE("(%p)->(%p)\n", This
, aOriginalURI
);
374 if(This
->original_uri
)
375 nsIURI_Release(This
->original_uri
);
377 nsIURI_AddRef(aOriginalURI
);
378 This
->original_uri
= aOriginalURI
;
381 return nsIChannel_SetOriginalURI(This
->channel
, aOriginalURI
);
385 static nsresult NSAPI
nsChannel_GetURI(nsIHttpChannel
*iface
, nsIURI
**aURI
)
387 nsChannel
*This
= NSCHANNEL_THIS(iface
);
389 TRACE("(%p)->(%p)\n", This
, aURI
);
391 nsIWineURI_AddRef(This
->uri
);
392 *aURI
= (nsIURI
*)This
->uri
;
397 static nsresult NSAPI
nsChannel_GetOwner(nsIHttpChannel
*iface
, nsISupports
**aOwner
)
399 nsChannel
*This
= NSCHANNEL_THIS(iface
);
401 TRACE("(%p)->(%p)\n", This
, aOwner
);
404 return nsIChannel_GetOwner(This
->channel
, aOwner
);
406 FIXME("default action not implemented\n");
407 return NS_ERROR_NOT_IMPLEMENTED
;
410 static nsresult NSAPI
nsChannel_SetOwner(nsIHttpChannel
*iface
, nsISupports
*aOwner
)
412 nsChannel
*This
= NSCHANNEL_THIS(iface
);
414 TRACE("(%p)->(%p)\n", This
, aOwner
);
417 return nsIChannel_SetOwner(This
->channel
, aOwner
);
419 FIXME("default action not implemented\n");
420 return NS_ERROR_NOT_IMPLEMENTED
;
423 static nsresult NSAPI
nsChannel_GetNotificationCallbacks(nsIHttpChannel
*iface
,
424 nsIInterfaceRequestor
**aNotificationCallbacks
)
426 nsChannel
*This
= NSCHANNEL_THIS(iface
);
428 TRACE("(%p)->(%p)\n", This
, aNotificationCallbacks
);
430 if(This
->notif_callback
)
431 nsIInterfaceRequestor_AddRef(This
->notif_callback
);
432 *aNotificationCallbacks
= This
->notif_callback
;
437 static nsresult NSAPI
nsChannel_SetNotificationCallbacks(nsIHttpChannel
*iface
,
438 nsIInterfaceRequestor
*aNotificationCallbacks
)
440 nsChannel
*This
= NSCHANNEL_THIS(iface
);
442 TRACE("(%p)->(%p)\n", This
, aNotificationCallbacks
);
444 if(This
->notif_callback
)
445 nsIInterfaceRequestor_Release(This
->notif_callback
);
446 if(aNotificationCallbacks
)
447 nsIInterfaceRequestor_AddRef(aNotificationCallbacks
);
449 This
->notif_callback
= aNotificationCallbacks
;
452 return nsIChannel_SetNotificationCallbacks(This
->channel
, aNotificationCallbacks
);
456 static nsresult NSAPI
nsChannel_GetSecurityInfo(nsIHttpChannel
*iface
, nsISupports
**aSecurityInfo
)
458 nsChannel
*This
= NSCHANNEL_THIS(iface
);
460 TRACE("(%p)->(%p)\n", This
, aSecurityInfo
);
463 return nsIChannel_GetSecurityInfo(This
->channel
, aSecurityInfo
);
465 FIXME("default action not implemented\n");
466 return NS_ERROR_NOT_IMPLEMENTED
;
469 static nsresult NSAPI
nsChannel_GetContentType(nsIHttpChannel
*iface
, nsACString
*aContentType
)
471 nsChannel
*This
= NSCHANNEL_THIS(iface
);
473 TRACE("(%p)->(%p)\n", This
, aContentType
);
476 nsACString_Init(aContentType
, This
->content
);
481 return nsIChannel_GetContentType(This
->channel
, aContentType
);
483 FIXME("default action not implemented\n");
484 return NS_ERROR_NOT_IMPLEMENTED
;
487 static nsresult NSAPI
nsChannel_SetContentType(nsIHttpChannel
*iface
,
488 const nsACString
*aContentType
)
490 nsChannel
*This
= NSCHANNEL_THIS(iface
);
492 TRACE("(%p)->(%p)\n", This
, aContentType
);
495 return nsIChannel_SetContentType(This
->channel
, aContentType
);
497 FIXME("default action not implemented\n");
498 return NS_ERROR_NOT_IMPLEMENTED
;
501 static nsresult NSAPI
nsChannel_GetContentCharset(nsIHttpChannel
*iface
,
502 nsACString
*aContentCharset
)
504 nsChannel
*This
= NSCHANNEL_THIS(iface
);
506 TRACE("(%p)->(%p)\n", This
, aContentCharset
);
509 return nsIChannel_GetContentCharset(This
->channel
, aContentCharset
);
511 FIXME("default action not implemented\n");
512 return NS_ERROR_NOT_IMPLEMENTED
;
515 static nsresult NSAPI
nsChannel_SetContentCharset(nsIHttpChannel
*iface
,
516 const nsACString
*aContentCharset
)
518 nsChannel
*This
= NSCHANNEL_THIS(iface
);
520 TRACE("(%p)->(%p)\n", This
, aContentCharset
);
523 return nsIChannel_SetContentCharset(This
->channel
, aContentCharset
);
525 FIXME("default action not implemented\n");
526 return NS_ERROR_NOT_IMPLEMENTED
;
529 static nsresult NSAPI
nsChannel_GetContentLength(nsIHttpChannel
*iface
, PRInt32
*aContentLength
)
531 nsChannel
*This
= NSCHANNEL_THIS(iface
);
533 TRACE("(%p)->(%p)\n", This
, aContentLength
);
536 return nsIChannel_GetContentLength(This
->channel
, aContentLength
);
538 FIXME("default action not implemented\n");
539 return NS_ERROR_NOT_IMPLEMENTED
;
542 static nsresult NSAPI
nsChannel_SetContentLength(nsIHttpChannel
*iface
, PRInt32 aContentLength
)
544 nsChannel
*This
= NSCHANNEL_THIS(iface
);
546 TRACE("(%p)->(%ld)\n", This
, aContentLength
);
549 return nsIChannel_SetContentLength(This
->channel
, aContentLength
);
551 FIXME("default action not implemented\n");
552 return NS_ERROR_NOT_IMPLEMENTED
;
555 static nsresult NSAPI
nsChannel_Open(nsIHttpChannel
*iface
, nsIInputStream
**_retval
)
557 nsChannel
*This
= NSCHANNEL_THIS(iface
);
559 TRACE("(%p)->(%p)\n", This
, _retval
);
562 return nsIChannel_Open(This
->channel
, _retval
);
564 FIXME("default action not implemented\n");
565 return NS_ERROR_NOT_IMPLEMENTED
;
568 static nsresult NSAPI
nsChannel_AsyncOpen(nsIHttpChannel
*iface
, nsIStreamListener
*aListener
,
569 nsISupports
*aContext
)
571 nsChannel
*This
= NSCHANNEL_THIS(iface
);
574 TRACE("(%p)->(%p %p)\n", This
, aListener
, aContext
);
576 if(This
->load_flags
& LOAD_INITIAL_DOCUMENT_URI
) {
577 NSContainer
*container
;
579 nsIWineURI_GetNSContainer(This
->uri
, &container
);
581 ERR("container = NULL\n");
582 return NS_ERROR_UNEXPECTED
;
585 if(container
->bscallback
) {
586 nsIChannel_AddRef(NSCHANNEL(This
));
587 container
->bscallback
->nschannel
= This
;
589 nsIStreamListener_AddRef(aListener
);
590 container
->bscallback
->nslistener
= aListener
;
593 nsISupports_AddRef(aContext
);
594 container
->bscallback
->nscontext
= aContext
;
597 nsIWebBrowserChrome_Release(NSWBCHROME(container
));
599 BOOL cont
= before_async_open(This
, container
);
600 nsIWebBrowserChrome_Release(NSWBCHROME(container
));
604 return NS_ERROR_UNEXPECTED
;
610 FIXME("channel == NULL\n");
611 return NS_ERROR_UNEXPECTED
;
614 if(This
->post_data_stream
) {
615 nsIUploadChannel
*upload_channel
;
617 nsres
= nsIChannel_QueryInterface(This
->channel
, &IID_nsIUploadChannel
,
618 (void**)&upload_channel
);
619 if(NS_SUCCEEDED(nsres
)) {
620 nsACString empty_string
;
621 nsACString_Init(&empty_string
, "");
623 nsres
= nsIUploadChannel_SetUploadStream(upload_channel
, This
->post_data_stream
,
625 nsIUploadChannel_Release(upload_channel
);
627 WARN("SetUploadStream failed: %08lx\n", nsres
);
629 nsACString_Finish(&empty_string
);
633 return nsIChannel_AsyncOpen(This
->channel
, aListener
, aContext
);
636 static nsresult NSAPI
nsChannel_GetRequestMethod(nsIHttpChannel
*iface
, nsACString
*aRequestMethod
)
638 nsChannel
*This
= NSCHANNEL_THIS(iface
);
640 TRACE("(%p)->(%p)\n", This
, aRequestMethod
);
642 if(This
->http_channel
)
643 return nsIHttpChannel_GetRequestMethod(This
->http_channel
, aRequestMethod
);
645 return NS_ERROR_NOT_IMPLEMENTED
;
648 static nsresult NSAPI
nsChannel_SetRequestMethod(nsIHttpChannel
*iface
,
649 const nsACString
*aRequestMethod
)
651 nsChannel
*This
= NSCHANNEL_THIS(iface
);
653 TRACE("(%p)->(%p)\n", This
, aRequestMethod
);
655 if(This
->http_channel
)
656 return nsIHttpChannel_SetRequestMethod(This
->http_channel
, aRequestMethod
);
658 return NS_ERROR_NOT_IMPLEMENTED
;
661 static nsresult NSAPI
nsChannel_GetReferrer(nsIHttpChannel
*iface
, nsIURI
**aReferrer
)
663 nsChannel
*This
= NSCHANNEL_THIS(iface
);
665 TRACE("(%p)->(%p)\n", This
, aReferrer
);
667 if(This
->http_channel
)
668 return nsIHttpChannel_GetReferrer(This
->http_channel
, aReferrer
);
670 return NS_ERROR_NOT_IMPLEMENTED
;
673 static nsresult NSAPI
nsChannel_SetReferrer(nsIHttpChannel
*iface
, nsIURI
*aReferrer
)
675 nsChannel
*This
= NSCHANNEL_THIS(iface
);
677 TRACE("(%p)->(%p)\n", This
, aReferrer
);
679 if(This
->http_channel
)
680 return nsIHttpChannel_SetReferrer(This
->http_channel
, aReferrer
);
682 return NS_ERROR_NOT_IMPLEMENTED
;
685 static nsresult NSAPI
nsChannel_GetRequestHeader(nsIHttpChannel
*iface
,
686 const nsACString
*aHeader
, nsACString
*_retval
)
688 nsChannel
*This
= NSCHANNEL_THIS(iface
);
690 TRACE("(%p)->(%p %p)\n", This
, aHeader
, _retval
);
692 if(This
->http_channel
)
693 return nsIHttpChannel_GetRequestHeader(This
->http_channel
, aHeader
, _retval
);
695 return NS_ERROR_NOT_IMPLEMENTED
;
698 static nsresult NSAPI
nsChannel_SetRequestHeader(nsIHttpChannel
*iface
,
699 const nsACString
*aHeader
, const nsACString
*aValue
, PRBool aMerge
)
701 nsChannel
*This
= NSCHANNEL_THIS(iface
);
703 TRACE("(%p)->(%p %p %x)\n", This
, aHeader
, aValue
, aMerge
);
705 if(This
->http_channel
)
706 return nsIHttpChannel_SetRequestHeader(This
->http_channel
, aHeader
, aValue
, aMerge
);
708 return NS_ERROR_NOT_IMPLEMENTED
;
711 static nsresult NSAPI
nsChannel_VisitRequestHeaders(nsIHttpChannel
*iface
,
712 nsIHttpHeaderVisitor
*aVisitor
)
714 nsChannel
*This
= NSCHANNEL_THIS(iface
);
716 TRACE("(%p)->(%p)\n", This
, aVisitor
);
718 if(This
->http_channel
)
719 return nsIHttpChannel_VisitRequestHeaders(This
->http_channel
, aVisitor
);
721 return NS_ERROR_NOT_IMPLEMENTED
;
724 static nsresult NSAPI
nsChannel_GetAllowPipelining(nsIHttpChannel
*iface
, PRBool
*aAllowPipelining
)
726 nsChannel
*This
= NSCHANNEL_THIS(iface
);
728 TRACE("(%p)->(%p)\n", This
, aAllowPipelining
);
730 if(This
->http_channel
)
731 return nsIHttpChannel_GetAllowPipelining(This
->http_channel
, aAllowPipelining
);
733 return NS_ERROR_NOT_IMPLEMENTED
;
736 static nsresult NSAPI
nsChannel_SetAllowPipelining(nsIHttpChannel
*iface
, PRBool aAllowPipelining
)
738 nsChannel
*This
= NSCHANNEL_THIS(iface
);
740 TRACE("(%p)->(%x)\n", This
, aAllowPipelining
);
742 if(This
->http_channel
)
743 return nsIHttpChannel_SetAllowPipelining(This
->http_channel
, aAllowPipelining
);
745 return NS_ERROR_NOT_IMPLEMENTED
;
748 static nsresult NSAPI
nsChannel_GetRedirectionLimit(nsIHttpChannel
*iface
, PRUint32
*aRedirectionLimit
)
750 nsChannel
*This
= NSCHANNEL_THIS(iface
);
752 TRACE("(%p)->(%p)\n", This
, aRedirectionLimit
);
754 if(This
->http_channel
)
755 return nsIHttpChannel_GetRedirectionLimit(This
->http_channel
, aRedirectionLimit
);
757 return NS_ERROR_NOT_IMPLEMENTED
;
760 static nsresult NSAPI
nsChannel_SetRedirectionLimit(nsIHttpChannel
*iface
, PRUint32 aRedirectionLimit
)
762 nsChannel
*This
= NSCHANNEL_THIS(iface
);
764 TRACE("(%p)->(%lu)\n", This
, aRedirectionLimit
);
766 if(This
->http_channel
)
767 return nsIHttpChannel_SetRedirectionLimit(This
->http_channel
, aRedirectionLimit
);
769 return NS_ERROR_NOT_IMPLEMENTED
;
772 static nsresult NSAPI
nsChannel_GetResponseStatus(nsIHttpChannel
*iface
, PRUint32
*aResponseStatus
)
774 nsChannel
*This
= NSCHANNEL_THIS(iface
);
776 TRACE("(%p)->(%p)\n", This
, aResponseStatus
);
778 if(This
->http_channel
)
779 return nsIHttpChannel_GetResponseStatus(This
->http_channel
, aResponseStatus
);
781 return NS_ERROR_NOT_IMPLEMENTED
;
784 static nsresult NSAPI
nsChannel_GetResponseStatusText(nsIHttpChannel
*iface
,
785 nsACString
*aResponseStatusText
)
787 nsChannel
*This
= NSCHANNEL_THIS(iface
);
789 TRACE("(%p)->(%p)\n", This
, aResponseStatusText
);
791 if(This
->http_channel
)
792 return nsIHttpChannel_GetResponseStatusText(This
->http_channel
, aResponseStatusText
);
794 return NS_ERROR_NOT_IMPLEMENTED
;
797 static nsresult NSAPI
nsChannel_GetRequestSucceeded(nsIHttpChannel
*iface
,
798 PRBool
*aRequestSucceeded
)
800 nsChannel
*This
= NSCHANNEL_THIS(iface
);
802 TRACE("(%p)->(%p)\n", This
, aRequestSucceeded
);
804 if(This
->http_channel
)
805 return nsIHttpChannel_GetRequestSucceeded(This
->http_channel
, aRequestSucceeded
);
807 return NS_ERROR_NOT_IMPLEMENTED
;
810 static nsresult NSAPI
nsChannel_GetResponseHeader(nsIHttpChannel
*iface
,
811 const nsACString
*header
, nsACString
*_retval
)
813 nsChannel
*This
= NSCHANNEL_THIS(iface
);
815 TRACE("(%p)->(%p %p)\n", This
, header
, _retval
);
817 if(This
->http_channel
)
818 return nsIHttpChannel_GetResponseHeader(This
->http_channel
, header
, _retval
);
820 return NS_ERROR_NOT_IMPLEMENTED
;
823 static nsresult NSAPI
nsChannel_SetResponseHeader(nsIHttpChannel
*iface
,
824 const nsACString
*header
, const nsACString
*value
, PRBool merge
)
826 nsChannel
*This
= NSCHANNEL_THIS(iface
);
828 TRACE("(%p)->(%p %p %x)\n", This
, header
, value
, merge
);
830 if(This
->http_channel
)
831 return nsIHttpChannel_SetResponseHeader(This
->http_channel
, header
, value
, merge
);
833 return NS_ERROR_NOT_IMPLEMENTED
;
836 static nsresult NSAPI
nsChannel_VisitResponseHeaders(nsIHttpChannel
*iface
,
837 nsIHttpHeaderVisitor
*aVisitor
)
839 nsChannel
*This
= NSCHANNEL_THIS(iface
);
841 TRACE("(%p)->(%p)\n", This
, aVisitor
);
843 if(This
->http_channel
)
844 return nsIHttpChannel_VisitResponseHeaders(This
->http_channel
, aVisitor
);
846 return NS_ERROR_NOT_IMPLEMENTED
;
849 static nsresult NSAPI
nsChannel_IsNoStoreResponse(nsIHttpChannel
*iface
, PRBool
*_retval
)
851 nsChannel
*This
= NSCHANNEL_THIS(iface
);
853 TRACE("(%p)->(%p)\n", This
, _retval
);
855 if(This
->http_channel
)
856 return nsIHttpChannel_IsNoStoreResponse(This
->http_channel
, _retval
);
858 return NS_ERROR_NOT_IMPLEMENTED
;
861 static nsresult NSAPI
nsChannel_IsNoCacheResponse(nsIHttpChannel
*iface
, PRBool
*_retval
)
863 nsChannel
*This
= NSCHANNEL_THIS(iface
);
865 TRACE("(%p)->(%p)\n", This
, _retval
);
867 if(This
->http_channel
)
868 return nsIHttpChannel_IsNoCacheResponse(This
->http_channel
, _retval
);
870 return NS_ERROR_NOT_IMPLEMENTED
;
873 #undef NSCHANNEL_THIS
875 static const nsIHttpChannelVtbl nsChannelVtbl
= {
876 nsChannel_QueryInterface
,
885 nsChannel_GetLoadGroup
,
886 nsChannel_SetLoadGroup
,
887 nsChannel_GetLoadFlags
,
888 nsChannel_SetLoadFlags
,
889 nsChannel_GetOriginalURI
,
890 nsChannel_SetOriginalURI
,
894 nsChannel_GetNotificationCallbacks
,
895 nsChannel_SetNotificationCallbacks
,
896 nsChannel_GetSecurityInfo
,
897 nsChannel_GetContentType
,
898 nsChannel_SetContentType
,
899 nsChannel_GetContentCharset
,
900 nsChannel_SetContentCharset
,
901 nsChannel_GetContentLength
,
902 nsChannel_SetContentLength
,
905 nsChannel_GetRequestMethod
,
906 nsChannel_SetRequestMethod
,
907 nsChannel_GetReferrer
,
908 nsChannel_SetReferrer
,
909 nsChannel_GetRequestHeader
,
910 nsChannel_SetRequestHeader
,
911 nsChannel_VisitRequestHeaders
,
912 nsChannel_GetAllowPipelining
,
913 nsChannel_SetAllowPipelining
,
914 nsChannel_GetRedirectionLimit
,
915 nsChannel_SetRedirectionLimit
,
916 nsChannel_GetResponseStatus
,
917 nsChannel_GetResponseStatusText
,
918 nsChannel_GetRequestSucceeded
,
919 nsChannel_GetResponseHeader
,
920 nsChannel_SetResponseHeader
,
921 nsChannel_VisitResponseHeaders
,
922 nsChannel_IsNoStoreResponse
,
923 nsChannel_IsNoCacheResponse
926 #define NSUPCHANNEL_THIS(iface) DEFINE_THIS(nsChannel, UploadChannel, iface)
928 static nsresult NSAPI
nsUploadChannel_QueryInterface(nsIUploadChannel
*iface
, nsIIDRef riid
,
931 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
932 return nsIChannel_QueryInterface(NSCHANNEL(This
), riid
, result
);
935 static nsrefcnt NSAPI
nsUploadChannel_AddRef(nsIUploadChannel
*iface
)
937 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
938 return nsIChannel_AddRef(NSCHANNEL(This
));
941 static nsrefcnt NSAPI
nsUploadChannel_Release(nsIUploadChannel
*iface
)
943 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
944 return nsIChannel_Release(NSCHANNEL(This
));
947 static nsresult NSAPI
nsUploadChannel_SetUploadStream(nsIUploadChannel
*iface
,
948 nsIInputStream
*aStream
, const nsACString
*aContentType
, PRInt32 aContentLength
)
950 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
951 const char *content_type
;
953 TRACE("(%p)->(%p %p %ld)\n", This
, aStream
, aContentType
, aContentLength
);
955 if(This
->post_data_stream
)
956 nsIInputStream_Release(This
->post_data_stream
);
959 nsACString_GetData(aContentType
, &content_type
, NULL
);
961 FIXME("Unsupported aContentType argument: %s\n", debugstr_a(content_type
));
964 if(aContentLength
!= -1)
965 FIXME("Unsupported acontentLength = %ld\n", aContentLength
);
968 nsIInputStream_AddRef(aStream
);
969 This
->post_data_stream
= aStream
;
974 static nsresult NSAPI
nsUploadChannel_GetUploadStream(nsIUploadChannel
*iface
,
975 nsIInputStream
**aUploadStream
)
977 nsChannel
*This
= NSUPCHANNEL_THIS(iface
);
979 TRACE("(%p)->(%p)\n", This
, aUploadStream
);
981 if(This
->post_data_stream
)
982 nsIInputStream_AddRef(This
->post_data_stream
);
984 *aUploadStream
= This
->post_data_stream
;
988 #undef NSUPCHANNEL_THIS
990 static const nsIUploadChannelVtbl nsUploadChannelVtbl
= {
991 nsUploadChannel_QueryInterface
,
992 nsUploadChannel_AddRef
,
993 nsUploadChannel_Release
,
994 nsUploadChannel_SetUploadStream
,
995 nsUploadChannel_GetUploadStream
998 #define NSURI_THIS(iface) DEFINE_THIS(nsURI, WineURI, iface)
1000 static nsresult NSAPI
nsURI_QueryInterface(nsIWineURI
*iface
, nsIIDRef riid
, nsQIResult result
)
1002 nsURI
*This
= NSURI_THIS(iface
);
1006 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
1007 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
1008 *result
= NSURI(This
);
1009 }else if(IsEqualGUID(&IID_nsIURI
, riid
)) {
1010 TRACE("(%p)->(IID_nsIURI %p)\n", This
, result
);
1011 *result
= NSURI(This
);
1012 }else if(IsEqualGUID(&IID_nsIWineURI
, riid
)) {
1013 TRACE("(%p)->(IID_nsIWineURI %p)\n", This
, result
);
1014 *result
= NSURI(This
);
1018 nsIURI_AddRef(NSURI(This
));
1022 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), result
);
1023 return nsIURI_QueryInterface(This
->uri
, riid
, result
);
1026 static nsrefcnt NSAPI
nsURI_AddRef(nsIWineURI
*iface
)
1028 nsURI
*This
= NSURI_THIS(iface
);
1029 LONG ref
= InterlockedIncrement(&This
->ref
);
1031 TRACE("(%p) ref=%ld\n", This
, ref
);
1036 static nsrefcnt NSAPI
nsURI_Release(nsIWineURI
*iface
)
1038 nsURI
*This
= NSURI_THIS(iface
);
1039 LONG ref
= InterlockedDecrement(&This
->ref
);
1041 TRACE("(%p) ref=%ld\n", This
, ref
);
1045 nsIWebBrowserChrome_Release(NSWBCHROME(This
->container
));
1046 nsIURI_Release(This
->uri
);
1047 HeapFree(GetProcessHeap(), 0, This
);
1053 static nsresult NSAPI
nsURI_GetSpec(nsIWineURI
*iface
, nsACString
*aSpec
)
1055 nsURI
*This
= NSURI_THIS(iface
);
1056 TRACE("(%p)->(%p)\n", This
, aSpec
);
1057 return nsIURI_GetSpec(This
->uri
, aSpec
);
1060 static nsresult NSAPI
nsURI_SetSpec(nsIWineURI
*iface
, const nsACString
*aSpec
)
1062 nsURI
*This
= NSURI_THIS(iface
);
1063 TRACE("(%p)->(%p)\n", This
, aSpec
);
1064 return nsIURI_SetSpec(This
->uri
, aSpec
);
1067 static nsresult NSAPI
nsURI_GetPrePath(nsIWineURI
*iface
, nsACString
*aPrePath
)
1069 nsURI
*This
= NSURI_THIS(iface
);
1070 TRACE("(%p)->(%p)\n", This
, aPrePath
);
1071 return nsIURI_GetPrePath(This
->uri
, aPrePath
);
1074 static nsresult NSAPI
nsURI_GetScheme(nsIWineURI
*iface
, nsACString
*aScheme
)
1076 nsURI
*This
= NSURI_THIS(iface
);
1077 TRACE("(%p)->(%p)\n", This
, aScheme
);
1078 return nsIURI_GetScheme(This
->uri
, aScheme
);
1081 static nsresult NSAPI
nsURI_SetScheme(nsIWineURI
*iface
, const nsACString
*aScheme
)
1083 nsURI
*This
= NSURI_THIS(iface
);
1084 TRACE("(%p)->(%p)\n", This
, aScheme
);
1085 return nsIURI_SetScheme(This
->uri
, aScheme
);
1088 static nsresult NSAPI
nsURI_GetUserPass(nsIWineURI
*iface
, nsACString
*aUserPass
)
1090 nsURI
*This
= NSURI_THIS(iface
);
1091 TRACE("(%p)->(%p)\n", This
, aUserPass
);
1092 return nsIURI_GetUserPass(This
->uri
, aUserPass
);
1095 static nsresult NSAPI
nsURI_SetUserPass(nsIWineURI
*iface
, const nsACString
*aUserPass
)
1097 nsURI
*This
= NSURI_THIS(iface
);
1098 TRACE("(%p)->(%p)\n", This
, aUserPass
);
1099 return nsIURI_SetUserPass(This
->uri
, aUserPass
);
1102 static nsresult NSAPI
nsURI_GetUsername(nsIWineURI
*iface
, nsACString
*aUsername
)
1104 nsURI
*This
= NSURI_THIS(iface
);
1105 TRACE("(%p)->(%p)\n", This
, aUsername
);
1106 return nsIURI_GetUsername(This
->uri
, aUsername
);
1109 static nsresult NSAPI
nsURI_SetUsername(nsIWineURI
*iface
, const nsACString
*aUsername
)
1111 nsURI
*This
= NSURI_THIS(iface
);
1112 TRACE("(%p)->(%p)\n", This
, aUsername
);
1113 return nsIURI_SetUsername(This
->uri
, aUsername
);
1116 static nsresult NSAPI
nsURI_GetPassword(nsIWineURI
*iface
, nsACString
*aPassword
)
1118 nsURI
*This
= NSURI_THIS(iface
);
1119 TRACE("(%p)->(%p)\n", This
, aPassword
);
1120 return nsIURI_GetPassword(This
->uri
, aPassword
);
1123 static nsresult NSAPI
nsURI_SetPassword(nsIWineURI
*iface
, const nsACString
*aPassword
)
1125 nsURI
*This
= NSURI_THIS(iface
);
1126 TRACE("(%p)->(%p)\n", This
, aPassword
);
1127 return nsIURI_SetPassword(This
->uri
, aPassword
);
1130 static nsresult NSAPI
nsURI_GetHostPort(nsIWineURI
*iface
, nsACString
*aHostPort
)
1132 nsURI
*This
= NSURI_THIS(iface
);
1133 TRACE("(%p)->(%p)\n", This
, aHostPort
);
1134 return nsIURI_GetHostPort(This
->uri
, aHostPort
);
1137 static nsresult NSAPI
nsURI_SetHostPort(nsIWineURI
*iface
, const nsACString
*aHostPort
)
1139 nsURI
*This
= NSURI_THIS(iface
);
1140 TRACE("(%p)->(%p)\n", This
, aHostPort
);
1141 return nsIURI_SetHostPort(This
->uri
, aHostPort
);
1144 static nsresult NSAPI
nsURI_GetHost(nsIWineURI
*iface
, nsACString
*aHost
)
1146 nsURI
*This
= NSURI_THIS(iface
);
1147 TRACE("(%p)->(%p)\n", This
, aHost
);
1148 return nsIURI_GetHost(This
->uri
, aHost
);
1151 static nsresult NSAPI
nsURI_SetHost(nsIWineURI
*iface
, const nsACString
*aHost
)
1153 nsURI
*This
= NSURI_THIS(iface
);
1154 TRACE("(%p)->(%p)\n", This
, aHost
);
1155 return nsIURI_SetHost(This
->uri
, aHost
);
1158 static nsresult NSAPI
nsURI_GetPort(nsIWineURI
*iface
, PRInt32
*aPort
)
1160 nsURI
*This
= NSURI_THIS(iface
);
1161 TRACE("(%p)->(%p)\n", This
, aPort
);
1162 return nsIURI_GetPort(This
->uri
, aPort
);
1165 static nsresult NSAPI
nsURI_SetPort(nsIWineURI
*iface
, PRInt32 aPort
)
1167 nsURI
*This
= NSURI_THIS(iface
);
1168 TRACE("(%p)->(%ld)\n", This
, aPort
);
1169 return nsIURI_SetPort(This
->uri
, aPort
);
1172 static nsresult NSAPI
nsURI_GetPath(nsIWineURI
*iface
, nsACString
*aPath
)
1174 nsURI
*This
= NSURI_THIS(iface
);
1175 TRACE("(%p)->(%p)\n", This
, aPath
);
1176 return nsIURI_GetPath(This
->uri
, aPath
);
1179 static nsresult NSAPI
nsURI_SetPath(nsIWineURI
*iface
, const nsACString
*aPath
)
1181 nsURI
*This
= NSURI_THIS(iface
);
1182 TRACE("(%p)->(%p)\n", This
, aPath
);
1183 return nsIURI_SetPath(This
->uri
, aPath
);
1186 static nsresult NSAPI
nsURI_Equals(nsIWineURI
*iface
, nsIURI
*other
, PRBool
*_retval
)
1188 nsURI
*This
= NSURI_THIS(iface
);
1189 TRACE("(%p)->(%p %p)\n", This
, other
, _retval
);
1190 return nsIURI_Equals(This
->uri
, other
, _retval
);
1193 static nsresult NSAPI
nsURI_SchemeIs(nsIWineURI
*iface
, const char *scheme
, PRBool
*_retval
)
1195 nsURI
*This
= NSURI_THIS(iface
);
1196 TRACE("(%p)->(%s %p)\n", This
, debugstr_a(scheme
), _retval
);
1197 return nsIURI_SchemeIs(This
->uri
, scheme
, _retval
);
1200 static nsresult NSAPI
nsURI_Clone(nsIWineURI
*iface
, nsIURI
**_retval
)
1202 nsURI
*This
= NSURI_THIS(iface
);
1206 TRACE("(%p)->(%p)\n", This
, _retval
);
1208 nsres
= nsIURI_Clone(This
->uri
, &uri
);
1209 if(NS_FAILED(nsres
)) {
1210 WARN("Clone failed: %08lx\n", nsres
);
1214 return create_uri(uri
, This
->container
, _retval
);
1217 static nsresult NSAPI
nsURI_Resolve(nsIWineURI
*iface
, const nsACString
*arelativePath
,
1218 nsACString
*_retval
)
1220 nsURI
*This
= NSURI_THIS(iface
);
1221 TRACE("(%p)->(%p %p)\n", This
, arelativePath
, _retval
);
1222 return nsIURI_Resolve(This
->uri
, arelativePath
, _retval
);
1225 static nsresult NSAPI
nsURI_GetAsciiSpec(nsIWineURI
*iface
, nsACString
*aAsciiSpec
)
1227 nsURI
*This
= NSURI_THIS(iface
);
1228 TRACE("(%p)->(%p)\n", This
, aAsciiSpec
);
1229 return nsIURI_GetAsciiSpec(This
->uri
, aAsciiSpec
);
1232 static nsresult NSAPI
nsURI_GetAsciiHost(nsIWineURI
*iface
, nsACString
*aAsciiHost
)
1234 nsURI
*This
= NSURI_THIS(iface
);
1235 TRACE("(%p)->(%p)\n", This
, aAsciiHost
);
1236 return nsIURI_GetAsciiHost(This
->uri
, aAsciiHost
);
1239 static nsresult NSAPI
nsURI_GetOriginCharset(nsIWineURI
*iface
, nsACString
*aOriginCharset
)
1241 nsURI
*This
= NSURI_THIS(iface
);
1242 TRACE("(%p)->(%p)\n", This
, aOriginCharset
);
1243 return nsIURI_GetOriginCharset(This
->uri
, aOriginCharset
);
1246 static nsresult NSAPI
nsURI_GetNSContainer(nsIWineURI
*iface
, NSContainer
**aContainer
)
1248 nsURI
*This
= NSURI_THIS(iface
);
1250 TRACE("(%p)->(%p)\n", This
, aContainer
);
1253 nsIWebBrowserChrome_AddRef(NSWBCHROME(This
->container
));
1254 *aContainer
= This
->container
;
1259 static nsresult NSAPI
nsURI_SetNSContainer(nsIWineURI
*iface
, NSContainer
*aContainer
)
1261 nsURI
*This
= NSURI_THIS(iface
);
1263 TRACE("(%p)->(%p)\n", This
, aContainer
);
1265 if(This
->container
) {
1266 WARN("Container already set: %p\n", This
->container
);
1267 nsIWebBrowserChrome_Release(NSWBCHROME(This
->container
));
1271 nsIWebBrowserChrome_AddRef(NSWBCHROME(aContainer
));
1272 This
->container
= aContainer
;
1279 static const nsIWineURIVtbl nsWineURIVtbl
= {
1280 nsURI_QueryInterface
,
1308 nsURI_GetOriginCharset
,
1309 nsURI_GetNSContainer
,
1310 nsURI_SetNSContainer
,
1313 static nsresult
create_uri(nsIURI
*uri
, NSContainer
*container
, nsIURI
**_retval
)
1315 nsURI
*ret
= HeapAlloc(GetProcessHeap(), 0, sizeof(nsURI
));
1317 ret
->lpWineURIVtbl
= &nsWineURIVtbl
;
1320 ret
->container
= container
;
1323 nsIWebBrowserChrome_AddRef(NSWBCHROME(container
));
1325 TRACE("retval=%p\n", ret
);
1326 *_retval
= NSURI(ret
);
1330 static nsresult NSAPI
nsIOService_QueryInterface(nsIIOService
*iface
, nsIIDRef riid
,
1335 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
1336 TRACE("(IID_nsISupports %p)\n", result
);
1338 }else if(IsEqualGUID(&IID_nsIIOService
, riid
)) {
1339 TRACE("(IID_nsIIOService %p)\n", result
);
1344 nsIIOService_AddRef(iface
);
1348 WARN("(%s %p)\n", debugstr_guid(riid
), result
);
1349 return NS_NOINTERFACE
;
1352 static nsrefcnt NSAPI
nsIOService_AddRef(nsIIOService
*iface
)
1357 static nsrefcnt NSAPI
nsIOService_Release(nsIIOService
*iface
)
1362 static nsresult NSAPI
nsIOService_GetProtocolHandler(nsIIOService
*iface
, const char *aScheme
,
1363 nsIProtocolHandler
**_retval
)
1365 TRACE("(%s %p)\n", debugstr_a(aScheme
), _retval
);
1366 return nsIIOService_GetProtocolHandler(nsio
, aScheme
, _retval
);
1369 static nsresult NSAPI
nsIOService_GetProtocolFlags(nsIIOService
*iface
, const char *aScheme
,
1372 TRACE("(%s %p)\n", debugstr_a(aScheme
), _retval
);
1373 return nsIIOService_GetProtocolFlags(nsio
, aScheme
, _retval
);
1376 static nsresult NSAPI
nsIOService_NewURI(nsIIOService
*iface
, const nsACString
*aSpec
,
1377 const char *aOriginCharset
, nsIURI
*aBaseURI
, nsIURI
**_retval
)
1379 const char *spec
= NULL
;
1381 PRBool is_javascript
= FALSE
;
1384 nsACString_GetData(aSpec
, &spec
, NULL
);
1386 TRACE("(%p(%s) %s %p %p)\n", aSpec
, debugstr_a(spec
), debugstr_a(aOriginCharset
),
1390 nsACString base_uri_str
;
1391 const char *base_uri
= NULL
;
1393 nsACString_Init(&base_uri_str
, NULL
);
1395 nsres
= nsIURI_GetSpec(aBaseURI
, &base_uri_str
);
1396 if(NS_SUCCEEDED(nsres
)) {
1397 nsACString_GetData(&base_uri_str
, &base_uri
, NULL
);
1398 TRACE("uri=%s\n", debugstr_a(base_uri
));
1400 ERR("GetSpec failed: %08lx\n", nsres
);
1403 nsACString_Finish(&base_uri_str
);
1406 nsres
= nsIIOService_NewURI(nsio
, aSpec
, aOriginCharset
, aBaseURI
, &uri
);
1407 if(NS_FAILED(nsres
)) {
1408 WARN("NewURI failed: %08lx\n", nsres
);
1412 nsIURI_SchemeIs(uri
, "javascript", &is_javascript
);
1414 TRACE("returning javascript uri: %p\n", uri
);
1419 return create_uri(uri
, NULL
, _retval
);
1422 static nsresult NSAPI
nsIOService_NewFileURI(nsIIOService
*iface
, nsIFile
*aFile
,
1425 TRACE("(%p %p)\n", aFile
, _retval
);
1426 return nsIIOService_NewFileURI(nsio
, aFile
, _retval
);
1429 static nsresult NSAPI
nsIOService_NewChannelFromURI(nsIIOService
*iface
, nsIURI
*aURI
,
1430 nsIChannel
**_retval
)
1432 nsIChannel
*channel
= NULL
;
1434 nsIWineURI
*wine_uri
;
1437 TRACE("(%p %p)\n", aURI
, _retval
);
1439 nsres
= nsIIOService_NewChannelFromURI(nsio
, aURI
, &channel
);
1440 if(NS_FAILED(nsres
) && nsres
!= NS_ERROR_UNKNOWN_PROTOCOL
) {
1441 WARN("NewChannelFromURI failed: %08lx\n", nsres
);
1446 nsres
= nsIURI_QueryInterface(aURI
, &IID_nsIWineURI
, (void**)&wine_uri
);
1447 if(NS_FAILED(nsres
)) {
1448 WARN("Could not get nsIWineURI: %08lx\n", nsres
);
1450 return channel
? NS_OK
: NS_ERROR_UNEXPECTED
;
1453 ret
= HeapAlloc(GetProcessHeap(), 0, sizeof(nsChannel
));
1455 ret
->lpHttpChannelVtbl
= &nsChannelVtbl
;
1456 ret
->lpUploadChannelVtbl
= &nsUploadChannelVtbl
;
1458 ret
->channel
= channel
;
1459 ret
->http_channel
= NULL
;
1460 ret
->uri
= wine_uri
;
1461 ret
->post_data_stream
= NULL
;
1462 ret
->load_group
= NULL
;
1463 ret
->notif_callback
= NULL
;
1464 ret
->load_flags
= 0;
1465 ret
->content
= NULL
;
1467 nsIURI_AddRef(aURI
);
1468 ret
->original_uri
= aURI
;
1471 nsIChannel_QueryInterface(channel
, &IID_nsIHttpChannel
, (void**)&ret
->http_channel
);
1473 *_retval
= NSCHANNEL(ret
);
1477 static nsresult NSAPI
nsIOService_NewChannel(nsIIOService
*iface
, const nsACString
*aSpec
,
1478 const char *aOriginCharset
, nsIURI
*aBaseURI
, nsIChannel
**_retval
)
1480 TRACE("(%p %s %p %p)\n", aSpec
, debugstr_a(aOriginCharset
), aBaseURI
, _retval
);
1481 return nsIIOService_NewChannel(nsio
, aSpec
, aOriginCharset
, aBaseURI
, _retval
);
1484 static nsresult NSAPI
nsIOService_GetOffline(nsIIOService
*iface
, PRBool
*aOffline
)
1486 TRACE("(%p)\n", aOffline
);
1487 return nsIIOService_GetOffline(nsio
, aOffline
);
1490 static nsresult NSAPI
nsIOService_SetOffline(nsIIOService
*iface
, PRBool aOffline
)
1492 TRACE("(%x)\n", aOffline
);
1493 return nsIIOService_SetOffline(nsio
, aOffline
);
1496 static nsresult NSAPI
nsIOService_AllowPort(nsIIOService
*iface
, PRInt32 aPort
,
1497 const char *aScheme
, PRBool
*_retval
)
1499 TRACE("(%ld %s %p)\n", aPort
, debugstr_a(aScheme
), _retval
);
1500 return nsIIOService_AllowPort(nsio
, aPort
, debugstr_a(aScheme
), _retval
);
1503 static nsresult NSAPI
nsIOService_ExtractScheme(nsIIOService
*iface
, const nsACString
*urlString
,
1504 nsACString
* _retval
)
1506 TRACE("(%p %p)\n", urlString
, _retval
);
1507 return nsIIOService_ExtractScheme(nsio
, urlString
, _retval
);
1510 static const nsIIOServiceVtbl nsIOServiceVtbl
= {
1511 nsIOService_QueryInterface
,
1513 nsIOService_Release
,
1514 nsIOService_GetProtocolHandler
,
1515 nsIOService_GetProtocolFlags
,
1517 nsIOService_NewFileURI
,
1518 nsIOService_NewChannelFromURI
,
1519 nsIOService_NewChannel
,
1520 nsIOService_GetOffline
,
1521 nsIOService_SetOffline
,
1522 nsIOService_AllowPort
,
1523 nsIOService_ExtractScheme
1526 static nsIIOService nsIOService
= { &nsIOServiceVtbl
};
1528 static nsresult NSAPI
nsIOServiceFactory_QueryInterface(nsIFactory
*iface
, nsIIDRef riid
,
1533 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
1534 TRACE("(IID_nsISupoprts %p)\n", result
);
1536 }else if(IsEqualGUID(&IID_nsIFactory
, riid
)) {
1537 TRACE("(IID_nsIFactory %p)\n", result
);
1542 nsIFactory_AddRef(iface
);
1546 WARN("(%s %p)\n", debugstr_guid(riid
), result
);
1547 return NS_NOINTERFACE
;
1550 static nsrefcnt NSAPI
nsIOServiceFactory_AddRef(nsIFactory
*iface
)
1555 static nsrefcnt NSAPI
nsIOServiceFactory_Release(nsIFactory
*iface
)
1560 static nsresult NSAPI
nsIOServiceFactory_CreateInstance(nsIFactory
*iface
,
1561 nsISupports
*aOuter
, const nsIID
*iid
, void **result
)
1563 return nsIIOService_QueryInterface(&nsIOService
, iid
, result
);
1566 static nsresult NSAPI
nsIOServiceFactory_LockFactory(nsIFactory
*iface
, PRBool lock
)
1568 WARN("(%x)\n", lock
);
1572 static const nsIFactoryVtbl nsIOServiceFactoryVtbl
= {
1573 nsIOServiceFactory_QueryInterface
,
1574 nsIOServiceFactory_AddRef
,
1575 nsIOServiceFactory_Release
,
1576 nsIOServiceFactory_CreateInstance
,
1577 nsIOServiceFactory_LockFactory
1580 static nsIFactory nsIOServiceFactory
= { &nsIOServiceFactoryVtbl
};
1582 void init_nsio(nsIComponentManager
*component_manager
, nsIComponentRegistrar
*registrar
)
1584 nsIFactory
*old_factory
= NULL
;
1587 nsres
= nsIComponentManager_GetClassObject(component_manager
, &NS_IOSERVICE_CID
,
1588 &IID_nsIFactory
, (void**)&old_factory
);
1589 if(NS_FAILED(nsres
)) {
1590 ERR("Could not get factory: %08lx\n", nsres
);
1591 nsIFactory_Release(old_factory
);
1595 nsres
= nsIFactory_CreateInstance(old_factory
, NULL
, &IID_nsIIOService
, (void**)&nsio
);
1596 if(NS_FAILED(nsres
)) {
1597 ERR("Couldn not create nsIOService instance %08lx\n", nsres
);
1598 nsIFactory_Release(old_factory
);
1602 nsres
= nsIComponentRegistrar_UnregisterFactory(registrar
, &NS_IOSERVICE_CID
, old_factory
);
1603 nsIFactory_Release(old_factory
);
1604 if(NS_FAILED(nsres
))
1605 ERR("UnregisterFactory failed: %08lx\n", nsres
);
1607 nsres
= nsIComponentRegistrar_RegisterFactory(registrar
, &NS_IOSERVICE_CID
,
1608 NS_IOSERVICE_CLASSNAME
, NS_IOSERVICE_CONTRACTID
, &nsIOServiceFactory
);
1609 if(NS_FAILED(nsres
))
1610 ERR("RegisterFactory failed: %08lx\n", nsres
);
1613 nsIURI
*get_nsIURI(LPCWSTR url
)
1621 len
= WideCharToMultiByte(CP_ACP
, 0, url
, -1, NULL
, -1, NULL
, NULL
);
1622 urla
= HeapAlloc(GetProcessHeap(), 0, len
);
1623 WideCharToMultiByte(CP_ACP
, 0, url
, -1, urla
, -1, NULL
, NULL
);
1625 nsACString_Init(&acstr
, urla
);
1627 nsres
= nsIIOService_NewURI(nsio
, &acstr
, NULL
, NULL
, &ret
);
1628 if(NS_FAILED(nsres
))
1629 FIXME("NewURI failed: %08lx\n", nsres
);
1631 nsACString_Finish(&acstr
);
1632 HeapFree(GetProcessHeap(), 0, urla
);