Commit cb50d66c authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Add and make use of ECM's clang-format support

Make the conding style consistent
parent ea196518
......@@ -27,10 +27,14 @@ include(KDECMakeSettings)
include(FeatureSummary)
include(ECMInstallIcons)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(KDEClangFormat)
add_subdirectory(services)
add_subdirectory(providers)
add_subdirectory(webkit-options)
add_subdirectory(plugins)
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h)
kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
......@@ -9,12 +9,12 @@
#include "nextcloud.h"
#include "nextcloudcontroller.h"
#include <KLocalizedString>
#include <KDeclarative/QmlObject>
#include <KLocalizedString>
#include <QIcon>
#include <QQmlEngine>
#include <QQmlContext>
#include <QQmlEngine>
#include <QWindow>
NextcloudWizard::NextcloudWizard(QObject *parent)
......@@ -30,7 +30,6 @@ NextcloudWizard::~NextcloudWizard()
void NextcloudWizard::init(KAccountsUiPlugin::UiType type)
{
if (type == KAccountsUiPlugin::NewAccountDialog) {
const QString packagePath("org.kde.kaccounts.nextcloud");
m_object = new KDeclarative::QmlObject();
......@@ -60,7 +59,6 @@ void NextcloudWizard::init(KAccountsUiPlugin::UiType type)
Q_EMIT uiReady();
}
}
void NextcloudWizard::setProviderName(const QString &providerName)
......
......@@ -9,13 +9,14 @@
#ifndef NEXTCLOUD_H
#define NEXTCLOUD_H
#include <QUrl>
#include <QHash>
#include <QUrl>
#include <kaccountsuiplugin.h>
namespace KDeclarative {
class QmlObject;
namespace KDeclarative
{
class QmlObject;
}
class NextcloudWizard : public KAccountsUiPlugin
......@@ -39,4 +40,4 @@ private:
KDeclarative::QmlObject *m_object;
};
#endif //NEXTCLOUD_H
#endif // NEXTCLOUD_H
......@@ -7,13 +7,13 @@
#include "nextcloudcontroller.h"
#include <KIO/Job>
#include <KIO/DavJob>
#include <kio/global.h>
#include <KIO/Job>
#include <KLocalizedString>
#include <QDesktopServices>
#include <QJsonDocument>
#include <QJsonObject>
#include <QDesktopServices>
#include <kio/global.h>
#include "../cloudurls.h"
......@@ -39,7 +39,7 @@ NextcloudController::~NextcloudController()
}
void NextcloudController::checkServer(const QString &path)
{
{
m_errorMessage.clear();
Q_EMIT errorMessageChanged();
......@@ -48,7 +48,7 @@ void NextcloudController::checkServer(const QString &path)
checkServer(createStatusUrl(path));
}
//To check if url is correct
// To check if url is correct
void NextcloudController::checkServer(const QUrl &url)
{
setWorking(true);
......@@ -64,7 +64,7 @@ void NextcloudController::dataReceived(KIO::Job *job, const QByteArray &data)
m_json.append(data);
}
void NextcloudController::fileChecked(KJob* job)
void NextcloudController::fileChecked(KJob *job)
{
KIO::TransferJob *kJob = qobject_cast<KIO::TransferJob *>(job);
if (kJob->error()) {
......@@ -78,7 +78,7 @@ void NextcloudController::fileChecked(KJob* job)
wrongUrlDetected();
return;
}
QUrl url = KIO::upUrl(kJob->url());
m_server = url.toString();
......@@ -97,10 +97,10 @@ void NextcloudController::wrongUrlDetected()
Q_EMIT errorMessageChanged();
}
// Open Webview for nextcloud login.
// Open Webview for nextcloud login.
void NextcloudController::finalUrlHandler(const QUrl &url){
void NextcloudController::finalUrlHandler(const QUrl &url)
{
// To fetch m_username and m_password from final url
QString finalURLtoString = url.toString();
int username_ini_pos = finalURLtoString.indexOf("&user:") + 6;
......@@ -113,7 +113,7 @@ void NextcloudController::finalUrlHandler(const QUrl &url){
username.replace(position, 3, "@");
m_username = username;
m_password = password;
m_password = password;
serverCheckResult();
}
......@@ -140,17 +140,17 @@ void NextcloudController::serverCheckResult()
url.setPath(url.path() + '/' + "remote.php/webdav");
// Send a basic PROPFIND command to test access
const QString requestStr = QStringLiteral(
"<d:propfind xmlns:d=\"DAV:\">"
"<d:prop>"
"<d:current-user-principal />"
"</d:prop>"
"</d:propfind>");
"<d:propfind xmlns:d=\"DAV:\">"
"<d:prop>"
"<d:current-user-principal />"
"</d:prop>"
"</d:propfind>");
KIO::DavJob *job = KIO::davPropFind(url, QDomDocument(requestStr), "1", KIO::HideProgressInfo);
connect(job, &KIO::DavJob::finished, this, &NextcloudController::authCheckResult);
connect(job, &KIO::DavJob::data, this, &NextcloudController::dataReceived);
QVariantMap metadata{{"cookies","none"}, {"no-cache",true}};
QVariantMap metadata{{"cookies", "none"}, {"no-cache", true}};
job->setMetaData(metadata);
job->setUiDelegate(0);
......@@ -161,7 +161,7 @@ void NextcloudController::serverCheckResult()
void NextcloudController::authCheckResult(KJob *job)
{
KIO::DavJob *kJob = qobject_cast<KIO::DavJob*>(job);
KIO::DavJob *kJob = qobject_cast<KIO::DavJob *>(job);
if (kJob->isErrorPage()) {
m_errorMessage = i18n("Unable to authenticate using the provided username and password");
......@@ -212,8 +212,6 @@ void NextcloudController::finish(const QStringList disabledServices)
QVariantList NextcloudController::availableServices() const
{
// TODO Find a way to not hardcode this
return {
QVariant::fromValue(Service{QStringLiteral("nextcloud-contacts"), i18n("Contacts"), i18n("Synchronize contacts")}),
QVariant::fromValue(Service{QStringLiteral("nextcloud-storage"), i18n("Storage"), i18n("Integrate into file manager")})
};
return {QVariant::fromValue(Service{QStringLiteral("nextcloud-contacts"), i18n("Contacts"), i18n("Synchronize contacts")}),
QVariant::fromValue(Service{QStringLiteral("nextcloud-storage"), i18n("Storage"), i18n("Integrate into file manager")})};
}
......@@ -9,14 +9,14 @@
#define QMLHELPER_H
#include <QObject>
#include <QQuickWebEngineProfile>
#include <QStringList>
#include <QVariant>
#include <QWebEngineUrlRequestInterceptor>
#include <QQuickWebEngineProfile>
namespace KIO
{
class Job;
class Job;
};
class KJob;
......@@ -34,7 +34,6 @@ public:
QString m_description;
};
class NextcloudUrlIntercepter : public QWebEngineUrlRequestInterceptor
{
void interceptRequest(QWebEngineUrlRequestInfo &info) override;
......@@ -51,7 +50,6 @@ class NextcloudController : public QObject
Q_PROPERTY(QVariantList availableServices READ availableServices CONSTANT)
public:
enum State {
ServerUrl = 0,
WebLogin,
......@@ -102,7 +100,6 @@ private:
QQuickWebEngineProfile *m_webengineProfile;
NextcloudUrlIntercepter m_urlIntercepter;
QString m_loginUrl;
};
#endif // QMLHELPER_H
......@@ -8,11 +8,11 @@
#include "owncloud.h"
#include "owncloudcontroller.h"
#include <KLocalizedString>
#include <KDeclarative/QmlObject>
#include <KLocalizedString>
#include <QQmlEngine>
#include <QQmlContext>
#include <QQmlEngine>
#include <QWindow>
OwnCloudWizard::OwnCloudWizard(QObject *parent)
......@@ -28,7 +28,6 @@ OwnCloudWizard::~OwnCloudWizard()
void OwnCloudWizard::init(KAccountsUiPlugin::UiType type)
{
if (type == KAccountsUiPlugin::NewAccountDialog) {
const QString packagePath("org.kde.kaccounts.owncloud");
m_object = new KDeclarative::QmlObject();
......@@ -58,7 +57,6 @@ void OwnCloudWizard::init(KAccountsUiPlugin::UiType type)
Q_EMIT uiReady();
}
}
void OwnCloudWizard::setProviderName(const QString &providerName)
......
......@@ -8,13 +8,14 @@
#ifndef OWNCLOUD_H
#define OWNCLOUD_H
#include <QUrl>
#include <QHash>
#include <QUrl>
#include <kaccountsuiplugin.h>
namespace KDeclarative {
class QmlObject;
namespace KDeclarative
{
class QmlObject;
}
class OwnCloudWizard : public KAccountsUiPlugin
......@@ -38,4 +39,4 @@ private:
KDeclarative::QmlObject *m_object;
};
#endif //OWNCLOUD_H
#endif // OWNCLOUD_H
......@@ -6,21 +6,21 @@
#include "owncloudcontroller.h"
#include <KIO/Job>
#include <KIO/DavJob>
#include <kio/global.h>
#include <KIO/Job>
#include <KLocalizedString>
#include <kio/global.h>
#include <QDebug>
#include <QJsonDocument>
#include <QJsonObject>
#include <QDebug>
#include "../cloudurls.h"
OwncloudController::OwncloudController(QObject *parent)
: QObject(parent),
m_errorMessage(QString()),
m_isWorking(false)
: QObject(parent)
, m_errorMessage(QString())
, m_isWorking(false)
{
}
......@@ -45,11 +45,11 @@ void OwncloudController::checkServer(const QUrl &url)
setWorking(true);
KIO::TransferJob *job = KIO::get(url, KIO::NoReload, KIO::HideProgressInfo);
job->setUiDelegate(0);
connect(job, SIGNAL(data(KIO::Job*,QByteArray)), SLOT(dataReceived(KIO::Job*,QByteArray)));
connect(job, SIGNAL(finished(KJob*)), this, SLOT(fileChecked(KJob*)));
connect(job, SIGNAL(data(KIO::Job *, QByteArray)), SLOT(dataReceived(KIO::Job *, QByteArray)));
connect(job, SIGNAL(finished(KJob *)), this, SLOT(fileChecked(KJob *)));
}
void OwncloudController::figureOutServer(const QUrl& url)
void OwncloudController::figureOutServer(const QUrl &url)
{
if (/*url == QLatin1String("/") ||*/ url.isEmpty()) {
serverCheckResult(false);
......@@ -77,7 +77,7 @@ void OwncloudController::dataReceived(KIO::Job *job, const QByteArray &data)
m_json.append(data);
}
void OwncloudController::fileChecked(KJob* job)
void OwncloudController::fileChecked(KJob *job)
{
KIO::TransferJob *kJob = qobject_cast<KIO::TransferJob *>(job);
if (kJob->error()) {
......@@ -142,10 +142,10 @@ void OwncloudController::serverCheckResult(bool result)
"</d:propfind>");
KIO::DavJob *job = KIO::davPropFind(url, QDomDocument(requestStr), "1", KIO::HideProgressInfo);
connect(job, SIGNAL(finished(KJob*)), this, SLOT(authCheckResult(KJob*)));
connect(job, SIGNAL(data(KIO::Job*,QByteArray)), SLOT(dataReceived(KIO::Job*,QByteArray)));
connect(job, SIGNAL(finished(KJob *)), this, SLOT(authCheckResult(KJob *)));
connect(job, SIGNAL(data(KIO::Job *, QByteArray)), SLOT(dataReceived(KIO::Job *, QByteArray)));
QVariantMap metadata{{"cookies","none"}, {"no-cache",true}};
QVariantMap metadata{{"cookies", "none"}, {"no-cache", true}};
job->setMetaData(metadata);
job->setUiDelegate(0);
......@@ -153,7 +153,6 @@ void OwncloudController::serverCheckResult(bool result)
}
Q_EMIT errorMessageChanged();
}
void OwncloudController::authCheckResult(KJob *job)
......@@ -163,7 +162,7 @@ void OwncloudController::authCheckResult(KJob *job)
qDebug() << job->errorText();
}
KIO::DavJob *kJob = qobject_cast<KIO::DavJob*>(job);
KIO::DavJob *kJob = qobject_cast<KIO::DavJob *>(job);
qDebug() << "Auth job finished, received error page:" << kJob->isErrorPage();
if (kJob->isErrorPage()) {
......@@ -219,7 +218,5 @@ void OwncloudController::cancel()
QVariantList OwncloudController::availableServices() const
{
// TODO Find a way to not hardcode this
return {
QVariant::fromValue(Service{QStringLiteral("owncloud-storage"), i18n("Storage"), i18n("Storage integration")})
};
return {QVariant::fromValue(Service{QStringLiteral("owncloud-storage"), i18n("Storage"), i18n("Storage integration")})};
}
......@@ -13,7 +13,7 @@
namespace KIO
{
class Job;
class Job;
};
class KJob;
......@@ -30,7 +30,6 @@ public:
QString m_description;
};
class OwncloudController : public QObject
{
Q_OBJECT
......@@ -40,10 +39,9 @@ class OwncloudController : public QObject
Q_PROPERTY(QVariantList availableServices READ availableServices CONSTANT)
public:
enum State {
Server = 0,
Services
Services,
};
Q_ENUM(State)
......@@ -84,7 +82,6 @@ private:
QStringList m_disabledServices;
bool m_isWorking;
State m_state = Server;
};
#endif // QMLHELPER_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment