1 /*
2 * Implementation of hyperlinking (hlink.dll)
3 *
4 * Copyright 2005 Aric Stewart for CodeWeavers
5 *
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.
10 *
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.
15 *
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
19 */
20
21 #include "hlink_private.h"
22
23 #include "wine/debug.h"
24
25 WINE_DEFAULT_DEBUG_CHANNEL(hlink);
26
27 typedef struct
28 {
29 IHlinkBrowseContext IHlinkBrowseContext_iface;
30 LONG ref;
31 HLBWINFO* BrowseWindowInfo;
32 IHlink* CurrentPage;
33 } HlinkBCImpl;
34
35 static inline HlinkBCImpl *impl_from_IHlinkBrowseContext(IHlinkBrowseContext *iface)
36 {
37 return CONTAINING_RECORD(iface, HlinkBCImpl, IHlinkBrowseContext_iface);
38 }
39
40 static HRESULT WINAPI IHlinkBC_fnQueryInterface( IHlinkBrowseContext *iface,
41 REFIID riid, LPVOID* ppvObj)
42 {
43 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
44 TRACE ("(%p)->(%s,%p)\n", This, debugstr_guid (riid), ppvObj);
45
46 if (IsEqualIID(riid, &IID_IUnknown) ||
47 IsEqualIID(riid, &IID_IHlinkBrowseContext))
48 *ppvObj = This;
49
50 if (*ppvObj)
51 {
52 IUnknown_AddRef((IUnknown*)(*ppvObj));
53 return S_OK;
54 }
55 return E_NOINTERFACE;
56 }
57
58 static ULONG WINAPI IHlinkBC_fnAddRef (IHlinkBrowseContext* iface)
59 {
60 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
61 ULONG refCount = InterlockedIncrement(&This->ref);
62
63 TRACE("(%p)->(count=%u)\n", This, refCount - 1);
64
65 return refCount;
66 }
67
68 static ULONG WINAPI IHlinkBC_fnRelease (IHlinkBrowseContext* iface)
69 {
70 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
71 ULONG refCount = InterlockedDecrement(&This->ref);
72
73 TRACE("(%p)->(count=%u)\n", This, refCount + 1);
74 if (refCount)
75 return refCount;
76
77 TRACE("-- destroying IHlinkBrowseContext (%p)\n", This);
78 heap_free(This->BrowseWindowInfo);
79 if (This->CurrentPage)
80 IHlink_Release(This->CurrentPage);
81 heap_free(This);
82 return 0;
83 }
84
85 static HRESULT WINAPI IHlinkBC_Register(IHlinkBrowseContext* iface,
86 DWORD dwReserved, IUnknown *piunk, IMoniker *pimk, DWORD *pdwRegister)
87 {
88 static const WCHAR szIdent[] = {'W','I','N','E','H','L','I','N','K',0};
89 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
90 IMoniker *mon;
91 IMoniker *composite;
92 IRunningObjectTable *ROT;
93
94 FIXME("(%p)->(%i %p %p %p)\n", This, dwReserved, piunk, pimk, pdwRegister);
95
96 CreateItemMoniker(NULL, szIdent, &mon);
97 CreateGenericComposite(mon, pimk, &composite);
98
99 GetRunningObjectTable(0, &ROT);
100 IRunningObjectTable_Register(ROT, 0, piunk, composite, pdwRegister);
101
102 IRunningObjectTable_Release(ROT);
103 IMoniker_Release(composite);
104 IMoniker_Release(mon);
105
106 return S_OK;
107 }
108
109 static HRESULT WINAPI IHlinkBC_GetObject(IHlinkBrowseContext* face,
110 IMoniker *pimk, BOOL fBindifRootRegistered, IUnknown **ppiunk)
111 {
112 FIXME("\n");
113 return E_NOTIMPL;
114 }
115
116 static HRESULT WINAPI IHlinkBC_Revoke(IHlinkBrowseContext* iface,
117 DWORD dwRegister)
118 {
119 HRESULT r = S_OK;
120 IRunningObjectTable *ROT;
121 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
122
123 FIXME("(%p)->(%i)\n", This, dwRegister);
124
125 GetRunningObjectTable(0, &ROT);
126 r = IRunningObjectTable_Revoke(ROT, dwRegister);
127 IRunningObjectTable_Release(ROT);
128
129 return r;
130 }
131
132 static HRESULT WINAPI IHlinkBC_SetBrowseWindowInfo(IHlinkBrowseContext* iface,
133 HLBWINFO *phlbwi)
134 {
135 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
136 TRACE("(%p)->(%p)\n", This, phlbwi);
137
138 if(!phlbwi)
139 return E_INVALIDARG;
140
141 heap_free(This->BrowseWindowInfo);
142 This->BrowseWindowInfo = heap_alloc(phlbwi->cbSize);
143 memcpy(This->BrowseWindowInfo, phlbwi, phlbwi->cbSize);
144
145 return S_OK;
146 }
147
148 static HRESULT WINAPI IHlinkBC_GetBrowseWindowInfo(IHlinkBrowseContext* iface,
149 HLBWINFO *phlbwi)
150 {
151 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
152 TRACE("(%p)->(%p)\n", This, phlbwi);
153
154 if(!phlbwi)
155 return E_INVALIDARG;
156
157 if(!This->BrowseWindowInfo)
158 phlbwi->cbSize = 0;
159 else
160 memcpy(phlbwi, This->BrowseWindowInfo, This->BrowseWindowInfo->cbSize);
161
162 return S_OK;
163 }
164
165 static HRESULT WINAPI IHlinkBC_SetInitialHlink(IHlinkBrowseContext* iface,
166 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName)
167 {
168 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
169
170 FIXME("(%p)->(%p %s %s)\n", This, pimkTarget,
171 debugstr_w(pwzLocation), debugstr_w(pwzFriendlyName));
172
173 if (This->CurrentPage)
174 IHlink_Release(This->CurrentPage);
175
176 HlinkCreateFromMoniker(pimkTarget, pwzLocation, pwzFriendlyName, NULL,
177 0, NULL, &IID_IHlink, (LPVOID*) &This->CurrentPage);
178
179 return S_OK;
180 }
181
182 static HRESULT WINAPI IHlinkBC_OnNavigateHlink(IHlinkBrowseContext *iface,
183 DWORD grfHLNF, IMoniker* pmkTarget, LPCWSTR pwzLocation, LPCWSTR
184 pwzFriendlyName, ULONG *puHLID)
185 {
186 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
187
188 FIXME("(%p)->(%i %p %s %s %p)\n", This, grfHLNF, pmkTarget,
189 debugstr_w(pwzLocation), debugstr_w(pwzFriendlyName), puHLID);
190
191 return S_OK;
192 }
193
194 static HRESULT WINAPI IHlinkBC_UpdateHlink(IHlinkBrowseContext* iface,
195 ULONG uHLID, IMoniker* pimkTarget, LPCWSTR pwzLocation,
196 LPCWSTR pwzFriendlyName)
197 {
198 FIXME("\n");
199 return E_NOTIMPL;
200 }
201
202 static HRESULT WINAPI IHlinkBC_EnumNavigationStack( IHlinkBrowseContext *iface,
203 DWORD dwReserved, DWORD grfHLFNAMEF, IEnumHLITEM** ppienumhlitem)
204 {
205 FIXME("\n");
206 return E_NOTIMPL;
207 }
208
209 static HRESULT WINAPI IHlinkBC_QueryHlink( IHlinkBrowseContext* iface,
210 DWORD grfHLONG, ULONG uHLID)
211 {
212 FIXME("\n");
213 return E_NOTIMPL;
214 }
215
216 static HRESULT WINAPI IHlinkBC_GetHlink( IHlinkBrowseContext* iface,
217 ULONG uHLID, IHlink** ppihl)
218 {
219 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
220
221 TRACE("(%p)->(%x %p)\n", This, uHLID, ppihl);
222
223 if(uHLID != HLID_CURRENT) {
224 FIXME("Only HLID_CURRENT implemented, given: %x\n", uHLID);
225 return E_NOTIMPL;
226 }
227
228 *ppihl = This->CurrentPage;
229 IHlink_AddRef(*ppihl);
230
231 return S_OK;
232 }
233
234 static HRESULT WINAPI IHlinkBC_SetCurrentHlink( IHlinkBrowseContext* iface,
235 ULONG uHLID)
236 {
237 FIXME("\n");
238 return E_NOTIMPL;
239 }
240
241 static HRESULT WINAPI IHlinkBC_Clone( IHlinkBrowseContext* iface,
242 IUnknown* piunkOuter, REFIID riid, IUnknown** ppiunkOjb)
243 {
244 FIXME("\n");
245 return E_NOTIMPL;
246 }
247
248 static HRESULT WINAPI IHlinkBC_Close(IHlinkBrowseContext* iface,
249 DWORD reserved)
250 {
251 FIXME("\n");
252 return E_NOTIMPL;
253 }
254
255 static const IHlinkBrowseContextVtbl hlvt =
256 {
257 IHlinkBC_fnQueryInterface,
258 IHlinkBC_fnAddRef,
259 IHlinkBC_fnRelease,
260 IHlinkBC_Register,
261 IHlinkBC_GetObject,
262 IHlinkBC_Revoke,
263 IHlinkBC_SetBrowseWindowInfo,
264 IHlinkBC_GetBrowseWindowInfo,
265 IHlinkBC_SetInitialHlink,
266 IHlinkBC_OnNavigateHlink,
267 IHlinkBC_UpdateHlink,
268 IHlinkBC_EnumNavigationStack,
269 IHlinkBC_QueryHlink,
270 IHlinkBC_GetHlink,
271 IHlinkBC_SetCurrentHlink,
272 IHlinkBC_Clone,
273 IHlinkBC_Close
274 };
275
276 HRESULT HLinkBrowseContext_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv)
277 {
278 HlinkBCImpl * hl;
279
280 TRACE("unkOut=%p riid=%s\n", pUnkOuter, debugstr_guid(riid));
281 *ppv = NULL;
282
283 if (pUnkOuter)
284 return CLASS_E_NOAGGREGATION;
285
286 hl = heap_alloc_zero(sizeof(HlinkBCImpl));
287 if (!hl)
288 return E_OUTOFMEMORY;
289
290 hl->ref = 1;
291 hl->IHlinkBrowseContext_iface.lpVtbl = &hlvt;
292
293 *ppv = hl;
294 return S_OK;
295 }
296
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.