Added on demand process

This commit is contained in:
M66B
2019-02-28 18:13:28 +00:00
parent 9d15ccc695
commit c39b85c139
11 changed files with 115 additions and 52 deletions

View File

@@ -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