Fixed previous commit + added logs related to incoming message decryption process

This commit is contained in:
Sylvain Berfini 2018-02-06 14:52:31 +01:00
parent a8bdc5976d
commit 8317d3e9b9
3 changed files with 12 additions and 5 deletions

View file

@ -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)) {

View file

@ -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;
}

View file

@ -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);