forked from layerfsd/Roomer-PMS-1
-
Notifications
You must be signed in to change notification settings - Fork 1
/
uAboutRoomer.pas
265 lines (233 loc) · 7.34 KB
/
uAboutRoomer.pas
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
unit uAboutRoomer;
interface
{$include roomer.inc}
uses
Winapi.Windows
, Winapi.Messages
, ShellApi
, System.SysUtils
, System.Variants
, System.Classes
, Vcl.Graphics
, Vcl.Controls
, Vcl.Forms
, Vcl.Dialogs
, Vcl.Menus
, Vcl.StdCtrls
, Vcl.ExtCtrls
, sLabel
, acPNG
, cmpRoomerDataSet
, dxGDIPlusClasses
;
type
TfrmAboutRoomer = class(TForm)
LabDBVerName: TsLabel;
LabCopyRight: TsLabel;
labCopyright2: TsLabel;
Label1: TsLabel;
sLabel1: TsLabel;
LabSupportHomepage: TsWebLabel;
LabSupportEmail: TsWebLabel;
sLabel2: TsLabel;
sLabel3: TsLabel;
sLabel4: TsLabel;
lblEndpoint: TsLabel;
Image1: TImage;
labExtraBuild: TsLabel;
labExtraBuildText: TsLabel;
procedure btnCloseClick(Sender: TObject);
procedure LabSupportHomepageClick(Sender: TObject);
procedure Label1Click(Sender: TObject);
procedure LabSupportEmailClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure LabDBVerNameMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure FormCreate(Sender: TObject);
private
public
end;
var
frmAboutRoomer: TfrmAboutRoomer;
procedure ShowRoomerAboutBox;
procedure downloadCurrentVersion(Handle : THandle; RoomerDataSet : TRoomerDataSet);
function checkNewVersion(Handle : THandle; RoomerDataSet : TRoomerDataSet) : boolean;
procedure StartRemoteSupport(Handle : THandle; RoomerDataSet : TRoomerDataSet);
procedure SetIgnoresToZero(RoomerDataSet : TRoomerDataSet);
implementation
{$R *.dfm}
uses uMain
, uRunWithElevatedOption
, uFileDependencyManager
, System.IOUtils
, uFileSystemUtils
, uStringUtils
, uAPIDataHandler
, IdGlobalProtocols
, uSplashRoomer
, uD
, uRoomerLanguage
, uRegistryServices
, PrjConst
, uUtils
, _Glob
, Math
, uRoomerVersionInfo;
const MAX_NUMBER_OF_IGNORES = 10;
WARNING_IGNORES = 5;
procedure ShowRoomerAboutBox;
begin
Application.CreateForm(TfrmAboutRoomer, frmAboutRoomer);
try
frmAboutRoomer.ShowModal;
finally
frmAboutRoomer.free;
end;
end;
procedure TfrmAboutRoomer.btnCloseClick(Sender: TObject);
begin
Close;
end;
procedure TfrmAboutRoomer.FormCreate(Sender: TObject);
begin
RoomerLanguage.TranslateThisForm(self);
end;
procedure TfrmAboutRoomer.FormShow(Sender: TObject);
begin
lblEndpoint.Caption := d.roomerMainDataSet.RoomerUri;
LabDBVerName.Caption := TRoomerVersionInfo.FileVersion;
if TRoomerVersionInfo.IsPreRelease then
LabDBVerName.Caption := LabDBVerName.Caption + ' (Pre-Release)';
labExtraBuild.Caption := TRoomerVersionInfo.ExtraBuild;
end;
procedure TfrmAboutRoomer.LabDBVerNameMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbRight then
begin
uStringUtils.ClipboardCopy(LabDBVerName.Caption);
ShowMessage(GetTranslatedText('shTx_AboutRoomer_CopyPMSVersion'));
end
else
btnCloseClick(Sender);
end;
procedure TfrmAboutRoomer.Label1Click(Sender: TObject);
begin
checkNewVersion(handle, TRoomerDataSet.Create(nil));
end;
procedure TfrmAboutRoomer.LabSupportEmailClick(Sender: TObject);
begin
ShellExecute(Self.WindowHandle, 'open', PChar('mailto:' + TsWebLabel(Sender).Caption), nil, nil, SW_SHOWNORMAL);
end;
procedure TfrmAboutRoomer.LabSupportHomepageClick(Sender: TObject);
begin
ShellExecute(Self.WindowHandle, 'open', PChar('http://' + TsWebLabel(Sender).Caption), nil, nil, SW_SHOWNORMAL);
end;
procedure StartRemoteSupport(Handle : THandle; RoomerDataSet : TRoomerDataSet);
var
filename : String;
language : String;
sPath,
RemoteSupportFilenameAndPath : String;
begin
language := LowerCase(copy(RoomerLanguage.LanguageCode, 1, 2));
if trim(language) = '' then
language := 'en';
filename := format('RoomerQS%s.exe', [language]);
sPath := RoomerAppDataPath;
forceDirectories(sPath);
RemoteSupportFilenameAndPath := TPath.Combine(sPath, filename);
FileDependencymanager.getAnyFileFromRoomerStore(filename, RemoteSupportFilenameAndPath);
ExecuteFile(Handle, RemoteSupportFilenameAndPath, '', []);
end;
procedure downloadCurrentVersion(Handle : THandle; RoomerDataSet : TRoomerDataSet);
var
sPath,
UpgradeManagerPath : String;
begin
try
frmMain.RemoveLanguagesFilesAndRefresh(False);
sPath := RoomerAppDataPath;
forceDirectories(sPath);
UpgradeManagerPath := TPath.Combine(sPath, 'RoomerUpgradeAgent.exe');
FileDependencymanager.getRoomerUpgradeAgentFilePath(UpgradeManagerPath);
ExecuteFile(Handle, UpgradeManagerPath, '-e:"' + Application.ExeName + '" -s:"' + d.roomerMainDataSet.RoomerStoreUri + '"', [eoElevate]);
except
end;
end;
procedure SetIgnoresToZero(RoomerDataSet : TRoomerDataSet);
var
version : String;
begin
if TRoomerVersionInfo.FileVersionOnServer(version) and (version <> TRoomerVersionInfo.FileVersion) then
begin
(* if MessageDlg('There is a new version of ROOMER (' + version + ').' + #13#10 +
'ROOMER needs to be updated.' + #13#10#13#10 +
'Click [OK] to perform the update now.'+ #13#10 +
'Click [Cancel] to do this later', mtConfirmation, [mbOK,mbCancel], 0) = mrOk then *)
with TRoomerRegistryIniFile.Create(GetRoomerIniFilename) do
try
WriteInteger('RoomerPMSVersion', version, 0);
finally
Free;
end;
end;
end;
function checkNewVersion(Handle : THandle; RoomerDataSet : TRoomerDataSet) : boolean;
var
version : String;
NumDialogShown : Integer;
s : String;
Buttons: TMsgDlgButtons;
lButton: TButton;
lMSgResult: integer;
begin
Result := false;
if TRoomerVersionInfo.FileVersionOnServer(version) and not TRoomerVersionInfo.IsDebug and (version <> TROomerVersionInfo.FileVersion) then
begin
with TRoomerRegistryIniFile.Create(GetRoomerIniFilename) do
try
NumDialogShown := ReadInteger('RoomerPMSVersion', version, 0) + 1;
finally
Free;
end;
if NumDialogShown > MAX_NUMBER_OF_IGNORES then
begin
s := format(GetTranslatedText('shTx_AboutRoomer_NewVersionAvailableExpired'), [version, MAX_NUMBER_OF_IGNORES]);
Buttons := [mbOK];
end else
if NumDialogShown > WARNING_IGNORES then
begin
s := format(GetTranslatedText('shTx_AboutRoomer_NewVersionAvailableExpireWarning'), [version, NumDialogShown - 1, MAX_NUMBER_OF_IGNORES - (NumDialogShown - 1)]);
Buttons := [mbOK,mbCancel];
end else
begin
s := format(GetTranslatedText('shTx_AboutRoomer_NewVersionAvailable'), [version]);
Buttons := [mbOK,mbCancel];
end;
with CreateMessageDialog(s, mtConfirmation, Buttons) do
try
lButton := TButton(FindComponent('OK'));
if lButton <> nil then
lButton.Caption := GetTranslatedText('shTx_AboutRoomer_NewVersionAvailableUpdateNow');
lButton := TButton(FindComponent('Cancel'));
if lButton <> nil then
lButton.Caption := GetTranslatedText('shTx_AboutRoomer_NewVersionAvailableUpdateLater');
Position := poScreenCenter;
lMsgResult := ShowModal;
finally
Free;
end;
if lMsgResult = mrOk then
begin
downloadCurrentVersion(Handle, RoomerDataSet);
result := true;
end
else
with TRoomerRegistryIniFile.Create(GetRoomerIniFilename) do
try
WriteInteger('RoomerPMSVersion', version, NumDialogShown);
finally
Free;
end;
end;
end;
end.