it compiles!
[org.ibex.mail.git] / src / org / ibex / mail / Message.java
index 3effcfa..bac2be3 100644 (file)
@@ -1,5 +1,11 @@
 package org.ibex.mail;
 import org.ibex.crypto.*;
+import org.ibex.js.*;
+import org.ibex.util.*;
+import java.util.*;
+import java.net.*;
+import java.io.*;
+
 // FIXME MIME: RFC2045, 2046, 2049
 // NOTE: always use Win32 line endings
 // hard line limit: 998 chars
@@ -19,6 +25,7 @@ public class Message extends JSReflection {
 
     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
 
     // parsed header fields
     public final Date date;
@@ -36,12 +43,22 @@ public class Message extends JSReflection {
     public final Address envelopeFrom;
     public final Address[] envelopeTo;
 
+    public void dump(OutputStream os) {
+        Log.error(this, "not implemented");
+    }
+
     public static class StoredMessage extends Message {
+        public StoredMessage(/*ReadStream rs*/BufferedReader rs, boolean dotTerminatedLikeSMTP) throws IOException {
+            super(rs, dotTerminatedLikeSMTP); uid = -1; }
         public final int uid;
         public boolean deleted = false;
         public boolean read = false;
         public boolean answered = false;
         public String dumpStoredForm() { throw new Error("StoredMessage.dumpStoredForm() not implemented"); };
+        public static StoredMessage undump(InputStream os) {
+            Log.error(StoredMessage.class, "not implemented");
+            return null;
+        }
     }
 
     public static class Address extends JSReflection {
@@ -71,21 +88,37 @@ public class Message extends JSReflection {
     }
 
     public class Trace {
-        final String returnPath = null;
-        final Element[] elements;
+        String returnPath = null;
+        Element[] elements;
         public class Element {
-            final String fromDomain;
-            final String fromIP;
-            final String toDomain;
-            final String forWhom;
-            final Date date;
+            // FIXME final
+            String fromDomain;
+            String fromIP;
+            String toDomain;
+            String forWhom;
+            Date date;
         }
     }
 
     // FIXME: support dotTerminatedLikeSMTP
-    public Message(ReadStream rs, boolean dotTermiantedLikeSMTP) {
+    public Message(/*ReadStream rs*/BufferedReader rs, boolean dotTerminatedLikeSMTP) throws IOException {
         String key = null;
         StringBuffer all = new StringBuffer();
+        String lastKey = null;
+        replyto = null;
+        subject = null;
+        messageid = null;
+        cc = null;
+        bcc = null;
+        resent = null;
+        traces = null;
+        envelopeFrom = null;
+        envelopeTo = null;
+
+        headers = new Hashtable();
+        date = null; // FIXME
+        to = null;
+        from = null;
         for(String s = rs.readLine(); s != null && !s.equals(""); s = rs.readLine()) {
             all.append(s);
             all.append("\r\n");
@@ -114,7 +147,7 @@ public class Message extends JSReflection {
             
             headers.put(key, val);
         }
-        pristeneHeaders = all.toString();
+        allHeaders = all.toString();
         StringBuffer body = new StringBuffer();
         for(String s = rs.readLine(); s != null && !s.equals(""); s = rs.readLine()) body.append(s);
         this.body = body.toString();