1;NSIS Script For Pidgin-Encryption Plugin (MUI version) 2; Based on installers by Mike Campell and Daniel Atallah, and on the Pidgin installer by 3; Herman Bloggs. Many thanks! 4; probably will not work with older versions of NSIS 5; Requires NSIS 2.0 or greater 6 7Name "Pidgin-Encryption ${PIDGIN-ENCRYPTION_VERSION}" 8!define MY_NAME Name 9 10; Registry keys: 11!define PIDGIN_ENCRYPTION_REG_KEY "SOFTWARE\pidgin-encryption" 12!define PIDGIN_ENCRYPTION_UNINSTALL_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\pidgin-encryption" 13!define PIDGIN_ENCRYPTION_UNINST_EXE "pidgin-encryption-uninst.exe" 14 15!define ALL_LINGUAS "bg cs da de es fr hu it ja lt nl nn pl pt_BR pt_PT ro ru sl sv ta tr uk zh_CN zh_TW" 16 17!include "MUI.nsh" 18 19;Do A CRC Check 20CRCCheck On 21 22;Output File Name 23OutFile "pidgin-encryption-${PIDGIN-ENCRYPTION_VERSION}.exe" 24 25ShowInstDetails show 26ShowUnInstDetails show 27SetCompressor lzma 28 29; Translations 30 31 32; Modern UI Configuration 33 34!define MUI_ICON .\nsis\install.ico 35!define MUI_UNICON .\nsis\install.ico 36!define MUI_HEADERIMAGE 37!define MUI_HEADERIMAGE_BITMAP "nsis\header.bmp" 38 39; Pidgin Plugin installer helper stuff 40;!addincludedir "..\..\src\win32\nsis" 41;!include "pidgin-plugin.nsh" 42 43; Pages 44; !insertmacro MUI_LANGDLL_DISPLAY 45 46!define MUI_WELCOMEPAGE_TITLE $(WELCOME_TITLE) 47!define MUI_WELCOMEPAGE_TEXT $(WELCOME_TEXT) 48!insertmacro MUI_PAGE_WELCOME 49 50!insertmacro MUI_PAGE_LICENSE "./COPYING" 51 52!define MUI_DIRECTORYPAGE_TEXT_TOP $(DIR_SUBTITLE) 53!define MUI_DIRECTORYPAGE_TEXT_DESTINATION $(DIR_INNERTEXT) 54!insertmacro MUI_PAGE_DIRECTORY 55 56!insertmacro MUI_PAGE_INSTFILES 57 58!define MUI_FINISHPAGE_TITLE $(FINISH_TITLE) 59!define MUI_FINISHPAGE_TEXT $(FINISH_TEXT) 60!insertmacro MUI_PAGE_FINISH 61 62; MUI Config 63 64!define MUI_CUSTOMFUNCTION_GUIINIT encrypt_checkPidginVersion 65!define MUI_ABORTWARNING 66!define MUI_UNINSTALLER 67!define MUI_PROGRESSBAR smooth 68!define MUI_INSTALLCOLORS /windows 69; !define MUI_FINISHPAGE_TEXT $(G-E_INSTALL_FINISHED) 70; !define MUI_FINISHPAGE_NOAUTOCLOSE 71;!define MUI_TEXT_WELCOME_INFO_TEXT $(WELCOME_TEXT) 72;!define MUI_TEXT_DIRECTORY_SUBTITLE $(DIR_SUBTITLE) 73;!define MUI_INNERTEXT_DIRECTORY_TOP $(DIR_INNERTEXT) 74 75 76;; Here in alphabetical order in native language 77;; i.e. Danish, Deutsch, Espanol, Francais... , not Danish, French, German, Spanish... 78;; English first as a default 79 80!insertmacro MUI_LANGUAGE "English" 81!insertmacro MUI_LANGUAGE "Bulgarian" 82!insertmacro MUI_LANGUAGE "Czech" 83!insertmacro MUI_LANGUAGE "Danish" 84!insertmacro MUI_LANGUAGE "SimpChinese" 85!insertmacro MUI_LANGUAGE "TradChinese" 86!insertmacro MUI_LANGUAGE "German" 87!insertmacro MUI_LANGUAGE "Spanish" 88!insertmacro MUI_LANGUAGE "French" 89!insertmacro MUI_LANGUAGE "Hungarian" 90!insertmacro MUI_LANGUAGE "Italian" 91!insertmacro MUI_LANGUAGE "Japanese" 92!insertmacro MUI_LANGUAGE "Lithuanian" 93!insertmacro MUI_LANGUAGE "Dutch" 94!insertmacro MUI_LANGUAGE "Norwegian" 95!insertmacro MUI_LANGUAGE "Polish" 96!insertmacro MUI_LANGUAGE "Portuguese" 97!insertmacro MUI_LANGUAGE "PortugueseBR" 98!insertmacro MUI_LANGUAGE "Romanian" 99!insertmacro MUI_LANGUAGE "Russian" 100!insertmacro MUI_LANGUAGE "Slovenian" 101!insertmacro MUI_LANGUAGE "Turkish" 102!insertmacro MUI_LANGUAGE "Ukrainian" 103 104!include "nsis\translations\english.nsh" 105!include "nsis\translations\czech.nsh" 106!include "nsis\translations\danish.nsh" 107!include "nsis\translations\trad-chinese.nsh" 108!include "nsis\translations\german.nsh" 109!include "nsis\translations\spanish.nsh" 110!include "nsis\translations\french.nsh" 111!include "nsis\translations\hungarian.nsh" 112!include "nsis\translations\italian.nsh" 113!include "nsis\translations\japanese.nsh" 114!include "nsis\translations\lithuanian.nsh" 115!include "nsis\translations\dutch.nsh" 116!include "nsis\translations\norwegian.nsh" 117!include "nsis\translations\polish.nsh" 118!include "nsis\translations\portugueseBR.nsh" 119!include "nsis\translations\romanian.nsh" 120!include "nsis\translations\russian.nsh" 121!include "nsis\translations\slovenian.nsh" 122!include "nsis\translations\turkish.nsh" 123!include "nsis\translations\ukrainian.nsh" 124 125 126 127!define MUI_LICENSEPAGE_RADIOBUTTONS 128 129 130;The Default Installation Directory 131InstallDir "$PROGRAMFILES\pidgin" 132InstallDirRegKey HKLM SOFTWARE\pidgin "" 133 134Section -SecUninstallOldPlugin 135 ; Check install rights.. 136 Call CheckUserInstallRights 137 Pop $R0 138 139 StrCmp $R0 "HKLM" rights_hklm 140 StrCmp $R0 "HKCU" rights_hkcu done 141 142 rights_hkcu: 143 ReadRegStr $R1 HKCU ${PIDGIN_ENCRYPTION_REG_KEY} "" 144 ReadRegStr $R2 HKCU ${PIDGIN_ENCRYPTION_REG_KEY} "Version" 145 ReadRegStr $R3 HKCU "${PIDGIN_ENCRYPTION_UNINSTALL_KEY}" "UninstallString" 146 Goto try_uninstall 147 148 rights_hklm: 149 ReadRegStr $R1 HKLM ${PIDGIN_ENCRYPTION_REG_KEY} "" 150 ReadRegStr $R2 HKLM ${PIDGIN_ENCRYPTION_REG_KEY} "Version" 151 ReadRegStr $R3 HKLM "${PIDGIN_ENCRYPTION_UNINSTALL_KEY}" "UninstallString" 152 153 ; If previous version exists .. remove 154 try_uninstall: 155 StrCmp $R1 "" done 156 StrCmp $R2 "" uninstall_problem 157 IfFileExists $R3 0 uninstall_problem 158 ; Have uninstall string.. go ahead and uninstall. 159 SetOverwrite on 160 ; Need to copy uninstaller outside of the install dir 161 ClearErrors 162 CopyFiles /SILENT $R3 "$TEMP\${PIDGIN_ENCRYPTION_UNINST_EXE}" 163 SetOverwrite off 164 IfErrors uninstall_problem 165 ; Ready to uninstall.. 166 ClearErrors 167 ExecWait '"$TEMP\${PIDGIN_ENCRYPTION_UNINST_EXE}" /S _?=$R1' 168 IfErrors exec_error 169 Delete "$TEMP\${PIDGIN_ENCRYPTION_UNINST_EXE}" 170 Goto done 171 172 exec_error: 173 Delete "$TEMP\${PIDGIN_ENCRYPTION_UNINST_EXE}" 174 Goto uninstall_problem 175 176 uninstall_problem: 177 ; Just delete the plugin and uninstaller, and remove Registry key 178 MessageBox MB_YESNO $(PIDGIN_ENCRYPTION_PROMPT_WIPEOUT) IDYES do_wipeout IDNO cancel_install 179 cancel_install: 180 Quit 181 182 do_wipeout: 183 StrCmp $R0 "HKLM" del_lm_reg del_cu_reg 184 del_cu_reg: 185 DeleteRegKey HKCU ${PIDGIN_ENCRYPTION_REG_KEY} 186 Goto uninstall_prob_cont 187 del_lm_reg: 188 DeleteRegKey HKLM ${PIDGIN_ENCRYPTION_REG_KEY} 189 190 uninstall_prob_cont: 191 Delete "$R1\plugins\encrypt.dll" 192 Delete "$R3" 193 194 done: 195 196SectionEnd 197 198 199Section "Install" 200 201 Call CheckUserInstallRights 202 Pop $R0 203 204 StrCmp $R0 "NONE" instrights_none 205 StrCmp $R0 "HKLM" instrights_hklm instrights_hkcu 206 207 instrights_hklm: 208 ; Write the version registry keys: 209 WriteRegStr HKLM ${PIDGIN_ENCRYPTION_REG_KEY} "" "$INSTDIR" 210 WriteRegStr HKLM ${PIDGIN_ENCRYPTION_REG_KEY} "Version" "${PIDGIN-ENCRYPTION_VERSION}" 211 212 ; Write the uninstall keys for Windows 213 WriteRegStr HKLM ${PIDGIN_ENCRYPTION_UNINSTALL_KEY} "DisplayName" "$(PIDGIN_ENCRYPTION_UNINSTALL_DESC)" 214 WriteRegStr HKLM ${PIDGIN_ENCRYPTION_UNINSTALL_KEY} "UninstallString" "$INSTDIR\${PIDGIN_ENCRYPTION_UNINST_EXE}" 215 SetShellVarContext "all" 216 Goto install_files 217 218 instrights_hkcu: 219 ; Write the version registry keys: 220 WriteRegStr HKCU ${PIDGIN_ENCRYPTION_REG_KEY} "" "$INSTDIR" 221 WriteRegStr HKCU ${PIDGIN_ENCRYPTION_REG_KEY} "Version" "${PIDGIN-ENCRYPTION_VERSION}" 222 223 ; Write the uninstall keys for Windows 224 WriteRegStr HKCU ${PIDGIN_ENCRYPTION_UNINSTALL_KEY} "DisplayName" "$(PIDGIN_ENCRYPTION_UNINSTALL_DESC)" 225 WriteRegStr HKCU ${PIDGIN_ENCRYPTION_UNINSTALL_KEY} "UninstallString" "$INSTDIR\${PIDGIN_ENCRYPTION_UNINST_EXE}" 226 Goto install_files 227 228 instrights_none: 229 ; No registry keys for us... 230 231 install_files: 232 SetOutPath $INSTDIR 233 SetCompress Auto 234 SetOverwrite on 235 File /r ".\win32-install-dir\*.*" 236 237 StrCmp $R0 "NONE" done 238 CreateShortCut "$SMPROGRAMS\Pidgin\Pidgin-Encryption Uninstall.lnk" "$INSTDIR\${PIDGIN_ENCRYPTION_UNINST_EXE}" 239 WriteUninstaller "$INSTDIR\${PIDGIN_ENCRYPTION_UNINST_EXE}" 240 SetOverWrite off 241 242 done: 243SectionEnd 244 245Section Uninstall 246 Call un.CheckUserInstallRights 247 Pop $R0 248 StrCmp $R0 "NONE" no_rights 249 StrCmp $R0 "HKCU" try_hkcu try_hklm 250 251 try_hkcu: 252 ReadRegStr $R0 HKCU ${PIDGIN_ENCRYPTION_REG_KEY} "" 253 StrCmp $R0 $INSTDIR 0 cant_uninstall 254 ; HKCU install path matches our INSTDIR.. so uninstall 255 DeleteRegKey HKCU ${PIDGIN_ENCRYPTION_REG_KEY} 256 DeleteRegKey HKCU "${PIDGIN_ENCRYPTION_UNINSTALL_KEY}" 257 Goto cont_uninstall 258 259 try_hklm: 260 ReadRegStr $R0 HKLM ${PIDGIN_ENCRYPTION_REG_KEY} "" 261 StrCmp $R0 $INSTDIR 0 try_hkcu 262 ; HKLM install path matches our INSTDIR.. so uninstall 263 DeleteRegKey HKLM ${PIDGIN_ENCRYPTION_REG_KEY} 264 DeleteRegKey HKLM "${PIDGIN_ENCRYPTION_UNINSTALL_KEY}" 265 ; Sets start menu and desktop scope to all users.. 266 SetShellVarContext "all" 267 268 cont_uninstall: 269 ; plugin 270 Delete "$INSTDIR\plugins\encrypt.dll" 271 272 ; all locales 273 Push $R0 ;save old values 274 Push $R1 275 Push $R2 276 Push "${ALL_LINGUAS}" 277 Pop $R0 ;initialize input array 278 alllinguas: 279 StrLen $R1 $R0 ;length of input array 280 IntCmp $R1 0 alldone 281 IntOp $R1 $R1 + 1 282 uptodelimiter: 283 IntOp $R1 $R1 - 1 284 IntCmp $R1 0 fullof fullof 285 StrCpy $R2 $R0 1 -$R1 286 StrCmp $R2 "" fullof 287 StrCmp $R2 " " partof 288 Goto uptodelimiter 289 partof: 290 StrCpy $R2 $R0 -$R1 291 IntOp $R1 $R1 - 1 292 StrCpy $R0 $R0 "" -$R1 293 Goto dodelwork 294 fullof: 295 StrCpy $R2 $R0 296 StrCpy $R0 "" 297 dodelwork: 298 StrCpy $R1 "$INSTDIR\locale" 299 Push $R1 300 StrCpy $R1 "$R1\$R2" 301 Push $R1 302 StrCpy $R1 "$R1\LC_MESSAGES" 303 Delete "$R1\pidgin-encryption.mo" 304 RMDir $R1 305 Pop $R1 306 RMDir $R1 307 Pop $R1 308 RMDir $R1 309 Goto alllinguas 310 alldone: 311 Pop $R2 ;restore old values 312 Pop $R1 313 Pop $R0 314 315 ; uninstaller shortcut 316 Delete "$SMPROGRAMS\Pidgin\Pidgin-Encryption Uninstall.lnk" 317 318 ; uninstaller 319 Delete "$INSTDIR\${PIDGIN_ENCRYPTION_UNINST_EXE}" 320 Delete "$INSTDIR\pixmaps\pidgin-encryption\*.png" 321 RMDir "$INSTDIR\pixmaps\pidgin-encryption" 322 323 ; try to delete the Pidgin directories, in case it has already uninstalled 324 RMDir "$INSTDIR\plugins" 325 RMDIR "$INSTDIR\locale" 326 RMDir "$INSTDIR" 327 RMDir "$SMPROGRAMS\Pidgin" 328 329 Goto done 330 331 cant_uninstall: 332 MessageBox MB_OK $(un.PIDGIN_ENCRYPTION_UNINSTALL_ERROR_1) IDOK 333 Quit 334 335 no_rights: 336 MessageBox MB_OK $(un.PIDGIN_ENCRYPTION_UNINSTALL_ERROR_2) IDOK 337 Quit 338 339 done: 340SectionEnd 341 342Function .onVerifyInstDir 343 IfFileExists $INSTDIR\pidgin.exe Good1 344 Abort 345 Good1: 346FunctionEnd 347 348Function encrypt_checkPidginVersion 349; Push $R0 350; Push ${PIDGIN_VERSION} 351; Call CheckPidginVersion 352; Pop $R0 353; 354; StrCmp $R0 ${PIDGIN_VERSION_OK} encrypt_checkPidginVersion_OK 355; 356; StrCmp $R0 ${PIDGIN_VERSION_INCOMPATIBLE} +1 +6 357; Call GetPidginVersion 358; IfErrors +3 359; Pop $R0 360; MessageBox MB_OK|MB_ICONSTOP "$(BAD_PIDGIN_VERSION_1) $R0 $(BAD_PIDGIN_VERSION_2)" 361; goto +2 362; MessageBox MB_OK|MB_ICONSTOP "$(UNKNOWN_PIDGIN_VERSION)" 363; Quit 364; 365; encrypt_checkPidginVersion_OK: 366; Pop $R0 367 368FunctionEnd 369 370Function CheckUserInstallRights 371 ClearErrors 372 UserInfo::GetName 373 IfErrors Win9x 374 Pop $0 375 UserInfo::GetAccountType 376 Pop $1 377 378 StrCmp $1 "Admin" 0 +3 379 StrCpy $1 "HKLM" 380 Goto done 381 StrCmp $1 "Power" 0 +3 382 StrCpy $1 "HKLM" 383 Goto done 384 StrCmp $1 "User" 0 +3 385 StrCpy $1 "HKCU" 386 Goto done 387 StrCmp $1 "Guest" 0 +3 388 StrCpy $1 "NONE" 389 Goto done 390 ; Unknown error 391 StrCpy $1 "NONE" 392 Goto done 393 394 Win9x: 395 StrCpy $1 "HKLM" 396 397 done: 398 Push $1 399FunctionEnd 400 401Function un.CheckUserInstallRights 402 ClearErrors 403 UserInfo::GetName 404 IfErrors Win9x 405 Pop $0 406 UserInfo::GetAccountType 407 Pop $1 408 StrCmp $1 "Admin" 0 +3 409 StrCpy $1 "HKLM" 410 Goto done 411 StrCmp $1 "Power" 0 +3 412 StrCpy $1 "HKLM" 413 Goto done 414 StrCmp $1 "User" 0 +3 415 StrCpy $1 "HKCU" 416 Goto done 417 StrCmp $1 "Guest" 0 +3 418 StrCpy $1 "NONE" 419 Goto done 420 ; Unknown error 421 StrCpy $1 "NONE" 422 Goto done 423 424 Win9x: 425 StrCpy $1 "HKLM" 426 427 done: 428 Push $1 429FunctionEnd 430 431Function .onInit 432 !insertmacro MUI_LANGDLL_DISPLAY 433FunctionEnd 434