diff src/com/five_ten_sg/connectbot/transport/Local.java @ 31:139394237973 tn5250

start tn5250 integration
author Carl Byington <carl@five-ten-sg.com>
date Tue, 10 Jun 2014 12:00:07 -0700
parents 6aaefb22d876
children 77ac18bc1b2f
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/transport/Local.java	Tue Jun 03 16:05:21 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/transport/Local.java	Tue Jun 10 12:00:07 2014 -0700
@@ -41,12 +41,10 @@
 public class Local extends AbsTransport {
     private static final String TAG = "ConnectBot.Local";
     private static final String PROTOCOL = "local";
-
     private static final String DEFAULT_URI = "local:#Local";
 
-    private FileDescriptor shellFd;
-
-    private FileInputStream is;
+    private FileDescriptor   shellFd;
+    private FileInputStream  is;
     private FileOutputStream os;
 
     /**
@@ -55,37 +53,23 @@
     public Local() {
     }
 
-    /**
-     * @param host
-     * @param bridge
-     * @param manager
-     */
-    public Local(HostBean host, TerminalBridge bridge, TerminalManager manager) {
-        super(host, bridge, manager);
-    }
 
     public static String getProtocolName() {
         return PROTOCOL;
     }
 
-    @Override
-    public void close() {
-        try {
-            if (os != null) {
-                os.close();
-                os = null;
-            }
+
+    public Uri getUri(String input) {
+        Uri uri = Uri.parse(DEFAULT_URI);
 
-            if (is != null) {
-                is.close();
-                is = null;
-            }
+        if (input != null && input.length() > 0) {
+            uri = uri.buildUpon().fragment(input).build();
         }
-        catch (IOException e) {
-            Log.e(TAG, "Couldn't close shell", e);
-        }
+
+        return uri;
     }
 
+
     @Override
     public void connect() {
         int[] pids = new int[1];
@@ -115,35 +99,6 @@
         bridge.onConnected();
     }
 
-    @Override
-    public void flush() throws IOException {
-        os.flush();
-    }
-
-    @Override
-    public String getDefaultNickname(String username, String hostname, int port) {
-        return DEFAULT_URI;
-    }
-
-    @Override
-    public int getDefaultPort() {
-        return 0;
-    }
-
-    @Override
-    public boolean isConnected() {
-        return is != null && os != null;
-    }
-
-    @Override
-    public boolean isSessionOpen() {
-        return is != null && os != null;
-    }
-
-    @Override
-    public boolean isAuthenticated() {
-        return isConnected();
-    }
 
     @Override
     public boolean willBlock() {
@@ -166,16 +121,6 @@
     }
 
     @Override
-    public void setDimensions(int columns, int rows, int width, int height) {
-        try {
-            Exec.setPtyWindowSize(shellFd, rows, columns, width, height);
-        }
-        catch (Exception e) {
-            Log.e(TAG, "Couldn't resize pty", e);
-        }
-    }
-
-    @Override
     public void write(byte[] buffer) throws IOException {
         if (os != null)
             os.write(buffer);
@@ -187,14 +132,68 @@
             os.write(c);
     }
 
-    public Uri getUri(String input) {
-        Uri uri = Uri.parse(DEFAULT_URI);
+    @Override
+    public void flush() throws IOException {
+        os.flush();
+    }
+
+    @Override
+    public void close() {
+        try {
+            if (os != null) {
+                os.close();
+                os = null;
+            }
+
+            if (is != null) {
+                is.close();
+                is = null;
+            }
+        }
+        catch (IOException e) {
+            Log.e(TAG, "Couldn't close shell", e);
+        }
+    }
 
-        if (input != null && input.length() > 0) {
-            uri = uri.buildUpon().fragment(input).build();
+    @Override
+    public void setDimensions(int columns, int rows, int width, int height) {
+        try {
+            Exec.setPtyWindowSize(shellFd, rows, columns, width, height);
+        }
+        catch (Exception e) {
+            Log.e(TAG, "Couldn't resize pty", e);
         }
+    }
 
-        return uri;
+    @Override
+    public int getDefaultPort() {
+        return 0;
+    }
+
+    @Override
+    public boolean isConnected() {
+        return is != null && os != null;
+    }
+
+    @Override
+    public boolean isSessionOpen() {
+        return isConnected();
+    }
+
+    @Override
+    public boolean isAuthenticated() {
+        return isConnected();
+    }
+
+    @Override
+    public String getDefaultNickname(String username, String hostname, int port) {
+        return DEFAULT_URI;
+    }
+
+    @Override
+    public void getSelectionArgs(Uri uri, Map<String, String> selection) {
+        selection.put(HostDatabase.FIELD_HOST_PROTOCOL, PROTOCOL);
+        selection.put(HostDatabase.FIELD_HOST_NICKNAME, uri.getFragment());
     }
 
     @Override
@@ -214,12 +213,6 @@
         return host;
     }
 
-    @Override
-    public void getSelectionArgs(Uri uri, Map<String, String> selection) {
-        selection.put(HostDatabase.FIELD_HOST_PROTOCOL, PROTOCOL);
-        selection.put(HostDatabase.FIELD_HOST_NICKNAME, uri.getFragment());
-    }
-
     public String getFormatHint(Context context) {
         return context.getString(R.string.hostpref_nickname_title);
     }