Loading k9mail/src/main/java/io/eelo/mail/account/K9OAuth2TokenProvider.java +2 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ import io.eelo.mail.mail.AuthenticationFailedException; import io.eelo.mail.mail.OAuth2NeedUserPromptException; import io.eelo.mail.mail.oauth.OAuth2TokenProvider; import static io.eelo.mail.account.OAuthConstants.ACCOUNT_EMAIL_ID_KEY; import static io.eelo.mail.account.OAuthConstants.ACCOUNT_USER_NAME_KEY; import static io.eelo.mail.account.OAuthConstants.AUTH_TOKEN_TYPE; import static io.eelo.mail.account.OAuthConstants.EELO_ACCOUNT_TYPE; import static io.eelo.mail.account.OAuthConstants.GOOGLE_ACCOUNT_TYPE; Loading Loading @@ -88,7 +88,7 @@ public class K9OAuth2TokenProvider extends OAuth2TokenProvider { if (accounts.size() > 0) { for (Account account : accounts) { String accountEmailId = accountManager.getUserData(account, ACCOUNT_EMAIL_ID_KEY); ACCOUNT_USER_NAME_KEY); if (emailId.equals(accountEmailId)) { final CountDownLatch countDownLatch = new CountDownLatch(1); accountManager.getAuthToken(account, AUTH_TOKEN_TYPE, new Bundle(), Loading k9mail/src/main/java/io/eelo/mail/account/OAuthConstants.java +1 −1 Original line number Diff line number Diff line Loading @@ -3,6 +3,6 @@ package io.eelo.mail.account; public class OAuthConstants { public static final String EELO_ACCOUNT_TYPE = "bitfire.at.davdroid.eelo"; public static final String GOOGLE_ACCOUNT_TYPE = "bitfire.at.davdroid.google"; public static final String ACCOUNT_EMAIL_ID_KEY = "email_id"; public static final String ACCOUNT_USER_NAME_KEY = "user_name"; public static final String AUTH_TOKEN_TYPE = "oauth2-access-token"; } k9mail/src/main/java/io/eelo/mail/activity/Accounts.java +6 −4 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import io.eelo.mail.K9; import io.eelo.mail.Preferences; import io.eelo.mail.activity.misc.ExtendedAsyncTask; import io.eelo.mail.activity.misc.NonConfigurationInstance; import io.eelo.mail.activity.setup.EeloAccountCreator; import io.eelo.mail.activity.setup.GoogleAccountCreator; import io.eelo.mail.controller.MessagingController; import io.eelo.mail.mail.AuthType; Loading Loading @@ -95,7 +96,7 @@ import io.eelo.mail.mailstore.StorageManager; import io.eelo.mail.preferences.SettingsExporter; import de.cketti.library.changelog.ChangeLog; import static io.eelo.mail.account.OAuthConstants.ACCOUNT_EMAIL_ID_KEY; import static io.eelo.mail.account.OAuthConstants.ACCOUNT_USER_NAME_KEY; import static io.eelo.mail.account.OAuthConstants.EELO_ACCOUNT_TYPE; import static io.eelo.mail.account.OAuthConstants.GOOGLE_ACCOUNT_TYPE; Loading Loading @@ -479,13 +480,14 @@ public class Accounts extends K9ListActivity implements OnItemClickListener { for (android.accounts.Account eeloAccount : eeloAccounts) { String emailId = accountManager.getUserData(eeloAccount, ACCOUNT_EMAIL_ID_KEY); //TODO Add /e/ accounts ACCOUNT_USER_NAME_KEY); String password = accountManager.getPassword(eeloAccount); EeloAccountCreator.createAccount(this, emailId, password); } for (android.accounts.Account googleAccount : googleAccounts) { String emailId = accountManager.getUserData(googleAccount, ACCOUNT_EMAIL_ID_KEY); ACCOUNT_USER_NAME_KEY); GoogleAccountCreator.createAccount(this, emailId); } Loading k9mail/src/main/java/io/eelo/mail/activity/setup/EeloAccountCreator.java 0 → 100644 +42 −0 Original line number Diff line number Diff line package io.eelo.mail.activity.setup; import android.content.Context; import io.eelo.mail.Account; import io.eelo.mail.K9; import io.eelo.mail.Preferences; import io.eelo.mail.controller.MessagingController; public class EeloAccountCreator { public static void createAccount(Context context, String emailId, String password) { Preferences preferences = Preferences.getPreferences(context); AccountConfigImpl accountConfig = new AccountConfigImpl(preferences); accountConfig.setEmail(emailId); accountConfig.setDescription(emailId); accountConfig.setTrashFolderName("Trash"); accountConfig.setArchiveFolderName("Archive"); accountConfig.setDraftsFolderName("Drafts"); accountConfig.setInboxFolderName("INBOX"); accountConfig.setSentFolderName("Sent"); accountConfig.setSpamFolderName("Spam"); accountConfig.setAutoExpandFolderName("INBOX"); accountConfig.setStoreUri("imap+ssl+://" + emailId.substring(0, emailId.indexOf("@")) + "%40eelo.io:" + password + "@mail.eelo.io"); accountConfig.setTransportUri("smtp+tls+://" + emailId.substring(0, emailId.indexOf("@")) + "%40eelo.io:" + password + "@mail.eelo.io"); Account account = preferences.newAccount(); account.loadConfig(accountConfig); MessagingController.getInstance(context).listFoldersSynchronous(account, true, null); MessagingController.getInstance(context) .synchronizeMailbox(account, account.getInboxFolderName(), null, null); account.save(preferences); preferences.setDefaultAccount(account); K9.setServicesEnabled(context); } } Loading
k9mail/src/main/java/io/eelo/mail/account/K9OAuth2TokenProvider.java +2 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ import io.eelo.mail.mail.AuthenticationFailedException; import io.eelo.mail.mail.OAuth2NeedUserPromptException; import io.eelo.mail.mail.oauth.OAuth2TokenProvider; import static io.eelo.mail.account.OAuthConstants.ACCOUNT_EMAIL_ID_KEY; import static io.eelo.mail.account.OAuthConstants.ACCOUNT_USER_NAME_KEY; import static io.eelo.mail.account.OAuthConstants.AUTH_TOKEN_TYPE; import static io.eelo.mail.account.OAuthConstants.EELO_ACCOUNT_TYPE; import static io.eelo.mail.account.OAuthConstants.GOOGLE_ACCOUNT_TYPE; Loading Loading @@ -88,7 +88,7 @@ public class K9OAuth2TokenProvider extends OAuth2TokenProvider { if (accounts.size() > 0) { for (Account account : accounts) { String accountEmailId = accountManager.getUserData(account, ACCOUNT_EMAIL_ID_KEY); ACCOUNT_USER_NAME_KEY); if (emailId.equals(accountEmailId)) { final CountDownLatch countDownLatch = new CountDownLatch(1); accountManager.getAuthToken(account, AUTH_TOKEN_TYPE, new Bundle(), Loading
k9mail/src/main/java/io/eelo/mail/account/OAuthConstants.java +1 −1 Original line number Diff line number Diff line Loading @@ -3,6 +3,6 @@ package io.eelo.mail.account; public class OAuthConstants { public static final String EELO_ACCOUNT_TYPE = "bitfire.at.davdroid.eelo"; public static final String GOOGLE_ACCOUNT_TYPE = "bitfire.at.davdroid.google"; public static final String ACCOUNT_EMAIL_ID_KEY = "email_id"; public static final String ACCOUNT_USER_NAME_KEY = "user_name"; public static final String AUTH_TOKEN_TYPE = "oauth2-access-token"; }
k9mail/src/main/java/io/eelo/mail/activity/Accounts.java +6 −4 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import io.eelo.mail.K9; import io.eelo.mail.Preferences; import io.eelo.mail.activity.misc.ExtendedAsyncTask; import io.eelo.mail.activity.misc.NonConfigurationInstance; import io.eelo.mail.activity.setup.EeloAccountCreator; import io.eelo.mail.activity.setup.GoogleAccountCreator; import io.eelo.mail.controller.MessagingController; import io.eelo.mail.mail.AuthType; Loading Loading @@ -95,7 +96,7 @@ import io.eelo.mail.mailstore.StorageManager; import io.eelo.mail.preferences.SettingsExporter; import de.cketti.library.changelog.ChangeLog; import static io.eelo.mail.account.OAuthConstants.ACCOUNT_EMAIL_ID_KEY; import static io.eelo.mail.account.OAuthConstants.ACCOUNT_USER_NAME_KEY; import static io.eelo.mail.account.OAuthConstants.EELO_ACCOUNT_TYPE; import static io.eelo.mail.account.OAuthConstants.GOOGLE_ACCOUNT_TYPE; Loading Loading @@ -479,13 +480,14 @@ public class Accounts extends K9ListActivity implements OnItemClickListener { for (android.accounts.Account eeloAccount : eeloAccounts) { String emailId = accountManager.getUserData(eeloAccount, ACCOUNT_EMAIL_ID_KEY); //TODO Add /e/ accounts ACCOUNT_USER_NAME_KEY); String password = accountManager.getPassword(eeloAccount); EeloAccountCreator.createAccount(this, emailId, password); } for (android.accounts.Account googleAccount : googleAccounts) { String emailId = accountManager.getUserData(googleAccount, ACCOUNT_EMAIL_ID_KEY); ACCOUNT_USER_NAME_KEY); GoogleAccountCreator.createAccount(this, emailId); } Loading
k9mail/src/main/java/io/eelo/mail/activity/setup/EeloAccountCreator.java 0 → 100644 +42 −0 Original line number Diff line number Diff line package io.eelo.mail.activity.setup; import android.content.Context; import io.eelo.mail.Account; import io.eelo.mail.K9; import io.eelo.mail.Preferences; import io.eelo.mail.controller.MessagingController; public class EeloAccountCreator { public static void createAccount(Context context, String emailId, String password) { Preferences preferences = Preferences.getPreferences(context); AccountConfigImpl accountConfig = new AccountConfigImpl(preferences); accountConfig.setEmail(emailId); accountConfig.setDescription(emailId); accountConfig.setTrashFolderName("Trash"); accountConfig.setArchiveFolderName("Archive"); accountConfig.setDraftsFolderName("Drafts"); accountConfig.setInboxFolderName("INBOX"); accountConfig.setSentFolderName("Sent"); accountConfig.setSpamFolderName("Spam"); accountConfig.setAutoExpandFolderName("INBOX"); accountConfig.setStoreUri("imap+ssl+://" + emailId.substring(0, emailId.indexOf("@")) + "%40eelo.io:" + password + "@mail.eelo.io"); accountConfig.setTransportUri("smtp+tls+://" + emailId.substring(0, emailId.indexOf("@")) + "%40eelo.io:" + password + "@mail.eelo.io"); Account account = preferences.newAccount(); account.loadConfig(accountConfig); MessagingController.getInstance(context).listFoldersSynchronous(account, true, null); MessagingController.getInstance(context) .synchronizeMailbox(account, account.getInboxFolderName(), null, null); account.save(preferences); preferences.setDefaultAccount(account); K9.setServicesEnabled(context); } }