changeset 15253:7dd8192b1a5c

[gaim-migrate @ 18042] Only prompt to resend a non-acked packet when the result of that packet being dropped would probably be significant. In that case, give a user-friendly notification. committer: Tailor Script <tailor@pidgin.im>
author Mark Huetsch <markhuetsch>
date Fri, 22 Dec 2006 05:31:54 +0000
parents ccad8138a4b2
children e6adc7b25eb8
files libgaim/protocols/qq/header_info.h libgaim/protocols/qq/qq.c libgaim/protocols/qq/sendqueue.c
diffstat 3 files changed, 52 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/libgaim/protocols/qq/header_info.h	Fri Dec 22 00:47:43 2006 +0000
+++ b/libgaim/protocols/qq/header_info.h	Fri Dec 22 05:31:54 2006 +0000
@@ -40,7 +40,7 @@
 	QQ_CMD_LOGOUT = 0x0001,				/* log out */
 	QQ_CMD_KEEP_ALIVE = 0x0002,			/* get onlines from tencent */
 	QQ_CMD_UPDATE_INFO = 0x0004,			/* update information */
-	QQ_CMD_SEARCH_USER = 0x0005,			/* serach for user */
+	QQ_CMD_SEARCH_USER = 0x0005,			/* search for user */
 	QQ_CMD_GET_USER_INFO = 0x0006,			/* get user information */
 	QQ_CMD_ADD_FRIEND_WO_AUTH = 0x0009,		/* add friend without auth */
 	QQ_CMD_DEL_FRIEND = 0x000a,			/* delete a friend  */
--- a/libgaim/protocols/qq/qq.c	Fri Dec 22 00:47:43 2006 +0000
+++ b/libgaim/protocols/qq/qq.c	Fri Dec 22 05:31:54 2006 +0000
@@ -766,7 +766,6 @@
 	gaim_prefs_add_none("/plugins/prpl/qq");
 	gaim_prefs_add_bool("/plugins/prpl/qq/show_status_by_icon", TRUE);
 	gaim_prefs_add_bool("/plugins/prpl/qq/show_fake_video", FALSE);
-	gaim_prefs_add_bool("/plugins/prpl/qq/prompt_for_missing_packet", TRUE);
 	gaim_prefs_add_bool("/plugins/prpl/qq/prompt_group_msg_on_recv", TRUE);
 }
 
--- a/libgaim/protocols/qq/sendqueue.c	Fri Dec 22 00:47:43 2006 +0000
+++ b/libgaim/protocols/qq/sendqueue.c	Fri Dec 22 05:31:54 2006 +0000
@@ -78,7 +78,7 @@
 	gaim_debug(GAIM_DEBUG_INFO, "QQ", "%d packets in sendqueue are freed!\n", i);
 }
 
-/* packet lost, agree to send again, (and will NOT prompt again)
+/* packet lost, agree to send again.
  * it is removed only when ack-ed by server */
 static void _qq_send_again(gc_and_packet *gp)
 {
@@ -125,16 +125,29 @@
 	g_free(gp);
 }
 
+static void _notify_packets_lost(GaimConnection *gc, const gchar *msg, qq_sendpacket *p)
+{
+	gc_and_packet *gp;
+
+	gp = g_new0(gc_and_packet, 1);
+	gp->gc = gc;
+	gp->packet = p;
+	gaim_request_action
+		(gc, NULL, _("Communication timed out"), msg,
+		0, gp, 2, _("Try again"), G_CALLBACK(_qq_send_again),
+		_("Cancel"), G_CALLBACK(_qq_send_cancel));
+	/* keep in sendqueue doing nothing until we hear back from the user */
+	p->resend_times++;
+}
+
 gboolean qq_sendqueue_timeout_callback(gpointer data)
 {
 	GaimConnection *gc;
 	qq_data *qd;
 	GList *list;
 	qq_sendpacket *p;
-	gc_and_packet *gp;
 	time_t now;
 	gint wait_time;
-	gboolean need_action;
 
 	gc = (GaimConnection *) data;
 	qd = (qq_data *) gc->proto_data;
@@ -166,44 +179,52 @@
 				case QQ_CMD_KEEP_ALIVE:
 					if (qd->logged_in) {
 						gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Connection lost!\n");
-						gaim_connection_error(gc, _("Connection lost!"));
+						gaim_connection_error(gc, _("Connection lost"));
 						qd->logged_in = FALSE;
 					}
 					p->resend_times = -1;
 					break;
 				case QQ_CMD_LOGIN:
+				case QQ_CMD_REQUEST_LOGIN_TOKEN:
 					if (!qd->logged_in)	/* cancel logging progress */
-						gaim_connection_error(gc, _("Login failed, no reply!"));
+						gaim_connection_error(gc, _("Login failed, no reply"));
 					p->resend_times = -1;
 					break;
 				case QQ_CMD_UPDATE_INFO:
-					gaim_notify_error(gc, NULL,
-							  _("Connection timeout!"), _("User info is not updated"));
-					p->resend_times = -1;
+					_notify_packets_lost(gc, 
+						_("Your attempt to update your info has timed out. Send the information again?"), p);
+					break;
+				case QQ_CMD_GET_USER_INFO:
+					_notify_packets_lost(gc, 
+						_("Your attempt to view a user's info has timed out. Try again?"), p);
+					break;
+				case QQ_CMD_ADD_FRIEND_WO_AUTH:
+					_notify_packets_lost(gc, 
+						_("Your attempt to add a buddy has timed out. Try again?"), p);
+					break;
+				case QQ_CMD_DEL_FRIEND:
+					_notify_packets_lost(gc, 
+						_("Your attempt to remove a buddy has timed out. Try again?"), p);
+					break;
+				case QQ_CMD_BUDDY_AUTH:
+					_notify_packets_lost(gc, 
+						_("Your attempt to add a buddy has timed out. Try again?"), p);
+					break;
+				case QQ_CMD_CHANGE_ONLINE_STATUS:
+					_notify_packets_lost(gc, 
+						_("Your attempt to change your online status has timed out. Send the information again?"), p);
+					break;
+				case QQ_CMD_SEND_IM:
+					_notify_packets_lost(gc, 
+						_("Your attempt to send an IM has timed out. Send it again?"), p);
+					break;
+				case QQ_CMD_REQUEST_KEY:
+					_notify_packets_lost(gc, 
+						_("Your request for a file transfer key has timed out. Request it again?"), p);
 					break;
 				default:{
-						need_action =
-						    gaim_prefs_get_bool("/plugins/prpl/qq/prompt_for_missing_packet");
-						if (!need_action)
-							p->resend_times = -1;	/* it will be removed next time */
-						else {	/* prompt for action */
-							gp = g_new0(gc_and_packet, 1);
-							gp->gc = gc;
-							gp->packet = p;
-							gaim_request_action
-							    (gc, NULL,
-							     _
-							     ("Send packet"),
-							     _
-							     ("Packets lost, send again?"),
-							     0, gp, 2,
-							     _("Send"),
-							     G_CALLBACK
-							     (_qq_send_again),
-							     _("Cancel"), G_CALLBACK(_qq_send_cancel));
-							/* will send once more, but only once */
-							p->resend_times++;
-						}
+					p->resend_times = -1;	/* it will be removed next time */
+					gaim_debug(GAIM_DEBUG_ERROR, "QQ", "%s packet lost!\n", qq_get_cmd_desc(p->cmd));
 					}
 				}
 			}