1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 19:22:22 -05:00

IMAP: implement empty and BEFORE search filters

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@428 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-03-09 23:12:08 +00:00
parent bfc205035d
commit 5f09ec9c54
2 changed files with 22 additions and 6 deletions

View File

@ -614,9 +614,11 @@ public class ExchangeSession {
" ,\"http://schemas.microsoft.com/mapi/proptag/x0E070003\", \"http://schemas.microsoft.com/mapi/proptag/x10810003\"" +
" ,\"urn:schemas:mailheader:message-id\", \"urn:schemas:httpmail:read\", \"DAV:isdeleted\", \"urn:schemas:mailheader:date\"" +
" FROM Scope('SHALLOW TRAVERSAL OF \"" + folderUrl + "\"')\n" +
" WHERE \"DAV:ishidden\" = False AND \"DAV:isfolder\" = False\n" +
conditions.replaceAll("<", "&lt;").replaceAll(">", "&gt;") +
" ORDER BY \"urn:schemas:httpmail:date\" ASC";
" WHERE \"DAV:ishidden\" = False AND \"DAV:isfolder\" = False\n";
if (conditions != null) {
searchRequest += conditions.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
}
searchRequest += " ORDER BY \"urn:schemas:httpmail:date\" ASC";
Enumeration folderEnum = DavGatewayHttpClientFacade.executeSearchMethod(wdr.retrieveSessionInstance(), folderUrl, searchRequest);
while (folderEnum.hasMoreElements()) {

View File

@ -226,8 +226,12 @@ public class ImapConnection extends AbstractConnection {
}
}
conditions.append(")");
String query = conditions.query.toString();
DavGatewayTray.debug("Search: " + conditions.query);
ExchangeSession.MessageList localMessages = session.searchMessages(currentFolder.folderName, conditions.query.toString());
if ("AND ()".equals(query)) {
query = null;
}
ExchangeSession.MessageList localMessages = session.searchMessages(currentFolder.folderName, query);
for (ExchangeSession.Message message : localMessages) {
if (((undeleted && !message.deleted) || !undeleted)
&& (conditions.flagged == null || message.flagged == conditions.flagged)
@ -659,6 +663,16 @@ public class ImapConnection extends AbstractConnection {
} else {
throw new IOException("Invalid search parameters");
}
} else if ("BEFORE".equals(token)) {
SimpleDateFormat parser = new SimpleDateFormat("dd-MMM-yyyy", Locale.ENGLISH);
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
dateFormatter.setTimeZone(ExchangeSession.GMT_TIMEZONE);
try {
Date date = parser.parse(tokens.nextToken());
conditions.append(operator).append("\"urn:schemas:httpmail:datereceived\"&lt;'").append(dateFormatter.format(date)).append("'");
} catch (ParseException e) {
throw new IOException("Invalid search parameters");
}
} else if ("OLD".equals(token)) {
// ignore
} else {