summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorZdenek Prikryl <zprikryl@redhat.com>2009-02-25 17:42:58 +0100
committerZdenek Prikryl <zprikryl@redhat.com>2009-02-25 17:42:58 +0100
commitb0f7c3729302bf66f96eedecb8633ed8e196f122 (patch)
treee00d494ee3762b0f3c7a5eb687b96a2f94f315d6 /src
parentebb7e355ca60e6f4913c65b2dfa439100312e5eb (diff)
parent302ec0b154a33209e187d0993dfbdd8c8d27d365 (diff)
downloadabrt-b0f7c3729302bf66f96eedecb8633ed8e196f122.tar.gz
abrt-b0f7c3729302bf66f96eedecb8633ed8e196f122.tar.xz
abrt-b0f7c3729302bf66f96eedecb8633ed8e196f122.zip
Merge branch 'master' of git://git.fedorahosted.org/crash-catcher
Conflicts: lib/MiddleWare/CrashTypes.h
Diffstat (limited to 'src')
-rw-r--r--src/Daemon/CrashWatcher.cpp42
-rw-r--r--src/Daemon/CrashWatcher.h4
-rw-r--r--src/Daemon/DBusCommon.h1
-rw-r--r--src/Daemon/DBusServerProxy.h32
-rw-r--r--src/Daemon/Daemon.cpp13
-rw-r--r--src/Gui/CCDBusBackend.py7
-rw-r--r--src/Gui/CCMainWindow.py12
-rw-r--r--src/Gui/CCReport.py30
-rw-r--r--src/Gui/CCReporterDialog.py34
-rw-r--r--src/Gui/Makefile.am2
10 files changed, 147 insertions, 30 deletions
diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp
index f1b6828..787412e 100644
--- a/src/Daemon/CrashWatcher.cpp
+++ b/src/Daemon/CrashWatcher.cpp
@@ -108,6 +108,7 @@ CCrashWatcher::CCrashWatcher(const std::string& pPath,DBus::Connection &connecti
CCrashWatcher::~CCrashWatcher()
{
//delete dispatcher, connection, etc..
+ delete m_pMW;
}
dbus_vector_crash_infos_t CCrashWatcher::GetCrashInfos(const std::string &pUID)
@@ -121,11 +122,11 @@ dbus_vector_crash_infos_t CCrashWatcher::GetCrashInfos(const std::string &pUID)
return retval;
}
-dbus_vector_map_crash_infos_t CCrashWatcher::GetCrashInfosMap(const std::string &pUID)
+dbus_vector_map_crash_infos_t CCrashWatcher::GetCrashInfosMap(const std::string &pDBusSender)
{
dbus_vector_map_crash_infos_t retval;
vector_crash_infos_t crash_info;
- unsigned long unix_uid = m_pConn->sender_unix_uid(pUID.c_str());
+ unsigned long unix_uid = m_pConn->sender_unix_uid(pDBusSender.c_str());
crash_info = m_pMW->GetCrashInfos(to_string(unix_uid));
for (vector_crash_infos_t::iterator it = crash_info.begin(); it!=crash_info.end(); ++it) {
retval.push_back(it->GetMap());
@@ -133,6 +134,39 @@ dbus_vector_map_crash_infos_t CCrashWatcher::GetCrashInfosMap(const std::string
return retval;
}
+dbus_map_report_info_t CCrashWatcher::CreateReport(const std::string &pUUID,const std::string &pDBusSender)
+{
+ dbus_map_report_info_t retval;
+ unsigned long unix_uid = m_pConn->sender_unix_uid(pDBusSender.c_str());
+ std::cerr << pUUID << ":" << unix_uid << std::endl;
+ crash_context_t crashContext;
+ crash_report_t crashReport;
+ std::cerr << "Creating report" << std::endl;
+ m_pMW->CreateReport(pUUID,to_string(unix_uid),crashContext, crashReport);
+ retval = crashReport.GetMap();
+ return retval;
+}
+
+bool CCrashWatcher::Report(dbus_map_report_info_t pReport)
+{
+ crash_context_t crashContext;
+ crash_report_t crashReport;
+ //#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;
+ //}
+ crashContext.m_sUUID = "1234";
+ crashContext.m_sUID = "12345";
+ crashContext.m_sLanAppPlugin = "CCpp";
+ crashReport.setFromMap(pReport);
+ std::cerr << crashReport.m_sPackage << std::endl;
+ m_pMW->Report(crashContext, crashReport);
+ return true;
+}
+
void CCrashWatcher::Lock()
{
int lfp = open("crashcatcher.lock",O_RDWR|O_CREAT,0640);
@@ -174,15 +208,11 @@ void CCrashWatcher::StartWatch()
/* daemon loop with glib */
void CCrashWatcher::GStartWatch()
{
- char *buff = new char[INOTIFY_BUFF_SIZE];
- int len = 0;
- int i = 0;
char action[FILENAME_MAX];
struct inotify_event *pevent;
g_io_add_watch (m_nGio, G_IO_IN, handle_event_cb, this);
//enter the event loop
g_main_run (m_nMainloop);
- delete[] buff;
}
diff --git a/src/Daemon/CrashWatcher.h b/src/Daemon/CrashWatcher.h
index b2e545f..d1f08df 100644
--- a/src/Daemon/CrashWatcher.h
+++ b/src/Daemon/CrashWatcher.h
@@ -60,7 +60,9 @@ class CCrashWatcher
/* methods exported on dbus */
public:
dbus_vector_crash_infos_t GetCrashInfos(const std::string &pUID);
- dbus_vector_map_crash_infos_t GetCrashInfosMap(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);
};
diff --git a/src/Daemon/DBusCommon.h b/src/Daemon/DBusCommon.h
index 186a74a..1e26e39 100644
--- a/src/Daemon/DBusCommon.h
+++ b/src/Daemon/DBusCommon.h
@@ -24,3 +24,4 @@
//typedef std::vector<crash_info_t> vector_crash_infos_t;
typedef std::vector< std::vector<std::string> > dbus_vector_crash_infos_t;
typedef std::vector< std::map<std::string, std::string> > dbus_vector_map_crash_infos_t;
+typedef std::map<std::string, std::string> dbus_map_report_info_t;
diff --git a/src/Daemon/DBusServerProxy.h b/src/Daemon/DBusServerProxy.h
index 5b8f688..8bb9b6b 100644
--- a/src/Daemon/DBusServerProxy.h
+++ b/src/Daemon/DBusServerProxy.h
@@ -31,6 +31,8 @@ public:
{
register_method(CDBusServer_adaptor, GetCrashInfos, _GetCrashInfos_stub);
register_method(CDBusServer_adaptor, GetCrashInfosMap, _GetCrashInfosMap_stub);
+ register_method(CDBusServer_adaptor, CreateReport, _CreateReport_stub);
+ register_method(CDBusServer_adaptor, Report, _Report_stub);
}
/* reveal Interface introspection when we stabilize the API */
/*
@@ -85,7 +87,9 @@ public:
* you will have to implement them in your ObjectAdaptor
*/
virtual dbus_vector_crash_infos_t GetCrashInfos(const std::string &pUID) = 0;
- virtual dbus_vector_map_crash_infos_t GetCrashInfosMap(const std::string &pUID) = 0;
+ virtual dbus_vector_map_crash_infos_t GetCrashInfosMap(const std::string &pDBusSender) = 0;
+ virtual dbus_map_report_info_t CreateReport(const std::string &pUUID,const std::string &pDBusSender) = 0;
+ virtual bool Report(dbus_map_report_info_t pReport) = 0;
public:
@@ -116,16 +120,40 @@ private:
return reply;
}
- DBus::Message _GetCrashInfosMap_stub(const DBus::CallMessage &call)
+ DBus::Message _CreateReport_stub(const DBus::CallMessage &call)
{
DBus::MessageIter ri = call.reader();
std::string argin1; ri >> argin1;
+ dbus_map_report_info_t argout1 = CreateReport(argin1,call.sender());
+ DBus::ReturnMessage reply(call);
+ DBus::MessageIter wi = reply.writer();
+ wi << argout1;
+ return reply;
+ }
+
+ DBus::Message _GetCrashInfosMap_stub(const DBus::CallMessage &call)
+ {
+ DBus::MessageIter ri = call.reader();
+
+ //std::string argin1; ri >> argin1;
dbus_vector_map_crash_infos_t argout1 = GetCrashInfosMap(call.sender());
DBus::ReturnMessage reply(call);
DBus::MessageIter wi = reply.writer();
wi << argout1;
return reply;
}
+
+ DBus::Message _Report_stub(const DBus::CallMessage &call)
+ {
+ DBus::MessageIter ri = call.reader();
+
+ dbus_map_report_info_t argin1; ri >> argin1;
+ bool argout1 = Report(argin1);
+ DBus::ReturnMessage reply(call);
+ DBus::MessageIter wi = reply.writer();
+ wi << argout1;
+ return reply;
+ }
};
diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp
index 835b76f..b5d6cbe 100644
--- a/src/Daemon/Daemon.cpp
+++ b/src/Daemon/Daemon.cpp
@@ -21,7 +21,6 @@
#include <iostream>
#include <cstdio>
-#define daemonize 0
CCrashWatcher *ccdaemon;
DBus::Glib::BusDispatcher *dispatcher;
@@ -34,6 +33,7 @@ void terminate(int signal)
}
int main(int argc, char** argv){
+ int daemonize = 1;
/*signal handlers */
signal(SIGTERM, terminate);
signal(SIGINT, terminate);
@@ -45,13 +45,12 @@ int main(int argc, char** argv){
DBus::Connection conn = DBus::Connection::SystemBus();
try{
- //CCrashWatcher daemon(DEBUG_DUMPS_DIR, conn);
ccdaemon = new CCrashWatcher(DEBUG_DUMPS_DIR, conn);
- //if (argc > 1){
- // if (strcmp(argv[1], "-d") == 0){
- // daemonize = 0;
- // }
- // }
+ if (argc > 1){
+ if (strcmp(argv[1], "-d") == 0){
+ daemonize = 0;
+ }
+ }
if(daemonize){
try{
ccdaemon->Daemonize();
diff --git a/src/Gui/CCDBusBackend.py b/src/Gui/CCDBusBackend.py
index ad3e82c..2235e78 100644
--- a/src/Gui/CCDBusBackend.py
+++ b/src/Gui/CCDBusBackend.py
@@ -48,9 +48,16 @@ class DBusManager(gobject.GObject):
except Exception, e:
raise Exception(e.message + "\nPlease check if crash-catcher daemon is running.")
+ def getReport(self, UUID):
+ return self.cc.CreateReport(UUID)
+
+ def Report(self,report):
+ return self.cc.Report(report)
+
def getDumps(self):
row_dict = None
rows = []
+ # FIXME check the arguments
for row in self.cc.GetCrashInfosMap(""):
row_dict = {}
for column in row:
diff --git a/src/Gui/CCMainWindow.py b/src/Gui/CCMainWindow.py
index 02f2a03..a579ee4 100644
--- a/src/Gui/CCMainWindow.py
+++ b/src/Gui/CCMainWindow.py
@@ -10,6 +10,7 @@ import sys
from CC_gui_functions import *
from CCDumpList import getDumpList, DumpList
from CCReporterDialog import ReporterDialog
+from CCReport import Report
def cb(self, *args):
pass
@@ -95,7 +96,7 @@ class MainWindow():
#self.rows = self.ccdaemon.getDumps()
#row_c = 0
for entry in dumplist:
- self.dumpsListStore.append([entry.getTime("%Y:%m:%d"),entry.getPackage(),entry])
+ self.dumpsListStore.append([entry.getTime("%m.%d."),entry.getPackage(),entry])
#row_c += 1
def on_tvDumps_cursor_changed(self,treeview):
@@ -125,8 +126,13 @@ class MainWindow():
return
dump = dumpsListStore.get_value(dumpsListStore.get_iter(path[0]), len(self.dlist.get_columns()))
# show the report window with selected dump
- report_dialog = ReporterDialog(dump)
- report_dialog.run()
+ report = self.ccdaemon.getReport(dump.getUUID())
+ report_dialog = ReporterDialog(report)
+ result = report_dialog.run()
+ if result == -1:
+ pass
+ else:
+ self.ccdaemon.Report(result)
def on_bQuit_clicked(self, button):
gtk.main_quit()
diff --git a/src/Gui/CCReport.py b/src/Gui/CCReport.py
new file mode 100644
index 0000000..ea2ed75
--- /dev/null
+++ b/src/Gui/CCReport.py
@@ -0,0 +1,30 @@
+from datetime import datetime
+
+class Report():
+ """Class for mapping the report to pyhon object"""
+ def __init__(self, report):
+ self.UUID = None
+ self.Architecture = None
+ self.Kernel = None
+ self.Release = None
+ self.Executable = None
+ self.CmdLine = None
+ self.Package = None
+ self.TextData1 = None
+ self.TextData2 = None
+ self.BinaryData1 = None
+ self.BinaryData2 = None
+ for item in report:
+ self.__dict__[item] = report[item]
+
+ def getUUID(self):
+ return self.UUID
+
+ def getArchitecture(self):
+ return self.Architecture
+
+ def getExecutable(self):
+ return self.Executable
+
+ def getPackage(self):
+ return self.Package
diff --git a/src/Gui/CCReporterDialog.py b/src/Gui/CCReporterDialog.py
index fa6e242..c186de1 100644
--- a/src/Gui/CCReporterDialog.py
+++ b/src/Gui/CCReporterDialog.py
@@ -4,12 +4,13 @@ import gtk
import gtk.glade
import sys
from CC_gui_functions import *
-from CCDumpList import getDumpList, DumpList
+from CCReport import Report
+#from CCDumpList import getDumpList, DumpList
class ReporterDialog():
"""Reporter window"""
- def __init__(self, dump):
- self.dump = dump
+ def __init__(self, report):
+ self.report = report
#Set the Glade file
# FIXME add to path
self.gladefile = "../share/crash-catcher/ccgui.glade"
@@ -17,7 +18,7 @@ class ReporterDialog():
#Get the Main Window, and connect the "destroy" event
self.window = self.wTree.get_widget("reporter_dialog")
- #init the dumps treeview
+ #init the reports treeview
self.tvReport = self.wTree.get_widget("tvReport")
columns = [None]*2
columns[0] = gtk.TreeViewColumn('Item')
@@ -26,7 +27,7 @@ class ReporterDialog():
self.reportListStore = gtk.ListStore(str, str, bool)
# set filter
#self.modelfilter = self.reportListStore.filter_new()
- #self.modelfilter.set_visible_func(self.filter_dumps, None)
+ #self.modelfilter.set_visible_func(self.filter_reports, None)
self.tvReport.set_model(self.reportListStore)
renderer = gtk.CellRendererText()
column = gtk.TreeViewColumn('Item', renderer, text=0)
@@ -39,6 +40,7 @@ class ReporterDialog():
# connect the signals
self.wTree.get_widget("bApply").connect("clicked", self.on_apply_clicked, self.tvReport)
+ self.wTree.get_widget("bCancel").connect("clicked", self.on_cancel_clicked, self.tvReport)
self.hydrate()
@@ -49,14 +51,26 @@ class ReporterDialog():
def on_apply_clicked(self, button, treeview):
#print treeview
- self.window.hide()
+ #self.window.destroy();
+ print self.report
+ return self.report
+ def on_cancel_clicked(self, button, treeview):
+ #print treeview
+ #self.window.destroy();
+ return -1
+
def hydrate(self):
- for item in self.dump.__dict__:
- self.reportListStore.append([item, self.dump.__dict__[item], False])
+ for item in self.report:
+ self.reportListStore.append([item, self.report[item], False])
self.reportListStore.append(["Comment","", True])
def run(self):
- self.window.show()
-
+ result = self.window.run()
+ if result == -1:
+ self.window.destroy()
+ return -1
+ else:
+ self.window.destroy()
+ return self.report
diff --git a/src/Gui/Makefile.am b/src/Gui/Makefile.am
index f604c79..a4d20b7 100644
--- a/src/Gui/Makefile.am
+++ b/src/Gui/Makefile.am
@@ -2,7 +2,7 @@
bin_SCRIPTS = cc-gui
-PYTHON_FILES = CCDBusBackend.py CCDumpList.py CCDump.py CC_gui_functions.py ccgui.glade CCReporterDialog.py CCMainWindow.py
+PYTHON_FILES = CCDBusBackend.py CCDumpList.py CCDump.py CC_gui_functions.py ccgui.glade CCReporterDialog.py CCReport.py CCMainWindow.py
GLADE_FILES = ccgui.glade