diff options
| author | Zdenek Prikryl <zprikryl@redhat.com> | 2009-06-10 10:06:37 +0200 |
|---|---|---|
| committer | Zdenek Prikryl <zprikryl@redhat.com> | 2009-06-10 10:06:37 +0200 |
| commit | 5b80ac3bd83483cf937b13b222b55a0980ffdc39 (patch) | |
| tree | ec7cb1d37cbf740b41263d4e2c6dd14c78f9a229 /lib/MiddleWare | |
| parent | 9eab929557ef4228b3335f4908dd6b4acf9251dc (diff) | |
| download | abrt-5b80ac3bd83483cf937b13b222b55a0980ffdc39.tar.gz abrt-5b80ac3bd83483cf937b13b222b55a0980ffdc39.tar.xz abrt-5b80ac3bd83483cf937b13b222b55a0980ffdc39.zip | |
abrt can take reporter's configuration file from reporting users's $HOME/.abrt/ directory
Diffstat (limited to 'lib/MiddleWare')
| -rw-r--r-- | lib/MiddleWare/MiddleWare.cpp | 63 | ||||
| -rw-r--r-- | lib/MiddleWare/MiddleWare.h | 13 |
2 files changed, 41 insertions, 35 deletions
diff --git a/lib/MiddleWare/MiddleWare.cpp b/lib/MiddleWare/MiddleWare.cpp index 9b4b088..78fc541 100644 --- a/lib/MiddleWare/MiddleWare.cpp +++ b/lib/MiddleWare/MiddleWare.cpp @@ -27,7 +27,8 @@ CMiddleWare::CMiddleWare(const std::string& pPlugisConfDir, const std::string& pPlugisLibDir) : m_pPluginManager(NULL), - m_bOpenGPGCheck(true) + m_bOpenGPGCheck(true), + m_sPluginsConfDir(pPlugisConfDir) { m_pPluginManager = new CPluginManager(pPlugisConfDir, pPlugisLibDir); m_pPluginManager->LoadPlugins(); @@ -193,14 +194,8 @@ void CMiddleWare::RunAction(const std::string& pActionDir, try { CAction* action = m_pPluginManager->GetAction(pPluginName); - if (action) - { - action->Run(pActionDir, pPluginArgs); - } - else - { - throw CABRTException(EXCEP_ERROR, "Plugin '"+pPluginName+"' is not registered."); - } + + action->Run(pActionDir, pPluginArgs); } catch (CABRTException& e) { @@ -217,33 +212,36 @@ void CMiddleWare::RunActionsAndReporters(const std::string& pDebugDumpDir) { try { - CReporter* reporter = m_pPluginManager->GetReporter((*it_ar).first); - CAction* action = m_pPluginManager->GetAction((*it_ar).first); - if (reporter) + if (m_pPluginManager->GetPluginType((*it_ar).first) == REPORTER) { + CReporter* reporter = m_pPluginManager->GetReporter((*it_ar).first); + map_crash_report_t crashReport; DebugDumpToCrashReport(pDebugDumpDir, crashReport); reporter->Report(crashReport, (*it_ar).second); } - else if (action) + else if (m_pPluginManager->GetPluginType((*it_ar).first) == ACTION) { + CAction* action = m_pPluginManager->GetAction((*it_ar).first); action->Run(pDebugDumpDir, (*it_ar).second); } - else - { - throw CABRTException(EXCEP_ERROR, "Plugin '"+(*it_ar).first+"' is not registered."); - } } catch (CABRTException& e) { comm_layer_inner_warning("CMiddleWare::RunActionsAndReporters(): " + e.what()); - comm_layer_inner_status("Reporting via '"+(*it_ar).first+"' was not successful: " + e.what()); + comm_layer_inner_status("Activation of plugin '"+(*it_ar).first+"' was not successful: " + e.what()); } } } void CMiddleWare::Report(const map_crash_report_t& pCrashReport) { + Report(pCrashReport, m_sPluginsConfDir); +} + +void CMiddleWare::Report(const map_crash_report_t& pCrashReport, + const std::string& pPluginsConfDir) +{ if (pCrashReport.find(CD_MWANALYZER) == pCrashReport.end() || pCrashReport.find(CD_MWUID) == pCrashReport.end() || pCrashReport.find(CD_MWUUID) == pCrashReport.end()) @@ -263,14 +261,20 @@ void CMiddleWare::Report(const map_crash_report_t& pCrashReport) { try { - CReporter* reporter = m_pPluginManager->GetReporter((*it_r).first); - if (reporter) + if (m_pPluginManager->GetPluginType((*it_r).first) == REPORTER) { - reporter->Report(pCrashReport, (*it_r).second); - } - else - { - throw CABRTException(EXCEP_ERROR, "Plugin '"+(*it_r).first+"' is not registered."); + CReporter* reporter = m_pPluginManager->GetReporter((*it_r).first); + + if (pPluginsConfDir == m_sPluginsConfDir) + { + reporter->Report(pCrashReport, (*it_r).second); + } + else + { + reporter->LoadSettings(pPluginsConfDir + "/" + (*it_r).first + "." + PLUGINS_CONF_EXTENSION); + reporter->Report(pCrashReport, (*it_r).second); + reporter->LoadSettings(m_sPluginsConfDir + "/" + (*it_r).first + "." + PLUGINS_CONF_EXTENSION); + } } } catch (CABRTException& e) @@ -403,15 +407,12 @@ void CMiddleWare::RunAnalyzerActions(const std::string& pAnalyzer, const std::st { try { - CAction* action = m_pPluginManager->GetAction((*it_a).first); - if (action) + if (m_pPluginManager->GetPluginType((*it_a).first) == ACTION) { + CAction* action = m_pPluginManager->GetAction((*it_a).first); + action->Run(pDebugDumpDir, (*it_a).second); } - else if (m_pPluginManager->GetReporter((*it_a).first) == NULL) - { - throw CABRTException(EXCEP_ERROR, "Plugin '"+(*it_a).first+"' is not registered."); - } } catch (CABRTException& e) { diff --git a/lib/MiddleWare/MiddleWare.h b/lib/MiddleWare/MiddleWare.h index eb12df6..f817f00 100644 --- a/lib/MiddleWare/MiddleWare.h +++ b/lib/MiddleWare/MiddleWare.h @@ -59,7 +59,7 @@ class CMiddleWare std::string m_sDatabase; map_analyzer_actions_and_reporters_t m_mapAnalyzerActionsAndReporters; vector_actions_and_reporters_t m_vectorActionsAndReporters; - + std::string m_sPluginsConfDir; bool m_bOpenGPGCheck; std::string GetLocalUUID(const std::string& pAnalyzer, @@ -68,11 +68,14 @@ class CMiddleWare const std::string& pDebugDumpDir); void CreateReport(const std::string& pAnalyzer, const std::string& pDebugDumpDir); - void RunAnalyzerActions(const std::string& pAnalyzer, const std::string& pDebugDumpDir); + void RunAnalyzerActions(const std::string& pAnalyzer, + const std::string& pDebugDumpDir); void DebugDumpToCrashReport(const std::string& pDebugDumpDir, map_crash_report_t& pCrashReport); - bool IsDebugDumpSaved(const std::string& pUID, const std::string& pDebugDumpDir); - mw_result_t SavePackageDescriptionToDebugDump(const std::string& pExecutable, const std::string& pDebugDumpDir); + bool IsDebugDumpSaved(const std::string& pUID, + const std::string& pDebugDumpDir); + mw_result_t SavePackageDescriptionToDebugDump(const std::string& pExecutable, + const std::string& pDebugDumpDir); mw_result_t SaveDebugDumpToDatabase(const std::string& pUUID, const std::string& pUID, const std::string& pTime, @@ -99,6 +102,8 @@ class CMiddleWare void RunActionsAndReporters(const std::string& pDebugDumpDir); void Report(const map_crash_report_t& pCrashReport); + void Report(const map_crash_report_t& pCrashReport, + const std::string& pSettingsPath); void DeleteDebugDumpDir(const std::string& pDebugDumpDir); std::string DeleteCrashInfo(const std::string& pUUID, const std::string& pUID); |
