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
31 #include "msxml_private.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(msxml
);
39 typedef struct _httprequest
41 const struct IXMLHTTPRequestVtbl
*lpVtbl
;
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
) )
63 FIXME("Unsupported interface %s\n", debugstr_guid(riid
));
67 IXMLHTTPRequest_AddRef( iface
);
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
);
83 ref
= InterlockedDecrement( &This
->ref
);
86 HeapFree( GetProcessHeap(), 0, This
);
92 static HRESULT WINAPI
httprequest_GetTypeInfoCount(IXMLHTTPRequest
*iface
, UINT
*pctinfo
)
94 httprequest
*This
= impl_from_IXMLHTTPRequest( iface
);
96 TRACE("(%p)->(%p)\n", This
, pctinfo
);
103 static HRESULT WINAPI
httprequest_GetTypeInfo(IXMLHTTPRequest
*iface
, UINT iTInfo
,
104 LCID lcid
, ITypeInfo
**ppTInfo
)
106 httprequest
*This
= impl_from_IXMLHTTPRequest( iface
);
109 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
111 hr
= get_typeinfo(IXMLHTTPRequest_tid
, ppTInfo
);
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
);
123 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
126 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
129 hr
= get_typeinfo(IXMLHTTPRequest_tid
, &typeinfo
);
132 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
133 ITypeInfo_Release(typeinfo
);
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
);
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
);
153 hr
= ITypeInfo_Invoke(typeinfo
, &(This
->lpVtbl
), dispIdMember
, wFlags
, pDispParams
,
154 pVarResult
, pExcepInfo
, puArgErr
);
155 ITypeInfo_Release(typeinfo
);
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
);
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
));
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
);
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
);
198 static HRESULT WINAPI
httprequest_send(IXMLHTTPRequest
*iface
, VARIANT varBody
)
200 httprequest
*This
= impl_from_IXMLHTTPRequest( iface
);
202 FIXME("stub (%p)\n", This
);
207 static HRESULT WINAPI
httprequest_abort(IXMLHTTPRequest
*iface
)
209 httprequest
*This
= impl_from_IXMLHTTPRequest( iface
);
211 FIXME("stub (%p)\n", This
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
288 static const struct IXMLHTTPRequestVtbl dimimpl_vtbl
=
290 httprequest_QueryInterface
,
293 httprequest_GetTypeInfoCount
,
294 httprequest_GetTypeInfo
,
295 httprequest_GetIDsOfNames
,
298 httprequest_setRequestHeader
,
299 httprequest_getResponseHeader
,
300 httprequest_getAllResponseHeaders
,
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
)
318 TRACE("(%p,%p)\n", pUnkOuter
, ppObj
);
320 req
= HeapAlloc( GetProcessHeap(), 0, sizeof (*req
) );
322 return E_OUTOFMEMORY
;
324 req
->lpVtbl
= &dimimpl_vtbl
;
327 *ppObj
= &req
->lpVtbl
;
329 TRACE("returning iface %p\n", *ppObj
);
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");