IMAP: implement a new imapAutoExpunge setting to delete messages immediately over IMAP

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1038 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-05-10 09:19:25 +00:00
parent 0910d22a93
commit 4763d94aca
7 changed files with 38 additions and 8 deletions

View File

@ -151,6 +151,7 @@ public final class Settings {
SETTINGS.put("davmail.caldavAlarmSound", "");
SETTINGS.put("davmail.forceActiveSyncUpdate", Boolean.FALSE.toString());
SETTINGS.put("davmail.showStartupBanner", Boolean.TRUE.toString());
SETTINGS.put("davmail.imapAutoExpunge", Boolean.TRUE.toString());
SETTINGS.put("davmail.ssl.keystoreType", "");
SETTINGS.put("davmail.ssl.keystoreFile", "");
SETTINGS.put("davmail.ssl.keystorePass", "");

View File

@ -220,9 +220,10 @@ public class ImapConnection extends AbstractConnection {
sendClient(commandId + " BAD command unrecognized");
}
} else if ("expunge".equalsIgnoreCase(command)) {
expunge(false);
// need to refresh folder to avoid 404 errors
session.refreshFolder(currentFolder);
if (expunge(false)) {
// need to refresh folder to avoid 404 errors
session.refreshFolder(currentFolder);
}
sendClient(commandId + " OK " + command + " completed");
} else if ("close".equalsIgnoreCase(command)) {
expunge(true);
@ -712,6 +713,12 @@ public class ImapConnection extends AbstractConnection {
updateFlags(message, action, flags);
sendClient("* " + (rangeIterator.getCurrentIndex()) + " FETCH (UID " + message.getImapUid() + " FLAGS (" + (message.getImapFlags()) + "))");
}
// auto expunge
if (Settings.getBooleanProperty("davmail.imapAutoExpunge")) {
if (expunge(false)) {
session.refreshFolder(currentFolder);
}
}
sendClient(commandId + " OK STORE completed");
}
@ -1114,12 +1121,14 @@ public class ImapConnection extends AbstractConnection {
}
protected void expunge(boolean silent) throws IOException {
protected boolean expunge(boolean silent) throws IOException {
boolean hasDeleted = false;
if (currentFolder.messages != null) {
int index = 1;
for (ExchangeSession.Message message : currentFolder.messages) {
if (message.deleted) {
message.delete();
hasDeleted = true;
if (!silent) {
sendClient("* " + index + " EXPUNGE");
}
@ -1128,6 +1137,7 @@ public class ImapConnection extends AbstractConnection {
}
}
}
return hasDeleted;
}
protected void updateFlags(ExchangeSession.Message message, String action, String flags) throws IOException {

View File

@ -87,6 +87,7 @@ public class SettingsFrame extends JFrame {
JCheckBox forceActiveSyncUpdateCheckBox;
JTextField defaultDomainField;
JCheckBox showStartupBannerCheckBox;
JCheckBox imapAutoExpungeCheckBox;
protected void addSettingComponent(JPanel panel, String label, JComponent component) {
addSettingComponent(panel, label, component, null);
@ -369,7 +370,7 @@ public class SettingsFrame extends JFrame {
}
protected JPanel getOtherSettingsPanel() {
JPanel otherSettingsPanel = new JPanel(new GridLayout(4, 2));
JPanel otherSettingsPanel = new JPanel(new GridLayout(5, 2));
otherSettingsPanel.setBorder(BorderFactory.createTitledBorder(BundleMessage.format("UI_OTHER")));
caldavAlarmSoundField = new JTextField(Settings.getProperty("davmail.caldavAlarmSound"), 15);
@ -378,6 +379,8 @@ public class SettingsFrame extends JFrame {
defaultDomainField = new JTextField(Settings.getProperty("davmail.defaultDomain"), 15);
showStartupBannerCheckBox = new JCheckBox();
showStartupBannerCheckBox.setSelected(Settings.getBooleanProperty("davmail.showStartupBanner", true));
imapAutoExpungeCheckBox = new JCheckBox();
imapAutoExpungeCheckBox.setSelected(Settings.getBooleanProperty("davmail.imapAutoExpunge", true));
addSettingComponent(otherSettingsPanel, BundleMessage.format("UI_CALDAV_ALARM_SOUND"), caldavAlarmSoundField,
BundleMessage.format("UI_CALDAV_ALARM_SOUND_HELP"));
@ -387,6 +390,8 @@ public class SettingsFrame extends JFrame {
BundleMessage.format("UI_DEFAULT_DOMAIN_HELP"));
addSettingComponent(otherSettingsPanel, BundleMessage.format("UI_SHOW_STARTUP_BANNER"), showStartupBannerCheckBox,
BundleMessage.format("UI_SHOW_STARTUP_BANNER_HELP"));
addSettingComponent(otherSettingsPanel, BundleMessage.format("UI_IMAP_AUTO_EXPUNGE"), imapAutoExpungeCheckBox,
BundleMessage.format("UI_IMAP_AUTO_EXPUNGE_HELP"));
Dimension preferredSize = otherSettingsPanel.getPreferredSize();
preferredSize.width = Integer.MAX_VALUE;
@ -479,6 +484,7 @@ public class SettingsFrame extends JFrame {
forceActiveSyncUpdateCheckBox.setSelected(Settings.getBooleanProperty("davmail.forceActiveSyncUpdate"));
defaultDomainField.setText(Settings.getProperty("davmail.defaultDomain"));
showStartupBannerCheckBox.setSelected(Settings.getBooleanProperty("davmail.showStartupBanner", true));
imapAutoExpungeCheckBox.setSelected(Settings.getBooleanProperty("davmail.imapAutoExpunge", true));
keystoreTypeCombo.setSelectedItem(Settings.getProperty("davmail.ssl.keystoreType"));
keystoreFileField.setText(Settings.getProperty("davmail.ssl.keystoreFile"));
@ -590,6 +596,7 @@ public class SettingsFrame extends JFrame {
Settings.setProperty("davmail.forceActiveSyncUpdate", String.valueOf(forceActiveSyncUpdateCheckBox.isSelected()));
Settings.setProperty("davmail.defaultDomain", String.valueOf(defaultDomainField.getText()));
Settings.setProperty("davmail.showStartupBanner", String.valueOf(showStartupBannerCheckBox.isSelected()));
Settings.setProperty("davmail.imapAutoExpunge", String.valueOf(imapAutoExpungeCheckBox.isSelected()));
Settings.setProperty("davmail.ssl.keystoreType", (String) keystoreTypeCombo.getSelectedItem());
Settings.setProperty("davmail.ssl.keystoreFile", keystoreFileField.getText());

View File

@ -250,8 +250,10 @@ UI_FORCE_ACTIVESYNC_UPDATE=Force ActiveSync update:
UI_FORCE_ACTIVESYNC_UPDATE_HELP=Force update of Caldav events for ActiveSync connected devices
UI_DEFAULT_DOMAIN=Default domain:
UI_DEFAULT_DOMAIN_HELP=Default windows domain name
UI_USE_SYSTEM_PROXIES=Use system proxy settings :
UI_USE_SYSTEM_PROXIES=Use system proxy settings:
UI_SHOW_STARTUP_BANNER=Display startup banner
UI_SHOW_STARTUP_BANNER_HELP=Whether to show the initial startup notification window or not
UI_IMAP_AUTO_EXPUNGE=IMAP auto expunge:
UI_IMAP_AUTO_EXPUNGE_HELP=Delete messages immediately on the server over IMAP
UI_IMAP_IDLE_DELAY=IDLE folder monitor delay (IMAP):
UI_IMAP_IDLE_DELAY_HELP=IMAP folder idle monitor delay in minutes, leave empty to disable IDLE support

View File

@ -249,8 +249,10 @@ UI_DEFAULT_DOMAIN_HELP=Nom du domaine windows par d
EXCEPTION_UNSUPPORTED_PARAMETER=Paramètre non supporté : {0}
EXCEPTION_INVALID_PARAMETER=Paramètre invalide : {0}
UI_USE_SYSTEM_PROXIES=Utiliser la configuration système :
UI_SHOW_STARTUP_BANNER=Notification au lancement
UI_SHOW_STARTUP_BANNER=Notification au lancement :
UI_SHOW_STARTUP_BANNER_HELP=Afficher ou non la fenêtre de notification au démarrage
LOG_READ_CLIENT_AUTH_LOGIN=< AUTH LOGIN ********
UI_IMAP_IDLE_DELAY=Délai de surveillance dossier (IMAP) :
UI_IMAP_IDLE_DELAY_HELP=Délai de surveillance du dossier IMAP en minutes, laisser vide pour désactiver le support IDLE
UI_IMAP_IDLE_DELAY_HELP=Délai de surveillance du dossier IMAP en minutes, laisser vide pour désactiver le support IDLE
UI_IMAP_AUTO_EXPUNGE=IMAP suppression immédiate :
UI_IMAP_AUTO_EXPUNGE_HELP=Supprimer immédiatement les messages du serveur via IMAP

View File

@ -172,6 +172,9 @@
<p>A workaround with Thunderbird is to set the property
<code>mail.imap.expunge_after_delete=true</code>
</p>
<p>New: a new setting is available in DavMail to delete messages immediately over IMAP:
<code>davmail.imapAutoExpunge=true</code>
</p>
</subsection>
<subsection name="Build">

View File

@ -91,6 +91,11 @@
<td>Use double event update to trigger ActiveSync mobile phones sync</td>
<td>false</td>
</tr>
<tr>
<td>IMAP auto expunge</td>
<td>Delete messages immediately on the server over IMAP</td>
<td>true</td>
</tr>
<tr>
<td>Display startup banner</td>
<td>Whether to show the initial startup notification window or not</td>