/** Adds the {@link EnterXMPPAccountWizardPage}'s account data to the {@link XMPPAccountStore}. */ private void addXMPPAccount() { if (!enterXMPPAccountWizardPage.isXMPPAccountCreated()) { JID jid = enterXMPPAccountWizardPage.getJID(); String username = jid.getName(); String password = enterXMPPAccountWizardPage.getPassword(); String domain = jid.getDomain().toLowerCase(); String server = enterXMPPAccountWizardPage.getServer(); int port; if (enterXMPPAccountWizardPage.getPort().length() != 0) port = Integer.valueOf(enterXMPPAccountWizardPage.getPort()); else port = 0; boolean useTLS = enterXMPPAccountWizardPage.isUsingTLS(); boolean useSASL = enterXMPPAccountWizardPage.isUsingSASL(); accountStore.createAccount(username, password, domain, server, port, useTLS, useSASL); } if (accountStore.getAllAccounts().size() == 1 && store.getBoolean(PreferenceConstants.AUTO_CONNECT)) ThreadUtils.runSafeAsync( "dpp-connect-demand", LOG, new Runnable() { @Override public void run() { connectionHandler.connect(accountStore.getActiveAccount(), false); } }); }
private void initAccountStore(XMPPAccountStore store) { // see http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4787931 String os = System.getProperty("os.name"); boolean isWindows = os != null && os.toLowerCase().contains("windows"); String homeDirectory = null; if (isWindows) { String userHome = System.getenv("USERPROFILE"); if (userHome != null) { File directory = new File(userHome); if (directory.exists() && directory.isDirectory()) homeDirectory = userHome; } } if (homeDirectory == null) homeDirectory = System.getProperty("user.home"); if (homeDirectory == null) { log.warn("home directory not set, cannot save and load account data"); return; } File sarosDataDir = new File(homeDirectory, SAROS_DATA_DIRECTORY); File accountFile = new File(sarosDataDir, SAROS_XMPP_ACCOUNT_FILE); store.setAccountFile(accountFile, System.getProperty("user.name")); }