Search in sources :

Example 16 with PendingCommand

use of com.fsck.k9.controller.MessagingControllerCommands.PendingCommand in project k-9 by k9mail.

the class MigrationTo60 method migrateCommandSetFlagBulk.

private static PendingCommand migrateCommandSetFlagBulk(OldPendingCommand command) {
    String folder = command.arguments[0];
    boolean newState = Boolean.parseBoolean(command.arguments[1]);
    Flag flag = Flag.valueOf(command.arguments[2]);
    List<String> uids = new ArrayList<>(command.arguments.length - 3);
    uids.addAll(Arrays.asList(command.arguments).subList(3, command.arguments.length));
    return PendingSetFlag.create(folder, newState, flag, uids);
}
Also used : ArrayList(java.util.ArrayList) PendingSetFlag(com.fsck.k9.controller.MessagingControllerCommands.PendingSetFlag) Flag(com.fsck.k9.mail.Flag)

Example 17 with PendingCommand

use of com.fsck.k9.controller.MessagingControllerCommands.PendingCommand in project k-9 by k9mail.

the class MigrationTo60 method migratePendingCommands.

public static void migratePendingCommands(SQLiteDatabase db) {
    List<PendingCommand> pendingCommands = new ArrayList<>();
    if (columnExists(db, "pending_commands", "arguments")) {
        for (OldPendingCommand oldPendingCommand : getPendingCommands(db)) {
            PendingCommand newPendingCommand = migratePendingCommand(oldPendingCommand);
            pendingCommands.add(newPendingCommand);
        }
        db.execSQL("DROP TABLE IF EXISTS pending_commands");
        db.execSQL("CREATE TABLE pending_commands (" + "id INTEGER PRIMARY KEY, " + "command TEXT, " + "data TEXT" + ")");
        PendingCommandSerializer pendingCommandSerializer = PendingCommandSerializer.getInstance();
        for (PendingCommand pendingCommand : pendingCommands) {
            ContentValues cv = new ContentValues();
            cv.put("command", pendingCommand.getCommandName());
            cv.put("data", pendingCommandSerializer.serialize(pendingCommand));
            db.insert("pending_commands", "command", cv);
        }
    }
}
Also used : ContentValues(android.content.ContentValues) ArrayList(java.util.ArrayList) PendingCommandSerializer(com.fsck.k9.controller.PendingCommandSerializer) PendingCommand(com.fsck.k9.controller.MessagingControllerCommands.PendingCommand)

Example 18 with PendingCommand

use of com.fsck.k9.controller.MessagingControllerCommands.PendingCommand in project k-9 by k9mail.

the class MigrationTo60 method migrateCommandSetFlag.

private static PendingCommand migrateCommandSetFlag(OldPendingCommand command) {
    String folder = command.arguments[0];
    String uid = command.arguments[1];
    boolean newState = Boolean.parseBoolean(command.arguments[2]);
    Flag flag = Flag.valueOf(command.arguments[3]);
    return PendingSetFlag.create(folder, newState, flag, singletonList(uid));
}
Also used : PendingSetFlag(com.fsck.k9.controller.MessagingControllerCommands.PendingSetFlag) Flag(com.fsck.k9.mail.Flag)

Example 19 with PendingCommand

use of com.fsck.k9.controller.MessagingControllerCommands.PendingCommand in project k-9 by k9mail.

the class MigrationTo60Test method migrateEmptyTrash.

@Test
public void migrateEmptyTrash() {
    OldPendingCommand command = queueEmptyTrash();
    PendingCommand pendingCommand = MigrationTo60.migratePendingCommand(command);
    assertTrue(pendingCommand instanceof PendingEmptyTrash);
}
Also used : PendingEmptyTrash(com.fsck.k9.controller.MessagingControllerCommands.PendingEmptyTrash) PendingCommand(com.fsck.k9.controller.MessagingControllerCommands.PendingCommand) OldPendingCommand(com.fsck.k9.mailstore.migrations.MigrationTo60.OldPendingCommand) OldPendingCommand(com.fsck.k9.mailstore.migrations.MigrationTo60.OldPendingCommand) Test(org.junit.Test)

Example 20 with PendingCommand

use of com.fsck.k9.controller.MessagingControllerCommands.PendingCommand 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);
}
Also used : PendingMarkAllAsRead(com.fsck.k9.controller.MessagingControllerCommands.PendingMarkAllAsRead) OldPendingCommand(com.fsck.k9.mailstore.migrations.MigrationTo60.OldPendingCommand) Test(org.junit.Test)

Aggregations

PendingCommand (com.fsck.k9.controller.MessagingControllerCommands.PendingCommand)14 Test (org.junit.Test)14 OldPendingCommand (com.fsck.k9.mailstore.migrations.MigrationTo60.OldPendingCommand)10 PendingMoveOrCopy (com.fsck.k9.controller.MessagingControllerCommands.PendingMoveOrCopy)5 PendingSetFlag (com.fsck.k9.controller.MessagingControllerCommands.PendingSetFlag)4 MessagingException (com.fsck.k9.mail.MessagingException)4 LocalStore (com.fsck.k9.mailstore.LocalStore)4 LocalFolder (com.fsck.k9.mailstore.LocalFolder)3 ContentValues (android.content.ContentValues)2 PendingAppend (com.fsck.k9.controller.MessagingControllerCommands.PendingAppend)2 PendingEmptyTrash (com.fsck.k9.controller.MessagingControllerCommands.PendingEmptyTrash)2 Flag (com.fsck.k9.mail.Flag)2 Message (com.fsck.k9.mail.Message)2 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)2 LocalMessage (com.fsck.k9.mailstore.LocalMessage)2 UnavailableStorageException (com.fsck.k9.mailstore.UnavailableStorageException)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 SuppressLint (android.annotation.SuppressLint)1 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1