add keep delay to settings panel
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@25 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
de81d3d7b8
commit
08f86575d5
|
@ -29,6 +29,7 @@ public class Settings {
|
||||||
settings.put("davmail.url", "http://exchangeServer");
|
settings.put("davmail.url", "http://exchangeServer");
|
||||||
settings.put("davmail.popPort", "110");
|
settings.put("davmail.popPort", "110");
|
||||||
settings.put("davmail.smtpPort", "25");
|
settings.put("davmail.smtpPort", "25");
|
||||||
|
settings.put("davmail.keepDelay", "30");
|
||||||
settings.put("davmail.enableProxy", "false");
|
settings.put("davmail.enableProxy", "false");
|
||||||
settings.put("davmail.proxyHost", "");
|
settings.put("davmail.proxyHost", "");
|
||||||
settings.put("davmail.proxyPort", "");
|
settings.put("davmail.proxyPort", "");
|
||||||
|
|
|
@ -19,16 +19,19 @@ public class SettingsFrame extends JFrame {
|
||||||
public SettingsFrame() {
|
public SettingsFrame() {
|
||||||
setTitle("DavMail Settings");
|
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"));
|
panel.setBorder(BorderFactory.createTitledBorder("Gateway settings"));
|
||||||
|
|
||||||
final JTextField urlField = new JTextField(Settings.getProperty("davmail.url"), 15);
|
final JTextField urlField = new JTextField(Settings.getProperty("davmail.url"), 15);
|
||||||
final JTextField popPortField = new JTextField(Settings.getProperty("davmail.popPort"), 4);
|
final JTextField popPortField = new JTextField(Settings.getProperty("davmail.popPort"), 4);
|
||||||
final JTextField smtpPortField = new JTextField(Settings.getProperty("davmail.smtpPort"), 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, "OWA url: ", urlField);
|
||||||
addSettingComponent(panel, "Local POP port: ", popPortField);
|
addSettingComponent(panel, "Local POP port: ", popPortField);
|
||||||
addSettingComponent(panel, "Local SMTP port: ", smtpPortField);
|
addSettingComponent(panel, "Local SMTP port: ", smtpPortField);
|
||||||
|
addSettingComponent(panel, "Keep Delay: ", keepDelayField);
|
||||||
|
|
||||||
add("North", panel);
|
add("North", panel);
|
||||||
|
|
||||||
|
@ -75,6 +78,7 @@ public class SettingsFrame extends JFrame {
|
||||||
Settings.setProperty("davmail.url", urlField.getText());
|
Settings.setProperty("davmail.url", urlField.getText());
|
||||||
Settings.setProperty("davmail.popPort", popPortField.getText());
|
Settings.setProperty("davmail.popPort", popPortField.getText());
|
||||||
Settings.setProperty("davmail.smtpPort", smtpPortField.getText());
|
Settings.setProperty("davmail.smtpPort", smtpPortField.getText());
|
||||||
|
Settings.setProperty("davmail.keepDelay", keepDelayField.getText());
|
||||||
Settings.setProperty("davmail.enableProxy", String.valueOf(enableProxyField.isSelected()));
|
Settings.setProperty("davmail.enableProxy", String.valueOf(enableProxyField.isSelected()));
|
||||||
Settings.setProperty("davmail.proxyHost", httpProxyField.getText());
|
Settings.setProperty("davmail.proxyHost", httpProxyField.getText());
|
||||||
Settings.setProperty("davmail.proxyPort", httpProxyPortField.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_TYPE_HEADER = "content-type: ";
|
||||||
public static final String CONTENT_TRANSFER_ENCODING_HEADER = "content-transfer-encoding: ";
|
public static final String CONTENT_TRANSFER_ENCODING_HEADER = "content-transfer-encoding: ";
|
||||||
|
|
||||||
|
private static final int DEFAULT_KEEP_DELAY = 30;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Date parser from Exchange format
|
* Date parser from Exchange format
|
||||||
*/
|
*/
|
||||||
|
@ -445,11 +447,15 @@ public class ExchangeSession {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete oldest messages in trash.
|
* Delete oldest messages in trash.
|
||||||
*
|
* keepDelay is the number of days to keep messages in trash before delete
|
||||||
* @param keepDelay number of days to keep messages in trash before delete
|
|
||||||
* @throws IOException
|
* @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();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.add(Calendar.DAY_OF_MONTH, -keepDelay);
|
cal.add(Calendar.DAY_OF_MONTH, -keepDelay);
|
||||||
logger.debug("Keep message not before " + cal.getTime());
|
logger.debug("Keep message not before " + cal.getTime());
|
||||||
|
|
|
@ -68,6 +68,8 @@ public class PopConnection extends AbstractConnection {
|
||||||
String command = tokens.nextToken();
|
String command = tokens.nextToken();
|
||||||
|
|
||||||
if ("QUIT".equalsIgnoreCase(command)) {
|
if ("QUIT".equalsIgnoreCase(command)) {
|
||||||
|
// delete messages before quit
|
||||||
|
session.purgeOldestTrashMessages();
|
||||||
sendOK("Bye");
|
sendOK("Bye");
|
||||||
break;
|
break;
|
||||||
} else if ("USER".equalsIgnoreCase(command)) {
|
} else if ("USER".equalsIgnoreCase(command)) {
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class TestExchangeSession {
|
||||||
messageTest.write(System.out);
|
messageTest.write(System.out);
|
||||||
System.out.println("Elapsed time " + (System.currentTimeMillis()-startTime) + " ms");
|
System.out.println("Elapsed time " + (System.currentTimeMillis()-startTime) + " ms");
|
||||||
|
|
||||||
session.purgeOldestTrashMessages(22);
|
session.purgeOldestTrashMessages();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
Loading…
Reference in New Issue