# HG changeset patch # User Will Thompson # Date 1191432182 0 # Node ID 8853202997768fc11761a0078d3fc964a20d98ba # Parent 6aca488bd8ab13e383903df7a9be060829315ef0 Add disconnection reasons to SIMPLE. diff -r 6aca488bd8ab -r 885320299776 libpurple/protocols/simple/simple.c --- a/libpurple/protocols/simple/simple.c Wed Oct 03 13:12:39 2007 +0000 +++ b/libpurple/protocols/simple/simple.c Wed Oct 03 17:23:02 2007 +0000 @@ -413,7 +413,8 @@ written = 0; else if(written <= 0) { /*TODO: do we really want to disconnect on a failure to write?*/ - purple_connection_error(gc, _("Could not write")); + purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR, + _("Could not write")); return; } @@ -435,7 +436,8 @@ } if(source < 0) { - purple_connection_error(gc, _("Could not connect")); + purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR, + _("Could not connect")); return; } @@ -461,7 +463,7 @@ if(!sip->connecting) { purple_debug_info("simple", "connecting to %s port %d\n", sip->realhostname ? sip->realhostname : "{NULL}", sip->realport); if (purple_proxy_connect(gc, sip->account, sip->realhostname, sip->realport, send_later_cb, gc) == NULL) { - purple_connection_error(gc, _("Couldn't create socket")); + purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR, _("Couldn't create socket")); } sip->connecting = TRUE; } @@ -1042,7 +1044,9 @@ if(sip->registrar.retries > SIMPLE_REGISTER_RETRY_MAX) { purple_debug_info("simple", "Setting wants_to_die to true.\n"); sip->gc->wants_to_die = TRUE; - purple_connection_error(sip->gc, _("Incorrect password.")); + purple_connection_error_reason(sip->gc, + PURPLE_REASON_AUTHENTICATION_FAILED, + _("Incorrect password.")); return TRUE; } tmp = sipmsg_find_header(msg, "WWW-Authenticate"); @@ -1056,7 +1060,8 @@ purple_debug_info("simple", "Unrecognized return code for REGISTER.\n"); if (sip->registrar.retries > SIMPLE_REGISTER_RETRY_MAX) { sip->gc->wants_to_die = TRUE; - purple_connection_error(sip->gc, _("Unknown server response.")); + purple_connection_error_reason(sip->gc, PURPLE_REASON_OTHER_ERROR, + _("Unknown server response.")); return TRUE; } sip->registerstatus = SIMPLE_REGISTER_RETRY; @@ -1526,7 +1531,8 @@ } if(source < 0) { - purple_connection_error(gc, _("Could not connect")); + purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR, + _("Could not connect")); return; } @@ -1560,7 +1566,8 @@ sip->listen_data = NULL; if(listenfd == -1) { - purple_connection_error(sip->gc, _("Could not create listen socket")); + purple_connection_error_reason(sip->gc, PURPLE_REASON_NETWORK_ERROR, + _("Could not create listen socket")); return; } @@ -1583,7 +1590,9 @@ sip->query_data = NULL; if (!hosts || !hosts->data) { - purple_connection_error(sip->gc, _("Couldn't resolve host")); + purple_connection_error_reason(sip->gc, + PURPLE_REASON_NETWORK_ERROR, + _("Couldn't resolve host")); return; } @@ -1602,7 +1611,9 @@ sip->listen_data = purple_network_listen_range(5060, 5160, SOCK_DGRAM, simple_udp_host_resolved_listen_cb, sip); if (sip->listen_data == NULL) { - purple_connection_error(sip->gc, _("Could not create listen socket")); + purple_connection_error_reason(sip->gc, + PURPLE_REASON_NETWORK_ERROR, + _("Could not create listen socket")); return; } } @@ -1615,7 +1626,9 @@ sip->listenfd = listenfd; if(sip->listenfd == -1) { - purple_connection_error(sip->gc, _("Could not create listen socket")); + purple_connection_error_reason(sip->gc, + PURPLE_REASON_NETWORK_ERROR, + _("Could not create listen socket")); return; } @@ -1628,7 +1641,9 @@ /* open tcp connection to the server */ if (purple_proxy_connect(sip->gc, sip->account, sip->realhostname, sip->realport, login_cb, sip->gc) == NULL) { - purple_connection_error(sip->gc, _("Couldn't create socket")); + purple_connection_error_reason(sip->gc, + PURPLE_REASON_NETWORK_ERROR, + _("Couldn't create socket")); } } @@ -1666,7 +1681,8 @@ sip->listen_data = purple_network_listen_range(5060, 5160, SOCK_STREAM, simple_tcp_connect_listen_cb, sip); if (sip->listen_data == NULL) { - purple_connection_error(sip->gc, _("Could not create listen socket")); + purple_connection_error_reason(sip->gc, PURPLE_REASON_NETWORK_ERROR, + _("Could not create listen socket")); return; } } else { /* UDP */ @@ -1674,7 +1690,8 @@ sip->query_data = purple_dnsquery_a(hostname, port, simple_udp_host_resolved, sip); if (sip->query_data == NULL) { - purple_connection_error(sip->gc, _("Could not resolve hostname")); + purple_connection_error_reason(sip->gc, PURPLE_REASON_NETWORK_ERROR, + _("Could not resolve hostname")); } } } @@ -1691,7 +1708,8 @@ if (strpbrk(username, " \t\v\r\n") != NULL) { gc->wants_to_die = TRUE; - purple_connection_error(gc, _("SIP screen names may not contain whitespaces or @ symbols")); + purple_connection_error_reason(gc, PURPLE_REASON_INVALID_SETTINGS, + _("SIP screen names may not contain whitespaces or @ symbols")); return; }