Commit 96a34b58 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

urlmon: Get rid of URLMonikerImpl_BindToStorage_hack.

parent 0da20926
......@@ -30,342 +30,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
static const IStreamVtbl stvt;
HRESULT UMCreateStreamOnCacheFile(LPCWSTR pszURL,
DWORD dwSize,
LPWSTR pszFileName,
HANDLE *phfile,
IUMCacheStream **ppstr)
{
IUMCacheStream* ucstr;
HANDLE handle;
DWORD size;
LPWSTR url, c, ext = NULL;
HRESULT hr;
size = (strlenW(pszURL)+1)*sizeof(WCHAR);
url = heap_alloc(size);
memcpy(url, pszURL, size);
for (c = url; *c && *c != '#' && *c != '?'; ++c)
{
if (*c == '.')
ext = c+1;
else if(*c == '/')
ext = NULL;
}
*c = 0;
if(!CreateUrlCacheEntryW(url, dwSize, ext, pszFileName, 0))
hr = HRESULT_FROM_WIN32(GetLastError());
else
hr = S_OK;
heap_free(url);
if (hr != S_OK)
return hr;
TRACE("Opening %s\n", debugstr_w(pszFileName) );
handle = CreateFileW( pszFileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, 0, NULL );
if( handle == INVALID_HANDLE_VALUE )
return HRESULT_FROM_WIN32(GetLastError());
if (phfile)
{
/* Call CreateFileW again because we need a handle with its own file pointer, and DuplicateHandle will return
* a handle that shares its file pointer with the original.
*/
*phfile = CreateFileW( pszFileName, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL );
if (*phfile == (HANDLE) HFILE_ERROR)
{
DWORD dwError = GetLastError();
CloseHandle(handle);
return HRESULT_FROM_WIN32(dwError);
}
}
ucstr = heap_alloc_zero(sizeof(IUMCacheStream));
if(ucstr)
{
ucstr->pszURL = heap_alloc_zero(sizeof(WCHAR) * (lstrlenW(pszURL) + 1));
if (ucstr->pszURL)
{
ucstr->pszFileName = heap_alloc_zero(sizeof(WCHAR) * (lstrlenW(pszFileName) + 1));
if (ucstr->pszFileName)
{
ucstr->lpVtbl=&stvt;
ucstr->ref = 1;
ucstr->handle = handle;
ucstr->closed = 0;
lstrcpyW(ucstr->pszURL, pszURL);
lstrcpyW(ucstr->pszFileName, pszFileName);
*ppstr = ucstr;
return S_OK;
}
heap_free(ucstr->pszURL);
}
heap_free(ucstr);
}
CloseHandle(handle);
if (phfile)
CloseHandle(*phfile);
return E_OUTOFMEMORY;
}
void UMCloseCacheFileStream(IUMCacheStream *This)
{
if (!This->closed)
{
FILETIME ftZero;
ftZero.dwLowDateTime = ftZero.dwHighDateTime = 0;
This->closed = 1;
CommitUrlCacheEntryW(This->pszURL,
This->pszFileName,
ftZero,
ftZero,
NORMAL_CACHE_ENTRY,
0,
0,
0,
0);
}
}
/**************************************************************************
* IStream_fnQueryInterface
*/
static HRESULT WINAPI IStream_fnQueryInterface(IStream *iface,
REFIID riid,
LPVOID *ppvObj)
{
IUMCacheStream *This = (IUMCacheStream *)iface;
TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
*ppvObj = NULL;
if(IsEqualIID(riid, &IID_IUnknown) ||
IsEqualIID(riid, &IID_IStream))
{
*ppvObj = This;
}
if(*ppvObj)
{
IStream_AddRef((IStream*)*ppvObj);
TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
return S_OK;
}
TRACE("-- Interface: E_NOINTERFACE\n");
return E_NOINTERFACE;
}
/**************************************************************************
* IStream_fnAddRef
*/
static ULONG WINAPI IStream_fnAddRef(IStream *iface)
{
IUMCacheStream *This = (IUMCacheStream *)iface;
ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p)->(count=%u)\n", This, refCount - 1);
return refCount;
}
/**************************************************************************
* IStream_fnRelease
*/
static ULONG WINAPI IStream_fnRelease(IStream *iface)
{
IUMCacheStream *This = (IUMCacheStream *)iface;
ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p)->(count=%u)\n", This, refCount + 1);
if (!refCount)
{
TRACE(" destroying UMCacheStream (%p)\n",This);
UMCloseCacheFileStream(This);
CloseHandle(This->handle);
heap_free(This->pszFileName);
heap_free(This->pszURL);
heap_free(This);
}
return refCount;
}
static HRESULT WINAPI IStream_fnRead (IStream * iface,
void* pv,
ULONG cb,
ULONG* pcbRead)
{
ULONG dwBytesRead;
IUMCacheStream *This = (IUMCacheStream *)iface;
TRACE("(%p)->(%p,0x%08x,%p)\n",This, pv, cb, pcbRead);
if ( !pv )
return STG_E_INVALIDPOINTER;
if ( !pcbRead)
pcbRead = &dwBytesRead;
if ( ! ReadFile( This->handle, pv, cb, pcbRead, NULL ) )
return S_FALSE;
if (!*pcbRead)
return This->closed ? S_FALSE : E_PENDING;
return S_OK;
}
static HRESULT WINAPI IStream_fnWrite (IStream * iface,
const void* pv,
ULONG cb,
ULONG* pcbWritten)
{
return E_NOTIMPL;
}
static HRESULT WINAPI IStream_fnSeek (IStream * iface,
LARGE_INTEGER dlibMove,
DWORD dwOrigin,
ULARGE_INTEGER* plibNewPosition)
{
LARGE_INTEGER newpos;
IUMCacheStream *This = (IUMCacheStream *)iface;
TRACE("(%p)\n",This);
if (!SetFilePointerEx( This->handle, dlibMove, &newpos, dwOrigin ))
return E_FAIL;
if (plibNewPosition)
plibNewPosition->QuadPart = newpos.QuadPart;
return S_OK;
}
static HRESULT WINAPI IStream_fnSetSize (IStream * iface,
ULARGE_INTEGER libNewSize)
{
LARGE_INTEGER newpos;
IUMCacheStream *This = (IUMCacheStream *)iface;
TRACE("(%p)\n",This);
newpos.QuadPart = libNewSize.QuadPart;
if( ! SetFilePointerEx( This->handle, newpos, NULL, FILE_BEGIN ) )
return E_FAIL;
if( ! SetEndOfFile( This->handle ) )
return E_FAIL;
return S_OK;
}
static HRESULT WINAPI IStream_fnCopyTo (IStream * iface,
IStream* pstm,
ULARGE_INTEGER cb,
ULARGE_INTEGER* pcbRead,
ULARGE_INTEGER* pcbWritten)
{
IUMCacheStream *This = (IUMCacheStream *)iface;
TRACE("(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI IStream_fnCommit (IStream * iface,
DWORD grfCommitFlags)
{
IUMCacheStream *This = (IUMCacheStream *)iface;
TRACE("(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI IStream_fnRevert (IStream * iface)
{
IUMCacheStream *This = (IUMCacheStream *)iface;
TRACE("(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI IStream_fnLockRegion (IStream * iface,
ULARGE_INTEGER libOffset,
ULARGE_INTEGER cb,
DWORD dwLockType)
{
IUMCacheStream *This = (IUMCacheStream *)iface;
TRACE("(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI IStream_fnUnlockRegion (IStream * iface,
ULARGE_INTEGER libOffset,
ULARGE_INTEGER cb,
DWORD dwLockType)
{
IUMCacheStream *This = (IUMCacheStream *)iface;
TRACE("(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI IStream_fnStat (IStream * iface,
STATSTG* pstatstg,
DWORD grfStatFlag)
{
IUMCacheStream *This = (IUMCacheStream *)iface;
TRACE("(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI IStream_fnClone (IStream * iface,
IStream** ppstm)
{
IUMCacheStream *This = (IUMCacheStream *)iface;
TRACE("(%p)\n",This);
return E_NOTIMPL;
}
static const IStreamVtbl stvt =
{
IStream_fnQueryInterface,
IStream_fnAddRef,
IStream_fnRelease,
IStream_fnRead,
IStream_fnWrite,
IStream_fnSeek,
IStream_fnSetSize,
IStream_fnCopyTo,
IStream_fnCommit,
IStream_fnRevert,
IStream_fnLockRegion,
IStream_fnUnlockRegion,
IStream_fnStat,
IStream_fnClone
};
typedef struct ProxyBindStatusCallback
{
const IBindStatusCallbackVtbl *lpVtbl;
......
......@@ -56,19 +56,6 @@ static inline void URLMON_UnlockModule(void) { InterlockedDecrement( &URLMON_ref
#define DEFINE_THIS2(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,ifc)))
#define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface)
typedef struct
{
const IStreamVtbl *lpVtbl;
LONG ref;
HANDLE handle;
BOOL closed;
WCHAR *pszFileName;
WCHAR *pszURL;
} IUMCacheStream;
HRESULT UMCreateStreamOnCacheFile(LPCWSTR pszURL, DWORD dwSize, LPWSTR pszFileName, HANDLE *phfile, IUMCacheStream **ppstr);
void UMCloseCacheFileStream(IUMCacheStream *pstr);
IInternetProtocolInfo *get_protocol_info(LPCWSTR url);
HRESULT get_protocol_handler(LPCWSTR url, CLSID *clsid, IClassFactory **ret);
BOOL is_registered_protocol(LPCWSTR);
......
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