248
by Michael Vogt
* src/crash.{c,h}: |
1 |
#ifdef HAVE_CONFIG_H
|
2 |
#include "config.h" |
|
3 |
#endif
|
|
4 |
||
5 |
#include <sys/types.h> |
|
6 |
#include <sys/stat.h> |
|
7 |
#include <unistd.h> |
|
8 |
||
9 |
#include <libnotify/notify.h> |
|
10 |
||
11 |
#include "update-notifier.h" |
|
12 |
#include "update.h" |
|
643
by Michael Vogt
* add #include "trayappletui.h" to ensure the prototypes are |
13 |
#include "trayappletui.h" |
279
by Michael Vogt
* src/update-notifier.{c,h}: |
14 |
|
276.1.1
by martin at piware
* src/crash.c: If the user is an admin, also check for crashes of system |
15 |
static gboolean |
754
by Colin Watson
Correct a number of imprecise prototypes. |
16 |
check_system_crashes(void) |
17 |
{
|
|
276.1.1
by martin at piware
* src/crash.c: If the user is an admin, also check for crashes of system |
18 |
int exitcode; |
280
by Michael Vogt
* src/crash.c: |
19 |
|
279
by Michael Vogt
* src/update-notifier.{c,h}: |
20 |
if(!in_admin_group()) |
21 |
return FALSE; |
|
276.1.1
by martin at piware
* src/crash.c: If the user is an admin, also check for crashes of system |
22 |
|
23 |
// check for system crashes
|
|
608
by Michael Vogt
* src/crash.c: |
24 |
gchar *argv[] = { CRASHREPORT_HELPER, "--system", NULL }; |
25 |
if(!g_spawn_sync(NULL, |
|
26 |
argv, |
|
27 |
NULL, |
|
28 |
G_SPAWN_STDOUT_TO_DEV_NULL|G_SPAWN_STDERR_TO_DEV_NULL, |
|
29 |
NULL, |
|
30 |
NULL, |
|
31 |
NULL, |
|
32 |
NULL, |
|
33 |
&exitcode, |
|
34 |
NULL)) { |
|
771
by Colin Watson
Remove unnecessary trailing newlines from all debugging messages. |
35 |
g_warning("Can not run %s", CRASHREPORT_HELPER); |
276.1.1
by martin at piware
* src/crash.c: If the user is an admin, also check for crashes of system |
36 |
return FALSE; |
37 |
}
|
|
38 |
||
39 |
return exitcode == 0; |
|
40 |
}
|
|
41 |
||
610
by Michael Vogt
* src/crash.c: |
42 |
static gboolean |
754
by Colin Watson
Correct a number of imprecise prototypes. |
43 |
ask_invoke_apport_with_pkexec(void) |
610
by Michael Vogt
* src/crash.c: |
44 |
{
|
45 |
GtkDialog *dialog; |
|
46 |
gchar *msg = _("System program problem detected"); |
|
613
by Michael Vogt
src/crash.c: fix typo (thanks to seb128) |
47 |
gchar *descr = _("Do you want to report the problem " |
610
by Michael Vogt
* src/crash.c: |
48 |
"now?"); |
614
by Michael Vogt
src/crash.c: make -Wall clean |
49 |
dialog = (GtkDialog*)gtk_message_dialog_new (NULL, |
610
by Michael Vogt
* src/crash.c: |
50 |
GTK_DIALOG_DESTROY_WITH_PARENT, |
51 |
GTK_MESSAGE_QUESTION, |
|
52 |
GTK_BUTTONS_NONE, |
|
614
by Michael Vogt
src/crash.c: make -Wall clean |
53 |
"%s", msg); |
54 |
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), |
|
55 |
"%s", descr); |
|
610
by Michael Vogt
* src/crash.c: |
56 |
gtk_dialog_add_button(dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); |
57 |
gtk_dialog_add_button(dialog, _("Report problem…"), GTK_RESPONSE_ACCEPT); |
|
58 |
int res = gtk_dialog_run(dialog); |
|
614
by Michael Vogt
src/crash.c: make -Wall clean |
59 |
gtk_widget_destroy(GTK_WIDGET(dialog)); |
610
by Michael Vogt
* src/crash.c: |
60 |
if (res == GTK_RESPONSE_ACCEPT) |
61 |
return TRUE; |
|
62 |
return FALSE; |
|
63 |
}
|
|
64 |
||
798
by Brian Murray
more whitespace cleanup |
65 |
static gboolean |
262
by Michael Vogt
* src/crash.c: |
66 |
run_apport(TrayApplet *ta) |
253
by Michael Vogt
* improved the crash report handling: |
67 |
{
|
771
by Colin Watson
Remove unnecessary trailing newlines from all debugging messages. |
68 |
g_debug("fire up the crashreport tool"); |
751
by Brian Murray
Switch from using gksu for apport crashes to pkexec (LP: #1098235) |
69 |
// be nice and always ask first before firing up pkexec
|
914.2.1
by Sebastien Bacher
src/crash.c: don't prompt about system reports under wayland, pkexec |
70 |
if (check_system_crashes()) { |
71 |
// workaround, wayland doesn't allow pkexec use
|
|
72 |
if (g_strcmp0 (g_getenv ("XDG_SESSION_TYPE"), "wayland") == 0) |
|
73 |
g_debug ("no pkexec for system reports under wayland"); |
|
74 |
else if (ask_invoke_apport_with_pkexec()) |
|
75 |
invoke_with_pkexec(CRASHREPORT_REPORT_APP); |
|
612
by Michael Vogt
src/crash.c: still run apport (just without gksu) if the user declines to report the system crashes |
76 |
} else { |
610
by Michael Vogt
* src/crash.c: |
77 |
return g_spawn_command_line_async(CRASHREPORT_REPORT_APP, NULL); |
612
by Michael Vogt
src/crash.c: still run apport (just without gksu) if the user declines to report the system crashes |
78 |
}
|
79 |
return TRUE; |
|
253
by Michael Vogt
* improved the crash report handling: |
80 |
}
|
248
by Michael Vogt
* src/crash.{c,h}: |
81 |
|
334
by Michael Vogt
* fix crash in leftover from pre-GtkStatusIcon code (LP: #127965) |
82 |
static gboolean |
248
by Michael Vogt
* src/crash.{c,h}: |
83 |
show_notification (TrayApplet *ta) |
84 |
{
|
|
329
by Michael Vogt
* use GtkStatusIcon instead of EggTrayIcon, that makes |
85 |
NotifyNotification *n; |
86 |
||
798
by Brian Murray
more whitespace cleanup |
87 |
// check if the update-icon is still visible (in the delay time a
|
365
by Michael Vogt
* src/update.c, src/crash.c, src/hooks.c: |
88 |
// update may already have been performed)
|
639.1.4
by Michael Vogt
add trayappletui abstraction, port everything over to it |
89 |
if(!tray_applet_ui_get_visible(ta)) |
365
by Michael Vogt
* src/update.c, src/crash.c, src/hooks.c: |
90 |
return FALSE; |
91 |
||
760
by Colin Watson
Fix several leaks of NotifyNotification objects. |
92 |
n = tray_applet_ui_get_data (ta, "notification"); |
93 |
if (n) |
|
94 |
g_object_unref (n); |
|
95 |
tray_applet_ui_set_data (ta, "notification", NULL); |
|
96 |
||
798
by Brian Murray
more whitespace cleanup |
97 |
// now show a notification handle
|
628
by Martin Pitt
Port to current libnotify 0.7 API. Bump libnotify-dev build dependency. |
98 |
n = notify_notification_new( |
329
by Michael Vogt
* use GtkStatusIcon instead of EggTrayIcon, that makes |
99 |
_("Crash report detected"), |
301
by Jonathan Riddell
Fix grammer, A application -> An Application |
100 |
_("An application has crashed on your " |
248
by Michael Vogt
* src/crash.{c,h}: |
101 |
"system (now or in the past). "
|
102 |
"Click on the notification icon to "
|
|
103 |
"display details. "
|
|
104 |
),
|
|
628
by Martin Pitt
Port to current libnotify 0.7 API. Bump libnotify-dev build dependency. |
105 |
GTK_STOCK_DIALOG_INFO); |
106 |
notify_notification_set_timeout (n, 60000); |
|
107 |
notify_notification_show (n, NULL); |
|
759
by Colin Watson
Restore code to keep a handle to crash and reboot notifications, so that |
108 |
tray_applet_ui_set_data (ta, "notification", n); |
248
by Michael Vogt
* src/crash.{c,h}: |
109 |
|
628
by Martin Pitt
Port to current libnotify 0.7 API. Bump libnotify-dev build dependency. |
110 |
return FALSE; |
248
by Michael Vogt
* src/crash.{c,h}: |
111 |
}
|
112 |
||
798
by Brian Murray
more whitespace cleanup |
113 |
static void |
262
by Michael Vogt
* src/crash.c: |
114 |
hide_crash_applet(TrayApplet *ta) |
115 |
{
|
|
116 |
NotifyNotification *n; |
|
798
by Brian Murray
more whitespace cleanup |
117 |
|
262
by Michael Vogt
* src/crash.c: |
118 |
/* Hide any notification popup */
|
639.1.4
by Michael Vogt
add trayappletui abstraction, port everything over to it |
119 |
n = tray_applet_ui_get_data (ta, "notification"); |
760
by Colin Watson
Fix several leaks of NotifyNotification objects. |
120 |
if (n) { |
262
by Michael Vogt
* src/crash.c: |
121 |
notify_notification_close (n, NULL); |
760
by Colin Watson
Fix several leaks of NotifyNotification objects. |
122 |
g_object_unref (n); |
123 |
}
|
|
773
by Colin Watson
Only create most indicators (or tray icons) when they're actually being |
124 |
tray_applet_ui_destroy (ta); |
125 |
}
|
|
126 |
||
127 |
static gboolean |
|
128 |
button_release_cb (GtkWidget *widget, |
|
129 |
TrayApplet *ta) |
|
130 |
{
|
|
131 |
run_apport(ta); |
|
132 |
hide_crash_applet(ta); |
|
133 |
return TRUE; |
|
262
by Michael Vogt
* src/crash.c: |
134 |
}
|
135 |
||
248
by Michael Vogt
* src/crash.{c,h}: |
136 |
gboolean
|
137 |
crashreport_check (TrayApplet *ta) |
|
138 |
{
|
|
139 |
int crashreports_found = 0; |
|
282
by Martin Pitt
* src/crash.c: Only show a notification for system crash reports, do not |
140 |
gboolean system_crashes; |
771
by Colin Watson
Remove unnecessary trailing newlines from all debugging messages. |
141 |
g_debug("crashreport_check"); |
611
by Michael Vogt
honor the /apps/update-notifier/auto_launch gconf key, if that is |
142 |
|
257
by Michael Vogt
* debian/control: |
143 |
// don't do anything if no apport-gtk is installed
|
144 |
if(!g_file_test(CRASHREPORT_REPORT_APP, G_FILE_TEST_IS_EXECUTABLE)) |
|
254
by Michael Vogt
* src/crash.c, src/hooks.c: |
145 |
return FALSE; |
248
by Michael Vogt
* src/crash.{c,h}: |
146 |
|
937
by Didier Roche
Only show apport UI if whoopsie is not in auto or never reporting mode. |
147 |
// don't do anything if autoreport is enabled
|
148 |
if (g_file_test(CRASHREPORT_AUTOREPORT, G_FILE_TEST_EXISTS)) |
|
149 |
return FALSE; |
|
150 |
||
939.1.1
by Brian Murray
Fix a typo |
151 |
// if whoopsie is installed, but disabled, don't do anything
|
937
by Didier Roche
Only show apport UI if whoopsie is not in auto or never reporting mode. |
152 |
if (g_file_test(CRASHREPORT_WHOOPSIE_EXEC, G_FILE_TEST_IS_EXECUTABLE)) { |
153 |
int exitcode; |
|
940
by Didier Roche
* Use absolute patch when testing if whoopsie service is enabled. |
154 |
gchar *argv[] = { "/bin/systemctl", "is-enabled", "-q", CRASHREPORT_WHOOPSIE_SERVICE, NULL }; |
937
by Didier Roche
Only show apport UI if whoopsie is not in auto or never reporting mode. |
155 |
if (g_spawn_sync(NULL, argv, NULL, G_SPAWN_STDOUT_TO_DEV_NULL|G_SPAWN_STDERR_TO_DEV_NULL, |
156 |
NULL, NULL, NULL, NULL, &exitcode, NULL)) { |
|
940
by Didier Roche
* Use absolute patch when testing if whoopsie service is enabled. |
157 |
if (exitcode != 0) { |
158 |
g_debug("whoopsie disabled, not displaying crashes"); |
|
159 |
return FALSE; |
|
160 |
}
|
|
937
by Didier Roche
Only show apport UI if whoopsie is not in auto or never reporting mode. |
161 |
}
|
162 |
}
|
|
163 |
||
311
by Martin Pitt
* src/crash.c: Do not show apport crash reports if above gconf key is false. |
164 |
// Check whether the user doesn't want notifications
|
750.1.1
by Colin Watson
Only create a single GSettings instance for com.ubuntu.update-notifier, |
165 |
if (!g_settings_get_boolean (ta->un->settings, |
166 |
SETTINGS_KEY_APPORT_NOTIFICATIONS)) { |
|
630.1.4
by Michael Terry
convert to gsettings |
167 |
g_debug("apport notifications disabled, not displaying crashes"); |
607
by Michael Vogt
merged from seb128, modified slightly to make the unity special case more obvious |
168 |
return FALSE; |
311
by Martin Pitt
* src/crash.c: Do not show apport crash reports if above gconf key is false. |
169 |
}
|
170 |
||
257
by Michael Vogt
* debian/control: |
171 |
// check for (new) reports by calling CRASHREPORT_HELPER
|
172 |
// and checking the return code
|
|
173 |
int exitcode; |
|
608
by Michael Vogt
* src/crash.c: |
174 |
gchar *argv[] = { CRASHREPORT_HELPER, NULL }; |
175 |
if(!g_spawn_sync(NULL, |
|
176 |
argv, |
|
177 |
NULL, |
|
178 |
G_SPAWN_STDOUT_TO_DEV_NULL|G_SPAWN_STDERR_TO_DEV_NULL, |
|
179 |
NULL, |
|
180 |
NULL, |
|
181 |
NULL, |
|
182 |
NULL, |
|
183 |
&exitcode, |
|
184 |
NULL)) { |
|
771
by Colin Watson
Remove unnecessary trailing newlines from all debugging messages. |
185 |
g_warning("Can not run %s", CRASHREPORT_HELPER); |
257
by Michael Vogt
* debian/control: |
186 |
return FALSE; |
248
by Michael Vogt
* src/crash.{c,h}: |
187 |
}
|
763
by Colin Watson
typos |
188 |
// exitcode == 0: reports found, else no reports
|
282
by Martin Pitt
* src/crash.c: Only show a notification for system crash reports, do not |
189 |
system_crashes = check_system_crashes(); |
190 |
crashreports_found = !exitcode || system_crashes; |
|
248
by Michael Vogt
* src/crash.{c,h}: |
191 |
|
795
by Brian Murray
* Remove support for choosing not to auto-launch applications (LP: #947008) |
192 |
if (crashreports_found > 0) { |
193 |
g_debug("crashreport found running apport now"); |
|
194 |
crashreports_found=0; |
|
195 |
run_apport(ta); |
|
196 |
return TRUE; |
|
197 |
} else |
|
198 |
return FALSE; |
|
611
by Michael Vogt
honor the /apps/update-notifier/auto_launch gconf key, if that is |
199 |
|
200 |
// non-autolaunch will always use the notification area
|
|
639.1.4
by Michael Vogt
add trayappletui abstraction, port everything over to it |
201 |
gboolean visible = tray_applet_ui_get_visible(ta); |
639.1.1
by Michael Vogt
start app-indicator port |
202 |
|
798
by Brian Murray
more whitespace cleanup |
203 |
// crashreport found
|
611
by Michael Vogt
honor the /apps/update-notifier/auto_launch gconf key, if that is |
204 |
if(crashreports_found > 0 && !visible) { |
773
by Colin Watson
Only create most indicators (or tray icons) when they're actually being |
205 |
tray_applet_ui_ensure(ta); |
206 |
tray_applet_ui_set_single_action(ta, _("Crash report detected"), |
|
207 |
G_CALLBACK(button_release_cb), ta); |
|
639.1.4
by Michael Vogt
add trayappletui abstraction, port everything over to it |
208 |
tray_applet_ui_set_visible(ta, TRUE); |
311
by Martin Pitt
* src/crash.c: Do not show apport crash reports if above gconf key is false. |
209 |
/* Show the notification, after a delay so it doesn't look ugly
|
210 |
* if we've just logged in */
|
|
777
by Colin Watson
Switch from g_timeout_add to g_timeout_add_seconds everywhere, which |
211 |
g_timeout_add_seconds(5, (GSourceFunc)(show_notification), ta); |
253
by Michael Vogt
* improved the crash report handling: |
212 |
}
|
260
by Michael Vogt
* src/crash.c: |
213 |
|
253
by Michael Vogt
* improved the crash report handling: |
214 |
// no crashreports, but visible
|
260
by Michael Vogt
* src/crash.c: |
215 |
if((crashreports_found == 0) && visible) { |
262
by Michael Vogt
* src/crash.c: |
216 |
hide_crash_applet(ta); |
248
by Michael Vogt
* src/crash.{c,h}: |
217 |
}
|
218 |
||
219 |
return TRUE; |
|
220 |
}
|
|
221 |
||
222 |
static gboolean |
|
610
by Michael Vogt
* src/crash.c: |
223 |
crashreport_check_initially(TrayApplet *ta) |
224 |
{
|
|
225 |
crashreport_check(ta); |
|
226 |
// stop timeout handler
|
|
227 |
return FALSE; |
|
228 |
}
|
|
248
by Michael Vogt
* src/crash.{c,h}: |
229 |
|
230 |
void
|
|
231 |
crashreport_tray_icon_init (TrayApplet *ta) |
|
232 |
{
|
|
233 |
/* Check for crashes for the first time */
|
|
614
by Michael Vogt
src/crash.c: make -Wall clean |
234 |
g_timeout_add_seconds(1, (GSourceFunc)crashreport_check_initially, ta); |
248
by Michael Vogt
* src/crash.{c,h}: |
235 |
}
|