diff --git a/grendel/dog/mail/nntp/Article.java b/grendel/dog/mail/nntp/Article.java index 677b46ac9a9..9c274a36703 100644 --- a/grendel/dog/mail/nntp/Article.java +++ b/grendel/dog/mail/nntp/Article.java @@ -31,7 +31,7 @@ import javax.mail.internet.*; * The message class implementing the NNTP mail protocol. * * @author dog@dog.net.uk - * @version 0.3 + * @version 1.0 */ public class Article extends MimeMessage { diff --git a/grendel/dog/mail/nntp/NNTPStore.java b/grendel/dog/mail/nntp/NNTPStore.java index be6bc8b7311..6da994de8e4 100644 --- a/grendel/dog/mail/nntp/NNTPStore.java +++ b/grendel/dog/mail/nntp/NNTPStore.java @@ -16,8 +16,7 @@ * The Initial Developer of the Original Code is dog. * Portions created by dog are Copyright (C) 1998 dog . All Rights Reserved. * - * Contributors: Mario Camou . - * Edwin Woudt + * Contributor(s): n/a. */ package dog.mail.nntp; @@ -35,7 +34,7 @@ import dog.util.*; * The storage class implementing the NNTP Usenet news protocol. * * @author dog@dog.net.uk - * @version 0.3 + * @version 1.0 */ public class NNTPStore extends Store implements StatusSource { @@ -68,9 +67,7 @@ public class NNTPStore extends Store implements StatusSource { static final int LISTING_ARTICLES = 230; // list of new articles by message-id follows static final int LISTING_NEW = 231; // list of new newsgroups follows static final int ARTICLE_POSTED = 240; // article posted ok - static final int PASSWORD_OK = 281; // Authentication OK static final int SEND_ARTICLE = 340; // send article to be posted. End with . - static final int PASS_REQ = 381; // PASS required (after sending user) static final int SERVICE_DISCONTINUED = 400; static final int NO_SUCH_GROUP = 411; static final int NO_GROUP_SELECTED = 412; // no newsgroup has been selected @@ -135,18 +132,6 @@ public class NNTPStore extends Store implements StatusSource { break; } - // -- authentication, added by mario -- - if (username != null && password != null) { - send ("AUTHINFO USER "+username); - if (getResponse() == PASS_REQ) { - send ("AUTHINFO PASS "+password); - if (getResponse() != PASSWORD_OK) { - throw new AuthenticationFailedException(); - } - } - } - // -- end authentication -- - readNewsrc(); return true; @@ -426,20 +411,9 @@ public class NNTPStore extends Store implements StatusSource { // Attempts to discover which newsgroups exist and which articles have been read. void readNewsrc() { try { - String osname = System.getProperties().getProperty("os.name"); - File newsrc; - if (osname.startsWith("Windows") || - osname.startsWith("Win32") || - osname.startsWith("Win16") || - osname.startsWith("16-bit Windows")) { - newsrc = new File(System.getProperty("user.home")+File.separator+"news-"+getHostName()+".rc"); - if (!newsrc.exists()) - newsrc = new File(System.getProperty("user.home")+File.separator+"news.rc"); - } else { - newsrc = new File(System.getProperty("user.home")+File.separator+".newsrc-"+getHostName()); - if (!newsrc.exists()) - newsrc = new File(System.getProperty("user.home")+File.separator+".newsrc"); - } + File newsrc = new File(System.getProperty("user.home")+File.separator+".newsrc-"+getHostName()); + if (!newsrc.exists()) + newsrc = new File(System.getProperty("user.home")+File.separator+".newsrc"); BufferedReader reader = new BufferedReader(new FileReader(newsrc)); String line; @@ -742,9 +716,7 @@ public class NNTPStore extends Store implements StatusSource { send(command); switch (getResponse()) { case LISTING_OVERVIEW: - processStatusEvent(new StatusEvent(this, StatusEvent.OPERATION_START, command)); String line; - int count = 0; for (line=in.readLine(); line!=null && !".".equals(line); line = in.readLine()) { int tabIndex = line.indexOf('\t'); if (tabIndex>-1) { @@ -752,13 +724,9 @@ public class NNTPStore extends Store implements StatusSource { Article article = new Article(newsgroup, msgnum); article.addXoverHeaders(getOverviewHeaders(format, line, tabIndex)); av.addElement(article); - count++; - if ((count%20)==0) - processStatusEvent(new StatusEvent(this, StatusEvent.OPERATION_UPDATE, command, newsgroup.first, newsgroup.last, msgnum)); } else throw new ProtocolException("Invalid overview line format"); } - processStatusEvent(new StatusEvent(this, StatusEvent.OPERATION_END, command)); break; case NO_ARTICLE_SELECTED: case PERMISSION_DENIED: diff --git a/grendel/dog/mail/nntp/Newsgroup.java b/grendel/dog/mail/nntp/Newsgroup.java index 345709d8ace..aa6d9aa8297 100644 --- a/grendel/dog/mail/nntp/Newsgroup.java +++ b/grendel/dog/mail/nntp/Newsgroup.java @@ -16,7 +16,7 @@ * The Initial Developer of the Original Code is dog. * Portions created by dog are Copyright (C) 1998 dog . All Rights Reserved. * - * Contributors: Edwin Woudt + * Contributor(s): n/a. */ package dog.mail.nntp; @@ -30,7 +30,7 @@ import javax.mail.event.*; * The folder class implementing the NNTP mail protocol. * * @author dog@dog.net.uk - * @version 0.3 + * @version 1.0 */ public class Newsgroup extends Folder { @@ -114,8 +114,8 @@ public class Newsgroup extends Folder { public void open(int mode) throws MessagingException { if (open) throw new MessagingException("Newsgroup is already open"); - //if (mode!=READ_ONLY) - // throw new MessagingException("Newsgroup is read-only"); + if (mode!=READ_ONLY) + throw new MessagingException("Newsgroup is read-only"); ((NNTPStore)store).open(this); open = true; notifyConnectionListeners(ConnectionEvent.OPENED); @@ -174,18 +174,18 @@ public class Newsgroup extends Folder { if (!open) throw new MessagingException("Newsgroup is not open"); NNTPStore s = (NNTPStore)store; - //if (articles==null) + if (articles==null) articles = s.getArticles(this); - //else { // check for new articles - // Article[] nm = s.getNewArticles(this, checkpoint); - // if (nm.length>0) { - // Article[] m2 = new Article[articles.length+nm.length]; - // System.arraycopy(articles, 0, m2, 0, articles.length); - // System.arraycopy(nm, 0, m2, articles.length, nm.length); - // articles = m2; - // } - //} - //checkpoint = new Date(); + else { // check for new articles + Article[] nm = s.getNewArticles(this, checkpoint); + if (nm.length>0) { + Article[] m2 = new Article[articles.length+nm.length]; + System.arraycopy(articles, 0, m2, 0, articles.length); + System.arraycopy(nm, 0, m2, articles.length, nm.length); + articles = m2; + } + } + checkpoint = new Date(); return articles; } diff --git a/grendel/dog/util/ObjectCollator.java b/grendel/dog/util/ObjectCollator.java index 2ad3ec0be3d..657e04c876d 100644 --- a/grendel/dog/util/ObjectCollator.java +++ b/grendel/dog/util/ObjectCollator.java @@ -33,7 +33,7 @@ import java.util.Locale; * A class for comparing objects in a tree. * * @author dog@dog.net.uk - * @version 1.0final + * @version 0.3 */ public class ObjectCollator extends Collator { @@ -75,13 +75,6 @@ public class ObjectCollator extends Collator { return (!descending ? comparison : -comparison); } - /** - * Utility method to return the opposite of a comparison if descending is true. - */ - protected int applyDescending(double comparison) { - return (!descending ? (int)Math.rint(comparison) : (int)Math.rint(comparison*(-1.0))); - } - /** * Compares the source string to the target string according to the collation rules for this Collator. * Returns an integer less than, equal to or greater than zero depending on whether the source String @@ -124,7 +117,7 @@ public class ObjectCollator extends Collator { return applyDescending(collator.compare(source.toString(), (String)target)); } else if (source instanceof Double) { if (target instanceof Number) - return applyDescending((double)(((Number)target).doubleValue()-((Double)source).doubleValue())); + return applyDescending((int)(((Number)target).doubleValue()-((Double)source).doubleValue())); else if (target instanceof String) return applyDescending(collator.compare(source.toString(), (String)target)); } else if (source instanceof Long) { @@ -134,7 +127,7 @@ public class ObjectCollator extends Collator { return applyDescending(collator.compare(source.toString(), (String)target)); } else if (source instanceof Float) { if (target instanceof Number) - return applyDescending((double)(((Number)target).floatValue()-((Float)source).floatValue())); + return applyDescending((int)(((Number)target).floatValue()-((Float)source).floatValue())); else if (target instanceof String) return applyDescending(collator.compare(source.toString(), (String)target)); } else if (source instanceof Byte) { diff --git a/grendel/dog/util/Referential.java b/grendel/dog/util/Referential.java index 9370ef58d99..b6185054800 100644 --- a/grendel/dog/util/Referential.java +++ b/grendel/dog/util/Referential.java @@ -30,7 +30,7 @@ package dog.util; * This reference can be used to tag objects with a datasource id or store a hashtable of associated values. * * @author dog@dog.net.uk - * @version 1.0final + * @version 0.3 */ public interface Referential { diff --git a/grendel/dog/util/StatusEvent.java b/grendel/dog/util/StatusEvent.java index 806ddf40904..d1d18caee66 100644 --- a/grendel/dog/util/StatusEvent.java +++ b/grendel/dog/util/StatusEvent.java @@ -30,7 +30,7 @@ import java.util.*; * A status message. * * @author dog@dog.net.uk - * @version 1.0final + * @version 0.1 */ public class StatusEvent extends EventObject { diff --git a/grendel/dog/util/StatusListener.java b/grendel/dog/util/StatusListener.java index 6f2ff33a71d..01e64b301ae 100644 --- a/grendel/dog/util/StatusListener.java +++ b/grendel/dog/util/StatusListener.java @@ -30,7 +30,7 @@ import java.util.*; * A callback interface for passing status messages. * * @author dog@dog.net.uk - * @version 1.0final + * @version 0.1 */ public interface StatusListener extends EventListener { diff --git a/grendel/dog/util/StatusSource.java b/grendel/dog/util/StatusSource.java index f74926d1c7b..3560e7051d3 100644 --- a/grendel/dog/util/StatusSource.java +++ b/grendel/dog/util/StatusSource.java @@ -28,7 +28,7 @@ package dog.util; * An interface for defining that an object can pass status messages. * * @author dog@dog.net.uk - * @version 1.0final + * @version 0.1 */ public interface StatusSource { diff --git a/grendel/dog/util/Timer.java b/grendel/dog/util/Timer.java index cf3e691d5e5..772544ce7c9 100644 --- a/grendel/dog/util/Timer.java +++ b/grendel/dog/util/Timer.java @@ -28,7 +28,7 @@ package dog.util; * A timer class that wakes up listeners after a specified number of milliseconds. * * @author dog@dog.net.uk - * @version 1.0final + * @version 0.3 */ public final class Timer extends Thread { diff --git a/grendel/dog/util/TimerEvent.java b/grendel/dog/util/TimerEvent.java index 7559c6cb615..9bb29eb268d 100644 --- a/grendel/dog/util/TimerEvent.java +++ b/grendel/dog/util/TimerEvent.java @@ -30,7 +30,7 @@ import java.util.EventObject; * A timer event. * * @author dog@dog.net.uk - * @version 1.0final + * @version 0.3 */ public class TimerEvent extends EventObject { diff --git a/grendel/dog/util/TimerListener.java b/grendel/dog/util/TimerListener.java index 50c9ee650e2..e5b48d0b4a4 100644 --- a/grendel/dog/util/TimerListener.java +++ b/grendel/dog/util/TimerListener.java @@ -30,7 +30,7 @@ import java.util.EventListener; * Interface for classes that wnat to recieve timer events. * * @author dog@dog.net.uk - * @version 1.0final + * @version 0.3 */ public interface TimerListener extends EventListener { diff --git a/grendel/dog/util/Tree.java b/grendel/dog/util/Tree.java index fa989be6de7..59f1f65a31f 100644 --- a/grendel/dog/util/Tree.java +++ b/grendel/dog/util/Tree.java @@ -365,61 +365,43 @@ public final class Tree { void removeElement(int e) { int len = 0; - boolean removed = false; + // does this element have children? for (int p=0; p0) { - System.arraycopy(parents, p+1, parents, p, len); - System.arraycopy(children, p+1, children, p, len); - System.arraycopy(nchildren, p+1, nchildren, p, len); - } - nparents--; - //printArray("parents", parents, nparents); - //printArray("elements", elements, nelements); - if ((len = nelements-e-1)>0) { - System.arraycopy(elements, e+1+nc, elements, e, len-nc); - System.arraycopy(depths, e+1+nc, depths, e, len-nc); - } - nelements-=(nc+1); - //printArray("elements", elements, nelements); - removed = true; - } catch (ArrayIndexOutOfBoundsException x) { - System.out.println("arrayindexoutofboundsexception in tree:"); - System.out.println("p="+p+": "+parents[p]); - System.out.println("e="+e+", nelements="+nelements+", elements.length="+elements.length+", nc="+nc+", len="+len); + // remove the children of this parent first + Object[] pchildren = new Object[nc]; + System.arraycopy(children[p], 0, pchildren, 0, nc); + for (int c=0; c-1) + removeElement(ce); } - break; - } - } - for (int p=0; p0) { - System.arraycopy(children[p], c+1, children[p], c, len); + // remove the parent + if ((len = nparents-p-1)>0) { + System.arraycopy(parents, p+1, parents, p, len); + System.arraycopy(children, p+1, children, p, len); + System.arraycopy(nchildren, p+1, nchildren, p, len); + } + nparents--; p--; + } else { + // is this element a child of another parent? + for (int c=0; c0) { + System.arraycopy(children[p], c+1, children[p], c, len); + } + nchildren[p]--; c--; } - nchildren[p]--; - if ((len = nelements-e-1)>0) { - System.arraycopy(elements, e+1, elements, e, len); - System.arraycopy(depths, e+1, depths, e, len); - } - nelements--; - removed = true; - break; } } } - if (!removed) { - if ((len = nelements-e-1)>0) { - System.arraycopy(elements, e+1, elements, e, len); - System.arraycopy(depths, e+1, depths, e, len); - } - nelements--; + if ((len = nelements-e-1)>0) { + System.arraycopy(elements, e+1, elements, e, len); + System.arraycopy(depths, e+1, depths, e, len); } - //printElements(); + nelements--; } /** diff --git a/grendel/dog/util/TreeEvent.java b/grendel/dog/util/TreeEvent.java index 7e036ee02c2..375009514bf 100644 --- a/grendel/dog/util/TreeEvent.java +++ b/grendel/dog/util/TreeEvent.java @@ -29,7 +29,7 @@ import java.util.EventObject; * A tree event. * * @author dog@dog.net.uk - * @version 1.0final + * @version 2.0alpha */ public class TreeEvent extends ItemEvent {