Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

XMLHttpRequest.h

Go to the documentation of this file.
00001 /* 00002 * Copyright 1999-2000,2004 The Apache Software Foundation. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 /* 00018 * $Log: XMLHttpRequest.h,v $ 00019 * Revision 1.7 2004/09/08 13:55:36 peiyongz 00020 * Apache License Version 2.0 00021 * 00022 * Revision 1.6 2004/02/25 18:38:33 amassari 00023 * The COM wrapper doesn't use the deprecated DOM anymore 00024 * 00025 * Revision 1.5 2004/02/12 13:49:43 amassari 00026 * Updated version to 2.5 00027 * 00028 * Revision 1.4 2003/11/21 12:05:48 amassari 00029 * Updated version to 2.4 00030 * 00031 * Revision 1.3 2003/10/21 21:21:32 amassari 00032 * When the COM object is loaded by a late-binding engine (like WSH, or 00033 * Visual Basic when the type library is not preloaded in the editor), the type 00034 * library version stored in the resource must match the version specified in the 00035 * IDispatchImpl template (defaulted to 1.0), or trying to invoke a method will fail 00036 * 00037 * Revision 1.2 2002/05/21 19:53:53 tng 00038 * DOM Reorganization: update include path for the old DOM interface in COM files 00039 * 00040 * Revision 1.1.1.1 2002/02/01 22:21:42 peiyongz 00041 * sane_include 00042 * 00043 * Revision 1.3 2000/06/03 00:29:04 andyh 00044 * COM Wrapper changes from Curt Arnold 00045 * 00046 * Revision 1.2 2000/03/30 02:00:09 abagchi 00047 * Initial checkin of working code with Copyright Notice 00048 * 00049 */ 00050 00051 #ifndef ___xmlhttprequest_h___ 00052 #define ___xmlhttprequest_h___ 00053 00054 #include <xercesc/dom/DOMDocument.hpp> 00055 #include "IXMLDOMNodeImpl.h" 00056 00057 #include "resource.h" // main symbols 00058 00059 class ATL_NO_VTABLE CXMLHttpRequest : 00060 public CComObjectRootEx<CComSingleThreadModel>, 00061 public CComCoClass<CXMLHttpRequest, &CLSID_XMLHTTPRequest>, 00062 public IObjectSafetyImpl<CXMLHttpRequest, INTERFACESAFE_FOR_UNTRUSTED_CALLER>, 00063 public IDispatchImpl<IXMLHttpRequest, &IID_IXMLHttpRequest, &LIBID_Xerces, 2, 50>, 00064 public IObjectWithSiteImpl<CXMLHttpRequest>, 00065 public ISupportErrorInfo, 00066 public CWindowImpl<CXMLHttpRequest, CWindow, CWinTraits<0,0> > 00067 { 00068 public: 00069 CXMLHttpRequest(); 00070 00071 HRESULT FinalConstruct(); 00072 void FinalRelease(); 00073 00074 //DECLARE_REGISTRY_RESOURCEID(IDR_XMLHTTPREQUEST) 00075 static HRESULT WINAPI UpdateRegistry(BOOL bRegister); 00076 00077 DECLARE_NOT_AGGREGATABLE(CXMLHttpRequest) 00078 00079 DECLARE_PROTECT_FINAL_CONSTRUCT() 00080 00081 BEGIN_COM_MAP(CXMLHttpRequest) 00082 COM_INTERFACE_ENTRY(IXMLHttpRequest) 00083 COM_INTERFACE_ENTRY(IDispatch) 00084 COM_INTERFACE_ENTRY(IObjectSafety) 00085 COM_INTERFACE_ENTRY(IObjectWithSite) 00086 COM_INTERFACE_ENTRY(ISupportErrorInfo) 00087 END_COM_MAP() 00088 00089 DECLARE_WND_CLASS(_T("XMLHttpRequestMonitor")) 00090 00091 BEGIN_MSG_MAP(CMonitorWnd) 00092 MESSAGE_HANDLER(MSG_READY_STATE_CHANGE, OnReadyStateChange) 00093 END_MSG_MAP() 00094 00095 LRESULT OnReadyStateChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 00096 00097 00098 // ISupportsErrorInfo 00099 STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid); 00100 00101 // IXMLHttpRequest methods 00102 STDMETHOD(open)(/*[in]*/ BSTR bstrMethod, /*[in]*/ BSTR bstrUrl, /*[in,optional]*/ VARIANT varAsync, /*[in,optional]*/ VARIANT bstrUser, /*[in,optional]*/ VARIANT bstrPassword); 00103 STDMETHOD(setRequestHeader)(/*[in]*/ BSTR bstrHeader, /*[in]*/ BSTR bstrValue); 00104 STDMETHOD(getResponseHeader)(/*[in]*/ BSTR bstrHeader, /*[out, retval]*/ BSTR * pbstrValue); 00105 STDMETHOD(getAllResponseHeaders)(/*[out, retval]*/ BSTR * pbstrHeaders); 00106 STDMETHOD(send)(/*[in, optional]*/ VARIANT varBody); 00107 STDMETHOD(abort)(); 00108 STDMETHOD(get_status)(/*[out, retval]*/ long * plStatus); 00109 STDMETHOD(get_statusText)(/*[out, retval]*/ BSTR * pbstrStatus); 00110 STDMETHOD(get_responseXML)(/*[out, retval]*/ IDispatch ** ppBody); 00111 STDMETHOD(get_responseText)(/*[out, retval]*/ BSTR * pbstrBody); 00112 STDMETHOD(get_responseBody)(/*[out, retval]*/ VARIANT * pvarBody); 00113 STDMETHOD(get_responseStream)(/*[out, retval]*/ VARIANT * pvarBody); 00114 STDMETHOD(get_readyState)(/*[out, retval]*/ long * plState); 00115 STDMETHOD(put_onreadystatechange)(/*[in]*/ IDispatch * pReadyStateSink); 00116 00117 private: 00118 00119 LPDISPATCH m_pOnReadyStateChange; 00120 bool m_bAbort; 00121 HANDLE m_hThread; 00122 long m_lReadyState; 00123 bool m_bAsync; 00124 _bstr_t m_Method; 00125 _bstr_t m_HostName; 00126 INTERNET_PORT m_Port; 00127 _bstr_t m_URLPath; 00128 _bstr_t m_User; 00129 _bstr_t m_Password; 00130 DWORD m_dwStatus; 00131 _bstr_t m_StatusText; 00132 _bstr_t m_ResponseHeaders; 00133 CSimpleMap<_bstr_t, _bstr_t> m_RequestHeaderMap; 00134 HWND m_HwndParent; 00135 00136 PBYTE m_pBody; 00137 long m_lBodyLength; 00138 PBYTE m_pResponseBody; 00139 long m_lResponseBodyLength; 00140 _bstr_t m_Error; 00141 bool m_bSuccess; 00142 00143 HWND GetParentWindow(); 00144 00145 static _bstr_t GetErrorMsg(DWORD rc); 00146 static void CALLBACK InternetStatusCallback(HINTERNET hInternet, 00147 DWORD dwContext, 00148 DWORD dwInternetStatus, 00149 LPVOID lpvStatusInformation, 00150 DWORD dwStatusInformationLength); 00151 static UINT APIENTRY SendThread(void *pParm); 00152 static HRESULT InitializeVarFromByte(VARIANT &varOut, const PBYTE pByte, long lSize); 00153 }; 00154 00155 typedef CComObject<CXMLHttpRequest> CXMLHttpRequestObj; 00156 00157 #endif // ___xmlhttprequest_h___

Generated on Thu Apr 30 02:30:52 2009 for ACS C++ API by doxygen 1.3.8