From b02b895aaf5ba1891bfb3924bce15f25e3d356cf Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sat, 2 Jul 2011 15:29:49 -0400 Subject: [PATCH] Add 2MB, 5MB and "All" message download options --- res/values/arrays.xml | 6 ++++++ res/values/strings.xml | 2 ++ src/com/fsck/k9/controller/MessagingController.java | 8 ++++++-- src/com/fsck/k9/mail/store/ImapStore.java | 7 ++++++- src/com/fsck/k9/mail/store/Pop3Store.java | 8 ++++++-- src/com/fsck/k9/mail/store/WebDavStore.java | 6 +++++- 6 files changed, 31 insertions(+), 6 deletions(-) diff --git a/res/values/arrays.xml b/res/values/arrays.xml index 68b88c018..e6cde687e 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -112,6 +112,9 @@ @string/account_settings_autodownload_message_size_512 @string/account_settings_autodownload_message_size_1024 @string/account_settings_autodownload_message_size_2048 + @string/account_settings_autodownload_message_size_5120 + @string/account_settings_autodownload_message_size_10240 + @string/account_settings_autodownload_message_size_any @@ -127,6 +130,9 @@ 524288 1048576 2097152 + 5242880 + 10485760 + 0 diff --git a/res/values/strings.xml b/res/values/strings.xml index 710bf894a..243e6d3d8 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -617,6 +617,8 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin 512Kb 1Mb 2Mb + 5Mb + 10Mb any size (no limit) Sync messages from diff --git a/src/com/fsck/k9/controller/MessagingController.java b/src/com/fsck/k9/controller/MessagingController.java index 079b72812..028ebfcd3 100644 --- a/src/com/fsck/k9/controller/MessagingController.java +++ b/src/com/fsck/k9/controller/MessagingController.java @@ -1441,7 +1441,8 @@ public class MessagingController implements Runnable { return; } - if (message.getSize() > account.getMaximumAutoDownloadMessageSize()) { + if (account.getMaximumAutoDownloadMessageSize() > 0 && + message.getSize() > account.getMaximumAutoDownloadMessageSize()) { largeMessages.add(message); } else { smallMessages.add(message); @@ -1674,8 +1675,11 @@ public class MessagingController implements Runnable { * the account's autodownload size limit, otherwise mark as only a partial * download. This will prevent the system from downloading the same message * twice. + * + * If there is no limit on autodownload size, that's the same as the message + * being smaller than the max size */ - if (message.getSize() < account.getMaximumAutoDownloadMessageSize()) { + if (account.getMaximumAutoDownloadMessageSize() == 0 || message.getSize() < account.getMaximumAutoDownloadMessageSize()) { localMessage.setFlag(Flag.X_DOWNLOADED_FULL, true); } else { // Set a flag indicating that the message has been partially downloaded and diff --git a/src/com/fsck/k9/mail/store/ImapStore.java b/src/com/fsck/k9/mail/store/ImapStore.java index b639a11f2..1ee09fc75 100644 --- a/src/com/fsck/k9/mail/store/ImapStore.java +++ b/src/com/fsck/k9/mail/store/ImapStore.java @@ -1110,7 +1110,12 @@ public class ImapStore extends Store { fetchFields.add("BODYSTRUCTURE"); } if (fp.contains(FetchProfile.Item.BODY_SANE)) { - fetchFields.add(String.format("BODY.PEEK[]<0.%d>", mAccount.getMaximumAutoDownloadMessageSize())); + // If the user wants to download unlimited-size messages, don't go only for the truncated body + if (mAccount.getMaximumAutoDownloadMessageSize() > 0) { + fetchFields.add(String.format("BODY.PEEK[]<0.%d>", mAccount.getMaximumAutoDownloadMessageSize())); + } else { + fetchFields.add("BODY.PEEK[]"); + } } if (fp.contains(FetchProfile.Item.BODY)) { fetchFields.add("BODY.PEEK[]"); diff --git a/src/com/fsck/k9/mail/store/Pop3Store.java b/src/com/fsck/k9/mail/store/Pop3Store.java index a307c8484..f6b8f1063 100644 --- a/src/com/fsck/k9/mail/store/Pop3Store.java +++ b/src/com/fsck/k9/mail/store/Pop3Store.java @@ -582,8 +582,12 @@ public class Pop3Store extends Store { * To convert the suggested download size we take the size * divided by the maximum line size (76). */ - fetchBody(pop3Message, - (mAccount.getMaximumAutoDownloadMessageSize() / 76)); + if (mAccount.getMaximumAutoDownloadMessageSize() > 0) { + fetchBody(pop3Message, + (mAccount.getMaximumAutoDownloadMessageSize() / 76)); + } else { + fetchBody(pop3Message, -1); + } } else if (fp.contains(FetchProfile.Item.STRUCTURE)) { /* * If the user is requesting STRUCTURE we are required to set the body diff --git a/src/com/fsck/k9/mail/store/WebDavStore.java b/src/com/fsck/k9/mail/store/WebDavStore.java index 81a498f25..dfd3d9155 100644 --- a/src/com/fsck/k9/mail/store/WebDavStore.java +++ b/src/com/fsck/k9/mail/store/WebDavStore.java @@ -1411,7 +1411,11 @@ public class WebDavStore extends Store { } if (fp.contains(FetchProfile.Item.BODY_SANE)) { - fetchMessages(messages, listener, (mAccount.getMaximumAutoDownloadMessageSize() / 76)); + if (mAccount.getMaximumAutoDownloadMessageSize() > 0) { + fetchMessages(messages, listener, (mAccount.getMaximumAutoDownloadMessageSize() / 76)); + } else { + fetchMessages(messages, listener, -1); + } } if (fp.contains(FetchProfile.Item.BODY)) { fetchMessages(messages, listener, -1);