/******************************************************************************* 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: p4clientapi.h * * Author: Robert Cowham <robert@vaccaperna.co.uk> * * Description: * COM bindings for the Perforce API. User interface class * for getting Perforce results into COM. * ******************************************************************************/ #ifndef _P4API_H_ #define _P4API_H_ // P4 API files # include "PerforceAPI.h" # include "enviro.h" # include "signaler.h" # include "msgclient.h" # include "spec.h" #endif // _P4API_H_ #include "p4clientuser.h" #ifdef SetPort // Windows bug #undef SetPort #endif class p4ClientApi { public: // caller's main interface p4ClientApi(); ~p4ClientApi(); // Protocol options. Call before Connect() void Tagged(); void ParseForms(); // Session management int Connect(StrBuf &errMsg); int Disconnect(); void ExceptionLevel( int i ) { m_exceptionLevel = i; } int ExceptionLevel() { return m_exceptionLevel; } long Run(BSTR cmd, StrBuf &errMsg); StrBuf ErrorMsg(); void CheckCharset(); void SetCharset(BSTR s) { m_client.SetCharset(ConvertString(s)); } void SetClient(BSTR s) { m_client.SetClient(ConvertString(s)); } void SetCwd(BSTR s) { m_client.SetCwd(ConvertString(s)); } void SetHost(BSTR s) { m_client.SetHost(ConvertString(s)); } void SetLanguage(BSTR s) { m_client.SetLanguage(ConvertString(s)); } void SetPassword(BSTR s) { m_client.SetPassword(ConvertString(s)); } void SetPort(BSTR s) { m_client.SetPort(ConvertString(s)); } void SetUser(BSTR s) { m_client.SetUser(ConvertString(s)); } void SetInput(BSTR s) { m_ui.SetInput(ConvertString(s)); } void SetProtocol(BSTR p, BSTR v) { StrBuf tag(ConvertString(p)->Text()); StrBuf val(ConvertString(v)->Text()); m_client.SetProtocol(tag.Text(), val.Text()); } void SetProtocolV(BSTR v) { m_client.SetProtocolV(ConvertString(v)->Text()); } void SetTicketFile(BSTR fname) { m_client.SetTicketFile(ConvertString(fname)->Text()); } void SetProg(BSTR val) { m_prog = ConvertString(val)->Text(); } void SetVersion(BSTR val) { m_version = ConvertString(val)->Text(); } LPCSTR GetCharset() { return m_client.GetCharset().Text(); } LPCSTR GetClient() { return m_client.GetClient().Text(); } LPCSTR GetCwd() { return m_client.GetCwd().Text(); } LPCSTR GetHost() { return m_client.GetHost().Text(); } LPCSTR GetLanguage() { return m_client.GetLanguage().Text(); } LPCSTR GetOs() { return m_client.GetOs().Text(); } LPCSTR GetPassword() { return m_client.GetPassword().Text(); } LPCSTR GetPort() { return m_client.GetPort().Text(); } LPCSTR GetUser() { return m_client.GetUser().Text(); } LPCSTR GetProtocol(BSTR p) { return m_client.GetProtocol(ConvertString(p)->Text())->Text(); } const long GetServerVersion() { StrPtr * sp = m_client.GetProtocol("server2"); long result = sp->Atoi(); return result; } int Dropped() { return m_client.Dropped(); } public: p4ClientUser m_ui; private: ClientApi m_client; int m_initCount; int m_exceptionLevel; int m_server2; int m_tagged; StrBuf m_emptyBuf; StrBuf m_buf; StrBuf m_prog; StrBuf m_version; void p4ClientApi::SplitArgs(BSTR cmd_line, StrBufArray *sba); private: StrBuf *ConvertString(BSTR s) { if (NULL == s) { return &m_emptyBuf; } else { m_buf = (LPCSTR)CW2A(s); return &m_buf; } } } ;
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#9 | 9835 | Robert Cowham | Added SetProtocolV | ||
#8 | 7459 | Robert Cowham | Add SetTicketFile option | ||
#7 | 7458 | Robert Cowham | Fix similar problem with SetVersion | ||
#6 | 7456 | Robert Cowham | Fix setting of Prog and Protocol calls | ||
#5 | 6050 | Robert Cowham |
- Use P4API 2007.2 - Added SetProg, SetVersion, SetProtocol and GetProtocol |
||
#4 | 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. |
||
#3 | 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!). |
||
#2 | 3542 | Robert Cowham | Update to use exceptions properly - including examples. | ||
#1 | 3525 | Robert Cowham | Initial release |