- Hide buttons while stopping all

This commit is contained in:
zzz
2012-06-19 20:24:30 +00:00
parent d368937bce
commit 48f29ff1b8
2 changed files with 12 additions and 2 deletions

View File

@ -61,6 +61,7 @@ public class SnarkManager implements Snark.CompleteListener {
private ConnectionAcceptor _connectionAcceptor;
private Thread _monitor;
private volatile boolean _running;
private volatile boolean _stopping;
private final Map<String, Tracker> _trackerMap;
public static final String PROP_I2CP_HOST = "i2psnark.i2cpHost";
@ -164,6 +165,9 @@ public class SnarkManager implements Snark.CompleteListener {
stopAllTorrents(true);
}
/** @since 0.9.1 */
public boolean isStopping() { return _stopping; }
/** hook to I2PSnarkUtil for the servlet */
public I2PSnarkUtil util() { return _util; }
@ -1684,6 +1688,7 @@ public class SnarkManager implements Snark.CompleteListener {
* @since 0.9.1
*/
public void stopAllTorrents(boolean finalShutdown) {
_stopping = true;
if (finalShutdown && _log.shouldLog(Log.WARN))
_log.warn("SnarkManager final shutdown");
int count = 0;
@ -1712,6 +1717,7 @@ public class SnarkManager implements Snark.CompleteListener {
}
} else {
_util.disconnect();
_stopping = false;
addMessage(_("I2P tunnel closed."));
}
}
@ -1722,6 +1728,7 @@ public class SnarkManager implements Snark.CompleteListener {
public void timeReached() {
if (_util.connected()) {
_util.disconnect();
_stopping = false;
addMessage(_("I2P tunnel closed."));
}
}

View File

@ -408,7 +408,9 @@ public class I2PSnarkServlet extends DefaultServlet {
ua.startsWith("Dillo"));
boolean noThinsp = isDegraded || (ua != null && ua.startsWith("Opera"));
if (_manager.util().connected()) {
if (_manager.isStopping()) {
out.write("&nbsp;");
} else if (_manager.util().connected()) {
if (isDegraded)
out.write("<a href=\"/i2psnark/?action=StopAll&amp;nonce=" + _nonce + "\"><img title=\"");
else {
@ -1142,6 +1144,7 @@ public class I2PSnarkServlet extends DefaultServlet {
if (isDegraded)
out.write("</a>");
} else if (!snark.isStarting()) {
if (!_manager.isStopping()) {
// Start Button
// This works in Opera but it's displayed a little differently, so use noThinsp here too so all 3 icons are consistent
if (noThinsp)
@ -1154,7 +1157,7 @@ public class I2PSnarkServlet extends DefaultServlet {
out.write("\">");
if (isDegraded)
out.write("</a>");
}
if (isValid) {
// Remove Button
// Doesnt work with Opera so use noThinsp instead of isDegraded