diff options
| author | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-04-01 09:36:46 +0200 |
|---|---|---|
| committer | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-04-01 09:36:46 +0200 |
| commit | 42657326fdf8db194013094537d9386830fe5876 (patch) | |
| tree | a81cde5aa03cc72950987c4eaa29d0461696a3d4 /src/Daemon | |
| parent | d879ebf08c48bbe8ed9bd344fceee9163fe464da (diff) | |
| download | abrt-42657326fdf8db194013094537d9386830fe5876.tar.gz abrt-42657326fdf8db194013094537d9386830fe5876.tar.xz abrt-42657326fdf8db194013094537d9386830fe5876.zip | |
Added commlayer to make dbus optional
Diffstat (limited to 'src/Daemon')
| -rw-r--r-- | src/Daemon/CrashWatcher.cpp | 39 | ||||
| -rw-r--r-- | src/Daemon/CrashWatcher.h | 28 | ||||
| -rw-r--r-- | src/Daemon/Daemon.cpp | 8 | ||||
| -rw-r--r-- | src/Daemon/Makefile.am | 4 |
4 files changed, 62 insertions, 17 deletions
diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp index ad4dac9..3426e92 100644 --- a/src/Daemon/CrashWatcher.cpp +++ b/src/Daemon/CrashWatcher.cpp @@ -31,7 +31,7 @@ #include <dirent.h> #include <cstring> -/* just a helper function */ +/* just a helper function template< class T > std::string to_string( T x ) @@ -40,6 +40,7 @@ to_string( T x ) o << x; return o.str(); } +*/ gboolean CCrashWatcher::handle_event_cb(GIOChannel *gio, GIOCondition condition, gpointer daemon){ GIOError err; @@ -76,7 +77,7 @@ gboolean CCrashWatcher::handle_event_cb(GIOChannel *gio, GIOCondition condition, if(cc->m_pMW->SaveDebugDump(std::string(DEBUG_DUMPS_DIR) + "/" + name, crashinfo)) { /* send message to dbus */ - cc->Crash(crashinfo.m_sPackage); + cc->m_pCommLayer->Crash(crashinfo.m_sPackage); } } catch(std::string err) @@ -94,7 +95,7 @@ gboolean CCrashWatcher::handle_event_cb(GIOChannel *gio, GIOCondition condition, delete[] buf; return TRUE; } - +/* CCrashWatcher::CCrashWatcher(const std::string& pPath,DBus::Connection &connection) : DBus::ObjectAdaptor(connection, CC_DBUS_PATH) { @@ -117,11 +118,39 @@ CCrashWatcher::CCrashWatcher(const std::string& pPath,DBus::Connection &connecti } m_pGio = g_io_channel_unix_new(m_nFd); } +*/ +CCrashWatcher::CCrashWatcher(const std::string& pPath) +{ + int watch = 0; + m_sTarget = pPath; + // middleware object + m_pMW = new CMiddleWare(PLUGINS_CONF_DIR,PLUGINS_LIB_DIR, std::string(CONF_DIR) + "/abrt.conf"); + FindNewDumps(pPath); + m_pMainloop = g_main_loop_new(NULL,FALSE); +#ifdef HAVE_DBUS + m_pCommLayer = new CCommLayerServerDBus(m_pMW); +#elif HAVE_SOCKET + m_pCommLayer = new CCommLayerServerSocket(m_pMW); +#endif + m_pCommLayer = new CCommLayerServerDBus(m_pMW); + m_pCommLayer->Attach(this); + + if((m_nFd = inotify_init()) == -1){ + throw std::string("Init Failed"); + //std::cerr << "Init Failed" << std::endl; + exit(-1); + } + if((watch = inotify_add_watch(m_nFd, pPath.c_str(), IN_CREATE)) == -1){ + + throw std::string("Add watch failed:") + pPath.c_str(); + } + m_pGio = g_io_channel_unix_new(m_nFd); +} CCrashWatcher::~CCrashWatcher() { //delete dispatcher, connection, etc.. - m_pConn->disconnect(); + //m_pConn->disconnect(); delete m_pMW; g_io_channel_unref(m_pGio); g_main_loop_unref(m_pMainloop); @@ -170,6 +199,7 @@ void CCrashWatcher::FindNewDumps(const std::string& pPath) } } } +/* dbus_vector_crash_infos_t CCrashWatcher::GetCrashInfos(const std::string &pUID) { dbus_vector_crash_infos_t retval; @@ -260,6 +290,7 @@ bool CCrashWatcher::DeleteDebugDump(const std::string& pUUID, const std::string& } return true; } +*/ void CCrashWatcher::Lock() { int lfp = open("abrt.lock",O_RDWR|O_CREAT,0640); diff --git a/src/Daemon/CrashWatcher.h b/src/Daemon/CrashWatcher.h index f18a16d..667e521 100644 --- a/src/Daemon/CrashWatcher.h +++ b/src/Daemon/CrashWatcher.h @@ -25,17 +25,25 @@ #include <sys/inotify.h> #include <glib.h> //#include "DBusManager.h" -#include "DBusServerProxy.h" +//#include "DBusServerProxy.h" #include "MiddleWare.h" +#include "CommLayerServerDBus.h" +#ifdef HAVE_DBUS + #include "CommLayerServerDBus.h" +#elif HAVE_SOCKET + #include "CommLayerServerSocket.h" +#endif + // 1024 simultaneous actions #define INOTIFY_BUFF_SIZE ((sizeof(struct inotify_event)+FILENAME_MAX)*1024) class CCrashWatcher -: public CDBusServer_adaptor, - public DBus::IntrospectableAdaptor, - public DBus::ObjectAdaptor +//: public CDBusServer_adaptor, +// public DBus::IntrospectableAdaptor, +// public DBus::ObjectAdaptor, +: public CObserver { private: static gboolean handle_event_cb(GIOChannel *gio, GIOCondition condition, gpointer data); @@ -50,9 +58,13 @@ class CCrashWatcher GMainLoop *m_pMainloop; std::string m_sTarget; CMiddleWare *m_pMW; - DBus::Connection *m_pConn; + CCommLayerServer *m_pCommLayer; + /*FIXME not needed */ + //DBus::Connection *m_pConn; + public: - CCrashWatcher(const std::string& pPath,DBus::Connection &connection); + //CCrashWatcher(const std::string& pPath,DBus::Connection &connection); + CCrashWatcher(const std::string& pPath); ~CCrashWatcher(); //run as daemon void Daemonize(); @@ -66,7 +78,9 @@ class CCrashWatcher 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); - + public: + /* Observer methods */ + void Update(const std::string&) {} }; #endif /*CRASHWATCHER_H_*/ diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp index b5d6cbe..1eca300 100644 --- a/src/Daemon/Daemon.cpp +++ b/src/Daemon/Daemon.cpp @@ -28,7 +28,7 @@ void terminate(int signal) { fprintf(stderr, "Got SIGINT/SIGTERM, cleaning up..\n"); delete ccdaemon; - delete dispatcher; + //delete dispatcher; exit(0); } @@ -37,15 +37,15 @@ int main(int argc, char** argv){ /*signal handlers */ signal(SIGTERM, terminate); signal(SIGINT, terminate); - /* connect to dbus */ + /* connect to dbus //DBus::Glib::BusDispatcher *dispatcher; dispatcher = new DBus::Glib::BusDispatcher(); dispatcher->attach(NULL); DBus::default_dispatcher = dispatcher; DBus::Connection conn = DBus::Connection::SystemBus(); - + */ try{ - ccdaemon = new CCrashWatcher(DEBUG_DUMPS_DIR, conn); + ccdaemon = new CCrashWatcher(DEBUG_DUMPS_DIR); if (argc > 1){ if (strcmp(argv[1], "-d") == 0){ daemonize = 0; diff --git a/src/Daemon/Makefile.am b/src/Daemon/Makefile.am index 70934b4..3eb2292 100644 --- a/src/Daemon/Makefile.am +++ b/src/Daemon/Makefile.am @@ -1,13 +1,13 @@ sbin_PROGRAMS = abrt abrt_SOURCES = CrashWatcher.cpp CrashWatcher.h Daemon.cpp DBusServerProxy.h \ DBusCommon.h -abrt_CPPFLAGS = -Wall -Werror -I../../lib/MiddleWare\ +abrt_CPPFLAGS = -Wall -Werror -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/libMiddleWare.la $(DL_LIBS) $(DBUSCPP_LIBS) $(RPM_LIBS) +abrt_LDADD = ../../lib/MiddleWare/libMiddleWare.la ../../lib/CommLayer/libABRTCommLayer.la $(DL_LIBS) $(DBUSCPP_LIBS) $(RPM_LIBS) dbusabrtconfdir = ${sysconfdir}/dbus-1/system.d/ dist_dbusabrtconf_DATA = dbus-abrt.conf |
