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
|
2005-12-31 13:19:32 +01:00
|
|
|
* Copyright 2005 Jacek Caban for CodeWeavers
|
2002-08-13 20:20:24 +02:00
|
|
|
*
|
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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2000-04-11 22:07:00 +02:00
|
|
|
*/
|
|
|
|
|
2007-12-13 20:26:51 +01:00
|
|
|
#include "urlmon_main.h"
|
2004-10-07 05:06:48 +02:00
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winreg.h"
|
2004-05-03 22:07:03 +02:00
|
|
|
#include "shlwapi.h"
|
2010-06-28 21:16:51 +02:00
|
|
|
#include "hlink.h"
|
|
|
|
#include "shellapi.h"
|
2007-12-13 20:26:51 +01:00
|
|
|
|
|
|
|
#include "wine/debug.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
|
|
|
|
2005-05-23 11:53:21 +02:00
|
|
|
typedef struct {
|
2011-01-11 10:10:04 +01:00
|
|
|
IMoniker IMoniker_iface;
|
2010-12-20 15:15:00 +01:00
|
|
|
IUriContainer IUriContainer_iface;
|
2005-05-23 11:53:21 +02:00
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
LONG ref;
|
2005-05-23 11:53:21 +02:00
|
|
|
|
2011-06-23 13:43:11 +02:00
|
|
|
IUri *uri;
|
2011-06-22 19:22:20 +02:00
|
|
|
BSTR URLName;
|
2009-03-23 18:30:11 +01:00
|
|
|
} URLMoniker;
|
2005-05-23 11:53:21 +02:00
|
|
|
|
2011-01-11 10:10:04 +01:00
|
|
|
static inline URLMoniker *impl_from_IMoniker(IMoniker *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, URLMoniker, IMoniker_iface);
|
|
|
|
}
|
2005-05-23 11:53:21 +02:00
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
static HRESULT WINAPI URLMoniker_QueryInterface(IMoniker *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-11 10:10:04 +01:00
|
|
|
URLMoniker *This = impl_from_IMoniker(iface);
|
2005-05-23 11:53:21 +02:00
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
if(!ppv)
|
2005-05-23 11:53:21 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
if(IsEqualIID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
|
|
|
*ppv = iface;
|
|
|
|
}else if(IsEqualIID(&IID_IPersist, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IPersist %p)\n", This, ppv);
|
|
|
|
*ppv = iface;
|
|
|
|
}else if(IsEqualIID(&IID_IPersistStream,riid)) {
|
|
|
|
TRACE("(%p)->(IID_IPersistStream %p)\n", This, ppv);
|
|
|
|
*ppv = iface;
|
|
|
|
}else if(IsEqualIID(&IID_IMoniker, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IMoniker %p)\n", This, ppv);
|
|
|
|
*ppv = iface;
|
2009-03-23 18:30:32 +01:00
|
|
|
}else if(IsEqualIID(&IID_IAsyncMoniker, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IAsyncMoniker %p)\n", This, ppv);
|
|
|
|
*ppv = iface;
|
2010-12-20 15:15:00 +01:00
|
|
|
}else if(IsEqualIID(&IID_IUriContainer, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUriContainer %p)\n", This, ppv);
|
|
|
|
*ppv = &This->IUriContainer_iface;
|
2009-03-23 18:30:11 +01:00
|
|
|
}else {
|
|
|
|
WARN("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppv);
|
|
|
|
*ppv = NULL;
|
2005-05-23 11:53:21 +02:00
|
|
|
return E_NOINTERFACE;
|
2009-03-23 18:30:11 +01:00
|
|
|
}
|
2005-05-23 11:53:21 +02:00
|
|
|
|
2012-07-27 11:15:05 +02:00
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
2005-05-23 11:53:21 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
static ULONG WINAPI URLMoniker_AddRef(IMoniker *iface)
|
2005-05-23 11:53:21 +02:00
|
|
|
{
|
2011-01-11 10:10:04 +01:00
|
|
|
URLMoniker *This = impl_from_IMoniker(iface);
|
2005-05-23 11:53:21 +02:00
|
|
|
ULONG refCount = InterlockedIncrement(&This->ref);
|
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p) ref=%lu\n",This, refCount);
|
2005-05-23 11:53:21 +02:00
|
|
|
|
|
|
|
return refCount;
|
|
|
|
}
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
static ULONG WINAPI URLMoniker_Release(IMoniker *iface)
|
2005-05-23 11:53:21 +02:00
|
|
|
{
|
2011-01-11 10:10:04 +01:00
|
|
|
URLMoniker *This = impl_from_IMoniker(iface);
|
2005-05-23 11:53:21 +02:00
|
|
|
ULONG refCount = InterlockedDecrement(&This->ref);
|
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p) ref=%lu\n",This, refCount);
|
2005-05-23 11:53:21 +02:00
|
|
|
|
|
|
|
if (!refCount) {
|
2011-06-23 13:43:11 +02:00
|
|
|
if(This->uri)
|
|
|
|
IUri_Release(This->uri);
|
2011-06-22 19:22:20 +02:00
|
|
|
SysFreeString(This->URLName);
|
2007-11-29 22:12:34 +01:00
|
|
|
heap_free(This);
|
2005-05-23 11:53:21 +02:00
|
|
|
|
2005-07-02 12:49:56 +02:00
|
|
|
URLMON_UnlockModule();
|
|
|
|
}
|
2005-05-23 11:53:21 +02:00
|
|
|
|
|
|
|
return refCount;
|
|
|
|
}
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
static HRESULT WINAPI URLMoniker_GetClassID(IMoniker *iface, CLSID *pClassID)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
2011-01-11 10:10:04 +01:00
|
|
|
URLMoniker *This = impl_from_IMoniker(iface);
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
TRACE("(%p,%p)\n", This, pClassID);
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
if(!pClassID)
|
2002-08-13 20:20:24 +02:00
|
|
|
return E_POINTER;
|
2009-03-23 18:30:11 +01:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
static HRESULT WINAPI URLMoniker_IsDirty(IMoniker *iface)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
2011-01-11 10:10:04 +01:00
|
|
|
URLMoniker *This = impl_from_IMoniker(iface);
|
2002-08-13 20:20:24 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n",This);
|
|
|
|
|
2009-03-23 18:30:11 +01: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. */
|
2002-08-13 20:20:24 +02:00
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
static HRESULT WINAPI URLMoniker_Load(IMoniker* iface,IStream* pStm)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
2011-01-11 10:10:04 +01:00
|
|
|
URLMoniker *This = impl_from_IMoniker(iface);
|
2011-06-23 13:44:17 +02:00
|
|
|
WCHAR *new_uri_str;
|
|
|
|
IUri *new_uri;
|
|
|
|
BSTR new_url;
|
2007-05-23 20:05:24 +02:00
|
|
|
ULONG size;
|
2004-03-29 23:39:44 +02:00
|
|
|
ULONG got;
|
2011-06-23 13:44:17 +02:00
|
|
|
HRESULT hres;
|
2009-03-23 18:30:11 +01:00
|
|
|
|
2004-03-29 23:39:44 +02:00
|
|
|
TRACE("(%p,%p)\n",This,pStm);
|
|
|
|
|
|
|
|
if(!pStm)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
/*
|
|
|
|
* NOTE
|
|
|
|
* Writes a ULONG containing length of unicode string, followed
|
|
|
|
* by that many unicode characters
|
|
|
|
*/
|
2011-06-23 13:44:17 +02:00
|
|
|
hres = IStream_Read(pStm, &size, sizeof(ULONG), &got);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
if(got != sizeof(ULONG))
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
new_uri_str = heap_alloc(size+sizeof(WCHAR));
|
|
|
|
if(!new_uri_str)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
hres = IStream_Read(pStm, new_uri_str, size, NULL);
|
|
|
|
new_uri_str[size/sizeof(WCHAR)] = 0;
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
hres = CreateUri(new_uri_str, 0, 0, &new_uri);
|
|
|
|
heap_free(new_uri_str);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = IUri_GetDisplayUri(new_uri, &new_url);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
IUri_Release(new_uri);
|
|
|
|
return hres;
|
2004-03-29 23:39:44 +02:00
|
|
|
}
|
2009-03-23 18:30:11 +01:00
|
|
|
|
2011-06-23 13:44:17 +02:00
|
|
|
SysFreeString(This->URLName);
|
|
|
|
if(This->uri)
|
|
|
|
IUri_Release(This->uri);
|
|
|
|
|
|
|
|
This->uri = new_uri;
|
|
|
|
This->URLName = new_url;
|
|
|
|
return S_OK;
|
2002-08-13 20:20:24 +02:00
|
|
|
}
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
static HRESULT WINAPI URLMoniker_Save(IMoniker *iface, IStream* pStm, BOOL fClearDirty)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
2011-01-11 10:10:04 +01:00
|
|
|
URLMoniker *This = impl_from_IMoniker(iface);
|
2004-03-29 23:39:44 +02:00
|
|
|
HRESULT res;
|
2007-05-23 20:05:24 +02:00
|
|
|
ULONG size;
|
2009-03-23 18:30:11 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2011-06-22 19:22:20 +02:00
|
|
|
size = (SysStringLen(This->URLName) + 1)*sizeof(WCHAR);
|
2007-05-23 20:05:24 +02:00
|
|
|
res=IStream_Write(pStm,&size,sizeof(ULONG),NULL);
|
2004-03-29 23:39:44 +02:00
|
|
|
if(SUCCEEDED(res))
|
2007-05-23 20:05:24 +02:00
|
|
|
res=IStream_Write(pStm,This->URLName,size,NULL);
|
2009-03-23 18:30:11 +01:00
|
|
|
|
2004-03-29 23:39:44 +02:00
|
|
|
return res;
|
2002-08-13 20:20:24 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
static HRESULT WINAPI URLMoniker_GetSizeMax(IMoniker* iface, ULARGE_INTEGER *pcbSize)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
2011-01-11 10:10:04 +01:00
|
|
|
URLMoniker *This = impl_from_IMoniker(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;
|
|
|
|
|
2011-06-22 19:22:20 +02:00
|
|
|
pcbSize->QuadPart = sizeof(ULONG) + ((SysStringLen(This->URLName)+1) * sizeof(WCHAR));
|
2004-03-29 23:39:44 +02:00
|
|
|
return S_OK;
|
2002-08-13 20:20:24 +02:00
|
|
|
}
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
static HRESULT WINAPI URLMoniker_BindToObject(IMoniker *iface, IBindCtx* pbc, IMoniker *pmkToLeft,
|
|
|
|
REFIID riid, void **ppv)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
2011-01-11 10:10:04 +01:00
|
|
|
URLMoniker *This = impl_from_IMoniker(iface);
|
2007-12-30 17:45:00 +01:00
|
|
|
IRunningObjectTable *obj_tbl;
|
|
|
|
HRESULT hres;
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2011-12-15 10:11:44 +01:00
|
|
|
TRACE("(%p)->(%p,%p,%s,%p)\n", This, pbc, pmkToLeft, debugstr_guid(riid), ppv);
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2007-12-30 17:45:00 +01:00
|
|
|
hres = IBindCtx_GetRunningObjectTable(pbc, &obj_tbl);
|
|
|
|
if(SUCCEEDED(hres)) {
|
2013-08-13 10:41:51 +02:00
|
|
|
hres = IRunningObjectTable_IsRunning(obj_tbl, &This->IMoniker_iface);
|
|
|
|
if(hres == S_OK) {
|
|
|
|
IUnknown *unk = NULL;
|
|
|
|
|
|
|
|
TRACE("Found in running object table\n");
|
|
|
|
|
|
|
|
hres = IRunningObjectTable_GetObject(obj_tbl, &This->IMoniker_iface, &unk);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
hres = IUnknown_QueryInterface(unk, riid, ppv);
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
}
|
|
|
|
|
|
|
|
IRunningObjectTable_Release(obj_tbl);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2007-12-30 17:45:00 +01:00
|
|
|
IRunningObjectTable_Release(obj_tbl);
|
|
|
|
}
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2011-06-23 13:44:57 +02:00
|
|
|
if(!This->uri) {
|
|
|
|
*ppv = NULL;
|
|
|
|
return MK_E_SYNTAX;
|
|
|
|
}
|
2010-11-15 12:38:06 +01:00
|
|
|
|
2011-06-23 13:44:57 +02:00
|
|
|
return bind_to_object(&This->IMoniker_iface, This->uri, pbc, riid, ppv);
|
2002-08-13 20:20:24 +02:00
|
|
|
}
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
static HRESULT WINAPI URLMoniker_BindToStorage(IMoniker* iface, IBindCtx* pbc,
|
|
|
|
IMoniker* pmkToLeft, REFIID riid, void **ppvObject)
|
2005-11-14 12:22:01 +01:00
|
|
|
{
|
2011-01-11 10:10:04 +01:00
|
|
|
URLMoniker *This = impl_from_IMoniker(iface);
|
2005-11-14 12:22:01 +01:00
|
|
|
|
2009-03-04 19:08:20 +01:00
|
|
|
TRACE("(%p)->(%p %p %s %p)\n", This, pbc, pmkToLeft, debugstr_guid(riid), ppvObject);
|
2005-11-14 12:22:01 +01:00
|
|
|
|
2011-04-01 08:57:12 +02:00
|
|
|
if(ppvObject) *ppvObject = NULL;
|
|
|
|
|
|
|
|
if(!pbc || !ppvObject) return E_INVALIDARG;
|
|
|
|
|
2007-09-09 20:12:21 +02:00
|
|
|
if(pmkToLeft)
|
2007-10-01 14:09:32 +02:00
|
|
|
FIXME("Unsupported pmkToLeft\n");
|
2007-09-09 20:12:21 +02:00
|
|
|
|
2011-06-23 13:44:38 +02:00
|
|
|
if(!This->uri)
|
|
|
|
return MK_E_SYNTAX;
|
2010-11-15 12:38:06 +01:00
|
|
|
|
2011-06-23 13:44:38 +02:00
|
|
|
return bind_to_storage(This->uri, pbc, riid, ppvObject);
|
2005-11-14 12:22:01 +01:00
|
|
|
}
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
static HRESULT WINAPI URLMoniker_Reduce(IMoniker *iface, IBindCtx *pbc,
|
|
|
|
DWORD dwReduceHowFar, IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
2011-01-11 10:10:04 +01:00
|
|
|
URLMoniker *This = impl_from_IMoniker(iface);
|
|
|
|
|
2022-02-18 09:18:16 +01: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;
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
IMoniker_AddRef(iface);
|
2004-03-29 23:39:44 +02:00
|
|
|
*ppmkReduced = iface;
|
|
|
|
return MK_S_REDUCED_TO_SELF;
|
2002-08-13 20:20:24 +02:00
|
|
|
}
|
|
|
|
|
2021-03-17 23:29:14 +01:00
|
|
|
static HRESULT WINAPI URLMoniker_ComposeWith(IMoniker *iface, IMoniker *right,
|
|
|
|
BOOL only_if_not_generic, IMoniker **composite)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
2021-03-17 23:29:14 +01:00
|
|
|
HRESULT res;
|
|
|
|
IUri *right_uri;
|
|
|
|
IUriContainer *uri_container;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p,%d,%p)\n", iface, right, only_if_not_generic, composite);
|
|
|
|
|
|
|
|
if (!right || !composite) return E_INVALIDARG;
|
|
|
|
|
|
|
|
res = IMoniker_QueryInterface(right, &IID_IUriContainer, (void**)&uri_container);
|
|
|
|
if (SUCCEEDED(res)){
|
|
|
|
res = IUriContainer_GetIUri(uri_container, &right_uri);
|
|
|
|
if (SUCCEEDED(res)) res = CreateURLMonikerEx2(iface, right_uri, composite, 0);
|
|
|
|
IUriContainer_Release(uri_container);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(only_if_not_generic) return MK_E_NEEDGENERIC;
|
|
|
|
return CreateGenericComposite(iface, right, composite);
|
2002-08-13 20:20:24 +02:00
|
|
|
}
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
static HRESULT WINAPI URLMoniker_Enum(IMoniker *iface, BOOL fForward, IEnumMoniker **ppenumMoniker)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
2011-01-11 10:10:04 +01:00
|
|
|
URLMoniker *This = impl_from_IMoniker(iface);
|
2009-03-23 18:30:11 +01: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
|
|
|
}
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
static HRESULT WINAPI URLMoniker_IsEqual(IMoniker *iface, IMoniker *pmkOtherMoniker)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
2011-01-11 10:10:04 +01:00
|
|
|
URLMoniker *This = impl_from_IMoniker(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
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
TRACE("(%p,%p)\n",This, pmkOtherMoniker);
|
2004-03-31 21:58:09 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2012-07-27 11:15:05 +02:00
|
|
|
IBindCtx_Release(bind);
|
2004-03-31 21:58:09 +02:00
|
|
|
return res;
|
2002-08-13 20:20:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
static HRESULT WINAPI URLMoniker_Hash(IMoniker *iface, DWORD *pdwHash)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
2011-01-11 10:10:04 +01:00
|
|
|
URLMoniker *This = impl_from_IMoniker(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++];
|
|
|
|
}
|
2009-03-23 18:30:11 +01:00
|
|
|
}else {
|
2004-03-29 23:39:44 +02:00
|
|
|
/* 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
|
|
|
}
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
static HRESULT WINAPI URLMoniker_IsRunning(IMoniker* iface, IBindCtx* pbc,
|
|
|
|
IMoniker *pmkToLeft, IMoniker *pmkNewlyRunning)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
2011-01-11 10:10:04 +01:00
|
|
|
URLMoniker *This = impl_from_IMoniker(iface);
|
2002-08-13 20:20:24 +02:00
|
|
|
FIXME("(%p)->(%p,%p,%p): stub\n",This,pbc,pmkToLeft,pmkNewlyRunning);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
static HRESULT WINAPI URLMoniker_GetTimeOfLastChange(IMoniker *iface,
|
|
|
|
IBindCtx *pbc, IMoniker *pmkToLeft, FILETIME *pFileTime)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
2011-01-11 10:10:04 +01:00
|
|
|
URLMoniker *This = impl_from_IMoniker(iface);
|
2009-03-23 18:30:11 +01:00
|
|
|
FIXME("(%p)->(%p,%p,%p): stub\n", This, pbc, pmkToLeft, pFileTime);
|
2002-08-13 20:20:24 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
static HRESULT WINAPI URLMoniker_Inverse(IMoniker *iface, IMoniker **ppmk)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
2011-01-11 10:10:04 +01:00
|
|
|
URLMoniker *This = impl_from_IMoniker(iface);
|
2004-03-29 23:39:44 +02:00
|
|
|
TRACE("(%p,%p)\n",This,ppmk);
|
|
|
|
return MK_E_NOINVERSE;
|
2002-08-13 20:20:24 +02:00
|
|
|
}
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
static HRESULT WINAPI URLMoniker_CommonPrefixWith(IMoniker *iface, IMoniker *pmkOther, IMoniker **ppmkPrefix)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
2011-01-11 10:10:04 +01:00
|
|
|
URLMoniker *This = impl_from_IMoniker(iface);
|
2002-08-13 20:20:24 +02:00
|
|
|
FIXME("(%p)->(%p,%p): stub\n",This,pmkOther,ppmkPrefix);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
static HRESULT WINAPI URLMoniker_RelativePathTo(IMoniker *iface, IMoniker *pmOther, IMoniker **ppmkRelPath)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
2011-01-11 10:10:04 +01:00
|
|
|
URLMoniker *This = impl_from_IMoniker(iface);
|
2002-08-13 20:20:24 +02:00
|
|
|
FIXME("(%p)->(%p,%p): stub\n",This,pmOther,ppmkRelPath);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
static HRESULT WINAPI URLMoniker_GetDisplayName(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
|
|
|
|
LPOLESTR *ppszDisplayName)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
2011-01-11 10:10:04 +01:00
|
|
|
URLMoniker *This = impl_from_IMoniker(iface);
|
2004-03-29 23:39:44 +02:00
|
|
|
int len;
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
TRACE("(%p,%p,%p,%p)\n", This, pbc, pmkToLeft, ppszDisplayName);
|
2004-03-29 23:39:44 +02:00
|
|
|
|
|
|
|
if(!ppszDisplayName)
|
|
|
|
return E_INVALIDARG;
|
2009-03-23 18:30:47 +01:00
|
|
|
|
2009-03-23 18:31:05 +01:00
|
|
|
if(!This->URLName)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2004-03-29 23:39:44 +02:00
|
|
|
/* 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
|
|
|
|
*/
|
2011-06-22 19:22:20 +02:00
|
|
|
len = SysStringLen(This->URLName)+1;
|
2004-03-29 23:39:44 +02:00
|
|
|
*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
|
|
|
}
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
static HRESULT WINAPI URLMoniker_ParseDisplayName(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
|
|
|
|
LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
2011-01-11 10:10:04 +01:00
|
|
|
URLMoniker *This = impl_from_IMoniker(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;
|
|
|
|
}
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
static HRESULT WINAPI URLMoniker_IsSystemMoniker(IMoniker *iface, DWORD *pwdMksys)
|
2002-08-13 20:20:24 +02:00
|
|
|
{
|
2011-01-11 10:10:04 +01:00
|
|
|
URLMoniker *This = impl_from_IMoniker(iface);
|
2009-03-23 18:30:11 +01:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2009-03-23 18:30:11 +01:00
|
|
|
static const IMonikerVtbl URLMonikerVtbl =
|
2004-11-30 22:14:21 +01:00
|
|
|
{
|
2009-03-23 18:30:11 +01:00
|
|
|
URLMoniker_QueryInterface,
|
|
|
|
URLMoniker_AddRef,
|
|
|
|
URLMoniker_Release,
|
|
|
|
URLMoniker_GetClassID,
|
|
|
|
URLMoniker_IsDirty,
|
|
|
|
URLMoniker_Load,
|
|
|
|
URLMoniker_Save,
|
|
|
|
URLMoniker_GetSizeMax,
|
|
|
|
URLMoniker_BindToObject,
|
|
|
|
URLMoniker_BindToStorage,
|
|
|
|
URLMoniker_Reduce,
|
|
|
|
URLMoniker_ComposeWith,
|
|
|
|
URLMoniker_Enum,
|
|
|
|
URLMoniker_IsEqual,
|
|
|
|
URLMoniker_Hash,
|
|
|
|
URLMoniker_IsRunning,
|
|
|
|
URLMoniker_GetTimeOfLastChange,
|
|
|
|
URLMoniker_Inverse,
|
|
|
|
URLMoniker_CommonPrefixWith,
|
|
|
|
URLMoniker_RelativePathTo,
|
|
|
|
URLMoniker_GetDisplayName,
|
|
|
|
URLMoniker_ParseDisplayName,
|
|
|
|
URLMoniker_IsSystemMoniker
|
2004-11-30 22:14:21 +01:00
|
|
|
};
|
|
|
|
|
2010-12-20 15:15:00 +01:00
|
|
|
static inline URLMoniker *impl_from_IUriContainer(IUriContainer *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, URLMoniker, IUriContainer_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI UriContainer_QueryInterface(IUriContainer *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
URLMoniker *This = impl_from_IUriContainer(iface);
|
2011-01-11 10:10:04 +01:00
|
|
|
return IMoniker_QueryInterface(&This->IMoniker_iface, riid, ppv);
|
2010-12-20 15:15:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI UriContainer_AddRef(IUriContainer *iface)
|
|
|
|
{
|
|
|
|
URLMoniker *This = impl_from_IUriContainer(iface);
|
2011-01-11 10:10:04 +01:00
|
|
|
return IMoniker_AddRef(&This->IMoniker_iface);
|
2010-12-20 15:15:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI UriContainer_Release(IUriContainer *iface)
|
|
|
|
{
|
|
|
|
URLMoniker *This = impl_from_IUriContainer(iface);
|
2011-01-11 10:10:04 +01:00
|
|
|
return IMoniker_Release(&This->IMoniker_iface);
|
2010-12-20 15:15:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI UriContainer_GetIUri(IUriContainer *iface, IUri **ppIUri)
|
|
|
|
{
|
|
|
|
URLMoniker *This = impl_from_IUriContainer(iface);
|
|
|
|
|
2011-06-23 13:43:33 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, ppIUri);
|
2010-12-20 15:15:00 +01:00
|
|
|
|
2011-06-23 13:43:33 +02:00
|
|
|
if(!This->uri) {
|
|
|
|
*ppIUri = NULL;
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUri_AddRef(This->uri);
|
|
|
|
*ppIUri = This->uri;
|
|
|
|
return S_OK;
|
2010-12-20 15:15:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IUriContainerVtbl UriContainerVtbl = {
|
|
|
|
UriContainer_QueryInterface,
|
|
|
|
UriContainer_AddRef,
|
|
|
|
UriContainer_Release,
|
|
|
|
UriContainer_GetIUri
|
|
|
|
};
|
|
|
|
|
2011-06-23 13:43:11 +02:00
|
|
|
static HRESULT create_moniker(IUri *uri, URLMoniker **ret)
|
2009-03-23 18:30:47 +01:00
|
|
|
{
|
2011-06-23 13:43:11 +02:00
|
|
|
URLMoniker *mon;
|
2004-11-30 22:14:21 +01:00
|
|
|
HRESULT hres;
|
|
|
|
|
2011-06-23 13:43:11 +02:00
|
|
|
mon = heap_alloc(sizeof(*mon));
|
|
|
|
if(!mon)
|
|
|
|
return E_OUTOFMEMORY;
|
2004-11-30 22:14:21 +01:00
|
|
|
|
2011-06-23 13:43:11 +02:00
|
|
|
mon->IMoniker_iface.lpVtbl = &URLMonikerVtbl;
|
|
|
|
mon->IUriContainer_iface.lpVtbl = &UriContainerVtbl;
|
|
|
|
mon->ref = 1;
|
2005-12-26 13:27:10 +01:00
|
|
|
|
2011-06-23 13:43:11 +02:00
|
|
|
if(uri) {
|
|
|
|
/* FIXME: try to avoid it */
|
|
|
|
hres = IUri_GetDisplayUri(uri, &mon->URLName);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
heap_free(mon);
|
|
|
|
return hres;
|
|
|
|
}
|
2004-11-30 22:14:21 +01:00
|
|
|
|
2011-06-23 13:43:11 +02:00
|
|
|
IUri_AddRef(uri);
|
|
|
|
mon->uri = uri;
|
|
|
|
}else {
|
|
|
|
mon->URLName = NULL;
|
|
|
|
mon->uri = NULL;
|
|
|
|
}
|
2005-07-02 12:49:56 +02:00
|
|
|
|
2011-06-22 19:22:20 +02:00
|
|
|
URLMON_LockModule();
|
2011-06-23 13:43:11 +02:00
|
|
|
*ret = mon;
|
2004-11-30 22:14:21 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-03-23 18:30:47 +01:00
|
|
|
HRESULT StdURLMoniker_Construct(IUnknown *outer, void **ppv)
|
|
|
|
{
|
2011-06-23 13:43:11 +02:00
|
|
|
URLMoniker *mon;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2009-03-23 18:30:47 +01:00
|
|
|
TRACE("(%p %p)\n", outer, ppv);
|
|
|
|
|
2011-06-23 13:43:11 +02:00
|
|
|
hres = create_moniker(NULL, &mon);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
*ppv = &mon->IMoniker_iface;
|
|
|
|
return S_OK;
|
2009-03-23 18:30:47 +01:00
|
|
|
}
|
|
|
|
|
2011-06-23 13:43:22 +02:00
|
|
|
static const DWORD create_flags_map[3] = {
|
|
|
|
Uri_CREATE_FILE_USE_DOS_PATH, /* URL_MK_LEGACY */
|
|
|
|
0, /* URL_MK_UNIFORM */
|
|
|
|
Uri_CREATE_NO_CANONICALIZE /* URL_MK_NO_CANONICALIZE */
|
|
|
|
};
|
|
|
|
|
|
|
|
static const DWORD combine_flags_map[3] = {
|
|
|
|
URL_FILE_USE_PATHURL, /* URL_MK_LEGACY */
|
|
|
|
0, /* URL_MK_UNIFORM */
|
|
|
|
URL_DONT_SIMPLIFY /* URL_MK_NO_CANONICALIZE */
|
|
|
|
};
|
|
|
|
|
2002-05-05 21:40:57 +02:00
|
|
|
/***********************************************************************
|
2007-04-22 11:38:15 +02:00
|
|
|
* CreateURLMonikerEx (URLMON.@)
|
2002-05-05 21:40:57 +02:00
|
|
|
*
|
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.
|
2007-04-22 11:38:15 +02:00
|
|
|
* dwFlags [I] Flags.
|
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
|
|
|
*/
|
2007-04-22 11:38:15 +02:00
|
|
|
HRESULT WINAPI CreateURLMonikerEx(IMoniker *pmkContext, LPCWSTR szURL, IMoniker **ppmk, DWORD dwFlags)
|
2002-05-05 21:40:57 +02:00
|
|
|
{
|
2011-06-23 13:43:11 +02:00
|
|
|
IUri *uri, *base_uri = NULL;
|
2009-03-23 18:30:11 +01:00
|
|
|
URLMoniker *obj;
|
2002-08-13 20:20:24 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p, %s, %p, %08lx)\n", pmkContext, debugstr_w(szURL), ppmk, dwFlags);
|
2007-04-22 11:38:15 +02:00
|
|
|
|
2010-05-20 05:25:54 +02:00
|
|
|
if (ppmk)
|
|
|
|
*ppmk = NULL;
|
|
|
|
|
|
|
|
if (!szURL || !ppmk)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2018-07-05 17:22:32 +02:00
|
|
|
if(dwFlags >= ARRAY_SIZE(create_flags_map)) {
|
2022-02-18 09:18:16 +01:00
|
|
|
FIXME("Unsupported flags %lx\n", dwFlags);
|
2011-06-23 13:43:22 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
2002-08-13 20:20:24 +02:00
|
|
|
|
2004-05-03 22:07:03 +02:00
|
|
|
if(pmkContext) {
|
2011-06-23 13:43:11 +02:00
|
|
|
IUriContainer *uri_container;
|
|
|
|
|
|
|
|
hres = IMoniker_QueryInterface(pmkContext, &IID_IUriContainer, (void**)&uri_container);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
hres = IUriContainer_GetIUri(uri_container, &base_uri);
|
|
|
|
IUriContainer_Release(uri_container);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2004-05-03 22:07:03 +02:00
|
|
|
}
|
|
|
|
}
|
2011-06-23 13:43:11 +02:00
|
|
|
|
|
|
|
if(base_uri) {
|
2011-06-23 13:43:22 +02:00
|
|
|
hres = CoInternetCombineUrlEx(base_uri, szURL, combine_flags_map[dwFlags], &uri, 0);
|
2011-06-23 13:43:11 +02:00
|
|
|
IUri_Release(base_uri);
|
|
|
|
}else {
|
2011-06-23 13:43:22 +02:00
|
|
|
hres = CreateUri(szURL, Uri_CREATE_ALLOW_RELATIVE|Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME|create_flags_map[dwFlags], 0, &uri);
|
2011-06-23 13:43:11 +02:00
|
|
|
}
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = create_moniker(uri, &obj);
|
|
|
|
IUri_Release(uri);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
*ppmk = &obj->IMoniker_iface;
|
|
|
|
return S_OK;
|
2002-05-05 21:40:57 +02:00
|
|
|
}
|
|
|
|
|
2011-06-23 13:43:47 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* CreateURLMonikerEx2 (URLMON.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CreateURLMonikerEx2(IMoniker *pmkContext, IUri *pUri, IMoniker **ppmk, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
IUri *context_uri = NULL, *uri;
|
|
|
|
IUriContainer *uri_container;
|
|
|
|
URLMoniker *ret;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p %p %p %lx)\n", pmkContext, pUri, ppmk, dwFlags);
|
2011-06-23 13:43:47 +02:00
|
|
|
|
|
|
|
if (ppmk)
|
|
|
|
*ppmk = NULL;
|
|
|
|
|
|
|
|
if (!pUri || !ppmk)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2018-07-05 17:22:32 +02:00
|
|
|
if(dwFlags >= ARRAY_SIZE(create_flags_map)) {
|
2022-02-18 09:18:16 +01:00
|
|
|
FIXME("Unsupported flags %lx\n", dwFlags);
|
2011-06-23 13:43:47 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pmkContext) {
|
|
|
|
hres = IMoniker_QueryInterface(pmkContext, &IID_IUriContainer, (void**)&uri_container);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
hres = IUriContainer_GetIUri(uri_container, &context_uri);
|
|
|
|
if(FAILED(hres))
|
|
|
|
context_uri = NULL;
|
|
|
|
IUriContainer_Release(uri_container);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(context_uri) {
|
|
|
|
hres = CoInternetCombineIUri(context_uri, pUri, combine_flags_map[dwFlags], &uri, 0);
|
|
|
|
IUri_Release(context_uri);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}else {
|
|
|
|
uri = pUri;
|
|
|
|
IUri_AddRef(uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = create_moniker(uri, &ret);
|
|
|
|
IUri_Release(uri);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
*ppmk = &ret->IMoniker_iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-04-22 11:38:15 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* CreateURLMoniker (URLMON.@)
|
|
|
|
*
|
|
|
|
* Create a url moniker.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pmkContext [I] Context
|
|
|
|
* szURL [I] Url to create the moniker for
|
|
|
|
* ppmk [O] Destination for created moniker.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CreateURLMoniker(IMoniker *pmkContext, LPCWSTR szURL, IMoniker **ppmk)
|
|
|
|
{
|
|
|
|
return CreateURLMonikerEx(pmkContext, szURL, ppmk, URL_MK_LEGACY);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2005-12-26 12:59:42 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* BindAsyncMoniker (URLMON.@)
|
|
|
|
*
|
|
|
|
* Bind a bind status callback to an asynchronous URL Moniker.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pmk [I] Moniker object to bind status callback to
|
|
|
|
* grfOpt [I] Options, seems not used
|
|
|
|
* pbsc [I] Status callback to bind
|
|
|
|
* iidResult [I] Interface to return
|
|
|
|
* ppvResult [O] Resulting asynchronous moniker object
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: E_INVALIDARG, if any argument is invalid, or
|
|
|
|
* E_OUTOFMEMORY if memory allocation fails.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI BindAsyncMoniker(IMoniker *pmk, DWORD grfOpt, IBindStatusCallback *pbsc, REFIID iidResult, LPVOID *ppvResult)
|
|
|
|
{
|
|
|
|
LPBC pbc = NULL;
|
|
|
|
HRESULT hr = E_INVALIDARG;
|
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p %08lx %p %s %p)\n", pmk, grfOpt, pbsc, debugstr_guid(iidResult), ppvResult);
|
2007-12-28 01:59:25 +01:00
|
|
|
|
2005-12-26 12:59:42 +01:00
|
|
|
if (pmk && ppvResult)
|
|
|
|
{
|
|
|
|
*ppvResult = NULL;
|
|
|
|
|
|
|
|
hr = CreateAsyncBindCtx(0, pbsc, NULL, &pbc);
|
|
|
|
if (hr == NOERROR)
|
|
|
|
{
|
|
|
|
hr = IMoniker_BindToObject(pmk, pbc, NULL, iidResult, ppvResult);
|
|
|
|
IBindCtx_Release(pbc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2008-01-29 00:18:33 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MkParseDisplayNameEx (URLMON.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI MkParseDisplayNameEx(IBindCtx *pbc, LPCWSTR szDisplayName, ULONG *pchEaten, LPMONIKER *ppmk)
|
|
|
|
{
|
|
|
|
TRACE("(%p %s %p %p)\n", pbc, debugstr_w(szDisplayName), pchEaten, ppmk);
|
|
|
|
|
2010-05-20 17:36:32 +02:00
|
|
|
if (!pbc || !szDisplayName || !*szDisplayName || !pchEaten || !ppmk)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2008-01-29 00:18:33 +01:00
|
|
|
if(is_registered_protocol(szDisplayName)) {
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = CreateURLMoniker(NULL, szDisplayName, ppmk);
|
|
|
|
if(SUCCEEDED(hres)) {
|
2019-06-24 10:15:45 +02:00
|
|
|
*pchEaten = lstrlenW(szDisplayName);
|
2008-01-29 00:18:33 +01:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return MkParseDisplayName(pbc, szDisplayName, pchEaten, ppmk);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-10 12:04:21 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* URLDownloadToCacheFileA (URLMON.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI URLDownloadToCacheFileA(LPUNKNOWN lpUnkCaller, LPCSTR szURL, LPSTR szFileName,
|
|
|
|
DWORD dwBufLength, DWORD dwReserved, LPBINDSTATUSCALLBACK pBSC)
|
|
|
|
{
|
|
|
|
LPWSTR url = NULL, file_name = NULL;
|
|
|
|
int len;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p %s %p %ld %ld %p)\n", lpUnkCaller, debugstr_a(szURL), szFileName,
|
2005-11-10 12:04:21 +01:00
|
|
|
dwBufLength, dwReserved, pBSC);
|
|
|
|
|
|
|
|
if(szURL) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, szURL, -1, NULL, 0);
|
2007-11-29 22:12:34 +01:00
|
|
|
url = heap_alloc(len*sizeof(WCHAR));
|
2009-02-04 21:15:04 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, szURL, -1, url, len);
|
2005-11-10 12:04:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(szFileName)
|
2007-11-29 22:12:34 +01:00
|
|
|
file_name = heap_alloc(dwBufLength*sizeof(WCHAR));
|
2005-11-10 12:04:21 +01:00
|
|
|
|
|
|
|
hres = URLDownloadToCacheFileW(lpUnkCaller, url, file_name, dwBufLength*sizeof(WCHAR),
|
|
|
|
dwReserved, pBSC);
|
|
|
|
|
|
|
|
if(SUCCEEDED(hres) && file_name)
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, file_name, -1, szFileName, dwBufLength, NULL, NULL);
|
|
|
|
|
2007-11-29 22:12:34 +01:00
|
|
|
heap_free(url);
|
|
|
|
heap_free(file_name);
|
2005-11-10 12:04:21 +01:00
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* URLDownloadToCacheFileW (URLMON.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI URLDownloadToCacheFileW(LPUNKNOWN lpUnkCaller, LPCWSTR szURL, LPWSTR szFileName,
|
|
|
|
DWORD dwBufLength, DWORD dwReserved, LPBINDSTATUSCALLBACK pBSC)
|
|
|
|
{
|
2006-07-11 22:27:59 +02:00
|
|
|
WCHAR cache_path[MAX_PATH + 1];
|
|
|
|
FILETIME expire, modified;
|
|
|
|
HRESULT hr;
|
|
|
|
LPWSTR ext;
|
|
|
|
|
2020-12-03 00:32:46 +01:00
|
|
|
static WCHAR header[] = L"HTTP/1.0 200 OK\\r\\n\\r\\n";
|
2006-07-11 22:27:59 +02:00
|
|
|
|
2022-02-18 09:18:16 +01:00
|
|
|
TRACE("(%p, %s, %p, %ld, %ld, %p)\n", lpUnkCaller, debugstr_w(szURL),
|
2006-07-11 22:27:59 +02:00
|
|
|
szFileName, dwBufLength, dwReserved, pBSC);
|
|
|
|
|
|
|
|
if (!szURL || !szFileName)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
ext = PathFindExtensionW(szURL);
|
|
|
|
|
|
|
|
if (!CreateUrlCacheEntryW(szURL, 0, ext, cache_path, 0))
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
hr = URLDownloadToFileW(lpUnkCaller, szURL, cache_path, 0, pBSC);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
expire.dwHighDateTime = 0;
|
|
|
|
expire.dwLowDateTime = 0;
|
|
|
|
modified.dwHighDateTime = 0;
|
|
|
|
modified.dwLowDateTime = 0;
|
|
|
|
|
|
|
|
if (!CommitUrlCacheEntryW(szURL, cache_path, expire, modified, NORMAL_CACHE_ENTRY,
|
2007-02-07 08:06:41 +01:00
|
|
|
header, sizeof(header), NULL, NULL))
|
2006-07-11 22:27:59 +02:00
|
|
|
return E_FAIL;
|
|
|
|
|
2019-06-24 10:15:45 +02:00
|
|
|
if (lstrlenW(cache_path) > dwBufLength)
|
2006-07-11 22:27:59 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
lstrcpyW(szFileName, cache_path);
|
|
|
|
|
|
|
|
return S_OK;
|
2005-11-10 12:04:21 +01:00
|
|
|
}
|
|
|
|
|
2009-01-20 23:47:30 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* HlinkSimpleNavigateToMoniker (URLMON.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI HlinkSimpleNavigateToMoniker(IMoniker *pmkTarget,
|
|
|
|
LPCWSTR szLocation, LPCWSTR szTargetFrameName, IUnknown *pUnk,
|
|
|
|
IBindCtx *pbc, IBindStatusCallback *pbsc, DWORD grfHLNF, DWORD dwReserved)
|
|
|
|
{
|
2010-07-01 17:20:10 +02:00
|
|
|
LPWSTR target;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
hres = IMoniker_GetDisplayName(pmkTarget, pbc, 0, &target);
|
|
|
|
if(hres == S_OK)
|
|
|
|
hres = HlinkSimpleNavigateToString( target, szLocation, szTargetFrameName,
|
|
|
|
pUnk, pbc, pbsc, grfHLNF, dwReserved );
|
|
|
|
CoTaskMemFree(target);
|
|
|
|
|
|
|
|
return hres;
|
2009-01-20 23:47:30 +01:00
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2022-02-18 09:18:16 +01:00
|
|
|
FIXME("%s %s %s %p %p %p %lu %lu partial stub\n", debugstr_w( szTarget ), debugstr_w( szLocation ),
|
2010-06-28 21:16:51 +02:00
|
|
|
debugstr_w( szTargetFrameName ), pUnk, pbc, pbsc, grfHLNF, dwReserved);
|
|
|
|
|
|
|
|
/* undocumented: 0 means HLNF_OPENINNEWWINDOW*/
|
|
|
|
if (!grfHLNF) grfHLNF = HLNF_OPENINNEWWINDOW;
|
|
|
|
|
|
|
|
if (grfHLNF == HLNF_OPENINNEWWINDOW)
|
|
|
|
{
|
|
|
|
SHELLEXECUTEINFOW sei;
|
|
|
|
|
|
|
|
memset(&sei, 0, sizeof(sei));
|
|
|
|
sei.cbSize = sizeof(sei);
|
2020-12-03 00:32:46 +01:00
|
|
|
sei.lpVerb = L"open";
|
2010-06-28 21:16:51 +02:00
|
|
|
sei.nShow = SW_SHOWNORMAL;
|
|
|
|
sei.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NO_CONSOLE;
|
|
|
|
sei.lpFile = szTarget;
|
|
|
|
|
|
|
|
if (ShellExecuteExW(&sei)) return S_OK;
|
|
|
|
}
|
|
|
|
|
2004-07-13 01:48:39 +02:00
|
|
|
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;
|
|
|
|
}
|