1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-24 02:12:15 -05:00

extract out "sync one account"

This commit is contained in:
Jesse Vincent 2010-11-28 20:28:42 +00:00
parent 4f376e8332
commit 36bb10fb2c
3 changed files with 202 additions and 187 deletions

View File

@ -4282,6 +4282,47 @@ public class MessagingController implements Runnable
} }
for (final Account account : accounts) for (final Account account : accounts)
{
checkMailForAccount(context, account,ignoreLastCheckedTime, notifMgr, prefs, listener);
}
}
catch (Exception e)
{
Log.e(K9.LOG_TAG, "Unable to synchronize mail", e);
addErrorMessage(account, null, e);
}
putBackground("finalize sync", null, new Runnable()
{
public void run()
{
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "Finished mail sync");
if (wakeLock != null)
{
wakeLock.release();
}
for (MessagingListener l : getListeners())
{
l.checkMailFinished(context, account);
}
}
}
);
}
});
}
private void checkMailForAccount(final Context context, final Account account,
final boolean ignoreLastCheckedTime,
final NotificationManager notifMgr,
final Preferences prefs,
final MessagingListener listener)
{ {
if (!account.isAvailable(context)) if (!account.isAvailable(context))
{ {
@ -4289,14 +4330,14 @@ public class MessagingController implements Runnable
{ {
Log.i(K9.LOG_TAG, "Skipping synchronizing unavailable account " + account.getDescription()); Log.i(K9.LOG_TAG, "Skipping synchronizing unavailable account " + account.getDescription());
} }
continue; return;
} }
final long accountInterval = account.getAutomaticCheckIntervalMinutes() * 60 * 1000; final long accountInterval = account.getAutomaticCheckIntervalMinutes() * 60 * 1000;
if (!ignoreLastCheckedTime && accountInterval <= 0) if (!ignoreLastCheckedTime && accountInterval <= 0)
{ {
if (K9.DEBUG) if (K9.DEBUG)
Log.i(K9.LOG_TAG, "Skipping synchronizing account " + account.getDescription()); Log.i(K9.LOG_TAG, "Skipping synchronizing account " + account.getDescription());
continue; return;
} }
if (K9.DEBUG) if (K9.DEBUG)
@ -4330,7 +4371,7 @@ public class MessagingController implements Runnable
" which is in display mode " + fDisplayClass + " while account is in display mode " + aDisplayMode); " which is in display mode " + fDisplayClass + " while account is in display mode " + aDisplayMode);
*/ */
continue; return;
} }
if (modeMismatch(aSyncMode, fSyncClass)) if (modeMismatch(aSyncMode, fSyncClass))
@ -4342,7 +4383,7 @@ public class MessagingController implements Runnable
" which is in sync mode " + fSyncClass + " while account is in sync mode " + aSyncMode); " which is in sync mode " + fSyncClass + " while account is in sync mode " + aSyncMode);
*/ */
continue; return;
} }
if (K9.DEBUG) if (K9.DEBUG)
@ -4357,7 +4398,7 @@ public class MessagingController implements Runnable
+ ", previously synced @ " + new Date(folder.getLastChecked()) + ", previously synced @ " + new Date(folder.getLastChecked())
+ " which would be too recent for the account period"); + " which would be too recent for the account period");
continue; return;
} }
putBackground("sync" + folder.getName(), null, new Runnable() putBackground("sync" + folder.getName(), null, new Runnable()
{ {
@ -4465,35 +4506,9 @@ public class MessagingController implements Runnable
} }
}
catch (Exception e)
{
Log.e(K9.LOG_TAG, "Unable to synchronize mail", e);
addErrorMessage(account, null, e);
}
putBackground("finalize sync", null, new Runnable()
{
public void run()
{
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "Finished mail sync");
if (wakeLock != null)
{
wakeLock.release();
}
for (MessagingListener l : getListeners())
{
l.checkMailFinished(context, account);
}
}
}
);
}
});
}
public void compact(final Account account, final MessagingListener ml) public void compact(final Account account, final MessagingListener ml)
{ {