diff --git a/qml/harbour-nextcloudnotes.qml b/qml/harbour-nextcloudnotes.qml index c761498..4cb55f6 100644 --- a/qml/harbour-nextcloudnotes.qml +++ b/qml/harbour-nextcloudnotes.qml @@ -2,13 +2,22 @@ import QtQuick 2.2 import Sailfish.Silica 1.0 import Nemo.Configuration 1.0 import Nemo.Notifications 1.0 -import NextcloudApi 1.0 +import harbour.nextcloudapi 1.0 +import harbour.nextcloudapi.notes 1.0 import "pages" ApplicationWindow { id: appWindow + property var nextcloudApi: Nextcloud + property var notesApp: Notes + property NotesModel notesModel: notesApp.model() + + Component.onCompleted: { + //console.log("Current account: ", appSettings.currentAccount) + } + // General settings of the app ConfigurationGroup { id: appSettings @@ -30,10 +39,10 @@ ApplicationWindow } onSortByChanged: { - if (sortBy == "none") notesModel.invalidate() + if (sortBy == "none") Notes.model.invalidate() } onFavoritesOnTopChanged: { - notesModel.favoritesOnTop = favoritesOnTop + Notes.model.favoritesOnTop = favoritesOnTop } function createAccount(username, password, url, name) { @@ -52,7 +61,7 @@ ApplicationWindow return hash } function removeAccount(hash) { - notesApi.deleteAppPassword(appSettings.value("accounts/" + hash + "/password"), + Nextcloud.deleteAppPassword(appSettings.value("accounts/" + hash + "/password"), appSettings.value("accounts/" + hash + "/username"), appSettings.value("accounts/" + hash + "/url")) var tmpaccounts = accounts @@ -77,6 +86,10 @@ ApplicationWindow property string passowrd: value("password", "", String) property string name: value("name", "", String) property var update: value("update", new Date(0), Date) + + onUrlChanged: Nextcloud.server = url + onUsernameChanged: Nextcloud.username = username + onPassowrdChanged: Nextcloud.password = passowrd } ConfigurationGroup { @@ -119,10 +132,10 @@ ApplicationWindow id: autoSyncTimer interval: appSettings.autoSyncInterval * 1000 repeat: true - running: interval > 0 && notesApi.networkAccessible && appWindow.visible + running: interval > 0 && appSettings.currentAccount !== "" && Nextcloud.networkAccessible && appWindow.visible triggeredOnStart: true onTriggered: { - notesApi.getAllNotes() + Notes.getAllNotes() } onIntervalChanged: { if (interval > 0) { @@ -134,16 +147,6 @@ ApplicationWindow } } - Nextcloud { - id: notesApi - server: account.url - username: account.username - password: account.passowrd - } - - Component.onCompleted: { - } - Component.onDestruction: { offlineNotification.close() storeErrorNotification.close() diff --git a/qml/pages/EditPage.qml b/qml/pages/EditPage.qml index b0ee9e2..c32cdd7 100644 --- a/qml/pages/EditPage.qml +++ b/qml/pages/EditPage.qml @@ -113,7 +113,7 @@ Dialog { Repeater { id: categoryRepeater - model: notesApi.categories + model: Nextcloud.categories BackgroundItem { id: categoryBackground width: categoryRectangle.width diff --git a/qml/pages/LoginPage.qml b/qml/pages/LoginPage.qml index 8bb3cb6..ef9b741 100644 --- a/qml/pages/LoginPage.qml +++ b/qml/pages/LoginPage.qml @@ -1,7 +1,7 @@ import QtQuick 2.2 import Sailfish.Silica 1.0 import Nemo.Configuration 1.0 -import NextcloudApi 1.0 +import harbour.nextcloudapi 1.0 Dialog { id: loginDialog @@ -18,31 +18,31 @@ Dialog { property bool allowUnecrypted: false Component.onCompleted: { - appSettings.currentAccount = null + appSettings.currentAccount = "" } onRejected: { - notesApi.abortFlowV2Login() + Nextcloud.abortFlowV2Login() appSettings.currentAccount = peviousAccount } onAccepted: { - appSettings.createAccount(notesApi.username, notesApi.password, notesApi.server, notesApi.statusProductName) + appSettings.currentAccount = appSettings.createAccount(Nextcloud.username, Nextcloud.password, Nextcloud.server, Nextcloud.statusProductName) } Timer { id: verifyServerTimer - onTriggered: notesApi.getNcStatus() + onTriggered: Nextcloud.getStatus() } Connections { - target: notesApi + target: Nextcloud onStatusInstalledChanged: { - if (notesApi.statusInstalled) + if (Nextcloud.statusInstalled) serverField.focus = false } onStatusVersionChanged: { - if (notesApi.statusVersion) { - if (notesApi.statusVersion.split('.')[0] >= 16) { + if (Nextcloud.statusVersion) { + if (Nextcloud.statusVersion.split('.')[0] >= 16) { legacyLoginPossible = false flowLoginV2Possible = true console.log("Using Flow Login v2") @@ -58,48 +58,39 @@ Dialog { flowLoginV2Possible = false } } - onStatusProductNameChanged: { - if (notesApi.statusProductName) { - productName = notesApi.statusProductName - console.log(productName) - } - else { - productName = null - } - } onLoginStatusChanged: { loginDialog.canAccept = false apiProgressBar.indeterminate = false - switch(notesApi.loginStatus) { - case NotesApi.LoginLegacyReady: + switch(Nextcloud.loginStatus) { + case Nextcloud.LoginLegacyReady: console.log("LoginLegacyReady") apiProgressBar.label = qsTr("Enter your credentials") break; - case NotesApi.LoginFlowV2Initiating: + case Nextcloud.LoginFlowV2Initiating: console.log("LoginFlowV2Initiating") apiProgressBar.indeterminate = true break; - case NotesApi.LoginFlowV2Polling: + case Nextcloud.LoginFlowV2Polling: console.log("LoginFlowV2Polling") apiProgressBar.label = qsTr("Follow the instructions in the browser") apiProgressBar.indeterminate = true break; - case NotesApi.LoginFlowV2Success: + case Nextcloud.LoginFlowV2Success: console.log("LoginFlowV2Success") - notesApi.verifyLogin() + Nextcloud.verifyLogin() break; - case NotesApi.LoginFlowV2Failed: + case Nextcloud.LoginFlowV2Failed: console.log("LoginFlowV2Failed") apiProgressBar.label = qsTr("Login failed!") break - case NotesApi.LoginSuccess: + case Nextcloud.LoginSuccess: console.log("LoginSuccess") apiProgressBar.label = qsTr("Login successfull!") if (legacyLoginPossible || forceLegacyButton.checked) - notesApi.convertToAppPassword(); + Nextcloud.convertToAppPassword(); loginDialog.canAccept = true break; - case NotesApi.LoginFailed: + case Nextcloud.LoginFailed: console.log("LoginFailed") apiProgressBar.label = qsTr("Login failed!") break; @@ -109,8 +100,8 @@ Dialog { } } onLoginUrlChanged: { - if (notesApi.loginUrl) { - Qt.openUrlExternally(notesApi.loginUrl) + if (Nextcloud.loginUrl) { + Qt.openUrlExternally(Nextcloud.loginUrl) } } } @@ -142,9 +133,9 @@ Dialog { anchors.horizontalCenter: parent.horizontalCenter width: parent.width label: verifyServerTimer.running ? qsTr("Verifying address") : " " - indeterminate: notesApi.loginStatus === NotesApi.LoginFlowV2Initiating || - notesApi.loginStatus === NotesApi.LoginFlowV2Polling || - notesApi.ncStatusStatus === NotesApi.NextcloudBusy || + indeterminate: Nextcloud.loginStatus === Nextcloud.LoginFlowV2Initiating || + Nextcloud.loginStatus === Nextcloud.LoginFlowV2Polling || + Nextcloud.statusStatus === Nextcloud.NextcloudBusy || verifyServerTimer.running } @@ -153,16 +144,16 @@ Dialog { TextField { id: serverField width: parent.width - statusIcon.width - Theme.horizontalPageMargin - text: notesApi.server + text: Nextcloud.server placeholderText: qsTr("Enter Nextcloud address") - label: notesApi.statusProductName ? notesApi.statusProductName : qsTr("Nextcloud address") + label: Nextcloud.statusProductName ? Nextcloud.statusProductName : qsTr("Nextcloud address") validator: RegExpValidator { regExp: allowUnecrypted ? /^https?:\/\/([-a-zA-Z0-9@:%._\+~#=].*)/: /^https:\/\/([-a-zA-Z0-9@:%._\+~#=].*)/ } inputMethodHints: Qt.ImhUrlCharactersOnly onClicked: if (text === "") text = allowUnecrypted ? "http://" : "https://" onTextChanged: { loginDialog.canAccept = false if (acceptableInput) { - notesApi.server = text + Nextcloud.server = text verifyServerTimer.restart() } } @@ -171,27 +162,15 @@ Dialog { EnterKey.onClicked: { if (legacyLoginPossible) usernameField.focus = true - else if (flowLoginV2Possible && notesApi.loginStatus !== notesApi.LoginFlowV2Polling) - notesApi.initiateFlowV2Login() + else if (flowLoginV2Possible && Nextcloud.loginStatus !== Nextcloud.LoginFlowV2Polling) + Nextcloud.initiateFlowV2Login() focus = false } } Icon { id: statusIcon - source: notesApi.statusInstalled ? "image://theme/icon-m-accept" : "image://theme/icon-m-cancel" - color: notesApi.statusInstalled ? "green" : Theme.errorColor - } - } - - TextSwitch { - id: forceLegacyButton - visible: debug || !notesApi.statusInstalled - text: qsTr("Enforce legacy login") - automaticCheck: true - onCheckedChanged: { - if (!checked) { - notesApi.getNcStatus() - } + source: Nextcloud.statusInstalled ? "image://theme/icon-m-accept" : "image://theme/icon-m-cancel" + color: Nextcloud.statusInstalled ? "green" : Theme.errorColor } } @@ -204,8 +183,20 @@ Dialog { Behavior on opacity { FadeAnimator {} } Button { anchors.horizontalCenter: parent.horizontalCenter - text: notesApi.loginStatus === NotesApi.LoginFlowV2Polling ? qsTr("Abort") : notesApi.loginStatus === NotesApi.LoginSuccess ? qsTr("Re-Login") : qsTr("Login") - onClicked: notesApi.loginStatus === NotesApi.LoginFlowV2Polling ? notesApi.abortFlowV2Login() : notesApi.initiateFlowV2Login() + text: Nextcloud.loginStatus === Nextcloud.LoginFlowV2Polling ? qsTr("Abort") : Nextcloud.loginStatus === Nextcloud.LoginSuccess ? qsTr("Re-Login") : qsTr("Login") + onClicked: Nextcloud.loginStatus === Nextcloud.LoginFlowV2Polling ? Nextcloud.abortFlowV2Login() : Nextcloud.initiateFlowV2Login() + } + } + + TextSwitch { + id: forceLegacyButton + visible: debug || !Nextcloud.statusInstalled + text: qsTr("Enforce legacy login") + automaticCheck: true + onCheckedChanged: { + if (!checked) { + Nextcloud.getNcStatus() + } } } @@ -218,14 +209,14 @@ Dialog { TextField { id: usernameField width: parent.width - text: notesApi.username + text: Nextcloud.username placeholderText: qsTr("Enter Username") label: qsTr("Username") inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase errorHighlight: text.length === 0// && focus === true onTextChanged: { loginDialog.canAccept = false - notesApi.username = text + Nextcloud.username = text } EnterKey.enabled: text.length > 0 EnterKey.iconSource: "image://theme/icon-m-enter-next" @@ -234,22 +225,22 @@ Dialog { PasswordField { id: passwordField width: parent.width - text: notesApi.password + text: Nextcloud.password placeholderText: qsTr("Enter Password") label: qsTr("Password") errorHighlight: text.length === 0// && focus === true onTextChanged: { loginDialog.canAccept = false - notesApi.password = text + Nextcloud.password = text } EnterKey.enabled: text.length > 0 EnterKey.iconSource: "image://theme/icon-m-enter-accept" - EnterKey.onClicked: notesApi.verifyLogin() + EnterKey.onClicked: Nextcloud.verifyLogin() } Button { anchors.horizontalCenter: parent.horizontalCenter text: qsTr("Test Login") - onClicked: notesApi.verifyLogin(passwordField.text, usernameField.text, serverField.text) + onClicked: Nextcloud.verifyLogin(passwordField.text, usernameField.text, serverField.text) } } @@ -262,7 +253,7 @@ Dialog { wrapMode: Text.Wrap color: Theme.secondaryColor linkColor: Theme.secondaryHighlightColor - text: qsTr("The Notes app needs to be installed on the Nextcloud server for this app to work.") + text: qsTr("The Notes app needs to be installed on the Nextcloud server for this app to work.") } SectionHeader { @@ -281,7 +272,7 @@ Dialog { text: qsTr("Do not check certificates") description: qsTr("Enable this option to allow selfsigned certificates") onCheckedChanged: { - notesApi.verifySsl = !checked + Nextcloud.verifySsl = !checked } } TextSwitch { diff --git a/qml/pages/NotePage.qml b/qml/pages/NotePage.qml index cbff9ab..667b370 100644 --- a/qml/pages/NotePage.qml +++ b/qml/pages/NotePage.qml @@ -95,7 +95,7 @@ Dialog { onTriggered: pageStack.pop() } PullDownMenu { - busy: notesApi.busy + busy: Nextcloud.busy MenuItem { text: qsTr("Delete") @@ -103,7 +103,7 @@ Dialog { } MenuItem { text: enabled ? qsTr("Reload") : qsTr("Updating...") - enabled: !notesApi.busy + enabled: !Nextcloud.busy onClicked: notesModel.note(note["id"]) } /*MenuItem { @@ -130,7 +130,7 @@ Dialog { anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter size: BusyIndicatorSize.Medium - running: notesApi.busy + running: Nextcloud.busy } Column { @@ -194,7 +194,7 @@ Dialog { Repeater { id: categoryRepeater - model: notesApi.categories + model: Nextcloud.categories BackgroundItem { id: categoryBackground width: categoryRectangle.width diff --git a/qml/pages/NotesPage.qml b/qml/pages/NotesPage.qml index 3857a76..1e464b7 100644 --- a/qml/pages/NotesPage.qml +++ b/qml/pages/NotesPage.qml @@ -1,5 +1,6 @@ import QtQuick 2.2 import Sailfish.Silica 1.0 +import harbour.nextcloudapi 1.0 Page { id: page @@ -24,7 +25,7 @@ Page { spacing: Theme.paddingLarge PullDownMenu { - busy: notesApi.busy + busy: Nextcloud.busy MenuItem { text: qsTr("Settings") @@ -32,16 +33,18 @@ Page { } MenuItem { text: qsTr("Add note") - enabled: account !== null && notesApi.networkAccessible - onClicked: notesApi.createNote( { 'content': "", 'modified': new Date().valueOf() / 1000 } ) + visible: appSettings.currentAccount !== "" + enabled: Nextcloud.networkAccessible + onClicked: Nextcloud.createNote( { 'content': "", 'modified': new Date().valueOf() / 1000 } ) } MenuItem { - text: notesApi.networkAccessible && !notesApi.busy ? qsTr("Reload") : qsTr("Updating...") - enabled: account !== null && notesApi.networkAccessible && !notesApi.busy - onClicked: notesApi.getAllNotes() + text: Nextcloud.networkAccessible && !Nextcloud.busy ? qsTr("Reload") : qsTr("Updating...") + visible: appSettings.currentAccount !== "" + enabled: Nextcloud.networkAccessible && !Nextcloud.busy + onClicked: Nextcloud.getAllNotes() } MenuLabel { - visible: account !== null + visible: appSettings.currentAccount !== "" text: qsTr("Last update") + ": " + ( new Date(account.update).valueOf() !== 0 ? new Date(account.update).toLocaleString(Qt.locale(), Locale.ShortFormat) : @@ -55,11 +58,11 @@ Page { id: searchField width: parent.width enabled: !busyIndicator.running && !noLoginPlaceholder.enabled && !errorPlaceholder.enabled && !noNotesPlaceholder.enabled - placeholderText: notesApi.statusProductName.length > 0 ? notesApi.statusProductName : account.name.length > 0 ? account.name : qsTr("Nextcloud Notes") + placeholderText: Nextcloud.statusProductName.length > 0 ? Nextcloud.statusProductName : account.name.length > 0 ? account.name : qsTr("Nextcloud Notes") EnterKey.iconSource: "image://theme/icon-m-enter-close" EnterKey.onClicked: focus = false onTextChanged: { - notesModel.searchFilter = text + Notes.model.searchFilter = text } } Label { @@ -71,14 +74,14 @@ Page { anchors.bottomMargin: Theme.paddingMedium color: Theme.secondaryHighlightColor font.pixelSize: Theme.fontSizeSmall - text: notesApi.username + "@" + notesApi.host + text: Nextcloud.username + "@" + Nextcloud.host } BusyIndicator { anchors.verticalCenter: searchField.verticalCenter anchors.right: parent.right anchors.rightMargin: Theme.horizontalPageMargin size: BusyIndicatorSize.Medium - running: notesApi.busy && !busyIndicator.running + running: Nextcloud.busy && !busyIndicator.running } } @@ -120,7 +123,7 @@ Page { icon.source: (favorite ? "image://theme/icon-m-favorite-selected?" : "image://theme/icon-m-favorite?") + (note.highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor) onClicked: { - notesModel.setNote({ 'favorite': !favorite }) + Notes.model.setNote({ 'favorite': !favorite }) } } @@ -190,7 +193,7 @@ Page { text: qsTr("Delete") onClicked: { remorse.execute(note, qsTr("Deleting note"), function() { - notesModel.deleteNote(id) + Notes.model.deleteNote(id) }) } } @@ -208,7 +211,7 @@ Page { id: busyIndicator anchors.centerIn: parent size: BusyIndicatorSize.Large - running: notesList.count === 0 && notesApi.busy + running: notesList.count === 0 && Nextcloud.busy } Label { id: busyLabel @@ -231,14 +234,14 @@ Page { ViewPlaceholder { id: noNotesPlaceholder - enabled: notesApi.status === 204 && !busyIndicator.running && !noLoginPlaceholder.enabled + enabled: Nextcloud.status === 204 && !busyIndicator.running && !noLoginPlaceholder.enabled text: qsTr("No notes yet") hintText: qsTr("Pull down to add a note") } ViewPlaceholder { id: noSearchPlaceholder - enabled: notesList.count === 0 && notesModel.searchFilter !== "" //notesModel.filterRegExp !== "" + enabled: notesList.count === 0 && notesModel.searchFilter !== "" //Notes.model.filterRegExp !== "" text: qsTr("No result") hintText: qsTr("Try another query") } @@ -247,7 +250,7 @@ Page { id: errorPlaceholder enabled: notesList.count === 0 && !busyIndicator.running && !noSearchPlaceholder.enabled && !noNotesPlaceholder.enabled && !noLoginPlaceholder.enabled text: qsTr("An error occurred") - //hintText: notesApi.statusText + //hintText: Nextcloud.statusText } TouchInteractionHint { diff --git a/qml/pages/SettingsPage.qml b/qml/pages/SettingsPage.qml index d7ef555..13d88c0 100644 --- a/qml/pages/SettingsPage.qml +++ b/qml/pages/SettingsPage.qml @@ -123,7 +123,9 @@ Page { } } onCurrentIndexChanged: { - appSettings.autoSyncInterval = autoSyncIntervalRepeater.model[currentIndex] + if (autoSyncIntervalRepeater.model[currentIndex] !== appSettings.autoSyncInterval) { + appSettings.autoSyncInterval = autoSyncIntervalRepeater.model[currentIndex] + } if (autoSyncIntervalRepeater.model[currentIndex] === 42 && theAnswer.enabled) { console.log(theAnswer.body) theAnswer.publish() diff --git a/src/apps/abstractnextcloudapp.h b/src/apps/abstractnextcloudapp.h index 879cccd..9342e96 100644 --- a/src/apps/abstractnextcloudapp.h +++ b/src/apps/abstractnextcloudapp.h @@ -13,10 +13,10 @@ class AbstractNextcloudApp : public QObject { public: AbstractNextcloudApp(QObject *parent = nullptr, QString name = QString(), NextcloudApi* api = nullptr) : QObject(parent), m_appName(name), m_api(api) { - connect(this, SIGNAL(capabilitiesChanged), this, SLOT(updateCapabilities)); - connect(m_api, SIGNAL(capabilitiesChanged), this, SLOT(updateApiCapabilities)); - connect(this, SIGNAL(replyReceived), this, SLOT(updateReply)); - connect(m_api, SIGNAL(replyReceived), this, SLOT(updateApiReply)); + connect(this, SIGNAL(capabilitiesChanged(QJsonObject*)), this, SLOT(updateCapabilities(QJsonObject*))); + connect(m_api, SIGNAL(capabilitiesChanged(QJsonObject*)), this, SLOT(updateApiCapabilities(QJsonObject*))); + connect(this, SIGNAL(replyReceived(QNetworkReply*)), this, SLOT(updateReply(QNetworkReply*))); + connect(m_api, SIGNAL(apiFinished(QNetworkReply*)), this, SLOT(updateApiReply(QNetworkReply*))); } virtual ~AbstractNextcloudApp() { diff --git a/src/apps/notes/notesapp.h b/src/apps/notes/notesapp.h index 3ebc4b4..7bf7b84 100644 --- a/src/apps/notes/notesapp.h +++ b/src/apps/notes/notesapp.h @@ -32,7 +32,7 @@ public: static AbstractNextcloudApp & getInstance(); static QObject * provider(QQmlEngine *, QJSEngine *); - const QSortFilterProxyModel* model() { return &m_notesProxy; } + Q_INVOKABLE NotesProxyModel* model() { return &m_notesProxy; } Q_INVOKABLE QVersionNumber serverVersion() const; Q_INVOKABLE QList apiVersions() const; @@ -47,7 +47,7 @@ public slots: //Q_INVOKABLE bool changeSettings(const QJsonObject& settings); protected slots: - void updateCapabilities(QJsonObject* json) { } + void updateCapabilities(QJsonObject*) { } void updateReply(QNetworkReply* reply); signals: diff --git a/src/apps/notes/notesmodel.cpp b/src/apps/notes/notesmodel.cpp index 60cab84..9dadc8f 100644 --- a/src/apps/notes/notesmodel.cpp +++ b/src/apps/notes/notesmodel.cpp @@ -302,7 +302,7 @@ Qt::ItemFlags NotesModel::flags(const QModelIndex &index) const { } } -int NotesModel::rowCount(const QModelIndex &parent) const { +int NotesModel::rowCount(const QModelIndex &) const { if (m_fileDir.exists() && !account().isEmpty()) { return static_cast(m_fileDir.count()); } diff --git a/src/harbour-nextcloudnotes.cpp b/src/harbour-nextcloudnotes.cpp index 7ad5eca..a48380a 100644 --- a/src/harbour-nextcloudnotes.cpp +++ b/src/harbour-nextcloudnotes.cpp @@ -20,9 +20,10 @@ int main(int argc, char *argv[]) AccountHash* accountHash = new AccountHash; NextcloudApi::instantiate(app); - qmlRegisterSingletonType("harbour.nextcloudnotes.nextcloudapi", 1, 0, "Nextcloud", NextcloudApi::provider); + qmlRegisterSingletonType("harbour.nextcloudapi", 1, 0, "Nextcloud", NextcloudApi::provider); NotesApp::instantiate(&NextcloudApi::getInstance(), &NextcloudApi::getInstance()); - qmlRegisterSingletonType("harbour.nextcloudnotes.nextcloudapi", 1, 0, "Notes", NotesApp::provider); + qmlRegisterSingletonType("harbour.nextcloudapi.notes", 1, 0, "Notes", NotesApp::provider); + qmlRegisterType("harbour.nextcloudapi.notes", 1, 0, "NotesModel"); //qmlRegisterType("NextcloudApi", 1, 0, "Nextcloud"); //qmlRegisterType("NextcloudApi", 1, 0, "Notes"); diff --git a/src/nextcloudapi.cpp b/src/nextcloudapi.cpp index 0d74775..aff493a 100644 --- a/src/nextcloudapi.cpp +++ b/src/nextcloudapi.cpp @@ -12,7 +12,7 @@ NextcloudApi::NextcloudApi(QObject *parent) : QObject(parent) setUserMetaStatus(ApiCallStatus::ApiUnknown); // Verify URL - connect(this, SIGNAL(urlChanged(QUrl)), this, SLOT(verifyUrl(QUrl))); + connect(this, SIGNAL(urlChanged(QUrl*)), this, SLOT(verifyUrl(QUrl*))); // Login Flow V2 poll timer m_loginPollTimer.setInterval(LOGIN_FLOWV2_POLL_INTERVALL); @@ -259,7 +259,7 @@ bool NextcloudApi::initiateFlowV2Login() { if (m_loginStatus == LoginStatus::LoginFlowV2Initiating || m_loginStatus == LoginStatus::LoginFlowV2Polling) { abortFlowV2Login(); } - if (post(LOGIN_FLOWV2_ENDPOINT, QByteArray(), false)) { + if (post(LOGIN_FLOWV2_ENDPOINT, QByteArray(), ReplyJSON, false)) { setLoginStatus(LoginStatus::LoginFlowV2Initiating); return true; } @@ -327,7 +327,7 @@ void NextcloudApi::onNetworkAccessibleChanged(QNetworkAccessManager::NetworkAcce } bool NextcloudApi::pollLoginUrl() { - if (post(m_pollUrl.path(), QByteArray("token=").append(m_pollToken), false)) { + if (post(m_pollUrl.path(), QByteArray("token=").append(m_pollToken), ReplyJSON, false)) { setLoginStatus(LoginStatus::LoginFlowV2Polling); return true; } @@ -350,6 +350,7 @@ void NextcloudApi::replyFinished(QNetworkReply* reply) { if (reply->error() != QNetworkReply::NoError) qDebug() << reply->error() << reply->errorString(); + qDebug() << reply->url().toDisplayString(); QByteArray data = reply->readAll(); QJsonDocument json = QJsonDocument::fromJson(data); //qDebug() << data; @@ -367,7 +368,7 @@ void NextcloudApi::replyFinished(QNetworkReply* reply) { qDebug() << "App password received"; updateAppPassword(json.object()); } - else if (reply->url().toString().contains(USER_METADATA_ENDPOINT)) { + else if (reply->url().toString().contains(QString(USER_METADATA_ENDPOINT).remove(QRegExp("/%[0-9]")))) { qDebug() << "User metadata for" << reply->url().toString().split('/').last() << "received"; updateUserMeta(json.object()); } @@ -545,7 +546,7 @@ bool NextcloudApi::updateAppPassword(const QJsonObject &json) { return false; } -bool NextcloudApi::deleteAppPassword(const QJsonObject &json) { +bool NextcloudApi::deleteAppPassword(const QJsonObject &) { setPassword(QString()); return true; } diff --git a/translations/harbour-nextcloudnotes-de.ts b/translations/harbour-nextcloudnotes-de.ts index dcf728d..affd663 100644 --- a/translations/harbour-nextcloudnotes-de.ts +++ b/translations/harbour-nextcloudnotes-de.ts @@ -182,10 +182,6 @@ Note Achtung - - The <a href="https://apps.nextcloud.com/apps/notes">Notes</a> app needs to be installed on the Nextcloud server for this app to work. - Die <a href="https://apps.nextcloud.com/apps/notes">Notes</a> Applikation muss auf dem Nextcloud-Server installiert sein, damit diese App funktioniert. - Re-Login Neu einloggen @@ -214,6 +210,10 @@ Enter Password + + The <a href="https://apps.Nextcloud.com/apps/notes">Notes</a> app needs to be installed on the Nextcloud server for this app to work. + + MITLicense diff --git a/translations/harbour-nextcloudnotes-sv.ts b/translations/harbour-nextcloudnotes-sv.ts index 655be11..ee3307b 100644 --- a/translations/harbour-nextcloudnotes-sv.ts +++ b/translations/harbour-nextcloudnotes-sv.ts @@ -182,10 +182,6 @@ Note - - The <a href="https://apps.nextcloud.com/apps/notes">Notes</a> app needs to be installed on the Nextcloud server for this app to work. - - Re-Login @@ -214,6 +210,10 @@ Enter Password + + The <a href="https://apps.Nextcloud.com/apps/notes">Notes</a> app needs to be installed on the Nextcloud server for this app to work. + + MITLicense diff --git a/translations/harbour-nextcloudnotes.ts b/translations/harbour-nextcloudnotes.ts index 3c82577..462abe8 100644 --- a/translations/harbour-nextcloudnotes.ts +++ b/translations/harbour-nextcloudnotes.ts @@ -138,123 +138,123 @@ LoginPage - + Nextcloud Login - + Username - + Password - + Abort - + Follow the instructions in the browser - + Login successfull! - - + + Login failed! - + Enter your credentials - + Nextcloud address - + Verifying address - + Enter Nextcloud address - + Enforce legacy login - + Login - + Re-Login - + Enter Username - + Enter Password - + Test Login - + Note - - The <a href="https://apps.nextcloud.com/apps/notes">Notes</a> app needs to be installed on the Nextcloud server for this app to work. + + The <a href="https://apps.Nextcloud.com/apps/notes">Notes</a> app needs to be installed on the Nextcloud server for this app to work. - + Security - + <strong>CAUTION: Your password will be saved without any encryption on the device!</strong><br>Please consider creating a dedicated app password! Open your Nextcloud in a browser and go to <i>Settings</i> → <i>Security</i>. - + Do not check certificates - + Enable this option to allow selfsigned certificates - + Allow unencrypted connections @@ -275,32 +275,32 @@ NextcloudApi - + No error - + No network connection available - + Failed to communicate with the Nextcloud server - + An error occured while establishing an encrypted connection - + Could not authenticate to the Nextcloud instance - + Unknown error @@ -308,12 +308,12 @@ Note - + Today - + Yesterday @@ -374,32 +374,32 @@ NotesApi - + No error - + No network connection available - + Failed to communicate with the Nextcloud server - + An error occured while establishing an encrypted connection - + Could not authenticate to the Nextcloud instance - + Unknown error @@ -407,97 +407,97 @@ NotesPage - + Settings - + Add note - + Reload - + Updating... - + Last update - + never - + Nextcloud Notes - + Modified - + Delete - + Deleting note - + Loading notes... - + No account yet - + Got to the settings to add an account - + No notes yet - + Pull down to add a note - + No result - + Try another query - + An error occurred - + Open the settings to configure your Nextcloud accounts @@ -585,122 +585,122 @@ - + The Answer is 42 - + Congratulation you found the Answer to the Ultimate Question of Life, The Universe, and Everything! - + Appearance - + No sorting - + Favorites on top - + Show notes marked as favorite above the others - + Reset - + Reset app settings - + Cleared app data - + Resetting the app wipes all application data from the device! This includes offline synced notes, app settings and accounts. - + Last edited - + Category - + Title alphabetically - + Sort notes by - + This will also change how the notes are grouped - + Show separator - + Show a separator line between the notes - + lines - + Number of lines in the preview - + Editing - + Monospaced font - + Use a monospeced font to edit a note - + Capital 'X' in checkboxes - + For interoperability with other apps such as Joplin @@ -912,27 +912,27 @@ You can also use other markdown syntax inside them. harbour-nextcloudnotes - + Notes - + Offline - + Synced - + API error - + File error