# Auto-generated by EclipseNSIS Script Wizard # 29.08.2006 15:05:17 Name JonDo SetCompressor /SOLID lzma BrandingText "JonDo - The Privacy Generator" Var secJavaName Var jrename Var detectedJre #!addplugindir NSISPlugins # GetUseableJavaVersion # --> need to decide which java to install # the matrix is as follows: # Win95, Win98, WinNT 4.0 --> JRE 1.3 # all others ---> JRE 1.6 # Returns on top of stack # 1.3 ; or # 1.6 Function GetUsableJavaVersion Push $R0 Push $R1 ClearErrors ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion IfErrors 0 lbl_winnt ; we are not NT ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion" VersionNumber StrCpy $R1 $R0 1 StrCmp $R1 '4' 0 lbl_jre13 StrCpy $R1 $R0 3 StrCmp $R1 '4.0' lbl_jre13 StrCmp $R1 '4.9' lbl_jre15 lbl_jre13 lbl_winnt: StrCpy $R1 $R0 1 StrCmp $R1 '3' lbl_jre13 StrCmp $R1 '4' lbl_jre13 StrCpy $R1 $R0 3 StrCmp $R1 '5.0' lbl_jre15 StrCmp $R1 '5.1' lbl_jre15 StrCmp $R1 '5.2' lbl_jre15 StrCmp $R1 '6.0' lbl_jre15 lbl_jre13 lbl_jre13: StrCpy $R0 '1.3' Goto lbl_done lbl_jre15: Strcpy $R0 '1.5' Goto lbl_done lbl_done: Pop $R1 Exch $R0 FunctionEnd # DetectJava # --> detects if Java is already installed # Returns on top of stack # 2 --> Java >1.2 is available # 1 --> Java 1.1 is available ; or # 0 --> Java is not available # -1 --> Error Function DetectJava #First we try it with the registry... #we look for: HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\'CurrentVersion'\JavaHome ClearErrors ReadRegStr $R0 HKLM "Software\JavaSoft\Java Runtime Environment" CurrentVersion IfErrors lbl_nosunjreinreg 0 StrCpy $R1 "Software\JavaSoft\Java Runtime Environment\$R1" JavaHome IfErrors lbl_nosunjreinreg 0 Push 2 Goto lbl_done lbl_nosunjreinreg: # There was no registry key... Push 0 lbl_done: FunctionEnd # Defines !define REGKEY "SOFTWARE\$(^Name)" !define VERSION 00.010.003 !define COMPANY "JonDos GmbH" !define URL http://www.jondos.de # MUI defines !define MUI_ICON Data\JonDo.ico !define MUI_FINISHPAGE_NOAUTOCLOSE !define MUI_FINISHPAGE_RUN !define MUI_FINISHPAGE_RUN_CHECKED !define MUI_FINISHPAGE_RUN_TEXT $(JonDoStart) !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink" !define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM !define MUI_STARTMENUPAGE_NODISABLE !define MUI_STARTMENUPAGE_REGISTRY_KEY Software\JonDoJAP !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME StartMenuGroup !define MUI_STARTMENUPAGE_DEFAULT_FOLDER JAP !define MUI_UNICON Data\JonDo.ico !define MUI_UNFINISHPAGE_NOAUTOCLOSE !define MUI_LANGDLL_REGISTRY_ROOT HKLM !define MUI_LANGDLL_REGISTRY_KEY ${REGKEY} !define MUI_LANGDLL_REGISTRY_VALUENAME InstallerLanguage # Included files !include Sections.nsh !include MUI.nsh # Reserved Files !insertmacro MUI_RESERVEFILE_LANGDLL ReserveFile "${NSISDIR}\Plugins\AdvSplash.dll" # Variables Var StartMenuGroup #interface configuration !define MUI_HEADERIMAGE !define MUI_HEADERIMAGE_BITMAP_NOSTRETCH !define MUI_HEADERIMAGE_BITMAP "Data\BackgroundJonDo.bmp" !define MUI_ABORTWARNING !define MUI_HEADERIMAGE_RIGHT # Installer pages !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES # Installer languages !insertmacro MUI_LANGUAGE English !insertmacro MUI_LANGUAGE German # Installer attributes OutFile JonDoSetup_optional.exe InstallDir $PROGRAMFILES\JonDo CRCCheck on XPStyle on ShowInstDetails hide VIProductVersion "1.0.0.0" VIAddVersionKey ProductName JonDo VIAddVersionKey ProductVersion "${VERSION}" VIAddVersionKey CompanyName "${COMPANY}" VIAddVersionKey Website "${URL}" VIAddVersionKey FileVersion "${VERSION}" VIAddVersionKey FileDescription "JonDo Setup" VIAddVersionKey LegalCopyright "" InstallDirRegKey HKLM "${REGKEY}" Path ShowUninstDetails hide # Installer sections Section "!JonDo" SEC0000 SetOutPath $INSTDIR SetOverwrite on File "JAP\jap.exe" File "JAP\japdll.dll" File "JAP\JAP.jar" # Georg: JonDo.ico has to be copied as well, because during testing always the JAP-Icon appeared. Probably it is delivered with the jap.exe. The copying and the following creation of the shortcut was the only way to avoid that... File "Data\JonDo.ico" WriteRegStr HKLM "${REGKEY}\Components" Main 1 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application CreateDirectory $SMPROGRAMS\$StartMenuGroup SetOutPath $INSTDIR CreateShortCut "$SMPROGRAMS\$StartMenuGroup\$(^InstallLink).lnk" "$INSTDIR\jap.exe" "--context otherServiceName" "$INSTDIR\JonDo.ico" CreateShortCut "$QUICKLAUNCH\$(^InstallLink).lnk" "$INSTDIR\jap.exe" "--context otherServiceName" "$INSTDIR\JonDo.ico" !insertmacro MUI_STARTMENU_WRITE_END SectionEnd Section /o "Swing" secSwing SetOutPath $INSTDIR SetOverwrite on File "Data\swingall.jar" SectionEnd Section "Java 1.6" secJava SetOutPath $TEMP SetOverwrite on File "Java\jre1.6.offline.exe" ExecWait '"$TEMP\jre1.6.offline.exe"' $0 # Georg: JRE yes, but without a usable Plug-in... DeleteRegKey HKLM "Software\JavaSoft\Java Plug-in" SectionEnd ;-------------------------------- ;Descriptions ;Language strings LangString DESC_SecJAP ${LANG_ENGLISH} "This will install JonDo. You must have installed Java version 1.1 or above." LangString DESC_SecJAP ${LANG_GERMAN} "JonDo. Zum Ausführen von JonDo wird Java Version 1.1 oder höher benötigt." LangString DESC_SecSwing ${LANG_ENGLISH} "This will install the Swing-Library. This library is only necessary if you do not have Java version 1.2 or higher installed." LangString DESC_SecSwing ${LANG_GERMAN} "Die Swing-Bibliothek. Sie ist zum Ausführen von JonDo notwendig und in Java ab Version 1.2 bereits enthalten." LangString DESC_SecJAVA ${LANG_ENGLISH} "The Java Runtime Environment is necessary to run JonDo." LangString DESC_SecJAVA ${LANG_GERMAN} "Die Java Laufzeitumgebung. Diese ist notwendig, um JonDo zu starten." LangString AccountConfig ${LANG_ENGLISH} "Do you want to delete your configuration files and accounts, too?" LangString AccountConfig ${LANG_GERMAN} "Sollen auch die Konfigurationsdateien und Konten entfernt werden?" LangString DeleteFileError ${LANG_ENGLISH} "Some of the installed JonDo files couldn't be deleted!" LangString DeleteFileError ${LANG_GERMAN} "Einige der installierten JonDo-Dateien konnten nicht gelöscht werden!" LangString DeleteUinstError ${LANG_ENGLISH} "The uninstall.exe couldn't be deleted!" LangString DeleteUinstError ${LANG_GERMAN} "Die uninstall.exe konnte nicht gelöscht werden!" LangString DeleteDirError ${LANG_ENGLISH} "The JonDo directory couldn't be deleted!" LangString DeleteDirError ${LANG_GERMAN} "Das JonDo-Installationsverzeichnis konnte nicht gelöscht werden!" LangString JAPJonDoExistence ${LANG_ENGLISH} "JAP/JonDo is still running! Do you want to stop it now?" LangString JAPJonDoExistence ${LANG_GERMAN} "JAP/JonDo läuft noch! Wollen Sie es beenden?" LangString JonDoInstall ${LANG_ENGLISH} "JonDo is already installed! Do you want to uninstall this version first?" LangString JonDoInstall ${LANG_GERMAN} "JonDo ist bereits installiert! Wollen Sie es zuerst deinstallieren?" LangString FindUninstallError ${LANG_ENGLISH} "The uninstall.exe couldn't be found!" LangString FindUninstallError ${LANG_GERMAN} "Die uninstall.exe konnte nicht gefunden werden!" LangString JonDoStart ${LANG_ENGLISH} "Start JonDo" LangString JonDoStart ${LANG_GERMAN} "JonDo starten" LangString JAPInstall ${LANG_ENGLISH} "JAP/JonDo is installed! Do you want to uninstall it first?" LangString JAPInstall ${LANG_GERMAN} "JAP/JonDo ist installiert! Wollen Sie es zuerst deinstallieren?" ;Assign language strings to sections !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${SEC0000} $(DESC_SecJAP) !insertmacro MUI_DESCRIPTION_TEXT ${secSwing} $(DESC_SecSwing) !insertmacro MUI_DESCRIPTION_TEXT ${secJava} $(DESC_SecJAVA) !insertmacro MUI_FUNCTION_DESCRIPTION_END Section -post SEC0001 WriteRegStr HKLM "${REGKEY}" Path $INSTDIR WriteUninstaller $INSTDIR\uninstall.exe !insertmacro MUI_STARTMENU_WRITE_BEGIN Application SetOutPath $SMPROGRAMS\$StartMenuGroup CreateShortCut "$SMPROGRAMS\$StartMenuGroup\$(^UninstallLink).lnk" "$INSTDIR\uninstall.exe" !insertmacro MUI_STARTMENU_WRITE_END WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)" WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}" WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}" WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}" ;WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\uninstall.exe WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\uninstall.exe WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1 WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1 SectionEnd # Macro for selecting uninstaller sections !macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID Push $R0 ReadRegStr $R0 HKLM "${REGKEY}\Components" "${SECTION_NAME}" StrCmp $R0 1 0 next${UNSECTION_ID} !insertmacro SelectSection "${UNSECTION_ID}" GoTo done${UNSECTION_ID} next${UNSECTION_ID}: !insertmacro UnselectSection "${UNSECTION_ID}" done${UNSECTION_ID}: Pop $R0 !macroend # Uninstaller sections Section /o un.JonDo UNSEC0000 Push $5 Push "jap.exe" processwork::existsprocess Pop $5 IntCmp $5 0 done MessageBox MB_YESNO $(JAPJonDoExistence) IDYES true IDNO false true: FindWindow $0 "" "JAP / JonDo" IntCmp $0 0 done SendMessage $0 ${WM_CLOSE} 0 0 Goto done false: # Georg: It works just once, but this should be enough... SendMessage $HWNDPARENT "0x408" "-1" "0" Abort done: MessageBox MB_YESNO $(AccountConfig) IDYES ok IDNO notok ok: ExecWait '"$INSTDIR\jap.exe" --uninstall' notok: ClearErrors Delete $INSTDIR\jap.exe Delete $INSTDIR\JAP.jar Delete $INSTDIR\swingall.jar Delete $INSTDIR\japdll.dll Delete $INSTDIR\JonDo.ico IfErrors 0 +2 MessageBox MB_OK $(DeleteFileError) Delete $QUICKLAUNCH\$(^InstallLink).lnk DeleteRegValue HKLM "${REGKEY}\Components" Main SectionEnd Section un.post UNSEC0001 DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" ClearErrors Delete $INSTDIR\uninstall.exe IfErrors 0 +2 MessageBox MB_OK $(DeleteUinstError) DeleteRegValue HKLM "${REGKEY}" StartMenuGroup DeleteRegValue HKLM "${REGKEY}" Path DeleteRegKey /ifempty HKLM "${REGKEY}\Components" DeleteRegKey /ifempty HKLM "${REGKEY}" DeleteRegKey HKLM "Software\JonDoJAP" # Georg: This will delete the links as well... RMDir /r /REBOOTOK $SMPROGRAMS\$StartMenuGroup\$(^Name) ClearErrors RMDir /r $INSTDIR IfErrors 0 +2 MessageBox MB_OK $(DeleteDirError) SectionEnd Function DetectJAPJonDo ClearErrors ReadRegStr $1 HKLM "Software\JonDo\Components" Main IfErrors JAPtest 0 MessageBox MB_YESNO $(JonDoInstall) IDYES yepJonDo IDNO JAPtest yepJonDo: ClearErrors ExecWait "$INSTDIR\uninstall.exe" IfErrors 0 +2 MessageBox MB_OK $(FindUninstallError) JAPtest: ReadRegStr $1 HKLM "Software\JAP\Components" Main IfErrors EndIt 0 MessageBox MB_YESNO $(JAPInstall) IDYES yepJAP IDNO EndIt yepJAP: ClearErrors ExecWait "$PROGRAMFILES\JAP\uninstall.exe" IfErrors 0 +2 MessageBox MB_OK $(FindUninstallError) EndIt: FunctionEnd Function LaunchLink Exec '"$INSTDIR\jap.exe" --context otherServiceName' FunctionEnd # Installer functions Function .onInit InitPluginsDir Push $R1 File /oname=$PLUGINSDIR\spltmp.bmp Data\splash.bmp advsplash::show 1000 600 400 -1 $PLUGINSDIR\spltmp Pop $R1 Pop $R1 !insertmacro MUI_LANGDLL_DISPLAY Call GetUsableJavaVersion Pop $R0 StrCpy $secJavaName "Java $R0" StrCpy $jrename "jre$R0.exe" Call DetectJava Pop $detectedJre #Initial Situation: # - Java is selected # - Swing is deselected IntCmp $detectedJre 0 lbl_done lbl_done lbl_deselect_java # If no JRE found (or Error) --> changes nothing # If JRE detected --> deselect Java... lbl_deselect_java: !insertmacro UnselectSection ${secJava} IntCmp $detectedJre 1 lbl_select_swing lbl_done lbl_done # ...and check if Swing is needed (Java 1.1!) # If Java 1.1 --> select Swing lbl_select_swing: !insertmacro SelectSection ${secSwing} lbl_done: Call DetectJAPJonDo FunctionEnd #Selection change event #if java is selected --> deselect Swing Function .onSelChange SectionGetFlags ${secJava} $0 IntOp $0 $0 & 1 IntCmp $0 1 lbl_unselect lbl_done lbl_done lbl_unselect: !insertmacro UnselectSection ${secSwing} lbl_done: FunctionEnd # Uninstaller functions Function un.onInit # Georg: Just in case you want to delete your old JonDo while you're installing a new version, you want to be sure that you have the uninstall-window in front of the install-window. That's why... BringToFront ReadRegStr $INSTDIR HKLM "${REGKEY}" Path ReadRegStr $StartMenuGroup HKLM "${REGKEY}" StartMenuGroup !insertmacro MUI_UNGETLANGUAGE !insertmacro SELECT_UNSECTION Main ${UNSEC0000} FunctionEnd # Installer Language Strings LangString ^UninstallLink ${LANG_GERMAN} "Lösche $(^Name)" LangString ^UninstallLink ${LANG_ENGLISH} "Uninstall $(^Name)" LangString ^InstallLink ${LANG_GERMAN} "Starte $(^Name)" LangString ^InstallLink ${LANG_ENGLISH} "Start $(^Name)"