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

Disable "download by date range" for webdav and pop3.

The previous behavior caused catastrophic network abuse, downloading
messages outside the date range over and over.
This commit is contained in:
Jesse Vincent 2011-07-12 21:47:37 -04:00
parent b85c9b7b0e
commit 87640719dd
3 changed files with 35 additions and 13 deletions

View File

@ -977,6 +977,18 @@ public class Account implements BaseAccount {
return Store.getRemoteInstance(this); return Store.getRemoteInstance(this);
} }
// It'd be great if this actually went into the store implementation
// to get this, but that's expensive and not easilly accessible
// during initialization
public boolean isSearchByDateCapable() {
if (getStoreUri().startsWith("imap")) {
return true;
} else {
return false;
}
}
@Override @Override
public synchronized String toString() { public synchronized String toString() {
return mDescription; return mDescription;

View File

@ -385,18 +385,26 @@ public class AccountSettings extends K9PreferenceActivity {
} }
}); });
mMessageAge = (ListPreference) findPreference(PREFERENCE_MESSAGE_AGE); mMessageAge = (ListPreference) findPreference(PREFERENCE_MESSAGE_AGE);
mMessageAge.setValue(String.valueOf(mAccount.getMaximumPolledMessageAge()));
mMessageAge.setSummary(mMessageAge.getEntry()); if (!mAccount.isSearchByDateCapable()) {
mMessageAge.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { mMessageAge.setEnabled(false);
public boolean onPreferenceChange(Preference preference, Object newValue) { } else {
final String summary = newValue.toString(); mMessageAge.setValue(String.valueOf(mAccount.getMaximumPolledMessageAge()));
int index = mMessageAge.findIndexOfValue(summary); mMessageAge.setSummary(mMessageAge.getEntry());
mMessageAge.setSummary(mMessageAge.getEntries()[index]); mMessageAge.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
mMessageAge.setValue(summary); public boolean onPreferenceChange(Preference preference, Object newValue) {
return false; final String summary = newValue.toString();
} int index = mMessageAge.findIndexOfValue(summary);
}); mMessageAge.setSummary(mMessageAge.getEntries()[index]);
mMessageAge.setValue(summary);
return false;
}
});
}
mMessageSize = (ListPreference) findPreference(PREFERENCE_MESSAGE_SIZE); mMessageSize = (ListPreference) findPreference(PREFERENCE_MESSAGE_SIZE);
mMessageSize.setValue(String.valueOf(mAccount.getMaximumAutoDownloadMessageSize())); mMessageSize.setValue(String.valueOf(mAccount.getMaximumAutoDownloadMessageSize()));
@ -683,8 +691,10 @@ public class AccountSettings extends K9PreferenceActivity {
mAccount.setNotifySelfNewMail(mAccountNotifySelf.isChecked()); mAccount.setNotifySelfNewMail(mAccountNotifySelf.isChecked());
mAccount.setShowOngoing(mAccountNotifySync.isChecked()); mAccount.setShowOngoing(mAccountNotifySync.isChecked());
mAccount.setDisplayCount(Integer.parseInt(mDisplayCount.getValue())); mAccount.setDisplayCount(Integer.parseInt(mDisplayCount.getValue()));
mAccount.setMaximumPolledMessageAge(Integer.parseInt(mMessageAge.getValue()));
mAccount.setMaximumAutoDownloadMessageSize(Integer.parseInt(mMessageSize.getValue())); mAccount.setMaximumAutoDownloadMessageSize(Integer.parseInt(mMessageSize.getValue()));
if (mAccount.isSearchByDateCapable()) {
mAccount.setMaximumPolledMessageAge(Integer.parseInt(mMessageAge.getValue()));
}
mAccount.getNotificationSetting().setVibrate(mAccountVibrate.isChecked()); mAccount.getNotificationSetting().setVibrate(mAccountVibrate.isChecked());
mAccount.getNotificationSetting().setVibratePattern(Integer.parseInt(mAccountVibratePattern.getValue())); mAccount.getNotificationSetting().setVibratePattern(Integer.parseInt(mAccountVibratePattern.getValue()));
mAccount.getNotificationSetting().setVibrateTimes(Integer.parseInt(mAccountVibrateTimes.getValue())); mAccount.getNotificationSetting().setVibrateTimes(Integer.parseInt(mAccountVibrateTimes.getValue()));

View File

@ -1534,7 +1534,7 @@ public class MessagingController implements Runnable {
return false; return false;
} }
if (message.olderThan(earliestDate)) { if (account.isSearchByDateCapable() && message.olderThan(earliestDate)) {
if (K9.DEBUG) { if (K9.DEBUG) {
Log.d(K9.LOG_TAG, "Message " + message.getUid() + " is older than " Log.d(K9.LOG_TAG, "Message " + message.getUid() + " is older than "
+ earliestDate + ", hence not saving"); + earliestDate + ", hence not saving");