static void msg_error_helper(MsnCmdProc *cmdproc, MsnMessage *msg, MsnMsgErrorType error) { MsnSwitchBoard *swboard; g_return_if_fail(cmdproc != NULL); g_return_if_fail(msg != NULL); if ((error != MSN_MSG_ERROR_SB) && (msg->nak_cb != NULL)) msg->nak_cb(msg, msg->ack_data); swboard = cmdproc->data; /* This is not good, and should be fixed somewhere else. */ g_return_if_fail(swboard != NULL); if (msg->type == MSN_MSG_TEXT) { const char *format, *str_reason; char *body_str, *body_enc, *pre, *post; #if 0 if (swboard->conv == NULL) { if (msg->ack_ref) msn_message_unref(msg); return; } #endif if (error == MSN_MSG_ERROR_TIMEOUT) { str_reason = _("Message may have not been sent " "because a timeout occurred:"); } else if (error == MSN_MSG_ERROR_SB) { MsnSession *session = swboard->session; if (!session->destroying && msg->retries && swboard->im_user && (swboard->error == MSN_SB_ERROR_CONNECTION || swboard->error == MSN_SB_ERROR_UNKNOWN)) { MsnSwitchBoard *new_sw = msn_session_find_swboard(session, swboard->im_user); if (new_sw == NULL || new_sw->reconn_timeout_h == 0) { new_sw = msn_switchboard_new(session); new_sw->im_user = g_strdup(swboard->im_user); new_sw->reconn_timeout_h = purple_timeout_add_seconds(3, msg_resend_cb, new_sw); new_sw->flag |= MSN_SB_FLAG_IM; } body_str = msn_message_to_string(msg); body_enc = g_markup_escape_text(body_str, -1); g_free(body_str); purple_debug_info("msn", "queuing unsent message to %s: %s\n", swboard->im_user, body_enc); g_free(body_enc); msn_send_im_message(session, msg); msg->retries--; return; } switch (swboard->error) { case MSN_SB_ERROR_OFFLINE: str_reason = _("Message could not be sent, " "not allowed while invisible:"); break; case MSN_SB_ERROR_USER_OFFLINE: str_reason = _("Message could not be sent " "because the user is offline:"); break; case MSN_SB_ERROR_CONNECTION: str_reason = _("Message could not be sent " "because a connection error occurred:"); break; case MSN_SB_ERROR_TOO_FAST: str_reason = _("Message could not be sent " "because we are sending too quickly:"); break; case MSN_SB_ERROR_AUTHFAILED: str_reason = _("Message could not be sent " "because we were unable to establish a " "session with the server. This is " "likely a server problem, try again in " "a few minutes:"); break; default: str_reason = _("Message could not be sent " "because an error with " "the switchboard occurred:"); break; } } else { str_reason = _("Message may have not been sent " "because an unknown error occurred:"); } body_str = msn_message_to_string(msg); body_enc = g_markup_escape_text(body_str, -1); g_free(body_str); format = msn_message_get_attr(msg, "X-MMS-IM-Format"); msn_parse_format(format, &pre, &post); body_str = g_strdup_printf("%s%s%s", pre ? pre : "", body_enc ? body_enc : "", post ? post : ""); g_free(body_enc); g_free(pre); g_free(post); msn_switchboard_report_user(swboard, PURPLE_MESSAGE_ERROR, str_reason); msn_switchboard_report_user(swboard, PURPLE_MESSAGE_RAW, body_str); g_free(body_str); } /* If a timeout occures we will want the msg around just in case we * receive the ACK after the timeout. */ if (msg->ack_ref && error != MSN_MSG_ERROR_TIMEOUT) { swboard->ack_list = g_list_remove(swboard->ack_list, msg); msn_message_unref(msg); } }
static void msg_error_helper(MsnCmdProc *cmdproc, MsnMessage *msg, MsnMsgErrorType error) { MsnSwitchBoard *swboard; g_return_if_fail(cmdproc != NULL); g_return_if_fail(msg != NULL); if ((error != MSN_MSG_ERROR_SB) && (msg->nak_cb != NULL)) msg->nak_cb(msg, msg->ack_data); swboard = cmdproc->data; /* This is not good, and should be fixed somewhere else. */ g_return_if_fail(swboard != NULL); if (msg->type == MSN_MSG_TEXT) { const char *format, *str_reason; char *body_str, *body_enc, *pre, *post; #if 0 if (swboard->conv == NULL) { if (msg->ack_ref) msn_message_unref(msg); return; } #endif if (error == MSN_MSG_ERROR_TIMEOUT) { str_reason = _("Message may have not been sent " "because a timeout occurred:"); } else if (error == MSN_MSG_ERROR_SB) { switch (swboard->error) { case MSN_SB_ERROR_OFFLINE: str_reason = _("Message could not be sent, " "not allowed while invisible:"); break; case MSN_SB_ERROR_USER_OFFLINE: str_reason = _("Message could not be sent " "because the user is offline:"); break; case MSN_SB_ERROR_CONNECTION: str_reason = _("Message could not be sent " "because a connection error occurred:"); break; case MSN_SB_ERROR_TOO_FAST: str_reason = _("Message could not be sent " "because we are sending too quickly:"); break; default: str_reason = _("Message could not be sent " "because an error with " "the switchboard occurred:"); break; } } else { str_reason = _("Message may have not been sent " "because an unknown error occurred:"); } body_str = msn_message_to_string(msg); body_enc = g_markup_escape_text(body_str, -1); g_free(body_str); format = msn_message_get_attr(msg, "X-MMS-IM-Format"); msn_parse_format(format, &pre, &post); body_str = g_strdup_printf("%s%s%s", pre ? pre : "", body_enc ? body_enc : "", post ? post : ""); g_free(body_enc); g_free(pre); g_free(post); msn_switchboard_report_user(swboard, GAIM_MESSAGE_ERROR, str_reason); msn_switchboard_report_user(swboard, GAIM_MESSAGE_RAW, body_str); g_free(body_str); } /* If a timeout occures we will want the msg around just in case we * receive the ACK after the timeout. */ if (msg->ack_ref && error != MSN_MSG_ERROR_TIMEOUT) { swboard->ack_list = g_list_remove(swboard->ack_list, msg); msn_message_unref(msg); } }