Fix Bongacams login in external browser
This commit is contained in:
parent
f04681a8be
commit
dfb1083c45
|
@ -31,7 +31,8 @@ public class ExternalBrowser implements AutoCloseable {
|
|||
private Socket socket;
|
||||
private Thread reader;
|
||||
private volatile boolean stopped = true;
|
||||
private Object ready = new Object();
|
||||
private volatile boolean browserReady = false;
|
||||
private Object browserReadyLock = new Object();
|
||||
|
||||
public static ExternalBrowser getInstance() {
|
||||
return INSTANCE;
|
||||
|
@ -46,14 +47,22 @@ public class ExternalBrowser implements AutoCloseable {
|
|||
|
||||
addProxyConfig(jsonConfig.getJSONObject("config"));
|
||||
|
||||
p = new ProcessBuilder(OS.getBrowserCommand()).start();
|
||||
if (LOG.isTraceEnabled()) {
|
||||
p = new ProcessBuilder(OS.getBrowserCommand("--enable-logging")).start();
|
||||
new StreamRedirectThread(p.getInputStream(), System.err);
|
||||
new StreamRedirectThread(p.getErrorStream(), System.err);
|
||||
} else {
|
||||
p = new ProcessBuilder(OS.getBrowserCommand()).start();
|
||||
new StreamRedirectThread(p.getInputStream(), OutputStream.nullOutputStream());
|
||||
new StreamRedirectThread(p.getErrorStream(), OutputStream.nullOutputStream());
|
||||
}
|
||||
LOG.debug("Browser started");
|
||||
|
||||
connectToRemoteControlSocket();
|
||||
synchronized (ready) {
|
||||
ready.wait();
|
||||
while (!browserReady) {
|
||||
synchronized (browserReadyLock) {
|
||||
browserReadyLock.wait(100);
|
||||
}
|
||||
}
|
||||
if(LOG.isTraceEnabled()) {
|
||||
LOG.debug("Connected to remote control server. Sending config {}", jsonConfig);
|
||||
|
@ -129,8 +138,9 @@ public class ExternalBrowser implements AutoCloseable {
|
|||
try {
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
||||
String line;
|
||||
synchronized (ready) {
|
||||
ready.notify();
|
||||
synchronized (browserReadyLock) {
|
||||
browserReady = true;
|
||||
browserReadyLock.notifyAll();
|
||||
}
|
||||
while( !Thread.interrupted() && (line = br.readLine()) != null ) {
|
||||
LOG.debug("Browser output: {}", line);
|
||||
|
@ -145,6 +155,12 @@ public class ExternalBrowser implements AutoCloseable {
|
|||
if(!stopped) {
|
||||
LOG.error("Couldn't read browser output", e);
|
||||
}
|
||||
} finally {
|
||||
stopped = true;
|
||||
synchronized (browserReadyLock) {
|
||||
browserReady = true;
|
||||
browserReadyLock.notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,12 +59,12 @@ public class BongaCamsElectronLoginDialog {
|
|||
Thread.sleep(500);
|
||||
String username = Config.getInstance().getSettings().bongaUsername;
|
||||
if (username != null && !username.trim().isEmpty()) {
|
||||
browser.executeJavaScript("$('input[name=\"log_in[username]\"]').attr('value','" + username + "')");
|
||||
browser.executeJavaScript("document.getElementById('log_in_username').value = '" + username + "';");
|
||||
}
|
||||
String password = Config.getInstance().getSettings().bongaPassword;
|
||||
if (password != null && !password.trim().isEmpty()) {
|
||||
password = password.replace("'", "\\'");
|
||||
browser.executeJavaScript("$('input[name=\"log_in[password]\"]').attr('value','" + password + "')");
|
||||
browser.executeJavaScript("document.getElementById('log_in_password').value = '" + password + "';");
|
||||
}
|
||||
String[] simplify = new String[] {
|
||||
"$('div#header').css('display','none');",
|
||||
|
|
Loading…
Reference in New Issue