|
From: <the...@us...> - 2006-08-31 09:45:09
|
Revision: 17099
http://svn.sourceforge.net/gaim/?rev=17099&view=rev
Author: thekingant
Date: 2006-08-31 02:44:51 -0700 (Thu, 31 Aug 2006)
Log Message:
-----------
Better connection error messages for dnsquery failures in
general and for oscar
Modified Paths:
--------------
trunk/libgaim/dnsquery.c
trunk/libgaim/protocols/oscar/flap_connection.c
trunk/libgaim/protocols/oscar/oscar.c
trunk/libgaim/protocols/oscar/oscar.h
trunk/libgaim/protocols/oscar/oscar_data.c
trunk/libgaim/proxy.c
Modified: trunk/libgaim/dnsquery.c
===================================================================
--- trunk/libgaim/dnsquery.c 2006-08-31 09:02:10 UTC (rev 17098)
+++ trunk/libgaim/dnsquery.c 2006-08-31 09:44:51 UTC (rev 17099)
@@ -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))) {
Modified: trunk/libgaim/protocols/oscar/flap_connection.c
===================================================================
--- trunk/libgaim/protocols/oscar/flap_connection.c 2006-08-31 09:02:10 UTC (rev 17098)
+++ trunk/libgaim/protocols/oscar/flap_connection.c 2006-08-31 09:44:51 UTC (rev 17099)
@@ -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,34 +217,13 @@
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);
- flap_connection_close(od, conn);
-
- 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
- */
- if (conn->type == SNAC_FAMILY_CHAT)
- flap_connection_destroy_chat(od, conn);
-
- 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.
@@ -235,15 +232,17 @@
|| (!flap_connection_getbytype(od, SNAC_FAMILY_LOCATE))))
{
/* No more FLAP connections! Sign off this GaimConnection! */
- const gchar *tmp;
+ gchar *tmp;
if (conn->disconnect_reason == OSCAR_DISCONNECT_REMOTE_CLOSED)
- tmp = _("Server closed the connection.");
+ tmp = g_strdup(_("Server closed the connection."));
else if (conn->disconnect_reason == OSCAR_DISCONNECT_LOST_CONNECTION)
- tmp = _("Lost connection with server for an unknown reason.");
+ tmp = g_strdup_printf(_("Lost connection with server:\n%s"),
+ conn->error_message);
else if (conn->disconnect_reason == OSCAR_DISCONNECT_INVALID_DATA)
- tmp = _("Received invalid data on connection with server.");
+ tmp = g_strdup(_("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.");
+ 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.
@@ -252,20 +251,43 @@
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);
+
+ /*
+ * Free conn->internal, if necessary
+ */
+ if (conn->type == SNAC_FAMILY_CHAT)
+ flap_connection_destroy_chat(od, conn);
+
+ g_slist_free(conn->groups);
+ flap_connection_destroy_rates(conn->rates);
+
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;
}
Modified: trunk/libgaim/protocols/oscar/oscar.c
===================================================================
--- trunk/libgaim/protocols/oscar/oscar.c 2006-08-31 09:02:10 UTC (rev 17098)
+++ trunk/libgaim/protocols/oscar/oscar.c 2006-08-31 09:44:51 UTC (rev 17099)
@@ -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);
Modified: trunk/libgaim/protocols/oscar/oscar.h
===================================================================
--- trunk/libgaim/protocols/oscar/oscar.h 2006-08-31 09:02:10 UTC (rev 17098)
+++ trunk/libgaim/protocols/oscar/oscar.h 2006-08-31 09:44:51 UTC (rev 17099)
@@ -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);
Modified: trunk/libgaim/protocols/oscar/oscar_data.c
===================================================================
--- trunk/libgaim/protocols/oscar/oscar_data.c 2006-08-31 09:02:10 UTC (rev 17098)
+++ trunk/libgaim/protocols/oscar/oscar_data.c 2006-08-31 09:44:51 UTC (rev 17099)
@@ -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,
Modified: trunk/libgaim/proxy.c
===================================================================
--- trunk/libgaim/proxy.c 2006-08-31 09:02:10 UTC (rev 17098)
+++ trunk/libgaim/proxy.c 2006-08-31 09:44:51 UTC (rev 17099)
@@ -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;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|