From: adam Date: Thu, 5 Jul 2007 01:39:27 +0000 (+0000) Subject: improve PEEK logic in IMAP X-Git-Url: http://git.megacz.com/?p=org.ibex.mail.git;a=commitdiff_plain;h=227b2bb3eff15c820e050e99d896dae2e98d551d improve PEEK logic in IMAP darcs-hash:20070705013927-5007d-b17558ebacab019489907ac03ee643a9fd562b68.gz --- diff --git a/src/org/ibex/mail/IMAP.java b/src/org/ibex/mail/IMAP.java index ea08055..522509d 100644 --- a/src/org/ibex/mail/IMAP.java +++ b/src/org/ibex/mail/IMAP.java @@ -14,6 +14,8 @@ import java.net.*; import java.text.*; import java.io.*; +// FEATURE: IDLE extension for blackberries + // FIXME: this is valid LSUB "" asdfdas%*%*%*%*SFEFGWEF // FIXME: be very careful about where/when we quotify stuff // FIXME: 'UID FOO 100:*' must match at least one message even if all UIDs less than 100 @@ -453,6 +455,7 @@ public class IMAP { t = new Parser.Token[] { parser.token("FLAGS"), parser.token("INTERNALDATE"), parser.token("RFC822.SIZE") }; } + boolean looked_at_body = false; for(int i=0; i initlen) r.append(" "); if (t[i] == null || t[i].s == null) continue; @@ -470,11 +473,11 @@ public class IMAP { } else if (!(s.equals("BODY.PEEK") || s.equals("BODY"))) { throw new Server.No("unknown fetch argument: " + s); } else { if (s.equalsIgnoreCase("BODY.PEEK")) spec |= PEEK; - //else if (e) api.addFlags(Query.imapNumber(new int[] { num, num }), Mailbox.Flag.SEEN, false, false); + looked_at_body = true; if (i >= t.length - 1 || t[i+1].type != Parser.Token.LIST) { spec |= BODYSTRUCTURE; if (e) { r.append(" "); r.append(Printer.bodystructure(m)); } continue; - //{ if (e) { r.append(" "); r.append(Printer.qq(m.body)); } continue; } + //if (e) { r.append(" "); r.append(Printer.qq(m.getBody().getStream())); } continue; } Fountain payload = Fountain.Util.create(""); r.append("["); @@ -504,6 +507,8 @@ public class IMAP { if (e) { r.append("] "); r.append(Printer.qq(payload.getStream())); } } } + if ((spec & PEEK) == 0 && looked_at_body && e) + api.addFlags(Query.imapNumber(new int[] { num, num }), Mailbox.Flag.SEEN, false, false); if (e) { r.append(")"); println("* " + r.toString()); @@ -835,7 +840,7 @@ public class IMAP { public static String qq(Stream stream) { StringBuffer sb = new StringBuffer(); stream.transcribe(sb); - return sb.toString(); + return qq(sb.toString()); } public static String qq(String s) { StringBuffer ret = new StringBuffer();