#pragma once /******************************************************************************* Copyright (c) 2010, Perforce Software, Inc. 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 PERFORCE SOFTWARE, INC. 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 : P4BridgeServer.h * * Author : dbb * * Description : P4BridgeServer * ******************************************************************************/ #include "P4BridgeClient.h" /******************************************************************************* * * This is the function prototypes for the call backs used to log status, * error conditions, debugging messages, and the like to the client. It is * up to the client to log the strings into a file if desired. * ******************************************************************************/ typedef int _stdcall LogCallbackFn(int, const char*, int, const char*); // Number returned by GetProtocol() if the server supports login, logout, etc. #define SERVER_SECURITY_PROTOCOL 18 // Minimum server level supporting extended submit options #define SERVER_EXTENDED_SUBMIT 22 /******************************************************************************* * * P4BridgeClient * * Class used to wrap the ClientApi in the p4api. It provides the capability to * connect to a P4 Server and execute commands. It initializes two * connections, one each for tagged/untagged output. * ******************************************************************************/ class P4BridgeServer : p4base, KeepAlive { friend P4BridgeServer; public: // logging support static int LogMessage(int log_level, char * file, int line, char * message, ...); protected: // Cannot create without initialization P4BridgeServer(void); // Get the protocol information from the server int GetServerProtocols(); public: // Create a server object and connect to the server P4BridgeServer( const char *server, const char *user, const char *pass, const char *ws_client ); // Finalize the connection to the server and release resources virtual ~P4BridgeServer(void); // Type for p4base virtual int Type(void) { return tP4BridgeServer; } // Get a pointer to the ui. P4BridgeClient * get_ui( void ) { return ui; } // server connection handling int connected( P4ClientError **err ); int connect_and_trust( P4ClientError **err, char* trust_flag, char* fingerprint ); void close_connection( ); void disconnect( ); // Doe the server support Unicode for meta data? int unicodeServer( ); // The APIlevel the connected sever supports int APILevel(); // Does the connected sever require login? int UseLogin(); //Does the connected sever support extended submit options (2006.2 higher)? int SupportsExtSubmit(); // If the server supports Unicode, set the character set used to // communicate with the server char * set_charset( const char* c, const char * filec = NULL ); // Get/Set the working directory void set_cwd( const char* newCwd ); const StrPtr &get_cwd( void ); // The 800 pound gorilla in the room, execute a command int run_command( const char *cmd, int tagged, char **args, int argc ); //int run_commandW( const WCHAR *cmd, int tagged, WCHAR **args, int argc ); int resolve( const char *file, int tagged ); // Set the connection data used void set_connection(const char* newPort, const char* newUser, const char* newPassword, const char* newClient); void set_client( const char* newVal ); void set_user( const char* newVal ); void set_port( const char* newVal ); void set_password( const char* newVal ); void set_programName( const char* newVal ); void set_programVer( const char* newVal ); // Get the connection data used const StrPtr* get_client(); const StrPtr* get_user(); const StrPtr* get_port(); const StrPtr* get_password(); const StrPtr* get_charset( ); const StrPtr* get_config( ); const char* get_programName(); const char* get_programVer(); static void SetLogCallFn( LogCallbackFn *log_fn) { pLogFn = log_fn; } // Save the callbacks so they can be reset in the client ui after a reconnect IntTextTextCallbackFn* pTaggedOutputCallbackFn; IntTextCallbackFn* pErrorCallbackFn; IntTextCallbackFn* pInfoResultsCallbackFn; TextCallbackFn* pTextResultsCallbackFn; BinaryCallbackFn* pBinaryResultsCallbackFn; PromptCallbackFn* pPromptCallbackFn; ResolveCallbackFn* pResolveCallbackFn; ResolveACallbackFn* pResolveACallbackFn; char* pProgramName; char* pProgramVer; // KeepAlive functionality virtual int IsAlive(); void cancel_command(); protected: // ClintApit object initialized to return untagged data ClientApi *client; // ClintApit object initialized to return tagged data //ClientApi *client_tagged; // Pointer to the P4BrigeClient used to receive output. P4BridgeClient *ui; // Working Directory const StrPtr* cwd; // Does the connected sever support Unicode? int isUnicode; // The APIlevel the connected sever supports int apiLevel; // Does the connected sever require login? int useLogin; //Does the connected sever support extended submit options (2006.2 higher)? int supportsExtSubmit; // This is where the pointer to the log callback is stored if set by the user. static LogCallbackFn * pLogFn; // has the client been initialized int clientNeedsInit; // KeepAlive status int isAlive; }; /******************************************************************************* * * Macros for logging * ******************************************************************************/ #define LOG_FATAL(msg) P4BridgeServer::LogMessage(0, __FILE__ , __LINE__, msg) #define LOG_ERROR(msg) P4BridgeServer::LogMessage(1, __FILE__ , __LINE__, msg) #define LOG_WARNING(msg) P4BridgeServer::LogMessage(2, __FILE__ , __LINE__, msg) #define LOG_INFO(msg) P4BridgeServer::LogMessage(3, __FILE__ , __LINE__, msg) #define LOG_DEBUG(lvl,msg) P4BridgeServer::LogMessage(lvl, __FILE__ , __LINE__, msg) #define LOG_FATAL1(msg, a1) P4BridgeServer::LogMessage(0, __FILE__ , __LINE__, msg, a1) #define LOG_ERROR1(msg, a1) P4BridgeServer::LogMessage(1, __FILE__ , __LINE__, msg, a1) #define LOG_WARNING1(msg, a1) P4BridgeServer::LogMessage(2, __FILE__ , __LINE__, msg, a1) #define LOG_INFO1(msg, a1) P4BridgeServer::LogMessage(3, __FILE__ , __LINE__, msg, a1) #define LOG_DEBUG1(lvl,msg, a1) P4BridgeServer::LogMessage(lvl, __FILE__ , __LINE__, msg, a1) #define LOG_FATAL2(msg, a1, a2) P4BridgeServer::LogMessage(0, __FILE__ , __LINE__, msg, a1, a2) #define LOG_ERROR2(msg, a1, a2) P4BridgeServer::LogMessage(1, __FILE__ , __LINE__, msg, a1, a2) #define LOG_WARNING2(msg, a1, a2) P4BridgeServer::LogMessage(2, __FILE__ , __LINE__, msg, a1, a2) #define LOG_INFO2(msg, a1, a2) P4BridgeServer::LogMessage(3, __FILE__ , __LINE__, msg, a1, a2) #define LOG_DEBUG2(lvl,msg, a1, a2) P4BridgeServer::LogMessage(lvl, __FILE__ , __LINE__, msg, a1, a2)
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 16210 | Norman Morse | Remove files from old locations | ||
#3 | 14005 | Norman Morse |
Bridge cleanup for OSX warnings and fixes for Unicode: P4CHARSET and P4HOST issues |
||
#2 | 12135 | Norman Morse |
Integrate dev branch changes into main. This code is the basiis of the 2.7 BETA release which provides Unity 5 compatibility |
||
#1 | 10940 | Norman Morse |
Inital Workshop release of P4Connect. Released under BSD-2 license |