From 666f73c4d6f28abd99acaa747f94233de41bc668 Mon Sep 17 00:00:00 2001 From: Steve Lamerton Date: Tue, 26 Jul 2011 16:11:38 +0000 Subject: [PATCH] Very basic implementation of IInternetProtocolInfo, this will allow us to correctly parse links in virtual file systems. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68432 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/webview_ie.h | 21 +++++++++++++++++- src/msw/webview_ie.cpp | 43 +++++++++++++++++++++++++++++++------ 2 files changed, 57 insertions(+), 7 deletions(-) diff --git a/include/wx/msw/webview_ie.h b/include/wx/msw/webview_ie.h index 935f2c6c12..b9d9bcfb26 100644 --- a/include/wx/msw/webview_ie.h +++ b/include/wx/msw/webview_ie.h @@ -158,7 +158,7 @@ private: }; -class VirtualProtocol : public IInternetProtocol +class VirtualProtocol : public IInternetProtocol, public IInternetProtocolInfo { protected: ULONG m_refCount; @@ -202,6 +202,25 @@ public: ULARGE_INTEGER* WXUNUSED(plibNewPosition)) { return E_FAIL; } HRESULT STDMETHODCALLTYPE UnlockRequest() { return S_OK; } + + //IInternetProtocolInfo + HRESULT STDMETHODCALLTYPE CombineUrl(LPCWSTR pwzBaseUrl, + LPCWSTR pwzRelativeUrl, + DWORD dwCombineFlags, + LPWSTR pwzResult, DWORD cchResult, + DWORD *pcchResult, DWORD dwReserved); + HRESULT STDMETHODCALLTYPE CompareUrl(LPCWSTR pwzUrl1, LPCWSTR pwzUrl2, + DWORD dwCompareFlags) + { return INET_E_DEFAULT_ACTION; } + HRESULT STDMETHODCALLTYPE ParseUrl(LPCWSTR pwzUrl, PARSEACTION ParseAction, + DWORD dwParseFlags, LPWSTR pwzResult, + DWORD cchResult, DWORD *pcchResult, + DWORD dwReserved); + HRESULT STDMETHODCALLTYPE QueryInfo(LPCWSTR pwzUrl, + QUERYOPTION OueryOption, + DWORD dwQueryFlags, LPVOID pBuffer, + DWORD cbBuffer, DWORD *pcbBuf, + DWORD dwReserved); }; class ClassFactory : public IClassFactory diff --git a/src/msw/webview_ie.cpp b/src/msw/webview_ie.cpp index 4905e5de82..761e9cc269 100644 --- a/src/msw/webview_ie.cpp +++ b/src/msw/webview_ie.cpp @@ -101,7 +101,7 @@ bool wxWebViewIE::Create(wxWindow* parent, IInternetSession* session; if(CoInternetGetSession(0, &session, 0) != S_OK) return false; - HRESULT hr = session->RegisterNameSpace(cf, CLSID_FileProtocol, L"file", 0, NULL, 0); + HRESULT hr = session->RegisterNameSpace(cf, CLSID_FileProtocol, L"test", 0, NULL, 0); if(FAILED(hr)) return false; @@ -990,10 +990,16 @@ ULONG VirtualProtocol::AddRef() HRESULT VirtualProtocol::QueryInterface(REFIID riid, void **ppvObject) { - if ((riid == IID_IUnknown) || (riid == IID_IInternetProtocol) - || (riid == IID_IInternetProtocolRoot)) + if(riid == IID_IUnknown || riid == IID_IInternetProtocol + || riid == IID_IInternetProtocolRoot) { - *ppvObject = this; + *ppvObject = (IInternetProtocol*)this; + AddRef(); + return S_OK; + } + else if(riid == IID_IInternetProtocolInfo) + { + *ppvObject = (IInternetProtocolInfo*)this; AddRef(); return S_OK; } @@ -1032,6 +1038,7 @@ HRESULT VirtualProtocol::Start(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink wxString path = wxString(szUrl).BeforeFirst(':') + ":" + EscapeFileNameCharsInURL(wxString(szUrl).AfterFirst(':')); path.Replace("///", "/"); + path.Replace("test", "file"); m_file = m_fileSys->OpenFile(path); if(!m_file) @@ -1039,11 +1046,11 @@ HRESULT VirtualProtocol::Start(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink //We return the stream length for current and total size as we can always //read the whole file from the stream + wxFileOffset length = m_file->GetStream()->GetLength(); m_protocolSink->ReportData(BSCF_FIRSTDATANOTIFICATION | BSCF_DATAFULLYAVAILABLE | BSCF_LASTDATANOTIFICATION, - m_file->GetStream()->GetLength(), - m_file->GetStream()->GetLength()); + length, length); return S_OK; } @@ -1086,6 +1093,30 @@ HRESULT VirtualProtocol::Read(void *pv, ULONG cb, ULONG *pcbRead) } } +HRESULT VirtualProtocol::CombineUrl(LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, + DWORD dwCombineFlags, LPWSTR pwzResult, + DWORD cchResult, DWORD *pcchResult, + DWORD dwReserved) +{ + return INET_E_DEFAULT_ACTION; +} + +HRESULT VirtualProtocol::ParseUrl(LPCWSTR pwzUrl, PARSEACTION ParseAction, + DWORD dwParseFlags, LPWSTR pwzResult, + DWORD cchResult, DWORD *pcchResult, + DWORD dwReserved) +{ + return INET_E_DEFAULT_ACTION; +} + +HRESULT VirtualProtocol::QueryInfo(LPCWSTR pwzUrl, QUERYOPTION OueryOption, + DWORD dwQueryFlags, LPVOID pBuffer, + DWORD cbBuffer, DWORD *pcbBuf, + DWORD dwReserved) +{ + return INET_E_DEFAULT_ACTION; +} + HRESULT ClassFactory::CreateInstance(IUnknown* pUnkOuter, REFIID riid, void ** ppvObject) { -- 2.45.2