# HG changeset patch
# Node ID 914661e61e5d
# Parent  79900d84f4bf
diff --git a/Makefile.mingw b/Makefile.mingw
--- a/Makefile.mingw
+++ b/Makefile.mingw
@@ -8,6 +8,8 @@
 PIDGIN_TREE_TOP := .
 include $(PIDGIN_TREE_TOP)/libpurple/win32/global.mak
 
+DICTIONARY_TIMESTAMP := 20220215-003057
+
 # Generate a X.X.X.X version for the installer file versioning header
 # The last digit will be 99 for a final release, 0 for dev or unknown, or the beta number
 PIDGIN_PRODUCT_VERSION = $(shell \
@@ -129,15 +131,13 @@
 	 | LC_ALL=C sort | sed -e s/^/\!insertmacro\ LANG_SECTION\ \"/ -e s/$$/\"/ \
 	 > pidgin/win32/nsis/pidgin-translations.nsh
 	#Convert the available.lst lines to "!insertmacro SPELLCHECK_SECTION lang lang_name lang_file"
-	sed -e "/^#/d" -e "s/^[^,]\{1,\},[^,]\{1,\},/\"/" \
-	 -e "s/,/\"\ \"/" -e "s/,/\"\ \"/" -e "s/[\ \t]*$$/\"/" \
-	 -e "s/^/\!insertmacro\ SPELLCHECK_SECTION\ /" \
+	sed -e "/^#/d" -e "s/,/\ /" -e "s/^/\!insertmacro\ SPELLCHECK_SECTION\ /" \
          pidgin/win32/nsis/available.lst \
          > pidgin/win32/nsis/pidgin-spellcheck.nsh
 	#Convert the lines to "!insertmacro CHECK_SPELLCHECK_SECTION lang"
 	iconv -f latin1 -t utf-8 pidgin/win32/nsis/pidgin-spellcheck.nsh | \
 	 sed -e "s/SPELLCHECK_SECTION/CHECK_SPELLCHECK_SECTION/" \
-	 -e "s/ \"[^\"]*\"\ \"[^\"]*\"[\t\ ]*$$//" | \
+	 -e "s/ \"[^\"]*\"[\t\ ]*$$//" | \
          iconv -f utf-8 -t latin1 \
         > pidgin/win32/nsis/pidgin-spellcheck-preselect.nsh
 	#Generate the Installer translations
@@ -163,7 +163,8 @@
 	$(eval $@_GTK_SHA1SUM := $(shell sha1sum pidgin/win32/nsis/gtk-runtime-$(GTK_INSTALL_VERSION).zip | sed -e "s/\ .*$$//"))
 	$(MAKENSIS) -V3 -DPIDGIN_VERSION="$(PIDGIN_VERSION)" -DPIDGIN_PRODUCT_VERSION="$(PIDGIN_PRODUCT_VERSION)" \
 		-DPIDGIN_INSTALL_DIR="$(STRIPPED_RELEASE_DIR)" -DGTK_INSTALL_VERSION="$(GTK_INSTALL_VERSION)" \
-		-DDEBUG_SYMBOLS_SHA1SUM="$($@_DEBUG_SYMBOLS_SHA1SUM)" -DGTK_SHA1SUM="$($@_GTK_SHA1SUM)"\
+		-DDEBUG_SYMBOLS_SHA1SUM="$($@_DEBUG_SYMBOLS_SHA1SUM)" -DGTK_SHA1SUM="$($@_GTK_SHA1SUM)" \
+		-DDICTIONARY_TIMESTAMP="$(DICTIONARY_TIMESTAMP)" \
 		pidgin/win32/nsis/pidgin-installer.nsi
 	$(call authenticode_sign, pidgin/win32/nsis/pidgin-$(PIDGIN_VERSION).exe, "Pidgin Installer")
 	mv pidgin/win32/nsis/pidgin-$(PIDGIN_VERSION).exe ./
@@ -172,7 +173,7 @@
 installer_offline: generate_installer_includes
 	$(MAKENSIS) -V3 -DPIDGIN_VERSION="$(PIDGIN_VERSION)" -DPIDGIN_PRODUCT_VERSION="$(PIDGIN_PRODUCT_VERSION)" \
 		-DPIDGIN_INSTALL_DIR="$(STRIPPED_RELEASE_DIR)" -DGTK_INSTALL_VERSION="$(GTK_INSTALL_VERSION)" \
-		-DOFFLINE_INSTALLER \
+		-DDICTIONARY_TIMESTAMP="$(DICTIONARY_TIMESTAMP)" -DOFFLINE_INSTALLER \
 		pidgin/win32/nsis/pidgin-installer.nsi
 	$(call authenticode_sign, pidgin/win32/nsis/pidgin-$(PIDGIN_VERSION)-offline.exe, "Pidgin Installer")
 	mv pidgin/win32/nsis/pidgin-$(PIDGIN_VERSION)-offline.exe ./
diff --git a/pidgin/win32/nsis/README.md b/pidgin/win32/nsis/README.md
new file mode 100644
--- /dev/null
+++ b/pidgin/win32/nsis/README.md
@@ -0,0 +1,20 @@
+This directory contains all of the stuff create our nsis installer. This file
+is meant to document what they all do, but we're still determining some of
+that.
+
+## available.lst
+
+`available.lst` is used to allow the user to select what spell checking
+dictionaries to install. It is generated from the
+[pidgin-dictionaries](https://keep.imfreedom.org/pidgin/dictionaries)
+repository. There's a CI job for it in TeamCity that should be ran whenever we
+want to upgrade the dictionaries. But this should be done sparingly as we don't
+want to break old links or have a ton of the files on SourceForge.
+
+The dictionaries as well as this file are deployed to
+[SourceForge](https://sourceforge.net/projects/pidgin/files/dictionaries) in a
+time stamped directory.
+
+After the dictionaries are updated on SourceForge, you should update the
+`available.lst` in this directory with the one from SourceForge.
+
diff --git a/pidgin/win32/nsis/available.lst b/pidgin/win32/nsis/available.lst
--- a/pidgin/win32/nsis/available.lst
+++ b/pidgin/win32/nsis/available.lst
@@ -1,100 +1,71 @@
-#This file is from ftp://ftp.services.openoffice.org/pub/OpenOffice.org/contrib/dictionaries/available.lst
-af,ZA,af_ZA,Afrikaans (South Africa),af_ZA.zip
-ak,GH,ak_GH,Akan (Ghana),ak_GH.zip
-sq,AL,sq_AL,Albanian (Albania),sq_AL.zip
-bg,BG,bg_BG,Bulgarian (Bulgaria),bg_BG.zip
-ca,ES,ca_ES,Catalan (Spain),ca_ES.zip
-cop,EG,cop_EG,Coptic (Egypt),cop_EG.zip
-hr,HR,hr_HR,Croatian (Croatia),hr_HR.zip
-cs,CZ,cs_CZ,Czech (Czech Republic),cs_CZ.zip
-da,DK,da_DK,Danish (Denmark),da_DK.zip
-nl,NL,nl_NL,Dutch (Netherlands),nl_NL.zip
-nl,NL,nl_med,Dutch Medical (Netherlands),nl_med.zip
-en,AU,en_AU,English (Australia),en_AU.zip
-en,CA,en_CA,English (Canada),en_CA.zip
-en,NZ,en_NZ,English (New Zealand),en_NZ.zip
-en,ZA,en_ZA,English (South Africa),en_ZA.zip
-en,GB,en_GB,English (United Kingdom),en_GB.zip
-en,US,en_US,English (United States),en_US.zip
-eo,ANY,eo_l3,Esperanto,eo.zip
-et,EE,et_EE,Estonian (Estonia),et_EE.zip
-fo,FO,fo_FO,Faroese (Faroe Islands),fo_FO.zip
-fr,FR,fr_FR-classique,Fran�ais Classique,fr_FR-classique_1-3-2.zip
-fr,FR,fr_FR-1990,Fran�ais R�forme 1990,fr_FR-1990_1-3-2.zip
-fr,FR,fr_FR,Fran�ais R�forme 1990 & Classique,fr_FR_1-3-2.zip
-fy,NL,fy_NL,Frisian (Netherlands),fy_NL.zip
-gl,ES,gl_ES,Galician (Spain),gl_ES.zip
-gsc,FR,gsc_FR,Gascon (France),gsc_FR.zip
-de,AT,de_AT,German (Austria Extension),de_AT.zip
-de,AT,de_AT_frami,German (Austria) neu 08/2006 (frami),de_AT_frami.zip
-de,DE,de_DE,German (Germany),de_DE.zip
-de,DE,de_DE_frami,German (Germany) neu 08/2006 (frami),de_DE_frami.zip
-de,CH,de_CH,German (Switzerland),de_CH.zip
-de,CT,de_CH_frami,German (Switzerland) neu 08/2006 (frami),de_CH_frami.zip
-el,GR,el_GR,Greek (Greece),el_GR.zip
-gu,IN,gu_IN,Gujarati (India),gu_IN.zip
-he,IL,he_IL,Hebrew (Israel),he_IL.zip
-hil,PH,hil_PH,Hiligaynon (Philippines),hil_PH.zip
-hu,HU,hu_HU,Hungarian (Hungary),hu_HU.zip
-hu,HU,hu_HU_comb,Hungarian (Hungary) collected compounds,hu_HU_comb.zip
-id,ID,id_ID,Indonesian (Indonesia),id_ID.zip
-ga,IE,ga_IE,Irish (Ireland),ga_IE.zip
-it,IT,it_IT,Italian (Italy),it_IT.zip
-sw,KE,sw_KE,Kiswahili (Africa),sw_KE.zip
-ku,TR,ku_TR,Kurdish (Turkey),ku_TR.zip
-it,IT,la,Latin,la.zip
-lv,LV,lv_LV,Latvian (Latvia),lv_LV.zip
-lt,LT,lt_LT,Lithuanian (Lithuania),lt_LT.zip
-mk,MK,mk_MK,Macedonian (Macedonia),mk_MK.zip
-ms,MY,ms_MY,Malay (Malaysia),ms_MY.zip
-mi,NZ,mi_NZ,Maori (New Zealand),mi_NZ.zip
-mr,IN,mr_IN,Marathi (India),mr_IN.zip
-mos,BF,mos_BF,Moore,ms_BF.zip
-nr,ZA,nr_ZA,Ndebele (South Africa),nr_ZA.zip
-ne,NP,ne_NP,Nepali (Nepal),ne_NP.zip
-ns,ZA,ns_ZA,Northern Sotho (South Africa),ns_ZA.zip
-nb,NO,nb_NO,Norwegian Bokmaal (Norway),nb_NO.zip
-nn,NO,nn_NO,Norwegian Nynorsk (Norway),nn_NO.zip
-oc,FR,oc_FR,Occitan (Languedoc),oc_FR.zip
-pl,PL,pl_PL,Polish (Poland),pl_PL.zip
-pt,BR,pt_BR,Portuguese (Brazil),pt_BR.zip
-pt,PT,pt_PT,Portuguese (Portugal),pt_PT.zip
-ro,RO,ro_RO,Romanian (Romania),ro_RO.zip
-ru,RU,ru_RU,Russian (Russia),ru_RU.zip
-ru,RU,ru_RU_ye,Russian_ye (Russia),ru_RU_ye.zip
-ru,RU,ru_RU_yo,Russian_yo (Russia),ru_RU_yo.zip
-gd,GB,gd_GB,Scots Gaelic (Scotland),gd_GB.zip
-tn,ZA,tn_ZA,Setswana (Africa),tn_ZA.zip
-sk,SK,sk_SK,Slovak (Slovakia),sk_SK.zip
-sl,SI,sl_SI,Slovenian (Slovenia),sl_SI.zip
-st,ZA,st_ZA,Southern Sotho (South Africa),st_ZA.zip
-es,AR,es_AR,Spanish (Argentina),es_AR.zip
-es,BZ,es_HN,Spanish (Belize),es_HN.zip
-es,BO,es_BO,Spanish (Bolivia),es_BO.zip
-es,CL,es_CL,Spanish (Chile),es_CL.zip
-es,CO,es_CO,Spanish (Colombia),es_CO.zip
-es,CR,es_CR,Spanish (Costa Rica),es_CR.zip
-es,CU,es_CU,Spanish (Cuba),es_CU.zip
-es,DO,es_DO,Spanish (Dominican Republic),es_DO.zip
-es,EC,es_EC,Spanish (Ecuador),es_EC.zip
-es,SV,es_SV,Spanish (El Salvador),es_SV.zip
-es,GT,es_GT,Spanish (Guatemala),es_GT.zip
-es,MX,es_MX,Spanish (Mexico),es_MX.zip
-es,NI,es_NI,Spanish (Nicaragua),es_NI.zip
-es,PA,es_PA,Spanish (Panama),es_PA.zip
-es,PY,es_PY,Spanish (Paraguay),es_PY.zip
-es,PE,es_PE,Spanish (Peru),es_PE.zip
-es,PR,es_PR,Spanish (Puerto Rico),es_PR.zip
-es,ES,es_ES,Spanish (Spain),es_ES.zip
-es,UY,es_UY,Spanish (Uruguay),es_UY.zip
-es,VE,es_VE,Spanish (Venezuela),es_VE.zip
-ss,ZA,ss_ZA,Swati (South Africa),ss_ZA.zip
-sv,SE,sv_SE,Swedish (Sweden),sv_SE.zip
-ts,ZA,ts_ZA,Tsonga (South Africa),ts_ZA.zip
-uk,UA,uk_UA,Ukrainian (Ukraine),uk_UA.zip
-ur,PK,ur_PK,Urdu,ur_PK.zip
-ve,ZA,ve_ZA,Venda (South Africa),ve_ZA.zip
-vi,VN,vi_VN,Vietnamese (Viet-Nam),vi_VN.zip
-cy,GB,cy_GB,Welsh (Wales),cy_GB.zip
-xh,ZA,xh_ZA,Xhosa (South Africa),xh_ZA.zip
-zu,ZA,zu_ZA,Zulu (South Africa),zu_ZA.zip
+"af_ZA","Afrikaans (South Africa)"
+"an_ES","Aragonese (Spain)"
+"ar","Arabic"
+"be_BY","Belarusian (Belarus)"
+"bg_BG","Bulgarian (Bulgaria)"
+"bn_BD","Bengali (Bangladesh)"
+"bo","Tibetan"
+"br_FR","Breton (France)"
+"bs_BA","Bosnian (Bosnia and Herzegovina)"
+"ca","Catalan"
+"ca_ES-valencia","Catalan (Spain)"
+"cs_CZ","Czech (Czechia)"
+"da_DK","Danish (Denmark)"
+"de_AT","German (Austria)"
+"de_CH","German (Switzerland)"
+"de_DE","German (Germany)"
+"dz","Dzongkha"
+"el_GR","Modern Greek (1453-) (Greece)"
+"en_AU","English (Australia)"
+"en_CA","English (Canada)"
+"en_GB","English (United Kingdom)"
+"en_US","English (United States)"
+"en_ZA","English (South Africa)"
+"eo","Esperanto"
+"es_ES","Spanish (Spain)"
+"et_EE","Estonian (Estonia)"
+"eu","Basque"
+"fo","Faroese"
+"fr","French"
+"gd_GB","Scottish Gaelic (United Kingdom)"
+"gl_ES","Galician (Spain)"
+"gu_IN","Gujarati (India)"
+"gug_PY","Paraguayan Guaraní (Paraguay)"
+"he_IL","Hebrew (Israel)"
+"hi_IN","Hindi (India)"
+"hr_HR","Croatian (Croatia)"
+"hu_HU","Hungarian (Hungary)"
+"id_ID","Indonesian (Indonesia)"
+"is_IS","Icelandic (Iceland)"
+"it_IT","Italian (Italy)"
+"kk_KZ","Kazakh (Kazakhstan)"
+"kmr_Latn","Northern Kurdish"
+"ko","Korean"
+"lo_LA","Lao (Lao People's Democratic Republic)"
+"lt_LT","Lithuanian (Lithuania)"
+"lv_LV","Latvian (Latvia)"
+"nb_NO","Norwegian Bokmål (Norway)"
+"ne_NP","Nepali (macrolanguage) (Nepal)"
+"nl","Dutch"
+"nn_NO","Norwegian Nynorsk (Norway)"
+"oc_FR","Occitan (post 1500) (France)"
+"pl_PL","Polish (Poland)"
+"pt_BR","Portuguese (Brazil)"
+"pt_PT","Portuguese (Portugal)"
+"ro_RO","Romanian (Romania)"
+"ru_RU","Russian (Russian Federation)"
+"si_LK","Sinhala (Sri Lanka)"
+"sk_SK","Slovak (Slovakia)"
+"sl_SI","Slovenian (Slovenia)"
+"sr_Latn_RS","Serbian (Serbia)"
+"sr_RS","Serbian (Serbia)"
+"sv_FI","Swedish (Finland)"
+"sv_SE","Swedish (Sweden)"
+"sw_TZ","Swahili (macrolanguage) (Tanzania, United Republic of)"
+"te_IN","Telugu (India)"
+"th_TH","Thai (Thailand)"
+"tl","Tagalog"
+"tr_TR","Turkish (Turkey)"
+"uk_UA","Ukrainian (Ukraine)"
+"uz_UZ","Uzbek (Uzbekistan)"
+"vi_VN","Vietnamese (Viet Nam)"
diff --git a/pidgin/win32/nsis/pidgin-installer.nsi b/pidgin/win32/nsis/pidgin-installer.nsi
--- a/pidgin/win32/nsis/pidgin-installer.nsi
+++ b/pidgin/win32/nsis/pidgin-installer.nsi
@@ -70,6 +70,7 @@
 !define GTK_MIN_VERSION				"2.14.0"
 
 !define DOWNLOADER_URL				"https://pidgin.im/win32/download_redir.php?version=${PIDGIN_VERSION}"
+!define DICTIONARY_URL        "https://downloads.sourceforge.net/project/pidgin/dictionaries/${DICTIONARY_TIMESTAMP}"
 
 !define MEMENTO_REGISTRY_ROOT			HKLM
 !define MEMENTO_REGISTRY_KEY			"${PIDGIN_UNINSTALL_KEY}"
@@ -257,7 +258,7 @@
   retry:
   StrCpy $R2 "${DOWNLOADER_URL}&gtk_version=${GTK_INSTALL_VERSION}&dl_pkg=gtk"
   DetailPrint "Downloading GTK+ Runtime ... ($R2)"
-  inetc::get /CONNECTTIMEOUT=10 "$R2" "$R1"
+  inetc::get /CONNECTTIMEOUT=10 "$R2" "$R1" /END
   Pop $R0
   StrCmp $R0 "OK" 0 prompt_retry
 
@@ -409,9 +410,8 @@
 ;--------------------------------
 ;Spell Checking
 
-!macro SPELLCHECK_SECTION lang lang_name lang_file
+!macro SPELLCHECK_SECTION lang lang_name
   Section /o "${lang_name}" SecSpell_${lang}
-    Push ${lang_file}
     Push ${lang}
     Call InstallDict
   SectionEnd
@@ -435,7 +435,7 @@
   retry:
   StrCpy $R2 "${DOWNLOADER_URL}&dl_pkg=dbgsym"
   DetailPrint "Downloading Debug Symbols... ($R2)"
-  inetc::get /CONNECTTIMEOUT=10 "$R2" "$R1"
+  inetc::get /CONNECTTIMEOUT=10 "$R2" "$R1" /END
   Pop $R0
   StrCmp $R0 "Cancelled" done
   StrCmp $R0 "OK" 0 prompt_retry
@@ -1248,13 +1248,10 @@
 Function InstallDict
   Push $R0
   Exch
-  Pop $R0 ;This is the language code
+  Pop $R4 ;This is the language code
   Push $R1
-  Exch 2
-  Pop $R1 ;This is the language file
   Push $R2
   Push $R3
-  Push $R4
 
   ClearErrors
   IfFileExists "$INSTDIR\spellcheck\share\enchant\myspell\$R0.dic" installed
@@ -1262,33 +1259,34 @@
   InitPluginsDir
 
   ; We need to download and install dictionary
-  StrCpy $R2 "$PLUGINSDIR\$R1"
-  StrCpy $R3 "${DOWNLOADER_URL}&dl_pkg=oo_dict&lang=$R1&lang_file=$R1"
-  DetailPrint "Downloading the $R0 Dictionary... ($R3)"
+  StrCpy $R1 "$PLUGINSDIR\$R4.zip"
+  StrCpy $R2 "${DICTIONARY_URL}/$R4.zip"
   retry:
-  NSISdl::download /TIMEOUT=10000 "$R3" "$R2"
-  Pop $R4
-  StrCmp $R4 "cancel" done
-  StrCmp $R4 "success" +3
-    MessageBox MB_RETRYCANCEL "$(PIDGINSPELLCHECKERROR)" /SD IDCANCEL IDRETRY retry IDCANCEL done
-    Goto done
+  DetailPrint "Downloading the $R4 Dictionary... ($R2)"
+  inetc::get /CONNECTTIMEOUT=10 "$R2" "$R1" /END
+  Pop $R0
+  StrCmp $R0 "OK" 0 prompt_retry
+
   SetOutPath "$INSTDIR\spellcheck\share\enchant\myspell"
-  nsisunz::UnzipToLog "$R2" "$OUTDIR"
+  nsisunz::UnzipToLog "$R1" "$OUTDIR"
   SetOutPath "$INSTDIR"
-  Pop $R3
-  StrCmp $R3 "success" installed
-    DetailPrint "$R3" ;print error message to log
+  Pop $R0
+  StrCmp $R0 "success" installed
+    DetailPrint "$R2" ;print error message to log
     Goto done
 
   installed: ;The dictionary is currently installed, no error message
-    DetailPrint "$R0 Dictionary is installed"
+    DetailPrint "$R4 Dictionary is installed"
+  goto done
+
+  prompt_retry:
+    MessageBox MB_RETRYCANCEL "$(PIDGINSPELLCHECKERROR)" /SD IDCANCEL IDRETRY retry IDCANCEL done
 
   done:
-  Pop $R4
   Pop $R3
   Pop $R2
+  Pop $R1
   Pop $R0
-  Exch $R1
 FunctionEnd
 
 !ifndef OFFLINE_INSTALLER
