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



commit a970f266447de98daacc4f9bc5c432d05e71b494
Author: Richard Hughes <richard hughsie com>
Date:   Wed Sep 23 15:53:42 2009 +0100

    moo

 src/gpk-dbus-task.c |  781 +++++++++++++++++++++++++--------------------------
 src/gpk-watch.c     |    6 +-
 2 files changed, 386 insertions(+), 401 deletions(-)
---
diff --git a/src/gpk-dbus-task.c b/src/gpk-dbus-task.c
index 5057a36..93a580f 100644
--- a/src/gpk-dbus-task.c
+++ b/src/gpk-dbus-task.c
@@ -57,15 +57,6 @@ static void     gpk_dbus_task_finalize (GObject *object);
 #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_MIME_TYPES,
-	GPK_DBUS_TASK_ROLE_INSTALL_GSTREAMER_RESOURCES,
-	GPK_DBUS_TASK_ROLE_INSTALL_FONTCONFIG_RESOURCES,
-	GPK_DBUS_TASK_ROLE_INSTALL_CATALOGS,
-	GPK_DBUS_TASK_ROLE_UNKNOWN
-} GpkDbusTaskRole;
-
 /**
  * GpkDbusTaskPrivate:
  *
@@ -97,11 +88,11 @@ struct _GpkDbusTaskPrivate
 	GpkHelperRun		*helper_run;
 	GpkHelperChooser	*helper_chooser;
 	DBusGMethodInvocation	*context;
-	GpkDbusTaskRole		 role;
 	gchar			**package_ids;
 	gchar			**files;
 	PkErrorCodeEnum		 last_exit_code;
 	GCancellable		*cancellable;
+	PkCatalog		*catalog;
 };
 
 G_DEFINE_TYPE (GpkDbusTask, gpk_dbus_task, G_TYPE_OBJECT)
@@ -209,22 +200,6 @@ out:
 }
 
 /**
- * gpk_dbus_task_libnotify_cb:
- **/
-static void
-gpk_dbus_task_libnotify_cb (NotifyNotification *notification, gchar *action, gpointer data)
-{
-	GpkDbusTask *task = GPK_DBUS_TASK (data);
-
-	if (g_strcmp0 (action, "show-error-details") == 0) {
-		/* TRANSLATORS: detailed text about the error */
-		gpk_error_dialog (_("Error details"), _("Package Manager error details"), task->priv->error_details);
-	} else {
-		egg_warning ("unknown action id: %s", action);
-	}
-}
-
-/**
  * gpk_dbus_task_error_msg:
  **/
 static void
@@ -326,35 +301,6 @@ gpk_dbus_task_install_package_ids (GpkDbusTask *task)
 #if 0
 
 /**
- * gpk_dbus_task_error_from_exit_enum:
- **/
-static GError *
-gpk_dbus_task_error_from_exit_enum (PkExitEnum exit)
-{
-	GError *error_dbus = NULL;
-
-	/* trivial case */
-	if (exit == PK_EXIT_ENUM_SUCCESS)
-		goto out;
-
-	/* set the correct error type */
-	if (exit == PK_EXIT_ENUM_FAILED)
-		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_FAILED, "Unspecified failure");
-	else if (exit == PK_EXIT_ENUM_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_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_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_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "The transaction was killed");
-	else
-		egg_error ("unknown exit code");
-out:
-	return error;
-}
-
-/**
  * gpk_dbus_task_finished_cb:
  **/
 static void
@@ -397,43 +343,6 @@ gpk_dbus_task_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runtime
 		goto out;
 	}
 
-	/* from InstallMimeTypes */
-	if (task->priv->role == GPK_DBUS_TASK_ROLE_INSTALL_MIME_TYPES &&
-	    role == PK_ROLE_ENUM_WHAT_PROVIDES) {
-
-		/* found nothing? */
-		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 */
-				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: title */
-				gpk_modal_dialog_set_title (task->priv->dialog, _("Failed to find software"));
-				/* TRANSLATORS: nothing found in the software sources that helps */
-				gpk_modal_dialog_set_message (task->priv->dialog, _("No new applications can be found to handle this type of file"));
-				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, "nothing was found to handle mime type");
-			dbus_g_method_return_error (task->priv->context, error_dbus);
-			goto out;
-		}
-
-		/* populate a chooser */
-		gpk_helper_chooser_show (task->priv->helper_chooser, list);
-		goto out;
-	}
-
 	/* from InstallPackageIds */
 	if (role == PK_ROLE_ENUM_INSTALL_PACKAGES ||
 	    role == PK_ROLE_ENUM_INSTALL_FILES) {
@@ -453,7 +362,7 @@ gpk_dbus_task_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runtime
 					i--;
 				}
 			}
-			gpk_modal_dialog_set_package_list (task->priv->dialog, list);
+			gpk_modal_dialog_set_package_list (task->priv->dialog, array);
 			gpk_modal_dialog_present (task->priv->dialog);
 			g_object_unref (list);
 		} else {
@@ -471,8 +380,8 @@ out:
 		g_error_free (error);
 	if (error_local != NULL)
 		g_error_free (error_local);
-	if (list != NULL)
-		g_object_unref (list);
+	if (array != NULL)
+		g_ptr_array_unref (array);
 }
 #endif
 
@@ -836,7 +745,7 @@ gpk_dbus_task_is_installed_resolve_cb (PkClient *client, GAsyncResult *res, GpkD
 		goto out;
 	}
 
-	/* one or more entry? */
+	/* get results */
 	array = pk_results_get_package_array (results);
 	ret = (array->len > 0);
 	egg_debug ("doing async return");
@@ -899,7 +808,7 @@ gpk_dbus_task_search_file_search_file_cb (PkClient *client, GAsyncResult *res, G
 		goto out;
 	}
 
-	/* one or more entry? */
+	/* get results */
 	array = pk_results_get_package_array (results);
 	if (array->len == 0) {
 		egg_warning ("no packages");
@@ -1249,7 +1158,7 @@ gpk_dbus_task_install_provide_files_search_file_cb (PkClient *client, GAsyncResu
 		goto out;
 	}
 
-	/* one or more entry? */
+	/* get results */
 	array = pk_results_get_package_array (results);
 	//FIXME: do something
 
@@ -1412,53 +1321,6 @@ out:
 }
 
 /**
- * gpk_dbus_task_install_gstreamer_codec_part:
- **/
-static PkItemPackage *
-gpk_dbus_task_install_gstreamer_codec_part (GpkDbusTask *task, const gchar *codec_name, const gchar *codec_desc, GError **error)
-{
-	GPtrArray *array = NULL;
-	PkItemPackage *new_item = NULL;
-	const PkItemPackage *item;
-	gchar *title;
-
-	/* 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 */
-	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);
-
-	array = pk_results_get_package_array (results);
-
-	/* found nothing? */
-	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 (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 (array, 0);
-	if (item == NULL)
-		egg_error ("item cannot be NULL");
-
-	/* copy the object */
-	new_item = pk_package_item_copy (item);
-out:
-	if (list != NULL)
-		g_object_unref (list);
-	return new_item;
-}
-
-/**
  * gpk_dbus_task_install_gstreamer_resources_confirm:
  **/
 static gboolean
@@ -1555,12 +1417,118 @@ gpk_dbus_task_install_gstreamer_resources_confirm (GpkDbusTask *task, gchar **co
 }
 
 /**
+ * gpk_dbus_task_codec_what_provides_cb:
+ **/
+static void
+gpk_dbus_task_codec_what_provides_cb (PkClient *client, GAsyncResult *res, GpkDbusTask *task)
+{
+	GError *error = NULL;
+	GError *error_dbus = NULL;
+	PkResults *results = NULL;
+	GPtrArray *array;
+	PkItemErrorCode *error_item = NULL;
+	GtkResponseType button;
+	gchar *info_url;
+	const gchar *title;
+	const gchar *message;
+
+	/* 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;
+	}
+
+	/* get results */
+	array = pk_results_get_package_array (results);
+
+	/* 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_CODEC);
+			/* 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 search for codec */
+			gpk_modal_dialog_set_title (task->priv->dialog, _("Failed to search for plugin"));
+			/* TRANSLATORS: no software sources have the wanted codec */
+			gpk_modal_dialog_set_message (task->priv->dialog, _("Could not find plugin in any configured software source"));
+			gpk_modal_dialog_set_help_id (task->priv->dialog, "dialog-package-not-found");
+
+			/* TRANSLATORS: button text */
+			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, "failed to find codec");
+		dbus_g_method_return_error (task->priv->context, error_dbus);
+		goto out;
+	}
+
+	/* optional */
+	if (!task->priv->show_confirm_deps) {
+		egg_debug ("skip confirm as not allowed to interact with user");
+		goto skip_checks2;
+	}
+
+	title = ngettext ("Install the following plugin", "Install the following plugins", array->len);
+	message = ngettext ("Do you want to install this package now?", "Do you want to install these packages now?", array->len);
+
+	gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_CONFIRM, GPK_MODAL_DIALOG_PACKAGE_LIST);
+	gpk_modal_dialog_set_package_list (task->priv->dialog, array);
+	gpk_modal_dialog_set_title (task->priv->dialog, title);
+	gpk_modal_dialog_set_message (task->priv->dialog, message);
+	gpk_modal_dialog_set_image (task->priv->dialog, "dialog-information");
+	/* TRANSLATORS: button: install codecs */
+	gpk_modal_dialog_set_action (task->priv->dialog, _("Install"));
+	gpk_modal_dialog_present_with_time (task->priv->dialog, task->priv->timestamp);
+	button = gpk_modal_dialog_run (task->priv->dialog);
+
+	/* close, we're going to fail the method */
+	if (button != GTK_RESPONSE_OK) {
+		gpk_modal_dialog_close (task->priv->dialog);
+		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;
+	}
+
+skip_checks2:
+	/* install with deps */
+	task->priv->package_ids = pk_package_array_to_strv (array);
+	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_gstreamer_resources:
  * @task: a valid #GpkDbusTask instance
  * @codecs: a codec_type such as <literal>application/text</literal>
  * @error: a %GError to put the error code and message in, or %NULL
  *
- * Install a application to handle a mime type
+ * Install a application to handle a gstreamer request
  *
  * Return value: %TRUE if the method succeeded
  **/
@@ -1569,16 +1537,8 @@ gpk_dbus_task_install_gstreamer_resources (GpkDbusTask *task, gchar **codec_name
 {
 	gboolean ret = TRUE;
 	GError *error_dbus = NULL;
-	GError *error_local = NULL;
-	guint i;
-	guint len;
 	gchar **parts;
-	PkItemPackage *item_new;
-	GtkResponseType button;
-	gchar *info_url;
-	GPtrArray *array = NULL;
-	const gchar *title;
-	const gchar *message;
+	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);
@@ -1613,86 +1573,100 @@ skip_checks:
 	if (task->priv->show_progress)
 		gpk_modal_dialog_present (task->priv->dialog);
 
-	/* save the objects to download in a list */
-	array = g_ptr_array_new_with_free_func_xxx ();
+	/* get the request */
+	parts = g_strsplit (codec_names[0], "|", 2);
 
-	len = g_strv_length (codec_names);
-	for (i=0; i<len; i++) {
-		parts = g_strsplit (codec_names[i], "|", 2);
-		if (g_strv_length (parts) != 2) {
-			egg_warning ("invalid line '%s', expecting a | delimiter", codec_names[i]);
-			continue;
-		}
-		item_new = gpk_dbus_task_install_gstreamer_codec_part (task, parts[0], parts[1], &error_local);
-		if (item_new == NULL) {
-			if (task->priv->show_warning) {
-				info_url = gpk_vendor_get_not_found_url (task->priv->vendor, GPK_VENDOR_URL_TYPE_CODEC);
-				/* 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 search for codec */
-				gpk_modal_dialog_set_title (task->priv->dialog, _("Failed to search for plugin"));
-				/* TRANSLATORS: no software sources have the wanted codec */
-				gpk_modal_dialog_set_message (task->priv->dialog, _("Could not find plugin in any configured software source"));
-				gpk_modal_dialog_set_help_id (task->priv->dialog, "dialog-package-not-found");
-
-				/* TRANSLATORS: button text */
-				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, 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);
-		pk_item_package_unref (item_new);
-		g_strfreev (parts);
-	}
+	/* TRANSLATORS: title, searching for codecs */
+	message = g_strdup_printf (_("Searching for plugin: %s"), parts[1]);
+	gpk_modal_dialog_set_message (task->priv->dialog, message);
 
-	/* optional */
-	if (!task->priv->show_confirm_deps) {
-		egg_debug ("skip confirm as not allowed to interact with user");
-		goto skip_checks2;
+	/* 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, parts[0], NULL,
+			               (PkProgressCallback) gpk_dbus_task_progress_cb, task,
+				       (GAsyncReadyCallback) gpk_dbus_task_codec_what_provides_cb, task);
+out:
+	g_strfreev (parts);
+	g_free (message);
+}
+
+/**
+ * gpk_dbus_task_mime_what_provides_cb:
+ **/
+static void
+gpk_dbus_task_mime_what_provides_cb (PkClient *client, GAsyncResult *res, GpkDbusTask *task)
+{
+	GError *error = NULL;
+	GError *error_dbus = NULL;
+	PkResults *results = NULL;
+	GPtrArray *array;
+	PkItemErrorCode *error_item = NULL;
+	gchar *info_url;
+	GtkResponseType button;
+
+	/* get the results */
+	results = pk_client_generic_finish (client, res, &error);
+	if (results == NULL) {
+		/* TRANSLATORS: we failed to find the package, this shouldn't happen */
+		gpk_dbus_task_error_msg (task, _("Failed to search for provides"), error);
+		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;
 	}
 
-	title = ngettext ("Install the following plugin", "Install the following plugins", len);
-	message = ngettext ("Do you want to install this package now?", "Do you want to install these packages now?", len);
+	/* 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;
+	}
 
-	gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_CONFIRM, GPK_MODAL_DIALOG_PACKAGE_LIST);
-	gpk_modal_dialog_set_package_list (task->priv->dialog, list);
-	gpk_modal_dialog_set_title (task->priv->dialog, title);
-	gpk_modal_dialog_set_message (task->priv->dialog, message);
-	gpk_modal_dialog_set_image (task->priv->dialog, "dialog-information");
-	/* TRANSLATORS: button: install codecs */
-	gpk_modal_dialog_set_action (task->priv->dialog, _("Install"));
-	gpk_modal_dialog_present_with_time (task->priv->dialog, task->priv->timestamp);
-	button = gpk_modal_dialog_run (task->priv->dialog);
+	/* get results */
+	array = pk_results_get_package_array (results);
 
-	/* close, we're going to fail the method */
-	if (button != GTK_RESPONSE_OK) {
-		gpk_modal_dialog_close (task->priv->dialog);
-		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "did not agree to download");
+	/* 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_MIME);
+			/* 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: title */
+			gpk_modal_dialog_set_title (task->priv->dialog, _("Failed to find software"));
+			/* TRANSLATORS: nothing found in the software sources that helps */
+			gpk_modal_dialog_set_message (task->priv->dialog, _("No new applications can be found to handle this type of file"));
+			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, "nothing was found to handle mime type");
 		dbus_g_method_return_error (task->priv->context, error_dbus);
 		goto out;
 	}
 
-skip_checks2:
-	/* install with deps */
-	task->priv->package_ids = pk_package_array_to_strv (list);
-	gpk_dbus_task_install_package_ids (task);
+	/* populate a chooser */
+	gpk_helper_chooser_show (task->priv->helper_chooser, array);
+
+	egg_debug ("doing async return");
+	dbus_g_method_return (task->priv->context, TRUE);
 out:
-	if (list != NULL)
-		g_object_unref (list);
-	if (error != NULL)
-		g_error_free (error);
-	if (error_local != NULL)
-		g_error_free (error_local);
+	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);
 }
 
 /**
@@ -1710,16 +1684,13 @@ gpk_dbus_task_install_mime_types (GpkDbusTask *task, gchar **mime_types)
 {
 	gboolean ret;
 	GError *error_dbus = NULL;
-	GError *error_local = NULL;
 	guint len;
-	gchar *message;
-	gchar *text;
+	gchar *message = NULL;
+	gchar *text = NULL;
 
 	g_return_if_fail (GPK_IS_DBUS_TASK (task));
 	g_return_if_fail (mime_types != NULL);
 
-	task->priv->role = GPK_DBUS_TASK_ROLE_INSTALL_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) {
@@ -1756,8 +1727,6 @@ gpk_dbus_task_install_mime_types (GpkDbusTask *task, gchar **mime_types)
 
 	/* TRANSLATORS: button: confirm to search for packages */
 	ret = gpk_dbus_task_confirm_action (task, text, message, _("Search"));
-	g_free (text);
-	g_free (message);
 	if (!ret) {
 		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);
@@ -1779,21 +1748,11 @@ skip_checks:
 	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_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;
-	}
-
+				       (GAsyncReadyCallback) gpk_dbus_task_mime_what_provides_cb, task);
 	/* wait for async reply */
 out:
-	if (error != NULL)
-		g_error_free (error);
-	if (error_local != NULL)
-		g_error_free (error_local);
+	g_free (text);
+	g_free (message);
 }
 
 /**
@@ -1880,6 +1839,113 @@ out:
 }
 
 /**
+ * gpk_dbus_task_fontconfig_what_provides_cb:
+ **/
+static void
+gpk_dbus_task_fontconfig_what_provides_cb (PkClient *client, GAsyncResult *res, GpkDbusTask *task)
+{
+	GError *error = NULL;
+	GError *error_dbus = NULL;
+	PkResults *results = NULL;
+	GPtrArray *array;
+	PkItemErrorCode *error_item = NULL;
+	gchar *title;
+	gchar *info_url;
+	GtkResponseType button;
+
+	/* get the results */
+	results = pk_client_generic_finish (client, res, &error);
+	if (results == NULL) {
+		/* TRANSLATORS: we failed to find the package, this shouldn't happen */
+//		gpk_dbus_task_error_msg (task, _("Failed to search for provides"), error);
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "failed to search for provides: %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) {
+		/* TRANSLATORS: we failed to find the package, this shouldn't happen */
+//		gpk_dbus_task_error_msg (task, _("Failed to search for provides"), error_item->details);
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "failed to search for provides: %s", error_item->details);
+		dbus_g_method_return_error (task->priv->context, error_dbus);
+		goto out;
+	}
+
+	/* get results */
+	array = pk_results_get_package_array (results);
+
+	/* 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_FONT);
+			/* TRANSLATORS: title: cannot find in sources */
+			title = ngettext ("Failed to find font", "Failed to find fonts", array->len);
+			/* 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: tell the user we suck */
+			gpk_modal_dialog_set_message (task->priv->dialog, _("No new fonts can be found for this document"));
+			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, "failed to find font");
+		dbus_g_method_return_error (task->priv->context, error_dbus);
+		goto out;
+	}
+
+	/* optional */
+	if (!task->priv->show_confirm_deps) {
+		egg_debug ("skip confirm as not allowed to interact with user");
+		goto skip_checks;
+	}
+
+	/* TRANSLATORS: title: show a list of fonts */
+	title = ngettext ("Do you want to install this package now?", "Do you want to install these packages now?", array->len);
+	gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_CONFIRM, GPK_MODAL_DIALOG_PACKAGE_LIST);
+	gpk_modal_dialog_set_package_list (task->priv->dialog, array);
+	gpk_modal_dialog_set_title (task->priv->dialog, title);
+	gpk_modal_dialog_set_message (task->priv->dialog, title);
+	gpk_modal_dialog_set_image (task->priv->dialog, "dialog-information");
+	/* TRANSLATORS: button: install a font */
+	gpk_modal_dialog_set_action (task->priv->dialog, _("Install"));
+	gpk_modal_dialog_present_with_time (task->priv->dialog, task->priv->timestamp);
+	button = gpk_modal_dialog_run (task->priv->dialog);
+
+	/* close, we're going to fail the method */
+	if (button != GTK_RESPONSE_OK) {
+		gpk_modal_dialog_close (task->priv->dialog);
+		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;
+	}
+
+skip_checks:
+	/* convert to list of package id's */
+	task->priv->package_ids = pk_package_array_to_strv (array);
+	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_fontconfig_resources:
  * @task: a valid #GpkDbusTask instance
  * @fonts: font description such as <literal>lang:fr</literal>
@@ -1894,11 +1960,9 @@ gpk_dbus_task_install_fontconfig_resources (GpkDbusTask *task, gchar **fonts)
 {
 	gboolean ret;
 	GPtrArray *array = NULL;
-	GPtrArray *list_tmp = NULL;
-	GtkResponseType button;
-	gchar *info_url;
+//	GtkResponseType button;
+//	gchar *info_url;
 	GError *error_dbus = NULL;
-	GError *error_local = NULL;
 	guint i;
 	guint len;
 	guint size;
@@ -2006,52 +2070,56 @@ skip_checks:
 		gpk_modal_dialog_present (task->priv->dialog);
 
 	/* do each one */
-	array = g_ptr_array_new_with_free_func_xxx ();
-	for (i=0; i<len; i++) {
-
-		/* action: FIXME: synchronous */
 	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,
+				       PK_PROVIDES_ENUM_FONT, fonts[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_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;
-		}
+				       (GAsyncReadyCallback) gpk_dbus_task_fontconfig_what_provides_cb, task);
+out:
+	if (array != NULL)
+		g_ptr_array_unref (array);
+}
+
+/**
+ * gpk_dbus_task_catalog_lookup_cb:
+ **/
+static void
+gpk_dbus_task_catalog_lookup_cb (GObject *object, GAsyncResult *res, GpkDbusTask *task)
+{
+	PkCatalog *catalog = PK_CATALOG (object);
+	GError *error = NULL;
+	GError *error_dbus = NULL;
+	GPtrArray *array;
+	GtkResponseType button;
 
-		/* add to main list */
-		list_tmp = pk_results_get_package_array (results);
-		g_ptr_array_add_list (list, list_tmp);
-		g_object_unref (list_tmp);
+	/* get the results */
+	array = pk_catalog_lookup_finish (catalog, res, &error);
+	if (array == NULL) {
+		if (task->priv->show_warning) {
+			/* TRANSLATORS: title: we've already got all these packages installed */
+			gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_WARNING, 0);
+			gpk_modal_dialog_set_title (task->priv->dialog, _("Could not process catalog"));
+			gpk_modal_dialog_set_help_id (task->priv->dialog, NULL);
+			gpk_modal_dialog_present_with_time (task->priv->dialog, task->priv->timestamp);
+			gpk_modal_dialog_run (task->priv->dialog);
+		}
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_FAILED, "failed to parse catalog: %s", error->message);
+		dbus_g_method_return_error (task->priv->context, error_dbus);
+		g_error_free (error);
+		goto out;
 	}
 
-	/* found nothing? */
+	/* nothing to do? */
 	if (array->len == 0) {
+		/* show UI */
 		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 */
-			title = ngettext ("Failed to find font", "Failed to find fonts", len);
-			/* 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: tell the user we suck */
-			gpk_modal_dialog_set_message (task->priv->dialog, _("No new fonts can be found for this document"));
-			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);
+			/* TRANSLATORS: title: we've already got all these packages installed */
+			gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_WARNING, 0);
+			gpk_modal_dialog_set_title (task->priv->dialog, _("No packages need to be installed"));
+			gpk_modal_dialog_set_help_id (task->priv->dialog, "dialog-catalog-none-required");
+			gpk_modal_dialog_present_with_time (task->priv->dialog, task->priv->timestamp);
+			gpk_modal_dialog_run (task->priv->dialog);
 		}
-		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_NO_PACKAGES_FOUND, "failed to find font");
+		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;
 	}
@@ -2059,66 +2127,35 @@ skip_checks:
 	/* optional */
 	if (!task->priv->show_confirm_deps) {
 		egg_debug ("skip confirm as not allowed to interact with user");
-		goto skip_checks2;
+		goto skip_checks;
 	}
 
-	/* TRANSLATORS: title: show a list of fonts */
-	title = ngettext ("Do you want to install this package now?", "Do you want to install these packages now?", len);
 	gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_CONFIRM, GPK_MODAL_DIALOG_PACKAGE_LIST);
-	gpk_modal_dialog_set_package_list (task->priv->dialog, list);
-	gpk_modal_dialog_set_title (task->priv->dialog, title);
-	gpk_modal_dialog_set_message (task->priv->dialog, title);
-	gpk_modal_dialog_set_image (task->priv->dialog, "dialog-information");
-	/* TRANSLATORS: button: install a font */
+	/* TRANSLATORS: title: allow user to confirm */
+	gpk_modal_dialog_set_title (task->priv->dialog, _("Install packages in catalog?"));
+	/* TRANSLATORS: display a list of packages to install */
+	gpk_modal_dialog_set_message (task->priv->dialog, _("The following packages are marked to be installed from the catalog:"));
+	gpk_modal_dialog_set_image (task->priv->dialog, "dialog-question");
+	gpk_modal_dialog_set_package_list (task->priv->dialog, array);
+	/* TRANSLATORS: button: install packages in catalog */
 	gpk_modal_dialog_set_action (task->priv->dialog, _("Install"));
 	gpk_modal_dialog_present_with_time (task->priv->dialog, task->priv->timestamp);
 	button = gpk_modal_dialog_run (task->priv->dialog);
 
-	/* close, we're going to fail the method */
+	/* did we click no or exit the window? */
 	if (button != GTK_RESPONSE_OK) {
-		gpk_modal_dialog_close (task->priv->dialog);
-		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "did not agree to download");
+		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;
 	}
 
-skip_checks2:
+skip_checks:
 	/* convert to list of package id's */
-	task->priv->package_ids = pk_package_array_to_strv (list);
+	task->priv->package_ids = pk_package_array_to_strv (array);
 	gpk_dbus_task_install_package_ids (task);
-
 out:
-	if (error != NULL)
-		g_error_free (error);
-	if (error_local != NULL)
-		g_error_free (error_local);
-	if (list != NULL)
-		g_object_unref (list);
-}
-
-/**
- * gpk_dbus_task_catalog_progress_cb:
- **/
-static void
-gpk_dbus_task_catalog_progress_cb (PkCatalog *catalog, PkCatalogProgress mode, const gchar *text, GpkDbusTask *task)
-{
-	gchar *message = NULL;
-
-	g_return_if_fail (GPK_IS_DBUS_TASK (task));
-
-	if (mode == PK_CATALOG_PROGRESS_PACKAGES) {
-		/* TRANSLATORS: finding the package names for a catalog */
-		message = g_strdup_printf (_("Finding package name: %s"), text);
-	} else if (mode == PK_CATALOG_PROGRESS_FILES) {
-		/* TRANSLATORS: finding a package for a file for a catalog */
-		message = g_strdup_printf (_("Finding file name: %s"), text);
-	} else if (mode == PK_CATALOG_PROGRESS_PROVIDES) {
-		/* TRANSLATORS: finding a package which can provide a virtual provide */
-		message = g_strdup_printf (_("Finding a package to provide: %s"), text);
-	}
-	gpk_dbus_task_set_status (task, PK_STATUS_ENUM_QUERY);
-	gpk_modal_dialog_set_message (task->priv->dialog, message);
-	g_free (message);
+	if (array != NULL)
+		g_ptr_array_unref (array);
 }
 
 /**
@@ -2129,10 +2166,8 @@ gpk_dbus_task_install_catalogs (GpkDbusTask *task, gchar **filenames)
 {
 	GError *error_dbus = NULL;
 	GtkResponseType button;
-	gchar *message;
+	gchar *message = NULL;
 	const gchar *title;
-	GPtrArray *array = NULL;
-	PkCatalog *catalog;
 	guint len;
 
 	len = g_strv_length (filenames);
@@ -2157,7 +2192,6 @@ gpk_dbus_task_install_catalogs (GpkDbusTask *task, gchar **filenames)
 	gpk_modal_dialog_set_help_id (task->priv->dialog, "dialog-install-catalogs");
 	gpk_modal_dialog_present_with_time (task->priv->dialog, task->priv->timestamp);
 	button = gpk_modal_dialog_run (task->priv->dialog);
-	g_free (message);
 
 	/* did we click no or exit the window? */
 	if (button != GTK_RESPONSE_OK) {
@@ -2176,63 +2210,12 @@ skip_checks:
 	if (task->priv->show_progress)
 		gpk_modal_dialog_present (task->priv->dialog);
 
-	/* get files to be installed */
-	catalog = pk_catalog_new ();
-	g_signal_connect (catalog, "progress", G_CALLBACK (gpk_dbus_task_catalog_progress_cb), task);
-	array = pk_catalog_process_files (catalog, filenames);
-	g_object_unref (catalog);
-
-	/* nothing to do? */
-	if (array->len == 0) {
-		/* show UI */
-		if (task->priv->show_warning) {
-			/* TRANSLATORS: title: we've already got all these packages installed */
-			gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_WARNING, 0);
-			gpk_modal_dialog_set_title (task->priv->dialog, _("No packages need to be installed"));
-			gpk_modal_dialog_set_help_id (task->priv->dialog, "dialog-catalog-none-required");
-			gpk_modal_dialog_present_with_time (task->priv->dialog, task->priv->timestamp);
-			gpk_modal_dialog_run (task->priv->dialog);
-		}
-		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;
-	}
-
-	/* optional */
-	if (!task->priv->show_confirm_deps) {
-		egg_debug ("skip confirm as not allowed to interact with user");
-		goto skip_checks2;
-	}
-
-	gpk_modal_dialog_setup (task->priv->dialog, GPK_MODAL_DIALOG_PAGE_CONFIRM, GPK_MODAL_DIALOG_PACKAGE_LIST);
-	/* TRANSLATORS: title: allow user to confirm */
-	gpk_modal_dialog_set_title (task->priv->dialog, _("Install packages in catalog?"));
-	/* TRANSLATORS: display a list of packages to install */
-	gpk_modal_dialog_set_message (task->priv->dialog, _("The following packages are marked to be installed from the catalog:"));
-	gpk_modal_dialog_set_image (task->priv->dialog, "dialog-question");
-	gpk_modal_dialog_set_package_list (task->priv->dialog, list);
-	/* TRANSLATORS: button: install packages in catalog */
-	gpk_modal_dialog_set_action (task->priv->dialog, _("Install"));
-	gpk_modal_dialog_present_with_time (task->priv->dialog, task->priv->timestamp);
-	button = gpk_modal_dialog_run (task->priv->dialog);
-
-	/* did we click no or exit the window? */
-	if (button != GTK_RESPONSE_OK) {
-		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;
-	}
-
-skip_checks2:
-	/* convert to list of package id's */
-	task->priv->package_ids = pk_package_array_to_strv (list);
-	gpk_dbus_task_install_package_ids (task);
-
+	/* lookup catalog */
+	pk_catalog_lookup_async (task->priv->catalog, filenames[0], NULL,
+			 	 (PkProgressCallback) gpk_dbus_task_progress_cb, task,
+				 (GAsyncReadyCallback) gpk_dbus_task_catalog_lookup_cb, task);
 out:
-	if (error != NULL)
-		g_error_free (error);
-	if (list != NULL)
-		g_object_unref (list);
+	g_free (message);
 }
 
 /**
@@ -2242,14 +2225,14 @@ static gchar *
 gpk_dbus_task_get_package_for_exec (GpkDbusTask *task, const gchar *exec)
 {
 	gchar *package = NULL;
-	gboolean ret;
 	GError *error = NULL;
 	GPtrArray *array = NULL;
 	const PkItemPackage *item;
+	PkResults *results = NULL;
 
 	/* find the package name */
-	ret = pk_client_search_file (task->priv->client, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), exec, &error);
-	if (!ret) {
+	results = pk_client_search_file (task->priv->client, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), exec, NULL, NULL, NULL, &error);
+	if (results == NULL) {
 		egg_warning ("failed to search file: %s", error->message);
 		g_error_free (error);
 		goto out;
@@ -2272,11 +2255,12 @@ gpk_dbus_task_get_package_for_exec (GpkDbusTask *task, const gchar *exec)
 	item = g_ptr_array_index (array, 0);
 	package = g_strdup (item->package_id);
 	egg_debug ("got package %s", package);
-
 out:
 	/* use the exec name if we can't find an installed package */
-	if (list != NULL)
-		g_object_unref (list);
+	if (array != NULL)
+		g_ptr_array_unref (array);
+	if (results != NULL)
+		g_object_unref (results);
 	return package;
 }
 
@@ -2392,7 +2376,6 @@ gpk_dbus_task_init (GpkDbusTask *task)
 	task->priv->show_warning = TRUE;
 	task->priv->timestamp = 0;
 	task->priv->last_exit_code = PK_ERROR_ENUM_UNKNOWN;
-	task->priv->role = GPK_DBUS_TASK_ROLE_UNKNOWN;
 
 	/* add application specific icons to search path */
 	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
@@ -2430,6 +2413,7 @@ gpk_dbus_task_init (GpkDbusTask *task)
 	task->priv->control = pk_control_new ();
 	task->priv->client = pk_client_new ();
 	task->priv->roles = pk_control_get_properties (task->priv->control, NULL, NULL);
+	task->priv->catalog = pk_catalog_new ();
 
 	/* used for icons and translations */
 	task->priv->desktop = pk_desktop_new ();
@@ -2467,6 +2451,7 @@ gpk_dbus_task_finalize (GObject *object)
 	g_object_unref (task->priv->cancellable);
 	g_object_unref (task->priv->helper_run);
 	g_object_unref (task->priv->helper_chooser);
+	g_object_unref (task->priv->catalog);
 
 	G_OBJECT_CLASS (gpk_dbus_task_parent_class)->finalize (object);
 }
diff --git a/src/gpk-watch.c b/src/gpk-watch.c
index f669132..2c0dffe 100644
--- a/src/gpk-watch.c
+++ b/src/gpk-watch.c
@@ -1561,14 +1561,14 @@ gpk_watch_progress_cb (PkProgress *progress, PkProgressType type, GpkWatch *watc
 	PkStatusEnum status;
 	guint percentage;
 	gboolean allow_cancel;
-	gchar *package_id;
-	gchar *transaction_id;
+	gchar *package_id = NULL;
+	gchar *transaction_id = NULL;
 	GPtrArray *array;
 	guint i;
 	gboolean ret = FALSE;
 	PkProgress *progress_tmp;
 	guint remaining_time;
-	gchar *text;
+	gchar *text = NULL;
 
 	/* add if not already in list */
 	array = watch->priv->array_progress;



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