mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-13 19:22:22 -05:00
Added a new setting to get events in the past not older than specified days count
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@205 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
21ea655d2a
commit
d426239bd4
@ -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) {
|
||||
|
@ -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 = "<?xml version=\"1.0\"?>\n" +
|
||||
"<d:searchrequest xmlns:d=\"DAV:\">\n" +
|
||||
" <d:sql>Select \"DAV:uid\"" +
|
||||
@ -795,6 +796,14 @@ public class ExchangeSession {
|
||||
}
|
||||
|
||||
public List<Event> 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<Event> events = new ArrayList<Event>();
|
||||
String searchRequest = "<?xml version=\"1.0\"?>\n" +
|
||||
"<d:searchrequest xmlns:d=\"DAV:\">\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" +
|
||||
" </d:sql>\n" +
|
||||
"</d:searchrequest>";
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
|
@ -55,6 +55,11 @@
|
||||
<td>Number of days to keep sent messages in Exchange sent folder</td>
|
||||
<td>90</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Calendar past events</td>
|
||||
<td>Get events in the past not older than specified days count, leave empty for no limits</td>
|
||||
<td>90</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Allow remote connections</td>
|
||||
<td>Allow remote connections to the gateway (server mode)</td>
|
||||
|
@ -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=
|
||||
|
@ -3,6 +3,7 @@ davmail.popPort=1110
|
||||
davmail.smtpPort=1025
|
||||
davmail.keepDelay=30
|
||||
davmail.sentKeepDelay=90
|
||||
davmail.caldavPastDelay=90
|
||||
|
||||
davmail.enableProxy=false
|
||||
davmail.proxyHost=
|
||||
|
Loading…
Reference in New Issue
Block a user