Commit 80a76ef4 authored by Laurent Montel's avatar Laurent Montel 😁

Coding style

parent de1fb3cb
...@@ -37,12 +37,13 @@ class KLDAP::AddHostDialogPrivate ...@@ -37,12 +37,13 @@ class KLDAP::AddHostDialogPrivate
{ {
public: public:
AddHostDialogPrivate(AddHostDialog *qq) AddHostDialogPrivate(AddHostDialog *qq)
: mCfg(nullptr), : mCfg(nullptr)
mServer(nullptr), , mServer(nullptr)
mOkButton(nullptr), , mOkButton(nullptr)
q(qq) , q(qq)
{ {
} }
~AddHostDialogPrivate() ~AddHostDialogPrivate()
{ {
writeConfig(); writeConfig();
...@@ -73,8 +74,8 @@ void AddHostDialogPrivate::writeConfig() ...@@ -73,8 +74,8 @@ void AddHostDialogPrivate::writeConfig()
} }
AddHostDialog::AddHostDialog(KLDAP::LdapServer *server, QWidget *parent) AddHostDialog::AddHostDialog(KLDAP::LdapServer *server, QWidget *parent)
: QDialog(parent), : QDialog(parent)
d(new KLDAP::AddHostDialogPrivate(this)) , d(new KLDAP::AddHostDialogPrivate(this))
{ {
setWindowTitle(i18n("Add Host")); setWindowTitle(i18n("Add Host"));
QVBoxLayout *mainLayout = new QVBoxLayout(this); QVBoxLayout *mainLayout = new QVBoxLayout(this);
...@@ -95,20 +96,20 @@ AddHostDialog::AddHostDialog(KLDAP::LdapServer *server, QWidget *parent) ...@@ -95,20 +96,20 @@ AddHostDialog::AddHostDialog(KLDAP::LdapServer *server, QWidget *parent)
layout->setMargin(0); layout->setMargin(0);
d->mCfg = new KLDAP::LdapConfigWidget( d->mCfg = new KLDAP::LdapConfigWidget(
KLDAP::LdapConfigWidget::W_USER | KLDAP::LdapConfigWidget::W_USER
KLDAP::LdapConfigWidget::W_PASS | |KLDAP::LdapConfigWidget::W_PASS
KLDAP::LdapConfigWidget::W_BINDDN | |KLDAP::LdapConfigWidget::W_BINDDN
KLDAP::LdapConfigWidget::W_REALM | |KLDAP::LdapConfigWidget::W_REALM
KLDAP::LdapConfigWidget::W_HOST | |KLDAP::LdapConfigWidget::W_HOST
KLDAP::LdapConfigWidget::W_PORT | |KLDAP::LdapConfigWidget::W_PORT
KLDAP::LdapConfigWidget::W_VER | |KLDAP::LdapConfigWidget::W_VER
KLDAP::LdapConfigWidget::W_TIMELIMIT | |KLDAP::LdapConfigWidget::W_TIMELIMIT
KLDAP::LdapConfigWidget::W_SIZELIMIT | |KLDAP::LdapConfigWidget::W_SIZELIMIT
KLDAP::LdapConfigWidget::W_PAGESIZE | |KLDAP::LdapConfigWidget::W_PAGESIZE
KLDAP::LdapConfigWidget::W_DN | |KLDAP::LdapConfigWidget::W_DN
KLDAP::LdapConfigWidget::W_FILTER | |KLDAP::LdapConfigWidget::W_FILTER
KLDAP::LdapConfigWidget::W_SECBOX | |KLDAP::LdapConfigWidget::W_SECBOX
KLDAP::LdapConfigWidget::W_AUTHBOX, |KLDAP::LdapConfigWidget::W_AUTHBOX,
page); page);
layout->addWidget(d->mCfg); layout->addWidget(d->mCfg);
......
...@@ -25,8 +25,7 @@ ...@@ -25,8 +25,7 @@
#include "kdepim_export.h" #include "kdepim_export.h"
#include <qdialog.h> #include <qdialog.h>
namespace KLDAP namespace KLDAP {
{
class LdapServer; class LdapServer;
class AddHostDialogPrivate; class AddHostDialogPrivate;
class KDEPIM_EXPORT AddHostDialog : public QDialog class KDEPIM_EXPORT AddHostDialog : public QDialog
...@@ -47,7 +46,6 @@ private Q_SLOTS: ...@@ -47,7 +46,6 @@ private Q_SLOTS:
private: private:
AddHostDialogPrivate *const d; AddHostDialogPrivate *const d;
}; };
} }
#endif // ADDHOSTDIALOG_H #endif // ADDHOSTDIALOG_H
...@@ -46,14 +46,15 @@ ...@@ -46,14 +46,15 @@
#include "addhostdialog.h" #include "addhostdialog.h"
K_PLUGIN_FACTORY_WITH_JSON(KCMLdapFactory, "kcmldap.json", registerPlugin<KCMLdap>();) K_PLUGIN_FACTORY_WITH_JSON(KCMLdapFactory, "kcmldap.json", registerPlugin<KCMLdap>();
)
class LDAPItem : public QListWidgetItem class LDAPItem : public QListWidgetItem
{ {
public: public:
LDAPItem(QListWidget *parent, const KLDAP::LdapServer &server, bool isActive = false) LDAPItem(QListWidget *parent, const KLDAP::LdapServer &server, bool isActive = false)
: QListWidgetItem(parent, QListWidgetItem::UserType), : QListWidgetItem(parent, QListWidgetItem::UserType)
mIsActive(isActive) , mIsActive(isActive)
{ {
setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable); setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
setCheckState(isActive ? Qt::Checked : Qt::Unchecked); setCheckState(isActive ? Qt::Checked : Qt::Unchecked);
...@@ -76,6 +77,7 @@ public: ...@@ -76,6 +77,7 @@ public:
{ {
mIsActive = isActive; mIsActive = isActive;
} }
bool isActive() const bool isActive() const
{ {
return mIsActive; return mIsActive;
......
...@@ -30,8 +30,7 @@ class QListWidgetItem; ...@@ -30,8 +30,7 @@ class QListWidgetItem;
class QPushButton; class QPushButton;
class QToolButton; class QToolButton;
namespace KLDAP namespace KLDAP {
{
class LdapClientSearchConfig; class LdapClientSearchConfig;
} }
......
...@@ -39,10 +39,10 @@ class Q_DECL_HIDDEN LdapClient::Private ...@@ -39,10 +39,10 @@ class Q_DECL_HIDDEN LdapClient::Private
{ {
public: public:
Private(LdapClient *qq) Private(LdapClient *qq)
: q(qq), : q(qq)
mJob(nullptr), , mJob(nullptr)
mActive(false), , mActive(false)
mClientNumber(0) , mClientNumber(0)
{ {
} }
...@@ -74,11 +74,11 @@ public: ...@@ -74,11 +74,11 @@ public:
KLDAP::Ldif mLdif; KLDAP::Ldif mLdif;
int mClientNumber; int mClientNumber;
int mCompletionWeight; int mCompletionWeight;
}; };
LdapClient::LdapClient(int clientNumber, QObject *parent) LdapClient::LdapClient(int clientNumber, QObject *parent)
: QObject(parent), d(new Private(this)) : QObject(parent)
, d(new Private(this))
{ {
d->mClientNumber = clientNumber; d->mClientNumber = clientNumber;
d->mCompletionWeight = 50 - d->mClientNumber; d->mCompletionWeight = 50 - d->mClientNumber;
...@@ -142,11 +142,11 @@ void LdapClient::startQuery(const QString &filter) ...@@ -142,11 +142,11 @@ void LdapClient::startQuery(const QString &filter)
d->startParseLDIF(); d->startParseLDIF();
d->mActive = true; d->mActive = true;
d->mJob = KIO::get(url, KIO::NoReload, KIO::HideProgressInfo); d->mJob = KIO::get(url, KIO::NoReload, KIO::HideProgressInfo);
connect(d->mJob, SIGNAL(data(KIO::Job*,QByteArray)), connect(d->mJob, SIGNAL(data(KIO::Job *,QByteArray)),
this, SLOT(slotData(KIO::Job*,QByteArray))); this, SLOT(slotData(KIO::Job *,QByteArray)));
connect(d->mJob, SIGNAL(infoMessage(KJob*,QString,QString)), connect(d->mJob, SIGNAL(infoMessage(KJob *,QString,QString)),
this, SLOT(slotInfoMessage(KJob*,QString,QString))); this, SLOT(slotInfoMessage(KJob *,QString,QString)));
connect(d->mJob, SIGNAL(result(KJob*)), connect(d->mJob, SIGNAL(result(KJob *)),
this, SLOT(slotDone())); this, SLOT(slotDone()));
} }
...@@ -205,8 +205,7 @@ void LdapClient::Private::finishCurrentObject() ...@@ -205,8 +205,7 @@ void LdapClient::Private::finishCurrentObject()
KLDAP::LdapAttrValue objectclasses; KLDAP::LdapAttrValue objectclasses;
const KLDAP::LdapAttrMap::ConstIterator end = mCurrentObject.attributes().constEnd(); const KLDAP::LdapAttrMap::ConstIterator end = mCurrentObject.attributes().constEnd();
for (KLDAP::LdapAttrMap::ConstIterator it = mCurrentObject.attributes().constBegin(); for (KLDAP::LdapAttrMap::ConstIterator it = mCurrentObject.attributes().constBegin();
it != end; ++it) { it != end; ++it) {
if (it.key().toLower() == QLatin1String("objectclass")) { if (it.key().toLower() == QLatin1String("objectclass")) {
objectclasses = it.value(); objectclasses = it.value();
break; break;
...@@ -216,8 +215,7 @@ void LdapClient::Private::finishCurrentObject() ...@@ -216,8 +215,7 @@ void LdapClient::Private::finishCurrentObject()
bool groupofnames = false; bool groupofnames = false;
const KLDAP::LdapAttrValue::ConstIterator endValue(objectclasses.constEnd()); const KLDAP::LdapAttrValue::ConstIterator endValue(objectclasses.constEnd());
for (KLDAP::LdapAttrValue::ConstIterator it = objectclasses.constBegin(); for (KLDAP::LdapAttrValue::ConstIterator it = objectclasses.constBegin();
it != endValue; ++it) { it != endValue; ++it) {
const QByteArray sClass = (*it).toLower(); const QByteArray sClass = (*it).toLower();
if (sClass == "groupofnames" || sClass == "kolabgroupofnames") { if (sClass == "groupofnames" || sClass == "kolabgroupofnames") {
groupofnames = true; groupofnames = true;
...@@ -266,12 +264,13 @@ void LdapClient::Private::parseLDIF(const QByteArray &data) ...@@ -266,12 +264,13 @@ void LdapClient::Private::parseLDIF(const QByteArray &data)
do { do {
ret = mLdif.nextItem(); ret = mLdif.nextItem();
switch (ret) { switch (ret) {
case KLDAP::Ldif::Item: { case KLDAP::Ldif::Item:
{
name = mLdif.attr(); name = mLdif.attr();
const QByteArray value = mLdif.value(); const QByteArray value = mLdif.value();
mCurrentObject.addValue(name, value); mCurrentObject.addValue(name, value);
break;
} }
break;
case KLDAP::Ldif::EndEntry: case KLDAP::Ldif::EndEntry:
finishCurrentObject(); finishCurrentObject();
break; break;
......
...@@ -29,9 +29,7 @@ ...@@ -29,9 +29,7 @@
class KJob; class KJob;
namespace KLDAP namespace KLDAP {
{
class LdapObject; class LdapObject;
class LdapServer; class LdapServer;
...@@ -159,7 +157,6 @@ private: ...@@ -159,7 +157,6 @@ private:
Q_PRIVATE_SLOT(d, void slotDone()) Q_PRIVATE_SLOT(d, void slotDone())
//@endcond //@endcond
}; };
} }
#endif #endif
...@@ -51,9 +51,9 @@ class Q_DECL_HIDDEN LdapClientSearch::Private ...@@ -51,9 +51,9 @@ class Q_DECL_HIDDEN LdapClientSearch::Private
{ {
public: public:
Private(LdapClientSearch *qq) Private(LdapClientSearch *qq)
: q(qq), : q(qq)
mActiveClients(0), , mActiveClients(0)
mNoLDAPLookup(false) , mNoLDAPLookup(false)
{ {
mClientSearchConfig = new LdapClientSearchConfig; mClientSearchConfig = new LdapClientSearchConfig;
} }
...@@ -88,7 +88,8 @@ public: ...@@ -88,7 +88,8 @@ public:
}; };
LdapClientSearch::LdapClientSearch(QObject *parent) LdapClientSearch::LdapClientSearch(QObject *parent)
: QObject(parent), d(new Private(this)) : QObject(parent)
, d(new Private(this))
{ {
Kdelibs4ConfigMigrator migrate(QStringLiteral("ldapsettings")); Kdelibs4ConfigMigrator migrate(QStringLiteral("ldapsettings"));
migrate.setConfigFiles(QStringList() << QStringLiteral("kabldaprc")); migrate.setConfigFiles(QStringList() << QStringLiteral("kabldaprc"));
...@@ -111,7 +112,6 @@ LdapClientSearch::LdapClientSearch(QObject *parent) ...@@ -111,7 +112,6 @@ LdapClientSearch::LdapClientSearch(QObject *parent)
d->readConfig(); d->readConfig();
connect(KDirWatch::self(), SIGNAL(dirty(QString)), this, connect(KDirWatch::self(), SIGNAL(dirty(QString)), this,
SLOT(slotFileChanged(QString))); SLOT(slotFileChanged(QString)));
} }
LdapClientSearch::~LdapClientSearch() LdapClientSearch::~LdapClientSearch()
...@@ -119,8 +119,7 @@ LdapClientSearch::~LdapClientSearch() ...@@ -119,8 +119,7 @@ LdapClientSearch::~LdapClientSearch()
delete d; delete d;
} }
void LdapClientSearch::Private::readWeighForClient(LdapClient *client, const KConfigGroup &config, void LdapClientSearch::Private::readWeighForClient(LdapClient *client, const KConfigGroup &config, int clientNumber)
int clientNumber)
{ {
const int completionWeight = config.readEntry(QStringLiteral("SelectedCompletionWeight%1").arg(clientNumber), -1); const int completionWeight = config.readEntry(QStringLiteral("SelectedCompletionWeight%1").arg(clientNumber), -1);
if (completionWeight != -1) { if (completionWeight != -1) {
...@@ -158,7 +157,6 @@ QStringList LdapClientSearch::attributes() const ...@@ -158,7 +157,6 @@ QStringList LdapClientSearch::attributes() const
void LdapClientSearch::setAttributes(const QStringList &attrs) void LdapClientSearch::setAttributes(const QStringList &attrs)
{ {
if (attrs != d->mAttributes) { if (attrs != d->mAttributes) {
d->mAttributes = attrs; d->mAttributes = attrs;
d->readConfig(); d->readConfig();
...@@ -258,8 +256,7 @@ void LdapClientSearch::cancelSearch() ...@@ -258,8 +256,7 @@ void LdapClientSearch::cancelSearch()
d->mResults.clear(); d->mResults.clear();
} }
void LdapClientSearch::Private::slotLDAPResult(const LdapClient &client, void LdapClientSearch::Private::slotLDAPResult(const LdapClient &client, const KLDAP::LdapObject &obj)
const KLDAP::LdapObject &obj)
{ {
LdapResultObject result; LdapResultObject result;
result.client = &client; result.client = &client;
...@@ -312,7 +309,6 @@ void LdapClientSearch::Private::finish() ...@@ -312,7 +309,6 @@ void LdapClientSearch::Private::finish()
void LdapClientSearch::Private::makeSearchData(QStringList &ret, LdapResult::List &resList) void LdapClientSearch::Private::makeSearchData(QStringList &ret, LdapResult::List &resList)
{ {
LdapResultObject::List::ConstIterator it1(mResults.constBegin()); LdapResultObject::List::ConstIterator it1(mResults.constBegin());
const LdapResultObject::List::ConstIterator end1(mResults.constEnd()); const LdapResultObject::List::ConstIterator end1(mResults.constEnd());
for (; it1 != end1; ++it1) { for (; it1 != end1; ++it1) {
...@@ -326,7 +322,7 @@ void LdapClientSearch::Private::makeSearchData(QStringList &ret, LdapResult::Lis ...@@ -326,7 +322,7 @@ void LdapClientSearch::Private::makeSearchData(QStringList &ret, LdapResult::Lis
KLDAP::LdapAttrMap::ConstIterator it2; KLDAP::LdapAttrMap::ConstIterator it2;
for (it2 = (*it1).object.attributes().constBegin(); for (it2 = (*it1).object.attributes().constBegin();
it2 != (*it1).object.attributes().constEnd(); ++it2) { it2 != (*it1).object.attributes().constEnd(); ++it2) {
QByteArray val = (*it2).first(); QByteArray val = (*it2).first();
int len = val.size(); int len = val.size();
if (len > 0 && '\0' == val[len - 1]) { if (len > 0 && '\0' == val[len - 1]) {
...@@ -369,8 +365,8 @@ void LdapClientSearch::Private::makeSearchData(QStringList &ret, LdapResult::Lis ...@@ -369,8 +365,8 @@ void LdapClientSearch::Private::makeSearchData(QStringList &ret, LdapResult::Lis
givenname = tmp; givenname = tmp;
} else if (it2.key() == QLatin1String("sn")) { } else if (it2.key() == QLatin1String("sn")) {
sn = tmp; sn = tmp;
} else if (it2.key() == QLatin1String("objectClass") && } else if (it2.key() == QLatin1String("objectClass")
(tmp == QLatin1String("groupOfNames") || tmp == QLatin1String("kolabGroupOfNames"))) { && (tmp == QLatin1String("groupOfNames") || tmp == QLatin1String("kolabGroupOfNames"))) {
isDistributionList = true; isDistributionList = true;
} }
} }
......
...@@ -27,8 +27,7 @@ ...@@ -27,8 +27,7 @@
#include <QObject> #include <QObject>
#include <QStringList> #include <QStringList>
namespace KLDAP namespace KLDAP {
{
class LdapClient; class LdapClient;
/** /**
...@@ -180,7 +179,6 @@ private: ...@@ -180,7 +179,6 @@ private:
Q_PRIVATE_SLOT(d, void slotFileChanged(const QString &)) Q_PRIVATE_SLOT(d, void slotFileChanged(const QString &))
//@endcond //@endcond
}; };
} }
Q_DECLARE_TYPEINFO(KLDAP::LdapResult, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(KLDAP::LdapResult, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(KLDAP::LdapResultObject, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(KLDAP::LdapResultObject, Q_MOVABLE_TYPE);
......
...@@ -32,12 +32,12 @@ class Q_DECL_HIDDEN LdapClientSearchConfig::Private ...@@ -32,12 +32,12 @@ class Q_DECL_HIDDEN LdapClientSearchConfig::Private
{ {
public: public:
Private() Private()
: useWallet(false), : useWallet(false)
askWallet(true), , askWallet(true)
wallet(nullptr) , wallet(nullptr)
{ {
} }
~Private() ~Private()
{ {
if (useWallet) { if (useWallet) {
...@@ -45,6 +45,7 @@ public: ...@@ -45,6 +45,7 @@ public:
wallet = nullptr; wallet = nullptr;
} }
} }
bool useWallet; bool useWallet;
bool askWallet; bool askWallet;
KWallet::Wallet *wallet; KWallet::Wallet *wallet;
...@@ -58,7 +59,8 @@ KConfig *LdapClientSearchConfig::config() ...@@ -58,7 +59,8 @@ KConfig *LdapClientSearchConfig::config()
} }
LdapClientSearchConfig::LdapClientSearchConfig(QObject *parent) LdapClientSearchConfig::LdapClientSearchConfig(QObject *parent)
: QObject(parent), d(new LdapClientSearchConfig::Private()) : QObject(parent)
, d(new LdapClientSearchConfig::Private())
{ {
} }
...@@ -74,8 +76,8 @@ void LdapClientSearchConfig::readConfig(KLDAP::LdapServer &server, KConfigGroup ...@@ -74,8 +76,8 @@ void LdapClientSearchConfig::readConfig(KLDAP::LdapServer &server, KConfigGroup
prefix = QStringLiteral("Selected"); prefix = QStringLiteral("Selected");
} }
const QString host = config.readEntry(prefix + QStringLiteral("Host%1").arg(j), const QString host = config.readEntry(prefix + QStringLiteral("Host%1").arg(j),
QString()).trimmed(); QString()).trimmed();
if (!host.isEmpty()) { if (!host.isEmpty()) {
server.setHost(host); server.setHost(host);
} }
...@@ -104,10 +106,10 @@ void LdapClientSearchConfig::readConfig(KLDAP::LdapServer &server, KConfigGroup ...@@ -104,10 +106,10 @@ void LdapClientSearchConfig::readConfig(KLDAP::LdapServer &server, KConfigGroup
QString pwdBindDN = config.readEntry(pwdBindBNEntry, QString()); QString pwdBindDN = config.readEntry(pwdBindBNEntry, QString());
if (!pwdBindDN.isEmpty()) { if (!pwdBindDN.isEmpty()) {
if (d->askWallet && KMessageBox::Yes == KMessageBox::questionYesNo(nullptr, i18n("LDAP password is stored as clear text, do you want to store it in kwallet?"), if (d->askWallet && KMessageBox::Yes == KMessageBox::questionYesNo(nullptr, i18n("LDAP password is stored as clear text, do you want to store it in kwallet?"),
i18n("Store clear text password in KWallet"), i18n("Store clear text password in KWallet"),
KStandardGuiItem::yes(), KStandardGuiItem::yes(),
KStandardGuiItem::no(), KStandardGuiItem::no(),
QStringLiteral("DoAskToStoreToKwallet"))) { QStringLiteral("DoAskToStoreToKwallet"))) {
d->wallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet(), 0); d->wallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet(), 0);
if (d->wallet) { if (d->wallet) {
connect(d->wallet, &KWallet::Wallet::walletClosed, this, &LdapClientSearchConfig::slotWalletClosed); connect(d->wallet, &KWallet::Wallet::walletClosed, this, &LdapClientSearchConfig::slotWalletClosed);
......
...@@ -27,8 +27,7 @@ ...@@ -27,8 +27,7 @@
class KConfigGroup; class KConfigGroup;
class KConfig; class KConfig;
namespace KLDAP namespace KLDAP {
{
class LdapServer; class LdapServer;
class LdapClient; class LdapClient;
class KDEPIM_EXPORT LdapClientSearchConfig : public QObject class KDEPIM_EXPORT LdapClientSearchConfig : public QObject
...@@ -49,8 +48,7 @@ public: ...@@ -49,8 +48,7 @@ public:
* *
* @param active Defines whether the active settings shall be read. * @param active Defines whether the active settings shall be read.
*/ */
void readConfig(KLDAP::LdapServer &server, KConfigGroup &group, void readConfig(KLDAP::LdapServer &server, KConfigGroup &group, int clientNumber, bool active);
int clientNumber, bool active);
/** /**
* Writes the LDAP @p server settings to the given config @p group for the * Writes the LDAP @p server settings to the given config @p group for the
...@@ -58,8 +56,7 @@ public: ...@@ -58,8 +56,7 @@ public:
* *
* @param active Defines whether the active settings shall be written. * @param active Defines whether the active settings shall be written.
*/