/** * Start background synchronization of the specified folder. */ public void synchronizeMailbox(final Account account, final String folder, final MessagingListener listener, final Folder providedRemoteFolder) { putBackground("synchronizeMailbox", listener, new Runnable() { @Override public void run() { synchronizeMailboxSynchronous(account, folder, listener, providedRemoteFolder); } }); }
public void expunge(final Account account, final String folder) { putBackground("expunge", null, new Runnable() { @Override public void run() { queueExpunge(account, folder); } }); }
public void clearFolder(final Account account, final String folderServerId, final MessagingListener listener) { putBackground("clearFolder", listener, new Runnable() { @Override public void run() { clearFolderSynchronous(account, folderServerId, listener); } }); }
private void processPendingCommands(final Account account) { putBackground("processPendingCommands", null, new Runnable() { @Override public void run() { try { processPendingCommandsSynchronous(account); } catch (UnavailableStorageException e) { Timber.i("Failed to process pending command because storage is not available - " + "trying again later."); throw new UnavailableAccountException(e); } catch (MessagingException me) { Timber.e(me, "processPendingCommands"); /* * Ignore any exceptions from the commands. Commands will be processed * on the next round. */ } } }); }
/** * Attempt to send any messages that are sitting in the Outbox. */ public void sendPendingMessages(final Account account, MessagingListener listener) { putBackground("sendPendingMessages", listener, new Runnable() { @Override public void run() { if (!account.isAvailable(context)) { throw new UnavailableAccountException(); } if (messagesPendingSend(account)) { showSendingNotificationIfNecessary(account); try { sendPendingMessagesSynchronous(account); } finally { clearSendingNotificationIfNecessary(account); } } } }); }
public void emptyTrash(final Account account, MessagingListener listener) { putBackground("emptyTrash", listener, new Runnable() { @Override public void run() {
private void queueSetFlag(final Account account, final String folderServerId, final boolean newState, final Flag flag, final List<String> uids) { putBackground("queueSetFlag " + account.getDescription() + ":" + folderServerId, null, new Runnable() { @Override public void run() { PendingCommand command = PendingSetFlag.create(folderServerId, newState, flag, uids); queuePendingCommand(account, command); processPendingCommands(account); } }); }
private void queueExpunge(final Account account, final String folderServerId) { putBackground("queueExpunge " + account.getDescription() + ":" + folderServerId, null, new Runnable() { @Override public void run() { PendingCommand command = PendingExpunge.create(folderServerId); queuePendingCommand(account, command); processPendingCommands(account); } }); }
public void compact(final Account account, final MessagingListener ml) { putBackground("compact:" + account.getDescription(), ml, new Runnable() { @Override public void run() { try { LocalStore localStore = localStoreProvider.getInstance(account); long oldSize = localStore.getSize(); localStore.compact(); long newSize = localStore.getSize(); for (MessagingListener l : getListeners(ml)) { l.accountSizeChanged(account, oldSize, newSize); } } catch (UnavailableStorageException e) { Timber.i("Failed to compact account because storage is not available - trying again later."); throw new UnavailableAccountException(e); } catch (Exception e) { Timber.e(e, "Failed to compact account %s", account.getDescription()); } } }); }
public void clear(final Account account, final MessagingListener ml) { putBackground("clear:" + account.getDescription(), ml, new Runnable() { @Override public void run() { try { LocalStore localStore = localStoreProvider.getInstance(account); long oldSize = localStore.getSize(); localStore.clear(); localStore.resetVisibleLimits(account.getDisplayCount()); long newSize = localStore.getSize(); AccountStats stats = new AccountStats(); stats.size = newSize; stats.unreadMessageCount = 0; stats.flaggedMessageCount = 0; for (MessagingListener l : getListeners(ml)) { l.accountSizeChanged(account, oldSize, newSize); l.accountStatusChanged(account, stats); } } catch (UnavailableStorageException e) { Timber.i("Failed to clear account because storage is not available - trying again later."); throw new UnavailableAccountException(e); } catch (Exception e) { Timber.e(e, "Failed to clear account %s", account.getDescription()); } } }); }
public void recreate(final Account account, final MessagingListener ml) { putBackground("recreate:" + account.getDescription(), ml, new Runnable() { @Override public void run() { try { LocalStore localStore = localStoreProvider.getInstance(account); long oldSize = localStore.getSize(); localStore.recreate(); localStore.resetVisibleLimits(account.getDisplayCount()); long newSize = localStore.getSize(); AccountStats stats = new AccountStats(); stats.size = newSize; stats.unreadMessageCount = 0; stats.flaggedMessageCount = 0; for (MessagingListener l : getListeners(ml)) { l.accountSizeChanged(account, oldSize, newSize); l.accountStatusChanged(account, stats); } } catch (UnavailableStorageException e) { Timber.i("Failed to recreate an account because storage is not available - trying again later."); throw new UnavailableAccountException(e); } catch (Exception e) { Timber.e(e, "Failed to recreate account %s", account.getDescription()); } } }); }
putBackground("sync" + folder.getServerId(), null, new Runnable() { @Override public void run() {
l.checkMailStarted(context, account); putBackground("checkMail", listener, new Runnable() { @Override public void run() {
Timber.e(e, "Unable to synchronize account %s", account.getName()); } finally { putBackground("clear notification flag for " + account.getDescription(), null, new Runnable() { @Override public void run() {