From 8317d3e9b9752f3165612a3f42751f299b61b698 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 6 Feb 2018 14:52:31 +0100 Subject: [PATCH] Fixed previous commit + added logs related to incoming message decryption process --- coreapi/chat.c | 7 ++++++- coreapi/lime.c | 6 ++++++ coreapi/linphonecore.c | 4 ---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/coreapi/chat.c b/coreapi/chat.c index bafd67912..4232b08fb 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -710,7 +710,8 @@ LinphoneReason linphone_core_message_received(LinphoneCore *lc, SalOp *op, const LinphoneImEncryptionEngineCbsIncomingMessageCb cb_process_incoming_message = linphone_im_encryption_engine_cbs_get_process_incoming_message(imee_cbs); if (cb_process_incoming_message) { retval = cb_process_incoming_message(imee, cr, msg); - if(retval == 0) { + ms_debug("Decryption done, result is %i", retval); + if (retval == 0) { msg->is_secured = TRUE; } else if(retval > 0) { // Unable to decrypt message @@ -721,7 +722,11 @@ LinphoneReason linphone_core_message_received(LinphoneCore *lc, SalOp *op, const reason = LinphoneReasonNone; goto end; } + } else { + ms_warning("IM Encryption Engine found but there is no process incoming messsage callback set..."); } + } else { + ms_debug("No IM Encryption Engine found"); } if ((retval <= 0) && (linphone_core_is_content_type_supported(lc, msg->content_type) == FALSE)) { diff --git a/coreapi/lime.c b/coreapi/lime.c index efeecf45f..984d056cd 100644 --- a/coreapi/lime.c +++ b/coreapi/lime.c @@ -793,6 +793,8 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneImEncryptionEn char *peerUri = NULL; char *selfUri = NULL; + ms_debug("Content type is known (%s), try to decrypt it", msg->content_type); + zrtp_cache_db = linphone_core_get_zrtp_cache_db(lc); if (zrtp_cache_db == NULL) { ms_warning("Unable to load content of ZRTP ZID cache to decrypt message"); @@ -817,9 +819,11 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneImEncryptionEn } msg->message = (char *)decrypted_body; if (decrypted_content_type != NULL) { + ms_debug("Decrypted content type is ", decrypted_content_type); linphone_chat_message_set_content_type(msg, decrypted_content_type); ms_free(decrypted_content_type); } else { + ms_debug("Decrypted content type is unknown, use plain/text or application/vnd.gsma.rcs-ft-http+xml"); if (strcmp("application/cipher.vnd.gsma.rcs-ft-http+xml", msg->content_type) == 0) { linphone_chat_message_set_content_type(msg, "application/vnd.gsma.rcs-ft-http+xml"); } else { @@ -827,6 +831,8 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneImEncryptionEn } } } + } else { + ms_message("Content type is unknown (%s), don't try to decrypt it", msg->content_type); } return errcode; } diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 9206f8cc0..b8a0b3f3e 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2444,15 +2444,11 @@ void linphone_core_enable_lime(LinphoneCore *lc, LinphoneLimeState val){ linphone_im_encryption_engine_cbs_set_process_uploading_file(cbs, lime_im_encryption_engine_process_uploading_file_cb); linphone_im_encryption_engine_cbs_set_is_encryption_enabled_for_file_transfer(cbs, lime_im_encryption_engine_is_file_encryption_enabled_cb); linphone_im_encryption_engine_cbs_set_generate_file_transfer_key(cbs, lime_im_encryption_engine_generate_file_transfer_key_cb); - - linphone_core_add_content_type_support(lc, "xml/cipher"); } else { linphone_im_encryption_engine_cbs_set_process_outgoing_message(cbs, NULL); linphone_im_encryption_engine_cbs_set_process_uploading_file(cbs, NULL); linphone_im_encryption_engine_cbs_set_is_encryption_enabled_for_file_transfer(cbs, NULL); linphone_im_encryption_engine_cbs_set_generate_file_transfer_key(cbs, NULL); - - linphone_core_remove_content_type_support(lc, "xml/cipher"); } linphone_core_set_im_encryption_engine(lc, imee);