mshtml: Add create_nscallback function to allow using BSCallback out of navigate.c.

This commit is contained in:
Jacek Caban 2006-06-03 00:37:58 +02:00 committed by Alexandre Julliard
parent beb5366e6f
commit 813e82f253
2 changed files with 34 additions and 33 deletions

View File

@ -45,6 +45,7 @@
typedef struct HTMLDOMNode HTMLDOMNode; typedef struct HTMLDOMNode HTMLDOMNode;
typedef struct ConnectionPoint ConnectionPoint; typedef struct ConnectionPoint ConnectionPoint;
typedef struct BSCallback BSCallback;
typedef struct { typedef struct {
const IHTMLDocument2Vtbl *lpHTMLDocument2Vtbl; const IHTMLDocument2Vtbl *lpHTMLDocument2Vtbl;
@ -114,6 +115,19 @@ struct NSContainer {
BOOL load_call; /* hack */ BOOL load_call; /* hack */
}; };
struct BSCallback {
const IBindStatusCallbackVtbl *lpBindStatusCallbackVtbl;
const IServiceProviderVtbl *lpServiceProviderVtbl;
const IHttpNegotiate2Vtbl *lpHttpNegotiate2Vtbl;
const IInternetBindInfoVtbl *lpInternetBindInfoVtbl;
LONG ref;
LPWSTR headers;
HGLOBAL post_data;
ULONG post_data_len;
};
struct HTMLDOMNode { struct HTMLDOMNode {
const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl; const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl;
@ -185,6 +199,10 @@ typedef struct {
#define NSWEAKREF(x) ((nsIWeakReference*) &(x)->lpWeakReferenceVtbl) #define NSWEAKREF(x) ((nsIWeakReference*) &(x)->lpWeakReferenceVtbl)
#define NSSUPWEAKREF(x) ((nsISupportsWeakReference*) &(x)->lpSupportsWeakReferenceVtbl) #define NSSUPWEAKREF(x) ((nsISupportsWeakReference*) &(x)->lpSupportsWeakReferenceVtbl)
#define HTTPNEG(x) ((IHttpNegotiate2*) &(x)->lpHttpNegotiate2Vtbl)
#define BINDINFO(x) ((IInternetBindInfo*) &(x)->lpInternetBindInfoVtbl);
#define HTMLELEM(x) ((IHTMLElement*) &(x)->lpHTMLElementVtbl) #define HTMLELEM(x) ((IHTMLElement*) &(x)->lpHTMLElementVtbl)
#define HTMLELEM2(x) ((IHTMLElement2*) &(x)->lpHTMLElement2Vtbl) #define HTMLELEM2(x) ((IHTMLElement2*) &(x)->lpHTMLElement2Vtbl)
#define HTMLDOMNODE(x) ((IHTMLDOMNode*) &(x)->lpHTMLDOMNodeVtbl) #define HTMLDOMNODE(x) ((IHTMLDOMNode*) &(x)->lpHTMLDOMNodeVtbl)
@ -235,6 +253,7 @@ PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**,PRBool*);
void nsAString_Finish(nsAString*); void nsAString_Finish(nsAString*);
nsIInputStream *create_nsstream(const char*,PRInt32); nsIInputStream *create_nsstream(const char*,PRInt32);
BSCallback *create_bscallback(HTMLDocument*,LPCOLESTR);
IHlink *Hlink_Create(void); IHlink *Hlink_Create(void);

View File

@ -41,22 +41,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
#define STATUSCLB_THIS(iface) DEFINE_THIS(BSCallback, BindStatusCallback, iface) #define STATUSCLB_THIS(iface) DEFINE_THIS(BSCallback, BindStatusCallback, iface)
typedef struct {
const IBindStatusCallbackVtbl *lpBindStatusCallbackVtbl;
const IServiceProviderVtbl *lpServiceProviderVtbl;
const IHttpNegotiate2Vtbl *lpHttpNegotiate2Vtbl;
const IInternetBindInfoVtbl *lpInternetBindInfoVtbl;
LONG ref;
LPWSTR headers;
HGLOBAL post_data;
ULONG post_data_len;
} BSCallback;
#define HTTPNEG(x) ((IHttpNegotiate2*) &(x)->lpHttpNegotiate2Vtbl)
#define BINDINFO(x) ((IInternetBindInfo*) &(x)->lpInternetBindInfoVtbl);
static HRESULT WINAPI BindStatusCallback_QueryInterface(IBindStatusCallback *iface, static HRESULT WINAPI BindStatusCallback_QueryInterface(IBindStatusCallback *iface,
REFIID riid, void **ppv) REFIID riid, void **ppv)
{ {
@ -375,8 +359,7 @@ static const IServiceProviderVtbl ServiceProviderVtbl = {
BSCServiceProvider_QueryService BSCServiceProvider_QueryService
}; };
static IBindStatusCallback *BSCallback_Create(HTMLDocument *doc, LPCOLESTR url, BSCallback *create_bscallback(HTMLDocument *doc, LPCOLESTR url)
HGLOBAL post_data, ULONG post_data_len, LPWSTR headers)
{ {
BSCallback *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(BSCallback)); BSCallback *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(BSCallback));
@ -385,11 +368,11 @@ static IBindStatusCallback *BSCallback_Create(HTMLDocument *doc, LPCOLESTR url,
ret->lpHttpNegotiate2Vtbl = &HttpNegotiate2Vtbl; ret->lpHttpNegotiate2Vtbl = &HttpNegotiate2Vtbl;
ret->lpInternetBindInfoVtbl = &InternetBindInfoVtbl; ret->lpInternetBindInfoVtbl = &InternetBindInfoVtbl;
ret->ref = 1; ret->ref = 1;
ret->post_data = post_data; ret->post_data = NULL;
ret->headers = headers; ret->headers = NULL;
ret->post_data_len = post_data_len; ret->post_data_len = 0;
return STATUSCLB(ret); return ret;
} }
static void parse_post_data(nsIInputStream *post_data_stream, LPWSTR *headers_ret, static void parse_post_data(nsIInputStream *post_data_stream, LPWSTR *headers_ret,
@ -466,22 +449,21 @@ static void parse_post_data(nsIInputStream *post_data_stream, LPWSTR *headers_re
void hlink_frame_navigate(HTMLDocument *doc, IHlinkFrame *hlink_frame, void hlink_frame_navigate(HTMLDocument *doc, IHlinkFrame *hlink_frame,
LPCWSTR uri, nsIInputStream *post_data_stream, DWORD hlnf) LPCWSTR uri, nsIInputStream *post_data_stream, DWORD hlnf)
{ {
IBindStatusCallback *callback; BSCallback *callback;
IBindCtx *bindctx; IBindCtx *bindctx;
IMoniker *mon; IMoniker *mon;
IHlink *hlink; IHlink *hlink;
PRUint32 post_data_len = 0;
HGLOBAL post_data = NULL; callback = create_bscallback(doc, uri);
LPWSTR headers = NULL;
if(post_data_stream) { if(post_data_stream) {
parse_post_data(post_data_stream, &headers, &post_data, &post_data_len); parse_post_data(post_data_stream, &callback->headers, &callback->post_data,
TRACE("headers = %s post_data = %s\n", debugstr_w(headers), &callback->post_data_len);
debugstr_an(post_data, post_data_len)); TRACE("headers = %s post_data = %s\n", debugstr_w(callback->headers),
debugstr_an(callback->post_data, callback->post_data_len));
} }
callback = BSCallback_Create(doc, uri, post_data, post_data_len, headers); CreateAsyncBindCtx(0, STATUSCLB(callback), NULL, &bindctx);
CreateAsyncBindCtx(0, callback, NULL, &bindctx);
hlink = Hlink_Create(); hlink = Hlink_Create();
@ -493,10 +475,10 @@ void hlink_frame_navigate(HTMLDocument *doc, IHlinkFrame *hlink_frame,
IHlink_SetTargetFrameName(hlink, wszBlank); /* FIXME */ IHlink_SetTargetFrameName(hlink, wszBlank); /* FIXME */
} }
IHlinkFrame_Navigate(hlink_frame, hlnf, bindctx, callback, hlink); IHlinkFrame_Navigate(hlink_frame, hlnf, bindctx, STATUSCLB(callback), hlink);
IBindCtx_Release(bindctx); IBindCtx_Release(bindctx);
IBindStatusCallback_Release(callback); IBindStatusCallback_Release(STATUSCLB(callback));
IMoniker_Release(mon); IMoniker_Release(mon);
} }