Mercurial > 510ConnectbotMonitor
comparison src/com/five_ten_sg/connectbot/monitor/MonitorService.java @ 2:f6a1aabf384f
add copyright
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Mon, 23 Jun 2014 16:57:39 -0700 |
parents | 5564580fe160 |
children | 2be5bca648ab |
comparison
equal
deleted
inserted
replaced
1:f12df02aa228 | 2:f6a1aabf384f |
---|---|
31 public class MonitorService extends Service implements OnInitListener { | 31 public class MonitorService extends Service implements OnInitListener { |
32 public final static String TAG = "ConnectBot.MonitorService"; | 32 public final static String TAG = "ConnectBot.MonitorService"; |
33 | 33 |
34 public static final char MONITOR_CMD_INIT = 0; | 34 public static final char MONITOR_CMD_INIT = 0; |
35 public static final char MONITOR_CMD_ACTIVATE = 1; | 35 public static final char MONITOR_CMD_ACTIVATE = 1; |
36 public static final char MONITOR_CMD_HOSTDATA = 2; | 36 public static final char MONITOR_CMD_KEYSTATE = 2; |
37 public static final char MONITOR_CMD_CURSORMOVE = 3; | 37 public static final char MONITOR_CMD_CURSORMOVE = 3; |
38 public static final char MONITOR_CMD_SCREENCHANGE = 4; | 38 public static final char MONITOR_CMD_SCREENCHANGE = 4; |
39 public static final char MONITOR_CMD_FIELDVALUE = 5; | 39 public static final char MONITOR_CMD_FIELDVALUE = 5; |
40 public static final char MONITOR_CMD_SETFIELD = 5; | 40 public static final char MONITOR_CMD_SETFIELD = 5; |
41 public static final char MONITOR_CMD_GETFIELD = 6; | 41 public static final char MONITOR_CMD_GETFIELD = 6; |
42 public static final char MONITOR_CMD_SCREENWATCH = 7; | 42 public static final char MONITOR_CMD_SCREENWATCH = 7; |
43 public static final char MONITOR_CMD_DEPRESS = 8; | |
43 | 44 |
44 public static final int MONITORPORT = 6000; | 45 public static final int MONITORPORT = 6000; |
45 | 46 |
46 private boolean speech = false; | 47 private boolean speech = false; |
47 private TextToSpeech talker = null; | 48 private TextToSpeech talker = null; |
247 abandonGetField(connection); | 248 abandonGetField(connection); |
248 buf = new char[plen-3]; | 249 buf = new char[plen-3]; |
249 System.arraycopy(packet, 3, buf, 0, plen-3); | 250 System.arraycopy(packet, 3, buf, 0, plen-3); |
250 teActivate(connection, packet[1], packet[2], buf); | 251 teActivate(connection, packet[1], packet[2], buf); |
251 break; | 252 break; |
252 case MONITOR_CMD_HOSTDATA: | 253 case MONITOR_CMD_KEYSTATE: |
253 teHostData(connection, packet[1]); | 254 teKeyState(connection, (packet[1] == 1)); |
254 break; | 255 break; |
255 case MONITOR_CMD_CURSORMOVE: | 256 case MONITOR_CMD_CURSORMOVE: |
256 teCursorMove(connection, packet[1], packet[2]); | 257 teCursorMove(connection, packet[1], packet[2]); |
257 break; | 258 break; |
258 case MONITOR_CMD_SCREENCHANGE: | 259 case MONITOR_CMD_SCREENCHANGE: |
304 //// these functions run on the reader thread here and call your monitoring code | 305 //// these functions run on the reader thread here and call your monitoring code |
305 | 306 |
306 public void teInit(int connection, char[] buf) { | 307 public void teInit(int connection, char[] buf) { |
307 String fn = new String(buf); | 308 String fn = new String(buf); |
308 Log.i(TAG, String.format("teInit %d file %s", connection, fn)); | 309 Log.i(TAG, String.format("teInit %d file %s", connection, fn)); |
309 printer(String.format("init %d %s", connection, fn)); | 310 //printer(String.format("init %d %s", connection, fn)); |
310 } | 311 } |
311 | 312 |
312 public void teActivate(int connection, int lines, int columns, char[] buf) { | 313 public void teActivate(int connection, int lines, int columns, char[] buf) { |
313 Log.i(TAG, String.format("teActivate %d", connection)); | 314 Log.i(TAG, String.format("teActivate %d", connection)); |
314 printer(String.format("activate %d lines %d columns %d b.len %d", connection, lines, columns, buf.length)); | 315 //printer(String.format("activate %d lines %d columns %d b.len %d", connection, lines, columns, buf.length)); |
315 } | 316 } |
316 | 317 |
317 public void teHostData(int connection, int keyCode) { | 318 public void teKeyState(int connection, boolean down) { |
318 Log.i(TAG, String.format("teHostData %d key %d", connection, keyCode)); | 319 String d = (down) ? "yes" : "no"; |
319 printer(String.format("key %d is %d", connection, keyCode)); | 320 Log.i(TAG, String.format("teKeyState %d isdown %s", connection, d)); |
321 //printer(String.format("keystate %d isdown %s", connection, d)); | |
320 } | 322 } |
321 | 323 |
322 public void teCursorMove(int connection, int l, int c) { | 324 public void teCursorMove(int connection, int l, int c) { |
323 //Log.i(TAG, String.format("teCursorMove %d line %d column %d", connection, l, c)); | 325 //Log.i(TAG, String.format("teCursorMove %d line %d column %d", connection, l, c)); |
324 } | 326 } |
379 } | 381 } |
380 | 382 |
381 public void teSpeak(int connection, String msg, boolean flush) { | 383 public void teSpeak(int connection, String msg, boolean flush) { |
382 if (speech) talker.speak(msg, (flush) ? TextToSpeech.QUEUE_FLUSH : TextToSpeech.QUEUE_ADD, null); | 384 if (speech) talker.speak(msg, (flush) ? TextToSpeech.QUEUE_FLUSH : TextToSpeech.QUEUE_ADD, null); |
383 } | 385 } |
386 | |
387 public static void teDepress(int connection, int vk_key) { | |
388 // http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731 | |
389 Log.i(TAG, String.format("teDepress %d, %d", connection, vk_key)); | |
390 CommunicationThread cm = clients.get(connection); | |
391 if (cm != null) { | |
392 char[] arg = new char[3]; | |
393 arg[2] = (char) (vk_key & 0x0000ffff); | |
394 cm.clientWrite(MONITOR_CMD_DEPRESS, arg); | |
395 } | |
396 } | |
384 } | 397 } |