changeset 32037:1e657ff2eacb

Hide some offset occurrences and define a couple of abstractions in the v2 case.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Tue, 10 May 2011 03:09:47 +0000
parents cf702c6ab9e7
children f5fbcdd07d48
files libpurple/protocols/msn/p2p.c libpurple/protocols/msn/p2p.h libpurple/protocols/msn/slpcall.h libpurple/protocols/msn/slplink.c
diffstat 4 files changed, 31 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/p2p.c	Mon May 09 22:56:29 2011 +0000
+++ b/libpurple/protocols/msn/p2p.c	Tue May 10 03:09:47 2011 +0000
@@ -349,6 +349,7 @@
 
 		case MSN_P2P_VERSION_TWO:
 			/* Nothing to do! */
+			valid = TRUE;
 			break;
 
 		default:
@@ -359,6 +360,28 @@
 }
 
 gboolean
+msn_p2p_info_is_first(MsnP2PInfo *info)
+{
+	gboolean first = FALSE;
+
+	switch (info->version) {
+		case MSN_P2P_VERSION_ONE:
+			first = info->header.v1.offset == 0;
+			break;
+
+		case MSN_P2P_VERSION_TWO:
+			/* Nothing to do! */
+			first = info->header.v2.data_tf & TF_FIRST;
+			break;
+
+		default:
+			purple_debug_error("msn", "Invalid P2P Info version: %d\n", info->version);
+	}
+
+	return first;
+}
+
+gboolean
 msn_p2p_info_is_final(MsnP2PInfo *info)
 {
 	gboolean final = FALSE;
@@ -369,7 +392,7 @@
 			break;
 
 		case MSN_P2P_VERSION_TWO:
-			/* Nothing to do! */
+			final = msn_tlv_gettlv(info->header.v2.data_tlv, 0x01, 1) == NULL;
 			break;
 
 		default:
--- a/libpurple/protocols/msn/p2p.h	Mon May 09 22:56:29 2011 +0000
+++ b/libpurple/protocols/msn/p2p.h	Tue May 10 03:09:47 2011 +0000
@@ -189,6 +189,9 @@
 msn_p2p_info_is_valid(MsnP2PInfo *info);
 
 gboolean
+msn_p2p_info_is_first(MsnP2PInfo *info);
+
+gboolean
 msn_p2p_info_is_final(MsnP2PInfo *info);
 
 void
--- a/libpurple/protocols/msn/slpcall.h	Mon May 09 22:56:29 2011 +0000
+++ b/libpurple/protocols/msn/slpcall.h	Tue May 10 03:09:47 2011 +0000
@@ -65,7 +65,7 @@
 	gboolean wait_for_socket;
 
 	void (*progress_cb)(MsnSlpCall *slpcall,
-						gsize total_length, gsize len, gsize offset);
+						gsize total_length, gsize len);
 	void (*session_init_cb)(MsnSlpCall *slpcall);
 
 	/* Can be checksum, or smile */
--- a/libpurple/protocols/msn/slplink.c	Mon May 09 22:56:29 2011 +0000
+++ b/libpurple/protocols/msn/slplink.c	Tue May 10 03:09:47 2011 +0000
@@ -344,7 +344,7 @@
 		if (slpmsg->slpcall->progress_cb != NULL)
 		{
 			slpmsg->slpcall->progress_cb(slpmsg->slpcall, slpmsg->size,
-										 len, offset);
+										 len);
 		}
 	}
 
@@ -561,7 +561,6 @@
 {
 	MsnSlpMessage *slpmsg;
 	MsnP2PInfo *info;
-	guint64 offset;
 
 	info = part->info;
 
@@ -574,9 +573,7 @@
 		return;
 	}
 
-	offset = msn_p2p_info_get_offset(info);
-
-	if (offset == 0)
+	if (msn_p2p_info_is_first(info))
 		slpmsg = init_first_msg(slplink, info);
 	else {
 		guint32 session_id, id;
@@ -600,7 +597,7 @@
 		if (slpmsg->slpcall->progress_cb != NULL)
 		{
 			slpmsg->slpcall->progress_cb(slpmsg->slpcall, slpmsg->size,
-										 part->size, offset);
+										 part->size);
 		}
 	}