Richard Alam 2015-03-25 21:14:48 +00:00 committed by Felipe Cecagno
parent 7a0e75ace3
commit c63c371e7b
2 changed files with 130 additions and 73 deletions

View File

@ -44,3 +44,102 @@ function stopApplet(){
function appletStartupCallback() {
BBB.javaAppletLaunched();
}
function getHighestJavaVersion(javas) {
var highestJava = javas[0];
console.log("highestJava = [" + highestJava + "]");
for (j = 0; j < javas.length; j++) {
var java = javas[j];
console.log("java[" + j + "]=[" + java + "]");
var highest = highestJava.split(".");
console.log(highest);
var iter = java.split(".");
console.log(iter);
if (parseInt(iter[0]) > parseInt(highest[0])) {
highestJava = java;
} else if (parseInt(iter[0]) == parseInt(highest[0]) && parseInt(iter[1]) > parseInt(highest[1])) {
highestJava = java;
console.log(highestJava);
} else if (parseInt(iter[0]) == parseInt(highest[0]) && parseInt(iter[1]) == parseInt(highest[1])) {
var iterMinor = parseInt((iter[2]).split("_")[1]);
var highestMinor = parseInt((highest[2]).split("_")[1]);
if (iterMinor > highestMinor) {
highestJava = java;
console.log(highestJava);
}
}
}
return highestJava;
}
function getIcedTeaWebVersion() {
for (i = 0; i < navigator.plugins.length; i++) {
var matches;
if (matches = navigator.plugins[i].name.match(/using IcedTea-Web ([0-9.]+)/)) {
return matches[1];
}
}
return null;
}
function isJavaVersionOk(installedVersion, minVersion) {
var required = minVersion.split(".");
highest = installedVersion.split(".");
if (parseInt(required[0]) > parseInt(highest[0])) {
console.log("older major version=[" + installedVersion + "]");
return {result: "JAVA_OLDER", version: installedVersion};
} else if (parseInt(required[0]) == parseInt(highest[0]) && parseInt(required[1]) > parseInt(highest[1])) {
console.log("older minor version=[" + installedVersion + "]");
return {result: "JAVA_OLDER", version: installedVersion};
} else if (parseInt(required[0]) == parseInt(highest[0]) && parseInt(required[1]) == parseInt(highest[1])) {
var requiredMinor = parseInt((required[2]).split("_")[1]);
var highestJavaMinor = parseInt((highest[2]).split("_")[1]);
if (requiredMinor > highestJavaMinor) {
console.log("older update version=[" + installedVersion + "]");
return {result: "JAVA_OLDER", version: installedVersion};
}
}
return {result: "JAVA_OK"};
}
function isIcedTeaVersionOkLinux(installedVersion, minVersion) {
var required = minVersion.split(".");
highest = installedVersion.split(".");
if (parseInt(required[0]) > parseInt(highest[0])) {
console.log("ice: older major version=[" + installedVersion + "]");
return {result: "JAVA_OLDER", version: installedVersion};
} else if (parseInt(required[0]) == parseInt(highest[0]) && parseInt(required[1]) > parseInt(highest[1])) {
console.log("ice: older minor version=[" + installedVersion + "]");
return {result: "JAVA_OLDER", version: installedVersion};
}
return {result: "JAVA_OK"};
}
function checkJavaVersion(minJavaVersion) {
var javas = deployJava.getJREs();
var highestJavaVersion = null;
if (javas == null || javas.length == 0) {
if (javas == null) {
return {result:"JAVA_NOT_DETECTED"};
}
if (javas.length == 0) {
return {result: "JAVA_NOT_INSTALLED"};
}
} else {
var highestJavaVersion = getHighestJavaVersion(javas);
var isOk = isJavaVersionOk(highestJavaVersion, minJavaVersion);
if (isOk.result === "JAVA_OLDER") {
highestJavaVersion = getIcedTeaWebVersion();
return isIcedTeaVersionOkLinux(highestJavaVersion, "1.5.0");
} else {
return isOk;
}
}
}

View File

@ -27,78 +27,36 @@ package org.bigbluebutton.modules.deskshare.utils
import org.bigbluebutton.main.events.ClientStatusEvent;
import org.bigbluebutton.util.i18n.ResourceUtil;
public class JavaCheck {
public static function checkJava():String {
var dispatcher : Dispatcher = new Dispatcher();
var java_version:String = "1.7.0_51";
var xml:XML = BBB.initConfigManager().config.browserVersions;
if (xml.@java != undefined) {
java_version = xml.@java.toString();
}
try {
var javas : Array = JavaCheck.getJREs();
} catch ( e : Error ) {
dispatcher.dispatchEvent(new ClientStatusEvent(ClientStatusEvent.FAIL_MESSAGE_EVENT, ResourceUtil.getInstance().getString("bbb.clientstatus.java.title"), ResourceUtil.getInstance().getString("bbb.clientstatus.java.notdetected")));
return ResourceUtil.getInstance().getString("bbb.clientstatus.java.notdetected");
}
if (javas.length == 0) {
dispatcher.dispatchEvent(new ClientStatusEvent(ClientStatusEvent.FAIL_MESSAGE_EVENT, ResourceUtil.getInstance().getString("bbb.clientstatus.java.title"), ResourceUtil.getInstance().getString("bbb.clientstatus.java.notinstalled")));
return ResourceUtil.getInstance().getString("bbb.clientstatus.java.notinstalled");
}
var highestJava : String = javas[0];
for each (var java : String in javas) {
var highest : Array = highestJava.split(".");
var iter : Array = java.split(".");
if (Number(iter[0]) > Number(highest[0])) {
highestJava = java;
} else if (Number(iter[0]) == Number(highest[0]) && Number(iter[1]) > Number(highest[1])) {
highestJava = java;
} else if (Number(iter[0]) == Number(highest[0]) && Number(iter[1]) == Number(highest[1])) {
var iterMinor : Number = Number((iter[2] as String).split("_")[1]);
var highestMinor : Number = Number((highest[2] as String).split("_")[1]);
if (iterMinor > highestMinor)
{
highestJava = java;
}
}
}
var passedJava : Boolean = true;
var required : Array = java_version.split(".");
highest = highestJava.split(".");
if (Number(required[0]) > Number(highest[0])) {
passedJava = false;
} else if (Number(required[0]) == Number(highest[0]) && Number(required[1]) > Number(highest[1])) {
passedJava = false;
} else if (Number(required[0]) == Number(highest[0]) && Number(required[1]) == Number(highest[1])) {
var requiredMinor : Number = Number((required[2] as String).split("_")[1]);
var highestJavaMinor : Number = Number((highest[2] as String).split("_")[1]);
if (requiredMinor > highestJavaMinor)
{
passedJava = false;
}
}
if (!passedJava) {
dispatcher.dispatchEvent(new ClientStatusEvent(ClientStatusEvent.FAIL_MESSAGE_EVENT, ResourceUtil.getInstance().getString("bbb.clientstatus.java.title"), ResourceUtil.getInstance().getString("bbb.clientstatus.java.oldversion")));
return ResourceUtil.getInstance().getString("bbb.clientstatus.java.oldversion");
} else {
// Java success
return null;
}
}
private static function getJREs():Array{
var installedJREs:Array = ExternalInterface.call("deployJava.getJREs");
if (installedJREs == null) throw new Error("Javascript files not found.");
return installedJREs;
}
public class JavaCheck {
public static function checkJava():String {
var dispatcher : Dispatcher = new Dispatcher();
var java_version:String = "1.7.0_51";
var xml:XML = BBB.initConfigManager().config.browserVersions;
if (xml.@java != undefined) {
java_version = xml.@java.toString();
}
var isJavaOk: Object = checkJavaVersion(java_version);
if (isJavaOk.result == "JAVA_OK") {
// Java success
return null;
} else if (isJavaOk.result == "JAVA_NOT_INSTALLED") {
dispatcher.dispatchEvent(new ClientStatusEvent(ClientStatusEvent.FAIL_MESSAGE_EVENT, ResourceUtil.getInstance().getString("bbb.clientstatus.java.title"), ResourceUtil.getInstance().getString("bbb.clientstatus.java.notinstalled")));
return ResourceUtil.getInstance().getString("bbb.clientstatus.java.notinstalled");
} else if (isJavaOk.result == "JAVA_OLDER") {
dispatcher.dispatchEvent(new ClientStatusEvent(ClientStatusEvent.FAIL_MESSAGE_EVENT, ResourceUtil.getInstance().getString("bbb.clientstatus.java.title"), ResourceUtil.getInstance().getString("bbb.clientstatus.java.oldversion")));
return ResourceUtil.getInstance().getString("bbb.clientstatus.java.oldversion");
} else {
dispatcher.dispatchEvent(new ClientStatusEvent(ClientStatusEvent.FAIL_MESSAGE_EVENT, ResourceUtil.getInstance().getString("bbb.clientstatus.java.title"), ResourceUtil.getInstance().getString("bbb.clientstatus.java.notdetected")));
return ResourceUtil.getInstance().getString("bbb.clientstatus.java.notdetected");
}
}
private static function checkJavaVersion(minVersion: String):Object {
return ExternalInterface.call("checkJavaVersion", minVersion);
}
}
}