AutoUpdate.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2018 Dolphin Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <string>
  5. #include <string_view>
  6. // Refer to docs/autoupdate_overview.md for a detailed overview of the autoupdate process
  7. // This class defines all the logic for Dolphin auto-update checking. UI-specific elements have to
  8. // be defined in a backend specific subclass.
  9. class AutoUpdateChecker
  10. {
  11. public:
  12. enum class CheckType
  13. {
  14. Automatic,
  15. Manual,
  16. };
  17. // Initiates a check for updates in the background. Calls the OnUpdateAvailable callback if an
  18. // update is available, does "nothing" otherwise.
  19. void CheckForUpdate(std::string_view update_track, std::string_view hash_override,
  20. CheckType check_type);
  21. static bool SystemSupportsAutoUpdates();
  22. struct NewVersionInformation
  23. {
  24. // Name (5.0-1234) and revision hash of the new version.
  25. std::string new_shortrev;
  26. std::string new_hash;
  27. // The full changelog in HTML format.
  28. std::string changelog_html;
  29. // Internals, to be passed to the updater binary.
  30. std::string this_manifest_url;
  31. std::string next_manifest_url;
  32. std::string content_store_url;
  33. };
  34. // Starts the updater process, which will wait in the background until the current process exits.
  35. enum class RestartMode
  36. {
  37. NO_RESTART_AFTER_UPDATE = 0,
  38. RESTART_AFTER_UPDATE,
  39. };
  40. void TriggerUpdate(const NewVersionInformation& info, RestartMode restart_mode);
  41. protected:
  42. virtual void OnUpdateAvailable(const NewVersionInformation& info) = 0;
  43. };