private void loadAutoLoginAccount() { String autoLogin = SwingUiSettings.XMPP_AUTO_LOGIN.get(); if (!autoLogin.equals("")) { int comma = autoLogin.indexOf(','); try { String label = autoLogin.substring(0, comma); String username = autoLogin.substring(comma + 1); FriendAccountConfiguration config = configs.get(label); if (config != null) { config.setUsername(username); if (config.storePassword()) { String password = passwordManager.loadPassword(username); config.setPassword(password); } autoLoginConfig = config; } } catch (IndexOutOfBoundsException ignored) { // Malformed string - no soup for you! } catch (IllegalArgumentException ignored) { // Empty username - no soup for you! } catch (IOException ignored) { // Error decrypting password - no soup for you! } } }
@Override public List<String> getLabels() { ArrayList<String> labels = new ArrayList<String>(); for (FriendAccountConfiguration config : getRawConfigs().values()) labels.add(config.getLabel()); Collections.sort(labels); return labels; }
@Override public void setAutoLoginConfig(FriendAccountConfiguration config) { // Remove the old configuration, if there is one if (autoLoginConfig != null) { passwordManager.removePassword(autoLoginConfig.getUserInputLocalID()); SwingUiSettings.XMPP_AUTO_LOGIN.set(""); SwingUiSettings.USER_DEFINED_JABBER_SERVICENAME.set(""); autoLoginConfig = null; } // Store the new configuration, if there is one if (config != null) { try { if (config.storePassword()) { passwordManager.storePassword(config.getUserInputLocalID(), config.getPassword()); } SwingUiSettings.XMPP_AUTO_LOGIN.set(config.getLabel() + "," + config.getUserInputLocalID()); if (config.getLabel().equals("Jabber")) SwingUiSettings.USER_DEFINED_JABBER_SERVICENAME.set(config.getServiceName()); autoLoginConfig = config; } catch (IllegalArgumentException ignored) { // Empty username or password - no soup for you! } catch (IOException ignored) { // Error encrypting password - no more Soup Nazi jokes for you! } } }
private void loadWellKnownServers() { FriendAccountConfiguration gmail = new FriendAccountConfigurationImpl( true, "gmail.com", "Gmail", gmailIconSmall, gmailIconLarge, resource, getGTalkServers(), Network.Type.XMPP); configs.put(gmail.getLabel(), gmail); FriendAccountConfiguration livejournal = new FriendAccountConfigurationImpl( false, "livejournal.com", "LiveJournal", ljIconSmall, ljIconLarge, resource, getLiveJournalServers(), Network.Type.XMPP); configs.put(livejournal.getLabel(), livejournal); }