2006-02-13 13:26:00 +01:00
|
|
|
/*
|
2007-05-11 13:17:41 +02:00
|
|
|
* Copyright 2006-2007 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"
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
|
|
|
|
#include "mshtml_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
|
|
|
|
|
|
|
#define CONTENT_LENGTH "Content-Length"
|
2007-04-12 21:25:08 +02:00
|
|
|
#define UTF16_STR "utf-16"
|
2006-02-13 13:26:00 +01:00
|
|
|
|
2008-03-23 02:16:18 +01:00
|
|
|
typedef struct {
|
|
|
|
const nsIInputStreamVtbl *lpInputStreamVtbl;
|
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
char buf[1024];
|
|
|
|
DWORD buf_size;
|
|
|
|
} nsProtocolStream;
|
|
|
|
|
2006-06-03 01:26:00 +02:00
|
|
|
#define NSINSTREAM(x) ((nsIInputStream*) &(x)->lpInputStreamVtbl)
|
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
typedef struct {
|
|
|
|
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);
|
2009-08-11 19:15:07 +02:00
|
|
|
HRESULT (*on_response)(BSCallback*,DWORD);
|
2008-03-23 02:17:17 +01:00
|
|
|
} BSCallbackVtbl;
|
|
|
|
|
2008-03-23 02:16:18 +01:00
|
|
|
struct BSCallback {
|
|
|
|
const IBindStatusCallbackVtbl *lpBindStatusCallbackVtbl;
|
|
|
|
const IServiceProviderVtbl *lpServiceProviderVtbl;
|
|
|
|
const IHttpNegotiate2Vtbl *lpHttpNegotiate2Vtbl;
|
|
|
|
const IInternetBindInfoVtbl *lpInternetBindInfoVtbl;
|
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
const BSCallbackVtbl *vtbl;
|
|
|
|
|
2008-03-23 02:16:18 +01:00
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
LPWSTR headers;
|
|
|
|
HGLOBAL post_data;
|
|
|
|
ULONG post_data_len;
|
|
|
|
ULONG readed;
|
2008-03-23 02:17:17 +01:00
|
|
|
DWORD bindf;
|
2009-08-19 20:40:00 +02:00
|
|
|
BOOL bindinfo_ready;
|
2008-03-23 02:16:18 +01:00
|
|
|
|
|
|
|
IMoniker *mon;
|
|
|
|
IBinding *binding;
|
|
|
|
|
2009-10-26 23:05:37 +01:00
|
|
|
HTMLDocumentNode *doc;
|
2008-03-23 02:16:18 +01:00
|
|
|
|
|
|
|
struct list entry;
|
|
|
|
};
|
|
|
|
|
2006-06-03 01:26:00 +02:00
|
|
|
#define NSINSTREAM_THIS(iface) DEFINE_THIS(nsProtocolStream, InputStream, iface)
|
|
|
|
|
|
|
|
static nsresult NSAPI nsInputStream_QueryInterface(nsIInputStream *iface, nsIIDRef riid,
|
|
|
|
nsQIResult result)
|
|
|
|
{
|
|
|
|
nsProtocolStream *This = NSINSTREAM_THIS(iface);
|
|
|
|
|
|
|
|
*result = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_nsISupports, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsISupports %p)\n", This, result);
|
|
|
|
*result = NSINSTREAM(This);
|
|
|
|
}else if(IsEqualGUID(&IID_nsIInputStream, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIInputStream %p)\n", This, result);
|
|
|
|
*result = NSINSTREAM(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*result) {
|
|
|
|
nsIInputStream_AddRef(NSINSTREAM(This));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("unsupported interface %s\n", debugstr_guid(riid));
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsInputStream_AddRef(nsIInputStream *iface)
|
|
|
|
{
|
|
|
|
nsProtocolStream *This = NSINSTREAM_THIS(iface);
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
nsProtocolStream *This = NSINSTREAM_THIS(iface);
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
nsProtocolStream *This = NSINSTREAM_THIS(iface);
|
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsInputStream_Available(nsIInputStream *iface, PRUint32 *_retval)
|
|
|
|
{
|
|
|
|
nsProtocolStream *This = NSINSTREAM_THIS(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, _retval);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsInputStream_Read(nsIInputStream *iface, char *aBuf, PRUint32 aCount,
|
|
|
|
PRUint32 *_retval)
|
|
|
|
{
|
|
|
|
nsProtocolStream *This = NSINSTREAM_THIS(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)
|
|
|
|
{
|
|
|
|
nsProtocolStream *This = NSINSTREAM_THIS(iface);
|
|
|
|
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
|
|
|
|
2008-12-18 14:08:47 +01:00
|
|
|
nsres = aWriter(NSINSTREAM(This), 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsInputStream_IsNonBlocking(nsIInputStream *iface, PRBool *_retval)
|
|
|
|
{
|
|
|
|
nsProtocolStream *This = NSINSTREAM_THIS(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, _retval);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef NSINSTREAM_THIS
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
ret->lpInputStreamVtbl = &nsInputStreamVtbl;
|
|
|
|
ret->ref = 1;
|
|
|
|
ret->buf_size = 0;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-02-13 13:26:00 +01:00
|
|
|
#define STATUSCLB_THIS(iface) DEFINE_THIS(BSCallback, BindStatusCallback, iface)
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindStatusCallback_QueryInterface(IBindStatusCallback *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
BSCallback *This = STATUSCLB_THIS(iface);
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppv);
|
|
|
|
*ppv = STATUSCLB(This);
|
|
|
|
}else if(IsEqualGUID(&IID_IBindStatusCallback, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IBindStatusCallback, %p)\n", This, ppv);
|
|
|
|
*ppv = STATUSCLB(This);
|
|
|
|
}else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
|
|
|
|
*ppv = SERVPROV(This);
|
|
|
|
}else if(IsEqualGUID(&IID_IHttpNegotiate, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IHttpNegotiate %p)\n", This, ppv);
|
|
|
|
*ppv = HTTPNEG(This);
|
|
|
|
}else if(IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IHttpNegotiate2 %p)\n", This, ppv);
|
|
|
|
*ppv = HTTPNEG(This);
|
|
|
|
}else if(IsEqualGUID(&IID_IInternetBindInfo, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetBindInfo %p)\n", This, ppv);
|
|
|
|
*ppv = BINDINFO(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppv) {
|
|
|
|
IBindStatusCallback_AddRef(STATUSCLB(This));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Unsupported riid = %s\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BindStatusCallback_AddRef(IBindStatusCallback *iface)
|
|
|
|
{
|
|
|
|
BSCallback *This = STATUSCLB_THIS(iface);
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
BSCallback *This = STATUSCLB_THIS(iface);
|
|
|
|
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);
|
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)
|
|
|
|
{
|
|
|
|
BSCallback *This = STATUSCLB_THIS(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)
|
|
|
|
{
|
|
|
|
BSCallback *This = STATUSCLB_THIS(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, pnPriority);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindStatusCallback_OnLowResource(IBindStatusCallback *iface, DWORD reserved)
|
|
|
|
{
|
|
|
|
BSCallback *This = STATUSCLB_THIS(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)
|
|
|
|
{
|
|
|
|
BSCallback *This = STATUSCLB_THIS(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)
|
|
|
|
{
|
|
|
|
BSCallback *This = STATUSCLB_THIS(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);
|
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)
|
|
|
|
{
|
|
|
|
BSCallback *This = STATUSCLB_THIS(iface);
|
|
|
|
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;
|
|
|
|
pbindinfo->stgmedData.pUnkForRelease = (IUnknown*)STATUSCLB(This);
|
|
|
|
IBindStatusCallback_AddRef(STATUSCLB(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindStatusCallback_OnDataAvailable(IBindStatusCallback *iface,
|
|
|
|
DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
|
|
|
|
{
|
|
|
|
BSCallback *This = STATUSCLB_THIS(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)
|
|
|
|
{
|
|
|
|
BSCallback *This = STATUSCLB_THIS(iface);
|
|
|
|
FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), punk);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef STATUSCLB_THIS
|
|
|
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
|
|
|
#define HTTPNEG_THIS(iface) DEFINE_THIS(BSCallback, HttpNegotiate2, iface)
|
|
|
|
|
|
|
|
static HRESULT WINAPI HttpNegotiate_QueryInterface(IHttpNegotiate2 *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
BSCallback *This = HTTPNEG_THIS(iface);
|
|
|
|
return IBindStatusCallback_QueryInterface(STATUSCLB(This), riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HttpNegotiate_AddRef(IHttpNegotiate2 *iface)
|
|
|
|
{
|
|
|
|
BSCallback *This = HTTPNEG_THIS(iface);
|
|
|
|
return IBindStatusCallback_AddRef(STATUSCLB(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HttpNegotiate_Release(IHttpNegotiate2 *iface)
|
|
|
|
{
|
|
|
|
BSCallback *This = HTTPNEG_THIS(iface);
|
|
|
|
return IBindStatusCallback_Release(STATUSCLB(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface,
|
|
|
|
LPCWSTR szURL, LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
|
|
|
|
{
|
|
|
|
BSCallback *This = HTTPNEG_THIS(iface);
|
|
|
|
DWORD size;
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
if(!This->headers) {
|
|
|
|
*pszAdditionalHeaders = NULL;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = (strlenW(This->headers)+1)*sizeof(WCHAR);
|
|
|
|
*pszAdditionalHeaders = CoTaskMemAlloc(size);
|
|
|
|
memcpy(*pszAdditionalHeaders, This->headers, size);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode,
|
|
|
|
LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders)
|
|
|
|
{
|
|
|
|
BSCallback *This = HTTPNEG_THIS(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
|
|
|
|
|
|
|
return This->vtbl->on_response(This, dwResponseCode);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface,
|
|
|
|
BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
|
|
|
|
{
|
|
|
|
BSCallback *This = HTTPNEG_THIS(iface);
|
|
|
|
FIXME("(%p)->(%p %p %ld)\n", This, pbSecurityId, pcbSecurityId, dwReserved);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef HTTPNEG
|
|
|
|
|
|
|
|
static const IHttpNegotiate2Vtbl HttpNegotiate2Vtbl = {
|
|
|
|
HttpNegotiate_QueryInterface,
|
|
|
|
HttpNegotiate_AddRef,
|
|
|
|
HttpNegotiate_Release,
|
|
|
|
HttpNegotiate_BeginningTransaction,
|
|
|
|
HttpNegotiate_OnResponse,
|
|
|
|
HttpNegotiate_GetRootSecurityId
|
|
|
|
};
|
|
|
|
|
|
|
|
#define BINDINFO_THIS(iface) DEFINE_THIS(BSCallback, InternetBindInfo, iface)
|
|
|
|
|
|
|
|
static HRESULT WINAPI InternetBindInfo_QueryInterface(IInternetBindInfo *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
BSCallback *This = BINDINFO_THIS(iface);
|
|
|
|
return IBindStatusCallback_QueryInterface(STATUSCLB(This), riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InternetBindInfo_AddRef(IInternetBindInfo *iface)
|
|
|
|
{
|
|
|
|
BSCallback *This = BINDINFO_THIS(iface);
|
|
|
|
return IBindStatusCallback_AddRef(STATUSCLB(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InternetBindInfo_Release(IInternetBindInfo *iface)
|
|
|
|
{
|
|
|
|
BSCallback *This = BINDINFO_THIS(iface);
|
|
|
|
return IBindStatusCallback_Release(STATUSCLB(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InternetBindInfo_GetBindInfo(IInternetBindInfo *iface,
|
|
|
|
DWORD *grfBINDF, BINDINFO *pbindinfo)
|
|
|
|
{
|
|
|
|
BSCallback *This = BINDINFO_THIS(iface);
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
BSCallback *This = BINDINFO_THIS(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;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef BINDINFO_THIS
|
|
|
|
|
|
|
|
static const IInternetBindInfoVtbl InternetBindInfoVtbl = {
|
|
|
|
InternetBindInfo_QueryInterface,
|
|
|
|
InternetBindInfo_AddRef,
|
|
|
|
InternetBindInfo_Release,
|
|
|
|
InternetBindInfo_GetBindInfo,
|
|
|
|
InternetBindInfo_GetBindString
|
|
|
|
};
|
|
|
|
|
|
|
|
#define SERVPROV_THIS(iface) DEFINE_THIS(BSCallback, ServiceProvider, iface)
|
|
|
|
|
|
|
|
static HRESULT WINAPI BSCServiceProvider_QueryInterface(IServiceProvider *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
BSCallback *This = SERVPROV_THIS(iface);
|
|
|
|
return IBindStatusCallback_QueryInterface(STATUSCLB(This), riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BSCServiceProvider_AddRef(IServiceProvider *iface)
|
|
|
|
{
|
|
|
|
BSCallback *This = SERVPROV_THIS(iface);
|
|
|
|
return IBindStatusCallback_AddRef(STATUSCLB(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BSCServiceProvider_Release(IServiceProvider *iface)
|
|
|
|
{
|
|
|
|
BSCallback *This = SERVPROV_THIS(iface);
|
|
|
|
return IBindStatusCallback_Release(STATUSCLB(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BSCServiceProvider_QueryService(IServiceProvider *iface,
|
|
|
|
REFGUID guidService, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
BSCallback *This = SERVPROV_THIS(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
|
|
|
}
|
|
|
|
|
|
|
|
#undef SERVPROV_THIS
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2008-03-23 02:17:17 +01:00
|
|
|
This->lpBindStatusCallbackVtbl = &BindStatusCallbackVtbl;
|
|
|
|
This->lpServiceProviderVtbl = &ServiceProviderVtbl;
|
|
|
|
This->lpHttpNegotiate2Vtbl = &HttpNegotiate2Vtbl;
|
|
|
|
This->lpInternetBindInfoVtbl = &InternetBindInfoVtbl;
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2006-02-13 13:26:00 +01:00
|
|
|
static void parse_post_data(nsIInputStream *post_data_stream, LPWSTR *headers_ret,
|
|
|
|
HGLOBAL *post_data_ret, ULONG *post_data_len_ret)
|
|
|
|
{
|
|
|
|
PRUint32 post_data_len = 0, available = 0;
|
|
|
|
HGLOBAL post_data = NULL;
|
|
|
|
LPWSTR headers = NULL;
|
|
|
|
DWORD headers_len = 0, len;
|
2006-02-24 20:29:37 +01:00
|
|
|
const char *ptr, *ptr2, *post_data_end;
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
nsIInputStream_Available(post_data_stream, &available);
|
|
|
|
post_data = GlobalAlloc(0, available+1);
|
|
|
|
nsIInputStream_Read(post_data_stream, post_data, available, &post_data_len);
|
2006-02-17 11:37:11 +01:00
|
|
|
|
|
|
|
TRACE("post_data = %s\n", debugstr_an(post_data, post_data_len));
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
ptr = ptr2 = post_data;
|
2006-02-24 20:29:37 +01:00
|
|
|
post_data_end = (const char*)post_data+post_data_len;
|
2006-02-13 13:26:00 +01:00
|
|
|
|
2006-02-24 20:29:37 +01:00
|
|
|
while(ptr < post_data_end && (*ptr != '\r' || ptr[1] != '\n')) {
|
|
|
|
while(ptr < post_data_end && (*ptr != '\r' || ptr[1] != '\n'))
|
2006-02-13 13:26:00 +01:00
|
|
|
ptr++;
|
|
|
|
|
|
|
|
if(!*ptr) {
|
|
|
|
FIXME("*ptr = 0\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ptr += 2;
|
|
|
|
|
|
|
|
if(ptr-ptr2 >= sizeof(CONTENT_LENGTH)
|
|
|
|
&& CompareStringA(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
|
|
|
|
CONTENT_LENGTH, sizeof(CONTENT_LENGTH)-1,
|
|
|
|
ptr2, sizeof(CONTENT_LENGTH)-1) == CSTR_EQUAL) {
|
|
|
|
ptr2 = ptr;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, ptr2, ptr-ptr2, NULL, 0);
|
|
|
|
|
|
|
|
if(headers)
|
2007-12-05 21:52:31 +01:00
|
|
|
headers = heap_realloc(headers,(headers_len+len+1)*sizeof(WCHAR));
|
2006-02-13 13:26:00 +01:00
|
|
|
else
|
2007-12-05 21:52:31 +01:00
|
|
|
headers = heap_alloc((len+1)*sizeof(WCHAR));
|
2006-02-13 13:26:00 +01:00
|
|
|
|
2009-02-04 21:11:31 +01:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, ptr2, ptr-ptr2, headers+headers_len, len);
|
2006-02-13 13:26:00 +01:00
|
|
|
headers_len += len;
|
|
|
|
|
|
|
|
ptr2 = ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
headers[headers_len] = 0;
|
|
|
|
*headers_ret = headers;
|
|
|
|
|
2006-02-24 20:29:37 +01:00
|
|
|
if(ptr >= post_data_end-2) {
|
2006-02-13 13:26:00 +01:00
|
|
|
GlobalFree(post_data);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-02-24 20:29:37 +01:00
|
|
|
ptr += 2;
|
|
|
|
|
2006-02-13 13:26:00 +01:00
|
|
|
if(headers_len) {
|
|
|
|
post_data_len -= ptr-(const char*)post_data;
|
2006-02-17 11:37:11 +01:00
|
|
|
memmove(post_data, ptr, post_data_len);
|
2006-02-13 13:26:00 +01:00
|
|
|
post_data = GlobalReAlloc(post_data, post_data_len+1, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
*post_data_ret = post_data;
|
2006-02-24 20:29:37 +01:00
|
|
|
*post_data_len_ret = post_data_len;
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2007-11-05 21:45:07 +01:00
|
|
|
bscallback->doc = doc;
|
2008-09-17 03:24:25 +02:00
|
|
|
|
|
|
|
/* NOTE: IE7 calls IsSystemMoniker here*/
|
|
|
|
|
2009-10-26 23:05:37 +01:00
|
|
|
if(window)
|
|
|
|
call_docview_84(window->doc_obj);
|
2007-11-05 21:45:07 +01:00
|
|
|
|
2007-12-24 12:48:43 +01:00
|
|
|
if(bctx) {
|
|
|
|
RegisterBindStatusCallback(bctx, STATUSCLB(bscallback), NULL, 0);
|
|
|
|
IBindCtx_AddRef(bctx);
|
|
|
|
}else {
|
|
|
|
hres = CreateAsyncBindCtx(0, STATUSCLB(bscallback), NULL, &bctx);
|
|
|
|
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;
|
|
|
|
|
|
|
|
#define BUFFERBSC_THIS(bsc) ((BufferBSC*) bsc)
|
|
|
|
|
|
|
|
static void BufferBSC_destroy(BSCallback *bsc)
|
|
|
|
{
|
|
|
|
BufferBSC *This = BUFFERBSC_THIS(bsc);
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
BufferBSC *This = BUFFERBSC_THIS(bsc);
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
BufferBSC *This = BUFFERBSC_THIS(bsc);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2009-08-11 19:15:07 +02:00
|
|
|
static HRESULT BufferBSC_on_response(BSCallback *bsc, DWORD response_code)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-03-29 21:57:48 +01:00
|
|
|
#undef BUFFERBSC_THIS
|
|
|
|
|
|
|
|
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,
|
2009-08-11 19:15:07 +02:00
|
|
|
BufferBSC_on_response
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IBindStatusCallback_Release(STATUSCLB(&bsc->bsc));
|
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
struct nsChannelBSC {
|
|
|
|
BSCallback bsc;
|
|
|
|
|
2009-10-26 23:05:37 +01:00
|
|
|
HTMLWindow *window;
|
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
nsChannel *nschannel;
|
|
|
|
nsIStreamListener *nslistener;
|
|
|
|
nsISupports *nscontext;
|
|
|
|
|
|
|
|
nsProtocolStream *nsstream;
|
|
|
|
};
|
|
|
|
|
2009-08-30 01:01:16 +02:00
|
|
|
static void on_start_nsrequest(nsChannelBSC *This)
|
|
|
|
{
|
|
|
|
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,
|
|
|
|
(nsIRequest*)NSCHANNEL(This->nschannel), This->nscontext);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
FIXME("OnStartRequest failed: %08x\n", nsres);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
if(!This->nslistener)
|
|
|
|
return;
|
|
|
|
|
2009-09-14 00:35:20 +02:00
|
|
|
if(!This->bsc.readed && SUCCEEDED(result)) {
|
2009-08-30 01:01:16 +02:00
|
|
|
TRACE("No data read! Calling OnStartRequest\n");
|
|
|
|
on_start_nsrequest(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIStreamListener_OnStopRequest(This->nslistener, (nsIRequest*)NSCHANNEL(This->nschannel),
|
2009-09-14 00:35:20 +02:00
|
|
|
This->nscontext, SUCCEEDED(result) ? NS_OK : NS_ERROR_FAILURE);
|
2009-08-30 01:01:16 +02:00
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
WARN("OnStopRequest failed: %08x\n", nsres);
|
|
|
|
}
|
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
static HRESULT read_stream_data(nsChannelBSC *This, IStream *stream)
|
|
|
|
{
|
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);
|
|
|
|
|
2009-08-30 01:01:16 +02:00
|
|
|
on_start_nsrequest(This);
|
2008-03-23 02:17:17 +01:00
|
|
|
|
2009-10-26 23:05:37 +01:00
|
|
|
if(This->window)
|
|
|
|
update_window_doc(This->window);
|
2008-03-23 02:17:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
This->bsc.readed += This->nsstream->buf_size;
|
|
|
|
|
|
|
|
nsres = nsIStreamListener_OnDataAvailable(This->nslistener,
|
|
|
|
(nsIRequest*)NSCHANNEL(This->nschannel), This->nscontext,
|
|
|
|
NSINSTREAM(This->nsstream), This->bsc.readed-This->nsstream->buf_size,
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void add_nsrequest(nsChannelBSC *This)
|
|
|
|
{
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
if(!This->nschannel || !This->nschannel->load_group)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsres = nsILoadGroup_AddRequest(This->nschannel->load_group,
|
|
|
|
(nsIRequest*)NSCHANNEL(This->nschannel), This->nscontext);
|
|
|
|
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("AddRequest failed:%08x\n", nsres);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NSCHANNELBSC_THIS(bsc) ((nsChannelBSC*) bsc)
|
|
|
|
|
|
|
|
static void nsChannelBSC_destroy(BSCallback *bsc)
|
|
|
|
{
|
|
|
|
nsChannelBSC *This = NSCHANNELBSC_THIS(bsc);
|
|
|
|
|
|
|
|
if(This->nschannel)
|
|
|
|
nsIChannel_Release(NSCHANNEL(This->nschannel));
|
|
|
|
if(This->nslistener)
|
|
|
|
nsIStreamListener_Release(This->nslistener);
|
|
|
|
if(This->nscontext)
|
|
|
|
nsISupports_Release(This->nscontext);
|
|
|
|
if(This->nsstream)
|
|
|
|
nsIInputStream_Release(NSINSTREAM(This->nsstream));
|
|
|
|
heap_free(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT nsChannelBSC_start_binding(BSCallback *bsc)
|
|
|
|
{
|
|
|
|
nsChannelBSC *This = NSCHANNELBSC_THIS(bsc);
|
|
|
|
|
|
|
|
add_nsrequest(This);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-08-19 20:40:00 +02:00
|
|
|
static HRESULT nsChannelBSC_init_bindinfo(BSCallback *bsc)
|
|
|
|
{
|
|
|
|
nsChannelBSC *This = NSCHANNELBSC_THIS(bsc);
|
|
|
|
|
|
|
|
if(This->nschannel && This->nschannel->post_data_stream) {
|
|
|
|
parse_post_data(This->nschannel->post_data_stream, &This->bsc.headers, &This->bsc.post_data, &This->bsc.post_data_len);
|
|
|
|
TRACE("headers = %s post_data = %s\n", debugstr_w(This->bsc.headers),
|
|
|
|
debugstr_an(This->bsc.post_data, This->bsc.post_data_len));
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
static HRESULT nsChannelBSC_stop_binding(BSCallback *bsc, HRESULT result)
|
|
|
|
{
|
|
|
|
nsChannelBSC *This = NSCHANNELBSC_THIS(bsc);
|
|
|
|
|
2009-09-14 00:35:20 +02:00
|
|
|
on_stop_nsrequest(This, result);
|
2008-03-23 02:17:17 +01:00
|
|
|
|
|
|
|
if(This->nslistener) {
|
|
|
|
if(This->nschannel->load_group) {
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = nsILoadGroup_RemoveRequest(This->nschannel->load_group,
|
|
|
|
(nsIRequest*)NSCHANNEL(This->nschannel), NULL, NS_OK);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("RemoveRequest failed: %08x\n", nsres);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT nsChannelBSC_read_data(BSCallback *bsc, IStream *stream)
|
|
|
|
{
|
|
|
|
nsChannelBSC *This = NSCHANNELBSC_THIS(bsc);
|
|
|
|
|
|
|
|
return read_stream_data(This, stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT nsChannelBSC_on_progress(BSCallback *bsc, ULONG status_code, LPCWSTR status_text)
|
|
|
|
{
|
|
|
|
nsChannelBSC *This = NSCHANNELBSC_THIS(bsc);
|
|
|
|
|
|
|
|
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);
|
2008-03-23 02:17:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-08-11 19:15:07 +02:00
|
|
|
static HRESULT nsChannelBSC_on_response(BSCallback *bsc, DWORD response_code)
|
|
|
|
{
|
|
|
|
nsChannelBSC *This = NSCHANNELBSC_THIS(bsc);
|
|
|
|
|
|
|
|
This->nschannel->response_status = response_code;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
#undef NSCHANNELBSC_THIS
|
|
|
|
|
|
|
|
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,
|
2009-08-11 19:15:07 +02:00
|
|
|
nsChannelBSC_on_response
|
2008-03-23 02:17:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
nsChannelBSC *create_channelbsc(IMoniker *mon)
|
|
|
|
{
|
|
|
|
nsChannelBSC *ret = heap_alloc_zero(sizeof(*ret));
|
|
|
|
|
|
|
|
init_bscallback(&ret->bsc, &nsChannelBSCVtbl, mon, BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMoniker *get_channelbsc_mon(nsChannelBSC *This)
|
2008-03-23 02:15:39 +01:00
|
|
|
{
|
2008-03-23 02:17:17 +01:00
|
|
|
if(This->bsc.mon)
|
|
|
|
IMoniker_AddRef(This->bsc.mon);
|
|
|
|
return This->bsc.mon;
|
2008-03-23 02:15:39 +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;
|
2009-10-26 23:03:53 +01:00
|
|
|
IBindStatusCallback_Release(STATUSCLB(&window->bscallback->bsc));
|
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;
|
2008-03-23 02:17:17 +01:00
|
|
|
IBindStatusCallback_AddRef(STATUSCLB(&callback->bsc));
|
2009-10-26 23:05:37 +01:00
|
|
|
callback->bsc.doc = window->doc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void abort_document_bindings(HTMLDocumentNode *doc)
|
|
|
|
{
|
|
|
|
BSCallback *iter;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(iter, &doc->bindings, BSCallback, entry) {
|
|
|
|
if(iter->binding)
|
|
|
|
IBinding_Abort(iter->binding);
|
|
|
|
iter->doc = NULL;
|
|
|
|
list_remove(&iter->entry);
|
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
|
|
|
{
|
|
|
|
HRESULT hres;
|
|
|
|
|
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
|
|
|
|
2009-11-12 14:51:43 +01:00
|
|
|
add_nsrequest(bscallback);
|
2007-05-11 13:17:41 +02:00
|
|
|
|
|
|
|
hres = read_stream_data(bscallback, stream);
|
2008-03-23 02:17:17 +01:00
|
|
|
IBindStatusCallback_OnStopBinding(STATUSCLB(&bscallback->bsc), 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
|
|
|
{
|
|
|
|
nsIChannel_AddRef(NSCHANNEL(channel));
|
|
|
|
This->nschannel = channel;
|
|
|
|
|
|
|
|
nsIStreamListener_AddRef(listener);
|
|
|
|
This->nslistener = listener;
|
|
|
|
|
|
|
|
if(context) {
|
|
|
|
nsISupports_AddRef(context);
|
|
|
|
This->nscontext = context;
|
|
|
|
}
|
|
|
|
}
|
2008-03-23 02:16:36 +01:00
|
|
|
|
2009-10-11 21:11:03 +02:00
|
|
|
HRESULT hlink_frame_navigate(HTMLDocument *doc, LPCWSTR url,
|
|
|
|
nsIInputStream *post_data_stream, DWORD hlnf)
|
2008-03-23 02:16:36 +01:00
|
|
|
{
|
2009-10-11 21:11:03 +02:00
|
|
|
IHlinkFrame *hlink_frame;
|
|
|
|
IServiceProvider *sp;
|
2008-03-23 02:16:36 +01:00
|
|
|
BSCallback *callback;
|
|
|
|
IBindCtx *bindctx;
|
|
|
|
IMoniker *mon;
|
|
|
|
IHlink *hlink;
|
2009-10-11 21:11:03 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IOleClientSite_QueryInterface(doc->doc_obj->client, &IID_IServiceProvider,
|
|
|
|
(void**)&sp);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = IServiceProvider_QueryService(sp, &IID_IHlinkFrame, &IID_IHlinkFrame,
|
|
|
|
(void**)&hlink_frame);
|
|
|
|
IServiceProvider_Release(sp);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2008-03-23 02:16:36 +01:00
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
callback = &create_channelbsc(NULL)->bsc;
|
2008-03-23 02:16:36 +01:00
|
|
|
|
|
|
|
if(post_data_stream) {
|
|
|
|
parse_post_data(post_data_stream, &callback->headers, &callback->post_data,
|
|
|
|
&callback->post_data_len);
|
|
|
|
TRACE("headers = %s post_data = %s\n", debugstr_w(callback->headers),
|
|
|
|
debugstr_an(callback->post_data, callback->post_data_len));
|
|
|
|
}
|
|
|
|
|
2009-10-11 21:11:03 +02:00
|
|
|
hres = CreateAsyncBindCtx(0, STATUSCLB(callback), NULL, &bindctx);
|
|
|
|
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 */
|
|
|
|
}
|
|
|
|
|
2009-10-11 21:11:03 +02:00
|
|
|
hres = IHlinkFrame_Navigate(hlink_frame, hlnf, bindctx, STATUSCLB(callback), hlink);
|
2008-03-23 02:16:36 +01:00
|
|
|
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
}
|
|
|
|
|
2009-10-11 21:11:03 +02:00
|
|
|
IHlinkFrame_Release(hlink_frame);
|
2008-03-23 02:16:36 +01:00
|
|
|
IBindCtx_Release(bindctx);
|
|
|
|
IBindStatusCallback_Release(STATUSCLB(callback));
|
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];
|
2009-11-30 18:01:31 +01:00
|
|
|
nsIWebNavigation *web_navigation;
|
|
|
|
nsIDocShell *doc_shell;
|
|
|
|
nsIWineURI *uri;
|
|
|
|
nsresult nsres;
|
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) {
|
|
|
|
strcpyW(url, translated_url);
|
|
|
|
CoTaskMemFree(translated_url);
|
|
|
|
}
|
2009-11-30 17:58:37 +01:00
|
|
|
}
|
|
|
|
|
2009-11-30 18:01:31 +01:00
|
|
|
if(window->doc_obj && window == window->doc_obj->basedoc.window) {
|
|
|
|
hres = hlink_frame_navigate(&window->doc->basedoc, url, NULL, 0);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
return S_OK;
|
|
|
|
TRACE("hlink_frame_navigate failed: %08x\n", hres);
|
|
|
|
}
|
2009-10-11 21:11:35 +02:00
|
|
|
|
2009-11-30 18:01:31 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = create_doc_uri(window, url, &uri);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
nsIDocShell_Release(doc_shell);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIDocShell_LoadURI(doc_shell, (nsIURI*)uri, NULL, 0, FALSE);
|
|
|
|
nsIDocShell_Release(doc_shell);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
WARN("LoadURI failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2009-10-11 21:11:35 +02:00
|
|
|
}
|