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.
5 package org.ibex.mail.target;
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 add(Message m) { throw new RuntimeException("not supported"); }
48 public void add(Message m, int i) { throw new RuntimeException("not supported"); }
50 public Message[] messages;
52 public int uidValidity() { return 1; }
53 public Mailbox.Iterator iterator() { return new Iterator(); }
54 public int uidNext() { return messages.length; }
56 private class Iterator extends Mailbox.Default.Iterator {
59 public int uid() { return num; }
60 public int num() { return num; }
62 public Message cur() { return messages[num]; }
63 public Headers head() { return messages[num].headers; }
64 public boolean next() { return (++num) < messages.length; }
65 public void delete() { }
67 public void set(String key, String val) { }
68 public String get(String key) { return null; }
69 public boolean seen() { return false; }
70 public boolean deleted() { return false; }
71 public boolean flagged() { return false; }
72 public boolean draft() { return false; }
73 public boolean answered() { return false; }
74 public boolean recent() { return false; }
75 public void seen(boolean on) { }
76 public void deleted(boolean on) { }
77 public void flagged(boolean on) { }
78 public void draft(boolean on) { }
79 public void answered(boolean on) { }
80 public void recent(boolean on) { }
81 public int flags() { return 0; }