-
Notifications
You must be signed in to change notification settings - Fork 42
/
Info.cpp
99 lines (79 loc) · 2.63 KB
/
Info.cpp
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
97
98
99
/*************************************************************************
* UrBackup - Client/Server backup system
* Copyright (C) 2011-2015 Martin Raiber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "Info.h"
#include "stringtools.h"
#include "TrayIcon.h"
extern std::string g_lang;
extern std::string g_res_path;
#ifdef wxUSE_WCHAR_T
std::wstring ConvertToUnicode(const std::string &str);
#else
#define ConvertToUnicode(x)
#endif
Info* Info::instance;
Info::Info(wxWindow* parent) : GUIInfo(parent)
{
std::string inf=getFile(g_res_path+"info_"+g_lang+".txt");
if(inf.empty())
{
inf=getFile(g_res_path+"info.txt");
}
m_textCtrl14->SetValue(ConvertToUnicode(inf));
Show(true);
std::string n_version = getFile(g_res_path+"version.txt");
std::string c_version = getFile(g_res_path+"curr_version.txt");
if (n_version.empty())n_version = "0";
if (c_version.empty())c_version = "0";
if (atoi(n_version.c_str()) > atoi(c_version.c_str()))
{
wxButton* updateButton = new wxButton(this, wxID_ANY, _("Update available. Update now."));
m_versionSizer->Add(updateButton);
updateButton->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Info::OnUpdateClick), NULL, this);
Layout();
}
if (FileExists(g_res_path+"urbctctl.exe"))
{
wxButton* cbtStatusButton = new wxButton(this, wxID_ANY, _("Show CBT status"));
m_versionSizer->Add(cbtStatusButton);
cbtStatusButton->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Info::OnShowCBTStatusClick), NULL, this);
Layout();
}
instance=this;
}
void Info::OnOKClick( wxCommandEvent& event )
{
Close();
}
void update_urbackup();
void Info::OnUpdateClick(wxCommandEvent & event)
{
update_urbackup();
}
void Info::OnShowCBTStatusClick(wxCommandEvent& event)
{
runCommand("cbt-status");
}
Info* Info::getInstance()
{
return instance;
}
void Info::OnClose()
{
instance=NULL;
Destroy();
}