diff --git a/Linphone/core/address-books/ldap/LdapCore.cpp b/Linphone/core/address-books/ldap/LdapCore.cpp index d4d91aac7..b0f7dc10c 100644 --- a/Linphone/core/address-books/ldap/LdapCore.cpp +++ b/Linphone/core/address-books/ldap/LdapCore.cpp @@ -23,20 +23,20 @@ DEFINE_ABSTRACT_OBJECT(LdapCore) -QSharedPointer LdapCore::create(const std::shared_ptr &ldap) { +QSharedPointer LdapCore::create(const std::shared_ptr &ldap) { auto sharedPointer = QSharedPointer(new LdapCore(ldap), &QObject::deleteLater); sharedPointer->setSelf(sharedPointer); sharedPointer->moveToThread(App::getInstance()->thread()); return sharedPointer; } -LdapCore::LdapCore(const std::shared_ptr &ldap) : QObject(nullptr) { +LdapCore::LdapCore(const std::shared_ptr &ldap) : QObject(nullptr) { App::getInstance()->mEngine->setObjectOwnership(this, QQmlEngine::CppOwnership); mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); mLdapModel = Utils::makeQObject_ptr(ldap); INIT_CORE_MEMBER(Enabled, mLdapModel) - INIT_CORE_MEMBER(Server, mLdapModel) + INIT_CORE_MEMBER(ServerUrl, mLdapModel) INIT_CORE_MEMBER(BindDn, mLdapModel) INIT_CORE_MEMBER(Password, mLdapModel) INIT_CORE_MEMBER(AuthMethod, mLdapModel) @@ -44,10 +44,10 @@ LdapCore::LdapCore(const std::shared_ptr &ldap) : QObject(nullpt INIT_CORE_MEMBER(ServerCertificatesVerificationMode, mLdapModel) INIT_CORE_MEMBER(BaseObject, mLdapModel) INIT_CORE_MEMBER(Filter, mLdapModel) - INIT_CORE_MEMBER(MaxResults, mLdapModel) + INIT_CORE_MEMBER(Limit, mLdapModel) INIT_CORE_MEMBER(Timeout, mLdapModel) INIT_CORE_MEMBER(Delay, mLdapModel) - INIT_CORE_MEMBER(MinChars, mLdapModel) + INIT_CORE_MEMBER(MinCharacters, mLdapModel) INIT_CORE_MEMBER(NameAttribute, mLdapModel) INIT_CORE_MEMBER(SipAttribute, mLdapModel) INIT_CORE_MEMBER(SipDomain, mLdapModel) @@ -73,7 +73,7 @@ void LdapCore::remove() { } bool LdapCore::isValid() { - return !mServer.isEmpty() && !mBaseObject.isEmpty(); + return !mServerUrl.isEmpty() && !mBaseObject.isEmpty(); } void LdapCore::setSelf(QSharedPointer me) { @@ -81,7 +81,7 @@ void LdapCore::setSelf(QSharedPointer me) { new SafeConnection(me, mLdapModel), &QObject::deleteLater); DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, bool, enabled, Enabled) - DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, QString, server, Server) + DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, QString, serverUrl, ServerUrl) DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, QString, bindDn, BindDn) DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, QString, password, Password) DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, linphone::Ldap::AuthMethod, @@ -92,10 +92,10 @@ void LdapCore::setSelf(QSharedPointer me) { ServerCertificatesVerificationMode) DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, QString, baseObject, BaseObject) DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, QString, filter, Filter) - DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, int, maxResults, MaxResults) + DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, int, limit, Limit) DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, int, timeout, Timeout) DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, int, delay, Delay) - DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, int, minChars, MinChars) + DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, int, minCharacters, MinCharacters) DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, QString, nameAttribute, NameAttribute) DEFINE_CORE_GETSET_CONNECT(mLdapModelConnection, LdapCore, LdapModel, mLdapModel, QString, sipAttribute, diff --git a/Linphone/core/address-books/ldap/LdapCore.hpp b/Linphone/core/address-books/ldap/LdapCore.hpp index bb3a3d59f..499d9da48 100644 --- a/Linphone/core/address-books/ldap/LdapCore.hpp +++ b/Linphone/core/address-books/ldap/LdapCore.hpp @@ -32,8 +32,8 @@ class LdapCore : public QObject, public AbstractObject { Q_OBJECT public: - static QSharedPointer create(const std::shared_ptr &ldap); - LdapCore(const std::shared_ptr &ldap); + static QSharedPointer create(const std::shared_ptr &ldap); + LdapCore(const std::shared_ptr &ldap); ~LdapCore(); void setSelf(QSharedPointer me); @@ -43,7 +43,7 @@ public: Q_INVOKABLE bool isValid(); DECLARE_CORE_GETSET_MEMBER(bool, enabled, Enabled) - DECLARE_CORE_GETSET_MEMBER(QString, server, Server) + DECLARE_CORE_GETSET_MEMBER(QString, serverUrl, ServerUrl) DECLARE_CORE_GETSET_MEMBER(QString, bindDn, BindDn) DECLARE_CORE_GETSET_MEMBER(QString, password, Password) DECLARE_CORE_GETSET_MEMBER(linphone::Ldap::AuthMethod, authMethod, AuthMethod) @@ -53,10 +53,10 @@ public: ServerCertificatesVerificationMode) DECLARE_CORE_GETSET_MEMBER(QString, baseObject, BaseObject) DECLARE_CORE_GETSET_MEMBER(QString, filter, Filter) - DECLARE_CORE_GETSET_MEMBER(int, maxResults, MaxResults) + DECLARE_CORE_GETSET_MEMBER(int, limit, Limit) DECLARE_CORE_GETSET_MEMBER(int, timeout, Timeout) DECLARE_CORE_GETSET_MEMBER(int, delay, Delay) - DECLARE_CORE_GETSET_MEMBER(int, minChars, MinChars) + DECLARE_CORE_GETSET_MEMBER(int, minCharacters, MinCharacters) DECLARE_CORE_GETSET_MEMBER(QString, nameAttribute, NameAttribute) DECLARE_CORE_GETSET_MEMBER(QString, sipAttribute, SipAttribute) DECLARE_CORE_GETSET_MEMBER(QString, sipDomain, SipDomain) diff --git a/Linphone/core/address-books/ldap/LdapList.cpp b/Linphone/core/address-books/ldap/LdapList.cpp index 417d64d95..374a16d79 100644 --- a/Linphone/core/address-books/ldap/LdapList.cpp +++ b/Linphone/core/address-books/ldap/LdapList.cpp @@ -36,7 +36,7 @@ QSharedPointer LdapList::create() { return model; } -QSharedPointer LdapList::createLdapCore(const std::shared_ptr &ldap) { +QSharedPointer LdapList::createLdapCore(const std::shared_ptr &ldap) { auto LdapCore = LdapCore::create(ldap); return LdapCore; } @@ -58,9 +58,11 @@ void LdapList::setSelf(QSharedPointer me) { mModelConnection->invokeToModel([this]() { QList> *ldaps = new QList>(); mustBeInLinphoneThread(getClassName()); - for (auto ldap : CoreModel::getInstance()->getCore()->getLdapList()) { - auto model = createLdapCore(ldap); - ldaps->push_back(model); + for (auto server : CoreModel::getInstance()->getCore()->getRemoteContactDirectories()) { + if (server->getType() == linphone::RemoteContactDirectory::Type::Ldap) { + auto model = createLdapCore(server); + ldaps->push_back(model); + } } mModelConnection->invokeToCore([this, ldaps]() { mustBeInMainThread(getClassName()); diff --git a/Linphone/core/address-books/ldap/LdapList.hpp b/Linphone/core/address-books/ldap/LdapList.hpp index ced6517e7..7e04a35ac 100644 --- a/Linphone/core/address-books/ldap/LdapList.hpp +++ b/Linphone/core/address-books/ldap/LdapList.hpp @@ -36,7 +36,7 @@ class LdapList : public ListProxy, public AbstractObject { public: static QSharedPointer create(); // Create a LdapCore and make connections to List. - QSharedPointer createLdapCore(const std::shared_ptr &ldap); + QSharedPointer createLdapCore(const std::shared_ptr &ldap); LdapList(QObject *parent = Q_NULLPTR); ~LdapList(); diff --git a/Linphone/core/call/CallCore.cpp b/Linphone/core/call/CallCore.cpp index ec07b72e4..6dc6d579c 100644 --- a/Linphone/core/call/CallCore.cpp +++ b/Linphone/core/call/CallCore.cpp @@ -131,7 +131,18 @@ CallCore::CallCore(const std::shared_ptr &call) : QObject(nullpt mRemoteName = Utils::coreStringToAppString( linphoneFriend->getVcard() ? linphoneFriend->getVcard()->getFullName() : linphoneFriend->getName()); if (mRemoteName.isEmpty()) mRemoteName = ToolModel::getDisplayName(mRemoteAddress); - mShouldFindRemoteLdapFriend = !linphoneFriend && !CoreModel::getInstance()->getCore()->getLdapList().empty(); + mShouldFindRemoteLdapFriend = !linphoneFriend; // + if (mShouldFindRemoteLdapFriend) { + auto servers = CoreModel::getInstance()->getCore()->getRemoteContactDirectories(); + bool haveLdap = false; + for (auto s : servers) { + if (s->getType() == linphone::RemoteContactDirectory::Type::Ldap) { + haveLdap = true; + break; + } + } + mShouldFindRemoteLdapFriend = haveLdap; + } mLocalAddress = Utils::coreStringToAppString(call->getCallLog()->getLocalAddress()->asStringUriOnly()); mStatus = LinphoneEnums::fromLinphone(call->getCallLog()->getStatus()); diff --git a/Linphone/model/address-books/ldap/LdapModel.cpp b/Linphone/model/address-books/ldap/LdapModel.cpp index 95dad431e..6ec3788f6 100644 --- a/Linphone/model/address-books/ldap/LdapModel.cpp +++ b/Linphone/model/address-books/ldap/LdapModel.cpp @@ -24,19 +24,20 @@ DEFINE_ABSTRACT_OBJECT(LdapModel) -LdapModel::LdapModel(const std::shared_ptr &ldap, QObject *parent) { +LdapModel::LdapModel(const std::shared_ptr &ldap, QObject *parent) { mustBeInLinphoneThread(getClassName()); if (ldap) { mLdap = ldap; - mLdapParamsClone = mLdap->getParams()->clone(); + mLdapParamsClone = mLdap->getLdapParams(); } else { - mLdap = nullptr; mLdapParamsClone = CoreModel::getInstance()->getCore()->createLdapParams(); - mLdapParamsClone->setTimeout(5); - mLdapParamsClone->setMaxResults(50); mLdapParamsClone->setDelay(2000); - mLdapParamsClone->setMinChars(0); // Needs to be 0 if Contacts list should be synchronized with LDAP AB mLdapParamsClone->enableTls(true); + + mLdap = CoreModel::getInstance()->getCore()->createLdapRemoteContactDirectory(mLdapParamsClone); + mLdap->setTimeout(5); + mLdap->setLimit(50); + mLdap->setMinCharacters(0); // Needs to be 0 if Contacts list should be synchronized with LDAP AB } } @@ -46,19 +47,29 @@ LdapModel::~LdapModel() { void LdapModel::save() { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); - if (mLdap) - CoreModel::getInstance()->getCore()->removeLdap( + int oldTimeout = 5; + int oldLimit = 50; + int oldMinChars = 0; + if (mLdap) { + oldTimeout = mLdap->getTimeout(); + oldLimit = mLdap->getLimit(); + oldMinChars = mLdap->getMinCharacters(); + CoreModel::getInstance()->getCore()->removeRemoteContactDirectory( mLdap); // Need to do remove/add when updating, as setParams on existing one also adds it to core. - mLdap = CoreModel::getInstance()->getCore()->createLdapWithParams(mLdapParamsClone); - CoreModel::getInstance()->getCore()->addLdap(mLdap); + } + mLdap = CoreModel::getInstance()->getCore()->createLdapRemoteContactDirectory(mLdapParamsClone); + mLdap->setTimeout(oldTimeout); + mLdap->setLimit(oldLimit); + mLdap->setMinCharacters(oldMinChars); + CoreModel::getInstance()->getCore()->addRemoteContactDirectory(mLdap); lDebug() << log().arg("LDAP Server saved"); - mLdapParamsClone = mLdap->getParams()->clone(); + mLdapParamsClone = mLdap->getLdapParams(); emit saved(); } void LdapModel::remove() { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); - CoreModel::getInstance()->getCore()->removeLdap(mLdap); + CoreModel::getInstance()->getCore()->removeRemoteContactDirectory(mLdap); lDebug() << log().arg("LDAP Server removed"); emit removed(); } @@ -77,7 +88,7 @@ void LdapModel::setDebug(bool data) { } DEFINE_GETSET(LdapModel, bool, enabled, Enabled, mLdapParamsClone) -DEFINE_GETSET_MODEL_STRING(LdapModel, server, Server, mLdapParamsClone) +DEFINE_GETSET_MODEL_STRING(LdapModel, serverUrl, ServerUrl, mLdap) DEFINE_GETSET_MODEL_STRING(LdapModel, bindDn, BindDn, mLdapParamsClone) DEFINE_GETSET_MODEL_STRING(LdapModel, password, Password, mLdapParamsClone) DEFINE_GETSET(LdapModel, linphone::Ldap::AuthMethod, authMethod, AuthMethod, mLdapParamsClone) @@ -89,10 +100,10 @@ DEFINE_GETSET(LdapModel, mLdapParamsClone) DEFINE_GETSET_MODEL_STRING(LdapModel, baseObject, BaseObject, mLdapParamsClone) DEFINE_GETSET_MODEL_STRING(LdapModel, filter, Filter, mLdapParamsClone) -DEFINE_GETSET(LdapModel, int, maxResults, MaxResults, mLdapParamsClone) -DEFINE_GETSET(LdapModel, int, timeout, Timeout, mLdapParamsClone) +DEFINE_GETSET(LdapModel, int, limit, Limit, mLdap) +DEFINE_GETSET(LdapModel, int, timeout, Timeout, mLdap) DEFINE_GETSET(LdapModel, int, delay, Delay, mLdapParamsClone) -DEFINE_GETSET(LdapModel, int, minChars, MinChars, mLdapParamsClone) +DEFINE_GETSET(LdapModel, int, minCharacters, MinCharacters, mLdap) DEFINE_GETSET_MODEL_STRING(LdapModel, nameAttribute, NameAttribute, mLdapParamsClone) DEFINE_GETSET_MODEL_STRING(LdapModel, sipAttribute, SipAttribute, mLdapParamsClone) DEFINE_GETSET_MODEL_STRING(LdapModel, sipDomain, SipDomain, mLdapParamsClone) diff --git a/Linphone/model/address-books/ldap/LdapModel.hpp b/Linphone/model/address-books/ldap/LdapModel.hpp index 97a6ce09f..47f510171 100644 --- a/Linphone/model/address-books/ldap/LdapModel.hpp +++ b/Linphone/model/address-books/ldap/LdapModel.hpp @@ -29,7 +29,7 @@ class LdapModel : public QObject, public AbstractObject { Q_OBJECT public: - LdapModel(const std::shared_ptr &ldap, QObject *parent = nullptr); + LdapModel(const std::shared_ptr &ldap, QObject *parent = nullptr); ~LdapModel(); void setDefaultParams(); @@ -37,7 +37,7 @@ public: void remove(); DECLARE_GETSET(bool, enabled, Enabled) - DECLARE_GETSET(QString, server, Server) + DECLARE_GETSET(QString, serverUrl, ServerUrl) DECLARE_GETSET(QString, bindDn, BindDn) DECLARE_GETSET(QString, password, Password) DECLARE_GETSET(linphone::Ldap::AuthMethod, authMethod, AuthMethod) @@ -47,10 +47,10 @@ public: ServerCertificatesVerificationMode) DECLARE_GETSET(QString, baseObject, BaseObject) DECLARE_GETSET(QString, filter, Filter) - DECLARE_GETSET(int, maxResults, MaxResults) + DECLARE_GETSET(int, limit, Limit) DECLARE_GETSET(int, timeout, Timeout) DECLARE_GETSET(int, delay, Delay) - DECLARE_GETSET(int, minChars, MinChars) + DECLARE_GETSET(int, minCharacters, MinCharacters) DECLARE_GETSET(QString, nameAttribute, NameAttribute) DECLARE_GETSET(QString, sipAttribute, SipAttribute) DECLARE_GETSET(QString, sipDomain, SipDomain) @@ -61,7 +61,7 @@ signals: void removed(); private: - std::shared_ptr mLdap; + std::shared_ptr mLdap; std::shared_ptr mLdapParamsClone; DECLARE_ABSTRACT_OBJECT diff --git a/Linphone/view/Page/Layout/Settings/ContactsSettingsLayout.qml b/Linphone/view/Page/Layout/Settings/ContactsSettingsLayout.qml index d03e1a990..8c0c2fb8f 100644 --- a/Linphone/view/Page/Layout/Settings/ContactsSettingsLayout.qml +++ b/Linphone/view/Page/Layout/Settings/ContactsSettingsLayout.qml @@ -42,7 +42,7 @@ AbstractSettingsLayout { newItemGui: createGuiObject('Ldap') settingsLayout: layoutUrl("LdapSettingsLayout") owner: mainItem - titleProperty: "server" + titleProperty: "serverUrl" supportsEnableDisable: true showAddButton: true } diff --git a/Linphone/view/Page/Layout/Settings/LdapSettingsLayout.qml b/Linphone/view/Page/Layout/Settings/LdapSettingsLayout.qml index 27179def9..e1cfd3d89 100644 --- a/Linphone/view/Page/Layout/Settings/LdapSettingsLayout.qml +++ b/Linphone/view/Page/Layout/Settings/LdapSettingsLayout.qml @@ -76,7 +76,7 @@ AbstractSettingsLayout { Layout.leftMargin: 64 * DefaultStyle.dp DecoratedTextField { id: server - propertyName: "server" + propertyName: "serverUrl" propertyOwner: ldapGui.core title: qsTr("URL du serveur (ne peut être vide)") toValidate: true @@ -117,7 +117,7 @@ AbstractSettingsLayout { Layout.fillWidth: true } DecoratedTextField { - propertyName: "maxResults" + propertyName: "limit" propertyOwner: ldapGui.core validator: RegularExpressionValidator { regularExpression: /[0-9]+/ } title: qsTr("Nombre maximum de résultats") @@ -141,7 +141,7 @@ AbstractSettingsLayout { Layout.fillWidth: true } DecoratedTextField { - propertyName: "minChars" + propertyName: "minCharacters" propertyOwner: ldapGui.core title: qsTr("Nombre minimum de caractères pour la requête") validator: RegularExpressionValidator { regularExpression: /[0-9]+/ } diff --git a/external/linphone-sdk b/external/linphone-sdk index 4e2af5b43..b9b42aff8 160000 --- a/external/linphone-sdk +++ b/external/linphone-sdk @@ -1 +1 @@ -Subproject commit 4e2af5b435cb7fd6aadc9cd2b7eb45ba547cf5e8 +Subproject commit b9b42aff89f650a5a1bd67d45bddb7dcc1b60481