diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-15 12:43:01 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-15 12:43:01 +0200 |
| commit | 0f91e9a06aa0f68a2cbe3c9fc4a858c0a5e6744a (patch) | |
| tree | 13f92f2fc02d346d8474ef03fd0596e3e0447eda /lib/MiddleWare | |
| parent | 5f4a56f97f36e9cb844fcf3e4399cea67000a6bb (diff) | |
| download | abrt-0f91e9a06aa0f68a2cbe3c9fc4a858c0a5e6744a.tar.gz abrt-0f91e9a06aa0f68a2cbe3c9fc4a858c0a5e6744a.tar.xz abrt-0f91e9a06aa0f68a2cbe3c9fc4a858c0a5e6744a.zip | |
unify CommLayer, MiddleWare and Utils into Utils
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib/MiddleWare')
| -rw-r--r-- | lib/MiddleWare/Action.h | 47 | ||||
| -rw-r--r-- | lib/MiddleWare/Analyzer.h | 56 | ||||
| -rw-r--r-- | lib/MiddleWare/Database.h | 126 | ||||
| -rw-r--r-- | lib/MiddleWare/Makefile.am | 34 | ||||
| -rw-r--r-- | lib/MiddleWare/Plugin.cpp | 27 | ||||
| -rw-r--r-- | lib/MiddleWare/Plugin.h | 118 | ||||
| -rw-r--r-- | lib/MiddleWare/Reporter.h | 47 | ||||
| -rw-r--r-- | lib/MiddleWare/test.cpp | 108 |
8 files changed, 0 insertions, 563 deletions
diff --git a/lib/MiddleWare/Action.h b/lib/MiddleWare/Action.h deleted file mode 100644 index 1286feb..0000000 --- a/lib/MiddleWare/Action.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - Action.h - header file for action plugin - - Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com) - Copyright (C) 2009 RedHat inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef ACTION_H_ -#define ACTION_H_ - -#include <string> -#include "Plugin.h" - -/** - * An abstract class. The class defines an action plugin interface. - */ -class CAction : public CPlugin -{ - public: - /** - * 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; -}; - -#endif /*ACTION_H_*/ diff --git a/lib/MiddleWare/Analyzer.h b/lib/MiddleWare/Analyzer.h deleted file mode 100644 index 4fe586b..0000000 --- a/lib/MiddleWare/Analyzer.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - Analyzer.h - header file for analyzer plugin - - Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com) - Copyright (C) 2009 RedHat inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef ANALYZER_H_ -#define ANALYZER_H_ - -#include <string> -#include "Plugin.h" - -/** - * An abstract class. The class defines an analyzer plugin interface. - */ -class CAnalyzer : public CPlugin -{ - public: - /** - * 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; -}; - -#endif /*ANALYZER_H_*/ diff --git a/lib/MiddleWare/Database.h b/lib/MiddleWare/Database.h deleted file mode 100644 index 0fc31ee..0000000 --- a/lib/MiddleWare/Database.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - Database.h - header file for database plugin - - Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com) - Copyright (C) 2009 RedHat inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - - -#ifndef DATABASE_H_ -#define DATABASE_H_ - -#include <string> -#include <vector> -#include "Plugin.h" - -/** - * Table - * ===== - * UUID | UID| DebugDumpPath | Count | Reported | Time | Message - * - * primary key (UUID, UID) - */ - -#define DATABASE_COLUMN_UUID "UUID" -#define DATABASE_COLUMN_UID "UID" -#define DATABASE_COLUMN_DEBUG_DUMP_PATH "DebugDumpPath" -#define DATABASE_COLUMN_COUNT "Count" -#define DATABASE_COLUMN_REPORTED "Reported" -#define DATABASE_COLUMN_TIME "Time" -#define DATABASE_COLUMN_MESSAGE "Message" - -/** - * A struct contains one database row. - */ -typedef struct SDatabaseRow -{ - 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_sMessage; /**< if a row is reported, then there can be store message abotu that*/ - std::string m_sTime; /**< Time of last occurred crash with same local UUID*/ -} database_row_t; - -/** - * 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 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; - /** - * 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. - * @param pMessga A text explanation of reported problem (where - * it is stored etc... - */ - virtual void SetReported(const std::string& pUUID, - const std::string& pUID, - const std::string& pMessage) = 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 vector_database_rows_t GetUIDData(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 database_row_t GetUUIDData(const std::string& pUUID, - const std::string& pUID) = 0; -}; - -#endif /* DATABASE_H_ */ diff --git a/lib/MiddleWare/Makefile.am b/lib/MiddleWare/Makefile.am deleted file mode 100644 index 0db4f79..0000000 --- a/lib/MiddleWare/Makefile.am +++ /dev/null @@ -1,34 +0,0 @@ -lib_LTLIBRARIES = libABRTMiddleWare.la - -libABRTMiddleWare_la_SOURCES = \ - Plugin.cpp Plugin.h \ - Action.h Database.h Reporter.h Analyzer.h -libABRTMiddleWare_la_LIBADD = \ - $(DL_LIBS) \ - ../Utils/libABRTUtils.la \ - $(RPM_LIBS) -libABRTMiddleWare_la_LDFLAGS = -version-info 0:1:0 -libABRTMiddleWare_la_CPPFLAGS = \ - -I$(srcdir)/../../inc \ - -I$(srcdir)/../Utils \ - -I$(srcdir)/../CommLayer \ - $(RPM_CFLAGS) - -# disabled: MiddleWare.* is moved to src/Daemon/ now -# -#check_PROGRAMS = test -# -#test_SOURCES = test.cpp -#test_LDADD = \ -# ../Utils/libABRTUtils.la \ -# ../CommLayer/libABRTCommLayer.la \ -# libABRTMiddleWare.la \ -# $(DL_LIBS) $(RPM_LIBS) -#test_CPPFLAGS = \ -# -I$(srcdir)/../../inc \ -# -I$(srcdir)/../Utils \ -# -I$(srcdir)/../CommLayer\ -# -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" \ -# -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \ -# -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" \ -# -DCONF_DIR=\"$(CONF_DIR)\" diff --git a/lib/MiddleWare/Plugin.cpp b/lib/MiddleWare/Plugin.cpp deleted file mode 100644 index 161ead8..0000000 --- a/lib/MiddleWare/Plugin.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com) - Copyright (C) 2009 RedHat inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "Plugin.h" - -/* class CPlugin's virtuals */ -CPlugin::~CPlugin() {} -void CPlugin::Init() {} -void CPlugin::DeInit() {} -void CPlugin::SetSettings(const map_plugin_settings_t& pSettings) {} -map_plugin_settings_t CPlugin::GetSettings() {return map_plugin_settings_t();} diff --git a/lib/MiddleWare/Plugin.h b/lib/MiddleWare/Plugin.h deleted file mode 100644 index 3929023..0000000 --- a/lib/MiddleWare/Plugin.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - Plugin.h - header file for plugin. It contains mandatory macros - and common function for plugins - - Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com) - Copyright (C) 2009 RedHat inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef PLUGIN_H_ -#define PLUGIN_H_ - -#include "abrt_types.h" - -#define PLUGINS_MAGIC_NUMBER 6 - -#define PLUGINS_CONF_EXTENSION "conf" -#define PLUGINS_LIB_EXTENSION "so" -#define PLUGINS_LIB_PREFIX "lib" - -#if HAVE_CONFIG_H - #include <config.h> -#endif - -#if ENABLE_NLS - #include <libintl.h> - #define _(S) gettext(S) -#else - #define _(S) (S) -#endif - -/** - * An abstract class. The class defines a common plugin interface. If a plugin - * has some settings, then a *Settings(*) method has to be written. - */ -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 takes a settings and apply them. It is not a mandatory method. - * @param pSettings Plugin's settings - */ - virtual void SetSettings(const map_plugin_settings_t& pSettings); - /** - * A method, which return current settings. It is not mandatory method. - * @return Plugin's settings - */ - virtual map_plugin_settings_t GetSettings(); -}; - -/** - * An enum of plugin types. - */ -typedef enum { - ANALYZER, /**< An analyzer plugin*/ - ACTION, /**< An action plugin*/ - REPORTER, /**< A reporter plugin*/ - DATABASE /**< A database plugin*/ -} plugin_type_t; - -/** - * A struct contains all needed data about particular plugin. - */ -typedef struct SPluginInfo -{ - const plugin_type_t m_Type; /**< Plugin type.*/ - const char *const m_sName; /**< Plugin name.*/ - const char *const m_sVersion; /**< Plugin version.*/ - const char *const m_sDescription; /**< Plugin description.*/ - const char *const m_sEmail; /**< Plugin author's email.*/ - const char *const m_sWWW; /**< Plugin's home page.*/ - const char *const m_sGTKBuilder; /**< Plugin's gui description.*/ - const int m_nMagicNumber; /**< Plugin magical number.*/ -} plugin_info_t; - -#define PLUGIN_INFO(type, plugin_class, name, version, description, email, www, gtk_builder)\ - extern "C" CPlugin* plugin_new()\ - {\ - return new plugin_class();\ - }\ - extern "C" const plugin_info_t plugin_info =\ - {\ - type,\ - name,\ - version,\ - description,\ - email,\ - www,\ - gtk_builder,\ - PLUGINS_MAGIC_NUMBER,\ - }; - -#endif /* PLUGIN_H_ */ diff --git a/lib/MiddleWare/Reporter.h b/lib/MiddleWare/Reporter.h deleted file mode 100644 index c74a10c..0000000 --- a/lib/MiddleWare/Reporter.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - Reporter.h - header file for reporter plugin - - Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com) - Copyright (C) 2009 RedHat inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef REPORTER_H_ -#define REPORTER_H_ - -#include <string> -#include "Plugin.h" -#include "CrashTypes.h" - -/** - * An abstract class. The class defines a reporter plugin interface. - */ -class CReporter : public CPlugin -{ - public: - /** - * 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. - * @retun A message which can be displayed after a report is created. - */ - virtual std::string Report(const map_crash_report_t& pCrashReport, - const std::string& pArgs) = 0; -}; - -#endif /* REPORTER_H_ */ diff --git a/lib/MiddleWare/test.cpp b/lib/MiddleWare/test.cpp deleted file mode 100644 index fbad1db..0000000 --- a/lib/MiddleWare/test.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - test.cpp - simple library test - - Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com) - Copyright (C) 2009 RedHat inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "MiddleWare.h" -#include "DebugDump.h" -#include "CrashTypes.h" -#include <iostream> -#include <sys/types.h> -#include <unistd.h> -#include <iostream> - - -int main(int argc, char** argv) -{ - - if (argc < 2) - { - std::cerr << "Usage: " << argv[0] << " <DebugDumpDir>" << std::endl; - return -1; - } - try - { - CMiddleWare middleWare(PLUGINS_CONF_DIR, - PLUGINS_LIB_DIR); - vector_map_string_t loaded_plugins; - middleWare.RegisterPlugin("CCpp"); - middleWare.RegisterPlugin("Mailx"); - middleWare.RegisterPlugin("Logger"); - middleWare.RegisterPlugin("RunApp"); - middleWare.RegisterPlugin("SQLite3"); - middleWare.SetDatabase("SQLite3"); - middleWare.SetOpenGPGCheck(false); - middleWare.AddActionOrReporter("Logger", ""); - middleWare.AddAnalyzerActionOrReporter("CCpp", "Mailx", ""); - middleWare.AddAnalyzerActionOrReporter("CCpp", "RunApp", "date"); - - loaded_plugins = middleWare.GetPluginsInfo(); - std::cout << "Loaded plugins" << std::endl; - int ii; - for ( ii = 0; ii < loaded_plugins.size(); ii++) - { - std::cout << "-------------------------------------------" << std::endl; - map_plugin_settings_t settings; - std::cout << "Enabled: " << loaded_plugins[ii]["Enabled"] << std::endl; - std::cout << "Type: " << loaded_plugins[ii]["Type"] << std::endl; - std::cout << "Name: " << loaded_plugins[ii]["Name"] << std::endl; - std::cout << "Version: " << loaded_plugins[ii]["Version"] << std::endl; - std::cout << "Description: " << loaded_plugins[ii]["Description"] << std::endl; - std::cout << "Email: " << loaded_plugins[ii]["Email"] << std::endl; - std::cout << "WWW: " << loaded_plugins[ii]["WWW"] << std::endl; - std::cout << "GTKBuilder: " << loaded_plugins[ii]["GTKBuilder"] << std::endl; - if (loaded_plugins[ii]["Enabled"] == "yes") - { - std::cout << std::endl << "Settings: " << std::endl; - settings = middleWare.GetPluginSettings(loaded_plugins[ii]["Name"]); - map_plugin_settings_t::iterator it; - for (it = settings.begin(); it != settings.end(); it++) - { - std::cout << "\t" << it->first << ": " << it->second << std::endl; - } - } - std::cout << "-------------------------------------------" << std::endl; - } - /* Try to save it into DB */ - map_crash_info_t crashInfo; - if (middleWare.SaveDebugDump(argv[1], crashInfo)) - { - std::cout << "Application Crashed! " << - crashInfo[CD_PACKAGE][CD_CONTENT] << ", " << - crashInfo[CD_EXECUTABLE][CD_CONTENT] << ", " << - crashInfo[CD_COUNT][CD_CONTENT] << ", " << std::endl; - - /* Get Report, so user can change data (remove private stuff) - * If we do not want user interaction, just send data immediately - */ - map_crash_report_t crashReport; - middleWare.CreateCrashReport(crashInfo[CD_UUID][CD_CONTENT], - crashInfo[CD_UID][CD_CONTENT], - crashReport); - /* Report crash */ - middleWare.Report(crashReport); - } - } - catch (std::string sError) - { - std::cerr << sError << std::endl; - } - - return 0; -} |
