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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 IID NS_IOSERVICE_CID =
44 {0x9ac9e770, 0x18bc, 0x11d3, {0x93, 0x37, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40}};
46 static nsIIOService *nsio = NULL;
49 const nsIHttpChannelVtbl *lpHttpChannelVtbl;
50 const nsIUploadChannelVtbl *lpUploadChannelVtbl;
55 nsIHttpChannel *http_channel;
57 nsIInputStream *post_data_stream;
61 const nsIWineURIVtbl *lpWineURIVtbl;
66 NSContainer *container;
69 #define NSCHANNEL(x) ((nsIChannel*) &(x)->lpHttpChannelVtbl)
70 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*) &(x)->lpHttpChannelVtbl)
71 #define NSUPCHANNEL(x) ((nsIUploadChannel*) &(x)->lpUploadChannelVtbl)
72 #define NSURI(x) ((nsIURI*) &(x)->lpWineURIVtbl)
74 static BOOL exec_shldocvw_67(NSContainer *container, LPCWSTR url)
76 IOleCommandTarget *cmdtrg = NULL;
79 hres = IOleClientSite_QueryInterface(container->doc->client, &IID_IOleCommandTarget,
82 VARIANT varUrl, varRes;
84 V_VT(&varUrl) = VT_BSTR;
85 V_BSTR(&varUrl) = SysAllocString(url);
86 V_VT(&varRes) = VT_BOOL;
88 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 67, 0, &varUrl, &varRes);
90 IOleCommandTarget_Release(cmdtrg);
91 SysFreeString(V_BSTR(&varUrl));
93 if(SUCCEEDED(hres) && !V_BOOL(&varRes)) {
94 TRACE("got VARIANT_FALSE, do not load\n");
102 static BOOL handle_uri(NSContainer *container, nsChannel *channel, LPCWSTR uri)
104 IServiceProvider *service_provider;
107 if(!exec_shldocvw_67(container, uri))
110 hres = IOleClientSite_QueryInterface(container->doc->client, &IID_IServiceProvider,
111 (void**)&service_provider);
112 if(SUCCEEDED(hres)) {
113 IHlinkFrame *hlink_frame;
115 hres = IServiceProvider_QueryService(service_provider, &IID_IHlinkFrame,
116 &IID_IHlinkFrame, (void**)&hlink_frame);
117 if(SUCCEEDED(hres)) {
118 hlink_frame_navigate(container, hlink_frame, uri, channel->post_data_stream);
119 IHlinkFrame_Release(hlink_frame);
124 IServiceProvider_Release(service_provider);
130 static BOOL before_async_open(nsChannel *This)
133 NSContainer *container;
134 PRUint32 load_flags = 0;
140 nsIChannel_GetLoadFlags(This->channel, &load_flags);
141 TRACE("load_flags = %08lx\n", load_flags);
142 if(!(load_flags & LOAD_INITIAL_DOCUMENT_URI))
145 nsIWineURI_GetNSContainer(This->uri, &container);
147 WARN("container = NULL\n");
151 if(container->load_call) {
152 nsIWebBrowserChrome_Release(NSWBCHROME(container));
156 uri_str = nsACString_Create();
157 nsIWineURI_GetSpec(This->uri, uri_str);
158 nsACString_GetData(uri_str, &uria, NULL);
159 len = MultiByteToWideChar(CP_ACP, 0, uria, -1, NULL, 0);
160 uri = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
161 MultiByteToWideChar(CP_ACP, 0, uria, -1, uri, len);
162 nsACString_Destroy(uri_str);
164 ret = handle_uri(container, This, uri);
166 nsIWebBrowserChrome_Release(NSWBCHROME(container));
167 HeapFree(GetProcessHeap(), 0, uri);
172 #define NSCHANNEL_THIS(iface) DEFINE_THIS(nsChannel, HttpChannel, iface)
174 static nsresult NSAPI nsChannel_QueryInterface(nsIHttpChannel *iface, nsIIDRef riid, nsQIResult result)
176 nsChannel *This = NSCHANNEL_THIS(iface);
180 if(IsEqualGUID(&IID_nsISupports, riid)) {
181 TRACE("(%p)->(IID_nsISupports %p)\n", This, result);
182 *result = NSCHANNEL(This);
183 }else if(IsEqualGUID(&IID_nsIRequest, riid)) {
184 TRACE("(%p)->(IID_nsIRequest %p)\n", This, result);
185 *result = NSCHANNEL(This);
186 }else if(IsEqualGUID(&IID_nsIChannel, riid)) {
187 TRACE("(%p)->(IID_nsIChannel %p)\n", This, result);
188 *result = NSCHANNEL(This);
189 }else if(This->http_channel && IsEqualGUID(&IID_nsIHttpChannel, riid)) {
190 TRACE("(%p)->(IID_nsIHttpChannel %p)\n", This, result);
191 *result = NSHTTPCHANNEL(This);
192 }else if(IsEqualGUID(&IID_nsIUploadChannel, riid)) {
193 TRACE("(%p)->(IID_nsIUploadChannel %p)\n", This, result);
194 *result = NSUPCHANNEL(This);
198 nsIChannel_AddRef(NSCHANNEL(This));
202 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), result);
203 return nsIChannel_QueryInterface(This->channel, riid, result);
206 static nsrefcnt NSAPI nsChannel_AddRef(nsIHttpChannel *iface)
208 nsChannel *This = NSCHANNEL_THIS(iface);
209 nsrefcnt ref = InterlockedIncrement(&This->ref);
211 TRACE("(%p) ref=%ld\n", This, ref);
216 static nsrefcnt NSAPI nsChannel_Release(nsIHttpChannel *iface)
218 nsChannel *This = NSCHANNEL_THIS(iface);
219 LONG ref = InterlockedDecrement(&This->ref);
222 nsIChannel_Release(This->channel);
223 nsIWineURI_Release(This->uri);
224 if(This->http_channel)
225 nsIHttpChannel_Release(This->http_channel);
226 if(This->post_data_stream)
227 nsIInputStream_Release(This->post_data_stream);
228 HeapFree(GetProcessHeap(), 0, This);
234 static nsresult NSAPI nsChannel_GetName(nsIHttpChannel *iface, nsACString *aName)
236 nsChannel *This = NSCHANNEL_THIS(iface);
237 TRACE("(%p)->(%p)\n", This, aName);
238 return nsIChannel_GetName(This->channel, aName);
241 static nsresult NSAPI nsChannel_IsPending(nsIHttpChannel *iface, PRBool *_retval)
243 nsChannel *This = NSCHANNEL_THIS(iface);
244 TRACE("(%p)->(%p)\n", This, _retval);
245 return nsIChannel_IsPending(This->channel, _retval);
248 static nsresult NSAPI nsChannel_GetStatus(nsIHttpChannel *iface, nsresult *aStatus)
250 nsChannel *This = NSCHANNEL_THIS(iface);
251 TRACE("(%p)->(%p)\n", This, aStatus);
252 return nsIChannel_GetStatus(This->channel, aStatus);
255 static nsresult NSAPI nsChannel_Cancel(nsIHttpChannel *iface, nsresult aStatus)
257 nsChannel *This = NSCHANNEL_THIS(iface);
258 TRACE("(%p)->(%08lx)\n", This, aStatus);
259 return nsIChannel_Cancel(This->channel, aStatus);
262 static nsresult NSAPI nsChannel_Suspend(nsIHttpChannel *iface)
264 nsChannel *This = NSCHANNEL_THIS(iface);
265 TRACE("(%p)\n", This);
266 return nsIChannel_Suspend(This->channel);
269 static nsresult NSAPI nsChannel_Resume(nsIHttpChannel *iface)
271 nsChannel *This = NSCHANNEL_THIS(iface);
272 TRACE("(%p)\n", This);
273 return nsIChannel_Resume(This->channel);
276 static nsresult NSAPI nsChannel_GetLoadGroup(nsIHttpChannel *iface, nsILoadGroup **aLoadGroup)
278 nsChannel *This = NSCHANNEL_THIS(iface);
279 TRACE("(%p)->(%p)\n", This, aLoadGroup);
280 return nsIChannel_GetLoadGroup(This->channel, aLoadGroup);
283 static nsresult NSAPI nsChannel_SetLoadGroup(nsIHttpChannel *iface, nsILoadGroup *aLoadGroup)
285 nsChannel *This = NSCHANNEL_THIS(iface);
286 TRACE("(%p)->(%p)\n", This, aLoadGroup);
287 return nsIChannel_SetLoadGroup(This->channel, aLoadGroup);
290 static nsresult NSAPI nsChannel_GetLoadFlags(nsIHttpChannel *iface, nsLoadFlags *aLoadFlags)
292 nsChannel *This = NSCHANNEL_THIS(iface);
293 TRACE("(%p)->(%p)\n", This, aLoadFlags);
294 return nsIChannel_GetLoadFlags(This->channel, aLoadFlags);
297 static nsresult NSAPI nsChannel_SetLoadFlags(nsIHttpChannel *iface, nsLoadFlags aLoadFlags)
299 nsChannel *This = NSCHANNEL_THIS(iface);
300 TRACE("(%p)->(%08lx)\n", This, aLoadFlags);
301 return nsIChannel_SetLoadFlags(This->channel, aLoadFlags);
304 static nsresult NSAPI nsChannel_GetOriginalURI(nsIHttpChannel *iface, nsIURI **aOriginalURI)
306 nsChannel *This = NSCHANNEL_THIS(iface);
307 TRACE("(%p)->(%p)\n", This, aOriginalURI);
308 return nsIChannel_GetOriginalURI(This->channel, aOriginalURI);
311 static nsresult NSAPI nsChannel_SetOriginalURI(nsIHttpChannel *iface, nsIURI *aOriginalURI)
313 nsChannel *This = NSCHANNEL_THIS(iface);
314 TRACE("(%p)->(%p)\n", This, aOriginalURI);
315 return nsIChannel_SetOriginalURI(This->channel, aOriginalURI);
318 static nsresult NSAPI nsChannel_GetURI(nsIHttpChannel *iface, nsIURI **aURI)
320 nsChannel *This = NSCHANNEL_THIS(iface);
322 TRACE("(%p)->(%p)\n", This, aURI);
324 nsIWineURI_AddRef(This->uri);
325 *aURI = (nsIURI*)This->uri;
330 static nsresult NSAPI nsChannel_GetOwner(nsIHttpChannel *iface, nsISupports **aOwner)
332 nsChannel *This = NSCHANNEL_THIS(iface);
333 TRACE("(%p)->(%p)\n", This, aOwner);
334 return nsIChannel_GetOwner(This->channel, aOwner);
337 static nsresult NSAPI nsChannel_SetOwner(nsIHttpChannel *iface, nsISupports *aOwner)
339 nsChannel *This = NSCHANNEL_THIS(iface);
340 TRACE("(%p)->(%p)\n", This, aOwner);
341 return nsIChannel_SetOwner(This->channel, aOwner);
344 static nsresult NSAPI nsChannel_GetNotificationCallbacks(nsIHttpChannel *iface,
345 nsIInterfaceRequestor **aNotificationCallbacks)
347 nsChannel *This = NSCHANNEL_THIS(iface);
348 TRACE("(%p)->(%p)\n", This, aNotificationCallbacks);
349 return nsIChannel_GetNotificationCallbacks(This->channel, aNotificationCallbacks);
352 static nsresult NSAPI nsChannel_SetNotificationCallbacks(nsIHttpChannel *iface,
353 nsIInterfaceRequestor *aNotificationCallbacks)
355 nsChannel *This = NSCHANNEL_THIS(iface);
356 TRACE("(%p)->(%p)\n", This, aNotificationCallbacks);
357 return nsIChannel_SetNotificationCallbacks(This->channel, aNotificationCallbacks);
360 static nsresult NSAPI nsChannel_GetSecurityInfo(nsIHttpChannel *iface, nsISupports **aSecurityInfo)
362 nsChannel *This = NSCHANNEL_THIS(iface);
363 TRACE("(%p)->(%p)\n", This, aSecurityInfo);
364 return nsIChannel_GetSecurityInfo(This->channel, aSecurityInfo);
367 static nsresult NSAPI nsChannel_GetContentType(nsIHttpChannel *iface, nsACString *aContentType)
369 nsChannel *This = NSCHANNEL_THIS(iface);
370 TRACE("(%p)->(%p)\n", This, aContentType);
371 return nsIChannel_GetContentType(This->channel, aContentType);
374 static nsresult NSAPI nsChannel_SetContentType(nsIHttpChannel *iface,
375 const nsACString *aContentType)
377 nsChannel *This = NSCHANNEL_THIS(iface);
378 TRACE("(%p)->(%p)\n", This, aContentType);
379 return nsIChannel_SetContentType(This->channel, aContentType);
382 static nsresult NSAPI nsChannel_GetContentCharset(nsIHttpChannel *iface,
383 nsACString *aContentCharset)
385 nsChannel *This = NSCHANNEL_THIS(iface);
386 TRACE("(%p)->(%p)\n", This, aContentCharset);
387 return nsIChannel_GetContentCharset(This->channel, aContentCharset);
390 static nsresult NSAPI nsChannel_SetContentCharset(nsIHttpChannel *iface,
391 const nsACString *aContentCharset)
393 nsChannel *This = NSCHANNEL_THIS(iface);
394 TRACE("(%p)->(%p)\n", This, aContentCharset);
395 return nsIChannel_SetContentCharset(This->channel, aContentCharset);
398 static nsresult NSAPI nsChannel_GetContentLength(nsIHttpChannel *iface, PRInt32 *aContentLength)
400 nsChannel *This = NSCHANNEL_THIS(iface);
401 TRACE("(%p)->(%p)\n", This, aContentLength);
402 return nsIChannel_GetContentLength(This->channel, aContentLength);
405 static nsresult NSAPI nsChannel_SetContentLength(nsIHttpChannel *iface, PRInt32 aContentLength)
407 nsChannel *This = NSCHANNEL_THIS(iface);
408 TRACE("(%p)->(%ld)\n", This, aContentLength);
409 return nsIChannel_SetContentLength(This->channel, aContentLength);
412 static nsresult NSAPI nsChannel_Open(nsIHttpChannel *iface, nsIInputStream **_retval)
414 nsChannel *This = NSCHANNEL_THIS(iface);
415 TRACE("(%p)->(%p)\n", This, _retval);
416 return nsIChannel_Open(This->channel, _retval);
419 static nsresult NSAPI nsChannel_AsyncOpen(nsIHttpChannel *iface, nsIStreamListener *aListener,
420 nsISupports *aContext)
422 nsChannel *This = NSCHANNEL_THIS(iface);
425 TRACE("(%p)->(%p %p)\n", This, aListener, aContext);
427 if(!before_async_open(This)) {
429 return NS_ERROR_UNEXPECTED;
432 if(This->post_data_stream) {
433 nsIUploadChannel *upload_channel;
435 nsres = nsIChannel_QueryInterface(This->channel, &IID_nsIUploadChannel,
436 (void**)&upload_channel);
437 if(NS_SUCCEEDED(nsres)) {
438 nsACString *empty_string = nsACString_Create();
439 nsACString_SetData(empty_string, "");
441 nsres = nsIUploadChannel_SetUploadStream(upload_channel, This->post_data_stream,
444 WARN("SetUploadStream failed: %08lx\n", nsres);
448 return nsIChannel_AsyncOpen(This->channel, aListener, aContext);
451 static nsresult NSAPI nsChannel_GetRequestMethod(nsIHttpChannel *iface, nsACString *aRequestMethod)
453 nsChannel *This = NSCHANNEL_THIS(iface);
455 TRACE("(%p)->(%p)\n", This, aRequestMethod);
457 if(This->http_channel)
458 return nsIHttpChannel_GetRequestMethod(This->http_channel, aRequestMethod);
460 return NS_ERROR_NOT_IMPLEMENTED;
463 static nsresult NSAPI nsChannel_SetRequestMethod(nsIHttpChannel *iface,
464 const nsACString *aRequestMethod)
466 nsChannel *This = NSCHANNEL_THIS(iface);
468 TRACE("(%p)->(%p)\n", This, aRequestMethod);
470 if(This->http_channel)
471 return nsIHttpChannel_SetRequestMethod(This->http_channel, aRequestMethod);
473 return NS_ERROR_NOT_IMPLEMENTED;
476 static nsresult NSAPI nsChannel_GetReferrer(nsIHttpChannel *iface, nsIURI **aReferrer)
478 nsChannel *This = NSCHANNEL_THIS(iface);
480 TRACE("(%p)->(%p)\n", This, aReferrer);
482 if(This->http_channel)
483 return nsIHttpChannel_GetReferrer(This->http_channel, aReferrer);
485 return NS_ERROR_NOT_IMPLEMENTED;
488 static nsresult NSAPI nsChannel_SetReferrer(nsIHttpChannel *iface, nsIURI *aReferrer)
490 nsChannel *This = NSCHANNEL_THIS(iface);
492 TRACE("(%p)->(%p)\n", This, aReferrer);
494 if(This->http_channel)
495 return nsIHttpChannel_SetReferrer(This->http_channel, aReferrer);
497 return NS_ERROR_NOT_IMPLEMENTED;
500 static nsresult NSAPI nsChannel_GetRequestHeader(nsIHttpChannel *iface,
501 const nsACString *aHeader, nsACString *_retval)
503 nsChannel *This = NSCHANNEL_THIS(iface);
505 TRACE("(%p)->(%p %p)\n", This, aHeader, _retval);
507 if(This->http_channel)
508 return nsIHttpChannel_GetRequestHeader(This->http_channel, aHeader, _retval);
510 return NS_ERROR_NOT_IMPLEMENTED;
513 static nsresult NSAPI nsChannel_SetRequestHeader(nsIHttpChannel *iface,
514 const nsACString *aHeader, const nsACString *aValue, PRBool aMerge)
516 nsChannel *This = NSCHANNEL_THIS(iface);
518 TRACE("(%p)->(%p %p %x)\n", This, aHeader, aValue, aMerge);
520 if(This->http_channel)
521 return nsIHttpChannel_SetRequestHeader(This->http_channel, aHeader, aValue, aMerge);
523 return NS_ERROR_NOT_IMPLEMENTED;
526 static nsresult NSAPI nsChannel_VisitRequestHeaders(nsIHttpChannel *iface,
527 nsIHttpHeaderVisitor *aVisitor)
529 nsChannel *This = NSCHANNEL_THIS(iface);
531 TRACE("(%p)->(%p)\n", This, aVisitor);
533 if(This->http_channel)
534 return nsIHttpChannel_VisitRequestHeaders(This->http_channel, aVisitor);
536 return NS_ERROR_NOT_IMPLEMENTED;
539 static nsresult NSAPI nsChannel_GetAllowPipelining(nsIHttpChannel *iface, PRBool *aAllowPipelining)
541 nsChannel *This = NSCHANNEL_THIS(iface);
543 TRACE("(%p)->(%p)\n", This, aAllowPipelining);
545 if(This->http_channel)
546 return nsIHttpChannel_GetAllowPipelining(This->http_channel, aAllowPipelining);
548 return NS_ERROR_NOT_IMPLEMENTED;
551 static nsresult NSAPI nsChannel_SetAllowPipelining(nsIHttpChannel *iface, PRBool aAllowPipelining)
553 nsChannel *This = NSCHANNEL_THIS(iface);
555 TRACE("(%p)->(%x)\n", This, aAllowPipelining);
557 if(This->http_channel)
558 return nsIHttpChannel_SetAllowPipelining(This->http_channel, aAllowPipelining);
560 return NS_ERROR_NOT_IMPLEMENTED;
563 static nsresult NSAPI nsChannel_GetRedirectionLimit(nsIHttpChannel *iface, PRUint32 *aRedirectionLimit)
565 nsChannel *This = NSCHANNEL_THIS(iface);
567 TRACE("(%p)->(%p)\n", This, aRedirectionLimit);
569 if(This->http_channel)
570 return nsIHttpChannel_GetRedirectionLimit(This->http_channel, aRedirectionLimit);
572 return NS_ERROR_NOT_IMPLEMENTED;
575 static nsresult NSAPI nsChannel_SetRedirectionLimit(nsIHttpChannel *iface, PRUint32 aRedirectionLimit)
577 nsChannel *This = NSCHANNEL_THIS(iface);
579 TRACE("(%p)->(%lu)\n", This, aRedirectionLimit);
581 if(This->http_channel)
582 return nsIHttpChannel_SetRedirectionLimit(This->http_channel, aRedirectionLimit);
584 return NS_ERROR_NOT_IMPLEMENTED;
587 static nsresult NSAPI nsChannel_GetResponseStatus(nsIHttpChannel *iface, PRUint32 *aResponseStatus)
589 nsChannel *This = NSCHANNEL_THIS(iface);
591 TRACE("(%p)->(%p)\n", This, aResponseStatus);
593 if(This->http_channel)
594 return nsIHttpChannel_GetResponseStatus(This->http_channel, aResponseStatus);
596 return NS_ERROR_NOT_IMPLEMENTED;
599 static nsresult NSAPI nsChannel_GetResponseStatusText(nsIHttpChannel *iface,
600 nsACString *aResponseStatusText)
602 nsChannel *This = NSCHANNEL_THIS(iface);
604 TRACE("(%p)->(%p)\n", This, aResponseStatusText);
606 if(This->http_channel)
607 return nsIHttpChannel_GetResponseStatusText(This->http_channel, aResponseStatusText);
609 return NS_ERROR_NOT_IMPLEMENTED;
612 static nsresult NSAPI nsChannel_GetRequestSucceeded(nsIHttpChannel *iface,
613 PRBool *aRequestSucceeded)
615 nsChannel *This = NSCHANNEL_THIS(iface);
617 TRACE("(%p)->(%p)\n", This, aRequestSucceeded);
619 if(This->http_channel)
620 return nsIHttpChannel_GetRequestSucceeded(This->http_channel, aRequestSucceeded);
622 return NS_ERROR_NOT_IMPLEMENTED;
625 static nsresult NSAPI nsChannel_GetResponseHeader(nsIHttpChannel *iface,
626 const nsACString *header, nsACString *_retval)
628 nsChannel *This = NSCHANNEL_THIS(iface);
630 TRACE("(%p)->(%p %p)\n", This, header, _retval);
632 if(This->http_channel)
633 return nsIHttpChannel_GetResponseHeader(This->http_channel, header, _retval);
635 return NS_ERROR_NOT_IMPLEMENTED;
638 static nsresult NSAPI nsChannel_SetResponseHeader(nsIHttpChannel *iface,
639 const nsACString *header, const nsACString *value, PRBool merge)
641 nsChannel *This = NSCHANNEL_THIS(iface);
643 TRACE("(%p)->(%p %p %x)\n", This, header, value, merge);
645 if(This->http_channel)
646 return nsIHttpChannel_SetResponseHeader(This->http_channel, header, value, merge);
648 return NS_ERROR_NOT_IMPLEMENTED;
651 static nsresult NSAPI nsChannel_VisitResponseHeaders(nsIHttpChannel *iface,
652 nsIHttpHeaderVisitor *aVisitor)
654 nsChannel *This = NSCHANNEL_THIS(iface);
656 TRACE("(%p)->(%p)\n", This, aVisitor);
658 if(This->http_channel)
659 return nsIHttpChannel_VisitResponseHeaders(This->http_channel, aVisitor);
661 return NS_ERROR_NOT_IMPLEMENTED;
664 static nsresult NSAPI nsChannel_IsNoStoreResponse(nsIHttpChannel *iface, PRBool *_retval)
666 nsChannel *This = NSCHANNEL_THIS(iface);
668 TRACE("(%p)->(%p)\n", This, _retval);
670 if(This->http_channel)
671 return nsIHttpChannel_IsNoStoreResponse(This->http_channel, _retval);
673 return NS_ERROR_NOT_IMPLEMENTED;
676 static nsresult NSAPI nsChannel_IsNoCacheResponse(nsIHttpChannel *iface, PRBool *_retval)
678 nsChannel *This = NSCHANNEL_THIS(iface);
680 TRACE("(%p)->(%p)\n", This, _retval);
682 if(This->http_channel)
683 return nsIHttpChannel_IsNoCacheResponse(This->http_channel, _retval);
685 return NS_ERROR_NOT_IMPLEMENTED;
688 #undef NSCHANNEL_THIS
690 static const nsIHttpChannelVtbl nsChannelVtbl = {
691 nsChannel_QueryInterface,
700 nsChannel_GetLoadGroup,
701 nsChannel_SetLoadGroup,
702 nsChannel_GetLoadFlags,
703 nsChannel_SetLoadFlags,
704 nsChannel_GetOriginalURI,
705 nsChannel_SetOriginalURI,
709 nsChannel_GetNotificationCallbacks,
710 nsChannel_SetNotificationCallbacks,
711 nsChannel_GetSecurityInfo,
712 nsChannel_GetContentType,
713 nsChannel_SetContentType,
714 nsChannel_GetContentCharset,
715 nsChannel_SetContentCharset,
716 nsChannel_GetContentLength,
717 nsChannel_SetContentLength,
720 nsChannel_GetRequestMethod,
721 nsChannel_SetRequestMethod,
722 nsChannel_GetReferrer,
723 nsChannel_SetReferrer,
724 nsChannel_GetRequestHeader,
725 nsChannel_SetRequestHeader,
726 nsChannel_VisitRequestHeaders,
727 nsChannel_GetAllowPipelining,
728 nsChannel_SetAllowPipelining,
729 nsChannel_GetRedirectionLimit,
730 nsChannel_SetRedirectionLimit,
731 nsChannel_GetResponseStatus,
732 nsChannel_GetResponseStatusText,
733 nsChannel_GetRequestSucceeded,
734 nsChannel_GetResponseHeader,
735 nsChannel_SetResponseHeader,
736 nsChannel_VisitResponseHeaders,
737 nsChannel_IsNoStoreResponse,
738 nsChannel_IsNoCacheResponse
741 #define NSUPCHANNEL_THIS(iface) DEFINE_THIS(nsChannel, UploadChannel, iface)
743 static nsresult NSAPI nsUploadChannel_QueryInterface(nsIUploadChannel *iface, nsIIDRef riid,
746 nsChannel *This = NSUPCHANNEL_THIS(iface);
747 return nsIChannel_QueryInterface(NSCHANNEL(This), riid, result);
750 static nsrefcnt NSAPI nsUploadChannel_AddRef(nsIUploadChannel *iface)
752 nsChannel *This = NSUPCHANNEL_THIS(iface);
753 return nsIChannel_AddRef(NSCHANNEL(This));
756 static nsrefcnt NSAPI nsUploadChannel_Release(nsIUploadChannel *iface)
758 nsChannel *This = NSUPCHANNEL_THIS(iface);
759 return nsIChannel_Release(NSCHANNEL(This));
762 static nsresult NSAPI nsUploadChannel_SetUploadStream(nsIUploadChannel *iface,
763 nsIInputStream *aStream, const nsACString *aContentType, PRInt32 aContentLength)
765 nsChannel *This = NSUPCHANNEL_THIS(iface);
766 const char *content_type;
768 TRACE("(%p)->(%p %p %ld)\n", This, aStream, aContentType, aContentLength);
770 if(This->post_data_stream)
771 nsIInputStream_Release(This->post_data_stream);
774 nsACString_GetData(aContentType, &content_type, NULL);
776 FIXME("Unsupported aContentType argument: %s\n", debugstr_a(content_type));
779 if(aContentLength != -1)
780 FIXME("Unsupported acontentLength = %ld\n", aContentLength);
783 nsIInputStream_AddRef(aStream);
784 This->post_data_stream = aStream;
789 static nsresult NSAPI nsUploadChannel_GetUploadStream(nsIUploadChannel *iface,
790 nsIInputStream **aUploadStream)
792 nsChannel *This = NSUPCHANNEL_THIS(iface);
794 TRACE("(%p)->(%p)\n", This, aUploadStream);
796 if(This->post_data_stream)
797 nsIInputStream_AddRef(This->post_data_stream);
799 *aUploadStream = This->post_data_stream;
803 #undef NSUPCHANNEL_THIS
805 static const nsIUploadChannelVtbl nsUploadChannelVtbl = {
806 nsUploadChannel_QueryInterface,
807 nsUploadChannel_AddRef,
808 nsUploadChannel_Release,
809 nsUploadChannel_SetUploadStream,
810 nsUploadChannel_GetUploadStream
813 #define NSURI_THIS(iface) DEFINE_THIS(nsURI, WineURI, iface)
815 static nsresult NSAPI nsURI_QueryInterface(nsIWineURI *iface, nsIIDRef riid, nsQIResult result)
817 nsURI *This = NSURI_THIS(iface);
821 if(IsEqualGUID(&IID_nsISupports, riid)) {
822 TRACE("(%p)->(IID_nsISupports %p)\n", This, result);
823 *result = NSURI(This);
824 }else if(IsEqualGUID(&IID_nsIURI, riid)) {
825 TRACE("(%p)->(IID_nsIURI %p)\n", This, result);
826 *result = NSURI(This);
827 }else if(IsEqualGUID(&IID_nsIWineURI, riid)) {
828 TRACE("(%p)->(IID_nsIWineURI %p)\n", This, result);
829 *result = NSURI(This);
833 nsIURI_AddRef(NSURI(This));
837 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), result);
838 return nsIURI_QueryInterface(This->uri, riid, result);
841 static nsrefcnt NSAPI nsURI_AddRef(nsIWineURI *iface)
843 nsURI *This = NSURI_THIS(iface);
844 LONG ref = InterlockedIncrement(&This->ref);
846 TRACE("(%p) ref=%ld\n", This, ref);
851 static nsrefcnt NSAPI nsURI_Release(nsIWineURI *iface)
853 nsURI *This = NSURI_THIS(iface);
854 LONG ref = InterlockedDecrement(&This->ref);
856 TRACE("(%p) ref=%ld\n", This, ref);
860 nsIWebBrowserChrome_Release(NSWBCHROME(This->container));
861 nsIURI_Release(This->uri);
862 HeapFree(GetProcessHeap(), 0, This);
868 static nsresult NSAPI nsURI_GetSpec(nsIWineURI *iface, nsACString *aSpec)
870 nsURI *This = NSURI_THIS(iface);
871 TRACE("(%p)->(%p)\n", This, aSpec);
872 return nsIURI_GetSpec(This->uri, aSpec);
875 static nsresult NSAPI nsURI_SetSpec(nsIWineURI *iface, const nsACString *aSpec)
877 nsURI *This = NSURI_THIS(iface);
878 TRACE("(%p)->(%p)\n", This, aSpec);
879 return nsIURI_SetSpec(This->uri, aSpec);
882 static nsresult NSAPI nsURI_GetPrePath(nsIWineURI *iface, nsACString *aPrePath)
884 nsURI *This = NSURI_THIS(iface);
885 TRACE("(%p)->(%p)\n", This, aPrePath);
886 return nsIURI_GetPrePath(This->uri, aPrePath);
889 static nsresult NSAPI nsURI_GetScheme(nsIWineURI *iface, nsACString *aScheme)
891 nsURI *This = NSURI_THIS(iface);
892 TRACE("(%p)->(%p)\n", This, aScheme);
893 return nsIURI_GetScheme(This->uri, aScheme);
896 static nsresult NSAPI nsURI_SetScheme(nsIWineURI *iface, const nsACString *aScheme)
898 nsURI *This = NSURI_THIS(iface);
899 TRACE("(%p)->(%p)\n", This, aScheme);
900 return nsIURI_SetScheme(This->uri, aScheme);
903 static nsresult NSAPI nsURI_GetUserPass(nsIWineURI *iface, nsACString *aUserPass)
905 nsURI *This = NSURI_THIS(iface);
906 TRACE("(%p)->(%p)\n", This, aUserPass);
907 return nsIURI_GetUserPass(This->uri, aUserPass);
910 static nsresult NSAPI nsURI_SetUserPass(nsIWineURI *iface, const nsACString *aUserPass)
912 nsURI *This = NSURI_THIS(iface);
913 TRACE("(%p)->(%p)\n", This, aUserPass);
914 return nsIURI_SetUserPass(This->uri, aUserPass);
917 static nsresult NSAPI nsURI_GetUsername(nsIWineURI *iface, nsACString *aUsername)
919 nsURI *This = NSURI_THIS(iface);
920 TRACE("(%p)->(%p)\n", This, aUsername);
921 return nsIURI_GetUsername(This->uri, aUsername);
924 static nsresult NSAPI nsURI_SetUsername(nsIWineURI *iface, const nsACString *aUsername)
926 nsURI *This = NSURI_THIS(iface);
927 TRACE("(%p)->(%p)\n", This, aUsername);
928 return nsIURI_SetUsername(This->uri, aUsername);
931 static nsresult NSAPI nsURI_GetPassword(nsIWineURI *iface, nsACString *aPassword)
933 nsURI *This = NSURI_THIS(iface);
934 TRACE("(%p)->(%p)\n", This, aPassword);
935 return nsIURI_GetPassword(This->uri, aPassword);
938 static nsresult NSAPI nsURI_SetPassword(nsIWineURI *iface, const nsACString *aPassword)
940 nsURI *This = NSURI_THIS(iface);
941 TRACE("(%p)->(%p)\n", This, aPassword);
942 return nsIURI_SetPassword(This->uri, aPassword);
945 static nsresult NSAPI nsURI_GetHostPort(nsIWineURI *iface, nsACString *aHostPort)
947 nsURI *This = NSURI_THIS(iface);
948 TRACE("(%p)->(%p)\n", This, aHostPort);
949 return nsIURI_GetHostPort(This->uri, aHostPort);
952 static nsresult NSAPI nsURI_SetHostPort(nsIWineURI *iface, const nsACString *aHostPort)
954 nsURI *This = NSURI_THIS(iface);
955 TRACE("(%p)->(%p)\n", This, aHostPort);
956 return nsIURI_SetHostPort(This->uri, aHostPort);
959 static nsresult NSAPI nsURI_GetHost(nsIWineURI *iface, nsACString *aHost)
961 nsURI *This = NSURI_THIS(iface);
962 TRACE("(%p)->(%p)\n", This, aHost);
963 return nsIURI_GetHost(This->uri, aHost);
966 static nsresult NSAPI nsURI_SetHost(nsIWineURI *iface, const nsACString *aHost)
968 nsURI *This = NSURI_THIS(iface);
969 TRACE("(%p)->(%p)\n", This, aHost);
970 return nsIURI_SetHost(This->uri, aHost);
973 static nsresult NSAPI nsURI_GetPort(nsIWineURI *iface, PRInt32 *aPort)
975 nsURI *This = NSURI_THIS(iface);
976 TRACE("(%p)->(%p)\n", This, aPort);
977 return nsIURI_GetPort(This->uri, aPort);
980 static nsresult NSAPI nsURI_SetPort(nsIWineURI *iface, PRInt32 aPort)
982 nsURI *This = NSURI_THIS(iface);
983 TRACE("(%p)->(%ld)\n", This, aPort);
984 return nsIURI_SetPort(This->uri, aPort);
987 static nsresult NSAPI nsURI_GetPath(nsIWineURI *iface, nsACString *aPath)
989 nsURI *This = NSURI_THIS(iface);
990 TRACE("(%p)->(%p)\n", This, aPath);
991 return nsIURI_GetPath(This->uri, aPath);
994 static nsresult NSAPI nsURI_SetPath(nsIWineURI *iface, const nsACString *aPath)
996 nsURI *This = NSURI_THIS(iface);
997 TRACE("(%p)->(%p)\n", This, aPath);
998 return nsIURI_SetPath(This->uri, aPath);
1001 static nsresult NSAPI nsURI_Equals(nsIWineURI *iface, nsIURI *other, PRBool *_retval)
1003 nsURI *This = NSURI_THIS(iface);
1004 TRACE("(%p)->(%p %p)\n", This, other, _retval);
1005 return nsIURI_Equals(This->uri, other, _retval);
1008 static nsresult NSAPI nsURI_SchemeIs(nsIWineURI *iface, const char *scheme, PRBool *_retval)
1010 nsURI *This = NSURI_THIS(iface);
1011 TRACE("(%p)->(%s %p)\n", This, debugstr_a(scheme), _retval);
1012 return nsIURI_SchemeIs(This->uri, scheme, _retval);
1015 static nsresult NSAPI nsURI_Clone(nsIWineURI *iface, nsIURI **_retval)
1017 nsURI *This = NSURI_THIS(iface);
1018 TRACE("(%p)->(%p)\n", This, _retval);
1019 return nsIURI_Clone(This->uri, _retval);
1022 static nsresult NSAPI nsURI_Resolve(nsIWineURI *iface, const nsACString *arelativePath,
1023 nsACString *_retval)
1025 nsURI *This = NSURI_THIS(iface);
1026 TRACE("(%p)->(%p %p)\n", This, arelativePath, _retval);
1027 return nsIURI_Resolve(This->uri, arelativePath, _retval);
1030 static nsresult NSAPI nsURI_GetAsciiSpec(nsIWineURI *iface, nsACString *aAsciiSpec)
1032 nsURI *This = NSURI_THIS(iface);
1033 TRACE("(%p)->(%p)\n", This, aAsciiSpec);
1034 return nsIURI_GetAsciiSpec(This->uri, aAsciiSpec);
1037 static nsresult NSAPI nsURI_GetAsciiHost(nsIWineURI *iface, nsACString *aAsciiHost)
1039 nsURI *This = NSURI_THIS(iface);
1040 TRACE("(%p)->(%p)\n", This, aAsciiHost);
1041 return nsIURI_GetAsciiHost(This->uri, aAsciiHost);
1044 static nsresult NSAPI nsURI_GetOriginCharset(nsIWineURI *iface, nsACString *aOriginCharset)
1046 nsURI *This = NSURI_THIS(iface);
1047 TRACE("(%p)->(%p)\n", This, aOriginCharset);
1048 return nsIURI_GetOriginCharset(This->uri, aOriginCharset);
1051 static nsresult NSAPI nsURI_GetNSContainer(nsIWineURI *iface, NSContainer **aContainer)
1053 nsURI *This = NSURI_THIS(iface);
1055 TRACE("(%p)->(%p)\n", This, aContainer);
1058 nsIWebBrowserChrome_AddRef(NSWBCHROME(This->container));
1059 *aContainer = This->container;
1064 static nsresult NSAPI nsURI_SetNSContainer(nsIWineURI *iface, NSContainer *aContainer)
1066 nsURI *This = NSURI_THIS(iface);
1068 TRACE("(%p)->(%p)\n", This, aContainer);
1070 if(This->container) {
1071 WARN("Container already set: %p\n", This->container);
1072 nsIWebBrowserChrome_Release(NSWBCHROME(This->container));
1076 nsIWebBrowserChrome_AddRef(NSWBCHROME(aContainer));
1077 This->container = aContainer;
1084 static const nsIWineURIVtbl nsWineURIVtbl = {
1085 nsURI_QueryInterface,
1113 nsURI_GetOriginCharset,
1114 nsURI_GetNSContainer,
1115 nsURI_SetNSContainer,
1118 static nsresult NSAPI nsIOService_QueryInterface(nsIIOService *iface, nsIIDRef riid,
1123 if(IsEqualGUID(&IID_nsISupports, riid)) {
1124 TRACE("(IID_nsISupports %p)\n", result);
1126 }else if(IsEqualGUID(&IID_nsIIOService, riid)) {
1127 TRACE("(IID_nsIIOService %p)\n", result);
1132 nsIIOService_AddRef(iface);
1136 WARN("(%s %p)\n", debugstr_guid(riid), result);
1137 return NS_NOINTERFACE;
1140 static nsrefcnt NSAPI nsIOService_AddRef(nsIIOService *iface)
1145 static nsrefcnt NSAPI nsIOService_Release(nsIIOService *iface)
1150 static nsresult NSAPI nsIOService_GetProtocolHandler(nsIIOService *iface, const char *aScheme,
1151 nsIProtocolHandler **_retval)
1153 TRACE("(%s %p)\n", debugstr_a(aScheme), _retval);
1154 return nsIIOService_GetProtocolHandler(nsio, aScheme, _retval);
1157 static nsresult NSAPI nsIOService_GetProtocolFlags(nsIIOService *iface, const char *aScheme,
1160 TRACE("(%s %p)\n", debugstr_a(aScheme), _retval);
1161 return nsIIOService_GetProtocolFlags(nsio, aScheme, _retval);
1164 static nsresult NSAPI nsIOService_NewURI(nsIIOService *iface, const nsACString *aSpec,
1165 const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval)
1167 const char *spec = NULL;
1170 PRBool is_javascript = FALSE;
1173 nsACString_GetData(aSpec, &spec, NULL);
1175 TRACE("(%p(%s) %s %p %p)\n", aSpec, debugstr_a(spec), debugstr_a(aOriginCharset),
1179 nsACString *base_uri_str = nsACString_Create();
1180 const char *base_uri = NULL;
1182 nsres = nsIURI_GetSpec(aBaseURI, base_uri_str);
1183 if(NS_SUCCEEDED(nsres)) {
1184 nsACString_GetData(base_uri_str, &base_uri, NULL);
1185 TRACE("uri=%s\n", debugstr_a(base_uri));
1187 ERR("GetSpec failed: %08lx\n", nsres);
1190 nsACString_Destroy(base_uri_str);
1193 nsres = nsIIOService_NewURI(nsio, aSpec, aOriginCharset, aBaseURI, &uri);
1194 if(NS_FAILED(nsres)) {
1195 WARN("NewURI failed: %08lx\n", nsres);
1199 nsIURI_SchemeIs(uri, "javascript", &is_javascript);
1201 TRACE("returning javascript uri: %p\n", uri);
1206 ret = HeapAlloc(GetProcessHeap(), 0, sizeof(nsURI));
1208 ret->lpWineURIVtbl = &nsWineURIVtbl;
1211 ret->container = NULL;
1213 TRACE("_retval = %p\n", ret);
1214 *_retval = NSURI(ret);
1218 static nsresult NSAPI nsIOService_NewFileURI(nsIIOService *iface, nsIFile *aFile,
1221 TRACE("(%p %p)\n", aFile, _retval);
1222 return nsIIOService_NewFileURI(nsio, aFile, _retval);
1225 static nsresult NSAPI nsIOService_NewChannelFromURI(nsIIOService *iface, nsIURI *aURI,
1226 nsIChannel **_retval)
1228 nsIChannel *channel = NULL;
1230 nsIWineURI *wine_uri;
1233 TRACE("(%p %p)\n", aURI, _retval);
1235 nsres = nsIIOService_NewChannelFromURI(nsio, aURI, &channel);
1236 if(NS_FAILED(nsres)) {
1237 WARN("NewChannelFromURI failed: %08lx\n", nsres);
1242 nsres = nsIURI_QueryInterface(aURI, &IID_nsIWineURI, (void**)&wine_uri);
1243 if(NS_FAILED(nsres)) {
1244 WARN("Could not get nsIWineURI: %08lx\n", nsres);
1249 ret = HeapAlloc(GetProcessHeap(), 0, sizeof(nsChannel));
1251 ret->lpHttpChannelVtbl = &nsChannelVtbl;
1252 ret->lpUploadChannelVtbl = &nsUploadChannelVtbl;
1254 ret->channel = channel;
1255 ret->http_channel = NULL;
1256 ret->uri = wine_uri;
1257 ret->post_data_stream = NULL;
1259 nsIChannel_QueryInterface(ret->channel, &IID_nsIHttpChannel, (void**)&ret->http_channel);
1261 *_retval = NSCHANNEL(ret);
1265 static nsresult NSAPI nsIOService_NewChannel(nsIIOService *iface, const nsACString *aSpec,
1266 const char *aOriginCharset, nsIURI *aBaseURI, nsIChannel **_retval)
1268 TRACE("(%p %s %p %p)\n", aSpec, debugstr_a(aOriginCharset), aBaseURI, _retval);
1269 return nsIIOService_NewChannel(nsio, aSpec, aOriginCharset, aBaseURI, _retval);
1272 static nsresult NSAPI nsIOService_GetOffline(nsIIOService *iface, PRBool *aOffline)
1274 TRACE("(%p)\n", aOffline);
1275 return nsIIOService_GetOffline(nsio, aOffline);
1278 static nsresult NSAPI nsIOService_SetOffline(nsIIOService *iface, PRBool aOffline)
1280 TRACE("(%x)\n", aOffline);
1281 return nsIIOService_SetOffline(nsio, aOffline);
1284 static nsresult NSAPI nsIOService_AllowPort(nsIIOService *iface, PRInt32 aPort,
1285 const char *aScheme, PRBool *_retval)
1287 TRACE("(%ld %s %p)\n", aPort, debugstr_a(aScheme), _retval);
1288 return nsIIOService_AllowPort(nsio, aPort, debugstr_a(aScheme), _retval);
1291 static nsresult NSAPI nsIOService_ExtractScheme(nsIIOService *iface, const nsACString *urlString,
1292 nsACString * _retval)
1294 TRACE("(%p %p)\n", urlString, _retval);
1295 return nsIIOService_ExtractScheme(nsio, urlString, _retval);
1298 static const nsIIOServiceVtbl nsIOServiceVtbl = {
1299 nsIOService_QueryInterface,
1301 nsIOService_Release,
1302 nsIOService_GetProtocolHandler,
1303 nsIOService_GetProtocolFlags,
1305 nsIOService_NewFileURI,
1306 nsIOService_NewChannelFromURI,
1307 nsIOService_NewChannel,
1308 nsIOService_GetOffline,
1309 nsIOService_SetOffline,
1310 nsIOService_AllowPort,
1311 nsIOService_ExtractScheme
1314 static nsIIOService nsIOService = { &nsIOServiceVtbl };
1316 static nsresult NSAPI nsIOServiceFactory_QueryInterface(nsIFactory *iface, nsIIDRef riid,
1321 if(IsEqualGUID(&IID_nsISupports, riid)) {
1322 TRACE("(IID_nsISupoprts %p)\n", result);
1324 }else if(IsEqualGUID(&IID_nsIFactory, riid)) {
1325 TRACE("(IID_nsIFactory %p)\n", result);
1330 nsIFactory_AddRef(iface);
1334 WARN("(%s %p)\n", debugstr_guid(riid), result);
1335 return NS_NOINTERFACE;
1338 static nsrefcnt NSAPI nsIOServiceFactory_AddRef(nsIFactory *iface)
1343 static nsrefcnt NSAPI nsIOServiceFactory_Release(nsIFactory *iface)
1348 static nsresult NSAPI nsIOServiceFactory_CreateInstance(nsIFactory *iface,
1349 nsISupports *aOuter, const nsIID *iid, void **result)
1351 return nsIIOService_QueryInterface(&nsIOService, iid, result);
1354 static nsresult NSAPI nsIOServiceFactory_LockFactory(nsIFactory *iface, PRBool lock)
1356 WARN("(%x)\n", lock);
1360 static const nsIFactoryVtbl nsIOServiceFactoryVtbl = {
1361 nsIOServiceFactory_QueryInterface,
1362 nsIOServiceFactory_AddRef,
1363 nsIOServiceFactory_Release,
1364 nsIOServiceFactory_CreateInstance,
1365 nsIOServiceFactory_LockFactory
1368 static nsIFactory nsIOServiceFactory = { &nsIOServiceFactoryVtbl };
1370 void init_nsio(nsIComponentManager *component_manager, nsIComponentRegistrar *registrar)
1372 nsIFactory *old_factory = NULL;
1375 nsres = nsIComponentManager_GetClassObject(component_manager, &NS_IOSERVICE_CID,
1376 &IID_nsIFactory, (void**)&old_factory);
1377 if(NS_FAILED(nsres)) {
1378 ERR("Could not get factory: %08lx\n", nsres);
1379 nsIFactory_Release(old_factory);
1383 nsres = nsIFactory_CreateInstance(old_factory, NULL, &IID_nsIIOService, (void**)&nsio);
1384 if(NS_FAILED(nsres)) {
1385 ERR("Couldn not create nsIOService instance %08lx\n", nsres);
1386 nsIFactory_Release(old_factory);
1390 nsres = nsIComponentRegistrar_UnregisterFactory(registrar, &NS_IOSERVICE_CID, old_factory);
1391 nsIFactory_Release(old_factory);
1392 if(NS_FAILED(nsres))
1393 ERR("UnregisterFactory failed: %08lx\n", nsres);
1395 nsres = nsIComponentRegistrar_RegisterFactory(registrar, &NS_IOSERVICE_CID,
1396 NS_IOSERVICE_CLASSNAME, NS_IOSERVICE_CONTRACTID, &nsIOServiceFactory);
1397 if(NS_FAILED(nsres))
1398 ERR("RegisterFactory failed: %08lx\n", nsres);
1401 nsIURI *get_nsIURI(LPCWSTR url)
1409 len = WideCharToMultiByte(CP_ACP, 0, url, -1, NULL, -1, NULL, NULL);
1410 urla = HeapAlloc(GetProcessHeap(), 0, len);
1411 WideCharToMultiByte(CP_ACP, 0, url, -1, urla, -1, NULL, NULL);
1413 acstr = nsACString_Create();
1414 nsACString_SetData(acstr, urla);
1416 nsres = nsIIOService_NewURI(nsio, acstr, NULL, NULL, &ret);
1417 if(NS_FAILED(nsres))
1418 FIXME("NewURI failed: %08lx\n", nsres);
1420 nsACString_Destroy(acstr);
1421 HeapFree(GetProcessHeap(), 0, urla);