Commit 17574518 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

urlmon: Added support for COM aggregation to mk protocol handler.

parent 44a99402
...@@ -25,26 +25,32 @@ ...@@ -25,26 +25,32 @@
WINE_DEFAULT_DEBUG_CHANNEL(urlmon); WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
typedef struct { typedef struct {
IUnknown IUnknown_outer;
IInternetProtocolEx IInternetProtocolEx_iface; IInternetProtocolEx IInternetProtocolEx_iface;
LONG ref; LONG ref;
IUnknown *outer;
IStream *stream; IStream *stream;
} MkProtocol; } MkProtocol;
static inline MkProtocol *impl_from_IUnknown(IUnknown *iface)
{
return CONTAINING_RECORD(iface, MkProtocol, IUnknown_outer);
}
static inline MkProtocol *impl_from_IInternetProtocolEx(IInternetProtocolEx *iface) static inline MkProtocol *impl_from_IInternetProtocolEx(IInternetProtocolEx *iface)
{ {
return CONTAINING_RECORD(iface, MkProtocol, IInternetProtocolEx_iface); return CONTAINING_RECORD(iface, MkProtocol, IInternetProtocolEx_iface);
} }
static HRESULT WINAPI MkProtocol_QueryInterface(IInternetProtocolEx *iface, REFIID riid, void **ppv) static HRESULT WINAPI MkProtocolUnk_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
{ {
MkProtocol *This = impl_from_IInternetProtocolEx(iface); MkProtocol *This = impl_from_IUnknown(iface);
*ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid)) { if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = &This->IInternetProtocolEx_iface; *ppv = &This->IUnknown_outer;
}else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) { }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv); TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv);
*ppv = &This->IInternetProtocolEx_iface; *ppv = &This->IInternetProtocolEx_iface;
...@@ -54,28 +60,27 @@ static HRESULT WINAPI MkProtocol_QueryInterface(IInternetProtocolEx *iface, REFI ...@@ -54,28 +60,27 @@ static HRESULT WINAPI MkProtocol_QueryInterface(IInternetProtocolEx *iface, REFI
}else if(IsEqualGUID(&IID_IInternetProtocolEx, riid)) { }else if(IsEqualGUID(&IID_IInternetProtocolEx, riid)) {
TRACE("(%p)->(IID_IInternetProtocolEx %p)\n", This, ppv); TRACE("(%p)->(IID_IInternetProtocolEx %p)\n", This, ppv);
*ppv = &This->IInternetProtocolEx_iface; *ppv = &This->IInternetProtocolEx_iface;
}else {
*ppv = NULL;
WARN("not supported interface %s\n", debugstr_guid(riid));
return E_NOINTERFACE;
} }
if(*ppv) { IUnknown_AddRef((IUnknown*)*ppv);
IInternetProtocolEx_AddRef(iface); return S_OK;
return S_OK;
}
WARN("not supported interface %s\n", debugstr_guid(riid));
return E_NOINTERFACE;
} }
static ULONG WINAPI MkProtocol_AddRef(IInternetProtocolEx *iface) static ULONG WINAPI MkProtocolUnk_AddRef(IUnknown *iface)
{ {
MkProtocol *This = impl_from_IInternetProtocolEx(iface); MkProtocol *This = impl_from_IUnknown(iface);
LONG ref = InterlockedIncrement(&This->ref); LONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref); TRACE("(%p) ref=%d\n", This, ref);
return ref; return ref;
} }
static ULONG WINAPI MkProtocol_Release(IInternetProtocolEx *iface) static ULONG WINAPI MkProtocolUnk_Release(IUnknown *iface)
{ {
MkProtocol *This = impl_from_IInternetProtocolEx(iface); MkProtocol *This = impl_from_IUnknown(iface);
LONG ref = InterlockedDecrement(&This->ref); LONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref); TRACE("(%p) ref=%d\n", This, ref);
...@@ -92,6 +97,33 @@ static ULONG WINAPI MkProtocol_Release(IInternetProtocolEx *iface) ...@@ -92,6 +97,33 @@ static ULONG WINAPI MkProtocol_Release(IInternetProtocolEx *iface)
return ref; return ref;
} }
static const IUnknownVtbl MkProtocolUnkVtbl = {
MkProtocolUnk_QueryInterface,
MkProtocolUnk_AddRef,
MkProtocolUnk_Release
};
static HRESULT WINAPI MkProtocol_QueryInterface(IInternetProtocolEx *iface, REFIID riid, void **ppv)
{
MkProtocol *This = impl_from_IInternetProtocolEx(iface);
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return IUnknown_QueryInterface(This->outer, riid, ppv);
}
static ULONG WINAPI MkProtocol_AddRef(IInternetProtocolEx *iface)
{
MkProtocol *This = impl_from_IInternetProtocolEx(iface);
TRACE("(%p)\n", This);
return IUnknown_AddRef(This->outer);
}
static ULONG WINAPI MkProtocol_Release(IInternetProtocolEx *iface)
{
MkProtocol *This = impl_from_IInternetProtocolEx(iface);
TRACE("(%p)\n", This);
return IUnknown_Release(This->outer);
}
static HRESULT report_result(IInternetProtocolSink *sink, HRESULT hres, DWORD dwError) static HRESULT report_result(IInternetProtocolSink *sink, HRESULT hres, DWORD dwError)
{ {
IInternetProtocolSink_ReportResult(sink, hres, dwError, NULL); IInternetProtocolSink_ReportResult(sink, hres, dwError, NULL);
...@@ -330,24 +362,25 @@ static const IInternetProtocolExVtbl MkProtocolVtbl = { ...@@ -330,24 +362,25 @@ static const IInternetProtocolExVtbl MkProtocolVtbl = {
MkProtocol_StartEx MkProtocol_StartEx
}; };
HRESULT MkProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) HRESULT MkProtocol_Construct(IUnknown *outer, void **ppv)
{ {
MkProtocol *ret; MkProtocol *ret;
TRACE("(%p %p)\n", pUnkOuter, ppobj); TRACE("(%p %p)\n", outer, ppv);
URLMON_LockModule(); URLMON_LockModule();
ret = heap_alloc(sizeof(MkProtocol)); ret = heap_alloc(sizeof(MkProtocol));
ret->IUnknown_outer.lpVtbl = &MkProtocolUnkVtbl;
ret->IInternetProtocolEx_iface.lpVtbl = &MkProtocolVtbl; ret->IInternetProtocolEx_iface.lpVtbl = &MkProtocolVtbl;
ret->ref = 1; ret->ref = 1;
ret->outer = outer ? outer : &ret->IUnknown_outer;
ret->stream = NULL; ret->stream = NULL;
/* NOTE: /* NOTE:
* Native returns NULL ppobj and S_OK in CreateInstance if called with IID_IUnknown riid. * Native returns NULL ppobj and S_OK in CreateInstance if called with IID_IUnknown riid and no outer.
*/ */
*ppobj = &ret->IInternetProtocolEx_iface; *ppv = &ret->IUnknown_outer;
return S_OK; return S_OK;
} }
...@@ -4104,6 +4104,7 @@ START_TEST(protocol) ...@@ -4104,6 +4104,7 @@ START_TEST(protocol)
test_com_aggregation(&CLSID_HttpProtocol); test_com_aggregation(&CLSID_HttpProtocol);
test_com_aggregation(&CLSID_HttpSProtocol); test_com_aggregation(&CLSID_HttpSProtocol);
test_com_aggregation(&CLSID_FtpProtocol); test_com_aggregation(&CLSID_FtpProtocol);
test_com_aggregation(&CLSID_MkProtocol);
OleUninitialize(); OleUninitialize();
} }
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