You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jl...@apache.org on 2006/03/08 19:04:33 UTC

svn commit: r384292 [2/2] - in /geronimo/trunk/modules/javamail-transport: ./ src/java/org/apache/geronimo/javamail/authentication/ src/java/org/apache/geronimo/javamail/store/nntp/ src/java/org/apache/geronimo/javamail/store/nntp/newsrc/ src/java/org/...

Added: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/nntp/newsrc/NNTPNewsrcGroup.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/nntp/newsrc/NNTPNewsrcGroup.java?rev=384292&view=auto
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/nntp/newsrc/NNTPNewsrcGroup.java (added)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/nntp/newsrc/NNTPNewsrcGroup.java Wed Mar  8 10:04:19 2006
@@ -0,0 +1,178 @@
+/**
+ *
+ * Copyright 2003-2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.javamail.store.nntp.newsrc;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+
+public class NNTPNewsrcGroup {
+    // the newsrc database we're part of
+    NNTPNewsrc newsrc;
+    // the name of the group
+    protected String name;
+    // the subscription flage
+    protected boolean subscribed;
+    // the range of already seen articles.
+    protected RangeList ranges;
+
+    /**
+     * Construct a NNTPNewsrcGroup item associated with a given
+     * .newsrc database.
+     *
+     * @param newsrc The owning .newsrc database.
+     * @param line   The .newsrc range entries in .newsrc format.  These ranges are
+     *               parsed to create a set of seen flags.
+     *
+     * @return A created NNTPNewsrcGroup item.
+     */
+    public static NNTPNewsrcGroup parse(NNTPNewsrc newsrc, String line) {
+        String groupName = null;
+        String ranges = null;
+
+        // subscribed lines have a ':' marker acting as a delimiter
+        int marker = line.indexOf(':');
+
+        if (marker != -1) {
+            groupName = line.substring(0, marker);
+            ranges = line.substring(marker + 1);
+            return new NNTPNewsrcGroup(newsrc, groupName, ranges, true);
+        }
+
+        // now check for an unsubscribed group
+        marker = line.indexOf('!');
+
+        if (marker != -1) {
+            groupName = line.substring(0, marker);
+            ranges = line.substring(marker + 1);
+            return new NNTPNewsrcGroup(newsrc, groupName, ranges, false);
+        }
+
+        // must be a comment line
+        return null;
+    }
+
+
+    /**
+     * Construct a .newsrc group item.
+     *
+     * @param newsrc     The owning newsrc database.
+     * @param name       The group name.
+     * @param newsrcRanges
+     *                   The initial set of seen ranges for the group (may be null).
+     * @param subscribed The initial group subscription state.
+     */
+    public NNTPNewsrcGroup(NNTPNewsrc newsrc, String name, String newsrcRanges, boolean subscribed) {
+        this.newsrc = newsrc;
+        this.name = name;
+        this.subscribed = subscribed;
+        this.ranges = new RangeList(newsrcRanges);
+    }
+
+
+    /**
+     * Get the group name.
+     *
+     * @return The String name of the group.
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Get the newsrc subscribed status for an article.
+     *
+     * @return The current subscription flag.
+     */
+    public boolean isSubscribed() {
+        return subscribed;
+    }
+
+    /**
+     * Set the subscription status for an article.
+     *
+     * @param flag   The new subscription value.
+     */
+    public void setSubscribed(boolean flag) {
+        // we don't blindly set this to the new value since we only want to resave the newsrc file if
+        // something changes.
+        if (flag && !subscribed) {
+            subscribed = true;
+            newsrc.setDirty();
+        }
+        else if (!flag && subscribed) {
+            subscribed = false;
+            newsrc.setDirty();
+        }
+    }
+
+    /**
+     * Test if an article has been seen yet.
+     *
+     * @param article The target article.
+     *
+     * @return The seen mark for the article.
+     */
+    public boolean isArticleSeen(int article) {
+        return ranges.isMarked(article);
+    }
+
+    /**
+     * Mark an article as seen.
+     *
+     * @param article The target article number.
+     */
+    public void markArticleSeen(int article) {
+        ranges.setMarked(article);
+        if (ranges.isDirty()) {
+            newsrc.setDirty();
+        }
+    }
+
+    /**
+     * Mark an article as unseen.
+     *
+     * @param article The target article number.
+     */
+    public void markArticleUnseen(int article) {
+        ranges.setUnmarked(article);
+        if (ranges.isDirty()) {
+            newsrc.setDirty();
+        }
+    }
+
+
+    /**
+     * Save this group definition to a .newsrc file.
+     *
+     * @param out    The output writer to send the information to.
+     *
+     * @exception IOException
+     */
+    public void save(Writer out) throws IOException {
+        out.write(name);
+        out.write(subscribed ? ": " : "! ");
+        ranges.save(out);
+        // put a terminating line end
+        out.write("\r\n");
+    }
+}
+

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/nntp/newsrc/NNTPNewsrcGroup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/nntp/newsrc/NNTPNewsrcGroup.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/nntp/newsrc/Range.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/nntp/newsrc/Range.java?rev=384292&view=auto
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/nntp/newsrc/Range.java (added)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/nntp/newsrc/Range.java Wed Mar  8 10:04:19 2006
@@ -0,0 +1,310 @@
+/**
+ *
+ * Copyright 2003-2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.javamail.store.nntp.newsrc;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+
+
+
+/**
+ * Represent a single Range in a newsrc file.  A Range can be
+ * either a single number (start == end) or a span of article
+ * numbers.
+ */
+public class Range {
+    // the low end of the range
+    int start;
+    // the high end of the range (start and end are inclusive);
+    int end;
+
+    /**
+     * Construct a Range item for a single digit range.
+     *
+     * @param spot   The location of the singleton.
+     */
+    public Range(int spot) {
+        this(spot, spot);
+    }
+
+    /**
+     * Construct a Range item.
+     *
+     * @param start  The starting point of the Range.
+     * @param end    The Range end point (which may be equal to the starting point).
+     */
+    public Range(int start, int end) {
+        this.start = start;
+        this.end = end;
+    }
+
+    /**
+     * Parse a section of a .newsrc range string into a single
+     * Range item.  The range is either a single number, or a pair of
+     * numbers separated by a hyphen.
+     *
+     * @param range  The range string.
+     *
+     * @return A constructed Range item, or null if there is a parsing error.
+     */
+    static public Range parse(String range) {
+        // a range from a newsrc file is either a single number or in the format 'nnnn-mmmm'.  We need
+        // to figure out which type this is.
+        int marker = range.indexOf('-');
+
+        try {
+            if (marker != -1) {
+                String rangeStart = range.substring(0, marker).trim();
+                String rangeEnd = range.substring(marker + 1).trim();
+
+                int start = Integer.parseInt(rangeStart);
+                int end = Integer.parseInt(rangeEnd);
+
+                if (start >= 0 && end >= 0) {
+                    return new Range(start, end);
+                }
+            }
+            else {
+                // use the entire token
+                int start = Integer.parseInt(range);
+                // and start and the end are the same
+                return new Range(start, start);
+
+            }
+        } catch (NumberFormatException e) {
+        }
+        // return null for any bad values
+        return null;
+    }
+
+    /**
+     * Get the starting point for the Range.
+     *
+     * @return The beginning of the mark range.
+     */
+    public int getStart() {
+        return start;
+    }
+
+    /**
+     * Set the starting point for a Range.
+     *
+     * @param start  The new start value.
+     */
+    public void setStart(int start) {
+        this.start = start;
+    }
+
+    /**
+     * Get the ending point for the Range.
+     *
+     * @return The end of the mark range.
+     */
+    public int getEnd() {
+        return end;
+    }
+
+    /**
+     * Set the ending point for a Range.
+     *
+     * @param end    The new end value.
+     */
+    public void setEnd(int end) {
+        this.end = end;
+    }
+
+    /**
+     * Test if a range contains a point value.
+     *
+     * @param target The article location to test.
+     *
+     * @return True if the target is between the start and end values, inclusive.
+     */
+    public boolean contains(int target) {
+        return target >= start && target <= end;
+    }
+
+    /**
+     * Test if one range is completely contained within another Range.
+     *
+     * @param other  The other test range.
+     *
+     * @return true if the other start and end points are contained within this range.
+     */
+    public boolean contains(Range other) {
+        return contains(other.getStart()) && contains(other.getEnd());
+    }
+
+    /**
+     * Tests if two ranges overlap
+     *
+     * @param other  The other test range.
+     *
+     * @return true if the start or end points of either range are contained
+     *         within the range of the other.
+     */
+    public boolean overlaps(Range other) {
+        return other.contains(start) || other.contains(end) || contains(other.getStart()) || contains(other.getEnd());
+    }
+
+    /**
+     * Test if two ranges exactly abutt each other.
+     *
+     * @param other  The other Range to test.
+     *
+     * @return true if the end of one range abutts the start of the other range.
+     */
+    public boolean abutts(Range other) {
+        return other.getStart() == end + 1 || other.getEnd() == start - 1;
+    }
+
+    /**
+     * Tests if a single point abutts either the start or end of this
+     * Range.
+     *
+     * @param article The point to test.
+     *
+     * @return true if test point is equal to start - 1 or end + 1.
+     */
+    public boolean abutts(int article) {
+        return article == start - 1 || article == end + 1;
+    }
+
+    /**
+     * Test if a point is below the test Range.
+     *
+     * @param article The point to test.
+     *
+     * @return true if the entire range is less than the test point.
+     */
+    public boolean lessThan(int article) {
+        return end < article;
+    }
+
+    /**
+     * Test if another Range is less than this Range.
+     *
+     * @param other  The other Range to test.
+     *
+     * @return true if the other Range lies completely below this Range.
+     */
+    public boolean lessThan(Range other) {
+        return end < other.start;
+    }
+
+
+    /**
+     * Test if a point is above the test Range.
+     *
+     * @param article The point to test.
+     *
+     * @return true if the entire range is greater than the test point.
+     */
+    public boolean greaterThan(int article) {
+        return start > article;
+    }
+
+
+    /**
+     * Test if another Range is greater than this Range.
+     *
+     * @param other  The other Range to test.
+     *
+     * @return true if the other Range lies completely below this Range.
+     */
+    public boolean greaterThan(Range other) {
+        return start > other.end;
+    }
+
+
+    /**
+     * Merge another Range into this one.  Merging will increase the
+     * bounds of this Range to encompass the entire span of the two.
+     * If the Ranges do not overlap, the newly created range will
+     * include the gap between the two.
+     *
+     * @param other  The Range to merge.
+     */
+    public void merge(Range other) {
+        if (other.start < start) {
+            start = other.start;
+        }
+
+        if (other.end > end ) {
+            end = other.end;
+        }
+    }
+
+    /**
+     * Split a range at a given split point.  Splitting will truncate
+     * at the split location - 1 and return a new range beginning
+     * at location + 1;  This code assumes that the split location
+     * is at neither end poing.
+     *
+     * @param location The split location.  Location must be in the range start < location < end.
+     *
+     * @return A new Range object for the split portion of the range.
+     */
+    public Range split(int location) {
+        int newEnd = end;
+
+        end = location - 1;
+
+        return new Range(location + 1, newEnd);
+    }
+
+
+    /**
+     * Save an individual range element to a newsrc file.  The range
+     * is expressed either as a single number, or a hypenated pair
+     * of numbers.
+     *
+     * @param out    The output writer used to save the data.
+     *
+     * @exception IOException
+     */
+    public void save(Writer out) throws IOException {
+        // do we have a single data point range?
+        if (start == end) {
+            out.write(Integer.toString(start));
+        }
+        else {
+            out.write(Integer.toString(start));
+            out.write("-");
+            out.write(Integer.toString(end));
+        }
+    }
+
+    /**
+     * Convert a Range into String form.  Used mostly for debugging.
+     *
+     * @return The String representation of the Range.
+     */
+    public String toString() {
+        if (start == end) {
+            return Integer.toString(start);
+        }
+        else {
+            return Integer.toString(start) + "-" + Integer.toString(end);
+        }
+    }
+}

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/nntp/newsrc/Range.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/nntp/newsrc/Range.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/nntp/newsrc/RangeList.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/nntp/newsrc/RangeList.java?rev=384292&view=auto
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/nntp/newsrc/RangeList.java (added)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/nntp/newsrc/RangeList.java Wed Mar  8 10:04:19 2006
@@ -0,0 +1,216 @@
+/**
+ *
+ * Copyright 2003-2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.javamail.store.nntp.newsrc;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+
+/**
+ * Manage a list of ranges values from a newsrc file.
+ */
+public class RangeList {
+    boolean dirty = false;
+
+    ArrayList ranges = new ArrayList();
+
+    /**
+     * Create a RangeList instance from a newsrc range line.  Values
+     * are saved as a comma separated set of range values.  A range
+     * value is either a single number or a hypenated pair of numbers.
+     *
+     * @param line   The newsrc range line.
+     */
+    public RangeList(String line) {
+
+        // we might be creating an first time list, so nothing to parse.
+        if (line != null) {
+            // ranges are comma delimited tokens
+            StringTokenizer tokenizer = new StringTokenizer(line, ",");
+
+            while (tokenizer.hasMoreTokens()) {
+                String rangeString = (String)tokenizer.nextToken();
+                rangeString = rangeString.trim();
+                if (rangeString.length() != 0) {
+                    Range range = Range.parse(rangeString);
+                    if (range != null) {
+                        insert(range);
+                    }
+                }
+            }
+        }
+        // make sure we start out in a clean state.  Any changes from this point will flip on the dirty flat.
+        dirty = false;
+    }
+
+    /**
+     * Insert a range item into our list.  If possible, the inserted
+     * range will be merged with existing ranges.
+     *
+     * @param newRange The new range item.
+     */
+    public void insert(Range newRange) {
+        // first find the insertion point
+        for (int i = 0; i < ranges.size(); i++) {
+            Range range = (Range)ranges.get(i);
+            // does an existing range fully contain the new range, we don't need to insert anything.
+            if (range.contains(newRange)) {
+                return;
+            }
+
+            // does the current one abutt or overlap with the inserted range?
+            if (range.abutts(newRange) || range.overlaps(newRange)) {
+                // rats, we have an overlap...and it is possible that we could overlap with
+                // the next range after this one too.  Therefore, we merge these two ranges together,
+                // remove the place where we're at, and then recursively insert the larger range into
+                // the list.
+                dirty = true;
+                newRange.merge(range);
+                ranges.remove(i);
+                insert(newRange);
+                return;
+            }
+
+
+            // ok, we don't touch the current one at all.  If it is completely above
+            // range we're adding, we can just poke this into the list here.
+            if (newRange.lessThan(range)) {
+                dirty = true;
+                ranges.add(i, newRange);
+                return;
+            }
+        }
+        dirty = true;
+        // this is easy (and fairly common)...we just tack this on to the end.
+        ranges.add(newRange);
+    }
+
+    /**
+     * Test if a given article point falls within one of the contained
+     * Ranges.
+     *
+     * @param article The test point.
+     *
+     * @return true if this falls within one of our current mark Ranges, false
+     *         otherwise.
+     */
+    public boolean isMarked(int article) {
+        for (int i = 0; i < ranges.size(); i++) {
+            Range range = (Range)ranges.get(i);
+            if (range.contains(article)) {
+                return true;
+            }
+            // we've passed the point where a match is possible.
+            if (range.greaterThan(article)) {
+                return false;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Mark a target article as having been seen.
+     *
+     * @param article The target article number.
+     */
+    public void setMarked(int article) {
+        // go through the insertion logic.
+        insert(new Range(article, article));
+    }
+
+    /**
+     * Clear the seen mark for a target article.
+     *
+     * @param article The target article number.
+     */
+    public void setUnmarked(int article) {
+        for (int i = 0; i < ranges.size(); i++) {
+            Range range = (Range)ranges.get(i);
+            // does this fall within an existing range?  We don't need to do anything here.
+            if (range.contains(article)) {
+                // ok, we've found where to insert, now to figure out how to insert
+                // article is at the beginning of the range.  We can just increment the lower
+                // bound, or if this is a single element range, we can remove it entirely.
+                if (range.getStart() == article) {
+                    if (range.getEnd() == article) {
+                        // piece of cake!
+                        ranges.remove(i);
+                    }
+                    else {
+                        // still pretty easy.
+                        range.setStart(article + 1);
+                    }
+                }
+                else if (range.getEnd() == article) {
+                    // pretty easy also
+                    range.setEnd(article - 1);
+                }
+                else {
+                    // split this into two ranges and insert the trailing piece after this.
+                    Range section = range.split(article);
+                    ranges.add(i + 1, section);
+                }
+                dirty = true;
+                return;
+            }
+            // did we find a point where any articles are greater?
+            if (range.greaterThan(article)) {
+                // nothing to do
+                return;
+            }
+        }
+        // didn't find it at all.  That was easy!
+    }
+
+
+    /**
+     * Save this List of Ranges out to a .newsrc file.  This creates
+     * a comma-separated list of range values from each of the Ranges.
+     *
+     * @param out    The target output stream.
+     *
+     * @exception IOException
+     */
+    public void save(Writer out) throws IOException {
+        // we have an empty list
+        if (ranges.size() == 0) {
+            return;
+        }
+
+        Range range = (Range)ranges.get(0);
+        range.save(out);
+
+        for (int i = 1; i < ranges.size(); i++) {
+            out.write(",");
+            range = (Range)ranges.get(i);
+            range.save(out);
+        }
+    }
+
+    /**
+     * Return the state of the dirty flag.
+     *
+     * @return True if the range list information has changed, false otherwise.
+     */
+    public boolean isDirty() {
+        return dirty;
+    }
+}

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/nntp/newsrc/RangeList.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/nntp/newsrc/RangeList.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3Command.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3CommandFactory.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3Connection.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3Constants.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3Folder.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3Response.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3ResponseBuilder.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3Store.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3Message.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3MessageFactory.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3MessageWithContentInfo.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3MessageWithEnvelope.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3MessageWithFlags.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/response/DefaultPOP3Response.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/response/POP3ListResponse.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/response/POP3ResponseFactory.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/response/POP3StatusResponse.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Modified: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/NNTPConnection.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/NNTPConnection.java?rev=384292&r1=384291&r2=384292&view=diff
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/NNTPConnection.java (original)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/NNTPConnection.java Wed Mar  8 10:04:19 2006
@@ -1,6 +1,6 @@
 /**
  *
- * Copyright 2006 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -63,7 +63,7 @@
  * delivery.
  * <p/>
  * There is no way to indicate failure for a given recipient (it's possible to have a
- * recipient address rejected).  The sun impl throws exceptions even if others are successful,
+ * recipient address rejected).  The sun impl throws exceptions even if others successful),
  * but maybe we do a different way...
  * <p/>
  *
@@ -147,6 +147,9 @@
     // map of server extension arguments
     protected HashMap serverExtensionArgs;
 
+    // the welcome string from the server.
+    protected String welcomeString = null;
+
     /**
      * Normal constructor for an NNTPConnection() object.
      *
@@ -383,6 +386,9 @@
             postingAllowed = false;
         }
 
+        // the NNTP store will want to use the welcome string, so save it.
+        welcomeString = line.getMessage();
+
         // find out what extensions this server supports.
         getExtensions();
     }
@@ -536,7 +542,7 @@
      * server is in the right place and ready for getting the DATA message
      * and the data right place in the sequence
      */
-    public void sendPost(Message msg) throws MessagingException {
+    public synchronized void sendPost(Message msg) throws MessagingException {
 
         // send the POST command
         NNTPReply line = sendCommand("POST");
@@ -590,7 +596,7 @@
      *
      * @return The command reply.
      */
-    public NNTPReply sendCommand(String command, int success) throws MessagingException {
+    public synchronized NNTPReply sendCommand(String command, int success) throws MessagingException {
         NNTPReply reply = sendCommand(command);
         if (reply.getCode() == success) {
             reply.retrieveData(in);
@@ -943,6 +949,26 @@
      */
     public boolean isPostingAllowed() {
         return postingAllowed;
+    }
+
+
+    /**
+     * Retrieve the welcome string sent back from the server.
+     *
+     * @return The server provided welcome string.
+     */
+    public String getWelcomeString() {
+        return welcomeString;
+    }
+
+
+    /**
+     * Return the server host for this connection.
+     *
+     * @return The String name of the server host.
+     */
+    public String getHost() {
+        return host;
     }
 }
 

Modified: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/NNTPReply.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/NNTPReply.java?rev=384292&r1=384291&r2=384292&view=diff
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/NNTPReply.java (original)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/NNTPReply.java Wed Mar  8 10:04:19 2006
@@ -1,6 +1,6 @@
 /**
  *
- * Copyright 2006 The Apache Software Foundation
+ * Copyright 2005 The Apache Software Foundation
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@
  *
  * @version $Rev$ $Date$
  */
-class NNTPReply {
+public class NNTPReply {
     // general server responses
     public static final int POSTING_ALLOWED = 200;
     public static final int NO_POSTING_ALLOWED = 201;
@@ -82,6 +82,10 @@
     public static final int AUTHINFO_SIMPLE_REQUIRED = 450;
     public static final int AUTHENTICATION_REJECTED = 482;
 
+    // list active reponses
+    public static final int LIST_FOLLOWS             = 215;
+
+
     // The original reply string
     private final String reply;
     // returned message code
@@ -132,11 +136,15 @@
             data = new ArrayList();
 
             String line = in.readLine();
-
             // read until the end of file or until we see the end of data marker.
             while (line != null && !line.equals(".")) {
+                // this line is not the terminator, but it may have been byte stuffed.  If it starts with
+                // '.', throw away the leading one.
+                if (line.startsWith(".")) {
+                    line = line.substring(1);
+                }
+
                 // just add the line to the list
-                // TODO:  figure out if we need to handle "stuffing".
                 data.add(line);
                 line = in.readLine();
             }

Modified: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/NNTPTransport.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/NNTPTransport.java?rev=384292&r1=384291&r2=384292&view=diff
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/NNTPTransport.java (original)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/NNTPTransport.java Wed Mar  8 10:04:19 2006
@@ -1,6 +1,6 @@
 /**
  *
- * Copyright 2006 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -54,7 +54,7 @@
  * delivery.
  * <p/>
  * There is no way to indicate failure for a given recipient (it's possible to have a
- * recipient address rejected).  The sun impl throws exceptions even if others are successful,
+ * recipient address rejected).  The sun impl throws exceptions even if others successful),
  * but maybe we do a different way...
  * <p/>
  *
@@ -63,13 +63,10 @@
 public class NNTPTransport extends Transport {
 
     /**
-     * property keys for protocol properties.  The actual property name will
-     * be appended with "mail." + protocol + ".", where the protocol is either
-     * "smtp" or "smtps".
+     * property keys for protocol properties.
      */
-    protected static final String MAIL_NNTP_AUTH = "auth";
-    protected static final String MAIL_NNTP_PORT = "port";
-    protected static final String MAIL_NNTP_TIMEOUT = "timeout";
+    protected static final String NNTP_AUTH = "mail.nntp.auth";
+    protected static final String NNTP_PORT = "mail.nntp.port";
 
     protected static final int DEFAULT_NNTP_PORT = 119;
 
@@ -119,7 +116,7 @@
 
         // first check to see if we need to authenticate.  If we need this, then we must have a username and
         // password specified.  Failing this may result in a user prompt to collect the information.
-        boolean mustAuthenticate = SessionUtil.getBooleanProperty(session, MAIL_NNTP_AUTH, false);
+        boolean mustAuthenticate = SessionUtil.getBooleanProperty(session, NNTP_AUTH, false);
 
         // if we need to authenticate, and we don't have both a userid and password, then we fail this
         // immediately.  The Service.connect() method will try to obtain the user information and retry the
@@ -133,7 +130,7 @@
         // if not configured, we just use the default default.
         if (port == -1) {
             // check for a property and fall back on the default if it's not set.
-            port = SessionUtil.getIntProperty(session, MAIL_NNTP_PORT, DEFAULT_NNTP_PORT);
+            port = SessionUtil.getIntProperty(session, NNTP_PORT, DEFAULT_NNTP_PORT);
         }
 
 
@@ -252,6 +249,8 @@
      * @exception MessagingException
      */
     public void close() throws MessagingException {
+		// This is done to ensure proper event notification.
+		super.close();
         connection.close();
         connection = null;
     }

Added: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/StringListInputStream.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/StringListInputStream.java?rev=384292&view=auto
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/StringListInputStream.java (added)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/StringListInputStream.java Wed Mar  8 10:04:19 2006
@@ -0,0 +1,106 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.javamail.transport.nntp;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StringListInputStream extends InputStream {
+    // the list of lines we're reading from
+    protected List lines;
+    // the next line to process.
+    protected int nextLine = 0;
+    // current buffer of bytes to read from
+    byte[] buffer;
+    // current offset within the buffer;
+    int offset;
+    // indicator that we've left off at a split between the CR and LF of a line break.
+    boolean atLineBreak = false;
+
+    public StringListInputStream(List lines) throws IOException {
+        this.lines = lines;
+        nextLine = 0;
+        buffer = null;
+        offset = 0;
+        atLineBreak = false;
+
+        // if we have at least one line in the list, get the bytes now.
+        if (lines.size() > 0) {
+            nextBuffer();
+        }
+    }
+
+    /**
+     * Just override the single byte read version, which handles all
+     * of the lineend markers correctly.
+     *
+     * @return The next byte from the stream or -1 if we've hit the EOF.
+     */
+    public int read() throws IOException {
+        // leave off at the split between a line?
+        if (atLineBreak) {
+            // flip this off and return the second line end character.  Also step to the next line.
+            atLineBreak = false;
+            nextBuffer();
+            return '\n';
+        }
+        // gone past the end?  Got an EOF
+        if (buffer == null) {
+            return -1;
+        }
+
+        // reach the end of the line?
+        if (offset >= buffer.length) {
+            // we're now working on a virtual linebreak
+            atLineBreak = true;
+            return '\r';
+        }
+        // just return the next byte
+        return buffer[offset++];
+
+    }
+
+    /**
+     * Step to the next buffer of string data.
+     *
+     * @exception IOException
+     */
+    protected void nextBuffer() throws IOException {
+        // give an eof check.
+        if (nextLine >= lines.size()) {
+            buffer = null;
+        }
+        else {
+            try {
+                String next = (String)lines.get(nextLine++);
+                buffer = next.getBytes("US-ASCII");
+
+            } catch (UnsupportedEncodingException e) {
+                throw new IOException("Invalid string encoding");
+            }
+        }
+
+        offset = 0;
+    }
+}
+

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/StringListInputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/StringListInputStream.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/MalformedSMTPReplyException.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPAddressFailedException.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPAddressSucceededException.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPMessage.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPReply.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPSTransport.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPSendFailedException.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransport.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Modified: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransportException.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransportException.java?rev=384292&r1=384291&r2=384292&view=diff
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransportException.java (original)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransportException.java Wed Mar  8 10:04:19 2006
@@ -20,7 +20,7 @@
 /**
  *  General purpose Exception
  *
- * @version $Id$
+ * @version $Id: SMTPTransportException.java 375375 2006-02-06 21:16:28Z bsnyder $
  */
 class SMTPTransportException extends Exception {
 

Propchange: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransportException.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Wed Mar  8 10:04:19 2006
@@ -1 +1 @@
-Date Author Id Revision HeadURL
+Rev Date

Modified: geronimo/trunk/modules/javamail-transport/src/resources/META-INF/javamail.default.providers
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/resources/META-INF/javamail.default.providers?rev=384292&r1=384291&r2=384292&view=diff
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/resources/META-INF/javamail.default.providers (original)
+++ geronimo/trunk/modules/javamail-transport/src/resources/META-INF/javamail.default.providers Wed Mar  8 10:04:19 2006
@@ -28,6 +28,7 @@
 #
 protocol=smtp; type=transport; class=org.apache.geronimo.javamail.transport.smtp.SMTPTransport; vendor=Apache Software Foundation; version=1.0
 protocol=smtps; type=transport; class=org.apache.geronimo.javamail.transport.smtp.SMTPTSransport; vendor=Apache Software Foundation; version=1.0
-protocol=nntp; type=transport; class=org.apache.geronimo.javamail.transport.nntp.NNTPTransport; vendor=Apache Software Foundation; version=1.0
+protocol=nntp-post; type=transport; class=org.apache.geronimo.javamail.transport.nntp.NNTPTransport; vendor=Apache Software Foundation; version=1.0
+protocol=nntp; type=store; class=org.apache.geronimo.javamail.store.nntp.NNTPStore; vendor=Apache Software Foundation; version=1.0
 protocol=pop3; type=store; class=org.apache.geronimo.javamail.store.pop3.POP3Store; vendor=Apache Software Foundation; version=1.0