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);
859 nsIURI_Release(This->uri);
860 HeapFree(GetProcessHeap(), 0, This);
866 static nsresult NSAPI nsURI_GetSpec(nsIWineURI *iface, nsACString *aSpec)
868 nsURI *This = NSURI_THIS(iface);
869 TRACE("(%p)->(%p)\n", This, aSpec);
870 return nsIURI_GetSpec(This->uri, aSpec);
873 static nsresult NSAPI nsURI_SetSpec(nsIWineURI *iface, const nsACString *aSpec)
875 nsURI *This = NSURI_THIS(iface);
876 TRACE("(%p)->(%p)\n", This, aSpec);
877 return nsIURI_SetSpec(This->uri, aSpec);
880 static nsresult NSAPI nsURI_GetPrePath(nsIWineURI *iface, nsACString *aPrePath)
882 nsURI *This = NSURI_THIS(iface);
883 TRACE("(%p)->(%p)\n", This, aPrePath);
884 return nsIURI_GetPrePath(This->uri, aPrePath);
887 static nsresult NSAPI nsURI_GetScheme(nsIWineURI *iface, nsACString *aScheme)
889 nsURI *This = NSURI_THIS(iface);
890 TRACE("(%p)->(%p)\n", This, aScheme);
891 return nsIURI_GetScheme(This->uri, aScheme);
894 static nsresult NSAPI nsURI_SetScheme(nsIWineURI *iface, const nsACString *aScheme)
896 nsURI *This = NSURI_THIS(iface);
897 TRACE("(%p)->(%p)\n", This, aScheme);
898 return nsIURI_SetScheme(This->uri, aScheme);
901 static nsresult NSAPI nsURI_GetUserPass(nsIWineURI *iface, nsACString *aUserPass)
903 nsURI *This = NSURI_THIS(iface);
904 TRACE("(%p)->(%p)\n", This, aUserPass);
905 return nsIURI_GetUserPass(This->uri, aUserPass);
908 static nsresult NSAPI nsURI_SetUserPass(nsIWineURI *iface, const nsACString *aUserPass)
910 nsURI *This = NSURI_THIS(iface);
911 TRACE("(%p)->(%p)\n", This, aUserPass);
912 return nsIURI_SetUserPass(This->uri, aUserPass);
915 static nsresult NSAPI nsURI_GetUsername(nsIWineURI *iface, nsACString *aUsername)
917 nsURI *This = NSURI_THIS(iface);
918 TRACE("(%p)->(%p)\n", This, aUsername);
919 return nsIURI_GetUsername(This->uri, aUsername);
922 static nsresult NSAPI nsURI_SetUsername(nsIWineURI *iface, const nsACString *aUsername)
924 nsURI *This = NSURI_THIS(iface);
925 TRACE("(%p)->(%p)\n", This, aUsername);
926 return nsIURI_SetUsername(This->uri, aUsername);
929 static nsresult NSAPI nsURI_GetPassword(nsIWineURI *iface, nsACString *aPassword)
931 nsURI *This = NSURI_THIS(iface);
932 TRACE("(%p)->(%p)\n", This, aPassword);
933 return nsIURI_GetPassword(This->uri, aPassword);
936 static nsresult NSAPI nsURI_SetPassword(nsIWineURI *iface, const nsACString *aPassword)
938 nsURI *This = NSURI_THIS(iface);
939 TRACE("(%p)->(%p)\n", This, aPassword);
940 return nsIURI_SetPassword(This->uri, aPassword);
943 static nsresult NSAPI nsURI_GetHostPort(nsIWineURI *iface, nsACString *aHostPort)
945 nsURI *This = NSURI_THIS(iface);
946 TRACE("(%p)->(%p)\n", This, aHostPort);
947 return nsIURI_GetHostPort(This->uri, aHostPort);
950 static nsresult NSAPI nsURI_SetHostPort(nsIWineURI *iface, const nsACString *aHostPort)
952 nsURI *This = NSURI_THIS(iface);
953 TRACE("(%p)->(%p)\n", This, aHostPort);
954 return nsIURI_SetHostPort(This->uri, aHostPort);
957 static nsresult NSAPI nsURI_GetHost(nsIWineURI *iface, nsACString *aHost)
959 nsURI *This = NSURI_THIS(iface);
960 TRACE("(%p)->(%p)\n", This, aHost);
961 return nsIURI_GetHost(This->uri, aHost);
964 static nsresult NSAPI nsURI_SetHost(nsIWineURI *iface, const nsACString *aHost)
966 nsURI *This = NSURI_THIS(iface);
967 TRACE("(%p)->(%p)\n", This, aHost);
968 return nsIURI_SetHost(This->uri, aHost);
971 static nsresult NSAPI nsURI_GetPort(nsIWineURI *iface, PRInt32 *aPort)
973 nsURI *This = NSURI_THIS(iface);
974 TRACE("(%p)->(%p)\n", This, aPort);
975 return nsIURI_GetPort(This->uri, aPort);
978 static nsresult NSAPI nsURI_SetPort(nsIWineURI *iface, PRInt32 aPort)
980 nsURI *This = NSURI_THIS(iface);
981 TRACE("(%p)->(%ld)\n", This, aPort);
982 return nsIURI_SetPort(This->uri, aPort);
985 static nsresult NSAPI nsURI_GetPath(nsIWineURI *iface, nsACString *aPath)
987 nsURI *This = NSURI_THIS(iface);
988 TRACE("(%p)->(%p)\n", This, aPath);
989 return nsIURI_GetPath(This->uri, aPath);
992 static nsresult NSAPI nsURI_SetPath(nsIWineURI *iface, const nsACString *aPath)
994 nsURI *This = NSURI_THIS(iface);
995 TRACE("(%p)->(%p)\n", This, aPath);
996 return nsIURI_SetPath(This->uri, aPath);
999 static nsresult NSAPI nsURI_Equals(nsIWineURI *iface, nsIURI *other, PRBool *_retval)
1001 nsURI *This = NSURI_THIS(iface);
1002 TRACE("(%p)->(%p %p)\n", This, other, _retval);
1003 return nsIURI_Equals(This->uri, other, _retval);
1006 static nsresult NSAPI nsURI_SchemeIs(nsIWineURI *iface, const char *scheme, PRBool *_retval)
1008 nsURI *This = NSURI_THIS(iface);
1009 TRACE("(%p)->(%s %p)\n", This, debugstr_a(scheme), _retval);
1010 return nsIURI_SchemeIs(This->uri, scheme, _retval);
1013 static nsresult NSAPI nsURI_Clone(nsIWineURI *iface, nsIURI **_retval)
1015 nsURI *This = NSURI_THIS(iface);
1016 TRACE("(%p)->(%p)\n", This, _retval);
1017 return nsIURI_Clone(This->uri, _retval);
1020 static nsresult NSAPI nsURI_Resolve(nsIWineURI *iface, const nsACString *arelativePath,
1021 nsACString *_retval)
1023 nsURI *This = NSURI_THIS(iface);
1024 TRACE("(%p)->(%p %p)\n", This, arelativePath, _retval);
1025 return nsIURI_Resolve(This->uri, arelativePath, _retval);
1028 static nsresult NSAPI nsURI_GetAsciiSpec(nsIWineURI *iface, nsACString *aAsciiSpec)
1030 nsURI *This = NSURI_THIS(iface);
1031 TRACE("(%p)->(%p)\n", This, aAsciiSpec);
1032 return nsIURI_GetAsciiSpec(This->uri, aAsciiSpec);
1035 static nsresult NSAPI nsURI_GetAsciiHost(nsIWineURI *iface, nsACString *aAsciiHost)
1037 nsURI *This = NSURI_THIS(iface);
1038 TRACE("(%p)->(%p)\n", This, aAsciiHost);
1039 return nsIURI_GetAsciiHost(This->uri, aAsciiHost);
1042 static nsresult NSAPI nsURI_GetOriginCharset(nsIWineURI *iface, nsACString *aOriginCharset)
1044 nsURI *This = NSURI_THIS(iface);
1045 TRACE("(%p)->(%p)\n", This, aOriginCharset);
1046 return nsIURI_GetOriginCharset(This->uri, aOriginCharset);
1049 static nsresult NSAPI nsURI_GetNSContainer(nsIWineURI *iface, NSContainer **aContainer)
1051 nsURI *This = NSURI_THIS(iface);
1053 TRACE("(%p)->(%p)\n", This, aContainer);
1056 nsIWebBrowserChrome_AddRef(NSWBCHROME(This->container));
1057 *aContainer = This->container;
1062 static nsresult NSAPI nsURI_SetNSContainer(nsIWineURI *iface, NSContainer *aContainer)
1064 nsURI *This = NSURI_THIS(iface);
1066 TRACE("(%p)->(%p)\n", This, aContainer);
1068 if(This->container) {
1069 WARN("Container already set: %p\n", This->container);
1070 nsIWebBrowserChrome_Release(NSWBCHROME(This->container));
1074 nsIWebBrowserChrome_AddRef(NSWBCHROME(aContainer));
1075 This->container = aContainer;
1082 static const nsIWineURIVtbl nsWineURIVtbl = {
1083 nsURI_QueryInterface,
1111 nsURI_GetOriginCharset,
1112 nsURI_GetNSContainer,
1113 nsURI_SetNSContainer,
1116 static nsresult NSAPI nsIOService_QueryInterface(nsIIOService *iface, nsIIDRef riid,
1121 if(IsEqualGUID(&IID_nsISupports, riid)) {
1122 TRACE("(IID_nsISupports %p)\n", result);
1124 }else if(IsEqualGUID(&IID_nsIIOService, riid)) {
1125 TRACE("(IID_nsIIOService %p)\n", result);
1130 nsIIOService_AddRef(iface);
1134 WARN("(%s %p)\n", debugstr_guid(riid), result);
1135 return NS_NOINTERFACE;
1138 static nsrefcnt NSAPI nsIOService_AddRef(nsIIOService *iface)
1143 static nsrefcnt NSAPI nsIOService_Release(nsIIOService *iface)
1148 static nsresult NSAPI nsIOService_GetProtocolHandler(nsIIOService *iface, const char *aScheme,
1149 nsIProtocolHandler **_retval)
1151 TRACE("(%s %p)\n", debugstr_a(aScheme), _retval);
1152 return nsIIOService_GetProtocolHandler(nsio, aScheme, _retval);
1155 static nsresult NSAPI nsIOService_GetProtocolFlags(nsIIOService *iface, const char *aScheme,
1158 TRACE("(%s %p)\n", debugstr_a(aScheme), _retval);
1159 return nsIIOService_GetProtocolFlags(nsio, aScheme, _retval);
1162 static nsresult NSAPI nsIOService_NewURI(nsIIOService *iface, const nsACString *aSpec,
1163 const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval)
1165 const char *spec = NULL;
1168 PRBool is_javascript = FALSE;
1171 nsACString_GetData(aSpec, &spec, NULL);
1173 TRACE("(%p(%s) %s %p %p)\n", aSpec, debugstr_a(spec), debugstr_a(aOriginCharset),
1177 nsACString *base_uri_str = nsACString_Create();
1178 const char *base_uri = NULL;
1180 nsres = nsIURI_GetSpec(aBaseURI, base_uri_str);
1181 if(NS_SUCCEEDED(nsres)) {
1182 nsACString_GetData(base_uri_str, &base_uri, NULL);
1183 TRACE("uri=%s\n", debugstr_a(base_uri));
1185 ERR("GetSpec failed: %08lx\n", nsres);
1188 nsACString_Destroy(base_uri_str);
1191 nsres = nsIIOService_NewURI(nsio, aSpec, aOriginCharset, aBaseURI, &uri);
1192 if(NS_FAILED(nsres)) {
1193 WARN("NewURI failed: %08lx\n", nsres);
1197 nsIURI_SchemeIs(uri, "javascript", &is_javascript);
1199 TRACE("returning javascript uri: %p\n", uri);
1204 ret = HeapAlloc(GetProcessHeap(), 0, sizeof(nsURI));
1206 ret->lpWineURIVtbl = &nsWineURIVtbl;
1209 ret->container = NULL;
1211 TRACE("_retval = %p\n", ret);
1212 *_retval = NSURI(ret);
1216 static nsresult NSAPI nsIOService_NewFileURI(nsIIOService *iface, nsIFile *aFile,
1219 TRACE("(%p %p)\n", aFile, _retval);
1220 return nsIIOService_NewFileURI(nsio, aFile, _retval);
1223 static nsresult NSAPI nsIOService_NewChannelFromURI(nsIIOService *iface, nsIURI *aURI,
1224 nsIChannel **_retval)
1226 nsIChannel *channel = NULL;
1228 nsIWineURI *wine_uri;
1231 TRACE("(%p %p)\n", aURI, _retval);
1233 nsres = nsIIOService_NewChannelFromURI(nsio, aURI, &channel);
1234 if(NS_FAILED(nsres)) {
1235 WARN("NewChannelFromURI failed: %08lx\n", nsres);
1240 nsres = nsIURI_QueryInterface(aURI, &IID_nsIWineURI, (void**)&wine_uri);
1241 if(NS_FAILED(nsres)) {
1242 WARN("Could not get nsIWineURI: %08lx\n", nsres);
1247 ret = HeapAlloc(GetProcessHeap(), 0, sizeof(nsChannel));
1249 ret->lpHttpChannelVtbl = &nsChannelVtbl;
1250 ret->lpUploadChannelVtbl = &nsUploadChannelVtbl;
1252 ret->channel = channel;
1253 ret->http_channel = NULL;
1254 ret->uri = wine_uri;
1255 ret->post_data_stream = NULL;
1257 nsIChannel_QueryInterface(ret->channel, &IID_nsIHttpChannel, (void**)&ret->http_channel);
1259 *_retval = NSCHANNEL(ret);
1263 static nsresult NSAPI nsIOService_NewChannel(nsIIOService *iface, const nsACString *aSpec,
1264 const char *aOriginCharset, nsIURI *aBaseURI, nsIChannel **_retval)
1266 TRACE("(%p %s %p %p)\n", aSpec, debugstr_a(aOriginCharset), aBaseURI, _retval);
1267 return nsIIOService_NewChannel(nsio, aSpec, aOriginCharset, aBaseURI, _retval);
1270 static nsresult NSAPI nsIOService_GetOffline(nsIIOService *iface, PRBool *aOffline)
1272 TRACE("(%p)\n", aOffline);
1273 return nsIIOService_GetOffline(nsio, aOffline);
1276 static nsresult NSAPI nsIOService_SetOffline(nsIIOService *iface, PRBool aOffline)
1278 TRACE("(%x)\n", aOffline);
1279 return nsIIOService_SetOffline(nsio, aOffline);
1282 static nsresult NSAPI nsIOService_AllowPort(nsIIOService *iface, PRInt32 aPort,
1283 const char *aScheme, PRBool *_retval)
1285 TRACE("(%ld %s %p)\n", aPort, debugstr_a(aScheme), _retval);
1286 return nsIIOService_AllowPort(nsio, aPort, debugstr_a(aScheme), _retval);
1289 static nsresult NSAPI nsIOService_ExtractScheme(nsIIOService *iface, const nsACString *urlString,
1290 nsACString * _retval)
1292 TRACE("(%p %p)\n", urlString, _retval);
1293 return nsIIOService_ExtractScheme(nsio, urlString, _retval);
1296 static const nsIIOServiceVtbl nsIOServiceVtbl = {
1297 nsIOService_QueryInterface,
1299 nsIOService_Release,
1300 nsIOService_GetProtocolHandler,
1301 nsIOService_GetProtocolFlags,
1303 nsIOService_NewFileURI,
1304 nsIOService_NewChannelFromURI,
1305 nsIOService_NewChannel,
1306 nsIOService_GetOffline,
1307 nsIOService_SetOffline,
1308 nsIOService_AllowPort,
1309 nsIOService_ExtractScheme
1312 static nsIIOService nsIOService = { &nsIOServiceVtbl };
1314 static nsresult NSAPI nsIOServiceFactory_QueryInterface(nsIFactory *iface, nsIIDRef riid,
1319 if(IsEqualGUID(&IID_nsISupports, riid)) {
1320 TRACE("(IID_nsISupoprts %p)\n", result);
1322 }else if(IsEqualGUID(&IID_nsIFactory, riid)) {
1323 TRACE("(IID_nsIFactory %p)\n", result);
1328 nsIFactory_AddRef(iface);
1332 WARN("(%s %p)\n", debugstr_guid(riid), result);
1333 return NS_NOINTERFACE;
1336 static nsrefcnt NSAPI nsIOServiceFactory_AddRef(nsIFactory *iface)
1341 static nsrefcnt NSAPI nsIOServiceFactory_Release(nsIFactory *iface)
1346 static nsresult NSAPI nsIOServiceFactory_CreateInstance(nsIFactory *iface,
1347 nsISupports *aOuter, const nsIID *iid, void **result)
1349 return nsIIOService_QueryInterface(&nsIOService, iid, result);
1352 static nsresult NSAPI nsIOServiceFactory_LockFactory(nsIFactory *iface, PRBool lock)
1354 WARN("(%x)\n", lock);
1358 static const nsIFactoryVtbl nsIOServiceFactoryVtbl = {
1359 nsIOServiceFactory_QueryInterface,
1360 nsIOServiceFactory_AddRef,
1361 nsIOServiceFactory_Release,
1362 nsIOServiceFactory_CreateInstance,
1363 nsIOServiceFactory_LockFactory
1366 static nsIFactory nsIOServiceFactory = { &nsIOServiceFactoryVtbl };
1368 void init_nsio(nsIComponentManager *component_manager, nsIComponentRegistrar *registrar)
1370 nsIFactory *old_factory = NULL;
1373 nsres = nsIComponentManager_GetClassObject(component_manager, &NS_IOSERVICE_CID,
1374 &IID_nsIFactory, (void**)&old_factory);
1375 if(NS_FAILED(nsres)) {
1376 ERR("Could not get factory: %08lx\n", nsres);
1377 nsIFactory_Release(old_factory);
1381 nsres = nsIFactory_CreateInstance(old_factory, NULL, &IID_nsIIOService, (void**)&nsio);
1382 if(NS_FAILED(nsres)) {
1383 ERR("Couldn not create nsIOService instance %08lx\n", nsres);
1384 nsIFactory_Release(old_factory);
1388 nsres = nsIComponentRegistrar_UnregisterFactory(registrar, &NS_IOSERVICE_CID, old_factory);
1389 nsIFactory_Release(old_factory);
1390 if(NS_FAILED(nsres))
1391 ERR("UnregisterFactory failed: %08lx\n", nsres);
1393 nsres = nsIComponentRegistrar_RegisterFactory(registrar, &NS_IOSERVICE_CID,
1394 NS_IOSERVICE_CLASSNAME, NS_IOSERVICE_CONTRACTID, &nsIOServiceFactory);
1395 if(NS_FAILED(nsres))
1396 ERR("RegisterFactory failed: %08lx\n", nsres);
1399 nsIURI *get_nsIURI(LPCWSTR url)
1407 len = WideCharToMultiByte(CP_ACP, 0, url, -1, NULL, -1, NULL, NULL);
1408 urla = HeapAlloc(GetProcessHeap(), 0, len);
1409 WideCharToMultiByte(CP_ACP, 0, url, -1, urla, -1, NULL, NULL);
1411 acstr = nsACString_Create();
1412 nsACString_SetData(acstr, urla);
1414 nsres = nsIIOService_NewURI(nsio, acstr, NULL, NULL, &ret);
1415 if(NS_FAILED(nsres))
1416 FIXME("NewURI failed: %08lx\n", nsres);
1418 nsACString_Destroy(acstr);
1419 HeapFree(GetProcessHeap(), 0, urla);