summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJiri Moskovcak <jmoskovc@redhat.com>2009-04-24 12:18:31 +0200
committerJiri Moskovcak <jmoskovc@redhat.com>2009-04-24 12:18:31 +0200
commit68ba4945437e12eaa1dead6df27b58ea408f63e8 (patch)
treea608d71e76dc82bf9ffdec95452c429d5aec29d2 /src
parent7b2d4874b7bd992ef3f09124b7ebbc346eba01f4 (diff)
downloadabrt-68ba4945437e12eaa1dead6df27b58ea408f63e8.tar.gz
abrt-68ba4945437e12eaa1dead6df27b58ea408f63e8.tar.xz
abrt-68ba4945437e12eaa1dead6df27b58ea408f63e8.zip
final touch on commlayer, minor fixes in exceptions (zprikryl)
Diffstat (limited to 'src')
-rw-r--r--src/Daemon/CrashWatcher.cpp29
-rw-r--r--src/Daemon/CrashWatcher.h4
-rw-r--r--src/Daemon/Daemon.cpp58
-rw-r--r--src/Daemon/Makefile.am4
4 files changed, 38 insertions, 57 deletions
diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp
index 390cb107..85a705ca 100644
--- a/src/Daemon/CrashWatcher.cpp
+++ b/src/Daemon/CrashWatcher.cpp
@@ -31,6 +31,7 @@
#include <dirent.h>
#include <cstring>
#include "CommLayer.h"
+#include "ABRTException.h"
/* just a helper function
template< class T >
@@ -43,17 +44,8 @@ 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;
char *buf = new char[INOTIFY_BUFF_SIZE];
gsize len;
gsize i = 0;
@@ -169,20 +161,20 @@ void CCrashWatcher::SetUpMW()
}
}
-void CCrashWatcher::StatusUpdate(const std::string& pMessage)
+void CCrashWatcher::Status(const std::string& pMessage)
{
- std::cout << "UPDATE: " << pMessage << std::endl;
+ std::cout << "Update: " << pMessage << std::endl;
}
void CCrashWatcher::Warning(const std::string& pMessage)
{
- std::cout << "WW: " << pMessage << std::endl;
+ std::cerr << "Warning: " << pMessage << std::endl;
}
void CCrashWatcher::Debug(const std::string& pMessage)
{
//some logic to add logging levels?
- std::cout << "DEBUG: " << pMessage << std::endl;
+ std::cout << "Debug: " << pMessage << std::endl;
}
double CCrashWatcher::GetDirSize(const std::string &pPath)
@@ -219,16 +211,19 @@ CCrashWatcher::CCrashWatcher(const std::string& pPath)
{
int watch = 0;
m_sTarget = pPath;
-// create inner commlayer
-pCommLayerInner = new CCommLayerInner(this);
-//middleware object
+
+ // TODO: initialize object according parameters -w -i
+ // status has to be always created.
+ CommLayerInner::init_status(this);
+ CommLayerInner::init_warning(this);
+ CommLayerInner::init_debug(this);
+
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);
-//first init commlayer
#ifdef HAVE_DBUS
m_pCommLayer = new CCommLayerServerDBus();
#elif HAVE_SOCKET
diff --git a/src/Daemon/CrashWatcher.h b/src/Daemon/CrashWatcher.h
index bdad2663..d20cecff 100644
--- a/src/Daemon/CrashWatcher.h
+++ b/src/Daemon/CrashWatcher.h
@@ -82,9 +82,9 @@ class CCrashWatcher
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 StatusUpdate(const std::string& pMessage);
+ void Status(const std::string& pMessage);
void Debug(const std::string& pMessage);
void Warning(const std::string& pMessage);
};
diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp
index 5133902d..ab656d2f 100644
--- a/src/Daemon/Daemon.cpp
+++ b/src/Daemon/Daemon.cpp
@@ -21,18 +21,19 @@
#include <iostream>
#include <cstdio>
-CCrashWatcher *ccdaemon;
-DBus::Glib::BusDispatcher *dispatcher;
+CCrashWatcher *g_pCrashWatcher;
+//DBus::Glib::BusDispatcher *dispatcher;
void terminate(int signal)
{
fprintf(stderr, "Got SIGINT/SIGTERM, cleaning up..\n");
- delete ccdaemon;
+ delete g_pCrashWatcher;
//delete dispatcher;
exit(0);
}
-int main(int argc, char** argv){
+int main(int argc, char** argv)
+{
int daemonize = 1;
/*signal handlers */
signal(SIGTERM, terminate);
@@ -44,44 +45,29 @@ int main(int argc, char** argv){
DBus::default_dispatcher = dispatcher;
DBus::Connection conn = DBus::Connection::SystemBus();
*/
- try{
- ccdaemon = new CCrashWatcher(DEBUG_DUMPS_DIR);
- if (argc > 1){
- if (strcmp(argv[1], "-d") == 0){
- daemonize = 0;
- }
- }
- if(daemonize){
- try{
- ccdaemon->Daemonize();
- }
- catch(std::string err)
+ try
+ {
+ g_pCrashWatcher = new CCrashWatcher(DEBUG_DUMPS_DIR);
+
+ if (argc > 1)
+ {
+ if (strcmp(argv[1], "-d") == 0)
{
- std::cerr << err << std::endl;
- }
- catch(...){
- std::cerr << "daemon.cpp:Daemonize" << std::endl;
+ daemonize = 0;
}
}
- else{
- try{
- #ifdef DEBUG
- std::cerr << "trying to run" << std::endl;
- #endif /*DEBUG*/
- ccdaemon->Run();
- }
- catch(std::string err)
- {
- std::cerr << err << std::endl;
- }
- catch(...){
- std::cerr << "daemon.cpp:Run" << std::endl;
- }
+ if(daemonize)
+ {
+ g_pCrashWatcher->Daemonize();
+ }
+ else
+ {
+ g_pCrashWatcher->Run();
}
}
- catch(std::string err)
+ catch(std::exception& e)
{
- std::cerr << "Cannot create daemon: " << err << std::endl;
+ std::cerr << "Cannot create daemon: " << e.what() << std::endl;
}
}
diff --git a/src/Daemon/Makefile.am b/src/Daemon/Makefile.am
index 38c73a12..ca3a4703 100644
--- a/src/Daemon/Makefile.am
+++ b/src/Daemon/Makefile.am
@@ -2,13 +2,13 @@ sbin_PROGRAMS = abrt
abrt_SOURCES = CrashWatcher.cpp CrashWatcher.h Daemon.cpp DBusServerProxy.h \
DBusCommon.h Settings.h Settings.cpp
abrt_CPPFLAGS = -Wall -Werror -rdynamic -I../../lib/MiddleWare -I../../lib/CommLayer\
- -I../../lib/DBus \
+ -I../../lib/DBus -I../../lib/Utils\
-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
+#abrt_LDFLAGS = -Wl,--dynamic-list,exported-symbols
dbusabrtconfdir = ${sysconfdir}/dbus-1/system.d/
dist_dbusabrtconf_DATA = dbus-abrt.conf