mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-02 15:17:03 +02:00
Added on demand process
This commit is contained in:
@@ -98,10 +98,14 @@ public class EntityOperation {
|
||||
queue(context, db, message, name, jargs);
|
||||
}
|
||||
|
||||
static void sync(Context context, DB db, long fid) {
|
||||
static void sync(Context context, long fid) {
|
||||
DB db = DB.getInstance(context);
|
||||
if (db.operation().getOperationCount(fid, EntityOperation.SYNC) == 0) {
|
||||
|
||||
EntityFolder folder = db.folder().getFolder(fid);
|
||||
EntityAccount account = null;
|
||||
if (folder.account != null)
|
||||
account = db.account().getAccount(folder.account);
|
||||
|
||||
EntityOperation operation = new EntityOperation();
|
||||
operation.folder = folder.id;
|
||||
@@ -111,10 +115,16 @@ public class EntityOperation {
|
||||
operation.created = new Date().getTime();
|
||||
operation.id = db.operation().insertOperation(operation);
|
||||
|
||||
db.folder().setFolderSyncState(fid, "requested");
|
||||
if (account != null && account.ondemand) {
|
||||
db.folder().setFolderState(fid, "waiting");
|
||||
db.folder().setFolderSyncState(fid, "manual");
|
||||
} else
|
||||
db.folder().setFolderSyncState(fid, "requested");
|
||||
|
||||
if (folder.account == null) // Outbox
|
||||
if (account == null) // Outbox
|
||||
ServiceSend.start(context);
|
||||
else if (account.ondemand)
|
||||
ServiceUI.process(context, fid);
|
||||
|
||||
Log.i("Queued sync folder=" + folder);
|
||||
}
|
||||
@@ -225,8 +235,6 @@ public class EntityOperation {
|
||||
} else if (DELETE.equals(name))
|
||||
db.message().setMessageUiHide(message.id, true);
|
||||
|
||||
else if (SEND.equals(name))
|
||||
ServiceSend.start(context);
|
||||
} catch (JSONException ex) {
|
||||
Log.e(ex);
|
||||
}
|
||||
@@ -242,6 +250,14 @@ public class EntityOperation {
|
||||
Log.i("Queued op=" + operation.id + "/" + operation.name +
|
||||
" msg=" + operation.folder + "/" + operation.message +
|
||||
" args=" + operation.args);
|
||||
|
||||
if (SEND.equals(name))
|
||||
ServiceSend.start(context);
|
||||
else {
|
||||
EntityAccount account = db.account().getAccount(message.account);
|
||||
if (account.ondemand)
|
||||
ServiceUI.process(context, operation.folder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user