Began implementing OCS capabilities
This commit is contained in:
parent
640286afe9
commit
47ed45a3cc
2 changed files with 44 additions and 11 deletions
|
@ -491,6 +491,47 @@ QUrl NotesApi::apiEndpointUrl(const QString endpoint) const {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NotesApi::updateCapabilities(const QJsonObject &capabilities) {
|
||||||
|
QJsonValue ocsValue = capabilities.value("ocs");
|
||||||
|
if (!ocsValue.isUndefined() && ocsValue.isObject()) {
|
||||||
|
QJsonObject ocsObject = ocsValue.toObject();
|
||||||
|
QJsonValue metaValue = ocsObject.value("meta");
|
||||||
|
if (!metaValue.isUndefined() && metaValue.isObject()) {
|
||||||
|
QJsonObject metaObject = metaValue.toObject();
|
||||||
|
if (metaObject.value("status").toString() == "ok") {
|
||||||
|
QJsonValue dataValue = ocsObject.value("data");
|
||||||
|
if (!dataValue.isUndefined() && dataValue.isObject()) {
|
||||||
|
QJsonObject dataObject = dataValue.toObject();
|
||||||
|
QJsonValue capabilitiesValue = dataObject.value("capabilities");
|
||||||
|
if (!capabilitiesValue.isUndefined() && capabilitiesValue.isObject()) {
|
||||||
|
QJsonObject capabilitiesObject = capabilitiesValue.toObject();
|
||||||
|
QJsonValue notesValue = capabilitiesObject.value("notes");
|
||||||
|
if (!notesValue.isUndefined() && notesValue.isObject()) {
|
||||||
|
QJsonObject notesObject = notesValue.toObject();
|
||||||
|
QJsonValue api_versionsValue = notesObject.value("api_versions");
|
||||||
|
if (!api_versionsValue.isUndefined() && api_versionsValue.isArray()) {
|
||||||
|
QJsonArray api_versions = api_versionsValue.toArray();
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotesApi::setCababilitiesStatus(CapabilitiesStatus status, bool *changed) {
|
||||||
|
if (status != m_capabilitiesStatus) {
|
||||||
|
if (changed)
|
||||||
|
*changed = true;
|
||||||
|
m_capabilitiesStatus = status;
|
||||||
|
emit capabilitiesStatusChanged(m_capabilitiesStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NotesApi::updateNcStatus(const QJsonObject &status) {
|
void NotesApi::updateNcStatus(const QJsonObject &status) {
|
||||||
bool tmpStatus = status.value("installed").toBool();
|
bool tmpStatus = status.value("installed").toBool();
|
||||||
if (m_status_installed != tmpStatus) {
|
if (m_status_installed != tmpStatus) {
|
||||||
|
@ -534,15 +575,6 @@ void NotesApi::updateNcStatus(const QJsonObject &status) {
|
||||||
setNcStatusStatus(NextcloudStatus::NextcloudSuccess);
|
setNcStatusStatus(NextcloudStatus::NextcloudSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotesApi::setCababilitiesStatus(CapabilitiesStatus status, bool *changed) {
|
|
||||||
if (status != m_capabilitiesStatus) {
|
|
||||||
if (changed)
|
|
||||||
*changed = true;
|
|
||||||
m_capabilitiesStatus = status;
|
|
||||||
emit capabilitiesStatusChanged(m_capabilitiesStatus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void NotesApi::setNcStatusStatus(NextcloudStatus status, bool *changed) {
|
void NotesApi::setNcStatusStatus(NextcloudStatus status, bool *changed) {
|
||||||
if (status != m_ncStatusStatus) {
|
if (status != m_ncStatusStatus) {
|
||||||
if (changed)
|
if (changed)
|
||||||
|
|
|
@ -25,8 +25,8 @@ class NotesApi : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// Generic API properties
|
// Generic API properties
|
||||||
Q_PROPERTY(bool verifySsl READ verifySsl WRITE setVerifySsl NOTIFY verifySslChanged)
|
Q_PROPERTY(bool verifySsl READ verifySsl WRITE setVerifySsl NOTIFY verifySslChanged) // to allow selfsigned certificates
|
||||||
Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
|
Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) // complete API URL = <scheme>://<username>:<password>@<host>[:<port>]/<path>
|
||||||
Q_PROPERTY(QString server READ server WRITE setServer NOTIFY serverChanged)
|
Q_PROPERTY(QString server READ server WRITE setServer NOTIFY serverChanged)
|
||||||
Q_PROPERTY(QString scheme READ scheme WRITE setScheme NOTIFY schemeChanged)
|
Q_PROPERTY(QString scheme READ scheme WRITE setScheme NOTIFY schemeChanged)
|
||||||
Q_PROPERTY(QString host READ host WRITE setHost NOTIFY hostChanged)
|
Q_PROPERTY(QString host READ host WRITE setHost NOTIFY hostChanged)
|
||||||
|
@ -231,6 +231,7 @@ private:
|
||||||
QNetworkRequest m_ocsRequest;
|
QNetworkRequest m_ocsRequest;
|
||||||
QUrl apiEndpointUrl(const QString endpoint) const;
|
QUrl apiEndpointUrl(const QString endpoint) const;
|
||||||
|
|
||||||
|
bool updateCapabilities(const QJsonObject & capabilities);
|
||||||
CapabilitiesStatus m_capabilitiesStatus;
|
CapabilitiesStatus m_capabilitiesStatus;
|
||||||
void setCababilitiesStatus(CapabilitiesStatus status, bool *changed = NULL);
|
void setCababilitiesStatus(CapabilitiesStatus status, bool *changed = NULL);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue