From 868d29906ef449366ea31b72f33a04af7a9dd866 Mon Sep 17 00:00:00 2001 From: Clemence Him <clemence.him@belledonne-communications.com> Date: Wed, 12 Mar 2025 16:33:52 +0100 Subject: [PATCH] Add security alert param --- coreapi/linphonecore.c | 8 ++++++++ coreapi/private_functions.h | 17 ++++++++++++++++- src/conference/session/tone-manager.cpp | 2 ++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index decbdedfdc..89a3c8bb1b 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -8741,6 +8741,14 @@ void linphone_core_set_media_encryption_mandatory(LinphoneCore *lc, bool_t m) { linphone_config_set_int(lc->config, "sip", "media_encryption_mandatory", (int)m); } +bool_t linphone_core_security_alert_enabled(const LinphoneCore *core) { + return !!linphone_config_get_int(core->config, "misc", "security_alert", 1); +} + +void linphone_core_enable_security_alert(LinphoneCore *core, bool_t enable) { + linphone_config_get_int(core->config, "misc", "security_alert", enable); +} + bool_t linphone_core_zero_rtp_port_for_stream_inactive_enabled(const LinphoneCore *lc) { return (bool_t) !!linphone_config_get_int(lc->config, "sip", "zero_rtp_port_for_stream_inactive", 0); } diff --git a/coreapi/private_functions.h b/coreapi/private_functions.h index 8a0f4afe23..65bd713048 100644 --- a/coreapi/private_functions.h +++ b/coreapi/private_functions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2022 Belledonne Communications SARL. + * Copyright (c) 2010-2025 Belledonne Communications SARL. * * This file is part of Liblinphone * (see https://gitlab.linphone.org/BC/public/liblinphone). @@ -793,6 +793,21 @@ MsZrtpCryptoTypesCount linphone_core_get_zrtp_auth_suites(LinphoneCore *lc, MsZrtpCryptoTypesCount linphone_core_get_zrtp_sas_suites(LinphoneCore *lc, MSZrtpSasType sasTypes[MS_MAX_ZRTP_CRYPTO_TYPES]); +/** + * Tells whether the security alert feature is enabled for this #LinphoneCore object. + * By default, the security alert is enabled. + * @param core The #LinphoneCore object. @notnil + * @return TRUE if the security alert feature is enabled. + */ +bool_t linphone_core_security_alert_enabled(const LinphoneCore *core); + +/** + * Enables the security alert feature. + * @param core The #LinphoneCore object @notnil + * @param enable A boolean value telling whether to enable or disable the security alert feature. + */ +void linphone_core_enable_security_alert(LinphoneCore *core, bool_t enable); + LinphoneImEncryptionEngineCbs *linphone_im_encryption_engine_cbs_new(void); LinphoneRange *linphone_range_new(void); diff --git a/src/conference/session/tone-manager.cpp b/src/conference/session/tone-manager.cpp index 271d3251a3..d4a095afca 100644 --- a/src/conference/session/tone-manager.cpp +++ b/src/conference/session/tone-manager.cpp @@ -753,6 +753,7 @@ void ToneManager::notifyState(const std::shared_ptr<CallSession> &callSession, C } void ToneManager::notifySecurityAlert(BCTBX_UNUSED(const std::shared_ptr<CallSession> &session)) { + if (!linphone_core_security_alert_enabled(getCore().getCCore())) return; notifyToneIndication(LinphoneReasonSasCheckRequired); if (mSecurityAlertTimer) stopSecurityAlert(); mSecurityAlertTimer = getCore().createTimer( @@ -764,6 +765,7 @@ void ToneManager::notifySecurityAlert(BCTBX_UNUSED(const std::shared_ptr<CallSes } void ToneManager::stopSecurityAlert() { + if (!linphone_core_security_alert_enabled(getCore().getCCore())) return; stopTone(); if (mSecurityAlertTimer) { getCore().destroyTimer(mSecurityAlertTimer); -- GitLab