aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog12
-rwxr-xr-xconfigure2
-rw-r--r--configure.ac2
-rw-r--r--src/apt-watcher.c196
4 files changed, 124 insertions, 88 deletions
diff --git a/ChangeLog b/ChangeLog
index 539f720..1495e9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
# Generated by Makefile. Do not edit.
+2011-09-14 Conor Curran <conor.curran@canonical.com>
+
+ fixes for apt handling
+
+2011-09-14 Conor Curran <conor.curran@canonical.com>
+
+ merge further apt handling fixes
+
+2011-09-14 Conor Curran <conor.curran@canonical.com>
+
+ apt property changed reboot required listened for and now the whole apt interaction does not happen until after 60 secs
+
2011-09-08 Conor Curran <conor.curran@canonical.com>
bump for release
diff --git a/configure b/configure
index 26210d8..ef58f16 100755
--- a/configure
+++ b/configure
@@ -2745,7 +2745,7 @@ fi
# Define the identity of the package.
PACKAGE=indicator-session
- VERSION=0.3.5.0
+ VERSION=0.3.5.1
cat >>confdefs.h <<_ACEOF
diff --git a/configure.ac b/configure.ac
index 6efac90..557a8d2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@ AC_INIT(src/indicator-session.c)
AC_PREREQ(2.53)
AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(indicator-session, 0.3.5.0)
+AM_INIT_AUTOMAKE(indicator-session, 0.3.5.1)
AM_MAINTAINER_MODE
diff --git a/src/apt-watcher.c b/src/apt-watcher.c
index e5e1d0e..2c5ed0b 100644
--- a/src/apt-watcher.c
+++ b/src/apt-watcher.c
@@ -71,10 +71,8 @@ static void apt_watcher_transaction_state_simulation_update_cb (AptTransaction*
gpointer user_data);
static void apt_watcher_transaction_state_real_update_cb (AptTransaction* trans,
gint update,
- gpointer user_data);
-
-
-
+ gpointer user_data);
+static gboolean apt_watcher_start_apt_interaction (gpointer data);
G_DEFINE_TYPE (AptWatcher, apt_watcher, G_TYPE_OBJECT);
@@ -85,7 +83,17 @@ apt_watcher_init (AptWatcher *self)
self->proxy_cancel = g_cancellable_new();
self->proxy = NULL;
self->reboot_query = 0;
- self->current_transaction = NULL;
+ self->current_transaction = NULL;
+ g_timeout_add_seconds (60,
+ apt_watcher_start_apt_interaction,
+ self);
+}
+
+static gboolean
+apt_watcher_start_apt_interaction (gpointer data)
+{
+ g_return_val_if_fail (APT_IS_WATCHER (data), FALSE);
+ AptWatcher* self = APT_WATCHER (data);
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
@@ -95,6 +103,7 @@ apt_watcher_init (AptWatcher *self)
self->proxy_cancel,
fetch_proxy_cb,
self);
+ return FALSE;
}
static void
@@ -154,7 +163,6 @@ fetch_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data)
self);
}
-
static void
apt_watcher_on_name_appeared (GDBusConnection *connection,
const gchar *name,
@@ -169,6 +177,8 @@ apt_watcher_on_name_appeared (GDBusConnection *connection,
"the system bus",
name_owner);
+ apt_watcher_query_reboot_status (user_data);
+
g_dbus_proxy_call (watcher->proxy,
"UpgradeSystem",
g_variant_new("(b)", TRUE),
@@ -176,9 +186,10 @@ apt_watcher_on_name_appeared (GDBusConnection *connection,
-1,
NULL,
apt_watcher_upgrade_system_cb,
- user_data);
+ user_data);
}
+
static void
apt_watcher_on_name_vanished (GDBusConnection *connection,
const gchar *name,
@@ -261,60 +272,52 @@ apt_watcher_transaction_state_real_update_cb (AptTransaction* trans,
AptWatcher* self = APT_WATCHER (user_data);
AptState state = (AptState)update;
-
- if (state == UP_TO_DATE){
- dbusmenu_menuitem_property_set (self->apt_item,
- DBUSMENU_MENUITEM_PROP_LABEL,
- _("Software Up to Date"));
- self->current_state = state;
- }
- else if (state == UPDATES_AVAILABLE){
- 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){
- gboolean query_again = FALSE;
-
- // 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);
+ if (self->current_state != RESTART_NEEDED)
+ {
+ if (state == UP_TO_DATE){
+ dbusmenu_menuitem_property_set (self->apt_item,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ _("Software Up to Date"));
+ self->current_state = state;
+ }
+ else if (state == UPDATES_AVAILABLE){
+ 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){
+ gboolean query_again = FALSE;
+
+ // Only query if the previous state was an upgrade.
+ if (self->current_state != UPGRADE_IN_PROGRESS){
+ query_again = TRUE;
+ }
+ self->current_state = state;
+
+ g_object_unref (G_OBJECT(self->current_transaction));
+ self->current_transaction = NULL;
+
+ // It is impossible to determine from a 'real' transaction whether
+ // updates are available therefore it is necessary to check again via a
+ // simulation whether there are updates available.
+ if (query_again){
+ g_dbus_proxy_call (self->proxy,
+ "UpgradeSystem",
+ g_variant_new("(b)", TRUE),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ apt_watcher_upgrade_system_cb,
+ self);
+ }
}
- else{
- query_again = TRUE;
- }
- self->current_state = state;
-
- g_object_unref (G_OBJECT(self->current_transaction));
- self->current_transaction = NULL;
-
- // It is impossible to determine from a 'real' transaction whether
- // updates are available ?
- if (query_again){
- g_dbus_proxy_call (self->proxy,
- "UpgradeSystem",
- g_variant_new("(b)", TRUE),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- apt_watcher_upgrade_system_cb,
- self);
- }
}
}
@@ -329,32 +332,32 @@ apt_watcher_transaction_state_simulation_update_cb (AptTransaction* trans,
AptWatcher* self = APT_WATCHER (user_data);
AptState state = (AptState)update;
-
- if (state == UP_TO_DATE){
- dbusmenu_menuitem_property_set (self->apt_item,
- DBUSMENU_MENUITEM_PROP_LABEL,
- _("Software Up to Date"));
- if (self->reboot_query != 0){
- g_source_remove (self->reboot_query);
- self->reboot_query = 0;
+ if (self->current_state != RESTART_NEEDED)
+ {
+ if (state == UP_TO_DATE){
+ dbusmenu_menuitem_property_set (self->apt_item,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ _("Software Up to Date"));
+ if (self->reboot_query != 0){
+ g_source_remove (self->reboot_query);
+ self->reboot_query = 0;
+ }
+ self->reboot_query = g_timeout_add_seconds (1,
+ apt_watcher_query_reboot_status,
+ self);
}
- self->reboot_query = g_timeout_add_seconds (2,
- apt_watcher_query_reboot_status,
- self);
- }
- else if (state == UPDATES_AVAILABLE){
- dbusmenu_menuitem_property_set (self->apt_item,
- DBUSMENU_MENUITEM_PROP_LABEL,
- _("Updates Available…"));
- }
- else if (state == UPGRADE_IN_PROGRESS){
- dbusmenu_menuitem_property_set (self->apt_item,
- DBUSMENU_MENUITEM_PROP_LABEL,
- _("Updates Installing…"));
+ else if (state == UPDATES_AVAILABLE){
+ dbusmenu_menuitem_property_set (self->apt_item,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ _("Updates Available…"));
+ }
+ else if (state == UPGRADE_IN_PROGRESS){
+ dbusmenu_menuitem_property_set (self->apt_item,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ _("Updates Installing…"));
+ }
+ self->current_state = state;
}
-
- self->current_state = state;
-
if (self->current_state != UPGRADE_IN_PROGRESS){
g_object_unref (G_OBJECT(self->current_transaction));
self->current_transaction = NULL;
@@ -383,7 +386,6 @@ apt_watcher_query_reboot_status (gpointer data)
gboolean reboot;
g_variant_get (reboot_result, "b", &reboot);
g_debug ("apt_watcher_query_reboot_status: reboot prop = %i", reboot);
-
if (reboot == FALSE){
dbusmenu_menuitem_property_set (self->apt_item,
DBUSMENU_MENUITEM_PROP_LABEL,
@@ -396,7 +398,7 @@ apt_watcher_query_reboot_status (gpointer data)
else{
dbusmenu_menuitem_property_set (self->apt_item,
DBUSMENU_MENUITEM_PROP_LABEL,
- _("Reboot Required"));
+ _("Restart to complete updates…"));
dbusmenu_menuitem_property_set (self->apt_item,
DBUSMENU_MENUITEM_PROP_DISPOSITION,
DBUSMENU_MENUITEM_DISPOSITION_ALERT);
@@ -446,6 +448,28 @@ static void apt_watcher_signal_cb ( GDBusProxy* proxy,
G_CALLBACK(apt_watcher_transaction_state_real_update_cb), self);
}
}
+ else if (g_strcmp0(signal_name, "PropertyChanged") == 0)
+ {
+ gchar* prop_name= NULL;
+ GVariant* value = NULL;
+ g_variant_get (parameters, "(sv)", &prop_name, &value);
+ g_debug ("transaction prop update - prop = %s", prop_name);
+
+ if (g_strcmp0 (prop_name, "RebootRequired") == 0){
+ gboolean reboot_required = FALSE;
+ g_variant_get (value, "(b)", &reboot_required);
+ if (reboot_required){
+ dbusmenu_menuitem_property_set (self->apt_item,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ _("Restart to complete updates…"));
+ dbusmenu_menuitem_property_set (self->apt_item,
+ DBUSMENU_MENUITEM_PROP_DISPOSITION,
+ DBUSMENU_MENUITEM_DISPOSITION_ALERT);
+ self->current_state = RESTART_NEEDED;
+ }
+ }
+ }
+
g_variant_unref (parameters);
}