diff --git a/src/nextcloudapi.cpp b/src/nextcloudapi.cpp index 986631c..e03cc93 100644 --- a/src/nextcloudapi.cpp +++ b/src/nextcloudapi.cpp @@ -10,21 +10,14 @@ NextcloudApi::NextcloudApi(QObject *parent) : QObject(parent) setCababilitiesStatus(ApiCallStatus::ApiUnknown); setUserListStatus(ApiCallStatus::ApiUnknown); setUserMetaStatus(ApiCallStatus::ApiUnknown); - m_status_installed = false; - m_status_maintenance = false; - m_status_needsDbUpgrade = false; - m_status_extendedSupport = false; - // Add capabilities functions for server apps - m_appCapabilities["notes"] = &NextcloudApi::updateNoteCapabilities; + // Verify URL + connect(this, SIGNAL(urlChanged(QUrl)), this, SLOT(verifyUrl(QUrl))); // Login Flow V2 poll timer m_loginPollTimer.setInterval(LOGIN_FLOWV2_POLL_INTERVALL); connect(&m_loginPollTimer, SIGNAL(timeout()), this, SLOT(pollLoginUrl())); - // Verify URL - connect(this, SIGNAL(urlChanged(QUrl)), this, SLOT(verifyUrl(QUrl))); - // Listen to signals of the QNetworkAccessManager class connect(&m_manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), this, SLOT(requireAuthentication(QNetworkReply*,QAuthenticator*))); connect(&m_manager, SIGNAL(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility)), this, SLOT(onNetworkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility))); @@ -61,16 +54,13 @@ void NextcloudApi::setVerifySsl(bool verify) { void NextcloudApi::setUrl(QUrl url) { if (url != m_url) { - QString oldServer = server(); setScheme(url.scheme()); setHost(url.host()); setPort(url.port()); setUsername(url.userName()); setPassword(url.password()); setPath(url.path()); - if (server() != oldServer) - emit serverChanged(server()); - emit urlChanged(m_url); + emit urlChanged(&m_url); } } @@ -97,36 +87,28 @@ void NextcloudApi::setServer(QString serverUrl) { void NextcloudApi::setScheme(QString scheme) { if (scheme != m_url.scheme() && (scheme == "http" || scheme == "https")) { m_url.setScheme(scheme); - emit schemeChanged(m_url.scheme()); - emit serverChanged(server()); - emit urlChanged(m_url); + emit urlChanged(&m_url); } } void NextcloudApi::setHost(QString host) { if (host != m_url.host()) { m_url.setHost(host); - emit hostChanged(m_url.host()); - emit serverChanged(server()); - emit urlChanged(m_url); + emit urlChanged(&m_url); } } void NextcloudApi::setPort(int port) { if (port != m_url.port() && port >= 1 && port <= 65535) { m_url.setPort(port); - emit portChanged(m_url.port()); - emit serverChanged(server()); - emit urlChanged(m_url); + emit urlChanged(&m_url); } } void NextcloudApi::setPath(QString path) { if (path != m_url.path()) { m_url.setPath(path); - emit pathChanged(m_url.path()); - emit serverChanged(server()); - emit urlChanged(m_url); + emit urlChanged(&m_url); } } @@ -137,8 +119,7 @@ void NextcloudApi::setUsername(QString username) { QByteArray data = concatenated.toLocal8Bit().toBase64(); QString headerData = "Basic " + data; m_authenticatedRequest.setRawHeader("Authorization", headerData.toLocal8Bit()); - emit usernameChanged(m_url.userName()); - emit urlChanged(m_url); + emit urlChanged(&m_url); } } @@ -149,8 +130,7 @@ void NextcloudApi::setPassword(QString password) { QByteArray data = concatenated.toLocal8Bit().toBase64(); QString headerData = "Basic " + data; m_authenticatedRequest.setRawHeader("Authorization", headerData.toLocal8Bit()); - emit passwordChanged(m_url.password()); - emit urlChanged(m_url); + emit urlChanged(&m_url); } } @@ -299,36 +279,38 @@ void NextcloudApi::abortFlowV2Login() { } bool NextcloudApi::verifyLogin() { - return get(USER_METADATA_ENDPOINT.arg(username()), true); + return getUserMetaData(username()); } bool NextcloudApi::getAppPassword() { - return get(GET_APPPASSWORD_ENDPOINT, true); + return get(GET_APPPASSWORD_ENDPOINT); } bool NextcloudApi::deleteAppPassword() { - return del(DEL_APPPASSWORD_ENDPOINT, true); -} - -bool NextcloudApi::getUserList() { - return false; // TODO + return del(DEL_APPPASSWORD_ENDPOINT); } bool NextcloudApi::getUserMetaData(const QString& user) { - return false; // TODO + if (!user.isEmpty() || !username().isEmpty()) + return get(USER_METADATA_ENDPOINT.arg(user.isEmpty() ? username() : user)); + return false; +} + +bool NextcloudApi::getUserList() { + return get(LIST_USERS_ENDPOINT); } bool NextcloudApi::getCapabilities() { - return false; // TODO + return get(CAPABILITIES_ENDPOINT); } -void NextcloudApi::verifyUrl(QUrl url) { +void NextcloudApi::verifyUrl(QUrl *url) { emit urlValidChanged( - url.isValid()&& - !url.isRelative() && - !url.userName().isEmpty() && - !url.password().isEmpty() && - !url.host().isEmpty()); + url->isValid()&& + !url->isRelative() && + !url->userName().isEmpty() && + !url->password().isEmpty() && + !url->host().isEmpty()); } void NextcloudApi::requireAuthentication(QNetworkReply *reply, QAuthenticator *authenticator) { @@ -385,18 +367,22 @@ void NextcloudApi::replyFinished(QNetworkReply* reply) { qDebug() << "App password received"; updateAppPassword(json.object()); } - else if (reply->url().toString().endsWith(LIST_USERS_ENDPOINT)) { - qDebug() << "User list received"; - updateUserList(json.object()); - } else if (reply->url().toString().contains(USER_METADATA_ENDPOINT)) { qDebug() << "User metadata for" << reply->url().toString().split('/').last() << "received"; updateUserMeta(json.object()); } + else if (reply->url().toString().endsWith(LIST_USERS_ENDPOINT)) { + qDebug() << "User list received"; + updateUserList(json.object()); + } else if (reply->url().toString().endsWith(CAPABILITIES_ENDPOINT)) { qDebug() << "Capabilites received"; updateCapabilities(json.object()); } + else if (reply->url().toString().endsWith(USER_NOTIFICATION_ENDPOINT)) { + qDebug() << "Notifications are not yet implemented!"; + qDebug() << json.object().value("ocs").toObject().value("data").toArray(); + } else { qDebug() << "GET reply received"; emit getFinished(reply); @@ -407,7 +393,7 @@ void NextcloudApi::replyFinished(QNetworkReply* reply) { break; case QNetworkAccessManager::PutOperation: if (reply->url().toString().endsWith(DIRECT_DOWNLOAD_ENDPOINT)) { - qDebug() << "This function is not yet implemented!"; + qDebug() << "Direct download is not yet implemented!"; } else { qDebug() << "PUT reply received"; @@ -474,51 +460,20 @@ void NextcloudApi::replyFinished(QNetworkReply* reply) { } } +void NextcloudApi::setStatusStatus(ApiCallStatus status, bool *changed) { + if (status != m_statusStatus) { + m_statusStatus = status; + if (changed) *changed = true; + emit statusStatusChanged(m_statusStatus); + } +} + bool NextcloudApi::updateStatus(const QJsonObject &json) { - bool tmpBool; - QString tmpString; - QVersionNumber tmpVersion; if (!json.isEmpty()) { setStatusStatus(ApiSuccess); - tmpBool = json.value("installed").toBool(); - if (m_status_installed != tmpBool) { - m_status_installed = tmpBool; - emit statusInstalledChanged(m_status_installed); - } - tmpBool = json.value("maintenance").toBool(); - if (m_status_maintenance != tmpBool) { - m_status_maintenance = tmpBool; - emit statusMaintenanceChanged(m_status_maintenance); - } - tmpBool = json.value("needsDbUpgrade").toBool(); - if (m_status_needsDbUpgrade != tmpBool) { - m_status_needsDbUpgrade = tmpBool; - emit statusNeedsDbUpgradeChanged(m_status_needsDbUpgrade); - } - tmpVersion = QVersionNumber::fromString(json.value("version").toString()); - if (m_status_version != tmpVersion) { - m_status_version = tmpVersion; - emit statusVersionChanged(m_status_version.toString()); - } - tmpString = json.value("versionstring").toString(); - if (m_status_versionstring != tmpString) { - m_status_versionstring = tmpString; - emit statusVersionStringChanged(m_status_versionstring); - } - tmpString = json.value("edition").toString(); - if (m_status_edition != tmpString) { - m_status_edition = tmpString; - emit statusEditionChanged(m_status_edition); - } - tmpString = json.value("productname").toString(); - if (m_status_productname != tmpString) { - m_status_productname = tmpString; - emit statusProductNameChanged(m_status_productname); - } - tmpBool = json.value("extendedSupport").toBool(); - if (m_status_extendedSupport != tmpBool) { - m_status_extendedSupport = tmpBool; - emit statusExtendedSupportChanged(m_status_extendedSupport); + if (json != m_status) { + m_status = json; + emit statusChanged(); } return true; } @@ -528,11 +483,11 @@ bool NextcloudApi::updateStatus(const QJsonObject &json) { return false; } -void NextcloudApi::setStatusStatus(ApiCallStatus status, bool *changed) { - if (status != m_statusStatus) { - m_statusStatus = status; +void NextcloudApi::setLoginStatus(LoginStatus status, bool *changed) { + if (status != m_loginStatus) { + m_loginStatus = status; if (changed) *changed = true; - emit statusStatusChanged(m_statusStatus); + emit loginStatusChanged(m_loginStatus); } } @@ -546,7 +501,7 @@ bool NextcloudApi::updateLoginFlow(const QJsonObject &json) { if (m_pollUrl.isValid() && !m_pollToken.isEmpty() && loginUrl.isValid()) { if (m_loginUrl != loginUrl) { m_loginUrl = loginUrl; - emit loginUrlChanged(m_loginUrl); + emit loginUrlChanged(&m_loginUrl); } setLoginStatus(LoginStatus::LoginFlowV2Polling); m_loginPollTimer.start(); @@ -595,13 +550,47 @@ bool NextcloudApi::updateAppPassword(const QJsonObject &json) { bool NextcloudApi::deleteAppPassword(const QJsonObject &json) { setPassword(QString()); + return true; } -void NextcloudApi::setLoginStatus(LoginStatus status, bool *changed) { - if (status != m_loginStatus) { - m_loginStatus = status; +void NextcloudApi::setUserMetaStatus(ApiCallStatus status, bool *changed) { + if (status != m_userMetaStatus) { + m_userMetaStatus = status; if (changed) *changed = true; - emit loginStatusChanged(m_loginStatus); + emit userMetaStatusChanged(m_userMetaStatus); + } +} + +bool NextcloudApi::updateUserMeta(const QJsonObject &json) { + QJsonObject ocs = json.value("ocs").toObject(); + QJsonObject meta = ocs.value("meta").toObject(); + QJsonObject data = ocs.value("data").toObject(); + QString user = data.value("id").toString(); + if (!user.isEmpty() && user == username()) { + setLoginStatus(LoginSuccess); + } + if (meta.value("statuscode").toInt() == 100) { + setUserMetaStatus(ApiSuccess); + if (!data.isEmpty() && data != m_userMeta[user]) { + m_userMeta[user] = data; + emit userMetaChanged(user); + } + return true; + } + else if (meta.value("statuscode").toInt() == 404) { + setUserMetaStatus(ApiSuccess); + m_userMeta.remove(user); + return true; + } + setUserMetaStatus(ApiFailed); + return false; +} + +void NextcloudApi::setUserListStatus(ApiCallStatus status, bool *changed) { + if (status != m_userListStatus) { + m_userListStatus = status; + if (changed) *changed = true; + emit userListStatusChanged(m_userListStatus); } } @@ -621,7 +610,7 @@ bool NextcloudApi::updateUserList(const QJsonObject &json) { if (userList != m_userList && !userList.isEmpty()) { setUserListStatus(ApiSuccess); m_userList = userList; - emit userListChanged(m_userList); + emit userListChanged(&m_userList); } return true; } @@ -629,62 +618,6 @@ bool NextcloudApi::updateUserList(const QJsonObject &json) { return false; } -void NextcloudApi::setUserListStatus(ApiCallStatus status, bool *changed) { - -} - -bool NextcloudApi::updateUserMeta(const QJsonObject &json) { - -} - -void NextcloudApi::setUserMetaStatus(ApiCallStatus status, bool *changed) { - -} - -bool NextcloudApi::updateCapabilities(const QJsonObject &json) { - QJsonObject ocs = json.value("ocs").toObject(); - QJsonObject data = ocs.value("data").toObject(); - QJsonObject preCapabilities = m_capabilities; - QJsonObject newCapabilities = data.value("capabilities").toObject(); - if (!newCapabilities.isEmpty()) { - setCababilitiesStatus(ApiSuccess); - if (newCapabilities != preCapabilities) { - m_capabilities = newCapabilities; - - QStringList apps = newCapabilities.keys(); - QStringList::const_iterator app; - for (app = apps.constBegin(); app != apps.constEnd(); ++app) { - if (m_appCapabilities.contains(*app)) { - qDebug() << "Updating \"" << *app << "\" capabilities"; - (this->*m_appCapabilities[*app])(newCapabilities.value(*app).toObject(), preCapabilities.value(*app).toObject()); - } - else { - qDebug() << "Capabilities for " << *app << " not implemented!"; - } - } - } - return true; - } - setCababilitiesStatus(ApiFailed); - return false; -} - -void NextcloudApi::updateNoteCapabilities(const QJsonObject &newObject, const QJsonObject &preObject) { - qDebug() << "Updating \"notes\" capabilities"; - if (newObject.isEmpty() != preObject.isEmpty()) - emit notesAppInstalledChanged(notesAppInstalled()); - - QStringList preVersions; - QJsonArray preApiVersion = preObject.value("api_version").toArray(); - QJsonArray::const_iterator i; - for (i = preApiVersion.constBegin(); i != preApiVersion.constEnd(); ++i) { - if (i->isString()) - preVersions << i->toString(); - } - if (preVersions != notesAppApiVersions()) - emit notesAppApiVersionsChanged(notesAppApiVersions()); -} - void NextcloudApi::setCababilitiesStatus(ApiCallStatus status, bool *changed) { if (status != m_capabilitiesStatus) { m_capabilitiesStatus = status; @@ -692,3 +625,20 @@ void NextcloudApi::setCababilitiesStatus(ApiCallStatus status, bool *changed) { emit capabilitiesStatusChanged(m_capabilitiesStatus); } } + +bool NextcloudApi::updateCapabilities(const QJsonObject &json) { + QJsonObject ocs = json.value("ocs").toObject(); + QJsonObject data = ocs.value("data").toObject(); + QJsonObject capabilities = data.value("capabilities").toObject(); + // TODO update version + if (!capabilities.isEmpty()) { + setCababilitiesStatus(ApiSuccess); + if (capabilities != m_capabilities) { + m_capabilities = capabilities; + emit capabilitiesChanged(&m_capabilities); + } + return true; + } + setCababilitiesStatus(ApiFailed); + return false; +} diff --git a/src/nextcloudapi.h b/src/nextcloudapi.h index b3902ce..e5a5075 100644 --- a/src/nextcloudapi.h +++ b/src/nextcloudapi.h @@ -18,11 +18,11 @@ const QString STATUS_ENDPOINT("/status.php"); // OCS APIs endpoints // https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-api-overview.html -const QString CAPABILITIES_ENDPOINT("/ocs/v2.php/cloud/capabilities"); -const QString LIST_USERS_ENDPOINT("/ocs/v2.php/cloud/users"); const QString USER_METADATA_ENDPOINT("/ocs/v2.php/cloud/users/%1"); -const QString USER_NOTIFICATION_ENDPOINT("/ocs/v2.php/apps/notifications/api/v2/notifications"); +const QString LIST_USERS_ENDPOINT("/ocs/v2.php/cloud/users"); +const QString CAPABILITIES_ENDPOINT("/ocs/v2.php/cloud/capabilities"); const QString DIRECT_DOWNLOAD_ENDPOINT("/ocs/v2.php/apps/dav/api/v1/direct"); +const QString USER_NOTIFICATION_ENDPOINT("/ocs/v2.php/apps/notifications/api/v2/notifications"); // Login Flow endpoints // https://docs.nextcloud.com/server/latest/developer_manual/client_apis/LoginFlow/index.html @@ -42,14 +42,14 @@ class NextcloudApi : public QObject // Generic API properties Q_PROPERTY(bool verifySsl READ verifySsl WRITE setVerifySsl NOTIFY verifySslChanged) // to allow selfsigned certificates Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) // complete nextcloud URL = ://:@[:]/ - Q_PROPERTY(QString server READ server WRITE setServer NOTIFY serverChanged) // url without username and password = ://[:]/ + Q_PROPERTY(QString server READ server WRITE setServer NOTIFY urlChanged) // url without username and password = ://[:]/ // the following properties will update the url and server properties and vice versa - Q_PROPERTY(QString scheme READ scheme WRITE setScheme NOTIFY schemeChanged) - Q_PROPERTY(QString host READ host WRITE setHost NOTIFY hostChanged) - Q_PROPERTY(int port READ port WRITE setPort NOTIFY portChanged) - Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged) - Q_PROPERTY(QString username READ username WRITE setUsername NOTIFY usernameChanged) - Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged) + Q_PROPERTY(QString scheme READ scheme WRITE setScheme NOTIFY urlChanged) + Q_PROPERTY(QString host READ host WRITE setHost NOTIFY urlChanged) + Q_PROPERTY(int port READ port WRITE setPort NOTIFY urlChanged) + Q_PROPERTY(QString path READ path WRITE setPath NOTIFY urlChanged) + Q_PROPERTY(QString username READ username WRITE setUsername NOTIFY urlChanged) + Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY urlChanged) // Networking status information Q_PROPERTY(bool ready READ ready NOTIFY readyChanged) // when all needed properties are set @@ -59,14 +59,14 @@ class NextcloudApi : public QObject // Nextcloud status (status.php), these properties will be automatically updated on changes of the generic properties Q_PROPERTY(ApiCallStatus statusStatus READ statusStatus NOTIFY statusStatusChanged) - Q_PROPERTY(bool statusInstalled READ statusInstalled NOTIFY statusInstalledChanged) - Q_PROPERTY(bool statusMaintenance READ statusMaintenance NOTIFY statusMaintenanceChanged) - Q_PROPERTY(bool statusNeedsDbUpgrade READ statusNeedsDbUpgrade NOTIFY statusNeedsDbUpgradeChanged) - Q_PROPERTY(QString statusVersion READ statusVersion NOTIFY statusVersionChanged) - Q_PROPERTY(QString statusVersionString READ statusVersionString NOTIFY statusVersionStringChanged) - Q_PROPERTY(QString statusEdition READ statusEdition NOTIFY statusEditionChanged) - Q_PROPERTY(QString statusProductName READ statusProductName NOTIFY statusProductNameChanged) - Q_PROPERTY(bool statusExtendedSupport READ statusExtendedSupport NOTIFY statusExtendedSupportChanged) + Q_PROPERTY(bool statusInstalled READ statusInstalled NOTIFY statusChanged) + Q_PROPERTY(bool statusMaintenance READ statusMaintenance NOTIFY statusChanged) + Q_PROPERTY(bool statusNeedsDbUpgrade READ statusNeedsDbUpgrade NOTIFY statusChanged) + Q_PROPERTY(QString statusVersion READ statusVersion NOTIFY statusChanged) + Q_PROPERTY(QString statusVersionString READ statusVersionString NOTIFY statusChanged) + Q_PROPERTY(QString statusEdition READ statusEdition NOTIFY statusChanged) + Q_PROPERTY(QString statusProductName READ statusProductName NOTIFY statusChanged) + Q_PROPERTY(bool statusExtendedSupport READ statusExtendedSupport NOTIFY statusChanged) // Login status Q_PROPERTY(LoginStatus loginStatus READ loginStatus NOTIFY loginStatusChanged) @@ -81,8 +81,8 @@ class NextcloudApi : public QObject // Nextcloud capabilities Q_PROPERTY(ApiCallStatus capabilitiesStatus READ capabilitiesStatus NOTIFY capabilitiesStatusChanged) - Q_PROPERTY(bool notesAppInstalled READ notesAppInstalled NOTIFY notesAppInstalledChanged) - Q_PROPERTY(QStringList notesAppApiVersions READ notesAppApiVersions NOTIFY notesAppApiVersionsChanged) + Q_PROPERTY(bool notesAppInstalled READ notesAppInstalled NOTIFY capabilitiesChanged) + Q_PROPERTY(QStringList notesAppApiVersions READ notesAppApiVersions NOTIFY capabilitiesChanged) // TODO other property for server capabilities public: @@ -145,14 +145,14 @@ public: // Nextcloud status (status.php) ApiCallStatus statusStatus() const { return m_statusStatus; } - bool statusInstalled() const { return m_status_installed; } - bool statusMaintenance() const { return m_status_maintenance; } - bool statusNeedsDbUpgrade() const { return m_status_needsDbUpgrade; } - QString statusVersion() const { return m_status_version.toString(); } - QString statusVersionString() const { return m_status_versionstring; } - QString statusEdition() const { return m_status_edition; } - QString statusProductName() const { return m_status_productname; } - bool statusExtendedSupport() const { return m_status_extendedSupport; } + bool statusInstalled() const { return m_status.value("installed").toBool(); } + bool statusMaintenance() const { return m_status.value("maintenance").toBool(); } + bool statusNeedsDbUpgrade() const { return m_status.value("needsDbUpgrade").toBool(); } + QString statusVersion() const { return m_status.value("version").toString(); } + QString statusVersionString() const { return m_status.value("versionstring").toString(); } + QString statusEdition() const { return m_status.value("edition").toString(); } + QString statusProductName() const { return m_status.value("productname").toString(); } + bool statusExtendedSupport() const { return m_status.value("extendedSupport").toBool(); } // Login status LoginStatus loginStatus() const { return m_loginStatus; } @@ -193,21 +193,14 @@ public slots: Q_INVOKABLE bool verifyLogin(); Q_INVOKABLE bool getAppPassword(); Q_INVOKABLE bool deleteAppPassword(); - Q_INVOKABLE bool getUserList(); Q_INVOKABLE bool getUserMetaData(const QString& user = QString()); + Q_INVOKABLE bool getUserList(); Q_INVOKABLE bool getCapabilities(); signals: // Generic API properties void verifySslChanged(bool verify); - void urlChanged(QUrl url); - void serverChanged(QString server); - void schemeChanged(QString scheme); - void hostChanged(QString host); - void portChanged(int port); - void pathChanged(QString path); - void usernameChanged(QString username); - void passwordChanged(QString password); + void urlChanged(QUrl* url); // Class status information void readyChanged(bool ready); @@ -217,29 +210,22 @@ signals: // Nextcloud status (status.php) void statusStatusChanged(ApiCallStatus status); - void statusInstalledChanged(bool installed); - void statusMaintenanceChanged(bool maintenance); - void statusNeedsDbUpgradeChanged(bool needsDbUpgrade); - void statusVersionChanged(QString version); - void statusVersionStringChanged(QString versionString); - void statusEditionChanged(QString edition); - void statusProductNameChanged(QString productName); - void statusExtendedSupportChanged(bool extendedSupport); + void statusChanged(); // Login status - void loginFlowV2PossibleChanged(bool loginV2possible); - void loginUrlChanged(QUrl url); void loginStatusChanged(LoginStatus status); + void loginFlowV2PossibleChanged(bool loginV2possible); + void loginUrlChanged(QUrl* url); // User(s) status - void userListStatusChanged(ApiCallStatus status); - void userListChanged(QStringList users); void userMetaStatusChanged(ApiCallStatus status); + void userMetaChanged(QString username); + void userListStatusChanged(ApiCallStatus status); + void userListChanged(QStringList* users); // Nextcloud capabilities void capabilitiesStatusChanged(ApiCallStatus status); - void notesAppInstalledChanged(bool installed); - void notesAppApiVersionsChanged(QStringList versions); + void capabilitiesChanged(QJsonObject* json); // API helper updates void getFinished(QNetworkReply* reply); @@ -249,7 +235,7 @@ signals: void apiError(ErrorCodes error); private slots: - void verifyUrl(QUrl url); + void verifyUrl(QUrl* url); void requireAuthentication(QNetworkReply * reply, QAuthenticator * authenticator); void onNetworkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility accessible); bool pollLoginUrl(); @@ -267,14 +253,7 @@ private: bool updateStatus(const QJsonObject &json); void setStatusStatus(ApiCallStatus status, bool *changed = NULL); ApiCallStatus m_statusStatus; - bool m_status_installed; - bool m_status_maintenance; - bool m_status_needsDbUpgrade; - QVersionNumber m_status_version; - QString m_status_versionstring; - QString m_status_edition; - QString m_status_productname; - bool m_status_extendedSupport; + QJsonObject m_status; // Nextcloud Login Flow v2 // https://docs.nextcloud.com/server/latest/developer_manual/client_apis/LoginFlow/index.html#login-flow-v2 @@ -289,22 +268,20 @@ private: QUrl m_pollUrl; QString m_pollToken; - // Nextcloud users list - bool updateUserList(const QJsonObject &json); - void setUserListStatus(ApiCallStatus status, bool *changed = NULL); - ApiCallStatus m_userListStatus; - QStringList m_userList; - // Nextcloud user metadata bool updateUserMeta(const QJsonObject &json); void setUserMetaStatus(ApiCallStatus status, bool *changed = NULL); ApiCallStatus m_userMetaStatus; QHash m_userMeta; + // Nextcloud users list + bool updateUserList(const QJsonObject &json); + void setUserListStatus(ApiCallStatus status, bool *changed = NULL); + ApiCallStatus m_userListStatus; + QStringList m_userList; + // Nextcloud capabilities bool updateCapabilities(const QJsonObject &json); - QMap m_appCapabilities; - void updateNoteCapabilities(const QJsonObject &newObject, const QJsonObject &preObject = QJsonObject()); void setCababilitiesStatus(ApiCallStatus status, bool *changed = NULL); ApiCallStatus m_capabilitiesStatus; QJsonObject m_capabilities; diff --git a/translations/harbour-nextcloudnotes.ts b/translations/harbour-nextcloudnotes.ts index 170c864..3c82577 100644 --- a/translations/harbour-nextcloudnotes.ts +++ b/translations/harbour-nextcloudnotes.ts @@ -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