Mercurial > pidgin.yaz
comparison libpurple/protocols/msn/msn.c @ 20418:0f6747c5dcc2
propagate from branch 'im.pidgin.pidgin' (head b0fb787915db137be9b01af88d1fb0c107f66cd6)
to branch 'im.pidgin.cpw.khc.msnp14' (head b26eeab8d7655cb97d30c814bd37041707f692df)
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Sun, 20 May 2007 15:48:51 +0000 |
parents | c2ecc135867d fd7b501cc9c8 |
children | 48e26f248251 |
comparison
equal
deleted
inserted
replaced
17197:c2ecc135867d | 20418:0f6747c5dcc2 |
---|---|
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" |
121 purple_conversation_write(conv, NULL, _("You have just sent a Nudge!"), PURPLE_MESSAGE_SYSTEM, time(NULL)); | 121 purple_conversation_write(conv, NULL, _("You have just sent a Nudge!"), PURPLE_MESSAGE_SYSTEM, time(NULL)); |
122 | 122 |
123 return PURPLE_CMD_RET_OK; | 123 return PURPLE_CMD_RET_OK; |
124 } | 124 } |
125 | 125 |
126 static void | 126 void |
127 msn_act_id(PurpleConnection *gc, const char *entry) | 127 msn_act_id(PurpleConnection *gc, const char *entry) |
128 { | 128 { |
129 MsnCmdProc *cmdproc; | 129 MsnCmdProc *cmdproc; |
130 MsnSession *session; | 130 MsnSession *session; |
131 PurpleAccount *account; | 131 PurpleAccount *account; |
132 const char *alias; | 132 const char *alias; |
133 | |
134 char *soapbody; | |
135 MsnSoapReq *soap_request; | |
133 | 136 |
134 session = gc->proto_data; | 137 session = gc->proto_data; |
135 cmdproc = session->notification->cmdproc; | 138 cmdproc = session->notification->cmdproc; |
136 account = purple_connection_get_account(gc); | 139 account = purple_connection_get_account(gc); |
137 | 140 |
145 purple_notify_error(gc, NULL, | 148 purple_notify_error(gc, NULL, |
146 _("Your new MSN friendly name is too long."), NULL); | 149 _("Your new MSN friendly name is too long."), NULL); |
147 return; | 150 return; |
148 } | 151 } |
149 | 152 |
150 msn_cmdproc_send(cmdproc, "REA", "%s %s", | 153 if (*alias == '\0') { |
151 purple_account_get_username(account), | 154 alias = purple_url_encode(purple_account_get_username(account)); |
152 alias); | 155 } |
156 | |
157 msn_cmdproc_send(cmdproc, "PRP", "MFN %s", alias); | |
158 | |
159 soapbody = g_strdup_printf(MSN_CONTACT_UPDATE_TEMPLATE, alias); | |
160 /*build SOAP and POST it*/ | |
161 soap_request = msn_soap_request_new(MSN_CONTACT_SERVER, | |
162 MSN_ADDRESS_BOOK_POST_URL, | |
163 MSN_CONTACT_UPDATE_SOAP_ACTION, | |
164 soapbody, | |
165 NULL, | |
166 NULL); | |
167 | |
168 session->contact->soapconn->read_cb = NULL; | |
169 msn_soap_post(session->contact->soapconn, | |
170 soap_request, | |
171 msn_contact_connect_init); | |
172 | |
173 g_free(soapbody); | |
153 } | 174 } |
154 | 175 |
155 static void | 176 static void |
156 msn_set_prp(PurpleConnection *gc, const char *type, const char *entry) | 177 msn_set_prp(PurpleConnection *gc, const char *type, const char *entry) |
157 { | 178 { |
430 PurpleXfer *xfer; | 451 PurpleXfer *xfer; |
431 | 452 |
432 session = gc->proto_data; | 453 session = gc->proto_data; |
433 | 454 |
434 xfer = purple_xfer_new(gc->account, PURPLE_XFER_SEND, who); | 455 xfer = purple_xfer_new(gc->account, PURPLE_XFER_SEND, who); |
456 | |
435 if (xfer) | 457 if (xfer) |
436 { | 458 { |
437 slplink = msn_session_get_slplink(session, who); | 459 slplink = msn_session_get_slplink(session, who); |
438 | 460 |
439 xfer->data = slplink; | 461 xfer->data = slplink; |
481 msn_list_icon(PurpleAccount *a, PurpleBuddy *b) | 503 msn_list_icon(PurpleAccount *a, PurpleBuddy *b) |
482 { | 504 { |
483 return "msn"; | 505 return "msn"; |
484 } | 506 } |
485 | 507 |
508 /* | |
509 * Set the User status text | |
510 * Add the PSM String Using "Name - PSM String" format | |
511 */ | |
486 static char * | 512 static char * |
487 msn_status_text(PurpleBuddy *buddy) | 513 msn_status_text(PurpleBuddy *buddy) |
488 { | 514 { |
489 PurplePresence *presence; | 515 PurplePresence *presence; |
490 PurpleStatus *status; | 516 PurpleStatus *status; |
517 const char *msg, *name, *cmedia; | |
518 char *psm_str, *tmp2, *text; | |
491 | 519 |
492 presence = purple_buddy_get_presence(buddy); | 520 presence = purple_buddy_get_presence(buddy); |
493 status = purple_presence_get_active_status(presence); | 521 status = purple_presence_get_active_status(presence); |
494 | 522 |
495 if (!purple_presence_is_available(presence) && !purple_presence_is_idle(presence)) | 523 msg = purple_status_get_attr_string(status, "message"); |
496 { | 524 cmedia=purple_status_get_attr_string(status, "currentmedia"); |
497 return g_strdup(purple_status_get_name(status)); | 525 |
526 if (!purple_presence_is_available(presence) && !purple_presence_is_idle(presence)){ | |
527 name = purple_status_get_name(status); | |
528 }else{ | |
529 name = NULL; | |
530 } | |
531 | |
532 if (cmedia != NULL) { | |
533 if(name) { | |
534 tmp2 = g_strdup_printf("%s - %s", name, cmedia); | |
535 text = g_markup_escape_text(tmp2, -1); | |
536 } else { | |
537 text = g_markup_escape_text(cmedia, -1); | |
538 } | |
539 return text; | |
540 } else if (msg != NULL) { | |
541 tmp2 = purple_markup_strip_html(msg); | |
542 if (name){ | |
543 psm_str = g_strdup_printf("%s - %s", name, tmp2); | |
544 g_free(tmp2); | |
545 }else{ | |
546 psm_str = tmp2; | |
547 } | |
548 text = g_markup_escape_text(psm_str, -1); | |
549 g_free(psm_str); | |
550 return text; | |
551 } else { | |
552 if (!purple_presence_is_available(presence) && !purple_presence_is_idle(presence)){ | |
553 psm_str = g_strdup(purple_status_get_name(status)); | |
554 text = g_markup_escape_text(psm_str, -1); | |
555 g_free(psm_str); | |
556 return text; | |
557 } | |
498 } | 558 } |
499 | 559 |
500 return NULL; | 560 return NULL; |
501 } | 561 } |
502 | 562 |
510 user = buddy->proto_data; | 570 user = buddy->proto_data; |
511 | 571 |
512 | 572 |
513 if (purple_presence_is_online(presence)) | 573 if (purple_presence_is_online(presence)) |
514 { | 574 { |
575 const char *psm, *currentmedia; | |
576 char *tmp; | |
577 | |
578 psm = purple_status_get_attr_string(status, "message"); | |
579 currentmedia = purple_status_get_attr_string(status, "currentmedia"); | |
580 | |
515 purple_notify_user_info_add_pair(user_info, _("Status"), | 581 purple_notify_user_info_add_pair(user_info, _("Status"), |
516 (purple_presence_is_idle(presence) ? _("Idle") : purple_status_get_name(status))); | 582 (purple_presence_is_idle(presence) ? _("Idle") : purple_status_get_name(status))); |
583 if (psm) { | |
584 tmp = g_markup_escape_text(psm, -1); | |
585 purple_notify_user_info_add_pair(user_info, _("PSM"), tmp); | |
586 g_free(tmp); | |
587 } | |
588 if (currentmedia) { | |
589 tmp = g_markup_escape_text(currentmedia, -1); | |
590 purple_notify_user_info_add_pair(user_info, _("Current media"), tmp); | |
591 g_free(tmp); | |
592 } | |
517 } | 593 } |
518 | 594 |
519 if (full && user) | 595 if (full && user) |
520 { | 596 { |
521 purple_notify_user_info_add_pair(user_info, _("Has you"), | 597 purple_notify_user_info_add_pair(user_info, _("Has you"), |
536 static GList * | 612 static GList * |
537 msn_status_types(PurpleAccount *account) | 613 msn_status_types(PurpleAccount *account) |
538 { | 614 { |
539 PurpleStatusType *status; | 615 PurpleStatusType *status; |
540 GList *types = NULL; | 616 GList *types = NULL; |
541 | 617 #if 0 |
542 status = purple_status_type_new_full(PURPLE_STATUS_AVAILABLE, | 618 status = purple_status_type_new_full(PURPLE_STATUS_AVAILABLE, |
543 NULL, NULL, FALSE, TRUE, FALSE); | 619 NULL, NULL, FALSE, TRUE, FALSE); |
620 #endif | |
621 status = purple_status_type_new_with_attrs( | |
622 PURPLE_STATUS_AVAILABLE, NULL, NULL, TRUE, TRUE, FALSE, | |
623 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
624 "currentmedia", _("Current media"), purple_value_new(PURPLE_TYPE_STRING), | |
625 NULL); | |
544 types = g_list_append(types, status); | 626 types = g_list_append(types, status); |
545 | 627 |
546 status = purple_status_type_new_full(PURPLE_STATUS_AWAY, | 628 status = purple_status_type_new_with_attrs( |
547 NULL, NULL, FALSE, TRUE, FALSE); | 629 PURPLE_STATUS_AWAY, NULL, NULL, TRUE, TRUE, FALSE, |
630 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
631 "currentmedia", _("Current media"), purple_value_new(PURPLE_TYPE_STRING), | |
632 NULL); | |
548 types = g_list_append(types, status); | 633 types = g_list_append(types, status); |
549 | 634 |
550 status = purple_status_type_new_full(PURPLE_STATUS_AWAY, | 635 status = purple_status_type_new_with_attrs( |
551 "brb", _("Be Right Back"), FALSE, TRUE, FALSE); | 636 PURPLE_STATUS_AWAY, "brb", _("Be Right Back"), TRUE, TRUE, FALSE, |
637 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
638 "currentmedia", _("Current media"), purple_value_new(PURPLE_TYPE_STRING), | |
639 NULL); | |
552 types = g_list_append(types, status); | 640 types = g_list_append(types, status); |
553 | 641 |
554 status = purple_status_type_new_full(PURPLE_STATUS_UNAVAILABLE, | 642 status = purple_status_type_new_with_attrs( |
555 "busy", _("Busy"), FALSE, TRUE, FALSE); | 643 PURPLE_STATUS_AWAY, "busy", _("Busy"), TRUE, TRUE, FALSE, |
644 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
645 "currentmedia", _("Current media"), purple_value_new(PURPLE_TYPE_STRING), | |
646 NULL); | |
556 types = g_list_append(types, status); | 647 types = g_list_append(types, status); |
557 | 648 status = purple_status_type_new_with_attrs( |
558 status = purple_status_type_new_full(PURPLE_STATUS_UNAVAILABLE, | 649 PURPLE_STATUS_AWAY, "phone", _("On the Phone"), TRUE, TRUE, FALSE, |
559 "phone", _("On the Phone"), FALSE, TRUE, FALSE); | 650 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), |
651 "currentmedia", _("Current media"), purple_value_new(PURPLE_TYPE_STRING), | |
652 NULL); | |
560 types = g_list_append(types, status); | 653 types = g_list_append(types, status); |
561 | 654 status = purple_status_type_new_with_attrs( |
562 status = purple_status_type_new_full(PURPLE_STATUS_AWAY, | 655 PURPLE_STATUS_AWAY, "lunch", _("Out to Lunch"), TRUE, TRUE, FALSE, |
563 "lunch", _("Out to Lunch"), FALSE, TRUE, FALSE); | 656 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), |
657 "currentmedia", _("Current media"), purple_value_new(PURPLE_TYPE_STRING), | |
658 NULL); | |
564 types = g_list_append(types, status); | 659 types = g_list_append(types, status); |
565 | 660 |
566 status = purple_status_type_new_full(PURPLE_STATUS_INVISIBLE, | 661 status = purple_status_type_new_full(PURPLE_STATUS_INVISIBLE, |
567 NULL, NULL, FALSE, TRUE, FALSE); | 662 NULL, NULL, FALSE, TRUE, FALSE); |
568 types = g_list_append(types, status); | 663 types = g_list_append(types, status); |
698 _("SSL support is needed for MSN. Please install a supported " | 793 _("SSL support is needed for MSN. Please install a supported " |
699 "SSL library.")); | 794 "SSL library.")); |
700 return; | 795 return; |
701 } | 796 } |
702 | 797 |
703 http_method = purple_account_get_bool(account, "http_method", FALSE); | 798 if (purple_account_get_bool(account, "http_method", FALSE)) |
799 http_method = TRUE; | |
704 | 800 |
705 host = purple_account_get_string(account, "server", MSN_SERVER); | 801 host = purple_account_get_string(account, "server", MSN_SERVER); |
706 port = purple_account_get_int(account, "port", MSN_PORT); | 802 port = purple_account_get_int(account, "port", MSN_PORT); |
707 | 803 |
708 session = msn_session_new(account); | 804 session = msn_session_new(account); |
755 PurpleBuddy *buddy = purple_find_buddy(gc->account, who); | 851 PurpleBuddy *buddy = purple_find_buddy(gc->account, who); |
756 MsnMessage *msg; | 852 MsnMessage *msg; |
757 char *msgformat; | 853 char *msgformat; |
758 char *msgtext; | 854 char *msgtext; |
759 | 855 |
856 purple_debug_info("MaYuan","send IM {%s} to %s\n",message,who); | |
760 account = purple_connection_get_account(gc); | 857 account = purple_connection_get_account(gc); |
761 | 858 |
762 if (buddy) { | 859 if (buddy) { |
763 PurplePresence *p = purple_buddy_get_presence(buddy); | 860 PurplePresence *p = purple_buddy_get_presence(buddy); |
764 if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_MOBILE)) { | 861 if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_MOBILE)) { |
768 return 1; | 865 return 1; |
769 } | 866 } |
770 } | 867 } |
771 | 868 |
772 msn_import_html(message, &msgformat, &msgtext); | 869 msn_import_html(message, &msgformat, &msgtext); |
773 | 870 if(msn_user_is_online(account, who)|| |
774 if (strlen(msgtext) + strlen(msgformat) + strlen(VERSION) > 1564) | 871 msn_user_is_yahoo(account, who)){ |
775 { | 872 /*User online,then send Online Instant Message*/ |
873 | |
874 if (strlen(msgtext) + strlen(msgformat) + strlen(VERSION) > 1564) | |
875 { | |
876 g_free(msgformat); | |
877 g_free(msgtext); | |
878 | |
879 return -E2BIG; | |
880 } | |
881 | |
882 msg = msn_message_new_plain(msgtext); | |
883 msg->remote_user = g_strdup(who); | |
884 msn_message_set_attr(msg, "X-MMS-IM-Format", msgformat); | |
885 | |
776 g_free(msgformat); | 886 g_free(msgformat); |
777 g_free(msgtext); | 887 g_free(msgtext); |
778 | 888 |
779 return -E2BIG; | 889 purple_debug_info("MaYuan","prepare to send online Message\n"); |
780 } | 890 if (g_ascii_strcasecmp(who, purple_account_get_username(account))) |
781 | 891 { |
782 msg = msn_message_new_plain(msgtext); | 892 MsnSession *session; |
783 msn_message_set_attr(msg, "X-MMS-IM-Format", msgformat); | 893 MsnSwitchBoard *swboard; |
784 | 894 |
785 g_free(msgformat); | 895 session = gc->proto_data; |
786 g_free(msgtext); | 896 if(msn_user_is_yahoo(account,who)){ |
787 | 897 /*we send the online and offline Message to Yahoo User via UBM*/ |
788 if (g_ascii_strcasecmp(who, purple_account_get_username(account))) | 898 purple_debug_info("MaYuan","send to Yahoo User\n"); |
789 { | 899 uum_send_msg(session,msg); |
900 }else{ | |
901 purple_debug_info("MaYuan","send via switchboard\n"); | |
902 swboard = msn_session_get_swboard(session, who, MSN_SB_FLAG_IM); | |
903 msn_switchboard_send_msg(swboard, msg, TRUE); | |
904 } | |
905 } | |
906 else | |
907 { | |
908 char *body_str, *body_enc, *pre, *post; | |
909 const char *format; | |
910 MsnIMData *imdata = g_new0(MsnIMData, 1); | |
911 /* | |
912 * In MSN, you can't send messages to yourself, so | |
913 * we'll fake like we received it ;) | |
914 */ | |
915 body_str = msn_message_to_string(msg); | |
916 body_enc = g_markup_escape_text(body_str, -1); | |
917 g_free(body_str); | |
918 | |
919 format = msn_message_get_attr(msg, "X-MMS-IM-Format"); | |
920 msn_parse_format(format, &pre, &post); | |
921 body_str = g_strdup_printf("%s%s%s", pre ? pre : "", | |
922 body_enc ? body_enc : "", post ? post : ""); | |
923 g_free(body_enc); | |
924 g_free(pre); | |
925 g_free(post); | |
926 | |
927 serv_got_typing_stopped(gc, who); | |
928 imdata->gc = gc; | |
929 imdata->who = who; | |
930 imdata->msg = body_str; | |
931 imdata->flags = flags; | |
932 imdata->when = time(NULL); | |
933 g_idle_add(msn_send_me_im, imdata); | |
934 } | |
935 | |
936 msn_message_destroy(msg); | |
937 }else { | |
938 /*send Offline Instant Message,only to MSN Passport User*/ | |
790 MsnSession *session; | 939 MsnSession *session; |
791 MsnSwitchBoard *swboard; | 940 MsnOim *oim; |
792 | 941 char *friendname; |
942 | |
943 purple_debug_info("MaYuan","prepare to send offline Message\n"); | |
793 session = gc->proto_data; | 944 session = gc->proto_data; |
794 swboard = msn_session_get_swboard(session, who, MSN_SB_FLAG_IM); | 945 /* XXX/khc: hack */ |
795 | 946 if (!session->oim) |
796 msn_switchboard_send_msg(swboard, msg, TRUE); | 947 session->oim = msn_oim_new(session); |
797 } | 948 |
798 else | 949 oim = session->oim; |
799 { | 950 friendname = msn_encode_mime(account->username); |
800 char *body_str, *body_enc, *pre, *post; | 951 msn_oim_prep_send_msg_info(oim, purple_account_get_username(account), |
801 const char *format; | 952 friendname, who, message); |
802 MsnIMData *imdata = g_new0(MsnIMData, 1); | 953 msn_oim_send_msg(oim); |
803 /* | 954 } |
804 * In MSN, you can't send messages to yourself, so | |
805 * we'll fake like we received it ;) | |
806 */ | |
807 body_str = msn_message_to_string(msg); | |
808 body_enc = g_markup_escape_text(body_str, -1); | |
809 g_free(body_str); | |
810 | |
811 format = msn_message_get_attr(msg, "X-MMS-IM-Format"); | |
812 msn_parse_format(format, &pre, &post); | |
813 body_str = g_strdup_printf("%s%s%s", pre ? pre : "", | |
814 body_enc ? body_enc : "", post ? post : ""); | |
815 g_free(body_enc); | |
816 g_free(pre); | |
817 g_free(post); | |
818 | |
819 serv_got_typing_stopped(gc, who); | |
820 imdata->gc = gc; | |
821 imdata->who = who; | |
822 imdata->msg = body_str; | |
823 imdata->flags = flags; | |
824 imdata->when = time(NULL); | |
825 g_idle_add(msn_send_me_im, imdata); | |
826 } | |
827 | |
828 msn_message_destroy(msg); | |
829 | 955 |
830 return 1; | 956 return 1; |
831 } | 957 } |
832 | 958 |
833 static unsigned int | 959 static unsigned int |
884 PurpleConnection *gc; | 1010 PurpleConnection *gc; |
885 MsnSession *session; | 1011 MsnSession *session; |
886 | 1012 |
887 gc = purple_account_get_connection(account); | 1013 gc = purple_account_get_connection(account); |
888 | 1014 |
889 if (gc != NULL) | 1015 if (gc != NULL){ |
890 { | |
891 session = gc->proto_data; | 1016 session = gc->proto_data; |
892 msn_change_status(session); | 1017 msn_change_status(session); |
893 } | 1018 } |
894 } | 1019 } |
895 | 1020 |
962 | 1087 |
963 session = gc->proto_data; | 1088 session = gc->proto_data; |
964 userlist = session->userlist; | 1089 userlist = session->userlist; |
965 who = msn_normalize(gc->account, buddy->name); | 1090 who = msn_normalize(gc->account, buddy->name); |
966 | 1091 |
1092 purple_debug_info("MaYuan","add user:{%s} to group:{%s}\n",who,group->name); | |
967 if (!session->logged_in) | 1093 if (!session->logged_in) |
968 { | 1094 { |
969 #if 0 | 1095 #if 0 |
970 fake_userlist_add_buddy(session->sync_userlist, who, MSN_LIST_FL, | 1096 fake_userlist_add_buddy(session->sync_userlist, who, MSN_LIST_FL, |
971 group ? group->name : NULL); | 1097 group ? group->name : NULL); |
1109 account = purple_connection_get_account(gc); | 1235 account = purple_connection_get_account(gc); |
1110 session = gc->proto_data; | 1236 session = gc->proto_data; |
1111 cmdproc = session->notification->cmdproc; | 1237 cmdproc = session->notification->cmdproc; |
1112 | 1238 |
1113 if (account->perm_deny == PURPLE_PRIVACY_ALLOW_ALL || | 1239 if (account->perm_deny == PURPLE_PRIVACY_ALLOW_ALL || |
1114 account->perm_deny == PURPLE_PRIVACY_DENY_USERS) | 1240 account->perm_deny == PURPLE_PRIVACY_DENY_USERS){ |
1115 { | |
1116 msn_cmdproc_send(cmdproc, "BLP", "%s", "AL"); | 1241 msn_cmdproc_send(cmdproc, "BLP", "%s", "AL"); |
1117 } | 1242 }else{ |
1118 else | |
1119 { | |
1120 msn_cmdproc_send(cmdproc, "BLP", "%s", "BL"); | 1243 msn_cmdproc_send(cmdproc, "BLP", "%s", "BL"); |
1121 } | 1244 } |
1122 } | 1245 } |
1123 | 1246 |
1124 static void | 1247 static void |
1254 msn_rename_group(PurpleConnection *gc, const char *old_name, | 1377 msn_rename_group(PurpleConnection *gc, const char *old_name, |
1255 PurpleGroup *group, GList *moved_buddies) | 1378 PurpleGroup *group, GList *moved_buddies) |
1256 { | 1379 { |
1257 MsnSession *session; | 1380 MsnSession *session; |
1258 MsnCmdProc *cmdproc; | 1381 MsnCmdProc *cmdproc; |
1259 int old_gid; | 1382 const char *old_gid; |
1260 const char *enc_new_group_name; | 1383 const char *enc_new_group_name; |
1261 | 1384 |
1262 session = gc->proto_data; | 1385 session = gc->proto_data; |
1263 cmdproc = session->notification->cmdproc; | 1386 cmdproc = session->notification->cmdproc; |
1264 enc_new_group_name = purple_url_encode(group->name); | 1387 enc_new_group_name = purple_url_encode(group->name); |
1265 | 1388 |
1389 purple_debug_info("MaYuan","rename group:old{%s},new{%s}",old_name,enc_new_group_name); | |
1266 old_gid = msn_userlist_find_group_id(session->userlist, old_name); | 1390 old_gid = msn_userlist_find_group_id(session->userlist, old_name); |
1267 | 1391 |
1268 if (old_gid >= 0) | 1392 if (old_gid != NULL){ |
1269 { | 1393 /*find a Group*/ |
1270 msn_cmdproc_send(cmdproc, "REG", "%d %s 0", old_gid, | 1394 msn_cmdproc_send(cmdproc, "REG", "%d %s 0", old_gid, |
1271 enc_new_group_name); | 1395 enc_new_group_name); |
1272 } | 1396 }else{ |
1273 else | 1397 /*not found*/ |
1274 { | |
1275 msn_cmdproc_send(cmdproc, "ADG", "%s 0", enc_new_group_name); | 1398 msn_cmdproc_send(cmdproc, "ADG", "%s 0", enc_new_group_name); |
1276 } | 1399 } |
1277 } | 1400 } |
1278 | 1401 |
1279 static void | 1402 static void |
1325 static void | 1448 static void |
1326 msn_remove_group(PurpleConnection *gc, PurpleGroup *group) | 1449 msn_remove_group(PurpleConnection *gc, PurpleGroup *group) |
1327 { | 1450 { |
1328 MsnSession *session; | 1451 MsnSession *session; |
1329 MsnCmdProc *cmdproc; | 1452 MsnCmdProc *cmdproc; |
1330 int group_id; | 1453 const char *group_id; |
1331 | 1454 |
1332 session = gc->proto_data; | 1455 session = gc->proto_data; |
1333 cmdproc = session->notification->cmdproc; | 1456 cmdproc = session->notification->cmdproc; |
1334 | 1457 |
1335 if ((group_id = msn_userlist_find_group_id(session->userlist, group->name)) >= 0) | 1458 /*we can't delete the default group*/ |
1336 { | 1459 if(!strcmp(group->name,MSN_INDIVIDUALS_GROUP_NAME)|| |
1337 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); | |
1338 } | 1466 } |
1339 } | 1467 } |
1340 | 1468 |
1341 /** | 1469 /** |
1342 * 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 |
1347 PurpleBuddy *b; | 1475 PurpleBuddy *b; |
1348 | 1476 |
1349 b = purple_find_buddy(purple_connection_get_account(info_data->gc), | 1477 b = purple_find_buddy(purple_connection_get_account(info_data->gc), |
1350 info_data->name); | 1478 info_data->name); |
1351 | 1479 |
1352 if (b) | 1480 if (b){ |
1353 { | |
1354 char *tmp; | 1481 char *tmp; |
1355 | 1482 |
1356 if (b->alias && b->alias[0]) | 1483 if (b->alias && b->alias[0]){ |
1357 { | |
1358 char *aliastext = g_markup_escape_text(b->alias, -1); | 1484 char *aliastext = g_markup_escape_text(b->alias, -1); |
1359 purple_notify_user_info_add_pair(user_info, _("Alias"), aliastext); | 1485 purple_notify_user_info_add_pair(user_info, _("Alias"), aliastext); |
1360 g_free(aliastext); | 1486 g_free(aliastext); |
1361 } | 1487 } |
1362 | 1488 |
1363 if (b->server_alias) | 1489 if (b->server_alias){ |
1364 { | |
1365 char *nicktext = g_markup_escape_text(b->server_alias, -1); | 1490 char *nicktext = g_markup_escape_text(b->server_alias, -1); |
1366 tmp = g_strdup_printf("<font sml=\"msn\">%s</font><br>", nicktext); | 1491 tmp = g_strdup_printf("<font sml=\"msn\">%s</font><br>", nicktext); |
1367 purple_notify_user_info_add_pair(user_info, _("Nickname"), tmp); | 1492 purple_notify_user_info_add_pair(user_info, _("Nickname"), tmp); |
1368 g_free(tmp); | 1493 g_free(tmp); |
1369 g_free(nicktext); | 1494 g_free(nicktext); |
1383 static char * | 1508 static char * |
1384 msn_get_photo_url(const char *url_text) | 1509 msn_get_photo_url(const char *url_text) |
1385 { | 1510 { |
1386 char *p, *q; | 1511 char *p, *q; |
1387 | 1512 |
1388 if ((p = strstr(url_text, " contactparams:photopreauthurl=\"")) != NULL) | 1513 if ((p = strstr(url_text, PHOTO_URL)) != NULL){ |
1389 { | 1514 p += strlen(PHOTO_URL); |
1390 p += strlen(" contactparams:photopreauthurl=\""); | 1515 } |
1391 } | 1516 if (p && (strncmp(p, "http://",strlen("http://")) == 0) && ((q = strchr(p, '"')) != NULL)) |
1392 | |
1393 if (p && (strncmp(p, "http://", 8) == 0) && ((q = strchr(p, '"')) != NULL)) | |
1394 return g_strndup(p, q - p); | 1517 return g_strndup(p, q - p); |
1395 | 1518 |
1396 return NULL; | 1519 return NULL; |
1397 } | 1520 } |
1398 | 1521 |
1437 #if PHOTO_SUPPORT | 1560 #if PHOTO_SUPPORT |
1438 char *photo_url_text = NULL; | 1561 char *photo_url_text = NULL; |
1439 MsnGetInfoStepTwoData *info2_data = NULL; | 1562 MsnGetInfoStepTwoData *info2_data = NULL; |
1440 #endif | 1563 #endif |
1441 | 1564 |
1442 purple_debug_info("msn", "In msn_got_info\n"); | 1565 purple_debug_info("msn", "In msn_got_info,url_text:{%s}\n",url_text); |
1443 | 1566 |
1444 /* Make sure the connection is still valid */ | 1567 /* Make sure the connection is still valid */ |
1445 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) |
1446 { | 1569 { |
1447 purple_debug_warning("msn", "invalid connection. ignoring buddy info.\n"); | 1570 purple_debug_warning("msn", "invalid connection. ignoring buddy info.\n"); |
1818 g_free(tmp); | 1941 g_free(tmp); |
1819 | 1942 |
1820 #if PHOTO_SUPPORT | 1943 #if PHOTO_SUPPORT |
1821 /* 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] */ |
1822 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); | |
1823 | 1947 |
1824 /* Marshall the existing state */ | 1948 /* Marshall the existing state */ |
1825 info2_data = g_malloc0(sizeof(MsnGetInfoStepTwoData)); | 1949 info2_data = g_malloc0(sizeof(MsnGetInfoStepTwoData)); |
1826 info2_data->info_data = info_data; | 1950 info2_data->info_data = info_data; |
1827 info2_data->stripped = stripped; | 1951 info2_data->stripped = stripped; |
2042 NULL, /* remove_buddies */ | 2166 NULL, /* remove_buddies */ |
2043 msn_add_permit, /* add_permit */ | 2167 msn_add_permit, /* add_permit */ |
2044 msn_add_deny, /* add_deny */ | 2168 msn_add_deny, /* add_deny */ |
2045 msn_rem_permit, /* rem_permit */ | 2169 msn_rem_permit, /* rem_permit */ |
2046 msn_rem_deny, /* rem_deny */ | 2170 msn_rem_deny, /* rem_deny */ |
2047 msn_set_permit_deny, /* set_permit_deny */ | 2171 msn_set_permit_deny, /* set_permit_deny */ |
2048 NULL, /* join_chat */ | 2172 NULL, /* join_chat */ |
2049 NULL, /* reject chat invite */ | 2173 NULL, /* reject chat invite */ |
2050 NULL, /* get_chat_name */ | 2174 NULL, /* get_chat_name */ |
2051 msn_chat_invite, /* chat_invite */ | 2175 msn_chat_invite, /* chat_invite */ |
2052 msn_chat_leave, /* chat_leave */ | 2176 msn_chat_leave, /* chat_leave */ |
2098 | 2222 |
2099 "prpl-msn", /**< id */ | 2223 "prpl-msn", /**< id */ |
2100 "MSN", /**< name */ | 2224 "MSN", /**< name */ |
2101 VERSION, /**< version */ | 2225 VERSION, /**< version */ |
2102 /** summary */ | 2226 /** summary */ |
2103 N_("MSN Protocol Plugin"), | 2227 N_("Windows Live Messenger Protocol Plugin"), |
2104 /** description */ | 2228 /** description */ |
2105 N_("MSN Protocol Plugin"), | 2229 N_("Windows Live Messenger Protocol Plugin"), |
2106 "Christian Hammond <chipx86@gnupdate.org>", /**< author */ | 2230 "MaYuan <mayuan2006@gmail.com>", /**< author */ |
2107 PURPLE_WEBSITE, /**< homepage */ | 2231 PURPLE_WEBSITE, /**< homepage */ |
2108 | 2232 |
2109 msn_load, /**< load */ | 2233 msn_load, /**< load */ |
2110 msn_unload, /**< unload */ | 2234 msn_unload, /**< unload */ |
2111 NULL, /**< destroy */ | 2235 NULL, /**< destroy */ |
2126 init_plugin(PurplePlugin *plugin) | 2250 init_plugin(PurplePlugin *plugin) |
2127 { | 2251 { |
2128 PurpleAccountOption *option; | 2252 PurpleAccountOption *option; |
2129 | 2253 |
2130 option = purple_account_option_string_new(_("Server"), "server", | 2254 option = purple_account_option_string_new(_("Server"), "server", |
2131 MSN_SERVER); | 2255 WLM_SERVER); |
2132 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | 2256 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
2133 option); | 2257 option); |
2134 | 2258 |
2135 option = purple_account_option_int_new(_("Port"), "port", 1863); | 2259 option = purple_account_option_int_new(_("Port"), "port", WLM_PORT); |
2136 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | 2260 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
2137 option); | 2261 option); |
2138 | 2262 |
2139 option = purple_account_option_bool_new(_("Use HTTP Method"), | 2263 option = purple_account_option_bool_new(_("Use HTTP Method"), |
2140 "http_method", FALSE); | 2264 "http_method", FALSE); |