changeset 31222:320c0852b5cc

Drop slp header and footer from MsnMessage in favor of MsnSlpMessage->header and footer.
author masca@cpw.pidgin.im
date Tue, 08 Jun 2010 21:26:39 +0000
parents 09f2a7d2ac99
children 64e2fe53acc2
files libpurple/protocols/msn/directconn.c libpurple/protocols/msn/msg.h libpurple/protocols/msn/slp.c libpurple/protocols/msn/slplink.c libpurple/protocols/msn/slpmsg.c
diffstat 5 files changed, 27 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/directconn.c	Tue Jun 08 21:21:49 2010 +0000
+++ b/libpurple/protocols/msn/directconn.c	Tue Jun 08 21:26:39 2010 +0000
@@ -548,7 +548,7 @@
 	length = msg->body_len + P2P_PACKET_HEADER_SIZE;
 	p = msn_dc_new_packet(length);
 
-	memcpy(p->data, &msg->msnslp_header, P2P_PACKET_HEADER_SIZE);
+	memcpy(p->data, msg->slpmsg->header, P2P_PACKET_HEADER_SIZE);
 	memcpy(p->data + P2P_PACKET_HEADER_SIZE, msg->body, msg->body_len);
 
 	p->sent_cb = msn_dc_send_packet_cb;
--- a/libpurple/protocols/msn/msg.h	Tue Jun 08 21:21:49 2010 +0000
+++ b/libpurple/protocols/msn/msg.h	Tue Jun 08 21:26:39 2010 +0000
@@ -58,7 +58,7 @@
 #include "session.h"
 #include "transaction.h"
 #include "user.h"
-#include "p2p.h"
+#include "slpmsg.h"
 
 typedef void (*MsnMsgCb)(MsnMessage *, void *data);
 
@@ -78,6 +78,7 @@
 	MsnMsgType type;
 
 	gboolean msnslp_message;
+	MsnSlpMessage *slpmsg;
 
 	char *remote_user;
 	char flag;
@@ -89,9 +90,6 @@
 	guint total_chunks;   /**< How many chunks in this multi-part message */
 	guint received_chunks; /**< How many chunks we've received so far */
 
-	MsnP2PHeader msnslp_header;
-	MsnP2PFooter msnslp_footer;
-
 	GHashTable *header_table;
 	GList *header_list;
 
--- a/libpurple/protocols/msn/slp.c	Tue Jun 08 21:21:49 2010 +0000
+++ b/libpurple/protocols/msn/slp.c	Tue Jun 08 21:26:39 2010 +0000
@@ -1112,7 +1112,7 @@
 
 	data = msn_message_get_bin_data(msg, &len);
 
-	msn_slplink_process_msg(slplink, &msg->msnslp_header, data, len);
+	msn_slplink_process_msg(slplink, msg->slpmsg->header, data, len);
 }
 
 static void
--- a/libpurple/protocols/msn/slplink.c	Tue Jun 08 21:21:49 2010 +0000
+++ b/libpurple/protocols/msn/slplink.c	Tue Jun 08 21:26:39 2010 +0000
@@ -319,8 +319,8 @@
 			msn_message_set_bin_data(msg, slpmsg->buffer + slpmsg->offset, len);
 		}
 
-		msg->msnslp_header.offset = slpmsg->offset;
-		msg->msnslp_header.length = len;
+		slpmsg->header->offset = slpmsg->offset;
+		slpmsg->header->length = len;
 	}
 
 	if (purple_debug_is_verbose())
@@ -362,7 +362,7 @@
 
 	real_size = (slpmsg->flags == P2P_ACK) ? 0 : slpmsg->size;
 
-	slpmsg->offset += msg->msnslp_header.length;
+	slpmsg->offset += msg->slpmsg->header->length;
 
 	slpmsg->msgs = g_list_remove(slpmsg->msgs, msg);
 
@@ -418,17 +418,21 @@
 
 	slpmsg->msg = msg = msn_message_new_msnslp();
 
+	msg->slpmsg = slpmsg;
+	msg->slpmsg->header = g_new0(MsnP2PHeader, 1);
+	msg->slpmsg->footer = g_new0(MsnP2PFooter, 1);
+
 	if (slpmsg->flags == P2P_NO_FLAG)
 	{
-		msg->msnslp_header.session_id = slpmsg->session_id;
-		msg->msnslp_header.ack_id = rand() % 0xFFFFFF00;
+		msg->slpmsg->header->session_id = slpmsg->session_id;
+		msg->slpmsg->header->ack_id = rand() % 0xFFFFFF00;
 	}
 	else if (slpmsg->flags == P2P_ACK)
 	{
-		msg->msnslp_header.session_id = slpmsg->session_id;
-		msg->msnslp_header.ack_id = slpmsg->ack_id;
-		msg->msnslp_header.ack_size = slpmsg->ack_size;
-		msg->msnslp_header.ack_sub_id = slpmsg->ack_sub_id;
+		msg->slpmsg->header->session_id = slpmsg->session_id;
+		msg->slpmsg->header->ack_id = slpmsg->ack_id;
+		msg->slpmsg->header->ack_size = slpmsg->ack_size;
+		msg->slpmsg->header->ack_sub_id = slpmsg->ack_sub_id;
 	}
 	else if (slpmsg->flags == P2P_MSN_OBJ_DATA ||
 	         slpmsg->flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) ||
@@ -438,21 +442,21 @@
 		slpcall = slpmsg->slpcall;
 
 		g_return_if_fail(slpcall != NULL);
-		msg->msnslp_header.session_id = slpcall->session_id;
-		msg->msnslp_footer.value = slpcall->app_id;
-		msg->msnslp_header.ack_id = rand() % 0xFFFFFF00;
+		msg->slpmsg->header->session_id = slpcall->session_id;
+		msg->slpmsg->footer->value = slpcall->app_id;
+		msg->slpmsg->header->ack_id = rand() % 0xFFFFFF00;
 	}
 	else if (slpmsg->flags == 0x100)
 	{
-		msg->msnslp_header.ack_id     = slpmsg->ack_id;
-		msg->msnslp_header.ack_sub_id = slpmsg->ack_sub_id;
-		msg->msnslp_header.ack_size   = slpmsg->ack_size;
+		msg->slpmsg->header->ack_id     = slpmsg->ack_id;
+		msg->slpmsg->header->ack_sub_id = slpmsg->ack_sub_id;
+		msg->slpmsg->header->ack_size   = slpmsg->ack_size;
 	}
 
-	msg->msnslp_header.id = slpmsg->id;
-	msg->msnslp_header.flags = slpmsg->flags;
+	msg->slpmsg->header->id = slpmsg->id;
+	msg->slpmsg->header->flags = (guint32)slpmsg->flags;
 
-	msg->msnslp_header.total_size = slpmsg->size;
+	msg->slpmsg->header->total_size = slpmsg->size;
 
 	passport = purple_normalize(slplink->session->account, slplink->remote_user);
 	msn_message_set_header(msg, "P2P-Dest", passport);
--- a/libpurple/protocols/msn/slpmsg.c	Tue Jun 08 21:21:49 2010 +0000
+++ b/libpurple/protocols/msn/slpmsg.c	Tue Jun 08 21:26:39 2010 +0000
@@ -172,7 +172,7 @@
 
 	text = FALSE;
 
-	flags = GUINT32_TO_LE(msg->msnslp_header.flags);
+	flags = GUINT32_TO_LE(msg->slpmsg->header->flags);
 
 	switch (flags)
 	{