2005-06-27 11:50:56 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2005 Jacek Caban
|
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-06-27 11:50:56 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
2005-06-30 12:21:58 +02:00
|
|
|
#include "wine/unicode.h"
|
2005-06-27 11:50:56 +02:00
|
|
|
|
|
|
|
#include "mshtml_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* common ProtocolFactory implementation
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define PROTOCOLINFO(x) ((IInternetProtocolInfo*) &(x)->lpInternetProtocolInfoVtbl)
|
|
|
|
#define CLASSFACTORY(x) ((IClassFactory*) &(x)->lpClassFactoryVtbl)
|
2005-08-11 19:04:45 +02:00
|
|
|
#define PROTOCOL(x) ((IInternetProtocol*) &(x)->lpInternetProtocolVtbl)
|
2005-06-27 11:50:56 +02:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
const IInternetProtocolInfoVtbl *lpInternetProtocolInfoVtbl;
|
|
|
|
const IClassFactoryVtbl *lpClassFactoryVtbl;
|
|
|
|
} ProtocolFactory;
|
|
|
|
|
2005-08-02 11:49:06 +02:00
|
|
|
#define PROTOCOLINFO_THIS(iface) DEFINE_THIS(ProtocolFactory, InternetProtocolInfo, iface)
|
2005-06-27 11:50:56 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI InternetProtocolInfo_QueryInterface(IInternetProtocolInfo *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
2005-06-30 12:21:58 +02:00
|
|
|
ProtocolFactory *This = PROTOCOLINFO_THIS(iface);
|
2005-06-27 11:50:56 +02:00
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
|
|
|
*ppv = PROTOCOLINFO(This);
|
|
|
|
}else if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetProtocolInfo %p)\n", This, ppv);
|
|
|
|
*ppv = PROTOCOLINFO(This);
|
|
|
|
}else if(IsEqualGUID(&IID_IClassFactory, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IClassFactory %p)\n", This, ppv);
|
|
|
|
*ppv = CLASSFACTORY(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!*ppv) {
|
|
|
|
WARN("unknown interface %s\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IInternetProtocolInfo_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InternetProtocolInfo_AddRef(IInternetProtocolInfo *iface)
|
|
|
|
{
|
2005-06-30 12:21:58 +02:00
|
|
|
ProtocolFactory *This = PROTOCOLINFO_THIS(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
2005-08-02 11:49:06 +02:00
|
|
|
LOCK_MODULE();
|
2005-06-27 11:50:56 +02:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InternetProtocolInfo_Release(IInternetProtocolInfo *iface)
|
|
|
|
{
|
2005-06-30 12:21:58 +02:00
|
|
|
ProtocolFactory *This = PROTOCOLINFO_THIS(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
2005-08-02 11:49:06 +02:00
|
|
|
UNLOCK_MODULE();
|
2005-06-27 11:50:56 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-08-12 18:43:16 +02:00
|
|
|
static HRESULT WINAPI InternetProtocolInfo_CombineUrl(IInternetProtocolInfo *iface,
|
|
|
|
LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags, LPWSTR pwzResult,
|
|
|
|
DWORD cchResult, DWORD* pcchResult, DWORD dwReserved)
|
|
|
|
{
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("%p)->(%s %s %08x %p %d %p %d)\n", iface, debugstr_w(pwzBaseUrl),
|
2006-08-12 18:43:16 +02:00
|
|
|
debugstr_w(pwzRelativeUrl), dwCombineFlags, pwzResult, cchResult,
|
|
|
|
pcchResult, dwReserved);
|
|
|
|
|
|
|
|
return INET_E_USE_DEFAULT_PROTOCOLHANDLER;
|
|
|
|
}
|
|
|
|
|
2006-12-12 21:52:46 +01:00
|
|
|
static HRESULT WINAPI InternetProtocolInfo_CompareUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl1,
|
|
|
|
LPCWSTR pwzUrl2, DWORD dwCompareFlags)
|
|
|
|
{
|
|
|
|
TRACE("%p)->(%s %s %08x)\n", iface, debugstr_w(pwzUrl1), debugstr_w(pwzUrl2), dwCompareFlags);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2005-06-30 12:21:58 +02:00
|
|
|
#undef PROTOCOLINFO_THIS
|
|
|
|
|
2005-08-02 11:49:06 +02:00
|
|
|
#define CLASSFACTORY_THIS(iface) DEFINE_THIS(ProtocolFactory, ClassFactory, iface)
|
2005-06-27 11:50:56 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
2005-06-30 12:21:58 +02:00
|
|
|
ProtocolFactory *This = CLASSFACTORY_THIS(iface);
|
2005-06-27 11:50:56 +02:00
|
|
|
return IInternetProtocolInfo_QueryInterface(PROTOCOLINFO(This), riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
|
|
|
|
{
|
2005-06-30 12:21:58 +02:00
|
|
|
ProtocolFactory *This = CLASSFACTORY_THIS(iface);
|
2005-06-27 11:50:56 +02:00
|
|
|
return IInternetProtocolInfo_AddRef(PROTOCOLINFO(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
|
|
|
|
{
|
2005-06-30 12:21:58 +02:00
|
|
|
ProtocolFactory *This = CLASSFACTORY_THIS(iface);
|
2005-06-27 11:50:56 +02:00
|
|
|
return IInternetProtocolInfo_Release(PROTOCOLINFO(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
|
|
|
|
{
|
2005-06-30 12:21:58 +02:00
|
|
|
ProtocolFactory *This = CLASSFACTORY_THIS(iface);
|
2005-08-02 11:49:06 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%x)\n", This, dolock);
|
|
|
|
|
|
|
|
if(dolock)
|
|
|
|
LOCK_MODULE();
|
|
|
|
else
|
|
|
|
UNLOCK_MODULE();
|
|
|
|
|
2005-06-27 11:50:56 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-30 12:21:58 +02:00
|
|
|
#undef CLASSFACTORY_THIS
|
|
|
|
|
2005-06-27 11:50:56 +02:00
|
|
|
/********************************************************************
|
|
|
|
* AboutProtocol implementation
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
const IInternetProtocolVtbl *lpInternetProtocolVtbl;
|
2005-08-03 12:56:26 +02:00
|
|
|
|
2005-07-06 12:33:10 +02:00
|
|
|
LONG ref;
|
2005-08-03 12:56:26 +02:00
|
|
|
|
|
|
|
BYTE *data;
|
|
|
|
ULONG data_len;
|
|
|
|
ULONG cur;
|
2005-08-11 19:04:45 +02:00
|
|
|
|
|
|
|
IUnknown *pUnkOuter;
|
2005-06-27 11:50:56 +02:00
|
|
|
} AboutProtocol;
|
|
|
|
|
2005-08-15 12:23:35 +02:00
|
|
|
#define PROTOCOL_THIS(iface) DEFINE_THIS(AboutProtocol, InternetProtocol, iface)
|
|
|
|
|
2005-06-27 11:50:56 +02:00
|
|
|
static HRESULT WINAPI AboutProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
AboutProtocol *This = PROTOCOL_THIS(iface);
|
2005-08-11 19:04:45 +02:00
|
|
|
|
2005-06-27 11:50:56 +02:00
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
|
2005-08-11 19:04:45 +02:00
|
|
|
if(This->pUnkOuter)
|
|
|
|
return IUnknown_QueryInterface(This->pUnkOuter, riid, ppv);
|
|
|
|
*ppv = PROTOCOL(This);
|
2005-06-27 11:50:56 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", iface, ppv);
|
2005-08-11 19:04:45 +02:00
|
|
|
*ppv = PROTOCOL(This);
|
2005-06-27 11:50:56 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetProtocol %p)\n", iface, ppv);
|
2005-08-11 19:04:45 +02:00
|
|
|
*ppv = PROTOCOL(This);
|
2005-06-27 11:50:56 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
|
|
|
|
FIXME("IServiceProvider is not implemented\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!*ppv) {
|
|
|
|
TRACE("unknown interface %s\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IInternetProtocol_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI AboutProtocol_AddRef(IInternetProtocol *iface)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
AboutProtocol *This = PROTOCOL_THIS(iface);
|
2005-06-27 11:50:56 +02:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p) ref=%d\n", iface, ref);
|
2005-08-11 19:04:45 +02:00
|
|
|
return This->pUnkOuter ? IUnknown_AddRef(This->pUnkOuter) : ref;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI AboutProtocol_Release(IInternetProtocol *iface)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
AboutProtocol *This = PROTOCOL_THIS(iface);
|
|
|
|
IUnknown *pUnkOuter = This->pUnkOuter;
|
2005-06-27 11:50:56 +02:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p) ref=%x\n", iface, ref);
|
2005-06-27 11:50:56 +02:00
|
|
|
|
2005-08-02 11:49:06 +02:00
|
|
|
if(!ref) {
|
2006-07-16 23:21:36 +02:00
|
|
|
mshtml_free(This->data);
|
|
|
|
mshtml_free(This);
|
2005-08-02 11:49:06 +02:00
|
|
|
UNLOCK_MODULE();
|
|
|
|
}
|
2005-06-27 11:50:56 +02:00
|
|
|
|
2005-08-15 12:23:35 +02:00
|
|
|
return pUnkOuter ? IUnknown_Release(pUnkOuter) : ref;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AboutProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
|
|
|
|
IInternetProtocolSink* pOIProtSink, IInternetBindInfo* pOIBindInfo,
|
|
|
|
DWORD grfPI, DWORD dwReserved)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
AboutProtocol *This = PROTOCOL_THIS(iface);
|
2005-08-03 12:56:26 +02:00
|
|
|
BINDINFO bindinfo;
|
|
|
|
DWORD grfBINDF = 0;
|
|
|
|
LPCWSTR text = NULL;
|
|
|
|
|
|
|
|
static const WCHAR html_begin[] = {0xfeff,'<','H','T','M','L','>',0};
|
|
|
|
static const WCHAR html_end[] = {'<','/','H','T','M','L','>',0};
|
|
|
|
static const WCHAR wszBlank[] = {'b','l','a','n','k',0};
|
|
|
|
static const WCHAR wszAbout[] = {'a','b','o','u','t',':'};
|
2005-08-09 22:35:36 +02:00
|
|
|
static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
|
2005-08-03 12:56:26 +02:00
|
|
|
|
|
|
|
/* NOTE:
|
|
|
|
* the about protocol seems not to work as I would expect. It creates html document
|
|
|
|
* for a given url, eg. about:some_text -> <HTML>some_text</HTML> except for the case when
|
|
|
|
* some_text = "blank", when document is blank (<HTML></HMTL>). The same happens
|
|
|
|
* when the url does not have "about:" in the beginning.
|
|
|
|
*/
|
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%s %p %p %08x %d)\n", This, debugstr_w(szUrl), pOIProtSink,
|
2005-06-27 11:50:56 +02:00
|
|
|
pOIBindInfo, grfPI, dwReserved);
|
2005-08-03 12:56:26 +02:00
|
|
|
|
|
|
|
memset(&bindinfo, 0, sizeof(bindinfo));
|
|
|
|
bindinfo.cbSize = sizeof(BINDINFO);
|
|
|
|
IInternetBindInfo_GetBindInfo(pOIBindInfo, &grfBINDF, &bindinfo);
|
2005-09-08 20:55:18 +02:00
|
|
|
ReleaseBindInfo(&bindinfo);
|
2005-08-03 12:56:26 +02:00
|
|
|
|
|
|
|
if(strlenW(szUrl)>=sizeof(wszAbout)/sizeof(WCHAR) && !memcmp(wszAbout, szUrl, sizeof(wszAbout))) {
|
|
|
|
text = szUrl + sizeof(wszAbout)/sizeof(WCHAR);
|
|
|
|
if(!strcmpW(wszBlank, text))
|
|
|
|
text = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
This->data_len = sizeof(html_begin)+sizeof(html_end)-sizeof(WCHAR)
|
|
|
|
+ (text ? strlenW(text)*sizeof(WCHAR) : 0);
|
2006-07-16 23:21:36 +02:00
|
|
|
This->data = mshtml_alloc(This->data_len);
|
2005-08-03 12:56:26 +02:00
|
|
|
|
|
|
|
memcpy(This->data, html_begin, sizeof(html_begin));
|
|
|
|
if(text)
|
|
|
|
strcatW((LPWSTR)This->data, text);
|
|
|
|
strcatW((LPWSTR)This->data, html_end);
|
|
|
|
|
|
|
|
This->cur = 0;
|
|
|
|
|
2005-08-09 22:35:36 +02:00
|
|
|
IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
|
|
|
|
|
2005-08-03 12:56:26 +02:00
|
|
|
IInternetProtocolSink_ReportData(pOIProtSink,
|
|
|
|
BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION | BSCF_DATAFULLYAVAILABLE,
|
|
|
|
This->data_len, This->data_len);
|
|
|
|
|
|
|
|
IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
|
|
|
|
|
|
|
|
return S_OK;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AboutProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA* pProtocolData)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
AboutProtocol *This = PROTOCOL_THIS(iface);
|
2005-06-27 11:50:56 +02:00
|
|
|
FIXME("(%p)->(%p)\n", This, pProtocolData);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AboutProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
|
|
|
|
DWORD dwOptions)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
AboutProtocol *This = PROTOCOL_THIS(iface);
|
2006-10-05 23:50:39 +02:00
|
|
|
FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions);
|
2005-06-27 11:50:56 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AboutProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
AboutProtocol *This = PROTOCOL_THIS(iface);
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%08x)\n", This, dwOptions);
|
2005-08-03 12:56:26 +02:00
|
|
|
return S_OK;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AboutProtocol_Suspend(IInternetProtocol *iface)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
AboutProtocol *This = PROTOCOL_THIS(iface);
|
2005-06-27 11:50:56 +02:00
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AboutProtocol_Resume(IInternetProtocol *iface)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
AboutProtocol *This = PROTOCOL_THIS(iface);
|
2005-06-27 11:50:56 +02:00
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AboutProtocol_Read(IInternetProtocol *iface, void* pv, ULONG cb, ULONG* pcbRead)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
AboutProtocol *This = PROTOCOL_THIS(iface);
|
2005-08-03 12:56:26 +02:00
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead);
|
2005-08-03 12:56:26 +02:00
|
|
|
|
|
|
|
if(!This->data)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
*pcbRead = (cb > This->data_len-This->cur ? This->data_len-This->cur : cb);
|
|
|
|
|
|
|
|
if(!*pcbRead)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
memcpy(pv, This->data, *pcbRead);
|
|
|
|
This->cur += *pcbRead;
|
|
|
|
|
|
|
|
return S_OK;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AboutProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
|
|
|
|
DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
AboutProtocol *This = PROTOCOL_THIS(iface);
|
2006-10-05 23:50:39 +02:00
|
|
|
FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
|
2005-06-27 11:50:56 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AboutProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
AboutProtocol *This = PROTOCOL_THIS(iface);
|
2005-08-03 12:56:26 +02:00
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%d)\n", This, dwOptions);
|
2005-08-03 12:56:26 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AboutProtocol_UnlockRequest(IInternetProtocol *iface)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
AboutProtocol *This = PROTOCOL_THIS(iface);
|
2005-08-03 12:56:26 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
return S_OK;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
2005-08-15 12:23:35 +02:00
|
|
|
#undef PROTOCOL_THIS
|
|
|
|
|
2005-06-27 11:50:56 +02:00
|
|
|
static const IInternetProtocolVtbl AboutProtocolVtbl = {
|
|
|
|
AboutProtocol_QueryInterface,
|
|
|
|
AboutProtocol_AddRef,
|
|
|
|
AboutProtocol_Release,
|
|
|
|
AboutProtocol_Start,
|
|
|
|
AboutProtocol_Continue,
|
|
|
|
AboutProtocol_Abort,
|
|
|
|
AboutProtocol_Terminate,
|
|
|
|
AboutProtocol_Suspend,
|
|
|
|
AboutProtocol_Resume,
|
|
|
|
AboutProtocol_Read,
|
|
|
|
AboutProtocol_Seek,
|
|
|
|
AboutProtocol_LockRequest,
|
|
|
|
AboutProtocol_UnlockRequest
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI AboutProtocolFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
AboutProtocol *ret;
|
2005-08-11 19:04:45 +02:00
|
|
|
HRESULT hres = S_OK;
|
2005-06-27 11:50:56 +02:00
|
|
|
|
2005-08-11 19:04:45 +02:00
|
|
|
TRACE("(%p)->(%p %s %p)\n", iface, pUnkOuter, debugstr_guid(riid), ppv);
|
2005-06-27 11:50:56 +02:00
|
|
|
|
2006-07-16 23:21:36 +02:00
|
|
|
ret = mshtml_alloc(sizeof(AboutProtocol));
|
2005-06-27 11:50:56 +02:00
|
|
|
ret->lpInternetProtocolVtbl = &AboutProtocolVtbl;
|
|
|
|
ret->ref = 0;
|
|
|
|
|
2005-08-03 12:56:26 +02:00
|
|
|
ret->data = NULL;
|
|
|
|
ret->data_len = 0;
|
|
|
|
ret->cur = 0;
|
2005-08-11 19:04:45 +02:00
|
|
|
ret->pUnkOuter = pUnkOuter;
|
|
|
|
|
|
|
|
if(pUnkOuter) {
|
|
|
|
ret->ref = 1;
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid))
|
|
|
|
*ppv = PROTOCOL(ret);
|
|
|
|
else
|
|
|
|
hres = E_INVALIDARG;
|
|
|
|
}else {
|
|
|
|
hres = IInternetProtocol_QueryInterface(PROTOCOL(ret), riid, ppv);
|
|
|
|
}
|
2005-06-27 11:50:56 +02:00
|
|
|
|
2005-08-02 11:49:06 +02:00
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
LOCK_MODULE();
|
|
|
|
else
|
2006-07-16 23:21:36 +02:00
|
|
|
mshtml_free(ret);
|
2005-06-27 11:50:56 +02:00
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AboutProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
|
|
|
|
PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
|
|
|
|
DWORD* pcchResult, DWORD dwReserved)
|
|
|
|
{
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("%p)->(%s %08x %08x %p %d %p %d)\n", iface, debugstr_w(pwzUrl), ParseAction,
|
2005-06-27 11:50:56 +02:00
|
|
|
dwParseFlags, pwzResult, cchResult, pcchResult, dwReserved);
|
2005-09-12 12:10:21 +02:00
|
|
|
|
|
|
|
if(ParseAction == PARSE_SECURITY_URL) {
|
|
|
|
int len = lstrlenW(pwzUrl);
|
|
|
|
|
|
|
|
if(len >= cchResult)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
memcpy(pwzResult, pwzUrl, (len+1)*sizeof(WCHAR));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ParseAction == PARSE_DOMAIN) {
|
2006-05-12 18:49:27 +02:00
|
|
|
if(!pcchResult)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
if(pwzUrl)
|
|
|
|
*pcchResult = strlenW(pwzUrl)+1;
|
|
|
|
else
|
|
|
|
*pcchResult = 1;
|
|
|
|
return E_FAIL;
|
2005-09-12 12:10:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return INET_E_DEFAULT_ACTION;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AboutProtocolInfo_QueryInfo(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
|
|
|
|
QUERYOPTION QueryOption, DWORD dwQueryFlags, LPVOID pBuffer, DWORD cbBuffer, DWORD* pcbBuf,
|
|
|
|
DWORD dwReserved)
|
|
|
|
{
|
2006-10-05 23:50:39 +02:00
|
|
|
FIXME("%p)->(%s %08x %08x %p %d %p %d)\n", iface, debugstr_w(pwzUrl), QueryOption, dwQueryFlags, pBuffer,
|
2005-06-27 11:50:56 +02:00
|
|
|
cbBuffer, pcbBuf, dwReserved);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IInternetProtocolInfoVtbl AboutProtocolInfoVtbl = {
|
|
|
|
InternetProtocolInfo_QueryInterface,
|
|
|
|
InternetProtocolInfo_AddRef,
|
|
|
|
InternetProtocolInfo_Release,
|
|
|
|
AboutProtocolInfo_ParseUrl,
|
2006-08-12 18:43:16 +02:00
|
|
|
InternetProtocolInfo_CombineUrl,
|
2006-12-12 21:52:46 +01:00
|
|
|
InternetProtocolInfo_CompareUrl,
|
2005-06-27 11:50:56 +02:00
|
|
|
AboutProtocolInfo_QueryInfo
|
|
|
|
};
|
|
|
|
|
|
|
|
static const IClassFactoryVtbl AboutProtocolFactoryVtbl = {
|
|
|
|
ClassFactory_QueryInterface,
|
|
|
|
ClassFactory_AddRef,
|
|
|
|
ClassFactory_Release,
|
|
|
|
AboutProtocolFactory_CreateInstance,
|
|
|
|
ClassFactory_LockServer
|
|
|
|
};
|
|
|
|
|
|
|
|
static ProtocolFactory AboutProtocolFactory = {
|
|
|
|
&AboutProtocolInfoVtbl,
|
|
|
|
&AboutProtocolFactoryVtbl
|
|
|
|
};
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* ResProtocol implementation
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
const IInternetProtocolVtbl *lpInternetProtocolVtbl;
|
2005-07-06 12:33:10 +02:00
|
|
|
LONG ref;
|
2005-06-30 12:21:58 +02:00
|
|
|
|
|
|
|
BYTE *data;
|
|
|
|
ULONG data_len;
|
|
|
|
ULONG cur;
|
2005-08-15 12:23:35 +02:00
|
|
|
|
|
|
|
IUnknown *pUnkOuter;
|
2005-06-27 11:50:56 +02:00
|
|
|
} ResProtocol;
|
|
|
|
|
2005-08-15 12:23:35 +02:00
|
|
|
#define PROTOCOL_THIS(iface) DEFINE_THIS(ResProtocol, InternetProtocol, iface)
|
|
|
|
|
2005-06-27 11:50:56 +02:00
|
|
|
static HRESULT WINAPI ResProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
ResProtocol *This = PROTOCOL_THIS(iface);
|
|
|
|
|
2005-06-27 11:50:56 +02:00
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
|
2005-08-15 12:23:35 +02:00
|
|
|
if(This->pUnkOuter)
|
|
|
|
return IUnknown_QueryInterface(This->pUnkOuter, &IID_IUnknown, ppv);
|
|
|
|
*ppv = PROTOCOL(This);
|
2005-06-27 11:50:56 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", iface, ppv);
|
2005-08-15 12:23:35 +02:00
|
|
|
*ppv = PROTOCOL(This);
|
2005-06-27 11:50:56 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetProtocol %p)\n", iface, ppv);
|
2005-08-15 12:23:35 +02:00
|
|
|
*ppv = PROTOCOL(This);
|
2005-06-27 11:50:56 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
|
|
|
|
FIXME("IServiceProvider is not implemented\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!*ppv) {
|
|
|
|
TRACE("unknown interface %s\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IInternetProtocol_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ResProtocol_AddRef(IInternetProtocol *iface)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
ResProtocol *This = PROTOCOL_THIS(iface);
|
2005-06-27 11:50:56 +02:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p) ref=%d\n", iface, ref);
|
2005-08-15 12:23:35 +02:00
|
|
|
return This->pUnkOuter ? IUnknown_AddRef(This->pUnkOuter) : ref;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ResProtocol_Release(IInternetProtocol *iface)
|
|
|
|
{
|
|
|
|
ResProtocol *This = (ResProtocol*)iface;
|
2005-08-15 12:23:35 +02:00
|
|
|
IUnknown *pUnkOuter = This->pUnkOuter;
|
2005-06-27 11:50:56 +02:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p) ref=%x\n", iface, ref);
|
2005-06-27 11:50:56 +02:00
|
|
|
|
2005-06-30 12:21:58 +02:00
|
|
|
if(!ref) {
|
2006-07-16 23:21:36 +02:00
|
|
|
mshtml_free(This->data);
|
|
|
|
mshtml_free(This);
|
2005-08-02 11:49:06 +02:00
|
|
|
UNLOCK_MODULE();
|
2005-06-30 12:21:58 +02:00
|
|
|
}
|
2005-06-27 11:50:56 +02:00
|
|
|
|
2005-08-15 12:23:35 +02:00
|
|
|
return pUnkOuter ? IUnknown_Release(pUnkOuter) : ref;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
|
|
|
|
IInternetProtocolSink* pOIProtSink, IInternetBindInfo* pOIBindInfo,
|
|
|
|
DWORD grfPI, DWORD dwReserved)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
ResProtocol *This = PROTOCOL_THIS(iface);
|
2005-09-12 22:12:58 +02:00
|
|
|
DWORD grfBINDF = 0, len;
|
2005-06-30 12:21:58 +02:00
|
|
|
BINDINFO bindinfo;
|
2005-09-14 12:06:34 +02:00
|
|
|
LPWSTR url_dll, url_file, url, mime;
|
2005-06-30 12:21:58 +02:00
|
|
|
HMODULE hdll;
|
|
|
|
HRSRC src;
|
2005-09-12 22:12:58 +02:00
|
|
|
HRESULT hres;
|
2005-06-30 12:21:58 +02:00
|
|
|
|
|
|
|
static const WCHAR wszRes[] = {'r','e','s',':','/','/'};
|
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%s %p %p %08x %d)\n", This, debugstr_w(szUrl), pOIProtSink,
|
2005-06-27 11:50:56 +02:00
|
|
|
pOIBindInfo, grfPI, dwReserved);
|
2005-06-30 12:21:58 +02:00
|
|
|
|
|
|
|
memset(&bindinfo, 0, sizeof(bindinfo));
|
|
|
|
bindinfo.cbSize = sizeof(BINDINFO);
|
|
|
|
IInternetBindInfo_GetBindInfo(pOIBindInfo, &grfBINDF, &bindinfo);
|
2005-09-08 20:55:18 +02:00
|
|
|
ReleaseBindInfo(&bindinfo);
|
2005-06-30 12:21:58 +02:00
|
|
|
|
2005-09-12 22:12:58 +02:00
|
|
|
len = strlenW(szUrl)+16;
|
2006-07-16 23:21:36 +02:00
|
|
|
url = mshtml_alloc(len*sizeof(WCHAR));
|
2005-09-12 22:12:58 +02:00
|
|
|
hres = CoInternetParseUrl(szUrl, PARSE_ENCODE, 0, url, len, &len, 0);
|
|
|
|
if(FAILED(hres)) {
|
2006-10-05 23:50:39 +02:00
|
|
|
WARN("CoInternetParseUrl failed: %08x\n", hres);
|
2006-07-16 23:21:36 +02:00
|
|
|
mshtml_free(url);
|
2005-09-12 22:12:58 +02:00
|
|
|
IInternetProtocolSink_ReportResult(pOIProtSink, hres, 0, NULL);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(len < sizeof(wszRes)/sizeof(wszRes[0]) || memcmp(url, wszRes, sizeof(wszRes))) {
|
|
|
|
WARN("Wrong protocol of url: %s\n", debugstr_w(url));
|
2005-06-30 12:21:58 +02:00
|
|
|
IInternetProtocolSink_ReportResult(pOIProtSink, MK_E_SYNTAX, 0, NULL);
|
2006-07-16 23:21:36 +02:00
|
|
|
mshtml_free(url);
|
2005-06-30 12:21:58 +02:00
|
|
|
return MK_E_SYNTAX;
|
|
|
|
}
|
|
|
|
|
2005-09-12 22:12:58 +02:00
|
|
|
url_dll = url + sizeof(wszRes)/sizeof(wszRes[0]);
|
2006-07-26 20:55:35 +02:00
|
|
|
if(!(url_file = strrchrW(url_dll, '/'))) {
|
2005-09-12 22:12:58 +02:00
|
|
|
WARN("wrong url: %s\n", debugstr_w(url));
|
2005-06-30 12:21:58 +02:00
|
|
|
IInternetProtocolSink_ReportResult(pOIProtSink, MK_E_SYNTAX, 0, NULL);
|
2006-07-16 23:21:36 +02:00
|
|
|
mshtml_free(url);
|
2005-06-30 12:21:58 +02:00
|
|
|
return MK_E_SYNTAX;
|
|
|
|
}
|
|
|
|
|
2005-09-12 22:12:58 +02:00
|
|
|
*url_file++ = 0;
|
|
|
|
hdll = LoadLibraryExW(url_dll, NULL, LOAD_LIBRARY_AS_DATAFILE);
|
2005-06-30 12:21:58 +02:00
|
|
|
if(!hdll) {
|
2005-09-12 22:12:58 +02:00
|
|
|
WARN("Could not open dll: %s\n", debugstr_w(url_dll));
|
2005-06-30 12:21:58 +02:00
|
|
|
IInternetProtocolSink_ReportResult(pOIProtSink, HRESULT_FROM_WIN32(GetLastError()), 0, NULL);
|
|
|
|
return HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
}
|
|
|
|
|
2005-09-12 22:12:58 +02:00
|
|
|
src = FindResourceW(hdll, url_file, (LPCWSTR)RT_HTML);
|
2005-06-30 12:21:58 +02:00
|
|
|
if(!src) {
|
2006-07-26 20:55:35 +02:00
|
|
|
LPWSTR endpoint = NULL;
|
|
|
|
DWORD file_id = strtolW(url_file, &endpoint, 10);
|
|
|
|
if(endpoint == url_file+strlenW(url_file))
|
|
|
|
src = FindResourceW(hdll, (LPCWSTR)file_id, (LPCWSTR)RT_HTML);
|
|
|
|
|
|
|
|
if(!src) {
|
|
|
|
WARN("Could not find resource\n");
|
|
|
|
IInternetProtocolSink_ReportResult(pOIProtSink,
|
|
|
|
HRESULT_FROM_WIN32(GetLastError()), 0, NULL);
|
|
|
|
mshtml_free(url);
|
|
|
|
return HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
}
|
2005-06-30 12:21:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(This->data) {
|
|
|
|
WARN("data already loaded\n");
|
2006-07-16 23:21:36 +02:00
|
|
|
mshtml_free(This->data);
|
2005-06-30 12:21:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
This->data_len = SizeofResource(hdll, src);
|
2006-07-16 23:21:36 +02:00
|
|
|
This->data = mshtml_alloc(This->data_len);
|
2005-06-30 12:21:58 +02:00
|
|
|
memcpy(This->data, LoadResource(hdll, src), This->data_len);
|
|
|
|
This->cur = 0;
|
|
|
|
|
|
|
|
FreeLibrary(hdll);
|
|
|
|
|
2005-09-14 12:06:34 +02:00
|
|
|
hres = FindMimeFromData(NULL, url_file, NULL, 0, NULL, 0, &mime, 0);
|
2006-07-16 23:21:36 +02:00
|
|
|
mshtml_free(url);
|
2005-09-14 12:06:34 +02:00
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_MIMETYPEAVAILABLE, mime);
|
|
|
|
CoTaskMemFree(mime);
|
|
|
|
}
|
|
|
|
|
2005-06-30 12:21:58 +02:00
|
|
|
IInternetProtocolSink_ReportData(pOIProtSink,
|
|
|
|
BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION | BSCF_DATAFULLYAVAILABLE,
|
|
|
|
This->data_len, This->data_len);
|
|
|
|
|
|
|
|
IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
|
|
|
|
|
|
|
|
return S_OK;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ResProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA* pProtocolData)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
ResProtocol *This = PROTOCOL_THIS(iface);
|
2005-06-27 11:50:56 +02:00
|
|
|
FIXME("(%p)->(%p)\n", This, pProtocolData);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ResProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
|
|
|
|
DWORD dwOptions)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
ResProtocol *This = PROTOCOL_THIS(iface);
|
2006-10-05 23:50:39 +02:00
|
|
|
FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions);
|
2005-06-27 11:50:56 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ResProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
ResProtocol *This = PROTOCOL_THIS(iface);
|
2005-06-30 12:21:58 +02:00
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%08x)\n", This, dwOptions);
|
2005-06-30 12:21:58 +02:00
|
|
|
|
|
|
|
/* test show that we don't have to do anything here */
|
|
|
|
return S_OK;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ResProtocol_Suspend(IInternetProtocol *iface)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
ResProtocol *This = PROTOCOL_THIS(iface);
|
2005-06-27 11:50:56 +02:00
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ResProtocol_Resume(IInternetProtocol *iface)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
ResProtocol *This = PROTOCOL_THIS(iface);
|
2005-06-27 11:50:56 +02:00
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ResProtocol_Read(IInternetProtocol *iface, void* pv, ULONG cb, ULONG* pcbRead)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
ResProtocol *This = PROTOCOL_THIS(iface);
|
2005-06-30 12:21:58 +02:00
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead);
|
2005-06-30 12:21:58 +02:00
|
|
|
|
|
|
|
if(!This->data)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
*pcbRead = (cb > This->data_len-This->cur ? This->data_len-This->cur : cb);
|
|
|
|
|
|
|
|
if(!*pcbRead)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
memcpy(pv, This->data, *pcbRead);
|
|
|
|
This->cur += *pcbRead;
|
|
|
|
|
|
|
|
return S_OK;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ResProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
|
|
|
|
DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
ResProtocol *This = PROTOCOL_THIS(iface);
|
2006-10-05 23:50:39 +02:00
|
|
|
FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
|
2005-06-27 11:50:56 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ResProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
ResProtocol *This = PROTOCOL_THIS(iface);
|
2005-06-30 12:21:58 +02:00
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%d)\n", This, dwOptions);
|
2005-06-30 12:21:58 +02:00
|
|
|
|
|
|
|
/* test show that we don't have to do anything here */
|
|
|
|
return S_OK;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ResProtocol_UnlockRequest(IInternetProtocol *iface)
|
|
|
|
{
|
2005-08-15 12:23:35 +02:00
|
|
|
ResProtocol *This = PROTOCOL_THIS(iface);
|
2005-06-30 12:21:58 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
/* test show that we don't have to do anything here */
|
|
|
|
return S_OK;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
2005-08-15 12:23:35 +02:00
|
|
|
#undef PROTOCOL_THIS
|
|
|
|
|
2005-06-27 11:50:56 +02:00
|
|
|
static const IInternetProtocolVtbl ResProtocolVtbl = {
|
|
|
|
ResProtocol_QueryInterface,
|
|
|
|
ResProtocol_AddRef,
|
|
|
|
ResProtocol_Release,
|
|
|
|
ResProtocol_Start,
|
|
|
|
ResProtocol_Continue,
|
|
|
|
ResProtocol_Abort,
|
|
|
|
ResProtocol_Terminate,
|
|
|
|
ResProtocol_Suspend,
|
|
|
|
ResProtocol_Resume,
|
|
|
|
ResProtocol_Read,
|
|
|
|
ResProtocol_Seek,
|
|
|
|
ResProtocol_LockRequest,
|
|
|
|
ResProtocol_UnlockRequest
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI ResProtocolFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
ResProtocol *ret;
|
2005-08-15 12:23:35 +02:00
|
|
|
HRESULT hres = S_OK;
|
2005-06-27 11:50:56 +02:00
|
|
|
|
2005-08-11 19:04:45 +02:00
|
|
|
TRACE("(%p)->(%p %s %p)\n", iface, pUnkOuter, debugstr_guid(riid), ppv);
|
2005-06-27 11:50:56 +02:00
|
|
|
|
2006-07-16 23:21:36 +02:00
|
|
|
ret = mshtml_alloc(sizeof(ResProtocol));
|
2005-06-27 11:50:56 +02:00
|
|
|
ret->lpInternetProtocolVtbl = &ResProtocolVtbl;
|
|
|
|
ret->ref = 0;
|
2005-06-30 12:21:58 +02:00
|
|
|
ret->data = NULL;
|
|
|
|
ret->data_len = 0;
|
|
|
|
ret->cur = 0;
|
2005-08-15 12:23:35 +02:00
|
|
|
ret->pUnkOuter = pUnkOuter;
|
2005-06-27 11:50:56 +02:00
|
|
|
|
2005-08-15 12:23:35 +02:00
|
|
|
if(pUnkOuter) {
|
|
|
|
ret->ref = 1;
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid))
|
|
|
|
*ppv = PROTOCOL(ret);
|
|
|
|
else
|
|
|
|
hres = E_FAIL;
|
|
|
|
}else {
|
|
|
|
hres = IInternetProtocol_QueryInterface(PROTOCOL(ret), riid, ppv);
|
|
|
|
}
|
2005-06-27 11:50:56 +02:00
|
|
|
|
2005-08-02 11:49:06 +02:00
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
LOCK_MODULE();
|
|
|
|
else
|
2006-07-16 23:21:36 +02:00
|
|
|
mshtml_free(ret);
|
2005-06-27 11:50:56 +02:00
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ResProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
|
|
|
|
PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
|
|
|
|
DWORD* pcchResult, DWORD dwReserved)
|
|
|
|
{
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("%p)->(%s %d %x %p %d %p %d)\n", iface, debugstr_w(pwzUrl), ParseAction,
|
2005-06-27 11:50:56 +02:00
|
|
|
dwParseFlags, pwzResult, cchResult, pcchResult, dwReserved);
|
2005-09-12 12:10:21 +02:00
|
|
|
|
|
|
|
if(ParseAction == PARSE_SECURITY_URL) {
|
|
|
|
WCHAR *ptr;
|
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
static const WCHAR wszFile[] = {'f','i','l','e',':','/','/'};
|
|
|
|
static const WCHAR wszRes[] = {'r','e','s',':','/','/'};
|
|
|
|
|
|
|
|
if(strlenW(pwzUrl) <= sizeof(wszRes)/sizeof(WCHAR) || memcmp(pwzUrl, wszRes, sizeof(wszRes)))
|
|
|
|
return MK_E_SYNTAX;
|
|
|
|
|
|
|
|
ptr = strchrW(pwzUrl + sizeof(wszRes)/sizeof(WCHAR), '/');
|
|
|
|
if(!ptr)
|
|
|
|
return MK_E_SYNTAX;
|
|
|
|
|
|
|
|
size = ptr-pwzUrl + sizeof(wszFile)/sizeof(WCHAR) - sizeof(wszRes)/sizeof(WCHAR);
|
|
|
|
if(size >= cchResult)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
/* FIXME: return full path */
|
|
|
|
memcpy(pwzResult, wszFile, sizeof(wszFile));
|
|
|
|
memcpy(pwzResult + sizeof(wszFile)/sizeof(WCHAR),
|
|
|
|
pwzUrl + sizeof(wszRes)/sizeof(WCHAR),
|
|
|
|
size*sizeof(WCHAR) - sizeof(wszFile));
|
|
|
|
pwzResult[size] = 0;
|
|
|
|
|
|
|
|
if(pcchResult)
|
|
|
|
*pcchResult = size;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ParseAction == PARSE_DOMAIN) {
|
2006-05-12 18:49:27 +02:00
|
|
|
if(!pcchResult)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
if(pwzUrl)
|
|
|
|
*pcchResult = strlenW(pwzUrl)+1;
|
|
|
|
else
|
|
|
|
*pcchResult = 1;
|
|
|
|
return E_FAIL;
|
2005-09-12 12:10:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return INET_E_DEFAULT_ACTION;
|
2005-06-27 11:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ResProtocolInfo_QueryInfo(IInternetProtocolInfo *iface, LPCWSTR pwzUrl,
|
|
|
|
QUERYOPTION QueryOption, DWORD dwQueryFlags, LPVOID pBuffer, DWORD cbBuffer, DWORD* pcbBuf,
|
|
|
|
DWORD dwReserved)
|
|
|
|
{
|
2006-10-05 23:50:39 +02:00
|
|
|
FIXME("%p)->(%s %08x %08x %p %d %p %d)\n", iface, debugstr_w(pwzUrl), QueryOption, dwQueryFlags, pBuffer,
|
2005-06-27 11:50:56 +02:00
|
|
|
cbBuffer, pcbBuf, dwReserved);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IInternetProtocolInfoVtbl ResProtocolInfoVtbl = {
|
|
|
|
InternetProtocolInfo_QueryInterface,
|
|
|
|
InternetProtocolInfo_AddRef,
|
|
|
|
InternetProtocolInfo_Release,
|
|
|
|
ResProtocolInfo_ParseUrl,
|
2006-08-12 18:43:16 +02:00
|
|
|
InternetProtocolInfo_CombineUrl,
|
2006-12-12 21:52:46 +01:00
|
|
|
InternetProtocolInfo_CompareUrl,
|
2005-06-27 11:50:56 +02:00
|
|
|
ResProtocolInfo_QueryInfo
|
|
|
|
};
|
|
|
|
|
|
|
|
static const IClassFactoryVtbl ResProtocolFactoryVtbl = {
|
|
|
|
ClassFactory_QueryInterface,
|
|
|
|
ClassFactory_AddRef,
|
|
|
|
ClassFactory_Release,
|
|
|
|
ResProtocolFactory_CreateInstance,
|
|
|
|
ClassFactory_LockServer
|
|
|
|
};
|
|
|
|
|
|
|
|
static ProtocolFactory ResProtocolFactory = {
|
|
|
|
&ResProtocolInfoVtbl,
|
|
|
|
&ResProtocolFactoryVtbl
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT ProtocolFactory_Create(REFCLSID rclsid, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
ProtocolFactory *cf = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&CLSID_AboutProtocol, rclsid))
|
|
|
|
cf = &AboutProtocolFactory;
|
|
|
|
else if(IsEqualGUID(&CLSID_ResProtocol, rclsid))
|
|
|
|
cf = &ResProtocolFactory;
|
|
|
|
|
|
|
|
if(!cf) {
|
|
|
|
FIXME("not implemented protocol %s\n", debugstr_guid(rclsid));
|
|
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
|
|
|
}
|
2005-08-02 11:49:06 +02:00
|
|
|
|
2005-06-27 11:50:56 +02:00
|
|
|
return IUnknown_QueryInterface((IUnknown*)cf, riid, ppv);
|
|
|
|
}
|