--- /dev/null
+package org.ibex.mail.target;
+import org.ibex.io.*;
+import org.ibex.mail.*;
+import org.ibex.util.*;
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import java.util.zip.*;
+import java.text.*;
+
+public class MailmanArchives extends Mailbox.Default {
+
+ public static final String archiveUrl =
+ "http://lists.false-profit.com/mailman/private/us/2004-August.txt.gz?username=adam@false-profit.com&password=bre4kull";
+
+ public MailmanArchives() {
+ try {
+ InputStream is = new java.net.URL(archiveUrl).openConnection().getInputStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(/*new GZIPInputStream(is)*/is));
+ Vec all = new Vec();
+ StringBuffer acc = null;
+ for(String s = br.readLine(); ; s = br.readLine()) {
+ if (s == null || s.startsWith("From ")) {
+ if (acc != null) {
+ Log.warn("[msg]", acc.toString());
+ all.addElement(new Message(new Stream(acc.toString()), null));
+ }
+ if (s == null) break;
+ acc = new StringBuffer();
+ } else {
+ acc.append(s);
+ acc.append("\r\n");
+ }
+ }
+ all.copyInto(messages = new Message[all.size()]);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void add(Message m) { throw new RuntimeException("not supported"); }
+ public void add(Message m, int i) { throw new RuntimeException("not supported"); }
+
+ public Message[] messages;
+
+ public int uidValidity() { return 1; }
+ public Mailbox.Iterator iterator() { return new Iterator(); }
+ public int uidNext() { return messages.length; }
+
+ private class Iterator extends Mailbox.Default.Iterator {
+ int num = 0;
+
+ public int uid() { return num; }
+ public int num() { return num; }
+
+ public Message cur() { return messages[num]; }
+ public Message head() { return messages[num]; }
+ public boolean next() { return (++num) < messages.length; }
+ public void delete() { }
+
+ public void set(String key, String val) { }
+ public String get(String key) { return null; }
+ public boolean seen() { return false; }
+ public boolean deleted() { return false; }
+ public boolean flagged() { return false; }
+ public boolean draft() { return false; }
+ public boolean answered() { return false; }
+ public boolean recent() { return false; }
+ public void seen(boolean on) { }
+ public void deleted(boolean on) { }
+ public void flagged(boolean on) { }
+ public void draft(boolean on) { }
+ public void answered(boolean on) { }
+ public void recent(boolean on) { }
+ public int flags() { return 0; }
+ }
+
+}