1 ; Inno Setup Script for Wammu installation
2 ; Copyright (c) 2006 Michal Èihaø
3 ; Language selection code based on GTK+ 2 installation script
4 ; made by Jernej Simoncic, <jernej.simoncic@guest.arnes.si>
6 #define MyAppDosName
"wammu"
7 #define MyAppName
"Wammu"
8 #define MyAppVersion
"0.30"
9 #define MyAppPublisher
"Micha Èihaø"
10 #define MyAppURL
"http://wammu.eu/"
11 #define MyAppPublisherURL
"http://cihar.com/"
12 #define MyAppBugsURL
"http://bugs.wammu.eu/"
13 #define MyAppDescription
"Wammu Mobile Phone Manager"
14 #define MyAppExeName
"wammu.exe"
15 #define MyAppUrlName
"wammu.url"
16 #define MyAppBugsUrlName
"wammu-bugs.url"
20 AppVerName
={#MyAppName} {#MyAppVersion}
21 AppPublisher
={#MyAppPublisher}
22 AppPublisherURL
={#MyAppPublisherURL}
23 AppSupportURL
={#MyAppBugsURL}
24 AppUpdatesURL
={#MyAppURL}
25 DefaultDirName
={pf}\
{#MyAppName}
26 DefaultGroupName
={#MyAppName}
29 OutputBaseFilename
={#MyAppDosName}-{#MyAppVersion}-setup
30 Compression
=lzma
/ultra
32 InternalCompressLevel
=ultra
33 VersionInfoVersion
={#MyAppVersion}
34 VersionInfoCompany
={#MyAppPublisher}
35 VersionInfoDescription
={#MyAppDescription}
36 ShowLanguageDialog
=yes
37 AppVersion
={#MyAppVersion}
38 UninstallDisplayIcon
={app}\share\pixmaps\wammu
.ico
39 AppModifyPath
="{uninstallexe}" /langsetup
40 ChangesEnvironment
=true
41 ;SetupIconFile={app}\icon\wammu.ico
44 Name
: en
; MessagesFile
: compiler
:Default
.isl
45 ;Name: af; MessagesFile: compiler:Languages\Afrikaans.isl
46 Name
: ca
; MessagesFile
: compiler
:Languages\Catalan
.isl
47 Name
: cs
; MessagesFile
: compiler
:Languages\Czech
.isl
48 Name
: de
; MessagesFile
: compiler
:Languages\German
.isl
49 ;Name: el; MessagesFile: compiler:Languages\Greek.isl
50 Name
: es
; MessagesFile
: compiler
:Languages\Spanish
.isl
51 ;Name: et; MessagesFile: compiler:Languages\Estonian.isl
52 Name
: fi
; MessagesFile
: compiler
:Languages\Finnish
.isl
53 Name
: fr
; MessagesFile
: compiler
:Languages\French
.isl
54 ;Name: gl; MessagesFile: compiler:Languages\Galician.isl
55 Name
: he
; MessagesFile
: compiler
:Languages\Hebrew
.isl
56 Name
: hu
; MessagesFile
: compiler
:Languages\Hungarian
.isl
57 ;Name: id; MessagesFile: compiler:Languages\Indonesian.isl
58 Name
: it
; MessagesFile
: compiler
:Languages\Italian
.isl
59 ;Name: ko; MessagesFile: compiler:Languages\Korean.isl
60 Name
: nl
; MessagesFile
: compiler
:Languages\Dutch
.isl
61 Name
: pl
; MessagesFile
: compiler
:Languages\Polish
.isl
62 Name
: pt_BR
; MessagesFile
: compiler
:Languages\BrazilianPortuguese
.isl
63 Name
: ru
; MessagesFile
: compiler
:Languages\Russian
.isl
64 Name
: sk
; MessagesFile
: compiler
:Languages\Slovak
.isl
65 ;Name: sv; MessagesFile: compiler:Languages\Swedish.isl
66 ;Name: zh_tw; MessagesFile: compiler:Languages\SimpChinese.isl
67 ;Name: zh_cz; MessagesFile: compiler:Languages\TradChinese.isl
70 Name
: desktopicon; Description
: {cm:CreateDesktopIcon}; GroupDescription
: {cm:AdditionalIcons}; Flags
: unchecked
73 Source
: dist\
*; DestDir
: {app}; Flags
: ignoreversion recursesubdirs createallsubdirs
; Excludes
: locale
74 Source
: uninst
.isl
; DestDir
: {app}
75 Source
: dist\share\locale\
*; DestDir
: {app}\share\locale
; Flags
: ignoreversion recursesubdirs createallsubdirs
; Components
: " Translations"; Tasks
: ; Languages
:
78 Filename
: {app}\
{#MyAppUrlName}; Section
: InternetShortcut
; Key
: URL
; String: {#MyAppURL}
79 Filename
: {app}\
{#MyAppBugsUrlName}; Section
: InternetShortcut
; Key
: URL
; String: {#MyAppBugsURL}
82 Name
: {group}\
{#MyAppName}; Filename
: {app}\
{#MyAppExeName}; IconFilename
: {app}\share\pixmaps\wammu
.ico
; IconIndex
: 0
83 Name
: {group}\
{cm:ProgramOnTheWeb,{#MyAppName}}
; Filename
: {app}\
{#MyAppUrlName}
84 Name
: {group}\
{cm:ReportBug,{#MyAppName}}
; Filename
: {app}\
{#MyAppBugsUrlName}
85 Name
: {group}\
{cm:UninstallProgram,{#MyAppName}}
; Filename
: {uninstallexe}
86 Name
: {userdesktop}\
{#MyAppName}; Filename
: {app}\
{#MyAppExeName}; Tasks
: desktopicon
87 Name
: {group}\
{cm:SelectLanguage}; Filename
: {uninstallexe}; Parameters
: /langsetup
; IconFilename
: {app}\share\pixmaps\wammu
.ico
; IconIndex
: 0
90 Filename
: {app}\
{#MyAppExeName}; Description
: {cm:LaunchProgram,{#MyAppName}}
; Flags
: nowait postinstall skipifsilent unchecked
91 Filename
: {uninstallexe}; Parameters
: /langsetup
; Description
: {cm:SelectLanguage}; Flags
: postinstall nowait
94 Name
: Translations
; Description
: {cm:TranslationsDesc}; Types
: custom
full; Languages
:
97 Type: files; Name
: {app}\
{#MyAppUrlName}
98 Type: files; Name
: {app}\
{#MyAppBugsUrlName}
101 en
.ReportBug
=Report bug
in application
%1
102 cs
.ReportBug
=Nahlásit chybu v aplikaci
%1
103 en
.SelectLanguage
=Select application language
104 cs
.SelectLanguage
=Zvolit jazyk aplikace
105 en
.Translations
=Translations
106 en
.TranslationsDesc
=Translations
of user
interface
107 cs
.Translations
=Pøeklady
108 cs
.TranslationsDesc
=Pøeklady uživatelského rozhraní
111 Root
: HKCU
; Subkey
: Environment
; ValueType
: string; ValueName
: LANG
; ValueData
: {language}; Check
: UsingWinNT
113 ; Following part is heavily based on GTK+ 2 setup
117 function SendMessageTimeout(hWnd
: HWND
; Msg
: Cardinal; wParam
: DWORD
; lParam
: String; fuFlags
, uTimeout
: Cardinal; lpdwResult
: DWORD
): {Int64}Cardinal; external 'SendMessageTimeoutA@user32 stdcall';
120 frmLangChooser
: TForm
;
121 cbUser
, cbSystem
: TComboBox
;
124 WM_SETTINGCHANGE
= 26;
125 //HWND_BROADCAST
= $FFFF;
126 SMTO_ABORTIFHUNG
= 2;
128 function RevPos(const SearchStr
, Str
: string): Integer;
132 if (Length(SearchStr
) < Length(Str
)) and (Pos(SearchStr
, Str
) > 0) then
133 for i
:= (Length(Str
) - Length(SearchStr
) + 1) downto 1 do
136 if Copy(Str
, i
, Length(SearchStr
)) = SearchStr
then
148 function ExtractLang(const Txt
: String): String;
153 if (S
[Length(S
)] = ')') then
157 S
:= Copy(Txt
,i
+1,Length(Txt
)-i
-1)
167 function GetLangIndex(Items
: TStrings
; Lang
: String): Integer;
171 Lang
:= LowerCase(Lang
);
172 for i
:= 0 to Items
.Count
- 1 do
174 S
:= LowerCase(ExtractLang(Items
.Strings
[i
]));
179 if (i
>= Items
.Count
) then
186 function GetTransStr(const Str
: String): String; //ExpandConstant('{cm:...}') doesn
't work on uninstall
188 Result := GetIniString('CustomMessages
',Str,'',ExpandConstant('{app}\uninst
.isl
'));
190 if (Result = '') then
191 RaiseException(Str + ' not found
in translation
file.');
195 procedure LanguageForm;
196 var lblInfo, lblUser, lblSystem: TLabel;
197 btnOK,btnCancel: TButton;
200 lang1,lang2,regSys,regUser: String;
201 AutoExec: TArrayOfString;
205 frmLangChooser := CreateCustomForm();
207 with frmLangChooser do
209 ClientWidth := ScaleX(321);
210 ClientHeight := ScaleY(119);
211 Caption := GetTransStr('LangTitle
');
212 Position := poScreenCenter;
216 lblInfo := TLabel.Create(frmLangChooser);
219 Parent := frmLangChooser;
222 Width := ScaleX(283);
223 Height := ScaleY(13);
224 Caption := GetTransStr('LangText
');
228 lblUser := TLabel.Create(frmLangChooser);
231 Parent := frmLangChooser;
234 Width := ScaleX(119);
235 Height := ScaleY(13);
236 Caption := GetTransStr('LangUser
');
237 FocusControl := cbUser;
241 lblSystem := TLabel.Create(frmLangChooser);
244 Parent := frmLangChooser;
248 Height := ScaleY(13);
249 Caption := GetTransStr('LangSystem
');
250 FocusControl := cbSystem;
254 cbUser := TComboBox.Create(frmLangChooser);
257 Parent := frmLangChooser;
258 Style := csDropDownList;
261 Width := ScaleX(169);
262 Height := ScaleY(16);
263 Hint := GetTransStr('LangUserHint
');
270 cbSystem := TComboBox.Create(frmLangChooser);
273 Parent := frmLangChooser;
274 Style := csDropDownList;
277 Width := ScaleX(169);
278 Height := ScaleY(16);
279 Hint := GetTransStr('LangSystemHint
');
286 btnOK := TButton.Create(frmLangChooser);
289 Parent := frmLangChooser;
293 Height := ScaleY(23);
294 Caption := SetupMessage(msgButtonOK);
301 btnCancel := TButton.Create(frmLangChooser);
304 Parent := frmLangChooser;
308 Height := ScaleY(23);
309 Caption := SetupMessage(msgButtonCancel);
315 cbUser.Items.Add(GetTransStr('LangDefault
'));
316 cbUser.Items.Add('English (C
)');
317 //cbSystem.Items.Add(GetTransStr('LangDefault
'));
319 if FindFirst(ExpandConstant('{app}\share\locale\
*'),frMsgs) then
324 if ((frMsgs.Attributes and FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY) and ((frMsgs.Name <> '.') and (frMsgs.Name <> '..')) then
328 lang1 := frMsgs.Name;
329 StringChange(lang1,'@','_
'); //custom messages only support letters,numbers and _
330 lang1 := GetTransStr('Lang_
'+lang1+'');
335 i := pos('@',frMsgs.Name);
336 if (lang1 = '') and (i > 0) then
338 lang1 := GetTransStr('Lang_
'+Copy(frMsgs.Name,1,i-1)+'');
339 lang2 := Copy(frMsgs.Name,i+1,length(frMsgs.Name))
344 if (lang1 = '') and (Length(frMsgs.Name) > 2) then
346 lang1 := GetTransStr('Lang_
'+Copy(frMsgs.Name,1,2)+'');
351 case lowercase(lang2) of
352 'latn
': lang2 := 'Latin
';
355 if (lang1 <> '') then
357 if (lang2 <> '') then
359 cbUser.Items.Add(lang1+' '+lang2+' ('+frMsgs.Name+')');
362 cbUser.Items.Add(lang1+' ('+frMsgs.Name+')');
366 cbUser.Items.Add(frMsgs.Name);
370 until not FindNext(frMsgs);
372 cbSystem.Items := cbUser.Items;
381 if not IsAdminLoggedOn then //only admins can change system-wide environment variables
383 cbSystem.Enabled := False;
384 lblSystem.Enabled := False;
387 if RegQueryStringValue(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment
','LANG
',regSys) then
388 cbSystem.ItemIndex := GetLangIndex(cbSystem.Items,regSys)
390 cbSystem.ItemIndex := 0;
392 if cbSystem.ItemIndex = -1 then
393 cbSystem.ItemIndex := cbSystem.Items.Add(regSys);
396 if RegQueryStringValue(HKEY_CURRENT_USER,'Environment
','LANG
',regUser) then
397 cbUser.ItemIndex := GetLangIndex(cbSystem.Items,regUser)
399 cbUser.ItemIndex := 0;
401 if cbUser.ItemIndex = -1 then
402 cbUser.ItemIndex := cbUser.Items.Add(regUser);
406 if frmLangChooser.ShowModal = 1 then
408 regSys := ExtractLang(cbSystem.Items.Strings[cbSystem.ItemIndex]);
412 regUser := ExtractLang(cbUser.Items.Strings[cbUser.ItemIndex]);
414 if cbUser.ItemIndex <> 0 then
416 if not RegWriteStringValue(HKEY_CURRENT_USER,'Environment
','LANG
',regUser) then
417 MsgBox(GetTransStr('LangRegUserFailed
'),mbCriticalError,mb_ok);
419 if RegValueExists(HKEY_CURRENT_USER,'Environment
','LANG
') and
420 (not RegDeleteValue(HKEY_CURRENT_USER,'Environment
','LANG
')) then
421 MsgBox(GetTransStr('LangRegUserFailed
'),mbCriticalError,mb_ok);
423 if IsAdminLoggedOn then
425 if cbSystem.ItemIndex <> 0 then
427 if not RegWriteStringValue(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment
','LANG
',regSys) then
428 MsgBox(GetTransStr('LangRegSysFailed
'),mbCriticalError,mb_ok);
430 if RegValueExists(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment
','LANG
') and
431 (not RegDeleteValue(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment
','LANG
')) then
432 MsgBox(GetTransStr('LangRegSysFailed
'),mbCriticalError,mb_ok);
435 //straight from the Inno source
436 SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 'Environment
', SMTO_ABORTIFHUNG, 5000, MsgResult);
440 if not FileCopy(ExpandConstant('{sd}\AutoExec
.bat
'),ExpandConstant('{sd}\AutoExec
.WAM
'),False) then
441 if MsgBox(GetTransStr('LangAutoExecBackupFailed
'),mbConfirmation,mb_yesno) = idno then
444 if LoadStringsFromFile(ExpandConstant('{sd}\Autoexec
.bat
'), AutoExec) then
446 for i := GetArrayLength(AutoExec) - 1 downto 0 do
447 if pos('set lang
=',LowerCase(AutoExec[i])) > 0 then
448 if (i>0) and (i<(GetArrayLength(AutoExec)-1))
449 and (LowerCase(AutoExec[i-1]) = 'REM
/=== by Wammu Language Setup
===\')
450 and (LowerCase(AutoExec
[i
+1]) = 'REM \=== by Wammu Language Setup ===/') then
452 for j
:= i
to GetArrayLength(AutoExec
) - 2 do //remove previous setting
453 AutoExec
[j
-1] := AutoExec
[j
+1];
454 SetArrayLength(AutoExec
,GetArrayLength(AutoExec
) - 3);
457 i
:= GetArrayLength(AutoExec
);
458 SetArrayLength(AutoExec
,i
+ 3);
459 AutoExec
[i
] := 'REM /=== by Wammu Language Setup ===\';
460 AutoExec[i+1] := 'SET LANG
='+regSys;
461 AutoExec[i+2] := 'REM \
=== by Wammu Language Setup
===/';
463 if SaveStringsToFile(ExpandConstant('{sd}\AutoExec
.bat
'),AutoExec,False) then
464 MsgBox(GetTransStr('LangRestartRequired
'),mbInformation,mb_ok)
466 MsgBox(GetTransStr('LangErrorSavingAutoExec
'),mbCriticalError,mb_ok);
469 MsgBox(GetTransStr('LangErrorLoadingAutoExec
'), mbCriticalError, MB_OK);
476 function InitializeUninstall(): Boolean;
482 for i := 1 to ParamCount do
484 if LowerCase(ParamStr(i)) = '/langsetup
' then
498 ; vim: fileencoding=windows-1250 fencs=windows-1250: