Mercurial > pidgin.yaz
changeset 20152:0cb113dfb096
Disable the account when the user cancels entering the password so the account isn't stuck in a weird unconnected state. Fixes #1791
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Tue, 18 Sep 2007 03:11:19 +0000 |
parents | 48374dc14adc |
children | 3b5d20590146 |
files | libpurple/account.c libpurple/protocols/jabber/auth.c |
diffstat | 2 files changed, 33 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/account.c Tue Sep 18 03:10:40 2007 +0000 +++ b/libpurple/account.c Tue Sep 18 03:11:19 2007 +0000 @@ -917,7 +917,7 @@ purple_account_set_register_callback(PurpleAccount *account, PurpleAccountRegistrationCb cb, void *user_data) { g_return_if_fail(account != NULL); - + account->registration_cb = cb; account->registration_cb_user_data = user_data; } @@ -937,10 +937,10 @@ purple_account_unregister(PurpleAccount *account, PurpleAccountUnregistrationCb cb, void *user_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); } @@ -960,13 +960,21 @@ } if(remember) - purple_account_set_remember_password(account, TRUE); + purple_account_set_remember_password(account, TRUE); purple_account_set_password(account, entry); purple_connection_new(account, FALSE, entry); } +static void +request_password_cancel_cb(PurpleAccount *account, PurpleRequestFields *fields) +{ + /* Disable the account as the user has canceled connecting */ + purple_account_set_enabled(account, purple_core_get_ui(), FALSE); +} + + void purple_account_request_password(PurpleAccount *account, GCallback ok_cb, GCallback cancel_cb, void *user_data) @@ -1040,7 +1048,7 @@ if ((password == NULL) && !(prpl_info->options & OPT_PROTO_NO_PASSWORD) && !(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL)) - purple_account_request_password(account, G_CALLBACK(request_password_ok_cb), NULL, account); + purple_account_request_password(account, G_CALLBACK(request_password_ok_cb), G_CALLBACK(request_password_cancel_cb), account); else purple_connection_new(account, FALSE, password); } @@ -1111,18 +1119,18 @@ g_free(info); } -void +void purple_account_request_close_with_account(PurpleAccount *account) { GList *l, *l_next; - + g_return_if_fail(account != NULL); - + for (l = handles; l != NULL; l = l_next) { PurpleAccountRequestInfo *info = l->data; - + l_next = l->next; - + if (info->account == account) { handles = g_list_remove(handles, info); purple_account_request_close_info(info); @@ -1130,18 +1138,18 @@ } } -void +void purple_account_request_close(void *ui_handle) { GList *l, *l_next; - + g_return_if_fail(ui_handle != NULL); - + for (l = handles; l != NULL; l = l_next) { PurpleAccountRequestInfo *info = l->data; - + l_next = l->next; - + if (info->ui_handle == ui_handle) { handles = g_list_remove(handles, info); purple_account_request_close_info(info); @@ -1172,7 +1180,7 @@ handles = g_list_append(handles, info); return info->ui_handle; } - + return NULL; } @@ -2443,7 +2451,7 @@ purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_ACCOUNT), purple_value_new(PURPLE_TYPE_STRING)); - + load_accounts(); }
--- a/libpurple/protocols/jabber/auth.c Tue Sep 18 03:10:40 2007 +0000 +++ b/libpurple/protocols/jabber/auth.c Tue Sep 18 03:11:19 2007 +0000 @@ -23,6 +23,7 @@ #include "account.h" #include "debug.h" #include "cipher.h" +#include "core.h" #include "conversation.h" #include "request.h" #include "sslconn.h" @@ -66,10 +67,10 @@ auth = xmlnode_new("auth"); xmlnode_set_namespace(auth, "urn:ietf:params:xml:ns:xmpp-sasl"); - + xmlnode_set_attrib(auth, "xmlns:ga", "http://www.google.com/talk/protocol/auth"); xmlnode_set_attrib(auth, "ga:client-uses-full-bind-result", "true"); - + response = g_string_new(""); response = g_string_append_len(response, "\0", 1); response = g_string_append(response, js->user->node); @@ -202,7 +203,7 @@ return TRUE; } - + static void auth_pass_cb(PurpleConnection *conn, PurpleRequestFields *fields) { JabberStream *js; @@ -236,7 +237,7 @@ if (!auth_pass_generic(js, fields)) return; - + /* Restart our connection */ jabber_auth_start_old(js); } @@ -253,7 +254,8 @@ js = conn->proto_data; - purple_connection_error(conn, _("Password is required to sign on.")); + /* Disable the account as the user has canceled connecting */ + purple_account_set_enabled(conn->account, purple_core_get_ui(), FALSE); } static void jabber_auth_start_cyrus(JabberStream *js) @@ -621,7 +623,7 @@ * to OPTIONAL for this protocol. So, we need to do our own * password prompting here */ - + if (!purple_account_get_password(js->gc->account)) { purple_account_request_password(js->gc->account, G_CALLBACK(auth_old_pass_cb), G_CALLBACK(auth_no_pass_cb), js->gc); return;