summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Klapetek <[email protected]>2015-09-18 11:09:02 -0400
committerMartin Klapetek <[email protected]>2015-09-18 11:09:02 -0400
commitfb841eccbb8872b31f2560daa264b797657e1d4e (patch)
tree3855043252786086a72f132f1b8ef009cb6506c2
parent5540a38866bcb6183a865994af6bfd6ceed9a80b (diff)
[owncloud] Minor refactor and cleanup
-rw-r--r--src/owncloud/package/contents/ui/BasicInfo.qml4
-rw-r--r--src/owncloud/qmlhelper.cpp24
-rw-r--r--src/owncloud/qmlhelper.h10
3 files changed, 21 insertions, 17 deletions
diff --git a/src/owncloud/package/contents/ui/BasicInfo.qml b/src/owncloud/package/contents/ui/BasicInfo.qml
index 6da4064..0f40958 100644
--- a/src/owncloud/package/contents/ui/BasicInfo.qml
+++ b/src/owncloud/package/contents/ui/BasicInfo.qml
@@ -26,7 +26,7 @@ import org.kde.plasma.extras 2.0 as PlasmaExtras
ColumnLayout {
id: basicInfoLayout
- property bool canContinue: helper.isServerValid && nameText.text.length > 0 && passwordText.text.length > 0
+ property bool canContinue: !helper.isWorking && helper.noError && nameText.text.length > 0 && passwordText.text.length > 0
Timer {
id: checkServerTimer
@@ -89,7 +89,7 @@ ColumnLayout {
height: width
anchors.centerIn: parent
source: "dialog-ok"
- visible: !helper.isWorking && helper.isServerValid && !errorLabel.visible
+ visible: !helper.isWorking && helper.noError && !errorLabel.visible
}
}
}
diff --git a/src/owncloud/qmlhelper.cpp b/src/owncloud/qmlhelper.cpp
index 1af667d..ce191e7 100644
--- a/src/owncloud/qmlhelper.cpp
+++ b/src/owncloud/qmlhelper.cpp
@@ -29,7 +29,7 @@
QmlHelper::QmlHelper(QObject *parent)
: QObject(parent),
m_isWorking(false),
- m_isServerValid(false),
+ m_noError(false),
m_errorMessage(QString())
{
}
@@ -80,7 +80,7 @@ void QmlHelper::checkServer(const QUrl &url)
void QmlHelper::figureOutServer(const QUrl& url)
{
if (/*url == QLatin1String("/") ||*/ url.isEmpty()) {
- setResult(false);
+ serverCheckResult(false);
return;
}
@@ -95,7 +95,7 @@ void QmlHelper::figureOutServer(const QUrl& url)
if (urlUp != url) {
checkServer(urlUp.adjusted(QUrl::NormalizePathSegments));
} else {
- setResult(false);
+ serverCheckResult(false);
}
}
@@ -125,7 +125,7 @@ void QmlHelper::fileChecked(KJob* job)
m_server = kJob->url().adjusted(QUrl::RemoveFilename).toString();
qDebug() << "ownCloud appears to be running at the specified URL";
- setResult(true);
+ serverCheckResult(true);
}
void QmlHelper::setWorking(bool start)
@@ -138,11 +138,10 @@ void QmlHelper::setWorking(bool start)
Q_EMIT isWorkingChanged();
}
-void QmlHelper::setResult(bool result)
+void QmlHelper::serverCheckResult(bool result)
{
-// setWorking(false);
- m_isServerValid = result;
- Q_EMIT isServerValidChanged();
+ m_noError = result;
+ Q_EMIT noErrorChanged();
if (!result) {
m_errorMessage = i18n("Unable to connect to ownCloud at the given server URL. Please check the server URL.");
@@ -152,6 +151,8 @@ void QmlHelper::setResult(bool result)
qDebug() << "Server URL ok, checking auth...";
+ m_json.clear();
+
QUrl url(m_server);
url.setUserName(m_username);
@@ -185,6 +186,9 @@ void QmlHelper::authCheckResult(KJob *job)
}
Q_EMIT errorMessageChanged();
+
+ m_noError = !kJob->isErrorPage();
+ Q_EMIT noErrorChanged();
setWorking(false);
}
@@ -193,9 +197,9 @@ bool QmlHelper::isWorking()
return m_isWorking;
}
-bool QmlHelper::isServerValid()
+bool QmlHelper::noError()
{
- return m_isServerValid;
+ return m_noError;
}
QString QmlHelper::errorMessage() const
diff --git a/src/owncloud/qmlhelper.h b/src/owncloud/qmlhelper.h
index 3730181..36be67a 100644
--- a/src/owncloud/qmlhelper.h
+++ b/src/owncloud/qmlhelper.h
@@ -33,7 +33,7 @@ class QmlHelper : public QObject
{
Q_OBJECT
Q_PROPERTY(bool isWorking READ isWorking NOTIFY isWorkingChanged)
- Q_PROPERTY(bool isServerValid READ isServerValid NOTIFY isServerValidChanged)
+ Q_PROPERTY(bool noError READ noError NOTIFY noErrorChanged)
Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorMessageChanged)
public:
@@ -43,12 +43,12 @@ public:
Q_INVOKABLE void checkServer(const QString &username, const QString &password, const QString &server);
Q_INVOKABLE void finish(bool contactsEnabled);
bool isWorking();
- bool isServerValid();
+ bool noError();
QString errorMessage() const;
Q_SIGNALS:
void isWorkingChanged();
- void isServerValidChanged();
+ void noErrorChanged();
void errorMessageChanged();
void wizardFinished(const QString &username, const QString &password, const QVariantMap &data);
@@ -61,7 +61,7 @@ private:
void checkServer(const QUrl &url);
void figureOutServer(const QUrl &url);
void setWorking(bool start);
- void setResult(bool result);
+ void serverCheckResult(bool result);
QByteArray m_json;
QString m_errorMessage;
@@ -70,7 +70,7 @@ private:
QString m_password;
QStringList m_disabledServices;
bool m_isWorking;
- bool m_isServerValid;
+ bool m_noError;
};