diff src/com/five_ten_sg/connectbot/transport/TransportFactory.java @ 11:f3b3bbd227b8 tn5250

adding tn5250 files
author Carl Byington <carl@five-ten-sg.com>
date Thu, 22 May 2014 18:26:27 -0700
parents 0ce5cc452d02
children b39bcf616a6f
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/transport/TransportFactory.java	Thu May 22 16:11:14 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/transport/TransportFactory.java	Thu May 22 18:26:27 2014 -0700
@@ -36,6 +36,7 @@
 
     private static String[] transportNames = {
         SSH.getProtocolName(),
+        TN5250.getProtocolName(),
         Telnet.getProtocolName(),
         Local.getProtocolName(),
     };
@@ -48,6 +49,9 @@
         if (SSH.getProtocolName().equals(protocol)) {
             return new SSH();
         }
+        else if (TN5250.getProtocolName().equals(protocol)) {
+            return new TN5250();
+        }
         else if (Telnet.getProtocolName().equals(protocol)) {
             return new Telnet();
         }
@@ -63,17 +67,9 @@
         Log.d("TransportFactory", String.format(
                   "Attempting to discover URI for scheme=%s on input=%s", scheme,
                   input));
-
-        if (SSH.getProtocolName().equals(scheme))
-            return SSH.getUri(input);
-        else if (Telnet.getProtocolName().equals(scheme))
-            return Telnet.getUri(input);
-        else if (Local.getProtocolName().equals(scheme)) {
-            Log.d("TransportFactory", "Got to the local parsing area");
-            return Local.getUri(input);
-        }
-        else
-            return null;
+        AbsTransport t = getTransport(protocol);
+        if (t == null) return null;
+        return t.getUri(input);
     }
 
     public static String[] getTransportNames() {
@@ -88,13 +84,9 @@
     }
 
     public static boolean canForwardPorts(String protocol) {
-        // TODO uh, make this have less knowledge about its children
-        if (SSH.getProtocolName().equals(protocol)) {
-            return true;
-        }
-        else {
-            return false;
-        }
+        AbsTransport t = getTransport(protocol);
+        if (t == null) return false;
+        return t.canForwardPorts();
     }
 
     /**
@@ -103,18 +95,9 @@
      * @return expanded format hint
      */
     public static String getFormatHint(String protocol, Context context) {
-        if (SSH.getProtocolName().equals(protocol)) {
-            return SSH.getFormatHint(context);
-        }
-        else if (Telnet.getProtocolName().equals(protocol)) {
-            return Telnet.getFormatHint(context);
-        }
-        else if (Local.getProtocolName().equals(protocol)) {
-            return Local.getFormatHint(context);
-        }
-        else {
-            return AbsTransport.getFormatHint(context);
-        }
+        AbsTransport t = getTransport(protocol);
+        if (t == null) return "???";
+        return t.getFormatHint(context);
     }
 
     /**