|
|
@ -431,11 +431,11 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
throw new IllegalStateException("synchronize folders", ex);
|
|
|
|
throw new IllegalStateException("synchronize folders", ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Synchronize folders
|
|
|
|
|
|
|
|
for (EntityFolder folder : db.folder().getFolders(account.id))
|
|
|
|
for (EntityFolder folder : db.folder().getFolders(account.id))
|
|
|
|
db.folder().setFolderState(folder.id, null);
|
|
|
|
db.folder().setFolderState(folder.id, null);
|
|
|
|
for (final EntityFolder folder : db.folder().getFolders(account.id, true))
|
|
|
|
|
|
|
|
try {
|
|
|
|
// Synchronize folders
|
|
|
|
|
|
|
|
for (final EntityFolder folder : db.folder().getFolders(account.id, true)) {
|
|
|
|
Log.i(Helper.TAG, account.name + " sync folder " + folder.name);
|
|
|
|
Log.i(Helper.TAG, account.name + " sync folder " + folder.name);
|
|
|
|
|
|
|
|
|
|
|
|
db.folder().setFolderState(folder.id, "connecting");
|
|
|
|
db.folder().setFolderState(folder.id, "connecting");
|
|
|
@ -447,6 +447,11 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
db.folder().setFolderState(folder.id, "connected");
|
|
|
|
db.folder().setFolderState(folder.id, "connected");
|
|
|
|
db.folder().setFolderError(folder.id, null);
|
|
|
|
db.folder().setFolderError(folder.id, null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Keep folder connection alive
|
|
|
|
|
|
|
|
Thread noop = new Thread(new Runnable() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
try {
|
|
|
|
// Listen for new and deleted messages
|
|
|
|
// Listen for new and deleted messages
|
|
|
|
ifolder.addMessageCountListener(new MessageCountAdapter() {
|
|
|
|
ifolder.addMessageCountListener(new MessageCountAdapter() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -535,11 +540,6 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Keep folder connection alive
|
|
|
|
|
|
|
|
Thread noop = new Thread(new Runnable() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Log.i(Helper.TAG, folder.name + " start noop");
|
|
|
|
Log.i(Helper.TAG, folder.name + " start noop");
|
|
|
|
while (state.running && ifolder.isOpen()) {
|
|
|
|
while (state.running && ifolder.isOpen()) {
|
|
|
|
Log.i(Helper.TAG, folder.name + " request NOOP");
|
|
|
|
Log.i(Helper.TAG, folder.name + " request NOOP");
|
|
|
@ -602,12 +602,6 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
}, "sync.idle." + folder.id);
|
|
|
|
}, "sync.idle." + folder.id);
|
|
|
|
idle.start();
|
|
|
|
idle.start();
|
|
|
|
idlers.add(idle);
|
|
|
|
idlers.add(idle);
|
|
|
|
} catch (MessagingException ex) {
|
|
|
|
|
|
|
|
// Don't show to user
|
|
|
|
|
|
|
|
throw new FolderClosedException(folders.get(folder), "start folder", ex);
|
|
|
|
|
|
|
|
} catch (IOException ex) {
|
|
|
|
|
|
|
|
// Don't show to user
|
|
|
|
|
|
|
|
throw new FolderClosedException(folders.get(folder), "start folder", ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BroadcastReceiver processReceiver = new BroadcastReceiver() {
|
|
|
|
BroadcastReceiver processReceiver = new BroadcastReceiver() {
|
|
|
|