made newMessage a static method and Message() private
authoradam <adam@megacz.com>
Sat, 30 Oct 2004 08:41:02 +0000 (08:41 +0000)
committeradam <adam@megacz.com>
Sat, 30 Oct 2004 08:41:02 +0000 (08:41 +0000)
darcs-hash:20041030084102-5007d-6096fd3fd55d9c08e9e75480b32d85c50ad30f87.gz

src/org/ibex/mail/Confirmation.java
src/org/ibex/mail/List.java
src/org/ibex/mail/protocol/GMail.java
src/org/ibex/mail/protocol/IMAP.java
src/org/ibex/mail/protocol/Mbox.java
src/org/ibex/mail/target/FileBasedMailbox.java
src/org/ibex/mail/target/MailmanArchives.java
src/org/ibex/mail/target/Script.java

index c5e0022..f741890 100644 (file)
@@ -84,14 +84,13 @@ public abstract class Confirmation implements Externalizable {
     }
 
     public void signAndSend(long secret, Date now) throws IOException, Message.Malformed {
-        SMTP.Outgoing.accept(new Message(new Stream("From: "    + FROM + "\r\n" +
-                                                    "To: "      + who.toString(true) + "\r\n" +
-                                                    "Subject: confirm " + getDescription() + "\r\n" +
-                                                    "\r\n" +
-                                                    "Please click the link below to " + getDescription() + "\r\n" +
-                                                    sign(secret)),
-                                         new Message.Envelope(FROM, who, now)
-                                         )
+        SMTP.Outgoing.accept(Message.newMessage(new Stream("From: "    + FROM + "\r\n" +
+                                                           "To: "      + who.toString(true) + "\r\n" +
+                                                           "Subject: confirm " + getDescription() + "\r\n" +
+                                                           "\r\n" +
+                                                           "Please click the link below to " + getDescription() + "\r\n" +
+                                                           sign(secret)),
+                                                FROM, who)
                              );
     }
 
index 5686f0f..33982e9 100644 (file)
@@ -73,12 +73,11 @@ public class List extends Target implements Serializable {
 
     public void accept(Message m) throws IOException, MailException {
         try {
-            m = new Message(new Stream("List-Id: " + one_line_description + "<"+address+">\r\n" +
+            m = Message.newMessage(new Stream("List-Id: " + one_line_description + "<"+address+">\r\n" +
                                        m.toString() +
                                        "--\r\n" +
                                        message_footer + "\r\n" +
-                                       "to unsubscribe, go to " + homepage + "\r\n"),
-                            null);
+                                       "to unsubscribe, go to " + homepage + "\r\n"));
         } catch (Exception e2) {
             Log.error("[list]", e2);
             throw new IOException(e2.toString());
@@ -92,7 +91,7 @@ public class List extends Target implements Serializable {
                 String s = subscribers[i];
                 try {
                     Log.warn(List.class, "  trying " + s);
-                    SMTP.Outgoing.accept(new Message(new Stream(m.toString()), new Message.Envelope(address, Address.parse(s), new Date())));
+                    SMTP.Outgoing.accept(Message.newMessage(new Stream(m.toString()), address, Address.parse(s)));
                     Log.warn("[list]", "successfully sent to " + s);
                 } catch (Exception e2) {
                     Log.error("[list]", e2);
index e97ef9e..62d1d6a 100644 (file)
@@ -221,7 +221,7 @@ public class GMail extends Account {
             "</form>\r\n"+
             "</body></html>\r\n";
         try {
-            captchaMessage = new Message(new Stream(str), null);
+            captchaMessage = Message.newMessage(new Stream(str));
         } catch (Message.Malformed e) {
             Log.warn(this, e);
             throw new IOException(e.toString());
@@ -285,7 +285,7 @@ public class GMail extends Account {
             Stream thestream =
                 new Stream(new HTTP(gmail+"?search=query&start=0&view=om&th=" + URLEncoder.encode(id)).GET(null, jar));
             thestream.readln();
-            return message = new Message(thestream, null);
+            return message = Message.newMessage(thestream);
         }
         
         public Summary(JSArray m) {
index 368a1b2..935ac05 100644 (file)
@@ -160,7 +160,7 @@ public class IMAP {
         public void delete(Mailbox m) { if (!m.equals(inbox)) m.destroy(false); else throw new Bad("can't delete inbox"); }
         public void create(String m) { mailbox(m, true, false); }
         public void append(String m,int f,Date a,String b) { try {
-            mailbox(m,false).add(new Message(new Stream(b), new Message.Envelope(null,null,a)),f|Mailbox.Flag.RECENT);
+            mailbox(m,false).add(Message.newMessage(new Stream(b)),f|Mailbox.Flag.RECENT);
         } catch (Message.Malformed e) { throw new No(e.getMessage()); } }
         public void check() { }
         public void noop() { }
index e0e02d5..82d2d92 100644 (file)
@@ -18,7 +18,7 @@ public class Mbox {
         for(String s = stream.readln(); ; s = stream.readln()) {
             if (s == null || s.startsWith("From ")) {
                 try {
-                    if (buf != null) vec.addElement(new Message(new Stream(buf.toString()), null));
+                    if (buf != null) vec.addElement(Message.newMessage(new Stream(buf.toString())));
                 } catch (Exception e) { Log.warn(Mbox.class, e); }
                 if (s == null) break;
                 buf = new StringBuffer();
index a13259a..6b03810 100644 (file)
@@ -105,7 +105,7 @@ public class FileBasedMailbox extends Mailbox.Default {
                 FileInputStream fis = null;
                 try {
                     fis = new FileInputStream(cache.dir.getParent() + slash + name);
-                    return new Message(new Stream(fis), new Message.Envelope(null, null, new Date()));
+                    return Message.newMessage(new Stream(fis));
                 } finally { if (fis != null) fis.close(); }
             } catch (IOException e) { throw new MailException.IOException(e);
             } catch (Message.Malformed e) { throw new MailException(e.getMessage()); }
index 1b0b4e1..b5e0a38 100644 (file)
@@ -23,7 +23,7 @@ public class MailmanArchives extends Mailbox.Default {
                 if (s == null || s.startsWith("From ")) {
                     if (acc != null) {
                         Log.warn("[msg]", acc.toString());
-                        all.addElement(new Message(new Stream(acc.toString()), null));
+                        all.addElement(Message.newMessage(new Stream(acc.toString())));
                     }
                     if (s == null) break;
                     acc = new StringBuffer();
index 1f822a7..67eb64b 100644 (file)
@@ -142,10 +142,7 @@ public class Script extends Target {
                         if ("from".equalsIgnoreCase(key)) from = Address.parse(val);
                         if ("to".equalsIgnoreCase(key)) to = Address.parse(val);
                     }
-                    Message message = new Message(new org.ibex.io.Stream(headers.toString() + "\r\n" + body),
-                                                  new Message.Envelope(from,
-                                                                       to,
-                                                                       new Date()));
+                    Message message = Message.newMessage(new org.ibex.io.Stream(headers.toString() + "\r\n" + body), from, to);
                     //org.ibex.mail.protocol.SMTP.Outgoing.accept(message);
                     boolean ok = org.ibex.mail.protocol.SMTP.Outgoing.attempt(message);
                     if (!ok) throw new JSExn("SMTP server rejected message");
@@ -154,10 +151,9 @@ public class Script extends Target {
                 if (name.equals("mail.forward")) { return new Target() {
                         public void accept(Message m) throws MailException {
                             try {
-                                Message m2 = new Message(new org.ibex.io.Stream(m.toString()),
-                                                         new Message.Envelope(m.envelope.from,
-                                                                              new Address(a.toString()),
-                                                                              new Date()));
+                                Message m2 = Message.newMessage(new org.ibex.io.Stream(m.toString()),
+                                                         m.envelopeFrom,
+                                                         new Address(a.toString()));
                                 org.ibex.mail.protocol.SMTP.Outgoing.accept(m2);
                             } catch (Exception e) {
                                 throw new MailException(e.toString());