ReactOS 0.4.17-dev-806-gffa4164
browse_ctx.c
Go to the documentation of this file.
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#include "wine/list.h"
25
27
29{
30 struct list entry;
32};
33
34typedef struct
35{
40 struct list links;
42
44{
45 return CONTAINING_RECORD(iface, HlinkBCImpl, IHlinkBrowseContext_iface);
46}
47
49 REFIID riid, LPVOID* ppvObj)
50{
52 TRACE ("(%p)->(%s,%p)\n", This, debugstr_guid (riid), ppvObj);
53
55 IsEqualIID(riid, &IID_IHlinkBrowseContext))
56 {
57 *ppvObj = &This->IHlinkBrowseContext_iface;
58 }
59 else
60 {
61 *ppvObj = NULL;
62 return E_NOINTERFACE;
63 }
64
65 IUnknown_AddRef((IUnknown *)*ppvObj);
66 return S_OK;
67}
68
70{
72 ULONG refCount = InterlockedIncrement(&This->ref);
73
74 TRACE("(%p)->(count=%lu)\n", This, refCount - 1);
75
76 return refCount;
77}
78
80{
83
84 TRACE("(%p)->(count=%lu)\n", This, ref + 1);
85
86 if (!ref)
87 {
88 struct link_entry *link, *link2;
89
90 LIST_FOR_EACH_ENTRY_SAFE(link, link2, &This->links, struct link_entry, entry)
91 {
92 list_remove(&link->entry);
93 IHlink_Release(link->link);
94 free(link);
95 }
96
97 free(This->BrowseWindowInfo);
98 free(This);
99 }
100
101 return ref;
102}
103
105 DWORD dwReserved, IUnknown *piunk, IMoniker *pimk, DWORD *pdwRegister)
106{
108 IMoniker *mon;
109 IMoniker *composite;
111 HRESULT hr;
112
113 FIXME("(%p)->(%li %p %p %p)\n", This, dwReserved, piunk, pimk, pdwRegister);
114
115 hr = CreateItemMoniker(NULL, L"WINEHLINK", &mon);
116 if (FAILED(hr))
117 return hr;
118 CreateGenericComposite(mon, pimk, &composite);
119
120 GetRunningObjectTable(0, &ROT);
121 IRunningObjectTable_Register(ROT, 0, piunk, composite, pdwRegister);
122
123 IRunningObjectTable_Release(ROT);
124 IMoniker_Release(composite);
125 IMoniker_Release(mon);
126
127 return S_OK;
128}
129
131 IMoniker *pimk, BOOL fBindifRootRegistered, IUnknown **ppiunk)
132{
134 IMoniker *mon;
135 IMoniker *composite;
137 HRESULT hr;
138
139 TRACE("(%p)->(%p, %d, %p)\n", This, pimk, fBindifRootRegistered, ppiunk);
140
141 hr = CreateItemMoniker(NULL, L"WINEHLINK", &mon);
142 if (FAILED(hr)) return hr;
143 CreateGenericComposite(mon, pimk, &composite);
144
145 GetRunningObjectTable(0, &ROT);
146 hr = IRunningObjectTable_GetObject(ROT, composite, ppiunk);
147
148 IRunningObjectTable_Release(ROT);
149 IMoniker_Release(composite);
150 IMoniker_Release(mon);
151
152 return hr;
153}
154
156 DWORD dwRegister)
157{
158 HRESULT r;
161
162 FIXME("(%p)->(%li)\n", This, dwRegister);
163
164 GetRunningObjectTable(0, &ROT);
165 r = IRunningObjectTable_Revoke(ROT, dwRegister);
166 IRunningObjectTable_Release(ROT);
167
168 return r;
169}
170
172 HLBWINFO *phlbwi)
173{
175 TRACE("(%p)->(%p)\n", This, phlbwi);
176
177 if(!phlbwi)
178 return E_INVALIDARG;
179
180 free(This->BrowseWindowInfo);
181 This->BrowseWindowInfo = malloc(phlbwi->cbSize);
182 memcpy(This->BrowseWindowInfo, phlbwi, phlbwi->cbSize);
183
184 return S_OK;
185}
186
188 HLBWINFO *phlbwi)
189{
191 TRACE("(%p)->(%p)\n", This, phlbwi);
192
193 if(!phlbwi)
194 return E_INVALIDARG;
195
196 if(!This->BrowseWindowInfo)
197 phlbwi->cbSize = 0;
198 else
199 memcpy(phlbwi, This->BrowseWindowInfo, This->BrowseWindowInfo->cbSize);
200
201 return S_OK;
202}
203
205 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName)
206{
208 struct link_entry *link;
209
210 TRACE("(%p)->(%p %s %s)\n", This, pimkTarget, debugstr_w(pwzLocation), debugstr_w(pwzFriendlyName));
211
212 if (!list_empty(&This->links))
214
215 link = malloc(sizeof(struct link_entry));
216 if (!link) return E_OUTOFMEMORY;
217
218 HlinkCreateFromMoniker(pimkTarget, pwzLocation, pwzFriendlyName, NULL,
219 0, NULL, &IID_IHlink, (void**)&link->link);
220
221 list_add_head(&This->links, &link->entry);
222 This->current = LIST_ENTRY(list_head(&This->links), struct link_entry, entry);
223 return S_OK;
224}
225
227 DWORD grfHLNF, IMoniker* pmkTarget, LPCWSTR pwzLocation, LPCWSTR
228 pwzFriendlyName, ULONG *puHLID)
229{
231
232 FIXME("(%p)->(%li %p %s %s %p)\n", This, grfHLNF, pmkTarget,
233 debugstr_w(pwzLocation), debugstr_w(pwzFriendlyName), puHLID);
234
235 return S_OK;
236}
237
239{
240 struct list *entry;
241
242 switch (hlid)
243 {
244 case HLID_PREVIOUS:
245 entry = list_prev(&ctxt->links, &ctxt->current->entry);
246 break;
247 case HLID_NEXT:
248 entry = list_next(&ctxt->links, &ctxt->current->entry);
249 break;
250 case HLID_CURRENT:
251 entry = &ctxt->current->entry;
252 break;
253 case HLID_STACKBOTTOM:
254 entry = list_tail(&ctxt->links);
255 break;
256 case HLID_STACKTOP:
257 entry = list_head(&ctxt->links);
258 break;
259 default:
260 WARN("unknown id 0x%lx\n", hlid);
261 entry = NULL;
262 }
263
264 return entry ? LIST_ENTRY(entry, struct link_entry, entry) : NULL;
265}
266
269{
271 struct link_entry *entry = context_get_entry(This, hlid);
272 IHlink *link;
273 HRESULT hr;
274
275 TRACE("(%p)->(0x%lx %p %s %s)\n", This, hlid, target, debugstr_w(location), debugstr_w(friendly_name));
276
277 if (!entry)
278 return E_INVALIDARG;
279
280 hr = HlinkCreateFromMoniker(target, location, friendly_name, NULL, 0, NULL, &IID_IHlink, (void**)&link);
281 if (FAILED(hr))
282 return hr;
283
284 IHlink_Release(entry->link);
285 entry->link = link;
286
287 return S_OK;
288}
289
291 DWORD dwReserved, DWORD grfHLFNAMEF, IEnumHLITEM** ppienumhlitem)
292{
293 FIXME("\n");
294 return E_NOTIMPL;
295}
296
298 DWORD grfHLONG, ULONG uHLID)
299{
300 FIXME("\n");
301 return E_NOTIMPL;
302}
303
305{
307 struct link_entry *link;
308
309 TRACE("(%p)->(0x%lx %p)\n", This, hlid, ret);
310
311 link = context_get_entry(This, hlid);
312 if (!link)
313 return E_FAIL;
314
315 *ret = link->link;
316 IHlink_AddRef(*ret);
317
318 return S_OK;
319}
320
322{
324 struct link_entry *link;
325
326 TRACE("(%p)->(0x%08lx)\n", This, hlid);
327
328 link = context_get_entry(This, hlid);
329 if (!link)
330 return E_FAIL;
331
332 This->current = link;
333 return S_OK;
334}
335
337 IUnknown* piunkOuter, REFIID riid, IUnknown** ppiunkOjb)
338{
339 FIXME("\n");
340 return E_NOTIMPL;
341}
342
345{
346 FIXME("\n");
347 return E_NOTIMPL;
348}
349
350static const IHlinkBrowseContextVtbl hlvt =
351{
369};
370
372{
373 HlinkBCImpl * hl;
374 HRESULT hr;
375
376 TRACE("unkOut=%p riid=%s\n", pUnkOuter, debugstr_guid(riid));
377 *ppv = NULL;
378
379 if (pUnkOuter)
381
382 hl = calloc(1, sizeof(*hl));
383 if (!hl)
384 return E_OUTOFMEMORY;
385
386 hl->ref = 1;
387 hl->IHlinkBrowseContext_iface.lpVtbl = &hlvt;
388 list_init(&hl->links);
389
390 hr = IHlinkBrowseContext_QueryInterface(&hl->IHlinkBrowseContext_iface, riid, ppv);
391 IHlinkBrowseContext_Release(&hl->IHlinkBrowseContext_iface);
392
393 return hr;
394}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static int list_empty(struct list_entry *head)
Definition: list.h:58
static void list_add_head(struct list_entry *head, struct list_entry *entry)
Definition: list.h:76
static void list_init(struct list_entry *head)
Definition: list.h:51
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
Definition: list.h:37
HRESULT WINAPI CreateGenericComposite(IMoniker *left, IMoniker *right, IMoniker **composite)
const WCHAR * link
Definition: db.cpp:998
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
HRESULT WINAPI GetRunningObjectTable(DWORD reserved, IRunningObjectTable **ret)
Definition: moniker.c:729
return ret
Definition: mutex.c:147
#define L(x)
Definition: resources.c:13
r reserved
Definition: btrfs.c:3006
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
uint32_t entry
Definition: isohybrid.c:63
HRESULT WINAPI CreateItemMoniker(const WCHAR *delimiter, const WCHAR *name, IMoniker **ret)
Definition: itemmoniker.c:932
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static const WCHAR friendly_name[]
Definition: devenum.c:40
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:95
long LONG
Definition: pedump.c:60
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
#define calloc
Definition: rosglue.h:14
__WINE_SERVER_LIST_INLINE struct list * list_prev(const struct list *list, const struct list *elem)
Definition: list.h:123
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
__WINE_SERVER_LIST_INLINE struct list * list_next(const struct list *list, const struct list *elem)
Definition: list.h:115
__WINE_SERVER_LIST_INLINE struct list * list_tail(const struct list *list)
Definition: list.h:137
#define TRACE(s)
Definition: solgame.cpp:4
struct list links
Definition: browse_ctx.c:40
struct link_entry * current
Definition: browse_ctx.c:39
HLBWINFO * BrowseWindowInfo
Definition: browse_ctx.c:38
IHlinkBrowseContext IHlinkBrowseContext_iface
Definition: browse_ctx.c:36
Definition: browse_ctx.c:29
struct list entry
Definition: browse_ctx.c:30
IHlink * link
Definition: browse_ctx.c:31
Definition: list.h:15
Definition: send.c:48
Definition: tools.h:99
#define LIST_ENTRY(type)
Definition: queue.h:175
const uint16_t * LPCWSTR
Definition: typedefs.h:57
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:3479
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:3771
#define CO_E_ALREADYINITIALIZED
Definition: winerror.h:3917