Mercurial > pidgin.yaz
comparison libpurple/protocols/msn/msn.c @ 20412:522f618a44b4
propagate from branch 'im.pidgin.pidgin' (head 3f8c9725bb938821f3ef6cb2e7c6c31d7b662d0b)
to branch 'im.pidgin.cpw.khc.msnp14' (head 7e655675a82d008f4ea9743aeb2ed141837bc1ec)
author | Ka-Hing Cheung <khc@hxbc.us> |
---|---|
date | Sat, 12 May 2007 19:19:55 +0000 |
parents | cb4380df3005 ed303260e05a |
children | fd7b501cc9c8 |
comparison
equal
deleted
inserted
replaced
17072:cb4380df3005 | 20412:522f618a44b4 |
---|---|
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); |
697 _("SSL support is needed for MSN. Please install a supported " | 792 _("SSL support is needed for MSN. Please install a supported " |
698 "SSL library.")); | 793 "SSL library.")); |
699 return; | 794 return; |
700 } | 795 } |
701 | 796 |
702 http_method = purple_account_get_bool(account, "http_method", FALSE); | 797 if (purple_account_get_bool(account, "http_method", FALSE)) |
798 http_method = TRUE; | |
703 | 799 |
704 host = purple_account_get_string(account, "server", MSN_SERVER); | 800 host = purple_account_get_string(account, "server", MSN_SERVER); |
705 port = purple_account_get_int(account, "port", MSN_PORT); | 801 port = purple_account_get_int(account, "port", MSN_PORT); |
706 | 802 |
707 session = msn_session_new(account); | 803 session = msn_session_new(account); |
754 PurpleBuddy *buddy = purple_find_buddy(gc->account, who); | 850 PurpleBuddy *buddy = purple_find_buddy(gc->account, who); |
755 MsnMessage *msg; | 851 MsnMessage *msg; |
756 char *msgformat; | 852 char *msgformat; |
757 char *msgtext; | 853 char *msgtext; |
758 | 854 |
855 purple_debug_info("MaYuan","send IM {%s} to %s\n",message,who); | |
759 account = purple_connection_get_account(gc); | 856 account = purple_connection_get_account(gc); |
760 | 857 |
761 if (buddy) { | 858 if (buddy) { |
762 PurplePresence *p = purple_buddy_get_presence(buddy); | 859 PurplePresence *p = purple_buddy_get_presence(buddy); |
763 if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_MOBILE)) { | 860 if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_MOBILE)) { |
767 return 1; | 864 return 1; |
768 } | 865 } |
769 } | 866 } |
770 | 867 |
771 msn_import_html(message, &msgformat, &msgtext); | 868 msn_import_html(message, &msgformat, &msgtext); |
772 | 869 if(msn_user_is_online(account, who)|| |
773 if (strlen(msgtext) + strlen(msgformat) + strlen(VERSION) > 1564) | 870 msn_user_is_yahoo(account, who)){ |
774 { | 871 /*User online,then send Online Instant Message*/ |
872 | |
873 if (strlen(msgtext) + strlen(msgformat) + strlen(VERSION) > 1564) | |
874 { | |
875 g_free(msgformat); | |
876 g_free(msgtext); | |
877 | |
878 return -E2BIG; | |
879 } | |
880 | |
881 msg = msn_message_new_plain(msgtext); | |
882 msg->remote_user = g_strdup(who); | |
883 msn_message_set_attr(msg, "X-MMS-IM-Format", msgformat); | |
884 | |
775 g_free(msgformat); | 885 g_free(msgformat); |
776 g_free(msgtext); | 886 g_free(msgtext); |
777 | 887 |
778 return -E2BIG; | 888 purple_debug_info("MaYuan","prepare to send online Message\n"); |
779 } | 889 if (g_ascii_strcasecmp(who, purple_account_get_username(account))) |
780 | 890 { |
781 msg = msn_message_new_plain(msgtext); | 891 MsnSession *session; |
782 msn_message_set_attr(msg, "X-MMS-IM-Format", msgformat); | 892 MsnSwitchBoard *swboard; |
783 | 893 |
784 g_free(msgformat); | 894 session = gc->proto_data; |
785 g_free(msgtext); | 895 if(msn_user_is_yahoo(account,who)){ |
786 | 896 /*we send the online and offline Message to Yahoo User via UBM*/ |
787 if (g_ascii_strcasecmp(who, purple_account_get_username(account))) | 897 purple_debug_info("MaYuan","send to Yahoo User\n"); |
788 { | 898 uum_send_msg(session,msg); |
899 }else{ | |
900 purple_debug_info("MaYuan","send via switchboard\n"); | |
901 swboard = msn_session_get_swboard(session, who, MSN_SB_FLAG_IM); | |
902 msn_switchboard_send_msg(swboard, msg, TRUE); | |
903 } | |
904 } | |
905 else | |
906 { | |
907 char *body_str, *body_enc, *pre, *post; | |
908 const char *format; | |
909 /* | |
910 * In MSN, you can't send messages to yourself, so | |
911 * we'll fake like we received it ;) | |
912 */ | |
913 body_str = msn_message_to_string(msg); | |
914 body_enc = g_markup_escape_text(body_str, -1); | |
915 g_free(body_str); | |
916 | |
917 format = msn_message_get_attr(msg, "X-MMS-IM-Format"); | |
918 msn_parse_format(format, &pre, &post); | |
919 body_str = g_strdup_printf("%s%s%s", pre ? pre : "", | |
920 body_enc ? body_enc : "", post ? post : ""); | |
921 g_free(body_enc); | |
922 g_free(pre); | |
923 g_free(post); | |
924 | |
925 serv_got_typing_stopped(gc, who); | |
926 serv_got_im(gc, who, body_str, flags, time(NULL)); | |
927 g_free(body_str); | |
928 } | |
929 | |
930 msn_message_destroy(msg); | |
931 }else { | |
932 /*send Offline Instant Message,only to MSN Passport User*/ | |
789 MsnSession *session; | 933 MsnSession *session; |
790 MsnSwitchBoard *swboard; | 934 MsnOim *oim; |
791 | 935 char *friendname; |
936 | |
937 purple_debug_info("MaYuan","prepare to send offline Message\n"); | |
792 session = gc->proto_data; | 938 session = gc->proto_data; |
793 swboard = msn_session_get_swboard(session, who, MSN_SB_FLAG_IM); | 939 /* XXX/khc: hack */ |
794 | 940 if (!session->oim) |
795 msn_switchboard_send_msg(swboard, msg, TRUE); | 941 session->oim = msn_oim_new(session); |
942 | |
943 oim = session->oim; | |
944 friendname = msn_encode_mime(account->username); | |
945 msn_oim_prep_send_msg_info(oim, purple_account_get_username(account), | |
946 friendname, who, message); | |
947 msn_oim_send_msg(oim); | |
796 } | 948 } |
797 else | 949 else |
798 { | 950 { |
799 char *body_str, *body_enc, *pre, *post; | 951 char *body_str, *body_enc, *pre, *post; |
800 const char *format; | 952 const char *format; |
883 PurpleConnection *gc; | 1035 PurpleConnection *gc; |
884 MsnSession *session; | 1036 MsnSession *session; |
885 | 1037 |
886 gc = purple_account_get_connection(account); | 1038 gc = purple_account_get_connection(account); |
887 | 1039 |
888 if (gc != NULL) | 1040 if (gc != NULL){ |
889 { | |
890 session = gc->proto_data; | 1041 session = gc->proto_data; |
891 msn_change_status(session); | 1042 msn_change_status(session); |
892 } | 1043 } |
893 } | 1044 } |
894 | 1045 |
961 | 1112 |
962 session = gc->proto_data; | 1113 session = gc->proto_data; |
963 userlist = session->userlist; | 1114 userlist = session->userlist; |
964 who = msn_normalize(gc->account, buddy->name); | 1115 who = msn_normalize(gc->account, buddy->name); |
965 | 1116 |
1117 purple_debug_info("MaYuan","add user:{%s} to group:{%s}\n",who,group->name); | |
966 if (!session->logged_in) | 1118 if (!session->logged_in) |
967 { | 1119 { |
968 #if 0 | 1120 #if 0 |
969 fake_userlist_add_buddy(session->sync_userlist, who, MSN_LIST_FL, | 1121 fake_userlist_add_buddy(session->sync_userlist, who, MSN_LIST_FL, |
970 group ? group->name : NULL); | 1122 group ? group->name : NULL); |
1108 account = purple_connection_get_account(gc); | 1260 account = purple_connection_get_account(gc); |
1109 session = gc->proto_data; | 1261 session = gc->proto_data; |
1110 cmdproc = session->notification->cmdproc; | 1262 cmdproc = session->notification->cmdproc; |
1111 | 1263 |
1112 if (account->perm_deny == PURPLE_PRIVACY_ALLOW_ALL || | 1264 if (account->perm_deny == PURPLE_PRIVACY_ALLOW_ALL || |
1113 account->perm_deny == PURPLE_PRIVACY_DENY_USERS) | 1265 account->perm_deny == PURPLE_PRIVACY_DENY_USERS){ |
1114 { | |
1115 msn_cmdproc_send(cmdproc, "BLP", "%s", "AL"); | 1266 msn_cmdproc_send(cmdproc, "BLP", "%s", "AL"); |
1116 } | 1267 }else{ |
1117 else | |
1118 { | |
1119 msn_cmdproc_send(cmdproc, "BLP", "%s", "BL"); | 1268 msn_cmdproc_send(cmdproc, "BLP", "%s", "BL"); |
1120 } | 1269 } |
1121 } | 1270 } |
1122 | 1271 |
1123 static void | 1272 static void |
1253 msn_rename_group(PurpleConnection *gc, const char *old_name, | 1402 msn_rename_group(PurpleConnection *gc, const char *old_name, |
1254 PurpleGroup *group, GList *moved_buddies) | 1403 PurpleGroup *group, GList *moved_buddies) |
1255 { | 1404 { |
1256 MsnSession *session; | 1405 MsnSession *session; |
1257 MsnCmdProc *cmdproc; | 1406 MsnCmdProc *cmdproc; |
1258 int old_gid; | 1407 const char *old_gid; |
1259 const char *enc_new_group_name; | 1408 const char *enc_new_group_name; |
1260 | 1409 |
1261 session = gc->proto_data; | 1410 session = gc->proto_data; |
1262 cmdproc = session->notification->cmdproc; | 1411 cmdproc = session->notification->cmdproc; |
1263 enc_new_group_name = purple_url_encode(group->name); | 1412 enc_new_group_name = purple_url_encode(group->name); |
1264 | 1413 |
1414 purple_debug_info("MaYuan","rename group:old{%s},new{%s}",old_name,enc_new_group_name); | |
1265 old_gid = msn_userlist_find_group_id(session->userlist, old_name); | 1415 old_gid = msn_userlist_find_group_id(session->userlist, old_name); |
1266 | 1416 |
1267 if (old_gid >= 0) | 1417 if (old_gid != NULL){ |
1268 { | 1418 /*find a Group*/ |
1269 msn_cmdproc_send(cmdproc, "REG", "%d %s 0", old_gid, | 1419 msn_cmdproc_send(cmdproc, "REG", "%d %s 0", old_gid, |
1270 enc_new_group_name); | 1420 enc_new_group_name); |
1271 } | 1421 }else{ |
1272 else | 1422 /*not found*/ |
1273 { | |
1274 msn_cmdproc_send(cmdproc, "ADG", "%s 0", enc_new_group_name); | 1423 msn_cmdproc_send(cmdproc, "ADG", "%s 0", enc_new_group_name); |
1275 } | 1424 } |
1276 } | 1425 } |
1277 | 1426 |
1278 static void | 1427 static void |
1324 static void | 1473 static void |
1325 msn_remove_group(PurpleConnection *gc, PurpleGroup *group) | 1474 msn_remove_group(PurpleConnection *gc, PurpleGroup *group) |
1326 { | 1475 { |
1327 MsnSession *session; | 1476 MsnSession *session; |
1328 MsnCmdProc *cmdproc; | 1477 MsnCmdProc *cmdproc; |
1329 int group_id; | 1478 const char *group_id; |
1330 | 1479 |
1331 session = gc->proto_data; | 1480 session = gc->proto_data; |
1332 cmdproc = session->notification->cmdproc; | 1481 cmdproc = session->notification->cmdproc; |
1333 | 1482 |
1334 if ((group_id = msn_userlist_find_group_id(session->userlist, group->name)) >= 0) | 1483 /*we can't delete the default group*/ |
1335 { | 1484 if(!strcmp(group->name,MSN_INDIVIDUALS_GROUP_NAME)|| |
1336 msn_cmdproc_send(cmdproc, "RMG", "%d", group_id); | 1485 !strcmp(group->name,MSN_NON_IM_GROUP_NAME)){ |
1486 return ; | |
1487 } | |
1488 group_id = msn_userlist_find_group_id(session->userlist, group->name); | |
1489 if (group_id != NULL){ | |
1490 msn_del_group(session,group_id); | |
1337 } | 1491 } |
1338 } | 1492 } |
1339 | 1493 |
1340 /** | 1494 /** |
1341 * Extract info text from info_data and add it to user_info | 1495 * Extract info text from info_data and add it to user_info |
1346 PurpleBuddy *b; | 1500 PurpleBuddy *b; |
1347 | 1501 |
1348 b = purple_find_buddy(purple_connection_get_account(info_data->gc), | 1502 b = purple_find_buddy(purple_connection_get_account(info_data->gc), |
1349 info_data->name); | 1503 info_data->name); |
1350 | 1504 |
1351 if (b) | 1505 if (b){ |
1352 { | |
1353 char *tmp; | 1506 char *tmp; |
1354 | 1507 |
1355 if (b->alias && b->alias[0]) | 1508 if (b->alias && b->alias[0]){ |
1356 { | |
1357 char *aliastext = g_markup_escape_text(b->alias, -1); | 1509 char *aliastext = g_markup_escape_text(b->alias, -1); |
1358 purple_notify_user_info_add_pair(user_info, _("Alias"), aliastext); | 1510 purple_notify_user_info_add_pair(user_info, _("Alias"), aliastext); |
1359 g_free(aliastext); | 1511 g_free(aliastext); |
1360 } | 1512 } |
1361 | 1513 |
1362 if (b->server_alias) | 1514 if (b->server_alias){ |
1363 { | |
1364 char *nicktext = g_markup_escape_text(b->server_alias, -1); | 1515 char *nicktext = g_markup_escape_text(b->server_alias, -1); |
1365 tmp = g_strdup_printf("<font sml=\"msn\">%s</font><br>", nicktext); | 1516 tmp = g_strdup_printf("<font sml=\"msn\">%s</font><br>", nicktext); |
1366 purple_notify_user_info_add_pair(user_info, _("Nickname"), tmp); | 1517 purple_notify_user_info_add_pair(user_info, _("Nickname"), tmp); |
1367 g_free(tmp); | 1518 g_free(tmp); |
1368 g_free(nicktext); | 1519 g_free(nicktext); |
1382 static char * | 1533 static char * |
1383 msn_get_photo_url(const char *url_text) | 1534 msn_get_photo_url(const char *url_text) |
1384 { | 1535 { |
1385 char *p, *q; | 1536 char *p, *q; |
1386 | 1537 |
1387 if ((p = strstr(url_text, " contactparams:photopreauthurl=\"")) != NULL) | 1538 if ((p = strstr(url_text, PHOTO_URL)) != NULL){ |
1388 { | 1539 p += strlen(PHOTO_URL); |
1389 p += strlen(" contactparams:photopreauthurl=\""); | 1540 } |
1390 } | 1541 if (p && (strncmp(p, "http://",strlen("http://")) == 0) && ((q = strchr(p, '"')) != NULL)) |
1391 | |
1392 if (p && (strncmp(p, "http://", 8) == 0) && ((q = strchr(p, '"')) != NULL)) | |
1393 return g_strndup(p, q - p); | 1542 return g_strndup(p, q - p); |
1394 | 1543 |
1395 return NULL; | 1544 return NULL; |
1396 } | 1545 } |
1397 | 1546 |
1436 #if PHOTO_SUPPORT | 1585 #if PHOTO_SUPPORT |
1437 char *photo_url_text = NULL; | 1586 char *photo_url_text = NULL; |
1438 MsnGetInfoStepTwoData *info2_data = NULL; | 1587 MsnGetInfoStepTwoData *info2_data = NULL; |
1439 #endif | 1588 #endif |
1440 | 1589 |
1441 purple_debug_info("msn", "In msn_got_info\n"); | 1590 purple_debug_info("msn", "In msn_got_info,url_text:{%s}\n",url_text); |
1442 | 1591 |
1443 /* Make sure the connection is still valid */ | 1592 /* Make sure the connection is still valid */ |
1444 if (g_list_find(purple_connections_get_all(), info_data->gc) == NULL) | 1593 if (g_list_find(purple_connections_get_all(), info_data->gc) == NULL) |
1445 { | 1594 { |
1446 purple_debug_warning("msn", "invalid connection. ignoring buddy info.\n"); | 1595 purple_debug_warning("msn", "invalid connection. ignoring buddy info.\n"); |
1817 g_free(tmp); | 1966 g_free(tmp); |
1818 | 1967 |
1819 #if PHOTO_SUPPORT | 1968 #if PHOTO_SUPPORT |
1820 /* Find the URL to the photo; must be before the marshalling [Bug 994207] */ | 1969 /* Find the URL to the photo; must be before the marshalling [Bug 994207] */ |
1821 photo_url_text = msn_get_photo_url(url_text); | 1970 photo_url_text = msn_get_photo_url(url_text); |
1971 purple_debug_info("Ma Yuan","photo url:{%s}\n",photo_url_text); | |
1822 | 1972 |
1823 /* Marshall the existing state */ | 1973 /* Marshall the existing state */ |
1824 info2_data = g_malloc0(sizeof(MsnGetInfoStepTwoData)); | 1974 info2_data = g_malloc0(sizeof(MsnGetInfoStepTwoData)); |
1825 info2_data->info_data = info_data; | 1975 info2_data->info_data = info_data; |
1826 info2_data->stripped = stripped; | 1976 info2_data->stripped = stripped; |
2041 NULL, /* remove_buddies */ | 2191 NULL, /* remove_buddies */ |
2042 msn_add_permit, /* add_permit */ | 2192 msn_add_permit, /* add_permit */ |
2043 msn_add_deny, /* add_deny */ | 2193 msn_add_deny, /* add_deny */ |
2044 msn_rem_permit, /* rem_permit */ | 2194 msn_rem_permit, /* rem_permit */ |
2045 msn_rem_deny, /* rem_deny */ | 2195 msn_rem_deny, /* rem_deny */ |
2046 msn_set_permit_deny, /* set_permit_deny */ | 2196 msn_set_permit_deny, /* set_permit_deny */ |
2047 NULL, /* join_chat */ | 2197 NULL, /* join_chat */ |
2048 NULL, /* reject chat invite */ | 2198 NULL, /* reject chat invite */ |
2049 NULL, /* get_chat_name */ | 2199 NULL, /* get_chat_name */ |
2050 msn_chat_invite, /* chat_invite */ | 2200 msn_chat_invite, /* chat_invite */ |
2051 msn_chat_leave, /* chat_leave */ | 2201 msn_chat_leave, /* chat_leave */ |
2097 | 2247 |
2098 "prpl-msn", /**< id */ | 2248 "prpl-msn", /**< id */ |
2099 "MSN", /**< name */ | 2249 "MSN", /**< name */ |
2100 VERSION, /**< version */ | 2250 VERSION, /**< version */ |
2101 /** summary */ | 2251 /** summary */ |
2102 N_("MSN Protocol Plugin"), | 2252 N_("Windows Live Messenger Protocol Plugin"), |
2103 /** description */ | 2253 /** description */ |
2104 N_("MSN Protocol Plugin"), | 2254 N_("Windows Live Messenger Protocol Plugin"), |
2105 "Christian Hammond <chipx86@gnupdate.org>", /**< author */ | 2255 "MaYuan <mayuan2006@gmail.com>", /**< author */ |
2106 PURPLE_WEBSITE, /**< homepage */ | 2256 PURPLE_WEBSITE, /**< homepage */ |
2107 | 2257 |
2108 msn_load, /**< load */ | 2258 msn_load, /**< load */ |
2109 msn_unload, /**< unload */ | 2259 msn_unload, /**< unload */ |
2110 NULL, /**< destroy */ | 2260 NULL, /**< destroy */ |
2125 init_plugin(PurplePlugin *plugin) | 2275 init_plugin(PurplePlugin *plugin) |
2126 { | 2276 { |
2127 PurpleAccountOption *option; | 2277 PurpleAccountOption *option; |
2128 | 2278 |
2129 option = purple_account_option_string_new(_("Server"), "server", | 2279 option = purple_account_option_string_new(_("Server"), "server", |
2130 MSN_SERVER); | 2280 WLM_SERVER); |
2131 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | 2281 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
2132 option); | 2282 option); |
2133 | 2283 |
2134 option = purple_account_option_int_new(_("Port"), "port", 1863); | 2284 option = purple_account_option_int_new(_("Port"), "port", WLM_PORT); |
2135 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | 2285 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
2136 option); | 2286 option); |
2137 | 2287 |
2138 option = purple_account_option_bool_new(_("Use HTTP Method"), | 2288 option = purple_account_option_bool_new(_("Use HTTP Method"), |
2139 "http_method", FALSE); | 2289 "http_method", FALSE); |