|
|
|
@ -216,7 +216,7 @@ class Core {
|
|
|
|
|
// Do nothing
|
|
|
|
|
break;
|
|
|
|
|
case EntityOperation.DELETE:
|
|
|
|
|
onDelete(context, jargs, folder, message, (POP3Folder) ifolder);
|
|
|
|
|
onDelete(context, jargs, folder, message, (POP3Folder) ifolder, state);
|
|
|
|
|
break;
|
|
|
|
|
case EntityOperation.SYNC:
|
|
|
|
|
onSynchronizeMessages(context, jargs, account, folder, (POP3Folder) ifolder, state);
|
|
|
|
@ -806,12 +806,39 @@ class Core {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void onDelete(Context context, JSONArray jargs, EntityFolder folder, EntityMessage message, POP3Folder ifolder) throws MessagingException {
|
|
|
|
|
private static void onDelete(Context context, JSONArray jargs, EntityFolder folder, EntityMessage message, POP3Folder ifolder, State state) throws MessagingException {
|
|
|
|
|
// Delete message
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
|
|
|
|
|
if (EntityFolder.INBOX.equals(folder.type)) {
|
|
|
|
|
// Do nothing
|
|
|
|
|
Message[] imessages = ifolder.getMessages();
|
|
|
|
|
Log.i(folder.name + " POP messages=" + imessages.length);
|
|
|
|
|
|
|
|
|
|
boolean found = false;
|
|
|
|
|
for (Message imessage : imessages) {
|
|
|
|
|
MessageHelper helper = new MessageHelper((MimeMessage) imessage);
|
|
|
|
|
String msgid = helper.getMessageID();
|
|
|
|
|
if (msgid != null && msgid.equals(message.msgid)) {
|
|
|
|
|
found = true;
|
|
|
|
|
Log.i(folder.name + " POP delete=" + msgid);
|
|
|
|
|
imessage.setFlag(Flags.Flag.DELETED, true);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Log.i(folder.name + " POP expunge=" + found);
|
|
|
|
|
|
|
|
|
|
if (found)
|
|
|
|
|
try {
|
|
|
|
|
ifolder.close(true);
|
|
|
|
|
ifolder.open(Folder.READ_WRITE);
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
Log.e(ex);
|
|
|
|
|
state.error(new FolderClosedException(ifolder, "POP"));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
db.message().deleteMessage(folder.id, message.id);
|
|
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
db.message().deleteMessage(folder.id, message.id);
|
|
|
|
|
}
|
|
|
|
|