pidgin: 4f1680aa: Add P2Pv2 ack'ing.

qulogic at pidgin.im qulogic at pidgin.im
Sat May 7 04:51:36 EDT 2011


----------------------------------------------------------------------
Revision: 4f1680aa9a16e4c8854c64f9f4509faf7df31255
Parent:   43961dedf5aa85dd12c391b7d6fbb0c7e3cf068b
Author:   qulogic at pidgin.im
Date:     05/07/11 03:29:47
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/4f1680aa9a16e4c8854c64f9f4509faf7df31255

Changelog: 

Add P2Pv2 ack'ing.

Changes against parent 43961dedf5aa85dd12c391b7d6fbb0c7e3cf068b

  patched  libpurple/protocols/msn/p2p.c
  patched  libpurple/protocols/msn/p2p.h
  patched  libpurple/protocols/msn/slpmsg.c

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/slpmsg.c	7b2c36165ce8cfe928c5427216b8e8b37c06a51a
+++ libpurple/protocols/msn/slpmsg.c	15d695b4fb3b023f62bf70fcf3d9c35e77897168
@@ -206,12 +206,8 @@ MsnSlpMessage *msn_slpmsg_ack_new(MsnP2P
 	slpmsg = msn_slpmsg_new(NULL);
 
 	new_info = slpmsg->p2p_info;
-	msn_p2p_info_set_session_id(new_info, msn_p2p_info_get_session_id(ack_info));
+	msn_p2p_info_create_ack(ack_info, new_info);
 	slpmsg->size = msn_p2p_info_get_total_size(ack_info);
-	msn_p2p_info_set_flags(new_info, P2P_ACK);
-	msn_p2p_info_set_ack_id(new_info, msn_p2p_info_get_id(ack_info));
-	msn_p2p_info_set_ack_sub_id(new_info, msn_p2p_info_get_ack_id(ack_info));
-	msn_p2p_info_set_ack_size(new_info, msn_p2p_info_get_total_size(ack_info));
 	slpmsg->info = "SLP ACK";
 
 	return slpmsg;
============================================================
--- libpurple/protocols/msn/p2p.h	465185fd70769f5a541d4689c3b872fc53e8a97e
+++ libpurple/protocols/msn/p2p.h	19fe0b8b2bd1d27078fe571f4423910bf442fe0f
@@ -191,6 +191,9 @@ msn_p2p_info_is_final(MsnP2PInfo *info);
 gboolean
 msn_p2p_info_is_final(MsnP2PInfo *info);
 
+void
+msn_p2p_info_create_ack(MsnP2PInfo *old_info, MsnP2PInfo *new_info);
+
 guint32
 msn_p2p_info_get_session_id(MsnP2PInfo *info);
 
============================================================
--- libpurple/protocols/msn/p2p.c	595f2ced5e1b148eef8bab3539657904954157f9
+++ libpurple/protocols/msn/p2p.c	e5a1d060b3fd1e2faf7aa8654db1fe2a30eacef5
@@ -362,6 +362,51 @@ msn_p2p_info_is_final(MsnP2PInfo *info)
 	return final;
 }
 
+void
+msn_p2p_info_create_ack(MsnP2PInfo *old_info, MsnP2PInfo *new_info)
+{
+	switch (old_info->version) {
+		case MSN_P2P_VERSION_ONE: {
+			MsnP2PHeader *old = &old_info->header.v1;
+			MsnP2PHeader *new = &new_info->header.v1;
+
+			new->session_id = old->session_id;
+			new->flags = P2P_ACK;
+			new->ack_id = old->id;
+			new->ack_sub_id = old->ack_id;
+			new->ack_size = old->total_size;
+			break;
+		}
+
+		case MSN_P2P_VERSION_TWO: {
+			MsnP2Pv2Header *old = &old_info->header.v2;
+			MsnP2Pv2Header *new = &new_info->header.v2;
+
+			msn_tlvlist_add_32(&new->header_tlv, P2P_TLV_TYPE_ACK, old->base_id + old->message_len);
+			new->opcode = P2P_OPCODE_NONE;
+
+			if (old->message_len > 0) {
+				if (!msn_tlv_gettlv(old->header_tlv, P2P_TLV_TYPE_ACK, 1)) {
+					if (old->opcode & P2P_OPCODE_SYN) {
+						msn_tlv_t *ack_tlv;
+						new->opcode |= P2P_OPCODE_RAK;
+						
+						ack_tlv = msn_tlv_gettlv(old->header_tlv, P2P_TLV_TYPE_PEER_INFO, 1);
+						if (ack_tlv) {
+							msn_tlvlist_add_tlv(&new->header_tlv, ack_tlv);
+							new->opcode |= P2P_OPCODE_SYN;
+						}
+					}
+				}
+			}
+			break;
+		}
+
+		default:
+			purple_debug_error("msn", "Invalid P2P Info version: %d\n", old_info->version);
+	}
+}
+
 guint32
 msn_p2p_info_get_session_id(MsnP2PInfo *info)
 {


More information about the Commits mailing list