ReactOS  0.4.13-dev-39-g8b6696f
nsio.c
Go to the documentation of this file.
1 /*
2  * Copyright 2006-2010 Jacek Caban for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  */
18 
19 #include "mshtml_private.h"
20 
21 #define NS_IOSERVICE_CLASSNAME "nsIOService"
22 #define NS_IOSERVICE_CONTRACTID "@mozilla.org/network/io-service;1"
23 
24 static const IID NS_IOSERVICE_CID =
25  {0x9ac9e770, 0x18bc, 0x11d3, {0x93, 0x37, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40}};
26 static const IID IID_nsWineURI =
27  {0x5088272e, 0x900b, 0x11da, {0xc6,0x87, 0x00,0x0f,0xea,0x57,0xf2,0x1a}};
28 
31 
32 static const char *request_method_strings[] = {"GET", "PUT", "POST"};
33 
34 struct nsWineURI {
35  nsIFileURL nsIFileURL_iface; /* For non-file URL objects, it's just nsIURL */
37 
39 
49 };
50 
52 {
53  HRESULT hres;
54 
55  assert(This->uri || This->uri_builder);
56 
57  if(!This->uri) {
58  hres = IUriBuilder_CreateUriSimple(This->uri_builder, 0, 0, &This->uri);
59  if(FAILED(hres)) {
60  WARN("CreateUriSimple failed: %08x\n", hres);
61  return FALSE;
62  }
63  }
64 
65  return TRUE;
66 }
67 
69 {
70  if(!ensure_uri(nsuri))
71  return NULL;
72 
73  IUri_AddRef(nsuri->uri);
74  return nsuri->uri;
75 }
76 
78 {
79  IUriBuilder *uri_builder;
80  IUri *ret;
81  BOOL b;
82  HRESULT hres;
83 
84  hres = IUri_HasProperty(uri, Uri_PROPERTY_FRAGMENT, &b);
85  if(SUCCEEDED(hres) && !b) {
86  IUri_AddRef(uri);
87  return uri;
88  }
89 
90  hres = CreateIUriBuilder(uri, 0, 0, &uri_builder);
91  if(FAILED(hres))
92  return NULL;
93 
94  hres = IUriBuilder_RemoveProperties(uri_builder, Uri_HAS_FRAGMENT);
95  if(SUCCEEDED(hres))
96  hres = IUriBuilder_CreateUriSimple(uri_builder, 0, 0, &ret);
97  IUriBuilder_Release(uri_builder);
98  if(FAILED(hres))
99  return NULL;
100 
101  return ret;
102 }
103 
104 static BOOL compare_ignoring_frag(IUri *uri1, IUri *uri2)
105 {
106  IUri *uri_nofrag1, *uri_nofrag2;
107  BOOL ret = FALSE;
108 
109  uri_nofrag1 = get_uri_nofrag(uri1);
110  if(!uri_nofrag1)
111  return FALSE;
112 
113  uri_nofrag2 = get_uri_nofrag(uri2);
114  if(uri_nofrag2) {
115  IUri_IsEqual(uri_nofrag1, uri_nofrag2, &ret);
116  IUri_Release(uri_nofrag2);
117  }
118 
119  IUri_Release(uri_nofrag1);
120  return ret;
121 }
122 
123 static HRESULT combine_url(IUri *base_uri, const WCHAR *rel_url, IUri **ret)
124 {
125  IUri *uri_nofrag;
126  HRESULT hres;
127 
128  uri_nofrag = get_uri_nofrag(base_uri);
129  if(!uri_nofrag)
130  return E_FAIL;
131 
133  ret, 0);
134  IUri_Release(uri_nofrag);
135  if(FAILED(hres))
136  WARN("CoInternetCombineUrlEx failed: %08x\n", hres);
137  return hres;
138 }
139 
141 
142 static const char *debugstr_nsacstr(const nsACString *nsstr)
143 {
144  const char *data;
145 
146  nsACString_GetData(nsstr, &data);
147  return debugstr_a(data);
148 }
149 
150 static nsresult return_wstr_nsacstr(nsACString *ret_str, const WCHAR *str, int len)
151 {
152  char *stra;
153  int lena;
154 
155  TRACE("returning %s\n", debugstr_wn(str, len));
156 
157  if(!*str) {
158  nsACString_SetData(ret_str, "");
159  return NS_OK;
160  }
161 
162  lena = WideCharToMultiByte(CP_UTF8, 0, str, len, NULL, 0, NULL, NULL);
163  stra = heap_alloc(lena+1);
164  if(!stra)
165  return NS_ERROR_OUT_OF_MEMORY;
166 
167  WideCharToMultiByte(CP_UTF8, 0, str, len, stra, lena, NULL, NULL);
168  stra[lena] = 0;
169 
170  nsACString_SetData(ret_str, stra);
171  heap_free(stra);
172  return NS_OK;
173 }
174 
176 {
177  const WCHAR *ptr = nsuri;
178 
179  static const WCHAR wine_prefixW[] = {'w','i','n','e',':'};
180 
181  if(!strncmpW(nsuri, wine_prefixW, sizeof(wine_prefixW)/sizeof(WCHAR)))
182  ptr += sizeof(wine_prefixW)/sizeof(WCHAR);
183 
184  if(*ptr || ret_empty) {
185  *ret = SysAllocString(ptr);
186  if(!*ret)
187  return E_OUTOFMEMORY;
188  }else {
189  *ret = NULL;
190  }
191 
192  TRACE("%s -> %s\n", debugstr_w(nsuri), debugstr_w(*ret));
193  return S_OK;
194 }
195 
197 {
198  IOleCommandTarget *cmdtrg = NULL;
199  HRESULT hres;
200 
201  hres = IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
202  if(SUCCEEDED(hres)) {
203  VARIANT varUrl, varRes;
204 
205  V_VT(&varUrl) = VT_BSTR;
206  V_BSTR(&varUrl) = url;
207  V_VT(&varRes) = VT_BOOL;
208 
209  hres = IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 67, 0, &varUrl, &varRes);
210 
211  IOleCommandTarget_Release(cmdtrg);
212 
213  if(SUCCEEDED(hres) && !V_BOOL(&varRes)) {
214  TRACE("got VARIANT_FALSE, do not load\n");
215  return FALSE;
216  }
217  }
218 
219  return TRUE;
220 }
221 
223 {
224  HTMLDocumentObj *doc = container->doc;
225  BSTR display_uri;
226  HRESULT hres;
227 
228  if(!doc->client) {
229  *cancel = TRUE;
230  return NS_OK;
231  }
232 
233  hres = IUri_GetDisplayUri(channel->uri->uri, &display_uri);
234  if(FAILED(hres))
235  return NS_ERROR_FAILURE;
236 
237  if(!exec_shldocvw_67(doc, display_uri)) {
238  SysFreeString(display_uri);
239  *cancel = FALSE;
240  return NS_OK;
241  }
242 
243  hres = hlink_frame_navigate(&doc->basedoc, display_uri, channel, 0, cancel);
244  SysFreeString(display_uri);
245  if(FAILED(hres))
246  *cancel = TRUE;
247  return NS_OK;
248 }
249 
251  nsChannelBSC *channelbsc, DWORD flags)
252 {
253  nsIDocShellLoadInfo *load_info = NULL;
254  nsIWebNavigation *web_navigation;
255  nsIDocShell *doc_shell;
256  HTMLDocumentNode *doc;
257  nsresult nsres;
258 
259  nsres = get_nsinterface((nsISupports*)window->nswindow, &IID_nsIWebNavigation, (void**)&web_navigation);
260  if(NS_FAILED(nsres)) {
261  ERR("Could not get nsIWebNavigation interface: %08x\n", nsres);
262  return E_FAIL;
263  }
264 
265  nsres = nsIWebNavigation_QueryInterface(web_navigation, &IID_nsIDocShell, (void**)&doc_shell);
266  nsIWebNavigation_Release(web_navigation);
267  if(NS_FAILED(nsres)) {
268  ERR("Could not get nsIDocShell: %08x\n", nsres);
269  return E_FAIL;
270  }
271 
272  if(post_stream) {
273  nsres = nsIDocShell_CreateLoadInfo(doc_shell, &load_info);
274  if(NS_FAILED(nsres)) {
275  nsIDocShell_Release(doc_shell);
276  return E_FAIL;
277  }
278 
279  nsres = nsIDocShellLoadInfo_SetPostDataStream(load_info, post_stream);
280  assert(nsres == NS_OK);
281  }
282 
283  uri->channel_bsc = channelbsc;
284  doc = window->base.inner_window->doc;
285  doc->skip_mutation_notif = TRUE;
286  nsres = nsIDocShell_LoadURI(doc_shell, (nsIURI*)&uri->nsIFileURL_iface, load_info, flags, FALSE);
287  if(doc == window->base.inner_window->doc)
288  doc->skip_mutation_notif = FALSE;
289  uri->channel_bsc = NULL;
290  nsIDocShell_Release(doc_shell);
291  if(load_info)
292  nsIDocShellLoadInfo_Release(load_info);
293  if(NS_FAILED(nsres)) {
294  WARN("LoadURI failed: %08x\n", nsres);
295  return E_FAIL;
296  }
297 
298  return S_OK;
299 }
300 
301 static void set_uri_nscontainer(nsWineURI *This, NSContainer *nscontainer)
302 {
303  if(This->container) {
304  if(This->container == nscontainer)
305  return;
306  TRACE("Changing %p -> %p\n", This->container, nscontainer);
307  nsIWebBrowserChrome_Release(&This->container->nsIWebBrowserChrome_iface);
308  }
309 
310  if(nscontainer)
311  nsIWebBrowserChrome_AddRef(&nscontainer->nsIWebBrowserChrome_iface);
312  This->container = nscontainer;
313 }
314 
316 {
317  if(This->window_ref) {
318  if(This->window_ref->window == window)
319  return;
320  TRACE("Changing %p -> %p\n", This->window_ref->window, window);
321  windowref_release(This->window_ref);
322  }
323 
324  if(window) {
325  windowref_addref(window->window_ref);
326  This->window_ref = window->window_ref;
327 
328  if(window->doc_obj)
329  set_uri_nscontainer(This, window->doc_obj->nscontainer);
330  }else {
331  This->window_ref = NULL;
332  }
333 }
334 
336 {
337  return This->uri->scheme == URL_SCHEME_HTTP || This->uri->scheme == URL_SCHEME_HTTPS;
338 }
339 
340 static http_header_t *find_http_header(struct list *headers, const WCHAR *name, int len)
341 {
342  http_header_t *iter;
343 
345  if(!strncmpiW(iter->header, name, len) && !iter->header[len])
346  return iter;
347  }
348 
349  return NULL;
350 }
351 
352 static nsresult get_channel_http_header(struct list *headers, const nsACString *header_name_str,
353  nsACString *_retval)
354 {
355  const char *header_namea;
358  char *data;
359 
360  nsACString_GetData(header_name_str, &header_namea);
361  header_name = heap_strdupAtoW(header_namea);
362  if(!header_name)
363  return NS_ERROR_UNEXPECTED;
364 
367  if(!header)
368  return NS_ERROR_NOT_AVAILABLE;
369 
370  data = heap_strdupWtoA(header->data);
371  if(!data)
372  return NS_ERROR_UNEXPECTED;
373 
374  TRACE("%s -> %s\n", debugstr_a(header_namea), debugstr_a(data));
375  nsACString_SetData(_retval, data);
376  heap_free(data);
377  return NS_OK;
378 }
379 
380 HRESULT set_http_header(struct list *headers, const WCHAR *name, int name_len,
381  const WCHAR *value, int value_len)
382 {
384 
385  TRACE("%s: %s\n", debugstr_wn(name, name_len), debugstr_wn(value, value_len));
386 
387  header = find_http_header(headers, name, name_len);
388  if(header) {
389  WCHAR *new_data;
390 
391  new_data = heap_strndupW(value, value_len);
392  if(!new_data)
393  return E_OUTOFMEMORY;
394 
395  heap_free(header->data);
396  header->data = new_data;
397  }else {
398  header = heap_alloc(sizeof(http_header_t));
399  if(!header)
400  return E_OUTOFMEMORY;
401 
402  header->header = heap_strndupW(name, name_len);
403  header->data = heap_strndupW(value, value_len);
404  if(!header->header || !header->data) {
405  heap_free(header->header);
406  heap_free(header->data);
407  heap_free(header);
408  return E_OUTOFMEMORY;
409  }
410 
411  list_add_tail(headers, &header->entry);
412  }
413 
414  return S_OK;
415 }
416 
417 static nsresult set_channel_http_header(struct list *headers, const nsACString *name_str,
418  const nsACString *value_str)
419 {
420  const char *namea, *valuea;
421  WCHAR *name, *value;
422  HRESULT hres;
423 
424  nsACString_GetData(name_str, &namea);
425  name = heap_strdupAtoW(namea);
426  if(!name)
427  return NS_ERROR_UNEXPECTED;
428 
429  nsACString_GetData(value_str, &valuea);
430  value = heap_strdupAtoW(valuea);
431  if(!value) {
432  heap_free(name);
433  return NS_ERROR_UNEXPECTED;
434  }
435 
437 
438  heap_free(name);
439  heap_free(value);
441 }
442 
444 {
445  nsACString header_str, value_str;
446  char *header, *value;
447  http_header_t *iter;
448  nsresult nsres;
449 
451  header = heap_strdupWtoA(iter->header);
452  if(!header)
453  return NS_ERROR_OUT_OF_MEMORY;
454 
455  value = heap_strdupWtoA(iter->data);
456  if(!value) {
457  heap_free(header);
458  return NS_ERROR_OUT_OF_MEMORY;
459  }
460 
461  nsACString_InitDepend(&header_str, header);
463  nsres = nsIHttpHeaderVisitor_VisitHeader(visitor, &header_str, &value_str);
464  nsACString_Finish(&header_str);
466  heap_free(header);
467  heap_free(value);
468  if(NS_FAILED(nsres))
469  break;
470  }
471 
472  return NS_OK;
473 }
474 
475 static void free_http_headers(struct list *list)
476 {
477  http_header_t *iter, *iter_next;
478 
479  LIST_FOR_EACH_ENTRY_SAFE(iter, iter_next, list, http_header_t, entry) {
480  list_remove(&iter->entry);
481  heap_free(iter->header);
482  heap_free(iter->data);
483  heap_free(iter);
484  }
485 }
486 
488 {
489  return CONTAINING_RECORD(iface, nsChannel, nsIHttpChannel_iface);
490 }
491 
493 {
495 
496  if(IsEqualGUID(&IID_nsISupports, riid)) {
497  TRACE("(%p)->(IID_nsISupports %p)\n", This, result);
498  *result = &This->nsIHttpChannel_iface;
499  }else if(IsEqualGUID(&IID_nsIRequest, riid)) {
500  TRACE("(%p)->(IID_nsIRequest %p)\n", This, result);
501  *result = &This->nsIHttpChannel_iface;
502  }else if(IsEqualGUID(&IID_nsIChannel, riid)) {
503  TRACE("(%p)->(IID_nsIChannel %p)\n", This, result);
504  *result = &This->nsIHttpChannel_iface;
505  }else if(IsEqualGUID(&IID_nsIHttpChannel, riid)) {
506  TRACE("(%p)->(IID_nsIHttpChannel %p)\n", This, result);
507  *result = is_http_channel(This) ? &This->nsIHttpChannel_iface : NULL;
508  }else if(IsEqualGUID(&IID_nsIUploadChannel, riid)) {
509  TRACE("(%p)->(IID_nsIUploadChannel %p)\n", This, result);
510  *result = &This->nsIUploadChannel_iface;
511  }else if(IsEqualGUID(&IID_nsIHttpChannelInternal, riid)) {
512  TRACE("(%p)->(IID_nsIHttpChannelInternal %p)\n", This, result);
513  *result = is_http_channel(This) ? &This->nsIHttpChannelInternal_iface : NULL;
514  }else {
515  TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), result);
516  *result = NULL;
517  }
518 
519  if(*result) {
520  nsIHttpChannel_AddRef(&This->nsIHttpChannel_iface);
521  return NS_OK;
522  }
523 
524  return NS_NOINTERFACE;
525 }
526 
528 {
531 
532  TRACE("(%p) ref=%d\n", This, ref);
533 
534  return ref;
535 }
536 
538 {
541 
542  if(!ref) {
543  nsIFileURL_Release(&This->uri->nsIFileURL_iface);
544  if(This->owner)
545  nsISupports_Release(This->owner);
546  if(This->post_data_stream)
547  nsIInputStream_Release(This->post_data_stream);
548  if(This->load_group)
549  nsILoadGroup_Release(This->load_group);
550  if(This->notif_callback)
551  nsIInterfaceRequestor_Release(This->notif_callback);
552  if(This->original_uri)
553  nsIURI_Release(This->original_uri);
554  if(This->referrer)
555  nsIURI_Release(This->referrer);
556 
557  free_http_headers(&This->response_headers);
558  free_http_headers(&This->request_headers);
559 
560  heap_free(This->content_type);
561  heap_free(This->charset);
562  heap_free(This);
563  }
564 
565  return ref;
566 }
567 
569 {
571 
572  TRACE("(%p)->(%p)\n", This, aName);
573 
574  return nsIFileURL_GetSpec(&This->uri->nsIFileURL_iface, aName);
575 }
576 
578 {
580 
581  FIXME("(%p)->(%p)\n", This, _retval);
582 
584 }
585 
587 {
589 
590  WARN("(%p)->(%p) returning NS_OK\n", This, aStatus);
591 
592  return *aStatus = NS_OK;
593 }
594 
596 {
598 
599  FIXME("(%p)->(%08x)\n", This, aStatus);
600 
602 }
603 
605 {
607 
608  FIXME("(%p)\n", This);
609 
611 }
612 
614 {
616 
617  FIXME("(%p)\n", This);
618 
620 }
621 
623 {
625 
626  TRACE("(%p)->(%p)\n", This, aLoadGroup);
627 
628  if(This->load_group)
629  nsILoadGroup_AddRef(This->load_group);
630 
631  *aLoadGroup = This->load_group;
632  return NS_OK;
633 }
634 
636 {
638 
639  TRACE("(%p)->(%p)\n", This, aLoadGroup);
640 
641  if(This->load_group)
642  nsILoadGroup_Release(This->load_group);
643  if(aLoadGroup)
644  nsILoadGroup_AddRef(aLoadGroup);
645  This->load_group = aLoadGroup;
646 
647  return NS_OK;
648 }
649 
651 {
653 
654  TRACE("(%p)->(%p)\n", This, aLoadFlags);
655 
656  *aLoadFlags = This->load_flags;
657  return NS_OK;
658 }
659 
661 {
663 
664  TRACE("(%p)->(%08x)\n", This, aLoadFlags);
665 
666  This->load_flags = aLoadFlags;
667  return NS_OK;
668 }
669 
671 {
673 
674  TRACE("(%p)->(%p)\n", This, aOriginalURI);
675 
676  if(This->original_uri)
677  nsIURI_AddRef(This->original_uri);
678 
679  *aOriginalURI = This->original_uri;
680  return NS_OK;
681 }
682 
684 {
686 
687  TRACE("(%p)->(%p)\n", This, aOriginalURI);
688 
689  if(This->original_uri)
690  nsIURI_Release(This->original_uri);
691 
692  nsIURI_AddRef(aOriginalURI);
693  This->original_uri = aOriginalURI;
694  return NS_OK;
695 }
696 
698 {
700 
701  TRACE("(%p)->(%p)\n", This, aURI);
702 
703  nsIFileURL_AddRef(&This->uri->nsIFileURL_iface);
704  *aURI = (nsIURI*)This->uri;
705 
706  return NS_OK;
707 }
708 
710 {
712 
713  TRACE("(%p)->(%p)\n", This, aOwner);
714 
715  if(This->owner)
716  nsISupports_AddRef(This->owner);
717  *aOwner = This->owner;
718 
719  return NS_OK;
720 }
721 
723 {
725 
726  TRACE("(%p)->(%p)\n", This, aOwner);
727 
728  if(aOwner)
729  nsISupports_AddRef(aOwner);
730  if(This->owner)
731  nsISupports_Release(This->owner);
732  This->owner = aOwner;
733 
734  return NS_OK;
735 }
736 
738  nsIInterfaceRequestor **aNotificationCallbacks)
739 {
741 
742  TRACE("(%p)->(%p)\n", This, aNotificationCallbacks);
743 
744  if(This->notif_callback)
745  nsIInterfaceRequestor_AddRef(This->notif_callback);
746  *aNotificationCallbacks = This->notif_callback;
747 
748  return NS_OK;
749 }
750 
752  nsIInterfaceRequestor *aNotificationCallbacks)
753 {
755 
756  TRACE("(%p)->(%p)\n", This, aNotificationCallbacks);
757 
758  if(This->notif_callback)
759  nsIInterfaceRequestor_Release(This->notif_callback);
760  if(aNotificationCallbacks)
761  nsIInterfaceRequestor_AddRef(aNotificationCallbacks);
762 
763  This->notif_callback = aNotificationCallbacks;
764 
765  return NS_OK;
766 }
767 
769 {
771 
772  TRACE("(%p)->(%p)\n", This, aSecurityInfo);
773 
775 }
776 
778 {
780 
781  TRACE("(%p)->(%p)\n", This, aContentType);
782 
783  if(This->content_type) {
784  nsACString_SetData(aContentType, This->content_type);
785  return S_OK;
786  }
787 
788  if(This->uri->is_doc_uri) {
789  WARN("Document channel with no MIME set. Assuming text/html\n");
790  nsACString_SetData(aContentType, "text/html");
791  return S_OK;
792  }
793 
794  WARN("unknown type\n");
795  return NS_ERROR_FAILURE;
796 }
797 
799  const nsACString *aContentType)
800 {
802  const char *content_type;
803 
804  TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aContentType));
805 
806  nsACString_GetData(aContentType, &content_type);
807  heap_free(This->content_type);
808  This->content_type = heap_strdupA(content_type);
809 
810  return NS_OK;
811 }
812 
814  nsACString *aContentCharset)
815 {
817 
818  TRACE("(%p)->(%p)\n", This, aContentCharset);
819 
820  if(This->charset) {
821  nsACString_SetData(aContentCharset, This->charset);
822  return NS_OK;
823  }
824 
825  nsACString_SetData(aContentCharset, "");
826  return NS_OK;
827 }
828 
830  const nsACString *aContentCharset)
831 {
833  const char *data;
834  char *charset;
835 
836  TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aContentCharset));
837 
838  nsACString_GetData(aContentCharset, &data);
840  if(!charset)
841  return NS_ERROR_OUT_OF_MEMORY;
842 
843  heap_free(This->charset);
844  This->charset = charset;
845  return NS_OK;
846 }
847 
849 {
851 
852  FIXME("(%p)->(%p)\n", This, aContentLength);
853 
855 }
856 
858 {
860 
861  FIXME("(%p)->(%s)\n", This, wine_dbgstr_longlong(aContentLength));
862 
864 }
865 
867 {
869 
870  FIXME("(%p)->(%p)\n", This, _retval);
871 
873 }
874 
876 {
878  nsIChannel *channel;
879  nsIRequest *req;
880  nsWineURI *wine_uri;
881  nsIURI *uri;
882  nsresult nsres;
883 
884  nsres = nsILoadGroup_GetDefaultLoadRequest(This->load_group, &req);
885  if(NS_FAILED(nsres)) {
886  ERR("GetDefaultLoadRequest failed: %08x\n", nsres);
887  return NULL;
888  }
889 
890  if(!req)
891  return NULL;
892 
893  nsres = nsIRequest_QueryInterface(req, &IID_nsIChannel, (void**)&channel);
894  nsIRequest_Release(req);
895  if(NS_FAILED(nsres)) {
896  WARN("Could not get nsIChannel interface: %08x\n", nsres);
897  return NULL;
898  }
899 
900  nsres = nsIChannel_GetURI(channel, &uri);
901  nsIChannel_Release(channel);
902  if(NS_FAILED(nsres)) {
903  ERR("GetURI failed: %08x\n", nsres);
904  return NULL;
905  }
906 
907  nsres = nsIURI_QueryInterface(uri, &IID_nsWineURI, (void**)&wine_uri);
908  nsIURI_Release(uri);
909  if(NS_FAILED(nsres)) {
910  TRACE("Could not get nsWineURI: %08x\n", nsres);
911  return NULL;
912  }
913 
914  window = wine_uri->window_ref ? wine_uri->window_ref->window : NULL;
915  if(window)
916  IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
917  nsIFileURL_Release(&wine_uri->nsIFileURL_iface);
918 
919  return window;
920 }
921 
923 {
924  nsIWebProgress *web_progress;
925  nsIDOMWindow *nswindow;
927  nsresult nsres;
928 
929  if(This->load_group) {
930  nsIRequestObserver *req_observer;
931 
932  nsres = nsILoadGroup_GetGroupObserver(This->load_group, &req_observer);
933  if(NS_FAILED(nsres) || !req_observer) {
934  ERR("GetGroupObserver failed: %08x\n", nsres);
935  return NULL;
936  }
937 
938  nsres = nsIRequestObserver_QueryInterface(req_observer, &IID_nsIWebProgress, (void**)&web_progress);
939  nsIRequestObserver_Release(req_observer);
940  if(NS_FAILED(nsres)) {
941  ERR("Could not get nsIWebProgress iface: %08x\n", nsres);
942  return NULL;
943  }
944  }else if(This->notif_callback) {
945  nsres = nsIInterfaceRequestor_GetInterface(This->notif_callback, &IID_nsIWebProgress, (void**)&web_progress);
946  if(NS_FAILED(nsres)) {
947  ERR("GetInterface(IID_nsIWebProgress failed: %08x\n", nsres);
948  return NULL;
949  }
950  }else {
951  ERR("no load group nor notif callback\n");
952  return NULL;
953  }
954 
955  nsres = nsIWebProgress_GetDOMWindow(web_progress, &nswindow);
956  nsIWebProgress_Release(web_progress);
957  if(NS_FAILED(nsres) || !nswindow) {
958  ERR("GetDOMWindow failed: %08x\n", nsres);
959  return NULL;
960  }
961 
962  window = nswindow_to_window(nswindow);
963  nsIDOMWindow_Release(nswindow);
964 
965  if(window)
966  IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
967  else
968  FIXME("NULL window for %p\n", nswindow);
969  return window;
970 }
971 
972 typedef struct {
977 
978 static void start_binding_proc(task_t *_task)
979 {
981 
982  start_binding(task->window, (BSCallback*)task->bscallback, NULL);
983 }
984 
985 static void start_binding_task_destr(task_t *_task)
986 {
988 
989  IBindStatusCallback_Release(&task->bscallback->bsc.IBindStatusCallback_iface);
990  heap_free(task);
991 }
992 
995 {
996  nsChannelBSC *bscallback;
997  IMoniker *mon = NULL;
998  HRESULT hres;
999 
1000  hres = CreateURLMonikerEx2(NULL, This->uri->uri, &mon, 0);
1001  if(FAILED(hres)) {
1002  WARN("CreateURLMoniker failed: %08x\n", hres);
1003  return NS_ERROR_UNEXPECTED;
1004  }
1005 
1006  if(is_doc_channel)
1008 
1009  hres = create_channelbsc(mon, NULL, NULL, 0, is_doc_channel, &bscallback);
1010  IMoniker_Release(mon);
1011  if(FAILED(hres))
1012  return NS_ERROR_UNEXPECTED;
1013 
1014  channelbsc_set_channel(bscallback, This, listener, context);
1015 
1016  if(is_doc_channel) {
1017  hres = create_pending_window(window, bscallback);
1018  if(SUCCEEDED(hres))
1019  async_start_doc_binding(window, window->pending_window);
1020  IBindStatusCallback_Release(&bscallback->bsc.IBindStatusCallback_iface);
1021  if(FAILED(hres))
1022  return NS_ERROR_UNEXPECTED;
1023  }else {
1024  start_binding_task_t *task;
1025 
1026  task = heap_alloc(sizeof(start_binding_task_t));
1027  if(!task) {
1028  IBindStatusCallback_Release(&bscallback->bsc.IBindStatusCallback_iface);
1029  return NS_ERROR_OUT_OF_MEMORY;
1030  }
1031 
1032  task->window = window->base.inner_window;
1033  task->bscallback = bscallback;
1034  hres = push_task(&task->header, start_binding_proc, start_binding_task_destr, window->base.inner_window->task_magic);
1035  if(FAILED(hres))
1036  return NS_ERROR_OUT_OF_MEMORY;
1037  }
1038 
1039  return NS_OK;
1040 }
1041 
1043  nsISupports *aContext)
1044 {
1047  BOOL cancel = FALSE;
1048  nsresult nsres = NS_OK;
1049 
1050  TRACE("(%p)->(%p %p)\n", This, aListener, aContext);
1051 
1052  if(!ensure_uri(This->uri))
1053  return NS_ERROR_FAILURE;
1054 
1055  if(TRACE_ON(mshtml)) {
1056  HRESULT hres;
1057  BSTR uri_str;
1058 
1059  hres = IUri_GetDisplayUri(This->uri->uri, &uri_str);
1060  if(SUCCEEDED(hres)) {
1061  TRACE("opening %s\n", debugstr_w(uri_str));
1062  SysFreeString(uri_str);
1063  }else {
1064  WARN("GetDisplayUri failed: %08x\n", hres);
1065  }
1066  }
1067 
1068  if(This->uri->is_doc_uri) {
1070  if(window) {
1071  set_uri_window(This->uri, window);
1072  }else if(This->uri->container) {
1073  BOOL b;
1074 
1075  /* nscontainer->doc should be NULL which means navigation to a new window */
1076  if(This->uri->container->doc)
1077  FIXME("nscontainer->doc = %p\n", This->uri->container->doc);
1078 
1079  nsres = before_async_open(This, This->uri->container, &b);
1080  if(NS_FAILED(nsres))
1081  return nsres;
1082  if(b)
1083  FIXME("Navigation not cancelled\n");
1084  return NS_ERROR_UNEXPECTED;
1085  }
1086  }
1087 
1088  if(!window) {
1089  if(This->uri->window_ref && This->uri->window_ref->window) {
1090  window = This->uri->window_ref->window;
1091  IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
1092  }else {
1093  /* FIXME: Analyze removing get_window_from_load_group call */
1094  if(This->load_group)
1096  if(!window)
1098  if(window)
1099  set_uri_window(This->uri, window);
1100  }
1101  }
1102 
1103  if(!window) {
1104  ERR("window = NULL\n");
1105  return NS_ERROR_UNEXPECTED;
1106  }
1107 
1108  if(This->uri->is_doc_uri && window == window->doc_obj->basedoc.window) {
1109  if(This->uri->channel_bsc) {
1110  channelbsc_set_channel(This->uri->channel_bsc, This, aListener, aContext);
1111 
1112  if(window->doc_obj->mime) {
1113  heap_free(This->content_type);
1114  This->content_type = heap_strdupWtoA(window->doc_obj->mime);
1115  }
1116 
1117  cancel = TRUE;
1118  }else {
1119  nsres = before_async_open(This, window->doc_obj->nscontainer, &cancel);
1120  if(NS_SUCCEEDED(nsres) && cancel) {
1121  TRACE("canceled\n");
1122  nsres = NS_BINDING_ABORTED;
1123  }
1124  }
1125  }
1126 
1127  if(!cancel)
1128  nsres = async_open(This, window, This->uri->is_doc_uri, aListener, aContext);
1129 
1130  if(NS_SUCCEEDED(nsres) && This->load_group) {
1131  nsres = nsILoadGroup_AddRequest(This->load_group, (nsIRequest*)&This->nsIHttpChannel_iface,
1132  aContext);
1133  if(NS_FAILED(nsres))
1134  ERR("AddRequest failed: %08x\n", nsres);
1135  }
1136 
1137  IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface);
1138  return nsres;
1139 }
1140 
1142 {
1144  FIXME("(%p)->(%p)\n", This, aContentDisposition);
1145  return NS_ERROR_NOT_IMPLEMENTED;
1146 }
1147 
1149 {
1151  FIXME("(%p)->(%u)\n", This, aContentDisposition);
1152  return NS_ERROR_NOT_IMPLEMENTED;
1153 }
1154 
1156 {
1158  FIXME("(%p)->(%p)\n", This, aContentDispositionFilename);
1159  return NS_ERROR_NOT_IMPLEMENTED;
1160 }
1161 
1162 static nsresult NSAPI nsChannel_SetContentDispositionFilename(nsIHttpChannel *iface, const nsAString *aContentDispositionFilename)
1163 {
1165  FIXME("(%p)->(%p)\n", This, aContentDispositionFilename);
1166  return NS_ERROR_NOT_IMPLEMENTED;
1167 }
1168 
1170 {
1172  FIXME("(%p)->(%p)\n", This, aContentDispositionHeader);
1173  return NS_ERROR_NOT_IMPLEMENTED;
1174 }
1175 
1177 {
1179 
1180  TRACE("(%p)->(%p)\n", This, aLoadInfo);
1181 
1182  if(This->load_info)
1183  nsISupports_AddRef(This->load_info);
1184  *aLoadInfo = This->load_info;
1185  return NS_OK;
1186 }
1187 
1189 {
1191 
1192  TRACE("(%p)->(%p)\n", This, aLoadInfo);
1193 
1194  if(This->load_info)
1195  nsISupports_Release(This->load_info);
1196  This->load_info = aLoadInfo;
1197  if(This->load_info)
1198  nsISupports_AddRef(This->load_info);
1199  return NS_OK;
1200 }
1201 
1203 {
1205 
1206  TRACE("(%p)->(%p)\n", This, aRequestMethod);
1207 
1208  nsACString_SetData(aRequestMethod, request_method_strings[This->request_method]);
1209  return NS_OK;
1210 }
1211 
1213  const nsACString *aRequestMethod)
1214 {
1216  const char *method;
1217  unsigned i;
1218 
1219  TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aRequestMethod));
1220 
1221  nsACString_GetData(aRequestMethod, &method);
1222  for(i=0; i < sizeof(request_method_strings)/sizeof(*request_method_strings); i++) {
1224  This->request_method = i;
1225  return NS_OK;
1226  }
1227  }
1228 
1229  ERR("Invalid method %s\n", debugstr_a(method));
1230  return NS_ERROR_UNEXPECTED;
1231 }
1232 
1234 {
1236 
1237  TRACE("(%p)->(%p)\n", This, aReferrer);
1238 
1239  if(This->referrer)
1240  nsIURI_AddRef(This->referrer);
1241  *aReferrer = This->referrer;
1242  return NS_OK;
1243 }
1244 
1246 {
1248 
1249  TRACE("(%p)->(%p)\n", This, aReferrer);
1250 
1251  if(aReferrer)
1252  nsIURI_AddRef(aReferrer);
1253  if(This->referrer)
1254  nsIURI_Release(This->referrer);
1255  This->referrer = aReferrer;
1256  return NS_OK;
1257 }
1258 
1260 {
1262  FIXME("(%p)->(%p)\n", This, aReferrerPolicy);
1263  return NS_ERROR_NOT_IMPLEMENTED;
1264 }
1265 
1266 static nsresult NSAPI nsChannel_SetReferrerWithPolicy(nsIHttpChannel *iface, nsIURI *aReferrer, UINT32 aReferrerPolicy)
1267 {
1269  FIXME("(%p)->(%p %x)\n", This, aReferrer, aReferrerPolicy);
1270  return NS_ERROR_NOT_IMPLEMENTED;
1271 }
1272 
1274  const nsACString *aHeader, nsACString *_retval)
1275 {
1277 
1278  TRACE("(%p)->(%s %p)\n", This, debugstr_nsacstr(aHeader), _retval);
1279 
1280  return get_channel_http_header(&This->request_headers, aHeader, _retval);
1281 }
1282 
1284  const nsACString *aHeader, const nsACString *aValue, cpp_bool aMerge)
1285 {
1287 
1288  TRACE("(%p)->(%s %s %x)\n", This, debugstr_nsacstr(aHeader), debugstr_nsacstr(aValue), aMerge);
1289 
1290  if(aMerge)
1291  FIXME("aMerge not supported\n");
1292 
1293  return set_channel_http_header(&This->request_headers, aHeader, aValue);
1294 }
1295 
1297  nsIHttpHeaderVisitor *aVisitor)
1298 {
1300 
1301  FIXME("(%p)->(%p)\n", This, aVisitor);
1302 
1303  return NS_ERROR_NOT_IMPLEMENTED;
1304 }
1305 
1307 {
1309 
1310  FIXME("(%p)->(%p)\n", This, aAllowPipelining);
1311 
1312  return NS_ERROR_NOT_IMPLEMENTED;
1313 }
1314 
1316 {
1318 
1319  FIXME("(%p)->(%x)\n", This, aAllowPipelining);
1320 
1321  return NS_ERROR_NOT_IMPLEMENTED;
1322 }
1323 
1325 {
1327  FIXME("(%p)->(%p)\n", This, aAllowTLS);
1328  return NS_ERROR_NOT_IMPLEMENTED;
1329 }
1330 
1332 {
1334  FIXME("(%p)->(%x)\n", This, aAllowTLS);
1335  return NS_ERROR_NOT_IMPLEMENTED;
1336 }
1337 
1339 {
1341 
1342  FIXME("(%p)->(%p)\n", This, aRedirectionLimit);
1343 
1344  return NS_ERROR_NOT_IMPLEMENTED;
1345 }
1346 
1348 {
1350 
1351  FIXME("(%p)->(%u)\n", This, aRedirectionLimit);
1352 
1353  return NS_ERROR_NOT_IMPLEMENTED;
1354 }
1355 
1357 {
1359 
1360  TRACE("(%p)->(%p)\n", This, aResponseStatus);
1361 
1362  if(This->response_status) {
1363  *aResponseStatus = This->response_status;
1364  return NS_OK;
1365  }
1366 
1367  WARN("No response status\n");
1368  return NS_ERROR_UNEXPECTED;
1369 }
1370 
1372  nsACString *aResponseStatusText)
1373 {
1375 
1376  TRACE("(%p)->(%p)\n", This, aResponseStatusText);
1377 
1378  nsACString_SetData(aResponseStatusText, This->response_status_text);
1379  return NS_OK;
1380 }
1381 
1383  cpp_bool *aRequestSucceeded)
1384 {
1386 
1387  TRACE("(%p)->(%p)\n", This, aRequestSucceeded);
1388 
1389  if(!This->response_status)
1390  return NS_ERROR_NOT_AVAILABLE;
1391 
1392  *aRequestSucceeded = This->response_status/100 == 2;
1393 
1394  return NS_OK;
1395 }
1396 
1398  const nsACString *header, nsACString *_retval)
1399 {
1401 
1402  TRACE("(%p)->(%s %p)\n", This, debugstr_nsacstr(header), _retval);
1403 
1404  return get_channel_http_header(&This->response_headers, header, _retval);
1405 }
1406 
1408  const nsACString *header, const nsACString *value, cpp_bool merge)
1409 {
1411 
1412  FIXME("(%p)->(%s %s %x)\n", This, debugstr_nsacstr(header), debugstr_nsacstr(value), merge);
1413 
1414  return NS_ERROR_NOT_IMPLEMENTED;
1415 }
1416 
1418  nsIHttpHeaderVisitor *aVisitor)
1419 {
1421 
1422  TRACE("(%p)->(%p)\n", This, aVisitor);
1423 
1424  return visit_http_headers(&This->response_headers, aVisitor);
1425 }
1426 
1428 {
1431 
1432  static const WCHAR cache_controlW[] = {'C','a','c','h','e','-','C','o','n','t','r','o','l'};
1433  static const WCHAR no_storeW[] = {'n','o','-','s','t','o','r','e',0};
1434 
1435  TRACE("(%p)->(%p)\n", This, _retval);
1436 
1437  header = find_http_header(&This->response_headers, cache_controlW, sizeof(cache_controlW)/sizeof(WCHAR));
1438  *_retval = header && !strcmpiW(header->data, no_storeW);
1439  return NS_OK;
1440 }
1441 
1443 {
1445 
1446  FIXME("(%p)->(%p)\n", This, _retval);
1447 
1448  return NS_ERROR_NOT_IMPLEMENTED;
1449 }
1450 
1452 {
1454 
1455  FIXME("(%p)->(%p)\n", This, _retval);
1456 
1457  return NS_ERROR_NOT_IMPLEMENTED;
1458 }
1459 
1461 {
1463 
1464  FIXME("(%p)->(%p)\n", This, aNewURI);
1465 
1466  return NS_ERROR_NOT_IMPLEMENTED;
1467 }
1468 
1469 static const nsIHttpChannelVtbl nsChannelVtbl = {
1531 };
1532 
1534 {
1535  return CONTAINING_RECORD(iface, nsChannel, nsIUploadChannel_iface);
1536 }
1537 
1539  void **result)
1540 {
1542  return nsIHttpChannel_QueryInterface(&This->nsIHttpChannel_iface, riid, result);
1543 }
1544 
1546 {
1548  return nsIHttpChannel_AddRef(&This->nsIHttpChannel_iface);
1549 }
1550 
1552 {
1554  return nsIHttpChannel_Release(&This->nsIHttpChannel_iface);
1555 }
1556 
1558  nsIInputStream *aStream, const nsACString *aContentType, INT64 aContentLength)
1559 {
1561  const char *content_type;
1562 
1563  static const WCHAR content_typeW[] =
1564  {'C','o','n','t','e','n','t','-','T','y','p','e',0};
1565 
1566  TRACE("(%p)->(%p %s %s)\n", This, aStream, debugstr_nsacstr(aContentType), wine_dbgstr_longlong(aContentLength));
1567 
1568  This->post_data_contains_headers = TRUE;
1569 
1570  if(aContentType) {
1571  nsACString_GetData(aContentType, &content_type);
1572  if(*content_type) {
1573  WCHAR *ct;
1574 
1576  if(!ct)
1577  return NS_ERROR_UNEXPECTED;
1578 
1579  set_http_header(&This->request_headers, content_typeW,
1580  sizeof(content_typeW)/sizeof(WCHAR), ct, strlenW(ct));
1581  heap_free(ct);
1582  This->post_data_contains_headers = FALSE;
1583  }
1584  }
1585 
1586  if(aContentLength != -1)
1587  FIXME("Unsupported acontentLength = %s\n", wine_dbgstr_longlong(aContentLength));
1588 
1589  if(This->post_data_stream)
1590  nsIInputStream_Release(This->post_data_stream);
1591  This->post_data_stream = aStream;
1592  if(aStream)
1593  nsIInputStream_AddRef(aStream);
1594 
1595  This->request_method = METHOD_POST;
1596  return NS_OK;
1597 }
1598 
1600  nsIInputStream **aUploadStream)
1601 {
1603 
1604  TRACE("(%p)->(%p)\n", This, aUploadStream);
1605 
1606  if(This->post_data_stream)
1607  nsIInputStream_AddRef(This->post_data_stream);
1608 
1609  *aUploadStream = This->post_data_stream;
1610  return NS_OK;
1611 }
1612 
1613 static const nsIUploadChannelVtbl nsUploadChannelVtbl = {
1619 };
1620 
1622 {
1623  return CONTAINING_RECORD(iface, nsChannel, nsIHttpChannelInternal_iface);
1624 }
1625 
1627  void **result)
1628 {
1630  return nsIHttpChannel_QueryInterface(&This->nsIHttpChannel_iface, riid, result);
1631 }
1632 
1634 {
1636  return nsIHttpChannel_AddRef(&This->nsIHttpChannel_iface);
1637 }
1638 
1640 {
1642  return nsIHttpChannel_Release(&This->nsIHttpChannel_iface);
1643 }
1644 
1646 {
1648 
1649  FIXME("(%p)->()\n", This);
1650 
1651  return NS_ERROR_NOT_IMPLEMENTED;
1652 }
1653 
1655 {
1657 
1658  FIXME("(%p)->()\n", This);
1659 
1660  return NS_ERROR_NOT_IMPLEMENTED;
1661 }
1662 
1664 {
1666 
1667  FIXME("(%p)->()\n", This);
1668 
1669  return NS_ERROR_NOT_IMPLEMENTED;
1670 }
1671 
1673 {
1675 
1676  FIXME("(%p)->()\n", This);
1677 
1678  return NS_ERROR_NOT_IMPLEMENTED;
1679 }
1680 
1682 {
1684 
1685  FIXME("(%p)->()\n", This);
1686 
1687  return NS_ERROR_NOT_IMPLEMENTED;
1688 }
1689 
1691 {
1693 
1694  FIXME("(%p)->()\n", This);
1695 
1696  return NS_ERROR_NOT_IMPLEMENTED;
1697 }
1698 
1700 {
1702 
1703  FIXME("(%p)->()\n", This);
1704 
1705  return NS_ERROR_NOT_IMPLEMENTED;
1706 }
1707 
1709 {
1711 
1712  FIXME("(%p)->()\n", This);
1713 
1714  return NS_ERROR_NOT_IMPLEMENTED;
1715 }
1716 
1718 {
1720 
1721  FIXME("(%p)->()\n", This);
1722 
1723  return NS_ERROR_NOT_IMPLEMENTED;
1724 }
1725 
1727 {
1729 
1730  FIXME("(%p)->(%p)\n", This, aCanceled);
1731 
1732  return NS_ERROR_NOT_IMPLEMENTED;
1733 }
1734 
1736 {
1738 
1739  FIXME("(%p)->(%p)\n", This, aCanceled);
1740 
1741  return NS_ERROR_NOT_IMPLEMENTED;
1742 }
1743 
1745 {
1747 
1748  FIXME("(%p)->(%x)\n", This, aCanceled);
1749 
1750  return NS_ERROR_NOT_IMPLEMENTED;
1751 }
1752 
1754 {
1756 
1757  FIXME("(%p)->(%p)\n", This, aLocalAddress);
1758 
1759  return NS_ERROR_NOT_IMPLEMENTED;
1760 }
1761 
1763 {
1765 
1766  FIXME("(%p)->(%p)\n", This, aLocalPort);
1767 
1768  return NS_ERROR_NOT_IMPLEMENTED;
1769 }
1770 
1772 {
1774 
1775  FIXME("(%p)->(%p)\n", This, aRemoteAddress);
1776 
1777  return NS_ERROR_NOT_IMPLEMENTED;
1778 }
1779 
1781 {
1783 
1784  FIXME("(%p)->(%p)\n", This, aRemotePort);
1785 
1786  return NS_ERROR_NOT_IMPLEMENTED;
1787 }
1788 
1790 {
1792 
1793  FIXME("(%p)->(%p)\n", This, cacheKeys);
1794 
1795  return NS_ERROR_NOT_IMPLEMENTED;
1796 }
1797 
1799  const nsACString *aProtocolName, nsIHttpUpgradeListener *aListener)
1800 {
1802  FIXME("(%p)->(%s %p)\n", This, debugstr_nsacstr(aProtocolName), aListener);
1803  return NS_ERROR_NOT_IMPLEMENTED;
1804 }
1805 
1807 {
1809  FIXME("(%p)->(%p)\n", This, aAllowSpdy);
1810  return NS_ERROR_NOT_IMPLEMENTED;
1811 }
1812 
1814 {
1816  FIXME("(%p)->(%x)\n", This, aAllowSpdy);
1817  return NS_ERROR_NOT_IMPLEMENTED;
1818 }
1819 
1821  cpp_bool *aResponseTimeoutEnabled)
1822 {
1824  FIXME("(%p)->(%p)\n", This, aResponseTimeoutEnabled);
1825  return NS_ERROR_NOT_IMPLEMENTED;
1826 }
1827 
1829  cpp_bool aResponseTimeoutEnabled)
1830 {
1832  FIXME("(%p)->(%x)\n", This, aResponseTimeoutEnabled);
1833  return NS_ERROR_NOT_IMPLEMENTED;
1834 }
1835 
1837 {
1839  FIXME("(%p)->(%p)\n", This, aApiRedirectToURI);
1840  return NS_ERROR_NOT_IMPLEMENTED;
1841 }
1842 
1844 {
1846  FIXME("(%p)->(%p)\n", This, aAllowAltSvc);
1847  return NS_ERROR_NOT_IMPLEMENTED;
1848 }
1849 
1851 {
1853  FIXME("(%p)->(%x)\n", This, aAllowAltSvc);
1854  return NS_ERROR_NOT_IMPLEMENTED;
1855 }
1856 
1858 {
1860  FIXME("(%p)->(%p)\n", This, aPrincipal);
1861  return NS_ERROR_NOT_IMPLEMENTED;
1862 }
1863 
1865 {
1867  FIXME("(%p)->(%p)\n", This, aLastModifiedTime);
1868  return NS_ERROR_NOT_IMPLEMENTED;
1869 }
1870 
1872 {
1874  FIXME("(%p)\n", This);
1875  return NS_ERROR_NOT_IMPLEMENTED;
1876 }
1877 
1879  cpp_bool *aCorsIncludeCredentials)
1880 {
1882  FIXME("(%p)->(%p)\n", This, aCorsIncludeCredentials);
1883  return NS_ERROR_NOT_IMPLEMENTED;
1884 }
1885 
1887  cpp_bool aCorsIncludeCredentials)
1888 {
1890  FIXME("(%p)->(%x)\n", This, aCorsIncludeCredentials);
1891  return NS_ERROR_NOT_IMPLEMENTED;
1892 }
1893 
1895 {
1897  FIXME("(%p)->(%p)\n", This, aCorsMode);
1898  return NS_ERROR_NOT_IMPLEMENTED;
1899 }
1900 
1902 {
1904  FIXME("(%p)->(%d)\n", This, aCorsMode);
1905  return NS_ERROR_NOT_IMPLEMENTED;
1906 }
1907 
1909 {
1911  FIXME("(%p)->(%p)\n", This, aTopWindowURI);
1912  return NS_ERROR_NOT_IMPLEMENTED;
1913 }
1914 
1916  nsACString *aNetworkInterfaceId)
1917 {
1919  FIXME("(%p)->(%p)\n", This, aNetworkInterfaceId);
1920  return NS_ERROR_NOT_IMPLEMENTED;
1921 }
1922 
1924  const nsACString *aNetworkInterfaceId)
1925 {
1927  FIXME("(%p)->(%s)\n", This, debugstr_nsacstr(aNetworkInterfaceId));
1928  return NS_ERROR_NOT_IMPLEMENTED;
1929 }
1930 
1932 {
1934  FIXME("(%p)\n", This);
1935  return NS_ERROR_NOT_IMPLEMENTED;
1936 }
1937 
1939 {
1941  FIXME("(%p)->(%p)\n", This, aProxyURI);
1942  return NS_ERROR_NOT_IMPLEMENTED;
1943 }
1944 
1945 static const nsIHttpChannelInternalVtbl nsHttpChannelInternalVtbl = {
1986 };
1987 
1988 
1990 {
1991  if(This->uri) {
1992  IUri_Release(This->uri);
1993  This->uri = NULL;
1994  }
1995 }
1996 
1998 {
1999  if(!This->is_mutable) {
2000  WARN("Not mutable URI\n");
2001  return FALSE;
2002  }
2003 
2004  if(!This->uri_builder) {
2005  HRESULT hres;
2006 
2007  if(!ensure_uri(This))
2008  return FALSE;
2009 
2010  hres = CreateIUriBuilder(This->uri, 0, 0, &This->uri_builder);
2011  if(FAILED(hres)) {
2012  WARN("CreateIUriBuilder failed: %08x\n", hres);
2013  return FALSE;
2014  }
2015  }
2016 
2018  return TRUE;
2019 }
2020 
2021 static nsresult get_uri_string(nsWineURI *This, Uri_PROPERTY prop, nsACString *ret)
2022 {
2023  char *vala;
2024  BSTR val;
2025  HRESULT hres;
2026 
2027  if(!ensure_uri(This))
2028  return NS_ERROR_UNEXPECTED;
2029 
2030  hres = IUri_GetPropertyBSTR(This->uri, prop, &val, 0);
2031  if(FAILED(hres)) {
2032  WARN("GetPropertyBSTR failed: %08x\n", hres);
2033  return NS_ERROR_UNEXPECTED;
2034  }
2035 
2036  vala = heap_strdupWtoU(val);
2037  SysFreeString(val);
2038  if(!vala)
2039  return NS_ERROR_OUT_OF_MEMORY;
2040 
2041  TRACE("ret %s\n", debugstr_a(vala));
2042  nsACString_SetData(ret, vala);
2043  heap_free(vala);
2044  return NS_OK;
2045 }
2046 
2048 {
2049  return CONTAINING_RECORD(iface, nsWineURI, nsIFileURL_iface);
2050 }
2051 
2053 {
2055 
2056  *result = NULL;
2057 
2058  if(IsEqualGUID(&IID_nsISupports, riid)) {
2059  TRACE("(%p)->(IID_nsISupports %p)\n", This, result);
2060  *result = &This->nsIFileURL_iface;
2061  }else if(IsEqualGUID(&IID_nsIURI, riid)) {
2062  TRACE("(%p)->(IID_nsIURI %p)\n", This, result);
2063  *result = &This->nsIFileURL_iface;
2064  }else if(IsEqualGUID(&IID_nsIURL, riid)) {
2065  TRACE("(%p)->(IID_nsIURL %p)\n", This, result);
2066  *result = &This->nsIFileURL_iface;
2067  }else if(IsEqualGUID(&IID_nsIFileURL, riid)) {
2068  TRACE("(%p)->(IID_nsIFileURL %p)\n", This, result);
2069  *result = This->scheme == URL_SCHEME_FILE ? &This->nsIFileURL_iface : NULL;
2070  }else if(IsEqualGUID(&IID_nsIMutable, riid)) {
2071  TRACE("(%p)->(IID_nsIMutable %p)\n", This, result);
2072  *result = &This->nsIStandardURL_iface;
2073  }else if(IsEqualGUID(&IID_nsIStandardURL, riid)) {
2074  TRACE("(%p)->(IID_nsIStandardURL %p)\n", This, result);
2075  *result = &This->nsIStandardURL_iface;
2076  }else if(IsEqualGUID(&IID_nsWineURI, riid)) {
2077  TRACE("(%p)->(IID_nsWineURI %p)\n", This, result);
2078  *result = This;
2079  }
2080 
2081  if(*result) {
2082  nsIFileURL_AddRef(&This->nsIFileURL_iface);
2083  return NS_OK;
2084  }
2085 
2086  TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), result);
2087  return NS_NOINTERFACE;
2088 }
2089 
2091 {
2093  LONG ref = InterlockedIncrement(&This->ref);
2094 
2095  TRACE("(%p) ref=%d\n", This, ref);
2096 
2097  return ref;
2098 }
2099 
2101 {
2103  LONG ref = InterlockedDecrement(&This->ref);
2104 
2105  TRACE("(%p) ref=%d\n", This, ref);
2106 
2107  if(!ref) {
2108  if(This->window_ref)
2109  windowref_release(This->window_ref);
2110  if(This->container)
2111  nsIWebBrowserChrome_Release(&This->container->nsIWebBrowserChrome_iface);
2112  if(This->uri)
2113  IUri_Release(This->uri);
2114  heap_free(This->origin_charset);
2115  heap_free(This);
2116  }
2117 
2118  return ref;
2119 }
2120 
2122 {
2124 
2125  TRACE("(%p)->(%p)\n", This, aSpec);
2126 
2127  return get_uri_string(This, Uri_PROPERTY_DISPLAY_URI, aSpec);
2128 }
2129 
2130 static nsresult NSAPI nsURI_SetSpec(nsIFileURL *iface, const nsACString *aSpec)
2131 {
2133  const char *speca;
2134  WCHAR *spec;
2135  IUri *uri;
2136  HRESULT hres;
2137 
2138  TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aSpec));
2139 
2140  if(!This->is_mutable)
2141  return NS_ERROR_UNEXPECTED;
2142 
2143  nsACString_GetData(aSpec, &speca);
2144  spec = heap_strdupUtoW(speca);
2145  if(!spec)
2146  return NS_ERROR_OUT_OF_MEMORY;
2147 
2148  hres = create_uri(spec, 0, &uri);
2149  heap_free(spec);
2150  if(FAILED(hres)) {
2151  WARN("create_uri failed: %08x\n", hres);
2152  return NS_ERROR_FAILURE;
2153  }
2154 
2156  if(This->uri_builder) {
2157  IUriBuilder_Release(This->uri_builder);
2158  This->uri_builder = NULL;
2159  }
2160 
2161  This->uri = uri;
2162  return NS_OK;
2163 }
2164 
2166 {
2168  IUriBuilder *uri_builder;
2169  BSTR display_uri;
2170  IUri *uri;
2171  int len;
2172  nsresult nsres;
2173  HRESULT hres;
2174 
2175  TRACE("(%p)->(%p)\n", This, aPrePath);
2176 
2177  if(!ensure_uri(This))
2178  return NS_ERROR_UNEXPECTED;
2179 
2180  hres = CreateIUriBuilder(This->uri, 0, 0, &uri_builder);
2181  if(FAILED(hres))
2182  return NS_ERROR_FAILURE;
2183 
2184  hres = IUriBuilder_RemoveProperties(uri_builder, Uri_HAS_PATH|Uri_HAS_QUERY|Uri_HAS_FRAGMENT);
2185  if(SUCCEEDED(hres))
2186  hres = IUriBuilder_CreateUriSimple(uri_builder, 0, 0, &uri);
2187  IUriBuilder_Release(uri_builder);
2188  if(FAILED(hres))
2189  return NS_ERROR_FAILURE;
2190 
2191  hres = IUri_GetDisplayUri(uri, &display_uri);
2192  IUri_Release(uri);
2193  if(FAILED(hres))
2194  return NS_ERROR_FAILURE;
2195 
2196  /* Remove trailing slash that may be appended as default path. */
2197  len = SysStringLen(display_uri);
2198  if(len && display_uri[len-1] == '/')
2199  display_uri[len-1] = 0;
2200 
2201  nsres = return_wstr_nsacstr(aPrePath, display_uri, -1);
2202  SysFreeString(display_uri);
2203  return nsres;
2204 }
2205 
2207 {
2209  DWORD scheme;
2210  HRESULT hres;
2211 
2212  TRACE("(%p)->(%p)\n", This, aScheme);
2213 
2214  if(!ensure_uri(This))
2215  return NS_ERROR_UNEXPECTED;
2216 
2217  hres = IUri_GetScheme(This->uri, &scheme);
2218  if(FAILED(hres)) {
2219  WARN("GetScheme failed: %08x\n", hres);
2220  return NS_ERROR_UNEXPECTED;
2221  }
2222 
2223  if(scheme == URL_SCHEME_ABOUT) {
2224  nsACString_SetData(aScheme, "wine");
2225  return NS_OK;
2226  }
2227 
2228  return get_uri_string(This, Uri_PROPERTY_SCHEME_NAME, aScheme);
2229 }
2230 
2231 static nsresult NSAPI nsURI_SetScheme(nsIFileURL *iface, const nsACString *aScheme)
2232 {
2234  const char *schemea;
2235  WCHAR *scheme;
2236  HRESULT hres;
2237 
2238  TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aScheme));
2239 
2240  if(!ensure_uri_builder(This))
2241  return NS_ERROR_UNEXPECTED;
2242 
2243  nsACString_GetData(aScheme, &schemea);
2244  scheme = heap_strdupUtoW(schemea);
2245  if(!scheme)
2246  return NS_ERROR_OUT_OF_MEMORY;
2247 
2248  hres = IUriBuilder_SetSchemeName(This->uri_builder, scheme);
2249  heap_free(scheme);
2250  if(FAILED(hres))
2251  return NS_ERROR_UNEXPECTED;
2252 
2253  return NS_OK;
2254 }
2255 
2257 {
2259  BSTR user, pass;
2260  HRESULT hres;
2261 
2262  TRACE("(%p)->(%p)\n", This, aUserPass);
2263 
2264  if(!ensure_uri(This))
2265  return NS_ERROR_UNEXPECTED;
2266 
2267  hres = IUri_GetUserName(This->uri, &user);
2268  if(FAILED(hres))
2269  return NS_ERROR_FAILURE;
2270 
2271  hres = IUri_GetPassword(This->uri, &pass);
2272  if(FAILED(hres)) {
2274  return NS_ERROR_FAILURE;
2275  }
2276 
2277  if(*user || *pass) {
2278  FIXME("Construct user:pass string\n");
2279  }else {
2280  nsACString_SetData(aUserPass, "");
2281  }
2282 
2285  return NS_OK;
2286 }
2287 
2288 static nsresult NSAPI nsURI_SetUserPass(nsIFileURL *iface, const nsACString *aUserPass)
2289 {
2291  WCHAR *user = NULL, *pass = NULL, *buf = NULL;
2292  const char *user_pass;
2293  HRESULT hres;
2294 
2295  TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aUserPass));
2296 
2297  if(!ensure_uri_builder(This))
2298  return NS_ERROR_UNEXPECTED;
2299 
2300  nsACString_GetData(aUserPass, &user_pass);
2301  if(*user_pass) {
2302  WCHAR *ptr;
2303 
2304  buf = heap_strdupUtoW(user_pass);
2305  if(!buf)
2306  return NS_ERROR_OUT_OF_MEMORY;
2307 
2308  ptr = strchrW(buf, ':');
2309  if(!ptr) {
2310  user = buf;
2311  }else if(ptr != buf) {
2312  *ptr++ = 0;
2313  user = buf;
2314  if(*ptr)
2315  pass = ptr;
2316  }else {
2317  pass = buf+1;
2318  }
2319  }
2320 
2321  hres = IUriBuilder_SetUserName(This->uri_builder, user);
2322  if(SUCCEEDED(hres))
2323  hres = IUriBuilder_SetPassword(This->uri_builder, pass);
2324 
2325  heap_free(buf);
2326  return SUCCEEDED(hres) ? NS_OK : NS_ERROR_FAILURE;
2327 }
2328 
2330 {
2332 
2333  TRACE("(%p)->(%p)\n", This, aUsername);
2334 
2335  return get_uri_string(This, Uri_PROPERTY_USER_NAME, aUsername);
2336 }
2337 
2338 static nsresult NSAPI nsURI_SetUsername(nsIFileURL *iface, const nsACString *aUsername)
2339 {
2341  const char *usera;
2342  WCHAR *user;
2343  HRESULT hres;
2344 
2345  TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aUsername));
2346 
2347  if(!ensure_uri_builder(This))
2348  return NS_ERROR_UNEXPECTED;
2349 
2350  nsACString_GetData(aUsername, &usera);
2351  user = heap_strdupUtoW(usera);
2352  if(!user)
2353  return NS_ERROR_OUT_OF_MEMORY;
2354 
2355  hres = IUriBuilder_SetUserName(This->uri_builder, user);
2356  heap_free(user);
2357  if(FAILED(hres))
2358  return NS_ERROR_UNEXPECTED;
2359 
2360  return NS_OK;
2361 }
2362 
2364 {
2366 
2367  TRACE("(%p)->(%p)\n", This, aPassword);
2368 
2369  return get_uri_string(This, Uri_PROPERTY_PASSWORD, aPassword);
2370 }
2371 
2372 static nsresult NSAPI nsURI_SetPassword(nsIFileURL *iface, const nsACString *aPassword)
2373 {
2375  const char *passa;
2376  WCHAR *pass;
2377  HRESULT hres;
2378 
2379  TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aPassword));
2380 
2381  if(!ensure_uri_builder(This))
2382  return NS_ERROR_UNEXPECTED;
2383 
2384  nsACString_GetData(aPassword, &passa);
2385  pass = heap_strdupUtoW(passa);
2386  if(!pass)
2387  return NS_ERROR_OUT_OF_MEMORY;
2388 
2389  hres = IUriBuilder_SetPassword(This->uri_builder, pass);
2390  heap_free(pass);
2391  if(FAILED(hres))
2392  return NS_ERROR_UNEXPECTED;
2393 
2394  return NS_OK;
2395 }
2396 
2398 {
2400  const WCHAR *ptr;
2401  char *vala;
2402  BSTR val;
2403  HRESULT hres;
2404 
2405  TRACE("(%p)->(%p)\n", This, aHostPort);
2406 
2407  if(!ensure_uri(This))
2408  return NS_ERROR_UNEXPECTED;
2409 
2410  hres = IUri_GetAuthority(This->uri, &val);
2411  if(FAILED(hres)) {
2412  WARN("GetAuthority failed: %08x\n", hres);
2413  return NS_ERROR_UNEXPECTED;
2414  }
2415 
2416  ptr = strchrW(val, '@');
2417  if(!ptr)
2418  ptr = val;
2419 
2420  vala = heap_strdupWtoU(ptr);
2421  SysFreeString(val);
2422  if(!vala)
2423  return NS_ERROR_OUT_OF_MEMORY;
2424 
2425  TRACE("ret %s\n", debugstr_a(vala));
2426  nsACString_SetData(aHostPort, vala);
2427  heap_free(vala);
2428  return NS_OK;
2429 }
2430 
2431 static nsresult NSAPI nsURI_SetHostPort(nsIFileURL *iface, const nsACString *aHostPort)
2432 {
2434 
2435  WARN("(%p)->(%s)\n", This, debugstr_nsacstr(aHostPort));
2436 
2437  /* Not implemented by Gecko */
2438  return NS_ERROR_NOT_IMPLEMENTED;
2439 }
2440 
2442 {
2444 
2445  TRACE("(%p)->(%p)\n", This, aHost);
2446 
2447  return get_uri_string(This, Uri_PROPERTY_HOST, aHost);
2448 }
2449 
2450 static nsresult NSAPI nsURI_SetHost(nsIFileURL *iface, const nsACString *aHost)
2451 {
2453  const char *hosta;
2454  WCHAR *host;
2455  HRESULT hres;
2456 
2457  TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aHost));
2458 
2459  if(!ensure_uri_builder(This))
2460  return NS_ERROR_UNEXPECTED;
2461 
2462  nsACString_GetData(aHost, &hosta);
2463  host = heap_strdupUtoW(hosta);
2464  if(!host)
2465  return NS_ERROR_OUT_OF_MEMORY;
2466 
2467  hres = IUriBuilder_SetHost(This->uri_builder, host);
2468  heap_free(host);
2469  if(FAILED(hres))
2470  return NS_ERROR_UNEXPECTED;
2471 
2472  return NS_OK;
2473 }
2474 
2476 {
2478  DWORD port;
2479  HRESULT hres;
2480 
2481  TRACE("(%p)->(%p)\n", This, aPort);
2482 
2483  if(!ensure_uri(This))
2484  return NS_ERROR_UNEXPECTED;
2485 
2486  hres = IUri_GetPort(This->uri, &port);
2487  if(FAILED(hres)) {
2488  WARN("GetPort failed: %08x\n", hres);
2489  return NS_ERROR_UNEXPECTED;
2490  }
2491 
2492  *aPort = port ? port : -1;
2493  return NS_OK;
2494 }
2495 
2497 {
2499  HRESULT hres;
2500 
2501  TRACE("(%p)->(%d)\n", This, aPort);
2502 
2503  if(!ensure_uri_builder(This))
2504  return NS_ERROR_UNEXPECTED;
2505 
2506  hres = IUriBuilder_SetPort(This->uri_builder, aPort != -1, aPort);
2507  return SUCCEEDED(hres) ? NS_OK : NS_ERROR_FAILURE;
2508 }
2509 
2511 {
2513 
2514  TRACE("(%p)->(%p)\n", This, aPath);
2515 
2516  return get_uri_string(This, Uri_PROPERTY_PATH, aPath);
2517 }
2518 
2519 static nsresult NSAPI nsURI_SetPath(nsIFileURL *iface, const nsACString *aPath)
2520 {
2522  const char *patha;
2523  WCHAR *path;
2524  HRESULT hres;
2525 
2526  TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aPath));
2527 
2528  if(!ensure_uri_builder(This))
2529  return NS_ERROR_UNEXPECTED;
2530 
2531  nsACString_GetData(aPath, &patha);
2532  path = heap_strdupUtoW(patha);
2533  if(!path)
2534  return NS_ERROR_OUT_OF_MEMORY;
2535 
2536  hres = IUriBuilder_SetPath(This->uri_builder, path);
2537  heap_free(path);
2538  if(FAILED(hres))
2539  return NS_ERROR_UNEXPECTED;
2540 
2541  return NS_OK;
2542 }
2543 
2545 {
2547  nsWineURI *other_obj;
2548  nsresult nsres;
2549  HRESULT hres;
2550 
2551  TRACE("(%p)->(%p %p)\n", This, other, _retval);
2552 
2553  nsres = nsIURI_QueryInterface(other, &IID_nsWineURI, (void**)&other_obj);
2554  if(NS_FAILED(nsres)) {
2555  TRACE("Could not get nsWineURI interface\n");
2556  *_retval = FALSE;
2557  return NS_OK;
2558  }
2559 
2560  if(ensure_uri(This) && ensure_uri(other_obj)) {
2561  BOOL b;
2562 
2563  hres = IUri_IsEqual(This->uri, other_obj->uri, &b);
2564  if(SUCCEEDED(hres)) {
2565  *_retval = b;
2566  nsres = NS_OK;
2567  }else {
2568  nsres = NS_ERROR_FAILURE;
2569  }
2570  }else {
2571  nsres = NS_ERROR_UNEXPECTED;
2572  }
2573 
2574  nsIFileURL_Release(&other_obj->nsIFileURL_iface);
2575  return nsres;
2576 }
2577 
2578 static nsresult NSAPI nsURI_SchemeIs(nsIFileURL *iface, const char *scheme, cpp_bool *_retval)
2579 {
2582  BSTR scheme_name;
2583  HRESULT hres;
2584 
2585  TRACE("(%p)->(%s %p)\n", This, debugstr_a(scheme), _retval);
2586 
2587  if(!ensure_uri(This))
2588  return NS_ERROR_UNEXPECTED;
2589 
2590  hres = IUri_GetSchemeName(This->uri, &scheme_name);
2591  if(FAILED(hres))
2592  return NS_ERROR_UNEXPECTED;
2593 
2594  MultiByteToWideChar(CP_UTF8, 0, scheme, -1, buf, sizeof(buf)/sizeof(WCHAR));
2595  *_retval = !strcmpW(scheme_name, buf);
2597  return NS_OK;
2598 }
2599 
2600 static nsresult NSAPI nsURI_Clone(nsIFileURL *iface, nsIURI **_retval)
2601 {
2603  nsWineURI *wine_uri;
2604  nsresult nsres;
2605 
2606  TRACE("(%p)->(%p)\n", This, _retval);
2607 
2608  if(!ensure_uri(This))
2609  return NS_ERROR_UNEXPECTED;
2610 
2611  nsres = create_nsuri(This->uri, This->window_ref ? This->window_ref->window : NULL,
2612  This->container, This->origin_charset, &wine_uri);
2613  if(NS_FAILED(nsres)) {
2614  WARN("create_nsuri failed: %08x\n", nsres);
2615  return nsres;
2616  }
2617 
2618  *_retval = (nsIURI*)&wine_uri->nsIFileURL_iface;
2619  return NS_OK;
2620 }
2621 
2622 static nsresult NSAPI nsURI_Resolve(nsIFileURL *iface, const nsACString *aRelativePath,
2623  nsACString *_retval)
2624 {
2626  const char *patha;
2627  IUri *new_uri;
2628  WCHAR *path;
2629  char *reta;
2630  BSTR ret;
2631  HRESULT hres;
2632 
2633  TRACE("(%p)->(%s %p)\n", This, debugstr_nsacstr(aRelativePath), _retval);
2634 
2635  if(!ensure_uri(This))
2636  return NS_ERROR_UNEXPECTED;
2637 
2638  nsACString_GetData(aRelativePath, &patha);
2639  path = heap_strdupUtoW(patha);
2640  if(!path)
2641  return NS_ERROR_OUT_OF_MEMORY;
2642 
2643  hres = combine_url(This->uri, path, &new_uri);
2644  heap_free(path);
2645  if(FAILED(hres))
2646  return NS_ERROR_FAILURE;
2647 
2648  hres = IUri_GetDisplayUri(new_uri, &ret);
2649  IUri_Release(new_uri);
2650  if(FAILED(hres))
2651  return NS_ERROR_FAILURE;
2652 
2653  reta = heap_strdupWtoU(ret);
2654  SysFreeString(ret);
2655  if(!reta)
2656  return NS_ERROR_OUT_OF_MEMORY;
2657 
2658  TRACE("returning %s\n", debugstr_a(reta));
2659  nsACString_SetData(_retval, reta);
2660  heap_free(reta);
2661  return NS_OK;
2662 }
2663 
2665 {
2667 
2668  TRACE("(%p)->(%p)\n", This, aAsciiSpec);
2669 
2670  return nsIFileURL_GetSpec(&This->nsIFileURL_iface, aAsciiSpec);
2671 }
2672 
2674 {
2676 
2677  WARN("(%p)->(%p) FIXME: Use Uri_PUNYCODE_IDN_HOST flag\n", This, aAsciiHost);
2678 
2679  return get_uri_string(This, Uri_PROPERTY_HOST, aAsciiHost);
2680 }
2681 
2683 {
2685 
2686  TRACE("(%p)->(%p)\n", This, aOriginCharset);
2687 
2688  nsACString_SetData(aOriginCharset, This->origin_charset);
2689  return NS_OK;
2690 }
2691 
2693 {
2695  char *refa = NULL;
2696  BSTR ref;
2697  HRESULT hres;
2698 
2699  TRACE("(%p)->(%p)\n", This, aRef);
2700 
2701  if(!ensure_uri(This))
2702  return NS_ERROR_UNEXPECTED;
2703 
2704  hres = IUri_GetFragment(This->uri, &ref);
2705  if(FAILED(hres))
2706  return NS_ERROR_UNEXPECTED;
2707 
2708  refa = heap_strdupWtoU(ref);
2709  SysFreeString(ref);
2710  if(ref && !refa)
2711  return NS_ERROR_OUT_OF_MEMORY;
2712 
2713  nsACString_SetData(aRef, refa && *refa == '#' ? refa+1 : refa);
2714  heap_free(refa);
2715  return NS_OK;
2716 }
2717 
2718 static nsresult NSAPI nsURL_SetRef(nsIFileURL *iface, const nsACString *aRef)
2719 {
2721  const char *refa;
2722  WCHAR *ref;
2723  HRESULT hres;
2724 
2725  TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aRef));
2726 
2727  if(!ensure_uri_builder(This))
2728  return NS_ERROR_UNEXPECTED;
2729 
2730  nsACString_GetData(aRef, &refa);
2731  ref = heap_strdupUtoW(refa);
2732  if(!ref)
2733  return NS_ERROR_OUT_OF_MEMORY;
2734 
2735  hres = IUriBuilder_SetFragment(This->uri_builder, ref);
2736  heap_free(ref);
2737  if(FAILED(hres))
2738  return NS_ERROR_UNEXPECTED;
2739 
2740  return NS_OK;
2741 }
2742 
2744 {
2746  nsWineURI *other_obj;
2747  nsresult nsres;
2748 
2749  TRACE("(%p)->(%p %p)\n", This, other, _retval);
2750 
2751  nsres = nsIURI_QueryInterface(other, &IID_nsWineURI, (void**)&other_obj);
2752  if(NS_FAILED(nsres)) {
2753  TRACE("Could not get nsWineURI interface\n");
2754  *_retval = FALSE;
2755  return NS_OK;
2756  }
2757 
2758  if(ensure_uri(This) && ensure_uri(other_obj)) {
2759  *_retval = compare_ignoring_frag(This->uri, other_obj->uri);
2760  nsres = NS_OK;
2761  }else {
2762  nsres = NS_ERROR_UNEXPECTED;
2763  }
2764 
2765  nsIFileURL_Release(&other_obj->nsIFileURL_iface);
2766  return nsres;
2767 }
2768 
2770 {
2772  nsWineURI *wine_uri;
2773  IUri *uri;
2774  nsresult nsres;
2775 
2776  TRACE("(%p)->(%p)\n", This, _retval);
2777 
2778  if(!ensure_uri(This))
2779  return NS_ERROR_UNEXPECTED;
2780 
2781  uri = get_uri_nofrag(This->uri);
2782  if(!uri)
2783  return NS_ERROR_FAILURE;
2784 
2785  nsres = create_nsuri(uri, This->window_ref ? This->window_ref->window : NULL, This->container,
2786  This->origin_charset, &wine_uri);
2787  IUri_Release(uri);
2788  if(NS_FAILED(nsres)) {
2789  WARN("create_nsuri failed: %08x\n", nsres);
2790  return nsres;
2791  }
2792 
2793  *_retval = (nsIURI*)&wine_uri->nsIFileURL_iface;
2794  return NS_OK;
2795 }
2796 
2798 {
2800 
2801  FIXME("(%p)->(%p)\n", This, aSpecIgnoringRef);
2802 
2803  return nsIFileURL_GetSpec(&This->nsIFileURL_iface, aSpecIgnoringRef);
2804 }
2805 
2807 {
2809  BOOL b;
2810  HRESULT hres;
2811 
2812  TRACE("(%p)->(%p)\n", This, aHasRef);
2813 
2814  if(!ensure_uri(This))
2815  return NS_ERROR_UNEXPECTED;
2816 
2817  hres = IUri_HasProperty(This->uri, Uri_PROPERTY_FRAGMENT, &b);
2818  if(FAILED(hres))
2819  return NS_ERROR_FAILURE;
2820 
2821  *aHasRef = b;
2822  return NS_OK;
2823 }
2824 
2826 {
2828 
2829  TRACE("(%p)->(%p)\n", This, aFilePath);
2830 
2831  return nsIFileURL_GetPath(&This->nsIFileURL_iface, aFilePath);
2832 }
2833 
2834 static nsresult NSAPI nsURL_SetFilePath(nsIFileURL *iface, const nsACString *aFilePath)
2835 {
2837 
2838  TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aFilePath));
2839 
2840  if(!This->is_mutable)
2841  return NS_ERROR_UNEXPECTED;
2842 
2843  return nsIFileURL_SetPath(&This->nsIFileURL_iface, aFilePath);
2844 }
2845 
2847 {
2849  WCHAR *ptr;
2850  BSTR query;
2851  nsresult nsres;
2852  HRESULT hres;
2853 
2854  TRACE("(%p)->(%p)\n", This, aQuery);
2855 
2856  if(!ensure_uri(This))
2857  return NS_ERROR_UNEXPECTED;
2858 
2859  hres = IUri_GetQuery(This->uri, &query);
2860  if(FAILED(hres))
2861  return NS_ERROR_FAILURE;
2862 
2863  ptr = query;
2864  if(ptr && *ptr == '?')
2865  ptr++;
2866 
2867  nsres = return_wstr_nsacstr(aQuery, ptr, -1);
2869  return nsres;
2870 }
2871 
2872 static nsresult NSAPI nsURL_SetQuery(nsIFileURL *iface, const nsACString *aQuery)
2873 {
2875  const char *querya;
2876  WCHAR *query;
2877  HRESULT hres;
2878 
2879  TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aQuery));
2880 
2881  if(!ensure_uri_builder(This))
2882  return NS_ERROR_UNEXPECTED;
2883 
2884  nsACString_GetData(aQuery, &querya);
2885  query = heap_strdupUtoW(querya);
2886  if(!query)
2887  return NS_ERROR_OUT_OF_MEMORY;
2888 
2889  hres = IUriBuilder_SetQuery(This->uri_builder, query);
2890  heap_free(query);
2891  if(FAILED(hres))
2892  return NS_ERROR_UNEXPECTED;
2893 
2894  return NS_OK;
2895 }
2896 
2898 {
2899  const WCHAR *ptr;
2900  HRESULT hres;
2901 
2902  if(!ensure_uri(This))
2903  return NS_ERROR_UNEXPECTED;
2904 
2905  hres = IUri_GetPath(This->uri, path);
2906  if(FAILED(hres))
2907  return NS_ERROR_FAILURE;
2908 
2909  for(ptr = *path + SysStringLen(*path)-1; ptr > *path && *ptr != '/' && *ptr != '\\'; ptr--);
2910  if(*ptr == '/' || *ptr == '\\')
2911  ptr++;
2912  *file = ptr;
2913 
2914  if(ext) {
2915  ptr = strrchrW(ptr, '.');
2916  if(!ptr)
2917  ptr = *path + SysStringLen(*path);
2918  *ext = ptr;
2919  }
2920 
2921  return NS_OK;
2922 }
2923 
2925 {
2927  const WCHAR *file;
2928  BSTR path;
2929  nsresult nsres;
2930 
2931  TRACE("(%p)->(%p)\n", This, aDirectory);
2932 
2933  nsres = get_uri_path(This, &path, &file, NULL);
2934  if(NS_FAILED(nsres))
2935  return nsres;
2936 
2937  nsres = return_wstr_nsacstr(aDirectory, path, file-path);
2939  return nsres;
2940 }
2941 
2942 static nsresult NSAPI nsURL_SetDirectory(nsIFileURL *iface, const nsACString *aDirectory)
2943 {
2945 
2946  WARN("(%p)->(%s)\n", This, debugstr_nsacstr(aDirectory));
2947 
2948  /* Not implemented by Gecko */
2949  return NS_ERROR_NOT_IMPLEMENTED;
2950 }
2951 
2953 {
2955  const WCHAR *file;
2956  BSTR path;
2957  nsresult nsres;
2958 
2959  TRACE("(%p)->(%p)\n", This, aFileName);
2960 
2961  nsres = get_uri_path(This, &path, &file, NULL);
2962  if(NS_FAILED(nsres))
2963  return nsres;
2964 
2965  nsres = return_wstr_nsacstr(aFileName, file, -1);
2967  return nsres;
2968 }
2969 
2970 static nsresult NSAPI nsURL_SetFileName(nsIFileURL *iface, const nsACString *aFileName)
2971 {
2973  FIXME("(%p)->(%s)\n", This, debugstr_nsacstr(aFileName));
2974  return NS_ERROR_NOT_IMPLEMENTED;
2975 }
2976 
2978 {
2980  const WCHAR *file, *ext;
2981  BSTR path;
2982  nsresult nsres;
2983 
2984  TRACE("(%p)->(%p)\n", This, aFileBaseName);
2985 
2986  nsres = get_uri_path(This, &path, &file, &ext);
2987  if(NS_FAILED(nsres))
2988  return nsres;
2989 
2990  nsres = return_wstr_nsacstr(aFileBaseName, file, ext-file);
2992  return nsres;
2993 }
2994 
2995 static nsresult NSAPI nsURL_SetFileBaseName(nsIFileURL *iface, const nsACString *aFileBaseName)
2996 {
2998  FIXME("(%p)->(%s)\n", This, debugstr_nsacstr(aFileBaseName));
2999  return NS_ERROR_NOT_IMPLEMENTED;
3000 }
3001 
3003 {
3005 
3006  TRACE("(%p)->(%p)\n", This, aFileExtension);
3007 
3008  return get_uri_string(This, Uri_PROPERTY_EXTENSION, aFileExtension);
3009 }
3010 
3011 static nsresult NSAPI nsURL_SetFileExtension(nsIFileURL *iface, const nsACString *aFileExtension)
3012 {
3014  FIXME("(%p)->(%s)\n", This, debugstr_nsacstr(aFileExtension));
3015  return NS_ERROR_NOT_IMPLEMENTED;
3016 }
3017 
3018 static nsresult NSAPI nsURL_GetCommonBaseSpec(nsIFileURL *iface, nsIURI *aURIToCompare, nsACString *_retval)
3019 {
3021  FIXME("(%p)->(%p %p)\n", This, aURIToCompare, _retval);
3022  return NS_ERROR_NOT_IMPLEMENTED;
3023 }
3024 
3025 static nsresult NSAPI nsURL_GetRelativeSpec(nsIFileURL *iface, nsIURI *aURIToCompare, nsACString *_retval)
3026 {
3028  FIXME("(%p)->(%p %p)\n", This, aURIToCompare, _retval);
3029  return NS_ERROR_NOT_IMPLEMENTED;
3030 }
3031 
3033 {
3035  WCHAR path[MAX_PATH];
3036  DWORD size;
3037  HRESULT hres;
3038 
3039  TRACE("(%p)->(%p)\n", This, aFile);
3040 
3041  hres = CoInternetParseIUri(This->uri, PARSE_PATH_FROM_URL, 0, path, sizeof(path)/sizeof(WCHAR), &size, 0);
3042  if(FAILED(hres)) {
3043  WARN("CoInternetParseIUri failed: %08x\n", hres);
3044  return NS_ERROR_FAILURE;
3045  }
3046 
3047  return create_nsfile(path, aFile);
3048 }
3049 
3051 {
3053  FIXME("(%p)->(%p)\n", This, aFile);
3054  return NS_ERROR_NOT_IMPLEMENTED;
3055 }
3056 
3057 static const nsIFileURLVtbl nsFileURLVtbl = {
3059  nsURI_AddRef,
3060  nsURI_Release,
3061  nsURI_GetSpec,
3062  nsURI_SetSpec,
3074  nsURI_GetHost,
3075  nsURI_SetHost,
3076  nsURI_GetPort,
3077  nsURI_SetPort,
3078  nsURI_GetPath,
3079  nsURI_SetPath,
3080  nsURI_Equals,
3082  nsURI_Clone,
3083  nsURI_Resolve,
3087  nsURL_GetRef,
3088  nsURL_SetRef,
3109 };
3110 
3112 {
3113  return CONTAINING_RECORD(iface, nsWineURI, nsIStandardURL_iface);
3114 }
3115 
3117  void **result)
3118 {
3120  return nsIFileURL_QueryInterface(&This->nsIFileURL_iface, riid, result);
3121 }
3122 
3124 {
3126  return nsIFileURL_AddRef(&This->nsIFileURL_iface);
3127 }
3128 
3130 {
3132  return nsIFileURL_Release(&This->nsIFileURL_iface);
3133 }
3134 
3136 {
3138 
3139  TRACE("(%p)->(%p)\n", This, aMutable);
3140 
3141  *aMutable = This->is_mutable;
3142  return NS_OK;
3143 }
3144 
3146 {
3148 
3149  TRACE("(%p)->(%x)\n", This, aMutable);
3150 
3151  This->is_mutable = aMutable;
3152  return NS_OK;
3153 }
3154 
3155 static nsresult NSAPI nsStandardURL_Init(nsIStandardURL *iface, UINT32 aUrlType, LONG aDefaultPort,
3156  const nsACString *aSpec, const char *aOriginCharset, nsIURI *aBaseURI)
3157 {
3159  FIXME("(%p)->(%d %d %s %s %p)\n", This, aUrlType, aDefaultPort, debugstr_nsacstr(aSpec), debugstr_a(aOriginCharset), aBaseURI);
3160  return NS_ERROR_NOT_IMPLEMENTED;
3161 }
3162 
3163 static const nsIStandardURLVtbl nsStandardURLVtbl = {
3170 };
3171 
3173  const char *origin_charset, nsWineURI **_retval)
3174 {
3175  nsWineURI *ret;
3176  HRESULT hres;
3177 
3178  ret = heap_alloc_zero(sizeof(nsWineURI));
3179  if(!ret)
3180  return NS_ERROR_OUT_OF_MEMORY;
3181 
3182  ret->nsIFileURL_iface.lpVtbl = &nsFileURLVtbl;
3183  ret->nsIStandardURL_iface.lpVtbl = &nsStandardURLVtbl;
3184  ret->ref = 1;
3185  ret->is_mutable = TRUE;
3186 
3189 
3190  IUri_AddRef(iuri);
3191  ret->uri = iuri;
3192 
3193  hres = IUri_GetScheme(iuri, &ret->scheme);
3194  if(FAILED(hres))
3195  ret->scheme = URL_SCHEME_UNKNOWN;
3196 
3197  if(origin_charset && *origin_charset && strcmp(origin_charset, "UTF-8")) {
3198  ret->origin_charset = heap_strdupA(origin_charset);
3199  if(!ret->origin_charset) {
3200  nsIFileURL_Release(&ret->nsIFileURL_iface);
3201  return NS_ERROR_OUT_OF_MEMORY;
3202  }
3203  }
3204 
3205  TRACE("retval=%p\n", ret);
3206  *_retval = ret;
3207  return NS_OK;
3208 }
3209 
3211 {
3212  nsWineURI *uri;
3213  nsresult nsres;
3214 
3215  nsres = create_nsuri(iuri, window, window->doc_obj->nscontainer, NULL, &uri);
3216  if(NS_FAILED(nsres))
3217  return E_FAIL;
3218 
3219  uri->is_doc_uri = TRUE;
3220 
3221  *ret = uri;
3222  return S_OK;
3223 }
3224 
3226 {
3227  nsChannel *channel;
3228 
3229  if(!ensure_uri(uri))
3230  return NS_ERROR_UNEXPECTED;
3231 
3232  channel = heap_alloc_zero(sizeof(nsChannel));
3233  if(!channel)
3234  return NS_ERROR_OUT_OF_MEMORY;
3235 
3236  channel->nsIHttpChannel_iface.lpVtbl = &nsChannelVtbl;
3237  channel->nsIUploadChannel_iface.lpVtbl = &nsUploadChannelVtbl;
3239  channel->ref = 1;
3240  channel->request_method = METHOD_GET;
3241  list_init(&channel->response_headers);
3242  list_init(&channel->request_headers);
3243 
3244  nsIFileURL_AddRef(&uri->nsIFileURL_iface);
3245  channel->uri = uri;
3246 
3247  *ret = channel;
3248  return NS_OK;
3249 }
3250 
3252 {
3254  nsChannel *channel;
3255  nsWineURI *uri;
3256  IUri *iuri;
3257  nsresult nsres;
3258  HRESULT hres;
3259 
3260  hres = create_uri(url, 0, &iuri);
3261  if(FAILED(hres))
3262  return hres;
3263 
3264  if(orig_channel->uri->window_ref)
3265  window = orig_channel->uri->window_ref->window;
3266  nsres = create_nsuri(iuri, window, NULL, NULL, &uri);
3267  IUri_Release(iuri);
3268  if(NS_FAILED(nsres))
3269  return E_FAIL;
3270 
3271  nsres = create_nschannel(uri, &channel);
3272  nsIFileURL_Release(&uri->nsIFileURL_iface);
3273  if(NS_FAILED(nsres))
3274  return E_FAIL;
3275 
3276  if(orig_channel->load_group) {
3277  nsILoadGroup_AddRef(orig_channel->load_group);
3278  channel->load_group = orig_channel->load_group;
3279  }
3280 
3281  if(orig_channel->notif_callback) {
3282  nsIInterfaceRequestor_AddRef(orig_channel->notif_callback);
3283  channel->notif_callback = orig_channel->notif_callback;
3284  }
3285 
3286  channel->load_flags = orig_channel->load_flags | LOAD_REPLACE;
3287 
3288  if(orig_channel->request_method == METHOD_POST)
3289  FIXME("unsupported POST method\n");
3290 
3291  if(orig_channel->original_uri) {
3292  nsIURI_AddRef(orig_channel->original_uri);
3293  channel->original_uri = orig_channel->original_uri;
3294  }
3295 
3296  if(orig_channel->referrer) {
3297  nsIURI_AddRef(orig_channel->referrer);
3298  channel->referrer = orig_channel->referrer;
3299  }
3300 
3301  *ret = channel;
3302  return S_OK;
3303 }
3304 
3305 typedef struct {
3307 
3309 
3312 
3314 {
3315  return CONTAINING_RECORD(iface, nsProtocolHandler, nsIProtocolHandler_iface);
3316 }
3317 
3319  void **result)
3320 {
3322 
3323  *result = NULL;
3324 
3325  if(IsEqualGUID(&IID_nsISupports, riid)) {
3326  TRACE("(%p)->(IID_nsISupports %p)\n", This, result);
3327  *result = &This->nsIProtocolHandler_iface;
3328  }else if(IsEqualGUID(&IID_nsIProtocolHandler, riid)) {
3329  TRACE("(%p)->(IID_nsIProtocolHandler %p)\n", This, result);
3330  *result = &This->nsIProtocolHandler_iface;
3331  }else if(IsEqualGUID(&IID_nsIExternalProtocolHandler, riid)) {
3332  TRACE("(%p)->(IID_nsIExternalProtocolHandler %p), returning NULL\n", This, result);
3333  return NS_NOINTERFACE;
3334  }
3335 
3336  if(*result) {
3337  nsISupports_AddRef((nsISupports*)*result);
3338  return NS_OK;
3339  }
3340 
3341  WARN("(%s %p)\n", debugstr_guid(riid), result);
3342  return NS_NOINTERFACE;
3343 }
3344 
3346 {
3348  LONG ref = InterlockedIncrement(&This->ref);
3349 
3350  TRACE("(%p) ref=%d\n", This, ref);
3351 
3352  return ref;
3353 }
3354 
3356 {
3358  LONG ref = InterlockedDecrement(&This->ref);
3359 
3360  TRACE("(%p) ref=%d\n", This, ref);
3361 
3362  if(!ref) {
3363  if(This->nshandler)
3364  nsIProtocolHandler_Release(This->nshandler);
3365  heap_free(This);
3366  }
3367 
3368  return ref;
3369 }
3370 
3372 {
3374 
3375  TRACE("(%p)->(%p)\n", This, aScheme);
3376 
3377  if(This->nshandler)
3378  return nsIProtocolHandler_GetScheme(This->nshandler, aScheme);
3379  return NS_ERROR_NOT_IMPLEMENTED;
3380 }
3381 
3383  LONG *aDefaultPort)
3384 {
3386 
3387  TRACE("(%p)->(%p)\n", This, aDefaultPort);
3388 
3389  if(This->nshandler)
3390  return nsIProtocolHandler_GetDefaultPort(This->nshandler, aDefaultPort);
3391  return NS_ERROR_NOT_IMPLEMENTED;
3392 }
3393 
3395  UINT32 *aProtocolFlags)
3396 {
3398 
3399  TRACE("(%p)->(%p)\n", This, aProtocolFlags);
3400 
3401  if(This->nshandler)
3402  return nsIProtocolHandler_GetProtocolFlags(This->nshandler, aProtocolFlags);
3403  return NS_ERROR_NOT_IMPLEMENTED;
3404 }
3405 
3407  const nsACString *aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval)
3408 {
3410 
3411  TRACE("((%p)->%s %s %p %p)\n", This, debugstr_nsacstr(aSpec), debugstr_a(aOriginCharset),
3412  aBaseURI, _retval);
3413 
3414  if(This->nshandler)
3415  return nsIProtocolHandler_NewURI(This->nshandler, aSpec, aOriginCharset, aBaseURI, _retval);
3416  return NS_ERROR_NOT_IMPLEMENTED;
3417 }
3418 
3420  nsIURI *aURI, nsILoadInfo *aLoadInfo, nsIChannel **_retval)
3421 {
3423 
3424  TRACE("(%p)->(%p %p %p)\n", This, aURI, aLoadInfo, _retval);
3425 
3426  if(This->nshandler)
3427  return nsIProtocolHandler_NewChannel2(This->nshandler, aURI, aLoadInfo, _retval);
3428  return NS_ERROR_NOT_IMPLEMENTED;
3429 }
3430 
3432  nsIURI *aURI, nsIChannel **_retval)
3433 {
3435 
3436  TRACE("(%p)->(%p %p)\n", This, aURI, _retval);
3437 
3438  if(This->nshandler)
3439  return nsIProtocolHandler_NewChannel(This->nshandler, aURI, _retval);
3440  return NS_ERROR_NOT_IMPLEMENTED;
3441 }
3442 
3444  LONG port, const char *scheme, cpp_bool *_retval)
3445 {
3447 
3448  TRACE("(%p)->(%d %s %p)\n", This, port, debugstr_a(scheme), _retval);
3449 
3450  if(This->nshandler)
3451  return nsIProtocolHandler_AllowPort(This->nshandler, port, scheme, _retval);
3452  return NS_ERROR_NOT_IMPLEMENTED;
3453 }
3454 
3455 static const nsIProtocolHandlerVtbl nsProtocolHandlerVtbl = {
3466 };
3467 
3469 
3471 {
3472  return 2;
3473 }
3474 
3476 {
3477  return 1;
3478 }
3479 
3480 static nsresult NSAPI nsIOService_GetProtocolHandler(nsIIOService *iface, const char *aScheme,
3481  nsIProtocolHandler **_retval)
3482 {
3483  nsIExternalProtocolHandler *nsexthandler;
3484  nsIProtocolHandler *nshandler;
3486  nsresult nsres;
3487 
3488  TRACE("(%s %p)\n", debugstr_a(aScheme), _retval);
3489 
3490  nsres = nsIIOService_GetProtocolHandler(nsio, aScheme, &nshandler);
3491  if(NS_FAILED(nsres)) {
3492  WARN("GetProtocolHandler failed: %08x\n", nsres);
3493  return nsres;
3494  }
3495 
3496  nsres = nsIProtocolHandler_QueryInterface(nshandler, &IID_nsIExternalProtocolHandler,
3497  (void**)&nsexthandler);
3498  if(NS_FAILED(nsres)) {
3499  *_retval = nshandler;
3500  return NS_OK;
3501  }
3502 
3503  nsIExternalProtocolHandler_Release(nsexthandler);
3504 
3505  ret = heap_alloc(sizeof(nsProtocolHandler));
3506  if(!ret)
3507  return NS_ERROR_OUT_OF_MEMORY;
3508 
3509  ret->nsIProtocolHandler_iface.lpVtbl = &nsProtocolHandlerVtbl;
3510  ret->ref = 1;
3511  ret->nshandler = nshandler;
3512  *_retval = &ret->nsIProtocolHandler_iface;
3513 
3514  TRACE("return %p\n", *_retval);
3515  return NS_OK;
3516 }
3517 
3518 static nsresult NSAPI nsIOService_GetProtocolFlags(nsIIOService *iface, const char *aScheme,
3519  UINT32 *_retval)
3520 {
3521  TRACE("(%s %p)\n", debugstr_a(aScheme), _retval);
3522  return nsIIOService_GetProtocolFlags(nsio, aScheme, _retval);
3523 }
3524 
3525 static BOOL is_gecko_special_uri(const char *spec)
3526 {
3527  static const char *special_schemes[] = {"chrome:", "data:", "jar:", "moz-safe-about", "resource:", "javascript:", "wyciwyg:"};
3528  unsigned int i;
3529 
3530  for(i=0; i < sizeof(special_schemes)/sizeof(*special_schemes); i++) {
3531  if(!strncasecmp(spec, special_schemes[i], strlen(special_schemes[i])))
3532  return TRUE;
3533  }
3534 
3535  if(!strncasecmp(spec, "file:", 5)) {
3536  const char *ptr = spec+5;
3537  while(*ptr == '/')
3538  ptr++;
3539  return is_gecko_path(ptr);
3540  }
3541 
3542  return FALSE;
3543 }
3544 
3546  const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval)
3547 {
3548  nsWineURI *wine_uri, *base_wine_uri = NULL;
3549  WCHAR new_spec[INTERNET_MAX_URL_LENGTH];
3551  const char *spec = NULL;
3552  UINT cp = CP_UTF8;
3553  IUri *urlmon_uri;
3554  nsresult nsres;
3555  HRESULT hres;
3556 
3557  TRACE("(%s %s %p %p)\n", debugstr_nsacstr(aSpec), debugstr_a(aOriginCharset),
3558  aBaseURI, _retval);
3559 
3560  nsACString_GetData(aSpec, &spec);
3561  if(is_gecko_special_uri(spec))
3562  return nsIIOService_NewURI(nsio, aSpec, aOriginCharset, aBaseURI, _retval);
3563 
3564  if(!strncmp(spec, "wine:", 5))
3565  spec += 5;
3566 
3567  if(aBaseURI) {
3568  nsres = nsIURI_QueryInterface(aBaseURI, &IID_nsWineURI, (void**)&base_wine_uri);
3569  if(NS_SUCCEEDED(nsres)) {
3570  if(!ensure_uri(base_wine_uri))
3571  return NS_ERROR_UNEXPECTED;
3572  if(base_wine_uri->window_ref)
3573  window = base_wine_uri->window_ref->window;
3574  }else {
3575  WARN("Could not get base nsWineURI: %08x\n", nsres);
3576  }
3577  }
3578 
3579  if(aOriginCharset && *aOriginCharset && strncasecmp(aOriginCharset, "utf", 3)) {
3580  BSTR charset;
3581  int len;
3582 
3583  len = MultiByteToWideChar(CP_UTF8, 0, aOriginCharset, -1, NULL, 0);
3585  if(!charset)
3586  return NS_ERROR_OUT_OF_MEMORY;
3587  MultiByteToWideChar(CP_UTF8, 0, aOriginCharset, -1, charset, len);
3588 
3590 
3592  }
3593 
3594  MultiByteToWideChar(cp, 0, spec, -1, new_spec, sizeof(new_spec)/sizeof(WCHAR));
3595 
3596  if(base_wine_uri) {
3597  hres = combine_url(base_wine_uri->uri, new_spec, &urlmon_uri);
3598  }else {
3599  hres = create_uri(new_spec, 0, &urlmon_uri);
3600  if(FAILED(hres))
3601  WARN("create_uri failed: %08x\n", hres);
3602  }
3603 
3604  if(FAILED(hres))
3605  return nsIIOService_NewURI(nsio, aSpec, aOriginCharset, aBaseURI, _retval);
3606 
3607  nsres = create_nsuri(urlmon_uri, window, NULL, NULL, &wine_uri);
3608  IUri_Release(urlmon_uri);
3609  if(base_wine_uri)
3610  nsIFileURL_Release(&base_wine_uri->nsIFileURL_iface);
3611  if(NS_FAILED(nsres))
3612  return nsres;
3613 
3614  *_retval = (nsIURI*)&wine_uri->nsIFileURL_iface;
3615  return nsres;
3616 }
3617 
3619  nsIURI **_retval)
3620 {
3621  TRACE("(%p %p)\n", aFile, _retval);
3622  return nsIIOService_NewFileURI(nsio, aFile, _retval);
3623 }
3624 
3626 {
3627  nsWineURI *wine_uri;
3628  nsChannel *ret;
3629  nsresult nsres;
3630 
3631  nsres = nsIURI_QueryInterface(uri, &IID_nsWineURI, (void**)&wine_uri);
3632  if(NS_FAILED(nsres)) {
3633  TRACE("Could not get nsWineURI: %08x\n", nsres);
3634  return nsIIOService_NewChannelFromURI(nsio, uri, _retval);
3635  }
3636 
3637  nsres = create_nschannel(wine_uri, &ret);
3638  nsIFileURL_Release(&wine_uri->nsIFileURL_iface);
3639  if(NS_FAILED(nsres))
3640  return nsres;
3641 
3642  nsIURI_AddRef(uri);
3643  ret->original_uri = uri;
3644 
3645  if(load_info)
3646  nsIHttpChannel_SetLoadInfo(&ret->nsIHttpChannel_iface, load_info);
3647 
3648  *_retval = (nsIChannel*)&ret->nsIHttpChannel_iface;
3649  return NS_OK;
3650 }
3651 
3653  nsIDOMNode *aLoadingNode, nsIPrincipal *aLoadingPrincipal, nsIPrincipal *aTriggeringPrincipal,
3654  UINT32 aSecurityFlags, UINT32 aContentPolicyType, nsIChannel **_retval)
3655 {
3656  nsILoadInfo *load_info = NULL;
3657  nsresult nsres;
3658 
3659  TRACE("(%p %p %p %p %x %d %p)\n", aURI, aLoadingNode, aLoadingPrincipal, aTriggeringPrincipal,
3660  aSecurityFlags, aContentPolicyType, _retval);
3661 
3662  if(aLoadingNode || aLoadingPrincipal) {
3663  nsres = nsIIOService_NewLoadInfo(nsio, aLoadingPrincipal, aTriggeringPrincipal, aLoadingNode,
3664  aSecurityFlags, aContentPolicyType, &load_info);
3665  assert(nsres == NS_OK);
3666  }
3667 
3668  nsres = new_channel_from_uri(aURI, load_info, _retval);
3669  if(load_info)
3670  nsISupports_Release(load_info);
3671  return nsres;
3672 }
3673 
3675  nsILoadInfo *aLoadInfo, nsIChannel **_retval)
3676 {
3677  TRACE("(%p %p %p)\n", aURI, aLoadInfo, _retval);
3678  return new_channel_from_uri(aURI, aLoadInfo, _retval);
3679 }
3680 
3682  nsIChannel **_retval)
3683 {
3684  TRACE("(%p %p)\n", aURI, _retval);
3685  return new_channel_from_uri(aURI, NULL, _retval);
3686 }
3687 
3689  const char *aOriginCharset, nsIURI *aBaseURI, nsIDOMNode *aLoadingNode, nsIPrincipal *aLoadingPrincipal,
3690  nsIPrincipal *aTriggeringPrincipal, UINT32 aSecurityFlags, UINT32 aContentPolicyType, nsIChannel **_retval)
3691 {
3692  TRACE("(%s %s %p %p %p %p %x %d %p)\n", debugstr_nsacstr(aSpec), debugstr_a(aOriginCharset), aBaseURI,
3693  aLoadingNode, aLoadingPrincipal, aTriggeringPrincipal, aSecurityFlags, aContentPolicyType, _retval);
3694  return nsIIOService_NewChannel2(nsio, aSpec, aOriginCharset, aBaseURI, aLoadingNode, aLoadingPrincipal,
3695  aTriggeringPrincipal, aSecurityFlags, aContentPolicyType, _retval);
3696 }
3697 
3699  const char *aOriginCharset, nsIURI *aBaseURI, nsIChannel **_retval)
3700 {
3701  TRACE("(%s %s %p %p)\n", debugstr_nsacstr(aSpec), debugstr_a(aOriginCharset), aBaseURI, _retval);
3702  return nsIIOService_NewChannel(nsio, aSpec, aOriginCharset, aBaseURI, _retval);
3703 }
3704 
3706 {
3707  TRACE("(%p)\n", aOffline);
3708  return nsIIOService_GetOffline(nsio, aOffline);
3709 }
3710 
3712 {
3713  TRACE("(%x)\n", aOffline);
3714  return nsIIOService_SetOffline(nsio, aOffline);
3715 }
3716 
3718 {
3719  TRACE("(%p)\n", aConnectivity);
3720  return nsIIOService_GetConnectivity(nsio, aConnectivity);
3721 }
3722 
3724 {
3725  TRACE("(%d %x)\n", appId, state);
3726  return nsIIOService_SetAppOffline(nsio, appId, state);
3727 }
3728 
3730 {
3731  TRACE("(%u %p)\n", appId, _retval);
3732  return nsIIOService_IsAppOffline(nsio, appId, _retval);
3733 }
3734 
3736 {
3737  TRACE("(%d %p)\n", appId, _retval);
3738  return nsIIOService_GetAppOfflineState(nsio, appId, _retval);
3739 }
3740 
3742  const char *aScheme, cpp_bool *_retval)
3743 {
3744  TRACE("(%d %s %p)\n", aPort, debugstr_a(aScheme), _retval);
3745  return nsIIOService_AllowPort(nsio, aPort, debugstr_a(aScheme), _retval);
3746 }
3747 
3749  nsACString * _retval)
3750 {
3751  TRACE("(%s %p)\n", debugstr_nsacstr(urlString), _retval);
3752  return nsIIOService_ExtractScheme(nsio, urlString, _retval);
3753 }
3754 
3755 static const nsIIOServiceVtbl nsIOServiceVtbl = {
3776 };
3777 
3779 
3781  void **result)
3782 {
3783  return nsIIOService_QueryInterface(&nsIOService, riid, result);
3784 }
3785 
3787 {
3788  return 2;
3789 }
3790 
3792 {
3793  return 1;
3794 }
3795 
3797  nsACString *aCharset, cpp_bool *aHadCharset, nsACString *aContentType)
3798 {
3799  TRACE("(%s %p %p %p)\n", debugstr_nsacstr(aTypeHeader), aCharset, aHadCharset, aContentType);
3800 
3801  return nsINetUtil_ParseContentType(net_util, aTypeHeader, aCharset, aHadCharset, aContentType);
3802 }
3803 
3805 {
3806  switch(flags) {
3807 #define X(f) case f: return #f
3808  X(URI_STD);
3809  X(URI_NORELATIVE);
3810  X(URI_NOAUTH);
3811  X(ALLOWS_PROXY);
3812  X(ALLOWS_PROXY_HTTP);
3813  X(URI_INHERITS_SECURITY_CONTEXT);
3814  X(URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT);
3815  X(URI_LOADABLE_BY_ANYONE);
3816  X(URI_DANGEROUS_TO_LOAD);
3817  X(URI_IS_UI_RESOURCE);
3818  X(URI_IS_LOCAL_FILE);
3819  X(URI_LOADABLE_BY_SUBSUMERS);
3820  X(URI_DOES_NOT_RETURN_DATA);
3821  X(URI_IS_LOCAL_RESOURCE);
3822  X(URI_OPENING_EXECUTES_SCRIPT);
3823  X(URI_NON_PERSISTABLE);
3824  X(URI_FORBIDS_COOKIE_ACCESS);
3825  X(URI_CROSS_ORIGIN_NEEDS_WEBAPPS_PERM);
3826  X(URI_SYNC_LOAD_IS_OK);
3827  X(URI_SAFE_TO_LOAD_IN_SECURE_CONTEXT);
3828 #undef X
3829  default:
3830  return wine_dbg_sprintf("%08x", flags);
3831  }
3832 }
3833 
3835 {
3836  TRACE("(%p %s %p)\n", aURI, debugstr_protocol_flags(aFlags), _retval);
3837 
3838  return nsINetUtil_ProtocolHasFlags(net_util, aURI, aFlags, _retval);
3839 }
3840 
3842 {
3843  TRACE("(%p %s %p)\n", aURI, debugstr_protocol_flags(aFlags), _retval);
3844 
3845  if(aFlags == URI_DOES_NOT_RETURN_DATA) {
3846  *_retval = FALSE;
3847  return NS_OK;
3848  }
3849 
3850  return nsINetUtil_URIChainHasFlags(net_util, aURI, aFlags, _retval);
3851 }
3852 
3854 {
3855  TRACE("(%p %p)\n", aURI, _retval);
3856 
3857  return nsINetUtil_ToImmutableURI(net_util, aURI, _retval);
3858 }
3859 
3861 {
3862  TRACE("(%p %p)\n", aURI, _retval);
3863 
3864  return nsINetUtil_NewSimpleNestedURI(net_util, aURI, _retval);
3865 }
3866 
3868  UINT32 aEscapeType, nsACString *_retval)
3869 {
3870  TRACE("(%s %x %p)\n", debugstr_nsacstr(aString), aEscapeType, _retval);
3871 
3872  return nsINetUtil_EscapeString(net_util, aString, aEscapeType, _retval);
3873 }
3874 
3875 static nsresult NSAPI nsNetUtil_EscapeURL(nsINetUtil *iface, const nsACString *aStr, UINT32 aFlags,
3876  nsACString *_retval)
3877 {
3878  TRACE("(%s %08x %p)\n", debugstr_nsacstr(aStr), aFlags, _retval);
3879 
3880  return nsINetUtil_EscapeURL(net_util, aStr, aFlags, _retval);
3881 }
3882 
3884  UINT32 aFlags, nsACString *_retval)
3885 {
3886  TRACE("(%s %08x %p)\n", debugstr_nsacstr(aStr), aFlags, _retval);
3887 
3888  return nsINetUtil_UnescapeString(net_util, aStr, aFlags, _retval);
3889 }
3890 
3892  nsACString *aCharset, LONG *aCharsetStart, LONG *aCharsetEnd, cpp_bool *_retval)
3893 {
3894  TRACE("(%s %p %p %p %p)\n", debugstr_nsacstr(aTypeHeader), aCharset, aCharsetStart,
3895  aCharsetEnd, _retval);
3896 
3897  return nsINetUtil_ExtractCharsetFromContentType(net_util, aTypeHeader, aCharset, aCharsetStart, aCharsetEnd, _retval);
3898 }
3899 
3900 static const nsINetUtilVtbl nsNetUtilVtbl = {
3913 };
3914 
3916 
3918  void **result)
3919 {
3920  *result = NULL;
3921 
3922  if(IsEqualGUID(&IID_nsISupports, riid))
3923  *result = &nsIOService;
3924  else if(IsEqualGUID(&IID_nsIIOService, riid))
3925  *result = &nsIOService;
3926  else if(IsEqualGUID(&IID_nsINetUtil, riid))
3927  *result = &nsNetUtil;
3928 
3929  if(*result) {
3930  nsISupports_AddRef((nsISupports*)*result);
3931  return NS_OK;
3932  }
3933 
3934  FIXME("(%s %p)\n", debugstr_guid(riid), result);
3935  return NS_NOINTERFACE;
3936 }
3937 
3939  void **result)
3940 {
3941  *result = NULL;
3942 
3943  if(IsEqualGUID(&IID_nsISupports, riid)) {
3944  TRACE("(IID_nsISupports %p)\n", result);
3945  *result = iface;
3946  }else if(IsEqualGUID(&IID_nsIFactory, riid)) {
3947  TRACE("(IID_nsIFactory %p)\n", result);
3948  *result = iface;
3949  }
3950 
3951  if(*result) {
3952  nsIFactory_AddRef(iface);
3953  return NS_OK;
3954  }
3955 
3956  WARN("(%s %p)\n", debugstr_guid(riid), result);
3957  return NS_NOINTERFACE;
3958 }
3959 
3961 {
3962  return 2;
3963 }
3964 
3966 {
3967  return 1;
3968 }
3969 
3971  nsISupports *aOuter, const nsIID *iid, void **result)
3972 {
3973  return nsIIOService_QueryInterface(&nsIOService, iid, result);
3974 }
3975 
3977 {
3978  WARN("(%x)\n", lock);
3979  return NS_OK;
3980 }
3981 
3982 static const nsIFactoryVtbl nsIOServiceFactoryVtbl = {
3988 };
3989 
3991 
3993 {
3994  OLECHAR *new_url = NULL;
3995  WCHAR *url;
3996  BOOL ret = FALSE;
3997  HRESULT hres;
3998 
3999  if(!doc->hostui || !ensure_uri(uri))
4000  return FALSE;
4001 
4002  hres = IUri_GetDisplayUri(uri->uri, &url);
4003  if(FAILED(hres))
4004  return FALSE;
4005 
4006  hres = IDocHostUIHandler_TranslateUrl(doc->hostui, 0, url, &new_url);
4007  if(hres == S_OK && new_url) {
4008  if(strcmpW(url, new_url)) {
4009  FIXME("TranslateUrl returned new URL %s -> %s\n", debugstr_w(url), debugstr_w(new_url));
4010  ret = TRUE;
4011  }
4012  CoTaskMemFree(new_url);
4013  }
4014 
4015  SysFreeString(url);
4016  return ret;
4017 }
4018 
4020 {
4021  nsWineURI *wine_uri;
4022  nsresult nsres;
4023 
4024  *_retval = FALSE;
4025 
4026  nsres = nsIURI_QueryInterface(uri, &IID_nsWineURI, (void**)&wine_uri);
4027  if(NS_FAILED(nsres)) {
4028  WARN("Could not get nsWineURI: %08x\n", nsres);
4029  return NS_ERROR_NOT_IMPLEMENTED;
4030  }
4031 
4032  if(!wine_uri->is_doc_uri) {
4033  wine_uri->is_doc_uri = TRUE;
4034 
4035  if(!wine_uri->container) {
4036  nsIWebBrowserChrome_AddRef(&nscontainer->nsIWebBrowserChrome_iface);
4037  wine_uri->container = nscontainer;
4038  }
4039 
4040  if(nscontainer->doc)
4041  *_retval = translate_url(nscontainer->doc, wine_uri);
4042  }
4043 
4044  nsIFileURL_Release(&wine_uri->nsIFileURL_iface);
4045  return NS_OK;
4046 }
4047 
4048 void init_nsio(nsIComponentManager *component_manager, nsIComponentRegistrar *registrar)
4049 {
4050  nsIFactory *old_factory = NULL;
4051  nsresult nsres;
4052 
4053  nsres = nsIComponentManager_GetClassObject(component_manager, &NS_IOSERVICE_CID,
4054  &IID_nsIFactory, (void**)&old_factory);
4055  if(NS_FAILED(nsres)) {
4056  ERR("Could not get factory: %08x\n", nsres);
4057  return;
4058  }
4059 
4060  nsres = nsIFactory_CreateInstance(old_factory, NULL, &IID_nsIIOService, (void**)&nsio);
4061  if(NS_FAILED(nsres)) {
4062  ERR("Couldn not create nsIOService instance %08x\n", nsres);
4063  nsIFactory_Release(old_factory);
4064  return;
4065  }
4066 
4067  nsres = nsIIOService_QueryInterface(nsio, &IID_nsINetUtil, (void**)&net_util);
4068  if(NS_FAILED(nsres)) {
4069  WARN("Could not get nsINetUtil interface: %08x\n", nsres);
4070  nsIIOService_Release(nsio);
4071  return;
4072  }
4073 
4074  nsres = nsIComponentRegistrar_UnregisterFactory(registrar, &NS_IOSERVICE_CID, old_factory);
4075  nsIFactory_Release(old_factory);
4076  if(NS_FAILED(nsres))
4077  ERR("UnregisterFactory failed: %08x\n", nsres);
4078 
4079  nsres = nsIComponentRegistrar_RegisterFactory(registrar, &NS_IOSERVICE_CID,
4081  if(NS_FAILED(nsres))
4082  ERR("RegisterFactory failed: %08x\n", nsres);
4083 }
4084 
4085 void release_nsio(void)
4086 {
4087  if(net_util) {
4088  nsINetUtil_Release(net_util);
4089  net_util = NULL;
4090  }
4091 
4092  if(nsio) {
4093  nsIIOService_Release(nsio);
4094  nsio = NULL;
4095  }
4096 }
static nsresult NSAPI nsHttpChannelInternal_SetAllowSpdy(nsIHttpChannelInternal *iface, cpp_bool aAllowSpdy)
Definition: nsio.c:1813
static nsresult NSAPI nsIOService_AllowPort(nsIIOService *iface, LONG aPort, const char *aScheme, cpp_bool *_retval)
Definition: nsio.c:3741
static const nsIHttpChannelVtbl nsChannelVtbl
Definition: nsio.c:1469
WCHAR OLECHAR
Definition: compat.h:1926
static nsresult NSAPI nsNetUtil_QueryInterface(nsINetUtil *iface, nsIIDRef riid, void **result)
Definition: nsio.c:3780
nsIInterfaceRequestor * notif_callback
Definition: binding.h:47
static nsresult NSAPI nsURL_SetDirectory(nsIFileURL *iface, const nsACString *aDirectory)
Definition: nsio.c:2942
static nsrefcnt NSAPI nsIOServiceFactory_AddRef(nsIFactory *iface)
Definition: nsio.c:3960
static nsresult NSAPI nsChannel_IsNoCacheResponse(nsIHttpChannel *iface, cpp_bool *_retval)
Definition: nsio.c:1442
nsWineURI * uri
Definition: binding.h:43
static nsresult NSAPI nsURL_GetFileName(nsIFileURL *iface, nsACString *aFileName)
Definition: nsio.c:2952
HRESULT hlink_frame_navigate(HTMLDocument *, LPCWSTR, nsChannel *, DWORD, BOOL *) DECLSPEC_HIDDEN
Definition: navigate.c:2193
#define TRUE
Definition: types.h:120
HRESULT WINAPI CoInternetCombineUrlEx(IUri *pBaseUri, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags, IUri **ppCombinedUri, DWORD_PTR dwReserved)
Definition: uri.c:6768
static nsresult NSAPI nsIOService_GetConnectivity(nsIIOService *iface, cpp_bool *aConnectivity)
Definition: nsio.c:3717
static void windowref_release(windowref_t *ref)
nsIHttpChannel nsIHttpChannel_iface
Definition: binding.h:37
static nsresult NSAPI nsHttpChannelInternal_GetChannelIsForDownload(nsIHttpChannelInternal *iface, cpp_bool *aCanceled)
Definition: nsio.c:1735
static nsresult NSAPI nsHttpChannelInternal_TakeAllSecurityMessages(nsIHttpChannelInternal *iface, void *aMessages)
Definition: nsio.c:1681
HRESULT WINAPI CreateIUriBuilder(IUri *pIUri, DWORD dwFlags, DWORD_PTR dwReserved, IUriBuilder **ppIUriBuilder)
Definition: uri.c:6354
static nsresult NSAPI nsNetUtil_ExtractCharsetFromContentType(nsINetUtil *iface, const nsACString *aTypeHeader, nsACString *aCharset, LONG *aCharsetStart, LONG *aCharsetEnd, cpp_bool *_retval)
Definition: nsio.c:3891
static LPWSTR heap_strndupW(LPCWSTR str, unsigned len)
const char * rel_url
Definition: protocol.c:463
static nsrefcnt NSAPI nsURI_Release(nsIFileURL *iface)
Definition: nsio.c:2100
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:422
static nsresult NSAPI nsIOService_ExtractScheme(nsIIOService *iface, const nsACString *urlString, nsACString *_retval)
Definition: nsio.c:3748
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
CFF_Charset charset
Definition: cffcmap.c:138
static nsresult NSAPI nsURI_GetSpecIgnoringRef(nsIFileURL *iface, nsACString *aSpecIgnoringRef)
Definition: nsio.c:2797
uint32_t nsLoadFlags
Definition: nsiface.idl:67
rwlock_t lock
Definition: tcpcore.h:1163
static nsresult NSAPI nsURI_SetPort(nsIFileURL *iface, LONG aPort)
Definition: nsio.c:2496
#define WideCharToMultiByte
Definition: compat.h:101
static nsresult NSAPI nsFileURL_GetFile(nsIFileURL *iface, nsIFile **aFile)
Definition: nsio.c:3032
static nsresult NSAPI nsHttpChannelInternal_SetupFallbackChannel(nsIHttpChannelInternal *iface, const char *aFallbackKey)
Definition: nsio.c:1699
LONG ref
Definition: nsio.c:38
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:342
#define strcasecmp
Definition: fake.h:9
NSContainer * container
Definition: nsio.c:40
BOOL is_gecko_path(const char *) DECLSPEC_HIDDEN
Definition: nsembed.c:1108
#define NS_BINDING_ABORTED
static nsresult NSAPI nsURI_GetPort(nsIFileURL *iface, LONG *aPort)
Definition: nsio.c:2475
static nsresult NSAPI nsChannel_GetResponseStatusText(nsIHttpChannel *iface, nsACString *aResponseStatusText)
Definition: nsio.c:1371
static nsresult NSAPI nsHttpChannelInternal_GetDocumentURI(nsIHttpChannelInternal *iface, nsIURI **aDocumentURI)
Definition: nsio.c:1645
HRESULT nsuri_to_url(LPCWSTR nsuri, BOOL ret_empty, BSTR *ret)
Definition: nsio.c:175
nsIFileURL nsIFileURL_iface
Definition: nsio.c:35
Definition: http.c:6587
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static nsresult NSAPI nsChannel_Suspend(nsIHttpChannel *iface)
Definition: nsio.c:604
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static void set_uri_window(nsWineURI *This, HTMLOuterWindow *window)
Definition: nsio.c:315
static nsresult NSAPI nsHttpChannelInternal_GetResponseVersion(nsIHttpChannelInternal *iface, UINT32 *major, UINT32 *minor)
Definition: nsio.c:1672
static nsresult NSAPI nsChannel_GetResponseHeader(nsIHttpChannel *iface, const nsACString *header, nsACString *_retval)
Definition: nsio.c:1397
IOleClientSite * client
#define NS_IOSERVICE_CONTRACTID
Definition: nsio.c:22
#define NSAPI
GLsizei const GLchar ** path
Definition: glext.h:7234
const char * uri
Definition: sec_mgr.c:1594
REFIID riid
Definition: precomp.h:44
static BOOL ensure_uri_builder(nsWineURI *This)
Definition: nsio.c:1997
UINT32 nsACString_GetData(const nsACString *, const char **) DECLSPEC_HIDDEN
Definition: nsembed.c:807
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
static nsresult NSAPI nsChannel_VisitRequestHeaders(nsIHttpChannel *iface, nsIHttpHeaderVisitor *aVisitor)
Definition: nsio.c:1296
static nsrefcnt NSAPI nsProtocolHandler_Release(nsIProtocolHandler *iface)
Definition: nsio.c:3355
static nsresult create_nsuri(IUri *, HTMLOuterWindow *, NSContainer *, const char *, nsWineURI **)
Definition: nsio.c:3172
static nsresult NSAPI nsURL_SetFilePath(nsIFileURL *iface, const nsACString *aFilePath)
Definition: nsio.c:2834
HRESULT create_channelbsc(IMoniker *, const WCHAR *, BYTE *, DWORD, BOOL, nsChannelBSC **) DECLSPEC_HIDDEN
Definition: navigate.c:1693
int other
Definition: msacm.c:1364
static const IID IID_nsWineURI
Definition: nsio.c:26
BSCallback bsc
Definition: binding.h:98
uint8_t entry
Definition: isohybrid.c:63
static const nsIIOServiceVtbl nsIOServiceVtbl
Definition: nsio.c:3755
#define WARN(fmt,...)
Definition: debug.h:111
windowref_t * window_ref
Definition: nsio.c:41
char * host
Definition: whois.c:55
nsresult create_nsfile(const PRUnichar *, nsIFile **) DECLSPEC_HIDDEN
Definition: nsembed.c:72
static nsresult new_channel_from_uri(nsIURI *uri, nsILoadInfo *load_info, nsIChannel **_retval)
Definition: nsio.c:3625
#define INTERNET_MAX_SCHEME_LENGTH
Definition: wininet.h:50
Definition: nsio.c:34
static nsresult NSAPI nsIOService_SetOffline(nsIIOService *iface, cpp_bool aOffline)
Definition: nsio.c:3711
REFIID nsIIDRef
Definition: nsiface.idl:45
nsLoadFlags load_flags
Definition: binding.h:50
static nsresult NSAPI nsChannel_QueryInterface(nsIHttpChannel *iface, nsIIDRef riid, void **result)
Definition: nsio.c:492
static const nsIFactoryVtbl nsIOServiceFactoryVtbl
Definition: nsio.c:3982
static nsrefcnt NSAPI nsURI_AddRef(nsIFileURL *iface)
Definition: nsio.c:2090
struct list response_headers
Definition: binding.h:58
static nsIFactory nsIOServiceFactory
Definition: nsio.c:3990
DWORD scheme
static nsresult NSAPI nsURL_SetFileExtension(nsIFileURL *iface, const nsACString *aFileExtension)
Definition: nsio.c:3011
static nsresult NSAPI nsIOService_NewChannel2(nsIIOService *iface, const nsACString *aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIDOMNode *aLoadingNode, nsIPrincipal *aLoadingPrincipal, nsIPrincipal *aTriggeringPrincipal, UINT32 aSecurityFlags, UINT32 aContentPolicyType, nsIChannel **_retval)
Definition: nsio.c:3688
#define assert(x)
Definition: debug.h:53
static nsresult NSAPI nsIOServiceFactory_QueryInterface(nsIFactory *iface, nsIIDRef riid, void **result)
Definition: nsio.c:3938
#define NS_IOSERVICE_CLASSNAME
Definition: nsio.c:21
static nsresult NSAPI nsURI_SetUsername(nsIFileURL *iface, const nsACString *aUsername)
Definition: nsio.c:2338
static void windowref_addref(windowref_t *ref)
static nsresult NSAPI nsChannel_IsNoStoreResponse(nsIHttpChannel *iface, cpp_bool *_retval)
Definition: nsio.c:1427
vector< Header * > headers
Definition: sdkparse.cpp:39
static nsresult NSAPI nsChannel_SetAllowPipelining(nsIHttpChannel *iface, cpp_bool aAllowPipelining)
Definition: nsio.c:1315
static nsresult NSAPI nsChannel_SetOriginalURI(nsIHttpChannel *iface, nsIURI *aOriginalURI)
Definition: nsio.c:683
WCHAR * data
Definition: binding.h:124
static void start_binding_proc(task_t *_task)
Definition: nsio.c:978
static char * heap_strdupWtoU(const WCHAR *str)
OLECHAR * BSTR
Definition: compat.h:1927
static nsresult NSAPI nsChannel_Cancel(nsIHttpChannel *iface, nsresult aStatus)
Definition: nsio.c:595
static nsresult NSAPI nsChannel_SetRequestMethod(nsIHttpChannel *iface, const nsACString *aRequestMethod)
Definition: nsio.c:1212
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
static nsresult NSAPI nsIOService_GetOffline(nsIIOService *iface, cpp_bool *aOffline)
Definition: nsio.c:3705
static nsresult NSAPI nsHttpChannelInternal_GetLocalPort(nsIHttpChannelInternal *iface, LONG *aLocalPort)
Definition: nsio.c:1762
static nsresult NSAPI nsChannel_SetContentType(nsIHttpChannel *iface, const nsACString *aContentType)
Definition: nsio.c:798
static nsresult NSAPI nsIOServiceFactory_LockFactory(nsIFactory *iface, cpp_bool lock)
Definition: nsio.c:3976
static nsresult NSAPI nsURI_SetPassword(nsIFileURL *iface, const nsACString *aPassword)
Definition: nsio.c:2372
nsChannelBSC * channel_bsc
Definition: nsio.c:42
#define E_FAIL
Definition: ddrawi.h:102
static nsChannel * impl_from_nsIHttpChannel(nsIHttpChannel *iface)
Definition: nsio.c:487
static nsresult NSAPI nsURI_Clone(nsIFileURL *iface, nsIURI **_retval)
Definition: nsio.c:2600
static nsresult NSAPI nsChannel_RedirectTo(nsIHttpChannel *iface, nsIURI *aNewURI)
Definition: nsio.c:1460
static nsChannel * impl_from_nsIUploadChannel(nsIUploadChannel *iface)
Definition: nsio.c:1533
Definition: send.c:47
static nsresult NSAPI nsChannel_GetURI(nsIHttpChannel *iface, nsIURI **aURI)
Definition: nsio.c:697
static nsresult NSAPI nsNetUtil_NewSimpleNestedURI(nsINetUtil *iface, nsIURI *aURI, nsIURI **_retval)
Definition: nsio.c:3860
static nsresult NSAPI nsURI_GetAsciiSpec(nsIFileURL *iface, nsACString *aAsciiSpec)
Definition: nsio.c:2664
static nsresult NSAPI nsNetUtil_URIChainHasFlags(nsINetUtil *iface, nsIURI *aURI, UINT32 aFlags, cpp_bool *_retval)
Definition: nsio.c:3841
static nsresult NSAPI nsURI_GetAsciiHost(nsIFileURL *iface, nsACString *aAsciiHost)
Definition: nsio.c:2673
static nsresult NSAPI nsNetUtil_UnescapeString(nsINetUtil *iface, const nsACString *aStr, UINT32 aFlags, nsACString *_retval)
Definition: nsio.c:3883
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
static nsresult NSAPI nsHttpChannelInternal_GetForceAllowThirdPartyCookie(nsIHttpChannelInternal *iface, cpp_bool *aForceThirdPartyCookie)
Definition: nsio.c:1708
static nsresult NSAPI nsIOService_QueryInterface(nsIIOService *, nsIIDRef, void **)
Definition: nsio.c:3917
HTMLOuterWindow * window
WINE_UNICODE_INLINE int strncmpW(const WCHAR *str1, const WCHAR *str2, int n)
Definition: unicode.h:235
static BOOL is_gecko_special_uri(const char *spec)
Definition: nsio.c:3525
static nsresult NSAPI nsURI_GetPath(nsIFileURL *iface, nsACString *aPath)
Definition: nsio.c:2510
static nsresult NSAPI nsHttpChannelInternal_SetResponseTimeoutEnabled(nsIHttpChannelInternal *iface, cpp_bool aResponseTimeoutEnabled)
Definition: nsio.c:1828
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:271
static nsrefcnt NSAPI nsStandardURL_AddRef(nsIStandardURL *iface)
Definition: nsio.c:3123
static nsresult NSAPI nsFileURL_SetFile(nsIFileURL *iface, nsIFile *aFile)
Definition: nsio.c:3050
static nsresult NSAPI nsChannel_GetAllowTLS(nsIHttpChannel *iface, cpp_bool *aAllowTLS)
Definition: nsio.c:1324
char * header_name
Definition: widl.c:136
static nsresult NSAPI nsProtocolHandler_NewURI(nsIProtocolHandler *iface, const nsACString *aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval)
Definition: nsio.c:3406
static nsresult NSAPI nsURI_CloneIgnoreRef(nsIFileURL *iface, nsIURI **_retval)
Definition: n