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
);
29 IHlinkBrowseContext IHlinkBrowseContext_iface
;
31 HLBWINFO
* BrowseWindowInfo
;
35 static inline HlinkBCImpl
*impl_from_IHlinkBrowseContext(IHlinkBrowseContext
*iface
)
37 return CONTAINING_RECORD(iface
, HlinkBCImpl
, IHlinkBrowseContext_iface
);
40 static HRESULT WINAPI
IHlinkBC_fnQueryInterface( IHlinkBrowseContext
*iface
,
41 REFIID riid
, LPVOID
* ppvObj
)
43 HlinkBCImpl
*This
= impl_from_IHlinkBrowseContext(iface
);
44 TRACE ("(%p)->(%s,%p)\n", This
, debugstr_guid (riid
), ppvObj
);
46 if (IsEqualIID(riid
, &IID_IUnknown
) ||
47 IsEqualIID(riid
, &IID_IHlinkBrowseContext
))
52 IUnknown_AddRef((IUnknown
*)(*ppvObj
));
58 static ULONG WINAPI
IHlinkBC_fnAddRef (IHlinkBrowseContext
* iface
)
60 HlinkBCImpl
*This
= impl_from_IHlinkBrowseContext(iface
);
61 ULONG refCount
= InterlockedIncrement(&This
->ref
);
63 TRACE("(%p)->(count=%u)\n", This
, refCount
- 1);
68 static ULONG WINAPI
IHlinkBC_fnRelease (IHlinkBrowseContext
* iface
)
70 HlinkBCImpl
*This
= impl_from_IHlinkBrowseContext(iface
);
71 ULONG refCount
= InterlockedDecrement(&This
->ref
);
73 TRACE("(%p)->(count=%u)\n", This
, refCount
+ 1);
77 TRACE("-- destroying IHlinkBrowseContext (%p)\n", This
);
78 heap_free(This
->BrowseWindowInfo
);
79 if (This
->CurrentPage
)
80 IHlink_Release(This
->CurrentPage
);
85 static HRESULT WINAPI
IHlinkBC_Register(IHlinkBrowseContext
* iface
,
86 DWORD dwReserved
, IUnknown
*piunk
, IMoniker
*pimk
, DWORD
*pdwRegister
)
88 static const WCHAR szIdent
[] = {'W','I','N','E','H','L','I','N','K',0};
89 HlinkBCImpl
*This
= impl_from_IHlinkBrowseContext(iface
);
92 IRunningObjectTable
*ROT
;
94 FIXME("(%p)->(%i %p %p %p)\n", This
, dwReserved
, piunk
, pimk
, pdwRegister
);
96 CreateItemMoniker(NULL
, szIdent
, &mon
);
97 CreateGenericComposite(mon
, pimk
, &composite
);
99 GetRunningObjectTable(0, &ROT
);
100 IRunningObjectTable_Register(ROT
, 0, piunk
, composite
, pdwRegister
);
102 IRunningObjectTable_Release(ROT
);
103 IMoniker_Release(composite
);
104 IMoniker_Release(mon
);
109 static HRESULT WINAPI
IHlinkBC_GetObject(IHlinkBrowseContext
* face
,
110 IMoniker
*pimk
, BOOL fBindifRootRegistered
, IUnknown
**ppiunk
)
116 static HRESULT WINAPI
IHlinkBC_Revoke(IHlinkBrowseContext
* iface
,
120 IRunningObjectTable
*ROT
;
121 HlinkBCImpl
*This
= impl_from_IHlinkBrowseContext(iface
);
123 FIXME("(%p)->(%i)\n", This
, dwRegister
);
125 GetRunningObjectTable(0, &ROT
);
126 r
= IRunningObjectTable_Revoke(ROT
, dwRegister
);
127 IRunningObjectTable_Release(ROT
);
132 static HRESULT WINAPI
IHlinkBC_SetBrowseWindowInfo(IHlinkBrowseContext
* iface
,
135 HlinkBCImpl
*This
= impl_from_IHlinkBrowseContext(iface
);
136 TRACE("(%p)->(%p)\n", This
, phlbwi
);
141 heap_free(This
->BrowseWindowInfo
);
142 This
->BrowseWindowInfo
= heap_alloc(phlbwi
->cbSize
);
143 memcpy(This
->BrowseWindowInfo
, phlbwi
, phlbwi
->cbSize
);
148 static HRESULT WINAPI
IHlinkBC_GetBrowseWindowInfo(IHlinkBrowseContext
* iface
,
151 HlinkBCImpl
*This
= impl_from_IHlinkBrowseContext(iface
);
152 TRACE("(%p)->(%p)\n", This
, phlbwi
);
157 if(!This
->BrowseWindowInfo
)
160 memcpy(phlbwi
, This
->BrowseWindowInfo
, This
->BrowseWindowInfo
->cbSize
);
165 static HRESULT WINAPI
IHlinkBC_SetInitialHlink(IHlinkBrowseContext
* iface
,
166 IMoniker
*pimkTarget
, LPCWSTR pwzLocation
, LPCWSTR pwzFriendlyName
)
168 HlinkBCImpl
*This
= impl_from_IHlinkBrowseContext(iface
);
170 FIXME("(%p)->(%p %s %s)\n", This
, pimkTarget
,
171 debugstr_w(pwzLocation
), debugstr_w(pwzFriendlyName
));
173 if (This
->CurrentPage
)
174 IHlink_Release(This
->CurrentPage
);
176 HlinkCreateFromMoniker(pimkTarget
, pwzLocation
, pwzFriendlyName
, NULL
,
177 0, NULL
, &IID_IHlink
, (LPVOID
*) &This
->CurrentPage
);
182 static HRESULT WINAPI
IHlinkBC_OnNavigateHlink(IHlinkBrowseContext
*iface
,
183 DWORD grfHLNF
, IMoniker
* pmkTarget
, LPCWSTR pwzLocation
, LPCWSTR
184 pwzFriendlyName
, ULONG
*puHLID
)
186 HlinkBCImpl
*This
= impl_from_IHlinkBrowseContext(iface
);
188 FIXME("(%p)->(%i %p %s %s %p)\n", This
, grfHLNF
, pmkTarget
,
189 debugstr_w(pwzLocation
), debugstr_w(pwzFriendlyName
), puHLID
);
194 static HRESULT WINAPI
IHlinkBC_UpdateHlink(IHlinkBrowseContext
* iface
,
195 ULONG uHLID
, IMoniker
* pimkTarget
, LPCWSTR pwzLocation
,
196 LPCWSTR pwzFriendlyName
)
202 static HRESULT WINAPI
IHlinkBC_EnumNavigationStack( IHlinkBrowseContext
*iface
,
203 DWORD dwReserved
, DWORD grfHLFNAMEF
, IEnumHLITEM
** ppienumhlitem
)
209 static HRESULT WINAPI
IHlinkBC_QueryHlink( IHlinkBrowseContext
* iface
,
210 DWORD grfHLONG
, ULONG uHLID
)
216 static HRESULT WINAPI
IHlinkBC_GetHlink( IHlinkBrowseContext
* iface
,
217 ULONG uHLID
, IHlink
** ppihl
)
219 HlinkBCImpl
*This
= impl_from_IHlinkBrowseContext(iface
);
221 TRACE("(%p)->(%x %p)\n", This
, uHLID
, ppihl
);
223 if(uHLID
!= HLID_CURRENT
) {
224 FIXME("Only HLID_CURRENT implemented, given: %x\n", uHLID
);
228 *ppihl
= This
->CurrentPage
;
229 IHlink_AddRef(*ppihl
);
234 static HRESULT WINAPI
IHlinkBC_SetCurrentHlink( IHlinkBrowseContext
* iface
,
241 static HRESULT WINAPI
IHlinkBC_Clone( IHlinkBrowseContext
* iface
,
242 IUnknown
* piunkOuter
, REFIID riid
, IUnknown
** ppiunkOjb
)
248 static HRESULT WINAPI
IHlinkBC_Close(IHlinkBrowseContext
* iface
,
255 static const IHlinkBrowseContextVtbl hlvt
=
257 IHlinkBC_fnQueryInterface
,
263 IHlinkBC_SetBrowseWindowInfo
,
264 IHlinkBC_GetBrowseWindowInfo
,
265 IHlinkBC_SetInitialHlink
,
266 IHlinkBC_OnNavigateHlink
,
267 IHlinkBC_UpdateHlink
,
268 IHlinkBC_EnumNavigationStack
,
271 IHlinkBC_SetCurrentHlink
,
276 HRESULT
HLinkBrowseContext_Constructor(IUnknown
*pUnkOuter
, REFIID riid
, void **ppv
)
280 TRACE("unkOut=%p riid=%s\n", pUnkOuter
, debugstr_guid(riid
));
284 return CLASS_E_NOAGGREGATION
;
286 hl
= heap_alloc_zero(sizeof(HlinkBCImpl
));
288 return E_OUTOFMEMORY
;
291 hl
->IHlinkBrowseContext_iface
.lpVtbl
= &hlvt
;