Mercurial > pidgin.yaz
comparison libpurple/protocols/msn/msg.c @ 30478:0b22c840f4f4
merge of '5378b2067023c1be51d87906196d87f03c9992e3'
and 'da604206b18f52b79c03f5cdd11dc0438e46038b'
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Fri, 07 May 2010 20:04:42 +0000 |
parents | 0f1df8098d00 538ca314c5f8 |
children | 3f6daa187665 |
comparison
equal
deleted
inserted
replaced
30301:7fbb7612e3dd | 30478:0b22c840f4f4 |
---|---|
1100 | 1100 |
1101 void | 1101 void |
1102 msn_invite_msg(MsnCmdProc *cmdproc, MsnMessage *msg) | 1102 msn_invite_msg(MsnCmdProc *cmdproc, MsnMessage *msg) |
1103 { | 1103 { |
1104 GHashTable *body; | 1104 GHashTable *body; |
1105 const gchar *guid; | 1105 const gchar *command; |
1106 const gchar *cookie; | |
1106 gboolean accepted = FALSE; | 1107 gboolean accepted = FALSE; |
1107 | 1108 |
1108 g_return_if_fail(cmdproc != NULL); | 1109 g_return_if_fail(cmdproc != NULL); |
1109 g_return_if_fail(msg != NULL); | 1110 g_return_if_fail(msg != NULL); |
1110 | 1111 |
1113 if (body == NULL) { | 1114 if (body == NULL) { |
1114 purple_debug_warning("msn", | 1115 purple_debug_warning("msn", |
1115 "Unable to parse invite msg body.\n"); | 1116 "Unable to parse invite msg body.\n"); |
1116 return; | 1117 return; |
1117 } | 1118 } |
1118 | 1119 |
1119 guid = g_hash_table_lookup(body, "Application-GUID"); | 1120 /* |
1120 | 1121 * GUID is NOT always present but Invitation-Command and Invitation-Cookie |
1121 if (guid == NULL) { | 1122 * are mandatory. |
1122 const gchar *cmd = g_hash_table_lookup( | 1123 */ |
1123 body, "Invitation-Command"); | 1124 command = g_hash_table_lookup(body, "Invitation-Command"); |
1124 | 1125 cookie = g_hash_table_lookup(body, "Invitation-Cookie"); |
1125 if (cmd && !strcmp(cmd, "CANCEL")) { | 1126 |
1126 const gchar *code = g_hash_table_lookup( | 1127 if (command == NULL || cookie == NULL) { |
1127 body, "Cancel-Code"); | 1128 purple_debug_warning("msn", |
1128 purple_debug_info("msn", | 1129 "Invalid invitation message: either Invitation-Command " |
1129 "MSMSGS invitation cancelled: %s.\n", | 1130 "or Invitation-Cookie is missing or invalid.\n" |
1130 code ? code : "no reason given"); | 1131 ); |
1131 } else | 1132 return; |
1132 purple_debug_warning("msn", "Invite msg missing " | 1133 |
1133 "Application-GUID.\n"); | 1134 } else if (!strcmp(command, "INVITE")) { |
1134 | 1135 const gchar *guid = g_hash_table_lookup(body, "Application-GUID"); |
1135 accepted = TRUE; | 1136 |
1136 | 1137 if (guid == NULL) { |
1137 } else if (!strcmp(guid, "{02D3C01F-BF30-4825-A83A-DE7AF41648AA}")) { | 1138 if (!strcmp(command, "CANCEL")) { |
1138 purple_debug_info("msn", "Computer call\n"); | 1139 const gchar *code = g_hash_table_lookup( |
1139 | 1140 body, "Cancel-Code"); |
1140 if (cmdproc->session) { | 1141 purple_debug_info("msn", |
1141 PurpleConversation *conv = NULL; | 1142 "MSMSGS invitation cancelled: %s.\n", |
1142 gchar *from = msg->remote_user; | 1143 code ? code : "no reason given"); |
1143 gchar *buf = NULL; | 1144 } else |
1144 | 1145 purple_debug_warning("msn", |
1145 if (from) | 1146 "Invite msg missing Application-GUID.\n"); |
1146 conv = purple_find_conversation_with_account( | 1147 |
1147 PURPLE_CONV_TYPE_IM, from, | 1148 accepted = TRUE; |
1148 cmdproc->session->account); | 1149 |
1149 if (conv) | 1150 } else if (!strcmp(guid, MSN_FT_GUID)) { |
1150 buf = g_strdup_printf( | 1151 |
1151 _("%s sent you a voice chat " | 1152 } else if (!strcmp(guid, "{02D3C01F-BF30-4825-A83A-DE7AF41648AA}")) { |
1152 "invite, which is not yet " | 1153 purple_debug_info("msn", "Computer call\n"); |
1153 "supported."), from); | 1154 |
1154 if (buf) { | 1155 if (cmdproc->session) { |
1155 purple_conversation_write(conv, NULL, buf, | 1156 PurpleConversation *conv = NULL; |
1156 PURPLE_MESSAGE_SYSTEM | | 1157 gchar *from = msg->remote_user; |
1157 PURPLE_MESSAGE_NOTIFY, | 1158 gchar *buf = NULL; |
1158 time(NULL)); | 1159 |
1159 g_free(buf); | 1160 if (from) |
1161 conv = purple_find_conversation_with_account( | |
1162 PURPLE_CONV_TYPE_IM, from, | |
1163 cmdproc->session->account); | |
1164 if (conv) | |
1165 buf = g_strdup_printf( | |
1166 _("%s sent you a voice chat " | |
1167 "invite, which is not yet " | |
1168 "supported."), from); | |
1169 if (buf) { | |
1170 purple_conversation_write(conv, NULL, buf, | |
1171 PURPLE_MESSAGE_SYSTEM | | |
1172 PURPLE_MESSAGE_NOTIFY, | |
1173 time(NULL)); | |
1174 g_free(buf); | |
1175 } | |
1160 } | 1176 } |
1161 } | 1177 } else { |
1162 } else { | 1178 const gchar *application = g_hash_table_lookup(body, "Application-Name"); |
1163 const gchar *application = g_hash_table_lookup(body, "Application-Name"); | 1179 purple_debug_warning("msn", "Unhandled invite msg with GUID %s: %s.\n", |
1164 purple_debug_warning("msn", "Unhandled invite msg with GUID %s: %s.\n", | 1180 guid, application ? application : "(null)"); |
1165 guid, application ? application : "(null)"); | 1181 } |
1166 } | 1182 |
1167 | 1183 if (!accepted) { |
1168 if (!accepted) { | |
1169 const gchar *cookie = g_hash_table_lookup(body, "Invitation-Cookie"); | |
1170 if (cookie) { | |
1171 MsnSwitchBoard *swboard = cmdproc->data; | 1184 MsnSwitchBoard *swboard = cmdproc->data; |
1172 char *text; | 1185 char *text; |
1173 MsnMessage *cancel; | 1186 MsnMessage *cancel; |
1174 | 1187 |
1175 cancel = msn_message_new(MSN_MSG_TEXT); | 1188 cancel = msn_message_new(MSN_MSG_TEXT); |
1185 g_free(text); | 1198 g_free(text); |
1186 | 1199 |
1187 msn_switchboard_send_msg(swboard, cancel, TRUE); | 1200 msn_switchboard_send_msg(swboard, cancel, TRUE); |
1188 msn_message_destroy(cancel); | 1201 msn_message_destroy(cancel); |
1189 } | 1202 } |
1203 | |
1204 } else { | |
1205 /* | |
1206 * Some other already established invitation session. | |
1207 * Can be retrieved by Invitation-Cookie. | |
1208 */ | |
1190 } | 1209 } |
1191 | 1210 |
1192 g_hash_table_destroy(body); | 1211 g_hash_table_destroy(body); |
1193 } | 1212 } |
1194 | 1213 |