]> git.lyx.org Git - lyx.git/blob - development/Win32/packaging/installer/LyXWinInstaller/Aspell.nsh
Changed comment character from ';' to '#*
[lyx.git] / development / Win32 / packaging / installer / LyXWinInstaller / Aspell.nsh
1 # Aspell dictionaries
2
3 Function DownloadDictionary
4         
5  FileOpen $R5 "$INSTDIR\Resources\AspellDictionaryNames.txt" r
6  ${Do}
7   FileRead $R5 $String # $String is now the dictionary name
8   StrCpy $R3 $String 2 # $R3 is now the dictionary language code
9   ${if} $R3 == "tr"
10   ${andif} $DictCode != "tr" # if nothing was found (the last line in the file starts with "tr")
11    FileClose $R5
12    StrCpy $String ""
13    StrCpy $AspellInstallYes "$RunNumber$AspellInstallYes"
14    Goto abortinstall
15   ${endif}
16  ${LoopUntil} $DictCode == $R3
17  FileClose $R5
18
19   StrCpy $String $String -2 # delete the linebreak characters at the end
20  
21   # Download aspell dictionaries,
22   # if first download repository is not available try the other ones listed in "AspellRepositories.txt"
23   FileOpen $R5 "$INSTDIR\Resources\AspellRepositories.txt" r
24   ${For} $4 1 4
25    FileRead $R5 $Search # $Search is now the AspellLocation
26    StrCpy $Search $Search -2 # delete the linebreak characters at the end
27    Push $R0
28    InetLoad::load /TIMEOUT=5000 "$Search/aspell6-$String.exe" "$INSTDIR\aspell6-$String.exe" /END
29    Pop $R0
30    # test if the downloaded file is really the expected one, because if the file didn't exist on the download server,
31    # berlios.de downloads a text file with the name of the non-existing file that contains the line "File doesn't exist" 
32    FileOpen $R4 "$INSTDIR\aspell6-$String.exe" r
33    FileRead $R4 $Search
34    FileClose $R4
35    StrCpy $Search $Search -1 # delete the unix linebreak character at the end
36    ${if} $Search == "File doesn't exist"
37     StrCpy $R0 ""
38    ${endif}
39    ${if} $R0 == "OK"
40     ${ExitFor}
41    ${endif}
42   ${Next}
43   FileClose $R5
44   
45   # Download failed
46   ${if} $R0 != "OK"
47    MessageBox MB_OK|MB_ICONEXCLAMATION "$(AspellDownloadFailed) $R0"
48    StrCpy $AspellInstallYes "$RunNumber$AspellInstallYes"
49    Goto abortinstall
50   ${endif}
51  
52   # Download successful
53   ExecWait '"$INSTDIR\aspell6-$String.exe" /NoDirChange /AutoClose'
54   ${if} $AspellBaseReg == "HKLM"
55    ReadRegStr $R2 HKLM "Software\Aspell\Dictionaries" $DictCode
56   ${else}
57    ReadRegStr $R2 HKCU "Software\Aspell\Dictionaries" $DictCode
58   ${endif}
59   ${if} $R2 == ""
60    MessageBox MB_OK|MB_ICONEXCLAMATION "$(AspellInstallFailed)"
61    StrCpy $AspellInstallYes "$RunNumber$AspellInstallYes"
62   ${endif}
63
64   abortinstall:
65   Delete "$INSTDIR\aspell6-$String.exe"
66
67 FunctionEnd
68
69 #--------------------------------
70
71 Function InstallAspellDictionary
72         
73  StrCpy $AspellInstallYes ""
74
75  # install the english dictionary if not already installed
76  StrCpy $DictCode "en"
77  StrCpy $RunNumber "1"
78  ${if} $AspellBaseReg == "HKLM" # $AspellBaseReg is either "HKLM" or if Aspell is already installed only for the current user "HKCU"
79   ReadRegStr $R2 HKLM "Software\Aspell\Dictionaries" $DictCode
80  ${else}
81   ReadRegStr $R2 HKCU "Software\Aspell\Dictionaries" $DictCode
82  ${endif}
83  ${if} $R2 == ""
84   MessageBox MB_OK|MB_ICONINFORMATION "$(AspellInfo)"
85   StrCpy $AspellMessage "Yes"
86   Call DownloadDictionary
87  ${else}
88   StrCpy $AspellInstallYes "$RunNumber$AspellInstallYes"
89  ${endif}
90  
91  # install the dictionary corresponding to the system and the chosen menu language
92  # check if the system language and the chosen menu language are the same, if not install
93  # both dictionaries
94  StrCpy $DictCode $LangCode 2
95  StrCpy $0 $DictCode # $0 is now the language code of the chosen LyX menu language
96  StrCpy $RunNumber "2"
97  ${if} $AspellInstallYes == "1"
98  ${andif} $DictCode == "en"
99   StrCpy $AspellInstallYes "$RunNumber$AspellInstallYes"
100  ${else}
101   ${if} $AspellBaseReg == "HKLM"
102    ReadRegStr $R2 HKLM "Software\Aspell\Dictionaries" $DictCode
103   ${else}
104    ReadRegStr $R2 HKCU "Software\Aspell\Dictionaries" $DictCode
105   ${endif}
106   ${if} $R2 == ""
107    ${if} $AspellMessage != "Yes"
108     MessageBox MB_OK|MB_ICONINFORMATION "$(AspellInfo)"
109    ${endif}
110    Call DownloadDictionary
111   ${else}
112    StrCpy $AspellInstallYes "$RunNumber$AspellInstallYes"
113   ${endif}
114  ${endif} # endif $AspellInstallYes == "1"
115  ${if} $LangCodeSys != $DictCode
116   StrCpy $RunNumber "3"
117   ${if} $LangCodeSys == "en"
118    StrCpy $AspellInstallYes "$RunNumber$AspellInstallYes"
119   ${else}
120    StrCpy $DictCode $LangCodeSys
121    ${if} $AspellBaseReg == "HKLM"
122     ReadRegStr $R2 HKLM "Software\Aspell\Dictionaries" $DictCode
123    ${else}
124     ReadRegStr $R2 HKCU "Software\Aspell\Dictionaries" $DictCode
125    ${endif}
126    ${if} $R2 == ""
127     ${if} $AspellMessage != "Yes"
128      MessageBox MB_OK|MB_ICONINFORMATION "$(AspellInfo)"
129     ${endif}
130     Call DownloadDictionary
131    ${else}
132     StrCpy $AspellInstallYes "$RunNumber$AspellInstallYes"
133    ${endif}
134   ${endif} # endif $LangCodeSys == "en"
135  ${else} # else ${if} $LangCodeSys != $DictCode
136   StrCpy $AspellInstallYes "4$AspellInstallYes"
137  ${endif}
138
139  # check the registry to divide between nothing installed or all already installed
140  ${if} $AspellInstallYes == "321"
141  ${orif} $AspellInstallYes == "421"
142   ${if} $AspellBaseReg == "HKLM"
143    ReadRegStr $R2 HKLM "Software\Aspell\Dictionaries" "en"
144   ${else}
145    ReadRegStr $R2 HKCU "Software\Aspell\Dictionaries" "en"
146   ${endif}
147   ${if} $R2 != ""
148    ${if} $0 == "en"
149    ${andif} $LangCodeSys == "en"
150     MessageBox MB_ICONINFORMATION|MB_DEFBUTTON2|MB_YESNO "$(AspellAll) English$(AspellPart4)" IDYES DownloadNow IDNO DownloadLater
151    ${endif}
152    ${if} $0 == "en"
153     MessageBox MB_ICONINFORMATION|MB_DEFBUTTON2|MB_YESNO "$(AspellAll) English$(AspellPartAnd)$LangNameSys$(AspellPart4)" IDYES DownloadNow IDNO DownloadLater
154    ${endif}
155    ${if} $LangCodeSys == "en"
156     MessageBox MB_ICONINFORMATION|MB_DEFBUTTON2|MB_YESNO "$(AspellAll) English$(AspellPartAnd)$LangName$(AspellPart4)" IDYES DownloadNow IDNO DownloadLater
157    ${endif}
158    ${if} $LangCodeSys != $0
159     MessageBox MB_ICONINFORMATION|MB_DEFBUTTON2|MB_YESNO "$(AspellAll) English$(AspellPartSep)$LangName$(AspellPartAnd)$LangNameSys$\r$\n$(AspellPart4)" IDYES DownloadNow IDNO DownloadLater
160    ${endif}
161    ${if} $LangCodeSys == $0
162     MessageBox MB_ICONINFORMATION|MB_DEFBUTTON2|MB_YESNO "$(AspellAll) English$(AspellPartAnd)$LangName$(AspellPart4)" IDYES DownloadNow IDNO DownloadLater
163    ${endif}
164   ${endif}
165  ${endif}
166  
167  Delete "$INSTDIR\Resources\AspellDictionaryNames.txt"
168  Delete "$INSTDIR\Resources\AspellRepositories.txt"
169  
170  # show message about Aspell dictionaries
171  # the code rule to display the correct message:
172  # - when the englisch dictionary is already installed or couldn't be installed -> set a "1"
173  # - when the dictionary of the chosen LyX menu language is already installed or couldn't be installed -> set a "2"
174  # - when the dictionary of the Windows system language is already installed or couldn't be installed -> set a "3"
175  # - when the dictionary of the chosen LyX menu language is equal to the dictionary of the Windows system language -> set a "4"
176  ${if} $AspellInstallYes == "32"
177  ${orif} $AspellInstallYes == "42"
178   MessageBox MB_ICONINFORMATION|MB_DEFBUTTON2|MB_YESNO "$(AspellPartStart)$(AspellPart1)$(AspellPart4)" IDYES DownloadNow IDNO DownloadLater
179  ${endif}
180  ${if} $AspellInstallYes == "3"
181  ${orif} $AspellInstallYes == "4"
182   MessageBox MB_ICONINFORMATION|MB_DEFBUTTON2|MB_YESNO "$(AspellPartStart)$(AspellPart1)$(AspellPartAnd)$(AspellPart2)$(AspellPart4)" IDYES DownloadNow IDNO DownloadLater
183  ${endif}
184  ${if} $AspellInstallYes == "2"
185   MessageBox MB_ICONINFORMATION|MB_DEFBUTTON2|MB_YESNO "$(AspellPartStart)$(AspellPart1)$(AspellPartAnd)$(AspellPart3)$(AspellPart4)" IDYES DownloadNow IDNO DownloadLater
186  ${endif}
187  ${if} $AspellInstallYes == ""
188   MessageBox MB_ICONINFORMATION|MB_DEFBUTTON2|MB_YESNO "$(AspellPartStart)$(AspellPart1)$(AspellPartSep)$(AspellPart2)$(AspellPartAnd)$(AspellPart3)$(AspellPart4)" IDYES DownloadNow IDNO DownloadLater
189  ${endif}
190  ${if} $AspellInstallYes == "321"
191  ${orif} $AspellInstallYes == "421"
192   MessageBox MB_ICONINFORMATION|MB_DEFBUTTON2|MB_YESNO "$(AspellNone)" IDYES DownloadNow IDNO DownloadLater
193  ${endif}
194  ${if} $AspellInstallYes == "31"
195  ${orif} $AspellInstallYes == "41"
196   MessageBox MB_ICONINFORMATION|MB_DEFBUTTON2|MB_YESNO "$(AspellPartStart)$(AspellPart2)$(AspellPart4)" IDYES DownloadNow IDNO DownloadLater
197  ${endif}
198  ${if} $AspellInstallYes == "21"
199   MessageBox MB_ICONINFORMATION|MB_DEFBUTTON2|MB_YESNO "$(AspellPartStart)$(AspellPart3)$(AspellPart4)" IDYES DownloadNow IDNO DownloadLater
200  ${endif}
201  ${if} $AspellInstallYes == "1"
202   MessageBox MB_ICONINFORMATION|MB_DEFBUTTON2|MB_YESNO "$(AspellPartStart)$(AspellPart2)$(AspellPartAnd)$(AspellPart3)$(AspellPart4)" IDYES DownloadNow IDNO DownloadLater
203  ${endif}
204
205  DownloadNow:
206   ExecShell "open" "${AspellLocationExact}"
207  DownloadLater:
208          
209 FunctionEnd
210  
211 #---------------------------
212
213 Function un.UninstAspell
214
215     ReadRegStr $1 SHCTX "Software\Aspell" "Base Path"
216     # delete Aspells' install folder
217     RMDir /r $1
218     # unregister Aspell and its dictionaries
219     DeleteRegKey SHCTX "Software\Aspell"
220     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell"
221     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-af"
222     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-am"
223     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-ar"
224     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-az"
225     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-be"
226     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-bg"
227     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-bn"
228     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-br"
229     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-ca"
230     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-cs"
231     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-csb"
232     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-cy"
233     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-da"
234     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-de"
235     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-en"
236     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-el"
237     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-eo"
238     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-es"
239     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-et"
240     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-fa"
241     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-fi"
242     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-fo"
243     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-fr"
244     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-ga"
245     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-gd"
246     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-gl"
247     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-gu"
248     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-gv"
249     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-he"
250     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-hi"
251     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-hil"
252     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-hr"
253     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-hsb"
254     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-hu"
255     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-ia"
256     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-id"
257     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-is"
258     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-it"
259     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-ku"
260     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-la"
261     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-lt"
262     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-lv"
263     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-mg"
264     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-mi"
265     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-mk"
266     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-mn"
267     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-mr"
268     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-ms"
269     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-mt"
270     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-nb"
271     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-nds"
272     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-nl"
273     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-nn"
274     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-no"
275     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-ny"
276     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-or"
277     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-pa"
278     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-pl"
279     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-pt"
280     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-qu"
281     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-ro"
282     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-ru"
283     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-rw"
284     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-sc"
285     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-sk"
286     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-sl"
287     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-sr"
288     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-sv"
289     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-sw"
290     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-ta"
291     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-te"
292     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-tet"
293     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-tl"
294     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-tn"
295     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-tr"
296     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-uk"
297     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-uz"
298     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-vi"
299     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-wa"
300     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-yi"
301     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Aspell6-Dictionary-zu"
302   
303 FunctionEnd
304