diff options
-rw-r--r-- | src/org/connectbot/ConsoleActivity.java | 7 | ||||
-rw-r--r-- | src/org/connectbot/HostListActivity.java | 4 | ||||
-rw-r--r-- | src/org/connectbot/service/TerminalBridge.java | 32 | ||||
-rw-r--r-- | src/org/connectbot/service/TerminalManager.java | 2 |
4 files changed, 24 insertions, 21 deletions
diff --git a/src/org/connectbot/ConsoleActivity.java b/src/org/connectbot/ConsoleActivity.java index 1c605d8..5ca4f4c 100644 --- a/src/org/connectbot/ConsoleActivity.java +++ b/src/org/connectbot/ConsoleActivity.java @@ -96,9 +96,7 @@ public class ConsoleActivity extends Activity { protected Animation slide_left_in, slide_left_out, slide_right_in, slide_right_out, fade_stay_hidden, fade_out; protected MenuItem disconnect, copy, paste, portForward, resize; - - protected boolean requestedDisconnect = false; - + protected boolean copying = false; protected TerminalView copySource = null; @@ -556,8 +554,7 @@ public class ConsoleActivity extends Activity { // disconnect or close the currently visible session TerminalBridge bridge = ((TerminalView)view).bridge; if (bridge.isSessionOpen() || !bridge.isDisconnected()) { - requestedDisconnect = true; - bridge.dispatchDisconnect(); + bridge.dispatchDisconnect(true); } else { // remove this bridge because it's been explicitly closed. closeBridge(bridge); diff --git a/src/org/connectbot/HostListActivity.java b/src/org/connectbot/HostListActivity.java index d7b6372..666a9ef 100644 --- a/src/org/connectbot/HostListActivity.java +++ b/src/org/connectbot/HostListActivity.java @@ -357,7 +357,7 @@ public class HostListActivity extends ListActivity { connect.setEnabled((bridge != null)); connect.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { - bridge.dispatchDisconnect(); + bridge.dispatchDisconnect(true); updateHandler.sendEmptyMessage(-1); return true; } @@ -393,7 +393,7 @@ public class HostListActivity extends ListActivity { public void onClick(DialogInterface dialog, int which) { // make sure we disconnect if(bridge != null) - bridge.dispatchDisconnect(); + bridge.dispatchDisconnect(true); hostdb.deleteHost(host); updateHandler.sendEmptyMessage(-1); diff --git a/src/org/connectbot/service/TerminalBridge.java b/src/org/connectbot/service/TerminalBridge.java index 5acad32..20bcb92 100644 --- a/src/org/connectbot/service/TerminalBridge.java +++ b/src/org/connectbot/service/TerminalBridge.java @@ -301,7 +301,7 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal Log.e(TAG, "Problem in SSH connection thread during authentication", e); // TODO report cause to user: Log.d(TAG, String.format("Cause is: %s", e.getCause().toString())); - dispatchDisconnect(); + dispatchDisconnect(false); return; } @@ -581,7 +581,7 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal if ((newConditions & ChannelCondition.EOF) != 0) { // The other side closed our channel, so let's disconnect. // TODO review whether any tunnel is in use currently. - dispatchDisconnect(); + dispatchDisconnect(false); break; } } catch (IOException e) { @@ -621,7 +621,7 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal /** * Force disconnection of this terminal bridge. */ - public void dispatchDisconnect() { + public void dispatchDisconnect(boolean immediate) { // We don't need to do this multiple times. if (disconnected) return; @@ -640,20 +640,26 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal authenticated = false; sessionOpen = false; + if (immediate) + awaitingClose = true; + // pass notification back up to terminal manager // the manager will do any gui notification if applicable if(disconnectListener != null) disconnectListener.onDisconnected(this); - new Thread(new Runnable() { - public void run() { - boolean result = promptHelper.requestBooleanPrompt("Host has disconnected.\nClose session?"); - if (result) { - awaitingClose = true; - disconnectListener.onDisconnected(TerminalBridge.this); + if (!immediate) { + new Thread(new Runnable() { + public void run() { + boolean result = promptHelper.requestBooleanPrompt("Host has disconnected.\nClose session?"); + if (result) { + awaitingClose = true; + if (disconnectListener != null) + disconnectListener.onDisconnected(TerminalBridge.this); + } } - } - }).start(); + }).start(); + } } public void refreshKeymode() { @@ -801,7 +807,7 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal } catch (IOException ioe) { // Our stdin got blown away, so we must be closed. Log.d(TAG, "Our stdin was closed, dispatching disconnect event"); - dispatchDisconnect(); + dispatchDisconnect(false); } } catch (NullPointerException npe) { Log.d(TAG, "Input before connection established ignored."); @@ -1017,7 +1023,7 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal public void connectionLost(Throwable reason) { // weve lost our ssh connection, so pass along to manager and gui Log.e(TAG, "Somehow our underlying SSH socket died", reason); - dispatchDisconnect(); + dispatchDisconnect(false); } /** diff --git a/src/org/connectbot/service/TerminalManager.java b/src/org/connectbot/service/TerminalManager.java index 78724f1..18c5233 100644 --- a/src/org/connectbot/service/TerminalManager.java +++ b/src/org/connectbot/service/TerminalManager.java @@ -114,7 +114,7 @@ public class TerminalManager extends Service implements BridgeDisconnectedListen // disconnect and dispose of any existing bridges for(TerminalBridge bridge : bridges) - bridge.dispatchDisconnect(); + bridge.dispatchDisconnect(true); if(this.hostdb != null) { this.hostdb.close(); |