comparison libpurple/protocols/msn/msn.c @ 23475:f85450504940

propagate from branch 'im.pidgin.pidgin' (head 5387bc28fa09b238593c3dc292863ec3ce5f3c4e) to branch 'im.pidgin.cpw.qulogic.msn' (head f2d5cd45d05d5b074677524bb08f2069d0683b09)
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 14 Jun 2008 07:47:38 +0000
parents 70de4e2246ec
children fd124c21ebb7
comparison
equal deleted inserted replaced
23365:ef4dbd2bb696 23475:f85450504940
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"
1060 return 1; 1061 return 1;
1061 } 1062 }
1062 } 1063 }
1063 1064
1064 msn_import_html(message, &msgformat, &msgtext); 1065 msn_import_html(message, &msgformat, &msgtext);
1065 if(msn_user_is_online(account, who)|| 1066 /* this is incorrect, we should try to initiate a connection to the
1067 buddy first, and only falls back if that fails. Otherwise we can
1068 only send offline message to invisible buddies */
1069 if (msn_user_is_online(account, who)||
1066 msn_user_is_yahoo(account, who)){ 1070 msn_user_is_yahoo(account, who)){
1067 /*User online,then send Online Instant Message*/ 1071 /*User online,then send Online Instant Message*/
1068 1072
1069 if (strlen(msgtext) + strlen(msgformat) + strlen(VERSION) > 1564) 1073 if (strlen(msgtext) + strlen(msgformat) + strlen(VERSION) > 1564)
1070 { 1074 {
1143 imdata->when = time(NULL); 1147 imdata->when = time(NULL);
1144 purple_timeout_add(0, msn_send_me_im, imdata); 1148 purple_timeout_add(0, msn_send_me_im, imdata);
1145 } 1149 }
1146 1150
1147 msn_message_destroy(msg); 1151 msn_message_destroy(msg);
1148 }else { 1152 } else {
1149 /*send Offline Instant Message,only to MSN Passport User*/ 1153 /*send Offline Instant Message,only to MSN Passport User*/
1150 MsnSession *session; 1154 MsnSession *session;
1151 char *friendname; 1155 char *friendname;
1152 1156
1153 purple_debug_info("MSNP14","prepare to send offline Message\n"); 1157 purple_debug_info("MSNP14","prepare to send offline Message\n");
1154 session = gc->proto_data; 1158 session = gc->proto_data;
1155 1159
1156 friendname = msn_encode_mime(account->username); 1160 friendname = msn_encode_mime(account->username);
1157 msn_oim_prep_send_msg_info(session->oim, 1161 msn_oim_prep_send_msg_info(session->oim,
1158 purple_account_get_username(account), 1162 purple_account_get_username(account),
1159 friendname, who, message); 1163 friendname, who, msgtext);
1160 msn_oim_send_msg(session->oim); 1164 msn_oim_send_msg(session->oim);
1165
1166 g_free(msgformat);
1167 g_free(msgtext);
1161 g_free(friendname); 1168 g_free(friendname);
1162 } 1169 }
1163 1170
1164 return 1; 1171 return 1;
1165 } 1172 }
1367 1374
1368 if (user != NULL && user->list_op & MSN_LIST_BL_OP) { 1375 if (user != NULL && user->list_op & MSN_LIST_BL_OP) {
1369 msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_BL); 1376 msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_BL);
1370 1377
1371 /* delete contact from Block list and add it to Allow in the callback */ 1378 /* delete contact from Block list and add it to Allow in the callback */
1372 msn_del_contact_from_list(session->contact, NULL, who, MSN_LIST_BL); 1379 msn_del_contact_from_list(session, NULL, who, MSN_LIST_BL);
1373 } else { 1380 } else {
1374 /* just add the contact to Allow list */ 1381 /* just add the contact to Allow list */
1375 msn_add_contact_to_list(session->contact, NULL, who, MSN_LIST_AL); 1382 msn_add_contact_to_list(session, NULL, who, MSN_LIST_AL);
1376 } 1383 }
1377 1384
1378 1385
1379 msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_AL); 1386 msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_AL);
1380 } 1387 }
1395 1402
1396 if (user != NULL && user->list_op & MSN_LIST_AL_OP) { 1403 if (user != NULL && user->list_op & MSN_LIST_AL_OP) {
1397 msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_AL); 1404 msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_AL);
1398 1405
1399 /* delete contact from Allow list and add it to Block in the callback */ 1406 /* delete contact from Allow list and add it to Block in the callback */
1400 msn_del_contact_from_list(session->contact, NULL, who, MSN_LIST_AL); 1407 msn_del_contact_from_list(session, NULL, who, MSN_LIST_AL);
1401 } else { 1408 } else {
1402 /* just add the contact to Block list */ 1409 /* just add the contact to Block list */
1403 msn_add_contact_to_list(session->contact, NULL, who, MSN_LIST_BL); 1410 msn_add_contact_to_list(session, NULL, who, MSN_LIST_BL);
1404 } 1411 }
1405 1412
1406 msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_BL); 1413 msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_BL);
1407 } 1414 }
1408 1415
1421 1428
1422 user = msn_userlist_find_user(userlist, who); 1429 user = msn_userlist_find_user(userlist, who);
1423 1430
1424 msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_AL); 1431 msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_AL);
1425 1432
1426 msn_del_contact_from_list(session->contact, NULL, who, MSN_LIST_AL); 1433 msn_del_contact_from_list(session, NULL, who, MSN_LIST_AL);
1427 1434
1428 if (user != NULL && user->list_op & MSN_LIST_RL_OP) 1435 if (user != NULL && user->list_op & MSN_LIST_RL_OP)
1429 msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_BL); 1436 msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_BL);
1430 } 1437 }
1431 1438
1444 1451
1445 user = msn_userlist_find_user(userlist, who); 1452 user = msn_userlist_find_user(userlist, who);
1446 1453
1447 msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_BL); 1454 msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_BL);
1448 1455
1449 msn_del_contact_from_list(session->contact, NULL, who, MSN_LIST_BL); 1456 msn_del_contact_from_list(session, NULL, who, MSN_LIST_BL);
1450 1457
1451 if (user != NULL && user->list_op & MSN_LIST_RL_OP) 1458 if (user != NULL && user->list_op & MSN_LIST_RL_OP)
1452 msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_AL); 1459 msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_AL);
1453 } 1460 }
1454 1461
1570 1577
1571 cmdproc = session->notification->cmdproc; 1578 cmdproc = session->notification->cmdproc;
1572 1579
1573 msn_cmdproc_send_quick(cmdproc, "PNG", NULL, NULL); 1580 msn_cmdproc_send_quick(cmdproc, "PNG", NULL, NULL);
1574 } 1581 }
1582 }
1583
1584 static void msn_alias_buddy(PurpleConnection *pc, const char *name, const char *alias)
1585 {
1586 MsnSession *session;
1587
1588 session = pc->proto_data;
1589
1590 msn_update_contact(session, name, MSN_UPDATE_ALIAS, alias);
1575 } 1591 }
1576 1592
1577 static void 1593 static void
1578 msn_group_buddy(PurpleConnection *gc, const char *who, 1594 msn_group_buddy(PurpleConnection *gc, const char *who,
1579 const char *old_group_name, const char *new_group_name) 1595 const char *old_group_name, const char *new_group_name)
2409 msn_chat_send, /* chat_send */ 2425 msn_chat_send, /* chat_send */
2410 msn_keepalive, /* keepalive */ 2426 msn_keepalive, /* keepalive */
2411 NULL, /* register_user */ 2427 NULL, /* register_user */
2412 NULL, /* get_cb_info */ 2428 NULL, /* get_cb_info */
2413 NULL, /* get_cb_away */ 2429 NULL, /* get_cb_away */
2414 NULL, /* alias_buddy */ 2430 msn_alias_buddy, /* alias_buddy */
2415 msn_group_buddy, /* group_buddy */ 2431 msn_group_buddy, /* group_buddy */
2416 msn_rename_group, /* rename_group */ 2432 msn_rename_group, /* rename_group */
2417 NULL, /* buddy_free */ 2433 NULL, /* buddy_free */
2418 msn_convo_closed, /* convo_closed */ 2434 msn_convo_closed, /* convo_closed */
2419 msn_normalize, /* normalize */ 2435 msn_normalize, /* normalize */