changeset 31568:50ca9e64186b

Only send acks on p2pv2 when required.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 07 May 2011 07:49:25 +0000
parents 968103d932d6
children eb1bbaae3427
files libpurple/protocols/msn/p2p.c libpurple/protocols/msn/p2p.h libpurple/protocols/msn/slplink.c
diffstat 3 files changed, 29 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/p2p.c	Sat May 07 07:29:47 2011 +0000
+++ b/libpurple/protocols/msn/p2p.c	Sat May 07 07:49:25 2011 +0000
@@ -407,6 +407,31 @@
 	}
 }
 
+gboolean
+msn_p2p_info_require_ack(MsnP2PInfo *info)
+{
+	gboolean ret = FALSE;
+
+	switch (info->version) {
+		case MSN_P2P_VERSION_ONE: {
+			guint32 flags = msn_p2p_info_get_flags(info);
+
+			ret = flags == P2P_NO_FLAG || flags == P2P_WLM2009_COMP ||
+			      msn_p2p_msg_is_data(flags);
+			break;
+		}
+
+		case MSN_P2P_VERSION_TWO:
+			ret = (info->header.v2.opcode & P2P_OPCODE_RAK) > 0;
+			break;
+
+		default:
+			purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
+	}
+
+	return ret;
+}
+
 guint32
 msn_p2p_info_get_session_id(MsnP2PInfo *info)
 {
--- a/libpurple/protocols/msn/p2p.h	Sat May 07 07:29:47 2011 +0000
+++ b/libpurple/protocols/msn/p2p.h	Sat May 07 07:49:25 2011 +0000
@@ -194,6 +194,9 @@
 void
 msn_p2p_info_create_ack(MsnP2PInfo *old_info, MsnP2PInfo *new_info);
 
+gboolean
+msn_p2p_info_require_ack(MsnP2PInfo *info);
+
 guint32
 msn_p2p_info_get_session_id(MsnP2PInfo *info);
 
--- a/libpurple/protocols/msn/slplink.c	Sat May 07 07:29:47 2011 +0000
+++ b/libpurple/protocols/msn/slplink.c	Sat May 07 07:49:25 2011 +0000
@@ -502,7 +502,6 @@
 process_complete_msg(MsnSlpLink *slplink, MsnSlpMessage *slpmsg, MsnP2PInfo *info)
 {
 	MsnSlpCall *slpcall;
-	guint32 flags;
 
 	slpcall = msn_slp_process_msg(slplink, slpmsg);
 
@@ -513,10 +512,7 @@
 
 	purple_debug_info("msn", "msn_slplink_process_msg: slpmsg complete\n");
 
-	flags = msn_p2p_info_get_flags(slpmsg->p2p_info);
-
-	if (flags == P2P_NO_FLAG || flags == P2P_WLM2009_COMP ||
-	    msn_p2p_msg_is_data(flags))
+	if (msn_p2p_info_require_ack(slpmsg->p2p_info))
 	{
 		/* Release all the messages and send the ACK */