diff options
author | Alex <b0ris@b0ris-satellite.localdomain> | 2011-11-04 03:02:16 +0200 |
---|---|---|
committer | Alex <b0ris@b0ris-satellite.localdomain> | 2011-11-04 03:02:16 +0200 |
commit | b7e0b79e7ce53bf467b1bcb8d60e86fac509f776 (patch) | |
tree | 8c239c3b5a0f6833ae75618fd15414682631a019 /client/Config.h | |
parent | fb6fef711742bf92f4812ea70423f19443049df0 (diff) |
config.cfg parser
Diffstat (limited to 'client/Config.h')
-rw-r--r-- | client/Config.h | 134 |
1 files changed, 93 insertions, 41 deletions
diff --git a/client/Config.h b/client/Config.h index 3701cd7..c95d9c6 100644 --- a/client/Config.h +++ b/client/Config.h @@ -3,9 +3,12 @@ #ifndef CONFIG_H #define CONFIG_H -#include <vector> +#include <client.h> #include "Proxy.h" +using std::vector; +using std::string; + class ProxyEntryGeneric; class ProxyEntryStatic; @@ -22,10 +25,10 @@ public: /** * @brief Class to represent 'firewall' record in the config file */ - class FirewallRecord + class FirewallEntry { public: - FirewallRecord(): block(false), host("127.0.0.1") + FirewallEntry(): block(false), host("127.0.0.1") { } /** @@ -36,33 +39,7 @@ public: /** * @brief Hostname or address to allow/block access to */ - std::string host; - }; - - /** - * @brief Class to represend 'server' record in the config file - */ - class ServerRecord - { - public: - ServerRecord(): host("127.0.0.1"), timeout(120), retry(60) - { - } - /** - * @brief Hostname or address of server<br/> - * Note that default port is 13666 as specified in SslClient - */ - std::string host; - /** - * @brief Cumulative timeout value (in seconds)<br/> - * When this time is expired then no further attempts is made - * to connect to this particular server - */ - unsigned timeout; - /** - * @brief Time (in seconds) between consecutive retries - */ - unsigned retry; + string host; }; /** @@ -72,6 +49,37 @@ public: static Config *CurrentConfig(); /** + * @brief Time between consecutive program updates + */ + unsigned ClientUpdateInterval; + + /** + * @brief Welcome message that is displayed after program start + */ + string WelcomeMsg; + + /** + * @brief Message that is shown when the config.cfg downloaded/updated + * successfully + */ + string ConfigLoadedMsg; + + /** + * @brief Text that is displayed in as the top panel caption in the UI + */ + string TopPanelText; + + /** + * @brief Text that is displayed in as the bottom panel caption in the UI + */ + string BottomPanelText; + + /** + * @brief Determines whether proxy speed displayed in the UI or not + */ + bool IsSpeedVisible; + + /** * @brief Update client configuration * @todo update config periodically on timer events */ @@ -90,7 +98,7 @@ public: * (generic proxy records only) * @return Alphabetically sorted vector<string> with unique country names */ - std::vector<std::string> GetCountries(); + vector<string> GetCountries(); /** * @brief Get list of country states where at least one proxy available<br/> @@ -99,7 +107,7 @@ public: * @return Alphabetically sorted vector<string> with unique state names.<br/> * Resultant vector<string> may be empty in case if there are no states in specified country */ - std::vector<std::string> GetStates(std::string &country); + vector<string> GetStates(std::string &country); /** * @brief Get list of cities in particular country without states<br/> @@ -107,7 +115,7 @@ public: * @param country name of country to get list of states for * @return Alphabetically sorted vector<string> with unique city names */ - std::vector<std::string> GetCities(std::string &country); + vector<string> GetCities(string &country); /** * @brief Get list of cities in particular country and state<br/> @@ -116,7 +124,7 @@ public: * @param state name of state to get list of cities for * @return Alphabetically sorted vector<string> with unique city names */ - std::vector<std::string> GetCities(std::string &country, std::string &state); + vector<string> GetCities(string &country, string &state); /** * @brief Get list of proxy server addresses in particular country and city (without states)<br/> @@ -125,7 +133,7 @@ public: * @param city name of city to get list of proxies for * @return Alphabetically sorted vector<string> with unique proxy names */ - std::vector<std::string> GetProxies(std::string &country, std::string &city); + vector<string> GetProxies(string &country, string &city); /** * @brief Get list of proxy server addresses in particular country, state and city<br/> @@ -135,14 +143,14 @@ public: * @param city name of city to get list of proxies for * @return Alphabetically sorted vector<string> with unique proxy names */ - std::vector<std::string> GetProxies(std::string &country, std::string &state, std::string &city); + vector<string> GetProxies(string &country, string &state, string &city); /** * @brief Get list of static proxy entries * @param line number of GUI line proxy list associated with * @return List of static proxy entries sorted by speed in descending order */ - std::vector<ProxyEntryStatic> GetStaticProxyGuiLine(unsigned line); + vector<ProxyEntryStatic> GetStaticProxyGuiLine(unsigned line); /** * @brief Get number of static proxy GUI lines @@ -159,12 +167,56 @@ public: protected: Config(); private: + /** + * @brief Class to represend 'server' record in the config file + */ + class ServerEntry + { + public: + /** + * @brief Initialize ServerEntry instance to default values + */ + ServerEntry(); + + /** + * @brief initilize ServerEntry instance from config file entry<br/> + * @param entry config file entry value, e.g.: '8.8.8.8:8080 600 60' + */ + ServerEntry(string entry); + + /** + * @brief Hostname or address of server<br/> + * Note that default port is 13666 as specified in SslClient + */ + string host; + + /** + * @brief Cumulative timeout value (in seconds)<br/> + * When this time is expired then no further attempts is made + * to connect to this particular server + */ + unsigned timeout; + + /** + * @brief Time (in seconds) between consecutive retries + */ + unsigned retry; + }; + + /** + * @brief Pointer to the singleton Config instance + */ static Config *self; + + /** + * @brief time interval between consequtive config updates + */ + unsigned updateInterval; bool configValid; - std::vector<ProxyEntryGeneric> genericProxy; - std::vector<ProxyEntryStatic> staticProxy; - std::vector<FirewallRecord> firewallList; - + vector<ProxyEntryGeneric> genericProxy; + vector<ProxyEntryStatic> staticProxy; + vector<FirewallEntry> firewalls; + vector<ServerEntry> servers; int ReadGenericProxy(); int ReadStaticProxy(); }; |