Commit 8ddde3b7 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

run git clang-format

parent 35737c82
......@@ -4,16 +4,16 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include <QObject>
#include <QDir>
#include <QObject>
#include <QTest>
#include <KConfig>
#include <KConfigGroup>
#include <QTemporaryFile>
#include <KLDAP/LdapClientSearchConfig>
#include "../ldap.h"
#include <KLDAP/LdapClientSearchConfig>
class TLdap : public Ldap
{
......@@ -25,7 +25,7 @@ public:
mTempFile.open();
mTempFile.close();
mConfig = new KConfig(mTempFile.fileName(), KConfig::SimpleConfig);
//TODO m_clientSearchConfig->askForWallet(false);
// TODO m_clientSearchConfig->askForWallet(false);
}
~TLdap() override
......@@ -50,7 +50,7 @@ class LdapTest : public QObject
private Q_SLOTS:
void testDestroy()
{
#if 0 //TODO port it
#if 0 // TODO port it
TLdap l;
QFile::remove(l.mTempFile.fileName());
QFile::copy(QStringLiteral(TEST_DATA_DIR) + QStringLiteral("/ldap.cfg"), l.mTempFile.fileName());
......
......@@ -34,6 +34,7 @@ public Q_SLOTS:
Q_SCRIPTABLE void setPassword(const QString &group, const QString &key, const QString &value);
Q_SCRIPTABLE void setEditMode(const bool editMode);
Q_SCRIPTABLE void setEditName(const QString &name);
private:
QVector<Config> m_configData;
QString m_name;
......
......@@ -5,35 +5,35 @@
*/
#include "cryptopage.h"
#include "accountwizard_debug.h"
#include "dialog.h"
#include "identity.h"
#include "accountwizard_debug.h"
#include "transport.h"
#include <Libkleo/Classify>
#include <Libkleo/DefaultKeyFilter>
#include <Libkleo/DefaultKeyGenerationJob>
#include <Libkleo/ProgressDialog>
#include <Libkleo/Classify>
#include <QGpgME/Job>
#include <QGpgME/ImportJob>
#include <QGpgME/Job>
#include <QGpgME/KeyListJob>
#include <QGpgME/Protocol>
#include <QGpgME/WKSPublishJob>
#include <QGpgME/KeyListJob>
#include <gpgme++/context.h>
#include <gpgme++/importresult.h>
#include <gpgme++/keygenerationresult.h>
#include <gpgme++/keylistresult.h>
#include <gpgme++/importresult.h>
#include <KMessageBox>
#include <KNotifications/KNotification>
#include <KNewPasswordDialog>
#include <KNotifications/KNotification>
#include <KIdentityManagement/IdentityManager>
#include <KIdentityManagement/Identity>
#include <KIdentityManagement/IdentityManager>
#include <QFileDialog>
#include <QEventLoopLocker>
#include <QFileDialog>
class KeyGenerationJob : public QObject
{
......@@ -50,14 +50,12 @@ public:
{
// Listen for when setup of Transport is finished so we can snatch
// the transport ID
connect(mSetupManager.data(), &SetupManager::setupFinished,
this, &KeyGenerationJob::onObjectSetupFinished);
connect(mSetupManager.data(), &SetupManager::setupFinished, this, &KeyGenerationJob::onObjectSetupFinished);
qCDebug(ACCOUNTWIZARD_LOG) << "Starting key generation";
auto job = new Kleo::DefaultKeyGenerationJob(this);
job->setPassphrase(mPassphrase);
connect(job, &Kleo::DefaultKeyGenerationJob::result,
this, &KeyGenerationJob::keyGenerated);
connect(job, &Kleo::DefaultKeyGenerationJob::result, this, &KeyGenerationJob::keyGenerated);
job->start(mEmail, mName);
}
......@@ -82,8 +80,7 @@ private Q_SLOTS:
qCWarning(ACCOUNTWIZARD_LOG) << "Key generation finished with error:" << result.error().asString();
KNotification::event(KNotification::Error,
i18n("Account Wizard"),
i18n("Error while generating new key pair for your account %1: %2",
mEmail, QString::fromUtf8(result.error().asString())),
i18n("Error while generating new key pair for your account %1: %2", mEmail, QString::fromUtf8(result.error().asString())),
QStringLiteral("akonadi"));
deleteLater();
return;
......@@ -94,9 +91,8 @@ private Q_SLOTS:
Q_EMIT this->result(fpr);
auto listJob = QGpgME::openpgp()->keyListJob(false, true, true);
connect(listJob, &QGpgME::KeyListJob::result,
this, &KeyGenerationJob::keyRetrieved);
listJob->start({ fpr }, true);
connect(listJob, &QGpgME::KeyListJob::result, this, &KeyGenerationJob::keyRetrieved);
listJob->start({fpr}, true);
}
void keyRetrieved(const GpgME::KeyListResult &result, const std::vector<GpgME::Key> &keys)
......@@ -105,8 +101,7 @@ private Q_SLOTS:
qCWarning(ACCOUNTWIZARD_LOG) << "Key listing finished with error;" << result.error().asString();
KNotification::event(KNotification::Error,
i18n("Account Wizard"),
i18n("Error while generating new key pair for your account %1: %2",
mEmail, QString::fromUtf8(result.error().asString())),
i18n("Error while generating new key pair for your account %1: %2", mEmail, QString::fromUtf8(result.error().asString())),
QStringLiteral("akonadi"));
deleteLater();
return;
......@@ -129,12 +124,10 @@ private Q_SLOTS:
// SetupManager still lives, see if Identity has already been set up.
// If not then pass it the new key and let it set up everything
const auto objectsToSetup = mSetupManager->objectsToSetup();
const auto identIt = std::find_if(objectsToSetup.cbegin(), objectsToSetup.cend(),
[](SetupObject *obj) -> bool {
const auto identIt = std::find_if(objectsToSetup.cbegin(), objectsToSetup.cend(), [](SetupObject *obj) -> bool {
return qobject_cast<Identity *>(obj);
});
const auto keyIt = std::find_if(objectsToSetup.cbegin(), objectsToSetup.cend(),
[](SetupObject *obj) -> bool {
const auto keyIt = std::find_if(objectsToSetup.cbegin(), objectsToSetup.cend(), [](SetupObject *obj) -> bool {
return qobject_cast<Key *>(obj);
});
if (identIt != objectsToSetup.cend()) {
......@@ -156,8 +149,7 @@ private Q_SLOTS:
// SetupManager still lives, but Identity has already been set up,
// so update it.
const auto setupObjects = mSetupManager->setupObjects();
const auto it = std::find_if(setupObjects.cbegin(), setupObjects.cend(),
[](SetupObject *obj) -> bool {
const auto it = std::find_if(setupObjects.cbegin(), setupObjects.cend(), [](SetupObject *obj) -> bool {
return qobject_cast<Identity *>(obj);
});
if (it != setupObjects.cend()) {
......@@ -208,14 +200,11 @@ private Q_SLOTS:
keyObj->setPublishingMethod(mPublishingMethod);
keyObj->setMailBox(mEmail);
keyObj->setTransportId(mTransportId);
connect(keyObj, &Key::error, this,
[this](const QString &msg) {
KNotification::event(KNotification::Error, i18n("Account Wizard"),
msg, QStringLiteral("akonadi"));
connect(keyObj, &Key::error, this, [this](const QString &msg) {
KNotification::event(KNotification::Error, i18n("Account Wizard"), msg, QStringLiteral("akonadi"));
deleteLater();
});
connect(keyObj, &Key::finished,
this, &KeyGenerationJob::deleteLater);
connect(keyObj, &Key::finished, this, &KeyGenerationJob::deleteLater);
keyObj->create();
}
......@@ -269,9 +258,7 @@ public:
}
if (!job) {
KMessageBox::error(qobject_cast<QWidget *>(parent()),
i18n("Could not detect valid key type"),
i18n("Import error"));
KMessageBox::error(qobject_cast<QWidget *>(parent()), i18n("Could not detect valid key type"), i18n("Import error"));
Q_EMIT done();
return;
}
......@@ -285,8 +272,7 @@ public:
return;
}
connect(job, &QGpgME::ImportJob::result,
this, &KeyImportJob::keyImported);
connect(job, &QGpgME::ImportJob::result, this, &KeyImportJob::keyImported);
job->start(keyFile.readAll());
mJob = job;
}
......@@ -304,17 +290,14 @@ public:
const auto imports = result.imports();
if (imports.size() == 0) {
KMessageBox::error(qobject_cast<QWidget *>(parent()),
i18n("Failed to import key."),
i18n("Import error"));
KMessageBox::error(qobject_cast<QWidget *>(parent()), i18n("Failed to import key."), i18n("Import error"));
Q_EMIT done();
return;
}
auto combo = qobject_cast<Kleo::KeySelectionCombo *>(parent());
combo->setDefaultKey(QLatin1String(result.import(0).fingerprint()));
connect(combo, &Kleo::KeySelectionCombo::keyListingFinished,
this, &KeyImportJob::done);
connect(combo, &Kleo::KeySelectionCombo::keyListingFinished, this, &KeyImportJob::done);
combo->refreshKeys();
}
......@@ -335,15 +318,11 @@ CryptoPage::CryptoPage(Dialog *parent)
filter->setHasSecret(Kleo::DefaultKeyFilter::Set);
ui.keyCombo->setKeyFilter(filter);
ui.keyCombo->prependCustomItem(QIcon(), i18n("No key"), NoKey);
ui.keyCombo->appendCustomItem(QIcon::fromTheme(QStringLiteral("document-new")),
i18n("Generate a new key pair"), GenerateKey);
ui.keyCombo->appendCustomItem(QIcon::fromTheme(QStringLiteral("document-import")),
i18n("Import a key"), ImportKey);
connect(ui.keyCombo, &Kleo::KeySelectionCombo::customItemSelected,
this, &CryptoPage::customItemSelected);
connect(ui.keyCombo, &Kleo::KeySelectionCombo::currentKeyChanged,
this, &CryptoPage::keySelected);
ui.keyCombo->appendCustomItem(QIcon::fromTheme(QStringLiteral("document-new")), i18n("Generate a new key pair"), GenerateKey);
ui.keyCombo->appendCustomItem(QIcon::fromTheme(QStringLiteral("document-import")), i18n("Import a key"), ImportKey);
connect(ui.keyCombo, &Kleo::KeySelectionCombo::customItemSelected, this, &CryptoPage::customItemSelected);
connect(ui.keyCombo, &Kleo::KeySelectionCombo::currentKeyChanged, this, &CryptoPage::keySelected);
}
void CryptoPage::enterPageNext()
......@@ -362,8 +341,7 @@ void CryptoPage::enterPageNext()
ui.stackedWidget->setCurrentIndex(CheckingkWKSPage);
auto job = QGpgME::openpgp()->wksPublishJob();
connect(job, &QGpgME::WKSPublishJob::result,
this, [this](const GpgME::Error &error) {
connect(job, &QGpgME::WKSPublishJob::result, this, [this](const GpgME::Error &error) {
if (error) {
ui.stackedWidget->setCurrentIndex(PKSPage);
} else {
......@@ -381,12 +359,10 @@ void CryptoPage::leavePageNext()
mSetupManager->setKeyPublishingMethod(currentPublishingMethod());
} else if (ui.keyCombo->currentData(Qt::UserRole).toInt() == GenerateKey) {
if (!mKeyGenerationJob) {
mKeyGenerationJob = new KeyGenerationJob(mSetupManager, ui.passwordWidget->password(),
currentPublishingMethod());
mKeyGenerationJob = new KeyGenerationJob(mSetupManager, ui.passwordWidget->password(), currentPublishingMethod());
ui.keyCombo->setEnabled(false); // disable until key is generated
ui.passwordWidget->setEnabled(false);
connect(mKeyGenerationJob.data(), &KeyGenerationJob::result,
this, [this](const QString &fpr) {
connect(mKeyGenerationJob.data(), &KeyGenerationJob::result, this, [this](const QString &fpr) {
ui.keyCombo->setEnabled(true);
ui.passwordWidget->setEnabled(true);
ui.keyCombo->setDefaultKey(fpr);
......@@ -453,9 +429,8 @@ void CryptoPage::importKey()
const QString certificateFilter = i18n("Certificates") + QLatin1String(" (*.asc *.cer *.cert *.crt *.der *.pem *.gpg *.p7c *.p12 *.pfx *.pgp)");
const QString anyFilesFilter = i18n("Any files") + QLatin1String(" (*)");
const QString file = QFileDialog::getOpenFileName(this, i18n("Select Certificate File"),
QString(),
certificateFilter + QLatin1String(";;") + anyFilesFilter);
const QString file =
QFileDialog::getOpenFileName(this, i18n("Select Certificate File"), QString(), certificateFilter + QLatin1String(";;") + anyFilesFilter);
if (file.isEmpty()) {
return;
}
......@@ -463,8 +438,7 @@ void CryptoPage::importKey()
auto job = new KeyImportJob(file, ui.keyCombo);
new Kleo::ProgressDialog(job, i18n("Importing key..."), ui.keyCombo->parentWidget());
ui.keyCombo->setEnabled(false);
QObject::connect(job, &KeyImportJob::done,
ui.keyCombo, [this]() {
QObject::connect(job, &KeyImportJob::done, ui.keyCombo, [this]() {
ui.keyCombo->setEnabled(true);
});
job->start();
......
......@@ -7,9 +7,9 @@
#ifndef CRYPTOPAGE_H
#define CRYPTOPAGE_H
#include "key.h"
#include "page.h"
#include "ui_cryptopage.h"
#include "key.h"
#include <QPointer>
......@@ -17,7 +17,8 @@ class Dialog;
class SetupManager;
class KeyGenerationJob;
namespace QGpgME {
namespace QGpgME
{
class Job;
}
......@@ -36,17 +37,9 @@ private Q_SLOTS:
void keySelected(const GpgME::Key &key);
private:
enum PublishingOptionPage {
CheckingkWKSPage,
WKSPage,
PKSPage
};
enum Action {
NoKey = 1,
GenerateKey,
ImportKey
};
enum PublishingOptionPage { CheckingkWKSPage, WKSPage, PKSPage };
enum Action { NoKey = 1, GenerateKey, ImportKey };
void setPublishingEnabled(bool enabled);
void importKey();
......
......@@ -10,24 +10,24 @@
#ifndef ACCOUNTWIZARD_NO_GHNS
#include "providerpage.h"
#endif
#include "typepage.h"
#include "loadpage.h"
#include "global.h"
#include "cryptopage.h"
#include "dynamicpage.h"
#include "global.h"
#include "loadpage.h"
#include "servertest.h"
#include "setuppage.h"
#include "cryptopage.h"
#include "typepage.h"
#include <QAction>
#include <KMime/Message>
#include <KLocalizedString>
#include "accountwizard_debug.h"
#include <KMessageBox>
#include <qplatformdefs.h>
#include <KAboutData>
#include <KLocalizedString>
#include <KMessageBox>
#include <PimCommon/PimUtil>
#include <qplatformdefs.h>
#include <KHelpMenu>
......@@ -90,11 +90,11 @@ Dialog::Dialog(QWidget *parent)
Page *page = qobject_cast<Page *>(currentPage()->widget());
page->enterPageNext();
//TODO ? necessary ???
// TODO ? necessary ???
Q_EMIT page->pageEnteredNext();
connect(button(QDialogButtonBox::Cancel), &QPushButton::clicked, this, &Dialog::reject);
auto *helpMenu = new KHelpMenu(this, KAboutData::applicationData(), true);
//Initialize menu
// Initialize menu
QMenu *menu = helpMenu->menu();
helpMenu->action(KHelpMenu::menuAboutApp)->setIcon(QIcon::fromTheme(QStringLiteral("akonadi")));
disconnect(helpMenu->action(KHelpMenu::menuHelpContents), nullptr, helpMenu, nullptr);
......@@ -203,7 +203,9 @@ void Dialog::clearDynamicPages()
void Dialog::reject()
{
connect(mSetupManager, &SetupManager::rollbackComplete, this, [this]() { KAssistantDialog::reject();} );
connect(mSetupManager, &SetupManager::rollbackComplete, this, [this]() {
KAssistantDialog::reject();
});
mSetupManager->requestRollback();
}
......
......@@ -8,13 +8,13 @@
#include "accountwizard_debug.h"
#include <QUiLoader>
#include <QFile>
#include <QBoxLayout>
#include <QScrollArea>
#include "global.h"
#include <KLocalizedTranslator>
#include <QBoxLayout>
#include <QCoreApplication>
#include <QFile>
#include <QScrollArea>
#include <QUiLoader>
DynamicPage::DynamicPage(const QString &uiFile, KAssistantDialog *parent)
: Page(parent)
......
......@@ -7,10 +7,10 @@
#include "global.h"
#include "accountwizard_debug.h"
#include <QFileInfo>
#include <QDir>
#include <kio/copyjob.h>
#include <QFileInfo>
#include <QStandardPaths>
#include <kio/copyjob.h>
class GlobalPrivate
{
......@@ -30,7 +30,8 @@ QString Global::assistant()
QStringList Global::assistants()
{
QStringList list;
const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("akonadi/accountwizard/"), QStandardPaths::LocateDirectory);
const QStringList dirs =
QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("akonadi/accountwizard/"), QStandardPaths::LocateDirectory);
for (const QString &dir : dirs) {
const QStringList directories = QDir(dir).entryList(QDir::AllDirs);
for (const QString &directory : directories) {
......@@ -61,7 +62,8 @@ void Global::setAssistant(const QString &assistant)
}
QStringList list;
const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("akonadi/accountwizard/"), QStandardPaths::LocateDirectory);
const QStringList dirs =
QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("akonadi/accountwizard/"), QStandardPaths::LocateDirectory);
for (const QString &dir : dirs) {
const QStringList directories = QDir(dir).entryList(QDir::AllDirs);
for (const QString &directory : directories) {
......
......@@ -7,10 +7,11 @@
#ifndef GLOBAL_H
#define GLOBAL_H
#include <QUrl>
#include <QStringList>
#include <QUrl>
namespace Global {
namespace Global
{
Q_REQUIRED_RESULT QStringList typeFilter();
void setTypeFilter(const QStringList &filter);
void setPoFileName(const QString &poFileName);
......
......@@ -7,9 +7,9 @@
#include "identity.h"
#include "transport.h"
#include <kidentitymanagement/identitymanager.h>
#include <kidentitymanagement/identity.h>
#include "accountwizard_debug.h"
#include <kidentitymanagement/identity.h>
#include <kidentitymanagement/identitymanager.h>
#include <KLocalizedString>
......@@ -57,9 +57,9 @@ QString Identity::identityName() const
name.replace(QLatin1Char('.'), QLatin1Char(' '));
pos = name.indexOf(QLatin1Char(' '));
if (pos != 0) {
name[ pos + 1 ] = name[ pos + 1 ].toUpper();
name[pos + 1] = name[pos + 1].toUpper();
}
name[ 0 ] = name[ 0 ].toUpper();
name[0] = name[0].toUpper();
}
auto manager = KIdentityManagement::IdentityManager::self();
......
......@@ -13,7 +13,8 @@
class Transport;
namespace KIdentityManagement {
namespace KIdentityManagement
{
class Identity;
}
......
......@@ -6,7 +6,6 @@
#include "inprocess-main.h"
AccountWizard::AccountWizard(QObject *parent)
: QObject(parent)
{
......
......@@ -71,8 +71,7 @@ freebusy AutoconfigKolabFreebusy::createFreebusyServer(const QDomElement &n)
s.password = f.text();
} else if (tagName == QLatin1String("authentication")) {
const QString type(f.text());
if (type == QLatin1String("none")
|| type == QLatin1String("plain")) {
if (type == QLatin1String("none") || type == QLatin1String("plain")) {
s.authentication = Plain;
} else if (type == QLatin1String("basic")) {
s.authentication = Basic;
......@@ -86,7 +85,7 @@ freebusy AutoconfigKolabFreebusy::createFreebusyServer(const QDomElement &n)
return s;
}
QHash< QString, freebusy > AutoconfigKolabFreebusy::freebusyServers() const
QHash<QString, freebusy> AutoconfigKolabFreebusy::freebusyServers() const
{
return mFreebusyServer;
}
......@@ -111,7 +111,7 @@ ldapServer AutoconfigKolabLdap::createLdapServer(const QDomElement &n)
return s;
}
QHash< QString, ldapServer > AutoconfigKolabLdap::ldapServers() const
QHash<QString, ldapServer> AutoconfigKolabLdap::ldapServers() const
{
return mLdapServers;
}
......
......@@ -5,8 +5,8 @@
*/
#include "autoconfigkolabmail.h"
#include <QDomDocument>
#include "accountwizard_debug.h"
#include <QDomDocument>
AutoconfigKolabMail::AutoconfigKolabMail(QObject *parent)
: Ispdb(parent)
......@@ -16,7 +16,7 @@ AutoconfigKolabMail::AutoconfigKolabMail(QObject *parent)
void AutoconfigKolabMail::startJob(const QUrl &url)
{
mData.clear();
QMap< QString, QVariant > map;
QMap<QString, QVariant> map;
map[QStringLiteral("errorPage")] = false;
map[QStringLiteral("no-auth-prompt")] = true;
map[QStringLiteral("no-www-auth")] = true;
......@@ -30,10 +30,9 @@ void AutoconfigKolabMail::startJob(const QUrl &url)
void AutoconfigKolabMail::slotResult(KJob *job)
{
if (job->error()) {
if (job->error() == KIO::ERR_INTERNAL_SERVER // error 500
|| job->error() == KIO::ERR_UNKNOWN_HOST // unknown host
|| job->error() == KIO::ERR_CANNOT_CONNECT
|| job->error() == KIO::ERR_DOES_NOT_EXIST) { // error 404
if (job->error() == KIO::ERR_INTERNAL_SERVER // error 500
|| job->error() == KIO::ERR_UNKNOWN_HOST // unknown host
|| job->error() == KIO::ERR_CANNOT_CONNECT || job->error() == KIO::ERR_DOES_NOT_EXIST) { // error 404
if (serverType() == DataBase) {
setServerType(IspAutoConfig);
lookupInDb(false, false);
......@@ -44,7 +43,7 @@ void AutoconfigKolabMail::slotResult(KJob *job)
Q_EMIT finished(false);
}
} else {
//qCDebug(ACCOUNTWIZARD_LOG) << "Fetching failed" << job->error() << job->errorString();
// qCDebug(ACCOUNTWIZARD_LOG) << "Fetching failed" << job->error() << job->errorString();
Q_EMIT finished(false);
}
return;
......@@ -58,7 +57,7 @@ void AutoconfigKolabMail::slotResult(KJob *job)
lookupInDb(true, true);
return;
} else if (responsecode != 200 && responsecode != 0 && responsecode != 304) {
//qCDebug(ACCOUNTWIZARD_LOG) << "Fetching failed with" << responsecode;
// qCDebug(ACCOUNTWIZARD_LOG) << "Fetching failed with" << responsecode;
Q_EMIT finished(false);
return;
}
......@@ -66,7 +65,7 @@ void AutoconfigKolabMail::slotResult(KJob *job)
QDomDocument document;
bool ok = document.setContent(mData);
if (!ok) {
//qCDebug(ACCOUNTWIZARD_LOG) << "Could not parse xml" << mData;
// qCDebug(ACCOUNTWIZARD_LOG) << "Could not parse xml" << mData;
Q_EMIT finished(false);
return;
}
......
......@@ -5,9 +5,9 @@
*/
#include <QObject>
#include <QTest>
#include <QProcess>
#include <QTcpSocket>
#include <QTest>
#include "../autoconfigkolabfreebusy.h"
......@@ -37,7 +37,7 @@ public:
const QString filePath = QStringLiteral(AUTOCONFIG_DATA_DIR) + QLatin1Char('/') + file;
[](const QString &file) {
QVERIFY(QFile(file).exists());
} (filePath);
}(filePath);
QEventLoop loop;
TAutoconfFreebusy *ispdb = new TAutoconfFreebusy();
......
......@@ -6,8 +6,8 @@
#include <QObject>
#include <QProcess>
#include <QTest>
#include <QTcpSocket>
#include <QTest>
#include "../autoconfigkolabldap.h"