mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-13 11:12:22 -05:00
Fix bug 2822625: support index range in IMAP SEARCH
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@616 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
76889311ea
commit
827a0bc806
@ -248,11 +248,13 @@ public class ImapConnection extends AbstractConnection {
|
||||
query = null;
|
||||
}
|
||||
ExchangeSession.MessageList localMessages = session.searchMessages(currentFolder.folderName, query);
|
||||
int index = 1;
|
||||
for (ExchangeSession.Message message : localMessages) {
|
||||
if (((undeleted && !message.deleted) || !undeleted)
|
||||
&& (conditions.flagged == null || message.flagged == conditions.flagged)
|
||||
&& (conditions.answered == null || message.answered == conditions.answered)
|
||||
&& (conditions.startUid == 0 || message.getImapUid() >= conditions.startUid)
|
||||
&& (conditions.startIndex == 0 || (index++ >= conditions.startIndex))
|
||||
) {
|
||||
sendClient("* SEARCH " + message.getImapUid());
|
||||
}
|
||||
@ -644,6 +646,7 @@ public class ImapConnection extends AbstractConnection {
|
||||
Boolean flagged;
|
||||
Boolean answered;
|
||||
long startUid;
|
||||
int startIndex;
|
||||
final StringBuilder query = new StringBuilder();
|
||||
|
||||
public StringBuilder append(String value) {
|
||||
@ -731,6 +734,13 @@ public class ImapConnection extends AbstractConnection {
|
||||
}
|
||||
} else if ("OLD".equals(token) || "RECENT".equals(token)) {
|
||||
// ignore
|
||||
} else if (token.indexOf(':') >= 0) {
|
||||
// range search
|
||||
try {
|
||||
conditions.startIndex = Integer.parseInt(token.substring(0, token.indexOf(':')));
|
||||
} catch (NumberFormatException e) {
|
||||
throw new DavMailException("EXCEPTION_INVALID_SEARCH_PARAMETERS", token);
|
||||
}
|
||||
} else {
|
||||
throw new DavMailException("EXCEPTION_INVALID_SEARCH_PARAMETERS", token);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user