use of com.fsck.k9.controller.MessagingControllerCommands.PendingSetFlag in project k-9 by k9mail.
the class MessagingController method processPendingSetFlag.
/**
* Processes a pending mark read or unread command.
*/
void processPendingSetFlag(PendingSetFlag command, Account account) throws MessagingException {
String folder = command.folder;
if (account.getErrorFolderName().equals(folder) || account.getOutboxFolderName().equals(folder)) {
return;
}
boolean newState = command.newState;
Flag flag = command.flag;
Store remoteStore = account.getRemoteStore();
Folder remoteFolder = remoteStore.getFolder(folder);
if (!remoteFolder.exists() || !remoteFolder.isFlagSupported(flag)) {
return;
}
try {
remoteFolder.open(Folder.OPEN_MODE_RW);
if (remoteFolder.getMode() != Folder.OPEN_MODE_RW) {
return;
}
List<Message> messages = new ArrayList<>();
for (String uid : command.uids) {
if (!uid.startsWith(K9.LOCAL_UID_PREFIX)) {
messages.add(remoteFolder.getMessage(uid));
}
}
if (messages.isEmpty()) {
return;
}
remoteFolder.setFlags(messages, Collections.singleton(flag), newState);
} finally {
closeFolder(remoteFolder);
}
}
use of com.fsck.k9.controller.MessagingControllerCommands.PendingSetFlag in project k-9 by k9mail.
the class MigrationTo60Test method migrateSetFlag_oldFormat.
@Test
public void migrateSetFlag_oldFormat() {
OldPendingCommand command = queueSetFlagOld(SOURCE_FOLDER, FLAG_STATE, FLAG, UID);
PendingSetFlag pendingCommand = (PendingSetFlag) MigrationTo60.migratePendingCommand(command);
assertEquals(SOURCE_FOLDER, pendingCommand.folder);
assertEquals(FLAG_STATE, pendingCommand.newState);
assertEquals(FLAG, pendingCommand.flag);
assertEquals(Collections.singletonList(UID), pendingCommand.uids);
}
use of com.fsck.k9.controller.MessagingControllerCommands.PendingSetFlag in project k-9 by k9mail.
the class MigrationTo60Test method migrateSetFlag.
@Test
public void migrateSetFlag() {
OldPendingCommand command = queueSetFlagBulk(SOURCE_FOLDER, FLAG_STATE, FLAG, UID_ARRAY);
PendingSetFlag pendingCommand = (PendingSetFlag) MigrationTo60.migratePendingCommand(command);
assertEquals(SOURCE_FOLDER, pendingCommand.folder);
assertEquals(FLAG_STATE, pendingCommand.newState);
assertEquals(FLAG, pendingCommand.flag);
assertEquals(asList(UID_ARRAY), pendingCommand.uids);
}
Aggregations