Mercurial > pidgin.yaz
diff libpurple/protocols/msn/msg.c @ 30511:9623db527d1e
merged from im.pidgin.pidgin
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Tue, 25 May 2010 22:21:47 +0900 |
parents | 46275cca345e 5044315e81e1 |
children | 0462bec07414 |
line wrap: on
line diff
--- a/libpurple/protocols/msn/msg.c Tue May 18 02:29:24 2010 +0900 +++ b/libpurple/protocols/msn/msg.c Tue May 25 22:21:47 2010 +0900 @@ -1128,7 +1128,8 @@ msn_invite_msg(MsnCmdProc *cmdproc, MsnMessage *msg) { GHashTable *body; - const gchar *guid; + const gchar *command; + const gchar *cookie; gboolean accepted = FALSE; g_return_if_fail(cmdproc != NULL); @@ -1141,59 +1142,64 @@ "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"); + + /* + * GUID is NOT always present but Invitation-Command and Invitation-Cookie + * are mandatory. + */ + command = g_hash_table_lookup(body, "Invitation-Command"); + cookie = g_hash_table_lookup(body, "Invitation-Cookie"); - 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"); + if (command == NULL || cookie == NULL) { + purple_debug_warning("msn", + "Invalid invitation message: either Invitation-Command " + "or Invitation-Cookie is missing or invalid.\n" + ); + return; - accepted = TRUE; - - } else if (!strcmp(guid, "{02D3C01F-BF30-4825-A83A-DE7AF41648AA}")) { - purple_debug_info("msn", "Computer call\n"); + } else if (!strcmp(command, "INVITE")) { + const gchar *guid = g_hash_table_lookup(body, "Application-GUID"); + + if (guid == NULL) { + purple_debug_warning("msn", + "Invite msg missing Application-GUID.\n"); - if (cmdproc->session) { - PurpleConversation *conv = NULL; - gchar *from = msg->remote_user; - gchar *buf = NULL; + accepted = TRUE; + + } else if (!strcmp(guid, MSN_FT_GUID)) { + + } else if (!strcmp(guid, "{02D3C01F-BF30-4825-A83A-DE7AF41648AA}")) { + purple_debug_info("msn", "Computer call\n"); - 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); + 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 { + const gchar *application = g_hash_table_lookup(body, "Application-Name"); + purple_debug_warning("msn", "Unhandled invite msg with GUID %s: %s.\n", + guid, application ? application : "(null)"); } - } else { - const gchar *application = g_hash_table_lookup(body, "Application-Name"); - purple_debug_warning("msn", "Unhandled invite msg with GUID %s: %s.\n", - guid, application ? application : "(null)"); - } - - if (!accepted) { - const gchar *cookie = g_hash_table_lookup(body, "Invitation-Cookie"); - if (cookie) { + + if (!accepted) { MsnSwitchBoard *swboard = cmdproc->data; char *text; MsnMessage *cancel; @@ -1213,6 +1219,17 @@ msn_switchboard_send_msg(swboard, cancel, TRUE); msn_message_destroy(cancel); } + + } else if (!strcmp(command, "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 { + /* + * Some other already established invitation session. + * Can be retrieved by Invitation-Cookie. + */ } g_hash_table_destroy(body);