soc.2010.msn-tlc: 39e9d0d3: Move more SlpMessage creation to its mod...

masca at cpw.pidgin.im masca at cpw.pidgin.im
Sat Jun 12 17:45:53 EDT 2010


-----------------------------------------------------------------
Revision: 39e9d0d35f265ccc2eda57be427140e9a587fc2f
Ancestor: 2f970e541e55b8bed161082b2fff07f59f12fae4
Author: masca at cpw.pidgin.im
Date: 2010-06-12T21:22:06
Branch: im.pidgin.soc.2010.msn-tlc
URL: http://d.pidgin.im/viewmtn/revision/info/39e9d0d35f265ccc2eda57be427140e9a587fc2f

Modified files:
        libpurple/protocols/msn/slp.c
        libpurple/protocols/msn/slplink.c
        libpurple/protocols/msn/slpmsg.c
        libpurple/protocols/msn/slpmsg.h

ChangeLog: 

Move more SlpMessage creation to its module.

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/slp.c	f88c999f8ae623e7ecb6fb87d4e1be9d8908ea1f
+++ libpurple/protocols/msn/slp.c	8a50a90b765b9fc7a4013b8f1c1ca062c3a4100a
@@ -509,19 +509,13 @@ got_sessionreq(MsnSlpCall *slpcall, cons
 
 		if (img != NULL) {
 			/* DATA PREP */
-			slpmsg = msn_slpmsg_new(slplink);
-			slpmsg->slpcall = slpcall;
-			slpmsg->session_id = slpcall->session_id;
-			msn_slpmsg_set_body(slpmsg, NULL, 4);
-			slpmsg->info = "SLP DATA PREP";
+			slpmsg = msn_slpmsg_new_dataprep(slpcall);
+			msn_slpmsg_set_slplink(slpmsg, slplink);
 			msn_slplink_queue_slpmsg(slplink, slpmsg);
 
 			/* DATA */
-			slpmsg = msn_slpmsg_new(slplink);
-			slpmsg->slpcall = slpcall;
-			slpmsg->flags = P2P_MSN_OBJ_DATA;
-			slpmsg->info = "SLP DATA";
-			msn_slpmsg_set_image(slpmsg, img);
+			slpmsg = msn_slpmsg_new_obj(slpcall, img);
+			msn_slpmsg_set_slplink(slpmsg, slplink);
 			msn_slplink_queue_slpmsg(slplink, slpmsg);
 			purple_imgstore_unref(img);
 
============================================================
--- libpurple/protocols/msn/slplink.c	d2bb985a259189ec94fd206c584e9cb96fb90e86
+++ libpurple/protocols/msn/slplink.c	1f00da23217b1437e514e12fb5a4913227dce5a6
@@ -538,11 +538,8 @@ send_file_cb(MsnSlpCall *slpcall)
 	}
 	purple_xfer_unref(xfer);
 
-	slpmsg = msn_slpmsg_new(slpcall->slplink);
-	slpmsg->slpcall = slpcall;
-	slpmsg->flags = P2P_FILE_DATA;
-	slpmsg->info = "SLP FILE";
-	slpmsg->size = purple_xfer_get_size(xfer);
+	slpmsg = msn_slpmsg_new_file(slpcall, purple_xfer_get_size(xfer));
+	msn_slpmsg_set_slplink(slpmsg, slpcall->slplink);
 
 	msn_slplink_send_slpmsg(slpcall->slplink, slpmsg);
 }
============================================================
--- libpurple/protocols/msn/slpmsg.c	d1957d9f3598d5c6a9cbd2c32390923005466b56
+++ libpurple/protocols/msn/slpmsg.c	bb2aeab4fa57ecd93d19017da57649702c4681e6
@@ -280,6 +280,48 @@ MsnSlpMessage *msn_slpmsg_new_ack(MsnP2P
 	return slpmsg;
 }
 
+MsnSlpMessage *msn_slpmsg_new_obj(MsnSlpCall *slpcall,PurpleStoredImage *img)
+{
+	MsnSlpMessage *slpmsg;
+
+	slpmsg = msn_slpmsg_new(NULL);
+	slpmsg->slpcall = slpcall;
+	slpmsg->flags = P2P_MSN_OBJ_DATA;
+	slpmsg->info = "SLP DATA";
+
+	msn_slpmsg_set_image(slpmsg, img);
+
+	return slpmsg;
+}
+
+MsnSlpMessage *msn_slpmsg_new_dataprep(MsnSlpCall *slpcall)
+{
+	MsnSlpMessage *slpmsg;
+
+	slpmsg = msn_slpmsg_new(NULL);
+	slpmsg->slpcall = slpcall;
+	slpmsg->session_id = slpcall->session_id;
+	msn_slpmsg_set_body(slpmsg, NULL, 4);
+	slpmsg->info = "SLP DATA PREP";
+
+	return slpmsg;
+
+}
+
+MsnSlpMessage *msn_slpmsg_new_file(MsnSlpCall *slpcall, size_t size)
+{
+	MsnSlpMessage *slpmsg;
+
+	slpmsg = msn_slpmsg_new(NULL);
+
+	slpmsg->slpcall = slpcall;
+	slpmsg->flags = P2P_FILE_DATA;
+	slpmsg->info = "SLP FILE";
+	slpmsg->size = size;
+
+	return slpmsg;
+}
+
 char *msn_slpmsg_serialize(MsnSlpMessage *slpmsg, size_t *ret_size)
 {
 	MsnP2PHeader *header;
============================================================
--- libpurple/protocols/msn/slpmsg.h	7926313e7301651878b108b0360050dd631e3795
+++ libpurple/protocols/msn/slpmsg.h	2e10f8f669df5d84cc962252515db2d833995c46
@@ -138,6 +138,35 @@ MsnSlpMessage *msn_slpmsg_new_ack(MsnP2P
  */
 MsnSlpMessage *msn_slpmsg_new_ack(MsnP2PHeader *header);
 
+/**
+ * Create a new SLP message for MsnObject data.
+ *
+ * @param slpcall 	The slpcall that manages this message.
+ * @param img 		The image to be sent in this message.
+ *
+ * @return A new SlpMessage with MsnObject info.
+ */
+MsnSlpMessage *msn_slpmsg_new_obj(MsnSlpCall *slpcall, PurpleStoredImage *img);
+
+/**
+ * Create a new SLP message for data preparation.
+ *
+ * @param slpcall 	The slpcall that manages this message.
+ * 
+ * @return A new SlpMessage with data preparation info.
+ */
+MsnSlpMessage *msn_slpmsg_new_dataprep(MsnSlpCall *slpcall);
+
+/**
+ * Create a new SLP message for File transfer.
+ *
+ * @param slpcall 	The slpcall that manages this message.
+ * @param size 		The size of the file being transsmited.
+ *
+ * @return A new SlpMessage with the file transfer info.
+ */
+MsnSlpMessage *msn_slpmsg_new_file(MsnSlpCall *slpcall, size_t size);
+
 void msn_slpmsg_show(MsnMessage *msg);
 
 /**


More information about the Commits mailing list