2005-09-06 11:27:04 +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-09-06 11:27:04 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "urlmon_main.h"
|
2010-09-02 00:25:46 +02:00
|
|
|
#include "winreg.h"
|
|
|
|
#include "shlwapi.h"
|
|
|
|
|
2005-09-06 11:27:04 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
|
|
|
|
|
|
|
|
typedef struct {
|
2019-06-03 21:50:16 +02:00
|
|
|
IUnknown IUnknown_inner;
|
2010-12-06 23:32:39 +01:00
|
|
|
IInternetProtocolEx IInternetProtocolEx_iface;
|
|
|
|
IInternetPriority IInternetPriority_iface;
|
2005-09-06 11:27:04 +02:00
|
|
|
|
2018-05-08 18:18:27 +02:00
|
|
|
IUnknown *outer;
|
|
|
|
|
2005-09-06 11:27:04 +02:00
|
|
|
HANDLE file;
|
2010-09-02 00:24:19 +02:00
|
|
|
ULONG size;
|
2005-11-09 11:58:02 +01:00
|
|
|
LONG priority;
|
2005-09-06 11:27:04 +02:00
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
} FileProtocol;
|
|
|
|
|
2018-05-08 18:18:27 +02:00
|
|
|
static inline FileProtocol *impl_from_IUnknown(IUnknown *iface)
|
|
|
|
{
|
2019-06-03 21:50:16 +02:00
|
|
|
return CONTAINING_RECORD(iface, FileProtocol, IUnknown_inner);
|
2018-05-08 18:18:27 +02:00
|
|
|
}
|
|
|
|
|
2010-12-06 23:32:39 +01:00
|
|
|
static inline FileProtocol *impl_from_IInternetProtocolEx(IInternetProtocolEx *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, FileProtocol, IInternetProtocolEx_iface);
|
|
|
|
}
|
2005-11-09 11:58:02 +01:00
|
|
|
|
2010-12-06 23:32:39 +01:00
|
|
|
static inline FileProtocol *impl_from_IInternetPriority(IInternetPriority *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, FileProtocol, IInternetPriority_iface);
|
|
|
|
}
|
2005-09-06 11:27:04 +02:00
|
|
|
|
2018-05-08 18:18:27 +02:00
|
|
|
static HRESULT WINAPI FileProtocolUnk_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
|
2005-09-06 11:27:04 +02:00
|
|
|
{
|
2018-05-08 18:18:27 +02:00
|
|
|
FileProtocol *This = impl_from_IUnknown(iface);
|
2005-09-06 11:27:04 +02:00
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
2019-06-03 21:50:16 +02:00
|
|
|
*ppv = &This->IUnknown_inner;
|
2005-09-06 11:27:04 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv);
|
2010-12-06 23:32:39 +01:00
|
|
|
*ppv = &This->IInternetProtocolEx_iface;
|
2005-09-06 11:27:04 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv);
|
2010-12-06 23:32:39 +01:00
|
|
|
*ppv = &This->IInternetProtocolEx_iface;
|
2010-09-02 00:25:46 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IInternetProtocolEx, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetProtocolEx %p)\n", This, ppv);
|
2010-12-06 23:32:39 +01:00
|
|
|
*ppv = &This->IInternetProtocolEx_iface;
|
2005-11-09 11:58:02 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IInternetPriority, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetPriority %p)\n", This, ppv);
|
2010-12-06 23:32:39 +01:00
|
|
|
*ppv = &This->IInternetPriority_iface;
|
2005-09-06 11:27:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppv) {
|
2018-05-08 18:18:27 +02:00
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
2005-09-06 11:27:04 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("not supported interface %s\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2018-05-08 18:18:27 +02:00
|
|
|
static ULONG WINAPI FileProtocolUnk_AddRef(IUnknown *iface)
|
2005-09-06 11:27:04 +02:00
|
|
|
{
|
2018-05-08 18:18:27 +02:00
|
|
|
FileProtocol *This = impl_from_IUnknown(iface);
|
2005-09-06 11:27:04 +02:00
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2005-09-06 11:27:04 +02:00
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2018-05-08 18:18:27 +02:00
|
|
|
static ULONG WINAPI FileProtocolUnk_Release(IUnknown *iface)
|
2005-09-06 11:27:04 +02:00
|
|
|
{
|
2018-05-08 18:18:27 +02:00
|
|
|
FileProtocol *This = impl_from_IUnknown(iface);
|
2005-09-06 11:27:04 +02:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2005-09-06 11:27:04 +02:00
|
|
|
|
|
|
|
if(!ref) {
|
2010-09-02 00:23:35 +02:00
|
|
|
if(This->file != INVALID_HANDLE_VALUE)
|
2005-09-06 11:27:04 +02:00
|
|
|
CloseHandle(This->file);
|
2007-11-29 22:12:34 +01:00
|
|
|
heap_free(This);
|
2005-09-06 11:27:04 +02:00
|
|
|
|
|
|
|
URLMON_UnlockModule();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2018-05-08 18:18:27 +02:00
|
|
|
static const IUnknownVtbl FileProtocolUnkVtbl = {
|
|
|
|
FileProtocolUnk_QueryInterface,
|
|
|
|
FileProtocolUnk_AddRef,
|
|
|
|
FileProtocolUnk_Release
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI FileProtocol_QueryInterface(IInternetProtocolEx *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
FileProtocol *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 FileProtocol_AddRef(IInternetProtocolEx *iface)
|
|
|
|
{
|
|
|
|
FileProtocol *This = impl_from_IInternetProtocolEx(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return IUnknown_AddRef(This->outer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI FileProtocol_Release(IInternetProtocolEx *iface)
|
|
|
|
{
|
|
|
|
FileProtocol *This = impl_from_IInternetProtocolEx(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return IUnknown_Release(This->outer);
|
|
|
|
}
|
|
|
|
|
2010-09-02 00:25:46 +02:00
|
|
|
static HRESULT WINAPI FileProtocol_Start(IInternetProtocolEx *iface, LPCWSTR szUrl,
|
2005-09-06 11:27:04 +02:00
|
|
|
IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
|
2009-04-01 03:42:37 +02:00
|
|
|
DWORD grfPI, HANDLE_PTR dwReserved)
|
2005-09-06 11:27:04 +02:00
|
|
|
{
|
2010-12-06 23:32:39 +01:00
|
|
|
FileProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2010-09-02 00:26:39 +02:00
|
|
|
IUri *uri;
|
2005-09-12 13:11:11 +02:00
|
|
|
HRESULT hres;
|
2005-09-06 11:27:04 +02:00
|
|
|
|
2009-04-01 03:42:37 +02:00
|
|
|
TRACE("(%p)->(%s %p %p %08x %lx)\n", This, debugstr_w(szUrl), pOIProtSink,
|
2005-09-06 11:27:04 +02:00
|
|
|
pOIBindInfo, grfPI, dwReserved);
|
|
|
|
|
2010-09-02 00:26:39 +02:00
|
|
|
hres = CreateUri(szUrl, Uri_CREATE_FILE_USE_DOS_PATH, 0, &uri);
|
|
|
|
if(FAILED(hres))
|
2005-09-12 13:11:11 +02:00
|
|
|
return hres;
|
2010-04-20 13:31:29 +02:00
|
|
|
|
2010-12-06 23:32:39 +01:00
|
|
|
hres = IInternetProtocolEx_StartEx(&This->IInternetProtocolEx_iface, uri, pOIProtSink,
|
|
|
|
pOIBindInfo, grfPI, (HANDLE*)dwReserved);
|
2005-12-19 09:52:30 +01:00
|
|
|
|
2010-09-02 00:26:39 +02:00
|
|
|
IUri_Release(uri);
|
|
|
|
return hres;
|
2005-09-06 11:27:04 +02:00
|
|
|
}
|
|
|
|
|
2010-09-02 00:25:46 +02:00
|
|
|
static HRESULT WINAPI FileProtocol_Continue(IInternetProtocolEx *iface, PROTOCOLDATA *pProtocolData)
|
2005-09-06 11:27:04 +02:00
|
|
|
{
|
2010-12-06 23:32:39 +01:00
|
|
|
FileProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2005-09-06 11:27:04 +02:00
|
|
|
FIXME("(%p)->(%p)\n", This, pProtocolData);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2010-09-02 00:25:46 +02:00
|
|
|
static HRESULT WINAPI FileProtocol_Abort(IInternetProtocolEx *iface, HRESULT hrReason,
|
2005-09-06 11:27:04 +02:00
|
|
|
DWORD dwOptions)
|
|
|
|
{
|
2010-12-06 23:32:39 +01:00
|
|
|
FileProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2006-10-05 23:49:11 +02:00
|
|
|
FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions);
|
2005-09-06 11:27:04 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2010-09-02 00:25:46 +02:00
|
|
|
static HRESULT WINAPI FileProtocol_Terminate(IInternetProtocolEx *iface, DWORD dwOptions)
|
2005-09-06 11:27:04 +02:00
|
|
|
{
|
2010-12-06 23:32:39 +01:00
|
|
|
FileProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2005-09-06 11:27:04 +02:00
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p)->(%08x)\n", This, dwOptions);
|
2005-09-06 11:27:04 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-09-02 00:25:46 +02:00
|
|
|
static HRESULT WINAPI FileProtocol_Suspend(IInternetProtocolEx *iface)
|
2005-09-06 11:27:04 +02:00
|
|
|
{
|
2010-12-06 23:32:39 +01:00
|
|
|
FileProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2005-09-06 11:27:04 +02:00
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2010-09-02 00:25:46 +02:00
|
|
|
static HRESULT WINAPI FileProtocol_Resume(IInternetProtocolEx *iface)
|
2005-09-06 11:27:04 +02:00
|
|
|
{
|
2010-12-06 23:32:39 +01:00
|
|
|
FileProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2005-09-06 11:27:04 +02:00
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2010-09-02 00:25:46 +02:00
|
|
|
static HRESULT WINAPI FileProtocol_Read(IInternetProtocolEx *iface, void *pv,
|
2005-09-06 11:27:04 +02:00
|
|
|
ULONG cb, ULONG *pcbRead)
|
|
|
|
{
|
2010-12-06 23:32:39 +01:00
|
|
|
FileProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2005-09-06 11:27:04 +02:00
|
|
|
DWORD read = 0;
|
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead);
|
2005-09-06 11:27:04 +02:00
|
|
|
|
2008-02-15 11:09:25 +01:00
|
|
|
if (pcbRead)
|
|
|
|
*pcbRead = 0;
|
|
|
|
|
2010-09-02 00:23:35 +02:00
|
|
|
if(This->file == INVALID_HANDLE_VALUE)
|
2005-09-06 11:27:04 +02:00
|
|
|
return INET_E_DATA_NOT_AVAILABLE;
|
|
|
|
|
2008-02-15 11:09:25 +01:00
|
|
|
if (!ReadFile(This->file, pv, cb, &read, NULL))
|
|
|
|
return INET_E_DOWNLOAD_FAILURE;
|
2005-09-06 11:27:04 +02:00
|
|
|
|
|
|
|
if(pcbRead)
|
|
|
|
*pcbRead = read;
|
|
|
|
|
|
|
|
return cb == read ? S_OK : S_FALSE;
|
|
|
|
}
|
|
|
|
|
2010-09-02 00:25:46 +02:00
|
|
|
static HRESULT WINAPI FileProtocol_Seek(IInternetProtocolEx *iface, LARGE_INTEGER dlibMove,
|
2006-10-03 14:11:42 +02:00
|
|
|
DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
|
2005-09-06 11:27:04 +02:00
|
|
|
{
|
2010-12-06 23:32:39 +01:00
|
|
|
FileProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2006-10-05 23:49:11 +02:00
|
|
|
FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
|
2005-09-06 11:27:04 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2010-09-02 00:25:46 +02:00
|
|
|
static HRESULT WINAPI FileProtocol_LockRequest(IInternetProtocolEx *iface, DWORD dwOptions)
|
2005-09-06 11:27:04 +02:00
|
|
|
{
|
2010-12-06 23:32:39 +01:00
|
|
|
FileProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2005-09-06 11:27:04 +02:00
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p)->(%08x)\n", This, dwOptions);
|
2005-09-06 11:27:04 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-09-02 00:25:46 +02:00
|
|
|
static HRESULT WINAPI FileProtocol_UnlockRequest(IInternetProtocolEx *iface)
|
2005-09-06 11:27:04 +02:00
|
|
|
{
|
2010-12-06 23:32:39 +01:00
|
|
|
FileProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2005-09-06 11:27:04 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-09-02 00:25:46 +02:00
|
|
|
static inline HRESULT report_result(IInternetProtocolSink *protocol_sink, HRESULT hres, DWORD res)
|
|
|
|
{
|
|
|
|
IInternetProtocolSink_ReportResult(protocol_sink, hres, res, NULL);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI FileProtocol_StartEx(IInternetProtocolEx *iface, IUri *pUri,
|
|
|
|
IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
|
|
|
|
DWORD grfPI, HANDLE *dwReserved)
|
|
|
|
{
|
2010-12-06 23:32:39 +01:00
|
|
|
FileProtocol *This = impl_from_IInternetProtocolEx(iface);
|
2015-05-19 16:36:48 +02:00
|
|
|
WCHAR path[MAX_PATH], *ptr;
|
|
|
|
LARGE_INTEGER file_size;
|
|
|
|
HANDLE file_handle;
|
2010-09-02 00:25:46 +02:00
|
|
|
BINDINFO bindinfo;
|
|
|
|
DWORD grfBINDF = 0;
|
2011-06-25 19:04:16 +02:00
|
|
|
DWORD scheme, size;
|
2010-09-02 00:25:46 +02:00
|
|
|
LPWSTR mime = NULL;
|
|
|
|
WCHAR null_char = 0;
|
2014-12-23 12:02:12 +01:00
|
|
|
BSTR ext;
|
2010-09-02 00:25:46 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p %p %08x %p)\n", This, pUri, pOIProtSink,
|
|
|
|
pOIBindInfo, grfPI, dwReserved);
|
|
|
|
|
|
|
|
if(!pUri)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
scheme = 0;
|
|
|
|
hres = IUri_GetScheme(pUri, &scheme);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
if(scheme != URL_SCHEME_FILE)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
memset(&bindinfo, 0, sizeof(bindinfo));
|
|
|
|
bindinfo.cbSize = sizeof(BINDINFO);
|
|
|
|
hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &grfBINDF, &bindinfo);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("GetBindInfo failed: %08x\n", hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReleaseBindInfo(&bindinfo);
|
|
|
|
|
|
|
|
if(!(grfBINDF & BINDF_FROMURLMON))
|
|
|
|
IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_DIRECTBIND, NULL);
|
|
|
|
|
|
|
|
if(This->file != INVALID_HANDLE_VALUE) {
|
|
|
|
IInternetProtocolSink_ReportData(pOIProtSink,
|
|
|
|
BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION,
|
|
|
|
This->size, This->size);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_SENDINGREQUEST, &null_char);
|
|
|
|
|
2011-06-25 19:04:16 +02:00
|
|
|
size = 0;
|
2018-07-05 17:22:32 +02:00
|
|
|
hres = CoInternetParseIUri(pUri, PARSE_PATH_FROM_URL, 0, path, ARRAY_SIZE(path), &size, 0);
|
2010-09-02 00:25:46 +02:00
|
|
|
if(FAILED(hres)) {
|
2011-06-25 19:04:16 +02:00
|
|
|
WARN("CoInternetParseIUri failed: %08x\n", hres);
|
2010-09-02 00:25:46 +02:00
|
|
|
return report_result(pOIProtSink, hres, 0);
|
|
|
|
}
|
|
|
|
|
2015-05-19 16:36:48 +02:00
|
|
|
file_handle = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, NULL,
|
|
|
|
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
2019-06-24 10:15:45 +02:00
|
|
|
if(file_handle == INVALID_HANDLE_VALUE && (ptr = wcsrchr(path, '#'))) {
|
2015-05-19 16:36:48 +02:00
|
|
|
/* If path contains fragment part, try without it. */
|
|
|
|
*ptr = 0;
|
|
|
|
file_handle = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, NULL,
|
|
|
|
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
}
|
|
|
|
if(file_handle == INVALID_HANDLE_VALUE)
|
|
|
|
return report_result(pOIProtSink, INET_E_RESOURCE_NOT_FOUND, GetLastError());
|
|
|
|
|
|
|
|
if(!GetFileSizeEx(file_handle, &file_size)) {
|
|
|
|
CloseHandle(file_handle);
|
|
|
|
return report_result(pOIProtSink, INET_E_RESOURCE_NOT_FOUND, GetLastError());
|
|
|
|
}
|
|
|
|
|
|
|
|
This->file = file_handle;
|
|
|
|
This->size = file_size.u.LowPart;
|
|
|
|
IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_CACHEFILENAMEAVAILABLE, path);
|
2010-09-02 00:25:46 +02:00
|
|
|
|
2014-12-23 12:02:12 +01:00
|
|
|
hres = IUri_GetExtension(pUri, &ext);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
if(hres == S_OK && *ext) {
|
2019-06-24 10:15:45 +02:00
|
|
|
if((ptr = wcschr(ext, '#')))
|
2015-05-19 16:36:48 +02:00
|
|
|
*ptr = 0;
|
2014-12-23 12:02:12 +01:00
|
|
|
hres = find_mime_from_ext(ext, &mime);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
IInternetProtocolSink_ReportProgress(pOIProtSink,
|
|
|
|
(grfBINDF & BINDF_FROMURLMON) ?
|
|
|
|
BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE : BINDSTATUS_MIMETYPEAVAILABLE,
|
|
|
|
mime);
|
|
|
|
CoTaskMemFree(mime);
|
|
|
|
}
|
2010-09-02 00:25:46 +02:00
|
|
|
}
|
2014-12-23 12:02:12 +01:00
|
|
|
SysFreeString(ext);
|
2010-09-02 00:25:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
IInternetProtocolSink_ReportData(pOIProtSink,
|
|
|
|
BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION,
|
|
|
|
This->size, This->size);
|
|
|
|
|
|
|
|
return report_result(pOIProtSink, S_OK, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IInternetProtocolExVtbl FileProtocolExVtbl = {
|
2005-09-06 11:27:04 +02:00
|
|
|
FileProtocol_QueryInterface,
|
|
|
|
FileProtocol_AddRef,
|
|
|
|
FileProtocol_Release,
|
|
|
|
FileProtocol_Start,
|
|
|
|
FileProtocol_Continue,
|
|
|
|
FileProtocol_Abort,
|
|
|
|
FileProtocol_Terminate,
|
|
|
|
FileProtocol_Suspend,
|
|
|
|
FileProtocol_Resume,
|
|
|
|
FileProtocol_Read,
|
|
|
|
FileProtocol_Seek,
|
|
|
|
FileProtocol_LockRequest,
|
2010-09-02 00:25:46 +02:00
|
|
|
FileProtocol_UnlockRequest,
|
|
|
|
FileProtocol_StartEx
|
2005-09-06 11:27:04 +02:00
|
|
|
};
|
|
|
|
|
2005-11-09 11:58:02 +01:00
|
|
|
static HRESULT WINAPI FilePriority_QueryInterface(IInternetPriority *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2010-12-06 23:32:39 +01:00
|
|
|
FileProtocol *This = impl_from_IInternetPriority(iface);
|
|
|
|
return IInternetProtocolEx_QueryInterface(&This->IInternetProtocolEx_iface, riid, ppv);
|
2005-11-09 11:58:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI FilePriority_AddRef(IInternetPriority *iface)
|
|
|
|
{
|
2010-12-06 23:32:39 +01:00
|
|
|
FileProtocol *This = impl_from_IInternetPriority(iface);
|
|
|
|
return IInternetProtocolEx_AddRef(&This->IInternetProtocolEx_iface);
|
2005-11-09 11:58:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI FilePriority_Release(IInternetPriority *iface)
|
|
|
|
{
|
2010-12-06 23:32:39 +01:00
|
|
|
FileProtocol *This = impl_from_IInternetPriority(iface);
|
|
|
|
return IInternetProtocolEx_Release(&This->IInternetProtocolEx_iface);
|
2005-11-09 11:58:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI FilePriority_SetPriority(IInternetPriority *iface, LONG nPriority)
|
|
|
|
{
|
2010-12-06 23:32:39 +01:00
|
|
|
FileProtocol *This = impl_from_IInternetPriority(iface);
|
2005-11-09 11:58:02 +01:00
|
|
|
|
2006-10-05 23:49:11 +02:00
|
|
|
TRACE("(%p)->(%d)\n", This, nPriority);
|
2005-11-09 11:58:02 +01:00
|
|
|
|
|
|
|
This->priority = nPriority;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI FilePriority_GetPriority(IInternetPriority *iface, LONG *pnPriority)
|
|
|
|
{
|
2010-12-06 23:32:39 +01:00
|
|
|
FileProtocol *This = impl_from_IInternetPriority(iface);
|
2005-11-09 11:58:02 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pnPriority);
|
|
|
|
|
|
|
|
*pnPriority = This->priority;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IInternetPriorityVtbl FilePriorityVtbl = {
|
|
|
|
FilePriority_QueryInterface,
|
|
|
|
FilePriority_AddRef,
|
|
|
|
FilePriority_Release,
|
|
|
|
FilePriority_SetPriority,
|
|
|
|
FilePriority_GetPriority
|
|
|
|
};
|
|
|
|
|
2018-05-08 18:18:27 +02:00
|
|
|
HRESULT FileProtocol_Construct(IUnknown *outer, LPVOID *ppobj)
|
2005-09-06 11:27:04 +02:00
|
|
|
{
|
|
|
|
FileProtocol *ret;
|
|
|
|
|
2018-05-08 18:18:27 +02:00
|
|
|
TRACE("(%p %p)\n", outer, ppobj);
|
2005-09-06 11:27:04 +02:00
|
|
|
|
|
|
|
URLMON_LockModule();
|
|
|
|
|
2007-11-29 22:12:34 +01:00
|
|
|
ret = heap_alloc(sizeof(FileProtocol));
|
2005-09-06 11:27:04 +02:00
|
|
|
|
2019-06-03 21:50:16 +02:00
|
|
|
ret->IUnknown_inner.lpVtbl = &FileProtocolUnkVtbl;
|
2010-12-06 23:32:39 +01:00
|
|
|
ret->IInternetProtocolEx_iface.lpVtbl = &FileProtocolExVtbl;
|
|
|
|
ret->IInternetPriority_iface.lpVtbl = &FilePriorityVtbl;
|
2010-09-02 00:23:35 +02:00
|
|
|
ret->file = INVALID_HANDLE_VALUE;
|
2005-11-09 11:58:02 +01:00
|
|
|
ret->priority = 0;
|
2005-09-06 11:27:04 +02:00
|
|
|
ret->ref = 1;
|
2019-06-03 21:50:16 +02:00
|
|
|
ret->outer = outer ? outer : &ret->IUnknown_inner;
|
2005-09-06 11:27:04 +02:00
|
|
|
|
2019-06-03 21:50:16 +02:00
|
|
|
*ppobj = &ret->IUnknown_inner;
|
2005-09-06 11:27:04 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|