Mercurial > pidgin.yaz
comparison libpurple/protocols/msn/switchboard.c @ 20510:b77adb803eca
explicit merge of '7aea471c6710708afa40152f5fc3aaeda3d67e76'
and 'de8f03b35895989d67321798cda909c34dfffc24'
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sun, 16 Sep 2007 17:59:57 +0000 |
parents | 33ccac7fd32b 1754155051a4 |
children | 723b5a2f91ce |
comparison
equal
deleted
inserted
replaced
19647:33ccac7fd32b | 20510:b77adb803eca |
---|---|
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) |
1098 | 1109 |
1099 static void | 1110 static void |
1100 cal_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error) | 1111 cal_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error) |
1101 { | 1112 { |
1102 int reason = MSN_SB_ERROR_UNKNOWN; | 1113 int reason = MSN_SB_ERROR_UNKNOWN; |
1114 MsnMessage *msg; | |
1115 MsnSwitchBoard *swboard = trans->data; | |
1103 | 1116 |
1104 if (error == 215) | 1117 if (error == 215) |
1105 { | 1118 { |
1106 purple_debug_info("msn", "Invited user already in switchboard\n"); | 1119 purple_debug_info("msn", "Invited user already in switchboard\n"); |
1107 return; | 1120 return; |
1110 { | 1123 { |
1111 reason = MSN_SB_ERROR_USER_OFFLINE; | 1124 reason = MSN_SB_ERROR_USER_OFFLINE; |
1112 } | 1125 } |
1113 | 1126 |
1114 purple_debug_warning("msn", "cal_error: command %s gave error %i\n", trans->command, error); | 1127 purple_debug_warning("msn", "cal_error: command %s gave error %i\n", trans->command, error); |
1115 | 1128 purple_debug_warning("msn", "Will Use Offline Message to sendit\n"); |
1129 | |
1130 // cal_error_helper(trans, reason); | |
1131 /*offline Message send Process*/ | |
1132 | |
1133 while ((msg = g_queue_pop_head(swboard->msg_queue)) != NULL){ | |
1134 purple_debug_warning("MSNP14","offline msg to send:{%s}\n",msg->body); | |
1135 /* The messages could not be sent due to a switchboard error */ | |
1136 swboard->error = MSN_SB_ERROR_USER_OFFLINE; | |
1137 msg_error_helper(swboard->cmdproc, msg, | |
1138 MSN_MSG_ERROR_SB); | |
1139 msn_message_unref(msg); | |
1140 } | |
1116 cal_error_helper(trans, reason); | 1141 cal_error_helper(trans, reason); |
1117 } | 1142 } |
1118 | 1143 |
1119 void | 1144 void |
1120 msn_switchboard_request_add_user(MsnSwitchBoard *swboard, const char *user) | 1145 msn_switchboard_request_add_user(MsnSwitchBoard *swboard, const char *user) |
1154 | 1179 |
1155 if (g_list_find(cmdproc->session->switches, swboard) == NULL) | 1180 if (g_list_find(cmdproc->session->switches, swboard) == NULL) |
1156 /* The conversation window was closed. */ | 1181 /* The conversation window was closed. */ |
1157 return; | 1182 return; |
1158 | 1183 |
1184 purple_debug_info("MSNP14","Switchboard:auth:{%s} socket:{%s}\n",cmd->params[4],cmd->params[2]); | |
1159 msn_switchboard_set_auth_key(swboard, cmd->params[4]); | 1185 msn_switchboard_set_auth_key(swboard, cmd->params[4]); |
1160 | 1186 |
1161 msn_parse_socket(cmd->params[2], &host, &port); | 1187 msn_parse_socket(cmd->params[2], &host, &port); |
1162 | 1188 |
1163 if (!msn_switchboard_connect(swboard, host, port)) | 1189 if (!msn_switchboard_connect(swboard, host, port)) |
1266 msn_table_add_cmd(cbs_table, "MSG", "NAK", nak_cmd); | 1292 msn_table_add_cmd(cbs_table, "MSG", "NAK", nak_cmd); |
1267 | 1293 |
1268 msn_table_add_cmd(cbs_table, "USR", "USR", usr_cmd); | 1294 msn_table_add_cmd(cbs_table, "USR", "USR", usr_cmd); |
1269 | 1295 |
1270 msn_table_add_cmd(cbs_table, NULL, "MSG", msg_cmd); | 1296 msn_table_add_cmd(cbs_table, NULL, "MSG", msg_cmd); |
1297 msn_table_add_cmd(cbs_table, NULL, "UBM", ubm_cmd); | |
1271 msn_table_add_cmd(cbs_table, NULL, "JOI", joi_cmd); | 1298 msn_table_add_cmd(cbs_table, NULL, "JOI", joi_cmd); |
1272 msn_table_add_cmd(cbs_table, NULL, "BYE", bye_cmd); | 1299 msn_table_add_cmd(cbs_table, NULL, "BYE", bye_cmd); |
1273 msn_table_add_cmd(cbs_table, NULL, "OUT", out_cmd); | 1300 msn_table_add_cmd(cbs_table, NULL, "OUT", out_cmd); |
1274 | 1301 |
1275 #if 0 | 1302 #if 0 |