| 671 |
671 |
| 672 if (gaim_account_get_bool(account, "http_method", FALSE)) |
672 if (gaim_account_get_bool(account, "http_method", FALSE)) |
| 673 http_method = TRUE; |
673 http_method = TRUE; |
| 674 |
674 |
| 675 host = gaim_account_get_string(account, "server", MSN_SERVER); |
675 host = gaim_account_get_string(account, "server", MSN_SERVER); |
| 676 port = gaim_account_get_int(account, "port", MSN_PORT); |
676 port = gaim_account_get_int(account, "port", MSN_PORT); |
| 677 |
677 |
| 678 session = msn_session_new(account, host, port, http_method); |
678 session = msn_session_new(account); |
| 679 |
679 |
| 680 gc->proto_data = session; |
680 gc->proto_data = session; |
| 681 gc->flags |= GAIM_CONNECTION_HTML | GAIM_CONNECTION_FORMATTING_WBFO | GAIM_CONNECTION_NO_BGCOLOR | GAIM_CONNECTION_NO_FONTSIZE | GAIM_CONNECTION_NO_URLDESC; |
681 gc->flags |= GAIM_CONNECTION_HTML | GAIM_CONNECTION_FORMATTING_WBFO | GAIM_CONNECTION_NO_BGCOLOR | GAIM_CONNECTION_NO_FONTSIZE | GAIM_CONNECTION_NO_URLDESC; |
| 682 |
682 |
| 683 gaim_connection_update_progress(gc, _("Connecting"), 0, MSN_CONNECT_STEPS); |
683 msn_session_set_login_step(session, MSN_LOGIN_STEP_START); |
| 684 |
684 |
| 685 /* Hmm, I don't like this. */ |
685 /* Hmm, I don't like this. */ |
| |
686 /* XXX shx: Me neither */ |
| 686 username = msn_normalize(account, gaim_account_get_username(account)); |
687 username = msn_normalize(account, gaim_account_get_username(account)); |
| 687 |
688 |
| 688 if (strcmp(username, gaim_account_get_username(account))) |
689 if (strcmp(username, gaim_account_get_username(account))) |
| 689 gaim_account_set_username(account, username); |
690 gaim_account_set_username(account, username); |
| 690 |
691 |
| 691 msn_session_connect(session); |
692 msn_session_connect(session, host, port, http_method); |
| 692 } |
693 } |
| 693 |
694 |
| 694 static void |
695 static void |
| 695 msn_close(GaimConnection *gc) |
696 msn_close(GaimConnection *gc) |
| 696 { |
697 { |
| 738 MsnSwitchBoard *swboard; |
739 MsnSwitchBoard *swboard; |
| 739 |
740 |
| 740 session = gc->proto_data; |
741 session = gc->proto_data; |
| 741 swboard = msn_session_get_swboard(session, who); |
742 swboard = msn_session_get_swboard(session, who); |
| 742 |
743 |
| 743 if (!g_queue_is_empty(swboard->im_queue) || swboard->empty) |
744 msn_switchboard_send_msg(swboard, msg, TRUE); |
| 744 { |
|
| 745 msn_switchboard_queue_msg(swboard, msg); |
|
| 746 } |
|
| 747 else |
|
| 748 { |
|
| 749 msn_switchboard_send_msg(swboard, msg); |
|
| 750 } |
|
| 751 } |
745 } |
| 752 else |
746 else |
| 753 { |
747 { |
| 754 char *body_str, *body_enc, *pre, *post; |
748 char *body_str, *body_enc, *pre, *post; |
| 755 const char *format; |
749 const char *format; |
| 800 return MSN_TYPING_SEND_TIMEOUT; |
794 return MSN_TYPING_SEND_TIMEOUT; |
| 801 } |
795 } |
| 802 |
796 |
| 803 swboard = msn_session_find_swboard(session, who); |
797 swboard = msn_session_find_swboard(session, who); |
| 804 |
798 |
| 805 if (swboard == NULL) |
799 if (swboard == NULL || !msn_switchboard_can_send(swboard)) |
| 806 return 0; |
|
| 807 |
|
| 808 if (swboard->empty) |
|
| 809 return 0; |
|
| 810 |
|
| 811 if (!g_queue_is_empty(swboard->im_queue)) |
|
| 812 return 0; |
800 return 0; |
| 813 |
801 |
| 814 msg = msn_message_new(MSN_MSG_TYPING); |
802 msg = msn_message_new(MSN_MSG_TYPING); |
| 815 msn_message_set_content_type(msg, "text/x-msmsgscontrol"); |
803 msn_message_set_content_type(msg, "text/x-msmsgscontrol"); |
| 816 msn_message_set_flag(msg, 'U'); |
804 msn_message_set_flag(msg, 'U'); |
| 817 msn_message_set_attr(msg, "TypingUser", |
805 msn_message_set_attr(msg, "TypingUser", |
| 818 gaim_account_get_username(account)); |
806 gaim_account_get_username(account)); |
| 819 msn_message_set_bin_data(msg, "\r\n", 2); |
807 msn_message_set_bin_data(msg, "\r\n", 2); |
| 820 |
808 |
| 821 msn_switchboard_send_msg(swboard, msg); |
809 msn_switchboard_send_msg(swboard, msg, FALSE); |
| 822 |
810 |
| 823 msn_message_destroy(msg); |
811 msn_message_destroy(msg); |
| 824 |
812 |
| 825 return MSN_TYPING_SEND_TIMEOUT; |
813 return MSN_TYPING_SEND_TIMEOUT; |
| 826 } |
814 } |
| 1148 return -E2BIG; |
1136 return -E2BIG; |
| 1149 } |
1137 } |
| 1150 |
1138 |
| 1151 msg = msn_message_new_plain(msgtext); |
1139 msg = msn_message_new_plain(msgtext); |
| 1152 msn_message_set_attr(msg, "X-MMS-IM-Format", msgformat); |
1140 msn_message_set_attr(msg, "X-MMS-IM-Format", msgformat); |
| 1153 msn_switchboard_send_msg(swboard, msg); |
1141 msn_switchboard_send_msg(swboard, msg, FALSE); |
| 1154 msn_message_destroy(msg); |
1142 msn_message_destroy(msg); |
| 1155 |
1143 |
| 1156 g_free(msgformat); |
1144 g_free(msgformat); |
| 1157 g_free(msgtext); |
1145 g_free(msgtext); |
| 1158 |
1146 |
| 1167 { |
1155 { |
| 1168 MsnSession *session; |
1156 MsnSession *session; |
| 1169 MsnCmdProc *cmdproc; |
1157 MsnCmdProc *cmdproc; |
| 1170 |
1158 |
| 1171 session = gc->proto_data; |
1159 session = gc->proto_data; |
| |
1160 |
| 1172 cmdproc = session->notification->cmdproc; |
1161 cmdproc = session->notification->cmdproc; |
| 1173 |
1162 |
| 1174 if (!session->http_method) |
1163 if (!session->http_method) |
| 1175 msn_cmdproc_send_quick(cmdproc, "PNG", NULL, NULL); |
1164 msn_cmdproc_send_quick(cmdproc, "PNG", NULL, NULL); |
| 1176 } |
1165 } |