OsuUpdateHandler.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //================ Copyright (c) 2016, PG, All rights reserved. =================//
  2. //
  3. // Purpose: checks if an update is available from github
  4. //
  5. // $NoKeywords: $osuupdchk
  6. //===============================================================================//
  7. #ifndef OSUUPDATECHECKER_H
  8. #define OSUUPDATECHECKER_H
  9. #include <pthread.h>
  10. #include "cbase.h"
  11. class OsuUpdateHandler {
  12. public:
  13. enum class STATUS {
  14. STATUS_UP_TO_DATE,
  15. STATUS_CHECKING_FOR_UPDATE,
  16. STATUS_DOWNLOADING_UPDATE,
  17. STATUS_INSTALLING_UPDATE,
  18. STATUS_SUCCESS_INSTALLATION,
  19. STATUS_ERROR
  20. };
  21. static void *run(void *data);
  22. OsuUpdateHandler();
  23. virtual ~OsuUpdateHandler();
  24. void stop(); // tells the update thread to stop at the next cancellation point
  25. void wait(); // blocks until the update thread is finished
  26. void checkForUpdates();
  27. inline STATUS getStatus() const { return m_status; }
  28. UString update_url;
  29. private:
  30. static const char *TEMP_UPDATE_DOWNLOAD_FILEPATH;
  31. // async
  32. void _requestUpdate();
  33. bool _downloadUpdate();
  34. void _installUpdate(std::string zipFilePath);
  35. pthread_t m_updateThread;
  36. bool _m_bKYS;
  37. // releases
  38. Environment::OS stringToOS(UString osString);
  39. // status
  40. STATUS m_status;
  41. int m_iNumRetries;
  42. };
  43. #endif