diff src/com/five_ten_sg/connectbot/HostEditorActivity.java @ 83:4ccfde0bc506

disable host config items that are not applicable to the host protocol
author Carl Byington <carl@five-ten-sg.com>
date Mon, 16 Jun 2014 10:43:30 -0700
parents 0ce5cc452d02
children 1c22e6a7efff
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/HostEditorActivity.java	Mon Jun 16 09:55:39 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/HostEditorActivity.java	Mon Jun 16 10:43:30 2014 -0700
@@ -231,6 +231,10 @@
     private ServiceConnection connection;
 
     private HostBean host;
+    private boolean enableSSHFeatures;
+    private boolean enable5250Features;
+    private boolean enableAsyncFeatures;
+
     protected TerminalBridge hostBridge;
 
     @Override
@@ -242,6 +246,9 @@
         this.hostdb = new HostDatabase(this);
         this.pubkeydb = new PubkeyDatabase(this);
         host = hostdb.findHostById(hostId);
+        enableSSHFeatures   = host.isSSH();
+        enable5250Features  = host.is5250();
+        enableAsyncFeatures = host.isAsync();
         connection = new ServiceConnection() {
             public void onServiceConnected(ComponentName className, IBinder service) {
                 TerminalManager bound = ((TerminalManager.TerminalBinder) service).getService();
@@ -254,6 +261,20 @@
         this.pref = new CursorPreferenceHack(HostDatabase.TABLE_HOSTS, hostId);
         this.pref.registerOnSharedPreferenceChangeListener(this);
         this.addPreferencesFromResource(R.xml.host_prefs);
+
+        // disable all preferences that are not applicable to this host
+        findPreference(HostDatabase.FIELD_HOST_USEKEYS).setEnabled(enableSSHFeatures);
+        findPreference(HostDatabase.FIELD_HOST_USEAUTHAGENT).setEnabled(enableSSHFeatures);
+        findPreference(HostDatabase.FIELD_HOST_COMPRESSION).setEnabled(enableSSHFeatures);
+        findPreference(HostDatabase.FIELD_HOST_HTTPPROXY).setEnabled(enableAsyncFeatures);
+        findPreference(HostDatabase.FIELD_HOST_WANTSESSION).setEnabled(enableSSHFeatures);
+        findPreference(HostDatabase.FIELD_HOST_USERNAME).setEnabled(enableSSHFeatures);
+        findPreference(HostDatabase.FIELD_HOST_EMULATION).setEnabled(!enable5250Features);
+        findPreference(HostDatabase.FIELD_HOST_ENCRYPTION5250).setEnabled(enable5250Features);
+        findPreference(HostDatabase.FIELD_HOST_WANTX11FORWARD).setEnabled(enableSSHFeatures);
+        findPreference(HostDatabase.FIELD_HOST_X11HOST).setEnabled(enableSSHFeatures);
+        findPreference(HostDatabase.FIELD_HOST_X11PORT).setEnabled(enableSSHFeatures);
+
         // add all existing pubkeys to our listpreference for user to choose from
         // TODO: may be an issue here when this activity is recycled after adding a new pubkey
         // TODO: should consider moving into onStart, but we dont have a good way of resetting the listpref after filling once
@@ -317,6 +338,7 @@
         // for all text preferences, set hint as current database value
         for (String key : this.pref.values.keySet()) {
             if (key.equals(HostDatabase.FIELD_HOST_POSTLOGIN)) continue;
+            if (key.equals(HostDatabase.FIELD_HOST_EMULATION)) continue;
 
             Preference pref = this.findPreference(key);