default implementation of recent()
[org.ibex.mail.git] / src / org / ibex / mail / target / FileBasedMailbox.java
index 6b03810..8d44198 100644 (file)
@@ -1,3 +1,7 @@
+// Copyright 2000-2005 the Contributors, as shown in the revision logs.
+// Licensed under the Apache Public Source License 2.0 ("the License").
+// You may not use this file except in compliance with the License.
+
 package org.ibex.mail.target;
 import org.prevayler.*;
 import org.ibex.mail.*;
@@ -55,6 +59,7 @@ public class FileBasedMailbox extends Mailbox.Default {
 
         public void init(final Prevayler prevayler) throws IOException {
             dir.mkdirs();
+            long time = System.currentTimeMillis();
             Log.info(this, "initializing maildir " + dir.getParent());
 
             // Drop entries whose files have vanished
@@ -77,7 +82,8 @@ public class FileBasedMailbox extends Mailbox.Default {
             }
 
             // Take a snapshot for posterity
-            Log.info(this, "  done initializing maildir " + dir.getParent());
+            if (System.currentTimeMillis() - time > 1000 * 5)
+                Log.info(this, "  done initializing maildir " + dir.getParent());
             new Thread() { public void run() {
                 try { prevayler.takeSnapshot(); } catch (Exception e) { Log.error(this, e); } } }.start();
         }
@@ -115,7 +121,6 @@ public class FileBasedMailbox extends Mailbox.Default {
 
             public static Transaction create(File f) throws IOException {
                 final boolean seen = f.lastModified() == MAGIC_DATE;
-                Log.error(Entry.class, "create with seen = " + seen);
                 final String name = f.getName();
                 final byte[] header = new MIME.Headers(new Stream(new FileInputStream(f)), true).toString().getBytes();
                 return new Transaction() {
@@ -203,7 +208,6 @@ public class FileBasedMailbox extends Mailbox.Default {
 
     public int uidNext() { return cache.uidNext(); }
     public synchronized void add(Message message, int flags) {
-        Log.info(path, message.summary());
         try {
             String name, fullname; File target, f;
             for(int i = cache.uidNext(); ; i++) {
@@ -216,10 +220,6 @@ public class FileBasedMailbox extends Mailbox.Default {
             }
             FileOutputStream fo = new FileOutputStream(f);
             Stream stream = new Stream(fo);
-            if (message.envelope != null) {
-                stream.println("X-org.ibex.mail.headers.envelope.From: " + message.envelope.from);
-                stream.println("X-org.ibex.mail.headers.envelope.To: " + message.envelope.to);
-            }
             message.dump(stream);
             fo.close();
             f.renameTo(new File(fullname));
@@ -227,6 +227,7 @@ public class FileBasedMailbox extends Mailbox.Default {
             if ((flags & Mailbox.Flag.SEEN) == Mailbox.Flag.SEEN) f.setLastModified(MAGIC_DATE);
             prevayler.execute(Cache.Entry.create(f));
         } catch (IOException e) { throw new MailException.IOException(e); }
+        Log.info(this, path + " <= " + message.summary());
     }
 
     private class Iterator extends Mailbox.Default.Iterator {
@@ -237,6 +238,7 @@ public class FileBasedMailbox extends Mailbox.Default {
         public boolean done() { return cur >= cache.size(); }
         public boolean next() { cur++; return !done(); }
         public boolean seen() { return done() ? false : entry().seen(); }
+        public boolean recent() { return false; }
         public int num() { return cur+1; }  // EUDORA insists that message numbers start at 1, not 0
         public int uid() { return done() ? -1 : entry().uid; }
         public void delete() { prevayler.execute(entry().delete(file())); }