2 * Implementation of hyperlinking (hlink.dll)
4 * Copyright 2005 Aric Stewart for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "hlink_private.h"
23 #include "wine/debug.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(hlink);
27 static const IHlinkBrowseContextVtbl hlvt;
31 IHlinkBrowseContext IHlinkBrowseContext_iface;
33 HLBWINFO* BrowseWindowInfo;
37 static inline HlinkBCImpl *impl_from_IHlinkBrowseContext(IHlinkBrowseContext *iface)
39 return CONTAINING_RECORD(iface, HlinkBCImpl, IHlinkBrowseContext_iface);
43 HRESULT WINAPI HLinkBrowseContext_Constructor(IUnknown *pUnkOuter, REFIID riid,
48 TRACE("unkOut=%p riid=%s\n", pUnkOuter, debugstr_guid(riid));
52 return CLASS_E_NOAGGREGATION;
54 hl = heap_alloc_zero(sizeof(HlinkBCImpl));
59 hl->IHlinkBrowseContext_iface.lpVtbl = &hlvt;
65 static HRESULT WINAPI IHlinkBC_fnQueryInterface( IHlinkBrowseContext *iface,
66 REFIID riid, LPVOID* ppvObj)
68 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
69 TRACE ("(%p)->(%s,%p)\n", This, debugstr_guid (riid), ppvObj);
71 if (IsEqualIID(riid, &IID_IUnknown) ||
72 IsEqualIID(riid, &IID_IHlinkBrowseContext))
77 IUnknown_AddRef((IUnknown*)(*ppvObj));
83 static ULONG WINAPI IHlinkBC_fnAddRef (IHlinkBrowseContext* iface)
85 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
86 ULONG refCount = InterlockedIncrement(&This->ref);
88 TRACE("(%p)->(count=%u)\n", This, refCount - 1);
93 static ULONG WINAPI IHlinkBC_fnRelease (IHlinkBrowseContext* iface)
95 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
96 ULONG refCount = InterlockedDecrement(&This->ref);
98 TRACE("(%p)->(count=%u)\n", This, refCount + 1);
102 TRACE("-- destroying IHlinkBrowseContext (%p)\n", This);
103 heap_free(This->BrowseWindowInfo);
104 if (This->CurrentPage)
105 IHlink_Release(This->CurrentPage);
110 static HRESULT WINAPI IHlinkBC_Register(IHlinkBrowseContext* iface,
111 DWORD dwReserved, IUnknown *piunk, IMoniker *pimk, DWORD *pdwRegister)
113 static const WCHAR szIdent[] = {'W','I','N','E','H','L','I','N','K',0};
114 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
117 IRunningObjectTable *ROT;
119 FIXME("(%p)->(%i %p %p %p)\n", This, dwReserved, piunk, pimk, pdwRegister);
121 CreateItemMoniker(NULL, szIdent, &mon);
122 CreateGenericComposite(mon, pimk, &composite);
124 GetRunningObjectTable(0, &ROT);
125 IRunningObjectTable_Register(ROT, 0, piunk, composite, pdwRegister);
127 IRunningObjectTable_Release(ROT);
128 IMoniker_Release(composite);
129 IMoniker_Release(mon);
134 static HRESULT WINAPI IHlinkBC_GetObject(IHlinkBrowseContext* face,
135 IMoniker *pimk, BOOL fBindifRootRegistered, IUnknown **ppiunk)
141 static HRESULT WINAPI IHlinkBC_Revoke(IHlinkBrowseContext* iface,
145 IRunningObjectTable *ROT;
146 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
148 FIXME("(%p)->(%i)\n", This, dwRegister);
150 GetRunningObjectTable(0, &ROT);
151 r = IRunningObjectTable_Revoke(ROT, dwRegister);
152 IRunningObjectTable_Release(ROT);
157 static HRESULT WINAPI IHlinkBC_SetBrowseWindowInfo(IHlinkBrowseContext* iface,
160 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
161 TRACE("(%p)->(%p)\n", This, phlbwi);
166 heap_free(This->BrowseWindowInfo);
167 This->BrowseWindowInfo = heap_alloc(phlbwi->cbSize);
168 memcpy(This->BrowseWindowInfo, phlbwi, phlbwi->cbSize);
173 static HRESULT WINAPI IHlinkBC_GetBrowseWindowInfo(IHlinkBrowseContext* iface,
176 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
177 TRACE("(%p)->(%p)\n", This, phlbwi);
182 if(!This->BrowseWindowInfo)
185 memcpy(phlbwi, This->BrowseWindowInfo, This->BrowseWindowInfo->cbSize);
190 static HRESULT WINAPI IHlinkBC_SetInitialHlink(IHlinkBrowseContext* iface,
191 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName)
193 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
195 FIXME("(%p)->(%p %s %s)\n", This, pimkTarget,
196 debugstr_w(pwzLocation), debugstr_w(pwzFriendlyName));
198 if (This->CurrentPage)
199 IHlink_Release(This->CurrentPage);
201 HlinkCreateFromMoniker(pimkTarget, pwzLocation, pwzFriendlyName, NULL,
202 0, NULL, &IID_IHlink, (LPVOID*) &This->CurrentPage);
207 static HRESULT WINAPI IHlinkBC_OnNavigateHlink(IHlinkBrowseContext *iface,
208 DWORD grfHLNF, IMoniker* pmkTarget, LPCWSTR pwzLocation, LPCWSTR
209 pwzFriendlyName, ULONG *puHLID)
211 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
213 FIXME("(%p)->(%i %p %s %s %p)\n", This, grfHLNF, pmkTarget,
214 debugstr_w(pwzLocation), debugstr_w(pwzFriendlyName), puHLID);
219 static HRESULT WINAPI IHlinkBC_UpdateHlink(IHlinkBrowseContext* iface,
220 ULONG uHLID, IMoniker* pimkTarget, LPCWSTR pwzLocation,
221 LPCWSTR pwzFriendlyName)
227 static HRESULT WINAPI IHlinkBC_EnumNavigationStack( IHlinkBrowseContext *iface,
228 DWORD dwReserved, DWORD grfHLFNAMEF, IEnumHLITEM** ppienumhlitem)
234 static HRESULT WINAPI IHlinkBC_QueryHlink( IHlinkBrowseContext* iface,
235 DWORD grfHLONG, ULONG uHLID)
241 static HRESULT WINAPI IHlinkBC_GetHlink( IHlinkBrowseContext* iface,
242 ULONG uHLID, IHlink** ppihl)
244 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
246 TRACE("(%p)->(%x %p)\n", This, uHLID, ppihl);
248 if(uHLID != HLID_CURRENT) {
249 FIXME("Only HLID_CURRENT implemented, given: %x\n", uHLID);
253 *ppihl = This->CurrentPage;
254 IHlink_AddRef(*ppihl);
259 static HRESULT WINAPI IHlinkBC_SetCurrentHlink( IHlinkBrowseContext* iface,
266 static HRESULT WINAPI IHlinkBC_Clone( IHlinkBrowseContext* iface,
267 IUnknown* piunkOuter, REFIID riid, IUnknown** ppiunkOjb)
273 static HRESULT WINAPI IHlinkBC_Close(IHlinkBrowseContext* iface,
280 static const IHlinkBrowseContextVtbl hlvt =
282 IHlinkBC_fnQueryInterface,
288 IHlinkBC_SetBrowseWindowInfo,
289 IHlinkBC_GetBrowseWindowInfo,
290 IHlinkBC_SetInitialHlink,
291 IHlinkBC_OnNavigateHlink,
292 IHlinkBC_UpdateHlink,
293 IHlinkBC_EnumNavigationStack,
296 IHlinkBC_SetCurrentHlink,