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
This commit is contained in:
@@ -158,7 +158,7 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class VirtualProtocol : public IInternetProtocol
|
class VirtualProtocol : public IInternetProtocol, public IInternetProtocolInfo
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
ULONG m_refCount;
|
ULONG m_refCount;
|
||||||
@@ -202,6 +202,25 @@ public:
|
|||||||
ULARGE_INTEGER* WXUNUSED(plibNewPosition))
|
ULARGE_INTEGER* WXUNUSED(plibNewPosition))
|
||||||
{ return E_FAIL; }
|
{ return E_FAIL; }
|
||||||
HRESULT STDMETHODCALLTYPE UnlockRequest() { return S_OK; }
|
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
|
class ClassFactory : public IClassFactory
|
||||||
|
@@ -101,7 +101,7 @@ bool wxWebViewIE::Create(wxWindow* parent,
|
|||||||
IInternetSession* session;
|
IInternetSession* session;
|
||||||
if(CoInternetGetSession(0, &session, 0) != S_OK)
|
if(CoInternetGetSession(0, &session, 0) != S_OK)
|
||||||
return false;
|
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))
|
if(FAILED(hr))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -990,10 +990,16 @@ ULONG VirtualProtocol::AddRef()
|
|||||||
|
|
||||||
HRESULT VirtualProtocol::QueryInterface(REFIID riid, void **ppvObject)
|
HRESULT VirtualProtocol::QueryInterface(REFIID riid, void **ppvObject)
|
||||||
{
|
{
|
||||||
if ((riid == IID_IUnknown) || (riid == IID_IInternetProtocol)
|
if(riid == IID_IUnknown || riid == IID_IInternetProtocol
|
||||||
|| (riid == IID_IInternetProtocolRoot))
|
|| riid == IID_IInternetProtocolRoot)
|
||||||
{
|
{
|
||||||
*ppvObject = this;
|
*ppvObject = (IInternetProtocol*)this;
|
||||||
|
AddRef();
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
else if(riid == IID_IInternetProtocolInfo)
|
||||||
|
{
|
||||||
|
*ppvObject = (IInternetProtocolInfo*)this;
|
||||||
AddRef();
|
AddRef();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
@@ -1032,6 +1038,7 @@ HRESULT VirtualProtocol::Start(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink
|
|||||||
wxString path = wxString(szUrl).BeforeFirst(':') + ":" +
|
wxString path = wxString(szUrl).BeforeFirst(':') + ":" +
|
||||||
EscapeFileNameCharsInURL(wxString(szUrl).AfterFirst(':'));
|
EscapeFileNameCharsInURL(wxString(szUrl).AfterFirst(':'));
|
||||||
path.Replace("///", "/");
|
path.Replace("///", "/");
|
||||||
|
path.Replace("test", "file");
|
||||||
m_file = m_fileSys->OpenFile(path);
|
m_file = m_fileSys->OpenFile(path);
|
||||||
|
|
||||||
if(!m_file)
|
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
|
//We return the stream length for current and total size as we can always
|
||||||
//read the whole file from the stream
|
//read the whole file from the stream
|
||||||
|
wxFileOffset length = m_file->GetStream()->GetLength();
|
||||||
m_protocolSink->ReportData(BSCF_FIRSTDATANOTIFICATION |
|
m_protocolSink->ReportData(BSCF_FIRSTDATANOTIFICATION |
|
||||||
BSCF_DATAFULLYAVAILABLE |
|
BSCF_DATAFULLYAVAILABLE |
|
||||||
BSCF_LASTDATANOTIFICATION,
|
BSCF_LASTDATANOTIFICATION,
|
||||||
m_file->GetStream()->GetLength(),
|
length, length);
|
||||||
m_file->GetStream()->GetLength());
|
|
||||||
return S_OK;
|
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,
|
HRESULT ClassFactory::CreateInstance(IUnknown* pUnkOuter, REFIID riid,
|
||||||
void ** ppvObject)
|
void ** ppvObject)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user