mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 19:18:06 +00:00
Fixes + tests for external body URL
This commit is contained in:
parent
166b0a5d62
commit
3fd55c4a2b
4 changed files with 58 additions and 3 deletions
|
|
@ -113,7 +113,12 @@ const LinphoneAddress *linphone_chat_room_get_local_address (LinphoneChatRoom *c
|
|||
}
|
||||
|
||||
LinphoneChatMessage *linphone_chat_room_create_message (LinphoneChatRoom *cr, const char *message) {
|
||||
shared_ptr<LinphonePrivate::ChatMessage> cppPtr = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->createChatMessage(L_C_TO_STRING(message));
|
||||
shared_ptr<LinphonePrivate::ChatMessage> cppPtr;
|
||||
if (message && strlen(message) > 0) {
|
||||
cppPtr = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->createChatMessage(L_C_TO_STRING(message));
|
||||
} else {
|
||||
cppPtr = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->createChatMessage();
|
||||
}
|
||||
LinphoneChatMessage *object = L_INIT(ChatMessage);
|
||||
L_SET_CPP_PTR_FROM_C_OBJECT(object, cppPtr);
|
||||
return object;
|
||||
|
|
|
|||
|
|
@ -722,7 +722,7 @@ void ChatMessagePrivate::send () {
|
|||
if (internalContent.isEmpty()) {
|
||||
if (contents.size() > 0) {
|
||||
internalContent = *(contents.front());
|
||||
} else if (!externalBodyUrl.empty()) { // When using external body url, there is no content
|
||||
} else if (externalBodyUrl.empty()) { // When using external body url, there is no content
|
||||
lError() << "Trying to send a message without any content !";
|
||||
return;
|
||||
}
|
||||
|
|
@ -730,7 +730,7 @@ void ChatMessagePrivate::send () {
|
|||
|
||||
auto msgOp = dynamic_cast<SalMessageOpInterface *>(op);
|
||||
if (!externalBodyUrl.empty()) {
|
||||
char *content_type = ms_strdup_printf("message/external-body; access-type=URL; URL=\"%s\"", externalBodyUrl);
|
||||
char *content_type = ms_strdup_printf("message/external-body; access-type=URL; URL=\"%s\"", externalBodyUrl.c_str());
|
||||
msgOp->send_message(content_type, NULL);
|
||||
ms_free(content_type);
|
||||
} else if (internalContent.getContentType().isValid()) {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "chat/chat-room/chat-room-p.h"
|
||||
#include "core/core-p.h"
|
||||
#include "sip-tools/sip-headers.h"
|
||||
#include "logger/logger.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
|
|
@ -194,6 +195,7 @@ LinphoneReason ChatRoomPrivate::onSipMessageReceived (SalOp *op, const SalMessag
|
|||
|
||||
Content content;
|
||||
if (message->url && strcmp(message->content_type, ContentType::ExternalBody.asString().c_str()) == 0) {
|
||||
lInfo() << "Received a message with an external body URL " << message->url;
|
||||
content.setContentType(ContentType::FileTransfer);
|
||||
content.setBody(msg->getPrivate()->createFakeFileTransferFromUrl(message->url));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -730,6 +730,52 @@ static void file_transfer_2_messages_simultaneously(void) {
|
|||
}
|
||||
}
|
||||
|
||||
static void file_transfer_external_body_url(bool_t use_file_body_handler_in_download) {
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc");
|
||||
LinphoneChatRoom* chat_room = linphone_core_get_chat_room(marie->lc, pauline->identity);
|
||||
LinphoneChatMessage* msg = linphone_chat_room_create_message(chat_room, NULL);
|
||||
LinphoneChatMessageCbs *cbs = linphone_chat_message_get_callbacks(msg);
|
||||
char *receive_filepath = bc_tester_file("receive_file.dump");
|
||||
|
||||
linphone_chat_message_set_external_body_url(msg, "https://www.linphone.org/img/linphone-open-source-voip-projectX2.png");
|
||||
linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed);
|
||||
linphone_chat_room_send_chat_message(chat_room, msg);
|
||||
linphone_chat_message_unref(msg);
|
||||
|
||||
BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneMessageReceivedWithFile, 1, 60000));
|
||||
|
||||
if (pauline->stat.last_received_chat_message) {
|
||||
LinphoneChatMessage *recv_msg = pauline->stat.last_received_chat_message;
|
||||
cbs = linphone_chat_message_get_callbacks(recv_msg);
|
||||
linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed);
|
||||
linphone_chat_message_cbs_set_file_transfer_recv(cbs, file_transfer_received);
|
||||
linphone_chat_message_cbs_set_file_transfer_progress_indication(cbs, file_transfer_progress_indication);
|
||||
if (use_file_body_handler_in_download) {
|
||||
/* Remove any previously downloaded file */
|
||||
remove(receive_filepath);
|
||||
linphone_chat_message_set_file_transfer_filepath(recv_msg, receive_filepath);
|
||||
}
|
||||
linphone_chat_message_download_file(recv_msg);
|
||||
|
||||
/* wait for a long time in case the DNS SRV resolution takes times - it should be immediate though */
|
||||
BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneFileTransferDownloadSuccessful, 1, 55000));
|
||||
}
|
||||
|
||||
remove(receive_filepath);
|
||||
bc_free(receive_filepath);
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
||||
static void file_transfer_using_external_body_url(void) {
|
||||
file_transfer_external_body_url(FALSE);
|
||||
}
|
||||
|
||||
static void file_transfer_using_external_body_url_2(void) {
|
||||
file_transfer_external_body_url(TRUE);
|
||||
}
|
||||
|
||||
static void text_message_denied(void) {
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc");
|
||||
|
|
@ -2439,6 +2485,8 @@ test_t message_tests[] = {
|
|||
TEST_NO_TAG("Transfer message upload cancelled", transfer_message_upload_cancelled),
|
||||
TEST_NO_TAG("Transfer message download cancelled", transfer_message_download_cancelled),
|
||||
TEST_NO_TAG("Transfer 2 messages simultaneously", file_transfer_2_messages_simultaneously),
|
||||
TEST_NO_TAG("Transfer using external body URL", file_transfer_using_external_body_url),
|
||||
TEST_NO_TAG("Transfer using external body URL 2", file_transfer_using_external_body_url_2),
|
||||
TEST_NO_TAG("Text message denied", text_message_denied),
|
||||
TEST_NO_TAG("IsComposing notification", is_composing_notification),
|
||||
TEST_NO_TAG("IMDN notifications", imdn_notifications),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue