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



commit f46370d70f7a0fa6719ca1e84d2116eda87c66a5
Author: Richard Hughes <richard hughsie com>
Date:   Tue Sep 22 16:46:56 2009 +0100

    moo

 src/gpk-dbus-task.c |  795 +++++++++++++++++++++++++--------------------------
 1 files changed, 397 insertions(+), 398 deletions(-)
---
diff --git a/src/gpk-dbus-task.c b/src/gpk-dbus-task.c
index 274147a..5057a36 100644
--- a/src/gpk-dbus-task.c
+++ b/src/gpk-dbus-task.c
@@ -53,14 +53,12 @@
 #include "gpk-helper-chooser.h"
 
 static void     gpk_dbus_task_finalize (GObject *object);
-static void	gpk_dbus_task_install_files (GpkDbusTask *task);
 
 #define GPK_DBUS_TASK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPK_TYPE_DBUS_TASK, GpkDbusTaskPrivate))
 #define GPK_DBUS_TASK_FINISHED_AUTOCLOSE_DELAY	10 /* seconds */
 
 typedef enum {
 	GPK_DBUS_TASK_ROLE_INSTALL_PACKAGE_FILES,
-	GPK_DBUS_TASK_ROLE_INSTALL_PROVIDE_FILES,
 	GPK_DBUS_TASK_ROLE_INSTALL_MIME_TYPES,
 	GPK_DBUS_TASK_ROLE_INSTALL_GSTREAMER_RESOURCES,
 	GPK_DBUS_TASK_ROLE_INSTALL_FONTCONFIG_RESOURCES,
@@ -172,7 +170,6 @@ gpk_dbus_task_set_timestamp (GpkDbusTask *task, guint32 timestamp)
 	return TRUE;
 }
 
-static void gpk_dbus_task_install_files_internal (GpkDbusTask *task);
 static void gpk_dbus_task_install_package_ids (GpkDbusTask *task);
 
 /**
@@ -181,14 +178,14 @@ static void gpk_dbus_task_install_package_ids (GpkDbusTask *task);
 static void
 gpk_dbus_task_chooser_event_cb (GpkHelperChooser *helper_chooser, GtkResponseType type, const gchar *package_id, GpkDbusTask *task)
 {
-	GError *error = NULL;
+	GError *error_dbus = NULL;
 
 	/* selected nothing */
 	if (type != GTK_RESPONSE_YES || package_id == NULL) {
 
 		/* failed */
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "did not choose anything to install");
-		dbus_g_method_return_error (task->priv->context, error);
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "did not choose anything to install");
+		dbus_g_method_return_error (task->priv->context, error_dbus);
 
 		if (task->priv->show_warning) {
 			gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_WARNING, 0);
@@ -207,10 +204,7 @@ gpk_dbus_task_chooser_event_cb (GpkHelperChooser *helper_chooser, GtkResponseTyp
 
 	/* install these packages with deps */
 	gpk_dbus_task_install_package_ids (task);
-
 out:
-	if (error != NULL)
-		g_error_free (error);
 	return;
 }
 
@@ -293,6 +287,7 @@ gpk_dbus_task_install_packages_cb (GObject *object, GAsyncResult *res, GpkDbusTa
 {
 	PkClient *client = PK_CLIENT (object);
 	GError *error = NULL;
+	GError *error_dbus = NULL;
 	PkResults *results = NULL;
 
 	/* get the results */
@@ -300,8 +295,8 @@ gpk_dbus_task_install_packages_cb (GObject *object, GAsyncResult *res, GpkDbusTa
 	if (results == NULL) {
 		/* TRANSLATORS: error: failed to install, detailed error follows */
 		gpk_dbus_task_error_msg (task, _("Failed to install package"), error);
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "%s", error->message);
-		dbus_g_method_return_error (task->priv->context, error);
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "%s", error->message);
+		dbus_g_method_return_error (task->priv->context, error_dbus);
 		g_error_free (error);
 		goto out;
 	}
@@ -336,7 +331,7 @@ gpk_dbus_task_install_package_ids (GpkDbusTask *task)
 static GError *
 gpk_dbus_task_error_from_exit_enum (PkExitEnum exit)
 {
-	GError *error = NULL;
+	GError *error_dbus = NULL;
 
 	/* trivial case */
 	if (exit == PK_EXIT_ENUM_SUCCESS)
@@ -344,15 +339,15 @@ gpk_dbus_task_error_from_exit_enum (PkExitEnum exit)
 
 	/* set the correct error type */
 	if (exit == PK_EXIT_ENUM_FAILED)
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_FAILED, "Unspecified failure");
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_FAILED, "Unspecified failure");
 	else if (exit == PK_EXIT_ENUM_CANCELLED)
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "Transaction was cancelled");
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "Transaction was cancelled");
 	else if (exit == PK_EXIT_ENUM_KEY_REQUIRED)
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "A key was required but not provided");
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "A key was required but not provided");
 	else if (exit == PK_EXIT_ENUM_EULA_REQUIRED)
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "A EULA was not agreed to");
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "A EULA was not agreed to");
 	else if (exit == PK_EXIT_ENUM_KILLED)
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "The transaction was killed");
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "The transaction was killed");
 	else
 		egg_error ("unknown exit code");
 out:
@@ -370,9 +365,9 @@ gpk_dbus_task_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runtime
 	guint len;
 	guint i;
 	const gchar *name = NULL;
-	GError *error = NULL;
+	GError *error_dbus = NULL;
 	GError *error_local = NULL;
-	GPtrArray *list = NULL;
+	GPtrArray *array = NULL;
 	const PkItemPackage *item;
 	gboolean already_installed = FALSE;
 	gchar *title = NULL;
@@ -398,7 +393,7 @@ gpk_dbus_task_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runtime
 
 		/* fail the transaction and set the correct error */
 		error = gpk_dbus_task_error_from_exit_enum (exit_enum);
-		dbus_g_method_return_error (task->priv->context, error);
+		dbus_g_method_return_error (task->priv->context, error_dbus);
 		goto out;
 	}
 
@@ -407,8 +402,8 @@ 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);
-		if (list->len == 0) {
+		array = pk_results_get_package_array (results);
+		if (array->len == 0) {
 			if (task->priv->show_warning) {
 				info_url = gpk_vendor_get_not_found_url (task->priv->vendor, GPK_VENDOR_URL_TYPE_MIME);
 				/* only show the "more info" button if there is a valid link */
@@ -429,8 +424,8 @@ gpk_dbus_task_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runtime
 					gpk_gnome_open (info_url);
 				g_free (info_url);
 			}
-			error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_NO_PACKAGES_FOUND, "nothing was found to handle mime type");
-			dbus_g_method_return_error (task->priv->context, error);
+			error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_NO_PACKAGES_FOUND, "nothing was found to handle mime type");
+			dbus_g_method_return_error (task->priv->context, error_dbus);
 			goto out;
 		}
 
@@ -439,89 +434,20 @@ gpk_dbus_task_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runtime
 		goto out;
 	}
 
-	/* from InstallProvideFiles */
-	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);
-		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);
-				/* only show the "more info" button if there is a valid link */
-				if (info_url != NULL)
-					gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_WARNING, GPK_MODAL_DIALOG_BUTTON_ACTION);
-				else
-					gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_WARNING, 0);
-				/* TRANSLATORS: failed to fild the package for thefile */
-				gpk_modal_dialog_set_title (task->priv->dialog, _("Failed to find package"));
-				/* TRANSLATORS: nothing found */
-				gpk_modal_dialog_set_message (task->priv->dialog, _("The file could not be found in any packages"));
-				gpk_modal_dialog_set_help_id (task->priv->dialog, "dialog-package-not-found");
-				/* TRANSLATORS: button: show the user a button to get more help finding stuff */
-				gpk_modal_dialog_set_action (task->priv->dialog, _("More information"));
-				gpk_modal_dialog_present (task->priv->dialog);
-				button = gpk_modal_dialog_run (task->priv->dialog);
-				if (button == GTK_RESPONSE_OK)
-					gpk_gnome_open (info_url);
-				g_free (info_url);
-			}
-			error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_NO_PACKAGES_FOUND, "no files found");
-			dbus_g_method_return_error (task->priv->context, error);
-			goto out;
-		}
-
-		/* see what we've got already */
-		for (i=0; i<len; i++) {
-			item = g_ptr_array_index (list, i);
-			if (item->info == PK_INFO_ENUM_INSTALLED) {
-				already_installed = TRUE;
-				id = item->package_id;
-			} else if (item->info == PK_INFO_ENUM_AVAILABLE) {
-				egg_debug ("package '%s' resolved to:", item->package_id);
-				id = item->package_id;
-			}
-		}
-
-		/* already installed? */
-		if (already_installed) {
-			if (task->priv->show_warning) {
-				/* TRANSLATORS: we've already got a package that provides this file */
-				text = g_strdup_printf (_("The %s package already provides this file"), id->name);
-				gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_WARNING, 0);
-				/* TRANSLATORS: title */
-				gpk_modal_dialog_set_title (task->priv->dialog, _("Failed to install file"));
-				gpk_modal_dialog_set_message (task->priv->dialog, text);
-				gpk_modal_dialog_present (task->priv->dialog);
-				gpk_modal_dialog_run (task->priv->dialog);
-				g_free (text);
-			}
-			error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_FAILED, "already provided");
-			dbus_g_method_return_error (task->priv->context, error);
-			goto out;
-		}
-
-		/* convert to data */
-		task->priv->package_ids = pk_package_ids_from_id (id);
-
-		/* install these packages with deps */
-		gpk_dbus_task_install_package_ids (task);
-		goto out;
-	}
-
 	/* from InstallPackageIds */
 	if (role == PK_ROLE_ENUM_INSTALL_PACKAGES ||
 	    role == PK_ROLE_ENUM_INSTALL_FILES) {
 
 		/* show summary? */
 		if (task->priv->show_finished) {
-			list = pk_results_get_package_array (client);
+			array = pk_results_get_package_array (client);
 			/* TRANSLATORS: list the packages we just installed */
 			gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_FINISHED, GPK_MODAL_DIALOG_PACKAGE_LIST);
 			gpk_modal_dialog_set_message (task->priv->dialog, _("The following packages were installed:"));
 
 			/* filter out installed */
-			for (i=0; i<list->len; i++) {
-				item = g_ptr_array_index (list, i);
+			for (i=0; i<array->len; i++) {
+				item = g_ptr_array_index (array, i);
 				if (item->info != PK_INFO_ENUM_INSTALLING) {
 					pk_item_list_remove_index (list, i);
 					i--;
@@ -540,94 +466,6 @@ gpk_dbus_task_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runtime
 		goto out;
 	}
 
-	/* InstallPackageNames */
-	if (task->priv->role == GPK_DBUS_TASK_ROLE_INSTALL_PACKAGE_NAMES &&
-	    role == PK_ROLE_ENUM_RESOLVE) {
-
-		/* found nothing? */
-		list = pk_results_get_package_array (task->priv->client);
-		if (list->len == 0) {
-			if (task->priv->show_warning) {
-				//FIXME: shows package_id in UI
-				/* TRANSLATORS: couldn't resolve name to package */
-				title = g_strdup_printf (_("Could not find packages"));
-				info_url = gpk_vendor_get_not_found_url (task->priv->vendor, GPK_VENDOR_URL_TYPE_DEFAULT);
-				/* only show the "more info" button if there is a valid link */
-				if (info_url != NULL)
-					gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_WARNING, GPK_MODAL_DIALOG_BUTTON_ACTION);
-				else
-					gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_WARNING, 0);
-				gpk_modal_dialog_set_title (task->priv->dialog, title);
-				/* TRANSLATORS: message: could not find */
-				gpk_modal_dialog_set_message (task->priv->dialog, _("The packages could not be found in any software source"));
-				gpk_modal_dialog_set_help_id (task->priv->dialog, "dialog-package-not-found");
-				/* TRANSLATORS: button: a link to the help file */
-				gpk_modal_dialog_set_action (task->priv->dialog, _("More information"));
-				gpk_modal_dialog_present (task->priv->dialog);
-				button = gpk_modal_dialog_run (task->priv->dialog);
-				if (button == GTK_RESPONSE_OK)
-					gpk_gnome_open (info_url);
-				g_free (info_url);
-				g_free (title);
-			}
-			error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_NO_PACKAGES_FOUND, "no package found");
-			dbus_g_method_return_error (task->priv->context, error);
-			goto out;
-		}
-
-		/* see what we've got already */
-		for (i=0; i<len; i++) {
-			item = g_ptr_array_index (list, i);
-			if (item->info == PK_INFO_ENUM_INSTALLED) {
-				already_installed = TRUE;
-			} else if (item->info == PK_INFO_ENUM_AVAILABLE) {
-				egg_debug ("package '%s' resolved", item->package_id);
-				id = item->package_id;
-				//TODO: we need to list these in a gpk-dbus_task-chooser
-			}
-		}
-
-		/* already installed? */
-		if (already_installed) {
-			if (task->priv->show_warning) {
-				//FIXME: shows package_id in UI
-				/* TRANSLATORS: title: package is already installed */
-				gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_WARNING, 0);
-				gpk_modal_dialog_set_title (task->priv->dialog, _("Failed to install packages"));
-				/* TRANSLATORS: message: package is already installed */
-				gpk_modal_dialog_set_message (task->priv->dialog, _("The package is already installed"));
-				gpk_modal_dialog_present (task->priv->dialog);
-				gpk_modal_dialog_run (task->priv->dialog);
-			}
-			error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_FAILED, "package already found");
-			dbus_g_method_return_error (task->priv->context, error);
-			goto out;
-		}
-
-		/* got junk? */
-		if (id == NULL) {
-			if (task->priv->show_warning) {
-				gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_WARNING, 0);
-				/* TRANSLATORS: failed to install, shouldn't be shown */
-				gpk_modal_dialog_set_title (task->priv->dialog, _("Failed to install package"));
-				/* TRANSLATORS: the search gave us the wrong result. internal error. barf. */
-				gpk_modal_dialog_set_message (task->priv->dialog, _("Incorrect response from search"));
-				gpk_modal_dialog_present (task->priv->dialog);
-				gpk_modal_dialog_run (task->priv->dialog);
-			}
-			error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "incorrect response from search");
-			dbus_g_method_return_error (task->priv->context, error);
-			goto out;
-		}
-
-		/* convert to data */
-		task->priv->package_ids = pk_package_array_to_strv (list);
-
-		/* install these packages with deps */
-		gpk_dbus_task_install_package_ids (task);
-		goto out;
-	}
-
 out:
 	if (error != NULL)
 		g_error_free (error);
@@ -690,27 +528,6 @@ gpk_dbus_task_set_status (GpkDbusTask *task, PkStatusEnum status)
 
 #if 0
 /**
- * gpk_dbus_task_progress_changed_cb:
- **/
-static void
-gpk_dbus_task_progress_changed_cb (PkClient *client, guint percentage, guint subpercentage,
-				guint elapsed, guint remaining, GpkDbusTask *task)
-{
-	/* ignore */
-	gpk_modal_dialog_set_percentage (task->priv->dialog, percentage);
-	gpk_modal_dialog_set_remaining (task->priv->dialog, remaining);
-}
-
-/**
- * gpk_dbus_task_status_changed_cb:
- **/
-static void
-gpk_dbus_task_status_changed_cb (PkClient *client, PkStatusEnum status, GpkDbusTask *task)
-{
-	gpk_dbus_task_set_status (task, status);
-}
-
-/**
  * gpk_dbus_task_error_code_cb:
  **/
 static void
@@ -786,15 +603,6 @@ gpk_dbus_task_package_cb (PkClient *client, const PkItemPackage *item, GpkDbusTa
 	gpk_modal_dialog_set_message (task->priv->dialog, text);
 	g_free (text);
 }
-
-/**
- * gpk_dbus_task_allow_cancel_cb:
- **/
-static void
-gpk_dbus_task_allow_cancel_cb (PkClient *client, gboolean allow_cancel, GpkDbusTask *task)
-{
-	gpk_modal_dialog_set_allow_cancel (task->priv->dialog, allow_cancel);
-}
 #endif
 
 /**
@@ -825,6 +633,7 @@ gpk_dbus_task_install_files_cb (GObject *object, GAsyncResult *res, GpkDbusTask
 {
 	PkClient *client = PK_CLIENT (object);
 	GError *error = NULL;
+	GError *error_dbus = NULL;
 	PkResults *results = NULL;
 	guint length;
 	const gchar *title;
@@ -836,8 +645,8 @@ gpk_dbus_task_install_files_cb (GObject *object, GAsyncResult *res, GpkDbusTask
 		length = g_strv_length (task->priv->files);
 		title = ngettext ("Failed to install file", "Failed to install files", length);
 		gpk_dbus_task_error_msg (task, title, error);
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "%s", error->message);
-		dbus_g_method_return_error (task->priv->context, error);
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "%s", error->message);
+		dbus_g_method_return_error (task->priv->context, error_dbus);
 		g_error_free (error);
 		goto out;
 	}
@@ -847,17 +656,6 @@ out:
 }
 
 /**
- * gpk_dbus_task_install_files_internal:
- **/
-static void
-gpk_dbus_task_install_files_internal (GpkDbusTask *task)
-{
-	/* install async */
-	pk_client_install_files_async (task->priv->client, TRUE, task->priv->files, NULL, NULL, NULL,
-				       (GAsyncReadyCallback) gpk_dbus_task_install_files_cb, task);
-}
-
-/**
  * gpk_dbus_task_ptr_array_to_bullets:
  *
  * splits the strings up nicely
@@ -981,23 +779,36 @@ gpk_dbus_task_confirm_action (GpkDbusTask *task, const gchar *title, const gchar
 static void
 gpk_dbus_task_progress_cb (PkProgress *progress, PkProgressType type, GpkDbusTask *task)
 {
+	gboolean allow_cancel;
+	gint percentage;
+	guint remaining_time;
+	PkStatusEnum status;
+
+	g_object_get (progress,
+		      "allow-cancel", &allow_cancel,
+		      "percentage", &percentage,
+		      "remaining-time", &remaining_time,
+		      "status", &status,
+//		      "xxxxxxxx", &xxxxxxxxxx,
+		      NULL);
+
 	if (type == PK_PROGRESS_TYPE_PACKAGE_ID)
 		egg_debug ("_package");
-	if (type == PK_PROGRESS_TYPE_PERCENTAGE)
-		egg_debug ("_progress");
-	if (type == PK_PROGRESS_TYPE_SUBPERCENTAGE)
-		egg_debug ("_progress");
-	if (type == PK_PROGRESS_TYPE_ALLOW_CANCEL)
-		egg_debug ("_allow_cancel");
-	if (type == PK_PROGRESS_TYPE_STATUS)
-		egg_debug ("_status");
+	else if (type == PK_PROGRESS_TYPE_PERCENTAGE)
+		gpk_modal_dialog_set_percentage (task->priv->dialog, percentage);
+	else if (type == PK_PROGRESS_TYPE_ALLOW_CANCEL)
+		gpk_modal_dialog_set_allow_cancel (task->priv->dialog, allow_cancel);
+	else if (type == PK_PROGRESS_TYPE_STATUS)
+		gpk_dbus_task_set_status (task, status);
+	else if (type == PK_PROGRESS_TYPE_REMAINING_TIME)
+		gpk_modal_dialog_set_remaining (task->priv->dialog, remaining_time);
 }
 
 /**
- * gpk_dbus_task_resolve_cb:
+ * gpk_dbus_task_is_installed_resolve_cb:
  **/
 static void
-gpk_dbus_task_resolve_cb (PkClient *client, GAsyncResult *res, GpkDbusTask *task)
+gpk_dbus_task_is_installed_resolve_cb (PkClient *client, GAsyncResult *res, GpkDbusTask *task)
 {
 	GError *error = NULL;
 	GError *error_dbus = NULL;
@@ -1051,15 +862,15 @@ gpk_dbus_task_is_installed (GpkDbusTask *task, const gchar *package_name)
 	package_names = g_strsplit (package_name, "|", 1);
 	pk_client_resolve_async (task->priv->client, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), package_names, NULL,
 				 (PkProgressCallback) gpk_dbus_task_progress_cb, task,
-				 (GAsyncReadyCallback) gpk_dbus_task_resolve_cb, task);
+				 (GAsyncReadyCallback) gpk_dbus_task_is_installed_resolve_cb, task);
 	g_strfreev (package_names);
 }
 
 /**
- * gpk_dbus_task_search_file_cb:
+ * gpk_dbus_task_search_file_search_file_cb:
  **/
 static void
-gpk_dbus_task_search_file_cb (PkClient *client, GAsyncResult *res, GpkDbusTask *task)
+gpk_dbus_task_search_file_search_file_cb (PkClient *client, GAsyncResult *res, GpkDbusTask *task)
 {
 	GError *error = NULL;
 	GError *error_dbus = NULL;
@@ -1120,28 +931,10 @@ void
 gpk_dbus_task_search_file (GpkDbusTask *task, const gchar *search_file)
 {
 	/* get the package list for the installed packages */
-	egg_warning ("package_name=%s", search_file);
+	egg_debug ("package_name=%s", search_file);
 	pk_client_search_file_async (task->priv->client, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), search_file, NULL,
 				     (PkProgressCallback) gpk_dbus_task_progress_cb, task,
-				     (GAsyncReadyCallback) gpk_dbus_task_search_file_cb, task);
-}
-
-/**
- * gpk_dbus_task_install_files:
- **/
-static void
-gpk_dbus_task_install_files (GpkDbusTask *task)
-{
-	guint len;
-
-	gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_PROGRESS, 0);
-	len = g_strv_length (task->priv->files);
-	/* TRANSLATORS: title: installing a local file */
-	gpk_modal_dialog_set_title (task->priv->dialog, ngettext ("Install local file", "Install local files", len));
-	if (task->priv->show_progress)
-		gpk_modal_dialog_present_with_time (task->priv->dialog, task->priv->timestamp);
-
-	gpk_dbus_task_install_files_internal (task);
+				     (GAsyncReadyCallback) gpk_dbus_task_search_file_search_file_cb, task);
 }
 
 /**
@@ -1159,8 +952,10 @@ void
 gpk_dbus_task_install_package_files (GpkDbusTask *task, gchar **files_rel)
 {
 	GError *error = NULL;
+	GError *error_dbus = NULL;
 	gboolean ret;
 	GPtrArray *array;
+	guint len;
 
 	g_return_if_fail (GPK_IS_DBUS_TASK (task));
 	g_return_if_fail (files_rel != NULL);
@@ -1171,14 +966,24 @@ gpk_dbus_task_install_package_files (GpkDbusTask *task, gchar **files_rel)
 	if (task->priv->show_confirm_search) {
 		ret = gpk_dbus_task_install_package_files_verify (task, array, &error);
 		if (!ret) {
-			dbus_g_method_return_error (task->priv->context, error);
+			dbus_g_method_return_error (task->priv->context, error_dbus);
 			goto out;
 		}
 	}
 
 	/* check for deps */
 	task->priv->files = pk_ptr_array_to_strv (array);
-	gpk_dbus_task_install_files_internal (task);
+
+	gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_PROGRESS, 0);
+	len = g_strv_length (task->priv->files);
+	/* TRANSLATORS: title: installing a local file */
+	gpk_modal_dialog_set_title (task->priv->dialog, ngettext ("Install local file", "Install local files", len));
+	if (task->priv->show_progress)
+		gpk_modal_dialog_present_with_time (task->priv->dialog, task->priv->timestamp);
+
+	/* install async */
+	pk_client_install_files_async (task->priv->client, TRUE, task->priv->files, NULL, NULL, NULL,
+				       (GAsyncReadyCallback) gpk_dbus_task_install_files_cb, task);
 
 	/* wait for async reply */
 out:
@@ -1188,6 +993,134 @@ out:
 }
 
 /**
+ * gpk_dbus_task_install_package_names_resolve_cb:
+ **/
+static void
+gpk_dbus_task_install_package_names_resolve_cb (PkClient *client, GAsyncResult *res, GpkDbusTask *task)
+{
+	GError *error = NULL;
+	GError *error_dbus = NULL;
+	PkResults *results = NULL;
+	GPtrArray *array;
+	PkItemErrorCode *error_item = NULL;
+	const gchar *package_id = NULL;
+	gchar *title;
+	gchar *info_url;
+	PkItemPackage *item;
+	GtkResponseType button;
+	guint i;
+	gboolean already_installed;
+
+	/* get the results */
+	results = pk_client_generic_finish (client, res, &error);
+	if (results == NULL) {
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "failed to resolve: %s", error->message);
+		dbus_g_method_return_error (task->priv->context, error_dbus);
+		egg_warning ("failed to resolve: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
+
+	/* check error code */
+	error_item = pk_results_get_error_code (results);
+	if (error_item != NULL) {
+		egg_warning ("failed to resolve: %s, %s", pk_error_enum_to_text (error_item->code), error_item->details);
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "failed to resolve: %s", error_item->details);
+		dbus_g_method_return_error (task->priv->context, error_dbus);
+		goto out;
+	}
+
+	/* found nothing? */
+	array = pk_results_get_package_array (results);
+	if (array->len == 0) {
+		if (!task->priv->show_warning) {
+			//FIXME: shows package_id in UI
+			/* TRANSLATORS: couldn't resolve name to package */
+			title = g_strdup_printf (_("Could not find packages"));
+			info_url = gpk_vendor_get_not_found_url (task->priv->vendor, GPK_VENDOR_URL_TYPE_DEFAULT);
+			/* only show the "more info" button if there is a valid link */
+			if (info_url != NULL)
+				gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_WARNING, GPK_MODAL_DIALOG_BUTTON_ACTION);
+			else
+				gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_WARNING, 0);
+			gpk_modal_dialog_set_title (task->priv->dialog, title);
+			/* TRANSLATORS: message: could not find */
+			gpk_modal_dialog_set_message (task->priv->dialog, _("The packages could not be found in any software source"));
+			gpk_modal_dialog_set_help_id (task->priv->dialog, "dialog-package-not-found");
+			/* TRANSLATORS: button: a link to the help file */
+			gpk_modal_dialog_set_action (task->priv->dialog, _("More information"));
+			gpk_modal_dialog_present (task->priv->dialog);
+			button = gpk_modal_dialog_run (task->priv->dialog);
+			if (button == GTK_RESPONSE_OK)
+				gpk_gnome_open (info_url);
+			g_free (info_url);
+			g_free (title);
+		}
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_NO_PACKAGES_FOUND, "no package found");
+		dbus_g_method_return_error (task->priv->context, error_dbus);
+		goto out;
+	}
+
+	/* see what we've got already */
+	for (i=0; i<array->len; i++) {
+		item = g_ptr_array_index (array, i);
+		if (item->info == PK_INFO_ENUM_INSTALLED) {
+			already_installed = TRUE;
+		} else if (item->info == PK_INFO_ENUM_AVAILABLE) {
+			egg_debug ("package '%s' resolved", item->package_id);
+			package_id = item->package_id;
+			//TODO: we need to list these in a gpk-dbus_task-chooser
+		}
+	}
+
+	/* already installed? */
+	if (already_installed) {
+		if (task->priv->show_warning) {
+			//FIXME: shows package_id in UI
+			/* TRANSLATORS: title: package is already installed */
+			gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_WARNING, 0);
+			gpk_modal_dialog_set_title (task->priv->dialog, _("Failed to install packages"));
+			/* TRANSLATORS: message: package is already installed */
+			gpk_modal_dialog_set_message (task->priv->dialog, _("The package is already installed"));
+			gpk_modal_dialog_present (task->priv->dialog);
+			gpk_modal_dialog_run (task->priv->dialog);
+		}
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_FAILED, "package already found");
+		dbus_g_method_return_error (task->priv->context, error_dbus);
+		goto out;
+	}
+
+	/* got junk? */
+	if (package_id == NULL) {
+		if (task->priv->show_warning) {
+			gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_WARNING, 0);
+			/* TRANSLATORS: failed to install, shouldn't be shown */
+			gpk_modal_dialog_set_title (task->priv->dialog, _("Failed to install package"));
+			/* TRANSLATORS: the search gave us the wrong result. internal error. barf. */
+			gpk_modal_dialog_set_message (task->priv->dialog, _("Incorrect response from search"));
+			gpk_modal_dialog_present (task->priv->dialog);
+			gpk_modal_dialog_run (task->priv->dialog);
+		}
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "incorrect response from search");
+		dbus_g_method_return_error (task->priv->context, error_dbus);
+		goto out;
+	}
+
+	/* convert to data */
+	task->priv->package_ids = pk_package_array_to_strv (array);
+
+	/* install these packages with deps */
+	gpk_dbus_task_install_package_ids (task);
+out:
+	if (error_item != NULL)
+		pk_item_error_code_unref (error_item);
+	if (array != NULL)
+		g_ptr_array_unref (array);
+	if (results != NULL)
+		g_object_unref (results);
+}
+
+/**
  * gpk_dbus_task_install_package_names:
  * @task: a valid #GpkDbusTask instance
  * @package: a pakage name such as <literal>hal-info</literal>
@@ -1201,8 +1134,7 @@ void
 gpk_dbus_task_install_package_names (GpkDbusTask *task, gchar **packages)
 {
 	gboolean ret;
-	GError *error = NULL;
-	GError *error_local = NULL;
+	GError *error_dbus = NULL;
 	gchar *message;
 	gchar *text;
 	guint len;
@@ -1212,8 +1144,6 @@ gpk_dbus_task_install_package_names (GpkDbusTask *task, gchar **packages)
 	g_return_if_fail (GPK_IS_DBUS_TASK (task));
 	g_return_if_fail (packages != NULL);
 
-	task->priv->role = GPK_DBUS_TASK_ROLE_INSTALL_PACKAGE_NAMES;
-
 	/* optional */
 	if (!task->priv->show_confirm_install) {
 		egg_debug ("skip confirm as not allowed to interact with user");
@@ -1256,8 +1186,8 @@ gpk_dbus_task_install_package_names (GpkDbusTask *task, gchar **packages)
 	g_free (text);
 	g_free (message);
 	if (!ret) {
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "did not agree to search");
-		dbus_g_method_return_error (task->priv->context, error);
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "did not agree to search");
+		dbus_g_method_return_error (task->priv->context, error_dbus);
 		goto out;
 	}
 
@@ -1271,24 +1201,129 @@ skip_checks:
 		gpk_modal_dialog_present (task->priv->dialog);
 
 	/* find out if we can find a package */
-	ret = pk_client_resolve (task->priv->client,
-				 pk_bitfield_from_enums (PK_FILTER_ENUM_ARCH,
-							 PK_FILTER_ENUM_NEWEST, -1),
-				 packages, &error_local);
-	if (!ret) {
-		/* TRANSLATORS: we failed to find the package, this shouldn't happen */
-		gpk_dbus_task_error_msg (task, _("Incorrect response from search"), error_local);
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "%s", error_local->message);
-		dbus_g_method_return_error (task->priv->context, error);
-		goto out;
-	}
-/*xxx*/
+	pk_client_resolve_async (task->priv->client, pk_bitfield_from_enums (PK_FILTER_ENUM_ARCH, PK_FILTER_ENUM_NEWEST, -1), packages, NULL,
+			         (PkProgressCallback) gpk_dbus_task_progress_cb, task,
+				 (GAsyncReadyCallback) gpk_dbus_task_install_package_names_resolve_cb, task);
+
 	/* wait for async reply */
 out:
-	if (error != NULL)
+	return;
+}
+
+/**
+ * gpk_dbus_task_install_provide_files_search_file_cb:
+ **/
+static void
+gpk_dbus_task_install_provide_files_search_file_cb (PkClient *client, GAsyncResult *res, GpkDbusTask *task)
+{
+	GError *error = NULL;
+	GError *error_dbus = NULL;
+	PkResults *results = NULL;
+	GPtrArray *array;
+	PkItemErrorCode *error_item = NULL;
+	const gchar *package_id = NULL;
+	gchar *info_url;
+	PkItemPackage *item;
+	GtkResponseType button;
+	guint i;
+	gboolean already_installed;
+	gchar *text;
+	gchar **split;
+
+	/* get the results */
+	results = pk_client_generic_finish (client, res, &error);
+	if (results == NULL) {
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "failed to resolve: %s", error->message);
+		dbus_g_method_return_error (task->priv->context, error_dbus);
+		egg_warning ("failed to resolve: %s", error->message);
 		g_error_free (error);
-	if (error_local != NULL)
-		g_error_free (error_local);
+		goto out;
+	}
+
+	/* check error code */
+	error_item = pk_results_get_error_code (results);
+	if (error_item != NULL) {
+		egg_warning ("failed to resolve: %s, %s", pk_error_enum_to_text (error_item->code), error_item->details);
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "failed to resolve: %s", error_item->details);
+		dbus_g_method_return_error (task->priv->context, error_dbus);
+		goto out;
+	}
+
+	/* one or more entry? */
+	array = pk_results_get_package_array (results);
+	//FIXME: do something
+
+	/* found nothing? */
+	if (array->len == 0) {
+		if (task->priv->show_warning) {
+			info_url = gpk_vendor_get_not_found_url (task->priv->vendor, GPK_VENDOR_URL_TYPE_DEFAULT);
+			/* only show the "more info" button if there is a valid link */
+			if (info_url != NULL)
+				gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_WARNING, GPK_MODAL_DIALOG_BUTTON_ACTION);
+			else
+				gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_WARNING, 0);
+			/* TRANSLATORS: failed to fild the package for thefile */
+			gpk_modal_dialog_set_title (task->priv->dialog, _("Failed to find package"));
+			/* TRANSLATORS: nothing found */
+			gpk_modal_dialog_set_message (task->priv->dialog, _("The file could not be found in any packages"));
+			gpk_modal_dialog_set_help_id (task->priv->dialog, "dialog-package-not-found");
+			/* TRANSLATORS: button: show the user a button to get more help finding stuff */
+			gpk_modal_dialog_set_action (task->priv->dialog, _("More information"));
+			gpk_modal_dialog_present (task->priv->dialog);
+			button = gpk_modal_dialog_run (task->priv->dialog);
+			if (button == GTK_RESPONSE_OK)
+				gpk_gnome_open (info_url);
+			g_free (info_url);
+		}
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_NO_PACKAGES_FOUND, "no files found");
+		dbus_g_method_return_error (task->priv->context, error_dbus);
+		goto out;
+	}
+
+	/* see what we've got already */
+	for (i=0; i<array->len; i++) {
+		item = g_ptr_array_index (array, i);
+		if (item->info == PK_INFO_ENUM_INSTALLED) {
+			already_installed = TRUE;
+			package_id = item->package_id;
+		} else if (item->info == PK_INFO_ENUM_AVAILABLE) {
+			egg_debug ("package '%s' resolved to:", item->package_id);
+			package_id = item->package_id;
+		}
+	}
+
+	/* already installed? */
+	if (already_installed) {
+		if (task->priv->show_warning) {
+			split = pk_package_id_split (package_id);
+			/* TRANSLATORS: we've already got a package that provides this file */
+			text = g_strdup_printf (_("The %s package already provides this file"), split[PK_PACKAGE_ID_NAME]);
+			gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_WARNING, 0);
+			/* TRANSLATORS: title */
+			gpk_modal_dialog_set_title (task->priv->dialog, _("Failed to install file"));
+			gpk_modal_dialog_set_message (task->priv->dialog, text);
+			gpk_modal_dialog_present (task->priv->dialog);
+			gpk_modal_dialog_run (task->priv->dialog);
+			g_free (text);
+			g_strfreev (split);
+		}
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_FAILED, "already provided");
+		dbus_g_method_return_error (task->priv->context, error_dbus);
+		goto out;
+	}
+
+	/* convert to data */
+	task->priv->package_ids = pk_package_ids_from_id (package_id);
+
+	/* install these packages with deps */
+	gpk_dbus_task_install_package_ids (task);
+out:
+	if (error_item != NULL)
+		pk_item_error_code_unref (error_item);
+	if (array != NULL)
+		g_ptr_array_unref (array);
+	if (results != NULL)
+		g_object_unref (results);
 }
 
 /**
@@ -1305,8 +1340,7 @@ void
 gpk_dbus_task_install_provide_files (GpkDbusTask *task, gchar **full_paths)
 {
 	gboolean ret;
-	GError *error = NULL;
-	GError *error_local = NULL;
+	GError *error_dbus = NULL;
 	guint len;
 	guint i;
 	gchar *text;
@@ -1316,8 +1350,6 @@ gpk_dbus_task_install_provide_files (GpkDbusTask *task, gchar **full_paths)
 	g_return_if_fail (GPK_IS_DBUS_TASK (task));
 	g_return_if_fail (full_paths != NULL);
 
-	task->priv->role = GPK_DBUS_TASK_ROLE_INSTALL_PROVIDE_FILES;
-
 	/* optional */
 	if (!task->priv->show_confirm_search) {
 		egg_debug ("skip confirm as not allowed to interact with user");
@@ -1359,8 +1391,8 @@ gpk_dbus_task_install_provide_files (GpkDbusTask *task, gchar **full_paths)
 	g_free (text);
 	g_free (message);
 	if (!ret) {
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "did not agree to search");
-		dbus_g_method_return_error (task->priv->context, error);
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "did not agree to search");
+		dbus_g_method_return_error (task->priv->context, error_dbus);
 		goto out;
 	}
 
@@ -1370,24 +1402,13 @@ skip_checks:
 	gpk_modal_dialog_set_image_status (task->priv->dialog, PK_STATUS_ENUM_WAIT);
 
 	/* do search */
-	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);
-	if (!ret) {
-		/* TRANSLATORS: we failed to find the package, this shouldn't happen */
-		gpk_dbus_task_error_msg (task, _("Failed to search for file"), error_local);
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "%s", error_local->message);
-		dbus_g_method_return_error (task->priv->context, error);
-		goto out;
-	}
+	pk_client_search_file_async (task->priv->client, pk_bitfield_from_enums (PK_FILTER_ENUM_ARCH, PK_FILTER_ENUM_NEWEST, -1), full_paths[0], NULL,
+			             (PkProgressCallback) gpk_dbus_task_progress_cb, task,
+				     (GAsyncReadyCallback) gpk_dbus_task_install_provide_files_search_file_cb, task);
 
 	/* wait for async reply */
 out:
-	if (error != NULL)
-		g_error_free (error);
-	if (error_local != NULL)
-		g_error_free (error_local);
+	return;
 }
 
 /**
@@ -1396,11 +1417,9 @@ out:
 static PkItemPackage *
 gpk_dbus_task_install_gstreamer_codec_part (GpkDbusTask *task, const gchar *codec_name, const gchar *codec_desc, GError **error)
 {
-	GPtrArray *list = NULL;
-	gboolean ret;
+	GPtrArray *array = NULL;
 	PkItemPackage *new_item = NULL;
 	const PkItemPackage *item;
-	guint len;
 	gchar *title;
 
 	/* TRANSLATORS: title, searching for codecs */
@@ -1408,29 +1427,26 @@ gpk_dbus_task_install_gstreamer_codec_part (GpkDbusTask *task, const gchar *code
 	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,
-				       pk_bitfield_from_enums (PK_FILTER_ENUM_NOT_INSTALLED,
-							       PK_FILTER_ENUM_ARCH,
-							       PK_FILTER_ENUM_NEWEST, -1),
-				       PK_PROVIDES_ENUM_CODEC, codec_desc, error);
-	if (!ret)
-		return NULL;
+	/* get codec packages */
+	pk_client_what_provides_async (task->priv->client, pk_bitfield_from_enums (PK_FILTER_ENUM_NOT_INSTALLED, PK_FILTER_ENUM_ARCH, PK_FILTER_ENUM_NEWEST, -1),
+				       PK_PROVIDES_ENUM_CODEC, codec_desc, NULL,
+			               (PkProgressCallback) gpk_dbus_task_progress_cb, task,
+				       (GAsyncReadyCallback) gpk_dbus_task_xxx_search_file_cb, task);
 
-	list = pk_results_get_package_array (task->priv->client);
+	array = pk_results_get_package_array (results);
 
 	/* found nothing? */
-	if (list->len == 0) {
+	if (array->len == 0) {
 		*error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_NO_PACKAGES_FOUND, "failed to find: %s", codec_desc);
 		goto out;
 	}
 
 	/* gstreamer-ffmpeg and gstreamer-plugins-ugly both provide mp3 playback, choose one */
-	if (list->len > 1)
+	if (array->len > 1)
 		egg_warning ("choosing one of the provides as more than one match");
 
 	/* always use the first one */
-	item = g_ptr_array_index (list, 0);
+	item = g_ptr_array_index (array, 0);
 	if (item == NULL)
 		egg_error ("item cannot be NULL");
 
@@ -1552,23 +1568,23 @@ void
 gpk_dbus_task_install_gstreamer_resources (GpkDbusTask *task, gchar **codec_names)
 {
 	gboolean ret = TRUE;
-	GError *error = NULL;
+	GError *error_dbus = NULL;
 	GError *error_local = NULL;
 	guint i;
 	guint len;
-	PkItemPackage *item_new;
 	gchar **parts;
+	PkItemPackage *item_new;
 	GtkResponseType button;
 	gchar *info_url;
-	GPtrArray *list = NULL;
+	GPtrArray *array = NULL;
 	const gchar *title;
 	const gchar *message;
 
 	/* check it's not session wide banned in gconf */
 	ret = gconf_client_get_bool (task->priv->gconf_client, GPK_CONF_ENABLE_CODEC_HELPER, NULL);
 	if (!ret) {
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_FORBIDDEN, "not enabled in GConf : %s", GPK_CONF_ENABLE_CODEC_HELPER);
-		dbus_g_method_return_error (task->priv->context, error);
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_FORBIDDEN, "not enabled in GConf : %s", GPK_CONF_ENABLE_CODEC_HELPER);
+		dbus_g_method_return_error (task->priv->context, error_dbus);
 		goto out;
 	}
 
@@ -1581,8 +1597,8 @@ gpk_dbus_task_install_gstreamer_resources (GpkDbusTask *task, gchar **codec_name
 	/* confirm */
 	ret = gpk_dbus_task_install_gstreamer_resources_confirm (task, codec_names);
 	if (!ret) {
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "did not agree to search");
-		dbus_g_method_return_error (task->priv->context, error);
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "did not agree to search");
+		dbus_g_method_return_error (task->priv->context, error_dbus);
 		goto out;
 	}
 
@@ -1598,7 +1614,7 @@ skip_checks:
 		gpk_modal_dialog_present (task->priv->dialog);
 
 	/* save the objects to download in a list */
-	list = g_ptr_array_new_with_free_func_xxx ();
+	array = g_ptr_array_new_with_free_func_xxx ();
 
 	len = g_strv_length (codec_names);
 	for (i=0; i<len; i++) {
@@ -1630,8 +1646,8 @@ skip_checks:
 					gpk_gnome_open (info_url);
 				g_free (info_url);
 			}
-			error = g_error_new (GPK_DBUS_ERROR, error_local->code, "%s", error_local->message);
-			dbus_g_method_return_error (task->priv->context, error);
+			error_dbus = g_error_new (GPK_DBUS_ERROR, error_local->code, "%s", error_local->message);
+			dbus_g_method_return_error (task->priv->context, error_dbus);
 			goto out;
 		}
 		g_ptr_array_add (list, item_new);
@@ -1661,8 +1677,8 @@ skip_checks:
 	/* close, we're going to fail the method */
 	if (button != GTK_RESPONSE_OK) {
 		gpk_modal_dialog_close (task->priv->dialog);
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "did not agree to download");
-		dbus_g_method_return_error (task->priv->context, error);
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "did not agree to download");
+		dbus_g_method_return_error (task->priv->context, error_dbus);
 		goto out;
 	}
 
@@ -1693,7 +1709,7 @@ void
 gpk_dbus_task_install_mime_types (GpkDbusTask *task, gchar **mime_types)
 {
 	gboolean ret;
-	GError *error = NULL;
+	GError *error_dbus = NULL;
 	GError *error_local = NULL;
 	guint len;
 	gchar *message;
@@ -1707,8 +1723,8 @@ gpk_dbus_task_install_mime_types (GpkDbusTask *task, gchar **mime_types)
 	/* check it's not session wide banned in gconf */
 	ret = gconf_client_get_bool (task->priv->gconf_client, GPK_CONF_ENABLE_MIME_TYPE_HELPER, NULL);
 	if (!ret) {
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_FORBIDDEN, "not enabled in GConf : %s", GPK_CONF_ENABLE_MIME_TYPE_HELPER);
-		dbus_g_method_return_error (task->priv->context, error);
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_FORBIDDEN, "not enabled in GConf : %s", GPK_CONF_ENABLE_MIME_TYPE_HELPER);
+		dbus_g_method_return_error (task->priv->context, error_dbus);
 		goto out;
 	}
 
@@ -1743,8 +1759,8 @@ gpk_dbus_task_install_mime_types (GpkDbusTask *task, gchar **mime_types)
 	g_free (text);
 	g_free (message);
 	if (!ret) {
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "did not agree to search");
-		dbus_g_method_return_error (task->priv->context, error);
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "did not agree to search");
+		dbus_g_method_return_error (task->priv->context, error_dbus);
 		goto out;
 	}
 
@@ -1760,16 +1776,15 @@ skip_checks:
 		gpk_modal_dialog_present (task->priv->dialog);
 
 	/* action */
-	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),
-				       PK_PROVIDES_ENUM_MIMETYPE, mime_types[0], &error_local);
+	pk_client_what_provides_async (task->priv->client, pk_bitfield_from_enums (PK_FILTER_ENUM_NOT_INSTALLED, PK_FILTER_ENUM_ARCH, PK_FILTER_ENUM_NEWEST, -1),
+				       PK_PROVIDES_ENUM_MIMETYPE, mime_types[0], NULL,
+			               (PkProgressCallback) gpk_dbus_task_progress_cb, task,
+				       (GAsyncReadyCallback) gpk_dbus_task_xxx_search_file_cb, task);
 	if (!ret) {
 		/* TRANSLATORS: we failed to find the package, this shouldn't happen */
 		gpk_dbus_task_error_msg (task, _("Failed to search for provides"), error_local);
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "%s", error_local->message);
-		dbus_g_method_return_error (task->priv->context, error);
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "%s", error_local->message);
+		dbus_g_method_return_error (task->priv->context, error_dbus);
 		goto out;
 	}
 
@@ -1878,11 +1893,11 @@ void
 gpk_dbus_task_install_fontconfig_resources (GpkDbusTask *task, gchar **fonts)
 {
 	gboolean ret;
-	GPtrArray *list = NULL;
+	GPtrArray *array = NULL;
 	GPtrArray *list_tmp = NULL;
 	GtkResponseType button;
 	gchar *info_url;
-	GError *error = NULL;
+	GError *error_dbus = NULL;
 	GError *error_local = NULL;
 	guint i;
 	guint len;
@@ -1902,8 +1917,8 @@ gpk_dbus_task_install_fontconfig_resources (GpkDbusTask *task, gchar **fonts)
 	/* check it's not session wide banned in gconf */
 	ret = gconf_client_get_bool (task->priv->gconf_client, GPK_CONF_ENABLE_FONT_HELPER, NULL);
 	if (!ret) {
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_FORBIDDEN, "not enabled in GConf : %s", GPK_CONF_ENABLE_FONT_HELPER);
-		dbus_g_method_return_error (task->priv->context, error);
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_FORBIDDEN, "not enabled in GConf : %s", GPK_CONF_ENABLE_FONT_HELPER);
+		dbus_g_method_return_error (task->priv->context, error_dbus);
 		goto out;
 	}
 
@@ -1917,15 +1932,15 @@ gpk_dbus_task_install_fontconfig_resources (GpkDbusTask *task, gchar **fonts)
 	for (i=0; i<len; i++) {
 		/* correct prefix */
 		if (!g_str_has_prefix (fonts[i], ":lang=")) {
-			error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "not recognised prefix: '%s'", fonts[i]);
-			dbus_g_method_return_error (task->priv->context, error);
+			error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "not recognised prefix: '%s'", fonts[i]);
+			dbus_g_method_return_error (task->priv->context, error_dbus);
 			goto out;
 		}
 		/* no lang code */
 		size = strlen (fonts[i]);
 		if (size < 7 || size > 20) {
-			error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "lang tag malformed: '%s'", fonts[i]);
-			dbus_g_method_return_error (task->priv->context, error);
+			error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "lang tag malformed: '%s'", fonts[i]);
+			dbus_g_method_return_error (task->priv->context, error_dbus);
 			goto out;
 		}
 	}
@@ -1973,8 +1988,8 @@ gpk_dbus_task_install_fontconfig_resources (GpkDbusTask *task, gchar **fonts)
 	g_free (text);
 	g_free (message);
 	if (!ret) {
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "did not agree to search");
-		dbus_g_method_return_error (task->priv->context, error);
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "did not agree to search");
+		dbus_g_method_return_error (task->priv->context, error_dbus);
 		goto out;
 	}
 
@@ -1991,31 +2006,30 @@ skip_checks:
 		gpk_modal_dialog_present (task->priv->dialog);
 
 	/* do each one */
-	list = g_ptr_array_new_with_free_func_xxx ();
+	array = g_ptr_array_new_with_free_func_xxx ();
 	for (i=0; i<len; i++) {
 
 		/* action: FIXME: synchronous */
-		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),
-					       PK_PROVIDES_ENUM_FONT, fonts[i], &error_local);
+	pk_client_what_provides_async (task->priv->client, pk_bitfield_from_enums (PK_FILTER_ENUM_NOT_INSTALLED, PK_FILTER_ENUM_ARCH, PK_FILTER_ENUM_NEWEST, -1),
+				       PK_PROVIDES_ENUM_FONT, fonts[i], NULL,
+			               (PkProgressCallback) gpk_dbus_task_progress_cb, task,
+				       (GAsyncReadyCallback) gpk_dbus_task_xxx_search_file_cb, task);
 		if (!ret) {
 			/* TRANSLATORS: we failed to find the package, this shouldn't happen */
 			gpk_dbus_task_error_msg (task, _("Failed to search for provides"), error_local);
-			error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "%s", error_local->message);
-			dbus_g_method_return_error (task->priv->context, error);
+			error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "%s", error_local->message);
+			dbus_g_method_return_error (task->priv->context, error_dbus);
 			goto out;
 		}
 
 		/* add to main list */
-		list_tmp = pk_results_get_package_array (task->priv->client);
+		list_tmp = pk_results_get_package_array (results);
 		g_ptr_array_add_list (list, list_tmp);
 		g_object_unref (list_tmp);
 	}
 
 	/* found nothing? */
-	if (list->len == 0) {
+	if (array->len == 0) {
 		if (task->priv->show_warning) {
 			info_url = gpk_vendor_get_not_found_url (task->priv->vendor, GPK_VENDOR_URL_TYPE_FONT);
 			/* TRANSLATORS: title: cannot find in sources */
@@ -2037,8 +2051,8 @@ skip_checks:
 				gpk_gnome_open (info_url);
 			g_free (info_url);
 		}
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_NO_PACKAGES_FOUND, "failed to find font");
-		dbus_g_method_return_error (task->priv->context, error);
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_NO_PACKAGES_FOUND, "failed to find font");
+		dbus_g_method_return_error (task->priv->context, error_dbus);
 		goto out;
 	}
 
@@ -2063,8 +2077,8 @@ skip_checks:
 	/* close, we're going to fail the method */
 	if (button != GTK_RESPONSE_OK) {
 		gpk_modal_dialog_close (task->priv->dialog);
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "did not agree to download");
-		dbus_g_method_return_error (task->priv->context, error);
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "did not agree to download");
+		dbus_g_method_return_error (task->priv->context, error_dbus);
 		goto out;
 	}
 
@@ -2113,11 +2127,11 @@ gpk_dbus_task_catalog_progress_cb (PkCatalog *catalog, PkCatalogProgress mode, c
 void
 gpk_dbus_task_install_catalogs (GpkDbusTask *task, gchar **filenames)
 {
-	GError *error = NULL;
+	GError *error_dbus = NULL;
 	GtkResponseType button;
 	gchar *message;
 	const gchar *title;
-	GPtrArray *list = NULL;
+	GPtrArray *array = NULL;
 	PkCatalog *catalog;
 	guint len;
 
@@ -2147,8 +2161,8 @@ gpk_dbus_task_install_catalogs (GpkDbusTask *task, gchar **filenames)
 
 	/* did we click no or exit the window? */
 	if (button != GTK_RESPONSE_OK) {
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "did not agree to install");
-		dbus_g_method_return_error (task->priv->context, error);
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "did not agree to install");
+		dbus_g_method_return_error (task->priv->context, error_dbus);
 		goto out;
 	}
 
@@ -2165,11 +2179,11 @@ skip_checks:
 	/* get files to be installed */
 	catalog = pk_catalog_new ();
 	g_signal_connect (catalog, "progress", G_CALLBACK (gpk_dbus_task_catalog_progress_cb), task);
-	list = pk_catalog_process_files (catalog, filenames);
+	array = pk_catalog_process_files (catalog, filenames);
 	g_object_unref (catalog);
 
 	/* nothing to do? */
-	if (list->len == 0) {
+	if (array->len == 0) {
 		/* show UI */
 		if (task->priv->show_warning) {
 			/* TRANSLATORS: title: we've already got all these packages installed */
@@ -2179,8 +2193,8 @@ skip_checks:
 			gpk_modal_dialog_present_with_time (task->priv->dialog, task->priv->timestamp);
 			gpk_modal_dialog_run (task->priv->dialog);
 		}
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_FAILED, "No packages need to be installed");
-		dbus_g_method_return_error (task->priv->context, error);
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_FAILED, "No packages need to be installed");
+		dbus_g_method_return_error (task->priv->context, error_dbus);
 		goto out;
 	}
 
@@ -2204,8 +2218,8 @@ skip_checks:
 
 	/* did we click no or exit the window? */
 	if (button != GTK_RESPONSE_OK) {
-		error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "Action was cancelled");
-		dbus_g_method_return_error (task->priv->context, error);
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "Action was cancelled");
+		dbus_g_method_return_error (task->priv->context, error_dbus);
 		goto out;
 	}
 
@@ -2230,7 +2244,7 @@ gpk_dbus_task_get_package_for_exec (GpkDbusTask *task, const gchar *exec)
 	gchar *package = NULL;
 	gboolean ret;
 	GError *error = NULL;
-	GPtrArray *list = NULL;
+	GPtrArray *array = NULL;
 	const PkItemPackage *item;
 
 	/* find the package name */
@@ -2242,20 +2256,20 @@ 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);
+	array = pk_results_get_package_array (results);
 
 	/* nothing found */
-	if (list->len == 0) {
+	if (array->len == 0) {
 		egg_debug ("cannot find installed package that provides : %s", exec);
 		goto out;
 	}
 
 	/* check we have one */
-	if (list->len != 1)
+	if (array->len != 1)
 		egg_warning ("not one return, using first");
 
 	/* copy name */
-	item = g_ptr_array_index (list, 0);
+	item = g_ptr_array_index (array, 0);
 	package = g_strdup (item->package_id);
 	egg_debug ("got package %s", package);
 
@@ -2414,23 +2428,8 @@ gpk_dbus_task_init (GpkDbusTask *task)
 
 	/* get actions */
 	task->priv->control = pk_control_new ();
-	task->priv->roles = pk_control_get_properties (task->priv->control, NULL, NULL);
-
 	task->priv->client = pk_client_new ();
-#if 0
-	g_signal_connect (task->priv->client, "finished",
-			  G_CALLBACK (gpk_dbus_task_finished_cb), task);
-	g_signal_connect (task->priv->client, "progress-changed",
-			  G_CALLBACK (gpk_dbus_task_progress_changed_cb), task);
-	g_signal_connect (task->priv->client, "status-changed",
-			  G_CALLBACK (gpk_dbus_task_status_changed_cb), task);
-	g_signal_connect (task->priv->client, "error-code",
-			  G_CALLBACK (gpk_dbus_task_error_code_cb), task);
-	g_signal_connect (task->priv->client, "package",
-			  G_CALLBACK (gpk_dbus_task_package_cb), task);
-	g_signal_connect (task->priv->client, "allow-cancel",
-			  G_CALLBACK (gpk_dbus_task_allow_cancel_cb), task);
-#endif
+	task->priv->roles = pk_control_get_properties (task->priv->control, NULL, NULL);
 
 	/* used for icons and translations */
 	task->priv->desktop = pk_desktop_new ();



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