/******************************************************************************* * rfaxprogram.hpp * RightFax program base class. * *------------------------------------------------------------------------------ * @version $Revision: 1.2 $ $Date: 2008/03/28 23:59:38 $ * @since 2008-03-27 * @author David R. Tribble (david@tribble.com) * * Copyright ©2008 by David R. Tribble, all rights reserved. * Permission is granted to any person or entity except those designated * by the United States Department of State as a terrorist, or terrorist * government or agency, to use and distribute this source code provided * that the original copyright notice remains present and unaltered. */ #ifndef rfaxprogram_hpp #define rfaxprogram_hpp 102 // Identification #ifndef NO_H_IDENT static char rfaxprogram_hpp_REV[] = "@(#)drt/rightfax/src/rfaxprogram.hpp $Revision: 1.2 $ $Date: 2008/03/28 23:59:38 $"; #endif // System includes #ifndef _WIN32 #error This only compiles on Win32 (MS/Windows) systems #endif #ifndef _INC_TIME #include #endif #define WINDOWS_LEAN_AND_MEAN 1 #include // Forward references #ifndef rfaxprogram_cpp struct FAXINFO_10; struct FAXINFO_11; struct SERVERINFO2; struct USERINFO_11; #endif /******************************************************************************* * class RFaxProgram * Base class for RightFax compatible programs. * * @since 1.1, 2008-03-27 */ #define RFaxProgram_VS 100 // Class version #define RFaxProgram_MAGIC 0xDAB10000 // Class magic number class RFaxProgram { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Constants public: const static int VS; // Class version enum ReturnCode // Program exit codes { RC_CONNECT = 1, // Can't connect to server RC_READ = 2, // Read error RC_WRITE = 3, // Write error RC_USAGE = 255 // Bad program usage }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Static functions protected: /*-------------------------------------------------------------------------- * Compare a name to a wildcard (filename) pattern. * * @param name * A name to compare. * * @param pat * Name pattern containing wildcards, which are: * ? - matches a single character * * - matches zero or more characters * Note that alphabetic character comparisons are case-insensitive (e.g., * "abc" * matches "abc", "Abc", and "ABC"). * * @return * True if 'name' matches 'pat', otherwise false. * If either 'name' or 'pat' is null, false is returned. * * @since 1.1, 2008-03-27 */ static bool matchesPattern(const char *name, const char *pat); /*-------------------------------------------------------------------------- * Convert a RightFax Fax status code into its corresponding textual * representation. * * @param status * A RightFax status code for a Fax document. * * @return * Pointer to a static string buffer. * * @since 1.2, 2008-03-28 */ static const char * cvtStatus(int status); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Functions protected: /*-------------------------------------------------------------------------- * Destructor. * * @since 1.1, 2008-03-27 */ virtual ~RFaxProgram(); /*-------------------------------------------------------------------------- * Default constructor. * * @since 1.1, 2008-03-27 */ RFaxProgram(); /*-------------------------------------------------------------------------- * Connect to a RightFax server. * * @param server * RightFax server name or IP address. * * @since 1.1, 2008-03-27 */ bool connect(const char *server); /*-------------------------------------------------------------------------- * Disconnect from a RightFax server. * * @since 1.1, 2008-03-27 */ void disconnect(); /*-------------------------------------------------------------------------- * Retrieve information about the RightFax server. * * @since 1.1, 2008-03-27 */ bool getServerInfo(); /*-------------------------------------------------------------------------- * Retrieve information about a RightFax user. * * @since 1.1, 2008-03-27 */ bool getUserInfo(const char *name); /*-------------------------------------------------------------------------- * Retrieve the text message for the last error. * * @return * Pointer to a string containing the text of the last error that occurred. * Note that this string should not be deleted or freed. * * @since 1.1, 2008-03-27 */ const char * getErrorMessage(); private: // Not implemented RFaxProgram(const RFaxProgram &o); // Not implemented const RFaxProgram & operator =(const RFaxProgram &o); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Variables protected: unsigned m_magic; // Class magic number int m_vers; // Class version time_t m_apiVers; // RightFax API library version const char * m_server; // Server name const char * m_serverIP; // Server IP address void * m_hdl; // Fax server handle SERVERINFO2 * m_info; // Fax server info int m_error; // Last error code time_t m_time; // Time of last action int m_tz; // Server UTC timezone offset const char * m_user; // User (in-box) ID const char * m_uname; // User (in-box) name const char * m_group; // Group name bool m_connected; // Connection is established char m_msg[500+1]; // Buffer for error messages }; #endif // rfaxprogram_hpp // End rfaxprogram.hpp