2006-02-13 13:26:00 +01:00
|
|
|
/*
|
2010-08-03 21:40:56 +02:00
|
|
|
* Copyright 2006-2010 Jacek Caban for CodeWeavers
|
2006-02-13 13:26:00 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2006-02-13 13:26:00 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
2009-11-30 18:00:38 +01:00
|
|
|
#include "winreg.h"
|
2006-02-13 13:26:00 +01:00
|
|
|
#include "ole2.h"
|
2007-06-12 11:26:50 +02:00
|
|
|
#include "hlguids.h"
|
2007-11-05 21:45:07 +01:00
|
|
|
#include "shlguid.h"
|
2009-11-30 18:00:38 +01:00
|
|
|
#include "wininet.h"
|
|
|
|
#include "shlwapi.h"
|
2012-01-09 17:56:54 +01:00
|
|
|
#include "htiface.h"
|
|
|
|
#include "shdeprecated.h"
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "mshtml_private.h"
|
2011-07-23 12:50:11 +02:00
|
|
|
#include "binding.h"
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
|
|
|
|
|
|
|
#define CONTENT_LENGTH "Content-Length"
|
2012-03-09 10:51:48 +01:00
|
|
|
#define UTF8_STR "utf-8"
|
2007-04-12 21:25:08 +02:00
|
|
|
#define UTF16_STR "utf-16"
|
2006-02-13 13:26:00 +01:00
|
|
|
|
2012-01-09 17:56:54 +01:00
|
|
|
static const WCHAR emptyW[] = {0};
|
|
|
|
|
2011-07-23 12:50:11 +02:00
|
|
|
struct nsProtocolStream {
|
2011-01-05 00:41:05 +01:00
|
|
|
nsIInputStream nsIInputStream_iface;
|
2008-03-23 02:16:18 +01:00
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
char buf[1024];
|
|
|
|
DWORD buf_size;
|
2011-07-23 12:50:11 +02:00
|
|
|
};
|
2008-03-23 02:16:18 +01:00
|
|
|
|
2011-07-23 12:50:11 +02:00
|
|
|
struct BSCallbackVtbl {
|
2008-03-23 02:17:17 +01:00
|
|
|
void (*destroy)(BSCallback*);
|
2009-08-19 20:40:00 +02:00
|
|
|
HRESULT (*init_bindinfo)(BSCallback*);
|
2008-03-23 02:17:17 +01:00
|
|
|
HRESULT (*start_binding)(BSCallback*);
|
|
|
|
HRESULT (*stop_binding)(BSCallback*,HRESULT);
|
|
|
|
HRESULT (*read_data)(BSCallback*,IStream*);
|
|
|
|
HRESULT (*on_progress)(BSCallback*,ULONG,LPCWSTR);
|
2010-04-03 00:31:45 +02:00
|
|
|
HRESULT (*on_response)(BSCallback*,DWORD,LPCWSTR);
|
2010-08-03 21:39:04 +02:00
|
|
|
HRESULT (*beginning_transaction)(BSCallback*,WCHAR**);
|
2008-03-23 02:16:18 +01:00
|
|
|
};
|
|
|
|
|
2011-01-05 00:41:05 +01:00
|
|
|
static inline nsProtocolStream *impl_from_nsIInputStream(nsIInputStream *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, nsProtocolStream, nsIInputStream_iface);
|
|
|
|
}
|
2006-06-03 01:26:00 +02:00
|
|
|
|
|
|
|
static nsresult NSAPI nsInputStream_QueryInterface(nsIInputStream *iface, nsIIDRef riid,
|
2010-08-02 11:08:26 +02:00
|
|
|
void **result)
|
2006-06-03 01:26:00 +02:00
|
|
|
{
|
2011-01-05 00:41:05 +01:00
|
|
|
nsProtocolStream *This = impl_from_nsIInputStream(iface);
|
2006-06-03 01:26:00 +02:00
|
|
|
|
|
|
|
*result = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_nsISupports, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsISupports %p)\n", This, result);
|
2011-01-05 00:41:05 +01:00
|
|
|
*result = &This->nsIInputStream_iface;
|
2006-06-03 01:26:00 +02:00
|
|
|
}else if(IsEqualGUID(&IID_nsIInputStream, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIInputStream %p)\n", This, result);
|
2011-01-05 00:41:05 +01:00
|
|
|
*result = &This->nsIInputStream_iface;
|
2006-06-03 01:26:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*result) {
|
2011-01-05 00:41:05 +01:00
|
|
|
nsIInputStream_AddRef(&This->nsIInputStream_iface);
|
2006-06-03 01:26:00 +02:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("unsupported interface %s\n", debugstr_guid(riid));
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsInputStream_AddRef(nsIInputStream *iface)
|
|
|
|
{
|
2011-01-05 00:41:05 +01:00
|
|
|
nsProtocolStream *This = impl_from_nsIInputStream(iface);
|
2006-06-03 01:26:00 +02:00
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2006-06-03 01:26:00 +02:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsInputStream_Release(nsIInputStream *iface)
|
|
|
|
{
|
2011-01-05 00:41:05 +01:00
|
|
|
nsProtocolStream *This = impl_from_nsIInputStream(iface);
|
2006-06-03 01:26:00 +02:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2006-06-03 01:26:00 +02:00
|
|
|
|
|
|
|
if(!ref)
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(This);
|
2006-06-03 01:26:00 +02:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsInputStream_Close(nsIInputStream *iface)
|
|
|
|
{
|
2011-01-05 00:41:05 +01:00
|
|
|
nsProtocolStream *This = impl_from_nsIInputStream(iface);
|
2006-06-03 01:26:00 +02:00
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsInputStream_Available(nsIInputStream *iface, PRUint32 *_retval)
|
|
|
|
{
|
2011-01-05 00:41:05 +01:00
|
|
|
nsProtocolStream *This = impl_from_nsIInputStream(iface);
|
2006-06-03 01:26:00 +02:00
|
|
|
FIXME("(%p)->(%p)\n", This, _retval);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsInputStream_Read(nsIInputStream *iface, char *aBuf, PRUint32 aCount,
|
|
|
|
PRUint32 *_retval)
|
|
|
|
{
|
2011-01-05 00:41:05 +01:00
|
|
|
nsProtocolStream *This = impl_from_nsIInputStream(iface);
|
2009-05-11 23:08:24 +02:00
|
|
|
DWORD read = aCount;
|
2006-08-03 21:38:08 +02:00
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%p %d %p)\n", This, aBuf, aCount, _retval);
|
2006-08-03 21:38:08 +02:00
|
|
|
|
2009-05-11 23:08:24 +02:00
|
|
|
if(read > This->buf_size)
|
|
|
|
read = This->buf_size;
|
2006-08-03 21:38:08 +02:00
|
|
|
|
2009-05-11 23:08:24 +02:00
|
|
|
if(read) {
|
|
|
|
memcpy(aBuf, This->buf, read);
|
|
|
|
if(read < This->buf_size)
|
|
|
|
memmove(This->buf, This->buf+read, This->buf_size-read);
|
|
|
|
This->buf_size -= read;
|
|
|
|
}
|
2006-08-03 21:38:08 +02:00
|
|
|
|
2009-05-11 23:08:24 +02:00
|
|
|
*_retval = read;
|
2006-08-03 21:38:08 +02:00
|
|
|
return NS_OK;
|
2006-06-03 01:26:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsInputStream_ReadSegments(nsIInputStream *iface,
|
2006-06-09 11:52:41 +02:00
|
|
|
nsresult (WINAPI *aWriter)(nsIInputStream*,void*,const char*,PRUint32,PRUint32,PRUint32*),
|
2006-06-03 01:26:00 +02:00
|
|
|
void *aClousure, PRUint32 aCount, PRUint32 *_retval)
|
|
|
|
{
|
2011-01-05 00:41:05 +01:00
|
|
|
nsProtocolStream *This = impl_from_nsIInputStream(iface);
|
2006-06-03 01:26:00 +02:00
|
|
|
PRUint32 written = 0;
|
|
|
|
nsresult nsres;
|
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%p %p %d %p)\n", This, aWriter, aClousure, aCount, _retval);
|
2006-06-03 01:26:00 +02:00
|
|
|
|
|
|
|
if(!This->buf_size)
|
|
|
|
return S_OK;
|
|
|
|
|
2008-12-18 14:08:47 +01:00
|
|
|
if(aCount > This->buf_size)
|
|
|
|
aCount = This->buf_size;
|
2006-06-03 01:26:00 +02:00
|
|
|
|
2011-01-05 00:41:05 +01:00
|
|
|
nsres = aWriter(&This->nsIInputStream_iface, aClousure, This->buf, 0, aCount, &written);
|
2006-06-03 01:26:00 +02:00
|
|
|
if(NS_FAILED(nsres))
|
2007-03-07 00:05:52 +01:00
|
|
|
TRACE("aWritter failed: %08x\n", nsres);
|
|
|
|
else if(written != This->buf_size)
|
|
|
|
FIXME("written %d != buf_size %d\n", written, This->buf_size);
|
2006-06-03 01:26:00 +02:00
|
|
|
|
|
|
|
This->buf_size -= written;
|
|
|
|
|
2007-03-07 00:05:52 +01:00
|
|
|
*_retval = written;
|
2006-06-03 01:26:00 +02:00
|
|
|
return nsres;
|
|
|
|
}
|
|
|
|
|
2012-03-15 11:55:01 +01:00
|
|
|
static nsresult NSAPI nsInputStream_IsNonBlocking(nsIInputStream *iface, cpp_bool *_retval)
|
2006-06-03 01:26:00 +02:00
|
|
|
{
|
2011-01-05 00:41:05 +01:00
|
|
|
nsProtocolStream *This = impl_from_nsIInputStream(iface);
|
2006-06-03 01:26:00 +02:00
|
|
|
FIXME("(%p)->(%p)\n", This, _retval);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const nsIInputStreamVtbl nsInputStreamVtbl = {
|
|
|
|
nsInputStream_QueryInterface,
|
|
|
|
nsInputStream_AddRef,
|
|
|
|
nsInputStream_Release,
|
|
|
|
nsInputStream_Close,
|
|
|
|
nsInputStream_Available,
|
|
|
|
nsInputStream_Read,
|
|
|
|
nsInputStream_ReadSegments,
|
|
|
|
nsInputStream_IsNonBlocking
|
|
|
|
};
|
|
|
|
|
2007-05-11 13:13:16 +02:00
|
|
|
static nsProtocolStream *create_nsprotocol_stream(void)
|
2006-06-03 01:26:00 +02:00
|
|
|
{
|
2007-12-05 21:52:31 +01:00
|
|
|
nsProtocolStream *ret = heap_alloc(sizeof(nsProtocolStream));
|
2006-06-03 01:26:00 +02:00
|
|
|
|
2011-01-05 00:41:05 +01:00
|
|
|
ret->nsIInputStream_iface.lpVtbl = &nsInputStreamVtbl;
|
2006-06-03 01:26:00 +02:00
|
|
|
ret->ref = 1;
|
|
|
|
ret->buf_size = 0;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-01-03 01:13:16 +01:00
|
|
|
static inline BSCallback *impl_from_IBindStatusCallback(IBindStatusCallback *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BSCallback, IBindStatusCallback_iface);
|
|
|
|
}
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI BindStatusCallback_QueryInterface(IBindStatusCallback *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IBindStatusCallback(iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppv);
|
2011-01-03 01:13:16 +01:00
|
|
|
*ppv = &This->IBindStatusCallback_iface;
|
2006-02-13 13:26:00 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IBindStatusCallback, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IBindStatusCallback, %p)\n", This, ppv);
|
2011-01-03 01:13:16 +01:00
|
|
|
*ppv = &This->IBindStatusCallback_iface;
|
2006-02-13 13:26:00 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
|
2010-12-27 01:43:10 +01:00
|
|
|
*ppv = &This->IServiceProvider_iface;
|
2006-02-13 13:26:00 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IHttpNegotiate, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IHttpNegotiate %p)\n", This, ppv);
|
2011-01-03 01:13:16 +01:00
|
|
|
*ppv = &This->IHttpNegotiate2_iface;
|
2006-02-13 13:26:00 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IHttpNegotiate2 %p)\n", This, ppv);
|
2011-01-03 01:13:16 +01:00
|
|
|
*ppv = &This->IHttpNegotiate2_iface;
|
2006-02-13 13:26:00 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IInternetBindInfo, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetBindInfo %p)\n", This, ppv);
|
2011-01-03 01:13:16 +01:00
|
|
|
*ppv = &This->IInternetBindInfo_iface;
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppv) {
|
2011-01-03 01:13:16 +01:00
|
|
|
IBindStatusCallback_AddRef(&This->IBindStatusCallback_iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Unsupported riid = %s\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BindStatusCallback_AddRef(IBindStatusCallback *iface)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IBindStatusCallback(iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p) ref = %d\n", This, ref);
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BindStatusCallback_Release(IBindStatusCallback *iface)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IBindStatusCallback(iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p) ref = %d\n", This, ref);
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
if(!ref) {
|
|
|
|
if(This->post_data)
|
|
|
|
GlobalFree(This->post_data);
|
2006-08-09 16:37:48 +02:00
|
|
|
if(This->mon)
|
|
|
|
IMoniker_Release(This->mon);
|
2006-09-24 23:12:23 +02:00
|
|
|
if(This->binding)
|
|
|
|
IBinding_Release(This->binding);
|
2007-11-05 21:45:07 +01:00
|
|
|
list_remove(&This->entry);
|
2011-01-31 20:28:10 +01:00
|
|
|
list_init(&This->entry);
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(This->headers);
|
2008-03-23 02:17:17 +01:00
|
|
|
|
|
|
|
This->vtbl->destroy(This);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindStatusCallback_OnStartBinding(IBindStatusCallback *iface,
|
|
|
|
DWORD dwReserved, IBinding *pbind)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IBindStatusCallback(iface);
|
2006-09-24 23:12:23 +02:00
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%d %p)\n", This, dwReserved, pbind);
|
2006-09-24 23:12:23 +02:00
|
|
|
|
|
|
|
IBinding_AddRef(pbind);
|
|
|
|
This->binding = pbind;
|
|
|
|
|
2007-11-05 21:45:07 +01:00
|
|
|
if(This->doc)
|
2009-10-26 23:05:37 +01:00
|
|
|
list_add_head(&This->doc->bindings, &This->entry);
|
2007-11-05 21:45:07 +01:00
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
return This->vtbl->start_binding(This);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindStatusCallback_GetPriority(IBindStatusCallback *iface, LONG *pnPriority)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IBindStatusCallback(iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, pnPriority);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindStatusCallback_OnLowResource(IBindStatusCallback *iface, DWORD reserved)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IBindStatusCallback(iface);
|
2006-10-05 23:50:39 +02:00
|
|
|
FIXME("(%p)->(%d)\n", This, reserved);
|
2006-02-13 13:26:00 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindStatusCallback_OnProgress(IBindStatusCallback *iface, ULONG ulProgress,
|
|
|
|
ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IBindStatusCallback(iface);
|
2006-06-03 00:48:13 +02:00
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("%p)->(%u %u %u %s)\n", This, ulProgress, ulProgressMax, ulStatusCode,
|
2006-02-13 13:26:00 +01:00
|
|
|
debugstr_w(szStatusText));
|
2006-06-03 00:48:13 +02:00
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
return This->vtbl->on_progress(This, ulStatusCode, szStatusText);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindStatusCallback_OnStopBinding(IBindStatusCallback *iface,
|
|
|
|
HRESULT hresult, LPCWSTR szError)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IBindStatusCallback(iface);
|
2009-08-10 19:17:05 +02:00
|
|
|
HRESULT hres;
|
2006-06-25 14:13:11 +02:00
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%08x %s)\n", This, hresult, debugstr_w(szError));
|
2006-06-25 14:13:11 +02:00
|
|
|
|
2008-09-17 03:24:25 +02:00
|
|
|
/* NOTE: IE7 calls GetBindResult here */
|
|
|
|
|
2009-08-10 19:17:05 +02:00
|
|
|
hres = This->vtbl->stop_binding(This, hresult);
|
|
|
|
|
2007-05-11 13:14:14 +02:00
|
|
|
if(This->binding) {
|
|
|
|
IBinding_Release(This->binding);
|
|
|
|
This->binding = NULL;
|
|
|
|
}
|
2006-09-24 23:12:23 +02:00
|
|
|
|
2007-11-05 21:45:07 +01:00
|
|
|
list_remove(&This->entry);
|
2011-01-31 20:28:10 +01:00
|
|
|
list_init(&This->entry);
|
2009-08-10 19:17:05 +02:00
|
|
|
This->doc = NULL;
|
2007-11-05 21:45:07 +01:00
|
|
|
|
2009-08-10 19:17:05 +02:00
|
|
|
return hres;
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindStatusCallback_GetBindInfo(IBindStatusCallback *iface,
|
|
|
|
DWORD *grfBINDF, BINDINFO *pbindinfo)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IBindStatusCallback(iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p)\n", This, grfBINDF, pbindinfo);
|
|
|
|
|
2009-08-19 20:40:00 +02:00
|
|
|
if(!This->bindinfo_ready) {
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = This->vtbl->init_bindinfo(This);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
This->bindinfo_ready = TRUE;
|
|
|
|
}
|
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
*grfBINDF = This->bindf;
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
size = pbindinfo->cbSize;
|
|
|
|
memset(pbindinfo, 0, size);
|
|
|
|
pbindinfo->cbSize = size;
|
|
|
|
|
2006-09-29 12:42:10 +02:00
|
|
|
pbindinfo->cbstgmedData = This->post_data_len;
|
2006-02-13 13:26:00 +01:00
|
|
|
pbindinfo->dwCodePage = CP_UTF8;
|
2006-09-24 23:43:29 +02:00
|
|
|
pbindinfo->dwOptions = 0x80000;
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
if(This->post_data) {
|
|
|
|
pbindinfo->dwBindVerb = BINDVERB_POST;
|
|
|
|
|
|
|
|
pbindinfo->stgmedData.tymed = TYMED_HGLOBAL;
|
|
|
|
pbindinfo->stgmedData.u.hGlobal = This->post_data;
|
2011-01-03 01:13:16 +01:00
|
|
|
pbindinfo->stgmedData.pUnkForRelease = (IUnknown*)&This->IBindStatusCallback_iface;
|
|
|
|
IBindStatusCallback_AddRef(&This->IBindStatusCallback_iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindStatusCallback_OnDataAvailable(IBindStatusCallback *iface,
|
|
|
|
DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IBindStatusCallback(iface);
|
2006-06-03 01:26:00 +02:00
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%08x %d %p %p)\n", This, grfBSCF, dwSize, pformatetc, pstgmed);
|
2006-06-03 01:26:00 +02:00
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
return This->vtbl->read_data(This, pstgmed->u.pstm);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindStatusCallback_OnObjectAvailable(IBindStatusCallback *iface,
|
|
|
|
REFIID riid, IUnknown *punk)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IBindStatusCallback(iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), punk);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IBindStatusCallbackVtbl BindStatusCallbackVtbl = {
|
|
|
|
BindStatusCallback_QueryInterface,
|
|
|
|
BindStatusCallback_AddRef,
|
|
|
|
BindStatusCallback_Release,
|
|
|
|
BindStatusCallback_OnStartBinding,
|
|
|
|
BindStatusCallback_GetPriority,
|
|
|
|
BindStatusCallback_OnLowResource,
|
|
|
|
BindStatusCallback_OnProgress,
|
|
|
|
BindStatusCallback_OnStopBinding,
|
|
|
|
BindStatusCallback_GetBindInfo,
|
|
|
|
BindStatusCallback_OnDataAvailable,
|
|
|
|
BindStatusCallback_OnObjectAvailable
|
|
|
|
};
|
|
|
|
|
2011-01-03 01:13:16 +01:00
|
|
|
static inline BSCallback *impl_from_IHttpNegotiate2(IHttpNegotiate2 *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BSCallback, IHttpNegotiate2_iface);
|
|
|
|
}
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI HttpNegotiate_QueryInterface(IHttpNegotiate2 *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IHttpNegotiate2(iface);
|
|
|
|
return IBindStatusCallback_QueryInterface(&This->IBindStatusCallback_iface, riid, ppv);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HttpNegotiate_AddRef(IHttpNegotiate2 *iface)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IHttpNegotiate2(iface);
|
|
|
|
return IBindStatusCallback_AddRef(&This->IBindStatusCallback_iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HttpNegotiate_Release(IHttpNegotiate2 *iface)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IHttpNegotiate2(iface);
|
|
|
|
return IBindStatusCallback_Release(&This->IBindStatusCallback_iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface,
|
|
|
|
LPCWSTR szURL, LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IHttpNegotiate2(iface);
|
2010-08-03 21:39:04 +02:00
|
|
|
HRESULT hres;
|
2006-02-13 13:26:00 +01:00
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%s %s %d %p)\n", This, debugstr_w(szURL), debugstr_w(szHeaders),
|
2006-02-13 13:26:00 +01:00
|
|
|
dwReserved, pszAdditionalHeaders);
|
|
|
|
|
2010-08-03 21:39:04 +02:00
|
|
|
*pszAdditionalHeaders = NULL;
|
|
|
|
|
|
|
|
hres = This->vtbl->beginning_transaction(This, pszAdditionalHeaders);
|
|
|
|
if(hres != S_FALSE)
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(This->headers) {
|
|
|
|
DWORD size;
|
2006-02-13 13:26:00 +01:00
|
|
|
|
2010-08-03 21:39:04 +02:00
|
|
|
size = (strlenW(This->headers)+1)*sizeof(WCHAR);
|
|
|
|
*pszAdditionalHeaders = CoTaskMemAlloc(size);
|
|
|
|
if(!*pszAdditionalHeaders)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
memcpy(*pszAdditionalHeaders, This->headers, size);
|
|
|
|
}
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode,
|
|
|
|
LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IHttpNegotiate2(iface);
|
2009-08-11 19:15:07 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%d %s %s %p)\n", This, dwResponseCode, debugstr_w(szResponseHeaders),
|
2006-02-13 13:26:00 +01:00
|
|
|
debugstr_w(szRequestHeaders), pszAdditionalRequestHeaders);
|
2009-08-11 19:15:07 +02:00
|
|
|
|
2010-04-03 00:31:45 +02:00
|
|
|
return This->vtbl->on_response(This, dwResponseCode, szResponseHeaders);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface,
|
|
|
|
BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IHttpNegotiate2(iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
FIXME("(%p)->(%p %p %ld)\n", This, pbSecurityId, pcbSecurityId, dwReserved);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IHttpNegotiate2Vtbl HttpNegotiate2Vtbl = {
|
|
|
|
HttpNegotiate_QueryInterface,
|
|
|
|
HttpNegotiate_AddRef,
|
|
|
|
HttpNegotiate_Release,
|
|
|
|
HttpNegotiate_BeginningTransaction,
|
|
|
|
HttpNegotiate_OnResponse,
|
|
|
|
HttpNegotiate_GetRootSecurityId
|
|
|
|
};
|
|
|
|
|
2011-01-03 01:13:16 +01:00
|
|
|
static inline BSCallback *impl_from_IInternetBindInfo(IInternetBindInfo *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BSCallback, IInternetBindInfo_iface);
|
|
|
|
}
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI InternetBindInfo_QueryInterface(IInternetBindInfo *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IInternetBindInfo(iface);
|
|
|
|
return IBindStatusCallback_QueryInterface(&This->IBindStatusCallback_iface, riid, ppv);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InternetBindInfo_AddRef(IInternetBindInfo *iface)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IInternetBindInfo(iface);
|
|
|
|
return IBindStatusCallback_AddRef(&This->IBindStatusCallback_iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InternetBindInfo_Release(IInternetBindInfo *iface)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IInternetBindInfo(iface);
|
|
|
|
return IBindStatusCallback_Release(&This->IBindStatusCallback_iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InternetBindInfo_GetBindInfo(IInternetBindInfo *iface,
|
|
|
|
DWORD *grfBINDF, BINDINFO *pbindinfo)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IInternetBindInfo(iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
FIXME("(%p)->(%p %p)\n", This, grfBINDF, pbindinfo);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InternetBindInfo_GetBindString(IInternetBindInfo *iface,
|
|
|
|
ULONG ulStringType, LPOLESTR *ppwzStr, ULONG cEl, ULONG *pcElFetched)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IInternetBindInfo(iface);
|
2006-10-05 23:50:39 +02:00
|
|
|
FIXME("(%p)->(%u %p %u %p)\n", This, ulStringType, ppwzStr, cEl, pcElFetched);
|
2006-02-13 13:26:00 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IInternetBindInfoVtbl InternetBindInfoVtbl = {
|
|
|
|
InternetBindInfo_QueryInterface,
|
|
|
|
InternetBindInfo_AddRef,
|
|
|
|
InternetBindInfo_Release,
|
|
|
|
InternetBindInfo_GetBindInfo,
|
|
|
|
InternetBindInfo_GetBindString
|
|
|
|
};
|
|
|
|
|
2010-12-27 01:43:10 +01:00
|
|
|
static inline BSCallback *impl_from_IServiceProvider(IServiceProvider *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BSCallback, IServiceProvider_iface);
|
|
|
|
}
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI BSCServiceProvider_QueryInterface(IServiceProvider *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2010-12-27 01:43:10 +01:00
|
|
|
BSCallback *This = impl_from_IServiceProvider(iface);
|
2011-01-03 01:13:16 +01:00
|
|
|
return IBindStatusCallback_QueryInterface(&This->IBindStatusCallback_iface, riid, ppv);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BSCServiceProvider_AddRef(IServiceProvider *iface)
|
|
|
|
{
|
2010-12-27 01:43:10 +01:00
|
|
|
BSCallback *This = impl_from_IServiceProvider(iface);
|
2011-01-03 01:13:16 +01:00
|
|
|
return IBindStatusCallback_AddRef(&This->IBindStatusCallback_iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BSCServiceProvider_Release(IServiceProvider *iface)
|
|
|
|
{
|
2010-12-27 01:43:10 +01:00
|
|
|
BSCallback *This = impl_from_IServiceProvider(iface);
|
2011-01-03 01:13:16 +01:00
|
|
|
return IBindStatusCallback_Release(&This->IBindStatusCallback_iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BSCServiceProvider_QueryService(IServiceProvider *iface,
|
|
|
|
REFGUID guidService, REFIID riid, void **ppv)
|
|
|
|
{
|
2010-12-27 01:43:10 +01:00
|
|
|
BSCallback *This = impl_from_IServiceProvider(iface);
|
2007-11-20 01:51:41 +01:00
|
|
|
TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
|
|
|
|
return E_NOINTERFACE;
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IServiceProviderVtbl ServiceProviderVtbl = {
|
|
|
|
BSCServiceProvider_QueryInterface,
|
|
|
|
BSCServiceProvider_AddRef,
|
|
|
|
BSCServiceProvider_Release,
|
|
|
|
BSCServiceProvider_QueryService
|
|
|
|
};
|
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
static void init_bscallback(BSCallback *This, const BSCallbackVtbl *vtbl, IMoniker *mon, DWORD bindf)
|
2006-02-13 13:26:00 +01:00
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
This->IBindStatusCallback_iface.lpVtbl = &BindStatusCallbackVtbl;
|
2010-12-27 01:43:10 +01:00
|
|
|
This->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
|
2011-01-03 01:13:16 +01:00
|
|
|
This->IHttpNegotiate2_iface.lpVtbl = &HttpNegotiate2Vtbl;
|
|
|
|
This->IInternetBindInfo_iface.lpVtbl = &InternetBindInfoVtbl;
|
2008-03-23 02:17:17 +01:00
|
|
|
This->vtbl = vtbl;
|
|
|
|
This->ref = 1;
|
|
|
|
This->bindf = bindf;
|
2006-02-13 13:26:00 +01:00
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
list_init(&This->entry);
|
2007-11-05 21:45:07 +01:00
|
|
|
|
2006-08-09 16:37:48 +02:00
|
|
|
if(mon)
|
|
|
|
IMoniker_AddRef(mon);
|
2008-03-23 02:17:17 +01:00
|
|
|
This->mon = mon;
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
2007-11-02 19:54:22 +01:00
|
|
|
/* Calls undocumented 84 cmd of CGID_ShellDocView */
|
2009-09-16 22:10:03 +02:00
|
|
|
static void call_docview_84(HTMLDocumentObj *doc)
|
2007-11-02 19:54:22 +01:00
|
|
|
{
|
|
|
|
IOleCommandTarget *olecmd;
|
|
|
|
VARIANT var;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(!doc->client)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hres = IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&olecmd);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return;
|
|
|
|
|
|
|
|
VariantInit(&var);
|
|
|
|
hres = IOleCommandTarget_Exec(olecmd, &CGID_ShellDocView, 84, 0, NULL, &var);
|
|
|
|
IOleCommandTarget_Release(olecmd);
|
|
|
|
if(SUCCEEDED(hres) && V_VT(&var) != VT_NULL)
|
|
|
|
FIXME("handle result\n");
|
|
|
|
}
|
|
|
|
|
2011-11-23 16:19:05 +01:00
|
|
|
static void parse_content_type(nsChannelBSC *This, const WCHAR *value)
|
|
|
|
{
|
|
|
|
const WCHAR *ptr;
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
static const WCHAR charsetW[] = {'c','h','a','r','s','e','t','='};
|
|
|
|
|
|
|
|
ptr = strchrW(value, ';');
|
|
|
|
if(!ptr)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ptr++;
|
|
|
|
while(*ptr && isspaceW(*ptr))
|
|
|
|
ptr++;
|
|
|
|
|
|
|
|
len = strlenW(value);
|
|
|
|
if(ptr + sizeof(charsetW)/sizeof(WCHAR) < value+len && !memicmpW(ptr, charsetW, sizeof(charsetW)/sizeof(WCHAR))) {
|
|
|
|
size_t charset_len, lena;
|
|
|
|
nsACString charset_str;
|
|
|
|
const WCHAR *charset;
|
|
|
|
char *charseta;
|
|
|
|
|
|
|
|
ptr += sizeof(charsetW)/sizeof(WCHAR);
|
|
|
|
|
|
|
|
if(*ptr == '\'') {
|
|
|
|
FIXME("Quoted value\n");
|
|
|
|
return;
|
|
|
|
}else {
|
|
|
|
charset = ptr;
|
|
|
|
while(*ptr && *ptr != ',')
|
|
|
|
ptr++;
|
|
|
|
charset_len = ptr-charset;
|
|
|
|
}
|
|
|
|
|
|
|
|
lena = WideCharToMultiByte(CP_ACP, 0, charset, charset_len, NULL, 0, NULL, NULL);
|
|
|
|
charseta = heap_alloc(lena+1);
|
|
|
|
if(!charseta)
|
|
|
|
return;
|
|
|
|
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, charset, charset_len, charseta, lena, NULL, NULL);
|
|
|
|
charseta[lena] = 0;
|
|
|
|
|
|
|
|
nsACString_InitDepend(&charset_str, charseta);
|
|
|
|
nsIHttpChannel_SetContentCharset(&This->nschannel->nsIHttpChannel_iface, &charset_str);
|
|
|
|
nsACString_Finish(&charset_str);
|
|
|
|
heap_free(charseta);
|
|
|
|
}else {
|
|
|
|
FIXME("unhandled: %s\n", debugstr_wn(ptr, len - (ptr-value)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-03 21:38:53 +02:00
|
|
|
static HRESULT parse_headers(const WCHAR *headers, struct list *headers_list)
|
|
|
|
{
|
|
|
|
const WCHAR *header, *header_end, *colon, *value;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
header = headers;
|
|
|
|
while(*header) {
|
|
|
|
if(header[0] == '\r' && header[1] == '\n' && !header[2])
|
|
|
|
break;
|
|
|
|
for(colon = header; *colon && *colon != ':' && *colon != '\r'; colon++);
|
|
|
|
if(*colon != ':')
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
value = colon+1;
|
|
|
|
while(*value == ' ')
|
|
|
|
value++;
|
|
|
|
if(!*value)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
for(header_end = value+1; *header_end && *header_end != '\r'; header_end++);
|
|
|
|
|
|
|
|
hres = set_http_header(headers_list, header, colon-header, value, header_end-value);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
header = header_end;
|
|
|
|
if(header[0] == '\r' && header[1] == '\n')
|
|
|
|
header += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-11-23 16:19:05 +01:00
|
|
|
static HRESULT process_response_headers(nsChannelBSC *This, const WCHAR *headers)
|
|
|
|
{
|
|
|
|
http_header_t *iter;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
static const WCHAR content_typeW[] = {'c','o','n','t','e','n','t','-','t','y','p','e',0};
|
|
|
|
|
|
|
|
hres = parse_headers(headers, &This->nschannel->response_headers);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(iter, &This->nschannel->response_headers, http_header_t, entry) {
|
|
|
|
if(!strcmpiW(iter->header, content_typeW))
|
|
|
|
parse_content_type(This, iter->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-10-26 23:05:37 +01:00
|
|
|
HRESULT start_binding(HTMLWindow *window, HTMLDocumentNode *doc, BSCallback *bscallback, IBindCtx *bctx)
|
2006-06-03 00:41:48 +02:00
|
|
|
{
|
|
|
|
IStream *str = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2011-06-16 16:42:12 +02:00
|
|
|
TRACE("(%p %p %p %p)\n", window, doc, bscallback, bctx);
|
|
|
|
|
2007-11-05 21:45:07 +01:00
|
|
|
bscallback->doc = doc;
|
2008-09-17 03:24:25 +02:00
|
|
|
|
|
|
|
/* NOTE: IE7 calls IsSystemMoniker here*/
|
|
|
|
|
2010-03-03 14:54:28 +01:00
|
|
|
if(window) {
|
|
|
|
if(bscallback->mon != window->mon)
|
|
|
|
set_current_mon(window, bscallback->mon);
|
2009-10-26 23:05:37 +01:00
|
|
|
call_docview_84(window->doc_obj);
|
2010-03-03 14:54:28 +01:00
|
|
|
}
|
2007-11-05 21:45:07 +01:00
|
|
|
|
2007-12-24 12:48:43 +01:00
|
|
|
if(bctx) {
|
2011-01-03 01:13:16 +01:00
|
|
|
RegisterBindStatusCallback(bctx, &bscallback->IBindStatusCallback_iface, NULL, 0);
|
2007-12-24 12:48:43 +01:00
|
|
|
IBindCtx_AddRef(bctx);
|
|
|
|
}else {
|
2011-01-03 01:13:16 +01:00
|
|
|
hres = CreateAsyncBindCtx(0, &bscallback->IBindStatusCallback_iface, NULL, &bctx);
|
2007-12-24 12:48:43 +01:00
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("CreateAsyncBindCtx failed: %08x\n", hres);
|
2008-03-23 02:17:17 +01:00
|
|
|
bscallback->vtbl->stop_binding(bscallback, hres);
|
2007-12-24 12:48:43 +01:00
|
|
|
return hres;
|
|
|
|
}
|
2006-06-03 00:41:48 +02:00
|
|
|
}
|
|
|
|
|
2006-08-09 16:37:48 +02:00
|
|
|
hres = IMoniker_BindToStorage(bscallback->mon, bctx, NULL, &IID_IStream, (void**)&str);
|
2006-06-03 00:41:48 +02:00
|
|
|
IBindCtx_Release(bctx);
|
|
|
|
if(FAILED(hres)) {
|
2006-10-05 23:50:39 +02:00
|
|
|
WARN("BindToStorage failed: %08x\n", hres);
|
2008-03-23 02:17:17 +01:00
|
|
|
bscallback->vtbl->stop_binding(bscallback, hres);
|
2006-06-03 00:41:48 +02:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(str)
|
|
|
|
IStream_Release(str);
|
|
|
|
|
2006-08-09 16:37:48 +02:00
|
|
|
IMoniker_Release(bscallback->mon);
|
|
|
|
bscallback->mon = NULL;
|
2007-07-25 00:07:10 +02:00
|
|
|
|
2006-06-03 00:41:48 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2006-09-24 23:39:55 +02:00
|
|
|
|
2008-03-29 21:57:48 +01:00
|
|
|
typedef struct {
|
|
|
|
BSCallback bsc;
|
|
|
|
|
|
|
|
DWORD size;
|
|
|
|
BYTE *buf;
|
|
|
|
HRESULT hres;
|
|
|
|
} BufferBSC;
|
|
|
|
|
2011-01-07 14:22:51 +01:00
|
|
|
static inline BufferBSC *BufferBSC_from_BSCallback(BSCallback *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BufferBSC, bsc);
|
|
|
|
}
|
2008-03-29 21:57:48 +01:00
|
|
|
|
|
|
|
static void BufferBSC_destroy(BSCallback *bsc)
|
|
|
|
{
|
2011-01-07 14:22:51 +01:00
|
|
|
BufferBSC *This = BufferBSC_from_BSCallback(bsc);
|
2008-03-29 21:57:48 +01:00
|
|
|
|
|
|
|
heap_free(This->buf);
|
|
|
|
heap_free(This);
|
|
|
|
}
|
|
|
|
|
2009-08-19 20:40:00 +02:00
|
|
|
static HRESULT BufferBSC_init_bindinfo(BSCallback *bsc)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-03-29 21:57:48 +01:00
|
|
|
static HRESULT BufferBSC_start_binding(BSCallback *bsc)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT BufferBSC_stop_binding(BSCallback *bsc, HRESULT result)
|
|
|
|
{
|
2011-01-07 14:22:51 +01:00
|
|
|
BufferBSC *This = BufferBSC_from_BSCallback(bsc);
|
2008-03-29 21:57:48 +01:00
|
|
|
|
|
|
|
This->hres = result;
|
|
|
|
|
|
|
|
if(FAILED(result)) {
|
|
|
|
heap_free(This->buf);
|
|
|
|
This->buf = NULL;
|
|
|
|
This->size = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT BufferBSC_read_data(BSCallback *bsc, IStream *stream)
|
|
|
|
{
|
2011-01-07 14:22:51 +01:00
|
|
|
BufferBSC *This = BufferBSC_from_BSCallback(bsc);
|
2008-03-29 21:57:48 +01:00
|
|
|
DWORD readed;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(!This->buf) {
|
|
|
|
This->size = 128;
|
|
|
|
This->buf = heap_alloc(This->size);
|
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
|
|
|
if(This->bsc.readed == This->size) {
|
|
|
|
This->size <<= 1;
|
|
|
|
This->buf = heap_realloc(This->buf, This->size);
|
|
|
|
}
|
|
|
|
|
|
|
|
readed = 0;
|
|
|
|
hres = IStream_Read(stream, This->buf+This->bsc.readed, This->size-This->bsc.readed, &readed);
|
|
|
|
This->bsc.readed += readed;
|
|
|
|
}while(hres == S_OK);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT BufferBSC_on_progress(BSCallback *bsc, ULONG status_code, LPCWSTR status_text)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-04-03 00:31:45 +02:00
|
|
|
static HRESULT BufferBSC_on_response(BSCallback *bsc, DWORD response_code,
|
|
|
|
LPCWSTR response_headers)
|
2009-08-11 19:15:07 +02:00
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-03 21:39:04 +02:00
|
|
|
static HRESULT BufferBSC_beginning_transaction(BSCallback *bsc, WCHAR **additional_headers)
|
|
|
|
{
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2008-03-29 21:57:48 +01:00
|
|
|
static const BSCallbackVtbl BufferBSCVtbl = {
|
|
|
|
BufferBSC_destroy,
|
2009-08-19 20:40:00 +02:00
|
|
|
BufferBSC_init_bindinfo,
|
2008-03-29 21:57:48 +01:00
|
|
|
BufferBSC_start_binding,
|
|
|
|
BufferBSC_stop_binding,
|
|
|
|
BufferBSC_read_data,
|
|
|
|
BufferBSC_on_progress,
|
2010-08-03 21:39:04 +02:00
|
|
|
BufferBSC_on_response,
|
|
|
|
BufferBSC_beginning_transaction
|
2008-03-29 21:57:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static BufferBSC *create_bufferbsc(IMoniker *mon)
|
|
|
|
{
|
|
|
|
BufferBSC *ret = heap_alloc_zero(sizeof(*ret));
|
|
|
|
|
|
|
|
init_bscallback(&ret->bsc, &BufferBSCVtbl, mon, 0);
|
|
|
|
ret->hres = E_FAIL;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-10-26 23:05:37 +01:00
|
|
|
HRESULT bind_mon_to_buffer(HTMLDocumentNode *doc, IMoniker *mon, void **buf, DWORD *size)
|
2008-03-29 21:57:48 +01:00
|
|
|
{
|
|
|
|
BufferBSC *bsc = create_bufferbsc(mon);
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
*buf = NULL;
|
|
|
|
|
2009-10-26 23:05:37 +01:00
|
|
|
hres = start_binding(NULL, doc, &bsc->bsc, NULL);
|
2008-03-29 21:57:48 +01:00
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
hres = bsc->hres;
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
*buf = bsc->buf;
|
|
|
|
bsc->buf = NULL;
|
2008-04-17 02:30:40 +02:00
|
|
|
*size = bsc->bsc.readed;
|
2008-03-29 21:57:48 +01:00
|
|
|
bsc->size = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-03 01:13:16 +01:00
|
|
|
IBindStatusCallback_Release(&bsc->bsc.IBindStatusCallback_iface);
|
2008-03-29 21:57:48 +01:00
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2011-04-05 15:23:25 +02:00
|
|
|
static HRESULT read_post_data_stream(nsChannelBSC *This, nsChannel *nschannel)
|
|
|
|
{
|
|
|
|
PRUint32 data_len = 0, available = 0;
|
|
|
|
char *data, *post_data;
|
|
|
|
nsresult nsres;
|
|
|
|
HRESULT hres = S_OK;
|
|
|
|
|
|
|
|
if(!nschannel->post_data_stream)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
nsres = nsIInputStream_Available(nschannel->post_data_stream, &available);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return E_FAIL;
|
|
|
|
|
2011-04-15 19:36:49 +02:00
|
|
|
post_data = data = GlobalAlloc(0, available);
|
2011-04-05 15:23:25 +02:00
|
|
|
if(!data)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
nsres = nsIInputStream_Read(nschannel->post_data_stream, data, available, &data_len);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
GlobalFree(data);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(nschannel->post_data_contains_headers) {
|
2011-04-15 19:36:49 +02:00
|
|
|
if(data_len >= 2 && data[0] == '\r' && data[1] == '\n') {
|
2011-04-05 15:23:25 +02:00
|
|
|
post_data = data+2;
|
|
|
|
data_len -= 2;
|
|
|
|
}else {
|
|
|
|
WCHAR *headers;
|
|
|
|
DWORD size;
|
2011-04-15 19:36:49 +02:00
|
|
|
char *ptr;
|
|
|
|
|
|
|
|
post_data += data_len;
|
|
|
|
for(ptr = data; ptr+4 < data+data_len; ptr++) {
|
|
|
|
if(!memcmp(ptr, "\r\n\r\n", 4)) {
|
|
|
|
post_data = ptr+4;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-04-05 15:23:25 +02:00
|
|
|
|
|
|
|
data_len -= post_data-data;
|
|
|
|
|
|
|
|
size = MultiByteToWideChar(CP_ACP, 0, data, post_data-data, NULL, 0);
|
|
|
|
headers = heap_alloc((size+1)*sizeof(WCHAR));
|
|
|
|
if(headers) {
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, data, post_data-data, headers, size);
|
|
|
|
headers[size] = 0;
|
|
|
|
hres = parse_headers(headers , &nschannel->request_headers);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
This->bsc.headers = headers;
|
|
|
|
else
|
|
|
|
heap_free(headers);
|
|
|
|
}else {
|
|
|
|
hres = E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
GlobalFree(data);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!data_len) {
|
|
|
|
GlobalFree(data);
|
|
|
|
post_data = NULL;
|
|
|
|
}else if(post_data != data) {
|
|
|
|
char *new_data;
|
|
|
|
|
|
|
|
new_data = GlobalAlloc(0, data_len);
|
|
|
|
if(new_data)
|
|
|
|
memcpy(new_data, post_data, data_len);
|
|
|
|
GlobalFree(data);
|
|
|
|
if(!new_data)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
post_data = new_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
This->bsc.post_data = post_data;
|
|
|
|
This->bsc.post_data_len = data_len;
|
|
|
|
TRACE("post_data = %s\n", debugstr_a(This->bsc.post_data));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-18 13:38:48 +02:00
|
|
|
static HRESULT on_start_nsrequest(nsChannelBSC *This)
|
2009-08-30 01:01:16 +02:00
|
|
|
{
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
/* FIXME: it's needed for http connections from BindToObject. */
|
|
|
|
if(!This->nschannel->response_status)
|
|
|
|
This->nschannel->response_status = 200;
|
|
|
|
|
|
|
|
nsres = nsIStreamListener_OnStartRequest(This->nslistener,
|
2010-12-30 01:43:11 +01:00
|
|
|
(nsIRequest*)&This->nschannel->nsIHttpChannel_iface, This->nscontext);
|
2010-08-18 13:38:48 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
2009-08-30 01:01:16 +02:00
|
|
|
FIXME("OnStartRequest failed: %08x\n", nsres);
|
2010-08-18 13:38:48 +02:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(This->window) {
|
2011-05-13 18:17:59 +02:00
|
|
|
list_remove(&This->bsc.entry);
|
|
|
|
list_init(&This->bsc.entry);
|
2010-08-18 13:38:48 +02:00
|
|
|
update_window_doc(This->window);
|
|
|
|
if(This->window->doc != This->bsc.doc)
|
|
|
|
This->bsc.doc = This->window->doc;
|
2011-05-13 18:17:59 +02:00
|
|
|
list_add_head(&This->bsc.doc->bindings, &This->bsc.entry);
|
2010-08-18 13:38:48 +02:00
|
|
|
if(This->window->readystate != READYSTATE_LOADING)
|
|
|
|
set_ready_state(This->window, READYSTATE_LOADING);
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2009-08-30 01:01:16 +02:00
|
|
|
}
|
|
|
|
|
2009-09-14 00:35:20 +02:00
|
|
|
static void on_stop_nsrequest(nsChannelBSC *This, HRESULT result)
|
2009-08-30 01:01:16 +02:00
|
|
|
{
|
2010-10-06 21:35:22 +02:00
|
|
|
nsresult nsres, request_result;
|
|
|
|
|
|
|
|
switch(result) {
|
|
|
|
case S_OK:
|
|
|
|
request_result = NS_OK;
|
|
|
|
break;
|
|
|
|
case E_ABORT:
|
|
|
|
request_result = NS_BINDING_ABORTED;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
request_result = NS_ERROR_FAILURE;
|
|
|
|
}
|
2009-08-30 01:01:16 +02:00
|
|
|
|
2010-08-18 13:38:30 +02:00
|
|
|
if(This->nslistener) {
|
|
|
|
nsres = nsIStreamListener_OnStopRequest(This->nslistener,
|
2010-12-30 01:43:11 +01:00
|
|
|
(nsIRequest*)&This->nschannel->nsIHttpChannel_iface, This->nscontext,
|
|
|
|
request_result);
|
2010-08-18 13:38:30 +02:00
|
|
|
if(NS_FAILED(nsres))
|
2012-01-09 22:28:21 +01:00
|
|
|
WARN("OnStopRequest failed: %08x\n", nsres);
|
2010-08-18 13:38:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(This->nschannel->load_group) {
|
|
|
|
nsres = nsILoadGroup_RemoveRequest(This->nschannel->load_group,
|
2010-12-30 01:43:11 +01:00
|
|
|
(nsIRequest*)&This->nschannel->nsIHttpChannel_iface, NULL, request_result);
|
2010-08-18 13:38:30 +02:00
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("RemoveRequest failed: %08x\n", nsres);
|
|
|
|
}
|
2009-08-30 01:01:16 +02:00
|
|
|
}
|
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
static HRESULT read_stream_data(nsChannelBSC *This, IStream *stream)
|
|
|
|
{
|
2012-03-08 13:02:05 +01:00
|
|
|
static const WCHAR mimeTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
|
|
|
|
|
2009-08-11 19:14:48 +02:00
|
|
|
DWORD read;
|
2008-03-23 02:17:17 +01:00
|
|
|
nsresult nsres;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(!This->nslistener) {
|
|
|
|
BYTE buf[1024];
|
|
|
|
|
|
|
|
do {
|
|
|
|
read = 0;
|
|
|
|
hres = IStream_Read(stream, buf, sizeof(buf), &read);
|
|
|
|
}while(hres == S_OK && read);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!This->nsstream)
|
|
|
|
This->nsstream = create_nsprotocol_stream();
|
|
|
|
|
|
|
|
do {
|
2009-08-11 19:14:48 +02:00
|
|
|
read = 0;
|
|
|
|
hres = IStream_Read(stream, This->nsstream->buf+This->nsstream->buf_size,
|
|
|
|
sizeof(This->nsstream->buf)-This->nsstream->buf_size, &read);
|
|
|
|
if(!read)
|
2008-03-23 02:17:17 +01:00
|
|
|
break;
|
|
|
|
|
2009-08-11 19:14:48 +02:00
|
|
|
This->nsstream->buf_size += read;
|
2008-03-23 02:17:17 +01:00
|
|
|
|
|
|
|
if(!This->bsc.readed) {
|
2009-08-11 19:14:48 +02:00
|
|
|
if(This->nsstream->buf_size >= 2
|
|
|
|
&& (BYTE)This->nsstream->buf[0] == 0xff
|
|
|
|
&& (BYTE)This->nsstream->buf[1] == 0xfe)
|
|
|
|
This->nschannel->charset = heap_strdupA(UTF16_STR);
|
2012-03-09 10:51:48 +01:00
|
|
|
if(This->nsstream->buf_size >= 3
|
|
|
|
&& (BYTE)This->nsstream->buf[0] == 0xef
|
|
|
|
&& (BYTE)This->nsstream->buf[1] == 0xbb
|
|
|
|
&& (BYTE)This->nsstream->buf[2] == 0xbf)
|
|
|
|
This->nschannel->charset = heap_strdupA(UTF8_STR);
|
2009-08-11 19:14:48 +02:00
|
|
|
|
2009-12-28 21:19:29 +01:00
|
|
|
if(!This->nschannel->content_type) {
|
|
|
|
WCHAR *mime;
|
|
|
|
|
2012-03-08 13:02:05 +01:00
|
|
|
hres = FindMimeFromData(NULL, NULL, This->nsstream->buf, This->nsstream->buf_size,
|
|
|
|
This->window ? mimeTextHtml : NULL, 0, &mime, 0);
|
2009-12-28 21:19:29 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
TRACE("Found MIME %s\n", debugstr_w(mime));
|
|
|
|
|
|
|
|
This->nschannel->content_type = heap_strdupWtoA(mime);
|
|
|
|
CoTaskMemFree(mime);
|
|
|
|
if(!This->nschannel->content_type)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2009-08-30 01:01:16 +02:00
|
|
|
on_start_nsrequest(This);
|
2008-03-23 02:17:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
This->bsc.readed += This->nsstream->buf_size;
|
|
|
|
|
|
|
|
nsres = nsIStreamListener_OnDataAvailable(This->nslistener,
|
2010-12-30 01:43:11 +01:00
|
|
|
(nsIRequest*)&This->nschannel->nsIHttpChannel_iface, This->nscontext,
|
2011-01-05 00:41:05 +01:00
|
|
|
&This->nsstream->nsIInputStream_iface, This->bsc.readed-This->nsstream->buf_size,
|
2008-03-23 02:17:17 +01:00
|
|
|
This->nsstream->buf_size);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("OnDataAvailable failed: %08x\n", nsres);
|
|
|
|
|
2009-08-11 19:14:48 +02:00
|
|
|
if(This->nsstream->buf_size == sizeof(This->nsstream->buf)) {
|
|
|
|
ERR("buffer is full\n");
|
|
|
|
break;
|
|
|
|
}
|
2008-03-23 02:17:17 +01:00
|
|
|
}while(hres == S_OK);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-04-15 19:36:36 +02:00
|
|
|
typedef struct {
|
|
|
|
nsIAsyncVerifyRedirectCallback nsIAsyncVerifyRedirectCallback_iface;
|
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
nsChannel *nschannel;
|
|
|
|
nsChannelBSC *bsc;
|
|
|
|
} nsRedirectCallback;
|
|
|
|
|
|
|
|
static nsRedirectCallback *impl_from_nsIAsyncVerifyRedirectCallback(nsIAsyncVerifyRedirectCallback *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, nsRedirectCallback, nsIAsyncVerifyRedirectCallback_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsAsyncVerifyRedirectCallback_QueryInterface(nsIAsyncVerifyRedirectCallback *iface,
|
|
|
|
nsIIDRef riid, void **result)
|
|
|
|
{
|
|
|
|
nsRedirectCallback *This = impl_from_nsIAsyncVerifyRedirectCallback(iface);
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_nsISupports, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsISuports %p)\n", This, result);
|
|
|
|
*result = &This->nsIAsyncVerifyRedirectCallback_iface;
|
|
|
|
}else if(IsEqualGUID(&IID_nsIAsyncVerifyRedirectCallback, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIAsyncVerifyRedirectCallback %p)\n", This, result);
|
|
|
|
*result = &This->nsIAsyncVerifyRedirectCallback_iface;
|
|
|
|
}else {
|
|
|
|
*result = NULL;
|
2011-05-09 09:03:40 +02:00
|
|
|
WARN("unimplemented iface %s\n", debugstr_guid(riid));
|
2011-04-15 19:36:36 +02:00
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsISupports_AddRef((nsISupports*)*result);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsAsyncVerifyRedirectCallback_AddRef(nsIAsyncVerifyRedirectCallback *iface)
|
|
|
|
{
|
|
|
|
nsRedirectCallback *This = impl_from_nsIAsyncVerifyRedirectCallback(iface);
|
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsAsyncVerifyRedirectCallback_Release(nsIAsyncVerifyRedirectCallback *iface)
|
|
|
|
{
|
|
|
|
nsRedirectCallback *This = impl_from_nsIAsyncVerifyRedirectCallback(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
if(!ref) {
|
|
|
|
IBindStatusCallback_Release(&This->bsc->bsc.IBindStatusCallback_iface);
|
|
|
|
nsIChannel_Release(&This->nschannel->nsIHttpChannel_iface);
|
|
|
|
heap_free(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsAsyncVerifyRedirectCallback_AsyncOnChannelRedirect(nsIAsyncVerifyRedirectCallback *iface, nsresult result)
|
|
|
|
{
|
|
|
|
nsRedirectCallback *This = impl_from_nsIAsyncVerifyRedirectCallback(iface);
|
2012-04-05 13:57:26 +02:00
|
|
|
nsChannel *old_nschannel;
|
|
|
|
nsresult nsres;
|
2011-04-15 19:36:36 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%08x)\n", This, result);
|
|
|
|
|
2012-04-05 13:57:26 +02:00
|
|
|
old_nschannel = This->bsc->nschannel;
|
2011-04-15 19:36:36 +02:00
|
|
|
nsIChannel_AddRef(&This->nschannel->nsIHttpChannel_iface);
|
|
|
|
This->bsc->nschannel = This->nschannel;
|
|
|
|
|
|
|
|
if(This->nschannel->load_group) {
|
|
|
|
nsres = nsILoadGroup_AddRequest(This->nschannel->load_group, (nsIRequest*)&This->nschannel->nsIHttpChannel_iface,
|
|
|
|
NULL);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("AddRequest failed: %08x\n", nsres);
|
|
|
|
}
|
|
|
|
|
2011-11-16 12:52:43 +01:00
|
|
|
if(This->bsc->window) {
|
|
|
|
IUri *uri = nsuri_get_uri(This->nschannel->uri);
|
|
|
|
|
|
|
|
if(uri) {
|
|
|
|
set_current_uri(This->bsc->window, uri);
|
|
|
|
IUri_Release(uri);
|
|
|
|
}else {
|
|
|
|
WARN("Could not get IUri from nsWineURI\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-05 13:57:26 +02:00
|
|
|
if(old_nschannel) {
|
|
|
|
nsres = nsILoadGroup_RemoveRequest(old_nschannel->load_group,
|
|
|
|
(nsIRequest*)&old_nschannel->nsIHttpChannel_iface, NULL, NS_OK);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("RemoveRequest failed: %08x\n", nsres);
|
|
|
|
nsIHttpChannel_Release(&old_nschannel->nsIHttpChannel_iface);
|
|
|
|
}
|
|
|
|
|
2011-04-15 19:36:36 +02:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const nsIAsyncVerifyRedirectCallbackVtbl nsAsyncVerifyRedirectCallbackVtbl = {
|
|
|
|
nsAsyncVerifyRedirectCallback_QueryInterface,
|
|
|
|
nsAsyncVerifyRedirectCallback_AddRef,
|
|
|
|
nsAsyncVerifyRedirectCallback_Release,
|
|
|
|
nsAsyncVerifyRedirectCallback_AsyncOnChannelRedirect
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT create_redirect_callback(nsChannel *nschannel, nsChannelBSC *bsc, nsRedirectCallback **ret)
|
|
|
|
{
|
|
|
|
nsRedirectCallback *callback;
|
|
|
|
|
|
|
|
callback = heap_alloc(sizeof(*callback));
|
|
|
|
if(!callback)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
callback->nsIAsyncVerifyRedirectCallback_iface.lpVtbl = &nsAsyncVerifyRedirectCallbackVtbl;
|
|
|
|
callback->ref = 1;
|
|
|
|
|
|
|
|
nsIChannel_AddRef(&nschannel->nsIHttpChannel_iface);
|
|
|
|
callback->nschannel = nschannel;
|
|
|
|
|
|
|
|
IBindStatusCallback_AddRef(&bsc->bsc.IBindStatusCallback_iface);
|
|
|
|
callback->bsc = bsc;
|
|
|
|
|
|
|
|
*ret = callback;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-07 14:22:51 +01:00
|
|
|
static inline nsChannelBSC *nsChannelBSC_from_BSCallback(BSCallback *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, nsChannelBSC, bsc);
|
|
|
|
}
|
2008-03-23 02:17:17 +01:00
|
|
|
|
|
|
|
static void nsChannelBSC_destroy(BSCallback *bsc)
|
|
|
|
{
|
2011-01-07 14:22:51 +01:00
|
|
|
nsChannelBSC *This = nsChannelBSC_from_BSCallback(bsc);
|
2008-03-23 02:17:17 +01:00
|
|
|
|
|
|
|
if(This->nschannel)
|
2010-12-30 01:43:11 +01:00
|
|
|
nsIChannel_Release(&This->nschannel->nsIHttpChannel_iface);
|
2008-03-23 02:17:17 +01:00
|
|
|
if(This->nslistener)
|
|
|
|
nsIStreamListener_Release(This->nslistener);
|
|
|
|
if(This->nscontext)
|
|
|
|
nsISupports_Release(This->nscontext);
|
|
|
|
if(This->nsstream)
|
2011-01-05 00:41:05 +01:00
|
|
|
nsIInputStream_Release(&This->nsstream->nsIInputStream_iface);
|
2008-03-23 02:17:17 +01:00
|
|
|
heap_free(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT nsChannelBSC_start_binding(BSCallback *bsc)
|
|
|
|
{
|
2011-01-07 14:22:51 +01:00
|
|
|
nsChannelBSC *This = nsChannelBSC_from_BSCallback(bsc);
|
2010-08-18 13:39:04 +02:00
|
|
|
|
|
|
|
if(This->window)
|
|
|
|
This->window->doc->skip_mutation_notif = FALSE;
|
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-08-19 20:40:00 +02:00
|
|
|
static HRESULT nsChannelBSC_init_bindinfo(BSCallback *bsc)
|
|
|
|
{
|
2011-01-07 14:22:51 +01:00
|
|
|
nsChannelBSC *This = nsChannelBSC_from_BSCallback(bsc);
|
2010-08-03 21:40:56 +02:00
|
|
|
HRESULT hres;
|
2009-08-19 20:40:00 +02:00
|
|
|
|
|
|
|
if(This->nschannel && This->nschannel->post_data_stream) {
|
2011-04-05 15:23:25 +02:00
|
|
|
hres = read_post_data_stream(This, This->nschannel);
|
2010-10-27 23:19:10 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2009-08-19 20:40:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-18 13:39:15 +02:00
|
|
|
typedef struct {
|
|
|
|
task_t header;
|
|
|
|
nsChannelBSC *bsc;
|
|
|
|
} stop_request_task_t;
|
|
|
|
|
|
|
|
static void stop_request_proc(task_t *_task)
|
2008-03-23 02:17:17 +01:00
|
|
|
{
|
2010-08-18 13:39:15 +02:00
|
|
|
stop_request_task_t *task = (stop_request_task_t*)_task;
|
2008-03-23 02:17:17 +01:00
|
|
|
|
2010-08-18 13:39:15 +02:00
|
|
|
TRACE("(%p)\n", task->bsc);
|
2008-03-23 02:17:17 +01:00
|
|
|
|
2011-01-31 20:28:10 +01:00
|
|
|
list_remove(&task->bsc->bsc.entry);
|
|
|
|
list_init(&task->bsc->bsc.entry);
|
2010-08-18 13:39:15 +02:00
|
|
|
on_stop_nsrequest(task->bsc, S_OK);
|
2011-08-03 12:35:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void stop_request_task_destr(task_t *_task)
|
|
|
|
{
|
|
|
|
stop_request_task_t *task = (stop_request_task_t*)_task;
|
|
|
|
|
2011-01-03 01:13:16 +01:00
|
|
|
IBindStatusCallback_Release(&task->bsc->bsc.IBindStatusCallback_iface);
|
2011-08-03 12:35:47 +02:00
|
|
|
heap_free(task);
|
2010-08-18 13:39:15 +02:00
|
|
|
}
|
2008-03-23 02:17:17 +01:00
|
|
|
|
2010-08-18 13:39:15 +02:00
|
|
|
static HRESULT async_stop_request(nsChannelBSC *This)
|
|
|
|
{
|
|
|
|
stop_request_task_t *task;
|
|
|
|
|
2011-06-16 16:42:12 +02:00
|
|
|
if(!This->bsc.readed) {
|
|
|
|
TRACE("No data read, calling OnStartRequest\n");
|
|
|
|
on_start_nsrequest(This);
|
|
|
|
}
|
|
|
|
|
2010-08-18 13:39:15 +02:00
|
|
|
task = heap_alloc(sizeof(*task));
|
|
|
|
if(!task)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2011-01-03 01:13:16 +01:00
|
|
|
IBindStatusCallback_AddRef(&This->bsc.IBindStatusCallback_iface);
|
2010-08-18 13:39:15 +02:00
|
|
|
task->bsc = This;
|
2011-08-03 12:35:47 +02:00
|
|
|
push_task(&task->header, stop_request_proc, stop_request_task_destr, This->bsc.doc->basedoc.doc_obj->basedoc.task_magic);
|
2010-08-18 13:39:15 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-03-28 23:35:34 +02:00
|
|
|
static void handle_navigation_error(nsChannelBSC *This, DWORD result)
|
|
|
|
{
|
|
|
|
HTMLDocumentObj *doc;
|
|
|
|
IOleCommandTarget *olecmd;
|
|
|
|
BOOL is_error_url;
|
|
|
|
SAFEARRAY *sa;
|
|
|
|
SAFEARRAYBOUND bound;
|
|
|
|
VARIANT var, varOut;
|
|
|
|
LONG ind;
|
2011-11-10 14:35:11 +01:00
|
|
|
BSTR unk;
|
2011-03-28 23:35:34 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(!This->window)
|
|
|
|
return;
|
|
|
|
|
|
|
|
doc = This->window->doc_obj;
|
|
|
|
if(!doc || !doc->doc_object_service || !doc->client)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hres = IDocObjectService_IsErrorUrl(doc->doc_object_service,
|
|
|
|
This->window->url, &is_error_url);
|
|
|
|
if(FAILED(hres) || is_error_url)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hres = IOleClientSite_QueryInterface(doc->client,
|
|
|
|
&IID_IOleCommandTarget, (void**)&olecmd);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return;
|
|
|
|
|
|
|
|
bound.lLbound = 0;
|
|
|
|
bound.cElements = 8;
|
|
|
|
sa = SafeArrayCreate(VT_VARIANT, 1, &bound);
|
|
|
|
if(!sa) {
|
|
|
|
IOleCommandTarget_Release(olecmd);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ind = 0;
|
|
|
|
V_VT(&var) = VT_I4;
|
|
|
|
V_I4(&var) = result;
|
|
|
|
SafeArrayPutElement(sa, &ind, &var);
|
|
|
|
|
|
|
|
ind = 1;
|
|
|
|
V_VT(&var) = VT_BSTR;
|
2011-11-10 14:35:11 +01:00
|
|
|
V_BSTR(&var) = This->window->url;
|
2011-03-28 23:35:34 +02:00
|
|
|
SafeArrayPutElement(sa, &ind, &var);
|
|
|
|
|
|
|
|
ind = 3;
|
|
|
|
V_VT(&var) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&var) = (IUnknown*)&This->window->IHTMLWindow2_iface;
|
|
|
|
SafeArrayPutElement(sa, &ind, &var);
|
|
|
|
|
|
|
|
/* FIXME: what are the following fields for? */
|
|
|
|
ind = 2;
|
|
|
|
V_VT(&var) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&var) = NULL;
|
|
|
|
SafeArrayPutElement(sa, &ind, &var);
|
|
|
|
|
|
|
|
ind = 4;
|
|
|
|
V_VT(&var) = VT_BOOL;
|
|
|
|
V_BOOL(&var) = FALSE;
|
|
|
|
SafeArrayPutElement(sa, &ind, &var);
|
|
|
|
|
|
|
|
ind = 5;
|
|
|
|
V_VT(&var) = VT_BOOL;
|
|
|
|
V_BOOL(&var) = FALSE;
|
|
|
|
SafeArrayPutElement(sa, &ind, &var);
|
|
|
|
|
|
|
|
ind = 6;
|
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
unk = SysAllocString(NULL);
|
|
|
|
V_BSTR(&var) = unk;
|
|
|
|
SafeArrayPutElement(sa, &ind, &var);
|
|
|
|
|
|
|
|
ind = 7;
|
|
|
|
V_VT(&var) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&var) = NULL;
|
|
|
|
SafeArrayPutElement(sa, &ind, &var);
|
|
|
|
|
|
|
|
V_VT(&var) = VT_ARRAY;
|
|
|
|
V_ARRAY(&var) = sa;
|
|
|
|
V_VT(&varOut) = VT_BOOL;
|
|
|
|
V_BOOL(&varOut) = VARIANT_TRUE;
|
|
|
|
IOleCommandTarget_Exec(olecmd, &CGID_DocHostCmdPriv, 1, 0, &var, FAILED(hres)?NULL:&varOut);
|
|
|
|
|
|
|
|
SysFreeString(unk);
|
|
|
|
SafeArrayDestroy(sa);
|
|
|
|
IOleCommandTarget_Release(olecmd);
|
|
|
|
}
|
|
|
|
|
2010-08-18 13:39:15 +02:00
|
|
|
static HRESULT nsChannelBSC_stop_binding(BSCallback *bsc, HRESULT result)
|
|
|
|
{
|
2011-01-07 14:22:51 +01:00
|
|
|
nsChannelBSC *This = nsChannelBSC_from_BSCallback(bsc);
|
2010-08-18 13:39:15 +02:00
|
|
|
|
2011-05-13 18:18:12 +02:00
|
|
|
if(result != E_ABORT) {
|
|
|
|
if(FAILED(result))
|
|
|
|
handle_navigation_error(This, result);
|
|
|
|
else if(This->window) {
|
|
|
|
result = async_stop_request(This);
|
|
|
|
if(SUCCEEDED(result))
|
|
|
|
return S_OK;
|
|
|
|
}
|
2008-03-23 02:17:17 +01:00
|
|
|
}
|
|
|
|
|
2010-08-18 13:39:15 +02:00
|
|
|
on_stop_nsrequest(This, result);
|
2008-03-23 02:17:17 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT nsChannelBSC_read_data(BSCallback *bsc, IStream *stream)
|
|
|
|
{
|
2011-01-07 14:22:51 +01:00
|
|
|
nsChannelBSC *This = nsChannelBSC_from_BSCallback(bsc);
|
2008-03-23 02:17:17 +01:00
|
|
|
|
|
|
|
return read_stream_data(This, stream);
|
|
|
|
}
|
|
|
|
|
2011-04-15 19:36:36 +02:00
|
|
|
static HRESULT handle_redirect(nsChannelBSC *This, const WCHAR *new_url)
|
|
|
|
{
|
|
|
|
nsRedirectCallback *callback;
|
|
|
|
nsIChannelEventSink *sink;
|
|
|
|
nsChannel *new_channel;
|
|
|
|
nsresult nsres;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_w(new_url));
|
|
|
|
|
|
|
|
if(!This->nschannel || !This->nschannel->notif_callback)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
nsres = nsIInterfaceRequestor_GetInterface(This->nschannel->notif_callback, &IID_nsIChannelEventSink, (void**)&sink);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
hres = create_redirect_nschannel(new_url, This->nschannel, &new_channel);
|
|
|
|
if(SUCCEEDED(hres)) {
|
2012-04-05 13:57:26 +02:00
|
|
|
TRACE("%p %p->%p\n", This, This->nschannel, new_channel);
|
|
|
|
|
2011-04-15 19:36:36 +02:00
|
|
|
hres = create_redirect_callback(new_channel, This, &callback);
|
|
|
|
nsIChannel_Release(&new_channel->nsIHttpChannel_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
nsres = nsIChannelEventSink_AsyncOnChannelRedirect(sink, (nsIChannel*)&This->nschannel->nsIHttpChannel_iface,
|
|
|
|
(nsIChannel*)&callback->nschannel->nsIHttpChannel_iface, REDIRECT_TEMPORARY, /* FIXME */
|
|
|
|
&callback->nsIAsyncVerifyRedirectCallback_iface);
|
|
|
|
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
FIXME("AsyncOnChannelRedirect failed: %08x\n", hres);
|
|
|
|
else if(This->nschannel != callback->nschannel)
|
|
|
|
FIXME("nschannel not updated\n");
|
2011-04-26 03:20:20 +02:00
|
|
|
|
|
|
|
nsIAsyncVerifyRedirectCallback_Release(&callback->nsIAsyncVerifyRedirectCallback_iface);
|
2011-04-15 19:36:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIChannelEventSink_Release(sink);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
static HRESULT nsChannelBSC_on_progress(BSCallback *bsc, ULONG status_code, LPCWSTR status_text)
|
|
|
|
{
|
2011-01-07 14:22:51 +01:00
|
|
|
nsChannelBSC *This = nsChannelBSC_from_BSCallback(bsc);
|
2008-03-23 02:17:17 +01:00
|
|
|
|
|
|
|
switch(status_code) {
|
2008-03-26 15:24:03 +01:00
|
|
|
case BINDSTATUS_MIMETYPEAVAILABLE:
|
2008-03-23 02:17:17 +01:00
|
|
|
if(!This->nschannel)
|
|
|
|
return S_OK;
|
|
|
|
|
2008-03-26 15:24:03 +01:00
|
|
|
heap_free(This->nschannel->content_type);
|
|
|
|
This->nschannel->content_type = heap_strdupWtoA(status_text);
|
2009-12-15 21:16:59 +01:00
|
|
|
break;
|
|
|
|
case BINDSTATUS_REDIRECTING:
|
2011-04-15 19:36:36 +02:00
|
|
|
return handle_redirect(This, status_text);
|
2011-03-28 23:35:34 +02:00
|
|
|
case BINDSTATUS_BEGINDOWNLOADDATA: {
|
|
|
|
IWinInetHttpInfo *http_info;
|
|
|
|
DWORD status, size = sizeof(DWORD);
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(!This->bsc.binding)
|
|
|
|
break;
|
|
|
|
|
|
|
|
hres = IBinding_QueryInterface(This->bsc.binding, &IID_IWinInetHttpInfo, (void**)&http_info);
|
|
|
|
if(FAILED(hres))
|
|
|
|
break;
|
|
|
|
|
|
|
|
hres = IWinInetHttpInfo_QueryInfo(http_info,
|
|
|
|
HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL, NULL);
|
|
|
|
IWinInetHttpInfo_Release(http_info);
|
|
|
|
if(FAILED(hres) || status == HTTP_STATUS_OK)
|
|
|
|
break;
|
|
|
|
|
|
|
|
handle_navigation_error(This, status);
|
|
|
|
}
|
2008-03-23 02:17:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-04-03 00:31:45 +02:00
|
|
|
static HRESULT nsChannelBSC_on_response(BSCallback *bsc, DWORD response_code,
|
|
|
|
LPCWSTR response_headers)
|
2009-08-11 19:15:07 +02:00
|
|
|
{
|
2011-01-07 14:22:51 +01:00
|
|
|
nsChannelBSC *This = nsChannelBSC_from_BSCallback(bsc);
|
2010-08-03 21:38:37 +02:00
|
|
|
HRESULT hres;
|
2009-08-11 19:15:07 +02:00
|
|
|
|
|
|
|
This->nschannel->response_status = response_code;
|
2010-04-03 00:31:45 +02:00
|
|
|
|
|
|
|
if(response_headers) {
|
2010-08-03 21:38:53 +02:00
|
|
|
const WCHAR *headers;
|
|
|
|
|
|
|
|
headers = strchrW(response_headers, '\r');
|
|
|
|
if(headers && headers[1] == '\n') {
|
|
|
|
headers += 2;
|
2011-11-23 16:19:05 +01:00
|
|
|
hres = process_response_headers(This, headers);
|
2010-08-03 21:38:53 +02:00
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("parsing headers failed: %08x\n", hres);
|
2010-08-03 21:38:37 +02:00
|
|
|
return hres;
|
2010-08-03 21:38:53 +02:00
|
|
|
}
|
2010-04-03 00:31:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-11 19:15:07 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-03 21:39:04 +02:00
|
|
|
static HRESULT nsChannelBSC_beginning_transaction(BSCallback *bsc, WCHAR **additional_headers)
|
|
|
|
{
|
2011-01-07 14:22:51 +01:00
|
|
|
nsChannelBSC *This = nsChannelBSC_from_BSCallback(bsc);
|
2010-08-03 21:39:34 +02:00
|
|
|
http_header_t *iter;
|
|
|
|
DWORD len = 0;
|
|
|
|
WCHAR *ptr;
|
|
|
|
|
|
|
|
static const WCHAR content_lengthW[] =
|
|
|
|
{'C','o','n','t','e','n','t','-','L','e','n','g','t','h',0};
|
|
|
|
|
|
|
|
if(!This->nschannel)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(iter, &This->nschannel->request_headers, http_header_t, entry) {
|
|
|
|
if(strcmpW(iter->header, content_lengthW))
|
|
|
|
len += strlenW(iter->header) + 2 /* ": " */ + strlenW(iter->data) + 2 /* "\r\n" */;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!len)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
*additional_headers = ptr = CoTaskMemAlloc((len+1)*sizeof(WCHAR));
|
|
|
|
if(!ptr)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(iter, &This->nschannel->request_headers, http_header_t, entry) {
|
|
|
|
if(!strcmpW(iter->header, content_lengthW))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
len = strlenW(iter->header);
|
|
|
|
memcpy(ptr, iter->header, len*sizeof(WCHAR));
|
|
|
|
ptr += len;
|
|
|
|
|
|
|
|
*ptr++ = ':';
|
|
|
|
*ptr++ = ' ';
|
|
|
|
|
|
|
|
len = strlenW(iter->data);
|
|
|
|
memcpy(ptr, iter->data, len*sizeof(WCHAR));
|
|
|
|
ptr += len;
|
|
|
|
|
|
|
|
*ptr++ = '\r';
|
|
|
|
*ptr++ = '\n';
|
|
|
|
}
|
|
|
|
|
|
|
|
*ptr = 0;
|
|
|
|
|
|
|
|
return S_OK;
|
2010-08-03 21:39:04 +02:00
|
|
|
}
|
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
static const BSCallbackVtbl nsChannelBSCVtbl = {
|
|
|
|
nsChannelBSC_destroy,
|
2009-08-19 20:40:00 +02:00
|
|
|
nsChannelBSC_init_bindinfo,
|
2008-03-23 02:17:17 +01:00
|
|
|
nsChannelBSC_start_binding,
|
|
|
|
nsChannelBSC_stop_binding,
|
|
|
|
nsChannelBSC_read_data,
|
|
|
|
nsChannelBSC_on_progress,
|
2010-08-03 21:39:04 +02:00
|
|
|
nsChannelBSC_on_response,
|
|
|
|
nsChannelBSC_beginning_transaction
|
2008-03-23 02:17:17 +01:00
|
|
|
};
|
|
|
|
|
2011-11-15 13:29:43 +01:00
|
|
|
HRESULT create_channelbsc(IMoniker *mon, const WCHAR *headers, BYTE *post_data, DWORD post_data_size, nsChannelBSC **retval)
|
2008-03-23 02:17:17 +01:00
|
|
|
{
|
2010-03-03 14:53:49 +01:00
|
|
|
nsChannelBSC *ret;
|
|
|
|
|
|
|
|
ret = heap_alloc_zero(sizeof(*ret));
|
|
|
|
if(!ret)
|
|
|
|
return E_OUTOFMEMORY;
|
2008-03-23 02:17:17 +01:00
|
|
|
|
|
|
|
init_bscallback(&ret->bsc, &nsChannelBSCVtbl, mon, BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA);
|
|
|
|
|
2010-03-03 14:53:49 +01:00
|
|
|
if(headers) {
|
|
|
|
ret->bsc.headers = heap_strdupW(headers);
|
|
|
|
if(!ret->bsc.headers) {
|
2011-01-03 01:13:16 +01:00
|
|
|
IBindStatusCallback_Release(&ret->bsc.IBindStatusCallback_iface);
|
2010-03-03 14:53:49 +01:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(post_data) {
|
|
|
|
ret->bsc.post_data = GlobalAlloc(0, post_data_size);
|
2010-03-04 12:39:18 +01:00
|
|
|
if(!ret->bsc.post_data) {
|
|
|
|
heap_free(ret->bsc.headers);
|
2011-01-03 01:13:16 +01:00
|
|
|
IBindStatusCallback_Release(&ret->bsc.IBindStatusCallback_iface);
|
2010-03-03 14:53:49 +01:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(ret->bsc.post_data, post_data, post_data_size);
|
|
|
|
ret->bsc.post_data_len = post_data_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
*retval = ret;
|
|
|
|
return S_OK;
|
2008-03-23 02:17:17 +01:00
|
|
|
}
|
|
|
|
|
2009-10-26 23:03:53 +01:00
|
|
|
void set_window_bscallback(HTMLWindow *window, nsChannelBSC *callback)
|
2006-09-24 23:39:55 +02:00
|
|
|
{
|
2009-10-26 23:03:53 +01:00
|
|
|
if(window->bscallback) {
|
|
|
|
if(window->bscallback->bsc.binding)
|
|
|
|
IBinding_Abort(window->bscallback->bsc.binding);
|
|
|
|
window->bscallback->bsc.doc = NULL;
|
2009-10-26 23:05:37 +01:00
|
|
|
window->bscallback->window = NULL;
|
2011-01-03 01:13:16 +01:00
|
|
|
IBindStatusCallback_Release(&window->bscallback->bsc.IBindStatusCallback_iface);
|
2006-09-24 23:39:55 +02:00
|
|
|
}
|
|
|
|
|
2009-10-26 23:03:53 +01:00
|
|
|
window->bscallback = callback;
|
2006-09-24 23:39:55 +02:00
|
|
|
|
|
|
|
if(callback) {
|
2009-10-26 23:05:37 +01:00
|
|
|
callback->window = window;
|
2011-01-03 01:13:16 +01:00
|
|
|
IBindStatusCallback_AddRef(&callback->bsc.IBindStatusCallback_iface);
|
2009-10-26 23:05:37 +01:00
|
|
|
callback->bsc.doc = window->doc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-03 14:53:32 +01:00
|
|
|
typedef struct {
|
|
|
|
task_t header;
|
|
|
|
HTMLWindow *window;
|
|
|
|
nsChannelBSC *bscallback;
|
|
|
|
} start_doc_binding_task_t;
|
|
|
|
|
|
|
|
static void start_doc_binding_proc(task_t *_task)
|
|
|
|
{
|
|
|
|
start_doc_binding_task_t *task = (start_doc_binding_task_t*)_task;
|
|
|
|
|
|
|
|
start_binding(task->window, NULL, (BSCallback*)task->bscallback, NULL);
|
2011-08-03 12:36:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void start_doc_binding_task_destr(task_t *_task)
|
|
|
|
{
|
|
|
|
start_doc_binding_task_t *task = (start_doc_binding_task_t*)_task;
|
|
|
|
|
2011-01-03 01:13:16 +01:00
|
|
|
IBindStatusCallback_Release(&task->bscallback->bsc.IBindStatusCallback_iface);
|
2011-08-03 12:36:10 +02:00
|
|
|
heap_free(task);
|
2010-03-03 14:53:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT async_start_doc_binding(HTMLWindow *window, nsChannelBSC *bscallback)
|
|
|
|
{
|
|
|
|
start_doc_binding_task_t *task;
|
|
|
|
|
2011-11-15 13:29:43 +01:00
|
|
|
TRACE("%p\n", bscallback);
|
|
|
|
|
2010-03-03 14:53:32 +01:00
|
|
|
task = heap_alloc(sizeof(start_doc_binding_task_t));
|
|
|
|
if(!task)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
task->window = window;
|
|
|
|
task->bscallback = bscallback;
|
2011-01-03 01:13:16 +01:00
|
|
|
IBindStatusCallback_AddRef(&bscallback->bsc.IBindStatusCallback_iface);
|
2010-03-03 14:53:32 +01:00
|
|
|
|
2011-08-03 12:36:10 +02:00
|
|
|
push_task(&task->header, start_doc_binding_proc, start_doc_binding_task_destr, window->task_magic);
|
2010-03-03 14:53:32 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-10-26 23:05:37 +01:00
|
|
|
void abort_document_bindings(HTMLDocumentNode *doc)
|
|
|
|
{
|
2011-01-31 20:28:10 +01:00
|
|
|
BSCallback *iter, *next;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(iter, next, &doc->bindings, BSCallback, entry) {
|
2011-05-13 18:18:23 +02:00
|
|
|
TRACE("Aborting %p\n", iter);
|
|
|
|
|
2011-01-31 20:28:10 +01:00
|
|
|
if(iter->doc)
|
|
|
|
remove_target_tasks(iter->doc->basedoc.task_magic);
|
2009-10-26 23:05:37 +01:00
|
|
|
|
|
|
|
if(iter->binding)
|
|
|
|
IBinding_Abort(iter->binding);
|
2011-01-31 20:28:10 +01:00
|
|
|
else {
|
|
|
|
list_remove(&iter->entry);
|
|
|
|
list_init(&iter->entry);
|
2011-05-13 18:18:23 +02:00
|
|
|
iter->vtbl->stop_binding(iter, E_ABORT);
|
2011-01-31 20:28:10 +01:00
|
|
|
}
|
|
|
|
|
2009-10-26 23:05:37 +01:00
|
|
|
iter->doc = NULL;
|
2006-09-24 23:39:55 +02:00
|
|
|
}
|
|
|
|
}
|
2007-05-11 13:17:41 +02:00
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
HRESULT channelbsc_load_stream(nsChannelBSC *bscallback, IStream *stream)
|
2007-05-11 13:17:41 +02:00
|
|
|
{
|
2010-08-18 13:39:15 +02:00
|
|
|
HRESULT hres = S_OK;
|
2007-05-11 13:17:41 +02:00
|
|
|
|
2009-11-12 14:51:43 +01:00
|
|
|
if(!bscallback->nschannel) {
|
|
|
|
ERR("NULL nschannel\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2007-05-11 13:17:41 +02:00
|
|
|
|
2009-11-12 14:51:43 +01:00
|
|
|
bscallback->nschannel->content_type = heap_strdupA("text/html");
|
|
|
|
if(!bscallback->nschannel->content_type)
|
|
|
|
return E_OUTOFMEMORY;
|
2007-05-11 13:17:41 +02:00
|
|
|
|
2011-01-31 20:28:10 +01:00
|
|
|
list_add_head(&bscallback->bsc.doc->bindings, &bscallback->bsc.entry);
|
2010-08-18 13:39:15 +02:00
|
|
|
if(stream)
|
|
|
|
hres = read_stream_data(bscallback, stream);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
hres = async_stop_request(bscallback);
|
|
|
|
if(FAILED(hres))
|
2011-01-03 01:13:16 +01:00
|
|
|
IBindStatusCallback_OnStopBinding(&bscallback->bsc.IBindStatusCallback_iface, hres,
|
|
|
|
ERROR_SUCCESS);
|
2007-05-11 13:17:41 +02:00
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
2008-03-23 02:15:20 +01:00
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
void channelbsc_set_channel(nsChannelBSC *This, nsChannel *channel, nsIStreamListener *listener, nsISupports *context)
|
2008-03-23 02:15:20 +01:00
|
|
|
{
|
2010-12-30 01:43:11 +01:00
|
|
|
nsIChannel_AddRef(&channel->nsIHttpChannel_iface);
|
2008-03-23 02:15:20 +01:00
|
|
|
This->nschannel = channel;
|
|
|
|
|
|
|
|
nsIStreamListener_AddRef(listener);
|
|
|
|
This->nslistener = listener;
|
|
|
|
|
|
|
|
if(context) {
|
|
|
|
nsISupports_AddRef(context);
|
|
|
|
This->nscontext = context;
|
|
|
|
}
|
2010-08-03 21:39:34 +02:00
|
|
|
|
|
|
|
if(This->bsc.headers) {
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = parse_headers(This->bsc.headers, &channel->request_headers);
|
|
|
|
heap_free(This->bsc.headers);
|
|
|
|
This->bsc.headers = NULL;
|
|
|
|
if(FAILED(hres))
|
|
|
|
WARN("parse_headers failed: %08x\n", hres);
|
|
|
|
}
|
2008-03-23 02:15:20 +01:00
|
|
|
}
|
2008-03-23 02:16:36 +01:00
|
|
|
|
2011-11-15 13:29:43 +01:00
|
|
|
typedef struct {
|
|
|
|
task_t header;
|
|
|
|
HTMLWindow *window;
|
|
|
|
IUri *uri;
|
|
|
|
} navigate_javascript_task_t;
|
|
|
|
|
|
|
|
static void navigate_javascript_proc(task_t *_task)
|
|
|
|
{
|
|
|
|
navigate_javascript_task_t *task = (navigate_javascript_task_t*)_task;
|
|
|
|
HTMLWindow *window = task->window;
|
|
|
|
VARIANT v;
|
|
|
|
BSTR code;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
static const WCHAR jscriptW[] = {'j','s','c','r','i','p','t',0};
|
|
|
|
|
|
|
|
task->window->readystate = READYSTATE_COMPLETE;
|
|
|
|
|
|
|
|
hres = IUri_GetPath(task->uri, &code);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return;
|
|
|
|
|
|
|
|
set_download_state(window->doc_obj, 1);
|
|
|
|
|
|
|
|
V_VT(&v) = VT_EMPTY;
|
|
|
|
hres = exec_script(window, code, jscriptW, &v);
|
|
|
|
SysFreeString(code);
|
|
|
|
if(SUCCEEDED(hres) && V_VT(&v) != VT_EMPTY) {
|
|
|
|
FIXME("javascirpt URL returned %s\n", debugstr_variant(&v));
|
|
|
|
VariantClear(&v);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(window->doc_obj->view_sink)
|
|
|
|
IAdviseSink_OnViewChange(window->doc_obj->view_sink, DVASPECT_CONTENT, -1);
|
|
|
|
|
|
|
|
set_download_state(window->doc_obj, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void navigate_javascript_task_destr(task_t *_task)
|
|
|
|
{
|
|
|
|
navigate_javascript_task_t *task = (navigate_javascript_task_t*)_task;
|
|
|
|
|
|
|
|
IUri_Release(task->uri);
|
|
|
|
heap_free(task);
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
task_t header;
|
|
|
|
HTMLWindow *window;
|
|
|
|
nsChannelBSC *bscallback;
|
|
|
|
IMoniker *mon;
|
|
|
|
} navigate_task_t;
|
|
|
|
|
|
|
|
static void navigate_proc(task_t *_task)
|
|
|
|
{
|
|
|
|
navigate_task_t *task = (navigate_task_t*)_task;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = set_moniker(&task->window->doc_obj->basedoc, task->mon, NULL, task->bscallback, TRUE);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
start_binding(task->window, NULL, (BSCallback*)task->bscallback, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void navigate_task_destr(task_t *_task)
|
|
|
|
{
|
|
|
|
navigate_task_t *task = (navigate_task_t*)_task;
|
|
|
|
|
|
|
|
IUnknown_Release((IUnknown*)task->bscallback);
|
|
|
|
IMoniker_Release(task->mon);
|
|
|
|
heap_free(task);
|
|
|
|
}
|
|
|
|
|
2011-11-15 13:30:28 +01:00
|
|
|
static HRESULT navigate_fragment(HTMLWindow *window, IUri *uri)
|
|
|
|
{
|
|
|
|
nsIDOMLocation *nslocation;
|
|
|
|
nsAString nsfrag_str;
|
|
|
|
BSTR frag;
|
|
|
|
nsresult nsres;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
set_current_uri(window, uri);
|
|
|
|
|
|
|
|
nsres = nsIDOMWindow_GetLocation(window->nswindow, &nslocation);
|
|
|
|
if(FAILED(nsres) || !nslocation)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
hres = IUri_GetFragment(uri, &frag);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
nsIDOMLocation_Release(nslocation);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAString_InitDepend(&nsfrag_str, frag);
|
|
|
|
nsres = nsIDOMLocation_SetHash(nslocation, &nsfrag_str);
|
|
|
|
nsAString_Finish(&nsfrag_str);
|
|
|
|
nsIDOMLocation_Release(nslocation);
|
|
|
|
SysFreeString(frag);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("SetHash failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(window->doc_obj->doc_object_service) {
|
|
|
|
IDocObjectService_FireNavigateComplete2(window->doc_obj->doc_object_service, &window->IHTMLWindow2_iface, 0x10);
|
|
|
|
IDocObjectService_FireDocumentComplete(window->doc_obj->doc_object_service, &window->IHTMLWindow2_iface, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-11-15 13:29:43 +01:00
|
|
|
HRESULT super_navigate(HTMLWindow *window, IUri *uri, const WCHAR *headers, BYTE *post_data, DWORD post_data_size)
|
|
|
|
{
|
|
|
|
nsChannelBSC *bsc;
|
|
|
|
IMoniker *mon;
|
|
|
|
DWORD scheme;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(window->doc_obj->client) {
|
|
|
|
IOleCommandTarget *cmdtrg;
|
|
|
|
|
|
|
|
hres = IOleClientSite_QueryInterface(window->doc_obj->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
VARIANT in, out;
|
|
|
|
BSTR url_str;
|
|
|
|
|
|
|
|
hres = IUri_GetDisplayUri(uri, &url_str);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
V_VT(&in) = VT_BSTR;
|
|
|
|
V_BSTR(&in) = url_str;
|
|
|
|
V_VT(&out) = VT_BOOL;
|
|
|
|
V_BOOL(&out) = VARIANT_TRUE;
|
|
|
|
hres = IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 67, 0, &in, &out);
|
|
|
|
IOleCommandTarget_Release(cmdtrg);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
VariantClear(&out);
|
|
|
|
SysFreeString(url_str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-26 15:15:39 +01:00
|
|
|
if(window->uri && !post_data_size && compare_ignoring_frag(window->uri, uri)) {
|
2011-11-15 13:30:28 +01:00
|
|
|
TRACE("fragment navigate\n");
|
|
|
|
return navigate_fragment(window, uri);
|
|
|
|
}
|
|
|
|
|
2011-11-15 13:29:43 +01:00
|
|
|
hres = CreateURLMonikerEx2(NULL, uri, &mon, URL_MK_UNIFORM);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
/* FIXME: Why not set_ready_state? */
|
|
|
|
window->readystate = READYSTATE_UNINITIALIZED;
|
|
|
|
|
|
|
|
hres = create_channelbsc(mon, headers, post_data, post_data_size, &bsc);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
prepare_for_binding(&window->doc_obj->basedoc, mon, TRUE);
|
|
|
|
|
|
|
|
hres = IUri_GetScheme(uri, &scheme);
|
2012-02-01 13:58:42 +01:00
|
|
|
if(SUCCEEDED(hres) && scheme != URL_SCHEME_JAVASCRIPT) {
|
2011-11-15 13:29:43 +01:00
|
|
|
navigate_task_t *task;
|
|
|
|
|
|
|
|
task = heap_alloc(sizeof(*task));
|
|
|
|
if(!task) {
|
|
|
|
IUnknown_Release((IUnknown*)bsc);
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
task->window = window;
|
|
|
|
task->bscallback = bsc;
|
|
|
|
task->mon = mon;
|
|
|
|
push_task(&task->header, navigate_proc, navigate_task_destr, window->task_magic);
|
|
|
|
|
|
|
|
/* Silently and repeated when real loading starts? */
|
|
|
|
window->readystate = READYSTATE_LOADING;
|
|
|
|
}else {
|
|
|
|
navigate_javascript_task_t *task;
|
|
|
|
|
|
|
|
IUnknown_Release((IUnknown*)bsc);
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
|
|
|
|
task = heap_alloc(sizeof(*task));
|
|
|
|
if(!task)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
IUri_AddRef(uri);
|
|
|
|
task->window = window;
|
|
|
|
task->uri = uri;
|
|
|
|
push_task(&task->header, navigate_javascript_proc, navigate_javascript_task_destr, window->task_magic);
|
|
|
|
|
|
|
|
/* Why silently? */
|
|
|
|
window->readystate = READYSTATE_COMPLETE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-09 17:56:54 +01:00
|
|
|
HRESULT navigate_new_window(HTMLWindow *window, IUri *uri, const WCHAR *name, IHTMLWindow2 **ret)
|
|
|
|
{
|
|
|
|
IWebBrowser2 *web_browser;
|
|
|
|
IHTMLWindow2 *new_window;
|
|
|
|
IBindCtx *bind_ctx;
|
|
|
|
nsChannelBSC *bsc;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = create_channelbsc(NULL, NULL, NULL, 0, &bsc);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = CreateAsyncBindCtx(0, &bsc->bsc.IBindStatusCallback_iface, NULL, &bind_ctx);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
IBindStatusCallback_Release(&bsc->bsc.IBindStatusCallback_iface);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = CoCreateInstance(&CLSID_InternetExplorer, NULL, CLSCTX_LOCAL_SERVER,
|
|
|
|
&IID_IWebBrowser2, (void**)&web_browser);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
ITargetFramePriv2 *target_frame_priv;
|
|
|
|
|
|
|
|
hres = IWebBrowser_QueryInterface(web_browser, &IID_ITargetFramePriv2, (void**)&target_frame_priv);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
hres = ITargetFramePriv2_AggregatedNavigation2(target_frame_priv,
|
|
|
|
HLNF_DISABLEWINDOWRESTRICTIONS|HLNF_OPENINNEWWINDOW, bind_ctx, &bsc->bsc.IBindStatusCallback_iface,
|
|
|
|
name, uri, emptyW);
|
|
|
|
ITargetFramePriv2_Release(target_frame_priv);
|
|
|
|
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
hres = do_query_service((IUnknown*)web_browser, &SID_SHTMLWindow, &IID_IHTMLWindow2, (void**)&new_window);
|
|
|
|
}
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
IWebBrowser2_Quit(web_browser);
|
|
|
|
IWebBrowser2_Release(web_browser);
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
WARN("Could not create InternetExplorer instance: %08x\n", hres);
|
|
|
|
}
|
|
|
|
|
|
|
|
IBindStatusCallback_Release(&bsc->bsc.IBindStatusCallback_iface);
|
|
|
|
IBindCtx_Release(bind_ctx);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
IWebBrowser2_put_Visible(web_browser, VARIANT_TRUE);
|
|
|
|
IWebBrowser2_Release(web_browser);
|
|
|
|
|
2012-01-10 17:07:36 +01:00
|
|
|
if(ret)
|
|
|
|
*ret = new_window;
|
|
|
|
else
|
|
|
|
IHTMLWindow2_Release(new_window);
|
2012-01-09 17:56:54 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-04-05 15:23:25 +02:00
|
|
|
HRESULT hlink_frame_navigate(HTMLDocument *doc, LPCWSTR url, nsChannel *nschannel, DWORD hlnf, BOOL *cancel)
|
2008-03-23 02:16:36 +01:00
|
|
|
{
|
2009-10-11 21:11:03 +02:00
|
|
|
IHlinkFrame *hlink_frame;
|
2010-03-03 14:53:49 +01:00
|
|
|
nsChannelBSC *callback;
|
2008-03-23 02:16:36 +01:00
|
|
|
IBindCtx *bindctx;
|
|
|
|
IMoniker *mon;
|
|
|
|
IHlink *hlink;
|
2009-10-11 21:11:03 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
2010-03-03 14:54:44 +01:00
|
|
|
*cancel = FALSE;
|
|
|
|
|
2012-01-05 18:30:27 +01:00
|
|
|
hres = do_query_service((IUnknown*)doc->doc_obj->client, &IID_IHlinkFrame, &IID_IHlinkFrame,
|
2009-10-11 21:11:03 +02:00
|
|
|
(void**)&hlink_frame);
|
|
|
|
if(FAILED(hres))
|
2010-03-03 14:54:44 +01:00
|
|
|
return S_OK;
|
2008-03-23 02:16:36 +01:00
|
|
|
|
2010-03-03 14:53:49 +01:00
|
|
|
hres = create_channelbsc(NULL, NULL, NULL, 0, &callback);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
IHlinkFrame_Release(hlink_frame);
|
|
|
|
return hres;
|
|
|
|
}
|
2008-03-23 02:16:36 +01:00
|
|
|
|
2011-04-05 15:23:25 +02:00
|
|
|
if(nschannel)
|
|
|
|
read_post_data_stream(callback, nschannel);
|
2008-03-23 02:16:36 +01:00
|
|
|
|
2011-01-03 01:13:16 +01:00
|
|
|
hres = CreateAsyncBindCtx(0, &callback->bsc.IBindStatusCallback_iface, NULL, &bindctx);
|
2009-10-11 21:11:03 +02:00
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
hres = CoCreateInstance(&CLSID_StdHlink, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IHlink, (LPVOID*)&hlink);
|
2008-03-23 02:16:36 +01:00
|
|
|
|
2009-10-11 21:11:03 +02:00
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
hres = CreateURLMoniker(NULL, url, &mon);
|
2008-03-23 02:16:36 +01:00
|
|
|
|
2009-10-11 21:11:03 +02:00
|
|
|
if(SUCCEEDED(hres)) {
|
2009-10-20 23:33:27 +02:00
|
|
|
IHlink_SetMonikerReference(hlink, HLINKSETF_TARGET, mon, NULL);
|
2008-03-23 02:16:36 +01:00
|
|
|
|
|
|
|
if(hlnf & HLNF_OPENINNEWWINDOW) {
|
|
|
|
static const WCHAR wszBlank[] = {'_','b','l','a','n','k',0};
|
|
|
|
IHlink_SetTargetFrameName(hlink, wszBlank); /* FIXME */
|
|
|
|
}
|
|
|
|
|
2011-01-03 01:13:16 +01:00
|
|
|
hres = IHlinkFrame_Navigate(hlink_frame, hlnf, bindctx,
|
|
|
|
&callback->bsc.IBindStatusCallback_iface, hlink);
|
2008-03-23 02:16:36 +01:00
|
|
|
IMoniker_Release(mon);
|
2010-03-03 14:54:44 +01:00
|
|
|
*cancel = hres == S_OK;
|
|
|
|
hres = S_OK;
|
2008-03-23 02:16:36 +01:00
|
|
|
}
|
|
|
|
|
2009-10-11 21:11:03 +02:00
|
|
|
IHlinkFrame_Release(hlink_frame);
|
2008-03-23 02:16:36 +01:00
|
|
|
IBindCtx_Release(bindctx);
|
2011-01-03 01:13:16 +01:00
|
|
|
IBindStatusCallback_Release(&callback->bsc.IBindStatusCallback_iface);
|
2009-10-11 21:11:03 +02:00
|
|
|
return hres;
|
2008-03-23 02:16:36 +01:00
|
|
|
}
|
2009-10-11 21:11:35 +02:00
|
|
|
|
2009-11-30 18:00:38 +01:00
|
|
|
HRESULT navigate_url(HTMLWindow *window, const WCHAR *new_url, const WCHAR *base_url)
|
2009-10-11 21:11:35 +02:00
|
|
|
{
|
2009-11-30 18:00:38 +01:00
|
|
|
WCHAR url[INTERNET_MAX_URL_LENGTH];
|
2010-02-21 21:06:51 +01:00
|
|
|
nsWineURI *uri;
|
2009-10-11 21:11:35 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
2009-11-30 18:00:38 +01:00
|
|
|
if(!new_url) {
|
|
|
|
*url = 0;
|
|
|
|
}else if(base_url) {
|
|
|
|
DWORD len = 0;
|
2009-10-11 21:11:35 +02:00
|
|
|
|
2009-11-30 18:00:38 +01:00
|
|
|
hres = CoInternetCombineUrl(base_url, new_url, URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO,
|
|
|
|
url, sizeof(url)/sizeof(WCHAR), &len, 0);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}else {
|
|
|
|
strcpyW(url, new_url);
|
2009-10-11 21:11:35 +02:00
|
|
|
}
|
|
|
|
|
2009-11-30 18:00:38 +01:00
|
|
|
if(window->doc_obj && window->doc_obj->hostui) {
|
|
|
|
OLECHAR *translated_url = NULL;
|
|
|
|
|
|
|
|
hres = IDocHostUIHandler_TranslateUrl(window->doc_obj->hostui, 0, url,
|
|
|
|
&translated_url);
|
|
|
|
if(hres == S_OK) {
|
2010-03-03 14:54:44 +01:00
|
|
|
TRACE("%08x %s -> %s\n", hres, debugstr_w(url), debugstr_w(translated_url));
|
2009-11-30 18:00:38 +01:00
|
|
|
strcpyW(url, translated_url);
|
|
|
|
CoTaskMemFree(translated_url);
|
|
|
|
}
|
2009-11-30 17:58:37 +01:00
|
|
|
}
|
|
|
|
|
2011-11-24 02:25:25 +01:00
|
|
|
if(window->doc_obj && window->doc_obj->is_webbrowser && window == window->doc_obj->basedoc.window) {
|
2011-11-15 13:29:59 +01:00
|
|
|
BOOL cancel = FALSE;
|
|
|
|
IUri *uri;
|
|
|
|
|
|
|
|
hres = IDocObjectService_FireBeforeNavigate2(window->doc_obj->doc_object_service, NULL, url, 0x40,
|
|
|
|
NULL, NULL, 0, NULL, TRUE, &cancel);
|
|
|
|
if(SUCCEEDED(hres) && cancel) {
|
|
|
|
TRACE("Navigation canceled\n");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = CreateUri(url, 0, 0, &uri);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = super_navigate(window, uri, NULL, NULL, 0);
|
|
|
|
IUri_Release(uri);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2009-11-30 18:01:31 +01:00
|
|
|
if(window->doc_obj && window == window->doc_obj->basedoc.window) {
|
2010-03-03 14:54:44 +01:00
|
|
|
BOOL cancel;
|
|
|
|
|
|
|
|
hres = hlink_frame_navigate(&window->doc->basedoc, url, NULL, 0, &cancel);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(cancel) {
|
|
|
|
TRACE("Navigation handled by hlink frame\n");
|
2009-11-30 18:01:31 +01:00
|
|
|
return S_OK;
|
2010-03-03 14:54:44 +01:00
|
|
|
}
|
2009-11-30 18:01:31 +01:00
|
|
|
}
|
2009-10-11 21:11:35 +02:00
|
|
|
|
2009-11-30 18:01:31 +01:00
|
|
|
hres = create_doc_uri(window, url, &uri);
|
2010-01-04 00:38:57 +01:00
|
|
|
if(FAILED(hres))
|
2009-11-30 18:01:31 +01:00
|
|
|
return hres;
|
|
|
|
|
2010-02-21 21:06:51 +01:00
|
|
|
hres = load_nsuri(window, uri, NULL, LOAD_FLAGS_NONE);
|
|
|
|
nsISupports_Release((nsISupports*)uri);
|
2010-01-04 00:38:57 +01:00
|
|
|
return hres;
|
2009-10-11 21:11:35 +02:00
|
|
|
}
|