From de2c473ef6cb27a080bb0491f21d1280e2c971c5 Mon Sep 17 00:00:00 2001 From: Zdenek Prikryl Date: Fri, 31 Jul 2009 17:08:49 +0200 Subject: added new interface for geting plugins' settings (will be used in gui) --- lib/MiddleWare/MiddleWare.cpp | 10 +++++ lib/MiddleWare/MiddleWare.h | 27 +++++++++---- lib/MiddleWare/Plugin.h | 81 ++++++++++++++++++++++++++++++++++++-- lib/MiddleWare/PluginManager.cpp | 26 ++++++++++++ lib/MiddleWare/PluginManager.h | 13 ++++++ lib/MiddleWare/test.cpp | 14 +++++++ lib/Plugins/Bugzilla.cpp | 41 +++++++++++++------ lib/Plugins/Bugzilla.h | 2 + lib/Plugins/CCpp.conf | 1 + lib/Plugins/CCpp.cpp | 27 +++++++++++-- lib/Plugins/CCpp.h | 3 ++ lib/Plugins/FileTransfer.cpp | 39 +++++++++++++----- lib/Plugins/FileTransfer.h | 2 + lib/Plugins/KerneloopsReporter.cpp | 25 +++++++++--- lib/Plugins/KerneloopsReporter.h | 5 ++- lib/Plugins/KerneloopsScanner.cpp | 21 ++++++++-- lib/Plugins/KerneloopsScanner.h | 2 + lib/Plugins/Logger.cpp | 26 +++++++++--- lib/Plugins/Logger.h | 5 ++- lib/Plugins/Mailx.cpp | 41 +++++++++++++------ lib/Plugins/Mailx.h | 5 ++- lib/Plugins/SQLite3.cpp | 21 ++++++++-- lib/Plugins/SQLite3.h | 2 + 23 files changed, 368 insertions(+), 71 deletions(-) diff --git a/lib/MiddleWare/MiddleWare.cpp b/lib/MiddleWare/MiddleWare.cpp index 91777556..b4f8da07 100644 --- a/lib/MiddleWare/MiddleWare.cpp +++ b/lib/MiddleWare/MiddleWare.cpp @@ -108,6 +108,16 @@ void CMiddleWare::UnRegisterPlugin(const std::string& pName) m_pPluginManager->UnRegisterPlugin(pName); } +void CMiddleWare::SetPluginSettings(const std::string& pName, + const map_plugin_settings_t& pSettings) +{ + m_pPluginManager->SetPluginSettings(pName, pSettings); +} + +map_plugin_settings_t CMiddleWare::GetPluginSettings(const std::string& pName) +{ + return m_pPluginManager->GetPluginSettings(pName); +} std::string CMiddleWare::GetLocalUUID(const std::string& pAnalyzer, const std::string& pDebugDumpDir) diff --git a/lib/MiddleWare/MiddleWare.h b/lib/MiddleWare/MiddleWare.h index 2144bbaf..6783c4e3 100644 --- a/lib/MiddleWare/MiddleWare.h +++ b/lib/MiddleWare/MiddleWare.h @@ -197,6 +197,26 @@ class CMiddleWare * @param pName A plugin name. */ void UnRegisterPlugin(const std::string& pName); + /** + * A method, which sets up a plugin. + * @param pName A plugin name. + * @param pSettings A plugin's settings. + */ + void SetPluginSettings(const std::string& pName, + const map_plugin_settings_t& pSettings); + /** + * A method, which returns plugin's settings. + * @param pName A plugin name. + * @return Plugin's settings + */ + map_plugin_settings_t GetPluginSettings(const std::string& pName); + /** + * A method, which gets all plugins info (event those plugins which are + * disabled). It can be send via DBus to GUI and displayed to an user. + * Then a user can fill all needed informations like URLs etc. + * @return A vector of maps + */ + vector_map_string_string_t GetPluginsInfo(); /** * A method, which takes care of getting all additional data needed * for computing UUIDs and creating a report for particular analyzer @@ -287,13 +307,6 @@ class CMiddleWare * @return A vector of pairs (local UUID, UID). */ vector_pair_string_string_t GetUUIDsOfCrash(const std::string& pUID); - /** - * A method, which gets all plugins info (event those plugins which are - * disabled). It can be send via DBus to GUI and displayed to an user. - * Then a user can fill all needed informations like URLs etc. - * @return A vector of maps - */ - vector_map_string_string_t GetPluginsInfo(); /** * A method, which set a GPG finger print check. * @param pCheck Is it enabled? diff --git a/lib/MiddleWare/Plugin.h b/lib/MiddleWare/Plugin.h index c7ae9ce7..47915ce4 100644 --- a/lib/MiddleWare/Plugin.h +++ b/lib/MiddleWare/Plugin.h @@ -25,15 +25,20 @@ #include #include +#include -#define PLUGINS_MAGIC_NUMBER 3 + +#define PLUGINS_MAGIC_NUMBER 4 #define PLUGINS_CONF_EXTENSION "conf" #define PLUGINS_LIB_EXTENSION "so" #define PLUGINS_LIB_PREFIX "lib" +typedef std::map map_plugin_settings_t; + /** - * An abstract class. The class defines a common plugin interface. + * An abstract class. The class defines a common plugin interface. If a plugin + * has some settings, then a *Settings(*) method has to be written. */ class CPlugin { @@ -51,10 +56,20 @@ class CPlugin */ virtual void DeInit() {} /** - * A method, which loads a plugin settings. It is not mandatory method. + * A method, which loads a plugin settings from a file. It is not mandatory method. * @param pPath A path to plugin configuration file. */ virtual void LoadSettings(const std::string& pPath) {} + /** + * A method, which takes a settings and apply them. It is not a mandatory method. + * @param pSettings Plugin's settings + */ + virtual void SetSettings(const map_plugin_settings_t& pSettings) {} + /** + * A method, which return current settings. It is not mandatory method. + * @return Plugin's settings + */ + virtual map_plugin_settings_t GetSettings() {return map_plugin_settings_t();} }; /** @@ -101,4 +116,64 @@ typedef struct SPluginInfo PLUGINS_MAGIC_NUMBER,\ }; +inline void plugin_load_settings(const std::string& path, map_plugin_settings_t& settings) +{ + std::ifstream fIn; + fIn.open(path.c_str()); + if (fIn.is_open()) + { + std::string line; + while (!fIn.eof()) + { + getline(fIn, line); + + int ii; + bool is_value = false; + bool valid = false; + bool in_quote = false; + std::string key = ""; + std::string value = ""; + for (ii = 0; ii < line.length(); ii++) + { + if (line[ii] == '\"') + { + in_quote = in_quote == true ? false : true; + } + if (isspace(line[ii]) && !in_quote) + { + continue; + } + if (line[ii] == '#' && !in_quote) + { + break; + } + else if (line[ii] == '=' && !in_quote) + { + is_value = true; + } + else if (line[ii] == '=' && is_value && !in_quote) + { + key = ""; + value = ""; + break; + } + else if (!is_value) + { + key += line[ii]; + } + else + { + valid = true; + value += line[ii]; + } + } + if (valid && !in_quote) + { + settings[key] = value; + } + } + fIn.close(); + } +} + #endif /* PLUGIN_H_ */ diff --git a/lib/MiddleWare/PluginManager.cpp b/lib/MiddleWare/PluginManager.cpp index 2d110936..2002a4ad 100644 --- a/lib/MiddleWare/PluginManager.cpp +++ b/lib/MiddleWare/PluginManager.cpp @@ -240,6 +240,8 @@ vector_map_string_string_t CPluginManager::GetPluginsInfo() { map_string_string_t plugin_info; + plugin_info["Enabled"] = (m_mapPlugins.find(it_abrt_plugin->second->GetName()) != m_mapPlugins.end()) ? + "yes" : "no"; plugin_info["Type"] = plugin_type_str_t[it_abrt_plugin->second->GetType()]; plugin_info["Name"] = it_abrt_plugin->second->GetName(); plugin_info["Version"] = it_abrt_plugin->second->GetVersion(); @@ -253,3 +255,27 @@ vector_map_string_string_t CPluginManager::GetPluginsInfo() return ret; } +void CPluginManager::SetPluginSettings(const std::string& pName, + const map_plugin_settings_t& pSettings) +{ + if (m_mapABRTPlugins.find(pName) != m_mapABRTPlugins.end()) + { + if (m_mapPlugins.find(pName) != m_mapPlugins.end()) + { + m_mapPlugins[pName]->SetSettings(pSettings); + } + } +} + +map_plugin_settings_t CPluginManager::GetPluginSettings(const std::string& pName) +{ + map_plugin_settings_t ret; + if (m_mapABRTPlugins.find(pName) != m_mapABRTPlugins.end()) + { + if (m_mapPlugins.find(pName) != m_mapPlugins.end()) + { + ret = m_mapPlugins[pName]->GetSettings(); + } + } + return ret; +} diff --git a/lib/MiddleWare/PluginManager.h b/lib/MiddleWare/PluginManager.h index 4883a107..21c37fae 100644 --- a/lib/MiddleWare/PluginManager.h +++ b/lib/MiddleWare/PluginManager.h @@ -138,6 +138,19 @@ class CPluginManager * @return A vector of maps */ vector_map_string_string_t GetPluginsInfo(); + /** + * A method, which sets up a plugin. + * @param pName A plugin name. + * @param pSettings A plugin's settings. + */ + void SetPluginSettings(const std::string& pName, + const map_plugin_settings_t& pSettings); + /** + * A method, which returns plugin's settings. + * @param pName A plugin name. + * @return Plugin's settings + */ + map_plugin_settings_t GetPluginSettings(const std::string& pName); }; #endif /*PLUGINMANAGER_H_*/ diff --git a/lib/MiddleWare/test.cpp b/lib/MiddleWare/test.cpp index 5a3519cc..9e2498f5 100644 --- a/lib/MiddleWare/test.cpp +++ b/lib/MiddleWare/test.cpp @@ -57,6 +57,9 @@ int main(int argc, char** argv) int ii; for ( ii = 0; ii < loaded_plugins.size(); ii++) { + std::cout << "-------------------------------------------" << std::endl; + map_plugin_settings_t settings; + std::cout << "Enabled: " << loaded_plugins[ii]["Enabled"] << std::endl; std::cout << "Type: " << loaded_plugins[ii]["Type"] << std::endl; std::cout << "Name: " << loaded_plugins[ii]["Name"] << std::endl; std::cout << "Version: " << loaded_plugins[ii]["Version"] << std::endl; @@ -64,6 +67,17 @@ int main(int argc, char** argv) std::cout << "Email: " << loaded_plugins[ii]["Email"] << std::endl; std::cout << "WWW: " << loaded_plugins[ii]["WWW"] << std::endl; std::cout << "GTKBuilder: " << loaded_plugins[ii]["GTKBuilder"] << std::endl; + if (loaded_plugins[ii]["Enabled"] == "yes") + { + std::cout << std::endl << "Settings: " << std::endl; + settings = middleWare.GetPluginSettings(loaded_plugins[ii]["Name"]); + map_plugin_settings_t::iterator it; + for (it = settings.begin(); it != settings.end(); it++) + { + std::cout << "\t" << it->first << ": " << it->second << std::endl; + } + } + std::cout << "-------------------------------------------" << std::endl; } /* Try to save it into DB */ map_crash_info_t crashInfo; diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp index 864321f2..2cb5b4cf 100644 --- a/lib/Plugins/Bugzilla.cpp +++ b/lib/Plugins/Bugzilla.cpp @@ -1,7 +1,6 @@ #include "Bugzilla.h" #include #include "CrashTypes.h" -#include "PluginSettings.h" #include "DebugDump.h" #include "ABRTException.h" #include "CommLayerInner.h" @@ -18,10 +17,9 @@ CReporterBugzilla::CReporterBugzilla() : CReporterBugzilla::~CReporterBugzilla() {} -#include + void CReporterBugzilla::NewXMLRPCClient() { - std::cout << "m_bNoSSLVerify: " << m_bNoSSLVerify << std::endl; m_pXmlrpcTransport = new xmlrpc_c::clientXmlTransport_curl( xmlrpc_c::clientXmlTransport_curl::constrOpt() .no_ssl_verifyhost(m_bNoSSLVerify) @@ -117,6 +115,8 @@ bool CReporterBugzilla::CheckUUIDInBugzilla(const std::string& pComponent, const std::vector bugs = xmlrpc_c::value_array(ret["bugs"]).vectorValueValue(); if (bugs.size() > 0) { + comm_layer_inner_debug("Bug is already reported."); + comm_layer_inner_status("Bug is already reported."); return true; } return false; @@ -322,27 +322,44 @@ void CReporterBugzilla::Report(const map_crash_report_t& pCrashReport, const std void CReporterBugzilla::LoadSettings(const std::string& pPath) { - map_settings_t settings; + map_plugin_settings_t settings; plugin_load_settings(pPath, settings); - if (settings.find("BugzillaURL")!= settings.end()) + SetSettings(settings); +} + +void CReporterBugzilla::SetSettings(const map_plugin_settings_t& pSettings) +{ + if (pSettings.find("BugzillaURL") != pSettings.end()) { - m_sBugzillaURL = settings["BugzillaURL"]; + m_sBugzillaURL = pSettings.find("BugzillaURL")->second; } - if (settings.find("Login")!= settings.end()) + if (pSettings.find("Login") != pSettings.end()) { - m_sLogin = settings["Login"]; + m_sLogin = pSettings.find("Login")->second; } - if (settings.find("Password")!= settings.end()) + if (pSettings.find("Password") != pSettings.end()) { - m_sPassword = settings["Password"]; + m_sPassword = pSettings.find("Password")->second; } - if (settings.find("NoSSLVerify")!= settings.end()) + if (pSettings.find("NoSSLVerify") != pSettings.end()) { - m_bNoSSLVerify = settings["NoSSLVerify"] == "yes"; + m_bNoSSLVerify = pSettings.find("NoSSLVerify")->second == "yes"; } } +map_plugin_settings_t CReporterBugzilla::GetSettings() +{ + map_plugin_settings_t ret; + + ret["BugzillaURL"] = m_sBugzillaURL; + ret["Login"] = m_sLogin; + ret["Password"] = m_sPassword; + ret["NoSSLVerify"] = m_bNoSSLVerify ? "yes" : "no"; + + return ret; +} + PLUGIN_INFO(REPORTER, CReporterBugzilla, "Bugzilla", diff --git a/lib/Plugins/Bugzilla.h b/lib/Plugins/Bugzilla.h index 6d53defe..84ae4e68 100644 --- a/lib/Plugins/Bugzilla.h +++ b/lib/Plugins/Bugzilla.h @@ -39,6 +39,8 @@ class CReporterBugzilla : public CReporter CReporterBugzilla(); virtual ~CReporterBugzilla(); virtual void LoadSettings(const std::string& pPath); + virtual void SetSettings(const map_plugin_settings_t& pSettings); + virtual map_plugin_settings_t GetSettings(); virtual void Report(const map_crash_report_t& pCrashReport, const std::string& pArgs); }; diff --git a/lib/Plugins/CCpp.conf b/lib/Plugins/CCpp.conf index 51a9558b..11a5eb8e 100644 --- a/lib/Plugins/CCpp.conf +++ b/lib/Plugins/CCpp.conf @@ -1,4 +1,5 @@ # Configuration file for CCpp add-on +# NONE OF THESE OPTIONS IS SUPPORTED # generate memory map too MemoryMap = no diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index 6c2bc444..0cbcdcc0 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -23,10 +23,10 @@ #include "CCpp.h" #include "ABRTException.h" #include "DebugDump.h" -#include "PluginSettings.h" #include "CommLayerInner.h" #include #include +#include //#include //#include //#include @@ -573,15 +573,34 @@ void CAnalyzerCCpp::DeInit() void CAnalyzerCCpp::LoadSettings(const std::string& pPath) { - map_settings_t settings; + map_plugin_settings_t settings; plugin_load_settings(pPath, settings); - if (settings.find("MemoryMap") != settings.end()) + SetSettings(settings); +} + +void CAnalyzerCCpp::SetSettings(const map_plugin_settings_t& pSettings) +{ + if (pSettings.find("MemoryMap") != pSettings.end()) + { + m_bMemoryMap = pSettings.find("MemoryMap")->second == "yes"; + } + if (pSettings.find("DebugInfo") != pSettings.end()) { - m_bMemoryMap = settings["MemoryMap"] == "yes"; + m_sDebugInfo = pSettings.find("DebugInfo")->second; } } +map_plugin_settings_t CAnalyzerCCpp::GetSettings() +{ + map_plugin_settings_t ret; + + ret["MemoryMap"] = m_bMemoryMap ? "yes" : "no"; + ret["DebugInfo"] = m_sDebugInfo; + + return ret; +} + PLUGIN_INFO(ANALYZER, CAnalyzerCCpp, "CCpp", diff --git a/lib/Plugins/CCpp.h b/lib/Plugins/CCpp.h index 27f17cdd..a6bb6aaa 100644 --- a/lib/Plugins/CCpp.h +++ b/lib/Plugins/CCpp.h @@ -33,6 +33,7 @@ class CAnalyzerCCpp : public CAnalyzer bool m_bMemoryMap; pid_t m_Pid; std::string m_sOldCorePattern; + std::string m_sDebugInfo; void InstallDebugInfos(const std::string& pPackage); void GetBacktrace(const std::string& pDebugDumpDir, std::string& pBacktrace); void GetIndependentBacktrace(const std::string& pBacktrace, std::string& pIndependentBacktrace); @@ -48,6 +49,8 @@ class CAnalyzerCCpp : public CAnalyzer virtual void Init(); virtual void DeInit(); virtual void LoadSettings(const std::string& pPath); + virtual void SetSettings(const map_plugin_settings_t& pSettings); + virtual map_plugin_settings_t GetSettings(); }; #endif /* CCPP */ diff --git a/lib/Plugins/FileTransfer.cpp b/lib/Plugins/FileTransfer.cpp index 3b7b979b..1aa724d6 100644 --- a/lib/Plugins/FileTransfer.cpp +++ b/lib/Plugins/FileTransfer.cpp @@ -32,7 +32,6 @@ #include "DebugDump.h" #include "ABRTException.h" -#include "PluginSettings.h" #include "CommLayerInner.h" @@ -225,32 +224,37 @@ void CFileTransfer::Run(const std::string& pActiveDir, const std::string& pArgs) void CFileTransfer::LoadSettings(const std::string& pPath) { - map_settings_t settings; + map_plugin_settings_t settings; plugin_load_settings(pPath, settings); - if (settings.find("URL")!= settings.end()) + SetSettings(settings); +} + +void CFileTransfer::SetSettings(const map_plugin_settings_t& pSettings) +{ + if (pSettings.find("URL") != pSettings.end()) { - m_sURL = settings["URL"]; + m_sURL = pSettings.find("URL")->second; } else { comm_layer_inner_warning("FileTransfer: URL not specified"); } - if (settings.find("RetryCount")!= settings.end()) + if (pSettings.find("RetryCount") != pSettings.end()) { - m_nRetryCount = atoi(settings["RetryCount"].c_str()); + m_nRetryCount = atoi(pSettings.find("RetryCount")->second.c_str()); } - if (settings.find("RetryDelay")!= settings.end()) + if (pSettings.find("RetryDelay") != pSettings.end()) { - m_nRetryDelay = atoi(settings["RetryDelay"].c_str()); + m_nRetryDelay = atoi(pSettings.find("RetryDelay")->second.c_str()); } - if (settings.find("ArchiveType")!= settings.end()) + if (pSettings.find("ArchiveType") != pSettings.end()) { /* currently supporting .tar.gz, .tar.bz2 and .zip */ - m_sArchiveType = settings["ArchiveType"]; + m_sArchiveType =pSettings.find("ArchiveType")->second; if(m_sArchiveType[0] != '.') { m_sArchiveType = "." + m_sArchiveType; @@ -258,6 +262,21 @@ void CFileTransfer::LoadSettings(const std::string& pPath) } } +map_plugin_settings_t CFileTransfer::GetSettings() +{ + map_plugin_settings_t ret; + std::stringstream ss; + ret["URL"] = m_sURL; + ss << m_nRetryCount; + ret["RetryCount"] = ss.str(); + ss.str(""); + ss << m_nRetryDelay; + ret["RetryDelay"] = ss.str(); + ret["ArchiveType"] = m_sArchiveType; + + return ret; +} + PLUGIN_INFO(ACTION, CFileTransfer, "FileTransfer", diff --git a/lib/Plugins/FileTransfer.h b/lib/Plugins/FileTransfer.h index f044cf7b..2dd0151e 100644 --- a/lib/Plugins/FileTransfer.h +++ b/lib/Plugins/FileTransfer.h @@ -51,6 +51,8 @@ class CFileTransfer : public CAction virtual ~CFileTransfer() {} virtual void LoadSettings(const std::string& pPath); + virtual void SetSettings(const map_plugin_settings_t& pSettings); + virtual map_plugin_settings_t GetSettings(); virtual void Run(const std::string& pActiveDir, const std::string& pArgs); }; diff --git a/lib/Plugins/KerneloopsReporter.cpp b/lib/Plugins/KerneloopsReporter.cpp index e3a28956..139ecf54 100644 --- a/lib/Plugins/KerneloopsReporter.cpp +++ b/lib/Plugins/KerneloopsReporter.cpp @@ -26,7 +26,6 @@ #include "abrtlib.h" #include "KerneloopsReporter.h" -#include "PluginSettings.h" #include "CommLayerInner.h" //#include @@ -110,13 +109,27 @@ void CKerneloopsReporter::Report(const map_crash_report_t& pCrashReport, const s void CKerneloopsReporter::LoadSettings(const std::string& pPath) { - map_settings_t settings; + map_plugin_settings_t settings; plugin_load_settings(pPath, settings); - if (settings.find("SubmitURL") != settings.end()) - { - m_sSubmitURL = settings["SubmitURL"]; - } + SetSettings(settings); +} + +void CKerneloopsReporter::SetSettings(const map_plugin_settings_t& pSettings) +{ + if (pSettings.find("SubmitURL") != pSettings.end()) + { + m_sSubmitURL = pSettings.find("SubmitURL")->second; + } +} + +map_plugin_settings_t CKerneloopsReporter::GetSettings() +{ + map_plugin_settings_t ret; + + ret["SubmitURL"] = m_sSubmitURL; + + return ret; } PLUGIN_INFO(REPORTER, diff --git a/lib/Plugins/KerneloopsReporter.h b/lib/Plugins/KerneloopsReporter.h index a5e06836..3ec8cc9b 100644 --- a/lib/Plugins/KerneloopsReporter.h +++ b/lib/Plugins/KerneloopsReporter.h @@ -42,7 +42,10 @@ class CKerneloopsReporter : public CReporter virtual ~CKerneloopsReporter() {} virtual void LoadSettings(const std::string& pPath); - virtual void Report(const map_crash_report_t& pCrashReport, const std::string& pArgs); + virtual void SetSettings(const map_plugin_settings_t& pSettings); + virtual map_plugin_settings_t GetSettings(); + virtual void Report(const map_crash_report_t& pCrashReport, + const std::string& pArgs); }; #endif diff --git a/lib/Plugins/KerneloopsScanner.cpp b/lib/Plugins/KerneloopsScanner.cpp index 96fe1973..082f1531 100644 --- a/lib/Plugins/KerneloopsScanner.cpp +++ b/lib/Plugins/KerneloopsScanner.cpp @@ -4,7 +4,6 @@ #include "DebugDump.h" #include "ABRTException.h" #include "CommLayerInner.h" -#include "PluginSettings.h" #include //#include @@ -143,15 +142,29 @@ int CKerneloopsScanner::ScanSysLogFile(const char *filename) void CKerneloopsScanner::LoadSettings(const std::string& pPath) { - map_settings_t settings; + map_plugin_settings_t settings; plugin_load_settings(pPath, settings); - if (settings.find("SysLogFile") != settings.end()) + SetSettings(settings); +} + +void CKerneloopsScanner::SetSettings(const map_plugin_settings_t& pSettings) +{ + if (pSettings.find("SysLogFile") != pSettings.end()) { - m_sSysLogFile = settings["SysLogFile"]; + m_sSysLogFile = pSettings.find("SysLogFile")->second; } } +map_plugin_settings_t CKerneloopsScanner::GetSettings() +{ + map_plugin_settings_t ret; + + ret["SysLogFile"] = m_sSysLogFile; + + return ret; +} + PLUGIN_INFO(ACTION, CKerneloopsScanner, "KerneloopsScanner", diff --git a/lib/Plugins/KerneloopsScanner.h b/lib/Plugins/KerneloopsScanner.h index 50e8a4d9..ff0d98b3 100644 --- a/lib/Plugins/KerneloopsScanner.h +++ b/lib/Plugins/KerneloopsScanner.h @@ -27,6 +27,8 @@ class CKerneloopsScanner : public CAction virtual void Run(const std::string& pActionDir, const std::string& pArgs); virtual void LoadSettings(const std::string& pPath); + virtual void SetSettings(const map_plugin_settings_t& pSettings); + virtual map_plugin_settings_t GetSettings(); }; #endif /* KERNELOOPSSCANNER_H_ */ diff --git a/lib/Plugins/Logger.cpp b/lib/Plugins/Logger.cpp index 5e99cf9d..1dd5a28d 100644 --- a/lib/Plugins/Logger.cpp +++ b/lib/Plugins/Logger.cpp @@ -21,7 +21,6 @@ #include "Logger.h" #include -#include "PluginSettings.h" #include #include "DebugDump.h" #include "CommLayerInner.h" @@ -33,19 +32,34 @@ CLogger::CLogger() : void CLogger::LoadSettings(const std::string& pPath) { - map_settings_t settings; + map_plugin_settings_t settings; plugin_load_settings(pPath, settings); - if (settings.find("LogPath")!= settings.end()) + SetSettings(settings); +} + +void CLogger::SetSettings(const map_plugin_settings_t& pSettings) +{ + if (pSettings.find("LogPath") != pSettings.end()) { - m_sLogPath = settings["LogPath"]; + m_sLogPath = pSettings.find("LogPath")->second; } - if (settings.find("AppendLogs")!= settings.end()) + if (pSettings.find("AppendLogs") != pSettings.end()) { - m_bAppendLogs = settings["AppendLogs"] == "yes"; + m_bAppendLogs = pSettings.find("AppendLogs")->second == "yes"; } } +map_plugin_settings_t CLogger::GetSettings() +{ + map_plugin_settings_t ret; + + ret["LogPath"] = m_sLogPath; + ret["AppendLogs"] = m_bAppendLogs ? "yes" : "no"; + + return ret; +} + void CLogger::Report(const map_crash_report_t& pCrashReport, const std::string& pArgs) { comm_layer_inner_status("Creating a report..."); diff --git a/lib/Plugins/Logger.h b/lib/Plugins/Logger.h index 5200f0ec..b76dbf2e 100644 --- a/lib/Plugins/Logger.h +++ b/lib/Plugins/Logger.h @@ -36,7 +36,10 @@ class CLogger : public CReporter virtual ~CLogger() {} virtual void LoadSettings(const std::string& pPath); - virtual void Report(const map_crash_report_t& pCrashReport, const std::string& pArgs); + virtual void SetSettings(const map_plugin_settings_t& pSettings); + virtual map_plugin_settings_t GetSettings(); + virtual void Report(const map_crash_report_t& pCrashReport, + const std::string& pArgs); }; #endif /* LOGGER_H_ */ diff --git a/lib/Plugins/Mailx.cpp b/lib/Plugins/Mailx.cpp index fdc3dcb1..d017d53f 100644 --- a/lib/Plugins/Mailx.cpp +++ b/lib/Plugins/Mailx.cpp @@ -24,7 +24,6 @@ #include #include "DebugDump.h" #include "ABRTException.h" -#include "PluginSettings.h" #include "CommLayerInner.h" #define MAILX_COMMAND "/bin/mailx" @@ -140,31 +139,49 @@ void CMailx::Report(const map_crash_report_t& pCrashReport, const std::string& p void CMailx::LoadSettings(const std::string& pPath) { - map_settings_t settings; + map_plugin_settings_t settings; plugin_load_settings(pPath, settings); - if (settings.find("Subject")!= settings.end()) + SetSettings(settings); +} + +void CMailx::SetSettings(const map_plugin_settings_t& pSettings) +{ + if (pSettings.find("Subject") != pSettings.end()) { - m_sSubject = settings["Subject"]; + m_sSubject = pSettings.find("Subject")->second; } - if (settings.find("EmailFrom")!= settings.end()) + if (pSettings.find("EmailFrom") != pSettings.end()) { - m_sEmailFrom = settings["EmailFrom"]; + m_sEmailFrom = pSettings.find("EmailFrom")->second; } - if (settings.find("EmailTo")!= settings.end()) + if (pSettings.find("EmailTo") != pSettings.end()) { - m_sEmailTo = settings["EmailTo"]; + m_sEmailTo = pSettings.find("EmailTo")->second; } - if (settings.find("Parameters")!= settings.end()) + if (pSettings.find("Parameters") != pSettings.end()) { - m_sParameters = settings["Parameters"]; + m_sParameters = pSettings.find("Parameters")->second; } - if (settings.find("SendBinaryData")!= settings.end()) + if (pSettings.find("SendBinaryData") != pSettings.end()) { - m_bSendBinaryData = settings["SendBinaryData"] == "yes"; + m_bSendBinaryData = pSettings.find("SendBinaryData")->second == "yes"; } } +map_plugin_settings_t CMailx::GetSettings() +{ + map_plugin_settings_t ret; + + ret["Subject"] = m_sSubject; + ret["EmailFrom"] = m_sEmailFrom; + ret["EmailTo"] = m_sEmailTo; + ret["Parameters"] = m_sParameters; + ret["SendBinaryData"] = m_bSendBinaryData ? "yes" : "no"; + + return ret; +} + PLUGIN_INFO(REPORTER, CMailx, "Mailx", diff --git a/lib/Plugins/Mailx.h b/lib/Plugins/Mailx.h index e2173ed5..414a6e93 100644 --- a/lib/Plugins/Mailx.h +++ b/lib/Plugins/Mailx.h @@ -44,7 +44,10 @@ class CMailx : public CReporter virtual ~CMailx() {} virtual void LoadSettings(const std::string& pPath); - virtual void Report(const map_crash_report_t& pCrashReport, const std::string& pArgs); + virtual void SetSettings(const map_plugin_settings_t& pSettings); + virtual map_plugin_settings_t GetSettings(); + virtual void Report(const map_crash_report_t& pCrashReport, + const std::string& pArgs); }; #endif /* MAILX_H_ */ diff --git a/lib/Plugins/SQLite3.cpp b/lib/Plugins/SQLite3.cpp index ada5f507..ecf848e7 100644 --- a/lib/Plugins/SQLite3.cpp +++ b/lib/Plugins/SQLite3.cpp @@ -24,7 +24,6 @@ #include "SQLite3.h" #include #include -#include "PluginSettings.h" #include "ABRTException.h" #define ABRT_TABLE "abrt" @@ -270,15 +269,29 @@ const database_row_t CSQLite3::GetUUIDData(const std::string& pUUID, const std:: void CSQLite3::LoadSettings(const std::string& pPath) { - map_settings_t settings; + map_plugin_settings_t settings; plugin_load_settings(pPath, settings); - if (settings.find("DBPath")!= settings.end()) + SetSettings(settings); +} + +void CSQLite3::SetSettings(const map_plugin_settings_t& pSettings) +{ + if (pSettings.find("DBPath") != pSettings.end()) { - m_sDBPath = settings["DBPath"]; + m_sDBPath = pSettings.find("DBPath")->second; } } +map_plugin_settings_t CSQLite3::GetSettings() +{ + map_plugin_settings_t ret; + + ret["DBPath"] = m_sDBPath; + + return ret; +} + PLUGIN_INFO(DATABASE, CSQLite3, "SQLite3", diff --git a/lib/Plugins/SQLite3.h b/lib/Plugins/SQLite3.h index ce0b81e9..15cb8c6f 100644 --- a/lib/Plugins/SQLite3.h +++ b/lib/Plugins/SQLite3.h @@ -59,6 +59,8 @@ class CSQLite3 : public CDatabase virtual const database_row_t GetUUIDData(const std::string& pUUID, const std::string& pUID); virtual void LoadSettings(const std::string& pPath); + virtual void SetSettings(const map_plugin_settings_t& pSettings); + virtual map_plugin_settings_t GetSettings(); }; #endif /* SQLITE3_H_ */ -- cgit