changeset 27928:13c2fb2da4eb

- moved msn_plain_msg() and msn_control_msg() as upstream. - a bit clean up msn_plain_msg().
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Mon, 02 Feb 2009 12:10:33 +0000
parents 1102f8642bd1
children 03279387cbe2
files libpurple/protocols/msn/msg.c libpurple/protocols/msn/switchboard.c
diffstat 2 files changed, 15 insertions(+), 118 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/msg.c	Mon Feb 02 05:34:19 2009 +0000
+++ b/libpurple/protocols/msn/msg.c	Mon Feb 02 12:10:33 2009 +0000
@@ -820,14 +820,15 @@
 	char *body_str;
 	char *body_enc;
 	char *body_final;
-	size_t body_len;
+	char *yaz_body_final;
+	size_t body_len, new_len;
 	const char *passport;
 	const char *value;
 
 	gc = cmdproc->session->account->gc;
 
 	body = msn_message_get_bin_data(msg, &body_len);
-	body_str = g_strndup(body, body_len);
+	body_str = sanitize_utf(body, body_len, &new_len);
 	body_enc = g_markup_escape_text(body_str, -1);
 	g_free(body_str);
 
@@ -864,23 +865,30 @@
 		body_final = body_enc;
 	}
 
+	/* yaz */
+	/* replace 0D 0A with <br> */
+	yaz_body_final = purple_strreplace(body_final, "\r\n", "<br>");
+//	purple_debug_info("yaz msn", "yaz_body_final=%s\n", yaz_body_final);
+	g_free(body_final);
+	body_final = yaz_body_final;
+
 	if (cmdproc->servconn->type == MSN_SERVCONN_SB) {
 		MsnSwitchBoard *swboard = cmdproc->data;
 
 		swboard->flag |= MSN_SB_FLAG_IM;
 
 		if (swboard->current_users > 1 ||
-			((swboard->conv != NULL) &&
-			 purple_conversation_get_type(swboard->conv) == PURPLE_CONV_TYPE_CHAT))
+		    ((swboard->conv != NULL) &&
+		     purple_conversation_get_type(swboard->conv) == PURPLE_CONV_TYPE_CHAT))
 		{
 			/* If current_users is always ok as it should then there is no need to
 			 * check if this is a chat. */
 			if (swboard->current_users <= 1)
 				purple_debug_misc("msn", "plain_msg: current_users(%d)\n",
-								swboard->current_users);
+						  swboard->current_users);
 
 			serv_got_chat_in(gc, swboard->chat_id, passport, 0, body_final,
-							 time(NULL));
+					 time(NULL));
 			if (swboard->conv == NULL)
 			{
 				swboard->conv = purple_find_chat(gc, swboard->chat_id);
@@ -893,7 +901,7 @@
 			if (swboard->conv == NULL)
 			{
 				swboard->conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM,
-										passport, purple_connection_get_account(gc));
+										      passport, purple_connection_get_account(gc));
 				swboard->flag |= MSN_SB_FLAG_IM;
 			}
 		}
--- a/libpurple/protocols/msn/switchboard.c	Mon Feb 02 05:34:19 2009 +0000
+++ b/libpurple/protocols/msn/switchboard.c	Mon Feb 02 12:10:33 2009 +0000
@@ -887,117 +887,6 @@
  * Message Handlers
  **************************************************************************/
 static void
-plain_msg(MsnCmdProc *cmdproc, MsnMessage *msg)
-{
-	PurpleConnection *gc;
-	MsnSwitchBoard *swboard;
-	const char *body;
-	char *body_str;
-	char *body_enc;
-	char *body_final;
-	size_t body_len, new_len;
-	const char *passport;
-	const char *value;
-
-	gc = cmdproc->session->account->gc;
-	swboard = cmdproc->data;
-
-	body = msn_message_get_bin_data(msg, &body_len);
-	body_str = sanitize_utf(body, body_len, &new_len);
-	body_enc = g_markup_escape_text(body_str, -1);
-	g_free(body_str);
-
-	passport = msg->remote_user;
-
-	if (!strcmp(passport, "messenger@microsoft.com") &&
-		strstr(body, "immediate security update"))
-	{
-		return;
-	}
-
-#if 0
-	if ((value = msn_message_get_attr(msg, "User-Agent")) != NULL)
-	{
-		purple_debug_misc("msn", "User-Agent = '%s'\n", value);
-	}
-#endif
-
-	if ((value = msn_message_get_attr(msg, "X-MMS-IM-Format")) != NULL)
-	{
-		char *pre, *post;
-
-		msn_parse_format(value, &pre, &post);
-
-		body_final = g_strdup_printf("%s%s%s", pre ? pre : "",
-									 body_enc ? body_enc : "", post ? post : "");
-
-		g_free(pre);
-		g_free(post);
-		g_free(body_enc);
-	}
-	else
-	{
-		body_final = body_enc;
-	}
-
-	swboard->flag |= MSN_SB_FLAG_IM;
-
-	if (swboard->current_users > 1 ||
-		((swboard->conv != NULL) &&
-		 purple_conversation_get_type(swboard->conv) == PURPLE_CONV_TYPE_CHAT))
-	{
-		/* If current_users is always ok as it should then there is no need to
-		 * check if this is a chat. */
-		if (swboard->current_users <= 1)
-			purple_debug_misc("msn", "plain_msg: current_users(%d)\n",
-							swboard->current_users);
-
-		serv_got_chat_in(gc, swboard->chat_id, passport, 0, body_final,
-						 time(NULL));
-		if (swboard->conv == NULL)
-		{
-			swboard->conv = purple_find_chat(gc, swboard->chat_id);
-			swboard->flag |= MSN_SB_FLAG_IM;
-		}
-	}
-	else
-	{
-		char *yaz_body_final;
-		yaz_body_final = purple_strreplace(body_final, "\r\n", "<br>"); // replace 0D 0A with <br>
-		purple_debug_info("yaz msn", "yaz_body_final=%s\n", yaz_body_final);
-		serv_got_im(gc, passport, yaz_body_final, 0, time(NULL));
-		if (swboard->conv == NULL)
-		{
-			swboard->conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM,
-									passport, purple_connection_get_account(gc));
-			swboard->flag |= MSN_SB_FLAG_IM;
-		}
-		g_free(yaz_body_final);
-	}
-
-	g_free(body_final);
-}
-
-static void
-control_msg(MsnCmdProc *cmdproc, MsnMessage *msg)
-{
-	PurpleConnection *gc;
-	MsnSwitchBoard *swboard;
-	char *passport;
-
-	gc = cmdproc->session->account->gc;
-	swboard = cmdproc->data;
-	passport = msg->remote_user;
-
-	if (swboard->current_users == 1 &&
-		msn_message_get_attr(msg, "TypingUser") != NULL)
-	{
-		serv_got_typing(gc, passport, MSN_TYPING_RECV_TIMEOUT,
-						PURPLE_TYPING);
-	}
-}
-
-static void
 clientcaps_msg(MsnCmdProc *cmdproc, MsnMessage *msg)
 {
 #if 0