From: adam Date: Mon, 31 May 2004 04:19:54 +0000 (+0000) Subject: moved flags into Mailbox X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=6f0a19bdbf9b193dd465ec6624ef274d11cdfdf9;p=org.ibex.mail.git moved flags into Mailbox darcs-hash:20040531041954-5007d-ab48fd0ef77ee4c34e135da74a973f7032cc64e8.gz --- diff --git a/src/org/ibex/mail/Message.java b/src/org/ibex/mail/Message.java index de7e5d1..5ee6864 100644 --- a/src/org/ibex/mail/Message.java +++ b/src/org/ibex/mail/Message.java @@ -19,14 +19,23 @@ import java.io.*; public class Message extends JSReflection { - // FIXME: case-insensitive header hashmap - public int rfc822size() { return -1; } // FIXME - public int numLines() { return -1; } // FIXME - public int messageNum = -1; + private static class CaseInsensitiveHash extends Hashtable { + public Object get(Object o) { + if (o instanceof String) return super.get(((String)o).toLowerCase()); + return super.get(o); + } + public Object put(Object k, Object v) { + if (k instanceof String) return super.put(((String)k).toLowerCase(), v); + else return super.put(k, v); + } + } + + public int rfc822size() { return allHeaders.length() + 2 /* CRLF */ + body.length(); } // double check this public final String allHeaders; // pristine headers public final Hashtable headers; // hash of headers (not including resent's and traces) public final String body; // entire body + public final int lines; // lines in the body public final Date date; public final Address to; @@ -53,16 +62,17 @@ public class Message extends JSReflection { w.write(body); w.flush(); } - - + /* + public static class Persistent { public boolean deleted = false; public boolean seen = false; public boolean flagged = false; public boolean draft = false; public boolean answered = false; public boolean recent = false; - public int uid = 0; - + public int uid = 0; + } + */ /* public static class StoredMessage extends Message { public int uid; @@ -125,7 +135,7 @@ public class Message extends JSReflection { this.envelopeFrom = envelopeFrom; this.envelopeTo = envelopeTo; this.arrival = new Date(); - this.headers = new Hashtable(); + this.headers = new CaseInsensitiveHash(); String key = null; StringBuffer all = new StringBuffer(); Date date = null; @@ -183,7 +193,9 @@ public class Message extends JSReflection { traces.copyInto(this.traces = new Trace[traces.size()]); allHeaders = all.toString(); StringBuffer body = new StringBuffer(); - for(String s = rs.readLine();; s = rs.readLine()) { if (s == null) break; else body.append(s + "\r\n"); } + int lines = 0; + for(String s = rs.readLine();; s = rs.readLine()) { if (s == null) break; lines++; body.append(s + "\r\n"); } + this.lines = lines; this.body = body.toString(); } diff --git a/src/org/ibex/mail/protocol/IMAP.java b/src/org/ibex/mail/protocol/IMAP.java index 02c2cbf..c8fd904 100644 --- a/src/org/ibex/mail/protocol/IMAP.java +++ b/src/org/ibex/mail/protocol/IMAP.java @@ -95,11 +95,7 @@ public class IMAP extends MessageProtocol { public void status(Mailbox m, Token[] attrs) { int[] list = m.list(); int recent = 0, unseen = 0; - for(int i=0; i