soc.2008.masterpassword: 5de34f0e: compile, appears to work too.
khc at pidgin.im
khc at pidgin.im
Mon Jan 5 03:55:38 EST 2009
-----------------------------------------------------------------
Revision: 5de34f0e82c22d80a2d6264913bf050f9ea13b61
Ancestor: e8e908daacfd872ddbe286bd79d6c387cbf31f5c
Author: khc at pidgin.im
Date: 2009-01-05T08:51:51
Branch: im.pidgin.soc.2008.masterpassword
URL: http://d.pidgin.im/viewmtn/revision/info/5de34f0e82c22d80a2d6264913bf050f9ea13b61
Modified files:
libpurple/account.c libpurple/account.h
libpurple/connection.c libpurple/connection.h
libpurple/protocols/oscar/flap_connection.c
libpurple/protocols/qq/qq_network.c libpurple/prpl.c
pidgin/gtkaccount.c pidgin/gtkconn.c
ChangeLog:
compile, appears to work too.
I changed how password are forgotten when ths user initiated a disconnect,
so that we always forget when the disconnect is not coming from
purple_connection_error_reason(), which I believe is clearer. Well that
really is just an excuse of getting around the fact that
purple_account_get_password is deprecated.
I also undeprecated purple_account_set_password(), mostly because the only
usages of purple_account_set_password_async() use NULL callback, which
is what purple_account_set_password() does anyway. I think we should just
get rid of purple_account_set_password_async() unless there's a reason
for the caller to handle it specially, and make the default popup an error
if there is one.
-------------- next part --------------
============================================================
--- libpurple/account.c d1d1a309e9f103db46846f19561a38fe75876a75
+++ libpurple/account.c 3a38db6f355c9f82de67489002978481df42f28c
@@ -1111,7 +1111,7 @@ purple_account_register_got_password_cb(
{
g_return_if_fail(account != NULL);
- purple_connection_new(account, TRUE, password);
+ _purple_connection_new(account, TRUE, password);
}
typedef struct
@@ -1148,7 +1148,7 @@ purple_account_unregister_got_password_c
unregdata = data;
g_return_if_fail(unregdata != NULL);
- purple_connection_new_unregister(account, password, unregdata->cb, unregdata->user_data);
+ _purple_connection_new_unregister(account, password, unregdata->cb, unregdata->user_data);
g_free(unregdata);
}
@@ -1177,7 +1177,7 @@ request_password_ok_cb(PurpleAccount *ac
password = g_strdup(entry);
purple_account_set_password(account, password);
g_free(password);
- purple_connection_new(account, FALSE, entry);
+ _purple_connection_new(account, FALSE, entry);
}
@@ -1292,7 +1292,7 @@ purple_account_disconnect(PurpleAccount
account->disconnecting = TRUE;
gc = purple_account_get_connection(account);
- purple_connection_destroy(gc);
+ _purple_connection_destroy(gc);
purple_account_set_connection(account, NULL);
account->disconnecting = FALSE;
@@ -2057,6 +2057,7 @@ purple_account_get_username(const Purple
return account->username;
}
+#ifndef PURPLE_DISABLE_DEPRECATED
/* XXX will be replaced by the async code in 3.0 */
const char *
purple_account_get_password(PurpleAccount *account)
@@ -2080,6 +2081,7 @@ purple_account_get_password(PurpleAccoun
return account->password;
}
+#endif
void
purple_account_get_password_async(PurpleAccount * account,
============================================================
--- libpurple/account.h eb196c874f99bfd1fc08e4bceeb1d6381bd7743e
+++ libpurple/account.h fb08a1d7eea1263b48550c32fdec405305151590
@@ -322,18 +322,15 @@ void purple_account_set_username(PurpleA
*/
void purple_account_set_username(PurpleAccount *account, const char *username);
-#ifndef PURPLE_DISABLE_DEPRECATED
/**
* Sets the account's password.
*
* @param account The account.
* @param password The password.
*
- * @deprecated You should use either purple_account_set_password_async() instead.
* This functions is just a wrapper for the async code anyway.
*/
void purple_account_set_password(PurpleAccount *account, const char *password);
-#endif
/**
* Set the account's password, and call the callback
============================================================
--- libpurple/connection.c 84d2bde33c7e350db9c24c06d2e1e4e5afc26ca5
+++ libpurple/connection.c 6383741858d4b89bbcce7a824a7604ba47555768
@@ -460,13 +460,7 @@ purple_connection_get_password(const Pur
{
g_return_val_if_fail(gc != NULL, NULL);
- if (gc->password) {
- return gc->password;
- } else {
- purple_debug_info("connection",
- "Password was unknown, getting password from account");
- return purple_account_get_password(gc->account);
- }
+ return gc->password;
}
const char *
@@ -477,6 +471,14 @@ purple_connection_get_display_name(const
return gc->display_name;
}
+gboolean
+purple_connection_had_error(const PurpleConnection *gc)
+{
+ g_return_val_if_fail(gc != NULL, FALSE);
+
+ return gc->disconnect_timeout != 0;
+}
+
void
purple_connection_update_progress(PurpleConnection *gc, const char *text,
size_t step, size_t count)
============================================================
--- libpurple/connection.h 47dcb5d38116fc0ac593dbb5d4ec9557fa65817e
+++ libpurple/connection.h d138af312a1e02fc5c153f2ee610913df3de93ed
@@ -61,6 +61,10 @@ typedef enum
*/
typedef enum
{
+ /** There was no error
+ *
+ */
+ PURPLE_CONNECTION_ERROR_NO_ERROR = -1,
/** There was an error sending or receiving on the network socket, or
* there was some protocol error (such as the server sending malformed
* data).
@@ -258,6 +262,8 @@ struct _PurpleConnection
guint disconnect_timeout; /**< Timer used for nasty stack tricks */
time_t last_received; /**< When we last received a packet. Set by the
prpl to avoid sending unneeded keepalives */
+
+ PurpleConnectionError disconnect_reason;
};
#ifdef __cplusplus
@@ -410,6 +416,15 @@ const char *purple_connection_get_displa
const char *purple_connection_get_display_name(const PurpleConnection *gc);
/**
+ * Returns if the connection had an error
+ *
+ * @param gc The connection.
+ *
+ * @return TRUE if the connection had an error, FALSE otherwise
+ */
+gboolean purple_connection_had_error(const PurpleConnection *gc);
+
+/**
* Updates the connection progress.
*
* @param gc The connection.
============================================================
--- libpurple/protocols/oscar/flap_connection.c cc074ef8462f48258443ecf77a6d66c08a7dafb1
+++ libpurple/protocols/oscar/flap_connection.c 98a48af70e64c9bf5ffb182b71ae3a5b3a47c02d
@@ -20,6 +20,7 @@
#include "oscar.h"
+#include "account.h"
#include "eventloop.h"
#include "proxy.h"
============================================================
--- libpurple/protocols/qq/qq_network.c 8257f51bfa1d6db8e0878b23bd9f25122b2e9c32
+++ libpurple/protocols/qq/qq_network.c d7c4fac87f8615cdbf39e12ec5040aee058334cf
@@ -715,7 +715,7 @@ static void set_all_keys(PurpleConnectio
#endif
/* now generate md5 processed passwd */
- passwd = purple_account_get_password(purple_connection_get_account(gc));
+ passwd = purple_connection_get_password(gc);
/* use twice-md5 of user password as session key since QQ 2003iii */
dest = qd->ld.pwd_md5;
============================================================
--- libpurple/prpl.c 460c74940efd531761be5d53ffd2980d04cb9272
+++ libpurple/prpl.c 6765c6a8c1241e1fc5ddfe237eb3ef076656b533
@@ -327,11 +327,17 @@ do_prpl_change_account_status(PurpleAcco
if (!purple_status_is_online(new_status))
{
+ /* Clear out the unsaved password if the disconnect was initiated
+ by the user */
+ if (!purple_account_get_remember_password(account)) {
+ PurpleConnection *gc = purple_account_get_connection(account);
+ if (gc && purple_connection_had_error(gc))
+ purple_account_set_password_async(account, NULL, NULL, NULL, NULL);
+ }
+
if (!purple_account_is_disconnected(account))
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_async(account, NULL, NULL, NULL, NULL);
+
return;
}
============================================================
--- pidgin/gtkaccount.c b52053f7316b51f5b173a9d7385b0a580adcb54b
+++ pidgin/gtkaccount.c e95b699b8541601392189cd9cb7e0b60acf94654
@@ -108,6 +108,7 @@ typedef struct
GtkWidget *login_frame;
GtkWidget *protocol_menu;
GtkWidget *password_box;
+ char *password;
GtkWidget *screenname_entry;
GtkWidget *password_entry;
GtkWidget *alias_entry;
@@ -566,10 +567,10 @@ add_login_options(AccountPrefsDialog *di
/* Set the fields. */
if (dialog->account != NULL) {
- if (purple_account_get_password(dialog->account) &&
+ if (dialog->password &&
purple_account_get_remember_password(dialog->account))
gtk_entry_set_text(GTK_ENTRY(dialog->password_entry),
- purple_account_get_password(dialog->account));
+ dialog->password);
gtk_toggle_button_set_active(
GTK_TOGGLE_BUTTON(dialog->remember_pass_check),
@@ -1497,6 +1498,7 @@ pidgin_account_dialog_show_continue(Purp
}
dialog->account = account;
+ dialog->password = g_strdup(password);
dialog->type = type;
dialog->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
============================================================
--- pidgin/gtkconn.c 9c65425207fe72d7140bc9bb166988997c257d45
+++ pidgin/gtkconn.c 8f434427ffc3242a2dbd492689d80a9dfcbe1cee
@@ -208,10 +208,7 @@ static void pidgin_connection_network_di
while (l) {
PurpleAccount *a = (PurpleAccount*)l->data;
if (!purple_account_is_disconnected(a)) {
- char *password = g_strdup(purple_account_get_password(a));
purple_account_disconnect(a);
- purple_account_set_password(a, password);
- g_free(password);
}
l = l->next;
}
More information about the Commits
mailing list