|
|
|
@ -1007,12 +1007,12 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
db.endTransaction();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (db.folder().getFolderDownload(folder.id))
|
|
|
|
|
try {
|
|
|
|
|
db.beginTransaction();
|
|
|
|
|
downloadMessage(ServiceSynchronize.this,
|
|
|
|
|
folder, ifolder, (IMAPMessage) imessage,
|
|
|
|
|
message.id,
|
|
|
|
|
db.folder().getFolderDownload(folder.id));
|
|
|
|
|
folder, ifolder,
|
|
|
|
|
(IMAPMessage) imessage, message.id);
|
|
|
|
|
db.setTransactionSuccessful();
|
|
|
|
|
} finally {
|
|
|
|
|
db.endTransaction();
|
|
|
|
@ -1097,12 +1097,12 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
db.endTransaction();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (db.folder().getFolderDownload(folder.id))
|
|
|
|
|
try {
|
|
|
|
|
db.beginTransaction();
|
|
|
|
|
downloadMessage(ServiceSynchronize.this,
|
|
|
|
|
folder, ifolder, (IMAPMessage) e.getMessage(),
|
|
|
|
|
message.id,
|
|
|
|
|
db.folder().getFolderDownload(folder.id));
|
|
|
|
|
folder, ifolder,
|
|
|
|
|
(IMAPMessage) e.getMessage(), message.id);
|
|
|
|
|
db.setTransactionSuccessful();
|
|
|
|
|
} finally {
|
|
|
|
|
db.endTransaction();
|
|
|
|
@ -2281,6 +2281,7 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
// Delete not synchronized messages without uid
|
|
|
|
|
db.message().deleteOrphans(folder.id);
|
|
|
|
|
|
|
|
|
|
if (download) {
|
|
|
|
|
db.folder().setFolderSyncState(folder.id, "downloading");
|
|
|
|
|
|
|
|
|
|
//fp.add(IMAPFolder.FetchProfileItem.MESSAGE);
|
|
|
|
@ -2299,9 +2300,8 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
if (ids[from + j] != null)
|
|
|
|
|
downloadMessage(
|
|
|
|
|
this,
|
|
|
|
|
folder, ifolder, (IMAPMessage) isub[j],
|
|
|
|
|
ids[from + j],
|
|
|
|
|
download);
|
|
|
|
|
folder, ifolder,
|
|
|
|
|
(IMAPMessage) isub[j], ids[from + j]);
|
|
|
|
|
db.setTransactionSuccessful();
|
|
|
|
|
} catch (FolderClosedException ex) {
|
|
|
|
|
throw ex;
|
|
|
|
@ -2321,12 +2321,14 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
} catch (InterruptedException ignored) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (state.running)
|
|
|
|
|
db.folder().setFolderInitialized(folder.id);
|
|
|
|
|
db.folder().setFolderSync(folder.id, new Date().getTime());
|
|
|
|
|
|
|
|
|
|
db.folder().setFolderSync(folder.id, new Date().getTime());
|
|
|
|
|
db.folder().setFolderError(folder.id, null);
|
|
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
Log.i(folder.name + " end sync state=" + state);
|
|
|
|
|
db.folder().setFolderSyncState(folder.id, null);
|
|
|
|
@ -2577,14 +2579,13 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
|
|
|
|
|
static void downloadMessage(
|
|
|
|
|
Context context,
|
|
|
|
|
EntityFolder folder, IMAPFolder ifolder, IMAPMessage imessage,
|
|
|
|
|
long id, boolean download) throws MessagingException, IOException {
|
|
|
|
|
EntityFolder folder, IMAPFolder ifolder,
|
|
|
|
|
IMAPMessage imessage, long id) throws MessagingException, IOException {
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
EntityMessage message = db.message().getMessage(id);
|
|
|
|
|
if (message == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (download) {
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
|
long maxSize = prefs.getInt("download", 32768);
|
|
|
|
|
if (maxSize == 0)
|
|
|
|
@ -2642,7 +2643,6 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class ServiceManager extends ConnectivityManager.NetworkCallback {
|
|
|
|
|
private ServiceState state;
|
|
|
|
|