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

« back to all changes in this revision

Viewing changes to src/crash.c

  • Committer: Michael Vogt
  • Date: 2011-01-03 15:21:35 UTC
  • mfrom: (606.1.3 update-notifier)
  • Revision ID: michael.vogt@ubuntu.com-20110103152135-zo1h6qa0ii4e4mjy
merged from seb128, modified slightly to make the unity special case more obvious

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
static gboolean
18
18
check_system_crashes() {
19
19
   int exitcode;
 
20
   gchar *stdlog;
20
21
 
21
22
   if(!in_admin_group())
22
23
      return FALSE;
23
24
 
24
25
   // check for system crashes
25
 
   if(!g_spawn_command_line_sync(CRASHREPORT_HELPER " --system", NULL, NULL, 
 
26
   if(!g_spawn_command_line_sync(CRASHREPORT_HELPER " --system", &stdlog, NULL, 
26
27
                                 &exitcode, NULL)) {
27
28
      g_warning("Can not run %s\n", CRASHREPORT_HELPER);
28
29
      return FALSE;
98
99
   int crashreports_found = 0;
99
100
   static gboolean first_run = TRUE;
100
101
   gboolean system_crashes;
101
 
 
 
102
   gchar *stdlog;
102
103
   //   g_debug("crashreport_check\n");
103
104
 
104
105
   // don't do anything if no apport-gtk is installed
108
109
   // Check whether the user doesn't want notifications
109
110
   if (!gconf_client_get_bool ((GConfClient*) ta->user_data,
110
111
       GCONF_KEY_APPORT_NOTIFICATIONS, NULL)) {
111
 
       g_debug("apport notifications disabled in gconf, not displaying crashes");
112
 
       return FALSE;
 
112
      g_debug("apport notifications disabled in gconf, not displaying crashes");
 
113
      return FALSE;
113
114
   }
114
115
 
115
116
   // check for (new) reports by calling CRASHREPORT_HELPER
116
117
   // and checking the return code
117
118
   int exitcode;
118
 
   if(!g_spawn_command_line_sync(CRASHREPORT_HELPER, NULL, NULL, 
 
119
   if(!g_spawn_command_line_sync(CRASHREPORT_HELPER, &stdlog, NULL,
119
120
                                 &exitcode, NULL)) {
120
121
      g_warning("Can not run %s\n", CRASHREPORT_HELPER);
121
122
      return FALSE;
124
125
   system_crashes = check_system_crashes();
125
126
   crashreports_found = !exitcode || system_crashes;
126
127
 
 
128
   gboolean visible = gtk_status_icon_get_visible(ta->tray_icon);
 
129
 
 
130
   // special case for unity (and generally stuff that lacks a 
 
131
   // notification area, if the icon can not be embedded we just
 
132
   // fire up apport regardless (but skip if there are system 
 
133
   // crashes as this will result in gksu windows
 
134
   if (!gtk_status_icon_is_embedded (ta->tray_icon) && 
 
135
       crashreports_found > 0 && 
 
136
       !system_crashes) {
 
137
      g_debug("unity handler");
 
138
      crashreports_found=0;
 
139
      run_apport(ta);
 
140
      return TRUE;
 
141
   }
 
142
 
 
143
   // normal operation
 
144
 
127
145
   // crashreport found and first run: show notification bubble and
128
146
   // return
129
 
   gboolean visible = gtk_status_icon_get_visible(ta->tray_icon);
130
 
 
131
 
   //   g_print("reports: %i, visible: %i\n",crashreports_found,visible);
132
 
 
133
147
   if((crashreports_found > 0) && (system_crashes || first_run)) {
134
148
      gtk_status_icon_set_tooltip(ta->tray_icon,
135
149
                                  _("Crash report detected"));
137
151
      /* Show the notification, after a delay so it doesn't look ugly
138
152
       * if we've just logged in */
139
153
      g_timeout_add(5000, (GSourceFunc)(show_notification), ta);
 
154
 
140
155
   }
141
156
   // crashreport found and already visible
142
157
   else if((crashreports_found > 0) && !(system_crashes || first_run)) {
158
173
button_release_cb (GtkWidget *widget,
159
174
                   TrayApplet *ta)
160
175
{
161
 
run_apport(ta);
162
 
hide_crash_applet(ta);
163
 
        return TRUE;
 
176
   run_apport(ta);
 
177
   hide_crash_applet(ta);
 
178
   return TRUE;
164
179
}
165
180
 
166
181