2000-04-11 22:07:00 +02:00
|
|
|
/*
|
|
|
|
* UrlMon
|
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* Copyright 1999 Ulrich Czekalla for Corel Corporation
|
2002-08-13 20:20:24 +02:00
|
|
|
* Copyright 2002 Huw D M Davies for CodeWeavers
|
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2000-04-11 22:07:00 +02:00
|
|
|
*/
|
|
|
|
|
2003-01-03 20:12:55 +01:00
|
|
|
#define COM_NO_WINDOWS_H
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2002-08-13 20:20:24 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
2003-01-07 21:36:20 +01:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2004-10-07 05:06:48 +02:00
|
|
|
|
2000-11-30 02:31:28 +01:00
|
|
|
#include "windef.h"
|
2002-08-13 20:20:24 +02:00
|
|
|
#include "winbase.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winreg.h"
|
2003-07-15 22:47:17 +02:00
|
|
|
#include "winternl.h"
|
2002-08-13 20:20:24 +02:00
|
|
|
#include "winuser.h"
|
2000-04-11 22:07:00 +02:00
|
|
|
#include "objbase.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2002-08-13 20:20:24 +02:00
|
|
|
#include "wine/unicode.h"
|
|
|
|
#include "ole2.h"
|
2000-04-11 22:07:00 +02:00
|
|
|
#include "urlmon.h"
|
2002-08-13 20:20:24 +02:00
|
|
|
#include "wininet.h"
|
2004-05-03 22:07:03 +02:00
|
|
|
#include "shlwapi.h"
|
2002-08-13 20:20:24 +02:00
|
|
|
#include "urlmon_main.h"
|
2000-04-11 22:07:00 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
|
2001-05-31 23:38:38 +02:00
|
|
|
|
|
|
|
/* native urlmon.dll uses this key, too */
|
2004-04-20 02:34:52 +02:00
|
|
|
static const WCHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
|
2000-04-11 22:07:00 +02:00
|
|
|
|
2002-08-13 20:20:24 +02:00
|
|
|
/*static BOOL registered_wndclass = FALSE;*/
|
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
typedef struct {
|
2005-06-06 21:50:35 +02:00
|
|
|
const IBindingVtbl *lpVtbl;
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2005-07-03 14:05:03 +02:00
|
|
|
LONG ref;
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
LPWSTR URLName;
|
2002-08-13 20:20:24 +02:00
|
|
|
|
|
|
|
HWND hwndCallback;
|
|
|
|
IBindCtx *pBC;
|
|
|
|
HINTERNET hinternet, hconnect, hrequest;
|
2005-05-04 12:36:54 +02:00
|
|
|
HANDLE hCacheFile;
|
|
|
|
IUMCacheStream *pstrCache;
|
|
|
|
IBindStatusCallback *pbscb;
|
|
|
|
DWORD total_read, expected_size;
|
2005-05-23 11:53:21 +02:00
|
|
|
} Binding;
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
static HRESULT WINAPI Binding_QueryInterface(IBinding* iface, REFIID riid, void **ppvObject)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
2005-05-23 11:53:21 +02:00
|
|
|
Binding *This = (Binding*)iface;
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppvObject);
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
if((This == NULL) || (ppvObject == NULL))
|
2002-08-13 20:20:24 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
if (IsEqualIID(&IID_IUnknown, riid) || IsEqualIID(&IID_IBinding, riid)) {
|
2002-08-13 20:20:24 +02:00
|
|
|
*ppvObject = iface;
|
2005-05-23 11:53:21 +02:00
|
|
|
IBinding_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
*ppvObject = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
static ULONG WINAPI Binding_AddRef(IBinding* iface)
|
|
|
|
{
|
|
|
|
Binding *This = (Binding*)iface;
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
TRACE("(%p) ref=%ld\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
2002-08-13 20:20:24 +02:00
|
|
|
}
|
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
static ULONG WINAPI Binding_Release(IBinding* iface)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
2005-05-23 11:53:21 +02:00
|
|
|
Binding *This = (Binding*)iface;
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%ld\n",This, ref);
|
|
|
|
|
|
|
|
if(!ref) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->URLName);
|
|
|
|
if (This->hCacheFile)
|
|
|
|
CloseHandle(This->hCacheFile);
|
|
|
|
if (This->pstrCache)
|
|
|
|
{
|
|
|
|
UMCloseCacheFileStream(This->pstrCache);
|
|
|
|
IStream_Release((IStream *)This->pstrCache);
|
|
|
|
}
|
|
|
|
if (This->pbscb)
|
|
|
|
IBindStatusCallback_Release(This->pbscb);
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
URLMON_UnlockModule();
|
|
|
|
}
|
2005-02-03 20:38:37 +01:00
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
return ref;
|
2002-08-13 20:20:24 +02:00
|
|
|
}
|
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
static HRESULT WINAPI Binding_Abort(IBinding* iface)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
2005-05-23 11:53:21 +02:00
|
|
|
Binding *This = (Binding*)iface;
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
FIXME("(%p): stub\n", This);
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
static HRESULT WINAPI Binding_GetBindResult(IBinding* iface, CLSID* pclsidProtocol, DWORD* pdwResult, LPOLESTR* pszResult, DWORD* pdwReserved)
|
|
|
|
{
|
|
|
|
Binding *This = (Binding*)iface;
|
2005-02-03 20:38:37 +01:00
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
FIXME("(%p)->(%p, %p, %p, %p): stub\n", This, pclsidProtocol, pdwResult, pszResult, pdwReserved);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Binding_GetPriority(IBinding* iface, LONG* pnPriority)
|
|
|
|
{
|
|
|
|
Binding *This = (Binding*)iface;
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p): stub\n", This, pnPriority);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Binding_Resume(IBinding* iface)
|
|
|
|
{
|
|
|
|
Binding *This = (Binding*)iface;
|
|
|
|
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
2002-08-13 20:20:24 +02:00
|
|
|
}
|
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
static HRESULT WINAPI Binding_SetPriority(IBinding* iface, LONG nPriority)
|
|
|
|
{
|
|
|
|
Binding *This = (Binding*)iface;
|
|
|
|
|
|
|
|
FIXME("(%p)->(%ld): stub\n", This, nPriority);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Binding_Suspend(IBinding* iface)
|
|
|
|
{
|
|
|
|
Binding *This = (Binding*)iface;
|
|
|
|
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Binding_CloseCacheDownload(Binding *This)
|
2005-05-04 12:36:54 +02:00
|
|
|
{
|
|
|
|
CloseHandle(This->hCacheFile);
|
|
|
|
This->hCacheFile = 0;
|
|
|
|
UMCloseCacheFileStream(This->pstrCache);
|
|
|
|
IStream_Release((IStream *)This->pstrCache);
|
|
|
|
This->pstrCache = 0;
|
|
|
|
}
|
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
static HRESULT Binding_MoreCacheData(Binding *This, char *buf, DWORD dwBytes)
|
2005-05-04 12:36:54 +02:00
|
|
|
{
|
|
|
|
DWORD written;
|
|
|
|
|
|
|
|
if (WriteFile(This->hCacheFile, buf, dwBytes, &written, NULL) && written == dwBytes)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
This->total_read += written;
|
|
|
|
hr = IBindStatusCallback_OnProgress(This->pbscb,
|
|
|
|
This->total_read + written,
|
|
|
|
This->expected_size,
|
|
|
|
(This->total_read == written) ?
|
|
|
|
BINDSTATUS_BEGINDOWNLOADDATA :
|
|
|
|
BINDSTATUS_DOWNLOADINGDATA,
|
|
|
|
NULL);
|
|
|
|
if (!hr)
|
|
|
|
{
|
|
|
|
STGMEDIUM stg;
|
|
|
|
FORMATETC fmt;
|
|
|
|
|
|
|
|
fmt.cfFormat = 0;
|
|
|
|
fmt.ptd = NULL;
|
|
|
|
fmt.dwAspect = 0;
|
|
|
|
fmt.lindex = -1;
|
|
|
|
fmt.tymed = TYMED_ISTREAM;
|
|
|
|
|
|
|
|
stg.tymed = TYMED_ISTREAM;
|
|
|
|
stg.u.pstm = (IStream *)This->pstrCache;
|
|
|
|
stg.pUnkForRelease = NULL;
|
|
|
|
|
|
|
|
hr = IBindStatusCallback_OnDataAvailable(This->pbscb,
|
|
|
|
(This->total_read == written) ?
|
|
|
|
BSCF_FIRSTDATANOTIFICATION :
|
|
|
|
BSCF_INTERMEDIATEDATANOTIFICATION,
|
|
|
|
This->total_read + written,
|
|
|
|
&fmt,
|
|
|
|
&stg);
|
|
|
|
}
|
|
|
|
if (written < dwBytes)
|
|
|
|
return STG_E_MEDIUMFULL;
|
|
|
|
else
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
return HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
}
|
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
static void Binding_FinishedDownload(Binding *This, HRESULT hr)
|
2005-05-04 12:36:54 +02:00
|
|
|
{
|
|
|
|
STGMEDIUM stg;
|
|
|
|
FORMATETC fmt;
|
|
|
|
|
|
|
|
fmt.ptd = NULL;
|
|
|
|
fmt.dwAspect = 0;
|
|
|
|
fmt.lindex = -1;
|
|
|
|
fmt.tymed = TYMED_ISTREAM;
|
|
|
|
|
|
|
|
stg.tymed = TYMED_ISTREAM;
|
|
|
|
stg.u.pstm = (IStream *)This->pstrCache;
|
|
|
|
stg.pUnkForRelease = NULL;
|
|
|
|
|
|
|
|
IBindStatusCallback_OnProgress(This->pbscb, This->total_read, This->expected_size, BINDSTATUS_ENDDOWNLOADDATA, NULL);
|
|
|
|
IBindStatusCallback_OnDataAvailable(This->pbscb, BSCF_LASTDATANOTIFICATION, This->total_read, &fmt, &stg);
|
|
|
|
if (hr)
|
|
|
|
{
|
|
|
|
WCHAR *pwchError = 0;
|
|
|
|
|
|
|
|
FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM |
|
|
|
|
FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
|
|
|
NULL, (DWORD) hr,
|
|
|
|
0, (LPWSTR) &pwchError,
|
|
|
|
0, NULL);
|
|
|
|
if (!pwchError)
|
|
|
|
{
|
|
|
|
static WCHAR achFormat[] = { '%', '0', '8', 'x', 0 };
|
|
|
|
|
|
|
|
pwchError =(WCHAR *) LocalAlloc(LMEM_FIXED, sizeof(WCHAR) * 9);
|
|
|
|
wsprintfW(pwchError, achFormat, hr);
|
|
|
|
}
|
|
|
|
IBindStatusCallback_OnStopBinding(This->pbscb, hr, pwchError);
|
|
|
|
LocalFree(pwchError);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
IBindStatusCallback_OnStopBinding(This->pbscb, hr, NULL);
|
|
|
|
}
|
|
|
|
IBindStatusCallback_Release(This->pbscb);
|
|
|
|
This->pbscb = 0;
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IBindingVtbl BindingVtbl =
|
2005-05-23 11:53:21 +02:00
|
|
|
{
|
|
|
|
Binding_QueryInterface,
|
|
|
|
Binding_AddRef,
|
|
|
|
Binding_Release,
|
|
|
|
Binding_Abort,
|
|
|
|
Binding_Suspend,
|
|
|
|
Binding_Resume,
|
|
|
|
Binding_SetPriority,
|
|
|
|
Binding_GetPriority,
|
|
|
|
Binding_GetBindResult
|
|
|
|
};
|
|
|
|
|
|
|
|
/* filemoniker data structure */
|
|
|
|
typedef struct {
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
const IMonikerVtbl* lpvtbl; /* VTable relative to the IMoniker interface.*/
|
2005-05-23 11:53:21 +02:00
|
|
|
|
2005-07-03 14:05:03 +02:00
|
|
|
LONG ref; /* reference counter for this object */
|
2005-05-23 11:53:21 +02:00
|
|
|
|
|
|
|
LPOLESTR URLName; /* URL string identified by this URLmoniker */
|
|
|
|
} URLMonikerImpl;
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* URLMoniker_QueryInterface
|
|
|
|
*******************************************************************************/
|
|
|
|
static HRESULT WINAPI URLMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
|
|
|
|
{
|
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppvObject);
|
|
|
|
|
|
|
|
/* Perform a sanity check on the parameters.*/
|
|
|
|
if ( (This==0) || (ppvObject==0) )
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
/* Initialize the return parameter */
|
|
|
|
*ppvObject = 0;
|
|
|
|
|
|
|
|
/* Compare the riid with the interface IDs implemented by this object.*/
|
|
|
|
if (IsEqualIID(&IID_IUnknown, riid) ||
|
|
|
|
IsEqualIID(&IID_IPersist, riid) ||
|
|
|
|
IsEqualIID(&IID_IPersistStream,riid) ||
|
|
|
|
IsEqualIID(&IID_IMoniker, riid)
|
|
|
|
)
|
|
|
|
*ppvObject = iface;
|
|
|
|
|
|
|
|
/* Check that we obtained an interface.*/
|
|
|
|
if ((*ppvObject)==0)
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
|
|
|
/* Query Interface always increases the reference count by one when it is successful */
|
|
|
|
IMoniker_AddRef(iface);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* URLMoniker_AddRef
|
|
|
|
******************************************************************************/
|
|
|
|
static ULONG WINAPI URLMonikerImpl_AddRef(IMoniker* iface)
|
|
|
|
{
|
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
|
|
|
ULONG refCount = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
|
|
|
|
|
|
|
|
return refCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* URLMoniker_Release
|
|
|
|
******************************************************************************/
|
|
|
|
static ULONG WINAPI URLMonikerImpl_Release(IMoniker* iface)
|
|
|
|
{
|
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
|
|
|
ULONG refCount = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->(ref before=%lu)\n",This, refCount + 1);
|
|
|
|
|
|
|
|
/* destroy the object if there's no more reference on it */
|
|
|
|
if (!refCount) {
|
|
|
|
HeapFree(GetProcessHeap(),0,This->URLName);
|
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
|
|
|
|
2005-07-02 12:49:56 +02:00
|
|
|
URLMON_UnlockModule();
|
|
|
|
}
|
2005-05-23 11:53:21 +02:00
|
|
|
|
|
|
|
return refCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-13 20:20:24 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* URLMoniker_GetClassID
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI URLMonikerImpl_GetClassID(IMoniker* iface,
|
|
|
|
CLSID *pClassID)/* Pointer to CLSID of object */
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2004-03-29 23:39:44 +02:00
|
|
|
TRACE("(%p,%p)\n",This,pClassID);
|
2002-08-13 20:20:24 +02:00
|
|
|
|
|
|
|
if (pClassID==NULL)
|
|
|
|
return E_POINTER;
|
2004-03-29 23:39:44 +02:00
|
|
|
/* Windows always returns CLSID_StdURLMoniker */
|
|
|
|
*pClassID = CLSID_StdURLMoniker;
|
|
|
|
return S_OK;
|
2002-08-13 20:20:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* URLMoniker_IsDirty
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI URLMonikerImpl_IsDirty(IMoniker* iface)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
2002-08-13 20:20:24 +02:00
|
|
|
/* Note that the OLE-provided implementations of the IPersistStream::IsDirty
|
|
|
|
method in the OLE-provided moniker interfaces always return S_FALSE because
|
|
|
|
their internal state never changes. */
|
|
|
|
|
|
|
|
TRACE("(%p)\n",This);
|
|
|
|
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* URLMoniker_Load
|
2004-03-29 23:39:44 +02:00
|
|
|
*
|
|
|
|
* NOTE
|
|
|
|
* Writes a ULONG containing length of unicode string, followed
|
|
|
|
* by that many unicode characters
|
2002-08-13 20:20:24 +02:00
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI URLMonikerImpl_Load(IMoniker* iface,IStream* pStm)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
2004-03-29 23:39:44 +02:00
|
|
|
|
|
|
|
HRESULT res;
|
|
|
|
ULONG len;
|
|
|
|
ULONG got;
|
|
|
|
TRACE("(%p,%p)\n",This,pStm);
|
|
|
|
|
|
|
|
if(!pStm)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
res = IStream_Read(pStm, &len, sizeof(ULONG), &got);
|
|
|
|
if(SUCCEEDED(res)) {
|
|
|
|
if(got == sizeof(ULONG)) {
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->URLName);
|
2004-03-29 23:39:44 +02:00
|
|
|
This->URLName=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(len+1));
|
|
|
|
if(!This->URLName)
|
|
|
|
res = E_OUTOFMEMORY;
|
|
|
|
else {
|
|
|
|
res = IStream_Read(pStm, This->URLName, len, NULL);
|
|
|
|
This->URLName[len] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
res = E_FAIL;
|
|
|
|
}
|
|
|
|
return res;
|
2002-08-13 20:20:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* URLMoniker_Save
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI URLMonikerImpl_Save(IMoniker* iface,
|
|
|
|
IStream* pStm,/* pointer to the stream where the object is to be saved */
|
|
|
|
BOOL fClearDirty)/* Specifies whether to clear the dirty flag */
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2004-03-29 23:39:44 +02:00
|
|
|
HRESULT res;
|
|
|
|
ULONG len;
|
|
|
|
TRACE("(%p,%p,%d)\n",This,pStm,fClearDirty);
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2004-03-29 23:39:44 +02:00
|
|
|
if(!pStm)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
len = strlenW(This->URLName);
|
|
|
|
res=IStream_Write(pStm,&len,sizeof(ULONG),NULL);
|
|
|
|
if(SUCCEEDED(res))
|
|
|
|
res=IStream_Write(pStm,&This->URLName,len*sizeof(WCHAR),NULL);
|
|
|
|
return res;
|
2002-08-13 20:20:24 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* URLMoniker_GetSizeMax
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI URLMonikerImpl_GetSizeMax(IMoniker* iface,
|
|
|
|
ULARGE_INTEGER* pcbSize)/* Pointer to size of stream needed to save object */
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2004-03-29 23:39:44 +02:00
|
|
|
TRACE("(%p,%p)\n",This,pcbSize);
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2004-03-29 23:39:44 +02:00
|
|
|
if(!pcbSize)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
pcbSize->u.LowPart = sizeof(ULONG) + (strlenW(This->URLName) * sizeof(WCHAR));
|
|
|
|
pcbSize->u.HighPart = 0;
|
|
|
|
return S_OK;
|
2002-08-13 20:20:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* URLMoniker_BindToObject
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI URLMonikerImpl_BindToObject(IMoniker* iface,
|
|
|
|
IBindCtx* pbc,
|
|
|
|
IMoniker* pmkToLeft,
|
|
|
|
REFIID riid,
|
|
|
|
VOID** ppvResult)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
2002-08-13 20:20:24 +02:00
|
|
|
|
|
|
|
*ppvResult=0;
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p,%p,%s,%p): stub\n",This,pbc,pmkToLeft,debugstr_guid(riid),
|
|
|
|
ppvResult);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
enum {OnProgress, OnDataAvailable} callback;
|
|
|
|
} URLMON_CallbackData;
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
static LRESULT CALLBACK URLMON_WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
return DefWindowProcA(hwnd, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PostOnProgress(URLMonikerImpl *This, UINT progress, UINT maxprogress, DWORD status, LPCWSTR *str)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void CALLBACK URLMON_InternetCallback(HINTERNET hinet, /*DWORD_PTR*/ DWORD context, DWORD status,
|
|
|
|
void *status_info, DWORD status_info_len)
|
|
|
|
{
|
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)context;
|
|
|
|
TRACE("handle %p this %p status %08lx\n", hinet, This, status);
|
|
|
|
|
|
|
|
if(This->filesize == -1) {
|
|
|
|
switch(status) {
|
|
|
|
case INTERNET_STATUS_RESOLVING_NAME:
|
|
|
|
PostOnProgess(This, 0, 0, BINDSTATUS_FINDINGRESOURCE, status_info);
|
|
|
|
break;
|
|
|
|
case INTERNET_STATUS_CONNECTING_TO_SERVER:
|
|
|
|
PostOnProgress(This, 0, 0, BINDSTATUS_CONNECTING, NULL);
|
|
|
|
break;
|
|
|
|
case INTERNET_STATUS_SENDING_REQUEST:
|
|
|
|
PostOnProgress(This, 0, 0, BINDSTATUS_SENDINGREQUEST, NULL);
|
|
|
|
break;
|
|
|
|
case INTERNET_REQUEST_COMPLETE:
|
|
|
|
{
|
|
|
|
DWORD len, lensz = sizeof(len);
|
|
|
|
|
|
|
|
HttpQueryInfoW(hrequest, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, &len, &lensz, NULL);
|
|
|
|
TRACE("res = %ld gle = %08lx url len = %ld\n", hres, GetLastError(), len);
|
|
|
|
This->filesize = len;
|
|
|
|
break;
|
|
|
|
}
|
2002-08-17 02:21:53 +02:00
|
|
|
}
|
|
|
|
}
|
2002-08-13 20:20:24 +02:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
2005-05-04 12:36:54 +02:00
|
|
|
|
|
|
|
|
2002-08-13 20:20:24 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* URLMoniker_BindToStorage
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI URLMonikerImpl_BindToStorage(IMoniker* iface,
|
|
|
|
IBindCtx* pbc,
|
|
|
|
IMoniker* pmkToLeft,
|
|
|
|
REFIID riid,
|
|
|
|
VOID** ppvObject)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
2002-08-13 20:20:24 +02:00
|
|
|
HRESULT hres;
|
|
|
|
BINDINFO bi;
|
|
|
|
DWORD bindf;
|
2005-05-04 12:36:54 +02:00
|
|
|
WCHAR szFileName[MAX_PATH + 1];
|
2005-05-23 11:53:21 +02:00
|
|
|
Binding *bind;
|
|
|
|
int len;
|
2002-08-13 20:20:24 +02:00
|
|
|
|
|
|
|
if(pmkToLeft) {
|
|
|
|
FIXME("pmkToLeft != NULL\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
if(!IsEqualIID(&IID_IStream, riid)) {
|
|
|
|
FIXME("unsupported iid\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
bind = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(Binding));
|
|
|
|
bind->lpVtbl = &BindingVtbl;
|
|
|
|
bind->ref = 1;
|
|
|
|
URLMON_LockModule();
|
|
|
|
|
|
|
|
len = lstrlenW(This->URLName)+1;
|
|
|
|
bind->URLName = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
|
|
|
|
memcpy(bind->URLName, This->URLName, len*sizeof(WCHAR));
|
|
|
|
|
|
|
|
hres = UMCreateStreamOnCacheFile(bind->URLName, 0, szFileName, &bind->hCacheFile, &bind->pstrCache);
|
2002-08-13 20:20:24 +02:00
|
|
|
|
|
|
|
if(SUCCEEDED(hres)) {
|
2005-05-04 12:36:54 +02:00
|
|
|
TRACE("Created stream...\n");
|
2004-12-20 19:58:04 +01:00
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
*ppvObject = (void *) bind->pstrCache;
|
|
|
|
IStream_AddRef((IStream *) bind->pstrCache);
|
2005-05-04 12:36:54 +02:00
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
hres = IBindCtx_GetObjectParam(pbc, (LPOLESTR)BSCBHolder, (IUnknown**)&bind->pbscb);
|
2004-12-20 19:58:04 +01:00
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
TRACE("Got IBindStatusCallback...\n");
|
|
|
|
|
|
|
|
memset(&bi, 0, sizeof(bi));
|
|
|
|
bi.cbSize = sizeof(bi);
|
|
|
|
bindf = 0;
|
2005-05-23 11:53:21 +02:00
|
|
|
hres = IBindStatusCallback_GetBindInfo(bind->pbscb, &bindf, &bi);
|
2004-12-20 19:58:04 +01:00
|
|
|
if(SUCCEEDED(hres)) {
|
2005-05-04 12:36:54 +02:00
|
|
|
WCHAR *urlcopy, *tmpwc;
|
2004-12-20 19:58:04 +01:00
|
|
|
URL_COMPONENTSW url;
|
2005-07-11 12:23:10 +02:00
|
|
|
WCHAR *host, *path, *partial_path, *user, *pass;
|
2005-05-23 11:53:21 +02:00
|
|
|
DWORD lensz = sizeof(bind->expected_size);
|
2005-05-04 12:36:54 +02:00
|
|
|
DWORD dwService = 0;
|
|
|
|
BOOL bSuccess;
|
2004-12-20 19:58:04 +01:00
|
|
|
|
|
|
|
TRACE("got bindinfo. bindf = %08lx extrainfo = %s bindinfof = %08lx bindverb = %08lx iid %s\n",
|
|
|
|
bindf, debugstr_w(bi.szExtraInfo), bi.grfBindInfoF, bi.dwBindVerb, debugstr_guid(&bi.iid));
|
2005-05-23 11:53:21 +02:00
|
|
|
hres = IBindStatusCallback_OnStartBinding(bind->pbscb, 0, (IBinding*)bind);
|
2004-12-20 19:58:04 +01:00
|
|
|
TRACE("OnStartBinding rets %08lx\n", hres);
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2005-05-04 12:36:54 +02:00
|
|
|
/* This class will accept URLs with the backslash in them. But InternetCrackURL will not - it
|
|
|
|
* requires forward slashes (this is the behaviour of Microsoft's INETAPI). So we need to make
|
|
|
|
* a copy of the URL here and change the backslash to a forward slash everywhere it appears -
|
|
|
|
* but only before any '#' or '?', after which backslash should be left alone.
|
|
|
|
*/
|
2005-05-23 11:53:21 +02:00
|
|
|
urlcopy = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * (lstrlenW(bind->URLName) + 1));
|
|
|
|
lstrcpyW(urlcopy, bind->URLName);
|
2005-05-04 12:36:54 +02:00
|
|
|
for (tmpwc = urlcopy; *tmpwc && *tmpwc != '#' && *tmpwc != '?'; ++tmpwc)
|
|
|
|
if (*tmpwc == '\\')
|
|
|
|
*tmpwc = '/';
|
|
|
|
|
2002-08-13 20:20:24 +02:00
|
|
|
#if 0
|
2005-05-04 12:36:54 +02:00
|
|
|
if(!registered_wndclass) {
|
2002-08-13 20:20:24 +02:00
|
|
|
WNDCLASSA urlmon_wndclass = {0, URLMON_WndProc,0, 0, URLMON_hInstance, 0, 0, 0, NULL, "URLMON_Callback_Window_Class"};
|
2005-05-04 12:36:54 +02:00
|
|
|
RegisterClassA(&urlmon_wndclass);
|
|
|
|
registered_wndclass = TRUE;
|
|
|
|
}
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2005-05-04 12:36:54 +02:00
|
|
|
This->hwndCallback = CreateWindowA("URLMON_Callback_Window_Class", NULL, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
URLMON_hInstance, NULL);
|
2002-08-13 20:20:24 +02:00
|
|
|
|
|
|
|
#endif
|
2005-05-23 11:53:21 +02:00
|
|
|
bind->expected_size = 0;
|
|
|
|
bind->total_read = 0;
|
2005-05-04 12:36:54 +02:00
|
|
|
|
2004-12-20 19:58:04 +01:00
|
|
|
memset(&url, 0, sizeof(url));
|
|
|
|
url.dwStructSize = sizeof(url);
|
2005-05-04 12:36:54 +02:00
|
|
|
url.dwSchemeLength = url.dwHostNameLength = url.dwUrlPathLength = url.dwUserNameLength = url.dwPasswordLength = 1;
|
2005-07-10 19:47:03 +02:00
|
|
|
InternetCrackUrlW(urlcopy, 0, ICU_ESCAPE, &url);
|
2004-12-20 19:58:04 +01:00
|
|
|
host = HeapAlloc(GetProcessHeap(), 0, (url.dwHostNameLength + 1) * sizeof(WCHAR));
|
|
|
|
memcpy(host, url.lpszHostName, url.dwHostNameLength * sizeof(WCHAR));
|
|
|
|
host[url.dwHostNameLength] = '\0';
|
|
|
|
path = HeapAlloc(GetProcessHeap(), 0, (url.dwUrlPathLength + 1) * sizeof(WCHAR));
|
|
|
|
memcpy(path, url.lpszUrlPath, url.dwUrlPathLength * sizeof(WCHAR));
|
|
|
|
path[url.dwUrlPathLength] = '\0';
|
2005-05-04 12:36:54 +02:00
|
|
|
if (url.dwUserNameLength)
|
|
|
|
{
|
|
|
|
user = HeapAlloc(GetProcessHeap(), 0, ((url.dwUserNameLength + 1) * sizeof(WCHAR)));
|
|
|
|
memcpy(user, url.lpszUserName, url.dwUserNameLength * sizeof(WCHAR));
|
|
|
|
user[url.dwUserNameLength] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
user = 0;
|
|
|
|
}
|
|
|
|
if (url.dwPasswordLength)
|
|
|
|
{
|
|
|
|
pass = HeapAlloc(GetProcessHeap(), 0, ((url.dwPasswordLength + 1) * sizeof(WCHAR)));
|
|
|
|
memcpy(pass, url.lpszPassword, url.dwPasswordLength * sizeof(WCHAR));
|
|
|
|
pass[url.dwPasswordLength] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pass = 0;
|
|
|
|
}
|
2004-12-20 19:58:04 +01:00
|
|
|
|
2005-05-04 12:36:54 +02:00
|
|
|
switch ((DWORD) url.nScheme)
|
|
|
|
{
|
|
|
|
case INTERNET_SCHEME_FTP:
|
|
|
|
case INTERNET_SCHEME_GOPHER:
|
|
|
|
case INTERNET_SCHEME_HTTP:
|
|
|
|
case INTERNET_SCHEME_HTTPS:
|
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
bind->hinternet = InternetOpenA("User Agent", 0, NULL, NULL, 0 /*INTERNET_FLAG_ASYNC*/);
|
|
|
|
/* InternetSetStatusCallback(bind->hinternet, URLMON_InternetCallback);*/
|
|
|
|
if (!bind->hinternet)
|
2005-05-04 12:36:54 +02:00
|
|
|
{
|
|
|
|
hres = HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ((DWORD) url.nScheme)
|
|
|
|
{
|
|
|
|
case INTERNET_SCHEME_FTP:
|
|
|
|
if (!url.nPort)
|
|
|
|
url.nPort = INTERNET_DEFAULT_FTP_PORT;
|
|
|
|
dwService = INTERNET_SERVICE_FTP;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INTERNET_SCHEME_GOPHER:
|
|
|
|
if (!url.nPort)
|
|
|
|
url.nPort = INTERNET_DEFAULT_GOPHER_PORT;
|
|
|
|
dwService = INTERNET_SERVICE_GOPHER;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INTERNET_SCHEME_HTTP:
|
|
|
|
if (!url.nPort)
|
|
|
|
url.nPort = INTERNET_DEFAULT_HTTP_PORT;
|
|
|
|
dwService = INTERNET_SERVICE_HTTP;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INTERNET_SCHEME_HTTPS:
|
|
|
|
if (!url.nPort)
|
|
|
|
url.nPort = INTERNET_DEFAULT_HTTPS_PORT;
|
|
|
|
dwService = INTERNET_SERVICE_HTTP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
bind->hconnect = InternetConnectW(bind->hinternet, host, url.nPort, user, pass,
|
|
|
|
dwService, 0, (DWORD)bind);
|
|
|
|
if (!bind->hconnect)
|
2005-05-04 12:36:54 +02:00
|
|
|
{
|
|
|
|
hres = HRESULT_FROM_WIN32(GetLastError());
|
2005-05-23 11:53:21 +02:00
|
|
|
CloseHandle(bind->hinternet);
|
2005-05-04 12:36:54 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
hres = IBindStatusCallback_OnProgress(bind->pbscb, 0, 0, 0x22, NULL);
|
|
|
|
hres = IBindStatusCallback_OnProgress(bind->pbscb, 0, 0, BINDSTATUS_FINDINGRESOURCE, NULL);
|
|
|
|
hres = IBindStatusCallback_OnProgress(bind->pbscb, 0, 0, BINDSTATUS_CONNECTING, NULL);
|
|
|
|
hres = IBindStatusCallback_OnProgress(bind->pbscb, 0, 0, BINDSTATUS_SENDINGREQUEST, NULL);
|
2005-05-04 12:36:54 +02:00
|
|
|
|
|
|
|
bSuccess = FALSE;
|
|
|
|
|
|
|
|
switch (dwService)
|
|
|
|
{
|
|
|
|
case INTERNET_SERVICE_GOPHER:
|
2005-05-23 11:53:21 +02:00
|
|
|
bind->hrequest = GopherOpenFileW(bind->hconnect,
|
2005-05-04 12:36:54 +02:00
|
|
|
path,
|
|
|
|
0,
|
|
|
|
INTERNET_FLAG_RELOAD,
|
|
|
|
0);
|
2005-05-23 11:53:21 +02:00
|
|
|
if (bind->hrequest)
|
2005-05-04 12:36:54 +02:00
|
|
|
bSuccess = TRUE;
|
|
|
|
else
|
|
|
|
hres = HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INTERNET_SERVICE_FTP:
|
2005-05-23 11:53:21 +02:00
|
|
|
bind->hrequest = FtpOpenFileW(bind->hconnect,
|
2005-05-04 12:36:54 +02:00
|
|
|
path,
|
|
|
|
GENERIC_READ,
|
|
|
|
FTP_TRANSFER_TYPE_BINARY |
|
|
|
|
INTERNET_FLAG_TRANSFER_BINARY |
|
|
|
|
INTERNET_FLAG_RELOAD,
|
|
|
|
0);
|
2005-05-23 11:53:21 +02:00
|
|
|
if (bind->hrequest)
|
2005-05-04 12:36:54 +02:00
|
|
|
bSuccess = TRUE;
|
|
|
|
else
|
|
|
|
hres = HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INTERNET_SERVICE_HTTP:
|
2005-05-23 11:53:21 +02:00
|
|
|
bind->hrequest = HttpOpenRequestW(bind->hconnect, NULL, path, NULL, NULL, NULL, 0, (DWORD)bind);
|
|
|
|
if (!bind->hrequest)
|
2005-05-04 12:36:54 +02:00
|
|
|
{
|
|
|
|
hres = HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
}
|
2005-05-23 11:53:21 +02:00
|
|
|
else if (!HttpSendRequestW(bind->hrequest, NULL, 0, NULL, 0))
|
2005-05-04 12:36:54 +02:00
|
|
|
{
|
|
|
|
hres = HRESULT_FROM_WIN32(GetLastError());
|
2005-05-23 11:53:21 +02:00
|
|
|
InternetCloseHandle(bind->hrequest);
|
2005-05-04 12:36:54 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-23 11:53:21 +02:00
|
|
|
HttpQueryInfoW(bind->hrequest,
|
2005-05-04 12:36:54 +02:00
|
|
|
HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER,
|
2005-05-23 11:53:21 +02:00
|
|
|
&bind->expected_size,
|
2005-05-04 12:36:54 +02:00
|
|
|
&lensz,
|
|
|
|
NULL);
|
|
|
|
bSuccess = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(bSuccess)
|
|
|
|
{
|
2005-05-23 11:53:21 +02:00
|
|
|
TRACE("res = %ld gle = %08lx url len = %ld\n", hres, GetLastError(), bind->expected_size);
|
2005-05-04 12:36:54 +02:00
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
IBindStatusCallback_OnProgress(bind->pbscb, 0, 0, BINDSTATUS_CACHEFILENAMEAVAILABLE, szFileName);
|
2005-05-04 12:36:54 +02:00
|
|
|
|
|
|
|
while(1) {
|
|
|
|
char buf[4096];
|
|
|
|
DWORD bufread;
|
2005-05-23 11:53:21 +02:00
|
|
|
if(InternetReadFile(bind->hrequest, buf, sizeof(buf), &bufread)) {
|
2005-05-04 12:36:54 +02:00
|
|
|
TRACE("read %ld bytes %s...\n", bufread, debugstr_an(buf, 10));
|
|
|
|
if(bufread == 0) break;
|
2005-05-23 11:53:21 +02:00
|
|
|
hres = Binding_MoreCacheData(bind, buf, bufread);
|
2005-05-04 12:36:54 +02:00
|
|
|
} else
|
|
|
|
break;
|
|
|
|
}
|
2005-05-23 11:53:21 +02:00
|
|
|
InternetCloseHandle(bind->hrequest);
|
2005-05-04 12:36:54 +02:00
|
|
|
hres = S_OK;
|
|
|
|
}
|
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
InternetCloseHandle(bind->hconnect);
|
|
|
|
InternetCloseHandle(bind->hinternet);
|
2005-05-04 12:36:54 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case INTERNET_SCHEME_FILE:
|
2005-07-11 12:23:10 +02:00
|
|
|
partial_path = bind->URLName + 5; /* Skip the "file:" part */
|
|
|
|
if ((partial_path[0] != '/' && partial_path[0] != '\\') ||
|
|
|
|
(partial_path[1] != '/' && partial_path[1] != '\\'))
|
2005-05-04 12:36:54 +02:00
|
|
|
{
|
|
|
|
hres = E_FAIL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
HANDLE h;
|
|
|
|
|
2005-07-11 12:23:10 +02:00
|
|
|
partial_path += 2;
|
|
|
|
if (partial_path[0] == '/' || partial_path[0] == '\\')
|
|
|
|
++partial_path;
|
|
|
|
h = CreateFileW(partial_path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
|
2005-05-04 12:36:54 +02:00
|
|
|
if (h == (HANDLE) HFILE_ERROR)
|
|
|
|
{
|
|
|
|
hres = HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char buf[4096];
|
|
|
|
DWORD bufread;
|
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
IBindStatusCallback_OnProgress(bind->pbscb, 0, 0, BINDSTATUS_CACHEFILENAMEAVAILABLE, szFileName);
|
2005-05-04 12:36:54 +02:00
|
|
|
|
|
|
|
while (ReadFile(h, buf, sizeof(buf), &bufread, NULL) && bufread > 0)
|
2005-05-23 11:53:21 +02:00
|
|
|
hres = Binding_MoreCacheData(bind, buf, bufread);
|
2005-05-04 12:36:54 +02:00
|
|
|
|
|
|
|
CloseHandle(h);
|
|
|
|
hres = S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("Unsupported URI scheme");
|
|
|
|
break;
|
2004-12-20 19:58:04 +01:00
|
|
|
}
|
2005-05-23 11:53:21 +02:00
|
|
|
Binding_CloseCacheDownload(bind);
|
|
|
|
Binding_FinishedDownload(bind, hres);
|
2005-05-04 12:36:54 +02:00
|
|
|
|
|
|
|
if (user)
|
|
|
|
HeapFree(GetProcessHeap(), 0, user);
|
|
|
|
if (pass)
|
|
|
|
HeapFree(GetProcessHeap(), 0, pass);
|
|
|
|
HeapFree(GetProcessHeap(), 0, path);
|
|
|
|
HeapFree(GetProcessHeap(), 0, host);
|
|
|
|
HeapFree(GetProcessHeap(), 0, urlcopy);
|
2004-12-20 19:58:04 +01:00
|
|
|
}
|
|
|
|
}
|
2002-08-13 20:20:24 +02:00
|
|
|
}
|
2005-05-23 11:53:21 +02:00
|
|
|
|
|
|
|
IBinding_Release((IBinding*)bind);
|
|
|
|
|
2002-08-13 20:20:24 +02:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* URLMoniker_Reduce
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI URLMonikerImpl_Reduce(IMoniker* iface,
|
|
|
|
IBindCtx* pbc,
|
|
|
|
DWORD dwReduceHowFar,
|
|
|
|
IMoniker** ppmkToLeft,
|
|
|
|
IMoniker** ppmkReduced)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
2004-03-29 23:39:44 +02:00
|
|
|
|
|
|
|
TRACE("(%p,%p,%ld,%p,%p)\n",This,pbc,dwReduceHowFar,ppmkToLeft,ppmkReduced);
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2004-03-29 23:39:44 +02:00
|
|
|
if(!ppmkReduced)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
URLMonikerImpl_AddRef(iface);
|
|
|
|
*ppmkReduced = iface;
|
|
|
|
return MK_S_REDUCED_TO_SELF;
|
2002-08-13 20:20:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* URLMoniker_ComposeWith
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI URLMonikerImpl_ComposeWith(IMoniker* iface,
|
|
|
|
IMoniker* pmkRight,
|
|
|
|
BOOL fOnlyIfNotGeneric,
|
|
|
|
IMoniker** ppmkComposite)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
2002-08-13 20:20:24 +02:00
|
|
|
FIXME("(%p)->(%p,%d,%p): stub\n",This,pmkRight,fOnlyIfNotGeneric,ppmkComposite);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* URLMoniker_Enum
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI URLMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
2004-03-29 23:39:44 +02:00
|
|
|
TRACE("(%p,%d,%p)\n",This,fForward,ppenumMoniker);
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2004-03-29 23:39:44 +02:00
|
|
|
if(!ppenumMoniker)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
/* Does not support sub-monikers */
|
|
|
|
*ppenumMoniker = NULL;
|
|
|
|
return S_OK;
|
2002-08-13 20:20:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* URLMoniker_IsEqual
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI URLMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
2004-03-31 21:58:09 +02:00
|
|
|
CLSID clsid;
|
|
|
|
LPOLESTR urlPath;
|
|
|
|
IBindCtx* bind;
|
|
|
|
HRESULT res;
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2004-03-31 21:58:09 +02:00
|
|
|
TRACE("(%p,%p)\n",This,pmkOtherMoniker);
|
|
|
|
|
|
|
|
if(pmkOtherMoniker==NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
IMoniker_GetClassID(pmkOtherMoniker,&clsid);
|
|
|
|
|
|
|
|
if(!IsEqualCLSID(&clsid,&CLSID_StdURLMoniker))
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
res = CreateBindCtx(0,&bind);
|
|
|
|
if(FAILED(res))
|
|
|
|
return res;
|
|
|
|
|
|
|
|
res = S_FALSE;
|
|
|
|
if(SUCCEEDED(IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&urlPath))) {
|
|
|
|
int result = lstrcmpiW(urlPath, This->URLName);
|
|
|
|
CoTaskMemFree(urlPath);
|
|
|
|
if(result == 0)
|
|
|
|
res = S_OK;
|
|
|
|
}
|
|
|
|
IUnknown_Release(bind);
|
|
|
|
return res;
|
2002-08-13 20:20:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* URLMoniker_Hash
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI URLMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
2004-03-29 23:39:44 +02:00
|
|
|
|
|
|
|
int h = 0,i,skip,len;
|
|
|
|
int off = 0;
|
|
|
|
LPOLESTR val;
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2004-03-29 23:39:44 +02:00
|
|
|
TRACE("(%p,%p)\n",This,pdwHash);
|
|
|
|
|
|
|
|
if(!pdwHash)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
val = This->URLName;
|
|
|
|
len = lstrlenW(val);
|
|
|
|
|
|
|
|
if(len < 16) {
|
|
|
|
for(i = len ; i > 0; i--) {
|
|
|
|
h = (h * 37) + val[off++];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* only sample some characters */
|
|
|
|
skip = len / 8;
|
|
|
|
for(i = len; i > 0; i -= skip, off += skip) {
|
|
|
|
h = (h * 39) + val[off];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*pdwHash = h;
|
|
|
|
return S_OK;
|
2002-08-13 20:20:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* URLMoniker_IsRunning
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI URLMonikerImpl_IsRunning(IMoniker* iface,
|
|
|
|
IBindCtx* pbc,
|
|
|
|
IMoniker* pmkToLeft,
|
|
|
|
IMoniker* pmkNewlyRunning)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
2002-08-13 20:20:24 +02:00
|
|
|
FIXME("(%p)->(%p,%p,%p): stub\n",This,pbc,pmkToLeft,pmkNewlyRunning);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* URLMoniker_GetTimeOfLastChange
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI URLMonikerImpl_GetTimeOfLastChange(IMoniker* iface,
|
|
|
|
IBindCtx* pbc,
|
|
|
|
IMoniker* pmkToLeft,
|
|
|
|
FILETIME* pFileTime)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
2002-08-13 20:20:24 +02:00
|
|
|
FIXME("(%p)->(%p,%p,%p): stub\n",This,pbc,pmkToLeft,pFileTime);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* URLMoniker_Inverse
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI URLMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
2004-03-29 23:39:44 +02:00
|
|
|
TRACE("(%p,%p)\n",This,ppmk);
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2004-03-29 23:39:44 +02:00
|
|
|
return MK_E_NOINVERSE;
|
2002-08-13 20:20:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* URLMoniker_CommonPrefixWith
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI URLMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** ppmkPrefix)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
2002-08-13 20:20:24 +02:00
|
|
|
FIXME("(%p)->(%p,%p): stub\n",This,pmkOther,ppmkPrefix);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* URLMoniker_RelativePathTo
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI URLMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
2002-08-13 20:20:24 +02:00
|
|
|
FIXME("(%p)->(%p,%p): stub\n",This,pmOther,ppmkRelPath);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* URLMoniker_GetDisplayName
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI URLMonikerImpl_GetDisplayName(IMoniker* iface,
|
|
|
|
IBindCtx* pbc,
|
|
|
|
IMoniker* pmkToLeft,
|
|
|
|
LPOLESTR *ppszDisplayName)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
2004-03-29 23:39:44 +02:00
|
|
|
|
|
|
|
int len;
|
|
|
|
|
|
|
|
TRACE("(%p,%p,%p,%p)\n",This,pbc,pmkToLeft,ppszDisplayName);
|
|
|
|
|
|
|
|
if(!ppszDisplayName)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
/* FIXME: If this is a partial URL, try and get a URL moniker from SZ_URLCONTEXT in the bind context,
|
|
|
|
then look at pmkToLeft to try and complete the URL
|
|
|
|
*/
|
|
|
|
len = lstrlenW(This->URLName)+1;
|
|
|
|
*ppszDisplayName = CoTaskMemAlloc(len*sizeof(WCHAR));
|
|
|
|
if(!*ppszDisplayName)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
lstrcpyW(*ppszDisplayName, This->URLName);
|
|
|
|
return S_OK;
|
2002-08-13 20:20:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* URLMoniker_ParseDisplayName
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI URLMonikerImpl_ParseDisplayName(IMoniker* iface,
|
|
|
|
IBindCtx* pbc,
|
|
|
|
IMoniker* pmkToLeft,
|
|
|
|
LPOLESTR pszDisplayName,
|
|
|
|
ULONG* pchEaten,
|
|
|
|
IMoniker** ppmkOut)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
2002-08-13 20:20:24 +02:00
|
|
|
FIXME("(%p)->(%p,%p,%p,%p,%p): stub\n",This,pbc,pmkToLeft,pszDisplayName,pchEaten,ppmkOut);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* URLMoniker_IsSystemMoniker
|
|
|
|
******************************************************************************/
|
|
|
|
static HRESULT WINAPI URLMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
2004-03-29 23:39:44 +02:00
|
|
|
TRACE("(%p,%p)\n",This,pwdMksys);
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2004-03-29 23:39:44 +02:00
|
|
|
if(!pwdMksys)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*pwdMksys = MKSYS_URLMONIKER;
|
|
|
|
return S_OK;
|
2002-08-13 20:20:24 +02:00
|
|
|
}
|
|
|
|
|
2004-11-30 22:14:21 +01:00
|
|
|
/********************************************************************************/
|
|
|
|
/* Virtual function table for the URLMonikerImpl class which include IPersist,*/
|
|
|
|
/* IPersistStream and IMoniker functions. */
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IMonikerVtbl VT_URLMonikerImpl =
|
2004-11-30 22:14:21 +01:00
|
|
|
{
|
|
|
|
URLMonikerImpl_QueryInterface,
|
|
|
|
URLMonikerImpl_AddRef,
|
|
|
|
URLMonikerImpl_Release,
|
|
|
|
URLMonikerImpl_GetClassID,
|
|
|
|
URLMonikerImpl_IsDirty,
|
|
|
|
URLMonikerImpl_Load,
|
|
|
|
URLMonikerImpl_Save,
|
|
|
|
URLMonikerImpl_GetSizeMax,
|
|
|
|
URLMonikerImpl_BindToObject,
|
|
|
|
URLMonikerImpl_BindToStorage,
|
|
|
|
URLMonikerImpl_Reduce,
|
|
|
|
URLMonikerImpl_ComposeWith,
|
|
|
|
URLMonikerImpl_Enum,
|
|
|
|
URLMonikerImpl_IsEqual,
|
|
|
|
URLMonikerImpl_Hash,
|
|
|
|
URLMonikerImpl_IsRunning,
|
|
|
|
URLMonikerImpl_GetTimeOfLastChange,
|
|
|
|
URLMonikerImpl_Inverse,
|
|
|
|
URLMonikerImpl_CommonPrefixWith,
|
|
|
|
URLMonikerImpl_RelativePathTo,
|
|
|
|
URLMonikerImpl_GetDisplayName,
|
|
|
|
URLMonikerImpl_ParseDisplayName,
|
|
|
|
URLMonikerImpl_IsSystemMoniker
|
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* URLMoniker_Construct (local function)
|
|
|
|
*******************************************************************************/
|
|
|
|
static HRESULT URLMonikerImpl_Construct(URLMonikerImpl* This, LPCOLESTR lpszLeftURLName, LPCOLESTR lpszURLName)
|
|
|
|
{
|
|
|
|
HRESULT hres;
|
2005-07-18 11:08:16 +02:00
|
|
|
DWORD sizeStr = INTERNET_MAX_URL_LENGTH;
|
2004-11-30 22:14:21 +01:00
|
|
|
|
|
|
|
TRACE("(%p,%s,%s)\n",This,debugstr_w(lpszLeftURLName),debugstr_w(lpszURLName));
|
|
|
|
memset(This, 0, sizeof(*This));
|
|
|
|
|
|
|
|
/* Initialize the virtual function table. */
|
2005-05-23 11:53:21 +02:00
|
|
|
This->lpvtbl = &VT_URLMonikerImpl;
|
|
|
|
This->ref = 0;
|
2004-11-30 22:14:21 +01:00
|
|
|
|
|
|
|
if(lpszLeftURLName) {
|
|
|
|
hres = UrlCombineW(lpszLeftURLName, lpszURLName, NULL, &sizeStr, 0);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
sizeStr++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
sizeStr = lstrlenW(lpszURLName)+1;
|
|
|
|
|
|
|
|
This->URLName=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr));
|
|
|
|
|
|
|
|
if (This->URLName==NULL)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if(lpszLeftURLName) {
|
|
|
|
hres = UrlCombineW(lpszLeftURLName, lpszURLName, This->URLName, &sizeStr, 0);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->URLName);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
strcpyW(This->URLName,lpszURLName);
|
|
|
|
|
2005-07-02 12:49:56 +02:00
|
|
|
URLMON_LockModule();
|
|
|
|
|
2004-11-30 22:14:21 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2003-12-13 01:03:30 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* CreateAsyncBindCtx (URLMON.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CreateAsyncBindCtx(DWORD reserved, IBindStatusCallback *callback,
|
|
|
|
IEnumFORMATETC *format, IBindCtx **pbind)
|
2005-09-03 11:36:12 +02:00
|
|
|
{
|
|
|
|
TRACE("(%08lx %p %p %p)\n", reserved, callback, format, pbind);
|
|
|
|
|
|
|
|
if(!callback)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
return CreateAsyncBindCtxEx(NULL, 0, callback, format, pbind, 0);
|
|
|
|
}
|
|
|
|
/***********************************************************************
|
|
|
|
* CreateAsyncBindCtxEx (URLMON.@)
|
|
|
|
*
|
|
|
|
* Create an asynchronous bind context.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CreateAsyncBindCtxEx(IBindCtx *ibind, DWORD options,
|
|
|
|
IBindStatusCallback *callback, IEnumFORMATETC *format, IBindCtx** pbind,
|
|
|
|
DWORD reserved)
|
2003-12-13 01:03:30 +01:00
|
|
|
{
|
2004-12-08 14:46:01 +01:00
|
|
|
HRESULT hres;
|
|
|
|
BIND_OPTS bindopts;
|
|
|
|
IBindCtx *bctx;
|
|
|
|
|
2005-09-03 11:36:12 +02:00
|
|
|
TRACE("(%p %08lx %p %p %p %ld)\n", ibind, options, callback, format, pbind, reserved);
|
2004-12-08 14:46:01 +01:00
|
|
|
|
2005-09-03 11:36:12 +02:00
|
|
|
if(!pbind)
|
2004-12-08 14:46:01 +01:00
|
|
|
return E_INVALIDARG;
|
2005-09-03 11:36:12 +02:00
|
|
|
|
|
|
|
if(options)
|
|
|
|
FIXME("not supported options %08lx", options);
|
2004-12-08 14:46:01 +01:00
|
|
|
if(format)
|
2005-09-03 11:36:12 +02:00
|
|
|
FIXME("format is not supported\n");
|
|
|
|
|
|
|
|
if(reserved)
|
|
|
|
WARN("reserved=%ld\n", reserved);
|
2004-12-08 14:46:01 +01:00
|
|
|
|
|
|
|
hres = CreateBindCtx(0, &bctx);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
bindopts.cbStruct = sizeof(BIND_OPTS);
|
|
|
|
bindopts.grfFlags = BIND_MAYBOTHERUSER;
|
|
|
|
bindopts.grfMode = STGM_READWRITE | STGM_SHARE_EXCLUSIVE;
|
|
|
|
bindopts.dwTickCountDeadline = 0;
|
|
|
|
IBindCtx_SetBindOptions(bctx, &bindopts);
|
|
|
|
|
2005-09-03 11:36:12 +02:00
|
|
|
if(callback)
|
|
|
|
RegisterBindStatusCallback(bctx, callback, NULL, 0);
|
2004-12-08 14:46:01 +01:00
|
|
|
|
|
|
|
*pbind = bctx;
|
|
|
|
|
|
|
|
return S_OK;
|
2003-12-13 01:03:30 +01:00
|
|
|
}
|
2001-12-24 21:24:36 +01:00
|
|
|
|
|
|
|
|
2002-05-05 21:40:57 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* CreateURLMoniker (URLMON.@)
|
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* Create a url moniker.
|
2002-05-05 21:40:57 +02:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* PARAMS
|
|
|
|
* pmkContext [I] Context
|
|
|
|
* szURL [I] Url to create the moniker for
|
|
|
|
* ppmk [O] Destination for created moniker.
|
2002-05-05 21:40:57 +02:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK. ppmk contains the created IMoniker object.
|
|
|
|
* Failure: MK_E_SYNTAX if szURL is not a valid url, or
|
|
|
|
* E_OUTOFMEMORY if memory allocation fails.
|
2002-05-05 21:40:57 +02:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI CreateURLMoniker(IMoniker *pmkContext, LPCWSTR szURL, IMoniker **ppmk)
|
|
|
|
{
|
2002-08-13 20:20:24 +02:00
|
|
|
URLMonikerImpl *obj;
|
|
|
|
HRESULT hres;
|
|
|
|
IID iid = IID_IMoniker;
|
2004-05-03 22:07:03 +02:00
|
|
|
LPOLESTR lefturl = NULL;
|
2002-08-13 20:20:24 +02:00
|
|
|
|
|
|
|
TRACE("(%p, %s, %p)\n", pmkContext, debugstr_w(szURL), ppmk);
|
2002-05-05 21:40:57 +02:00
|
|
|
|
2002-08-13 20:20:24 +02:00
|
|
|
if(!(obj = HeapAlloc(GetProcessHeap(), 0, sizeof(*obj))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2004-05-03 22:07:03 +02:00
|
|
|
if(pmkContext) {
|
|
|
|
IBindCtx* bind;
|
2005-07-03 13:20:28 +02:00
|
|
|
DWORD dwMksys = 0;
|
|
|
|
IMoniker_IsSystemMoniker(pmkContext, &dwMksys);
|
|
|
|
if(dwMksys == MKSYS_URLMONIKER && SUCCEEDED(CreateBindCtx(0, &bind))) {
|
|
|
|
IMoniker_GetDisplayName(pmkContext, bind, NULL, &lefturl);
|
|
|
|
TRACE("lefturl = %s\n", debugstr_w(lefturl));
|
2004-05-03 22:07:03 +02:00
|
|
|
IBindCtx_Release(bind);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = URLMonikerImpl_Construct(obj, lefturl, szURL);
|
|
|
|
CoTaskMemFree(lefturl);
|
2002-08-13 20:20:24 +02:00
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
hres = URLMonikerImpl_QueryInterface((IMoniker*)obj, &iid, (void**)ppmk);
|
|
|
|
else
|
|
|
|
HeapFree(GetProcessHeap(), 0, obj);
|
|
|
|
return hres;
|
2002-05-05 21:40:57 +02:00
|
|
|
}
|
|
|
|
|
2002-08-13 20:20:24 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CoInternetGetSession (URLMON.@)
|
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* Create a new internet session and return an IInternetSession interface
|
|
|
|
* representing it.
|
2002-08-13 20:20:24 +02:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* PARAMS
|
|
|
|
* dwSessionMode [I] Mode for the internet session
|
|
|
|
* ppIInternetSession [O] Destination for creates IInternetSession object
|
|
|
|
* dwReserved [I] Reserved, must be 0.
|
2002-08-13 20:20:24 +02:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK. ppIInternetSession contains the IInternetSession interface.
|
|
|
|
* Failure: E_INVALIDARG, if any argument is invalid, or
|
|
|
|
* E_OUTOFMEMORY if memory allocation fails.
|
2002-08-13 20:20:24 +02:00
|
|
|
*/
|
2004-05-17 22:51:02 +02:00
|
|
|
HRESULT WINAPI CoInternetGetSession(DWORD dwSessionMode, IInternetSession **ppIInternetSession, DWORD dwReserved)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
|
|
|
FIXME("(%ld, %p, %ld): stub\n", dwSessionMode, ppIInternetSession, dwReserved);
|
|
|
|
|
|
|
|
if(dwSessionMode) {
|
|
|
|
ERR("dwSessionMode: %ld, must be zero\n", dwSessionMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(dwReserved) {
|
|
|
|
ERR("dwReserved: %ld, must be zero\n", dwReserved);
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppIInternetSession=NULL;
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2003-01-13 21:44:13 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* CoInternetQueryInfo (URLMON.@)
|
|
|
|
*
|
|
|
|
* Retrieves information relevant to a specified URL
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* S_OK success
|
|
|
|
* S_FALSE buffer too small
|
|
|
|
* INET_E_QUERYOPTIONUNKNOWN invalid option
|
|
|
|
*
|
|
|
|
*/
|
2003-04-01 01:58:27 +02:00
|
|
|
HRESULT WINAPI CoInternetQueryInfo(LPCWSTR pwzUrl, QUERYOPTION QueryOption,
|
2003-01-13 21:44:13 +01:00
|
|
|
DWORD dwQueryFlags, LPVOID pvBuffer, DWORD cbBuffer, DWORD * pcbBuffer,
|
|
|
|
DWORD dwReserved)
|
|
|
|
{
|
|
|
|
FIXME("(%s, %x, %lx, %p, %lx, %p, %lx): stub\n", debugstr_w(pwzUrl),
|
|
|
|
QueryOption, dwQueryFlags, pvBuffer, cbBuffer, pcbBuffer, dwReserved);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2003-12-13 01:03:30 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* IsAsyncMoniker (URLMON.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI IsAsyncMoniker(IMoniker *pmk)
|
|
|
|
{
|
2004-05-07 05:49:19 +02:00
|
|
|
IUnknown *am;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", pmk);
|
|
|
|
if(!pmk)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
if(SUCCEEDED(IMoniker_QueryInterface(pmk, &IID_IAsyncMoniker, (void**)&am))) {
|
|
|
|
IUnknown_Release(am);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2003-12-13 01:03:30 +01:00
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2001-05-31 23:38:38 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RegisterBindStatusCallback (URLMON.@)
|
2001-05-31 23:38:38 +02:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* Register a bind status callback.
|
2001-05-31 23:38:38 +02:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* PARAMS
|
|
|
|
* pbc [I] Binding context
|
|
|
|
* pbsc [I] Callback to register
|
|
|
|
* ppbscPrevious [O] Destination for previous callback
|
|
|
|
* dwReserved [I] Reserved, must be 0.
|
2001-05-31 23:38:38 +02:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: E_INVALIDARG, if any argument is invalid, or
|
|
|
|
* E_OUTOFMEMORY if memory allocation fails.
|
2001-05-31 23:38:38 +02:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI RegisterBindStatusCallback(
|
|
|
|
IBindCtx *pbc,
|
|
|
|
IBindStatusCallback *pbsc,
|
|
|
|
IBindStatusCallback **ppbscPrevious,
|
|
|
|
DWORD dwReserved)
|
|
|
|
{
|
|
|
|
IBindStatusCallback *prev;
|
|
|
|
|
2004-11-30 22:14:21 +01:00
|
|
|
TRACE("(%p,%p,%p,%lu)\n", pbc, pbsc, ppbscPrevious, dwReserved);
|
2001-05-31 23:38:38 +02:00
|
|
|
|
|
|
|
if (pbc == NULL || pbsc == NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2004-04-20 04:14:00 +02:00
|
|
|
if (SUCCEEDED(IBindCtx_GetObjectParam(pbc, (LPOLESTR)BSCBHolder, (IUnknown **)&prev)))
|
2001-05-31 23:38:38 +02:00
|
|
|
{
|
2004-04-20 04:14:00 +02:00
|
|
|
IBindCtx_RevokeObjectParam(pbc, (LPOLESTR)BSCBHolder);
|
2001-05-31 23:38:38 +02:00
|
|
|
if (ppbscPrevious)
|
|
|
|
*ppbscPrevious = prev;
|
|
|
|
else
|
|
|
|
IBindStatusCallback_Release(prev);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-09-03 11:36:12 +02:00
|
|
|
return IBindCtx_RegisterObjectParam(pbc, (LPOLESTR)BSCBHolder, (IUnknown *)pbsc);
|
2001-05-31 23:38:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* RevokeBindStatusCallback (URLMON.@)
|
2001-05-31 23:38:38 +02:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* Unregister a bind status callback.
|
2001-05-31 23:38:38 +02:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* pbc [I] Binding context
|
|
|
|
* pbsc [I] Callback to unregister
|
2001-05-31 23:38:38 +02:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: E_INVALIDARG, if any argument is invalid, or
|
|
|
|
* E_FAIL if pbsc wasn't registered with pbc.
|
2001-05-31 23:38:38 +02:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI RevokeBindStatusCallback(
|
|
|
|
IBindCtx *pbc,
|
|
|
|
IBindStatusCallback *pbsc)
|
|
|
|
{
|
|
|
|
IBindStatusCallback *callback;
|
|
|
|
HRESULT hr = E_FAIL;
|
|
|
|
|
|
|
|
TRACE("(%p,%p)\n", pbc, pbsc);
|
|
|
|
|
|
|
|
if (pbc == NULL || pbsc == NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2004-04-20 04:14:00 +02:00
|
|
|
if (SUCCEEDED(IBindCtx_GetObjectParam(pbc, (LPOLESTR)BSCBHolder, (IUnknown **)&callback)))
|
2001-05-31 23:38:38 +02:00
|
|
|
{
|
|
|
|
if (callback == pbsc)
|
|
|
|
{
|
2004-04-20 04:14:00 +02:00
|
|
|
IBindCtx_RevokeObjectParam(pbc, (LPOLESTR)BSCBHolder);
|
2001-05-31 23:38:38 +02:00
|
|
|
hr = S_OK;
|
|
|
|
}
|
|
|
|
IBindStatusCallback_Release(pbsc);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2003-07-15 22:47:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* URLDownloadToFileA (URLMON.@)
|
|
|
|
*
|
|
|
|
* Downloads URL szURL to rile szFileName and call lpfnCB callback to
|
|
|
|
* report progress.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pCaller [I] controlling IUnknown interface.
|
|
|
|
* szURL [I] URL of the file to download
|
|
|
|
* szFileName [I] file name to store the content of the URL
|
|
|
|
* dwReserved [I] reserved - set to 0
|
|
|
|
* lpfnCB [I] callback for progress report
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* S_OK on success
|
|
|
|
* E_OUTOFMEMORY when going out of memory
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI URLDownloadToFileA(LPUNKNOWN pCaller,
|
|
|
|
LPCSTR szURL,
|
|
|
|
LPCSTR szFileName,
|
|
|
|
DWORD dwReserved,
|
|
|
|
LPBINDSTATUSCALLBACK lpfnCB)
|
|
|
|
{
|
|
|
|
UNICODE_STRING szURL_w, szFileName_w;
|
|
|
|
|
|
|
|
if ((szURL == NULL) || (szFileName == NULL)) {
|
|
|
|
FIXME("(%p,%s,%s,%08lx,%p) cannot accept NULL strings !\n", pCaller, debugstr_a(szURL), debugstr_a(szFileName), dwReserved, lpfnCB);
|
|
|
|
return E_INVALIDARG; /* The error code is not specified in this case... */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RtlCreateUnicodeStringFromAsciiz(&szURL_w, szURL)) {
|
|
|
|
if (RtlCreateUnicodeStringFromAsciiz(&szFileName_w, szFileName)) {
|
|
|
|
HRESULT ret = URLDownloadToFileW(pCaller, szURL_w.Buffer, szFileName_w.Buffer, dwReserved, lpfnCB);
|
|
|
|
|
|
|
|
RtlFreeUnicodeString(&szURL_w);
|
|
|
|
RtlFreeUnicodeString(&szFileName_w);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
} else {
|
|
|
|
RtlFreeUnicodeString(&szURL_w);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("(%p,%s,%s,%08lx,%p) could not allocate W strings !\n", pCaller, szURL, szFileName, dwReserved, lpfnCB);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* URLDownloadToFileW (URLMON.@)
|
|
|
|
*
|
|
|
|
* Downloads URL szURL to rile szFileName and call lpfnCB callback to
|
|
|
|
* report progress.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pCaller [I] controlling IUnknown interface.
|
|
|
|
* szURL [I] URL of the file to download
|
|
|
|
* szFileName [I] file name to store the content of the URL
|
|
|
|
* dwReserved [I] reserved - set to 0
|
|
|
|
* lpfnCB [I] callback for progress report
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* S_OK on success
|
|
|
|
* E_OUTOFMEMORY when going out of memory
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI URLDownloadToFileW(LPUNKNOWN pCaller,
|
|
|
|
LPCWSTR szURL,
|
|
|
|
LPCWSTR szFileName,
|
|
|
|
DWORD dwReserved,
|
|
|
|
LPBINDSTATUSCALLBACK lpfnCB)
|
|
|
|
{
|
|
|
|
HINTERNET hinternet, hcon, hreq;
|
|
|
|
BOOL r;
|
|
|
|
CHAR buffer[0x1000];
|
|
|
|
DWORD sz, total, written;
|
|
|
|
DWORD total_size = 0xFFFFFFFF, arg_size = sizeof(total_size);
|
|
|
|
URL_COMPONENTSW url;
|
|
|
|
WCHAR host[0x80], path[0x100];
|
|
|
|
HANDLE hfile;
|
2004-05-04 06:13:05 +02:00
|
|
|
static const WCHAR wszAppName[]={'u','r','l','m','o','n','.','d','l','l',0};
|
2003-07-15 22:47:17 +02:00
|
|
|
|
|
|
|
/* Note: all error codes would need to be checked agains real Windows behaviour... */
|
|
|
|
TRACE("(%p,%s,%s,%08lx,%p) stub!\n", pCaller, debugstr_w(szURL), debugstr_w(szFileName), dwReserved, lpfnCB);
|
|
|
|
|
|
|
|
if ((szURL == NULL) || (szFileName == NULL)) {
|
|
|
|
FIXME(" cannot accept NULL strings !\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Would be better to use the application name here rather than 'urlmon' :-/ */
|
|
|
|
hinternet = InternetOpenW(wszAppName, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
|
|
|
|
if (hinternet == NULL) {
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&url, 0, sizeof(url));
|
|
|
|
url.dwStructSize = sizeof(url);
|
|
|
|
url.lpszHostName = host;
|
|
|
|
url.dwHostNameLength = sizeof(host);
|
|
|
|
url.lpszUrlPath = path;
|
|
|
|
url.dwUrlPathLength = sizeof(path);
|
|
|
|
|
|
|
|
if (!InternetCrackUrlW(szURL, 0, 0, &url)) {
|
|
|
|
InternetCloseHandle(hinternet);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpfnCB) {
|
|
|
|
if (IBindStatusCallback_OnProgress(lpfnCB, 0, 0, BINDSTATUS_CONNECTING, url.lpszHostName) == E_ABORT) {
|
|
|
|
InternetCloseHandle(hinternet);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
hcon = InternetConnectW(hinternet, url.lpszHostName, url.nPort,
|
|
|
|
url.lpszUserName, url.lpszPassword,
|
|
|
|
INTERNET_SERVICE_HTTP, 0, 0);
|
|
|
|
if (!hcon) {
|
|
|
|
InternetCloseHandle(hinternet);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
hreq = HttpOpenRequestW(hcon, NULL, url.lpszUrlPath, NULL, NULL, NULL, 0, 0);
|
|
|
|
if (!hreq) {
|
|
|
|
InternetCloseHandle(hinternet);
|
|
|
|
InternetCloseHandle(hcon);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!HttpSendRequestW(hreq, NULL, 0, NULL, 0)) {
|
|
|
|
InternetCloseHandle(hinternet);
|
|
|
|
InternetCloseHandle(hcon);
|
|
|
|
InternetCloseHandle(hreq);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (HttpQueryInfoW(hreq, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER,
|
|
|
|
&total_size, &arg_size, NULL)) {
|
|
|
|
TRACE(" total size : %ld\n", total_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
hfile = CreateFileW(szFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
|
|
|
|
FILE_ATTRIBUTE_NORMAL, NULL );
|
|
|
|
if (hfile == INVALID_HANDLE_VALUE) {
|
|
|
|
return E_ACCESSDENIED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpfnCB) {
|
|
|
|
if (IBindStatusCallback_OnProgress(lpfnCB, 0, total_size != 0xFFFFFFFF ? total_size : 0,
|
|
|
|
BINDSTATUS_BEGINDOWNLOADDATA, szURL) == E_ABORT) {
|
|
|
|
InternetCloseHandle(hreq);
|
|
|
|
InternetCloseHandle(hcon);
|
|
|
|
InternetCloseHandle(hinternet);
|
|
|
|
CloseHandle(hfile);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
total = 0;
|
|
|
|
while (1) {
|
|
|
|
r = InternetReadFile(hreq, buffer, sizeof(buffer), &sz);
|
|
|
|
if (!r) {
|
|
|
|
InternetCloseHandle(hreq);
|
|
|
|
InternetCloseHandle(hcon);
|
|
|
|
InternetCloseHandle(hinternet);
|
|
|
|
|
|
|
|
CloseHandle(hfile);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
if (!sz)
|
|
|
|
break;
|
|
|
|
|
|
|
|
total += sz;
|
|
|
|
|
|
|
|
if (lpfnCB) {
|
|
|
|
if (IBindStatusCallback_OnProgress(lpfnCB, total, total_size != 0xFFFFFFFF ? total_size : 0,
|
|
|
|
BINDSTATUS_DOWNLOADINGDATA, szURL) == E_ABORT) {
|
|
|
|
InternetCloseHandle(hreq);
|
|
|
|
InternetCloseHandle(hcon);
|
|
|
|
InternetCloseHandle(hinternet);
|
|
|
|
CloseHandle(hfile);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!WriteFile(hfile, buffer, sz, &written, NULL)) {
|
|
|
|
InternetCloseHandle(hreq);
|
|
|
|
InternetCloseHandle(hcon);
|
|
|
|
InternetCloseHandle(hinternet);
|
|
|
|
|
|
|
|
CloseHandle(hfile);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpfnCB) {
|
|
|
|
if (IBindStatusCallback_OnProgress(lpfnCB, total, total_size != 0xFFFFFFFF ? total_size : 0,
|
|
|
|
BINDSTATUS_ENDDOWNLOADDATA, szURL) == E_ABORT) {
|
|
|
|
InternetCloseHandle(hreq);
|
|
|
|
InternetCloseHandle(hcon);
|
|
|
|
InternetCloseHandle(hinternet);
|
|
|
|
CloseHandle(hfile);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
InternetCloseHandle(hreq);
|
|
|
|
InternetCloseHandle(hcon);
|
|
|
|
InternetCloseHandle(hinternet);
|
|
|
|
|
|
|
|
CloseHandle(hfile);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2004-07-13 01:48:39 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* HlinkSimpleNavigateToString (URLMON.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI HlinkSimpleNavigateToString( LPCWSTR szTarget,
|
|
|
|
LPCWSTR szLocation, LPCWSTR szTargetFrameName, IUnknown *pUnk,
|
|
|
|
IBindCtx *pbc, IBindStatusCallback *pbsc, DWORD grfHLNF, DWORD dwReserved)
|
|
|
|
{
|
|
|
|
FIXME("%s\n", debugstr_w( szTarget ) );
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* HlinkNavigateString (URLMON.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI HlinkNavigateString( IUnknown *pUnk, LPCWSTR szTarget )
|
|
|
|
{
|
|
|
|
TRACE("%p %s\n", pUnk, debugstr_w( szTarget ) );
|
|
|
|
return HlinkSimpleNavigateToString(
|
|
|
|
szTarget, NULL, NULL, pUnk, NULL, NULL, 0, 0 );
|
|
|
|
}
|
2005-05-25 11:54:15 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetSoftwareUpdateInfo (URLMON.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI GetSoftwareUpdateInfo( LPCWSTR szDistUnit, LPSOFTDISTINFO psdi )
|
|
|
|
{
|
|
|
|
FIXME("%s %p\n", debugstr_w(szDistUnit), psdi );
|
|
|
|
return E_FAIL;
|
|
|
|
}
|