Create two new events to signal enabling and disabling of transports

This commit is contained in:
Torsten Grote
2015-12-16 13:48:56 -02:00
parent c7e4d5ffa9
commit 2d28dcada2
14 changed files with 132 additions and 18 deletions

View File

@@ -172,7 +172,7 @@ class DroidtoothPlugin implements DuplexPlugin {
}
LOG.info("Socket bound");
socket = ss;
callback.pollNow();
callback.transportEnabled();
acceptContactConnections();
}
});
@@ -196,6 +196,8 @@ class DroidtoothPlugin implements DuplexPlugin {
if (ss != null) ss.close();
} catch (IOException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} finally {
callback.transportDisabled();
}
}

View File

@@ -391,6 +391,8 @@ class TorPlugin implements DuplexPlugin, EventHandler,
if (ss != null) ss.close();
} catch (IOException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} finally {
callback.transportDisabled();
}
}
@@ -459,7 +461,10 @@ class TorPlugin implements DuplexPlugin, EventHandler,
private void enableNetwork(boolean enable) throws IOException {
if (!running) return;
if (LOG.isLoggable(INFO)) LOG.info("Enabling network: " + enable);
if (!enable) circuitBuilt.set(false);
if (!enable) {
circuitBuilt.set(false);
callback.transportDisabled();
}
networkEnabled = enable;
controlConnection.setConf("DisableNetwork", enable ? "0" : "1");
}
@@ -549,7 +554,7 @@ class TorPlugin implements DuplexPlugin, EventHandler,
public void circuitStatus(String status, String id, String path) {
if (status.equals("BUILT") && !circuitBuilt.getAndSet(true)) {
LOG.info("First circuit built");
if (isRunning()) callback.pollNow();
if (isRunning()) callback.transportEnabled();
}
}
@@ -567,7 +572,7 @@ class TorPlugin implements DuplexPlugin, EventHandler,
if (LOG.isLoggable(INFO)) LOG.info(severity + " " + msg);
if (severity.equals("NOTICE") && msg.startsWith("Bootstrapped 100%")) {
bootstrapped = true;
if (isRunning()) callback.pollNow();
if (isRunning()) callback.transportEnabled();
}
}