[gnome-packagekit/glib2: 23/79] Mo



commit e461e939dee302f2234c64c5cca88b3fe697bb6f
Author: Richard Hughes <richard hughsie com>
Date:   Thu Sep 17 12:13:35 2009 +0100

    Mo

 src/gpk-check-update.c |   53 ++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 47 insertions(+), 6 deletions(-)
---
diff --git a/src/gpk-check-update.c b/src/gpk-check-update.c
index 59f45b9..fc074f5 100644
--- a/src/gpk-check-update.c
+++ b/src/gpk-check-update.c
@@ -1019,16 +1019,51 @@ out:
 }
 
 /**
+ * gpk_check_update_get_active_roles:
+ **/
+static PkBitfield
+gpk_check_update_get_active_roles (GpkCheckUpdate *cupdate)
+{
+	PkRoleEnum role;
+	PkBitfield roles = 0;
+	gchar **tids;
+	guint i;
+	PkProgress *progress;
+	GError *error = NULL;
+
+	tids = pk_transaction_list_get_ids (cupdate->priv->tlist);
+	for (i=0; tids[i] != NULL; i++) {
+		/* get progress */
+		progress = pk_client_get_progress (cupdate->priv->client, tids[i], cupdate->priv->cancellable, &error);
+		if (progress == NULL) {
+			egg_warning ("failed to get progress of %s: %s", tids[i], error->message);
+			g_error_free (error);
+			goto out;
+		}
+		/* get data */
+		g_object_get (progress,
+			      "role", &role,
+			      NULL);
+		pk_bitfield_add (roles, role);
+		g_object_unref (progress);
+	}
+out:
+	return roles;
+}
+
+/**
  * gpk_check_update_query_updates:
  **/
 static void
 gpk_check_update_query_updates (GpkCheckUpdate *cupdate)
 {
+	PkBitfield roles;
 	g_return_if_fail (GPK_IS_CHECK_UPDATE (cupdate));
 
 	/* No point if we are already updating */
-	if (pk_transaction_list_contains_role (cupdate->priv->tlist, PK_ROLE_ENUM_UPDATE_PACKAGES) ||
-	    pk_transaction_list_contains_role (cupdate->priv->tlist, PK_ROLE_ENUM_UPDATE_SYSTEM)) {
+	roles = gpk_check_update_get_active_roles (cupdate);
+	if (pk_bitfield_contain (roles, PK_ROLE_ENUM_UPDATE_PACKAGES) ||
+	    pk_bitfield_contain (roles, PK_ROLE_ENUM_UPDATE_SYSTEM)) {
 		egg_debug ("Not checking for updates as already in progress");
 		goto out;
 	}
@@ -1121,12 +1156,14 @@ gpk_check_update_restart_schedule_cb (PkClient *client, GpkCheckUpdate *cupdate)
 static void
 gpk_check_update_task_list_changed_cb (PkTransactionList *tlist, GpkCheckUpdate *cupdate)
 {
+	PkBitfield roles;
 	g_return_if_fail (GPK_IS_CHECK_UPDATE (cupdate));
 
 	/* inhibit icon if we are updating */
+	roles = gpk_check_update_get_active_roles (cupdate);
 	cupdate->priv->icon_inhibit_update_in_progress =
-		(pk_transaction_list_contains_role (tlist, PK_ROLE_ENUM_UPDATE_SYSTEM) ||
-		 pk_transaction_list_contains_role (tlist, PK_ROLE_ENUM_UPDATE_PACKAGES));
+		(pk_bitfield_contain (roles, PK_ROLE_ENUM_UPDATE_SYSTEM) ||
+		 pk_bitfield_contain (roles, PK_ROLE_ENUM_UPDATE_PACKAGES));
 	gpk_check_update_set_icon_visibility (cupdate);
 }
 
@@ -1354,6 +1391,7 @@ out:
 	return;
 }
 
+#if 0
 /**
  * gpk_check_update_repo_signature_required_cb:
  **/
@@ -1367,6 +1405,7 @@ gpk_check_update_repo_signature_required_cb (PkClient *client, const gchar *pack
 	gpk_helper_repo_signature_show (cupdate->priv->helper_repo_signature, package_id,
 					repository_name, key_url, key_userid, key_id, key_fingerprint, key_timestamp);
 }
+#endif
 
 /**
  * gpk_check_update_get_properties_cb:
@@ -1409,6 +1448,7 @@ static void
 gpk_check_update_init (GpkCheckUpdate *cupdate)
 {
 	gboolean ret;
+	PkBitfield roles;
 
 	cupdate->priv = GPK_CHECK_UPDATE_GET_PRIVATE (cupdate);
 
@@ -1470,10 +1510,11 @@ gpk_check_update_init (GpkCheckUpdate *cupdate)
 	g_signal_connect (cupdate->priv->tlist, "changed",
 			  G_CALLBACK (gpk_check_update_task_list_changed_cb), cupdate);
 
+	roles = gpk_check_update_get_active_roles (cupdate);
 	/* coldplug update in progress */
 	cupdate->priv->icon_inhibit_update_in_progress =
-		(pk_transaction_list_contains_role (cupdate->priv->tlist, PK_ROLE_ENUM_UPDATE_SYSTEM) ||
-		 pk_transaction_list_contains_role (cupdate->priv->tlist, PK_ROLE_ENUM_UPDATE_PACKAGES));
+		(pk_bitfield_contain (roles, PK_ROLE_ENUM_UPDATE_SYSTEM) ||
+		 pk_bitfield_contain (roles, PK_ROLE_ENUM_UPDATE_PACKAGES));
 
 	/* get properties */
 	pk_control_get_properties_async (cupdate->priv->control, cupdate->priv->cancellable, (GAsyncReadyCallback) gpk_check_update_get_properties_cb, cupdate);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]