Mercurial > pidgin.yaz
comparison libpurple/protocols/msn/switchboard.c @ 25038:ea98810d89c5
Move some MSN message handlers from switchboard to general msg.c.
References #7676.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sun, 01 Feb 2009 08:25:57 +0000 |
parents | 86ba0d87c04b |
children | c7c8baa5d824 1102f8642bd1 |
comparison
equal
deleted
inserted
replaced
25037:3e89d2c6bf93 | 25038:ea98810d89c5 |
---|---|
885 | 885 |
886 /************************************************************************** | 886 /************************************************************************** |
887 * Message Handlers | 887 * Message Handlers |
888 **************************************************************************/ | 888 **************************************************************************/ |
889 static void | 889 static void |
890 plain_msg(MsnCmdProc *cmdproc, MsnMessage *msg) | |
891 { | |
892 PurpleConnection *gc; | |
893 MsnSwitchBoard *swboard; | |
894 const char *body; | |
895 char *body_str; | |
896 char *body_enc; | |
897 char *body_final; | |
898 size_t body_len; | |
899 const char *passport; | |
900 const char *value; | |
901 | |
902 gc = cmdproc->session->account->gc; | |
903 swboard = cmdproc->data; | |
904 | |
905 body = msn_message_get_bin_data(msg, &body_len); | |
906 body_str = g_strndup(body, body_len); | |
907 body_enc = g_markup_escape_text(body_str, -1); | |
908 g_free(body_str); | |
909 | |
910 passport = msg->remote_user; | |
911 | |
912 if (!strcmp(passport, "messenger@microsoft.com") && | |
913 strstr(body, "immediate security update")) | |
914 { | |
915 return; | |
916 } | |
917 | |
918 #if 0 | |
919 if ((value = msn_message_get_attr(msg, "User-Agent")) != NULL) | |
920 { | |
921 purple_debug_misc("msn", "User-Agent = '%s'\n", value); | |
922 } | |
923 #endif | |
924 | |
925 if ((value = msn_message_get_attr(msg, "X-MMS-IM-Format")) != NULL) | |
926 { | |
927 char *pre, *post; | |
928 | |
929 msn_parse_format(value, &pre, &post); | |
930 | |
931 body_final = g_strdup_printf("%s%s%s", pre ? pre : "", | |
932 body_enc ? body_enc : "", post ? post : ""); | |
933 | |
934 g_free(pre); | |
935 g_free(post); | |
936 g_free(body_enc); | |
937 } | |
938 else | |
939 { | |
940 body_final = body_enc; | |
941 } | |
942 | |
943 swboard->flag |= MSN_SB_FLAG_IM; | |
944 | |
945 if (swboard->current_users > 1 || | |
946 ((swboard->conv != NULL) && | |
947 purple_conversation_get_type(swboard->conv) == PURPLE_CONV_TYPE_CHAT)) | |
948 { | |
949 /* If current_users is always ok as it should then there is no need to | |
950 * check if this is a chat. */ | |
951 if (swboard->current_users <= 1) | |
952 purple_debug_misc("msn", "plain_msg: current_users(%d)\n", | |
953 swboard->current_users); | |
954 | |
955 serv_got_chat_in(gc, swboard->chat_id, passport, 0, body_final, | |
956 time(NULL)); | |
957 if (swboard->conv == NULL) | |
958 { | |
959 swboard->conv = purple_find_chat(gc, swboard->chat_id); | |
960 swboard->flag |= MSN_SB_FLAG_IM; | |
961 } | |
962 } | |
963 else | |
964 { | |
965 serv_got_im(gc, passport, body_final, 0, time(NULL)); | |
966 if (swboard->conv == NULL) | |
967 { | |
968 swboard->conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, | |
969 passport, purple_connection_get_account(gc)); | |
970 swboard->flag |= MSN_SB_FLAG_IM; | |
971 } | |
972 } | |
973 | |
974 g_free(body_final); | |
975 } | |
976 | |
977 static void | |
978 control_msg(MsnCmdProc *cmdproc, MsnMessage *msg) | |
979 { | |
980 PurpleConnection *gc; | |
981 MsnSwitchBoard *swboard; | |
982 char *passport; | |
983 | |
984 gc = cmdproc->session->account->gc; | |
985 swboard = cmdproc->data; | |
986 passport = msg->remote_user; | |
987 | |
988 if (swboard->current_users == 1 && | |
989 msn_message_get_attr(msg, "TypingUser") != NULL) | |
990 { | |
991 serv_got_typing(gc, passport, MSN_TYPING_RECV_TIMEOUT, | |
992 PURPLE_TYPING); | |
993 } | |
994 } | |
995 | |
996 static void | |
997 clientcaps_msg(MsnCmdProc *cmdproc, MsnMessage *msg) | 890 clientcaps_msg(MsnCmdProc *cmdproc, MsnMessage *msg) |
998 { | 891 { |
999 #if 0 | 892 #if 0 |
1000 MsnSession *session; | 893 MsnSession *session; |
1001 MsnSwitchBoard *swboard; | 894 MsnSwitchBoard *swboard; |
1008 session = cmdproc->session; | 901 session = cmdproc->session; |
1009 swboard = cmdproc->servconn->swboard; | 902 swboard = cmdproc->servconn->swboard; |
1010 | 903 |
1011 clientcaps = msn_message_get_hashtable_from_body(msg); | 904 clientcaps = msn_message_get_hashtable_from_body(msg); |
1012 #endif | 905 #endif |
1013 } | |
1014 | |
1015 static void | |
1016 datacast_msg(MsnCmdProc *cmdproc, MsnMessage *msg) | |
1017 { | |
1018 GHashTable *body; | |
1019 const char *id; | |
1020 body = msn_message_get_hashtable_from_body(msg); | |
1021 | |
1022 id = g_hash_table_lookup(body, "ID"); | |
1023 | |
1024 if (!strcmp(id, "1")) { | |
1025 /* Nudge */ | |
1026 MsnSwitchBoard *swboard; | |
1027 PurpleAccount *account; | |
1028 const char *user; | |
1029 | |
1030 swboard = cmdproc->data; | |
1031 account = cmdproc->session->account; | |
1032 user = msg->remote_user; | |
1033 | |
1034 if (swboard->current_users > 1 || | |
1035 ((swboard->conv != NULL) && | |
1036 purple_conversation_get_type(swboard->conv) == PURPLE_CONV_TYPE_CHAT)) | |
1037 purple_prpl_got_attention_in_chat(account->gc, swboard->chat_id, user, MSN_NUDGE); | |
1038 | |
1039 else | |
1040 purple_prpl_got_attention(account->gc, user, MSN_NUDGE); | |
1041 | |
1042 } else if (!strcmp(id, "2")) { | |
1043 /* Wink */ | |
1044 | |
1045 } else if (!strcmp(id, "3")) { | |
1046 /* Voiceclip */ | |
1047 | |
1048 } else if (!strcmp(id, "4")) { | |
1049 /* Action */ | |
1050 | |
1051 } else { | |
1052 purple_debug_warning("msn", "Got unknown datacast with ID %s.\n", id); | |
1053 } | |
1054 | |
1055 g_hash_table_destroy(body); | |
1056 } | 906 } |
1057 | 907 |
1058 /************************************************************************** | 908 /************************************************************************** |
1059 * Connect stuff | 909 * Connect stuff |
1060 **************************************************************************/ | 910 **************************************************************************/ |
1370 msn_table_add_error(cbs_table, "MSG", msg_error); | 1220 msn_table_add_error(cbs_table, "MSG", msg_error); |
1371 msn_table_add_error(cbs_table, "CAL", cal_error); | 1221 msn_table_add_error(cbs_table, "CAL", cal_error); |
1372 | 1222 |
1373 /* Register the message type callbacks. */ | 1223 /* Register the message type callbacks. */ |
1374 msn_table_add_msg_type(cbs_table, "text/plain", | 1224 msn_table_add_msg_type(cbs_table, "text/plain", |
1375 plain_msg); | 1225 msn_plain_msg); |
1376 msn_table_add_msg_type(cbs_table, "text/x-msmsgscontrol", | 1226 msn_table_add_msg_type(cbs_table, "text/x-msmsgscontrol", |
1377 control_msg); | 1227 msn_control_msg); |
1378 msn_table_add_msg_type(cbs_table, "text/x-clientcaps", | 1228 msn_table_add_msg_type(cbs_table, "text/x-clientcaps", |
1379 clientcaps_msg); | 1229 clientcaps_msg); |
1380 msn_table_add_msg_type(cbs_table, "text/x-clientinfo", | 1230 msn_table_add_msg_type(cbs_table, "text/x-clientinfo", |
1381 clientcaps_msg); | 1231 clientcaps_msg); |
1382 msn_table_add_msg_type(cbs_table, "application/x-msnmsgrp2p", | 1232 msn_table_add_msg_type(cbs_table, "application/x-msnmsgrp2p", |
1383 msn_p2p_msg); | 1233 msn_p2p_msg); |
1384 msn_table_add_msg_type(cbs_table, "text/x-mms-emoticon", | 1234 msn_table_add_msg_type(cbs_table, "text/x-mms-emoticon", |
1385 msn_emoticon_msg); | 1235 msn_emoticon_msg); |
1386 msn_table_add_msg_type(cbs_table, "text/x-mms-animemoticon", | 1236 msn_table_add_msg_type(cbs_table, "text/x-mms-animemoticon", |
1387 msn_emoticon_msg); | 1237 msn_emoticon_msg); |
1388 msn_table_add_msg_type(cbs_table, "text/x-msnmsgr-datacast", | 1238 msn_table_add_msg_type(cbs_table, "text/x-msnmsgr-datacast", |
1389 datacast_msg); | 1239 msn_datacast_msg); |
1390 #if 0 | 1240 #if 0 |
1391 msn_table_add_msg_type(cbs_table, "text/x-msmmsginvite", | 1241 msn_table_add_msg_type(cbs_table, "text/x-msmmsginvite", |
1392 msn_invite_msg); | 1242 msn_invite_msg); |
1393 #endif | 1243 #endif |
1394 } | 1244 } |