comparison libpurple/protocols/msn/msn.c @ 23505:a1652ea8f252

propagate from branch 'im.pidgin.pidgin' (head 119df2055ed7ee5143047b4d18ae81d58c2feac6) to branch 'im.pidgin.pidgin.khc.msnp15' (head f9f92fe0f0a499de8ed1933639155b1b04048388)
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Tue, 18 Mar 2008 05:36:30 +0000
parents 616a76954a97 69af5301e1a7
children d756a0477c06
comparison
equal deleted inserted replaced
22495:2ded253bcdbb 23505:a1652ea8f252
25 25
26 #include <glib.h> 26 #include <glib.h>
27 27
28 #include "msn.h" 28 #include "msn.h"
29 #include "accountopt.h" 29 #include "accountopt.h"
30 #include "contact.h"
30 #include "msg.h" 31 #include "msg.h"
31 #include "page.h" 32 #include "page.h"
32 #include "pluginpref.h" 33 #include "pluginpref.h"
33 #include "prefs.h" 34 #include "prefs.h"
34 #include "session.h" 35 #include "session.h"
933 return 1; 934 return 1;
934 } 935 }
935 } 936 }
936 937
937 msn_import_html(message, &msgformat, &msgtext); 938 msn_import_html(message, &msgformat, &msgtext);
938 if(msn_user_is_online(account, who)|| 939 /* this is incorrect, we should try to initiate a connection to the
940 buddy first, and only falls back if that fails. Otherwise we can
941 only send offline message to invisible buddies */
942 if (msn_user_is_online(account, who)||
939 msn_user_is_yahoo(account, who)){ 943 msn_user_is_yahoo(account, who)){
940 /*User online,then send Online Instant Message*/ 944 /*User online,then send Online Instant Message*/
941 945
942 if (strlen(msgtext) + strlen(msgformat) + strlen(VERSION) > 1564) 946 if (strlen(msgtext) + strlen(msgformat) + strlen(VERSION) > 1564)
943 { 947 {
1000 imdata->when = time(NULL); 1004 imdata->when = time(NULL);
1001 purple_timeout_add(0, msn_send_me_im, imdata); 1005 purple_timeout_add(0, msn_send_me_im, imdata);
1002 } 1006 }
1003 1007
1004 msn_message_destroy(msg); 1008 msn_message_destroy(msg);
1005 }else { 1009 } else {
1006 /*send Offline Instant Message,only to MSN Passport User*/ 1010 /*send Offline Instant Message,only to MSN Passport User*/
1007 MsnSession *session; 1011 MsnSession *session;
1008 char *friendname; 1012 char *friendname;
1009 1013
1010 purple_debug_info("MSNP14","prepare to send offline Message\n"); 1014 purple_debug_info("MSNP14","prepare to send offline Message\n");
1011 session = gc->proto_data; 1015 session = gc->proto_data;
1012 1016
1013 friendname = msn_encode_mime(account->username); 1017 friendname = msn_encode_mime(account->username);
1014 msn_oim_prep_send_msg_info(session->oim, 1018 msn_oim_prep_send_msg_info(session->oim,
1015 purple_account_get_username(account), 1019 purple_account_get_username(account),
1016 friendname, who, message); 1020 friendname, who, msgtext);
1017 msn_oim_send_msg(session->oim); 1021 msn_oim_send_msg(session->oim);
1022
1023 g_free(msgformat);
1024 g_free(msgtext);
1018 g_free(friendname); 1025 g_free(friendname);
1019 } 1026 }
1020 1027
1021 return 1; 1028 return 1;
1022 } 1029 }
1224 1231
1225 if (user != NULL && user->list_op & MSN_LIST_BL_OP) { 1232 if (user != NULL && user->list_op & MSN_LIST_BL_OP) {
1226 msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_BL); 1233 msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_BL);
1227 1234
1228 /* delete contact from Block list and add it to Allow in the callback */ 1235 /* delete contact from Block list and add it to Allow in the callback */
1229 msn_del_contact_from_list(session->contact, NULL, who, MSN_LIST_BL); 1236 msn_del_contact_from_list(session, NULL, who, MSN_LIST_BL);
1230 } else { 1237 } else {
1231 /* just add the contact to Allow list */ 1238 /* just add the contact to Allow list */
1232 msn_add_contact_to_list(session->contact, NULL, who, MSN_LIST_AL); 1239 msn_add_contact_to_list(session, NULL, who, MSN_LIST_AL);
1233 } 1240 }
1234 1241
1235 1242
1236 msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_AL); 1243 msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_AL);
1237 } 1244 }
1252 1259
1253 if (user != NULL && user->list_op & MSN_LIST_AL_OP) { 1260 if (user != NULL && user->list_op & MSN_LIST_AL_OP) {
1254 msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_AL); 1261 msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_AL);
1255 1262
1256 /* delete contact from Allow list and add it to Block in the callback */ 1263 /* delete contact from Allow list and add it to Block in the callback */
1257 msn_del_contact_from_list(session->contact, NULL, who, MSN_LIST_AL); 1264 msn_del_contact_from_list(session, NULL, who, MSN_LIST_AL);
1258 } else { 1265 } else {
1259 /* just add the contact to Block list */ 1266 /* just add the contact to Block list */
1260 msn_add_contact_to_list(session->contact, NULL, who, MSN_LIST_BL); 1267 msn_add_contact_to_list(session, NULL, who, MSN_LIST_BL);
1261 } 1268 }
1262 1269
1263 msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_BL); 1270 msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_BL);
1264 } 1271 }
1265 1272
1278 1285
1279 user = msn_userlist_find_user(userlist, who); 1286 user = msn_userlist_find_user(userlist, who);
1280 1287
1281 msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_AL); 1288 msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_AL);
1282 1289
1283 msn_del_contact_from_list(session->contact, NULL, who, MSN_LIST_AL); 1290 msn_del_contact_from_list(session, NULL, who, MSN_LIST_AL);
1284 1291
1285 if (user != NULL && user->list_op & MSN_LIST_RL_OP) 1292 if (user != NULL && user->list_op & MSN_LIST_RL_OP)
1286 msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_BL); 1293 msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_BL);
1287 } 1294 }
1288 1295
1301 1308
1302 user = msn_userlist_find_user(userlist, who); 1309 user = msn_userlist_find_user(userlist, who);
1303 1310
1304 msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_BL); 1311 msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_BL);
1305 1312
1306 msn_del_contact_from_list(session->contact, NULL, who, MSN_LIST_BL); 1313 msn_del_contact_from_list(session, NULL, who, MSN_LIST_BL);
1307 1314
1308 if (user != NULL && user->list_op & MSN_LIST_RL_OP) 1315 if (user != NULL && user->list_op & MSN_LIST_RL_OP)
1309 msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_AL); 1316 msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_AL);
1310 } 1317 }
1311 1318