Make MessagingController use Backend.deleteMessage()
This commit is contained in:
parent
91e5f629fd
commit
189f50a15e
3 changed files with 46 additions and 1 deletions
|
@ -50,6 +50,7 @@ import com.fsck.k9.cache.EmailProviderCache;
|
|||
import com.fsck.k9.controller.ControllerExtension.ControllerInternals;
|
||||
import com.fsck.k9.controller.MessagingControllerCommands.PendingAppend;
|
||||
import com.fsck.k9.controller.MessagingControllerCommands.PendingCommand;
|
||||
import com.fsck.k9.controller.MessagingControllerCommands.PendingDelete;
|
||||
import com.fsck.k9.controller.MessagingControllerCommands.PendingEmptyTrash;
|
||||
import com.fsck.k9.controller.MessagingControllerCommands.PendingExpunge;
|
||||
import com.fsck.k9.controller.MessagingControllerCommands.PendingMarkAllAsRead;
|
||||
|
@ -1033,6 +1034,22 @@ public class MessagingController {
|
|||
backend.setFlag(command.folder, command.uids, command.flag, command.newState);
|
||||
}
|
||||
|
||||
private void queueDelete(final Account account, final String folderServerId, final List<String> uids) {
|
||||
putBackground("queueDelete " + account.getDescription() + ":" + folderServerId, null, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PendingCommand command = PendingDelete.create(folderServerId, uids);
|
||||
queuePendingCommand(account, command);
|
||||
processPendingCommands(account);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void processPendingDelete(PendingDelete command, Account account) throws MessagingException {
|
||||
Backend backend = getBackend(account);
|
||||
backend.deleteMessages(command.folder, command.uids);
|
||||
}
|
||||
|
||||
private void queueExpunge(final Account account, final String folderServerId) {
|
||||
putBackground("queueExpunge " + account.getDescription() + ":" + folderServerId, null, new Runnable() {
|
||||
@Override
|
||||
|
@ -2221,7 +2238,7 @@ public class MessagingController {
|
|||
} else if (!syncedMessageUids.isEmpty()) {
|
||||
if (account.getDeletePolicy() == DeletePolicy.ON_DELETE) {
|
||||
if (folder.equals(account.getTrashFolder()) || !backend.isDeleteMoveToTrash()) {
|
||||
queueSetFlag(account, folder, true, Flag.DELETED, syncedMessageUids);
|
||||
queueDelete(account, folder, syncedMessageUids);
|
||||
} else {
|
||||
queueMoveOrCopy(account, folder, account.getTrashFolder(), false,
|
||||
syncedMessageUids, uidMap);
|
||||
|
|
|
@ -13,6 +13,7 @@ public class MessagingControllerCommands {
|
|||
static final String COMMAND_APPEND = "append";
|
||||
static final String COMMAND_MARK_ALL_AS_READ = "mark_all_as_read";
|
||||
static final String COMMAND_SET_FLAG = "set_flag";
|
||||
static final String COMMAND_DELETE = "delete";
|
||||
static final String COMMAND_EXPUNGE = "expunge";
|
||||
static final String COMMAND_MOVE_OR_COPY = "move_or_copy";
|
||||
static final String COMMAND_EMPTY_TRASH = "empty_trash";
|
||||
|
@ -158,6 +159,31 @@ public class MessagingControllerCommands {
|
|||
}
|
||||
}
|
||||
|
||||
public static class PendingDelete extends PendingCommand {
|
||||
public final String folder;
|
||||
public final List<String> uids;
|
||||
|
||||
|
||||
public static PendingDelete create(String folder, List<String> uids) {
|
||||
return new PendingDelete(folder, uids);
|
||||
}
|
||||
|
||||
private PendingDelete(String folder, List<String> uids) {
|
||||
this.folder = folder;
|
||||
this.uids = uids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return COMMAND_DELETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(MessagingController controller, Account account) throws MessagingException {
|
||||
controller.processPendingDelete(this, account);
|
||||
}
|
||||
}
|
||||
|
||||
public static class PendingExpunge extends PendingCommand {
|
||||
public final String folder;
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.Map;
|
|||
|
||||
import com.fsck.k9.controller.MessagingControllerCommands.PendingAppend;
|
||||
import com.fsck.k9.controller.MessagingControllerCommands.PendingCommand;
|
||||
import com.fsck.k9.controller.MessagingControllerCommands.PendingDelete;
|
||||
import com.fsck.k9.controller.MessagingControllerCommands.PendingEmptyTrash;
|
||||
import com.fsck.k9.controller.MessagingControllerCommands.PendingExpunge;
|
||||
import com.fsck.k9.controller.MessagingControllerCommands.PendingMarkAllAsRead;
|
||||
|
@ -35,6 +36,7 @@ public class PendingCommandSerializer {
|
|||
adapters.put(MessagingControllerCommands.COMMAND_EXPUNGE, moshi.adapter(PendingExpunge.class));
|
||||
adapters.put(MessagingControllerCommands.COMMAND_MARK_ALL_AS_READ, moshi.adapter(PendingMarkAllAsRead.class));
|
||||
adapters.put(MessagingControllerCommands.COMMAND_SET_FLAG, moshi.adapter(PendingSetFlag.class));
|
||||
adapters.put(MessagingControllerCommands.COMMAND_DELETE, moshi.adapter(PendingDelete.class));
|
||||
|
||||
this.adapters = Collections.unmodifiableMap(adapters);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue