Mercurial > pidgin
diff libpurple/protocols/jabber/auth.c @ 20117:f24a2cacacd1
Use PurpleDisconnectReasons in prpl-jabber.
author | Will Thompson <will.thompson@collabora.co.uk> |
---|---|
date | Wed, 19 Sep 2007 15:03:59 +0000 |
parents | da29f5c7dc1a |
children | f3cfcbbac3d8 |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/auth.c Wed Sep 19 15:01:47 2007 +0000 +++ b/libpurple/protocols/jabber/auth.c Wed Sep 19 15:03:59 2007 +0000 @@ -49,7 +49,8 @@ "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>", -1); return TRUE; } else if(xmlnode_get_child(starttls, "required")) { - purple_connection_error(js->gc, _("Server requires TLS/SSL for login. No TLS/SSL support found.")); + purple_connection_error_reason (js->gc, PURPLE_REASON_ENCRYPTION_ERROR, + _("Server requires TLS/SSL for login. No TLS/SSL support found.")); return TRUE; } } @@ -112,7 +113,8 @@ static void disallow_plaintext_auth(PurpleAccount *account) { - purple_connection_error(account->gc, _("Server requires plaintext authentication over an unencrypted stream")); + purple_connection_error_reason (account->gc, PURPLE_REASON_ENCRYPTION_ERROR, + _("Server requires plaintext authentication over an unencrypted stream")); } #ifdef HAVE_CYRUS_SASL @@ -253,7 +255,8 @@ js = conn->proto_data; - purple_connection_error(conn, _("Password is required to sign on.")); + purple_connection_error_reason (conn, PURPLE_REASON_AUTHENTICATION_FAILED, + _("Password is required to sign on.")); } static void jabber_auth_start_cyrus(JabberStream *js) @@ -329,7 +332,9 @@ * error here. */ } else { - purple_connection_error(js->gc, _("Server does not use any supported authentication method")); + purple_connection_error_reason (js->gc, + PURPLE_REASON_AUTHENTICATION_IMPOSSIBLE, + _("Server does not use any supported authentication method")); return; } /* not reached */ @@ -384,7 +389,9 @@ jabber_send(js, auth); xmlnode_free(auth); } else { - purple_connection_error(js->gc, "SASL authentication failed\n"); + purple_connection_error_reason (js->gc, + PURPLE_REASON_AUTHENTICATION_IMPOSSIBLE, + "SASL authentication failed\n"); } } @@ -457,7 +464,8 @@ mechs = xmlnode_get_child(packet, "mechanisms"); if(!mechs) { - purple_connection_error(js->gc, _("Invalid response from server.")); + purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR, + _("Invalid response from server.")); return; } @@ -517,7 +525,7 @@ } finish_plaintext_authentication(js); } else { - purple_connection_error(js->gc, + purple_connection_error_reason (js->gc, PURPLE_REASON_AUTHENTICATION_IMPOSSIBLE, _("Server does not use any supported authentication method")); } #endif @@ -543,7 +551,7 @@ purple_account_set_password(js->gc->account, NULL); } - purple_connection_error(js->gc, msg); + purple_connection_error_reason (js->gc, PURPLE_REASON_OTHER_ERROR, msg); g_free(msg); } } @@ -556,11 +564,13 @@ const char *pw = purple_connection_get_password(js->gc); if(!type) { - purple_connection_error(js->gc, _("Invalid response from server.")); + purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR, + _("Invalid response from server.")); return; } else if(!strcmp(type, "error")) { char *msg = jabber_parse_error(js, packet); - purple_connection_error(js->gc, msg); + purple_connection_error_reason (js->gc, PURPLE_REASON_AUTHENTICATION_FAILED, + msg); g_free(msg); } else if(!strcmp(type, "result")) { query = xmlnode_get_child(packet, "query"); @@ -604,8 +614,9 @@ } finish_plaintext_authentication(js); } else { - purple_connection_error(js->gc, - _("Server does not use any supported authentication method")); + purple_connection_error_reason (js->gc, + PURPLE_REASON_AUTHENTICATION_IMPOSSIBLE, + _("Server does not use any supported authentication method")); return; } } @@ -771,7 +782,8 @@ GHashTable *parts; if(!enc_in) { - purple_connection_error(js->gc, _("Invalid response from server.")); + purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR, + _("Invalid response from server.")); return; } @@ -792,7 +804,8 @@ "<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />", -1); } else { - purple_connection_error(js->gc, _("Invalid challenge from server")); + purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR, + _("Invalid challenge from server")); } g_free(js->expected_rspauth); } else { @@ -815,7 +828,8 @@ realm = js->user->domain; if (nonce == NULL || realm == NULL) - purple_connection_error(js->gc, _("Invalid challenge from server")); + purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR, + _("Invalid challenge from server")); else { GString *response = g_string_new(""); char *a2; @@ -887,7 +901,8 @@ g_free(dec_in); if (js->sasl_state != SASL_CONTINUE && js->sasl_state != SASL_OK) { purple_debug_error("jabber", "Error is %d : %s\n",js->sasl_state,sasl_errdetail(js->sasl)); - purple_connection_error(js->gc, _("SASL error")); + purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR, + _("SASL error")); return; } else { response = xmlnode_new("response"); @@ -912,7 +927,8 @@ #endif if(!ns || strcmp(ns, "urn:ietf:params:xml:ns:xmpp-sasl")) { - purple_connection_error(js->gc, _("Invalid response from server.")); + purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR, + _("Invalid response from server.")); return; } @@ -937,7 +953,8 @@ if (js->sasl_state != SASL_OK) { /* This should never happen! */ - purple_connection_error(js->gc, _("Invalid response from server.")); + purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR, + _("Invalid response from server.")); } } /* If we've negotiated a security layer, we need to enable it */ @@ -956,9 +973,11 @@ char *msg = jabber_parse_error(js, packet); if(!msg) { - purple_connection_error(js->gc, _("Invalid response from server.")); + purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR, + _("Invalid response from server.")); } else { - purple_connection_error(js->gc, msg); + purple_connection_error_reason (js->gc, PURPLE_REASON_AUTHENTICATION_FAILED, + msg); g_free(msg); } }