use of com.fsck.k9.controller.MessagingControllerCommands.PendingMarkAllAsRead in project k-9 by k9mail.
the class MigrationTo60Test method migrateMarkAllMessagesRead.
@Test
public void migrateMarkAllMessagesRead() {
OldPendingCommand command = queueMarkAllMessagesRead(SOURCE_FOLDER);
PendingMarkAllAsRead pendingCommand = (PendingMarkAllAsRead) MigrationTo60.migratePendingCommand(command);
assertEquals(SOURCE_FOLDER, pendingCommand.folder);
}
use of com.fsck.k9.controller.MessagingControllerCommands.PendingMarkAllAsRead in project k-9 by k9mail.
the class MessagingController method processPendingMarkAllAsRead.
void processPendingMarkAllAsRead(PendingMarkAllAsRead command, Account account) throws MessagingException {
String folder = command.folder;
Folder remoteFolder = null;
LocalFolder localFolder = null;
try {
Store localStore = account.getLocalStore();
localFolder = (LocalFolder) localStore.getFolder(folder);
localFolder.open(Folder.OPEN_MODE_RW);
List<? extends Message> messages = localFolder.getMessages(null, false);
for (Message message : messages) {
if (!message.isSet(Flag.SEEN)) {
message.setFlag(Flag.SEEN, true);
}
}
for (MessagingListener l : getListeners()) {
l.folderStatusChanged(account, folder, 0);
}
if (account.getErrorFolderName().equals(folder)) {
return;
}
Store remoteStore = account.getRemoteStore();
remoteFolder = remoteStore.getFolder(folder);
if (!remoteFolder.exists() || !remoteFolder.isFlagSupported(Flag.SEEN)) {
return;
}
remoteFolder.open(Folder.OPEN_MODE_RW);
if (remoteFolder.getMode() != Folder.OPEN_MODE_RW) {
return;
}
remoteFolder.setFlags(Collections.singleton(Flag.SEEN), true);
remoteFolder.close();
} catch (UnsupportedOperationException uoe) {
Timber.w(uoe, "Could not mark all server-side as read because store doesn't support operation");
} finally {
closeFolder(localFolder);
closeFolder(remoteFolder);
}
}
Aggregations