ircproxy The Ultimate Cyborg |
00001 // ircproxy -- An IRC bouncer. 00002 // 00003 //! @file Application.h 00004 //! @brief This file contains the declaration of class Application. 00005 // 00006 // Copyright (C) 2006, 2007 by 00007 // 00008 // Carlo Wood, Run on IRC <carlo@alinoe.com> 00009 // RSA-1024 0x624ACAD5 1997-01-26 Sign & Encrypt 00010 // Fingerprint16 = 32 EC A7 B6 AC DB 65 A6 F6 F6 55 DD 1C DC FF 61 00011 // 00012 // This file may be distributed under the terms of the Q Public License 00013 // version 1.0 as appearing in the file LICENSE.QPL included in the 00014 // packaging of this file. 00015 00016 #ifndef TARGET_H 00017 // Must be included before Application.h 00018 #include "Target.h" 00019 #endif 00020 00021 #ifndef APPLICATION_H 00022 #define APPLICATION_H 00023 00024 #ifndef USE_PCH 00025 #include <libcw/libcw_app.h> 00026 #endif 00027 00028 #include "networks_type.h" 00029 #include "identities_type.h" 00030 00031 class PersistXML; 00032 00033 /*! @brief The application singleton 00034 * 00035 * This class represents the application itself. 00036 * It is a singleton and needs to be accessed through Application::instance(). 00037 */ 00038 class Application : public libcw_app_tct<Application> { 00039 #ifndef DOXYGEN 00040 friend_Instance; // See documentation of libcw. 00041 #endif 00042 private: 00043 unsigned short M_listen_port; //!< The listen port the IRC proxy listens on. 00044 #ifdef CWDEBUG 00045 bool M_suppress_ping; //!< True if PING/PONG debug messages should be suppressed. 00046 bool M_suppress_who; //!< True if WHO debug messages should be suppressed. 00047 #endif 00048 networks_type M_networks; //!< List with all known networks. 00049 identities_type M_identities; //!< Map with all known identities. 00050 memory_block_st* M_memory_block_dummy; //!< Dummy variable used during construction. 00051 msg_block_ct M_msg_block_dummy; //!< Used for MessageIn objects not related to a real message block. 00052 bool M_terminating; //!< Set to true when the application should terminate after the last ServerSession is destructed. 00053 00054 private: 00055 Application(void); 00056 00057 //! Called when a signal is received (SIGINT or SIGHUP). 00058 void handle_signal(SignalType const&); 00059 00060 public: 00061 ~Application() throw(); 00062 00063 //! A const reference to an STL container with all known networks. 00064 networks_type const& networks(void) const { return M_networks; } 00065 00066 //! A reference to the STL container with all known networks. 00067 networks_type& networks(void) { return M_networks; } 00068 00069 //! A const reference to a map with all known identities. 00070 identities_type const& identities(void) const { return M_identities; } 00071 00072 //! A reference to the map with all known identities. 00073 identities_type& identities(void) { return M_identities; } 00074 00075 //! A dummy message block that can be used as place holder. 00076 msg_block_ct& dummy_msg_block(void) { return M_msg_block_dummy; } 00077 00078 protected: 00079 virtual void start(void); 00080 virtual void finish_options(void); 00081 virtual void print_version(std::ostream&) const; 00082 #ifdef CWDEBUG 00083 virtual void main_entered(int* argc_ptr, char* const** argv_ptr); 00084 #endif 00085 00086 protected: 00087 void command_line_option_listen_port(char const* argument); 00088 void command_line_option_suppress_ping(char const* argument); 00089 void command_line_option_suppress_who(char const* argument); 00090 00091 public: 00092 void serialize(PersistXML& xml); 00093 #ifdef CWDEBUG 00094 bool suppress_ping(void) const { return M_suppress_ping; } 00095 bool suppress_who(void) const { return M_suppress_who; } 00096 #endif 00097 00098 //! This function is called from the destructor of the last ServerSession. 00099 void last_server_session_destroyed(void); 00100 }; 00101 00102 #endif // APPLICATION_H 00103
Copyright © 2005-2007 Carlo Wood. All rights reserved. |
---|