libpurple/protocols/jabber/auth.c

changeset 41850
7d551859bd94
parent 41791
3bf884522663
child 41903
27f355b8b497
equal deleted inserted replaced
41849:413cde086275 41850:7d551859bd94
106 manager = purple_credential_manager_get_default(); 106 manager = purple_credential_manager_get_default();
107 purple_credential_manager_write_password_async(manager, account, entry, 107 purple_credential_manager_write_password_async(manager, account, entry,
108 NULL, NULL, NULL); 108 NULL, NULL, NULL);
109 } 109 }
110 110
111 /* Restart our connection */ 111 /* Store the new password in our connection. */
112 purple_connection_set_password(gc, entry);
113
114 /* Restart our connection. */
112 jabber_auth_start_old(js); 115 jabber_auth_start_old(js);
113 } 116 }
114 117
115 static void 118 static void
116 auth_no_pass_cb(PurpleConnection *gc, PurpleRequestFields *fields) 119 auth_no_pass_cb(PurpleConnection *gc, PurpleRequestFields *fields)
118 /* TODO: the password prompt dialog doesn't get disposed if the account disconnects */ 121 /* TODO: the password prompt dialog doesn't get disposed if the account disconnects */
119 PURPLE_ASSERT_CONNECTION_IS_VALID(gc); 122 PURPLE_ASSERT_CONNECTION_IS_VALID(gc);
120 123
121 /* Disable the account as the user has cancelled connecting */ 124 /* Disable the account as the user has cancelled connecting */
122 purple_account_set_enabled(purple_connection_get_account(gc), FALSE); 125 purple_account_set_enabled(purple_connection_get_account(gc), FALSE);
126 }
127
128 static void
129 auth_old_read_pass_cb(GObject *source, GAsyncResult *result, gpointer data) {
130 JabberStream *js = data;
131 PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(source);
132 GError *error = NULL;
133 char *password = NULL;
134
135 password = purple_credential_manager_read_password_finish(manager, result,
136 &error);
137 if(password == NULL || error != NULL) {
138 PurpleAccount *account = NULL;
139 const char *message = "unknown error";
140
141 if(error != NULL) {
142 message = error->message;
143 }
144
145 purple_debug_warning("jabber", "failed to read password from the "
146 "credential manager : %s", message);
147
148 g_clear_error(&error);
149
150 account = purple_connection_get_account(js->gc);
151 purple_account_request_password(account, G_CALLBACK(auth_old_pass_cb),
152 G_CALLBACK(auth_no_pass_cb),
153 js->gc);
154
155 return;
156 }
157
158 /* Save the password in the connection. */
159 purple_connection_set_password(js->gc, password);
160 purple_str_wipe(password);
161
162 /* Restart the authentication process. */
163 jabber_auth_start_old(js);
123 } 164 }
124 165
125 void 166 void
126 jabber_auth_start(JabberStream *js, PurpleXmlNode *packet) 167 jabber_auth_start(JabberStream *js, PurpleXmlNode *packet)
127 { 168 {
367 /* With Cyrus SASL, passwords are optional for this protocol. So, we need to 408 /* With Cyrus SASL, passwords are optional for this protocol. So, we need to
368 * do our own password prompting here 409 * do our own password prompting here
369 */ 410 */
370 411
371 if (!purple_connection_get_password(js->gc)) { 412 if (!purple_connection_get_password(js->gc)) {
372 purple_account_request_password(account, G_CALLBACK(auth_old_pass_cb), G_CALLBACK(auth_no_pass_cb), js->gc); 413 PurpleCredentialManager *manager = NULL;
414
415 manager = purple_credential_manager_get_default();
416
417 purple_credential_manager_read_password_async(manager, account, NULL,
418 auth_old_read_pass_cb,
419 js);
373 return; 420 return;
374 } 421 }
375 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:auth"); 422 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:auth");
376 423
377 query = purple_xmlnode_get_child(iq->node, "query"); 424 query = purple_xmlnode_get_child(iq->node, "query");

mercurial