/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. * * The Original Code is the Grendel mail/news client. * * The Initial Developer of the Original Code is Netscape Communications * Corporation. Portions created by Netscape are Copyright (C) 1997 * Netscape Communications Corporation. All Rights Reserved. * * Created: Terry Weissman , 30 Oct 1997. */ package grendel.storage; import java.io.IOException; import java.util.Hashtable; import java.util.StringTokenizer; import javax.mail.Folder; import javax.mail.FolderNotFoundException; import javax.mail.Flags; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.MethodNotSupportedException; import javax.mail.event.ConnectionEvent; class PopFolder extends Folder implements FolderExtra { static public final String DELETED = "d"; static public final String KEEP = "k"; Hashtable leave; PopMessage msgs[]; PopFolder(PopStore store) { super(store); } public String getName() { return "INBOX"; } public String getFullName() { return "INBOX"; } public Folder getParent() { return null; } public boolean exists() { return true; } public Folder[] list(String string) { return null; } public char getSeparator() { return '/'; } public int getType() { return HOLDS_MESSAGES; } public boolean create(int i) { return true; } public boolean hasNewMessages() { return false; // ### Is this right? Or should it really // go do the work and see? } public Folder getFolder(String string) throws MessagingException { throw new FolderNotFoundException(); } public boolean delete(boolean flag) throws MessagingException { throw new MethodNotSupportedException(); } public boolean renameTo(Folder folder) throws MessagingException { throw new MethodNotSupportedException(); } public void open(int mode) throws MessagingException { if (isOpen()) return; PopStore store = (PopStore) this.store; store.connect(); store.writeln("STAT"); String line = store.readln(); store.check(line, "Stat failed"); StringTokenizer st = new StringTokenizer(line); st.nextToken(); //skip +OK int nummsgs = Integer.parseInt(st.nextToken()); // stat_octetcount = Integer.parseInt(st.nextToken()); msgs = new PopMessage[nummsgs]; for (int i=0 ; i