presage
0.8.7
|
00001 00002 /****************************************************** 00003 * Presage, an extensible predictive text entry system 00004 * --------------------------------------------------- 00005 * 00006 * Copyright (C) 2008 Matteo Vescovi <matteo.vescovi@yahoo.co.uk> 00007 00008 This program is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 2 of the License, or 00011 (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License along 00019 with this program; if not, write to the Free Software Foundation, Inc., 00020 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00021 * 00022 **********(*)*/ 00023 00024 00025 #ifndef PRESAGE_PROFILEMANAGER 00026 #define PRESAGE_PROFILEMANAGER 00027 00028 #include "profile.h" 00029 #include "defaultProfile.h" 00030 #include "combiner.h" 00031 #include "logger.h" 00032 #include "dispatcher.h" 00033 00034 #include <string> 00035 #include <list> 00036 #include <sstream> // for std::ostringstream 00037 #include <stdio.h> // for int remove( const char* ) to remove files/dirs 00038 00039 00051 class ProfileManager { 00052 public: 00053 ProfileManager(const std::string = ""); 00054 ~ProfileManager(); 00055 00056 void save_profile() const; 00057 00058 Configuration* get_configuration(); 00059 00060 void set_autopersist (const std::string& value); 00061 00062 static const char* LOGGER; 00063 static const char* AUTOPERSIST; 00064 00065 private: 00066 void init_profiles (const std::string& profilename); 00067 00068 Profile* create_profile_from_xml (const std::string& filename); 00069 00070 std::string get_user_home_dir() const; 00071 std::string get_system_etc_dir() const; 00072 00073 bool loaded_at_least_one_profile; 00074 00077 void cache_log_message(Logger<char>::Level level, const std::string& message); 00080 void flush_cached_log_messages(); 00083 void refresh_config(); 00084 00085 struct CachedLogMessage { 00086 // Level is commented out because it gets translated to 00087 // numeric value of enum, instead of acting as templatized 00088 // function type switching the logger level as intended. This 00089 // is not an issue however since all cached log messages need 00090 // to be logged at same level, so we can hardcode level in 00091 // flush method. 00092 // 00093 //Logger<char>::Level level; 00094 std::string message; 00095 }; 00096 00097 std::list<CachedLogMessage> cached_log_messages; 00098 00099 Configuration* config; 00100 Profile* rw_profile; // readable-writable profile 00101 bool autopersist_config; 00102 00103 Logger<char> logger; 00104 00105 }; 00106 00107 00108 #endif // PRESAGE_PROFILEMANAGER