comparison libpurple/protocols/msn/switchboard.c @ 20694:d35d761ded1a

propagate from branch 'im.pidgin.rlaager.merging.2_2_1_conflicts' (head e76d28a0d9305478af3a13c36b2feaa466fc27ec) to branch 'im.pidgin.pidgin' (head fe204b08484653e89ab7ac68a4f50421599e078c)
author Richard Laager <rlaager@wiktel.com>
date Fri, 28 Sep 2007 20:29:06 +0000
parents de8dd5a54e85 22034ce81dc4
children 2c039a40babc
comparison
equal deleted inserted replaced
20379:66c76cdf4c40 20694:d35d761ded1a
23 */ 23 */
24 #include "msn.h" 24 #include "msn.h"
25 #include "prefs.h" 25 #include "prefs.h"
26 #include "switchboard.h" 26 #include "switchboard.h"
27 #include "notification.h" 27 #include "notification.h"
28 #include "msn-utils.h" 28 #include "msnutils.h"
29 29
30 #include "error.h" 30 #include "error.h"
31 31
32 static MsnTable *cbs_table; 32 static MsnTable *cbs_table;
33 33
532 cmdproc = swboard->cmdproc; 532 cmdproc = swboard->cmdproc;
533 533
534 payload = msn_message_gen_payload(msg, &payload_len); 534 payload = msn_message_gen_payload(msg, &payload_len);
535 535
536 #ifdef MSN_DEBUG_SB 536 #ifdef MSN_DEBUG_SB
537 purple_debug_info("MSNP14","SB length:{%d}",payload_len);
537 msn_message_show_readable(msg, "SB SEND", FALSE); 538 msn_message_show_readable(msg, "SB SEND", FALSE);
538 #endif 539 #endif
539 540
540 trans = msn_transaction_new(cmdproc, "MSG", "%c %d", 541 trans = msn_transaction_new(cmdproc, "MSG", "%c %d",
541 msn_message_get_flag(msg), payload_len); 542 msn_message_get_flag(msg), payload_len);
619 gboolean queue) 620 gboolean queue)
620 { 621 {
621 g_return_if_fail(swboard != NULL); 622 g_return_if_fail(swboard != NULL);
622 g_return_if_fail(msg != NULL); 623 g_return_if_fail(msg != NULL);
623 624
625 purple_debug_info("MSNP14","switchboard send msg..\n");
624 if (msn_switchboard_can_send(swboard)) 626 if (msn_switchboard_can_send(swboard))
625 release_msg(swboard, msg); 627 release_msg(swboard, msg);
626 else if (queue) 628 else if (queue)
627 queue_msg(swboard, msg); 629 queue_msg(swboard, msg);
628 } 630 }
725 { 727 {
726 MsnMessage *msg; 728 MsnMessage *msg;
727 729
728 msg = msn_message_new_from_cmd(cmdproc->session, cmd); 730 msg = msn_message_new_from_cmd(cmdproc->session, cmd);
729 731
730 msn_message_parse_payload(msg, payload, len); 732 msn_message_parse_payload(msg, payload, len,
733 MSG_LINE_DEM,MSG_BODY_DEM);
731 #ifdef MSN_DEBUG_SB 734 #ifdef MSN_DEBUG_SB
732 msn_message_show_readable(msg, "SB RECV", FALSE); 735 msn_message_show_readable(msg, "SB RECV", FALSE);
733 #endif 736 #endif
734 737
735 if (msg->remote_user != NULL) 738 if (msg->remote_user != NULL)
743 746
744 static void 747 static void
745 msg_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) 748 msg_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
746 { 749 {
747 cmdproc->servconn->payload_len = atoi(cmd->params[2]); 750 cmdproc->servconn->payload_len = atoi(cmd->params[2]);
751 cmdproc->last_cmd->payload_cb = msg_cmd_post;
752 }
753
754 static void
755 ubm_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
756 {
757 purple_debug_misc("MSNP14","get UBM...\n");
758 cmdproc->servconn->payload_len = atoi(cmd->params[4]);
748 cmdproc->last_cmd->payload_cb = msg_cmd_post; 759 cmdproc->last_cmd->payload_cb = msg_cmd_post;
749 } 760 }
750 761
751 static void 762 static void
752 nak_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) 763 nak_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
1082 1093
1083 static void 1094 static void
1084 cal_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error) 1095 cal_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error)
1085 { 1096 {
1086 int reason = MSN_SB_ERROR_UNKNOWN; 1097 int reason = MSN_SB_ERROR_UNKNOWN;
1098 MsnMessage *msg;
1099 MsnSwitchBoard *swboard = trans->data;
1087 1100
1088 if (error == 215) 1101 if (error == 215)
1089 { 1102 {
1090 purple_debug_info("msn", "Invited user already in switchboard\n"); 1103 purple_debug_info("msn", "Invited user already in switchboard\n");
1091 return; 1104 return;
1094 { 1107 {
1095 reason = MSN_SB_ERROR_USER_OFFLINE; 1108 reason = MSN_SB_ERROR_USER_OFFLINE;
1096 } 1109 }
1097 1110
1098 purple_debug_warning("msn", "cal_error: command %s gave error %i\n", trans->command, error); 1111 purple_debug_warning("msn", "cal_error: command %s gave error %i\n", trans->command, error);
1099 1112 purple_debug_warning("msn", "Will Use Offline Message to sendit\n");
1113
1114 // cal_error_helper(trans, reason);
1115 /*offline Message send Process*/
1116
1117 while ((msg = g_queue_pop_head(swboard->msg_queue)) != NULL){
1118 purple_debug_warning("MSNP14","offline msg to send:{%s}\n",msg->body);
1119 /* The messages could not be sent due to a switchboard error */
1120 swboard->error = MSN_SB_ERROR_USER_OFFLINE;
1121 msg_error_helper(swboard->cmdproc, msg,
1122 MSN_MSG_ERROR_SB);
1123 msn_message_unref(msg);
1124 }
1100 cal_error_helper(trans, reason); 1125 cal_error_helper(trans, reason);
1101 } 1126 }
1102 1127
1103 void 1128 void
1104 msn_switchboard_request_add_user(MsnSwitchBoard *swboard, const char *user) 1129 msn_switchboard_request_add_user(MsnSwitchBoard *swboard, const char *user)
1138 1163
1139 if (g_list_find(cmdproc->session->switches, swboard) == NULL) 1164 if (g_list_find(cmdproc->session->switches, swboard) == NULL)
1140 /* The conversation window was closed. */ 1165 /* The conversation window was closed. */
1141 return; 1166 return;
1142 1167
1168 purple_debug_info("MSNP14","Switchboard:auth:{%s} socket:{%s}\n",cmd->params[4],cmd->params[2]);
1143 msn_switchboard_set_auth_key(swboard, cmd->params[4]); 1169 msn_switchboard_set_auth_key(swboard, cmd->params[4]);
1144 1170
1145 msn_parse_socket(cmd->params[2], &host, &port); 1171 msn_parse_socket(cmd->params[2], &host, &port);
1146 1172
1147 if (!msn_switchboard_connect(swboard, host, port)) 1173 if (!msn_switchboard_connect(swboard, host, port))
1250 msn_table_add_cmd(cbs_table, "MSG", "NAK", nak_cmd); 1276 msn_table_add_cmd(cbs_table, "MSG", "NAK", nak_cmd);
1251 1277
1252 msn_table_add_cmd(cbs_table, "USR", "USR", usr_cmd); 1278 msn_table_add_cmd(cbs_table, "USR", "USR", usr_cmd);
1253 1279
1254 msn_table_add_cmd(cbs_table, NULL, "MSG", msg_cmd); 1280 msn_table_add_cmd(cbs_table, NULL, "MSG", msg_cmd);
1281 msn_table_add_cmd(cbs_table, NULL, "UBM", ubm_cmd);
1255 msn_table_add_cmd(cbs_table, NULL, "JOI", joi_cmd); 1282 msn_table_add_cmd(cbs_table, NULL, "JOI", joi_cmd);
1256 msn_table_add_cmd(cbs_table, NULL, "BYE", bye_cmd); 1283 msn_table_add_cmd(cbs_table, NULL, "BYE", bye_cmd);
1257 msn_table_add_cmd(cbs_table, NULL, "OUT", out_cmd); 1284 msn_table_add_cmd(cbs_table, NULL, "OUT", out_cmd);
1258 1285
1259 #if 0 1286 #if 0