diff options
| author | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-04-23 14:42:40 +0200 |
|---|---|---|
| committer | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-04-23 14:42:40 +0200 |
| commit | bcf4c69ca5fdd6489ca1c09890971fc8f647aa1b (patch) | |
| tree | e5fedc350ae9368faf77360ea4fb3c0f6d264210 /src | |
| parent | 99047bce024f1d23c953649cf56ff67e754e44ef (diff) | |
| download | abrt-bcf4c69ca5fdd6489ca1c09890971fc8f647aa1b.tar.gz abrt-bcf4c69ca5fdd6489ca1c09890971fc8f647aa1b.tar.xz abrt-bcf4c69ca5fdd6489ca1c09890971fc8f647aa1b.zip | |
Added intercomm layer so plugins can send various information to the daemon.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Daemon/CrashWatcher.cpp | 108 | ||||
| -rw-r--r-- | src/Daemon/CrashWatcher.h | 17 | ||||
| -rw-r--r-- | src/Daemon/Makefile.am | 4 | ||||
| -rw-r--r-- | src/Daemon/exported-symbols | 3 |
4 files changed, 115 insertions, 17 deletions
diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp index 48d18db..2884e7c 100644 --- a/src/Daemon/CrashWatcher.cpp +++ b/src/Daemon/CrashWatcher.cpp @@ -30,6 +30,7 @@ #include <sstream> #include <dirent.h> #include <cstring> +#include "CommLayer.h" /* just a helper function template< class T > @@ -42,6 +43,14 @@ to_string( T x ) } */ +CCommLayerInner* pCommLayerInner; +CCommLayerInner* get_commlayer() +{ + std::cerr << "get_commlayer" << std::endl; + return pCommLayerInner; +} + + gboolean CCrashWatcher::handle_event_cb(GIOChannel *gio, GIOCondition condition, gpointer daemon){ GIOError err; //char *buf = malloc(INOTIFY_BUFF_SIZE; @@ -160,6 +169,22 @@ void CCrashWatcher::SetUpMW() } } +void CCrashWatcher::StatusUpdate(const std::string& pMessage) +{ + std::cout << "UPDATE: " << pMessage << std::endl; +} + +void CCrashWatcher::Warning(const std::string& pMessage) +{ + std::cout << "WW: " << pMessage << std::endl; +} + +void CCrashWatcher::Debug(const std::string& pMessage) +{ + //some logic to add logging levels? + std::cout << "DEBUG: " << pMessage << std::endl; +} + double CCrashWatcher::GetDirSize(const std::string &pPath) { double size = 0; @@ -194,21 +219,24 @@ CCrashWatcher::CCrashWatcher(const std::string& pPath) { int watch = 0; m_sTarget = pPath; - // middleware object +// create inner commlayer +pCommLayerInner = new CCommLayerInner(this); +//middleware object m_pSettings = new CSettings(); m_pSettings->LoadSettings(std::string(CONF_DIR) + "/abrt.conf"); + m_pMainloop = g_main_loop_new(NULL,FALSE); m_pMW = new CMiddleWare(PLUGINS_CONF_DIR,PLUGINS_LIB_DIR); SetUpMW(); FindNewDumps(pPath); - m_pMainloop = g_main_loop_new(NULL,FALSE); +//first init commlayer #ifdef HAVE_DBUS - m_pCommLayer = new CCommLayerServerDBus(m_pMW); + m_pCommLayer = new CCommLayerServerDBus(); #elif HAVE_SOCKET - m_pCommLayer = new CCommLayerServerSocket(m_pMW); + m_pCommLayer = new CCommLayerServerSocket(); #endif - m_pCommLayer = new CCommLayerServerDBus(m_pMW); + m_pCommLayer = new CCommLayerServerDBus(); m_pCommLayer->Attach(this); - + if((m_nFd = inotify_init()) == -1){ throw std::string("Init Failed"); //std::cerr << "Init Failed" << std::endl; @@ -266,7 +294,7 @@ void CCrashWatcher::FindNewDumps(const std::string& pPath) std::cerr << "Saving debugdeump: " << *itt << std::endl; try { - if(m_pMW->SaveDebugDump(*itt, crashinfo)) + if(m_pMW->SaveDebugDump(*itt, crashinfo) == 0) { std::cerr << "Saved new entry: " << *itt << std::endl; m_pMW->Report(*itt); @@ -360,3 +388,69 @@ void CCrashWatcher::Run() GStartWatch(); } +vector_crash_infos_t CCrashWatcher::GetCrashInfos(const std::string &pUID) +{ + vector_crash_infos_t retval; + std::cerr << "CCommLayerServerDBus::GetCrashInfos" << std::endl; + try + { + retval = m_pMW->GetCrashInfos(pUID); + } + catch(std::string err) + { + std::cerr << err << std::endl; + } + //Notify("Sent crash info"); + return retval; +} + +map_crash_report_t CCrashWatcher::CreateReport(const std::string &pUUID,const std::string &pUID) +{ + map_crash_report_t crashReport; + std::cerr << "Creating report" << std::endl; + try + { + m_pMW->CreateCrashReport(pUUID,pUID,crashReport); + m_pCommLayer->AnalyzeComplete(crashReport); + } + catch(std::string err) + { + m_pCommLayer->Error(err); + } + return crashReport; +} + +bool CCrashWatcher::Report(map_crash_report_t pReport) +{ + //#define FIELD(X) crashReport.m_s##X = pReport[#X]; + //crashReport.m_sUUID = pReport["UUID"]; + //ALL_CRASH_REPORT_FIELDS; + //#undef FIELD + //for (dbus_map_report_info_t::iterator it = pReport.begin(); it!=pReport.end(); ++it) { + // std::cerr << it->second << std::endl; + //} + try + { + m_pMW->Report(pReport); + } + catch(std::string err) + { + std::cerr << err << std::endl; + return false; + } + return true; +} + +bool CCrashWatcher::DeleteDebugDump(const std::string& pUUID, const std::string& pUID) +{ + try + { + m_pMW->DeleteCrashInfo(pUUID,pUID, true); + } + catch(std::string err) + { + std::cerr << err << std::endl; + return false; + } + return true; +} diff --git a/src/Daemon/CrashWatcher.h b/src/Daemon/CrashWatcher.h index a71e370..bdad266 100644 --- a/src/Daemon/CrashWatcher.h +++ b/src/Daemon/CrashWatcher.h @@ -28,7 +28,9 @@ //#include "DBusServerProxy.h" #include "MiddleWare.h" #include "Settings.h" +#include "CommLayerInner.h" +//FIXME remove when it gets to autoconf #include "CommLayerServerDBus.h" #ifdef HAVE_DBUS #include "CommLayerServerDBus.h" @@ -76,16 +78,15 @@ class CCrashWatcher /* methods exported on dbus */ public: - /* - vector_crash_infos_t GetCrashInfos(const std::string &pUID); - dbus_vector_map_crash_infos_t GetCrashInfosMap(const std::string &pDBusSender); - dbus_map_report_info_t CreateReport(const std::string &pUUID,const std::string &pDBusSender); - bool Report(dbus_map_report_info_t pReport); - bool DeleteDebugDump(const std::string& pUUID, const std::string& pDBusSender); - */ + virtual vector_crash_infos_t GetCrashInfos(const std::string &pUID); + virtual map_crash_report_t CreateReport(const std::string &pUUID,const std::string &pUID); + virtual bool Report(map_crash_report_t pReport); + virtual bool DeleteDebugDump(const std::string& pUUID, const std::string& pUID); public: /* Observer methods */ - void Update(const std::string&) {} + void StatusUpdate(const std::string& pMessage); + void Debug(const std::string& pMessage); + void Warning(const std::string& pMessage); }; #endif /*CRASHWATCHER_H_*/ diff --git a/src/Daemon/Makefile.am b/src/Daemon/Makefile.am index 8c05723..38c73a1 100644 --- a/src/Daemon/Makefile.am +++ b/src/Daemon/Makefile.am @@ -1,14 +1,14 @@ sbin_PROGRAMS = abrt abrt_SOURCES = CrashWatcher.cpp CrashWatcher.h Daemon.cpp DBusServerProxy.h \ DBusCommon.h Settings.h Settings.cpp -abrt_CPPFLAGS = -Wall -Werror -I../../lib/MiddleWare -I../../lib/CommLayer\ +abrt_CPPFLAGS = -Wall -Werror -rdynamic -I../../lib/MiddleWare -I../../lib/CommLayer\ -I../../lib/DBus \ -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" $(GLIB_CFLAGS) $(DBUSCPP_CFLAGS) \ -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" \ -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \ -DCONF_DIR=\"$(CONF_DIR)\" abrt_LDADD = ../../lib/MiddleWare/libABRTMiddleWare.la ../../lib/CommLayer/libABRTCommLayer.la $(DL_LIBS) $(DBUSCPP_LIBS) $(RPM_LIBS) - +abrt_LDFLAGS = -Wl,--dynamic-list,exported-symbols dbusabrtconfdir = ${sysconfdir}/dbus-1/system.d/ dist_dbusabrtconf_DATA = dbus-abrt.conf diff --git a/src/Daemon/exported-symbols b/src/Daemon/exported-symbols new file mode 100644 index 0000000..511b598 --- /dev/null +++ b/src/Daemon/exported-symbols @@ -0,0 +1,3 @@ +{ + get_commlayer; +}; |
