diff libpurple/protocols/msn/slplink.c @ 30859:2c2ca0aed68e

Split a little more msn_slplink_process_msg. I think this way is easier to read.
author masca@cpw.pidgin.im
date Thu, 29 Jul 2010 20:54:50 +0000
parents 2d00d29a45fd
children 5ad928319db0
line wrap: on
line diff
--- a/libpurple/protocols/msn/slplink.c	Thu Jul 29 00:12:54 2010 +0000
+++ b/libpurple/protocols/msn/slplink.c	Thu Jul 29 20:54:50 2010 +0000
@@ -568,6 +568,29 @@
 		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 @@
 		}
 	}
 
-	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) ||