sparkleupdater.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (C) by Daniel Molkentin <danimo@owncloud.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  11. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. * for more details.
  13. */
  14. #ifndef SPARKLEUPDATER_H
  15. #define SPARKLEUPDATER_H
  16. #include "updater/updater.h"
  17. #include <QObject>
  18. namespace OCC {
  19. class SparkleUpdater : public Updater
  20. {
  21. Q_OBJECT
  22. Q_PROPERTY(QString statusString READ statusString NOTIFY statusChanged)
  23. Q_PROPERTY(State state READ state NOTIFY statusChanged)
  24. public:
  25. class SparkleInterface;
  26. enum class State {
  27. Unknown = 0,
  28. Idle,
  29. Working,
  30. AwaitingUserInput
  31. };
  32. explicit SparkleUpdater(const QUrl &appCastUrl);
  33. ~SparkleUpdater() override;
  34. [[nodiscard]] static bool autoUpdaterAllowed();
  35. [[nodiscard]] bool handleStartup() override { return false; }
  36. [[nodiscard]] QString statusString() const;
  37. [[nodiscard]] State state() const;
  38. public slots:
  39. void setUpdateUrl(const QUrl &url);
  40. void checkForUpdate() override;
  41. void backgroundCheckForUpdate() override;
  42. signals:
  43. void statusChanged();
  44. private:
  45. std::unique_ptr<SparkleInterface> _interface;
  46. QString _statusString;
  47. State _state = State::Unknown;
  48. friend class SparkleInterface;
  49. };
  50. } // namespace OCC
  51. #endif // SPARKLEUPDATER_H