soc.2008.masterpassword: cb456867: Changed most of the account_get_password...

scrouaf at soc.pidgin.im scrouaf at soc.pidgin.im
Thu Aug 14 23:46:21 EDT 2008


-----------------------------------------------------------------
Revision: cb4568677518a721945328eca0cab9c071dd71b3
Ancestor: 2a854c62dce5b27dc247b6d3964050068533b629
Author: scrouaf at soc.pidgin.im
Date: 2008-08-15T03:39:45
Branch: im.pidgin.soc.2008.masterpassword
URL: http://d.pidgin.im/viewmtn/revision/info/cb4568677518a721945328eca0cab9c071dd71b3

Modified files:
        finch/gntaccount.c libpurple/account.c libpurple/account.h
        libpurple/connection.c libpurple/connection.h
        libpurple/example/nullclient.c libpurple/keyring.c
        libpurple/keyring.h
        libpurple/plugins/keyrings/gnomekeyring.c
        libpurple/protocols/gg/gg.c
        libpurple/protocols/jabber/auth.c
        libpurple/protocols/qq/qq_network.c
        libpurple/protocols/sametime/sametime.c
        libpurple/protocols/silc/silc.c libpurple/prpl.c
        pidgin/gtkaccount.c

ChangeLog: 

Changed most of the account_get_password() calls to the async function.
Remaining are : 
 - myspace.c that uses direct access to account->password
 - xmpp's auth.c that still has a few calls
 - and maybe a few others.
Changed a few set_password() as well.
Also, since purple_connection_get_password() accessed the password member
directly, I changed it to use the sync accessor, and wrote an async function.
Right now, only the silc prpl uses that async function, so more work there.

-------------- next part --------------
============================================================
--- finch/gntaccount.c	a3bb24a41e42468c1655425adb19bcde974c182d
+++ finch/gntaccount.c	db9f6a557df501b32bf6e187bc68b4c7821ba5d9
@@ -499,9 +499,6 @@ edit_account_continue(PurpleAccount * ac
 	GList *list, *iter;
 	AccountEditDialog *dialog;
 
-	if (error)
-		g_error_free(error);
-
 	if (account)
 	{
 		GList *iter;
============================================================
--- libpurple/account.c	5c5fb0c8a39b673058e891dc542f00e4b2593f08
+++ libpurple/account.c	a5e3bf543a269a3102833771b3d34a37596f6f03
@@ -807,8 +807,8 @@ parse_account(xmlnode *node)
 	xmlnode *child;
 	char *protocol_id = NULL;
 	char *name = NULL;
-	const char *keyring_id = NULL;
-	const char *mode = NULL;
+	char *keyring_id = NULL;
+	char *mode = NULL;
 	char *data = NULL;
 	gboolean result = FALSE;
 	GError * error = NULL;
@@ -1107,7 +1107,7 @@ purple_account_register_got_password_cb(
 	g_return_if_fail(account != NULL);
 
 	/* FIXME : handle error properly */
-
+ 
 	purple_connection_new(account, TRUE, password);
 }
 
@@ -1167,7 +1167,8 @@ request_password_ok_cb(PurpleAccount *ac
 	if(remember)
 		purple_account_set_remember_password(account, TRUE);
 
-	purple_account_set_password(account, entry);
+	/* XXX this might be a problem if a read occurs before the write is finished */
+	purple_account_set_password_async(account, g_strdup(entry), g_free, NULL, NULL);
 
 	purple_connection_new(account, FALSE, entry);
 }
@@ -1286,7 +1287,7 @@ purple_account_disconnect(PurpleAccount 
 	gc = purple_account_get_connection(account);
 	purple_connection_destroy(gc);
 	if (!purple_account_get_remember_password(account))
-		purple_account_set_password(account, NULL);
+		purple_account_set_password_async(account, NULL, NULL, NULL, NULL);
 	purple_account_set_connection(account, NULL);
 
 	account->disconnecting = FALSE;
@@ -1614,7 +1615,7 @@ purple_account_set_password(PurpleAccoun
 		account->password = g_strdup(password);
 
 	else
-		purple_keyring_set_password_sync(account, password);
+		purple_keyring_set_password_async(account, g_strdup(password), g_free, NULL, NULL);
 
 	schedule_accounts_save();
 }
@@ -2514,7 +2515,7 @@ purple_account_change_password(PurpleAcc
 	PurpleConnection *gc = purple_account_get_connection(account);
 	PurplePlugin *prpl = NULL;
 	
-	purple_account_set_password(account, new_pw);
+	purple_account_set_password_async(account, g_strdup(new_pw), g_free, NULL, NULL);
 	
 	if (gc != NULL)
 	        prpl = purple_connection_get_prpl(gc);      
============================================================
--- libpurple/account.h	09a9d48cd711d1fc47497ed0b3e71372caa84073
+++ libpurple/account.h	dbc81839d1ff72a772d742057890390cf188de03
@@ -328,7 +328,7 @@ void purple_account_set_username(PurpleA
  * @param account  The account.
  * @param password The password.
  */
-void purple_account_set_password(PurpleAccount *account, const char *password);
+void purple_account_set_password(PurpleAccount *account, const char *password)  __attribute__ ((deprecated));
 
 /**
  * Set a password to be remembered.
@@ -572,9 +572,8 @@ const char *purple_account_get_username(
  *
  * @return The password.
  */
-const char *purple_account_get_password(const PurpleAccount *account);
+const char *purple_account_get_password(const PurpleAccount *account)  __attribute__ ((deprecated));
 
-
 /**
  * Reads the password for the account and passes it to the callback
  *
============================================================
--- libpurple/connection.c	b461e573c91d8c699019969ea9a80e586358715d
+++ libpurple/connection.c	86690bfbdfe4d6bbb9bf7bf9fa7abec03ab67a9a
@@ -434,14 +434,34 @@ purple_connection_get_prpl(const PurpleC
 	return gc->prpl;
 }
 
+
+/**
+ * FIXME : all the calling tree needs to be async.
+ */
 const char *
 purple_connection_get_password(const PurpleConnection *gc)
 {
 	g_return_val_if_fail(gc != NULL, NULL);
 
-	return gc->password ? gc->password : gc->account->password;
+	return gc->password ? gc->password : purple_account_get_password(gc->account);
 }
 
+void
+purple_connection_get_password_async(PurpleConnection *gc, 
+				     PurpleKeyringReadCallback cb,
+				     gpointer data)
+{
+	char * password;
+	g_return_val_if_fail(gc != NULL, NULL);
+
+	if (gc->password != NULL) {
+		/* casted to prevent warning */
+		cb((PurpleAccount *)gc, gc->password, NULL, data);
+	} else {
+		purple_account_get_password_async(gc->account, cb, gc);
+	}
+}
+
 const char *
 purple_connection_get_display_name(const PurpleConnection *gc)
 {
@@ -501,7 +521,7 @@ purple_connection_disconnect_got_pw_cb(P
 	char * pw = g_strdup(password);
 
 	purple_account_disconnect(account);
-	purple_account_set_password(account, pw);
+	purple_account_set_password_async(account, g_strdup(pw), g_free, NULL, NULL);
 }
 
 void
============================================================
--- libpurple/connection.h	1bedab3e80682d43f51c28e7c6893169e597662a
+++ libpurple/connection.h	9cbb0460921eba42411d0987d9ed4be8177a2a14
@@ -144,6 +144,7 @@ typedef struct
 #include <time.h>
 
 #include "account.h"
+#include "keyring.h"
 #include "plugin.h"
 #include "status.h"
 #include "sslconn.h"
@@ -390,15 +391,26 @@ PurplePlugin * purple_connection_get_prp
 PurplePlugin * purple_connection_get_prpl(const PurpleConnection *gc);
 
 /**
- * Returns the connection's password.
+ * Returns the connection's password. Deprecated, use
+ * purple_connection_get_password_async() instead.
  *
  * @param gc The connection.
  *
  * @return The connection's password.
  */
-const char *purple_connection_get_password(const PurpleConnection *gc);
+const char *purple_connection_get_password(const PurpleConnection *gc) __attribute__ ((deprecated));
 
 /**
+ * Passes the connection's keyring to the callback.
+ *
+ * @param gc The connection.
+ * @param cb The callback to pass the password to.
+ * @param data A pointer passed to the callback.
+ */
+void
+purple_connection_get_password_async(PurpleConnection *gc, 
+	PurpleKeyringReadCallback cb, gpointer data);
+/**
  * Returns the connection's displayed name.
  *
  * @param gc The connection.
============================================================
--- libpurple/example/nullclient.c	587f78d7b0f0c1d170ac1eac35d526ca62efa8f8
+++ libpurple/example/nullclient.c	0c9214cbc29562b084d3ab3a80fbf58445cfdb40
@@ -295,7 +295,7 @@ int main(int argc, char *argv[])
 
 	/* Get the password for the account */
 	password = getpass("Password: ");
-	purple_account_set_password(account, password);
+	purple_account_set_password_async(account, g_strdup(password), g_free, NULL, NULL);
 
 	/* It's necessary to enable the account first. */
 	purple_account_set_enabled(account, UI_ID, TRUE);
============================================================
--- libpurple/keyring.c	db768cd667bccb5076353c9a519fa7159c3f6323
+++ libpurple/keyring.c	b818e89b24d41e4053eddab75d3c053a325f131d
@@ -1008,6 +1008,7 @@ purple_keyring_set_password_async(const 
 				g_error_free(error);
 
 			} else {
+				cbinfo = g_malloc(sizeof(PurpleKeyringCbInfo));
 				cbinfo->cb = cb;
 				cbinfo->data = data;
 				save(account, password, destroypassword,
============================================================
--- libpurple/keyring.h	b9f80e1f1dbac927b2cbef61e5b595b0a185cbdf
+++ libpurple/keyring.h	92683f2239191f94c9de4e3077bb3fa0bed905d0
@@ -325,18 +325,6 @@ purple_keyring_export_password(PurpleAcc
 			       GError ** error,
 			       GDestroyNotify * destroy);
 
-
-
-/** 
- * functions called from the code to access passwords (account.h):
- *	purple_account_get_password()
- *	purple_account_set_password()
- * @todo :
- *	- rewrite these functions to use the sync functions for compatibility,
- *	- build an async way to access the async functions, and patch all libpurple 
- *	code that calls the accessors to use new ones.
- */
-
 /**
  * Read a password from the active safe.
  * This should be renamed purple_keyring_get_password() when getting
============================================================
--- libpurple/plugins/keyrings/gnomekeyring.c	fc7c4c3ae33380eba0a5a5c885b872497fb631c9
+++ libpurple/plugins/keyrings/gnomekeyring.c	c5b8750e267af5ffaad947b07c4329c59ed7d7db
@@ -80,7 +80,7 @@ static void 		gkp_read(PurpleAccount *, 
 /* a few prototypes : */
 static GQuark 		gkp_error_domain(void);
 static void 		gkp_read(PurpleAccount *, PurpleKeyringReadCallback, gpointer);
-static void		gkp_read_continue(GnomeKeyringResult, const char *, gpointer);
+static void		gkp_read_continue(GnomeKeyringResult, char *, gpointer);
 static void 		gkp_save(PurpleAccount *, gchar *, GDestroyNotify, PurpleKeyringSaveCallback, gpointer);
 static void		gkp_save_continue(GnomeKeyringResult, gpointer);
 static const char * 	gkp_read_sync(const PurpleAccount *);
@@ -124,7 +124,7 @@ static void gkp_read_continue(GnomeKeyri
 }
 
 static void gkp_read_continue(GnomeKeyringResult result,
-                       const char *password,
+                       char *password,
                        gpointer data)
 /* XXX : make sure list is freed on return */
 {
============================================================
--- libpurple/protocols/gg/gg.c	3541ee65317e2d346e4e478792f99829dd6d2f26
+++ libpurple/protocols/gg/gg.c	2c7f14995fdb050d2c6b585d6aa3d17f62b33e81
@@ -676,12 +676,41 @@ static void ggp_find_buddies(PurplePlugi
 
 /* ----- CHANGE PASSWORD ------------------------------------------------ */
 
+typedef struct _ConnectionCallbackData
+{
+	PurpleConnection *gc;
+	PurpleRequestFields *fields;
+} ConnectionCallbackData;
+
+
 /*
  */
 /* static void ggp_callback_change_passwd_ok(PurpleConnection *gc, PurpleRequestFields *fields) {{{ */
+static void ggp_callback_change_passwd_ok_continue(PurpleAccount * account,
+	gchar * password, GError * error, gpointer user_data);
+
 static void ggp_callback_change_passwd_ok(PurpleConnection *gc, PurpleRequestFields *fields)
 {
+	ConnectionCallbackData *data;
 	PurpleAccount *account;
+
+       	data = g_new(ConnectionCallbackData, 1);
+	account = purple_connection_get_account(gc);
+
+	data->gc = gc;
+	data->fields = fields;
+
+	purple_account_get_password_async(account, ggp_callback_change_passwd_ok_continue, data);
+}
+
+static void ggp_callback_change_passwd_ok_continue(PurpleAccount * account,
+					  gchar * password,
+					  GError * error,
+					  gpointer user_data)
+{
+	ConnectionCallbackData *data = user_data;
+	PurpleConnection *gc = data->gc;
+	PurpleRequestFields *fields = data->fields;
 	GGPInfo *info = gc->proto_data;
 	struct gg_http *h;
 	gchar *cur, *p1, *p2, *t;
@@ -713,7 +742,7 @@ static void ggp_callback_change_passwd_o
 		goto exit_err;
 	}
 
-	if (g_utf8_collate(cur, purple_account_get_password(account)) != 0) {
+	if (g_utf8_collate(cur, password) != 0) {
 		purple_notify_error(account, NULL,
 			_("Your current password is different from the one that you specified."),
 			NULL);
@@ -724,7 +753,7 @@ static void ggp_callback_change_passwd_o
 
 	/* XXX: this email should be a pref... */
 	h = gg_change_passwd4(ggp_get_uin(account),
-			      "user at example.net", purple_account_get_password(account),
+			      "user at example.net", password,
 			      p1, info->token->id, t, 0);
 
 	if (h == NULL) {
@@ -1685,8 +1714,18 @@ static GList *ggp_chat_info(PurpleConnec
 /* }}} */
 
 /* static void ggp_login(PurpleAccount *account) {{{ */
+static void ggp_login_continue(PurpleAccount *account, gchar * password, GError * error, gpointer data);
+
 static void ggp_login(PurpleAccount *account)
 {
+	purple_account_get_password_async(account, ggp_login_continue, NULL);
+}
+
+static void ggp_login_continue(PurpleAccount *account,
+			       gchar * password,
+			       GError * error,
+			       gpointer data)
+{
 	PurpleConnection *gc;
 	PurplePresence *presence;
 	PurpleStatus *status;
@@ -1710,7 +1749,7 @@ static void ggp_login(PurpleAccount *acc
 	gc->proto_data = info;
 
 	glp->uin = ggp_get_uin(account);
-	glp->password = (char *)purple_account_get_password(account);
+	glp->password = password;
 
 	presence = purple_account_get_presence(account);
 	status = purple_presence_get_active_status(presence);
============================================================
--- libpurple/protocols/jabber/auth.c	3edd7f889379139a3fb0da6e9a0810c224b54384
+++ libpurple/protocols/jabber/auth.c	a73b3f570892edfa782aa6e17808b8d20e1f6ae8
@@ -25,6 +25,7 @@
 #include "cipher.h"
 #include "core.h"
 #include "conversation.h"
+#include "keyring.h"
 #include "request.h"
 #include "sslconn.h"
 #include "util.h"
@@ -65,52 +66,78 @@ jabber_process_starttls(JabberStream *js
 	return FALSE;
 }
 
+static void finish_plaintext_authentication_continue_plain(PurpleAccount * account,
+	char * password, GError * error, gpointer data);
+static void finish_plaintext_authentication_continue_iq_auth(PurpleAccount * account,
+	char * password, GError * error, gpointer data);
+
 static void finish_plaintext_authentication(JabberStream *js)
 {
 	if(js->auth_type == JABBER_AUTH_PLAIN) {
-		xmlnode *auth;
-		GString *response;
-		gchar *enc_out;
+		 purple_connection_get_password_async(js->gc,
+			finish_plaintext_authentication_continue_plain, js);
 
-		auth = xmlnode_new("auth");
-		xmlnode_set_namespace(auth, "urn:ietf:params:xml:ns:xmpp-sasl");
+	} else if(js->auth_type == JABBER_AUTH_IQ_AUTH) {
+		purple_account_get_password_async(js->gc,
+			finish_plaintext_authentication_continue_iq_auth, js);
+	}
+}
 
-		xmlnode_set_attrib(auth, "xmlns:ga", "http://www.google.com/talk/protocol/auth");
-		xmlnode_set_attrib(auth, "ga:client-uses-full-bind-result", "true");
+static void finish_plaintext_authentication_continue_plain(PurpleAccount * account,
+							   char * password,
+							   GError * error,
+							   gpointer data)
+{
+	xmlnode *auth;
+	GString *response;
+	gchar *enc_out;
+	JabberStream *js = data;
 
-		response = g_string_new("");
-		response = g_string_append_len(response, "\0", 1);
-		response = g_string_append(response, js->user->node);
-		response = g_string_append_len(response, "\0", 1);
-		response = g_string_append(response,
-				purple_connection_get_password(js->gc));
+	auth = xmlnode_new("auth");
+	xmlnode_set_namespace(auth, "urn:ietf:params:xml:ns:xmpp-sasl");
 
-		enc_out = purple_base64_encode((guchar *)response->str, response->len);
+	xmlnode_set_attrib(auth, "xmlns:ga", "http://www.google.com/talk/protocol/auth");
+	xmlnode_set_attrib(auth, "ga:client-uses-full-bind-result", "true");
 
-		xmlnode_set_attrib(auth, "mechanism", "PLAIN");
-		xmlnode_insert_data(auth, enc_out, -1);
-		g_free(enc_out);
-		g_string_free(response, TRUE);
+	response = g_string_new("");
+	response = g_string_append_len(response, "\0", 1);
+	response = g_string_append(response, js->user->node);
+	response = g_string_append_len(response, "\0", 1);
+	response = g_string_append(response,
+			purple_connection_get_password(js->gc));
 
-		jabber_send(js, auth);
-		xmlnode_free(auth);
-	} else if(js->auth_type == JABBER_AUTH_IQ_AUTH) {
-		JabberIq *iq;
-		xmlnode *query, *x;
+	enc_out = purple_base64_encode((guchar *)response->str, response->len);
 
-		iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth");
-		query = xmlnode_get_child(iq->node, "query");
-		x = xmlnode_new_child(query, "username");
-		xmlnode_insert_data(x, js->user->node, -1);
-		x = xmlnode_new_child(query, "resource");
-		xmlnode_insert_data(x, js->user->resource, -1);
-		x = xmlnode_new_child(query, "password");
-		xmlnode_insert_data(x, purple_connection_get_password(js->gc), -1);
-		jabber_iq_set_callback(iq, auth_old_result_cb, NULL);
-		jabber_iq_send(iq);
-	}
+	xmlnode_set_attrib(auth, "mechanism", "PLAIN");
+	xmlnode_insert_data(auth, enc_out, -1);
+	g_free(enc_out);
+	g_string_free(response, TRUE);
+
+	jabber_send(js, auth);
+	xmlnode_free(auth);
 }
 
+static void finish_plaintext_authentication_continue_iq_auth(PurpleAccount * account,
+							     char * password,
+							     GError * error,
+							     gpointer data)
+{
+	JabberIq *iq;
+	xmlnode *query, *x;
+	JabberStream *js = data;
+
+	iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth");
+	query = xmlnode_get_child(iq->node, "query");
+	x = xmlnode_new_child(query, "username");
+	xmlnode_insert_data(x, js->user->node, -1);
+	x = xmlnode_new_child(query, "resource");
+	xmlnode_insert_data(x, js->user->resource, -1);
+	x = xmlnode_new_child(query, "password");
+	xmlnode_insert_data(x, password, -1);
+	jabber_iq_set_callback(iq, auth_old_result_cb, NULL);
+	jabber_iq_send(iq);
+}
+
 static void allow_plaintext_auth(PurpleAccount *account)
 {
 	purple_account_set_bool(account, "auth_plain_in_clear", TRUE);
============================================================
--- libpurple/protocols/qq/qq_network.c	4364dbec36ac54db6ce17b68698173e582d596de
+++ libpurple/protocols/qq/qq_network.c	83570bf68fedc74884525549ea7617220c04e4a5
@@ -564,16 +564,42 @@ static gboolean network_timeout(gpointer
 
 /* the callback function after socket is built
  * we setup the qq protocol related configuration here */
+typedef struct _ConnectInfo
+{
+	PurpleConnection * gc;
+	gint source;
+	const gchar * error;
+} ConnectInfo;
+static void qq_connect_cb_continue(PurpleAccount * account, char * password, GError * error, gpointer data);
+
 static void qq_connect_cb(gpointer data, gint source, const gchar *error_message)
 {
+	ConnectInfo * info;
+	PurpleAccount * account;
+
+	info = g_malloc(sizeof(ConnectInfo));
+	info->gc = (PurpleConnection *) data;
+	info->source = source;
+	info->error =error_message;
+	
+	account = purple_connection_get_account(info->gc);
+
+	purple_account_get_password_async(account, qq_connect_cb_continue, info);
+
+	g_free(info);
+}
+static void qq_connect_cb_continue(PurpleAccount * account,
+				   char * passwd,
+				   GError * error,
+				   gpointer data)
+{
+	ConnectInfo * info = (ConnectInfo *)data;
+	gint source			= info->source;
+	const gchar *error_message	= info->error;
+	PurpleConnection *gc		= info->gc;
 	qq_data *qd;
-	PurpleConnection *gc;
 	gchar *conn_msg;
-	const gchar *passwd;
-	PurpleAccount *account ;
 
-	gc = (PurpleConnection *) data;
-
 	if (!PURPLE_CONNECTION_IS_VALID(gc)) {
 		purple_debug(PURPLE_DEBUG_INFO, "QQ_CONN", "Invalid connection\n");
 		close(source);
@@ -583,7 +609,6 @@ static void qq_connect_cb(gpointer data,
 	g_return_if_fail(gc != NULL && gc->proto_data != NULL);
 
 	qd = (qq_data *) gc->proto_data;
-	account = purple_connection_get_account(gc);
 
 	/* Connect is now complete; clear the PurpleProxyConnectData */
 	qd->connect_data = NULL;
@@ -603,10 +628,9 @@ static void qq_connect_cb(gpointer data,
 	qd->fd = source;
 	qd->logged_in = FALSE;
 	qd->channel = 1;
-	qd->uid = strtol(purple_account_get_username(purple_connection_get_account(gc)), NULL, 10);
+	qd->uid = strtol(purple_account_get_username(account), NULL, 10);
 
 	/* now generate md5 processed passwd */
-	passwd = purple_account_get_password(purple_connection_get_account(gc));
 
 	/* use twice-md5 of user password as session key since QQ 2003iii */
 	qq_get_md5(qd->password_twice_md5, sizeof(qd->password_twice_md5),
============================================================
--- libpurple/protocols/sametime/sametime.c	f57a2836e3579dc767727265d04760f695730200
+++ libpurple/protocols/sametime/sametime.c	d439635129e338429aa7206dba80afca5aff7a96
@@ -42,6 +42,7 @@
 #include "debug.h"
 #include "ft.h"
 #include "imgstore.h"
+#include "keyring.h"
 #include "mime.h"
 #include "notify.h"
 #include "plugin.h"
@@ -311,7 +312,8 @@ struct named_id {
 
 
 /* connection functions */
-
+static void mw_prpl_login_continue(PurpleAccount * account,
+	char * pass, GError * error, gpointer data);
 static void connect_cb(gpointer data, gint source, const gchar *error_message);
 
 
@@ -3705,11 +3707,20 @@ static void prompt_host(PurpleConnection
 }
 
 
-static void mw_prpl_login(PurpleAccount *account) {
+static void mw_prpl_login(PurpleAccount *account)
+{
+	purple_account_get_password_async(account, mw_prpl_login_continue, NULL);
+}
+
+static void mw_prpl_login_continue(PurpleAccount * account,
+				   char * pass,
+				   GError * error,
+				   gpointer data)
+{
   PurpleConnection *gc;
   struct mwPurplePluginData *pd;
 
-  char *user, *pass, *host;
+  char *user, *host;
   guint port;
 
   gc = purple_account_get_connection(account);
@@ -3719,7 +3730,6 @@ static void mw_prpl_login(PurpleAccount 
   gc->flags |= PURPLE_CONNECTION_NO_IMAGES;
 
   user = g_strdup(purple_account_get_username(account));
-  pass = g_strdup(purple_account_get_password(account));
 
   host = strrchr(user, ':');
   if(host) {
============================================================
--- libpurple/protocols/silc/silc.c	ec27b9d2305549d9aa39f8c4c54124177e80a088
+++ libpurple/protocols/silc/silc.c	4e17c145d01b9dfac317b251a3c1eaa4c864552f
@@ -511,11 +511,25 @@ static void silcpurple_no_password_cb(Pu
 	silc_free(sg);
 }
 
+static void silcpurple_running_continue(PurpleAccount * account, 
+	char * password, GError * error, gpointer context);
+
 static void silcpurple_running(SilcClient client, void *context)
 {
 	SilcPurple sg = context;
 	PurpleConnection *gc = sg->gc;
+
 	PurpleAccount *account = purple_connection_get_account(gc);
+	purple_account_get_password_async(account, silcpurple_running_continue, context);
+}
+
+static void silcpurple_running_continue(PurpleAccount * account,
+					char * password,
+					GError * error,
+					gpointer context)
+{
+	SilcPurple sg = context;
+	PurpleConnection *gc = sg->gc;
 	char pkd[256], prd[256];
 
 
@@ -529,7 +543,7 @@ static void silcpurple_running(SilcClien
 				(char *)purple_account_get_string(account, "private-key", prd),
 				(gc->password == NULL) ? "" : gc->password,
 				&sg->public_key, &sg->private_key)) {
-		if (!purple_account_get_password(account)) {
+		if (!password) {
 			purple_account_request_password(account, G_CALLBACK(silcpurple_got_password_cb),
 											G_CALLBACK(silcpurple_no_password_cb), gc);
 			return;
============================================================
--- libpurple/prpl.c	a2f9ed66262e0720f017a353b705a132e4e7825e
+++ libpurple/prpl.c	642a6d38811f3a2c2e275f734ef8507405d7feba
@@ -329,7 +329,7 @@ do_prpl_change_account_status(PurpleAcco
 			purple_account_disconnect(account);
 		/* Clear out the unsaved password if we're already disconnected and we switch to offline status */
 		else if (!purple_account_get_remember_password(account))
-			purple_account_set_password(account, NULL);
+			purple_account_set_password_async(account, NULL, NULL, NULL, NULL);
 		return;
 	}
 
============================================================
--- pidgin/gtkaccount.c	d6a43d89af6d06476933f00155266ac0c495ab8b
+++ pidgin/gtkaccount.c	7d0f4a75bcf76de97d89adea0211f186f0e7a245
@@ -145,7 +145,7 @@ static void add_login_options_continue(P
 static void set_account(GtkListStore *store, GtkTreeIter *iter,
 						  PurpleAccount *account, GdkPixbuf *global_buddyicon);
 static void add_login_options_continue(PurpleAccount * account, 
-	const gchar * password, GError * error, gpointer user_data);
+	gchar * password, GError * error, gpointer user_data);
 
 /**************************************************************************
  * Add/Modify Account dialog
@@ -412,7 +412,7 @@ add_login_options_continue(PurpleAccount
 
 static void
 add_login_options_continue(PurpleAccount * account,
-			   const gchar * password,
+			   gchar * password,
 			   GError * error,
 			   gpointer user_data)
 {
@@ -429,10 +429,6 @@ add_login_options_continue(PurpleAccount
 	GList *l, *l2;
 	char *username = NULL;
 
-	/* XXX : report error ? */
-	if (error)
-		g_error_free(error);
-
 	if (dialog->protocol_menu != NULL)
 	{
 		gtk_widget_ref(dialog->protocol_menu);
@@ -1341,9 +1337,9 @@ ok_account_prefs_cb(GtkWidget *w, Accoun
 	 * don't want to prompt them.
 	 */
 	if ((purple_account_get_remember_password(account) || new_acct) && (*value != '\0'))
-		purple_account_set_password(account, value);
+		purple_account_set_password_async(account, g_strdup(value), g_free, NULL, NULL);
 	else
-		purple_account_set_password(account, NULL);
+		purple_account_set_password_async(account, NULL, NULL, NULL,NULL);
 
 	purple_account_set_username(account, username);
 	g_free(username);


More information about the Commits mailing list