ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

httprequest.c
Go to the documentation of this file.
00001 /*
00002  *    IXMLHTTPRequest implementation
00003  *
00004  * Copyright 2008 Alistair Leslie-Hughes
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00019  */
00020 #define COBJMACROS
00021 
00022 #include "config.h"
00023 
00024 #include <stdarg.h>
00025 #include "windef.h"
00026 #include "winbase.h"
00027 #include "winuser.h"
00028 #include "ole2.h"
00029 #include "msxml2.h"
00030 
00031 #include "msxml_private.h"
00032 
00033 #include "wine/debug.h"
00034 
00035 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
00036 
00037 #ifdef HAVE_LIBXML2
00038 
00039 typedef struct _httprequest
00040 {
00041     const struct IXMLHTTPRequestVtbl *lpVtbl;
00042     LONG ref;
00043 } httprequest;
00044 
00045 static inline httprequest *impl_from_IXMLHTTPRequest( IXMLHTTPRequest *iface )
00046 {
00047     return (httprequest *)((char*)iface - FIELD_OFFSET(httprequest, lpVtbl));
00048 }
00049 
00050 static HRESULT WINAPI httprequest_QueryInterface(IXMLHTTPRequest *iface, REFIID riid, void **ppvObject)
00051 {
00052     httprequest *This = impl_from_IXMLHTTPRequest( iface );
00053     TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
00054 
00055     if ( IsEqualGUID( riid, &IID_IXMLHTTPRequest) ||
00056          IsEqualGUID( riid, &IID_IDispatch) ||
00057          IsEqualGUID( riid, &IID_IUnknown) )
00058     {
00059         *ppvObject = iface;
00060     }
00061     else
00062     {
00063         FIXME("Unsupported interface %s\n", debugstr_guid(riid));
00064         return E_NOINTERFACE;
00065     }
00066 
00067     IXMLHTTPRequest_AddRef( iface );
00068 
00069     return S_OK;
00070 }
00071 
00072 static ULONG WINAPI httprequest_AddRef(IXMLHTTPRequest *iface)
00073 {
00074     httprequest *This = impl_from_IXMLHTTPRequest( iface );
00075     return InterlockedIncrement( &This->ref );
00076 }
00077 
00078 static ULONG WINAPI httprequest_Release(IXMLHTTPRequest *iface)
00079 {
00080     httprequest *This = impl_from_IXMLHTTPRequest( iface );
00081     ULONG ref;
00082 
00083     ref = InterlockedDecrement( &This->ref );
00084     if ( ref == 0 )
00085     {
00086         heap_free( This );
00087     }
00088 
00089     return ref;
00090 }
00091 
00092 static HRESULT WINAPI httprequest_GetTypeInfoCount(IXMLHTTPRequest *iface, UINT *pctinfo)
00093 {
00094     httprequest *This = impl_from_IXMLHTTPRequest( iface );
00095 
00096     TRACE("(%p)->(%p)\n", This, pctinfo);
00097 
00098     *pctinfo = 1;
00099 
00100     return S_OK;
00101 }
00102 
00103 static HRESULT WINAPI httprequest_GetTypeInfo(IXMLHTTPRequest *iface, UINT iTInfo,
00104         LCID lcid, ITypeInfo **ppTInfo)
00105 {
00106     httprequest *This = impl_from_IXMLHTTPRequest( iface );
00107     HRESULT hr;
00108 
00109     TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
00110 
00111     hr = get_typeinfo(IXMLHTTPRequest_tid, ppTInfo);
00112 
00113     return hr;
00114 }
00115 
00116 static HRESULT WINAPI httprequest_GetIDsOfNames(IXMLHTTPRequest *iface, REFIID riid,
00117         LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
00118 {
00119     httprequest *This = impl_from_IXMLHTTPRequest( iface );
00120     ITypeInfo *typeinfo;
00121     HRESULT hr;
00122 
00123     TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
00124           lcid, rgDispId);
00125 
00126     if(!rgszNames || cNames == 0 || !rgDispId)
00127         return E_INVALIDARG;
00128 
00129     hr = get_typeinfo(IXMLHTTPRequest_tid, &typeinfo);
00130     if(SUCCEEDED(hr))
00131     {
00132         hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
00133         ITypeInfo_Release(typeinfo);
00134     }
00135 
00136     return hr;
00137 }
00138 
00139 static HRESULT WINAPI httprequest_Invoke(IXMLHTTPRequest *iface, DISPID dispIdMember, REFIID riid,
00140         LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
00141         EXCEPINFO *pExcepInfo, UINT *puArgErr)
00142 {
00143     httprequest *This = impl_from_IXMLHTTPRequest( iface );
00144     ITypeInfo *typeinfo;
00145     HRESULT hr;
00146 
00147     TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
00148           lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
00149 
00150     hr = get_typeinfo(IXMLHTTPRequest_tid, &typeinfo);
00151     if(SUCCEEDED(hr))
00152     {
00153         hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
00154                 pVarResult, pExcepInfo, puArgErr);
00155         ITypeInfo_Release(typeinfo);
00156     }
00157 
00158     return hr;
00159 }
00160 
00161 static HRESULT WINAPI httprequest_open(IXMLHTTPRequest *iface, BSTR bstrMethod, BSTR bstrUrl,
00162         VARIANT varAsync, VARIANT bstrUser, VARIANT bstrPassword)
00163 {
00164     httprequest *This = impl_from_IXMLHTTPRequest( iface );
00165 
00166     FIXME("stub (%p)\n", This);
00167 
00168     return E_NOTIMPL;
00169 }
00170 
00171 static HRESULT WINAPI httprequest_setRequestHeader(IXMLHTTPRequest *iface, BSTR bstrHeader, BSTR bstrValue)
00172 {
00173     httprequest *This = impl_from_IXMLHTTPRequest( iface );
00174 
00175     FIXME("stub (%p) %s %s\n", This, debugstr_w(bstrHeader), debugstr_w(bstrValue));
00176 
00177     return E_NOTIMPL;
00178 }
00179 
00180 static HRESULT WINAPI httprequest_getResponseHeader(IXMLHTTPRequest *iface, BSTR bstrHeader, BSTR *pbstrValue)
00181 {
00182     httprequest *This = impl_from_IXMLHTTPRequest( iface );
00183 
00184     FIXME("stub (%p) %s %p\n", This, debugstr_w(bstrHeader), pbstrValue);
00185 
00186     return E_NOTIMPL;
00187 }
00188 
00189 static HRESULT WINAPI httprequest_getAllResponseHeaders(IXMLHTTPRequest *iface, BSTR *pbstrHeaders)
00190 {
00191     httprequest *This = impl_from_IXMLHTTPRequest( iface );
00192 
00193     FIXME("stub (%p) %p\n", This, pbstrHeaders);
00194 
00195     return E_NOTIMPL;
00196 }
00197 
00198 static HRESULT WINAPI httprequest_send(IXMLHTTPRequest *iface, VARIANT varBody)
00199 {
00200     httprequest *This = impl_from_IXMLHTTPRequest( iface );
00201 
00202     FIXME("stub (%p)\n", This);
00203 
00204     return E_NOTIMPL;
00205 }
00206 
00207 static HRESULT WINAPI httprequest_abort(IXMLHTTPRequest *iface)
00208 {
00209     httprequest *This = impl_from_IXMLHTTPRequest( iface );
00210 
00211     FIXME("stub (%p)\n", This);
00212 
00213     return E_NOTIMPL;
00214 }
00215 
00216 static HRESULT WINAPI httprequest_get_status(IXMLHTTPRequest *iface, LONG *plStatus)
00217 {
00218     httprequest *This = impl_from_IXMLHTTPRequest( iface );
00219 
00220     FIXME("stub %p %p\n", This, plStatus);
00221 
00222     return E_NOTIMPL;
00223 }
00224 
00225 static HRESULT WINAPI httprequest_get_statusText(IXMLHTTPRequest *iface, BSTR *pbstrStatus)
00226 {
00227     httprequest *This = impl_from_IXMLHTTPRequest( iface );
00228 
00229     FIXME("stub %p %p\n", This, pbstrStatus);
00230 
00231     return E_NOTIMPL;
00232 }
00233 
00234 static HRESULT WINAPI httprequest_get_responseXML(IXMLHTTPRequest *iface, IDispatch **ppBody)
00235 {
00236     httprequest *This = impl_from_IXMLHTTPRequest( iface );
00237 
00238     FIXME("stub %p %p\n", This, ppBody);
00239 
00240     return E_NOTIMPL;
00241 }
00242 
00243 static HRESULT WINAPI httprequest_get_responseText(IXMLHTTPRequest *iface, BSTR *pbstrBody)
00244 {
00245     httprequest *This = impl_from_IXMLHTTPRequest( iface );
00246 
00247     FIXME("stub %p %p\n", This, pbstrBody);
00248 
00249     return E_NOTIMPL;
00250 }
00251 
00252 static HRESULT WINAPI httprequest_get_responseBody(IXMLHTTPRequest *iface, VARIANT *pvarBody)
00253 {
00254     httprequest *This = impl_from_IXMLHTTPRequest( iface );
00255 
00256     FIXME("stub %p %p\n", This, pvarBody);
00257 
00258     return E_NOTIMPL;
00259 }
00260 
00261 static HRESULT WINAPI httprequest_get_responseStream(IXMLHTTPRequest *iface, VARIANT *pvarBody)
00262 {
00263     httprequest *This = impl_from_IXMLHTTPRequest( iface );
00264 
00265     FIXME("stub %p %p\n", This, pvarBody);
00266 
00267     return E_NOTIMPL;
00268 }
00269 
00270 static HRESULT WINAPI httprequest_get_readyState(IXMLHTTPRequest *iface, LONG *plState)
00271 {
00272     httprequest *This = impl_from_IXMLHTTPRequest( iface );
00273 
00274     FIXME("stub %p %p\n", This, plState);
00275 
00276     return E_NOTIMPL;
00277 }
00278 
00279 static HRESULT WINAPI httprequest_put_onreadystatechange(IXMLHTTPRequest *iface, IDispatch *pReadyStateSink)
00280 {
00281     httprequest *This = impl_from_IXMLHTTPRequest( iface );
00282 
00283     FIXME("stub %p %p\n", This, pReadyStateSink);
00284 
00285     return E_NOTIMPL;
00286 }
00287 
00288 static const struct IXMLHTTPRequestVtbl dimimpl_vtbl =
00289 {
00290     httprequest_QueryInterface,
00291     httprequest_AddRef,
00292     httprequest_Release,
00293     httprequest_GetTypeInfoCount,
00294     httprequest_GetTypeInfo,
00295     httprequest_GetIDsOfNames,
00296     httprequest_Invoke,
00297     httprequest_open,
00298     httprequest_setRequestHeader,
00299     httprequest_getResponseHeader,
00300     httprequest_getAllResponseHeaders,
00301     httprequest_send,
00302     httprequest_abort,
00303     httprequest_get_status,
00304     httprequest_get_statusText,
00305     httprequest_get_responseXML,
00306     httprequest_get_responseText,
00307     httprequest_get_responseBody,
00308     httprequest_get_responseStream,
00309     httprequest_get_readyState,
00310     httprequest_put_onreadystatechange
00311 };
00312 
00313 HRESULT XMLHTTPRequest_create(IUnknown *pUnkOuter, LPVOID *ppObj)
00314 {
00315     httprequest *req;
00316     HRESULT hr = S_OK;
00317 
00318     TRACE("(%p,%p)\n", pUnkOuter, ppObj);
00319 
00320     req = heap_alloc( sizeof (*req) );
00321     if( !req )
00322         return E_OUTOFMEMORY;
00323 
00324     req->lpVtbl = &dimimpl_vtbl;
00325     req->ref = 1;
00326 
00327     *ppObj = &req->lpVtbl;
00328 
00329     TRACE("returning iface %p\n", *ppObj);
00330 
00331     return hr;
00332 }
00333 
00334 #else
00335 
00336 HRESULT XMLHTTPRequest_create(IUnknown *pUnkOuter, LPVOID *ppObj)
00337 {
00338     MESSAGE("This program tried to use a XMLHTTPRequest object, but\n"
00339             "libxml2 support was not present at compile time.\n");
00340     return E_NOTIMPL;
00341 }
00342 
00343 #endif

Generated on Sun May 27 2012 04:25:24 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.