X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Forg%2Fibex%2Fmail%2FFileBasedMailbox.java;h=2a614d7bab19c9c536b56622f3b7abd8f4821f0b;hb=71904e0d41c8cd254c347ac47d9c2591b671bc38;hp=062168998e634986a14556a9055588d33fb18501;hpb=73c4f25fcc07bcee4e3dde4539a9776094fe5187;p=org.ibex.mail.git diff --git a/src/org/ibex/mail/FileBasedMailbox.java b/src/org/ibex/mail/FileBasedMailbox.java index 0621689..2a614d7 100644 --- a/src/org/ibex/mail/FileBasedMailbox.java +++ b/src/org/ibex/mail/FileBasedMailbox.java @@ -123,7 +123,10 @@ public class FileBasedMailbox extends Mailbox.Default { } public int uidValidity() { return uidValidity; } - public int uidNext() { return uidNext; } + + // UGLY: Apple Mail doesn't like UID=0, so we add one + public int uidNext() { return uidNext+1; } + public synchronized void insert(Message message, int flags) { try { String name, fullname; File target, f; @@ -141,11 +144,14 @@ public class FileBasedMailbox extends Mailbox.Default { f.renameTo(new File(fullname)); uidNext++; f = new File(fullname); - if ((flags & Mailbox.Flag.SEEN) == Mailbox.Flag.SEEN) f.setLastModified(MAGIC_DATE); + if ((flags & Mailbox.Flag.SEEN) == 0) f.setLastModified(MAGIC_DATE); + else if (f.lastModified()==MAGIC_DATE) f.setLastModified(System.currentTimeMillis()); } catch (IOException e) { throw new MailException.IOException(e); } Log.info(this, path + " <= " + message.summary()); } + + private static FilenameFilter filter = new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith("."); @@ -157,13 +163,23 @@ public class FileBasedMailbox extends Mailbox.Default { private File file() { return new File(path.getAbsolutePath() + slash + files[cur]); } public boolean done() { return cur >= files.length; } public boolean next() { cur++; return !done(); } - public boolean seen() { return false; } public boolean recent() { return false; } public int nntpNumber() { return cur+1; } // FIXME: lame public int imapNumber() { return cur+1; } // EUDORA insists that message numbers start at 1, not 0 - public int uid() { return done() ? -1 : Integer.parseInt(files[cur].substring(0, files[cur].length()-1)); } + + // UGLY: Apple Mail doesn't like UID=0, so we add one + public int uid() { return done() ? -1 : 1+Integer.parseInt(files[cur].substring(0, files[cur].length()-1)); } + public void delete() { File f = file(); if (f != null && f.exists()) f.delete(); } - public void seen(boolean seen) { } + public int getFlags() { + return file().lastModified()==MAGIC_DATE ? 0 : Flag.SEEN; + } + public void setFlags(int flags) { + File f = file(); + if ((flags & Mailbox.Flag.SEEN) == 0) f.setLastModified(MAGIC_DATE); + else if (f.lastModified()==MAGIC_DATE) f.setLastModified(System.currentTimeMillis()); + // FIXME + } public Headers head() { if (done()) return null; FileInputStream fis = null;