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



commit 4e48c978e6eb85d9339549fe3d5c6606d79da1ec
Author: Richard Hughes <richard hughsie com>
Date:   Mon Oct 5 09:54:09 2009 +0100

    moo

 src/gpk-application.c   |   97 +++++++++++++++++++++++++++++++++++++----------
 src/gpk-check-update.c  |   58 ++++++++++++---------------
 src/gpk-dbus-task.c     |   91 ++++++++++++++++++++------------------------
 src/gpk-firmware.c      |   33 ++++------------
 src/gpk-update-viewer.c |   40 ++++++++++++-------
 5 files changed, 177 insertions(+), 142 deletions(-)
---
diff --git a/src/gpk-application.c b/src/gpk-application.c
index 8a077a6..440441c 100644
--- a/src/gpk-application.c
+++ b/src/gpk-application.c
@@ -554,6 +554,13 @@ gpk_application_get_files_cb (PkClient *client, GAsyncResult *res, GpkApplicatio
 	error_item = pk_results_get_error_code (results);
 	if (error_item != NULL) {
 		egg_warning ("failed to get files: %s, %s", pk_error_enum_to_text (error_item->code), error_item->details);
+
+		/* if obvious message, don't tell the user */
+		if (error_item->code != PK_ERROR_ENUM_TRANSACTION_CANCELLED) {
+			window = GTK_WINDOW (gtk_builder_get_object (application->priv->builder, "window_manager"));
+			gpk_error_dialog_modal (window, gpk_error_enum_to_localised_text (error_item->code),
+						gpk_error_enum_to_localised_message (error_item->code), error_item->details);
+		}
 		goto out;
 	}
 
@@ -905,6 +912,13 @@ gpk_application_get_requires_cb (PkClient *client, GAsyncResult *res, GpkApplica
 	error_item = pk_results_get_error_code (results);
 	if (error_item != NULL) {
 		egg_warning ("failed to get requires: %s, %s", pk_error_enum_to_text (error_item->code), error_item->details);
+
+		/* if obvious message, don't tell the user */
+		if (error_item->code != PK_ERROR_ENUM_TRANSACTION_CANCELLED) {
+			window = GTK_WINDOW (gtk_builder_get_object (application->priv->builder, "window_manager"));
+			gpk_error_dialog_modal (window, gpk_error_enum_to_localised_text (error_item->code),
+						gpk_error_enum_to_localised_message (error_item->code), error_item->details);
+		}
 		goto out;
 	}
 
@@ -1021,6 +1035,13 @@ gpk_application_get_depends_cb (PkClient *client, GAsyncResult *res, GpkApplicat
 	error_item = pk_results_get_error_code (results);
 	if (error_item != NULL) {
 		egg_warning ("failed to get depends: %s, %s", pk_error_enum_to_text (error_item->code), error_item->details);
+
+		/* if obvious message, don't tell the user */
+		if (error_item->code != PK_ERROR_ENUM_TRANSACTION_CANCELLED) {
+			window = GTK_WINDOW (gtk_builder_get_object (application->priv->builder, "window_manager"));
+			gpk_error_dialog_modal (window, gpk_error_enum_to_localised_text (error_item->code),
+						gpk_error_enum_to_localised_message (error_item->code), error_item->details);
+		}
 		goto out;
 	}
 
@@ -1298,26 +1319,6 @@ gpk_application_add_item_to_results (GpkApplication *application, const PkItemPa
 	g_free (text);
 }
 
-#if 0
-/**
- * gpk_application_error_code_cb:
- **/
-static void
-gpk_application_error_code_cb (PkClient *client, PkErrorCodeEnum code, const gchar *details, GpkApplication *application)
-{
-	GtkWindow *window;
-	g_return_if_fail (GPK_IS_APPLICATION (application));
-
-	/* obvious message, don't tell the user */
-	if (code == PK_ERROR_ENUM_TRANSACTION_CANCELLED)
-		return;
-
-	window = GTK_WINDOW (gtk_builder_get_object (application->priv->builder, "window_manager"));
-	gpk_error_dialog_modal (window, gpk_error_enum_to_localised_text (code),
-				gpk_error_enum_to_localised_message (code), details);
-}
-#endif
-
 /**
  * gpk_application_suggest_better_search:
  **/
@@ -1504,6 +1505,7 @@ gpk_application_search_cb (PkClient *client, GAsyncResult *res, GpkApplication *
 	PkItemPackage *item;
 	guint i;
 	GtkWidget *widget;
+	GtkWindow *window;
 
 	/* get the results */
 	results = pk_client_generic_finish (client, res, &error);
@@ -1517,6 +1519,13 @@ gpk_application_search_cb (PkClient *client, GAsyncResult *res, GpkApplication *
 	error_item = pk_results_get_error_code (results);
 	if (error_item != NULL) {
 		egg_warning ("failed to search: %s, %s", pk_error_enum_to_text (error_item->code), error_item->details);
+
+		/* if obvious message, don't tell the user */
+		if (error_item->code != PK_ERROR_ENUM_TRANSACTION_CANCELLED) {
+			window = GTK_WINDOW (gtk_builder_get_object (application->priv->builder, "window_manager"));
+			gpk_error_dialog_modal (window, gpk_error_enum_to_localised_text (error_item->code),
+						gpk_error_enum_to_localised_message (error_item->code), error_item->details);
+		}
 		goto out;
 	}
 
@@ -1948,6 +1957,7 @@ gpk_application_install_packages_cb (PkTask *task, GAsyncResult *res, GpkApplica
 	PkResults *results;
 	GError *error = NULL;
 	PkItemErrorCode *error_item = NULL;
+	GtkWindow *window;
 
 	/* get the results */
 	results = pk_task_generic_finish (task, res, &error);
@@ -1961,6 +1971,13 @@ gpk_application_install_packages_cb (PkTask *task, GAsyncResult *res, GpkApplica
 	error_item = pk_results_get_error_code (results);
 	if (error_item != NULL) {
 		egg_warning ("failed to install packages: %s, %s", pk_error_enum_to_text (error_item->code), error_item->details);
+
+		/* if obvious message, don't tell the user */
+		if (error_item->code != PK_ERROR_ENUM_TRANSACTION_CANCELLED) {
+			window = GTK_WINDOW (gtk_builder_get_object (application->priv->builder, "window_manager"));
+			gpk_error_dialog_modal (window, gpk_error_enum_to_localised_text (error_item->code),
+						gpk_error_enum_to_localised_message (error_item->code), error_item->details);
+		}
 		goto out;
 	}
 
@@ -1990,6 +2007,7 @@ gpk_application_remove_packages_cb (PkTask *task, GAsyncResult *res, GpkApplicat
 	PkResults *results;
 	GError *error = NULL;
 	PkItemErrorCode *error_item = NULL;
+	GtkWindow *window;
 
 	/* get the results */
 	results = pk_task_generic_finish (task, res, &error);
@@ -2003,6 +2021,13 @@ gpk_application_remove_packages_cb (PkTask *task, GAsyncResult *res, GpkApplicat
 	error_item = pk_results_get_error_code (results);
 	if (error_item != NULL) {
 		egg_warning ("failed to remove packages: %s, %s", pk_error_enum_to_text (error_item->code), error_item->details);
+
+		/* if obvious message, don't tell the user */
+		if (error_item->code != PK_ERROR_ENUM_TRANSACTION_CANCELLED) {
+			window = GTK_WINDOW (gtk_builder_get_object (application->priv->builder, "window_manager"));
+			gpk_error_dialog_modal (window, gpk_error_enum_to_localised_text (error_item->code),
+						gpk_error_enum_to_localised_message (error_item->code), error_item->details);
+		}
 		goto out;
 	}
 
@@ -2188,6 +2213,7 @@ gpk_application_get_details_cb (PkClient *client, GAsyncResult *res, GpkApplicat
 	const gchar *group;
 	gboolean installed;
 	gchar **split = NULL;
+	GtkWindow *window;
 
 	g_return_if_fail (GPK_IS_APPLICATION (application));
 
@@ -2203,6 +2229,13 @@ gpk_application_get_details_cb (PkClient *client, GAsyncResult *res, GpkApplicat
 	error_item = pk_results_get_error_code (results);
 	if (error_item != NULL) {
 		egg_warning ("failed to get cats: %s, %s", pk_error_enum_to_text (error_item->code), error_item->details);
+
+		/* if obvious message, don't tell the user */
+		if (error_item->code != PK_ERROR_ENUM_TRANSACTION_CANCELLED) {
+			window = GTK_WINDOW (gtk_builder_get_object (application->priv->builder, "window_manager"));
+			gpk_error_dialog_modal (window, gpk_error_enum_to_localised_text (error_item->code),
+						gpk_error_enum_to_localised_message (error_item->code), error_item->details);
+		}
 		goto out;
 	}
 
@@ -2783,6 +2816,7 @@ gpk_application_refresh_cache_cb (PkClient *client, GAsyncResult *res, GpkApplic
 	PkResults *results;
 	GError *error = NULL;
 	PkItemErrorCode *error_item = NULL;
+	GtkWindow *window;
 
 	/* get the results */
 	results = pk_client_generic_finish (client, res, &error);
@@ -2796,6 +2830,13 @@ gpk_application_refresh_cache_cb (PkClient *client, GAsyncResult *res, GpkApplic
 	error_item = pk_results_get_error_code (results);
 	if (error_item != NULL) {
 		egg_warning ("failed to refresh: %s, %s", pk_error_enum_to_text (error_item->code), error_item->details);
+
+		/* if obvious message, don't tell the user */
+		if (error_item->code != PK_ERROR_ENUM_TRANSACTION_CANCELLED) {
+			window = GTK_WINDOW (gtk_builder_get_object (application->priv->builder, "window_manager"));
+			gpk_error_dialog_modal (window, gpk_error_enum_to_localised_text (error_item->code),
+						gpk_error_enum_to_localised_message (error_item->code), error_item->details);
+		}
 		goto out;
 	}
 out:
@@ -3230,6 +3271,7 @@ gpk_application_get_categories_cb (PkClient *client, GAsyncResult *res, GpkAppli
 	GtkTreeView *treeview;
 	PkItemCategory *item;
 	PkItemCategory *item2;
+	GtkWindow *window;
 
 	/* get the results */
 	results = pk_client_generic_finish (client, res, &error);
@@ -3243,6 +3285,13 @@ gpk_application_get_categories_cb (PkClient *client, GAsyncResult *res, GpkAppli
 	error_item = pk_results_get_error_code (results);
 	if (error_item != NULL) {
 		egg_warning ("failed to get cats: %s, %s", pk_error_enum_to_text (error_item->code), error_item->details);
+
+		/* if obvious message, don't tell the user */
+		if (error_item->code != PK_ERROR_ENUM_TRANSACTION_CANCELLED) {
+			window = GTK_WINDOW (gtk_builder_get_object (application->priv->builder, "window_manager"));
+			gpk_error_dialog_modal (window, gpk_error_enum_to_localised_text (error_item->code),
+						gpk_error_enum_to_localised_message (error_item->code), error_item->details);
+		}
 		goto out;
 	}
 
@@ -3529,6 +3578,7 @@ gpk_application_get_repo_list_cb (PkClient *client, GAsyncResult *res, GpkApplic
 	GPtrArray *array = NULL;
 	PkItemRepoDetail *item;
 	guint i;
+	GtkWindow *window;
 
 	/* get the results */
 	results = pk_client_generic_finish (client, res, &error);
@@ -3542,6 +3592,13 @@ gpk_application_get_repo_list_cb (PkClient *client, GAsyncResult *res, GpkApplic
 	error_item = pk_results_get_error_code (results);
 	if (error_item != NULL) {
 		egg_warning ("failed to repo list: %s, %s", pk_error_enum_to_text (error_item->code), error_item->details);
+
+		/* if obvious message, don't tell the user */
+		if (error_item->code != PK_ERROR_ENUM_TRANSACTION_CANCELLED) {
+			window = GTK_WINDOW (gtk_builder_get_object (application->priv->builder, "window_manager"));
+			gpk_error_dialog_modal (window, gpk_error_enum_to_localised_text (error_item->code),
+						gpk_error_enum_to_localised_message (error_item->code), error_item->details);
+		}
 		goto out;
 	}
 
diff --git a/src/gpk-check-update.c b/src/gpk-check-update.c
index 230e177..0926be1 100644
--- a/src/gpk-check-update.c
+++ b/src/gpk-check-update.c
@@ -470,6 +470,13 @@ gpk_check_update_update_system_finished_cb (PkTask *task, GAsyncResult *res, Gpk
 	error_item = pk_results_get_error_code (results);
 	if (error_item != NULL) {
 		egg_warning ("failed to update system: %s, %s", pk_error_enum_to_text (error_item->code), error_item->details);
+		/* ignore some errors */
+		if (error_item->code != PK_ERROR_ENUM_PROCESS_KILL &&
+		    error_item->code != PK_ERROR_ENUM_TRANSACTION_CANCELLED &&
+		    error_item->code != PK_ERROR_ENUM_CANNOT_GET_LOCK) {
+			gpk_error_dialog (gpk_error_enum_to_localised_text (error_item->code),
+					  gpk_error_enum_to_localised_message (error_item->code), error_item->details);
+		}
 		goto out;
 	}
 
@@ -882,6 +889,13 @@ gpk_check_update_get_updates_finished_cb (GObject *object, GAsyncResult *res, Gp
 	error_item = pk_results_get_error_code (results);
 	if (error_item != NULL) {
 		egg_warning ("failed to get updates: %s, %s", pk_error_enum_to_text (error_item->code), error_item->details);
+		/* ignore some errors */
+		if (error_item->code != PK_ERROR_ENUM_PROCESS_KILL &&
+		    error_item->code != PK_ERROR_ENUM_TRANSACTION_CANCELLED &&
+		    error_item->code != PK_ERROR_ENUM_CANNOT_GET_LOCK) {
+			gpk_error_dialog (gpk_error_enum_to_localised_text (error_item->code),
+					  gpk_error_enum_to_localised_message (error_item->code), error_item->details);
+		}
 		goto out;
 	}
 
@@ -1206,6 +1220,12 @@ gpk_check_update_refresh_cache_finished_cb (GObject *object, GAsyncResult *res,
 	error_item = pk_results_get_error_code (results);
 	if (error_item != NULL) {
 		egg_warning ("failed to refresh the cache: %s, %s", pk_error_enum_to_text (error_item->code), error_item->details);
+		/* ignore some errors */
+		if (error_item->code != PK_ERROR_ENUM_PROCESS_KILL &&
+		    error_item->code != PK_ERROR_ENUM_TRANSACTION_CANCELLED) {
+			gpk_error_dialog (gpk_error_enum_to_localised_text (error_item->code),
+					  gpk_error_enum_to_localised_message (error_item->code), error_item->details);
+		}
 		goto out;
 	}
 out:
@@ -1270,6 +1290,12 @@ gpk_check_update_get_distro_upgrades_finished_cb (GObject *object, GAsyncResult
 	error_item = pk_results_get_error_code (results);
 	if (error_item != NULL) {
 		egg_warning ("failed to get upgrades: %s, %s", pk_error_enum_to_text (error_item->code), error_item->details);
+		/* ignore some errors */
+		if (error_item->code != PK_ERROR_ENUM_PROCESS_KILL &&
+		    error_item->code != PK_ERROR_ENUM_TRANSACTION_CANCELLED) {
+			gpk_error_dialog (gpk_error_enum_to_localised_text (error_item->code),
+					  gpk_error_enum_to_localised_message (error_item->code), error_item->details);
+		}
 		goto out;
 	}
 
@@ -1367,38 +1393,6 @@ gpk_cupdate_connection_changed_cb (EggDbusMonitor *monitor, gboolean connected,
 	gpk_check_update_set_icon_visibility (cupdate);
 }
 
-#if 0
-/**
- * gpk_check_update_error_code_cb:
- **/
-static void
-gpk_check_update_error_code_cb (PkClient *client, PkErrorCodeEnum code, const gchar *details, GpkCheckUpdate *cupdate)
-{
-	/* ignore some errors */
-	if (code == PK_ERROR_ENUM_PROCESS_KILL ||
-	    code == PK_ERROR_ENUM_TRANSACTION_CANCELLED) {
-		egg_debug ("error ignored %s\n%s", pk_error_enum_to_text (code), details);
-		goto out;
-	}
-
-	/* if we're doing queries automatically for the user, don't spam them
-	   with locking failure messages */
-	if (code == PK_ERROR_ENUM_CANNOT_GET_LOCK) {
-		if (role == PK_ROLE_ENUM_GET_UPDATES ||
-		    role == PK_ROLE_ENUM_GET_DISTRO_UPGRADES) {
-			egg_debug ("cannot get lock for automatic action, ignoring");
-			goto out;
-		}
-	}
-
-	/* not modal as we are a status icon */
-	gpk_error_dialog (gpk_error_enum_to_localised_text (code),
-			  gpk_error_enum_to_localised_message (code), details);
-out:
-	return;
-}
-#endif
-
 /**
  * gpk_check_update_get_properties_cb:
  **/
diff --git a/src/gpk-dbus-task.c b/src/gpk-dbus-task.c
index c777d6f..638d89e 100644
--- a/src/gpk-dbus-task.c
+++ b/src/gpk-dbus-task.c
@@ -281,6 +281,9 @@ gpk_dbus_task_install_packages_cb (PkTask *task, GAsyncResult *res, GpkDbusTask
 	error_item = pk_results_get_error_code (results);
 	if (error_item != NULL) {
 		egg_warning ("failed to install package: %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, "%s", error_item->details);
+		dbus_g_method_return_error (dtask->priv->context, error_dbus);
+		gpk_dbus_task_handle_error (dtask, error_item);
 		goto out;
 	}
 out:
@@ -334,13 +337,6 @@ gpk_dbus_task_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runtime
 	GtkResponseType button;
 	gchar *package_id = NULL;
 
-	/* get role */
-	pk_client_get_role (client, &role, NULL, NULL);
-	egg_debug ("role: %s, exit: %s", pk_role_enum_to_text (role), pk_exit_enum_to_text (exit_enum));
-
-	/* stop spinning */
-	gpk_modal_dialog_set_percentage (dtask->priv->dialog, 100);
-
 	if (exit_enum != PK_EXIT_ENUM_SUCCESS) {
 
 		/* show finished? */
@@ -445,12 +441,11 @@ gpk_dbus_task_set_status (GpkDbusTask *dtask, PkStatusEnum status)
 	return TRUE;
 }
 
-#if 0
 /**
- * gpk_dbus_task_error_code_cb:
+ * gpk_dbus_task_handle_error:
  **/
 static void
-gpk_dbus_task_error_code_cb (PkClient *client, PkErrorCodeEnum code, const gchar *details, GpkDbusTask *dtask)
+gpk_dbus_task_handle_error (GpkDbusTask *dtask, PkItemErrorCode *error_item)
 {
 	gboolean ret;
 	GError *error = NULL;
@@ -459,29 +454,21 @@ gpk_dbus_task_error_code_cb (PkClient *client, PkErrorCodeEnum code, const gchar
 	NotifyNotification *notification;
 	GtkWidget *widget;
 
-	g_return_if_fail (GPK_IS_DBUS_TASK (dtask));
-
 	/* save for later */
-	dtask->priv->last_exit_code = code;
-
-	/* have we handled? */
-	if (code == PK_ERROR_ENUM_NO_LICENSE_AGREEMENT) {
-		egg_warning ("did not auth, but should be already handled");
-		return;
-	}
+	dtask->priv->last_exit_code = error_item->code;
 
 	/* ignore some errors */
-	if (code == PK_ERROR_ENUM_PROCESS_KILL ||
-	    code == PK_ERROR_ENUM_TRANSACTION_CANCELLED) {
-		egg_debug ("error ignored %s\n%s", pk_error_enum_to_text (code), details);
-		return;
+	if (error_item->code == PK_ERROR_ENUM_NO_LICENSE_AGREEMENT ||
+	    error_item->code == PK_ERROR_ENUM_PROCESS_KILL ||
+	    error_item->code == PK_ERROR_ENUM_TRANSACTION_CANCELLED) {
+		egg_warning ("ignoring %s", pk_error_enum_to_text (error_item->code));
 	}
 
-	egg_debug ("code was %s", pk_error_enum_to_text (code));
+	egg_debug ("code was %s", pk_error_enum_to_text (error_item->code));
 
 	/* use a modal dialog if showing progress, else use libnotify */
-	title = gpk_error_enum_to_localised_text (code);
-	message = gpk_error_enum_to_localised_message (code);
+	title = gpk_error_enum_to_localised_text (error_item->code);
+	message = gpk_error_enum_to_localised_message (error_item->code);
 	if (dtask->priv->show_progress) {
 		widget = GTK_WIDGET (gpk_modal_dialog_get_window (dtask->priv->dialog));
 		gpk_error_dialog_modal (GTK_WINDOW (widget), title, message, details);
@@ -490,7 +477,7 @@ gpk_dbus_task_error_code_cb (PkClient *client, PkErrorCodeEnum code, const gchar
 
 	/* save this globally */
 	g_free (dtask->priv->error_details);
-	dtask->priv->error_details = g_markup_escape_text (details, -1);
+	dtask->priv->error_details = g_markup_escape_text (error_item->details, -1);
 
 	/* do the bubble */
 	notification = notify_notification_new (title, message, "help-browser", NULL);
@@ -507,24 +494,6 @@ gpk_dbus_task_error_code_cb (PkClient *client, PkErrorCodeEnum code, const gchar
 }
 
 /**
- * gpk_dbus_task_package_cb:
- **/
-static void
-gpk_dbus_task_package_cb (PkClient *client, const PkItemPackage *item, GpkDbusTask *dtask)
-{
-	gchar *text;
-	g_return_if_fail (GPK_IS_DBUS_TASK (dtask));
-
-	if (!dtask->priv->show_progress)
-		return;
-
-	text = gpk_package_id_format_twoline (item->package_id, item->summary);
-	gpk_modal_dialog_set_message (dtask->priv->dialog, text);
-	g_free (text);
-}
-#endif
-
-/**
  * gpk_dbus_task_button_close_cb:
  **/
 static void
@@ -574,6 +543,9 @@ gpk_dbus_task_install_files_cb (PkTask *task, GAsyncResult *res, GpkDbusTask *dt
 	error_item = pk_results_get_error_code (results);
 	if (error_item != NULL) {
 		egg_warning ("failed to install file: %s, %s", pk_error_enum_to_text (error_item->code), error_item->details);
+		gpk_dbus_task_handle_error (dtask, error_item);
+		error_dbus = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "%s", error->message);
+		dbus_g_method_return_error (dtask->priv->context, error_dbus);
 		goto out;
 	}
 out:
@@ -711,24 +683,43 @@ gpk_dbus_task_progress_cb (PkProgress *progress, PkProgressType type, GpkDbusTas
 	gint percentage;
 	guint remaining_time;
 	PkStatusEnum status;
+	gchar *package_id = NULL;
+	gchar *text;
+
+	/* optimise */
+	if (!dtask->priv->show_progress)
+		goto out;
 
 	g_object_get (progress,
 		      "allow-cancel", &allow_cancel,
 		      "percentage", &percentage,
 		      "remaining-time", &remaining_time,
 		      "status", &status,
+		      "package-id", &package_id,
 		      NULL);
 
-	if (type == PK_PROGRESS_TYPE_PACKAGE_ID)
+	if (type == PK_PROGRESS_TYPE_PACKAGE_ID) {
 		egg_debug ("_package");
-	else if (type == PK_PROGRESS_TYPE_PERCENTAGE)
+	} else if (type == PK_PROGRESS_TYPE_PERCENTAGE) {
 		gpk_modal_dialog_set_percentage (dtask->priv->dialog, percentage);
-	else if (type == PK_PROGRESS_TYPE_ALLOW_CANCEL)
+	} else if (type == PK_PROGRESS_TYPE_ALLOW_CANCEL) {
 		gpk_modal_dialog_set_allow_cancel (dtask->priv->dialog, allow_cancel);
-	else if (type == PK_PROGRESS_TYPE_STATUS)
+	} else if (type == PK_PROGRESS_TYPE_STATUS) {
 		gpk_dbus_task_set_status (dtask, status);
-	else if (type == PK_PROGRESS_TYPE_REMAINING_TIME)
+
+		if (status == PK_STATUS_ENUM_FINISHED) {
+			/* stop spinning */
+			gpk_modal_dialog_set_percentage (dtask->priv->dialog, 100);
+		}
+	} else if (type == PK_PROGRESS_TYPE_REMAINING_TIME) {
 		gpk_modal_dialog_set_remaining (dtask->priv->dialog, remaining_time);
+	} else if (type == PK_PROGRESS_TYPE_PACKAGE_ID) {
+		text = gpk_package_id_format_twoline (package_id, NULL); //TODO: need summary
+		gpk_modal_dialog_set_message (dtask->priv->dialog, text);
+		g_free (text);
+	}
+out:
+	g_free (package_id);
 }
 
 /**
diff --git a/src/gpk-firmware.c b/src/gpk-firmware.c
index 23d37a1..a3170ad 100644
--- a/src/gpk-firmware.c
+++ b/src/gpk-firmware.c
@@ -370,6 +370,14 @@ gpk_firmware_install_packages_cb (GObject *object, GAsyncResult *res, GpkFirmwar
 	error_item = pk_results_get_error_code (results);
 	if (error_item != NULL) {
 		egg_warning ("failed to install file: %s, %s", pk_error_enum_to_text (error_item->code), error_item->details);
+
+		/* ignore some errors */
+		if (error_item->code != PK_ERROR_ENUM_PROCESS_KILL &&
+		    error_item->code != PK_ERROR_ENUM_TRANSACTION_CANCELLED &&
+		    error_item->code != PK_ERROR_ENUM_NOT_AUTHORIZED) {
+			gpk_error_dialog (gpk_error_enum_to_localised_text (error_item->code),
+					  gpk_error_enum_to_localised_message (error_item->code), error_item->details);
+		}
 		goto out;
 	}
 
@@ -756,31 +764,6 @@ gpk_firmware_udev_text_decode (const gchar *data)
 	return decode;
 }
 
-#if 0
-/**
- * gpk_firmware_error_code_cb:
- **/
-static void
-gpk_firmware_error_code_cb (PkClient *client, PkErrorCodeEnum code, const gchar *details, GpkFirmware *firmware)
-{
-	/* ignore some errors */
-	if (code == PK_ERROR_ENUM_PROCESS_KILL ||
-	    code == PK_ERROR_ENUM_TRANSACTION_CANCELLED) {
-		egg_debug ("error ignored %s: %s", pk_error_enum_to_text (code), details);
-		return;
-	}
-
-	/* ignore not authorised, which seems odd but this will happen if the user clicks cancel */
-	if (code == PK_ERROR_ENUM_NOT_AUTHORIZED) {
-		egg_debug ("auth failure '%s' ignored: %s", pk_error_enum_to_text (code), details);
-		return;
-	}
-
-	gpk_error_dialog (gpk_error_enum_to_localised_text (code),
-			  gpk_error_enum_to_localised_message (code), details);
-}
-#endif
-
 /**
  * gpk_firmware_get_device:
  **/
diff --git a/src/gpk-update-viewer.c b/src/gpk-update-viewer.c
index 3b0280f..9f287e1 100644
--- a/src/gpk-update-viewer.c
+++ b/src/gpk-update-viewer.c
@@ -357,6 +357,7 @@ gpk_update_viewer_update_packages_cb (PkTask *_task, GAsyncResult *res, GMainLoo
 	PkRestartEnum restart;
 	gchar *text;
 	PkItemErrorCode *error_item = NULL;
+	GtkWindow *window;
 
 	/* get the results */
 	results = pk_task_generic_finish (task, res, &error);
@@ -370,6 +371,10 @@ gpk_update_viewer_update_packages_cb (PkTask *_task, GAsyncResult *res, GMainLoo
 	error_item = pk_results_get_error_code (results);
 	if (error_item != NULL) {
 		egg_warning ("failed to update packages: %s, %s", pk_error_enum_to_text (error_item->code), error_item->details);
+
+		window = GTK_WINDOW (gtk_builder_get_object (builder, "dialog_updates"));
+		gpk_error_dialog_modal (window, gpk_error_enum_to_localised_text (error_item->code),
+					gpk_error_enum_to_localised_message (error_item->code), error_item->details);
 		goto out;
 	}
 
@@ -1551,6 +1556,7 @@ gpk_update_viewer_get_details_cb (PkClient *client, GAsyncResult *res, GMainLoop
 	GtkTreeView *treeview;
 	GtkTreeIter iter;
 	PkItemErrorCode *error_item = NULL;
+	GtkWindow *window;
 
 	/* get the results */
 	results = pk_client_generic_finish (client, res, &error);
@@ -1564,6 +1570,10 @@ gpk_update_viewer_get_details_cb (PkClient *client, GAsyncResult *res, GMainLoop
 	error_item = pk_results_get_error_code (results);
 	if (error_item != NULL) {
 		egg_warning ("failed to get details: %s, %s", pk_error_enum_to_text (error_item->code), error_item->details);
+
+		window = GTK_WINDOW (gtk_builder_get_object (builder, "dialog_updates"));
+		gpk_error_dialog_modal (window, gpk_error_enum_to_localised_text (error_item->code),
+					gpk_error_enum_to_localised_message (error_item->code), error_item->details);
 		goto out;
 	}
 
@@ -1629,6 +1639,7 @@ gpk_update_viewer_get_update_detail_cb (PkClient *client, GAsyncResult *res, GMa
 	GtkTreeIter iter;
 	GtkTreePath *path;
 	PkItemErrorCode *error_item = NULL;
+	GtkWindow *window;
 
 	/* get the results */
 	results = pk_client_generic_finish (client, res, &error);
@@ -1642,6 +1653,10 @@ gpk_update_viewer_get_update_detail_cb (PkClient *client, GAsyncResult *res, GMa
 	error_item = pk_results_get_error_code (results);
 	if (error_item != NULL) {
 		egg_warning ("failed to get update details: %s, %s", pk_error_enum_to_text (error_item->code), error_item->details);
+
+		window = GTK_WINDOW (gtk_builder_get_object (builder, "dialog_updates"));
+		gpk_error_dialog_modal (window, gpk_error_enum_to_localised_text (error_item->code),
+					gpk_error_enum_to_localised_message (error_item->code), error_item->details);
 		goto out;
 	}
 
@@ -1810,21 +1825,6 @@ gpk_update_viewer_finished_cb (PkClient *client, PkExitEnum exit, guint runtime,
 }
 #endif
 
-#if 0
-/**
- * gpk_update_viewer_error_code_cb:
- **/
-static void
-gpk_update_viewer_error_code_cb (PkClient *client, PkErrorCodeEnum code, const gchar *details, gpointer data)
-{
-	GtkWindow *window;
-
-	window = GTK_WINDOW (gtk_builder_get_object (builder, "dialog_updates"));
-	gpk_error_dialog_modal (window, gpk_error_enum_to_localised_text (code),
-				gpk_error_enum_to_localised_message (code), details);
-}
-#endif
-
 /**
  * gpk_update_viewer_repo_array_changed_cb:
  **/
@@ -2097,6 +2097,7 @@ gpk_update_viewer_get_updates_cb (PkClient *client, GAsyncResult *res, GMainLoop
 	GtkTreeModel *model;
 	GtkWidget *widget;
 	PkItemErrorCode *error_item = NULL;
+	GtkWindow *window;
 
 	/* get the results */
 	results = pk_client_generic_finish (client, res, &error);
@@ -2110,6 +2111,10 @@ gpk_update_viewer_get_updates_cb (PkClient *client, GAsyncResult *res, GMainLoop
 	error_item = pk_results_get_error_code (results);
 	if (error_item != NULL) {
 		egg_warning ("failed to get updates: %s, %s", pk_error_enum_to_text (error_item->code), error_item->details);
+
+		window = GTK_WINDOW (gtk_builder_get_object (builder, "dialog_updates"));
+		gpk_error_dialog_modal (window, gpk_error_enum_to_localised_text (error_item->code),
+					gpk_error_enum_to_localised_message (error_item->code), error_item->details);
 		goto out;
 	}
 
@@ -2469,6 +2474,7 @@ gpk_update_viewer_get_distro_upgrades_cb (PkClient *client, GAsyncResult *res, G
 	GtkTreeView *treeview;
 	GtkTreeModel *model;
 	PkItemErrorCode *error_item = NULL;
+	GtkWindow *window;
 
 	/* get the results */
 	results = pk_client_generic_finish (client, res, &error);
@@ -2482,6 +2488,10 @@ gpk_update_viewer_get_distro_upgrades_cb (PkClient *client, GAsyncResult *res, G
 	error_item = pk_results_get_error_code (results);
 	if (error_item != NULL) {
 		egg_warning ("failed to get list of distro upgrades: %s, %s", pk_error_enum_to_text (error_item->code), error_item->details);
+
+		window = GTK_WINDOW (gtk_builder_get_object (builder, "dialog_updates"));
+		gpk_error_dialog_modal (window, gpk_error_enum_to_localised_text (error_item->code),
+					gpk_error_enum_to_localised_message (error_item->code), error_item->details);
 		goto out;
 	}
 



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