pidgin: 0ed16a63: Notify the user if a contact invites the...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Wed Apr 8 21:40:42 EDT 2009


-----------------------------------------------------------------
Revision: 0ed16a6303234ba80205566fdece672867c7e4a0
Ancestor: 70c87d1707d48439fed0e2545ddd96c4714a69f1
Author: maiku at soc.pidgin.im
Date: 2009-04-09T01:38:23
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/0ed16a6303234ba80205566fdece672867c7e4a0

Modified files:
        libpurple/protocols/msn/msg.c
        libpurple/protocols/msn/switchboard.c

ChangeLog: 

Notify the user if a contact invites them to a voice call over MSN.

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/msg.c	e635599d8868e7b8a31662d4605556c25fb19839
+++ libpurple/protocols/msn/msg.c	7727a9894ac0920e52a895a77d29cf31785aa917
@@ -984,3 +984,67 @@ msn_datacast_msg(MsnCmdProc *cmdproc, Ms
 	g_hash_table_destroy(body);
 }
 
+void
+msn_invite_msg(MsnCmdProc *cmdproc, MsnMessage *msg)
+{
+	GHashTable *body;
+	const gchar *guid;
+
+	g_return_if_fail(cmdproc != NULL);
+	g_return_if_fail(msg != NULL);
+
+	body = msn_message_get_hashtable_from_body(msg);
+
+	if (body == NULL) {
+		purple_debug_warning("msn",
+				"Unable to parse invite msg body.\n");
+		return;
+	}
+
+	guid = g_hash_table_lookup(body, "Application-GUID");
+
+	if (guid == NULL) {
+		const gchar *cmd = g_hash_table_lookup(
+				body, "Invitation-Command");
+
+		if (cmd && !strcmp(cmd, "CANCEL")) {
+			const gchar *code = g_hash_table_lookup(
+					body, "Cancel-Code");
+			purple_debug_info("msn",
+					"MSMSGS invitation cancelled: %s.\n",
+					code ? code : "no reason given");
+		} else
+			purple_debug_warning("msn", "Invite msg missing "
+					"Application-GUID.\n");
+	} else if (!strcmp(guid, "{02D3C01F-BF30-4825-A83A-DE7AF41648AA}")) {
+		purple_debug_info("msn", "Computer call\n");
+
+		if (cmdproc->session) {
+			PurpleConversation *conv = NULL;
+			gchar *from = msg->remote_user;
+			gchar *buf = NULL;
+
+			if (from)
+				conv = purple_find_conversation_with_account(
+						PURPLE_CONV_TYPE_IM, from,
+						cmdproc->session->account);
+			if (conv)
+				buf = g_strdup_printf(
+						_("%s sent you a voice chat "
+						"invite, which is not yet "
+						"supported."), from);
+			if (buf) {
+				purple_conversation_write(conv, NULL, buf,
+						PURPLE_MESSAGE_SYSTEM |
+						PURPLE_MESSAGE_NOTIFY,
+						time(NULL));
+				g_free(buf);
+			}
+		}
+	} else
+		purple_debug_warning("msn",
+				"Unhandled invite msg with GUID %s.\n", guid);
+
+	g_hash_table_destroy(body);
+}
+
============================================================
--- libpurple/protocols/msn/switchboard.c	9d902d40fc43840d750642453f6c453d3e0e0403
+++ libpurple/protocols/msn/switchboard.c	995d0025ca4f7e6d1eb4a607d676da5203bff542
@@ -1237,10 +1237,8 @@ msn_switchboard_init(void)
 	                       msn_emoticon_msg);
 	msn_table_add_msg_type(cbs_table, "text/x-msnmsgr-datacast",
 						   msn_datacast_msg);
-#if 0
-	msn_table_add_msg_type(cbs_table, "text/x-msmmsginvite",
+	msn_table_add_msg_type(cbs_table, "text/x-msmsgsinvite",
 						   msn_invite_msg);
-#endif
 }
 
 void


More information about the Commits mailing list