[gnome-packagekit] Support the new exit enum in PackageKit 0.5.x



commit d7ec2d1e84af76f1dc0b19fa8c42d2b9294c5e39
Author: Richard Hughes <richard hughsie com>
Date:   Wed Jun 17 22:06:46 2009 +0100

    Support the new exit enum in PackageKit 0.5.x

 src/gpk-application.c   |   15 ++++++++++++---
 src/gpk-check-update.c  |   11 ++++++++++-
 src/gpk-common.c        |    6 ++++--
 src/gpk-common.h        |    4 +++-
 src/gpk-dbus-task.c     |   36 ++++++++++++++++++++++++++++++------
 src/gpk-enum.h          |    6 ++++++
 src/gpk-update-viewer.c |   13 +++++++++++--
 7 files changed, 76 insertions(+), 15 deletions(-)
---
diff --git a/src/gpk-application.c b/src/gpk-application.c
index 16fecef..989525d 100644
--- a/src/gpk-application.c
+++ b/src/gpk-application.c
@@ -1021,9 +1021,9 @@ gpk_application_error_code_cb (PkClient *client, PkErrorCodeEnum code, const gch
 		return;
 
 	/* ignore the ones we can handle */
-	if (code == PK_ERROR_ENUM_GPG_FAILURE ||
-	    code == PK_ERROR_ENUM_NO_LICENSE_AGREEMENT ||
-	    code == PK_ERROR_ENUM_MEDIA_CHANGE_REQUIRED) {
+	if (code == PK_ERROR_ENUM_NO_LICENSE_AGREEMENT ||
+	    code == PK_ERROR_ENUM_MEDIA_CHANGE_REQUIRED ||
+	    pk_error_code_is_need_untrusted (code)) {
 		egg_debug ("error ignored as we're handling %s\n%s", pk_error_enum_to_text (code), details);
 		return;
 	}
@@ -1291,6 +1291,15 @@ gpk_application_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runti
 	gtk_widget_set_sensitive (widget, TRUE);
 	gpk_application_set_buttons_apply_clear (application);
 
+	/* need to handle retry with only_trusted=FALSE */
+	if (client == application->priv->client_primary &&
+	    exit_enum == PK_EXIT_ENUM_NEED_UNTRUSTED) {
+		egg_debug ("need to handle untrusted");
+		pk_client_set_only_trusted (client, FALSE);
+		gpk_application_primary_requeue (application);
+		return;
+	}
+
 	/* if secondary, ignore */
 	if (client == application->priv->client_primary &&
 	    (exit_enum == PK_EXIT_ENUM_KEY_REQUIRED ||
diff --git a/src/gpk-check-update.c b/src/gpk-check-update.c
index 7a683ad..d482e6e 100644
--- a/src/gpk-check-update.c
+++ b/src/gpk-check-update.c
@@ -1249,7 +1249,7 @@ gpk_check_update_error_code_cb (PkClient *client, PkErrorCodeEnum code, const gc
 	}
 
 	/* ignore the ones we can handle */
-	if (code == PK_ERROR_ENUM_GPG_FAILURE) {
+	if (pk_error_code_is_need_untrusted (code)) {
 		egg_debug ("error ignored as we're handling %s\n%s", pk_error_enum_to_text (code), details);
 		return;
 	}
@@ -1438,6 +1438,15 @@ gpk_check_update_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runt
 	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));
 
+	/* need to handle retry with only_trusted=FALSE */
+	if (client == cupdate->priv->client_primary &&
+	    exit_enum == PK_EXIT_ENUM_NEED_UNTRUSTED) {
+		egg_debug ("need to handle untrusted");
+		pk_client_set_only_trusted (client, FALSE);
+		gpk_check_update_primary_requeue (cupdate);
+		return;
+	}
+
 	/* we've just agreed to auth */
 	if (role == PK_ROLE_ENUM_INSTALL_SIGNATURE) {
 		if (exit_enum == PK_EXIT_ENUM_SUCCESS)
diff --git a/src/gpk-common.c b/src/gpk-common.c
index 5a511c8..101b752 100644
--- a/src/gpk-common.c
+++ b/src/gpk-common.c
@@ -45,14 +45,15 @@
 #define GNOME_SESSION_MANAGER_PATH		"/org/gnome/SessionManager"
 #define GNOME_SESSION_MANAGER_INTERFACE		"org.gnome.SessionManager"
 
+#if (!PK_CHECK_VERSION(0,5,0))
 /**
- * gpk_is_error_code_retry_trusted:
+ * gpk_error_code_is_need_untrusted:
  * @error_code: the transactions #PkErrorCodeEnum
  *
  * Return value: if the error code suggests to try with only_trusted %FALSE
  **/
 gboolean
-gpk_is_error_code_retry_trusted (PkErrorCodeEnum error_code)
+gpk_error_code_is_need_untrusted (PkErrorCodeEnum error_code)
 {
 	gboolean ret = FALSE;
 	switch (error_code) {
@@ -68,6 +69,7 @@ gpk_is_error_code_retry_trusted (PkErrorCodeEnum error_code)
 	}
 	return ret;
 }
+#endif
 
 /**
  * gtk_text_buffer_insert_markup:
diff --git a/src/gpk-common.h b/src/gpk-common.h
index 3e11acc..8e2e538 100644
--- a/src/gpk-common.h
+++ b/src/gpk-common.h
@@ -105,7 +105,9 @@ gboolean	 gpk_window_set_size_request		(GtkWindow	*window,
 							 guint		 width,
 							 guint		 height);
 gboolean	 gpk_ignore_session_error		(GError		*error);
-gboolean	 gpk_is_error_code_retry_trusted	(PkErrorCodeEnum error_code);
+#if (!PK_CHECK_VERSION(0,5,0))
+gboolean	 gpk_error_code_is_need_untrusted	(PkErrorCodeEnum error_code);
+#endif
 
 G_END_DECLS
 
diff --git a/src/gpk-dbus-task.c b/src/gpk-dbus-task.c
index 1d3c611..15115d3 100644
--- a/src/gpk-dbus-task.c
+++ b/src/gpk-dbus-task.c
@@ -106,7 +106,9 @@ struct _GpkDbusTaskPrivate
 	GpkHelperRepoSignature	*helper_repo_signature;
 	GpkHelperEula		*helper_eula;
 	GpkHelperRun		*helper_run;
+#if (!PK_CHECK_VERSION(0,5,0))
 	GpkHelperUntrusted	*helper_untrusted;
+#endif
 	GpkHelperChooser	*helper_chooser;
 	DBusGMethodInvocation	*context;
 	GpkDbusTaskRole		 role;
@@ -301,6 +303,7 @@ gpk_dbus_task_repo_signature_required_cb (PkClient *client, const gchar *package
 
 static void gpk_dbus_task_install_package_files_internal (GpkDbusTask *task, gboolean trusted);
 
+#if (!PK_CHECK_VERSION(0,5,0))
 /**
  * gpk_dbus_task_untrusted_event_cb:
  **/
@@ -329,6 +332,7 @@ out:
 		g_error_free (error);
 	return;
 }
+#endif
 
 static void gpk_dbus_task_install_package_ids_dep_check (GpkDbusTask *task);
 
@@ -666,6 +670,22 @@ gpk_dbus_task_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runtime
 		goto out;
 	}
 
+	/* need to handle retry with only_trusted=FALSE */
+	if (client == task->priv->client_primary &&
+	    exit_enum == PK_EXIT_ENUM_NEED_UNTRUSTED) {
+		egg_debug ("need to handle untrusted");
+		pk_client_set_only_trusted (client, FALSE);
+
+		/* try again */
+		ret = pk_client_requeue (task->priv->client_primary, &error_local);
+		if (!ret) {
+			egg_warning ("Failed to requeue: %s", error_local->message);
+			error = g_error_new (GPK_DBUS_ERROR, PK_ERROR_ENUM_INTERNAL_ERROR, "cannot requeue: %s", error_local->message);
+			dbus_g_method_return_error (task->priv->context, error);
+		}
+		goto out;
+	}
+
 	/* EULA or GPG key auth done */
 	if (client == task->priv->client_secondary &&
 	    exit_enum == PK_EXIT_ENUM_SUCCESS) {
@@ -682,13 +702,15 @@ gpk_dbus_task_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runtime
 
 	if (exit_enum != PK_EXIT_ENUM_SUCCESS) {
 
+#if (!PK_CHECK_VERSION(0,5,0))
 		/* we failed because of failed exit code */
-		ret = gpk_is_error_code_retry_trusted (task->priv->last_exit_code);
+		ret = pk_error_code_is_need_untrusted (task->priv->last_exit_code);
 		if (ret) {
-			egg_warning ("showing untrusted ui");
+			egg_debug ("showing untrusted ui");
 			gpk_helper_untrusted_show (task->priv->helper_untrusted, task->priv->last_exit_code);
 			goto out;
 		}
+#endif
 
 		/* show finished? */
 		if (!task->priv->show_finished)
@@ -1099,15 +1121,13 @@ gpk_dbus_task_error_code_cb (PkClient *client, PkErrorCodeEnum code, const gchar
 	task->priv->last_exit_code = code;
 
 	/* have we handled? */
-	if (code == PK_ERROR_ENUM_GPG_FAILURE ||
-	    code == PK_ERROR_ENUM_NO_LICENSE_AGREEMENT) {
+	if (code == PK_ERROR_ENUM_NO_LICENSE_AGREEMENT) {
 		egg_warning ("did not auth, but should be already handled");
 		return;
 	}
 
 	/* have we handled? */
-	if (code == PK_ERROR_ENUM_BAD_GPG_SIGNATURE ||
-	    code == PK_ERROR_ENUM_MISSING_GPG_SIGNATURE) {
+	if (pk_error_code_is_need_untrusted (code)) {
 		egg_warning ("will handled in finished");
 		return;
 	}
@@ -3211,9 +3231,11 @@ gpk_dbus_task_init (GpkDbusTask *task)
 	task->priv->helper_run = gpk_helper_run_new ();
 	gpk_helper_run_set_parent (task->priv->helper_run, main_window);
 
+#if (!PK_CHECK_VERSION(0,5,0))
 	task->priv->helper_untrusted = gpk_helper_untrusted_new ();
 	g_signal_connect (task->priv->helper_untrusted, "event", G_CALLBACK (gpk_dbus_task_untrusted_event_cb), task);
 	gpk_helper_untrusted_set_parent (task->priv->helper_untrusted, main_window);
+#endif
 
 	task->priv->helper_chooser = gpk_helper_chooser_new ();
 	g_signal_connect (task->priv->helper_chooser, "event", G_CALLBACK (gpk_dbus_task_chooser_event_cb), task);
@@ -3294,7 +3316,9 @@ gpk_dbus_task_finalize (GObject *object)
 	g_object_unref (task->priv->language);
 	g_object_unref (task->priv->helper_eula);
 	g_object_unref (task->priv->helper_run);
+#if (!PK_CHECK_VERSION(0,5,0))
 	g_object_unref (task->priv->helper_untrusted);
+#endif
 	g_object_unref (task->priv->helper_chooser);
 	g_object_unref (task->priv->helper_repo_signature);
 
diff --git a/src/gpk-enum.h b/src/gpk-enum.h
index 1e8dbbe..e701ed3 100644
--- a/src/gpk-enum.h
+++ b/src/gpk-enum.h
@@ -88,6 +88,12 @@ typedef guint PkMediaTypeEnum;
 #define PK_ERROR_ENUM_CANNOT_UPDATE_REPO_UNSIGNED	(PK_ERROR_ENUM_CANNOT_INSTALL_REPO_UNSIGNED + 1)
 #endif
 
+/* constants defined in 0.5.0 */
+#if (!PK_CHECK_VERSION(0,5,0))
+#define PK_EXIT_ENUM_NEED_UNTRUSTED			(PK_EXIT_ENUM_MEDIA_CHANGE_REQUIRED + 1)
+#define pk_error_code_is_need_untrusted			gpk_error_code_is_need_untrusted
+#endif
+
 void		 gpk_enum_test				(gpointer	 data);
 const gchar	*gpk_role_enum_to_localised_past	(PkRoleEnum	 role)
 							 G_GNUC_CONST;
diff --git a/src/gpk-update-viewer.c b/src/gpk-update-viewer.c
index 21cef3c..3335819 100644
--- a/src/gpk-update-viewer.c
+++ b/src/gpk-update-viewer.c
@@ -1718,6 +1718,15 @@ gpk_update_viewer_finished_cb (PkClient *client, PkExitEnum exit, guint runtime,
 	widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_quit"));
 	gtk_widget_set_sensitive (widget, TRUE);
 
+	/* need to handle retry with only_trusted=FALSE */
+	if (client == client_primary &&
+	    exit == PK_EXIT_ENUM_NEED_UNTRUSTED) {
+		egg_debug ("need to handle untrusted");
+		pk_client_set_only_trusted (client, FALSE);
+		gpk_update_viewer_primary_requeue (NULL);
+		return;
+	}
+
 	/* if secondary, ignore */
 	if (client == client_primary &&
 	    (exit == PK_EXIT_ENUM_KEY_REQUIRED ||
@@ -2046,8 +2055,8 @@ gpk_update_viewer_error_code_cb (PkClient *client, PkErrorCodeEnum code, const g
 	}
 
 	/* ignore the ones we can handle */
-	if (code == PK_ERROR_ENUM_GPG_FAILURE ||
-	    code == PK_ERROR_ENUM_NO_LICENSE_AGREEMENT) {
+	if (code == PK_ERROR_ENUM_NO_LICENSE_AGREEMENT ||
+	    pk_error_code_is_need_untrusted (code)) {
 		egg_debug ("error ignored as we're handling %s\n%s", pk_error_enum_to_text (code), details);
 		return;
 	}



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