Added shortcuts for POP3 operations

This commit is contained in:
M66B 2023-01-25 10:33:16 +01:00
parent a9ca0f3339
commit 2902053f37
3 changed files with 39 additions and 44 deletions

View File

@ -411,25 +411,6 @@ class Core {
messages.addAll(similar.values());
switch (op.name) {
case EntityOperation.SEEN:
onSeen(context, jargs, folder, message, (POP3Folder) ifolder);
break;
case EntityOperation.FLAG:
onFlag(context, jargs, folder, message, (POP3Folder) ifolder);
break;
case EntityOperation.ANSWERED:
case EntityOperation.KEYWORD:
case EntityOperation.ADD:
case EntityOperation.REPORT:
// Do nothing
break;
case EntityOperation.EXISTS:
onExists(context, jargs, account, folder, message);
break;
case EntityOperation.MOVE:
onMove(context, jargs, account, folder, messages, (POP3Folder) ifolder, (POP3Store) istore, state);
break;
@ -1013,22 +994,6 @@ class Core {
db.message().setMessageDeleted(message.id, set);
}
private static void onSeen(Context context, JSONArray jargs, EntityFolder folder, EntityMessage message, POP3Folder ifolder) throws JSONException {
// Mark message (un)seen
DB db = DB.getInstance(context);
boolean seen = jargs.getBoolean(0);
db.message().setMessageUiSeen(message.id, seen);
}
private static void onFlag(Context context, JSONArray jargs, EntityFolder folder, EntityMessage message, POP3Folder ifolder) throws MessagingException, JSONException {
// Star/unstar message
DB db = DB.getInstance(context);
boolean flagged = jargs.getBoolean(0);
db.message().setMessageFlagged(message.id, flagged);
}
private static void onAnswered(Context context, JSONArray jargs, EntityFolder folder, EntityMessage message, IMAPFolder ifolder) throws MessagingException, JSONException {
// Mark message (un)answered
DB db = DB.getInstance(context);
@ -2265,11 +2230,6 @@ class Core {
EntityLog.log(context, "Operation attachment size=" + attachment.size);
}
private static void onExists(Context context, JSONArray jargs, EntityAccount account, EntityFolder folder, EntityMessage message) {
// POP3
EntityContact.received(context, account, folder, message);
}
private static void onExists(Context context, JSONArray jargs, EntityAccount account, EntityFolder folder, EntityMessage message, EntityOperation op, IMAPFolder ifolder) throws MessagingException, IOException {
DB db = DB.getInstance(context);

View File

@ -543,6 +543,44 @@ public class EntityOperation {
}
}
if (account != null) {
EntityAccount a = db.account().getAccount(account);
if (a != null && a.protocol == EntityAccount.TYPE_POP) {
// TODO: special cases for MOVE, DELETE, PURGE
if (SEEN.equals(name) ||
FLAG.equals(name) ||
ANSWERED.equals(name) ||
KEYWORD.equals(name) ||
ADD.equals(name) ||
REPORT.equals(name)) {
Log.i("POP3: skipping op=" + name);
return;
}
if (EXISTS.equals(name)) {
EntityFolder f = db.folder().getFolder(folder);
EntityMessage m = db.message().getMessage(message);
if (f != null && m != null) {
Log.i("POP3: inline EXISTS");
EntityContact.received(context, a, f, m);
return;
}
}
if (DELETE.equals(name)) {
EntityFolder f = db.folder().getFolder(folder);
if (f != null &&
(EntityFolder.DRAFTS.equals(f.type) ||
EntityFolder.TRASH.equals(f.type))) {
Log.i("POP3: inline DELETE folder=" + f.name);
db.message().deleteMessage(message);
return;
}
}
}
}
EntityOperation op = new EntityOperation();
op.account = account;
op.folder = folder;

View File

@ -858,10 +858,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
// Message could have been deleted
EntityMessage orphan = db.message().getMessage(sid);
if (orphan != null)
if (account == null || account.protocol == EntityAccount.TYPE_IMAP)
EntityOperation.queue(this, orphan, EntityOperation.EXISTS);
else if (sent != null)
EntityContact.received(this, account, sent, message);
EntityOperation.queue(this, orphan, EntityOperation.EXISTS);
db.setTransactionSuccessful();
} finally {