Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/auth.c @ 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 | da29f5c7dc1a |
children | 591267f6f1d5 f3cfcbbac3d8 |
comparison
equal
deleted
inserted
replaced
20151:48374dc14adc | 20152:0cb113dfb096 |
---|---|
21 #include "internal.h" | 21 #include "internal.h" |
22 | 22 |
23 #include "account.h" | 23 #include "account.h" |
24 #include "debug.h" | 24 #include "debug.h" |
25 #include "cipher.h" | 25 #include "cipher.h" |
26 #include "core.h" | |
26 #include "conversation.h" | 27 #include "conversation.h" |
27 #include "request.h" | 28 #include "request.h" |
28 #include "sslconn.h" | 29 #include "sslconn.h" |
29 #include "util.h" | 30 #include "util.h" |
30 #include "xmlnode.h" | 31 #include "xmlnode.h" |
64 GString *response; | 65 GString *response; |
65 gchar *enc_out; | 66 gchar *enc_out; |
66 | 67 |
67 auth = xmlnode_new("auth"); | 68 auth = xmlnode_new("auth"); |
68 xmlnode_set_namespace(auth, "urn:ietf:params:xml:ns:xmpp-sasl"); | 69 xmlnode_set_namespace(auth, "urn:ietf:params:xml:ns:xmpp-sasl"); |
69 | 70 |
70 xmlnode_set_attrib(auth, "xmlns:ga", "http://www.google.com/talk/protocol/auth"); | 71 xmlnode_set_attrib(auth, "xmlns:ga", "http://www.google.com/talk/protocol/auth"); |
71 xmlnode_set_attrib(auth, "ga:client-uses-full-bind-result", "true"); | 72 xmlnode_set_attrib(auth, "ga:client-uses-full-bind-result", "true"); |
72 | 73 |
73 response = g_string_new(""); | 74 response = g_string_new(""); |
74 response = g_string_append_len(response, "\0", 1); | 75 response = g_string_append_len(response, "\0", 1); |
75 response = g_string_append(response, js->user->node); | 76 response = g_string_append(response, js->user->node); |
76 response = g_string_append_len(response, "\0", 1); | 77 response = g_string_append_len(response, "\0", 1); |
77 response = g_string_append(response, | 78 response = g_string_append(response, |
200 | 201 |
201 purple_account_set_password(js->gc->account, entry); | 202 purple_account_set_password(js->gc->account, entry); |
202 | 203 |
203 return TRUE; | 204 return TRUE; |
204 } | 205 } |
205 | 206 |
206 static void auth_pass_cb(PurpleConnection *conn, PurpleRequestFields *fields) | 207 static void auth_pass_cb(PurpleConnection *conn, PurpleRequestFields *fields) |
207 { | 208 { |
208 JabberStream *js; | 209 JabberStream *js; |
209 | 210 |
210 /* The password prompt dialog doesn't get disposed if the account disconnects */ | 211 /* The password prompt dialog doesn't get disposed if the account disconnects */ |
234 | 235 |
235 js = conn->proto_data; | 236 js = conn->proto_data; |
236 | 237 |
237 if (!auth_pass_generic(js, fields)) | 238 if (!auth_pass_generic(js, fields)) |
238 return; | 239 return; |
239 | 240 |
240 /* Restart our connection */ | 241 /* Restart our connection */ |
241 jabber_auth_start_old(js); | 242 jabber_auth_start_old(js); |
242 } | 243 } |
243 | 244 |
244 | 245 |
251 if (!PURPLE_CONNECTION_IS_VALID(conn)) | 252 if (!PURPLE_CONNECTION_IS_VALID(conn)) |
252 return; | 253 return; |
253 | 254 |
254 js = conn->proto_data; | 255 js = conn->proto_data; |
255 | 256 |
256 purple_connection_error(conn, _("Password is required to sign on.")); | 257 /* Disable the account as the user has canceled connecting */ |
258 purple_account_set_enabled(conn->account, purple_core_get_ui(), FALSE); | |
257 } | 259 } |
258 | 260 |
259 static void jabber_auth_start_cyrus(JabberStream *js) | 261 static void jabber_auth_start_cyrus(JabberStream *js) |
260 { | 262 { |
261 const char *clientout = NULL, *mech = NULL; | 263 const char *clientout = NULL, *mech = NULL; |
619 #ifdef HAVE_CYRUS_SASL | 621 #ifdef HAVE_CYRUS_SASL |
620 /* If we have Cyrus SASL, then passwords will have been set | 622 /* If we have Cyrus SASL, then passwords will have been set |
621 * to OPTIONAL for this protocol. So, we need to do our own | 623 * to OPTIONAL for this protocol. So, we need to do our own |
622 * password prompting here | 624 * password prompting here |
623 */ | 625 */ |
624 | 626 |
625 if (!purple_account_get_password(js->gc->account)) { | 627 if (!purple_account_get_password(js->gc->account)) { |
626 purple_account_request_password(js->gc->account, G_CALLBACK(auth_old_pass_cb), G_CALLBACK(auth_no_pass_cb), js->gc); | 628 purple_account_request_password(js->gc->account, G_CALLBACK(auth_old_pass_cb), G_CALLBACK(auth_no_pass_cb), js->gc); |
627 return; | 629 return; |
628 } | 630 } |
629 #endif | 631 #endif |