comparison src/com/five_ten_sg/connectbot/service/TerminalMonitor.java @ 155:156b53fc4815

add showurl command
author Carl Byington <carl@five-ten-sg.com>
date Mon, 23 Jun 2014 17:54:39 -0700
parents 3ca280646f2d
children cb9e359ea2bd
comparison
equal deleted inserted replaced
154:86f903100573 155:156b53fc4815
2 2
3 import android.content.ComponentName; 3 import android.content.ComponentName;
4 import android.content.Context; 4 import android.content.Context;
5 import android.content.Intent; 5 import android.content.Intent;
6 import android.content.ServiceConnection; 6 import android.content.ServiceConnection;
7 import android.net.Uri;
7 import android.os.IBinder; 8 import android.os.IBinder;
8 import android.util.Log; 9 import android.util.Log;
9 import android.view.View; 10 import android.view.View;
10 import de.mud.terminal.vt320; 11 import de.mud.terminal.vt320;
11 import java.io.IOException; 12 import java.io.IOException;
30 public static final char MONITOR_CMD_FIELDVALUE = 5; 31 public static final char MONITOR_CMD_FIELDVALUE = 5;
31 public static final char MONITOR_CMD_SETFIELD = 5; 32 public static final char MONITOR_CMD_SETFIELD = 5;
32 public static final char MONITOR_CMD_GETFIELD = 6; 33 public static final char MONITOR_CMD_GETFIELD = 6;
33 public static final char MONITOR_CMD_SCREENWATCH = 7; 34 public static final char MONITOR_CMD_SCREENWATCH = 7;
34 public static final char MONITOR_CMD_DEPRESS = 8; 35 public static final char MONITOR_CMD_DEPRESS = 8;
36 public static final char MONITOR_CMD_SHOWURL = 9;
35 37
36 private static final int MONITORPORT = 6000; 38 private static final int MONITORPORT = 6000;
37 private static final String LOCALHOST = "127.0.0.1"; 39 private static final String LOCALHOST = "127.0.0.1";
38 40
39 private Context parent = null; 41 private Context parent = null;
117 break; 119 break;
118 120
119 case MONITOR_CMD_DEPRESS: 121 case MONITOR_CMD_DEPRESS:
120 if (packet.length == 2) 122 if (packet.length == 2)
121 depress(packet[1]); 123 depress(packet[1]);
124
125 break;
126
127 case MONITOR_CMD_SHOWURL:
128 if (packet.length > 1)
129 showUrl(packet, 1);
122 130
123 break; 131 break;
124 132
125 default: 133 default:
126 break; 134 break;
367 } 375 }
368 376
369 buffer.setField(l, c, da); 377 buffer.setField(l, c, da);
370 } 378 }
371 379
380 public synchronized void showUrl(char [] data, int offset) {
381 Log.i(TAG, "setField()");
382 char[] da = new char[data.length - offset];
383 int i;
384
385 for (i = 0; i < da.length; i++) {
386 da[i] = data[i + offset];
387 }
388 String url = new String(da);
389 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
390 parent.startActivity(intent);
391 }
392
372 public synchronized void getField(int l, int c, int len) { 393 public synchronized void getField(int l, int c, int len) {
373 Log.i(TAG, "getField()"); 394 Log.i(TAG, "getField()");
374 char[] arg2 = new char[4 + len]; 395 char[] arg2 = new char[4 + len];
375 arg2[2] = (char)(l & 0x0000ffff); 396 arg2[2] = (char)(l & 0x0000ffff);
376 arg2[3] = (char)(c & 0x0000ffff); 397 arg2[3] = (char)(c & 0x0000ffff);