# HG changeset patch # User Mark Doliner # Date 1157017491 0 # Node ID 92eb7a040663f51160660d495b9a50e51caff223 # Parent 6e89bfd2b33f98d955f83ffc2eb71a4df7112219 [gaim-migrate @ 17099] Better connection error messages for dnsquery failures in general and for oscar committer: Tailor Script diff -r 6e89bfd2b33f -r 92eb7a040663 libgaim/dnsquery.c --- a/libgaim/dnsquery.c Thu Aug 31 09:02:10 2006 +0000 +++ b/libgaim/dnsquery.c Thu Aug 31 09:44:51 2006 +0000 @@ -524,7 +524,7 @@ if ((rc == 4) && (err != 0)) { #ifdef HAVE_GETADDRINFO - g_snprintf(message, sizeof(message), _("Error resolving %s: %s"), + g_snprintf(message, sizeof(message), _("Error resolving %s:\n%s"), query_data->hostname, gai_strerror(err)); #else g_snprintf(message, sizeof(message), _("Error resolving %s: %d"), @@ -549,7 +549,7 @@ gaim_dnsquery_resolved(query_data, hosts); } else if (rc == -1) { - g_snprintf(message, sizeof(message), _("Error reading from resolver process: %s"), strerror(errno)); + g_snprintf(message, sizeof(message), _("Error reading from resolver process:\n%s"), strerror(errno)); gaim_dnsquery_failed(query_data, message); } else if (rc == 0) { @@ -668,7 +668,7 @@ } freeaddrinfo(tmp); } else { - query_data->error_message = g_strdup_printf(_("Error resolving %s: %s"), query_data->hostname, gai_strerror(rc)); + query_data->error_message = g_strdup_printf(_("Error resolving %s:\n%s"), query_data->hostname, gai_strerror(rc)); } #else if ((hp = gethostbyname(query_data->hostname))) { diff -r 6e89bfd2b33f -r 92eb7a040663 libgaim/protocols/oscar/flap_connection.c --- a/libgaim/protocols/oscar/flap_connection.c Thu Aug 31 09:02:10 2006 +0000 +++ b/libgaim/protocols/oscar/flap_connection.c Thu Aug 31 09:44:51 2006 +0000 @@ -163,6 +163,24 @@ close(conn->fd); conn->fd = -1; } + + if (conn->watcher_incoming != 0) + { + gaim_input_remove(conn->watcher_incoming); + conn->watcher_incoming = 0; + } + + if (conn->watcher_outgoing != 0) + { + gaim_input_remove(conn->watcher_outgoing); + conn->watcher_outgoing = 0; + } + + g_free(conn->buffer_incoming.data.data); + conn->buffer_incoming.data.data = NULL; + + gaim_circ_buffer_destroy(conn->buffer_outgoing); + conn->buffer_outgoing = NULL; } static void @@ -199,21 +217,51 @@ conn = data; od = conn->od; + account = gaim_connection_get_account(od->gc); gaim_debug_info("oscar", "Destroying oscar connection of " "type 0x%04hx\n", conn->type); + od->oscar_connections = g_slist_remove(od->oscar_connections, conn); + + /* + * TODO: If we don't have a SNAC_FAMILY_LOCATE connection then + * we should try to request one instead of disconnecting. + */ + if (!account->disconnecting && ((od->oscar_connections == NULL) + || (!flap_connection_getbytype(od, SNAC_FAMILY_LOCATE)))) + { + /* No more FLAP connections! Sign off this GaimConnection! */ + gchar *tmp; + if (conn->disconnect_reason == OSCAR_DISCONNECT_REMOTE_CLOSED) + tmp = g_strdup(_("Server closed the connection.")); + else if (conn->disconnect_reason == OSCAR_DISCONNECT_LOST_CONNECTION) + tmp = g_strdup_printf(_("Lost connection with server:\n%s"), + conn->error_message); + else if (conn->disconnect_reason == OSCAR_DISCONNECT_INVALID_DATA) + tmp = g_strdup(_("Received invalid data on connection with server.")); + else if (conn->disconnect_reason == OSCAR_DISCONNECT_COULD_NOT_CONNECT) + tmp = g_strdup_printf(_("Could not establish a connection with the server:\n%s"), + conn->error_message); + else + /* + * We shouldn't print a message for some disconnect_reasons. + * Like OSCAR_DISCONNECT_LOCAL_CLOSED. + */ + tmp = NULL; + + if (tmp != NULL) + { + gaim_connection_error(od->gc, tmp); + g_free(tmp); + } + } + flap_connection_close(od, conn); + g_free(conn->error_message); g_free(conn->cookie); - if (conn->watcher_incoming != 0) - gaim_input_remove(conn->watcher_incoming); - if (conn->watcher_outgoing != 0) - gaim_input_remove(conn->watcher_outgoing); - g_free(conn->buffer_incoming.data.data); - gaim_circ_buffer_destroy(conn->buffer_outgoing); - /* * Free conn->internal, if necessary */ @@ -223,49 +271,23 @@ g_slist_free(conn->groups); flap_connection_destroy_rates(conn->rates); - od->oscar_connections = g_slist_remove(od->oscar_connections, conn); - - account = gaim_connection_get_account(od->gc); - - /* - * TODO: If we don't have a SNAC_FAMILY_LOCATE connection then - * we should try to request one instead of disconnecting. - */ - if (!account->disconnecting && ((od->oscar_connections == NULL) - || (!flap_connection_getbytype(od, SNAC_FAMILY_LOCATE)))) - { - /* No more FLAP connections! Sign off this GaimConnection! */ - const gchar *tmp; - if (conn->disconnect_reason == OSCAR_DISCONNECT_REMOTE_CLOSED) - tmp = _("Server closed the connection."); - else if (conn->disconnect_reason == OSCAR_DISCONNECT_LOST_CONNECTION) - tmp = _("Lost connection with server for an unknown reason."); - else if (conn->disconnect_reason == OSCAR_DISCONNECT_INVALID_DATA) - tmp = _("Received invalid data on connection with server."); - else if (conn->disconnect_reason == OSCAR_DISCONNECT_COULD_NOT_CONNECT) - tmp = _("Could not establish a connection with the server."); - else - /* - * We shouldn't print a message for some disconnect_reasons. - * Like OSCAR_DISCONNECT_LOCAL_CLOSED. - */ - tmp = NULL; - - if (tmp != NULL) - gaim_connection_error(od->gc, tmp); - } - g_free(conn); return FALSE; } +/** + * See the comments for the parameters of + * flap_connection_schedule_destroy(). + */ void -flap_connection_destroy(FlapConnection *conn, OscarDisconnectReason reason) +flap_connection_destroy(FlapConnection *conn, OscarDisconnectReason reason, const gchar *error_message) { if (conn->destroy_timeout != 0) gaim_timeout_remove(conn->destroy_timeout); conn->disconnect_reason = reason; + g_free(conn->error_message); + conn->error_message = g_strdup(error_message); flap_connection_destroy_cb(conn); } @@ -274,9 +296,18 @@ * return control back to the program's main loop. We must do this * if we want to destroy the connection but we are still using it * for some reason. + * + * @param reason The reason for the disconnection. + * @param error_message A brief error message that gives more detail + * regarding the reason for the disconnecting. This should + * be NULL for everything except OSCAR_DISCONNECT_LOST_CONNECTION, + * in which case it should contain the value of strerror(errno), + * and OSCAR_DISCONNECT_COULD_NOT_CONNECT, in which case it + * should contain the error_message passed back from the call + * to gaim_proxy_connect(). */ void -flap_connection_schedule_destroy(FlapConnection *conn, OscarDisconnectReason reason) +flap_connection_schedule_destroy(FlapConnection *conn, OscarDisconnectReason reason, const gchar *error_message) { if (conn->destroy_timeout != 0) /* Already taken care of */ @@ -285,6 +316,7 @@ gaim_debug_info("oscar", "Scheduling destruction of FLAP " "connection of type 0x%04hx\n", conn->type); conn->disconnect_reason = reason; + conn->error_message = g_strdup(error_message); conn->destroy_timeout = gaim_timeout_add(0, flap_connection_destroy_cb, conn); } @@ -571,7 +603,7 @@ "0x00000001 but received FLAP version %08lx. Closing connection.\n", flap_version); flap_connection_schedule_destroy(conn, - OSCAR_DISCONNECT_INVALID_DATA); + OSCAR_DISCONNECT_INVALID_DATA, NULL); } else conn->connected = TRUE; @@ -616,7 +648,7 @@ if (read == 0) { flap_connection_schedule_destroy(conn, - OSCAR_DISCONNECT_REMOTE_CLOSED); + OSCAR_DISCONNECT_REMOTE_CLOSED, NULL); break; } @@ -629,7 +661,7 @@ /* Error! */ flap_connection_schedule_destroy(conn, - OSCAR_DISCONNECT_LOST_CONNECTION); + OSCAR_DISCONNECT_LOST_CONNECTION, strerror(errno)); break; } @@ -644,7 +676,7 @@ if (aimutil_get8(&header[0]) != 0x2a) { flap_connection_schedule_destroy(conn, - OSCAR_DISCONNECT_INVALID_DATA); + OSCAR_DISCONNECT_INVALID_DATA, NULL); break; } @@ -668,7 +700,7 @@ if (read == 0) { flap_connection_schedule_destroy(conn, - OSCAR_DISCONNECT_REMOTE_CLOSED); + OSCAR_DISCONNECT_REMOTE_CLOSED, NULL); break; } @@ -680,7 +712,7 @@ /* Error! */ flap_connection_schedule_destroy(conn, - OSCAR_DISCONNECT_LOST_CONNECTION); + OSCAR_DISCONNECT_LOST_CONNECTION, strerror(errno)); break; } @@ -724,7 +756,8 @@ return; /* Error! */ - flap_connection_schedule_destroy(conn, OSCAR_DISCONNECT_LOST_CONNECTION); + flap_connection_schedule_destroy(conn, + OSCAR_DISCONNECT_LOST_CONNECTION, strerror(errno)); return; } diff -r 6e89bfd2b33f -r 92eb7a040663 libgaim/protocols/oscar/oscar.c --- a/libgaim/protocols/oscar/oscar.c Thu Aug 31 09:02:10 2006 +0000 +++ b/libgaim/protocols/oscar/oscar.c Thu Aug 31 09:44:51 2006 +0000 @@ -897,7 +897,7 @@ /* Destroy the chat_connection */ od->oscar_chats = g_slist_remove(od->oscar_chats, cc); - flap_connection_schedule_destroy(cc->conn, OSCAR_DISCONNECT_DONE); + flap_connection_schedule_destroy(cc->conn, OSCAR_DISCONNECT_DONE, NULL); oscar_chat_destroy(cc); } @@ -927,12 +927,27 @@ gaim_debug_error("oscar", "unable to connect FLAP server " "of type 0x%04hx\n", conn->type); if (conn->type == SNAC_FAMILY_AUTH) - gaim_connection_error(gc, _("Could not connect to authentication server")); - if (conn->type == SNAC_FAMILY_LOCATE) - gaim_connection_error(gc, _("Could not connect to BOS server")); - else /* Maybe we should call this for BOS connections, too? */ + { + gchar *msg; + msg = g_strdup_printf(_("Could not connect to authentication server:\n%s"), + error_message); + gaim_connection_error(gc, msg); + g_free(msg); + } + else if (conn->type == SNAC_FAMILY_LOCATE) + { + gchar *msg; + msg = g_strdup_printf(_("Could not connect to BOS server:\n%s"), + error_message); + gaim_connection_error(gc, msg); + g_free(msg); + } + else + { + /* Maybe we should call this for BOS connections, too? */ flap_connection_schedule_destroy(conn, - OSCAR_DISCONNECT_COULD_NOT_CONNECT); + OSCAR_DISCONNECT_COULD_NOT_CONNECT, error_message); + } return; } @@ -1302,7 +1317,7 @@ (info->email != NULL) ? info->email : "null"); gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); gaim_debug_info("oscar", "Closing auth connection...\n"); - flap_connection_schedule_destroy(conn, OSCAR_DISCONNECT_DONE); + flap_connection_schedule_destroy(conn, OSCAR_DISCONNECT_DONE, NULL); for (i = 0; i < strlen(info->bosip); i++) { if (info->bosip[i] == ':') { @@ -1617,7 +1632,9 @@ connection_established_cb, newconn); if (newconn->connect_data == NULL) { - flap_connection_schedule_destroy(newconn, OSCAR_DISCONNECT_COULD_NOT_CONNECT); + flap_connection_schedule_destroy(newconn, + OSCAR_DISCONNECT_COULD_NOT_CONNECT, + _("gaim_proxy_connect() failed")); gaim_debug_error("oscar", "Unable to connect to FLAP server " "of type 0x%04hx\n", redir->group); } @@ -6515,7 +6532,7 @@ prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); option = gaim_account_option_bool_new( - _("Always use AIM/ICQ proxy server\n(slower, but does not reveal your IP address)"), "always_use_rv_proxy", + _("Always use AIM/ICQ proxy server for file transfers\n(slower, but does not reveal your IP address)"), "always_use_rv_proxy", OSCAR_DEFAULT_ALWAYS_USE_RV_PROXY); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); diff -r 6e89bfd2b33f -r 92eb7a040663 libgaim/protocols/oscar/oscar.h --- a/libgaim/protocols/oscar/oscar.h Thu Aug 31 09:02:10 2006 +0000 +++ b/libgaim/protocols/oscar/oscar.h Thu Aug 31 09:44:51 2006 +0000 @@ -366,6 +366,7 @@ time_t lastactivity; /**< Time of last transmit. */ guint destroy_timeout; OscarDisconnectReason disconnect_reason; + gchar *error_message; /* A few variables that are only used when connecting */ GaimProxyConnectData *connect_data; @@ -571,8 +572,8 @@ /* flap_connection.c */ FlapConnection *flap_connection_new(OscarData *, int type); void flap_connection_close(OscarData *od, FlapConnection *conn); -void flap_connection_destroy(FlapConnection *conn, OscarDisconnectReason reason); -void flap_connection_schedule_destroy(FlapConnection *conn, OscarDisconnectReason reason); +void flap_connection_destroy(FlapConnection *conn, OscarDisconnectReason reason, const gchar *error_message); +void flap_connection_schedule_destroy(FlapConnection *conn, OscarDisconnectReason reason, const gchar *error_message); FlapConnection *flap_connection_findbygroup(OscarData *od, guint16 group); FlapConnection *flap_connection_getbytype(OscarData *, int type); FlapConnection *flap_connection_getbytype_all(OscarData *, int type); diff -r 6e89bfd2b33f -r 92eb7a040663 libgaim/protocols/oscar/oscar_data.c --- a/libgaim/protocols/oscar/oscar_data.c Thu Aug 31 09:02:10 2006 +0000 +++ b/libgaim/protocols/oscar/oscar_data.c Thu Aug 31 09:44:51 2006 +0000 @@ -109,7 +109,7 @@ gaim_timeout_remove(od->getinfotimer); while (od->oscar_connections != NULL) flap_connection_destroy(od->oscar_connections->data, - OSCAR_DISCONNECT_DONE); + OSCAR_DISCONNECT_DONE, NULL); while (od->peer_connections != NULL) peer_connection_destroy(od->peer_connections->data, diff -r 6e89bfd2b33f -r 92eb7a040663 libgaim/proxy.c --- a/libgaim/proxy.c Thu Aug 31 09:02:10 2006 +0000 +++ b/libgaim/proxy.c Thu Aug 31 09:44:51 2006 +0000 @@ -1582,8 +1582,7 @@ if (error_message != NULL) { - gaim_proxy_connect_data_error(connect_data, - _("Error while resolving hostname: %s\n"), error_message); + gaim_proxy_connect_data_error(connect_data, error_message); return; }