sync mshtml and shdocvw to wine 1.1.14
[reactos.git] / reactos / dll / win32 / mshtml / htmllocation.c
1 /*
2 * Copyright 2008 Jacek Caban for CodeWeavers
3 *
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.
8 *
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.
13 *
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
17 */
18
19 #include <stdarg.h>
20
21 #define COBJMACROS
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
27
28 #include "wine/debug.h"
29
30 #include "mshtml_private.h"
31 #include "resource.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
34
35 #define HTMLLOCATION_THIS(iface) DEFINE_THIS(HTMLLocation, HTMLLocation, iface)
36
37 static HRESULT WINAPI HTMLLocation_QueryInterface(IHTMLLocation *iface, REFIID riid, void **ppv)
38 {
39 HTMLLocation *This = HTMLLOCATION_THIS(iface);
40
41 *ppv = NULL;
42
43 if(IsEqualGUID(&IID_IUnknown, riid)) {
44 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
45 *ppv = HTMLLOCATION(This);
46 }else if(IsEqualGUID(&IID_IHTMLLocation, riid)) {
47 TRACE("(%p)->(IID_IHTMLLocation %p)\n", This, ppv);
48 *ppv = HTMLLOCATION(This);
49 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
50 return *ppv ? S_OK : E_NOINTERFACE;
51 }
52
53 if(*ppv) {
54 IUnknown_AddRef((IUnknown*)*ppv);
55 return S_OK;
56 }
57
58 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
59 return E_NOINTERFACE;
60 }
61
62 static ULONG WINAPI HTMLLocation_AddRef(IHTMLLocation *iface)
63 {
64 HTMLLocation *This = HTMLLOCATION_THIS(iface);
65 LONG ref = InterlockedIncrement(&This->ref);
66
67 TRACE("(%p) ref=%d\n", This, ref);
68
69 return ref;
70 }
71
72 static ULONG WINAPI HTMLLocation_Release(IHTMLLocation *iface)
73 {
74 HTMLLocation *This = HTMLLOCATION_THIS(iface);
75 LONG ref = InterlockedDecrement(&This->ref);
76
77 TRACE("(%p) ref=%d\n", This, ref);
78
79 if(!ref) {
80 if(This->doc && This->doc->location == This)
81 This->doc->location = NULL;
82 heap_free(This);
83 }
84
85 return ref;
86 }
87
88 static HRESULT WINAPI HTMLLocation_GetTypeInfoCount(IHTMLLocation *iface, UINT *pctinfo)
89 {
90 HTMLLocation *This = HTMLLOCATION_THIS(iface);
91 FIXME("(%p)->(%p)\n", This, pctinfo);
92 return E_NOTIMPL;
93 }
94
95 static HRESULT WINAPI HTMLLocation_GetTypeInfo(IHTMLLocation *iface, UINT iTInfo,
96 LCID lcid, ITypeInfo **ppTInfo)
97 {
98 HTMLLocation *This = HTMLLOCATION_THIS(iface);
99 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
100 return E_NOTIMPL;
101 }
102
103 static HRESULT WINAPI HTMLLocation_GetIDsOfNames(IHTMLLocation *iface, REFIID riid,
104 LPOLESTR *rgszNames, UINT cNames,
105 LCID lcid, DISPID *rgDispId)
106 {
107 HTMLLocation *This = HTMLLOCATION_THIS(iface);
108 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
109 lcid, rgDispId);
110 return E_NOTIMPL;
111 }
112
113 static HRESULT WINAPI HTMLLocation_Invoke(IHTMLLocation *iface, DISPID dispIdMember,
114 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
115 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
116 {
117 HTMLLocation *This = HTMLLOCATION_THIS(iface);
118 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
119 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
120 return E_NOTIMPL;
121 }
122
123 static HRESULT WINAPI HTMLLocation_put_href(IHTMLLocation *iface, BSTR v)
124 {
125 HTMLLocation *This = HTMLLOCATION_THIS(iface);
126 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
127 return E_NOTIMPL;
128 }
129
130 static HRESULT WINAPI HTMLLocation_get_href(IHTMLLocation *iface, BSTR *p)
131 {
132 HTMLLocation *This = HTMLLOCATION_THIS(iface);
133 FIXME("(%p)->(%p)\n", This, p);
134 return E_NOTIMPL;
135 }
136
137 static HRESULT WINAPI HTMLLocation_put_protocol(IHTMLLocation *iface, BSTR v)
138 {
139 HTMLLocation *This = HTMLLOCATION_THIS(iface);
140 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
141 return E_NOTIMPL;
142 }
143
144 static HRESULT WINAPI HTMLLocation_get_protocol(IHTMLLocation *iface, BSTR *p)
145 {
146 HTMLLocation *This = HTMLLOCATION_THIS(iface);
147 FIXME("(%p)->(%p)\n", This, p);
148 return E_NOTIMPL;
149 }
150
151 static HRESULT WINAPI HTMLLocation_put_host(IHTMLLocation *iface, BSTR v)
152 {
153 HTMLLocation *This = HTMLLOCATION_THIS(iface);
154 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
155 return E_NOTIMPL;
156 }
157
158 static HRESULT WINAPI HTMLLocation_get_host(IHTMLLocation *iface, BSTR *p)
159 {
160 HTMLLocation *This = HTMLLOCATION_THIS(iface);
161 FIXME("(%p)->(%p)\n", This, p);
162 return E_NOTIMPL;
163 }
164
165 static HRESULT WINAPI HTMLLocation_put_hostname(IHTMLLocation *iface, BSTR v)
166 {
167 HTMLLocation *This = HTMLLOCATION_THIS(iface);
168 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
169 return E_NOTIMPL;
170 }
171
172 static HRESULT WINAPI HTMLLocation_get_hostname(IHTMLLocation *iface, BSTR *p)
173 {
174 HTMLLocation *This = HTMLLOCATION_THIS(iface);
175 FIXME("(%p)->(%p)\n", This, p);
176 return E_NOTIMPL;
177 }
178
179 static HRESULT WINAPI HTMLLocation_put_port(IHTMLLocation *iface, BSTR v)
180 {
181 HTMLLocation *This = HTMLLOCATION_THIS(iface);
182 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
183 return E_NOTIMPL;
184 }
185
186 static HRESULT WINAPI HTMLLocation_get_port(IHTMLLocation *iface, BSTR *p)
187 {
188 HTMLLocation *This = HTMLLOCATION_THIS(iface);
189 FIXME("(%p)->(%p)\n", This, p);
190 return E_NOTIMPL;
191 }
192
193 static HRESULT WINAPI HTMLLocation_put_pathname(IHTMLLocation *iface, BSTR v)
194 {
195 HTMLLocation *This = HTMLLOCATION_THIS(iface);
196 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
197 return E_NOTIMPL;
198 }
199
200 static HRESULT WINAPI HTMLLocation_get_pathname(IHTMLLocation *iface, BSTR *p)
201 {
202 HTMLLocation *This = HTMLLOCATION_THIS(iface);
203 FIXME("(%p)->(%p)\n", This, p);
204 return E_NOTIMPL;
205 }
206
207 static HRESULT WINAPI HTMLLocation_put_search(IHTMLLocation *iface, BSTR v)
208 {
209 HTMLLocation *This = HTMLLOCATION_THIS(iface);
210 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
211 return E_NOTIMPL;
212 }
213
214 static HRESULT WINAPI HTMLLocation_get_search(IHTMLLocation *iface, BSTR *p)
215 {
216 HTMLLocation *This = HTMLLOCATION_THIS(iface);
217 FIXME("(%p)->(%p)\n", This, p);
218 return E_NOTIMPL;
219 }
220
221 static HRESULT WINAPI HTMLLocation_put_hash(IHTMLLocation *iface, BSTR v)
222 {
223 HTMLLocation *This = HTMLLOCATION_THIS(iface);
224 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
225 return E_NOTIMPL;
226 }
227
228 static HRESULT WINAPI HTMLLocation_get_hash(IHTMLLocation *iface, BSTR *p)
229 {
230 HTMLLocation *This = HTMLLOCATION_THIS(iface);
231 FIXME("(%p)->(%p)\n", This, p);
232 return E_NOTIMPL;
233 }
234
235 static HRESULT WINAPI HTMLLocation_reload(IHTMLLocation *iface, VARIANT_BOOL flag)
236 {
237 HTMLLocation *This = HTMLLOCATION_THIS(iface);
238 FIXME("(%p)->(%x)\n", This, flag);
239 return E_NOTIMPL;
240 }
241
242 static HRESULT WINAPI HTMLLocation_replace(IHTMLLocation *iface, BSTR bstr)
243 {
244 HTMLLocation *This = HTMLLOCATION_THIS(iface);
245 FIXME("(%p)->(%s)\n", This, debugstr_w(bstr));
246 return E_NOTIMPL;
247 }
248
249 static HRESULT WINAPI HTMLLocation_assign(IHTMLLocation *iface, BSTR bstr)
250 {
251 HTMLLocation *This = HTMLLOCATION_THIS(iface);
252 FIXME("(%p)->(%s)\n", This, debugstr_w(bstr));
253 return E_NOTIMPL;
254 }
255
256 static HRESULT WINAPI HTMLLocation_toString(IHTMLLocation *iface, BSTR *String)
257 {
258 HTMLLocation *This = HTMLLOCATION_THIS(iface);
259 FIXME("(%p)->(%p)\n", This, String);
260 return E_NOTIMPL;
261 }
262
263 #undef HTMLLOCATION_THIS
264
265 static const IHTMLLocationVtbl HTMLLocationVtbl = {
266 HTMLLocation_QueryInterface,
267 HTMLLocation_AddRef,
268 HTMLLocation_Release,
269 HTMLLocation_GetTypeInfoCount,
270 HTMLLocation_GetTypeInfo,
271 HTMLLocation_GetIDsOfNames,
272 HTMLLocation_Invoke,
273 HTMLLocation_put_href,
274 HTMLLocation_get_href,
275 HTMLLocation_put_protocol,
276 HTMLLocation_get_protocol,
277 HTMLLocation_put_host,
278 HTMLLocation_get_host,
279 HTMLLocation_put_hostname,
280 HTMLLocation_get_hostname,
281 HTMLLocation_put_port,
282 HTMLLocation_get_port,
283 HTMLLocation_put_pathname,
284 HTMLLocation_get_pathname,
285 HTMLLocation_put_search,
286 HTMLLocation_get_search,
287 HTMLLocation_put_hash,
288 HTMLLocation_get_hash,
289 HTMLLocation_reload,
290 HTMLLocation_replace,
291 HTMLLocation_assign,
292 HTMLLocation_toString
293 };
294
295 static const tid_t HTMLLocation_iface_tids[] = {
296 IHTMLLocation_tid,
297 0
298 };
299 static dispex_static_data_t HTMLLocation_dispex = {
300 NULL,
301 IHTMLLocation_tid,
302 NULL,
303 HTMLLocation_iface_tids
304 };
305
306
307 HTMLLocation *HTMLLocation_Create(HTMLDocument *doc)
308 {
309 HTMLLocation *ret = heap_alloc(sizeof(*ret));
310
311 ret->lpHTMLLocationVtbl = &HTMLLocationVtbl;
312 ret->ref = 1;
313 ret->doc = doc;
314
315 init_dispex(&ret->dispex, (IUnknown*)HTMLLOCATION(ret), &HTMLLocation_dispex);
316
317 return ret;
318 }