Mercurial > 510Connectbot
changeset 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 | d8da9f32074c |
children | 8f23b05a51f7 |
files | src/com/five_ten_sg/connectbot/HostEditorActivity.java src/com/five_ten_sg/connectbot/bean/HostBean.java |
diffstat | 2 files changed, 38 insertions(+), 0 deletions(-) [+] |
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);
--- a/src/com/five_ten_sg/connectbot/bean/HostBean.java Mon Jun 16 09:55:39 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/bean/HostBean.java Mon Jun 16 10:43:30 2014 -0700 @@ -73,6 +73,22 @@ this.port = port; } + public boolean isSSH() { + return (protocol == "ssh"); + } + + public boolean is5250() { + return (protocol == "tn5250"); + } + + public boolean isTelnet() { + return (protocol == "telnet"); + } + + public boolean isAsync() { + return isSSH() || isTelnet(); + } + public void setId(long id) { this.id = id; }