soc.2010.msn-tlc: 6a647441: Split a little more msn_slplink_process_...

masca at cpw.pidgin.im masca at cpw.pidgin.im
Thu Jul 29 21:37:04 EDT 2010


----------------------------------------------------------------------
Revision: 6a647441e1cdfd29518ba5113546591e58850e7a
Parent:   6601beab41218971580648c827ee68a1c02fb1ef
Author:   masca at cpw.pidgin.im
Date:     07/29/10 16:54:50
Branch:   im.pidgin.soc.2010.msn-tlc
URL: http://d.pidgin.im/viewmtn/revision/info/6a647441e1cdfd29518ba5113546591e58850e7a

Changelog: 

Split a little more msn_slplink_process_msg. I think this way is easier to read.

Changes against parent 6601beab41218971580648c827ee68a1c02fb1ef

  patched  libpurple/protocols/msn/slplink.c

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/slplink.c	0ed77905d98035a7c7bfe13ccfbc0e92a6645d49
+++ libpurple/protocols/msn/slplink.c	266a7c55b33a686b0514d1473b37c2445925450c
@@ -568,6 +568,29 @@ process_complete_msg(MsnSlpLink *slplink
 		msn_slpcall_destroy(slpcall);
 }
 
+static void
+slpmsg_add_part(MsnSlpMessage *slpmsg, MsnSlpMessagePart *part)
+{
+	if (slpmsg->ft) {
+		slpmsg->slpcall->u.incoming_data =
+				g_byte_array_append(slpmsg->slpcall->u.incoming_data, (const guchar *)part->buffer, part->size);
+		purple_xfer_prpl_ready(slpmsg->slpcall->xfer);
+	}
+	else if (slpmsg->size && slpmsg->buffer) {
+		if (G_MAXSIZE - part->size < part->header->offset
+				|| (part->header->offset + part->size) > slpmsg->size
+				|| slpmsg->offset != part->header->offset) {
+			purple_debug_error("msn",
+				"Oversized slpmsg - msgsize=%lld offset=%" G_GUINT64_FORMAT " len=%" G_GSIZE_FORMAT "\n",
+				slpmsg->size, part->header->offset, part->size);
+			g_return_if_reached();
+		} else {
+			memcpy(slpmsg->buffer + part->header->offset, part->buffer, part->size);
+			slpmsg->offset += part->size;
+		}
+	}
+}
+
 void
 msn_slplink_process_msg(MsnSlpLink *slplink, MsnSlpMessagePart *part)
 {
@@ -600,27 +623,7 @@ msn_slplink_process_msg(MsnSlpLink *slpl
 		}
 	}
 
-	if (slpmsg->ft)
-	{
-		slpmsg->slpcall->u.incoming_data =
-				g_byte_array_append(slpmsg->slpcall->u.incoming_data, (const guchar *)part->buffer, part->size);
-		purple_xfer_prpl_ready(slpmsg->slpcall->xfer);
-	}
-	else if (slpmsg->size && slpmsg->buffer)
-	{
-		if (G_MAXSIZE - part->size < offset
-				|| (offset + part->size) > slpmsg->size
-				|| slpmsg->offset != offset)
-		{
-			purple_debug_error("msn",
-				"Oversized slpmsg - msgsize=%lld offset=%" G_GUINT64_FORMAT " len=%" G_GSIZE_FORMAT "\n",
-				slpmsg->size, offset, part->size);
-			g_return_if_reached();
-		} else {
-			memcpy(slpmsg->buffer + offset, part->buffer, part->size);
-			slpmsg->offset += part->size;
-		}
-	}
+	slpmsg_add_part(slpmsg, part);
 
 	if ((slpmsg->flags == P2P_MSN_OBJ_DATA ||
 		slpmsg->flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) ||


More information about the Commits mailing list