From 40137bcf26b393681f2bdfe734f8e997ae8261e4 Mon Sep 17 00:00:00 2001 From: Christophe Deschamps Date: Wed, 6 Nov 2024 19:10:51 +0100 Subject: [PATCH] Ldap debug option --- Linphone/core/address-books/ldap/LdapCore.cpp | 9 ++++----- Linphone/core/address-books/ldap/LdapCore.hpp | 2 +- Linphone/model/address-books/ldap/LdapModel.cpp | 14 +++++++++++++- Linphone/model/address-books/ldap/LdapModel.hpp | 2 +- .../Page/Layout/Settings/LdapSettingsLayout.qml | 5 +++++ 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Linphone/core/address-books/ldap/LdapCore.cpp b/Linphone/core/address-books/ldap/LdapCore.cpp index 0e08a780e..c16ce609d 100644 --- a/Linphone/core/address-books/ldap/LdapCore.cpp +++ b/Linphone/core/address-books/ldap/LdapCore.cpp @@ -51,7 +51,7 @@ LdapCore::LdapCore(const std::shared_ptr &ldap) : QObject(nullpt INIT_CORE_MEMBER(NameAttribute, mLdapModel) INIT_CORE_MEMBER(SipAttribute, mLdapModel) INIT_CORE_MEMBER(SipDomain, mLdapModel) - INIT_CORE_MEMBER(DebugLevel, mLdapModel) + INIT_CORE_MEMBER(Debug, mLdapModel) } LdapCore::~LdapCore() { @@ -101,13 +101,12 @@ void LdapCore::setSelf(QSharedPointer me) { DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, QString, sipAttribute, SipAttribute) DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, QString, sipDomain, SipDomain) - DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, linphone::Ldap::DebugLevel, - debugLevel, DebugLevel) + DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, bool, debug, Debug) mLdapModelConnection->makeConnectToModel(&LdapModel::saved, [this]() { - mLdapModelConnection->invokeToCore([this]() { emit App::getInstance()->getSettings()->ldapConfigChanged(); }); + mLdapModelConnection->invokeToCore([this]() { emit App::getInstance() -> getSettings()->ldapConfigChanged(); }); }); mLdapModelConnection->makeConnectToModel(&LdapModel::removed, [this]() { - mLdapModelConnection->invokeToCore([this]() { emit App::getInstance()->getSettings()->ldapConfigChanged(); }); + mLdapModelConnection->invokeToCore([this]() { emit App::getInstance() -> getSettings()->ldapConfigChanged(); }); }); } diff --git a/Linphone/core/address-books/ldap/LdapCore.hpp b/Linphone/core/address-books/ldap/LdapCore.hpp index b07d21ad2..bb3a3d59f 100644 --- a/Linphone/core/address-books/ldap/LdapCore.hpp +++ b/Linphone/core/address-books/ldap/LdapCore.hpp @@ -60,7 +60,7 @@ public: DECLARE_CORE_GETSET_MEMBER(QString, nameAttribute, NameAttribute) DECLARE_CORE_GETSET_MEMBER(QString, sipAttribute, SipAttribute) DECLARE_CORE_GETSET_MEMBER(QString, sipDomain, SipDomain) - DECLARE_CORE_GETSET_MEMBER(linphone::Ldap::DebugLevel, debugLevel, DebugLevel) + DECLARE_CORE_GETSET_MEMBER(bool, debug, Debug) private: std::shared_ptr mLdapModel; diff --git a/Linphone/model/address-books/ldap/LdapModel.cpp b/Linphone/model/address-books/ldap/LdapModel.cpp index 9fdd57435..95dad431e 100644 --- a/Linphone/model/address-books/ldap/LdapModel.cpp +++ b/Linphone/model/address-books/ldap/LdapModel.cpp @@ -63,6 +63,19 @@ void LdapModel::remove() { emit removed(); } +bool LdapModel::getDebug() const { + mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); + return mLdapParamsClone->getDebugLevel() == linphone::Ldap::DebugLevel::Verbose; +} +void LdapModel::setDebug(bool data) { + mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); + if (getDebug() != data) { + mLdapParamsClone->setDebugLevel(data ? linphone::Ldap::DebugLevel::Verbose : linphone::Ldap::DebugLevel::Off); + save(); + emit debugChanged(data); + } +} + DEFINE_GETSET(LdapModel, bool, enabled, Enabled, mLdapParamsClone) DEFINE_GETSET_MODEL_STRING(LdapModel, server, Server, mLdapParamsClone) DEFINE_GETSET_MODEL_STRING(LdapModel, bindDn, BindDn, mLdapParamsClone) @@ -83,4 +96,3 @@ DEFINE_GETSET(LdapModel, int, minChars, MinChars, mLdapParamsClone) DEFINE_GETSET_MODEL_STRING(LdapModel, nameAttribute, NameAttribute, mLdapParamsClone) DEFINE_GETSET_MODEL_STRING(LdapModel, sipAttribute, SipAttribute, mLdapParamsClone) DEFINE_GETSET_MODEL_STRING(LdapModel, sipDomain, SipDomain, mLdapParamsClone) -DEFINE_GETSET(LdapModel, linphone::Ldap::DebugLevel, debugLevel, DebugLevel, mLdapParamsClone) diff --git a/Linphone/model/address-books/ldap/LdapModel.hpp b/Linphone/model/address-books/ldap/LdapModel.hpp index e1e0d5138..97a6ce09f 100644 --- a/Linphone/model/address-books/ldap/LdapModel.hpp +++ b/Linphone/model/address-books/ldap/LdapModel.hpp @@ -54,7 +54,7 @@ public: DECLARE_GETSET(QString, nameAttribute, NameAttribute) DECLARE_GETSET(QString, sipAttribute, SipAttribute) DECLARE_GETSET(QString, sipDomain, SipDomain) - DECLARE_GETSET(linphone::Ldap::DebugLevel, debugLevel, DebugLevel) + DECLARE_GETSET(bool, debug, Debug) signals: void saved(); diff --git a/Linphone/view/Page/Layout/Settings/LdapSettingsLayout.qml b/Linphone/view/Page/Layout/Settings/LdapSettingsLayout.qml index 17e218cba..606b3f512 100644 --- a/Linphone/view/Page/Layout/Settings/LdapSettingsLayout.qml +++ b/Linphone/view/Page/Layout/Settings/LdapSettingsLayout.qml @@ -176,6 +176,11 @@ AbstractSettingsLayout { title: qsTr("Domaine SIP") toValidate: true } + SwitchSetting { + titleText: qsTr("Débogage") + propertyName: "debug" + propertyOwner: ldapGui.core + } } } }