Migrate certificates, icons, logs to XDG dirs
[pidgin-git.git] / pidgin / win32 / nsis / pidgin-installer.nsi
blobe029b1dc98efda8e7dd1a80e8424abb67aa2cbcc
1 ; Installer script for win32 Pidgin
2 ; Original Author: Herman Bloggs <hermanator12002@yahoo.com>
3 ; Updated By: Daniel Atallah <daniel_atallah@yahoo.com>
5 ; NOTE: this .NSI script is intended for NSIS 2.27+
8 ;--------------------------------
9 ;Global Variables
10 Var name
11 Var STARTUP_RUN_KEY
12 Var CURRENT_GTK_STATE
13 Var WARNED_GTK_STATE
15 ;--------------------------------
16 ;Configuration
18 ;The name var is set in .onInit
19 Name $name
21 !ifdef OFFLINE_INSTALLER
22 OutFile "pidgin-${PIDGIN_VERSION}-offline.exe"
23 !else
24 OutFile "pidgin-${PIDGIN_VERSION}.exe"
25 !endif
27 SetCompressor /SOLID lzma
28 ShowInstDetails show
29 ShowUninstDetails show
30 SetDateSave on
31 RequestExecutionLevel highest
33 ; $name and $INSTDIR are set in .onInit function..
35 !include "MUI.nsh"
36 !include "Sections.nsh"
37 !include "LogicLib.nsh"
38 !include "Memento.nsh"
40 !include "FileFunc.nsh"
41 !insertmacro GetParameters
42 !insertmacro GetOptions
43 !insertmacro GetParent
45 !include "WordFunc.nsh"
46 !insertmacro VersionCompare
47 !insertmacro WordFind
48 !insertmacro un.WordFind
50 !include "TextFunc.nsh"
52 ;--------------------------------
53 ;Defines
55 !define PIDGIN_NSIS_INCLUDE_PATH "."
57 ; Remove these and the stuff that uses them at some point
58 !define OLD_GAIM_REG_KEY "SOFTWARE\gaim"
59 !define OLD_GAIM_UNINSTALL_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Gaim"
60 !define OLD_GAIM_UNINST_EXE "gaim-uninst.exe"
62 !define PIDGIN_REG_KEY "SOFTWARE\pidgin"
63 !define PIDGIN_UNINSTALL_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Pidgin"
65 !define HKLM_APP_PATHS_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\pidgin.exe"
66 !define STARTUP_RUN_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
67 !define PIDGIN_UNINST_EXE "pidgin-uninst.exe"
69 !define GTK_MIN_VERSION "2.14.0"
71 !define DOWNLOADER_URL "https://pidgin.im/win32/download_redir.php?version=${PIDGIN_VERSION}"
73 !define MEMENTO_REGISTRY_ROOT HKLM
74 !define MEMENTO_REGISTRY_KEY "${PIDGIN_UNINSTALL_KEY}"
76 ;--------------------------------
77 ;Version resource
78 VIProductVersion "${PIDGIN_PRODUCT_VERSION}"
79 VIAddVersionKey "ProductName" "Pidgin"
80 VIAddVersionKey "FileVersion" "${PIDGIN_VERSION}"
81 VIAddVersionKey "ProductVersion" "${PIDGIN_VERSION}"
82 VIAddVersionKey "LegalCopyright" ""
83 !ifdef OFFLINE_INSTALLER
84 VIAddVersionKey "FileDescription" "Pidgin Installer (Offline)"
85 !else
86 VIAddVersionKey "FileDescription" "Pidgin Installer"
87 !endif
89 ;--------------------------------
90 ;Reserve files used in .onInit
91 ;for faster start-up
92 ReserveFile "${NSISDIR}\Plugins\System.dll"
93 ReserveFile "${NSISDIR}\Plugins\UserInfo.dll"
94 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
95 !insertmacro MUI_RESERVEFILE_LANGDLL
97 ;--------------------------------
98 ;Modern UI Configuration
100 !define MUI_ICON ".\pixmaps\pidgin-install.ico"
101 !define MUI_UNICON ".\pixmaps\pidgin-install.ico"
102 !define MUI_WELCOMEFINISHPAGE_BITMAP ".\pixmaps\pidgin-intro.bmp"
103 !define MUI_HEADERIMAGE
104 !define MUI_HEADERIMAGE_BITMAP ".\pixmaps\pidgin-header.bmp"
106 ; Alter License section
107 !define MUI_LICENSEPAGE_BUTTON $(PIDGINLICENSEBUTTON)
108 !define MUI_LICENSEPAGE_TEXT_BOTTOM $(PIDGINLICENSEBOTTOMTEXT)
110 !define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
111 !define MUI_LANGDLL_REGISTRY_KEY ${PIDGIN_REG_KEY}
112 !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
114 !define MUI_COMPONENTSPAGE_SMALLDESC
115 !define MUI_ABORTWARNING
117 ;Finish Page config
118 !define MUI_FINISHPAGE_NOAUTOCLOSE
119 ;!define MUI_FINISHPAGE_RUN "$INSTDIR\pidgin.exe"
120 ;!define MUI_FINISHPAGE_RUN_NOTCHECKED
121 !define MUI_FINISHPAGE_LINK $(PIDGINFINISHVISITWEBSITE)
122 !define MUI_FINISHPAGE_LINK_LOCATION "https://pidgin.im"
124 ;--------------------------------
125 ;Pages
127 !define MUI_PAGE_CUSTOMFUNCTION_PRE preWelcomePage
128 !insertmacro MUI_PAGE_WELCOME
129 !insertmacro MUI_PAGE_LICENSE "../../../COPYING"
130 !insertmacro MUI_PAGE_COMPONENTS
132 ; Pidgin install dir page
133 !insertmacro MUI_PAGE_DIRECTORY
135 !insertmacro MUI_PAGE_INSTFILES
136 !insertmacro MUI_PAGE_FINISH
138 !insertmacro MUI_UNPAGE_WELCOME
139 !insertmacro MUI_UNPAGE_CONFIRM
140 !insertmacro MUI_UNPAGE_INSTFILES
141 !insertmacro MUI_UNPAGE_FINISH
143 ;--------------------------------
144 ;Languages
146 !include "${PIDGIN_NSIS_INCLUDE_PATH}\langmacros.nsh"
148 ;--------------------------------
150 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
151 ;; Start Install Sections ;;
152 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
154 ;--------------------------------
155 ;Uninstall any old version of Pidgin (or Gaim)
157 Section -SecUninstallOldPidgin
158 ; Check install rights..
159 Call CheckUserInstallRights
160 Pop $R0
162 ;First try to uninstall Pidgin
163 StrCpy $R4 ${PIDGIN_REG_KEY}
164 StrCpy $R5 ${PIDGIN_UNINSTALL_KEY}
165 StrCpy $R6 ${PIDGIN_UNINST_EXE}
166 StrCpy $R7 "Pidgin"
168 start_comparison:
169 ;If pidgin is currently set to run on startup,
170 ; save the section of the Registry where the setting is before uninstalling,
171 ; so we can put it back after installing the new version
172 ClearErrors
173 ReadRegStr $STARTUP_RUN_KEY HKCU "${STARTUP_RUN_KEY}" $R7
174 IfErrors +3
175 StrCpy $STARTUP_RUN_KEY "HKCU"
176 Goto +5
177 ClearErrors
178 ReadRegStr $STARTUP_RUN_KEY HKLM "${STARTUP_RUN_KEY}" $R7
179 IfErrors +2
180 StrCpy $STARTUP_RUN_KEY "HKLM"
182 StrCmp $R0 "HKLM" compare_hklm
183 StrCmp $R0 "HKCU" compare_hkcu done
185 compare_hkcu:
186 ReadRegStr $R1 HKCU $R4 ""
187 ReadRegStr $R2 HKCU $R4 "Version"
188 ReadRegStr $R3 HKCU "$R5" "UninstallString"
189 Goto try_uninstall
191 compare_hklm:
192 ReadRegStr $R1 HKLM $R4 ""
193 ReadRegStr $R2 HKLM $R4 "Version"
194 ReadRegStr $R3 HKLM "$R5" "UninstallString"
196 ; If a previous version exists, remove it
197 try_uninstall:
198 StrCmp $R1 "" no_version_found
199 ; Version key started with 0.60a3. Prior versions can't be
200 ; automatically uninstalled.
201 StrCmp $R2 "" uninstall_problem
202 ; Check if we have uninstall string..
203 IfFileExists $R3 0 uninstall_problem
204 ; Have uninstall string, go ahead and uninstall.
205 SetOverwrite on
206 ; Need to copy uninstaller outside of the install dir
207 ClearErrors
208 CopyFiles /SILENT $R3 "$TEMP\$R6"
209 SetOverwrite off
210 IfErrors uninstall_problem
211 ; Ready to uninstall..
212 ClearErrors
213 ExecWait '"$TEMP\$R6" /S /UPGRADE=1 _?=$R1'
214 IfErrors exec_error
215 Delete "$TEMP\$R6"
216 Goto done
218 exec_error:
219 Delete "$TEMP\$R6"
220 Goto uninstall_problem
222 no_version_found:
223 ;We've already tried to fallback to an old gaim instance
224 StrCmp $R7 "Gaim" done
225 ; If we couldn't uninstall Pidgin, try to uninstall Gaim
226 StrCpy $STARTUP_RUN_KEY "NONE"
227 StrCpy $R4 ${OLD_GAIM_REG_KEY}
228 StrCpy $R5 ${OLD_GAIM_UNINSTALL_KEY}
229 StrCpy $R6 ${OLD_GAIM_UNINST_EXE}
230 StrCpy $R7 "Gaim"
231 Goto start_comparison
233 uninstall_problem:
234 ; We can't uninstall. Either the user must manually uninstall or we ignore and reinstall over it.
235 MessageBox MB_OKCANCEL $(PIDGINPROMPTCONTINUEWITHOUTUNINSTALL) /SD IDOK IDOK done
236 Quit
237 done:
238 SectionEnd
241 ;--------------------------------
242 ;GTK+ Runtime Install Section
244 Section $(GTKSECTIONTITLE) SecGtk
246 InitPluginsDir
247 StrCpy $R1 "$PLUGINSDIR\gtk.zip"
248 !ifdef OFFLINE_INSTALLER
250 SetOutPath $PLUGINSDIR
251 File /oname=gtk.zip ".\gtk-runtime-${GTK_INSTALL_VERSION}.zip"
253 !else
255 ; We need to download the GTK+ runtime
256 retry:
257 StrCpy $R2 "${DOWNLOADER_URL}&gtk_version=${GTK_INSTALL_VERSION}&dl_pkg=gtk"
258 DetailPrint "Downloading GTK+ Runtime ... ($R2)"
259 NSISdl::download /TIMEOUT=10000 "$R2" "$R1"
260 Pop $R0
261 ;StrCmp $R0 "cancel" done
262 StrCmp $R0 "success" 0 prompt_retry
264 Push "${GTK_SHA1SUM}"
265 Push "$R1" ; Filename
266 Call CheckSHA1Sum
267 Pop $R0
269 StrCmp "$R0" "0" extract
270 prompt_retry:
271 MessageBox MB_RETRYCANCEL "$(PIDGINGTKDOWNLOADERROR)" /SD IDCANCEL IDRETRY retry IDCANCEL done
273 extract:
274 !endif
276 ;Delete the old Gtk directory
277 RMDir /r "$INSTDIR\Gtk"
279 SetOutPath "$INSTDIR"
280 nsisunz::UnzipToLog $R1 "$INSTDIR"
281 Pop $R0
282 StrCmp $R0 "success" +2
283 DetailPrint "$R0" ;print error message to log
285 !ifndef OFFLINE_INSTALLER
286 done:
287 !endif
288 SectionEnd ; end of GTK+ section
290 ;--------------------------------
291 ;Pidgin Install Section
293 Section $(PIDGINSECTIONTITLE) SecPidgin
294 SectionIn 1 RO
296 ; Check install rights..
297 Call CheckUserInstallRights
298 Pop $R0
300 StrCmp $R0 "NONE" pidgin_install_files
301 StrCmp $R0 "HKLM" pidgin_hklm pidgin_hkcu
303 pidgin_hklm:
304 WriteRegStr HKLM "${HKLM_APP_PATHS_KEY}" "" "$INSTDIR\pidgin.exe"
305 WriteRegStr HKLM "${HKLM_APP_PATHS_KEY}" "Path" "$INSTDIR\Gtk\bin"
306 WriteRegStr HKLM ${PIDGIN_REG_KEY} "" "$INSTDIR"
307 WriteRegStr HKLM ${PIDGIN_REG_KEY} "Version" "${PIDGIN_VERSION}"
308 WriteRegStr HKLM "${PIDGIN_UNINSTALL_KEY}" "DisplayIcon" "$INSTDIR\pidgin.exe"
309 WriteRegStr HKLM "${PIDGIN_UNINSTALL_KEY}" "DisplayName" "Pidgin"
310 WriteRegStr HKLM "${PIDGIN_UNINSTALL_KEY}" "DisplayVersion" "${PIDGIN_VERSION}"
311 WriteRegStr HKLM "${PIDGIN_UNINSTALL_KEY}" "HelpLink" "https://developer.pidgin.im/wiki/Using Pidgin"
312 WriteRegDWORD HKLM "${PIDGIN_UNINSTALL_KEY}" "NoModify" 1
313 WriteRegDWORD HKLM "${PIDGIN_UNINSTALL_KEY}" "NoRepair" 1
314 WriteRegStr HKLM "${PIDGIN_UNINSTALL_KEY}" "UninstallString" "$INSTDIR\${PIDGIN_UNINST_EXE}"
315 ; Sets scope of the desktop and Start Menu entries for all users.
316 SetShellVarContext "all"
317 Goto pidgin_install_files
319 pidgin_hkcu:
320 WriteRegStr HKCU ${PIDGIN_REG_KEY} "" "$INSTDIR"
321 WriteRegStr HKCU ${PIDGIN_REG_KEY} "Version" "${PIDGIN_VERSION}"
322 WriteRegStr HKCU "${PIDGIN_UNINSTALL_KEY}" "DisplayIcon" "$INSTDIR\pidgin.exe"
323 WriteRegStr HKCU "${PIDGIN_UNINSTALL_KEY}" "DisplayName" "Pidgin"
324 WriteRegStr HKCU "${PIDGIN_UNINSTALL_KEY}" "DisplayVersion" "${PIDGIN_VERSION}"
325 WriteRegStr HKCU "${PIDGIN_UNINSTALL_KEY}" "HelpLink" "https://developer.pidgin.im/wiki/Using Pidgin"
326 WriteRegDWORD HKCU "${PIDGIN_UNINSTALL_KEY}" "NoModify" 1
327 WriteRegDWORD HKCU "${PIDGIN_UNINSTALL_KEY}" "NoRepair" 1
328 WriteRegStr HKCU "${PIDGIN_UNINSTALL_KEY}" "UninstallString" "$INSTDIR\${PIDGIN_UNINST_EXE}"
329 Goto pidgin_install_files
331 pidgin_install_files:
332 SetOutPath "$INSTDIR"
333 ; Pidgin files
334 SetOverwrite on
336 File /r /x locale /x Gtk ..\..\..\${PIDGIN_INSTALL_DIR}\*.*
338 SetOutPath "$INSTDIR"
340 ; If we don't have install rights we're done
341 StrCmp $R0 "NONE" done
342 SetOverwrite off
344 ; write out uninstaller
345 SetOverwrite on
346 WriteUninstaller "$INSTDIR\${PIDGIN_UNINST_EXE}"
347 SetOverwrite off
349 ; If we previously had pidgin set up to run on startup, make it do so again
350 StrCmp $STARTUP_RUN_KEY "HKCU" +1 +2
351 WriteRegStr HKCU "${STARTUP_RUN_KEY}" "Pidgin" "$INSTDIR\pidgin.exe"
352 StrCmp $STARTUP_RUN_KEY "HKLM" +1 +2
353 WriteRegStr HKLM "${STARTUP_RUN_KEY}" "Pidgin" "$INSTDIR\pidgin.exe"
355 done:
356 SectionEnd ; end of default Pidgin section
358 ;--------------------------------
359 ;Shortcuts
361 SectionGroup /e $(PIDGINSHORTCUTSSECTIONTITLE) SecShortcuts
362 Section /o $(PIDGINDESKTOPSHORTCUTSECTIONTITLE) SecDesktopShortcut
363 SetOverwrite on
364 CreateShortCut "$DESKTOP\Pidgin.lnk" "$INSTDIR\pidgin.exe"
365 SetOverwrite off
366 SectionEnd
367 Section $(PIDGINSTARTMENUSHORTCUTSECTIONTITLE) SecStartMenuShortcut
368 SetOverwrite on
369 CreateShortCut "$SMPROGRAMS\Pidgin.lnk" "$INSTDIR\pidgin.exe"
370 SetOverwrite off
371 SectionEnd
372 SectionGroupEnd
374 ;--------------------------------
375 ;URI Handling
377 !macro URI_SECTION proto
378 Section /o "${proto}:" SecURI_${proto}
379 Push "${proto}"
380 Call RegisterURIHandler
381 SectionEnd
382 !macroend
383 SectionGroup /e $(URIHANDLERSSECTIONTITLE) SecURIHandlers
384 !insertmacro URI_SECTION "aim"
385 !insertmacro URI_SECTION "msnim"
386 !insertmacro URI_SECTION "ymsgr"
387 !insertmacro URI_SECTION "xmpp"
388 SectionGroupEnd
390 ;--------------------------------
391 ;Translations
393 !macro LANG_SECTION lang
394 ${MementoUnselectedSection} "${lang}" SecLang_${lang}
395 SetOutPath "$INSTDIR\locale\${lang}\LC_MESSAGES"
396 File "..\..\..\${PIDGIN_INSTALL_DIR}\locale\${lang}\LC_MESSAGES\*.mo"
397 SetOutPath "$INSTDIR"
398 ${MementoSectionEnd}
399 !macroend
400 SectionGroup $(TRANSLATIONSSECTIONTITLE) SecTranslations
401 # pidgin-translations is generated based on the contents of the locale directory
402 !include "pidgin-translations.nsh"
403 SectionGroupEnd
404 ${MementoSectionDone}
406 ;--------------------------------
407 ;Spell Checking
409 !macro SPELLCHECK_SECTION lang lang_name lang_file
410 Section /o "${lang_name}" SecSpell_${lang}
411 Push ${lang_file}
412 Push ${lang}
413 Call InstallDict
414 SectionEnd
415 !macroend
416 SectionGroup $(PIDGINSPELLCHECKSECTIONTITLE) SecSpellCheck
417 !include "pidgin-spellcheck.nsh"
418 SectionGroupEnd
420 Section /o $(DEBUGSYMBOLSSECTIONTITLE) SecDebugSymbols
422 InitPluginsDir
423 StrCpy $R1 "$PLUGINSDIR\dbgsym.zip"
424 !ifdef OFFLINE_INSTALLER
426 SetOutPath $PLUGINSDIR
427 File /oname=dbgsym.zip "..\..\..\pidgin-${PIDGIN_VERSION}-dbgsym.zip"
429 !else
431 ; We need to download the debug symbols
432 retry:
433 StrCpy $R2 "${DOWNLOADER_URL}&dl_pkg=dbgsym"
434 DetailPrint "Downloading Debug Symbols... ($R2)"
435 NSISdl::download /TIMEOUT=10000 "$R2" "$R1"
436 Pop $R0
437 StrCmp $R0 "cancel" done
438 StrCmp $R0 "success" 0 prompt_retry
440 Push "${DEBUG_SYMBOLS_SHA1SUM}"
441 Push "$R1" ; Filename
442 Call CheckSHA1Sum
443 Pop $R0
445 StrCmp "$R0" "0" extract
446 prompt_retry:
447 MessageBox MB_RETRYCANCEL "$(PIDGINDEBUGSYMBOLSERROR)" /SD IDCANCEL IDRETRY retry IDCANCEL done
449 extract:
450 !endif
452 SetOutPath "$INSTDIR"
453 nsisunz::UnzipToLog $R1 "$INSTDIR"
454 Pop $R0
455 StrCmp $R0 "success" +2
456 DetailPrint "$R0" ;print error message to log
458 !ifndef OFFLINE_INSTALLER
459 done:
460 !endif
461 SectionEnd
463 ;--------------------------------
464 ;Uninstaller Section
467 Section Uninstall
468 Call un.CheckUserInstallRights
469 Pop $R0
470 StrCmp $R0 "NONE" no_rights
471 StrCmp $R0 "HKCU" try_hkcu try_hklm
473 try_hkcu:
474 ReadRegStr $R0 HKCU ${PIDGIN_REG_KEY} ""
475 StrCmp $R0 $INSTDIR 0 cant_uninstall
476 ; HKCU install path matches our INSTDIR so uninstall
477 DeleteRegKey HKCU ${PIDGIN_REG_KEY}
478 DeleteRegKey HKCU "${PIDGIN_UNINSTALL_KEY}"
479 Goto cont_uninstall
481 try_hklm:
482 ReadRegStr $R0 HKLM ${PIDGIN_REG_KEY} ""
483 StrCmp $R0 $INSTDIR 0 try_hkcu
484 ; HKLM install path matches our INSTDIR so uninstall
485 DeleteRegKey HKLM ${PIDGIN_REG_KEY}
486 DeleteRegKey HKLM "${PIDGIN_UNINSTALL_KEY}"
487 DeleteRegKey HKLM "${HKLM_APP_PATHS_KEY}"
488 ; Sets start menu and desktop scope to all users..
489 SetShellVarContext "all"
491 cont_uninstall:
492 ; The WinPrefs plugin may have left this behind..
493 DeleteRegValue HKCU "${STARTUP_RUN_KEY}" "Pidgin"
494 DeleteRegValue HKLM "${STARTUP_RUN_KEY}" "Pidgin"
495 ; Remove Language preference info
496 DeleteRegValue HKCU "${PIDGIN_REG_KEY}" "${MUI_LANGDLL_REGISTRY_VALUENAME}"
498 ; Remove any URI handlers
499 ; I can't think of an easy way to maintain a list in a single place
500 Push "aim"
501 Call un.UnregisterURIHandler
502 Push "msnim"
503 Call un.UnregisterURIHandler
504 Push "ymsgr"
505 Call un.UnregisterURIHandler
506 Push "xmpp"
507 Call un.UnregisterURIHandler
509 ; Some of these aren't shipped anymore. Delete them anyway.
510 Delete "$INSTDIR\ca-certs\AddTrust_External_Root.pem"
511 Delete "$INSTDIR\ca-certs\America_Online_Root_Certification_Authority_1.pem"
512 Delete "$INSTDIR\ca-certs\AOL_Member_CA.pem"
513 Delete "$INSTDIR\ca-certs\Baltimore_CyberTrust_Root.pem"
514 Delete "$INSTDIR\ca-certs\CAcert_Class3.pem"
515 Delete "$INSTDIR\ca-certs\CAcert_Root.pem"
516 Delete "$INSTDIR\ca-certs\Deutsche_Telekom_Root_CA_2.pem"
517 Delete "$INSTDIR\ca-certs\DigiCertHighAssuranceCA-3.pem"
518 Delete "$INSTDIR\ca-certs\DigiCertHighAssuranceEVRootCA.pem"
519 Delete "$INSTDIR\ca-certs\Entrust.net_Secure_Server_CA.pem"
520 Delete "$INSTDIR\ca-certs\Equifax_Secure_CA.pem"
521 Delete "$INSTDIR\ca-certs\Equifax_Secure_Global_eBusiness_CA-1.pem"
522 Delete "$INSTDIR\ca-certs\Go_Daddy_Class_2_CA.pem"
523 Delete "$INSTDIR\ca-certs\GTE_CyberTrust_Global_Root.pem"
524 Delete "$INSTDIR\ca-certs\Microsoft_Internet_Authority.pem"
525 Delete "$INSTDIR\ca-certs\Microsoft_Internet_Authority_2010.pem"
526 Delete "$INSTDIR\ca-certs\Microsoft_Secure_Server_Authority.pem"
527 Delete "$INSTDIR\ca-certs\Microsoft_Secure_Server_Authority_2010.pem"
528 Delete "$INSTDIR\ca-certs\StartCom_Certification_Authority.pem"
529 Delete "$INSTDIR\ca-certs\StartCom_Free_SSL_CA.pem"
530 Delete "$INSTDIR\ca-certs\Thawte_Premium_Server_CA.pem"
531 Delete "$INSTDIR\ca-certs\Thawte_Primary_Root_CA.pem"
532 Delete "$INSTDIR\ca-certs\ValiCert_Class_2_VA.pem"
533 Delete "$INSTDIR\ca-certs\VeriSign_Class3_Extended_Validation_CA.pem"
534 Delete "$INSTDIR\ca-certs\Verisign_Class3_Primary_CA.pem"
535 Delete "$INSTDIR\ca-certs\VeriSign_Class_3_Primary_CA-G2.pem"
536 Delete "$INSTDIR\ca-certs\VeriSign_Class_3_Primary_CA-G5.pem"
537 Delete "$INSTDIR\ca-certs\VeriSign_Class_3_Primary_CA-G5-2.pem"
538 Delete "$INSTDIR\ca-certs\VeriSign_International_Server_Class_3_CA.pem"
539 Delete "$INSTDIR\ca-certs\Verisign_RSA_Secure_Server_CA.pem"
540 Delete "$INSTDIR\ca-certs\mozilla.pem"
541 RMDir "$INSTDIR\ca-certs"
542 RMDir /r "$INSTDIR\locale"
543 RMDir /r "$INSTDIR\pixmaps"
544 RMDir /r "$INSTDIR\theme"
545 Delete "$INSTDIR\plugins\autoaccept.dll"
546 Delete "$INSTDIR\plugins\buddynote.dll"
547 Delete "$INSTDIR\plugins\convcolors.dll"
548 Delete "$INSTDIR\plugins\extplacement.dll"
549 Delete "$INSTDIR\plugins\gtkbuddynote.dll"
550 Delete "$INSTDIR\plugins\history.dll"
551 Delete "$INSTDIR\plugins\internalkeyring.dll"
552 Delete "$INSTDIR\plugins\ssl-gnutls.dll"
553 Delete "$INSTDIR\plugins\webkit.dll"
554 Delete "$INSTDIR\plugins\wincred.dll"
555 Delete "$INSTDIR\plugins\iconaway.dll"
556 Delete "$INSTDIR\plugins\idle.dll"
557 Delete "$INSTDIR\plugins\joinpart.dll"
558 Delete "$INSTDIR\plugins\libbonjour.dll"
559 Delete "$INSTDIR\plugins\libgg.dll"
560 Delete "$INSTDIR\plugins\libirc.dll"
561 Delete "$INSTDIR\plugins\libjabber.dll"
562 Delete "$INSTDIR\plugins\libmsn.dll"
563 Delete "$INSTDIR\plugins\libmxit.dll"
564 Delete "$INSTDIR\plugins\libnovell.dll"
565 Delete "$INSTDIR\plugins\liboscar.dll"
566 Delete "$INSTDIR\plugins\libsametime.dll"
567 Delete "$INSTDIR\plugins\libsilc.dll"
568 Delete "$INSTDIR\plugins\libsimple.dll"
569 Delete "$INSTDIR\plugins\libyahoo.dll"
570 Delete "$INSTDIR\plugins\log_reader.dll"
571 Delete "$INSTDIR\plugins\markerline.dll"
572 Delete "$INSTDIR\plugins\newline.dll"
573 Delete "$INSTDIR\plugins\notify.dll"
574 Delete "$INSTDIR\plugins\nss-prefs.dll"
575 Delete "$INSTDIR\plugins\offlinemsg.dll"
576 Delete "$INSTDIR\plugins\perl.dll"
577 Delete "$INSTDIR\plugins\pidginrc.dll"
578 Delete "$INSTDIR\plugins\psychic.dll"
579 Delete "$INSTDIR\plugins\relnot.dll"
580 Delete "$INSTDIR\plugins\sendbutton.dll"
581 Delete "$INSTDIR\plugins\spellchk.dll"
582 Delete "$INSTDIR\plugins\ssl-nss.dll"
583 Delete "$INSTDIR\plugins\ssl.dll"
584 Delete "$INSTDIR\plugins\statenotify.dll"
585 Delete "$INSTDIR\plugins\ticker.dll"
586 Delete "$INSTDIR\plugins\timestamp.dll"
587 Delete "$INSTDIR\plugins\timestamp_format.dll"
588 Delete "$INSTDIR\plugins\win2ktrans.dll"
589 Delete "$INSTDIR\plugins\winprefs.dll"
590 Delete "$INSTDIR\plugins\xmppconsole.dll"
591 Delete "$INSTDIR\plugins\xmppdisco.dll"
592 Delete "$INSTDIR\plugins\perl\auto\Pidgin\Pidgin.dll"
593 RMDir "$INSTDIR\plugins\perl\auto\Pidgin"
594 Delete "$INSTDIR\plugins\perl\auto\Purple\autosplit.ix"
595 Delete "$INSTDIR\plugins\perl\auto\Purple\Purple.dll"
596 RMDir "$INSTDIR\plugins\perl\auto\Purple"
597 RMDir "$INSTDIR\plugins\perl\auto"
598 Delete "$INSTDIR\plugins\perl\Pidgin.pm"
599 Delete "$INSTDIR\plugins\perl\Purple.pm"
600 RMDir "$INSTDIR\plugins\perl"
601 RMDir "$INSTDIR\plugins"
602 Delete "$INSTDIR\sasl2\libanonymous-3.dll"
603 Delete "$INSTDIR\sasl2\libcrammd5-3.dll"
604 Delete "$INSTDIR\sasl2\libdigestmd5-3.dll"
605 Delete "$INSTDIR\sasl2\libplain-3.dll"
606 RMDir "$INSTDIR\sasl2"
607 Delete "$INSTDIR\sounds\purple\alert.wav"
608 Delete "$INSTDIR\sounds\purple\login.wav"
609 Delete "$INSTDIR\sounds\purple\logout.wav"
610 Delete "$INSTDIR\sounds\purple\receive.wav"
611 Delete "$INSTDIR\sounds\purple\send.wav"
612 RMDir "$INSTDIR\sounds\purple"
613 RMDir "$INSTDIR\sounds"
614 Delete "$INSTDIR\spellcheck\libenchant.dll"
615 Delete "$INSTDIR\spellcheck\lib\enchant\libenchant_aspell.dll"
616 Delete "$INSTDIR\spellcheck\lib\enchant\libenchant_ispell.dll"
617 Delete "$INSTDIR\spellcheck\lib\enchant\libenchant_myspell.dll"
618 RMDir "$INSTDIR\spellcheck\lib\enchant"
619 RMDir "$INSTDIR\spellcheck\lib"
620 RMDir "$INSTDIR\spellcheck"
621 Delete "$INSTDIR\freebl3.dll"
622 Delete "$INSTDIR\libnspr4.dll"
623 Delete "$INSTDIR\libmeanwhile-1.dll"
624 Delete "$INSTDIR\libplc4.dll"
625 Delete "$INSTDIR\libplds4.dll"
626 Delete "$INSTDIR\libpurple.dll"
627 Delete "$INSTDIR\libsasl2-3.dll"
628 Delete "$INSTDIR\libsilc-1-1-4.dll"
629 Delete "$INSTDIR\libsilcclient-1-1-4.dll"
630 Delete "$INSTDIR\libssp-0.dll"
631 Delete "$INSTDIR\libxml2-2.dll"
632 Delete "$INSTDIR\nss3.dll"
633 Delete "$INSTDIR\nssutil3.dll"
634 Delete "$INSTDIR\pidgin.dll"
635 Delete "$INSTDIR\pidgin.exe"
636 Delete "$INSTDIR\smime3.dll"
637 Delete "$INSTDIR\softokn3.dll"
638 Delete "$INSTDIR\sqlite3.dll"
639 Delete "$INSTDIR\ssl3.dll"
640 Delete "$INSTDIR\${PIDGIN_UNINST_EXE}"
641 Delete "$INSTDIR\exchndl.dll"
642 Delete "$INSTDIR\install.log"
644 ; Remove the debug symbols
645 RMDir /r "$INSTDIR\pidgin-${PIDGIN_VERSION}-dbgsym"
647 ; Remove the local GTK+ copy (if we're not just upgrading)
648 ${GetParameters} $R0
649 ClearErrors
650 ${GetOptions} "$R0" "/UPGRADE=" $R1
651 IfErrors +2
652 StrCmp $R1 "1" upgrade_done
653 RMDir /r "$INSTDIR\Gtk"
654 ; Remove the downloaded spellcheck dictionaries (if we're not just upgrading)
655 RMDir /r "$INSTDIR\spellcheck"
656 upgrade_done:
658 ;Try to remove Pidgin install dir (only if empty)
659 RMDir "$INSTDIR"
661 ; Shortcuts..
662 Delete "$DESKTOP\Pidgin.lnk"
663 Delete "$SMPROGRAMS\Pidgin.lnk"
665 Goto done
667 cant_uninstall:
668 MessageBox MB_OK $(PIDGINUNINSTALLERROR1) /SD IDOK
669 Quit
671 no_rights:
672 MessageBox MB_OK $(PIDGINUNINSTALLERROR2) /SD IDOK
673 Quit
675 done:
676 SectionEnd ; end of uninstall section
678 ;--------------------------------
679 ;Descriptions
680 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
681 !insertmacro MUI_DESCRIPTION_TEXT ${SecPidgin} \
682 $(PIDGINSECTIONDESCRIPTION)
683 !insertmacro MUI_DESCRIPTION_TEXT ${SecGtk} \
684 $(GTKSECTIONDESCRIPTION)
686 !insertmacro MUI_DESCRIPTION_TEXT ${SecShortcuts} \
687 $(PIDGINSHORTCUTSSECTIONDESCRIPTION)
688 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktopShortcut} \
689 $(PIDGINDESKTOPSHORTCUTDESC)
690 !insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenuShortcut} \
691 $(PIDGINSTARTMENUSHORTCUTDESC)
693 !insertmacro MUI_DESCRIPTION_TEXT ${SecSpellCheck} \
694 $(PIDGINSPELLCHECKSECTIONDESCRIPTION)
696 !insertmacro MUI_FUNCTION_DESCRIPTION_END
698 ;--------------------------------
699 ;Functions
701 ; Default the URI handler checkboxes if Pidgin is the current handler or if there is no handler
702 Function SelectURIHandlerSelections
703 Push $R0
704 Push $R1
705 Push $R2
706 Push $R3
708 ; Start with the first URI handler
709 IntOp $R0 ${SecURIHandlers} + 1
711 start:
712 ; If it is the end of the section group, stop
713 SectionGetFlags $R0 $R1
714 IntOp $R2 $R1 & ${SF_SECGRPEND}
715 IntCmp $R2 ${SF_SECGRPEND} done
717 SectionGetText $R0 $R2
718 ;Strip the trailing ':'
719 StrLen $R3 $R2
720 IntOp $R3 $R3 - 1
721 StrCpy $R2 $R2 $R3
723 ClearErrors
724 ReadRegStr $R3 HKCR "$R2" ""
725 IfErrors default_on ;there is no current handler
727 Push $R2
728 Call CheckIfPidginIsCurrentURIHandler
729 Pop $R3
731 ; If Pidgin isn't the current handler, we don't steal it automatically
732 IntCmp $R3 0 end_loop
734 ;We default the URI handler checkbox on
735 default_on:
736 IntOp $R1 $R1 | ${SF_SELECTED} ; Select
737 SectionSetFlags $R0 $R1
739 end_loop:
740 IntOp $R0 $R0 + 1 ;Advance to the next section
741 Goto start
743 done:
744 Pop $R3
745 Pop $R2
746 Pop $R1
747 Pop $R0
748 FunctionEnd ;SelectURIHandlerSections
750 ; Check if Pidgin is the current handler
751 ; Returns a boolean on the stack
752 !macro CheckIfPidginIsCurrentURIHandlerMacro UN
753 Function ${UN}CheckIfPidginIsCurrentURIHandler
754 Exch $R0
755 ClearErrors
757 ReadRegStr $R0 HKCR "$R0\shell\Open\command" ""
758 IfErrors 0 +3
759 IntOp $R0 0 + 0
760 Goto done
762 !ifdef __UNINSTALL__
763 ${un.WordFind} "$R0" "pidgin.exe" "E+1{" $R0
764 !else
765 ${WordFind} "$R0" "pidgin.exe" "E+1{" $R0
766 !endif
767 IntOp $R0 0 + 1
768 IfErrors 0 +2
769 IntOp $R0 0 + 0
771 done:
772 Exch $R0
773 FunctionEnd
774 !macroend
775 !insertmacro CheckIfPidginIsCurrentURIHandlerMacro ""
776 !insertmacro CheckIfPidginIsCurrentURIHandlerMacro "un."
778 ; If Pidgin is the current URI handler for the specified protocol, remove it.
779 Function un.UnregisterURIHandler
780 Exch $R0
781 Push $R1
783 Push $R0
784 Call un.CheckIfPidginIsCurrentURIHandler
785 Pop $R1
787 ; If Pidgin isn't the current handler, leave it as-is
788 IntCmp $R1 0 done
790 ;Unregister the URI handler
791 DetailPrint "Unregistering $R0 URI Handler"
792 DeleteRegKey HKCR "$R0"
794 done:
795 Pop $R1
796 Pop $R0
797 FunctionEnd
799 Function RegisterURIHandler
800 Exch $R0
801 DetailPrint "Registering $R0 URI Handler"
802 DeleteRegKey HKCR "$R0"
803 WriteRegStr HKCR "$R0" "" "URL:$R0"
804 WriteRegStr HKCR "$R0" "URL Protocol" ""
805 WriteRegStr HKCR "$R0\DefaultIcon" "" "$INSTDIR\pidgin.exe"
806 WriteRegStr HKCR "$R0\shell" "" ""
807 WriteRegStr HKCR "$R0\shell\Open" "" ""
808 WriteRegStr HKCR "$R0\shell\Open\command" "" "$INSTDIR\pidgin.exe --protocolhandler=%1"
809 Pop $R0
810 FunctionEnd
813 !macro CheckUserInstallRightsMacro UN
814 Function ${UN}CheckUserInstallRights
815 Push $0
816 Push $1
817 ClearErrors
818 UserInfo::GetName
819 IfErrors Win9x
820 Pop $0
821 UserInfo::GetAccountType
822 Pop $1
824 StrCmp $1 "Admin" 0 +3
825 StrCpy $1 "HKLM"
826 Goto done
827 StrCmp $1 "Power" 0 +3
828 StrCpy $1 "HKLM"
829 Goto done
830 StrCmp $1 "User" 0 +3
831 StrCpy $1 "HKCU"
832 Goto done
833 StrCmp $1 "Guest" 0 +3
834 StrCpy $1 "NONE"
835 Goto done
836 ; Unknown error
837 StrCpy $1 "NONE"
838 Goto done
840 Win9x:
841 StrCpy $1 "HKLM"
843 done:
844 Exch $1
845 Exch
846 Pop $0
847 FunctionEnd
848 !macroend
849 !insertmacro CheckUserInstallRightsMacro ""
850 !insertmacro CheckUserInstallRightsMacro "un."
853 ; Usage:
854 ; Push $0 ; Path string
855 ; Call VerifyDir
856 ; Pop $0 ; 0 - Bad path 1 - Good path
858 Function VerifyDir
859 Exch $0
860 Push $1
861 Push $2
862 Loop:
863 IfFileExists $0 dir_exists
864 StrCpy $1 $0 ; save last
865 ${GetParent} $0 $0
866 StrLen $2 $0
867 ; IfFileExists "C:" on xp returns true and on win2k returns false
868 ; So we're done in such a case..
869 IntCmp $2 2 loop_done
870 ; GetParent of "C:" returns ""
871 IntCmp $2 0 loop_done
872 Goto Loop
874 loop_done:
875 StrCpy $1 "$0\GaImFooB"
876 ; Check if we can create dir on this drive..
877 ClearErrors
878 CreateDirectory $1
879 IfErrors DirBad DirGood
881 dir_exists:
882 ClearErrors
883 FileOpen $1 "$0\pidginfoo.bar" w
884 IfErrors PathBad PathGood
886 DirGood:
887 RMDir $1
888 Goto PathGood1
890 DirBad:
891 RMDir $1
892 Goto PathBad1
894 PathBad:
895 FileClose $1
896 Delete "$0\pidginfoo.bar"
897 PathBad1:
898 StrCpy $0 "0"
899 Push $0
900 Goto done
902 PathGood:
903 FileClose $1
904 Delete "$0\pidginfoo.bar"
905 PathGood1:
906 StrCpy $0 "1"
907 Push $0
909 done:
910 Exch 3 ; The top of the stack contains the output variable
911 Pop $0
912 Pop $2
913 Pop $1
914 FunctionEnd
916 Function .onVerifyInstDir
917 Push $0
918 Push $INSTDIR
919 Call VerifyDir
920 Pop $0
921 StrCmp $0 "0" 0 dir_good
922 Pop $0
923 Abort
925 dir_good:
926 Pop $0
927 FunctionEnd
930 ; Usage:
931 ; Call DoWeNeedGtk
932 ; First Pop:
933 ; 0 - We have the correct version
934 ; 1 - We have an old version that should work, prompt user for optional upgrade
935 ; 2 - We have an old version that needs to be upgraded
936 ; 3 - We don't have Gtk+ at all
938 Function DoWeNeedGtk
939 Push $0
940 Push $1
942 IfFileExists "$INSTDIR\Gtk\CONTENTS" +3
943 Push "3"
944 Goto done
946 ClearErrors
947 ${ConfigRead} "$INSTDIR\Gtk\CONTENTS" "Bundle Version " $0
948 IfErrors 0 +3
949 Push "3"
950 Goto done
952 ${VersionCompare} ${GTK_INSTALL_VERSION} $0 $1
953 IntCmp $1 1 +3
954 Push "0" ; Have a good version
955 Goto done
957 ${VersionCompare} ${GTK_MIN_VERSION} $0 $1
958 IntCmp $1 1 +3
959 Push "1" ; Optional Upgrade
960 Goto done
961 Push "2" ; Mandatory Upgrade
962 Goto done
964 done:
965 ; The item on the stack is what we want to return
966 Exch
967 Pop $1
968 Exch
969 Pop $0
970 FunctionEnd
973 !macro RunCheckMacro UN
974 Function ${UN}RunCheck
975 Push $R0
976 Push $R1
978 IntOp $R1 0 + 0
979 retry_runcheck:
980 ; Close the Handle (needed if we're retrying)
981 IntCmp $R1 0 +2
982 System::Call 'kernel32::CloseHandle(i $R1) i .R1'
983 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "pidgin_is_running") i .R1 ?e'
984 Pop $R0
985 IntCmp $R0 0 +3 ;This could check for ERROR_ALREADY_EXISTS(183), but lets just assume
986 MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION $(PIDGINISRUNNING) /SD IDCANCEL IDRETRY retry_runcheck
987 Abort
989 ; Close the Handle (If we don't do this, the uninstaller called from within will fail)
990 ; This is not optimal because there is a (small) window of time when a new process could start
991 System::Call 'kernel32::CloseHandle(i $R1) i .R1'
993 Pop $R1
994 Pop $R0
995 FunctionEnd
996 !macroend
997 !insertmacro RunCheckMacro ""
998 !insertmacro RunCheckMacro "un."
1000 Function .onInit
1001 Push $R0
1002 Push $R1
1003 Push $R2
1004 Push $R3 ; This is only used for the Parameters throughout the function
1006 ${GetParameters} $R3
1008 IntOp $R1 0 + 0
1009 retry_runcheck:
1010 ; Close the Handle (needed if we're retrying)
1011 IntCmp $R1 0 +2
1012 System::Call 'kernel32::CloseHandle(i $R1) i .R1'
1013 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "pidgin_installer_running") i .R1 ?e'
1014 Pop $R0
1015 IntCmp $R0 0 +3 ;This could check for ERROR_ALREADY_EXISTS(183), but lets just assume
1016 MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION $(INSTALLERISRUNNING) /SD IDCANCEL IDRETRY retry_runcheck
1017 Abort
1019 ; Allow installer to run even if pidgin is running via "/NOPIDGINRUNCHECK=1"
1020 ; This is useful for testing
1021 ClearErrors
1022 ${GetOptions} "$R3" "/NOPIDGINRUNCHECK=" $R1
1023 IfErrors 0 +2
1024 Call RunCheck
1026 StrCpy $name "Pidgin ${PIDGIN_VERSION}"
1028 ;Try to copy the old Gaim installer Lang Reg. key
1029 ;(remove it after we're done to prevent this being done more than once)
1030 ClearErrors
1031 ReadRegStr $R0 HKCU "${PIDGIN_REG_KEY}" "${MUI_LANGDLL_REGISTRY_VALUENAME}"
1032 IfErrors 0 +5
1033 ClearErrors
1034 ReadRegStr $R0 HKCU "${OLD_GAIM_REG_KEY}" "${MUI_LANGDLL_REGISTRY_VALUENAME}"
1035 IfErrors +3
1036 DeleteRegValue HKCU "${OLD_GAIM_REG_KEY}" "${MUI_LANGDLL_REGISTRY_VALUENAME}"
1037 WriteRegStr HKCU "${PIDGIN_REG_KEY}" "${MUI_LANGDLL_REGISTRY_VALUENAME}" "$R0"
1039 ${MementoSectionRestore}
1041 ;Preselect the URI handlers as appropriate
1042 Call SelectURIHandlerSelections
1044 ;Preselect the "shortcuts" checkboxes according to the previous installation
1045 ClearErrors
1046 ;Make sure that there was a previous installation
1047 ReadRegStr $R0 HKCU "${PIDGIN_REG_KEY}" "${MUI_LANGDLL_REGISTRY_VALUENAME}"
1048 IfErrors done_preselecting_shortcuts
1049 ;Does the Desktop shortcut exist?
1050 GetFileTime "$DESKTOP\Pidgin.lnk" $R0 $R0
1051 IfErrors +1 +5
1052 ClearErrors
1053 SetShellVarContext "all"
1054 GetFileTime "$DESKTOP\Pidgin.lnk" $R0 $R0
1055 IfErrors preselect_startmenu_shortcut ;Desktop Shortcut if off by default
1056 !insertmacro SelectSection ${SecDesktopShortcut}
1057 preselect_startmenu_shortcut:
1058 ;Reset ShellVarContext because we may have changed it
1059 SetShellVarContext "current"
1060 ClearErrors
1061 ;Does the StartMenu shortcut exist?
1062 GetFileTime "$SMPROGRAMS\Pidgin.lnk" $R0 $R0
1063 IfErrors +1 done_preselecting_shortcuts ;StartMenu Shortcut is on by default
1064 ClearErrors
1065 SetShellVarContext "all"
1066 GetFileTime "$SMPROGRAMS\Pidgin.lnk" $R0 $R0
1067 IfErrors +1 done_preselecting_shortcuts ;StartMenu Shortcut is on by default
1068 !insertmacro UnselectSection ${SecStartMenuShortcut}
1069 done_preselecting_shortcuts:
1070 ;Reset ShellVarContext because we may have changed it
1071 SetShellVarContext "current"
1073 ClearErrors
1074 ${GetOptions} "$R3" "/L=" $R1
1075 IfErrors +3
1076 StrCpy $LANGUAGE $R1
1077 Goto skip_lang
1079 ; Select Language
1080 ; Display Language selection dialog
1081 !define MUI_LANGDLL_ALWAYSSHOW
1082 !insertmacro MUI_LANGDLL_DISPLAY
1083 skip_lang:
1085 ClearErrors
1086 ${GetOptions} "$R3" "/DS=" $R1
1087 IfErrors +8
1088 SectionGetFlags ${SecDesktopShortcut} $R2
1089 StrCmp "1" $R1 0 +2
1090 IntOp $R2 $R2 | ${SF_SELECTED}
1091 StrCmp "0" $R1 0 +3
1092 IntOp $R1 ${SF_SELECTED} ~
1093 IntOp $R2 $R2 & $R1
1094 SectionSetFlags ${SecDesktopShortcut} $R2
1096 ClearErrors
1097 ${GetOptions} "$R3" "/SMS=" $R1
1098 IfErrors +8
1099 SectionGetFlags ${SecStartMenuShortcut} $R2
1100 StrCmp "1" $R1 0 +2
1101 IntOp $R2 $R2 | ${SF_SELECTED}
1102 StrCmp "0" $R1 0 +3
1103 IntOp $R1 ${SF_SELECTED} ~
1104 IntOp $R2 $R2 & $R1
1105 SectionSetFlags ${SecStartMenuShortcut} $R2
1107 ; If install path was set on the command, use it.
1108 StrCmp $INSTDIR "" 0 instdir_done
1110 ; If pidgin or gaim is currently installed, we should default to where it is currently installed
1111 ClearErrors
1112 ReadRegStr $INSTDIR HKCU "${PIDGIN_REG_KEY}" ""
1113 IfErrors +2
1114 StrCmp $INSTDIR "" 0 instdir_done
1115 ClearErrors
1116 ReadRegStr $INSTDIR HKLM "${PIDGIN_REG_KEY}" ""
1117 IfErrors +2
1118 StrCmp $INSTDIR "" 0 instdir_done
1120 Call CheckUserInstallRights
1121 Pop $R0
1123 StrCmp $R0 "HKLM" 0 user_dir
1124 StrCpy $INSTDIR "$PROGRAMFILES\Pidgin"
1125 Goto instdir_done
1126 user_dir:
1127 Push $SMPROGRAMS
1128 ${GetParent} $SMPROGRAMS $R2
1129 ${GetParent} $R2 $R2
1130 StrCpy $INSTDIR "$R2\Pidgin"
1132 instdir_done:
1133 ;LogSet on
1135 ; Try to select a translation and a dictionary for the currently selected Language
1136 Call SelectTranslationForCurrentLanguage
1138 ;Mark the dictionaries that are already installed as readonly
1139 Call SelectAndDisableInstalledDictionaries
1141 Pop $R3
1142 Pop $R2
1143 Pop $R1
1144 Pop $R0
1145 FunctionEnd
1147 Function .onInstSuccess
1149 ${MementoSectionSave}
1151 FunctionEnd
1154 Function un.onInit
1156 Call un.RunCheck
1157 StrCpy $name "Pidgin ${PIDGIN_VERSION}"
1158 ;LogSet on
1160 ; Get stored language preference
1161 !insertmacro MUI_UNGETLANGUAGE
1163 FunctionEnd
1165 ; Page enter and exit functions..
1167 Function preWelcomePage
1168 Push $R0
1169 Push $R1
1171 !ifdef OFFLINE_INSTALLER
1172 !insertmacro SelectSection ${SecDebugSymbols}
1173 !endif
1175 Call DoWeNeedGtk
1176 Pop $CURRENT_GTK_STATE
1177 StrCpy $WARNED_GTK_STATE "0"
1178 IntCmp $CURRENT_GTK_STATE 1 done gtk_not_mandatory
1179 ; Make the GTK+ Section RO if it is required. (it is required only if you have an existing version that is too old)
1180 StrCmp $CURRENT_GTK_STATE "2" 0 done
1181 !insertmacro SetSectionFlag ${SecGtk} ${SF_RO}
1182 Goto done
1183 gtk_not_mandatory:
1184 ; Don't select the GTK+ section if we already have this version or newer installed
1185 !insertmacro UnselectSection ${SecGtk}
1187 done:
1188 Pop $R1
1189 Pop $R0
1190 FunctionEnd
1192 ; If the GTK+ Section has been unselected and there isn't a compatible GTK+ already, confirm
1193 Function .onSelChange
1194 Push $R0
1196 SectionGetFlags ${SecGtk} $R0
1197 IntOp $R0 $R0 & ${SF_SELECTED}
1198 ; If the Gtk Section is currently selected, reset the "Warned" flag
1199 StrCmp $R0 "${SF_SELECTED}" 0 +3
1200 StrCpy $WARNED_GTK_STATE "0"
1201 Goto done
1203 ; If we've already warned the user, don't warn them again
1204 StrCmp $WARNED_GTK_STATE "1" done
1205 IntCmp $CURRENT_GTK_STATE 1 done done 0
1206 StrCpy $WARNED_GTK_STATE "1"
1207 MessageBox MB_YESNO $(PIDGINPROMPTFORCENOGTK) /SD IDNO IDYES done
1208 !insertmacro SelectSection ${SecGtk}
1210 done:
1211 Pop $R0
1212 FunctionEnd
1214 Function SelectTranslationForCurrentLanguage
1215 !insertmacro SELECT_TRANSLATION_FUNCTION
1216 FunctionEnd
1218 ; SpellChecker Related Functions
1219 ;-------------------------------
1221 ; Select and Disable any Sections that have currently installed dictionaries
1222 !macro CHECK_SPELLCHECK_SECTION lang
1223 ;Advance to the next (correct) section index
1224 IntOp $R0 $R0 + 1
1225 IfFileExists "$INSTDIR\spellcheck\share\enchant\myspell\${lang}.dic" 0 done_${lang}
1226 SectionGetFlags $R0 $R1
1227 IntOp $R1 $R1 | ${SF_RO} ; Mark Readonly
1228 IntOp $R1 $R1 | ${SF_SELECTED} ; Select
1229 SectionSetFlags $R0 $R1
1230 done_${lang}:
1231 !macroend
1232 Function SelectAndDisableInstalledDictionaries
1233 Push $R0
1234 Push $R1
1236 !insertmacro SetSectionFlag ${SecSpellCheck} ${SF_RO}
1237 !insertmacro UnselectSection ${SecSpellCheck}
1239 IntOp $R0 ${SecSpellCheck} + 0
1240 !include "pidgin-spellcheck-preselect.nsh"
1242 Pop $R1
1243 Pop $R0
1244 FunctionEnd
1246 Function InstallDict
1247 Push $R0
1248 Exch
1249 Pop $R0 ;This is the language code
1250 Push $R1
1251 Exch 2
1252 Pop $R1 ;This is the language file
1253 Push $R2
1254 Push $R3
1255 Push $R4
1257 ClearErrors
1258 IfFileExists "$INSTDIR\spellcheck\share\enchant\myspell\$R0.dic" installed
1260 InitPluginsDir
1262 ; We need to download and install dictionary
1263 StrCpy $R2 "$PLUGINSDIR\$R1"
1264 StrCpy $R3 "${DOWNLOADER_URL}&dl_pkg=oo_dict&lang=$R1&lang_file=$R1"
1265 DetailPrint "Downloading the $R0 Dictionary... ($R3)"
1266 retry:
1267 NSISdl::download /TIMEOUT=10000 "$R3" "$R2"
1268 Pop $R4
1269 StrCmp $R4 "cancel" done
1270 StrCmp $R4 "success" +3
1271 MessageBox MB_RETRYCANCEL "$(PIDGINSPELLCHECKERROR)" /SD IDCANCEL IDRETRY retry IDCANCEL done
1272 Goto done
1273 SetOutPath "$INSTDIR\spellcheck\share\enchant\myspell"
1274 nsisunz::UnzipToLog "$R2" "$OUTDIR"
1275 SetOutPath "$INSTDIR"
1276 Pop $R3
1277 StrCmp $R3 "success" installed
1278 DetailPrint "$R3" ;print error message to log
1279 Goto done
1281 installed: ;The dictionary is currently installed, no error message
1282 DetailPrint "$R0 Dictionary is installed"
1284 done:
1285 Pop $R4
1286 Pop $R3
1287 Pop $R2
1288 Pop $R0
1289 Exch $R1
1290 FunctionEnd
1292 !ifndef OFFLINE_INSTALLER
1293 ; Input Stack: Filename, SHA1sum
1294 ; Output Return Code: 0=Match; 1=FileSum error; 2=Mismatch
1295 Function CheckSHA1Sum
1296 Push $R0
1297 Exch
1298 Pop $R0 ;Filename
1299 Push $R2
1300 Exch 2
1301 Pop $R2 ;SHA1sum
1302 Push $R1
1304 SHA1Plugin::FileSum "$R0"
1305 Pop $R1
1306 Pop $R0
1308 StrCmp "$R1" "0" +4
1309 DetailPrint "SHA1Sum calculation error: $R0"
1310 IntOp $R1 0 + 1
1311 Goto done
1313 ; Compare the SHA1Sums
1314 StrCmp $R2 $R0 +4
1315 DetailPrint "SHA1Sum mismatch... Expected $R2; got $R0"
1316 IntOp $R1 0 + 2
1317 Goto done
1319 IntOp $R1 0 + 0
1321 done:
1322 Exch $R1 ;$R1 has the return code
1323 Exch
1324 Pop $R2
1325 Exch
1326 Pop $R0
1327 FunctionEnd
1328 !endif