diff options
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/applet/Makefile.am | 2 | ||||
-rw-r--r-- | src/applet/applet_gtk.c | 16 | ||||
-rw-r--r-- | src/gtk-helpers/libreport-gtk.h | 3 | ||||
-rw-r--r-- | src/gui-gtk/abrt-gtk.c | 13 | ||||
-rw-r--r-- | src/include/Makefile.am | 3 | ||||
-rw-r--r-- | src/include/report/report.h | 43 | ||||
-rw-r--r-- | src/lib/Makefile.am | 4 | ||||
-rw-r--r-- | src/lib/report.c | 96 |
9 files changed, 154 insertions, 28 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 7736a7c7..07230880 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1 +1 @@ -SUBDIRS = include lib report-python hooks btparser daemon applet gtk-helpers gui-gtk cli plugins gui-wizard-gtk retrace +SUBDIRS = include lib report-python hooks btparser daemon gtk-helpers applet gui-gtk cli plugins gui-wizard-gtk retrace diff --git a/src/applet/Makefile.am b/src/applet/Makefile.am index 4756f312..8fcd38d1 100644 --- a/src/applet/Makefile.am +++ b/src/applet/Makefile.am @@ -7,6 +7,7 @@ abrt_applet_SOURCES = \ abrt_applet_CPPFLAGS = \ -I$(srcdir)/../include/report -I$(srcdir)/../include \ -I$(srcdir)/../lib \ + -I$(srcdir)/../gtk-helpers \ -DBIN_DIR=\"$(bindir)\" \ -DVAR_RUN=\"$(VAR_RUN)\" \ -DCONF_DIR=\"$(CONF_DIR)\" \ @@ -25,6 +26,7 @@ abrt_applet_CPPFLAGS = \ abrt_applet_LDADD = \ ../lib/libreport.la \ ../lib/libabrt_dbus.la \ + ../gtk-helpers/libreportgtk.la \ -lglib-2.0 \ -lgthread-2.0 \ $(DBUS_LIBS) \ diff --git a/src/applet/applet_gtk.c b/src/applet/applet_gtk.c index 8071ec14..524aca7c 100644 --- a/src/applet/applet_gtk.c +++ b/src/applet/applet_gtk.c @@ -18,6 +18,7 @@ */ #include "abrtlib.h" #include "applet_gtk.h" +#include "libreport-gtk.h" static gboolean persistent_notification; @@ -85,20 +86,7 @@ static void action_report(NotifyNotification *notification, gchar *action, gpoin struct applet *applet = (struct applet *)user_data; if (applet->ap_daemon_running) { - pid_t pid = vfork(); - if (pid < 0) - perror_msg("vfork"); - if (pid == 0) - { /* child */ - signal(SIGCHLD, SIG_DFL); /* undo SIG_IGN in abrt-applet */ - execl(BIN_DIR"/bug-reporting-wizard", "bug-reporting-wizard", - applet->ap_last_crash_id, (char*) NULL); - /* Did not find abrt-gui in installation directory. Oh well */ - /* Trying to find it in PATH */ - execlp("bug-reporting-wizard", "bug-reporting-wizard", - applet->ap_last_crash_id, (char*) NULL); - perror_msg_and_die("Can't execute abrt-gui"); - } + analyze_and_report_dir(applet->ap_last_crash_id); GError *err = NULL; notify_notification_close(notification, &err); if (err != NULL) diff --git a/src/gtk-helpers/libreport-gtk.h b/src/gtk-helpers/libreport-gtk.h index b3baea26..9395c550 100644 --- a/src/gtk-helpers/libreport-gtk.h +++ b/src/gtk-helpers/libreport-gtk.h @@ -16,6 +16,9 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + +#include "report.h" + void show_events_list_dialog(GtkWindow *parent); void make_label_autowrap_on_resize(GtkLabel *label); void fix_all_wrapped_labels(GtkWidget *widget); diff --git a/src/gui-gtk/abrt-gtk.c b/src/gui-gtk/abrt-gtk.c index 61c5c4f9..df94485e 100644 --- a/src/gui-gtk/abrt-gtk.c +++ b/src/gui-gtk/abrt-gtk.c @@ -112,17 +112,8 @@ static void on_row_activated_cb(GtkTreeView *treeview, GtkTreePath *path, GtkTre GValue d_dir = { 0 }; gtk_tree_model_get_value(store, &iter, COLUMN_DUMP_DIR, &d_dir); - pid_t pid = vfork(); - if (pid == 0) - { - /* Undo signal(SIGCHLD, SIG_IGN), or child inherits it and gets terribly confused */ - /*signal(SIGCHLD, SIG_DFL); - not needed, we dont set it to SIG_IGN in main anymore */ - - const char *dirname= g_value_get_string(&d_dir); - VERB1 log("Executing: %s %s", "bug-reporting-wizard", dirname); - execlp("bug-reporting-wizard", "bug-reporting-wizard", dirname, NULL); - perror_msg_and_die("Can't execute %s", "bug-reporting-wizard"); - } + const char *dirname= g_value_get_string(&d_dir); + analyze_and_report_dir(dirname); } } } diff --git a/src/include/Makefile.am b/src/include/Makefile.am index eaebe3a1..4d31d1a9 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -3,7 +3,8 @@ libreport_include_HEADERS = \ report/problem_data.h \ report/dump_dir.h \ report/run_event.h \ - report/event_config.h + report/event_config.h \ + report/report.h libabrt_includedir = $(includedir)/abrt libabrt_include_HEADERS = \ diff --git a/src/include/report/report.h b/src/include/report/report.h new file mode 100644 index 00000000..1922961f --- /dev/null +++ b/src/include/report/report.h @@ -0,0 +1,43 @@ +/* + Copyright (C) 2009 Abrt team. + 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 REPORT_H_ +#define REPORT_H_ + +#include "problem_data.h" + +/* analyzes AND reports a problem saved on disk + * - takes user through all the steps in reporting wizard + */ +int analyze_and_report_dir(const char* dirname); + +/* analyzes AND reports a problem stored in problem_data_t + * it's first saved to /tmp and then processed as a dump_dir + * - takes user through all the steps in reporting wizard + */ +int analyze_and_report(problem_data_t *pd); + +/* reports a problem saved on disk + * - shows only reporter selector and progress +*/ +int report_dir(const char* dirname); + +/* to report a problem stored in memory */ +int report(problem_data_t *pd); + +#endif /* REPORT_H_ */ diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 88671f54..6493db99 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -46,7 +46,8 @@ libreport_la_SOURCES = \ abrt_conf.c abrt_conf.h \ steal_directory.c \ event_xml_parser.c \ - event_config.c + event_config.c \ + report.c libreport_la_CPPFLAGS = \ -Wall -Wwrite-strings -Werror \ -I$(srcdir)/../include/report -I$(srcdir)/../include \ @@ -57,6 +58,7 @@ libreport_la_CPPFLAGS = \ -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \ -DCONF_DIR=\"$(CONF_DIR)\" \ -DEVENTS_DIR=\"$(EVENTS_DIR)\" \ + -DBIN_DIR=\"$(bindir)\" \ $(GLIB_CFLAGS) \ -D_GNU_SOURCE libreport_la_LDFLAGS = \ diff --git a/src/lib/report.c b/src/lib/report.c new file mode 100644 index 00000000..f1729efc --- /dev/null +++ b/src/lib/report.c @@ -0,0 +1,96 @@ +/* + 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 "abrtlib.h" + +int analyze_and_report_dir(const char* dirname) +{ + /* + if is isatty -> run cli reporter + */ + pid_t pid = vfork(); + if (pid == 0) + { + /* Undo signal(SIGCHLD, SIG_IGN), or child inherits it and gets terribly confused */ + signal(SIGCHLD, SIG_DFL); // applet still set it to SIG_IGN + VERB1 log("Executing: %s %s", "bug-reporting-wizard", dirname); + execl(BIN_DIR"/bug-reporting-wizard", "bug-reporting-wizard", dirname, NULL); + // note the -o in options which means --report-only + /* Did not find abrt-gui in installation directory. Oh well */ + /* Trying to find it in PATH */ + execlp("bug-reporting-wizard", "bug-reporting-wizard", dirname, NULL); + perror_msg_and_die("Can't execute %s", "bug-reporting-wizard"); + } + return 0; +} + +/* analyzes AND reports a problem saved on disk + * - takes user through all the steps in reporting wizard + */ +int analyze_and_report(problem_data_t *pd) +{ + struct dump_dir *dd = create_dump_dir_from_problem_data(pd, "/tmp"/* /var/tmp ?? */); + if (!dd) + return -1; + char *dir_name = strdup(dd->dd_dirname); + dd_close(dd); + VERB2 log("Temp problem dir: '%s'\n", dir_name); + analyze_and_report_dir(dir_name); + free(dir_name); + + return 0; +} + +/* reports a problem saved on disk + * - shows only reporter selector and progress +*/ +int report_dir(const char* dirname) +{ + pid_t pid = vfork(); + if (pid == 0) + { + /* Undo signal(SIGCHLD, SIG_IGN), or child inherits it and gets terribly confused */ + signal(SIGCHLD, SIG_DFL); // applet still set it to SIG_IGN + VERB1 log("Executing: %s %s", "bug-reporting-wizard", dirname); + execl(BIN_DIR"/bug-reporting-wizard", "bug-reporting-wizard", + "-o", dirname, NULL); + // note the -o in options which means --report-only + /* Did not find abrt-gui in installation directory. Oh well */ + /* Trying to find it in PATH */ + execlp("bug-reporting-wizard", "bug-reporting-wizard", + "-o", dirname, NULL); + perror_msg_and_die("Can't execute %s", "bug-reporting-wizard"); + } + return 0; +} + +int report(problem_data_t *pd) +{ + struct dump_dir *dd = create_dump_dir_from_problem_data(pd, "/tmp"/* /var/tmp ?? */); + if (!dd) + return -1; + char *dir_name = strdup(dd->dd_dirname); + dd_close(dd); + VERB2 log("Temp problem dir: '%s'\n", dir_name); + report_dir(dir_name); + free(dir_name); + + return 0; +} + |