altoslib: Fix map preloading callbacks, run in separate thread
[fw/altos] / altosui / Instdrv / NSIS / Includes / java.nsh
1 !include WordFunc.nsh
2
3 ; Definitions for Java Detection
4
5 !define JAVA_VERSION "6.0"
6
7 Function GetFileVersion
8         !define GetFileVersion `!insertmacro GetFileVersionCall`
9  
10         !macro GetFileVersionCall _FILE _RESULT
11                 Push `${_FILE}`
12                 Call GetFileVersion
13                 Pop ${_RESULT}
14         !macroend
15  
16         Exch $0
17         Push $1
18         Push $2
19         Push $3
20         Push $4
21         Push $5
22         Push $6
23         ClearErrors
24  
25         GetDllVersion '$0' $1 $2
26         IfErrors error
27         IntOp $3 $1 >> 16
28         IntOp $3 $3 & 0x0000FFFF
29         IntOp $4 $1 & 0x0000FFFF
30         IntOp $5 $2 >> 16
31         IntOp $5 $5 & 0x0000FFFF
32         IntOp $6 $2 & 0x0000FFFF
33         StrCpy $0 '$3.$4.$5.$6'
34         goto end
35  
36         error:
37         SetErrors
38         StrCpy $0 ''
39  
40         end:
41         Pop $6
42         Pop $5
43         Pop $4
44         Pop $3
45         Pop $2
46         Pop $1
47         Exch $0
48 FunctionEnd
49
50 Function openLinkNewWindow
51   Push $3
52   Exch
53   Push $2
54   Exch
55   Push $1
56   Exch
57   Push $0
58   Exch
59  
60   ReadRegStr $0 HKCR "http\shell\open\command" ""
61 # Get browser path
62     DetailPrint $0
63   StrCpy $2 '"'
64   StrCpy $1 $0 1
65   StrCmp $1 $2 +2 # if path is not enclosed in " look for space as final char
66     StrCpy $2 ' '
67   StrCpy $3 1
68   loop:
69     StrCpy $1 $0 1 $3
70     DetailPrint $1
71     StrCmp $1 $2 found
72     StrCmp $1 "" found
73     IntOp $3 $3 + 1
74     Goto loop
75  
76   found:
77     StrCpy $1 $0 $3
78     StrCmp $2 " " +2
79       StrCpy $1 '$1"'
80  
81   Pop $0
82   Exec '$1 $0'
83   Pop $0
84   Pop $1
85   Pop $2
86   Pop $3
87 FunctionEnd
88  
89 !macro _OpenURL URL
90 Push "${URL}"
91 Call openLinkNewWindow
92 !macroend
93  
94 !define OpenURL '!insertmacro "_OpenURL"'
95
96 Function DoDetectJRE
97
98   DetailPrint "Desired Java version ${JAVA_VERSION}"
99
100   SearchPath $0 javaw.exe
101   IfErrors no
102   
103   DetailPrint "Detected java in $0"
104
105   ${GetFileVersion} "$0" $1
106   IfErrors no
107
108   DetailPrint "Java version $1"
109
110   ${VersionCompare} $1 ${JAVA_VERSION} $2
111   IntCmp $2 1 yes yes old
112
113 yes:
114   StrCpy $0 2
115   Goto done
116
117 old:
118   StrCpy $0 1
119   Goto done
120
121 no:
122   StrCpy $0 0
123   Goto done  
124
125 done:
126
127 FunctionEnd
128
129 var dialog
130 var hwnd
131 var null
132
133 var install
134 var quit
135 var skip
136
137 Function GetJRE
138   ${OpenURL} "java.com"
139   MessageBox MB_OK "Click OK to continue after completing the Java Install."
140 FunctionEnd
141
142 Function DetectJRE
143
144   Call DoDetectJRE
145
146   IntCmp $0 1 ask_old ask_no yes
147
148 ask_no:
149   StrCpy $0 "Cannot find Java. Download and install?"
150   Goto ask
151
152 ask_old:
153   StrCpy $0 "Java version appears to be too old. Download and install?"
154   Goto ask
155
156 ask:
157   MessageBox MB_YESNOCANCEL $0 IDYES do_java IDNO skip_java
158
159 do_java:
160   Call GetJRE
161
162
163 skip_java:
164 yes:
165
166 FunctionEnd