IMAP: implement DRAFT and UNDRAFT search conditions, fix 3396248

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1779 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2011-08-29 21:04:30 +00:00
parent 3ea83a69a3
commit af5bf09828
2 changed files with 15 additions and 1 deletions

View File

@ -905,7 +905,8 @@ public class ImapConnection extends AbstractConnection {
while (iterator.hasNext()) {
ExchangeSession.Message message = iterator.next();
if ((conditions.flagged == null || message.flagged == conditions.flagged)
&& (conditions.answered == null || message.answered == conditions.answered)) {
&& (conditions.answered == null || message.answered == conditions.answered)
&& (conditions.draft == null || message.draft == conditions.draft)) {
uidList.add(message.getImapUid());
}
}
@ -1169,6 +1170,7 @@ public class ImapConnection extends AbstractConnection {
static final class SearchConditions {
Boolean flagged;
Boolean answered;
Boolean draft;
String indexRange;
String uidRange;
}
@ -1215,6 +1217,10 @@ public class ImapConnection extends AbstractConnection {
return session.isTrue("read");
} else if ("UNSEEN".equals(token) || "NEW".equals(token)) {
return session.isFalse("read");
} else if ("DRAFT".equals(token)) {
conditions.draft = Boolean.TRUE;
} else if ("UNDRAFT".equals(token)) {
conditions.draft = Boolean.FALSE;
} else if ("DELETED".equals(token)) {
// conditions.deleted = Boolean.TRUE;
return session.isEqualTo("deleted", "1");

View File

@ -316,6 +316,14 @@ public class TestImap extends AbstractImapTestCase {
assertEquals(". OK SEARCH completed", readFullAnswer("."));
}
public void testSearchUndraft() throws IOException {
testSelectInbox();
writeLine(". UID SEARCH UNDRAFT");
assertEquals(". OK SEARCH completed", readFullAnswer("."));
writeLine(". UID SEARCH DRAFT");
assertEquals(". OK SEARCH completed", readFullAnswer("."));
}
public void testBrokenPipe() throws IOException, InterruptedException {
testSelectInbox();
writeLine(". UID FETCH 1:* (RFC822.SIZE BODY.TEXT)");