Allow moving POP3 message from trash

pull/178/head
M66B 5 years ago
parent a5c6634d95
commit 7b8e082d81

@ -1546,7 +1546,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean inJunk = EntityFolder.JUNK.equals(message.folderType);
boolean outbox = EntityFolder.OUTBOX.equals(message.folderType);
boolean move = !(message.folderReadOnly || message.uid == null);
boolean move = !(message.folderReadOnly || message.uid == null) ||
(message.accountProtocol == EntityAccount.TYPE_POP &&
EntityFolder.TRASH.equals(message.folderType));
boolean archive = (move && (hasArchive && !inArchive));
boolean trash = (move || outbox || debug ||
message.accountProtocol == EntityAccount.TYPE_POP);

@ -212,7 +212,8 @@ class Core {
case EntityOperation.MOVE:
if (group &&
message.uid != null &&
EntityOperation.MOVE.equals(next.name)) {
EntityOperation.MOVE.equals(next.name) &&
account.protocol == EntityAccount.TYPE_IMAP) {
JSONArray jnext = new JSONArray(next.args);
// Same target
if (jargs.getLong(0) == jnext.getLong(0)) {
@ -287,6 +288,10 @@ class Core {
// Do nothing
break;
case EntityOperation.MOVE:
onMove(context, jargs, folder, message);
break;
case EntityOperation.DELETE:
onDelete(context, jargs, account, folder, message, (POP3Folder) ifolder, (POP3Store) istore, state);
break;
@ -871,7 +876,6 @@ class Core {
ifolder.expunge();
}
// Fetch appended/copied when needed
boolean fetch = !"connected".equals(target.state);
if (draft || fetch)
@ -929,6 +933,34 @@ class Core {
}
}
private static void onMove(Context context, JSONArray jargs, EntityFolder folder, EntityMessage message) throws JSONException, FolderNotFoundException {
// Move message
DB db = DB.getInstance(context);
// Get arguments
long id = jargs.getLong(0);
boolean seen = jargs.optBoolean(1);
boolean unflag = jargs.optBoolean(3);
// Move from trash only
if (!EntityFolder.TRASH.equals(folder.type))
throw new IllegalArgumentException("Invalid POP3 folder type=" + folder.type);
// Get target folder
EntityFolder target = db.folder().getFolder(id);
if (target == null)
throw new FolderNotFoundException();
message.folder = target.id;
if (seen)
message.ui_seen = seen;
if (unflag)
message.ui_flagged = false;
message.ui_hide = false;
db.message().updateMessage(message);
}
private static void onFetch(Context context, JSONArray jargs, EntityFolder folder, IMAPStore istore, IMAPFolder ifolder, State state) throws JSONException, MessagingException, IOException {
long uid = jargs.getLong(0);
@ -1082,7 +1114,7 @@ class Core {
message.id = null;
message.folder = trash.id;
message.msgid = null;
message.msgid = null; // virtual message
message.ui_hide = false;
message.ui_seen = true;
message.id = db.message().insertMessage(message);

Loading…
Cancel
Save