chat_file_transfer.c: handle 4XX errors when trying to download image andlinphone_chat_message_cancel_file_transfer should change message state only if it was being pushed/pulled

This commit is contained in:
Gautier Pelloux-Prayer 2015-11-18 11:51:25 +01:00
parent 6725ac3323
commit d9a2fb2e08

View file

@ -449,6 +449,9 @@ static void linphone_chat_process_response_from_get_file(void *data, const belle
linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, NULL, 0);
}
linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferDone);
} else if (code >= 400 && code < 500) {
ms_warning("File transfer failed with code %d", code);
linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferError);
} else {
ms_warning("Unhandled HTTP code response %d for file transfer", code);
}
@ -539,7 +542,9 @@ void linphone_chat_message_start_file_download(LinphoneChatMessage *msg,
void linphone_chat_message_cancel_file_transfer(LinphoneChatMessage *msg) {
if (msg->http_request) {
linphone_chat_message_set_state(msg, LinphoneChatMessageStateNotDelivered);
if (msg->state == LinphoneChatMessageStateInProgress) {
linphone_chat_message_set_state(msg, LinphoneChatMessageStateNotDelivered);
}
if (!belle_http_request_is_cancelled(msg->http_request)) {
if (msg->chat_room) {
ms_message("Canceling file transfer %s - msg [%p] chat room[%p]"