Commit 58709d22 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

hlink: Add a basic implementation (based on work by Aric Stewart).

parent b732e9b4
......@@ -8,7 +8,9 @@ DELAYIMPORTS = urlmon
EXTRALIBS = -luuid $(LIBUNICODE)
C_SRCS = \
hlink_main.c
browse_ctx.c \
hlink_main.c \
link.c
@MAKE_DLL_RULES@
......
/*
* 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
*/
#include <stdarg.h>
#define COBJMACROS
#include "winerror.h"
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"
#include "unknwn.h"
#include "objidl.h"
#include "wine/debug.h"
#include "hlink.h"
WINE_DEFAULT_DEBUG_CHANNEL(hlink);
static const IHlinkBrowseContextVtbl hlvt;
typedef struct
{
const IHlinkBrowseContextVtbl *lpVtbl;
LONG ref;
HLBWINFO* BrowseWindowInfo;
IHlink* CurrentPage;
} HlinkBCImpl;
HRESULT WINAPI HLinkBrowseContext_Constructor(IUnknown *pUnkOuter, REFIID riid,
LPVOID *ppv)
{
HlinkBCImpl * hl;
TRACE("unkOut=%p riid=%s\n", pUnkOuter, debugstr_guid(riid));
*ppv = NULL;
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
hl = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(HlinkBCImpl));
if (!hl)
return E_OUTOFMEMORY;
hl->ref = 1;
hl->lpVtbl = &hlvt;
*ppv = hl;
return S_OK;
}
static HRESULT WINAPI IHlinkBC_fnQueryInterface( IHlinkBrowseContext *iface,
REFIID riid, LPVOID* ppvObj)
{
HlinkBCImpl *This = (HlinkBCImpl*)iface;
TRACE ("(%p)->(%s,%p)\n", This, debugstr_guid (riid), ppvObj);
if (IsEqualIID(riid, &IID_IUnknown) ||
IsEqualIID(riid, &IID_IHlinkBrowseContext))
*ppvObj = This;
if (*ppvObj)
{
IUnknown_AddRef((IUnknown*)(*ppvObj));
return S_OK;
}
return E_NOINTERFACE;
}
static ULONG WINAPI IHlinkBC_fnAddRef (IHlinkBrowseContext* iface)
{
HlinkBCImpl *This = (HlinkBCImpl*)iface;
ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p)->(count=%lu)\n", This, refCount - 1);
return refCount;
}
static ULONG WINAPI IHlinkBC_fnRelease (IHlinkBrowseContext* iface)
{
HlinkBCImpl *This = (HlinkBCImpl*)iface;
ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p)->(count=%lu)\n", This, refCount + 1);
if (refCount)
return refCount;
TRACE("-- destroying IHlinkBrowseContext (%p)\n", This);
HeapFree(GetProcessHeap(), 0, This->BrowseWindowInfo);
if (This->CurrentPage)
IHlink_Release(This->CurrentPage);
HeapFree(GetProcessHeap(), 0, This);
return 0;
}
static HRESULT WINAPI IHlinkBC_Register(IHlinkBrowseContext* iface,
DWORD dwReserved, IUnknown *piunk, IMoniker *pimk, DWORD *pdwRegister)
{
static const WCHAR szIdent[] = {'W','I','N','E','H','L','I','N','K',0};
HlinkBCImpl *This = (HlinkBCImpl*)iface;
IMoniker *mon;
IMoniker *composite;
IRunningObjectTable *ROT;
FIXME("(%p)->(%li %p %p %p)\n", This, dwReserved, piunk, pimk, pdwRegister);
CreateItemMoniker(NULL, szIdent, &mon);
CreateGenericComposite(mon, pimk, &composite);
GetRunningObjectTable(0, &ROT);
IRunningObjectTable_Register(ROT, 0, piunk, composite, pdwRegister);
IRunningObjectTable_Release(ROT);
IMoniker_Release(composite);
IMoniker_Release(mon);
return S_OK;
}
static HRESULT WINAPI IHlinkBC_GetObject(IHlinkBrowseContext* face,
IMoniker *pimk, BOOL fBindifRootRegistered, IUnknown **ppiunk)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT WINAPI IHlinkBC_Revoke(IHlinkBrowseContext* iface,
DWORD dwRegister)
{
HRESULT r = S_OK;
IRunningObjectTable *ROT;
HlinkBCImpl *This = (HlinkBCImpl*)iface;
FIXME("(%p)->(%li)\n", This, dwRegister);
GetRunningObjectTable(0, &ROT);
r = IRunningObjectTable_Revoke(ROT, dwRegister);
IRunningObjectTable_Release(ROT);
return r;
}
static HRESULT WINAPI IHlinkBC_SetBrowseWindowInfo(IHlinkBrowseContext* iface,
HLBWINFO *phlbwi)
{
HlinkBCImpl *This = (HlinkBCImpl*)iface;
TRACE("(%p)->(%p)\n", This, phlbwi);
HeapFree(GetProcessHeap(), 0, This->BrowseWindowInfo);
This->BrowseWindowInfo = HeapAlloc(GetProcessHeap(), 0, phlbwi->cbSize);
memcpy(This->BrowseWindowInfo, phlbwi, phlbwi->cbSize);
return S_OK;
}
static HRESULT WINAPI IHlinkBC_GetBrowseWindowInfo(IHlinkBrowseContext* iface,
HLBWINFO *phlbwi)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT WINAPI IHlinkBC_SetInitialHlink(IHlinkBrowseContext* iface,
IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName)
{
HlinkBCImpl *This = (HlinkBCImpl*)iface;
FIXME("(%p)->(%p %s %s)\n", This, pimkTarget,
debugstr_w(pwzLocation), debugstr_w(pwzFriendlyName));
if (This->CurrentPage)
IHlink_Release(This->CurrentPage);
HlinkCreateFromMoniker(pimkTarget, pwzLocation, pwzFriendlyName, NULL,
0, NULL, &IID_IHlink, (LPVOID*) &This->CurrentPage);
return S_OK;
}
static HRESULT WINAPI IHlinkBC_OnNavigateHlink(IHlinkBrowseContext *iface,
DWORD grfHLNF, IMoniker* pmkTarget, LPCWSTR pwzLocation, LPCWSTR
pwzFriendlyName, ULONG *puHLID)
{
HlinkBCImpl *This = (HlinkBCImpl*)iface;
FIXME("(%p)->(%li %p %s %s %p)\n", This, grfHLNF, pmkTarget,
debugstr_w(pwzLocation), debugstr_w(pwzFriendlyName), puHLID);
return S_OK;
}
static HRESULT WINAPI IHlinkBC_UpdateHlink(IHlinkBrowseContext* iface,
ULONG uHLID, IMoniker* pimkTarget, LPCWSTR pwzLocation,
LPCWSTR pwzFriendlyName)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT WINAPI IHlinkBC_EnumNavigationStack( IHlinkBrowseContext *iface,
DWORD dwReserved, DWORD grfHLFNAMEF, IEnumHLITEM** ppienumhlitem)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT WINAPI IHlinkBC_QueryHlink( IHlinkBrowseContext* iface,
DWORD grfHLONG, ULONG uHLID)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT WINAPI IHlinkBC_GetHlink( IHlinkBrowseContext* iface,
ULONG uHLID, IHlink** ppihl)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT WINAPI IHlinkBC_SetCurrentHlink( IHlinkBrowseContext* iface,
ULONG uHLID)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT WINAPI IHlinkBC_Clone( IHlinkBrowseContext* iface,
IUnknown* piunkOuter, REFIID riid, IUnknown** ppiunkOjb)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT WINAPI IHlinkBC_Close(IHlinkBrowseContext* iface,
DWORD reserverd)
{
FIXME("\n");
return E_NOTIMPL;
}
static const IHlinkBrowseContextVtbl hlvt =
{
IHlinkBC_fnQueryInterface,
IHlinkBC_fnAddRef,
IHlinkBC_fnRelease,
IHlinkBC_Register,
IHlinkBC_GetObject,
IHlinkBC_Revoke,
IHlinkBC_SetBrowseWindowInfo,
IHlinkBC_GetBrowseWindowInfo,
IHlinkBC_SetInitialHlink,
IHlinkBC_OnNavigateHlink,
IHlinkBC_UpdateHlink,
IHlinkBC_EnumNavigationStack,
IHlinkBC_QueryHlink,
IHlinkBC_GetHlink,
IHlinkBC_SetCurrentHlink,
IHlinkBC_Clone,
IHlinkBC_Close
};
......@@ -32,8 +32,21 @@
#include "wine/debug.h"
#include "hlink.h"
#include "initguid.h"
#include "hlguids.h"
WINE_DEFAULT_DEBUG_CHANNEL(hlink);
extern HRESULT WINAPI HLink_Constructor(IUnknown *, REFIID, LPVOID*);
extern HRESULT WINAPI HLinkBrowseContext_Constructor(IUnknown *, REFIID, LPVOID*);
typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown*, REFIID, LPVOID*);
typedef struct
{
const IClassFactoryVtbl *lpVtbl;
LPFNCREATEINSTANCE lpfnCI;
} CFImpl;
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
......@@ -62,49 +75,136 @@ HRESULT WINAPI HlinkCreateFromMoniker( IMoniker *pimkTrgt, LPCWSTR pwzLocation,
LPCWSTR pwzFriendlyName, IHlinkSite* pihlsite, DWORD dwSiteData,
IUnknown* piunkOuter, REFIID riid, void** ppvObj)
{
FIXME("%p %s %s %p %li %p %s %p\n", pimkTrgt, debugstr_w(pwzLocation),
debugstr_w(pwzFriendlyName), pihlsite, dwSiteData, piunkOuter,
debugstr_guid(riid), ppvObj);
IHlink *hl = NULL;
HRESULT r = S_OK;
return E_NOTIMPL;
TRACE("%p %s %s %p %li %p %s %p\n", pimkTrgt, debugstr_w(pwzLocation),
debugstr_w(pwzFriendlyName), pihlsite, dwSiteData, piunkOuter,
debugstr_guid(riid), ppvObj);
r = CoCreateInstance(&CLSID_StdHlink, piunkOuter, CLSCTX_INPROC_SERVER, riid, ppvObj);
if (FAILED(r))
return r;
if (pwzLocation)
IHlink_SetStringReference(hl, HLINKSETF_LOCATION, NULL, pwzLocation);
if (pwzFriendlyName)
IHlink_SetFriendlyName(hl, pwzFriendlyName);
if (pihlsite)
IHlink_SetHlinkSite(hl, pihlsite, dwSiteData);
if (pimkTrgt)
IHlink_SetMonikerReference(hl, 0, pimkTrgt, pwzLocation);
*ppvObj = hl;
TRACE("Returning %li\n",r);
return r;
}
HRESULT WINAPI HlinkCreateFromString( LPCWSTR pwzTarget, LPCWSTR pwzLocation,
LPCWSTR pwzFriendlyName, IHlinkSite* pihlsite, DWORD dwSiteData,
IUnknown* piunkOuter, REFIID riid, void** ppvObj)
{
FIXME("%s %s %s %p %li %p %s %p\n", debugstr_w(pwzTarget),
debugstr_w(pwzLocation), debugstr_w(pwzFriendlyName), pihlsite,
dwSiteData, piunkOuter, debugstr_guid(riid), ppvObj);
IHlink *hl = NULL;
HRESULT r = S_OK;
return E_NOTIMPL;
TRACE("%s %s %s %p %li %p %s %p\n", debugstr_w(pwzTarget),
debugstr_w(pwzLocation), debugstr_w(pwzFriendlyName), pihlsite,
dwSiteData, piunkOuter, debugstr_guid(riid), ppvObj);
r = CoCreateInstance(&CLSID_StdHlink, piunkOuter, CLSCTX_INPROC_SERVER, riid, (LPVOID*)&hl);
if (FAILED(r))
return r;
if (pwzLocation)
IHlink_SetStringReference(hl, HLINKSETF_LOCATION, NULL, pwzLocation);
if (pwzTarget)
{
IMoniker *pTgtMk = NULL;
IBindCtx *pbc = NULL;
ULONG eaten;
CreateBindCtx(0, &pbc);
r = MkParseDisplayName(pbc, pwzTarget, &eaten, &pTgtMk);
IBindCtx_Release(pbc);
if (FAILED(r))
{
FIXME("ParseDisplayName failed, falling back to file\n");
r = CreateFileMoniker(pwzTarget,&pTgtMk);
}
if (pTgtMk)
{
IHlink_SetMonikerReference(hl, 0, pTgtMk, pwzLocation);
IMoniker_Release(pTgtMk);
}
else
FIXME("Unable to come up with a moniker, expect problems\n");
IHlink_SetStringReference(hl, HLINKSETF_TARGET, pwzTarget, NULL);
}
if (pwzFriendlyName)
IHlink_SetFriendlyName(hl, pwzFriendlyName);
if (pihlsite)
IHlink_SetHlinkSite(hl, pihlsite, dwSiteData);
TRACE("Returning %li\n",r);
*ppvObj = hl;
return r;
}
HRESULT WINAPI HlinkCreateBrowseContext( IUnknown* piunkOuter, REFIID riid, void** ppvObj)
{
FIXME("%p %s %p\n", piunkOuter, debugstr_guid(riid), ppvObj);
HRESULT r = S_OK;
return E_NOTIMPL;
TRACE("%p %s %p\n", piunkOuter, debugstr_guid(riid), ppvObj);
r = CoCreateInstance(&CLSID_StdHlinkBrowseContext, piunkOuter, CLSCTX_INPROC_SERVER, riid, ppvObj);
TRACE("returning %li\n",r);
return r;
}
HRESULT WINAPI HlinkNavigate(IHlink *phl, IHlinkFrame *phlFrame,
DWORD grfHLNF, LPBC pbc, IBindStatusCallback *pbsc,
IHlinkBrowseContext *phlbc)
{
FIXME("%p %p %li %p %p %p\n", phl, phlFrame, grfHLNF, pbc, pbsc, phlbc);
HRESULT r = S_OK;
return E_NOTIMPL;
TRACE("%p %p %li %p %p %p\n", phl, phlFrame, grfHLNF, pbc, pbsc, phlbc);
if (phlFrame)
r = IHlinkFrame_Navigate(phlFrame, grfHLNF, pbc, pbsc, phl);
else if (phl)
r = IHlink_Navigate(phl, grfHLNF, pbc, pbsc, phlbc);
return r;
}
HRESULT WINAPI HlinkOnNavigate( IHlinkFrame *phlFrame,
IHlinkBrowseContext* phlbc, DWORD grfHLNF, IMoniker *pmkTarget,
LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName, ULONG* puHLID)
{
FIXME("%p %p %li %p %s %s %p\n",phlFrame, phlbc, grfHLNF, pmkTarget,
debugstr_w(pwzLocation), debugstr_w(pwzFriendlyName), puHLID);
HRESULT r = S_OK;
return E_NOTIMPL;
TRACE("%p %p %li %p %s %s %p\n",phlFrame, phlbc, grfHLNF, pmkTarget,
debugstr_w(pwzLocation), debugstr_w(pwzFriendlyName), puHLID);
r = IHlinkBrowseContext_OnNavigateHlink(phlbc, grfHLNF, pmkTarget,
pwzLocation, pwzFriendlyName, puHLID);
if (phlFrame)
r = IHlinkFrame_OnNavigate(phlFrame,grfHLNF,pmkTarget, pwzLocation,
pwzFriendlyName, 0);
return r;
}
HRESULT WINAPI HlinkCreateFromData(IDataObject *piDataObj,
......@@ -113,7 +213,13 @@ HRESULT WINAPI HlinkCreateFromData(IDataObject *piDataObj,
{
FIXME("%p %p %ld %p %p %p\n",
piDataObj, pihlsite, dwSiteData, piunkOuter, riid, ppvObj);
*ppvObj = NULL;
return E_NOTIMPL;
}
HRESULT WINAPI HlinkQueryCreateFromData(IDataObject* piDataObj)
{
FIXME("%p\n", piDataObj);
return E_NOTIMPL;
}
......@@ -124,17 +230,85 @@ HRESULT WINAPI HlinkCreateExtensionServices(LPCWSTR pwzAdditionalHeaders,
FIXME("%s %p %s %s %p %s %p\n",debugstr_w(pwzAdditionalHeaders),
phwnd, debugstr_w(pszUsername), debugstr_w(pszPassword),
punkOuter, debugstr_guid(riid), ppvObj);
return E_NOTIMPL;
}
static HRESULT WINAPI HLinkCF_fnQueryInterface ( LPCLASSFACTORY iface,
REFIID riid, LPVOID *ppvObj)
{
CFImpl *This = (CFImpl *)iface;
TRACE("(%p)->(%s)\n",This,debugstr_guid(riid));
*ppvObj = NULL;
if (IsEqualIID(riid, &IID_IUnknown) ||
IsEqualIID(riid, &IID_IClassFactory))
{
*ppvObj = This;
return S_OK;
}
TRACE("-- E_NOINTERFACE\n");
return E_NOINTERFACE;
}
static ULONG WINAPI HLinkCF_fnAddRef (LPCLASSFACTORY iface)
{
return 2;
}
static ULONG WINAPI HLinkCF_fnRelease(LPCLASSFACTORY iface)
{
return 1;
}
static HRESULT WINAPI HLinkCF_fnCreateInstance( LPCLASSFACTORY iface,
LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject)
{
CFImpl *This = (CFImpl *)iface;
TRACE("%p->(%p,%s,%p)\n", This, pUnkOuter, debugstr_guid(riid), ppvObject);
*ppvObject = NULL;
return This->lpfnCI(pUnkOuter, riid, ppvObject);
}
static HRESULT WINAPI HLinkCF_fnLockServer(LPCLASSFACTORY iface, BOOL fLock)
{
FIXME("%p %d\n", iface, fLock);
return E_NOTIMPL;
}
static const IClassFactoryVtbl hlcfvt =
{
HLinkCF_fnQueryInterface,
HLinkCF_fnAddRef,
HLinkCF_fnRelease,
HLinkCF_fnCreateInstance,
HLinkCF_fnLockServer
};
static CFImpl HLink_cf = { &hlcfvt, &HLink_Constructor };
static CFImpl HLinkBrowseContext_cf = { &hlcfvt, &HLinkBrowseContext_Constructor };
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
{
FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
IClassFactory *pcf = NULL;
TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
if (!ppv)
return E_INVALIDARG;
*ppv = NULL;
return CLASS_E_CLASSNOTAVAILABLE;
if (IsEqualIID(rclsid, &CLSID_StdHlink))
pcf = (IClassFactory*) &HLink_cf;
else if (IsEqualIID(rclsid, &CLSID_StdHlinkBrowseContext))
pcf = (IClassFactory*) &HLinkBrowseContext_cf;
else
return CLASS_E_CLASSNOTAVAILABLE;
return IClassFactory_QueryInterface(pcf, iid, ppv);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment