; Installer script for win32 Pidgin ; Original Author: Herman Bloggs <hermanator12002@yahoo.com> ; Updated By: Daniel Atallah <daniel_atallah@yahoo.com> ; NOTE: this .NSI script is intended for NSIS 2.27+ ;-------------------------------- ;-------------------------------- ;The name var is set in .onInit OutFile "pidgin-${PIDGIN_VERSION}-offline.exe" OutFile "pidgin-${PIDGIN_VERSION}.exe" SetCompressor /SOLID lzma RequestExecutionLevel highest ; $name and $INSTDIR are set in .onInit function.. !insertmacro GetParameters
!insertmacro VersionCompare
;-------------------------------- !define PIDGIN_NSIS_INCLUDE_PATH
"." ; Remove these and the stuff that uses them at some point !define OLD_GAIM_REG_KEY
"SOFTWARE\gaim" !define OLD_GAIM_UNINSTALL_KEY
"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Gaim" !define OLD_GAIM_UNINST_EXE
"gaim-uninst.exe" !define PIDGIN_REG_KEY
"SOFTWARE\pidgin" !define PIDGIN_UNINSTALL_KEY
"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Pidgin" !define HKLM_APP_PATHS_KEY
"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\pidgin.exe" !define STARTUP_RUN_KEY
"SOFTWARE\Microsoft\Windows\CurrentVersion\Run" !define PIDGIN_UNINST_EXE
"pidgin-uninst.exe" !define GTK_MIN_VERSION
"2.14.0" !define DOWNLOADER_URL
"https://pidgin.im/win32/download_redir.php?version=${PIDGIN_VERSION}" !define MEMENTO_REGISTRY_ROOT
HKLM !define MEMENTO_REGISTRY_KEY
"${PIDGIN_UNINSTALL_KEY}" ;-------------------------------- VIProductVersion "${PIDGIN_PRODUCT_VERSION}" VIAddVersionKey "ProductName" "Pidgin" VIAddVersionKey "FileVersion" "${PIDGIN_VERSION}" VIAddVersionKey "ProductVersion" "${PIDGIN_VERSION}" VIAddVersionKey "LegalCopyright" "" VIAddVersionKey "FileDescription" "Pidgin Installer (Offline)" VIAddVersionKey "FileDescription" "Pidgin Installer" ;-------------------------------- ;Reserve files used in .onInit ReserveFile "${NSISDIR}\Plugins\System.dll" ReserveFile "${NSISDIR}\Plugins\UserInfo.dll" !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
!insertmacro MUI_RESERVEFILE_LANGDLL
;-------------------------------- !define MUI_ICON
".\pixmaps\pidgin-install.ico" !define MUI_UNICON
".\pixmaps\pidgin-install.ico" !define MUI_WELCOMEFINISHPAGE_BITMAP
".\pixmaps\pidgin-intro.bmp" !define MUI_HEADERIMAGE_BITMAP
".\pixmaps\pidgin-header.bmp" !define MUI_LICENSEPAGE_BUTTON
$(PIDGINLICENSEBUTTON
) !define MUI_LICENSEPAGE_TEXT_BOTTOM
$(PIDGINLICENSEBOTTOMTEXT
) !define MUI_LANGDLL_REGISTRY_ROOT
"HKCU" !define MUI_LANGDLL_REGISTRY_KEY
${PIDGIN_REG_KEY} !define MUI_LANGDLL_REGISTRY_VALUENAME
"Installer Language" !define MUI_COMPONENTSPAGE_SMALLDESC
!define MUI_FINISHPAGE_NOAUTOCLOSE
;!define MUI_FINISHPAGE_RUN "$INSTDIR\pidgin.exe" ;!define MUI_FINISHPAGE_RUN_NOTCHECKED !define MUI_FINISHPAGE_LINK
$(PIDGINFINISHVISITWEBSITE
) !define MUI_FINISHPAGE_LINK_LOCATION
"https://pidgin.im" ;-------------------------------- !define MUI_PAGE_CUSTOMFUNCTION_PRE
preWelcomePage
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE
"../../../COPYING" !insertmacro MUI_PAGE_COMPONENTS
; Pidgin install dir page !insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
;-------------------------------- !include "${PIDGIN_NSIS_INCLUDE_PATH}\langmacros.nsh" ;-------------------------------- ;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Start Install Sections ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;-------------------------------- ;Uninstall any old version of Pidgin (or Gaim) Section -SecUninstallOldPidgin
Call CheckUserInstallRights
;First try to uninstall Pidgin StrCpy $R4 ${PIDGIN_REG_KEY} StrCpy $R5 ${PIDGIN_UNINSTALL_KEY} StrCpy $R6 ${PIDGIN_UNINST_EXE} ;If pidgin is currently set to run on startup, ; save the section of the Registry where the setting is before uninstalling, ; so we can put it back after installing the new version ReadRegStr $STARTUP_RUN_KEY HKCU "${STARTUP_RUN_KEY}" $R7 StrCpy $STARTUP_RUN_KEY "HKCU" ReadRegStr $STARTUP_RUN_KEY HKLM "${STARTUP_RUN_KEY}" $R7 StrCpy $STARTUP_RUN_KEY "HKLM" StrCmp $R0 "HKLM" compare_hklm
StrCmp $R0 "HKCU" compare_hkcu
done
ReadRegStr $R1 HKCU $R4 "" ReadRegStr $R2 HKCU $R4 "Version" ReadRegStr $R3 HKCU "$R5" "UninstallString" ReadRegStr $R1 HKLM $R4 "" ReadRegStr $R2 HKLM $R4 "Version" ReadRegStr $R3 HKLM "$R5" "UninstallString" ; If a previous version exists, remove it StrCmp $R1 "" no_version_found
; Version key started with 0.60a3. Prior versions can't be ; automatically uninstalled. StrCmp $R2 "" uninstall_problem
; Check if we have uninstall string.. IfFileExists $R3 0
uninstall_problem
; Have uninstall string, go ahead and uninstall. ; Need to copy uninstaller outside of the install dir CopyFiles /SILENT $R3 "$TEMP\$R6" IfErrors uninstall_problem
ExecWait '"$TEMP\$R6" /S /UPGRADE=1 _?=$R1' ;We've already tried to fallback to an old gaim instance ; If we couldn't uninstall Pidgin, try to uninstall Gaim StrCpy $STARTUP_RUN_KEY "NONE" StrCpy $R4 ${OLD_GAIM_REG_KEY} StrCpy $R5 ${OLD_GAIM_UNINSTALL_KEY} StrCpy $R6 ${OLD_GAIM_UNINST_EXE} ; We can't uninstall. Either the user must manually uninstall or we ignore and reinstall over it. MessageBox MB_OKCANCEL $(PIDGINPROMPTCONTINUEWITHOUTUNINSTALL
) /SD IDOK IDOK done
;-------------------------------- ;GTK+ Runtime Install Section Section $(GTKSECTIONTITLE
) SecGtk
StrCpy $R1 "$PLUGINSDIR\gtk.zip" File /oname=gtk.zip
".\gtk-runtime-${GTK_INSTALL_VERSION}.zip" ; We need to download the GTK+ runtime StrCpy $R2 "${DOWNLOADER_URL}>k_version=${GTK_INSTALL_VERSION}&dl_pkg=gtk" DetailPrint "Downloading GTK+ Runtime ... ($R2)" NSISdl::download /TIMEOUT=10000
"$R2" "$R1" ;StrCmp $R0 "cancel" done StrCmp $R0 "success" 0
prompt_retry
MessageBox MB_RETRYCANCEL "$(PIDGINGTKDOWNLOADERROR)" /SD IDCANCEL IDRETRY retry
IDCANCEL done
;Delete the old Gtk directory nsisunz::UnzipToLog $R1 "$INSTDIR" DetailPrint "$R0" ;print error message to log !ifndef OFFLINE_INSTALLER
SectionEnd ; end of GTK+ section ;-------------------------------- Section $(PIDGINSECTIONTITLE
) SecPidgin
Call CheckUserInstallRights
StrCmp $R0 "NONE" pidgin_install_files
StrCmp $R0 "HKLM" pidgin_hklm
pidgin_hkcu
WriteRegStr HKLM "${HKLM_APP_PATHS_KEY}" "" "$INSTDIR\pidgin.exe" WriteRegStr HKLM "${HKLM_APP_PATHS_KEY}" "Path" "$INSTDIR\Gtk\bin" WriteRegStr HKLM ${PIDGIN_REG_KEY} "" "$INSTDIR" WriteRegStr HKLM ${PIDGIN_REG_KEY} "Version" "${PIDGIN_VERSION}" WriteRegStr HKLM "${PIDGIN_UNINSTALL_KEY}" "DisplayIcon" "$INSTDIR\pidgin.exe" WriteRegStr HKLM "${PIDGIN_UNINSTALL_KEY}" "DisplayName" "Pidgin" WriteRegStr HKLM "${PIDGIN_UNINSTALL_KEY}" "DisplayVersion" "${PIDGIN_VERSION}" WriteRegStr HKLM "${PIDGIN_UNINSTALL_KEY}" "HelpLink" "https://developer.pidgin.im/wiki/Using Pidgin" WriteRegDWORD HKLM "${PIDGIN_UNINSTALL_KEY}" "NoModify" 1
WriteRegDWORD HKLM "${PIDGIN_UNINSTALL_KEY}" "NoRepair" 1
WriteRegStr HKLM "${PIDGIN_UNINSTALL_KEY}" "UninstallString" "$INSTDIR\${PIDGIN_UNINST_EXE}" ; Sets scope of the desktop and Start Menu entries for all users. Goto pidgin_install_files
WriteRegStr HKCU ${PIDGIN_REG_KEY} "" "$INSTDIR" WriteRegStr HKCU ${PIDGIN_REG_KEY} "Version" "${PIDGIN_VERSION}" WriteRegStr HKCU "${PIDGIN_UNINSTALL_KEY}" "DisplayIcon" "$INSTDIR\pidgin.exe" WriteRegStr HKCU "${PIDGIN_UNINSTALL_KEY}" "DisplayName" "Pidgin" WriteRegStr HKCU "${PIDGIN_UNINSTALL_KEY}" "DisplayVersion" "${PIDGIN_VERSION}" WriteRegStr HKCU "${PIDGIN_UNINSTALL_KEY}" "HelpLink" "https://developer.pidgin.im/wiki/Using Pidgin" WriteRegDWORD HKCU "${PIDGIN_UNINSTALL_KEY}" "NoModify" 1
WriteRegDWORD HKCU "${PIDGIN_UNINSTALL_KEY}" "NoRepair" 1
WriteRegStr HKCU "${PIDGIN_UNINSTALL_KEY}" "UninstallString" "$INSTDIR\${PIDGIN_UNINST_EXE}" Goto pidgin_install_files
;Delete old liboscar and libjabber since they tend to be problematic Delete "$INSTDIR\plugins\liboscar.dll" Delete "$INSTDIR\plugins\libjabber.dll" ;Delete misnamed nss-prefs plugin from 2.10.11 Delete "$INSTDIR\plugins\.dll" File /r /x locale
/x Gtk
..
\..
\..
\${PIDGIN_INSTALL_DIR}\*.
* ; If we don't have install rights we're done WriteUninstaller "$INSTDIR\${PIDGIN_UNINST_EXE}" ; If we previously had pidgin set up to run on startup, make it do so again StrCmp $STARTUP_RUN_KEY "HKCU" +1
+2
WriteRegStr HKCU "${STARTUP_RUN_KEY}" "Pidgin" "$INSTDIR\pidgin.exe" StrCmp $STARTUP_RUN_KEY "HKLM" +1
+2
WriteRegStr HKLM "${STARTUP_RUN_KEY}" "Pidgin" "$INSTDIR\pidgin.exe" SectionEnd ; end of default Pidgin section ;-------------------------------- SectionGroup /e $(PIDGINSHORTCUTSSECTIONTITLE
) SecShortcuts
Section /o $(PIDGINDESKTOPSHORTCUTSECTIONTITLE
) SecDesktopShortcut
CreateShortCut "$DESKTOP\Pidgin.lnk" "$INSTDIR\pidgin.exe" Section $(PIDGINSTARTMENUSHORTCUTSECTIONTITLE
) SecStartMenuShortcut
CreateShortCut "$SMPROGRAMS\Pidgin.lnk" "$INSTDIR\pidgin.exe" ;-------------------------------- Section /o "${proto}:" SecURI_
${proto} SectionGroup /e $(URIHANDLERSSECTIONTITLE
) SecURIHandlers
!insertmacro URI_SECTION
"aim" !insertmacro URI_SECTION
"xmpp" ;-------------------------------- ${MementoUnselectedSection} "${lang}" SecLang_
${lang} SetOutPath "$INSTDIR\locale\${lang}\LC_MESSAGES" File "..\..\..\${PIDGIN_INSTALL_DIR}\locale\${lang}\LC_MESSAGES\*.mo" SectionGroup $(TRANSLATIONSSECTIONTITLE
) SecTranslations
# pidgin-translations is generated based on the contents of the locale directory !include "pidgin-translations.nsh" ;-------------------------------- !macro SPELLCHECK_SECTION
lang
lang_name
lang_file
Section /o "${lang_name}" SecSpell_
${lang} SectionGroup $(PIDGINSPELLCHECKSECTIONTITLE
) SecSpellCheck
!include "pidgin-spellcheck.nsh" Section /o $(DEBUGSYMBOLSSECTIONTITLE
) SecDebugSymbols
StrCpy $R1 "$PLUGINSDIR\dbgsym.zip" File /oname=dbgsym.zip
"..\..\..\pidgin-${PIDGIN_VERSION}-dbgsym.zip" ; We need to download the debug symbols StrCpy $R2 "${DOWNLOADER_URL}&dl_pkg=dbgsym" DetailPrint "Downloading Debug Symbols... ($R2)" NSISdl::download /TIMEOUT=10000
"$R2" "$R1" StrCmp $R0 "success" 0
prompt_retry
Push "${DEBUG_SYMBOLS_SHA1SUM}" MessageBox MB_RETRYCANCEL "$(PIDGINDEBUGSYMBOLSERROR)" /SD IDCANCEL IDRETRY retry
IDCANCEL done
nsisunz::UnzipToLog $R1 "$INSTDIR" DetailPrint "$R0" ;print error message to log !ifndef OFFLINE_INSTALLER
;-------------------------------- Call un.CheckUserInstallRights
StrCmp $R0 "NONE" no_rights
StrCmp $R0 "HKCU" try_hkcu
try_hklm
ReadRegStr $R0 HKCU ${PIDGIN_REG_KEY} "" StrCmp $R0 $INSTDIR 0
cant_uninstall
; HKCU install path matches our INSTDIR so uninstall DeleteRegKey HKCU ${PIDGIN_REG_KEY} DeleteRegKey HKCU "${PIDGIN_UNINSTALL_KEY}" ReadRegStr $R0 HKLM ${PIDGIN_REG_KEY} "" StrCmp $R0 $INSTDIR 0
try_hkcu
; HKLM install path matches our INSTDIR so uninstall DeleteRegKey HKLM ${PIDGIN_REG_KEY} DeleteRegKey HKLM "${PIDGIN_UNINSTALL_KEY}" DeleteRegKey HKLM "${HKLM_APP_PATHS_KEY}" ; Sets start menu and desktop scope to all users.. ; The WinPrefs plugin may have left this behind.. DeleteRegValue HKCU "${STARTUP_RUN_KEY}" "Pidgin" DeleteRegValue HKLM "${STARTUP_RUN_KEY}" "Pidgin" ; Remove Language preference info DeleteRegValue HKCU "${PIDGIN_REG_KEY}" "${MUI_LANGDLL_REGISTRY_VALUENAME}" ; Remove any URI handlers ; I can't think of an easy way to maintain a list in a single place Call un.UnregisterURIHandler
Call un.UnregisterURIHandler
; Some of these aren't shipped anymore. Delete them anyway. Delete "$INSTDIR\ca-certs\AddTrust_External_Root.pem" Delete "$INSTDIR\ca-certs\America_Online_Root_Certification_Authority_1.pem" Delete "$INSTDIR\ca-certs\AOL_Member_CA.pem" Delete "$INSTDIR\ca-certs\Baltimore_CyberTrust_Root.pem" Delete "$INSTDIR\ca-certs\CAcert_Class3.pem" Delete "$INSTDIR\ca-certs\CAcert_Root.pem" Delete "$INSTDIR\ca-certs\Deutsche_Telekom_Root_CA_2.pem" Delete "$INSTDIR\ca-certs\DigiCertHighAssuranceCA-3.pem" Delete "$INSTDIR\ca-certs\DigiCertHighAssuranceEVRootCA.pem" Delete "$INSTDIR\ca-certs\Entrust.net_Secure_Server_CA.pem" Delete "$INSTDIR\ca-certs\Equifax_Secure_CA.pem" Delete "$INSTDIR\ca-certs\Equifax_Secure_Global_eBusiness_CA-1.pem" Delete "$INSTDIR\ca-certs\Go_Daddy_Class_2_CA.pem" Delete "$INSTDIR\ca-certs\GTE_CyberTrust_Global_Root.pem" Delete "$INSTDIR\ca-certs\Microsoft_Internet_Authority.pem" Delete "$INSTDIR\ca-certs\Microsoft_Internet_Authority_2010.pem" Delete "$INSTDIR\ca-certs\Microsoft_Secure_Server_Authority.pem" Delete "$INSTDIR\ca-certs\Microsoft_Secure_Server_Authority_2010.pem" Delete "$INSTDIR\ca-certs\StartCom_Certification_Authority.pem" Delete "$INSTDIR\ca-certs\StartCom_Free_SSL_CA.pem" Delete "$INSTDIR\ca-certs\Thawte_Premium_Server_CA.pem" Delete "$INSTDIR\ca-certs\Thawte_Primary_Root_CA.pem" Delete "$INSTDIR\ca-certs\ValiCert_Class_2_VA.pem" Delete "$INSTDIR\ca-certs\VeriSign_Class3_Extended_Validation_CA.pem" Delete "$INSTDIR\ca-certs\Verisign_Class3_Primary_CA.pem" Delete "$INSTDIR\ca-certs\VeriSign_Class_3_Primary_CA-G2.pem" Delete "$INSTDIR\ca-certs\VeriSign_Class_3_Primary_CA-G5.pem" Delete "$INSTDIR\ca-certs\VeriSign_Class_3_Primary_CA-G5-2.pem" Delete "$INSTDIR\ca-certs\VeriSign_International_Server_Class_3_CA.pem" Delete "$INSTDIR\ca-certs\Verisign_RSA_Secure_Server_CA.pem" Delete "$INSTDIR\ca-certs\mozilla.pem" RMDir "$INSTDIR\ca-certs" RMDir /r "$INSTDIR\locale" RMDir /r "$INSTDIR\pixmaps" Delete "$INSTDIR\plugins\autoaccept.dll" Delete "$INSTDIR\plugins\buddynote.dll" Delete "$INSTDIR\plugins\convcolors.dll" Delete "$INSTDIR\plugins\extplacement.dll" Delete "$INSTDIR\plugins\gtkbuddynote.dll" Delete "$INSTDIR\plugins\history.dll" Delete "$INSTDIR\plugins\iconaway.dll" Delete "$INSTDIR\plugins\idle.dll" Delete "$INSTDIR\plugins\joinpart.dll" Delete "$INSTDIR\plugins\libaim.dll" Delete "$INSTDIR\plugins\libbonjour.dll" Delete "$INSTDIR\plugins\libgg.dll" Delete "$INSTDIR\plugins\libicq.dll" Delete "$INSTDIR\plugins\libirc.dll" Delete "$INSTDIR\plugins\libnapster.dll" Delete "$INSTDIR\plugins\libnovell.dll" Delete "$INSTDIR\plugins\libsametime.dll" Delete "$INSTDIR\plugins\libsilc.dll" Delete "$INSTDIR\plugins\libsimple.dll" Delete "$INSTDIR\plugins\libtoc.dll" Delete "$INSTDIR\plugins\libxmpp.dll" Delete "$INSTDIR\plugins\log_reader.dll" Delete "$INSTDIR\plugins\markerline.dll" Delete "$INSTDIR\plugins\newline.dll" Delete "$INSTDIR\plugins\notify.dll" Delete "$INSTDIR\plugins\nss-prefs.dll" Delete "$INSTDIR\plugins\offlinemsg.dll" Delete "$INSTDIR\plugins\perl.dll" Delete "$INSTDIR\plugins\pidginrc.dll" Delete "$INSTDIR\plugins\psychic.dll" Delete "$INSTDIR\plugins\relnot.dll" Delete "$INSTDIR\plugins\sendbutton.dll" Delete "$INSTDIR\plugins\spellchk.dll" Delete "$INSTDIR\plugins\ssl-nss.dll" Delete "$INSTDIR\plugins\ssl.dll" Delete "$INSTDIR\plugins\statenotify.dll" Delete "$INSTDIR\plugins\themeedit.dll" Delete "$INSTDIR\plugins\ticker.dll" Delete "$INSTDIR\plugins\timestamp.dll" Delete "$INSTDIR\plugins\timestamp_format.dll" Delete "$INSTDIR\plugins\win2ktrans.dll" Delete "$INSTDIR\plugins\winprefs.dll" Delete "$INSTDIR\plugins\xmppconsole.dll" Delete "$INSTDIR\plugins\xmppdisco.dll" Delete "$INSTDIR\plugins\perl\auto\Pidgin\Pidgin.dll" RMDir "$INSTDIR\plugins\perl\auto\Pidgin" Delete "$INSTDIR\plugins\perl\auto\Purple\autosplit.ix" Delete "$INSTDIR\plugins\perl\auto\Purple\Purple.dll" RMDir "$INSTDIR\plugins\perl\auto\Purple" RMDir "$INSTDIR\plugins\perl\auto" Delete "$INSTDIR\plugins\perl\Pidgin.pm" Delete "$INSTDIR\plugins\perl\Purple.pm" RMDir "$INSTDIR\plugins\perl" Delete "$INSTDIR\sasl2\libanonymous-3.dll" Delete "$INSTDIR\sasl2\libcrammd5-3.dll" Delete "$INSTDIR\sasl2\libdigestmd5-3.dll" Delete "$INSTDIR\sasl2\libplain-3.dll" Delete "$INSTDIR\sounds\purple\alert.wav" Delete "$INSTDIR\sounds\purple\login.wav" Delete "$INSTDIR\sounds\purple\logout.wav" Delete "$INSTDIR\sounds\purple\receive.wav" Delete "$INSTDIR\sounds\purple\send.wav" RMDir "$INSTDIR\sounds\purple" Delete "$INSTDIR\spellcheck\libenchant.dll" Delete "$INSTDIR\spellcheck\libgtkspell-0.dll" Delete "$INSTDIR\spellcheck\lib\enchant\libenchant_aspell.dll" Delete "$INSTDIR\spellcheck\lib\enchant\libenchant_ispell.dll" Delete "$INSTDIR\spellcheck\lib\enchant\libenchant_myspell.dll" RMDir "$INSTDIR\spellcheck\lib\enchant" RMDir "$INSTDIR\spellcheck\lib" RMDir "$INSTDIR\spellcheck" Delete "$INSTDIR\freebl3.dll" Delete "$INSTDIR\libjabber.dll" Delete "$INSTDIR\libnspr4.dll" Delete "$INSTDIR\libmeanwhile-1.dll" Delete "$INSTDIR\liboscar.dll" Delete "$INSTDIR\libplc4.dll" Delete "$INSTDIR\libplds4.dll" Delete "$INSTDIR\libpurple.dll" Delete "$INSTDIR\libsasl2-3.dll" Delete "$INSTDIR\libsilc-1-1-4.dll" Delete "$INSTDIR\libsilcclient-1-1-4.dll" Delete "$INSTDIR\libssp-0.dll" Delete "$INSTDIR\libxml2-2.dll" Delete "$INSTDIR\libymsg.dll" Delete "$INSTDIR\nss3.dll" Delete "$INSTDIR\nssutil3.dll" Delete "$INSTDIR\pidgin.dll" Delete "$INSTDIR\pidgin.exe" Delete "$INSTDIR\smime3.dll" Delete "$INSTDIR\softokn3.dll" Delete "$INSTDIR\sqlite3.dll" Delete "$INSTDIR\ssl3.dll" Delete "$INSTDIR\${PIDGIN_UNINST_EXE}" Delete "$INSTDIR\exchndl.dll" Delete "$INSTDIR\install.log" ; Remove the debug symbols RMDir /r "$INSTDIR\pidgin-${PIDGIN_VERSION}-dbgsym" ; Remove the local GTK+ copy (if we're not just upgrading) ${GetOptions} "$R0" "/UPGRADE=" $R1 StrCmp $R1 "1" upgrade_done
; Remove the downloaded spellcheck dictionaries (if we're not just upgrading) RMDir /r "$INSTDIR\spellcheck" ;Try to remove Pidgin install dir (only if empty) Delete "$DESKTOP\Pidgin.lnk" Delete "$SMPROGRAMS\Pidgin.lnk" MessageBox MB_OK $(PIDGINUNINSTALLERROR1
) /SD IDOK MessageBox MB_OK $(PIDGINUNINSTALLERROR2
) /SD IDOK SectionEnd ; end of uninstall section ;-------------------------------- !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT
${SecPidgin} \ $(PIDGINSECTIONDESCRIPTION
) !insertmacro MUI_DESCRIPTION_TEXT
${SecGtk} \ !insertmacro MUI_DESCRIPTION_TEXT
${SecShortcuts} \ $(PIDGINSHORTCUTSSECTIONDESCRIPTION
) !insertmacro MUI_DESCRIPTION_TEXT
${SecDesktopShortcut} \ $(PIDGINDESKTOPSHORTCUTDESC
) !insertmacro MUI_DESCRIPTION_TEXT
${SecStartMenuShortcut} \ $(PIDGINSTARTMENUSHORTCUTDESC
) !insertmacro MUI_DESCRIPTION_TEXT
${SecSpellCheck} \ $(PIDGINSPELLCHECKSECTIONDESCRIPTION
) !insertmacro MUI_FUNCTION_DESCRIPTION_END
;-------------------------------- ; Default the URI handler checkboxes if Pidgin is the current handler or if there is no handler Function SelectURIHandlerSelections
; Start with the first URI handler IntOp $R0 ${SecURIHandlers} + 1
; If it is the end of the section group, stop IntOp $R2 $R1 & ${SF_SECGRPEND} IntCmp $R2 ${SF_SECGRPEND} done
ReadRegStr $R3 HKCR "$R2" "" IfErrors default_on
;there is no current handler Call CheckIfPidginIsCurrentURIHandler
; If Pidgin isn't the current handler, we don't steal it automatically ;We default the URI handler checkbox on IntOp $R1 $R1 | ${SF_SELECTED} ; Select IntOp $R0 $R0 + 1
;Advance to the next section FunctionEnd ;SelectURIHandlerSections ; Check if Pidgin is the current handler ; Returns a boolean on the stack !macro CheckIfPidginIsCurrentURIHandlerMacro
UN
Function ${UN}CheckIfPidginIsCurrentURIHandler
ReadRegStr $R0 HKCR "$R0\shell\Open\command" "" ${un.WordFind
} "$R0" "pidgin.exe" "E+1{" $R0 ${WordFind} "$R0" "pidgin.exe" "E+1{" $R0 !insertmacro CheckIfPidginIsCurrentURIHandlerMacro
"" !insertmacro CheckIfPidginIsCurrentURIHandlerMacro
"un." ; If Pidgin is the current URI handler for the specified protocol, remove it. Function un.UnregisterURIHandler
Call un.CheckIfPidginIsCurrentURIHandler
; If Pidgin isn't the current handler, leave it as-is ;Unregister the URI handler DetailPrint "Unregistering $R0 URI Handler" Function RegisterURIHandler
DetailPrint "Registering $R0 URI Handler" WriteRegStr HKCR "$R0" "" "URL:$R0" WriteRegStr HKCR "$R0" "URL Protocol" "" WriteRegStr HKCR "$R0\DefaultIcon" "" "$INSTDIR\pidgin.exe" WriteRegStr HKCR "$R0\shell" "" "" WriteRegStr HKCR "$R0\shell\Open" "" "" WriteRegStr HKCR "$R0\shell\Open\command" "" "$INSTDIR\pidgin.exe --protocolhandler=%1" !macro CheckUserInstallRightsMacro
UN
Function ${UN}CheckUserInstallRights
!insertmacro CheckUserInstallRightsMacro
"" !insertmacro CheckUserInstallRightsMacro
"un." ; Pop $0 ; 0 - Bad path 1 - Good path IfFileExists $0 dir_exists
; IfFileExists "C:" on xp returns true and on win2k returns false ; So we're done in such a case.. ; GetParent of "C:" returns "" ; Check if we can create dir on this drive.. FileOpen $1 "$0\pidginfoo.bar" w
IfErrors PathBad
PathGood
Delete "$0\pidginfoo.bar" Delete "$0\pidginfoo.bar" Exch 3
; The top of the stack contains the output variable Function .onVerifyInstDir
; 0 - We have the correct version ; 1 - We have an old version that should work, prompt user for optional upgrade ; 2 - We have an old version that needs to be upgraded ; 3 - We don't have Gtk+ at all IfFileExists "$INSTDIR\Gtk\CONTENTS" +3
${ConfigRead} "$INSTDIR\Gtk\CONTENTS" "Bundle Version " $0 ${VersionCompare} ${GTK_INSTALL_VERSION} $0 $1 Push "0" ; Have a good version ${VersionCompare} ${GTK_MIN_VERSION} $0 $1 Push "1" ; Optional Upgrade Push "2" ; Mandatory Upgrade ; The item on the stack is what we want to return ; Close the Handle (needed if we're retrying) System::Call 'kernel32::CloseHandle(i $R1) i .R1' System::Call 'kernel32::CreateMutexA(i 0, i 0, t "pidgin_is_running") i .R1 ?e' IntCmp $R0 0
+3
;This could check for ERROR_ALREADY_EXISTS(183), but lets just assume MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION $(PIDGINISRUNNING
) /SD IDCANCEL IDRETRY retry_runcheck
; Close the Handle (If we don't do this, the uninstaller called from within will fail) ; This is not optimal because there is a (small) window of time when a new process could start System::Call 'kernel32::CloseHandle(i $R1) i .R1' !insertmacro RunCheckMacro
"" !insertmacro RunCheckMacro
"un." Push $R3 ; This is only used for the Parameters throughout the function ; Close the Handle (needed if we're retrying) System::Call 'kernel32::CloseHandle(i $R1) i .R1' System::Call 'kernel32::CreateMutexA(i 0, i 0, t "pidgin_installer_running") i .R1 ?e' IntCmp $R0 0
+3
;This could check for ERROR_ALREADY_EXISTS(183), but lets just assume MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION $(INSTALLERISRUNNING
) /SD IDCANCEL IDRETRY retry_runcheck
; Allow installer to run even if pidgin is running via "/NOPIDGINRUNCHECK=1" ; This is useful for testing ${GetOptions} "$R3" "/NOPIDGINRUNCHECK=" $R1 StrCpy $name "Pidgin ${PIDGIN_VERSION}" ;Try to copy the old Gaim installer Lang Reg. key ;(remove it after we're done to prevent this being done more than once) ReadRegStr $R0 HKCU "${PIDGIN_REG_KEY}" "${MUI_LANGDLL_REGISTRY_VALUENAME}" ReadRegStr $R0 HKCU "${OLD_GAIM_REG_KEY}" "${MUI_LANGDLL_REGISTRY_VALUENAME}" DeleteRegValue HKCU "${OLD_GAIM_REG_KEY}" "${MUI_LANGDLL_REGISTRY_VALUENAME}" WriteRegStr HKCU "${PIDGIN_REG_KEY}" "${MUI_LANGDLL_REGISTRY_VALUENAME}" "$R0" ;Preselect the URI handlers as appropriate Call SelectURIHandlerSelections
;Preselect the "shortcuts" checkboxes according to the previous installation ;Make sure that there was a previous installation ReadRegStr $R0 HKCU "${PIDGIN_REG_KEY}" "${MUI_LANGDLL_REGISTRY_VALUENAME}" IfErrors done_preselecting_shortcuts
;Does the Desktop shortcut exist? GetFileTime "$DESKTOP\Pidgin.lnk" $R0 $R0 GetFileTime "$DESKTOP\Pidgin.lnk" $R0 $R0 IfErrors preselect_startmenu_shortcut
;Desktop Shortcut if off by default !insertmacro SelectSection
${SecDesktopShortcut} preselect_startmenu_shortcut: ;Reset ShellVarContext because we may have changed it SetShellVarContext "current" ;Does the StartMenu shortcut exist? GetFileTime "$SMPROGRAMS\Pidgin.lnk" $R0 $R0 IfErrors +1
done_preselecting_shortcuts
;StartMenu Shortcut is on by default GetFileTime "$SMPROGRAMS\Pidgin.lnk" $R0 $R0 IfErrors +1
done_preselecting_shortcuts
;StartMenu Shortcut is on by default !insertmacro UnselectSection
${SecStartMenuShortcut} done_preselecting_shortcuts: ;Reset ShellVarContext because we may have changed it SetShellVarContext "current" ${GetOptions} "$R3" "/L=" $R1 ; Display Language selection dialog !define MUI_LANGDLL_ALWAYSSHOW
!insertmacro MUI_LANGDLL_DISPLAY
${GetOptions} "$R3" "/DS=" $R1 SectionGetFlags ${SecDesktopShortcut} $R2 IntOp $R2 $R2 | ${SF_SELECTED} IntOp $R1 ${SF_SELECTED} ~ SectionSetFlags ${SecDesktopShortcut} $R2 ${GetOptions} "$R3" "/SMS=" $R1 SectionGetFlags ${SecStartMenuShortcut} $R2 IntOp $R2 $R2 | ${SF_SELECTED} IntOp $R1 ${SF_SELECTED} ~ SectionSetFlags ${SecStartMenuShortcut} $R2 ; If install path was set on the command, use it. StrCmp $INSTDIR "" 0
instdir_done
; If pidgin or gaim is currently installed, we should default to where it is currently installed ReadRegStr $INSTDIR HKCU "${PIDGIN_REG_KEY}" "" StrCmp $INSTDIR "" 0
instdir_done
ReadRegStr $INSTDIR HKLM "${PIDGIN_REG_KEY}" "" StrCmp $INSTDIR "" 0
instdir_done
Call CheckUserInstallRights
StrCmp $R0 "HKLM" 0
user_dir
StrCpy $INSTDIR "$PROGRAMFILES\Pidgin" ${GetParent} $SMPROGRAMS $R2 StrCpy $INSTDIR "$R2\Pidgin" ; Try to select a translation and a dictionary for the currently selected Language Call SelectTranslationForCurrentLanguage
;Mark the dictionaries that are already installed as readonly Call SelectAndDisableInstalledDictionaries
StrCpy $name "Pidgin ${PIDGIN_VERSION}" ; Get stored language preference !insertmacro MUI_UNGETLANGUAGE
; Page enter and exit functions.. !insertmacro SelectSection
${SecDebugSymbols} StrCpy $WARNED_GTK_STATE "0" IntCmp $CURRENT_GTK_STATE 1
done
gtk_not_mandatory
; Make the GTK+ Section RO if it is required. (it is required only if you have an existing version that is too old) StrCmp $CURRENT_GTK_STATE "2" 0
done
!insertmacro SetSectionFlag
${SecGtk} ${SF_RO} ; Don't select the GTK+ section if we already have this version or newer installed !insertmacro UnselectSection
${SecGtk} ; If the GTK+ Section has been unselected and there isn't a compatible GTK+ already, confirm SectionGetFlags ${SecGtk} $R0 IntOp $R0 $R0 & ${SF_SELECTED} ; If the Gtk Section is currently selected, reset the "Warned" flag StrCmp $R0 "${SF_SELECTED}" 0
+3
StrCpy $WARNED_GTK_STATE "0" ; If we've already warned the user, don't warn them again StrCmp $WARNED_GTK_STATE "1" done
IntCmp $CURRENT_GTK_STATE 1
done
done
0
StrCpy $WARNED_GTK_STATE "1" MessageBox MB_YESNO $(PIDGINPROMPTFORCENOGTK
) /SD IDNO IDYES done
!insertmacro SelectSection
${SecGtk} Function SelectTranslationForCurrentLanguage
!insertmacro SELECT_TRANSLATION_FUNCTION
; SpellChecker Related Functions ;------------------------------- ; Select and Disable any Sections that have currently installed dictionaries !macro CHECK_SPELLCHECK_SECTION
lang
;Advance to the next (correct) section index IfFileExists "$INSTDIR\spellcheck\share\enchant\myspell\${lang}.dic" 0
done_
${lang} IntOp $R1 $R1 | ${SF_RO} ; Mark Readonly IntOp $R1 $R1 | ${SF_SELECTED} ; Select Function SelectAndDisableInstalledDictionaries !insertmacro SetSectionFlag
${SecSpellCheck} ${SF_RO} !insertmacro UnselectSection
${SecSpellCheck} IntOp $R0 ${SecSpellCheck} + 0
!include "pidgin-spellcheck-preselect.nsh" Pop $R0 ;This is the language code Pop $R1 ;This is the language file IfFileExists "$INSTDIR\spellcheck\share\enchant\myspell\$R0.dic" installed
; 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)" NSISdl::download /TIMEOUT=10000
"$R3" "$R2" MessageBox MB_RETRYCANCEL "$(PIDGINSPELLCHECKERROR)" /SD IDCANCEL IDRETRY retry
IDCANCEL done
SetOutPath "$INSTDIR\spellcheck\share\enchant\myspell" nsisunz::UnzipToLog "$R2" "$OUTDIR" StrCmp $R3 "success" installed
DetailPrint "$R3" ;print error message to log installed: ;The dictionary is currently installed, no error message DetailPrint "$R0 Dictionary is installed" !ifndef OFFLINE_INSTALLER
; Input Stack: Filename, SHA1sum ; Output Return Code: 0=Match; 1=FileSum error; 2=Mismatch SHA1Plugin::FileSum "$R0" DetailPrint "SHA1Sum calculation error: $R0" DetailPrint "SHA1Sum mismatch... Expected $R2; got $R0" Exch $R1 ;$R1 has the return code