msxml3: Make functions static.
[wine/hacks.git] / dlls / msxml3 / httprequest.c
blobc53957384278e0181f9c951b380788be6e052479
1 /*
2 * IXMLHTTPRequest implementation
4 * Copyright 2008 Alistair Leslie-Hughes
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #define COBJMACROS
22 #include "config.h"
24 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "ole2.h"
29 #include "msxml2.h"
31 #include "msxml_private.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
37 #ifdef HAVE_LIBXML2
39 typedef struct _httprequest
41 const struct IXMLHTTPRequestVtbl *lpVtbl;
42 LONG ref;
43 } httprequest;
45 static inline httprequest *impl_from_IXMLHTTPRequest( IXMLHTTPRequest *iface )
47 return (httprequest *)((char*)iface - FIELD_OFFSET(httprequest, lpVtbl));
50 static HRESULT WINAPI httprequest_QueryInterface(IXMLHTTPRequest *iface, REFIID riid, void **ppvObject)
52 httprequest *This = impl_from_IXMLHTTPRequest( iface );
53 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
55 if ( IsEqualGUID( riid, &IID_IXMLHTTPRequest) ||
56 IsEqualGUID( riid, &IID_IDispatch) ||
57 IsEqualGUID( riid, &IID_IUnknown) )
59 *ppvObject = iface;
61 else
63 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
64 return E_NOINTERFACE;
67 IXMLHTTPRequest_AddRef( iface );
69 return S_OK;
72 static ULONG WINAPI httprequest_AddRef(IXMLHTTPRequest *iface)
74 httprequest *This = impl_from_IXMLHTTPRequest( iface );
75 return InterlockedIncrement( &This->ref );
78 static ULONG WINAPI httprequest_Release(IXMLHTTPRequest *iface)
80 httprequest *This = impl_from_IXMLHTTPRequest( iface );
81 ULONG ref;
83 ref = InterlockedDecrement( &This->ref );
84 if ( ref == 0 )
86 HeapFree( GetProcessHeap(), 0, This );
89 return ref;
92 static HRESULT WINAPI httprequest_GetTypeInfoCount(IXMLHTTPRequest *iface, UINT *pctinfo)
94 httprequest *This = impl_from_IXMLHTTPRequest( iface );
96 TRACE("(%p)->(%p)\n", This, pctinfo);
98 *pctinfo = 1;
100 return S_OK;
103 static HRESULT WINAPI httprequest_GetTypeInfo(IXMLHTTPRequest *iface, UINT iTInfo,
104 LCID lcid, ITypeInfo **ppTInfo)
106 httprequest *This = impl_from_IXMLHTTPRequest( iface );
107 HRESULT hr;
109 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
111 hr = get_typeinfo(IXMLHTTPRequest_tid, ppTInfo);
113 return hr;
116 static HRESULT WINAPI httprequest_GetIDsOfNames(IXMLHTTPRequest *iface, REFIID riid,
117 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
119 httprequest *This = impl_from_IXMLHTTPRequest( iface );
120 ITypeInfo *typeinfo;
121 HRESULT hr;
123 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
124 lcid, rgDispId);
126 if(!rgszNames || cNames == 0 || !rgDispId)
127 return E_INVALIDARG;
129 hr = get_typeinfo(IXMLHTTPRequest_tid, &typeinfo);
130 if(SUCCEEDED(hr))
132 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
133 ITypeInfo_Release(typeinfo);
136 return hr;
139 static HRESULT WINAPI httprequest_Invoke(IXMLHTTPRequest *iface, DISPID dispIdMember, REFIID riid,
140 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
141 EXCEPINFO *pExcepInfo, UINT *puArgErr)
143 httprequest *This = impl_from_IXMLHTTPRequest( iface );
144 ITypeInfo *typeinfo;
145 HRESULT hr;
147 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
148 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
150 hr = get_typeinfo(IXMLHTTPRequest_tid, &typeinfo);
151 if(SUCCEEDED(hr))
153 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
154 pVarResult, pExcepInfo, puArgErr);
155 ITypeInfo_Release(typeinfo);
158 return hr;
161 static HRESULT WINAPI httprequest_open(IXMLHTTPRequest *iface, BSTR bstrMethod, BSTR bstrUrl,
162 VARIANT varAsync, VARIANT bstrUser, VARIANT bstrPassword)
164 httprequest *This = impl_from_IXMLHTTPRequest( iface );
166 FIXME("stub (%p)\n", This);
168 return E_NOTIMPL;
171 static HRESULT WINAPI httprequest_setRequestHeader(IXMLHTTPRequest *iface, BSTR bstrHeader, BSTR bstrValue)
173 httprequest *This = impl_from_IXMLHTTPRequest( iface );
175 FIXME("stub (%p) %s %s\n", This, debugstr_w(bstrHeader), debugstr_w(bstrValue));
177 return E_NOTIMPL;
180 static HRESULT WINAPI httprequest_getResponseHeader(IXMLHTTPRequest *iface, BSTR bstrHeader, BSTR *pbstrValue)
182 httprequest *This = impl_from_IXMLHTTPRequest( iface );
184 FIXME("stub (%p) %s %p\n", This, debugstr_w(bstrHeader), pbstrValue);
186 return E_NOTIMPL;
189 static HRESULT WINAPI httprequest_getAllResponseHeaders(IXMLHTTPRequest *iface, BSTR *pbstrHeaders)
191 httprequest *This = impl_from_IXMLHTTPRequest( iface );
193 FIXME("stub (%p) %p\n", This, pbstrHeaders);
195 return E_NOTIMPL;
198 static HRESULT WINAPI httprequest_send(IXMLHTTPRequest *iface, VARIANT varBody)
200 httprequest *This = impl_from_IXMLHTTPRequest( iface );
202 FIXME("stub (%p)\n", This);
204 return E_NOTIMPL;
207 static HRESULT WINAPI httprequest_abort(IXMLHTTPRequest *iface)
209 httprequest *This = impl_from_IXMLHTTPRequest( iface );
211 FIXME("stub (%p)\n", This);
213 return E_NOTIMPL;
216 static HRESULT WINAPI httprequest_get_status(IXMLHTTPRequest *iface, long *plStatus)
218 httprequest *This = impl_from_IXMLHTTPRequest( iface );
220 FIXME("stub %p %p\n", This, plStatus);
222 return E_NOTIMPL;
225 static HRESULT WINAPI httprequest_get_statusText(IXMLHTTPRequest *iface, BSTR *pbstrStatus)
227 httprequest *This = impl_from_IXMLHTTPRequest( iface );
229 FIXME("stub %p %p\n", This, pbstrStatus);
231 return E_NOTIMPL;
234 static HRESULT WINAPI httprequest_get_responseXML(IXMLHTTPRequest *iface, IDispatch **ppBody)
236 httprequest *This = impl_from_IXMLHTTPRequest( iface );
238 FIXME("stub %p %p\n", This, ppBody);
240 return E_NOTIMPL;
243 static HRESULT WINAPI httprequest_get_responseText(IXMLHTTPRequest *iface, BSTR *pbstrBody)
245 httprequest *This = impl_from_IXMLHTTPRequest( iface );
247 FIXME("stub %p %p\n", This, pbstrBody);
249 return E_NOTIMPL;
252 static HRESULT WINAPI httprequest_get_responseBody(IXMLHTTPRequest *iface, VARIANT *pvarBody)
254 httprequest *This = impl_from_IXMLHTTPRequest( iface );
256 FIXME("stub %p %p\n", This, pvarBody);
258 return E_NOTIMPL;
261 static HRESULT WINAPI httprequest_get_responseStream(IXMLHTTPRequest *iface, VARIANT *pvarBody)
263 httprequest *This = impl_from_IXMLHTTPRequest( iface );
265 FIXME("stub %p %p\n", This, pvarBody);
267 return E_NOTIMPL;
270 static HRESULT WINAPI httprequest_get_readyState(IXMLHTTPRequest *iface, long *plState)
272 httprequest *This = impl_from_IXMLHTTPRequest( iface );
274 FIXME("stub %p %p\n", This, plState);
276 return E_NOTIMPL;
279 static HRESULT WINAPI httprequest_put_onreadystatechange(IXMLHTTPRequest *iface, IDispatch *pReadyStateSink)
281 httprequest *This = impl_from_IXMLHTTPRequest( iface );
283 FIXME("stub %p %p\n", This, pReadyStateSink);
285 return E_NOTIMPL;
288 static const struct IXMLHTTPRequestVtbl dimimpl_vtbl =
290 httprequest_QueryInterface,
291 httprequest_AddRef,
292 httprequest_Release,
293 httprequest_GetTypeInfoCount,
294 httprequest_GetTypeInfo,
295 httprequest_GetIDsOfNames,
296 httprequest_Invoke,
297 httprequest_open,
298 httprequest_setRequestHeader,
299 httprequest_getResponseHeader,
300 httprequest_getAllResponseHeaders,
301 httprequest_send,
302 httprequest_abort,
303 httprequest_get_status,
304 httprequest_get_statusText,
305 httprequest_get_responseXML,
306 httprequest_get_responseText,
307 httprequest_get_responseBody,
308 httprequest_get_responseStream,
309 httprequest_get_readyState,
310 httprequest_put_onreadystatechange
313 HRESULT XMLHTTPRequest_create(IUnknown *pUnkOuter, LPVOID *ppObj)
315 httprequest *req;
316 HRESULT hr = S_OK;
318 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
320 req = HeapAlloc( GetProcessHeap(), 0, sizeof (*req) );
321 if( !req )
322 return E_OUTOFMEMORY;
324 req->lpVtbl = &dimimpl_vtbl;
325 req->ref = 1;
327 *ppObj = &req->lpVtbl;
329 TRACE("returning iface %p\n", *ppObj);
331 return hr;
334 #else
336 HRESULT XMLHTTPRequest_create(IUnknown *pUnkOuter, LPVOID *ppObj)
338 MESSAGE("This program tried to use a XMLHTTPRequest object, but\n"
339 "libxml2 support was not present at compile time.\n");
340 return E_NOTIMPL;
343 #endif