~ubuntu-core-dev/update-notifier/ubuntu

« back to all changes in this revision

Viewing changes to src/system-crash.c

  • Committer: Brian Murray
  • Date: 2013-06-03 22:40:21 UTC
  • mfrom: (781.2.12 distro-cd-detected)
  • Revision ID: brian@canonical.com-20130603224021-17l6xslzhzss1ji9
* Move update-notifier checking for CDs with packages into a new binary
  distro-cd-updater
* Add an upstart user session job that runs upon CD insertion
* Remove sections of uevent related to hp firmware and replace them with an
  upstart user session job
* Modified avahi disabled notification to run as an upstart user session
* Modified new release check to run as an upstart user session
* Added in a weekly cron job to check for a new release of ubuntu
* Added an upstart user session job to check for crashes
* Ensure we ask before launching a pkexec dialog for an apport crash

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifdef HAVE_CONFIG_H
 
2
#include "config.h"
 
3
#endif
 
4
#include <glib.h>
 
5
#include <glib-object.h>
 
6
#include <gtk/gtk.h>
 
7
 
 
8
#include <sys/types.h>
 
9
#include <sys/stat.h>
 
10
#include <unistd.h>
 
11
#include <glib/gi18n.h>
 
12
 
 
13
#include "update-notifier.h"
 
14
#include "system-crash.h"
 
15
 
 
16
static gboolean
 
17
ask_invoke_apport_with_pkexec(void)
 
18
{
 
19
   GtkDialog *dialog;
 
20
   gchar *msg = _("System program problem detected");
 
21
   gchar *descr = _("Do you want to report the problem "
 
22
                    "now?");
 
23
   dialog = (GtkDialog*)gtk_message_dialog_new (NULL,
 
24
                                    GTK_DIALOG_DESTROY_WITH_PARENT,
 
25
                                    GTK_MESSAGE_QUESTION,
 
26
                                    GTK_BUTTONS_NONE,
 
27
                                    "%s", msg);
 
28
   gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
 
29
                                            "%s", descr);
 
30
   gtk_dialog_add_button(dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
 
31
   gtk_dialog_add_button(dialog, _("Report problem…"), GTK_RESPONSE_ACCEPT);
 
32
   int res = gtk_dialog_run(dialog);
 
33
   gtk_widget_destroy(GTK_WIDGET(dialog));
 
34
   if (res == GTK_RESPONSE_ACCEPT)
 
35
      return TRUE;
 
36
   return FALSE;
 
37
}
 
38
 
 
39
void
 
40
invoke_with_pkexec(const gchar *cmd)
 
41
{
 
42
        g_debug("invoke_with_pkexec ()");
 
43
        gchar *argv[3];
 
44
        argv[0] = "/usr/bin/pkexec";
 
45
        argv[1] = (gchar*)cmd;
 
46
        argv[2] = NULL;
 
47
        g_spawn_async (NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, NULL, NULL);
 
48
}
 
49
 
 
50
int
 
51
main (int argc, char **argv)
 
52
{
 
53
   gtk_init (&argc, &argv);
 
54
   // be nice and always ask first before firing up pkexec
 
55
   if (ask_invoke_apport_with_pkexec()) {
 
56
      invoke_with_pkexec(CRASHREPORT_REPORT_APP);
 
57
   } else {
 
58
      return g_spawn_command_line_async(CRASHREPORT_REPORT_APP, NULL);
 
59
   }
 
60
   return 0;
 
61
}