changeset 31231:f84fb808e8ed

Move MsnMessage stuff out of slplink to SBConn.
author masca@cpw.pidgin.im
date Tue, 15 Jun 2010 00:42:05 +0000
parents 9192c59f2f84
children 4481d04cda70
files libpurple/protocols/msn/Makefile.am libpurple/protocols/msn/Makefile.mingw libpurple/protocols/msn/sbconn.c libpurple/protocols/msn/sbconn.h libpurple/protocols/msn/slplink.c
diffstat 5 files changed, 76 insertions(+), 61 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/Makefile.am	Sat Jun 12 21:38:32 2010 +0000
+++ b/libpurple/protocols/msn/Makefile.am	Tue Jun 15 00:42:05 2010 +0000
@@ -54,6 +54,8 @@
 	soap.h \
 	state.c \
 	state.h \
+	sbconn.c \
+	sbconn.h \
 	switchboard.c \
 	switchboard.h \
 	table.c \
--- a/libpurple/protocols/msn/Makefile.mingw	Sat Jun 12 21:38:32 2010 +0000
+++ b/libpurple/protocols/msn/Makefile.mingw	Tue Jun 15 00:42:05 2010 +0000
@@ -62,6 +62,7 @@
 			slpmsg.c \
 			soap.c\
 			state.c \
+			sbconn.c \
 			switchboard.c \
 			sync.c \
 			table.c \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/protocols/msn/sbconn.c	Tue Jun 15 00:42:05 2010 +0000
@@ -0,0 +1,61 @@
+#include "sbconn.h"
+
+/* We have received the message ack */
+void
+msn_sbconn_msg_ack(MsnMessage *msg, void *data)
+{
+	MsnSlpMessage *slpmsg;
+	long long real_size;
+
+	slpmsg = data;
+
+	real_size = (slpmsg->flags == P2P_ACK) ? 0 : slpmsg->size;
+
+	slpmsg->offset += msg->slpmsg->header->length;
+
+	slpmsg->msgs = g_list_remove(slpmsg->msgs, msg);
+
+	if (slpmsg->offset < real_size)
+	{
+		if (slpmsg->slpcall->xfer && purple_xfer_get_status(slpmsg->slpcall->xfer) == PURPLE_XFER_STATUS_STARTED)
+		{
+			slpmsg->slpcall->xfer_msg = slpmsg;
+			msn_message_ref(msg);
+			purple_xfer_prpl_ready(slpmsg->slpcall->xfer);
+		}
+		else
+			msn_slplink_send_msgpart(slpmsg->slplink, slpmsg);
+	}
+	else
+	{
+		/* The whole message has been sent */
+		if (slpmsg->flags == P2P_MSN_OBJ_DATA ||
+	        slpmsg->flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) ||
+	        slpmsg->flags == P2P_FILE_DATA) 
+		{
+			if (slpmsg->slpcall != NULL)
+			{
+				if (slpmsg->slpcall->cb)
+					slpmsg->slpcall->cb(slpmsg->slpcall,
+						NULL, 0);
+			}
+		}
+	}
+
+	msn_message_unref(msg);
+}
+
+/* We have received the message nak. */
+void
+msn_sbconn_msg_nak(MsnMessage *msg, void *data)
+{
+	MsnSlpMessage *slpmsg;
+
+	slpmsg = data;
+
+	msn_slplink_send_msgpart(slpmsg->slplink, slpmsg);
+
+	slpmsg->msgs = g_list_remove(slpmsg->msgs, msg);
+	msn_message_unref(msg);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/protocols/msn/sbconn.h	Tue Jun 15 00:42:05 2010 +0000
@@ -0,0 +1,9 @@
+#ifndef MSN_SBCONN_H
+#define MSN_SBCONN_H
+
+#include "msg.h"
+
+void msn_sbconn_msg_ack(MsnMessage *msg, void *data);
+
+void msn_sbconn_msg_nak(MsnMessage *msg, void *data);
+#endif /* MSN_SBCONN_H */
--- a/libpurple/protocols/msn/slplink.c	Sat Jun 12 21:38:32 2010 +0000
+++ b/libpurple/protocols/msn/slplink.c	Tue Jun 15 00:42:05 2010 +0000
@@ -28,6 +28,7 @@
 #include "msn.h"
 #include "slplink.h"
 
+#include "sbconn.h"
 #include "switchboard.h"
 #include "slp.h"
 #include "p2p.h"
@@ -351,65 +352,6 @@
 	/* slpmsg->offset += len; */
 }
 
-/* We have received the message ack */
-static void
-msg_ack(MsnMessage *msg, void *data)
-{
-	MsnSlpMessage *slpmsg;
-	long long real_size;
-
-	slpmsg = data;
-
-	real_size = (slpmsg->flags == P2P_ACK) ? 0 : slpmsg->size;
-
-	slpmsg->offset += msg->slpmsg->header->length;
-
-	slpmsg->msgs = g_list_remove(slpmsg->msgs, msg);
-
-	if (slpmsg->offset < real_size)
-	{
-		if (slpmsg->slpcall->xfer && purple_xfer_get_status(slpmsg->slpcall->xfer) == PURPLE_XFER_STATUS_STARTED)
-		{
-			slpmsg->slpcall->xfer_msg = slpmsg;
-			msn_message_ref(msg);
-			purple_xfer_prpl_ready(slpmsg->slpcall->xfer);
-		}
-		else
-			msn_slplink_send_msgpart(slpmsg->slplink, slpmsg);
-	}
-	else
-	{
-		/* The whole message has been sent */
-		if (slpmsg->flags == P2P_MSN_OBJ_DATA ||
-	        slpmsg->flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) ||
-	        slpmsg->flags == P2P_FILE_DATA) 
-		{
-			if (slpmsg->slpcall != NULL)
-			{
-				if (slpmsg->slpcall->cb)
-					slpmsg->slpcall->cb(slpmsg->slpcall,
-						NULL, 0);
-			}
-		}
-	}
-
-	msn_message_unref(msg);
-}
-
-/* We have received the message nak. */
-static void
-msg_nak(MsnMessage *msg, void *data)
-{
-	MsnSlpMessage *slpmsg;
-
-	slpmsg = data;
-
-	msn_slplink_send_msgpart(slpmsg->slplink, slpmsg);
-
-	slpmsg->msgs = g_list_remove(slpmsg->msgs, msg);
-	msn_message_unref(msg);
-}
-
 static void
 msn_slplink_release_slpmsg(MsnSlpLink *slplink, MsnSlpMessage *slpmsg)
 {
@@ -461,8 +403,8 @@
 	passport = purple_normalize(slplink->session->account, slplink->remote_user);
 	msn_message_set_header(msg, "P2P-Dest", passport);
 
-	msg->ack_cb = msg_ack;
-	msg->nak_cb = msg_nak;
+	msg->ack_cb = msn_sbconn_msg_ack;
+	msg->nak_cb = msn_sbconn_msg_nak;
 	msg->ack_data = slpmsg;
 
 	msn_slplink_send_msgpart(slplink, slpmsg);