changeset 28211:9262c8f306a6

Send a cancel message for any unknown text/x-msmsgsinvite requests, so that your buddies won't be wondering why you never answered their invitation. This is used for stuff like Whiteboard and Application Sharing.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Mon, 10 Aug 2009 04:16:40 +0000
parents 2f7386e1c5d1
children 00836f1fde84
files libpurple/protocols/msn/msg.c
diffstat 1 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/msg.c	Sun Aug 09 07:29:01 2009 +0000
+++ b/libpurple/protocols/msn/msg.c	Mon Aug 10 04:16:40 2009 +0000
@@ -1102,6 +1102,7 @@
 {
 	GHashTable *body;
 	const gchar *guid;
+	gboolean accepted = FALSE;
 
 	g_return_if_fail(cmdproc != NULL);
 	g_return_if_fail(msg != NULL);
@@ -1129,6 +1130,9 @@
 		} else
 			purple_debug_warning("msn", "Invite msg missing "
 					"Application-GUID.\n");
+
+		accepted = TRUE;
+
 	} else if (!strcmp(guid, "{02D3C01F-BF30-4825-A83A-DE7AF41648AA}")) {
 		purple_debug_info("msn", "Computer call\n");
 
@@ -1160,6 +1164,30 @@
 		                     guid, application ? application : "(null)");
 	}
 
+	if (!accepted) {
+		const gchar *cookie = g_hash_table_lookup(body, "Invitation-Cookie");
+		if (cookie) {
+			MsnSwitchBoard *swboard = cmdproc->data;
+			char *text;
+			MsnMessage *cancel;
+
+			cancel = msn_message_new(MSN_MSG_TEXT);
+			msn_message_set_content_type(cancel, "text/x-msmsgsinvite");
+			msn_message_set_charset(cancel, "UTF-8");
+			msn_message_set_flag(cancel, 'U');
+
+			text = g_strdup_printf("Invitation-Command: CANCEL\r\n"
+			                       "Invitation-Cookie: %s\r\n"
+			                       "Cancel-Code: REJECT_NOT_INSTALLED\r\n",
+			                       cookie);
+			msn_message_set_bin_data(cancel, text, strlen(text));
+			g_free(text);
+
+			msn_switchboard_send_msg(swboard, cancel, TRUE);
+			msn_message_destroy(cancel);
+		}
+	}
+
 	g_hash_table_destroy(body);
 }