• Classes
  • Modules
  • Namespaces
  • Files
  • Related Pages
  • File List
  • File Members

XMLHttpRequest.h

Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  * 
00009  *      http://www.apache.org/licenses/LICENSE-2.0
00010  * 
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 /*
00019  * $Id: XMLHttpRequest.h 568078 2007-08-21 11:43:25Z amassari $
00020  */
00021 
00022 #ifndef ___xmlhttprequest_h___
00023 #define ___xmlhttprequest_h___
00024 
00025 #include <xercesc/dom/DOMDocument.hpp>
00026 #include "IXMLDOMNodeImpl.h"
00027 
00028 #include "resource.h"       // main symbols
00029 
00030 class ATL_NO_VTABLE CXMLHttpRequest : 
00031         public CComObjectRootEx<CComSingleThreadModel>,
00032         public CComCoClass<CXMLHttpRequest, &CLSID_XMLHTTPRequest>,
00033         public IObjectSafetyImpl<CXMLHttpRequest, INTERFACESAFE_FOR_UNTRUSTED_CALLER>,
00034         public IDispatchImpl<IXMLHttpRequest, &IID_IXMLHttpRequest, &LIBID_Xerces, XERCES_VERSION_MAJOR, INVK_CAT2_RAW_NUMERIC(XERCES_VERSION_MINOR,XERCES_VERSION_REVISION)>,
00035         public IObjectWithSiteImpl<CXMLHttpRequest>,
00036         public ISupportErrorInfo,
00037         public CWindowImpl<CXMLHttpRequest, CWindow, CWinTraits<0,0> >
00038 {
00039 public:
00040         CXMLHttpRequest();
00041 
00042         HRESULT FinalConstruct();
00043         void    FinalRelease();
00044 
00045         //DECLARE_REGISTRY_RESOURCEID(IDR_XMLHTTPREQUEST)
00046         static HRESULT WINAPI UpdateRegistry(BOOL bRegister);
00047 
00048 DECLARE_NOT_AGGREGATABLE(CXMLHttpRequest)
00049 
00050 DECLARE_PROTECT_FINAL_CONSTRUCT()
00051 
00052 BEGIN_COM_MAP(CXMLHttpRequest)
00053         COM_INTERFACE_ENTRY(IXMLHttpRequest)
00054         COM_INTERFACE_ENTRY(IDispatch)
00055         COM_INTERFACE_ENTRY(IObjectSafety)
00056         COM_INTERFACE_ENTRY(IObjectWithSite)
00057         COM_INTERFACE_ENTRY(ISupportErrorInfo)
00058 END_COM_MAP()
00059 
00060         DECLARE_WND_CLASS(_T("XMLHttpRequestMonitor")) 
00061 
00062 BEGIN_MSG_MAP(CMonitorWnd)
00063         MESSAGE_HANDLER(MSG_READY_STATE_CHANGE, OnReadyStateChange)
00064 END_MSG_MAP()
00065 
00066         LRESULT OnReadyStateChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
00067 
00068 
00069         // ISupportsErrorInfo
00070         STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
00071 
00072         // IXMLHttpRequest methods
00073         STDMETHOD(open)(/*[in]*/ BSTR bstrMethod, /*[in]*/ BSTR bstrUrl, /*[in,optional]*/ VARIANT varAsync, /*[in,optional]*/ VARIANT bstrUser, /*[in,optional]*/ VARIANT bstrPassword);
00074         STDMETHOD(setRequestHeader)(/*[in]*/ BSTR bstrHeader, /*[in]*/ BSTR bstrValue);
00075         STDMETHOD(getResponseHeader)(/*[in]*/ BSTR bstrHeader, /*[out, retval]*/ BSTR * pbstrValue);
00076         STDMETHOD(getAllResponseHeaders)(/*[out, retval]*/ BSTR * pbstrHeaders);
00077         STDMETHOD(send)(/*[in, optional]*/ VARIANT varBody);
00078         STDMETHOD(abort)();
00079         STDMETHOD(get_status)(/*[out, retval]*/ long * plStatus);
00080         STDMETHOD(get_statusText)(/*[out, retval]*/ BSTR * pbstrStatus);
00081         STDMETHOD(get_responseXML)(/*[out, retval]*/ IDispatch ** ppBody);
00082         STDMETHOD(get_responseText)(/*[out, retval]*/ BSTR * pbstrBody);
00083         STDMETHOD(get_responseBody)(/*[out, retval]*/ VARIANT * pvarBody);
00084         STDMETHOD(get_responseStream)(/*[out, retval]*/ VARIANT * pvarBody);
00085         STDMETHOD(get_readyState)(/*[out, retval]*/ long * plState);
00086         STDMETHOD(put_onreadystatechange)(/*[in]*/ IDispatch * pReadyStateSink);
00087 
00088 private:
00089 
00090         LPDISPATCH        m_pOnReadyStateChange;
00091         bool              m_bAbort;     
00092         HANDLE            m_hThread;            
00093         long              m_lReadyState;
00094         bool              m_bAsync;     
00095         _bstr_t           m_Method;
00096         _bstr_t           m_HostName;   
00097         INTERNET_PORT m_Port;
00098         _bstr_t           m_URLPath;
00099         _bstr_t           m_User;
00100         _bstr_t           m_Password;
00101         DWORD             m_dwStatus;
00102         _bstr_t           m_StatusText; 
00103         _bstr_t           m_ResponseHeaders;
00104         CSimpleMap<_bstr_t, _bstr_t>  m_RequestHeaderMap;
00105         HWND              m_HwndParent;         
00106  
00107         PBYTE             m_pBody;
00108         long              m_lBodyLength;
00109         PBYTE             m_pResponseBody;
00110         long              m_lResponseBodyLength;
00111         _bstr_t       m_Error;  
00112         bool          m_bSuccess;
00113 
00114         HWND GetParentWindow();
00115 
00116         static _bstr_t GetErrorMsg(DWORD rc);
00117         static void CALLBACK InternetStatusCallback(HINTERNET hInternet,
00118                                                                                                 DWORD_PTR dwContext,
00119                                                                                                 DWORD dwInternetStatus,
00120                                                                                                 LPVOID lpvStatusInformation,
00121                                                                                                 DWORD dwStatusInformationLength);
00122         static UINT APIENTRY SendThread(void *pParm);
00123         static HRESULT InitializeVarFromByte(VARIANT &varOut, const PBYTE pByte, long lSize);
00124 };
00125 
00126 typedef CComObject<CXMLHttpRequest> CXMLHttpRequestObj;
00127 
00128 #endif // ___xmlhttprequest_h___

Generated on Thu Jan 12 2012 23:13:51 for ACS-10.0 C++ API by  doxygen 1.7.0