Mercurial > pidgin.yaz
comparison libpurple/protocols/msn/msn.c @ 21000:89c7be36fd61
propagate from branch 'im.pidgin.pidgin.2.2.2' (head 0adab134b7a42e144aee3ac60d825db1f28a42a4)
to branch 'im.pidgin.pidgin' (head 4e59fcb1e2baf2eb63083224381e0af9fe1331cc)
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Tue, 23 Oct 2007 17:27:12 +0000 |
parents | a482263cf1d8 bc731b26335c |
children | 27c72bd82a81 f387e8c671a4 3f5b0039428b |
comparison
equal
deleted
inserted
replaced
20374:535de68c9d09 | 21000:89c7be36fd61 |
---|---|
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" |
149 serv_send_attention(gc, username, MSN_NUDGE); | 149 serv_send_attention(gc, username, MSN_NUDGE); |
150 | 150 |
151 return PURPLE_CMD_RET_OK; | 151 return PURPLE_CMD_RET_OK; |
152 } | 152 } |
153 | 153 |
154 static void | 154 void |
155 msn_act_id(PurpleConnection *gc, const char *entry) | 155 msn_act_id(PurpleConnection *gc, const char *entry) |
156 { | 156 { |
157 MsnCmdProc *cmdproc; | 157 MsnCmdProc *cmdproc; |
158 MsnSession *session; | 158 MsnSession *session; |
159 PurpleAccount *account; | 159 PurpleAccount *account; |
173 purple_notify_error(gc, NULL, | 173 purple_notify_error(gc, NULL, |
174 _("Your new MSN friendly name is too long."), NULL); | 174 _("Your new MSN friendly name is too long."), NULL); |
175 return; | 175 return; |
176 } | 176 } |
177 | 177 |
178 msn_cmdproc_send(cmdproc, "REA", "%s %s", | 178 if (*alias == '\0') { |
179 purple_account_get_username(account), | 179 alias = purple_url_encode(purple_account_get_username(account)); |
180 alias); | 180 } |
181 | |
182 msn_cmdproc_send(cmdproc, "PRP", "MFN %s", alias); | |
183 | |
181 } | 184 } |
182 | 185 |
183 static void | 186 static void |
184 msn_set_prp(PurpleConnection *gc, const char *type, const char *entry) | 187 msn_set_prp(PurpleConnection *gc, const char *type, const char *entry) |
185 { | 188 { |
249 payload = msn_page_gen_payload(page, &payload_len); | 252 payload = msn_page_gen_payload(page, &payload_len); |
250 | 253 |
251 trans = msn_transaction_new(cmdproc, "PGD", "%s 1 %d", who, payload_len); | 254 trans = msn_transaction_new(cmdproc, "PGD", "%s 1 %d", who, payload_len); |
252 | 255 |
253 msn_transaction_set_payload(trans, payload, payload_len); | 256 msn_transaction_set_payload(trans, payload, payload_len); |
257 g_free(payload); | |
254 | 258 |
255 msn_page_destroy(page); | 259 msn_page_destroy(page); |
256 | 260 |
257 msn_cmdproc_send_trans(cmdproc, trans); | 261 msn_cmdproc_send_trans(cmdproc, trans); |
258 } | 262 } |
412 return FALSE; | 416 return FALSE; |
413 user = buddy->proto_data; | 417 user = buddy->proto_data; |
414 return user && user->mobile; | 418 return user && user->mobile; |
415 } | 419 } |
416 | 420 |
421 void | |
422 msn_send_privacy(PurpleConnection *gc) | |
423 { | |
424 PurpleAccount *account; | |
425 MsnSession *session; | |
426 MsnCmdProc *cmdproc; | |
427 | |
428 account = purple_connection_get_account(gc); | |
429 session = gc->proto_data; | |
430 cmdproc = session->notification->cmdproc; | |
431 | |
432 if (account->perm_deny == PURPLE_PRIVACY_ALLOW_ALL || | |
433 account->perm_deny == PURPLE_PRIVACY_DENY_USERS) | |
434 { | |
435 msn_cmdproc_send(cmdproc, "BLP", "%s", "AL"); | |
436 } | |
437 else | |
438 { | |
439 msn_cmdproc_send(cmdproc, "BLP", "%s", "BL"); | |
440 } | |
441 } | |
442 | |
417 static void | 443 static void |
418 initiate_chat_cb(PurpleBlistNode *node, gpointer data) | 444 initiate_chat_cb(PurpleBlistNode *node, gpointer data) |
419 { | 445 { |
420 PurpleBuddy *buddy; | 446 PurpleBuddy *buddy; |
421 PurpleConnection *gc; | 447 PurpleConnection *gc; |
458 PurpleXfer *xfer; | 484 PurpleXfer *xfer; |
459 | 485 |
460 session = gc->proto_data; | 486 session = gc->proto_data; |
461 | 487 |
462 xfer = purple_xfer_new(gc->account, PURPLE_XFER_SEND, who); | 488 xfer = purple_xfer_new(gc->account, PURPLE_XFER_SEND, who); |
489 | |
463 if (xfer) | 490 if (xfer) |
464 { | 491 { |
465 slplink = msn_session_get_slplink(session, who); | 492 slplink = msn_session_get_slplink(session, who); |
466 | 493 |
467 xfer->data = slplink; | 494 xfer->data = slplink; |
509 msn_list_icon(PurpleAccount *a, PurpleBuddy *b) | 536 msn_list_icon(PurpleAccount *a, PurpleBuddy *b) |
510 { | 537 { |
511 return "msn"; | 538 return "msn"; |
512 } | 539 } |
513 | 540 |
541 /* | |
542 * Set the User status text | |
543 * Add the PSM String Using "Name - PSM String" format | |
544 */ | |
514 static char * | 545 static char * |
515 msn_status_text(PurpleBuddy *buddy) | 546 msn_status_text(PurpleBuddy *buddy) |
516 { | 547 { |
517 PurplePresence *presence; | 548 PurplePresence *presence; |
518 PurpleStatus *status; | 549 PurpleStatus *status; |
550 const char *msg, *cmedia; | |
519 | 551 |
520 presence = purple_buddy_get_presence(buddy); | 552 presence = purple_buddy_get_presence(buddy); |
521 status = purple_presence_get_active_status(presence); | 553 status = purple_presence_get_active_status(presence); |
522 | 554 |
523 if (!purple_presence_is_available(presence) && !purple_presence_is_idle(presence)) | 555 msg = purple_status_get_attr_string(status, "message"); |
524 { | 556 cmedia = purple_status_get_attr_string(status, PURPLE_TUNE_FULL); |
525 return g_strdup(purple_status_get_name(status)); | 557 |
526 } | 558 if (cmedia) |
527 | 559 return g_markup_escape_text(cmedia, -1); |
560 else if (msg) | |
561 return g_markup_escape_text(msg, -1); | |
528 return NULL; | 562 return NULL; |
529 } | 563 } |
530 | 564 |
531 static void | 565 static void |
532 msn_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean full) | 566 msn_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean full) |
538 user = buddy->proto_data; | 572 user = buddy->proto_data; |
539 | 573 |
540 | 574 |
541 if (purple_presence_is_online(presence)) | 575 if (purple_presence_is_online(presence)) |
542 { | 576 { |
543 purple_notify_user_info_add_pair(user_info, _("Status"), | 577 const char *psm, *currentmedia, *name; |
544 (purple_presence_is_idle(presence) ? _("Idle") : purple_status_get_name(status))); | 578 char *tmp; |
545 } | 579 |
546 | 580 psm = purple_status_get_attr_string(status, "message"); |
547 if (full && user) | 581 currentmedia = purple_status_get_attr_string(status, PURPLE_TUNE_FULL); |
548 { | 582 |
549 purple_notify_user_info_add_pair(user_info, _("Has you"), | 583 if (!purple_presence_is_available(presence)) { |
550 ((user->list_op & (1 << MSN_LIST_RL)) ? _("Yes") : _("No"))); | 584 name = purple_status_get_name(status); |
585 } else { | |
586 name = NULL; | |
587 } | |
588 | |
589 if (name != NULL && *name) { | |
590 char *tmp2 = g_markup_escape_text(name, -1); | |
591 | |
592 if (psm != NULL && *psm) { | |
593 tmp = g_markup_escape_text(psm, -1); | |
594 purple_notify_user_info_add_pair(user_info, tmp2, tmp); | |
595 g_free(tmp); | |
596 } else { | |
597 purple_notify_user_info_add_pair(user_info, _("Status"), tmp2); | |
598 } | |
599 | |
600 g_free(tmp2); | |
601 } else { | |
602 if (psm != NULL && *psm) { | |
603 tmp = g_markup_escape_text(psm, -1); | |
604 purple_notify_user_info_add_pair(user_info, _("Status"), tmp); | |
605 g_free(tmp); | |
606 } | |
607 } | |
608 | |
609 if (currentmedia) { | |
610 tmp = g_markup_escape_text(currentmedia, -1); | |
611 purple_notify_user_info_add_pair(user_info, _("Current media"), tmp); | |
612 g_free(tmp); | |
613 } | |
551 } | 614 } |
552 | 615 |
553 /* XXX: This is being shown in non-full tooltips because the | 616 /* XXX: This is being shown in non-full tooltips because the |
554 * XXX: blocked icon overlay isn't always accurate for MSN. | 617 * XXX: blocked icon overlay isn't always accurate for MSN. |
555 * XXX: This can die as soon as purple_privacy_check() knows that | 618 * XXX: This can die as soon as purple_privacy_check() knows that |
565 msn_status_types(PurpleAccount *account) | 628 msn_status_types(PurpleAccount *account) |
566 { | 629 { |
567 PurpleStatusType *status; | 630 PurpleStatusType *status; |
568 GList *types = NULL; | 631 GList *types = NULL; |
569 | 632 |
570 status = purple_status_type_new_full(PURPLE_STATUS_AVAILABLE, | 633 status = purple_status_type_new_with_attrs( |
571 NULL, NULL, FALSE, TRUE, FALSE); | 634 PURPLE_STATUS_AVAILABLE, NULL, NULL, TRUE, TRUE, FALSE, |
635 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
636 PURPLE_TUNE_FULL, _("Current media"), purple_value_new(PURPLE_TYPE_STRING), | |
637 NULL); | |
572 types = g_list_append(types, status); | 638 types = g_list_append(types, status); |
573 | 639 |
574 status = purple_status_type_new_full(PURPLE_STATUS_AWAY, | 640 status = purple_status_type_new_with_attrs( |
575 NULL, NULL, FALSE, TRUE, FALSE); | 641 PURPLE_STATUS_AWAY, NULL, NULL, TRUE, TRUE, FALSE, |
642 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
643 PURPLE_TUNE_FULL, _("Current media"), purple_value_new(PURPLE_TYPE_STRING), | |
644 NULL); | |
576 types = g_list_append(types, status); | 645 types = g_list_append(types, status); |
577 | 646 |
578 status = purple_status_type_new_full(PURPLE_STATUS_AWAY, | 647 status = purple_status_type_new_with_attrs( |
579 "brb", _("Be Right Back"), FALSE, TRUE, FALSE); | 648 PURPLE_STATUS_AWAY, "brb", _("Be Right Back"), TRUE, TRUE, FALSE, |
649 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
650 PURPLE_TUNE_FULL, _("Current media"), purple_value_new(PURPLE_TYPE_STRING), | |
651 NULL); | |
580 types = g_list_append(types, status); | 652 types = g_list_append(types, status); |
581 | 653 |
582 status = purple_status_type_new_full(PURPLE_STATUS_UNAVAILABLE, | 654 status = purple_status_type_new_with_attrs( |
583 "busy", _("Busy"), FALSE, TRUE, FALSE); | 655 PURPLE_STATUS_UNAVAILABLE, "busy", _("Busy"), TRUE, TRUE, FALSE, |
656 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
657 PURPLE_TUNE_FULL, _("Current media"), purple_value_new(PURPLE_TYPE_STRING), | |
658 NULL); | |
584 types = g_list_append(types, status); | 659 types = g_list_append(types, status); |
585 | 660 status = purple_status_type_new_with_attrs( |
586 status = purple_status_type_new_full(PURPLE_STATUS_UNAVAILABLE, | 661 PURPLE_STATUS_UNAVAILABLE, "phone", _("On the Phone"), TRUE, TRUE, FALSE, |
587 "phone", _("On the Phone"), FALSE, TRUE, FALSE); | 662 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), |
663 PURPLE_TUNE_FULL, _("Current media"), purple_value_new(PURPLE_TYPE_STRING), | |
664 NULL); | |
588 types = g_list_append(types, status); | 665 types = g_list_append(types, status); |
589 | 666 status = purple_status_type_new_with_attrs( |
590 status = purple_status_type_new_full(PURPLE_STATUS_AWAY, | 667 PURPLE_STATUS_AWAY, "lunch", _("Out to Lunch"), TRUE, TRUE, FALSE, |
591 "lunch", _("Out to Lunch"), FALSE, TRUE, FALSE); | 668 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), |
669 PURPLE_TUNE_FULL, _("Current media"), purple_value_new(PURPLE_TYPE_STRING), | |
670 NULL); | |
592 types = g_list_append(types, status); | 671 types = g_list_append(types, status); |
593 | 672 |
594 status = purple_status_type_new_full(PURPLE_STATUS_INVISIBLE, | 673 status = purple_status_type_new_full(PURPLE_STATUS_INVISIBLE, |
595 NULL, NULL, FALSE, TRUE, FALSE); | 674 NULL, NULL, FALSE, TRUE, FALSE); |
596 types = g_list_append(types, status); | 675 types = g_list_append(types, status); |
786 PurpleBuddy *buddy = purple_find_buddy(gc->account, who); | 865 PurpleBuddy *buddy = purple_find_buddy(gc->account, who); |
787 MsnMessage *msg; | 866 MsnMessage *msg; |
788 char *msgformat; | 867 char *msgformat; |
789 char *msgtext; | 868 char *msgtext; |
790 | 869 |
870 purple_debug_info("MSNP14","send IM {%s} to %s\n",message,who); | |
791 account = purple_connection_get_account(gc); | 871 account = purple_connection_get_account(gc); |
792 | 872 |
793 if (buddy) { | 873 if (buddy) { |
794 PurplePresence *p = purple_buddy_get_presence(buddy); | 874 PurplePresence *p = purple_buddy_get_presence(buddy); |
795 if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_MOBILE)) { | 875 if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_MOBILE)) { |
799 return 1; | 879 return 1; |
800 } | 880 } |
801 } | 881 } |
802 | 882 |
803 msn_import_html(message, &msgformat, &msgtext); | 883 msn_import_html(message, &msgformat, &msgtext); |
804 | 884 if(msn_user_is_online(account, who)|| |
805 if (strlen(msgtext) + strlen(msgformat) + strlen(VERSION) > 1564) | 885 msn_user_is_yahoo(account, who)){ |
806 { | 886 /*User online,then send Online Instant Message*/ |
887 | |
888 if (strlen(msgtext) + strlen(msgformat) + strlen(VERSION) > 1564) | |
889 { | |
890 g_free(msgformat); | |
891 g_free(msgtext); | |
892 | |
893 return -E2BIG; | |
894 } | |
895 | |
896 msg = msn_message_new_plain(msgtext); | |
897 msg->remote_user = g_strdup(who); | |
898 msn_message_set_attr(msg, "X-MMS-IM-Format", msgformat); | |
899 | |
807 g_free(msgformat); | 900 g_free(msgformat); |
808 g_free(msgtext); | 901 g_free(msgtext); |
809 | 902 |
810 return -E2BIG; | 903 purple_debug_info("MSNP14","prepare to send online Message\n"); |
811 } | 904 if (g_ascii_strcasecmp(who, purple_account_get_username(account))) |
812 | 905 { |
813 msg = msn_message_new_plain(msgtext); | 906 MsnSession *session; |
814 msn_message_set_attr(msg, "X-MMS-IM-Format", msgformat); | 907 MsnSwitchBoard *swboard; |
815 | 908 |
816 g_free(msgformat); | 909 session = gc->proto_data; |
817 g_free(msgtext); | 910 if(msn_user_is_yahoo(account,who)){ |
818 | 911 /*we send the online and offline Message to Yahoo User via UBM*/ |
819 if (g_ascii_strcasecmp(who, purple_account_get_username(account))) | 912 purple_debug_info("MSNP14","send to Yahoo User\n"); |
820 { | 913 uum_send_msg(session,msg); |
914 }else{ | |
915 purple_debug_info("MSNP14","send via switchboard\n"); | |
916 swboard = msn_session_get_swboard(session, who, MSN_SB_FLAG_IM); | |
917 msn_switchboard_send_msg(swboard, msg, TRUE); | |
918 } | |
919 } | |
920 else | |
921 { | |
922 char *body_str, *body_enc, *pre, *post; | |
923 const char *format; | |
924 MsnIMData *imdata = g_new0(MsnIMData, 1); | |
925 /* | |
926 * In MSN, you can't send messages to yourself, so | |
927 * we'll fake like we received it ;) | |
928 */ | |
929 body_str = msn_message_to_string(msg); | |
930 body_enc = g_markup_escape_text(body_str, -1); | |
931 g_free(body_str); | |
932 | |
933 format = msn_message_get_attr(msg, "X-MMS-IM-Format"); | |
934 msn_parse_format(format, &pre, &post); | |
935 body_str = g_strdup_printf("%s%s%s", pre ? pre : "", | |
936 body_enc ? body_enc : "", post ? post : ""); | |
937 g_free(body_enc); | |
938 g_free(pre); | |
939 g_free(post); | |
940 | |
941 serv_got_typing_stopped(gc, who); | |
942 imdata->gc = gc; | |
943 imdata->who = who; | |
944 imdata->msg = body_str; | |
945 imdata->flags = flags; | |
946 imdata->when = time(NULL); | |
947 purple_timeout_add(0, msn_send_me_im, imdata); | |
948 } | |
949 | |
950 msn_message_destroy(msg); | |
951 }else { | |
952 /*send Offline Instant Message,only to MSN Passport User*/ | |
821 MsnSession *session; | 953 MsnSession *session; |
822 MsnSwitchBoard *swboard; | 954 MsnOim *oim; |
823 | 955 char *friendname; |
956 | |
957 purple_debug_info("MSNP14","prepare to send offline Message\n"); | |
824 session = gc->proto_data; | 958 session = gc->proto_data; |
825 swboard = msn_session_get_swboard(session, who, MSN_SB_FLAG_IM); | 959 /* XXX/khc: hack */ |
826 | 960 if (!session->oim) |
827 msn_switchboard_send_msg(swboard, msg, TRUE); | 961 session->oim = msn_oim_new(session); |
828 } | 962 |
829 else | 963 oim = session->oim; |
830 { | 964 friendname = msn_encode_mime(account->username); |
831 char *body_str, *body_enc, *pre, *post; | 965 msn_oim_prep_send_msg_info(oim, purple_account_get_username(account), |
832 const char *format; | 966 friendname, who, message); |
833 MsnIMData *imdata = g_new0(MsnIMData, 1); | 967 g_free(friendname); |
834 /* | 968 msn_oim_send_msg(oim); |
835 * In MSN, you can't send messages to yourself, so | 969 } |
836 * we'll fake like we received it ;) | |
837 */ | |
838 body_str = msn_message_to_string(msg); | |
839 body_enc = g_markup_escape_text(body_str, -1); | |
840 g_free(body_str); | |
841 | |
842 format = msn_message_get_attr(msg, "X-MMS-IM-Format"); | |
843 msn_parse_format(format, &pre, &post); | |
844 body_str = g_strdup_printf("%s%s%s", pre ? pre : "", | |
845 body_enc ? body_enc : "", post ? post : ""); | |
846 g_free(body_enc); | |
847 g_free(pre); | |
848 g_free(post); | |
849 | |
850 serv_got_typing_stopped(gc, who); | |
851 imdata->gc = gc; | |
852 imdata->who = who; | |
853 imdata->msg = body_str; | |
854 imdata->flags = flags; | |
855 imdata->when = time(NULL); | |
856 g_idle_add(msn_send_me_im, imdata); | |
857 } | |
858 | |
859 msn_message_destroy(msg); | |
860 | 970 |
861 return 1; | 971 return 1; |
862 } | 972 } |
863 | 973 |
864 static unsigned int | 974 static unsigned int |
993 | 1103 |
994 session = gc->proto_data; | 1104 session = gc->proto_data; |
995 userlist = session->userlist; | 1105 userlist = session->userlist; |
996 who = msn_normalize(gc->account, buddy->name); | 1106 who = msn_normalize(gc->account, buddy->name); |
997 | 1107 |
1108 purple_debug_info("MSN","Add user:%s to group:%s\n", who, (group && group->name) ? group->name : "(null)"); | |
998 if (!session->logged_in) | 1109 if (!session->logged_in) |
999 { | 1110 { |
1000 #if 0 | 1111 #if 0 |
1001 fake_userlist_add_buddy(session->sync_userlist, who, MSN_LIST_FL, | 1112 fake_userlist_add_buddy(session->sync_userlist, who, MSN_LIST_FL, |
1002 group ? group->name : NULL); | 1113 group ? group->name : NULL); |
1026 #endif | 1137 #endif |
1027 | 1138 |
1028 /* XXX - Would group ever be NULL here? I don't think so... | 1139 /* XXX - Would group ever be NULL here? I don't think so... |
1029 * shx: Yes it should; MSN handles non-grouped buddies, and this is only | 1140 * shx: Yes it should; MSN handles non-grouped buddies, and this is only |
1030 * internal. */ | 1141 * internal. */ |
1031 msn_userlist_add_buddy(userlist, who, MSN_LIST_FL, | 1142 msn_userlist_add_buddy(userlist, who, group ? group->name : NULL); |
1032 group ? group->name : NULL); | |
1033 } | 1143 } |
1034 | 1144 |
1035 static void | 1145 static void |
1036 msn_rem_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) | 1146 msn_rem_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
1037 { | 1147 { |
1043 | 1153 |
1044 if (!session->logged_in) | 1154 if (!session->logged_in) |
1045 return; | 1155 return; |
1046 | 1156 |
1047 /* XXX - Does buddy->name need to be msn_normalize'd here? --KingAnt */ | 1157 /* XXX - Does buddy->name need to be msn_normalize'd here? --KingAnt */ |
1048 msn_userlist_rem_buddy(userlist, buddy->name, MSN_LIST_FL, group->name); | 1158 msn_userlist_rem_buddy(userlist, buddy->name); |
1049 } | 1159 } |
1050 | 1160 |
1051 static void | 1161 static void |
1052 msn_add_permit(PurpleConnection *gc, const char *who) | 1162 msn_add_permit(PurpleConnection *gc, const char *who) |
1053 { | 1163 { |
1060 user = msn_userlist_find_user(userlist, who); | 1170 user = msn_userlist_find_user(userlist, who); |
1061 | 1171 |
1062 if (!session->logged_in) | 1172 if (!session->logged_in) |
1063 return; | 1173 return; |
1064 | 1174 |
1065 if (user != NULL && user->list_op & MSN_LIST_BL_OP) | 1175 if (user != NULL && user->list_op & MSN_LIST_BL_OP) { |
1066 msn_userlist_rem_buddy(userlist, who, MSN_LIST_BL, NULL); | 1176 msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_BL); |
1067 | 1177 |
1068 msn_userlist_add_buddy(userlist, who, MSN_LIST_AL, NULL); | 1178 /* delete contact from Block list and add it to Allow in the callback */ |
1179 msn_del_contact_from_list(session->contact, NULL, who, MSN_LIST_BL); | |
1180 } else { | |
1181 /* just add the contact to Allow list */ | |
1182 msn_add_contact_to_list(session->contact, NULL, who, MSN_LIST_AL); | |
1183 } | |
1184 | |
1185 | |
1186 msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_AL); | |
1069 } | 1187 } |
1070 | 1188 |
1071 static void | 1189 static void |
1072 msn_add_deny(PurpleConnection *gc, const char *who) | 1190 msn_add_deny(PurpleConnection *gc, const char *who) |
1073 { | 1191 { |
1080 user = msn_userlist_find_user(userlist, who); | 1198 user = msn_userlist_find_user(userlist, who); |
1081 | 1199 |
1082 if (!session->logged_in) | 1200 if (!session->logged_in) |
1083 return; | 1201 return; |
1084 | 1202 |
1085 if (user != NULL && user->list_op & MSN_LIST_AL_OP) | 1203 if (user != NULL && user->list_op & MSN_LIST_AL_OP) { |
1086 msn_userlist_rem_buddy(userlist, who, MSN_LIST_AL, NULL); | 1204 msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_AL); |
1087 | 1205 |
1088 msn_userlist_add_buddy(userlist, who, MSN_LIST_BL, NULL); | 1206 /* delete contact from Allow list and add it to Block in the callback */ |
1207 msn_del_contact_from_list(session->contact, NULL, who, MSN_LIST_AL); | |
1208 } else { | |
1209 /* just add the contact to Block list */ | |
1210 msn_add_contact_to_list(session->contact, NULL, who, MSN_LIST_BL); | |
1211 } | |
1212 | |
1213 msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_BL); | |
1089 } | 1214 } |
1090 | 1215 |
1091 static void | 1216 static void |
1092 msn_rem_permit(PurpleConnection *gc, const char *who) | 1217 msn_rem_permit(PurpleConnection *gc, const char *who) |
1093 { | 1218 { |
1101 if (!session->logged_in) | 1226 if (!session->logged_in) |
1102 return; | 1227 return; |
1103 | 1228 |
1104 user = msn_userlist_find_user(userlist, who); | 1229 user = msn_userlist_find_user(userlist, who); |
1105 | 1230 |
1106 msn_userlist_rem_buddy(userlist, who, MSN_LIST_AL, NULL); | 1231 msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_AL); |
1232 | |
1233 msn_del_contact_from_list(session->contact, NULL, who, MSN_LIST_AL); | |
1107 | 1234 |
1108 if (user != NULL && user->list_op & MSN_LIST_RL_OP) | 1235 if (user != NULL && user->list_op & MSN_LIST_RL_OP) |
1109 msn_userlist_add_buddy(userlist, who, MSN_LIST_BL, NULL); | 1236 msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_BL); |
1110 } | 1237 } |
1111 | 1238 |
1112 static void | 1239 static void |
1113 msn_rem_deny(PurpleConnection *gc, const char *who) | 1240 msn_rem_deny(PurpleConnection *gc, const char *who) |
1114 { | 1241 { |
1122 if (!session->logged_in) | 1249 if (!session->logged_in) |
1123 return; | 1250 return; |
1124 | 1251 |
1125 user = msn_userlist_find_user(userlist, who); | 1252 user = msn_userlist_find_user(userlist, who); |
1126 | 1253 |
1127 msn_userlist_rem_buddy(userlist, who, MSN_LIST_BL, NULL); | 1254 msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_BL); |
1255 | |
1256 msn_del_contact_from_list(session->contact, NULL, who, MSN_LIST_BL); | |
1128 | 1257 |
1129 if (user != NULL && user->list_op & MSN_LIST_RL_OP) | 1258 if (user != NULL && user->list_op & MSN_LIST_RL_OP) |
1130 msn_userlist_add_buddy(userlist, who, MSN_LIST_AL, NULL); | 1259 msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_AL); |
1131 } | 1260 } |
1132 | 1261 |
1133 static void | 1262 static void |
1134 msn_set_permit_deny(PurpleConnection *gc) | 1263 msn_set_permit_deny(PurpleConnection *gc) |
1135 { | 1264 { |
1136 PurpleAccount *account; | 1265 msn_send_privacy(gc); |
1137 MsnSession *session; | |
1138 MsnCmdProc *cmdproc; | |
1139 | |
1140 account = purple_connection_get_account(gc); | |
1141 session = gc->proto_data; | |
1142 cmdproc = session->notification->cmdproc; | |
1143 | |
1144 if (account->perm_deny == PURPLE_PRIVACY_ALLOW_ALL || | |
1145 account->perm_deny == PURPLE_PRIVACY_DENY_USERS) | |
1146 { | |
1147 msn_cmdproc_send(cmdproc, "BLP", "%s", "AL"); | |
1148 } | |
1149 else | |
1150 { | |
1151 msn_cmdproc_send(cmdproc, "BLP", "%s", "BL"); | |
1152 } | |
1153 } | 1266 } |
1154 | 1267 |
1155 static void | 1268 static void |
1156 msn_chat_invite(PurpleConnection *gc, int id, const char *msg, | 1269 msn_chat_invite(PurpleConnection *gc, int id, const char *msg, |
1157 const char *who) | 1270 const char *who) |
1284 static void | 1397 static void |
1285 msn_rename_group(PurpleConnection *gc, const char *old_name, | 1398 msn_rename_group(PurpleConnection *gc, const char *old_name, |
1286 PurpleGroup *group, GList *moved_buddies) | 1399 PurpleGroup *group, GList *moved_buddies) |
1287 { | 1400 { |
1288 MsnSession *session; | 1401 MsnSession *session; |
1289 MsnCmdProc *cmdproc; | 1402 |
1290 int old_gid; | 1403 session = gc->proto_data; |
1291 const char *enc_new_group_name; | 1404 |
1292 | 1405 g_return_if_fail(session != NULL); |
1293 session = gc->proto_data; | 1406 g_return_if_fail(session->userlist != NULL); |
1294 cmdproc = session->notification->cmdproc; | 1407 |
1295 enc_new_group_name = purple_url_encode(group->name); | 1408 if (msn_userlist_find_group_with_name(session->userlist, old_name) != NULL) |
1296 | 1409 { |
1297 old_gid = msn_userlist_find_group_id(session->userlist, old_name); | 1410 msn_contact_rename_group(session, old_name, group->name); |
1298 | |
1299 if (old_gid >= 0) | |
1300 { | |
1301 msn_cmdproc_send(cmdproc, "REG", "%d %s 0", old_gid, | |
1302 enc_new_group_name); | |
1303 } | 1411 } |
1304 else | 1412 else |
1305 { | 1413 { |
1306 msn_cmdproc_send(cmdproc, "ADG", "%s 0", enc_new_group_name); | 1414 /* not found */ |
1415 msn_add_group(session, NULL, group->name); | |
1307 } | 1416 } |
1308 } | 1417 } |
1309 | 1418 |
1310 static void | 1419 static void |
1311 msn_convo_closed(PurpleConnection *gc, const char *who) | 1420 msn_convo_closed(PurpleConnection *gc, const char *who) |
1361 static void | 1470 static void |
1362 msn_remove_group(PurpleConnection *gc, PurpleGroup *group) | 1471 msn_remove_group(PurpleConnection *gc, PurpleGroup *group) |
1363 { | 1472 { |
1364 MsnSession *session; | 1473 MsnSession *session; |
1365 MsnCmdProc *cmdproc; | 1474 MsnCmdProc *cmdproc; |
1366 int group_id; | |
1367 | 1475 |
1368 session = gc->proto_data; | 1476 session = gc->proto_data; |
1369 cmdproc = session->notification->cmdproc; | 1477 cmdproc = session->notification->cmdproc; |
1370 | 1478 |
1371 if ((group_id = msn_userlist_find_group_id(session->userlist, group->name)) >= 0) | 1479 purple_debug_info("MSN", "Remove group %s\n", group->name); |
1372 { | 1480 /*we can't delete the default group*/ |
1373 msn_cmdproc_send(cmdproc, "RMG", "%d", group_id); | 1481 if(!strcmp(group->name, MSN_INDIVIDUALS_GROUP_NAME)|| |
1374 } | 1482 !strcmp(group->name, MSN_NON_IM_GROUP_NAME)) |
1483 { | |
1484 purple_debug_info("MSN", "This group can't be removed, returning.\n"); | |
1485 return ; | |
1486 } | |
1487 | |
1488 msn_del_group(session, group->name); | |
1375 } | 1489 } |
1376 | 1490 |
1377 /** | 1491 /** |
1378 * Extract info text from info_data and add it to user_info | 1492 * Extract info text from info_data and add it to user_info |
1379 */ | 1493 */ |
1419 static char * | 1533 static char * |
1420 msn_get_photo_url(const char *url_text) | 1534 msn_get_photo_url(const char *url_text) |
1421 { | 1535 { |
1422 char *p, *q; | 1536 char *p, *q; |
1423 | 1537 |
1424 if ((p = strstr(url_text, " contactparams:photopreauthurl=\"")) != NULL) | 1538 if ((p = strstr(url_text, PHOTO_URL)) != NULL) |
1425 { | 1539 { |
1426 p += strlen(" contactparams:photopreauthurl=\""); | 1540 p += strlen(PHOTO_URL); |
1427 } | 1541 } |
1428 | 1542 if (p && (strncmp(p, "http://",strlen("http://")) == 0) && ((q = strchr(p, '"')) != NULL)) |
1429 if (p && (strncmp(p, "http://", 8) == 0) && ((q = strchr(p, '"')) != NULL)) | |
1430 return g_strndup(p, q - p); | 1543 return g_strndup(p, q - p); |
1431 | 1544 |
1432 return NULL; | 1545 return NULL; |
1433 } | 1546 } |
1434 | 1547 |
1462 | 1575 |
1463 static char * | 1576 static char * |
1464 msn_info_strip_search_link(const char *field, size_t len) | 1577 msn_info_strip_search_link(const char *field, size_t len) |
1465 { | 1578 { |
1466 const char *c; | 1579 const char *c; |
1467 if ((c = strstr(field, " (http://spaces.live.com/default.aspx?page=searchresults")) == NULL && | 1580 if ((c = strstr(field, " (http://")) == NULL) |
1468 (c = strstr(field, " (http://spaces.msn.com/default.aspx?page=searchresults")) == NULL) | |
1469 return g_strndup(field, len); | 1581 return g_strndup(field, len); |
1470 return g_strndup(field, c - field); | 1582 return g_strndup(field, c - field); |
1471 } | 1583 } |
1472 | 1584 |
1473 static void | 1585 static void |
1488 #if PHOTO_SUPPORT | 1600 #if PHOTO_SUPPORT |
1489 char *photo_url_text = NULL; | 1601 char *photo_url_text = NULL; |
1490 MsnGetInfoStepTwoData *info2_data = NULL; | 1602 MsnGetInfoStepTwoData *info2_data = NULL; |
1491 #endif | 1603 #endif |
1492 | 1604 |
1493 purple_debug_info("msn", "In msn_got_info\n"); | 1605 purple_debug_info("msn", "In msn_got_info,url_text:{%s}\n",url_text); |
1494 | 1606 |
1495 /* Make sure the connection is still valid */ | 1607 /* Make sure the connection is still valid */ |
1496 if (g_list_find(purple_connections_get_all(), info_data->gc) == NULL) | 1608 if (g_list_find(purple_connections_get_all(), info_data->gc) == NULL) |
1497 { | 1609 { |
1498 purple_debug_warning("msn", "invalid connection. ignoring buddy info.\n"); | 1610 purple_debug_warning("msn", "invalid connection. ignoring buddy info.\n"); |
1867 g_free(tmp); | 1979 g_free(tmp); |
1868 | 1980 |
1869 #if PHOTO_SUPPORT | 1981 #if PHOTO_SUPPORT |
1870 /* Find the URL to the photo; must be before the marshalling [Bug 994207] */ | 1982 /* Find the URL to the photo; must be before the marshalling [Bug 994207] */ |
1871 photo_url_text = msn_get_photo_url(url_text); | 1983 photo_url_text = msn_get_photo_url(url_text); |
1984 purple_debug_info("MSNP14","photo url:{%s}\n", photo_url_text ? photo_url_text : "(null)"); | |
1872 | 1985 |
1873 /* Marshall the existing state */ | 1986 /* Marshall the existing state */ |
1874 info2_data = g_malloc0(sizeof(MsnGetInfoStepTwoData)); | 1987 info2_data = g_new0(MsnGetInfoStepTwoData, 1); |
1875 info2_data->info_data = info_data; | 1988 info2_data->info_data = info_data; |
1876 info2_data->stripped = stripped; | 1989 info2_data->stripped = stripped; |
1877 info2_data->url_buffer = url_buffer; | 1990 info2_data->url_buffer = url_buffer; |
1878 info2_data->user_info = user_info; | 1991 info2_data->user_info = user_info; |
1879 info2_data->photo_url_text = photo_url_text; | 1992 info2_data->photo_url_text = photo_url_text; |
2091 NULL, /* remove_buddies */ | 2204 NULL, /* remove_buddies */ |
2092 msn_add_permit, /* add_permit */ | 2205 msn_add_permit, /* add_permit */ |
2093 msn_add_deny, /* add_deny */ | 2206 msn_add_deny, /* add_deny */ |
2094 msn_rem_permit, /* rem_permit */ | 2207 msn_rem_permit, /* rem_permit */ |
2095 msn_rem_deny, /* rem_deny */ | 2208 msn_rem_deny, /* rem_deny */ |
2096 msn_set_permit_deny, /* set_permit_deny */ | 2209 msn_set_permit_deny, /* set_permit_deny */ |
2097 NULL, /* join_chat */ | 2210 NULL, /* join_chat */ |
2098 NULL, /* reject chat invite */ | 2211 NULL, /* reject chat invite */ |
2099 NULL, /* get_chat_name */ | 2212 NULL, /* get_chat_name */ |
2100 msn_chat_invite, /* chat_invite */ | 2213 msn_chat_invite, /* chat_invite */ |
2101 msn_chat_leave, /* chat_leave */ | 2214 msn_chat_leave, /* chat_leave */ |
2147 | 2260 |
2148 "prpl-msn", /**< id */ | 2261 "prpl-msn", /**< id */ |
2149 "MSN", /**< name */ | 2262 "MSN", /**< name */ |
2150 VERSION, /**< version */ | 2263 VERSION, /**< version */ |
2151 /** summary */ | 2264 /** summary */ |
2152 N_("MSN Protocol Plugin"), | 2265 N_("Windows Live Messenger Protocol Plugin"), |
2153 /** description */ | 2266 /** description */ |
2154 N_("MSN Protocol Plugin"), | 2267 N_("Windows Live Messenger Protocol Plugin"), |
2155 "Christian Hammond <chipx86@gnupdate.org>", /**< author */ | 2268 "Christian Hammond <chipx86@gnupdate.org>, " |
2269 "MaYuan <mayuan2006@gmail.com>", /**< author */ | |
2156 PURPLE_WEBSITE, /**< homepage */ | 2270 PURPLE_WEBSITE, /**< homepage */ |
2157 | 2271 |
2158 msn_load, /**< load */ | 2272 msn_load, /**< load */ |
2159 msn_unload, /**< unload */ | 2273 msn_unload, /**< unload */ |
2160 NULL, /**< destroy */ | 2274 NULL, /**< destroy */ |
2175 init_plugin(PurplePlugin *plugin) | 2289 init_plugin(PurplePlugin *plugin) |
2176 { | 2290 { |
2177 PurpleAccountOption *option; | 2291 PurpleAccountOption *option; |
2178 | 2292 |
2179 option = purple_account_option_string_new(_("Server"), "server", | 2293 option = purple_account_option_string_new(_("Server"), "server", |
2180 MSN_SERVER); | 2294 WLM_SERVER); |
2181 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | 2295 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
2182 option); | 2296 option); |
2183 | 2297 |
2184 option = purple_account_option_int_new(_("Port"), "port", 1863); | 2298 option = purple_account_option_int_new(_("Port"), "port", WLM_PORT); |
2185 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | 2299 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
2186 option); | 2300 option); |
2187 | 2301 |
2188 option = purple_account_option_bool_new(_("Use HTTP Method"), | 2302 option = purple_account_option_bool_new(_("Use HTTP Method"), |
2189 "http_method", FALSE); | 2303 "http_method", FALSE); |