Search in sources :

Example 11 with Flag

use of com.fsck.k9.mail.Flag in project k-9 by k9mail.

the class MessagingController method removeFlagFromCache.

private void removeFlagFromCache(final Account account, final List<Long> messageIds, final Flag flag) {
    EmailProviderCache cache = EmailProviderCache.getCache(account.getUuid(), context);
    String columnName = LocalStore.getColumnNameForFlag(flag);
    cache.removeValueForMessages(messageIds, columnName);
}
Also used : EmailProviderCache(com.fsck.k9.cache.EmailProviderCache)

Example 12 with Flag

use of com.fsck.k9.mail.Flag in project k-9 by k9mail.

the class MessagingController method downloadPartial.

private void downloadPartial(Folder remoteFolder, LocalFolder localFolder, Message message) throws MessagingException {
    /*
         * We have a structure to deal with, from which
         * we can pull down the parts we want to actually store.
         * Build a list of parts we are interested in. Text parts will be downloaded
         * right now, attachments will be left for later.
         */
    Set<Part> viewables = MessageExtractor.collectTextParts(message);
    /*
         * Now download the parts we're interested in storing.
         */
    for (Part part : viewables) {
        remoteFolder.fetchPart(message, part, null);
    }
    // Store the updated message locally
    localFolder.appendMessages(Collections.singletonList(message));
    Message localMessage = localFolder.getMessage(message.getUid());
    // Set a flag indicating this message has been fully downloaded and can be
    // viewed.
    localMessage.setFlag(Flag.X_DOWNLOADED_PARTIAL, true);
}
Also used : LocalMessage(com.fsck.k9.mailstore.LocalMessage) MimeMessage(com.fsck.k9.mail.internet.MimeMessage) Message(com.fsck.k9.mail.Message) Part(com.fsck.k9.mail.Part)

Example 13 with Flag

use of com.fsck.k9.mail.Flag in project k-9 by k9mail.

the class MigrationTo60Test method queueSetFlagBulk.

OldPendingCommand queueSetFlagBulk(String folderName, boolean newState, Flag flag, String[] uids) {
    OldPendingCommand command = new OldPendingCommand();
    command.command = PENDING_COMMAND_SET_FLAG_BULK;
    int length = 3 + uids.length;
    command.arguments = new String[length];
    command.arguments[0] = folderName;
    command.arguments[1] = Boolean.toString(newState);
    command.arguments[2] = flag.toString();
    System.arraycopy(uids, 0, command.arguments, 3, uids.length);
    return command;
}
Also used : OldPendingCommand(com.fsck.k9.mailstore.migrations.MigrationTo60.OldPendingCommand)

Example 14 with Flag

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

Example 15 with Flag

use of com.fsck.k9.mail.Flag in project k-9 by k9mail.

the class MessageReference method parse.

@Nullable
public static MessageReference parse(String identity) {
    if (identity == null || identity.length() < 1 || identity.charAt(0) != IDENTITY_VERSION_1) {
        return null;
    }
    StringTokenizer tokens = new StringTokenizer(identity.substring(2), IDENTITY_SEPARATOR, false);
    if (tokens.countTokens() < 3) {
        return null;
    }
    String accountUuid = Base64.decode(tokens.nextToken());
    String folderName = Base64.decode(tokens.nextToken());
    String uid = Base64.decode(tokens.nextToken());
    if (!tokens.hasMoreTokens()) {
        return new MessageReference(accountUuid, folderName, uid, null);
    }
    Flag flag;
    try {
        flag = Flag.valueOf(tokens.nextToken());
    } catch (IllegalArgumentException e) {
        return null;
    }
    return new MessageReference(accountUuid, folderName, uid, flag);
}
Also used : StringTokenizer(java.util.StringTokenizer) Flag(com.fsck.k9.mail.Flag) Nullable(android.support.annotation.Nullable)

Aggregations

MessagingException (com.fsck.k9.mail.MessagingException)10 Message (com.fsck.k9.mail.Message)9 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)9 LocalMessage (com.fsck.k9.mailstore.LocalMessage)9 Flag (com.fsck.k9.mail.Flag)8 LocalFolder (com.fsck.k9.mailstore.LocalFolder)8 LocalStore (com.fsck.k9.mailstore.LocalStore)8 ArrayList (java.util.ArrayList)8 Folder (com.fsck.k9.mail.Folder)7 PendingSetFlag (com.fsck.k9.controller.MessagingControllerCommands.PendingSetFlag)6 Store (com.fsck.k9.mail.Store)6 Pop3Store (com.fsck.k9.mail.store.pop3.Pop3Store)6 Account (com.fsck.k9.Account)5 IOException (java.io.IOException)5 SuppressLint (android.annotation.SuppressLint)4 Cursor (android.database.Cursor)4 EmailProviderCache (com.fsck.k9.cache.EmailProviderCache)4 FetchProfile (com.fsck.k9.mail.FetchProfile)4 OldPendingCommand (com.fsck.k9.mailstore.migrations.MigrationTo60.OldPendingCommand)4 Date (java.util.Date)4