POP: add a new setting to mark messages read after RETR

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1910 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2012-02-15 21:41:03 +00:00
parent f6f95a9300
commit c0ef8f9357
7 changed files with 37 additions and 7 deletions

View File

@ -157,6 +157,7 @@ public final class Settings {
SETTINGS.put("davmail.showStartupBanner", Boolean.TRUE.toString());
SETTINGS.put("davmail.disableGuiNotifications", Boolean.FALSE.toString());
SETTINGS.put("davmail.imapAutoExpunge", Boolean.TRUE.toString());
SETTINGS.put("davmail.popMarkReadOnRetr", Boolean.FALSE.toString());
SETTINGS.put("davmail.smtpSaveInSent", Boolean.TRUE.toString());
SETTINGS.put("davmail.ssl.keystoreType", "");
SETTINGS.put("davmail.ssl.keystoreFile", "");

View File

@ -1850,12 +1850,20 @@ public abstract class ExchangeSession {
* @throws IOException on error
*/
public void moveToTrash() throws IOException {
// mark message as read
markRead();
ExchangeSession.this.moveToTrash(this);
}
/**
* Mark message as read.
*
* @throws IOException on error
*/
public void markRead() throws IOException {
HashMap<String, String> properties = new HashMap<String, String>();
properties.put("read", "1");
updateMessage(this, properties);
ExchangeSession.this.moveToTrash(this);
}
/**
@ -2590,7 +2598,7 @@ public abstract class ExchangeSession {
}
return andCondition;
} catch (ParseException e) {
throw new IOException(e);
throw new IOException(e+" "+e.getMessage());
}
}

View File

@ -21,6 +21,7 @@ package davmail.pop;
import davmail.AbstractConnection;
import davmail.BundleMessage;
import davmail.DavGateway;
import davmail.Settings;
import davmail.exchange.DoubleDotOutputStream;
import davmail.exchange.ExchangeSession;
import davmail.exchange.ExchangeSessionFactory;
@ -202,8 +203,12 @@ public class PopConnection extends AbstractConnection {
int messageNumber = Integer.valueOf(tokens.nextToken()) - 1;
sendOK("");
DoubleDotOutputStream doubleDotOutputStream = new DoubleDotOutputStream(os);
IOUtil.write(messages.get(messageNumber).getRawInputStream(), doubleDotOutputStream);
ExchangeSession.Message message = messages.get(messageNumber);
IOUtil.write(message.getRawInputStream(), doubleDotOutputStream);
doubleDotOutputStream.close();
if (Settings.getBooleanProperty("davmail.popMarkReadOnRetr")) {
message.markRead();
}
} catch (SocketException e) {
// can not send error to client after a socket exception
LOGGER.warn(BundleMessage.formatLog("LOG_CLIENT_CLOSED_CONNECTION"));

View File

@ -99,6 +99,7 @@ public class SettingsFrame extends JFrame {
JCheckBox showStartupBannerCheckBox;
JCheckBox disableGuiNotificationsCheckBox;
JCheckBox imapAutoExpungeCheckBox;
JCheckBox popMarkReadOnRetrCheckBox;
JComboBox enableEwsComboBox;
JCheckBox smtpSaveInSentCheckBox;
@ -411,7 +412,7 @@ public class SettingsFrame extends JFrame {
}
protected JPanel getOtherSettingsPanel() {
JPanel otherSettingsPanel = new JPanel(new GridLayout(10, 2));
JPanel otherSettingsPanel = new JPanel(new GridLayout(11, 2));
otherSettingsPanel.setBorder(BorderFactory.createTitledBorder(BundleMessage.format("UI_OTHER")));
enableEwsComboBox = new JComboBox(new String[]{WEBDAV, EWS, AUTO});
@ -428,6 +429,8 @@ public class SettingsFrame extends JFrame {
disableGuiNotificationsCheckBox.setSelected(Settings.getBooleanProperty("davmail.disableGuiNotifications", false));
imapAutoExpungeCheckBox = new JCheckBox();
imapAutoExpungeCheckBox.setSelected(Settings.getBooleanProperty("davmail.imapAutoExpunge", true));
popMarkReadOnRetrCheckBox = new JCheckBox();
popMarkReadOnRetrCheckBox.setSelected(Settings.getBooleanProperty("davmail.popMarkReadOnRetr", false));
smtpSaveInSentCheckBox = new JCheckBox();
smtpSaveInSentCheckBox.setSelected(Settings.getBooleanProperty("davmail.smtpSaveInSent", true));
disableUpdateCheck = new JCheckBox();
@ -449,6 +452,8 @@ public class SettingsFrame extends JFrame {
BundleMessage.format("UI_DISABLE_GUI_NOTIFICATIONS_HELP"));
addSettingComponent(otherSettingsPanel, BundleMessage.format("UI_IMAP_AUTO_EXPUNGE"), imapAutoExpungeCheckBox,
BundleMessage.format("UI_IMAP_AUTO_EXPUNGE_HELP"));
addSettingComponent(otherSettingsPanel, BundleMessage.format("UI_POP_MARK_READ"), popMarkReadOnRetrCheckBox,
BundleMessage.format("UI_POP_MARK_READ_HELP"));
addSettingComponent(otherSettingsPanel, BundleMessage.format("UI_SAVE_IN_SENT"), smtpSaveInSentCheckBox,
BundleMessage.format("UI_SAVE_IN_SENT_HELP"));
addSettingComponent(otherSettingsPanel, BundleMessage.format("UI_DISABLE_UPDATE_CHECK"), disableUpdateCheck,
@ -568,6 +573,7 @@ public class SettingsFrame extends JFrame {
showStartupBannerCheckBox.setSelected(Settings.getBooleanProperty("davmail.showStartupBanner", true));
disableGuiNotificationsCheckBox.setSelected(Settings.getBooleanProperty("davmail.disableGuiNotifications", false));
imapAutoExpungeCheckBox.setSelected(Settings.getBooleanProperty("davmail.imapAutoExpunge", true));
popMarkReadOnRetrCheckBox.setSelected(Settings.getBooleanProperty("davmail.popMarkReadOnRetrCheckBox", false));
setEwsModeSelectedItem(Settings.getProperty("davmail.enableEws", "auto"));
smtpSaveInSentCheckBox.setSelected(Settings.getBooleanProperty("davmail.smtpSaveInSent", true));
@ -712,6 +718,7 @@ public class SettingsFrame extends JFrame {
Settings.setProperty("davmail.showStartupBanner", String.valueOf(showStartupBannerCheckBox.isSelected()));
Settings.setProperty("davmail.disableGuiNotifications", String.valueOf(disableGuiNotificationsCheckBox.isSelected()));
Settings.setProperty("davmail.imapAutoExpunge", String.valueOf(imapAutoExpungeCheckBox.isSelected()));
Settings.setProperty("davmail.popMarkReadOnRetr", String.valueOf(popMarkReadOnRetrCheckBox.isSelected()));
String selectedEwsMode = (String) enableEwsComboBox.getSelectedItem();
String enableEws;
if (EWS.equals(selectedEwsMode)) {

View File

@ -14,7 +14,7 @@ EXCEPTION_INVALID_CREDENTIALS=Invalid credentials
EXCEPTION_INVALID_DATE=Invalid date: {0}
EXCEPTION_INVALID_DATES=Invalid dates: {0}
EXCEPTION_INVALID_FOLDER_URL=Invalid folder URL: {0}
EXCEPTION_INVALID_HEADER=Invalid header, HTTPS connection to an HTTP listener ?
EXCEPTION_INVALID_HEADER=Invalid header, HTTPS connection to an HTTP listener ?
EXCEPTION_INVALID_KEEPALIVE=Invalid Keep-Alive: {0}
EXCEPTION_INVALID_MAIL_PATH=Invalid mail path: {0}
EXCEPTION_INVALID_MESSAGE_CONTENT=Invalid message content: {0}
@ -261,6 +261,8 @@ UI_DISABLE_GUI_NOTIFICATIONS=Disable balloon notifications
UI_DISABLE_GUI_NOTIFICATIONS_HELP=Disable all graphical notifications
UI_IMAP_AUTO_EXPUNGE=IMAP auto expunge:
UI_IMAP_AUTO_EXPUNGE_HELP=Delete messages immediately on the server over IMAP
UI_POP_MARK_READ=POP mark read:
UI_POP_MARK_READ_HELP=Mark messages read on server immediately after retrieval
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
EXCEPTION_EWS_NOT_AVAILABLE=EWS end point not available

View File

@ -264,6 +264,8 @@ UI_IMAP_IDLE_DELAY=D
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
UI_POP_MARK_READ=POP marquer lu :
UI_POP_MARK_READ_HELP=Marquer les messages lus sur le serveur immédiatement après chargement
EXCEPTION_EWS_NOT_AVAILABLE=Point d''accès EWS non disponible
EXCEPTION_FOLDER_NOT_FOUND=Dossier {0} non trouvé
UNKNOWN_ATTRIBUTE=Attribut inconnu: {0}

View File

@ -162,6 +162,11 @@
</td>
<td>90</td>
</tr>
<tr>
<td>POP mark read</td>
<td>Mark messages read on server immediately after retrieval</td>
<td>true</td>
</tr>
</table>
</subsection>
<subsection name="Caldav (Calendar)">