Loading app/core/src/main/java/com/fsck/k9/OsAccountManagerUtil.kt +21 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ import android.content.Context import app.k9mail.core.android.common.accountmanager.AccountManagerConstants import timber.log.Timber import com.fsck.k9.Account as K9Account object OsAccountManagerUtil { /** Loading Loading @@ -83,4 +85,23 @@ object OsAccountManagerUtil { fun isAccountFound() = this != ACCOUNT_NOT_FOUND } fun isMurenaEmailAccount(account: K9Account): Boolean { val incoming = account.incomingServerSettings val outgoing = account.outgoingServerSettings if (incoming.host == null || outgoing.host == null) { return false } return isMurenaMailHost(incoming.host!!) && isMurenaMailHost(outgoing.host!!) } private fun isMurenaMailHost(host: String): Boolean { return "mail.ecloud.global" == host } fun isMurenaWebHostUrl(host: String): Boolean { return host.contains("https://murena.io") || host.contains("http://murena.io") } } app/core/src/main/java/com/fsck/k9/controller/MessagingController.java +30 −23 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import com.fsck.k9.Account.DeletePolicy; import com.fsck.k9.Account.Expunge; import com.fsck.k9.DI; import com.fsck.k9.K9; import com.fsck.k9.OsAccountManagerUtil; import com.fsck.k9.Preferences; import com.fsck.k9.backend.BackendManager; import com.fsck.k9.backend.api.Backend; Loading Loading @@ -671,10 +672,17 @@ public class MessagingController { } private boolean updatePassword(Account account) { if (!OsAccountManagerUtil.INSTANCE.isMurenaEmailAccount(account)) return false; AccountManager accountManager = AccountManager.get(context); android.accounts.Account[] eeloAccounts = accountManager.getAccountsByType(AccountManagerConstants.EELO_ACCOUNT_TYPE); for (String accountType : AccountManagerConstants.INSTANCE.getALL_ACCOUNT_TYPES()) { for (android.accounts.Account deviceAccount : accountManager.getAccountsByType(accountType)) { for (android.accounts.Account deviceAccount : eeloAccounts) { String hostUrl = accountManager.getUserData(deviceAccount, AccountManagerConstants.KEY_OC_BASE_URL); if (hostUrl == null || !OsAccountManagerUtil.INSTANCE.isMurenaWebHostUrl(hostUrl)) { continue; } // Check if the account email matches with account manager String emailId = accountManager.getUserData(deviceAccount, AccountManagerConstants.ACCOUNT_EMAIL_ADDRESS_KEY); Loading @@ -700,7 +708,6 @@ public class MessagingController { return true; } } } return false; } Loading app/ui/legacy/src/main/java/com/fsck/k9/activity/setup/accountmanager/EeloAccountCreator.java +9 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import com.fsck.k9.Account; import com.fsck.k9.Account.DeletePolicy; import com.fsck.k9.Core; import com.fsck.k9.DI; import com.fsck.k9.OsAccountManagerUtil; import com.fsck.k9.Preferences; import com.fsck.k9.account.AccountCreatorHelper; import com.fsck.k9.account.BackgroundAccountRemover; Loading Loading @@ -140,6 +141,9 @@ public class EeloAccountCreator { } private static void updatePasswordIfChanged(Account account, String password) { // Don't update password if its not a murena account if (!OsAccountManagerUtil.INSTANCE.isMurenaEmailAccount(account)) return; ServerSettings incoming = account.getIncomingServerSettings(); ServerSettings outgoing = account.getOutgoingServerSettings(); Loading Loading @@ -170,6 +174,11 @@ public class EeloAccountCreator { accountManager.getAccountsByType(AccountManagerConstants.EELO_ACCOUNT_TYPE); for (android.accounts.Account eeloAccount : eeloAccounts) { final String emailId = getEmailId(accountManager, eeloAccount); String hostUrl = accountManager.getUserData(eeloAccount, AccountManagerConstants.KEY_OC_BASE_URL); // We are trying to add account that are not murena. if (hostUrl == null || !OsAccountManagerUtil.INSTANCE.isMurenaWebHostUrl(hostUrl)) { continue; } if (isInvalidEmail(emailId)) { continue; Loading core/android/common/src/main/kotlin/app/k9mail/core/android/common/accountmanager/AccountManagerConstants.kt +1 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ object AccountManagerConstants { const val AUTH_TOKEN_TYPE = "oauth2-access-token" const val KEY_AUTH_STATE = "auth_state" const val USERNAME_HINT = "userNameHint" const val KEY_OC_BASE_URL = "oc_base_url" const val OPEN_APP_PACKAGE_AFTER_AUTH = "open_app_package_after_auth" const val OPEN_APP_ACTIVITY_AFTER_AUTH = "open_app_activity_after_auth" Loading Loading
app/core/src/main/java/com/fsck/k9/OsAccountManagerUtil.kt +21 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ import android.content.Context import app.k9mail.core.android.common.accountmanager.AccountManagerConstants import timber.log.Timber import com.fsck.k9.Account as K9Account object OsAccountManagerUtil { /** Loading Loading @@ -83,4 +85,23 @@ object OsAccountManagerUtil { fun isAccountFound() = this != ACCOUNT_NOT_FOUND } fun isMurenaEmailAccount(account: K9Account): Boolean { val incoming = account.incomingServerSettings val outgoing = account.outgoingServerSettings if (incoming.host == null || outgoing.host == null) { return false } return isMurenaMailHost(incoming.host!!) && isMurenaMailHost(outgoing.host!!) } private fun isMurenaMailHost(host: String): Boolean { return "mail.ecloud.global" == host } fun isMurenaWebHostUrl(host: String): Boolean { return host.contains("https://murena.io") || host.contains("http://murena.io") } }
app/core/src/main/java/com/fsck/k9/controller/MessagingController.java +30 −23 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import com.fsck.k9.Account.DeletePolicy; import com.fsck.k9.Account.Expunge; import com.fsck.k9.DI; import com.fsck.k9.K9; import com.fsck.k9.OsAccountManagerUtil; import com.fsck.k9.Preferences; import com.fsck.k9.backend.BackendManager; import com.fsck.k9.backend.api.Backend; Loading Loading @@ -671,10 +672,17 @@ public class MessagingController { } private boolean updatePassword(Account account) { if (!OsAccountManagerUtil.INSTANCE.isMurenaEmailAccount(account)) return false; AccountManager accountManager = AccountManager.get(context); android.accounts.Account[] eeloAccounts = accountManager.getAccountsByType(AccountManagerConstants.EELO_ACCOUNT_TYPE); for (String accountType : AccountManagerConstants.INSTANCE.getALL_ACCOUNT_TYPES()) { for (android.accounts.Account deviceAccount : accountManager.getAccountsByType(accountType)) { for (android.accounts.Account deviceAccount : eeloAccounts) { String hostUrl = accountManager.getUserData(deviceAccount, AccountManagerConstants.KEY_OC_BASE_URL); if (hostUrl == null || !OsAccountManagerUtil.INSTANCE.isMurenaWebHostUrl(hostUrl)) { continue; } // Check if the account email matches with account manager String emailId = accountManager.getUserData(deviceAccount, AccountManagerConstants.ACCOUNT_EMAIL_ADDRESS_KEY); Loading @@ -700,7 +708,6 @@ public class MessagingController { return true; } } } return false; } Loading
app/ui/legacy/src/main/java/com/fsck/k9/activity/setup/accountmanager/EeloAccountCreator.java +9 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import com.fsck.k9.Account; import com.fsck.k9.Account.DeletePolicy; import com.fsck.k9.Core; import com.fsck.k9.DI; import com.fsck.k9.OsAccountManagerUtil; import com.fsck.k9.Preferences; import com.fsck.k9.account.AccountCreatorHelper; import com.fsck.k9.account.BackgroundAccountRemover; Loading Loading @@ -140,6 +141,9 @@ public class EeloAccountCreator { } private static void updatePasswordIfChanged(Account account, String password) { // Don't update password if its not a murena account if (!OsAccountManagerUtil.INSTANCE.isMurenaEmailAccount(account)) return; ServerSettings incoming = account.getIncomingServerSettings(); ServerSettings outgoing = account.getOutgoingServerSettings(); Loading Loading @@ -170,6 +174,11 @@ public class EeloAccountCreator { accountManager.getAccountsByType(AccountManagerConstants.EELO_ACCOUNT_TYPE); for (android.accounts.Account eeloAccount : eeloAccounts) { final String emailId = getEmailId(accountManager, eeloAccount); String hostUrl = accountManager.getUserData(eeloAccount, AccountManagerConstants.KEY_OC_BASE_URL); // We are trying to add account that are not murena. if (hostUrl == null || !OsAccountManagerUtil.INSTANCE.isMurenaWebHostUrl(hostUrl)) { continue; } if (isInvalidEmail(emailId)) { continue; Loading
core/android/common/src/main/kotlin/app/k9mail/core/android/common/accountmanager/AccountManagerConstants.kt +1 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ object AccountManagerConstants { const val AUTH_TOKEN_TYPE = "oauth2-access-token" const val KEY_AUTH_STATE = "auth_state" const val USERNAME_HINT = "userNameHint" const val KEY_OC_BASE_URL = "oc_base_url" const val OPEN_APP_PACKAGE_AFTER_AUTH = "open_app_package_after_auth" const val OPEN_APP_ACTIVITY_AFTER_AUTH = "open_app_activity_after_auth" Loading