classpathx-javamail
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Classpathx-javamail] Patch updating input streams and concurrency debug


From: Doug Porter
Subject: [Classpathx-javamail] Patch updating input streams and concurrency debugging
Date: Fri, 19 Sep 2003 02:31:06 -0800

I've rewriten most of the input stream management in gnu.mail. Most of
the replicated code is gone, replaced by classes for specific purposes
that are combined as needed. I haven't changed all the MIME input streams
yet because I don't have good test cases for them. The new code is much
more reliable, based on tests here. And I'm confident that as we find
bugs, it will be easier to fix them.

This also includes an updated version of simple concurrency debugging
support. When debug messages are from different threads they print
clearly. You can control whether to include timestamps and thread ids by
setting properties. We now have a central Session.log to handle debug
messages cleanly.

I've been working with a copy from cvs from a couple of weeks ago, so we
may need to reconcile.

Doug


> diff -r /usr/src/CVS/classpathx/mail 
> /usr/src/tiger-0.5.2/thirdparty/classpathx-javamail-customized/mail
Only in /usr/src/CVS/classpathx/mail: CVS
Only in /usr/src/CVS/classpathx/mail/config: CVS
Only in /usr/src/CVS/classpathx/mail/lib: CVS
Only in /usr/src/CVS/classpathx/mail/source: CVS
Only in /usr/src/CVS/classpathx/mail/source/gnu: CVS
Only in /usr/src/CVS/classpathx/mail/source/gnu/mail: CVS
Only in /usr/src/CVS/classpathx/mail/source/gnu/mail/handler: CVS
Only in /usr/src/CVS/classpathx/mail/source/gnu/mail/providers: CVS
Only in /usr/src/CVS/classpathx/mail/source/gnu/mail/providers/imap: CVS
Only in /usr/src/CVS/classpathx/mail/source/gnu/mail/providers/imap4: CVS
Only in /usr/src/CVS/classpathx/mail/source/gnu/mail/providers/maildir:
CVS
Only in /usr/src/CVS/classpathx/mail/source/gnu/mail/providers/mbox: CVS
Only in /usr/src/CVS/classpathx/mail/source/gnu/mail/providers/nntp: CVS
Only in /usr/src/CVS/classpathx/mail/source/gnu/mail/providers/pop3: CVS
diff -r
/usr/src/CVS/classpathx/mail/source/gnu/mail/providers/pop3/POP3Connection.java
/usr/src/tiger-0.5.2/thirdparty/classpathx-javamail-customized/mail/source/gnu/mail/providers/pop3/POP3Connection.java
37,38c37,38
< import java.util.ArrayList;
< import java.util.List;
---
> 
> import javax.mail.Session;
41a42
> import gnu.mail.util.LineInputStream;
48,51c49
<  * followed by multiple LIST and/or UIDL instead) and TOP with a
specified
<  * number of content lines. It also implements the POP3 extension
mechanism
<  * CAPA, documented in RFC 2449, as well as the STLS command to
initiate TLS
<  * over POP3 documented in RFC 2595.
---
>  * followed by multiple LIST and/or UIDL instead).
79,80d76
<       protected static final String CAPA = "CAPA";
<       protected static final String STLS = "STLS";
90c86
<   protected CRLFInputStream in;
---
>   protected LineInputStream in;
115c111,112
<    * Creates a new connection to the server.
---
>    * Constructor.
>        * This establishes the connection to the server.
121,135d117
<       {
<               this(hostname, port, -1, -1, false);
<       }
<       
<   /**
<    * Creates a new connection to the server.
<        * @param hostname the hostname of the server to connect to
<        * @param port the port to connect to (if &lt;=0, use default
POP3 port)
<        * @param connectionTimeout the connection timeout, in
milliseconds
<        * @param timeout the I/O timeout, in milliseconds
<        * @param debug print debugging information
<    */
<   public POP3Connection(String hostname, int port,
<                       int connectionTimeout, int timeout, boolean
debug)
<               throws UnknownHostException, IOException
137c119
<               this.debug = debug;
---
>               debug = false;
140,142d121
< 
<               // Set up socket
<               // TODO connection timeout
144,147c123
<               if (timeout>0)
<                       socket.setSoTimeout(timeout);
<               
<               in = new CRLFInputStream(socket.getInputStream());
---
>               in = new LineInputStream (new 
> CRLFInputStream(socket.getInputStream()));
155a132,147
>        * Indicates if debug is currently enabled.
>        */
>       public boolean isDebug()
>       {
>               return debug;
>       }
> 
>       /**
>        * Sets debug status.
>        */
>       public void setDebug(boolean flag)
>       {
>               debug = flag;
>       }
> 
>       /**
156a149
>        * TODO APOP
188,193c181
<                               cmd = new StringBuffer(APOP)
<                                       .append(' ')
<                                       .append(username)
<                                       .append(' ')
<                                       .append(digest.toString())
<                                       .toString();
---
>                               cmd = APOP + " " + username + " " + 
> digest.toString();
204,207c192
<               cmd = new StringBuffer(USER)
<                       .append(' ')
<                       .append(username)
<                       .toString();
---
>               cmd = USER + " " + username;
212,215c197
<               cmd = new StringBuffer(PASS)
<                       .append(' ')
<                       .append(password)
<                       .toString();
---
>               cmd = PASS + " " + password;
220,265d201
<   /**
<    * Attempts to start TLS on the specified connection.
<    * See RFC 2595 for details
<    * @return true if successful, false otherwise
<    */
<   public boolean stls()
<     throws IOException
<   {
<     send(STLS);
<     if (!getResponse())
<       return false;
<     try
<     {
<       // Attempt to instantiate an SSLSocketFactory
<       // This requires introspection, as the class may not be available
in
<       // all runtimes.
<       Class factoryClass =
Class.forName("javax.net.ssl.SSLSocketFactory");
<       java.lang.reflect.Method getDefault =
<         factoryClass.getMethod("getDefault", new Class[0]);
<       Object factory = getDefault.invoke(null, new Object[0]);
<       // Use the factory to negotiate a TLS session and wrap the
current
<       // socket.
<       Class[] pt = new Class[4];
<       pt[0] = Socket.class;
<       pt[1] = String.class;
<       pt[2] = Integer.TYPE;
<       pt[3] = Boolean.TYPE;
<       java.lang.reflect.Method createSocket =
<         factoryClass.getMethod("createSocket", pt);
<       Object[] args = new Object[4];
<       args[0] = socket;
<       args[1] = socket.getInetAddress().getHostName();
<       args[2] = new Integer(socket.getPort());
<       args[3] = Boolean.TRUE;
<       socket = (Socket)createSocket.invoke(factory, args);
<       // set up streams
<       in = new CRLFInputStream(socket.getInputStream());
<       out = new CRLFOutputStream(socket.getOutputStream());
<       return true;
<     }
<     catch (Exception e)
<     {
<       return false;
<     }
<   }
<   
269c205
<       public int stat()
---
>       public synchronized int stat()
293c229
<       public int list(int msgnum)
---
>       public synchronized int list(int msgnum)
296,299c232
<               String cmd = new StringBuffer(LIST)
<                       .append(' ')
<                       .append(msgnum)
<                       .toString();
---
>               String cmd = LIST + " " + msgnum;
319c252
<       public InputStream retr(int msgnum)
---
>       public synchronized InputStream retr(int msgnum)
322,325c255
<               String cmd = new StringBuffer(RETR)
<                       .append(' ')
<                       .append(msgnum)
<                       .toString();
---
>               String cmd = RETR + " " + msgnum;
336c266
<       public void dele(int msgnum)
---
>       public synchronized void dele(int msgnum)
339,342c269
<               String cmd = new StringBuffer(DELE)
<                       .append(' ')
<                       .append(msgnum)
<                       .toString();
---
>               String cmd = DELE + " " + msgnum;
352c279
<       public void noop()
---
>       public synchronized void noop()
363c290
<       public void rset()
---
>       public synchronized void rset()
378c305
<   public boolean quit()
---
>   public synchronized boolean quit()
393c320
<       public InputStream top(int msgnum)
---
>       public synchronized InputStream top(int msgnum)
396,401c323
<               String cmd = new StringBuffer(TOP)
<                       .append(' ')
<                       .append(msgnum)
<                       .append(' ')
<                       .append(0)
<                       .toString();
---
>               String cmd = TOP + " " + msgnum + " 0";
412c334
<       public String uidl(int msgnum)
---
>       public synchronized String uidl(int msgnum)
415,418c337
<               String cmd = new StringBuffer(UIDL)
<                       .append(' ')
<                       .append(msgnum)
<                       .toString();
---
>               String cmd = UIDL + " " + msgnum;
425,446d343
<   /**
<    * Returns a list of capabilities supported by the POP3 server.
<    * If the server does not support POP3 extensions, returns
<    * <code>null</code>.
<    */
<   public List capa()
<     throws IOException
<   {
<     send(CAPA);
<     if (getResponse())
<     {
<       final String DOT = ".";
<       List list = new ArrayList();
<       for (String line = in.readLine();
<           !DOT.equals(line);
<           line = in.readLine())
<         list.add(line);
<       return list;
<     }
<     return null;
<   }
< 
456c353
<       System.err.println("pop3: > "+command);
---
>       Session.log ("POP> "+command);
467c364
<   protected boolean getResponse()
---
>   protected synchronized boolean getResponse()
472c369
<       System.err.println("pop3: < "+response);
---
>       Session.log ("POP< "+response);
diff -r
/usr/src/CVS/classpathx/mail/source/gnu/mail/providers/pop3/POP3Message.java
/usr/src/tiger-0.5.2/thirdparty/classpathx-javamail-customized/mail/source/gnu/mail/providers/pop3/POP3Message.java
35a36
> import javax.mail.Session;
36a38
> import javax.mail.internet.MimeMessage;
48c50,51
<   extends ReadOnlyMessage 
---
> //  extends ReadOnlyMessage 
>   extends MimeMessage 
75c78
<   void fetchContent() 
---
>   synchronized void fetchContent() 
diff -r
/usr/src/CVS/classpathx/mail/source/gnu/mail/providers/pop3/POP3Store.java
/usr/src/tiger-0.5.2/thirdparty/classpathx-javamail-customized/mail/source/gnu/mail/providers/pop3/POP3Store.java
33d32
< import java.util.List;
78,85d76
<     if (connection!=null)
<       return true;
<     if (host==null)
<             host = getProperty("host");
<     if (username==null)
<       username = getProperty("user");
<     if (port<0)
<       port = getIntProperty("port");
87a79,80
>     if (connection!=null)
>       return true;
92,107c85,86
<                               int connectionTimeout =
getIntProperty("connectiontimeout");
<                               int timeout = getIntProperty("timeout");
<                               connection = new POP3Connection(host,
port,
<                                               connectionTimeout,
timeout, session.getDebug());
<         // Disable APOP if necessary
<         if (propertyIsFalse("apop"))
<           connection.timestamp = null;
<         if (!propertyIsFalse("tls"))
<         {
<           List capa = connection.capa();
<           if (capa!=null)
<           {
<             if (capa.contains(POP3Connection.STLS))
<               connection.stls();
<           }
<         }
---
>                               connection = new POP3Connection(host, port);
>                               connection.setDebug(session.getDebug());
133,134d111
<                                       if
(propertyIsTrue("rsetbeforequit"))
<                                               connection.rset();
177,216d153
<   }
< 
<   // -- Utility methods --
< 
<       private int getIntProperty(String key)
<       {
<     String value = getProperty(key);
<               if (value!=null)
<               {
<                       try
<                       {
<                               return Integer.parseInt(value);
<                       }
<                       catch (Exception e)
<                       {
<                       }
<               }
<               return -1;
<       }
< 
<   private boolean propertyIsFalse(String key)
<   {
<     return "false".equals(getProperty(key));
<   }
< 
<   private boolean propertyIsTrue(String key)
<   {
<     return "true".equals(getProperty(key));
<   }
< 
<   /*
<    * Returns the provider-specific or general mail property
corresponding to
<    * the specified key.
<    */
<   private String getProperty(String key)
<   {
<     String value = session.getProperty("mail.pop3."+key);
<     if (value==null)
<       value = session.getProperty("mail."+key);
<     return value;
Only in /usr/src/CVS/classpathx/mail/source/gnu/mail/providers/smtp: CVS
Only in /usr/src/CVS/classpathx/mail/source/gnu/mail/providers/smtp:
SMTPConnection.java
diff -r
/usr/src/CVS/classpathx/mail/source/gnu/mail/providers/smtp/SMTPTransport.java
/usr/src/tiger-0.5.2/thirdparty/classpathx-javamail-customized/mail/source/gnu/mail/providers/smtp/SMTPTransport.java
23a24,26
> import java.io.BufferedInputStream;
> import java.io.BufferedOutputStream;
> import java.io.InputStream;
25a29
> import java.io.UnsupportedEncodingException;
26a31,32
> import java.net.Socket;
> import java.net.SocketException;
29c35
< import java.util.Iterator;
---
> import java.util.HashMap;
30a37
> import java.util.Map;
41a49,52
> import gnu.mail.util.BASE64;
> import gnu.mail.util.CRLFInputStream;
> import gnu.mail.util.CRLFOutputStream;
> import gnu.mail.util.LineInputStream;
46,47c57,78
<  * @author Andrew Selkirk
<  * @author Ben Speakmon
---
>  * <P><B>Important System Properties</B><BR>
>  * 
>  * <UL>
>  *   <LI><code>mail.smtp.port</code> - the port used to connect
>  *       to the SMTP server.
>  *   <LI><code>mail.smtp.timeout</code> - milliseconds
>  *       to wait for a reply from the server before timing out.
>  *   <LI><code>mail.smtp.ehlo</code> - if true, will attempt
>  *       to connect to SMTP server with "EHLO" first.
>  *   <LI><code>mail.smtp.host</code> - the SMTP server to connect
>  *       with.
>  *   <LI><code>mail.smtp.user</code> - the user name to connect as
>  *       (not yet implemented)
>  *   <LI><code>mail.smtp.from</code> - the RFC 2822 address to use 
>  *       as the message sender
>  *   <LI><code>mail.smtp.localhost</code> - the hostname to use
>  *       when identifying the local host to the SMTP server
>  * </UL>
>  *
>  *
>  * @author      Andrew Selkirk
>  * @author      Ben Speakmon
49c80
<  * @version 2.0
---
>  * @version     2.0
55,58c86,92
<   /**
<    * The connection used to communicate with the server.
<    */
<   protected SMTPConnection connection;
---
>   public static final int SMTP_PORT = 25;
>   
>   public static final int READY = 220;
>   public static final int OK = 250;
>   public static final int OK_NOT_LOCAL = 251;
>   public static final int OK_UNVERIFIED = 252;
>   public static final int SEND_DATA = 354;
60c94,98
<   protected String localHostName;
---
>   private static final byte[] CRLF = {13, 10};
> 
>   private Socket socket = null;
>   private LineInputStream in = null;
>   private CRLFOutputStream out = null;
62c100,101
<   private List extensions = null;
---
>   private String localHostName;
> 
76c115
<     localHostName = getProperty("localhost");
---
>     localHostName = session.getProperty("mail.smtp.localhost");
89a129,133
>   void log(String message)
>   {
>     Session.log("smtp: "+message);
>   }
> 
91c135,142
<    * Connects to the SMTP server.
---
>    * Describe <code>protocolConnect</code> method here.
>    *
>    * @param host the SMTP server to connect to
>    * @param port the port to attempt connection on
>    * @param user the user to connect as 
>    * @param password the password to use for authenticating user
>    * @return true if the connection attempt succeeds.
>    * @exception MessagingException if an error occurs
93,94c144,145
<   protected boolean protocolConnect(String host, int port, String
username,
<       String password)
---
>   protected boolean protocolConnect(String host, int port, String user,
>                                     String password)
97,98c148
<     if (connection!=null)
<       return true;
---
> 
100,104c150,170
<       host = getProperty("host");
<     if (port<0)
<       port = getIntProperty("port");
<     if (username==null)
<       username = getProperty("user");
---
>       host = session.getProperty("mail.smtp.host");
>     if (port==-1)
>     {
>       String smtpPort = session.getProperty("mail.smtp.port");
>       if (smtpPort!=null)
>       {
>         try
>         {
>           port = Integer.parseInt(smtpPort);
>         }
>         catch (NumberFormatException e)
>         {
>           throw new MessagingException("Invalid mail.smtp.port value: "+
>               smtpPort);
>         }
>       }
>       else
>           port = SMTP_PORT;
>     }
>     if (user==null)
>       user = session.getProperty("mail.smtp.user");
108c174,175
<       throw new MessagingException("No SMTP host set
(mail.smtp.host)");
---
>       throw new MessagingException("No SMTP host has been set "+
>           "(mail.smtp.host)");
110c177
<     try
---
>     try 
112,115c179,180
<       int connectionTimeout = getIntProperty("connectiontimeout");
<       int timeout = getIntProperty("timeout");
<       connection = new SMTPConnection(host, port,
<           connectionTimeout, timeout, session.getDebug());
---
>       // Create Server Socket
>       socket = new Socket(host, port);
117,118c182,184
<       // EHLO/HELO
<       if (propertyIsFalse("ehlo"))
---
>       // Check for "mail.smtp.timeout" option
>       String smtpTimeout = session.getProperty("mail.smtp.timeout");
>       if (smtpTimeout!=null) 
120,126c186
<         if (!connection.helo(localHostName))
<           throw new MessagingException("HELO failed:
"+connection.response);
<       }
<       else
<       {
<         extensions = connection.ehlo(localHostName);
<         if (extensions==null)
---
>         try
128,129c188,192
<           if (!connection.helo(localHostName))
<             throw new MessagingException("HELO failed:
"+connection.response);
---
>           socket.setSoTimeout(Integer.parseInt(smtpTimeout));
>         } 
>         catch (SocketException se)
>         {
>           log("WARNING: unable to set socket timeout property");
131c194
<         else
---
>         catch (NumberFormatException e)
133,151c196,197
<           for (Iterator i=extensions.iterator(); i.hasNext(); )
<           {
<             String extension = (String)i.next();
<             if (extension.startsWith("AUTH "))
<             {
<               // Populate authenticationMechanisms
<               authenticationMechanisms = new ArrayList();
<               StringTokenizer st = new
StringTokenizer(extension.substring(5));
<               while (st.hasMoreTokens())
<                 authenticationMechanisms.add(st.nextToken());
<             }
<             else if (SMTPConnection.STARTTLS.equals(extension))
<             {
<               if (!propertyIsFalse("tls"))
<               {
<                 connection.starttls();
<               }
<             }
<           }
---
>           throw new MessagingException("Invalid mail.smtp.timeout value: "+
>               smtpTimeout);
153a200,217
>     
>       in = new LineInputStream (
>         new CRLFInputStream(
>             socket.getInputStream()));
>       out = new CRLFOutputStream(
>             socket.getOutputStream());
>       
>       // Greeting
>       Response greeting = readResponse();
>       if (greeting.code!=READY)
>         throw new MessagingException("Server not ready");
>       
>       // EHLO/HELO
>       String smtpEhlo = session.getProperty("mail.smtp.ehlo");
>       if (smtpEhlo==null || new Boolean(smtpEhlo).booleanValue())
>         helo(localHostName);
>       else if (!ehlo(localHostName)) 
>         helo(localHostName);
157,158c221
<           !authenticationMechanisms.isEmpty() &&
<           propertyIsTrue("auth"))
---
>           !authenticationMechanisms.isEmpty())
160c223
<         if (username!=null && password!=null)
---
>         if (user!=null && password!=null)
164,167c227
<           {
<             if (connection.authLogin(username, password))
<               return (connection.ehlo(localHostName)!=null);
<           }
---
>             return authLogin(user, password);
169c229
<             return connection.authPlain(username, password);
---
>             return authPlain(user, password);
171c231
<             System.err.println("smtp: No supported authentication
mechanisms");
---
>             log("No supported authentication mechanisms");
175d234
<       return true;
179c238,240
<       throw new MessagingException(e.getMessage(), e);
---
>       if (session.getDebug())
>         log(e.getMessage());
>       return false;
180a242
>     return true;
184c246,251
<    * Send the specified message to the server.
---
>    * Sends the SMTP message to the server.
>    *
>    * @param message the Message to send
>    * @param addresses the Addresses to send the Message to 
>    * @exception MessagingException if an error occurs
>    * @exception SendFailedException if an error occurs
186c253,254
<   public void sendMessage(Message message, Address[] addresses)
---
>   public void sendMessage(Message message,
>       Address[] addresses)
199d266
<     ParameterList params = null; // ESMTP parameters
201c268
<     synchronized (connection)
---
>     synchronized (this)
205a273,279
>       // MAIL FROM
>       mailFrom(mimeMessage);
>       
>       // RCPT TO
>       rcptTo(addresses, sent, invalid);
>       
>       // DATA
208,325c282,286
<         // reverse-path
<         String from0 = getProperty("from");
<         InternetAddress from = null;
<         if (from0!=null)
<         {
<           InternetAddress[] from1 = InternetAddress.parse(from0);
<           if (from1!=null && from1.length>0)
<             from = from1[0];
<         }
<         if (from==null)
<         {
<           Address[] from2 = mimeMessage.getFrom();
<           if (from2!=null && from2.length>0 &&
<               from2[0] instanceof InternetAddress)
<             from = (InternetAddress)from2[0];
<         }
<         if (from==null)
<           from = InternetAddress.getLocalAddress(session);
<         String reversePath = from.getAddress();
<         // DSN RET
<         String dsnRet = getProperty("dsn.ret");
<         if (dsnRet!=null)
<         {
<           String FULL = "FULL", HDRS = "HDRS";
<           String value = null;
<           if (FULL.equalsIgnoreCase(dsnRet))
<             value = FULL;
<           else if (HDRS.equalsIgnoreCase(dsnRet))
<             value = HDRS;
<           if (value!=null)
<           {
<             params = new ParameterList();
<             params.add(new Parameter("RET", value));
<           }
<         }
<         // MAIL FROM
<         if (!connection.mailFrom(reversePath, params))
<           throw new SendFailedException(connection.response);
<         params = null;
<        
<         // DSN NOTIFY
<         String dsnNotify = getProperty("dsn.notify");
<         if (dsnNotify!=null)
<         {
<           String NEVER = "NEVER", SUCCESS = "SUCCESS";
<           String FAILURE = "FAILURE", DELAY = "DELAY";
<           String value = null;
<           if (NEVER.equalsIgnoreCase(dsnNotify))
<             value = NEVER;
<           else
<           {
<             StringBuffer buf = new StringBuffer();
<             StringTokenizer st = new StringTokenizer(dsnNotify, " ,");
<             while (st.hasMoreTokens())
<             {
<               String token = st.nextToken();
<               if (SUCCESS.equalsIgnoreCase(token))
<               {
<                 if (buf.length()>0)
<                   buf.append(',');
<                 buf.append(SUCCESS);
<               }
<               else if (FAILURE.equalsIgnoreCase(token))
<               {
<                 if (buf.length()>0)
<                   buf.append(',');
<                 buf.append(FAILURE);
<               }
<               else if (DELAY.equalsIgnoreCase(token))
<               {
<                 if (buf.length()>0)
<                   buf.append(',');
<                 buf.append(DELAY);
<               }
<             }
<             if (buf.length()>0)
<               value = buf.toString();
<           }
<           if (value!=null)
<           {
<             params = new ParameterList();
<             params.add(new Parameter("NOTIFY", value));
<           }
<         }
<         // RCPT TO
<         for (int i=0; i<addresses.length; i++)
<         {
<           Address address = addresses[i];
<           if (address instanceof InternetAddress)
<           {
<             String forwardPath =
((InternetAddress)address).getAddress();
<             if (connection.rcptTo(forwardPath, params))
<               sent.add(address);
<             else
<               invalid.add(address);
<           }
<           else
<             invalid.add(address);
<         }
<         
<         // DATA
<         OutputStream dataStream = connection.data();
<         if (dataStream==null)
<           throw new MessagingException(connection.response);
<         mimeMessage.writeTo(dataStream);
<         dataStream.flush();
<         if (connection.finishData())
<         {
<           unsent.addAll(sent);
<           sent.clear();
<           deliveryStatus = TransportEvent.MESSAGE_NOT_DELIVERED;
<         }
<         else 
<         {
<           deliveryStatus = invalid.isEmpty() ?
<             TransportEvent.MESSAGE_DELIVERED :
<             TransportEvent.MESSAGE_PARTIALLY_DELIVERED;
<         }
---
>         if (simpleCommand("DATA")!=SEND_DATA)
>           throw new MessagingException("Error sending data");
>         SMTPOutputStream sout = new SMTPOutputStream(out);
>         mimeMessage.writeTo(sout);
>         sout.flush();
330a292
>       deliveryStatus = finishData(sent, unsent, invalid);
346c308,311
<    * Close this transport.
---
>    * Close our streams and sockets. This will be called by
>    * the superclass after our sendMessage() returns.
>    *
>    * @exception MessagingException if an error occurs
348c313
<   public void close()
---
>   public synchronized void close()
350a316
>     // Check if connection is Open
353c319
<       synchronized (connection)
---
>       try 
355,366c321
<         try 
<         {
<           connection.quit();
<         }
<         catch (IOException e) 
<         {
<           throw new MessagingException(e.getMessage(), e);
<         }
<         finally
<         {
<           connection = null;
<         }
---
>         simpleCommand("QUIT");
368c323,340
<     }
---
>       catch (Exception e) 
>       {
>       }
>         
>       try 
>       {
>         // Close streams
>         out.close();
>         in.close();
>         socket.close();
>         out = null;
>         in = null;
>         socket = null;
>       } 
>       catch (IOException e) 
>       {
>       }
>     } 
371,372d342
<   
<   // -- Utility methods --
374c344,352
<   private int getIntProperty(String key)
---
>   /**
>    * Checks lines of input from the server and returns true
>    * if the server has finished sending this reply to us.
>    * This may happen in response to EHLO or HELP commands.
>    *
>    * @param value a line of input from the SMTP server
>    * @return true if the server is waiting for us now.
>    */
>   private boolean isNotLastLine(String value) 
376,377c354,410
<     String value = getProperty(key);
<     if (value!=null)
---
>     // Check for space after code
>     return (value.charAt(3)!=' ');
>   }
> 
>   /**
>    * Send a ELHO command to the SMTP server.  Since it is possible
>    * that the SMTP server doesn't support extensions, false would be
>    * returned in such a scenario.  Otherwise, if there is a problem,
>    * an exception should be thrown.
>    *
>    * @param domain EHLO domain for handshaking
>    * @returns true if SMTP extensions are supported, false otherwise
>    * @exception MessagingException Problem has occurred
>    */
>   private boolean ehlo(String domain)
>     throws MessagingException 
>   {
>     String command = new StringBuffer("EHLO ")
>       .append(domain)
>       .toString();
>     sendCommand(command);
>     while (true)
>     {
>       Response response = readResponse();
>       if (response.text.startsWith("AUTH "))
>       {
>         authenticationMechanisms = new ArrayList();
>         StringTokenizer st = new StringTokenizer(response.text.substring(5));
>         while (st.hasMoreTokens())
>           authenticationMechanisms.add(st.nextToken());
>       }
>       if (response.last)
>         return (response.code==OK);
>     }
>   }
> 
>   /**
>    * Send a HELO command to the SMTP server.  If there is a problem,
>    * an exception should be thrown.
>    * @param domain HELO domain for handshaking
>    * @exception MessagingException Problem has occurred
>    */
>   private void helo(String domain) throws MessagingException 
>   {
>     String command = new StringBuffer("HELO ")
>       .append(domain)
>       .toString();
>     simpleCommand(command);
>   }
> 
>   /**
>    * LOGIN authentication mechanism.
>    */
>   private boolean authLogin(String username, String password)
>     throws MessagingException
>   {
>     if (simpleCommand("AUTH LOGIN")==334)
381c414,428
<         return Integer.parseInt(value);
---
>         String US_ASCII = "US-ASCII";
>         byte[] bytes = username.getBytes(US_ASCII);
>         String encoded = new String(BASE64.encode(bytes), US_ASCII);
>         if (simpleCommand(encoded)==334)
>         {
>           bytes = password.getBytes(US_ASCII);
>           encoded = new String(BASE64.encode(bytes), US_ASCII);
>           if (simpleCommand(encoded)==235)
>             return ehlo(localHostName); // Re-issue EHLO
>         }
>       }
>       catch (UnsupportedEncodingException e)
>       {
>         // Should not happen according to JDK docs
>         throw new MessagingException(e.getMessage(), e);
383,385d429
<       catch (Exception e)
<                                             {
<                                             }
387c431
<                     return -1;
---
>     return false;
389,390c433,438
<   
<   private boolean propertyIsFalse(String key)
---
> 
>   /**
>    * PLAIN authentication mechanism.
>    */
>   private boolean authPlain(String username, String password)
>     throws MessagingException
392c440,460
<     return "false".equals(getProperty(key));
---
>     try
>     {
>       String plain = new StringBuffer(username)
>         .append('\u0000')
>         .append(username)
>         .append('\u0000')
>         .append(password)
>         .toString();
>       String US_ASCII = "US-ASCII";
>       byte[] bytes = plain.getBytes(US_ASCII);
>       String encoded = new String(BASE64.encode(bytes), US_ASCII);
>       String command = new StringBuffer("AUTH PLAIN ")
>         .append(encoded)
>         .toString();
>       return (simpleCommand(command)==235);
>     }
>     catch (UnsupportedEncodingException e)
>     {
>       // Should not happen according to JDK docs
>       throw new MessagingException(e.getMessage(), e);
>     }
394,395c462,470
<   
<   private boolean propertyIsTrue(String key)
---
> 
>   /**
>    * Offers our mail sender(s) to the SMTP server.
>    *
>    * @exception SendFailedException if no valid message sender is found.
>    * @exception MessagingException for any other error cause.
>    */
>   private void mailFrom(MimeMessage message)
>     throws SendFailedException, MessagingException 
397c472,497
<     return "true".equals(getProperty(key));
---
>     Address from = null;
>     String smtpFrom = session.getProperty("mail.smtp.from");
>     if (smtpFrom!=null)
>       from = new InternetAddress(smtpFrom);
>     if (from==null)
>     {
>       Address[] f = message.getFrom(); // returns Sender if From absent
>       if (f!=null && f.length>0)
>         from = f[0];
>     }
>     if (from==null)
>       throw new SendFailedException("No valid message sender specified");
>     
>     String command = new StringBuffer("MAIL FROM:<")
>       .append(from.toString())
>       .append(">")
>       .toString();
>     switch (simpleCommand(command))
>     {
>       case OK:
>       case OK_NOT_LOCAL:
>       case OK_UNVERIFIED:
>         break;
>       default:
>         throw new SendFailedException("Sender "+from+" rejected");
>     }
399,409c499,549
<   
<   /*
<    * Returns the provider-specific or general mail property
corresponding to
<    * the specified key.
<    */
<   private String getProperty(String key)
<   {
<     String value = session.getProperty("mail.pop3."+key);
<     if (value==null)
<       value = session.getProperty("mail."+key);
<     return value;
---
> 
>   /**
>    * Send list of mail recipients to SMTP server.  Keeps track
>    * of which messages are valid/invalid.
>    *
>    * @exception SendFailedException Problem has occurred
>    */
>   private void rcptTo(Address[] addresses, List sent, List invalid)
>     throws SendFailedException, MessagingException 
>   {
>     for (int i=0; i<addresses.length; i++) 
>     {
>       String command = new StringBuffer("RCPT TO:<")
>         .append(addresses[i].toString())
>         .append(">")
>         .toString();
>       switch (simpleCommand(command))
>       {
>         case OK:
>         case OK_NOT_LOCAL:
>         case OK_UNVERIFIED:
>           sent.add(0, addresses[i]);
>           break;
>         default:
>           invalid.add(0, addresses[i]);
>       }
>     }
>     if (sent.isEmpty())
>       throw new SendFailedException("No valid mail recipients specified");    
>   }
> 
>   /**
>    * Send end-of-data tag to SMTP server.
>    * @exception MessagingException Problem has occurred
>    */
>   private int finishData(List sent, List unsent, List invalid)
>     throws MessagingException 
>   {
>     String dataEnd = "\r\n.\r\n";
>     if (simpleCommand(dataEnd)!=OK)
>     {
>       unsent.addAll(sent);
>       sent.clear();
>       return TransportEvent.MESSAGE_NOT_DELIVERED;
>     }
>     else 
>     {
>       return invalid.isEmpty() ?
>         TransportEvent.MESSAGE_DELIVERED :
>         TransportEvent.MESSAGE_PARTIALLY_DELIVERED;
>     }
411a552,644
>   private Response readResponse()
>     throws MessagingException
>   {
>     String line = null;
>     try
>     {
>       line = in.readLine();
>       // Handle special case eg 334 where CRLF occurs after code.
>       if (line.length()<4)
>         line = new StringBuffer(line)
>           .append('\n')
>           .append(in.readLine())
>           .toString();
>       return new Response(line);
>     } 
>     catch (IOException e)
>     {
>       throw new MessagingException(e.getMessage(), e);
>     }
>     catch (NumberFormatException e)
>     {
>       throw new MessagingException("Unexpected response: "+line);
>     }
>     finally
>     {
>       if (session.getDebug())
>         log("< " + line);
>     }
>   }
> 
>   /**
>    * Write a command to the SMTP server and parse the response.
>    * @param command Command to send
>    * @returns Return code from SMTP server
>    * @exception MessagingException Problem has occurred
>    */
>   private int simpleCommand(String command)
>     throws MessagingException 
>   {
>     sendCommand(command);
>     Response response = readResponse();
>     while (!response.last)
>       response = readResponse();
>     return response.code;
>   }
> 
>   /**
>    * Send command to SMTP server.
>    * @param command Command to send
>    * @exception MessagingException Problem has occurred
>    */
>   private void sendCommand(String command)
>     throws MessagingException 
>   {
>     try 
>     {
>       out.write(command.getBytes());
>       out.write(CRLF);
>       out.flush();
>     } 
>     catch (IOException e) 
>     {
>       throw new MessagingException(e.getMessage(), e);
>     }
>     finally
>     {
>       if (session.getDebug()) 
>         log("> " + command);
>     }
>   }
> 
>   /**
>    * Models and parses an SMTP server response.
>    */
>   static class Response
>   {
>     int code;
>     boolean last;
>     String text;
> 
>     Response(String line)
>     {
>       code = Integer.parseInt(line.substring(0, 3));
>       last = (line.charAt(3)!='-');
>       text = line.substring(4);
>     }
> 
>     boolean success()
>     {
>       return (code>=200 && code<300);
>     }
>   }
> 
Only in /usr/src/CVS/classpathx/mail/source/gnu/mail/treeutil: CVS
diff -r
/usr/src/CVS/classpathx/mail/source/gnu/mail/util/CRLFInputStream.java
/usr/src/tiger-0.5.2/thirdparty/classpathx-javamail-customized/mail/source/gnu/mail/util/CRLFInputStream.java
3c3
<  * Copyright (C) 2002 The Free Software Foundation
---
>  * Copyright (C) 2003 Doug Porter
30c30,33
< import java.io.*;
---
> import java.io.BufferedInputStream;
> import java.io.FilterInputStream;
> import java.io.InputStream;
> import java.io.IOException;
31a35
> import javax.mail.Session;
33a38,42
>  * <p>
>  * This class should probably be deprecated. Too many other classes, such as 
>  * LineInputStream and DotTerminatedInputStream, don't know whether this 
> class wraps
>  * their inner input streams. Those classes currently have to accomodate for 
> lines
>  * ending in both LF and CRLF.
35c44
<  * @author <a href="mailto:address@hidden";>Chris Burdess</a>
---
>  * @author Doug Porter
38,120c47,52
<   extends PushbackInputStream
< {
< 
<   /**
<    * The CR octet.
<    */
<   public static final int CR = 13;
< 
<   /**
<    * The LF octet.
<    */
<   public static final int LF = 10;
< 
<   /**
<    * Constructs a CR/LF input stream connected to the specified input
<    * stream.
<    */
<   public CRLFInputStream(InputStream in) 
<   {
<     super(in, 4096);
<   }
< 
<   /**
<    * Constructs a CR/LF input stream connected to the specified input
<    * stream, with the specified pushback buffer size.
<    */
<   public CRLFInputStream(InputStream in, int bufsize)
<   {
<     super(in, bufsize);
<   }
< 
<   /**
<    * Reads the next byte of data from this input stream.
<    * Returns -1 if the end of the stream has been reached.
<    * @exception IOException if an I/O error occurs
<    */
<   public int read()
<     throws IOException
<   {
<     int c = super.read();
<     if (c==CR) // skip CR
<       return super.read();
<     return c;
<   }
< 
<   /**
<    * Reads up to b.length bytes of data from this input stream into
<    * an array of bytes.
<    * Returns -1 if the end of the stream has been reached.
<    * @exception IOException if an I/O error occurs
<    */
<   public int read(byte[] b)
<     throws IOException
<   {
<     return read(b, 0, b.length);
<   }
< 
<   /**
<    * Reads up to len bytes of data from this input stream into an
<    * array of bytes, starting at the specified offset.
<    * Returns -1 if the end of the stream has been reached.
<    * @exception IOException if an I/O error occurs
<    */
<   public int read(byte[] b, int off, int len)
<     throws IOException
<   {
<     int l = doRead(b, off, len);
<     l = removeCRs(b, off, l);
<     return l;
<   }
< 
<   /*
<    * Slight modification of PushbackInputStream.read() not to do a
<    * blocking read on the underlying stream if there are bytes in the
<    * buffer.
<    */
<   private int doRead(byte[] b, int off, int len)
<     throws IOException
<   {
<     if (len<=0)
<       return 0;
<     int avail = buf.length-pos;
<     if (avail>0)
---
>   extends ReadFilterInputStream
> {   
>     /**
>     * Constructs an LF input stream from the specified CR/LF input stream.
>     */
>     public CRLFInputStream (InputStream in) 
122,127c54,55
<       if (len<avail)
<       avail = len;
<       System.arraycopy(buf, pos, b, off, avail);
<       pos += avail;
<       off += avail;
<       len -= avail;
---
>         // we need mark/reset
>         super (in.markSupported () ? in : new BufferedInputStream (in));
129,143c57,63
<     else if (len>0)
<     {
<       len = super.read(b, off, len);
<       if (len==-1)
<         return avail == 0 ? -1 : avail;
<       return avail + len;
<     }
<     return avail;
<   }
< 
<   /**
<    * Reads a line of input terminated by LF.
<    * @exception IOException if an I/O error occurs
<    */
<   public String readLine()
---
>     
>     /**
>     * Reads the next byte of data from this input stream, converting CR/LF to 
> LF.
>     * Returns -1 if the end of the stream has been reached.
>     * @exception IOException if an I/O error occurs
>     */
>     public int read ()
145,148d64
<   {
<     StringBuffer sb = new StringBuffer();
<     boolean done = false, eos = false;
<     while (!done)
150,169c66,86
<       byte[] b = new byte[buf.length];
<       int l = read(b);
<       if (l==-1)
<       {
<         done = true;
<         eos = true;
<       }
<       else
<       {
<         for (int i=0; i<l; i++)
<         {
<           if (b[i]==LF)
<           {
<             if (i>0)
<               sb.append(new String(b, 0, i));
<             if (l-(i+1)>0)
<               unread(b, i+1, (l-i)-1);
<             done = true;
<             break;
<           }
---
>         // carriage return/line feed
>         final int CR = 13;
>         final int LF = 10;
>     
>         // max bytes to save for mark/reset
>         final int MarkReadLimit = 5;
>         
>         int c = super.read();
>         if (c == CR) {
>         
>             // look ahead one byte
>             mark (MarkReadLimit);
>             c = super.read ();
>             if (c != LF) {
>                 
>                 // keep any CR in the middle of a line
>                 reset ();
>                 c = CR;
>                 
>             }
>             
171,173c88,89
<         if (!done && l>0)
<           sb.append(new String(b, 0, l));
<       }
---
>         
>         return c;
175,201d90
<     if (eos && sb.length()<1)
<       return null;
<     else
<       return sb.toString();
<   }
< 
<   private int removeCRs(byte[] b, int off, int len)
<   {
<     for (int index = indexOfCR(b, off, len);
<         index>-1;
<         index = indexOfCR(b, off, len))
<     {
<       for (int i=index; i<b.length-1; i++)
<         b[i] = b[i+1];
<       len--;
<     }
<     return len;
<   }
< 
<   private int indexOfCR(byte[] b, int off, int len)
<   {
<     for (int i=off; i<off+len; i++)
<       if (b[i]==CR)
<         return i;
<     return -1;
<   }
< 
Only in /usr/src/CVS/classpathx/mail/source/gnu/mail/util: CVS
Only in
/usr/src/tiger-0.5.2/thirdparty/classpathx-javamail-customized/mail/source/gnu/mail/util:
DotTerminatedInputStream.java
diff -r
/usr/src/CVS/classpathx/mail/source/gnu/mail/util/LineInputStream.java
/usr/src/tiger-0.5.2/thirdparty/classpathx-javamail-customized/mail/source/gnu/mail/util/LineInputStream.java
3c3
<  * Copyright (C) 2002 The Free Software Foundation
---
>  * Copyright (C) 2003 Doug Porter
30c30,35
< import java.io.*;
---
> import java.io.ByteArrayOutputStream;
> import java.io.IOException;
> import java.io.InputStream;
> 
> import javax.mail.MessagingException;
> import javax.mail.Session;
35c40
<  * @author <a href="mailto:address@hidden";>Chris Burdess</a>
---
>  * @author Doug Porter
38c43
<   extends FilterInputStream
---
>   extends ReadFilterInputStream
40,73c45,51
< 
<   private char[] line;
<   private static final int LF = 10, CR = 13;
< 
<   /**
<    * Constructor.
<    */
<   public LineInputStream(InputStream in)
<   {
<     this(in, 80);
<   }
<   
<   /**
<    * Constructor.
<    * @param in the underlying input stream
<    * @param size the buffer size
<    */
<   public LineInputStream(InputStream in, int size)
<   {
<     super(in);
<     line = new char[size];
<   }
< 
<   /**
<    * Read a line of input.
<    */
<   public String readLine()
<     throws IOException
<   {
<     char[] chars = line;
<     int len = chars.length;
<     int pos = 0;
<     int c;
<     for (c = in.read(); c!=-1; c = in.read()) 
---
>     
>     private boolean isDataAvailable = false;    
>     
>     /**
>     * Constructor.
>     */
>     public LineInputStream (InputStream in)
75,85c53,110
<       if (c==LF)
<         break;
<       if (c==CR)
<       {
<         // Peek ahead
<         int peek = in.read();
<         if (peek!=LF)
<         {
<           if (!(in instanceof PushbackInputStream))
<             in = new PushbackInputStream(in);
<           ((PushbackInputStream)in).unread(peek);
---
>         super (in);
>     }
>   
>     
>     /** Read the next line of text without character encoding.
>      *
>      *  The contract is as for <code>DataInput.readLine</code>, except CR is 
> accepted
>      *  before the end of the line.
>      *
>      * @return Line.
>      */
>     public String readLine ()
>     throws IOException {
>         
>         final int EOF = -1;
>         final int CR = 13;
>         final int LF = 10;
>         
>         ByteArrayOutputStream buffer = new ByteArrayOutputStream ();
>         int c;
>         String line = null;
>         
>         try {
>             
>             c = read ();
>             isDataAvailable = (c != EOF);
>             
>             while (c != LF &&
>                    c != EOF) {
>     
>                 /* plain DataInput.readLine contract
>                 if (c != CR) {
>                     
>                     buffer.write (c);
>                     
>                 }
>                 
>                 c = read ();
>                 */
>                 
>                 if (c == CR) {
>                 
>                     // look ahead one byte
>                     c = read ();
>                     if (c != LF) {
>                         buffer.write (CR);
>                     }
>                     
>                 }
>                 else {
>                     buffer.write (c);
>                     c = read ();
>                 }
>             }
>         }
>         catch (IOException ioe) {
>             isDataAvailable = false;
>             throw ioe;
87,98c112,121
<         break;
<       }
<       len--;
<       if (len<0)
<       {
<         chars = new char[pos+line.length];
<         len = (chars.length-pos)-1;
<         System.arraycopy(line, 0, chars, 0, len+1);
<         line = chars;
<       }
<       chars[pos] = (char)c;
<       pos++;
---
>         
>         if (isDataAvailable) {
>             
>             // Contrary to its spec, ByteArrayOutputStream.toString(0) does 
> character encoding,
>             // at least in Sun's 1.4.1 jvm. So there is no point in using it 
> here.
>             line = buffer.toString ();
>             
>         }
>         
>         return line;
100,105c123
<     if (c==-1 && pos==0)
<       return null;
<     else
<       return new String(chars, 0, pos);
<   }
< 
---
>     
diff -r
/usr/src/CVS/classpathx/mail/source/gnu/mail/util/MessageInputStream.java
/usr/src/tiger-0.5.2/thirdparty/classpathx-javamail-customized/mail/source/gnu/mail/util/MessageInputStream.java
3c3
<  * Copyright (C) 2002 The Free Software Foundation
---
>  * Copyright (C) 2003 Doug Porter
30c30,35
< import java.io.*;
---
> import java.io.BufferedInputStream;
> import java.io.FilterInputStream;
> import java.io.InputStream;
> import java.io.IOException;
> 
> import javax.mail.Session;
33c38,45
<  * A utility class for feeding message contents to messages.
---
>  * An input stream for messages and message headers that terminates on 
>  * a dot line as well as end of stream, and that includes a readLine method.
>  * <p>
>  * Be sure here to inherit, directly or indirectly, from classes that add
>  * functions, and to wrap the stream in the constructor with classes that
>  * are simply subclasses of FilterInputStream.
>  * <p>
>  * We may want to merge MessageInputStream and DotTerminatedInputStream.
35c47
<  * @author <a href="mailto:address@hidden";>Chris Burdess</a>
---
>  * @author Doug Porter
38c50
<       extends FilterInputStream
---
> extends LineInputStream
40,115c52,53
<       
<       /**
<        * The stream termination octet.
<        */
<       public static final int END = 46;
<       
<       /**
<        * The line termination octet.
<        */
<       public static final int LF = 10;
<       
<       boolean done = false, debug = false;
<       private boolean lf = false, lf_end = false;
<       
<       /**
<        * Constructs a message input stream connected to the specified
pushback input stream.
<        */
<       public MessageInputStream(PushbackInputStream in)
<       {
<               super(in);
<       }
<       
<       /**
<        * Constructs a message input stream connected to the specified
pushback input stream.
<        */
<       public MessageInputStream(PushbackInputStream in, boolean debug)
<       {
<               super(in);
<               this.debug = debug;
<       }
<       
<       /**
<        * Reads the next byte of data from this message input stream.
<        * Returns -1 if the end of the message stream has been reached.
<        * @exception IOException if an I/O error occurs
<        */
<       public int read()
<               throws IOException
<       {
<               if (done) return -1;
<               int ch = in.read();
<               if (lf && lf_end)
<               {
<                       int ch2 = in.read(); // look ahead for LF
<                       if (ch2==LF)
<                       {
<                               done = true;
<                               return -1; // swallow the END and LF
<                       }
<                       else
<                       {
<                               ((PushbackInputStream)in).unread(ch2);
<                               lf = lf_end = false;
<                       }
<               }
<               else if (lf)
<               {
<                       if (ch==END)
<                               lf_end = true;
<               }
<               else if (ch==LF)
<               {
<                       lf = true;
<               }
<               else
<               {
<                       lf = lf_end = false;
<               }
<               return ch;
<       }
<       
<       /**
<        * Reads up to b.length bytes of data from this input stream into
<        * an array of bytes.
<        * Returns -1 if the end of the stream has been reached.
<        * @exception IOException if an I/O error occurs
---
>     /**
>        * Constructs a message input stream from the specified input stream.
117,252c55
<       public int read(byte[] b)
<               throws IOException
<       {
<               return read(b, 0, b.length);
<       }
<       
<       /**
<        * Reads up to len bytes of data from this input stream into an
<        * array of bytes, starting at the specified offset.
<        * Returns -1 if the end of the stream has been reached.
<        * @exception IOException if an I/O error occurs
<        */
<       public int read(byte[] b, int off, int len)
<               throws IOException
<       {
<               if (done) return -1;
<               int l = doRead(b, off, len);
<               int i = indexOfEnd(b, off, l);
<               if (i>=0)
<               {
<                       ((PushbackInputStream)in).unread(b, i+off+2,
(l-(i+2)));
<                       done = true;
<                       l = i;
<               }
<               else if ((l>0) && b[l-1]==LF)
<               {
<                       lf = true;
<                       l--;
<               }
<               else if ((l>1) && (b[l-2]==LF && b[l-1]==END))
<               {
<                       lf_end = true;
<                       l-=2;
<               }
<               if (debug)
<               {
<                       System.err.println("DEBUG: stream: read "+l+"
bytes");
<                       System.err.println(new String(b, off, l));
<               }
<               return l;
<       }
<       
<       // Prefixes a read with special LF or LF&END combinations if
necessary
<       private int doRead(byte[] b, int off, int len)
<               throws IOException
<       {
<               int l = 0;
<               if (lf_end)
<               {
<                       b[off] = LF;
<                       b[off+1] = END;
<                       l += 2;
<               }
<               else if (lf)
<               {
<                       b[off] = LF;
<                       l++;
<               }
<               l += in.read(b, off+l, len-l);
<               lf_end = lf = false;
<               return l;
<       }
<       
<       /**
<        * Reads a line of input from this input stream.
<        */
<       public String readLine()
<               throws IOException
<       {
<               if (done)
<                       return null;
<               StringBuffer buf = new StringBuffer();
<               int l = 1024;
<               byte[] b = new byte[l];
<               l = doRead(b, 0, l);
<               if (l<0)
<                       return null;
<               while (l>-1 && !done)
<               {
<                       int i = indexOfEnd(b, 0, l);
<                       if (b[0]==END && (b[1]==LF || b[1]==0))
<                       {
<                               done = true;
<                               return null;
<                       }
<                       else if (b[0]==LF && b[1]==END && (b[2]==LF ||
b[2]==0))
<                       {
<                               done = true;
<                               return null;
<                       }
<                       else if (i>0)
<                       {
<                               ((PushbackInputStream)in).unread(b, i+2,
(l-(i+2)));
<                               l = i;
<                       }
<                       else if ((l>0) && b[l-1]==LF)
<                       {
<                               lf = true;
<                               l--;
<                       }
<                       else if ((l>1) && (b[l-2]==LF && b[l-1]==END))
<                       {
<                               lf_end = true;
<                               l-=2;
<                       }
<                       i = indexOfLF(b, 0, l);
<                       if (i>=0)
<                       {
<                               ((PushbackInputStream)in).unread(b, i+1,
l-i);
<                               buf.append(new String(b, 0, i));
<                               break;
<                       }
<                       else
<                       {
<                               buf.append(new String(b, 0, l));
<                       }
<                       l = doRead(b, 0, l);
<               }
<               if (debug)
<               {
<                       System.err.println("DEBUG: stream: readLine:
"+buf.toString());
<               }
<               return buf.toString();
<       }
<       
<       // Discover the index of END in a byte array.
<       int indexOfEnd(byte[] b, int off, int len)
<       {
<               for (int i=off+2; i<(off+len); i++)
<                       if (b[i]==LF && b[i-1]==END && b[i-2]==LF)
<                               return i-off-1;
<               return -1;
<       }
<       
<       // Discover the index of LF in a byte array.
<       int indexOfLF(byte[] b, int off, int len)
---
>       public MessageInputStream (InputStream in)
254,257c57
<               for (int i=off; i<(off+len); i++)
<                       if (b[i]==LF)
<                               return i;
<               return -1;
---
>               super (new DotTerminatedInputStream (in));
259c59,117
<       
---
>     
>     /**
>      * Log the class and superclasses for the given stream, and for
>      * FilterInputStreams the class and superclasses of FilterInputStream.in.
>      * <p>
>      * We may want to put this in a different class.
>      *
>      * @param stream The input stream to log
>      */
>     public static void logClass (InputStream stream)
>     {
>         Class thisClass = stream.getClass ();
>         logClass (thisClass.toString() + " classes and superclasses:", 
> stream);
>       }
>     
>     /**
>      * Log the class and superclasses for the given stream, and for
>      * FilterInputStreams the class and superclasses of FilterInputStream.in.
>      * <p>
>      * We may want to put this in a different class.
>      *
>      * @param stream The input stream to log
>      */
>     public static void logClass (String  message,
>                                  InputStream stream)
>     {
>         Session.log (message);
>         
>         Class thisClass = stream.getClass ();
>         
>         if (stream instanceof FilterInputStream) {
>             
>             try {
>                 // find FilterInputStream
>                 final String FilterInputClass = "class 
> java.io.FilterInputStream";
>                 Class superClass = thisClass;
>                 while (! superClass.toString ().equals (FilterInputClass)) {
>                     
>                     superClass = superClass.getSuperclass ();
>                     Session.log ("    " + superClass.toString());
>                 }
>                 
>                 // find FilterInputStream.in
>                 java.lang.reflect.Field inField = 
> superClass.getDeclaredField("in");
>                 InputStream innerStream = (java.io.InputStream) 
> inField.get(stream);
>                 Session.log (thisClass.toString() + ".in follows");
>                 
>                 // recurse
>                 logClass (innerStream);
>             }
>             catch (Exception e) {
>                 Session.log (thisClass.toString() + ": " + e);
>                 e.printStackTrace ();
>             }
>         }
>         else {
>             Session.logClass (stream);
>         }
>     }
Only in
/usr/src/tiger-0.5.2/thirdparty/classpathx-javamail-customized/mail/source/gnu/mail/util:
MimeMultipartInputStream.java
Only in
/usr/src/tiger-0.5.2/thirdparty/classpathx-javamail-customized/mail/source/gnu/mail/util:
ReadFilterInputStream.java
Only in /usr/src/CVS/classpathx/mail/source/javax: CVS
Only in /usr/src/CVS/classpathx/mail/source/javax/mail: CVS
diff -r /usr/src/CVS/classpathx/mail/source/javax/mail/Session.java
/usr/src/tiger-0.5.2/thirdparty/classpathx-javamail-customized/mail/source/javax/mail/Session.java
34a35
> import java.util.Date;
36a38
> import java.text.SimpleDateFormat;
37a40
> import java.util.TimeZone;
47a51
>  * @author Doug Porter
50c54
< {
---
> {  
88c92,94
<   private boolean debug;
---
>   private static boolean debug;
>   private static boolean debugShowTimestamp;
>   private static boolean debugShowThread;
107,108c113,115
<     if (debug)
<       System.out.println("DEBUG: using GNU JavaMail");
---
>     debugShowTimestamp = new 
> Boolean(props.getProperty("mail.debug.showtimestamp")).booleanValue();
>     debugShowThread = new 
> Boolean(props.getProperty("mail.debug.showthread")).booleanValue();
>     Session.log("DEBUG: using GNU JavaMail");
125,133c132
<       if (debug)
<             System.out.println("DEBUG: no system providers");
<     }
<     if (debug)
<     {
<       System.out.println("DEBUG: Providers by class name: "
<                          + providersByClassName.toString());
<       System.out.println("DEBUG: Providers by protocol: "
<                          + providersByProtocol.toString());
---
>       Session.log("DEBUG: no system providers");
134a134,137
>     Session.log("DEBUG: Providers by class name: "
>            + providersByClassName.toString());
>     Session.log("DEBUG: Providers by protocol: "
>            + providersByProtocol.toString());
146,147c149
<       if (debug)
<             System.out.println("DEBUG: no system address map");
---
>       Session.log("DEBUG: no system address map");
183,184c185
<       if (debug)
<         System.out.println("DEBUG: no "+description+" providers");
---
>       Session.log("DEBUG: no "+description+" providers");
227,228c228
<               if (debug)
<                 System.out.println("DEBUG: Invalid provider: "+line);
---
>               Session.log("DEBUG: Invalid provider: "+line);
242,243c242
<         if (debug)
<           System.out.println("DEBUG: loaded "+description+"
providers");
---
>         Session.log("DEBUG: loaded "+description+" providers");
247,248c246
<       if (debug)
<         System.out.println("DEBUG: "+e.getMessage());
---
>       Session.log("DEBUG: "+e.getMessage());
252,253c250
<       if (debug)
<         System.out.println("DEBUG: can't load "+description+"
providers");
---
>       Session.log("DEBUG: can't load "+description+" providers");
261,262c258
<       if (debug)
<         System.out.println("DEBUG: no "+description+" address map");
---
>       Session.log("DEBUG: no "+description+" address map");
269,270c265
<       if (debug)
<         System.out.println("DEBUG: loaded "+description+" address
map");
---
>       Session.log("DEBUG: loaded "+description+" address map");
274,275c269
<       if (debug)
<         System.out.println("DEBUG: "+e.getMessage());
---
>       Session.log("DEBUG: "+e.getMessage());
279,280c273
<       if (debug)
<         System.out.println("DEBUG: can't load "+description+" address
map");
---
>       Session.log("DEBUG: can't load "+description+" address map");
451,452c444
<         if (debug)
<           System.out.println("DEBUG:
"+providerClassKey+"="+providerClassName);
---
>         Session.log("DEBUG: "+providerClassKey+"="+providerClassName);
460,461c452
<     if (debug)
<       System.out.println("DEBUG: getProvider(): " +
provider.toString());
---
>     Session.log("DEBUG: getProvider(): " + provider.toString());
771a763,868
>   }
>   
>   /**
>    * These debugging methods are in the Session class because it
>    * already has the setDebug and getDebug methods, and interprets the
>    * mail.debug property. But it may make sense to put them in their own
>    * class.
>    */
>   
>   /**
>    * Logs a message to System.err.
>    * <p>
>    * Log messages do not appear by default. To show them, set the property 
>    * "mail.debug" to "true" in the property list passed to the Session 
>    * constructor, or call Session.setDebug(true).
>    * <p>
>    * To show a timestamp for each log message, set the property 
>    * "mail.debug.timestamp" to "true".
>    * To show the thread identifier for each log message, set the property 
>    * "mail.debug.thread" to "true".
>    *
>    * @param message Message to log
>    */
>   public static synchronized void log (String message)
>   {
>     log (System.err, message);
>   }
>   
>   /**
>    * Logs a message to the specified print stream.
>    * <p>
>    * Log messages do not appear by default. To show them, set the property 
>    * "mail.debug" to "true" in the property list passed to the Session 
>    * constructor, or call Session.setDebug(true).
>    * <p>
>    * To show a timestamp for each log message, set the property 
>    * "mail.debug.timestamp" to "true".
>    * To show the thread identifier for each log message, set the property 
>    * "mail.debug.thread" to "true".
>    *
>    * @param out Print stream to use
>    * @param message Message to log
>    */
>   public static synchronized void log (PrintStream out, String message)
>   {
>     if (debug)
>     {          
>     String line = "";
>     if (debugShowTimestamp) {
>         line += getDateTimeStamp () + " ";
>     }
>     if (debugShowThread) {
>         line += "[" + Thread.currentThread ().toString () + "] ";
>     }
>     line += message;
>     
>     out.println(line);
>     }
>   }
>   
>   /**
>    * Logs the class type for the given object, including superclasses.
>    * <p>
>    * To log just the class of an object without its superclasses, use 
>    * <code>Session.log (object.getClass ().toString ())</code>. 
>    *
>    * @param obj Object for which to log classes
>    */  
>   public static synchronized void logClass (Object obj)
>   {
>     logClass (obj.getClass().toString() + " classes and superclasses:", obj);
>   }
>   
>   /**
>    * Logs the class type for the given object, including superclasses.
>    * <p>
>    * To log just the class of an object without its superclasses, use 
>    * <code>Session.log (object.getClass ().toString ())</code>. 
>    *
>    * @param message Message to print at top of class list, usually 
> identifying the object
>    * @param obj Object for which to log classes
>    */  
>   public static synchronized void logClass (String message, 
>                                             Object obj)
>   {
>     final String ObjectClass = "class java.lang.Object";
>     
>     log (message);
>     
>     Class s = obj.getClass ();
>     while (s != null &&
>            ! s.toString().equals(ObjectClass)) {
>                
>       log ("    " + s.toString());
>       s = s.getSuperclass();
>       
>     }
>   }
> 
>   private static String getDateTimeStamp ()
>   {
>     TimeZone gmt = TimeZone.getTimeZone ("GMT");
>     SimpleDateFormat df = new SimpleDateFormat ("yyyy-MM-dd hh:mm:ss.SSS");
>     df.setTimeZone (gmt);
>     Date now = new Date ();
>     return df.format (now);
Only in /usr/src/CVS/classpathx/mail/source/javax/mail/event: CVS
Only in /usr/src/CVS/classpathx/mail/source/javax/mail/internet: CVS
diff -r
/usr/src/CVS/classpathx/mail/source/javax/mail/internet/MimeBodyPart.java
/usr/src/tiger-0.5.2/thirdparty/classpathx-javamail-customized/mail/source/javax/mail/internet/MimeBodyPart.java
150,151c150
<     if (!(is instanceof ByteArrayInputStream) &&
<         !(is instanceof BufferedInputStream))
---
>     if (!is.markSupported ())
153d151
<     
diff -r
/usr/src/CVS/classpathx/mail/source/javax/mail/internet/MimeMessage.java
/usr/src/tiger-0.5.2/thirdparty/classpathx-javamail-customized/mail/source/javax/mail/internet/MimeMessage.java
38d37
< import java.text.DateFormat;
53a53
> import gnu.mail.util.MessageInputStream;
332,333c332,334
<       if (!(is instanceof ByteArrayInputStream) && 
<           !(is instanceof BufferedInputStream))
---
>       /*
>       if (!is.markSupported ()) {
>         Session.log ("MimeMessage.parse: buffering input stream");//DEBUG
334a336,337
>       }
>       */
341c344
<         int len = 1024;
---
>         int len = 1024;  
352,354c355,357
<           for (int l = is.read(content, 0, len); 
<               l!=-1;
<               l = is.read(content, 0, len)) 
---
>           int l = is.read(content, 0, len);
>           while (l!=-1)
>           { 
355a359,360
>             l = is.read(content, 0, len);
>           }
diff -r
/usr/src/CVS/classpathx/mail/source/javax/mail/internet/MimeMultipart.java
/usr/src/tiger-0.5.2/thirdparty/classpathx-javamail-customized/mail/source/javax/mail/internet/MimeMultipart.java
35a36
> import java.io.PushbackInputStream;
44a46,47
> import gnu.mail.util.LineInputStream;
> import gnu.mail.util.MimeMultipartInputStream;
315,316c318
<         if (!(is instanceof ByteArrayInputStream) && 
<             !(is instanceof BufferedInputStream))
---
>       if (!is.markSupported ())
329c331
<          * Using a CRLFInputStream simplifies things here, but it may
buffer
---
>          * Using a CRLFInputStream simplifies things here (how, exactly?), 
> but it may buffer
333c335,336
<         CRLFInputStream crlfis = new CRLFInputStream(is);
---
>         MimeMultipartInputStream lis = 
>             new MimeMultipartInputStream(new CRLFInputStream(is));
335c338
<         while ((line = crlfis.readLine())!=null)
---
>         while ((line = lis.readLine())!=null)
350c353
<             while ((line = crlfis.readLine())!=null &&
line.length()>0);
---
>             while ((line = lis.readLine())!=null && line.length()>0);
355c358
<             headers = createInternetHeaders(crlfis);
---
>             headers = createInternetHeaders(lis);
370c373
<                 c = crlfis.read();
---
>                 c = lis.read();
373,374c376,377
<                   crlfis.unread(c);
<                   crlfis.unread(bbytes, 0, pos);
---
>                   lis.unread(c);
>                   lis.unread(bbytes, 0, pos);
382c385
<                 c = crlfis.read();
---
>                 c = lis.read();
385c388
<                   c = crlfis.read();
---
>                   c = lis.read();
394c397
<                   c = crlfis.read();
---
>                   c = lis.read();
404c407
<             c = crlfis.read();
---
>             c = lis.read();
Only in /usr/src/CVS/classpathx/mail/source/javax/mail/search: CVS
Only in /usr/src/CVS/classpathx/mail/test: CVS
Only in /usr/src/CVS/classpathx/mail/test/src: CVS

-- 
  Doug Porter
  address@hidden

-- 
http://www.fastmail.fm - The professional email service




reply via email to

[Prev in Thread] Current Thread [Next in Thread]