diff src/com/five_ten_sg/connectbot/transport/TN5250.java @ 29:017eeed8332c tn5250

start tn5250 integration
author Carl Byington <carl@five-ten-sg.com>
date Tue, 03 Jun 2014 16:02:29 -0700
parents cfcb8d9859a8
children d738f6b876fe
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/transport/TN5250.java	Tue Jun 03 12:38:59 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/transport/TN5250.java	Tue Jun 03 16:02:29 2014 -0700
@@ -35,12 +35,13 @@
 import com.five_ten_sg.connectbot.bean.HostBean;
 import com.five_ten_sg.connectbot.bean.PortForwardBean;
 import com.five_ten_sg.connectbot.service.TerminalBridge;
+import com.five_ten_sg.connectbot.service.TerminalKeyListener;
 import com.five_ten_sg.connectbot.service.TerminalManager;
 import com.five_ten_sg.connectbot.util.HostDatabase;
-
 import android.content.Context;
 import android.net.Uri;
 import android.util.Log;
+import de.mud.terminal.vt320;
 
 
 /**
@@ -56,8 +57,6 @@
     private tnvt   handler = null;
     private Socket socket;
 
-    private InputStream is;
-    private OutputStream os;
     private int width;
     private int height;
 
@@ -75,7 +74,6 @@
 
    public TN5250(HostBean host, TerminalBridge bridge, TerminalManager manager) {
        super(host, bridge, manager);
-       handler = new tnvt(screen52, true, false, bridge, manager);
    }
 
 
@@ -130,12 +128,10 @@
     */
    @Override
    public void connect() {
+        screen52  = new Screen5250;
+        handler   = new tnvt(screen52, true, false, bridge, manager);
         connected = handler.connect(host.getHostname(), host.getPort());
-        if (connected) {
-            is = handler.bin;
-            os = handler.bout;
-            bridge.onConnected();
-        }
+        if (connected) bridge.onConnected();
     }
 
 
@@ -145,12 +141,8 @@
      */
     @Override
     public boolean willBlock() {
-        if (is == null) return true;
-        try {
-            return is.available() == 0;
-        } catch (Exception e) {
-            return true;
-        }
+        // we don't use a relay thread between the transport and the vt320 buffer
+        return true;
     }
 
     /**
@@ -165,6 +157,7 @@
      * @throws IOException when remote host disconnects
      */
     public int read(byte[] buffer, int offset, int length) throws IOException {
+        // we don't use a relay thread between the transport and the vt320 buffer
         return 0;
     }
 
@@ -196,7 +189,7 @@
 
     /**
      * Closes the connection to the terminal. Note that the resulting failure to read
-     * should call {@link TerminalBridge#dispatchDisconnect(boolean)}.
+     * should call {@link TerminalBridge#dispatchDisconnect(boolean)}.  !!!
      */
     public void close() {
         handler.disconnect();
@@ -419,4 +412,18 @@
     public boolean usesNetwork() {
         return true;
     }
+
+
+    @Override
+    public boolean needsRelay() {
+        // we don't use a relay thread between the transport and the vt320 buffer
+        return false;
+    }
+
+
+    @Override
+    public TerminalKeyListener(TerminalManager manager, TerminalBridge bridge, vt320 buffer, String encoding) {
+        return new TerminalKeyListener(manager, bridge, buffer, encoding);
+    }
+
 }