taskmgr: Avoid forward declarations and make functions static.
[wine.git] / dlls / mshtml / hlink.c
blob3016917aefbaacd152135b3724c7b2aa8fff90b9
1 /*
2 * Copyright 2005-2006 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 #include "config.h"
20 #include <stdarg.h>
21 #include <stdio.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "ole2.h"
30 #include "wine/debug.h"
31 #include "wine/unicode.h"
33 #include "mshtml_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
37 /**********************************************************
38 * IHlinkTarget implementation
41 #define HLINKTRG_THIS(iface) DEFINE_THIS(HTMLDocument, HlinkTarget, iface)
43 static HRESULT WINAPI HlinkTarget_QueryInterface(IHlinkTarget *iface, REFIID riid, void **ppv)
45 HTMLDocument *This = HLINKTRG_THIS(iface);
46 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
49 static ULONG WINAPI HlinkTarget_AddRef(IHlinkTarget *iface)
51 HTMLDocument *This = HLINKTRG_THIS(iface);
52 return IHTMLDocument2_AddRef(HTMLDOC(This));
55 static ULONG WINAPI HlinkTarget_Release(IHlinkTarget *iface)
57 HTMLDocument *This = HLINKTRG_THIS(iface);
58 return IHTMLDocument2_Release(HTMLDOC(This));
61 static HRESULT WINAPI HlinkTarget_SetBrowseContext(IHlinkTarget *iface, IHlinkBrowseContext *pihlbc)
63 HTMLDocument *This = HLINKTRG_THIS(iface);
64 FIXME("(%p)->(%p)\n", This, pihlbc);
65 return E_NOTIMPL;
68 static HRESULT WINAPI HlinkTarget_GetBrowseContext(IHlinkTarget *iface, IHlinkBrowseContext **ppihlbc)
70 HTMLDocument *This = HLINKTRG_THIS(iface);
71 FIXME("(%p)->(%p)\n", This, ppihlbc);
72 return E_NOTIMPL;
75 static HRESULT WINAPI HlinkTarget_Navigate(IHlinkTarget *iface, DWORD grfHLNF, LPCWSTR pwzJumpLocation)
77 HTMLDocument *This = HLINKTRG_THIS(iface);
79 TRACE("(%p)->(%08lx %s)\n", This, grfHLNF, debugstr_w(pwzJumpLocation));
81 if(grfHLNF)
82 FIXME("Unsupported grfHLNF=%08lx\n", grfHLNF);
83 if(pwzJumpLocation)
84 FIXME("JumpLocation not supported\n");
86 return IOleObject_DoVerb(OLEOBJ(This), OLEIVERB_SHOW, NULL, NULL, -1, NULL, NULL);
89 static HRESULT WINAPI HlinkTarget_GetMoniker(IHlinkTarget *iface, LPCWSTR pwzLocation, DWORD dwAssign,
90 IMoniker **ppimkLocation)
92 HTMLDocument *This = HLINKTRG_THIS(iface);
93 FIXME("(%p)->(%s %08lx %p)\n", This, debugstr_w(pwzLocation), dwAssign, ppimkLocation);
94 return E_NOTIMPL;
97 static HRESULT WINAPI HlinkTarget_GetFriendlyName(IHlinkTarget *iface, LPCWSTR pwzLocation,
98 LPWSTR *ppwzFriendlyName)
100 HTMLDocument *This = HLINKTRG_THIS(iface);
101 FIXME("(%p)->(%s %p)\n", This, debugstr_w(pwzLocation), ppwzFriendlyName);
102 return E_NOTIMPL;
105 static const IHlinkTargetVtbl HlinkTargetVtbl = {
106 HlinkTarget_QueryInterface,
107 HlinkTarget_AddRef,
108 HlinkTarget_Release,
109 HlinkTarget_SetBrowseContext,
110 HlinkTarget_GetBrowseContext,
111 HlinkTarget_Navigate,
112 HlinkTarget_GetMoniker,
113 HlinkTarget_GetFriendlyName
116 void HTMLDocument_Hlink_Init(HTMLDocument *This)
118 This->lpHlinkTargetVtbl = &HlinkTargetVtbl;
121 typedef struct {
122 const IHlinkVtbl *lpHlinkVtbl;
124 LONG ref;
126 IMoniker *mon;
127 LPWSTR location;
128 } Hlink;
130 #define HLINK(x) ((IHlink*) &(x)->lpHlinkVtbl)
132 #define HLINK_THIS(iface) DEFINE_THIS(Hlink, Hlink, iface)
134 static HRESULT WINAPI Hlink_QueryInterface(IHlink *iface, REFIID riid, void **ppv)
136 Hlink *This = HLINK_THIS(iface);
138 *ppv = NULL;
140 if(IsEqualGUID(&IID_IUnknown, riid)) {
141 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
142 *ppv = HLINK(This);
143 }else if(IsEqualGUID(&IID_IHlink, riid)) {
144 TRACE("(%p)->(IID_IHlink %p)\n", This, ppv);
145 *ppv = HLINK(This);
148 if(*ppv) {
149 IHlink_AddRef(HLINK(This));
150 return S_OK;
153 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
154 return E_NOINTERFACE;
157 static ULONG WINAPI Hlink_AddRef(IHlink *iface)
159 Hlink *This = HLINK_THIS(iface);
160 LONG ref = InterlockedIncrement(&This->ref);
162 TRACE("(%p) ref=%ld\n", This, ref);
164 return ref;
167 static ULONG WINAPI Hlink_Release(IHlink *iface)
169 Hlink *This = HLINK_THIS(iface);
170 LONG ref = InterlockedDecrement(&This->ref);
172 TRACE("(%p) ref=%ld\n", This, ref);
174 if(!ref) {
175 if(This->mon)
176 IMoniker_Release(This->mon);
177 HeapFree(GetProcessHeap(), 0, This->location);
178 HeapFree(GetProcessHeap(), 0, This);
181 return ref;
184 static HRESULT WINAPI Hlink_SetHlinkSite(IHlink *iface, IHlinkSite *pihlSite, DWORD dwSiteData)
186 Hlink *This = HLINK_THIS(iface);
187 FIXME("(%p)->(%p %ld)\n", This, pihlSite, dwSiteData);
188 return E_NOTIMPL;
191 static HRESULT WINAPI Hlink_GetHlinkSite(IHlink *iface, IHlinkSite **ppihlSite,
192 DWORD *pdwSiteData)
194 Hlink *This = HLINK_THIS(iface);
196 TRACE("(%p)->(%p %p)\n", This, ppihlSite, pdwSiteData);
198 *ppihlSite = NULL;
199 return S_OK;
202 static HRESULT WINAPI Hlink_SetMonikerReference(IHlink *iface, DWORD grfHLSETF,
203 IMoniker *pimkTarget, LPCWSTR pwzLocation)
205 Hlink *This = HLINK_THIS(iface);
207 TRACE("(%p)->(%08lx %p %s)\n", This, grfHLSETF, pimkTarget, debugstr_w(pwzLocation));
209 if(grfHLSETF)
210 FIXME("unsupported grfHLSETF=%08lx\n", grfHLSETF);
212 if(This->mon)
213 IMoniker_Release(This->mon);
214 if(This->location)
215 HeapFree(GetProcessHeap(), 0, This->location);
217 if(pimkTarget)
218 IMoniker_AddRef(pimkTarget);
219 This->mon = pimkTarget;
221 if(pwzLocation) {
222 DWORD len = strlenW(pwzLocation)+1;
224 This->location = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
225 memcpy(This->location, pwzLocation, len*sizeof(WCHAR));
226 }else {
227 This->location = NULL;
230 return S_OK;
233 static HRESULT WINAPI Hlink_GetMonikerReference(IHlink *iface, DWORD dwWhichRef,
234 IMoniker **ppimkTarget, LPWSTR *ppwzLocation)
236 Hlink *This = HLINK_THIS(iface);
238 TRACE("(%p)->(%ld %p %p)\n", This, dwWhichRef, ppimkTarget, ppwzLocation);
240 if(dwWhichRef != 1)
241 FIXME("upsupported dwWhichRef = %ld\n", dwWhichRef);
243 if(This->mon)
244 IMoniker_AddRef(This->mon);
245 *ppimkTarget = This->mon;
247 if(This->location) {
248 DWORD len = strlenW(This->location)+1;
250 *ppwzLocation = CoTaskMemAlloc(len*sizeof(WCHAR));
251 memcpy(*ppwzLocation, This->location, len*sizeof(WCHAR));
252 }else {
253 *ppwzLocation = NULL;
256 return S_OK;
259 static HRESULT WINAPI Hlink_SetStringReference(IHlink *iface, DWORD grfHLSETF,
260 LPCWSTR pwzTarget, LPCWSTR pwzLocation)
262 Hlink *This = HLINK_THIS(iface);
263 FIXME("(%p)->(%08lx %s %s)\n", This, grfHLSETF, debugstr_w(pwzTarget),
264 debugstr_w(pwzLocation));
265 return E_NOTIMPL;
268 static HRESULT WINAPI Hlink_GetStringReference(IHlink *iface, DWORD dwWhichRef,
269 LPWSTR *ppwzTarget, LPWSTR *ppwzLocation)
271 Hlink *This = HLINK_THIS(iface);
272 FIXME("(%p)->(%ld %p %p)\n", This, dwWhichRef, ppwzTarget, ppwzLocation);
273 return E_NOTIMPL;
276 static HRESULT WINAPI Hlink_SetFriendlyName(IHlink *iface, LPCWSTR pwzFriendlyName)
278 Hlink *This = HLINK_THIS(iface);
279 FIXME("(%p)->(%s)\n", This, debugstr_w(pwzFriendlyName));
280 return E_NOTIMPL;
283 static HRESULT WINAPI Hlink_GetFriendlyName(IHlink *iface, DWORD grfHLNAMEF,
284 LPWSTR *ppwzFriendlyName)
286 Hlink *This = HLINK_THIS(iface);
288 TRACE("(%p)->(%08lx %p)\n", This, grfHLNAMEF, ppwzFriendlyName);
290 *ppwzFriendlyName = NULL;
291 return S_FALSE;
294 static HRESULT WINAPI Hlink_SetTargetFrameName(IHlink *iface, LPCWSTR pwzTargetFrameName)
296 Hlink *This = HLINK_THIS(iface);
297 FIXME("(%p)->(%s)\n", This, debugstr_w(pwzTargetFrameName));
298 return E_NOTIMPL;
301 static HRESULT WINAPI Hlink_GetTargetFrameName(IHlink *iface, LPWSTR *ppwzTargetFrameName)
303 Hlink *This = HLINK_THIS(iface);
305 TRACE("(%p)->(%p)\n", This, ppwzTargetFrameName);
307 *ppwzTargetFrameName = NULL;
308 return S_FALSE;
311 static HRESULT WINAPI Hlink_GetMiscStatus(IHlink *iface, DWORD *pdwStatus)
313 Hlink *This = HLINK_THIS(iface);
314 FIXME("(%p)->(%p)\n", This, pdwStatus);
315 return E_NOTIMPL;
318 static HRESULT WINAPI Hlink_Navigate(IHlink *iface, DWORD grfHLNF, LPBC pibc,
319 IBindStatusCallback *pibsc, IHlinkBrowseContext *pihlbc)
321 Hlink *This = HLINK_THIS(iface);
322 FIXME("(%p)->(%08lx %p %p %p)\n", This, grfHLNF, pibc, pibsc, pihlbc);
323 return E_NOTIMPL;
326 static HRESULT WINAPI Hlink_SetAdditionalParams(IHlink *iface, LPCWSTR pwzAdditionalParams)
328 Hlink *This = HLINK_THIS(iface);
329 FIXME("(%p)->(%s)\n", This, debugstr_w(pwzAdditionalParams));
330 return E_NOTIMPL;
333 static HRESULT WINAPI Hlink_GetAdditionalParams(IHlink *iface, LPWSTR *ppwzAdditionalParams)
335 Hlink *This = HLINK_THIS(iface);
336 FIXME("(%p)->(%p)\n", This, ppwzAdditionalParams);
337 return E_NOTIMPL;
340 #undef HLINK_THIS
342 static const IHlinkVtbl HlinkVtbl = {
343 Hlink_QueryInterface,
344 Hlink_AddRef,
345 Hlink_Release,
346 Hlink_SetHlinkSite,
347 Hlink_GetHlinkSite,
348 Hlink_SetMonikerReference,
349 Hlink_GetMonikerReference,
350 Hlink_SetStringReference,
351 Hlink_GetStringReference,
352 Hlink_SetFriendlyName,
353 Hlink_GetFriendlyName,
354 Hlink_SetTargetFrameName,
355 Hlink_GetTargetFrameName,
356 Hlink_GetMiscStatus,
357 Hlink_Navigate,
358 Hlink_SetAdditionalParams,
359 Hlink_GetAdditionalParams
362 IHlink *Hlink_Create(void)
364 Hlink *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(Hlink));
366 ret->lpHlinkVtbl = &HlinkVtbl;
367 ret->ref = 1;
368 ret->mon = NULL;
369 ret->location = NULL;
371 return HLINK(ret);