Commit 682dc4d6 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

urlmon: Store object instead of interface pointer to BindProtocol in Binding object.

parent 08b919f8
......@@ -27,17 +27,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
static WCHAR cbinding_contextW[] = {'C','B','i','n','d','i','n','g',' ','C','o','n','t','e','x','t',0};
static WCHAR bscb_holderW[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
typedef struct Binding Binding;
struct _task_header_t;
typedef void (*task_proc_t)(Binding*, struct _task_header_t*);
typedef struct _task_header_t {
task_proc_t proc;
struct _task_header_t *next;
} task_header_t;
typedef struct {
const IUnknownVtbl *lpUnknownVtbl;
......@@ -79,7 +68,7 @@ typedef enum {
#define BINDING_OBJAVAIL 0x0004
#define BINDING_ABORTED 0x0008
struct Binding {
typedef struct {
const IBindingVtbl *lpBindingVtbl;
const IInternetProtocolSinkVtbl *lpIInternetProtocolSinkVtbl;
const IInternetBindInfoVtbl *lpInternetBindInfoVtbl;
......@@ -89,9 +78,10 @@ struct Binding {
LONG ref;
IBindStatusCallback *callback;
IInternetProtocolEx *protocol;
IServiceProvider *service_provider;
BindProtocol *protocol;
stgmed_buf_t *stgmed_buf;
stgmed_obj_t *stgmed_obj;
......@@ -114,7 +104,7 @@ struct Binding {
HWND notif_hwnd;
CRITICAL_SECTION section;
};
} Binding;
#define BINDING(x) ((IBinding*) &(x)->lpBindingVtbl)
#define BINDINF(x) ((IInternetBindInfo*) &(x)->lpInternetBindInfoVtbl)
......@@ -212,7 +202,7 @@ static void mime_available(Binding *This, LPCWSTR mime)
static void stop_binding(Binding *binding, HRESULT hres, LPCWSTR str)
{
if(binding->state & BINDING_LOCKED) {
IInternetProtocol_UnlockRequest(binding->protocol);
IInternetProtocolEx_UnlockRequest(PROTOCOLEX(binding->protocol));
binding->state &= ~BINDING_LOCKED;
}
......@@ -354,7 +344,7 @@ static void create_object(Binding *binding)
stop_binding(binding, hres, NULL);
if(FAILED(hres))
IInternetProtocol_Terminate(binding->protocol, 0);
IInternetProtocolEx_Terminate(PROTOCOLEX(binding->protocol), 0);
}
static void cache_file_available(Binding *This, const WCHAR *file_name)
......@@ -818,22 +808,20 @@ static HRESULT WINAPI Binding_QueryInterface(IBinding *iface, REFIID riid, void
TRACE("(%p)->(IID_IWinInetInfo %p)\n", This, ppv);
/* NOTE: This violidates COM rules, but tests prove that we should do it */
if(!get_wininet_info(This->protocol))
if(!This->protocol->wininet_info)
return E_NOINTERFACE;
*ppv = INETINFO(This);
}else if(IsEqualGUID(&IID_IWinInetHttpInfo, riid)) {
IWinInetHttpInfo *http_info;
IWinInetInfo *info;
HRESULT hres;
TRACE("(%p)->(IID_IWinInetHttpInfo %p)\n", This, ppv);
info = get_wininet_info(This->protocol);
if(!info)
if(!This->protocol->wininet_info)
return E_NOINTERFACE;
hres = IWinInetInfo_QueryInterface(info, &IID_IWinInetHttpInfo, (void**)&http_info);
hres = IWinInetInfo_QueryInterface(This->protocol->wininet_info, &IID_IWinInetHttpInfo, (void**)&http_info);
if(FAILED(hres))
return E_NOINTERFACE;
......@@ -875,7 +863,7 @@ static ULONG WINAPI Binding_Release(IBinding *iface)
if(This->callback)
IBindStatusCallback_Release(This->callback);
if(This->protocol)
IInternetProtocol_Release(This->protocol);
IInternetProtocolEx_Release(PROTOCOLEX(This->protocol));
if(This->service_provider)
IServiceProvider_Release(This->service_provider);
if(This->stgmed_buf)
......@@ -911,7 +899,7 @@ static HRESULT WINAPI Binding_Abort(IBinding *iface)
if(This->state & BINDING_ABORTED)
return E_FAIL;
hres = IInternetProtocol_Abort(This->protocol, E_ABORT, ERROR_SUCCESS);
hres = IInternetProtocolEx_Abort(PROTOCOLEX(This->protocol), E_ABORT, ERROR_SUCCESS);
if(FAILED(hres))
return hres;
......@@ -1128,7 +1116,7 @@ static void report_data(Binding *This, DWORD bscf, ULONG progress, ULONG progres
HRESULT hres;
if(!(This->state & BINDING_LOCKED)) {
HRESULT hres = IInternetProtocol_LockRequest(This->protocol, 0);
HRESULT hres = IInternetProtocolEx_LockRequest(PROTOCOLEX(This->protocol), 0);
if(SUCCEEDED(hres))
This->state |= BINDING_LOCKED;
}
......@@ -1169,7 +1157,7 @@ static HRESULT WINAPI InternetProtocolSink_ReportResult(IInternetProtocolSink *i
TRACE("(%p)->(%08x %d %s)\n", This, hrResult, dwError, debugstr_w(szResult));
stop_binding(This, hrResult, szResult);
IInternetProtocol_Terminate(This->protocol, 0);
IInternetProtocolEx_Terminate(PROTOCOLEX(This->protocol), 0);
return S_OK;
}
......@@ -1472,7 +1460,7 @@ static HRESULT Binding_Create(IMoniker *mon, Binding *binding_ctx, IUri *uri, IB
if(binding_ctx) {
ret->protocol = binding_ctx->protocol;
IInternetProtocol_AddRef(ret->protocol);
IInternetProtocolEx_AddRef(PROTOCOLEX(ret->protocol));
}else {
hres = create_binding_protocol(TRUE, &ret->protocol);
if(FAILED(hres)) {
......@@ -1514,7 +1502,7 @@ static HRESULT Binding_Create(IMoniker *mon, Binding *binding_ctx, IUri *uri, IB
IUnknown_AddRef(STGMEDUNK(ret->stgmed_buf));
ret->clipboard_format = binding_ctx->clipboard_format;
}else {
ret->stgmed_buf = create_stgmed_buf(ret->protocol);
ret->stgmed_buf = create_stgmed_buf(PROTOCOLEX(ret->protocol));
}
if(to_obj) {
......@@ -1560,7 +1548,7 @@ static HRESULT start_binding(IMoniker *mon, Binding *binding_ctx, IUri *uri, IBi
report_data(binding, BSCF_FIRSTDATANOTIFICATION | (binding_ctx->download_state == END_DOWNLOAD ? BSCF_LASTDATANOTIFICATION : 0),
0, 0);
}else {
hres = IInternetProtocolEx_StartEx(binding->protocol, uri, PROTSINK(binding),
hres = IInternetProtocolEx_StartEx(PROTOCOLEX(binding->protocol), uri, PROTSINK(binding),
BINDINF(binding), PI_APARTMENTTHREADED|PI_MIMEVERIFICATION, 0);
TRACE("start ret %08x\n", hres);
......@@ -1603,7 +1591,7 @@ HRESULT bind_to_storage(IUri *uri, IBindCtx *pbc, REFIID riid, void **ppv)
if(binding->hres == S_OK && binding->stgmed_buf->init) {
if((binding->state & BINDING_STOPPED) && (binding->state & BINDING_LOCKED))
IInternetProtocol_UnlockRequest(binding->protocol);
IInternetProtocolEx_UnlockRequest(PROTOCOLEX(binding->protocol));
hres = binding->stgmed_obj->vtbl->get_result(binding->stgmed_obj, binding->bindf, ppv);
}else if(binding->bindf & BINDF_ASYNCHRONOUS) {
......
......@@ -21,64 +21,17 @@
WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
typedef struct BindProtocol BindProtocol;
typedef void (*task_proc_t)(BindProtocol*,task_header_t*);
struct _task_header_t;
typedef void (*task_proc_t)(BindProtocol*,struct _task_header_t*);
typedef struct _task_header_t {
struct _task_header_t {
task_proc_t proc;
struct _task_header_t *next;
} task_header_t;
struct BindProtocol {
const IInternetProtocolExVtbl *lpIInternetProtocolExVtbl;
const IInternetBindInfoVtbl *lpInternetBindInfoVtbl;
const IInternetPriorityVtbl *lpInternetPriorityVtbl;
const IServiceProviderVtbl *lpServiceProviderVtbl;
const IInternetProtocolSinkVtbl *lpIInternetProtocolSinkVtbl;
const IWinInetHttpInfoVtbl *lpIWinInetHttpInfoVtbl;
LONG ref;
IInternetProtocol *protocol;
IInternetBindInfo *bind_info;
IInternetProtocolSink *protocol_sink;
IServiceProvider *service_provider;
IWinInetInfo *wininet_info;
struct {
IInternetProtocol IInternetProtocol_iface;
} default_protocol_handler;
IInternetProtocol *protocol_handler;
LONG priority;
BOOL reported_result;
BOOL reported_mime;
BOOL from_urlmon;
DWORD pi;
DWORD apartment_thread;
HWND notif_hwnd;
DWORD continue_call;
CRITICAL_SECTION section;
task_header_t *task_queue_head, *task_queue_tail;
BYTE *buf;
DWORD buf_size;
LPWSTR mime;
IUri *uri;
ProtocolProxy *filter_proxy;
task_header_t *next;
};
#define BINDINFO(x) ((IInternetBindInfo*) &(x)->lpInternetBindInfoVtbl)
#define PRIORITY(x) ((IInternetPriority*) &(x)->lpInternetPriorityVtbl)
#define HTTPINFO(x) ((IWinInetHttpInfo*) &(x)->lpIWinInetHttpInfoVtbl)
#define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl)
#define PROTOCOLEX(x) ((IInternetProtocolEx*) &(x)->lpIInternetProtocolExVtbl)
#define PROTOCOLHANDLER(x) ((IInternetProtocol*) &(x)->lpIInternetProtocolHandlerVtbl)
......@@ -390,7 +343,7 @@ static ULONG WINAPI BindProtocol_Release(IInternetProtocolEx *iface)
if(This->uri)
IUri_Release(This->uri);
set_binding_sink(PROTOCOLEX(This), NULL, NULL);
set_binding_sink(This, NULL, NULL);
if(This->notif_hwnd)
release_notif_hwnd(This->notif_hwnd);
......@@ -576,7 +529,7 @@ static HRESULT WINAPI BindProtocol_StartEx(IInternetProtocolEx *iface, IUri *pUr
if(urlmon_protocol)
IInternetProtocol_QueryInterface(protocol, &IID_IWinInetInfo, (void**)&This->wininet_info);
set_binding_sink(PROTOCOLEX(This), pOIProtSink, pOIBindInfo);
set_binding_sink(This, pOIProtSink, pOIBindInfo);
hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetPriority, (void**)&priority);
if(SUCCEEDED(hres)) {
......@@ -602,9 +555,8 @@ static HRESULT WINAPI BindProtocol_StartEx(IInternetProtocolEx *iface, IUri *pUr
return hres;
}
void set_binding_sink(IInternetProtocolEx *bind_protocol, IInternetProtocolSink *sink, IInternetBindInfo *bind_info)
void set_binding_sink(BindProtocol *This, IInternetProtocolSink *sink, IInternetBindInfo *bind_info)
{
BindProtocol *This = PROTOCOL_THIS(bind_protocol);
IInternetProtocolSink *prev_sink;
IServiceProvider *service_provider = NULL;
......@@ -627,13 +579,6 @@ void set_binding_sink(IInternetProtocolEx *bind_protocol, IInternetProtocolSink
IInternetBindInfo_Release(bind_info);
}
IWinInetInfo *get_wininet_info(IInternetProtocolEx *bind_protocol)
{
BindProtocol *This = PROTOCOL_THIS(bind_protocol);
return This->wininet_info;
}
#undef PROTOCOL_THIS
static const IInternetProtocolExVtbl BindProtocolVtbl = {
......@@ -726,7 +671,7 @@ static HRESULT WINAPI ProtocolHandler_Terminate(IInternetProtocol *iface, DWORD
This->filter_proxy = NULL;
}
set_binding_sink(PROTOCOLEX(This), NULL, NULL);
set_binding_sink(This, NULL, NULL);
if(This->bind_info) {
IInternetBindInfo_Release(This->bind_info);
......@@ -1336,7 +1281,7 @@ static const IServiceProviderVtbl ServiceProviderVtbl = {
BPServiceProvider_QueryService
};
HRESULT create_binding_protocol(BOOL from_urlmon, IInternetProtocolEx **protocol)
HRESULT create_binding_protocol(BOOL from_urlmon, BindProtocol **protocol)
{
BindProtocol *ret = heap_alloc_zero(sizeof(BindProtocol));
......@@ -1358,6 +1303,6 @@ HRESULT create_binding_protocol(BOOL from_urlmon, IInternetProtocolEx **protocol
URLMON_LockModule();
*protocol = PROTOCOLEX(ret);
*protocol = ret;
return S_OK;
}
......@@ -424,7 +424,7 @@ static HRESULT WINAPI InternetSession_CreateBinding(IInternetSession *iface,
LPBC pBC, LPCWSTR szUrl, IUnknown *pUnkOuter, IUnknown **ppUnk,
IInternetProtocol **ppOInetProt, DWORD dwOption)
{
IInternetProtocolEx *protocol;
BindProtocol *protocol;
HRESULT hres;
TRACE("(%p %s %p %p %p %08x)\n", pBC, debugstr_w(szUrl), pUnkOuter, ppUnk,
......@@ -437,7 +437,7 @@ static HRESULT WINAPI InternetSession_CreateBinding(IInternetSession *iface,
if(FAILED(hres))
return hres;
*ppOInetProt = (IInternetProtocol*)protocol;
*ppOInetProt = (IInternetProtocol*)PROTOCOLEX(protocol);
return S_OK;
}
......
......@@ -76,9 +76,6 @@ void free_session(void);
HRESULT bind_to_storage(IUri*,IBindCtx*,REFIID,void**);
HRESULT bind_to_object(IMoniker*,IUri*,IBindCtx*,REFIID,void**ppv);
HRESULT create_binding_protocol(BOOL,IInternetProtocolEx**);
void set_binding_sink(IInternetProtocolEx*,IInternetProtocolSink*,IInternetBindInfo*);
IWinInetInfo *get_wininet_info(IInternetProtocolEx*);
HRESULT create_default_callback(IBindStatusCallback**);
HRESULT wrap_callback(IBindStatusCallback*,IBindStatusCallback**);
......@@ -169,6 +166,55 @@ typedef struct {
HRESULT create_protocol_proxy(IInternetProtocol*,IInternetProtocolSink*,ProtocolProxy**);
typedef struct _task_header_t task_header_t;
typedef struct {
const IInternetProtocolExVtbl *lpIInternetProtocolExVtbl;
const IInternetBindInfoVtbl *lpInternetBindInfoVtbl;
const IInternetPriorityVtbl *lpInternetPriorityVtbl;
const IServiceProviderVtbl *lpServiceProviderVtbl;
const IInternetProtocolSinkVtbl *lpIInternetProtocolSinkVtbl;
const IWinInetHttpInfoVtbl *lpIWinInetHttpInfoVtbl;
LONG ref;
IInternetProtocol *protocol;
IInternetBindInfo *bind_info;
IInternetProtocolSink *protocol_sink;
IServiceProvider *service_provider;
IWinInetInfo *wininet_info;
struct {
IInternetProtocol IInternetProtocol_iface;
} default_protocol_handler;
IInternetProtocol *protocol_handler;
LONG priority;
BOOL reported_result;
BOOL reported_mime;
BOOL from_urlmon;
DWORD pi;
DWORD apartment_thread;
HWND notif_hwnd;
DWORD continue_call;
CRITICAL_SECTION section;
task_header_t *task_queue_head, *task_queue_tail;
BYTE *buf;
DWORD buf_size;
LPWSTR mime;
IUri *uri;
ProtocolProxy *filter_proxy;
} BindProtocol;
#define PROTOCOLEX(x) ((IInternetProtocolEx*) &(x)->lpIInternetProtocolExVtbl)
HRESULT create_binding_protocol(BOOL,BindProtocol**);
void set_binding_sink(BindProtocol*,IInternetProtocolSink*,IInternetBindInfo*);
typedef struct {
HWND notif_hwnd;
DWORD notif_hwnd_cnt;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment