summaryrefslogtreecommitdiffstats
path: root/lib/MiddleWare
diff options
context:
space:
mode:
authorZdenek Prikryl <zprikryl@redhat.com>2009-06-29 10:59:01 +0200
committerZdenek Prikryl <zprikryl@redhat.com>2009-06-29 10:59:01 +0200
commit7171080b4efbc279408047a7a2bf49fec3866456 (patch)
tree685ae2fdfc22557723d9c86a49e0d5bd3a92972a /lib/MiddleWare
parent0f60b164457d0f0aa7f540c94625feaed4f9e3ce (diff)
downloadabrt-7171080b4efbc279408047a7a2bf49fec3866456.tar.gz
abrt-7171080b4efbc279408047a7a2bf49fec3866456.tar.xz
abrt-7171080b4efbc279408047a7a2bf49fec3866456.zip
added comments
Diffstat (limited to 'lib/MiddleWare')
-rw-r--r--lib/MiddleWare/ABRTPlugin.h59
-rw-r--r--lib/MiddleWare/Action.h15
-rw-r--r--lib/MiddleWare/Analyzer.h23
-rw-r--r--lib/MiddleWare/Database.h76
-rw-r--r--lib/MiddleWare/DynamicLibrary.h25
-rw-r--r--lib/MiddleWare/MiddleWare.h248
-rw-r--r--lib/MiddleWare/MiddleWareTypes.h1
-rw-r--r--lib/MiddleWare/Plugin.h46
-rw-r--r--lib/MiddleWare/PluginManager.h79
-rw-r--r--lib/MiddleWare/RPM.h45
-rw-r--r--lib/MiddleWare/Reporter.h13
11 files changed, 566 insertions, 64 deletions
diff --git a/lib/MiddleWare/ABRTPlugin.h b/lib/MiddleWare/ABRTPlugin.h
index 0bf078b..e585f2a 100644
--- a/lib/MiddleWare/ABRTPlugin.h
+++ b/lib/MiddleWare/ABRTPlugin.h
@@ -1,6 +1,5 @@
/*
- ABRTPlugin.h - header file for abrt plugin. It takes care
- of reporting thinks which has loaded plugin.
+ ABRTPlugin.h - header file for abrt plugin.
Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
Copyright (C) 2009 RedHat inc.
@@ -28,6 +27,9 @@
#include "DynamicLibrary.h"
#include "Plugin.h"
+/**
+ * CABRTPlugin class. A class which contains a loaded plugin.
+ */
class CABRTPlugin
{
private:
@@ -35,22 +37,71 @@ class CABRTPlugin
typedef const plugin_info_t* p_plugin_info_t;
typedef CPlugin* (*p_fn_plugin_new_t)();
+ /**
+ * A class containing library which contains plugin functionality.
+ * @see DynamicLibrary.h
+ */
CDynamicLibrary* m_pDynamicLibrary;
+ /**
+ * A pointer to struc containing information about plugin.
+ */
p_plugin_info_t m_pPluginInfo;
+ /**
+ * A pointer to function, which creates new instances of plugin.
+ */
p_fn_plugin_new_t m_pFnPluginNew;
public:
+ /**
+ * A constructor.
+ * The constructor loads a plugin
+ * @param pLibPath a path to a plugin
+ */
CABRTPlugin(const std::string& pLibPath);
+ /**
+ * A destructor.
+ */
~CABRTPlugin();
-
+ /**
+ * It is used for getting loaded plugin's version.
+ * @return plugin version
+ */
const std::string& GetVersion();
+ /**
+ * It is used for getting loaded plugin's magic number.
+ * @return magic number
+ */
const int GetMagicNumber();
+ /**
+ * It is used for getting loaded plugin's name.
+ * @return magic number
+ */
const std::string& GetName();
+ /**
+ * It is used for getting loaded plugin's description.
+ * @return magic number
+ */
const std::string& GetDescription();
+ /**
+ * It is used for getting an author email of loaded plugin.
+ * @return description
+ */
const std::string& GetEmail();
+ /**
+ * It is used for getting a home page of loaded plugin.
+ * @return home page
+ */
const std::string& GetWWW();
+ /**
+ * It is used for getting loaded plugin's type.
+ * @return type
+ */
const plugin_type_t GetType();
-
+ /**
+ * It is used fot getting of a new instance of loaded plugin
+ * @return pointer to new allocated instance of plugin. A caller
+ * has to delete it.
+ */
CPlugin* PluginNew();
};
diff --git a/lib/MiddleWare/Action.h b/lib/MiddleWare/Action.h
index 96461f3..c468984 100644
--- a/lib/MiddleWare/Action.h
+++ b/lib/MiddleWare/Action.h
@@ -25,10 +25,25 @@
#include <string>
#include "Plugin.h"
+/**
+ * An abstract class. The class defines an action plugin interface.
+ */
class CAction : public CPlugin
{
public:
+ /**
+ * A destructor.
+ */
virtual ~CAction() {}
+ /**
+ * A Method which performs particular action. As the first parameter it
+ * takes an action directory. It could be either a directory of actual
+ * crash or it could be a directory contains all crashes. It depends on
+ * who call the plugin. The plugin can takes arguments, but the plugin
+ * has to parse them by itself.
+ * @param pActionDir An actual directory.
+ * @param pArgs Plugin's arguments.
+ */
virtual void Run(const std::string& pActionDir,
const std::string& pArgs) = 0;
};
diff --git a/lib/MiddleWare/Analyzer.h b/lib/MiddleWare/Analyzer.h
index dda976f..61e5018 100644
--- a/lib/MiddleWare/Analyzer.h
+++ b/lib/MiddleWare/Analyzer.h
@@ -25,12 +25,35 @@
#include <string>
#include "Plugin.h"
+/**
+ * An abstract class. The class defines an analyzer plugin interface.
+ */
class CAnalyzer : public CPlugin
{
public:
+ /**
+ * A destructor.
+ */
virtual ~CAnalyzer() {}
+ /**
+ * A method, which gets a local UUID of particular crash. The local
+ * UUID is usualy computed from data which are stored in debugdump dir.
+ * @param pDebugDumpPath A debugdump dir containing all necessary data.
+ * @return A local UUID.
+ */
virtual std::string GetLocalUUID(const std::string& pDebugDumpPath) = 0;
+ /**
+ * A method, which gets a global UUID of particular crash.
+ * @param pDebugDumpPath A debugdump dir containing all necessary data.
+ * @return A global UUID.
+ */
virtual std::string GetGlobalUUID(const std::string& pDebugDumpPath) = 0;
+ /**
+ * A method, which takes care of getting all additional data needed
+ * for computing UUIDs and creating a report. This report could be send
+ * somewhere afterwards.
+ * @param pDebugDumpPath A debugdump dir containing all necessary data.
+ */
virtual void CreateReport(const std::string& pDebugDumpPath) = 0;
};
diff --git a/lib/MiddleWare/Database.h b/lib/MiddleWare/Database.h
index b634a70..b4affe9 100644
--- a/lib/MiddleWare/Database.h
+++ b/lib/MiddleWare/Database.h
@@ -27,7 +27,7 @@
#include <vector>
#include "Plugin.h"
-/*
+/**
* Table
* =====
* UUID | UID| DebugDumpPath | Count | Reported
@@ -42,36 +42,84 @@
#define DATABASE_COLUMN_REPORTED "Reported"
#define DATABASE_COLUMN_TIME "Time"
+/**
+ * A struct contains one database row.
+ */
typedef struct SDatabaseRow
{
- std::string m_sUUID;
- std::string m_sUID;
- std::string m_sDebugDumpDir;
- std::string m_sCount;
- std::string m_sReported;
- std::string m_sTime;
+ std::string m_sUUID; /**< A local UUID.*/
+ std::string m_sUID; /**< An UID of an user.*/
+ std::string m_sDebugDumpDir; /**< A debugdump directory of a crash.*/
+ std::string m_sCount; /**< Crash rate.*/
+ std::string m_sReported; /**< Is a row reported?*/
+ std::string m_sTime; /**< Time of last occurred crash with same local UUID*/
} database_row_t;
-// <column_name, <array of values in all selected rows> >
+/**
+ * A vector contains one or more database rows.
+ */
typedef std::vector<database_row_t> vector_database_rows_t;
+/**
+ * An abstract class. The class defines a database plugin interface.
+ */
class CDatabase : public CPlugin
{
public:
+ /**
+ * A destructor.
+ */
virtual ~CDatabase() {}
-
+ /**
+ * A method, which connects to a database.
+ */
virtual void Connect() = 0;
+ /**
+ * A method, which disconnects from a database.
+ */
virtual void DisConnect() = 0;
+ /**
+ * A method, which inserts one row to a database.
+ * @param pUUID A local UUID of a crash.
+ * @param pUID An UID of an user.
+ * @param pDebugDumpPath A debugdump path.
+ * @param pTime Time when a crash occurs.
+ */
virtual void Insert(const std::string& pUUID,
const std::string& pUID,
const std::string& pDebugDumpPath,
const std::string& pTime) = 0;
-
- virtual void Delete(const std::string& pUUID, const std::string& pUID) = 0;
-
- virtual void SetReported(const std::string& pUUID, const std::string& pUID) = 0;
+ /**
+ * A method, which deletes one row in a database.
+ * @param pUUID A lodal UUID of a crash.
+ * @param pUID An UID of an user.
+ */
+ virtual void Delete(const std::string& pUUID,
+ const std::string& pUID) = 0;
+ /**
+ * A method, which sets that particular row was reported.
+ * @param pUUID A local UUID of a crash.
+ * @param pUID An UID of an user.
+ */
+ virtual void SetReported(const std::string& pUUID,
+ const std::string& pUID) = 0;
+ /**
+ * A method, which gets all rows which belongs to particular user.
+ * If the user is root, then all rows are returned. If there are no
+ * rows, empty vector is returned.
+ * @param pUID An UID of an user.
+ * @return A vector of matched rows.
+ */
virtual const vector_database_rows_t GetUIDData(const std::string& pUID) = 0;
- virtual const database_row_t GetUUIDData(const std::string& pUUID, const std::string& pUID) = 0;
+ /**
+ * A method, which returns one row accordind to UUID of a crash and
+ * UID of an user. If there are no row, empty row is returned.
+ * @param pUUID A UUID of a crash.
+ * @param pUID An UID of an user.
+ * @return A matched row.
+ */
+ virtual const database_row_t GetUUIDData(const std::string& pUUID,
+ const std::string& pUID) = 0;
};
#endif /* DATABASE_H_ */
diff --git a/lib/MiddleWare/DynamicLibrary.h b/lib/MiddleWare/DynamicLibrary.h
index 4cf36f6..f3a95f5 100644
--- a/lib/MiddleWare/DynamicLibrary.h
+++ b/lib/MiddleWare/DynamicLibrary.h
@@ -25,16 +25,37 @@
#include <string>
+/**
+ * A class. It contains one dynamic library.
+ */
class CDynamicLibrary
{
private:
+ /**
+ * A pointer to library.
+ */
void* m_pHandle;
-
+ /**
+ * A method, which loads a library.
+ * @param pPath A path to the library.
+ */
void Load(const std::string& pPath);
public:
+ /**
+ * A constructor.
+ * @param pPath A path to the library.
+ */
CDynamicLibrary(const std::string& pPath);
+ /**
+ * A destructor.
+ */
~CDynamicLibrary();
-
+ /**
+ * A method, which tries to find a symbol in a library. If it successes
+ * then a non-NULL pointer is returned, otherwise NULL is returned.
+ * @param pName A symbol name.
+ * @return A pointer where a symbol name is loaded.
+ */
void* FindSymbol(const std::string& pName);
};
diff --git a/lib/MiddleWare/MiddleWare.h b/lib/MiddleWare/MiddleWare.h
index f817f00..d0bc9f7 100644
--- a/lib/MiddleWare/MiddleWare.h
+++ b/lib/MiddleWare/MiddleWare.h
@@ -29,53 +29,146 @@
#include "MiddleWareTypes.h"
#include "RPM.h"
+/**
+ * A very important class :-). It manages part of user demands like creating
+ * reports, or reporting stuff somewhere etc.
+ */
class CMiddleWare
{
public:
-
- typedef enum { MW_ERROR,
- MW_OK,
- MW_BLACKLISTED,
- MW_CORRUPTED,
- MW_PACKAGE_ERROR,
- MW_GPG_ERROR,
- MW_REPORTED,
- MW_OCCURED,
- MW_IN_DB,
- MW_IN_DB_ERROR,
- MW_FILE_ERROR } mw_result_t;
+ /**
+ * An emun 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_FILE_ERROR /**< Error when trying open debugdump directory or
+ when trying open file in debug dump directory..*/
+ } mw_result_t;
private:
typedef set_strings_t set_blacklist_t;
typedef set_strings_t set_enabled_plugins_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;
+ /**
+ * 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_blacklist_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_actions_and_reporters_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.
+ * @param pDebugDumpDir A debugdump dir containing all necessary data.
+ * @return A local UUID.
+ */
std::string GetLocalUUID(const std::string& pAnalyzer,
const std::string& pDebugDumpDir);
+ /**
+ * A method, which gets a global UUID from particular analyzer plugin.
+ * @param pAnalyzer A name of an analyzer plugin.
+ * @param pDebugDumpDir A debugdump dir containing all necessary data.
+ * @return A global UUID.
+ */
std::string GetGlobalUUID(const std::string& pAnalyzer,
const std::string& pDebugDumpDir);
+ /**
+ * A method, which takes care of getting all additional data needed
+ * for computing UUIDs and creating a report for particular analyzer
+ * plugin. This report could be send somewhere afterwards.
+ * @param pAnalyzer A name of an analyzer plugin.
+ * @param pDebugDumpPath A debugdump dir containing all necessary data.
+ */
void CreateReport(const std::string& pAnalyzer,
- const std::string& pDebugDumpDir);
+ const std::string& pDebugDumpDir);
+ /**
+ * A method, which executes all action plugins, which are associated to
+ * particular analyzer plugin.
+ * @param pAnalyzer A name of an analyzer plugin.
+ * @param pDebugDumpPath A debugdump dir containing all necessary data.
+ */
void RunAnalyzerActions(const std::string& pAnalyzer,
const std::string& pDebugDumpDir);
+ /**
+ * A method, which transforms a debugdump direcortry to inner crash
+ * report form. This form is used for later reporting.
+ * @param pDebugDumpDir A debugdump dir containing all necessary data.
+ * @param pCrashReport A created crash report.
+ */
void DebugDumpToCrashReport(const std::string& pDebugDumpDir,
map_crash_report_t& pCrashReport);
+ /**
+ * A method, which checks is particular debugdump directory is saved
+ * in database. This check is done together with an UID of an user.
+ * @param pUID an UID of an user.
+ * @param pDebugDumpDir A debugdump dir containing all necessary data.
+ * @return It returns true if debugdump dir is already saved, otherwise
+ * it returns false.
+ */
bool IsDebugDumpSaved(const std::string& pUID,
const std::string& pDebugDumpDir);
+ /**
+ * A method, which gets a package name from executable name and saves
+ * package description to particular debugdump directory of a crash.
+ * @param pExecutable A name of crashed application.
+ * @param pDebugDumpDir A debugdump dir containing all necessary data.
+ * @return It return results of operation. See mw_result_t.
+ */
mw_result_t SavePackageDescriptionToDebugDump(const std::string& pExecutable,
const std::string& pDebugDumpDir);
+ /**
+ * A method, which save a debugdump into database. If a saving is
+ * successful, then a crash info is filled. Otherwise the crash info is
+ * not changed.
+ * @param pUUID A local UUID of a crash.
+ * @param pUID An UID of an user.
+ * @param pTime Time when a crash occurs.
+ * @param pDebugDumpPath A debugdump path.
+ * @param pCrashInfo A filled crash info.
+ * @return It return results of operation. See mw_result_t.
+ */
mw_result_t SaveDebugDumpToDatabase(const std::string& pUUID,
const std::string& pUID,
const std::string& pTime,
@@ -83,48 +176,153 @@ class CMiddleWare
map_crash_info_t& pCrashInfo);
public:
-
+ /**
+ * A constructor.
+ * @param pPlugisConfDir A plugins configuration directory.
+ * @param pPlugisLibDir A plugins library directory.
+ */
CMiddleWare(const std::string& pPlugisConfDir,
const std::string& pPlugisLibDir);
-
+ /**
+ * A destructor.
+ */
~CMiddleWare();
-
+ /**
+ * A method, which registers particular plugin.
+ * @param pName A plugin name.
+ */
void RegisterPlugin(const std::string& pName);
+ /**
+ * A method, which unregister particular plugin.
+ * @param pName A plugin name.
+ */
void UnRegisterPlugin(const std::string& pName);
-
+ /**
+ * A method, which takes care of getting all additional data needed
+ * for computing UUIDs and creating a report for particular analyzer
+ * plugin. This report could be send somewhere afterwards. If a creation
+ * is successful, then a crash report is filled.
+ * @param pAnalyzer A name of an analyzer plugin.
+ * @param pDebugDumpPath A debugdump dir containing all necessary data.
+ * @param pCrashReport A filled crash report.
+ * @return It return results of operation. See mw_result_t.
+ */
mw_result_t CreateCrashReport(const std::string& pUUID,
const std::string& pUID,
map_crash_report_t& pCrashReport);
-
+ /**
+ * A method, which activate particular action plugin.
+ * @param pActionDir A directory, which is passed as working to a action plugin.
+ * @param pPluginName An action plugin name.
+ * @param pPluginArgs Action plugin's arguments.
+ */
void RunAction(const std::string& pActionDir,
const std::string& pPluginName,
const std::string& pPluginArgs);
+ /**
+ * A method, which activate all action and reporter plugins when any
+ * crash occurs.
+ * @param pDebugDumpDir A debugdump dir containing all necessary data.
+ */
void RunActionsAndReporters(const std::string& pDebugDumpDir);
-
+ /**
+ * A method, which reports a crash report to particular receiver.
+ * @param pCrashReport A crash report.
+ */
void Report(const map_crash_report_t& pCrashReport);
+ /**
+ * A method, which reports a crash report to particular receiver. It
+ * takes a path where settings of reporter are stored (e.g. $HOME/.abrt,
+ * ...).
+ * @param pCrashReport A crash report.
+ * @param pSettingsPath A path to setting files.
+ */
void Report(const map_crash_report_t& pCrashReport,
const std::string& pSettingsPath);
+ /**
+ * A method, which deletes particular debugdump directory.
+ * @param pDebugDumpDir A debugdump directory.
+ */
void DeleteDebugDumpDir(const std::string& pDebugDumpDir);
+ /**
+ * A method, which delete a row from database. If a deleting is
+ * successfull, it returns a debugdump directort, which is not
+ * deleted. Otherwise, it returns empty string.
+ * @param pUUID A local UUID of a crash.
+ * @param pUID An UID of an user.
+ * @return A debugdump directory.
+ */
std::string DeleteCrashInfo(const std::string& pUUID,
const std::string& pUID);
-
-
+ /**
+ * A method, whis saves debugdump into database.
+ * @param pDebugDumpDir A debugdump directory.
+ * @return It return results of operation. See mw_result_t.
+ */
mw_result_t SaveDebugDump(const std::string& pDebugDumpDir);
+ /**
+ * A method, whis saves debugdump into database. If saving is sucessful
+ * it fills crash info.
+ * @param pDebugDumpDir A debugdump directory.
+ * @param pCrashInfo A crash info.
+ * @return It return results of operation. See mw_result_t.
+ */
mw_result_t SaveDebugDump(const std::string& pDebugDumpDir,
map_crash_info_t& pCrashInfo);
-
+ /**
+ * A method, which gets one crash info. If a getting is successful,
+ * then a crash info is filled.
+ * @param pUUID A local UUID of a crash.
+ * @param pUID An UID of an user.
+ * @param pCrashInfo A crash info.
+ * @return It return results of operation. See mw_result_t.
+ */
mw_result_t GetCrashInfo(const std::string& pUUID,
const std::string& pUID,
map_crash_info_t& pCrashInfo);
- vector_strings_t GetUUIDsOfCrash(const std::string& pUID);
+ /**
+ * A method, which gets all local UUIDs and UIDs of crashes. These crashes
+ * occurred when a particular user was logged in.
+ * @param pUID an UID of an user.
+ * @return A vector of pairs (local UUID, UID).
+ */
+ vector_pair_string_string_t GetUUIDsOfCrash(const std::string& pUID);
+ /**
+ * A method, which set a GPG finger print check.
+ * @param pCheck Is it enabled?
+ */
void SetOpenGPGCheck(const bool& pCheck);
+ /**
+ * A method, which sets a name of database.
+ * @param pDatabase A database name.
+ */
void SetDatabase(const std::string& pDatabase);
+ /**
+ * A method, which adds one path to a GPG public key into MW's set.
+ * @param pKey A path to a GPG public key.
+ */
void AddOpenGPGPublicKey(const std::string& pKey);
+ /**
+ * A method, which adds one blacklisted package.
+ */
void AddBlackListedPackage(const std::string& pPackage);
+ /**
+ * A method, which adds one association among alanyzer plugin and its
+ * action and reporter plugins.
+ * @param pAnalyzer A name of an analyzer plugin.
+ * @param pActionOrReporter A name of an action or reporter plugin.
+ * @param pArgs An arguments for action or reporter plugin.
+ */
void AddAnalyzerActionOrReporter(const std::string& pAnalyzer,
const std::string& pActionOrReporter,
const std::string& pArgs);
+ /**
+ * A method, which adds action and reporter plugins, which are activated
+ * when any crash occurs.
+ * @param pActionOrReporter A name of an action or reporter plugin.
+ * @param pArgs An arguments for action or reporter plugin.
+ */
void AddActionOrReporter(const std::string& pActionOrReporter,
const std::string& pArgs);
};
diff --git a/lib/MiddleWare/MiddleWareTypes.h b/lib/MiddleWare/MiddleWareTypes.h
index fe37715..12e1031 100644
--- a/lib/MiddleWare/MiddleWareTypes.h
+++ b/lib/MiddleWare/MiddleWareTypes.h
@@ -8,6 +8,7 @@
typedef std::vector<std::string> vector_strings_t;
typedef std::pair<std::string, std::string> pair_string_string_t;
+typedef std::vector<pair_string_string_t> vector_pair_string_string_t;
typedef std::map<std::string, std::string> map_string_string_t;
typedef std::set<std::string> set_strings_t;
diff --git a/lib/MiddleWare/Plugin.h b/lib/MiddleWare/Plugin.h
index 9fd5929..b6bfb3e 100644
--- a/lib/MiddleWare/Plugin.h
+++ b/lib/MiddleWare/Plugin.h
@@ -32,28 +32,56 @@
#define PLUGINS_LIB_EXTENSION "so"
#define PLUGINS_LIB_PREFIX "lib"
+/**
+ * An abstract class. The class defines a common plugin interface.
+ */
class CPlugin
{
public:
+ /**
+ * A destructor.
+ */
virtual ~CPlugin() {}
-
+ /**
+ * A method, which initializes a plugin. It is not mandatory method.
+ */
virtual void Init() {}
+ /**
+ * A method, which deinitializes a plugin. It is not mandatory method.
+ */
virtual void DeInit() {}
+ /**
+ * A method, which loads a plugin settings. It is not mandatory method.
+ * @param pPath A path to plugin configuration file.
+ */
virtual void LoadSettings(const std::string& pPath) {}
};
-typedef enum { ANALYZER, ACTION, REPORTER, DATABASE } plugin_type_t;
+/**
+ * An emun of plugin types.
+ */
+typedef enum { ANALYZER, /**< An analyzer plugin*/
+ ACTION, /**< An action plugin*/
+ REPORTER, /**< A reporter plugin*/
+ DATABASE /**< A database plugin*/
+ } plugin_type_t;
+/**
+ * Text reprezentation of plugin types.
+ */
const char* const plugin_type_str_t[] = {"Analyzer", "Action", "Reporter", "Database"};
+/**
+ * A struct contains all needed data about particular plugin.
+ */
typedef struct SPluginInfo
{
- const plugin_type_t m_Type;
- const std::string m_sName;
- const std::string m_sVersion;
- const std::string m_sDescription;
- const std::string m_sEmail;
- const std::string m_sWWW;
- const int m_nMagicNumber;
+ const plugin_type_t m_Type; /**< Plugin type.*/
+ const std::string m_sName; /**< Plugin name.*/
+ const std::string m_sVersion; /**< Plugin version.*/
+ const std::string m_sDescription; /**< Plugin description.*/
+ const std::string m_sEmail; /**< Plugin author's email.*/
+ const std::string m_sWWW; /**< Plugin's home page.*/
+ const int m_nMagicNumber; /**< Plugin magical number.*/
} plugin_info_t;
#define PLUGIN_IFACE extern "C"
diff --git a/lib/MiddleWare/PluginManager.h b/lib/MiddleWare/PluginManager.h
index 0da246d..2e2e797 100644
--- a/lib/MiddleWare/PluginManager.h
+++ b/lib/MiddleWare/PluginManager.h
@@ -32,39 +32,104 @@
#include "Database.h"
#include "Action.h"
+/**
+ * A class. It takes care of loading, registering and manipulating with
+ * plugins. When a plugin is loaded, its library is opened, but no plugin
+ * instance is created. It is possible after plugin registration.
+ */
class CPluginManager
{
private:
typedef std::map<std::string, CABRTPlugin*> map_abrt_plugins_t;
typedef std::map<std::string, CPlugin*> map_plugins_t;
-
+ /**
+ * Loaded plugins. A key is a plugin name.
+ */
map_abrt_plugins_t m_mapABRTPlugins;
+ /**
+ * Registered plugins. A key is a plugin name.
+ */
map_plugins_t m_mapPlugins;
-
+ /**
+ * Plugins configuration directory (e.g. /etc/abrt/plugins, ...).
+ */
std::string m_sPlugisConfDir;
+ /**
+ * Plugins library directory (e.g. /usr/lib/abrt/plugins, ...).
+ */
std::string m_sPlugisLibDir;
public:
+ /**
+ * A constructor.
+ * @param pPlugisConfDir A plugins configuration directory.
+ * @param pPlugisLibDir A plugins library directory.
+ */
CPluginManager(const std::string& pPlugisConfDir,
const std::string& pPlugisLibDir);
-
+ /**
+ * A destructor.
+ */
~CPluginManager();
-
+ /**
+ * A method, which loads all plugins in plugins library direcotry.
+ */
void LoadPlugins();
+ /**
+ * A method, which unregister and unload all loaded plugins.
+ */
void UnLoadPlugins();
-
+ /**
+ * A method, which loads particular plugin.
+ * @param pName A plugin name.
+ */
void LoadPlugin(const std::string& pName);
+ /**
+ * A method, which unloads particular plugin.
+ * @param pName A plugin name.
+ */
void UnLoadPlugin(const std::string& pName);
+ /**
+ * A method, which registers particular plugin.
+ * @param pName A plugin name.
+ */
void RegisterPlugin(const std::string& pName);
+ /**
+ * A method, which unregister particular plugin.
+ * @param pName A plugin name.
+ */
void UnRegisterPlugin(const std::string& pName);
-
+ /**
+ * A method, which returns instance of particular analyzer plugin.
+ * @param pName A plugin name.
+ * @return An analyzer plugin.
+ */
CAnalyzer* GetAnalyzer(const std::string& pName);
+ /**
+ * A method, which returns instance of particular reporter plugin.
+ * @param pName A plugin name.
+ * @return A reporter plugin.
+ */
CReporter* GetReporter(const std::string& pName);
+ /**
+ * A method, which returns instance of particular action plugin.
+ * @param pName A plugin name.
+ * @return An action plugin.
+ */
CAction* GetAction(const std::string& pName);
+ /**
+ * A method, which returns instance of particular database plugin.
+ * @param pName A plugin name.
+ * @return A database plugin.
+ */
CDatabase* GetDatabase(const std::string& pName);
+ /**
+ * A method, which returns type of particular plugin.
+ * @param pName A plugin name.
+ * @return A plugin type.
+ */
plugin_type_t GetPluginType(const std::string& pName);
-
};
#endif /*PLUGINMANAGER_H_*/
diff --git a/lib/MiddleWare/RPM.h b/lib/MiddleWare/RPM.h
index 00196f7..4a0f0f4 100644
--- a/lib/MiddleWare/RPM.h
+++ b/lib/MiddleWare/RPM.h
@@ -29,24 +29,63 @@
#include <rpm/rpmts.h>
#include <rpm/rpmdb.h>
+/**
+ * A class. It is used for additional checks of package, which contains
+ * crashed application.
+ */
class CRPM
{
private:
typedef set_strings_t set_fingerprints_t;
+ /**
+ * A context for librpm library.
+ */
poptContext m_poptContext;
+ /**
+ * A set, which contains finger prints.
+ */
set_fingerprints_t m_setFingerprints;
public:
+ /**
+ * A constructior.
+ */
CRPM();
+ /**
+ * A destructor.
+ */
~CRPM();
-
+ /**
+ * A method, which loads one GPG public key.
+ * @param pFileName A path to the public key.
+ */
void LoadOpenGPGPublicKey(const std::string& pFileName);
-
+ /**
+ * A method, which checks if package's finger print is valid.
+ * @param pPackage A package name.
+ */
bool CheckFingerprint(const std::string& pPackage);
- bool CheckHash(const std::string& pPackage, const std::string&pPath);
+ /**
+ * A method, which checks if an application is modified by thir party.
+ * @param pPackage A package name. The package contains the application.
+ * @param pPath A path to the application.
+ */
+ bool CheckHash(const std::string& pPackage, const std::string& pPath);
+ /**
+ * A method, which gets a package description.
+ * @param pPackage A package name.
+ * @return A package description.
+ */
std::string GetDescription(const std::string& pPackage);
+ /**
+ * A method, which gets a package name. This package contains particular
+ * file. If the file doesn't belong to any package, empty string is
+ * returned.
+ * @param pFileName A file name.
+ * @return A package name.
+ */
std::string GetPackage(const std::string& pFileName);
};
diff --git a/lib/MiddleWare/Reporter.h b/lib/MiddleWare/Reporter.h
index 76680df..87c46db 100644
--- a/lib/MiddleWare/Reporter.h
+++ b/lib/MiddleWare/Reporter.h
@@ -26,10 +26,23 @@
#include "Plugin.h"
#include "CrashTypes.h"
+/**
+ * An abstract class. The class defines a reporter plugin interface.
+ */
class CReporter : public CPlugin
{
public:
+ /**
+ * A destructor.
+ */
virtual ~CReporter() {}
+ /**
+ * A method, which reports a crash report to particular receiver.
+ * The plugin can takes arguments, but the plugin has to parse them
+ * by itself.
+ * @param pCrashReport A crash report.
+ * @param pArgs Plugin's arguments.
+ */
virtual void Report(const map_crash_report_t& pCrashReport,
const std::string& pArgs) = 0;
};