2006-02-09 11:17:08 +00:00
|
|
|
/*
|
2010-08-03 19:40:20 +00:00
|
|
|
* Copyright 2006-2010 Jacek Caban for CodeWeavers
|
2006-02-09 11:17:08 +00: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 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2006-02-09 11:17:08 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
2007-02-09 19:19:13 +00:00
|
|
|
#include "winreg.h"
|
2006-02-09 11:17:08 +00:00
|
|
|
#include "ole2.h"
|
2006-02-09 11:19:33 +00:00
|
|
|
#include "shlguid.h"
|
2007-02-09 19:17:16 +00:00
|
|
|
#include "wininet.h"
|
2007-02-09 19:19:13 +00:00
|
|
|
#include "shlwapi.h"
|
2006-02-09 11:17:08 +00:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
|
|
|
|
#include "mshtml_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
|
|
|
|
|
|
|
#define NS_IOSERVICE_CLASSNAME "nsIOService"
|
|
|
|
#define NS_IOSERVICE_CONTRACTID "@mozilla.org/network/io-service;1"
|
|
|
|
|
2006-02-24 19:31:12 +00:00
|
|
|
static const IID NS_IOSERVICE_CID =
|
2006-02-09 11:17:08 +00:00
|
|
|
{0x9ac9e770, 0x18bc, 0x11d3, {0x93, 0x37, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40}};
|
2010-02-21 20:10:15 +00:00
|
|
|
static const IID IID_nsWineURI =
|
|
|
|
{0x5088272e, 0x900b, 0x11da, {0xc6,0x87, 0x00,0x0f,0xea,0x57,0xf2,0x1a}};
|
2006-02-09 11:17:08 +00:00
|
|
|
|
|
|
|
static nsIIOService *nsio = NULL;
|
2008-12-18 13:08:13 +00:00
|
|
|
static nsINetUtil *net_util;
|
2006-02-09 11:17:08 +00:00
|
|
|
|
2008-02-20 20:31:07 +00:00
|
|
|
static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
|
|
|
|
|
2010-08-03 19:40:20 +00:00
|
|
|
static const char *request_method_strings[] = {"GET", "PUT", "POST"};
|
|
|
|
|
2010-02-21 20:05:15 +00:00
|
|
|
struct nsWineURI {
|
2010-02-21 20:10:15 +00:00
|
|
|
const nsIURLVtbl *lpIURLVtbl;
|
2006-02-09 11:18:18 +00:00
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
nsIURI *uri;
|
2009-08-27 09:31:14 +00:00
|
|
|
nsIURL *nsurl;
|
2006-02-09 11:18:18 +00:00
|
|
|
NSContainer *container;
|
2009-10-26 22:02:50 +00:00
|
|
|
windowref_t *window_ref;
|
2010-01-03 23:38:57 +00:00
|
|
|
nsChannelBSC *channel_bsc;
|
2007-02-09 19:17:16 +00:00
|
|
|
LPWSTR wine_url;
|
2010-03-03 13:54:10 +00:00
|
|
|
BOOL is_doc_uri;
|
2007-02-10 17:59:38 +00:00
|
|
|
BOOL use_wine_url;
|
2010-02-21 20:05:15 +00:00
|
|
|
};
|
2006-02-09 11:18:18 +00:00
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
#define NSURI(x) ((nsIURI*) &(x)->lpIURLVtbl)
|
|
|
|
#define NSURL(x) ((nsIURL*) &(x)->lpIURLVtbl)
|
2006-02-09 11:18:18 +00:00
|
|
|
|
2010-02-21 20:06:51 +00:00
|
|
|
static nsresult create_uri(nsIURI*,HTMLWindow*,NSContainer*,nsWineURI**);
|
2006-02-24 19:31:12 +00:00
|
|
|
|
2009-08-27 09:31:14 +00:00
|
|
|
static const char *debugstr_nsacstr(const nsACString *nsstr)
|
|
|
|
{
|
|
|
|
const char *data;
|
|
|
|
|
|
|
|
nsACString_GetData(nsstr, &data);
|
|
|
|
return debugstr_a(data);
|
|
|
|
}
|
|
|
|
|
2009-09-13 22:36:09 +00:00
|
|
|
HRESULT nsuri_to_url(LPCWSTR nsuri, BOOL ret_empty, BSTR *ret)
|
2008-10-13 19:50:37 +00: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-13 22:36:09 +00:00
|
|
|
if(*ptr || ret_empty) {
|
|
|
|
*ret = SysAllocString(ptr);
|
|
|
|
if(!*ret)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}else {
|
|
|
|
*ret = NULL;
|
|
|
|
}
|
2008-10-13 19:50:37 +00:00
|
|
|
|
|
|
|
TRACE("%s -> %s\n", debugstr_w(nsuri), debugstr_w(*ret));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-09-16 20:09:17 +00:00
|
|
|
static BOOL exec_shldocvw_67(HTMLDocumentObj *doc, LPCWSTR url)
|
2006-02-09 11:19:33 +00:00
|
|
|
{
|
|
|
|
IOleCommandTarget *cmdtrg = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2009-09-16 20:10:03 +00:00
|
|
|
hres = IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
|
2006-02-09 11:19:33 +00:00
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
VARIANT varUrl, varRes;
|
|
|
|
|
|
|
|
V_VT(&varUrl) = VT_BSTR;
|
|
|
|
V_BSTR(&varUrl) = SysAllocString(url);
|
|
|
|
V_VT(&varRes) = VT_BOOL;
|
|
|
|
|
|
|
|
hres = IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 67, 0, &varUrl, &varRes);
|
|
|
|
|
|
|
|
IOleCommandTarget_Release(cmdtrg);
|
|
|
|
SysFreeString(V_BSTR(&varUrl));
|
|
|
|
|
|
|
|
if(SUCCEEDED(hres) && !V_BOOL(&varRes)) {
|
|
|
|
TRACE("got VARIANT_FALSE, do not load\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-09-29 01:41:10 +00:00
|
|
|
static BOOL before_async_open(nsChannel *channel, NSContainer *container)
|
2006-02-13 12:26:00 +00:00
|
|
|
{
|
2009-09-16 20:09:17 +00:00
|
|
|
HTMLDocumentObj *doc = container->doc;
|
2006-03-01 21:04:51 +00:00
|
|
|
DWORD hlnf = 0;
|
2010-03-03 13:54:44 +00:00
|
|
|
BOOL cancel;
|
2006-02-13 12:26:00 +00:00
|
|
|
HRESULT hres;
|
|
|
|
|
2006-03-01 21:04:51 +00:00
|
|
|
if(!doc) {
|
|
|
|
NSContainer *container_iter = container;
|
|
|
|
|
|
|
|
hlnf = HLNF_OPENINNEWWINDOW;
|
|
|
|
while(!container_iter->doc)
|
|
|
|
container_iter = container_iter->parent;
|
|
|
|
doc = container_iter->doc;
|
|
|
|
}
|
|
|
|
|
2009-09-16 20:10:03 +00:00
|
|
|
if(!doc->client)
|
2008-01-10 11:53:14 +00:00
|
|
|
return TRUE;
|
|
|
|
|
2010-02-21 20:05:15 +00:00
|
|
|
if(!hlnf && !exec_shldocvw_67(doc, channel->uri->wine_url))
|
2006-02-13 12:26:00 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2010-03-03 13:54:44 +00:00
|
|
|
hres = hlink_frame_navigate(&doc->basedoc, channel->uri->wine_url, channel->post_data_stream, hlnf, &cancel);
|
|
|
|
return FAILED(hres) || cancel;
|
2006-02-13 12:26:00 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:06:51 +00:00
|
|
|
HRESULT load_nsuri(HTMLWindow *window, nsWineURI *uri, nsChannelBSC *channelbsc, DWORD flags)
|
|
|
|
{
|
|
|
|
nsIWebNavigation *web_navigation;
|
|
|
|
nsIDocShell *doc_shell;
|
|
|
|
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;
|
|
|
|
nsres = nsIDocShell_LoadURI(doc_shell, NSURI(uri), NULL, flags, FALSE);
|
|
|
|
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 20:05:59 +00:00
|
|
|
static BOOL translate_url(HTMLDocumentObj *doc, nsWineURI *uri)
|
|
|
|
{
|
|
|
|
OLECHAR *new_url = NULL, *url;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(!doc->hostui)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
url = heap_strdupW(uri->wine_url);
|
|
|
|
hres = IDocHostUIHandler_TranslateUrl(doc->hostui, 0, url, &new_url);
|
2010-04-22 19:36:08 +00:00
|
|
|
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);
|
2010-02-21 20:05:59 +00:00
|
|
|
}
|
|
|
|
|
2010-04-22 19:36:08 +00:00
|
|
|
heap_free(url);
|
2010-02-21 20:05:59 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult on_start_uri_open(NSContainer *nscontainer, nsIURI *uri, PRBool *_retval)
|
|
|
|
{
|
|
|
|
nsWineURI *wine_uri;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
*_retval = FALSE;
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
nsres = nsIURI_QueryInterface(uri, &IID_nsWineURI, (void**)&wine_uri);
|
2010-02-21 20:05:59 +00:00
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
WARN("Could not get nsWineURI: %08x\n", nsres);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!wine_uri->is_doc_uri) {
|
2010-06-14 00:19:12 +00:00
|
|
|
wine_uri->is_doc_uri = TRUE;
|
|
|
|
|
2010-02-21 20:05:59 +00:00
|
|
|
if(!wine_uri->container) {
|
|
|
|
nsIWebBrowserChrome_AddRef(NSWBCHROME(nscontainer));
|
|
|
|
wine_uri->container = nscontainer;
|
|
|
|
}
|
|
|
|
|
2010-06-14 00:19:12 +00:00
|
|
|
if(nscontainer->doc)
|
|
|
|
*_retval = translate_url(nscontainer->doc, wine_uri);
|
2010-02-21 20:05:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIURI_Release(NSURI(wine_uri));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2010-02-21 20:06:51 +00:00
|
|
|
|
2010-02-21 20:05:15 +00:00
|
|
|
HRESULT set_wine_url(nsWineURI *This, LPCWSTR url)
|
|
|
|
{
|
2010-02-21 20:07:43 +00:00
|
|
|
static const WCHAR wszFtp[] = {'f','t','p',':'};
|
|
|
|
static const WCHAR wszHttp[] = {'h','t','t','p',':'};
|
|
|
|
static const WCHAR wszHttps[] = {'h','t','t','p','s',':'};
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_w(url));
|
|
|
|
|
|
|
|
if(url) {
|
|
|
|
WCHAR *new_url;
|
|
|
|
|
|
|
|
new_url = heap_strdupW(url);
|
|
|
|
if(!new_url)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
heap_free(This->wine_url);
|
|
|
|
This->wine_url = new_url;
|
|
|
|
|
|
|
|
if(This->uri) {
|
|
|
|
/* FIXME: Always use wine url */
|
|
|
|
This->use_wine_url =
|
|
|
|
strncmpW(url, wszFtp, sizeof(wszFtp)/sizeof(WCHAR))
|
|
|
|
&& strncmpW(url, wszHttp, sizeof(wszHttp)/sizeof(WCHAR))
|
|
|
|
&& strncmpW(url, wszHttps, sizeof(wszHttps)/sizeof(WCHAR));
|
|
|
|
}else {
|
|
|
|
This->use_wine_url = TRUE;
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
heap_free(This->wine_url);
|
|
|
|
This->wine_url = NULL;
|
|
|
|
This->use_wine_url = FALSE;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:05:15 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:09:11 +00: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);
|
|
|
|
nsIWebBrowserChrome_Release(NSWBCHROME(This->container));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(nscontainer)
|
|
|
|
nsIWebBrowserChrome_AddRef(NSWBCHROME(nscontainer));
|
|
|
|
This->container = nscontainer;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:08:39 +00: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 20:09:11 +00:00
|
|
|
set_uri_nscontainer(This, window->doc_obj->nscontainer);
|
2010-02-21 20:08:39 +00:00
|
|
|
}else {
|
|
|
|
This->window_ref = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-01 21:50:19 +00:00
|
|
|
static inline BOOL is_http_channel(nsChannel *This)
|
|
|
|
{
|
2010-03-19 20:57:26 +00:00
|
|
|
return This->url_scheme == URL_SCHEME_HTTP || This->url_scheme == URL_SCHEME_HTTPS;
|
2009-12-01 21:50:19 +00:00
|
|
|
}
|
|
|
|
|
2010-08-03 19:38:11 +00: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;
|
|
|
|
|
|
|
|
nsACString_SetData(_retval, data);
|
|
|
|
heap_free(data);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-03 19:38:37 +00: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 19:40:05 +00: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-08-03 19:37:00 +00: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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-09 11:19:13 +00:00
|
|
|
#define NSCHANNEL_THIS(iface) DEFINE_THIS(nsChannel, HttpChannel, iface)
|
|
|
|
|
2010-08-02 09:08:26 +00:00
|
|
|
static nsresult NSAPI nsChannel_QueryInterface(nsIHttpChannel *iface, nsIIDRef riid, void **result)
|
2006-02-09 11:19:13 +00:00
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_nsISupports, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsISupports %p)\n", This, result);
|
|
|
|
*result = NSCHANNEL(This);
|
|
|
|
}else if(IsEqualGUID(&IID_nsIRequest, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIRequest %p)\n", This, result);
|
|
|
|
*result = NSCHANNEL(This);
|
|
|
|
}else if(IsEqualGUID(&IID_nsIChannel, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIChannel %p)\n", This, result);
|
|
|
|
*result = NSCHANNEL(This);
|
2009-08-22 17:37:30 +00:00
|
|
|
}else if(IsEqualGUID(&IID_nsIHttpChannel, riid)) {
|
2006-02-09 11:19:13 +00:00
|
|
|
TRACE("(%p)->(IID_nsIHttpChannel %p)\n", This, result);
|
2009-12-01 21:50:19 +00:00
|
|
|
*result = is_http_channel(This) ? NSHTTPCHANNEL(This) : NULL;
|
2006-02-10 13:49:41 +00:00
|
|
|
}else if(IsEqualGUID(&IID_nsIUploadChannel, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIUploadChannel %p)\n", This, result);
|
|
|
|
*result = NSUPCHANNEL(This);
|
2009-08-22 17:37:30 +00:00
|
|
|
}else if(IsEqualGUID(&IID_nsIHttpChannelInternal, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIHttpChannelInternal %p)\n", This, result);
|
2009-12-01 21:50:19 +00:00
|
|
|
*result = is_http_channel(This) ? NSHTTPINTERNAL(This) : NULL;
|
2009-08-22 17:37:30 +00:00
|
|
|
}else {
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), result);
|
|
|
|
*result = NULL;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*result) {
|
|
|
|
nsIChannel_AddRef(NSCHANNEL(This));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-02-20 10:13:37 +00:00
|
|
|
return NS_NOINTERFACE;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsChannel_AddRef(nsIHttpChannel *iface)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
|
|
|
nsrefcnt ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2006-10-05 21:50:39 +00:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2006-02-09 11:19:13 +00:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsChannel_Release(nsIHttpChannel *iface)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
if(!ref) {
|
2010-02-21 20:05:15 +00:00
|
|
|
nsIURI_Release(NSURI(This->uri));
|
2008-12-22 00:10:47 +00:00
|
|
|
if(This->owner)
|
|
|
|
nsISupports_Release(This->owner);
|
2006-02-10 13:49:41 +00:00
|
|
|
if(This->post_data_stream)
|
|
|
|
nsIInputStream_Release(This->post_data_stream);
|
2006-02-20 10:13:37 +00: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-04-02 22:31:45 +00:00
|
|
|
|
2010-08-03 19:37:00 +00:00
|
|
|
free_http_headers(&This->response_headers);
|
2010-08-03 19:39:34 +00:00
|
|
|
free_http_headers(&This->request_headers);
|
2010-04-02 22:31:45 +00:00
|
|
|
|
2010-08-03 19:37:00 +00:00
|
|
|
heap_free(This->content_type);
|
|
|
|
heap_free(This->charset);
|
2007-12-05 20:52:31 +00:00
|
|
|
heap_free(This);
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetName(nsIHttpChannel *iface, nsACString *aName)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2010-01-03 23:38:20 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, aName);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_IsPending(nsIHttpChannel *iface, PRBool *_retval)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2010-01-03 23:38:20 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, _retval);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetStatus(nsIHttpChannel *iface, nsresult *aStatus)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2010-01-03 23:38:20 +00:00
|
|
|
WARN("(%p)->(%p) returning NS_OK\n", This, aStatus);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2006-06-25 12:13:48 +00:00
|
|
|
return *aStatus = NS_OK;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_Cancel(nsIHttpChannel *iface, nsresult aStatus)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2010-01-03 23:38:20 +00:00
|
|
|
FIXME("(%p)->(%08x)\n", This, aStatus);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_Suspend(nsIHttpChannel *iface)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2010-01-03 23:38:20 +00:00
|
|
|
FIXME("(%p)\n", This);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_Resume(nsIHttpChannel *iface)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2010-01-03 23:38:20 +00:00
|
|
|
FIXME("(%p)\n", This);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetLoadGroup(nsIHttpChannel *iface, nsILoadGroup **aLoadGroup)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2006-02-09 11:19:13 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aLoadGroup);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
|
|
|
if(This->load_group)
|
|
|
|
nsILoadGroup_AddRef(This->load_group);
|
|
|
|
|
|
|
|
*aLoadGroup = This->load_group;
|
|
|
|
return NS_OK;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetLoadGroup(nsIHttpChannel *iface, nsILoadGroup *aLoadGroup)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2006-02-09 11:19:13 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aLoadGroup);
|
2006-02-20 10:13:37 +00: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 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetLoadFlags(nsIHttpChannel *iface, nsLoadFlags *aLoadFlags)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2006-02-09 11:19:13 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aLoadFlags);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
|
|
|
*aLoadFlags = This->load_flags;
|
|
|
|
return NS_OK;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetLoadFlags(nsIHttpChannel *iface, nsLoadFlags aLoadFlags)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2006-10-05 21:50:39 +00:00
|
|
|
TRACE("(%p)->(%08x)\n", This, aLoadFlags);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
|
|
|
This->load_flags = aLoadFlags;
|
|
|
|
return NS_OK;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetOriginalURI(nsIHttpChannel *iface, nsIURI **aOriginalURI)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2006-02-09 11:19:13 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aOriginalURI);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
|
|
|
if(This->original_uri)
|
|
|
|
nsIURI_AddRef(This->original_uri);
|
|
|
|
|
|
|
|
*aOriginalURI = This->original_uri;
|
|
|
|
return NS_OK;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetOriginalURI(nsIHttpChannel *iface, nsIURI *aOriginalURI)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2006-02-09 11:19:13 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aOriginalURI);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
|
|
|
if(This->original_uri)
|
|
|
|
nsIURI_Release(This->original_uri);
|
|
|
|
|
|
|
|
nsIURI_AddRef(aOriginalURI);
|
|
|
|
This->original_uri = aOriginalURI;
|
|
|
|
return NS_OK;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetURI(nsIHttpChannel *iface, nsIURI **aURI)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aURI);
|
|
|
|
|
2010-02-21 20:05:15 +00:00
|
|
|
nsIURI_AddRef(NSURI(This->uri));
|
2006-02-09 11:19:13 +00:00
|
|
|
*aURI = (nsIURI*)This->uri;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetOwner(nsIHttpChannel *iface, nsISupports **aOwner)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2006-02-09 11:19:13 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aOwner);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2008-12-18 13:08:31 +00:00
|
|
|
if(This->owner)
|
|
|
|
nsISupports_AddRef(This->owner);
|
|
|
|
*aOwner = This->owner;
|
|
|
|
|
|
|
|
return NS_OK;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetOwner(nsIHttpChannel *iface, nsISupports *aOwner)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2006-02-09 11:19:13 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aOwner);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2008-12-18 13:08:31 +00:00
|
|
|
if(aOwner)
|
|
|
|
nsISupports_AddRef(aOwner);
|
|
|
|
if(This->owner)
|
|
|
|
nsISupports_Release(This->owner);
|
|
|
|
This->owner = aOwner;
|
|
|
|
|
|
|
|
return NS_OK;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetNotificationCallbacks(nsIHttpChannel *iface,
|
|
|
|
nsIInterfaceRequestor **aNotificationCallbacks)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2006-02-09 11:19:13 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aNotificationCallbacks);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
|
|
|
if(This->notif_callback)
|
|
|
|
nsIInterfaceRequestor_AddRef(This->notif_callback);
|
|
|
|
*aNotificationCallbacks = This->notif_callback;
|
|
|
|
|
|
|
|
return NS_OK;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetNotificationCallbacks(nsIHttpChannel *iface,
|
|
|
|
nsIInterfaceRequestor *aNotificationCallbacks)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2006-02-09 11:19:13 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aNotificationCallbacks);
|
2006-02-20 10:13:37 +00: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 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetSecurityInfo(nsIHttpChannel *iface, nsISupports **aSecurityInfo)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2006-06-20 16:59:09 +00:00
|
|
|
|
2010-01-14 16:10:57 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aSecurityInfo);
|
2006-06-20 16:59:09 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetContentType(nsIHttpChannel *iface, nsACString *aContentType)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2006-02-09 11:19:13 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aContentType);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2008-03-26 14:24:03 +00:00
|
|
|
if(This->content_type) {
|
|
|
|
nsACString_SetData(aContentType, This->content_type);
|
2006-06-02 22:48:13 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-10-13 18:50:55 +00:00
|
|
|
WARN("unknown type\n");
|
|
|
|
return NS_ERROR_FAILURE;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetContentType(nsIHttpChannel *iface,
|
|
|
|
const nsACString *aContentType)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2008-03-26 14:24:38 +00:00
|
|
|
const char *content_type;
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2010-08-03 13:44:56 +00:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aContentType));
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2008-03-26 14:24:38 +00:00
|
|
|
nsACString_GetData(aContentType, &content_type);
|
|
|
|
heap_free(This->content_type);
|
|
|
|
This->content_type = heap_strdupA(content_type);
|
|
|
|
|
|
|
|
return NS_OK;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetContentCharset(nsIHttpChannel *iface,
|
|
|
|
nsACString *aContentCharset)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2006-02-09 11:19:13 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aContentCharset);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2007-04-12 19:25:08 +00:00
|
|
|
if(This->charset) {
|
|
|
|
nsACString_SetData(aContentCharset, This->charset);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2007-04-12 19:25:08 +00:00
|
|
|
nsACString_SetData(aContentCharset, "");
|
|
|
|
return NS_OK;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetContentCharset(nsIHttpChannel *iface,
|
|
|
|
const nsACString *aContentCharset)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2010-08-03 13:44:56 +00:00
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_nsacstr(aContentCharset));
|
2006-02-20 10:13:37 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetContentLength(nsIHttpChannel *iface, PRInt32 *aContentLength)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2010-01-03 23:38:20 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, aContentLength);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetContentLength(nsIHttpChannel *iface, PRInt32 aContentLength)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2010-01-03 23:38:20 +00:00
|
|
|
FIXME("(%p)->(%d)\n", This, aContentLength);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_Open(nsIHttpChannel *iface, nsIInputStream **_retval)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
2010-01-03 23:38:20 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, _retval);
|
2006-02-20 10:13:37 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
2007-06-11 15:25:51 +00:00
|
|
|
static HRESULT create_mon_for_nschannel(nsChannel *channel, IMoniker **mon)
|
|
|
|
{
|
2010-02-21 20:07:43 +00:00
|
|
|
nsWineURI *wine_uri;
|
2007-06-11 15:25:51 +00:00
|
|
|
nsresult nsres;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(!channel->original_uri) {
|
|
|
|
ERR("original_uri == NULL\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
nsres = nsIURI_QueryInterface(channel->original_uri, &IID_nsWineURI, (void**)&wine_uri);
|
2007-06-11 15:25:51 +00:00
|
|
|
if(NS_FAILED(nsres)) {
|
2010-02-21 20:10:15 +00:00
|
|
|
ERR("Could not get nsWineURI: %08x\n", nsres);
|
2007-06-11 15:25:51 +00:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:07:43 +00:00
|
|
|
if(wine_uri->wine_url) {
|
|
|
|
hres = CreateURLMoniker(NULL, wine_uri->wine_url, mon);
|
|
|
|
if(FAILED(hres))
|
|
|
|
WARN("CreateURLMoniker failed: %08x\n", hres);
|
|
|
|
}else {
|
2007-06-11 15:25:51 +00:00
|
|
|
TRACE("wine_url == NULL\n");
|
2010-02-21 20:07:43 +00:00
|
|
|
hres = E_FAIL;
|
2007-06-11 15:25:51 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:07:43 +00:00
|
|
|
nsIURI_Release(NSURI(wine_uri));
|
2007-06-11 15:25:51 +00:00
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2009-10-26 22:03:29 +00:00
|
|
|
static HTMLWindow *get_window_from_load_group(nsChannel *This)
|
2008-03-08 19:15:30 +00:00
|
|
|
{
|
2009-10-26 22:03:29 +00:00
|
|
|
HTMLWindow *window;
|
2008-03-08 19:15:30 +00:00
|
|
|
nsIChannel *channel;
|
|
|
|
nsIRequest *req;
|
2010-02-21 20:08:39 +00:00
|
|
|
nsWineURI *wine_uri;
|
2008-03-08 19:15:30 +00: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 08:38:05 +00:00
|
|
|
if(!req)
|
|
|
|
return NULL;
|
|
|
|
|
2008-03-08 19:15:30 +00: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 20:10:15 +00:00
|
|
|
nsres = nsIURI_QueryInterface(uri, &IID_nsWineURI, (void**)&wine_uri);
|
2008-03-08 19:15:30 +00:00
|
|
|
nsIURI_Release(uri);
|
|
|
|
if(NS_FAILED(nsres)) {
|
2010-02-21 20:10:15 +00:00
|
|
|
TRACE("Could not get nsWineURI: %08x\n", nsres);
|
2008-03-08 19:15:30 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:08:39 +00:00
|
|
|
window = wine_uri->window_ref ? wine_uri->window_ref->window : NULL;
|
|
|
|
if(window)
|
|
|
|
IHTMLWindow2_AddRef(HTMLWINDOW2(window));
|
|
|
|
nsIURI_Release(NSURI(wine_uri));
|
2008-03-08 19:15:30 +00:00
|
|
|
|
2009-10-26 22:03:29 +00:00
|
|
|
return window;
|
2008-03-08 19:15:30 +00:00
|
|
|
}
|
|
|
|
|
2009-10-26 22:02:50 +00:00
|
|
|
static HTMLWindow *get_channel_window(nsChannel *This)
|
|
|
|
{
|
|
|
|
nsIRequestObserver *req_observer;
|
|
|
|
nsIWebProgress *web_progress;
|
|
|
|
nsIDOMWindow *nswindow;
|
|
|
|
HTMLWindow *window;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
if(!This->load_group) {
|
|
|
|
ERR("NULL load_group\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsILoadGroup_GetGroupObserver(This->load_group, &req_observer);
|
|
|
|
if(NS_FAILED(nsres) || !req_observer) {
|
|
|
|
ERR("GetGroupObserver failed: %08x\n", nsres);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
IHTMLWindow2_AddRef(HTMLWINDOW2(window));
|
|
|
|
else
|
|
|
|
FIXME("NULL window for %p\n", nswindow);
|
|
|
|
return window;
|
|
|
|
}
|
|
|
|
|
2009-10-26 22:05:10 +00:00
|
|
|
typedef struct {
|
|
|
|
task_t header;
|
2009-10-26 22:05:37 +00:00
|
|
|
HTMLDocumentNode *doc;
|
2009-10-26 22:05:10 +00: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 22:05:37 +00:00
|
|
|
start_binding(NULL, task->doc, (BSCallback*)task->bscallback, NULL);
|
|
|
|
|
|
|
|
IUnknown_Release((IUnknown*)task->bscallback);
|
2009-10-26 22:05:10 +00:00
|
|
|
}
|
|
|
|
|
2009-10-26 22:03:29 +00:00
|
|
|
static nsresult async_open(nsChannel *This, HTMLWindow *window, BOOL is_doc_channel, nsIStreamListener *listener,
|
2007-11-02 18:53:02 +00:00
|
|
|
nsISupports *context)
|
|
|
|
{
|
2008-03-23 01:16:03 +00:00
|
|
|
nsChannelBSC *bscallback;
|
2007-11-02 18:53:02 +00:00
|
|
|
IMoniker *mon = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2007-06-11 15:25:51 +00:00
|
|
|
hres = create_mon_for_nschannel(This, &mon);
|
|
|
|
if(FAILED(hres))
|
2006-08-09 14:42:51 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
2006-02-10 13:49:41 +00:00
|
|
|
|
2009-10-26 22:03:29 +00:00
|
|
|
if(is_doc_channel)
|
2009-10-26 22:04:28 +00:00
|
|
|
set_current_mon(window, mon);
|
2009-10-26 22:03:29 +00:00
|
|
|
|
2010-03-03 13:53:49 +00:00
|
|
|
hres = create_channelbsc(mon, NULL, NULL, 0, &bscallback);
|
2006-08-09 14:42:51 +00:00
|
|
|
IMoniker_Release(mon);
|
2010-03-03 13:53:49 +00:00
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2006-03-18 21:00:34 +00:00
|
|
|
|
2008-03-23 01:15:20 +00:00
|
|
|
channelbsc_set_channel(bscallback, This, listener, context);
|
2006-02-10 13:49:41 +00:00
|
|
|
|
2009-10-26 22:05:37 +00:00
|
|
|
if(is_doc_channel) {
|
|
|
|
set_window_bscallback(window, bscallback);
|
2010-03-03 13:53:32 +00:00
|
|
|
async_start_doc_binding(window, bscallback);
|
|
|
|
IUnknown_Release((IUnknown*)bscallback);
|
2009-10-26 22:05:37 +00:00
|
|
|
}else {
|
|
|
|
start_binding_task_t *task = heap_alloc(sizeof(start_binding_task_t));
|
|
|
|
|
|
|
|
task->doc = window->doc;
|
|
|
|
task->bscallback = bscallback;
|
|
|
|
push_task(&task->header, start_binding_proc, window->doc->basedoc.task_magic);
|
|
|
|
}
|
2006-08-09 14:42:51 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
2007-11-02 18:53:02 +00:00
|
|
|
static nsresult NSAPI nsChannel_AsyncOpen(nsIHttpChannel *iface, nsIStreamListener *aListener,
|
|
|
|
nsISupports *aContext)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2009-10-26 22:03:29 +00:00
|
|
|
HTMLWindow *window = NULL;
|
2007-11-02 18:53:02 +00:00
|
|
|
BOOL open = TRUE;
|
|
|
|
nsresult nsres = NS_OK;
|
|
|
|
|
2010-02-21 20:05:15 +00:00
|
|
|
TRACE("(%p)->(%p %p) opening %s\n", This, aListener, aContext, debugstr_w(This->uri->wine_url));
|
2009-10-26 22:02:50 +00:00
|
|
|
|
2010-02-21 20:05:15 +00:00
|
|
|
if(This->uri->is_doc_uri) {
|
2009-10-26 22:02:50 +00:00
|
|
|
window = get_channel_window(This);
|
|
|
|
if(window) {
|
2010-02-21 20:08:39 +00:00
|
|
|
set_uri_window(This->uri, window);
|
2010-02-21 20:05:15 +00: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);
|
|
|
|
|
|
|
|
b = before_async_open(This, This->uri->container);
|
|
|
|
if(b)
|
|
|
|
FIXME("Navigation not cancelled\n");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2009-10-26 22:02:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-26 22:03:29 +00:00
|
|
|
if(!window) {
|
2010-02-21 20:08:39 +00:00
|
|
|
if(This->uri->window_ref && This->uri->window_ref->window) {
|
|
|
|
window = This->uri->window_ref->window;
|
|
|
|
IHTMLWindow2_AddRef(HTMLWINDOW2(window));
|
|
|
|
}else if(This->load_group) {
|
2009-10-26 22:03:29 +00:00
|
|
|
window = get_window_from_load_group(This);
|
|
|
|
if(window)
|
2010-02-21 20:08:39 +00:00
|
|
|
set_uri_window(This->uri, window);
|
2009-10-26 22:03:29 +00:00
|
|
|
}
|
2008-03-08 19:15:30 +00:00
|
|
|
}
|
|
|
|
|
2009-10-26 22:03:29 +00:00
|
|
|
if(!window) {
|
2009-12-01 21:50:00 +00:00
|
|
|
ERR("window = NULL\n");
|
2010-01-03 23:38:20 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
2007-11-02 18:53:02 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:05:15 +00: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 22:03:29 +00:00
|
|
|
|
2010-01-03 23:38:57 +00:00
|
|
|
if(window->doc_obj->mime) {
|
2009-10-26 22:03:29 +00:00
|
|
|
heap_free(This->content_type);
|
2010-01-03 23:38:57 +00:00
|
|
|
This->content_type = heap_strdupWtoA(window->doc_obj->mime);
|
2009-10-26 22:03:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
open = FALSE;
|
|
|
|
}else {
|
2010-03-17 21:09:09 +00:00
|
|
|
open = !before_async_open(This, window->doc_obj->nscontainer);
|
2009-10-26 22:03:29 +00:00
|
|
|
if(!open) {
|
|
|
|
TRACE("canceled\n");
|
|
|
|
nsres = NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-11-02 18:53:02 +00:00
|
|
|
|
|
|
|
if(open)
|
2010-02-21 20:05:15 +00:00
|
|
|
nsres = async_open(This, window, This->uri->is_doc_uri, aListener, aContext);
|
2007-11-02 18:53:02 +00:00
|
|
|
|
2010-01-03 23:38:57 +00:00
|
|
|
IHTMLWindow2_Release(HTMLWINDOW2(window));
|
2007-11-02 18:53:02 +00:00
|
|
|
return nsres;
|
|
|
|
}
|
|
|
|
|
2006-02-09 11:19:13 +00:00
|
|
|
static nsresult NSAPI nsChannel_GetRequestMethod(nsIHttpChannel *iface, nsACString *aRequestMethod)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
|
|
|
|
2009-12-20 23:23:02 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, aRequestMethod);
|
2006-02-09 11:19:13 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetRequestMethod(nsIHttpChannel *iface,
|
|
|
|
const nsACString *aRequestMethod)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
2010-08-03 19:40:20 +00:00
|
|
|
const char *method;
|
|
|
|
unsigned i;
|
2006-02-09 11:19:13 +00:00
|
|
|
|
2010-08-03 19:40:20 +00:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aRequestMethod));
|
2006-02-09 11:19:13 +00:00
|
|
|
|
2010-08-03 19:40:20 +00: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 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetReferrer(nsIHttpChannel *iface, nsIURI **aReferrer)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
|
|
|
|
2009-12-20 23:23:02 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, aReferrer);
|
2006-02-09 11:19:13 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetReferrer(nsIHttpChannel *iface, nsIURI *aReferrer)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
|
|
|
|
2009-12-20 23:23:02 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, aReferrer);
|
2006-02-09 11:19:13 +00:00
|
|
|
|
2010-01-03 23:38:20 +00:00
|
|
|
return NS_OK;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetRequestHeader(nsIHttpChannel *iface,
|
|
|
|
const nsACString *aHeader, nsACString *_retval)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
|
|
|
|
2010-08-03 19:39:49 +00:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_nsacstr(aHeader), _retval);
|
2006-02-09 11:19:13 +00:00
|
|
|
|
2010-08-03 19:39:49 +00:00
|
|
|
return get_channel_http_header(&This->request_headers, aHeader, _retval);
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetRequestHeader(nsIHttpChannel *iface,
|
|
|
|
const nsACString *aHeader, const nsACString *aValue, PRBool aMerge)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
|
|
|
|
2010-08-03 19:40:05 +00:00
|
|
|
TRACE("(%p)->(%s %s %x)\n", This, debugstr_nsacstr(aHeader), debugstr_nsacstr(aValue), aMerge);
|
2006-02-09 11:19:13 +00:00
|
|
|
|
2010-08-03 19:40:05 +00:00
|
|
|
if(aMerge)
|
|
|
|
FIXME("aMerge not supported\n");
|
|
|
|
|
|
|
|
return set_channel_http_header(&This->request_headers, aHeader, aValue);
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_VisitRequestHeaders(nsIHttpChannel *iface,
|
|
|
|
nsIHttpHeaderVisitor *aVisitor)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
|
|
|
|
2009-12-20 23:23:02 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, aVisitor);
|
2006-02-09 11:19:13 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetAllowPipelining(nsIHttpChannel *iface, PRBool *aAllowPipelining)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
|
|
|
|
2009-12-20 23:23:02 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, aAllowPipelining);
|
2006-02-09 11:19:13 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetAllowPipelining(nsIHttpChannel *iface, PRBool aAllowPipelining)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
|
|
|
|
2009-12-20 23:23:02 +00:00
|
|
|
FIXME("(%p)->(%x)\n", This, aAllowPipelining);
|
2006-02-09 11:19:13 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetRedirectionLimit(nsIHttpChannel *iface, PRUint32 *aRedirectionLimit)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
|
|
|
|
2009-12-20 23:23:02 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, aRedirectionLimit);
|
2006-02-09 11:19:13 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetRedirectionLimit(nsIHttpChannel *iface, PRUint32 aRedirectionLimit)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
|
|
|
|
2009-12-20 23:23:02 +00:00
|
|
|
FIXME("(%p)->(%u)\n", This, aRedirectionLimit);
|
2006-02-09 11:19:13 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetResponseStatus(nsIHttpChannel *iface, PRUint32 *aResponseStatus)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aResponseStatus);
|
|
|
|
|
2009-08-11 17:15:07 +00:00
|
|
|
if(This->response_status) {
|
|
|
|
*aResponseStatus = This->response_status;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-12-20 23:23:02 +00:00
|
|
|
WARN("No response status\n");
|
2009-08-11 17:15:07 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetResponseStatusText(nsIHttpChannel *iface,
|
|
|
|
nsACString *aResponseStatusText)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
|
|
|
|
2009-12-20 23:23:02 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, aResponseStatusText);
|
2006-02-09 11:19:13 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetRequestSucceeded(nsIHttpChannel *iface,
|
|
|
|
PRBool *aRequestSucceeded)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
|
|
|
|
2010-04-02 22:31:42 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aRequestSucceeded);
|
2006-02-09 11:19:13 +00:00
|
|
|
|
2010-04-02 22:31:42 +00:00
|
|
|
if(!This->response_status)
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2010-04-05 18:20:59 +00:00
|
|
|
*aRequestSucceeded = This->response_status/100 == 2;
|
2010-04-02 22:31:42 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_GetResponseHeader(nsIHttpChannel *iface,
|
|
|
|
const nsACString *header, nsACString *_retval)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
|
|
|
|
2010-08-03 13:44:56 +00:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_nsacstr(header), _retval);
|
2006-02-09 11:19:13 +00:00
|
|
|
|
2010-08-03 19:38:11 +00:00
|
|
|
return get_channel_http_header(&This->response_headers, header, _retval);
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_SetResponseHeader(nsIHttpChannel *iface,
|
|
|
|
const nsACString *header, const nsACString *value, PRBool merge)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
|
|
|
|
2010-08-03 13:44:56 +00:00
|
|
|
FIXME("(%p)->(%s %s %x)\n", This, debugstr_nsacstr(header), debugstr_nsacstr(value), merge);
|
2006-02-09 11:19:13 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_VisitResponseHeaders(nsIHttpChannel *iface,
|
|
|
|
nsIHttpHeaderVisitor *aVisitor)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
|
|
|
|
2009-12-20 23:23:02 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, aVisitor);
|
2006-02-09 11:19:13 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_IsNoStoreResponse(nsIHttpChannel *iface, PRBool *_retval)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
|
|
|
|
2009-12-20 23:23:02 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, _retval);
|
2006-02-09 11:19:13 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsChannel_IsNoCacheResponse(nsIHttpChannel *iface, PRBool *_retval)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSCHANNEL_THIS(iface);
|
|
|
|
|
2009-12-20 23:23:02 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, _retval);
|
2006-02-09 11:19:13 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef NSCHANNEL_THIS
|
|
|
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2006-02-10 13:49:41 +00:00
|
|
|
#define NSUPCHANNEL_THIS(iface) DEFINE_THIS(nsChannel, UploadChannel, iface)
|
|
|
|
|
|
|
|
static nsresult NSAPI nsUploadChannel_QueryInterface(nsIUploadChannel *iface, nsIIDRef riid,
|
2010-08-02 09:08:26 +00:00
|
|
|
void **result)
|
2006-02-10 13:49:41 +00:00
|
|
|
{
|
|
|
|
nsChannel *This = NSUPCHANNEL_THIS(iface);
|
|
|
|
return nsIChannel_QueryInterface(NSCHANNEL(This), riid, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsUploadChannel_AddRef(nsIUploadChannel *iface)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSUPCHANNEL_THIS(iface);
|
|
|
|
return nsIChannel_AddRef(NSCHANNEL(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsUploadChannel_Release(nsIUploadChannel *iface)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSUPCHANNEL_THIS(iface);
|
|
|
|
return nsIChannel_Release(NSCHANNEL(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsUploadChannel_SetUploadStream(nsIUploadChannel *iface,
|
|
|
|
nsIInputStream *aStream, const nsACString *aContentType, PRInt32 aContentLength)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSUPCHANNEL_THIS(iface);
|
|
|
|
const char *content_type;
|
|
|
|
|
2010-08-03 13:44:56 +00:00
|
|
|
TRACE("(%p)->(%p %s %d)\n", This, aStream, debugstr_nsacstr(aContentType), aContentLength);
|
2006-02-10 13:49:41 +00:00
|
|
|
|
|
|
|
if(This->post_data_stream)
|
|
|
|
nsIInputStream_Release(This->post_data_stream);
|
|
|
|
|
|
|
|
if(aContentType) {
|
2007-12-17 00:38:15 +00:00
|
|
|
nsACString_GetData(aContentType, &content_type);
|
2006-02-10 13:49:41 +00:00
|
|
|
if(*content_type)
|
|
|
|
FIXME("Unsupported aContentType argument: %s\n", debugstr_a(content_type));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(aContentLength != -1)
|
2006-10-05 21:50:39 +00:00
|
|
|
FIXME("Unsupported acontentLength = %d\n", aContentLength);
|
2006-02-10 13:49:41 +00:00
|
|
|
|
2008-11-22 19:06:37 +00:00
|
|
|
if(This->post_data_stream)
|
|
|
|
nsIInputStream_Release(This->post_data_stream);
|
|
|
|
This->post_data_stream = aStream;
|
2006-02-10 13:49:41 +00:00
|
|
|
if(aStream)
|
|
|
|
nsIInputStream_AddRef(aStream);
|
2008-11-22 19:06:37 +00:00
|
|
|
|
2010-08-03 19:40:20 +00:00
|
|
|
This->request_method = METHOD_POST;
|
2006-02-10 13:49:41 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsUploadChannel_GetUploadStream(nsIUploadChannel *iface,
|
|
|
|
nsIInputStream **aUploadStream)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSUPCHANNEL_THIS(iface);
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef NSUPCHANNEL_THIS
|
|
|
|
|
|
|
|
static const nsIUploadChannelVtbl nsUploadChannelVtbl = {
|
|
|
|
nsUploadChannel_QueryInterface,
|
|
|
|
nsUploadChannel_AddRef,
|
|
|
|
nsUploadChannel_Release,
|
|
|
|
nsUploadChannel_SetUploadStream,
|
|
|
|
nsUploadChannel_GetUploadStream
|
|
|
|
};
|
|
|
|
|
2009-08-22 17:37:30 +00:00
|
|
|
#define NSHTTPINTERNAL_THIS(iface) DEFINE_THIS(nsChannel, IHttpChannelInternal, iface)
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_QueryInterface(nsIHttpChannelInternal *iface, nsIIDRef riid,
|
2010-08-02 09:08:26 +00:00
|
|
|
void **result)
|
2009-08-22 17:37:30 +00:00
|
|
|
{
|
|
|
|
nsChannel *This = NSHTTPINTERNAL_THIS(iface);
|
|
|
|
return nsIChannel_QueryInterface(NSCHANNEL(This), riid, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsHttpChannelInternal_AddRef(nsIHttpChannelInternal *iface)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSHTTPINTERNAL_THIS(iface);
|
|
|
|
return nsIChannel_AddRef(NSCHANNEL(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsHttpChannelInternal_Release(nsIHttpChannelInternal *iface)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSHTTPINTERNAL_THIS(iface);
|
|
|
|
return nsIChannel_Release(NSCHANNEL(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetDocumentURI(nsIHttpChannelInternal *iface, nsIURI **aDocumentURI)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSHTTPINTERNAL_THIS(iface);
|
|
|
|
|
2009-12-17 20:25:34 +00:00
|
|
|
FIXME("(%p)->()\n", This);
|
2009-08-22 17:37:30 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_SetDocumentURI(nsIHttpChannelInternal *iface, nsIURI *aDocumentURI)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSHTTPINTERNAL_THIS(iface);
|
|
|
|
|
2009-12-17 20:25:34 +00:00
|
|
|
FIXME("(%p)->()\n", This);
|
2009-08-22 17:37:30 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetRequestVersion(nsIHttpChannelInternal *iface, PRUint32 *major, PRUint32 *minor)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSHTTPINTERNAL_THIS(iface);
|
|
|
|
|
2009-12-17 20:25:34 +00:00
|
|
|
FIXME("(%p)->()\n", This);
|
2009-08-22 17:37:30 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetResponseVersion(nsIHttpChannelInternal *iface, PRUint32 *major, PRUint32 *minor)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSHTTPINTERNAL_THIS(iface);
|
|
|
|
|
2009-12-17 20:25:34 +00:00
|
|
|
FIXME("(%p)->()\n", This);
|
2009-08-22 17:37:30 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_SetCookie(nsIHttpChannelInternal *iface, const char *aCookieHeader)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSHTTPINTERNAL_THIS(iface);
|
|
|
|
|
2009-12-17 20:25:34 +00:00
|
|
|
FIXME("(%p)->()\n", This);
|
2009-08-22 17:37:30 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_SetupFallbackChannel(nsIHttpChannelInternal *iface, const char *aFallbackKey)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSHTTPINTERNAL_THIS(iface);
|
|
|
|
|
2009-12-17 20:25:34 +00:00
|
|
|
FIXME("(%p)->()\n", This);
|
2009-08-22 17:37:30 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_GetForceAllowThirdPartyCookie(nsIHttpChannelInternal *iface, PRBool *aForceThirdPartyCookie)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSHTTPINTERNAL_THIS(iface);
|
|
|
|
|
2009-12-17 20:25:34 +00:00
|
|
|
FIXME("(%p)->()\n", This);
|
2009-08-22 17:37:30 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsHttpChannelInternal_SetForceAllowThirdPartyCookie(nsIHttpChannelInternal *iface, PRBool aForceThirdPartyCookie)
|
|
|
|
{
|
|
|
|
nsChannel *This = NSHTTPINTERNAL_THIS(iface);
|
|
|
|
|
2009-12-17 20:25:34 +00:00
|
|
|
FIXME("(%p)->()\n", This);
|
2009-08-22 17:37:30 +00:00
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef NSHTTPINTERNAL_THIS
|
|
|
|
|
|
|
|
static const nsIHttpChannelInternalVtbl nsHttpChannelInternalVtbl = {
|
|
|
|
nsHttpChannelInternal_QueryInterface,
|
|
|
|
nsHttpChannelInternal_AddRef,
|
|
|
|
nsHttpChannelInternal_Release,
|
|
|
|
nsHttpChannelInternal_GetDocumentURI,
|
|
|
|
nsHttpChannelInternal_SetDocumentURI,
|
|
|
|
nsHttpChannelInternal_GetRequestVersion,
|
|
|
|
nsHttpChannelInternal_GetResponseVersion,
|
|
|
|
nsHttpChannelInternal_SetCookie,
|
|
|
|
nsHttpChannelInternal_SetupFallbackChannel,
|
|
|
|
nsHttpChannelInternal_GetForceAllowThirdPartyCookie,
|
|
|
|
nsHttpChannelInternal_SetForceAllowThirdPartyCookie
|
|
|
|
};
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
#define NSURI_THIS(iface) DEFINE_THIS(nsWineURI, IURL, iface)
|
2006-02-13 12:26:00 +00:00
|
|
|
|
2010-08-02 09:08:26 +00:00
|
|
|
static nsresult NSAPI nsURI_QueryInterface(nsIURL *iface, nsIIDRef riid, void **result)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-02-09 11:18:18 +00:00
|
|
|
|
|
|
|
*result = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_nsISupports, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsISupports %p)\n", This, result);
|
|
|
|
*result = NSURI(This);
|
|
|
|
}else if(IsEqualGUID(&IID_nsIURI, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIURI %p)\n", This, result);
|
|
|
|
*result = NSURI(This);
|
2009-08-27 09:31:14 +00:00
|
|
|
}else if(IsEqualGUID(&IID_nsIURL, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIURL %p)\n", This, result);
|
2010-02-21 20:10:15 +00:00
|
|
|
*result = NSURL(This);
|
|
|
|
}else if(IsEqualGUID(&IID_nsWineURI, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsWineURI %p)\n", This, result);
|
|
|
|
*result = This;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*result) {
|
|
|
|
nsIURI_AddRef(NSURI(This));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), result);
|
2006-08-09 14:41:47 +00:00
|
|
|
return This->uri ? nsIURI_QueryInterface(This->uri, riid, result) : NS_NOINTERFACE;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsrefcnt NSAPI nsURI_AddRef(nsIURL *iface)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-02-09 11:18:18 +00:00
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2006-10-05 21:50:39 +00:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2006-02-09 11:18:18 +00:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsrefcnt NSAPI nsURI_Release(nsIURL *iface)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-02-09 11:18:18 +00:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2006-10-05 21:50:39 +00:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2006-02-09 11:18:18 +00:00
|
|
|
|
|
|
|
if(!ref) {
|
2009-10-26 22:02:50 +00:00
|
|
|
if(This->window_ref)
|
|
|
|
windowref_release(This->window_ref);
|
2006-02-15 10:51:44 +00:00
|
|
|
if(This->container)
|
|
|
|
nsIWebBrowserChrome_Release(NSWBCHROME(This->container));
|
2009-08-27 09:31:14 +00:00
|
|
|
if(This->nsurl)
|
|
|
|
nsIURL_Release(This->nsurl);
|
2006-07-07 13:17:27 +00:00
|
|
|
if(This->uri)
|
|
|
|
nsIURI_Release(This->uri);
|
2007-12-05 20:52:31 +00:00
|
|
|
heap_free(This->wine_url);
|
|
|
|
heap_free(This);
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_GetSpec(nsIURL *iface, nsACString *aSpec)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2006-02-09 11:18:18 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aSpec);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2007-02-10 17:59:38 +00:00
|
|
|
if(This->use_wine_url) {
|
2007-08-14 20:36:10 +00:00
|
|
|
char speca[INTERNET_MAX_URL_LENGTH] = "wine:";
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, This->wine_url, -1, speca+5, sizeof(speca)-5, NULL, NULL);
|
2007-02-09 19:17:16 +00:00
|
|
|
nsACString_SetData(aSpec, speca);
|
|
|
|
|
2006-08-09 14:40:50 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-02-10 18:04:32 +00:00
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_GetSpec(This->uri, aSpec);
|
|
|
|
|
2007-02-10 17:59:38 +00:00
|
|
|
TRACE("returning error\n");
|
2006-07-07 13:17:27 +00:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_SetSpec(nsIURL *iface, const nsACString *aSpec)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2010-08-03 13:44:56 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, debugstr_nsacstr(aSpec));
|
2006-07-07 13:17:27 +00:00
|
|
|
|
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_SetSpec(This->uri, aSpec);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_GetPrePath(nsIURL *iface, nsACString *aPrePath)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2006-02-09 11:18:18 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aPrePath);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_GetPrePath(This->uri, aPrePath);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_GetScheme(nsIURL *iface, nsACString *aScheme)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2006-02-09 11:18:18 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aScheme);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2009-11-30 17:01:47 +00:00
|
|
|
if(This->use_wine_url) {
|
2007-02-10 17:59:38 +00:00
|
|
|
/*
|
|
|
|
* For Gecko we set scheme to unknown so it won't be handled
|
|
|
|
* as any special case.
|
|
|
|
*/
|
|
|
|
nsACString_SetData(aScheme, "wine");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-07-07 13:17:27 +00:00
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_GetScheme(This->uri, aScheme);
|
|
|
|
|
2007-02-10 17:59:38 +00:00
|
|
|
TRACE("returning error\n");
|
2006-07-07 13:17:27 +00:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_SetScheme(nsIURL *iface, const nsACString *aScheme)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2010-08-03 13:44:56 +00:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aScheme));
|
2006-07-07 13:17:27 +00:00
|
|
|
|
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_SetScheme(This->uri, aScheme);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_GetUserPass(nsIURL *iface, nsACString *aUserPass)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2006-02-09 11:18:18 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aUserPass);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_GetUserPass(This->uri, aUserPass);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_SetUserPass(nsIURL *iface, const nsACString *aUserPass)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2010-08-03 13:44:56 +00:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aUserPass));
|
2006-07-07 13:17:27 +00:00
|
|
|
|
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_SetUserPass(This->uri, aUserPass);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_GetUsername(nsIURL *iface, nsACString *aUsername)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2006-02-09 11:18:18 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aUsername);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_GetUsername(This->uri, aUsername);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_SetUsername(nsIURL *iface, const nsACString *aUsername)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2010-08-03 13:44:56 +00:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aUsername));
|
2006-07-07 13:17:27 +00:00
|
|
|
|
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_SetUsername(This->uri, aUsername);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_GetPassword(nsIURL *iface, nsACString *aPassword)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2006-02-09 11:18:18 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aPassword);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_GetPassword(This->uri, aPassword);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_SetPassword(nsIURL *iface, const nsACString *aPassword)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2010-08-03 13:44:56 +00:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aPassword));
|
2006-07-07 13:17:27 +00:00
|
|
|
|
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_SetPassword(This->uri, aPassword);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_GetHostPort(nsIURL *iface, nsACString *aHostPort)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2006-02-09 11:18:18 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aHostPort);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_GetHostPort(This->uri, aHostPort);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_SetHostPort(nsIURL *iface, const nsACString *aHostPort)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2010-08-03 13:44:56 +00:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aHostPort));
|
2006-07-07 13:17:27 +00:00
|
|
|
|
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_SetHostPort(This->uri, aHostPort);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_GetHost(nsIURL *iface, nsACString *aHost)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2006-02-09 11:18:18 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aHost);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_GetHost(This->uri, aHost);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_SetHost(nsIURL *iface, const nsACString *aHost)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2010-08-03 13:44:56 +00:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aHost));
|
2006-07-07 13:17:27 +00:00
|
|
|
|
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_SetHost(This->uri, aHost);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_GetPort(nsIURL *iface, PRInt32 *aPort)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2006-02-09 11:18:18 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aPort);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_GetPort(This->uri, aPort);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_SetPort(nsIURL *iface, PRInt32 aPort)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2006-10-05 21:50:39 +00:00
|
|
|
TRACE("(%p)->(%d)\n", This, aPort);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_SetPort(This->uri, aPort);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_GetPath(nsIURL *iface, nsACString *aPath)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2006-02-09 11:18:18 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aPath);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_GetPath(This->uri, aPath);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_SetPath(nsIURL *iface, const nsACString *aPath)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2008-02-01 14:31:19 +00:00
|
|
|
const char *path;
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2010-08-03 13:44:56 +00:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aPath));
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2010-08-03 13:44:56 +00:00
|
|
|
nsACString_GetData(aPath, &path);
|
2008-02-01 14:31:19 +00:00
|
|
|
if(This->wine_url) {
|
|
|
|
WCHAR new_url[INTERNET_MAX_URL_LENGTH];
|
|
|
|
DWORD size = sizeof(new_url)/sizeof(WCHAR);
|
|
|
|
LPWSTR pathw;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
pathw = heap_strdupAtoW(path);
|
|
|
|
hres = UrlCombineW(This->wine_url, pathw, new_url, &size, 0);
|
|
|
|
heap_free(pathw);
|
|
|
|
if(SUCCEEDED(hres))
|
2010-02-21 20:07:43 +00:00
|
|
|
set_wine_url(This, new_url);
|
2008-02-01 14:31:19 +00:00
|
|
|
else
|
|
|
|
WARN("UrlCombine failed: %08x\n", hres);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!This->uri)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
return nsIURI_SetPath(This->uri, aPath);
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_Equals(nsIURL *iface, nsIURI *other, PRBool *_retval)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2010-02-21 20:07:43 +00:00
|
|
|
nsWineURI *wine_uri;
|
2008-02-28 11:41:40 +00:00
|
|
|
nsresult nsres;
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2006-02-09 11:18:18 +00:00
|
|
|
TRACE("(%p)->(%p %p)\n", This, other, _retval);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_Equals(This->uri, other, _retval);
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
nsres = nsIURI_QueryInterface(other, &IID_nsWineURI, (void**)&wine_uri);
|
2008-02-28 11:41:40 +00:00
|
|
|
if(NS_FAILED(nsres)) {
|
2010-02-21 20:10:15 +00:00
|
|
|
TRACE("Could not get nsWineURI interface\n");
|
2008-02-28 11:41:40 +00:00
|
|
|
*_retval = FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:07:43 +00:00
|
|
|
*_retval = wine_uri->wine_url && !UrlCompareW(This->wine_url, wine_uri->wine_url, TRUE);
|
|
|
|
nsIURI_Release(NSURI(wine_uri));
|
2008-02-28 11:41:40 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_SchemeIs(nsIURL *iface, const char *scheme, PRBool *_retval)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2006-02-09 11:18:18 +00:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_a(scheme), _retval);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2007-02-13 17:08:09 +00:00
|
|
|
if(This->use_wine_url) {
|
|
|
|
WCHAR buf[INTERNET_MAX_SCHEME_LENGTH];
|
|
|
|
int len = MultiByteToWideChar(CP_ACP, 0, scheme, -1, buf, sizeof(buf)/sizeof(WCHAR))-1;
|
|
|
|
|
2008-10-18 15:08:41 +00:00
|
|
|
*_retval = lstrlenW(This->wine_url) > len
|
2007-02-13 17:08:09 +00:00
|
|
|
&& This->wine_url[len] == ':'
|
|
|
|
&& !memcmp(buf, This->wine_url, len*sizeof(WCHAR));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-07-07 13:17:27 +00:00
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_SchemeIs(This->uri, scheme, _retval);
|
|
|
|
|
2007-02-13 17:08:09 +00:00
|
|
|
TRACE("returning error\n");
|
2006-07-07 13:17:27 +00:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_Clone(nsIURL *iface, nsIURI **_retval)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2008-02-28 11:41:22 +00:00
|
|
|
nsIURI *nsuri = NULL;
|
2010-02-21 20:06:51 +00:00
|
|
|
nsWineURI *wine_uri;
|
2008-02-28 11:41:22 +00:00
|
|
|
nsresult nsres;
|
2006-02-24 19:31:12 +00:00
|
|
|
|
2006-02-09 11:18:18 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, _retval);
|
2006-02-24 19:31:12 +00:00
|
|
|
|
2006-07-07 13:17:27 +00:00
|
|
|
if(This->uri) {
|
2008-02-28 11:41:22 +00:00
|
|
|
nsres = nsIURI_Clone(This->uri, &nsuri);
|
2006-07-07 13:17:27 +00:00
|
|
|
if(NS_FAILED(nsres)) {
|
2006-10-05 21:50:39 +00:00
|
|
|
WARN("Clone failed: %08x\n", nsres);
|
2006-07-07 13:17:27 +00:00
|
|
|
return nsres;
|
|
|
|
}
|
2008-02-28 11:41:22 +00:00
|
|
|
}
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2009-10-26 22:02:50 +00:00
|
|
|
nsres = create_uri(nsuri, This->window_ref ? This->window_ref->window : NULL, This->container, &wine_uri);
|
2008-02-28 11:41:22 +00:00
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
WARN("create_uri failed: %08x\n", nsres);
|
2007-02-10 16:36:58 +00:00
|
|
|
return nsres;
|
2006-02-24 19:31:12 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:07:43 +00:00
|
|
|
set_wine_url(wine_uri, This->wine_url);
|
|
|
|
|
2010-02-21 20:06:51 +00:00
|
|
|
*_retval = NSURI(wine_uri);
|
2010-02-21 20:07:43 +00:00
|
|
|
return NS_OK;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_Resolve(nsIURL *iface, const nsACString *arelativePath,
|
2006-02-09 11:18:18 +00:00
|
|
|
nsACString *_retval)
|
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2010-08-03 13:44:56 +00:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_nsacstr(arelativePath), _retval);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_Resolve(This->uri, arelativePath, _retval);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_GetAsciiSpec(nsIURL *iface, nsACString *aAsciiSpec)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2006-02-09 11:18:18 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aAsciiSpec);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2007-08-14 20:35:19 +00:00
|
|
|
if(This->use_wine_url)
|
2007-02-10 18:02:02 +00:00
|
|
|
return nsIURI_GetSpec(NSURI(This), aAsciiSpec);
|
|
|
|
|
2006-07-07 13:17:27 +00:00
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_GetAsciiSpec(This->uri, aAsciiSpec);
|
|
|
|
|
2007-02-10 18:02:02 +00:00
|
|
|
TRACE("returning error\n");
|
2006-07-07 13:17:27 +00:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_GetAsciiHost(nsIURL *iface, nsACString *aAsciiHost)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2006-02-09 11:18:18 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aAsciiHost);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_GetAsciiHost(This->uri, aAsciiHost);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURI_GetOriginCharset(nsIURL *iface, nsACString *aOriginCharset)
|
2006-02-09 11:18:18 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2006-02-09 11:18:18 +00:00
|
|
|
TRACE("(%p)->(%p)\n", This, aOriginCharset);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
|
|
|
if(This->uri)
|
|
|
|
return nsIURI_GetOriginCharset(This->uri, aOriginCharset);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURL_GetFilePath(nsIURL *iface, nsACString *aFilePath)
|
2009-08-27 09:31:14 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2009-08-27 09:31:14 +00:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aFilePath);
|
|
|
|
|
|
|
|
if(This->nsurl)
|
|
|
|
return nsIURL_GetFilePath(This->nsurl, aFilePath);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURL_SetFilePath(nsIURL *iface, const nsACString *aFilePath)
|
2009-08-27 09:31:14 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2009-08-27 09:31:14 +00:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aFilePath));
|
|
|
|
|
|
|
|
if(This->nsurl)
|
|
|
|
return nsIURL_SetFilePath(This->nsurl, aFilePath);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURL_GetParam(nsIURL *iface, nsACString *aParam)
|
2009-08-27 09:31:14 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2009-08-27 09:31:14 +00:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aParam);
|
|
|
|
|
|
|
|
if(This->nsurl)
|
|
|
|
return nsIURL_GetParam(This->nsurl, aParam);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURL_SetParam(nsIURL *iface, const nsACString *aParam)
|
2009-08-27 09:31:14 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2009-08-27 09:31:14 +00:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aParam));
|
|
|
|
|
|
|
|
if(This->nsurl)
|
|
|
|
return nsIURL_SetParam(This->nsurl, aParam);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURL_GetQuery(nsIURL *iface, nsACString *aQuery)
|
2009-08-27 09:31:14 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2009-08-27 09:31:14 +00:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aQuery);
|
|
|
|
|
|
|
|
if(This->nsurl)
|
|
|
|
return nsIURL_GetQuery(This->nsurl, aQuery);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURL_SetQuery(nsIURL *iface, const nsACString *aQuery)
|
2009-08-27 09:31:14 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2009-08-26 21:14:20 +00:00
|
|
|
const WCHAR *ptr1, *ptr2;
|
|
|
|
const char *query;
|
|
|
|
WCHAR *new_url, *ptr;
|
|
|
|
DWORD len, size;
|
2009-08-27 09:31:14 +00:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aQuery));
|
|
|
|
|
|
|
|
if(This->nsurl)
|
2009-08-26 21:14:20 +00:00
|
|
|
nsIURL_SetQuery(This->nsurl, aQuery);
|
2009-08-27 09:31:14 +00:00
|
|
|
|
2009-08-26 21:14:20 +00:00
|
|
|
if(!This->wine_url)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsACString_GetData(aQuery, &query);
|
|
|
|
size = len = MultiByteToWideChar(CP_ACP, 0, query, -1, NULL, 0);
|
|
|
|
ptr1 = strchrW(This->wine_url, '?');
|
|
|
|
if(ptr1) {
|
|
|
|
size += ptr1-This->wine_url;
|
|
|
|
ptr2 = strchrW(ptr1, '#');
|
|
|
|
if(ptr2)
|
|
|
|
size += strlenW(ptr2);
|
|
|
|
}else {
|
|
|
|
ptr1 = This->wine_url + strlenW(This->wine_url);
|
|
|
|
ptr2 = NULL;
|
|
|
|
size += strlenW(This->wine_url);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*query)
|
|
|
|
size++;
|
|
|
|
|
|
|
|
new_url = heap_alloc(size*sizeof(WCHAR));
|
|
|
|
memcpy(new_url, This->wine_url, (ptr1-This->wine_url)*sizeof(WCHAR));
|
|
|
|
ptr = new_url + (ptr1-This->wine_url);
|
|
|
|
if(*query) {
|
|
|
|
*ptr++ = '?';
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, query, -1, ptr, len);
|
|
|
|
ptr += len-1;
|
|
|
|
}
|
|
|
|
if(ptr2)
|
|
|
|
strcpyW(ptr, ptr2);
|
|
|
|
else
|
|
|
|
*ptr = 0;
|
|
|
|
|
|
|
|
TRACE("setting %s\n", debugstr_w(new_url));
|
|
|
|
|
|
|
|
heap_free(This->wine_url);
|
|
|
|
This->wine_url = new_url;
|
|
|
|
return NS_OK;
|
2009-08-27 09:31:14 +00:00
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURL_GetRef(nsIURL *iface, nsACString *aRef)
|
2009-08-27 09:31:14 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2009-08-27 09:31:14 +00:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aRef);
|
|
|
|
|
|
|
|
if(This->nsurl)
|
|
|
|
return nsIURL_GetRef(This->nsurl, aRef);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURL_SetRef(nsIURL *iface, const nsACString *aRef)
|
2009-08-27 09:31:14 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2009-11-01 18:20:04 +00:00
|
|
|
const char *refa;
|
2009-08-27 09:31:14 +00:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aRef));
|
|
|
|
|
|
|
|
if(This->nsurl)
|
|
|
|
return nsIURL_SetRef(This->nsurl, aRef);
|
|
|
|
|
2009-11-01 18:20:04 +00:00
|
|
|
nsACString_GetData(aRef, &refa);
|
|
|
|
if(!*refa)
|
|
|
|
return NS_OK;
|
|
|
|
|
2009-08-27 09:31:14 +00:00
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURL_GetDirectory(nsIURL *iface, nsACString *aDirectory)
|
2009-08-27 09:31:14 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2009-08-27 09:31:14 +00:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aDirectory);
|
|
|
|
|
|
|
|
if(This->nsurl)
|
|
|
|
return nsIURL_GetDirectory(This->nsurl, aDirectory);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURL_SetDirectory(nsIURL *iface, const nsACString *aDirectory)
|
2009-08-27 09:31:14 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2009-08-27 09:31:14 +00:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aDirectory));
|
|
|
|
|
|
|
|
if(This->nsurl)
|
|
|
|
return nsIURL_SetDirectory(This->nsurl, aDirectory);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURL_GetFileName(nsIURL *iface, nsACString *aFileName)
|
2009-08-27 09:31:14 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2009-08-27 09:31:14 +00: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 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURL_SetFileName(nsIURL *iface, const nsACString *aFileName)
|
2009-08-27 09:31:14 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2009-08-27 09:31:14 +00:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aFileName));
|
|
|
|
|
|
|
|
if(This->nsurl)
|
|
|
|
return nsIURL_SetFileName(This->nsurl, aFileName);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURL_GetFileBaseName(nsIURL *iface, nsACString *aFileBaseName)
|
2009-08-27 09:31:14 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2009-08-27 09:31:14 +00: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 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURL_SetFileBaseName(nsIURL *iface, const nsACString *aFileBaseName)
|
2009-08-27 09:31:14 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2009-08-27 09:31:14 +00:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aFileBaseName));
|
|
|
|
|
|
|
|
if(This->nsurl)
|
|
|
|
return nsIURL_SetFileBaseName(This->nsurl, aFileBaseName);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURL_GetFileExtension(nsIURL *iface, nsACString *aFileExtension)
|
2009-08-27 09:31:14 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2009-08-27 09:31:14 +00:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aFileExtension);
|
|
|
|
|
|
|
|
if(This->nsurl)
|
|
|
|
return nsIURL_GetFileExtension(This->nsurl, aFileExtension);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURL_SetFileExtension(nsIURL *iface, const nsACString *aFileExtension)
|
2009-08-27 09:31:14 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2009-08-27 09:31:14 +00:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aFileExtension));
|
|
|
|
|
|
|
|
if(This->nsurl)
|
|
|
|
return nsIURL_SetFileExtension(This->nsurl, aFileExtension);
|
|
|
|
|
|
|
|
FIXME("default action not implemented\n");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURL_GetCommonBaseSpec(nsIURL *iface, nsIURI *aURIToCompare, nsACString *_retval)
|
2009-08-27 09:31:14 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2009-08-27 09:31:14 +00: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 20:10:15 +00:00
|
|
|
static nsresult NSAPI nsURL_GetRelativeSpec(nsIURL *iface, nsIURI *aURIToCompare, nsACString *_retval)
|
2009-08-27 09:31:14 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *This = NSURI_THIS(iface);
|
2009-08-27 09:31:14 +00: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;
|
|
|
|
}
|
|
|
|
|
2006-02-09 11:18:18 +00:00
|
|
|
#undef NSURI_THIS
|
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
static const nsIURLVtbl nsURLVtbl = {
|
2006-02-09 11:18:18 +00: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,
|
2009-08-27 09:31:14 +00:00
|
|
|
nsURL_GetFilePath,
|
|
|
|
nsURL_SetFilePath,
|
|
|
|
nsURL_GetParam,
|
|
|
|
nsURL_SetParam,
|
|
|
|
nsURL_GetQuery,
|
|
|
|
nsURL_SetQuery,
|
|
|
|
nsURL_GetRef,
|
|
|
|
nsURL_SetRef,
|
|
|
|
nsURL_GetDirectory,
|
|
|
|
nsURL_SetDirectory,
|
|
|
|
nsURL_GetFileName,
|
|
|
|
nsURL_SetFileName,
|
|
|
|
nsURL_GetFileBaseName,
|
|
|
|
nsURL_SetFileBaseName,
|
|
|
|
nsURL_GetFileExtension,
|
|
|
|
nsURL_SetFileExtension,
|
|
|
|
nsURL_GetCommonBaseSpec,
|
2010-02-21 20:09:11 +00:00
|
|
|
nsURL_GetRelativeSpec
|
2006-02-09 11:18:18 +00:00
|
|
|
};
|
|
|
|
|
2010-02-21 20:06:51 +00:00
|
|
|
static nsresult create_uri(nsIURI *uri, HTMLWindow *window, NSContainer *container, nsWineURI **_retval)
|
2006-02-24 19:31:12 +00:00
|
|
|
{
|
2010-02-21 20:04:29 +00:00
|
|
|
nsWineURI *ret = heap_alloc_zero(sizeof(nsWineURI));
|
2006-02-24 19:31:12 +00:00
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
ret->lpIURLVtbl = &nsURLVtbl;
|
2006-02-24 19:31:12 +00:00
|
|
|
ret->ref = 1;
|
|
|
|
ret->uri = uri;
|
|
|
|
|
2010-02-21 20:09:11 +00:00
|
|
|
set_uri_nscontainer(ret, container);
|
2010-02-21 20:08:39 +00:00
|
|
|
set_uri_window(ret, window);
|
2006-02-24 19:31:12 +00:00
|
|
|
|
2009-08-27 09:31:14 +00:00
|
|
|
if(uri)
|
|
|
|
nsIURI_QueryInterface(uri, &IID_nsIURL, (void**)&ret->nsurl);
|
|
|
|
|
2006-02-24 19:31:12 +00:00
|
|
|
TRACE("retval=%p\n", ret);
|
2010-02-21 20:06:51 +00:00
|
|
|
*_retval = ret;
|
2006-02-24 19:31:12 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-02-21 20:06:51 +00:00
|
|
|
HRESULT create_doc_uri(HTMLWindow *window, WCHAR *url, nsWineURI **ret)
|
2009-11-30 17:01:31 +00:00
|
|
|
{
|
2010-02-21 20:06:51 +00:00
|
|
|
nsWineURI *uri;
|
2009-11-30 17:01:31 +00:00
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = create_uri(NULL, window, window->doc_obj->nscontainer, &uri);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return E_FAIL;
|
|
|
|
|
2010-02-21 20:07:43 +00:00
|
|
|
set_wine_url(uri, url);
|
2010-02-21 20:06:51 +00:00
|
|
|
uri->is_doc_uri = TRUE;
|
2009-11-30 17:01:31 +00:00
|
|
|
|
|
|
|
*ret = uri;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-05-12 14:12:04 +00:00
|
|
|
typedef struct {
|
|
|
|
const nsIProtocolHandlerVtbl *lpProtocolHandlerVtbl;
|
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
nsIProtocolHandler *nshandler;
|
|
|
|
} nsProtocolHandler;
|
|
|
|
|
|
|
|
#define NSPROTHANDLER(x) ((nsIProtocolHandler*) &(x)->lpProtocolHandlerVtbl)
|
|
|
|
|
|
|
|
#define NSPROTHANDLER_THIS(iface) DEFINE_THIS(nsProtocolHandler, ProtocolHandler, iface)
|
|
|
|
|
|
|
|
static nsresult NSAPI nsProtocolHandler_QueryInterface(nsIProtocolHandler *iface, nsIIDRef riid,
|
2010-08-02 09:08:26 +00:00
|
|
|
void **result)
|
2007-05-12 14:12:04 +00:00
|
|
|
{
|
|
|
|
nsProtocolHandler *This = NSPROTHANDLER_THIS(iface);
|
|
|
|
|
|
|
|
*result = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_nsISupports, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsISupports %p)\n", This, result);
|
|
|
|
*result = NSPROTHANDLER(This);
|
|
|
|
}else if(IsEqualGUID(&IID_nsIProtocolHandler, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIProtocolHandler %p)\n", This, result);
|
|
|
|
*result = NSPROTHANDLER(This);
|
|
|
|
}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 12:00:40 +00:00
|
|
|
WARN("(%s %p)\n", debugstr_guid(riid), result);
|
2007-05-12 14:12:04 +00:00
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsProtocolHandler_AddRef(nsIProtocolHandler *iface)
|
|
|
|
{
|
|
|
|
nsProtocolHandler *This = NSPROTHANDLER_THIS(iface);
|
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsProtocolHandler_Release(nsIProtocolHandler *iface)
|
|
|
|
{
|
|
|
|
nsProtocolHandler *This = NSPROTHANDLER_THIS(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
if(!ref) {
|
|
|
|
if(This->nshandler)
|
|
|
|
nsIProtocolHandler_Release(This->nshandler);
|
2007-12-05 20:52:31 +00:00
|
|
|
heap_free(This);
|
2007-05-12 14:12:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsProtocolHandler_GetScheme(nsIProtocolHandler *iface, nsACString *aScheme)
|
|
|
|
{
|
|
|
|
nsProtocolHandler *This = NSPROTHANDLER_THIS(iface);
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
nsProtocolHandler *This = NSPROTHANDLER_THIS(iface);
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
nsProtocolHandler *This = NSPROTHANDLER_THIS(iface);
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
nsProtocolHandler *This = NSPROTHANDLER_THIS(iface);
|
|
|
|
|
2010-08-03 13:44:56 +00:00
|
|
|
TRACE("((%p)->%s %s %p %p)\n", This, debugstr_nsacstr(aSpec), debugstr_a(aOriginCharset),
|
|
|
|
aBaseURI, _retval);
|
2007-05-12 14:12:04 +00: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)
|
|
|
|
{
|
|
|
|
nsProtocolHandler *This = NSPROTHANDLER_THIS(iface);
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
nsProtocolHandler *This = NSPROTHANDLER_THIS(iface);
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef NSPROTHANDLER_THIS
|
|
|
|
|
|
|
|
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 20:52:31 +00:00
|
|
|
nsProtocolHandler *ret = heap_alloc(sizeof(nsProtocolHandler));
|
2007-05-12 14:12:04 +00:00
|
|
|
|
|
|
|
ret->lpProtocolHandlerVtbl = &nsProtocolHandlerVtbl;
|
|
|
|
ret->ref = 1;
|
|
|
|
ret->nshandler = nshandler;
|
|
|
|
|
|
|
|
return NSPROTHANDLER(ret);
|
|
|
|
}
|
|
|
|
|
2010-08-02 09:08:26 +00:00
|
|
|
static nsresult NSAPI nsIOService_QueryInterface(nsIIOService*,nsIIDRef,void**);
|
2006-02-09 11:17:08 +00: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 14:12:04 +00:00
|
|
|
nsIExternalProtocolHandler *nsexthandler;
|
|
|
|
nsIProtocolHandler *nshandler;
|
|
|
|
nsresult nsres;
|
|
|
|
|
2006-02-09 11:17:08 +00:00
|
|
|
TRACE("(%s %p)\n", debugstr_a(aScheme), _retval);
|
2007-05-12 14:12:04 +00: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 11:17:08 +00: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 15:37:33 +00:00
|
|
|
static BOOL is_gecko_special_uri(const char *spec)
|
|
|
|
{
|
2009-08-22 17:37:59 +00:00
|
|
|
static const char *special_schemes[] = {"chrome:", "jar:", "resource:", "javascript:", "wyciwyg:"};
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2007-08-12 15:37:33 +00:00
|
|
|
}
|
|
|
|
|
2006-02-09 11:17:08 +00:00
|
|
|
static nsresult NSAPI nsIOService_NewURI(nsIIOService *iface, const nsACString *aSpec,
|
|
|
|
const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval)
|
|
|
|
{
|
2010-02-21 20:07:43 +00:00
|
|
|
nsWineURI *wine_uri, *base_wine_uri = NULL;
|
2006-02-09 11:18:18 +00:00
|
|
|
const char *spec = NULL;
|
2009-10-26 22:02:50 +00:00
|
|
|
HTMLWindow *window = NULL;
|
2006-07-07 13:17:27 +00:00
|
|
|
nsIURI *uri = NULL;
|
2007-02-09 19:19:13 +00:00
|
|
|
LPCWSTR base_wine_url = NULL;
|
2010-04-22 15:48:12 +00:00
|
|
|
nsACString spec_str;
|
2006-02-09 11:18:18 +00:00
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
|
2010-08-03 13:44:56 +00:00
|
|
|
TRACE("(%s %s %p %p)\n", debugstr_nsacstr(aSpec), debugstr_a(aOriginCharset),
|
2006-02-09 11:18:18 +00:00
|
|
|
aBaseURI, _retval);
|
|
|
|
|
2010-08-03 13:44:56 +00:00
|
|
|
nsACString_GetData(aSpec, &spec);
|
2007-08-12 15:37:33 +00:00
|
|
|
if(is_gecko_special_uri(spec))
|
|
|
|
return nsIIOService_NewURI(nsio, aSpec, aOriginCharset, aBaseURI, _retval);
|
|
|
|
|
2010-04-03 16:07:07 +00:00
|
|
|
if(!strncmp(spec, "wine:", 5))
|
2007-08-14 20:36:10 +00:00
|
|
|
spec += 5;
|
|
|
|
|
2006-02-09 11:18:18 +00:00
|
|
|
if(aBaseURI) {
|
2009-12-01 21:50:00 +00:00
|
|
|
PARSEDURLA parsed_url = {sizeof(PARSEDURLA)};
|
2006-02-09 11:18:18 +00:00
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
nsres = nsIURI_QueryInterface(aBaseURI, &IID_nsWineURI, (void**)&base_wine_uri);
|
2006-02-09 11:18:18 +00:00
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
2010-02-21 20:07:43 +00:00
|
|
|
base_wine_url = base_wine_uri->wine_url;
|
2010-02-21 20:08:39 +00:00
|
|
|
if(base_wine_uri->window_ref && base_wine_uri->window_ref->window) {
|
|
|
|
window = base_wine_uri->window_ref->window;
|
|
|
|
IHTMLWindow2_AddRef(HTMLWINDOW2(window));
|
|
|
|
}
|
2009-12-01 21:50:00 +00:00
|
|
|
TRACE("base url: %s window: %p\n", debugstr_w(base_wine_url), window);
|
|
|
|
}else if(FAILED(ParseURLA(spec, &parsed_url))) {
|
|
|
|
TRACE("not wraping\n");
|
|
|
|
return nsIIOService_NewURI(nsio, aSpec, aOriginCharset, aBaseURI, _retval);
|
2006-02-09 11:18:18 +00:00
|
|
|
}else {
|
2010-02-21 20:10:15 +00:00
|
|
|
WARN("Could not get base nsWineURI: %08x\n", nsres);
|
2006-02-09 11:18:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-22 15:48:12 +00:00
|
|
|
nsACString_InitDepend(&spec_str, spec);
|
2010-07-30 13:37:26 +00:00
|
|
|
nsres = nsIIOService_NewURI(nsio, &spec_str, aOriginCharset, aBaseURI, &uri);
|
2010-04-22 15:48:12 +00:00
|
|
|
nsACString_Finish(&spec_str);
|
2006-07-07 13:17:27 +00:00
|
|
|
if(NS_FAILED(nsres))
|
2006-10-05 21:50:39 +00:00
|
|
|
TRACE("NewURI failed: %08x\n", nsres);
|
2006-07-07 13:17:27 +00:00
|
|
|
|
2009-10-26 22:02:50 +00:00
|
|
|
nsres = create_uri(uri, window, NULL, &wine_uri);
|
2007-02-09 19:19:13 +00:00
|
|
|
*_retval = (nsIURI*)wine_uri;
|
2006-06-22 14:09:29 +00:00
|
|
|
|
2009-10-26 22:02:50 +00:00
|
|
|
if(window)
|
|
|
|
IHTMLWindow2_Release(HTMLWINDOW2(window));
|
2006-06-22 14:09:29 +00:00
|
|
|
|
2007-02-09 19:19:13 +00:00
|
|
|
if(base_wine_url) {
|
|
|
|
WCHAR url[INTERNET_MAX_URL_LENGTH], rel_url[INTERNET_MAX_URL_LENGTH];
|
2006-08-09 14:42:37 +00:00
|
|
|
DWORD len;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2007-08-14 20:36:10 +00:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, spec, -1, rel_url, sizeof(rel_url)/sizeof(WCHAR));
|
2006-08-09 14:42:37 +00:00
|
|
|
|
2007-02-09 19:19:13 +00:00
|
|
|
hres = CoInternetCombineUrl(base_wine_url, rel_url,
|
|
|
|
URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO,
|
|
|
|
url, sizeof(url)/sizeof(WCHAR), &len, 0);
|
|
|
|
if(SUCCEEDED(hres))
|
2010-02-21 20:06:51 +00:00
|
|
|
set_wine_url(wine_uri, url);
|
2007-02-09 19:19:13 +00:00
|
|
|
else
|
2007-08-14 20:36:10 +00:00
|
|
|
WARN("CoCombineUrl failed: %08x\n", hres);
|
2010-04-03 16:07:07 +00:00
|
|
|
}else {
|
2007-08-14 20:36:10 +00:00
|
|
|
WCHAR url[INTERNET_MAX_URL_LENGTH];
|
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, spec, -1, url, sizeof(url)/sizeof(WCHAR));
|
2010-02-21 20:06:51 +00:00
|
|
|
set_wine_url(wine_uri, url);
|
2006-08-09 14:42:37 +00:00
|
|
|
}
|
|
|
|
|
2007-02-09 19:19:13 +00:00
|
|
|
if(base_wine_uri)
|
2010-02-21 20:07:43 +00:00
|
|
|
nsIURI_Release(NSURI(base_wine_uri));
|
2007-02-09 19:19:13 +00:00
|
|
|
|
2006-06-22 14:09:29 +00:00
|
|
|
return nsres;
|
2006-02-09 11:17:08 +00: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)
|
|
|
|
{
|
2009-12-01 21:50:19 +00:00
|
|
|
PARSEDURLW parsed_url = {sizeof(PARSEDURLW)};
|
2006-02-09 11:19:13 +00:00
|
|
|
nsChannel *ret;
|
2010-02-21 20:05:15 +00:00
|
|
|
nsWineURI *wine_uri;
|
2006-02-09 11:19:13 +00:00
|
|
|
nsresult nsres;
|
|
|
|
|
2006-02-09 11:17:08 +00:00
|
|
|
TRACE("(%p %p)\n", aURI, _retval);
|
2006-02-09 11:19:13 +00:00
|
|
|
|
2010-02-21 20:10:15 +00:00
|
|
|
nsres = nsIURI_QueryInterface(aURI, &IID_nsWineURI, (void**)&wine_uri);
|
2006-02-09 11:19:13 +00:00
|
|
|
if(NS_FAILED(nsres)) {
|
2010-02-21 20:10:15 +00:00
|
|
|
TRACE("Could not get nsWineURI: %08x\n", nsres);
|
2009-11-30 16:59:53 +00:00
|
|
|
return nsIIOService_NewChannelFromURI(nsio, aURI, _retval);
|
2006-02-09 11:19:13 +00:00
|
|
|
}
|
|
|
|
|
2008-03-26 14:24:03 +00:00
|
|
|
ret = heap_alloc_zero(sizeof(nsChannel));
|
2006-02-09 11:19:13 +00:00
|
|
|
|
|
|
|
ret->lpHttpChannelVtbl = &nsChannelVtbl;
|
2006-02-10 13:49:41 +00:00
|
|
|
ret->lpUploadChannelVtbl = &nsUploadChannelVtbl;
|
2009-08-22 17:37:30 +00:00
|
|
|
ret->lpIHttpChannelInternalVtbl = &nsHttpChannelInternalVtbl;
|
2006-02-09 11:19:13 +00:00
|
|
|
ret->ref = 1;
|
|
|
|
ret->uri = wine_uri;
|
2010-08-03 19:40:20 +00:00
|
|
|
ret->request_method = METHOD_GET;
|
2010-04-02 22:31:45 +00:00
|
|
|
list_init(&ret->response_headers);
|
2010-08-03 19:39:34 +00:00
|
|
|
list_init(&ret->request_headers);
|
2006-02-20 15:43:32 +00:00
|
|
|
|
|
|
|
nsIURI_AddRef(aURI);
|
|
|
|
ret->original_uri = aURI;
|
2010-02-21 20:05:15 +00:00
|
|
|
ret->url_scheme = wine_uri->wine_url && SUCCEEDED(ParseURLW(wine_uri->wine_url, &parsed_url))
|
|
|
|
? parsed_url.nScheme : URL_SCHEME_UNKNOWN;
|
2009-12-01 21:50:19 +00:00
|
|
|
|
2006-02-09 11:19:13 +00:00
|
|
|
*_retval = NSCHANNEL(ret);
|
|
|
|
return NS_OK;
|
2006-02-09 11:17:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsIOService_NewChannel(nsIIOService *iface, const nsACString *aSpec,
|
|
|
|
const char *aOriginCharset, nsIURI *aBaseURI, nsIChannel **_retval)
|
|
|
|
{
|
2010-08-03 13:44:56 +00:00
|
|
|
TRACE("(%s %s %p %p)\n", debugstr_nsacstr(aSpec), debugstr_a(aOriginCharset), aBaseURI, _retval);
|
2006-02-09 11:17:08 +00: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 21:50:39 +00:00
|
|
|
TRACE("(%d %s %p)\n", aPort, debugstr_a(aScheme), _retval);
|
2006-02-09 11:17:08 +00: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 13:44:56 +00:00
|
|
|
TRACE("(%s %p)\n", debugstr_nsacstr(urlString), _retval);
|
2006-02-09 11:17:08 +00: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 20:30:51 +00:00
|
|
|
static nsresult NSAPI nsNetUtil_QueryInterface(nsINetUtil *iface, nsIIDRef riid,
|
2010-08-02 09:08:26 +00:00
|
|
|
void **result)
|
2008-02-20 20:30:51 +00: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 13:44:56 +00:00
|
|
|
TRACE("(%s %p %p %p)\n", debugstr_nsacstr(aTypeHeader), aCharset, aHadCharset, aContentType);
|
2008-02-20 20:30:51 +00:00
|
|
|
|
2008-12-18 13:08:13 +00:00
|
|
|
return nsINetUtil_ParseContentType(net_util, aTypeHeader, aCharset, aHadCharset, aContentType);
|
2008-02-20 20:30:51 +00:00
|
|
|
}
|
|
|
|
|
2008-12-30 05:48:59 +00: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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsNetUtil_EscapeString(nsINetUtil *iface, const nsACString *aString,
|
|
|
|
PRUint32 aEscapeType, nsACString *_retval)
|
|
|
|
{
|
2010-08-03 13:44:56 +00:00
|
|
|
TRACE("(%s %x %p)\n", debugstr_nsacstr(aString), aEscapeType, _retval);
|
2008-12-30 05:48:59 +00: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 13:44:56 +00:00
|
|
|
TRACE("(%s %08x %p)\n", debugstr_nsacstr(aStr), aFlags, _retval);
|
2008-12-30 05:48:59 +00: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 13:44:56 +00:00
|
|
|
TRACE("(%s %08x %p)\n", debugstr_nsacstr(aStr), aFlags, _retval);
|
2008-12-30 05:48:59 +00: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 13:44:56 +00:00
|
|
|
TRACE("(%s %p %p %p %p)\n", debugstr_nsacstr(aTypeHeader), aCharset, aCharsetStart,
|
|
|
|
aCharsetEnd, _retval);
|
2008-12-30 05:48:59 +00:00
|
|
|
|
|
|
|
return nsINetUtil_ExtractCharsetFromContentType(net_util, aTypeHeader, aCharset, aCharsetStart, aCharsetEnd, _retval);
|
|
|
|
}
|
|
|
|
|
2008-02-20 20:30:51 +00:00
|
|
|
static const nsINetUtilVtbl nsNetUtilVtbl = {
|
|
|
|
nsNetUtil_QueryInterface,
|
|
|
|
nsNetUtil_AddRef,
|
|
|
|
nsNetUtil_Release,
|
2008-12-30 05:48:59 +00:00
|
|
|
nsNetUtil_ParseContentType,
|
|
|
|
nsNetUtil_ProtocolHasFlags,
|
|
|
|
nsNetUtil_URIChainHasFlags,
|
|
|
|
nsNetUtil_ToImmutableURI,
|
|
|
|
nsNetUtil_EscapeString,
|
|
|
|
nsNetUtil_EscapeURL,
|
|
|
|
nsNetUtil_UnescapeString,
|
|
|
|
nsNetUtil_ExtractCharsetFromContentType
|
2008-02-20 20:30:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static nsINetUtil nsNetUtil = { &nsNetUtilVtbl };
|
|
|
|
|
|
|
|
static nsresult NSAPI nsIOService_QueryInterface(nsIIOService *iface, nsIIDRef riid,
|
2010-08-02 09:08:26 +00:00
|
|
|
void **result)
|
2008-02-20 20:30:51 +00: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 11:17:08 +00:00
|
|
|
static nsresult NSAPI nsIOServiceFactory_QueryInterface(nsIFactory *iface, nsIIDRef riid,
|
2010-08-02 09:08:26 +00:00
|
|
|
void **result)
|
2006-02-09 11:17:08 +00:00
|
|
|
{
|
|
|
|
*result = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_nsISupports, riid)) {
|
2008-01-16 11:20:50 +00:00
|
|
|
TRACE("(IID_nsISupports %p)\n", result);
|
2006-02-09 11:17:08 +00: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 };
|
|
|
|
|
|
|
|
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 21:50:39 +00:00
|
|
|
ERR("Could not get factory: %08x\n", nsres);
|
2006-02-09 11:17:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIFactory_CreateInstance(old_factory, NULL, &IID_nsIIOService, (void**)&nsio);
|
|
|
|
if(NS_FAILED(nsres)) {
|
2006-10-05 21:50:39 +00:00
|
|
|
ERR("Couldn not create nsIOService instance %08x\n", nsres);
|
2006-02-09 11:17:08 +00:00
|
|
|
nsIFactory_Release(old_factory);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-12-18 13:08:13 +00: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 11:17:08 +00:00
|
|
|
nsres = nsIComponentRegistrar_UnregisterFactory(registrar, &NS_IOSERVICE_CID, old_factory);
|
|
|
|
nsIFactory_Release(old_factory);
|
|
|
|
if(NS_FAILED(nsres))
|
2006-10-05 21:50:39 +00:00
|
|
|
ERR("UnregisterFactory failed: %08x\n", nsres);
|
2006-02-09 11:17:08 +00:00
|
|
|
|
|
|
|
nsres = nsIComponentRegistrar_RegisterFactory(registrar, &NS_IOSERVICE_CID,
|
|
|
|
NS_IOSERVICE_CLASSNAME, NS_IOSERVICE_CONTRACTID, &nsIOServiceFactory);
|
|
|
|
if(NS_FAILED(nsres))
|
2006-10-05 21:50:39 +00:00
|
|
|
ERR("RegisterFactory failed: %08x\n", nsres);
|
2006-02-09 11:17:08 +00:00
|
|
|
}
|
2008-12-18 13:08:13 +00:00
|
|
|
|
|
|
|
void release_nsio(void)
|
|
|
|
{
|
|
|
|
if(net_util) {
|
|
|
|
nsINetUtil_Release(net_util);
|
|
|
|
net_util = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(nsio) {
|
|
|
|
nsIIOService_Release(nsio);
|
|
|
|
nsio = NULL;
|
|
|
|
}
|
|
|
|
}
|