soc.2010.msn-tlc: 6af873e1: Replace magic numbers with the enumed Sl...

masca at cpw.pidgin.im masca at cpw.pidgin.im
Wed Jun 2 19:16:27 EDT 2010


-----------------------------------------------------------------
Revision: 6af873e129a81446e3e36143b64e6d4e628e9f4c
Ancestor: 198af8787bee2b92bcad264323c6f85a3eb55700
Author: masca at cpw.pidgin.im
Date: 2010-06-02T09:01:12
Branch: im.pidgin.soc.2010.msn-tlc
URL: http://d.pidgin.im/viewmtn/revision/info/6af873e129a81446e3e36143b64e6d4e628e9f4c

Modified files:
        libpurple/protocols/msn/slp.c
        libpurple/protocols/msn/slpcall.c
        libpurple/protocols/msn/slplink.c

ChangeLog: 

Replace magic numbers with the enumed SlpHeaderFlag.

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/slp.c	153e6fa85858c71e42eb824451aa16590f3d3623
+++ libpurple/protocols/msn/slp.c	e5f88f0e646d8bb4cf031761501f3b8c5441b605
@@ -518,7 +518,7 @@ got_sessionreq(MsnSlpCall *slpcall, cons
 			/* DATA */
 			slpmsg = msn_slpmsg_new(slplink);
 			slpmsg->slpcall = slpcall;
-			slpmsg->flags = 0x20;
+			slpmsg->flags = SLP_HF_MSN_OBJ_DATA;
 			slpmsg->info = "SLP DATA";
 			msn_slpmsg_set_image(slpmsg, img);
 			msn_slplink_queue_slpmsg(slplink, slpmsg);
============================================================
--- libpurple/protocols/msn/slpcall.c	3ab2406763f6e87d90439c80321d016cb8f51589
+++ libpurple/protocols/msn/slpcall.c	f2813c13816dc5d8ca5a40a961b963c9c39fdcaf
@@ -204,7 +204,7 @@ msn_slp_process_msg(MsnSlpLink *slplink,
 	body = slpmsg->buffer;
 	body_len = slpmsg->offset;
 
-	if (slpmsg->flags == 0x0 || slpmsg->flags == 0x1000000)
+	if (slpmsg->flags == SLP_HF_NO_FLAG || slpmsg->flags == SLP_HF_WML2009_COMP)
 	{
 		char *body_str;
 
@@ -265,9 +265,9 @@ msn_slp_process_msg(MsnSlpLink *slplink,
 		}
 		g_free(body_str);
 	}
-	else if (slpmsg->flags == 0x20 ||
-	         slpmsg->flags == 0x1000020 ||
-	         slpmsg->flags == 0x1000030)
+	else if (slpmsg->flags == SLP_HF_MSN_OBJ_DATA ||
+	         slpmsg->flags == SLP_HF_WML2009_COMP & SLP_HF_MSN_OBJ_DATA ||
+	         slpmsg->flags == SLP_HF_FILE_DATA)
 	{
 		slpcall = msn_slplink_find_slp_call_with_session_id(slplink, slpmsg->session_id);
 
@@ -293,7 +293,7 @@ msn_slp_process_msg(MsnSlpLink *slplink,
 			msn_slpcall_session_init(slpcall);
 	}
 #endif
-	else if (slpmsg->flags == 0x2)
+	else if (slpmsg->flags == SLP_HF_ACK)
 	{
 		/* Acknowledgement of previous message. Don't do anything currently. */
 	}
============================================================
--- libpurple/protocols/msn/slplink.c	1df1a2049667203aeca6e75594812bdd51a5b98e
+++ libpurple/protocols/msn/slplink.c	c51a106510d44c95be05c0e8e9094008f73913d2
@@ -294,7 +294,7 @@ msn_slplink_send_msgpart(MsnSlpLink *slp
 	 * reusing the same one all the time. */
 	msg = slpmsg->msg;
 
-	real_size = (slpmsg->flags == 0x2) ? 0 : slpmsg->size;
+	real_size = (slpmsg->flags == SLP_HF_ACK) ? 0 : slpmsg->size;
 
 	if (slpmsg->offset < real_size)
 	{
@@ -329,8 +329,9 @@ msn_slplink_send_msgpart(MsnSlpLink *slp
 		g_list_append(slpmsg->msgs, msn_message_ref(msg));
 	msn_slplink_send_msg(slplink, msg);
 
-	if ((slpmsg->flags == 0x20 || slpmsg->flags == 0x1000020 ||
-	     slpmsg->flags == 0x1000030) &&
+	if ((slpmsg->flags == SLP_HF_MSN_OBJ_DATA || 
+	     slpmsg->flags == (SLP_HF_WML2009_COMP & SLP_HF_MSN_OBJ_DATA) ||
+	     slpmsg->flags == SLP_HF_FILE_DATA) &&
 		(slpmsg->slpcall != NULL))
 	{
 		slpmsg->slpcall->progress = TRUE;
@@ -354,7 +355,7 @@ msg_ack(MsnMessage *msg, void *data)
 
 	slpmsg = data;
 
-	real_size = (slpmsg->flags == 0x2) ? 0 : slpmsg->size;
+	real_size = (slpmsg->flags == SLP_HF_ACK) ? 0 : slpmsg->size;
 
 	slpmsg->offset += msg->msnslp_header.length;
 
@@ -374,8 +375,9 @@ msg_ack(MsnMessage *msg, void *data)
 	else
 	{
 		/* The whole message has been sent */
-		if (slpmsg->flags == 0x20 ||
-		    slpmsg->flags == 0x1000020 || slpmsg->flags == 0x1000030)
+		if (slpmsg->flags == SLP_HF_MSN_OBJ_DATA ||
+	        slpmsg->flags == (SLP_HF_WML2009_COMP & SLP_HF_MSN_OBJ_DATA) ||
+	        slpmsg->flags == SLP_HF_FILE_DATA) 
 		{
 			if (slpmsg->slpcall != NULL)
 			{
@@ -411,20 +413,21 @@ msn_slplink_release_slpmsg(MsnSlpLink *s
 
 	slpmsg->msg = msg = msn_message_new_msnslp();
 
-	if (slpmsg->flags == 0x0)
+	if (slpmsg->flags == SLP_HF_NO_FLAG)
 	{
 		msg->msnslp_header.session_id = slpmsg->session_id;
 		msg->msnslp_header.ack_id = rand() % 0xFFFFFF00;
 	}
-	else if (slpmsg->flags == 0x2)
+	else if (slpmsg->flags == SLP_HF_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;
 	}
-	else if (slpmsg->flags == 0x20 ||
-	         slpmsg->flags == 0x1000020 || slpmsg->flags == 0x1000030)
+	else if (slpmsg->flags == SLP_HF_MSN_OBJ_DATA ||
+	         slpmsg->flags == (SLP_HF_WML2009_COMP & SLP_HF_MSN_OBJ_DATA) ||
+	         slpmsg->flags == SLP_HF_FILE_DATA)
 	{
 		MsnSlpCall *slpcall;
 		slpcall = slpmsg->slpcall;
@@ -497,7 +500,7 @@ msn_slplink_create_ack(MsnSlpLink *slpli
 
 	slpmsg->session_id = header->session_id;
 	slpmsg->size       = header->total_size;
-	slpmsg->flags      = 0x02;
+	slpmsg->flags      = SLP_HF_ACK;
 	slpmsg->ack_id     = header->id;
 	slpmsg->ack_sub_id = header->ack_id;
 	slpmsg->ack_size   = header->total_size;
@@ -535,7 +538,7 @@ send_file_cb(MsnSlpCall *slpcall)
 
 	slpmsg = msn_slpmsg_new(slpcall->slplink);
 	slpmsg->slpcall = slpcall;
-	slpmsg->flags = 0x1000030;
+	slpmsg->flags = SLP_HF_FILE_DATA;
 	slpmsg->info = "SLP FILE";
 	slpmsg->size = purple_xfer_get_size(xfer);
 
@@ -588,8 +591,9 @@ msn_slplink_process_msg(MsnSlpLink *slpl
 			slpmsg->slpcall = msn_slplink_find_slp_call_with_session_id(slplink, slpmsg->session_id);
 			if (slpmsg->slpcall != NULL)
 			{
-				if (slpmsg->flags == 0x20 ||
-				    slpmsg->flags == 0x1000020 || slpmsg->flags == 0x1000030)
+				if (slpmsg->flags == SLP_HF_MSN_OBJ_DATA ||
+					slpmsg->flags == (SLP_HF_WML2009_COMP & SLP_HF_MSN_OBJ_DATA) ||
+					slpmsg->flags == SLP_HF_FILE_DATA)
 				{
 					PurpleXfer *xfer = slpmsg->slpcall->xfer;
 					if (xfer != NULL)
@@ -653,8 +657,9 @@ msn_slplink_process_msg(MsnSlpLink *slpl
 		}
 	}
 
-	if ((slpmsg->flags == 0x20 ||
-	     slpmsg->flags == 0x1000020 || slpmsg->flags == 0x1000030) &&
+	if ((slpmsg->flags == SLP_HF_MSN_OBJ_DATA ||
+		slpmsg->flags == (SLP_HF_WML2009_COMP & SLP_HF_MSN_OBJ_DATA) ||
+		slpmsg->flags == SLP_HF_FILE_DATA) &&
 		(slpmsg->slpcall != NULL))
 	{
 		slpmsg->slpcall->progress = TRUE;
@@ -695,9 +700,10 @@ msn_slplink_process_msg(MsnSlpLink *slpl
 				msn_directconn_send_handshake(directconn);
 #endif
 		}
-		else if (slpmsg->flags == 0x00 || slpmsg->flags == 0x1000000 ||
-		         slpmsg->flags == 0x20 || slpmsg->flags == 0x1000020 ||
-		         slpmsg->flags == 0x1000030)
+		else if (slpmsg->flags == SLP_HF_NO_FLAG || slpmsg->flags == SLP_HF_WML2009_COMP ||
+			slpmsg->flags == SLP_HF_MSN_OBJ_DATA ||
+			slpmsg->flags == (SLP_HF_WML2009_COMP & SLP_HF_MSN_OBJ_DATA) ||
+			slpmsg->flags == SLP_HF_FILE_DATA)
 		{
 			/* Release all the messages and send the ACK */
 


More information about the Commits mailing list