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);
131 FIXME("(%p)->(%p)\n", This, p);
135 static HRESULT WINAPI HTMLLocation_put_protocol(IHTMLLocation *iface, BSTR v)
137 HTMLLocation *This = HTMLLOCATION_THIS(iface);
138 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
142 static HRESULT WINAPI HTMLLocation_get_protocol(IHTMLLocation *iface, BSTR *p)
144 HTMLLocation *This = HTMLLOCATION_THIS(iface);
145 FIXME("(%p)->(%p)\n", This, p);
149 static HRESULT WINAPI HTMLLocation_put_host(IHTMLLocation *iface, BSTR v)
151 HTMLLocation *This = HTMLLOCATION_THIS(iface);
152 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
156 static HRESULT WINAPI HTMLLocation_get_host(IHTMLLocation *iface, BSTR *p)
158 HTMLLocation *This = HTMLLOCATION_THIS(iface);
159 FIXME("(%p)->(%p)\n", This, p);
163 static HRESULT WINAPI HTMLLocation_put_hostname(IHTMLLocation *iface, BSTR v)
165 HTMLLocation *This = HTMLLOCATION_THIS(iface);
166 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
170 static HRESULT WINAPI HTMLLocation_get_hostname(IHTMLLocation *iface, BSTR *p)
172 HTMLLocation *This = HTMLLOCATION_THIS(iface);
173 FIXME("(%p)->(%p)\n", This, p);
177 static HRESULT WINAPI HTMLLocation_put_port(IHTMLLocation *iface, BSTR v)
179 HTMLLocation *This = HTMLLOCATION_THIS(iface);
180 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
184 static HRESULT WINAPI HTMLLocation_get_port(IHTMLLocation *iface, BSTR *p)
186 HTMLLocation *This = HTMLLOCATION_THIS(iface);
187 FIXME("(%p)->(%p)\n", This, p);
191 static HRESULT WINAPI HTMLLocation_put_pathname(IHTMLLocation *iface, BSTR v)
193 HTMLLocation *This = HTMLLOCATION_THIS(iface);
194 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
198 static HRESULT WINAPI HTMLLocation_get_pathname(IHTMLLocation *iface, BSTR *p)
200 HTMLLocation *This = HTMLLOCATION_THIS(iface);
201 WCHAR buf[INTERNET_MAX_PATH_LENGTH];
202 URL_COMPONENTSW url = {sizeof(url)};
206 TRACE("(%p)->(%p)\n", This, p);
208 if(!This->doc || !This->doc->url) {
209 FIXME("No current URL\n");
213 hres = CoInternetParseUrl(This->doc->url, PARSE_PATH_FROM_URL, 0, buf, sizeof(buf), &size, 0);
214 if(SUCCEEDED(hres)) {
215 *p = SysAllocString(buf);
217 return E_OUTOFMEMORY;
221 url.dwUrlPathLength = 1;
222 if(!InternetCrackUrlW(This->doc->url, 0, 0, &url)) {
223 FIXME("InternetCrackUrl failed\n");
227 if(!url.dwUrlPathLength) {
232 *p = SysAllocStringLen(url.lpszUrlPath, url.dwUrlPathLength);
234 return E_OUTOFMEMORY;
238 static HRESULT WINAPI HTMLLocation_put_search(IHTMLLocation *iface, BSTR v)
240 HTMLLocation *This = HTMLLOCATION_THIS(iface);
241 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
245 static HRESULT WINAPI HTMLLocation_get_search(IHTMLLocation *iface, BSTR *p)
247 HTMLLocation *This = HTMLLOCATION_THIS(iface);
248 FIXME("(%p)->(%p)\n", This, p);
252 static HRESULT WINAPI HTMLLocation_put_hash(IHTMLLocation *iface, BSTR v)
254 HTMLLocation *This = HTMLLOCATION_THIS(iface);
255 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
259 static HRESULT WINAPI HTMLLocation_get_hash(IHTMLLocation *iface, BSTR *p)
261 HTMLLocation *This = HTMLLOCATION_THIS(iface);
262 FIXME("(%p)->(%p)\n", This, p);
266 static HRESULT WINAPI HTMLLocation_reload(IHTMLLocation *iface, VARIANT_BOOL flag)
268 HTMLLocation *This = HTMLLOCATION_THIS(iface);
269 FIXME("(%p)->(%x)\n", This, flag);
273 static HRESULT WINAPI HTMLLocation_replace(IHTMLLocation *iface, BSTR bstr)
275 HTMLLocation *This = HTMLLOCATION_THIS(iface);
276 FIXME("(%p)->(%s)\n", This, debugstr_w(bstr));
280 static HRESULT WINAPI HTMLLocation_assign(IHTMLLocation *iface, BSTR bstr)
282 HTMLLocation *This = HTMLLOCATION_THIS(iface);
283 FIXME("(%p)->(%s)\n", This, debugstr_w(bstr));
287 static HRESULT WINAPI HTMLLocation_toString(IHTMLLocation *iface, BSTR *String)
289 HTMLLocation *This = HTMLLOCATION_THIS(iface);
290 FIXME("(%p)->(%p)\n", This, String);
294 #undef HTMLLOCATION_THIS
296 static const IHTMLLocationVtbl HTMLLocationVtbl = {
297 HTMLLocation_QueryInterface,
299 HTMLLocation_Release,
300 HTMLLocation_GetTypeInfoCount,
301 HTMLLocation_GetTypeInfo,
302 HTMLLocation_GetIDsOfNames,
304 HTMLLocation_put_href,
305 HTMLLocation_get_href,
306 HTMLLocation_put_protocol,
307 HTMLLocation_get_protocol,
308 HTMLLocation_put_host,
309 HTMLLocation_get_host,
310 HTMLLocation_put_hostname,
311 HTMLLocation_get_hostname,
312 HTMLLocation_put_port,
313 HTMLLocation_get_port,
314 HTMLLocation_put_pathname,
315 HTMLLocation_get_pathname,
316 HTMLLocation_put_search,
317 HTMLLocation_get_search,
318 HTMLLocation_put_hash,
319 HTMLLocation_get_hash,
321 HTMLLocation_replace,
323 HTMLLocation_toString
326 static const tid_t HTMLLocation_iface_tids[] = {
330 static dispex_static_data_t HTMLLocation_dispex = {
332 DispHTMLLocation_tid,
334 HTMLLocation_iface_tids
338 HTMLLocation *HTMLLocation_Create(HTMLDocument *doc)
340 HTMLLocation *ret = heap_alloc(sizeof(*ret));
342 ret->lpHTMLLocationVtbl = &HTMLLocationVtbl;
346 init_dispex(&ret->dispex, (IUnknown*)HTMLLOCATION(ret), &HTMLLocation_dispex);