1 // Copyright 2000-2005 the Contributors, as shown in the revision logs.
2 // Licensed under the Apache Public Source License 2.0 ("the License").
3 // You may not use this file except in compliance with the License
7 import org.ibex.mail.*;
8 import org.ibex.util.*;
12 import java.util.zip.*;
15 /** designed to make a set of HTTP-accessible Mailman archives appear as a mailbox */
16 public class MailmanArchives extends Mailbox.Default {
18 public static final String archiveUrl =
19 "http://lists.false-profit.com/mailman/private/us/2004-August.txt.gz?username=adam@false-profit.com&password=bre4kull";
21 public MailmanArchives() {
23 InputStream is = new java.net.URL(archiveUrl).openConnection().getInputStream();
24 BufferedReader br = new BufferedReader(new InputStreamReader(/*new GZIPInputStream(is)*/is));
26 StringBuffer acc = null;
27 for(String s = br.readLine(); ; s = br.readLine()) {
28 if (s == null || s.startsWith("From ")) {
30 Log.warn("[msg]", acc.toString());
31 all.addElement(Message.newMessage(new Fountain.StringFountain(acc.toString())));
34 acc = new StringBuffer();
40 all.copyInto(messages = new Message[all.size()]);
41 } catch (Exception e) {
43 throw new RuntimeException(e);
47 public void insert(Message m, int i) { throw new RuntimeException("not supported"); }
49 public Message[] messages;
51 public int uidValidity() { return 1; }
52 public Mailbox.Iterator iterator() { return new Iterator(); }
53 public int uidNext() { return messages.length; }
55 private class Iterator extends Mailbox.Default.Iterator {
57 public int uid() { return num; }
58 public int nntpNumber() { return num; }
59 public int imapNumber() { return num; }
60 public Message cur() { return messages[num]; }
61 public Headers head() { return messages[num].headers; }
62 public boolean next() { return (++num) < messages.length; }
63 public void delete() { }