pidgin/pidgin

Use PurpleDisconnectReasons in prpl-jabber.
cpw.resiak.disconnectreason
2007-09-19, Will Thompson
c900767c024b
Parents cc02f15b7a91
Children 9c5f56f82ec1
Use PurpleDisconnectReasons in prpl-jabber.
--- 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);
}
}
--- a/libpurple/protocols/jabber/jabber.c Wed Sep 19 15:01:47 2007 +0000
+++ b/libpurple/protocols/jabber/jabber.c Wed Sep 19 15:03:59 2007 +0000
@@ -89,7 +89,8 @@
if(js->unregistration)
jabber_unregister_account_cb(js);
} else {
- purple_connection_error(js->gc, _("Error initializing session"));
+ purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR,
+ ("Error initializing session"));
}
}
@@ -120,7 +121,8 @@
JabberBuddy *my_jb = NULL;
jabber_id_free(js->user);
if(!(js->user = jabber_id_new(full_jid))) {
- purple_connection_error(js->gc, _("Invalid response from server."));
+ purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR,
+ _("Invalid response from server."));
}
if((my_jb = jabber_buddy_find(js, full_jid, TRUE)))
my_jb->subscription |= JABBER_SUB_BOTH;
@@ -128,7 +130,7 @@
}
} else {
char *msg = jabber_parse_error(js, packet);
- purple_connection_error(js->gc, msg);
+ purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR, msg);
g_free(msg);
}
@@ -142,7 +144,8 @@
return;
} else if(purple_account_get_bool(js->gc->account, "require_tls", FALSE) && !js->gsc) {
js->gc->wants_to_die = TRUE;
- purple_connection_error(js->gc, _("You require encryption, but it is not available on this server."));
+ purple_connection_error_reason (js->gc, PURPLE_REASON_ENCRYPTION_ERROR,
+ _("You require encryption, but it is not available on this server."));
return;
}
@@ -175,7 +178,10 @@
{
char *msg = jabber_parse_error(js, packet);
- purple_connection_error(js->gc, msg);
+ if (js->gc->wants_to_die)
+ purple_connection_error_reason (js->gc, PURPLE_REASON_OTHER_ERROR, msg);
+ else
+ purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR, msg);
g_free(msg);
}
@@ -256,7 +262,8 @@
if (ret < 0 && errno == EAGAIN)
return;
else if (ret <= 0) {
- purple_connection_error(js->gc, _("Write error"));
+ purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR,
+ _("Write error"));
return;
}
@@ -309,7 +316,9 @@
}
if (ret < 0 && errno != EAGAIN)
- purple_connection_error(js->gc, _("Write error"));
+ purple_connection_error_reason (js->gc,
+ PURPLE_REASON_NETWORK_ERROR,
+ _("Write error"));
else if (ret < olen) {
if (ret < 0)
ret = 0;
@@ -337,7 +346,9 @@
}
if (ret < 0 && errno != EAGAIN)
- purple_connection_error(js->gc, _("Write error"));
+ purple_connection_error_reason (js->gc,
+ PURPLE_REASON_NETWORK_ERROR,
+ _("Write error"));
else if (ret < len) {
if (ret < 0)
ret = 0;
@@ -405,7 +416,9 @@
if(errno == EAGAIN)
return;
else
- purple_connection_error(gc, _("Read Error"));
+ purple_connection_error_reason (js->gc,
+ PURPLE_REASON_NETWORK_ERROR,
+ _("Read Error"));
}
static void
@@ -442,7 +455,9 @@
} else if(errno == EAGAIN) {
return;
} else {
- purple_connection_error(gc, _("Read Error"));
+ purple_connection_error_reason (js->gc,
+ PURPLE_REASON_NETWORK_ERROR,
+ _("Read Error"));
}
}
@@ -481,7 +496,7 @@
gchar *tmp;
tmp = g_strdup_printf(_("Could not establish a connection with the server:\n%s"),
error);
- purple_connection_error(gc, tmp);
+ purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR, tmp);
g_free(tmp);
return;
}
@@ -509,7 +524,7 @@
js = gc->proto_data;
js->gsc = NULL;
- purple_connection_error(gc, purple_ssl_strerror(error));
+ purple_connection_ssl_error (gc, error);
}
static void tls_init(JabberStream *js)
@@ -526,7 +541,8 @@
if (purple_proxy_connect(js->gc, js->gc->account, host,
port, jabber_login_callback, js->gc) == NULL)
- purple_connection_error(js->gc, _("Unable to create socket"));
+ purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR,
+ _("Unable to create socket"));
}
static void srv_resolved_cb(PurpleSrvResponse *resp, int results, gpointer data)
@@ -572,12 +588,14 @@
js->old_length = -1;
if(!js->user) {
- purple_connection_error(gc, _("Invalid XMPP ID"));
+ purple_connection_error_reason (gc, PURPLE_REASON_INVALID_USERNAME,
+ _("Invalid XMPP ID"));
return;
}
if (!js->user->domain || *(js->user->domain) == '\0') {
- purple_connection_error(gc, _("Invalid XMPP ID. Domain must be set."));
+ purple_connection_error_reason (gc, PURPLE_REASON_INVALID_USERNAME,
+ _("Invalid XMPP ID. Domain must be set."));
return;
}
@@ -607,7 +625,8 @@
purple_account_get_int(account, "port", 5223), jabber_login_callback_ssl,
jabber_ssl_connect_failure, js->gc);
} else {
- purple_connection_error(js->gc, _("SSL support unavailable"));
+ purple_connection_error_reason (js->gc, PURPLE_REASON_ENCRYPTION_ERROR,
+ _("SSL support unavailable"));
}
}
@@ -1060,7 +1079,8 @@
js->old_length = -1;
if(!js->user) {
- purple_connection_error(gc, _("Invalid XMPP ID"));
+ purple_connection_error_reason (gc, PURPLE_REASON_INVALID_USERNAME,
+ _("Invalid XMPP ID"));
return;
}
@@ -1092,7 +1112,8 @@
purple_account_get_int(account, "port", 5222),
jabber_login_callback_ssl, jabber_ssl_connect_failure, gc);
} else {
- purple_connection_error(gc, _("SSL support unavailable"));
+ purple_connection_error_reason (gc, PURPLE_REASON_ENCRYPTION_ERROR,
+ _("SSL support unavailable"));
}
}
--- a/libpurple/protocols/jabber/parser.c Wed Sep 19 15:01:47 2007 +0000
+++ b/libpurple/protocols/jabber/parser.c Wed Sep 19 15:03:59 2007 +0000
@@ -193,7 +193,8 @@
js->context = xmlCreatePushParserCtxt(&jabber_parser_libxml, js, buf, len, NULL);
xmlParseChunk(js->context, "", 0, 0);
} else if (xmlParseChunk(js->context, buf, len, 0) < 0) {
- purple_connection_error(js->gc, _("XML Parse error"));
+ purple_connection_error_reason (js->gc, PURPLE_REASON_OTHER_ERROR,
+ _("XML Parse error"));
}
}