/* * Call back called when a message is received */ static void message_received(LinphoneCore *lc, LinphoneChatRoom *cr, LinphoneChatMessage *msg) { const LinphoneContent *file_transfer_info = linphone_chat_message_get_file_transfer_information(msg); printf ("Do you really want to download %s (size %ld)?[Y/n]\nOk, let's go\n", linphone_content_get_name(file_transfer_info), (long int)linphone_content_get_size(file_transfer_info)); linphone_chat_message_start_file_download(msg, linphone_file_transfer_state_changed, NULL); }
static void file_transfer_message_download_cancelled(void) { #if 0 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"); reset_counters(&marie->stat); reset_counters(&pauline->stat); /* setting dummy file content to something */ for (i=0;i<sizeof(big_file);i+=strlen(big_file_content)) memcpy(big_file+i, big_file_content, strlen(big_file_content)); big_file[0]=*"S"; big_file[sizeof(big_file)-1]=*"E"; /* Globally configure an http file transfer server. */ linphone_core_set_file_transfer_server(pauline->lc,"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); { int dummy=0; wait_for_until(marie->lc,pauline->lc,&dummy,1,100); /*just to have time to purge message stored in the server*/ reset_counters(&marie->stat); reset_counters(&pauline->stat); } linphone_chat_room_send_message2(chat_room,message,liblinphone_tester_chat_message_state_change,pauline->lc); /* wait for marie to receive pauline's message */ CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,1)); if (marie->stat.last_received_chat_message ) { /* get last message and use it to download file */ linphone_chat_message_start_file_download(marie->stat.last_received_chat_message, liblinphone_tester_chat_message_state_change, marie->lc); /* wait for file to be 50% downloaded */ CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.progress_of_LinphoneFileTransfer, 50)); /* and cancel the transfer */ linphone_chat_message_cancel_file_transfer(marie->stat.last_received_chat_message); } CU_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageInProgress,1); CU_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageDelivered,1); CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageExtBodyReceived,0); CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageNotDelivered,1); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); #endif ms_error("Test skipped"); }