winscpsetup.iss 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485
  1. #define AppId "winscp3"
  2. #define ParentRegistryKey "Software\Martin Prikryl"
  3. #define RegistryKey ParentRegistryKey+"\WinSCP 2"
  4. #define DefaultLang "en"
  5. #define WebRoot "http://winscp.net/"
  6. #define WebForum WebRoot+"forum/"
  7. #define WebDocumentation WebRoot+"eng/docs/"
  8. #define WebReport WebRoot+"install.php"
  9. #define WebPuTTY "http://www.chiark.greenend.org.uk/~sgtatham/putty/"
  10. #define Year 2013
  11. #define EnglishLang "English"
  12. #define SetupTypeData "SetupType"
  13. #define InnoSetupReg "Software\Microsoft\Windows\CurrentVersion\Uninstall\" + AppId + "_is1"
  14. #define InnoSetupAppPathReg "Inno Setup: App Path"
  15. #ifndef PuttySourceDir
  16. #define PuttySourceDir "c:\Program Files\PuTTY"
  17. #endif
  18. #ifndef Status
  19. #define Status "unofficial"
  20. #endif
  21. #ifndef SourceDir
  22. #define SourceDir "..\source"
  23. #endif
  24. #ifndef BinariesDir
  25. #define BinariesDir SourceDir + "\Release"
  26. #endif
  27. #ifndef OutputSuffix
  28. #define OutputSuffix
  29. #endif
  30. #ifndef AllTranslations
  31. #define AllTranslations
  32. #endif
  33. #define TranslationDirRel "translations"
  34. #define TranslationDir "translations"
  35. #define OutputDir "."
  36. #define TranslationFileMask "WinSCP.???"
  37. #define MainFileName "WinSCP.exe"
  38. #define MainFileSource BinariesDir+"\"+MainFileName
  39. #define ShellExtFileSource BinariesDir+"\DragExt.dll"
  40. #define ShellExt64FileSource BinariesDir+"\DragExt64.dll"
  41. #define ConsoleFileSource BinariesDir+"\WinSCP.com"
  42. #define IconFileSource SourceDir+"\resource\Icon256.ico"
  43. #ifdef Donations
  44. #define PayPalCardImage "paypalcard.bmp"
  45. #endif
  46. #define Major
  47. #define Minor
  48. #define Rev
  49. #define Build
  50. #expr ParseVersion(MainFileSource, Major, Minor, Rev, Build)
  51. #define VersionOnly Str(Major)+"."+Str(Minor)+(Rev > 0 ? "."+Str(Rev) : "")
  52. #define Version VersionOnly+(Status != "" ? " "+Status : "")
  53. #define WebArguments "ver=" +VersionOnly + "&lang={language}&utm_source=winscp&utm_medium=setup&utm_campaign=" + VersionOnly
  54. #define WebGettingStarted WebRoot + "eng/installed.php?" + WebArguments + "&prevver="
  55. #ifdef OpenCandy
  56. #include "opencandy\OCSetupHlp.iss"
  57. #endif
  58. ; Some features of ISCC requires path relative to script,
  59. ; some path relative to CWD
  60. #define MessagesPathRel(L) TranslationDirRel + "\" + "WinSCP." + L + ".isl"
  61. #define ExplorerFile "explorer.bmp"
  62. #define CommanderFile "commander.bmp"
  63. #ifdef Chrome
  64. #define ChromeLogoFile "chromelogo.bmp"
  65. #define ChromeAdFile "chromead.bmp"
  66. #define ChromeGcApiDllFile "gcapi_dll.dll"
  67. #define ChromeCheckerFile "chromech.exe"
  68. #define ChromeInstallerFile "WinSCP_Chrome.exe"
  69. #define ChromeBrandCode1 "WSCA"
  70. #define ChromeBrandCode2 "WSCB"
  71. #include "chrome\texts.iss"
  72. #endif
  73. [Setup]
  74. AppId={#AppId}
  75. AppName=WinSCP
  76. AppMutex=WinSCP
  77. AppPublisher=Martin Prikryl
  78. AppPublisherURL={#WebRoot}
  79. AppSupportURL={#WebForum}
  80. AppUpdatesURL={#WebRoot}eng/download.php
  81. VersionInfoCompany=Martin Prikryl
  82. VersionInfoDescription=Setup for WinSCP {#Version} (SFTP, FTP and SCP client)
  83. VersionInfoVersion={#Major}.{#Minor}.{#Rev}.{#Build}
  84. VersionInfoTextVersion={#Version}
  85. VersionInfoCopyright=(c) 2000-{#Year} Martin Prikryl
  86. DefaultDirName={pf}\WinSCP
  87. DefaultGroupName=WinSCP
  88. AllowNoIcons=yes
  89. #ifdef Chrome
  90. LicenseFile=licence.setup-chrome.txt
  91. #else
  92. LicenseFile=licence.setup.txt
  93. #endif
  94. UninstallDisplayIcon={app}\WinSCP.exe
  95. OutputDir={#OutputDir}
  96. DisableStartupPrompt=yes
  97. AppVersion={#Version}
  98. AppVerName=WinSCP {#Version}
  99. OutputBaseFilename=winscp{#Major}{#Minor}{#Rev}setup{#OutputSuffix}
  100. SolidCompression=yes
  101. WizardImageFile=compiler:WizModernImage-IS.bmp
  102. WizardSmallImageFile=compiler:WizModernSmallImage-IS.bmp
  103. ShowTasksTreeLines=yes
  104. PrivilegesRequired=none
  105. UsePreviousLanguage=yes
  106. DisableProgramGroupPage=yes
  107. MinVersion=0,5.1
  108. #ifdef Sign
  109. SignTool=sign $f "WinSCP Installer" http://winscp.net/eng/docs/installation
  110. #endif
  111. #ifdef Chrome
  112. RestartIfNeededByRun=no
  113. #endif
  114. [Languages]
  115. Name: {#DefaultLang}; MessagesFile: {#MessagesPathRel(DefaultLang)}
  116. #define FindHandle
  117. #dim Languages[200]
  118. #define LanguageCount 0
  119. #define AnyLanguageComplete 0
  120. #define LangI
  121. #define Complete
  122. #define DirName
  123. #define DirNameRel
  124. #sub ProcessTranslationFile
  125. #define FileName FindGetFileName(FindHandle)
  126. #define Lang Copy(FileName, Pos(".", FileName)+1)
  127. #define MessagesPath DirName + "\" + "WinSCP." + Lang + ".isl"
  128. #define LangNameFull ReadIni(MessagesPath, "LangOptions", "LanguageName")
  129. #define Sep Pos(" - ", LangNameFull)
  130. #if Sep > 0
  131. #define LangName Copy(LangNameFull, 1, Sep - 1)
  132. #else
  133. #define LangName LangNameFull
  134. #endif
  135. #define LangID ReadIni(MessagesPath, "LangOptions", "LanguageID")
  136. #expr Languages[LanguageCount*4] = Lang
  137. #expr Languages[LanguageCount*4+1] = LangName
  138. #expr Languages[LanguageCount*4+2] = LangID
  139. #expr Languages[LanguageCount*4+3] = Complete
  140. #expr LanguageCount++
  141. #if Complete == 1
  142. Name: {#Lang}; MessagesFile: {#MessagesPathRel(Lang)}
  143. #expr AnyLanguageComplete = 1
  144. #endif
  145. #endsub /* sub ProcessTranslationFile */
  146. #sub ProcessTranslationDir
  147. #if FindHandle = FindFirst(DirNameRel + "\" + TranslationFileMask, 0)
  148. #define FResult 1
  149. #for {0; FResult; FResult = FindNext(FindHandle)} ProcessTranslationFile
  150. #expr FindClose(FindHandle)
  151. #endif
  152. #endsub /* sub ProcessTranslationDir */
  153. #expr Complete = 1
  154. #expr DirName = TranslationDir
  155. #expr DirNameRel = TranslationDirRel
  156. #emit ProcessTranslationDir
  157. #ifdef TranslationIncompleteDir
  158. #expr Complete = 0
  159. #expr DirName = TranslationIncompleteDir
  160. #expr DirNameRel = TranslationIncompleteDirRel
  161. #emit ProcessTranslationDir
  162. #endif
  163. ; Types are not used anymore, they are preserved only to let setup
  164. ; detect previous installation type and decide between typical/custom setup
  165. [Types]
  166. Name: full; Description: "full"
  167. Name: compact; Description: "compact"
  168. Name: custom; Description: "custom"; Flags: iscustom
  169. [Components]
  170. Name: main; Description: {cm:ApplicationComponent}; \
  171. Types: full custom compact; Flags: fixed
  172. Name: shellext; Description: {cm:ShellExtComponent}; \
  173. Types: full compact
  174. Name: pageant; Description: {cm:PageantComponent}; \
  175. Types: full
  176. Name: puttygen; Description: {cm:PuTTYgenComponent}; \
  177. Types: full
  178. #if AnyLanguageComplete == 1
  179. Name: transl; Description: {cm:TranslationsComponent}; \
  180. Types: full
  181. #endif
  182. [Tasks]
  183. Name: enableupdates; Description: {cm:EnableUpdates}
  184. Name: enableupdates\enablecollectusage; Description: {cm:EnableCollectUsage}
  185. ; Windows integration
  186. Name: desktopicon; Description: {cm:DesktopIconTask}
  187. Name: desktopicon\user; Description: {cm:DesktopIconUserTask}; \
  188. Flags: exclusive unchecked
  189. Name: desktopicon\common; Description: {cm:DesktopIconCommonTask}; \
  190. Flags: exclusive
  191. ; No Quick Launch on Win7
  192. Name: quicklaunchicon; Description: {cm:QuickLaunchIconTask}; \
  193. Flags: unchecked; OnlyBelowVersion: 6.1.7600
  194. Name: sendtohook; Description: {cm:SendToHookTask}
  195. Name: urlhandler; Description: {cm:RegisterAsUrlHandler}
  196. Name: searchpath; Description: {cm:AddSearchPath}; \
  197. Flags: unchecked; Check: IsAdminLoggedOn
  198. [Icons]
  199. Name: "{commonprograms}\WinSCP"; Filename: "{app}\WinSCP.exe"; Components: main; \
  200. Comment: "{cm:ProgramComment}"
  201. ; This is created when desktopicon task is selected
  202. Name: "{userdesktop}\WinSCP"; Filename: "{app}\WinSCP.exe"; \
  203. Tasks: desktopicon\user
  204. Name: "{commondesktop}\WinSCP"; Filename: "{app}\WinSCP.exe"; \
  205. Tasks: desktopicon\common
  206. ; This is created when quicklaunchicon task is selected
  207. Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\WinSCP"; \
  208. Filename: "{app}\WinSCP.exe"; Tasks: quicklaunchicon
  209. ; This is created when sendtohook task is selected
  210. Name: "{sendto}\{cm:SendToHookNew}"; Filename: "{app}\WinSCP.exe"; \
  211. Parameters: "/upload"; Tasks: sendtohook
  212. [InstallDelete]
  213. Type: files; Name: "{app}\licence"
  214. Type: files; Name: "{group}\{cm:WebSite}.url"
  215. Type: files; Name: "{group}\{cm:SupportForum}.url"
  216. Type: files; Name: "{group}\{cm:DocumentationPage}.url"
  217. Type: files; Name: "{group}\{cm:RSAKeyTools}\{cm:PuTTYgenManual}.lnk"
  218. Type: files; Name: "{group}\{cm:RSAKeyTools}\{cm:PageantManual}.lnk"
  219. Type: files; Name: "{group}\{cm:RSAKeyTools}\{cm:PuttyWebSite}.url"
  220. ; Legacy sendto hook (SCP-only), only english link is removed
  221. Type: files; Name: "{sendto}\WinSCP3 (upload using SCP).lnk"
  222. Type: files; Name: "{group}\{cm:RSAKeyTools}\{cm:KeysManual}.lnk"
  223. Type: files; Name: "{app}\{cm:SupportForum}.url"
  224. Type: files; Name: "{app}\{cm:DocumentationPage}.url"
  225. Type: files; Name: "{app}\WinSCP.url"
  226. Type: files; Name: "{app}\PuTTY\PuTTY.url"
  227. ; Remove links to winscp3
  228. Type: files; Name: "{app}\WinSCP3.exe"
  229. Type: files; Name: "{app}\WinSCP3.com"
  230. Type: files; Name: "{group}\WinSCP3.lnk"
  231. Type: files; Name: "{userdesktop}\WinSCP3.lnk"
  232. Type: files; Name: "{commondesktop}\WinSCP3.lnk"
  233. Type: files; Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\WinSCP3.lnk"
  234. Type: files; Name: "{sendto}\{cm:SendToHook}.lnk"
  235. ; Remove
  236. Type: filesandordirs; Name: "{commonprograms}\WinSCP"
  237. Type: filesandordirs; Name: "{userprograms}\WinSCP"
  238. [Run]
  239. ; This is called when urlhandler task is selected
  240. Filename: "{app}\WinSCP.exe"; Parameters: "/RegisterAsUrlHandler"; \
  241. StatusMsg: {cm:RegisteringAsUrlHandler}; Tasks: urlhandler
  242. Filename: "{app}\WinSCP.exe"; Parameters: "/AddSearchPath"; \
  243. StatusMsg: {cm:AddingSearchPath}; Tasks: searchpath
  244. Filename: "{app}\WinSCP.exe"; Parameters: "/ImportSitesIfAny"; \
  245. StatusMsg: {cm:ImportSites}
  246. #ifdef Chrome
  247. Filename: "{tmp}\{#ChromeInstallerFile}"; \
  248. Parameters: "/r1:{#ChromeBrandCode1} /r2:{#ChromeBrandCode2} /b:1"; \
  249. StatusMsg: {cm:ChromeInstalling}; \
  250. Check: IsChromeSelected and IsChromeDefaultSelected
  251. Filename: "{tmp}\{#ChromeInstallerFile}"; \
  252. Parameters: "/r1:{#ChromeBrandCode1} /r2:{#ChromeBrandCode2} /b:0"; \
  253. StatusMsg: {cm:ChromeInstalling}; \
  254. Check: IsChromeSelected and (not IsChromeDefaultSelected)
  255. #endif
  256. [UninstallDelete]
  257. ; These additional files are created by application
  258. Type: files; Name: "{app}\WinSCP.ini"
  259. Type: files; Name: "{app}\WinSCP.cgl"
  260. ; WinSCP3 may remain from previous version, note that we do not delete it on
  261. ; upgrade, only duplicate into WinSCP.ini, see [Files]
  262. Type: files; Name: "{app}\WinSCP3.ini"
  263. [Files]
  264. Source: "{#MainFileSource}"; DestDir: "{app}"; \
  265. Components: main; Flags: ignoreversion
  266. ; If WinSCP3.ini already exists on target system, copy it into WinSCP.ini
  267. ; (if WinSCP.ini does not exist yet)
  268. Source: "{app}\WinSCP3.ini"; DestName: "WinSCP.ini"; DestDir: "{app}"; \
  269. Components: main; Flags: ignoreversion external skipifsourcedoesntexist onlyifdoesntexist
  270. Source: "{#ConsoleFileSource}"; DestDir: "{app}"; \
  271. Components: main; Flags: ignoreversion
  272. Source: "licence.txt"; DestDir: "{app}"; \
  273. Components: main; Flags: ignoreversion
  274. Source: "{#ShellExtFileSource}"; DestDir: "{app}"; \
  275. Components: shellext; \
  276. Flags: regserver restartreplace uninsrestartdelete; \
  277. Check: not IsWin64
  278. Source: "{#ShellExt64FileSource}"; DestDir: "{app}"; \
  279. Components: shellext; \
  280. Flags: regserver restartreplace uninsrestartdelete; \
  281. Check: IsWin64
  282. Source: "{#PuttySourceDir}\LICENCE"; DestDir: "{app}\PuTTY"; \
  283. Components: pageant puttygen; Flags: ignoreversion
  284. Source: "{#PuttySourceDir}\putty.hlp"; DestDir: "{app}\PuTTY"; \
  285. Components: pageant puttygen; Flags: ignoreversion
  286. Source: "{#PuttySourceDir}\pageant.exe"; DestDir: "{app}\PuTTY"; \
  287. Components: pageant; Flags: ignoreversion
  288. Source: "{#PuttySourceDir}\puttygen.exe"; DestDir: "{app}\PuTTY"; \
  289. Components: puttygen; Flags: ignoreversion
  290. Source: "{#ExplorerFile}"; Flags: dontcopy
  291. Source: "{#CommanderFile}"; Flags: dontcopy
  292. #ifdef Donations
  293. Source: "{#PayPalCardImage}"; \
  294. Flags: dontcopy
  295. #endif
  296. #ifdef OpenCandy
  297. Source: "{#OC_OCSETUPHLP_FILE_PATH}"; \
  298. Flags: dontcopy ignoreversion deleteafterinstall
  299. #endif
  300. #ifdef Chrome
  301. Source: "chrome\{#ChromeLogoFile}"; Flags: dontcopy
  302. Source: "chrome\{#ChromeAdFile}"; Flags: dontcopy
  303. Source: "chrome\{#ChromeGcApiDllFile}"; Flags: dontcopy
  304. Source: "chrome\{#ChromeCheckerFile}"; Flags: dontcopy
  305. Source: "chrome\{#ChromeInstallerFile}"; DestDir: "{tmp}"; \
  306. Flags: deleteafterinstall; Check: IsChromeSelected
  307. #endif
  308. [Registry]
  309. Root: HKCU; Subkey: "{#ParentRegistryKey}"; Flags: uninsdeletekeyifempty
  310. Root: HKCU; Subkey: "{#RegistryKey}"; Flags: uninsdeletekeyifempty
  311. ; Norton Commander interface
  312. Root: HKCU; SubKey: "{#RegistryKey}\Configuration\Interface"; ValueType: dword; \
  313. ValueName: "Interface"; ValueData: 0; Check: UserSettings(1)
  314. Root: HKLM; SubKey: "{#RegistryKey}"; ValueType: dword; \
  315. ValueName: "DefaultInterfaceInterface"; ValueData: 0; \
  316. Check: UserSettings(1); Flags: noerror
  317. ; Explorer-like interface
  318. Root: HKCU; SubKey: "{#RegistryKey}\Configuration\Interface"; ValueType: dword; \
  319. ValueName: "Interface"; ValueData: 1; Check: not UserSettings(1)
  320. Root: HKLM; SubKey: "{#RegistryKey}"; ValueType: dword; \
  321. ValueName: "DefaultInterfaceInterface"; ValueData: 1; \
  322. Check: not UserSettings(1); Flags: noerror
  323. ; If installer enabled ddext, let it reset the settings on uninstall,
  324. ; so the default is used on the next run
  325. Root: HKCU; SubKey: "{#RegistryKey}\Configuration\Interface"; ValueType: dword; \
  326. ValueName: "DDExtEnabled"; ValueData: 1; Components: shellext; \
  327. Flags: uninsdeletevalue
  328. ; This will remove url handler on uninstall
  329. ; (when urlhandler task was selected when installing)
  330. Root: HKCR; Subkey: "SFTP"; Flags: dontcreatekey uninsdeletekey; \
  331. Tasks: urlhandler
  332. Root: HKCR; Subkey: "SCP"; Flags: dontcreatekey uninsdeletekey; \
  333. Tasks: urlhandler
  334. Root: HKCU; Subkey: "Software\Classes\SFTP"; Flags: dontcreatekey uninsdeletekey; \
  335. Tasks: urlhandler
  336. Root: HKCU; Subkey: "Software\Classes\SCP"; Flags: dontcreatekey uninsdeletekey; \
  337. Tasks: urlhandler
  338. ; Updates
  339. Root: HKCU; SubKey: "{#RegistryKey}\Configuration\Interface\Updates"; \
  340. ValueType: dword; ValueName: "Period"; ValueData: 7; \
  341. Tasks: enableupdates; Check: not UpdatesEnabled
  342. Root: HKLM; SubKey: "{#RegistryKey}"; \
  343. ValueType: dword; ValueName: "DefaultUpdatesPeriod"; ValueData: 7; \
  344. Tasks: enableupdates; Flags: noerror
  345. Root: HKLM; SubKey: "{#RegistryKey}"; \
  346. ValueType: dword; ValueName: "DefaultCollectUsage"; ValueData: 1; \
  347. Tasks: enableupdates\enablecollectusage; Flags: noerror
  348. #if AnyLanguageComplete == 1
  349. [Components]
  350. Name: transl\eng; Description: {#EnglishLang}; Types: full custom compact; \
  351. Flags: fixed
  352. #endif
  353. #sub EmitLang
  354. #if Languages[LangI*4+3] == 1
  355. [Components]
  356. Name: transl\{#Languages[LangI*4]}; Description: {#Languages[LangI*4+1]}; \
  357. Types: full compact custom; Check: IsLang('{#Languages[LangI*4]}')
  358. Name: transl\{#Languages[LangI*4]}; Description: {#Languages[LangI*4+1]}; \
  359. Check: not IsLang('{#Languages[LangI*4]}')
  360. [Files]
  361. Source: "{#TranslationDirRel}\WinSCP.{#Languages[LangI*4]}"; DestDir: "{app}"; \
  362. Components: transl\{#Languages[LangI*4]}; Flags: ignoreversion
  363. [Registry]
  364. ; set program default language to setup language, but only if user installs it
  365. Root: HKCU; SubKey: "{#RegistryKey}\Configuration\Interface"; \
  366. ValueType: dword; ValueName: "LocaleSafe"; ValueData: {#Languages[LangI*4+2]}; \
  367. Components: transl\{#Languages[LangI*4]}; Languages: {#Languages[LangI*4]}
  368. #endif
  369. #endsub /* sub EmitLang */
  370. #for {LangI = 0; LangI < LanguageCount; LangI++} EmitLang
  371. [UninstallRun]
  372. Filename: "{app}\WinSCP.exe"; Parameters: "/UninstallCleanup"; \
  373. RunOnceId: "UninstallCleanup"
  374. Filename: "{app}\WinSCP.exe"; Parameters: "/RemoveSearchPath"; \
  375. RunOnceId: "RemoveSearchPath"
  376. [Code]
  377. const
  378. wpSetupType = 100;
  379. wpInterface = 101;
  380. #ifdef Chrome
  381. wpChrome = 102;
  382. #endif
  383. NewLine = #13#10;
  384. var
  385. TypicalTypeButton: TRadioButton;
  386. CustomTypeButton: TRadioButton;
  387. CommanderRadioButton: TRadioButton;
  388. ExplorerRadioButton: TRadioButton;
  389. LaunchCheckbox: TCheckbox;
  390. OpenGettingStartedCheckbox: TCheckbox;
  391. AreUpdatesEnabled: Boolean;
  392. Upgrade: Boolean;
  393. MissingTranslations: string;
  394. PrevVersion: string;
  395. #ifdef Donations
  396. DonationPanel: TPanel;
  397. #endif
  398. InstallationDone: Boolean;
  399. LicenseAccepted: Boolean;
  400. #ifdef Chrome
  401. ChromeLogoImage: TBitmapImage;
  402. ChromeLogoImageOffset: Integer;
  403. ChromeAdImage: TBitmapImage;
  404. ChromeCheckbox: TCheckbox;
  405. ChromeDefaultCheckbox: TCheckbox;
  406. ChromeLastPolicyText: TLabel;
  407. ChromeAllowed: Boolean;
  408. ChromeLaunched: Boolean;
  409. LaunchChromeCheckbox: TCheckbox;
  410. #endif
  411. procedure ShowMessage(Text: string);
  412. begin
  413. MsgBox(Text, mbInformation, MB_OK);
  414. end;
  415. function IsLang(Lang: string): Boolean;
  416. begin
  417. Result := (Lang = ActiveLanguage);
  418. end;
  419. function IsWin8: Boolean;
  420. var
  421. Version: TWindowsVersion;
  422. begin
  423. GetWindowsVersionEx(Version);
  424. Result :=
  425. (Version.Major > 6) or
  426. ((Version.Major = 6) and (Version.Minor >= 2));
  427. end;
  428. function UpdatesEnabled: Boolean;
  429. begin
  430. Result := AreUpdatesEnabled;
  431. end;
  432. function UserSettings(Settings: Integer): Boolean;
  433. begin
  434. case Settings of
  435. 1: Result := CommanderRadioButton.Checked;
  436. else Result := False;
  437. end;
  438. end;
  439. function LanguageName(Lang: string; Unknown: string): string;
  440. begin
  441. #sub EmitLang2
  442. if Lang = '{#Languages[LangI*4]}' then Result := '{#Languages[LangI*4+1]}'
  443. else
  444. #endsub /* sub EmitLang2 */
  445. #for {LangI = 0; LangI < LanguageCount; LangI++} EmitLang2
  446. Result := Unknown;
  447. end;
  448. function ContainsLanguage(Lang: string): Boolean;
  449. begin
  450. #sub EmitLang3
  451. #if Languages[LangI*4+3] == 1
  452. if (Lang = '{#Languages[LangI*4]}') then Result := True
  453. else
  454. #endif
  455. #endsub /* sub EmitLang3 */
  456. #for {LangI = 0; LangI < LanguageCount; LangI++} EmitLang3
  457. Result := False;
  458. end;
  459. procedure OpenBrowser(Url: string);
  460. var
  461. ErrorCode: Integer;
  462. begin
  463. ShellExec('open', Url, '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
  464. end;
  465. procedure OpenHelp;
  466. begin
  467. OpenBrowser('{#WebDocumentation}installation?page=' + IntToStr(WizardForm.CurPageID) + '&' + ExpandConstant('{#WebArguments}'));
  468. end;
  469. procedure HelpButtonClick(Sender: TObject);
  470. begin
  471. OpenHelp;
  472. end;
  473. #ifdef Donations
  474. procedure AboutDonationsLinkClick(Sender: TObject);
  475. begin
  476. OpenBrowser('{#WebRoot}eng/donate.php?' + ExpandConstant('{#WebArguments}'));
  477. end;
  478. procedure DonateLinkClick(Sender: TObject);
  479. var
  480. Control: TControl;
  481. begin
  482. Control := TControl(Sender);
  483. OpenBrowser('{#WebRoot}eng/donate.php?amount=' + IntToStr(Control.Tag) + '&currency=' + ExpandConstant('{cm:Currency}') + '&' + ExpandConstant('{#WebArguments}'));
  484. end;
  485. #endif
  486. procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  487. begin
  488. if Key = 112 { VK_F1 } then
  489. begin
  490. OpenHelp;
  491. Key := 0;
  492. end;
  493. end;
  494. procedure CaptionClick(Sender: TObject);
  495. begin
  496. WizardForm.ActiveControl := TLabel(Sender).FocusControl;
  497. end;
  498. procedure ImageClick(Sender: TObject);
  499. begin
  500. WizardForm.ActiveControl := TWinControl(TControl(Sender).Tag);
  501. end;
  502. type
  503. TProcessTranslationEvent = procedure(Lang: string; FileName: string);
  504. procedure CollectNames(Lang: string; FileName: string);
  505. begin
  506. if Length(MissingTranslations) > 0 then
  507. MissingTranslations := MissingTranslations + ', ';
  508. MissingTranslations := MissingTranslations + LanguageName(Lang, Lang);
  509. end;
  510. procedure DeleteTranslation(Lang: string; FileName: string);
  511. begin
  512. DeleteFile(FileName);
  513. end;
  514. procedure ProcessMissingTranslations(OnProcessTranslation: TProcessTranslationEvent);
  515. var
  516. Path: string;
  517. FindRec: TFindRec;
  518. Ext: string;
  519. LExt: string;
  520. begin
  521. Path := AddBackslash(WizardDirValue);
  522. if FindFirst(ExpandConstant(Path + '{#TranslationFileMask}'), FindRec) then
  523. begin
  524. try
  525. repeat
  526. if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY = 0 then
  527. begin
  528. Ext := Uppercase(ExtractFileExt(FindRec.Name));
  529. if Pos('.', Ext) = 1 then
  530. begin
  531. Ext := Uppercase(Copy(Ext, 2, Length(Ext) - 1));
  532. LExt := Lowercase(Ext);
  533. if (Pos('-' + Ext + '-', '-{#AllTranslations}-') > 0) and
  534. not ContainsLanguage(LExt) then
  535. OnProcessTranslation(LExt, Path + FindRec.Name);
  536. end;
  537. end;
  538. until not FindNext(FindRec);
  539. finally
  540. FindClose(FindRec);
  541. end;
  542. end;
  543. end;
  544. function WillRestart: Boolean;
  545. begin
  546. Result := WizardForm.YesRadio.Visible and WizardForm.YesRadio.Checked;
  547. end;
  548. procedure UpdatePostInstallRunCheckboxes(Sender: TObject);
  549. begin
  550. LaunchCheckbox.Enabled := not WillRestart;
  551. OpenGettingStartedCheckbox.Enabled :=
  552. LaunchCheckbox.Enabled
  553. #ifdef Chrome
  554. and
  555. ((not LaunchChromeCheckbox.Visible) or (not LaunchChromeCheckbox.Checked));
  556. LaunchChromeCheckbox.Enabled := LaunchCheckbox.Enabled
  557. #endif
  558. end;
  559. procedure LinkLabel(Control: TLabel);
  560. begin
  561. Control.ParentFont := True;
  562. Control.Font.Style := Control.Font.Style + [fsUnderline];
  563. Control.Font.Color := clBlue;
  564. Control.Cursor := crHand;
  565. end;
  566. #ifdef Donations
  567. procedure CreateDonateLink(Amount: Integer; Row: Integer; Top: Integer);
  568. var
  569. Caption: TLabel;
  570. begin
  571. Caption := TLabel.Create(DonationPanel);
  572. Caption.Left := 0;
  573. Caption.Top := Top + Row * ScaleY(16);
  574. Caption.Tag := Amount;
  575. Caption.Parent := DonationPanel;
  576. Caption.Caption := Format(ExpandConstant('{cm:Donate}'), ['$' + IntToStr(Amount)]);
  577. Caption.OnClick := @DonateLinkClick;
  578. LinkLabel(Caption);
  579. end;
  580. #endif
  581. #ifdef Chrome
  582. procedure LoadEmbededBitmap(Image: TBitmapImage; Name: string);
  583. begin
  584. ExtractTemporaryFile(Name);
  585. Image.Bitmap.LoadFromFile(ExpandConstant('{tmp}\' + Name));
  586. Image.AutoSize := True;
  587. end;
  588. procedure ChromeCheckboxClick(Sender: TObject);
  589. begin
  590. ChromeDefaultCheckbox.Enabled := ChromeCheckbox.Checked;
  591. end;
  592. procedure AddChromePolicyText(S: string; OnLinkClick: TNotifyEvent);
  593. var
  594. Caption: TLabel;
  595. I: Integer;
  596. begin
  597. S := ExpandConstant(S);
  598. if s <> '' then
  599. begin
  600. Caption := TLabel.Create(ChromeDefaultCheckbox.Parent);
  601. if ChromeLastPolicyText <> nil then
  602. begin
  603. Caption.Top := ChromeLastPolicyText.Top;
  604. Caption.Left := ChromeLastPolicyText.Left + ChromeLastPolicyText.Width;
  605. end
  606. else
  607. begin
  608. Caption.Top :=
  609. ChromeDefaultCheckbox.Top + ChromeDefaultCheckbox.Height + ScaleY(4);
  610. end;
  611. Caption.Caption := S;
  612. Caption.Parent := ChromeDefaultCheckbox.Parent;
  613. Caption.Font.Name := 'Arial';
  614. Caption.Font.Size := Caption.Font.Size - 1;
  615. Caption.Tag := 1;
  616. if OnLinkClick <> nil then
  617. begin
  618. Caption.Font.Style := Caption.Font.Style + [fsUnderline];
  619. Caption.Font.Color := clBlue;
  620. Caption.Cursor := crHand;
  621. Caption.OnClick := OnLinkClick;
  622. end;
  623. if Caption.Left + Caption.Width > Caption.Parent.Width then
  624. begin
  625. Caption.Left := 0;
  626. Caption.Top := Caption.Top + Caption.Height;
  627. ChromeAdImage.Top := ChromeAdImage.Top - 1;
  628. ChromeCheckbox.Top := ChromeCheckbox.Top - 3;
  629. ChromeDefaultCheckbox.Top := ChromeDefaultCheckbox.Top - 4;
  630. for I := 0 to Caption.Parent.ControlCount - 1 do
  631. begin
  632. if Caption.Parent.Controls[I].Tag = 1 then
  633. Caption.Parent.Controls[I].Top := Caption.Parent.Controls[I].Top - 5;
  634. end;
  635. if Copy(Caption.Caption, 1, 1) = ' ' then
  636. Caption.Caption := Copy(Caption.Caption, 2, Length(Caption.Caption) - 1);
  637. end;
  638. ChromeLastPolicyText := Caption;
  639. end;
  640. end;
  641. procedure OpenPolicy(S: string);
  642. begin
  643. S := FmtMessage(S, [ExpandConstant('{cm:LanguageISOCode}')]);
  644. OpenBrowser(S);
  645. end;
  646. procedure ChromeTermsOfUseClick(Sender: TObject);
  647. begin
  648. OpenPolicy('http://www.google.com/chrome/intl/%1/eula_text.html');
  649. end;
  650. procedure ChromePrivacyPolicyClick(Sender: TObject);
  651. begin
  652. OpenPolicy('http://www.google.com/chrome/intl/%1/privacy.html');
  653. end;
  654. function IsChromeSelected: Boolean;
  655. begin
  656. Result := ChromeAllowed and ChromeCheckbox.Checked;
  657. end;
  658. function IsChromeDefaultSelected: Boolean;
  659. begin
  660. Result := ChromeAllowed and ChromeDefaultCheckbox.Checked;
  661. end;
  662. #endif
  663. procedure InitializeWizard;
  664. var
  665. DefaultLang: Boolean;
  666. UserInterface: Cardinal;
  667. UpdatesPeriod: Cardinal;
  668. InterfacePage: TWizardPage;
  669. SetupTypePage: TWizardPage;
  670. Caption: TLabel;
  671. Image: TBitmapImage;
  672. HelpButton: TButton;
  673. #ifdef Donations
  674. P: Integer;
  675. #endif
  676. S: string;
  677. I: Integer;
  678. #ifdef OpenCandy
  679. OpenCandyNewPageID: Integer;
  680. #endif
  681. #ifdef Chrome
  682. ChromePage: TWizardPage;
  683. ResultCode: Integer;
  684. #endif
  685. begin
  686. InstallationDone := False;
  687. LicenseAccepted := False;
  688. #ifdef Chrome
  689. ChromeLaunched := False;
  690. #endif
  691. DefaultLang := (ActiveLanguage = '{#DefaultLang}');
  692. Upgrade :=
  693. RegQueryStringValue(HKLM, '{#InnoSetupReg}', '{#InnoSetupAppPathReg}', S) or
  694. RegQueryStringValue(HKCU, '{#InnoSetupReg}', '{#InnoSetupAppPathReg}', S)
  695. if Upgrade and GetVersionNumbersString(AddBackslash(WizardDirValue) + '{#MainFileName}', PrevVersion) and
  696. (PrevVersion[2] = '.') and (PrevVersion[4] = '.') and (PrevVersion[6] = '.') then
  697. begin
  698. PrevVersion := Copy(PrevVersion, 1, 5);
  699. end;
  700. ProcessMissingTranslations(@CollectNames);
  701. WizardForm.KeyPreview := True;
  702. WizardForm.OnKeyDown := @FormKeyDown;
  703. // to accomodate one more task
  704. WizardForm.TasksList.Height := WizardForm.TasksList.Height + ScaleY(8);
  705. #ifndef Chrome
  706. // allow installation without requiring user to accept licence
  707. WizardForm.LicenseAcceptedRadio.Checked := True;
  708. WizardForm.LicenseAcceptedRadio.Visible := False;
  709. WizardForm.LicenseLabel1.Visible := False;
  710. WizardForm.LicenseNotAcceptedRadio.Visible := False;
  711. WizardForm.LicenseMemo.Top := WizardForm.LicenseLabel1.Top;
  712. WizardForm.LicenseMemo.Height :=
  713. WizardForm.LicenseNotAcceptedRadio.Top +
  714. WizardForm.LicenseNotAcceptedRadio.Height -
  715. WizardForm.LicenseMemo.Top - 5;
  716. #endif
  717. // hide installation types combo
  718. WizardForm.TypesCombo.Visible := False;
  719. WizardForm.ComponentsList.Height :=
  720. WizardForm.ComponentsList.Top + WizardForm.ComponentsList.Height -
  721. WizardForm.TypesCombo.Top;
  722. WizardForm.ComponentsList.Top := WizardForm.TypesCombo.Top;
  723. // add help button
  724. HelpButton := TButton.Create(WizardForm);
  725. HelpButton.Parent := WizardForm;
  726. HelpButton.Left :=
  727. WizardForm.ClientWidth -
  728. (WizardForm.CancelButton.Left + WizardForm.CancelButton.Width);
  729. HelpButton.Top := WizardForm.CancelButton.Top;
  730. HelpButton.Width := WizardForm.CancelButton.Width;
  731. HelpButton.Height := WizardForm.CancelButton.Height;
  732. HelpButton.Caption := ExpandConstant('{cm:HelpButton}');
  733. HelpButton.OnClick := @HelpButtonClick;
  734. // installation type page
  735. SetupTypePage := CreateCustomPage(wpLicense,
  736. ExpandConstant('{cm:SetupTypeTitle}'),
  737. ExpandConstant('{cm:SetupTypePrompt}'));
  738. TypicalTypeButton := TRadioButton.Create(SetupTypePage);
  739. if not Upgrade then
  740. S := ExpandConstant('{cm:TypicalType}')
  741. else
  742. S := ExpandConstant('{cm:TypicalUpgradeType}');
  743. TypicalTypeButton.Caption :=
  744. FmtMessage(ExpandConstant('{cm:Recommended}'), [S]);
  745. // check typical install, if typical install was installed before or
  746. // when version without setup type support was installed with
  747. // "full" installation or when there were no installation before
  748. // ("full" installation is default)
  749. TypicalTypeButton.Checked :=
  750. ((GetPreviousData('{#SetupTypeData}', '') = 'typical')) or
  751. ((GetPreviousData('{#SetupTypeData}', '') = '') and
  752. (WizardSetupType(False) = 'full'));
  753. TypicalTypeButton.Left := ScaleX(4);
  754. TypicalTypeButton.Width := SetupTypePage.SurfaceWidth -
  755. TypicalTypeButton.Left;
  756. TypicalTypeButton.Parent := SetupTypePage.Surface;
  757. Caption := TLabel.Create(SetupTypePage);
  758. Caption.WordWrap := True;
  759. if not Upgrade then
  760. begin
  761. if DefaultLang then
  762. S := ExpandConstant('{cm:TypicalType2Eng}')
  763. else
  764. S := FmtMessage(ExpandConstant('{cm:TypicalType2Intl}'), [LanguageName(ActiveLanguage, 'Unknown')]);
  765. Caption.Caption :=
  766. ExpandConstant('{cm:TypicalType1}') + NewLine +
  767. S + NewLine +
  768. ExpandConstant('{cm:TypicalType3}');
  769. end
  770. else
  771. begin
  772. if Length(MissingTranslations) > 0 then
  773. begin
  774. #if AnyLanguageComplete
  775. S := FmtMessage(ExpandConstant('{cm:TypicalUpgradeTypeMissingTransl}'), [MissingTranslations]);
  776. #else
  777. S := ExpandConstant('{cm:TypicalUpgradeTypeNoTransl}');
  778. #endif
  779. S := NewLine + S;
  780. end
  781. else S := '';
  782. Caption.Caption :=
  783. ExpandConstant('{cm:TypicalUpgradeType1}') + S;
  784. end;
  785. Caption.Left := ScaleX(4) + ScaleX(20);
  786. Caption.Width := SetupTypePage.SurfaceWidth - Caption.Left;
  787. Caption.Top := TypicalTypeButton.Top + TypicalTypeButton.Height + ScaleY(6);
  788. Caption.Parent := SetupTypePage.Surface;
  789. Caption.FocusControl := TypicalTypeButton;
  790. Caption.OnClick := @CaptionClick;
  791. CustomTypeButton := TRadioButton.Create(SetupTypePage);
  792. if not Upgrade then
  793. CustomTypeButton.Caption := ExpandConstant('{cm:CustomType}')
  794. else
  795. CustomTypeButton.Caption := ExpandConstant('{cm:CustomUpgradeType}');
  796. CustomTypeButton.Checked := (not TypicalTypeButton.Checked);
  797. CustomTypeButton.Left := ScaleX(4);
  798. CustomTypeButton.Width := SetupTypePage.SurfaceWidth -
  799. CustomTypeButton.Left;
  800. CustomTypeButton.Top := Caption.Top + Caption.Height + ScaleY(10);
  801. CustomTypeButton.Parent := SetupTypePage.Surface;
  802. Caption := TLabel.Create(SetupTypePage);
  803. Caption.WordWrap := True;
  804. if not Upgrade then
  805. begin
  806. Caption.Caption :=
  807. ExpandConstant('{cm:CustomType1}');
  808. end
  809. else
  810. begin
  811. Caption.Caption :=
  812. ExpandConstant('{cm:CustomUpgradeType1}') + NewLine +
  813. ExpandConstant('{cm:CustomUpgradeType2}');
  814. end;
  815. Caption.Left := ScaleX(4) + ScaleX(20);
  816. Caption.Width := SetupTypePage.SurfaceWidth - Caption.Left;
  817. Caption.Top := CustomTypeButton.Top + CustomTypeButton.Height +
  818. ScaleY(6);
  819. Caption.Parent := SetupTypePage.Surface;
  820. Caption.FocusControl := CustomTypeButton;
  821. Caption.OnClick := @CaptionClick;
  822. // interface page
  823. InterfacePage := CreateCustomPage(wpSelectTasks,
  824. ExpandConstant('{cm:UserSettingsTitle}'),
  825. ExpandConstant('{cm:UserSettingsPrompt}'));
  826. UpdatesPeriod := 0;
  827. RegQueryDWordValue(HKCU, '{#RegistryKey}\Configuration\Interface\Updates',
  828. 'Period', UpdatesPeriod);
  829. AreUpdatesEnabled := (UpdatesPeriod <> 0);
  830. UserInterface := 0; { default is commander }
  831. RegQueryDWordValue(HKCU, '{#RegistryKey}\Configuration\Interface',
  832. 'Interface', UserInterface);
  833. Caption := TLabel.Create(InterfacePage);
  834. Caption.Caption := ExpandConstant('{cm:UserInterfaceStyle}');
  835. Caption.Width := InterfacePage.SurfaceWidth;
  836. Caption.Parent := InterfacePage.Surface;
  837. CommanderRadioButton := TRadioButton.Create(InterfacePage);
  838. CommanderRadioButton.Caption := ExpandConstant('{cm:NortonCommanderInterfaceC}');
  839. CommanderRadioButton.Checked := (UserInterface = 0);
  840. CommanderRadioButton.Left := ScaleX(4);
  841. CommanderRadioButton.Width := InterfacePage.SurfaceWidth -
  842. CommanderRadioButton.Left;
  843. CommanderRadioButton.Top := Caption.Top + Caption.Height + ScaleY(6);
  844. CommanderRadioButton.Parent := InterfacePage.Surface;
  845. Image := TBitmapImage.Create(InterfacePage);
  846. Image.Top := CommanderRadioButton.Top + CommanderRadioButton.Height + ScaleY(6);
  847. Image.Left := CommanderRadioButton.Left + ScaleX(45);
  848. Image.Parent := InterfacePage.Surface;
  849. LoadEmbededBitmap(Image, '{#CommanderFile}');
  850. Image.ReplaceColor := $FF00FF;
  851. Image.ReplaceWithColor := InterfacePage.Surface.Color;
  852. Image.OnClick := @ImageClick;
  853. Image.Tag := Integer(CommanderRadioButton);
  854. Caption := TLabel.Create(InterfacePage);
  855. Caption.WordWrap := True;
  856. Caption.Caption :=
  857. ExpandConstant('{cm:NortonCommanderInterface1}') + NewLine +
  858. ExpandConstant('{cm:NortonCommanderInterface2}') + NewLine +
  859. ExpandConstant('{cm:NortonCommanderInterface3}');
  860. Caption.Left := CommanderRadioButton.Left + ScaleX(116);
  861. Caption.Width := InterfacePage.SurfaceWidth - Caption.Left;
  862. Caption.Top := CommanderRadioButton.Top;
  863. Caption.Parent := InterfacePage.Surface;
  864. Caption.FocusControl := CommanderRadioButton;
  865. Caption.OnClick := @CaptionClick;
  866. ExplorerRadioButton := TRadioButton.Create(InterfacePage);
  867. ExplorerRadioButton.Caption := ExpandConstant('{cm:ExplorerInterfaceC}');
  868. ExplorerRadioButton.Checked := (UserInterface <> 0);
  869. ExplorerRadioButton.Left := ScaleX(4);
  870. ExplorerRadioButton.Width := InterfacePage.SurfaceWidth -
  871. ExplorerRadioButton.Left;
  872. ExplorerRadioButton.Top := Caption.Top + Caption.Height + ScaleY(10);
  873. ExplorerRadioButton.Parent := InterfacePage.Surface;
  874. Image := TBitmapImage.Create(InterfacePage);
  875. Image.Top := ExplorerRadioButton.Top + ExplorerRadioButton.Height + ScaleY(6);
  876. Image.Left := ExplorerRadioButton.Left + ScaleX(45);
  877. Image.Parent := InterfacePage.Surface;
  878. LoadEmbededBitmap(Image, '{#ExplorerFile}');
  879. Image.ReplaceColor := $C020E0;
  880. Image.ReplaceWithColor := InterfacePage.Surface.Color;
  881. Image.OnClick := @ImageClick;
  882. Image.Tag := Integer(ExplorerRadioButton);
  883. I := CommanderRadioButton.Left + ScaleX(116);
  884. Caption := TLabel.Create(InterfacePage);
  885. Caption.WordWrap := True;
  886. Caption.Caption :=
  887. ExpandConstant('{cm:ExplorerInterface1}') + NewLine +
  888. ExpandConstant('{cm:ExplorerInterface2}') + NewLine +
  889. ExpandConstant('{cm:ExplorerInterface3}');
  890. Caption.Left := I;
  891. Caption.Width := InterfacePage.SurfaceWidth - Caption.Left;
  892. Caption.Top := ExplorerRadioButton.Top;
  893. Caption.Parent := InterfacePage.Surface;
  894. Caption.FocusControl := ExplorerRadioButton;
  895. Caption.OnClick := @CaptionClick;
  896. if Caption.Top + Caption.Height > Image.Top + Image.Height then
  897. I := Caption.Top + Caption.Height
  898. else
  899. I := Image.Top + Image.Height;
  900. // run checkbox
  901. LaunchCheckbox := TCheckbox.Create(WizardForm.FinishedPage);
  902. LaunchCheckbox.Caption := ExpandConstant('{cm:Launch}');
  903. LaunchCheckbox.Checked := True;
  904. LaunchCheckbox.Left := WizardForm.YesRadio.Left;
  905. LaunchCheckbox.Width := WizardForm.YesRadio.Width;
  906. LaunchCheckbox.Parent := WizardForm.FinishedPage;
  907. OpenGettingStartedCheckbox := TCheckbox.Create(WizardForm.FinishedPage);
  908. OpenGettingStartedCheckbox.Caption := ExpandConstant('{cm:OpenGettingStarted}');
  909. OpenGettingStartedCheckbox.Checked := True;
  910. OpenGettingStartedCheckbox.Left := WizardForm.YesRadio.Left;
  911. OpenGettingStartedCheckbox.Width := WizardForm.YesRadio.Width;
  912. OpenGettingStartedCheckbox.Parent := WizardForm.FinishedPage;
  913. #ifdef Chrome
  914. LaunchChromeCheckbox := TCheckbox.Create(WizardForm.FinishedPage);
  915. LaunchChromeCheckbox.Caption := ExpandConstant('{cm:ChromeLaunch}');
  916. LaunchChromeCheckbox.Checked := True;
  917. LaunchChromeCheckbox.Left := WizardForm.YesRadio.Left;
  918. LaunchChromeCheckbox.Width := WizardForm.YesRadio.Width;
  919. LaunchChromeCheckbox.Parent := WizardForm.FinishedPage;
  920. LaunchChromeCheckbox.OnClick := @UpdatePostInstallRunCheckboxes;
  921. #endif
  922. #ifdef Donations
  923. DonationPanel := TPanel.Create(WizardForm.FinishedPage);
  924. DonationPanel.Left := WizardForm.YesRadio.Left;
  925. DonationPanel.Width := WizardForm.YesRadio.Width;
  926. DonationPanel.Parent := WizardForm.FinishedPage;
  927. DonationPanel.Top := ScaleY(190);
  928. DonationPanel.Height := ScaleY(110);
  929. DonationPanel.BevelInner := bvNone;
  930. DonationPanel.BevelOuter := bvNone;
  931. DonationPanel.Color := WizardForm.FinishedPage.Color;
  932. Caption := TLabel.Create(DonationPanel);
  933. Caption.Left := 0;
  934. Caption.Top := 0;
  935. Caption.Width := DonationPanel.Width;
  936. Caption.Parent := DonationPanel;
  937. Caption.Caption := ExpandConstant('{cm:PleaseDonate}');
  938. P := Caption.Top + Caption.Height + ScaleY(12);
  939. CreateDonateLink( 9, 0, P);
  940. CreateDonateLink(19, 1, P);
  941. CreateDonateLink(29, 2, P);
  942. CreateDonateLink(49, 3, P);
  943. Caption := TLabel.Create(DonationPanel);
  944. Caption.Left := 0;
  945. Caption.Top := P + 3 * ScaleY(16) + ScaleY(24);
  946. Caption.Parent := DonationPanel;
  947. Caption.Caption := ExpandConstant('{cm:AboutDonations}');
  948. Caption.OnClick := @AboutDonationsLinkClick;
  949. LinkLabel(Caption);
  950. Image := TBitmapImage.Create(DonationPanel);
  951. LoadEmbededBitmap(Image, '{#PayPalCardImage}');
  952. Image.Cursor := crHand;
  953. Image.Parent := DonationPanel;
  954. Image.Left := ScaleX(100);
  955. Image.Top := P + ScaleX(8);
  956. Image.ReplaceColor := $FCFE04;
  957. Image.ReplaceWithColor := WizardForm.FinishedPage.Color;
  958. Image.Hint := ExpandConstant('{cm:AboutDonations}');
  959. Image.ShowHint := True;
  960. Image.OnClick := @AboutDonationsLinkClick;
  961. #endif
  962. WizardForm.YesRadio.OnClick := @UpdatePostInstallRunCheckboxes;
  963. WizardForm.NoRadio.OnClick := @UpdatePostInstallRunCheckboxes;
  964. UpdatePostInstallRunCheckboxes(nil);
  965. if IsWin8 then
  966. begin
  967. WizardForm.NoIconsCheck.Checked := True;
  968. end;
  969. #ifdef OpenCandy
  970. OpenCandyInit('{#OC_STR_MY_PRODUCT_NAME}', '{#OC_STR_KEY}', '{#OC_STR_SECRET}',
  971. ExpandConstant('{cm:LanguageISOCode}'), {#OC_INIT_MODE_NORMAL});
  972. OpenCandyNewPageID := OpenCandyInsertLoadDLLPage(wpLicense);
  973. OpenCandyInsertConnectPage(OpenCandyNewPageID);
  974. OpenCandyNewPageID := OpenCandyInsertLoadingPage(wpSelectTasks, ' ', ' ', 'Loading...', 'Arial', 100);
  975. OpenCandyInsertOfferPage(OpenCandyNewPageID);
  976. #endif
  977. #ifdef Chrome
  978. ExtractTemporaryFile('{#ChromeGcApiDllFile}');
  979. ExtractTemporaryFile('{#ChromeCheckerFile}');
  980. ChromeAllowed :=
  981. (not WizardSilent) and
  982. ExecAsOriginalUser(ExpandConstant('{tmp}\{#ChromeCheckerFile}'), 'checkstandard', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) and
  983. (ResultCode = 0) and
  984. Exec(ExpandConstant('{tmp}\{#ChromeCheckerFile}'), 'checkelevated', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) and
  985. (ResultCode = 0);
  986. if ChromeAllowed then
  987. begin
  988. Log('Chrome allowed');
  989. ChromePage := CreateCustomPage(wpInterface,
  990. ExpandConstant('{cm:ChromeTitle}'),
  991. ExpandConstant('{cm:ChromePrompt}'));
  992. Caption := TLabel.Create(ChromePage);
  993. Caption.WordWrap := True;
  994. Caption.Caption :=
  995. '- ' + ExpandConstant('{cm:ChromePoint1}') + #13#10 +
  996. '- ' + ExpandConstant('{cm:ChromePoint2}') + #13#10 +
  997. '- ' + ExpandConstant('{cm:ChromePoint3}');
  998. Caption.Width := ChromePage.SurfaceWidth;
  999. Caption.Parent := ChromePage.Surface;
  1000. ChromeAdImage := TBitmapImage.Create(ChromePage);
  1001. ChromeAdImage.Top := Caption.Top + Caption.Height + ScaleY(6);
  1002. ChromeAdImage.Parent := ChromePage.Surface;
  1003. LoadEmbededBitmap(ChromeAdImage, '{#ChromeAdFile}');
  1004. ChromeCheckbox := TCheckbox.Create(ChromePage);
  1005. ChromeCheckbox.Top := ChromeAdImage.Top + ChromeAdImage.Height + ScaleY(6);
  1006. ChromeCheckbox.Left := ScaleX(4);
  1007. ChromeCheckbox.Width :=
  1008. ChromePage.SurfaceWidth - ChromeCheckbox.Left;
  1009. ChromeCheckbox.Caption := ExpandConstant('{cm:ChromeCheck}');
  1010. ChromeCheckbox.Checked := True;
  1011. ChromeCheckbox.Parent := ChromePage.Surface;
  1012. ChromeCheckbox.OnClick := @ChromeCheckboxClick;
  1013. ChromeDefaultCheckbox := TCheckbox.Create(ChromePage);
  1014. ChromeDefaultCheckbox.Top :=
  1015. ChromeCheckbox.Top + ChromeCheckbox.Height + ScaleY(4);
  1016. ChromeDefaultCheckbox.Left := ScaleX(4);
  1017. ChromeDefaultCheckbox.Width :=
  1018. ChromePage.SurfaceWidth - ChromeDefaultCheckbox.Left;
  1019. ChromeDefaultCheckbox.Caption := ExpandConstant('{cm:ChromeDefaultCheck}');
  1020. ChromeDefaultCheckbox.Checked := True;
  1021. ChromeDefaultCheckbox.Parent := ChromePage.Surface;
  1022. ChromeLastPolicyText := nil;
  1023. AddChromePolicyText('{cm:ChromeDisclaimerPrefix}', nil);
  1024. AddChromePolicyText('{cm:ChromeDisclaimerTermsOfUse}', @ChromeTermsOfUseClick);
  1025. AddChromePolicyText('{cm:ChromeDisclaimerInfix}', nil);
  1026. AddChromePolicyText('{cm:ChromeDisclaimerPrivacyPolicy}', @ChromePrivacyPolicyClick);
  1027. AddChromePolicyText('{cm:ChromeDisclaimerPostfix}', nil);
  1028. // override the windows scheme to make sure it matches chrome logo background
  1029. WizardForm.MainPanel.Color := clWhite;
  1030. ChromeLogoImage := TBitmapImage.Create(WizardForm.MainPanel);
  1031. ChromeLogoImage.Top := WizardForm.PageNameLabel.Top;
  1032. ChromeLogoImage.Left := ScaleX(8);
  1033. ChromeLogoImage.Parent := WizardForm.MainPanel;
  1034. LoadEmbededBitmap(ChromeLogoImage, '{#ChromeLogoFile}');
  1035. ChromeLogoImage.Visible := False;
  1036. ChromeLogoImageOffset :=
  1037. (ChromeLogoImage.Left + ChromeLogoImage.Width + ScaleX(8)) -
  1038. WizardForm.PageNameLabel.Left;
  1039. end;
  1040. #endif
  1041. end;
  1042. procedure RegisterPreviousData(PreviousDataKey: Integer);
  1043. var
  1044. S: string;
  1045. begin
  1046. if TypicalTypeButton.Checked then S := 'typical'
  1047. else S := 'custom';
  1048. SetPreviousData(PreviousDataKey, '{#SetupTypeData}', S);
  1049. end;
  1050. procedure CurPageChanged(CurPageID: Integer);
  1051. var
  1052. Delta: Integer;
  1053. LineHeight: Integer;
  1054. LaunchCheckboxTop: Integer;
  1055. begin
  1056. #ifdef OpenCandy
  1057. OpenCandyCurPageChanged(CurPageID);
  1058. #endif
  1059. if CurPageID = wpFinished then
  1060. begin
  1061. LineHeight := (WizardForm.NoRadio.Top - WizardForm.YesRadio.Top);
  1062. // Are we at the "Restart?" screen
  1063. if WizardForm.YesRadio.Visible then
  1064. begin
  1065. WizardForm.FinishedLabel.Caption :=
  1066. ExpandConstant('{cm:FinishedRestartDragExtLabel}') + NewLine;
  1067. Delta := WizardForm.AdjustLabelHeight(WizardForm.FinishedLabel);
  1068. WizardForm.YesRadio.Top := WizardForm.YesRadio.Top + Delta;
  1069. WizardForm.NoRadio.Top := WizardForm.NoRadio.Top + Delta;
  1070. LaunchCheckboxTop := WizardForm.NoRadio.Top + LineHeight;
  1071. #ifdef Donations
  1072. DonationPanel.Visible := False;
  1073. #endif
  1074. end
  1075. else
  1076. begin
  1077. LaunchCheckboxTop := WizardForm.RunList.Top;
  1078. #ifdef Donations
  1079. DonationPanel.Visible := not IsChromeSelected;
  1080. #endif
  1081. end;
  1082. LaunchCheckbox.Top := LaunchCheckboxTop;
  1083. OpenGettingStartedCheckbox.Top := LaunchCheckbox.Top + LineHeight;
  1084. LaunchChromeCheckbox.Visible := IsChromeSelected;
  1085. LaunchChromeCheckbox.Top := OpenGettingStartedCheckbox.Top + LineHeight;
  1086. UpdatePostInstallRunCheckboxes(nil);
  1087. end;
  1088. if CurPageID = wpSetupType then
  1089. begin
  1090. Log('License accepted');
  1091. LicenseAccepted := True;
  1092. end;
  1093. #ifdef Chrome
  1094. if ChromeAllowed then
  1095. begin
  1096. if CurPageID = wpChrome then
  1097. begin
  1098. WizardForm.PageNameLabel.Width := WizardForm.PageNameLabel.Width - ChromeLogoImageOffset;
  1099. WizardForm.PageNameLabel.Left := WizardForm.PageNameLabel.Left + ChromeLogoImageOffset;
  1100. WizardForm.PageDescriptionLabel.Width := WizardForm.PageDescriptionLabel.Width - ChromeLogoImageOffset;
  1101. WizardForm.PageDescriptionLabel.Left := WizardForm.PageDescriptionLabel.Left + ChromeLogoImageOffset;
  1102. ChromeLogoImage.Visible := True;
  1103. end
  1104. else
  1105. if ChromeLogoImage.Visible then
  1106. begin
  1107. ChromeLogoImage.Visible := False;
  1108. WizardForm.PageNameLabel.Left := WizardForm.PageNameLabel.Left - ChromeLogoImageOffset;
  1109. WizardForm.PageNameLabel.Width := WizardForm.PageNameLabel.Width + ChromeLogoImageOffset;
  1110. WizardForm.PageDescriptionLabel.Left := WizardForm.PageDescriptionLabel.Left - ChromeLogoImageOffset;
  1111. WizardForm.PageDescriptionLabel.Width := WizardForm.PageDescriptionLabel.Width + ChromeLogoImageOffset;
  1112. end;
  1113. end;
  1114. #endif
  1115. end;
  1116. #ifdef OpenCandy
  1117. function BackButtonClick(CurPageID: Integer): Boolean;
  1118. begin
  1119. Result := True;
  1120. OpenCandyBackButtonClick(CurPageID);
  1121. end;
  1122. function NextButtonClick(CurPageID: Integer): Boolean;
  1123. begin
  1124. Result := OpenCandyNextButtonClick(CurPageID);
  1125. end;
  1126. #endif
  1127. function AskedRestart: Boolean;
  1128. begin
  1129. Result := WizardForm.YesRadio.Visible;
  1130. end;
  1131. procedure DeinitializeSetup;
  1132. var
  1133. WinHttpReq: Variant;
  1134. ReportUrl: string;
  1135. ReportData: string;
  1136. begin
  1137. #ifdef OpenCandy
  1138. OpenCandyDeinitializeSetup();
  1139. #endif
  1140. // cannot send report, unless user already accepted license
  1141. // (with privacy policy)
  1142. if LicenseAccepted then
  1143. begin
  1144. Log('Preparing intallation report');
  1145. ReportData := Format(
  1146. 'installed=%d&silent=%d&ver=%s&lang=%s&', [
  1147. Integer(InstallationDone), Integer(WizardSilent),
  1148. ExpandConstant('{#VersionOnly}'), ActiveLanguage]);
  1149. #ifdef Chrome
  1150. ReportData := ReportData +
  1151. Format('chromeoffered=%d&chromeaccepted=%d&chromelaunched=%d&', [Integer(ChromeAllowed), Integer(IsChromeSelected), Integer(ChromeLaunched)]);
  1152. #endif
  1153. try
  1154. ReportUrl := ExpandConstant('{#WebReport}?') + ReportData;
  1155. Log('Sending installation report: ' + ReportUrl);
  1156. WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
  1157. WinHttpReq.Open('GET', ReportUrl, False);
  1158. WinHttpReq.Send('');
  1159. Log('Installation report send result: ' + IntToStr(WinHttpReq.Status) + ' ' + WinHttpReq.StatusText);
  1160. except
  1161. Log('Error sending installation report: ' + GetExceptionMessage);
  1162. end;
  1163. end;
  1164. end;
  1165. procedure CurStepChanged(CurStep: TSetupStep);
  1166. var
  1167. ErrorCode: Integer;
  1168. ShowCmd: Integer;
  1169. Path: string;
  1170. WebGettingStarted: string;
  1171. OpenGettingStarted: Boolean;
  1172. LaunchChrome: Boolean;
  1173. begin
  1174. if CurStep = ssPostInstall then
  1175. begin
  1176. Log('Post install');
  1177. if Length(MissingTranslations) > 0 then
  1178. begin
  1179. Log('Removing obsolete translations');
  1180. WizardForm.StatusLabel.Caption :=
  1181. ExpandConstant('{cm:RemovingObsoleteTranslations}');
  1182. ProcessMissingTranslations(@DeleteTranslation);
  1183. end;
  1184. InstallationDone := True;
  1185. end
  1186. else
  1187. if CurStep = ssDone then
  1188. begin
  1189. Log('Done');
  1190. // bug in InnoSetup causes it using ssDone even when
  1191. // setup failed because machine was not restarted to complete previous
  1192. // installation. double check that ssPostInstall was called
  1193. if (not WizardSilent) and (not WillRestart) and InstallationDone then
  1194. begin
  1195. OpenGettingStarted :=
  1196. OpenGettingStartedCheckbox.Enabled and
  1197. OpenGettingStartedCheckbox.Checked;
  1198. LaunchChrome :=
  1199. ChromeAllowed and IsChromeSelected and
  1200. LaunchChromeCheckbox.Visible and // sanity check
  1201. LaunchChromeCheckbox.Checked;
  1202. if OpenGettingStarted then
  1203. begin
  1204. WebGettingStarted :=
  1205. ExpandConstant('{#WebGettingStarted}') + PrevVersion;
  1206. Log('Opening getting started page: ' + WebGettingStarted);
  1207. OpenBrowser(WebGettingStarted);
  1208. end;
  1209. if LaunchCheckbox.Checked then
  1210. begin
  1211. if OpenGettingStarted or LaunchChrome then
  1212. begin
  1213. Log('Will launch WinSCP minimized');
  1214. ShowCmd := SW_SHOWMINIMIZED
  1215. end
  1216. else
  1217. begin
  1218. ShowCmd := SW_SHOWNORMAL;
  1219. end;
  1220. Log('Launching WinSCP');
  1221. Path := ExpandConstant('{app}\{#MainFileName}');
  1222. ExecAsOriginalUser(Path, '', '', ShowCmd, ewNoWait, ErrorCode)
  1223. end;
  1224. if LaunchChrome then
  1225. begin
  1226. Log('Launching Chrome');
  1227. ChromeLaunched :=
  1228. ExecAsOriginalUser(ExpandConstant('{tmp}\{#ChromeCheckerFile}'), 'launch', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode) and
  1229. (ErrorCode = 0);
  1230. Log(Format('Launched Chrome [%d] [%d]', [Integer(ChromeLaunched), ErrorCode]));
  1231. if not ChromeLaunched then
  1232. begin
  1233. MsgBox(ExpandConstant('{cm:ChromeInstallationFailed}'), mbError, MB_OK);
  1234. end;
  1235. end;
  1236. end;
  1237. end;
  1238. #ifdef OpenCandy
  1239. OpenCandyCurStepChanged(CurStep);
  1240. #endif
  1241. end;
  1242. function ShouldSkipPage(PageID: Integer): Boolean;
  1243. begin
  1244. Result :=
  1245. #ifdef OpenCandy
  1246. OpenCandyShouldSkipPage(PageID) or
  1247. #endif
  1248. { Hide most pages during typical installation }
  1249. (TypicalTypeButton.Checked and
  1250. ((PageID = wpSelectDir) or (PageID = wpSelectComponents) or
  1251. (PageID = wpSelectTasks) or
  1252. { Hide Interface page for upgrades only, show for fresh installs }
  1253. ((PageID = wpInterface) and Upgrade)));
  1254. end;
  1255. function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo,
  1256. MemoTypeInfo, MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: string): string;
  1257. var
  1258. S: string;
  1259. S2: string;
  1260. begin
  1261. S := '';
  1262. S := S + MemoDirInfo + NewLine + NewLine;
  1263. if not Upgrade then
  1264. begin
  1265. if TypicalTypeButton.Checked then S2 := ExpandConstant('{cm:TypicalType}')
  1266. else S2 := ExpandConstant('{cm:CustomType}');
  1267. end
  1268. else
  1269. begin
  1270. if TypicalTypeButton.Checked then S2 := ExpandConstant('{cm:TypicalUpgradeType}')
  1271. else S2 := ExpandConstant('{cm:CustomUpgradeType}');
  1272. end;
  1273. StringChange(S2, '&', '');
  1274. S := S + SetupMessage(msgReadyMemoType) + NewLine + Space + S2 + NewLine + NewLine;
  1275. S := S + MemoComponentsInfo + NewLine + NewLine;
  1276. if Length(MemoGroupInfo) > 0 then
  1277. S := S + MemoGroupInfo + NewLine + NewLine;
  1278. if Length(MemoTasksInfo) > 0 then
  1279. S := S + MemoTasksInfo + NewLine + NewLine;
  1280. S := S + ExpandConstant('{cm:UserSettingsOverview}') + NewLine;
  1281. S := S + Space;
  1282. if CommanderRadioButton.Checked then S2 := ExpandConstant('{cm:NortonCommanderInterfaceC}')
  1283. else S2 := ExpandConstant('{cm:ExplorerInterfaceC}');
  1284. StringChange(S2, '&', '');
  1285. S := S + S2;
  1286. S := S + NewLine;
  1287. Result := S;
  1288. end;
  1289. function InitializeUninstall: Boolean;
  1290. begin
  1291. // let application know that we are running silent uninstall,
  1292. // this turns UninstallCleanup to noop
  1293. if UninstallSilent then
  1294. CreateMutex('WinSCPSilentUninstall');
  1295. Result := True;
  1296. end;