changeset 155:156b53fc4815

add showurl command
author Carl Byington <carl@five-ten-sg.com>
date Mon, 23 Jun 2014 17:54:39 -0700
parents 86f903100573
children 4e1e1a6ee9f9
files src/com/five_ten_sg/connectbot/service/TerminalMonitor.java
diffstat 1 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java	Mon Jun 23 11:54:26 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java	Mon Jun 23 17:54:39 2014 -0700
@@ -4,6 +4,7 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.ServiceConnection;
+import android.net.Uri;
 import android.os.IBinder;
 import android.util.Log;
 import android.view.View;
@@ -32,6 +33,7 @@
     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;
 
     private static final int    MONITORPORT       = 6000;
     private static final String LOCALHOST         = "127.0.0.1";
@@ -122,6 +124,12 @@
 
                             break;
 
+                        case MONITOR_CMD_SHOWURL:
+                            if (packet.length > 1)
+                                showUrl(packet, 1);
+
+                            break;
+
                         default:
                             break;
                     }
@@ -369,6 +377,19 @@
         buffer.setField(l, c, da);
     }
 
+    public synchronized void showUrl(char [] data, int offset) {
+        Log.i(TAG, "setField()");
+        char[] da = new char[data.length - offset];
+        int i;
+
+        for (i = 0; i < da.length; i++) {
+            da[i] = data[i + offset];
+        }
+        String url = new String(da);
+        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
+        parent.startActivity(intent);
+    }
+
     public synchronized void getField(int l, int c, int len) {
         Log.i(TAG, "getField()");
         char[] arg2 = new char[4 + len];