-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
wammu.iss
498 lines (420 loc) · 14.6 KB
/
wammu.iss
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
; Inno Setup Script for Wammu installation
; Copyright (c) 2006 Michal Èihaø
; Language selection code based on GTK+ 2 installation script
; made by Jernej Simoncic, <jernej.simoncic@guest.arnes.si>
#define MyAppDosName "wammu"
#define MyAppName "Wammu"
#define MyAppVersion "0.44"
#define MyAppPublisher "Micha Èihaø"
#define MyAppURL "https://wammu.eu/"
#define MyAppPublisherURL "https://cihar.com/"
#define MyAppBugsURL "https://github.com/gammu/wammu/issues/"
#define MyAppDescription "Wammu Mobile Phone Manager"
#define MyAppExeName "wammu.exe"
#define MyAppUrlName "wammu.url"
#define MyAppBugsUrlName "wammu-bugs.url"
[Setup]
AppName={#MyAppName}
AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppPublisherURL}
AppSupportURL={#MyAppBugsURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
AllowNoIcons=true
LicenseFile=COPYING
OutputBaseFilename={#MyAppDosName}-{#MyAppVersion}-setup
Compression=lzma/ultra
SolidCompression=true
InternalCompressLevel=ultra
VersionInfoVersion={#MyAppVersion}
VersionInfoCompany={#MyAppPublisher}
VersionInfoDescription={#MyAppDescription}
ShowLanguageDialog=yes
AppVersion={#MyAppVersion}
UninstallDisplayIcon={app}\share\pixmaps\wammu.ico
AppModifyPath="{uninstallexe}" /langsetup
ChangesEnvironment=true
;SetupIconFile={app}\icon\wammu.ico
[Languages]
Name: en; MessagesFile: compiler:Default.isl
;Name: af; MessagesFile: compiler:Languages\Afrikaans.isl
Name: ca; MessagesFile: compiler:Languages\Catalan.isl
Name: cs; MessagesFile: compiler:Languages\Czech.isl
Name: de; MessagesFile: compiler:Languages\German.isl
;Name: el; MessagesFile: compiler:Languages\Greek.isl
Name: es; MessagesFile: compiler:Languages\Spanish.isl
;Name: et; MessagesFile: compiler:Languages\Estonian.isl
Name: fi; MessagesFile: compiler:Languages\Finnish.isl
Name: fr; MessagesFile: compiler:Languages\French.isl
;Name: gl; MessagesFile: compiler:Languages\Galician.isl
Name: he; MessagesFile: compiler:Languages\Hebrew.isl
Name: hu; MessagesFile: compiler:Languages\Hungarian.isl
;Name: id; MessagesFile: compiler:Languages\Indonesian.isl
Name: it; MessagesFile: compiler:Languages\Italian.isl
;Name: ko; MessagesFile: compiler:Languages\Korean.isl
Name: nl; MessagesFile: compiler:Languages\Dutch.isl
Name: pl; MessagesFile: compiler:Languages\Polish.isl
Name: pt_BR; MessagesFile: compiler:Languages\BrazilianPortuguese.isl
Name: ru; MessagesFile: compiler:Languages\Russian.isl
;Name: sk; MessagesFile: compiler:Languages\Slovak.isl
;Name: sv; MessagesFile: compiler:Languages\Swedish.isl
;Name: zh_tw; MessagesFile: compiler:Languages\SimpChinese.isl
;Name: zh_cz; MessagesFile: compiler:Languages\TradChinese.isl
[Tasks]
Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
[Files]
Source: dist\*; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs; Excludes: locale
Source: uninst.isl; DestDir: {app}
Source: dist\share\locale\*; DestDir: {app}\share\locale; Flags: ignoreversion recursesubdirs createallsubdirs; Components: " Translations"; Tasks: ; Languages:
[INI]
Filename: {app}\{#MyAppUrlName}; Section: InternetShortcut; Key: URL; String: {#MyAppURL}
Filename: {app}\{#MyAppBugsUrlName}; Section: InternetShortcut; Key: URL; String: {#MyAppBugsURL}
[Icons]
Name: {group}\{#MyAppName}; Filename: {app}\{#MyAppExeName}; IconFilename: {app}\share\pixmaps\wammu.ico; IconIndex: 0
Name: {group}\{cm:ProgramOnTheWeb,{#MyAppName}}; Filename: {app}\{#MyAppUrlName}
Name: {group}\{cm:ReportBug,{#MyAppName}}; Filename: {app}\{#MyAppBugsUrlName}
Name: {group}\{cm:UninstallProgram,{#MyAppName}}; Filename: {uninstallexe}
Name: {userdesktop}\{#MyAppName}; Filename: {app}\{#MyAppExeName}; Tasks: desktopicon
Name: {group}\{cm:SelectLanguage}; Filename: {uninstallexe}; Parameters: /langsetup; IconFilename: {app}\share\pixmaps\wammu.ico; IconIndex: 0
[Run]
Filename: {app}\{#MyAppExeName}; Description: {cm:LaunchProgram,{#MyAppName}}; Flags: nowait postinstall skipifsilent unchecked
Filename: {uninstallexe}; Parameters: /langsetup; Description: {cm:SelectLanguage}; Flags: postinstall nowait
[Components]
Name: Translations; Description: {cm:TranslationsDesc}; Types: custom full; Languages:
[UninstallDelete]
Type: files; Name: {app}\{#MyAppUrlName}
Type: files; Name: {app}\{#MyAppBugsUrlName}
[CustomMessages]
en.ReportBug=Report bug in application %1
cs.ReportBug=Nahlásit chybu v aplikaci %1
en.SelectLanguage=Select application language
cs.SelectLanguage=Zvolit jazyk aplikace
en.Translations=Translations
en.TranslationsDesc=Translations of user interface
cs.Translations=Pøeklady
cs.TranslationsDesc=Pøeklady uživatelského rozhraní
[Registry]
Root: HKCU; Subkey: Environment; ValueType: string; ValueName: LANG; ValueData: {language}; Check: UsingWinNT
; Following part is heavily based on GTK+ 2 setup
[Code]
program Setup;
function SendMessageTimeout(hWnd: HWND; Msg: Cardinal; wParam: DWORD; lParam: String; fuFlags, uTimeout: Cardinal; lpdwResult: DWORD): {Int64}Cardinal; external 'SendMessageTimeoutA@user32 stdcall';
var
frmLangChooser: TForm;
cbUser, cbSystem: TComboBox;
const
WM_SETTINGCHANGE = 26;
//HWND_BROADCAST = $FFFF;
SMTO_ABORTIFHUNG = 2;
function RevPos(const SearchStr, Str: string): Integer;
var i: Integer;
begin
if (Length(SearchStr) < Length(Str)) and (Pos(SearchStr, Str) > 0) then
for i := (Length(Str) - Length(SearchStr) + 1) downto 1 do
begin
if Copy(Str, i, Length(SearchStr)) = SearchStr then
begin
Result := i;
exit;
end;
end;
Result := 0;
end;
function ExtractLang(const Txt: String): String;
var S: String;
i: Integer;
begin
S := LowerCase(Txt);
if (S[Length(S)] = ')') then
begin
i := RevPos('(',S);
if (i > 0) then
S := Copy(Txt,i+1,Length(Txt)-i-1)
else
S := Txt;
end else
S := Txt;
Result := S;
end;
function GetLangIndex(Items: TStrings; Lang: String): Integer;
var i: Integer;
s: String;
begin
Lang := LowerCase(Lang);
for i := 0 to Items.Count - 1 do
begin
S := LowerCase(ExtractLang(Items.Strings[i]));
if (S = Lang) then
break;
end;
if (i >= Items.Count) then
Result := -1
else
Result := i;
end;
function GetTransStr(const Str: String): String; //ExpandConstant('{cm:...}') doesn't work on uninstall
begin
Result := GetIniString('CustomMessages',Str,'',ExpandConstant('{app}\uninst.isl'));
if (Result = '') then
RaiseException(Str + ' not found in translation file.');
end;
procedure LanguageForm;
var lblInfo, lblUser, lblSystem: TLabel;
btnOK,btnCancel: TButton;
frMsgs: TFindRec;
i,j: Integer;
lang1,lang2,regSys,regUser: String;
AutoExec: TArrayOfString;
MsgResult: DWORD;
begin
frmLangChooser := CreateCustomForm();
with frmLangChooser do
begin
ClientWidth := ScaleX(321);
ClientHeight := ScaleY(119);
Caption := GetTransStr('LangTitle');
Position := poScreenCenter;
end;
{ lblInfo }
lblInfo := TLabel.Create(frmLangChooser);
with lblInfo do
begin
Parent := frmLangChooser;
Left := ScaleX(8);
Top := ScaleY(8);
Width := ScaleX(283);
Height := ScaleY(13);
Caption := GetTransStr('LangText');
end;
{ lblUser }
lblUser := TLabel.Create(frmLangChooser);
with lblUser do
begin
Parent := frmLangChooser;
Left := ScaleX(8);
Top := ScaleY(34);
Width := ScaleX(119);
Height := ScaleY(13);
Caption := GetTransStr('LangUser');
FocusControl := cbUser;
end;
{ lblSystem }
lblSystem := TLabel.Create(frmLangChooser);
with lblSystem do
begin
Parent := frmLangChooser;
Left := ScaleX(8);
Top := ScaleY(58);
Width := ScaleX(93);
Height := ScaleY(13);
Caption := GetTransStr('LangSystem');
FocusControl := cbSystem;
end;
{ cbUser }
cbUser := TComboBox.Create(frmLangChooser);
with cbUser do
begin
Parent := frmLangChooser;
Style := csDropDownList;
Left := ScaleX(144);
Top := ScaleY(32);
Width := ScaleX(169);
Height := ScaleY(16);
Hint := GetTransStr('LangUserHint');
ShowHint := True;
TabOrder := 0;
Sorted := True;
end;
{ cbSystem }
cbSystem := TComboBox.Create(frmLangChooser);
with cbSystem do
begin
Parent := frmLangChooser;
Style := csDropDownList;
Left := ScaleX(144);
Top := ScaleY(56);
Width := ScaleX(169);
Height := ScaleY(16);
Hint := GetTransStr('LangSystemHint');
ShowHint := True;
TabOrder := 1;
Sorted := True;
end;
{ btnOK }
btnOK := TButton.Create(frmLangChooser);
with btnOK do
begin
Parent := frmLangChooser;
Left := ScaleX(82);
Top := ScaleY(88);
Width := ScaleX(75);
Height := ScaleY(23);
Caption := SetupMessage(msgButtonOK);
Default := True;
TabOrder := 2;
ModalResult := 1;
end;
{ btnCancel }
btnCancel := TButton.Create(frmLangChooser);
with btnCancel do
begin
Parent := frmLangChooser;
Left := ScaleX(164);
Top := ScaleY(88);
Width := ScaleX(75);
Height := ScaleY(23);
Caption := SetupMessage(msgButtonCancel);
Cancel := True;
TabOrder := 3;
ModalResult := 2;
end;
cbUser.Items.Add(GetTransStr('LangDefault'));
cbUser.Items.Add('English (C)');
//cbSystem.Items.Add(GetTransStr('LangDefault'));
if FindFirst(ExpandConstant('{app}\share\locale\*'),frMsgs) then
begin
try
repeat
if ((frMsgs.Attributes and FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY) and ((frMsgs.Name <> '.') and (frMsgs.Name <> '..')) then
begin
try
lang1 := frMsgs.Name;
StringChange(lang1,'@','_'); //custom messages only support letters,numbers and _
lang1 := GetTransStr('Lang_'+lang1+'');
except
lang1 := '';
end;
i := pos('@',frMsgs.Name);
if (lang1 = '') and (i > 0) then
try
lang1 := GetTransStr('Lang_'+Copy(frMsgs.Name,1,i-1)+'');
lang2 := Copy(frMsgs.Name,i+1,length(frMsgs.Name))
except
lang1 := '';
end;
if (lang1 = '') and (Length(frMsgs.Name) > 2) then
try
lang1 := GetTransStr('Lang_'+Copy(frMsgs.Name,1,2)+'');
except
lang1 := '';
end;
case lowercase(lang2) of
'latn': lang2 := 'Latin';
end;
if (lang1 <> '') then
begin
if (lang2 <> '') then
begin
cbUser.Items.Add(lang1+' '+lang2+' ('+frMsgs.Name+')');
end else
begin
cbUser.Items.Add(lang1+' ('+frMsgs.Name+')');
end
end else
begin
cbUser.Items.Add(frMsgs.Name);
end;
end;
until not FindNext(frMsgs);
cbSystem.Items := cbUser.Items;
finally
FindClose(frMsgs);
end;
end;
if UsingWinNT then
begin
if not IsAdminLoggedOn then //only admins can change system-wide environment variables
begin
cbSystem.Enabled := False;
lblSystem.Enabled := False;
end;
if RegQueryStringValue(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment','LANG',regSys) then
cbSystem.ItemIndex := GetLangIndex(cbSystem.Items,regSys)
else
cbSystem.ItemIndex := 0;
if cbSystem.ItemIndex = -1 then
cbSystem.ItemIndex := cbSystem.Items.Add(regSys);
if RegQueryStringValue(HKEY_CURRENT_USER,'Environment','LANG',regUser) then
cbUser.ItemIndex := GetLangIndex(cbSystem.Items,regUser)
else
cbUser.ItemIndex := 0;
if cbUser.ItemIndex = -1 then
cbUser.ItemIndex := cbUser.Items.Add(regUser);
end;
if frmLangChooser.ShowModal = 1 then
begin
regSys := ExtractLang(cbSystem.Items.Strings[cbSystem.ItemIndex]);
if UsingWinNT then
begin
regUser := ExtractLang(cbUser.Items.Strings[cbUser.ItemIndex]);
if cbUser.ItemIndex <> 0 then
begin
if not RegWriteStringValue(HKEY_CURRENT_USER,'Environment','LANG',regUser) then
MsgBox(GetTransStr('LangRegUserFailed'),mbCriticalError,mb_ok);
end else
if RegValueExists(HKEY_CURRENT_USER,'Environment','LANG') and
(not RegDeleteValue(HKEY_CURRENT_USER,'Environment','LANG')) then
MsgBox(GetTransStr('LangRegUserFailed'),mbCriticalError,mb_ok);
if IsAdminLoggedOn then
begin
if cbSystem.ItemIndex <> 0 then
begin
if not RegWriteStringValue(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment','LANG',regSys) then
MsgBox(GetTransStr('LangRegSysFailed'),mbCriticalError,mb_ok);
end else
if RegValueExists(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment','LANG') and
(not RegDeleteValue(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment','LANG')) then
MsgBox(GetTransStr('LangRegSysFailed'),mbCriticalError,mb_ok);
end;
//straight from the Inno source
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 'Environment', SMTO_ABORTIFHUNG, 5000, MsgResult);
end else
begin
if not FileCopy(ExpandConstant('{sd}\AutoExec.bat'),ExpandConstant('{sd}\AutoExec.WAM'),False) then
if MsgBox(GetTransStr('LangAutoExecBackupFailed'),mbConfirmation,mb_yesno) = idno then
exit;
if LoadStringsFromFile(ExpandConstant('{sd}\Autoexec.bat'), AutoExec) then
begin
for i := GetArrayLength(AutoExec) - 1 downto 0 do
if pos('set lang=',LowerCase(AutoExec[i])) > 0 then
if (i>0) and (i<(GetArrayLength(AutoExec)-1))
and (LowerCase(AutoExec[i-1]) = 'REM /=== by Wammu Language Setup ===\')
and (LowerCase(AutoExec[i+1]) = 'REM \=== by Wammu Language Setup ===/') then
begin
for j := i to GetArrayLength(AutoExec) - 2 do //remove previous setting
AutoExec[j-1] := AutoExec[j+1];
SetArrayLength(AutoExec,GetArrayLength(AutoExec) - 3);
end;
i := GetArrayLength(AutoExec);
SetArrayLength(AutoExec,i + 3);
AutoExec[i] := 'REM /=== by Wammu Language Setup ===\';
AutoExec[i+1] := 'SET LANG='+regSys;
AutoExec[i+2] := 'REM \=== by Wammu Language Setup ===/';
if SaveStringsToFile(ExpandConstant('{sd}\AutoExec.bat'),AutoExec,False) then
MsgBox(GetTransStr('LangRestartRequired'),mbInformation,mb_ok)
else
MsgBox(GetTransStr('LangErrorSavingAutoExec'),mbCriticalError,mb_ok);
end else
MsgBox(GetTransStr('LangErrorLoadingAutoExec'), mbCriticalError, MB_OK);
end;
end;
end;
function InitializeUninstall(): Boolean;
var i: Integer;
begin
Result := True;
for i := 1 to ParamCount do
begin
if LowerCase(ParamStr(i)) = '/langsetup' then
begin
LanguageForm;
Result := False;
break;
end;
end;
end;
begin
end.
; vim: fileencoding=windows-1250 fencs=windows-1250: