changeset 2:f6a1aabf384f

add copyright
author Carl Byington <carl@five-ten-sg.com>
date Mon, 23 Jun 2014 16:57:39 -0700
parents f12df02aa228
children 2be5bca648ab
files res/values/strings.xml src/com/five_ten_sg/connectbot/monitor/MonitorActivity.java src/com/five_ten_sg/connectbot/monitor/MonitorService.java xml/510connectbotmonitor.in
diffstat 4 files changed, 49 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/res/values/strings.xml	Mon May 05 14:37:11 2014 -0700
+++ b/res/values/strings.xml	Mon Jun 23 16:57:39 2014 -0700
@@ -3,4 +3,5 @@
     <string name="app_name">510 Connectbot Monitor</string>
     <string name="service_desc">Maintains socket connection between 510 Connectbot terminal emulator and the monitoring application.</string>
     <string name="action_settings">Settings</string>
+    <string name="copyright">Copyright 510 Software Group. Released under the GPLv3 or later. Full source code at http://www.five-ten-sg.com/510ConnectbotMonitor/</string>
 </resources>
--- a/src/com/five_ten_sg/connectbot/monitor/MonitorActivity.java	Mon May 05 14:37:11 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/monitor/MonitorActivity.java	Mon Jun 23 16:57:39 2014 -0700
@@ -36,13 +36,7 @@
         @Override
         public void handleMessage (Message msg) {
             if (msg.what == MESSAGE_CODE_PRINT) {
-                String s = (String)msg.obj;
-                if (count < LINES) count++;
-                else               start = (start+1) % LINES;
-                texts[(start+count-1) % LINES] = s + "\n";
-                String c = "";
-                for (int i=0; i<count; i++) c = c.concat(texts[(start+i) % LINES]);
-                text.setText(c);
+                printer((String)msg.obj);
             } else {
                 super.handleMessage(msg);
             }
@@ -65,19 +59,24 @@
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);
         text = (TextView) findViewById(R.id.text2);
+        printer(getString(R.string.copyright));
         Log.i(TAG, "binding to monitor service");
         Intent intent = new Intent ("com.five_ten_sg.connectbot.monitor.MonitorService");
         bindService(intent, connection, Context.BIND_AUTO_CREATE);
     }
 
-    public void printer(String msg) {
-        handler.sendMessage(handler.obtainMessage(MonitorActivity.MESSAGE_CODE_PRINT, msg));
+    private void printer(String msg) {
+        if (count < LINES) count++;
+        else               start = (start+1) % LINES;
+        texts[(start+count-1) % LINES] = s + "\n";
+        String c = "";
+        for (int i=0; i<count; i++) c = c.concat(texts[(start+i) % LINES]);
+        text.setText(c);
     }
 
     @Override
     protected void onStart() {
         super.onStart();
-        printer("activity onStart()");
         Log.i(TAG, "activity onStart()");
     }
 
--- a/src/com/five_ten_sg/connectbot/monitor/MonitorService.java	Mon May 05 14:37:11 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/monitor/MonitorService.java	Mon Jun 23 16:57:39 2014 -0700
@@ -33,13 +33,14 @@
 
     public  static final char MONITOR_CMD_INIT         = 0;
     public  static final char MONITOR_CMD_ACTIVATE     = 1;
-    public  static final char MONITOR_CMD_HOSTDATA     = 2;
+    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 int       MONITORPORT = 6000;
 
@@ -249,8 +250,8 @@
                             System.arraycopy(packet, 3, buf, 0, plen-3);
                             teActivate(connection, packet[1], packet[2], buf);
                             break;
-                        case MONITOR_CMD_HOSTDATA:
-                            teHostData(connection, packet[1]);
+                        case MONITOR_CMD_KEYSTATE:
+                            teKeyState(connection, (packet[1] == 1));
                             break;
                         case MONITOR_CMD_CURSORMOVE:
                             teCursorMove(connection, packet[1], packet[2]);
@@ -306,17 +307,18 @@
     public void teInit(int connection, char[] buf) {
         String fn = new String(buf);
         Log.i(TAG, String.format("teInit %d file %s", connection, fn));
-        printer(String.format("init %d %s", connection, fn));
+        //printer(String.format("init %d %s", connection, fn));
     }
 
     public void teActivate(int connection, int lines, int columns, char[] buf) {
         Log.i(TAG, String.format("teActivate %d", connection));
-        printer(String.format("activate %d lines %d columns %d b.len %d", connection, lines, columns, buf.length));
+        //printer(String.format("activate %d lines %d columns %d b.len %d", connection, lines, columns, buf.length));
     }
 
-    public void teHostData(int connection, int keyCode) {
-        Log.i(TAG, String.format("teHostData %d key %d", connection, keyCode));
-        printer(String.format("key %d is %d", connection, keyCode));
+    public void teKeyState(int connection, boolean down) {
+        String d = (down) ? "yes" : "no";
+        Log.i(TAG, String.format("teKeyState %d isdown %s", connection, d));
+        //printer(String.format("keystate %d isdown %s", connection, d));
     }
 
     public void teCursorMove(int connection, int l, int c) {
@@ -381,4 +383,15 @@
     public void teSpeak(int connection, String msg, boolean flush) {
         if (speech) talker.speak(msg, (flush) ? TextToSpeech.QUEUE_FLUSH : TextToSpeech.QUEUE_ADD, null);
     }
+
+    public static void teDepress(int connection, int vk_key) {
+        // http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731
+        Log.i(TAG, String.format("teDepress %d, %d", connection, vk_key));
+        CommunicationThread cm = clients.get(connection);
+        if (cm != null) {
+            char[] arg = new char[3];
+            arg[2] = (char) (vk_key & 0x0000ffff);
+            cm.clientWrite(MONITOR_CMD_DEPRESS, arg);
+        }
+    }
 }
--- a/xml/510connectbotmonitor.in	Mon May 05 14:37:11 2014 -0700
+++ b/xml/510connectbotmonitor.in	Mon Jun 23 16:57:39 2014 -0700
@@ -19,7 +19,7 @@
 
     <refentry id="x@PACKAGE@.1">
         <refentryinfo>
-            <date>2014-04-18</date>
+            <date>2014-06-22</date>
             <author>
                 <firstname>Carl</firstname>
                 <surname>Byington</surname>
@@ -58,9 +58,9 @@
         <refsect1 id='monitor.1'>
             <title>Terminal Monitor</title>
             <para>
-                For every terminal session (local, telnet, ssh or other), the
+                For every terminal session (local, telnet, ssh or tn5250), the
                 terminal emulator also makes a connection to a terminal monitor
-                process, which can see keystrokes and screen contents, and can
+                process, which can see cursor movement and screen contents, and can
                 inject characters to send to the host.
             </para>
 
@@ -108,8 +108,10 @@
             </para>
 
             <para>
-                HOSTDATA = 2 (TE -> Monitor). The argument is a single uint16
-                value containing the 8 bit character that was sent to the host.
+                KEYSTATE = 2 (TE -> Monitor). The argument is a single uint16
+                value, 1 for key down, 0 for key up. The TE tracks a single special
+                key for the monitor, and reports key up/down state when it changes.
+                The actual key is configurable.
             </para>
 
             <para>
@@ -157,6 +159,17 @@
                 changes, the emulator will send a SCREENCHANGE message back
                 to the monitor.
             </para>
+
+            <para>
+                DEPRESS = 8 (Monitor -> TE). The argument is a single
+                uint16 value containing a Windows VK key code. See
+                http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731
+                for the values. The following values are implemented
+                in the emulator - vk_back vk_tab vk_return vk_escape
+                vk_prior vk_next vk_end vk_home vk_left vk_up vk_right
+                vk_down vk_insert vk_delete vk_f1 vk_f2 vk_f3 vk_f4
+                vk_f5 vk_f6 vk_f7 vk_f8 vk_f9 vk_f10 vk_f11 vk_f12.
+            </para>
         </refsect1>
 
         <refsect1 id='todo.1'>