From 6691439d2ad0c89cf3482eeae422fe0f55ccf3e7 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Tue, 18 Oct 2016 16:30:00 +0200 Subject: API rename: ::server* -> ::remote* These methods do not retrieve data about the server itself. Instead they present us with data of a remote rootfs snapshot that the server is hosting. Change-Id: If3102476121b204760880119231c1c95aacd729f Reviewed-by: Gatis Paeglis --- src/imports/pluginmain.cpp | 30 ++++++------ src/lib/qotaclient.cpp | 112 ++++++++++++++++++++++---------------------- src/lib/qotaclient.h | 22 ++++----- src/lib/qotaclient_p.h | 16 +++---- src/lib/qotaclientasync.cpp | 26 +++++----- src/lib/qotaclientasync_p.h | 8 ++-- 6 files changed, 107 insertions(+), 107 deletions(-) diff --git a/src/imports/pluginmain.cpp b/src/imports/pluginmain.cpp index 19f237d..d7dd28a 100644 --- a/src/imports/pluginmain.cpp +++ b/src/imports/pluginmain.cpp @@ -78,27 +78,27 @@ QT_BEGIN_NAMESPACE */ /*! - \qmlproperty string OTAClient::serverVersion + \qmlproperty string OTAClient::remoteVersion \readonly This is a convenience property that holds a string containing the system's version on a server. - \sa serverInfo + \sa remoteInfo */ /*! - \qmlproperty string OTAClient::serverDescription + \qmlproperty string OTAClient::remoteDescription \readonly This is a convenience property that holds a string containing the system's description on a server. - \sa serverInfo + \sa remoteInfo */ /*! - \qmlproperty string OTAClient::serverRevision + \qmlproperty string OTAClient::remoteRevision \readonly This property holds a string containing the system's revision on a server @@ -106,7 +106,7 @@ QT_BEGIN_NAMESPACE */ /*! - \qmlproperty string OTAClient::serverInfo + \qmlproperty string OTAClient::remoteInfo \readonly This property holds a JSON-formatted string containing OTA metadata for the @@ -159,24 +159,24 @@ QT_BEGIN_NAMESPACE */ /*! - \qmlmethod bool OTAClient::fetchServerInfo() + \qmlmethod bool OTAClient::fetchRemoteInfo() - \include qotaclient.cpp fetchserverinfo-description + \include qotaclient.cpp fetchremoteinfo-description - \sa fetchServerInfoFinished(), updateAvailable, serverInfo + \sa fetchRemoteInfoFinished(), updateAvailable, remoteInfo */ /*! - \qmlsignal OTAClient::fetchServerInfoFinished(bool success) + \qmlsignal OTAClient::fetchRemoteInfoFinished(bool success) - This is a notifier signal for fetchServerInfo(). The \a success argument + This is a notifier signal for fetchRemoteInfo(). The \a success argument indicates whether the operation was successful. */ /*! - \qmlsignal OTAClient::serverInfoChanged() + \qmlsignal OTAClient::remoteInfoChanged() - \include qotaclient.cpp serverinfochanged-description + \include qotaclient.cpp remoteinfochanged-description */ /*! @@ -184,7 +184,7 @@ QT_BEGIN_NAMESPACE \include qotaclient.cpp update-description - \sa updateFinished(), fetchServerInfo, restartRequired + \sa updateFinished(), fetchRemoteInfo, restartRequired */ /*! @@ -261,7 +261,7 @@ QT_BEGIN_NAMESPACE \readonly Holds a bool indicating the availability of a system update. This - information is cached; to update the local cache, call fetchServerInfo(). + information is cached; to update the local cache, call fetchRemoteInfo(). \sa update() */ diff --git a/src/lib/qotaclient.cpp b/src/lib/qotaclient.cpp index 131e202..7654cc3 100644 --- a/src/lib/qotaclient.cpp +++ b/src/lib/qotaclient.cpp @@ -77,15 +77,15 @@ static void updateInfoMembers(const QJsonDocument &json, QByteArray *info, QStri *description = root.value(QStringLiteral("description")).toString(QStringLiteral("unknown")); } -void QOTAClientPrivate::updateServerInfo(const QString &serverRev, const QJsonDocument &serverInfo) +void QOTAClientPrivate::updateRemoteInfo(const QString &remoteRev, const QJsonDocument &remoteInfo) { Q_Q(QOTAClient); - if (m_serverRev == serverRev) + if (m_remoteRev == remoteRev) return; - m_serverRev = serverRev; - updateInfoMembers(serverInfo, &m_serverInfo, &m_serverVersion, &m_serverDescription); - emit q->serverInfoChanged(); + m_remoteRev = remoteRev; + updateInfoMembers(remoteInfo, &m_remoteInfo, &m_remoteVersion, &m_remoteDescription); + emit q->remoteInfoChanged(); } bool QOTAClientPrivate::isReady() const @@ -105,7 +105,7 @@ void QOTAClientPrivate::refreshState() { Q_Q(QOTAClient); - bool updateAvailable = m_defaultRev != m_serverRev && m_serverRev != m_bootedRev; + bool updateAvailable = m_defaultRev != m_remoteRev && m_remoteRev != m_bootedRev; if (m_updateAvailable != updateAvailable) { m_updateAvailable = updateAvailable; emit q->updateAvailableChanged(m_updateAvailable); @@ -120,26 +120,26 @@ void QOTAClientPrivate::refreshState() void QOTAClientPrivate::initializeFinished(const QString &defaultRev, const QString &bootedRev, const QJsonDocument &bootedInfo, - const QString &serverRev, const QJsonDocument &serverInfo) + const QString &remoteRev, const QJsonDocument &remoteInfo) { Q_Q(QOTAClient); m_defaultRev = defaultRev; m_bootedRev = bootedRev; updateInfoMembers(bootedInfo, &m_bootedInfo, &m_bootedVersion, &m_bootedDescription); - updateServerInfo(serverRev, serverInfo); + updateRemoteInfo(remoteRev, remoteInfo); refreshState(); m_initialized = true; emit q->initializationFinished(); } -void QOTAClientPrivate::fetchServerInfoFinished(const QString &serverRev, const QJsonDocument &serverInfo, bool success) +void QOTAClientPrivate::fetchRemoteInfoFinished(const QString &remoteRev, const QJsonDocument &remoteInfo, bool success) { Q_Q(QOTAClient); if (success) { - updateServerInfo(serverRev, serverInfo); + updateRemoteInfo(remoteRev, remoteInfo); refreshState(); } - emit q->fetchServerInfoFinished(success); + emit q->fetchRemoteInfoFinished(success); } void QOTAClientPrivate::updateFinished(const QString &defaultRev, bool success) @@ -196,8 +196,8 @@ QString QOTAClientPrivate::version(QueryTarget target) const switch (target) { case QueryTarget::Booted: return m_bootedVersion.isEmpty() ? QStringLiteral("unknown") : m_bootedVersion; - case QueryTarget::Server: - return m_serverVersion.isEmpty() ? QStringLiteral("unknown") : m_serverVersion; + case QueryTarget::Remote: + return m_remoteVersion.isEmpty() ? QStringLiteral("unknown") : m_remoteVersion; case QueryTarget::Rollback: return m_rollbackVersion.isEmpty() ? QStringLiteral("unknown") : m_rollbackVersion; default: @@ -213,8 +213,8 @@ QByteArray QOTAClientPrivate::info(QueryTarget target) const switch (target) { case QueryTarget::Booted: return m_bootedInfo; - case QueryTarget::Server: - return m_serverInfo; + case QueryTarget::Remote: + return m_remoteInfo; case QueryTarget::Rollback: return m_rollbackInfo; default: @@ -230,8 +230,8 @@ QString QOTAClientPrivate::description(QueryTarget target) const switch (target) { case QueryTarget::Booted: return m_bootedDescription.isEmpty() ? QStringLiteral("unknown") : m_bootedDescription; - case QueryTarget::Server: - return m_serverDescription.isEmpty() ? QStringLiteral("unknown") : m_serverDescription; + case QueryTarget::Remote: + return m_remoteDescription.isEmpty() ? QStringLiteral("unknown") : m_remoteDescription; case QueryTarget::Rollback: return m_rollbackDescription.isEmpty() ? QStringLiteral("unknown") : m_rollbackDescription; default: @@ -247,8 +247,8 @@ QString QOTAClientPrivate::revision(QueryTarget target) const switch (target) { case QueryTarget::Booted: return m_bootedRev.isEmpty() ? QStringLiteral("unknown") : m_bootedRev; - case QueryTarget::Server: - return m_serverRev.isEmpty() ? QStringLiteral("unknown") : m_serverRev; + case QueryTarget::Remote: + return m_remoteRev.isEmpty() ? QStringLiteral("unknown") : m_remoteRev; case QueryTarget::Rollback: return m_rollbackRev.isEmpty() ? QStringLiteral("unknown") : m_rollbackRev; default: @@ -303,9 +303,9 @@ QString QOTAClientPrivate::revision(QueryTarget target) const */ /*! - \fn void QOTAClient::fetchServerInfoFinished(bool success) + \fn void QOTAClient::fetchRemoteInfoFinished(bool success) - A notifier signal for fetchServerInfo(). The \a success argument indicates + A notifier signal for fetchRemoteInfo(). The \a success argument indicates whether the operation was successful. */ @@ -324,12 +324,12 @@ QString QOTAClientPrivate::revision(QueryTarget target) const */ /*! - \fn void QOTAClient::serverInfoChanged() -//! [serverinfochanged-description] - Server info can change when calling fetchServerInfo(). If OTA metadata on - the server is different from the local cache, the local cache is updated + \fn void QOTAClient::remoteInfoChanged() +//! [remoteinfochanged-description] + Remote info can change when calling fetchRemoteInfo(). If OTA metadata on + the remote server is different from the local cache, the local cache is updated and this signal is emitted. -//! [serverinfochanged-description] +//! [remoteinfochanged-description] */ /*! @@ -392,7 +392,7 @@ QOTAClient::QOTAClient(QObject *parent) : QObject(parent), QOTAClientAsync *async = d->m_otaAsync.data(); // async finished handlers connect(async, &QOTAClientAsync::initializeFinished, d, &QOTAClientPrivate::initializeFinished); - connect(async, &QOTAClientAsync::fetchServerInfoFinished, d, &QOTAClientPrivate::fetchServerInfoFinished); + connect(async, &QOTAClientAsync::fetchRemoteInfoFinished, d, &QOTAClientPrivate::fetchRemoteInfoFinished); connect(async, &QOTAClientAsync::updateFinished, d, &QOTAClientPrivate::updateFinished); connect(async, &QOTAClientAsync::rollbackFinished, d, &QOTAClientPrivate::rollbackFinished); connect(async, &QOTAClientAsync::errorOccurred, d, &QOTAClientPrivate::errorOccurred); @@ -408,36 +408,36 @@ QOTAClient::~QOTAClient() } /*! -//! [fetchserverinfo-description] - Fetches OTA metadata from a server and updates the local cache. This +//! [fetchremoteinfo-description] + Fetches OTA metadata from a remote server and updates the local cache. This metadata contains information on what system version is available on a server. The cache is persistent as it is stored on the disk. This method is asynchronous and returns immediately. The return value holds whether the operation was started successfully. -//! [fetchserverinfo-description] +//! [fetchremoteinfo-description] - \sa fetchServerInfoFinished(), updateAvailable, serverInfo + \sa fetchRemoteInfoFinished(), updateAvailable, remoteInfo */ -bool QOTAClient::fetchServerInfo() const +bool QOTAClient::fetchRemoteInfo() const { Q_D(const QOTAClient); if (!d->isReady()) return false; - d->m_otaAsync->fetchServerInfo(); + d->m_otaAsync->fetchRemoteInfo(); return true; } /*! //! [update-description] - Fetches an OTA update from a server and performs the system update. + Fetches an OTA update from a remote and performs the system update. This method is asynchronous and returns immediately. The return value holds whether the operation was started successfully. //! [update-description] - \sa updateFinished(), fetchServerInfo(), restartRequired + \sa updateFinished(), fetchRemoteInfo(), restartRequired */ bool QOTAClient::update() const { @@ -445,7 +445,7 @@ bool QOTAClient::update() const if (!d->isReady() || !updateAvailable()) return false; - d->m_otaAsync->update(d->m_serverRev); + d->m_otaAsync->update(d->m_remoteRev); return true; } @@ -488,7 +488,7 @@ bool QOTAClient::otaEnabled() const Initialization is fast unless there is another process locking access to the OSTree repository on a device, for example, a daemon process calling - fetchServerInfo(). + fetchRemoteInfo(). //! [initialized-description] \sa initializationFinished() @@ -526,13 +526,13 @@ QString QOTAClient::statusString() const \brief whether a system update is available. This information is cached; to update the local cache, call - fetchServerInfo(). + fetchRemoteInfo(). */ bool QOTAClient::updateAvailable() const { Q_D(const QOTAClient); if (d->m_updateAvailable) - Q_ASSERT(!d->m_serverRev.isEmpty()); + Q_ASSERT(!d->m_remoteRev.isEmpty()); return d->m_updateAvailable; } @@ -568,7 +568,7 @@ bool QOTAClient::restartRequired() const This is a convenience method. - \sa clientInfo + \sa bootedInfo */ QString QOTAClient::bootedVersion() const { @@ -581,7 +581,7 @@ QString QOTAClient::bootedVersion() const This is a convenience method. - \sa clientInfo + \sa bootedInfo */ QString QOTAClient::bootedDescription() const { @@ -612,54 +612,54 @@ QByteArray QOTAClient::bootedInfo() const } /*! - \property QOTAClient::serverVersion + \property QOTAClient::remoteVersion \brief a QString containing the system's version on a server. This is a convenience method. - \sa serverInfo + \sa remoteInfo */ -QString QOTAClient::serverVersion() const +QString QOTAClient::remoteVersion() const { - return d_func()->version(QOTAClientPrivate::QueryTarget::Server); + return d_func()->version(QOTAClientPrivate::QueryTarget::Remote); } /*! - \property QOTAClient::serverDescription + \property QOTAClient::remoteDescription \brief a QString containing the system's description on a server. This is a convenience method. - \sa serverInfo + \sa remoteInfo */ -QString QOTAClient::serverDescription() const +QString QOTAClient::remoteDescription() const { - return d_func()->description(QOTAClientPrivate::QueryTarget::Server); + return d_func()->description(QOTAClientPrivate::QueryTarget::Remote); } /*! - \property QOTAClient::serverRevision + \property QOTAClient::remoteRevision \brief a QString containing the system's revision on a server. A checksum in the OSTree repository. */ -QString QOTAClient::serverRevision() const +QString QOTAClient::remoteRevision() const { - return d_func()->revision(QOTAClientPrivate::QueryTarget::Server); + return d_func()->revision(QOTAClientPrivate::QueryTarget::Remote); } /*! - \property QOTAClient::serverInfo + \property QOTAClient::remoteInfo \brief a QByteArray containing the system's OTA metadata on a server. Returns a JSON-formatted QByteArray containing OTA metadata for the system on a server. Metadata is bundled with each system's version. - \sa fetchServerInfo() + \sa fetchRemoteInfo() */ -QByteArray QOTAClient::serverInfo() const +QByteArray QOTAClient::remoteInfo() const { - return d_func()->info(QOTAClientPrivate::QueryTarget::Server); + return d_func()->info(QOTAClientPrivate::QueryTarget::Remote); } /*! diff --git a/src/lib/qotaclient.h b/src/lib/qotaclient.h index da772a8..cc413e3 100644 --- a/src/lib/qotaclient.h +++ b/src/lib/qotaclient.h @@ -51,10 +51,10 @@ class Q_DECL_EXPORT QOTAClient : public QObject Q_PROPERTY(QString bootedDescription READ bootedDescription NOTIFY initializationFinished) Q_PROPERTY(QString bootedRevision READ bootedRevision NOTIFY initializationFinished) Q_PROPERTY(QByteArray bootedInfo READ bootedInfo NOTIFY initializationFinished) - Q_PROPERTY(QString serverVersion READ serverVersion NOTIFY serverInfoChanged) - Q_PROPERTY(QString serverDescription READ serverDescription NOTIFY serverInfoChanged) - Q_PROPERTY(QString serverRevision READ serverRevision NOTIFY serverInfoChanged) - Q_PROPERTY(QByteArray serverInfo READ serverInfo NOTIFY serverInfoChanged) + Q_PROPERTY(QString remoteVersion READ remoteVersion NOTIFY remoteInfoChanged) + Q_PROPERTY(QString remoteDescription READ remoteDescription NOTIFY remoteInfoChanged) + Q_PROPERTY(QString remoteRevision READ remoteRevision NOTIFY remoteInfoChanged) + Q_PROPERTY(QByteArray remoteInfo READ remoteInfo NOTIFY remoteInfoChanged) Q_PROPERTY(QString rollbackVersion READ rollbackVersion NOTIFY rollbackInfoChanged) Q_PROPERTY(QString rollbackDescription READ rollbackDescription NOTIFY rollbackInfoChanged) Q_PROPERTY(QString rollbackRevision READ rollbackRevision NOTIFY rollbackInfoChanged) @@ -71,7 +71,7 @@ public: QString errorString() const; QString statusString() const; - Q_INVOKABLE bool fetchServerInfo() const; + Q_INVOKABLE bool fetchRemoteInfo() const; Q_INVOKABLE bool update() const; Q_INVOKABLE bool rollback() const; @@ -80,10 +80,10 @@ public: QString bootedRevision() const; QByteArray bootedInfo() const; - QString serverVersion() const; - QString serverDescription() const; - QString serverRevision() const; - QByteArray serverInfo() const; + QString remoteVersion() const; + QString remoteDescription() const; + QString remoteRevision() const; + QByteArray remoteInfo() const; QString rollbackVersion() const; QString rollbackDescription() const; @@ -91,7 +91,7 @@ public: QByteArray rollbackInfo() const; Q_SIGNALS: - void serverInfoChanged(); + void remoteInfoChanged(); void rollbackInfoChanged(); void updateAvailableChanged(bool available); void rollbackAvailableChanged(); @@ -100,7 +100,7 @@ Q_SIGNALS: void errorOccurred(const QString &error); void initializationFinished(); - void fetchServerInfoFinished(bool success); + void fetchRemoteInfoFinished(bool success); void updateFinished(bool success); void rollbackFinished(bool success); diff --git a/src/lib/qotaclient_p.h b/src/lib/qotaclient_p.h index 6ee2215..064ea5b 100644 --- a/src/lib/qotaclient_p.h +++ b/src/lib/qotaclient_p.h @@ -50,7 +50,7 @@ public: enum class QueryTarget { Booted, - Server, + Remote, Rollback }; Q_ENUM(QueryTarget) @@ -61,8 +61,8 @@ public: void refreshState(); void initializeFinished(const QString &defaultRev, const QString &bootedRev, const QJsonDocument &bootedInfo, - const QString &serverRev, const QJsonDocument &serverInfo); - void fetchServerInfoFinished(const QString &serverRev, const QJsonDocument &serverInfo, bool success); + const QString &remoteRev, const QJsonDocument &remoteInfo); + void fetchRemoteInfoFinished(const QString &remoteRev, const QJsonDocument &remoteInfo, bool success); void updateFinished(const QString &defaultRev, bool success); void rollbackFinished(const QString &defaultRev, bool success); void statusStringChanged(const QString &status); @@ -74,7 +74,7 @@ public: QString revision(QueryTarget target) const; QByteArray info(QueryTarget target) const; - void updateServerInfo(const QString &serverRev, const QJsonDocument &serverInfo); + void updateRemoteInfo(const QString &remoteRev, const QJsonDocument &remoteInfo); bool isReady() const; // members @@ -95,10 +95,10 @@ public: QString m_bootedRev; QByteArray m_bootedInfo; - QString m_serverVersion; - QString m_serverDescription; - QString m_serverRev; - QByteArray m_serverInfo; + QString m_remoteVersion; + QString m_remoteDescription; + QString m_remoteRev; + QByteArray m_remoteInfo; QString m_rollbackVersion; QString m_rollbackDescription; diff --git a/src/lib/qotaclientasync.cpp b/src/lib/qotaclientasync.cpp index 2ada18d..d0303c3 100644 --- a/src/lib/qotaclientasync.cpp +++ b/src/lib/qotaclientasync.cpp @@ -43,7 +43,7 @@ QOTAClientAsync::QOTAClientAsync() : { // async mapper connect(this, &QOTAClientAsync::initialize, this, &QOTAClientAsync::_initialize); - connect(this, &QOTAClientAsync::fetchServerInfo, this, &QOTAClientAsync::_fetchServerInfo); + connect(this, &QOTAClientAsync::fetchRemoteInfo, this, &QOTAClientAsync::_fetchRemoteInfo); connect(this, &QOTAClientAsync::update, this, &QOTAClientAsync::_update); connect(this, &QOTAClientAsync::rollback, this, &QOTAClientAsync::_rollback); } @@ -122,7 +122,7 @@ QJsonDocument QOTAClientAsync::info(QOTAClientPrivate::QueryTarget target, bool jsonData = QString::fromLatin1(metadata.readAll()); break; } - case QOTAClientPrivate::QueryTarget::Server: + case QOTAClientPrivate::QueryTarget::Remote: jsonData = ostree(QString(QStringLiteral("ostree cat %1 /usr/etc/qt-ota.json")).arg(rev), ok); break; case QOTAClientPrivate::QueryTarget::Rollback: @@ -176,26 +176,26 @@ void QOTAClientAsync::_initialize() bool ok = true; QJsonDocument bootedInfo = info(QOTAClientPrivate::QueryTarget::Booted, &ok); QString defaultRev = defaultRevision(); - // prepopulate with what we think is on the server (head of the local repo) - QString serverRev = ostree(QStringLiteral("ostree rev-parse linux/qt"), &ok); - QJsonDocument serverInfo = info(QOTAClientPrivate::QueryTarget::Server, &ok, serverRev); + // prepopulate with what we think is on the remote server (head of the local repo) + QString remoteRev = ostree(QStringLiteral("ostree rev-parse linux/qt"), &ok); + QJsonDocument remoteInfo = info(QOTAClientPrivate::QueryTarget::Remote, &ok, remoteRev); refreshRollbackState(); - emit initializeFinished(defaultRev, bootedRev, bootedInfo, serverRev, serverInfo); + emit initializeFinished(defaultRev, bootedRev, bootedInfo, remoteRev, remoteInfo); multiprocessUnlock(); } -void QOTAClientAsync::_fetchServerInfo() +void QOTAClientAsync::_fetchRemoteInfo() { - multiprocessLock(QStringLiteral("_fetchServerInfo")); - QString serverRev; - QJsonDocument serverInfo; + multiprocessLock(QStringLiteral("_fetchRemoteInfo")); + QString remoteRev; + QJsonDocument remoteInfo; bool ok = true; ostree(QStringLiteral("ostree pull --commit-metadata-only qt-os linux/qt"), &ok); if (ok) ostree(QStringLiteral("ostree pull --subpath=/usr/etc/qt-ota.json qt-os linux/qt"), &ok); - if (ok) serverRev = ostree(QStringLiteral("ostree rev-parse linux/qt"), &ok); - if (ok) serverInfo = info(QOTAClientPrivate::QueryTarget::Server, &ok, serverRev); - emit fetchServerInfoFinished(serverRev, serverInfo, ok); + if (ok) remoteRev = ostree(QStringLiteral("ostree rev-parse linux/qt"), &ok); + if (ok) remoteInfo = info(QOTAClientPrivate::QueryTarget::Remote, &ok, remoteRev); + emit fetchRemoteInfoFinished(remoteRev, remoteInfo, ok); multiprocessUnlock(); } diff --git a/src/lib/qotaclientasync_p.h b/src/lib/qotaclientasync_p.h index 3929316..9e663e3 100644 --- a/src/lib/qotaclientasync_p.h +++ b/src/lib/qotaclientasync_p.h @@ -51,9 +51,9 @@ signals: void initialize(); void initializeFinished(const QString &defaultRev, const QString &bootedRev, const QJsonDocument &bootedInfo, - const QString &serverRev, const QJsonDocument &serverInfo); - void fetchServerInfo(); - void fetchServerInfoFinished(const QString &serverRev, const QJsonDocument &serverInfo, bool success); + const QString &remoteRev, const QJsonDocument &remoteInfo); + void fetchRemoteInfo(); + void fetchRemoteInfoFinished(const QString &remoteRev, const QJsonDocument &remoteInfo, bool success); void update(const QString &updateToRev); void updateFinished(const QString &defaultRev, bool success); void rollback(); @@ -73,7 +73,7 @@ protected: void refreshRollbackState(int index = -2); void _initialize(); - void _fetchServerInfo(); + void _fetchRemoteInfo(); void _update(const QString &updateToRev); void _rollback(); -- cgit v1.2.3