X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosui%2FInstdrv%2FNSIS%2FIncludes%2Fjava.nsh;h=a457562b334df59214783119a4816035dfda0309;hp=ebf1c5b96071223146a54f441ed021ecd1884557;hb=25cdbf15e7284eb963070b28dd886aa299af6487;hpb=bd440afc2a6e37b74fffcf1b977e149485095316 diff --git a/altosui/Instdrv/NSIS/Includes/java.nsh b/altosui/Instdrv/NSIS/Includes/java.nsh index ebf1c5b9..a457562b 100644 --- a/altosui/Instdrv/NSIS/Includes/java.nsh +++ b/altosui/Instdrv/NSIS/Includes/java.nsh @@ -2,49 +2,165 @@ ; Definitions for Java Detection -!define JRE_VERSION "1.6" -!define JRE32_URL "http://javadl.sun.com/webapps/download/AutoDL?BundleId=52247&/jre-6u27-windows-i586.exe" -!define JRE64_URL "http://javadl.sun.com/webapps/download/AutoDL?BundleId=52249&/jre-6u27-windows-x64.exe" +!define JAVA_VERSION "6.0" -Var JavaDownload -Var JavaBits +Function GetFileVersion + !define GetFileVersion `!insertmacro GetFileVersionCall` + + !macro GetFileVersionCall _FILE _RESULT + Push `${_FILE}` + Call GetFileVersion + Pop ${_RESULT} + !macroend + + Exch $0 + Push $1 + Push $2 + Push $3 + Push $4 + Push $5 + Push $6 + ClearErrors + + GetDllVersion '$0' $1 $2 + IfErrors error + IntOp $3 $1 >> 16 + IntOp $3 $3 & 0x0000FFFF + IntOp $4 $1 & 0x0000FFFF + IntOp $5 $2 >> 16 + IntOp $5 $5 & 0x0000FFFF + IntOp $6 $2 & 0x0000FFFF + StrCpy $0 '$3.$4.$5.$6' + goto end + + error: + SetErrors + StrCpy $0 '' + + end: + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Exch $0 +FunctionEnd + +Function openLinkNewWindow + Push $3 + Exch + Push $2 + Exch + Push $1 + Exch + Push $0 + Exch + + ReadRegStr $0 HKCR "http\shell\open\command" "" +# Get browser path + DetailPrint $0 + StrCpy $2 '"' + StrCpy $1 $0 1 + StrCmp $1 $2 +2 # if path is not enclosed in " look for space as final char + StrCpy $2 ' ' + StrCpy $3 1 + loop: + StrCpy $1 $0 1 $3 + DetailPrint $1 + StrCmp $1 $2 found + StrCmp $1 "" found + IntOp $3 $3 + 1 + Goto loop + + found: + StrCpy $1 $0 $3 + StrCmp $2 " " +2 + StrCpy $1 '$1"' + + Pop $0 + Exec '$1 $0' + Pop $0 + Pop $1 + Pop $2 + Pop $3 +FunctionEnd + +!macro _OpenURL URL +Push "${URL}" +Call openLinkNewWindow +!macroend + +!define OpenURL '!insertmacro "_OpenURL"' + +Function DoDetectJRE + + DetailPrint "Desired Java version ${JAVA_VERSION}" + + SearchPath $0 javaw.exe + IfErrors no + + DetailPrint "Detected java in $0" + + ${GetFileVersion} "$0" $1 + IfErrors no + + DetailPrint "Java version $1" + + ${VersionCompare} $1 ${JAVA_VERSION} $2 + IntCmp $2 1 yes yes old + +yes: + StrCpy $0 2 + Goto done + +old: + StrCpy $0 1 + Goto done + +no: + StrCpy $0 0 + Goto done + +done: + +FunctionEnd + +var dialog +var hwnd +var null + +var install +var quit +var skip Function GetJRE - ${If} ${RunningX64} - StrCpy $JavaDownload ${JRE64_URL} - StrCpy $JavaBits "64" - ${Else} - StrCpy $JavaDownload ${JRE32_URL} - StrCpy $JavaBits "32" - ${EndIf} - - MessageBox MB_OK "This product uses Java ${JRE_VERSION}, \ - $JavaBits bits, it will now \ - be downloaded and installed" - - StrCpy $2 "$TEMP\Java Runtime Environment.exe" - nsisdl::download /TIMEOUT=30000 $JavaDownload $2 - Pop $R0 ;Get the return value - StrCmp $R0 "success" +3 - MessageBox MB_OK "Download failed: $R0" - Quit - ExecWait $2 - Delete $2 + ${OpenURL} "java.com" + MessageBox MB_OK "Click OK to continue after completing the Java Install." FunctionEnd Function DetectJRE - ReadRegStr $2 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" \ - "CurrentVersion" - DetailPrint "Desired Java version ${JRE_VERSION}" - DetailPrint "Actual Java version $2" + Call DoDetectJRE + + IntCmp $0 1 ask_old ask_no yes + +ask_no: + StrCpy $0 "Cannot find Java. Download and install?" + Goto ask - ${VersionCompare} $2 ${JRE_VERSION} $3 +ask_old: + StrCpy $0 "Java version appears to be too old. Download and install?" + Goto ask - IntCmp $3 1 done done +ask: + MessageBox MB_YESNOCANCEL $0 IDYES do_java IDNO skip_java +do_java: Call GetJRE -done: + +skip_java: +yes: FunctionEnd