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

Rename qmlhelper to (own|next)cloudcontroller

Qmlhelper is a rather bad name, *Controller is slightly better.
parent 79d4cd7d
set(nextcloud_plugin_kaccounts_SRCS set(nextcloud_plugin_kaccounts_SRCS
nextcloud.cpp nextcloud.cpp
qmlhelper.cpp nextcloudcontroller.cpp
) )
add_library(nextcloud_plugin_kaccounts MODULE add_library(nextcloud_plugin_kaccounts MODULE
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
*/ */
#include "nextcloud.h" #include "nextcloud.h"
#include "qmlhelper.h" #include "nextcloudcontroller.h"
#include <KLocalizedString> #include <KLocalizedString>
#include <KDeclarative/QmlObject> #include <KDeclarative/QmlObject>
...@@ -35,9 +35,9 @@ void NextcloudWizard::init(KAccountsUiPlugin::UiType type) ...@@ -35,9 +35,9 @@ void NextcloudWizard::init(KAccountsUiPlugin::UiType type)
m_object->setInitializationDelayed(true); m_object->setInitializationDelayed(true);
m_object->loadPackage(packagePath); m_object->loadPackage(packagePath);
QmlHelper *helper = new QmlHelper(m_object); NextcloudController *helper = new NextcloudController(m_object);
connect(helper, &QmlHelper::wizardFinished, this, &NextcloudWizard::success); connect(helper, &NextcloudController::wizardFinished, this, &NextcloudWizard::success);
connect(helper, &QmlHelper::wizardFinished, [=] { connect(helper, &NextcloudController::wizardFinished, [=] {
QWindow *window = qobject_cast<QWindow *>(m_object->rootObject()); QWindow *window = qobject_cast<QWindow *>(m_object->rootObject());
if (window) { if (window) {
window->close(); window->close();
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
* *
* SPDX-License-Identifier: GPL-2.0-or-later * SPDX-License-Identifier: GPL-2.0-or-later
*/ */
#include "qmlhelper.h"
#include "nextcloudcontroller.h"
#include <KIO/Job> #include <KIO/Job>
#include <KIO/DavJob> #include <KIO/DavJob>
...@@ -21,16 +22,16 @@ ...@@ -21,16 +22,16 @@
#include <QFileSystemWatcher> #include <QFileSystemWatcher>
#include <QDesktopServices> #include <QDesktopServices>
QmlHelper::QmlHelper(QObject *parent) NextcloudController::NextcloudController(QObject *parent)
: QObject(parent) : QObject(parent)
{ {
} }
QmlHelper::~QmlHelper() NextcloudController::~NextcloudController()
{ {
} }
void QmlHelper::checkServer(const QString &path) void NextcloudController::checkServer(const QString &path)
{ {
m_errorMessage.clear(); m_errorMessage.clear();
Q_EMIT errorMessageChanged(); Q_EMIT errorMessageChanged();
...@@ -54,22 +55,22 @@ void QmlHelper::checkServer(const QString &path) ...@@ -54,22 +55,22 @@ void QmlHelper::checkServer(const QString &path)
} }
//To check if url is correct //To check if url is correct
void QmlHelper::checkServer(const QUrl &url) void NextcloudController::checkServer(const QUrl &url)
{ {
setWorking(true); setWorking(true);
KIO::TransferJob *job = KIO::get(url, KIO::NoReload, KIO::HideProgressInfo); KIO::TransferJob *job = KIO::get(url, KIO::NoReload, KIO::HideProgressInfo);
job->setUiDelegate(0); job->setUiDelegate(0);
connect(job, &KIO::DavJob::data, this, &QmlHelper::dataReceived); connect(job, &KIO::DavJob::data, this, &NextcloudController::dataReceived);
connect(job, &KIO::DavJob::finished, this, &QmlHelper::fileChecked); connect(job, &KIO::DavJob::finished, this, &NextcloudController::fileChecked);
} }
void QmlHelper::dataReceived(KIO::Job *job, const QByteArray &data) void NextcloudController::dataReceived(KIO::Job *job, const QByteArray &data)
{ {
Q_UNUSED(job); Q_UNUSED(job);
m_json.append(data); m_json.append(data);
} }
void QmlHelper::fileChecked(KJob* job) void NextcloudController::fileChecked(KJob* job)
{ {
KIO::TransferJob *kJob = qobject_cast<KIO::TransferJob *>(job); KIO::TransferJob *kJob = qobject_cast<KIO::TransferJob *>(job);
if (kJob->error()) { if (kJob->error()) {
...@@ -92,7 +93,7 @@ void QmlHelper::fileChecked(KJob* job) ...@@ -92,7 +93,7 @@ void QmlHelper::fileChecked(KJob* job)
} }
// When url entered by user is wrong // When url entered by user is wrong
void QmlHelper::wrongUrlDetected() void NextcloudController::wrongUrlDetected()
{ {
m_noError = false; m_noError = false;
Q_EMIT noErrorChanged(); Q_EMIT noErrorChanged();
...@@ -104,7 +105,7 @@ void QmlHelper::wrongUrlDetected() ...@@ -104,7 +105,7 @@ void QmlHelper::wrongUrlDetected()
// Open Webview for nextcloud login. // Open Webview for nextcloud login.
// Document for login flow : https://docs.nextcloud.com/server/stable/developer_manual/client_apis/LoginFlow/index.html // Document for login flow : https://docs.nextcloud.com/server/stable/developer_manual/client_apis/LoginFlow/index.html
void QmlHelper::openWebView() void NextcloudController::openWebView()
{ {
QWebEngineHttpRequest request; QWebEngineHttpRequest request;
// set proper headers // set proper headers
...@@ -129,7 +130,7 @@ void QmlHelper::openWebView() ...@@ -129,7 +130,7 @@ void QmlHelper::openWebView()
m_view->resize(424, 650); m_view->resize(424, 650);
} }
void QmlHelper::finalUrlHandler(const QUrl &url){ void NextcloudController::finalUrlHandler(const QUrl &url){
m_finalUrl = url; m_finalUrl = url;
m_view->close(); m_view->close();
delete m_view; delete m_view;
...@@ -151,7 +152,7 @@ void QmlHelper::finalUrlHandler(const QUrl &url){ ...@@ -151,7 +152,7 @@ void QmlHelper::finalUrlHandler(const QUrl &url){
serverCheckResult(); serverCheckResult();
} }
void QmlHelper::setWorking(bool start) void NextcloudController::setWorking(bool start)
{ {
if (start == m_isWorking) { if (start == m_isWorking) {
return; return;
...@@ -161,7 +162,7 @@ void QmlHelper::setWorking(bool start) ...@@ -161,7 +162,7 @@ void QmlHelper::setWorking(bool start)
Q_EMIT isWorkingChanged(); Q_EMIT isWorkingChanged();
} }
void QmlHelper::serverCheckResult() void NextcloudController::serverCheckResult()
{ {
m_noError = true; m_noError = true;
Q_EMIT noErrorChanged(); Q_EMIT noErrorChanged();
...@@ -182,8 +183,8 @@ void QmlHelper::serverCheckResult() ...@@ -182,8 +183,8 @@ void QmlHelper::serverCheckResult()
"</d:propfind>"); "</d:propfind>");
KIO::DavJob *job = KIO::davPropFind(url, QDomDocument(requestStr), "1", KIO::HideProgressInfo); KIO::DavJob *job = KIO::davPropFind(url, QDomDocument(requestStr), "1", KIO::HideProgressInfo);
connect(job, &KIO::DavJob::finished, this, &QmlHelper::authCheckResult); connect(job, &KIO::DavJob::finished, this, &NextcloudController::authCheckResult);
connect(job, &KIO::DavJob::data, this, &QmlHelper::dataReceived); connect(job, &KIO::DavJob::data, this, &NextcloudController::dataReceived);
QVariantMap metadata{{"cookies","none"}, {"no-cache",true}}; QVariantMap metadata{{"cookies","none"}, {"no-cache",true}};
...@@ -194,7 +195,7 @@ void QmlHelper::serverCheckResult() ...@@ -194,7 +195,7 @@ void QmlHelper::serverCheckResult()
Q_EMIT errorMessageChanged(); Q_EMIT errorMessageChanged();
} }
void QmlHelper::authCheckResult(KJob *job) void NextcloudController::authCheckResult(KJob *job)
{ {
KIO::DavJob *kJob = qobject_cast<KIO::DavJob*>(job); KIO::DavJob *kJob = qobject_cast<KIO::DavJob*>(job);
...@@ -213,27 +214,27 @@ void QmlHelper::authCheckResult(KJob *job) ...@@ -213,27 +214,27 @@ void QmlHelper::authCheckResult(KJob *job)
setWorking(false); setWorking(false);
} }
bool QmlHelper::isWorking() bool NextcloudController::isWorking()
{ {
return m_isWorking; return m_isWorking;
} }
bool QmlHelper::noError() bool NextcloudController::noError()
{ {
return m_noError; return m_noError;
} }
QString QmlHelper::errorMessage() const QString NextcloudController::errorMessage() const
{ {
return m_errorMessage; return m_errorMessage;
} }
bool QmlHelper::isLoginComplete() bool NextcloudController::isLoginComplete()
{ {
return m_isLoginComplete; return m_isLoginComplete;
} }
void QmlHelper::finish(bool contactsEnabled) void NextcloudController::finish(bool contactsEnabled)
{ {
QVariantMap data; QVariantMap data;
data.insert("server", m_server); data.insert("server", m_server);
......
...@@ -22,7 +22,7 @@ namespace KIO ...@@ -22,7 +22,7 @@ namespace KIO
class KJob; class KJob;
class QmlHelper : public QObject class NextcloudController : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool isWorking READ isWorking NOTIFY isWorkingChanged) Q_PROPERTY(bool isWorking READ isWorking NOTIFY isWorkingChanged)
...@@ -31,8 +31,8 @@ class QmlHelper : public QObject ...@@ -31,8 +31,8 @@ class QmlHelper : public QObject
Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorMessageChanged) Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorMessageChanged)
public: public:
QmlHelper(QObject *parent = 0); NextcloudController(QObject *parent = 0);
~QmlHelper(); ~NextcloudController();
Q_INVOKABLE void checkServer(const QString &server); Q_INVOKABLE void checkServer(const QString &server);
Q_INVOKABLE void finish(bool contactsEnabled); Q_INVOKABLE void finish(bool contactsEnabled);
......
...@@ -4,7 +4,7 @@ include_directories(${CMAKE_CURRENT_BUILD_DIR} ...@@ -4,7 +4,7 @@ include_directories(${CMAKE_CURRENT_BUILD_DIR}
set(owncloud_plugin_kaccounts_SRCS set(owncloud_plugin_kaccounts_SRCS
owncloud.cpp owncloud.cpp
qmlhelper.cpp owncloudcontroller.cpp
) )
add_library(owncloud_plugin_kaccounts MODULE add_library(owncloud_plugin_kaccounts MODULE
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
*/ */
#include "owncloud.h" #include "owncloud.h"
#include "qmlhelper.h" #include "owncloudcontroller.h"
#include <KLocalizedString> #include <KLocalizedString>
#include <KDeclarative/QmlObject> #include <KDeclarative/QmlObject>
...@@ -35,9 +35,9 @@ void OwnCloudWizard::init(KAccountsUiPlugin::UiType type) ...@@ -35,9 +35,9 @@ void OwnCloudWizard::init(KAccountsUiPlugin::UiType type)
m_object->setInitializationDelayed(true); m_object->setInitializationDelayed(true);
m_object->loadPackage(packagePath); m_object->loadPackage(packagePath);
QmlHelper *helper = new QmlHelper(m_object); OwncloudController *helper = new OwncloudController(m_object);
connect(helper, &QmlHelper::wizardFinished, this, &OwnCloudWizard::success); connect(helper, &OwncloudController::wizardFinished, this, &OwnCloudWizard::success);
connect(helper, &QmlHelper::wizardFinished, [=] { connect(helper, &OwncloudController::wizardFinished, [=] {
QWindow *window = qobject_cast<QWindow *>(m_object->rootObject()); QWindow *window = qobject_cast<QWindow *>(m_object->rootObject());
if (window) { if (window) {
window->close(); window->close();
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* SPDX-License-Identifier: GPL-2.0-or-later * SPDX-License-Identifier: GPL-2.0-or-later
*/ */
#include "qmlhelper.h" #include "owncloudcontroller.h"
#include <KIO/Job> #include <KIO/Job>
#include <KIO/DavJob> #include <KIO/DavJob>
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <QJsonObject> #include <QJsonObject>
#include <QDebug> #include <QDebug>
QmlHelper::QmlHelper(QObject *parent) OwncloudController::OwncloudController(QObject *parent)
: QObject(parent), : QObject(parent),
m_errorMessage(QString()), m_errorMessage(QString()),
m_isWorking(false), m_isWorking(false),
...@@ -23,11 +23,11 @@ QmlHelper::QmlHelper(QObject *parent) ...@@ -23,11 +23,11 @@ QmlHelper::QmlHelper(QObject *parent)
{ {
} }
QmlHelper::~QmlHelper() OwncloudController::~OwncloudController()
{ {
} }
void QmlHelper::checkServer(const QString &username, const QString &password, const QString &path) void OwncloudController::checkServer(const QString &username, const QString &password, const QString &path)
{ {
m_errorMessage.clear(); m_errorMessage.clear();
Q_EMIT errorMessageChanged(); Q_EMIT errorMessageChanged();
...@@ -56,7 +56,7 @@ void QmlHelper::checkServer(const QString &username, const QString &password, co ...@@ -56,7 +56,7 @@ void QmlHelper::checkServer(const QString &username, const QString &password, co
checkServer(url); checkServer(url);
} }
void QmlHelper::checkServer(const QUrl &url) void OwncloudController::checkServer(const QUrl &url)
{ {
qDebug() << "Checking for ownCloud instance at" << url; qDebug() << "Checking for ownCloud instance at" << url;
setWorking(true); setWorking(true);
...@@ -66,7 +66,7 @@ void QmlHelper::checkServer(const QUrl &url) ...@@ -66,7 +66,7 @@ void QmlHelper::checkServer(const QUrl &url)
connect(job, SIGNAL(finished(KJob*)), this, SLOT(fileChecked(KJob*))); connect(job, SIGNAL(finished(KJob*)), this, SLOT(fileChecked(KJob*)));
} }
void QmlHelper::figureOutServer(const QUrl& url) void OwncloudController::figureOutServer(const QUrl& url)
{ {
if (/*url == QLatin1String("/") ||*/ url.isEmpty()) { if (/*url == QLatin1String("/") ||*/ url.isEmpty()) {
serverCheckResult(false); serverCheckResult(false);
...@@ -88,13 +88,13 @@ void QmlHelper::figureOutServer(const QUrl& url) ...@@ -88,13 +88,13 @@ void QmlHelper::figureOutServer(const QUrl& url)
} }
} }
void QmlHelper::dataReceived(KIO::Job *job, const QByteArray &data) void OwncloudController::dataReceived(KIO::Job *job, const QByteArray &data)
{ {
Q_UNUSED(job); Q_UNUSED(job);
m_json.append(data); m_json.append(data);
} }
void QmlHelper::fileChecked(KJob* job) void OwncloudController::fileChecked(KJob* job)
{ {
KIO::TransferJob *kJob = qobject_cast<KIO::TransferJob *>(job); KIO::TransferJob *kJob = qobject_cast<KIO::TransferJob *>(job);
if (kJob->error()) { if (kJob->error()) {
...@@ -117,7 +117,7 @@ void QmlHelper::fileChecked(KJob* job) ...@@ -117,7 +117,7 @@ void QmlHelper::fileChecked(KJob* job)
serverCheckResult(true); serverCheckResult(true);
} }
void QmlHelper::setWorking(bool start) void OwncloudController::setWorking(bool start)
{ {
if (start == m_isWorking) { if (start == m_isWorking) {
return; return;
...@@ -127,7 +127,7 @@ void QmlHelper::setWorking(bool start) ...@@ -127,7 +127,7 @@ void QmlHelper::setWorking(bool start)
Q_EMIT isWorkingChanged(); Q_EMIT isWorkingChanged();
} }
void QmlHelper::serverCheckResult(bool result) void OwncloudController::serverCheckResult(bool result)
{ {
m_noError = result; m_noError = result;
Q_EMIT noErrorChanged(); Q_EMIT noErrorChanged();
...@@ -176,7 +176,7 @@ void QmlHelper::serverCheckResult(bool result) ...@@ -176,7 +176,7 @@ void QmlHelper::serverCheckResult(bool result)
} }
void QmlHelper::authCheckResult(KJob *job) void OwncloudController::authCheckResult(KJob *job)
{ {
if (job->error()) { if (job->error()) {
qDebug() << job->errorString(); qDebug() << job->errorString();
...@@ -199,22 +199,22 @@ void QmlHelper::authCheckResult(KJob *job) ...@@ -199,22 +199,22 @@ void QmlHelper::authCheckResult(KJob *job)
setWorking(false); setWorking(false);
} }
bool QmlHelper::isWorking() bool OwncloudController::isWorking()
{ {
return m_isWorking; return m_isWorking;
} }
bool QmlHelper::noError() bool OwncloudController::noError()
{ {
return m_noError; return m_noError;
} }
QString QmlHelper::errorMessage() const QString OwncloudController::errorMessage() const
{ {
return m_errorMessage; return m_errorMessage;
} }
void QmlHelper::finish(bool contactsEnabled) void OwncloudController::finish(bool contactsEnabled)
{ {
QVariantMap data; QVariantMap data;
data.insert("server", m_server); data.insert("server", m_server);
...@@ -230,5 +230,3 @@ void QmlHelper::finish(bool contactsEnabled) ...@@ -230,5 +230,3 @@ void QmlHelper::finish(bool contactsEnabled)
Q_EMIT wizardFinished(m_username, m_password, data); Q_EMIT wizardFinished(m_username, m_password, data);
} }
#include "qmlhelper.moc"
...@@ -16,7 +16,7 @@ namespace KIO ...@@ -16,7 +16,7 @@ namespace KIO
}; };
class KJob; class KJob;
class QmlHelper : public QObject class OwncloudController : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool isWorking READ isWorking NOTIFY isWorkingChanged) Q_PROPERTY(bool isWorking READ isWorking NOTIFY isWorkingChanged)
...@@ -24,8 +24,8 @@ class QmlHelper : public QObject ...@@ -24,8 +24,8 @@ class QmlHelper : public QObject
Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorMessageChanged) Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorMessageChanged)
public: public:
explicit QmlHelper(QObject *parent = 0); explicit OwncloudController(QObject *parent = 0);
~QmlHelper(); ~OwncloudController();
Q_INVOKABLE void checkServer(const QString &username, const QString &password, const QString &server); Q_INVOKABLE void checkServer(const QString &username, const QString &password, const QString &server);
Q_INVOKABLE void finish(bool contactsEnabled); Q_INVOKABLE void finish(bool contactsEnabled);
......
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