diff --git a/coreapi/chat.c b/coreapi/chat.c index addc400fc..39e5f4c34 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -49,7 +49,8 @@ static size_t linphone_chat_message_compute_multipart_header_size(const char *fi return strlen(MULTIPART_HEADER_1)+strlen(filename)+strlen(MULTIPART_HEADER_2)+strlen(content_type)+strlen(MULTIPART_HEADER_3); } static void process_io_error(void *data, const belle_sip_io_error_event_t *event){ - printf("We have a response io error!\n"); + LinphoneChatMessage* msg=(LinphoneChatMessage *)data; + msg->cb(msg, LinphoneChatMessageStateNotDelivered, msg->chat_room->lc); } static void process_auth_requested(void *data, belle_sip_auth_event_t *event){ printf("We have a auth requested!\n"); diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index 3d1cbc953..239e30e0b 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -131,6 +131,7 @@ typedef struct _stats { int number_of_LinphoneMessageNotDelivered; int number_of_LinphoneIsComposingActiveReceived; int number_of_LinphoneIsComposingIdleReceived; + int progress_of_LinphoneFileTransfer; int number_of_IframeDecoded; diff --git a/tester/message_tester.c b/tester/message_tester.c index a9b35253a..bb18b1931 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -127,6 +127,8 @@ void file_transfer_progress_indication(LinphoneCore *lc, LinphoneChatMessage *me , content->subtype ,(linphone_chat_message_is_outgoing(message)?"to":"from") , address); + stats* counters = get_stats(lc); + counters->progress_of_LinphoneFileTransfer = progress; free(address); } @@ -380,6 +382,54 @@ static void file_transfer_message(void) { linphone_core_manager_destroy(pauline); } +static void file_transfer_message_io_error(void) { + int i; + char* to; + LinphoneChatRoom* chat_room; + LinphoneChatMessage* message; + LinphoneContent content; + const char* big_file_content="big file"; /* setting dummy file content to something */ + LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); + + /* setting dummy file content to something */ + for (i=0;ilc,"https://www.linphone.org:444/lft.php"); + + /* create a chatroom on pauline's side */ + to = linphone_address_as_string(marie->identity); + chat_room = linphone_core_create_chat_room(pauline->lc,to); + + /* create a file transfer message */ + memset(&content,0,sizeof(content)); + content.type="text"; + content.subtype="plain"; + content.size=sizeof(big_file); /*total size to be transfered*/ + content.name = "bigfile.txt"; + message = linphone_chat_room_create_file_transfer_message(chat_room, &content); + + linphone_chat_room_send_message2(chat_room,message,liblinphone_tester_chat_message_state_change,pauline->lc); + + /*wait for file to be 25% uploaded and simultate a network error*/ + CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.progress_of_LinphoneFileTransfer,25)); + sal_set_send_error(pauline->lc->sal, -1); + + CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneMessageNotDelivered,1)); + + CU_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageNotDelivered,1); + CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageExtBodyReceived,0); + + sal_set_send_error(pauline->lc->sal, 0); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + static void text_message_with_send_error(void) { LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); @@ -607,6 +657,7 @@ test_t message_tests[] = { { "Text message with send error", text_message_with_send_error }, { "Text message with external body", text_message_with_external_body }, { "File transfer message", file_transfer_message }, + { "File transfer message with io error", file_transfer_message_io_error }, { "Text message denied", text_message_denied }, { "Info message", info_message }, { "Info message with body", info_message_with_body },