Added cross account copy

This commit is contained in:
M66B 2021-08-17 20:28:58 +02:00
parent dd56ad86d7
commit 6c3da926d0
3 changed files with 25 additions and 3 deletions

View File

@ -998,6 +998,7 @@ class Core {
// Get arguments
long target = jargs.optLong(0, folder.id);
boolean autoread = jargs.optBoolean(1, false);
boolean copy = jargs.optBoolean(2, false); // Cross account
if (target != folder.id)
throw new IllegalArgumentException("Invalid folder");
@ -1161,7 +1162,8 @@ class Core {
EntityOperation.queue(context, message, EntityOperation.SEEN, true);
// Delete source
EntityOperation.queue(context, message, EntityOperation.DELETE);
if (!copy)
EntityOperation.queue(context, message, EntityOperation.DELETE);
}
db.setTransactionSuccessful();
@ -1704,7 +1706,7 @@ class Core {
}
if (jargs.length() > 0) {
// Cross account move
// Cross account move/copy
long tid = jargs.getLong(0);
EntityFolder target = db.folder().getFolder(tid);
if (target == null)

View File

@ -355,6 +355,26 @@ public class EntityOperation {
}
return;
} else if (COPY.equals(name)) {
// Parameters in:
// 0: target folder
// 1: mark seen
EntityFolder source = db.folder().getFolder(message.folder);
EntityFolder target = db.folder().getFolder(jargs.getLong(0));
if (source == null || target == null)
return;
// Cross account copy
if (!source.account.equals(target.account)) {
jargs.put(2, true); // copy
if (message.raw != null && message.raw)
queue(context, target.account, target.id, message.id, ADD, jargs);
else
queue(context, source.account, source.id, message.id, RAW, jargs);
return;
}
} else if (DELETE.equals(name)) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean perform_expunge = prefs.getBoolean("perform_expunge", true);

View File

@ -67,7 +67,7 @@ public class FragmentDialogFolder extends FragmentDialogBase {
final String title = aargs.getString("title");
final long account = aargs.getLong("account");
final long[] disabled = aargs.getLongArray("disabled");
final boolean cancopy = aargs.getBoolean("cancopy") && false;
final boolean cancopy = aargs.getBoolean("cancopy");
final Context context = getContext();
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);