2 * Copyright 2008 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 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "wine/debug.h"
33 #include "mshtml_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
38 #define HTMLLOCATION_THIS(iface) DEFINE_THIS(HTMLLocation, HTMLLocation, iface)
40 static HRESULT WINAPI
HTMLLocation_QueryInterface(IHTMLLocation
*iface
, REFIID riid
, void **ppv
)
42 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
46 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
47 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
48 *ppv
= HTMLLOCATION(This
);
49 }else if(IsEqualGUID(&IID_IHTMLLocation
, riid
)) {
50 TRACE("(%p)->(IID_IHTMLLocation %p)\n", This
, ppv
);
51 *ppv
= HTMLLOCATION(This
);
52 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
53 return *ppv
? S_OK
: E_NOINTERFACE
;
57 IUnknown_AddRef((IUnknown
*)*ppv
);
61 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
65 static ULONG WINAPI
HTMLLocation_AddRef(IHTMLLocation
*iface
)
67 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
68 LONG ref
= InterlockedIncrement(&This
->ref
);
70 TRACE("(%p) ref=%d\n", This
, ref
);
75 static ULONG WINAPI
HTMLLocation_Release(IHTMLLocation
*iface
)
77 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
78 LONG ref
= InterlockedDecrement(&This
->ref
);
80 TRACE("(%p) ref=%d\n", This
, ref
);
83 if(This
->doc
&& This
->doc
->location
== This
)
84 This
->doc
->location
= NULL
;
91 static HRESULT WINAPI
HTMLLocation_GetTypeInfoCount(IHTMLLocation
*iface
, UINT
*pctinfo
)
93 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
94 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This
->dispex
), pctinfo
);
97 static HRESULT WINAPI
HTMLLocation_GetTypeInfo(IHTMLLocation
*iface
, UINT iTInfo
,
98 LCID lcid
, ITypeInfo
**ppTInfo
)
100 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
101 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This
->dispex
), iTInfo
, lcid
, ppTInfo
);
104 static HRESULT WINAPI
HTMLLocation_GetIDsOfNames(IHTMLLocation
*iface
, REFIID riid
,
105 LPOLESTR
*rgszNames
, UINT cNames
,
106 LCID lcid
, DISPID
*rgDispId
)
108 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
109 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This
->dispex
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
112 static HRESULT WINAPI
HTMLLocation_Invoke(IHTMLLocation
*iface
, DISPID dispIdMember
,
113 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
114 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
116 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
117 return IDispatchEx_Invoke(DISPATCHEX(&This
->dispex
), dispIdMember
, riid
, lcid
,
118 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
121 static HRESULT WINAPI
HTMLLocation_put_href(IHTMLLocation
*iface
, BSTR v
)
123 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
124 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
128 static HRESULT WINAPI
HTMLLocation_get_href(IHTMLLocation
*iface
, BSTR
*p
)
130 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
132 TRACE("(%p)->(%p)\n", This
, p
);
137 if(!This
->doc
|| !This
->doc
->url
) {
138 FIXME("No current URL\n");
142 *p
= SysAllocString(This
->doc
->url
);
147 static HRESULT WINAPI
HTMLLocation_put_protocol(IHTMLLocation
*iface
, BSTR v
)
149 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
150 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
154 static HRESULT WINAPI
HTMLLocation_get_protocol(IHTMLLocation
*iface
, BSTR
*p
)
156 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
157 FIXME("(%p)->(%p)\n", This
, p
);
161 static HRESULT WINAPI
HTMLLocation_put_host(IHTMLLocation
*iface
, BSTR v
)
163 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
164 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
168 static HRESULT WINAPI
HTMLLocation_get_host(IHTMLLocation
*iface
, BSTR
*p
)
170 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
171 FIXME("(%p)->(%p)\n", This
, p
);
175 static HRESULT WINAPI
HTMLLocation_put_hostname(IHTMLLocation
*iface
, BSTR v
)
177 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
178 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
182 static HRESULT WINAPI
HTMLLocation_get_hostname(IHTMLLocation
*iface
, BSTR
*p
)
184 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
185 FIXME("(%p)->(%p)\n", This
, p
);
189 static HRESULT WINAPI
HTMLLocation_put_port(IHTMLLocation
*iface
, BSTR v
)
191 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
192 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
196 static HRESULT WINAPI
HTMLLocation_get_port(IHTMLLocation
*iface
, BSTR
*p
)
198 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
199 FIXME("(%p)->(%p)\n", This
, p
);
203 static HRESULT WINAPI
HTMLLocation_put_pathname(IHTMLLocation
*iface
, BSTR v
)
205 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
206 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
210 static HRESULT WINAPI
HTMLLocation_get_pathname(IHTMLLocation
*iface
, BSTR
*p
)
212 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
213 WCHAR buf
[INTERNET_MAX_PATH_LENGTH
];
214 URL_COMPONENTSW url
= {sizeof(url
)};
218 TRACE("(%p)->(%p)\n", This
, p
);
220 if(!This
->doc
|| !This
->doc
->url
) {
221 FIXME("No current URL\n");
225 hres
= CoInternetParseUrl(This
->doc
->url
, PARSE_PATH_FROM_URL
, 0, buf
, sizeof(buf
), &size
, 0);
226 if(SUCCEEDED(hres
)) {
227 *p
= SysAllocString(buf
);
229 return E_OUTOFMEMORY
;
233 url
.dwUrlPathLength
= 1;
234 if(!InternetCrackUrlW(This
->doc
->url
, 0, 0, &url
)) {
235 FIXME("InternetCrackUrl failed\n");
239 if(!url
.dwUrlPathLength
) {
244 *p
= SysAllocStringLen(url
.lpszUrlPath
, url
.dwUrlPathLength
);
246 return E_OUTOFMEMORY
;
250 static HRESULT WINAPI
HTMLLocation_put_search(IHTMLLocation
*iface
, BSTR v
)
252 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
253 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
257 static HRESULT WINAPI
HTMLLocation_get_search(IHTMLLocation
*iface
, BSTR
*p
)
259 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
260 FIXME("(%p)->(%p)\n", This
, p
);
264 static HRESULT WINAPI
HTMLLocation_put_hash(IHTMLLocation
*iface
, BSTR v
)
266 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
267 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
271 static HRESULT WINAPI
HTMLLocation_get_hash(IHTMLLocation
*iface
, BSTR
*p
)
273 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
274 FIXME("(%p)->(%p)\n", This
, p
);
278 static HRESULT WINAPI
HTMLLocation_reload(IHTMLLocation
*iface
, VARIANT_BOOL flag
)
280 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
281 FIXME("(%p)->(%x)\n", This
, flag
);
285 static HRESULT WINAPI
HTMLLocation_replace(IHTMLLocation
*iface
, BSTR bstr
)
287 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
288 FIXME("(%p)->(%s)\n", This
, debugstr_w(bstr
));
292 static HRESULT WINAPI
HTMLLocation_assign(IHTMLLocation
*iface
, BSTR bstr
)
294 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
295 FIXME("(%p)->(%s)\n", This
, debugstr_w(bstr
));
299 static HRESULT WINAPI
HTMLLocation_toString(IHTMLLocation
*iface
, BSTR
*String
)
301 HTMLLocation
*This
= HTMLLOCATION_THIS(iface
);
302 FIXME("(%p)->(%p)\n", This
, String
);
306 #undef HTMLLOCATION_THIS
308 static const IHTMLLocationVtbl HTMLLocationVtbl
= {
309 HTMLLocation_QueryInterface
,
311 HTMLLocation_Release
,
312 HTMLLocation_GetTypeInfoCount
,
313 HTMLLocation_GetTypeInfo
,
314 HTMLLocation_GetIDsOfNames
,
316 HTMLLocation_put_href
,
317 HTMLLocation_get_href
,
318 HTMLLocation_put_protocol
,
319 HTMLLocation_get_protocol
,
320 HTMLLocation_put_host
,
321 HTMLLocation_get_host
,
322 HTMLLocation_put_hostname
,
323 HTMLLocation_get_hostname
,
324 HTMLLocation_put_port
,
325 HTMLLocation_get_port
,
326 HTMLLocation_put_pathname
,
327 HTMLLocation_get_pathname
,
328 HTMLLocation_put_search
,
329 HTMLLocation_get_search
,
330 HTMLLocation_put_hash
,
331 HTMLLocation_get_hash
,
333 HTMLLocation_replace
,
335 HTMLLocation_toString
338 static const tid_t HTMLLocation_iface_tids
[] = {
342 static dispex_static_data_t HTMLLocation_dispex
= {
344 DispHTMLLocation_tid
,
346 HTMLLocation_iface_tids
350 HTMLLocation
*HTMLLocation_Create(HTMLDocument
*doc
)
352 HTMLLocation
*ret
= heap_alloc(sizeof(*ret
));
354 ret
->lpHTMLLocationVtbl
= &HTMLLocationVtbl
;
358 init_dispex(&ret
->dispex
, (IUnknown
*)HTMLLOCATION(ret
), &HTMLLocation_dispex
);