|
|
@ -397,6 +397,7 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
Thread t = new Thread(new Runnable() {
|
|
|
|
Thread t = new Thread(new Runnable() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
boolean connected = false;
|
|
|
|
IMAPFolder ifolder = null;
|
|
|
|
IMAPFolder ifolder = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Log.i(Helper.TAG, folder.name + " start");
|
|
|
|
Log.i(Helper.TAG, folder.name + " start");
|
|
|
@ -406,6 +407,7 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
ifolder = (IMAPFolder) fstore.getFolder(folder.name);
|
|
|
|
ifolder = (IMAPFolder) fstore.getFolder(folder.name);
|
|
|
|
ifolder.open(Folder.READ_WRITE);
|
|
|
|
ifolder.open(Folder.READ_WRITE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connected = true;
|
|
|
|
db.folder().setFolderState(folder.id, "connected");
|
|
|
|
db.folder().setFolderState(folder.id, "connected");
|
|
|
|
db.folder().setFolderError(folder.id, null);
|
|
|
|
db.folder().setFolderError(folder.id, null);
|
|
|
|
|
|
|
|
|
|
|
@ -423,19 +425,23 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
// Happens when syncing message
|
|
|
|
// Happens when syncing message
|
|
|
|
// This operation is not allowed on a closed folder
|
|
|
|
// This operation is not allowed on a closed folder
|
|
|
|
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
|
|
|
|
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
|
|
|
// MessagingException
|
|
|
|
|
|
|
|
// - message: connection failure
|
|
|
|
|
|
|
|
// - event: Too many simultaneous connections. (Failure)
|
|
|
|
|
|
|
|
|
|
|
|
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
|
|
|
|
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
|
|
|
|
reportError(account.name, folder.name, ex);
|
|
|
|
reportError(account.name, folder.name, ex);
|
|
|
|
|
|
|
|
|
|
|
|
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
|
|
|
|
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
|
|
|
|
|
|
|
|
|
|
|
|
// Cascade up
|
|
|
|
// Cascade up
|
|
|
|
try {
|
|
|
|
if (connected)
|
|
|
|
fstore.close();
|
|
|
|
try {
|
|
|
|
} catch (MessagingException e1) {
|
|
|
|
fstore.close();
|
|
|
|
Log.w(Helper.TAG, account.name + " " + e1 + "\n" + Log.getStackTraceString(e1));
|
|
|
|
} catch (MessagingException e1) {
|
|
|
|
}
|
|
|
|
Log.w(Helper.TAG, account.name + " " + e1 + "\n" + Log.getStackTraceString(e1));
|
|
|
|
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
if (ifolder != null && ifolder.isOpen()) {
|
|
|
|
if (ifolder != null && ifolder.isOpen()) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|