SetCompressor zlib !define VERSION "0.99.3" Name "rulesPlayer ${VERSION}" OutFile "rulessetup.exe" InstallDir $PROGRAMFILES\rulesPlayer InstallDirRegKey HKLM "Software\bobef\rulesPlayer" "InstallDir" CRCCheck on Icon "C:\Program Files\NSIS\Contrib\Graphics\Icons\orange-install.ico" UninstallIcon "C:\Program Files\NSIS\Contrib\Graphics\Icons\orange-uninstall.ico" CheckBitmap "C:\Program Files\NSIS\Contrib\Graphics\Checks\modern.bmp" XPStyle on LicenseText "License agreement" LicenseData "license.txt" Page license Page custom SetCustom ValidateCustom Page components Page directory Page instfiles #Uninstpage components UninstPage uninstConfirm UninstPage instfiles Var mplayer_file Var mplayer_url Var codecs_file Var codecs_url Var update_file Var update_url Var installing_bin #Var installing_src Var download_mplayer Var install_mplayer Var mplayer_section Var mplayer_version Var fatalerrors #Var tvtool UninstallText "Uninstaller will remove the rulesPlayer directory (really)! Also if you registered some files with rulesPlayer you may wish to unregister them prior to uninstalling." "Uninstalling from:" Function .onInit InitPluginsDir File /oname=$PLUGINSDIR\rulessetup.ini rulessetup.ini FunctionEnd Function SetCustom Push $R0 InstallOptions::dialog $PLUGINSDIR\rulessetup.ini Pop $R0 FunctionEnd Function ValidateCustom #check for update autoupdate: ReadINIStr $R0 "$PLUGINSDIR\rulessetup.ini" "Field 1" "State" StrCmp $R0 "1" 0 default StrCpy $update_file "update.ini" #try to read the url from updateurl.txt ClearErrors FileOpen $0 "$EXEDIR\updateurl.txt" r IfErrors +4 FileRead $0 $update_url FileClose $0 Goto +3 StrCmp $update_url "" 0 +2 StrCpy $update_url "http://svn.dsource.org/projects/rulesplayer/trunk/setup/update.ini" inetc::get /TIMEOUT 30000 /RESUME "Connection interrupted.$\nTry to resume?" /BANNER "Setup will download info about latest MPlayer version.$\nThe operation will timeout in 30 secons." $update_url "$PLUGINSDIR\$update_file" Pop $0 StrCmp $0 "OK" 0 ask ReadINIStr $0 "$PLUGINSDIR\$update_file" "URLs" "MPlayer" ReadINIStr $1 "$PLUGINSDIR\$update_file" "URLs" "Codecs_all" ReadINIStr $2 "$PLUGINSDIR\$update_file" "URLs" "Codecs_essential" ReadINIStr $3 "$PLUGINSDIR\$update_file" "Files" "MPlayer" ReadINIStr $4 "$PLUGINSDIR\$update_file" "Files" "Codecs_all" ReadINIStr $5 "$PLUGINSDIR\$update_file" "Files" "Codecs_essential" ReadINIStr $mplayer_version "$PLUGINSDIR\$update_file" "Info" "MPlayer_version" StrCmp $0 "" ask good StrCmp $1 "" ask good StrCmp $2 "" ask good StrCmp $3 "" ask good StrCmp $4 "" ask good StrCmp $5 "" ask good StrCmp $mplayer_version "" ask good ask: MessageBox MB_ICONEXCLAMATION|MB_YESNO "Unable to get info about the latest MPlayer version.$\nDo you want to install the default one?" IDYES default IDNO 0 StrCpy $install_mplayer "0" StrCpy $mplayer_section "" Goto done good: StrCpy $mplayer_file "$EXEDIR\$3" StrCpy $mplayer_url $0 ReadINIStr $R0 "$PLUGINSDIR\rulessetup.ini" "Field 5" "State" StrCmp $R0 "1" 0 +4 StrCpy $codecs_file "$EXEDIR\$4" StrCpy $codecs_url $1 Goto +3 StrCpy $codecs_file "$EXEDIR\$5" StrCpy $codecs_url $2 StrCpy $install_mplayer "1" StrCpy $download_mplayer "1" StrCpy $mplayer_section "Download and install MPlayer $mplayer_version" Goto done #download default default: ReadINIStr $R0 "$PLUGINSDIR\rulessetup.ini" "Field 2" "State" StrCmp $R0 "1" 0 existing StrCpy $mplayer_file "MPlayer-mingw32-1.0rc1.zip" StrCpy $mplayer_url "http://www1.mplayerhq.hu/MPlayer/releases/win32/MPlayer-mingw32-1.0rc1.zip" ReadINIStr $R0 "$PLUGINSDIR\rulessetup.ini" "Field 5" "State" StrCmp $R0 "1" 0 +4 StrCpy $codecs_file "windows-all-20061022.zip" StrCpy $codecs_url "http://www1.mplayerhq.hu/MPlayer/releases/codecs/windows-all-20061022.zip" Goto +3 StrCpy $codecs_file "windows-essential-20061022.zip" StrCpy $codecs_url "http://www1.mplayerhq.hu/MPlayer/releases/codecs/windows-essential-20061022.zip" StrCpy $install_mplayer "1" StrCpy $download_mplayer "1" StrCpy $mplayer_version "rc1" StrCpy $mplayer_section "Download and install MPlayer $mplayer_version" Goto done #use existing files existing: ReadINIStr $R0 "$PLUGINSDIR\rulessetup.ini" "Field 3" "State" StrCmp $R0 "1" 0 manual ReadINIStr $R0 "$PLUGINSDIR\rulessetup.ini" "Field 7" "State" StrCmp $R0 "" 0 +3 MessageBox MB_ICONEXCLAMATION|MB_OK "Please select MPlayer file." Goto bad StrCpy $mplayer_file $R0 ReadINIStr $R0 "$PLUGINSDIR\rulessetup.ini" "Field 8" "State" StrCmp $R0 "" 0 +3 MessageBox MB_ICONEXCLAMATION|MB_OK "Please select MPlayer codecs file." Goto bad StrCpy $codecs_file $R0 StrCpy $install_mplayer "1" StrCpy $download_mplayer "0" StrCpy $mplayer_section "Install existing MPlayer" Goto done manual: #no mplayer ReadINIStr $R0 "$PLUGINSDIR\rulessetup.ini" "Field 4" "State" StrCmp $R0 "1" 0 autoupdate StrCpy $install_mplayer "0" StrCpy $mplayer_section "" Goto done bad: Abort done: SectionSetText 5 $mplayer_section FunctionEnd Section "" SetOutPath $INSTDIR WriteRegStr HKLM "SOFTWARE\bobef\akIDE" "InstallDir" "$INSTDIR" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\rulesPlayer" "DisplayName" "rulesPlayer ${VERSION}" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\rulesPlayer" "UninstallString" '"$INSTDIR\rulesuninstall.exe"' WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\rulesPlayer" "NoModify" 1 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\rulesPlayer" "NoRepair" 1 WriteUninstaller "rulesuninstall.exe" SectionEnd Section "Install program files" #$test works StrCpy $installing_bin "1" File /x config.kfg ".\rulesPlayer\*.*" File /r ".\rulesPlayer\images" SetOverwrite off File ".\rulesPlayer\config.kfg" SetOverwrite on SectionEnd #Section "Install TV tool" # StrCpy $tvtool "1" # File /r ".\rulesPlayer\tv" #SectionEnd Section /o "Install source code" File /r ".\rulesPlayer\src" SectionEnd Section /o "Overwrite existing configuration files" File ".\rulesPlayer\config.kfg" SectionEnd Section "" StrCmp $install_mplayer "1" 0 done StrCmp $download_mplayer "1" 0 extract1 NSISdl::download $mplayer_url "$mplayer_file" Pop $0 StrCmp $0 success +4 DetailPrint "Download failed: $0" DetailPrint "You will have to install MPlayer manually or restart the installer" StrCpy $fatalerrors "1" #extract MPlayer extract1: ClearErrors FileOpen $0 "$mplayer_file" r IfErrors bad1 FileClose $0 ZipDLL::extractall "$mplayer_file" "$INSTDIR" Goto codecs bad1: DetailPrint "Can't extact $mplayer_file (file not found)" StrCpy $fatalerrors "1" codecs: StrCmp $download_mplayer "1" 0 extract2 NSISdl::download $codecs_url "$codecs_file" Pop $0 StrCmp $0 success +4 DetailPrint "Download failed: $0" DetailPrint "You will have to install some codecs for MPlayer manually or restart the installer" StrCpy $fatalerrors "1" #extract codecs extract2: ClearErrors FileOpen $0 "$codecs_file" r IfErrors bad2 FileClose $0 ZipDLL::extractall "$codecs_file" "$INSTDIR\mplayer\codecs" Goto done bad2: DetailPrint "Can't extact $codecs_file (file not found)" StrCpy $fatalerrors "1" done: StrCmp $fatalerrors "1" 0 exit SetDetailsView show MessageBox MB_OK|MB_ICONSTOP "MPlayer or it's codecs or both failed to install. You will not be able to use rulesPlayer without them.$\nPlease reinstall or install MPlayer manually in $INSTDIR\mplayer" exit: SectionEnd Section "Create Start menu shortcut" CreateDirectory "$SMPROGRAMS\rulesPlayer" CreateShortCut "$SMPROGRAMS\rulesPlayer\uninstall.lnk" "$INSTDIR\rulesuninstall.exe" "" "$INSTDIR\rulesuninstall.exe" 0 StrCmp $installing_bin "1" eq done eq: CreateShortCut "$SMPROGRAMS\rulesPlayer.lnk" "$INSTDIR\player.exe" "" "$INSTDIR\player.exe" 0 done: SectionEnd Section "Create Start menu program group" CreateDirectory "$SMPROGRAMS\rulesPlayer" CreateShortCut "$SMPROGRAMS\rulesPlayer\uninstall.lnk" "$INSTDIR\rulesuninstall.exe" "" "$INSTDIR\rulesuninstall.exe" 0 StrCmp $installing_bin "1" eq done eq: CreateShortCut "$SMPROGRAMS\rulesPlayer\rulesPlayer.lnk" "$INSTDIR\player.exe" "" "$INSTDIR\player.exe" 0 CreateShortCut "$SMPROGRAMS\rulesPlayer\readme.lnk" "$INSTDIR\readme.txt" "" "$INSTDIR\readme.txt" 0 CreateShortCut "$SMPROGRAMS\rulesPlayer\faq.lnk" "$INSTDIR\faq.txt" "" "$INSTDIR\faq.txt" 0 done: #StrCmp $tvtool "1" eq2 done2 #eq2: #CreateShortCut "$SMPROGRAMS\rulesPlayer\tv tool.lnk" "$INSTDIR\tv" "" "$INSTDIR\tv" 0 done2: SectionEnd Section "-un.Uninstall" #todo: remove any associated files DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\rulesPlayer" DeleteRegKey HKLM "Software\rulesPlayer" Delete "$SMPROGRAMS\rulesPlayer.lnk" RMDir /r "$SMPROGRAMS\rulesPlayer" RMDir /r /REBOOTOK "$INSTDIR" SectionEnd