From f0b363c6de322de981996a6b08b26a543ab399d3 Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 6 Aug 2004 01:55:06 +0000 Subject: [PATCH] preliminary MailmanArchives darcs-hash:20040806015506-5007d-8eee0cd8c99145a66bcec7a13d0426bb4b02f0d8.gz --- src/org/ibex/mail/target/MailmanArchives.java | 79 +++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 src/org/ibex/mail/target/MailmanArchives.java diff --git a/src/org/ibex/mail/target/MailmanArchives.java b/src/org/ibex/mail/target/MailmanArchives.java new file mode 100644 index 0000000..7f9bad5 --- /dev/null +++ b/src/org/ibex/mail/target/MailmanArchives.java @@ -0,0 +1,79 @@ +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; } + } + +} -- 1.7.10.4