Search in sources :

Example 66 with K9

use of com.fsck.k9.K9 in project k-9 by k9mail.

the class DatabaseUpgradeService method upgradeDatabases.

/**
     * Upgrade the accounts' databases.
     */
private void upgradeDatabases() {
    Preferences preferences = Preferences.getPreferences(this);
    List<Account> accounts = preferences.getAccounts();
    mProgressEnd = accounts.size();
    mProgress = 0;
    for (Account account : accounts) {
        mAccountUuid = account.getUuid();
        sendProgressBroadcast(mAccountUuid, mProgress, mProgressEnd);
        try {
            // Account.getLocalStore() is blocking and will upgrade the database if necessary
            account.getLocalStore();
        } catch (UnavailableStorageException e) {
            Timber.e("Database unavailable");
        } catch (Exception e) {
            Timber.e(e, "Error while upgrading database");
        }
        mProgress++;
    }
    K9.setDatabasesUpToDate(true);
    sendUpgradeCompleteBroadcast();
}
Also used : Account(com.fsck.k9.Account) UnavailableStorageException(com.fsck.k9.mailstore.UnavailableStorageException) Preferences(com.fsck.k9.Preferences) UnavailableStorageException(com.fsck.k9.mailstore.UnavailableStorageException)

Aggregations

Account (com.fsck.k9.Account)20 MessagingException (com.fsck.k9.mail.MessagingException)13 IOException (java.io.IOException)11 ArrayList (java.util.ArrayList)11 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)10 LocalStore (com.fsck.k9.mailstore.LocalStore)10 Message (com.fsck.k9.mail.Message)9 Store (com.fsck.k9.mail.Store)9 LocalFolder (com.fsck.k9.mailstore.LocalFolder)9 UnavailableStorageException (com.fsck.k9.mailstore.UnavailableStorageException)9 Intent (android.content.Intent)8 Pop3Store (com.fsck.k9.mail.store.pop3.Pop3Store)8 LocalMessage (com.fsck.k9.mailstore.LocalMessage)8 SuppressLint (android.annotation.SuppressLint)7 BaseAccount (com.fsck.k9.BaseAccount)7 Preferences (com.fsck.k9.Preferences)7 AuthenticationFailedException (com.fsck.k9.mail.AuthenticationFailedException)7 CertificateValidationException (com.fsck.k9.mail.CertificateValidationException)7 Folder (com.fsck.k9.mail.Folder)7 SearchAccount (com.fsck.k9.search.SearchAccount)7