about summary refs log tree commit diff stats
path: root/src/updater.h
blob: 2d2f746545fc3afea5060e6713d2dcfcab49ed3c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef UPDATER_H_809E7381
#define UPDATER_H_809E7381

#include <filesystem>
#include <set>
#include <string>

#include <wx/wxprec.h>

#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif

class wxWebRequest;
class wxWebRequestEvent;

class Updater : public wxEvtHandler {
 public:
  explicit Updater(wxFrame* parent);

  void Cleanup();

  void CheckForUpdates(bool invisible);

 private:
  enum class UpdateState {
    GetVersionInvisible,
    GetVersionManual,
    GetPackage,
  };

  void OnWebRequestState(wxWebRequestEvent& event);

  void ProcessVersionFile(std::string data);

  void InstallUpdate(std::string url, std::string checksum,
                     std::vector<std::filesystem::path> files,
                     std::vector<std::filesystem::path> deletedFiles);

  bool DownloadWithProgress(wxWebRequest& request);

  wxFrame* parent_;
  UpdateState update_state_ = UpdateState::GetVersionInvisible;
  std::string package_path_;
};

#endif /* end of include guard: UPDATER_H_809E7381 */