comparison src/protocols/msn/msn.c @ 10275:d9468bd22b7c

[gaim-migrate @ 11428] I reworked Fernando Herrera's patch from September to show who you've blocked and who doesn't have you on their MSN buddy list as emblems. I reworked Evan Schoenberg's patch to more accurately render formatting in messages sent to yourself on MSN Applied part of a patch from Felipe Contreras to fix auto-login to hotmail for new mail (the other part was to make it work on win32, but I think that's no longer needed), and I made sure that the temporary file used is deleted at the end of the session (mentioned in patch 1059682 by Nigel Horne) Applied patch 1073317 by Nigel Horne - even though I think it may not be strictly necessary, it's probably safer like this. I'm committing Felipe's new MSN icon too, I think it's much better, and so does everyone else who's expressed an opinion. committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Sun, 28 Nov 2004 18:13:18 +0000
parents 3016b1b32339
children a7b2fd5efcf2
comparison
equal deleted inserted replaced
10274:3016b1b32339 10275:d9468bd22b7c
47 #include "imgstore.h" 47 #include "imgstore.h"
48 #endif 48 #endif
49 49
50 #define BUDDY_ALIAS_MAXLEN 387 50 #define BUDDY_ALIAS_MAXLEN 387
51 51
52 static GaimPlugin *my_protocol = NULL;
53
54 typedef struct 52 typedef struct
55 { 53 {
56 GaimConnection *gc; 54 GaimConnection *gc;
57 const char *passport; 55 const char *passport;
58 56
456 454
457 if (user == NULL) 455 if (user == NULL)
458 { 456 {
459 emblems[0] = "offline"; 457 emblems[0] = "offline";
460 } 458 }
461 else if (user->mobile) 459 else
462 emblems[i++] = "wireless"; 460 {
461 if (user->mobile)
462 emblems[i++] = "wireless";
463 if (user->list_op & (1 << MSN_LIST_BL))
464 emblems[i++] = "blocked";
465 if (!(user->list_op & (1 << MSN_LIST_RL)))
466 emblems[i++] = "nr";
467 }
463 468
464 *se = emblems[0]; 469 *se = emblems[0];
465 *sw = emblems[1]; 470 *sw = emblems[1];
466 *nw = emblems[2]; 471 *nw = emblems[2];
467 *ne = emblems[3]; 472 *ne = emblems[3];
504 509
505 if (user) 510 if (user)
506 { 511 {
507 g_string_append_printf(s, _("\n<b>%s:</b> %s"), _("Has you"), 512 g_string_append_printf(s, _("\n<b>%s:</b> %s"), _("Has you"),
508 (user->list_op & (1 << MSN_LIST_RL)) ? 513 (user->list_op & (1 << MSN_LIST_RL)) ?
514 _("Yes") : _("No"));
515 g_string_append_printf(s, _("\n<b>%s:</b> %s"), _("Blocked"),
516 (user->list_op & (1 << MSN_LIST_BL)) ?
509 _("Yes") : _("No")); 517 _("Yes") : _("No"));
510 } 518 }
511 519
512 return g_string_free(s, FALSE); 520 return g_string_free(s, FALSE);
513 } 521 }
677 host = gaim_account_get_string(account, "server", MSN_SERVER); 685 host = gaim_account_get_string(account, "server", MSN_SERVER);
678 port = gaim_account_get_int(account, "port", MSN_PORT); 686 port = gaim_account_get_int(account, "port", MSN_PORT);
679 } 687 }
680 688
681 session = msn_session_new(account, host, port, http_method); 689 session = msn_session_new(account, host, port, http_method);
682 session->prpl = my_protocol;
683 690
684 if (session->http_method) 691 if (session->http_method)
685 msn_http_session_init(session); 692 msn_http_session_init(session);
686 693
687 gc->proto_data = session; 694 gc->proto_data = session;
718 static int 725 static int
719 msn_send_im(GaimConnection *gc, const char *who, const char *message, 726 msn_send_im(GaimConnection *gc, const char *who, const char *message,
720 GaimConvImFlags flags) 727 GaimConvImFlags flags)
721 { 728 {
722 GaimAccount *account; 729 GaimAccount *account;
730 MsnMessage *msg;
731 char *msgformat;
732 char *msgtext;
723 733
724 account = gaim_connection_get_account(gc); 734 account = gaim_connection_get_account(gc);
735
736 msn_import_html(message, &msgformat, &msgtext);
737
738 if (strlen(msgtext) + strlen(msgformat) + strlen(VERSION) > 1564)
739 {
740 g_free(msgformat);
741 g_free(msgtext);
742
743 return -E2BIG;
744 }
745
746 msg = msn_message_new_plain(msgtext);
747 msn_message_set_attr(msg, "X-MMS-IM-Format", msgformat);
748
749 g_free(msgformat);
750 g_free(msgtext);
725 751
726 if (g_ascii_strcasecmp(who, gaim_account_get_username(account))) 752 if (g_ascii_strcasecmp(who, gaim_account_get_username(account)))
727 { 753 {
728 MsnSession *session; 754 MsnSession *session;
729 MsnSwitchBoard *swboard; 755 MsnSwitchBoard *swboard;
730 MsnMessage *msg;
731 char *msgformat;
732 char *msgtext;
733 756
734 session = gc->proto_data; 757 session = gc->proto_data;
735 swboard = msn_session_get_swboard(session, who); 758 swboard = msn_session_get_swboard(session, who);
736 759
737 msn_import_html(message, &msgformat, &msgtext);
738
739 if (strlen(msgtext) + strlen(msgformat) + strlen(VERSION) > 1564)
740 {
741 g_free(msgformat);
742 g_free(msgtext);
743
744 return -E2BIG;
745 }
746
747 msg = msn_message_new_plain(msgtext);
748 msn_message_set_attr(msg, "X-MMS-IM-Format", msgformat);
749
750 g_free(msgformat);
751 g_free(msgtext);
752
753 swboard = msn_session_get_swboard(session, who);
754 760
755 if (!g_queue_is_empty(swboard->im_queue) || 761 if (!g_queue_is_empty(swboard->im_queue) ||
756 !swboard->user_joined) 762 !swboard->user_joined)
757 { 763 {
758 msn_switchboard_queue_msg(swboard, msg); 764 msn_switchboard_queue_msg(swboard, msg);
760 else 766 else
761 { 767 {
762 msn_switchboard_send_msg(swboard, msg); 768 msn_switchboard_send_msg(swboard, msg);
763 } 769 }
764 770
765 msn_message_destroy(msg);
766 } 771 }
767 else 772 else
768 { 773 {
774 char *body_str, *body_enc, *pre, *post;
775 const char *format;
769 /* 776 /*
770 * In MSN, you can't send messages to yourself, so 777 * In MSN, you can't send messages to yourself, so
771 * we'll fake like we received it ;) 778 * we'll fake like we received it ;)
772 */ 779 */
780 body_str = msn_message_to_string(msg);
781 body_enc = gaim_escape_html(body_str);
782 g_free(body_str);
783
784 format = msn_message_get_attr(msg, "X-MMS-IM-Format");
785 msn_parse_format(format, &pre, &post);
786 body_str = g_strdup_printf("%s%s%s", pre, body_enc, post);
787 g_free(pre);
788 g_free(post);
789
773 serv_got_typing_stopped(gc, who); 790 serv_got_typing_stopped(gc, who);
774 serv_got_im(gc, who, message, flags, time(NULL)); 791 serv_got_im(gc, who, body_str, flags, time(NULL));
775 } 792 g_free(body_str);
793 }
794
795 msn_message_destroy(msg);
776 796
777 return 1; 797 return 1;
778 } 798 }
779 799
780 static int 800 static int
1947 option = gaim_account_option_bool_new(_("Use HTTP Method"), 1967 option = gaim_account_option_bool_new(_("Use HTTP Method"),
1948 "http_method", FALSE); 1968 "http_method", FALSE);
1949 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, 1969 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
1950 option); 1970 option);
1951 1971
1952 my_protocol = plugin;
1953
1954 gaim_prefs_add_none("/plugins/prpl/msn"); 1972 gaim_prefs_add_none("/plugins/prpl/msn");
1955 gaim_prefs_add_bool("/plugins/prpl/msn/conv_close_notice", TRUE); 1973 gaim_prefs_add_bool("/plugins/prpl/msn/conv_close_notice", TRUE);
1956 gaim_prefs_add_bool("/plugins/prpl/msn/conv_timeout_notice", TRUE); 1974 gaim_prefs_add_bool("/plugins/prpl/msn/conv_timeout_notice", TRUE);
1957 } 1975 }
1958 1976