[gnome-packagekit/glib2: 32/79] moo



commit 43ee5e726a18b10c5d731eef2fc06d58b099e426
Author: Richard Hughes <richard hughsie com>
Date:   Mon Sep 21 11:38:09 2009 +0100

    moo

 src/gpk-dbus-task.c |  157 +++---------
 src/gpk-dbus-task.h |    2 -
 src/gpk-dbus.c      |    2 +-
 src/gpk-watch.c     |  723 +++++++++++++++++++++++++++------------------------
 4 files changed, 424 insertions(+), 460 deletions(-)
---
diff --git a/src/gpk-dbus-task.c b/src/gpk-dbus-task.c
index 41e78e8..28cbb6d 100644
--- a/src/gpk-dbus-task.c
+++ b/src/gpk-dbus-task.c
@@ -80,8 +80,7 @@ struct _GpkDbusTaskPrivate
 {
 	GdkWindow		*parent_window;
 	GConfClient		*gconf_client;
-	PkClient		*client_primary;
-	PkClient		*client_secondary;
+	PkClient		*client;
 	PkDesktop		*desktop;
 	PkControl		*control;
 	PkExitEnum		 exit;
@@ -149,18 +148,6 @@ gpk_dbus_task_set_context (GpkDbusTask *task, DBusGMethodInvocation *context)
 }
 
 /**
- * gpk_dbus_task_set_timeout:
- **/
-gboolean
-gpk_dbus_task_set_timeout (GpkDbusTask *task, gint timeout)
-{
-	g_return_val_if_fail (GPK_IS_DBUS_TASK (task), FALSE);
-
-	task->priv->timeout = timeout;
-	return TRUE;
-}
-
-/**
  * gpk_dbus_task_set_xid:
  **/
 gboolean
@@ -317,14 +304,7 @@ gpk_dbus_task_install_package_ids (GpkDbusTask *task)
 	if (task->priv->show_progress)
 		gpk_modal_dialog_present (task->priv->dialog);
 
-	/* set timeout */
-	pk_client_set_timeout (task->priv->client_primary, task->priv->timeout, NULL);
-
-#if PK_CHECK_VERSION(0,5,0)
-	ret = pk_client_install_packages (task->priv->client_primary, TRUE, task->priv->package_ids, &error_local);
-#else
-	ret = pk_client_install_packages (task->priv->client_primary, task->priv->package_ids, &error_local);
-#endif
+	ret = pk_client_install_packages (task->priv->client, TRUE, task->priv->package_ids, &error_local);
 	if (!ret) {
 		/* TRANSLATORS: error: failed to install, detailed error follows */
 		gpk_dbus_task_error_msg (task, _("Failed to install package"), error_local);
@@ -388,15 +368,8 @@ gpk_dbus_task_install_package_ids_dep_check (GpkDbusTask *task)
 	if (task->priv->show_progress)
 		gpk_modal_dialog_present (task->priv->dialog);
 
-	/* set timeout */
-	pk_client_set_timeout (task->priv->client_primary, task->priv->timeout, NULL);
-
 	/* find out if this would drag in other packages */
-#if PK_CHECK_VERSION(0,5,2)
-	ret = pk_client_simulate_install_packages (task->priv->client_primary, task->priv->package_ids, &error_local);
-#else
-	ret = pk_client_get_depends (task->priv->client_primary, pk_bitfield_value (PK_FILTER_ENUM_NOT_INSTALLED), task->priv->package_ids, TRUE, &error_local);
-#endif
+	ret = pk_client_simulate_install_packages (task->priv->client, task->priv->package_ids, &error_local);
 	if (!ret) {
 		/* TRANSLATORS: error: could not get the extra package list when installing a package */
 		gpk_dbus_task_error_msg (task, _("Could not work out what packages would be also installed"), error_local);
@@ -508,7 +481,7 @@ gpk_dbus_task_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runtime
 	gpk_modal_dialog_set_percentage (task->priv->dialog, 100);
 
 	/* we failed because we're handling the auth, just ignore */
-	if (client == task->priv->client_primary &&
+	if (client == task->priv->client &&
 	    (exit_enum == PK_EXIT_ENUM_KEY_REQUIRED ||
 	     exit_enum == PK_EXIT_ENUM_EULA_REQUIRED)) {
 		egg_debug ("ignoring primary sig-required or eula");
@@ -532,7 +505,7 @@ gpk_dbus_task_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runtime
 	    role == PK_ROLE_ENUM_WHAT_PROVIDES) {
 
 		/* found nothing? */
-		list = pk_results_get_package_array (task->priv->client_primary);
+		list = pk_results_get_package_array (task->priv->client);
 		if (list->len == 0) {
 			if (task->priv->show_warning) {
 				info_url = gpk_vendor_get_not_found_url (task->priv->vendor, GPK_VENDOR_URL_TYPE_MIME);
@@ -568,7 +541,7 @@ gpk_dbus_task_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runtime
 	if (task->priv->role == GPK_DBUS_TASK_ROLE_INSTALL_PROVIDE_FILES &&
 	    role == PK_ROLE_ENUM_SEARCH_FILE) {
 		/* found nothing? */
-		list = pk_results_get_package_array (task->priv->client_primary);
+		list = pk_results_get_package_array (task->priv->client);
 		if (list->len == 0) {
 			if (task->priv->show_warning) {
 				info_url = gpk_vendor_get_not_found_url (task->priv->vendor, GPK_VENDOR_URL_TYPE_DEFAULT);
@@ -643,7 +616,7 @@ gpk_dbus_task_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runtime
 		GPtrArray *new;
 
 		/* these are the new packages */
-		list = pk_results_get_package_array (task->priv->client_primary);
+		list = pk_results_get_package_array (task->priv->client);
 		new = g_ptr_array_new_with_free_func_xxx ();
 		for (i=0; i<list->len; i++) {
 			item = g_ptr_array_index (list, i);
@@ -750,7 +723,7 @@ skip_checks:
 
 	/* IsInstalled */
 	if (task->priv->role == GPK_DBUS_TASK_ROLE_IS_INSTALLED) {
-		list = pk_results_get_package_array (task->priv->client_primary);
+		list = pk_results_get_package_array (task->priv->client);
 
 		/* one or more entry? */
 		ret = (list->len > 0);
@@ -761,7 +734,7 @@ skip_checks:
 
 	/* SearchFile */
 	if (task->priv->role == GPK_DBUS_TASK_ROLE_SEARCH_FILE) {
-		list = pk_results_get_package_array (task->priv->client_primary);
+		list = pk_results_get_package_array (task->priv->client);
 
 		/* one or more entry? */
 		len = list->len;
@@ -777,7 +750,7 @@ skip_checks:
 	    role == PK_ROLE_ENUM_RESOLVE) {
 
 		/* found nothing? */
-		list = pk_results_get_package_array (task->priv->client_primary);
+		list = pk_results_get_package_array (task->priv->client);
 		if (list->len == 0) {
 			if (task->priv->show_warning) {
 				//FIXME: shows package_id in UI
@@ -1042,25 +1015,8 @@ gpk_dbus_task_button_close_cb (GtkWidget *widget, GpkDbusTask *task)
 static void
 gpk_dbus_task_button_cancel_cb (GtkWidget *widget, GpkDbusTask *task)
 {
-	gboolean ret;
-	GError *error = NULL;
-
 	/* we might have a transaction running */
-	ret = g_cancellable_cancel (task->priv->client_primary, &error);
-	if (!ret) {
-		egg_warning ("failed to cancel client: %s", error->message);
-		g_error_free (error);
-		goto out;
-	}
-
-	ret = g_cancellable_cancel (task->priv->client_secondary, &error);
-	if (!ret) {
-		egg_warning ("failed to cancel client: %s", error->message);
-		g_error_free (error);
-		goto out;
-	}
-out:
-	return;
+	g_cancellable_cancel (task->priv->cancellable);
 }
 
 /**
@@ -1078,11 +1034,8 @@ gpk_dbus_task_install_package_files_internal (GpkDbusTask *task, gboolean truste
 	/* FIXME: we need to move this into PkClient sooner or later */
 	task->priv->last_exit_code = PK_ERROR_ENUM_UNKNOWN;
 
-	/* set timeout */
-	pk_client_set_timeout (task->priv->client_primary, task->priv->timeout, NULL);
-
 	/* install local file */
-	ret = pk_client_install_files (task->priv->client_primary, trusted, task->priv->files, &error_local);
+	ret = pk_client_install_files (task->priv->client, trusted, task->priv->files, &error_local);
 	if (!ret) {
 		length = g_strv_length (task->priv->files);
 		/* TRANSLATORS: title: detailed internal error why the file install failed */
@@ -1666,13 +1619,10 @@ gpk_dbus_task_is_installed (GpkDbusTask *task, const gchar *package_name)
 
 	task->priv->role = GPK_DBUS_TASK_ROLE_IS_INSTALLED;
 
-	/* set timeout */
-	pk_client_set_timeout (task->priv->client_primary, task->priv->timeout, NULL);
-
 	/* get the package list for the installed packages */
 	package_names = g_strsplit (package_name, "|", 1);
 	egg_warning ("package_name=%s", package_name);
-	ret = pk_client_resolve (task->priv->client_primary, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), package_names, &error_local);
+	ret = pk_client_resolve (task->priv->client, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), package_names, &error_local);
 	if (!ret) {
 		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "failed to get installed status: %s", error_local->message);
 		dbus_g_method_return_error (task->priv->context, error);
@@ -1700,12 +1650,9 @@ gpk_dbus_task_search_file (GpkDbusTask *task, const gchar *search_file)
 
 	task->priv->role = GPK_DBUS_TASK_ROLE_SEARCH_FILE;
 
-	/* set timeout */
-	pk_client_set_timeout (task->priv->client_primary, task->priv->timeout, NULL);
-
 	/* get the package list for the installed packages */
 	egg_warning ("package_name=%s", search_file);
-	ret = pk_client_search_file (task->priv->client_primary, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), search_file, &error_local);
+	ret = pk_client_search_file (task->priv->client, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), search_file, &error_local);
 	if (!ret) {
 		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "failed to get installed status: %s", error_local->message);
 		dbus_g_method_return_error (task->priv->context, error);
@@ -1782,12 +1729,8 @@ gpk_dbus_task_install_files_dep_check (GpkDbusTask *task)
 	if (task->priv->show_progress)
 		gpk_modal_dialog_present (task->priv->dialog);
 
-	/* set timeout */
-	pk_client_set_timeout (task->priv->client_primary, task->priv->timeout, NULL);
-
-#if (PK_CHECK_VERSION(0,5,2))
 	/* find out if this would drag in other packages */
-	ret = pk_client_simulate_install_files (task->priv->client_primary, task->priv->files, &error_local);
+	ret = pk_client_simulate_install_files (task->priv->client, task->priv->files, &error_local);
 	if (!ret) {
 		/* TRANSLATORS: error: could not get the extra package list when installing a package */
 		gpk_dbus_task_error_msg (task, _("Could not work out what packages would be also installed"), error_local);
@@ -1795,9 +1738,6 @@ gpk_dbus_task_install_files_dep_check (GpkDbusTask *task)
 		dbus_g_method_return_error (task->priv->context, error);
 		goto out;
 	}
-#else
-	gpk_dbus_task_install_files (task);
-#endif
 
 	/* wait for async reply */
 out:
@@ -1955,11 +1895,8 @@ skip_checks:
 	if (task->priv->show_progress)
 		gpk_modal_dialog_present (task->priv->dialog);
 
-	/* set timeout */
-	pk_client_set_timeout (task->priv->client_primary, task->priv->timeout, NULL);
-
 	/* find out if we can find a package */
-	ret = pk_client_resolve (task->priv->client_primary,
+	ret = pk_client_resolve (task->priv->client,
 				 pk_bitfield_from_enums (PK_FILTER_ENUM_ARCH,
 							 PK_FILTER_ENUM_NEWEST, -1),
 				 packages, &error_local);
@@ -2057,11 +1994,8 @@ skip_checks:
 	gpk_modal_dialog_set_title (task->priv->dialog, _("Searching for file"));
 	gpk_modal_dialog_set_image_status (task->priv->dialog, PK_STATUS_ENUM_WAIT);
 
-	/* set timeout */
-	pk_client_set_timeout (task->priv->client_primary, task->priv->timeout, NULL);
-
 	/* do search */
-	ret = pk_client_search_file (task->priv->client_primary,
+	ret = pk_client_search_file (task->priv->client,
 				     pk_bitfield_from_enums (PK_FILTER_ENUM_ARCH,
 							     PK_FILTER_ENUM_NEWEST, -1),
 				     full_paths[0], &error_local);
@@ -2094,16 +2028,13 @@ gpk_dbus_task_install_gstreamer_codec_part (GpkDbusTask *task, const gchar *code
 	guint len;
 	gchar *title;
 
-	/* set timeout */
-	pk_client_set_timeout (task->priv->client_primary, task->priv->timeout, NULL);
-
 	/* TRANSLATORS: title, searching for codecs */
 	title = g_strdup_printf (_("Searching for plugin: %s"), codec_name);
 	gpk_modal_dialog_set_message (task->priv->dialog, title);
 	g_free (title);
 
 	/* get codec packages, FIXME: synchronous! */
-	ret = pk_client_what_provides (task->priv->client_primary,
+	ret = pk_client_what_provides (task->priv->client,
 				       pk_bitfield_from_enums (PK_FILTER_ENUM_NOT_INSTALLED,
 							       PK_FILTER_ENUM_ARCH,
 							       PK_FILTER_ENUM_NEWEST, -1),
@@ -2111,7 +2042,7 @@ gpk_dbus_task_install_gstreamer_codec_part (GpkDbusTask *task, const gchar *code
 	if (!ret)
 		return NULL;
 
-	list = pk_results_get_package_array (task->priv->client_primary);
+	list = pk_results_get_package_array (task->priv->client);
 
 	/* found nothing? */
 	if (list->len == 0) {
@@ -2453,11 +2384,8 @@ skip_checks:
 	if (task->priv->show_progress)
 		gpk_modal_dialog_present (task->priv->dialog);
 
-	/* set timeout */
-	pk_client_set_timeout (task->priv->client_primary, task->priv->timeout, NULL);
-
 	/* action */
-	ret = pk_client_what_provides (task->priv->client_primary,
+	ret = pk_client_what_provides (task->priv->client,
 				       pk_bitfield_from_enums (PK_FILTER_ENUM_NOT_INSTALLED,
 							       PK_FILTER_ENUM_ARCH,
 							       PK_FILTER_ENUM_NEWEST, -1),
@@ -2691,11 +2619,8 @@ skip_checks:
 	list = g_ptr_array_new_with_free_func_xxx ();
 	for (i=0; i<len; i++) {
 
-		/* set timeout */
-		pk_client_set_timeout (task->priv->client_primary, task->priv->timeout, NULL);
-
 		/* action: FIXME: synchronous */
-		ret = pk_client_what_provides (task->priv->client_primary,
+		ret = pk_client_what_provides (task->priv->client,
 					       pk_bitfield_from_enums (PK_FILTER_ENUM_NOT_INSTALLED,
 								       PK_FILTER_ENUM_ARCH,
 								       PK_FILTER_ENUM_NEWEST, -1),
@@ -2709,7 +2634,7 @@ skip_checks:
 		}
 
 		/* add to main list */
-		list_tmp = pk_results_get_package_array (task->priv->client_primary);
+		list_tmp = pk_results_get_package_array (task->priv->client);
 		g_ptr_array_add_list (list, list_tmp);
 		g_object_unref (list_tmp);
 	}
@@ -2933,11 +2858,8 @@ gpk_dbus_task_get_package_for_exec (GpkDbusTask *task, const gchar *exec)
 	GPtrArray *list = NULL;
 	const PkItemPackage *item;
 
-	/* set timeout */
-	pk_client_set_timeout (task->priv->client_primary, task->priv->timeout, NULL);
-
 	/* find the package name */
-	ret = pk_client_search_file (task->priv->client_primary, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), exec, &error);
+	ret = pk_client_search_file (task->priv->client, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), exec, &error);
 	if (!ret) {
 		egg_warning ("failed to search file: %s", error->message);
 		g_error_free (error);
@@ -2945,7 +2867,7 @@ gpk_dbus_task_get_package_for_exec (GpkDbusTask *task, const gchar *exec)
 	}
 
 	/* get the list of packages */
-	list = pk_results_get_package_array (task->priv->client_primary);
+	list = pk_results_get_package_array (task->priv->client);
 
 	/* nothing found */
 	if (list->len == 0) {
@@ -3079,7 +3001,6 @@ gpk_dbus_task_init (GpkDbusTask *task)
 	task->priv->show_finished = TRUE;
 	task->priv->show_warning = TRUE;
 	task->priv->timestamp = 0;
-	task->priv->timeout = -1;
 	task->priv->last_exit_code = PK_ERROR_ENUM_UNKNOWN;
 	task->priv->role = GPK_DBUS_TASK_ROLE_UNKNOWN;
 
@@ -3119,33 +3040,24 @@ gpk_dbus_task_init (GpkDbusTask *task)
 	task->priv->control = pk_control_new ();
 	task->priv->roles = pk_control_get_properties (task->priv->control, NULL, NULL);
 
-	task->priv->client_primary = pk_client_new ();
-	g_signal_connect (task->priv->client_primary, "finished",
+	task->priv->client = pk_client_new ();
+	g_signal_connect (task->priv->client, "finished",
 			  G_CALLBACK (gpk_dbus_task_finished_cb), task);
-	g_signal_connect (task->priv->client_primary, "progress-changed",
+	g_signal_connect (task->priv->client, "progress-changed",
 			  G_CALLBACK (gpk_dbus_task_progress_changed_cb), task);
-	g_signal_connect (task->priv->client_primary, "status-changed",
+	g_signal_connect (task->priv->client, "status-changed",
 			  G_CALLBACK (gpk_dbus_task_status_changed_cb), task);
-	g_signal_connect (task->priv->client_primary, "error-code",
+	g_signal_connect (task->priv->client, "error-code",
 			  G_CALLBACK (gpk_dbus_task_error_code_cb), task);
-	g_signal_connect (task->priv->client_primary, "package",
+	g_signal_connect (task->priv->client, "package",
 			  G_CALLBACK (gpk_dbus_task_package_cb), task);
-	g_signal_connect (task->priv->client_primary, "allow-cancel",
+	g_signal_connect (task->priv->client, "allow-cancel",
 			  G_CALLBACK (gpk_dbus_task_allow_cancel_cb), task);
-	g_signal_connect (task->priv->client_primary, "repo-signature-required",
+	g_signal_connect (task->priv->client, "repo-signature-required",
 			  G_CALLBACK (gpk_dbus_task_repo_signature_required_cb), task);
-	g_signal_connect (task->priv->client_primary, "eula-required",
+	g_signal_connect (task->priv->client, "eula-required",
 			  G_CALLBACK (gpk_dbus_task_eula_required_cb), task);
 
-	/* this is asynchronous, else we get into livelock */
-	task->priv->client_secondary = pk_client_new ();
-	g_signal_connect (task->priv->client_secondary, "finished",
-			  G_CALLBACK (gpk_dbus_task_finished_cb), task);
-	g_signal_connect (task->priv->client_secondary, "error-code",
-			  G_CALLBACK (gpk_dbus_task_error_code_cb), task);
-	g_signal_connect (task->priv->client_secondary, "status-changed",
-			  G_CALLBACK (gpk_dbus_task_status_changed_cb), task);
-
 	/* used for icons and translations */
 	task->priv->desktop = pk_desktop_new ();
 	ret = pk_desktop_open_database (task->priv->desktop, NULL);
@@ -3172,8 +3084,7 @@ gpk_dbus_task_finalize (GObject *object)
 	g_free (task->priv->error_details);
 	g_strfreev (task->priv->files);
 	g_strfreev (task->priv->package_ids);
-	g_object_unref (task->priv->client_primary);
-	g_object_unref (task->priv->client_secondary);
+	g_object_unref (task->priv->client);
 	g_object_unref (task->priv->control);
 	g_object_unref (task->priv->desktop);
 	g_object_unref (task->priv->gconf_client);
diff --git a/src/gpk-dbus-task.h b/src/gpk-dbus-task.h
index 2341a08..b17d660 100644
--- a/src/gpk-dbus-task.h
+++ b/src/gpk-dbus-task.h
@@ -108,8 +108,6 @@ void		 gpk_dbus_task_install_catalogs		(GpkDbusTask	*task,
 /* set state */
 gboolean	 gpk_dbus_task_set_interaction		(GpkDbusTask	*task,
 							 PkBitfield	 interact);
-gboolean	 gpk_dbus_task_set_timeout		(GpkDbusTask	*task,
-							 gint		 timeout);
 gboolean	 gpk_dbus_task_set_timestamp		(GpkDbusTask	*task,
 							 guint		 timeout);
 gboolean	 gpk_dbus_task_set_context		(GpkDbusTask	*task,
diff --git a/src/gpk-dbus.c b/src/gpk-dbus.c
index 6806f31..8eab795 100644
--- a/src/gpk-dbus.c
+++ b/src/gpk-dbus.c
@@ -492,7 +492,7 @@ gpk_dbus_init (GpkDbus *dbus)
 	dbus->priv = GPK_DBUS_GET_PRIVATE (dbus);
 	dbus->priv->timeout_tmp = -1;
 	dbus->priv->gconf_client = gconf_client_get_default ();
-	dbus->priv->array = g_ptr_array_new_with_free_func (g_object_unref)
+	dbus->priv->array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
 	dbus->priv->x11 = gpk_x11_new ();
 
 	/* find out PIDs on the session bus */
diff --git a/src/gpk-watch.c b/src/gpk-watch.c
index 6714a42..afdb18a 100644
--- a/src/gpk-watch.c
+++ b/src/gpk-watch.c
@@ -404,317 +404,6 @@ gpk_watch_libnotify_cb (NotifyNotification *notification, gchar *action, gpointe
 }
 
 /**
- * gpk_watch_task_list_finished_cb:
- **/
-static void
-gpk_watch_task_list_finished_cb (PkTransactionList *tlist, PkClient *client, PkExitEnum exit_enum, guint runtime, GpkWatch *watch)
-{
-xxx
-	guint i;
-	gboolean ret;
-	gboolean value;
-	PkRoleEnum role;
-	PkRestartEnum restart;
-	GError *error = NULL;
-	gchar *text = NULL;
-	gchar *message = NULL;
-	NotifyNotification *notification;
-	guint j;
-	const PkItemRequireRestart *item;
-	const PkItemRequireRestart *item_tmp;
-	GPtrArray *array;
-	gchar **split;
-
-	g_return_if_fail (GPK_IS_WATCH (watch));
-
-	/* get the role */
-	ret = pk_client_get_role (client, &role, &text, NULL);
-	if (!ret) {
-		egg_warning ("cannot get role");
-		goto out;
-	}
-	egg_debug ("role=%s, text=%s", pk_role_enum_to_text (role), text);
-
-	/* is it worth processing? */
-	if (exit_enum != PK_EXIT_ENUM_SUCCESS) {
-		egg_debug ("not processing, as didn't complete okay");
-		goto out;
-	}
-
-	/* show an icon if the user needs to reboot */
-	if (role == PK_ROLE_ENUM_UPDATE_PACKAGES ||
-	    role == PK_ROLE_ENUM_INSTALL_PACKAGES ||
-	    role == PK_ROLE_ENUM_UPDATE_SYSTEM) {
-		/* if more important than what we are already showing, then update the icon */
-		restart = pk_client_get_require_restart (client);
-		if (restart > watch->priv->restart) {
-			/* list packages requiring this */
-			array = pk_client_get_require_restart_list (client);
-			if (array == NULL) {
-				egg_warning ("no data about restarts, perhaps not buffered");
-				goto no_data;
-			}
-			for (i=0; i<array->len; i++) {
-				item = g_ptr_array_index (array, i);
-
-				/* is a lesser restart that what we have already */
-				if (item->restart != restart)
-					continue;
-
-				split = pk_package_id_split (item->package_id);
-				
-				/* is already in the list */
-				ret = FALSE;
-				for (j=0; j<array->len; j++) {
-					item_tmp = g_ptr_array_index (array, j);
-					if (g_strcmp0 (item_tmp->id->name, split[PK_PACKAGE_ID_NAME]) == 0) {
-						ret = TRUE;
-						break;
-					}
-				}
-				if (ret)
-					continue;
-
-				/* add to list */
-				g_ptr_array_add (watch->priv->restart_package_names, g_strdup (split[PK_PACKAGE_ID_NAME]));
-				g_strfreev (split);
-			}
-			g_object_unref (array);
-no_data:
-			/* save new restart */
-			watch->priv->restart = restart;
-		}
-	}
-
-	/* is it worth showing a UI? */
-	if (runtime < 3000) {
-		egg_debug ("no notification, too quick");
-		goto out;
-	}
-
-	/* are we accepting notifications */
-	value = gconf_client_get_bool (watch->priv->gconf_client, GPK_CONF_NOTIFY_COMPLETED, NULL);
-	if (!value) {
-		egg_debug ("not showing notification as prevented in gconf");
-		goto out;
-	}
-
-	/* is caller able to handle the messages itself? */
-	ret = pk_client_is_caller_active (client, &value, &error);
-	if (!ret) {
-		egg_warning ("could not get caller active status: %s", error->message);
-		g_error_free (error);
-		goto out;
-	}
-	if (value) {
-		egg_debug ("not showing notification as caller is still present");
-		goto out;
-	}
-
-	if (role == PK_ROLE_ENUM_REMOVE_PACKAGES)
-		/* TRANSLATORS: This is the message in the libnotify body */
-		message = g_strdup_printf (_("Package '%s' has been removed"), text);
-	else if (role == PK_ROLE_ENUM_INSTALL_PACKAGES)
-		/* TRANSLATORS: This is the message in the libnotify body */
-		message = g_strdup_printf (_("Package '%s' has been installed"), text);
-	else if (role == PK_ROLE_ENUM_UPDATE_SYSTEM)
-		/* TRANSLATORS: This is the message in the libnotify body */
-		message = g_strdup (_("System has been updated"));
-
-	/* nothing of interest */
-	if (message == NULL)
-		goto out;
-
-	/* TRANSLATORS: title: an action has finished, and we are showing the libnotify bubble */
-	notification = notify_notification_new (_("Task completed"), message, "help-browser", NULL);
-	notify_notification_set_timeout (notification, 5000);
-	notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
-	notify_notification_add_action (notification, "do-not-show-notify-complete",
-					_("Do not show this again"), gpk_watch_libnotify_cb, watch, NULL);
-	ret = notify_notification_show (notification, &error);
-	if (!ret) {
-		egg_warning ("error: %s", error->message);
-		g_error_free (error);
-	}
-
-out:
-	g_free (message);
-	g_free (text);
-}
-
-/**
- * gpk_watch_error_code_cb:
- **/
-static void
-gpk_watch_error_code_cb (PkTransactionList *tlist, PkClient *client, PkErrorCodeEnum error_code, const gchar *details, GpkWatch *watch)
-{
-xxx
-	gboolean ret;
-	GError *error = NULL;
-	const gchar *title;
-	gchar *title_prefix;
-	const gchar *message;
-	gboolean is_active;
-	gboolean value;
-	NotifyNotification *notification;
-
-	g_return_if_fail (GPK_IS_WATCH (watch));
-
-	title = gpk_error_enum_to_localised_text (error_code);
-
-	/* if the client dbus connection is still active */
-	pk_client_is_caller_active (client, &is_active, NULL);
-
-	/* do we ignore this error? */
-	if (is_active) {
-		egg_debug ("client active so leaving error %s%s", title, details);
-		return;
-	}
-
-	/* ignore some errors */
-	if (error_code == PK_ERROR_ENUM_NOT_SUPPORTED ||
-	    error_code == PK_ERROR_ENUM_NO_NETWORK ||
-	    error_code == PK_ERROR_ENUM_PROCESS_KILL ||
-	    error_code == PK_ERROR_ENUM_TRANSACTION_CANCELLED) {
-		egg_debug ("error ignored %s%s", title, details);
-		return;
-	}
-
-	/* are we accepting notifications */
-	value = gconf_client_get_bool (watch->priv->gconf_client, GPK_CONF_NOTIFY_ERROR, NULL);
-	if (!value) {
-		egg_debug ("not showing notification as prevented in gconf");
-		return;
-	}
-
-	/* we need to format this */
-	message = gpk_error_enum_to_localised_message (error_code);
-
-	/* save this globally */
-	g_free (watch->priv->error_details);
-	watch->priv->error_details = g_markup_escape_text (details, -1);
-
-	/* TRANSLATORS: Prefix to the title shown in the libnotify popup */
-	title_prefix = g_strdup_printf ("%s: %s", _("Package Manager"), title);
-
-	/* do the bubble */
-	notification = notify_notification_new (title_prefix, message, "help-browser", NULL);
-	notify_notification_set_timeout (notification, 15000);
-	notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
-	notify_notification_add_action (notification, "show-error-details",
-					/* TRANSLATORS: This is a link in a libnotify bubble that shows the detailed error */
-					_("Show details"), gpk_watch_libnotify_cb, watch, NULL);
-
-	ret = notify_notification_show (notification, &error);
-	if (!ret) {
-		egg_warning ("error: %s", error->message);
-		g_error_free (error);
-	}
-	g_free (title_prefix);
-}
-
-/**
- * gpk_watch_is_message_ignored:
- **/
-static gboolean
-gpk_watch_is_message_ignored (GpkWatch *watch, PkMessageEnum message)
-{
-	guint i;
-	gboolean ret = FALSE;
-	gchar *ignored_str;
-	gchar **ignored = NULL;
-	const gchar *message_str;
-
-	/* get from gconf */
-	ignored_str = gconf_client_get_string (watch->priv->gconf_client, GPK_CONF_IGNORED_MESSAGES, NULL);
-	if (ignored_str == NULL) {
-		egg_warning ("could not read ignored list");
-		goto out;
-	}
-
-	/* nothing in list, common case */
-	if (egg_strzero (ignored_str)) {
-		egg_debug ("nothing in ignored list");
-		goto out;
-	}
-
-	/* split using "," */
-	ignored = g_strsplit (ignored_str, ",", 0);
-
-	/* remove any ignored pattern matches */
-	message_str = pk_message_enum_to_text (message);
-	for (i=0; ignored[i] != NULL; i++) {
-		ret = g_pattern_match_simple (ignored[i], message_str);
-		if (ret) {
-			egg_debug ("match %s for %s, ignoring", ignored[i], message_str);
-			break;
-		}
-	}
-out:
-	g_free (ignored_str);
-	g_strfreev (ignored);
-	return ret;
-}
-
-/**
- * gpk_watch_message_cb:
- **/
-static void
-gpk_watch_message_cb (PkTransactionList *tlist, PkClient *client, PkMessageEnum message, const gchar *details, GpkWatch *watch)
-{
-xxx
-	gboolean ret;
-	GError *error = NULL;
-	gboolean value;
-	NotifyNotification *notification;
-	GpkWatchCachedMessage *cached_message;
-
-	g_return_if_fail (GPK_IS_WATCH (watch));
-
-	/* is ignored */
-	ret = gpk_watch_is_message_ignored (watch, message);
-	if (ret) {
-		egg_debug ("igoring message");
-		return;
-	}
-
-	/* add to list */
-	cached_message = g_new0 (GpkWatchCachedMessage, 1);
-	cached_message->type = message;
-	cached_message->tid = pk_client_get_tid (client);
-	cached_message->details = g_strdup (details);
-	g_ptr_array_add (watch->priv->cached_messages, cached_message);
-
-	/* close existing */
-	if (watch->priv->notification_cached_messages != NULL) {
-		ret = notify_notification_close (watch->priv->notification_cached_messages, &error);
-		if (!ret) {
-			egg_warning ("error: %s", error->message);
-			g_error_free (error);
-			error = NULL;
-		}
-	}
-
-	/* are we accepting notifications */
-	value = gconf_client_get_bool (watch->priv->gconf_client, GPK_CONF_NOTIFY_MESSAGE, NULL);
-	if (!value) {
-		egg_debug ("not showing notification as prevented in gconf");
-		return;
-	}
-
-	/* do the bubble */
-	notification = notify_notification_new_with_status_icon (_("New package manager message"), NULL, "emblem-important", watch->priv->status_icon);
-	notify_notification_set_timeout (notification, NOTIFY_EXPIRES_NEVER);
-	notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
-	ret = notify_notification_show (notification, &error);
-	if (!ret) {
-		egg_warning ("error: %s", error->message);
-		g_error_free (error);
-	}
-	watch->priv->notification_cached_messages = notification;
-}
-
-/**
  * gpk_watch_about_dialog_url_cb:
  **/
 static void
@@ -999,7 +688,7 @@ gpk_watch_lookup_progress_from_transaction_id (GpkWatch *watch, const gchar *tra
 	PkProgress *progress;
 
 	array = watch->priv->array_progress;
-	for (i=0; i<array->length; i++) {
+	for (i=0; i<array->len; i++) {
 		progress = g_ptr_array_index (array, i);
 		g_object_get (progress,
 			      "transaction-id", &tid_tmp,
@@ -1018,27 +707,25 @@ out:
  * gpk_watch_monitor_tid:
  **/
 static gboolean
-gpk_watch_monitor_tid (GpkWatch *watch, const gchar *tid)
+gpk_watch_monitor_tid (GpkWatch *watch, const gchar *transaction_id)
 {
 	gboolean allow_cancel;
-	gboolean ret;
 	gchar *package_id = NULL;
 	gchar *text;
 	guint percentage;
 	guint remaining_time;
-	GError *error = NULL;
 	PkProgress *progress;
 	PkRoleEnum role;
 	PkStatusEnum status;
 
 	g_free (watch->priv->transaction_id);
-	watch->priv->transaction_id = g_strdup (tid);
+	watch->priv->transaction_id = g_strdup (transaction_id);
 
 	/* find progress */
 	progress = gpk_watch_lookup_progress_from_transaction_id (watch, transaction_id);
 	if (progress == NULL) {
 		egg_warning ("could not find: %s", transaction_id);
-		return;
+		return FALSE;
 	}
 
 	/* fill in role */
@@ -1121,7 +808,7 @@ gpk_watch_populate_menu_with_jobs (GpkWatch *watch, GtkMenu *menu)
 	gchar *transaction_id;
 	GPtrArray *array;
 
-	g_return_val_if_fail (GPK_IS_WATCH (watch), 0);
+	g_return_if_fail (GPK_IS_WATCH (watch));
 
 	array = watch->priv->array_progress;
 	if (array->len == 0)
@@ -1514,32 +1201,279 @@ gpk_watch_button_cancel_cb (GtkWidget *widget, GpkWatch *watch)
 }
 
 /**
+ * gpk_watch_set_connected:
+ **/
+static void
+gpk_watch_set_connected (GpkWatch *watch, gboolean connected)
+{
+	if (!connected) {
+		gtk_status_icon_set_visible (watch->priv->status_icon, FALSE);
+		return;
+	}
+
+	/* daemon has just appeared */
+	gpk_watch_refresh_icon (watch);
+	gpk_watch_refresh_tooltip (watch);
+	gpk_watch_set_proxies (watch);
+}
+
+/**
  * gpk_watch_notify_connected_cb:
  **/
 static void
-gpk_watch_notify_connected_cb (PkControl *control, GParamSpec *pspec, gpointer data)
+gpk_watch_notify_connected_cb (PkControl *control, GParamSpec *pspec, GpkWatch *watch)
 {
 	gboolean connected;
 	g_object_get (control, "connected", &connected, NULL);
-	if (connected) {
-		gpk_watch_refresh_icon (watch);
-		gpk_watch_refresh_tooltip (watch);
-		gpk_watch_set_proxies (watch);
-	} else {
-		gtk_status_icon_set_visible (watch->priv->status_icon, FALSE);
+	gpk_watch_set_connected (watch, connected);
+}
+
+/**
+ * gpk_watch_is_message_ignored:
+ **/
+static gboolean
+gpk_watch_is_message_ignored (GpkWatch *watch, PkMessageEnum message)
+{
+	guint i;
+	gboolean ret = FALSE;
+	gchar *ignored_str;
+	gchar **ignored = NULL;
+	const gchar *message_str;
+
+	/* get from gconf */
+	ignored_str = gconf_client_get_string (watch->priv->gconf_client, GPK_CONF_IGNORED_MESSAGES, NULL);
+	if (ignored_str == NULL) {
+		egg_warning ("could not read ignored list");
+		goto out;
+	}
+
+	/* nothing in list, common case */
+	if (egg_strzero (ignored_str)) {
+		egg_debug ("nothing in ignored list");
+		goto out;
 	}
+
+	/* split using "," */
+	ignored = g_strsplit (ignored_str, ",", 0);
+
+	/* remove any ignored pattern matches */
+	message_str = pk_message_enum_to_text (message);
+	for (i=0; ignored[i] != NULL; i++) {
+		ret = g_pattern_match_simple (ignored[i], message_str);
+		if (ret) {
+			egg_debug ("match %s for %s, ignoring", ignored[i], message_str);
+			break;
+		}
+	}
+out:
+	g_free (ignored_str);
+	g_strfreev (ignored);
+	return ret;
+}
+
+/**
+ * pk_watch_process_messages_cb:
+ **/
+static void
+pk_watch_process_messages_cb (PkItemMessage *item, GpkWatch *watch)
+{
+	gboolean ret;
+	GError *error = NULL;
+	gboolean value;
+	NotifyNotification *notification;
+	GpkWatchCachedMessage *cached_message;
+
+	g_return_if_fail (GPK_IS_WATCH (watch));
+
+	/* is ignored */
+	ret = gpk_watch_is_message_ignored (watch, item->type);
+	if (ret) {
+		egg_debug ("ignoring message");
+		return;
+	}
+
+	/* add to list */
+	cached_message = g_new0 (GpkWatchCachedMessage, 1);
+	cached_message->type = item->type;
+	cached_message->tid = NULL;
+	cached_message->details = g_strdup (item->details);
+	g_ptr_array_add (watch->priv->cached_messages, cached_message);
+
+	/* close existing */
+	if (watch->priv->notification_cached_messages != NULL) {
+		ret = notify_notification_close (watch->priv->notification_cached_messages, &error);
+		if (!ret) {
+			egg_warning ("error: %s", error->message);
+			g_error_free (error);
+			error = NULL;
+		}
+	}
+
+	/* are we accepting notifications */
+	value = gconf_client_get_bool (watch->priv->gconf_client, GPK_CONF_NOTIFY_MESSAGE, NULL);
+	if (!value) {
+		egg_debug ("not showing notification as prevented in gconf");
+		return;
+	}
+
+	/* do the bubble */
+	notification = notify_notification_new_with_status_icon (_("New package manager message"), NULL, "emblem-important", watch->priv->status_icon);
+	notify_notification_set_timeout (notification, NOTIFY_EXPIRES_NEVER);
+	notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
+	ret = notify_notification_show (notification, &error);
+	if (!ret) {
+		egg_warning ("error: %s", error->message);
+		g_error_free (error);
+	}
+	watch->priv->notification_cached_messages = notification;
+}
+
+/**
+ * pk_watch_process_error_code_cb:
+ **/
+static void
+pk_watch_process_error_code_cb (PkItemErrorCode *item, GpkWatch *watch)
+{
+	gboolean ret;
+	GError *error = NULL;
+	const gchar *title;
+	gchar *title_prefix = NULL;
+	const gchar *message;
+	gboolean caller_active = FALSE;
+	gboolean value;
+	NotifyNotification *notification;
+	PkResults *results = PK_RESULTS (item->user_data);
+	PkProgress *progress = NULL;
+
+	g_return_if_fail (GPK_IS_WATCH (watch));
+
+	title = gpk_error_enum_to_localised_text (item->code);
+
+	/* get progress data about the transaction */
+	g_object_get (results,
+		      "progress", &progress,
+		      NULL);
+
+	/* if the client dbus connection is still active */
+	g_object_get (progress,
+		      "caller-active", &caller_active,
+		      NULL);
+
+	/* do we ignore this error? */
+	if (caller_active) {
+		egg_debug ("client active so leaving error %s%s", title, item->details);
+		goto out;
+	}
+
+	/* ignore some errors */
+	if (item->code == PK_ERROR_ENUM_NOT_SUPPORTED ||
+	    item->code == PK_ERROR_ENUM_NO_NETWORK ||
+	    item->code == PK_ERROR_ENUM_PROCESS_KILL ||
+	    item->code == PK_ERROR_ENUM_TRANSACTION_CANCELLED) {
+		egg_debug ("error ignored %s%s", title, item->details);
+		goto out;
+	}
+
+	/* are we accepting notifications */
+	value = gconf_client_get_bool (watch->priv->gconf_client, GPK_CONF_NOTIFY_ERROR, NULL);
+	if (!value) {
+		egg_debug ("not showing notification as prevented in gconf");
+		goto out;
+	}
+
+	/* we need to format this */
+	message = gpk_error_enum_to_localised_message (item->code);
+
+	/* save this globally */
+	g_free (watch->priv->error_details);
+	watch->priv->error_details = g_markup_escape_text (item->details, -1);
+
+	/* TRANSLATORS: Prefix to the title shown in the libnotify popup */
+	title_prefix = g_strdup_printf ("%s: %s", _("Package Manager"), title);
+
+	/* do the bubble */
+	notification = notify_notification_new (title_prefix, message, "help-browser", NULL);
+	notify_notification_set_timeout (notification, 15000);
+	notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
+	notify_notification_add_action (notification, "show-error-details",
+					/* TRANSLATORS: This is a link in a libnotify bubble that shows the detailed error */
+					_("Show details"), gpk_watch_libnotify_cb, watch, NULL);
+
+	ret = notify_notification_show (notification, &error);
+	if (!ret) {
+		egg_warning ("error: %s", error->message);
+		g_error_free (error);
+	}
+out:
+	g_free (title_prefix);
+	if (progress != NULL)
+		g_object_unref (progress);
+}
+
+/**
+ * pk_watch_set_error_code_userdata_cb:
+ **/
+static void
+pk_watch_set_error_code_userdata_cb (PkItemErrorCode *item, PkResults *results)
+{
+	item->user_data = results;
+}
+
+/**
+ * pk_watch_process_require_restart_cb:
+ **/
+static void
+pk_watch_process_require_restart_cb (PkItemRequireRestart *item, GpkWatch *watch)
+{
+	GPtrArray *array = NULL;
+	GPtrArray *names = NULL;
+	const gchar *name;
+	gchar **split = NULL;
+	guint i;
+
+	/* if less important than what we are already showing */
+	if (item->restart <= watch->priv->restart)
+		goto out;
+
+	/* add name if not already in the list */
+	split = pk_package_id_split (item->package_id);
+	names = watch->priv->restart_package_names;
+	for (i=0; i<names->len; i++) {
+		name = g_ptr_array_index (names, i);
+		if (g_strcmp0 (name, split[PK_PACKAGE_ID_NAME]) == 0)
+			break;
+	}
+	if (i < names->len) {
+		/* add to list */
+		g_ptr_array_add (names, g_strdup (split[PK_PACKAGE_ID_NAME]));
+	}
+
+	/* save new restart */
+	watch->priv->restart = item->restart;
+out:
+	g_strfreev (split);
+	if (array != NULL)
+		g_object_unref (array);
 }
 
 /**
  * gpk_watch_adopt_cb:
  **/
 static void
-gpk_watch_adopt_cb (PkClient *client, GAsyncResult *res, gpointer user_data)
+gpk_watch_adopt_cb (PkClient *client, GAsyncResult *res, GpkWatch *watch)
 {
+	const gchar *message = NULL;
+	gboolean caller_active;
+	gboolean ret;
+	gchar *transaction_id = NULL;
 	GError *error = NULL;
-	PkResults *results = NULL;
+	GPtrArray *array;
+	guint elapsed_time;
+	NotifyNotification *notification;
 	PkExitEnum exit_enum;
-	gchar *transaction_id = NULL;
+	PkProgress *progress = NULL;
+	PkResults *results = NULL;
+	PkRoleEnum role;
 
 	/* get the results */
 	results = pk_client_generic_finish (client, res, &error);
@@ -1551,11 +1485,17 @@ gpk_watch_adopt_cb (PkClient *client, GAsyncResult *res, gpointer user_data)
 
 	/* get data about the transaction */
 	g_object_get (results,
+		      "role", &role,
+		      "progress", &progress,
+		      NULL);
+
+	/* get data */
+	g_object_get (progress,
 		      "transaction-id", &transaction_id,
 		      NULL);
 
 	/* is not the watched transaction */
-	if (g_strcmp0 (transaction_id, progress->priv->transaction_id) != 0)
+	if (g_strcmp0 (transaction_id, watch->priv->transaction_id) != 0)
 		goto out;
 
 	/* stop spinning */
@@ -1565,8 +1505,91 @@ gpk_watch_adopt_cb (PkClient *client, GAsyncResult *res, gpointer user_data)
 	exit_enum = pk_results_get_exit_code (results);
 	if (exit_enum == PK_EXIT_ENUM_SUCCESS)
 		gpk_modal_dialog_close (watch->priv->dialog);
+
+	/* process messages */
+	if (exit_enum == PK_EXIT_ENUM_SUCCESS) {
+		array = pk_results_get_message_array (results);
+		g_ptr_array_foreach (array, (GFunc) pk_watch_process_messages_cb, watch);
+		g_ptr_array_unref (array);
+	}
+
+	/* process errors */
+	if (exit_enum != PK_EXIT_ENUM_SUCCESS) {
+		array = pk_results_get_error_code_array (results);
+		g_ptr_array_foreach (array, (GFunc) pk_watch_set_error_code_userdata_cb, results);
+		g_ptr_array_foreach (array, (GFunc) pk_watch_process_error_code_cb, watch);
+		g_ptr_array_unref (array);
+		goto out;
+	}
+
+	/* process restarts */
+	if (role == PK_ROLE_ENUM_UPDATE_PACKAGES ||
+	    role == PK_ROLE_ENUM_INSTALL_PACKAGES ||
+	    role == PK_ROLE_ENUM_UPDATE_SYSTEM) {
+		array = pk_results_get_require_restart_array (results);
+		g_ptr_array_foreach (array, (GFunc) pk_watch_process_require_restart_cb, watch);
+		g_ptr_array_unref (array);
+	}
+
+	/* are we accepting notifications */
+	ret = gconf_client_get_bool (watch->priv->gconf_client, GPK_CONF_NOTIFY_COMPLETED, NULL);
+	if (!ret) {
+		egg_debug ("not showing notification as prevented in gconf");
+		goto out;
+	}
+
+	/* get progress data about the transaction */
+	g_object_get (results,
+		      "progress", &progress,
+		      NULL);
+
+	/* if the client dbus connection is still active */
+	g_object_get (progress,
+		      "caller-active", &caller_active,
+		      "elapsed-time", &elapsed_time,
+		      NULL);
+
+	/* is it worth showing a UI? */
+	if (elapsed_time < 3000) {
+		egg_debug ("no notification, too quick");
+		goto out;
+	}
+
+	/* is caller able to handle the messages itself? */
+	if (caller_active) {
+		egg_debug ("not showing notification as caller is still present");
+		goto out;
+	}
+
+	if (role == PK_ROLE_ENUM_REMOVE_PACKAGES)
+		/* TRANSLATORS: This is the message in the libnotify body */
+		message = _("Packages have been removed");
+	else if (role == PK_ROLE_ENUM_INSTALL_PACKAGES)
+		/* TRANSLATORS: This is the message in the libnotify body */
+		message = _("Packages have been installed");
+	else if (role == PK_ROLE_ENUM_UPDATE_SYSTEM)
+		/* TRANSLATORS: This is the message in the libnotify body */
+		message = _("System has been updated");
+
+	/* nothing of interest */
+	if (message == NULL)
+		goto out;
+
+	/* TRANSLATORS: title: an action has finished, and we are showing the libnotify bubble */
+	notification = notify_notification_new (_("Task completed"), message, "help-browser", NULL);
+	notify_notification_set_timeout (notification, 5000);
+	notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
+	notify_notification_add_action (notification, "do-not-show-notify-complete",
+					_("Do not show this again"), gpk_watch_libnotify_cb, watch, NULL);
+	ret = notify_notification_show (notification, &error);
+	if (!ret) {
+		egg_warning ("error: %s", error->message);
+		g_error_free (error);
+	}
 out:
 	g_free (transaction_id);
+	if (progress != NULL)
+		g_object_unref (progress);
 	if (results != NULL)
 		g_object_unref (results);
 }
@@ -1575,7 +1598,7 @@ out:
  * gpk_watch_progress_cb:
  **/
 static void
-gpk_watch_progress_cb (PkProgress *progress, PkProgressType type, gpointer user_data)
+gpk_watch_progress_cb (PkProgress *progress, PkProgressType type, GpkWatch *watch)
 {
 	PkStatusEnum status;
 	guint percentage;
@@ -1591,7 +1614,7 @@ gpk_watch_progress_cb (PkProgress *progress, PkProgressType type, gpointer user_
 
 	/* add if not already in list */
 	array = watch->priv->array_progress;
-	for (i=0; i<array->length; i++) {
+	for (i=0; i<array->len; i++) {
 		progress = g_ptr_array_index (array, i);
 		if (progress_tmp == progress)
 			ret = TRUE;
@@ -1614,7 +1637,7 @@ gpk_watch_progress_cb (PkProgress *progress, PkProgressType type, gpointer user_
 	gpk_watch_refresh_tooltip (watch);
 
 	/* is not the watched transaction */
-	if (g_strcmp0 (transaction_id, progress->priv->transaction_id) != 0)
+	if (g_strcmp0 (transaction_id, watch->priv->transaction_id) != 0)
 		goto out;
 
 	if (type == PK_PROGRESS_TYPE_PACKAGE_ID) {
@@ -1674,6 +1697,37 @@ gpk_watch_transaction_list_removed_cb (PkTransactionList *tlist, const gchar *tr
 }
 
 /**
+ * gpk_check_update_get_properties_cb:
+ **/
+static void
+gpk_check_update_get_properties_cb (GObject *object, GAsyncResult *res, GpkWatch *watch)
+{
+	gboolean connected;
+	GError *error = NULL;
+	PkControl *control = PK_CONTROL(object);
+	gboolean ret;
+
+	/* get the result */
+	ret = pk_control_get_properties_finish (control, res, &error);
+	if (!ret) {
+		/* TRANSLATORS: backend is broken, and won't tell us what it supports */
+		egg_warning ("details could not be retrieved: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
+
+	/* get values */
+	g_object_get (control,
+		      "connected", &connected,
+		      NULL);
+
+	/* coldplug daemon */
+	gpk_watch_set_connected (watch, connected);
+out:
+	return;
+}
+
+/**
  * gpk_watch_init:
  * @watch: This class instance
  **/
@@ -1709,8 +1763,9 @@ gpk_watch_init (GpkWatch *watch)
 			  G_CALLBACK (gpk_watch_locked_cb), watch);
 	g_signal_connect (watch->priv->control, "notify::connected",
 			  G_CALLBACK (gpk_watch_notify_connected_cb), watch);
-	if (pk_connection_valid (watch->priv->control))
-		gpk_watch_connection_changed_cb (watch->priv->control, TRUE, watch);
+
+	/* get properties */
+	pk_control_get_properties_async (watch->priv->control, NULL, (GAsyncReadyCallback) gpk_check_update_get_properties_cb, watch);
 
 	/* do session inhibit */
 	watch->priv->inhibit = gpk_inhibit_new ();



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