diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-25 18:27:07 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-25 18:27:07 +0200 |
commit | b9f2171818e7776f7b0ae2cb5f7d64133fc9f494 (patch) | |
tree | a0d035946d2a5cf150f18e8f24f44fe1bbfbdc36 /src/Daemon | |
parent | dc8ad3b59e41ffce53541411649b6838e905b8b5 (diff) | |
parent | ef56b3c8afa0edfca2122c84343f6a35a3defb9e (diff) | |
download | abrt-b9f2171818e7776f7b0ae2cb5f7d64133fc9f494.tar.gz abrt-b9f2171818e7776f7b0ae2cb5f7d64133fc9f494.tar.xz abrt-b9f2171818e7776f7b0ae2cb5f7d64133fc9f494.zip |
Merge branch 'master' of ssh://vda@git.fedorahosted.org/git/abrt
Diffstat (limited to 'src/Daemon')
-rw-r--r-- | src/Daemon/Settings.cpp | 104 | ||||
-rw-r--r-- | src/Daemon/Settings.h | 6 | ||||
-rw-r--r-- | src/Daemon/abrt.conf | 2 |
3 files changed, 109 insertions, 3 deletions
diff --git a/src/Daemon/Settings.cpp b/src/Daemon/Settings.cpp index b7497ef4..468213dc 100644 --- a/src/Daemon/Settings.cpp +++ b/src/Daemon/Settings.cpp @@ -286,3 +286,107 @@ void LoadSettings(const char* pPath) ParseCron(); } +static void SaveSetString(const std::string& pKey, const set_strings_t& pSet, std::ofstream& pFOut, bool pNewLine = true) +{ + set_strings_t::const_iterator it_set; + if (pKey != "") + { + pFOut << pKey << " = "; + } + int ii = 0; + for (it_set = pSet.begin(); it_set != pSet.end(); it_set++) + { + pFOut << (*it_set); + ii++; + if (ii < pSet.size()) + { + pFOut << ","; + } + } + if (pNewLine) + { + pFOut << std::endl; + } +} + +static void SaveVectorPairStrings(const std::string& pKey, const vector_pair_string_string_t& pVector, std::ofstream& pFOut, bool pNewLine = true) +{ + int ii; + if (pKey != "") + { + pFOut << pKey << " = "; + } + for (ii = 0; ii < pVector.size(); ii++) + { + pFOut << pVector[ii].first; + if (pVector[ii].second != "") + { + pFOut << "(" << pVector[ii].second << ")"; + } + if ((ii + 1) < pVector.size()) + { + pFOut << ","; + } + } + if (pNewLine) + { + pFOut << std::endl; + } +} + +static void SaveMapVectorPairStrings(const map_vector_pair_strings_t& pMap, std::ofstream& pFOut, bool pNewLine = true) +{ + map_vector_pair_strings_t::const_iterator it; + for (it = pMap.begin(); it != pMap.end(); it++) + { + pFOut << it->first << " = "; + SaveVectorPairStrings("", it->second, pFOut, false); + pFOut << std::endl; + } + if (pNewLine) + { + pFOut << std::endl; + } + +} + +static void SaveSection(const std::string& pSection, std::ofstream& pFOut) +{ + pFOut << std::endl << "[" << pSection << "]" << std::endl << std::endl; +} + +static void SaveBool(const std::string& pKey, const bool pBool, std::ofstream& pFOut, bool pNewLine = true) +{ + if (pKey != "") + { + pFOut << pKey << " = "; + } + pFOut << (pBool ? "yes" : "no"); + if (pNewLine) + { + pFOut << std::endl; + } +} + +void SaveSettings(const char* pPath) +{ + std::ofstream fOut; + fOut.open(pPath); + + if (fOut.is_open()) + { + SaveSection(SECTION_COMMON, fOut); + SaveBool("OpenGPGCheck", g_settings_bOpenGPGCheck, fOut); + SaveSetString("OpenGPGPublicKeys", g_settings_setOpenGPGPublicKeys, fOut); + SaveSetString("BlackList", g_settings_mapSettingsBlackList, fOut); + SaveSetString("EnabledPlugins", g_settings_setEnabledPlugins, fOut); + fOut << "Database = " << g_settings_sDatabase << std::endl; + fOut << "MaxCrashReportsSize = " << g_settings_nMaxCrashReportsSize << std::endl; + SaveVectorPairStrings("ActionsAndReporters", g_settings_vectorActionsAndReporters, fOut); + SaveSection(SECTION_ANALYZER_ACTIONS_AND_REPORTERS, fOut); + SaveMapVectorPairStrings(g_settings_mapAnalyzerActionsAndReporters, fOut); + SaveSection(SECTION_CRON, fOut); + SaveMapVectorPairStrings(g_settings_mapCron, fOut); + fOut.close(); + } +} diff --git a/src/Daemon/Settings.h b/src/Daemon/Settings.h index c95786d3..3d3154f6 100644 --- a/src/Daemon/Settings.h +++ b/src/Daemon/Settings.h @@ -12,10 +12,12 @@ typedef std::map<std::string, std::string> map_settings_t; typedef std::set<std::string> set_strings_t; typedef std::pair<std::string, std::string> pair_string_string_t; typedef std::vector<pair_string_string_t> vector_pair_strings_t; -typedef std::map<std::string, vector_pair_strings_t> map_analyzer_actions_and_reporters_t; -typedef std::map<std::string, vector_pair_strings_t> map_cron_t; +typedef std::map<std::string, vector_pair_strings_t> map_vector_pair_strings_t; +typedef map_vector_pair_strings_t map_analyzer_actions_and_reporters_t; +typedef map_vector_pair_strings_t map_cron_t; void LoadSettings(const char* pPath); +void SaveSettings(const char* pPath); extern set_strings_t g_settings_setOpenGPGPublicKeys; extern set_strings_t g_settings_mapSettingsBlackList; diff --git a/src/Daemon/abrt.conf b/src/Daemon/abrt.conf index cc305e02..1fe6123b 100644 --- a/src/Daemon/abrt.conf +++ b/src/Daemon/abrt.conf @@ -11,7 +11,7 @@ OpenGPGPublicKeys = /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora BlackList = # enabled plugins # there has to be exactly one database plugin -EnabledPlugins = SQLite3, CCpp, Logger, Kerneloops, KerneloopsScanner, KerneloopsReporter, Bugzilla, Python #, Mailx +EnabledPlugins = SQLite3, CCpp, Logger, Kerneloops, KerneloopsScanner, KerneloopsReporter, Bugzilla, Python # Database Database = SQLite3 # max size for crash storage [MiB] |