2006-06-06 12:39:58 +02:00
|
|
|
/*
|
|
|
|
* Implementation of hyperlinking (hlink.dll)
|
|
|
|
*
|
|
|
|
* Copyright 2005 Aric Stewart for CodeWeavers
|
|
|
|
*
|
|
|
|
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2007-11-21 02:13:36 +01:00
|
|
|
#include "hlink_private.h"
|
2006-06-06 12:39:58 +02:00
|
|
|
|
2006-08-01 20:25:36 +02:00
|
|
|
#include "shellapi.h"
|
2007-11-21 02:13:36 +01:00
|
|
|
#include "hlguids.h"
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
2007-05-23 20:06:47 +02:00
|
|
|
|
2006-06-06 12:39:58 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(hlink);
|
|
|
|
|
2007-05-23 20:06:47 +02:00
|
|
|
#define HLINK_SAVE_MAGIC 0x00000002
|
|
|
|
#define HLINK_SAVE_MONIKER_PRESENT 0x01
|
|
|
|
#define HLINK_SAVE_MONIKER_IS_ABSOLUTE 0x02
|
|
|
|
#define HLINK_SAVE_LOCATION_PRESENT 0x08
|
|
|
|
#define HLINK_SAVE_FRIENDLY_PRESENT 0x10
|
|
|
|
/* 0x20, 0x40 unknown */
|
|
|
|
#define HLINK_SAVE_TARGET_FRAME_PRESENT 0x80
|
2007-05-23 20:07:29 +02:00
|
|
|
/* known flags */
|
|
|
|
#define HLINK_SAVE_ALL (HLINK_SAVE_TARGET_FRAME_PRESENT|HLINK_SAVE_FRIENDLY_PRESENT|HLINK_SAVE_LOCATION_PRESENT|0x04|HLINK_SAVE_MONIKER_IS_ABSOLUTE|HLINK_SAVE_MONIKER_PRESENT)
|
2007-05-23 20:06:47 +02:00
|
|
|
|
2006-06-06 12:39:58 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
2010-12-29 02:48:17 +01:00
|
|
|
IHlink IHlink_iface;
|
2006-06-06 12:39:58 +02:00
|
|
|
LONG ref;
|
|
|
|
|
2010-12-29 02:48:17 +01:00
|
|
|
IPersistStream IPersistStream_iface;
|
|
|
|
IDataObject IDataObject_iface;
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
LPWSTR FriendlyName;
|
|
|
|
LPWSTR Location;
|
|
|
|
LPWSTR TargetFrameName;
|
|
|
|
IMoniker *Moniker;
|
|
|
|
IHlinkSite *Site;
|
|
|
|
DWORD SiteData;
|
2007-05-23 20:06:47 +02:00
|
|
|
BOOL absolute;
|
2018-11-21 04:26:24 +01:00
|
|
|
|
|
|
|
IBindStatusCallback IBindStatusCallback_iface;
|
|
|
|
IBindStatusCallback *bind_callback;
|
|
|
|
IBindCtx *async_bind_ctx;
|
|
|
|
DWORD async_flags;
|
|
|
|
IHlinkBrowseContext *async_browse_ctx;
|
2006-06-06 12:39:58 +02:00
|
|
|
} HlinkImpl;
|
|
|
|
|
2010-12-29 02:48:17 +01:00
|
|
|
static inline HlinkImpl *impl_from_IHlink(IHlink *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HlinkImpl, IHlink_iface);
|
|
|
|
}
|
|
|
|
|
2006-06-06 12:39:58 +02:00
|
|
|
|
2010-12-29 02:48:17 +01:00
|
|
|
static inline HlinkImpl* impl_from_IPersistStream( IPersistStream* iface)
|
2006-06-06 12:39:58 +02:00
|
|
|
{
|
2010-12-29 02:48:17 +01:00
|
|
|
return CONTAINING_RECORD(iface, HlinkImpl, IPersistStream_iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
}
|
|
|
|
|
2010-12-29 02:48:17 +01:00
|
|
|
static inline HlinkImpl* impl_from_IDataObject( IDataObject* iface)
|
2006-06-06 12:39:58 +02:00
|
|
|
{
|
2010-12-29 02:48:17 +01:00
|
|
|
return CONTAINING_RECORD(iface, HlinkImpl, IDataObject_iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
}
|
|
|
|
|
2010-08-16 20:55:14 +02:00
|
|
|
static HRESULT __GetMoniker(HlinkImpl* This, IMoniker** moniker,
|
|
|
|
DWORD ref_type)
|
2006-06-06 12:39:58 +02:00
|
|
|
{
|
2010-08-16 20:55:14 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if (ref_type == HLINKGETREF_DEFAULT)
|
|
|
|
ref_type = HLINKGETREF_RELATIVE;
|
|
|
|
|
2012-02-03 20:17:49 +01:00
|
|
|
if (This->Moniker)
|
|
|
|
{
|
|
|
|
DWORD mktype = MKSYS_NONE;
|
|
|
|
|
|
|
|
hres = IMoniker_IsSystemMoniker(This->Moniker, &mktype);
|
|
|
|
if (hres == S_OK && mktype != MKSYS_NONE)
|
|
|
|
{
|
|
|
|
*moniker = This->Moniker;
|
|
|
|
IMoniker_AddRef(*moniker);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-16 20:55:14 +02:00
|
|
|
if (ref_type == HLINKGETREF_ABSOLUTE && This->Site)
|
2006-06-06 12:39:58 +02:00
|
|
|
{
|
2010-08-16 20:55:14 +02:00
|
|
|
IMoniker *hls_moniker;
|
|
|
|
|
|
|
|
hres = IHlinkSite_GetMoniker(This->Site, This->SiteData,
|
|
|
|
OLEGETMONIKER_FORCEASSIGN, OLEWHICHMK_CONTAINER, &hls_moniker);
|
|
|
|
if (FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if (This->Moniker)
|
|
|
|
{
|
|
|
|
hres = IMoniker_ComposeWith(hls_moniker, This->Moniker, FALSE,
|
|
|
|
moniker);
|
|
|
|
IMoniker_Release(hls_moniker);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
*moniker = hls_moniker;
|
|
|
|
return S_OK;
|
2006-06-06 12:39:58 +02:00
|
|
|
}
|
2010-08-16 20:55:14 +02:00
|
|
|
|
|
|
|
*moniker = This->Moniker;
|
|
|
|
if (*moniker)
|
|
|
|
IMoniker_AddRef(*moniker);
|
|
|
|
|
|
|
|
return S_OK;
|
2006-06-06 12:39:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IHlink_fnQueryInterface(IHlink* iface, REFIID riid,
|
|
|
|
LPVOID *ppvObj)
|
|
|
|
{
|
2010-12-29 02:48:17 +01:00
|
|
|
HlinkImpl *This = impl_from_IHlink(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
TRACE ("(%p)->(%s,%p)\n", This, debugstr_guid (riid), ppvObj);
|
|
|
|
|
|
|
|
*ppvObj = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) || (IsEqualIID(riid, &IID_IHlink)))
|
2017-02-13 12:16:03 +01:00
|
|
|
*ppvObj = &This->IHlink_iface;
|
2006-06-06 12:39:58 +02:00
|
|
|
else if (IsEqualIID(riid, &IID_IPersistStream))
|
2010-12-29 02:48:17 +01:00
|
|
|
*ppvObj = &This->IPersistStream_iface;
|
2006-06-06 12:39:58 +02:00
|
|
|
else if (IsEqualIID(riid, &IID_IDataObject))
|
2010-12-29 02:48:17 +01:00
|
|
|
*ppvObj = &This->IDataObject_iface;
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
if (*ppvObj)
|
|
|
|
{
|
|
|
|
IUnknown_AddRef((IUnknown*)(*ppvObj));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IHlink_fnAddRef (IHlink* iface)
|
|
|
|
{
|
2010-12-29 02:48:17 +01:00
|
|
|
HlinkImpl *This = impl_from_IHlink(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
ULONG refCount = InterlockedIncrement(&This->ref);
|
|
|
|
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("(%p)->(count=%lu)\n", This, refCount - 1);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
return refCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IHlink_fnRelease (IHlink* iface)
|
|
|
|
{
|
2010-12-29 02:48:17 +01:00
|
|
|
HlinkImpl *This = impl_from_IHlink(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
ULONG refCount = InterlockedDecrement(&This->ref);
|
|
|
|
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("(%p)->(count=%lu)\n", This, refCount + 1);
|
2006-06-06 12:39:58 +02:00
|
|
|
if (refCount)
|
|
|
|
return refCount;
|
|
|
|
|
|
|
|
TRACE("-- destroying IHlink (%p)\n", This);
|
2022-04-11 10:40:29 +02:00
|
|
|
free(This->FriendlyName);
|
|
|
|
free(This->TargetFrameName);
|
|
|
|
free(This->Location);
|
2006-06-06 12:39:58 +02:00
|
|
|
if (This->Moniker)
|
|
|
|
IMoniker_Release(This->Moniker);
|
|
|
|
if (This->Site)
|
|
|
|
IHlinkSite_Release(This->Site);
|
2022-04-11 10:40:29 +02:00
|
|
|
free(This);
|
2006-06-06 12:39:58 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IHlink_fnSetHlinkSite( IHlink* iface,
|
|
|
|
IHlinkSite* pihlSite, DWORD dwSiteData)
|
|
|
|
{
|
2010-12-29 02:48:17 +01:00
|
|
|
HlinkImpl *This = impl_from_IHlink(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("(%p)->(%p %li)\n", This, pihlSite, dwSiteData);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
if (This->Site)
|
|
|
|
IHlinkSite_Release(This->Site);
|
|
|
|
|
|
|
|
This->Site = pihlSite;
|
|
|
|
if (This->Site)
|
|
|
|
IHlinkSite_AddRef(This->Site);
|
|
|
|
|
|
|
|
This->SiteData = dwSiteData;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IHlink_fnGetHlinkSite( IHlink* iface,
|
|
|
|
IHlinkSite** ppihlSite, DWORD *pdwSiteData)
|
|
|
|
{
|
2010-12-29 02:48:17 +01:00
|
|
|
HlinkImpl *This = impl_from_IHlink(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p)\n", This, ppihlSite, pdwSiteData);
|
|
|
|
|
|
|
|
*ppihlSite = This->Site;
|
|
|
|
|
2010-11-01 18:06:08 +01:00
|
|
|
if (This->Site) {
|
2006-06-06 12:39:58 +02:00
|
|
|
IHlinkSite_AddRef(This->Site);
|
2010-11-01 18:06:08 +01:00
|
|
|
*pdwSiteData = This->SiteData;
|
|
|
|
}
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IHlink_fnSetMonikerReference( IHlink* iface,
|
|
|
|
DWORD rfHLSETF, IMoniker *pmkTarget, LPCWSTR pwzLocation)
|
|
|
|
{
|
2010-12-29 02:48:17 +01:00
|
|
|
HlinkImpl *This = impl_from_IHlink(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("(%p)->(%li %p %s)\n", This, rfHLSETF, pmkTarget,
|
2006-06-06 12:39:58 +02:00
|
|
|
debugstr_w(pwzLocation));
|
|
|
|
|
2009-10-20 23:33:27 +02:00
|
|
|
if(rfHLSETF == 0)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
if(!(rfHLSETF & (HLINKSETF_TARGET | HLINKSETF_LOCATION)))
|
|
|
|
return rfHLSETF;
|
|
|
|
|
|
|
|
if(rfHLSETF & HLINKSETF_TARGET){
|
|
|
|
if (This->Moniker)
|
|
|
|
IMoniker_Release(This->Moniker);
|
|
|
|
|
|
|
|
This->Moniker = pmkTarget;
|
|
|
|
if (This->Moniker)
|
|
|
|
{
|
2012-02-03 20:15:27 +01:00
|
|
|
IBindCtx *pbc;
|
2009-10-20 23:33:27 +02:00
|
|
|
LPOLESTR display_name;
|
|
|
|
IMoniker_AddRef(This->Moniker);
|
2012-02-03 20:15:27 +01:00
|
|
|
CreateBindCtx( 0, &pbc);
|
|
|
|
IMoniker_GetDisplayName(This->Moniker, pbc, NULL, &display_name);
|
|
|
|
IBindCtx_Release(pbc);
|
2019-06-05 08:37:02 +02:00
|
|
|
This->absolute = display_name && wcschr(display_name, ':');
|
2009-10-20 23:33:27 +02:00
|
|
|
CoTaskMemFree(display_name);
|
|
|
|
}
|
2007-05-23 20:06:47 +02:00
|
|
|
}
|
2006-06-06 12:39:58 +02:00
|
|
|
|
2009-10-20 23:33:27 +02:00
|
|
|
if(rfHLSETF & HLINKSETF_LOCATION){
|
2022-04-11 10:40:29 +02:00
|
|
|
free(This->Location);
|
|
|
|
This->Location = wcsdup( pwzLocation );
|
2009-10-20 23:33:27 +02:00
|
|
|
}
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IHlink_fnSetStringReference(IHlink* iface,
|
|
|
|
DWORD grfHLSETF, LPCWSTR pwzTarget, LPCWSTR pwzLocation)
|
|
|
|
{
|
2010-12-29 02:48:17 +01:00
|
|
|
HlinkImpl *This = impl_from_IHlink(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("(%p)->(%li %s %s)\n", This, grfHLSETF, debugstr_w(pwzTarget),
|
2006-06-06 12:39:58 +02:00
|
|
|
debugstr_w(pwzLocation));
|
|
|
|
|
2009-12-23 00:43:26 +01:00
|
|
|
if(grfHLSETF > (HLINKSETF_TARGET | HLINKSETF_LOCATION) &&
|
|
|
|
grfHLSETF < -(HLINKSETF_TARGET | HLINKSETF_LOCATION))
|
|
|
|
return grfHLSETF;
|
|
|
|
|
2006-06-06 12:39:58 +02:00
|
|
|
if (grfHLSETF & HLINKSETF_TARGET)
|
|
|
|
{
|
2009-12-30 18:43:05 +01:00
|
|
|
if (This->Moniker)
|
|
|
|
{
|
|
|
|
IMoniker_Release(This->Moniker);
|
|
|
|
This->Moniker = NULL;
|
|
|
|
}
|
|
|
|
if (pwzTarget && *pwzTarget)
|
|
|
|
{
|
|
|
|
IMoniker *pMon;
|
|
|
|
IBindCtx *pbc = NULL;
|
|
|
|
ULONG eaten;
|
|
|
|
HRESULT r;
|
|
|
|
|
|
|
|
r = CreateBindCtx(0, &pbc);
|
|
|
|
if (FAILED(r))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
r = MkParseDisplayName(pbc, pwzTarget, &eaten, &pMon);
|
|
|
|
IBindCtx_Release(pbc);
|
|
|
|
|
|
|
|
if (FAILED(r))
|
|
|
|
{
|
2019-06-05 08:37:02 +02:00
|
|
|
LPCWSTR p = wcschr(pwzTarget, ':');
|
2009-12-30 18:43:05 +01:00
|
|
|
if (p && (p - pwzTarget > 1))
|
|
|
|
r = CreateURLMoniker(NULL, pwzTarget, &pMon);
|
|
|
|
else
|
|
|
|
r = CreateFileMoniker(pwzTarget, &pMon);
|
|
|
|
if (FAILED(r))
|
|
|
|
{
|
2022-02-10 08:43:37 +01:00
|
|
|
ERR("couldn't create moniker for %s, failed with error 0x%08lx\n",
|
2009-12-30 18:43:05 +01:00
|
|
|
debugstr_w(pwzTarget), r);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IHlink_SetMonikerReference(iface, HLINKSETF_TARGET, pMon, NULL);
|
|
|
|
IMoniker_Release(pMon);
|
|
|
|
}
|
2006-06-06 12:39:58 +02:00
|
|
|
}
|
2009-12-30 18:43:05 +01:00
|
|
|
|
2006-06-06 12:39:58 +02:00
|
|
|
if (grfHLSETF & HLINKSETF_LOCATION)
|
|
|
|
{
|
2022-04-11 10:40:29 +02:00
|
|
|
free(This->Location);
|
2010-03-16 20:52:01 +01:00
|
|
|
This->Location = NULL;
|
|
|
|
if (pwzLocation && *pwzLocation)
|
2022-04-11 10:40:29 +02:00
|
|
|
This->Location = wcsdup( pwzLocation );
|
2006-06-06 12:39:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IHlink_fnGetMonikerReference(IHlink* iface,
|
|
|
|
DWORD dwWhichRef, IMoniker **ppimkTarget, LPWSTR *ppwzLocation)
|
|
|
|
{
|
2010-12-29 02:48:17 +01:00
|
|
|
HlinkImpl *This = impl_from_IHlink(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("(%p) -> (%li %p %p)\n", This, dwWhichRef, ppimkTarget,
|
2006-06-06 12:39:58 +02:00
|
|
|
ppwzLocation);
|
|
|
|
|
2010-08-16 20:55:14 +02:00
|
|
|
if (ppimkTarget)
|
|
|
|
{
|
|
|
|
HRESULT hres = __GetMoniker(This, ppimkTarget, dwWhichRef);
|
|
|
|
if (FAILED(hres))
|
|
|
|
{
|
|
|
|
if (ppwzLocation)
|
|
|
|
*ppwzLocation = NULL;
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
}
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
if (ppwzLocation)
|
|
|
|
IHlink_GetStringReference(iface, dwWhichRef, NULL, ppwzLocation);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IHlink_fnGetStringReference (IHlink* iface,
|
|
|
|
DWORD dwWhichRef, LPWSTR *ppwzTarget, LPWSTR *ppwzLocation)
|
|
|
|
{
|
2010-12-29 02:48:17 +01:00
|
|
|
HlinkImpl *This = impl_from_IHlink(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("(%p) -> (%li %p %p)\n", This, dwWhichRef, ppwzTarget, ppwzLocation);
|
2009-12-23 00:43:26 +01:00
|
|
|
|
|
|
|
if(dwWhichRef != -1 && dwWhichRef & ~(HLINKGETREF_DEFAULT | HLINKGETREF_ABSOLUTE | HLINKGETREF_RELATIVE))
|
|
|
|
{
|
|
|
|
if(ppwzTarget)
|
|
|
|
*ppwzTarget = NULL;
|
|
|
|
if(ppwzLocation)
|
|
|
|
*ppwzLocation = NULL;
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2006-06-06 12:39:58 +02:00
|
|
|
if (ppwzTarget)
|
|
|
|
{
|
2009-12-30 18:43:05 +01:00
|
|
|
IMoniker* mon;
|
2010-08-16 20:55:14 +02:00
|
|
|
HRESULT hres = __GetMoniker(This, &mon, dwWhichRef);
|
|
|
|
if (FAILED(hres))
|
|
|
|
{
|
|
|
|
if (ppwzLocation)
|
|
|
|
*ppwzLocation = NULL;
|
|
|
|
return hres;
|
|
|
|
}
|
2009-12-30 18:43:05 +01:00
|
|
|
if (mon)
|
2006-06-06 12:39:58 +02:00
|
|
|
{
|
2009-12-30 18:43:05 +01:00
|
|
|
IBindCtx *pbc;
|
2006-06-06 12:39:58 +02:00
|
|
|
|
2009-12-30 18:43:05 +01:00
|
|
|
CreateBindCtx( 0, &pbc);
|
|
|
|
IMoniker_GetDisplayName(mon, pbc, NULL, ppwzTarget);
|
|
|
|
IBindCtx_Release(pbc);
|
|
|
|
IMoniker_Release(mon);
|
2006-06-06 12:39:58 +02:00
|
|
|
}
|
2009-12-30 18:43:05 +01:00
|
|
|
else
|
|
|
|
*ppwzTarget = NULL;
|
2006-06-06 12:39:58 +02:00
|
|
|
}
|
|
|
|
if (ppwzLocation)
|
2007-11-21 02:13:58 +01:00
|
|
|
*ppwzLocation = hlink_co_strdupW( This->Location );
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
TRACE("(Target: %s Location: %s)\n",
|
|
|
|
(ppwzTarget)?debugstr_w(*ppwzTarget):"<NULL>",
|
|
|
|
(ppwzLocation)?debugstr_w(*ppwzLocation):"<NULL>");
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IHlink_fnSetFriendlyName (IHlink *iface,
|
|
|
|
LPCWSTR pwzFriendlyName)
|
|
|
|
{
|
2010-12-29 02:48:17 +01:00
|
|
|
HlinkImpl *This = impl_from_IHlink(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
TRACE("(%p) -> (%s)\n", This, debugstr_w(pwzFriendlyName));
|
|
|
|
|
2022-04-11 10:40:29 +02:00
|
|
|
free(This->FriendlyName);
|
|
|
|
This->FriendlyName = wcsdup( pwzFriendlyName );
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IHlink_fnGetFriendlyName (IHlink* iface,
|
|
|
|
DWORD grfHLFNAMEF, LPWSTR* ppwzFriendlyName)
|
|
|
|
{
|
2010-12-29 02:48:17 +01:00
|
|
|
HlinkImpl *This = impl_from_IHlink(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("(%p) -> (%li %p)\n", This, grfHLFNAMEF, ppwzFriendlyName);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
/* FIXME: Only using explicitly set and cached friendly names */
|
|
|
|
|
|
|
|
if (This->FriendlyName)
|
2007-11-21 02:13:58 +01:00
|
|
|
*ppwzFriendlyName = hlink_co_strdupW( This->FriendlyName );
|
2006-06-06 12:39:58 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
IMoniker *moniker;
|
2010-08-16 20:55:14 +02:00
|
|
|
HRESULT hres = __GetMoniker(This, &moniker, HLINKGETREF_DEFAULT);
|
|
|
|
if (FAILED(hres))
|
|
|
|
{
|
|
|
|
*ppwzFriendlyName = NULL;
|
|
|
|
return hres;
|
|
|
|
}
|
2006-06-06 12:39:58 +02:00
|
|
|
if (moniker)
|
|
|
|
{
|
|
|
|
IBindCtx *bcxt;
|
|
|
|
CreateBindCtx(0, &bcxt);
|
|
|
|
|
|
|
|
IMoniker_GetDisplayName(moniker, bcxt, NULL, ppwzFriendlyName);
|
|
|
|
IBindCtx_Release(bcxt);
|
|
|
|
IMoniker_Release(moniker);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*ppwzFriendlyName = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IHlink_fnSetTargetFrameName(IHlink* iface,
|
|
|
|
LPCWSTR pwzTargetFramename)
|
|
|
|
{
|
2010-12-29 02:48:17 +01:00
|
|
|
HlinkImpl *This = impl_from_IHlink(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_w(pwzTargetFramename));
|
|
|
|
|
2022-04-11 10:40:29 +02:00
|
|
|
free(This->TargetFrameName);
|
|
|
|
This->TargetFrameName = wcsdup( pwzTargetFramename );
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IHlink_fnGetTargetFrameName(IHlink* iface,
|
|
|
|
LPWSTR *ppwzTargetFrameName)
|
|
|
|
{
|
2010-12-29 02:48:17 +01:00
|
|
|
HlinkImpl *This = impl_from_IHlink(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, ppwzTargetFrameName);
|
2011-10-21 15:16:08 +02:00
|
|
|
|
|
|
|
if(!This->TargetFrameName) {
|
|
|
|
*ppwzTargetFrameName = NULL;
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2007-11-21 02:13:58 +01:00
|
|
|
*ppwzTargetFrameName = hlink_co_strdupW( This->TargetFrameName );
|
2011-10-21 15:16:08 +02:00
|
|
|
if(!*ppwzTargetFrameName)
|
|
|
|
return E_OUTOFMEMORY;
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IHlink_fnGetMiscStatus(IHlink* iface, DWORD* pdwStatus)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-11-21 04:26:23 +01:00
|
|
|
static HRESULT WINAPI IHlink_fnNavigate(IHlink *iface, DWORD flags, IBindCtx *user_bind_ctx,
|
|
|
|
IBindStatusCallback *bind_callback, IHlinkBrowseContext *browse_ctx)
|
2006-06-06 12:39:58 +02:00
|
|
|
{
|
2018-11-21 04:26:23 +01:00
|
|
|
HlinkImpl *This = impl_from_IHlink(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
IMoniker *mon = NULL;
|
2010-08-16 20:55:14 +02:00
|
|
|
HRESULT r;
|
2006-06-06 12:39:58 +02:00
|
|
|
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("hlink %p, flags %#lx, user_bind_ctx %p, bind_callback %p, browse_ctx %p.\n",
|
2018-11-21 04:26:23 +01:00
|
|
|
This, flags, user_bind_ctx, bind_callback, browse_ctx);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
2018-11-21 04:26:24 +01:00
|
|
|
if (This->async_bind_ctx)
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
2010-08-16 20:55:14 +02:00
|
|
|
r = __GetMoniker(This, &mon, HLINKGETREF_ABSOLUTE);
|
2006-06-06 12:39:58 +02:00
|
|
|
TRACE("Moniker %p\n", mon);
|
|
|
|
|
2010-08-16 20:55:14 +02:00
|
|
|
if (SUCCEEDED(r))
|
2006-06-06 12:39:58 +02:00
|
|
|
{
|
2018-11-21 04:26:23 +01:00
|
|
|
IBindCtx *bind_ctx = NULL;
|
2013-02-26 17:20:42 +01:00
|
|
|
IUnknown *unk = NULL;
|
|
|
|
IHlinkTarget *target;
|
2006-06-06 12:39:58 +02:00
|
|
|
|
2018-11-21 04:26:23 +01:00
|
|
|
if (browse_ctx)
|
2006-06-06 12:39:58 +02:00
|
|
|
{
|
2018-11-21 04:26:23 +01:00
|
|
|
r = IHlinkBrowseContext_GetObject(browse_ctx, mon, TRUE, &unk);
|
2018-01-27 22:30:32 +01:00
|
|
|
if (r != S_OK)
|
2017-11-30 17:21:02 +01:00
|
|
|
{
|
2018-11-21 04:26:23 +01:00
|
|
|
CreateBindCtx(0, &bind_ctx);
|
2018-11-21 04:26:24 +01:00
|
|
|
RegisterBindStatusCallback(bind_ctx, &This->IBindStatusCallback_iface, NULL, 0);
|
|
|
|
This->bind_callback = bind_callback;
|
2018-11-21 04:26:23 +01:00
|
|
|
r = IMoniker_BindToObject(mon, bind_ctx, NULL, &IID_IUnknown, (void**)&unk);
|
2018-11-21 04:26:24 +01:00
|
|
|
if (r == MK_S_ASYNCHRONOUS)
|
|
|
|
{
|
|
|
|
This->async_bind_ctx = bind_ctx;
|
|
|
|
This->async_flags = flags;
|
|
|
|
if (bind_callback)
|
|
|
|
IBindStatusCallback_AddRef(bind_callback);
|
|
|
|
IHlinkBrowseContext_AddRef(This->async_browse_ctx = browse_ctx);
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
return r;
|
|
|
|
}
|
2017-11-30 17:21:02 +01:00
|
|
|
}
|
|
|
|
if (r == S_OK)
|
|
|
|
{
|
|
|
|
r = IUnknown_QueryInterface(unk, &IID_IHlinkTarget, (void **)&target);
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
}
|
|
|
|
if (r == S_OK)
|
|
|
|
{
|
2018-11-21 04:26:23 +01:00
|
|
|
if (bind_ctx) IHlinkTarget_SetBrowseContext(target, browse_ctx);
|
|
|
|
r = IHlinkTarget_Navigate(target, flags, This->Location);
|
2017-11-30 17:21:02 +01:00
|
|
|
IHlinkTarget_Release(target);
|
|
|
|
}
|
|
|
|
|
2018-11-21 04:26:24 +01:00
|
|
|
RevokeBindStatusCallback(bind_ctx, &This->IBindStatusCallback_iface);
|
2018-11-21 04:26:23 +01:00
|
|
|
if (bind_ctx) IBindCtx_Release(bind_ctx);
|
2006-06-06 12:39:58 +02:00
|
|
|
}
|
2006-08-01 20:25:36 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
LPWSTR target = NULL;
|
|
|
|
|
|
|
|
r = IHlink_GetStringReference(iface, HLINKGETREF_DEFAULT, &target, NULL);
|
|
|
|
if (SUCCEEDED(r) && target)
|
|
|
|
{
|
2020-10-03 20:28:12 +02:00
|
|
|
ShellExecuteW(NULL, L"open", target, NULL, NULL, SW_SHOW);
|
2006-08-01 20:25:36 +02:00
|
|
|
CoTaskMemFree(target);
|
2017-11-30 17:21:02 +01:00
|
|
|
r = DRAGDROP_S_DROP;
|
2006-08-01 20:25:36 +02:00
|
|
|
}
|
|
|
|
}
|
2006-06-06 12:39:58 +02:00
|
|
|
IMoniker_Release(mon);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (This->Site)
|
2010-08-16 20:55:14 +02:00
|
|
|
IHlinkSite_OnNavigationComplete(This->Site, This->SiteData, 0, r, NULL);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
TRACE("Finished Navigation\n");
|
2010-08-16 20:55:14 +02:00
|
|
|
return r;
|
2006-06-06 12:39:58 +02:00
|
|
|
}
|
|
|
|
|
2012-05-14 01:05:07 +02:00
|
|
|
static HRESULT WINAPI IHlink_fnSetAdditionalParams(IHlink* iface,
|
2006-06-06 12:39:58 +02:00
|
|
|
LPCWSTR pwzAdditionalParams)
|
|
|
|
{
|
2008-09-11 03:19:23 +02:00
|
|
|
TRACE("Not implemented in native IHlink\n");
|
2006-06-06 12:39:58 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IHlink_fnGetAdditionalParams(IHlink* iface,
|
|
|
|
LPWSTR* ppwzAdditionalParams)
|
|
|
|
{
|
2008-09-11 03:19:23 +02:00
|
|
|
TRACE("Not implemented in native IHlink\n");
|
2006-06-06 12:39:58 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IHlinkVtbl hlvt =
|
|
|
|
{
|
|
|
|
IHlink_fnQueryInterface,
|
|
|
|
IHlink_fnAddRef,
|
|
|
|
IHlink_fnRelease,
|
|
|
|
IHlink_fnSetHlinkSite,
|
|
|
|
IHlink_fnGetHlinkSite,
|
|
|
|
IHlink_fnSetMonikerReference,
|
|
|
|
IHlink_fnGetMonikerReference,
|
|
|
|
IHlink_fnSetStringReference,
|
|
|
|
IHlink_fnGetStringReference,
|
|
|
|
IHlink_fnSetFriendlyName,
|
|
|
|
IHlink_fnGetFriendlyName,
|
|
|
|
IHlink_fnSetTargetFrameName,
|
|
|
|
IHlink_fnGetTargetFrameName,
|
|
|
|
IHlink_fnGetMiscStatus,
|
|
|
|
IHlink_fnNavigate,
|
2012-05-14 01:05:07 +02:00
|
|
|
IHlink_fnSetAdditionalParams,
|
2006-06-06 12:39:58 +02:00
|
|
|
IHlink_fnGetAdditionalParams
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDataObject_fnQueryInterface(IDataObject* iface,
|
|
|
|
REFIID riid, LPVOID *ppvObj)
|
|
|
|
{
|
2010-12-29 02:48:17 +01:00
|
|
|
HlinkImpl *This = impl_from_IDataObject(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
TRACE("%p\n", This);
|
2010-12-29 02:48:17 +01:00
|
|
|
return IHlink_QueryInterface(&This->IHlink_iface, riid, ppvObj);
|
2006-06-06 12:39:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IDataObject_fnAddRef (IDataObject* iface)
|
|
|
|
{
|
2010-12-29 02:48:17 +01:00
|
|
|
HlinkImpl *This = impl_from_IDataObject(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
TRACE("%p\n", This);
|
2010-12-29 02:48:17 +01:00
|
|
|
return IHlink_AddRef(&This->IHlink_iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IDataObject_fnRelease (IDataObject* iface)
|
|
|
|
{
|
2010-12-29 02:48:17 +01:00
|
|
|
HlinkImpl *This = impl_from_IDataObject(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
TRACE("%p\n", This);
|
2010-12-29 02:48:17 +01:00
|
|
|
return IHlink_Release(&This->IHlink_iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDataObject_fnGetData(IDataObject* iface,
|
|
|
|
FORMATETC* pformatetcIn, STGMEDIUM* pmedium)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDataObject_fnGetDataHere(IDataObject* iface,
|
|
|
|
FORMATETC* pformatetc, STGMEDIUM* pmedium)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDataObject_fnQueryGetData(IDataObject* iface,
|
|
|
|
FORMATETC* pformatetc)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDataObject_fnGetConicalFormatEtc(IDataObject* iface,
|
|
|
|
FORMATETC* pformatetcIn, FORMATETC* pformatetcOut)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDataObject_fnSetData(IDataObject* iface,
|
|
|
|
FORMATETC* pformatetc, STGMEDIUM* pmedium, BOOL fRelease)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDataObject_fnEnumFormatEtc(IDataObject* iface,
|
|
|
|
DWORD dwDirection, IEnumFORMATETC** ppenumFormatEtc)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDataObject_fnDAdvise(IDataObject* iface,
|
|
|
|
FORMATETC* pformatetc, DWORD advf, IAdviseSink* pAdvSink,
|
|
|
|
DWORD* pdwConnection)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDataObject_fnDUnadvise(IDataObject* iface,
|
|
|
|
DWORD dwConnection)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDataObject_fnEnumDAdvise(IDataObject* iface,
|
|
|
|
IEnumSTATDATA** ppenumAdvise)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDataObjectVtbl dovt =
|
|
|
|
{
|
|
|
|
IDataObject_fnQueryInterface,
|
|
|
|
IDataObject_fnAddRef,
|
|
|
|
IDataObject_fnRelease,
|
|
|
|
IDataObject_fnGetData,
|
|
|
|
IDataObject_fnGetDataHere,
|
|
|
|
IDataObject_fnQueryGetData,
|
|
|
|
IDataObject_fnGetConicalFormatEtc,
|
|
|
|
IDataObject_fnSetData,
|
|
|
|
IDataObject_fnEnumFormatEtc,
|
|
|
|
IDataObject_fnDAdvise,
|
|
|
|
IDataObject_fnDUnadvise,
|
|
|
|
IDataObject_fnEnumDAdvise
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI IPersistStream_fnQueryInterface(IPersistStream* iface,
|
|
|
|
REFIID riid, LPVOID *ppvObj)
|
|
|
|
{
|
2010-12-29 02:48:17 +01:00
|
|
|
HlinkImpl *This = impl_from_IPersistStream(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
TRACE("(%p)\n", This);
|
2010-12-29 02:48:17 +01:00
|
|
|
return IHlink_QueryInterface(&This->IHlink_iface, riid, ppvObj);
|
2006-06-06 12:39:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IPersistStream_fnAddRef (IPersistStream* iface)
|
|
|
|
{
|
2010-12-29 02:48:17 +01:00
|
|
|
HlinkImpl *This = impl_from_IPersistStream(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
TRACE("(%p)\n", This);
|
2010-12-29 02:48:17 +01:00
|
|
|
return IHlink_AddRef(&This->IHlink_iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IPersistStream_fnRelease (IPersistStream* iface)
|
|
|
|
{
|
2010-12-29 02:48:17 +01:00
|
|
|
HlinkImpl *This = impl_from_IPersistStream(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
TRACE("(%p)\n", This);
|
2010-12-29 02:48:17 +01:00
|
|
|
return IHlink_Release(&This->IHlink_iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IPersistStream_fnGetClassID(IPersistStream* iface,
|
|
|
|
CLSID* pClassID)
|
|
|
|
{
|
2010-12-29 02:48:17 +01:00
|
|
|
HlinkImpl *This = impl_from_IPersistStream(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
TRACE("(%p)\n", This);
|
2008-02-29 11:44:01 +01:00
|
|
|
*pClassID = CLSID_StdHlink;
|
2006-06-06 12:39:58 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IPersistStream_fnIsDirty(IPersistStream* iface)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2007-05-23 20:06:47 +02:00
|
|
|
static HRESULT write_hlink_string(IStream *pStm, LPCWSTR str)
|
|
|
|
{
|
|
|
|
DWORD len;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p, %s)\n", pStm, debugstr_w(str));
|
|
|
|
|
2019-06-05 08:37:02 +02:00
|
|
|
len = lstrlenW(str) + 1;
|
2007-05-23 20:06:47 +02:00
|
|
|
|
|
|
|
hr = IStream_Write(pStm, &len, sizeof(len), NULL);
|
2007-05-23 20:07:29 +02:00
|
|
|
if (FAILED(hr)) return hr;
|
2007-05-23 20:06:47 +02:00
|
|
|
|
|
|
|
hr = IStream_Write(pStm, str, len * sizeof(WCHAR), NULL);
|
2007-05-23 20:07:29 +02:00
|
|
|
if (FAILED(hr)) return hr;
|
2007-05-23 20:06:47 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline ULONG size_hlink_string(LPCWSTR str)
|
|
|
|
{
|
2019-06-05 08:37:02 +02:00
|
|
|
return sizeof(DWORD) + (lstrlenW(str) + 1) * sizeof(WCHAR);
|
2007-05-23 20:06:47 +02:00
|
|
|
}
|
|
|
|
|
2007-05-23 20:07:29 +02:00
|
|
|
static HRESULT read_hlink_string(IStream *pStm, LPWSTR *out_str)
|
|
|
|
{
|
|
|
|
LPWSTR str;
|
|
|
|
DWORD len;
|
|
|
|
ULONG read;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IStream_Read(pStm, &len, sizeof(len), &read);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
if (read != sizeof(len)) return STG_E_READFAULT;
|
|
|
|
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("read len %ld\n", len);
|
2007-05-23 20:07:29 +02:00
|
|
|
|
2022-04-11 10:40:29 +02:00
|
|
|
str = malloc(len * sizeof(WCHAR));
|
2007-05-23 20:07:29 +02:00
|
|
|
if (!str) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
hr = IStream_Read(pStm, str, len * sizeof(WCHAR), &read);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2022-04-11 10:40:29 +02:00
|
|
|
free(str);
|
2007-05-23 20:07:29 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
if (read != len * sizeof(WCHAR))
|
|
|
|
{
|
2022-04-11 10:40:29 +02:00
|
|
|
free(str);
|
2007-05-23 20:07:29 +02:00
|
|
|
return STG_E_READFAULT;
|
|
|
|
}
|
|
|
|
TRACE("read string %s\n", debugstr_w(str));
|
|
|
|
|
|
|
|
*out_str = str;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IPersistStream_fnLoad(IPersistStream* iface,
|
|
|
|
IStream* pStm)
|
|
|
|
{
|
|
|
|
HRESULT r;
|
|
|
|
DWORD hdr[2];
|
|
|
|
DWORD read;
|
2010-12-29 02:48:17 +01:00
|
|
|
HlinkImpl *This = impl_from_IPersistStream(iface);
|
2007-05-23 20:07:29 +02:00
|
|
|
|
2008-07-11 00:08:59 +02:00
|
|
|
r = IStream_Read(pStm, hdr, sizeof(hdr), &read);
|
2007-05-23 20:07:29 +02:00
|
|
|
if (read != sizeof(hdr) || (hdr[0] != HLINK_SAVE_MAGIC))
|
|
|
|
{
|
|
|
|
r = E_FAIL;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
if (hdr[1] & ~HLINK_SAVE_ALL)
|
2022-02-10 08:43:37 +01:00
|
|
|
FIXME("unknown flag(s) 0x%lx\n", hdr[1] & ~HLINK_SAVE_ALL);
|
2007-05-23 20:07:29 +02:00
|
|
|
|
|
|
|
if (hdr[1] & HLINK_SAVE_TARGET_FRAME_PRESENT)
|
|
|
|
{
|
|
|
|
TRACE("loading target frame name\n");
|
|
|
|
r = read_hlink_string(pStm, &This->TargetFrameName);
|
|
|
|
if (FAILED(r)) goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hdr[1] & HLINK_SAVE_FRIENDLY_PRESENT)
|
|
|
|
{
|
|
|
|
TRACE("loading target friendly name\n");
|
|
|
|
if (!(hdr[1] & 0x4))
|
|
|
|
FIXME("0x4 flag not present with friendly name flag - not sure what this means\n");
|
|
|
|
r = read_hlink_string(pStm, &This->FriendlyName);
|
|
|
|
if (FAILED(r)) goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hdr[1] & HLINK_SAVE_MONIKER_PRESENT)
|
|
|
|
{
|
|
|
|
TRACE("loading moniker\n");
|
|
|
|
r = OleLoadFromStream(pStm, &IID_IMoniker, (LPVOID*)&(This->Moniker));
|
|
|
|
if (FAILED(r))
|
|
|
|
goto end;
|
2012-08-13 11:44:12 +02:00
|
|
|
This->absolute = (hdr[1] & HLINK_SAVE_MONIKER_IS_ABSOLUTE) != 0;
|
2007-05-23 20:07:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hdr[1] & HLINK_SAVE_LOCATION_PRESENT)
|
|
|
|
{
|
|
|
|
TRACE("loading location\n");
|
|
|
|
r = read_hlink_string(pStm, &This->Location);
|
|
|
|
if (FAILED(r)) goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("Load Result 0x%lx (%p)\n", r, This->Moniker);
|
2007-05-23 20:07:29 +02:00
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2006-06-06 12:39:58 +02:00
|
|
|
static HRESULT WINAPI IPersistStream_fnSave(IPersistStream* iface,
|
|
|
|
IStream* pStm, BOOL fClearDirty)
|
|
|
|
{
|
2010-08-16 20:55:14 +02:00
|
|
|
HRESULT r;
|
2010-12-29 02:48:17 +01:00
|
|
|
HlinkImpl *This = impl_from_IPersistStream(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
DWORD hdr[2];
|
|
|
|
IMoniker *moniker;
|
|
|
|
|
2007-05-23 20:06:47 +02:00
|
|
|
TRACE("(%p) Moniker(%p)\n", This, This->Moniker);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
2010-08-16 20:55:14 +02:00
|
|
|
r = __GetMoniker(This, &moniker, HLINKGETREF_DEFAULT);
|
|
|
|
if (FAILED(r))
|
|
|
|
return r;
|
|
|
|
r = E_FAIL;
|
2007-05-23 20:06:47 +02:00
|
|
|
|
|
|
|
hdr[0] = HLINK_SAVE_MAGIC;
|
|
|
|
hdr[1] = 0;
|
|
|
|
|
2006-06-06 12:39:58 +02:00
|
|
|
if (moniker)
|
2007-05-23 20:06:47 +02:00
|
|
|
hdr[1] |= HLINK_SAVE_MONIKER_PRESENT;
|
|
|
|
if (This->absolute)
|
|
|
|
hdr[1] |= HLINK_SAVE_MONIKER_IS_ABSOLUTE;
|
|
|
|
if (This->Location)
|
|
|
|
hdr[1] |= HLINK_SAVE_LOCATION_PRESENT;
|
|
|
|
if (This->FriendlyName)
|
|
|
|
hdr[1] |= HLINK_SAVE_FRIENDLY_PRESENT | 4 /* FIXME */;
|
|
|
|
if (This->TargetFrameName)
|
|
|
|
hdr[1] |= HLINK_SAVE_TARGET_FRAME_PRESENT;
|
|
|
|
|
2008-07-11 00:08:59 +02:00
|
|
|
IStream_Write(pStm, hdr, sizeof(hdr), NULL);
|
2007-05-23 20:06:47 +02:00
|
|
|
|
|
|
|
if (This->TargetFrameName)
|
2006-06-06 12:39:58 +02:00
|
|
|
{
|
2007-05-23 20:06:47 +02:00
|
|
|
r = write_hlink_string(pStm, This->TargetFrameName);
|
|
|
|
if (FAILED(r)) goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (This->FriendlyName)
|
|
|
|
{
|
|
|
|
r = write_hlink_string(pStm, This->FriendlyName);
|
|
|
|
if (FAILED(r)) goto end;
|
|
|
|
}
|
2006-06-06 12:39:58 +02:00
|
|
|
|
2007-05-23 20:06:47 +02:00
|
|
|
if (moniker)
|
|
|
|
{
|
|
|
|
IPersistStream* monstream;
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
monstream = NULL;
|
|
|
|
IMoniker_QueryInterface(moniker, &IID_IPersistStream,
|
|
|
|
(LPVOID*)&monstream);
|
|
|
|
if (monstream)
|
|
|
|
{
|
|
|
|
r = OleSaveToStream(monstream, pStm);
|
|
|
|
IPersistStream_Release(monstream);
|
|
|
|
}
|
2007-05-23 20:07:29 +02:00
|
|
|
if (FAILED(r)) goto end;
|
2006-06-06 12:39:58 +02:00
|
|
|
}
|
2007-05-23 20:06:47 +02:00
|
|
|
|
|
|
|
if (This->Location)
|
|
|
|
{
|
|
|
|
r = write_hlink_string(pStm, This->Location);
|
|
|
|
if (FAILED(r)) goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
2007-05-23 20:07:29 +02:00
|
|
|
if (moniker) IMoniker_Release(moniker);
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("Save Result 0x%lx\n", r);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IPersistStream_fnGetSizeMax(IPersistStream* iface,
|
|
|
|
ULARGE_INTEGER* pcbSize)
|
|
|
|
{
|
2010-08-16 20:55:14 +02:00
|
|
|
HRESULT r;
|
2010-12-29 02:48:17 +01:00
|
|
|
HlinkImpl *This = impl_from_IPersistStream(iface);
|
2006-06-06 12:39:58 +02:00
|
|
|
IMoniker *moniker;
|
|
|
|
|
2007-05-23 20:06:47 +02:00
|
|
|
TRACE("(%p) Moniker(%p)\n", This, This->Moniker);
|
|
|
|
|
|
|
|
pcbSize->QuadPart = sizeof(DWORD)*2;
|
|
|
|
|
|
|
|
if (This->TargetFrameName)
|
|
|
|
pcbSize->QuadPart += size_hlink_string(This->TargetFrameName);
|
|
|
|
|
|
|
|
if (This->FriendlyName)
|
|
|
|
pcbSize->QuadPart += size_hlink_string(This->FriendlyName);
|
2006-06-06 12:39:58 +02:00
|
|
|
|
2010-08-16 20:55:14 +02:00
|
|
|
r = __GetMoniker(This, &moniker, HLINKGETREF_DEFAULT);
|
|
|
|
if (FAILED(r))
|
|
|
|
return r;
|
|
|
|
r = E_FAIL;
|
|
|
|
|
2006-06-06 12:39:58 +02:00
|
|
|
if (moniker)
|
|
|
|
{
|
|
|
|
IPersistStream* monstream = NULL;
|
|
|
|
IMoniker_QueryInterface(moniker, &IID_IPersistStream,
|
|
|
|
(LPVOID*)&monstream);
|
|
|
|
if (monstream)
|
|
|
|
{
|
2007-05-23 20:06:47 +02:00
|
|
|
ULARGE_INTEGER mon_size;
|
|
|
|
r = IPersistStream_GetSizeMax(monstream, &mon_size);
|
|
|
|
pcbSize->QuadPart += mon_size.QuadPart;
|
2006-06-06 12:39:58 +02:00
|
|
|
IPersistStream_Release(monstream);
|
|
|
|
}
|
|
|
|
IMoniker_Release(moniker);
|
|
|
|
}
|
|
|
|
|
2007-05-23 20:06:47 +02:00
|
|
|
if (This->Location)
|
|
|
|
pcbSize->QuadPart += size_hlink_string(This->Location);
|
|
|
|
|
2006-06-06 12:39:58 +02:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IPersistStreamVtbl psvt =
|
|
|
|
{
|
|
|
|
IPersistStream_fnQueryInterface,
|
|
|
|
IPersistStream_fnAddRef,
|
|
|
|
IPersistStream_fnRelease,
|
|
|
|
IPersistStream_fnGetClassID,
|
|
|
|
IPersistStream_fnIsDirty,
|
|
|
|
IPersistStream_fnLoad,
|
|
|
|
IPersistStream_fnSave,
|
|
|
|
IPersistStream_fnGetSizeMax,
|
|
|
|
};
|
2011-10-21 15:11:55 +02:00
|
|
|
|
2018-11-21 04:26:24 +01:00
|
|
|
static HlinkImpl *impl_from_IBindStatusCallback(IBindStatusCallback *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HlinkImpl, IBindStatusCallback_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI bind_callback_QueryInterface(IBindStatusCallback *iface, REFIID iid, void **out)
|
|
|
|
{
|
|
|
|
if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IBindStatusCallback))
|
|
|
|
{
|
|
|
|
IBindStatusCallback_AddRef(*out = iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("No interface for %s.\n", debugstr_guid(iid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI bind_callback_AddRef(IBindStatusCallback *iface)
|
|
|
|
{
|
|
|
|
HlinkImpl *hlink = impl_from_IBindStatusCallback(iface);
|
|
|
|
return IHlink_AddRef(&hlink->IHlink_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI bind_callback_Release(IBindStatusCallback *iface)
|
|
|
|
{
|
|
|
|
HlinkImpl *hlink = impl_from_IBindStatusCallback(iface);
|
|
|
|
return IHlink_Release(&hlink->IHlink_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI bind_callback_OnStartBinding(IBindStatusCallback *iface,
|
|
|
|
DWORD reserved, IBinding *binding)
|
|
|
|
{
|
|
|
|
HlinkImpl *hlink = impl_from_IBindStatusCallback(iface);
|
|
|
|
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("hlink %p, reserved %#lx, binding %p.\n", hlink, reserved, binding);
|
2018-11-21 04:26:24 +01:00
|
|
|
|
|
|
|
if (hlink->bind_callback)
|
|
|
|
return IBindStatusCallback_OnStartBinding(hlink->bind_callback, reserved, binding);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI bind_callback_GetPriority(IBindStatusCallback *iface, LONG *priority)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, priority %p, stub!\n", iface, priority);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI bind_callback_OnLowResource(IBindStatusCallback *iface, DWORD reserved)
|
|
|
|
{
|
|
|
|
HlinkImpl *hlink = impl_from_IBindStatusCallback(iface);
|
|
|
|
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("hlink %p, reserved %#lx.\n", hlink, reserved);
|
2018-11-21 04:26:24 +01:00
|
|
|
|
|
|
|
if (hlink->bind_callback)
|
|
|
|
return IBindStatusCallback_OnLowResource(hlink->bind_callback, reserved);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI bind_callback_OnProgress(IBindStatusCallback *iface,
|
|
|
|
ULONG progress, ULONG max, ULONG status, const WCHAR *text)
|
|
|
|
{
|
|
|
|
HlinkImpl *hlink = impl_from_IBindStatusCallback(iface);
|
|
|
|
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("hlink %p, progress %lu, max %lu, status %lu, text %s.\n",
|
2018-11-21 04:26:24 +01:00
|
|
|
hlink, progress, max, status, debugstr_w(text));
|
|
|
|
|
|
|
|
if (hlink->bind_callback)
|
|
|
|
return IBindStatusCallback_OnProgress(hlink->bind_callback, progress, max, status, text);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI bind_callback_OnStopBinding(IBindStatusCallback *iface,
|
|
|
|
HRESULT hr, const WCHAR *error)
|
|
|
|
{
|
|
|
|
HlinkImpl *hlink = impl_from_IBindStatusCallback(iface);
|
|
|
|
|
2022-02-10 08:43:37 +01:00
|
|
|
TRACE("hlink %p, hr %#lx, error %s.\n", hlink, hr, debugstr_w(error));
|
2018-11-21 04:26:24 +01:00
|
|
|
|
|
|
|
if (hlink->bind_callback)
|
|
|
|
IBindStatusCallback_OnStopBinding(hlink->bind_callback, hr, error);
|
|
|
|
|
|
|
|
if (hlink->async_bind_ctx)
|
|
|
|
{
|
|
|
|
if (hlink->bind_callback)
|
|
|
|
IBindStatusCallback_Release(hlink->bind_callback);
|
|
|
|
RevokeBindStatusCallback(hlink->async_bind_ctx, iface);
|
|
|
|
IBindCtx_Release(hlink->async_bind_ctx);
|
|
|
|
IHlinkBrowseContext_Release(hlink->async_browse_ctx);
|
|
|
|
hlink->async_bind_ctx = NULL;
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI bind_callback_GetBindInfo(IBindStatusCallback *iface,
|
|
|
|
DWORD *bind_flags, BINDINFO *bind_info)
|
|
|
|
{
|
|
|
|
HlinkImpl *hlink = impl_from_IBindStatusCallback(iface);
|
|
|
|
|
|
|
|
TRACE("hlink %p, bind_flags %p, bind_info %p.\n", hlink, bind_flags, bind_info);
|
|
|
|
|
|
|
|
if (hlink->bind_callback)
|
|
|
|
return IBindStatusCallback_GetBindInfo(hlink->bind_callback, bind_flags, bind_info);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI bind_callback_OnDataAvailable(IBindStatusCallback *iface,
|
|
|
|
DWORD flags, DWORD size, FORMATETC *formatetc, STGMEDIUM *stgmed)
|
|
|
|
{
|
2022-02-10 08:43:37 +01:00
|
|
|
FIXME("iface %p, flags %#lx, size %ld, formatetc %p, stgmed %p, stub!\n",
|
2018-11-21 04:26:24 +01:00
|
|
|
iface, flags, size, formatetc, stgmed);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI bind_callback_OnObjectAvailable(IBindStatusCallback *iface,
|
|
|
|
REFIID iid, IUnknown *unk)
|
|
|
|
{
|
|
|
|
HlinkImpl *hlink = impl_from_IBindStatusCallback(iface);
|
|
|
|
IHlinkTarget *target;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("hlink %p, iid %s, unk %p.\n", hlink, debugstr_guid(iid), unk);
|
|
|
|
|
|
|
|
if (hlink->bind_callback)
|
|
|
|
IBindStatusCallback_OnObjectAvailable(hlink->bind_callback, iid, unk);
|
|
|
|
|
|
|
|
if (hlink->async_bind_ctx)
|
|
|
|
{
|
|
|
|
hr = IUnknown_QueryInterface(unk, &IID_IHlinkTarget, (void **)&target);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
IHlinkTarget_SetBrowseContext(target, hlink->async_browse_ctx);
|
|
|
|
hr = IHlinkTarget_Navigate(target, hlink->async_flags, hlink->Location);
|
|
|
|
IHlinkTarget_Release(target);
|
|
|
|
|
|
|
|
if (hlink->Site)
|
|
|
|
IHlinkSite_OnNavigationComplete(hlink->Site, hlink->SiteData, 0, hr, NULL);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IBindStatusCallbackVtbl bind_callback_vtbl =
|
|
|
|
{
|
|
|
|
bind_callback_QueryInterface,
|
|
|
|
bind_callback_AddRef,
|
|
|
|
bind_callback_Release,
|
|
|
|
bind_callback_OnStartBinding,
|
|
|
|
bind_callback_GetPriority,
|
|
|
|
bind_callback_OnLowResource,
|
|
|
|
bind_callback_OnProgress,
|
|
|
|
bind_callback_OnStopBinding,
|
|
|
|
bind_callback_GetBindInfo,
|
|
|
|
bind_callback_OnDataAvailable,
|
|
|
|
bind_callback_OnObjectAvailable,
|
|
|
|
};
|
|
|
|
|
2011-10-21 15:12:09 +02:00
|
|
|
HRESULT HLink_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv)
|
2011-10-21 15:11:55 +02:00
|
|
|
{
|
|
|
|
HlinkImpl * hl;
|
2022-04-11 10:40:31 +02:00
|
|
|
HRESULT hr;
|
2011-10-21 15:11:55 +02:00
|
|
|
|
|
|
|
TRACE("unkOut=%p riid=%s\n", pUnkOuter, debugstr_guid(riid));
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if (pUnkOuter)
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
|
2022-04-11 10:40:29 +02:00
|
|
|
if (!(hl = calloc(1, sizeof(*hl))))
|
2011-10-21 15:11:55 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
hl->ref = 1;
|
|
|
|
hl->IHlink_iface.lpVtbl = &hlvt;
|
|
|
|
hl->IPersistStream_iface.lpVtbl = &psvt;
|
|
|
|
hl->IDataObject_iface.lpVtbl = &dovt;
|
2018-11-21 04:26:24 +01:00
|
|
|
hl->IBindStatusCallback_iface.lpVtbl = &bind_callback_vtbl;
|
2011-10-21 15:11:55 +02:00
|
|
|
|
2022-04-11 10:40:31 +02:00
|
|
|
hr = IHlink_QueryInterface(&hl->IHlink_iface, riid, ppv);
|
|
|
|
IHlink_Release(&hl->IHlink_iface);
|
|
|
|
|
|
|
|
return hr;
|
2011-10-21 15:11:55 +02:00
|
|
|
}
|