diff options
author | Kenny Root <kenny@the-b.org> | 2008-11-18 21:00:10 +0000 |
---|---|---|
committer | Kenny Root <kenny@the-b.org> | 2008-11-18 21:00:10 +0000 |
commit | 8781fd2b9fbc560238ccec6b1d45dee3209f49b1 (patch) | |
tree | a1ccfe21f265199d6fb3c7077dc1636f4dbae1f8 /src/org | |
parent | 2066c47a3624c05979ee84822043d62bd2983bc6 (diff) | |
download | connectbot-8781fd2b9fbc560238ccec6b1d45dee3209f49b1.tar.gz connectbot-8781fd2b9fbc560238ccec6b1d45dee3209f49b1.tar.bz2 connectbot-8781fd2b9fbc560238ccec6b1d45dee3209f49b1.zip |
* Handle not-yet-connected hosts correctly
* Fix annoying pre-connection row movement bug when resizing to a larger number of rows.
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/connectbot/ConsoleActivity.java | 30 | ||||
-rw-r--r-- | src/org/connectbot/service/TerminalBridge.java | 74 |
2 files changed, 66 insertions, 38 deletions
diff --git a/src/org/connectbot/ConsoleActivity.java b/src/org/connectbot/ConsoleActivity.java index 9015c35..8ab2890 100644 --- a/src/org/connectbot/ConsoleActivity.java +++ b/src/org/connectbot/ConsoleActivity.java @@ -228,6 +228,11 @@ public class ConsoleActivity extends Activity { break; } } + + // If we just closed the last bridge, go back to the previous activity. + if (flip.getChildCount() == 0) { + finish(); + } } protected void createPortForward(TerminalView target, String nickname, String type, String source, String dest) { @@ -531,15 +536,17 @@ public class ConsoleActivity extends Activity { final boolean activeTerminal = (view instanceof TerminalView); boolean authenticated = false; boolean sessionOpen = false; + boolean disconnected = false; if (activeTerminal) { authenticated = ((TerminalView) view).bridge.isAuthenticated(); sessionOpen = ((TerminalView) view).bridge.isSessionOpen(); + disconnected = ((TerminalView) view).bridge.isDisconnected(); } disconnect = menu.add(R.string.console_menu_disconnect); - if (!sessionOpen) + if (!sessionOpen && disconnected) disconnect.setTitle(R.string.console_menu_close); disconnect.setEnabled(activeTerminal); disconnect.setIcon(android.R.drawable.ic_menu_close_clear_cancel); @@ -547,7 +554,7 @@ public class ConsoleActivity extends Activity { public boolean onMenuItemClick(MenuItem item) { // disconnect or close the currently visible session TerminalBridge bridge = ((TerminalView)view).bridge; - if (bridge.isSessionOpen()) { + if (bridge.isSessionOpen() || !bridge.isDisconnected()) { requestedDisconnect = true; bridge.dispatchDisconnect(); } else { @@ -637,13 +644,15 @@ public class ConsoleActivity extends Activity { boolean activeTerminal = (view instanceof TerminalView); boolean authenticated = false; boolean sessionOpen = false; + boolean disconnected = false; if (activeTerminal) { authenticated = ((TerminalView)view).bridge.isAuthenticated(); sessionOpen = ((TerminalView)view).bridge.isSessionOpen(); + disconnected = ((TerminalView)view).bridge.isDisconnected(); } disconnect.setEnabled(activeTerminal); - if (sessionOpen) + if (sessionOpen || !disconnected) disconnect.setTitle(R.string.console_menu_disconnect); else disconnect.setTitle(R.string.console_menu_close); @@ -682,14 +691,15 @@ public class ConsoleActivity extends Activity { } protected void shiftLeft() { + // Only show animation if there is something else to go to. + if (flip.getChildCount() <= 1) + return; + // keep current overlay from popping up again View overlay = findCurrentView(R.id.terminal_overlay); if(overlay != null) overlay.startAnimation(fade_stay_hidden); - // Only show animation if there is something else to go to. - if (flip.getChildCount() > 1) - flip.setInAnimation(slide_left_in); - + flip.setInAnimation(slide_left_in); flip.setOutAnimation(slide_left_out); flip.showNext(); ConsoleActivity.this.updateDefault(); @@ -702,7 +712,10 @@ public class ConsoleActivity extends Activity { } protected void shiftRight() { - + // Only show animation if there is something else to go to. + if (flip.getChildCount() <= 1) + return; + // keep current overlay from popping up again View overlay = findCurrentView(R.id.terminal_overlay); if(overlay != null) overlay.startAnimation(fade_stay_hidden); @@ -717,7 +730,6 @@ public class ConsoleActivity extends Activity { if(overlay != null) overlay.startAnimation(fade_out); updatePromptVisible(); - } /** diff --git a/src/org/connectbot/service/TerminalBridge.java b/src/org/connectbot/service/TerminalBridge.java index ad60450..eb93f23 100644 --- a/src/org/connectbot/service/TerminalBridge.java +++ b/src/org/connectbot/service/TerminalBridge.java @@ -141,13 +141,39 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal private boolean authenticated = false; private boolean sessionOpen = false; - protected boolean disconnectFlag = false; + private boolean disconnected = false; private boolean awaitingClose = false; private boolean forcedSize = false; private int termWidth; private int termHeight; + public String keymode = null; + + public KeyCharacterMap keymap = KeyCharacterMap.load(KeyCharacterMap.BUILT_IN_KEYBOARD); + + public int charWidth = -1; + + public int charHeight = -1; + + public int charDescent = -1; + + protected float fontSize = -1; + + /** + * Flag indicating if we should perform a full-screen redraw during our next + * rendering pass. + */ + protected boolean fullRedraw = false; + + public long drawTolerance = 100; + + public long lastDraw = 0; + + public PromptHelper promptHelper; + + protected BridgeDisconnectedListener disconnectListener = null; + public class HostKeyVerifier implements ServerHostKeyVerifier { public boolean verifyServerHostKey(String hostname, int port, String serverHostKeyAlgorithm, byte[] serverHostKey) throws Exception { @@ -200,8 +226,6 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal } - public PromptHelper promptHelper; - /** * Create new terminal bridge with following parameters. We will immediately * launch thread to start SSH connection and handle any hostkey verification @@ -250,7 +274,6 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal } }; - buffer.setScreenSize(TERM_WIDTH_CHARS, TERM_HEIGHT_CHARS, true); buffer.setBufferSize(scrollback); buffer.setDisplay(this); buffer.setCursorPosition(0, 0); @@ -277,12 +300,14 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal } catch (IOException e) { Log.e(TAG, "Problem in SSH connection thread during authentication", e); Log.d(TAG, String.format("Cause is: %s", e.getCause().toString())); + dispatchDisconnect(); + return; } try { // enter a loop to keep trying until authentication int tries = 0; - while(!connection.isAuthenticationComplete() && tries++ < AUTH_TRIES && !disconnectFlag) { + while(!connection.isAuthenticationComplete() && tries++ < AUTH_TRIES && !disconnected) { handleAuthentication(); // sleep to make sure we dont kill system @@ -583,8 +608,6 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal return sessionOpen; } - protected BridgeDisconnectedListener disconnectListener = null; - public void setOnDisconnectedListener(BridgeDisconnectedListener disconnectListener) { this.disconnectListener = disconnectListener; } @@ -594,7 +617,7 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal */ public void dispatchDisconnect() { // We don't need to do this multiple times. - if (disconnectFlag) + if (disconnected) return; // disconnection request hangs if we havent really connected to a host yet @@ -607,7 +630,7 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal } }).start(); - disconnectFlag = true; + disconnected = true; authenticated = false; sessionOpen = false; @@ -627,14 +650,10 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal }).start(); } - public String keymode = null; - public void refreshKeymode() { keymode = manager.getKeyMode(); } - public KeyCharacterMap keymap = KeyCharacterMap.load(KeyCharacterMap.BUILT_IN_KEYBOARD); - /** * Handle onKey() events coming down from a {@link TerminalView} above us. * We might collect these for our internal buffer when working with hostkeys @@ -661,7 +680,7 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal boolean printing = (keymap.isPrintingKey(keyCode) || keyCode == KeyEvent.KEYCODE_SPACE); // skip keys if we aren't connected yet or have been disconnected - if(disconnectFlag || session == null) + if(disconnected || session == null) return false; // otherwise pass through to existing session @@ -783,12 +802,6 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal } - public int charWidth = -1, - charHeight = -1, - charDescent = -1; - - protected float fontSize = -1; - /** * Request a different font size. Will make call to parentChanged() to make * sure we resize PTY if needed. @@ -812,12 +825,6 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal } /** - * Flag indicating if we should perform a full-screen redraw during our next - * rendering pass. - */ - protected boolean fullRedraw = false; - - /** * Something changed in our parent {@link TerminalView}, maybe it's a new * parent, or maybe it's an updated font size. We should recalculate * terminal size information and request a PTY resize. @@ -872,7 +879,12 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal try { // request a terminal pty resize + int prevRow = buffer.getCursorRow(); buffer.setScreenSize(termWidth, termHeight, true); + + // Work around weird vt320.java behavior where cursor is an offset from the bottom?? + buffer.setCursorPosition(buffer.getCursorColumn(), prevRow); + if(session != null) session.resizePTY(termWidth, termHeight); } catch(Exception e) { @@ -908,9 +920,6 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal return buffer; } - public long lastDraw = 0; - public long drawTolerance = 100; - public synchronized void redraw() { // render our buffer only if we have a surface if(parent == null) return; @@ -1242,4 +1251,11 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal public boolean isAwaitingClose() { return awaitingClose; } + + /** + * @return whether this connection had started and subsequently disconnected + */ + public boolean isDisconnected() { + return disconnected; + } } |