diff options
author | Conor Curran <conor.curran@canonical.com> | 2011-09-07 12:04:16 +0100 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2011-09-07 12:04:16 +0100 |
commit | d0d4fd57cf3a25547c570139cc6a311ce05eed44 (patch) | |
tree | 296f0580e115e1ecd70b7e4c712a2ce9d5a0bf30 /src | |
parent | 46db1068e1684293f02125872361f75204399e8f (diff) | |
download | ayatana-indicator-session-d0d4fd57cf3a25547c570139cc6a311ce05eed44.tar.gz ayatana-indicator-session-d0d4fd57cf3a25547c570139cc6a311ce05eed44.tar.bz2 ayatana-indicator-session-d0d4fd57cf3a25547c570139cc6a311ce05eed44.zip |
more revelations with regards the behaviour of the apt dbus 'api'
Diffstat (limited to 'src')
-rw-r--r-- | src/apt-transaction.c | 33 | ||||
-rw-r--r-- | src/apt-watcher.c | 28 |
2 files changed, 30 insertions, 31 deletions
diff --git a/src/apt-transaction.c b/src/apt-transaction.c index cd9e131..317d74a 100644 --- a/src/apt-transaction.c +++ b/src/apt-transaction.c @@ -160,7 +160,7 @@ apt_transaction_receive_signal (GDBusProxy * proxy, AptTransaction* self = APT_TRANSACTION(user_data); AptState current_state = DONT_KNOW; - if (g_strcmp0(signal_name, "PropertyChanged") == 0 && self->type == SIMULATION) + if (g_strcmp0(signal_name, "PropertyChanged") == 0) { gchar* prop_name= NULL; GVariant* value = NULL; @@ -204,23 +204,22 @@ apt_transaction_receive_signal (GDBusProxy * proxy, current_state = UP_TO_DATE; } } - } - else if (g_strcmp0(signal_name, "PropertyChanged") == 0 && - self->type == REAL) - { - GVariant* role = g_dbus_proxy_get_cached_property (self->proxy, - "Role"); - if (g_variant_is_of_type (role, G_VARIANT_TYPE_STRING) == TRUE){ - gchar* current_role = NULL; - g_variant_get (role, "s", ¤t_role); - //g_debug ("Current transaction role = %s", current_role); - if (g_strcmp0 (current_role, "role-commit-packages") == 0 || - g_strcmp0 (current_role, "role-upgrade-system") == 0){ - g_debug ("UPGRADE IN PROGRESS"); - current_state = UPGRADE_IN_PROGRESS; + if (self->type == REAL) + { + GVariant* role = g_dbus_proxy_get_cached_property (self->proxy, + "Role"); + if (g_variant_is_of_type (role, G_VARIANT_TYPE_STRING) == TRUE){ + gchar* current_role = NULL; + g_variant_get (role, "s", ¤t_role); + //g_debug ("Current transaction role = %s", current_role); + if (g_strcmp0 (current_role, "role-commit-packages") == 0 || + g_strcmp0 (current_role, "role-upgrade-system") == 0){ + g_debug ("UPGRADE IN PROGRESS"); + current_state = UPGRADE_IN_PROGRESS; + } } - } - } + } + } else if (g_strcmp0(signal_name, "Finished") == 0) { g_debug ("TRANSACTION Finished"); diff --git a/src/apt-watcher.c b/src/apt-watcher.c index b0d9688..1f88868 100644 --- a/src/apt-watcher.c +++ b/src/apt-watcher.c @@ -269,7 +269,7 @@ apt_watcher_transaction_state_real_update_cb (AptTransaction* trans, g_source_remove (self->reboot_query); self->reboot_query = 0; } - self->reboot_query = g_timeout_add_seconds (1, + self->reboot_query = g_timeout_add_seconds (2, apt_watcher_query_reboot_status, self); } @@ -277,27 +277,27 @@ apt_watcher_transaction_state_real_update_cb (AptTransaction* trans, dbusmenu_menuitem_property_set (self->apt_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Updates Available…")); - self->current_state = state; } else if (state == UPGRADE_IN_PROGRESS){ dbusmenu_menuitem_property_set (self->apt_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Updates Installing…")); - self->current_state = state; } else if (state == FINISHED){ - - if (self->reboot_query != 0){ - g_source_remove (self->reboot_query); - self->reboot_query = 0; + // Only query if the previous state was an upgrade. + if (self->current_state == UPGRADE_IN_PROGRESS){ + if (self->reboot_query != 0){ + g_source_remove (self->reboot_query); + self->reboot_query = 0; + } + // Wait a sec before querying for reboot status, + // race condition with Apt has been observed. + self->reboot_query = g_timeout_add_seconds (2, + apt_watcher_query_reboot_status, + self); } - // Wait a sec before querying for reboot status, - // race condition with Apt has been observed. - self->reboot_query = g_timeout_add_seconds (1, - apt_watcher_query_reboot_status, - self); } - + // Set the current state self->current_state = state; if (self->current_state != UPGRADE_IN_PROGRESS){ @@ -326,7 +326,7 @@ apt_watcher_transaction_state_simulation_update_cb (AptTransaction* trans, g_source_remove (self->reboot_query); self->reboot_query = 0; } - self->reboot_query = g_timeout_add_seconds (1, + self->reboot_query = g_timeout_add_seconds (2, apt_watcher_query_reboot_status, self); } |