From 6833dd10d2fd14219d4da2e2dec9c6c9834225fc Mon Sep 17 00:00:00 2001 From: Christophe Deschamps <christophe.deschamps@belledonne-communications.com> Date: Fri, 10 Jan 2025 12:17:18 +0100 Subject: [PATCH] Option to control Ldap Friend cache clearing --- Linphone/model/core/CoreModel.cpp | 10 ++++++---- Linphone/model/setting/SettingsModel.cpp | 9 +++++++++ Linphone/model/setting/SettingsModel.hpp | 2 ++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Linphone/model/core/CoreModel.cpp b/Linphone/model/core/CoreModel.cpp index 6d3615dbc..63adb90a5 100644 --- a/Linphone/model/core/CoreModel.cpp +++ b/Linphone/model/core/CoreModel.cpp @@ -96,10 +96,12 @@ void CoreModel::start() { mCore->setUserAgent(Utils::appStringToCoreString(userAgent), LINPHONESDK_VERSION); mCore->start(); setPathAfterStart(); - // Remove ldap friends cache list. If not, old stored friends will take priority on merge and will not be updated - // from new LDAP requests.. - auto ldapFriendList = mCore->getFriendListByName("ldap_friends"); - if (ldapFriendList) mCore->removeFriendList(ldapFriendList); + if (SettingsModel::clearLocalLdapFriendsUponStartup(config)) { + // Remove ldap friends cache list. If not, old stored friends will take priority on merge and will not be + // updated from new LDAP requests.. + auto ldapFriendList = mCore->getFriendListByName("ldap_friends"); + if (ldapFriendList) mCore->removeFriendList(ldapFriendList); + } mCore->enableFriendListSubscription(true); // TODO : get this from settings auto videoPolicy = mCore->getVideoActivationPolicy()->clone(); diff --git a/Linphone/model/setting/SettingsModel.cpp b/Linphone/model/setting/SettingsModel.cpp index 035751c39..5e50e72f4 100644 --- a/Linphone/model/setting/SettingsModel.cpp +++ b/Linphone/model/setting/SettingsModel.cpp @@ -603,6 +603,15 @@ QString SettingsModel::getDeviceName(const std::shared_ptr<linphone::Config> &co config->getString(UiSection, "device_name", Utils::appStringToCoreString(QSysInfo::machineHostName()))); } +// ============================================================================== +// Clears the local "ldap_friends" friend list upon startup (Ldap contacts cache) +// ============================================================================== + +bool SettingsModel::clearLocalLdapFriendsUponStartup(const shared_ptr<linphone::Config> &config) { + mustBeInLinphoneThread(sLog().arg(Q_FUNC_INFO)); + return config ? config->getBool(UiSection, "clear_local_ldap_friends_upon_startup", false) : false; +} + // ============================================================================= // Ui. // ============================================================================= diff --git a/Linphone/model/setting/SettingsModel.hpp b/Linphone/model/setting/SettingsModel.hpp index 228fabc4d..31a5badb7 100644 --- a/Linphone/model/setting/SettingsModel.hpp +++ b/Linphone/model/setting/SettingsModel.hpp @@ -143,6 +143,8 @@ public: static QString getDeviceName(const std::shared_ptr<linphone::Config> &config); + static bool clearLocalLdapFriendsUponStartup(const std::shared_ptr<linphone::Config> &config); + // UI DECLARE_GETSET(bool, disableChatFeature, DisableChatFeature) DECLARE_GETSET(bool, disableMeetingsFeature, DisableMeetingsFeature) -- GitLab