From 6ee6437b21fdd0756f376367ba9447443af9509e Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 20 Dec 2016 12:38:55 +0100 Subject: [PATCH] Fix lime. --- coreapi/im_encryption_engine.c | 3 ++- coreapi/linphonecore.c | 19 +++++++++++++------ coreapi/private.h | 4 ++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/coreapi/im_encryption_engine.c b/coreapi/im_encryption_engine.c index c0afa3df5..16e7b8c09 100644 --- a/coreapi/im_encryption_engine.c +++ b/coreapi/im_encryption_engine.c @@ -67,7 +67,8 @@ void linphone_im_encryption_engine_cbs_set_user_data(LinphoneImEncryptionEngineC } LinphoneImEncryptionEngine *linphone_im_encryption_engine_new(LinphoneCore *lc) { - LinphoneImEncryptionEngine *imee = ms_new0(LinphoneImEncryptionEngine, 1); + LinphoneImEncryptionEngine *imee = belle_sip_object_new(LinphoneImEncryptionEngine); + belle_sip_object_ref(imee); imee->lc = lc; imee->callbacks = linphone_im_encryption_engine_cbs_new(); return imee; diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 41f4a2b07..c7f7c554f 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1953,12 +1953,10 @@ 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); - lc->im_encryption_engine = imee; + linphone_core_set_im_encryption_engine(lc, imee); + linphone_im_encryption_engine_unref(imee); } else { - if (lc->im_encryption_engine) { - linphone_im_encryption_engine_unref(lc->im_encryption_engine); - lc->im_encryption_engine = NULL; - } + linphone_core_set_im_encryption_engine(lc, NULL); } } @@ -5939,6 +5937,9 @@ static void linphone_core_uninit(LinphoneCore *lc) if (lc->ringtoneplayer) { linphone_ringtoneplayer_destroy(lc->ringtoneplayer); } + if (lc->im_encryption_engine) { + linphone_im_encryption_engine_unref(lc->im_encryption_engine); + } linphone_core_free_payload_types(lc); if (lc->supported_formats) ms_free((void *)lc->supported_formats); @@ -7064,7 +7065,13 @@ const char *linphone_core_get_tls_key_path(const LinphoneCore *lc) { } void linphone_core_set_im_encryption_engine(LinphoneCore *lc, LinphoneImEncryptionEngine *imee) { - lc->im_encryption_engine = imee; + if (lc->im_encryption_engine) { + linphone_im_encryption_engine_unref(lc->im_encryption_engine); + lc->im_encryption_engine = NULL; + } + if (imee) { + lc->im_encryption_engine = linphone_im_encryption_engine_ref(imee); + } } LinphoneImEncryptionEngine *linphone_core_get_im_encryption_engine(const LinphoneCore *lc) { diff --git a/coreapi/private.h b/coreapi/private.h index 94b07c3fb..5de21c116 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -1492,7 +1492,7 @@ MsZrtpCryptoTypesCount linphone_core_get_zrtp_auth_suites(LinphoneCore *lc, MSZr MsZrtpCryptoTypesCount linphone_core_get_zrtp_sas_suites(LinphoneCore *lc, MSZrtpSasType sasTypes[MS_MAX_ZRTP_CRYPTO_TYPES]); struct _LinphoneImEncryptionEngineCbs { - belle_sip_object_t *base; + belle_sip_object_t base; void *user_data; LinphoneImEncryptionEngineCbsIncomingMessageCb process_incoming_message; LinphoneImEncryptionEngineCbsOutgoingMessageCb process_outgoing_message; @@ -1507,7 +1507,7 @@ BELLE_SIP_DECLARE_VPTR(LinphoneImEncryptionEngineCbs); LinphoneImEncryptionEngineCbs * linphone_im_encryption_engine_cbs_new(void); struct _LinphoneImEncryptionEngine { - belle_sip_object_t *base; + belle_sip_object_t base; void *user_data; LinphoneCore *lc; LinphoneImEncryptionEngineCbs *callbacks;