Loading k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/Commands.java +1 −0 Original line number Diff line number Diff line Loading @@ -15,4 +15,5 @@ public class Commands { public static final String LIST = "LIST"; public static final String NOOP = "NOOP"; public static final String UID_SEARCH = "UID SEARCH"; public static final String UID_STORE = "UID STORE"; } k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapFolder.java +18 −16 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import com.fsck.k9.mail.internet.MimeMultipart; import com.fsck.k9.mail.internet.MimeUtility; import com.fsck.k9.mail.store.imap.command.ImapCommandFactory; import com.fsck.k9.mail.store.imap.command.UidSearchCommand; import com.fsck.k9.mail.store.imap.command.UidStoreCommand; import com.fsck.k9.mail.store.imap.response.BaseResponse; import com.fsck.k9.mail.store.imap.response.SearchResponse; import timber.log.Timber; Loading Loading @@ -1295,12 +1296,13 @@ public class ImapFolder extends Folder<ImapMessage> { open(OPEN_MODE_RW); checkOpen(); try { String command = String.format("UID STORE 1:* %sFLAGS.SILENT (%s)", value ? "+" : "-", combineFlags(flags)); executeSimpleCommand(command); } catch (IOException ioe) { throw ioExceptionHandler(connection, ioe); } UidStoreCommand command = commandFactory.createUidStoreCommandBuilder(this) .allIds(true) .value(value) .flagSet(flags) .canCreateKeywords(canCreateKeywords || store.getPermanentFlagsIndex().contains(Flag.FORWARDED)) .build(); command.execute(); } @Override Loading Loading @@ -1331,18 +1333,18 @@ public class ImapFolder extends Folder<ImapMessage> { open(OPEN_MODE_RW); checkOpen(); String[] uids = new String[messages.size()]; for (int i = 0, count = messages.size(); i < count; i++) { uids[i] = messages.get(i).getUid(); Set<Long> uids = new HashSet<>(messages.size()); for (Message message : messages) { uids.add(Long.parseLong(message.getUid())); } try { String command = String.format("UID STORE %s %sFLAGS.SILENT (%s)", combine(uids, ','), value ? "+" : "-", combineFlags(flags)); executeSimpleCommand(command); } catch (IOException ioe) { throw ioExceptionHandler(connection, ioe); } UidStoreCommand command = commandFactory.createUidStoreCommandBuilder(this) .idSet(uids) .value(value) .flagSet(flags) .canCreateKeywords(canCreateKeywords || store.getPermanentFlagsIndex().contains(Flag.FORWARDED)) .build(); command.execute(); } private void checkOpen() throws MessagingException { Loading k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapUtility.java +15 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.fsck.k9.mail.store.imap; import java.util.ArrayList; import java.util.Collection; import java.util.List; import timber.log.Timber; Loading Loading @@ -154,4 +155,18 @@ public class ImapUtility { return responses.get(lastIndex); } public static String join(String delimiter, Collection<? extends Object> tokens) { StringBuilder sb = new StringBuilder(); boolean firstTime = true; for (Object token: tokens) { if (firstTime) { firstTime = false; } else { sb.append(delimiter); } sb.append(token); } return sb.toString(); } } k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/command/ImapCommandFactory.java +4 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,10 @@ public class ImapCommandFactory { return new UidSearchCommand.Builder(this, folder, listener); } public UidStoreCommand.Builder createUidStoreCommandBuilder(ImapFolder folder) { return new UidStoreCommand.Builder(this, folder); } ImapConnection getConnection() { return connection; } Loading k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/command/SelectByIdCommand.java +3 −4 Original line number Diff line number Diff line Loading @@ -9,9 +9,8 @@ import java.util.List; import java.util.Set; import java.util.TreeSet; import android.text.TextUtils; import com.fsck.k9.mail.store.imap.ImapFolder; import com.fsck.k9.mail.store.imap.ImapUtility; //This is the base class for a command that takes sequence numbers/uids as an argument Loading Loading @@ -95,13 +94,13 @@ abstract class SelectByIdCommand extends BaseCommand { optimizeGroupings(); if (idSet != null) { builder.append(TextUtils.join(",", idSet)); builder.append(ImapUtility.join(",", idSet)); } if (idRanges != null) { if (idSet != null) { builder.append(","); } builder.append(TextUtils.join(",", idRanges)); builder.append(ImapUtility.join(",", idRanges)); } builder.append(" "); } Loading Loading
k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/Commands.java +1 −0 Original line number Diff line number Diff line Loading @@ -15,4 +15,5 @@ public class Commands { public static final String LIST = "LIST"; public static final String NOOP = "NOOP"; public static final String UID_SEARCH = "UID SEARCH"; public static final String UID_STORE = "UID STORE"; }
k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapFolder.java +18 −16 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import com.fsck.k9.mail.internet.MimeMultipart; import com.fsck.k9.mail.internet.MimeUtility; import com.fsck.k9.mail.store.imap.command.ImapCommandFactory; import com.fsck.k9.mail.store.imap.command.UidSearchCommand; import com.fsck.k9.mail.store.imap.command.UidStoreCommand; import com.fsck.k9.mail.store.imap.response.BaseResponse; import com.fsck.k9.mail.store.imap.response.SearchResponse; import timber.log.Timber; Loading Loading @@ -1295,12 +1296,13 @@ public class ImapFolder extends Folder<ImapMessage> { open(OPEN_MODE_RW); checkOpen(); try { String command = String.format("UID STORE 1:* %sFLAGS.SILENT (%s)", value ? "+" : "-", combineFlags(flags)); executeSimpleCommand(command); } catch (IOException ioe) { throw ioExceptionHandler(connection, ioe); } UidStoreCommand command = commandFactory.createUidStoreCommandBuilder(this) .allIds(true) .value(value) .flagSet(flags) .canCreateKeywords(canCreateKeywords || store.getPermanentFlagsIndex().contains(Flag.FORWARDED)) .build(); command.execute(); } @Override Loading Loading @@ -1331,18 +1333,18 @@ public class ImapFolder extends Folder<ImapMessage> { open(OPEN_MODE_RW); checkOpen(); String[] uids = new String[messages.size()]; for (int i = 0, count = messages.size(); i < count; i++) { uids[i] = messages.get(i).getUid(); Set<Long> uids = new HashSet<>(messages.size()); for (Message message : messages) { uids.add(Long.parseLong(message.getUid())); } try { String command = String.format("UID STORE %s %sFLAGS.SILENT (%s)", combine(uids, ','), value ? "+" : "-", combineFlags(flags)); executeSimpleCommand(command); } catch (IOException ioe) { throw ioExceptionHandler(connection, ioe); } UidStoreCommand command = commandFactory.createUidStoreCommandBuilder(this) .idSet(uids) .value(value) .flagSet(flags) .canCreateKeywords(canCreateKeywords || store.getPermanentFlagsIndex().contains(Flag.FORWARDED)) .build(); command.execute(); } private void checkOpen() throws MessagingException { Loading
k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/ImapUtility.java +15 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.fsck.k9.mail.store.imap; import java.util.ArrayList; import java.util.Collection; import java.util.List; import timber.log.Timber; Loading Loading @@ -154,4 +155,18 @@ public class ImapUtility { return responses.get(lastIndex); } public static String join(String delimiter, Collection<? extends Object> tokens) { StringBuilder sb = new StringBuilder(); boolean firstTime = true; for (Object token: tokens) { if (firstTime) { firstTime = false; } else { sb.append(delimiter); } sb.append(token); } return sb.toString(); } }
k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/command/ImapCommandFactory.java +4 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,10 @@ public class ImapCommandFactory { return new UidSearchCommand.Builder(this, folder, listener); } public UidStoreCommand.Builder createUidStoreCommandBuilder(ImapFolder folder) { return new UidStoreCommand.Builder(this, folder); } ImapConnection getConnection() { return connection; } Loading
k9mail-library/src/main/java/com/fsck/k9/mail/store/imap/command/SelectByIdCommand.java +3 −4 Original line number Diff line number Diff line Loading @@ -9,9 +9,8 @@ import java.util.List; import java.util.Set; import java.util.TreeSet; import android.text.TextUtils; import com.fsck.k9.mail.store.imap.ImapFolder; import com.fsck.k9.mail.store.imap.ImapUtility; //This is the base class for a command that takes sequence numbers/uids as an argument Loading Loading @@ -95,13 +94,13 @@ abstract class SelectByIdCommand extends BaseCommand { optimizeGroupings(); if (idSet != null) { builder.append(TextUtils.join(",", idSet)); builder.append(ImapUtility.join(",", idSet)); } if (idRanges != null) { if (idSet != null) { builder.append(","); } builder.append(TextUtils.join(",", idRanges)); builder.append(ImapUtility.join(",", idRanges)); } builder.append(" "); } Loading