comparison libpurple/protocols/msn/msn.c @ 20411:ed303260e05a

propagate of im.pidgin.pidgin to im.pidgin.cpw.khc.msnp14
author Ka-Hing Cheung <khc@hxbc.us>
date Sun, 06 May 2007 02:40:23 +0000
parents 680b5910933b 7c0a2ef88018
children 522f618a44b4
comparison
equal deleted inserted replaced
16921:b668951121d8 20411:ed303260e05a
35 #include "state.h" 35 #include "state.h"
36 #include "util.h" 36 #include "util.h"
37 #include "cmds.h" 37 #include "cmds.h"
38 #include "core.h" 38 #include "core.h"
39 #include "prpl.h" 39 #include "prpl.h"
40 #include "msn-utils.h" 40 #include "msnutils.h"
41 #include "version.h" 41 #include "version.h"
42 42
43 #include "switchboard.h" 43 #include "switchboard.h"
44 #include "notification.h" 44 #include "notification.h"
45 #include "sync.h" 45 #include "sync.h"
112 purple_conversation_write(conv, NULL, _("You have just sent a Nudge!"), PURPLE_MESSAGE_SYSTEM, time(NULL)); 112 purple_conversation_write(conv, NULL, _("You have just sent a Nudge!"), PURPLE_MESSAGE_SYSTEM, time(NULL));
113 113
114 return PURPLE_CMD_RET_OK; 114 return PURPLE_CMD_RET_OK;
115 } 115 }
116 116
117 static void 117 void
118 msn_act_id(PurpleConnection *gc, const char *entry) 118 msn_act_id(PurpleConnection *gc, const char *entry)
119 { 119 {
120 MsnCmdProc *cmdproc; 120 MsnCmdProc *cmdproc;
121 MsnSession *session; 121 MsnSession *session;
122 PurpleAccount *account; 122 PurpleAccount *account;
123 const char *alias; 123 const char *alias;
124
125 char *soapbody;
126 MsnSoapReq *soap_request;
124 127
125 session = gc->proto_data; 128 session = gc->proto_data;
126 cmdproc = session->notification->cmdproc; 129 cmdproc = session->notification->cmdproc;
127 account = purple_connection_get_account(gc); 130 account = purple_connection_get_account(gc);
128 131
136 purple_notify_error(gc, NULL, 139 purple_notify_error(gc, NULL,
137 _("Your new MSN friendly name is too long."), NULL); 140 _("Your new MSN friendly name is too long."), NULL);
138 return; 141 return;
139 } 142 }
140 143
141 msn_cmdproc_send(cmdproc, "REA", "%s %s", 144 if (*alias == '\0') {
142 purple_account_get_username(account), 145 alias = purple_url_encode(purple_account_get_username(account));
143 alias); 146 }
147
148 msn_cmdproc_send(cmdproc, "PRP", "MFN %s", alias);
149
150 soapbody = g_strdup_printf(MSN_CONTACT_UPDATE_TEMPLATE, alias);
151 /*build SOAP and POST it*/
152 soap_request = msn_soap_request_new(MSN_CONTACT_SERVER,
153 MSN_ADDRESS_BOOK_POST_URL,
154 MSN_CONTACT_UPDATE_SOAP_ACTION,
155 soapbody,
156 NULL,
157 NULL);
158
159 session->contact->soapconn->read_cb = NULL;
160 msn_soap_post(session->contact->soapconn,
161 soap_request,
162 msn_contact_connect_init);
163
164 g_free(soapbody);
144 } 165 }
145 166
146 static void 167 static void
147 msn_set_prp(PurpleConnection *gc, const char *type, const char *entry) 168 msn_set_prp(PurpleConnection *gc, const char *type, const char *entry)
148 { 169 {
447 PurpleXfer *xfer; 468 PurpleXfer *xfer;
448 469
449 session = gc->proto_data; 470 session = gc->proto_data;
450 471
451 xfer = purple_xfer_new(gc->account, PURPLE_XFER_SEND, who); 472 xfer = purple_xfer_new(gc->account, PURPLE_XFER_SEND, who);
473
452 if (xfer) 474 if (xfer)
453 { 475 {
454 slplink = msn_session_get_slplink(session, who); 476 slplink = msn_session_get_slplink(session, who);
455 477
456 xfer->data = slplink; 478 xfer->data = slplink;
498 msn_list_icon(PurpleAccount *a, PurpleBuddy *b) 520 msn_list_icon(PurpleAccount *a, PurpleBuddy *b)
499 { 521 {
500 return "msn"; 522 return "msn";
501 } 523 }
502 524
525 /*
526 * Set the User status text
527 * Add the PSM String Using "Name - PSM String" format
528 */
503 static char * 529 static char *
504 msn_status_text(PurpleBuddy *buddy) 530 msn_status_text(PurpleBuddy *buddy)
505 { 531 {
506 PurplePresence *presence; 532 PurplePresence *presence;
507 PurpleStatus *status; 533 PurpleStatus *status;
534 const char *msg, *name, *cmedia;
535 char *psm_str, *tmp2, *text;
508 536
509 presence = purple_buddy_get_presence(buddy); 537 presence = purple_buddy_get_presence(buddy);
510 status = purple_presence_get_active_status(presence); 538 status = purple_presence_get_active_status(presence);
511 539
512 if (!purple_presence_is_available(presence) && !purple_presence_is_idle(presence)) 540 msg = purple_status_get_attr_string(status, "message");
513 { 541 cmedia=purple_status_get_attr_string(status, "currentmedia");
514 return g_strdup(purple_status_get_name(status)); 542
543 if (!purple_presence_is_available(presence) && !purple_presence_is_idle(presence)){
544 name = purple_status_get_name(status);
545 }else{
546 name = NULL;
547 }
548
549 if (cmedia != NULL) {
550 if(name) {
551 tmp2 = g_strdup_printf("%s - %s", name, cmedia);
552 text = g_markup_escape_text(tmp2, -1);
553 } else {
554 text = g_markup_escape_text(cmedia, -1);
555 }
556 return text;
557 } else if (msg != NULL) {
558 tmp2 = purple_markup_strip_html(msg);
559 if (name){
560 psm_str = g_strdup_printf("%s - %s", name, tmp2);
561 g_free(tmp2);
562 }else{
563 psm_str = tmp2;
564 }
565 text = g_markup_escape_text(psm_str, -1);
566 g_free(psm_str);
567 return text;
568 } else {
569 if (!purple_presence_is_available(presence) && !purple_presence_is_idle(presence)){
570 psm_str = g_strdup(purple_status_get_name(status));
571 text = g_markup_escape_text(psm_str, -1);
572 g_free(psm_str);
573 return text;
574 }
515 } 575 }
516 576
517 return NULL; 577 return NULL;
518 } 578 }
519 579
527 user = buddy->proto_data; 587 user = buddy->proto_data;
528 588
529 589
530 if (purple_presence_is_online(presence)) 590 if (purple_presence_is_online(presence))
531 { 591 {
592 const char *psm, *currentmedia;
593 char *tmp;
594
595 psm = purple_status_get_attr_string(status, "message");
596 currentmedia = purple_status_get_attr_string(status, "currentmedia");
597
532 purple_notify_user_info_add_pair(user_info, _("Status"), 598 purple_notify_user_info_add_pair(user_info, _("Status"),
533 (purple_presence_is_idle(presence) ? _("Idle") : purple_status_get_name(status))); 599 (purple_presence_is_idle(presence) ? _("Idle") : purple_status_get_name(status)));
600 if (psm) {
601 tmp = g_markup_escape_text(psm, -1);
602 purple_notify_user_info_add_pair(user_info, _("PSM"), tmp);
603 g_free(tmp);
604 }
605 if (currentmedia) {
606 tmp = g_markup_escape_text(currentmedia, -1);
607 purple_notify_user_info_add_pair(user_info, _("Current media"), tmp);
608 g_free(tmp);
609 }
534 } 610 }
535 611
536 if (full && user) 612 if (full && user)
537 { 613 {
538 purple_notify_user_info_add_pair(user_info, _("Has you"), 614 purple_notify_user_info_add_pair(user_info, _("Has you"),
553 static GList * 629 static GList *
554 msn_status_types(PurpleAccount *account) 630 msn_status_types(PurpleAccount *account)
555 { 631 {
556 PurpleStatusType *status; 632 PurpleStatusType *status;
557 GList *types = NULL; 633 GList *types = NULL;
558 634 #if 0
559 status = purple_status_type_new_full(PURPLE_STATUS_AVAILABLE, 635 status = purple_status_type_new_full(PURPLE_STATUS_AVAILABLE,
560 NULL, NULL, FALSE, TRUE, FALSE); 636 NULL, NULL, FALSE, TRUE, FALSE);
637 #endif
638 status = purple_status_type_new_with_attrs(
639 PURPLE_STATUS_AVAILABLE, NULL, NULL, TRUE, TRUE, FALSE,
640 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
641 "currentmedia", _("Current media"), purple_value_new(PURPLE_TYPE_STRING),
642 NULL);
561 types = g_list_append(types, status); 643 types = g_list_append(types, status);
562 644
563 status = purple_status_type_new_full(PURPLE_STATUS_AWAY, 645 status = purple_status_type_new_with_attrs(
564 NULL, NULL, FALSE, TRUE, FALSE); 646 PURPLE_STATUS_AWAY, NULL, NULL, TRUE, TRUE, FALSE,
647 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
648 "currentmedia", _("Current media"), purple_value_new(PURPLE_TYPE_STRING),
649 NULL);
565 types = g_list_append(types, status); 650 types = g_list_append(types, status);
566 651
567 status = purple_status_type_new_full(PURPLE_STATUS_AWAY, 652 status = purple_status_type_new_with_attrs(
568 "brb", _("Be Right Back"), FALSE, TRUE, FALSE); 653 PURPLE_STATUS_AWAY, "brb", _("Be Right Back"), TRUE, TRUE, FALSE,
654 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
655 "currentmedia", _("Current media"), purple_value_new(PURPLE_TYPE_STRING),
656 NULL);
569 types = g_list_append(types, status); 657 types = g_list_append(types, status);
570 658
571 status = purple_status_type_new_full(PURPLE_STATUS_UNAVAILABLE, 659 status = purple_status_type_new_with_attrs(
572 "busy", _("Busy"), FALSE, TRUE, FALSE); 660 PURPLE_STATUS_AWAY, "busy", _("Busy"), TRUE, TRUE, FALSE,
661 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
662 "currentmedia", _("Current media"), purple_value_new(PURPLE_TYPE_STRING),
663 NULL);
573 types = g_list_append(types, status); 664 types = g_list_append(types, status);
574 665 status = purple_status_type_new_with_attrs(
575 status = purple_status_type_new_full(PURPLE_STATUS_UNAVAILABLE, 666 PURPLE_STATUS_AWAY, "phone", _("On the Phone"), TRUE, TRUE, FALSE,
576 "phone", _("On the Phone"), FALSE, TRUE, FALSE); 667 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
668 "currentmedia", _("Current media"), purple_value_new(PURPLE_TYPE_STRING),
669 NULL);
577 types = g_list_append(types, status); 670 types = g_list_append(types, status);
578 671 status = purple_status_type_new_with_attrs(
579 status = purple_status_type_new_full(PURPLE_STATUS_AWAY, 672 PURPLE_STATUS_AWAY, "lunch", _("Out to Lunch"), TRUE, TRUE, FALSE,
580 "lunch", _("Out to Lunch"), FALSE, TRUE, FALSE); 673 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
674 "currentmedia", _("Current media"), purple_value_new(PURPLE_TYPE_STRING),
675 NULL);
581 types = g_list_append(types, status); 676 types = g_list_append(types, status);
582 677
583 status = purple_status_type_new_full(PURPLE_STATUS_INVISIBLE, 678 status = purple_status_type_new_full(PURPLE_STATUS_INVISIBLE,
584 NULL, NULL, FALSE, TRUE, FALSE); 679 NULL, NULL, FALSE, TRUE, FALSE);
585 types = g_list_append(types, status); 680 types = g_list_append(types, status);
714 _("SSL support is needed for MSN. Please install a supported " 809 _("SSL support is needed for MSN. Please install a supported "
715 "SSL library.")); 810 "SSL library."));
716 return; 811 return;
717 } 812 }
718 813
719 http_method = purple_account_get_bool(account, "http_method", FALSE); 814 if (purple_account_get_bool(account, "http_method", FALSE))
815 http_method = TRUE;
720 816
721 host = purple_account_get_string(account, "server", MSN_SERVER); 817 host = purple_account_get_string(account, "server", MSN_SERVER);
722 port = purple_account_get_int(account, "port", MSN_PORT); 818 port = purple_account_get_int(account, "port", MSN_PORT);
723 819
724 session = msn_session_new(account); 820 session = msn_session_new(account);
761 PurpleBuddy *buddy = purple_find_buddy(gc->account, who); 857 PurpleBuddy *buddy = purple_find_buddy(gc->account, who);
762 MsnMessage *msg; 858 MsnMessage *msg;
763 char *msgformat; 859 char *msgformat;
764 char *msgtext; 860 char *msgtext;
765 861
862 purple_debug_info("MaYuan","send IM {%s} to %s\n",message,who);
766 account = purple_connection_get_account(gc); 863 account = purple_connection_get_account(gc);
767 864
768 if (buddy) { 865 if (buddy) {
769 PurplePresence *p = purple_buddy_get_presence(buddy); 866 PurplePresence *p = purple_buddy_get_presence(buddy);
770 if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_MOBILE)) { 867 if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_MOBILE)) {
774 return 1; 871 return 1;
775 } 872 }
776 } 873 }
777 874
778 msn_import_html(message, &msgformat, &msgtext); 875 msn_import_html(message, &msgformat, &msgtext);
779 876 if(msn_user_is_online(account, who)||
780 if (strlen(msgtext) + strlen(msgformat) + strlen(VERSION) > 1564) 877 msn_user_is_yahoo(account, who)){
781 { 878 /*User online,then send Online Instant Message*/
879
880 if (strlen(msgtext) + strlen(msgformat) + strlen(VERSION) > 1564)
881 {
882 g_free(msgformat);
883 g_free(msgtext);
884
885 return -E2BIG;
886 }
887
888 msg = msn_message_new_plain(msgtext);
889 msg->remote_user = g_strdup(who);
890 msn_message_set_attr(msg, "X-MMS-IM-Format", msgformat);
891
782 g_free(msgformat); 892 g_free(msgformat);
783 g_free(msgtext); 893 g_free(msgtext);
784 894
785 return -E2BIG; 895 purple_debug_info("MaYuan","prepare to send online Message\n");
786 } 896 if (g_ascii_strcasecmp(who, purple_account_get_username(account)))
787 897 {
788 msg = msn_message_new_plain(msgtext); 898 MsnSession *session;
789 msn_message_set_attr(msg, "X-MMS-IM-Format", msgformat); 899 MsnSwitchBoard *swboard;
790 900
791 g_free(msgformat); 901 session = gc->proto_data;
792 g_free(msgtext); 902 if(msn_user_is_yahoo(account,who)){
793 903 /*we send the online and offline Message to Yahoo User via UBM*/
794 if (g_ascii_strcasecmp(who, purple_account_get_username(account))) 904 purple_debug_info("MaYuan","send to Yahoo User\n");
795 { 905 uum_send_msg(session,msg);
906 }else{
907 purple_debug_info("MaYuan","send via switchboard\n");
908 swboard = msn_session_get_swboard(session, who, MSN_SB_FLAG_IM);
909 msn_switchboard_send_msg(swboard, msg, TRUE);
910 }
911 }
912 else
913 {
914 char *body_str, *body_enc, *pre, *post;
915 const char *format;
916 /*
917 * In MSN, you can't send messages to yourself, so
918 * we'll fake like we received it ;)
919 */
920 body_str = msn_message_to_string(msg);
921 body_enc = g_markup_escape_text(body_str, -1);
922 g_free(body_str);
923
924 format = msn_message_get_attr(msg, "X-MMS-IM-Format");
925 msn_parse_format(format, &pre, &post);
926 body_str = g_strdup_printf("%s%s%s", pre ? pre : "",
927 body_enc ? body_enc : "", post ? post : "");
928 g_free(body_enc);
929 g_free(pre);
930 g_free(post);
931
932 serv_got_typing_stopped(gc, who);
933 serv_got_im(gc, who, body_str, flags, time(NULL));
934 g_free(body_str);
935 }
936
937 msn_message_destroy(msg);
938 }else {
939 /*send Offline Instant Message,only to MSN Passport User*/
796 MsnSession *session; 940 MsnSession *session;
797 MsnSwitchBoard *swboard; 941 MsnOim *oim;
798 942 char *friendname;
943
944 purple_debug_info("MaYuan","prepare to send offline Message\n");
799 session = gc->proto_data; 945 session = gc->proto_data;
800 swboard = msn_session_get_swboard(session, who, MSN_SB_FLAG_IM); 946 /* XXX/khc: hack */
801 947 if (!session->oim)
802 msn_switchboard_send_msg(swboard, msg, TRUE); 948 session->oim = msn_oim_new(session);
803 } 949
804 else 950 oim = session->oim;
805 { 951 friendname = msn_encode_mime(account->username);
806 char *body_str, *body_enc, *pre, *post; 952 msn_oim_prep_send_msg_info(oim, purple_account_get_username(account),
807 const char *format; 953 friendname, who, message);
808 /* 954 msn_oim_send_msg(oim);
809 * In MSN, you can't send messages to yourself, so 955 }
810 * we'll fake like we received it ;)
811 */
812 body_str = msn_message_to_string(msg);
813 body_enc = g_markup_escape_text(body_str, -1);
814 g_free(body_str);
815
816 format = msn_message_get_attr(msg, "X-MMS-IM-Format");
817 msn_parse_format(format, &pre, &post);
818 body_str = g_strdup_printf("%s%s%s", pre ? pre : "",
819 body_enc ? body_enc : "", post ? post : "");
820 g_free(body_enc);
821 g_free(pre);
822 g_free(post);
823
824 serv_got_typing_stopped(gc, who);
825 serv_got_im(gc, who, body_str, flags, time(NULL));
826 g_free(body_str);
827 }
828
829 msn_message_destroy(msg);
830
831 return 1; 956 return 1;
832 } 957 }
833 958
834 static unsigned int 959 static unsigned int
835 msn_send_typing(PurpleConnection *gc, const char *who, PurpleTypingState state) 960 msn_send_typing(PurpleConnection *gc, const char *who, PurpleTypingState state)
885 PurpleConnection *gc; 1010 PurpleConnection *gc;
886 MsnSession *session; 1011 MsnSession *session;
887 1012
888 gc = purple_account_get_connection(account); 1013 gc = purple_account_get_connection(account);
889 1014
890 if (gc != NULL) 1015 if (gc != NULL){
891 {
892 session = gc->proto_data; 1016 session = gc->proto_data;
893 msn_change_status(session); 1017 msn_change_status(session);
894 } 1018 }
895 } 1019 }
896 1020
963 1087
964 session = gc->proto_data; 1088 session = gc->proto_data;
965 userlist = session->userlist; 1089 userlist = session->userlist;
966 who = msn_normalize(gc->account, buddy->name); 1090 who = msn_normalize(gc->account, buddy->name);
967 1091
1092 purple_debug_info("MaYuan","add user:{%s} to group:{%s}\n",who,group->name);
968 if (!session->logged_in) 1093 if (!session->logged_in)
969 { 1094 {
970 #if 0 1095 #if 0
971 fake_userlist_add_buddy(session->sync_userlist, who, MSN_LIST_FL, 1096 fake_userlist_add_buddy(session->sync_userlist, who, MSN_LIST_FL,
972 group ? group->name : NULL); 1097 group ? group->name : NULL);
1110 account = purple_connection_get_account(gc); 1235 account = purple_connection_get_account(gc);
1111 session = gc->proto_data; 1236 session = gc->proto_data;
1112 cmdproc = session->notification->cmdproc; 1237 cmdproc = session->notification->cmdproc;
1113 1238
1114 if (account->perm_deny == PURPLE_PRIVACY_ALLOW_ALL || 1239 if (account->perm_deny == PURPLE_PRIVACY_ALLOW_ALL ||
1115 account->perm_deny == PURPLE_PRIVACY_DENY_USERS) 1240 account->perm_deny == PURPLE_PRIVACY_DENY_USERS){
1116 {
1117 msn_cmdproc_send(cmdproc, "BLP", "%s", "AL"); 1241 msn_cmdproc_send(cmdproc, "BLP", "%s", "AL");
1118 } 1242 }else{
1119 else
1120 {
1121 msn_cmdproc_send(cmdproc, "BLP", "%s", "BL"); 1243 msn_cmdproc_send(cmdproc, "BLP", "%s", "BL");
1122 } 1244 }
1123 } 1245 }
1124 1246
1125 static void 1247 static void
1255 msn_rename_group(PurpleConnection *gc, const char *old_name, 1377 msn_rename_group(PurpleConnection *gc, const char *old_name,
1256 PurpleGroup *group, GList *moved_buddies) 1378 PurpleGroup *group, GList *moved_buddies)
1257 { 1379 {
1258 MsnSession *session; 1380 MsnSession *session;
1259 MsnCmdProc *cmdproc; 1381 MsnCmdProc *cmdproc;
1260 int old_gid; 1382 const char *old_gid;
1261 const char *enc_new_group_name; 1383 const char *enc_new_group_name;
1262 1384
1263 session = gc->proto_data; 1385 session = gc->proto_data;
1264 cmdproc = session->notification->cmdproc; 1386 cmdproc = session->notification->cmdproc;
1265 enc_new_group_name = purple_url_encode(group->name); 1387 enc_new_group_name = purple_url_encode(group->name);
1266 1388
1389 purple_debug_info("MaYuan","rename group:old{%s},new{%s}",old_name,enc_new_group_name);
1267 old_gid = msn_userlist_find_group_id(session->userlist, old_name); 1390 old_gid = msn_userlist_find_group_id(session->userlist, old_name);
1268 1391
1269 if (old_gid >= 0) 1392 if (old_gid != NULL){
1270 { 1393 /*find a Group*/
1271 msn_cmdproc_send(cmdproc, "REG", "%d %s 0", old_gid, 1394 msn_cmdproc_send(cmdproc, "REG", "%d %s 0", old_gid,
1272 enc_new_group_name); 1395 enc_new_group_name);
1273 } 1396 }else{
1274 else 1397 /*not found*/
1275 {
1276 msn_cmdproc_send(cmdproc, "ADG", "%s 0", enc_new_group_name); 1398 msn_cmdproc_send(cmdproc, "ADG", "%s 0", enc_new_group_name);
1277 } 1399 }
1278 } 1400 }
1279 1401
1280 static void 1402 static void
1326 static void 1448 static void
1327 msn_remove_group(PurpleConnection *gc, PurpleGroup *group) 1449 msn_remove_group(PurpleConnection *gc, PurpleGroup *group)
1328 { 1450 {
1329 MsnSession *session; 1451 MsnSession *session;
1330 MsnCmdProc *cmdproc; 1452 MsnCmdProc *cmdproc;
1331 int group_id; 1453 const char *group_id;
1332 1454
1333 session = gc->proto_data; 1455 session = gc->proto_data;
1334 cmdproc = session->notification->cmdproc; 1456 cmdproc = session->notification->cmdproc;
1335 1457
1336 if ((group_id = msn_userlist_find_group_id(session->userlist, group->name)) >= 0) 1458 /*we can't delete the default group*/
1337 { 1459 if(!strcmp(group->name,MSN_INDIVIDUALS_GROUP_NAME)||
1338 msn_cmdproc_send(cmdproc, "RMG", "%d", group_id); 1460 !strcmp(group->name,MSN_NON_IM_GROUP_NAME)){
1461 return ;
1462 }
1463 group_id = msn_userlist_find_group_id(session->userlist, group->name);
1464 if (group_id != NULL){
1465 msn_del_group(session,group_id);
1339 } 1466 }
1340 } 1467 }
1341 1468
1342 /** 1469 /**
1343 * Extract info text from info_data and add it to user_info 1470 * Extract info text from info_data and add it to user_info
1348 PurpleBuddy *b; 1475 PurpleBuddy *b;
1349 1476
1350 b = purple_find_buddy(purple_connection_get_account(info_data->gc), 1477 b = purple_find_buddy(purple_connection_get_account(info_data->gc),
1351 info_data->name); 1478 info_data->name);
1352 1479
1353 if (b) 1480 if (b){
1354 {
1355 char *tmp; 1481 char *tmp;
1356 1482
1357 if (b->alias && b->alias[0]) 1483 if (b->alias && b->alias[0]){
1358 {
1359 char *aliastext = g_markup_escape_text(b->alias, -1); 1484 char *aliastext = g_markup_escape_text(b->alias, -1);
1360 purple_notify_user_info_add_pair(user_info, _("Alias"), aliastext); 1485 purple_notify_user_info_add_pair(user_info, _("Alias"), aliastext);
1361 g_free(aliastext); 1486 g_free(aliastext);
1362 } 1487 }
1363 1488
1364 if (b->server_alias) 1489 if (b->server_alias){
1365 {
1366 char *nicktext = g_markup_escape_text(b->server_alias, -1); 1490 char *nicktext = g_markup_escape_text(b->server_alias, -1);
1367 tmp = g_strdup_printf("<font sml=\"msn\">%s</font><br>", nicktext); 1491 tmp = g_strdup_printf("<font sml=\"msn\">%s</font><br>", nicktext);
1368 purple_notify_user_info_add_pair(user_info, _("Nickname"), tmp); 1492 purple_notify_user_info_add_pair(user_info, _("Nickname"), tmp);
1369 g_free(tmp); 1493 g_free(tmp);
1370 g_free(nicktext); 1494 g_free(nicktext);
1384 static char * 1508 static char *
1385 msn_get_photo_url(const char *url_text) 1509 msn_get_photo_url(const char *url_text)
1386 { 1510 {
1387 char *p, *q; 1511 char *p, *q;
1388 1512
1389 if ((p = strstr(url_text, " contactparams:photopreauthurl=\"")) != NULL) 1513 if ((p = strstr(url_text, PHOTO_URL)) != NULL){
1390 { 1514 p += strlen(PHOTO_URL);
1391 p += strlen(" contactparams:photopreauthurl=\""); 1515 }
1392 } 1516 if (p && (strncmp(p, "http://",strlen("http://")) == 0) && ((q = strchr(p, '"')) != NULL))
1393
1394 if (p && (strncmp(p, "http://", 8) == 0) && ((q = strchr(p, '"')) != NULL))
1395 return g_strndup(p, q - p); 1517 return g_strndup(p, q - p);
1396 1518
1397 return NULL; 1519 return NULL;
1398 } 1520 }
1399 1521
1438 #if PHOTO_SUPPORT 1560 #if PHOTO_SUPPORT
1439 char *photo_url_text = NULL; 1561 char *photo_url_text = NULL;
1440 MsnGetInfoStepTwoData *info2_data = NULL; 1562 MsnGetInfoStepTwoData *info2_data = NULL;
1441 #endif 1563 #endif
1442 1564
1443 purple_debug_info("msn", "In msn_got_info\n"); 1565 purple_debug_info("msn", "In msn_got_info,url_text:{%s}\n",url_text);
1444 1566
1445 /* Make sure the connection is still valid */ 1567 /* Make sure the connection is still valid */
1446 if (g_list_find(purple_connections_get_all(), info_data->gc) == NULL) 1568 if (g_list_find(purple_connections_get_all(), info_data->gc) == NULL)
1447 { 1569 {
1448 purple_debug_warning("msn", "invalid connection. ignoring buddy info.\n"); 1570 purple_debug_warning("msn", "invalid connection. ignoring buddy info.\n");
1819 g_free(tmp); 1941 g_free(tmp);
1820 1942
1821 #if PHOTO_SUPPORT 1943 #if PHOTO_SUPPORT
1822 /* Find the URL to the photo; must be before the marshalling [Bug 994207] */ 1944 /* Find the URL to the photo; must be before the marshalling [Bug 994207] */
1823 photo_url_text = msn_get_photo_url(url_text); 1945 photo_url_text = msn_get_photo_url(url_text);
1946 purple_debug_info("Ma Yuan","photo url:{%s}\n",photo_url_text);
1824 1947
1825 /* Marshall the existing state */ 1948 /* Marshall the existing state */
1826 info2_data = g_malloc0(sizeof(MsnGetInfoStepTwoData)); 1949 info2_data = g_malloc0(sizeof(MsnGetInfoStepTwoData));
1827 info2_data->info_data = info_data; 1950 info2_data->info_data = info_data;
1828 info2_data->stripped = stripped; 1951 info2_data->stripped = stripped;
2043 NULL, /* remove_buddies */ 2166 NULL, /* remove_buddies */
2044 msn_add_permit, /* add_permit */ 2167 msn_add_permit, /* add_permit */
2045 msn_add_deny, /* add_deny */ 2168 msn_add_deny, /* add_deny */
2046 msn_rem_permit, /* rem_permit */ 2169 msn_rem_permit, /* rem_permit */
2047 msn_rem_deny, /* rem_deny */ 2170 msn_rem_deny, /* rem_deny */
2048 msn_set_permit_deny, /* set_permit_deny */ 2171 msn_set_permit_deny, /* set_permit_deny */
2049 NULL, /* join_chat */ 2172 NULL, /* join_chat */
2050 NULL, /* reject chat invite */ 2173 NULL, /* reject chat invite */
2051 NULL, /* get_chat_name */ 2174 NULL, /* get_chat_name */
2052 msn_chat_invite, /* chat_invite */ 2175 msn_chat_invite, /* chat_invite */
2053 msn_chat_leave, /* chat_leave */ 2176 msn_chat_leave, /* chat_leave */
2099 2222
2100 "prpl-msn", /**< id */ 2223 "prpl-msn", /**< id */
2101 "MSN", /**< name */ 2224 "MSN", /**< name */
2102 VERSION, /**< version */ 2225 VERSION, /**< version */
2103 /** summary */ 2226 /** summary */
2104 N_("MSN Protocol Plugin"), 2227 N_("Windows Live Messenger Protocol Plugin"),
2105 /** description */ 2228 /** description */
2106 N_("MSN Protocol Plugin"), 2229 N_("Windows Live Messenger Protocol Plugin"),
2107 "Christian Hammond <chipx86@gnupdate.org>", /**< author */ 2230 "MaYuan <mayuan2006@gmail.com>", /**< author */
2108 PURPLE_WEBSITE, /**< homepage */ 2231 PURPLE_WEBSITE, /**< homepage */
2109 2232
2110 msn_load, /**< load */ 2233 msn_load, /**< load */
2111 msn_unload, /**< unload */ 2234 msn_unload, /**< unload */
2112 NULL, /**< destroy */ 2235 NULL, /**< destroy */
2127 init_plugin(PurplePlugin *plugin) 2250 init_plugin(PurplePlugin *plugin)
2128 { 2251 {
2129 PurpleAccountOption *option; 2252 PurpleAccountOption *option;
2130 2253
2131 option = purple_account_option_string_new(_("Server"), "server", 2254 option = purple_account_option_string_new(_("Server"), "server",
2132 MSN_SERVER); 2255 WLM_SERVER);
2133 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, 2256 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
2134 option); 2257 option);
2135 2258
2136 option = purple_account_option_int_new(_("Port"), "port", 1863); 2259 option = purple_account_option_int_new(_("Port"), "port", WLM_PORT);
2137 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, 2260 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
2138 option); 2261 option);
2139 2262
2140 option = purple_account_option_bool_new(_("Use HTTP Method"), 2263 option = purple_account_option_bool_new(_("Use HTTP Method"),
2141 "http_method", FALSE); 2264 "http_method", FALSE);