Fix for issues 567 and also remove multiple calls to beef.browser.hasJava() from /beef/core/main/client/net/local.js

This commit is contained in:
Keith Lee
2012-03-07 01:41:27 +08:00
parent 95f7e92011
commit 97672966df
5 changed files with 70 additions and 13 deletions

View File

@@ -21,6 +21,8 @@
beef.net.local = {
sock: false,
checkJava: false,
hasJava: false,
/**
* Initializes the java socket. We have to use this method because
@@ -29,16 +31,30 @@ beef.net.local = {
* is invalid:
* sock: new java.net.Socket();
*/
initializeSocket: function() {
if(! beef.browser.hasJava()) return -1;
try {
this.sock = new java.net.Socket();
} catch(e) {
return -1;
if(this.checkJava){
if(!beef.browser.hasJava()) {
this.checkJava=True;
this.hasJava=False;
return -1;
}else{
this.checkJava=True;
this.hasJava=True;
return 1;
}
}
else{
if(!this.hasJava) return -1;
else{
try {
this.sock = new java.net.Socket();
} catch(e) {
return -1;
}
return 1;
}
}
return 1;
},
/**
@@ -47,7 +63,7 @@ beef.net.local = {
* @error: return -1 if the internal ip cannot be retrieved.
*/
getLocalAddress: function() {
if(! beef.browser.hasJava()) return false;
if(!this.hasJava) return false;
this.initializeSocket();
@@ -65,7 +81,7 @@ beef.net.local = {
* @error: return -1 if the hostname cannot be retrieved.
*/
getLocalHostname: function() {
if(! beef.browser.hasJava()) return false;
if(!this.hasJava) return false;
this.initializeSocket();
@@ -79,4 +95,4 @@ beef.net.local = {
};
beef.regCmp('beef.net.local');
beef.regCmp('beef.net.local');