changeset 20311:66b73b0def79

This asked me to do a 3way merge in vim. Someone should check it. applied changes from 614efd22968bb59c279872f991d97f3053ded4f0 through cbefbdeb71c4fe12f131d0932abeaf81bea091cb
author Luke Schierer <lschiere@pidgin.im>
date Fri, 19 Oct 2007 17:18:40 +0000
parents 311000f10bb0
children eda97aca0b24 8e54d39743cd
files libpurple/protocols/msn/command.c
diffstat 1 files changed, 52 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/command.c	Fri Oct 19 17:11:34 2007 +0000
+++ b/libpurple/protocols/msn/command.c	Fri Oct 19 17:18:40 2007 +0000
@@ -36,6 +36,52 @@
 	return TRUE;
 }
 
+/*
+ * check the command is the command with payload content
+ *  if it is	return TRUE
+ *  else 		return FALSE
+ */
+static gboolean
+msn_check_payload_cmd(const char *str)
+{
+	g_return_val_if_fail(str != NULL, FALSE);
+	if( (!strcmp(str,"ADL")) ||
+		(!strcmp(str,"GCF")) ||
+		(!strcmp(str,"SG")) ||
+		(!strcmp(str,"MSG")) ||
+		(!strcmp(str,"RML")) ||
+		(!strcmp(str,"UBX")) ||
+		(!strcmp(str,"UBN")) ||
+		(!strcmp(str,"UUM")) ||
+		(!strcmp(str,"UBM")) ||
+		(!strcmp(str,"FQY")) ||
+		(!strcmp(str,"UUN")) ||
+		(!strcmp(str,"UUX")) ||
+		(is_num(str))){
+			return TRUE;
+		}
+
+	return FALSE;
+}
+
+/*
+ * set command Payload length
+ */
+static void
+msn_set_payload_len(MsnCommand *cmd)
+{
+	char *param;
+	int len = 0;
+
+	if (msn_check_payload_cmd(cmd->command) && (cmd->param_count > 0)){
+		param = cmd->params[cmd->param_count - 1];
+		len = is_num(param) ? atoi(param) : 0;
+	}
+
+	cmd->payload_len = len;
+}
+
+
 MsnCommand *
 msn_command_from_string(const char *string)
 {
@@ -70,7 +116,13 @@
 		cmd->trId = is_num(param) ? atoi(param) : 0;
 	}
 	else
+	{
 		cmd->trId = 0;
+	}
+
+	/*add payload Length checking*/
+	msn_set_payload_len(cmd);
+	purple_debug_info("MSNP14","get payload len:%d\n",cmd->payload_len);
 
 	msn_command_ref(cmd);