diff options
| author | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-05-12 15:55:34 +0200 |
|---|---|---|
| committer | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-05-12 15:55:34 +0200 |
| commit | b6bc6d13eed2f346414d731ecb29579a719556f3 (patch) | |
| tree | b429d87c2dc7a7b97e2ee4fe19a2e1c1a5b1180d /lib/MiddleWare | |
| parent | f92d9b70a2cb12451f2df00a5a2f9a47e2b9c5ce (diff) | |
| parent | 6b77cb82cb7b918660435effb0fe356401bfdd55 (diff) | |
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Conflicts:
src/Daemon/Daemon.cpp
Diffstat (limited to 'lib/MiddleWare')
| -rw-r--r-- | lib/MiddleWare/Action.h | 2 | ||||
| -rw-r--r-- | lib/MiddleWare/MiddleWare.cpp | 111 | ||||
| -rw-r--r-- | lib/MiddleWare/MiddleWare.h | 29 |
3 files changed, 93 insertions, 49 deletions
diff --git a/lib/MiddleWare/Action.h b/lib/MiddleWare/Action.h index 9a2c2f1..96461f3 100644 --- a/lib/MiddleWare/Action.h +++ b/lib/MiddleWare/Action.h @@ -29,7 +29,7 @@ class CAction : public CPlugin { public: virtual ~CAction() {} - virtual void Run(const std::string& pDebugDumpDir, + virtual void Run(const std::string& pActionDir, const std::string& pArgs) = 0; }; diff --git a/lib/MiddleWare/MiddleWare.cpp b/lib/MiddleWare/MiddleWare.cpp index 03285ee..d5e8237 100644 --- a/lib/MiddleWare/MiddleWare.cpp +++ b/lib/MiddleWare/MiddleWare.cpp @@ -185,24 +185,58 @@ int CMiddleWare::CreateCrashReport(const std::string& pUUID, return 1; } -void CMiddleWare::Report(const std::string& pDebugDumpDir) +void CMiddleWare::RunAction(const std::string& pActionDir, + const std::string& pPluginName, + const std::string& pPluginArgs) { - map_crash_report_t crashReport; + try + { + CAction* action = m_pPluginManager->GetAction(pPluginName); + if (action) + { + action->Run(pActionDir, pPluginArgs); + } + else + { + throw CABRTException(EXCEP_ERROR, "Plugin '"+pPluginName+"' is not registered."); + } + } + catch (CABRTException& e) + { + comm_layer_inner_warning("CMiddleWare::RunAction(): " + e.what()); + comm_layer_inner_status("Execution of '"+pPluginName+"' was not successful: " + e.what()); + } - DebugDumpToCrashReport(pDebugDumpDir, crashReport); +} - set_reporters_t::iterator it_r; - for (it_r = m_setReporters.begin(); it_r != m_setReporters.end(); it_r++) +void CMiddleWare::RunActionsAndReporters(const std::string& pDebugDumpDir) +{ + vector_actions_and_reporters_t::iterator it_ar; + for (it_ar = m_vectorActionsAndReporters.begin(); it_ar != m_vectorActionsAndReporters.end(); it_ar++) { try { - CReporter* reporter = m_pPluginManager->GetReporter((*it_r).first); - reporter->Report(crashReport, (*it_r).second); + CReporter* reporter = m_pPluginManager->GetReporter((*it_ar).first); + CAction* action = m_pPluginManager->GetAction((*it_ar).first); + if (reporter) + { + map_crash_report_t crashReport; + DebugDumpToCrashReport(pDebugDumpDir, crashReport); + reporter->Report(crashReport, (*it_ar).second); + } + else if (action) + { + 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::Report(): " + e.what()); - comm_layer_inner_status("Reporting via '"+(*it_r).first+"' was not successful: " + e.what()); + comm_layer_inner_warning("CMiddleWare::RunActionsAndReporters(): " + e.what()); + comm_layer_inner_status("Reporting via '"+(*it_ar).first+"' was not successful: " + e.what()); } } } @@ -219,17 +253,24 @@ void CMiddleWare::Report(const map_crash_report_t& pCrashReport) std::string UID = pCrashReport.find(CD_MWUID)->second[CD_CONTENT]; std::string UUID = pCrashReport.find(CD_MWUUID)->second[CD_CONTENT]; - if (m_mapAnalyzerReporters.find(analyzer) != m_mapAnalyzerReporters.end()) + if (m_mapAnalyzerActionsAndReporters.find(analyzer) != m_mapAnalyzerActionsAndReporters.end()) { - set_reporters_t::iterator it_r; - for (it_r = m_mapAnalyzerReporters[analyzer].begin(); - it_r != m_mapAnalyzerReporters[analyzer].end(); + vector_actions_and_reporters_t::iterator it_r; + for (it_r = m_mapAnalyzerActionsAndReporters[analyzer].begin(); + it_r != m_mapAnalyzerActionsAndReporters[analyzer].end(); it_r++) { try { CReporter* reporter = m_pPluginManager->GetReporter((*it_r).first); - reporter->Report(pCrashReport, (*it_r).second); + if (reporter) + { + reporter->Report(pCrashReport, (*it_r).second); + } + else + { + throw CABRTException(EXCEP_ERROR, "Plugin '"+(*it_r).first+"' is not registered."); + } } catch (CABRTException& e) { @@ -311,6 +352,7 @@ int CMiddleWare::SavePackageDescriptionToDebugDump(const std::string& pExecutabl if (packageName == "" || (m_setBlackList.find(packageName) != m_setBlackList.end())) { + comm_layer_inner_debug("Blacklisted package - deleting debug dump..."); DeleteDebugDumpDir(pDebugDumpDir); return 0; } @@ -319,6 +361,7 @@ int CMiddleWare::SavePackageDescriptionToDebugDump(const std::string& pExecutabl if (!m_RPM.CheckFingerprint(packageName) || !m_RPM.CheckHash(packageName, pExecutable)) { + comm_layer_inner_debug("Can not find package - deleting debug dump..."); DeleteDebugDumpDir(pDebugDumpDir); return 0; } @@ -338,17 +381,24 @@ int CMiddleWare::SavePackageDescriptionToDebugDump(const std::string& pExecutabl void CMiddleWare::RunAnalyzerActions(const std::string& pAnalyzer, const std::string& pDebugDumpDir) { - if (m_mapAnalyzerActions.find(pAnalyzer) != m_mapAnalyzerActions.end()) + if (m_mapAnalyzerActionsAndReporters.find(pAnalyzer) != m_mapAnalyzerActionsAndReporters.end()) { - set_pairt_strings_t::iterator it_a; - for (it_a = m_mapAnalyzerActions[pAnalyzer].begin(); - it_a != m_mapAnalyzerActions[pAnalyzer].end(); + vector_actions_and_reporters_t::iterator it_a; + for (it_a = m_mapAnalyzerActionsAndReporters[pAnalyzer].begin(); + it_a != m_mapAnalyzerActionsAndReporters[pAnalyzer].end(); it_a++) { try { CAction* action = m_pPluginManager->GetAction((*it_a).first); - action->Run(pDebugDumpDir, (*it_a).second); + if (action) + { + 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) { @@ -374,6 +424,7 @@ int CMiddleWare::SaveDebugDumpToDatabase(const std::string& pUUID, database->DisConnect(); if (row.m_sReported == "1") { + comm_layer_inner_debug("Crash is already reported - deleting debug dump..."); DeleteDebugDumpDir(pDebugDumpDir); return 0; } @@ -381,6 +432,7 @@ int CMiddleWare::SaveDebugDumpToDatabase(const std::string& pUUID, pCrashInfo = GetCrashInfo(pUUID, pUID); if (row.m_sCount != "1") { + comm_layer_inner_debug("Crash is in database already - deleting debug dump..."); DeleteDebugDumpDir(pDebugDumpDir); return 2; } @@ -522,22 +574,15 @@ void CMiddleWare::AddBlackListedPackage(const std::string& pPackage) m_setBlackList.insert(pPackage); } -void CMiddleWare::AddAnalyzerReporter(const std::string& pAnalyzer, - const std::string& pReporter, - const std::string& pArgs) -{ - m_mapAnalyzerReporters[pAnalyzer].insert(make_pair(pReporter, pArgs)); -} - -void CMiddleWare::AddAnalyzerAction(const std::string& pAnalyzer, - const std::string& pAction, - const std::string& pArgs) +void CMiddleWare::AddAnalyzerActionOrReporter(const std::string& pAnalyzer, + const std::string& pAnalyzerOrReporter, + const std::string& pArgs) { - m_mapAnalyzerActions[pAnalyzer].insert(make_pair(pAction, pArgs)); + m_mapAnalyzerActionsAndReporters[pAnalyzer].push_back(make_pair(pAnalyzerOrReporter, pArgs)); } -void CMiddleWare::AddReporter(const std::string& pReporter, - const std::string& pArgs) +void CMiddleWare::AddActionOrReporter(const std::string& pActionOrReporter, + const std::string& pArgs) { - m_setReporters.insert(make_pair(pReporter, pArgs)); + m_vectorActionsAndReporters.push_back(make_pair(pActionOrReporter, pArgs)); } diff --git a/lib/MiddleWare/MiddleWare.h b/lib/MiddleWare/MiddleWare.h index c3b47a4..cad737a 100644 --- a/lib/MiddleWare/MiddleWare.h +++ b/lib/MiddleWare/MiddleWare.h @@ -35,18 +35,16 @@ class CMiddleWare typedef set_strings_t set_blacklist_t; typedef set_strings_t set_enabled_plugins_t; - typedef std::set<pair_string_string_t> set_pairt_strings_t; - typedef std::map<std::string, set_pairt_strings_t> map_reporter_associations_t; - typedef std::map<std::string, set_pairt_strings_t> map_action_associations_t; - typedef set_pairt_strings_t set_reporters_t; + typedef std::vector<pair_string_string_t> vector_pairt_strings_t; + typedef vector_pairt_strings_t vector_actions_and_reporters_t; + typedef std::map<std::string, vector_actions_and_reporters_t> map_analyzer_actions_and_reporters_t; CPluginManager* m_pPluginManager; CRPM m_RPM; set_blacklist_t m_setBlackList; std::string m_sDatabase; - map_reporter_associations_t m_mapAnalyzerReporters; - map_action_associations_t m_mapAnalyzerActions; - set_reporters_t m_setReporters; + map_analyzer_actions_and_reporters_t m_mapAnalyzerActionsAndReporters; + vector_actions_and_reporters_t m_vectorActionsAndReporters; bool m_bOpenGPGCheck; @@ -83,7 +81,11 @@ class CMiddleWare const std::string& pUID, map_crash_report_t& pCrashReport); - void Report(const std::string& pDebugDumpDir); + void RunAction(const std::string& pActionDir, + const std::string& pPluginName, + const std::string& pPluginArgs); + void RunActionsAndReporters(const std::string& pDebugDumpDir); + void Report(const map_crash_report_t& pCrashReport); void DeleteDebugDumpDir(const std::string& pDebugDumpDir); void DeleteCrashInfo(const std::string& pUUID, @@ -100,14 +102,11 @@ class CMiddleWare void SetDatabase(const std::string& pDatabase); void AddOpenGPGPublicKey(const std::string& pKey); void AddBlackListedPackage(const std::string& pPackage); - void AddAnalyzerReporter(const std::string& pAnalyzer, - const std::string& pReporter, + void AddAnalyzerActionOrReporter(const std::string& pAnalyzer, + const std::string& pActionOrReporter, + const std::string& pArgs); + void AddActionOrReporter(const std::string& pActionOrReporter, const std::string& pArgs); - void AddAnalyzerAction(const std::string& pAnalyzer, - const std::string& pAction, - const std::string& pArgs); - void AddReporter(const std::string& pReporter, - const std::string& pArgs); }; #endif /*MIDDLEWARE_H_*/ |
