changeset 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 18aceeae6681
children 5f26d0ba6abd
files AndroidManifest.xml src/com/five_ten_sg/connectbot/service/ConnectionNotifier.java src/com/five_ten_sg/connectbot/service/TerminalBridge.java src/com/five_ten_sg/connectbot/service/TerminalMonitor.java
diffstat 4 files changed, 32 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/AndroidManifest.xml	Sun Jun 29 12:41:26 2014 -0700
+++ b/AndroidManifest.xml	Tue Jul 01 20:07:12 2014 -0700
@@ -17,7 +17,7 @@
 -->
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
 	package="com.five_ten_sg.connectbot"
-	android:versionName="1.8.1-1"
+	android:versionName="1.8.2-1"
 	android:versionCode="1"
 	android:installLocation="auto">
 
--- a/src/com/five_ten_sg/connectbot/service/ConnectionNotifier.java	Sun Jun 29 12:41:26 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/service/ConnectionNotifier.java	Tue Jul 01 20:07:12 2014 -0700
@@ -56,7 +56,7 @@
         String contentText = res.getString(
                                  R.string.notification_text, host.getNickname());
         Intent notificationIntent = new Intent(context, ConsoleActivity.class);
-        notificationIntent.setAction("android.intent.action.VIEW");
+        notificationIntent.setAction(Intent.ACTION_VIEW);
         notificationIntent.setData(host.getUri());
         PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
                                       notificationIntent, 0);
--- a/src/com/five_ten_sg/connectbot/service/TerminalBridge.java	Sun Jun 29 12:41:26 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/service/TerminalBridge.java	Tue Jul 01 20:07:12 2014 -0700
@@ -222,7 +222,7 @@
         String monitor_init = host.getMonitor();
 
         if ((monitor_init != null) && (monitor_init.length() > 0)) {
-            monitor = new TerminalMonitor(manager, buffer, parent, monitor_init);
+            monitor = new TerminalMonitor(manager, buffer, parent, host, monitor_init);
         }
 
         transport.setCompression(host.getCompression());
--- 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);
+    }
+
 }