Commit 38d578af authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

urlmon: Add mime handler layer before data is processed.

parent 8e2f97fa
......@@ -18,7 +18,6 @@ C_SRCS = \
mimefilter.c \
mk.c \
protocol.c \
protproxy.c \
sec_mgr.c \
session.c \
umon.c \
......
/*
* Copyright 2009 Jacek Caban for CodeWeavers
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "urlmon_main.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
static inline ProtocolProxy *impl_from_IInternetProtocol(IInternetProtocol *iface)
{
return CONTAINING_RECORD(iface, ProtocolProxy, IInternetProtocol_iface);
}
static HRESULT WINAPI ProtocolProxy_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
{
ProtocolProxy *This = impl_from_IInternetProtocol(iface);
*ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = &This->IInternetProtocol_iface;
}else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv);
*ppv = &This->IInternetProtocol_iface;
}else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv);
*ppv = &This->IInternetProtocol_iface;
}else if(IsEqualGUID(&IID_IInternetProtocolSink, riid)) {
TRACE("(%p)->(IID_IInternetProtocolSink %p)\n", This, ppv);
*ppv = &This->IInternetProtocolSink_iface;
}
if(*ppv) {
IInternetProtocol_AddRef(iface);
return S_OK;
}
WARN("not supported interface %s\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
static ULONG WINAPI ProtocolProxy_AddRef(IInternetProtocol *iface)
{
ProtocolProxy *This = impl_from_IInternetProtocol(iface);
LONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
return ref;
}
static ULONG WINAPI ProtocolProxy_Release(IInternetProtocol *iface)
{
ProtocolProxy *This = impl_from_IInternetProtocol(iface);
LONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
if(!ref) {
if(This->protocol_sink)
IInternetProtocolSink_Release(This->protocol_sink);
if(This->protocol)
IInternetProtocol_Release(This->protocol);
heap_free(This);
URLMON_UnlockModule();
}
return ref;
}
static HRESULT WINAPI ProtocolProxy_Start(IInternetProtocol *iface, LPCWSTR szUrl,
IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
DWORD grfPI, HANDLE_PTR dwReserved)
{
ProtocolProxy *This = impl_from_IInternetProtocol(iface);
TRACE("(%p)->(%s %p %p %08x %lx)\n", This, debugstr_w(szUrl), pOIProtSink,
pOIBindInfo, grfPI, dwReserved);
return IInternetProtocol_Start(This->protocol, szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved);
}
static HRESULT WINAPI ProtocolProxy_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData)
{
ProtocolProxy *This = impl_from_IInternetProtocol(iface);
TRACE("(%p)->(%p)\n", This, pProtocolData);
return IInternetProtocol_Continue(This->protocol, pProtocolData);
}
static HRESULT WINAPI ProtocolProxy_Abort(IInternetProtocol *iface, HRESULT hrReason,
DWORD dwOptions)
{
ProtocolProxy *This = impl_from_IInternetProtocol(iface);
FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions);
return E_NOTIMPL;
}
static HRESULT WINAPI ProtocolProxy_Terminate(IInternetProtocol *iface, DWORD dwOptions)
{
ProtocolProxy *This = impl_from_IInternetProtocol(iface);
TRACE("(%p)->(%08x)\n", This, dwOptions);
return IInternetProtocol_Terminate(This->protocol, dwOptions);
}
static HRESULT WINAPI ProtocolProxy_Suspend(IInternetProtocol *iface)
{
ProtocolProxy *This = impl_from_IInternetProtocol(iface);
FIXME("(%p)\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI ProtocolProxy_Resume(IInternetProtocol *iface)
{
ProtocolProxy *This = impl_from_IInternetProtocol(iface);
FIXME("(%p)\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI ProtocolProxy_Read(IInternetProtocol *iface, void *pv,
ULONG cb, ULONG *pcbRead)
{
ProtocolProxy *This = impl_from_IInternetProtocol(iface);
TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead);
return IInternetProtocol_Read(This->protocol, pv, cb, pcbRead);
}
static HRESULT WINAPI ProtocolProxy_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
{
ProtocolProxy *This = impl_from_IInternetProtocol(iface);
FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
return E_NOTIMPL;
}
static HRESULT WINAPI ProtocolProxy_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
{
ProtocolProxy *This = impl_from_IInternetProtocol(iface);
TRACE("(%p)->(%08x)\n", This, dwOptions);
return IInternetProtocol_LockRequest(This->protocol, dwOptions);
}
static HRESULT WINAPI ProtocolProxy_UnlockRequest(IInternetProtocol *iface)
{
ProtocolProxy *This = impl_from_IInternetProtocol(iface);
TRACE("(%p)\n", This);
return IInternetProtocol_UnlockRequest(This->protocol);
}
static const IInternetProtocolVtbl ProtocolProxyVtbl = {
ProtocolProxy_QueryInterface,
ProtocolProxy_AddRef,
ProtocolProxy_Release,
ProtocolProxy_Start,
ProtocolProxy_Continue,
ProtocolProxy_Abort,
ProtocolProxy_Terminate,
ProtocolProxy_Suspend,
ProtocolProxy_Resume,
ProtocolProxy_Read,
ProtocolProxy_Seek,
ProtocolProxy_LockRequest,
ProtocolProxy_UnlockRequest
};
static inline ProtocolProxy *impl_from_IInternetProtocolSink(IInternetProtocolSink *iface)
{
return CONTAINING_RECORD(iface, ProtocolProxy, IInternetProtocolSink_iface);
}
static HRESULT WINAPI ProtocolProxySink_QueryInterface(IInternetProtocolSink *iface,
REFIID riid, void **ppv)
{
ProtocolProxy *This = impl_from_IInternetProtocolSink(iface);
return IInternetProtocol_QueryInterface(&This->IInternetProtocol_iface, riid, ppv);
}
static ULONG WINAPI ProtocolProxySink_AddRef(IInternetProtocolSink *iface)
{
ProtocolProxy *This = impl_from_IInternetProtocolSink(iface);
return IInternetProtocol_AddRef(&This->IInternetProtocol_iface);
}
static ULONG WINAPI ProtocolProxySink_Release(IInternetProtocolSink *iface)
{
ProtocolProxy *This = impl_from_IInternetProtocolSink(iface);
return IInternetProtocol_Release(&This->IInternetProtocol_iface);
}
static HRESULT WINAPI ProtocolProxySink_Switch(IInternetProtocolSink *iface,
PROTOCOLDATA *pProtocolData)
{
ProtocolProxy *This = impl_from_IInternetProtocolSink(iface);
TRACE("(%p)->(%p)\n", This, pProtocolData);
return IInternetProtocolSink_Switch(This->protocol_sink, pProtocolData);
}
static HRESULT WINAPI ProtocolProxySink_ReportProgress(IInternetProtocolSink *iface,
ULONG ulStatusCode, LPCWSTR szStatusText)
{
ProtocolProxy *This = impl_from_IInternetProtocolSink(iface);
TRACE("(%p)->(%u %s)\n", This, ulStatusCode, debugstr_w(szStatusText));
switch(ulStatusCode) {
case BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE:
IInternetProtocolSink_ReportProgress(This->protocol_sink, BINDSTATUS_MIMETYPEAVAILABLE, szStatusText);
break;
default:
IInternetProtocolSink_ReportProgress(This->protocol_sink, ulStatusCode, szStatusText);
}
return S_OK;
}
static HRESULT WINAPI ProtocolProxySink_ReportData(IInternetProtocolSink *iface,
DWORD grfBSCF, ULONG ulProgress, ULONG ulProgressMax)
{
ProtocolProxy *This = impl_from_IInternetProtocolSink(iface);
TRACE("(%p)->(%d %u %u)\n", This, grfBSCF, ulProgress, ulProgressMax);
return IInternetProtocolSink_ReportData(This->protocol_sink, grfBSCF, ulProgress, ulProgressMax);
}
static HRESULT WINAPI ProtocolProxySink_ReportResult(IInternetProtocolSink *iface,
HRESULT hrResult, DWORD dwError, LPCWSTR szResult)
{
ProtocolProxy *This = impl_from_IInternetProtocolSink(iface);
TRACE("(%p)->(%08x %d %s)\n", This, hrResult, dwError, debugstr_w(szResult));
return IInternetProtocolSink_ReportResult(This->protocol_sink, hrResult, dwError, szResult);
}
static const IInternetProtocolSinkVtbl InternetProtocolSinkVtbl = {
ProtocolProxySink_QueryInterface,
ProtocolProxySink_AddRef,
ProtocolProxySink_Release,
ProtocolProxySink_Switch,
ProtocolProxySink_ReportProgress,
ProtocolProxySink_ReportData,
ProtocolProxySink_ReportResult
};
HRESULT create_protocol_proxy(IInternetProtocol *protocol, IInternetProtocolSink *protocol_sink, ProtocolProxy **ret)
{
ProtocolProxy *sink;
sink = heap_alloc(sizeof(ProtocolProxy));
if(!sink)
return E_OUTOFMEMORY;
sink->IInternetProtocol_iface.lpVtbl = &ProtocolProxyVtbl;
sink->IInternetProtocolSink_iface.lpVtbl = &InternetProtocolSinkVtbl;
sink->ref = 1;
IInternetProtocol_AddRef(protocol);
sink->protocol = protocol;
IInternetProtocolSink_AddRef(protocol_sink);
sink->protocol_sink = protocol_sink;
*ret = sink;
return S_OK;
}
......@@ -148,7 +148,7 @@ static void *expect_pv;
static HANDLE event_complete, event_complete2, event_continue, event_continue_done;
static BOOL binding_test;
static PROTOCOLDATA protocoldata, *pdata, continue_protdata;
static DWORD prot_read, pi, filter_state, http_post_test, thread_id;
static DWORD prot_read, filter_state, http_post_test, thread_id;
static BOOL security_problem, test_async_req, impl_protex;
static BOOL async_read_pending, mimefilter_test, direct_read, wait_for_switch, emulate_prot, short_read, test_abort;
static BOOL empty_file;
......@@ -1617,7 +1617,7 @@ static void protocol_start(IInternetProtocolSink *pOIProtSink, IInternetBindInfo
CHECK_CALLED(MimeFilter_CreateInstance);
CHECK_CALLED(MimeFilter_Start);
CHECK_CALLED(ReportProgress_LOADINGMIMEHANDLER);
todo_wine CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
}else {
CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
}
......@@ -2208,8 +2208,6 @@ static void register_filter(BOOL do_register)
IInternetSession *session;
HRESULT hres;
static const WCHAR gzipW[] = {'g','z','i','p',0};
hres = pCoInternetGetSession(0, &session, 0);
ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
......
......@@ -155,18 +155,6 @@ void protocol_close_connection(Protocol*) DECLSPEC_HIDDEN;
void find_domain_name(const WCHAR*,DWORD,INT*) DECLSPEC_HIDDEN;
typedef struct {
IInternetProtocol IInternetProtocol_iface;
IInternetProtocolSink IInternetProtocolSink_iface;
LONG ref;
IInternetProtocolSink *protocol_sink;
IInternetProtocol *protocol;
} ProtocolProxy;
HRESULT create_protocol_proxy(IInternetProtocol*,IInternetProtocolSink*,ProtocolProxy**) DECLSPEC_HIDDEN;
typedef struct _task_header_t task_header_t;
typedef struct {
......@@ -188,8 +176,10 @@ typedef struct {
struct {
IInternetProtocol IInternetProtocol_iface;
IInternetProtocolSink IInternetProtocolSink_iface;
} default_protocol_handler;
IInternetProtocol *protocol_handler;
IInternetProtocolSink *protocol_sink_handler;
LONG priority;
......@@ -214,7 +204,6 @@ typedef struct {
LPWSTR mime;
IUri *uri;
BSTR display_uri;
ProtocolProxy *filter_proxy;
} BindProtocol;
HRESULT create_binding_protocol(BOOL,BindProtocol**) DECLSPEC_HIDDEN;
......
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