~ubuntu-branches/ubuntu/oneiric/indicator-session/oneiric-proposed

« back to all changes in this revision

Viewing changes to src/apt-watcher.c

  • Committer: Package Import Robot
  • Author(s): Ken VanDine, Ken VanDine, Ted Gould
  • Date: 2011-09-01 13:53:50 UTC
  • mfrom: (1.1.37 upstream)
  • Revision ID: package-import@ubuntu.com-20110901135350-sl5g84ls1z0r7kwc
Tags: 0.3.4.1-0ubuntu1
[Ken VanDine]
* New upstream release.
  - in a Guest session user menu is not visible (LP: #834948)
  - User name shown as [Invalid UTF-8] in live session (LP: #837246)
  - "Reboot Required" menu opens Update Manager, doesn't reboot (LP: #837658)
  - indicator-session-service crashed with SIGSEGV in 
    g_str_hash() (LP: #824243)
  - indicator-session-service crashed with SIGSEGV in 
    g_variant_unref() (LP: #833965)
* +debian/patches/revert_icon_change.patch
  - revert the icon change in greeter mode until a UIF exception is 
    approved
* +debian/source/format

[Ted Gould]
* debian/control: Adding a depend on gnome-settings-daemon to ensure that
  the required schemas are available.  (LP: #833965)

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
struct _AptWatcher
28
28
{
29
29
        GObject parent_instance;
 
30
  guint reboot_query;
30
31
        GCancellable * proxy_cancel;
31
32
        GDBusProxy * proxy;  
32
33
  SessionDbus* session_dbus_interface;
55
56
                
56
57
static void apt_watcher_show_apt_dialog (DbusmenuMenuitem* mi,
57
58
                                         guint timestamp,
58
 
                                         gchar * type);
 
59
                                         gpointer userdata);
59
60
 
60
61
static void apt_watcher_signal_cb (GDBusProxy* proxy,
61
62
                                   gchar* sender_name,
64
65
                                   gpointer user_data);
65
66
static void  apt_watcher_manage_transactions (AptWatcher* self,
66
67
                                              gchar* transaction_id);
 
68
static gboolean apt_watcher_query_reboot_status (gpointer self);
67
69
                                   
68
70
 
69
71
 
75
77
  self->current_state = UP_TO_DATE;
76
78
  self->proxy_cancel = g_cancellable_new();
77
79
  self->proxy = NULL;
 
80
  self->reboot_query = 0;
78
81
  self->current_transaction = NULL;
79
82
  g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
80
83
                            G_DBUS_PROXY_FLAGS_NONE,
141
144
        g_signal_connect (self->proxy,
142
145
                    "g-signal",
143
146
                    G_CALLBACK(apt_watcher_signal_cb),
144
 
                    self);  
 
147
                    self);   
145
148
}
146
149
 
147
150
 
213
216
static void
214
217
apt_watcher_show_apt_dialog (DbusmenuMenuitem * mi,
215
218
                             guint timestamp,
216
 
                             gchar * type)
 
219
                             gpointer userdata)
217
220
{
218
221
  GError * error = NULL;
219
 
  if (!g_spawn_command_line_async("update-manager", &error))
220
 
  {
221
 
    g_warning("Unable to show update-manager: %s", error->message);
222
 
    g_error_free(error);
223
 
  }  
 
222
  g_return_if_fail (APT_IS_WATCHER (userdata));
 
223
  AptWatcher* self = APT_WATCHER (userdata);
 
224
  const gchar* disposition = NULL;
 
225
  disposition = dbusmenu_menuitem_property_get (self->apt_item,
 
226
                                                DBUSMENU_MENUITEM_PROP_DISPOSITION);
 
227
                                    
 
228
  if (g_strcmp0 (disposition, DBUSMENU_MENUITEM_DISPOSITION_ALERT) == 0){       
 
229
    gchar * helper = g_build_filename (LIBEXECDIR, "gtk-logout-helper", NULL);
 
230
          gchar * dialog_line = g_strdup_printf ("%s --%s", helper, "restart");
 
231
        g_free(helper);
 
232
          if (!g_spawn_command_line_async(dialog_line, &error)) {
 
233
                  g_warning("Unable to show dialog: %s", error->message);
 
234
                  g_error_free(error);
 
235
          }
 
236
          g_free(dialog_line);
 
237
  } 
 
238
  else{
 
239
    if (!g_spawn_command_line_async("update-manager", &error))
 
240
    {
 
241
      g_warning("Unable to show update-manager: %s", error->message);
 
242
      g_error_free(error);
 
243
    }
 
244
  }   
224
245
}
225
246
 
226
247
static void
245
266
        == SIMULATION){
246
267
      g_object_unref (G_OBJECT(self->current_transaction));
247
268
      self->current_transaction = NULL;
248
 
    }                                                                   
 
269
    }  
 
270
    if (self->reboot_query != 0){
 
271
      g_source_remove (self->reboot_query);
 
272
      self->reboot_query = 0;
 
273
    }
 
274
    // Wait a sec before querying for reboot status, 
 
275
    // race condition with Apt has been observed.
 
276
    self->reboot_query = g_timeout_add_seconds (1,
 
277
                                                apt_watcher_query_reboot_status,
 
278
                                                self); 
249
279
  }
250
280
  else if (state == UPDATES_AVAILABLE){
251
281
    dbusmenu_menuitem_property_set (self->apt_item,
266
296
                                    _("Updates Installing…"));    
267
297
  }  
268
298
  else if (state == FINISHED){
269
 
    GVariant* reboot_result = g_dbus_proxy_get_cached_property (self->proxy,
270
 
                                                               "RebootRequired");
271
 
    gboolean reboot;
272
 
    g_variant_get (reboot_result, "b", &reboot);
273
 
    if (reboot == FALSE){
274
 
      dbusmenu_menuitem_property_set (self->apt_item,
275
 
                                      DBUSMENU_MENUITEM_PROP_LABEL,
276
 
                                      _("Software Up to Date"));
277
 
    }
278
 
    else{
279
 
      dbusmenu_menuitem_property_set (self->apt_item,
280
 
                                      DBUSMENU_MENUITEM_PROP_LABEL,
281
 
                                      _("Reboot Required"));
282
 
      dbusmenu_menuitem_property_set (self->apt_item,
283
 
                                      DBUSMENU_MENUITEM_PROP_DISPOSITION,
284
 
                                      DBUSMENU_MENUITEM_DISPOSITION_ALERT);                                       
285
 
      session_dbus_restart_required (self->session_dbus_interface);
286
 
    }
287
 
    g_debug ("Finished with a reboot value of %i", reboot); 
288
299
    g_object_unref (G_OBJECT(self->current_transaction));
289
 
    self->current_transaction = NULL;                                    
 
300
    self->current_transaction = NULL;   
 
301
    if (self->reboot_query != 0){
 
302
      g_source_remove (self->reboot_query);
 
303
      self->reboot_query = 0;
 
304
    }
 
305
    // Wait a sec before querying for reboot status, 
 
306
    // race condition with Apt has been observed.
 
307
    self->reboot_query = g_timeout_add_seconds (1,
 
308
                                                apt_watcher_query_reboot_status,
 
309
                                                self); 
 
310
    dbusmenu_menuitem_property_set (self->apt_item,
 
311
                                    DBUSMENU_MENUITEM_PROP_LABEL,
 
312
                                    _("Finished Updating…"));                                                                            
290
313
  }
291
314
  self->current_state = state;
292
315
302
325
    }
303
326
}
304
327
 
 
328
static gboolean
 
329
apt_watcher_query_reboot_status (gpointer data)
 
330
{
 
331
  g_return_val_if_fail (APT_IS_WATCHER (data), FALSE);
 
332
  AptWatcher* self = APT_WATCHER (data);
 
333
  
 
334
  GVariant* reboot_result = g_dbus_proxy_get_cached_property (self->proxy,
 
335
                                                             "RebootRequired");
 
336
  gboolean reboot;
 
337
  g_variant_get (reboot_result, "b", &reboot);
 
338
  g_debug ("apt_watcher_query_reboot_status: reboot prop = %i", reboot);
 
339
  
 
340
  if (reboot == FALSE){
 
341
    dbusmenu_menuitem_property_set (self->apt_item,
 
342
                                    DBUSMENU_MENUITEM_PROP_LABEL,
 
343
                                    _("Software Up to Date"));
 
344
    dbusmenu_menuitem_property_set (self->apt_item,
 
345
                                    DBUSMENU_MENUITEM_PROP_DISPOSITION,
 
346
                                    DBUSMENU_MENUITEM_DISPOSITION_NORMAL);
 
347
                                    
 
348
  }
 
349
  else{
 
350
    dbusmenu_menuitem_property_set (self->apt_item,
 
351
                                    DBUSMENU_MENUITEM_PROP_LABEL,
 
352
                                    _("Reboot Required"));
 
353
    dbusmenu_menuitem_property_set (self->apt_item,
 
354
                                    DBUSMENU_MENUITEM_PROP_DISPOSITION,
 
355
                                    DBUSMENU_MENUITEM_DISPOSITION_ALERT);
 
356
    session_dbus_restart_required (self->session_dbus_interface);
 
357
  }
 
358
  self->reboot_query = 0;
 
359
  return FALSE;
 
360
}
 
361
 
305
362
// TODO - Ask MVO about this.
306
 
// Signal is of type s not sas which is on d-feet !!!
 
363
// Signal is of type s not sas which is on d-feet.
307
364
static void apt_watcher_signal_cb ( GDBusProxy* proxy,
308
365
                                    gchar* sender_name,
309
366
                                    gchar* signal_name,