dpwsockx: Implementation of SPInit
[wine/gsoc_dplay.git] / dlls / mshtml / htmllocation.c
blob2026a06a75532ea0a0f7781d0ca2f66e053ff0dd
1 /*
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
19 #include <stdarg.h>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "winreg.h"
27 #include "ole2.h"
28 #include "wininet.h"
29 #include "shlwapi.h"
31 #include "wine/debug.h"
33 #include "mshtml_private.h"
34 #include "resource.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);
44 *ppv = NULL;
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;
56 if(*ppv) {
57 IUnknown_AddRef((IUnknown*)*ppv);
58 return S_OK;
61 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
62 return E_NOINTERFACE;
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);
72 return 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);
82 if(!ref) {
83 if(This->doc && This->doc->location == This)
84 This->doc->location = NULL;
85 heap_free(This);
88 return ref;
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));
125 return E_NOTIMPL;
128 static HRESULT WINAPI HTMLLocation_get_href(IHTMLLocation *iface, BSTR *p)
130 HTMLLocation *This = HTMLLOCATION_THIS(iface);
132 TRACE("(%p)->(%p)\n", This, p);
134 if(!p)
135 return E_POINTER;
137 if(!This->doc || !This->doc->url) {
138 FIXME("No current URL\n");
139 return E_NOTIMPL;
142 *p = SysAllocString(This->doc->url);
144 return S_OK;
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));
151 return E_NOTIMPL;
154 static HRESULT WINAPI HTMLLocation_get_protocol(IHTMLLocation *iface, BSTR *p)
156 HTMLLocation *This = HTMLLOCATION_THIS(iface);
157 FIXME("(%p)->(%p)\n", This, p);
158 return E_NOTIMPL;
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));
165 return E_NOTIMPL;
168 static HRESULT WINAPI HTMLLocation_get_host(IHTMLLocation *iface, BSTR *p)
170 HTMLLocation *This = HTMLLOCATION_THIS(iface);
171 FIXME("(%p)->(%p)\n", This, p);
172 return E_NOTIMPL;
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));
179 return E_NOTIMPL;
182 static HRESULT WINAPI HTMLLocation_get_hostname(IHTMLLocation *iface, BSTR *p)
184 HTMLLocation *This = HTMLLOCATION_THIS(iface);
185 FIXME("(%p)->(%p)\n", This, p);
186 return E_NOTIMPL;
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));
193 return E_NOTIMPL;
196 static HRESULT WINAPI HTMLLocation_get_port(IHTMLLocation *iface, BSTR *p)
198 HTMLLocation *This = HTMLLOCATION_THIS(iface);
199 FIXME("(%p)->(%p)\n", This, p);
200 return E_NOTIMPL;
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));
207 return E_NOTIMPL;
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)};
215 DWORD size = 0;
216 HRESULT hres;
218 TRACE("(%p)->(%p)\n", This, p);
220 if(!This->doc || !This->doc->url) {
221 FIXME("No current URL\n");
222 return E_NOTIMPL;
225 hres = CoInternetParseUrl(This->doc->url, PARSE_PATH_FROM_URL, 0, buf, sizeof(buf), &size, 0);
226 if(SUCCEEDED(hres)) {
227 *p = SysAllocString(buf);
228 if(!*p)
229 return E_OUTOFMEMORY;
230 return S_OK;
233 url.dwUrlPathLength = 1;
234 if(!InternetCrackUrlW(This->doc->url, 0, 0, &url)) {
235 FIXME("InternetCrackUrl failed\n");
236 return E_FAIL;
239 if(!url.dwUrlPathLength) {
240 *p = NULL;
241 return S_OK;
244 *p = SysAllocStringLen(url.lpszUrlPath, url.dwUrlPathLength);
245 if(!*p)
246 return E_OUTOFMEMORY;
247 return S_OK;
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));
254 return E_NOTIMPL;
257 static HRESULT WINAPI HTMLLocation_get_search(IHTMLLocation *iface, BSTR *p)
259 HTMLLocation *This = HTMLLOCATION_THIS(iface);
260 FIXME("(%p)->(%p)\n", This, p);
261 return E_NOTIMPL;
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));
268 return E_NOTIMPL;
271 static HRESULT WINAPI HTMLLocation_get_hash(IHTMLLocation *iface, BSTR *p)
273 HTMLLocation *This = HTMLLOCATION_THIS(iface);
274 FIXME("(%p)->(%p)\n", This, p);
275 return E_NOTIMPL;
278 static HRESULT WINAPI HTMLLocation_reload(IHTMLLocation *iface, VARIANT_BOOL flag)
280 HTMLLocation *This = HTMLLOCATION_THIS(iface);
281 FIXME("(%p)->(%x)\n", This, flag);
282 return E_NOTIMPL;
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));
289 return E_NOTIMPL;
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));
296 return E_NOTIMPL;
299 static HRESULT WINAPI HTMLLocation_toString(IHTMLLocation *iface, BSTR *String)
301 HTMLLocation *This = HTMLLOCATION_THIS(iface);
302 FIXME("(%p)->(%p)\n", This, String);
303 return E_NOTIMPL;
306 #undef HTMLLOCATION_THIS
308 static const IHTMLLocationVtbl HTMLLocationVtbl = {
309 HTMLLocation_QueryInterface,
310 HTMLLocation_AddRef,
311 HTMLLocation_Release,
312 HTMLLocation_GetTypeInfoCount,
313 HTMLLocation_GetTypeInfo,
314 HTMLLocation_GetIDsOfNames,
315 HTMLLocation_Invoke,
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,
332 HTMLLocation_reload,
333 HTMLLocation_replace,
334 HTMLLocation_assign,
335 HTMLLocation_toString
338 static const tid_t HTMLLocation_iface_tids[] = {
339 IHTMLLocation_tid,
342 static dispex_static_data_t HTMLLocation_dispex = {
343 NULL,
344 DispHTMLLocation_tid,
345 NULL,
346 HTMLLocation_iface_tids
350 HTMLLocation *HTMLLocation_Create(HTMLDocument *doc)
352 HTMLLocation *ret = heap_alloc(sizeof(*ret));
354 ret->lpHTMLLocationVtbl = &HTMLLocationVtbl;
355 ret->ref = 1;
356 ret->doc = doc;
358 init_dispex(&ret->dispex, (IUnknown*)HTMLLOCATION(ret), &HTMLLocation_dispex);
360 return ret;