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 {
|
2011-01-05 00:39:25 +01:00
|
|
|
nsIURL nsIURL_iface;
|
2011-11-18 12:21:47 +01:00
|
|
|
nsIStandardURL nsIStandardURL_iface;
|
2006-02-09 12:18:18 +01:00
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
2010-09-28 13:24:57 +02:00
|
|
|
nsIURI *nsuri;
|
2009-08-27 11:31:14 +02:00
|
|
|
nsIURL *nsurl;
|
2006-02-09 12:18:18 +01:00
|
|
|
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;
|
2010-03-03 14:54:10 +01:00
|
|
|
BOOL is_doc_uri;
|
2011-11-23 16:19:42 +01:00
|
|
|
BOOL is_mutable;
|
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;
|
|
|
|
}
|
|
|
|
|
2011-11-15 13:31:12 +01:00
|
|
|
static IUri *get_uri_nofrag(IUri *uri)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-11-15 13:30:28 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-06-25 19:03:19 +02:00
|
|
|
static nsresult create_nsuri(IUri*,nsIURI*,HTMLWindow*,NSContainer*,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);
|
|
|
|
}
|
|
|
|
|
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-03-01 22:04:51 +01:00
|
|
|
DWORD hlnf = 0;
|
2006-02-13 13:26:00 +01:00
|
|
|
HRESULT hres;
|
|
|
|
|
2006-03-01 22:04:51 +01:00
|
|
|
if(!doc) {
|
|
|
|
NSContainer *container_iter = container;
|
|
|
|
|
|
|
|
hlnf = HLNF_OPENINNEWWINDOW;
|
|
|
|
while(!container_iter->doc)
|
|
|
|
container_iter = container_iter->parent;
|
|
|
|
doc = container_iter->doc;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2011-06-23 13:45:34 +02:00
|
|
|
if(!hlnf) {
|
|
|
|
BOOL b;
|
|
|
|
|
|
|
|
b = !exec_shldocvw_67(doc, display_uri);
|
|
|
|
if(b) {
|
2011-06-25 19:03:38 +02:00
|
|
|
SysFreeString(display_uri);
|
2011-06-23 13:45:34 +02:00
|
|
|
*cancel = FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-25 19:03:38 +02:00
|
|
|
hres = hlink_frame_navigate(&doc->basedoc, display_uri, channel, hlnf, cancel);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-02-21 21:06:51 +01:00
|
|
|
HRESULT load_nsuri(HTMLWindow *window, nsWineURI *uri, nsChannelBSC *channelbsc, DWORD flags)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
uri->channel_bsc = channelbsc;
|
2010-08-18 13:39:04 +02:00
|
|
|
doc = window->doc;
|
|
|
|
doc->skip_mutation_notif = TRUE;
|
2011-01-05 00:39:25 +01:00
|
|
|
nsres = nsIDocShell_LoadURI(doc_shell, (nsIURI*)&uri->nsIURL_iface, NULL, flags, FALSE);
|
2010-08-18 13:39:04 +02:00
|
|
|
if(doc == window->doc)
|
|
|
|
doc->skip_mutation_notif = FALSE;
|
2010-02-21 21:06:51 +01:00
|
|
|
uri->channel_bsc = NULL;
|
|
|
|
nsIDocShell_Release(doc_shell);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-02-21 21:08:39 +01:00
|
|
|
static void set_uri_window(nsWineURI *This, HTMLWindow *window)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
2010-03-19 21:57:26 +01:00
|
|
|
return This->url_scheme == URL_SCHEME_HTTP || This->url_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) {
|
|
|
|
if(!strcmpiW(iter->header, name))
|
|
|
|
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) {
|
2010-12-30 01:43:11 +01:00
|
|
|
nsIChannel_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) {
|
2011-01-05 00:39:25 +01:00
|
|
|
nsIURI_Release(&This->uri->nsIURL_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
|
|
|
|
2011-01-05 00:39:25 +01:00
|
|
|
return nsIURI_GetSpec(&This->uri->nsIURL_iface, aName);
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_IsPending(nsIHttpChannel *iface, PRBool *_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
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2010-01-04 00:38:20 +01:00
|
|
|
FIXME("(%p)->(%08x)\n", This, aStatus);
|
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_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);
|
|
|
|
|
2011-01-05 00:39:25 +01:00
|
|
|
nsIURI_AddRef(&This->uri->nsIURL_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;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetContentLength(nsIHttpChannel *iface, PRInt32 *aContentLength)
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetContentLength(nsIHttpChannel *iface, PRInt32 aContentLength)
|
|
|
|
{
|
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)->(%d)\n", This, 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
|
|
|
}
|
|
|
|
|
2009-10-26 23:03:29 +01:00
|
|
|
static HTMLWindow *get_window_from_load_group(nsChannel *This)
|
2008-03-08 20:15:30 +01:00
|
|
|
{
|
2009-10-26 23:03:29 +01:00
|
|
|
HTMLWindow *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)
|
2010-12-27 12:50:32 +01:00
|
|
|
IHTMLWindow2_AddRef(&window->IHTMLWindow2_iface);
|
2011-01-05 00:39:25 +01:00
|
|
|
nsIURI_Release(&wine_uri->nsIURL_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
|
|
|
}
|
|
|
|
|
2009-10-26 23:02:50 +01:00
|
|
|
static HTMLWindow *get_channel_window(nsChannel *This)
|
|
|
|
{
|
|
|
|
nsIWebProgress *web_progress;
|
|
|
|
nsIDOMWindow *nswindow;
|
|
|
|
HTMLWindow *window;
|
|
|
|
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)
|
2010-12-27 12:50:32 +01:00
|
|
|
IHTMLWindow2_AddRef(&window->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;
|
2009-10-26 23:05:37 +01:00
|
|
|
HTMLDocumentNode *doc;
|
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;
|
|
|
|
|
2009-10-26 23:05:37 +01:00
|
|
|
start_binding(NULL, task->doc, (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
|
|
|
}
|
|
|
|
|
2009-10-26 23:03:29 +01:00
|
|
|
static nsresult async_open(nsChannel *This, HTMLWindow *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)
|
2009-10-26 23:04:28 +01:00
|
|
|
set_current_mon(window, mon);
|
2009-10-26 23:03:29 +01:00
|
|
|
|
2010-03-03 14:53:49 +01:00
|
|
|
hres = create_channelbsc(mon, NULL, NULL, 0, &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) {
|
|
|
|
set_window_bscallback(window, bscallback);
|
2010-03-03 14:53:32 +01:00
|
|
|
async_start_doc_binding(window, bscallback);
|
|
|
|
IUnknown_Release((IUnknown*)bscallback);
|
2009-10-26 23:05:37 +01:00
|
|
|
}else {
|
|
|
|
start_binding_task_t *task = heap_alloc(sizeof(start_binding_task_t));
|
|
|
|
|
|
|
|
task->doc = window->doc;
|
|
|
|
task->bscallback = bscallback;
|
2011-08-03 12:36:26 +02:00
|
|
|
push_task(&task->header, start_binding_proc, start_binding_task_destr, window->doc->basedoc.task_magic);
|
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);
|
2009-10-26 23:03:29 +01:00
|
|
|
HTMLWindow *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)) {
|
|
|
|
BSTR uri_str;
|
|
|
|
IUri_GetDisplayUri(This->uri->uri, &uri_str);
|
|
|
|
TRACE("opening %s\n", debugstr_w(uri_str));
|
|
|
|
SysFreeString(uri_str);
|
|
|
|
}
|
|
|
|
|
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;
|
2010-12-27 12:50:32 +01:00
|
|
|
IHTMLWindow2_AddRef(&window->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);
|
|
|
|
}
|
|
|
|
|
2010-12-27 12:50:32 +01:00
|
|
|
IHTMLWindow2_Release(&window->IHTMLWindow2_iface);
|
2007-11-02 19:53:02 +01:00
|
|
|
return nsres;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
const nsACString *aHeader, const nsACString *aValue, PRBool aMerge)
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetAllowPipelining(nsIHttpChannel *iface, PRBool *aAllowPipelining)
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetAllowPipelining(nsIHttpChannel *iface, PRBool aAllowPipelining)
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetRedirectionLimit(nsIHttpChannel *iface, PRUint32 *aRedirectionLimit)
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetRedirectionLimit(nsIHttpChannel *iface, PRUint32 aRedirectionLimit)
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetResponseStatus(nsIHttpChannel *iface, PRUint32 *aResponseStatus)
|
|
|
|
{
|
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
|
|
|
|
2009-12-21 00:23:02 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, aResponseStatusText);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetRequestSucceeded(nsIHttpChannel *iface,
|
|
|
|
PRBool *aRequestSucceeded)
|
|
|
|
{
|
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,
|
|
|
|
const nsACString *header, const nsACString *value, PRBool merge)
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_IsNoStoreResponse(nsIHttpChannel *iface, PRBool *_retval)
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_IsNoCacheResponse(nsIHttpChannel *iface, PRBool *_retval)
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
nsChannel_GetRequestMethod,
|
|
|
|
nsChannel_SetRequestMethod,
|
|
|
|
nsChannel_GetReferrer,
|
|
|
|
nsChannel_SetReferrer,
|
|
|
|
nsChannel_GetRequestHeader,
|
|
|
|
nsChannel_SetRequestHeader,
|
|
|
|
nsChannel_VisitRequestHeaders,
|
|
|
|
nsChannel_GetAllowPipelining,
|
|
|
|
nsChannel_SetAllowPipelining,
|
|
|
|
nsChannel_GetRedirectionLimit,
|
|
|
|
nsChannel_SetRedirectionLimit,
|
|
|
|
nsChannel_GetResponseStatus,
|
|
|
|
nsChannel_GetResponseStatusText,
|
|
|
|
nsChannel_GetRequestSucceeded,
|
|
|
|
nsChannel_GetResponseHeader,
|
|
|
|
nsChannel_SetResponseHeader,
|
|
|
|
nsChannel_VisitResponseHeaders,
|
|
|
|
nsChannel_IsNoStoreResponse,
|
|
|
|
nsChannel_IsNoCacheResponse
|
|
|
|
};
|
|
|
|
|
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);
|
2010-12-30 01:43:11 +01:00
|
|
|
return nsIChannel_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);
|
2010-12-30 01:43:11 +01:00
|
|
|
return nsIChannel_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);
|
2010-12-30 01:43:11 +01:00
|
|
|
return nsIChannel_Release(&This->nsIHttpChannel_iface);
|
2006-02-10 14:49:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsUploadChannel_SetUploadStream(nsIUploadChannel *iface,
|
|
|
|
nsIInputStream *aStream, const nsACString *aContentType, PRInt32 aContentLength)
|
|
|
|
{
|
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
|
|
|
|
2010-08-03 21:40:56 +02:00
|
|
|
TRACE("(%p)->(%p %s %d)\n", This, aStream, debugstr_nsacstr(aContentType), 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
|
|
|
}
|
|
|
|
|
2010-08-03 21:40:56 +02:00
|
|
|
if(This->post_data_stream)
|
|
|
|
nsIInputStream_Release(This->post_data_stream);
|
|
|
|
|
2006-02-10 14:49:41 +01:00
|
|
|
if(aContentLength != -1)
|
2006-10-05 23:50:39 +02:00
|
|
|
FIXME("Unsupported acontentLength = %d\n", 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);
|
2010-12-30 01:43:11 +01:00
|
|
|
return nsIChannel_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);
|
2010-12-30 01:43:11 +01:00
|
|
|
return nsIChannel_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);
|
2010-12-30 01:43:11 +01:00
|
|
|
return nsIChannel_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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetRequestVersion(nsIHttpChannelInternal *iface, PRUint32 *major, PRUint32 *minor)
|
|
|
|
{
|
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_GetResponseVersion(nsIHttpChannelInternal *iface, PRUint32 *major, PRUint32 *minor)
|
|
|
|
{
|
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_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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetForceAllowThirdPartyCookie(nsIHttpChannelInternal *iface, PRBool *aForceThirdPartyCookie)
|
|
|
|
{
|
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_SetForceAllowThirdPartyCookie(nsIHttpChannelInternal *iface, PRBool aForceThirdPartyCookie)
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2010-08-25 14:22:25 +02:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetCanceled(nsIHttpChannelInternal *iface, PRBool *aCanceled)
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2011-03-15 13:45:29 +01:00
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetChannelIsForDownload(nsIHttpChannelInternal *iface, PRBool *aCanceled)
|
|
|
|
{
|
|
|
|
nsChannel *This = impl_from_nsIHttpChannelInternal(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p)\n", This, aCanceled);
|
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_SetChannelIsForDownload(nsIHttpChannelInternal *iface, PRBool aCanceled)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetLocalPort(nsIHttpChannelInternal *iface, PRInt32 *aLocalPort)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetRemotePort(nsIHttpChannelInternal *iface, PRInt32 *aRemotePort)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
nsHttpChannelInternal_SetCookie,
|
|
|
|
nsHttpChannelInternal_SetupFallbackChannel,
|
|
|
|
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,
|
|
|
|
nsHttpChannelInternal_SetCacheKeysRedirectChain
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
vala = heap_strdupWtoA(val);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-01-05 00:39:25 +01:00
|
|
|
static inline nsWineURI *impl_from_nsIURL(nsIURL *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, nsWineURI, nsIURL_iface);
|
|
|
|
}
|
2006-02-13 13:26:00 +01:00
|
|
|
|
2010-08-02 11:08:26 +02:00
|
|
|
static nsresult NSAPI nsURI_QueryInterface(nsIURL *iface, nsIIDRef riid, void **result)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(iface);
|
2006-02-09 12:18:18 +01:00
|
|
|
|
|
|
|
*result = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_nsISupports, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsISupports %p)\n", This, result);
|
2011-01-05 00:39:25 +01:00
|
|
|
*result = &This->nsIURL_iface;
|
2006-02-09 12:18:18 +01:00
|
|
|
}else if(IsEqualGUID(&IID_nsIURI, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIURI %p)\n", This, result);
|
2011-01-05 00:39:25 +01:00
|
|
|
*result = &This->nsIURL_iface;
|
2009-08-27 11:31:14 +02:00
|
|
|
}else if(IsEqualGUID(&IID_nsIURL, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIURL %p)\n", This, result);
|
2011-01-05 00:39:25 +01:00
|
|
|
*result = &This->nsIURL_iface;
|
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) {
|
2011-01-05 00:39:25 +01:00
|
|
|
nsIURI_AddRef(&This->nsIURL_iface);
|
2006-02-09 12:18:18 +01:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), result);
|
2010-09-28 13:24:57 +02:00
|
|
|
return This->nsuri ? nsIURI_QueryInterface(This->nsuri, riid, result) : NS_NOINTERFACE;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsrefcnt NSAPI nsURI_AddRef(nsIURL *iface)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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;
|
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsrefcnt NSAPI nsURI_Release(nsIURL *iface)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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);
|
2009-08-27 11:31:14 +02:00
|
|
|
if(This->nsurl)
|
|
|
|
nsIURL_Release(This->nsurl);
|
2010-09-28 13:24:57 +02:00
|
|
|
if(This->nsuri)
|
|
|
|
nsIURI_Release(This->nsuri);
|
2010-09-28 13:25:24 +02:00
|
|
|
if(This->uri)
|
|
|
|
IUri_Release(This->uri);
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(This);
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_GetSpec(nsIURL *iface, nsACString *aSpec)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_SetSpec(nsIURL *iface, const nsACString *aSpec)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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);
|
|
|
|
spec = heap_strdupAtoW(speca);
|
|
|
|
if(!spec)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-02-03 20:47:58 +01:00
|
|
|
hres = CreateUri(spec, 0, 0, &uri);
|
|
|
|
heap_free(spec);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("CreateUri failed: %08x\n", hres);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_GetPrePath(nsIURL *iface, nsACString *aPrePath)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(iface);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2006-02-09 12:18:18 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aPrePath);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2010-09-28 13:24:57 +02:00
|
|
|
if(This->nsuri)
|
|
|
|
return nsIURI_GetPrePath(This->nsuri, aPrePath);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_GetScheme(nsIURL *iface, nsACString *aScheme)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_SetScheme(nsIURL *iface, const nsACString *aScheme)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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);
|
|
|
|
scheme = heap_strdupAtoW(schemea);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_GetUserPass(nsIURL *iface, nsACString *aUserPass)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_SetUserPass(nsIURL *iface, const nsACString *aUserPass)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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;
|
|
|
|
|
|
|
|
buf = heap_strdupAtoW(user_pass);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_GetUsername(nsIURL *iface, nsACString *aUsername)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_SetUsername(nsIURL *iface, const nsACString *aUsername)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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);
|
|
|
|
user = heap_strdupAtoW(usera);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_GetPassword(nsIURL *iface, nsACString *aPassword)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_SetPassword(nsIURL *iface, const nsACString *aPassword)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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);
|
|
|
|
pass = heap_strdupAtoW(passa);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_GetHostPort(nsIURL *iface, nsACString *aHostPort)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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;
|
|
|
|
|
|
|
|
vala = heap_strdupWtoA(ptr);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_SetHostPort(nsIURL *iface, const nsACString *aHostPort)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_GetHost(nsIURL *iface, nsACString *aHost)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_SetHost(nsIURL *iface, const nsACString *aHost)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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);
|
|
|
|
host = heap_strdupAtoW(hosta);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_GetPort(nsIURL *iface, PRInt32 *aPort)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_SetPort(nsIURL *iface, PRInt32 aPort)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_GetPath(nsIURL *iface, nsACString *aPath)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_SetPath(nsIURL *iface, const nsACString *aPath)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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);
|
|
|
|
path = heap_strdupAtoW(patha);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_Equals(nsIURL *iface, nsIURI *other, PRBool *_retval)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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
|
|
|
|
2011-01-05 00:39:25 +01:00
|
|
|
nsIURI_Release(&other_obj->nsIURL_iface);
|
2010-10-21 15:50:27 +02:00
|
|
|
return nsres;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_SchemeIs(nsIURL *iface, const char *scheme, PRBool *_retval)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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
|
|
|
|
2010-11-25 13:56:25 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, scheme, -1, buf, sizeof(buf)/sizeof(WCHAR));
|
|
|
|
*_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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_Clone(nsIURL *iface, nsIURI **_retval)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(iface);
|
2008-02-28 12:41:22 +01:00
|
|
|
nsIURI *nsuri = NULL;
|
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;
|
|
|
|
|
2010-09-28 13:24:57 +02:00
|
|
|
if(This->nsuri) {
|
|
|
|
nsres = nsIURI_Clone(This->nsuri, &nsuri);
|
2006-07-07 15:17:27 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
2006-10-05 23:50:39 +02:00
|
|
|
WARN("Clone failed: %08x\n", nsres);
|
2006-07-07 15:17:27 +02:00
|
|
|
return nsres;
|
|
|
|
}
|
2008-02-28 12:41:22 +01:00
|
|
|
}
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2011-06-25 19:03:19 +02:00
|
|
|
nsres = create_nsuri(This->uri, nsuri, This->window_ref ? This->window_ref->window : NULL, This->container, &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
|
|
|
}
|
|
|
|
|
2011-01-05 00:39:25 +01:00
|
|
|
*_retval = (nsIURI*)&wine_uri->nsIURL_iface;
|
2010-02-21 21:07:43 +01:00
|
|
|
return NS_OK;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2010-08-18 13:37:32 +02:00
|
|
|
static nsresult NSAPI nsURI_Resolve(nsIURL *iface, const nsACString *aRelativePath,
|
2006-02-09 12:18:18 +01:00
|
|
|
nsACString *_retval)
|
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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);
|
|
|
|
path = heap_strdupAtoW(patha);
|
|
|
|
if(!path)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
2011-01-03 23:48:29 +01:00
|
|
|
hres = CoInternetCombineUrlEx(This->uri, path, URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO, &new_uri, 0);
|
2010-08-18 13:37:32 +02:00
|
|
|
heap_free(path);
|
|
|
|
if(FAILED(hres)) {
|
2011-01-03 23:48:29 +01:00
|
|
|
ERR("CoIntenetCombineUrlEx failed: %08x\n", 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;
|
|
|
|
|
|
|
|
reta = heap_strdupWtoA(ret);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_GetAsciiSpec(nsIURL *iface, nsACString *aAsciiSpec)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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
|
|
|
|
2011-01-05 00:39:25 +01:00
|
|
|
return nsIURI_GetSpec(&This->nsIURL_iface, aAsciiSpec);
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_GetAsciiHost(nsIURL *iface, nsACString *aAsciiHost)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURI_GetOriginCharset(nsIURL *iface, nsACString *aOriginCharset)
|
2006-02-09 12:18:18 +01:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(iface);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2006-02-09 12:18:18 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, aOriginCharset);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
2010-09-28 13:24:57 +02:00
|
|
|
if(This->nsuri)
|
|
|
|
return nsIURI_GetOriginCharset(This->nsuri, aOriginCharset);
|
2006-07-07 15:17:27 +02:00
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 12:18:18 +01:00
|
|
|
}
|
|
|
|
|
2011-12-29 13:49:36 +01:00
|
|
|
static nsresult NSAPI nsURL_GetRef(nsIURL *iface, nsACString *aRef)
|
|
|
|
{
|
|
|
|
nsWineURI *This = impl_from_nsIURL(iface);
|
|
|
|
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;
|
|
|
|
|
|
|
|
refa = heap_strdupWtoA(ref);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsURL_SetRef(nsIURL *iface, const nsACString *aRef)
|
|
|
|
{
|
|
|
|
nsWineURI *This = impl_from_nsIURL(iface);
|
|
|
|
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);
|
|
|
|
ref = heap_strdupAtoW(refa);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-11-15 13:31:22 +01:00
|
|
|
static nsresult NSAPI nsURI_EqualsExceptRef(nsIURL *iface, nsIURI *other, PRBool *_retval)
|
|
|
|
{
|
|
|
|
nsWineURI *This = impl_from_nsIURL(iface);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIURI_Release(&other_obj->nsIURL_iface);
|
|
|
|
return nsres;
|
|
|
|
}
|
|
|
|
|
2011-11-15 13:31:12 +01:00
|
|
|
static nsresult NSAPI nsURI_CloneIgnoreRef(nsIURL *iface, nsIURI **_retval)
|
|
|
|
{
|
|
|
|
nsWineURI *This = impl_from_nsIURL(iface);
|
|
|
|
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;
|
|
|
|
|
|
|
|
nsres = create_nsuri(uri, NULL, This->window_ref ? This->window_ref->window : NULL, This->container, &wine_uri);
|
|
|
|
IUri_Release(uri);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
WARN("create_nsuri failed: %08x\n", nsres);
|
|
|
|
return nsres;
|
|
|
|
}
|
|
|
|
|
|
|
|
*_retval = (nsIURI*)&wine_uri->nsIURL_iface;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-11-09 18:11:42 +01:00
|
|
|
static nsresult NSAPI nsURI_GetSpecIgnoringRef(nsIURL *iface, nsACString *aSpecIgnoringRef)
|
|
|
|
{
|
|
|
|
nsWineURI *This = impl_from_nsIURL(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p)\n", This, aSpecIgnoringRef);
|
|
|
|
|
|
|
|
return nsIURL_GetSpec(&This->nsIURL_iface, aSpecIgnoringRef);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsURI_GetHasRef(nsIURL *iface, PRBool *aHasRef)
|
|
|
|
{
|
|
|
|
nsWineURI *This = impl_from_nsIURL(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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURL_GetFilePath(nsIURL *iface, nsACString *aFilePath)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(iface);
|
2009-08-27 11:31:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aFilePath);
|
|
|
|
|
2011-01-20 12:21:20 +01:00
|
|
|
return nsIURL_GetPath(&This->nsIURL_iface, aFilePath);
|
2009-08-27 11:31:14 +02:00
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURL_SetFilePath(nsIURL *iface, const nsACString *aFilePath)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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;
|
|
|
|
|
2011-01-20 12:21:20 +01:00
|
|
|
return nsIURL_SetPath(&This->nsIURL_iface, aFilePath);
|
2009-08-27 11:31:14 +02:00
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURL_GetParam(nsIURL *iface, nsACString *aParam)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(iface);
|
2009-08-27 11:31:14 +02:00
|
|
|
|
2011-11-08 16:17:31 +01:00
|
|
|
WARN("(%p)->(%p)\n", This, aParam);
|
2009-08-27 11:31:14 +02:00
|
|
|
|
2011-11-08 16:17:31 +01:00
|
|
|
/* This is a leftover of ';' special handling in URLs. It will be removed from Gecko soon */
|
|
|
|
nsACString_SetData(aParam, "");
|
|
|
|
return NS_OK;
|
2009-08-27 11:31:14 +02:00
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURL_SetParam(nsIURL *iface, const nsACString *aParam)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(iface);
|
2009-08-27 11:31:14 +02:00
|
|
|
|
2011-02-03 13:07:57 +01:00
|
|
|
WARN("(%p)->(%s)\n", This, debugstr_nsacstr(aParam));
|
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;
|
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURL_GetQuery(nsIURL *iface, nsACString *aQuery)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(iface);
|
2009-08-27 11:31:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aQuery);
|
|
|
|
|
2010-09-29 12:45:39 +02:00
|
|
|
return get_uri_string(This, Uri_PROPERTY_QUERY, aQuery);
|
2009-08-27 11:31:14 +02:00
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURL_SetQuery(nsIURL *iface, const nsACString *aQuery)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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);
|
|
|
|
query = heap_strdupAtoW(querya);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURL_GetDirectory(nsIURL *iface, nsACString *aDirectory)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(iface);
|
2011-08-03 12:33:32 +02:00
|
|
|
char *dir = NULL;
|
|
|
|
WCHAR *ptr;
|
|
|
|
BSTR path;
|
|
|
|
HRESULT hres;
|
2009-08-27 11:31:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aDirectory);
|
|
|
|
|
2011-08-03 12:33:32 +02:00
|
|
|
if(!ensure_uri(This))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2009-08-27 11:31:14 +02:00
|
|
|
|
2011-08-03 12:33:32 +02:00
|
|
|
hres = IUri_GetPath(This->uri, &path);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
ptr = strrchrW(path, '/');
|
|
|
|
if(ptr) {
|
|
|
|
if(ptr[1])
|
|
|
|
*ptr = 0;
|
|
|
|
dir = heap_strdupWtoA(path);
|
|
|
|
if(!dir) {
|
|
|
|
SysFreeString(path);
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SysFreeString(path);
|
|
|
|
TRACE("ret %s\n", debugstr_a(dir));
|
|
|
|
nsACString_SetData(aDirectory, dir ? dir : "");
|
2011-11-10 14:35:59 +01:00
|
|
|
heap_free(dir);
|
2011-08-03 12:33:32 +02:00
|
|
|
return NS_OK;
|
2009-08-27 11:31:14 +02:00
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURL_SetDirectory(nsIURL *iface, const nsACString *aDirectory)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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;
|
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURL_GetFileName(nsIURL *iface, nsACString *aFileName)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(iface);
|
2009-08-27 11:31:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aFileName);
|
|
|
|
|
|
|
|
if(This->nsurl)
|
|
|
|
return nsIURL_GetFileName(This->nsurl, aFileName);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURL_SetFileName(nsIURL *iface, const nsACString *aFileName)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(iface);
|
2009-08-27 11:31:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aFileName));
|
|
|
|
|
2011-11-23 16:19:42 +01:00
|
|
|
if(!This->is_mutable)
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
2010-09-28 13:25:24 +02:00
|
|
|
if(This->nsurl) {
|
|
|
|
invalidate_uri(This);
|
2009-08-27 11:31:14 +02:00
|
|
|
return nsIURL_SetFileName(This->nsurl, aFileName);
|
2010-09-28 13:25:24 +02:00
|
|
|
}
|
2009-08-27 11:31:14 +02:00
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURL_GetFileBaseName(nsIURL *iface, nsACString *aFileBaseName)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(iface);
|
2009-08-27 11:31:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aFileBaseName);
|
|
|
|
|
|
|
|
if(This->nsurl)
|
|
|
|
return nsIURL_GetFileBaseName(This->nsurl, aFileBaseName);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURL_SetFileBaseName(nsIURL *iface, const nsACString *aFileBaseName)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(iface);
|
2009-08-27 11:31:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aFileBaseName));
|
|
|
|
|
2011-11-23 16:19:42 +01:00
|
|
|
if(!This->is_mutable)
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
2010-09-28 13:25:24 +02:00
|
|
|
if(This->nsurl) {
|
|
|
|
invalidate_uri(This);
|
2009-08-27 11:31:14 +02:00
|
|
|
return nsIURL_SetFileBaseName(This->nsurl, aFileBaseName);
|
2010-09-28 13:25:24 +02:00
|
|
|
}
|
2009-08-27 11:31:14 +02:00
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURL_GetFileExtension(nsIURL *iface, nsACString *aFileExtension)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(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
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURL_SetFileExtension(nsIURL *iface, const nsACString *aFileExtension)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(iface);
|
2009-08-27 11:31:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aFileExtension));
|
|
|
|
|
2011-11-23 16:19:42 +01:00
|
|
|
if(!This->is_mutable)
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
2010-09-28 13:25:24 +02:00
|
|
|
if(This->nsurl) {
|
|
|
|
invalidate_uri(This);
|
2009-08-27 11:31:14 +02:00
|
|
|
return nsIURL_SetFileExtension(This->nsurl, aFileExtension);
|
2010-09-28 13:25:24 +02:00
|
|
|
}
|
2009-08-27 11:31:14 +02:00
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURL_GetCommonBaseSpec(nsIURL *iface, nsIURI *aURIToCompare, nsACString *_retval)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(iface);
|
2009-08-27 11:31:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p)\n", This, aURIToCompare, _retval);
|
|
|
|
|
|
|
|
if(This->nsurl)
|
|
|
|
return nsIURL_GetCommonBaseSpec(This->nsurl, aURIToCompare, _retval);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static nsresult NSAPI nsURL_GetRelativeSpec(nsIURL *iface, nsIURI *aURIToCompare, nsACString *_retval)
|
2009-08-27 11:31:14 +02:00
|
|
|
{
|
2011-01-05 00:39:25 +01:00
|
|
|
nsWineURI *This = impl_from_nsIURL(iface);
|
2009-08-27 11:31:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p)\n", This, aURIToCompare, _retval);
|
|
|
|
|
|
|
|
if(This->nsurl)
|
|
|
|
return nsIURL_GetRelativeSpec(This->nsurl, aURIToCompare, _retval);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
static const nsIURLVtbl nsURLVtbl = {
|
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_GetParam,
|
|
|
|
nsURL_SetParam,
|
|
|
|
nsURL_GetQuery,
|
|
|
|
nsURL_SetQuery,
|
|
|
|
nsURL_GetDirectory,
|
|
|
|
nsURL_SetDirectory,
|
|
|
|
nsURL_GetFileName,
|
|
|
|
nsURL_SetFileName,
|
|
|
|
nsURL_GetFileBaseName,
|
|
|
|
nsURL_SetFileBaseName,
|
|
|
|
nsURL_GetFileExtension,
|
|
|
|
nsURL_SetFileExtension,
|
|
|
|
nsURL_GetCommonBaseSpec,
|
2010-02-21 21:09:11 +01:00
|
|
|
nsURL_GetRelativeSpec
|
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);
|
|
|
|
return nsIURL_QueryInterface(&This->nsIURL_iface, riid, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsStandardURL_AddRef(nsIStandardURL *iface)
|
|
|
|
{
|
|
|
|
nsWineURI *This = impl_from_nsIStandardURL(iface);
|
|
|
|
return nsIURL_AddRef(&This->nsIURL_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsStandardURL_Release(nsIStandardURL *iface)
|
|
|
|
{
|
|
|
|
nsWineURI *This = impl_from_nsIStandardURL(iface);
|
|
|
|
return nsIURL_Release(&This->nsIURL_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsStandardURL_GetMutable(nsIStandardURL *iface, PRBool *aMutable)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsStandardURL_SetMutable(nsIStandardURL *iface, PRBool aMutable)
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsStandardURL_Init(nsIStandardURL *iface, PRUint32 aUrlType, PRInt32 aDefaultPort,
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2011-06-25 19:03:19 +02:00
|
|
|
static nsresult create_nsuri(IUri *iuri, nsIURI *nsuri, HTMLWindow *window, NSContainer *container, nsWineURI **_retval)
|
2006-02-24 20:31:12 +01:00
|
|
|
{
|
2010-02-21 21:04:29 +01:00
|
|
|
nsWineURI *ret = heap_alloc_zero(sizeof(nsWineURI));
|
2006-02-24 20:31:12 +01:00
|
|
|
|
2011-01-05 00:39:25 +01:00
|
|
|
ret->nsIURL_iface.lpVtbl = &nsURLVtbl;
|
2011-11-18 12:21:47 +01:00
|
|
|
ret->nsIStandardURL_iface.lpVtbl = &nsStandardURLVtbl;
|
2006-02-24 20:31:12 +01:00
|
|
|
ret->ref = 1;
|
2010-09-28 13:24:57 +02:00
|
|
|
ret->nsuri = nsuri;
|
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;
|
|
|
|
|
2010-09-28 13:24:57 +02:00
|
|
|
if(nsuri)
|
|
|
|
nsIURI_QueryInterface(nsuri, &IID_nsIURL, (void**)&ret->nsurl);
|
2009-08-27 11:31:14 +02:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-02-21 21:06:51 +01:00
|
|
|
HRESULT create_doc_uri(HTMLWindow *window, WCHAR *url, nsWineURI **ret)
|
2009-11-30 18:01:31 +01:00
|
|
|
{
|
2010-02-21 21:06:51 +01:00
|
|
|
nsWineURI *uri;
|
2011-06-25 19:03:19 +02:00
|
|
|
IUri *iuri;
|
2009-11-30 18:01:31 +01:00
|
|
|
nsresult nsres;
|
2011-06-25 19:03:19 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = CreateUri(url, 0, 0, &iuri);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2009-11-30 18:01:31 +01:00
|
|
|
|
2011-06-25 19:03:19 +02:00
|
|
|
nsres = create_nsuri(iuri, NULL, window, window->doc_obj->nscontainer, &uri);
|
|
|
|
IUri_Release(iuri);
|
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;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
nsIURL_AddRef(&uri->nsIURL_iface);
|
|
|
|
channel->uri = uri;
|
|
|
|
|
|
|
|
hres = IUri_GetScheme(uri->uri, &channel->url_scheme);
|
|
|
|
if(FAILED(hres))
|
|
|
|
channel->url_scheme = URL_SCHEME_UNKNOWN;
|
|
|
|
|
|
|
|
*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)
|
|
|
|
{
|
|
|
|
HTMLWindow *window = NULL;
|
|
|
|
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;
|
|
|
|
|
2011-06-25 19:03:19 +02:00
|
|
|
hres = CreateUri(url, 0, 0, &iuri);
|
|
|
|
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;
|
2011-06-25 19:03:19 +02:00
|
|
|
nsres = create_nsuri(iuri, NULL, window, NULL, &uri);
|
|
|
|
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);
|
2011-04-15 19:36:36 +02:00
|
|
|
nsIURL_Release(&uri->nsIURL_iface);
|
|
|
|
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,
|
|
|
|
PRInt32 *aDefaultPort)
|
|
|
|
{
|
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,
|
|
|
|
PRUint32 *aProtocolFlags)
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
PRInt32 port, const char *scheme, PRBool *_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)->(%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,
|
|
|
|
nsProtocolHandler_NewChannel,
|
|
|
|
nsProtocolHandler_AllowPort
|
|
|
|
};
|
|
|
|
|
|
|
|
static nsIProtocolHandler *create_protocol_handler(nsIProtocolHandler *nshandler)
|
|
|
|
{
|
2007-12-05 21:52:31 +01:00
|
|
|
nsProtocolHandler *ret = heap_alloc(sizeof(nsProtocolHandler));
|
2007-05-12 16:12:04 +02:00
|
|
|
|
2010-12-29 02:52:32 +01:00
|
|
|
ret->nsIProtocolHandler_iface.lpVtbl = &nsProtocolHandlerVtbl;
|
2007-05-12 16:12:04 +02:00
|
|
|
ret->ref = 1;
|
|
|
|
ret->nshandler = nshandler;
|
|
|
|
|
2010-12-29 02:52:32 +01:00
|
|
|
return &ret->nsIProtocolHandler_iface;
|
2007-05-12 16:12:04 +02:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
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);
|
|
|
|
*_retval = create_protocol_handler(nshandler);
|
|
|
|
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,
|
|
|
|
PRUint32 *_retval)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
2010-12-30 23:29:11 +01:00
|
|
|
static const char *special_schemes[] = {"chrome:", "jar:", "moz-safe-about", "resource:", "javascript:", "wyciwyg:"};
|
2009-08-22 19:37:59 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
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];
|
2009-10-26 23:02:50 +01:00
|
|
|
HTMLWindow *window = NULL;
|
2010-12-30 23:32:58 +01:00
|
|
|
const char *spec = NULL;
|
2006-07-07 15:17:27 +02:00
|
|
|
nsIURI *uri = NULL;
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-30 23:32:58 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 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) {
|
|
|
|
hres = CoInternetCombineUrlEx(base_wine_uri->uri, new_spec, URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO,
|
|
|
|
&urlmon_uri, 0);
|
|
|
|
if(FAILED(hres))
|
|
|
|
WARN("CoInternetCombineUrlEx failed: %08x\n", hres);
|
2010-04-03 18:07:07 +02:00
|
|
|
}else {
|
2010-12-30 23:32:58 +01:00
|
|
|
hres = CreateUri(new_spec, 0, 0, &urlmon_uri);
|
|
|
|
if(FAILED(hres))
|
|
|
|
WARN("CreateUri failed: %08x\n", hres);
|
|
|
|
}
|
2007-08-14 22:36:10 +02:00
|
|
|
|
2010-12-30 23:32:58 +01:00
|
|
|
nsres = nsIIOService_NewURI(nsio, aSpec, aOriginCharset, aBaseURI, &uri);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
TRACE("NewURI failed: %08x\n", nsres);
|
|
|
|
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
*_retval = uri;
|
|
|
|
return nsres;
|
2006-08-09 16:42:37 +02:00
|
|
|
}
|
|
|
|
|
2011-06-25 19:03:19 +02:00
|
|
|
nsres = create_nsuri(urlmon_uri, uri, window, NULL, &wine_uri);
|
|
|
|
IUri_Release(urlmon_uri);
|
2007-02-09 20:19:13 +01:00
|
|
|
if(base_wine_uri)
|
2011-01-05 00:39:25 +01:00
|
|
|
nsIURI_Release(&base_wine_uri->nsIURL_iface);
|
2010-12-30 23:32:58 +01:00
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return nsres;
|
2007-02-09 20:19:13 +01:00
|
|
|
|
2011-06-25 19:03:38 +02:00
|
|
|
*_retval = (nsIURI*)&wine_uri->nsIURL_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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsIOService_NewChannelFromURI(nsIIOService *iface, nsIURI *aURI,
|
|
|
|
nsIChannel **_retval)
|
|
|
|
{
|
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;
|
|
|
|
|
2006-02-09 12:17:08 +01:00
|
|
|
TRACE("(%p %p)\n", aURI, _retval);
|
2006-02-09 12:19:13 +01:00
|
|
|
|
2010-02-21 21:10:15 +01:00
|
|
|
nsres = nsIURI_QueryInterface(aURI, &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);
|
2009-11-30 17:59:53 +01:00
|
|
|
return nsIIOService_NewChannelFromURI(nsio, aURI, _retval);
|
2006-02-09 12:19:13 +01:00
|
|
|
}
|
|
|
|
|
2011-04-15 19:36:24 +02:00
|
|
|
nsres = create_nschannel(wine_uri, &ret);
|
|
|
|
nsIURL_Release(&wine_uri->nsIURL_iface);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return nsres;
|
2006-02-20 16:43:32 +01:00
|
|
|
|
|
|
|
nsIURI_AddRef(aURI);
|
|
|
|
ret->original_uri = aURI;
|
2010-11-25 13:56:03 +01:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsIOService_GetOffline(nsIIOService *iface, PRBool *aOffline)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", aOffline);
|
|
|
|
return nsIIOService_GetOffline(nsio, aOffline);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsIOService_SetOffline(nsIIOService *iface, PRBool aOffline)
|
|
|
|
{
|
|
|
|
TRACE("(%x)\n", aOffline);
|
|
|
|
return nsIIOService_SetOffline(nsio, aOffline);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsIOService_AllowPort(nsIIOService *iface, PRInt32 aPort,
|
|
|
|
const char *aScheme, PRBool *_retval)
|
|
|
|
{
|
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,
|
|
|
|
nsIOService_NewChannelFromURI,
|
|
|
|
nsIOService_NewChannel,
|
|
|
|
nsIOService_GetOffline,
|
|
|
|
nsIOService_SetOffline,
|
|
|
|
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,
|
|
|
|
nsACString *aCharset, PRBool *aHadCharset, nsACString *aContentType)
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2008-12-30 06:48:59 +01:00
|
|
|
static nsresult NSAPI nsNetUtil_ProtocolHasFlags(nsINetUtil *iface, nsIURI *aURI, PRUint32 aFlags, PRBool *_retval)
|
|
|
|
{
|
|
|
|
TRACE("()\n");
|
|
|
|
|
|
|
|
return nsINetUtil_ProtocolHasFlags(net_util, aURI, aFlags, _retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsNetUtil_URIChainHasFlags(nsINetUtil *iface, nsIURI *aURI, PRUint32 aFlags, PRBool *_retval)
|
|
|
|
{
|
|
|
|
TRACE("(%p %08x %p)\n", aURI, aFlags, _retval);
|
|
|
|
|
|
|
|
if(aFlags == (1<<11)) {
|
|
|
|
*_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,
|
|
|
|
PRUint32 aEscapeType, nsACString *_retval)
|
|
|
|
{
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsNetUtil_EscapeURL(nsINetUtil *iface, const nsACString *aStr, PRUint32 aFlags,
|
|
|
|
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,
|
|
|
|
PRUint32 aFlags, 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_UnescapeString(net_util, aStr, aFlags, _retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsNetUtil_ExtractCharsetFromContentType(nsINetUtil *iface, const nsACString *aTypeHeader,
|
|
|
|
nsACString *aCharset, PRInt32 *aCharsetStart, PRInt32 *aCharsetEnd, PRBool *_retval)
|
|
|
|
{
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsIOServiceFactory_LockFactory(nsIFactory *iface, PRBool lock)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult on_start_uri_open(NSContainer *nscontainer, nsIURI *uri, PRBool *_retval)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2011-01-05 00:39:25 +01:00
|
|
|
nsIURI_Release(&wine_uri->nsIURL_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;
|
|
|
|
}
|
|
|
|
}
|