[URLMON]
[reactos.git] / reactos / dll / win32 / urlmon / uri.c
1 /*
2 * Copyright 2010 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 "urlmon_main.h"
20 #include "wine/debug.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
23
24 typedef struct {
25 const IUriVtbl *lpIUriVtbl;
26 LONG ref;
27 } Uri;
28
29 #define URI(x) ((IUri*) &(x)->lpIUriVtbl)
30
31 #define URI_THIS(iface) DEFINE_THIS(Uri, IUri, iface)
32
33 static HRESULT WINAPI Uri_QueryInterface(IUri *iface, REFIID riid, void **ppv)
34 {
35 Uri *This = URI_THIS(iface);
36
37 if(IsEqualGUID(&IID_IUnknown, riid)) {
38 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
39 *ppv = URI(This);
40 }else if(IsEqualGUID(&IID_IUri, riid)) {
41 TRACE("(%p)->(IID_IUri %p)\n", This, ppv);
42 *ppv = URI(This);
43 }else {
44 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
45 *ppv = NULL;
46 return E_NOINTERFACE;
47 }
48
49 IUnknown_AddRef((IUnknown*)*ppv);
50 return S_OK;
51 }
52
53 static ULONG WINAPI Uri_AddRef(IUri *iface)
54 {
55 Uri *This = URI_THIS(iface);
56 LONG ref = InterlockedIncrement(&This->ref);
57
58 TRACE("(%p) ref=%d\n", This, ref);
59
60 return ref;
61 }
62
63 static ULONG WINAPI Uri_Release(IUri *iface)
64 {
65 Uri *This = URI_THIS(iface);
66 LONG ref = InterlockedDecrement(&This->ref);
67
68 TRACE("(%p) ref=%d\n", This, ref);
69
70 if(!ref)
71 heap_free(This);
72
73 return ref;
74 }
75
76 static HRESULT WINAPI Uri_GetPropertyBSTR(IUri *iface, Uri_PROPERTY uriProp, BSTR *pbstrProperty, DWORD dwFlags)
77 {
78 Uri *This = URI_THIS(iface);
79 FIXME("(%p)->(%d %p %x)\n", This, uriProp, pbstrProperty, dwFlags);
80 return E_NOTIMPL;
81 }
82
83 static HRESULT WINAPI Uri_GetPropertyLength(IUri *iface, Uri_PROPERTY uriProp, DWORD *pcchProperty, DWORD dwFlags)
84 {
85 Uri *This = URI_THIS(iface);
86 FIXME("(%p)->(%d %p %x)\n", This, uriProp, pcchProperty, dwFlags);
87 return E_NOTIMPL;
88 }
89
90 static HRESULT WINAPI Uri_GetPropertyDWORD(IUri *iface, Uri_PROPERTY uriProp, DWORD *pcchProperty, DWORD dwFlags)
91 {
92 Uri *This = URI_THIS(iface);
93 FIXME("(%p)->(%d %p %x)\n", This, uriProp, pcchProperty, dwFlags);
94 return E_NOTIMPL;
95 }
96
97 static HRESULT WINAPI Uri_HasProperty(IUri *iface, Uri_PROPERTY uriProp, BOOL *pfHasProperty)
98 {
99 Uri *This = URI_THIS(iface);
100 FIXME("(%p)->()\n", This);
101 return E_NOTIMPL;
102 }
103
104 static HRESULT WINAPI Uri_GetAbsoluteUri(IUri *iface, BSTR *pstrAbsoluteUri)
105 {
106 Uri *This = URI_THIS(iface);
107 FIXME("(%p)->(%p)\n", This, pstrAbsoluteUri);
108 return E_NOTIMPL;
109 }
110
111 static HRESULT WINAPI Uri_GetAuthority(IUri *iface, BSTR *pstrAuthority)
112 {
113 Uri *This = URI_THIS(iface);
114 FIXME("(%p)->(%p)\n", This, pstrAuthority);
115 return E_NOTIMPL;
116 }
117
118 static HRESULT WINAPI Uri_GetDisplayUri(IUri *iface, BSTR *pstrDisplayUri)
119 {
120 Uri *This = URI_THIS(iface);
121 FIXME("(%p)->(%p)\n", This, pstrDisplayUri);
122 return E_NOTIMPL;
123 }
124
125 static HRESULT WINAPI Uri_GetDomain(IUri *iface, BSTR *pstrDomain)
126 {
127 Uri *This = URI_THIS(iface);
128 FIXME("(%p)->(%p)\n", This, pstrDomain);
129 return E_NOTIMPL;
130 }
131
132 static HRESULT WINAPI Uri_GetExtension(IUri *iface, BSTR *pstrExtension)
133 {
134 Uri *This = URI_THIS(iface);
135 FIXME("(%p)->(%p)\n", This, pstrExtension);
136 return E_NOTIMPL;
137 }
138
139 static HRESULT WINAPI Uri_GetFragment(IUri *iface, BSTR *pstrFragment)
140 {
141 Uri *This = URI_THIS(iface);
142 FIXME("(%p)->(%p)\n", This, pstrFragment);
143 return E_NOTIMPL;
144 }
145
146 static HRESULT WINAPI Uri_GetHost(IUri *iface, BSTR *pstrHost)
147 {
148 Uri *This = URI_THIS(iface);
149 FIXME("(%p)->(%p)\n", This, pstrHost);
150 return E_NOTIMPL;
151 }
152
153 static HRESULT WINAPI Uri_GetPassword(IUri *iface, BSTR *pstrPassword)
154 {
155 Uri *This = URI_THIS(iface);
156 FIXME("(%p)->(%p)\n", This, pstrPassword);
157 return E_NOTIMPL;
158 }
159
160 static HRESULT WINAPI Uri_GetPath(IUri *iface, BSTR *pstrPath)
161 {
162 Uri *This = URI_THIS(iface);
163 FIXME("(%p)->(%p)\n", This, pstrPath);
164 return E_NOTIMPL;
165 }
166
167 static HRESULT WINAPI Uri_GetPathAndQuery(IUri *iface, BSTR *pstrPathAndQuery)
168 {
169 Uri *This = URI_THIS(iface);
170 FIXME("(%p)->(%p)\n", This, pstrPathAndQuery);
171 return E_NOTIMPL;
172 }
173
174 static HRESULT WINAPI Uri_GetQuery(IUri *iface, BSTR *pstrQuery)
175 {
176 Uri *This = URI_THIS(iface);
177 FIXME("(%p)->(%p)\n", This, pstrQuery);
178 return E_NOTIMPL;
179 }
180
181 static HRESULT WINAPI Uri_GetRawUri(IUri *iface, BSTR *pstrRawUri)
182 {
183 Uri *This = URI_THIS(iface);
184 FIXME("(%p)->(%p)\n", This, pstrRawUri);
185 return E_NOTIMPL;
186 }
187
188 static HRESULT WINAPI Uri_GetSchemeName(IUri *iface, BSTR *pstrSchemeName)
189 {
190 Uri *This = URI_THIS(iface);
191 FIXME("(%p)->(%p)\n", This, pstrSchemeName);
192 return E_NOTIMPL;
193 }
194
195 static HRESULT WINAPI Uri_GetUserInfo(IUri *iface, BSTR *pstrUserInfo)
196 {
197 Uri *This = URI_THIS(iface);
198 FIXME("(%p)->(%p)\n", This, pstrUserInfo);
199 return E_NOTIMPL;
200 }
201
202 static HRESULT WINAPI Uri_GetUserName(IUri *iface, BSTR *pstrUserName)
203 {
204 Uri *This = URI_THIS(iface);
205 FIXME("(%p)->(%p)\n", This, pstrUserName);
206 return E_NOTIMPL;
207 }
208
209 static HRESULT WINAPI Uri_GetHostType(IUri *iface, DWORD *pdwHostType)
210 {
211 Uri *This = URI_THIS(iface);
212 FIXME("(%p)->(%p)\n", This, pdwHostType);
213 return E_NOTIMPL;
214 }
215
216 static HRESULT WINAPI Uri_GetPort(IUri *iface, DWORD *pdwPort)
217 {
218 Uri *This = URI_THIS(iface);
219 FIXME("(%p)->(%p)\n", This, pdwPort);
220 return E_NOTIMPL;
221 }
222
223 static HRESULT WINAPI Uri_GetScheme(IUri *iface, DWORD *pdwScheme)
224 {
225 Uri *This = URI_THIS(iface);
226 FIXME("(%p)->(%p)\n", This, pdwScheme);
227 return E_NOTIMPL;
228 }
229
230 static HRESULT WINAPI Uri_GetZone(IUri *iface, DWORD *pdwZone)
231 {
232 Uri *This = URI_THIS(iface);
233 FIXME("(%p)->(%p)\n", This, pdwZone);
234 return E_NOTIMPL;
235 }
236
237 static HRESULT WINAPI Uri_GetProperties(IUri *iface, DWORD *pdwProperties)
238 {
239 Uri *This = URI_THIS(iface);
240 FIXME("(%p)->(%p)\n", This, pdwProperties);
241 return E_NOTIMPL;
242 }
243
244 static HRESULT WINAPI Uri_IsEqual(IUri *iface, IUri *pUri, BOOL *pfEqual)
245 {
246 Uri *This = URI_THIS(iface);
247 FIXME("(%p)->(%p %p)\n", This, pUri, pfEqual);
248 return E_NOTIMPL;
249 }
250
251 #undef URI_THIS
252
253 static const IUriVtbl UriVtbl = {
254 Uri_QueryInterface,
255 Uri_AddRef,
256 Uri_Release,
257 Uri_GetPropertyBSTR,
258 Uri_GetPropertyLength,
259 Uri_GetPropertyDWORD,
260 Uri_HasProperty,
261 Uri_GetAbsoluteUri,
262 Uri_GetAuthority,
263 Uri_GetDisplayUri,
264 Uri_GetDomain,
265 Uri_GetExtension,
266 Uri_GetFragment,
267 Uri_GetHost,
268 Uri_GetPassword,
269 Uri_GetPath,
270 Uri_GetPathAndQuery,
271 Uri_GetQuery,
272 Uri_GetRawUri,
273 Uri_GetSchemeName,
274 Uri_GetUserInfo,
275 Uri_GetUserName,
276 Uri_GetHostType,
277 Uri_GetPort,
278 Uri_GetScheme,
279 Uri_GetZone,
280 Uri_GetProperties,
281 Uri_IsEqual
282 };
283
284 /***********************************************************************
285 * CreateUri (urlmon.@)
286 */
287 HRESULT WINAPI CreateUri(LPCWSTR pwzURI, DWORD dwFlags, DWORD_PTR dwReserved, IUri **ppURI)
288 {
289 Uri *ret;
290
291 TRACE("(%s %x %x %p)\n", debugstr_w(pwzURI), dwFlags, (DWORD)dwReserved, ppURI);
292
293 ret = heap_alloc(sizeof(Uri));
294 if(!ret)
295 return E_OUTOFMEMORY;
296
297 ret->lpIUriVtbl = &UriVtbl;
298 ret->ref = 1;
299
300 *ppURI = URI(ret);
301 return S_OK;
302 }