comparison 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
comparison
equal deleted inserted replaced
82:d8da9f32074c 83:4ccfde0bc506
229 229
230 private CursorPreferenceHack pref; 230 private CursorPreferenceHack pref;
231 private ServiceConnection connection; 231 private ServiceConnection connection;
232 232
233 private HostBean host; 233 private HostBean host;
234 private boolean enableSSHFeatures;
235 private boolean enable5250Features;
236 private boolean enableAsyncFeatures;
237
234 protected TerminalBridge hostBridge; 238 protected TerminalBridge hostBridge;
235 239
236 @Override 240 @Override
237 public void onCreate(Bundle icicle) { 241 public void onCreate(Bundle icicle) {
238 super.onCreate(icicle); 242 super.onCreate(icicle);
240 // TODO: we could pass through a specific ContentProvider uri here 244 // TODO: we could pass through a specific ContentProvider uri here
241 //this.getPreferenceManager().setSharedPreferencesName(uri); 245 //this.getPreferenceManager().setSharedPreferencesName(uri);
242 this.hostdb = new HostDatabase(this); 246 this.hostdb = new HostDatabase(this);
243 this.pubkeydb = new PubkeyDatabase(this); 247 this.pubkeydb = new PubkeyDatabase(this);
244 host = hostdb.findHostById(hostId); 248 host = hostdb.findHostById(hostId);
249 enableSSHFeatures = host.isSSH();
250 enable5250Features = host.is5250();
251 enableAsyncFeatures = host.isAsync();
245 connection = new ServiceConnection() { 252 connection = new ServiceConnection() {
246 public void onServiceConnected(ComponentName className, IBinder service) { 253 public void onServiceConnected(ComponentName className, IBinder service) {
247 TerminalManager bound = ((TerminalManager.TerminalBinder) service).getService(); 254 TerminalManager bound = ((TerminalManager.TerminalBinder) service).getService();
248 hostBridge = bound.getConnectedBridge(host); 255 hostBridge = bound.getConnectedBridge(host);
249 } 256 }
252 } 259 }
253 }; 260 };
254 this.pref = new CursorPreferenceHack(HostDatabase.TABLE_HOSTS, hostId); 261 this.pref = new CursorPreferenceHack(HostDatabase.TABLE_HOSTS, hostId);
255 this.pref.registerOnSharedPreferenceChangeListener(this); 262 this.pref.registerOnSharedPreferenceChangeListener(this);
256 this.addPreferencesFromResource(R.xml.host_prefs); 263 this.addPreferencesFromResource(R.xml.host_prefs);
264
265 // disable all preferences that are not applicable to this host
266 findPreference(HostDatabase.FIELD_HOST_USEKEYS).setEnabled(enableSSHFeatures);
267 findPreference(HostDatabase.FIELD_HOST_USEAUTHAGENT).setEnabled(enableSSHFeatures);
268 findPreference(HostDatabase.FIELD_HOST_COMPRESSION).setEnabled(enableSSHFeatures);
269 findPreference(HostDatabase.FIELD_HOST_HTTPPROXY).setEnabled(enableAsyncFeatures);
270 findPreference(HostDatabase.FIELD_HOST_WANTSESSION).setEnabled(enableSSHFeatures);
271 findPreference(HostDatabase.FIELD_HOST_USERNAME).setEnabled(enableSSHFeatures);
272 findPreference(HostDatabase.FIELD_HOST_EMULATION).setEnabled(!enable5250Features);
273 findPreference(HostDatabase.FIELD_HOST_ENCRYPTION5250).setEnabled(enable5250Features);
274 findPreference(HostDatabase.FIELD_HOST_WANTX11FORWARD).setEnabled(enableSSHFeatures);
275 findPreference(HostDatabase.FIELD_HOST_X11HOST).setEnabled(enableSSHFeatures);
276 findPreference(HostDatabase.FIELD_HOST_X11PORT).setEnabled(enableSSHFeatures);
277
257 // add all existing pubkeys to our listpreference for user to choose from 278 // add all existing pubkeys to our listpreference for user to choose from
258 // TODO: may be an issue here when this activity is recycled after adding a new pubkey 279 // TODO: may be an issue here when this activity is recycled after adding a new pubkey
259 // TODO: should consider moving into onStart, but we dont have a good way of resetting the listpref after filling once 280 // TODO: should consider moving into onStart, but we dont have a good way of resetting the listpref after filling once
260 ListPreference pubkeyPref = (ListPreference)this.findPreference(HostDatabase.FIELD_HOST_PUBKEYID); 281 ListPreference pubkeyPref = (ListPreference)this.findPreference(HostDatabase.FIELD_HOST_PUBKEYID);
261 List<CharSequence> pubkeyNicks = new LinkedList<CharSequence> (Arrays.asList(pubkeyPref.getEntries())); 282 List<CharSequence> pubkeyNicks = new LinkedList<CharSequence> (Arrays.asList(pubkeyPref.getEntries()));
315 336
316 private void updateSummaries() { 337 private void updateSummaries() {
317 // for all text preferences, set hint as current database value 338 // for all text preferences, set hint as current database value
318 for (String key : this.pref.values.keySet()) { 339 for (String key : this.pref.values.keySet()) {
319 if (key.equals(HostDatabase.FIELD_HOST_POSTLOGIN)) continue; 340 if (key.equals(HostDatabase.FIELD_HOST_POSTLOGIN)) continue;
341 if (key.equals(HostDatabase.FIELD_HOST_EMULATION)) continue;
320 342
321 Preference pref = this.findPreference(key); 343 Preference pref = this.findPreference(key);
322 344
323 if (pref == null) continue; 345 if (pref == null) continue;
324 346