-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUpdateChecker.h
96 lines (67 loc) · 2.04 KB
/
UpdateChecker.h
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifndef UpdateChecker__INCLUDED
#define UpdateChecker__INCLUDED
#include <wx/wx.h>
#include <wx/progdlg.h>
wxDECLARE_EVENT(wxEVT_UPDATE_PROGRESS, wxThreadEvent);
wxDECLARE_EVENT(wxEVT_UPDATE_FINISHED, wxThreadEvent);
class UpdateChecker:
public wxEvtHandler,
protected wxThreadHelper
{
public:
UpdateChecker();
~UpdateChecker();
// Checks if update interval has been reached
bool IsCheckRequired();
// Ask server for update
bool CheckForUpdate();
// Ask the user for confirmation
bool ConfirmUpdate();
// Download and start the update
void ApplyUpdate();
const wxString& GetSoftwareTitle() const;
const wxString& GetUpdateInfoFileName() const;
void SetUpdateInfoFileName(const wxString& fileName);
protected:
wxThread::ExitCode Entry();
private:
typedef unsigned long SoftwareVersion[4];
// Software parameters
wxString m_softwareTitle;
wxString m_softwareId;
wxString m_softwareDisplayVersion;
SoftwareVersion m_softwareVersion;
wxString m_softwareUpdateURL;
wxUint32 m_softwareUpdateInterval; // Update interval in days
// Update information
wxString m_updateInfoFileName;
bool m_updateDownloadCanceled;
// UI
wxProgressDialog* m_progDlg;
void Init();
// Look for local external software info
void LoadSoftwareInfo();
// Load software information
void LoadSoftwareInfo(wxInputStream& istr);
void SaveCheckDate() const;
void OnUpdateProgress(wxThreadEvent& event);
void OnUpdateFinished(wxThreadEvent& event);
static void StringToVersion(const wxString& str, SoftwareVersion& version);
static bool IsVersionNewer(const SoftwareVersion& v1, const SoftwareVersion& v2);
};
//
// inlines
//
inline const wxString& UpdateChecker::GetSoftwareTitle() const
{
return m_softwareTitle;
}
inline const wxString& UpdateChecker::GetUpdateInfoFileName() const
{
return m_updateInfoFileName;
}
inline void UpdateChecker::SetUpdateInfoFileName(const wxString& fileName)
{
m_updateInfoFileName = fileName;
}
#endif // UpdateChecker__INCLUDED