Change List<? extends Message> to List<ImapMessage> where appropriate
This commit is contained in:
parent
46b2633bea
commit
d3bdebccf3
4 changed files with 20 additions and 24 deletions
|
@ -6,9 +6,9 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fsck.k9.mail.Message;
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
import com.fsck.k9.mail.store.imap.ImapFolder;
|
||||
import com.fsck.k9.mail.store.imap.ImapMessage;
|
||||
import com.fsck.k9.mail.store.imap.ImapStore;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import timber.log.Timber;
|
||||
|
@ -40,7 +40,7 @@ class CommandMoveOrCopyMessages {
|
|||
try {
|
||||
remoteSrcFolder = imapStore.getFolder(srcFolder);
|
||||
|
||||
List<Message> messages = new ArrayList<>();
|
||||
List<ImapMessage> messages = new ArrayList<>();
|
||||
|
||||
for (String uid : uids) {
|
||||
messages.add(remoteSrcFolder.getMessage(uid));
|
||||
|
|
|
@ -6,9 +6,9 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
import com.fsck.k9.mail.Flag;
|
||||
import com.fsck.k9.mail.Message;
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
import com.fsck.k9.mail.store.imap.ImapFolder;
|
||||
import com.fsck.k9.mail.store.imap.ImapMessage;
|
||||
import com.fsck.k9.mail.store.imap.ImapStore;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -34,7 +34,7 @@ class CommandSetFlag {
|
|||
if (remoteFolder.getMode() != ImapFolder.OPEN_MODE_RW) {
|
||||
return;
|
||||
}
|
||||
List<Message> messages = new ArrayList<>();
|
||||
List<ImapMessage> messages = new ArrayList<>();
|
||||
for (String uid : messageServerIds) {
|
||||
messages.add(remoteFolder.getMessage(uid));
|
||||
}
|
||||
|
|
|
@ -4,15 +4,14 @@ package com.fsck.k9.mail.store.imap;
|
|||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fsck.k9.mail.Message;
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
import com.fsck.k9.mail.filter.FixedLengthInputStream;
|
||||
|
||||
|
||||
class FetchBodyCallback implements ImapResponseCallback {
|
||||
private Map<String, Message> mMessageMap;
|
||||
private Map<String, ImapMessage> mMessageMap;
|
||||
|
||||
FetchBodyCallback(Map<String, Message> messageMap) {
|
||||
FetchBodyCallback(Map<String, ImapMessage> messageMap) {
|
||||
mMessageMap = messageMap;
|
||||
}
|
||||
|
||||
|
@ -24,7 +23,7 @@ class FetchBodyCallback implements ImapResponseCallback {
|
|||
ImapList fetchList = (ImapList)response.getKeyedValue("FETCH");
|
||||
String uid = fetchList.getKeyedString("UID");
|
||||
|
||||
ImapMessage message = (ImapMessage) mMessageMap.get(uid);
|
||||
ImapMessage message = mMessageMap.get(uid);
|
||||
message.parse(literal);
|
||||
|
||||
// Return placeholder object
|
||||
|
|
|
@ -345,7 +345,7 @@ public class ImapFolder {
|
|||
*
|
||||
* <p>
|
||||
* <strong>Note:</strong>
|
||||
* Only the UIDs of the given {@link Message} instances are used. It is assumed that all
|
||||
* Only the UIDs of the given {@link ImapMessage} instances are used. It is assumed that all
|
||||
* UIDs represent valid messages in this folder.
|
||||
* </p>
|
||||
*
|
||||
|
@ -356,7 +356,7 @@ public class ImapFolder {
|
|||
*
|
||||
* @return The mapping of original message UIDs to the new server UIDs.
|
||||
*/
|
||||
public Map<String, String> copyMessages(List<? extends Message> messages, ImapFolder folder) throws MessagingException {
|
||||
public Map<String, String> copyMessages(List<ImapMessage> messages, ImapFolder folder) throws MessagingException {
|
||||
if (messages.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
@ -392,7 +392,7 @@ public class ImapFolder {
|
|||
}
|
||||
}
|
||||
|
||||
public Map<String, String> moveMessages(List<? extends Message> messages, ImapFolder folder) throws MessagingException {
|
||||
public Map<String, String> moveMessages(List<ImapMessage> messages, ImapFolder folder) throws MessagingException {
|
||||
if (messages.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
@ -615,8 +615,8 @@ public class ImapFolder {
|
|||
checkOpen();
|
||||
|
||||
List<String> uids = new ArrayList<>(messages.size());
|
||||
HashMap<String, Message> messageMap = new HashMap<>();
|
||||
for (Message message : messages) {
|
||||
HashMap<String, ImapMessage> messageMap = new HashMap<>();
|
||||
for (ImapMessage message : messages) {
|
||||
String uid = message.getUid();
|
||||
uids.add(uid);
|
||||
messageMap.put(uid, message);
|
||||
|
@ -691,7 +691,7 @@ public class ImapFolder {
|
|||
}
|
||||
}
|
||||
|
||||
Message message = messageMap.get(uid);
|
||||
ImapMessage message = messageMap.get(uid);
|
||||
if (message == null) {
|
||||
if (K9MailLib.isDebug()) {
|
||||
Timber.d("Do not have message in messageMap for UID %s for %s", uid, getLogId());
|
||||
|
@ -705,14 +705,13 @@ public class ImapFolder {
|
|||
listener.messageStarted(uid, messageNumber++, messageMap.size());
|
||||
}
|
||||
|
||||
ImapMessage imapMessage = (ImapMessage) message;
|
||||
Object literal = handleFetchResponse(imapMessage, fetchList);
|
||||
Object literal = handleFetchResponse(message, fetchList);
|
||||
|
||||
if (literal != null) {
|
||||
if (literal instanceof String) {
|
||||
String bodyString = (String) literal;
|
||||
InputStream bodyStream = new ByteArrayInputStream(bodyString.getBytes());
|
||||
imapMessage.parse(bodyStream);
|
||||
message.parse(bodyStream);
|
||||
} else if (literal instanceof Integer) {
|
||||
// All the work was done in FetchBodyCallback.foundLiteral()
|
||||
} else {
|
||||
|
@ -722,7 +721,7 @@ public class ImapFolder {
|
|||
}
|
||||
|
||||
if (listener != null) {
|
||||
listener.messageFinished(imapMessage, messageNumber, messageMap.size());
|
||||
listener.messageFinished(message, messageNumber, messageMap.size());
|
||||
}
|
||||
} else {
|
||||
handleUntaggedResponse(response);
|
||||
|
@ -735,7 +734,7 @@ public class ImapFolder {
|
|||
}
|
||||
}
|
||||
|
||||
public void fetchPart(Message message, Part part, MessageRetrievalListener<Message> listener,
|
||||
public void fetchPart(ImapMessage message, Part part, MessageRetrievalListener<ImapMessage> listener,
|
||||
BodyFactory bodyFactory) throws MessagingException {
|
||||
checkOpen();
|
||||
|
||||
|
@ -778,9 +777,7 @@ public class ImapFolder {
|
|||
listener.messageStarted(uid, messageNumber++, 1);
|
||||
}
|
||||
|
||||
ImapMessage imapMessage = (ImapMessage) message;
|
||||
|
||||
Object literal = handleFetchResponse(imapMessage, fetchList);
|
||||
Object literal = handleFetchResponse(message, fetchList);
|
||||
|
||||
if (literal != null) {
|
||||
if (literal instanceof Body) {
|
||||
|
@ -1261,13 +1258,13 @@ public class ImapFolder {
|
|||
}
|
||||
}
|
||||
|
||||
public void setFlags(List<? extends Message> messages, final Set<Flag> flags, boolean value)
|
||||
public void setFlags(List<ImapMessage> messages, final Set<Flag> flags, boolean value)
|
||||
throws MessagingException {
|
||||
open(OPEN_MODE_RW);
|
||||
checkOpen();
|
||||
|
||||
Set<Long> uids = new HashSet<>(messages.size());
|
||||
for (Message message : messages) {
|
||||
for (ImapMessage message : messages) {
|
||||
uids.add(Long.parseLong(message.getUid()));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue