soc.2008.masterpassword: e5468291: Fixed a bunch of bugs/errors, worked on ..

scrouaf at soc.pidgin.im scrouaf at soc.pidgin.im
Sun Aug 10 21:11:17 EDT 2008


-----------------------------------------------------------------
Revision: e5468291c93e8b3eaabc5045630392afc3e6bc51
Ancestor: d2fecdd676d4493f84d3ed47afd31fd3ea041774
Author: scrouaf at soc.pidgin.im
Date: 2008-08-11T00:47:08
Branch: im.pidgin.soc.2008.masterpassword
URL: http://d.pidgin.im/viewmtn/revision/info/e5468291c93e8b3eaabc5045630392afc3e6bc51

Deleted entries:
        libpurple/keyring_info.txt
Modified files:
        libpurple/account.c libpurple/account.h
        libpurple/connection.c libpurple/keyring.c
        libpurple/keyring.h libpurple/plugins/Makefile.am
        libpurple/plugins/internalkeyring.c pidgin/gtkaccount.c
        pidgin/gtkprefs.c

ChangeLog: 

Fixed a bunch of bugs/errors, worked on making calls async, on configuration UI, and on Makefiles.

-------------- next part --------------
============================================================
--- libpurple/account.c	ecd0c062522ecdf0aa7f913f4bd091409d7274f6
+++ libpurple/account.c	1a94bf3b6d2a29e838255e3fd3c420c9abcb68c2
@@ -95,6 +95,15 @@ static void set_current_error(PurpleAcco
 static void set_current_error(PurpleAccount *account,
 	PurpleConnectionErrorInfo *new_err);
 
+static void purple_account_register_got_password_cb(PurpleAccount * account, 
+	char * password, GError * error, gpointer data);
+
+
+static void purple_account_unregister_got_password_cb(PurpleAccount * account,
+	char * password, GError * error, gpointer data);
+
+static void purple_account_connect_got_password_cb(const PurpleAccount * account,
+       gchar * password, GError * error, gpointer data);
 /*********************************************************************
  * Writing to disk                                                   *
  *********************************************************************/
@@ -792,8 +801,8 @@ parse_account(xmlnode *node)
 	xmlnode *child;
 	char *protocol_id = NULL;
 	char *name = NULL;
-	char *keyring_id = NULL;
-	char *mode = NULL;
+	const char *keyring_id = NULL;
+	const char *mode = NULL;
 	char *data = NULL;
 	gboolean result;
 	GError * error = NULL;
@@ -1079,21 +1088,59 @@ purple_account_register(PurpleAccount *a
 	purple_debug_info("account", "Registering account %s\n",
 					purple_account_get_username(account));
 
-	purple_connection_new(account, TRUE, purple_account_get_password(account));
+	purple_keyring_get_password_async(account, purple_account_register_got_password_cb, NULL);
 }
 
+
+static void
+purple_account_register_got_password_cb(PurpleAccount * account, char * password, GError * error, gpointer data)
+{
+	g_return_if_fail(account != NULL);
+
+	/* FIXME : handle error properly */
+
+	purple_connection_new(account, TRUE, password);
+}
+
+struct _unregister_data
+{
+	PurpleAccountUnregistrationCb cb;
+	void *user_data;
+};
+
 void
 purple_account_unregister(PurpleAccount *account, PurpleAccountUnregistrationCb cb, void *user_data)
 {
+	struct _unregister_data * data;
+
 	g_return_if_fail(account != NULL);
 
 	purple_debug_info("account", "Unregistering account %s\n",
 					  purple_account_get_username(account));
 
-	purple_connection_new_unregister(account, purple_account_get_password(account), cb, user_data);
+	data = g_malloc(sizeof(struct _unregister_data));
+	data->cb = cb;
+	data->user_data = user_data;
+
+	purple_keyring_get_password_async(account, purple_account_unregister_got_password_cb, data);
+
 }
 
 static void
+purple_account_unregister_got_password_cb(PurpleAccount * account, char * password, GError * error, gpointer data)
+{
+	struct _unregister_data * unregdata;
+
+	g_return_if_fail(account != NULL);
+
+	/* FIXME : handle error properly */
+
+	unregdata = data;
+	purple_connection_new_unregister(account, password, unregdata->cb, unregdata->user_data);
+}
+
+
+static void
 request_password_ok_cb(PurpleAccount *account, PurpleRequestFields *fields)
 {
 	const char *entry;
@@ -1193,7 +1240,20 @@ purple_account_connect(PurpleAccount *ac
 	}
 
 	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
-	password = purple_account_get_password(account);
+	purple_keyring_get_password_async(account, purple_account_connect_got_password_cb, prpl_info);
+
+}
+
+static void
+purple_account_connect_got_password_cb(const PurpleAccount * account,
+				       gchar * password,
+				       GError * error,
+				       gpointer data)
+{
+	PurplePluginProtocolInfo *prpl_info;
+
+	prpl_info = data;
+
 	if ((password == NULL) &&
 		!(prpl_info->options & OPT_PROTO_NO_PASSWORD) &&
 		!(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL))
@@ -1955,6 +2015,16 @@ purple_account_get_password(const Purple
 	}
 }
 
+void
+purple_account_get_password_async(PurpleAccount * account,
+				  PurpleKeyringReadCallback cb,
+				  gpointer data)
+{
+	purple_keyring_get_password_async(account, cb, data);
+}
+
+
+
 const char *
 purple_account_get_alias(const PurpleAccount *account)
 {
============================================================
--- libpurple/account.h	c58af3eec1c7ad35377ffe5bd10428ac67e30af7
+++ libpurple/account.h	78a50d84e465cd484a06ddd56de6abe839742278
@@ -46,6 +46,7 @@ typedef void (*PurpleAccountUnregistrati
 #include "proxy.h"
 #include "prpl.h"
 #include "status.h"
+#include "keyring.h"
 
 /**
  * Account request types.
@@ -549,7 +550,7 @@ const char *purple_account_get_username(
 const char *purple_account_get_username(const PurpleAccount *account);
 
 /**
- * Returns the account's password.
+ * Returns the account's password (deprecated, use async code instead).
  *
  * @param account The account.
  *
@@ -557,7 +558,18 @@ const char *purple_account_get_password(
  */
 const char *purple_account_get_password(const PurpleAccount *account);
 
+
 /**
+ * Reads the password for the account and passes it to the callback
+ *
+ * @param account The account to read the password for.
+ * @param cb The callback to pass the password to.
+ * @param data A pointer passed to the callback.
+ */
+void purple_account_get_password_async(PurpleAccount * account, 
+	PurpleKeyringReadCallback cb, gpointer data);
+
+/**
  * Returns the account's alias.
  *
  * @param account The account.
============================================================
--- libpurple/connection.c	99d100199ff71455d6a80af4dbfb7226e5ae2fb1
+++ libpurple/connection.c	b461e573c91d8c699019969ea9a80e586358715d
@@ -39,6 +39,8 @@
 #include "util.h"
 
 #define KEEPALIVE_INTERVAL 30
+static void purple_connection_disconnect_got_pw_cb(PurpleAccount * account,
+       gchar * password, GError * error, gpointer data);
 
 static GList *connections = NULL;
 static GList *connections_connecting = NULL;
@@ -483,13 +485,25 @@ purple_connection_disconnect_cb(gpointer
 purple_connection_disconnect_cb(gpointer data)
 {
 	PurpleAccount *account = data;
-	char *password = g_strdup(purple_account_get_password(account));
-	purple_account_disconnect(account);
-	purple_account_set_password(account, password);
-	g_free(password);
+	purple_account_get_password_async(account, 
+		purple_connection_disconnect_got_pw_cb, NULL);
+
 	return FALSE;
 }
 
+static void
+purple_connection_disconnect_got_pw_cb(PurpleAccount * account,
+				       gchar * password,
+				       GError * error,
+				       gpointer data)
+{
+	/* FIXME : handle error */
+	char * pw = g_strdup(password);
+
+	purple_account_disconnect(account);
+	purple_account_set_password(account, pw);
+}
+
 void
 purple_connection_error(PurpleConnection *gc, const char *text)
 {
============================================================
--- libpurple/keyring.c	5cb004775a3a4bf0bd124f73643b9fbcd16f76c8
+++ libpurple/keyring.c	fa918cf8a827cdf18864523c77e017ad84984aab
@@ -1,9 +1,8 @@
 /**
  * @file keyring.c Keyring plugin API
  * @todo
- *  - purple_keyring_set_inuse()
+ *  - purple_keyring_()
  *  - loading : find a way to fallback
- *  - purple_keyring_drop()
  */
 
 /* purple
@@ -42,7 +41,8 @@ struct _PurpleKeyring
 
 struct _PurpleKeyring
 {
-	char * name;		// same as plugin id
+	char * name;		// a user friendly name
+	char * id;		// same as plugin id
 	PurpleKeyringRead read_password;
 	PurpleKeyringSave save_password;
 	PurpleKeyringClose close_keyring;
@@ -81,6 +81,14 @@ purple_keyring_get_name(const PurpleKeyr
 	return keyring->name;
 }
 
+const char * 
+purple_keyring_get_id(const PurpleKeyring * keyring)
+{
+	g_return_val_if_fail(keyring != NULL, NULL);
+
+	return keyring->id;
+}
+
 PurpleKeyringRead 
 purple_keyring_get_read_password(const PurpleKeyring * keyring)
 {
@@ -156,6 +164,17 @@ purple_keyring_set_name(PurpleKeyring * 
 	return;
 }
 
+void 
+purple_keyring_set_id(PurpleKeyring * keyring, char * id)
+{
+	g_return_if_fail(keyring != NULL);
+
+	g_free(keyring->id);
+	keyring->id = g_strdup(id);
+
+	return;
+}
+
 void
 purple_keyring_set_read_password(PurpleKeyring * keyring, PurpleKeyringRead read)
 {
@@ -257,8 +276,6 @@ purple_keyring_init()
 	PurpleCore * core;
 	const char * touse;
 
-	purple_debug_info("keyring", "keyring_it");
-
 	/* Make sure we don't have junk */
 	purple_keyring_keyrings = NULL;
 	purple_keyring_inuse = NULL;
@@ -269,20 +286,26 @@ purple_keyring_init()
 	purple_signal_register(core, "keyring-register",
 		purple_marshal_VOID__POINTER_POINTER, 
 		NULL, 2,
-		purple_value_new(PURPLE_TYPE_STRING),			/* keyring name */
+		purple_value_new(PURPLE_TYPE_STRING),			/* keyring ID */
 		purple_value_new(PURPLE_TYPE_BOXED, "PurpleKeyring *")); /* a pointer to the keyring */
 
 	purple_signal_register(core, "keyring-unregister",
 		purple_marshal_VOID__POINTER_POINTER, 
 		NULL, 2,
-		purple_value_new(PURPLE_TYPE_STRING),			/* keyring name */
+		purple_value_new(PURPLE_TYPE_STRING),			/* keyring ID */
 		purple_value_new(PURPLE_TYPE_BOXED, "PurpleKeyring *")); /* a pointer to the keyring */
 
 	/* see what keyring we want to use */
-	touse = purple_prefs_get_string("active-keyring");
 
+	purple_prefs_add_string("/purple/keyring/active", "txt");
+	purple_prefs_connect_callback(NULL, "/purple/keyring/active",
+				purple_keyring_pref_cb, NULL);
+
+
+	touse = purple_prefs_get_string("/purple/keyring/active");
+
 	if (touse == NULL) {
-
+		purple_prefs_add_string("/purple/keyring/active", FALLBACK_KEYRING);
 		purple_keyring_to_use = g_strdup(FALLBACK_KEYRING);
 
 	} else {
@@ -290,6 +313,12 @@ purple_keyring_init()
 		purple_keyring_to_use = g_strdup(touse);
 	}
 
+	purple_prefs_connect_callback(NULL, "/purple/keyring/active",
+				purple_keyring_pref_cb, NULL);
+
+	purple_debug_info("keyring", "purple_keyring_init() done, selected keyring is : %s.\n",
+		purple_keyring_to_use);
+
 	return;
 }
 
@@ -297,6 +326,7 @@ purple_keyring_uninit()
 purple_keyring_uninit()
 {
 	g_free(purple_keyring_to_use);
+	purple_debug_info("keyring", "purple_keyring_uninit() done.\n");
 }
 
 static PurpleKeyring *
@@ -304,13 +334,13 @@ purple_keyring_find_keyring_by_id(char *
 {
 	GList * l;
 	PurpleKeyring * keyring;
-	const char * name;
+	const char * curr_id;
 
 	for (l = purple_keyring_keyrings; l != NULL; l = l->next) {
 		keyring = l->data;
-		name = purple_keyring_get_name(keyring);
+		curr_id = purple_keyring_get_id(keyring);
 
-		if (g_strcmp0(id, name) == 0)
+		if (g_strcmp0(id, curr_id) == 0)
 			return keyring;
 	}
 
@@ -505,62 +535,62 @@ purple_keyring_set_inuse(const PurpleKey
 	struct _PurpleKeyringChangeTracker * tracker;
 	GError * error = NULL; 
 
-	purple_debug_info("keyring", "changing in use keyring\n");
+	purple_debug_info("keyring", "Attempting to set new keyring : %s.\n",
+		newkeyring->id);
 
 	oldkeyring = purple_keyring_get_inuse();
 
-	if (oldkeyring != NULL)
+	if (oldkeyring != NULL) {
 		read = purple_keyring_get_read_password(oldkeyring);
 
-	if (read == NULL) {
-		error = g_error_new(ERR_PIDGINKEYRING , ERR_NOCAP,
-			"Existing keyring cannot read passwords");
-		g_debug("Existing keyring cannot read passwords");
+		if (read == NULL) {
+			error = g_error_new(ERR_PIDGINKEYRING , ERR_NOCAP,
+				"Existing keyring cannot read passwords");
+			g_debug("Existing keyring cannot read passwords");
 
-		/* at this point, we know the keyring won't let us
-		 * read passwords, so there no point in copying them.
-		 * therefore we just cleanup the old and setup the new 
-		 * one later.
-		 */
+			/* at this point, we know the keyring won't let us
+			 * read passwords, so there no point in copying them.
+			 * therefore we just cleanup the old and setup the new 
+			 * one later.
+			 */
 
-		purple_keyring_drop_passwords(newkeyring);
+			purple_keyring_drop_passwords(oldkeyring);
 
-		close = purple_keyring_get_close_keyring(oldkeyring);
+			close = purple_keyring_get_close_keyring(oldkeyring);
 
-		if (close != NULL)
-			close(NULL);	/* we can't do much about errors at this point*/
+			if (close != NULL)
+				close(NULL);	/* we can't do much about errors at this point*/
 
-	}
+		} else {
+			tracker = g_malloc(sizeof(struct _PurpleKeyringChangeTracker));
+			oldkeyring = purple_keyring_get_inuse();
 
-	if (purple_keyring_inuse != NULL && read != NULL) {
+			tracker->cb = cb;
+			tracker->data = data;
+			tracker->new = newkeyring;
+			tracker->old = oldkeyring;
+			tracker->read_outstanding = 0;
+			tracker->finished = FALSE;
+			tracker->abort = FALSE;
+			tracker->force = force;
+			tracker->error = NULL;
 
-		tracker = g_malloc(sizeof(struct _PurpleKeyringChangeTracker));
-		oldkeyring = purple_keyring_get_inuse();
+			for (cur = purple_accounts_get_all(); 
+			    (cur != NULL) && (tracker->abort == FALSE);
+			    cur = cur->next) {
 
-		tracker->cb = cb;
-		tracker->data = data;
-		tracker->new = newkeyring;
-		tracker->old = oldkeyring;
-		tracker->read_outstanding = 0;
-		tracker->finished = FALSE;
-		tracker->abort = FALSE;
-		tracker->force = force;
-		tracker->error = NULL;
+				tracker->read_outstanding++;
 
-		for (cur = purple_accounts_get_all(); 
-		    (cur != NULL) && (tracker->abort == FALSE);
-		    cur = cur->next)
-		{
-			tracker->read_outstanding++;
+				if (cur->next == NULL)
+					tracker->finished = TRUE;
 
-			if (cur->next == NULL)
-				tracker->finished = TRUE;
-
-			read(cur->data, purple_keyring_set_inuse_got_pw_cb, tracker);
+				read(cur->data, purple_keyring_set_inuse_got_pw_cb, tracker);
+			}
 		}
 
 	} else { /* no keyring was set before. */
-		purple_debug_info("keyring", "setting keyring for the first time\n");
+		purple_debug_info("keyring", "Setting keyring for the first time : %s.\n",
+			newkeyring->id);
 		purple_keyring_inuse = newkeyring;
 
 		if (cb != NULL)
@@ -571,24 +601,89 @@ purple_keyring_set_inuse(const PurpleKey
 }
 
 
+
 void 
+purple_keyring_pref_cb(const char *pref,
+		       PurplePrefType type,
+		       gconstpointer id,
+		       gpointer data)
+{
+	PurpleKeyring * new;
+
+	g_return_if_fail(g_strcmp0(pref, "/purple/keyring/active") == 0);
+	g_return_if_fail(type == PURPLE_PREF_STRING);
+	g_return_if_fail(id != NULL);
+
+	new = purple_keyring_get_keyring_by_id(id);
+	g_return_if_fail(new != NULL);
+
+	purple_keyring_set_inuse(new, FALSE, /* XXX */NULL, data);	/* FIXME This should have a callback that can cancel the action */
+
+	return;
+}
+
+GList *
+purple_keyring_get_options()
+{
+	const GList * keyrings;
+	PurpleKeyring * keyring;
+	static GList * list = NULL;
+
+	for (keyrings = purple_keyring_get_keyrings();
+	     keyrings != NULL;
+	     keyrings = keyrings->next) {
+
+		keyring = keyrings->data;
+		list = g_list_append(list, keyring->name);
+		list = g_list_append(list, keyring->id);
+	}
+
+	return list;
+}
+
+PurpleKeyring *
+purple_keyring_get_keyring_by_id(const char * id)
+{
+	const GList * keyrings;
+	PurpleKeyring * keyring;
+
+	for (keyrings = purple_keyring_get_keyrings();
+	     keyrings != NULL;
+	     keyrings = keyrings->next) {
+
+		keyring = keyrings->data;
+		if (g_strcmp0(id, keyring->id) == 0)
+			return keyring;
+
+	}
+	return NULL;
+}
+
+
+
+void 
 purple_keyring_register(PurpleKeyring * keyring)
 {
 	const char * keyring_id;
 	PurpleCore * core;
 
-	purple_debug_info("keyring", "registering keyring.\n");
 	g_return_if_fail(keyring != NULL);
 	
-	keyring_id = purple_keyring_get_name(keyring);
+	keyring_id = purple_keyring_get_id(keyring);
 
-	/* keyring with no name. Add error handling ? */
+	/* keyring with no ID. Add error handling ? */
 	g_return_if_fail(keyring_id != NULL);
 
+
+	purple_debug_info("keyring", "Registering keyring : %s\n",
+		keyring->id);
+
 	/* If this is the configured keyring, use it. */
 	if (purple_keyring_inuse == NULL &&
 	    g_strcmp0(keyring_id, purple_keyring_to_use) == 0) {
 
+		purple_debug_info("keyring", "Keyring %s matches keyring to use, using it.\n",
+			keyring->id);
 		/** @todo add callback to make sure all is ok */
 		purple_keyring_set_inuse(keyring, TRUE, NULL, NULL);
 
@@ -613,7 +708,7 @@ purple_keyring_unregister(PurpleKeyring 
 	const char * keyring_id;
 
 	core = purple_get_core();
-	keyring_id = purple_keyring_get_name(keyring);
+	keyring_id = purple_keyring_get_id(keyring);
 	purple_signal_emit(core, "keyring-unregister", keyring_id, keyring);
 
 	inuse = purple_keyring_get_inuse();
@@ -627,6 +722,8 @@ purple_keyring_unregister(PurpleKeyring 
 
 	purple_keyring_keyrings = g_list_remove(purple_keyring_keyrings,
 		keyring);
+
+	purple_debug_info("keyring", "Keyring %s unregistered", keyring->id);
 }
 
 
@@ -650,18 +747,21 @@ purple_keyring_import_password(PurpleAcc
 	PurpleKeyringImportPassword import;
 	const char * realid;
 
-	purple_debug_info("keyring", "importing password.\n");
+	purple_debug_info("keyring", "Importing password for account %s (%s).\n",
+		purple_account_get_username(account), purple_account_get_protocol_id(account));
 
 	inuse = purple_keyring_get_inuse();
 
 	if (inuse == NULL) {
 		*error = g_error_new(ERR_PIDGINKEYRING , ERR_NOKEYRING,
 			"No keyring configured, cannot import password info");
-		g_debug("No keyring configured, cannot import password info");
+		purple_debug_info("Keyring", 
+			"No keyring configured, cannot import password info for account %s (%s).\n",
+			purple_account_get_username(account), purple_account_get_protocol_id(account));
 		return FALSE;
 	}
 
-	realid = purple_keyring_get_name(inuse);
+	realid = purple_keyring_get_id(inuse);
 	/*
 	 * we want to be sure that either :
 	 *  - there is a keyringid specified and it matches the one configured
@@ -671,7 +771,8 @@ purple_keyring_import_password(PurpleAcc
 	    g_strcmp0(FALLBACK_KEYRING, realid)) {
 		*error = g_error_new(ERR_PIDGINKEYRING , ERR_INVALID,
 			"Specified keyring id does not match the configured one.");
-		g_debug("Specified keyring id does not match the configured one.");
+		purple_debug_info("keyring",
+			"Specified keyring id does not match the configured one. Data will be lost.");
 		return FALSE;
 	}
 
@@ -679,7 +780,7 @@ purple_keyring_import_password(PurpleAcc
 	if (import == NULL) {
 		*error = g_error_new(ERR_PIDGINKEYRING , ERR_NOCAP,
 			"Keyring cannot import password info.");
-		g_debug("Keyring cannot import password info. This might be normal");
+		purple_debug_info("Keyring", "Configured keyring cannot import password info. This might be normal.");
 		return FALSE;
 	}
 	
@@ -705,10 +806,10 @@ purple_keyring_export_password(PurpleAcc
 		*error = g_error_new(ERR_PIDGINKEYRING , ERR_NOKEYRING,
 			"No keyring configured, cannot import password info");
 		g_debug("No keyring configured, cannot import password info");
-		return;
+		return FALSE;
 	}
 
-	*keyringid = purple_keyring_get_name(inuse);
+	*keyringid = purple_keyring_get_id(inuse);
 
 	if (*keyringid == NULL) {
 		*error = g_error_new(ERR_PIDGINKEYRING , ERR_INVALID,
@@ -735,7 +836,7 @@ void 
  * to 3.0, while dropping purple_keyring_get_password_sync().
  */
 void 
-purple_keyring_get_password_async(const PurpleAccount * account,
+purple_keyring_get_password_async(PurpleAccount * account,
 				  PurpleKeyringReadCallback cb,
 				  gpointer data)
 {
============================================================
--- libpurple/keyring.h	46bd6836ecc1f9d53d4d505e3314f3577f86a602
+++ libpurple/keyring.h	7c9a3afbd3f7e05d76cf1cc711f4219cb6234b8e
@@ -216,6 +216,15 @@ typedef gboolean (*PurpleKeyringExportPa
 /***************************************/
 /*@{*/
 
+PurpleKeyring *
+purple_keyring_get_keyring_by_id(const char * id);
+GList *
+purple_keyring_get_options(void);
+void 
+purple_keyring_pref_cb(const char *pref,
+		       PurplePrefType type,
+		       gconstpointer name,
+		       gpointer data);
 /**
  * Prepare stuff at startup.
  */
@@ -336,7 +345,7 @@ void 
  * @param data A pointer passed to the callback.
  */
 void 
-purple_keyring_get_password_async(const PurpleAccount * account,
+purple_keyring_get_password_async(PurpleAccount * account,
 				  PurpleKeyringReadCallback cb,
 				  gpointer data);
 
@@ -409,6 +418,7 @@ const char * purple_keyring_get_name(con
 void purple_keyring_free(PurpleKeyring * keyring);
 
 const char * purple_keyring_get_name(const PurpleKeyring * info);
+const char * purple_keyring_get_id(const PurpleKeyring * info);
 PurpleKeyringRead purple_keyring_get_read_password(const PurpleKeyring * info);
 PurpleKeyringSave purple_keyring_get_save_password(const PurpleKeyring * info);
 PurpleKeyringReadSync purple_keyring_get_read_sync(const PurpleKeyring * info);
@@ -418,7 +428,8 @@ PurpleKeyringExportPassword purple_keyri
 PurpleKeyringImportPassword purple_keyring_get_import_password(const PurpleKeyring * info);
 PurpleKeyringExportPassword purple_keyring_get_export_password(const PurpleKeyring * info);
 
-void purple_keyring_set_name(PurpleKeyring * info, char * name);		/* must be static, will not be auto-freed upon destruction */
+void purple_keyring_set_name(PurpleKeyring * info, char * name);
+void purple_keyring_set_id(PurpleKeyring * info, char * id);
 void purple_keyring_set_read_sync(PurpleKeyring * info, PurpleKeyringReadSync read);
 void purple_keyring_set_save_sync(PurpleKeyring * info, PurpleKeyringSaveSync save);
 void purple_keyring_set_read_password(PurpleKeyring * info, PurpleKeyringRead read);
@@ -441,7 +452,7 @@ void purple_keyring_set_export_password(
  */
 #define ERR_PIDGINKEYRING 	purple_keyring_error_domain()
 /** stuff here too */
-GQuark purple_keyring_error_domain();
+GQuark purple_keyring_error_domain(void);
 
 /** error codes for keyrings. */
 enum PurpleKeyringError
============================================================
--- libpurple/plugins/Makefile.am	673854bbe73470144a8d7e61c18c62c230e74ab5
+++ libpurple/plugins/Makefile.am	734c1c75bbd85b817ce930c0e5e187bcb8a805d1
@@ -1,4 +1,4 @@
-DIST_SUBDIRS = mono perl ssl tcl
+DIST_SUBDIRS = mono perl ssl tcl keyrings
 
 if USE_PERL
 PERL_DIR = perl
@@ -20,7 +20,8 @@ SUBDIRS = \
 	$(MONO_DIR) \
 	$(PERL_DIR) \
 	ssl \
-	$(TCL_DIR)
+	$(TCL_DIR) \
+	keyrings
 
 plugindir = $(libdir)/purple-$(PURPLE_MAJOR_VERSION)
 
============================================================
--- libpurple/plugins/internalkeyring.c	ebc914dcfffeaeea37b0af97eed0e19739a7f9fd
+++ libpurple/plugins/internalkeyring.c	d6f5ea559eb568dac11ec0b224ad0ba744e5d7d1
@@ -1,6 +1,6 @@
 /**
  * @file internalkeyring.c internal keyring
- * @ingroup core
+ * @ingroup plugins
  *
  * @todo 
  *   cleanup error handling and reporting
@@ -51,11 +51,11 @@
 #include "debug.h"
 #include "plugin.h"
 
-#define KEYRINGNAME			FALLBACK_KEYRING
+#define INTERNALKEYRING_NAME		"Internal keyring"
 #define INTERNALKEYRING_VERSION		"0.7"
 #define INTERNALKEYRING_DESCRIPTION	"This plugin provides the default password storage behaviour for libpurple."
 #define	INTERNALKEYRING_AUTHOR		"Scrouaf (scrouaf[at]soc.pidgin.im)"
-#define INTERNALKEYRING_ID		"core-internalkeyring-scrouaf"
+#define INTERNALKEYRING_ID		FALLBACK_KEYRING
 
 
 #define GET_PASSWORD(account) \
@@ -211,7 +211,8 @@ internal_keyring_init()
 {
 	keyring_handler = purple_keyring_new();
 
-	purple_keyring_set_name(keyring_handler, KEYRINGNAME);
+	purple_keyring_set_name(keyring_handler, INTERNALKEYRING_NAME);
+	purple_keyring_set_id(keyring_handler, INTERNALKEYRING_ID);
 	purple_keyring_set_read_sync(keyring_handler, internal_keyring_read_sync);
 	purple_keyring_set_save_sync(keyring_handler, internal_keyring_save_sync);
 	purple_keyring_set_read_password(keyring_handler, internal_keyring_read);
@@ -274,7 +275,7 @@ PurplePluginInfo plugininfo =
 	NULL,								/* dependencies */
 	PURPLE_PRIORITY_DEFAULT,					/* priority */
 	INTERNALKEYRING_ID,						/* id */
-	"internal-keyring",						/* name */
+	INTERNALKEYRING_NAME,						/* name */
 	INTERNALKEYRING_VERSION,					/* version */
 	"Internal Keyring Plugin",					/* summary */
 	INTERNALKEYRING_DESCRIPTION,					/* description */
============================================================
--- pidgin/gtkaccount.c	8caa4630fc4d3a0b432393c8955edb27408a2931
+++ pidgin/gtkaccount.c	6d89a8287020c65fde0164a38fc76d0390215c37
@@ -402,6 +402,7 @@ add_login_options(AccountPrefsDialog *di
 	GList *user_splits;
 	GList *l, *l2;
 	char *username = NULL;
+	char *password = NULL;
 
 	if (dialog->protocol_menu != NULL)
 	{
@@ -561,10 +562,11 @@ add_login_options(AccountPrefsDialog *di
 
 	/* Set the fields. */
 	if (dialog->account != NULL) {
-		if (purple_account_get_password(dialog->account))
-			gtk_entry_set_text(GTK_ENTRY(dialog->password_entry),
-							   purple_account_get_password(dialog->account));
+		password = purple_account_get_password(dialog->account);
 
+		if (password)
+			gtk_entry_set_text(GTK_ENTRY(dialog->password_entry), password);
+
 		gtk_toggle_button_set_active(
 				GTK_TOGGLE_BUTTON(dialog->remember_pass_check),
 				purple_account_get_remember_password(dialog->account));
============================================================
--- pidgin/gtkprefs.c	8c2ed56087f9959d97b13d6ad5242001cb5256ac
+++ pidgin/gtkprefs.c	6bbd4830d17cc896eeba0ea1e521a7f8ed8ca03a
@@ -37,6 +37,7 @@
 #include "sound.h"
 #include "util.h"
 #include "network.h"
+#include "keyring.h"
 
 #include "gtkblist.h"
 #include "gtkconv.h"
@@ -1631,6 +1632,37 @@ logging_page(void)
 	return ret;
 }
 
+
+static GtkWidget *
+keyring_page(void)
+{
+	GtkWidget *ret;
+	GtkWidget *vbox;
+	GtkWidget *menu;
+	GtkWidget *changemaster;
+	GList *names;
+
+
+	purple_debug_info("prefs", "drawing keyring prefs page");
+	ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
+	gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER);
+
+
+	vbox = pidgin_make_frame (ret, _("Keyring"));
+
+	names = purple_keyring_get_options();
+
+	pidgin_prefs_dropdown_from_list(vbox, _("Keyring"), PURPLE_PREF_STRING,
+				 "/purple/keyring/active", names);
+
+	g_list_free(names);
+
+
+	gtk_widget_show_all(ret);
+
+	return ret;
+}
+
 #ifndef _WIN32
 static gint sound_cmd_yeah(GtkEntry *entry, gpointer d)
 {
@@ -2153,6 +2185,7 @@ static void prefs_notebook_init(void) {
 	}
 #endif
 	prefs_notebook_add_page(_("Logging"), logging_page(), notebook_page++);
+	prefs_notebook_add_page(_("Password Storage"), keyring_page(), notebook_page++);
 	prefs_notebook_add_page(_("Status / Idle"), away_page(), notebook_page++);
 }
 


More information about the Commits mailing list