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/MiddleWare.cpp | |
| parent | f92d9b70a2cb12451f2df00a5a2f9a47e2b9c5ce (diff) | |
| parent | 6b77cb82cb7b918660435effb0fe356401bfdd55 (diff) | |
| download | abrt-b6bc6d13eed2f346414d731ecb29579a719556f3.tar.gz abrt-b6bc6d13eed2f346414d731ecb29579a719556f3.tar.xz abrt-b6bc6d13eed2f346414d731ecb29579a719556f3.zip | |
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Conflicts:
src/Daemon/Daemon.cpp
Diffstat (limited to 'lib/MiddleWare/MiddleWare.cpp')
| -rw-r--r-- | lib/MiddleWare/MiddleWare.cpp | 111 |
1 files changed, 78 insertions, 33 deletions
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)); } |
