diff --git a/src/java/davmail/Settings.java b/src/java/davmail/Settings.java
index 00648e0a..5b74e57f 100644
--- a/src/java/davmail/Settings.java
+++ b/src/java/davmail/Settings.java
@@ -52,6 +52,7 @@ public class Settings {
SETTINGS.put("davmail.caldavPort", "1080");
SETTINGS.put("davmail.keepDelay", "30");
SETTINGS.put("davmail.sentKeepDelay", "90");
+ SETTINGS.put("davmail.caldavPastDelay", "90");
SETTINGS.put("davmail.allowRemote", "false");
SETTINGS.put("davmail.bindAddress", "");
SETTINGS.put("davmail.enableProxy", "false");
@@ -115,7 +116,11 @@ public class Settings {
}
public static synchronized int getIntProperty(String property) {
- int value = 0;
+ return getIntProperty(property, 0);
+ }
+
+ public static synchronized int getIntProperty(String property, int defaultValue) {
+ int value = defaultValue;
try {
String propertyValue = SETTINGS.getProperty(property);
if (propertyValue != null && propertyValue.length() > 0) {
diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java
index 0c3032e9..db5f6dfb 100644
--- a/src/java/davmail/exchange/ExchangeSession.java
+++ b/src/java/davmail/exchange/ExchangeSession.java
@@ -45,6 +45,7 @@ public class ExchangeSession {
* Date parser from Exchange format
*/
private final SimpleDateFormat dateParser;
+ private final SimpleDateFormat dateFormatter;
/**
* Various standard mail boxes Urls
@@ -81,6 +82,8 @@ public class ExchangeSession {
// each session
dateParser = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
dateParser.setTimeZone(new SimpleTimeZone(0, "GMT"));
+
+ dateFormatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
LOGGER.debug("Session " + this + " created");
}
@@ -524,8 +527,6 @@ public class ExchangeSession {
cal.add(Calendar.DAY_OF_MONTH, -keepDelay);
LOGGER.debug("Delete messages in " + folderUrl + " since " + cal.getTime());
- SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
-
String searchRequest = "\n" +
"\n" +
" Select \"DAV:uid\"" +
@@ -795,6 +796,14 @@ public class ExchangeSession {
}
public List getAllEvents() throws IOException {
+ int caldavPastDelay = Settings.getIntProperty("davmail.caldavPastDelay", 90);
+ String dateCondition = "";
+ if(caldavPastDelay != 0) {
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.DAY_OF_MONTH, -caldavPastDelay);
+ dateCondition = " AND \"urn:schemas:calendar:dtstart\" > '"+dateFormatter.format(cal.getTime())+"'\n";
+ }
+
List events = new ArrayList();
String searchRequest = "\n" +
"\n" +
@@ -802,7 +811,7 @@ public class ExchangeSession {
" FROM Scope('SHALLOW TRAVERSAL OF \"" + calendarUrl + "\"')\n" +
" WHERE NOT \"urn:schemas:calendar:instancetype\" = 1\n" +
" AND \"DAV:contentclass\" = 'urn:content-classes:appointment'\n" +
-// " AND \"urn:schemas:calendar:dtstart\" > '2008/11/01 00:00:00'\n" +
+ dateCondition +
" ORDER BY \"urn:schemas:calendar:dtstart\" ASC\n" +
" \n" +
"";
diff --git a/src/java/davmail/pop/PopConnection.java b/src/java/davmail/pop/PopConnection.java
index d5ad2d22..94a80257 100644
--- a/src/java/davmail/pop/PopConnection.java
+++ b/src/java/davmail/pop/PopConnection.java
@@ -82,7 +82,7 @@ public class PopConnection extends AbstractConnection {
if ("QUIT".equalsIgnoreCase(command)) {
// delete messages before quit
if (session != null) {
- session.purgeOldestTrashMessages();
+ session.purgeOldestTrashAndSentMessages();
}
sendOK("Bye");
break;
diff --git a/src/java/davmail/ui/SettingsFrame.java b/src/java/davmail/ui/SettingsFrame.java
index 1ceb07d7..cd3e11df 100644
--- a/src/java/davmail/ui/SettingsFrame.java
+++ b/src/java/davmail/ui/SettingsFrame.java
@@ -22,6 +22,7 @@ public class SettingsFrame extends JFrame {
protected JTextField caldavPortField;
protected JTextField keepDelayField;
protected JTextField sentKeepDelayField;
+ protected JTextField caldavPastDelayField;
JCheckBox enableProxyField;
JTextField httpProxyField;
@@ -40,15 +41,17 @@ public class SettingsFrame extends JFrame {
JComboBox wireLoggingLevelField;
protected void addSettingComponent(JPanel panel, String label, JComponent component) {
- addSettingComponent(panel, label, component, null);
+ addSettingComponent(panel, label, component, null);
}
protected void addSettingComponent(JPanel panel, String label, JComponent component, String toolTipText) {
JLabel fieldLabel = new JLabel(label);
fieldLabel.setHorizontalAlignment(SwingConstants.RIGHT);
+ fieldLabel.setVerticalAlignment(SwingConstants.CENTER);
panel.add(fieldLabel);
component.setMaximumSize(component.getPreferredSize());
- JPanel innerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
+ JPanel innerPanel = new JPanel();
+ innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.X_AXIS));
innerPanel.add(component);
panel.add(innerPanel);
if (toolTipText != null) {
@@ -58,25 +61,38 @@ public class SettingsFrame extends JFrame {
}
protected JPanel getSettingsPanel() {
- JPanel settingsPanel = new JPanel(new GridLayout(6, 2));
+ JPanel settingsPanel = new JPanel(new GridLayout(4, 2));
settingsPanel.setBorder(BorderFactory.createTitledBorder("Gateway"));
urlField = new JTextField(Settings.getProperty("davmail.url"), 17);
popPortField = new JTextField(Settings.getProperty("davmail.popPort"), 4);
smtpPortField = new JTextField(Settings.getProperty("davmail.smtpPort"), 4);
caldavPortField = new JTextField(Settings.getProperty("davmail.caldavPort"), 4);
- keepDelayField = new JTextField(Settings.getProperty("davmail.keepDelay"), 4);
- sentKeepDelayField = new JTextField(Settings.getProperty("davmail.sentKeepDelay"), 4);
addSettingComponent(settingsPanel, "OWA url: ", urlField, "Base outlook web access URL");
addSettingComponent(settingsPanel, "Local POP port: ", popPortField);
addSettingComponent(settingsPanel, "Local SMTP port: ", smtpPortField);
addSettingComponent(settingsPanel, "Caldav HTTP port: ", caldavPortField);
- addSettingComponent(settingsPanel, "Keep delay: ", keepDelayField, "Number of days to keep messages in trash");
- addSettingComponent(settingsPanel, "Sent keep delay: ", sentKeepDelayField, "Number of days to keep messages in sent folder");
return settingsPanel;
}
+ protected JPanel getDelaysPanel() {
+ JPanel delaysPanel = new JPanel(new GridLayout(3, 2));
+ delaysPanel.setBorder(BorderFactory.createTitledBorder("Delays"));
+
+ keepDelayField = new JTextField(Settings.getProperty("davmail.keepDelay"), 4);
+ sentKeepDelayField = new JTextField(Settings.getProperty("davmail.sentKeepDelay"), 4);
+ caldavPastDelayField = new JTextField(Settings.getProperty("davmail.caldavPastDelay"), 4);
+
+ addSettingComponent(delaysPanel, "Keep delay: ", keepDelayField,
+ "Number of days to keep messages in trash");
+ addSettingComponent(delaysPanel, "Sent keep delay: ", sentKeepDelayField,
+ "Number of days to keep messages in sent folder");
+ addSettingComponent(delaysPanel, "Calendar past events: ", caldavPastDelayField,
+ "Get events in the past not older than specified days count, leave empty for no limits");
+ return delaysPanel;
+ }
+
protected JPanel getProxyPanel() {
JPanel proxyPanel = new JPanel(new GridLayout(5, 2));
proxyPanel.setBorder(BorderFactory.createTitledBorder("Proxy"));
@@ -162,6 +178,7 @@ public class SettingsFrame extends JFrame {
caldavPortField.setText(Settings.getProperty("davmail.caldavPort"));
keepDelayField.setText(Settings.getProperty("davmail.keepDelay"));
sentKeepDelayField.setText(Settings.getProperty("davmail.sentKeepDelay"));
+ caldavPastDelayField.setText(Settings.getProperty("davmail.caldavPastDelay"));
boolean enableProxy = Settings.getBooleanProperty("davmail.enableProxy");
enableProxyField.setSelected(enableProxy);
httpProxyField.setEnabled(enableProxy);
@@ -202,6 +219,7 @@ public class SettingsFrame extends JFrame {
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
mainPanel.add(getSettingsPanel());
+ mainPanel.add(getDelaysPanel());
mainPanel.add(getProxyPanel());
mainPanel.add(Box.createVerticalGlue());
@@ -212,9 +230,12 @@ public class SettingsFrame extends JFrame {
advancedPanel.add(getNetworkSettingsPanel());
advancedPanel.add(getLoggingSettingsPanel());
+ // empty panel
+ advancedPanel.add(new JPanel());
tabbedPane.add("Advanced", advancedPanel);
+
add("Center", tabbedPane);
JPanel buttonPanel = new JPanel();
@@ -229,6 +250,7 @@ public class SettingsFrame extends JFrame {
Settings.setProperty("davmail.caldavPort", caldavPortField.getText());
Settings.setProperty("davmail.keepDelay", keepDelayField.getText());
Settings.setProperty("davmail.sentKeepDelay", sentKeepDelayField.getText());
+ Settings.setProperty("davmail.caldavPastDelay", caldavPastDelayField.getText());
Settings.setProperty("davmail.enableProxy", String.valueOf(enableProxyField.isSelected()));
Settings.setProperty("davmail.proxyHost", httpProxyField.getText());
Settings.setProperty("davmail.proxyPort", httpProxyPortField.getText());
diff --git a/src/site/xdoc/gettingstarted.xml b/src/site/xdoc/gettingstarted.xml
index e7b53b8c..1b8c8820 100644
--- a/src/site/xdoc/gettingstarted.xml
+++ b/src/site/xdoc/gettingstarted.xml
@@ -55,6 +55,11 @@
Number of days to keep sent messages in Exchange sent folder |
90 |
+
+ Calendar past events |
+ Get events in the past not older than specified days count, leave empty for no limits |
+ 90 |
+
Allow remote connections |
Allow remote connections to the gateway (server mode) |
diff --git a/src/site/xdoc/serversetup.xml b/src/site/xdoc/serversetup.xml
index 48d06fb5..d9440006 100644
--- a/src/site/xdoc/serversetup.xml
+++ b/src/site/xdoc/serversetup.xml
@@ -33,6 +33,7 @@ davmail.popPort=1110
davmail.smtpPort=1025
davmail.keepDelay=30
davmail.sentKeepDelay=90
+davmail.caldavPastDelay=90
davmail.enableProxy=false
davmail.proxyHost=
davmail.proxyPort=
diff --git a/src/web/WEB-INF/classes/davmail.properties b/src/web/WEB-INF/classes/davmail.properties
index 7c323122..e89c1875 100644
--- a/src/web/WEB-INF/classes/davmail.properties
+++ b/src/web/WEB-INF/classes/davmail.properties
@@ -3,6 +3,7 @@ davmail.popPort=1110
davmail.smtpPort=1025
davmail.keepDelay=30
davmail.sentKeepDelay=90
+davmail.caldavPastDelay=90
davmail.enableProxy=false
davmail.proxyHost=