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,
214
217
apt_watcher_show_apt_dialog (DbusmenuMenuitem * mi,
218
221
GError * error = NULL;
219
if (!g_spawn_command_line_async("update-manager", &error))
221
g_warning("Unable to show update-manager: %s", error->message);
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);
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");
232
if (!g_spawn_command_line_async(dialog_line, &error)) {
233
g_warning("Unable to show dialog: %s", error->message);
239
if (!g_spawn_command_line_async("update-manager", &error))
241
g_warning("Unable to show update-manager: %s", error->message);
246
267
g_object_unref (G_OBJECT(self->current_transaction));
247
268
self->current_transaction = NULL;
270
if (self->reboot_query != 0){
271
g_source_remove (self->reboot_query);
272
self->reboot_query = 0;
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,
250
280
else if (state == UPDATES_AVAILABLE){
251
281
dbusmenu_menuitem_property_set (self->apt_item,
266
296
_("Updates Installing…"));
268
298
else if (state == FINISHED){
269
GVariant* reboot_result = g_dbus_proxy_get_cached_property (self->proxy,
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"));
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);
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;
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,
310
dbusmenu_menuitem_property_set (self->apt_item,
311
DBUSMENU_MENUITEM_PROP_LABEL,
312
_("Finished Updating…"));
291
314
self->current_state = state;
329
apt_watcher_query_reboot_status (gpointer data)
331
g_return_val_if_fail (APT_IS_WATCHER (data), FALSE);
332
AptWatcher* self = APT_WATCHER (data);
334
GVariant* reboot_result = g_dbus_proxy_get_cached_property (self->proxy,
337
g_variant_get (reboot_result, "b", &reboot);
338
g_debug ("apt_watcher_query_reboot_status: reboot prop = %i", reboot);
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);
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);
358
self->reboot_query = 0;
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,