2006-02-09 12:17:08 +01:00
|
|
|
/*
|
2010-08-03 21:40:20 +02:00
|
|
|
* Copyright 2006-2010 Jacek Caban for CodeWeavers
|
2006-02-09 12:17:08 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2006-02-09 12:17:08 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2011-06-25 19:03:38 +02:00
|
|
|
#include <assert.h>
|
2006-02-09 12:17:08 +01:00
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
2007-02-09 20:19:13 +01:00
|
|
|
#include "winreg.h"
|
2006-02-09 12:17:08 +01:00
|
|
|
#include "ole2.h"
|
2006-02-09 12:19:33 +01:00
|
|
|
#include "shlguid.h"
|
2007-02-09 20:17:16 +01:00
|
|
|
#include "wininet.h"
|
2007-02-09 20:19:13 +01:00
|
|
|
#include "shlwapi.h"
|
2006-02-09 12:17:08 +01:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "mshtml_private.h"
|
2011-07-23 12:50:11 +02:00
|
|
|
#include "binding.h"
|
2006-02-09 12:17:08 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
|
|
|
|
|
|
|
#define NS_IOSERVICE_CLASSNAME "nsIOService"
|
|
|
|
#define NS_IOSERVICE_CONTRACTID "@mozilla.org/network/io-service;1"
|
|
|
|
|
2006-02-24 20:31:12 +01:00
|
|
|
static const IID NS_IOSERVICE_CID =
|
2006-02-09 12:17:08 +01:00
|
|
|
{0x9ac9e770, 0x18bc, 0x11d3, {0x93, 0x37, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40}};
|
2010-02-21 21:10:15 +01:00
|
|
|
static const IID IID_nsWineURI =
|
|
|
|
{0x5088272e, 0x900b, 0x11da, {0xc6,0x87, 0x00,0x0f,0xea,0x57,0xf2,0x1a}};
|
2006-02-09 12:17:08 +01:00
|
|
|
|
|
|
|
static nsIIOService *nsio = NULL;
|
2008-12-18 14:08:13 +01:00
|
|
|
static nsINetUtil *net_util;
|
2006-02-09 12:17:08 +01:00
|
|
|
|
2010-08-03 21:40:20 +02:00
|
|
|
static const char *request_method_strings[] = {"GET", "PUT", "POST"};
|
|
|
|
|
2010-02-21 21:05:15 +01:00
|
|
|
struct nsWineURI {
|
2012-07-20 12:36:33 +02:00
|
|
|
nsIFileURL nsIFileURL_iface; /* For non-file URL objects, it's just nsIURL */
|
2011-11-18 12:21:47 +01:00
|
|
|
nsIStandardURL nsIStandardURL_iface;
|
2006-02-09 12:18:18 +01:00
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
NSContainer *container;
|
2009-10-26 23:02:50 +01:00
|
|
|
windowref_t *window_ref;
|
2010-01-04 00:38:57 +01:00
|
|
|
nsChannelBSC *channel_bsc;
|
2010-09-28 13:25:24 +02:00
|
|
|
IUri *uri;
|
2010-11-12 12:31:41 +01:00
|
|
|
IUriBuilder *uri_builder;
|
2012-11-21 15:06:46 +01:00
|
|
|
char *origin_charset;
|
2010-03-03 14:54:10 +01:00
|
|
|
BOOL is_doc_uri;
|
2011-11-23 16:19:42 +01:00
|
|
|
BOOL is_mutable;
|
2012-07-20 12:36:02 +02:00
|
|
|
DWORD scheme;
|
2010-02-21 21:05:15 +01:00
|
|
|
};
|
2006-02-09 12:18:18 +01:00
|
|
|
|
2011-06-23 13:45:18 +02:00
|
|
|
static BOOL ensure_uri(nsWineURI *This)
|
|
|
|
{
|
|
|
|
HRESULT hres;
|
|
|
|
|
2011-06-25 19:03:38 +02:00
|
|
|
assert(This->uri || This->uri_builder);
|
2011-06-23 13:45:18 +02:00
|
|
|
|
2011-06-25 19:03:38 +02:00
|
|
|
if(!This->uri) {
|
2011-06-23 13:45:18 +02:00
|
|
|
hres = IUriBuilder_CreateUriSimple(This->uri_builder, 0, 0, &This->uri);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("CreateUriSimple failed: %08x\n", hres);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-11-16 12:52:43 +01:00
|
|
|
IUri *nsuri_get_uri(nsWineURI *nsuri)
|
|
|
|
{
|
|
|
|
if(!ensure_uri(nsuri))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
IUri_AddRef(nsuri->uri);
|
|
|
|
return nsuri->uri;
|
|
|
|
}
|
|
|
|
|
2012-11-08 18:16:42 +01:00
|
|
|
IUri *get_uri_nofrag(IUri *uri)
|
2011-11-15 13:31:12 +01:00
|
|
|
{
|
|
|
|
IUriBuilder *uri_builder;
|
|
|
|
IUri *ret;
|
|
|
|
BOOL b;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IUri_HasProperty(uri, Uri_PROPERTY_FRAGMENT, &b);
|
|
|
|
if(SUCCEEDED(hres) && !b) {
|
|
|
|
IUri_AddRef(uri);
|
|
|
|
return uri;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = CreateIUriBuilder(uri, 0, 0, &uri_builder);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
hres = IUriBuilder_RemoveProperties(uri_builder, Uri_HAS_FRAGMENT);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
hres = IUriBuilder_CreateUriSimple(uri_builder, 0, 0, &ret);
|
|
|
|
IUriBuilder_Release(uri_builder);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-11-08 18:17:12 +01:00
|
|
|
static BOOL compare_ignoring_frag(IUri *uri1, IUri *uri2)
|
2011-11-15 13:31:22 +01:00
|
|
|
{
|
|
|
|
IUri *uri_nofrag1, *uri_nofrag2;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
uri_nofrag1 = get_uri_nofrag(uri1);
|
|
|
|
if(!uri_nofrag1)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
uri_nofrag2 = get_uri_nofrag(uri2);
|
|
|
|
if(uri_nofrag2) {
|
|
|
|
IUri_IsEqual(uri_nofrag1, uri_nofrag2, &ret);
|
|
|
|
IUri_Release(uri_nofrag2);
|
|
|
|
}
|
|
|
|
|
|
|
|
IUri_Release(uri_nofrag1);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-11-29 12:58:25 +01:00
|
|
|
static HRESULT combine_url(IUri *base_uri, const WCHAR *rel_url, IUri **ret)
|
|
|
|
{
|
|
|
|
IUri *uri_nofrag;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
uri_nofrag = get_uri_nofrag(base_uri);
|
|
|
|
if(!uri_nofrag)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
hres = CoInternetCombineUrlEx(uri_nofrag, rel_url, URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO,
|
|
|
|
ret, 0);
|
|
|
|
IUri_Release(uri_nofrag);
|
|
|
|
if(FAILED(hres))
|
|
|
|
WARN("CoInternetCombineUrlEx failed: %08x\n", hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2012-11-21 15:06:46 +01:00
|
|
|
static nsresult create_nsuri(IUri*,HTMLOuterWindow*,NSContainer*,const char*,nsWineURI**);
|
2006-02-24 20:31:12 +01:00
|
|
|
|
2009-08-27 11:31:14 +02:00
|
|
|
static const char *debugstr_nsacstr(const nsACString *nsstr)
|
|
|
|
{
|
|
|
|
const char *data;
|
|
|
|
|
|
|
|
nsACString_GetData(nsstr, &data);
|
|
|
|
return debugstr_a(data);
|
|
|
|
}
|
|
|
|
|
2012-01-11 19:41:02 +01:00
|
|
|
static nsresult return_wstr_nsacstr(nsACString *ret_str, const WCHAR *str, int len)
|
|
|
|
{
|
|
|
|
char *stra;
|
|
|
|
int lena;
|
|
|
|
|
|
|
|
TRACE("returning %s\n", debugstr_wn(str, len));
|
|
|
|
|
|
|
|
if(!*str) {
|
|
|
|
nsACString_SetData(ret_str, "");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-11-21 15:06:34 +01:00
|
|
|
lena = WideCharToMultiByte(CP_UTF8, 0, str, len, NULL, 0, NULL, NULL);
|
2012-01-11 19:41:02 +01:00
|
|
|
stra = heap_alloc(lena+1);
|
|
|
|
if(!stra)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
2012-11-21 15:06:34 +01:00
|
|
|
WideCharToMultiByte(CP_UTF8, 0, str, len, stra, lena, NULL, NULL);
|
2012-01-11 19:41:02 +01:00
|
|
|
stra[lena] = 0;
|
|
|
|
|
|
|
|
nsACString_SetData(ret_str, stra);
|
|
|
|
heap_free(stra);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-09-14 00:36:09 +02:00
|
|
|
HRESULT nsuri_to_url(LPCWSTR nsuri, BOOL ret_empty, BSTR *ret)
|
2008-10-13 21:50:37 +02:00
|
|
|
{
|
|
|
|
const WCHAR *ptr = nsuri;
|
|
|
|
|
|
|
|
static const WCHAR wine_prefixW[] = {'w','i','n','e',':'};
|
|
|
|
|
|
|
|
if(!strncmpW(nsuri, wine_prefixW, sizeof(wine_prefixW)/sizeof(WCHAR)))
|
|
|
|
ptr += sizeof(wine_prefixW)/sizeof(WCHAR);
|
|
|
|
|
2009-09-14 00:36:09 +02:00
|
|
|
if(*ptr || ret_empty) {
|
|
|
|
*ret = SysAllocString(ptr);
|
|
|
|
if(!*ret)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}else {
|
|
|
|
*ret = NULL;
|
|
|
|
}
|
2008-10-13 21:50:37 +02:00
|
|
|
|
|
|
|
TRACE("%s -> %s\n", debugstr_w(nsuri), debugstr_w(*ret));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-23 13:45:34 +02:00
|
|
|
static BOOL exec_shldocvw_67(HTMLDocumentObj *doc, BSTR url)
|
2006-02-09 12:19:33 +01:00
|
|
|
{
|
|
|
|
IOleCommandTarget *cmdtrg = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2009-09-16 22:10:03 +02:00
|
|
|
hres = IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
|
2006-02-09 12:19:33 +01:00
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
VARIANT varUrl, varRes;
|
|
|
|
|
|
|
|
V_VT(&varUrl) = VT_BSTR;
|
2011-06-23 13:45:34 +02:00
|
|
|
V_BSTR(&varUrl) = url;
|
2006-02-09 12:19:33 +01:00
|
|
|
V_VT(&varRes) = VT_BOOL;
|
|
|
|
|
|
|
|
hres = IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 67, 0, &varUrl, &varRes);
|
|
|
|
|
|
|
|
IOleCommandTarget_Release(cmdtrg);
|
|
|
|
|
|
|
|
if(SUCCEEDED(hres) && !V_BOOL(&varRes)) {
|
|
|
|
TRACE("got VARIANT_FALSE, do not load\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-06-23 13:45:34 +02:00
|
|
|
static nsresult before_async_open(nsChannel *channel, NSContainer *container, BOOL *cancel)
|
2006-02-13 13:26:00 +01:00
|
|
|
{
|
2009-09-16 22:09:17 +02:00
|
|
|
HTMLDocumentObj *doc = container->doc;
|
2011-06-25 19:03:38 +02:00
|
|
|
BSTR display_uri;
|
2006-02-13 13:26:00 +01:00
|
|
|
HRESULT hres;
|
|
|
|
|
2011-06-23 13:45:34 +02:00
|
|
|
if(!doc->client) {
|
|
|
|
*cancel = TRUE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2008-01-10 12:53:14 +01:00
|
|
|
|
2011-06-25 19:03:38 +02:00
|
|
|
hres = IUri_GetDisplayUri(channel->uri->uri, &display_uri);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2012-07-13 14:44:45 +02:00
|
|
|
if(!exec_shldocvw_67(doc, display_uri)) {
|
|
|
|
SysFreeString(display_uri);
|
|
|
|
*cancel = FALSE;
|
|
|
|
return NS_OK;
|
2011-06-23 13:45:34 +02:00
|
|
|
}
|
|
|
|
|
2012-07-13 14:44:45 +02:00
|
|
|
hres = hlink_frame_navigate(&doc->basedoc, display_uri, channel, 0, cancel);
|
2011-06-25 19:03:38 +02:00
|
|
|
SysFreeString(display_uri);
|
2011-06-23 13:45:34 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
*cancel = TRUE;
|
|
|
|
return NS_OK;
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
2015-02-02 13:43:49 +01:00
|
|
|
HRESULT load_nsuri(HTMLOuterWindow *window, nsWineURI *uri, nsIInputStream *post_stream,
|
|
|
|
nsChannelBSC *channelbsc, DWORD flags)
|
2010-02-21 21:06:51 +01:00
|
|
|
{
|
2015-02-02 13:43:49 +01:00
|
|
|
nsIDocShellLoadInfo *load_info = NULL;
|
2010-02-21 21:06:51 +01:00
|
|
|
nsIWebNavigation *web_navigation;
|
|
|
|
nsIDocShell *doc_shell;
|
2010-08-18 13:39:04 +02:00
|
|
|
HTMLDocumentNode *doc;
|
2010-02-21 21:06:51 +01:00
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = get_nsinterface((nsISupports*)window->nswindow, &IID_nsIWebNavigation, (void**)&web_navigation);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("Could not get nsIWebNavigation interface: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIWebNavigation_QueryInterface(web_navigation, &IID_nsIDocShell, (void**)&doc_shell);
|
|
|
|
nsIWebNavigation_Release(web_navigation);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("Could not get nsIDocShell: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2015-02-02 13:43:49 +01:00
|
|
|
if(post_stream) {
|
|
|
|
nsres = nsIDocShell_CreateLoadInfo(doc_shell, &load_info);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
nsIDocShell_Release(doc_shell);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIDocShellLoadInfo_SetPostDataStream(load_info, post_stream);
|
|
|
|
assert(nsres == NS_OK);
|
|
|
|
}
|
|
|
|
|
2010-02-21 21:06:51 +01:00
|
|
|
uri->channel_bsc = channelbsc;
|
2012-06-25 14:05:17 +02:00
|
|
|
doc = window->base.inner_window->doc;
|
2010-08-18 13:39:04 +02:00
|
|
|
doc->skip_mutation_notif = TRUE;
|
2015-02-02 13:43:49 +01:00
|
|
|
nsres = nsIDocShell_LoadURI(doc_shell, (nsIURI*)&uri->nsIFileURL_iface, load_info, flags, FALSE);
|
2012-06-25 14:05:17 +02:00
|
|
|
if(doc == window->base.inner_window->doc)
|
2010-08-18 13:39:04 +02:00
|
|
|
doc->skip_mutation_notif = FALSE;
|
2010-02-21 21:06:51 +01:00
|
|
|
uri->channel_bsc = NULL;
|
|
|
|
nsIDocShell_Release(doc_shell);
|
2015-02-02 13:43:49 +01:00
|
|
|
if(load_info)
|
|
|
|
nsIDocShellLoadInfo_Release(load_info);
|
2010-02-21 21:06:51 +01:00
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
WARN("LoadURI failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-02-21 21:09:11 +01:00
|
|
|
static void set_uri_nscontainer(nsWineURI *This, NSContainer *nscontainer)
|
|
|
|
{
|
|
|
|
if(This->container) {
|
|
|
|
if(This->container == nscontainer)
|
|
|
|
return;
|
|
|
|
TRACE("Changing %p -> %p\n", This->container, nscontainer);
|
2010-12-27 23:27:55 +01:00
|
|
|
nsIWebBrowserChrome_Release(&This->container->nsIWebBrowserChrome_iface);
|
2010-02-21 21:09:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(nscontainer)
|
2010-12-27 23:27:55 +01:00
|
|
|
nsIWebBrowserChrome_AddRef(&nscontainer->nsIWebBrowserChrome_iface);
|
2010-02-21 21:09:11 +01:00
|
|
|
This->container = nscontainer;
|
|
|
|
}
|
|
|
|
|
2012-06-25 14:04:59 +02:00
|
|
|
static void set_uri_window(nsWineURI *This, HTMLOuterWindow *window)
|
2010-02-21 21:08:39 +01:00
|
|
|
{
|
|
|
|
if(This->window_ref) {
|
|
|
|
if(This->window_ref->window == window)
|
|
|
|
return;
|
|
|
|
TRACE("Changing %p -> %p\n", This->window_ref->window, window);
|
|
|
|
windowref_release(This->window_ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(window) {
|
|
|
|
windowref_addref(window->window_ref);
|
|
|
|
This->window_ref = window->window_ref;
|
|
|
|
|
|
|
|
if(window->doc_obj)
|
2010-02-21 21:09:11 +01:00
|
|
|
set_uri_nscontainer(This, window->doc_obj->nscontainer);
|
2010-02-21 21:08:39 +01:00
|
|
|
}else {
|
|
|
|
This->window_ref = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-01 22:50:19 +01:00
|
|
|
static inline BOOL is_http_channel(nsChannel *This)
|
|
|
|
{
|
2012-07-20 12:36:02 +02:00
|
|
|
return This->uri->scheme == URL_SCHEME_HTTP || This->uri->scheme == URL_SCHEME_HTTPS;
|
2009-12-01 22:50:19 +01:00
|
|
|
}
|
|
|
|
|
2010-08-03 21:38:11 +02:00
|
|
|
static http_header_t *find_http_header(struct list *headers, const WCHAR *name, int len)
|
|
|
|
{
|
|
|
|
http_header_t *iter;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(iter, headers, http_header_t, entry) {
|
2015-10-05 15:50:27 +02:00
|
|
|
if(!strncmpiW(iter->header, name, len) && !iter->header[len])
|
2010-08-03 21:38:11 +02:00
|
|
|
return iter;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult get_channel_http_header(struct list *headers, const nsACString *header_name_str,
|
|
|
|
nsACString *_retval)
|
|
|
|
{
|
|
|
|
const char *header_namea;
|
|
|
|
http_header_t *header;
|
|
|
|
WCHAR *header_name;
|
|
|
|
char *data;
|
|
|
|
|
|
|
|
nsACString_GetData(header_name_str, &header_namea);
|
|
|
|
header_name = heap_strdupAtoW(header_namea);
|
|
|
|
if(!header_name)
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
header = find_http_header(headers, header_name, strlenW(header_name));
|
|
|
|
heap_free(header_name);
|
|
|
|
if(!header)
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
|
|
|
data = heap_strdupWtoA(header->data);
|
|
|
|
if(!data)
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
2011-11-18 12:21:47 +01:00
|
|
|
TRACE("%s -> %s\n", debugstr_a(header_namea), debugstr_a(data));
|
2010-08-03 21:38:11 +02:00
|
|
|
nsACString_SetData(_retval, data);
|
|
|
|
heap_free(data);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-03 21:38:37 +02:00
|
|
|
HRESULT set_http_header(struct list *headers, const WCHAR *name, int name_len,
|
|
|
|
const WCHAR *value, int value_len)
|
|
|
|
{
|
|
|
|
http_header_t *header;
|
|
|
|
|
|
|
|
TRACE("%s: %s\n", debugstr_wn(name, name_len), debugstr_wn(value, value_len));
|
|
|
|
|
|
|
|
header = find_http_header(headers, name, name_len);
|
|
|
|
if(header) {
|
|
|
|
WCHAR *new_data;
|
|
|
|
|
|
|
|
new_data = heap_strndupW(value, value_len);
|
|
|
|
if(!new_data)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
heap_free(header->data);
|
|
|
|
header->data = new_data;
|
|
|
|
}else {
|
|
|
|
header = heap_alloc(sizeof(http_header_t));
|
|
|
|
if(!header)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
header->header = heap_strndupW(name, name_len);
|
|
|
|
header->data = heap_strndupW(value, value_len);
|
|
|
|
if(!header->header || !header->data) {
|
|
|
|
heap_free(header->header);
|
|
|
|
heap_free(header->data);
|
|
|
|
heap_free(header);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
list_add_tail(headers, &header->entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-03 21:40:05 +02:00
|
|
|
static nsresult set_channel_http_header(struct list *headers, const nsACString *name_str,
|
|
|
|
const nsACString *value_str)
|
|
|
|
{
|
|
|
|
const char *namea, *valuea;
|
|
|
|
WCHAR *name, *value;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
nsACString_GetData(name_str, &namea);
|
|
|
|
name = heap_strdupAtoW(namea);
|
|
|
|
if(!name)
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
nsACString_GetData(value_str, &valuea);
|
|
|
|
value = heap_strdupAtoW(valuea);
|
|
|
|
if(!value) {
|
|
|
|
heap_free(name);
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = set_http_header(headers, name, strlenW(name), value, strlenW(value));
|
|
|
|
|
|
|
|
heap_free(name);
|
|
|
|
heap_free(value);
|
|
|
|
return SUCCEEDED(hres) ? NS_OK : NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2010-09-17 18:33:10 +02:00
|
|
|
static nsresult visit_http_headers(struct list *headers, nsIHttpHeaderVisitor *visitor)
|
|
|
|
{
|
|
|
|
nsACString header_str, value_str;
|
|
|
|
char *header, *value;
|
|
|
|
http_header_t *iter;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(iter, headers, http_header_t, entry) {
|
|
|
|
header = heap_strdupWtoA(iter->header);
|
|
|
|
if(!header)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
value = heap_strdupWtoA(iter->data);
|
|
|
|
if(!value) {
|
|
|
|
heap_free(header);
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsACString_InitDepend(&header_str, header);
|
|
|
|
nsACString_InitDepend(&value_str, value);
|
|
|
|
nsres = nsIHttpHeaderVisitor_VisitHeader(visitor, &header_str, &value_str);
|
|
|
|
nsACString_Finish(&header_str);
|
|
|
|
nsACString_Finish(&value_str);
|
|
|
|
heap_free(header);
|
|
|
|
heap_free(value);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-03 21:37:00 +02:00
|
|
|
static void free_http_headers(struct list *list)
|
|
|
|
{
|
|
|
|
http_header_t *iter, *iter_next;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(iter, iter_next, list, http_header_t, entry) {
|
|
|
|
list_remove(&iter->entry);
|
|
|
|
heap_free(iter->header);
|
|
|
|
heap_free(iter->data);
|
|
|
|
heap_free(iter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-30 01:43:11 +01:00
|
|
|
static inline nsChannel *impl_from_nsIHttpChannel(nsIHttpChannel *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, nsChannel, nsIHttpChannel_iface);
|
|
|
|
}
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2010-08-02 11:08:26 +02:00
|
|
|
static nsresult NSAPI nsChannel_QueryInterface(nsIHttpChannel *iface, nsIIDRef riid, void **result)
|
2006-02-09 12:19:13 +01:00
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_nsISupports, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsISupports %p)\n", This, result);
|
2010-12-30 01:43:11 +01:00
|
|
|
*result = &This->nsIHttpChannel_iface;
|
2006-02-09 12:19:13 +01:00
|
|
|
}else if(IsEqualGUID(&IID_nsIRequest, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIRequest %p)\n", This, result);
|
2010-12-30 01:43:11 +01:00
|
|
|
*result = &This->nsIHttpChannel_iface;
|
2006-02-09 12:19:13 +01:00
|
|
|
}else if(IsEqualGUID(&IID_nsIChannel, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIChannel %p)\n", This, result);
|
2010-12-30 01:43:11 +01:00
|
|
|
*result = &This->nsIHttpChannel_iface;
|
2009-08-22 19:37:30 +02:00
|
|
|
}else if(IsEqualGUID(&IID_nsIHttpChannel, riid)) {
|
2006-02-09 12:19:13 +01:00
|
|
|
TRACE("(%p)->(IID_nsIHttpChannel %p)\n", This, result);
|
2010-12-30 01:43:11 +01:00
|
|
|
*result = is_http_channel(This) ? &This->nsIHttpChannel_iface : NULL;
|
2006-02-10 14:49:41 +01:00
|
|
|
}else if(IsEqualGUID(&IID_nsIUploadChannel, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIUploadChannel %p)\n", This, result);
|
2010-12-30 01:49:21 +01:00
|
|
|
*result = &This->nsIUploadChannel_iface;
|
2009-08-22 19:37:30 +02:00
|
|
|
}else if(IsEqualGUID(&IID_nsIHttpChannelInternal, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIHttpChannelInternal %p)\n", This, result);
|
2010-12-30 01:49:21 +01:00
|
|
|
*result = is_http_channel(This) ? &This->nsIHttpChannelInternal_iface : NULL;
|
2009-08-22 19:37:30 +02:00
|
|
|
}else {
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), result);
|
|
|
|
*result = NULL;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*result) {
|
2012-07-26 11:37:48 +02:00
|
|
|
nsIHttpChannel_AddRef(&This->nsIHttpChannel_iface);
|
2006-02-09 12:19:13 +01:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-02-20 11:13:37 +01:00
|
|
|
return NS_NOINTERFACE;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsChannel_AddRef(nsIHttpChannel *iface)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-09 12:19:13 +01:00
|
|
|
nsrefcnt ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsChannel_Release(nsIHttpChannel *iface)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-09 12:19:13 +01:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
if(!ref) {
|
2012-07-26 11:37:48 +02:00
|
|
|
nsIFileURL_Release(&This->uri->nsIFileURL_iface);
|
2008-12-22 01:10:47 +01:00
|
|
|
if(This->owner)
|
|
|
|
nsISupports_Release(This->owner);
|
2006-02-10 14:49:41 +01:00
|
|
|
if(This->post_data_stream)
|
|
|
|
nsIInputStream_Release(This->post_data_stream);
|
2006-02-20 11:13:37 +01:00
|
|
|
if(This->load_group)
|
|
|
|
nsILoadGroup_Release(This->load_group);
|
|
|
|
if(This->notif_callback)
|
|
|
|
nsIInterfaceRequestor_Release(This->notif_callback);
|
|
|
|
if(This->original_uri)
|
|
|
|
nsIURI_Release(This->original_uri);
|
2010-08-18 13:37:08 +02:00
|
|
|
if(This->referrer)
|
|
|
|
nsIURI_Release(This->referrer);
|
2010-04-03 00:31:45 +02:00
|
|
|
|
2010-08-03 21:37:00 +02:00
|
|
|
free_http_headers(&This->response_headers);
|
2010-08-03 21:39:34 +02:00
|
|
|
free_http_headers(&This->request_headers);
|
2010-04-03 00:31:45 +02:00
|
|
|
|
2010-08-03 21:37:00 +02:00
|
|
|
heap_free(This->content_type);
|
|
|
|
heap_free(This->charset);
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(This);
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetName(nsIHttpChannel *iface, nsACString *aName)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2010-08-18 13:38:18 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, aName);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2012-07-26 11:37:48 +02:00
|
|
|
return nsIFileURL_GetSpec(&This->uri->nsIFileURL_iface, aName);
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
2012-03-15 11:54:33 +01:00
|
|
|
static nsresult NSAPI nsChannel_IsPending(nsIHttpChannel *iface, cpp_bool *_retval)
|
2006-02-09 12:19:13 +01:00
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2010-01-04 00:38:20 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, _retval);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetStatus(nsIHttpChannel *iface, nsresult *aStatus)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2010-01-04 00:38:20 +01:00
|
|
|
WARN("(%p)->(%p) returning NS_OK\n", This, aStatus);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2006-06-25 14:13:48 +02:00
|
|
|
return *aStatus = NS_OK;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_Cancel(nsIHttpChannel *iface, nsresult aStatus)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2015-12-21 14:31:29 +01:00
|
|
|
TRACE("(%p)->(%08x)\n", This, aStatus);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2015-12-21 14:31:29 +01:00
|
|
|
if(This->binding && This->binding->bsc.binding)
|
|
|
|
IBinding_Abort(This->binding->bsc.binding);
|
|
|
|
else
|
|
|
|
WARN("No binding to cancel\n");
|
|
|
|
return NS_OK;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_Suspend(nsIHttpChannel *iface)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2010-01-04 00:38:20 +01:00
|
|
|
FIXME("(%p)\n", This);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_Resume(nsIHttpChannel *iface)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2010-01-04 00:38:20 +01:00
|
|
|
FIXME("(%p)\n", This);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetLoadGroup(nsIHttpChannel *iface, nsILoadGroup **aLoadGroup)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2006-02-09 12:19:13 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aLoadGroup);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
|
|
|
if(This->load_group)
|
|
|
|
nsILoadGroup_AddRef(This->load_group);
|
|
|
|
|
|
|
|
*aLoadGroup = This->load_group;
|
|
|
|
return NS_OK;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetLoadGroup(nsIHttpChannel *iface, nsILoadGroup *aLoadGroup)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2006-02-09 12:19:13 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aLoadGroup);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
|
|
|
if(This->load_group)
|
|
|
|
nsILoadGroup_Release(This->load_group);
|
|
|
|
if(aLoadGroup)
|
|
|
|
nsILoadGroup_AddRef(aLoadGroup);
|
|
|
|
This->load_group = aLoadGroup;
|
|
|
|
|
|
|
|
return NS_OK;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetLoadFlags(nsIHttpChannel *iface, nsLoadFlags *aLoadFlags)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2006-02-09 12:19:13 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aLoadFlags);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
|
|
|
*aLoadFlags = This->load_flags;
|
|
|
|
return NS_OK;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetLoadFlags(nsIHttpChannel *iface, nsLoadFlags aLoadFlags)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%08x)\n", This, aLoadFlags);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
|
|
|
This->load_flags = aLoadFlags;
|
|
|
|
return NS_OK;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetOriginalURI(nsIHttpChannel *iface, nsIURI **aOriginalURI)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2006-02-09 12:19:13 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aOriginalURI);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
|
|
|
if(This->original_uri)
|
|
|
|
nsIURI_AddRef(This->original_uri);
|
|
|
|
|
|
|
|
*aOriginalURI = This->original_uri;
|
|
|
|
return NS_OK;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetOriginalURI(nsIHttpChannel *iface, nsIURI *aOriginalURI)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2006-02-09 12:19:13 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aOriginalURI);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
|
|
|
if(This->original_uri)
|
|
|
|
nsIURI_Release(This->original_uri);
|
|
|
|
|
|
|
|
nsIURI_AddRef(aOriginalURI);
|
|
|
|
This->original_uri = aOriginalURI;
|
|
|
|
return NS_OK;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetURI(nsIHttpChannel *iface, nsIURI **aURI)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aURI);
|
|
|
|
|
2012-07-26 11:37:48 +02:00
|
|
|
nsIFileURL_AddRef(&This->uri->nsIFileURL_iface);
|
2006-02-09 12:19:13 +01:00
|
|
|
*aURI = (nsIURI*)This->uri;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetOwner(nsIHttpChannel *iface, nsISupports **aOwner)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2006-02-09 12:19:13 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aOwner);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2008-12-18 14:08:31 +01:00
|
|
|
if(This->owner)
|
|
|
|
nsISupports_AddRef(This->owner);
|
|
|
|
*aOwner = This->owner;
|
|
|
|
|
|
|
|
return NS_OK;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetOwner(nsIHttpChannel *iface, nsISupports *aOwner)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2006-02-09 12:19:13 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aOwner);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2008-12-18 14:08:31 +01:00
|
|
|
if(aOwner)
|
|
|
|
nsISupports_AddRef(aOwner);
|
|
|
|
if(This->owner)
|
|
|
|
nsISupports_Release(This->owner);
|
|
|
|
This->owner = aOwner;
|
|
|
|
|
|
|
|
return NS_OK;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetNotificationCallbacks(nsIHttpChannel *iface,
|
|
|
|
nsIInterfaceRequestor **aNotificationCallbacks)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2006-02-09 12:19:13 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aNotificationCallbacks);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
|
|
|
if(This->notif_callback)
|
|
|
|
nsIInterfaceRequestor_AddRef(This->notif_callback);
|
|
|
|
*aNotificationCallbacks = This->notif_callback;
|
|
|
|
|
|
|
|
return NS_OK;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetNotificationCallbacks(nsIHttpChannel *iface,
|
|
|
|
nsIInterfaceRequestor *aNotificationCallbacks)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2006-02-09 12:19:13 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aNotificationCallbacks);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
|
|
|
if(This->notif_callback)
|
|
|
|
nsIInterfaceRequestor_Release(This->notif_callback);
|
|
|
|
if(aNotificationCallbacks)
|
|
|
|
nsIInterfaceRequestor_AddRef(aNotificationCallbacks);
|
|
|
|
|
|
|
|
This->notif_callback = aNotificationCallbacks;
|
|
|
|
|
|
|
|
return NS_OK;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetSecurityInfo(nsIHttpChannel *iface, nsISupports **aSecurityInfo)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-06-20 18:59:09 +02:00
|
|
|
|
2010-01-14 17:10:57 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aSecurityInfo);
|
2006-06-20 18:59:09 +02:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetContentType(nsIHttpChannel *iface, nsACString *aContentType)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2006-02-09 12:19:13 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aContentType);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2008-03-26 15:24:03 +01:00
|
|
|
if(This->content_type) {
|
|
|
|
nsACString_SetData(aContentType, This->content_type);
|
2006-06-03 00:48:13 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-27 15:56:32 +01:00
|
|
|
if(This->uri->is_doc_uri) {
|
|
|
|
WARN("Document channel with no MIME set. Assuming text/html\n");
|
|
|
|
nsACString_SetData(aContentType, "text/html");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-10-13 20:50:55 +02:00
|
|
|
WARN("unknown type\n");
|
|
|
|
return NS_ERROR_FAILURE;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetContentType(nsIHttpChannel *iface,
|
|
|
|
const nsACString *aContentType)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2008-03-26 15:24:38 +01:00
|
|
|
const char *content_type;
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2010-08-03 15:44:56 +02:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aContentType));
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2008-03-26 15:24:38 +01:00
|
|
|
nsACString_GetData(aContentType, &content_type);
|
|
|
|
heap_free(This->content_type);
|
|
|
|
This->content_type = heap_strdupA(content_type);
|
|
|
|
|
|
|
|
return NS_OK;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetContentCharset(nsIHttpChannel *iface,
|
|
|
|
nsACString *aContentCharset)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2006-02-09 12:19:13 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aContentCharset);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2007-04-12 21:25:08 +02:00
|
|
|
if(This->charset) {
|
|
|
|
nsACString_SetData(aContentCharset, This->charset);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2007-04-12 21:25:08 +02:00
|
|
|
nsACString_SetData(aContentCharset, "");
|
|
|
|
return NS_OK;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetContentCharset(nsIHttpChannel *iface,
|
|
|
|
const nsACString *aContentCharset)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2011-11-23 16:18:53 +01:00
|
|
|
const char *data;
|
|
|
|
char *charset;
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2011-11-23 16:18:53 +01:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aContentCharset));
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2011-11-23 16:18:53 +01:00
|
|
|
nsACString_GetData(aContentCharset, &data);
|
|
|
|
charset = heap_strdupA(data);
|
|
|
|
if(!charset)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
heap_free(This->charset);
|
|
|
|
This->charset = charset;
|
|
|
|
return NS_OK;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
2013-05-17 12:34:34 +02:00
|
|
|
static nsresult NSAPI nsChannel_GetContentLength(nsIHttpChannel *iface, INT64 *aContentLength)
|
2006-02-09 12:19:13 +01:00
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2010-01-04 00:38:20 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, aContentLength);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
2013-05-17 12:34:34 +02:00
|
|
|
static nsresult NSAPI nsChannel_SetContentLength(nsIHttpChannel *iface, INT64 aContentLength)
|
2006-02-09 12:19:13 +01:00
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2013-05-17 12:34:34 +02:00
|
|
|
FIXME("(%p)->(%s)\n", This, wine_dbgstr_longlong(aContentLength));
|
2006-02-20 11:13:37 +01:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_Open(nsIHttpChannel *iface, nsIInputStream **_retval)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
2010-01-04 00:38:20 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, _retval);
|
2006-02-20 11:13:37 +01:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
2012-06-25 14:04:59 +02:00
|
|
|
static HTMLOuterWindow *get_window_from_load_group(nsChannel *This)
|
2008-03-08 20:15:30 +01:00
|
|
|
{
|
2012-06-25 14:04:59 +02:00
|
|
|
HTMLOuterWindow *window;
|
2008-03-08 20:15:30 +01:00
|
|
|
nsIChannel *channel;
|
|
|
|
nsIRequest *req;
|
2010-02-21 21:08:39 +01:00
|
|
|
nsWineURI *wine_uri;
|
2008-03-08 20:15:30 +01:00
|
|
|
nsIURI *uri;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = nsILoadGroup_GetDefaultLoadRequest(This->load_group, &req);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("GetDefaultLoadRequest failed: %08x\n", nsres);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-04-10 10:38:05 +02:00
|
|
|
if(!req)
|
|
|
|
return NULL;
|
|
|
|
|
2008-03-08 20:15:30 +01:00
|
|
|
nsres = nsIRequest_QueryInterface(req, &IID_nsIChannel, (void**)&channel);
|
|
|
|
nsIRequest_Release(req);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
WARN("Could not get nsIChannel interface: %08x\n", nsres);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIChannel_GetURI(channel, &uri);
|
|
|
|
nsIChannel_Release(channel);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("GetURI failed: %08x\n", nsres);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
nsres = nsIURI_QueryInterface(uri, &IID_nsWineURI, (void**)&wine_uri);
|
2008-03-08 20:15:30 +01:00
|
|
|
nsIURI_Release(uri);
|
|
|
|
if(NS_FAILED(nsres)) {
|
2010-02-21 21:10:15 +01:00
|
|
|
TRACE("Could not get nsWineURI: %08x\n", nsres);
|
2008-03-08 20:15:30 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-02-21 21:08:39 +01:00
|
|
|
window = wine_uri->window_ref ? wine_uri->window_ref->window : NULL;
|
|
|
|
if(window)
|
2012-06-25 14:04:59 +02:00
|
|
|
IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
|
2012-07-26 11:37:48 +02:00
|
|
|
nsIFileURL_Release(&wine_uri->nsIFileURL_iface);
|
2008-03-08 20:15:30 +01:00
|
|
|
|
2009-10-26 23:03:29 +01:00
|
|
|
return window;
|
2008-03-08 20:15:30 +01:00
|
|
|
}
|
|
|
|
|
2012-06-25 14:04:59 +02:00
|
|
|
static HTMLOuterWindow *get_channel_window(nsChannel *This)
|
2009-10-26 23:02:50 +01:00
|
|
|
{
|
|
|
|
nsIWebProgress *web_progress;
|
|
|
|
nsIDOMWindow *nswindow;
|
2012-06-25 14:04:59 +02:00
|
|
|
HTMLOuterWindow *window;
|
2009-10-26 23:02:50 +01:00
|
|
|
nsresult nsres;
|
|
|
|
|
2010-09-17 18:33:32 +02:00
|
|
|
if(This->load_group) {
|
|
|
|
nsIRequestObserver *req_observer;
|
2009-10-26 23:02:50 +01:00
|
|
|
|
2010-09-17 18:33:32 +02:00
|
|
|
nsres = nsILoadGroup_GetGroupObserver(This->load_group, &req_observer);
|
|
|
|
if(NS_FAILED(nsres) || !req_observer) {
|
|
|
|
ERR("GetGroupObserver failed: %08x\n", nsres);
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-10-26 23:02:50 +01:00
|
|
|
|
2010-09-17 18:33:32 +02:00
|
|
|
nsres = nsIRequestObserver_QueryInterface(req_observer, &IID_nsIWebProgress, (void**)&web_progress);
|
|
|
|
nsIRequestObserver_Release(req_observer);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("Could not get nsIWebProgress iface: %08x\n", nsres);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}else if(This->notif_callback) {
|
|
|
|
nsres = nsIInterfaceRequestor_GetInterface(This->notif_callback, &IID_nsIWebProgress, (void**)&web_progress);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("GetInterface(IID_nsIWebProgress failed: %08x\n", nsres);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
ERR("no load group nor notif callback\n");
|
2009-10-26 23:02:50 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIWebProgress_GetDOMWindow(web_progress, &nswindow);
|
|
|
|
nsIWebProgress_Release(web_progress);
|
|
|
|
if(NS_FAILED(nsres) || !nswindow) {
|
|
|
|
ERR("GetDOMWindow failed: %08x\n", nsres);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
window = nswindow_to_window(nswindow);
|
|
|
|
nsIDOMWindow_Release(nswindow);
|
|
|
|
|
|
|
|
if(window)
|
2012-06-25 14:04:59 +02:00
|
|
|
IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
|
2009-10-26 23:02:50 +01:00
|
|
|
else
|
|
|
|
FIXME("NULL window for %p\n", nswindow);
|
|
|
|
return window;
|
|
|
|
}
|
|
|
|
|
2009-10-26 23:05:10 +01:00
|
|
|
typedef struct {
|
|
|
|
task_t header;
|
2012-07-11 13:51:00 +02:00
|
|
|
HTMLInnerWindow *window;
|
2009-10-26 23:05:10 +01:00
|
|
|
nsChannelBSC *bscallback;
|
|
|
|
} start_binding_task_t;
|
|
|
|
|
|
|
|
static void start_binding_proc(task_t *_task)
|
|
|
|
{
|
|
|
|
start_binding_task_t *task = (start_binding_task_t*)_task;
|
|
|
|
|
2012-07-12 14:26:13 +02:00
|
|
|
start_binding(task->window, (BSCallback*)task->bscallback, NULL);
|
2011-08-03 12:36:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void start_binding_task_destr(task_t *_task)
|
|
|
|
{
|
|
|
|
start_binding_task_t *task = (start_binding_task_t*)_task;
|
2009-10-26 23:05:37 +01:00
|
|
|
|
2011-08-03 12:36:26 +02:00
|
|
|
IBindStatusCallback_Release(&task->bscallback->bsc.IBindStatusCallback_iface);
|
|
|
|
heap_free(task);
|
2009-10-26 23:05:10 +01:00
|
|
|
}
|
|
|
|
|
2012-06-25 14:04:59 +02:00
|
|
|
static nsresult async_open(nsChannel *This, HTMLOuterWindow *window, BOOL is_doc_channel, nsIStreamListener *listener,
|
2007-11-02 19:53:02 +01:00
|
|
|
nsISupports *context)
|
|
|
|
{
|
2008-03-23 02:16:03 +01:00
|
|
|
nsChannelBSC *bscallback;
|
2007-11-02 19:53:02 +01:00
|
|
|
IMoniker *mon = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2011-06-23 13:45:18 +02:00
|
|
|
hres = CreateURLMonikerEx2(NULL, This->uri->uri, &mon, 0);
|
2010-09-16 22:47:00 +02:00
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("CreateURLMoniker failed: %08x\n", hres);
|
2006-08-09 16:42:51 +02:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
2010-09-16 22:47:00 +02:00
|
|
|
}
|
2006-02-10 14:49:41 +01:00
|
|
|
|
2009-10-26 23:03:29 +01:00
|
|
|
if(is_doc_channel)
|
2012-11-12 12:57:48 +01:00
|
|
|
set_current_mon(window, mon, BINDING_NAVIGATED);
|
2009-10-26 23:03:29 +01:00
|
|
|
|
2012-07-12 14:26:13 +02:00
|
|
|
hres = create_channelbsc(mon, NULL, NULL, 0, is_doc_channel, &bscallback);
|
2006-08-09 16:42:51 +02:00
|
|
|
IMoniker_Release(mon);
|
2010-03-03 14:53:49 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2006-03-18 22:00:34 +01:00
|
|
|
|
2008-03-23 02:15:20 +01:00
|
|
|
channelbsc_set_channel(bscallback, This, listener, context);
|
2006-02-10 14:49:41 +01:00
|
|
|
|
2009-10-26 23:05:37 +01:00
|
|
|
if(is_doc_channel) {
|
2012-07-12 14:25:43 +02:00
|
|
|
hres = create_pending_window(window, bscallback);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
async_start_doc_binding(window, window->pending_window);
|
2012-10-19 11:58:01 +02:00
|
|
|
IBindStatusCallback_Release(&bscallback->bsc.IBindStatusCallback_iface);
|
2012-07-12 14:25:43 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2009-10-26 23:05:37 +01:00
|
|
|
}else {
|
2012-10-19 11:58:01 +02:00
|
|
|
start_binding_task_t *task;
|
|
|
|
|
|
|
|
task = heap_alloc(sizeof(start_binding_task_t));
|
|
|
|
if(!task) {
|
|
|
|
IBindStatusCallback_Release(&bscallback->bsc.IBindStatusCallback_iface);
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2009-10-26 23:05:37 +01:00
|
|
|
|
2012-07-11 13:51:00 +02:00
|
|
|
task->window = window->base.inner_window;
|
2009-10-26 23:05:37 +01:00
|
|
|
task->bscallback = bscallback;
|
2012-10-19 11:56:59 +02:00
|
|
|
hres = push_task(&task->header, start_binding_proc, start_binding_task_destr, window->base.inner_window->task_magic);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2009-10-26 23:05:37 +01:00
|
|
|
}
|
2006-08-09 16:42:51 +02:00
|
|
|
|
|
|
|
return NS_OK;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
2007-11-02 19:53:02 +01:00
|
|
|
static nsresult NSAPI nsChannel_AsyncOpen(nsIHttpChannel *iface, nsIStreamListener *aListener,
|
|
|
|
nsISupports *aContext)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2012-06-25 14:04:59 +02:00
|
|
|
HTMLOuterWindow *window = NULL;
|
2011-06-23 13:45:34 +02:00
|
|
|
BOOL cancel = FALSE;
|
2007-11-02 19:53:02 +01:00
|
|
|
nsresult nsres = NS_OK;
|
|
|
|
|
2011-06-25 19:03:38 +02:00
|
|
|
TRACE("(%p)->(%p %p)\n", This, aListener, aContext);
|
2009-10-26 23:02:50 +01:00
|
|
|
|
2011-06-23 13:45:18 +02:00
|
|
|
if(!ensure_uri(This->uri))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2011-11-12 18:25:23 +01:00
|
|
|
if(TRACE_ON(mshtml)) {
|
2012-11-27 12:16:34 +01:00
|
|
|
HRESULT hres;
|
2011-11-12 18:25:23 +01:00
|
|
|
BSTR uri_str;
|
2012-11-27 12:16:34 +01:00
|
|
|
|
|
|
|
hres = IUri_GetDisplayUri(This->uri->uri, &uri_str);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
TRACE("opening %s\n", debugstr_w(uri_str));
|
|
|
|
SysFreeString(uri_str);
|
|
|
|
}else {
|
|
|
|
WARN("GetDisplayUri failed: %08x\n", hres);
|
|
|
|
}
|
2011-11-12 18:25:23 +01:00
|
|
|
}
|
|
|
|
|
2010-02-21 21:05:15 +01:00
|
|
|
if(This->uri->is_doc_uri) {
|
2009-10-26 23:02:50 +01:00
|
|
|
window = get_channel_window(This);
|
|
|
|
if(window) {
|
2010-02-21 21:08:39 +01:00
|
|
|
set_uri_window(This->uri, window);
|
2010-02-21 21:05:15 +01:00
|
|
|
}else if(This->uri->container) {
|
|
|
|
BOOL b;
|
|
|
|
|
|
|
|
/* nscontainer->doc should be NULL which means navigation to a new window */
|
|
|
|
if(This->uri->container->doc)
|
|
|
|
FIXME("nscontainer->doc = %p\n", This->uri->container->doc);
|
|
|
|
|
2011-06-23 13:45:34 +02:00
|
|
|
nsres = before_async_open(This, This->uri->container, &b);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return nsres;
|
2010-02-21 21:05:15 +01:00
|
|
|
if(b)
|
|
|
|
FIXME("Navigation not cancelled\n");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2009-10-26 23:02:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-26 23:03:29 +01:00
|
|
|
if(!window) {
|
2010-02-21 21:08:39 +01:00
|
|
|
if(This->uri->window_ref && This->uri->window_ref->window) {
|
|
|
|
window = This->uri->window_ref->window;
|
2012-06-25 14:04:59 +02:00
|
|
|
IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
|
2010-09-17 18:33:32 +02:00
|
|
|
}else {
|
|
|
|
/* FIXME: Analyze removing get_window_from_load_group call */
|
|
|
|
if(This->load_group)
|
|
|
|
window = get_window_from_load_group(This);
|
|
|
|
if(!window)
|
|
|
|
window = get_channel_window(This);
|
2009-10-26 23:03:29 +01:00
|
|
|
if(window)
|
2010-02-21 21:08:39 +01:00
|
|
|
set_uri_window(This->uri, window);
|
2009-10-26 23:03:29 +01:00
|
|
|
}
|
2008-03-08 20:15:30 +01:00
|
|
|
}
|
|
|
|
|
2009-10-26 23:03:29 +01:00
|
|
|
if(!window) {
|
2009-12-01 22:50:00 +01:00
|
|
|
ERR("window = NULL\n");
|
2010-01-04 00:38:20 +01:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
2007-11-02 19:53:02 +01:00
|
|
|
}
|
|
|
|
|
2010-02-21 21:05:15 +01:00
|
|
|
if(This->uri->is_doc_uri && window == window->doc_obj->basedoc.window) {
|
|
|
|
if(This->uri->channel_bsc) {
|
|
|
|
channelbsc_set_channel(This->uri->channel_bsc, This, aListener, aContext);
|
2009-10-26 23:03:29 +01:00
|
|
|
|
2010-01-04 00:38:57 +01:00
|
|
|
if(window->doc_obj->mime) {
|
2009-10-26 23:03:29 +01:00
|
|
|
heap_free(This->content_type);
|
2010-01-04 00:38:57 +01:00
|
|
|
This->content_type = heap_strdupWtoA(window->doc_obj->mime);
|
2009-10-26 23:03:29 +01:00
|
|
|
}
|
|
|
|
|
2011-06-23 13:45:34 +02:00
|
|
|
cancel = TRUE;
|
2009-10-26 23:03:29 +01:00
|
|
|
}else {
|
2011-06-23 13:45:34 +02:00
|
|
|
nsres = before_async_open(This, window->doc_obj->nscontainer, &cancel);
|
|
|
|
if(NS_SUCCEEDED(nsres) && cancel) {
|
2009-10-26 23:03:29 +01:00
|
|
|
TRACE("canceled\n");
|
2011-07-22 15:35:47 +02:00
|
|
|
nsres = NS_BINDING_ABORTED;
|
2009-10-26 23:03:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-11-02 19:53:02 +01:00
|
|
|
|
2011-06-23 13:45:34 +02:00
|
|
|
if(!cancel)
|
2010-02-21 21:05:15 +01:00
|
|
|
nsres = async_open(This, window, This->uri->is_doc_uri, aListener, aContext);
|
2007-11-02 19:53:02 +01:00
|
|
|
|
2010-08-18 13:38:30 +02:00
|
|
|
if(NS_SUCCEEDED(nsres) && This->load_group) {
|
2010-12-30 01:43:11 +01:00
|
|
|
nsres = nsILoadGroup_AddRequest(This->load_group, (nsIRequest*)&This->nsIHttpChannel_iface,
|
|
|
|
aContext);
|
2010-08-18 13:38:30 +02:00
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("AddRequest failed: %08x\n", nsres);
|
|
|
|
}
|
|
|
|
|
2012-06-25 14:04:59 +02:00
|
|
|
IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface);
|
2007-11-02 19:53:02 +01:00
|
|
|
return nsres;
|
|
|
|
}
|
|
|
|
|
2013-01-23 18:44:42 +01:00
|
|
|
static nsresult NSAPI nsChannel_GetContentDisposition(nsIHttpChannel *iface, UINT32 *aContentDisposition)
|
2012-03-14 14:45:32 +01:00
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, aContentDisposition);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2013-01-23 18:44:42 +01:00
|
|
|
static nsresult NSAPI nsChannel_SetContentDisposition(nsIHttpChannel *iface, UINT32 aContentDisposition)
|
2013-01-09 14:21:18 +01:00
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
|
|
|
FIXME("(%p)->(%u)\n", This, aContentDisposition);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-03-14 14:45:32 +01:00
|
|
|
static nsresult NSAPI nsChannel_GetContentDispositionFilename(nsIHttpChannel *iface, nsAString *aContentDispositionFilename)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, aContentDispositionFilename);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2013-01-09 14:21:18 +01:00
|
|
|
static nsresult NSAPI nsChannel_SetContentDispositionFilename(nsIHttpChannel *iface, const nsAString *aContentDispositionFilename)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, aContentDispositionFilename);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-03-14 14:45:32 +01:00
|
|
|
static nsresult NSAPI nsChannel_GetContentDispositionHeader(nsIHttpChannel *iface, nsACString *aContentDispositionHeader)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, aContentDispositionHeader);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2014-11-03 12:39:59 +01:00
|
|
|
static nsresult NSAPI nsChannel_GetLoadInfo(nsIHttpChannel *iface, nsILoadInfo **aLoadInfo)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aLoadInfo);
|
|
|
|
|
|
|
|
if(This->load_info)
|
|
|
|
nsISupports_AddRef(This->load_info);
|
|
|
|
*aLoadInfo = This->load_info;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetLoadInfo(nsIHttpChannel *iface, nsILoadInfo *aLoadInfo)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aLoadInfo);
|
|
|
|
|
|
|
|
if(This->load_info)
|
|
|
|
nsISupports_Release(This->load_info);
|
|
|
|
This->load_info = aLoadInfo;
|
|
|
|
if(This->load_info)
|
|
|
|
nsISupports_AddRef(This->load_info);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-02-09 12:19:13 +01:00
|
|
|
static nsresult NSAPI nsChannel_GetRequestMethod(nsIHttpChannel *iface, nsACString *aRequestMethod)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2010-08-03 21:40:30 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, aRequestMethod);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2010-08-03 21:40:30 +02:00
|
|
|
nsACString_SetData(aRequestMethod, request_method_strings[This->request_method]);
|
|
|
|
return NS_OK;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetRequestMethod(nsIHttpChannel *iface,
|
|
|
|
const nsACString *aRequestMethod)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2010-08-03 21:40:20 +02:00
|
|
|
const char *method;
|
|
|
|
unsigned i;
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2010-08-03 21:40:20 +02:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aRequestMethod));
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2010-08-03 21:40:20 +02:00
|
|
|
nsACString_GetData(aRequestMethod, &method);
|
|
|
|
for(i=0; i < sizeof(request_method_strings)/sizeof(*request_method_strings); i++) {
|
|
|
|
if(!strcasecmp(method, request_method_strings[i])) {
|
|
|
|
This->request_method = i;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ERR("Invalid method %s\n", debugstr_a(method));
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetReferrer(nsIHttpChannel *iface, nsIURI **aReferrer)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2010-08-18 13:37:08 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, aReferrer);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2010-08-18 13:37:08 +02:00
|
|
|
if(This->referrer)
|
|
|
|
nsIURI_AddRef(This->referrer);
|
|
|
|
*aReferrer = This->referrer;
|
|
|
|
return NS_OK;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetReferrer(nsIHttpChannel *iface, nsIURI *aReferrer)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2010-08-18 13:37:08 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, aReferrer);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2010-08-18 13:37:08 +02:00
|
|
|
if(aReferrer)
|
|
|
|
nsIURI_AddRef(aReferrer);
|
|
|
|
if(This->referrer)
|
|
|
|
nsIURI_Release(This->referrer);
|
|
|
|
This->referrer = aReferrer;
|
2010-01-04 00:38:20 +01:00
|
|
|
return NS_OK;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:19:41 +01:00
|
|
|
static nsresult NSAPI nsChannel_GetReferrerPolicy(nsIHttpChannel *iface, UINT32 *aReferrerPolicy)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, aReferrerPolicy);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetReferrerWithPolicy(nsIHttpChannel *iface, nsIURI *aReferrer, UINT32 aReferrerPolicy)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
|
|
|
FIXME("(%p)->(%p %x)\n", This, aReferrer, aReferrerPolicy);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2006-02-09 12:19:13 +01:00
|
|
|
static nsresult NSAPI nsChannel_GetRequestHeader(nsIHttpChannel *iface,
|
|
|
|
const nsACString *aHeader, nsACString *_retval)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2010-08-03 21:39:49 +02:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_nsacstr(aHeader), _retval);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2010-08-03 21:39:49 +02:00
|
|
|
return get_channel_http_header(&This->request_headers, aHeader, _retval);
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetRequestHeader(nsIHttpChannel *iface,
|
2012-03-15 11:54:33 +01:00
|
|
|
const nsACString *aHeader, const nsACString *aValue, cpp_bool aMerge)
|
2006-02-09 12:19:13 +01:00
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2010-08-03 21:40:05 +02:00
|
|
|
TRACE("(%p)->(%s %s %x)\n", This, debugstr_nsacstr(aHeader), debugstr_nsacstr(aValue), aMerge);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2010-08-03 21:40:05 +02:00
|
|
|
if(aMerge)
|
|
|
|
FIXME("aMerge not supported\n");
|
|
|
|
|
|
|
|
return set_channel_http_header(&This->request_headers, aHeader, aValue);
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_VisitRequestHeaders(nsIHttpChannel *iface,
|
|
|
|
nsIHttpHeaderVisitor *aVisitor)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2009-12-21 00:23:02 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, aVisitor);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-03-15 11:54:33 +01:00
|
|
|
static nsresult NSAPI nsChannel_GetAllowPipelining(nsIHttpChannel *iface, cpp_bool *aAllowPipelining)
|
2006-02-09 12:19:13 +01:00
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2009-12-21 00:23:02 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, aAllowPipelining);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-03-15 11:54:33 +01:00
|
|
|
static nsresult NSAPI nsChannel_SetAllowPipelining(nsIHttpChannel *iface, cpp_bool aAllowPipelining)
|
2006-02-09 12:19:13 +01:00
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2009-12-21 00:23:02 +01:00
|
|
|
FIXME("(%p)->(%x)\n", This, aAllowPipelining);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2014-11-03 12:39:59 +01:00
|
|
|
static nsresult NSAPI nsChannel_GetAllowTLS(nsIHttpChannel *iface, cpp_bool *aAllowTLS)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, aAllowTLS);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetAllowTLS(nsIHttpChannel *iface, cpp_bool aAllowTLS)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
|
|
|
FIXME("(%p)->(%x)\n", This, aAllowTLS);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2013-01-23 18:44:42 +01:00
|
|
|
static nsresult NSAPI nsChannel_GetRedirectionLimit(nsIHttpChannel *iface, UINT32 *aRedirectionLimit)
|
2006-02-09 12:19:13 +01:00
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2009-12-21 00:23:02 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, aRedirectionLimit);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2013-01-23 18:44:42 +01:00
|
|
|
static nsresult NSAPI nsChannel_SetRedirectionLimit(nsIHttpChannel *iface, UINT32 aRedirectionLimit)
|
2006-02-09 12:19:13 +01:00
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2009-12-21 00:23:02 +01:00
|
|
|
FIXME("(%p)->(%u)\n", This, aRedirectionLimit);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2013-01-23 18:44:42 +01:00
|
|
|
static nsresult NSAPI nsChannel_GetResponseStatus(nsIHttpChannel *iface, UINT32 *aResponseStatus)
|
2006-02-09 12:19:13 +01:00
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aResponseStatus);
|
|
|
|
|
2009-08-11 19:15:07 +02:00
|
|
|
if(This->response_status) {
|
|
|
|
*aResponseStatus = This->response_status;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-12-21 00:23:02 +01:00
|
|
|
WARN("No response status\n");
|
2009-08-11 19:15:07 +02:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetResponseStatusText(nsIHttpChannel *iface,
|
|
|
|
nsACString *aResponseStatusText)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2015-07-22 17:34:12 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, aResponseStatusText);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2015-07-22 17:34:12 +02:00
|
|
|
nsACString_SetData(aResponseStatusText, This->response_status_text);
|
|
|
|
return NS_OK;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetRequestSucceeded(nsIHttpChannel *iface,
|
2012-03-15 11:54:33 +01:00
|
|
|
cpp_bool *aRequestSucceeded)
|
2006-02-09 12:19:13 +01:00
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2010-04-03 00:31:42 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, aRequestSucceeded);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2010-04-03 00:31:42 +02:00
|
|
|
if(!This->response_status)
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2010-04-05 20:20:59 +02:00
|
|
|
*aRequestSucceeded = This->response_status/100 == 2;
|
2010-04-03 00:31:42 +02:00
|
|
|
|
|
|
|
return NS_OK;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetResponseHeader(nsIHttpChannel *iface,
|
|
|
|
const nsACString *header, nsACString *_retval)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2010-08-03 15:44:56 +02:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_nsacstr(header), _retval);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2010-08-03 21:38:11 +02:00
|
|
|
return get_channel_http_header(&This->response_headers, header, _retval);
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetResponseHeader(nsIHttpChannel *iface,
|
2012-03-15 11:54:33 +01:00
|
|
|
const nsACString *header, const nsACString *value, cpp_bool merge)
|
2006-02-09 12:19:13 +01:00
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2010-08-03 15:44:56 +02:00
|
|
|
FIXME("(%p)->(%s %s %x)\n", This, debugstr_nsacstr(header), debugstr_nsacstr(value), merge);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_VisitResponseHeaders(nsIHttpChannel *iface,
|
|
|
|
nsIHttpHeaderVisitor *aVisitor)
|
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2010-09-17 18:33:10 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, aVisitor);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2010-09-17 18:33:10 +02:00
|
|
|
return visit_http_headers(&This->response_headers, aVisitor);
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
2012-03-15 11:54:33 +01:00
|
|
|
static nsresult NSAPI nsChannel_IsNoStoreResponse(nsIHttpChannel *iface, cpp_bool *_retval)
|
2006-02-09 12:19:13 +01:00
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2010-10-13 15:11:13 +02:00
|
|
|
http_header_t *header;
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2010-10-13 15:11:13 +02:00
|
|
|
static const WCHAR cache_controlW[] = {'C','a','c','h','e','-','C','o','n','t','r','o','l'};
|
|
|
|
static const WCHAR no_storeW[] = {'n','o','-','s','t','o','r','e',0};
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2010-10-13 15:11:13 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, _retval);
|
|
|
|
|
|
|
|
header = find_http_header(&This->response_headers, cache_controlW, sizeof(cache_controlW)/sizeof(WCHAR));
|
|
|
|
*_retval = header && !strcmpiW(header->data, no_storeW);
|
|
|
|
return NS_OK;
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
2012-03-15 11:54:33 +01:00
|
|
|
static nsresult NSAPI nsChannel_IsNoCacheResponse(nsIHttpChannel *iface, cpp_bool *_retval)
|
2006-02-09 12:19:13 +01:00
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2009-12-21 00:23:02 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, _retval);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-08-11 15:11:35 +02:00
|
|
|
static nsresult NSAPI nsChannel_IsPrivateResponse(nsIHttpChannel *iface, cpp_bool *_retval)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p)\n", This, _retval);
|
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2013-05-17 12:34:34 +02:00
|
|
|
static nsresult NSAPI nsChannel_RedirectTo(nsIHttpChannel *iface, nsIURI *aNewURI)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannel(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p)\n", This, aNewURI);
|
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2006-02-09 12:19:13 +01:00
|
|
|
static const nsIHttpChannelVtbl nsChannelVtbl = {
|
|
|
|
nsChannel_QueryInterface,
|
|
|
|
nsChannel_AddRef,
|
|
|
|
nsChannel_Release,
|
|
|
|
nsChannel_GetName,
|
|
|
|
nsChannel_IsPending,
|
|
|
|
nsChannel_GetStatus,
|
|
|
|
nsChannel_Cancel,
|
|
|
|
nsChannel_Suspend,
|
|
|
|
nsChannel_Resume,
|
|
|
|
nsChannel_GetLoadGroup,
|
|
|
|
nsChannel_SetLoadGroup,
|
|
|
|
nsChannel_GetLoadFlags,
|
|
|
|
nsChannel_SetLoadFlags,
|
|
|
|
nsChannel_GetOriginalURI,
|
|
|
|
nsChannel_SetOriginalURI,
|
|
|
|
nsChannel_GetURI,
|
|
|
|
nsChannel_GetOwner,
|
|
|
|
nsChannel_SetOwner,
|
|
|
|
nsChannel_GetNotificationCallbacks,
|
|
|
|
nsChannel_SetNotificationCallbacks,
|
|
|
|
nsChannel_GetSecurityInfo,
|
|
|
|
nsChannel_GetContentType,
|
|
|
|
nsChannel_SetContentType,
|
|
|
|
nsChannel_GetContentCharset,
|
|
|
|
nsChannel_SetContentCharset,
|
|
|
|
nsChannel_GetContentLength,
|
|
|
|
nsChannel_SetContentLength,
|
|
|
|
nsChannel_Open,
|
|
|
|
nsChannel_AsyncOpen,
|
2012-03-14 14:45:32 +01:00
|
|
|
nsChannel_GetContentDisposition,
|
2013-01-09 14:21:18 +01:00
|
|
|
nsChannel_SetContentDisposition,
|
2012-03-14 14:45:32 +01:00
|
|
|
nsChannel_GetContentDispositionFilename,
|
2013-01-09 14:21:18 +01:00
|
|
|
nsChannel_SetContentDispositionFilename,
|
2012-03-14 14:45:32 +01:00
|
|
|
nsChannel_GetContentDispositionHeader,
|
2014-11-03 12:39:59 +01:00
|
|
|
nsChannel_GetLoadInfo,
|
|
|
|
nsChannel_SetLoadInfo,
|
2006-02-09 12:19:13 +01:00
|
|
|
nsChannel_GetRequestMethod,
|
|
|
|
nsChannel_SetRequestMethod,
|
|
|
|
nsChannel_GetReferrer,
|
|
|
|
nsChannel_SetReferrer,
|
2015-02-24 14:19:41 +01:00
|
|
|
nsChannel_GetReferrerPolicy,
|
|
|
|
nsChannel_SetReferrerWithPolicy,
|
2006-02-09 12:19:13 +01:00
|
|
|
nsChannel_GetRequestHeader,
|
|
|
|
nsChannel_SetRequestHeader,
|
|
|
|
nsChannel_VisitRequestHeaders,
|
|
|
|
nsChannel_GetAllowPipelining,
|
|
|
|
nsChannel_SetAllowPipelining,
|
2014-11-03 12:39:59 +01:00
|
|
|
nsChannel_GetAllowTLS,
|
|
|
|
nsChannel_SetAllowTLS,
|
2006-02-09 12:19:13 +01:00
|
|
|
nsChannel_GetRedirectionLimit,
|
|
|
|
nsChannel_SetRedirectionLimit,
|
|
|
|
nsChannel_GetResponseStatus,
|
|
|
|
nsChannel_GetResponseStatusText,
|
|
|
|
nsChannel_GetRequestSucceeded,
|
|
|
|
nsChannel_GetResponseHeader,
|
|
|
|
nsChannel_SetResponseHeader,
|
|
|
|
nsChannel_VisitResponseHeaders,
|
|
|
|
nsChannel_IsNoStoreResponse,
|
2013-05-17 12:34:34 +02:00
|
|
|
nsChannel_IsNoCacheResponse,
|
2015-08-11 15:11:35 +02:00
|
|
|
nsChannel_IsPrivateResponse,
|
2013-05-17 12:34:34 +02:00
|
|
|
nsChannel_RedirectTo
|
2006-02-09 12:19:13 +01:00
|
|
|
};
|
|
|
|
|
2010-12-30 01:49:21 +01:00
|
|
|
static inline nsChannel *impl_from_nsIUploadChannel(nsIUploadChannel *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, nsChannel, nsIUploadChannel_iface);
|
|
|
|
}
|
2006-02-10 14:49:41 +01:00
|
|
|
|
|
|
|
static nsresult NSAPI nsUploadChannel_QueryInterface(nsIUploadChannel *iface, nsIIDRef riid,
|
2010-08-02 11:08:26 +02:00
|
|
|
void **result)
|
2006-02-10 14:49:41 +01:00
|
|
|
{
|
2010-12-30 01:49:21 +01:00
|
|
|
nsChannel *This = impl_from_nsIUploadChannel(iface);
|
2012-07-26 11:37:48 +02:00
|
|
|
return nsIHttpChannel_QueryInterface(&This->nsIHttpChannel_iface, riid, result);
|
2006-02-10 14:49:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsUploadChannel_AddRef(nsIUploadChannel *iface)
|
|
|
|
{
|
2010-12-30 01:49:21 +01:00
|
|
|
nsChannel *This = impl_from_nsIUploadChannel(iface);
|
2012-07-26 11:37:48 +02:00
|
|
|
return nsIHttpChannel_AddRef(&This->nsIHttpChannel_iface);
|
2006-02-10 14:49:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsUploadChannel_Release(nsIUploadChannel *iface)
|
|
|
|
{
|
2010-12-30 01:49:21 +01:00
|
|
|
nsChannel *This = impl_from_nsIUploadChannel(iface);
|
2012-07-26 11:37:48 +02:00
|
|
|
return nsIHttpChannel_Release(&This->nsIHttpChannel_iface);
|
2006-02-10 14:49:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsUploadChannel_SetUploadStream(nsIUploadChannel *iface,
|
2013-01-23 18:43:25 +01:00
|
|
|
nsIInputStream *aStream, const nsACString *aContentType, INT64 aContentLength)
|
2006-02-10 14:49:41 +01:00
|
|
|
{
|
2010-12-30 01:49:21 +01:00
|
|
|
nsChannel *This = impl_from_nsIUploadChannel(iface);
|
2006-02-10 14:49:41 +01:00
|
|
|
const char *content_type;
|
|
|
|
|
2010-08-03 21:40:56 +02:00
|
|
|
static const WCHAR content_typeW[] =
|
|
|
|
{'C','o','n','t','e','n','t','-','T','y','p','e',0};
|
2006-02-10 14:49:41 +01:00
|
|
|
|
2013-01-09 14:21:18 +01:00
|
|
|
TRACE("(%p)->(%p %s %s)\n", This, aStream, debugstr_nsacstr(aContentType), wine_dbgstr_longlong(aContentLength));
|
2006-02-10 14:49:41 +01:00
|
|
|
|
2011-04-05 15:23:25 +02:00
|
|
|
This->post_data_contains_headers = TRUE;
|
|
|
|
|
2006-02-10 14:49:41 +01:00
|
|
|
if(aContentType) {
|
2007-12-17 01:38:15 +01:00
|
|
|
nsACString_GetData(aContentType, &content_type);
|
2010-08-03 21:40:56 +02:00
|
|
|
if(*content_type) {
|
|
|
|
WCHAR *ct;
|
|
|
|
|
|
|
|
ct = heap_strdupAtoW(content_type);
|
|
|
|
if(!ct)
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
set_http_header(&This->request_headers, content_typeW,
|
|
|
|
sizeof(content_typeW)/sizeof(WCHAR), ct, strlenW(ct));
|
|
|
|
heap_free(ct);
|
2011-04-05 15:23:25 +02:00
|
|
|
This->post_data_contains_headers = FALSE;
|
2010-08-03 21:40:56 +02:00
|
|
|
}
|
2006-02-10 14:49:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(aContentLength != -1)
|
2013-01-09 14:21:18 +01:00
|
|
|
FIXME("Unsupported acontentLength = %s\n", wine_dbgstr_longlong(aContentLength));
|
2006-02-10 14:49:41 +01:00
|
|
|
|
2008-11-22 20:06:37 +01:00
|
|
|
if(This->post_data_stream)
|
|
|
|
nsIInputStream_Release(This->post_data_stream);
|
|
|
|
This->post_data_stream = aStream;
|
2006-02-10 14:49:41 +01:00
|
|
|
if(aStream)
|
|
|
|
nsIInputStream_AddRef(aStream);
|
2008-11-22 20:06:37 +01:00
|
|
|
|
2010-08-03 21:40:20 +02:00
|
|
|
This->request_method = METHOD_POST;
|
2006-02-10 14:49:41 +01:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsUploadChannel_GetUploadStream(nsIUploadChannel *iface,
|
|
|
|
nsIInputStream **aUploadStream)
|
|
|
|
{
|
2010-12-30 01:49:21 +01:00
|
|
|
nsChannel *This = impl_from_nsIUploadChannel(iface);
|
2006-02-10 14:49:41 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aUploadStream);
|
|
|
|
|
|
|
|
if(This->post_data_stream)
|
|
|
|
nsIInputStream_AddRef(This->post_data_stream);
|
|
|
|
|
|
|
|
*aUploadStream = This->post_data_stream;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const nsIUploadChannelVtbl nsUploadChannelVtbl = {
|
|
|
|
nsUploadChannel_QueryInterface,
|
|
|
|
nsUploadChannel_AddRef,
|
|
|
|
nsUploadChannel_Release,
|
|
|
|
nsUploadChannel_SetUploadStream,
|
|
|
|
nsUploadChannel_GetUploadStream
|
|
|
|
};
|
|
|
|
|
2010-12-30 01:49:21 +01:00
|
|
|
static inline nsChannel *impl_from_nsIHttpChannelInternal(nsIHttpChannelInternal *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, nsChannel, nsIHttpChannelInternal_iface);
|
|
|
|
}
|
2009-08-22 19:37:30 +02:00
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_QueryInterface(nsIHttpChannelInternal *iface, nsIIDRef riid,
|
2010-08-02 11:08:26 +02:00
|
|
|
void **result)
|
2009-08-22 19:37:30 +02:00
|
|
|
{
|
2010-12-30 01:49:21 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
2012-07-26 11:37:48 +02:00
|
|
|
return nsIHttpChannel_QueryInterface(&This->nsIHttpChannel_iface, riid, result);
|
2009-08-22 19:37:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsHttpChannelInternal_AddRef(nsIHttpChannelInternal *iface)
|
|
|
|
{
|
2010-12-30 01:49:21 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
2012-07-26 11:37:48 +02:00
|
|
|
return nsIHttpChannel_AddRef(&This->nsIHttpChannel_iface);
|
2009-08-22 19:37:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsHttpChannelInternal_Release(nsIHttpChannelInternal *iface)
|
|
|
|
{
|
2010-12-30 01:49:21 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
2012-07-26 11:37:48 +02:00
|
|
|
return nsIHttpChannel_Release(&This->nsIHttpChannel_iface);
|
2009-08-22 19:37:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetDocumentURI(nsIHttpChannelInternal *iface, nsIURI **aDocumentURI)
|
|
|
|
{
|
2010-12-30 01:49:21 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
2009-08-22 19:37:30 +02:00
|
|
|
|
2009-12-17 21:25:34 +01:00
|
|
|
FIXME("(%p)->()\n", This);
|
2009-08-22 19:37:30 +02:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_SetDocumentURI(nsIHttpChannelInternal *iface, nsIURI *aDocumentURI)
|
|
|
|
{
|
2010-12-30 01:49:21 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
2009-08-22 19:37:30 +02:00
|
|
|
|
2009-12-17 21:25:34 +01:00
|
|
|
FIXME("(%p)->()\n", This);
|
2009-08-22 19:37:30 +02:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2013-01-23 18:44:42 +01:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetRequestVersion(nsIHttpChannelInternal *iface, UINT32 *major, UINT32 *minor)
|
2009-08-22 19:37:30 +02:00
|
|
|
{
|
2010-12-30 01:49:21 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
2009-08-22 19:37:30 +02:00
|
|
|
|
2009-12-17 21:25:34 +01:00
|
|
|
FIXME("(%p)->()\n", This);
|
2009-08-22 19:37:30 +02:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2013-01-23 18:44:42 +01:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetResponseVersion(nsIHttpChannelInternal *iface, UINT32 *major, UINT32 *minor)
|
2009-08-22 19:37:30 +02:00
|
|
|
{
|
2010-12-30 01:49:21 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
2009-08-22 19:37:30 +02:00
|
|
|
|
2009-12-17 21:25:34 +01:00
|
|
|
FIXME("(%p)->()\n", This);
|
2009-08-22 19:37:30 +02:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2014-11-03 12:39:59 +01:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_TakeAllSecurityMessages(nsIHttpChannelInternal *iface, void *aMessages)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->()\n", This);
|
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2009-08-22 19:37:30 +02:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_SetCookie(nsIHttpChannelInternal *iface, const char *aCookieHeader)
|
|
|
|
{
|
2010-12-30 01:49:21 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
2009-08-22 19:37:30 +02:00
|
|
|
|
2009-12-17 21:25:34 +01:00
|
|
|
FIXME("(%p)->()\n", This);
|
2009-08-22 19:37:30 +02:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_SetupFallbackChannel(nsIHttpChannelInternal *iface, const char *aFallbackKey)
|
|
|
|
{
|
2010-12-30 01:49:21 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
2009-08-22 19:37:30 +02:00
|
|
|
|
2009-12-17 21:25:34 +01:00
|
|
|
FIXME("(%p)->()\n", This);
|
2009-08-22 19:37:30 +02:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-12-04 17:31:57 +01:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetThirdPartyFlags(nsIHttpChannelInternal *iface, UINT32 *aThirdPartyFlags)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, aThirdPartyFlags);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_SetThirdPartyFlags(nsIHttpChannelInternal *iface, UINT32 aThirdPartyFlags)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
|
|
|
FIXME("(%p)->(%x)\n", This, aThirdPartyFlags);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-03-15 11:54:33 +01:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetForceAllowThirdPartyCookie(nsIHttpChannelInternal *iface, cpp_bool *aForceThirdPartyCookie)
|
2009-08-22 19:37:30 +02:00
|
|
|
{
|
2010-12-30 01:49:21 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
2009-08-22 19:37:30 +02:00
|
|
|
|
2009-12-17 21:25:34 +01:00
|
|
|
FIXME("(%p)->()\n", This);
|
2009-08-22 19:37:30 +02:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-03-15 11:54:33 +01:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_SetForceAllowThirdPartyCookie(nsIHttpChannelInternal *iface, cpp_bool aForceThirdPartyCookie)
|
2009-08-22 19:37:30 +02:00
|
|
|
{
|
2010-12-30 01:49:21 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
2009-08-22 19:37:30 +02:00
|
|
|
|
2009-12-17 21:25:34 +01:00
|
|
|
FIXME("(%p)->()\n", This);
|
2009-08-22 19:37:30 +02:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-03-15 11:54:33 +01:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetCanceled(nsIHttpChannelInternal *iface, cpp_bool *aCanceled)
|
2010-08-25 14:22:25 +02:00
|
|
|
{
|
2010-12-30 01:49:21 +01:00
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
2010-08-25 14:22:25 +02:00
|
|
|
|
|
|
|
FIXME("(%p)->(%p)\n", This, aCanceled);
|
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-03-15 11:54:33 +01:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetChannelIsForDownload(nsIHttpChannelInternal *iface, cpp_bool *aCanceled)
|
2011-03-15 13:45:29 +01:00
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p)\n", This, aCanceled);
|
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-03-15 11:54:33 +01:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_SetChannelIsForDownload(nsIHttpChannelInternal *iface, cpp_bool aCanceled)
|
2011-03-15 13:45:29 +01:00
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%x)\n", This, aCanceled);
|
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2011-08-23 14:07:02 +02:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetLocalAddress(nsIHttpChannelInternal *iface, nsACString *aLocalAddress)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p)\n", This, aLocalAddress);
|
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2013-01-18 14:05:15 +01:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetLocalPort(nsIHttpChannelInternal *iface, LONG *aLocalPort)
|
2011-08-23 14:07:02 +02:00
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p)\n", This, aLocalPort);
|
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetRemoteAddress(nsIHttpChannelInternal *iface, nsACString *aRemoteAddress)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p)\n", This, aRemoteAddress);
|
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2013-01-18 14:05:15 +01:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetRemotePort(nsIHttpChannelInternal *iface, LONG *aRemotePort)
|
2011-08-23 14:07:02 +02:00
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p)\n", This, aRemotePort);
|
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_SetCacheKeysRedirectChain(nsIHttpChannelInternal *iface, void *cacheKeys)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p)\n", This, cacheKeys);
|
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-03-14 14:45:32 +01:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_HTTPUpgrade(nsIHttpChannelInternal *iface,
|
|
|
|
const nsACString *aProtocolName, nsIHttpUpgradeListener *aListener)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
|
|
|
FIXME("(%p)->(%s %p)\n", This, debugstr_nsacstr(aProtocolName), aListener);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-03-15 11:54:33 +01:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetAllowSpdy(nsIHttpChannelInternal *iface, cpp_bool *aAllowSpdy)
|
2012-03-14 14:45:32 +01:00
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, aAllowSpdy);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-03-15 11:54:33 +01:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_SetAllowSpdy(nsIHttpChannelInternal *iface, cpp_bool aAllowSpdy)
|
2012-03-14 14:45:32 +01:00
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
|
|
|
FIXME("(%p)->(%x)\n", This, aAllowSpdy);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-08-11 15:11:35 +02:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetResponseTimeoutEnabled(nsIHttpChannelInternal *iface,
|
|
|
|
cpp_bool *aResponseTimeoutEnabled)
|
2013-05-17 12:34:34 +02:00
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
2015-08-11 15:11:35 +02:00
|
|
|
FIXME("(%p)->(%p)\n", This, aResponseTimeoutEnabled);
|
2013-05-17 12:34:34 +02:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-08-11 15:11:35 +02:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_SetResponseTimeoutEnabled(nsIHttpChannelInternal *iface,
|
|
|
|
cpp_bool aResponseTimeoutEnabled)
|
2013-05-17 12:34:34 +02:00
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
2015-08-11 15:11:35 +02:00
|
|
|
FIXME("(%p)->(%x)\n", This, aResponseTimeoutEnabled);
|
2013-05-17 12:34:34 +02:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-08-11 15:11:35 +02:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetApiRedirectToURI(nsIHttpChannelInternal *iface, nsIURI **aApiRedirectToURI)
|
2013-05-17 12:34:34 +02:00
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
2015-08-11 15:11:35 +02:00
|
|
|
FIXME("(%p)->(%p)\n", This, aApiRedirectToURI);
|
2013-05-17 12:34:34 +02:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-08-11 15:11:35 +02:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetAllowAltSvc(nsIHttpChannelInternal *iface, cpp_bool *aAllowAltSvc)
|
2013-05-17 12:34:34 +02:00
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
2015-08-11 15:11:35 +02:00
|
|
|
FIXME("(%p)->(%p)\n", This, aAllowAltSvc);
|
2013-05-17 12:34:34 +02:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-08-11 15:11:35 +02:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_SetAllowAltSvc(nsIHttpChannelInternal *iface, cpp_bool aAllowAltSvc)
|
2014-11-20 14:45:27 +01:00
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
2015-08-11 15:11:35 +02:00
|
|
|
FIXME("(%p)->(%x)\n", This, aAllowAltSvc);
|
2014-11-20 14:45:27 +01:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-08-11 15:11:35 +02:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_AddRedirect(nsIHttpChannelInternal *iface, nsIPrincipal *aPrincipal)
|
2014-11-20 14:45:27 +01:00
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
2015-08-11 15:11:35 +02:00
|
|
|
FIXME("(%p)->(%p)\n", This, aPrincipal);
|
2014-11-20 14:45:27 +01:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-08-11 15:11:35 +02:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetLastModifiedTime(nsIHttpChannelInternal *iface, PRTime *aLastModifiedTime)
|
2014-11-20 14:45:27 +01:00
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
2015-08-11 15:11:35 +02:00
|
|
|
FIXME("(%p)->(%p)\n", This, aLastModifiedTime);
|
2014-11-20 14:45:27 +01:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-08-11 15:11:35 +02:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_ForceNoIntercept(nsIHttpChannelInternal *iface)
|
2014-11-20 14:45:27 +01:00
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
2015-08-11 15:11:35 +02:00
|
|
|
FIXME("(%p)\n", This);
|
2014-11-20 14:45:27 +01:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-08-11 15:11:35 +02:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetCorsIncludeCredentials(nsIHttpChannelInternal *iface,
|
|
|
|
cpp_bool *aCorsIncludeCredentials)
|
2014-11-20 14:45:27 +01:00
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
2015-08-11 15:11:35 +02:00
|
|
|
FIXME("(%p)->(%p)\n", This, aCorsIncludeCredentials);
|
2014-11-20 14:45:27 +01:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-08-11 15:11:35 +02:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_SetCorsIncludeCredentials(nsIHttpChannelInternal *iface,
|
|
|
|
cpp_bool aCorsIncludeCredentials)
|
2015-02-24 14:19:41 +01:00
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
2015-12-04 17:32:47 +01:00
|
|
|
TRACE("(%p)->(%x)\n", This, aCorsIncludeCredentials);
|
|
|
|
return NS_OK;
|
2015-08-11 15:11:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetCorsMode(nsIHttpChannelInternal *iface, UINT32 *aCorsMode)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, aCorsMode);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_SetCorsMode(nsIHttpChannelInternal *iface, UINT32 aCorsMode)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
2015-12-04 17:32:47 +01:00
|
|
|
TRACE("(%p)->(%d)\n", This, aCorsMode);
|
|
|
|
return NS_OK;
|
2015-02-24 14:19:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetTopWindowURI(nsIHttpChannelInternal *iface, nsIURI **aTopWindowURI)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, aTopWindowURI);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-08-11 15:11:35 +02:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetNetworkInterfaceId(nsIHttpChannelInternal *iface,
|
|
|
|
nsACString *aNetworkInterfaceId)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, aNetworkInterfaceId);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_SetNetworkInterfaceId(nsIHttpChannelInternal *iface,
|
|
|
|
const nsACString *aNetworkInterfaceId)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_nsacstr(aNetworkInterfaceId));
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_ContinueBeginConnect(nsIHttpChannelInternal *iface)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetProxyURI(nsIHttpChannelInternal *iface, nsIURI **aProxyURI)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, aProxyURI);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2009-08-22 19:37:30 +02:00
|
|
|
static const nsIHttpChannelInternalVtbl nsHttpChannelInternalVtbl = {
|
|
|
|
nsHttpChannelInternal_QueryInterface,
|
|
|
|
nsHttpChannelInternal_AddRef,
|
|
|
|
nsHttpChannelInternal_Release,
|
|
|
|
nsHttpChannelInternal_GetDocumentURI,
|
|
|
|
nsHttpChannelInternal_SetDocumentURI,
|
|
|
|
nsHttpChannelInternal_GetRequestVersion,
|
|
|
|
nsHttpChannelInternal_GetResponseVersion,
|
2014-11-03 12:39:59 +01:00
|
|
|
nsHttpChannelInternal_TakeAllSecurityMessages,
|
2009-08-22 19:37:30 +02:00
|
|
|
nsHttpChannelInternal_SetCookie,
|
|
|
|
nsHttpChannelInternal_SetupFallbackChannel,
|
2015-12-04 17:31:57 +01:00
|
|
|
nsHttpChannelInternal_GetThirdPartyFlags,
|
|
|
|
nsHttpChannelInternal_SetThirdPartyFlags,
|
2009-08-22 19:37:30 +02:00
|
|
|
nsHttpChannelInternal_GetForceAllowThirdPartyCookie,
|
2010-08-25 14:22:25 +02:00
|
|
|
nsHttpChannelInternal_SetForceAllowThirdPartyCookie,
|
2011-03-15 13:45:29 +01:00
|
|
|
nsHttpChannelInternal_GetCanceled,
|
|
|
|
nsHttpChannelInternal_GetChannelIsForDownload,
|
2011-08-23 14:07:02 +02:00
|
|
|
nsHttpChannelInternal_SetChannelIsForDownload,
|
|
|
|
nsHttpChannelInternal_GetLocalAddress,
|
|
|
|
nsHttpChannelInternal_GetLocalPort,
|
|
|
|
nsHttpChannelInternal_GetRemoteAddress,
|
|
|
|
nsHttpChannelInternal_GetRemotePort,
|
2012-03-14 14:45:32 +01:00
|
|
|
nsHttpChannelInternal_SetCacheKeysRedirectChain,
|
|
|
|
nsHttpChannelInternal_HTTPUpgrade,
|
|
|
|
nsHttpChannelInternal_GetAllowSpdy,
|
2013-05-17 12:34:34 +02:00
|
|
|
nsHttpChannelInternal_SetAllowSpdy,
|
2014-11-20 14:45:27 +01:00
|
|
|
nsHttpChannelInternal_GetResponseTimeoutEnabled,
|
|
|
|
nsHttpChannelInternal_SetResponseTimeoutEnabled,
|
|
|
|
nsHttpChannelInternal_GetApiRedirectToURI,
|
2015-08-11 15:11:35 +02:00
|
|
|
nsHttpChannelInternal_GetAllowAltSvc,
|
|
|
|
nsHttpChannelInternal_SetAllowAltSvc,
|
2014-11-20 14:45:27 +01:00
|
|
|
nsHttpChannelInternal_AddRedirect,
|
2015-02-24 14:19:41 +01:00
|
|
|
nsHttpChannelInternal_GetLastModifiedTime,
|
|
|
|
nsHttpChannelInternal_ForceNoIntercept,
|
2015-08-11 15:11:35 +02:00
|
|
|
nsHttpChannelInternal_GetCorsIncludeCredentials,
|
|
|
|
nsHttpChannelInternal_SetCorsIncludeCredentials,
|
|
|
|
nsHttpChannelInternal_GetCorsMode,
|
|
|
|
nsHttpChannelInternal_SetCorsMode,
|
|
|
|
nsHttpChannelInternal_GetTopWindowURI,
|
|
|
|
nsHttpChannelInternal_GetNetworkInterfaceId,
|
|
|
|
nsHttpChannelInternal_SetNetworkInterfaceId,
|
|
|
|
nsHttpChannelInternal_ContinueBeginConnect,
|
|
|
|
nsHttpChannelInternal_GetProxyURI
|
2009-08-22 19:37:30 +02:00
|
|
|
};
|
|
|
|
|
2010-11-12 12:31:41 +01:00
|
|
|
|
|
|
|
static void invalidate_uri(nsWineURI *This)
|
|
|
|
{
|
|
|
|
if(This->uri) {
|
|
|
|
IUri_Release(This->uri);
|
|
|
|
This->uri = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL ensure_uri_builder(nsWineURI *This)
|
|
|
|
{
|
2011-11-23 16:19:42 +01:00
|
|
|
if(!This->is_mutable) {
|
|
|
|
WARN("Not mutable URI\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-11-12 12:31:41 +01:00
|
|
|
if(!This->uri_builder) {
|
2010-09-28 13:25:24 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
2010-11-12 12:31:41 +01:00
|
|
|
if(!ensure_uri(This))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
hres = CreateIUriBuilder(This->uri, 0, 0, &This->uri_builder);
|
2010-09-28 13:25:24 +02:00
|
|
|
if(FAILED(hres)) {
|
2011-08-03 11:36:15 +02:00
|
|
|
WARN("CreateIUriBuilder failed: %08x\n", hres);
|
2010-09-28 13:25:24 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-12 12:31:41 +01:00
|
|
|
invalidate_uri(This);
|
2010-09-28 13:25:24 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult get_uri_string(nsWineURI *This, Uri_PROPERTY prop, nsACString *ret)
|
|
|
|
{
|
|
|
|
char *vala;
|
|
|
|
BSTR val;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(!ensure_uri(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
hres = IUri_GetPropertyBSTR(This->uri, prop, &val, 0);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("GetPropertyBSTR failed: %08x\n", hres);
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2012-11-21 15:06:34 +01:00
|
|
|
vala = heap_strdupWtoU(val);
|
2010-09-28 13:25:24 +02:00
|
|
|
SysFreeString(val);
|
|
|
|
if(!vala)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
TRACE("ret %s\n", debugstr_a(vala));
|
|
|
|
nsACString_SetData(ret, vala);
|
|
|
|
heap_free(vala);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static inline nsWineURI *impl_from_nsIFileURL(nsIFileURL *iface)
|
2011-01-05 00:39:25 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
return CONTAINING_RECORD(iface, nsWineURI, nsIFileURL_iface);
|
2011-01-05 00:39:25 +01:00
|
|
|
}
|
2006-02-13 13:26:00 +01:00
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_QueryInterface(nsIFileURL *iface, nsIIDRef riid, void **result)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2006-02-09 12:18:18 +01:00
|
|
|
|
|
|
|
*result = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_nsISupports, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsISupports %p)\n", This, result);
|
2012-07-20 12:36:33 +02:00
|
|
|
*result = &This->nsIFileURL_iface;
|
2006-02-09 12:18:18 +01:00
|
|
|
}else if(IsEqualGUID(&IID_nsIURI, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIURI %p)\n", This, result);
|
2012-07-20 12:36:33 +02:00
|
|
|
*result = &This->nsIFileURL_iface;
|
2009-08-27 11:31:14 +02:00
|
|
|
}else if(IsEqualGUID(&IID_nsIURL, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIURL %p)\n", This, result);
|
2012-07-20 12:36:33 +02:00
|
|
|
*result = &This->nsIFileURL_iface;
|
|
|
|
}else if(IsEqualGUID(&IID_nsIFileURL, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIFileURL %p)\n", This, result);
|
|
|
|
*result = This->scheme == URL_SCHEME_FILE ? &This->nsIFileURL_iface : NULL;
|
2011-11-18 12:21:47 +01:00
|
|
|
}else if(IsEqualGUID(&IID_nsIMutable, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIMutable %p)\n", This, result);
|
|
|
|
*result = &This->nsIStandardURL_iface;
|
|
|
|
}else if(IsEqualGUID(&IID_nsIStandardURL, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIStandardURL %p)\n", This, result);
|
|
|
|
*result = &This->nsIStandardURL_iface;
|
2010-02-21 21:10:15 +01:00
|
|
|
}else if(IsEqualGUID(&IID_nsWineURI, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsWineURI %p)\n", This, result);
|
|
|
|
*result = This;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*result) {
|
2012-07-26 11:37:48 +02:00
|
|
|
nsIFileURL_AddRef(&This->nsIFileURL_iface);
|
2006-02-09 12:18:18 +01:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), result);
|
2012-01-12 15:37:23 +01:00
|
|
|
return NS_NOINTERFACE;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsrefcnt NSAPI nsURI_AddRef(nsIFileURL *iface)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2006-02-09 12:18:18 +01:00
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2006-02-09 12:18:18 +01:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsrefcnt NSAPI nsURI_Release(nsIFileURL *iface)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2006-02-09 12:18:18 +01:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2006-02-09 12:18:18 +01:00
|
|
|
|
|
|
|
if(!ref) {
|
2009-10-26 23:02:50 +01:00
|
|
|
if(This->window_ref)
|
|
|
|
windowref_release(This->window_ref);
|
2006-02-15 11:51:44 +01:00
|
|
|
if(This->container)
|
2010-12-27 23:27:55 +01:00
|
|
|
nsIWebBrowserChrome_Release(&This->container->nsIWebBrowserChrome_iface);
|
2010-09-28 13:25:24 +02:00
|
|
|
if(This->uri)
|
|
|
|
IUri_Release(This->uri);
|
2012-11-21 15:06:46 +01:00
|
|
|
heap_free(This->origin_charset);
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(This);
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_GetSpec(nsIFileURL *iface, nsACString *aSpec)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2006-02-09 12:18:18 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aSpec);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2010-11-14 14:41:18 +01:00
|
|
|
return get_uri_string(This, Uri_PROPERTY_DISPLAY_URI, aSpec);
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_SetSpec(nsIFileURL *iface, const nsACString *aSpec)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2011-02-03 20:47:58 +01:00
|
|
|
const char *speca;
|
|
|
|
WCHAR *spec;
|
|
|
|
IUri *uri;
|
|
|
|
HRESULT hres;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-02-03 20:47:58 +01:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aSpec));
|
|
|
|
|
2011-11-23 16:19:42 +01:00
|
|
|
if(!This->is_mutable)
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
2011-02-03 20:47:58 +01:00
|
|
|
nsACString_GetData(aSpec, &speca);
|
2012-11-21 15:06:34 +01:00
|
|
|
spec = heap_strdupUtoW(speca);
|
2011-02-03 20:47:58 +01:00
|
|
|
if(!spec)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2013-03-26 11:37:47 +01:00
|
|
|
hres = create_uri(spec, 0, &uri);
|
2011-02-03 20:47:58 +01:00
|
|
|
heap_free(spec);
|
|
|
|
if(FAILED(hres)) {
|
2013-03-26 11:37:47 +01:00
|
|
|
WARN("create_uri failed: %08x\n", hres);
|
2011-02-03 20:47:58 +01:00
|
|
|
return NS_ERROR_FAILURE;
|
2010-09-28 13:25:24 +02:00
|
|
|
}
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-02-03 20:47:58 +01:00
|
|
|
invalidate_uri(This);
|
|
|
|
if(This->uri_builder) {
|
|
|
|
IUriBuilder_Release(This->uri_builder);
|
|
|
|
This->uri_builder = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
This->uri = uri;
|
|
|
|
return NS_OK;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_GetPrePath(nsIFileURL *iface, nsACString *aPrePath)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2014-11-20 14:45:35 +01:00
|
|
|
IUriBuilder *uri_builder;
|
|
|
|
BSTR display_uri;
|
|
|
|
IUri *uri;
|
|
|
|
int len;
|
|
|
|
nsresult nsres;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aPrePath);
|
|
|
|
|
|
|
|
if(!ensure_uri(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
hres = CreateIUriBuilder(This->uri, 0, 0, &uri_builder);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
hres = IUriBuilder_RemoveProperties(uri_builder, Uri_HAS_PATH|Uri_HAS_QUERY|Uri_HAS_FRAGMENT);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
hres = IUriBuilder_CreateUriSimple(uri_builder, 0, 0, &uri);
|
|
|
|
IUriBuilder_Release(uri_builder);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
hres = IUri_GetDisplayUri(uri, &display_uri);
|
|
|
|
IUri_Release(uri);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
/* Remove trailing slash that may be appended as default path. */
|
|
|
|
len = SysStringLen(display_uri);
|
|
|
|
if(len && display_uri[len-1] == '/')
|
|
|
|
display_uri[len-1] = 0;
|
|
|
|
|
|
|
|
nsres = return_wstr_nsacstr(aPrePath, display_uri, -1);
|
|
|
|
SysFreeString(display_uri);
|
|
|
|
return nsres;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_GetScheme(nsIFileURL *iface, nsACString *aScheme)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2010-09-29 12:44:40 +02:00
|
|
|
DWORD scheme;
|
|
|
|
HRESULT hres;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2006-02-09 12:18:18 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aScheme);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2010-09-29 12:44:40 +02:00
|
|
|
if(!ensure_uri(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2010-08-18 13:37:56 +02:00
|
|
|
|
2010-09-29 12:44:40 +02:00
|
|
|
hres = IUri_GetScheme(This->uri, &scheme);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("GetScheme failed: %08x\n", hres);
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
2010-08-18 13:37:56 +02:00
|
|
|
|
2010-09-29 12:44:40 +02:00
|
|
|
if(scheme == URL_SCHEME_ABOUT) {
|
|
|
|
nsACString_SetData(aScheme, "wine");
|
2007-02-10 18:59:38 +01:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-09-29 12:44:40 +02:00
|
|
|
return get_uri_string(This, Uri_PROPERTY_SCHEME_NAME, aScheme);
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_SetScheme(nsIFileURL *iface, const nsACString *aScheme)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2011-03-14 14:06:37 +01:00
|
|
|
const char *schemea;
|
|
|
|
WCHAR *scheme;
|
|
|
|
HRESULT hres;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2010-08-03 15:44:56 +02:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aScheme));
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-03-14 14:06:37 +01:00
|
|
|
if(!ensure_uri_builder(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-03-14 14:06:37 +01:00
|
|
|
nsACString_GetData(aScheme, &schemea);
|
2012-11-21 15:06:34 +01:00
|
|
|
scheme = heap_strdupUtoW(schemea);
|
2011-03-14 14:06:37 +01:00
|
|
|
if(!scheme)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
hres = IUriBuilder_SetSchemeName(This->uri_builder, scheme);
|
|
|
|
heap_free(scheme);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
return NS_OK;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_GetUserPass(nsIFileURL *iface, nsACString *aUserPass)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2011-07-19 16:01:44 +02:00
|
|
|
BSTR user, pass;
|
|
|
|
HRESULT hres;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2006-02-09 12:18:18 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aUserPass);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-07-19 16:01:44 +02:00
|
|
|
if(!ensure_uri(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
hres = IUri_GetUserName(This->uri, &user);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
hres = IUri_GetPassword(This->uri, &pass);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
SysFreeString(user);
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*user || *pass) {
|
|
|
|
FIXME("Construct user:pass string\n");
|
|
|
|
}else {
|
|
|
|
nsACString_SetData(aUserPass, "");
|
|
|
|
}
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-07-19 16:01:44 +02:00
|
|
|
SysFreeString(user);
|
|
|
|
SysFreeString(pass);
|
|
|
|
return NS_OK;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_SetUserPass(nsIFileURL *iface, const nsACString *aUserPass)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2011-07-19 16:01:44 +02:00
|
|
|
WCHAR *user = NULL, *pass = NULL, *buf = NULL;
|
|
|
|
const char *user_pass;
|
|
|
|
HRESULT hres;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2010-08-03 15:44:56 +02:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aUserPass));
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-07-19 16:01:44 +02:00
|
|
|
if(!ensure_uri_builder(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
nsACString_GetData(aUserPass, &user_pass);
|
|
|
|
if(*user_pass) {
|
|
|
|
WCHAR *ptr;
|
|
|
|
|
2012-11-21 15:06:34 +01:00
|
|
|
buf = heap_strdupUtoW(user_pass);
|
2011-07-19 16:01:44 +02:00
|
|
|
if(!buf)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
ptr = strchrW(buf, ':');
|
|
|
|
if(!ptr) {
|
|
|
|
user = buf;
|
|
|
|
}else if(ptr != buf) {
|
|
|
|
*ptr++ = 0;
|
|
|
|
user = buf;
|
|
|
|
if(*ptr)
|
|
|
|
pass = ptr;
|
|
|
|
}else {
|
|
|
|
pass = buf+1;
|
|
|
|
}
|
2010-09-28 13:25:24 +02:00
|
|
|
}
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-07-19 16:01:44 +02:00
|
|
|
hres = IUriBuilder_SetUserName(This->uri_builder, user);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
hres = IUriBuilder_SetPassword(This->uri_builder, pass);
|
|
|
|
|
|
|
|
heap_free(buf);
|
|
|
|
return SUCCEEDED(hres) ? NS_OK : NS_ERROR_FAILURE;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_GetUsername(nsIFileURL *iface, nsACString *aUsername)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2006-02-09 12:18:18 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aUsername);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-02-10 12:58:00 +01:00
|
|
|
return get_uri_string(This, Uri_PROPERTY_USER_NAME, aUsername);
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_SetUsername(nsIFileURL *iface, const nsACString *aUsername)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2011-02-10 12:58:00 +01:00
|
|
|
const char *usera;
|
|
|
|
WCHAR *user;
|
|
|
|
HRESULT hres;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2010-08-03 15:44:56 +02:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aUsername));
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-02-10 12:58:00 +01:00
|
|
|
if(!ensure_uri_builder(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-02-10 12:58:00 +01:00
|
|
|
nsACString_GetData(aUsername, &usera);
|
2012-11-21 15:06:34 +01:00
|
|
|
user = heap_strdupUtoW(usera);
|
2011-02-10 12:58:00 +01:00
|
|
|
if(!user)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
hres = IUriBuilder_SetUserName(This->uri_builder, user);
|
|
|
|
heap_free(user);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
return NS_OK;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_GetPassword(nsIFileURL *iface, nsACString *aPassword)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2006-02-09 12:18:18 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aPassword);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-01-03 14:52:34 +01:00
|
|
|
return get_uri_string(This, Uri_PROPERTY_PASSWORD, aPassword);
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_SetPassword(nsIFileURL *iface, const nsACString *aPassword)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2011-01-03 14:52:34 +01:00
|
|
|
const char *passa;
|
|
|
|
WCHAR *pass;
|
|
|
|
HRESULT hres;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2010-08-03 15:44:56 +02:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aPassword));
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-01-03 14:52:34 +01:00
|
|
|
if(!ensure_uri_builder(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-01-03 14:52:34 +01:00
|
|
|
nsACString_GetData(aPassword, &passa);
|
2012-11-21 15:06:34 +01:00
|
|
|
pass = heap_strdupUtoW(passa);
|
2011-01-03 14:52:34 +01:00
|
|
|
if(!pass)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
hres = IUriBuilder_SetPassword(This->uri_builder, pass);
|
|
|
|
heap_free(pass);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
return NS_OK;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_GetHostPort(nsIFileURL *iface, nsACString *aHostPort)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2010-09-28 13:26:01 +02:00
|
|
|
const WCHAR *ptr;
|
|
|
|
char *vala;
|
|
|
|
BSTR val;
|
|
|
|
HRESULT hres;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2006-02-09 12:18:18 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aHostPort);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2010-09-28 13:26:01 +02:00
|
|
|
if(!ensure_uri(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
hres = IUri_GetAuthority(This->uri, &val);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("GetAuthority failed: %08x\n", hres);
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
ptr = strchrW(val, '@');
|
|
|
|
if(!ptr)
|
|
|
|
ptr = val;
|
|
|
|
|
2012-11-21 15:06:34 +01:00
|
|
|
vala = heap_strdupWtoU(ptr);
|
2010-09-28 13:26:01 +02:00
|
|
|
SysFreeString(val);
|
|
|
|
if(!vala)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
TRACE("ret %s\n", debugstr_a(vala));
|
|
|
|
nsACString_SetData(aHostPort, vala);
|
|
|
|
heap_free(vala);
|
|
|
|
return NS_OK;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_SetHostPort(nsIFileURL *iface, const nsACString *aHostPort)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-02-03 13:07:57 +01:00
|
|
|
WARN("(%p)->(%s)\n", This, debugstr_nsacstr(aHostPort));
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-02-03 13:07:57 +01:00
|
|
|
/* Not implemented by Gecko */
|
2006-07-07 15:17:27 +02:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_GetHost(nsIFileURL *iface, nsACString *aHost)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2006-02-09 12:18:18 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aHost);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2010-09-28 13:25:24 +02:00
|
|
|
return get_uri_string(This, Uri_PROPERTY_HOST, aHost);
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_SetHost(nsIFileURL *iface, const nsACString *aHost)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2011-04-08 13:04:14 +02:00
|
|
|
const char *hosta;
|
|
|
|
WCHAR *host;
|
|
|
|
HRESULT hres;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2010-08-03 15:44:56 +02:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aHost));
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-04-08 13:04:14 +02:00
|
|
|
if(!ensure_uri_builder(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-04-08 13:04:14 +02:00
|
|
|
nsACString_GetData(aHost, &hosta);
|
2012-11-21 15:06:34 +01:00
|
|
|
host = heap_strdupUtoW(hosta);
|
2011-04-08 13:04:14 +02:00
|
|
|
if(!host)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
hres = IUriBuilder_SetHost(This->uri_builder, host);
|
|
|
|
heap_free(host);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
return NS_OK;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2013-01-18 14:05:15 +01:00
|
|
|
static nsresult NSAPI nsURI_GetPort(nsIFileURL *iface, LONG *aPort)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2010-09-28 13:25:40 +02:00
|
|
|
DWORD port;
|
|
|
|
HRESULT hres;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2006-02-09 12:18:18 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aPort);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2010-09-28 13:25:40 +02:00
|
|
|
if(!ensure_uri(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
hres = IUri_GetPort(This->uri, &port);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("GetPort failed: %08x\n", hres);
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aPort = port ? port : -1;
|
|
|
|
return NS_OK;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2013-01-18 14:05:15 +01:00
|
|
|
static nsresult NSAPI nsURI_SetPort(nsIFileURL *iface, LONG aPort)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2011-06-25 19:03:51 +02:00
|
|
|
HRESULT hres;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%d)\n", This, aPort);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-06-25 19:03:51 +02:00
|
|
|
if(!ensure_uri_builder(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-06-25 19:03:51 +02:00
|
|
|
hres = IUriBuilder_SetPort(This->uri_builder, aPort != -1, aPort);
|
|
|
|
return SUCCEEDED(hres) ? NS_OK : NS_ERROR_FAILURE;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_GetPath(nsIFileURL *iface, nsACString *aPath)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2006-02-09 12:18:18 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aPath);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2010-09-29 12:45:59 +02:00
|
|
|
return get_uri_string(This, Uri_PROPERTY_PATH, aPath);
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_SetPath(nsIFileURL *iface, const nsACString *aPath)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2010-11-14 14:41:00 +01:00
|
|
|
const char *patha;
|
|
|
|
WCHAR *path;
|
|
|
|
HRESULT hres;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2010-08-03 15:44:56 +02:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aPath));
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2010-11-14 14:41:00 +01:00
|
|
|
if(!ensure_uri_builder(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2008-02-01 15:31:19 +01:00
|
|
|
|
2010-11-14 14:41:00 +01:00
|
|
|
nsACString_GetData(aPath, &patha);
|
2012-11-21 15:06:34 +01:00
|
|
|
path = heap_strdupUtoW(patha);
|
2010-11-14 14:41:00 +01:00
|
|
|
if(!path)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2008-02-01 15:31:19 +01:00
|
|
|
|
2010-11-14 14:41:00 +01:00
|
|
|
hres = IUriBuilder_SetPath(This->uri_builder, path);
|
|
|
|
heap_free(path);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2008-02-01 15:31:19 +01:00
|
|
|
|
2010-11-14 14:41:00 +01:00
|
|
|
return NS_OK;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_Equals(nsIFileURL *iface, nsIURI *other, cpp_bool *_retval)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2010-10-21 15:50:27 +02:00
|
|
|
nsWineURI *other_obj;
|
2008-02-28 12:41:40 +01:00
|
|
|
nsresult nsres;
|
2010-10-21 15:50:27 +02:00
|
|
|
HRESULT hres;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2006-02-09 12:18:18 +01:00
|
|
|
TRACE("(%p)->(%p %p)\n", This, other, _retval);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2010-10-21 15:50:27 +02:00
|
|
|
nsres = nsIURI_QueryInterface(other, &IID_nsWineURI, (void**)&other_obj);
|
2008-02-28 12:41:40 +01:00
|
|
|
if(NS_FAILED(nsres)) {
|
2010-02-21 21:10:15 +01:00
|
|
|
TRACE("Could not get nsWineURI interface\n");
|
2008-02-28 12:41:40 +01:00
|
|
|
*_retval = FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-21 15:50:27 +02:00
|
|
|
if(ensure_uri(This) && ensure_uri(other_obj)) {
|
2011-11-17 16:11:58 +01:00
|
|
|
BOOL b;
|
|
|
|
|
|
|
|
hres = IUri_IsEqual(This->uri, other_obj->uri, &b);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
*_retval = b;
|
|
|
|
nsres = NS_OK;
|
|
|
|
}else {
|
|
|
|
nsres = NS_ERROR_FAILURE;
|
|
|
|
}
|
2010-10-21 15:50:27 +02:00
|
|
|
}else {
|
|
|
|
nsres = NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
2008-02-28 12:41:40 +01:00
|
|
|
|
2012-07-26 11:37:48 +02:00
|
|
|
nsIFileURL_Release(&other_obj->nsIFileURL_iface);
|
2010-10-21 15:50:27 +02:00
|
|
|
return nsres;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_SchemeIs(nsIFileURL *iface, const char *scheme, cpp_bool *_retval)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2010-09-29 12:45:13 +02:00
|
|
|
WCHAR buf[INTERNET_MAX_SCHEME_LENGTH];
|
2010-11-25 13:56:25 +01:00
|
|
|
BSTR scheme_name;
|
|
|
|
HRESULT hres;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2006-02-09 12:18:18 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_a(scheme), _retval);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2010-11-25 13:56:25 +01:00
|
|
|
if(!ensure_uri(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
hres = IUri_GetSchemeName(This->uri, &scheme_name);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2012-11-21 15:06:34 +01:00
|
|
|
MultiByteToWideChar(CP_UTF8, 0, scheme, -1, buf, sizeof(buf)/sizeof(WCHAR));
|
2010-11-25 13:56:25 +01:00
|
|
|
*_retval = !strcmpW(scheme_name, buf);
|
2011-01-20 11:48:56 +01:00
|
|
|
SysFreeString(scheme_name);
|
2010-09-29 12:45:13 +02:00
|
|
|
return NS_OK;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_Clone(nsIFileURL *iface, nsIURI **_retval)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2010-02-21 21:06:51 +01:00
|
|
|
nsWineURI *wine_uri;
|
2008-02-28 12:41:22 +01:00
|
|
|
nsresult nsres;
|
2006-02-24 20:31:12 +01:00
|
|
|
|
2006-02-09 12:18:18 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, _retval);
|
2006-02-24 20:31:12 +01:00
|
|
|
|
2010-11-25 13:55:33 +01:00
|
|
|
if(!ensure_uri(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
2012-11-21 15:06:46 +01:00
|
|
|
nsres = create_nsuri(This->uri, This->window_ref ? This->window_ref->window : NULL,
|
|
|
|
This->container, This->origin_charset, &wine_uri);
|
2008-02-28 12:41:22 +01:00
|
|
|
if(NS_FAILED(nsres)) {
|
2011-06-25 19:03:19 +02:00
|
|
|
WARN("create_nsuri failed: %08x\n", nsres);
|
2007-02-10 17:36:58 +01:00
|
|
|
return nsres;
|
2006-02-24 20:31:12 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
*_retval = (nsIURI*)&wine_uri->nsIFileURL_iface;
|
2010-02-21 21:07:43 +01:00
|
|
|
return NS_OK;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_Resolve(nsIFileURL *iface, const nsACString *aRelativePath,
|
2006-02-09 12:18:18 +01:00
|
|
|
nsACString *_retval)
|
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2010-08-18 13:37:32 +02:00
|
|
|
const char *patha;
|
2011-01-03 23:48:29 +01:00
|
|
|
IUri *new_uri;
|
2010-08-18 13:37:32 +02:00
|
|
|
WCHAR *path;
|
2011-01-03 23:48:29 +01:00
|
|
|
char *reta;
|
|
|
|
BSTR ret;
|
2010-08-18 13:37:32 +02:00
|
|
|
HRESULT hres;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2010-08-18 13:37:32 +02:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_nsacstr(aRelativePath), _retval);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-01-03 23:48:29 +01:00
|
|
|
if(!ensure_uri(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
2010-08-18 13:37:32 +02:00
|
|
|
nsACString_GetData(aRelativePath, &patha);
|
2012-11-21 15:06:34 +01:00
|
|
|
path = heap_strdupUtoW(patha);
|
2010-08-18 13:37:32 +02:00
|
|
|
if(!path)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
2013-11-29 12:58:25 +01:00
|
|
|
hres = combine_url(This->uri, path, &new_uri);
|
2010-08-18 13:37:32 +02:00
|
|
|
heap_free(path);
|
2013-11-29 12:58:25 +01:00
|
|
|
if(FAILED(hres))
|
2010-08-18 13:37:32 +02:00
|
|
|
return NS_ERROR_FAILURE;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-01-03 23:48:29 +01:00
|
|
|
hres = IUri_GetDisplayUri(new_uri, &ret);
|
|
|
|
IUri_Release(new_uri);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2012-11-21 15:06:34 +01:00
|
|
|
reta = heap_strdupWtoU(ret);
|
2011-01-03 23:48:29 +01:00
|
|
|
SysFreeString(ret);
|
|
|
|
if(!reta)
|
2010-08-18 13:37:32 +02:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
2011-01-03 23:48:29 +01:00
|
|
|
TRACE("returning %s\n", debugstr_a(reta));
|
|
|
|
nsACString_SetData(_retval, reta);
|
|
|
|
heap_free(reta);
|
2010-08-18 13:37:32 +02:00
|
|
|
return NS_OK;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_GetAsciiSpec(nsIFileURL *iface, nsACString *aAsciiSpec)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2006-02-09 12:18:18 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aAsciiSpec);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2012-07-26 11:37:48 +02:00
|
|
|
return nsIFileURL_GetSpec(&This->nsIFileURL_iface, aAsciiSpec);
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_GetAsciiHost(nsIFileURL *iface, nsACString *aAsciiHost)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-11-08 16:17:40 +01:00
|
|
|
WARN("(%p)->(%p) FIXME: Use Uri_PUNYCODE_IDN_HOST flag\n", This, aAsciiHost);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2010-11-07 18:46:54 +01:00
|
|
|
return get_uri_string(This, Uri_PROPERTY_HOST, aAsciiHost);
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_GetOriginCharset(nsIFileURL *iface, nsACString *aOriginCharset)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2012-11-21 15:06:46 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aOriginCharset);
|
|
|
|
|
|
|
|
nsACString_SetData(aOriginCharset, This->origin_charset);
|
|
|
|
return NS_OK;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURL_GetRef(nsIFileURL *iface, nsACString *aRef)
|
2011-12-29 13:49:36 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2011-12-29 13:49:36 +01:00
|
|
|
char *refa = NULL;
|
|
|
|
BSTR ref;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aRef);
|
|
|
|
|
|
|
|
if(!ensure_uri(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
hres = IUri_GetFragment(This->uri, &ref);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
2012-11-21 15:06:34 +01:00
|
|
|
refa = heap_strdupWtoU(ref);
|
2011-12-29 13:49:36 +01:00
|
|
|
SysFreeString(ref);
|
|
|
|
if(ref && !refa)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
nsACString_SetData(aRef, refa && *refa == '#' ? refa+1 : refa);
|
|
|
|
heap_free(refa);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURL_SetRef(nsIFileURL *iface, const nsACString *aRef)
|
2011-12-29 13:49:36 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2011-12-29 13:49:36 +01:00
|
|
|
const char *refa;
|
|
|
|
WCHAR *ref;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aRef));
|
|
|
|
|
|
|
|
if(!ensure_uri_builder(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
nsACString_GetData(aRef, &refa);
|
2012-11-21 15:06:34 +01:00
|
|
|
ref = heap_strdupUtoW(refa);
|
2011-12-29 13:49:36 +01:00
|
|
|
if(!ref)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
hres = IUriBuilder_SetFragment(This->uri_builder, ref);
|
|
|
|
heap_free(ref);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_EqualsExceptRef(nsIFileURL *iface, nsIURI *other, cpp_bool *_retval)
|
2011-11-15 13:31:22 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2011-11-15 13:31:22 +01:00
|
|
|
nsWineURI *other_obj;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p)\n", This, other, _retval);
|
|
|
|
|
|
|
|
nsres = nsIURI_QueryInterface(other, &IID_nsWineURI, (void**)&other_obj);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
TRACE("Could not get nsWineURI interface\n");
|
|
|
|
*_retval = FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ensure_uri(This) && ensure_uri(other_obj)) {
|
|
|
|
*_retval = compare_ignoring_frag(This->uri, other_obj->uri);
|
|
|
|
nsres = NS_OK;
|
|
|
|
}else {
|
|
|
|
nsres = NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2012-07-26 11:37:48 +02:00
|
|
|
nsIFileURL_Release(&other_obj->nsIFileURL_iface);
|
2011-11-15 13:31:22 +01:00
|
|
|
return nsres;
|
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_CloneIgnoreRef(nsIFileURL *iface, nsIURI **_retval)
|
2011-11-15 13:31:12 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2011-11-15 13:31:12 +01:00
|
|
|
nsWineURI *wine_uri;
|
|
|
|
IUri *uri;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, _retval);
|
|
|
|
|
|
|
|
if(!ensure_uri(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
uri = get_uri_nofrag(This->uri);
|
|
|
|
if(!uri)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2012-11-21 15:06:46 +01:00
|
|
|
nsres = create_nsuri(uri, This->window_ref ? This->window_ref->window : NULL, This->container,
|
|
|
|
This->origin_charset, &wine_uri);
|
2011-11-15 13:31:12 +01:00
|
|
|
IUri_Release(uri);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
WARN("create_nsuri failed: %08x\n", nsres);
|
|
|
|
return nsres;
|
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
*_retval = (nsIURI*)&wine_uri->nsIFileURL_iface;
|
2011-11-15 13:31:12 +01:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_GetSpecIgnoringRef(nsIFileURL *iface, nsACString *aSpecIgnoringRef)
|
2011-11-09 18:11:42 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2011-11-09 18:11:42 +01:00
|
|
|
|
|
|
|
FIXME("(%p)->(%p)\n", This, aSpecIgnoringRef);
|
|
|
|
|
2012-07-26 11:37:48 +02:00
|
|
|
return nsIFileURL_GetSpec(&This->nsIFileURL_iface, aSpecIgnoringRef);
|
2011-11-09 18:11:42 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURI_GetHasRef(nsIFileURL *iface, cpp_bool *aHasRef)
|
2011-11-09 18:11:42 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2011-11-15 13:31:44 +01:00
|
|
|
BOOL b;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aHasRef);
|
|
|
|
|
|
|
|
if(!ensure_uri(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
hres = IUri_HasProperty(This->uri, Uri_PROPERTY_FRAGMENT, &b);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
*aHasRef = b;
|
|
|
|
return NS_OK;
|
2011-11-09 18:11:42 +01:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURL_GetFilePath(nsIFileURL *iface, nsACString *aFilePath)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2009-08-27 11:31:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aFilePath);
|
|
|
|
|
2012-07-26 11:37:48 +02:00
|
|
|
return nsIFileURL_GetPath(&This->nsIFileURL_iface, aFilePath);
|
2009-08-27 11:31:14 +02:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURL_SetFilePath(nsIFileURL *iface, const nsACString *aFilePath)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2009-08-27 11:31:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aFilePath));
|
|
|
|
|
2011-11-23 16:19:42 +01:00
|
|
|
if(!This->is_mutable)
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
2012-07-26 11:37:48 +02:00
|
|
|
return nsIFileURL_SetPath(&This->nsIFileURL_iface, aFilePath);
|
2009-08-27 11:31:14 +02:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURL_GetQuery(nsIFileURL *iface, nsACString *aQuery)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2014-09-19 13:00:01 +02:00
|
|
|
WCHAR *ptr;
|
|
|
|
BSTR query;
|
|
|
|
nsresult nsres;
|
|
|
|
HRESULT hres;
|
2009-08-27 11:31:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aQuery);
|
|
|
|
|
2014-09-19 13:00:01 +02:00
|
|
|
if(!ensure_uri(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
hres = IUri_GetQuery(This->uri, &query);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
ptr = query;
|
|
|
|
if(ptr && *ptr == '?')
|
|
|
|
ptr++;
|
|
|
|
|
|
|
|
nsres = return_wstr_nsacstr(aQuery, ptr, -1);
|
|
|
|
SysFreeString(query);
|
|
|
|
return nsres;
|
2009-08-27 11:31:14 +02:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURL_SetQuery(nsIFileURL *iface, const nsACString *aQuery)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2010-11-12 12:31:41 +01:00
|
|
|
const char *querya;
|
|
|
|
WCHAR *query;
|
|
|
|
HRESULT hres;
|
2009-08-27 11:31:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aQuery));
|
|
|
|
|
2010-11-12 12:31:41 +01:00
|
|
|
if(!ensure_uri_builder(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2009-08-26 23:14:20 +02:00
|
|
|
|
2010-11-12 12:31:41 +01:00
|
|
|
nsACString_GetData(aQuery, &querya);
|
2012-11-21 15:06:34 +01:00
|
|
|
query = heap_strdupUtoW(querya);
|
2010-11-12 12:31:41 +01:00
|
|
|
if(!query)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2009-08-26 23:14:20 +02:00
|
|
|
|
2010-11-12 12:31:41 +01:00
|
|
|
hres = IUriBuilder_SetQuery(This->uri_builder, query);
|
|
|
|
heap_free(query);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2009-08-26 23:14:20 +02:00
|
|
|
|
|
|
|
return NS_OK;
|
2009-08-27 11:31:14 +02:00
|
|
|
}
|
|
|
|
|
2012-01-11 19:41:02 +01:00
|
|
|
static nsresult get_uri_path(nsWineURI *This, BSTR *path, const WCHAR **file, const WCHAR **ext)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2012-01-11 19:41:02 +01:00
|
|
|
const WCHAR *ptr;
|
2011-08-03 12:33:32 +02:00
|
|
|
HRESULT hres;
|
2009-08-27 11:31:14 +02:00
|
|
|
|
2011-08-03 12:33:32 +02:00
|
|
|
if(!ensure_uri(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2009-08-27 11:31:14 +02:00
|
|
|
|
2012-01-11 19:41:02 +01:00
|
|
|
hres = IUri_GetPath(This->uri, path);
|
2011-08-03 12:33:32 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2012-01-11 19:41:02 +01:00
|
|
|
for(ptr = *path + SysStringLen(*path)-1; ptr > *path && *ptr != '/' && *ptr != '\\'; ptr--);
|
|
|
|
if(*ptr == '/' || *ptr == '\\')
|
|
|
|
ptr++;
|
|
|
|
*file = ptr;
|
|
|
|
|
|
|
|
if(ext) {
|
|
|
|
ptr = strrchrW(ptr, '.');
|
|
|
|
if(!ptr)
|
|
|
|
ptr = *path + SysStringLen(*path);
|
|
|
|
*ext = ptr;
|
2011-08-03 12:33:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
2009-08-27 11:31:14 +02:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURL_GetDirectory(nsIFileURL *iface, nsACString *aDirectory)
|
2012-01-11 19:41:02 +01:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2012-01-11 19:41:02 +01:00
|
|
|
const WCHAR *file;
|
|
|
|
BSTR path;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aDirectory);
|
|
|
|
|
|
|
|
nsres = get_uri_path(This, &path, &file, NULL);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return nsres;
|
|
|
|
|
|
|
|
nsres = return_wstr_nsacstr(aDirectory, path, file-path);
|
|
|
|
SysFreeString(path);
|
|
|
|
return nsres;
|
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURL_SetDirectory(nsIFileURL *iface, const nsACString *aDirectory)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2009-08-27 11:31:14 +02:00
|
|
|
|
2011-02-03 13:07:57 +01:00
|
|
|
WARN("(%p)->(%s)\n", This, debugstr_nsacstr(aDirectory));
|
2009-08-27 11:31:14 +02:00
|
|
|
|
2011-02-03 13:07:57 +01:00
|
|
|
/* Not implemented by Gecko */
|
2009-08-27 11:31:14 +02:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURL_GetFileName(nsIFileURL *iface, nsACString *aFileName)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2012-01-11 19:41:18 +01:00
|
|
|
const WCHAR *file;
|
|
|
|
BSTR path;
|
|
|
|
nsresult nsres;
|
2009-08-27 11:31:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aFileName);
|
|
|
|
|
2012-01-11 19:41:18 +01:00
|
|
|
nsres = get_uri_path(This, &path, &file, NULL);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return nsres;
|
2009-08-27 11:31:14 +02:00
|
|
|
|
2012-01-11 19:41:18 +01:00
|
|
|
nsres = return_wstr_nsacstr(aFileName, file, -1);
|
|
|
|
SysFreeString(path);
|
|
|
|
return nsres;
|
2009-08-27 11:31:14 +02:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURL_SetFileName(nsIFileURL *iface, const nsACString *aFileName)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2012-01-11 19:41:42 +01:00
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_nsacstr(aFileName));
|
2009-08-27 11:31:14 +02:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURL_GetFileBaseName(nsIFileURL *iface, nsACString *aFileBaseName)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2012-01-11 19:41:28 +01:00
|
|
|
const WCHAR *file, *ext;
|
|
|
|
BSTR path;
|
|
|
|
nsresult nsres;
|
2009-08-27 11:31:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aFileBaseName);
|
|
|
|
|
2012-01-11 19:41:28 +01:00
|
|
|
nsres = get_uri_path(This, &path, &file, &ext);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return nsres;
|
2009-08-27 11:31:14 +02:00
|
|
|
|
2012-01-11 19:41:28 +01:00
|
|
|
nsres = return_wstr_nsacstr(aFileBaseName, file, ext-file);
|
|
|
|
SysFreeString(path);
|
|
|
|
return nsres;
|
2009-08-27 11:31:14 +02:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURL_SetFileBaseName(nsIFileURL *iface, const nsACString *aFileBaseName)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2012-01-11 19:41:42 +01:00
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_nsacstr(aFileBaseName));
|
2009-08-27 11:31:14 +02:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURL_GetFileExtension(nsIFileURL *iface, nsACString *aFileExtension)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2009-08-27 11:31:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aFileExtension);
|
|
|
|
|
2011-10-27 13:08:11 +02:00
|
|
|
return get_uri_string(This, Uri_PROPERTY_EXTENSION, aFileExtension);
|
2009-08-27 11:31:14 +02:00
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURL_SetFileExtension(nsIFileURL *iface, const nsACString *aFileExtension)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2012-01-11 19:41:42 +01:00
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_nsacstr(aFileExtension));
|
2009-08-27 11:31:14 +02:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURL_GetCommonBaseSpec(nsIFileURL *iface, nsIURI *aURIToCompare, nsACString *_retval)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2012-01-11 19:41:42 +01:00
|
|
|
FIXME("(%p)->(%p %p)\n", This, aURIToCompare, _retval);
|
2009-08-27 11:31:14 +02:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsURL_GetRelativeSpec(nsIFileURL *iface, nsIURI *aURIToCompare, nsACString *_retval)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2012-07-20 12:36:33 +02:00
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2012-01-11 19:41:42 +01:00
|
|
|
FIXME("(%p)->(%p %p)\n", This, aURIToCompare, _retval);
|
2009-08-27 11:31:14 +02:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
static nsresult NSAPI nsFileURL_GetFile(nsIFileURL *iface, nsIFile **aFile)
|
|
|
|
{
|
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
2012-07-20 12:36:50 +02:00
|
|
|
WCHAR path[MAX_PATH];
|
|
|
|
DWORD size;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aFile);
|
|
|
|
|
|
|
|
hres = CoInternetParseIUri(This->uri, PARSE_PATH_FROM_URL, 0, path, sizeof(path)/sizeof(WCHAR), &size, 0);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("CoInternetParseIUri failed: %08x\n", hres);
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return create_nsfile(path, aFile);
|
2012-07-20 12:36:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsFileURL_SetFile(nsIFileURL *iface, nsIFile *aFile)
|
|
|
|
{
|
|
|
|
nsWineURI *This = impl_from_nsIFileURL(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, aFile);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const nsIFileURLVtbl nsFileURLVtbl = {
|
2006-02-09 12:18:18 +01:00
|
|
|
nsURI_QueryInterface,
|
|
|
|
nsURI_AddRef,
|
|
|
|
nsURI_Release,
|
|
|
|
nsURI_GetSpec,
|
|
|
|
nsURI_SetSpec,
|
|
|
|
nsURI_GetPrePath,
|
|
|
|
nsURI_GetScheme,
|
|
|
|
nsURI_SetScheme,
|
|
|
|
nsURI_GetUserPass,
|
|
|
|
nsURI_SetUserPass,
|
|
|
|
nsURI_GetUsername,
|
|
|
|
nsURI_SetUsername,
|
|
|
|
nsURI_GetPassword,
|
|
|
|
nsURI_SetPassword,
|
|
|
|
nsURI_GetHostPort,
|
|
|
|
nsURI_SetHostPort,
|
|
|
|
nsURI_GetHost,
|
|
|
|
nsURI_SetHost,
|
|
|
|
nsURI_GetPort,
|
|
|
|
nsURI_SetPort,
|
|
|
|
nsURI_GetPath,
|
|
|
|
nsURI_SetPath,
|
|
|
|
nsURI_Equals,
|
|
|
|
nsURI_SchemeIs,
|
|
|
|
nsURI_Clone,
|
|
|
|
nsURI_Resolve,
|
|
|
|
nsURI_GetAsciiSpec,
|
|
|
|
nsURI_GetAsciiHost,
|
|
|
|
nsURI_GetOriginCharset,
|
2011-11-09 18:11:42 +01:00
|
|
|
nsURL_GetRef,
|
|
|
|
nsURL_SetRef,
|
|
|
|
nsURI_EqualsExceptRef,
|
|
|
|
nsURI_CloneIgnoreRef,
|
|
|
|
nsURI_GetSpecIgnoringRef,
|
|
|
|
nsURI_GetHasRef,
|
2009-08-27 11:31:14 +02:00
|
|
|
nsURL_GetFilePath,
|
|
|
|
nsURL_SetFilePath,
|
|
|
|
nsURL_GetQuery,
|
|
|
|
nsURL_SetQuery,
|
|
|
|
nsURL_GetDirectory,
|
|
|
|
nsURL_SetDirectory,
|
|
|
|
nsURL_GetFileName,
|
|
|
|
nsURL_SetFileName,
|
|
|
|
nsURL_GetFileBaseName,
|
|
|
|
nsURL_SetFileBaseName,
|
|
|
|
nsURL_GetFileExtension,
|
|
|
|
nsURL_SetFileExtension,
|
|
|
|
nsURL_GetCommonBaseSpec,
|
2012-07-20 12:36:33 +02:00
|
|
|
nsURL_GetRelativeSpec,
|
|
|
|
nsFileURL_GetFile,
|
|
|
|
nsFileURL_SetFile
|
2006-02-09 12:18:18 +01:00
|
|
|
};
|
|
|
|
|
2011-11-18 12:21:47 +01:00
|
|
|
static inline nsWineURI *impl_from_nsIStandardURL(nsIStandardURL *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, nsWineURI, nsIStandardURL_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsStandardURL_QueryInterface(nsIStandardURL *iface, nsIIDRef riid,
|
|
|
|
void **result)
|
|
|
|
{
|
|
|
|
nsWineURI *This = impl_from_nsIStandardURL(iface);
|
2012-07-26 11:37:48 +02:00
|
|
|
return nsIFileURL_QueryInterface(&This->nsIFileURL_iface, riid, result);
|
2011-11-18 12:21:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsStandardURL_AddRef(nsIStandardURL *iface)
|
|
|
|
{
|
|
|
|
nsWineURI *This = impl_from_nsIStandardURL(iface);
|
2012-07-26 11:37:48 +02:00
|
|
|
return nsIFileURL_AddRef(&This->nsIFileURL_iface);
|
2011-11-18 12:21:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsStandardURL_Release(nsIStandardURL *iface)
|
|
|
|
{
|
|
|
|
nsWineURI *This = impl_from_nsIStandardURL(iface);
|
2012-07-26 11:37:48 +02:00
|
|
|
return nsIFileURL_Release(&This->nsIFileURL_iface);
|
2011-11-18 12:21:47 +01:00
|
|
|
}
|
|
|
|
|
2012-03-15 11:54:33 +01:00
|
|
|
static nsresult NSAPI nsStandardURL_GetMutable(nsIStandardURL *iface, cpp_bool *aMutable)
|
2011-11-18 12:21:47 +01:00
|
|
|
{
|
|
|
|
nsWineURI *This = impl_from_nsIStandardURL(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aMutable);
|
|
|
|
|
2011-11-23 16:19:42 +01:00
|
|
|
*aMutable = This->is_mutable;
|
2011-11-18 12:21:47 +01:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-15 11:54:33 +01:00
|
|
|
static nsresult NSAPI nsStandardURL_SetMutable(nsIStandardURL *iface, cpp_bool aMutable)
|
2011-11-18 12:21:47 +01:00
|
|
|
{
|
|
|
|
nsWineURI *This = impl_from_nsIStandardURL(iface);
|
2011-11-23 16:19:42 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%x)\n", This, aMutable);
|
|
|
|
|
|
|
|
This->is_mutable = aMutable;
|
|
|
|
return NS_OK;
|
2011-11-18 12:21:47 +01:00
|
|
|
}
|
|
|
|
|
2013-01-23 18:44:42 +01:00
|
|
|
static nsresult NSAPI nsStandardURL_Init(nsIStandardURL *iface, UINT32 aUrlType, LONG aDefaultPort,
|
2011-11-18 12:21:47 +01:00
|
|
|
const nsACString *aSpec, const char *aOriginCharset, nsIURI *aBaseURI)
|
|
|
|
{
|
|
|
|
nsWineURI *This = impl_from_nsIStandardURL(iface);
|
|
|
|
FIXME("(%p)->(%d %d %s %s %p)\n", This, aUrlType, aDefaultPort, debugstr_nsacstr(aSpec), debugstr_a(aOriginCharset), aBaseURI);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const nsIStandardURLVtbl nsStandardURLVtbl = {
|
|
|
|
nsStandardURL_QueryInterface,
|
|
|
|
nsStandardURL_AddRef,
|
|
|
|
nsStandardURL_Release,
|
|
|
|
nsStandardURL_GetMutable,
|
|
|
|
nsStandardURL_SetMutable,
|
|
|
|
nsStandardURL_Init
|
|
|
|
};
|
|
|
|
|
2012-11-21 15:06:46 +01:00
|
|
|
static nsresult create_nsuri(IUri *iuri, HTMLOuterWindow *window, NSContainer *container,
|
|
|
|
const char *origin_charset, nsWineURI **_retval)
|
2006-02-24 20:31:12 +01:00
|
|
|
{
|
2012-10-19 11:58:01 +02:00
|
|
|
nsWineURI *ret;
|
2012-07-20 12:36:02 +02:00
|
|
|
HRESULT hres;
|
2006-02-24 20:31:12 +01:00
|
|
|
|
2012-10-19 11:58:01 +02:00
|
|
|
ret = heap_alloc_zero(sizeof(nsWineURI));
|
|
|
|
if(!ret)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
ret->nsIFileURL_iface.lpVtbl = &nsFileURLVtbl;
|
2011-11-18 12:21:47 +01:00
|
|
|
ret->nsIStandardURL_iface.lpVtbl = &nsStandardURLVtbl;
|
2006-02-24 20:31:12 +01:00
|
|
|
ret->ref = 1;
|
2011-11-23 16:19:42 +01:00
|
|
|
ret->is_mutable = TRUE;
|
2006-02-24 20:31:12 +01:00
|
|
|
|
2010-02-21 21:09:11 +01:00
|
|
|
set_uri_nscontainer(ret, container);
|
2010-02-21 21:08:39 +01:00
|
|
|
set_uri_window(ret, window);
|
2006-02-24 20:31:12 +01:00
|
|
|
|
2011-06-25 19:03:19 +02:00
|
|
|
IUri_AddRef(iuri);
|
|
|
|
ret->uri = iuri;
|
|
|
|
|
2012-07-20 12:36:02 +02:00
|
|
|
hres = IUri_GetScheme(iuri, &ret->scheme);
|
|
|
|
if(FAILED(hres))
|
|
|
|
ret->scheme = URL_SCHEME_UNKNOWN;
|
|
|
|
|
2012-11-21 15:06:46 +01:00
|
|
|
if(origin_charset && *origin_charset && strcmp(origin_charset, "UTF-8")) {
|
|
|
|
ret->origin_charset = heap_strdupA(origin_charset);
|
|
|
|
if(!ret->origin_charset) {
|
|
|
|
nsIFileURL_Release(&ret->nsIFileURL_iface);
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-24 20:31:12 +01:00
|
|
|
TRACE("retval=%p\n", ret);
|
2010-02-21 21:06:51 +01:00
|
|
|
*_retval = ret;
|
2006-02-24 20:31:12 +01:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-04-04 16:15:33 +02:00
|
|
|
HRESULT create_doc_uri(HTMLOuterWindow *window, IUri *iuri, nsWineURI **ret)
|
2009-11-30 18:01:31 +01:00
|
|
|
{
|
2010-02-21 21:06:51 +01:00
|
|
|
nsWineURI *uri;
|
2009-11-30 18:01:31 +01:00
|
|
|
nsresult nsres;
|
|
|
|
|
2012-11-21 15:06:46 +01:00
|
|
|
nsres = create_nsuri(iuri, window, window->doc_obj->nscontainer, NULL, &uri);
|
2009-11-30 18:01:31 +01:00
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return E_FAIL;
|
|
|
|
|
2010-02-21 21:06:51 +01:00
|
|
|
uri->is_doc_uri = TRUE;
|
2009-11-30 18:01:31 +01:00
|
|
|
|
|
|
|
*ret = uri;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-04-15 19:36:24 +02:00
|
|
|
static nsresult create_nschannel(nsWineURI *uri, nsChannel **ret)
|
|
|
|
{
|
|
|
|
nsChannel *channel;
|
|
|
|
|
|
|
|
if(!ensure_uri(uri))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
channel = heap_alloc_zero(sizeof(nsChannel));
|
|
|
|
if(!channel)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
channel->nsIHttpChannel_iface.lpVtbl = &nsChannelVtbl;
|
|
|
|
channel->nsIUploadChannel_iface.lpVtbl = &nsUploadChannelVtbl;
|
|
|
|
channel->nsIHttpChannelInternal_iface.lpVtbl = &nsHttpChannelInternalVtbl;
|
|
|
|
channel->ref = 1;
|
|
|
|
channel->request_method = METHOD_GET;
|
|
|
|
list_init(&channel->response_headers);
|
|
|
|
list_init(&channel->request_headers);
|
|
|
|
|
2012-07-26 11:37:48 +02:00
|
|
|
nsIFileURL_AddRef(&uri->nsIFileURL_iface);
|
2011-04-15 19:36:24 +02:00
|
|
|
channel->uri = uri;
|
|
|
|
|
|
|
|
*ret = channel;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-04-15 19:36:36 +02:00
|
|
|
HRESULT create_redirect_nschannel(const WCHAR *url, nsChannel *orig_channel, nsChannel **ret)
|
|
|
|
{
|
2012-06-25 14:04:59 +02:00
|
|
|
HTMLOuterWindow *window = NULL;
|
2011-04-15 19:36:36 +02:00
|
|
|
nsChannel *channel;
|
|
|
|
nsWineURI *uri;
|
2011-06-25 19:03:19 +02:00
|
|
|
IUri *iuri;
|
2011-04-15 19:36:36 +02:00
|
|
|
nsresult nsres;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2013-03-26 11:37:47 +01:00
|
|
|
hres = create_uri(url, 0, &iuri);
|
2011-06-25 19:03:19 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2011-04-15 19:36:36 +02:00
|
|
|
if(orig_channel->uri->window_ref)
|
|
|
|
window = orig_channel->uri->window_ref->window;
|
2012-11-21 15:06:46 +01:00
|
|
|
nsres = create_nsuri(iuri, window, NULL, NULL, &uri);
|
2011-06-25 19:03:19 +02:00
|
|
|
IUri_Release(iuri);
|
2011-04-15 19:36:36 +02:00
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return E_FAIL;
|
|
|
|
|
2011-06-25 19:03:19 +02:00
|
|
|
nsres = create_nschannel(uri, &channel);
|
2012-07-26 11:37:48 +02:00
|
|
|
nsIFileURL_Release(&uri->nsIFileURL_iface);
|
2011-04-15 19:36:36 +02:00
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
if(orig_channel->load_group) {
|
|
|
|
nsILoadGroup_AddRef(orig_channel->load_group);
|
|
|
|
channel->load_group = orig_channel->load_group;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(orig_channel->notif_callback) {
|
|
|
|
nsIInterfaceRequestor_AddRef(orig_channel->notif_callback);
|
|
|
|
channel->notif_callback = orig_channel->notif_callback;
|
|
|
|
}
|
|
|
|
|
|
|
|
channel->load_flags = orig_channel->load_flags | LOAD_REPLACE;
|
|
|
|
|
|
|
|
if(orig_channel->request_method == METHOD_POST)
|
|
|
|
FIXME("unsupported POST method\n");
|
|
|
|
|
|
|
|
if(orig_channel->original_uri) {
|
|
|
|
nsIURI_AddRef(orig_channel->original_uri);
|
|
|
|
channel->original_uri = orig_channel->original_uri;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(orig_channel->referrer) {
|
|
|
|
nsIURI_AddRef(orig_channel->referrer);
|
|
|
|
channel->referrer = orig_channel->referrer;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ret = channel;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-05-12 16:12:04 +02:00
|
|
|
typedef struct {
|
2010-12-29 02:52:32 +01:00
|
|
|
nsIProtocolHandler nsIProtocolHandler_iface;
|
2007-05-12 16:12:04 +02:00
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
nsIProtocolHandler *nshandler;
|
|
|
|
} nsProtocolHandler;
|
|
|
|
|
2010-12-29 02:52:32 +01:00
|
|
|
static inline nsProtocolHandler *impl_from_nsIProtocolHandler(nsIProtocolHandler *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, nsProtocolHandler, nsIProtocolHandler_iface);
|
|
|
|
}
|
2007-05-12 16:12:04 +02:00
|
|
|
|
|
|
|
static nsresult NSAPI nsProtocolHandler_QueryInterface(nsIProtocolHandler *iface, nsIIDRef riid,
|
2010-08-02 11:08:26 +02:00
|
|
|
void **result)
|
2007-05-12 16:12:04 +02:00
|
|
|
{
|
2010-12-29 02:52:32 +01:00
|
|
|
nsProtocolHandler *This = impl_from_nsIProtocolHandler(iface);
|
2007-05-12 16:12:04 +02:00
|
|
|
|
|
|
|
*result = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_nsISupports, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsISupports %p)\n", This, result);
|
2010-12-29 02:52:32 +01:00
|
|
|
*result = &This->nsIProtocolHandler_iface;
|
2007-05-12 16:12:04 +02:00
|
|
|
}else if(IsEqualGUID(&IID_nsIProtocolHandler, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIProtocolHandler %p)\n", This, result);
|
2010-12-29 02:52:32 +01:00
|
|
|
*result = &This->nsIProtocolHandler_iface;
|
2007-05-12 16:12:04 +02:00
|
|
|
}else if(IsEqualGUID(&IID_nsIExternalProtocolHandler, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIExternalProtocolHandler %p), returning NULL\n", This, result);
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*result) {
|
|
|
|
nsISupports_AddRef((nsISupports*)*result);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-05-15 14:00:40 +02:00
|
|
|
WARN("(%s %p)\n", debugstr_guid(riid), result);
|
2007-05-12 16:12:04 +02:00
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsProtocolHandler_AddRef(nsIProtocolHandler *iface)
|
|
|
|
{
|
2010-12-29 02:52:32 +01:00
|
|
|
nsProtocolHandler *This = impl_from_nsIProtocolHandler(iface);
|
2007-05-12 16:12:04 +02:00
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsProtocolHandler_Release(nsIProtocolHandler *iface)
|
|
|
|
{
|
2010-12-29 02:52:32 +01:00
|
|
|
nsProtocolHandler *This = impl_from_nsIProtocolHandler(iface);
|
2007-05-12 16:12:04 +02:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
if(!ref) {
|
|
|
|
if(This->nshandler)
|
|
|
|
nsIProtocolHandler_Release(This->nshandler);
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(This);
|
2007-05-12 16:12:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsProtocolHandler_GetScheme(nsIProtocolHandler *iface, nsACString *aScheme)
|
|
|
|
{
|
2010-12-29 02:52:32 +01:00
|
|
|
nsProtocolHandler *This = impl_from_nsIProtocolHandler(iface);
|
2007-05-12 16:12:04 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aScheme);
|
|
|
|
|
|
|
|
if(This->nshandler)
|
|
|
|
return nsIProtocolHandler_GetScheme(This->nshandler, aScheme);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsProtocolHandler_GetDefaultPort(nsIProtocolHandler *iface,
|
2013-01-18 14:05:15 +01:00
|
|
|
LONG *aDefaultPort)
|
2007-05-12 16:12:04 +02:00
|
|
|
{
|
2010-12-29 02:52:32 +01:00
|
|
|
nsProtocolHandler *This = impl_from_nsIProtocolHandler(iface);
|
2007-05-12 16:12:04 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aDefaultPort);
|
|
|
|
|
|
|
|
if(This->nshandler)
|
|
|
|
return nsIProtocolHandler_GetDefaultPort(This->nshandler, aDefaultPort);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsProtocolHandler_GetProtocolFlags(nsIProtocolHandler *iface,
|
2013-01-23 18:44:42 +01:00
|
|
|
UINT32 *aProtocolFlags)
|
2007-05-12 16:12:04 +02:00
|
|
|
{
|
2010-12-29 02:52:32 +01:00
|
|
|
nsProtocolHandler *This = impl_from_nsIProtocolHandler(iface);
|
2007-05-12 16:12:04 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aProtocolFlags);
|
|
|
|
|
|
|
|
if(This->nshandler)
|
|
|
|
return nsIProtocolHandler_GetProtocolFlags(This->nshandler, aProtocolFlags);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsProtocolHandler_NewURI(nsIProtocolHandler *iface,
|
|
|
|
const nsACString *aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval)
|
|
|
|
{
|
2010-12-29 02:52:32 +01:00
|
|
|
nsProtocolHandler *This = impl_from_nsIProtocolHandler(iface);
|
2007-05-12 16:12:04 +02:00
|
|
|
|
2010-08-03 15:44:56 +02:00
|
|
|
TRACE("((%p)->%s %s %p %p)\n", This, debugstr_nsacstr(aSpec), debugstr_a(aOriginCharset),
|
|
|
|
aBaseURI, _retval);
|
2007-05-12 16:12:04 +02:00
|
|
|
|
|
|
|
if(This->nshandler)
|
|
|
|
return nsIProtocolHandler_NewURI(This->nshandler, aSpec, aOriginCharset, aBaseURI, _retval);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:19:41 +01:00
|
|
|
static nsresult NSAPI nsProtocolHandler_NewChannel2(nsIProtocolHandler *iface,
|
|
|
|
nsIURI *aURI, nsILoadInfo *aLoadInfo, nsIChannel **_retval)
|
|
|
|
{
|
|
|
|
nsProtocolHandler *This = impl_from_nsIProtocolHandler(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p %p)\n", This, aURI, aLoadInfo, _retval);
|
|
|
|
|
|
|
|
if(This->nshandler)
|
|
|
|
return nsIProtocolHandler_NewChannel2(This->nshandler, aURI, aLoadInfo, _retval);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2007-05-12 16:12:04 +02:00
|
|
|
static nsresult NSAPI nsProtocolHandler_NewChannel(nsIProtocolHandler *iface,
|
|
|
|
nsIURI *aURI, nsIChannel **_retval)
|
|
|
|
{
|
2010-12-29 02:52:32 +01:00
|
|
|
nsProtocolHandler *This = impl_from_nsIProtocolHandler(iface);
|
2007-05-12 16:12:04 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p)\n", This, aURI, _retval);
|
|
|
|
|
|
|
|
if(This->nshandler)
|
|
|
|
return nsIProtocolHandler_NewChannel(This->nshandler, aURI, _retval);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsProtocolHandler_AllowPort(nsIProtocolHandler *iface,
|
2013-01-18 14:05:15 +01:00
|
|
|
LONG port, const char *scheme, cpp_bool *_retval)
|
2007-05-12 16:12:04 +02:00
|
|
|
{
|
2010-12-29 02:52:32 +01:00
|
|
|
nsProtocolHandler *This = impl_from_nsIProtocolHandler(iface);
|
2007-05-12 16:12:04 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%d %s %p)\n", This, port, debugstr_a(scheme), _retval);
|
|
|
|
|
|
|
|
if(This->nshandler)
|
|
|
|
return nsIProtocolHandler_AllowPort(This->nshandler, port, scheme, _retval);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const nsIProtocolHandlerVtbl nsProtocolHandlerVtbl = {
|
|
|
|
nsProtocolHandler_QueryInterface,
|
|
|
|
nsProtocolHandler_AddRef,
|
|
|
|
nsProtocolHandler_Release,
|
|
|
|
nsProtocolHandler_GetScheme,
|
|
|
|
nsProtocolHandler_GetDefaultPort,
|
|
|
|
nsProtocolHandler_GetProtocolFlags,
|
|
|
|
nsProtocolHandler_NewURI,
|
2015-02-24 14:19:41 +01:00
|
|
|
nsProtocolHandler_NewChannel2,
|
2007-05-12 16:12:04 +02:00
|
|
|
nsProtocolHandler_NewChannel,
|
|
|
|
nsProtocolHandler_AllowPort
|
|
|
|
};
|
|
|
|
|
2010-08-02 11:08:26 +02:00
|
|
|
static nsresult NSAPI nsIOService_QueryInterface(nsIIOService*,nsIIDRef,void**);
|
2006-02-09 12:17:08 +01:00
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsIOService_AddRef(nsIIOService *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsIOService_Release(nsIIOService *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsIOService_GetProtocolHandler(nsIIOService *iface, const char *aScheme,
|
|
|
|
nsIProtocolHandler **_retval)
|
|
|
|
{
|
2007-05-12 16:12:04 +02:00
|
|
|
nsIExternalProtocolHandler *nsexthandler;
|
|
|
|
nsIProtocolHandler *nshandler;
|
2012-10-19 11:58:01 +02:00
|
|
|
nsProtocolHandler *ret;
|
2007-05-12 16:12:04 +02:00
|
|
|
nsresult nsres;
|
|
|
|
|
2006-02-09 12:17:08 +01:00
|
|
|
TRACE("(%s %p)\n", debugstr_a(aScheme), _retval);
|
2007-05-12 16:12:04 +02:00
|
|
|
|
|
|
|
nsres = nsIIOService_GetProtocolHandler(nsio, aScheme, &nshandler);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
WARN("GetProtocolHandler failed: %08x\n", nsres);
|
|
|
|
return nsres;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIProtocolHandler_QueryInterface(nshandler, &IID_nsIExternalProtocolHandler,
|
|
|
|
(void**)&nsexthandler);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
*_retval = nshandler;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIExternalProtocolHandler_Release(nsexthandler);
|
2012-10-19 11:58:01 +02:00
|
|
|
|
|
|
|
ret = heap_alloc(sizeof(nsProtocolHandler));
|
|
|
|
if(!ret)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
ret->nsIProtocolHandler_iface.lpVtbl = &nsProtocolHandlerVtbl;
|
|
|
|
ret->ref = 1;
|
|
|
|
ret->nshandler = nshandler;
|
|
|
|
*_retval = &ret->nsIProtocolHandler_iface;
|
|
|
|
|
2007-05-12 16:12:04 +02:00
|
|
|
TRACE("return %p\n", *_retval);
|
|
|
|
return NS_OK;
|
2006-02-09 12:17:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsIOService_GetProtocolFlags(nsIIOService *iface, const char *aScheme,
|
2013-01-23 18:44:42 +01:00
|
|
|
UINT32 *_retval)
|
2006-02-09 12:17:08 +01:00
|
|
|
{
|
|
|
|
TRACE("(%s %p)\n", debugstr_a(aScheme), _retval);
|
|
|
|
return nsIIOService_GetProtocolFlags(nsio, aScheme, _retval);
|
|
|
|
}
|
|
|
|
|
2007-08-12 17:37:33 +02:00
|
|
|
static BOOL is_gecko_special_uri(const char *spec)
|
|
|
|
{
|
2015-09-28 15:45:20 +02:00
|
|
|
static const char *special_schemes[] = {"chrome:", "data:", "jar:", "moz-safe-about", "resource:", "javascript:", "wyciwyg:"};
|
2013-02-16 22:09:13 +01:00
|
|
|
unsigned int i;
|
2009-08-22 19:37:59 +02:00
|
|
|
|
|
|
|
for(i=0; i < sizeof(special_schemes)/sizeof(*special_schemes); i++) {
|
|
|
|
if(!strncasecmp(spec, special_schemes[i], strlen(special_schemes[i])))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-08-18 13:37:21 +02:00
|
|
|
if(!strncasecmp(spec, "file:", 5)) {
|
|
|
|
const char *ptr = spec+5;
|
|
|
|
while(*ptr == '/')
|
|
|
|
ptr++;
|
|
|
|
return is_gecko_path(ptr);
|
|
|
|
}
|
|
|
|
|
2009-08-22 19:37:59 +02:00
|
|
|
return FALSE;
|
2007-08-12 17:37:33 +02:00
|
|
|
}
|
|
|
|
|
2006-02-09 12:17:08 +01:00
|
|
|
static nsresult NSAPI nsIOService_NewURI(nsIIOService *iface, const nsACString *aSpec,
|
|
|
|
const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval)
|
|
|
|
{
|
2010-02-21 21:07:43 +01:00
|
|
|
nsWineURI *wine_uri, *base_wine_uri = NULL;
|
2010-12-30 23:32:58 +01:00
|
|
|
WCHAR new_spec[INTERNET_MAX_URL_LENGTH];
|
2012-06-25 14:04:59 +02:00
|
|
|
HTMLOuterWindow *window = NULL;
|
2010-12-30 23:32:58 +01:00
|
|
|
const char *spec = NULL;
|
2014-10-11 17:35:19 +02:00
|
|
|
UINT cp = CP_UTF8;
|
2010-12-30 23:32:58 +01:00
|
|
|
IUri *urlmon_uri;
|
2006-02-09 12:18:18 +01:00
|
|
|
nsresult nsres;
|
2010-12-30 23:32:58 +01:00
|
|
|
HRESULT hres;
|
2006-02-09 12:18:18 +01:00
|
|
|
|
2010-08-03 15:44:56 +02:00
|
|
|
TRACE("(%s %s %p %p)\n", debugstr_nsacstr(aSpec), debugstr_a(aOriginCharset),
|
2006-02-09 12:18:18 +01:00
|
|
|
aBaseURI, _retval);
|
|
|
|
|
2010-08-03 15:44:56 +02:00
|
|
|
nsACString_GetData(aSpec, &spec);
|
2007-08-12 17:37:33 +02:00
|
|
|
if(is_gecko_special_uri(spec))
|
|
|
|
return nsIIOService_NewURI(nsio, aSpec, aOriginCharset, aBaseURI, _retval);
|
|
|
|
|
2010-04-03 18:07:07 +02:00
|
|
|
if(!strncmp(spec, "wine:", 5))
|
2007-08-14 22:36:10 +02:00
|
|
|
spec += 5;
|
|
|
|
|
2006-02-09 12:18:18 +01:00
|
|
|
if(aBaseURI) {
|
2010-02-21 21:10:15 +01:00
|
|
|
nsres = nsIURI_QueryInterface(aBaseURI, &IID_nsWineURI, (void**)&base_wine_uri);
|
2006-02-09 12:18:18 +01:00
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
2010-12-30 23:32:58 +01:00
|
|
|
if(!ensure_uri(base_wine_uri))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
if(base_wine_uri->window_ref)
|
2010-02-21 21:08:39 +01:00
|
|
|
window = base_wine_uri->window_ref->window;
|
2006-02-09 12:18:18 +01:00
|
|
|
}else {
|
2010-02-21 21:10:15 +01:00
|
|
|
WARN("Could not get base nsWineURI: %08x\n", nsres);
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-11 17:35:19 +02:00
|
|
|
if(aOriginCharset && *aOriginCharset && strncasecmp(aOriginCharset, "utf", 3)) {
|
|
|
|
BSTR charset;
|
|
|
|
int len;
|
2014-09-26 15:38:59 +02:00
|
|
|
|
2014-10-11 17:35:19 +02:00
|
|
|
len = MultiByteToWideChar(CP_UTF8, 0, aOriginCharset, -1, NULL, 0);
|
|
|
|
charset = SysAllocStringLen(NULL, len-1);
|
|
|
|
if(!charset)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
MultiByteToWideChar(CP_UTF8, 0, aOriginCharset, -1, charset, len);
|
|
|
|
|
|
|
|
cp = cp_from_charset_string(charset);
|
|
|
|
|
|
|
|
SysFreeString(charset);
|
|
|
|
}
|
|
|
|
|
|
|
|
MultiByteToWideChar(cp, 0, spec, -1, new_spec, sizeof(new_spec)/sizeof(WCHAR));
|
2006-06-22 16:09:29 +02:00
|
|
|
|
2010-12-30 23:32:58 +01:00
|
|
|
if(base_wine_uri) {
|
2013-11-29 12:58:25 +01:00
|
|
|
hres = combine_url(base_wine_uri->uri, new_spec, &urlmon_uri);
|
2010-04-03 18:07:07 +02:00
|
|
|
}else {
|
2013-03-26 11:37:47 +01:00
|
|
|
hres = create_uri(new_spec, 0, &urlmon_uri);
|
2010-12-30 23:32:58 +01:00
|
|
|
if(FAILED(hres))
|
2013-03-26 11:37:47 +01:00
|
|
|
WARN("create_uri failed: %08x\n", hres);
|
2010-12-30 23:32:58 +01:00
|
|
|
}
|
2007-08-14 22:36:10 +02:00
|
|
|
|
2012-01-12 15:37:23 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return nsIIOService_NewURI(nsio, aSpec, aOriginCharset, aBaseURI, _retval);
|
2006-08-09 16:42:37 +02:00
|
|
|
|
2012-11-21 15:06:46 +01:00
|
|
|
nsres = create_nsuri(urlmon_uri, window, NULL, NULL, &wine_uri);
|
2011-06-25 19:03:19 +02:00
|
|
|
IUri_Release(urlmon_uri);
|
2007-02-09 20:19:13 +01:00
|
|
|
if(base_wine_uri)
|
2012-07-26 11:37:48 +02:00
|
|
|
nsIFileURL_Release(&base_wine_uri->nsIFileURL_iface);
|
2010-12-30 23:32:58 +01:00
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return nsres;
|
2007-02-09 20:19:13 +01:00
|
|
|
|
2012-07-20 12:36:33 +02:00
|
|
|
*_retval = (nsIURI*)&wine_uri->nsIFileURL_iface;
|
2006-06-22 16:09:29 +02:00
|
|
|
return nsres;
|
2006-02-09 12:17:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsIOService_NewFileURI(nsIIOService *iface, nsIFile *aFile,
|
|
|
|
nsIURI **_retval)
|
|
|
|
{
|
|
|
|
TRACE("(%p %p)\n", aFile, _retval);
|
|
|
|
return nsIIOService_NewFileURI(nsio, aFile, _retval);
|
|
|
|
}
|
|
|
|
|
2015-08-11 15:11:35 +02:00
|
|
|
static nsresult new_channel_from_uri(nsIURI *uri, nsILoadInfo *load_info, nsIChannel **_retval)
|
2006-02-09 12:17:08 +01:00
|
|
|
{
|
2010-02-21 21:05:15 +01:00
|
|
|
nsWineURI *wine_uri;
|
2011-04-15 19:36:24 +02:00
|
|
|
nsChannel *ret;
|
2006-02-09 12:19:13 +01:00
|
|
|
nsresult nsres;
|
|
|
|
|
2015-07-02 17:50:10 +02:00
|
|
|
nsres = nsIURI_QueryInterface(uri, &IID_nsWineURI, (void**)&wine_uri);
|
2006-02-09 12:19:13 +01:00
|
|
|
if(NS_FAILED(nsres)) {
|
2010-02-21 21:10:15 +01:00
|
|
|
TRACE("Could not get nsWineURI: %08x\n", nsres);
|
2015-07-02 17:50:10 +02:00
|
|
|
return nsIIOService_NewChannelFromURI(nsio, uri, _retval);
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
2011-04-15 19:36:24 +02:00
|
|
|
nsres = create_nschannel(wine_uri, &ret);
|
2012-07-26 11:37:48 +02:00
|
|
|
nsIFileURL_Release(&wine_uri->nsIFileURL_iface);
|
2011-04-15 19:36:24 +02:00
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return nsres;
|
2006-02-20 16:43:32 +01:00
|
|
|
|
2015-07-02 17:50:10 +02:00
|
|
|
nsIURI_AddRef(uri);
|
|
|
|
ret->original_uri = uri;
|
2010-11-25 13:56:03 +01:00
|
|
|
|
2015-08-11 15:11:35 +02:00
|
|
|
if(load_info)
|
|
|
|
nsIHttpChannel_SetLoadInfo(&ret->nsIHttpChannel_iface, load_info);
|
|
|
|
|
2010-12-30 01:43:11 +01:00
|
|
|
*_retval = (nsIChannel*)&ret->nsIHttpChannel_iface;
|
2006-02-09 12:19:13 +01:00
|
|
|
return NS_OK;
|
2006-02-09 12:17:08 +01:00
|
|
|
}
|
|
|
|
|
2015-07-02 17:50:10 +02:00
|
|
|
static nsresult NSAPI nsIOService_NewChannelFromURI2(nsIIOService *iface, nsIURI *aURI,
|
|
|
|
nsIDOMNode *aLoadingNode, nsIPrincipal *aLoadingPrincipal, nsIPrincipal *aTriggeringPrincipal,
|
|
|
|
UINT32 aSecurityFlags, UINT32 aContentPolicyType, nsIChannel **_retval)
|
|
|
|
{
|
2015-08-11 15:11:35 +02:00
|
|
|
nsILoadInfo *load_info = NULL;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p %p %p %p %x %d %p)\n", aURI, aLoadingNode, aLoadingPrincipal, aTriggeringPrincipal,
|
2015-07-02 17:50:10 +02:00
|
|
|
aSecurityFlags, aContentPolicyType, _retval);
|
2015-08-11 15:11:35 +02:00
|
|
|
|
|
|
|
if(aLoadingNode || aLoadingPrincipal) {
|
|
|
|
nsres = nsIIOService_NewLoadInfo(nsio, aLoadingPrincipal, aTriggeringPrincipal, aLoadingNode,
|
|
|
|
aSecurityFlags, aContentPolicyType, &load_info);
|
|
|
|
assert(nsres == NS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = new_channel_from_uri(aURI, load_info, _retval);
|
|
|
|
if(load_info)
|
|
|
|
nsISupports_Release(load_info);
|
|
|
|
return nsres;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsIOService_NewChannelFromURIWithLoadInfo(nsIIOService *iface, nsIURI *aURI,
|
|
|
|
nsILoadInfo *aLoadInfo, nsIChannel **_retval)
|
|
|
|
{
|
|
|
|
TRACE("(%p %p %p)\n", aURI, aLoadInfo, _retval);
|
|
|
|
return new_channel_from_uri(aURI, aLoadInfo, _retval);
|
2015-07-02 17:50:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsIOService_NewChannelFromURI(nsIIOService *iface, nsIURI *aURI,
|
|
|
|
nsIChannel **_retval)
|
|
|
|
{
|
|
|
|
TRACE("(%p %p)\n", aURI, _retval);
|
2015-08-11 15:11:35 +02:00
|
|
|
return new_channel_from_uri(aURI, NULL, _retval);
|
2015-07-02 17:50:10 +02:00
|
|
|
}
|
|
|
|
|
2015-02-24 14:19:41 +01:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
TRACE("(%s %s %p %p %p %p %x %d %p)\n", debugstr_nsacstr(aSpec), debugstr_a(aOriginCharset), aBaseURI,
|
|
|
|
aLoadingNode, aLoadingPrincipal, aTriggeringPrincipal, aSecurityFlags, aContentPolicyType, _retval);
|
|
|
|
return nsIIOService_NewChannel2(nsio, aSpec, aOriginCharset, aBaseURI, aLoadingNode, aLoadingPrincipal,
|
|
|
|
aTriggeringPrincipal, aSecurityFlags, aContentPolicyType, _retval);
|
|
|
|
}
|
|
|
|
|
2006-02-09 12:17:08 +01:00
|
|
|
static nsresult NSAPI nsIOService_NewChannel(nsIIOService *iface, const nsACString *aSpec,
|
|
|
|
const char *aOriginCharset, nsIURI *aBaseURI, nsIChannel **_retval)
|
|
|
|
{
|
2010-08-03 15:44:56 +02:00
|
|
|
TRACE("(%s %s %p %p)\n", debugstr_nsacstr(aSpec), debugstr_a(aOriginCharset), aBaseURI, _retval);
|
2006-02-09 12:17:08 +01:00
|
|
|
return nsIIOService_NewChannel(nsio, aSpec, aOriginCharset, aBaseURI, _retval);
|
|
|
|
}
|
|
|
|
|
2012-03-15 11:54:33 +01:00
|
|
|
static nsresult NSAPI nsIOService_GetOffline(nsIIOService *iface, cpp_bool *aOffline)
|
2006-02-09 12:17:08 +01:00
|
|
|
{
|
|
|
|
TRACE("(%p)\n", aOffline);
|
|
|
|
return nsIIOService_GetOffline(nsio, aOffline);
|
|
|
|
}
|
|
|
|
|
2012-03-15 11:54:33 +01:00
|
|
|
static nsresult NSAPI nsIOService_SetOffline(nsIIOService *iface, cpp_bool aOffline)
|
2006-02-09 12:17:08 +01:00
|
|
|
{
|
|
|
|
TRACE("(%x)\n", aOffline);
|
|
|
|
return nsIIOService_SetOffline(nsio, aOffline);
|
|
|
|
}
|
|
|
|
|
2015-08-11 15:11:35 +02:00
|
|
|
static nsresult NSAPI nsIOService_GetConnectivity(nsIIOService *iface, cpp_bool *aConnectivity)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", aConnectivity);
|
|
|
|
return nsIIOService_GetConnectivity(nsio, aConnectivity);
|
|
|
|
}
|
|
|
|
|
2015-02-24 14:19:41 +01:00
|
|
|
static nsresult NSAPI nsIOService_SetAppOffline(nsIIOService *iface, UINT32 appId, INT32 state)
|
|
|
|
{
|
|
|
|
TRACE("(%d %x)\n", appId, state);
|
|
|
|
return nsIIOService_SetAppOffline(nsio, appId, state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsIOService_IsAppOffline(nsIIOService *iface, UINT32 appId, cpp_bool *_retval)
|
|
|
|
{
|
|
|
|
TRACE("(%u %p)\n", appId, _retval);
|
|
|
|
return nsIIOService_IsAppOffline(nsio, appId, _retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsIOService_GetAppOfflineState(nsIIOService *iface, UINT32 appId, INT32 *_retval)
|
|
|
|
{
|
|
|
|
TRACE("(%d %p)\n", appId, _retval);
|
|
|
|
return nsIIOService_GetAppOfflineState(nsio, appId, _retval);
|
|
|
|
}
|
|
|
|
|
2013-01-18 14:05:15 +01:00
|
|
|
static nsresult NSAPI nsIOService_AllowPort(nsIIOService *iface, LONG aPort,
|
2012-03-15 11:54:33 +01:00
|
|
|
const char *aScheme, cpp_bool *_retval)
|
2006-02-09 12:17:08 +01:00
|
|
|
{
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%d %s %p)\n", aPort, debugstr_a(aScheme), _retval);
|
2006-02-09 12:17:08 +01:00
|
|
|
return nsIIOService_AllowPort(nsio, aPort, debugstr_a(aScheme), _retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsIOService_ExtractScheme(nsIIOService *iface, const nsACString *urlString,
|
|
|
|
nsACString * _retval)
|
|
|
|
{
|
2010-08-03 15:44:56 +02:00
|
|
|
TRACE("(%s %p)\n", debugstr_nsacstr(urlString), _retval);
|
2006-02-09 12:17:08 +01:00
|
|
|
return nsIIOService_ExtractScheme(nsio, urlString, _retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const nsIIOServiceVtbl nsIOServiceVtbl = {
|
|
|
|
nsIOService_QueryInterface,
|
|
|
|
nsIOService_AddRef,
|
|
|
|
nsIOService_Release,
|
|
|
|
nsIOService_GetProtocolHandler,
|
|
|
|
nsIOService_GetProtocolFlags,
|
|
|
|
nsIOService_NewURI,
|
|
|
|
nsIOService_NewFileURI,
|
2015-02-24 14:19:41 +01:00
|
|
|
nsIOService_NewChannelFromURI2,
|
2015-08-11 15:11:35 +02:00
|
|
|
nsIOService_NewChannelFromURIWithLoadInfo,
|
2006-02-09 12:17:08 +01:00
|
|
|
nsIOService_NewChannelFromURI,
|
2015-02-24 14:19:41 +01:00
|
|
|
nsIOService_NewChannel2,
|
2006-02-09 12:17:08 +01:00
|
|
|
nsIOService_NewChannel,
|
|
|
|
nsIOService_GetOffline,
|
|
|
|
nsIOService_SetOffline,
|
2015-08-11 15:11:35 +02:00
|
|
|
nsIOService_GetConnectivity,
|
2015-02-24 14:19:41 +01:00
|
|
|
nsIOService_SetAppOffline,
|
|
|
|
nsIOService_IsAppOffline,
|
|
|
|
nsIOService_GetAppOfflineState,
|
2006-02-09 12:17:08 +01:00
|
|
|
nsIOService_AllowPort,
|
|
|
|
nsIOService_ExtractScheme
|
|
|
|
};
|
|
|
|
|
|
|
|
static nsIIOService nsIOService = { &nsIOServiceVtbl };
|
|
|
|
|
2008-02-20 21:30:51 +01:00
|
|
|
static nsresult NSAPI nsNetUtil_QueryInterface(nsINetUtil *iface, nsIIDRef riid,
|
2010-08-02 11:08:26 +02:00
|
|
|
void **result)
|
2008-02-20 21:30:51 +01:00
|
|
|
{
|
|
|
|
return nsIIOService_QueryInterface(&nsIOService, riid, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsNetUtil_AddRef(nsINetUtil *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsNetUtil_Release(nsINetUtil *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsNetUtil_ParseContentType(nsINetUtil *iface, const nsACString *aTypeHeader,
|
2012-03-15 11:54:33 +01:00
|
|
|
nsACString *aCharset, cpp_bool *aHadCharset, nsACString *aContentType)
|
2008-02-20 21:30:51 +01:00
|
|
|
{
|
2010-08-03 15:44:56 +02:00
|
|
|
TRACE("(%s %p %p %p)\n", debugstr_nsacstr(aTypeHeader), aCharset, aHadCharset, aContentType);
|
2008-02-20 21:30:51 +01:00
|
|
|
|
2008-12-18 14:08:13 +01:00
|
|
|
return nsINetUtil_ParseContentType(net_util, aTypeHeader, aCharset, aHadCharset, aContentType);
|
2008-02-20 21:30:51 +01:00
|
|
|
}
|
|
|
|
|
2015-01-26 16:13:31 +01:00
|
|
|
static const char *debugstr_protocol_flags(UINT32 flags)
|
|
|
|
{
|
|
|
|
switch(flags) {
|
|
|
|
#define X(f) case f: return #f
|
|
|
|
X(URI_STD);
|
|
|
|
X(URI_NORELATIVE);
|
|
|
|
X(URI_NOAUTH);
|
|
|
|
X(ALLOWS_PROXY);
|
|
|
|
X(ALLOWS_PROXY_HTTP);
|
|
|
|
X(URI_INHERITS_SECURITY_CONTEXT);
|
|
|
|
X(URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT);
|
|
|
|
X(URI_LOADABLE_BY_ANYONE);
|
|
|
|
X(URI_DANGEROUS_TO_LOAD);
|
|
|
|
X(URI_IS_UI_RESOURCE);
|
|
|
|
X(URI_IS_LOCAL_FILE);
|
|
|
|
X(URI_LOADABLE_BY_SUBSUMERS);
|
|
|
|
X(URI_DOES_NOT_RETURN_DATA);
|
|
|
|
X(URI_IS_LOCAL_RESOURCE);
|
|
|
|
X(URI_OPENING_EXECUTES_SCRIPT);
|
|
|
|
X(URI_NON_PERSISTABLE);
|
|
|
|
X(URI_FORBIDS_COOKIE_ACCESS);
|
|
|
|
X(URI_CROSS_ORIGIN_NEEDS_WEBAPPS_PERM);
|
|
|
|
X(URI_SYNC_LOAD_IS_OK);
|
|
|
|
X(URI_SAFE_TO_LOAD_IN_SECURE_CONTEXT);
|
|
|
|
#undef X
|
|
|
|
default:
|
|
|
|
return wine_dbg_sprintf("%08x", flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-23 18:44:42 +01:00
|
|
|
static nsresult NSAPI nsNetUtil_ProtocolHasFlags(nsINetUtil *iface, nsIURI *aURI, UINT32 aFlags, cpp_bool *_retval)
|
2008-12-30 06:48:59 +01:00
|
|
|
{
|
2015-01-26 16:13:31 +01:00
|
|
|
TRACE("(%p %s %p)\n", aURI, debugstr_protocol_flags(aFlags), _retval);
|
2008-12-30 06:48:59 +01:00
|
|
|
|
|
|
|
return nsINetUtil_ProtocolHasFlags(net_util, aURI, aFlags, _retval);
|
|
|
|
}
|
|
|
|
|
2013-01-23 18:44:42 +01:00
|
|
|
static nsresult NSAPI nsNetUtil_URIChainHasFlags(nsINetUtil *iface, nsIURI *aURI, UINT32 aFlags, cpp_bool *_retval)
|
2008-12-30 06:48:59 +01:00
|
|
|
{
|
2015-01-26 16:13:31 +01:00
|
|
|
TRACE("(%p %s %p)\n", aURI, debugstr_protocol_flags(aFlags), _retval);
|
2008-12-30 06:48:59 +01:00
|
|
|
|
2015-01-26 16:13:31 +01:00
|
|
|
if(aFlags == URI_DOES_NOT_RETURN_DATA) {
|
2008-12-30 06:48:59 +01:00
|
|
|
*_retval = FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsINetUtil_URIChainHasFlags(net_util, aURI, aFlags, _retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsNetUtil_ToImmutableURI(nsINetUtil *iface, nsIURI *aURI, nsIURI **_retval)
|
|
|
|
{
|
|
|
|
TRACE("(%p %p)\n", aURI, _retval);
|
|
|
|
|
|
|
|
return nsINetUtil_ToImmutableURI(net_util, aURI, _retval);
|
|
|
|
}
|
|
|
|
|
2010-08-25 14:22:25 +02:00
|
|
|
static nsresult NSAPI nsNetUtil_NewSimpleNestedURI(nsINetUtil *iface, nsIURI *aURI, nsIURI **_retval)
|
|
|
|
{
|
|
|
|
TRACE("(%p %p)\n", aURI, _retval);
|
|
|
|
|
|
|
|
return nsINetUtil_NewSimpleNestedURI(net_util, aURI, _retval);
|
|
|
|
}
|
|
|
|
|
2008-12-30 06:48:59 +01:00
|
|
|
static nsresult NSAPI nsNetUtil_EscapeString(nsINetUtil *iface, const nsACString *aString,
|
2013-01-23 18:44:42 +01:00
|
|
|
UINT32 aEscapeType, nsACString *_retval)
|
2008-12-30 06:48:59 +01:00
|
|
|
{
|
2010-08-03 15:44:56 +02:00
|
|
|
TRACE("(%s %x %p)\n", debugstr_nsacstr(aString), aEscapeType, _retval);
|
2008-12-30 06:48:59 +01:00
|
|
|
|
|
|
|
return nsINetUtil_EscapeString(net_util, aString, aEscapeType, _retval);
|
|
|
|
}
|
|
|
|
|
2013-01-23 18:44:42 +01:00
|
|
|
static nsresult NSAPI nsNetUtil_EscapeURL(nsINetUtil *iface, const nsACString *aStr, UINT32 aFlags,
|
2008-12-30 06:48:59 +01:00
|
|
|
nsACString *_retval)
|
|
|
|
{
|
2010-08-03 15:44:56 +02:00
|
|
|
TRACE("(%s %08x %p)\n", debugstr_nsacstr(aStr), aFlags, _retval);
|
2008-12-30 06:48:59 +01:00
|
|
|
|
|
|
|
return nsINetUtil_EscapeURL(net_util, aStr, aFlags, _retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsNetUtil_UnescapeString(nsINetUtil *iface, const nsACString *aStr,
|
2013-01-23 18:44:42 +01:00
|
|
|
UINT32 aFlags, nsACString *_retval)
|
2008-12-30 06:48:59 +01:00
|
|
|
{
|
2010-08-03 15:44:56 +02:00
|
|
|
TRACE("(%s %08x %p)\n", debugstr_nsacstr(aStr), aFlags, _retval);
|
2008-12-30 06:48:59 +01:00
|
|
|
|
|
|
|
return nsINetUtil_UnescapeString(net_util, aStr, aFlags, _retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsNetUtil_ExtractCharsetFromContentType(nsINetUtil *iface, const nsACString *aTypeHeader,
|
2013-01-18 14:05:15 +01:00
|
|
|
nsACString *aCharset, LONG *aCharsetStart, LONG *aCharsetEnd, cpp_bool *_retval)
|
2008-12-30 06:48:59 +01:00
|
|
|
{
|
2010-08-03 15:44:56 +02:00
|
|
|
TRACE("(%s %p %p %p %p)\n", debugstr_nsacstr(aTypeHeader), aCharset, aCharsetStart,
|
|
|
|
aCharsetEnd, _retval);
|
2008-12-30 06:48:59 +01:00
|
|
|
|
|
|
|
return nsINetUtil_ExtractCharsetFromContentType(net_util, aTypeHeader, aCharset, aCharsetStart, aCharsetEnd, _retval);
|
|
|
|
}
|
|
|
|
|
2008-02-20 21:30:51 +01:00
|
|
|
static const nsINetUtilVtbl nsNetUtilVtbl = {
|
|
|
|
nsNetUtil_QueryInterface,
|
|
|
|
nsNetUtil_AddRef,
|
|
|
|
nsNetUtil_Release,
|
2008-12-30 06:48:59 +01:00
|
|
|
nsNetUtil_ParseContentType,
|
|
|
|
nsNetUtil_ProtocolHasFlags,
|
|
|
|
nsNetUtil_URIChainHasFlags,
|
|
|
|
nsNetUtil_ToImmutableURI,
|
2010-08-25 14:22:25 +02:00
|
|
|
nsNetUtil_NewSimpleNestedURI,
|
2008-12-30 06:48:59 +01:00
|
|
|
nsNetUtil_EscapeString,
|
|
|
|
nsNetUtil_EscapeURL,
|
|
|
|
nsNetUtil_UnescapeString,
|
|
|
|
nsNetUtil_ExtractCharsetFromContentType
|
2008-02-20 21:30:51 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static nsINetUtil nsNetUtil = { &nsNetUtilVtbl };
|
|
|
|
|
|
|
|
static nsresult NSAPI nsIOService_QueryInterface(nsIIOService *iface, nsIIDRef riid,
|
2010-08-02 11:08:26 +02:00
|
|
|
void **result)
|
2008-02-20 21:30:51 +01:00
|
|
|
{
|
|
|
|
*result = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_nsISupports, riid))
|
|
|
|
*result = &nsIOService;
|
|
|
|
else if(IsEqualGUID(&IID_nsIIOService, riid))
|
|
|
|
*result = &nsIOService;
|
|
|
|
else if(IsEqualGUID(&IID_nsINetUtil, riid))
|
|
|
|
*result = &nsNetUtil;
|
|
|
|
|
|
|
|
if(*result) {
|
|
|
|
nsISupports_AddRef((nsISupports*)*result);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("(%s %p)\n", debugstr_guid(riid), result);
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2006-02-09 12:17:08 +01:00
|
|
|
static nsresult NSAPI nsIOServiceFactory_QueryInterface(nsIFactory *iface, nsIIDRef riid,
|
2010-08-02 11:08:26 +02:00
|
|
|
void **result)
|
2006-02-09 12:17:08 +01:00
|
|
|
{
|
|
|
|
*result = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_nsISupports, riid)) {
|
2008-01-16 12:20:50 +01:00
|
|
|
TRACE("(IID_nsISupports %p)\n", result);
|
2006-02-09 12:17:08 +01:00
|
|
|
*result = iface;
|
|
|
|
}else if(IsEqualGUID(&IID_nsIFactory, riid)) {
|
|
|
|
TRACE("(IID_nsIFactory %p)\n", result);
|
|
|
|
*result = iface;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*result) {
|
|
|
|
nsIFactory_AddRef(iface);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("(%s %p)\n", debugstr_guid(riid), result);
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsIOServiceFactory_AddRef(nsIFactory *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsIOServiceFactory_Release(nsIFactory *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsIOServiceFactory_CreateInstance(nsIFactory *iface,
|
|
|
|
nsISupports *aOuter, const nsIID *iid, void **result)
|
|
|
|
{
|
|
|
|
return nsIIOService_QueryInterface(&nsIOService, iid, result);
|
|
|
|
}
|
|
|
|
|
2012-03-15 11:54:33 +01:00
|
|
|
static nsresult NSAPI nsIOServiceFactory_LockFactory(nsIFactory *iface, cpp_bool lock)
|
2006-02-09 12:17:08 +01:00
|
|
|
{
|
|
|
|
WARN("(%x)\n", lock);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const nsIFactoryVtbl nsIOServiceFactoryVtbl = {
|
|
|
|
nsIOServiceFactory_QueryInterface,
|
|
|
|
nsIOServiceFactory_AddRef,
|
|
|
|
nsIOServiceFactory_Release,
|
|
|
|
nsIOServiceFactory_CreateInstance,
|
|
|
|
nsIOServiceFactory_LockFactory
|
|
|
|
};
|
|
|
|
|
|
|
|
static nsIFactory nsIOServiceFactory = { &nsIOServiceFactoryVtbl };
|
|
|
|
|
2010-12-04 14:19:54 +01:00
|
|
|
static BOOL translate_url(HTMLDocumentObj *doc, nsWineURI *uri)
|
|
|
|
{
|
|
|
|
OLECHAR *new_url = NULL;
|
|
|
|
WCHAR *url;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(!doc->hostui || !ensure_uri(uri))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
hres = IUri_GetDisplayUri(uri->uri, &url);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
hres = IDocHostUIHandler_TranslateUrl(doc->hostui, 0, url, &new_url);
|
|
|
|
if(hres == S_OK && new_url) {
|
|
|
|
if(strcmpW(url, new_url)) {
|
|
|
|
FIXME("TranslateUrl returned new URL %s -> %s\n", debugstr_w(url), debugstr_w(new_url));
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
CoTaskMemFree(new_url);
|
|
|
|
}
|
|
|
|
|
|
|
|
SysFreeString(url);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-03-15 11:54:33 +01:00
|
|
|
nsresult on_start_uri_open(NSContainer *nscontainer, nsIURI *uri, cpp_bool *_retval)
|
2010-12-04 14:19:54 +01:00
|
|
|
{
|
|
|
|
nsWineURI *wine_uri;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
*_retval = FALSE;
|
|
|
|
|
|
|
|
nsres = nsIURI_QueryInterface(uri, &IID_nsWineURI, (void**)&wine_uri);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
WARN("Could not get nsWineURI: %08x\n", nsres);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!wine_uri->is_doc_uri) {
|
|
|
|
wine_uri->is_doc_uri = TRUE;
|
|
|
|
|
|
|
|
if(!wine_uri->container) {
|
2010-12-27 23:27:55 +01:00
|
|
|
nsIWebBrowserChrome_AddRef(&nscontainer->nsIWebBrowserChrome_iface);
|
2010-12-04 14:19:54 +01:00
|
|
|
wine_uri->container = nscontainer;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(nscontainer->doc)
|
|
|
|
*_retval = translate_url(nscontainer->doc, wine_uri);
|
|
|
|
}
|
|
|
|
|
2012-07-26 11:37:48 +02:00
|
|
|
nsIFileURL_Release(&wine_uri->nsIFileURL_iface);
|
2010-12-04 14:19:54 +01:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-02-09 12:17:08 +01:00
|
|
|
void init_nsio(nsIComponentManager *component_manager, nsIComponentRegistrar *registrar)
|
|
|
|
{
|
|
|
|
nsIFactory *old_factory = NULL;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = nsIComponentManager_GetClassObject(component_manager, &NS_IOSERVICE_CID,
|
|
|
|
&IID_nsIFactory, (void**)&old_factory);
|
|
|
|
if(NS_FAILED(nsres)) {
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("Could not get factory: %08x\n", nsres);
|
2006-02-09 12:17:08 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIFactory_CreateInstance(old_factory, NULL, &IID_nsIIOService, (void**)&nsio);
|
|
|
|
if(NS_FAILED(nsres)) {
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("Couldn not create nsIOService instance %08x\n", nsres);
|
2006-02-09 12:17:08 +01:00
|
|
|
nsIFactory_Release(old_factory);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-12-18 14:08:13 +01:00
|
|
|
nsres = nsIIOService_QueryInterface(nsio, &IID_nsINetUtil, (void**)&net_util);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
WARN("Could not get nsINetUtil interface: %08x\n", nsres);
|
|
|
|
nsIIOService_Release(nsio);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-02-09 12:17:08 +01:00
|
|
|
nsres = nsIComponentRegistrar_UnregisterFactory(registrar, &NS_IOSERVICE_CID, old_factory);
|
|
|
|
nsIFactory_Release(old_factory);
|
|
|
|
if(NS_FAILED(nsres))
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("UnregisterFactory failed: %08x\n", nsres);
|
2006-02-09 12:17:08 +01:00
|
|
|
|
|
|
|
nsres = nsIComponentRegistrar_RegisterFactory(registrar, &NS_IOSERVICE_CID,
|
|
|
|
NS_IOSERVICE_CLASSNAME, NS_IOSERVICE_CONTRACTID, &nsIOServiceFactory);
|
|
|
|
if(NS_FAILED(nsres))
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("RegisterFactory failed: %08x\n", nsres);
|
2006-02-09 12:17:08 +01:00
|
|
|
}
|
2008-12-18 14:08:13 +01:00
|
|
|
|
|
|
|
void release_nsio(void)
|
|
|
|
{
|
|
|
|
if(net_util) {
|
|
|
|
nsINetUtil_Release(net_util);
|
|
|
|
net_util = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(nsio) {
|
|
|
|
nsIIOService_Release(nsio);
|
|
|
|
nsio = NULL;
|
|
|
|
}
|
|
|
|
}
|