From 73c4f25fcc07bcee4e3dde4539a9776094fe5187 Mon Sep 17 00:00:00 2001 From: adam Date: Wed, 28 Feb 2007 14:09:16 +0000 Subject: [PATCH] reshuffling of file locations to make package structure flatter darcs-hash:20070228140916-5007d-6f97f8a4acdabc918d7fc470a3e4d21cf1998a1c.gz --- .../ibex/mail/{target => }/FileBasedMailbox.java | 2 +- src/org/ibex/mail/{protocol => }/GMail.java | 3 +- src/org/ibex/mail/{protocol => }/IMAP.java | 42 +++--- src/org/ibex/mail/{target => }/Mailbox.java | 14 +- .../ibex/mail/{target => }/MailmanArchives.java | 4 +- .../mail/{target => }/MessageArrayMailbox.java | 3 +- src/org/ibex/mail/{protocol => }/NNTP.java | 7 +- src/org/ibex/mail/{protocol => }/POP3.java | 3 +- src/org/ibex/mail/Query.java | 12 +- src/org/ibex/mail/{protocol => }/SMTP.java | 15 +- src/org/ibex/mail/{target => }/Script.java | 151 ++++++++++++++------ .../ibex/mail/{target => }/SqliteJdbcMailbox.java | 39 +++-- src/org/ibex/mail/filter/Anonymizer.java | 9 -- src/org/ibex/mail/filter/DCC.java | 9 -- src/org/ibex/mail/filter/HTML2Text.java | 9 -- src/org/ibex/mail/filter/PGP.java | 9 -- src/org/ibex/mail/filter/ReturnReciept.java | 9 -- src/org/ibex/mail/filter/RewriteFilter.java | 9 -- src/org/ibex/mail/filter/SingleUse.java | 9 -- src/org/ibex/mail/filter/SpamAssassin.java | 9 -- src/org/ibex/mail/filter/SpamFilter.java | 9 -- src/org/ibex/mail/filter/VipulsRazor.java | 9 -- src/org/ibex/mail/protocol/Fax.java | 8 -- src/org/ibex/mail/protocol/Incoming.java | 15 -- src/org/ibex/mail/protocol/Mbox.java | 36 ----- src/org/ibex/mail/protocol/RSS.java | 8 -- src/org/ibex/mail/protocol/SMS.java | 8 -- src/org/ibex/mail/protocol/VERP.java | 8 -- src/org/ibex/mail/protocol/WebMail.java | 8 -- src/org/ibex/mail/target/Bounce.java | 9 -- src/org/ibex/mail/target/Darcs.java | 9 -- src/org/ibex/mail/target/Drop.java | 20 --- src/org/ibex/mail/target/LMTP.java | 9 -- src/org/ibex/mail/target/Later.java | 19 --- src/org/ibex/mail/target/List.java | 9 -- src/org/ibex/mail/target/MBX.java | 9 -- src/org/ibex/mail/target/Pipe.java | 9 -- src/org/ibex/mail/target/Procmail.java | 9 -- src/org/ibex/mail/target/Reject.java | 23 --- src/org/ibex/mail/target/Transcript.java | 48 ------- src/org/ibex/mail/target/Vacation.java | 9 -- src/org/ibex/mail/target/XMLRPC.java | 9 -- 42 files changed, 183 insertions(+), 484 deletions(-) rename src/org/ibex/mail/{target => }/FileBasedMailbox.java (99%) rename src/org/ibex/mail/{protocol => }/GMail.java (99%) rename src/org/ibex/mail/{protocol => }/IMAP.java (97%) rename src/org/ibex/mail/{target => }/Mailbox.java (94%) rename src/org/ibex/mail/{target => }/MailmanArchives.java (98%) rename src/org/ibex/mail/{target => }/MessageArrayMailbox.java (95%) rename src/org/ibex/mail/{protocol => }/NNTP.java (99%) rename src/org/ibex/mail/{protocol => }/POP3.java (97%) rename src/org/ibex/mail/{protocol => }/SMTP.java (97%) rename src/org/ibex/mail/{target => }/Script.java (73%) rename src/org/ibex/mail/{target => }/SqliteJdbcMailbox.java (65%) delete mode 100644 src/org/ibex/mail/filter/Anonymizer.java delete mode 100644 src/org/ibex/mail/filter/DCC.java delete mode 100644 src/org/ibex/mail/filter/HTML2Text.java delete mode 100644 src/org/ibex/mail/filter/PGP.java delete mode 100644 src/org/ibex/mail/filter/ReturnReciept.java delete mode 100644 src/org/ibex/mail/filter/RewriteFilter.java delete mode 100644 src/org/ibex/mail/filter/SingleUse.java delete mode 100644 src/org/ibex/mail/filter/SpamAssassin.java delete mode 100644 src/org/ibex/mail/filter/SpamFilter.java delete mode 100644 src/org/ibex/mail/filter/VipulsRazor.java delete mode 100644 src/org/ibex/mail/protocol/Fax.java delete mode 100644 src/org/ibex/mail/protocol/Incoming.java delete mode 100644 src/org/ibex/mail/protocol/Mbox.java delete mode 100644 src/org/ibex/mail/protocol/RSS.java delete mode 100644 src/org/ibex/mail/protocol/SMS.java delete mode 100644 src/org/ibex/mail/protocol/VERP.java delete mode 100644 src/org/ibex/mail/protocol/WebMail.java delete mode 100644 src/org/ibex/mail/target/Bounce.java delete mode 100644 src/org/ibex/mail/target/Darcs.java delete mode 100644 src/org/ibex/mail/target/Drop.java delete mode 100644 src/org/ibex/mail/target/LMTP.java delete mode 100644 src/org/ibex/mail/target/Later.java delete mode 100644 src/org/ibex/mail/target/List.java delete mode 100644 src/org/ibex/mail/target/MBX.java delete mode 100644 src/org/ibex/mail/target/Pipe.java delete mode 100644 src/org/ibex/mail/target/Procmail.java delete mode 100644 src/org/ibex/mail/target/Reject.java delete mode 100644 src/org/ibex/mail/target/Transcript.java delete mode 100644 src/org/ibex/mail/target/Vacation.java delete mode 100644 src/org/ibex/mail/target/XMLRPC.java diff --git a/src/org/ibex/mail/target/FileBasedMailbox.java b/src/org/ibex/mail/FileBasedMailbox.java similarity index 99% rename from src/org/ibex/mail/target/FileBasedMailbox.java rename to src/org/ibex/mail/FileBasedMailbox.java index 7af0194..0621689 100644 --- a/src/org/ibex/mail/target/FileBasedMailbox.java +++ b/src/org/ibex/mail/FileBasedMailbox.java @@ -2,7 +2,7 @@ // 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; +package org.ibex.mail; import org.prevayler.*; import org.ibex.mail.*; import org.ibex.util.*; diff --git a/src/org/ibex/mail/protocol/GMail.java b/src/org/ibex/mail/GMail.java similarity index 99% rename from src/org/ibex/mail/protocol/GMail.java rename to src/org/ibex/mail/GMail.java index 1a5d4ef..3bdc7af 100644 --- a/src/org/ibex/mail/protocol/GMail.java +++ b/src/org/ibex/mail/GMail.java @@ -2,11 +2,10 @@ // 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.protocol; +package org.ibex.mail; import org.ibex.crypto.*; import org.ibex.mail.protocol.*; import org.ibex.jinetd.Listener; -import org.ibex.mail.*; import org.ibex.util.*; import org.ibex.net.*; import org.ibex.js.*; diff --git a/src/org/ibex/mail/protocol/IMAP.java b/src/org/ibex/mail/IMAP.java similarity index 97% rename from src/org/ibex/mail/protocol/IMAP.java rename to src/org/ibex/mail/IMAP.java index 848feb2..0632ea4 100644 --- a/src/org/ibex/mail/protocol/IMAP.java +++ b/src/org/ibex/mail/IMAP.java @@ -2,7 +2,7 @@ // 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.protocol; +package org.ibex.mail; import org.ibex.io.*; import org.ibex.crypto.*; import org.ibex.jinetd.Listener; @@ -208,7 +208,7 @@ public class IMAP { Vec.Int vec = new Vec.Int(); for(Mailbox.Iterator it = selected().iterator(q); it.next();) { vec.addElement(uid ? it.uid() : it.imapNumber()); - it.setFlag(Mailbox.Flag.RECENT, false); + it.setFlags(it.getFlags() & ~Mailbox.Flag.RECENT); } return vec.dump(); } @@ -218,14 +218,14 @@ public class IMAP { public void removeFlags(Query q, int f, boolean uid, boolean silent) { doFlags(q, f, uid, -1, silent); } private void doFlags(Query q, int flags, boolean uid, int style, boolean silent) { for(Mailbox.Iterator it = selected().iterator(q);it.next();) { - boolean recent = it.getFlag(Mailbox.Flag.RECENT); + // FIXME: what's going on here with the recent flag? + //boolean recent = it.getFlag(Mailbox.Flag.RECENT); try { throw new Exception("flags " + flags); } catch (Exception e) { Log.error(this, e); } - for(int flag : Mailbox.Flag.all) - if (style == -1) { if ((flags & flag)!=0) it.setFlag(flag, false); } - else if (style == 0) { it.setFlag(flag, ((flags & flag)!=0)); } - else if (style == 1) { if ((flags & flag)!=0) it.setFlag(flag, true); } - it.setFlag(Mailbox.Flag.RECENT, recent); - if (!silent) client.fetch(it.imapNumber(), flags(it), -1, null, it.uid()); + if (style == -1) it.setFlags(it.getFlags() & ~flags); + else if (style == 0) it.setFlags(flags); + else if (style == 1) it.setFlags(it.getFlags() | flags); + //it.setFlag(Mailbox.Flag.RECENT, recent); + if (!silent) client.fetch(it.imapNumber(), it.getFlags(), -1, null, it.uid()); } } @@ -240,20 +240,12 @@ public class IMAP { Message message = ((spec & (BODYSTRUCTURE | ENVELOPE | INTERNALDATE | FIELDS | FIELDSNOT | RFC822 | RFC822TEXT | RFC822SIZE | HEADERNOT | HEADER)) != 0) ? it.cur() : null; int size = message == null ? 0 : message.getLength(); - client.fetch(it.imapNumber(), flags(it), size, message, it.uid()); - it.setFlag(Mailbox.Flag.RECENT, false); + client.fetch(it.imapNumber(), it.getFlags(), size, message, it.uid()); + it.setFlags(it.getFlags() & ~Mailbox.Flag.RECENT); } } } - private static int flags(Mailbox.Iterator it) { - int ret = 0; - for(int flag : Mailbox.Flag.all) - if (it.getFlag(flag)) - ret |= flag; - return ret; - } - // Single Session Handler ////////////////////////////////////////////////////////////////////////////// /** takes an IMAP.Server and exposes it to the world as an IMAP server on a TCP socket */ @@ -790,12 +782,12 @@ public class IMAP { } static String flags(Mailbox.Iterator it) { return - (it.getFlag(Mailbox.Flag.DELETED) ? "\\Deleted " : "") + - (it.getFlag(Mailbox.Flag.SEEN) ? "\\Seen " : "") + - (it.getFlag(Mailbox.Flag.FLAGGED) ? "\\Flagged " : "") + - (it.getFlag(Mailbox.Flag.DRAFT) ? "\\Draft " : "") + - (it.getFlag(Mailbox.Flag.ANSWERED) ? "\\Answered " : "") + - (it.getFlag(Mailbox.Flag.RECENT) ? "\\Recent " : ""); + ((it.getFlags() & Mailbox.Flag.DELETED)!=0 ? "\\Deleted " : "") + + ((it.getFlags() & Mailbox.Flag.SEEN)!=0 ? "\\Seen " : "") + + ((it.getFlags() & Mailbox.Flag.FLAGGED)!=0 ? "\\Flagged " : "") + + ((it.getFlags() & Mailbox.Flag.DRAFT)!=0 ? "\\Draft " : "") + + ((it.getFlags() & Mailbox.Flag.ANSWERED)!=0 ? "\\Answered " : "") + + ((it.getFlags() & Mailbox.Flag.RECENT)!=0 ? "\\Recent " : ""); } static String flags(int flags) { String ret = "(" + diff --git a/src/org/ibex/mail/target/Mailbox.java b/src/org/ibex/mail/Mailbox.java similarity index 94% rename from src/org/ibex/mail/target/Mailbox.java rename to src/org/ibex/mail/Mailbox.java index 8ad3c14..6905692 100644 --- a/src/org/ibex/mail/target/Mailbox.java +++ b/src/org/ibex/mail/Mailbox.java @@ -2,7 +2,7 @@ // 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; +package org.ibex.mail; import org.ibex.mail.*; import org.ibex.util.*; import org.ibex.mail.*; @@ -30,6 +30,7 @@ public abstract class Mailbox extends JS.Obj implements Target { public abstract Mailbox.Iterator iterator(Query q); public abstract void insert(Message message, int flags); + public abstract void post(Message message); public abstract void move(Query q, Mailbox dest); public abstract void copy(Query q, Mailbox dest); public abstract int count(Query q); @@ -60,14 +61,14 @@ public abstract class Mailbox extends JS.Obj implements Target { public void destroy(boolean recursive) { throw new MailException("not supported"); } public Mailbox slash(String name, boolean create) { return null; } public String[] children() { return new String[] { }; } + public void post(Message message) { insert(message, Flag.RECENT); } public void move(Query q, Mailbox dest) { for(Mailbox.Iterator it = iterator(q);it.next();) { dest.insert(it.cur(), it.getFlags()); it.delete(); } } public static abstract class Iterator implements Mailbox.Iterator { public int nntpNumber() { throw new MailException("not supported"); } public int getFlags() { return 0; } - public boolean getFlag(int flag) { return false; } - public void setFlag(int flag, boolean set) { throw new RuntimeException("not implemented"); } + public void setFlags(int flags) { throw new MailException("not supported"); } } } @@ -101,8 +102,7 @@ public abstract class Mailbox extends JS.Obj implements Target { public abstract int nntpNumber(); public abstract int getFlags(); - public abstract boolean getFlag(int flag); - public abstract void setFlag(int flag, boolean set); + public abstract void setFlags(int flags); public static class Wrapper implements Iterator { private Iterator it; @@ -115,8 +115,7 @@ public abstract class Mailbox extends JS.Obj implements Target { public int imapNumber() { return it.imapNumber(); } public void delete() { it.delete(); } public int getFlags() { return it.getFlags(); } - public boolean getFlag(int flag) { return it.getFlag(flag); } - public void setFlag(int flag, boolean set) { it.setFlag(flag, set); } + public void setFlags(int flags) { it.setFlags(flags); } } class QueryIterator extends Mailbox.Iterator.Wrapper { @@ -159,6 +158,7 @@ public abstract class Mailbox extends JS.Obj implements Target { public boolean phantom() { return m.phantom(); } public Mailbox.Iterator iterator(Query q) { return m.iterator(q); } public void insert(Message message, int flags) { m.insert(message, flags); } + public void post(Message message) { m.insert(message, Flag.RECENT); } public void move(Query q, Mailbox dest) { m.move(q, dest); } public void copy(Query q, Mailbox dest) { m.copy(q, dest); } public int count(Query q) { return m.count(q); } diff --git a/src/org/ibex/mail/target/MailmanArchives.java b/src/org/ibex/mail/MailmanArchives.java similarity index 98% rename from src/org/ibex/mail/target/MailmanArchives.java rename to src/org/ibex/mail/MailmanArchives.java index 65c874c..0426967 100644 --- a/src/org/ibex/mail/target/MailmanArchives.java +++ b/src/org/ibex/mail/MailmanArchives.java @@ -1,8 +1,8 @@ // 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. +// You may not use this file except in compliance with the License -package org.ibex.mail.target; +package org.ibex.mail; import org.ibex.io.*; import org.ibex.mail.*; import org.ibex.util.*; diff --git a/src/org/ibex/mail/target/MessageArrayMailbox.java b/src/org/ibex/mail/MessageArrayMailbox.java similarity index 95% rename from src/org/ibex/mail/target/MessageArrayMailbox.java rename to src/org/ibex/mail/MessageArrayMailbox.java index 350f54b..3ac15cb 100644 --- a/src/org/ibex/mail/target/MessageArrayMailbox.java +++ b/src/org/ibex/mail/MessageArrayMailbox.java @@ -2,8 +2,7 @@ // 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.ibex.mail.*; +package org.ibex.mail; import org.ibex.util.*; import org.ibex.mail.*; import java.io.*; diff --git a/src/org/ibex/mail/protocol/NNTP.java b/src/org/ibex/mail/NNTP.java similarity index 99% rename from src/org/ibex/mail/protocol/NNTP.java rename to src/org/ibex/mail/NNTP.java index 284cf04..a0d8dd6 100644 --- a/src/org/ibex/mail/protocol/NNTP.java +++ b/src/org/ibex/mail/NNTP.java @@ -7,11 +7,12 @@ // 503 optional subfeature not supported // Xref header // LIST EXTENSIONS is probably incomplete +// pull mode (ie suck) +// control message processing? -package org.ibex.mail.protocol; +package org.ibex.mail; import org.ibex.util.*; import org.ibex.io.*; -import org.ibex.mail.*; import org.ibex.mail.target.*; import org.ibex.jinetd.*; import java.io.*; @@ -64,7 +65,7 @@ public class NNTP { public MailboxWrapper(Mailbox root) { this(root, false); } public MailboxWrapper(Mailbox root, boolean post) { this.root = root; this.post = post; } public boolean postok() { return post; } - public void post(Message m) throws IOException { current.accept(m); } + public void post(Message m) throws IOException { current.post(m); } public Group group(String s) { ptr = 0; Group g = getgroup(s); diff --git a/src/org/ibex/mail/protocol/POP3.java b/src/org/ibex/mail/POP3.java similarity index 97% rename from src/org/ibex/mail/protocol/POP3.java rename to src/org/ibex/mail/POP3.java index fd16972..2a31425 100644 --- a/src/org/ibex/mail/protocol/POP3.java +++ b/src/org/ibex/mail/POP3.java @@ -2,10 +2,9 @@ // 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.protocol; +package org.ibex.mail; import org.ibex.util.*; import org.ibex.io.*; -import org.ibex.mail.*; import org.ibex.mail.target.*; import org.ibex.jinetd.*; import java.io.*; diff --git a/src/org/ibex/mail/Query.java b/src/org/ibex/mail/Query.java index 87837f9..4fded9d 100644 --- a/src/org/ibex/mail/Query.java +++ b/src/org/ibex/mail/Query.java @@ -105,12 +105,12 @@ public class Query { (earliest == null || it.cur().arrival.after(earliest)); case HEADER: return it.cur().headers.get(key) != null && ((String)it.cur().headers.get(key)).toLowerCase().indexOf(text.toLowerCase()) != -1; - case DELETED: return it.getFlag(Mailbox.Flag.DELETED); - case SEEN: return it.getFlag(Mailbox.Flag.SEEN); - case FLAGGED: return it.getFlag(Mailbox.Flag.FLAGGED); - case DRAFT: return it.getFlag(Mailbox.Flag.DRAFT); - case ANSWERED: return it.getFlag(Mailbox.Flag.ANSWERED); - case RECENT: return it.getFlag(Mailbox.Flag.RECENT); + case DELETED: return (it.getFlags() & Mailbox.Flag.DELETED) !=0; + case SEEN: return (it.getFlags() & Mailbox.Flag.SEEN)!=0; + case FLAGGED: return (it.getFlags() & Mailbox.Flag.FLAGGED)!=0; + case DRAFT: return (it.getFlags() & Mailbox.Flag.DRAFT)!=0; + case ANSWERED: return (it.getFlags() & Mailbox.Flag.ANSWERED)!=0; + case RECENT: return (it.getFlags() & Mailbox.Flag.RECENT)!=0; // FIXME: super inefficient case BODY: throw new RuntimeException("BODY searches are not supported because they are slow"); diff --git a/src/org/ibex/mail/protocol/SMTP.java b/src/org/ibex/mail/SMTP.java similarity index 97% rename from src/org/ibex/mail/protocol/SMTP.java rename to src/org/ibex/mail/SMTP.java index 35855f1..22e1813 100644 --- a/src/org/ibex/mail/protocol/SMTP.java +++ b/src/org/ibex/mail/SMTP.java @@ -2,8 +2,7 @@ // 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.protocol; -import org.ibex.mail.*; +package org.ibex.mail; import org.ibex.mail.target.*; import org.ibex.util.*; import org.ibex.net.*; @@ -15,6 +14,10 @@ import java.text.*; import javax.naming.*; import javax.naming.directory.*; +// Note: we can't actually use status codes for feedback if we accept +// multiple destination addresses... a failure on one and success on +// the other... + // FIXME: logging: current logging sucks // FIXME: loop prevention // FIXME: probably need some throttling on outbound mail @@ -185,12 +188,12 @@ public class SMTP { conn.println("250 message accepted"); conn.flush(); from = null; to = new Vector(); - } catch (Reject.RejectException re) { + } catch (MailException.Malformed mfe) { conn.println("501 " + mfe.toString()); + } catch (MailException.MailboxFull mbf) { conn.println("452 " + mbf); + } catch (Script.Later.LaterException le) { conn.println("453 try again later"); + } catch (Script.Reject.RejectException re) { Log.warn(SMTP.class, "rejecting message due to: " + re.reason + "\n " + re.m.summary()); conn.println("501 " + re.reason); - } catch (MailException.Malformed mfe) { conn.println("501 " + mfe.toString()); - } catch (MailException.MailboxFull mbf) { conn.println("452 " + mbf); - } catch (Later.LaterException le) { conn.println("453 try again later"); } } else { conn.println("500 unrecognized command"); } } catch (Message.Malformed e) { conn.println("501 " + e.toString()); } diff --git a/src/org/ibex/mail/target/Script.java b/src/org/ibex/mail/Script.java similarity index 73% rename from src/org/ibex/mail/target/Script.java rename to src/org/ibex/mail/Script.java index 616d5ac..d3b118f 100644 --- a/src/org/ibex/mail/target/Script.java +++ b/src/org/ibex/mail/Script.java @@ -2,15 +2,15 @@ // 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; +package org.ibex.mail; import org.ibex.js.*; import org.ibex.io.*; import org.ibex.util.*; -import org.ibex.mail.*; import org.ibex.mail.filter.*; import org.ibex.mail.target.*; import java.io.*; import java.util.*; +import java.text.*; public class Script extends JS.Obj implements Target { @@ -43,8 +43,8 @@ public class Script extends JS.Obj implements Target { case "m": return m; case "ibex": return env; default: return null; - //#end - return null; + //#end + return null; } } @@ -77,16 +77,16 @@ public class Script extends JS.Obj implements Target { public class ScriptEnv extends JS.Obj { private PropertyFile prefs = null; - /* - static { - try { - // FIXME - prefs = new PropertyFile(new File("/etc/org.ibex.mail.properties")); - } catch (IOException e) { - Log.error(ScriptEnv.class, e); - } - } - */ + /* + static { + try { + // FIXME + prefs = new PropertyFile(new File("/etc/org.ibex.mail.properties")); + } catch (IOException e) { + Log.error(ScriptEnv.class, e); + } + } + */ /** lets us put multi-level get/put/call keys all in the same method */ private class Sub extends JS.Immutable { @@ -132,15 +132,15 @@ public class Script extends JS.Obj implements Target { case "mail.dir": return METHOD; case "mail.shell": return METHOD; case "mail.my.prefs": try { - return new org.ibex.js.Directory(new File("/etc/org.ibex.mail.prefs")); + return new org.ibex.js.Directory(new File("/etc/org.ibex.mail.prefs")); } catch (IOException e) { throw new JSExn(e.toString()); } - case "mail.whitelist": return JSReflection.wrap(org.ibex.mail.protocol.SMTP.whitelist); + case "mail.whitelist": return JSReflection.wrap(org.ibex.mail.SMTP.whitelist); case "mail.my.mailbox": Mailbox root = FileBasedMailbox.getFileBasedMailbox(Mailbox.STORAGE_ROOT, true); return root.slash("user", true).slash("megacz", true); case "mail.list": return METHOD; - //#end - return super.get(name); + //#end + return super.get(name); } public JS call(JS name0, JS[] args) throws JSExn { @@ -207,9 +207,9 @@ public class Script extends JS.Obj implements Target { boolean ok = false; try { if (attempt) { - org.ibex.mail.protocol.SMTP.Outgoing.attempt(message); + org.ibex.mail.SMTP.Outgoing.attempt(message); } else { - org.ibex.mail.protocol.SMTP.Outgoing.accept(message); + org.ibex.mail.SMTP.Outgoing.accept(message); } ok = true; } catch (Exception ex) { @@ -239,7 +239,7 @@ public class Script extends JS.Obj implements Target { public void accept(Message m) throws MailException { try { Message m2 = m.bounce(JSU.toString(a)); - org.ibex.mail.protocol.SMTP.Outgoing.accept(m2); + org.ibex.mail.SMTP.Outgoing.accept(m2); Log.error(this, "BOUNCING! " + m2.summary()); } catch (Exception e) { Log.warn(this, e); @@ -251,7 +251,7 @@ public class Script extends JS.Obj implements Target { Message m2 = Message.newMessage(new org.ibex.io.Fountain.StringFountain(m.toString()), m.envelopeFrom, new Address(JSU.toString(a))); - org.ibex.mail.protocol.SMTP.Outgoing.accept(m2); + org.ibex.mail.SMTP.Outgoing.accept(m2); } catch (Exception e) { Log.warn(this, e); throw new JSExn(e.toString()); @@ -260,7 +260,7 @@ public class Script extends JS.Obj implements Target { } if (name.equals("mail.forward") || name.equals("forward")) { Message m2 = Message.newMessage(Script.this.m, Script.this.m.envelopeFrom, new Address(JSU.toString(a))); - org.ibex.mail.protocol.SMTP.Outgoing.attempt(m2, false); + org.ibex.mail.SMTP.Outgoing.attempt(m2, false); return Drop.instance; } if (name.equals("mail.reject")) @@ -270,11 +270,11 @@ public class Script extends JS.Obj implements Target { if (name.equals("log.warn") || name.equals("warn")) { JSU.warn(a== null ? "**null**" : JSU.toString(a)); return null; } if (name.equals("log.error") || name.equals("error")) { JSU.error(a== null ? "**null**" : JSU.toString(a)); return null; } switch (nargs) { - case 1: - if (name.equals("regexp")) {return new JSRegexp(a, null); } - break; - case 2: - if (name.equals("regexp")) {return new JSRegexp(a, b); } + case 1: + if (name.equals("regexp")) {return new JSRegexp(a, null); } + break; + case 2: + if (name.equals("regexp")) {return new JSRegexp(a, b); } } } catch (MailException e) { throw e; } catch (Exception e) { @@ -290,10 +290,10 @@ public class Script extends JS.Obj implements Target { public JS get(JS name) throws JSExn { // FIXME!!! /* - case "isNaN": return gs.get(name); - case "isFinite": return gs.get(name); - case "NaN": return gs.get(name); - case "Infinity": return gs.get(name); + case "isNaN": return gs.get(name); + case "isFinite": return gs.get(name); + case "NaN": return gs.get(name); + case "Infinity": return gs.get(name); */ return null; } @@ -303,15 +303,15 @@ public class Script extends JS.Obj implements Target { public JS get(JS name) throws JSExn { // FIXME!!! /* - case "parseInt": return gs.get(JSU.S("parseInt")); - case "parseFloat": return gs.get(JSU.S("parseFloat")); - case "decodeURI": return gs.get(JSU.S("decodeURI")); - case "decodeURIComponent": return gs.get(JSU.S("decodeURIComponent")); - case "encodeURI": return gs.get(JSU.S("encodeURI")); - case "encodeURIComponent": return gs.get(JSU.S("encodeURIComponent")); - case "escape": return gs.get(JSU.S("escape")); - case "unescape": return gs.get(JSU.S("unescape")); - case "fromCharCode": return gs.get(JSU.S("stringFromCharCode")); + case "parseInt": return gs.get(JSU.S("parseInt")); + case "parseFloat": return gs.get(JSU.S("parseFloat")); + case "decodeURI": return gs.get(JSU.S("decodeURI")); + case "decodeURIComponent": return gs.get(JSU.S("decodeURIComponent")); + case "encodeURI": return gs.get(JSU.S("encodeURI")); + case "encodeURIComponent": return gs.get(JSU.S("encodeURIComponent")); + case "escape": return gs.get(JSU.S("escape")); + case "unescape": return gs.get(JSU.S("unescape")); + case "fromCharCode": return gs.get(JSU.S("stringFromCharCode")); */ return null; } @@ -319,4 +319,73 @@ public class Script extends JS.Obj implements Target { } private static abstract class JSTarget extends JS.Obj implements Target { } + + public static class Drop extends JS.Obj implements Target { + public static final Drop instance = new Drop(); + public final String reason; + public Drop() { this(null); } + public Drop(String reason) { this.reason = reason; } + public void accept(Message m) throws IOException, MailException { + Log.warn(this, "dropping" +(reason==null?"":(" because "+reason))+ ": " + m.summary()); + } + } + + public static class Later extends JS.Obj implements Target { + public static final Later instance = new Later(); + public static class LaterException extends RuntimeException { } + public void accept(Message m) throws IOException, MailException { + Log.warn(this, "delaying message " + m.summary()); + throw new LaterException(); + } + } + + /** a fast-write, slow-read place to stash all messages we touch -- in case of a major f*ckup */ + public static class Transcript implements Target { + + public static final Transcript transcript = new Transcript(Mailbox.STORAGE_ROOT + File.separatorChar + "transcript"); + + private String path; + public Transcript(String path) { new File(this.path = path).mkdirs(); } + private static String lastTime = null; + private static int lastCounter = 0; + + public synchronized void accept(Message message) { + try { + File today = new File(path + File.separatorChar + (new SimpleDateFormat("yy-MMM-dd").format(new Date()))); + today.mkdirs(); + + String time = new SimpleDateFormat("HH:mm:ss").format(new Date()); + synchronized (Transcript.class) { + if (lastTime != null && lastTime.equals(time)) { + time += "." + (++lastCounter); + } else { + lastTime = time; + lastCounter = 0; + } + } + + File target = new File(today.getPath() + File.separatorChar + time + ".txt"); + OutputStream os = new FileOutputStream(target); + try { + message.getStream().transcribe(new Stream(os)); + os.flush(); + } finally { os.close(); } + } catch (IOException e) { throw new MailException.IOException(e); } + } + } + + public static class Reject extends JS.Obj implements Target { + public final String reason; + public Reject(String reason) { this.reason = reason; } + public void accept(Message m) throws IOException, MailException { + throw new RejectException(m, reason); + } + public static class RejectException extends RuntimeException { + public final Message m; + public final String reason; + public RejectException(Message m, String reason) { this.m = m; this.reason = reason; } + } + } + + } diff --git a/src/org/ibex/mail/target/SqliteJdbcMailbox.java b/src/org/ibex/mail/SqliteJdbcMailbox.java similarity index 65% rename from src/org/ibex/mail/target/SqliteJdbcMailbox.java rename to src/org/ibex/mail/SqliteJdbcMailbox.java index a0afc8f..af8ee5c 100644 --- a/src/org/ibex/mail/target/SqliteJdbcMailbox.java +++ b/src/org/ibex/mail/SqliteJdbcMailbox.java @@ -1,6 +1,5 @@ -package org.ibex.mail.target; +package org.ibex.mail; -import org.ibex.mail.*; import org.ibex.io.Fountain; import org.ibex.io.Stream; import java.sql.Timestamp; @@ -9,26 +8,32 @@ import java.net.*; import java.io.*; import java.util.*; +// nntpNumber (column) +// uid (column) +// uidvalidity public class SqliteJdbcMailbox extends Mailbox.Default { private Connection conn; + private static final String columns = "messageid_,from_,to_,date_,subject_,headers_,body_,flags_"; public SqliteJdbcMailbox(String filename) { try { Class.forName("org.sqlite.JDBC"); conn = DriverManager.getConnection("jdbc:sqlite:"+filename); - conn.prepareStatement("create table if not exists "+ - "'mail' (messageid_,from_,to_,date_,subject_,headers_,body_,PRIMARY KEY(messageid_))").executeUpdate(); + conn.prepareStatement("create virtual table if not exists "+ + "'mail' using FTS1("+columns+",PRIMARY KEY(messageid_))").executeUpdate(); } catch (SQLException e) { throw new RuntimeException(e); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } - public Mailbox.Iterator iterator() { return new SqliteJdbcIterator(); } + public int uidNext() { throw new RuntimeException("not supported"); } + public Mailbox.Iterator iterator() { return new SqliteJdbcIterator(); } public void insert(Message m, int flags) { // FIXME: flags try { - PreparedStatement add = conn.prepareStatement("insert into 'mail' values (?,?,?,?,?,?,?)"); + PreparedStatement add = + conn.prepareStatement("insert into 'mail' ("+columns+") values (?,?,?,?,?,?,?,?)"); add.setString(1, m.messageid+""); add.setString(2, m.from+""); add.setString(3, m.to+""); @@ -36,15 +41,17 @@ public class SqliteJdbcMailbox extends Mailbox.Default { add.setString(5, m.subject+""); add.setString(6, streamToString(m.headers.getStream())); add.setString(7, streamToString(m.getBody().getStream())); + add.setInt (8, flags); add.executeUpdate(); } catch (Exception e) { throw new RuntimeException(e); } } - public int uidNext() { throw new RuntimeException("not supported"); } private class SqliteJdbcIterator extends Mailbox.Default.Iterator { + // could be more efficient in a ton of ways private ResultSet rs; - private int count=1; - private Message m = null; + private int count = 1; + private int flags; + private Message m = null; public SqliteJdbcIterator() { try { PreparedStatement query = conn.prepareStatement("select messageid_ from 'mail'"); @@ -56,19 +63,21 @@ public class SqliteJdbcMailbox extends Mailbox.Default { try { if (m!=null) return m; rs.next(); - PreparedStatement query = conn.prepareStatement("select headers_,body_ from 'mail' where messageid_=?"); + PreparedStatement query = conn.prepareStatement("select headers_,body_,flags_ from 'mail' where messageid_=?"); query.setString(1, rs.getString(1)); ResultSet rs2 = query.executeQuery(); if (!rs.next()) return null; m = Message.newMessage(new Fountain.StringFountain(rs.getString(1) + "\r\n\r\n" + rs.getString(2))); + flags = rs.getInt(3); return m; } catch (Exception e) { throw new RuntimeException(e); } } - public Headers head() { return cur().headers; } - public boolean next() { try { m = null; count++; return rs.next(); } catch (Exception e) { throw new RuntimeException(e); } } - public int uid() { throw new RuntimeException("not supported"); } - public int nntpNumber() { throw new RuntimeException("not supported"); } + public int getFlags() { if (m==null) /* could be more efficient */ cur(); return flags; } + public Headers head() { return cur().headers; } + public boolean next() { try { m = null; count++; return rs.next(); } catch (Exception e) { throw new RuntimeException(e); } } + public int uid() { throw new RuntimeException("not supported"); } public int imapNumber() { return count; } + public int nntpNumber() { throw new RuntimeException("not supported"); } public void delete() { throw new RuntimeException("not supported"); } } @@ -79,4 +88,4 @@ public class SqliteJdbcMailbox extends Mailbox.Default { return b.toString(); } -} \ No newline at end of file +} diff --git a/src/org/ibex/mail/filter/Anonymizer.java b/src/org/ibex/mail/filter/Anonymizer.java deleted file mode 100644 index 170bea7..0000000 --- a/src/org/ibex/mail/filter/Anonymizer.java +++ /dev/null @@ -1,9 +0,0 @@ -// 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.filter; -import org.ibex.mail.*; -/** anonymizes mail messages */ -public class Anonymizer extends Filter { -} diff --git a/src/org/ibex/mail/filter/DCC.java b/src/org/ibex/mail/filter/DCC.java deleted file mode 100644 index 5095e3d..0000000 --- a/src/org/ibex/mail/filter/DCC.java +++ /dev/null @@ -1,9 +0,0 @@ -// 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.filter; -import org.ibex.mail.*; -/** implements the Distributed Checksum Clearinghouse spam filtering protocol */ -public class DCC extends SpamFilter { -} diff --git a/src/org/ibex/mail/filter/HTML2Text.java b/src/org/ibex/mail/filter/HTML2Text.java deleted file mode 100644 index 8ea4f33..0000000 --- a/src/org/ibex/mail/filter/HTML2Text.java +++ /dev/null @@ -1,9 +0,0 @@ -// 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.filter; -import org.ibex.mail.*; -/** converts text/html parts into nice ASCII text for mutt/gnus/pine/etc */ -public class HTML2Text extends Filter { -} diff --git a/src/org/ibex/mail/filter/PGP.java b/src/org/ibex/mail/filter/PGP.java deleted file mode 100644 index 3bb302a..0000000 --- a/src/org/ibex/mail/filter/PGP.java +++ /dev/null @@ -1,9 +0,0 @@ -// 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.filter; -import org.ibex.mail.*; -/** checks PGP signatures on incoming mail */ -public class PGP extends Filter { -} diff --git a/src/org/ibex/mail/filter/ReturnReciept.java b/src/org/ibex/mail/filter/ReturnReciept.java deleted file mode 100644 index 0d043fd..0000000 --- a/src/org/ibex/mail/filter/ReturnReciept.java +++ /dev/null @@ -1,9 +0,0 @@ -// 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.filter; -import org.ibex.mail.*; -/** sticks a 1x1 gif in outbound messages so we can tell when the message is read */ -public class ReturnReciept extends Filter { -} diff --git a/src/org/ibex/mail/filter/RewriteFilter.java b/src/org/ibex/mail/filter/RewriteFilter.java deleted file mode 100644 index e5d3861..0000000 --- a/src/org/ibex/mail/filter/RewriteFilter.java +++ /dev/null @@ -1,9 +0,0 @@ -// 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.filter; -import org.ibex.mail.*; -/** a flexible, regexp-based email address rewriting engine */ -public class RewriteFilter extends Filter { -} diff --git a/src/org/ibex/mail/filter/SingleUse.java b/src/org/ibex/mail/filter/SingleUse.java deleted file mode 100644 index 929f7d9..0000000 --- a/src/org/ibex/mail/filter/SingleUse.java +++ /dev/null @@ -1,9 +0,0 @@ -// 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.filter; -import org.ibex.mail.*; -/** tags outgoing messages with a single-use email address */ -public class SingleUse extends Filter { -} diff --git a/src/org/ibex/mail/filter/SpamAssassin.java b/src/org/ibex/mail/filter/SpamAssassin.java deleted file mode 100644 index fba9699..0000000 --- a/src/org/ibex/mail/filter/SpamAssassin.java +++ /dev/null @@ -1,9 +0,0 @@ -// 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.filter; -import org.ibex.mail.*; -/** invokes SpamAssassin */ -public class SpamAssassin extends SpamFilter { -} diff --git a/src/org/ibex/mail/filter/SpamFilter.java b/src/org/ibex/mail/filter/SpamFilter.java deleted file mode 100644 index 22e986a..0000000 --- a/src/org/ibex/mail/filter/SpamFilter.java +++ /dev/null @@ -1,9 +0,0 @@ -// 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.filter; -import org.ibex.mail.*; -/** base class for spam filters */ -public class SpamFilter extends Filter { -} diff --git a/src/org/ibex/mail/filter/VipulsRazor.java b/src/org/ibex/mail/filter/VipulsRazor.java deleted file mode 100644 index 20de3e8..0000000 --- a/src/org/ibex/mail/filter/VipulsRazor.java +++ /dev/null @@ -1,9 +0,0 @@ -// 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.filter; -import org.ibex.mail.*; -/** invokes Vipul's Razor */ -public class VipulsRazor extends SpamFilter { -} diff --git a/src/org/ibex/mail/protocol/Fax.java b/src/org/ibex/mail/protocol/Fax.java deleted file mode 100644 index 398a5ac..0000000 --- a/src/org/ibex/mail/protocol/Fax.java +++ /dev/null @@ -1,8 +0,0 @@ -// 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.protocol; -/** Fax send/recieve/gateway */ -public class Fax { -} diff --git a/src/org/ibex/mail/protocol/Incoming.java b/src/org/ibex/mail/protocol/Incoming.java deleted file mode 100644 index d9719af..0000000 --- a/src/org/ibex/mail/protocol/Incoming.java +++ /dev/null @@ -1,15 +0,0 @@ -// 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.protocol; -import org.ibex.mail.*; -import org.ibex.mail.target.*; -import java.io.*; - -public class Incoming { - protected void accept(Message m) throws IOException, MailException { - Transcript.transcript.accept(m); // currently, we write all inbound messages to the transcript - Target.root.accept(m); - } -} diff --git a/src/org/ibex/mail/protocol/Mbox.java b/src/org/ibex/mail/protocol/Mbox.java deleted file mode 100644 index 5f1a2d0..0000000 --- a/src/org/ibex/mail/protocol/Mbox.java +++ /dev/null @@ -1,36 +0,0 @@ -// 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.protocol; -import org.ibex.io.*; -import org.ibex.crypto.*; -import org.ibex.jinetd.Listener; -import org.ibex.mail.*; -import org.ibex.util.*; -import org.ibex.mail.target.*; -import java.util.*; -import java.net.*; -import java.text.*; -import java.io.*; - -public class Mbox { - public static Message[] parse(Stream stream) { - StringBuffer buf = null; - Vec vec = new Vec(); - for(String s = stream.readln(); ; s = stream.readln()) { - if (s == null || s.startsWith("From ")) { - try { - if (buf != null) vec.addElement(Message.newMessage(new Fountain.StringFountain(buf.toString()))); - } catch (Exception e) { Log.warn(Mbox.class, e); } - if (s == null) break; - buf = new StringBuffer(); - } else if (buf != null) { - if (buf.length() == 0 && s.length() == 0) continue; // skip blank line after From - buf.append(s); - buf.append("\r\n"); - } - } - return (Message[])vec.copyInto(new Message[vec.size()]); - } -} diff --git a/src/org/ibex/mail/protocol/RSS.java b/src/org/ibex/mail/protocol/RSS.java deleted file mode 100644 index b7ec6f3..0000000 --- a/src/org/ibex/mail/protocol/RSS.java +++ /dev/null @@ -1,8 +0,0 @@ -// 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.protocol; -/** RSS send/recieve/gateway */ -public class RSS { -} diff --git a/src/org/ibex/mail/protocol/SMS.java b/src/org/ibex/mail/protocol/SMS.java deleted file mode 100644 index ad4512c..0000000 --- a/src/org/ibex/mail/protocol/SMS.java +++ /dev/null @@ -1,8 +0,0 @@ -// 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.protocol; -/** SMS send/recieve/gateway */ -public class SMS { -} diff --git a/src/org/ibex/mail/protocol/VERP.java b/src/org/ibex/mail/protocol/VERP.java deleted file mode 100644 index bd31ef6..0000000 --- a/src/org/ibex/mail/protocol/VERP.java +++ /dev/null @@ -1,8 +0,0 @@ -// 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.protocol; -public class VERP { - // http://cr.yp.to/proto/verp.txt -} diff --git a/src/org/ibex/mail/protocol/WebMail.java b/src/org/ibex/mail/protocol/WebMail.java deleted file mode 100644 index 5aed2aa..0000000 --- a/src/org/ibex/mail/protocol/WebMail.java +++ /dev/null @@ -1,8 +0,0 @@ -// 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.protocol; -/** a nice WebMail GUI */ -public class WebMail { -} diff --git a/src/org/ibex/mail/target/Bounce.java b/src/org/ibex/mail/target/Bounce.java deleted file mode 100644 index c6af7f9..0000000 --- a/src/org/ibex/mail/target/Bounce.java +++ /dev/null @@ -1,9 +0,0 @@ -// 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.ibex.mail.*; -/** bounces a message */ -public abstract class Bounce implements Target { -} diff --git a/src/org/ibex/mail/target/Darcs.java b/src/org/ibex/mail/target/Darcs.java deleted file mode 100644 index d827436..0000000 --- a/src/org/ibex/mail/target/Darcs.java +++ /dev/null @@ -1,9 +0,0 @@ -// 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.ibex.mail.*; -/** simple class to handle darcs patches */ -public abstract class Darcs extends Pipe { -} diff --git a/src/org/ibex/mail/target/Drop.java b/src/org/ibex/mail/target/Drop.java deleted file mode 100644 index f276871..0000000 --- a/src/org/ibex/mail/target/Drop.java +++ /dev/null @@ -1,20 +0,0 @@ -// 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 java.io.*; -import org.ibex.js.*; -import org.ibex.util.*; -import org.ibex.mail.*; -import org.ibex.mail.target.*; - -public class Drop extends JS.Obj implements Target { - public static final Drop instance = new Drop(); - public final String reason; - public Drop() { this(null); } - public Drop(String reason) { this.reason = reason; } - public void accept(Message m) throws IOException, MailException { - Log.warn(this, "dropping" +(reason==null?"":(" because "+reason))+ ": " + m.summary()); - } -} diff --git a/src/org/ibex/mail/target/LMTP.java b/src/org/ibex/mail/target/LMTP.java deleted file mode 100644 index fa244a5..0000000 --- a/src/org/ibex/mail/target/LMTP.java +++ /dev/null @@ -1,9 +0,0 @@ -// 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.ibex.mail.*; -/** implementation of the Local Mail Transport Protocol */ -public abstract class LMTP implements Target { -} diff --git a/src/org/ibex/mail/target/Later.java b/src/org/ibex/mail/target/Later.java deleted file mode 100644 index ee331ef..0000000 --- a/src/org/ibex/mail/target/Later.java +++ /dev/null @@ -1,19 +0,0 @@ -// 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 java.io.*; -import org.ibex.js.*; -import org.ibex.util.*; -import org.ibex.mail.*; -import org.ibex.mail.target.*; - -public class Later extends JS.Obj implements Target { - public static final Later instance = new Later(); - public static class LaterException extends RuntimeException { } - public void accept(Message m) throws IOException, MailException { - Log.warn(this, "delaying message " + m.summary()); - throw new LaterException(); - } -} diff --git a/src/org/ibex/mail/target/List.java b/src/org/ibex/mail/target/List.java deleted file mode 100644 index 80abcee..0000000 --- a/src/org/ibex/mail/target/List.java +++ /dev/null @@ -1,9 +0,0 @@ -// 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.ibex.mail.*; -/** A full-featured mailing list manager */ -public abstract class List implements Target { -} diff --git a/src/org/ibex/mail/target/MBX.java b/src/org/ibex/mail/target/MBX.java deleted file mode 100644 index df15b21..0000000 --- a/src/org/ibex/mail/target/MBX.java +++ /dev/null @@ -1,9 +0,0 @@ -// 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; - -/** implementation of the MBX mailbox format; only documentation is in UW imapd in src/osdep/unix/mbx.c */ -public class MBX { -} diff --git a/src/org/ibex/mail/target/Pipe.java b/src/org/ibex/mail/target/Pipe.java deleted file mode 100644 index f2f89f6..0000000 --- a/src/org/ibex/mail/target/Pipe.java +++ /dev/null @@ -1,9 +0,0 @@ -// 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.ibex.mail.*; -/** generic pipe-the-message-to-a-file target */ -public abstract class Pipe implements Target { -} diff --git a/src/org/ibex/mail/target/Procmail.java b/src/org/ibex/mail/target/Procmail.java deleted file mode 100644 index 891bcb4..0000000 --- a/src/org/ibex/mail/target/Procmail.java +++ /dev/null @@ -1,9 +0,0 @@ -// 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.ibex.mail.*; -/** callout to support legacy .procmailrc files */ -public abstract class Procmail extends Pipe { -} diff --git a/src/org/ibex/mail/target/Reject.java b/src/org/ibex/mail/target/Reject.java deleted file mode 100644 index c41630f..0000000 --- a/src/org/ibex/mail/target/Reject.java +++ /dev/null @@ -1,23 +0,0 @@ -// 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 java.io.*; -import org.ibex.js.*; -import org.ibex.util.*; -import org.ibex.mail.*; -import org.ibex.mail.target.*; - -public class Reject extends JS.Obj implements Target { - public final String reason; - public Reject(String reason) { this.reason = reason; } - public void accept(Message m) throws IOException, MailException { - throw new RejectException(m, reason); - } - public static class RejectException extends RuntimeException { - public final Message m; - public final String reason; - public RejectException(Message m, String reason) { this.m = m; this.reason = reason; } - } -} diff --git a/src/org/ibex/mail/target/Transcript.java b/src/org/ibex/mail/target/Transcript.java deleted file mode 100644 index af70e95..0000000 --- a/src/org/ibex/mail/target/Transcript.java +++ /dev/null @@ -1,48 +0,0 @@ -// 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.ibex.mail.*; -import org.ibex.util.*; -import org.ibex.io.*; -import java.io.*; -import java.net.*; -import java.util.*; -import java.text.*; - -/** a fast-write, slow-read place to stash all messages we touch -- in case of a major f*ckup */ -public class Transcript implements Target { - - public static final Transcript transcript = new Transcript(Mailbox.STORAGE_ROOT + File.separatorChar + "transcript"); - - private String path; - public Transcript(String path) { new File(this.path = path).mkdirs(); } - private static String lastTime = null; - private static int lastCounter = 0; - - public synchronized void accept(Message message) { - try { - File today = new File(path + File.separatorChar + (new SimpleDateFormat("yy-MMM-dd").format(new Date()))); - today.mkdirs(); - - String time = new SimpleDateFormat("HH:mm:ss").format(new Date()); - synchronized (Transcript.class) { - if (lastTime != null && lastTime.equals(time)) { - time += "." + (++lastCounter); - } else { - lastTime = time; - lastCounter = 0; - } - } - - File target = new File(today.getPath() + File.separatorChar + time + ".txt"); - OutputStream os = new FileOutputStream(target); - try { - message.getStream().transcribe(new Stream(os)); - os.flush(); - } finally { os.close(); } - } catch (IOException e) { throw new MailException.IOException(e); } - } -} - diff --git a/src/org/ibex/mail/target/Vacation.java b/src/org/ibex/mail/target/Vacation.java deleted file mode 100644 index cbb40ef..0000000 --- a/src/org/ibex/mail/target/Vacation.java +++ /dev/null @@ -1,9 +0,0 @@ -// 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.ibex.mail.*; -/** functionality similar to the UNIX vacation command */ -public abstract class Vacation implements Target { -} diff --git a/src/org/ibex/mail/target/XMLRPC.java b/src/org/ibex/mail/target/XMLRPC.java deleted file mode 100644 index 3bbb33a..0000000 --- a/src/org/ibex/mail/target/XMLRPC.java +++ /dev/null @@ -1,9 +0,0 @@ -// 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.ibex.mail.*; -/** an XML-RPC server which accepts requests sent via SMTP */ -public abstract class XMLRPC implements Target { -} -- 1.7.10.4