/cpw/tomkiewicz/masterpassword: cdd4b0dfe92b: keyring.c refactor...

Tomasz Wasilczyk tomkiewicz at cpw.pidgin.im
Sun Apr 28 05:13:32 EDT 2013


Changeset: cdd4b0dfe92b154caf86b3c3896044c51b730a8c
Author:	 Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date:	 2013-04-28 11:13 +0200
Branch:	 soc.2008.masterpassword
URL: https://hg.pidgin.im/cpw/tomkiewicz/masterpassword/rev/cdd4b0dfe92b

Description:

keyring.c refactoring: use signal instead of hack depending on implementation

diffstat:

 libpurple/account.c |  10 ++++++++++
 libpurple/core.c    |   2 +-
 libpurple/keyring.c |  19 ++++++++-----------
 3 files changed, 19 insertions(+), 12 deletions(-)

diffs (75 lines):

diff --git a/libpurple/account.c b/libpurple/account.c
--- a/libpurple/account.c
+++ b/libpurple/account.c
@@ -2907,6 +2907,14 @@ connection_error_cb(PurpleConnection *gc
 	                   account, type, description);
 }
 
+static void
+password_migration_cb(PurpleAccount *account)
+{
+	g_return_if_fail(account != NULL);
+
+	schedule_accounts_save();
+}
+
 const PurpleConnectionErrorInfo *
 purple_account_get_current_error(PurpleAccount *account)
 {
@@ -3282,6 +3290,8 @@ purple_accounts_init(void)
 	                      PURPLE_CALLBACK(signed_off_cb), NULL);
 	purple_signal_connect(conn_handle, "connection-error", handle,
 	                      PURPLE_CALLBACK(connection_error_cb), NULL);
+	purple_signal_connect(purple_keyring_get_handle(), "password-migration", handle,
+	                      PURPLE_CALLBACK(password_migration_cb), NULL);
 
 	load_accounts();
 
diff --git a/libpurple/core.c b/libpurple/core.c
--- a/libpurple/core.c
+++ b/libpurple/core.c
@@ -152,7 +152,7 @@ purple_core_init(const char *ui)
 
 	purple_plugins_probe(G_MODULE_SUFFIX);
 
-	purple_keyring_init();
+	purple_keyring_init(); /* before accounts */
 	purple_theme_manager_init();
 
 	/* The buddy icon code uses the imgstore, so init it early. */
diff --git a/libpurple/keyring.c b/libpurple/keyring.c
--- a/libpurple/keyring.c
+++ b/libpurple/keyring.c
@@ -292,17 +292,8 @@ purple_keyring_set_inuse_save_cb(PurpleA
 			tracker->error = g_error_copy(error);
 	}
 
-	/**
-	 * This is kind of hackish. It will schedule an account save.
-	 *
-	 * Another way to do this would be to expose the
-	 * schedule_accounts_save() function, but other such functions
-	 * are not exposed. So these was done for consistency.
-	 *
-	 * TODO: put a signal here
-	 */
-	purple_account_set_remember_password(account,
-		purple_account_get_remember_password(account));
+	purple_signal_emit(purple_keyring_get_handle(), "password-migration",
+		account);
 
 	if (!tracker->finished || tracker->read_outstanding > 0)
 		return;
@@ -1194,6 +1185,12 @@ purple_keyring_init(void)
 		purple_value_new(PURPLE_TYPE_STRING),                    /* keyring ID */
 		purple_value_new(PURPLE_TYPE_BOXED, "PurpleKeyring *")); /* a pointer to the keyring */
 
+	purple_signal_register(purple_keyring_get_handle(),
+		"password-migration",
+		purple_marshal_VOID__POINTER,
+		NULL, 1,
+		purple_value_new(PURPLE_TYPE_BOXED, "PurpleAccount *")); /* a pointer to the account */
+
 	/* see what keyring we want to use */
 	touse = purple_prefs_get_string("/purple/keyring/active");
 



More information about the Commits mailing list