Mercurial > pidgin.yaz
changeset 14402:648e33275d9d
[gaim-migrate @ 17110]
Make peer disconnection error messages a little better for oscar ft and
direct connect
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 01 Sep 2006 08:52:23 +0000 |
parents | 4f51b45f4f70 |
children | 646dcf11b4eb |
files | libgaim/protocols/oscar/flap_connection.c libgaim/protocols/oscar/odc.c libgaim/protocols/oscar/oft.c libgaim/protocols/oscar/oscar.c libgaim/protocols/oscar/oscar_data.c libgaim/protocols/oscar/peer.c libgaim/protocols/oscar/peer.h |
diffstat | 7 files changed, 47 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/libgaim/protocols/oscar/flap_connection.c Fri Sep 01 08:19:31 2006 +0000 +++ b/libgaim/protocols/oscar/flap_connection.c Fri Sep 01 08:52:23 2006 +0000 @@ -316,6 +316,7 @@ gaim_debug_info("oscar", "Scheduling destruction of FLAP " "connection of type 0x%04hx\n", conn->type); conn->disconnect_reason = reason; + g_free(conn->error_message); conn->error_message = g_strdup(error_message); conn->destroy_timeout = gaim_timeout_add(0, flap_connection_destroy_cb, conn); }
--- a/libgaim/protocols/oscar/odc.c Fri Sep 01 08:19:31 2006 +0000 +++ b/libgaim/protocols/oscar/odc.c Fri Sep 01 08:52:23 2006 +0000 @@ -34,18 +34,19 @@ void peer_odc_close(PeerConnection *conn) { - const gchar *tmp; + gchar *tmp; if (conn->disconnect_reason == OSCAR_DISCONNECT_REMOTE_CLOSED) - tmp = _("The remote user has closed the connection."); + tmp = g_strdup(_("The remote user has closed the connection.")); else if (conn->disconnect_reason == OSCAR_DISCONNECT_REMOTE_REFUSED) - tmp = _("The remote user has declined your request."); + tmp = g_strdup(_("The remote user has declined your request.")); else if (conn->disconnect_reason == OSCAR_DISCONNECT_LOST_CONNECTION) - tmp = _("Lost connection with the remote user for an unknown reason."); + tmp = g_strdup_printf(_("Lost connection with the remote user:<br>%s"), + conn->error_message); else if (conn->disconnect_reason == OSCAR_DISCONNECT_INVALID_DATA) - tmp = _("Received invalid data on connection with remote user."); + tmp = g_strdup(_("Received invalid data on connection with remote user.")); else if (conn->disconnect_reason == OSCAR_DISCONNECT_COULD_NOT_CONNECT) - tmp = _("Could not establish a connection with the remote user."); + tmp = g_strdup(_("Could not establish a connection with the remote user.")); else /* * We shouldn't print a message for some disconnect_reasons. @@ -61,6 +62,7 @@ account = gaim_connection_get_account(conn->od->gc); conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, conn->sn); gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); + g_free(tmp); } if (conn->frame != NULL) @@ -442,7 +444,7 @@ /* Check if the remote user closed the connection */ if (read == 0) { - peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_CLOSED); + peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_CLOSED, NULL); return; } @@ -452,7 +454,8 @@ /* No worries */ return; - peer_connection_destroy(conn, OSCAR_DISCONNECT_LOST_CONNECTION); + peer_connection_destroy(conn, + OSCAR_DISCONNECT_LOST_CONNECTION, strerror(errno)); return; } @@ -526,7 +529,8 @@ */ gaim_debug_info("oscar", "Received an incorrect cookie. " "Closing connection.\n"); - peer_connection_destroy(conn, OSCAR_DISCONNECT_INVALID_DATA); + peer_connection_destroy(conn, + OSCAR_DISCONNECT_INVALID_DATA, NULL); g_free(frame); return; }
--- a/libgaim/protocols/oscar/oft.c Fri Sep 01 08:19:31 2006 +0000 +++ b/libgaim/protocols/oscar/oft.c Fri Sep 01 08:52:23 2006 +0000 @@ -269,7 +269,7 @@ if (gaim_circ_buffer_get_max_read(conn->buffer_outgoing) == 0) { conn->sending_data_timer = 0; - peer_connection_destroy(conn, conn->disconnect_reason); + peer_connection_destroy(conn, conn->disconnect_reason, NULL); return FALSE; } @@ -307,7 +307,7 @@ { gaim_debug_info("oscar", "Received an incorrect cookie. " "Closing connection.\n"); - peer_connection_destroy(conn, OSCAR_DISCONNECT_INVALID_DATA); + peer_connection_destroy(conn, OSCAR_DISCONNECT_INVALID_DATA, NULL); return; } @@ -521,7 +521,7 @@ if (conn == NULL) return; - peer_connection_destroy(conn, OSCAR_DISCONNECT_LOCAL_CLOSED); + peer_connection_destroy(conn, OSCAR_DISCONNECT_LOCAL_CLOSED, NULL); } /*******************************************************************/
--- a/libgaim/protocols/oscar/oscar.c Fri Sep 01 08:19:31 2006 +0000 +++ b/libgaim/protocols/oscar/oscar.c Fri Sep 01 08:52:23 2006 +0000 @@ -2044,7 +2044,7 @@ */ if (conn != NULL) { - peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_CLOSED); + peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_CLOSED, NULL); } } else if (args->status == AIM_RENDEZVOUS_CONNECTED) @@ -2275,6 +2275,7 @@ msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); for (i=0; msg1[i]; i++) { gaim_str_strip_char(msg1[i], '\r'); + /* TODO: Should use an encoding other than ASCII? */ msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); } msg2[i] = NULL; @@ -2583,7 +2584,7 @@ } else { - peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_REFUSED); + peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_REFUSED, NULL); } } else @@ -6349,7 +6350,7 @@ if (!conn->ready) aim_im_sendch2_cancel(conn); - peer_connection_destroy(conn, OSCAR_DISCONNECT_LOCAL_CLOSED); + peer_connection_destroy(conn, OSCAR_DISCONNECT_LOCAL_CLOSED, NULL); } }
--- a/libgaim/protocols/oscar/oscar_data.c Fri Sep 01 08:19:31 2006 +0000 +++ b/libgaim/protocols/oscar/oscar_data.c Fri Sep 01 08:52:23 2006 +0000 @@ -113,7 +113,7 @@ while (od->peer_connections != NULL) peer_connection_destroy(od->peer_connections->data, - OSCAR_DISCONNECT_LOCAL_CLOSED); + OSCAR_DISCONNECT_LOCAL_CLOSED, NULL); if (od->handlerlist != NULL) aim_clearhandlers(od);
--- a/libgaim/protocols/oscar/peer.c Fri Sep 01 08:19:31 2006 +0000 +++ b/libgaim/protocols/oscar/peer.c Fri Sep 01 08:52:23 2006 +0000 @@ -219,6 +219,8 @@ conn->xfer = NULL; } + g_free(conn->sn); + g_free(conn->error_message); g_free(conn->proxyip); g_free(conn->clientip); g_free(conn->verifiedip); @@ -232,16 +234,18 @@ } void -peer_connection_destroy(PeerConnection *conn, OscarDisconnectReason reason) +peer_connection_destroy(PeerConnection *conn, OscarDisconnectReason reason, const gchar *error_message) { - conn->disconnect_reason = reason; 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); peer_connection_destroy_cb(conn); } void -peer_connection_schedule_destroy(PeerConnection *conn, OscarDisconnectReason reason) +peer_connection_schedule_destroy(PeerConnection *conn, OscarDisconnectReason reason, const gchar *error_message) { if (conn->destroy_timeout != 0) /* Already taken care of */ @@ -249,6 +253,8 @@ gaim_debug_info("oscar", "Scheduling destruction of peer connection\n"); conn->disconnect_reason = reason; + g_free(conn->error_message); + conn->error_message = g_strdup(error_message); conn->destroy_timeout = gaim_timeout_add(0, peer_connection_destroy_cb, conn); } @@ -289,7 +295,7 @@ /* Check if the remote user closed the connection */ if (read == 0) { - peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_CLOSED); + peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_CLOSED, NULL); return; } @@ -300,7 +306,8 @@ /* No worries */ return; - peer_connection_destroy(conn, OSCAR_DISCONNECT_LOST_CONNECTION); + peer_connection_destroy(conn, + OSCAR_DISCONNECT_LOST_CONNECTION, strerror(errno)); return; } @@ -321,7 +328,7 @@ "Closing connection.\n", conn->magic[0], conn->magic[1], conn->magic[2], conn->magic[3], header[0], header[1], header[2], header[3]); - peer_connection_destroy(conn, OSCAR_DISCONNECT_INVALID_DATA); + peer_connection_destroy(conn, OSCAR_DISCONNECT_INVALID_DATA, NULL); return; } @@ -340,7 +347,7 @@ /* Check if the remote user closed the connection */ if (read == 0) { - peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_CLOSED); + peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_CLOSED, NULL); return; } @@ -350,7 +357,8 @@ /* No worries */ return; - peer_connection_destroy(conn, OSCAR_DISCONNECT_LOST_CONNECTION); + peer_connection_destroy(conn, + OSCAR_DISCONNECT_LOST_CONNECTION, strerror(errno)); return; } @@ -407,7 +415,8 @@ return; if (conn->ready) - peer_connection_schedule_destroy(conn, OSCAR_DISCONNECT_LOST_CONNECTION); + peer_connection_schedule_destroy(conn, + OSCAR_DISCONNECT_LOST_CONNECTION, NULL); else { /* @@ -810,7 +819,7 @@ } /* Give up! */ - peer_connection_destroy(conn, OSCAR_DISCONNECT_COULD_NOT_CONNECT); + peer_connection_destroy(conn, OSCAR_DISCONNECT_COULD_NOT_CONNECT, NULL); } /** @@ -842,7 +851,7 @@ } /* Cancel the old connection and try again */ - peer_connection_destroy(conn, OSCAR_DISCONNECT_RETRYING); + peer_connection_destroy(conn, OSCAR_DISCONNECT_RETRYING, NULL); } } @@ -885,7 +894,7 @@ aim_im_denytransfer(conn->od, conn->sn, conn->cookie, AIM_TRANSFER_DENY_DECLINE); - peer_connection_destroy(conn, OSCAR_DISCONNECT_LOCAL_CLOSED); + peer_connection_destroy(conn, OSCAR_DISCONNECT_LOCAL_CLOSED, NULL); } /** @@ -938,7 +947,7 @@ /* Close the old direct IM and start a new one */ gaim_debug_info("oscar", "Received new direct IM request " "from %s. Destroying old connection.\n", sn); - peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_CLOSED); + peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_CLOSED, NULL); } }
--- a/libgaim/protocols/oscar/peer.h Fri Sep 01 08:19:31 2006 +0000 +++ b/libgaim/protocols/oscar/peer.h Fri Sep 01 08:52:23 2006 +0000 @@ -147,6 +147,7 @@ time_t lastactivity; /**< Time of last transmit. */ guint destroy_timeout; OscarDisconnectReason disconnect_reason; + char *error_message; /** * A pointer to either an OdcFrame or an OftFrame. @@ -221,8 +222,8 @@ */ PeerConnection *peer_connection_new(OscarData *od, OscarCapability type, const char *sn); -void peer_connection_destroy(PeerConnection *conn, OscarDisconnectReason reason); -void peer_connection_schedule_destroy(PeerConnection *conn, OscarDisconnectReason reason); +void peer_connection_destroy(PeerConnection *conn, OscarDisconnectReason reason, const gchar *error_message); +void peer_connection_schedule_destroy(PeerConnection *conn, OscarDisconnectReason reason, const gchar *error_message); PeerConnection *peer_connection_find_by_type(OscarData *od, const char *sn, OscarCapability type); PeerConnection *peer_connection_find_by_cookie(OscarData *od, const char *sn, const guchar *cookie);