Blob Blame History Raw
diff --git a/src/gpk-application.c b/src/gpk-application.c
index d586d5a..8a28300 100644
--- a/src/gpk-application.c
+++ b/src/gpk-application.c
@@ -118,6 +118,10 @@ enum
 	GROUPS_COLUMN_LAST
 };
 
+static gchar *key_repository_name = NULL;
+static gchar *key_repo_id = NULL;
+static gchar *key_package_id = NULL;
+
 static guint	     signals [LAST_SIGNAL] = { 0 };
 
 G_DEFINE_TYPE (GpkApplication, gpk_application, G_TYPE_OBJECT)
@@ -577,6 +581,39 @@ gpk_application_package_cb (PkClient *client, PkInfoEnum info, const gchar *pack
 		gtk_main_iteration ();
 }
 
+gboolean
+gpk_application_install_sig_cb (GpkApplication *application)
+{
+	gboolean ret;
+	GError *error = NULL;
+
+	g_return_val_if_fail (PK_IS_APPLICATION (application), FALSE);
+
+	pk_debug ("install sig %s", key_package_id);
+	ret = pk_client_reset (application->priv->client_action, &error);
+	if (!ret) {
+		pk_warning ("failed to reset client: %s", error->message);
+		g_error_free (error);
+		return FALSE;
+	}
+
+	// GIGANTIC HACK TO PRESERVE ABI
+	ret = pk_client_rollback (application->priv->client_action, key_package_id, &error);
+	if (!ret) {
+		pk_warning ("failed to install signature: %s", error->message);
+		if (strcmp (error->message, "org.freedesktop.packagekit.install no") == 0) {
+			gpk_application_error_message (application, _("You don't have the necessary privileges to install a signature"), NULL);
+		} else if (g_str_has_prefix (error->message, "org.freedesktop.packagekit.install")) {
+			/* canceled auth dialog, be silent */
+		} else {
+			/* ick, we failed so pretend we didn't do the action */
+			gpk_application_error_message (application, _("The signature could not be installed"), error->message);
+		}
+		g_error_free (error);
+	}
+	return FALSE;
+}
+
 /**
  * gpk_application_error_code_cb:
  **/
@@ -590,6 +627,33 @@ gpk_application_error_code_cb (PkClient *client, PkErrorCodeEnum code, const gch
 		return;
 	}
 
+	// GIGANTIC HACK
+	if (code == PK_ERROR_ENUM_GPG_FAILURE) {
+		GtkWidget *main_window;
+		GtkWidget *dialog;
+		PkPackageId *ident;
+		main_window = glade_xml_get_widget (application->priv->glade_xml, "window_manager");
+		ident = pk_package_id_new_from_string (key_package_id);
+		dialog = gtk_message_dialog_new (GTK_WINDOW (main_window), GTK_DIALOG_DESTROY_WITH_PARENT,
+						 GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
+						 "Do you want to import key %s from %s for %s?",
+						 key_repo_id, key_repository_name, ident->name);
+		pk_package_id_free (ident);
+		gint result = gtk_dialog_run (GTK_DIALOG (dialog));
+		gtk_widget_destroy (dialog);
+		if (result == GTK_RESPONSE_YES) {
+			dialog = gtk_message_dialog_new (GTK_WINDOW (main_window), GTK_DIALOG_DESTROY_WITH_PARENT,
+							 GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK,
+							 "Key will be imported, please try transaction again.\n"
+							 "This UI will be replaced in future versions of PackageKit"
+							 " - please don't file bugs as an update is being worked on...");
+			result = gtk_dialog_run (GTK_DIALOG (dialog));
+			gtk_widget_destroy (dialog);
+			g_idle_add ((GSourceFunc) gpk_application_install_sig_cb, application);
+			return;
+		}
+	}
+
 	gpk_application_error_message (application,
 				      gpk_error_enum_to_localised_text (code), details);
 }
@@ -1967,6 +2031,20 @@ pk_application_repo_detail_cb (PkClient *client, const gchar *repo_id,
 }
 
 /**
+ * pk_application_repo_signature_required_cb:
+ **/
+static void
+pk_application_repo_signature_required_cb (PkClient *client, const gchar *package_id, const gchar *repository_name,
+				       const gchar *key_url, const gchar *key_userid, const gchar *key_id,
+				       const gchar *key_fingerprint, const gchar *key_timestamp,
+				       PkSigTypeEnum type, GpkApplication *application)
+{
+	key_repository_name = g_strdup (repository_name);
+	key_repo_id = g_strdup (key_id);
+	key_package_id = g_strdup (package_id);
+}
+
+/**
  * gpk_application_init:
  **/
 static void
@@ -2040,6 +2118,8 @@ gpk_application_init (GpkApplication *application)
 			  G_CALLBACK (gpk_application_allow_cancel_cb), application);
 	g_signal_connect (application->priv->client_action, "repo-detail",
 			  G_CALLBACK (pk_application_repo_detail_cb), application);
+	g_signal_connect (application->priv->client_action, "repo-signature-required",
+			  G_CALLBACK (pk_application_repo_signature_required_cb), application);
 
 	application->priv->client_description = pk_client_new ();
 	g_signal_connect (application->priv->client_description, "description",
diff --git a/src/gpk-install-file.c b/src/gpk-install-file.c
index 578c70c..a5e1c35 100644
--- a/src/gpk-install-file.c
+++ b/src/gpk-install-file.c
@@ -34,6 +34,7 @@
 
 #include <pk-debug.h>
 #include <pk-client.h>
+#include <pk-package-id.h>
 
 #include "gpk-progress.h"
 #include "gpk-common.h"
@@ -48,6 +49,10 @@ typedef enum {
         PAGE_LAST
 } PkPageEnum;
 
+static gchar *key_repository_name = NULL;
+static gchar *key_repo_id = NULL;
+static gchar *key_package_id = NULL;
+
 static void
 gpk_install_file_set_page (PkPageEnum page)
 {
@@ -150,6 +155,29 @@ gpk_install_file_status_changed_cb (PkClient     *client,
 	}
 }
 
+gboolean
+gpk_install_file_install_sig_cb (gpointer data)
+{
+	gboolean ret;
+	GError *error = NULL;
+
+	pk_debug ("install sig %s", key_package_id);
+	ret = pk_client_reset (client, &error);
+	if (!ret) {
+		pk_warning ("failed to reset client: %s", error->message);
+		g_error_free (error);
+		return FALSE;
+	}
+
+	// GIGANTIC HACK TO PRESERVE ABI
+	ret = pk_client_rollback (client, key_package_id, &error);
+	if (!ret) {
+		pk_warning ("failed to install signature: %s", error->message);
+		g_error_free (error);
+	}
+	return FALSE;
+}
+
 static void
 gpk_install_file_error_code_cb (PkClient        *client,
 			        PkErrorCodeEnum  code,
@@ -161,6 +189,32 @@ gpk_install_file_error_code_cb (PkClient        *client,
         gchar *title_bold;
         gchar *details_safe;
 
+	// GIGANTIC HACK
+	if (code == PK_ERROR_ENUM_GPG_FAILURE) {
+		GtkWidget *main_window;
+		GtkWidget *dialog;
+		PkPackageId *ident;
+		main_window = glade_xml_get_widget (glade_xml, "window_updates");
+		ident = pk_package_id_new_from_string (key_package_id);
+		dialog = gtk_message_dialog_new (GTK_WINDOW (main_window), GTK_DIALOG_DESTROY_WITH_PARENT,
+						 GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
+						 "Do you want to import key %s from %s for %s?",
+						 key_repo_id, key_repository_name, ident->name);
+		pk_package_id_free (ident);
+		gint result = gtk_dialog_run (GTK_DIALOG (dialog));
+		gtk_widget_destroy (dialog);
+		if (result == GTK_RESPONSE_YES) {
+			dialog = gtk_message_dialog_new (GTK_WINDOW (main_window), GTK_DIALOG_DESTROY_WITH_PARENT,
+							 GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK,
+							 "Key will be imported, please try transaction again.\n"
+							 "This UI will be replaced in future versions of PackageKit"
+							 " - please don't file bugs as an update is being worked on...");
+			result = gtk_dialog_run (GTK_DIALOG (dialog));
+			gtk_widget_destroy (dialog);
+			g_idle_add ((GSourceFunc) gpk_install_file_install_sig_cb, NULL);
+			return;
+		}
+	}
         gpk_install_file_set_page (PAGE_ERROR);
 
         /* set bold title */
@@ -199,6 +253,20 @@ pk_button_close_cb (GtkWidget *widget, gpointer data)
 }
 
 /**
+ * pk_install_file_repo_signature_required_cb:
+ **/
+static void
+pk_install_file_repo_signature_required_cb (PkClient *client, const gchar *package_id, const gchar *repository_name,
+				       const gchar *key_url, const gchar *key_userid, const gchar *key_id,
+				       const gchar *key_fingerprint, const gchar *key_timestamp,
+				       PkSigTypeEnum type, gpointer userdata)
+{
+	key_repository_name = g_strdup (repository_name);
+	key_repo_id = g_strdup (key_id);
+	key_package_id = g_strdup (package_id);
+}
+
+/**
  * main:
  **/
 int
@@ -272,6 +340,8 @@ main (int argc, char *argv[])
 			  G_CALLBACK (gpk_install_file_status_changed_cb), NULL);
 	g_signal_connect (client, "error-code",
 			  G_CALLBACK (gpk_install_file_error_code_cb), NULL);
+	g_signal_connect (client, "repo-signature-required",
+			  G_CALLBACK (pk_install_file_repo_signature_required_cb), NULL);
 
 	glade_xml = glade_xml_new (PK_DATA "/gpk-install-file.glade", NULL, NULL);
 	main_window = glade_xml_get_widget (glade_xml, "window_updates");
diff --git a/src/gpk-notify.c b/src/gpk-notify.c
index d3406d6..747f28a 100644
--- a/src/gpk-notify.c
+++ b/src/gpk-notify.c
@@ -74,6 +74,10 @@ struct GpkNotifyPrivate
 
 G_DEFINE_TYPE (GpkNotify, gpk_notify, G_TYPE_OBJECT)
 
+static gchar *key_repository_name = NULL;
+static gchar *key_repo_id = NULL;
+static gchar *key_package_id = NULL;
+
 /**
  * gpk_notify_class_init:
  * @klass: The GpkNotifyClass
@@ -800,6 +804,31 @@ out:
 	g_ptr_array_free (security_array, TRUE);
 }
 
+gboolean
+gpk_notify_install_sig_cb (GpkNotify *notify)
+{
+	gboolean ret;
+	GError *error = NULL;
+
+	g_return_val_if_fail (GPK_IS_NOTIFY (notify), FALSE);
+
+	pk_debug ("install sig %s", key_package_id);
+	ret = pk_client_reset (notify->priv->client_update_system, &error);
+	if (!ret) {
+		pk_warning ("failed to reset client: %s", error->message);
+		g_error_free (error);
+		return FALSE;
+	}
+
+	// GIGANTIC HACK TO PRESERVE ABI
+	ret = pk_client_rollback (notify->priv->client_update_system, key_package_id, &error);
+	if (!ret) {
+		pk_warning ("failed to install signature: %s", error->message);
+		g_error_free (error);
+	}
+	return FALSE;
+}
+
 /**
  * gpk_notify_error_code_cb:
  **/
@@ -810,6 +839,31 @@ gpk_notify_error_code_cb (PkClient *client, PkErrorCodeEnum error_code, const gc
 
 	g_return_if_fail (GPK_IS_NOTIFY (notify));
 
+	// GIGANTIC HACK
+	if (error_code == PK_ERROR_ENUM_GPG_FAILURE) {
+		GtkWidget *dialog;
+		PkPackageId *ident;
+		ident = pk_package_id_new_from_string (key_package_id);
+		dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
+						 GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
+						 "Do you want to import key %s from %s for %s?",
+						 key_repo_id, key_repository_name, ident->name);
+		pk_package_id_free (ident);
+		gint result = gtk_dialog_run (GTK_DIALOG (dialog));
+		gtk_widget_destroy (dialog);
+		if (result == GTK_RESPONSE_YES) {
+			dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
+							 GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK,
+							 "Key will be imported, please try transaction again.\n"
+							 "This UI will be replaced in future versions of PackageKit"
+							 " - please don't file bugs as an update is being worked on...");
+			result = gtk_dialog_run (GTK_DIALOG (dialog));
+			gtk_widget_destroy (dialog);
+			g_idle_add ((GSourceFunc) gpk_notify_install_sig_cb, notify);
+			return;
+		}
+	}
+
 	title = gpk_error_enum_to_localised_text (error_code);
 
 	/* ignore some errors */
@@ -1043,6 +1097,20 @@ gpk_notify_smart_icon_notify_button (GpkSmartIcon *sicon, GpkNotifyButton button
 }
 
 /**
+ * pk_notify_repo_signature_required_cb:
+ **/
+static void
+pk_notify_repo_signature_required_cb (PkClient *client, const gchar *package_id, const gchar *repository_name,
+				       const gchar *key_url, const gchar *key_userid, const gchar *key_id,
+				       const gchar *key_fingerprint, const gchar *key_timestamp,
+				       PkSigTypeEnum type, GpkNotify *notify)
+{
+	key_repository_name = g_strdup (repository_name);
+	key_repo_id = g_strdup (key_id);
+	key_package_id = g_strdup (package_id);
+}
+
+/**
  * gpk_notify_init:
  * @notify: This class instance
  **/
@@ -1087,6 +1155,8 @@ gpk_notify_init (GpkNotify *notify)
 			  G_CALLBACK (gpk_notify_update_system_finished_cb), notify);
 	g_signal_connect (notify->priv->client_update_system, "error-code",
 			  G_CALLBACK (gpk_notify_error_code_cb), notify);
+	g_signal_connect (notify->priv->client_update_system, "repo-signature-required",
+			  G_CALLBACK (pk_notify_repo_signature_required_cb), notify);
 
 	notify->priv->notify = pk_notify_new ();
 	g_signal_connect (notify->priv->notify, "updates-changed",
diff --git a/src/gpk-update-viewer.c b/src/gpk-update-viewer.c
index e7d32f2..23c4808 100644
--- a/src/gpk-update-viewer.c
+++ b/src/gpk-update-viewer.c
@@ -69,6 +69,10 @@ static int frame_counter = 0;
 static int n_frames = 0;
 static GdkPixbuf **frames = NULL;
 
+static gchar *key_repository_name = NULL;
+static gchar *key_repo_id = NULL;
+static gchar *key_package_id = NULL;
+
 enum {
 	PREVIEW_COLUMN_ICON,
 	PREVIEW_COLUMN_TEXT,
@@ -1272,12 +1276,6 @@ pk_updates_finished_cb (PkClient *client, PkExitEnum exit, guint runtime, gpoint
 		pk_update_update_last_updated_time (client);
 	}
 
-	/* we don't need to do anything here */
-	if (role == PK_ROLE_ENUM_REFRESH_CACHE ||
-	    role == PK_ROLE_ENUM_GET_UPDATE_DETAIL) {
-		return;
-	}
-
 	/* stop the throbber */
 	pk_updates_preview_animation_stop ();
 
@@ -1322,6 +1320,12 @@ pk_updates_finished_cb (PkClient *client, PkExitEnum exit, guint runtime, gpoint
 		}
 	}
 
+	/* HACK: force a new update -- fixed much better in master */
+	if (role == PK_ROLE_ENUM_REFRESH_CACHE) {
+		pk_button_overview_cb (NULL, NULL);
+		return;
+	}
+
 	populate_preview ();
 }
 
@@ -1498,6 +1502,29 @@ pk_updates_task_list_changed_cb (PkTaskList *tlist, gpointer data)
 	}
 }
 
+gboolean
+gpk_updates_install_sig_cb (gpointer data)
+{
+	gboolean ret;
+	GError *error = NULL;
+
+	pk_debug ("install sig %s", key_package_id);
+	ret = pk_client_reset (client_action, &error);
+	if (!ret) {
+		pk_warning ("failed to reset client: %s", error->message);
+		g_error_free (error);
+		return FALSE;
+	}
+
+	// GIGANTIC HACK TO PRESERVE ABI
+	ret = pk_client_rollback (client_action, key_package_id, &error);
+	if (!ret) {
+		pk_warning ("failed to install signature: %s", error->message);
+		g_error_free (error);
+	}
+	return FALSE;
+}
+
 /**
  * pk_updates_error_code_cb:
  **/
@@ -1509,6 +1536,33 @@ pk_updates_error_code_cb (PkClient *client, PkErrorCodeEnum code, const gchar *d
 	gchar *title_bold;
 	gchar *details_safe;
 
+	// GIGANTIC HACK
+	if (code == PK_ERROR_ENUM_GPG_FAILURE) {
+		GtkWidget *main_window;
+		GtkWidget *dialog;
+		PkPackageId *ident;
+		main_window = glade_xml_get_widget (glade_xml, "window_updates");
+		ident = pk_package_id_new_from_string (key_package_id);
+		dialog = gtk_message_dialog_new (GTK_WINDOW (main_window), GTK_DIALOG_DESTROY_WITH_PARENT,
+						 GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
+						 "Do you want to import key %s from %s for %s?",
+						 key_repo_id, key_repository_name, ident->name);
+		pk_package_id_free (ident);
+		gint result = gtk_dialog_run (GTK_DIALOG (dialog));
+		gtk_widget_destroy (dialog);
+		if (result == GTK_RESPONSE_YES) {
+			dialog = gtk_message_dialog_new (GTK_WINDOW (main_window), GTK_DIALOG_DESTROY_WITH_PARENT,
+							 GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK,
+							 "Key will be imported, please try transaction again.\n"
+							 "This UI will be replaced in future versions of PackageKit"
+							 " - please don't file bugs as an update is being worked on...");
+			result = gtk_dialog_run (GTK_DIALOG (dialog));
+			gtk_widget_destroy (dialog);
+			g_idle_add ((GSourceFunc) gpk_updates_install_sig_cb, NULL);
+			return;
+		}
+	}
+
 	/* set bold title */
 	widget = glade_xml_get_widget (glade_xml, "label_error_title");
 	title = gpk_error_enum_to_localised_text (code);
@@ -1716,6 +1770,20 @@ pk_updates_detail_popup_menu (GtkWidget *treeview, gpointer userdata)
 }
 
 /**
+ * pk_updates_repo_signature_required_cb:
+ **/
+static void
+pk_updates_repo_signature_required_cb (PkClient *client, const gchar *package_id, const gchar *repository_name,
+				       const gchar *key_url, const gchar *key_userid, const gchar *key_id,
+				       const gchar *key_fingerprint, const gchar *key_timestamp,
+				       PkSigTypeEnum type, gpointer userdata)
+{
+	key_repository_name = g_strdup (repository_name);
+	key_repo_id = g_strdup (key_id);
+	key_package_id = g_strdup (package_id);
+}
+
+/**
  * main:
  **/
 int
@@ -1809,6 +1877,8 @@ main (int argc, char *argv[])
 			  G_CALLBACK (pk_updates_error_code_cb), NULL);
 	g_signal_connect (client_action, "allow-cancel",
 			  G_CALLBACK (pk_updates_allow_cancel_cb), NULL);
+	g_signal_connect (client_action, "repo-signature-required",
+			  G_CALLBACK (pk_updates_repo_signature_required_cb), NULL);
 
 	notify = pk_notify_new ();
 	g_signal_connect (notify, "repo-list-changed",