1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-30 13:12:25 -05:00

. Large messages are now only retrieved once for POP3 servers that don't support the TOP command

This commit is contained in:
Bao-Long Nguyen-Trong 2009-05-10 05:47:26 +00:00
parent e844f4ab0c
commit 5b0dee8cc0
2 changed files with 237 additions and 203 deletions

View File

@ -933,13 +933,41 @@ s * critical data as fast as possible, and then we'll fill in the de
ArrayList<Message> largeMessages = new ArrayList<Message>(); ArrayList<Message> largeMessages = new ArrayList<Message>();
ArrayList<Message> smallMessages = new ArrayList<Message>(); ArrayList<Message> smallMessages = new ArrayList<Message>();
for (Message message : unsyncedMessages) { for (Message message : unsyncedMessages) {
/*
* Some (POP3) servers only support full message download
* and not header/partial so messages may already be downloaded
*/
if (message.isSet(Flag.X_DOWNLOADED_FULL)) {
try {
// Store the updated message locally
localFolder.appendMessages(new Message[]{
message
});
Message localMessage = localFolder.getMessage(message.getUid());
// Set a flag indicating this message has now be fully downloaded
localMessage.setFlag(Flag.X_DOWNLOADED_FULL, true);
if (isMessageSuppressed(account, folder, localMessage) == false) {
// Update the listener with what we've found
for (MessagingListener l : getListeners()) {
l.synchronizeMailboxNewMessage(
account,
folder,
localMessage);
}
}
} catch (MessagingException me) {
addErrorMessage(account, me);
}
}
/* /*
* Sort the messages into two buckets, small and large. Small messages will be * Sort the messages into two buckets, small and large. Small messages will be
* downloaded fully and large messages will be downloaded in parts. By sorting * downloaded fully and large messages will be downloaded in parts. By sorting
* into two buckets we can pipeline the commands for each set of messages * into two buckets we can pipeline the commands for each set of messages
* into a single command to the server saving lots of round trips. * into a single command to the server saving lots of round trips.
*/ */
if (message.getSize() > (MAX_SMALL_MESSAGE_SIZE)) { else if (message.getSize() > (MAX_SMALL_MESSAGE_SIZE)) {
largeMessages.add(message); largeMessages.add(message);
} else { } else {
smallMessages.add(message); smallMessages.add(message);
@ -947,8 +975,11 @@ s * critical data as fast as possible, and then we'll fill in the de
} }
if (Config.LOGV) { if (Config.LOGV) {
Log.v(Email.LOG_TAG, "SYNC: Have " + largeMessages.size() + " large messages and " Log.v(Email.LOG_TAG, "SYNC: Have "
+ smallMessages.size() + " small messages to fetch for folder " + folder); + largeMessages.size() + " large messages and "
+ smallMessages.size() + " small messages out of "
+ unsyncedMessages.size() + " un synced messages "
+ " to fetch for folder " + folder);
} }

View File

@ -666,6 +666,9 @@ public class Pop3Store extends Store {
if (response != null) { if (response != null) {
try { try {
message.parse(new Pop3ResponseInputStream(mIn)); message.parse(new Pop3ResponseInputStream(mIn));
if (lines == -1 || !mCapabilities.top) {
message.setFlag(Flag.X_DOWNLOADED_FULL, true);
}
} }
catch (MessagingException me) { catch (MessagingException me) {
/* /*