changeset 30868:5964f65c17ed

Avoid duplicated code using a util function to check the flags.
author masca@cpw.pidgin.im
date Thu, 05 Aug 2010 23:42:42 +0000
parents 6b73ff4fcc69
children 320c6eb04e11
files libpurple/protocols/msn/p2p.c libpurple/protocols/msn/p2p.h libpurple/protocols/msn/slpcall.c libpurple/protocols/msn/slplink.c
diffstat 4 files changed, 18 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/p2p.c	Thu Aug 05 23:16:49 2010 +0000
+++ b/libpurple/protocols/msn/p2p.c	Thu Aug 05 23:42:42 2010 +0000
@@ -67,3 +67,10 @@
 	return wire;
 }
 
+gboolean
+msn_p2p_msg_is_data(const MsnP2PHeaderFlag flags)
+{
+	return (flags == P2P_MSN_OBJ_DATA ||
+	        flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) ||
+	        flags == P2P_FILE_DATA);
+}
--- a/libpurple/protocols/msn/p2p.h	Thu Aug 05 23:16:49 2010 +0000
+++ b/libpurple/protocols/msn/p2p.h	Thu Aug 05 23:42:42 2010 +0000
@@ -82,4 +82,7 @@
 MsnP2PFooter *
 msn_p2p_footer_to_wire(MsnP2PFooter *footer);
 
+gboolean
+msn_p2p_msg_is_data(const MsnP2PHeaderFlag flags);
+
 #endif /* MSN_P2P_H */
--- a/libpurple/protocols/msn/slpcall.c	Thu Aug 05 23:16:49 2010 +0000
+++ b/libpurple/protocols/msn/slpcall.c	Thu Aug 05 23:42:42 2010 +0000
@@ -1123,9 +1123,7 @@
 		}
 		g_free(body_str);
 	}
-	else if (slpmsg->flags == P2P_MSN_OBJ_DATA ||
-	         slpmsg->flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) ||
-	         slpmsg->flags == P2P_FILE_DATA)
+	 else if (msn_p2p_msg_is_data(slpmsg->flags))
 	{
 		slpcall = msn_slplink_find_slp_call_with_session_id(slplink, slpmsg->header->session_id);
 
--- a/libpurple/protocols/msn/slplink.c	Thu Aug 05 23:16:49 2010 +0000
+++ b/libpurple/protocols/msn/slplink.c	Thu Aug 05 23:42:42 2010 +0000
@@ -332,9 +332,8 @@
 	slpmsg->parts = g_list_append(slpmsg->parts, part);
 	msn_slplink_send_part(slplink, part);
 
-	if ((slpmsg->flags == P2P_MSN_OBJ_DATA || 
-	     slpmsg->flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) ||
-	     slpmsg->flags == P2P_FILE_DATA) &&
+
+	if (msn_p2p_msg_is_data(slpmsg->flags) &&
 		(slpmsg->slpcall != NULL))
 	{
 		slpmsg->slpcall->progress = TRUE;
@@ -359,9 +358,7 @@
 	{
 		slpmsg->header->ack_id = rand() % 0xFFFFFF00;
 	}
-	else if (slpmsg->flags == P2P_MSN_OBJ_DATA ||
-	         slpmsg->flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) ||
-	         slpmsg->flags == P2P_FILE_DATA)
+	else if (msn_p2p_msg_is_data(slpmsg->flags))
 	{
 		MsnSlpCall *slpcall;
 		slpcall = slpmsg->slpcall;
@@ -462,9 +459,7 @@
 		slpmsg->slpcall = msn_slplink_find_slp_call_with_session_id(slplink, slpmsg->header->session_id);
 		if (slpmsg->slpcall != NULL)
 		{
-			if (slpmsg->flags == P2P_MSN_OBJ_DATA ||
-					slpmsg->flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) ||
-					slpmsg->flags == P2P_FILE_DATA)
+			if (msn_p2p_msg_is_data(slpmsg->flags))
 			{
 				PurpleXfer *xfer = slpmsg->slpcall->xfer;
 				if (xfer != NULL)
@@ -525,9 +520,7 @@
 #endif
 	}
 	else if (slpmsg->flags == P2P_NO_FLAG || slpmsg->flags == P2P_WML2009_COMP ||
-			slpmsg->flags == P2P_MSN_OBJ_DATA ||
-			slpmsg->flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) ||
-			slpmsg->flags == P2P_FILE_DATA)
+			msn_p2p_msg_is_data(slpmsg->flags))
 	{
 		/* Release all the messages and send the ACK */
 
@@ -612,9 +605,8 @@
 
 	slpmsg_add_part(slpmsg, part);
 
-	if ((slpmsg->flags == P2P_MSN_OBJ_DATA ||
-		slpmsg->flags == (P2P_WML2009_COMP | P2P_MSN_OBJ_DATA) ||
-		slpmsg->flags == P2P_FILE_DATA) &&
+
+	if (msn_p2p_msg_is_data(slpmsg->flags) &&
 		(slpmsg->slpcall != NULL))
 	{
 		slpmsg->slpcall->progress = TRUE;