mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 03:18:07 +00:00
Fix deprecated LDAP API.
This commit is contained in:
parent
de2612b40e
commit
ea2612acbb
10 changed files with 70 additions and 46 deletions
|
|
@ -23,20 +23,20 @@
|
|||
|
||||
DEFINE_ABSTRACT_OBJECT(LdapCore)
|
||||
|
||||
QSharedPointer<LdapCore> LdapCore::create(const std::shared_ptr<linphone::Ldap> &ldap) {
|
||||
QSharedPointer<LdapCore> LdapCore::create(const std::shared_ptr<linphone::RemoteContactDirectory> &ldap) {
|
||||
auto sharedPointer = QSharedPointer<LdapCore>(new LdapCore(ldap), &QObject::deleteLater);
|
||||
sharedPointer->setSelf(sharedPointer);
|
||||
sharedPointer->moveToThread(App::getInstance()->thread());
|
||||
return sharedPointer;
|
||||
}
|
||||
|
||||
LdapCore::LdapCore(const std::shared_ptr<linphone::Ldap> &ldap) : QObject(nullptr) {
|
||||
LdapCore::LdapCore(const std::shared_ptr<linphone::RemoteContactDirectory> &ldap) : QObject(nullptr) {
|
||||
App::getInstance()->mEngine->setObjectOwnership(this, QQmlEngine::CppOwnership);
|
||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||
mLdapModel = Utils::makeQObject_ptr<LdapModel>(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<linphone::Ldap> &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<LdapCore> me) {
|
||||
|
|
@ -81,7 +81,7 @@ void LdapCore::setSelf(QSharedPointer<LdapCore> me) {
|
|||
new SafeConnection<LdapCore, LdapModel>(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<LdapCore> 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,
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ class LdapCore : public QObject, public AbstractObject {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static QSharedPointer<LdapCore> create(const std::shared_ptr<linphone::Ldap> &ldap);
|
||||
LdapCore(const std::shared_ptr<linphone::Ldap> &ldap);
|
||||
static QSharedPointer<LdapCore> create(const std::shared_ptr<linphone::RemoteContactDirectory> &ldap);
|
||||
LdapCore(const std::shared_ptr<linphone::RemoteContactDirectory> &ldap);
|
||||
~LdapCore();
|
||||
|
||||
void setSelf(QSharedPointer<LdapCore> 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)
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ QSharedPointer<LdapList> LdapList::create() {
|
|||
return model;
|
||||
}
|
||||
|
||||
QSharedPointer<LdapCore> LdapList::createLdapCore(const std::shared_ptr<linphone::Ldap> &ldap) {
|
||||
QSharedPointer<LdapCore> LdapList::createLdapCore(const std::shared_ptr<linphone::RemoteContactDirectory> &ldap) {
|
||||
auto LdapCore = LdapCore::create(ldap);
|
||||
return LdapCore;
|
||||
}
|
||||
|
|
@ -58,9 +58,11 @@ void LdapList::setSelf(QSharedPointer<LdapList> me) {
|
|||
mModelConnection->invokeToModel([this]() {
|
||||
QList<QSharedPointer<LdapCore>> *ldaps = new QList<QSharedPointer<LdapCore>>();
|
||||
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());
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class LdapList : public ListProxy, public AbstractObject {
|
|||
public:
|
||||
static QSharedPointer<LdapList> create();
|
||||
// Create a LdapCore and make connections to List.
|
||||
QSharedPointer<LdapCore> createLdapCore(const std::shared_ptr<linphone::Ldap> &ldap);
|
||||
QSharedPointer<LdapCore> createLdapCore(const std::shared_ptr<linphone::RemoteContactDirectory> &ldap);
|
||||
LdapList(QObject *parent = Q_NULLPTR);
|
||||
~LdapList();
|
||||
|
||||
|
|
|
|||
|
|
@ -131,7 +131,18 @@ CallCore::CallCore(const std::shared_ptr<linphone::Call> &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());
|
||||
|
||||
|
|
|
|||
|
|
@ -24,19 +24,20 @@
|
|||
|
||||
DEFINE_ABSTRACT_OBJECT(LdapModel)
|
||||
|
||||
LdapModel::LdapModel(const std::shared_ptr<linphone::Ldap> &ldap, QObject *parent) {
|
||||
LdapModel::LdapModel(const std::shared_ptr<linphone::RemoteContactDirectory> &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)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class LdapModel : public QObject, public AbstractObject {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LdapModel(const std::shared_ptr<linphone::Ldap> &ldap, QObject *parent = nullptr);
|
||||
LdapModel(const std::shared_ptr<linphone::RemoteContactDirectory> &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<linphone::Ldap> mLdap;
|
||||
std::shared_ptr<linphone::RemoteContactDirectory> mLdap;
|
||||
std::shared_ptr<linphone::LdapParams> mLdapParamsClone;
|
||||
|
||||
DECLARE_ABSTRACT_OBJECT
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ AbstractSettingsLayout {
|
|||
newItemGui: createGuiObject('Ldap')
|
||||
settingsLayout: layoutUrl("LdapSettingsLayout")
|
||||
owner: mainItem
|
||||
titleProperty: "server"
|
||||
titleProperty: "serverUrl"
|
||||
supportsEnableDisable: true
|
||||
showAddButton: true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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]+/ }
|
||||
|
|
|
|||
2
external/linphone-sdk
vendored
2
external/linphone-sdk
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit 4e2af5b435cb7fd6aadc9cd2b7eb45ba547cf5e8
|
||||
Subproject commit b9b42aff89f650a5a1bd67d45bddb7dcc1b60481
|
||||
Loading…
Add table
Reference in a new issue