changeset 43:6b0f1ece1d91 tn5250

start tn5250 integration
author Carl Byington <carl@five-ten-sg.com>
date Wed, 11 Jun 2014 09:29:22 -0700
parents 7ac846a07ed4
children 959ebe0247b5
files src/com/five_ten_sg/connectbot/service/TerminalMonitor.java src/com/five_ten_sg/connectbot/transport/AbsTransport.java src/com/five_ten_sg/connectbot/transport/TN5250.java
diffstat 3 files changed, 20 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java	Wed Jun 11 09:14:31 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java	Wed Jun 11 09:29:22 2014 -0700
@@ -294,6 +294,7 @@
     }
 
     public synchronized void hostData(byte[] b) {
+        if (b == null) return;
         for (int i = 0; i < b.length; i++) {
             hostData((int)b[i] & 0xff);
         }
--- a/src/com/five_ten_sg/connectbot/transport/AbsTransport.java	Wed Jun 11 09:14:31 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/transport/AbsTransport.java	Wed Jun 11 09:29:22 2014 -0700
@@ -28,6 +28,7 @@
 import com.five_ten_sg.connectbot.service.TerminalManager;
 import android.content.Context;
 import android.net.Uri;
+import android.util.Log;
 import de.mud.terminal.vt320;
 
 /**
@@ -35,11 +36,12 @@
  *
  */
 public abstract class AbsTransport {
-    TerminalManager manager;
-    TerminalBridge  bridge;
-    HostBean        host;
-    vt320           buffer;
-    String          emulation;
+    private String          TAG;
+    private TerminalManager manager;
+    private TerminalBridge  bridge;
+    private HostBean        host;
+    private vt320           buffer;
+    private String          emulation;
 
     class vt320Default extends vt320 {
         @Override
@@ -49,10 +51,9 @@
         @Override
         public void write(byte[] b) {
             try {
-                if (b != null && transport != null)
-                    if (bridge.monitor != null) bridge.monitor.hostData(b);
+                if (bridge.monitor != null) bridge.monitor.hostData(b);
 
-                transport.write(b);
+                AbsTransport.this.write(b);
             }
             catch (IOException e) {
                 Log.e(TAG, "Problem writing outgoing data in vt320() thread", e);
@@ -61,10 +62,9 @@
         @Override
         public void write(int b) {
             try {
-                if (transport != null)
-                    if (bridge.monitor != null) bridge.monitor.hostData(b);
+                if (bridge.monitor != null) bridge.monitor.hostData(b);
 
-                transport.write(b);
+                AbsTransport.this.write(b);
             }
             catch (IOException e) {
                 Log.e(TAG, "Problem writing outgoing data in vt320() thread", e);
@@ -237,7 +237,7 @@
         return emulation;
     }
 
-    public vt320 getTransportbuffer() {
+    public vt320 getTransportBuffer() {
         buffer = vt320Default();
         int scrollback = (host.getWantSession()) ?  manager.getScrollback() : 0;
         buffer.setBufferSize(scrollback);
--- a/src/com/five_ten_sg/connectbot/transport/TN5250.java	Wed Jun 11 09:14:31 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/transport/TN5250.java	Wed Jun 11 09:29:22 2014 -0700
@@ -63,6 +63,9 @@
         hostmask = Pattern.compile("^([0-9a-z.-]+)(:(\\d+))?$", Pattern.CASE_INSENSITIVE);
     }
 
+    class Terminal5250KeyListener extends TerminalKeyListener {
+
+    };
 
     public TN5250() {
        super();
@@ -308,4 +311,8 @@
         return false;
     }
 
+    public TerminalKeyListener getTerminalKeyListener() {
+        return new Terminal5250KeyListener(manager, bridge, buffer, host.getEncoding());
+    }
+
 }