/******************************************************************************* Copyright (c) 2003, Robert Cowham and Vaccaperna Systems Ltd. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL VACCAPERNA SYSTEMS LTD. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ /******************************************************************************* * Name: p4.cpp * * Author: Robert Cowham <robert@vaccaperna.co.uk> * * Description: * Implementation of p4 - the COM class and thus external interface. * ******************************************************************************/ #ifndef __P4_H_ #define __P4_H_ #include "resource.h" // main symbols #include "p4interface.h" #include "p4clientapi.h" ///////////////////////////////////////////////////////////////////////////// // p4 class ATL_NO_VTABLE p4 : public CComObjectRootEx<CComSingleThreadModel>, public CComCoClass<p4, &CLSID_p4>, public ISupportErrorInfo, public IDispatchImpl<Ip4, &IID_Ip4, &LIBID_P4COM> { public: p4() : m_Initialized(0) { } DECLARE_REGISTRY_RESOURCEID(IDR_P4) DECLARE_PROTECT_FINAL_CONSTRUCT() BEGIN_COM_MAP(p4) COM_INTERFACE_ENTRY(Ip4) COM_INTERFACE_ENTRY(IDispatch) COM_INTERFACE_ENTRY(ISupportErrorInfo) END_COM_MAP() // Ip4 public: STDMETHOD(get_ServerVersion)(/*[out, retval]*/ long *pVal); STDMETHOD(get_Os)(/*[out, retval]*/ BSTR *pVal); STDMETHOD(get_ArrayVar)(BSTR varName, /*[out, retval]*/ SAFEARRAY ** valArray); STDMETHOD(put_ArrayVar)(BSTR varName, /*[in]*/ SAFEARRAY ** valArray); STDMETHOD(get_ArrayVar_variant)(BSTR varName, /*[out, retval]*/ VARIANT *vArray); STDMETHOD(put_ArrayVar_variant)(BSTR varName, /*[in]*/ VARIANT newVal); STDMETHOD(get_VarExists)(BSTR varName, /*[out, retval]*/ BOOL *pVal); STDMETHOD(get_Var)(BSTR varName, /*[out, retval]*/ BSTR *pVal); STDMETHOD(put_Var)(BSTR varName, /*[in]*/ BSTR newVal); STDMETHOD(get_TempFilename)(/*[out, retval]*/ BSTR *pVal); STDMETHOD(Tagged)(); STDMETHOD(ParseForms)(); STDMETHOD(get_ExceptionLevel)(/*[out, retval]*/ long *pVal); STDMETHOD(put_ExceptionLevel)(/*[in]*/ long newVal); STDMETHOD(Disconnect)(); STDMETHOD(Connect)(); STDMETHOD(run)(/*[in]*/ BSTR cmd, /*[out, retval]*/ SAFEARRAY ** valArray); STDMETHOD(run_variant)(/*[in]*/ BSTR cmd, /*[out, retval]*/ VARIANT * valArray); STDMETHODIMP InterfaceSupportsErrorInfo(REFIID riid); STDMETHOD(get_Warnings)(/*[out, retval]*/ SAFEARRAY ** valArray); STDMETHOD(get_Warnings_variant)(/*[out, retval]*/ VARIANT *vArray); STDMETHOD(get_Errors)(/*[out, retval]*/ SAFEARRAY ** valArray); STDMETHOD(get_Errors_variant)(/*[out, retval]*/ VARIANT *vArray); STDMETHOD(get_Charset)(/*[out, retval]*/ BSTR *pVal); STDMETHOD(put_Charset)(/*[in]*/ BSTR newVal); STDMETHOD(get_Client)(/*[out, retval]*/ BSTR *pVal); STDMETHOD(put_Client)(/*[in]*/ BSTR newVal); STDMETHOD(get_Cwd)(/*[out, retval]*/ BSTR *pVal); STDMETHOD(put_Cwd)(/*[in]*/ BSTR newVal); STDMETHOD(get_Host)(/*[out, retval]*/ BSTR *pVal); STDMETHOD(put_Host)(/*[in]*/ BSTR newVal); STDMETHOD(get_Language)(/*[out, retval]*/ BSTR *pVal); STDMETHOD(put_Language)(/*[in]*/ BSTR newVal); STDMETHOD(get_Password)(/*[out, retval]*/ BSTR *pVal); STDMETHOD(put_Password)(/*[in]*/ BSTR newVal); STDMETHOD(get_Port)(/*[out, retval]*/ BSTR *pVal); STDMETHOD(put_Port)(/*[in]*/ BSTR newVal); STDMETHOD(get_User)(/*[out, retval]*/ BSTR *pVal); STDMETHOD(put_User)(/*[in]*/ BSTR newVal); STDMETHOD(put_Input)(/*[in]*/ BSTR newVal); STDMETHOD(FormatDateTime)(/*[in]*/ long unixtime, /*[out, retval]*/ BSTR *pVal); STDMETHOD(Dropped)(/*[out, retval]*/ long *pVal); STDMETHOD(GetProtocol)(/*[in]*/ BSTR pname, /*[out, retval]*/ BSTR *pVal); STDMETHOD(SetProtocol)(/*[in]*/ BSTR pname, /*[in]*/ BSTR newVal); STDMETHOD(SetProtocolV)(/*[in]*/ BSTR newVal); STDMETHOD(SetProg)(/*[in]*/ BSTR pname); STDMETHOD(SetVersion)(/*[in]*/ BSTR ver); STDMETHOD(SetTicketFile)(/*[in]*/ BSTR fname); private: void ConvertSafeArrayToArray(SAFEARRAY *pArray, StrBufArray *result); void ConvertVariantToArray(const VARIANT &newVal, StrBufArray *result); HRESULT ConvertArrayToSafeArray(StrBufArray *sba, SAFEARRAY **ppArray); HRESULT ConvertArrayToVariant(StrBufArray *sba, VARIANT *pVal); int m_Initialized; p4ClientApi m_client; }; #endif //__P4_H_
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#9 | 9835 | Robert Cowham | Added SetProtocolV | ||
#8 | 7459 | Robert Cowham | Add SetTicketFile option | ||
#7 | 6050 | Robert Cowham |
- Use P4API 2007.2 - Added SetProg, SetVersion, SetProtocol and GetProtocol |
||
#6 | 5194 | Robert Cowham |
Changes (2005.1.0.0) Added Dropped() to detect dropped connections Added Input property to provide input e.g. for passwords Added FormatDateTime() as a convenience for calling C Runtime function (for VB use) Imported changes from p4ofc which made it more reliable. |
||
#5 | 4156 | Robert Cowham | Updated to support Variant Arrays (as required by VBScript). | ||
#4 | 3612 | Robert Cowham |
Version 1.0.0.2 New interface for ServerVersion. New put property ArrayVarVar which is the same as ArrayVar but takes an Array of Variants rather than strings (for Lisp compatibility!). |
||
#3 | 3561 | Robert Cowham | Renamed P4COMLib to P4COM and run from property to method. | ||
#2 | 3542 | Robert Cowham | Update to use exceptions properly - including examples. | ||
#1 | 3525 | Robert Cowham | Initial release |