added tons of stuff, including js support
[org.ibex.mail.git] / src / org / ibex / mail / Message.java
index e01ef8e..3effcfa 100644 (file)
@@ -1,4 +1,5 @@
 package org.ibex.mail;
+import org.ibex.crypto.*;
 // FIXME MIME: RFC2045, 2046, 2049
 // NOTE: always use Win32 line endings
 // hard line limit: 998 chars
@@ -13,7 +14,8 @@ package org.ibex.mail;
 // FEATURE: mailing list header parsing
 // FEATURE: delivery status notification (and the sneaky variety)
 // FEATURE: threading as in http://www.jwz.org/doc/threading.html
-public class Message {
+
+public class Message extends JSReflection {
 
     public final String allHeaders;   // pristine headers
     public final Hashtable headers;   // hash of headers (not including resent's and traces)
@@ -39,9 +41,14 @@ public class Message {
         public boolean deleted = false;
         public boolean read = false;
         public boolean answered = false;
+        public String dumpStoredForm() { throw new Error("StoredMessage.dumpStoredForm() not implemented"); };
     }
 
-    public static class Address {
+    public static class Address extends JSReflection {
+        public String coerceToString() {
+            if (description == null || description.equals("")) return user +"@"+ host;
+            return description + " " + "<" + user +"@"+ host + ">";
+        }
         public final String user;
         public final String host;
         public final String description;
@@ -75,18 +82,8 @@ public class Message {
         }
     }
 
-    public static class Base36 {
-        public static String encode(long l) {
-            StringBuffer ret = new StringBuffer();
-            while (l > 0) {
-                if ((l % 36) < 10) ret.append((char)(((int)'0') + (int)(l % 36)));
-                else ret.append((char)(((int)'A') + (int)((l % 36) - 10)));
-                l /= 36;
-            }
-        }
-    }
-
-    public Message(ReadStream rs) {
+    // FIXME: support dotTerminatedLikeSMTP
+    public Message(ReadStream rs, boolean dotTermiantedLikeSMTP) {
         String key = null;
         StringBuffer all = new StringBuffer();
         for(String s = rs.readLine(); s != null && !s.equals(""); s = rs.readLine()) {
@@ -136,5 +133,5 @@ public class Message {
         return ret.toString();
     }
 
-    private static final Random = new Random();
+    private static final Random random = new Random();
 }