diff src/com/five_ten_sg/connectbot/service/TerminalMonitor.java @ 172:cb9e359ea2bd

add switch session command from the monitor
author Carl Byington <carl@five-ten-sg.com>
date Tue, 01 Jul 2014 20:07:12 -0700
parents 156b53fc4815
children 5f26d0ba6abd
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java	Sun Jun 29 12:41:26 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java	Tue Jul 01 20:07:12 2014 -0700
@@ -23,17 +23,18 @@
 public class TerminalMonitor {
     public final static String TAG = "ConnectBot.TerminalMonitor";
 
-    public  static final char MONITOR_CMD_INIT         = 0;
-    public  static final char MONITOR_CMD_ACTIVATE     = 1;
-    public  static final char MONITOR_CMD_KEYSTATE     = 2;
-    public  static final char MONITOR_CMD_CURSORMOVE   = 3;
-    public  static final char MONITOR_CMD_SCREENCHANGE = 4;
-    public  static final char MONITOR_CMD_FIELDVALUE   = 5;
-    public  static final char MONITOR_CMD_SETFIELD     = 5;
-    public  static final char MONITOR_CMD_GETFIELD     = 6;
-    public  static final char MONITOR_CMD_SCREENWATCH  = 7;
-    public  static final char MONITOR_CMD_DEPRESS      = 8;
-    public  static final char MONITOR_CMD_SHOWURL      = 9;
+    public  static final char MONITOR_CMD_INIT          = 0;
+    public  static final char MONITOR_CMD_ACTIVATE      = 1;
+    public  static final char MONITOR_CMD_KEYSTATE      = 2;
+    public  static final char MONITOR_CMD_CURSORMOVE    = 3;
+    public  static final char MONITOR_CMD_SCREENCHANGE  = 4;
+    public  static final char MONITOR_CMD_FIELDVALUE    = 5;
+    public  static final char MONITOR_CMD_SETFIELD      = 5;
+    public  static final char MONITOR_CMD_GETFIELD      = 6;
+    public  static final char MONITOR_CMD_SCREENWATCH   = 7;
+    public  static final char MONITOR_CMD_DEPRESS       = 8;
+    public  static final char MONITOR_CMD_SHOWURL       = 9;
+    public  static final char MONITOR_CMD_SWITCHSESSION = 10;
 
     private static final int    MONITORPORT       = 6000;
     private static final String LOCALHOST         = "127.0.0.1";
@@ -130,6 +131,12 @@
 
                             break;
 
+                        case MONITOR_CMD_SHOWURL:
+                            if (packet.length == 1)
+                                switchSession();
+
+                            break;
+
                         default:
                             break;
                     }
@@ -179,10 +186,11 @@
     };
 
 
-    public TerminalMonitor(Context parent, vt320 buffer, View view, String init) {
+    public TerminalMonitor(Context parent, vt320 buffer, View view, HostBean host, String init) {
         this.parent      = parent;
         this.buffer      = buffer;
         this.view        = view;
+        this.host        = host;
         this.init        = init;
         // setup the windows->android keymapping
         // http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731
@@ -413,4 +421,13 @@
         Integer x = keymap.get(new Integer(vk_key));
         if (x != null) buffer.keyPressed(x, ' ', 0);
     }
+
+    public synchronized void switchSession() {
+        Log.i(TAG, "switchSession()");
+        Intent intent = new Intent(parent, ConsoleActivity.class);
+        intent.setAction(Intent.ACTION_VIEW);
+        intent.setData(host.getUri());
+        parent.startActivity(intent);
+    }
+
 }