add keep delay to settings panel

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@25 3d1905a2-6b24-0410-a738-b14d5a86fcbd
master
mguessan 17 years ago
parent de81d3d7b8
commit 08f86575d5

@ -29,6 +29,7 @@ public class Settings {
settings.put("davmail.url", "http://exchangeServer");
settings.put("davmail.popPort", "110");
settings.put("davmail.smtpPort", "25");
settings.put("davmail.keepDelay", "30");
settings.put("davmail.enableProxy", "false");
settings.put("davmail.proxyHost", "");
settings.put("davmail.proxyPort", "");

@ -19,16 +19,19 @@ public class SettingsFrame extends JFrame {
public SettingsFrame() {
setTitle("DavMail Settings");
JPanel panel = new JPanel(new GridLayout(3, 2));
JPanel panel = new JPanel(new GridLayout(4, 2));
panel.setBorder(BorderFactory.createTitledBorder("Gateway settings"));
final JTextField urlField = new JTextField(Settings.getProperty("davmail.url"), 15);
final JTextField popPortField = new JTextField(Settings.getProperty("davmail.popPort"), 4);
final JTextField smtpPortField = new JTextField(Settings.getProperty("davmail.smtpPort"), 4);
final JTextField keepDelayField = new JTextField(Settings.getProperty("davmail.keepDelay"), 4);
keepDelayField.setToolTipText("Number of days to keep messages in trash");
addSettingComponent(panel, "OWA url: ", urlField);
addSettingComponent(panel, "Local POP port: ", popPortField);
addSettingComponent(panel, "Local SMTP port: ", smtpPortField);
addSettingComponent(panel, "Keep Delay: ", keepDelayField);
add("North", panel);
@ -75,6 +78,7 @@ public class SettingsFrame extends JFrame {
Settings.setProperty("davmail.url", urlField.getText());
Settings.setProperty("davmail.popPort", popPortField.getText());
Settings.setProperty("davmail.smtpPort", smtpPortField.getText());
Settings.setProperty("davmail.keepDelay", keepDelayField.getText());
Settings.setProperty("davmail.enableProxy", String.valueOf(enableProxyField.isSelected()));
Settings.setProperty("davmail.proxyHost", httpProxyField.getText());
Settings.setProperty("davmail.proxyPort", httpProxyPortField.getText());

@ -91,6 +91,8 @@ public class ExchangeSession {
public static final String CONTENT_TYPE_HEADER = "content-type: ";
public static final String CONTENT_TRANSFER_ENCODING_HEADER = "content-transfer-encoding: ";
private static final int DEFAULT_KEEP_DELAY = 30;
/**
* Date parser from Exchange format
*/
@ -445,11 +447,15 @@ public class ExchangeSession {
/**
* Delete oldest messages in trash.
*
* @param keepDelay number of days to keep messages in trash before delete
* keepDelay is the number of days to keep messages in trash before delete
* @throws IOException
*/
public void purgeOldestTrashMessages(int keepDelay) throws IOException {
public void purgeOldestTrashMessages() throws IOException {
int keepDelay = Settings.getIntProperty("davmail.keepDelay");
if (keepDelay == 0) {
keepDelay = DEFAULT_KEEP_DELAY;
}
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_MONTH, -keepDelay);
logger.debug("Keep message not before " + cal.getTime());

@ -68,6 +68,8 @@ public class PopConnection extends AbstractConnection {
String command = tokens.nextToken();
if ("QUIT".equalsIgnoreCase(command)) {
// delete messages before quit
session.purgeOldestTrashMessages();
sendOK("Bye");
break;
} else if ("USER".equalsIgnoreCase(command)) {

@ -26,7 +26,7 @@ public class TestExchangeSession {
messageTest.write(System.out);
System.out.println("Elapsed time " + (System.currentTimeMillis()-startTime) + " ms");
session.purgeOldestTrashMessages(22);
session.purgeOldestTrashMessages();
} catch (Exception e) {
e.printStackTrace();

Loading…
Cancel
Save