diff src/protocols/msn/switchboard.c @ 11321:95fa774d216d

[gaim-migrate @ 13525] Kill off the conversation closed notices Fix for setting the ACK id on slpmsg ACKs which might improve things for other clients (see bug #1222320) Clean up some debugging stuff Add support for sending and receiving Nudges (Based on patch #1169352) Add an account action to go direct to a Hotmail Inbox committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Sun, 21 Aug 2005 17:14:22 +0000
parents 58c84363c8ae
children 17142948653e
line wrap: on
line diff
--- a/src/protocols/msn/switchboard.c	Sun Aug 21 17:01:43 2005 +0000
+++ b/src/protocols/msn/switchboard.c	Sun Aug 21 17:14:22 2005 +0000
@@ -29,8 +29,6 @@
 
 #include "error.h"
 
-/* #define MSN_DEBUG_SWBOARD */
-
 static MsnTable *cbs_table;
 
 static void msg_error_helper(MsnCmdProc *cmdproc, MsnMessage *msg,
@@ -72,7 +70,7 @@
 	MsnMessage *msg;
 	GList *l;
 
-#ifdef MSN_DEBUG_SWBOARD
+#ifdef MSN_DEBUG_SB
 	gaim_debug_info("msn", "switchboard_destroy: swboard(%p)\n", swboard);
 #endif
 
@@ -527,7 +525,9 @@
 
 	payload = msn_message_gen_payload(msg, &payload_len);
 
-	/* msn_message_show_readable(msg, "SB SEND", FALSE); */
+#ifdef MSN_DEBUG_SB
+	msn_message_show_readable(msg, "SB SEND", FALSE);
+#endif
 
 	trans = msn_transaction_new(cmdproc, "MSG", "%c %d",
 								msn_message_get_flag(msg), payload_len);
@@ -641,19 +641,8 @@
 	swboard = cmdproc->data;
 	user = cmd->params[0];
 
-#if 0
-	if (!(swboard->flag & MSN_SB_FLAG_IM))
-	{
-		/* TODO: This is a helper switchboard. It would be better if
-		 * swboard->conv is NULL, but it isn't. */
-		/* Umm? I think swboard->conv is NULL for all helper switchboards now? */
-		msn_switchboard_destroy(swboard);
-		return;
-	}
-#else
-	if (!(swboard->flag & MSN_SB_FLAG_IM))
+	if (!(swboard->flag & MSN_SB_FLAG_IM) && (swboard->conv != NULL))
 		gaim_debug_error("msn_switchboard", "bye_cmd: helper bug\n");
-#endif
 
 	if (swboard->conv == NULL)
 	{
@@ -672,28 +661,6 @@
 	else
 	{
 		/* This is a switchboard used for a im session */
-
-		if (cmd->param_count == 1)
-		{
-			char *username, *str;
-			GaimAccount *account;
-			GaimBuddy *b;
-
-			account = cmdproc->session->account;
-
-			if ((b = gaim_find_buddy(account, user)) != NULL)
-				username = g_markup_escape_text(gaim_buddy_get_alias(b), -1);
-			else
-				username = g_markup_escape_text(user, -1);
-
-			str = g_strdup_printf(_("%s has closed the conversation window."),
-								  username);
-
-			g_free(username);
-			msn_switchboard_report_user(swboard, GAIM_MESSAGE_SYSTEM, str);
-			g_free(str);
-		}
-
 		msn_switchboard_destroy(swboard);
 	}
 }
@@ -749,7 +716,9 @@
 	msg = msn_message_new_from_cmd(cmdproc->session, cmd);
 
 	msn_message_parse_payload(msg, payload, len);
-	/* msn_message_show_readable(msg, "SB RECV", FALSE); */
+#ifdef MSN_DEBUG_SB
+	msn_message_show_readable(msg, "SB RECV", FALSE);
+#endif
 
 	if (msg->remote_user != NULL)
 		g_free (msg->remote_user);
@@ -962,6 +931,30 @@
 #endif
 }
 
+void
+nudge_msg(MsnCmdProc *cmdproc, MsnMessage *msg)
+{
+	MsnSwitchBoard *swboard;
+	char *username, *str;
+	GaimAccount *account;
+	GaimBuddy *buddy;
+	const char *user;
+
+	swboard = cmdproc->data;
+	account = cmdproc->session->account;
+	user = msg->remote_user;
+
+	if ((buddy = gaim_find_buddy(account, user)) != NULL)
+		username = g_markup_escape_text(gaim_buddy_get_alias(buddy), -1);
+	else
+		username = g_markup_escape_text(user, -1);
+
+	str = g_strdup_printf(_("%s just sent you a Nudge!"), username);
+	g_free(username);
+	msn_switchboard_report_user(swboard, GAIM_MESSAGE_SYSTEM, str);
+	g_free(str);
+}
+
 /**************************************************************************
  * Connect stuff
  **************************************************************************/
@@ -1240,6 +1233,8 @@
 						   msn_p2p_msg);
 	msn_table_add_msg_type(cbs_table, "text/x-mms-emoticon",
 						   msn_emoticon_msg);
+	msn_table_add_msg_type(cbs_table, "text/x-msnmsgr-datacast",
+						   nudge_msg);
 #if 0
 	msn_table_add_msg_type(cbs_table, "text/x-msmmsginvite",
 						   msn_invite_msg);