msacm32: acmFormatEnum: Implement ACM_FORMATENUMF_SUGGEST.
[wine] / dlls / 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     return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo);
92 }
93
94 static HRESULT WINAPI HTMLLocation_GetTypeInfo(IHTMLLocation *iface, UINT iTInfo,
95                                               LCID lcid, ITypeInfo **ppTInfo)
96 {
97     HTMLLocation *This = HTMLLOCATION_THIS(iface);
98     return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
99 }
100
101 static HRESULT WINAPI HTMLLocation_GetIDsOfNames(IHTMLLocation *iface, REFIID riid,
102                                                 LPOLESTR *rgszNames, UINT cNames,
103                                                 LCID lcid, DISPID *rgDispId)
104 {
105     HTMLLocation *This = HTMLLOCATION_THIS(iface);
106     return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
107 }
108
109 static HRESULT WINAPI HTMLLocation_Invoke(IHTMLLocation *iface, DISPID dispIdMember,
110                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
111                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
112 {
113     HTMLLocation *This = HTMLLOCATION_THIS(iface);
114     return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid,
115             wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
116 }
117
118 static HRESULT WINAPI HTMLLocation_put_href(IHTMLLocation *iface, BSTR v)
119 {
120     HTMLLocation *This = HTMLLOCATION_THIS(iface);
121     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
122     return E_NOTIMPL;
123 }
124
125 static HRESULT WINAPI HTMLLocation_get_href(IHTMLLocation *iface, BSTR *p)
126 {
127     HTMLLocation *This = HTMLLOCATION_THIS(iface);
128     FIXME("(%p)->(%p)\n", This, p);
129     return E_NOTIMPL;
130 }
131
132 static HRESULT WINAPI HTMLLocation_put_protocol(IHTMLLocation *iface, BSTR v)
133 {
134     HTMLLocation *This = HTMLLOCATION_THIS(iface);
135     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
136     return E_NOTIMPL;
137 }
138
139 static HRESULT WINAPI HTMLLocation_get_protocol(IHTMLLocation *iface, BSTR *p)
140 {
141     HTMLLocation *This = HTMLLOCATION_THIS(iface);
142     FIXME("(%p)->(%p)\n", This, p);
143     return E_NOTIMPL;
144 }
145
146 static HRESULT WINAPI HTMLLocation_put_host(IHTMLLocation *iface, BSTR v)
147 {
148     HTMLLocation *This = HTMLLOCATION_THIS(iface);
149     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
150     return E_NOTIMPL;
151 }
152
153 static HRESULT WINAPI HTMLLocation_get_host(IHTMLLocation *iface, BSTR *p)
154 {
155     HTMLLocation *This = HTMLLOCATION_THIS(iface);
156     FIXME("(%p)->(%p)\n", This, p);
157     return E_NOTIMPL;
158 }
159
160 static HRESULT WINAPI HTMLLocation_put_hostname(IHTMLLocation *iface, BSTR v)
161 {
162     HTMLLocation *This = HTMLLOCATION_THIS(iface);
163     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
164     return E_NOTIMPL;
165 }
166
167 static HRESULT WINAPI HTMLLocation_get_hostname(IHTMLLocation *iface, BSTR *p)
168 {
169     HTMLLocation *This = HTMLLOCATION_THIS(iface);
170     FIXME("(%p)->(%p)\n", This, p);
171     return E_NOTIMPL;
172 }
173
174 static HRESULT WINAPI HTMLLocation_put_port(IHTMLLocation *iface, BSTR v)
175 {
176     HTMLLocation *This = HTMLLOCATION_THIS(iface);
177     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
178     return E_NOTIMPL;
179 }
180
181 static HRESULT WINAPI HTMLLocation_get_port(IHTMLLocation *iface, BSTR *p)
182 {
183     HTMLLocation *This = HTMLLOCATION_THIS(iface);
184     FIXME("(%p)->(%p)\n", This, p);
185     return E_NOTIMPL;
186 }
187
188 static HRESULT WINAPI HTMLLocation_put_pathname(IHTMLLocation *iface, BSTR v)
189 {
190     HTMLLocation *This = HTMLLOCATION_THIS(iface);
191     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
192     return E_NOTIMPL;
193 }
194
195 static HRESULT WINAPI HTMLLocation_get_pathname(IHTMLLocation *iface, BSTR *p)
196 {
197     HTMLLocation *This = HTMLLOCATION_THIS(iface);
198     FIXME("(%p)->(%p)\n", This, p);
199     return E_NOTIMPL;
200 }
201
202 static HRESULT WINAPI HTMLLocation_put_search(IHTMLLocation *iface, BSTR v)
203 {
204     HTMLLocation *This = HTMLLOCATION_THIS(iface);
205     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
206     return E_NOTIMPL;
207 }
208
209 static HRESULT WINAPI HTMLLocation_get_search(IHTMLLocation *iface, BSTR *p)
210 {
211     HTMLLocation *This = HTMLLOCATION_THIS(iface);
212     FIXME("(%p)->(%p)\n", This, p);
213     return E_NOTIMPL;
214 }
215
216 static HRESULT WINAPI HTMLLocation_put_hash(IHTMLLocation *iface, BSTR v)
217 {
218     HTMLLocation *This = HTMLLOCATION_THIS(iface);
219     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
220     return E_NOTIMPL;
221 }
222
223 static HRESULT WINAPI HTMLLocation_get_hash(IHTMLLocation *iface, BSTR *p)
224 {
225     HTMLLocation *This = HTMLLOCATION_THIS(iface);
226     FIXME("(%p)->(%p)\n", This, p);
227     return E_NOTIMPL;
228 }
229
230 static HRESULT WINAPI HTMLLocation_reload(IHTMLLocation *iface, VARIANT_BOOL flag)
231 {
232     HTMLLocation *This = HTMLLOCATION_THIS(iface);
233     FIXME("(%p)->(%x)\n", This, flag);
234     return E_NOTIMPL;
235 }
236
237 static HRESULT WINAPI HTMLLocation_replace(IHTMLLocation *iface, BSTR bstr)
238 {
239     HTMLLocation *This = HTMLLOCATION_THIS(iface);
240     FIXME("(%p)->(%s)\n", This, debugstr_w(bstr));
241     return E_NOTIMPL;
242 }
243
244 static HRESULT WINAPI HTMLLocation_assign(IHTMLLocation *iface, BSTR bstr)
245 {
246     HTMLLocation *This = HTMLLOCATION_THIS(iface);
247     FIXME("(%p)->(%s)\n", This, debugstr_w(bstr));
248     return E_NOTIMPL;
249 }
250
251 static HRESULT WINAPI HTMLLocation_toString(IHTMLLocation *iface, BSTR *String)
252 {
253     HTMLLocation *This = HTMLLOCATION_THIS(iface);
254     FIXME("(%p)->(%p)\n", This, String);
255     return E_NOTIMPL;
256 }
257
258 #undef HTMLLOCATION_THIS
259
260 static const IHTMLLocationVtbl HTMLLocationVtbl = {
261     HTMLLocation_QueryInterface,
262     HTMLLocation_AddRef,
263     HTMLLocation_Release,
264     HTMLLocation_GetTypeInfoCount,
265     HTMLLocation_GetTypeInfo,
266     HTMLLocation_GetIDsOfNames,
267     HTMLLocation_Invoke,
268     HTMLLocation_put_href,
269     HTMLLocation_get_href,
270     HTMLLocation_put_protocol,
271     HTMLLocation_get_protocol,
272     HTMLLocation_put_host,
273     HTMLLocation_get_host,
274     HTMLLocation_put_hostname,
275     HTMLLocation_get_hostname,
276     HTMLLocation_put_port,
277     HTMLLocation_get_port,
278     HTMLLocation_put_pathname,
279     HTMLLocation_get_pathname,
280     HTMLLocation_put_search,
281     HTMLLocation_get_search,
282     HTMLLocation_put_hash,
283     HTMLLocation_get_hash,
284     HTMLLocation_reload,
285     HTMLLocation_replace,
286     HTMLLocation_assign,
287     HTMLLocation_toString
288 };
289
290 static const tid_t HTMLLocation_iface_tids[] = {
291     IHTMLLocation_tid,
292     0
293 };
294 static dispex_static_data_t HTMLLocation_dispex = {
295     NULL,
296     IHTMLLocation_tid,
297     NULL,
298     HTMLLocation_iface_tids
299 };
300
301
302 HTMLLocation *HTMLLocation_Create(HTMLDocument *doc)
303 {
304     HTMLLocation *ret = heap_alloc(sizeof(*ret));
305
306     ret->lpHTMLLocationVtbl = &HTMLLocationVtbl;
307     ret->ref = 1;
308     ret->doc = doc;
309
310     init_dispex(&ret->dispex, (IUnknown*)HTMLLOCATION(ret),  &HTMLLocation_dispex);
311
312     return ret;
313 }