|
|
@ -438,10 +438,22 @@ class Core {
|
|
|
|
// Add message
|
|
|
|
// Add message
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get arguments
|
|
|
|
|
|
|
|
Long tmpid = (jargs.length() > 0 && !jargs.isNull(0) ? jargs.getLong(0) : null);
|
|
|
|
|
|
|
|
boolean autoread = (jargs.length() > 1 && jargs.getBoolean(1));
|
|
|
|
|
|
|
|
boolean across = (jargs.length() > 2 && jargs.getBoolean(2));
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (TextUtils.isEmpty(message.msgid))
|
|
|
|
if (TextUtils.isEmpty(message.msgid))
|
|
|
|
throw new IllegalArgumentException("Message ID missing");
|
|
|
|
throw new IllegalArgumentException("Message ID missing");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (EntityFolder.DRAFTS.equals(folder.type) &&
|
|
|
|
|
|
|
|
!folder.id.equals(message.folder) &&
|
|
|
|
|
|
|
|
!across) {
|
|
|
|
|
|
|
|
Log.i("Drafts moved folder=" + message.folder);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Delete previous message(s) with same ID
|
|
|
|
// Delete previous message(s) with same ID
|
|
|
|
if (folder.id.equals(message.folder)) {
|
|
|
|
if (folder.id.equals(message.folder)) {
|
|
|
|
// Prevent adding/deleting message
|
|
|
|
// Prevent adding/deleting message
|
|
|
@ -483,16 +495,12 @@ class Core {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Handle auto read
|
|
|
|
// Handle auto read
|
|
|
|
boolean autoread = false;
|
|
|
|
|
|
|
|
if (jargs.length() > 1) {
|
|
|
|
|
|
|
|
autoread = jargs.getBoolean(1);
|
|
|
|
|
|
|
|
if (ifolder.getPermanentFlags().contains(Flags.Flag.SEEN)) {
|
|
|
|
if (ifolder.getPermanentFlags().contains(Flags.Flag.SEEN)) {
|
|
|
|
if (autoread && !imessage.isSet(Flags.Flag.SEEN)) {
|
|
|
|
if (autoread && !imessage.isSet(Flags.Flag.SEEN)) {
|
|
|
|
Log.i(folder.name + " autoread");
|
|
|
|
Log.i(folder.name + " autoread");
|
|
|
|
imessage.setFlag(Flags.Flag.SEEN, true);
|
|
|
|
imessage.setFlag(Flags.Flag.SEEN, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Handle draft
|
|
|
|
// Handle draft
|
|
|
|
if (EntityFolder.DRAFTS.equals(folder.type))
|
|
|
|
if (EntityFolder.DRAFTS.equals(folder.type))
|
|
|
@ -532,15 +540,15 @@ class Core {
|
|
|
|
if (folder.id.equals(message.folder)) {
|
|
|
|
if (folder.id.equals(message.folder)) {
|
|
|
|
Log.i(folder.name + " Setting id=" + message.id + " uid=" + uid);
|
|
|
|
Log.i(folder.name + " Setting id=" + message.id + " uid=" + uid);
|
|
|
|
db.message().setMessageUid(message.id, uid);
|
|
|
|
db.message().setMessageUid(message.id, uid);
|
|
|
|
} else {
|
|
|
|
} else
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
db.beginTransaction();
|
|
|
|
|
|
|
|
|
|
|
|
// Cross account move
|
|
|
|
// Cross account move
|
|
|
|
if (jargs.length() > 0 && !jargs.isNull(0)) {
|
|
|
|
if (tmpid != null) {
|
|
|
|
long tmpid = jargs.getLong(0);
|
|
|
|
|
|
|
|
Log.i(folder.name + " Setting id=" + tmpid + " (tmp) appended uid=" + uid);
|
|
|
|
Log.i(folder.name + " Setting id=" + tmpid + " (tmp) appended uid=" + uid);
|
|
|
|
db.message().setMessageUid(tmpid, uid);
|
|
|
|
db.message().setMessageUid(tmpid, uid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
|
|
|
|
db.beginTransaction();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Mark source read
|
|
|
|
// Mark source read
|
|
|
|
if (autoread) {
|
|
|
|
if (autoread) {
|
|
|
@ -556,7 +564,6 @@ class Core {
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
db.endTransaction();
|
|
|
|
db.endTransaction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
if (folder.id.equals(message.folder))
|
|
|
|
if (folder.id.equals(message.folder))
|
|
|
|
db.message().setMessageUid(message.id, message.uid);
|
|
|
|
db.message().setMessageUid(message.id, message.uid);
|
|
|
@ -664,6 +671,7 @@ class Core {
|
|
|
|
// Cross account move
|
|
|
|
// Cross account move
|
|
|
|
long target = jargs.getLong(2);
|
|
|
|
long target = jargs.getLong(2);
|
|
|
|
jargs.remove(2);
|
|
|
|
jargs.remove(2);
|
|
|
|
|
|
|
|
jargs.put(2, true); // cross account
|
|
|
|
Log.i(folder.name + " queuing ADD id=" + message.id + ":" + target);
|
|
|
|
Log.i(folder.name + " queuing ADD id=" + message.id + ":" + target);
|
|
|
|
|
|
|
|
|
|
|
|
EntityOperation operation = new EntityOperation();
|
|
|
|
EntityOperation operation = new EntityOperation();
|
|
|
|