Do not install some files (man page, application shortcut).
[wammu.git] / wammu.iss
blob79aa19c4552367a3dccc9b8c7233f1ac0b5b8a0d
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"
18 [Setup]
19 AppName={#MyAppName}
20 AppVerName={#MyAppName} {#MyAppVersion}
21 AppPublisher={#MyAppPublisher}
22 AppPublisherURL={#MyAppPublisherURL}
23 AppSupportURL={#MyAppBugsURL}
24 AppUpdatesURL={#MyAppURL}
25 DefaultDirName={pf}\{#MyAppName}
26 DefaultGroupName={#MyAppName}
27 AllowNoIcons=true
28 LicenseFile=COPYING
29 OutputBaseFilename={#MyAppDosName}-{#MyAppVersion}-setup
30 Compression=lzma/ultra
31 SolidCompression=true
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
43 [Languages]
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
69 [Tasks]
70 Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
72 [Files]
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:
77 [INI]
78 Filename: {app}\{#MyAppUrlName}; Section: InternetShortcut; Key: URL; String: {#MyAppURL}
79 Filename: {app}\{#MyAppBugsUrlName}; Section: InternetShortcut; Key: URL; String: {#MyAppBugsURL}
81 [Icons]
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
89 [Run]
90 Filename: {app}\{#MyAppExeName}; Description: {cm:LaunchProgram,{#MyAppName}}; Flags: nowait postinstall skipifsilent unchecked
91 Filename: {uninstallexe}; Parameters: /langsetup; Description: {cm:SelectLanguage}; Flags: postinstall nowait
93 [UninstallDelete]
94 Type: files; Name: {app}\{#MyAppUrlName}
95 Type: files; Name: {app}\{#MyAppBugsUrlName}
97 [CustomMessages]
98 en.ReportBug=Report bug in application %1
99 cs.ReportBug=Nahlásit chybu v aplikaci %1
100 en.SelectLanguage=Select application language
101 cs.SelectLanguage=Zvolit jazyk aplikace
103 [Registry]
104 Root: HKCU; Subkey: Environment; ValueType: string; ValueName: LANG; ValueData: {language}; Check: UsingWinNT
106 ; Following part is heavily based on GTK+ 2 setup
107 [Code]
108 program Setup;
110 function SendMessageTimeout(hWnd: HWND; Msg: Cardinal; wParam: DWORD; lParam: String; fuFlags, uTimeout: Cardinal; lpdwResult: DWORD): {Int64}Cardinal; external 'SendMessageTimeoutA@user32 stdcall';
113 frmLangChooser: TForm;
114 cbUser, cbSystem: TComboBox;
116 const
117 WM_SETTINGCHANGE = 26;
118 //HWND_BROADCAST = $FFFF;
119 SMTO_ABORTIFHUNG = 2;
121 function RevPos(const SearchStr, Str: string): Integer;
122 var i: Integer;
123 begin
125 if (Length(SearchStr) < Length(Str)) and (Pos(SearchStr, Str) > 0) then
126 for i := (Length(Str) - Length(SearchStr) + 1) downto 1 do
127 begin
129 if Copy(Str, i, Length(SearchStr)) = SearchStr then
130 begin
131 Result := i;
132 exit;
133 end;
135 end;
137 Result := 0;
138 end;
141 function ExtractLang(const Txt: String): String;
142 var S: String;
143 i: Integer;
144 begin
145 S := LowerCase(Txt);
146 if (S[Length(S)] = ')') then
147 begin
148 i := RevPos('(',S);
149 if (i > 0) then
150 S := Copy(Txt,i+1,Length(Txt)-i-1)
151 else
152 S := Txt;
153 end else
154 S := Txt;
156 Result := S;
157 end;
160 function GetLangIndex(Items: TStrings; Lang: String): Integer;
161 var i: Integer;
162 s: String;
163 begin
164 Lang := LowerCase(Lang);
165 for i := 0 to Items.Count - 1 do
166 begin
167 S := LowerCase(ExtractLang(Items.Strings[i]));
168 if (S = Lang) then
169 break;
170 end;
172 if (i >= Items.Count) then
173 Result := -1
174 else
175 Result := i;
176 end;
179 function GetTransStr(const Str: String): String; //ExpandConstant('{cm:...}') doesn't work on uninstall
180 begin
181 Result := GetIniString('CustomMessages',Str,'',ExpandConstant('{app}\uninst.isl'));
183 if (Result = '') then
184 RaiseException(Str + ' not found in translation file.');
185 end;
188 procedure LanguageForm;
189 var lblInfo, lblUser, lblSystem: TLabel;
190 btnOK,btnCancel: TButton;
191 frMsgs: TFindRec;
192 i,j: Integer;
193 lang1,lang2,regSys,regUser: String;
194 AutoExec: TArrayOfString;
195 MsgResult: DWORD;
196 begin
198 frmLangChooser := CreateCustomForm();
200 with frmLangChooser do
201 begin
202 ClientWidth := ScaleX(321);
203 ClientHeight := ScaleY(119);
204 Caption := GetTransStr('LangTitle');
205 Position := poScreenCenter;
206 end;
208 { lblInfo }
209 lblInfo := TLabel.Create(frmLangChooser);
210 with lblInfo do
211 begin
212 Parent := frmLangChooser;
213 Left := ScaleX(8);
214 Top := ScaleY(8);
215 Width := ScaleX(283);
216 Height := ScaleY(13);
217 Caption := GetTransStr('LangText');
218 end;
220 { lblUser }
221 lblUser := TLabel.Create(frmLangChooser);
222 with lblUser do
223 begin
224 Parent := frmLangChooser;
225 Left := ScaleX(8);
226 Top := ScaleY(34);
227 Width := ScaleX(119);
228 Height := ScaleY(13);
229 Caption := GetTransStr('LangUser');
230 FocusControl := cbUser;
231 end;
233 { lblSystem }
234 lblSystem := TLabel.Create(frmLangChooser);
235 with lblSystem do
236 begin
237 Parent := frmLangChooser;
238 Left := ScaleX(8);
239 Top := ScaleY(58);
240 Width := ScaleX(93);
241 Height := ScaleY(13);
242 Caption := GetTransStr('LangSystem');
243 FocusControl := cbSystem;
244 end;
246 { cbUser }
247 cbUser := TComboBox.Create(frmLangChooser);
248 with cbUser do
249 begin
250 Parent := frmLangChooser;
251 Style := csDropDownList;
252 Left := ScaleX(144);
253 Top := ScaleY(32);
254 Width := ScaleX(169);
255 Height := ScaleY(16);
256 Hint := GetTransStr('LangUserHint');
257 ShowHint := True;
258 TabOrder := 0;
259 Sorted := True;
260 end;
262 { cbSystem }
263 cbSystem := TComboBox.Create(frmLangChooser);
264 with cbSystem do
265 begin
266 Parent := frmLangChooser;
267 Style := csDropDownList;
268 Left := ScaleX(144);
269 Top := ScaleY(56);
270 Width := ScaleX(169);
271 Height := ScaleY(16);
272 Hint := GetTransStr('LangSystemHint');
273 ShowHint := True;
274 TabOrder := 1;
275 Sorted := True;
276 end;
278 { btnOK }
279 btnOK := TButton.Create(frmLangChooser);
280 with btnOK do
281 begin
282 Parent := frmLangChooser;
283 Left := ScaleX(82);
284 Top := ScaleY(88);
285 Width := ScaleX(75);
286 Height := ScaleY(23);
287 Caption := SetupMessage(msgButtonOK);
288 Default := True;
289 TabOrder := 2;
290 ModalResult := 1;
291 end;
293 { btnCancel }
294 btnCancel := TButton.Create(frmLangChooser);
295 with btnCancel do
296 begin
297 Parent := frmLangChooser;
298 Left := ScaleX(164);
299 Top := ScaleY(88);
300 Width := ScaleX(75);
301 Height := ScaleY(23);
302 Caption := SetupMessage(msgButtonCancel);
303 Cancel := True;
304 TabOrder := 3;
305 ModalResult := 2;
306 end;
308 cbUser.Items.Add(GetTransStr('LangDefault'));
309 cbUser.Items.Add('English (C)');
310 //cbSystem.Items.Add(GetTransStr('LangDefault'));
312 if FindFirst(ExpandConstant('{app}\share\locale\*'),frMsgs) then
313 begin
316 repeat
317 if ((frMsgs.Attributes and FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY) and ((frMsgs.Name <> '.') and (frMsgs.Name <> '..')) then
318 begin
321 lang1 := frMsgs.Name;
322 StringChange(lang1,'@','_'); //custom messages only support letters,numbers and _
323 lang1 := GetTransStr('Lang_'+lang1+'');
324 except
325 lang1 := '';
326 end;
328 i := pos('@',frMsgs.Name);
329 if (lang1 = '') and (i > 0) then
331 lang1 := GetTransStr('Lang_'+Copy(frMsgs.Name,1,i-1)+'');
332 lang2 := Copy(frMsgs.Name,i+1,length(frMsgs.Name))
333 except
334 lang1 := '';
335 end;
337 if (lang1 = '') and (Length(frMsgs.Name) > 2) then
339 lang1 := GetTransStr('Lang_'+Copy(frMsgs.Name,1,2)+'');
340 except
341 lang1 := '';
342 end;
344 case lowercase(lang2) of
345 'latn': lang2 := 'Latin';
346 end;
348 if (lang1 <> '') then
349 begin
350 if (lang2 <> '') then
351 begin
352 cbUser.Items.Add(lang1+' '+lang2+' ('+frMsgs.Name+')');
353 end else
354 begin
355 cbUser.Items.Add(lang1+' ('+frMsgs.Name+')');
357 end else
358 begin
359 cbUser.Items.Add(frMsgs.Name);
360 end;
362 end;
363 until not FindNext(frMsgs);
365 cbSystem.Items := cbUser.Items;
367 finally
368 FindClose(frMsgs);
369 end;
370 end;
372 if UsingWinNT then
373 begin
374 if not IsAdminLoggedOn then //only admins can change system-wide environment variables
375 begin
376 cbSystem.Enabled := False;
377 lblSystem.Enabled := False;
378 end;
380 if RegQueryStringValue(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment','LANG',regSys) then
381 cbSystem.ItemIndex := GetLangIndex(cbSystem.Items,regSys)
382 else
383 cbSystem.ItemIndex := 0;
385 if cbSystem.ItemIndex = -1 then
386 cbSystem.ItemIndex := cbSystem.Items.Add(regSys);
389 if RegQueryStringValue(HKEY_CURRENT_USER,'Environment','LANG',regUser) then
390 cbUser.ItemIndex := GetLangIndex(cbSystem.Items,regUser)
391 else
392 cbUser.ItemIndex := 0;
394 if cbUser.ItemIndex = -1 then
395 cbUser.ItemIndex := cbUser.Items.Add(regUser);
396 end;
399 if frmLangChooser.ShowModal = 1 then
400 begin
401 regSys := ExtractLang(cbSystem.Items.Strings[cbSystem.ItemIndex]);
403 if UsingWinNT then
404 begin
405 regUser := ExtractLang(cbUser.Items.Strings[cbUser.ItemIndex]);
407 if cbUser.ItemIndex <> 0 then
408 begin
409 if not RegWriteStringValue(HKEY_CURRENT_USER,'Environment','LANG',regUser) then
410 MsgBox(GetTransStr('LangRegUserFailed'),mbCriticalError,mb_ok);
411 end else
412 if RegValueExists(HKEY_CURRENT_USER,'Environment','LANG') and
413 (not RegDeleteValue(HKEY_CURRENT_USER,'Environment','LANG')) then
414 MsgBox(GetTransStr('LangRegUserFailed'),mbCriticalError,mb_ok);
416 if IsAdminLoggedOn then
417 begin
418 if cbSystem.ItemIndex <> 0 then
419 begin
420 if not RegWriteStringValue(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment','LANG',regSys) then
421 MsgBox(GetTransStr('LangRegSysFailed'),mbCriticalError,mb_ok);
422 end else
423 if RegValueExists(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment','LANG') and
424 (not RegDeleteValue(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment','LANG')) then
425 MsgBox(GetTransStr('LangRegSysFailed'),mbCriticalError,mb_ok);
426 end;
428 //straight from the Inno source
429 SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 'Environment', SMTO_ABORTIFHUNG, 5000, MsgResult);
431 end else
432 begin
433 if not FileCopy(ExpandConstant('{sd}\AutoExec.bat'),ExpandConstant('{sd}\AutoExec.WAM'),False) then
434 if MsgBox(GetTransStr('LangAutoExecBackupFailed'),mbConfirmation,mb_yesno) = idno then
435 exit;
437 if LoadStringsFromFile(ExpandConstant('{sd}\Autoexec.bat'), AutoExec) then
438 begin
439 for i := GetArrayLength(AutoExec) - 1 downto 0 do
440 if pos('set lang=',LowerCase(AutoExec[i])) > 0 then
441 if (i>0) and (i<(GetArrayLength(AutoExec)-1))
442 and (LowerCase(AutoExec[i-1]) = 'REM /=== by Wammu Language Setup ===\')
443 and (LowerCase(AutoExec[i+1]) = 'REM \=== by Wammu Language Setup ===/') then
444 begin
445 for j := i to GetArrayLength(AutoExec) - 2 do //remove previous setting
446 AutoExec[j-1] := AutoExec[j+1];
447 SetArrayLength(AutoExec,GetArrayLength(AutoExec) - 3);
448 end;
450 i := GetArrayLength(AutoExec);
451 SetArrayLength(AutoExec,i + 3);
452 AutoExec[i] := 'REM /=== by Wammu Language Setup ===\';
453 AutoExec[i+1] := 'SET LANG='+regSys;
454 AutoExec[i+2] := 'REM \=== by Wammu Language Setup ===/';
456 if SaveStringsToFile(ExpandConstant('{sd}\AutoExec.bat'),AutoExec,False) then
457 MsgBox(GetTransStr('LangRestartRequired'),mbInformation,mb_ok)
458 else
459 MsgBox(GetTransStr('LangErrorSavingAutoExec'),mbCriticalError,mb_ok);
461 end else
462 MsgBox(GetTransStr('LangErrorLoadingAutoExec'), mbCriticalError, MB_OK);
463 end;
464 end;
466 end;
469 function InitializeUninstall(): Boolean;
470 var i: Integer;
471 begin
473 Result := True;
475 for i := 1 to ParamCount do
476 begin
477 if LowerCase(ParamStr(i)) = '/langsetup' then
478 begin
479 LanguageForm;
480 Result := False;
481 break;
482 end;
483 end;
486 end;
488 begin
489 end.
490 [Components]
491 Name: Translations; Description: Translation data; Types: custom full; Languages: