mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-14 03:32: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:
parent
bfc205035d
commit
5f09ec9c54
@ -614,9 +614,11 @@ public class ExchangeSession {
|
|||||||
" ,\"http://schemas.microsoft.com/mapi/proptag/x0E070003\", \"http://schemas.microsoft.com/mapi/proptag/x10810003\"" +
|
" ,\"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\"" +
|
" ,\"urn:schemas:mailheader:message-id\", \"urn:schemas:httpmail:read\", \"DAV:isdeleted\", \"urn:schemas:mailheader:date\"" +
|
||||||
" FROM Scope('SHALLOW TRAVERSAL OF \"" + folderUrl + "\"')\n" +
|
" FROM Scope('SHALLOW TRAVERSAL OF \"" + folderUrl + "\"')\n" +
|
||||||
" WHERE \"DAV:ishidden\" = False AND \"DAV:isfolder\" = False\n" +
|
" WHERE \"DAV:ishidden\" = False AND \"DAV:isfolder\" = False\n";
|
||||||
conditions.replaceAll("<", "<").replaceAll(">", ">") +
|
if (conditions != null) {
|
||||||
" ORDER BY \"urn:schemas:httpmail:date\" ASC";
|
searchRequest += conditions.replaceAll("<", "<").replaceAll(">", ">");
|
||||||
|
}
|
||||||
|
searchRequest += " ORDER BY \"urn:schemas:httpmail:date\" ASC";
|
||||||
Enumeration folderEnum = DavGatewayHttpClientFacade.executeSearchMethod(wdr.retrieveSessionInstance(), folderUrl, searchRequest);
|
Enumeration folderEnum = DavGatewayHttpClientFacade.executeSearchMethod(wdr.retrieveSessionInstance(), folderUrl, searchRequest);
|
||||||
|
|
||||||
while (folderEnum.hasMoreElements()) {
|
while (folderEnum.hasMoreElements()) {
|
||||||
|
@ -226,8 +226,12 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
conditions.append(")");
|
conditions.append(")");
|
||||||
|
String query = conditions.query.toString();
|
||||||
DavGatewayTray.debug("Search: " + conditions.query);
|
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) {
|
for (ExchangeSession.Message message : localMessages) {
|
||||||
if (((undeleted && !message.deleted) || !undeleted)
|
if (((undeleted && !message.deleted) || !undeleted)
|
||||||
&& (conditions.flagged == null || message.flagged == conditions.flagged)
|
&& (conditions.flagged == null || message.flagged == conditions.flagged)
|
||||||
@ -659,6 +663,16 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
} else {
|
} else {
|
||||||
throw new IOException("Invalid search parameters");
|
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\"<'").append(dateFormatter.format(date)).append("'");
|
||||||
|
} catch (ParseException e) {
|
||||||
|
throw new IOException("Invalid search parameters");
|
||||||
|
}
|
||||||
} else if ("OLD".equals(token)) {
|
} else if ("OLD".equals(token)) {
|
||||||
// ignore
|
// ignore
|
||||||
} else {
|
} else {
|
||||||
@ -928,7 +942,7 @@ public class ImapConnection extends AbstractConnection {
|
|||||||
ExchangeSession.Message message = messages.get(currentIndex++);
|
ExchangeSession.Message message = messages.get(currentIndex++);
|
||||||
long uid = message.getUidAsLong();
|
long uid = message.getUidAsLong();
|
||||||
if (uid < startUid || uid > endUid) {
|
if (uid < startUid || uid > endUid) {
|
||||||
throw new RuntimeException("Message uid "+uid+ " not in range "+startUid+":"+endUid);
|
throw new RuntimeException("Message uid " + uid + " not in range " + startUid + ":" + endUid);
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user