~ubuntu-branches/ubuntu/hardy/pidgin/hardy

« back to all changes in this revision

Viewing changes to libpurple/protocols/msn/msn.c

  • Committer: Bazaar Package Importer
  • Author(s): Pedro Fragoso
  • Date: 2007-12-21 02:48:06 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20071221024806-pd44a5k9tiyh12mp
Tags: 1:2.3.1-2ubuntu1
* Sync with Debian, remaining Ubuntu changes; (LP: #177811)
  - Set Maintainer to Ubuntu Core Developers.
  - Add build-deps on liblaunchpad-integration-dev, intltool,
    libnm-glib-dev (for --enable-nm) (Ubuntu #112720).
  - Drop build-deps on libsilc-1.1-2-dev | libsilc-dev (>= 1.1.1) as 
    this library is in universe.
  - Drop the libpurple0 recommends on libpurple-bin.
  - Add a gaim transitionnal package for upgrades.
  - Ship compatibility symlinks via debian/gaim.links.
  - Pass --enable-nm to configure to enable NetworkManager support.
  - Pass --disable-silc to configure to disable silc support even if 
    it's installed in the build environment.
  - Add X-Ubuntu-Gettext-Domain to the desktop file and update the
    translation templates in common-install-impl::.
   - Update debian/prefs.xml to set the notify plugin prefs
    /plugins/gtk/X11/notify/* and set /pidgin/plugins/loaded to load 
    the notify plugin; Ubuntu: #13389.
  - Add LPI integration patch, 02_lpi.
  - Add patch 04_let_crasher_for_apport to stop catching the SIGSEGV signal
    and let apport handle it.
  - Add patch 05_default_to_irc_ubuntu_com to set the default IRC 
    server to irc.ubuntu.com.
  - Add autoconf patch, 70_autoconf.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include "cmds.h"
38
38
#include "core.h"
39
39
#include "prpl.h"
40
 
#include "msn-utils.h"
 
40
#include "msnutils.h"
41
41
#include "version.h"
42
42
 
43
43
#include "switchboard.h"
151
151
        return PURPLE_CMD_RET_OK;
152
152
}
153
153
 
154
 
static void
 
154
void
155
155
msn_act_id(PurpleConnection *gc, const char *entry)
156
156
{
157
157
        MsnCmdProc *cmdproc;
175
175
                return;
176
176
        }
177
177
 
178
 
        msn_cmdproc_send(cmdproc, "REA", "%s %s",
179
 
                                         purple_account_get_username(account),
180
 
                                         alias);
 
178
        if (*alias == '\0') {
 
179
                alias = purple_url_encode(purple_account_get_username(account));
 
180
        }
 
181
 
 
182
        msn_cmdproc_send(cmdproc, "PRP", "MFN %s", alias);
 
183
 
181
184
}
182
185
 
183
186
static void
251
254
        trans = msn_transaction_new(cmdproc, "PGD", "%s 1 %d", who, payload_len);
252
255
 
253
256
        msn_transaction_set_payload(trans, payload, payload_len);
 
257
        g_free(payload);
254
258
 
255
259
        msn_page_destroy(page);
256
260
 
414
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
443
static void
418
444
initiate_chat_cb(PurpleBlistNode *node, gpointer data)
419
445
{
460
486
        session = gc->proto_data;
461
487
 
462
488
        xfer = purple_xfer_new(gc->account, PURPLE_XFER_SEND, who);
 
489
 
463
490
        if (xfer)
464
491
        {
465
492
                slplink = msn_session_get_slplink(session, who);
511
538
        return "msn";
512
539
}
513
540
 
 
541
/*
 
542
 * Set the User status text
 
543
 */
514
544
static char *
515
545
msn_status_text(PurpleBuddy *buddy)
516
546
{
517
547
        PurplePresence *presence;
518
548
        PurpleStatus *status;
 
549
        const char *msg;
519
550
 
520
551
        presence = purple_buddy_get_presence(buddy);
521
552
        status = purple_presence_get_active_status(presence);
522
553
 
523
 
        if (!purple_presence_is_available(presence) && !purple_presence_is_idle(presence))
524
 
        {
525
 
                return g_strdup(purple_status_get_name(status));
 
554
        /* I think status message should take precedence over media */
 
555
        msg = purple_status_get_attr_string(status, "message");
 
556
        if (msg && *msg)
 
557
                return g_markup_escape_text(msg, -1);
 
558
 
 
559
        if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) {
 
560
                const char *title, *artist;
 
561
                char *media, *esc;
 
562
                status = purple_presence_get_status(presence, "tune");
 
563
                title = purple_status_get_attr_string(status, PURPLE_TUNE_TITLE);
 
564
                artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST);
 
565
 
 
566
                media = g_strdup_printf("%s%s%s", title, artist ? " - " : "",
 
567
                                artist ? artist : "");
 
568
                esc = g_markup_escape_text(media, -1);
 
569
                g_free(media);
 
570
                return esc;
526
571
        }
527
572
 
528
573
        return NULL;
537
582
 
538
583
        user = buddy->proto_data;
539
584
 
540
 
 
541
585
        if (purple_presence_is_online(presence))
542
586
        {
543
 
                purple_notify_user_info_add_pair(user_info, _("Status"),
544
 
                                                                           (purple_presence_is_idle(presence) ? _("Idle") : purple_status_get_name(status)));
545
 
        }
546
 
 
547
 
        if (full && user)
548
 
        {
549
 
                purple_notify_user_info_add_pair(user_info, _("Has you"),
550
 
                                                                           ((user->list_op & (1 << MSN_LIST_RL)) ? _("Yes") : _("No")));
 
587
                const char *psm, *name;
 
588
                char *currentmedia = NULL;
 
589
                char *tmp;
 
590
 
 
591
                psm = purple_status_get_attr_string(status, "message");
 
592
                if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) {
 
593
                        PurpleStatus *tune = purple_presence_get_status(presence, "tune");
 
594
                        const char *title = purple_status_get_attr_string(tune, PURPLE_TUNE_TITLE);
 
595
                        const char *artist = purple_status_get_attr_string(tune, PURPLE_TUNE_ARTIST);
 
596
                        currentmedia = g_strdup_printf("%s%s%s", title, artist ? " - " : "",
 
597
                                        artist ? artist : "");
 
598
                        /* We could probably just use user->media.title etc. here */
 
599
                }
 
600
 
 
601
                if (!purple_status_is_available(status)) {
 
602
                        name = purple_status_get_name(status);
 
603
                } else {
 
604
                        name = NULL;
 
605
                }
 
606
 
 
607
                if (name != NULL && *name) {
 
608
                        char *tmp2;
 
609
 
 
610
                        if (purple_presence_is_idle(presence)) {
 
611
                                tmp2 = g_markup_printf_escaped("%s/%s", name, _("Idle"));
 
612
                        } else {
 
613
                                tmp2 = g_markup_escape_text(name, -1);
 
614
                        }
 
615
 
 
616
                        if (psm != NULL && *psm) {
 
617
                                tmp = g_markup_escape_text(psm, -1);
 
618
                                purple_notify_user_info_add_pair(user_info, tmp2, tmp);
 
619
                                g_free(tmp);
 
620
                        } else {
 
621
                                purple_notify_user_info_add_pair(user_info, _("Status"), tmp2);
 
622
                        }
 
623
 
 
624
                        g_free(tmp2);
 
625
                } else {
 
626
                        if (psm != NULL && *psm) {
 
627
                                tmp = g_markup_escape_text(psm, -1);
 
628
                                if (purple_presence_is_idle(presence)) {
 
629
                                        purple_notify_user_info_add_pair(user_info, _("Idle"), tmp);
 
630
                                } else {
 
631
                                        purple_notify_user_info_add_pair(user_info, _("Status"), tmp);
 
632
                                }
 
633
                                g_free(tmp);
 
634
                        } else {
 
635
                                if (purple_presence_is_idle(presence)) {
 
636
                                        purple_notify_user_info_add_pair(user_info, _("Status"),
 
637
                                                _("Idle"));
 
638
                                } else {
 
639
                                        purple_notify_user_info_add_pair(user_info, _("Status"),
 
640
                                                purple_status_get_name(status));
 
641
                                }
 
642
                        }
 
643
                }
 
644
 
 
645
                if (currentmedia) {
 
646
                        tmp = g_markup_escape_text(currentmedia, -1);
 
647
                        purple_notify_user_info_add_pair(user_info, _("Current media"), tmp);
 
648
                        g_free(tmp);
 
649
                        g_free(currentmedia);
 
650
                }
551
651
        }
552
652
 
553
653
        /* XXX: This is being shown in non-full tooltips because the
554
654
         * XXX: blocked icon overlay isn't always accurate for MSN.
555
655
         * XXX: This can die as soon as purple_privacy_check() knows that
556
656
         * XXX: this prpl always honors both the allow and deny lists. */
557
 
        if (user)
 
657
        /* While the above comment may be strictly correct (the privacy API needs
 
658
         * rewriteing), purple_privacy_check() is going to be more accurate at
 
659
         * indicating whether a particular buddy is going to be able to message
 
660
         * you, which is the important information that this is trying to convey.
 
661
         */
 
662
        if (full && user)
558
663
        {
559
664
                purple_notify_user_info_add_pair(user_info, _("Blocked"),
560
665
                                                                           ((user->list_op & (1 << MSN_LIST_BL)) ? _("Yes") : _("No")));
567
672
        PurpleStatusType *status;
568
673
        GList *types = NULL;
569
674
 
570
 
        status = purple_status_type_new_full(PURPLE_STATUS_AVAILABLE,
571
 
                        NULL, NULL, FALSE, TRUE, FALSE);
572
 
        types = g_list_append(types, status);
573
 
 
574
 
        status = purple_status_type_new_full(PURPLE_STATUS_AWAY,
575
 
                        NULL, NULL, FALSE, TRUE, FALSE);
576
 
        types = g_list_append(types, status);
577
 
 
578
 
        status = purple_status_type_new_full(PURPLE_STATUS_AWAY,
579
 
                        "brb", _("Be Right Back"), FALSE, TRUE, FALSE);
580
 
        types = g_list_append(types, status);
581
 
 
582
 
        status = purple_status_type_new_full(PURPLE_STATUS_UNAVAILABLE,
583
 
                        "busy", _("Busy"), FALSE, TRUE, FALSE);
584
 
        types = g_list_append(types, status);
585
 
 
586
 
        status = purple_status_type_new_full(PURPLE_STATUS_UNAVAILABLE,
587
 
                        "phone", _("On the Phone"), FALSE, TRUE, FALSE);
588
 
        types = g_list_append(types, status);
589
 
 
590
 
        status = purple_status_type_new_full(PURPLE_STATUS_AWAY,
591
 
                        "lunch", _("Out to Lunch"), FALSE, TRUE, FALSE);
 
675
        status = purple_status_type_new_with_attrs(
 
676
                                PURPLE_STATUS_AVAILABLE, NULL, NULL, TRUE, TRUE, FALSE,
 
677
                                "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
 
678
                                NULL);
 
679
        types = g_list_append(types, status);
 
680
 
 
681
        status = purple_status_type_new_with_attrs(
 
682
                        PURPLE_STATUS_AWAY, NULL, NULL, TRUE, TRUE, FALSE,
 
683
                        "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
 
684
                        NULL);
 
685
        types = g_list_append(types, status);
 
686
 
 
687
        status = purple_status_type_new_with_attrs(
 
688
                        PURPLE_STATUS_AWAY, "brb", _("Be Right Back"), TRUE, TRUE, FALSE,
 
689
                        "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
 
690
                        NULL);
 
691
        types = g_list_append(types, status);
 
692
 
 
693
        status = purple_status_type_new_with_attrs(
 
694
                        PURPLE_STATUS_UNAVAILABLE, "busy", _("Busy"), TRUE, TRUE, FALSE,
 
695
                        "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
 
696
                        NULL);
 
697
        types = g_list_append(types, status);
 
698
        status = purple_status_type_new_with_attrs(
 
699
                        PURPLE_STATUS_UNAVAILABLE, "phone", _("On the Phone"), TRUE, TRUE, FALSE,
 
700
                        "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
 
701
                        NULL);
 
702
        types = g_list_append(types, status);
 
703
        status = purple_status_type_new_with_attrs(
 
704
                        PURPLE_STATUS_AWAY, "lunch", _("Out to Lunch"), TRUE, TRUE, FALSE,
 
705
                        "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
 
706
                        NULL);
592
707
        types = g_list_append(types, status);
593
708
 
594
709
        status = purple_status_type_new_full(PURPLE_STATUS_INVISIBLE,
603
718
                        "mobile", NULL, FALSE, FALSE, TRUE);
604
719
        types = g_list_append(types, status);
605
720
 
 
721
        status = purple_status_type_new_with_attrs(PURPLE_STATUS_TUNE,
 
722
                        "tune", NULL, TRUE, TRUE, TRUE,
 
723
                        PURPLE_TUNE_ARTIST, _("Artist"), purple_value_new(PURPLE_TYPE_STRING),
 
724
                        PURPLE_TUNE_ALBUM, _("Album"), purple_value_new(PURPLE_TYPE_STRING),
 
725
                        PURPLE_TUNE_TITLE, _("Title"), purple_value_new(PURPLE_TYPE_STRING),
 
726
                        NULL);
 
727
        types = g_list_append(types, status);
 
728
 
606
729
        return types;
607
730
}
608
731
 
721
844
 
722
845
        if (!purple_ssl_is_supported())
723
846
        {
724
 
                gc->wants_to_die = TRUE;
725
 
                purple_connection_error(gc,
 
847
                purple_connection_error_reason (gc,
 
848
                        PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
726
849
                        _("SSL support is needed for MSN. Please install a supported "
727
850
                          "SSL library."));
728
851
                return;
751
874
                purple_account_set_username(account, username);
752
875
 
753
876
        if (!msn_session_connect(session, host, port, http_method))
754
 
                purple_connection_error(gc, _("Failed to connect to server."));
 
877
                purple_connection_error_reason (gc,
 
878
                        PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
 
879
                        _("Failed to connect to server."));
755
880
}
756
881
 
757
882
static void
788
913
        char *msgformat;
789
914
        char *msgtext;
790
915
 
 
916
        purple_debug_info("MSNP14","send IM {%s} to %s\n",message,who);
791
917
        account = purple_connection_get_account(gc);
792
918
 
793
919
        if (buddy) {
801
927
        }
802
928
 
803
929
        msn_import_html(message, &msgformat, &msgtext);
804
 
 
805
 
        if (strlen(msgtext) + strlen(msgformat) + strlen(VERSION) > 1564)
806
 
        {
 
930
        if(msn_user_is_online(account, who)||
 
931
                msn_user_is_yahoo(account, who)){
 
932
                /*User online,then send Online Instant Message*/
 
933
 
 
934
                if (strlen(msgtext) + strlen(msgformat) + strlen(VERSION) > 1564)
 
935
                {
 
936
                        g_free(msgformat);
 
937
                        g_free(msgtext);
 
938
 
 
939
                        return -E2BIG;
 
940
                }
 
941
 
 
942
                msg = msn_message_new_plain(msgtext);
 
943
                msg->remote_user = g_strdup(who);
 
944
                msn_message_set_attr(msg, "X-MMS-IM-Format", msgformat);
 
945
 
807
946
                g_free(msgformat);
808
947
                g_free(msgtext);
809
948
 
810
 
                return -E2BIG;
811
 
        }
812
 
 
813
 
        msg = msn_message_new_plain(msgtext);
814
 
        msn_message_set_attr(msg, "X-MMS-IM-Format", msgformat);
815
 
 
816
 
        g_free(msgformat);
817
 
        g_free(msgtext);
818
 
 
819
 
        if (g_ascii_strcasecmp(who, purple_account_get_username(account)))
820
 
        {
 
949
                purple_debug_info("MSNP14","prepare to send online Message\n");
 
950
                if (g_ascii_strcasecmp(who, purple_account_get_username(account)))
 
951
                {
 
952
                        MsnSession *session;
 
953
                        MsnSwitchBoard *swboard;
 
954
 
 
955
                        session = gc->proto_data;
 
956
                        if(msn_user_is_yahoo(account,who)){
 
957
                                /*we send the online and offline Message to Yahoo User via UBM*/
 
958
                                purple_debug_info("MSNP14","send to Yahoo User\n");
 
959
                                uum_send_msg(session,msg);
 
960
                        }else{
 
961
                                purple_debug_info("MSNP14","send via switchboard\n");
 
962
                                swboard = msn_session_get_swboard(session, who, MSN_SB_FLAG_IM);
 
963
                                msn_switchboard_send_msg(swboard, msg, TRUE);
 
964
                        }
 
965
                }
 
966
                else
 
967
                {
 
968
                        char *body_str, *body_enc, *pre, *post;
 
969
                        const char *format;
 
970
                        MsnIMData *imdata = g_new0(MsnIMData, 1);
 
971
                        /*
 
972
                         * In MSN, you can't send messages to yourself, so
 
973
                         * we'll fake like we received it ;)
 
974
                         */
 
975
                        body_str = msn_message_to_string(msg);
 
976
                        body_enc = g_markup_escape_text(body_str, -1);
 
977
                        g_free(body_str);
 
978
 
 
979
                        format = msn_message_get_attr(msg, "X-MMS-IM-Format");
 
980
                        msn_parse_format(format, &pre, &post);
 
981
                        body_str = g_strdup_printf("%s%s%s", pre ? pre :  "",
 
982
                                                                           body_enc ? body_enc : "", post ? post : "");
 
983
                        g_free(body_enc);
 
984
                        g_free(pre);
 
985
                        g_free(post);
 
986
 
 
987
                        serv_got_typing_stopped(gc, who);
 
988
                        imdata->gc = gc;
 
989
                        imdata->who = who;
 
990
                        imdata->msg = body_str;
 
991
                        imdata->flags = flags;
 
992
                        imdata->when = time(NULL);
 
993
                        purple_timeout_add(0, msn_send_me_im, imdata);
 
994
                }
 
995
 
 
996
                msn_message_destroy(msg);
 
997
        }else   {
 
998
                /*send Offline Instant Message,only to MSN Passport User*/
821
999
                MsnSession *session;
822
 
                MsnSwitchBoard *swboard;
 
1000
                char *friendname;
823
1001
 
 
1002
                purple_debug_info("MSNP14","prepare to send offline Message\n");
824
1003
                session = gc->proto_data;
825
 
                swboard = msn_session_get_swboard(session, who, MSN_SB_FLAG_IM);
826
 
 
827
 
                msn_switchboard_send_msg(swboard, msg, TRUE);
828
 
        }
829
 
        else
830
 
        {
831
 
                char *body_str, *body_enc, *pre, *post;
832
 
                const char *format;
833
 
                MsnIMData *imdata = g_new0(MsnIMData, 1);
834
 
                /*
835
 
                 * In MSN, you can't send messages to yourself, so
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);
 
1004
 
 
1005
                friendname = msn_encode_mime(account->username);
 
1006
                msn_oim_prep_send_msg_info(session->oim,
 
1007
                        purple_account_get_username(account),
 
1008
                        friendname, who,        message);
 
1009
                msn_oim_send_msg(session->oim);
 
1010
                g_free(friendname);
 
1011
        }
860
1012
 
861
1013
        return 1;
862
1014
}
995
1147
        userlist = session->userlist;
996
1148
        who = msn_normalize(gc->account, buddy->name);
997
1149
 
 
1150
        purple_debug_info("MSN","Add user:%s to group:%s\n", who, (group && group->name) ? group->name : "(null)");
998
1151
        if (!session->logged_in)
999
1152
        {
1000
1153
#if 0
1028
1181
        /* XXX - Would group ever be NULL here?  I don't think so...
1029
1182
         * shx: Yes it should; MSN handles non-grouped buddies, and this is only
1030
1183
         * internal. */
1031
 
        msn_userlist_add_buddy(userlist, who, MSN_LIST_FL,
1032
 
                                                   group ? group->name : NULL);
 
1184
        msn_userlist_add_buddy(userlist, who, group ? group->name : NULL);
1033
1185
}
1034
1186
 
1035
1187
static void
1045
1197
                return;
1046
1198
 
1047
1199
        /* 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);
 
1200
        msn_userlist_rem_buddy(userlist, buddy->name);
1049
1201
}
1050
1202
 
1051
1203
static void
1062
1214
        if (!session->logged_in)
1063
1215
                return;
1064
1216
 
1065
 
        if (user != NULL && user->list_op & MSN_LIST_BL_OP)
1066
 
                msn_userlist_rem_buddy(userlist, who, MSN_LIST_BL, NULL);
1067
 
 
1068
 
        msn_userlist_add_buddy(userlist, who, MSN_LIST_AL, NULL);
 
1217
        if (user != NULL && user->list_op & MSN_LIST_BL_OP) {
 
1218
                msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_BL);
 
1219
 
 
1220
                /* delete contact from Block list and add it to Allow in the callback */
 
1221
                msn_del_contact_from_list(session->contact, NULL, who, MSN_LIST_BL);
 
1222
        } else {
 
1223
                /* just add the contact to Allow list */
 
1224
                msn_add_contact_to_list(session->contact, NULL, who, MSN_LIST_AL);
 
1225
        }
 
1226
 
 
1227
 
 
1228
        msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_AL);
1069
1229
}
1070
1230
 
1071
1231
static void
1082
1242
        if (!session->logged_in)
1083
1243
                return;
1084
1244
 
1085
 
        if (user != NULL && user->list_op & MSN_LIST_AL_OP)
1086
 
                msn_userlist_rem_buddy(userlist, who, MSN_LIST_AL, NULL);
1087
 
 
1088
 
        msn_userlist_add_buddy(userlist, who, MSN_LIST_BL, NULL);
 
1245
        if (user != NULL && user->list_op & MSN_LIST_AL_OP) {
 
1246
                msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_AL);
 
1247
 
 
1248
                /* delete contact from Allow list and add it to Block in the callback */
 
1249
                msn_del_contact_from_list(session->contact, NULL, who, MSN_LIST_AL);
 
1250
        } else {
 
1251
                /* just add the contact to Block list */
 
1252
                msn_add_contact_to_list(session->contact, NULL, who, MSN_LIST_BL);
 
1253
        }
 
1254
 
 
1255
        msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_BL);
1089
1256
}
1090
1257
 
1091
1258
static void
1103
1270
 
1104
1271
        user = msn_userlist_find_user(userlist, who);
1105
1272
 
1106
 
        msn_userlist_rem_buddy(userlist, who, MSN_LIST_AL, NULL);
 
1273
        msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_AL);
 
1274
 
 
1275
        msn_del_contact_from_list(session->contact, NULL, who, MSN_LIST_AL);
1107
1276
 
1108
1277
        if (user != NULL && user->list_op & MSN_LIST_RL_OP)
1109
 
                msn_userlist_add_buddy(userlist, who, MSN_LIST_BL, NULL);
 
1278
                msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_BL);
1110
1279
}
1111
1280
 
1112
1281
static void
1124
1293
 
1125
1294
        user = msn_userlist_find_user(userlist, who);
1126
1295
 
1127
 
        msn_userlist_rem_buddy(userlist, who, MSN_LIST_BL, NULL);
 
1296
        msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_BL);
 
1297
 
 
1298
        msn_del_contact_from_list(session->contact, NULL, who, MSN_LIST_BL);
1128
1299
 
1129
1300
        if (user != NULL && user->list_op & MSN_LIST_RL_OP)
1130
 
                msn_userlist_add_buddy(userlist, who, MSN_LIST_AL, NULL);
 
1301
                msn_userlist_add_buddy_to_list(userlist, who, MSN_LIST_AL);
1131
1302
}
1132
1303
 
1133
1304
static void
1134
1305
msn_set_permit_deny(PurpleConnection *gc)
1135
1306
{
1136
 
        PurpleAccount *account;
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
 
        }
 
1307
        msn_send_privacy(gc);
1153
1308
}
1154
1309
 
1155
1310
static void
1286
1441
                                 PurpleGroup *group, GList *moved_buddies)
1287
1442
{
1288
1443
        MsnSession *session;
1289
 
        MsnCmdProc *cmdproc;
1290
 
        int old_gid;
1291
 
        const char *enc_new_group_name;
1292
1444
 
1293
1445
        session = gc->proto_data;
1294
 
        cmdproc = session->notification->cmdproc;
1295
 
        enc_new_group_name = purple_url_encode(group->name);
1296
 
 
1297
 
        old_gid = msn_userlist_find_group_id(session->userlist, old_name);
1298
 
 
1299
 
        if (old_gid >= 0)
 
1446
        
 
1447
        g_return_if_fail(session != NULL);
 
1448
        g_return_if_fail(session->userlist != NULL);
 
1449
        
 
1450
        if (msn_userlist_find_group_with_name(session->userlist, old_name) != NULL)
1300
1451
        {
1301
 
                msn_cmdproc_send(cmdproc, "REG", "%d %s 0", old_gid,
1302
 
                                                 enc_new_group_name);
 
1452
                msn_contact_rename_group(session, old_name, group->name);
1303
1453
        }
1304
1454
        else
1305
1455
        {
1306
 
                msn_cmdproc_send(cmdproc, "ADG", "%s 0", enc_new_group_name);
 
1456
                /* not found */
 
1457
                msn_add_group(session, NULL, group->name);
1307
1458
        }
1308
1459
}
1309
1460
 
1363
1514
{
1364
1515
        MsnSession *session;
1365
1516
        MsnCmdProc *cmdproc;
1366
 
        int group_id;
1367
1517
 
1368
1518
        session = gc->proto_data;
1369
1519
        cmdproc = session->notification->cmdproc;
1370
1520
 
1371
 
        if ((group_id = msn_userlist_find_group_id(session->userlist, group->name)) >= 0)
 
1521
        purple_debug_info("MSN", "Remove group %s\n", group->name);
 
1522
        /*we can't delete the default group*/
 
1523
        if(!strcmp(group->name, MSN_INDIVIDUALS_GROUP_NAME)||
 
1524
                !strcmp(group->name, MSN_NON_IM_GROUP_NAME))
1372
1525
        {
1373
 
                msn_cmdproc_send(cmdproc, "RMG", "%d", group_id);
 
1526
                purple_debug_info("MSN", "This group can't be removed, returning.\n");
 
1527
                return ;
1374
1528
        }
 
1529
        
 
1530
        msn_del_group(session, group->name);
1375
1531
}
1376
1532
 
1377
1533
/**
1421
1577
{
1422
1578
        char *p, *q;
1423
1579
 
1424
 
        if ((p = strstr(url_text, " contactparams:photopreauthurl=\"")) != NULL)
 
1580
        if ((p = strstr(url_text, PHOTO_URL)) != NULL)
1425
1581
        {
1426
 
                p += strlen(" contactparams:photopreauthurl=\"");
 
1582
                p += strlen(PHOTO_URL);
1427
1583
        }
1428
 
 
1429
 
        if (p && (strncmp(p, "http://", 8) == 0) && ((q = strchr(p, '"')) != NULL))
 
1584
        if (p && (strncmp(p, "http://",strlen("http://")) == 0) && ((q = strchr(p, '"')) != NULL))
1430
1585
                        return g_strndup(p, q - p);
1431
1586
 
1432
1587
        return NULL;
1464
1619
msn_info_strip_search_link(const char *field, size_t len)
1465
1620
{
1466
1621
        const char *c;
1467
 
        if ((c = strstr(field, " (http://spaces.live.com/default.aspx?page=searchresults")) == NULL &&
1468
 
                (c = strstr(field, " (http://spaces.msn.com/default.aspx?page=searchresults")) == NULL)
 
1622
        if ((c = strstr(field, " (http://")) == NULL)
1469
1623
                return g_strndup(field, len);
1470
1624
        return g_strndup(field, c - field);
1471
1625
}
1490
1644
        MsnGetInfoStepTwoData *info2_data = NULL;
1491
1645
#endif
1492
1646
 
1493
 
        purple_debug_info("msn", "In msn_got_info\n");
 
1647
        purple_debug_info("msn", "In msn_got_info,url_text:{%s}\n",url_text);
1494
1648
 
1495
1649
        /* Make sure the connection is still valid */
1496
1650
        if (g_list_find(purple_connections_get_all(), info_data->gc) == NULL)
1869
2023
#if PHOTO_SUPPORT
1870
2024
        /* Find the URL to the photo; must be before the marshalling [Bug 994207] */
1871
2025
        photo_url_text = msn_get_photo_url(url_text);
 
2026
        purple_debug_info("MSNP14","photo url:{%s}\n", photo_url_text ? photo_url_text : "(null)");
1872
2027
 
1873
2028
        /* Marshall the existing state */
1874
 
        info2_data = g_malloc0(sizeof(MsnGetInfoStepTwoData));
 
2029
        info2_data = g_new0(MsnGetInfoStepTwoData, 1);
1875
2030
        info2_data->info_data = info_data;
1876
2031
        info2_data->stripped = stripped;
1877
2032
        info2_data->url_buffer = url_buffer;
2093
2248
        msn_add_deny,                   /* add_deny */
2094
2249
        msn_rem_permit,                 /* rem_permit */
2095
2250
        msn_rem_deny,                   /* rem_deny */
2096
 
        msn_set_permit_deny,            /* set_permit_deny */
 
2251
        msn_set_permit_deny,    /* set_permit_deny */
2097
2252
        NULL,                                   /* join_chat */
2098
2253
        NULL,                                   /* reject chat invite */
2099
2254
        NULL,                                   /* get_chat_name */
2147
2302
 
2148
2303
        "prpl-msn",                                       /**< id             */
2149
2304
        "MSN",                                            /**< name           */
2150
 
        VERSION,                                          /**< version        */
 
2305
        DISPLAY_VERSION,                                  /**< version        */
2151
2306
                                                          /**  summary        */
2152
 
        N_("MSN Protocol Plugin"),
 
2307
        N_("Windows Live Messenger Protocol Plugin"),
2153
2308
                                                          /**  description    */
2154
 
        N_("MSN Protocol Plugin"),
2155
 
        "Christian Hammond <chipx86@gnupdate.org>",       /**< author         */
 
2309
        N_("Windows Live Messenger Protocol Plugin"),
 
2310
        "Christian Hammond <chipx86@gnupdate.org>, "
 
2311
        "MaYuan <mayuan2006@gmail.com>",                                  /**< author         */
2156
2312
        PURPLE_WEBSITE,                                     /**< homepage       */
2157
2313
 
2158
2314
        msn_load,                                         /**< load           */
2177
2333
        PurpleAccountOption *option;
2178
2334
 
2179
2335
        option = purple_account_option_string_new(_("Server"), "server",
2180
 
                                                                                        MSN_SERVER);
 
2336
                                                                                        WLM_SERVER);
2181
2337
        prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
2182
2338
                                                                                           option);
2183
2339
 
2184
 
        option = purple_account_option_int_new(_("Port"), "port", 1863);
 
2340
        option = purple_account_option_int_new(_("Port"), "port", WLM_PORT);
2185
2341
        prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
2186
2342
                                                                                           option);
2187
2343