summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Daemon/CrashWatcher.cpp24
-rw-r--r--src/Daemon/CrashWatcher.h2
-rw-r--r--src/Daemon/Daemon.cpp40
-rw-r--r--src/Daemon/MiddleWare.cpp62
-rw-r--r--src/Daemon/MiddleWare.h93
-rw-r--r--src/Daemon/Settings.h2
6 files changed, 113 insertions, 110 deletions
diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp
index 11748f9d..c1d7f50d 100644
--- a/src/Daemon/CrashWatcher.cpp
+++ b/src/Daemon/CrashWatcher.cpp
@@ -64,21 +64,21 @@ vector_crash_infos_t CCrashWatcher::GetCrashInfos(const std::string &pUID)
unsigned int ii;
for (ii = 0; ii < UUIDsUIDs.size(); ii++)
{
- CMiddleWare::mw_result_t res;
+ mw_result_t res;
map_crash_info_t info;
res = g_pMW->GetCrashInfo(UUIDsUIDs[ii].first, UUIDsUIDs[ii].second, info);
switch (res)
{
- case CMiddleWare::MW_OK:
+ case MW_OK:
retval.push_back(info);
break;
- case CMiddleWare::MW_ERROR:
+ case MW_ERROR:
Warning("Can not find debug dump directory for UUID: " + UUIDsUIDs[ii].first + ", deleting from database");
Status("Can not find debug dump directory for UUID: " + UUIDsUIDs[ii].first + ", deleting from database");
g_pMW->DeleteCrashInfo(UUIDsUIDs[ii].first, UUIDsUIDs[ii].second);
break;
- case CMiddleWare::MW_FILE_ERROR:
+ case MW_FILE_ERROR:
{
std::string debugDumpDir;
Warning("Can not open file in debug dump directory for UUID: " + UUIDsUIDs[ii].first + ", deleting ");
@@ -120,20 +120,20 @@ static void *create_report(void *arg)
g_cw->Debug("Creating report...");
try
{
- CMiddleWare::mw_result_t res;
+ mw_result_t res;
res = g_pMW->CreateCrashReport(thread_data->UUID, thread_data->UID, crashReport);
switch (res)
{
- case CMiddleWare::MW_OK:
+ case MW_OK:
break;
- case CMiddleWare::MW_IN_DB_ERROR:
+ case MW_IN_DB_ERROR:
g_cw->Warning(std::string("Did not find crash with UUID ")+thread_data->UUID+ " in database.");
break;
- case CMiddleWare::MW_PLUGIN_ERROR:
+ case MW_PLUGIN_ERROR:
g_cw->Warning(std::string("Particular analyzer plugin isn't loaded or there is an error within plugin(s)."));
break;
- case CMiddleWare::MW_CORRUPTED:
- case CMiddleWare::MW_FILE_ERROR:
+ case MW_CORRUPTED:
+ case MW_FILE_ERROR:
default:
{
std::string debugDumpDir;
@@ -192,7 +192,7 @@ uint64_t CCrashWatcher::CreateReport_t(const std::string &pUUID,const std::strin
return 0;
}
-CMiddleWare::report_status_t CCrashWatcher::Report(map_crash_report_t pReport, const std::string& pUID)
+report_status_t CCrashWatcher::Report(map_crash_report_t pReport, const std::string& pUID)
{
//#define FIELD(X) crashReport.m_s##X = pReport[#X];
//crashReport.m_sUUID = pReport["UUID"];
@@ -201,7 +201,7 @@ CMiddleWare::report_status_t CCrashWatcher::Report(map_crash_report_t pReport, c
//for (dbus_map_report_info_t::iterator it = pReport.begin(); it!=pReport.end(); ++it) {
// std::cerr << it->second << std::endl;
//}
- CMiddleWare::report_status_t rs;
+ report_status_t rs;
try
{
rs = g_pMW->Report(pReport, pUID);
diff --git a/src/Daemon/CrashWatcher.h b/src/Daemon/CrashWatcher.h
index a8f0381a..104532ad 100644
--- a/src/Daemon/CrashWatcher.h
+++ b/src/Daemon/CrashWatcher.h
@@ -64,7 +64,7 @@ class CCrashWatcher
return retval;
}
uint64_t CreateReport_t(const std::string &pUUID,const std::string &pUID, const std::string &pSender);
- virtual CMiddleWare::report_status_t Report(map_crash_report_t pReport, const std::string &pUID);
+ virtual report_status_t Report(map_crash_report_t pReport, const std::string &pUID);
virtual bool DeleteDebugDump(const std::string& pUUID, const std::string& pUID);
virtual map_crash_report_t GetJobResult(uint64_t pJobID, const std::string& pSender);
/* plugins related */
diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp
index cb9e7dd4..9021c9c7 100644
--- a/src/Daemon/Daemon.cpp
+++ b/src/Daemon/Daemon.cpp
@@ -319,24 +319,24 @@ static void FindNewDumps(const std::string& pPath)
map_crash_info_t crashinfo;
try
{
- CMiddleWare::mw_result_t res;
+ mw_result_t res;
res = g_pMW->SaveDebugDump(*itt, crashinfo);
switch (res)
{
- case CMiddleWare::MW_OK:
+ case MW_OK:
g_cw->Debug("Saving into database (" + *itt + ").");
g_pMW->RunActionsAndReporters(crashinfo[CD_MWDDD][CD_CONTENT]);
break;
- case CMiddleWare::MW_IN_DB:
+ case MW_IN_DB:
g_cw->Debug("Already saved in database (" + *itt + ").");
break;
- case CMiddleWare::MW_REPORTED:
- case CMiddleWare::MW_OCCURED:
- case CMiddleWare::MW_BLACKLISTED:
- case CMiddleWare::MW_CORRUPTED:
- case CMiddleWare::MW_PACKAGE_ERROR:
- case CMiddleWare::MW_GPG_ERROR:
- case CMiddleWare::MW_FILE_ERROR:
+ case MW_REPORTED:
+ case MW_OCCURED:
+ case MW_BLACKLISTED:
+ case MW_CORRUPTED:
+ case MW_PACKAGE_ERROR:
+ case MW_GPG_ERROR:
+ case MW_FILE_ERROR:
default:
g_cw->Warning("Corrupted, bad or already saved crash, deleting.");
g_pMW->DeleteDebugDumpDir(*itt);
@@ -471,29 +471,29 @@ static gboolean handle_event_cb(GIOChannel *gio, GIOCondition condition, gpointe
map_crash_info_t crashinfo;
try
{
- CMiddleWare::mw_result_t res;
+ mw_result_t res;
res = g_pMW->SaveDebugDump(std::string(DEBUG_DUMPS_DIR) + "/" + name, crashinfo);
switch (res)
{
- case CMiddleWare::MW_OK:
+ case MW_OK:
g_cw->Debug("New crash, saving...");
g_pMW->RunActionsAndReporters(crashinfo[CD_MWDDD][CD_CONTENT]);
/* send message to dbus */
g_pCommLayer->Crash(crashinfo[CD_PACKAGE][CD_CONTENT]);
break;
- case CMiddleWare::MW_REPORTED:
- case CMiddleWare::MW_OCCURED:
+ case MW_REPORTED:
+ case MW_OCCURED:
/* send message to dbus */
g_cw->Debug("Already saved crash, deleting...");
g_pCommLayer->Crash(crashinfo[CD_PACKAGE][CD_CONTENT]);
g_pMW->DeleteDebugDumpDir(std::string(DEBUG_DUMPS_DIR) + "/" + name);
break;
- case CMiddleWare::MW_BLACKLISTED:
- case CMiddleWare::MW_CORRUPTED:
- case CMiddleWare::MW_PACKAGE_ERROR:
- case CMiddleWare::MW_GPG_ERROR:
- case CMiddleWare::MW_IN_DB:
- case CMiddleWare::MW_FILE_ERROR:
+ case MW_BLACKLISTED:
+ case MW_CORRUPTED:
+ case MW_PACKAGE_ERROR:
+ case MW_GPG_ERROR:
+ case MW_IN_DB:
+ case MW_FILE_ERROR:
default:
g_cw->Warning("Corrupted or bad crash, deleting...");
g_pMW->DeleteDebugDumpDir(std::string(DEBUG_DUMPS_DIR) + "/" + name);
diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp
index 9107b808..54ed2917 100644
--- a/src/Daemon/MiddleWare.cpp
+++ b/src/Daemon/MiddleWare.cpp
@@ -25,12 +25,52 @@
#include "ABRTException.h"
#include "CommLayerInner.h"
+
+/**
+ * An instance of CPluginManager. When MiddleWare wants to do something
+ * with plugins, it calls the plugin manager.
+ * @see PluginManager.h
+ */
+static CPluginManager* m_pPluginManager;
+/**
+ * An instance of CRPM used for package checking.
+ * @see RPM.h
+ */
+static CRPM m_RPM;
+/**
+ * A set of blacklisted packages.
+ */
+static set_strings_t m_setBlackList;
+/**
+ * A name of database plugin, which is used for metadata.
+ */
+static std::string m_sDatabase;
+/**
+ * A map, which associates particular analyzer to one or more
+ * action or reporter plugins. These are activated when a crash, which
+ * is maintained by particular analyzer, occurs.
+ */
+static map_analyzer_actions_and_reporters_t m_mapAnalyzerActionsAndReporters;
+/**
+ * A vector of one or more action or reporter plugins. These are
+ * activated when any crash occurs.
+ */
+static vector_pair_string_string_t m_vectorActionsAndReporters;
+/**
+ * Plugins configuration directory (e.g. /etc/abrt/plugins, ...).
+ */
+static std::string m_sPluginsConfDir;
+/**
+ * Check GPG finger print?
+ */
+static bool m_bOpenGPGCheck;
+
+
CMiddleWare::CMiddleWare(const std::string& pPluginsConfDir,
- const std::string& pPluginsLibDir) :
- m_pPluginManager(NULL),
- m_sPluginsConfDir(pPluginsConfDir),
- m_bOpenGPGCheck(true)
+ const std::string& pPluginsLibDir)
{
+ m_sPluginsConfDir = pPluginsConfDir;
+ m_bOpenGPGCheck = true;
m_pPluginManager = new CPluginManager(pPluginsConfDir, pPluginsLibDir);
m_pPluginManager->LoadPlugins();
}
@@ -145,7 +185,7 @@ void CMiddleWare::CreateReport(const std::string& pAnalyzer,
analyzer->CreateReport(pDebugDumpDir);
}
-CMiddleWare::mw_result_t CMiddleWare::CreateCrashReport(const std::string& pUUID,
+mw_result_t CMiddleWare::CreateCrashReport(const std::string& pUUID,
const std::string& pUID,
map_crash_report_t& pCrashReport)
{
@@ -253,7 +293,7 @@ void CMiddleWare::RunActionsAndReporters(const std::string& pDebugDumpDir)
}
}
-CMiddleWare::report_status_t CMiddleWare::Report(const map_crash_report_t& pCrashReport,
+report_status_t CMiddleWare::Report(const map_crash_report_t& pCrashReport,
const std::string& pUID)
{
report_status_t ret;
@@ -394,7 +434,7 @@ bool CMiddleWare::IsDebugDumpSaved(const std::string& pUID,
return found;
}
-CMiddleWare::mw_result_t CMiddleWare::SavePackageDescriptionToDebugDump(const std::string& pExecutable,
+mw_result_t CMiddleWare::SavePackageDescriptionToDebugDump(const std::string& pExecutable,
const std::string& pDebugDumpDir)
{
std::string package;
@@ -487,7 +527,7 @@ void CMiddleWare::RunAnalyzerActions(const std::string& pAnalyzer, const std::st
}
}
-CMiddleWare::mw_result_t CMiddleWare::SaveDebugDumpToDatabase(const std::string& pUUID,
+mw_result_t CMiddleWare::SaveDebugDumpToDatabase(const std::string& pUUID,
const std::string& pUID,
const std::string& pTime,
const std::string& pDebugDumpDir,
@@ -514,13 +554,13 @@ CMiddleWare::mw_result_t CMiddleWare::SaveDebugDumpToDatabase(const std::string&
return res;
}
-CMiddleWare::mw_result_t CMiddleWare::SaveDebugDump(const std::string& pDebugDumpDir)
+mw_result_t CMiddleWare::SaveDebugDump(const std::string& pDebugDumpDir)
{
map_crash_info_t info;
return SaveDebugDump(pDebugDumpDir, info);
}
-CMiddleWare::mw_result_t CMiddleWare::SaveDebugDump(const std::string& pDebugDumpDir,
+mw_result_t CMiddleWare::SaveDebugDump(const std::string& pDebugDumpDir,
map_crash_info_t& pCrashInfo)
{
std::string lUUID;
@@ -565,7 +605,7 @@ CMiddleWare::mw_result_t CMiddleWare::SaveDebugDump(const std::string& pDebugDum
return SaveDebugDumpToDatabase(lUUID, UID, time, pDebugDumpDir, pCrashInfo);
}
-CMiddleWare::mw_result_t CMiddleWare::GetCrashInfo(const std::string& pUUID,
+mw_result_t CMiddleWare::GetCrashInfo(const std::string& pUUID,
const std::string& pUID,
map_crash_info_t& pCrashInfo)
{
diff --git a/src/Daemon/MiddleWare.h b/src/Daemon/MiddleWare.h
index 04541e99..cfbf6683 100644
--- a/src/Daemon/MiddleWare.h
+++ b/src/Daemon/MiddleWare.h
@@ -30,78 +30,39 @@
#include "RPM.h"
/**
+ * An enum contains all return codes.
+ */
+typedef enum {
+ MW_ERROR, /**< Common error.*/
+ MW_OK, /**< No error.*/
+ MW_BLACKLISTED, /**< Package is blacklisted.*/
+ MW_CORRUPTED, /**< Debugdump directory is corrupted.*/
+ MW_PACKAGE_ERROR, /**< Cannot determine package name.*/
+ MW_GPG_ERROR, /**< Package is not signed properly.*/
+ MW_REPORTED, /**< Crash is already reported.*/
+ MW_OCCURED, /**< Crash occurred in the past, but it is not reported yet.*/
+ MW_IN_DB, /**< Debugdump directory is already saved in a database.*/
+ MW_IN_DB_ERROR, /**< Error while working with a database.*/
+ MW_PLUGIN_ERROR, /**< plugin wasn't found or error within plugin*/
+ MW_FILE_ERROR /**< Error when trying open debugdump directory or
+ when trying open file in debug dump directory..*/
+} mw_result_t;
+
+typedef enum {
+ RS_CODE,
+ RS_MESSAGE
+} report_status_items_t;
+
+typedef std::map<std::string, vector_strings_t> report_status_t;
+typedef std::map<std::string, vector_pair_string_string_t> map_analyzer_actions_and_reporters_t;
+
+/**
* A very important class :-). It manages part of user demands like creating
* reports, or reporting stuff somewhere etc.
*/
class CMiddleWare
{
- public:
- /**
- * An enum contains all return codes.
- */
- typedef enum {
- MW_ERROR, /**< Common error.*/
- MW_OK, /**< No error.*/
- MW_BLACKLISTED, /**< Package is blacklisted.*/
- MW_CORRUPTED, /**< Debugdump directory is corrupted.*/
- MW_PACKAGE_ERROR, /**< Cannot determine package name.*/
- MW_GPG_ERROR, /**< Package is not signed properly.*/
- MW_REPORTED, /**< Crash is already reported.*/
- MW_OCCURED, /**< Crash occurred in the past, but it is not reported yet.*/
- MW_IN_DB, /**< Debugdump directory is already saved in a database.*/
- MW_IN_DB_ERROR, /**< Error while working with a database.*/
- MW_PLUGIN_ERROR, /**< plugin wasn't found or error within plugin*/
- MW_FILE_ERROR /**< Error when trying open debugdump directory or
- when trying open file in debug dump directory..*/
- } mw_result_t;
-
- typedef std::map<std::string, vector_strings_t> report_status_t;
- typedef enum {
- RS_CODE,
- RS_MESSAGE
- } report_status_items_t;
-
private:
- typedef std::map<std::string, vector_pair_string_string_t> map_analyzer_actions_and_reporters_t;
-
- /**
- * An instance of CPluginManager. When MiddleWare wants to do something
- * with plugins, it calls the plugin manager.
- * @see PluginManager.h
- */
- CPluginManager* m_pPluginManager;
- /**
- * An instance of CRPM used for package checking.
- * @see RPM.h
- */
- CRPM m_RPM;
- /**
- * A set of blacklisted packages.
- */
- set_strings_t m_setBlackList;
- /**
- * A name of database plugin, which is used for metadata.
- */
- std::string m_sDatabase;
- /**
- * A map, which associates particular analyzer to one or more
- * action or reporter plugins. These are activated when a crash, which
- * is maintained by particular analyzer, occurs.
- */
- map_analyzer_actions_and_reporters_t m_mapAnalyzerActionsAndReporters;
- /**
- * A vector of one or more action or reporter plugins. These are
- * activated when any crash occurs.
- */
- vector_pair_string_string_t m_vectorActionsAndReporters;
- /**
- * Plugins configuration directory (e.g. /etc/abrt/plugins, ...).
- */
- std::string m_sPluginsConfDir;
- /**
- * Check GPG finger print?
- */
- bool m_bOpenGPGCheck;
/**
* A method, which gets a local UUID from particular analyzer plugin.
* @param pAnalyzer A name of an analyzer plugin.
diff --git a/src/Daemon/Settings.h b/src/Daemon/Settings.h
index d4e54f50..1bb264c1 100644
--- a/src/Daemon/Settings.h
+++ b/src/Daemon/Settings.h
@@ -6,6 +6,8 @@
#include <set>
#include <vector>
+#include "MiddleWareTypes.h"
+
class CSettings
{
public: