1 /* 2 * This file is part of GtkEveMon. 3 * 4 * GtkEveMon is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * You should have received a copy of the GNU General Public License 10 * along with GtkEveMon. If not, see <http://www.gnu.org/licenses/>. 11 */ 12 13 #ifndef CONFIG_HEADER 14 #define CONFIG_HEADER 15 16 #include <string> 17 18 #include "util/conf.h" 19 #include "net/asynchttp.h" 20 21 class Config 22 { 23 private: 24 static std::string conf_dir; 25 static std::string filename; 26 27 public: 28 static Conf conf; 29 30 public: 31 static void init_defaults (void); 32 static void init_config_path (void); 33 static void init_user_config (void); 34 static void save_to_file (void); 35 static void unload (void); 36 37 static std::string const& get_conf_dir (void); 38 static std::string const& get_filename (void); 39 40 /* Helper function to setup HTTP requests. */ 41 static void setup_http (AsyncHttp* fetcher, bool is_api_call = false); 42 }; 43 44 /* ---------------------------------------------------------------- */ 45 46 inline void save_to_file(void)47Config::save_to_file (void) 48 { 49 Config::conf.to_file(Config::filename); 50 } 51 52 inline void unload(void)53Config::unload (void) 54 { 55 Config::save_to_file(); 56 } 57 58 inline std::string const& get_conf_dir(void)59Config::get_conf_dir (void) 60 { 61 return Config::conf_dir; 62 } 63 64 inline std::string const& get_filename(void)65Config::get_filename (void) 66 { 67 return Config::filename; 68 } 69 70 #endif /* CONFIG_HEADER */ 71