Commit 1ca20552 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

urlmon: Use BindProtocol in Binding object.

parent 86a0b1d2
......@@ -790,6 +790,8 @@ static HRESULT WINAPI InternetProtocolSink_ReportProgress(IInternetProtocolSink
case BINDSTATUS_SENDINGREQUEST:
on_progress(This, 0, 0, BINDSTATUS_SENDINGREQUEST, szStatusText);
break;
case BINDSTATUS_PROTOCOLCLASSID:
break;
case BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE:
mime_available(This, szStatusText, FALSE);
break;
......@@ -1095,33 +1097,6 @@ static HRESULT get_callback(IBindCtx *pbc, IBindStatusCallback **callback)
return SUCCEEDED(hres) ? S_OK : MK_E_SYNTAX;
}
static HRESULT get_protocol(Binding *This, LPCWSTR url)
{
IClassFactory *cf = NULL;
HRESULT hres;
hres = IBindStatusCallback_QueryInterface(This->callback, &IID_IInternetProtocol,
(void**)&This->protocol);
if(SUCCEEDED(hres))
return S_OK;
if(This->service_provider) {
hres = IServiceProvider_QueryService(This->service_provider, &IID_IInternetProtocol,
&IID_IInternetProtocol, (void**)&This->protocol);
if(SUCCEEDED(hres))
return S_OK;
}
hres = get_protocol_handler(url, NULL, &cf);
if(FAILED(hres))
return hres;
hres = IClassFactory_CreateInstance(cf, NULL, &IID_IInternetProtocol, (void**)&This->protocol);
IClassFactory_Release(cf);
return hres;
}
static BOOL is_urlmon_protocol(LPCWSTR url)
{
static const WCHAR wszCdl[] = {'c','d','l'};
......@@ -1210,7 +1185,7 @@ static HRESULT Binding_Create(LPCWSTR url, IBindCtx *pbc, REFIID riid, Binding *
IBindStatusCallback_QueryInterface(ret->callback, &IID_IServiceProvider,
(void**)&ret->service_provider);
hres = get_protocol(ret, url);
hres = create_binding_protocol(url, TRUE, &ret->protocol);
if(FAILED(hres)) {
WARN("Could not get protocol handler\n");
IBinding_Release(BINDING(ret));
......
......@@ -38,6 +38,7 @@ typedef struct {
LONG priority;
BOOL reported_result;
BOOL from_urlmon;
} BindProtocol;
#define PROTOCOL(x) ((IInternetProtocol*) &(x)->lpInternetProtocolVtbl)
......@@ -152,16 +153,23 @@ static HRESULT WINAPI BindProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl
if(FAILED(hres))
return hres;
hres = IClassFactory_CreateInstance(cf, (IUnknown*)BINDINFO(This),
&IID_IUnknown, (void**)&unk);
IClassFactory_Release(cf);
if(FAILED(hres))
return hres;
hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocol, (void**)&protocol);
IUnknown_Release(unk);
if(FAILED(hres))
return hres;
if(This->from_urlmon) {
hres = IClassFactory_CreateInstance(cf, NULL, &IID_IInternetProtocol, (void**)&protocol);
IClassFactory_Release(cf);
if(FAILED(hres))
return hres;
}else {
hres = IClassFactory_CreateInstance(cf, (IUnknown*)BINDINFO(This),
&IID_IUnknown, (void**)&unk);
IClassFactory_Release(cf);
if(FAILED(hres))
return hres;
hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocol, (void**)&protocol);
IUnknown_Release(unk);
if(FAILED(hres))
return hres;
}
}
StringFromCLSID(&clsid, &clsid_str);
......@@ -488,7 +496,8 @@ static HRESULT WINAPI BPInternetProtocolSink_ReportProgress(IInternetProtocolSin
if(!This->protocol_sink)
return S_OK;
return IInternetProtocolSink_ReportProgress(This->protocol_sink,
BINDSTATUS_MIMETYPEAVAILABLE, szStatusText);
This->from_urlmon ? BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE : BINDSTATUS_MIMETYPEAVAILABLE,
szStatusText);
default:
FIXME("unsupported ulStatusCode %u\n", ulStatusCode);
}
......@@ -579,7 +588,7 @@ static const IServiceProviderVtbl ServiceProviderVtbl = {
BPServiceProvider_QueryService
};
HRESULT create_binding_protocol(LPCWSTR url, IInternetProtocol **protocol)
HRESULT create_binding_protocol(LPCWSTR url, BOOL from_urlmon, IInternetProtocol **protocol)
{
BindProtocol *ret = heap_alloc_zero(sizeof(BindProtocol));
......@@ -590,6 +599,7 @@ HRESULT create_binding_protocol(LPCWSTR url, IInternetProtocol **protocol)
ret->lpInternetProtocolSinkVtbl = &InternetProtocolSinkVtbl;
ret->ref = 1;
ret->from_urlmon = from_urlmon;
URLMON_LockModule();
......
......@@ -306,7 +306,7 @@ static HRESULT WINAPI InternetSession_CreateBinding(IInternetSession *iface,
if(pBC || pUnkOuter || ppUnk || dwOption)
FIXME("Unsupported arguments\n");
return create_binding_protocol(szUrl, ppOInetProt);
return create_binding_protocol(szUrl, FALSE, ppOInetProt);
}
static HRESULT WINAPI InternetSession_SetSessionOption(IInternetSession *iface,
......
......@@ -70,7 +70,7 @@ HRESULT get_protocol_handler(LPCWSTR url, CLSID *clsid, IClassFactory **ret);
HRESULT start_binding(LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv);
HRESULT create_binding_protocol(LPCWSTR url, IInternetProtocol **protocol);
HRESULT create_binding_protocol(LPCWSTR url, BOOL from_urlmon, IInternetProtocol **protocol);
void set_binding_sink(IInternetProtocol *bind_protocol, IInternetProtocolSink *sink);
static inline void *heap_alloc(size_t len)
......
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