mshtml: Added nsIChannel::SetContentCharset implementation.
[wine/multimedia.git] / dlls / hlink / browse_ctx.c
blob4e91398f4982f9e04c138a763ebc55ca8ef6f8f1
1 /*
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 typedef struct
29 IHlinkBrowseContext IHlinkBrowseContext_iface;
30 LONG ref;
31 HLBWINFO* BrowseWindowInfo;
32 IHlink* CurrentPage;
33 } HlinkBCImpl;
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))
48 *ppvObj = This;
50 if (*ppvObj)
52 IUnknown_AddRef((IUnknown*)(*ppvObj));
53 return S_OK;
55 return E_NOINTERFACE;
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);
65 return refCount;
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);
74 if (refCount)
75 return refCount;
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;
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);
90 IMoniker *mon;
91 IMoniker *composite;
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);
106 return S_OK;
109 static HRESULT WINAPI IHlinkBC_GetObject(IHlinkBrowseContext* face,
110 IMoniker *pimk, BOOL fBindifRootRegistered, IUnknown **ppiunk)
112 FIXME("\n");
113 return E_NOTIMPL;
116 static HRESULT WINAPI IHlinkBC_Revoke(IHlinkBrowseContext* iface,
117 DWORD dwRegister)
119 HRESULT r = S_OK;
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);
129 return r;
132 static HRESULT WINAPI IHlinkBC_SetBrowseWindowInfo(IHlinkBrowseContext* iface,
133 HLBWINFO *phlbwi)
135 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
136 TRACE("(%p)->(%p)\n", This, phlbwi);
138 if(!phlbwi)
139 return E_INVALIDARG;
141 heap_free(This->BrowseWindowInfo);
142 This->BrowseWindowInfo = heap_alloc(phlbwi->cbSize);
143 memcpy(This->BrowseWindowInfo, phlbwi, phlbwi->cbSize);
145 return S_OK;
148 static HRESULT WINAPI IHlinkBC_GetBrowseWindowInfo(IHlinkBrowseContext* iface,
149 HLBWINFO *phlbwi)
151 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
152 TRACE("(%p)->(%p)\n", This, phlbwi);
154 if(!phlbwi)
155 return E_INVALIDARG;
157 if(!This->BrowseWindowInfo)
158 phlbwi->cbSize = 0;
159 else
160 memcpy(phlbwi, This->BrowseWindowInfo, This->BrowseWindowInfo->cbSize);
162 return S_OK;
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);
179 return S_OK;
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);
191 return S_OK;
194 static HRESULT WINAPI IHlinkBC_UpdateHlink(IHlinkBrowseContext* iface,
195 ULONG uHLID, IMoniker* pimkTarget, LPCWSTR pwzLocation,
196 LPCWSTR pwzFriendlyName)
198 FIXME("\n");
199 return E_NOTIMPL;
202 static HRESULT WINAPI IHlinkBC_EnumNavigationStack( IHlinkBrowseContext *iface,
203 DWORD dwReserved, DWORD grfHLFNAMEF, IEnumHLITEM** ppienumhlitem)
205 FIXME("\n");
206 return E_NOTIMPL;
209 static HRESULT WINAPI IHlinkBC_QueryHlink( IHlinkBrowseContext* iface,
210 DWORD grfHLONG, ULONG uHLID)
212 FIXME("\n");
213 return E_NOTIMPL;
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);
225 return E_NOTIMPL;
228 *ppihl = This->CurrentPage;
229 IHlink_AddRef(*ppihl);
231 return S_OK;
234 static HRESULT WINAPI IHlinkBC_SetCurrentHlink( IHlinkBrowseContext* iface,
235 ULONG uHLID)
237 FIXME("\n");
238 return E_NOTIMPL;
241 static HRESULT WINAPI IHlinkBC_Clone( IHlinkBrowseContext* iface,
242 IUnknown* piunkOuter, REFIID riid, IUnknown** ppiunkOjb)
244 FIXME("\n");
245 return E_NOTIMPL;
248 static HRESULT WINAPI IHlinkBC_Close(IHlinkBrowseContext* iface,
249 DWORD reserved)
251 FIXME("\n");
252 return E_NOTIMPL;
255 static const IHlinkBrowseContextVtbl hlvt =
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
276 HRESULT HLinkBrowseContext_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv)
278 HlinkBCImpl * hl;
280 TRACE("unkOut=%p riid=%s\n", pUnkOuter, debugstr_guid(riid));
281 *ppv = NULL;
283 if (pUnkOuter)
284 return CLASS_E_NOAGGREGATION;
286 hl = heap_alloc_zero(sizeof(HlinkBCImpl));
287 if (!hl)
288 return E_OUTOFMEMORY;
290 hl->ref = 1;
291 hl->IHlinkBrowseContext_iface.lpVtbl = &hlvt;
293 *ppv = hl;
294 return S_OK;