|
|
@ -764,6 +764,8 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
// Close store
|
|
|
|
// Close store
|
|
|
|
Log.i(Helper.TAG, account.name + " closing");
|
|
|
|
Log.i(Helper.TAG, account.name + " closing");
|
|
|
|
db.account().setAccountState(account.id, "closing");
|
|
|
|
db.account().setAccountState(account.id, "closing");
|
|
|
|
|
|
|
|
for (EntityFolder folder : folders.keySet())
|
|
|
|
|
|
|
|
db.folder().setFolderState(folder.id, "closing");
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// This can take some time
|
|
|
|
// This can take some time
|
|
|
|
istore.close();
|
|
|
|
istore.close();
|
|
|
@ -1173,10 +1175,11 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void synchronizeMessages(EntityAccount account, EntityFolder folder, IMAPFolder ifolder, ServiceState state) throws MessagingException, IOException {
|
|
|
|
private void synchronizeMessages(EntityAccount account, EntityFolder folder, IMAPFolder ifolder, ServiceState state) throws MessagingException, IOException {
|
|
|
|
|
|
|
|
DB db = DB.getInstance(this);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Log.v(Helper.TAG, folder.name + " start sync after=" + folder.after);
|
|
|
|
Log.v(Helper.TAG, folder.name + " start sync after=" + folder.after);
|
|
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(this);
|
|
|
|
db.folder().setFolderState(folder.id, "syncing");
|
|
|
|
|
|
|
|
|
|
|
|
// Get reference times
|
|
|
|
// Get reference times
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
@ -1283,6 +1286,7 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
Log.w(Helper.TAG, folder.name + " statistics added=" + added + " updated=" + updated + " unchanged=" + unchanged);
|
|
|
|
Log.w(Helper.TAG, folder.name + " statistics added=" + added + " updated=" + updated + " unchanged=" + unchanged);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
Log.v(Helper.TAG, folder.name + " end sync");
|
|
|
|
Log.v(Helper.TAG, folder.name + " end sync");
|
|
|
|
|
|
|
|
db.folder().setFolderState(folder.id, ifolder.isOpen() ? "connected" : "disconnected");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1579,20 +1583,23 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
|
|
|
|
|
|
|
private BroadcastReceiver outboxReceiver = new BroadcastReceiver() {
|
|
|
|
private BroadcastReceiver outboxReceiver = new BroadcastReceiver() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
public void onReceive(final Context context, Intent intent) {
|
|
|
|
Log.v(Helper.TAG, outbox.name + " run operations");
|
|
|
|
Log.v(Helper.TAG, outbox.name + " run operations");
|
|
|
|
|
|
|
|
|
|
|
|
executor.submit(new Runnable() {
|
|
|
|
executor.submit(new Runnable() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Log.i(Helper.TAG, outbox.name + " start operations");
|
|
|
|
Log.i(Helper.TAG, outbox.name + " start operations");
|
|
|
|
|
|
|
|
db.folder().setFolderState(outbox.id, "syncing");
|
|
|
|
processOperations(outbox, null, null, null);
|
|
|
|
processOperations(outbox, null, null, null);
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
Log.e(Helper.TAG, outbox.name + " " + ex + "\n" + Log.getStackTraceString(ex));
|
|
|
|
Log.e(Helper.TAG, outbox.name + " " + ex + "\n" + Log.getStackTraceString(ex));
|
|
|
|
reportError(null, outbox.name, ex);
|
|
|
|
reportError(null, outbox.name, ex);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
Log.i(Helper.TAG, outbox.name + " end operations");
|
|
|
|
Log.i(Helper.TAG, outbox.name + " end operations");
|
|
|
|
|
|
|
|
db.folder().setFolderState(outbox.id, "connected");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|