]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
Also record sparkle updater state
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Thu, 23 Feb 2023 12:42:10 +0000 (13:42 +0100)
committerMatthieu Gallien <matthieu_gallien@yahoo.fr>
Sat, 22 Jul 2023 09:16:39 +0000 (11:16 +0200)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/updater/sparkleupdater.h
src/gui/updater/sparkleupdater_mac.mm

index c5d6ea9111b29686ff7f9ad6a47bd3c16ca5acae..fab3050baaaa2fdaefaa63cf9423e696a2c7f13d 100644 (file)
@@ -26,6 +26,13 @@ class SparkleUpdater : public Updater
     Q_OBJECT
 
 public:
+    enum class State {
+        Unknown = 0,
+        Idle,
+        Working,
+        AwaitingUserInput
+    };
+
     SparkleUpdater(const QUrl &appCastUrl);
     ~SparkleUpdater();
 
@@ -36,7 +43,8 @@ public:
     void backgroundCheckForUpdate() override;
     bool handleStartup() override { return false; }
 
-    QString statusString();
+    QString statusString() const;
+    State state() const;
 
     class SparkleInterface;
 
@@ -46,6 +54,7 @@ signals:
 private:
     std::unique_ptr<SparkleInterface> _interface;
     QString _statusString;
+    State _state = State::Unknown;
     friend class SparkleInterface;
 };
 
index c02397f6506269bc7a67c8493833877fafa6eba4..706d3879131b64fa70f6369e3f602e3fed817a85 100644 (file)
@@ -38,8 +38,9 @@ public:
         [delegate release];
     }
 
-    void statusChanged(const QString &statusString)
+    void statusChanged(const OCC::SparkleUpdater::State state, const QString &statusString = {})
     {
+        q->_state = state;
         q->_statusString = statusString;
         emit q->statusChanged();
     }
@@ -79,10 +80,10 @@ private:
     return YES;
 }
 
-- (void)notifyChange:(const QString&)statusString
+- (void)notifyStateChange:(const OCC::SparkleUpdater::State)state displayStatus:(const QString&)statusString
 {
     qCDebug(OCC::lcUpdater) << statusString;
-    _owner->statusChanged(statusString);
+    _owner->statusChanged(state, statusString);
 }
 
 // Sent when a valid update is found by the update driver.
@@ -90,14 +91,16 @@ private:
 {
     Q_UNUSED(updater)
     Q_UNUSED(update)
-    [self notifyChange:QStringLiteral("Found a valid update.")];
+    [self notifyStateChange:OCC::SparkleUpdater::State::AwaitingUserInput
+              displayStatus:QStringLiteral("Found a valid update.")];
 }
 
 // Sent when a valid update is not found.
 - (void)updaterDidNotFindUpdate:(SUUpdater *)update
 {
     Q_UNUSED(update)
-    [self notifyChange:QStringLiteral("No valid update found.")];
+    [self notifyStateChange:OCC::SparkleUpdater::State::Idle
+              displayStatus:QStringLiteral("No valid update found.")];
 }
 
 // Sent immediately before installing the specified update.
@@ -105,21 +108,24 @@ private:
 {
     Q_UNUSED(updater)
     Q_UNUSED(update)
-    [self notifyChange:QStringLiteral("About to install update.")];
+    [self notifyStateChange:OCC::SparkleUpdater::State::Working
+              displayStatus:QStringLiteral("About to install update.")];
 }
 
 - (void)updater:(SUUpdater *)updater didAbortWithError:(NSError *)error
 {
     Q_UNUSED(updater)
     const QString message(QStringLiteral("Aborted with error: ") + QString::fromNSString(error.description));
-    [self notifyChange:message];
+    [self notifyStateChange:OCC::SparkleUpdater::State::Idle
+              displayStatus:message];
 }
 
 - (void)updater:(SUUpdater *)updater didFinishLoadingAppcast:(SUAppcast *)appcast
 {
     Q_UNUSED(updater)
     Q_UNUSED(appcast)
-    [self notifyChange:QStringLiteral("Finished loading appcast.")];
+    [self notifyStateChange:OCC::SparkleUpdater::State::Working
+              displayStatus:QStringLiteral("Finished loading appcast.")];
 }
 
 
@@ -195,9 +201,14 @@ void SparkleUpdater::backgroundCheckForUpdate()
     }
 }
 
-QString SparkleUpdater::statusString()
+QString SparkleUpdater::statusString() const
 {
     return _statusString;
 }
 
+SparkleUpdater::State SparkleUpdater::state() const
+{
+    return _state;
+}
+
 } // namespace OCC