/cpw/tomkiewicz/masterpassword: e56d3dd7b0e4: Track migrating pa...

Tomasz Wasilczyk tomkiewicz at cpw.pidgin.im
Fri Mar 22 20:06:36 EDT 2013


Changeset: e56d3dd7b0e47f30195e7142ad84ba826c846afe
Author:	 Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date:	 2013-03-23 01:06 +0100
Branch:	 soc.2008.masterpassword
URL: https://hg.pidgin.im/cpw/tomkiewicz/masterpassword/rev/e56d3dd7b0e4

Description:

Track migrating passwords in prefs window

diffstat:

 libpurple/keyring.c                          |  21 +++++++++----
 libpurple/plugins/keyrings/internalkeyring.c |   3 --
 libpurple/plugins/keyrings/kwallet.cpp       |   3 --
 pidgin/gtkprefs.c                            |  40 ++++++++++++++++++++++++++-
 4 files changed, 52 insertions(+), 15 deletions(-)

diffs (173 lines):

diff --git a/libpurple/keyring.c b/libpurple/keyring.c
--- a/libpurple/keyring.c
+++ b/libpurple/keyring.c
@@ -424,8 +424,6 @@ purple_keyring_set_inuse_check_error_cb(
 	name = purple_account_get_username(account);
 
 	if ((error != NULL) && (error->domain == PURPLE_KEYRING_ERROR)) {
-		tracker->error = error;
-
 		switch(error->code) {
 			case PURPLE_KEYRING_ERROR_NOCAP:
 				purple_debug_info("keyring",
@@ -446,6 +444,7 @@ purple_keyring_set_inuse_check_error_cb(
 					"Failed to communicate with backend while changing keyring for account %s: %s. Aborting changes.\n",
 					name, error->message);
 				tracker->abort = TRUE;
+				tracker->error = error;
 				break;
 
 			default:
@@ -453,6 +452,7 @@ purple_keyring_set_inuse_check_error_cb(
 					"Unknown error while changing keyring for account %s: %s. Aborting changes.\n",
 					name, error->message);
 				tracker->abort = TRUE;
+				tracker->error = error;
 				break;
 		}
 	}
@@ -472,8 +472,6 @@ purple_keyring_set_inuse_check_error_cb(
 			purple_debug_error("keyring",
 				"Failed to change keyring, aborting.\n");
 
-			purple_notify_error(NULL, _("Keyrings"), _("Failed to change the keyring."),
-				_("Aborting changes."));
 			purple_keyring_inuse = tracker->old;
 			purple_prefs_disconnect_callback(purple_keyring_pref_cb_id);
 			purple_prefs_set_string("/purple/keyring/active",
@@ -491,7 +489,7 @@ purple_keyring_set_inuse_check_error_cb(
 			purple_debug_info("keyring", "Successfully changed keyring.\n");
 
 			if (tracker->cb != NULL)
-				tracker->cb(tracker->new, TRUE, error, tracker->data);
+				tracker->cb(tracker->new, TRUE, NULL, tracker->data);
 		}
 
 		g_free(tracker);
@@ -565,11 +563,20 @@ purple_keyring_set_inuse(const PurpleKey
 	PurpleKeyringClose close;
 	PurpleKeyringChangeTracker *tracker;
 
+	oldkeyring = purple_keyring_get_inuse();
+
+	if (oldkeyring == newkeyring) {
+		purple_debug_misc("keyring",
+			"Old and new keyring are the same: %s.\n",
+			(newkeyring != NULL) ? newkeyring->id : "(null)");
+		if (cb != NULL)
+			cb(newkeyring, TRUE, NULL, data);
+		return;
+	}
+
 	purple_debug_info("keyring", "Attempting to set new keyring: %s.\n",
 		(newkeyring != NULL) ? newkeyring->id : "(null)");
 
-	oldkeyring = purple_keyring_get_inuse();
-
 	if (oldkeyring != NULL) {
 		read = purple_keyring_get_read_password(oldkeyring);
 
diff --git a/libpurple/plugins/keyrings/internalkeyring.c b/libpurple/plugins/keyrings/internalkeyring.c
--- a/libpurple/plugins/keyrings/internalkeyring.c
+++ b/libpurple/plugins/keyrings/internalkeyring.c
@@ -1,9 +1,6 @@
 /**
  * @file internalkeyring.c internal keyring
  * @ingroup plugins
- *
- * @todo
- *   cleanup error handling and reporting
  */
 
 /* purple
diff --git a/libpurple/plugins/keyrings/kwallet.cpp b/libpurple/plugins/keyrings/kwallet.cpp
--- a/libpurple/plugins/keyrings/kwallet.cpp
+++ b/libpurple/plugins/keyrings/kwallet.cpp
@@ -1,9 +1,6 @@
 /**
  * @file kwallet.cpp KWallet password storage
  * @ingroup plugins
- *
- * @todo
- *   cleanup error handling and reporting
  */
 
 /* purple
diff --git a/pidgin/gtkprefs.c b/pidgin/gtkprefs.c
--- a/pidgin/gtkprefs.c
+++ b/pidgin/gtkprefs.c
@@ -111,6 +111,9 @@ static GtkWidget *prefs_conv_variants_co
 static GtkWidget *prefs_status_themes_combo_box;
 static GtkWidget *prefs_smiley_themes_combo_box;
 
+/* Keyrings page */
+static gpointer keyring_page_pref_set_instance = NULL;
+
 /* Sound theme specific */
 static GtkWidget *sound_entry = NULL;
 static int sound_row_sel = 0;
@@ -538,6 +541,8 @@ delete_prefs(GtkWidget *asdf, void *gdsa
 	prefs_status_themes_combo_box = NULL;
 	prefs_smiley_themes_combo_box = NULL;
 
+	keyring_page_pref_set_instance = NULL;
+
 	sample_webview = NULL;
 
 	notebook_page = 0;
@@ -2588,6 +2593,33 @@ change_master_password_cb(GtkWidget *but
 }
 
 static void
+keyring_page_pref_set_inuse(const PurpleKeyring *keyring, gboolean result,
+	GError *error, gpointer _combo_box)
+{
+	GtkComboBox *combo_box = _combo_box;
+	const PurpleKeyring *in_use = purple_keyring_get_inuse();
+
+	if (keyring_page_pref_set_instance != combo_box) {
+		purple_debug_info("gtkprefs", "pref window already closed\n");
+		return;
+	}
+	keyring_page_pref_set_instance = NULL;
+
+	gtk_widget_set_sensitive(GTK_WIDGET(combo_box), TRUE);
+
+	if (error != NULL) {
+		pidgin_prefs_dropdown_revert_active(combo_box);
+		purple_notify_error(NULL, _("Keyring"),
+			_("Failed to set new keyring"), error->message);
+		return;
+	}
+
+	g_return_if_fail(in_use != NULL);
+	purple_prefs_set_string("/purple/keyring/active",
+		purple_keyring_get_id(in_use));
+}
+
+static void
 keyring_page_pref_changed(GtkComboBox *combo_box, PidginPrefValue value)
 {
 	const char *keyring_id;
@@ -2609,7 +2641,11 @@ keyring_page_pref_changed(GtkComboBox *c
 		return;
 	}
 
-	purple_prefs_set_string("/purple/keyring/active", keyring_id);
+	gtk_widget_set_sensitive(GTK_WIDGET(combo_box), FALSE);
+
+	keyring_page_pref_set_instance = combo_box;
+	purple_keyring_set_inuse(keyring, FALSE, keyring_page_pref_set_inuse,
+		combo_box);
 
 	if (purple_keyring_get_change_master(keyring))
 		gtk_widget_set_sensitive(change_master_button, TRUE);
@@ -2638,7 +2674,7 @@ keyring_page(void)
 	/* Change master password */
 	button = gtk_button_new_with_mnemonic(_("_Change master password."));
 
-	/*  Keyring selection */
+	/* Keyring selection */
 	vbox = pidgin_make_frame(ret, _("Keyring"));
 	names = purple_keyring_get_options();
 	initial.type = PURPLE_PREF_STRING;



More information about the Commits mailing list