diff --git a/src/chat/chat-message.cpp b/src/chat/chat-message.cpp index a500464d6..8c673c9bb 100644 --- a/src/chat/chat-message.cpp +++ b/src/chat/chat-message.cpp @@ -1116,6 +1116,7 @@ void ChatMessagePrivate::send() { q->store(); return; } else if (result == ChatMessageModifier::Result::Suspended) { + currentSendStep |= ChatMessagePrivate::Step::Encryption; return; } currentSendStep |= ChatMessagePrivate::Step::Encryption; diff --git a/tester/message_tester.c b/tester/message_tester.c index 1e93ca046..6aa7cf4ed 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -23,6 +23,7 @@ #include "lime.h" #include "bctoolbox/crypto.h" #include +#include "linphone/core_utils.h" #include #ifdef SQLITE_STORAGE_ENABLED @@ -2394,7 +2395,26 @@ static int im_encryption_engine_process_outgoing_message_cb(LinphoneImEncryption return -1; } -void im_encryption_engine_b64(void) { +static bool_t im_encryption_engine_process_outgoing_message_async_impl(LinphoneChatMessage** msg) { + if (*msg) { + im_encryption_engine_process_outgoing_message_cb(NULL,NULL,*msg); + linphone_chat_room_send_chat_message(linphone_chat_message_get_chat_room(*msg), *msg); + linphone_chat_message_unref(*msg); + *msg=NULL; + } + return TRUE; +} + +static LinphoneChatMessage* pending_message=NULL; /*limited to one message at a time */ + +static int im_encryption_engine_process_outgoing_message_async(LinphoneImEncryptionEngine *engine, LinphoneChatRoom *room, LinphoneChatMessage *msg) { + pending_message=msg; + linphone_chat_message_ref(pending_message); + linphone_core_add_iterate_hook(linphone_chat_room_get_core(room), (LinphoneCoreIterateHook)im_encryption_engine_process_outgoing_message_async_impl,&pending_message); + return 1;/*temporaly code to defer message sending*/ +} + +void im_encryption_engine_b64_base(bool_t async) { LinphoneChatMessage *chat_msg = NULL; LinphoneChatRoom* chat_room = NULL; LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); @@ -2407,7 +2427,11 @@ void im_encryption_engine_b64(void) { linphone_im_encryption_engine_cbs_set_process_incoming_message(marie_cbs, im_encryption_engine_process_incoming_message_cb); linphone_im_encryption_engine_cbs_set_process_outgoing_message(marie_cbs, im_encryption_engine_process_outgoing_message_cb); linphone_im_encryption_engine_cbs_set_process_incoming_message(pauline_cbs, im_encryption_engine_process_incoming_message_cb); - linphone_im_encryption_engine_cbs_set_process_outgoing_message(pauline_cbs, im_encryption_engine_process_outgoing_message_cb); + if (async) { + linphone_im_encryption_engine_cbs_set_process_outgoing_message(pauline_cbs, im_encryption_engine_process_outgoing_message_async); + } else { + linphone_im_encryption_engine_cbs_set_process_outgoing_message(pauline_cbs, im_encryption_engine_process_outgoing_message_cb); + } linphone_core_set_im_encryption_engine(marie->lc, marie_imee); linphone_core_set_im_encryption_engine(pauline->lc, pauline_imee); @@ -2428,6 +2452,14 @@ void im_encryption_engine_b64(void) { linphone_core_manager_destroy(pauline); } +void im_encryption_engine_b64(void) { + im_encryption_engine_b64_base(FALSE); +} + +void im_encryption_engine_b64_async(void) { + im_encryption_engine_b64_base(TRUE); +} + test_t message_tests[] = { TEST_NO_TAG("Text message", text_message), TEST_NO_TAG("Text message within call dialog", text_message_within_call_dialog), @@ -2504,7 +2536,8 @@ test_t message_tests[] = { #ifdef SQLITE_STORAGE_ENABLED TEST_ONE_TAG("Text message with custom content-type and lime", text_message_with_custom_content_type_and_lime, "LIME"), #endif - TEST_NO_TAG("IM Encryption Engine b64", im_encryption_engine_b64) + TEST_NO_TAG("IM Encryption Engine b64", im_encryption_engine_b64), + TEST_NO_TAG("IM Encryption Engine b64 async", im_encryption_engine_b64_async) }; static int message_tester_before_suite(void) {