зеркало из https://github.com/mozilla/pjs.git
adding new sources
This commit is contained in:
Родитель
25e803bf0c
Коммит
2a774f4e55
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Netscape Messaging Access SDK Version 3.5 code,
|
||||
* released on or about June 15, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998 Netscape
|
||||
* Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 and 1998 Netscape Communications Corporation
|
||||
* (http://home.netscape.com/misc/trademarks.html)
|
||||
*/
|
||||
|
||||
package netscape.messaging.imap4;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* IGlobals contains global constants
|
||||
*/
|
||||
|
||||
public interface IGlobals
|
||||
{
|
||||
/** The server response types*/
|
||||
final static String STAR = "*";
|
||||
final static String PLUS = "+";
|
||||
final static String connect = "connect";
|
||||
|
||||
//Any State
|
||||
final static String CAPABILITY = "CAPABILITY";
|
||||
final static String LOGOUT = "LOGOUT";
|
||||
final static String NOOP = "NOOP";
|
||||
|
||||
//Non-authenticated state
|
||||
final static String LOGIN = "LOGIN ";
|
||||
|
||||
//Authenticated state
|
||||
final static String SELECT = "SELECT";
|
||||
final static String EXAMINE = "EXAMINE";
|
||||
final static String CREATE = "CREATE ";
|
||||
final static String DELETE = "DELETE ";
|
||||
final static String RENAME = "RENAME ";
|
||||
final static String SUBSCRIBE = "SUBSCRIBE";
|
||||
final static String UNSUBSCRIBE = "UNSUBSCRIBE";
|
||||
final static String LIST = "LIST";
|
||||
final static String LSUB = "LSUB";
|
||||
final static String STATUS = "STATUS";
|
||||
final static String APPEND = "APPEND";
|
||||
|
||||
//Selected state
|
||||
final static String CHECK = "CHECK";
|
||||
final static String CLOSE = "CLOSE";
|
||||
final static String EXPUNGE = "EXPUNGE";
|
||||
final static String SEARCH = "SEARCH";
|
||||
final static String FETCH = "FETCH";
|
||||
final static String STORE = "STORE";
|
||||
final static String COPY = "COPY";
|
||||
final static String UID = "UID";
|
||||
|
||||
//Extended IMAP
|
||||
final static String NAMESPACE = "NAMESPACE";
|
||||
final static String SETACL = "SETACL";
|
||||
final static String DELETEACL = "DELETEACL";
|
||||
final static String GETACL = "GETACL";
|
||||
final static String LISTRIGHTS = "LISTRIGHTS";
|
||||
final static String MYRIGHTS = "MYRIGHTS";
|
||||
|
||||
|
||||
//Server response types
|
||||
final static String BYE = "BYE";
|
||||
final static String RECENT = "RECENT";
|
||||
final static String EXISTS = "EXISTS";
|
||||
final static String FLAGS = "FLAGS";
|
||||
final static String taggedOK = "taggedOK";
|
||||
final static String taggedNO = "taggedNO";
|
||||
final static String taggedBAD = "taggedBAD";
|
||||
final static String OK = "OK";
|
||||
final static String NO = "NO";
|
||||
final static String BAD = "BAD";
|
||||
final static String PREAUTH = "PREAUTH";
|
||||
final static String ACL = "ACL";
|
||||
final static String UNTAGGED = "UNTAGGED";
|
||||
|
||||
//Others
|
||||
final static String UNKNOWN = "UNKNOWN";
|
||||
|
||||
|
||||
//Fetch data items
|
||||
final static int Uid = 0;
|
||||
final static int InternalDate = 1;
|
||||
final static int BodyStructure = 2;
|
||||
final static int Flags = 3;
|
||||
final static int Envelope = 4;
|
||||
final static int Message = 5;
|
||||
|
||||
final static int Rfc822Text = 6;
|
||||
final static int Rfc822Size = 7;
|
||||
|
||||
final static int Unknown = 8;
|
||||
|
||||
//Status data items
|
||||
final static int StatusMessages = 0;
|
||||
final static int StatusRecent = 1;
|
||||
final static int StatusUidNext = 2;
|
||||
final static int StatusUidValidity = 3;
|
||||
final static int StatusUnSeen = 4;
|
||||
|
||||
//Control Characters
|
||||
final static String NewLine = "\n";
|
||||
final static String CarriageNewLine = "\r\n";
|
||||
final static String Space = " ";
|
||||
final static String LCurly = "{";
|
||||
final static String RCurly = "}";
|
||||
final static String LBracket = "(";
|
||||
final static String RBracket = ")";
|
||||
final static String Quote = "\"";
|
||||
final static String Colon = ":";
|
||||
final static String Equal = "=";
|
||||
final static String EmptyString = "";
|
||||
|
||||
//Errors
|
||||
final static String DispatcherError = "A fatal error has occured in the dispatcher";
|
||||
final static String NoConnection = "Must connect to server";
|
||||
final static String UnexpectedServerData = "Unexcepted Server Data";
|
||||
final static String ConnectedAlready = "A connection currently exists.";
|
||||
final static String ConnectionLost = "The connection has been lost unexpectedly.";
|
||||
}
|
|
@ -0,0 +1,646 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Netscape Messaging Access SDK Version 3.5 code,
|
||||
* released on or about June 15, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998 Netscape
|
||||
* Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 and 1998 Netscape Communications Corporation
|
||||
* (http://home.netscape.com/misc/trademarks.html)
|
||||
*/
|
||||
|
||||
package netscape.messaging.imap4;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* IIMAP4Sink is the interface for the response sink for all IMAP4 commands.
|
||||
*<p>The IIMAP4Sink interface contains callbacks for each client call.
|
||||
*These callbacks receive the server responses for each client call after
|
||||
*processResponses is invoked. The methods defined in IIMAP4Sink map to
|
||||
*the server responses defined in RFC 2060, chapter 7.
|
||||
*<p>To utilize the IMAP4 client object, you must extend this
|
||||
*interface. The constructor for the IMAP4 client class takes an IMAP4 sink object
|
||||
*as a parameter. As a convenience, the Messaging Access SDK
|
||||
*provides the IMAP4Sink class, which is a default implementation of the
|
||||
*IIMAP4Sink interface.
|
||||
*<p>The IMAP4Sink class provides sink methods that do nothing.
|
||||
*You can either define the response sink by subclassing IMAP4Sink and
|
||||
*overriding only those methods that are of interest to you, or you can
|
||||
*implement IIMAP4Sink. In this case, you must provide an implementation of
|
||||
*all the methods defined in the response sink.
|
||||
*<p>For information about the IMAP4 responses returned by the client methods,
|
||||
*see RFC 2060. (For the URL, see "Where to Find More Information" in "About This Book.")
|
||||
*/
|
||||
|
||||
public interface IIMAP4Sink
|
||||
{
|
||||
//General Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Indicates the end of response(s) for successful commands.
|
||||
* @param in_tag The tag associated with the command.
|
||||
* @param in_status "OK"
|
||||
* @param in_reason Reason for in_status.
|
||||
* @see IMAP4Client#sendCommand
|
||||
* @see IMAP4Client#capability
|
||||
* @see IMAP4Client#noop
|
||||
* @see IMAP4Client#login
|
||||
* @see IMAP4Client#logout
|
||||
* @see IMAP4Client#append
|
||||
* @see IMAP4Client#create
|
||||
* @see IMAP4Client#delete
|
||||
* @see IMAP4Client#examine
|
||||
* @see IMAP4Client#list
|
||||
* @see IMAP4Client#lsub
|
||||
* @see IMAP4Client#rename
|
||||
* @see IMAP4Client#select
|
||||
* @see IMAP4Client#status
|
||||
* @see IMAP4Client#subscribe
|
||||
* @see IMAP4Client#unsubscribe
|
||||
* @see IMAP4Client#check
|
||||
* @see IMAP4Client#close
|
||||
* @see IMAP4Client#copy
|
||||
* @see IMAP4Client#uidCopy
|
||||
* @see IMAP4Client#expunge
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
* @see IMAP4Client#search
|
||||
* @see IMAP4Client#uidSearch
|
||||
* @see IMAP4Client#store
|
||||
* @see IMAP4Client#uidStore
|
||||
* @see IMAP4Client#nameSpace
|
||||
* @see IMAP4Client#setACL
|
||||
* @see IMAP4Client#deleteACL
|
||||
* @see IMAP4Client#getACL
|
||||
* @see IMAP4Client#myRights
|
||||
* @see IMAP4Client#listRights
|
||||
*/
|
||||
public void taggedLine( StringBuffer in_tag, StringBuffer in_status,
|
||||
StringBuffer in_reason);
|
||||
|
||||
/**
|
||||
*Indicates the response for unsuccessful commands (error responses).
|
||||
*The two types of in_status are NO and BAD, which may be tagged or
|
||||
*untagged.
|
||||
*<ul><li>NO response: Indicates an operational error message
|
||||
*from the server. If tagged, indicates unsuccessful completion
|
||||
*of the associated command. If untagged, indicates a warning,
|
||||
*but the command can still complete successfully.
|
||||
*<li>BAD response: Indicates an error message for the server.
|
||||
*If tagged, reports a protocol-level error in the client's
|
||||
*command; the tag indicates the command that caused the error.
|
||||
*If untagged, indicates a protocol-level error for which
|
||||
*the associated command cannot be determined; can also
|
||||
*indicate an internal server failure.
|
||||
*</ul>
|
||||
* @param in_tag The tag associated with the command.
|
||||
* @param in_status Status response showing the status of the command. Values:
|
||||
*<ul><li>"NO" If tagged: unsuccessful completion; if untagged: client warning message.
|
||||
*<li>"BAD" Protocol-level error; if tagged: client command that contained an error; if untagged: serious or wide-spread problem.
|
||||
*</ul>
|
||||
* @param in_reason Reason for in_status.
|
||||
* @exception IMAP4ServerException If a server response error occurs.
|
||||
* @see IMAP4Client#connect
|
||||
* @see IMAP4Client#sendCommand
|
||||
* @see IMAP4Client#capability
|
||||
* @see IMAP4Client#noop
|
||||
* @see IMAP4Client#login
|
||||
* @see IMAP4Client#logout
|
||||
* @see IMAP4Client#append
|
||||
* @see IMAP4Client#create
|
||||
* @see IMAP4Client#delete
|
||||
* @see IMAP4Client#examine
|
||||
* @see IMAP4Client#list
|
||||
* @see IMAP4Client#lsub
|
||||
* @see IMAP4Client#rename
|
||||
* @see IMAP4Client#select
|
||||
* @see IMAP4Client#status
|
||||
* @see IMAP4Client#subscribe
|
||||
* @see IMAP4Client#unsubscribe
|
||||
* @see IMAP4Client#check
|
||||
* @see IMAP4Client#close
|
||||
* @see IMAP4Client#copy
|
||||
* @see IMAP4Client#uidCopy
|
||||
* @see IMAP4Client#expunge
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
* @see IMAP4Client#search
|
||||
* @see IMAP4Client#uidSearch
|
||||
* @see IMAP4Client#store
|
||||
* @see IMAP4Client#uidStore
|
||||
* @see IMAP4Client#nameSpace
|
||||
* @see IMAP4Client#setACL
|
||||
* @see IMAP4Client#deleteACL
|
||||
* @see IMAP4Client#getACL
|
||||
* @see IMAP4Client#myRights
|
||||
* @see IMAP4Client#listRights
|
||||
*/
|
||||
public void error( StringBuffer in_tag, StringBuffer in_status,
|
||||
StringBuffer in_reason) throws IMAP4ServerException;
|
||||
|
||||
/**
|
||||
* An unsolicited OK response.
|
||||
* Gets the OK status response to IMAP4 commands.
|
||||
* @param in_responseCode Response code (optional).
|
||||
* @param in_information Information text message for the user.
|
||||
* @see IMAP4Client#connect
|
||||
* @see IMAP4Client#examine
|
||||
* @see IMAP4Client#select
|
||||
*/
|
||||
public void ok(StringBuffer in_responseCode, StringBuffer in_information);
|
||||
|
||||
/**
|
||||
* Raw (unparsed) data is pushed into here.
|
||||
* <P>Note: Matches up with sendCommand; is used as a default method
|
||||
* to push information that does not belong anywhere else.
|
||||
* @param in_data Raw data.
|
||||
* @see #sendCommand
|
||||
*/
|
||||
public void rawResponse(StringBuffer in_data);
|
||||
|
||||
|
||||
//Fetch Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Indicates the beginning of a fetch response.
|
||||
* @param in_msg Message number or uid.
|
||||
* @return Reference object to use to associate all data
|
||||
* items for a given response, or an error code.
|
||||
* @see IMAP4Client#noop
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
*/
|
||||
public Object fetchStart(int in_msg);
|
||||
|
||||
/**
|
||||
* Signals that the data for this message has been completely fetched.
|
||||
* @param in_reference Reference object to use to associate all
|
||||
* data items for a given response.
|
||||
* @see IMAP4Client#noop
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
*/
|
||||
public void fetchEnd(Object in_reference);
|
||||
|
||||
/**
|
||||
* The size of the message. The value of the following data
|
||||
* items are routed here: RFC822.SIZE.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_size Size of the data.
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
*/
|
||||
public void fetchSize(Object in_reference, int in_size);
|
||||
|
||||
/**
|
||||
* Fetches the data associated with specific data items.
|
||||
* The value of the following data items are routed here:
|
||||
* BODY[<section>]<<partial>>, BODY.PEEK[<section>]<<partial>>,
|
||||
* RFC822.HEADER, RFC822, RFC822.TEXT
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_data Chunk of message data.
|
||||
* @param in_bytesRead Number of bytes read so far.
|
||||
* @param in_totalBytes Total size of the body segment.
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
*/
|
||||
public void fetchData(Object in_reference, byte[] in_data, int in_bytesRead, int in_totalBytes);
|
||||
|
||||
/**
|
||||
* Fetches the value of the flags.
|
||||
* The value of the FLAGS data item is routed here.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_flags Flags for the object.
|
||||
* @see IMAP4Client#noop
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
*/
|
||||
public void fetchFlags(Object in_reference, StringBuffer in_flags);
|
||||
|
||||
/**
|
||||
* Fetches the value of the body structure.
|
||||
* The value of the BODYSTRUCTURE data item is routed here.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_bodyStructure Body structure.
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
*/
|
||||
public void fetchBodyStructure(Object in_reference, StringBuffer in_bodyStructure);
|
||||
|
||||
/**
|
||||
* Fetches the value of the envelope.
|
||||
* Note: Use ENVELOPE_* values for quick access to ENVELOPE Data items.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_fieldValue The value of the field.
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
*/
|
||||
public void fetchEnvelope(Object in_reference, StringBuffer[] in_fieldValue);
|
||||
|
||||
/**
|
||||
* Fetches the value of the internal date.
|
||||
* The value of the INTERNALDATE data item is routed here.
|
||||
* @param in_reference A reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_internalDate The internal date of the message.
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
*/
|
||||
public void fetchInternalDate(Object in_reference, StringBuffer in_internalDate);
|
||||
|
||||
/**
|
||||
* Fetches the value of the header.
|
||||
* The value of the following data items are routed here:
|
||||
* BODY[HEADER], BODY.PEEK[HEADER], RFC822.HEADER,
|
||||
* RFC822, BODY[0], BODY.PEEK[0], BODY[], BODY.PEEK[].
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_field Text representing the header field name.
|
||||
* @param in_value Value of the header field.
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
*/
|
||||
public void fetchHeader(Object in_reference, StringBuffer in_field, StringBuffer in_value);
|
||||
|
||||
/**
|
||||
* Fetches the value of the unique ID of the message.
|
||||
* The value of the UID data item is routed here.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_uid UID of the message.
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
*/
|
||||
public void fetchUid(Object in_reference, int in_uid);
|
||||
|
||||
//Lsub Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Lists subscribed or active mailboxes that match the search criteria.
|
||||
* @param in_attribute Attributes of the mailbox.
|
||||
* @param in_delimeter Hierarchy delimiter.
|
||||
* @param in_name Name of the mailbox.
|
||||
* @see #list
|
||||
* @see IMAP4Client#lsub
|
||||
*/
|
||||
public void lsub(StringBuffer in_attribute, StringBuffer in_delimeter, StringBuffer in_name);
|
||||
|
||||
//List Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Lists mailboxes that match the search criteria.
|
||||
* @param in_attribute Attributes of the mailbox.
|
||||
* @param in_delimeter Hierarchy delimiter.
|
||||
* @param in_name Name of the mailbox.
|
||||
* @see #lsub
|
||||
* @see IMAP4Client#list
|
||||
*/
|
||||
public void list(StringBuffer in_attribute, StringBuffer in_delimeter, StringBuffer in_name);
|
||||
|
||||
//Search Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Indicates the start of the retrieval of messages numbers that
|
||||
* match the search criteria.
|
||||
* @returns Reference object that associates all data
|
||||
* items for a given response, or an error code.
|
||||
* @see IMAP4Client#search
|
||||
* @see IMAP4Client#uidSearch
|
||||
*/
|
||||
public Object searchStart();
|
||||
|
||||
/**
|
||||
* Gets the messages that match the search criteria.
|
||||
* Sends the SEARCH IMAP4 protocol command.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_message Message number.
|
||||
* @see IMAP4Client#search
|
||||
* @see IMAP4Client#uidSearch
|
||||
*/
|
||||
public void search(Object in_reference, int in_message);
|
||||
|
||||
/**
|
||||
* Indicates the end of the retrieval of message numbers
|
||||
* that match the search criteria.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @see #search
|
||||
* @see #searchStart
|
||||
* @see #fetchBodyStructure
|
||||
* @see IMAP4Client#search
|
||||
* @see IMAP4Client#uidSearch
|
||||
*/
|
||||
public void searchEnd(Object in_reference);
|
||||
|
||||
//Status Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Total number of messages.
|
||||
* @param in_messages Total number of messages.
|
||||
* @see #statusRecent
|
||||
* @see #statusUidnext
|
||||
* @see IMAP4Client#status
|
||||
*/
|
||||
public void statusMessages(int in_messages);
|
||||
|
||||
/**
|
||||
* Number of messages with the recent flag set.
|
||||
* @param in_recent Number of recent messages.
|
||||
* @see #statusMessages
|
||||
* @see #statusUidnext
|
||||
* @see IMAP4Client#status
|
||||
*/
|
||||
public void statusRecent(int in_recent);
|
||||
|
||||
/**
|
||||
* The next uid value to be assigned to a new message in the mailbox.
|
||||
* @param in_uidNext The next uid value.
|
||||
* @see #statusMessages
|
||||
* @see #statusUidvalidity
|
||||
* @see IMAP4Client#status
|
||||
*/
|
||||
public void statusUidnext(int in_uidNext);
|
||||
|
||||
/**
|
||||
* The uid validity value of the mailbox.
|
||||
* @param in_uidValidity The unique ID of the mailbox.
|
||||
* @see #statusMessages,
|
||||
* @see #statusUidnext
|
||||
* @see IMAP4Client#status
|
||||
*/
|
||||
public void statusUidvalidity(int in_uidValidity);
|
||||
|
||||
/**
|
||||
* The number of messages without the \Seen flag set.
|
||||
* @param in_unSeen Number of unseen messages.
|
||||
* @see #statusMessages
|
||||
* @see #statusUidnext
|
||||
* @see IMAP4Client#status
|
||||
*/
|
||||
public void statusUnseen(int in_unSeen);
|
||||
|
||||
//Capability Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Listing of capabilities supported by the server.
|
||||
* Sends the CAPABILITY IMAP4 protocol command.
|
||||
* @param in_listing Listing of the capabilities that the server supports.
|
||||
* @see IMAP4Client#connect
|
||||
* @see IMAP4Client#capability
|
||||
*/
|
||||
public void capability(StringBuffer in_listing);
|
||||
|
||||
//Exists Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The total number of messages in the selected mailbox.
|
||||
* @param in_messages Number of messages in the mailbox.
|
||||
* @see IMAP4Client#noop
|
||||
* @see IMAP4Client#examine
|
||||
* @see IMAP4Client#select
|
||||
*/
|
||||
public void exists(int in_messages);
|
||||
|
||||
//Expunge Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Expunges the specified message.
|
||||
* @param in_message Number of message to expunge.
|
||||
* @see IMAP4Client#noop
|
||||
* @see IMAP4Client#expunge
|
||||
*/
|
||||
public void expunge(int in_message);
|
||||
|
||||
//Recent Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The total number of messages with the \Recent flag set.
|
||||
* @param in_messages Number of \Recent messages.
|
||||
* @see IMAP4Client#noop
|
||||
* @see IMAP4Client#examine
|
||||
* @see IMAP4Client#select
|
||||
*/
|
||||
public void recent(int in_messages);
|
||||
|
||||
//Flags Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The flags that are applicable for the selected mailbox.
|
||||
* @param in_flags Applicable flags.
|
||||
* @see #fetchFlags
|
||||
* @see IMAP4Client#examine
|
||||
* @see IMAP4Client#select
|
||||
*/
|
||||
public void flags(StringBuffer in_flags);
|
||||
|
||||
//Bye Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The reason the connection was closed.
|
||||
* @param in_reason Reason for closing the connection.
|
||||
* @see IMAP4Client#disconnect
|
||||
* @see IMAP4Client#logout
|
||||
*/
|
||||
public void bye(StringBuffer in_reason);
|
||||
|
||||
//Namespace Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Indicates the beginning of a namespace response.
|
||||
* Lets the client get the prefixes of namespaces used by a server
|
||||
* for personal mailboxes, other user's mailboxes, and shared objects.
|
||||
* @return Reference object to use to associate all data
|
||||
* items for a given response or an error code.
|
||||
* @see #nameSpaceEnd
|
||||
* @see #nameSpaceOtherUsers
|
||||
* @see #nameSpacePersonal
|
||||
* @see #nameSpaceShared
|
||||
* @see IMAP4Client#nameSpace
|
||||
*/
|
||||
public Object nameSpaceStart();
|
||||
|
||||
/**
|
||||
* The personal namespace.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response or an error code.
|
||||
* @param in_personal The personal namespace.
|
||||
* @see #nameSpaceEnd
|
||||
* @see #nameSpaceOtherUsers
|
||||
* @see #nameSpaceStart
|
||||
* @see #nameSpaceShared
|
||||
* @see IMAP4Client#nameSpace
|
||||
*/
|
||||
public void nameSpacePersonal(Object in_reference, StringBuffer in_personal);
|
||||
|
||||
/**
|
||||
* The other user's namespace.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response or an error code.
|
||||
* @param in_otherUsers The other user's namespace.
|
||||
* @see #nameSpaceEnd
|
||||
* @see #nameSpacePersonal
|
||||
* @see #nameSpaceStart
|
||||
* @see #nameSpaceShared
|
||||
* @see IMAP4Client#nameSpace
|
||||
*/
|
||||
public void nameSpaceOtherUsers(Object in_reference, StringBuffer in_otherUsers);
|
||||
|
||||
/**
|
||||
* The shared namespace.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_shared The shared namespace.
|
||||
* @see #nameSpaceEnd
|
||||
* @see #nameSpaceOtherUsers
|
||||
* @see #nameSpacePersonal
|
||||
* @see #nameSpaceStart
|
||||
* @see IMAP4Client#nameSpace
|
||||
*/
|
||||
public void nameSpaceShared(Object in_reference, StringBuffer in_shared);
|
||||
|
||||
/**
|
||||
* Signals that the data for the particular namespace has been completely fetched.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @see #nameSpaceShared
|
||||
* @see #nameSpaceOtherUsers
|
||||
* @see #nameSpacePersonal
|
||||
* @see #nameSpaceStart
|
||||
* @see IMAP4Client#nameSpace
|
||||
*/
|
||||
public void nameSpaceEnd(Object in_reference);
|
||||
|
||||
|
||||
//ACL Responses
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The mailbox name for which the ACL applies.
|
||||
* @param in_mailbox Name of the mailbox to which the control list applies.
|
||||
* @return Reference object to use to associate all data
|
||||
* items for a given response or an error code.
|
||||
* @see #aclEnd
|
||||
* @see #aclIdentifierRight
|
||||
* @see IMAP4Client#getACL
|
||||
*/
|
||||
public Object aclStart(StringBuffer in_mailbox);
|
||||
|
||||
/**
|
||||
* The identifier rights pairs that apply to mailbox specified in aclStart.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_identifier Identifier for which the entry applies.
|
||||
* @param in_rights The client's current set of rights.
|
||||
* @see IMAP4Client#getACL
|
||||
*/
|
||||
public void aclIdentifierRight( Object in_reference, StringBuffer in_identifier,
|
||||
StringBuffer in_rights);
|
||||
|
||||
/**
|
||||
* The end of an ACL response.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @see #aclIdentifierRight
|
||||
* @see #aclStart
|
||||
* @see IMAP4Client#getACL
|
||||
*/
|
||||
public void aclEnd(Object in_reference);
|
||||
|
||||
|
||||
//LISTRIGHTS Responses
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The start of a response to the LISTRIGHTS command.
|
||||
* @param in_mailbox Mailbox name for which the rights list applies.
|
||||
* @param in_identifier Identifier for which the rights list applies.
|
||||
* @return Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @see IMAP4Client#listRights
|
||||
*/
|
||||
public Object listRightsStart(StringBuffer in_mailbox, StringBuffer in_identifier);
|
||||
|
||||
/**
|
||||
* The required rights for the identifier defined in listRightsStart.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_requiredRights The set of rights that the identifier will always
|
||||
* be granted in the mailbox.
|
||||
* @see #listRightsStart
|
||||
* @see IMAP4Client#listRights
|
||||
*/
|
||||
public void listRightsRequiredRights(Object in_reference, StringBuffer in_requiredRights);
|
||||
|
||||
/**
|
||||
* The optional rights for the identifier defined in listRightsStart.
|
||||
* <P>NOTE: Rights mentioned
|
||||
* in the same StringBuffer are tied together. Either all must be granted to the
|
||||
* identifier in the mailbox or none may be granted.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_optionalRights Set of rights that the identifier may be granted
|
||||
* in the mailbox.
|
||||
* @see #listRightsStart
|
||||
* @see IMAP4Client#listRights
|
||||
*/
|
||||
public void listRightsOptionalRights(Object in_reference, StringBuffer in_optionalRights);
|
||||
|
||||
/**
|
||||
* The end of a LISTRIGHTS response.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @see #listRightsOptionalRights
|
||||
* @see #listRightsRequiredRights
|
||||
* @see IMAP4Client#listRights
|
||||
*/
|
||||
public void listRightsEnd(Object in_reference);
|
||||
|
||||
//MYRIGHTS Responses
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The set of rights that the user has to the mailbox.
|
||||
* @param in_mailbox The mailbox name for which these rights apply.
|
||||
* @param in_rights The client's current set of rights.
|
||||
* @see IMAP4Client#myRights
|
||||
*/
|
||||
public void myRights(StringBuffer in_mailbox, StringBuffer in_rights);
|
||||
|
||||
}
|
||||
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Netscape Messaging Access SDK Version 3.5 code,
|
||||
* released on or about June 15, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998 Netscape
|
||||
* Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 and 1998 Netscape Communications Corporation
|
||||
* (http://home.netscape.com/misc/trademarks.html)
|
||||
*/
|
||||
|
||||
package netscape.messaging.imap4;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
*The IMAP4Exception class represents an internal error in the IMAP4
|
||||
*implementation of the Messaging Access SDK.
|
||||
*/
|
||||
public class IMAP4Exception extends IOException
|
||||
{
|
||||
/**
|
||||
*Creates an IMAP4Exception object.
|
||||
*Default constructor for the IMAP4Exception class.
|
||||
*/
|
||||
public IMAP4Exception()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
*Creates an IMAP4Exception object that includes a descriptive string.
|
||||
*@param s String that describes the exception.
|
||||
*/
|
||||
public IMAP4Exception(String s)
|
||||
{
|
||||
super(s);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Netscape Messaging Access SDK Version 3.5 code,
|
||||
* released on or about June 15, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998 Netscape
|
||||
* Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 and 1998 Netscape Communications Corporation
|
||||
* (http://home.netscape.com/misc/trademarks.html)
|
||||
*/
|
||||
|
||||
package netscape.messaging.imap4;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
*The IMAP4ServerException class represents a server response
|
||||
*error in the IMAP4 implementation of the Messaging Access SDK.
|
||||
*<p>The IMAP4ServerException class handles server response errors.
|
||||
*An IMAP4ServerException is thrown only from the error
|
||||
*callback on the response sink. The interface definition for
|
||||
*IIMAP4Sink states that an IMAP4 server exception can be thrown,
|
||||
*but it is up to the developer to determine whether or not
|
||||
*the implementation of the error callback will throw this
|
||||
*exception. As a default, the IMAP4Sink class throws an exception whenever
|
||||
*the error callback is called.
|
||||
*<p>This exception is caused when the server sends an
|
||||
*error saying that some part of the operation failed or is not
|
||||
*supported. This can happen even when all relevant code executes
|
||||
*properly.
|
||||
*/
|
||||
|
||||
public class IMAP4ServerException extends IMAP4Exception
|
||||
{
|
||||
/**
|
||||
*Creates an IMAP4ServerException object.
|
||||
*Default constructor for an IMAP4ServerException object.
|
||||
*/
|
||||
public IMAP4ServerException()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
*Creates an IMAP4ServerException object that includes a
|
||||
*descriptive string.
|
||||
*@param s String that describes the exception.
|
||||
*/
|
||||
public IMAP4ServerException(String s)
|
||||
{
|
||||
super(s);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,778 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Netscape Messaging Access SDK Version 3.5 code,
|
||||
* released on or about June 15, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998 Netscape
|
||||
* Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 and 1998 Netscape Communications Corporation
|
||||
* (http://home.netscape.com/misc/trademarks.html)
|
||||
*/
|
||||
|
||||
package netscape.messaging.imap4;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*IMAP4Sink is the default implementation of the response sink for
|
||||
*all IMAP4 commands.
|
||||
*<p>To implement the IMAP4 protocol, you must extend the IIMAP4Sink interface.
|
||||
*The IMAP4Sink class is provided as a convenience. You can save time
|
||||
*by using this class, or you can derive your own class from the IIMAP4Sink
|
||||
*interface. The constructor for the IMAP4Client class takes an
|
||||
*IIMAP4Sink interface as a parameter.
|
||||
*<p>IMAP4Sink implements all the interfaces in IIMAP4Sink. By default,
|
||||
*the implementation does nothing, except for the error callback, which
|
||||
*throws an exception.
|
||||
* @author alterego@netscape.com
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
public class IMAP4Sink implements IIMAP4Sink
|
||||
{
|
||||
//Issues:
|
||||
// error handling
|
||||
// data dependencies
|
||||
|
||||
/** Creates an IMAP4Sink object.
|
||||
*Default constructor for the IMAP4Sink class.
|
||||
*/
|
||||
public IMAP4Sink()
|
||||
{}
|
||||
|
||||
//General Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Indicates the end of response(s) for successful commands.
|
||||
* @param in_tag The tag associated with the command.
|
||||
* @param in_status "OK"
|
||||
* @param in_reason Reason for in_status.
|
||||
* @see IMAP4Client#sendCommand
|
||||
* @see IMAP4Client#capability
|
||||
* @see IMAP4Client#noop
|
||||
* @see IMAP4Client#login
|
||||
* @see IMAP4Client#logout
|
||||
* @see IMAP4Client#append
|
||||
* @see IMAP4Client#create
|
||||
* @see IMAP4Client#delete
|
||||
* @see IMAP4Client#examine
|
||||
* @see IMAP4Client#list
|
||||
* @see IMAP4Client#lsub
|
||||
* @see IMAP4Client#rename
|
||||
* @see IMAP4Client#select
|
||||
* @see IMAP4Client#status
|
||||
* @see IMAP4Client#subscribe
|
||||
* @see IMAP4Client#unsubscribe
|
||||
* @see IMAP4Client#check
|
||||
* @see IMAP4Client#close
|
||||
* @see IMAP4Client#copy
|
||||
* @see IMAP4Client#uidCopy
|
||||
* @see IMAP4Client#expunge
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
* @see IMAP4Client#search
|
||||
* @see IMAP4Client#uidSearch
|
||||
* @see IMAP4Client#store
|
||||
* @see IMAP4Client#uidStore
|
||||
* @see IMAP4Client#nameSpace
|
||||
* @see IMAP4Client#setACL
|
||||
* @see IMAP4Client#deleteACL
|
||||
* @see IMAP4Client#getACL
|
||||
* @see IMAP4Client#myRights
|
||||
* @see IMAP4Client#listRights
|
||||
*/
|
||||
public void taggedLine( StringBuffer in_tag, StringBuffer in_status,
|
||||
StringBuffer in_reason)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
*Indicates the response for unsuccessful commands (error responses).
|
||||
*The two types of in_status are NO and BAD, which may be tagged or
|
||||
*untagged.
|
||||
*<ul><li>NO response: Indicates an operational error message
|
||||
*from the server. If tagged, indicates unsuccessful completion
|
||||
*of the associated command. If untagged, indicates a warning,
|
||||
*but the command can still complete successfully.
|
||||
*<li>BAD response: Indicates an error message for the server.
|
||||
*If tagged, reports a protocol-level error in the client's
|
||||
*command; the tag indicates the command that caused the error.
|
||||
*If untagged, indicates a protocol-level error for which
|
||||
*the associated command cannot be determined; can also
|
||||
*indicate an internal server failure.
|
||||
*</ul>
|
||||
* @param in_tag The tag associated with the command.
|
||||
* @param in_status Status response showing the status of the command. Values:
|
||||
*<ul><li>"NO" If tagged: unsuccessful completion; if untagged: client warning message.
|
||||
*<li>"BAD" Protocol-level error; if tagged: client command that contained an error; if untagged: serious or wide-spread problem.
|
||||
*</ul>
|
||||
* @param in_reason Reason for in_status.
|
||||
* @exception IMAP4ServerException If a server response error occurs.
|
||||
* @see IMAP4Client#connect
|
||||
* @see IMAP4Client#sendCommand
|
||||
* @see IMAP4Client#capability
|
||||
* @see IMAP4Client#noop
|
||||
* @see IMAP4Client#login
|
||||
* @see IMAP4Client#logout
|
||||
* @see IMAP4Client#append
|
||||
* @see IMAP4Client#create
|
||||
* @see IMAP4Client#delete
|
||||
* @see IMAP4Client#examine
|
||||
* @see IMAP4Client#list
|
||||
* @see IMAP4Client#lsub
|
||||
* @see IMAP4Client#rename
|
||||
* @see IMAP4Client#select
|
||||
* @see IMAP4Client#status
|
||||
* @see IMAP4Client#subscribe
|
||||
* @see IMAP4Client#unsubscribe
|
||||
* @see IMAP4Client#check
|
||||
* @see IMAP4Client#close
|
||||
* @see IMAP4Client#copy
|
||||
* @see IMAP4Client#uidCopy
|
||||
* @see IMAP4Client#expunge
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
* @see IMAP4Client#search
|
||||
* @see IMAP4Client#uidSearch
|
||||
* @see IMAP4Client#store
|
||||
* @see IMAP4Client#uidStore
|
||||
* @see IMAP4Client#nameSpace
|
||||
* @see IMAP4Client#setACL
|
||||
* @see IMAP4Client#deleteACL
|
||||
* @see IMAP4Client#getACL
|
||||
* @see IMAP4Client#myRights
|
||||
* @see IMAP4Client#listRights
|
||||
*/
|
||||
public void error( StringBuffer in_tag, StringBuffer in_status,
|
||||
StringBuffer in_reason) throws IMAP4ServerException
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* An unsolicited OK response.
|
||||
* Gets the OK status response to IMAP4 commands.
|
||||
* @param in_responseCode Response code (optional).
|
||||
* @param in_information Information text message for the user.
|
||||
* @see IMAP4Client#connect
|
||||
* @see IMAP4Client#examine
|
||||
* @see IMAP4Client#select
|
||||
*/
|
||||
public void ok(StringBuffer in_responseCode, StringBuffer in_information)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Raw (unparsed) data is pushed into here.
|
||||
* <P>Note: Matches up with sendCommand; is used as a default method
|
||||
* to push information that does not belong anywhere else.
|
||||
* @param in_data Raw data.
|
||||
* @see #sendCommand
|
||||
*/
|
||||
public void rawResponse(StringBuffer in_data)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//Fetch Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Indicates the beginning of a fetch response.
|
||||
* @param in_msg Message number or uid.
|
||||
* @return Reference object to use to associate all data
|
||||
* items for a given response, or an error code.
|
||||
* @see IMAP4Client#noop
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
*/
|
||||
public Object fetchStart(int in_msg)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signals that the data for this message has been completely fetched
|
||||
* @param in_reference Reference object to use to associate all
|
||||
* data items for a given response.
|
||||
* @see IMAP4Client#noop
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
*/
|
||||
public void fetchEnd(Object in_reference)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The size of the message. The value of the following data
|
||||
* items are routed here: RFC822.SIZE.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_size Size of the data.
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
*/
|
||||
public void fetchSize(Object in_reference, int in_size)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the data associated with specific data items.
|
||||
* The value of the following data items are routed here:
|
||||
* BODY[<section>]<<partial>>, BODY.PEEK[<section>]<<partial>>,
|
||||
* RFC822.HEADER, RFC822, RFC822.TEXT
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_data Chunk of message data.
|
||||
* @param in_bytesRead Number of bytes read so far.
|
||||
* @param in_totalBytes Total size of the body segment.
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
*/
|
||||
public void fetchData(Object in_reference, byte[] in_data, int in_bytesRead, int in_totalBytes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the value of the flags.
|
||||
* The value of the following data items are routed here: FLAGS.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_flags Flags for the object.
|
||||
* @see IMAP4Client#noop
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
*/
|
||||
public void fetchFlags(Object in_reference, StringBuffer in_flags)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the value of the body structure.
|
||||
* The value of the BODYSTRUCTURE data item is routed here.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_bodyStructure Body structure.
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
*/
|
||||
public void fetchBodyStructure(Object in_reference, StringBuffer in_bodyStructure)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the value of the envelope.
|
||||
* Note: Use ENVELOPE_* values for quick access to ENVELOPE Data items.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_fieldValue The value of the field.
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
*/
|
||||
public void fetchEnvelope(Object in_reference, StringBuffer[] in_fieldValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the value of the internal date.
|
||||
* The value of the INTERNALDATE data item is routed here.
|
||||
* @param in_reference A reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_internalDate The internal date of the message.
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
*/
|
||||
public void fetchInternalDate(Object in_reference, StringBuffer in_internalDate)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the value of the header.
|
||||
* The value of the following data items are routed here:
|
||||
* BODY[HEADER], BODY.PEEK[HEADER], RFC822.HEADER,
|
||||
* RFC822, BODY[0], BODY.PEEK[0], BODY[], BODY.PEEK[].
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_field Text representing the header field name.
|
||||
* @param in_value Value of the header field.
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
*/
|
||||
public void fetchHeader(Object in_reference, StringBuffer in_field, StringBuffer in_value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the value of the unique ID of the message.
|
||||
* The value of the UID data item is routed here.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_uid UID of the message.
|
||||
* @see IMAP4Client#fetch
|
||||
* @see IMAP4Client#uidFetch
|
||||
*/
|
||||
public void fetchUid(Object in_reference, int in_uid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Lsub Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Lists subscribed or active mailboxes that match the search criteria.
|
||||
* @param in_attribute Attributes of the mailbox.
|
||||
* @param in_delimeter Hierarchy delimiter.
|
||||
* @param in_name Name of the mailbox.
|
||||
* @see #list
|
||||
* @see IMAP4Client#lsub
|
||||
*/
|
||||
public void lsub(StringBuffer in_attribute, StringBuffer in_delimeter, StringBuffer in_name)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//List Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Lists mailboxes that match the search criteria.
|
||||
* @param in_attribute Attributes of the mailbox.
|
||||
* @param in_delimeter Hierarchy delimiter.
|
||||
* @param in_name Name of the mailbox.
|
||||
* @see #lsub
|
||||
* @see IMAP4Client#list
|
||||
*/
|
||||
public void list(StringBuffer in_attribute, StringBuffer in_delimeter, StringBuffer in_name)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Search Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Indicates the start of the retrieval of messages numbers that
|
||||
* match the search criteria.
|
||||
* @returns Reference object that associates all data
|
||||
* items for a given response or an error code.
|
||||
* @see IMAP4Client#search
|
||||
* @see IMAP4Client#uidSearch
|
||||
*/
|
||||
public Object searchStart()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the messages that match the search criteria.
|
||||
* Sends the SEARCH IMAP4 protocol command.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_message Message number.
|
||||
* @see IMAP4Client#search
|
||||
* @see IMAP4Client#uidSearch
|
||||
*/
|
||||
public void search(Object in_reference, int in_message)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates the end of the retrieval of message numbers
|
||||
* that match the search criteria.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @see #search
|
||||
* @see #searchStart
|
||||
* @see #fetchBodyStructure
|
||||
* @see IMAP4Client#search
|
||||
* @see IMAP4Client#uidSearch
|
||||
*/
|
||||
public void searchEnd(Object in_reference)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Status Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Total number of messages.
|
||||
* @param in_messages Total number of messages.
|
||||
* @see #statusRecent
|
||||
* @see #statusUidnext
|
||||
* @see IMAP4Client#status
|
||||
*/
|
||||
public void statusMessages(int in_messages)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of messages with the recent flag set.
|
||||
* @param in_recent Number of recent messages.
|
||||
* @see #statusMessages
|
||||
* @see #statusUidnext
|
||||
* @see IMAP4Client#status
|
||||
*/
|
||||
public void statusRecent(int in_recent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The next uid value to be assigned to a new message in the mailbox.
|
||||
* @param in_uidNext The next uid value.
|
||||
* @see #statusMessages
|
||||
* @see #statusUidvalidity
|
||||
* @see IMAP4Client#status
|
||||
*/
|
||||
public void statusUidnext(int in_uidNext)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The uid validity value of the mailbox.
|
||||
* @param in_uidValidity The unique ID of the mailbox.
|
||||
* @see #statusMessages,
|
||||
* @see #statusUidnext
|
||||
* @see IMAP4Client#status
|
||||
*/
|
||||
public void statusUidvalidity(int in_uidValidity)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of messages without the \Seen flag set.
|
||||
* @param in_unSeen Number of unseen messages.
|
||||
* @see #statusMessages
|
||||
* @see #statusUidnext
|
||||
* @see IMAP4Client#status
|
||||
*/
|
||||
public void statusUnseen(int in_unSeen)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Capability Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Listing of capabilities supported by the server.
|
||||
* Sends the CAPABILITY IMAP4 protocol command.
|
||||
* @param in_listing Listing of the capabilities that the server supports.
|
||||
* @see IMAP4Client#connect
|
||||
* @see IMAP4Client#capability
|
||||
*/
|
||||
public void capability(StringBuffer in_listing)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Exists Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The total number of messages in the selected mailbox.
|
||||
* @param in_messages Number of messages in the mailbox.
|
||||
* @see IMAP4Client#noop
|
||||
* @see IMAP4Client#examine
|
||||
* @see IMAP4Client#select
|
||||
*/
|
||||
public void exists(int in_messages)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Expunge Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Expunges the specified message.
|
||||
* @param in_message Number of message to expunge.
|
||||
* @see IMAP4Client#noop
|
||||
* @see IMAP4Client#expunge
|
||||
*/
|
||||
public void expunge(int in_message)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Recent Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The total number of messages with the \Recent flag set.
|
||||
* @param in_messages Number of \Recent messages.
|
||||
* @see IMAP4Client#noop
|
||||
* @see IMAP4Client#examine
|
||||
* @see IMAP4Client#select
|
||||
*/
|
||||
public void recent(int in_messages)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Flags Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The flags that are applicable for the selected mailbox.
|
||||
* @param in_flags Applicable flags.
|
||||
* @see #fetchFlags
|
||||
* @see IMAP4Client#examine
|
||||
* @see IMAP4Client#select
|
||||
*/
|
||||
public void flags(StringBuffer in_flags)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Bye Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The reason the connection was closed.
|
||||
* @param in_reason Reason for closing the connection.
|
||||
* @see IMAP4Client#disconnect
|
||||
* @see IMAP4Client#logout
|
||||
*/
|
||||
public void bye(StringBuffer in_reason)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Namespace Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Indicates the beginning of a namespace response.
|
||||
* Lets the client get the prefixes of namespaces used by a server
|
||||
* for personal mailboxes, other user's mailboxes, and shared objects.
|
||||
* @return Reference object to use to associate all data
|
||||
* items for a given response or an error code.
|
||||
* @see #nameSpaceEnd
|
||||
* @see #nameSpaceOtherUsers
|
||||
* @see #nameSpacePersonal
|
||||
* @see #nameSpaceShared
|
||||
* @see IMAP4Client#nameSpace
|
||||
*/
|
||||
public Object nameSpaceStart()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The personal namespace.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response or an error code.
|
||||
* @param in_personal The personal namespace.
|
||||
* @see #nameSpaceEnd
|
||||
* @see #nameSpaceOtherUsers
|
||||
* @see #nameSpaceStart
|
||||
* @see #nameSpaceShared
|
||||
* @see IMAP4Client#nameSpace
|
||||
*/
|
||||
public void nameSpacePersonal(Object in_reference, StringBuffer in_personal)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The other user's namespace.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response or an error code.
|
||||
* @param in_otherUsers The other user's namespace.
|
||||
* @see #nameSpaceEnd
|
||||
* @see #nameSpacePersonal
|
||||
* @see #nameSpaceStart
|
||||
* @see #nameSpaceShared
|
||||
* @see IMAP4Client#nameSpace
|
||||
*/
|
||||
public void nameSpaceOtherUsers(Object in_reference, StringBuffer in_otherUsers)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The shared namespace.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_shared The shared namespace.
|
||||
* @see #nameSpaceEnd
|
||||
* @see #nameSpaceOtherUsers
|
||||
* @see #nameSpacePersonal
|
||||
* @see #nameSpaceStart
|
||||
* @see IMAP4Client#nameSpace
|
||||
*/
|
||||
public void nameSpaceShared(Object in_reference, StringBuffer in_shared)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signals that the data for the particular namespace has been completely fetched.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @see #nameSpaceShared
|
||||
* @see #nameSpaceOtherUsers
|
||||
* @see #nameSpacePersonal
|
||||
* @see #nameSpaceStart
|
||||
* @see IMAP4Client#nameSpace
|
||||
*/
|
||||
public void nameSpaceEnd(Object in_reference)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//ACL Responses
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The mailbox name for which the ACL applies.
|
||||
* @param in_mailbox Name of the mailbox to which the control list applies.
|
||||
* @return Reference object to use to associate all data
|
||||
* items for a given response or an error code.
|
||||
* @see #aclEnd
|
||||
* @see #aclIdentifierRight
|
||||
* @see IMAP4Client#getACL
|
||||
*/
|
||||
public Object aclStart(StringBuffer in_mailbox)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The identifier rights pairs that apply to mailbox specified in aclStart.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_identifier Identifier for which the entry applies.
|
||||
* @param in_rights The client's current set of rights.
|
||||
* @see IMAP4Client#getACL
|
||||
*/
|
||||
public void aclIdentifierRight( Object in_reference, StringBuffer in_identifier,
|
||||
StringBuffer in_rights)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* The end of an ACL response.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @see #aclIdentifierRight
|
||||
* @see #aclStart
|
||||
* @see IMAP4Client#getACL
|
||||
*/
|
||||
public void aclEnd(Object in_reference)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//LISTRIGHTS Responses
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The start of a response to the LISTRIGHTS command.
|
||||
* @param in_mailbox Mailbox name for which the rights list applies.
|
||||
* @param in_identifier Identifier for which the rights list applies.
|
||||
* @return Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @see IMAP4Client#listRights
|
||||
*/
|
||||
public Object listRightsStart(StringBuffer in_mailbox, StringBuffer in_identifier)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The required rights for the identifier defined in listRightsStart.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_requiredRights The set of rights that the identifier will always
|
||||
* be granted in the mailbox.
|
||||
* @see #listRightsStart
|
||||
* @see IMAP4Client#listRights
|
||||
*/
|
||||
public void listRightsRequiredRights(Object in_reference, StringBuffer in_requiredRights)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The optional rights for the identifier defined in listRightsStart.
|
||||
* NOTE: Rights mentioned
|
||||
* in the same StringBuffer are tied together. Either all must be granted to the
|
||||
* identifier in the mailbox or none may be granted.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @param in_optionalRights Set of rights that the identifier may be granted
|
||||
* in the mailbox.
|
||||
* @see #listRightsStart
|
||||
* @see IMAP4Client#listRights
|
||||
*/
|
||||
public void listRightsOptionalRights(Object in_reference, StringBuffer in_optionalRights)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The end of a LISTRIGHTS response.
|
||||
* @param in_reference Reference object to use to associate all data
|
||||
* items for a given response.
|
||||
* @see #listRightsOptionalRights
|
||||
* @see #listRightsRequiredRights
|
||||
* @see IMAP4Client#listRights
|
||||
*/
|
||||
public void listRightsEnd(Object in_reference)
|
||||
{
|
||||
}
|
||||
|
||||
//MYRIGHTS Responses
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The set of rights that the user has to the mailbox.
|
||||
* @param in_mailbox The mailbox name for which these rights apply.
|
||||
* @param in_rights The client's current set of rights.
|
||||
* @see IMAP4Client#myRights
|
||||
*/
|
||||
public void myRights(StringBuffer in_mailbox, StringBuffer in_rights)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
##########################################################################
|
||||
# IMAP4 makefile.
|
||||
# created 9/9/97 -- Prasad
|
||||
#
|
||||
############################################################################
|
||||
# environment
|
||||
#SHELL = /usr/bin/ksh
|
||||
|
||||
# commands
|
||||
JAVAC = javac
|
||||
ARCH = $(shell uname -s)
|
||||
|
||||
ifeq ($(ARCH), SunOS)
|
||||
ARCH = SOLARIS
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH), HP-UX)
|
||||
ARCH = HPUX
|
||||
endif
|
||||
|
||||
# java flags
|
||||
DEBUGJAVAFLAG =
|
||||
OPTJAVAFLAG = -d $(CLASSDIR)
|
||||
JAVAFLAGS = $(OTHERJAVAFLAGS) $(OPTJAVAFLAG) $(DEBUGJAVAFLAG)
|
||||
|
||||
# files and directories
|
||||
CLASSDIR = ../../../built/$(ARCH)/protocol
|
||||
|
||||
#CLASSPATH = .:$(CLASSDIR):$(JDKCLASSPATH)
|
||||
|
||||
SRCS = \
|
||||
IMAP4Exception.java \
|
||||
IMAP4ServerException.java \
|
||||
IGlobals.java \
|
||||
IIMAP4Sink.java \
|
||||
IMAP4Sink.java \
|
||||
SystemPreferences.java \
|
||||
Dispatcher.java \
|
||||
IMAP4Client.java
|
||||
|
||||
OBJS = ${SRCS:.java=.class}
|
||||
|
||||
TARGET = package
|
||||
|
||||
.SUFFIXES: .java .class
|
||||
|
||||
all: $(CLASSDIR) $(TARGET)
|
||||
|
||||
install: $(TARGET)
|
||||
foreach f ( $(OBJS) ) \
|
||||
mv -f $$f $(CLASSDIR)/$$f \
|
||||
end
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
$(CLASSDIR):
|
||||
echo mkdir $(CLASSDIR)
|
||||
- mkdir -p $(CLASSDIR)
|
||||
|
||||
.java.class: $(SRCS)
|
||||
$(JAVAC) $(JAVAFLAGS) $<
|
||||
|
||||
clean:
|
||||
echo $(ARCH)
|
||||
rm -f ../../../built/$(ARCH)/protocol/netscape/messaging/imap4/*.class
|
||||
|
|
@ -0,0 +1,175 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Netscape Messaging Access SDK Version 3.5 code,
|
||||
* released on or about June 15, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998 Netscape
|
||||
* Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 and 1998 Netscape Communications Corporation
|
||||
* (http://home.netscape.com/misc/trademarks.html)
|
||||
*/
|
||||
|
||||
package netscape.messaging.imap4;
|
||||
|
||||
import netscape.messaging.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* The SystemPreferences class records the preferences
|
||||
* for the IMAP4 implementation of the Messaging Access SDK.
|
||||
* <p>The methods of this class return preferences for block
|
||||
* size, default port, debug flag, and time-out length.
|
||||
* @author alterego@netscape.com
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
public class SystemPreferences
|
||||
{
|
||||
/**
|
||||
*Creates a SystemPreferences object.
|
||||
*Default constructor for the SystemPreferences class.
|
||||
*/
|
||||
public SystemPreferences()
|
||||
{
|
||||
m_io = null;
|
||||
m_imapPort = 143;
|
||||
m_timeOut = 0;
|
||||
m_fDebug = false;
|
||||
m_blockSize = 1024;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the synchronous timeout for reading data from the socket
|
||||
* input buffer.
|
||||
* @param in_timeOut Time-out in milliseconds. Default: 60000 milliseconds.
|
||||
* @exception InterruptedIOException If the timeout period expires.
|
||||
* @see #getTimeout
|
||||
*/
|
||||
public synchronized void setTimeout(int in_timeOut) throws IOException
|
||||
{
|
||||
m_timeOut = in_timeOut;
|
||||
if(m_io != null)
|
||||
{
|
||||
m_io.setTimeout(in_timeOut);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the synchronous timeout for reading data from the socket
|
||||
* input buffer. If timeout expires, a InterruptedIOException is thrown.
|
||||
* @param in_timeOut Time-out in milliseconds.
|
||||
* @exception InterruptedIOException If the timeout period expires.
|
||||
* @see #setTimeout
|
||||
*/
|
||||
public synchronized int getTimeout()
|
||||
{
|
||||
return m_timeOut;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the debug flag.
|
||||
* @param in_fDebug Status of the flag. true: debug flag is present;
|
||||
* false: no debug flag.
|
||||
* @see #getDebugFlag
|
||||
*/
|
||||
public synchronized void setDebugFlag(boolean in_fDebug)
|
||||
{
|
||||
m_fDebug = in_fDebug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the debug flag.
|
||||
* @return boolean Status of the debug flag. true: debug flag is present;
|
||||
* false: no debug flag.
|
||||
* @see #setDebugFlag
|
||||
*/
|
||||
public synchronized boolean getDebugFlag()
|
||||
{
|
||||
return m_fDebug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the block size returned in fetchData.
|
||||
* @param int Block size.
|
||||
* @see #getBlockSize
|
||||
*/
|
||||
public synchronized void setBlockSize(int in_blockSize)
|
||||
{
|
||||
m_blockSize = in_blockSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the block size used in fetchData.
|
||||
* @return int Block size.
|
||||
* @see #setBlockSize
|
||||
*/
|
||||
public synchronized int getBlockSize()
|
||||
{
|
||||
return m_blockSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default port to connect to.
|
||||
* @param in_port Numeric ID of default port.
|
||||
* @see #getPort
|
||||
*/
|
||||
public synchronized void setPort(int in_port)
|
||||
{
|
||||
m_imapPort = in_port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default port to connect to.
|
||||
* @return int The default port.
|
||||
* @see #setPort
|
||||
*/
|
||||
public synchronized int getPort()
|
||||
{
|
||||
return m_imapPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IO object.
|
||||
* @param in_io The IO object
|
||||
*/
|
||||
protected synchronized void setIO(IO in_io)
|
||||
{
|
||||
m_io = in_io;
|
||||
}
|
||||
|
||||
|
||||
//Data members
|
||||
|
||||
/**The default IMAP4 port*/
|
||||
private int m_imapPort;
|
||||
|
||||
/**The time out in milliseconds for waiting for data on a read off the socket. Default: 1000*/
|
||||
private int m_timeOut;
|
||||
|
||||
/**A reference to the dispatcher so that it can update the time out*/
|
||||
private IO m_io;
|
||||
|
||||
/**The block size*/
|
||||
private int m_blockSize;
|
||||
|
||||
/**The debug flag*/
|
||||
private boolean m_fDebug;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,323 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Netscape Messaging Access SDK Version 3.5 code,
|
||||
* released on or about June 15, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998 Netscape
|
||||
* Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
import netscape.messaging.imap4.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
import java.lang.reflect.*;
|
||||
|
||||
/**
|
||||
* An e-mail client that utilizes the IMAP4rev1 SDK
|
||||
*
|
||||
* NOTE: This is only used on the client side and is NOT a part of
|
||||
* the SDK.. used for testing purposes only
|
||||
*
|
||||
* @author alterego@netscape.com
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
public class Email_Client
|
||||
{
|
||||
public Email_Client()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test capability, noop, status, select, fetch, close, create, rename,
|
||||
* list, delete, copy, store, search ,expunge, status
|
||||
*/
|
||||
public void testRun1(IMAP4Client in_client) throws IOException
|
||||
{
|
||||
System.out.println("---------------------- testRun1 -----------------------------");
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// append messages to inbox
|
||||
///////////////////////////////////////////////////////////////////
|
||||
File l_file = null;
|
||||
FileInputStream l_inputStream = null;
|
||||
|
||||
l_file = new File("msg2.out");
|
||||
l_inputStream = new FileInputStream(l_file);
|
||||
in_client.append("inbox", "", "", l_inputStream);
|
||||
in_client.processResponses();
|
||||
l_inputStream = new FileInputStream(l_file);
|
||||
in_client.append("inbox", "", "", l_inputStream);
|
||||
in_client.processResponses();
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// capability, noop, status.. select fetch close
|
||||
///////////////////////////////////////////////////////////////////
|
||||
in_client.capability();
|
||||
in_client.processResponses();
|
||||
in_client.noop();
|
||||
in_client.processResponses();
|
||||
in_client.status("inbox", "(MESSAGES RECENT UIDVALIDITY UNSEEN UIDNEXT)");
|
||||
in_client.processResponses();
|
||||
//in_client.status("inbox", "( )");
|
||||
//in_client.processResponses();
|
||||
in_client.select("inbox");
|
||||
in_client.processResponses();
|
||||
in_client.fetch("1:2", "(BODY[])");
|
||||
in_client.processResponses();
|
||||
in_client.fetch("1", "(RFC822.SIZE BODYSTRUCTURE INTERNALDATE)");
|
||||
in_client.processResponses();
|
||||
in_client.fetch("1", "(BODY[] INTERNALDATE)");
|
||||
in_client.processResponses();
|
||||
in_client.fetch("1", "(UID BODY[] INTERNALDATE)");
|
||||
in_client.processResponses();
|
||||
in_client.fetch("1", "(RFC822.TEXT ENVELOPE)");
|
||||
in_client.processResponses();
|
||||
in_client.close();
|
||||
in_client.processResponses();
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Create, rename, list, delete mailbox
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
in_client.create("NEWMAILBOX");
|
||||
in_client.rename("NEWMAILBOX", "RENAMEDBOX");
|
||||
in_client.list("\"\"", "*");
|
||||
in_client.delete("RENAMEDBOX");
|
||||
in_client.processResponses();
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Select inbox, copy msg, delete msg, search, expunge, close inbox
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
in_client.select("inbox");
|
||||
in_client.copy("1:2", "inbox");
|
||||
// The following line of code will set the DELETED flag on all the
|
||||
// messages in the currently selected mailbox. This has been removed
|
||||
// so that users who run this test program do not accidentally delete
|
||||
// their inbox.
|
||||
// derekt 06/03/98
|
||||
//in_client.store("1:*", "+FLAGS", "(\\DELETED)");
|
||||
in_client.search("DELETED");
|
||||
in_client.expunge();
|
||||
in_client.close();
|
||||
in_client.processResponses();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test create, list, lsub, delete, status, select, search, subscribe,
|
||||
* unsubscribe
|
||||
*/
|
||||
public void testRun2(IMAP4Client in_client) throws IOException
|
||||
{
|
||||
System.out.println("---------------------- testRun2 -----------------------------");
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Test listing functionality
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
in_client.create("mbox");
|
||||
in_client.list("\"\"", "*");
|
||||
in_client.processResponses();
|
||||
in_client.subscribe("mbox");
|
||||
in_client.lsub("\"\"", "*");
|
||||
in_client.processResponses();
|
||||
in_client.unsubscribe("mbox");
|
||||
in_client.lsub("\"\"", "*");
|
||||
in_client.delete("mbox");
|
||||
in_client.processResponses();
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Test status, search
|
||||
///////////////////////////////////////////////////////////////////
|
||||
in_client.status("inbox", "(MESSAGES UIDNEXT UIDVALIDITY)");
|
||||
in_client.processResponses();
|
||||
in_client.select("inbox");
|
||||
in_client.search("SUBJECT \"afternoon\"");
|
||||
in_client.processResponses();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test append, search, fetch, delete
|
||||
*/
|
||||
public void testRun3(IMAP4Client in_client) throws IOException
|
||||
{
|
||||
File l_file = null;
|
||||
FileInputStream l_inputStream = null;
|
||||
|
||||
System.out.println("---------------------- testRun3 -----------------------------");
|
||||
|
||||
l_file = new File("msg2.out");
|
||||
l_inputStream = new FileInputStream(l_file);
|
||||
in_client.append("inbox", "", "", l_inputStream);
|
||||
in_client.processResponses();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Testing check, examine, pipelineStart, pipelineEnd, sendCommand
|
||||
*/
|
||||
public void testRun4(IMAP4Client in_client) throws IOException
|
||||
{
|
||||
System.out.println("---------------------- testRun4 -----------------------------");
|
||||
|
||||
in_client.select("inbox");
|
||||
in_client.check();
|
||||
in_client.close();
|
||||
in_client.examine("inbox");
|
||||
in_client.close();
|
||||
in_client.processResponses();
|
||||
|
||||
in_client.sendCommand("SELECT INBOX");
|
||||
in_client.processResponses();
|
||||
in_client.sendCommand("CLOSE");
|
||||
in_client.processResponses();
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing uidCopy, uidFetch, uidSearch, uidStore
|
||||
*/
|
||||
public void testRun5(IMAP4Client in_client) throws IOException
|
||||
{
|
||||
int l_size = 0;
|
||||
Integer l_uid = null;
|
||||
String l_uidString = null;
|
||||
|
||||
System.out.println("---------------------- testRun5 -----------------------------");
|
||||
|
||||
File l_file = null;
|
||||
FileInputStream l_inputStream = null;
|
||||
|
||||
l_file = new File("msg1.out");
|
||||
l_inputStream = new FileInputStream(l_file);
|
||||
in_client.append("inbox", "", "", l_inputStream);
|
||||
in_client.processResponses();
|
||||
l_inputStream = new FileInputStream(l_file);
|
||||
in_client.append("inbox", "", "", l_inputStream);
|
||||
in_client.processResponses();
|
||||
|
||||
in_client.select("inbox");
|
||||
in_client.fetch("1:2", "UID");
|
||||
in_client.processResponses();
|
||||
l_size = m_sink.m_uidNumbers.size();
|
||||
for(int i = 0; i < l_size; i++)
|
||||
{
|
||||
l_uid = (Integer)m_sink.m_uidNumbers.elementAt(i);
|
||||
l_uidString = l_uid.toString();
|
||||
in_client.uidFetch(l_uidString, "ALL");
|
||||
in_client.uidCopy(l_uidString, "inbox");
|
||||
}
|
||||
in_client.uidSearch("SUBJECT \"afternoon\"");
|
||||
in_client.processResponses();
|
||||
in_client.uidStore(l_uidString, "+FLAGS", "(\\DELETED)");
|
||||
|
||||
in_client.processResponses();
|
||||
in_client.close();
|
||||
in_client.processResponses();
|
||||
m_sink.m_uidNumbers.removeAllElements();
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing namespace, setacl, deleteacl, getacl, listrights, myrights
|
||||
*/
|
||||
public void testRun6(IMAP4Client in_client) throws IOException
|
||||
{
|
||||
System.out.println("---------------------- testRun6 -----------------------------");
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Test namespace extension
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
in_client.nameSpace();
|
||||
in_client.processResponses();
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Test acl extension
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
in_client.myRights("inbox");
|
||||
in_client.processResponses();
|
||||
in_client.getACL("inbox");
|
||||
in_client.processResponses();
|
||||
in_client.deleteACL("inbox", "sama44");
|
||||
in_client.processResponses();
|
||||
in_client.setACL("inbox", "sama44", "lrswipcda");
|
||||
in_client.processResponses();
|
||||
in_client.listRights("inbox", "sama44");
|
||||
in_client.processResponses();
|
||||
}
|
||||
|
||||
//Data members
|
||||
////////////////////////////////////////////////////////////////////
|
||||
protected ServerSink m_sink;
|
||||
|
||||
public static void main(String args[])
|
||||
{
|
||||
try
|
||||
{
|
||||
Email_Client m_email = new Email_Client();
|
||||
ServerSink l_sink = new ServerSink();
|
||||
m_email.m_sink = l_sink;
|
||||
IMAP4Client l_client = new IMAP4Client(l_sink);
|
||||
SystemPreferences l_preferences = l_client.getSystemPreferences();
|
||||
l_preferences.setDebugFlag(true);
|
||||
l_preferences.setBlockSize(100000);
|
||||
|
||||
//Connect
|
||||
l_client.connect("alterego.mcom.com", 143); //Messaging Server 3.01
|
||||
// l_client.connect("sama.mcom.com", 143); //(Netscape Messaging Server 4.0a0 (built Dec 14 1997)
|
||||
l_client.processResponses();
|
||||
|
||||
l_client.noop();
|
||||
l_client.processResponses();
|
||||
|
||||
//Login
|
||||
l_client.login("imaptest","test"); //Messaging Server 3.01
|
||||
// l_client.login("sama44","sama44"); //(Netscape Messaging Server 4.0a0 (built Dec 14 1997)
|
||||
l_client.processResponses();
|
||||
|
||||
//Test Runs
|
||||
m_email.testRun1(l_client);
|
||||
m_email.testRun2(l_client);
|
||||
|
||||
m_email.testRun3(l_client);
|
||||
m_email.testRun4(l_client);
|
||||
m_email.testRun5(l_client);
|
||||
|
||||
//IMAP extensions
|
||||
// m_email.testRun6(l_client);
|
||||
|
||||
//Logout
|
||||
l_client.logout();
|
||||
l_client.processResponses();
|
||||
}
|
||||
catch(IMAP4ServerException e)
|
||||
{
|
||||
System.out.println("IMAP4ServerException: " + e.getMessage());
|
||||
}
|
||||
catch(IMAP4Exception e)
|
||||
{
|
||||
System.out.println("IMAP4Exception: " + e.getMessage());
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
System.out.println("IOException: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,593 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Netscape Messaging Access SDK Version 3.5 code,
|
||||
* released on or about June 15, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998 Netscape
|
||||
* Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
import netscape.messaging.imap4.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* ServerSink is the data sink for all IMAP4 commands
|
||||
* @author alterego@netscape.com
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
public class ServerSink extends IMAP4Sink
|
||||
{
|
||||
/** Creates an ServerSink object */
|
||||
public ServerSink()
|
||||
{
|
||||
m_uidNumbers = new Vector();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Indicates the end of response(s) for successful commands
|
||||
* @param in_tag The tag associated with the command
|
||||
* @param in_status "OK"
|
||||
* @param in_reason The reason for in_status
|
||||
*/
|
||||
public void taggedLine( StringBuffer in_tag, StringBuffer in_status,
|
||||
StringBuffer in_reason)
|
||||
{
|
||||
System.out.println("TAG: " + in_tag);
|
||||
System.out.println("STATUS: " + in_status);
|
||||
System.out.println("REASON: " + in_reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates the response for unsuccessful commands (error responses)
|
||||
* @param in_tag The tag associated with the command
|
||||
* @param in_status "NO" or "BAD"
|
||||
* @param in_reason The reason for in_status
|
||||
*/
|
||||
public void error( StringBuffer in_tag, StringBuffer in_status,
|
||||
StringBuffer in_reason) throws IMAP4ServerException
|
||||
{
|
||||
System.out.println("----------ERROR---------");
|
||||
System.out.println("TAG: " + in_tag);
|
||||
System.out.println("STATUS: " + in_status);
|
||||
System.out.println("REASON: " + in_reason);
|
||||
System.out.println("----------ERROR---------");
|
||||
|
||||
throw new IMAP4ServerException(in_tag + " " + in_reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* An unsolicited ok response
|
||||
* @param in_responseCode The response code (optional)
|
||||
* @param in_information An information message in the form of human-readable text
|
||||
*/
|
||||
public void ok(StringBuffer in_responseCode, StringBuffer in_information)
|
||||
{
|
||||
System.out.println("CODE: " + in_responseCode);
|
||||
System.out.println("Info: " + in_information);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raw (unparsed) data is pushed into here. Note: Matches up with sendCommand
|
||||
* and will also be used as a default method to push information that doesn't
|
||||
* belong anywhere else
|
||||
* @param in_tag The tag associated with the command
|
||||
* @param in_data The raw data
|
||||
*/
|
||||
public void rawResponse(StringBuffer in_data)
|
||||
{
|
||||
System.out.println("rawResponse: " + in_data);
|
||||
}
|
||||
//Fetch Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Indicates the beginning of a fetch response
|
||||
* @param in_msg The message number or uid
|
||||
* @return Object A reference object that will be used to associate all data
|
||||
* items for a given response
|
||||
*/
|
||||
public Object fetchStart(int in_msg)
|
||||
{
|
||||
System.out.println("Fetch Start.................. " + in_msg);
|
||||
StringBuffer l_buffer = new StringBuffer();
|
||||
l_buffer.append("Msg Num: " + in_msg);
|
||||
return l_buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* The data for the particular message has been completely fetched
|
||||
* @param in_reference A reference object that will be used to associate all data
|
||||
* items for a given response
|
||||
*/
|
||||
public void fetchEnd(Object in_reference)
|
||||
{
|
||||
System.out.println("Fetch End.................. ");
|
||||
}
|
||||
|
||||
/**
|
||||
* The size of the message
|
||||
* Data item(s): RFC822.SIZE
|
||||
* @param in_reference A reference object that will be used to associate all data
|
||||
* items for a given response
|
||||
* @param in_size The size of the data
|
||||
*
|
||||
*/
|
||||
public void fetchSize(Object in_reference, int in_size)
|
||||
{
|
||||
String l_data = "Size: " + in_size;
|
||||
System.out.println(l_data);
|
||||
((StringBuffer)in_reference).append(l_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* The data associated with the data items listed below
|
||||
* Data item(s): BODY[, BODY.PEEK[, RFC822.HEADER, RFC822, RFC822.TEXT
|
||||
* @param in_reference A reference object that will be used to associate all data
|
||||
* items for a given response
|
||||
* @param in_data A chunk of message data
|
||||
* @param in_bytesRead The number of bytes read so far
|
||||
* @param in_totalBytes The total size of the body segment
|
||||
*/
|
||||
public void fetchData(Object in_reference, byte[] in_data, int in_bytesRead, int in_totalBytes)
|
||||
{
|
||||
String l_data = new String(in_data);
|
||||
// System.out.println("Data: " + l_data);
|
||||
((StringBuffer)in_reference).append(l_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* The value of the flags
|
||||
* Data item(s): FLAGS
|
||||
* @param in_reference A reference object that will be used to associate all data
|
||||
* items for a given response
|
||||
* @param in_flags The flags
|
||||
|
||||
*/
|
||||
public void fetchFlags(Object in_reference, StringBuffer in_flags)
|
||||
{
|
||||
System.out.println("Flags: " + in_flags);
|
||||
((StringBuffer)in_reference).append("Flags: " + in_flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* The value of the body structure
|
||||
* Data item(s): BODY, BODYSTRUCTURE
|
||||
* @param in_reference A reference object that will be used to associate all data
|
||||
* items for a given response
|
||||
* @param in_bodyStructure The body structure
|
||||
*/
|
||||
public void fetchBodyStructure(Object in_reference, StringBuffer in_bodyStructure)
|
||||
{
|
||||
System.out.println("BodyStructure: " + in_bodyStructure);
|
||||
((StringBuffer)in_reference).append("BodyStructure: " + in_bodyStructure);
|
||||
}
|
||||
|
||||
/**
|
||||
* The value of the envelope Note: Use ENVELOPE_* values for quick access
|
||||
* Data item(s): ENVELOPE
|
||||
* @param in_reference A reference object that will be used to associate all data
|
||||
* items for a given response
|
||||
* @param in_fieldValue The value of the field
|
||||
*/
|
||||
public void fetchEnvelope(Object in_reference, StringBuffer[] in_fieldValue)
|
||||
{
|
||||
for(int i=0; i<in_fieldValue.length; i++)
|
||||
{
|
||||
System.out.println("Env: " + in_fieldValue[i]);
|
||||
((StringBuffer)in_reference).append("Env: " + in_fieldValue[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The value of the internal date
|
||||
* Data item(s): INTERNALDATE
|
||||
* @param in_reference A reference object that will be used to associate all data
|
||||
* items for a given response
|
||||
* @param in_internalDate The internal date of the message
|
||||
*/
|
||||
public void fetchInternalDate(Object in_reference, StringBuffer in_internalDate)
|
||||
{
|
||||
System.out.println("Internal Date: " + in_internalDate);
|
||||
((StringBuffer)in_reference).append("Internal Date: " + in_internalDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* The value of the header
|
||||
* Data item(s): BODY[HEADER, BODY.PEEK[HEADER, RFC822.HEADER,
|
||||
* RFC822, BODY[0], BODY.PEEK[0], BODY[], BODY.PEEK[]
|
||||
* @param in_reference A reference object that will be used to associate all data
|
||||
* items for a given response
|
||||
* @param in_field The text representing the field name
|
||||
* @param in_value The value of the field
|
||||
*/
|
||||
public void fetchHeader(Object in_reference, StringBuffer in_field, StringBuffer in_value)
|
||||
{
|
||||
System.out.println("Header: " + in_field + ": " + in_value);
|
||||
((StringBuffer)in_reference).append("Header: " + in_field + ": " + in_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* The value of the uid of the message
|
||||
* Data item(s): UID
|
||||
* @param in_reference A reference object that will be used to associate all data
|
||||
* items for a given response
|
||||
* @param in_uid The uid of the message
|
||||
*/
|
||||
public void fetchUid(Object in_reference, int in_uid)
|
||||
{
|
||||
System.out.println("UID: " + in_uid);
|
||||
((StringBuffer)in_reference).append("UID: " + in_uid);
|
||||
m_uidNumbers.addElement(new Integer(in_uid));
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Lsub Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Subscribed or active mailboxes that matched the search criteria
|
||||
* @param in_attribute The attributes of the mailbox
|
||||
* @param in_delimeter The hierarchy delimeter
|
||||
* @param in_name The name of the mailbox
|
||||
*/
|
||||
public void lsub(StringBuffer in_attribute, StringBuffer in_delimeter, StringBuffer in_name)
|
||||
{
|
||||
System.out.println("LSub attribute: " + in_attribute + " delimeter: " + in_delimeter + " name: " + in_name);
|
||||
}
|
||||
|
||||
//List Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Mailboxes that matched the search criteria
|
||||
* @param in_attribute The attributes of the mailbox
|
||||
* @param in_delimeter The hierarchy delimeter
|
||||
* @param in_name The name of the mailbox
|
||||
*/
|
||||
public void list(StringBuffer in_attribute, StringBuffer in_delimeter, StringBuffer in_name)
|
||||
{
|
||||
System.out.println("List attribute: " + in_attribute + " delimeter: " + in_delimeter + " name: " + in_name);
|
||||
}
|
||||
|
||||
//Search Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The start of the retrieval of messages numbers that matched the search criteria
|
||||
* @returns Object A reference object
|
||||
*/
|
||||
public Object searchStart()
|
||||
{
|
||||
System.out.println("Search Start");
|
||||
return new StringBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* The messages that matched the search criteria
|
||||
* @param in_message The messages
|
||||
*/
|
||||
public void search(Object in_reference, int in_message)
|
||||
{
|
||||
((StringBuffer)in_reference).append(in_message + " ");
|
||||
System.out.println("SEARCH: " + in_message);
|
||||
}
|
||||
|
||||
/**
|
||||
* The messages that matched the search criteria
|
||||
* @param in_messages The messages
|
||||
*/
|
||||
public void searchEnd(Object in_reference)
|
||||
{
|
||||
System.out.println("Search Done.");
|
||||
}
|
||||
|
||||
//Status Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The total number of messages
|
||||
* @param in_messages The total number of messages
|
||||
*/
|
||||
public void statusMessages(int in_messages)
|
||||
{
|
||||
System.out.println("Status Messages: " + in_messages);
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of messages with the recent flag set
|
||||
* @param in_recent The number of recent messages
|
||||
*/
|
||||
public void statusRecent(int in_recent)
|
||||
{
|
||||
System.out.println("Status recent: " + in_recent);
|
||||
}
|
||||
|
||||
/**
|
||||
* The next uid value that will be assigned to a new message in the mailbox
|
||||
* @param in_uidNext The next uid value
|
||||
*/
|
||||
public void statusUidnext(int in_uidNext)
|
||||
{
|
||||
System.out.println("Status UIDNext: " + in_uidNext);
|
||||
}
|
||||
|
||||
/**
|
||||
* The uid validity value of the mailbox
|
||||
* @param in_uidValidity The uid
|
||||
*/
|
||||
public void statusUidvalidity(int in_uidValidity)
|
||||
{
|
||||
System.out.println("Status UIDValidity: " + in_uidValidity);
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of messages without the \Seen flag set
|
||||
* @param in_unSeen The number of unseen messages
|
||||
*/
|
||||
public void statusUnseen(int in_unSeen)
|
||||
{
|
||||
System.out.println("Status Unseen: " + in_unSeen);
|
||||
}
|
||||
|
||||
//Capability Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The capability of the IMAP server
|
||||
* @param in_listing A listing of the capabilities that the server supports
|
||||
*/
|
||||
public void capability(StringBuffer in_listing)
|
||||
{
|
||||
System.out.println("CAPABILITY: " + in_listing);
|
||||
}
|
||||
|
||||
//Exists Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The total number of messages in the selected mailbox
|
||||
* @param in_messages The number of messages
|
||||
*/
|
||||
public void exists(int in_messages)
|
||||
{
|
||||
System.out.println("EXISTS: " + in_messages);
|
||||
}
|
||||
|
||||
//Expunge Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The message number of the expunged message
|
||||
* @param in_message The message number
|
||||
*/
|
||||
public void expunge(int in_message)
|
||||
{
|
||||
System.out.println("EXPUNGE: " + in_message);
|
||||
}
|
||||
|
||||
//Recent Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The total number of messages with the \Recent flag set
|
||||
* @param in_messages The number of messages
|
||||
*/
|
||||
public void recent(int in_messages)
|
||||
{
|
||||
System.out.println("RECENT: " + in_messages);
|
||||
}
|
||||
|
||||
//Flags Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The flags that are applicable for the selected mailbox
|
||||
* @param in_flags The applicable flags
|
||||
*/
|
||||
public void flags(StringBuffer in_flags)
|
||||
{
|
||||
System.out.println("FLAGS: " + in_flags);
|
||||
}
|
||||
|
||||
//Bye Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The reason why the connection was closed
|
||||
* @param in_reason The reason
|
||||
*/
|
||||
public void bye(StringBuffer in_reason)
|
||||
{
|
||||
System.out.println("BYE: " + in_reason);
|
||||
}
|
||||
|
||||
//Namespace Response
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Indicates the beginning of a namespace response
|
||||
* @return Object A reference object that will be used to associate all data
|
||||
* items for a given response
|
||||
*/
|
||||
public Object nameSpaceStart()
|
||||
{
|
||||
System.out.println("NAMESPACE START....");
|
||||
return new StringBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* The personal namespace
|
||||
* @param in_reference A reference object that will be used to associate all data
|
||||
* items for a given response
|
||||
* @param in_personal The personal namespace
|
||||
*/
|
||||
public void nameSpacePersonal(Object in_reference, StringBuffer in_personal)
|
||||
{
|
||||
System.out.println("Personal Namespace: " + in_personal);
|
||||
((StringBuffer)in_reference).append("Personal Namespace: " + in_personal);
|
||||
}
|
||||
|
||||
/**
|
||||
* The other user's namespace
|
||||
* @param in_reference A reference object that will be used to associate all data
|
||||
* items for a given response
|
||||
* @param in_otherUsers The other user's namespace
|
||||
*/
|
||||
public void nameSpaceOtherUsers(Object in_reference, StringBuffer in_otherUsers)
|
||||
{
|
||||
System.out.println("Other Users Namespace: " + in_otherUsers);
|
||||
((StringBuffer)in_reference).append("Other Users Namespace: " + in_otherUsers);
|
||||
}
|
||||
|
||||
/**
|
||||
* The shared namespace
|
||||
* @param in_reference A reference object that will be used to associate all data
|
||||
* items for a given response
|
||||
* @param in_shared The shared namespace
|
||||
*/
|
||||
public void nameSpaceShared(Object in_reference, StringBuffer in_shared)
|
||||
{
|
||||
System.out.println("Shared Namespace: " + in_shared);
|
||||
((StringBuffer)in_reference).append("Shared Users Namespace: " + in_shared);
|
||||
}
|
||||
|
||||
/**
|
||||
* The data for the particular namespace has been completely fetched
|
||||
* @param in_reference A reference object that will be used to associate all data
|
||||
* items for a given response
|
||||
*/
|
||||
public void nameSpaceEnd(Object in_reference)
|
||||
{
|
||||
System.out.println("NAMESPACE END....");
|
||||
}
|
||||
|
||||
|
||||
//ACL Responses
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The mailbox name for which the ACL applies
|
||||
* @return Object A reference object that will be used to associate all data
|
||||
* items for a given response
|
||||
*/
|
||||
public Object aclStart(StringBuffer in_mailbox)
|
||||
{
|
||||
System.out.println("ACL START... " + in_mailbox);
|
||||
return new StringBuffer(in_mailbox.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* The identifier rights pairs that apply to mailbox specified in aclStart
|
||||
* @param in_reference A reference object that will be used to associate all data
|
||||
* items for a given response
|
||||
* @param in_identifier The identifier for which the entry applies
|
||||
* @param in_rights The set of rights that the identifier has
|
||||
*/
|
||||
public void aclIdentifierRight( Object in_reference, StringBuffer in_identifier,
|
||||
StringBuffer in_rights)
|
||||
{
|
||||
System.out.println("ACL: " + in_identifier + " " + in_rights);
|
||||
((StringBuffer)in_reference).append("ACL: " + in_identifier + " " + in_rights);
|
||||
}
|
||||
|
||||
/**
|
||||
* The end of an ACL response
|
||||
* @param in_reference A reference object that will be used to associate all data
|
||||
* items for a given response
|
||||
*/
|
||||
public void aclEnd(Object in_reference)
|
||||
{
|
||||
System.out.println("ACL END...");
|
||||
}
|
||||
|
||||
|
||||
//LISTRIGHTS Responses
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The start of a response to the LISTRIGHTS command
|
||||
* @param in_mailbox The mailbox name for which the rights list applies
|
||||
* @param in_identifier The identifier for which the rights list applies
|
||||
* @return Object A reference object that will be used to associate all data
|
||||
* items for a given response
|
||||
*/
|
||||
public Object listRightsStart(StringBuffer in_mailbox, StringBuffer in_identifier)
|
||||
{
|
||||
System.out.println("LISTRIGHTS START.... " + in_mailbox + " " + in_identifier);
|
||||
return new StringBuffer(in_mailbox.toString() + in_identifier.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* The required rights for in_identifier defined in listRightsStart
|
||||
* @param in_reference A reference object that will be used to associate all data
|
||||
* items for a given response
|
||||
* @param in_requiredRights The set of rights that the identifier will always
|
||||
* be granted in the mailbox
|
||||
*/
|
||||
public void listRightsRequiredRights(Object in_reference, StringBuffer in_requiredRights)
|
||||
{
|
||||
System.out.println("...REQUIRED RIGHTS : " + in_requiredRights);
|
||||
((StringBuffer)in_reference).append("...REQUIRED RIGHTS : " + in_requiredRights);
|
||||
}
|
||||
|
||||
/**
|
||||
* The optional rights for in_identifier defined in listRightsStart. NOTE: Rights mentioned
|
||||
* in the same StringBuffer are tied together--either all must be granted to the
|
||||
* identifier in the mailbox or none may be granted
|
||||
* @param in_reference A reference object that will be used to associate all data
|
||||
* items for a given response
|
||||
* @param in_optionalRights A set of rights that the identifier may be granted
|
||||
* in the mailbox
|
||||
*/
|
||||
public void listRightsOptionalRights(Object in_reference, StringBuffer in_optionalRights)
|
||||
{
|
||||
System.out.println("...OPTIONAL RIGHTS : " + in_optionalRights);
|
||||
((StringBuffer)in_reference).append("...OPTIONAL RIGHTS : " + in_optionalRights);
|
||||
}
|
||||
|
||||
/**
|
||||
* The end of an LISTRIGHTS response
|
||||
* @param in_reference A reference object that will be used to associate all data
|
||||
* items for a given response
|
||||
*/
|
||||
public void listRightsEnd(Object in_reference)
|
||||
{
|
||||
System.out.println("LISTRIGHTS END....");
|
||||
}
|
||||
|
||||
//MYRIGHTS Responses
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* MYRIGHTS response
|
||||
* @param in_mailbox The mailbox name for which these rights apply
|
||||
* @param in_rights The set of rights that the client has
|
||||
*/
|
||||
public void myRights(StringBuffer in_mailbox, StringBuffer in_rights)
|
||||
{
|
||||
System.out.println("MYRIGHTS.... " + in_mailbox + " " + in_rights);
|
||||
}
|
||||
|
||||
|
||||
//Data members
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
public Vector m_uidNumbers;
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
|
||||
From: Fred Foobar <foobar@Blurdybloop.COM>
|
||||
Subject: afternoon meeting
|
||||
To: mooch@owatagu.siam.edu
|
||||
Message-Id: <B27397-0100000@Blurdybloop.COM>
|
||||
MIME-Version: 1.0
|
||||
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
|
||||
|
||||
Hello Joe, do you think we can meet at 3:30 tomorrow?
|
||||
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,20 @@
|
|||
#
|
||||
# GNU Makefile for Messaging SDK
|
||||
#
|
||||
|
||||
all:
|
||||
cd Messaging/src; $(MAKE) $(MFLAGS)
|
||||
cd MIME/src; $(MAKE) $(MFLAGS)
|
||||
cd POP3/src; $(MAKE) $(MFLAGS)
|
||||
cd IMAP4/src; $(MAKE) $(MFLAGS)
|
||||
cd SMTP/src; $(MAKE) $(MFLAGS)
|
||||
|
||||
javaDoc:
|
||||
- mkdir ../built/$(ARCH)/docs/mime
|
||||
- mkdir ../built/$(ARCH)/docs/pop3
|
||||
- mkdir ../built/$(ARCH)/docs/imap4
|
||||
- mkdir ../built/$(ARCH)/docs/smtp
|
||||
cd POP3/src; javadoc -d ../../../built/$(ARCH)/docs/POP3 *.java
|
||||
cd smtp/src; javadoc -d ../../../built/$(ARCH)/docs/smtp *.java
|
||||
cd imap4/src; javadoc -d ../../../built/$(ARCH)/docs/imap4 *.java
|
||||
cd MIME/src; javadoc -d ../../../built/$(ARCH)/docs/mime *.java
|
|
@ -0,0 +1,355 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Netscape Messaging Access SDK Version 3.5 code,
|
||||
* released on or about June 15, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998 Netscape
|
||||
* Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 and 1998 Netscape Communications Corporation
|
||||
* (http://home.netscape.com/misc/trademarks.html)
|
||||
*/
|
||||
|
||||
package netscape.messaging.pop3;
|
||||
|
||||
/**
|
||||
*IPOP3Sink is the interface for the response sink for all POP3 commands.
|
||||
*<p>The IPOP3Sink interface contains callback methods for each
|
||||
*client call. The client’s processResponses call invokes the
|
||||
*appropriate interface callback method.
|
||||
*<p>To utilize the POP3 object, you must extend this
|
||||
*interface. As a convenience, the Messaging Access SDK
|
||||
*provides the POP3Sink class, which implements the IPOP3Sink
|
||||
*interface. You can save a step by extending the POP3Sink class, or
|
||||
*you can implement your own class based on the IPOP3Sink interface.
|
||||
*The constructor for the POP3Client class takes a IPOP3Sink
|
||||
*interface as a parameter.
|
||||
*<p>For detailed information about POP3,
|
||||
*see RFC 1939. (For the URL, see "Where to Find More Information" in "About This Book.")
|
||||
*@author derekt@netscape.com
|
||||
*@version 1.0
|
||||
*/
|
||||
|
||||
public interface IPOP3Sink
|
||||
{
|
||||
/**
|
||||
*Notification for the response to the connection to the server.
|
||||
*<P>Connects to the server using the default port.
|
||||
*See "POP3 Response Codes" in Chapter 5, "Receiving Mail with POP3."
|
||||
* @param in_responseMessage Server response for connect.
|
||||
* @see POP3Client#connect
|
||||
* @see #quit
|
||||
*/
|
||||
public void connect( StringBuffer in_responseMessage );
|
||||
|
||||
/**
|
||||
*Notification for the response to the DELE command.
|
||||
*Marks a message for deletion on the server;
|
||||
*actually deleted when quit() is called.
|
||||
*Sends the DELE [arg] POP3 protocol command.
|
||||
* @param in_responseMessage Server response for delete.
|
||||
* @see POP3Client#delete
|
||||
* @see #quit
|
||||
*/
|
||||
public void delete( StringBuffer in_responseMessage );
|
||||
|
||||
/**
|
||||
*Error notification.
|
||||
*Called when an error occurs.
|
||||
*See "POP3 Response Codes" in Chapter 5, "Receiving Mail with POP3."
|
||||
* @param in_responseMessage Server response for an error.
|
||||
* @exception POP3ServerException If a server response error occurs.
|
||||
* @see POP3Client#processResponses
|
||||
*/
|
||||
public void error( StringBuffer in_responseMessage ) throws POP3ServerException;
|
||||
|
||||
/**
|
||||
*Notification for the start of the LIST command.
|
||||
*Along with list and listComplete, can be used to list
|
||||
*all messages.
|
||||
* @see POP3Client#list
|
||||
* @see #listComplete
|
||||
* @see #list
|
||||
*/
|
||||
public void listStart();
|
||||
|
||||
/**
|
||||
*Notification for the response to the LIST command.
|
||||
*Along with listStart and listStartComplete, can be used to
|
||||
*list all messages.
|
||||
* @param in_messageNumber Number of message to list.
|
||||
* @param in_octetCount Octet count of the message.
|
||||
* @see POP3Client#list
|
||||
* @see #listStart
|
||||
* @see #listComplete
|
||||
*/
|
||||
public void list( int in_messageNumber, int in_octetCount );
|
||||
|
||||
/**
|
||||
*Notification for the completion of the LIST command.
|
||||
*Along with list and listStartComplete, can be used to list
|
||||
*all messages.
|
||||
* @see POP3Client#list
|
||||
* @see #listStart
|
||||
* @see #list
|
||||
*/
|
||||
public void listComplete();
|
||||
|
||||
/**
|
||||
*Notification for the response to the NOOP command.
|
||||
*<P>Server responds to commands with a "still here" response.
|
||||
*Sending the noop method does nothing except force this response.
|
||||
*Can be used to maintain server connection, perhaps being issued
|
||||
*at timed intervals to make sure that the server is still active.
|
||||
*<p>Resets the autologout timer inside the server.
|
||||
*Not needed by applications that do not need to maintain the connection.
|
||||
* @see POP3Client#noop
|
||||
*/
|
||||
public void noop();
|
||||
|
||||
/**
|
||||
*Notification for the response to the PASS command.
|
||||
*Identifies the user password; on success, the POP3
|
||||
*session enters the Transaction state.
|
||||
* @param in_responseMessage Server response for pass.
|
||||
* @see POP3Client#pass
|
||||
*/
|
||||
public void pass( StringBuffer in_responseMessage );
|
||||
|
||||
/**
|
||||
*Notification for the response to the QUIT command.
|
||||
*Closes the connection with the POP3 server, purges
|
||||
*deleted messages, and logs the user out from the server.
|
||||
*<p>If issued in Authentication state, server closes
|
||||
*connection. If issued in Transaction state, server goes
|
||||
*into the Update state and deletes marked messages, then quits.
|
||||
* @param in_responseMessage Server response for quit.
|
||||
* @see POP3Client#quit
|
||||
*/
|
||||
public void quit( StringBuffer in_responseMessage );
|
||||
|
||||
/**
|
||||
*Notification for the response to the RSET command.
|
||||
*POP3 can affect server only by deleting/undeleting messages
|
||||
*with delete and reset.
|
||||
* @param in_responseMessage Server response for reset.
|
||||
* @see POP3Client#reset
|
||||
* @see #retrieve
|
||||
* @see #delete
|
||||
*/
|
||||
// ??? These are not clearly defined in the protocol.
|
||||
public void reset( StringBuffer in_responseMessage );
|
||||
|
||||
/**
|
||||
*Notification for the start of a message from the RETR command.
|
||||
*Along with retrieve and retrieveComplete, can be used to retrieve
|
||||
*the message data.
|
||||
* @param in_messageNumber Number of message to list.
|
||||
* @param in_octetCount Octet count of the message.
|
||||
* @see POP3Client#retrieve
|
||||
* @see #retrieve
|
||||
* @see #retrieveComplete
|
||||
*/
|
||||
public void retrieveStart( int in_messageNumber, int in_octetCount );
|
||||
|
||||
/**
|
||||
*Notification for raw message from the RETR command.
|
||||
*Along with retrieveStart and retrieveComplete, can be used to
|
||||
*retrieve the message data.
|
||||
* @param in_messageData Message data to retrieve.
|
||||
* @see POP3Client#retrieve
|
||||
* @see #retrieveStart
|
||||
* @see #retrieveComplete
|
||||
*/
|
||||
public void retrieve( byte[] in_messageData );
|
||||
|
||||
/**
|
||||
*Notification for the completion of the RETR command.
|
||||
*Along with retrieve and retrieveStart, can be used to
|
||||
*retrieve the data in the message.
|
||||
* @see POP3Client#retrieve
|
||||
* @see #retrieveStart
|
||||
* @see #retrieve
|
||||
*/
|
||||
public void retrieveComplete();
|
||||
|
||||
/**
|
||||
*Notification for the start of the extended method.
|
||||
*Along with sendCommand and sendCommandComplete,
|
||||
*extends the protocol to meet client application needs.
|
||||
*See "POP3 Response Codes" in Chapter 5, "Receiving Mail with POP3."
|
||||
* @see POP3Client#sendCommand
|
||||
* @see #sendCommand
|
||||
* @see #sendCommandComplete
|
||||
*/
|
||||
public void sendCommandStart();
|
||||
|
||||
/**
|
||||
*Notification for the response to the extended method.
|
||||
*Along with sendCommandStart and sendCommandComplete,
|
||||
*extends the protocol to meet client application needs.
|
||||
*Sends commands that are not supported
|
||||
*by the Messaging SDK implementation of POP3. Can get
|
||||
*extended server information, possibly multiline.
|
||||
*See "POP3 Response Codes" in Chapter 5, "Receiving Mail with POP3."
|
||||
* @param in_line Number of lines of the body to read.
|
||||
* @see POP3Client#sendCommand, #sendCommandStart, #sendCommandComplete
|
||||
*/
|
||||
public void sendCommand( StringBuffer in_line );
|
||||
|
||||
/**
|
||||
*Notification for the completion of the extended command.
|
||||
*Along with sendCommandStart and sendCommand,
|
||||
*extends the protocol to meet client application needs.
|
||||
*See "POP3 Response Codes" in Chapter 5, "Receiving Mail with POP3."
|
||||
* @see POP3Client#sendCommand
|
||||
* @see #sendCommandStart
|
||||
* @see #sendCommand
|
||||
*/
|
||||
public void sendCommandComplete();
|
||||
|
||||
/**
|
||||
*Notification for the response to the STAT command.
|
||||
*Gets the status of the mail drop: returns the number of messages
|
||||
*and octet size of the mail drop. Always returns message octet count.
|
||||
* @param in_messageCount Number of messages.
|
||||
* @param in_octetCount Octet count of the message.
|
||||
* @see POP3Client#stat
|
||||
*/
|
||||
public void stat( int in_messageCount, int in_octetCount );
|
||||
|
||||
/**
|
||||
*Notification for the start of a message from the TOP command.
|
||||
*Along with the top and topComplete methods, retrieves the
|
||||
*headers plus the specified number of lines from the message.
|
||||
* @param in_messageNumber Number of message.
|
||||
* @see POP3Client#top
|
||||
* @see #top
|
||||
* @see #topComplete
|
||||
*/
|
||||
public void topStart( int in_messageNumber );
|
||||
|
||||
/**
|
||||
*Notification for a line of the message from the TOP command.
|
||||
*Along with the top and topComplete methods, retrieves the
|
||||
*headers plus the specified number of lines from the message.
|
||||
*Issues a 'TOP [arg1] [arg2]' command.
|
||||
* @param in_line Number of lines of the body to read.
|
||||
* @see POP3Client#top
|
||||
* @see #top
|
||||
* @see #topComplete
|
||||
*/
|
||||
public void top( StringBuffer in_line );
|
||||
|
||||
/**
|
||||
*Notification for the completion of the TOP command.
|
||||
*Along with the top and topStart methods, retrieves the
|
||||
*headers plus the specified number of lines from the message.
|
||||
* @see POP3Client#top
|
||||
* @see #top
|
||||
* @see #topStart
|
||||
*/
|
||||
public void topComplete();
|
||||
|
||||
/**
|
||||
*Notification for the start of the UIDL command.
|
||||
*Along with uidList and uidListComplete, goes
|
||||
*through all the messages in the mailbox and
|
||||
*generates a list line by line. Uses the UIDL POP3 protocol command.
|
||||
* @see POP3Client#uidList
|
||||
* @see #uidList
|
||||
* @see #uidListComplete
|
||||
* @see #listStart
|
||||
*/
|
||||
public void uidListStart();
|
||||
|
||||
/**
|
||||
*Notification for the response to the UIDL command.
|
||||
*Along with uidListStart and uidListComplete, goes
|
||||
*through all the messages in the mailbox and
|
||||
*generates a list line by line.
|
||||
* @param in_messageNumber Number of message.
|
||||
* @param in_uid Unique ID of message.
|
||||
* @see POP3Client#uidList
|
||||
* @see #uidListStart
|
||||
* @see #uidListComplete
|
||||
* @see #list
|
||||
*/
|
||||
public void uidList( int in_messageNumber, StringBuffer in_uid );
|
||||
|
||||
/**
|
||||
*Notification for the completion of the UIDL command.
|
||||
*Along with uidListStart and uidListComplete, goes
|
||||
*through all the messages in the mailbox and
|
||||
*generates a list line by line.
|
||||
* @see POP3Client#uidList
|
||||
* @see #uidList
|
||||
* @see #uidListStart
|
||||
* @see #ListComplete
|
||||
*/
|
||||
public void uidListComplete();
|
||||
|
||||
/**
|
||||
*Notification for the response to the USER command.
|
||||
* @param in_responseMessage Server response for user.
|
||||
* @see POP3Client#user
|
||||
*/
|
||||
public void user( StringBuffer in_responseMessage );
|
||||
|
||||
/**
|
||||
*Notification for the start of the XAUTHLIST command.
|
||||
*Along with xAuthList and xAuthListComplete,
|
||||
*gets a list of authenticated users.
|
||||
* @see POP3Client#xAuthList
|
||||
* @see #xAuthList
|
||||
* @see #xAuthListComplete
|
||||
*/
|
||||
public void xAuthListStart();
|
||||
|
||||
/**
|
||||
*Notification for the response to the XAUTHLIST command.
|
||||
*Along with xAuthListStart and xAuthListComplete,
|
||||
*gets a list of authenticated users.
|
||||
* @param in_messageNumber Number of message.
|
||||
* @param in_octetCount Octet count of the message.
|
||||
* @param in_emailAddress Email address.
|
||||
* @see POP3Client#xAuthList
|
||||
* @see #xAuthListStart
|
||||
* @see #xAuthListComplete
|
||||
*/
|
||||
public void xAuthList( int in_messageNumber,
|
||||
int in_octetCount,
|
||||
StringBuffer in_emailAddress );
|
||||
|
||||
/**
|
||||
*Notification for the completion of the XAUTHLIST command.
|
||||
*Along with xAuthList and xAuthListComplete,
|
||||
*gets a list of authenticated users.
|
||||
* @see POP3Client#xAuthList
|
||||
* @see #xAuthList
|
||||
* @see #xAuthListStart
|
||||
*/
|
||||
public void xAuthListComplete();
|
||||
|
||||
/**
|
||||
*Notification for the response to the XSENDER command.
|
||||
*Gets the email address of the sender of the specified message.
|
||||
*Sends the XSENDER [arg] POP3 protocol command.
|
||||
* @param in_emailAddress Email address.
|
||||
* @see POP3Client#xSender
|
||||
*/
|
||||
public void xSender( StringBuffer in_emailAddress );
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
##########################################################################
|
||||
# POP3 makefile.
|
||||
# created 9/9/97 -- Prasad
|
||||
#
|
||||
############################################################################
|
||||
# environment
|
||||
#SHELL = /usr/bin/ksh
|
||||
|
||||
# commands
|
||||
JAVAC = javac
|
||||
ARCH = $(shell uname -s)
|
||||
|
||||
ifeq ($(ARCH), SunOS)
|
||||
ARCH = SOLARIS
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH), HP-UX)
|
||||
ARCH = HPUX
|
||||
endif
|
||||
|
||||
# java flags
|
||||
DEBUGJAVAFLAG =
|
||||
OPTJAVAFLAG = -d $(CLASSDIR)
|
||||
JAVAFLAGS = $(OTHERJAVAFLAGS) $(OPTJAVAFLAG) $(DEBUGJAVAFLAG)
|
||||
RM = rm -f
|
||||
|
||||
ifeq ($(ARCH), WINNT)
|
||||
RM = del /q
|
||||
endif
|
||||
|
||||
# files and directories
|
||||
CLASSDIR = ../../../built/$(ARCH)/protocol
|
||||
|
||||
#CLASSPATH = .:$(CLASSDIR):$(JDKCLASSPATH)
|
||||
|
||||
SRCS = \
|
||||
POP3Exception.java \
|
||||
POP3ServerException.java \
|
||||
IPOP3Sink.java \
|
||||
POP3Sink.java \
|
||||
POP3Client.java
|
||||
|
||||
OBJS = ${SRCS:.java=.class}
|
||||
|
||||
TARGET = package
|
||||
|
||||
.SUFFIXES: .java .class
|
||||
|
||||
all: $(CLASSDIR) $(TARGET)
|
||||
|
||||
install: $(TARGET)
|
||||
foreach f ( $(OBJS) ) \
|
||||
mv -f $$f $(CLASSDIR)/$$f \
|
||||
end
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
$(CLASSDIR):
|
||||
echo mkdir $(CLASSDIR)
|
||||
- mkdir -p $(CLASSDIR)
|
||||
|
||||
.java.class: $(SRCS)
|
||||
$(JAVAC) $(JAVAFLAGS) $<
|
||||
|
||||
clean:
|
||||
echo $(ARCH)
|
||||
ifneq ($(ARCH), WINNT)
|
||||
cd ../../../built/$(ARCH)/netscape/messaging/pop3; \
|
||||
$(RM) $(OBJS) $(TARGET)
|
||||
else
|
||||
rm -f $(CLASSDIR)/netscape/messaging/pop3/*.class
|
||||
endif
|
||||
# cd ../../../built/$(ARCH)/SASL; \
|
||||
# $(RM) $(OBJS) $(TARGET)
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Netscape Messaging Access SDK Version 3.5 code,
|
||||
* released on or about June 15, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998 Netscape
|
||||
* Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 and 1998 Netscape Communications Corporation
|
||||
* (http://home.netscape.com/misc/trademarks.html)
|
||||
*/
|
||||
|
||||
package netscape.messaging.pop3;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
*The POP3Exception class represents an internal error in the POP3
|
||||
*implementation of the Messaging Access SDK.
|
||||
*@author Derek Tumulak
|
||||
*@version 1.0
|
||||
*/
|
||||
public class POP3Exception extends IOException
|
||||
{
|
||||
/**
|
||||
*Creates a POP3Exception object.
|
||||
*Default constructor for the POP3Exception class.
|
||||
*/
|
||||
public POP3Exception()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
*Creates a POP3Exception object that includes a descriptive string.
|
||||
*@param s String that describes the exception.
|
||||
*/
|
||||
public POP3Exception(String s)
|
||||
{
|
||||
super(s);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Netscape Messaging Access SDK Version 3.5 code,
|
||||
* released on or about June 15, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998 Netscape
|
||||
* Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 and 1998 Netscape Communications Corporation
|
||||
* (http://home.netscape.com/misc/trademarks.html)
|
||||
*/
|
||||
|
||||
package netscape.messaging.pop3;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
*The POP3ServerException class represents a server response
|
||||
*error in the POP3 implementation of the Messaging Access SDK.
|
||||
*<p>The POP3ServerException class handles server response errors.
|
||||
*A POP3ServerException is thrown only from the error
|
||||
*callback on the response sink. The interface definition for
|
||||
*IPOP3Sink states that a POP3 server exception can be thrown,
|
||||
*but it is up to the developer to determine whether or not
|
||||
*the implementation of the error callback will throw this
|
||||
*exception. As a default, the POP3Sink class throws an exception whenever
|
||||
*the error callback is called.
|
||||
*<p>This exception is caused when the server sends an
|
||||
*error saying that some part of the operation failed or is not
|
||||
*supported. This can happen even when all relevant code executes
|
||||
*properly.
|
||||
*@author Derek Tumulak
|
||||
*@version 1.0
|
||||
*/
|
||||
public class POP3ServerException extends POP3Exception
|
||||
{
|
||||
|
||||
/**
|
||||
*Creates a POP3ServerException object.
|
||||
*Default constructor for a POP3ServerException object.
|
||||
*/
|
||||
public POP3ServerException()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
*Creates a POP3ServerException object that includes a descriptive string.
|
||||
*@param s String that describes the exception.
|
||||
*/
|
||||
public POP3ServerException(String s)
|
||||
{
|
||||
super(s);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,359 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Netscape Messaging Access SDK Version 3.5 code,
|
||||
* released on or about June 15, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998 Netscape
|
||||
* Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 and 1998 Netscape Communications Corporation
|
||||
* (http://home.netscape.com/misc/trademarks.html)
|
||||
*/
|
||||
|
||||
package netscape.messaging.pop3;
|
||||
|
||||
/**
|
||||
*POP3Sink is the default implementation of the response sink for all
|
||||
*POP3 commands.
|
||||
*<p>The POP3Sink object contains callback methods for each client call.
|
||||
*The client’s processResponses call invokes the appropriate
|
||||
*object method.
|
||||
*<p>The Messaging Access SDK provides the POP3Sink class as a convenience
|
||||
*implementation the POP3Sink interface.
|
||||
*You can save a step by extending the POP3Sink class, or
|
||||
*you can implement your own class based on the POP3Sink
|
||||
*interface. The constructor for the POP3Sink class takes an
|
||||
*POP3Sink interface as a parameter.
|
||||
*<p>By default,
|
||||
*this implementation does nothing, except for the error callback, which
|
||||
*throws an exception.
|
||||
*@author derekt@netscape.com
|
||||
*@version 1.0
|
||||
*/
|
||||
|
||||
public class POP3Sink implements IPOP3Sink
|
||||
{
|
||||
/**
|
||||
*Notification for the response to the connection to the server.
|
||||
*<P>Connects to the server using the default port.
|
||||
*See "POP3 Response Codes" in Chapter 5, "Receiving Mail with POP3."
|
||||
* @param in_responseMessage Server response for connect.
|
||||
* @see POP3Client#connect
|
||||
* @see #quit
|
||||
*/
|
||||
public void connect( StringBuffer in_responseMessage ) {}
|
||||
|
||||
/**
|
||||
*Notification for the response to the DELE command.
|
||||
*Marks a message for deletion on the server;
|
||||
*actually deleted when quit() is called.
|
||||
*Sends the DELE [arg] POP3 protocol command.
|
||||
* @param in_responseMessage Server response for delete.
|
||||
* @see POP3Client#delete
|
||||
* @see #quit
|
||||
*/
|
||||
public void delete( StringBuffer in_responseMessage ) {}
|
||||
|
||||
/**
|
||||
*Error notification.
|
||||
*Called when an error occurs.
|
||||
*See "POP3 Response Codes" in Chapter 5, "Receiving Mail with POP3."
|
||||
* @param in_responseMessage Server response for an error.
|
||||
* @exception POP3ServerException If a server response error occurs.
|
||||
* @see POP3Client#processResponses
|
||||
*/
|
||||
public void error( StringBuffer in_responseMessage ) throws POP3ServerException
|
||||
{
|
||||
throw new POP3ServerException();
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the start of the LIST command.
|
||||
*Along with list and listComplete, can be used to list
|
||||
*all messages.
|
||||
* @see POP3Client#list
|
||||
* @see #listComplete
|
||||
* @see #list
|
||||
*/
|
||||
public void listStart() {}
|
||||
|
||||
/**
|
||||
*Notification for the response to the LIST command.
|
||||
*Along with listStart and listStartComplete, can be used to
|
||||
*list all messages.
|
||||
* @param in_messageNumber Number of message to list.
|
||||
* @param in_octetCount Octet count of the message.
|
||||
* @see POP3Client#list
|
||||
* @see #listStart
|
||||
* @see #listComplete
|
||||
*/
|
||||
public void list( int in_messageNumber, int in_octetCount ) {}
|
||||
|
||||
/**
|
||||
*Notification for the completion of the LIST command.
|
||||
*Along with list and listStartComplete, can be used to list
|
||||
*all messages.
|
||||
* @see POP3Client#list
|
||||
* @see #listStart
|
||||
* @see #list
|
||||
*/
|
||||
public void listComplete() {}
|
||||
|
||||
/**
|
||||
*Notification for the response to the NOOP command.
|
||||
*<P>Server responds to commands with a "still here" response.
|
||||
*Sending the noop method does nothing except force this response.
|
||||
*Can be used to maintain server connection, perhaps being issued
|
||||
*at timed intervals to make sure that the server is still active.
|
||||
*<p>Resets the autologout timer inside the server.
|
||||
*Not needed by applications that do not need to maintain the connection.
|
||||
* @see POP3Client#noop
|
||||
*/
|
||||
public void noop() {}
|
||||
|
||||
/**
|
||||
*Notification for the response to the PASS command.
|
||||
*Identifies the user password; on success, the POP3
|
||||
*session enters the Transaction state.
|
||||
* @param in_responseMessage Server response for pass.
|
||||
* @see POP3Client#pass
|
||||
*/
|
||||
public void pass( StringBuffer in_responseMessage ) {}
|
||||
|
||||
/**
|
||||
*Notification for the response to the QUIT command.
|
||||
*Closes the connection with the POP3 server, purges
|
||||
*deleted messages, and logs the user out from the server.
|
||||
*<p>If issued in Authentication state, server closes
|
||||
*connection. If issued in Transaction state, server goes
|
||||
*into the Update state and deletes marked messages, then quits.
|
||||
* @param in_responseMessage Server response for quit.
|
||||
* @see POP3Client#quit
|
||||
*/
|
||||
public void quit( StringBuffer in_responseMessage ) {}
|
||||
|
||||
/**
|
||||
*Notification for the response to the RSET command.
|
||||
*POP3 can affect server only by deleting/undeleting messages
|
||||
*with delete and reset.
|
||||
* @param in_responseMessage Server response for reset.
|
||||
* @see POP3Client#reset
|
||||
* @see #retrieve
|
||||
* @see #delete
|
||||
*/
|
||||
// ??? These are not clearly defined in the protocol.
|
||||
public void reset( StringBuffer in_responseMessage ) {}
|
||||
|
||||
/**
|
||||
*Notification for the start of a message from the RETR command.
|
||||
*Along with retrieve and retrieveComplete, can be used to retrieve
|
||||
*the message data.
|
||||
* @param in_messageNumber Number of message to list.
|
||||
* @param in_octetCount Octet count of the message.
|
||||
* @see POP3Client#retrieve
|
||||
* @see #retrieve
|
||||
* @see #retrieveComplete
|
||||
*/
|
||||
public void retrieveStart( int in_messageNumber, int in_octetCount ) {}
|
||||
|
||||
/**
|
||||
*Notification for raw message from the RETR command.
|
||||
*Along with retrieveStart and retrieveComplete, can be used to
|
||||
*retrieve the message data.
|
||||
* @param in_messageData Message data to retrieve.
|
||||
* @see POP3Client#retrieve
|
||||
* @see #retrieveStart
|
||||
* @see #retrieveComplete
|
||||
*/
|
||||
public void retrieve( byte[] in_messageData ) {}
|
||||
|
||||
/**
|
||||
*Notification for the completion of the RETR command.
|
||||
*Along with retrieve and retrieveStart, can be used to
|
||||
*retrieve the data in the message.
|
||||
* @see POP3Client#retrieve
|
||||
* @see #retrieveStart
|
||||
* @see #retrieve
|
||||
*/
|
||||
public void retrieveComplete() {}
|
||||
|
||||
/**
|
||||
*Notification for the start of the extended method.
|
||||
*Along with sendCommand and sendCommandComplete,
|
||||
*extends the protocol to meet client application needs.
|
||||
*See "POP3 Response Codes" in Chapter 5, "Receiving Mail with POP3."
|
||||
* @see POP3Client#sendCommand
|
||||
* @see #sendCommand
|
||||
* @see #sendCommandComplete
|
||||
*/
|
||||
public void sendCommandStart() {}
|
||||
|
||||
/**
|
||||
*Notification for the response to the extended method.
|
||||
*Along with sendCommandStart and sendCommandComplete,
|
||||
*extends the protocol to meet client application needs.
|
||||
*Sends commands that are not supported
|
||||
*by the Messaging SDK implementation of POP3. Can get
|
||||
*extended server information, possibly multiline.
|
||||
*See "POP3 Response Codes" in Chapter 5, "Receiving Mail with POP3."
|
||||
* @param in_line Number of lines of the body to read.
|
||||
* @see POP3Client#sendCommand, #sendCommandStart, #sendCommandComplete
|
||||
*/
|
||||
public void sendCommand( StringBuffer in_line ) {}
|
||||
|
||||
/**
|
||||
*Notification for the completion of the extended command.
|
||||
*Along with sendCommandStart and sendCommand,
|
||||
*extends the protocol to meet client application needs.
|
||||
*See "POP3 Response Codes" in Chapter 5, "Receiving Mail with POP3."
|
||||
* @see POP3Client#sendCommand
|
||||
* @see #sendCommandStart
|
||||
* @see #sendCommand
|
||||
*/
|
||||
public void sendCommandComplete() {}
|
||||
|
||||
/**
|
||||
*Notification for the response to the STAT command.
|
||||
*Gets the status of the mail drop: returns the number of messages
|
||||
*and octet size of the mail drop. Always returns message octet count.
|
||||
* @param in_messageCount Number of messages.
|
||||
* @param in_octetCount Octet count of the message.
|
||||
* @see POP3Client#stat
|
||||
*/
|
||||
public void stat( int in_messageCount, int in_octetCount ) {}
|
||||
|
||||
/**
|
||||
*Notification for the start of a message from the TOP command.
|
||||
*Along with the top and topComplete methods, retrieves the
|
||||
*headers plus the specified number of lines from the message.
|
||||
* @param in_messageNumber Number of message.
|
||||
* @see POP3Client#top
|
||||
* @see #top
|
||||
* @see #topComplete
|
||||
*/
|
||||
public void topStart( int in_messageNumber ) {}
|
||||
|
||||
/**
|
||||
*Notification for a line of the message from the TOP command.
|
||||
*Along with the top and topComplete methods, retrieves the
|
||||
*headers plus the specified number of lines from the message.
|
||||
*Issues a 'TOP [arg1] [arg2]' command.
|
||||
* @param in_line Number of lines of the body to read.
|
||||
* @see POP3Client#top
|
||||
* @see #topStart
|
||||
* @see #topComplete
|
||||
*/
|
||||
public void top( StringBuffer in_line ) {}
|
||||
|
||||
/**
|
||||
*Notification for the completion of the TOP command.
|
||||
*Along with the top and topStart methods, retrieves the
|
||||
*headers plus the specified number of lines from the message.
|
||||
* @see POP3Client#top
|
||||
* @see #top
|
||||
* @see #topStart
|
||||
*/
|
||||
public void topComplete() {}
|
||||
|
||||
/**
|
||||
*Notification for the start of the UIDL command.
|
||||
*Along with uidList and uidListComplete, goes
|
||||
*through all the messages in the mailbox and
|
||||
*generates a list line by line. Uses the UIDL POP3 protocol command,
|
||||
* @see POP3Client#uidList
|
||||
* @see #uidList
|
||||
* @see #uidListComplete
|
||||
* @see #listStart
|
||||
*/
|
||||
public void uidListStart() {}
|
||||
|
||||
/**
|
||||
*Notification for the response to the UIDL command.
|
||||
*Along with uidListStart and uidListComplete, goes
|
||||
*through all the messages in the mailbox and
|
||||
*generates a list line by line.
|
||||
* @param in_messageNumber Number of message.
|
||||
* @param in_uid Unique ID of message.
|
||||
* @see POP3Client#uidList
|
||||
* @see #uidListStart
|
||||
* @see #uidListComplete
|
||||
* @see #list
|
||||
*/
|
||||
public void uidList( int in_messageNumber, StringBuffer in_uid ) {}
|
||||
|
||||
/**
|
||||
*Notification for the completion of the UIDL command.
|
||||
*Along with uidListStart and uidListComplete, goes
|
||||
*through all the messages in the mailbox and
|
||||
*generates a list line by line.
|
||||
* @see POP3Client#uidList
|
||||
* @see #uidList
|
||||
* @see #uidListStart
|
||||
* @see #ListComplete
|
||||
*/
|
||||
public void uidListComplete() {}
|
||||
|
||||
/**
|
||||
*Notification for the response to the USER command.
|
||||
* @param in_responseMessage Server response for user.
|
||||
* @see POP3Client#user
|
||||
*/
|
||||
public void user( StringBuffer in_responseMessage ) {}
|
||||
|
||||
/**
|
||||
*Notification for the start of the XAUTHLIST command.
|
||||
*Along with xAuthList and xAuthListComplete, sends the
|
||||
*XAUTHLIST POP3 protocol command.
|
||||
* @see POP3Client#xAuthList
|
||||
* @see #xAuthList
|
||||
* @see #xAuthListComplete
|
||||
*/
|
||||
public void xAuthListStart() {}
|
||||
|
||||
/**
|
||||
*Notification for the response to the XAUTHLIST command.
|
||||
*Along with xAuthListStart and xAuthListComplete, sends the
|
||||
*XAUTHLIST POP3 protocol command.
|
||||
* @param in_messageNumber Number of message.
|
||||
* @param in_octetCount Octet count of the message.
|
||||
* @param in_emailAddress Email address.
|
||||
* @see POP3Client#xAuthList
|
||||
* @see #xAuthListStart
|
||||
* @see #xAuthListComplete
|
||||
*/
|
||||
public void xAuthList( int in_messageNumber,
|
||||
int in_octetCount,
|
||||
StringBuffer in_emailAddress ) {}
|
||||
|
||||
/**
|
||||
*Notification for the completion of the XAUTHLIST command.
|
||||
*Along with xAuthList and xAuthListComplete, sends the
|
||||
*XAUTHLIST POP3 protocol command.
|
||||
* @see POP3Client#xAuthList
|
||||
* @see #xAuthList
|
||||
* @see #xAuthListStart
|
||||
*/
|
||||
public void xAuthListComplete() {}
|
||||
|
||||
/**
|
||||
*Notification for the response to the XSENDER command.
|
||||
*Gets the email address of the sender of the specified message.
|
||||
*Sends the XSENDER [arg] POP3 protocol command.
|
||||
* @param in_emailAddress Email address.
|
||||
* @see POP3Client#xSender
|
||||
*/
|
||||
public void xSender( StringBuffer in_emailAddress ) {}
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Netscape Messaging Access SDK Version 3.5 code,
|
||||
* released on or about June 15, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998 Netscape
|
||||
* Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 and 1998 Netscape Communications Corporation
|
||||
* (http://home.netscape.com/misc/trademarks.html)
|
||||
*/
|
||||
|
||||
import netscape.messaging.pop3.*;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
*@author derekt@netscape.com
|
||||
*@version 1.0
|
||||
*/
|
||||
|
||||
// Usage: At the command line type "java POP3Test serverName user password messageNumber"
|
||||
|
||||
class POP3Test
|
||||
{
|
||||
public static void main( String args[] )
|
||||
{
|
||||
POP3Client m_client;
|
||||
POP3TestSink m_pop3Sink;
|
||||
|
||||
try
|
||||
{
|
||||
// Create the response sink.
|
||||
m_pop3Sink = new POP3TestSink();
|
||||
|
||||
// Create the client.
|
||||
m_client = new POP3Client( m_pop3Sink );
|
||||
|
||||
// Set the timeout to 10 seconds.
|
||||
m_client.setTimeout( 10000 );
|
||||
|
||||
// Connect to the specified server.
|
||||
m_client.connect( args[0] );
|
||||
m_client.processResponses();
|
||||
|
||||
// Send the USER command.
|
||||
m_client.user( args[1] );
|
||||
m_client.processResponses();
|
||||
|
||||
// Send the PASS command.
|
||||
m_client.pass( args[2] );
|
||||
m_client.processResponses();
|
||||
|
||||
// Send the LIST command.
|
||||
m_client.list();
|
||||
m_client.processResponses();
|
||||
|
||||
// Send the LIST command with an argument.
|
||||
m_client.list( 1 );
|
||||
m_client.processResponses();
|
||||
|
||||
// Send the RETR command.
|
||||
m_client.retrieve( (new Integer(args[3])).intValue() );
|
||||
m_client.processResponses();
|
||||
|
||||
// Send the NOOP command.
|
||||
m_client.noop();
|
||||
m_client.processResponses();
|
||||
|
||||
// Send the DELE command.
|
||||
m_client.delete( 1 );
|
||||
m_client.processResponses();
|
||||
|
||||
// Send the RSET command.
|
||||
m_client.reset();
|
||||
m_client.processResponses();
|
||||
|
||||
// Send a generic command.
|
||||
m_client.sendCommand( "RSET", false );
|
||||
m_client.processResponses();
|
||||
|
||||
// Send the STAT command.
|
||||
m_client.stat();
|
||||
m_client.processResponses();
|
||||
|
||||
// Send the TOP command.
|
||||
m_client.top( 1, 10 );
|
||||
m_client.processResponses();
|
||||
|
||||
// Send the UIDL command.
|
||||
m_client.uidList();
|
||||
m_client.processResponses();
|
||||
|
||||
// Send the UIDL command with an argument.
|
||||
m_client.uidList( 1 );
|
||||
m_client.processResponses();
|
||||
|
||||
// Send the XAUTHLIST command.
|
||||
m_client.xAuthList();
|
||||
m_client.processResponses();
|
||||
|
||||
// Send the XAUTHLIST command with an argument.
|
||||
m_client.xAuthList( 1 );
|
||||
m_client.processResponses();
|
||||
|
||||
// Send the XSENDER command.
|
||||
m_client.xSender( 1 );
|
||||
m_client.processResponses();
|
||||
|
||||
// Send the QUIT command.
|
||||
m_client.quit();
|
||||
m_client.processResponses();
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
// Print out the exception.
|
||||
System.out.println( "Exception caught in main:" + e );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,298 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Netscape Messaging Access SDK Version 3.5 code,
|
||||
* released on or about June 15, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998 Netscape
|
||||
* Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
import netscape.messaging.pop3.*;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
*Notification sink for SMTP commands.
|
||||
*@author derekt@netscape.com
|
||||
*@version 1.0
|
||||
*/
|
||||
|
||||
public class POP3TestSink implements IPOP3Sink
|
||||
{
|
||||
boolean m_fStatus;
|
||||
int m_octetCount;
|
||||
int m_messageCount;
|
||||
FileOutputStream m_outStream;
|
||||
|
||||
POP3TestSink()
|
||||
{
|
||||
m_fStatus = true;
|
||||
m_octetCount = 0;
|
||||
m_messageCount = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the response to the connection to the server.
|
||||
*/
|
||||
public void connect( StringBuffer in_responseMessage )
|
||||
{
|
||||
System.out.println( in_responseMessage.toString() );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the response to the DELE command.
|
||||
*/
|
||||
public void delete( StringBuffer in_responseMessage )
|
||||
{
|
||||
System.out.println( in_responseMessage.toString() );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for an error response.
|
||||
*/
|
||||
public void error( StringBuffer in_responseMessage ) throws POP3ServerException
|
||||
{
|
||||
throw new POP3ServerException();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*Notification for the start of the LIST command.
|
||||
*/
|
||||
public void listStart()
|
||||
{
|
||||
System.out.println( "LIST Start" );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the response to the LIST command.
|
||||
*/
|
||||
public void list( int in_messageNumber, int in_octetCount )
|
||||
{
|
||||
System.out.println( (new Integer(in_messageNumber)) + " " +
|
||||
(new Integer(in_octetCount)) );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the completion of the LIST command.
|
||||
*/
|
||||
public void listComplete()
|
||||
{
|
||||
System.out.println( "LIST Complete" );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the response to the NOOP command.
|
||||
*/
|
||||
public void noop()
|
||||
{
|
||||
System.out.println( "NOOP" );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the response to the PASS command.
|
||||
*/
|
||||
public void pass( StringBuffer in_responseMessage )
|
||||
{
|
||||
System.out.println( in_responseMessage.toString() );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the response to the QUIT command.
|
||||
*/
|
||||
public void quit( StringBuffer in_responseMessage )
|
||||
{
|
||||
System.out.println( in_responseMessage.toString() );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the response to the RSET command.
|
||||
*/
|
||||
public void reset( StringBuffer in_responseMessage )
|
||||
{
|
||||
System.out.println( in_responseMessage.toString() );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the start of a message from the RETR command.
|
||||
*/
|
||||
public void retrieveStart( int in_messageNumber, int in_octetCount )
|
||||
{
|
||||
try
|
||||
{
|
||||
m_outStream = new FileOutputStream( "retrieve.txt" );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
}
|
||||
System.out.println( new Integer(in_messageNumber) + " " + new Integer(in_octetCount) );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for raw message from the RETR command.
|
||||
*/
|
||||
public void retrieve( byte[] in_messageData )
|
||||
{
|
||||
try
|
||||
{
|
||||
m_outStream.write( in_messageData );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
}
|
||||
System.out.println( new String( in_messageData ) );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the completion of the RETR command.
|
||||
*/
|
||||
public void retrieveComplete()
|
||||
{
|
||||
try
|
||||
{
|
||||
m_outStream.close();
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
}
|
||||
System.out.println( "RETR Complete" );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the start of the extended command.
|
||||
*/
|
||||
public void sendCommandStart()
|
||||
{
|
||||
System.out.println( "SENDCOMMAND Start" );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the response to sendCommand() method.
|
||||
*/
|
||||
public void sendCommand( StringBuffer in_line )
|
||||
{
|
||||
System.out.println( in_line.toString() );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the completion of the extended command.
|
||||
*/
|
||||
public void sendCommandComplete()
|
||||
{
|
||||
System.out.println( "SENDCOMMAND Complete" );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the response to the STAT command.
|
||||
*/
|
||||
public void stat( int in_messageCount, int in_octetCount )
|
||||
{
|
||||
m_octetCount = in_octetCount;
|
||||
m_messageCount = in_messageCount;
|
||||
|
||||
System.out.println( new Integer(m_messageCount) + " " + new Integer(m_octetCount) );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the start of a message from the TOP command.
|
||||
*/
|
||||
public void topStart( int in_messageNumber )
|
||||
{
|
||||
System.out.println( "TOP Start " + new Integer(in_messageNumber) );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for a line of the message from the TOP command.
|
||||
*/
|
||||
public void top( StringBuffer in_line )
|
||||
{
|
||||
System.out.println( in_line.toString() );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the completion of the TOP command.
|
||||
*/
|
||||
public void topComplete()
|
||||
{
|
||||
System.out.println( "TOP Complete" );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the start of the UIDL command.
|
||||
*/
|
||||
public void uidListStart()
|
||||
{
|
||||
System.out.println( "UIDL Start" );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the response to the UIDL command.
|
||||
*/
|
||||
public void uidList( int in_messageNumber, StringBuffer in_uid )
|
||||
{
|
||||
System.out.println( (new Integer(in_messageNumber)) + " " +
|
||||
in_uid.toString() );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the completion of the UIDL command.
|
||||
*/
|
||||
public void uidListComplete()
|
||||
{
|
||||
System.out.println( "UIDL Complete" );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the response to the USER command.
|
||||
*/
|
||||
public void user( StringBuffer in_responseMessage )
|
||||
{
|
||||
System.out.println( in_responseMessage.toString() );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the start of the XAUTHLIST command.
|
||||
*/
|
||||
public void xAuthListStart()
|
||||
{
|
||||
System.out.println( "XAUTHLIST Start" );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the response to the XAUTHLIST command.
|
||||
*/
|
||||
public void xAuthList( int in_messageNumber,
|
||||
int in_octetCount,
|
||||
StringBuffer in_emailAddress )
|
||||
{
|
||||
System.out.println( (new Integer(in_messageNumber)) + " " +
|
||||
(new Integer(in_octetCount)) + " " +
|
||||
in_emailAddress.toString() );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the completion of the XAUTHLIST command.
|
||||
*/
|
||||
public void xAuthListComplete()
|
||||
{
|
||||
System.out.println( "XAUTHLIST Complete" );
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the response to the XSENDER command.
|
||||
*/
|
||||
public void xSender( StringBuffer in_emailAddress )
|
||||
{
|
||||
System.out.println( in_emailAddress.toString() );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,164 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Netscape Messaging Access SDK Version 3.5 code,
|
||||
* released on or about June 15, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998 Netscape
|
||||
* Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 and 1998 Netscape Communications Corporation
|
||||
* (http://home.netscape.com/misc/trademarks.html)
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
|
||||
/* Support class for the Demo Message Send Application using Netscape Messaging SDK.
|
||||
* prasad@netscape.com
|
||||
*/
|
||||
|
||||
public class Config extends Frame
|
||||
{
|
||||
|
||||
SendMsgClnt clnt = null;
|
||||
|
||||
//Choice updateChoice = new Choice();
|
||||
Button okButton = new Button ("OK");
|
||||
Button cancelButton = new Button ("Cancel");
|
||||
|
||||
TextField senderTextField = new TextField(30);
|
||||
TextField hostTextField = new TextField(30);
|
||||
TextField portTextField = new TextField(12);
|
||||
TextField tmpTextField = new TextField(12);
|
||||
|
||||
Checkbox pipeline = new Checkbox("Pipeline", false);
|
||||
Checkbox dsn = new Checkbox("DSN", false);
|
||||
Checkbox tracelog = new Checkbox("Tracing", false);
|
||||
|
||||
public Config (SendMsgClnt clnt)
|
||||
{
|
||||
setTitle("SMTP Options");
|
||||
this.clnt = clnt;
|
||||
init();
|
||||
}
|
||||
|
||||
public void display()
|
||||
{
|
||||
hostTextField.setText (clnt.host);
|
||||
portTextField.setText (String.valueOf(clnt.port));
|
||||
tmpTextField.setText (String.valueOf(clnt.tmpdir));
|
||||
senderTextField.setText (clnt.sender);
|
||||
pipeline.setState (clnt.b_pipeline);
|
||||
dsn.setState (clnt.b_dsn);
|
||||
tracelog.setState (clnt.b_tracelog);
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
Panel sender = new Panel();
|
||||
sender.add("West", new Label("Msg Sender: "));
|
||||
sender.add("East", senderTextField);
|
||||
|
||||
Panel host = new Panel();
|
||||
host.add("West", new Label("SMTP Host:"));
|
||||
host.add("East", hostTextField);
|
||||
|
||||
Panel north = new Panel();
|
||||
north.setLayout(new BorderLayout(0,0));
|
||||
north.add("North", sender);
|
||||
north.add("South", host);
|
||||
//north.add("North", sender);
|
||||
//north.add("West", host);
|
||||
|
||||
Panel port = new Panel();
|
||||
port.add("West", new Label("SMTP Port:"));
|
||||
port.add("East", portTextField);
|
||||
|
||||
Panel tmp = new Panel();
|
||||
tmp.add("West", new Label("TEMP Dir:"));
|
||||
tmp.add("East", tmpTextField);
|
||||
|
||||
Panel west = new Panel();
|
||||
west.setLayout(new BorderLayout(0,0));
|
||||
|
||||
west.add("North", port);
|
||||
west.add("West", tmp);
|
||||
|
||||
Panel ckBox = new Panel();
|
||||
Panel ckBoxwest = new Panel();
|
||||
ckBoxwest.setLayout(new BorderLayout(0,0));
|
||||
Panel ckBoxeast = new Panel();
|
||||
ckBoxeast.setLayout(new BorderLayout(0,0));
|
||||
|
||||
ckBox.add(new Label("Options:"));
|
||||
ckBoxeast.add("North", pipeline);
|
||||
ckBoxeast.add("Center", dsn);
|
||||
ckBoxeast.add("South", tracelog);
|
||||
|
||||
ckBox.add("West", ckBoxeast);
|
||||
ckBox.add("East", ckBoxwest);
|
||||
|
||||
Panel east = new Panel();
|
||||
east.setLayout(new BorderLayout(0,0));
|
||||
|
||||
east.add("South", ckBox);
|
||||
|
||||
Panel south = new Panel(); // new south panel
|
||||
south.add(okButton);
|
||||
south.add(cancelButton);
|
||||
|
||||
add("North", north);
|
||||
add("West", west);
|
||||
add("East", east);
|
||||
add("South", south);
|
||||
pack();
|
||||
|
||||
okButton.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
clnt.host = hostTextField.getText();
|
||||
clnt.sender = senderTextField.getText();
|
||||
clnt.tmpdir = tmpTextField.getText();
|
||||
try
|
||||
{
|
||||
clnt.port = Integer.parseInt(portTextField.getText());
|
||||
}
|
||||
catch (NumberFormatException ee) {}
|
||||
|
||||
clnt.b_pipeline = pipeline.getState();
|
||||
clnt.b_dsn = dsn.getState();
|
||||
clnt.b_tracelog = tracelog.getState();
|
||||
clnt.setEnabled(true);
|
||||
|
||||
clnt.b_configured = true;
|
||||
|
||||
setVisible(false);
|
||||
}
|
||||
});
|
||||
|
||||
cancelButton.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
clnt.setEnabled(true);
|
||||
setVisible(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Netscape Messaging Access SDK Version 3.5 code,
|
||||
* released on or about June 15, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998 Netscape
|
||||
* Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 and 1998 Netscape Communications Corporation
|
||||
* (http://home.netscape.com/misc/trademarks.html)
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.lang.*;
|
||||
|
||||
/* Support class for the Demo Message Send Application using Netscape Messaging SDK.
|
||||
* prasad@netscape.com
|
||||
*/
|
||||
public class OKDialog extends Dialog
|
||||
{
|
||||
public OKDialog(Frame parent, String title, String message)
|
||||
{
|
||||
super(parent, title, true);
|
||||
|
||||
Panel north = new Panel();
|
||||
setLayout(new BorderLayout(0,0));
|
||||
north.add("Center", new Label(message));
|
||||
|
||||
Panel south = new Panel();
|
||||
setLayout(new BorderLayout(0,0));
|
||||
Button okButton = new Button("OK");
|
||||
south.add(okButton);
|
||||
|
||||
add("North", north);
|
||||
add("South", south);
|
||||
|
||||
pack();
|
||||
|
||||
okButton.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
setVisible(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void display()
|
||||
{
|
||||
for (int i = 1; i <= 2; i++)
|
||||
Toolkit.getDefaultToolkit().beep();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
This directory contains files that implement an example Send Message Program using
|
||||
Netscape Messaging SDK. This is a fairly complex example showing the use of SMTP
|
||||
and MIME java APIs.
|
||||
|
||||
To compile and run:
|
||||
-------------------
|
||||
|
||||
(1) Make sure CLASSPATH includes the msg-sdk jar file (proapi.jar).
|
||||
When installed proapi.jar is located at <install-root>/packages/proapi.jar.
|
||||
|
||||
Make sure CLASSPATH includes the directory you are compiling in also.
|
||||
|
||||
(2) Compile: javac *.java
|
||||
|
||||
(3) Run: java SendMsgClnt (No parameters needed).
|
||||
|
||||
This brings up a GUI screen that lets one compose and send a message,
|
||||
optionally attaching a file.
|
|
@ -0,0 +1,218 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Netscape Messaging Access SDK Version 3.5 code,
|
||||
* released on or about June 15, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998 Netscape
|
||||
* Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 and 1998 Netscape Communications Corporation
|
||||
* (http://home.netscape.com/misc/trademarks.html)
|
||||
*/
|
||||
|
||||
import netscape.messaging.smtp.*;
|
||||
|
||||
/* Support class for the Demo Message Send Application using Netscape Messaging SDK.
|
||||
* Implemnts SMTPTestSink.
|
||||
* prasad@netscape.com
|
||||
*/
|
||||
|
||||
public class SMTPTestSink extends SMTPSink
|
||||
{
|
||||
public boolean m_cmdStatus;
|
||||
public boolean m_cmdStatusPending;
|
||||
public boolean m_ehloStatus;
|
||||
public boolean m_expnStatus;
|
||||
public boolean m_debug;
|
||||
public String m_thrCmd;
|
||||
public int m_failCode;
|
||||
private static int FAILCODE = 400;
|
||||
|
||||
public SMTPTestSink ()
|
||||
{
|
||||
m_cmdStatus = false;
|
||||
m_cmdStatusPending = true;
|
||||
m_ehloStatus = false;
|
||||
}
|
||||
|
||||
public boolean tryProcessResponses(SMTPClient p_client)
|
||||
{
|
||||
m_cmdStatus = false;
|
||||
m_cmdStatusPending = false;
|
||||
m_failCode = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
p_client.processResponses();
|
||||
|
||||
if (m_cmdStatusPending != true)
|
||||
return m_cmdStatus;
|
||||
}
|
||||
/*
|
||||
catch (InterruptedIOException e)
|
||||
{
|
||||
if (m_debug)
|
||||
System.out.println ("*** processResponses()> InterruptedIOException"
|
||||
+ e.getMessage());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
if (m_debug)
|
||||
System.out.println ("*** processResponses()> IOException"
|
||||
+ e.getMessage());
|
||||
m_cmdStatus = false;
|
||||
return m_cmdStatus;
|
||||
}
|
||||
*/
|
||||
catch (Exception e)
|
||||
{
|
||||
if (m_debug)
|
||||
System.out.println ("*** processResponses()> Exception"
|
||||
+ e.getMessage());
|
||||
m_cmdStatus = false;
|
||||
return m_cmdStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification for error()
|
||||
*/
|
||||
public void error (int respCode, StringBuffer respMsg) throws SMTPServerException
|
||||
{
|
||||
m_cmdStatus = respCode < FAILCODE ? true : false;
|
||||
m_cmdStatusPending = false;
|
||||
m_failCode = respCode;
|
||||
|
||||
if (m_cmdStatus != false)
|
||||
throw new SMTPServerException ("respCode = " + respCode +
|
||||
" server response = " + respCode);
|
||||
} // end error
|
||||
|
||||
|
||||
/**
|
||||
* Notification for connect() response
|
||||
*/
|
||||
public void connect (int respCode, StringBuffer respMsg)
|
||||
{
|
||||
m_cmdStatus = respCode < FAILCODE ? true : false;
|
||||
m_cmdStatusPending = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notification for the response to the DATA command.
|
||||
*/
|
||||
public void data (int respCode, StringBuffer respMsg)
|
||||
{
|
||||
m_cmdStatus = respCode < FAILCODE ? true : false;
|
||||
m_cmdStatusPending = false;
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the response to the EHLO command.
|
||||
*/
|
||||
public void ehlo (int respCode, StringBuffer respMsg)
|
||||
{
|
||||
m_ehloStatus = respCode < FAILCODE ? true : false;
|
||||
m_cmdStatusPending = true;
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the completion of the EHLO command.
|
||||
*/
|
||||
public void ehloComplete()
|
||||
{
|
||||
|
||||
m_cmdStatusPending = false;
|
||||
m_cmdStatus = m_ehloStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the response to the EXPN command.
|
||||
*/
|
||||
public void expand (int respCode, StringBuffer respMsg)
|
||||
{
|
||||
m_expnStatus = respCode < FAILCODE ? true : false;
|
||||
m_cmdStatusPending = true;
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the completion of the EXPN command.
|
||||
*/
|
||||
public void expandComplete ()
|
||||
{
|
||||
m_cmdStatusPending = false;
|
||||
m_cmdStatus = m_expnStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the response to the MAIL FROM command.
|
||||
*/
|
||||
public void mailFrom (int respCode, StringBuffer respMsg)
|
||||
{
|
||||
m_cmdStatus = respCode < FAILCODE ? true : false;
|
||||
m_cmdStatusPending = false;
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the response to the NOOP command.
|
||||
*/
|
||||
public void noop (int respCode, StringBuffer respMsg)
|
||||
{
|
||||
m_cmdStatus = respCode < FAILCODE ? true : false;
|
||||
m_cmdStatusPending = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification for the QUIT response
|
||||
*/
|
||||
public void quit (int respCode, StringBuffer respMsg)
|
||||
{
|
||||
m_cmdStatus = respCode < FAILCODE ? true : false;
|
||||
m_cmdStatusPending = false;
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the response to the RCPT TO command.
|
||||
*/
|
||||
public void rcptTo (int respCode, StringBuffer respMsg)
|
||||
{
|
||||
m_cmdStatus = respCode < FAILCODE ? true : false;
|
||||
m_cmdStatusPending = false;
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the response to the RSET command.
|
||||
*/
|
||||
public void reset (int respCode, StringBuffer respMsg)
|
||||
{
|
||||
m_cmdStatus = respCode < FAILCODE ? true : false;
|
||||
m_cmdStatusPending = false;
|
||||
}
|
||||
|
||||
/**
|
||||
*Notification for the response to data sent to the server.
|
||||
*/
|
||||
public void send (int respCode, StringBuffer respMsg)
|
||||
{
|
||||
m_cmdStatus = respCode < FAILCODE ? true : false;
|
||||
m_cmdStatusPending = false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,716 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Netscape Messaging Access SDK Version 3.5 code,
|
||||
* released on or about June 15, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998 Netscape
|
||||
* Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 and 1998 Netscape Communications Corporation
|
||||
* (http://home.netscape.com/misc/trademarks.html)
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
|
||||
import netscape.messaging.smtp.*;
|
||||
import netscape.messaging.mime.*;
|
||||
|
||||
|
||||
/* Demo Message Send Application using Netscape Messaging SDK.
|
||||
* Demonstrates use of MIME and SMTP java APIs.
|
||||
* Author: Prasad Yendluri <prasad@netscape.com>, Feb 1998.
|
||||
*/
|
||||
|
||||
public class SendMsgClnt extends Frame
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Private data members.
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private Button sendOrNewButton;
|
||||
private Button fileButton;
|
||||
private Button cancelButton;
|
||||
private Button configButton;
|
||||
private Button exitButton;
|
||||
private Button blankButton;
|
||||
private FileDialog m_fd;
|
||||
private Config config;
|
||||
private OKDialog configPopup;
|
||||
private OKDialog errPopup;
|
||||
private TextField ToTextField = new TextField(30);
|
||||
private TextField CcTextField = new TextField(30);
|
||||
private TextArea textArea = new TextArea();
|
||||
private TextField SubjTextField = new TextField(30);
|
||||
private TextField FileTextField = new TextField(30);
|
||||
//private TextField InfoTextField = new TextField(30); // sending msg.. / sent
|
||||
private String blank = new String (" ");
|
||||
private String ToField = null;
|
||||
private String CcField = null;
|
||||
private String SubjField = null;
|
||||
|
||||
protected SMTPClient m_SMTPclnt;
|
||||
protected SMTPTestSink m_smtpSink;
|
||||
|
||||
private String filename = null;
|
||||
private String filename_lastnode = null;
|
||||
public String sender = "user@domain.com";
|
||||
public String host = "host.mcom.com";
|
||||
public String tmpdir = null;
|
||||
public int port = 25;
|
||||
|
||||
private boolean b_sending = false;
|
||||
public boolean b_pipeline = false;
|
||||
public boolean b_tracelog = false;
|
||||
public boolean b_dsn = false;
|
||||
public boolean b_configured = false;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
public SendMsgClnt ()
|
||||
{
|
||||
init ();
|
||||
}
|
||||
|
||||
public void init ()
|
||||
{
|
||||
try
|
||||
{
|
||||
Panel controlPanel;
|
||||
|
||||
//setLayout (new BorderLayout (0,0));
|
||||
setLayout (new FlowLayout (FlowLayout.LEFT));
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Create the panels and set the layouts
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// 1. Control Panel
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
controlPanel = new Panel ();
|
||||
|
||||
controlPanel.setLayout (new GridLayout (8,1));
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Create the buttons.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
sendOrNewButton = new Button ("NewMessage");
|
||||
fileButton = new Button ("AttachFile");
|
||||
cancelButton = new Button ("Cancel");
|
||||
blankButton = new Button (" ");
|
||||
configButton = new Button ("SetUp");
|
||||
exitButton = new Button ("Exit");
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Set Button Properties
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
sendOrNewButton.setBackground(Color.yellow);
|
||||
sendOrNewButton.setForeground(Color.black);
|
||||
|
||||
cancelButton.setBackground(Color.red);
|
||||
cancelButton.setForeground(Color.black);
|
||||
|
||||
fileButton.setBackground(Color.blue);
|
||||
fileButton.setForeground(Color.white);
|
||||
|
||||
configButton.setBackground(Color.magenta);
|
||||
configButton.setForeground(Color.white);
|
||||
|
||||
exitButton.setBackground(Color.black);
|
||||
exitButton.setForeground(Color.white);
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Add the buttons and the images to the controlPanel
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
controlPanel.add (sendOrNewButton);
|
||||
controlPanel.add (cancelButton);
|
||||
controlPanel.add (fileButton);
|
||||
controlPanel.add (blankButton);
|
||||
controlPanel.add (configButton);
|
||||
controlPanel.add (exitButton);
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Add the panel to the frame
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
add ("South", controlPanel);
|
||||
|
||||
cancelButton.setEnabled(false); // initially
|
||||
fileButton.setEnabled(false); // initially
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// 2. To/Cc/Text/Staus Panel
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
Panel userPanel = new Panel ();
|
||||
Panel ToPanel = new Panel ();
|
||||
Panel CcPanel = new Panel ();
|
||||
Panel SubjPanel = new Panel ();
|
||||
Panel FilePanel = new Panel ();
|
||||
|
||||
ToPanel.add("West", new Label("To: "));
|
||||
ToPanel.add("East", ToTextField);
|
||||
|
||||
CcPanel.add("West", new Label("Cc: "));
|
||||
CcPanel.add("East", CcTextField);
|
||||
|
||||
SubjPanel.add("West", new Label("Subject: "));
|
||||
SubjPanel.add("East", SubjTextField);
|
||||
|
||||
FilePanel.add("West", new Label("Attached: "));
|
||||
FilePanel.add("East", FileTextField);
|
||||
|
||||
Panel northPanel = new Panel ();
|
||||
northPanel.setLayout (new BorderLayout());
|
||||
|
||||
northPanel.add ("North", ToPanel);
|
||||
northPanel.add ("Center", CcPanel);
|
||||
northPanel.add ("South", SubjPanel);
|
||||
|
||||
// Intially Until New Message is pressed
|
||||
ToTextField.setEnabled(false);
|
||||
CcTextField.setEnabled(false);
|
||||
SubjTextField.setEnabled(false);
|
||||
FileTextField.setEditable(false);
|
||||
textArea.setEnabled(false);
|
||||
|
||||
userPanel.setLayout (new BorderLayout());
|
||||
|
||||
userPanel.add ("North", northPanel);
|
||||
userPanel.add ("Center", textArea);
|
||||
userPanel.add ("South", FilePanel);
|
||||
|
||||
add ("West", userPanel);
|
||||
add ("East", controlPanel);
|
||||
//add ("South", InfoPanel);
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Action Handlers
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -- New_Or_Send Button was pressed --------
|
||||
sendOrNewButton.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
if (b_configured == false)
|
||||
{
|
||||
// POP UP a Dialog BOX to configure
|
||||
// and return without sending
|
||||
|
||||
configPopup.display();
|
||||
return;
|
||||
}
|
||||
|
||||
if (b_sending == true)
|
||||
{
|
||||
// Currently in "Send" Mode.
|
||||
// Send Message and Switch to "NewMessage" Mode
|
||||
|
||||
// Try to send the message.
|
||||
// If it was successfull (i.e. all needed
|
||||
// fields are present etc. only then do the
|
||||
// label change. If not Pop up a Dialog Box
|
||||
// asking user to check for the needed fields.
|
||||
|
||||
if (sendIt ())
|
||||
return;
|
||||
|
||||
sendOrNewButton.setLabel ("NewMessage");
|
||||
sendOrNewButton.setBackground(Color.yellow);
|
||||
cancelButton.setEnabled(false);
|
||||
fileButton.setEnabled(false);
|
||||
|
||||
ToTextField.setEnabled(false);
|
||||
CcTextField.setEnabled(false);
|
||||
SubjTextField.setEnabled(false);
|
||||
textArea.setEnabled(false);
|
||||
|
||||
b_sending = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Currently in "NewMessage" Mode.
|
||||
// Switch to (Compose &) Send mode.
|
||||
sendOrNewButton.setLabel ("Send");
|
||||
sendOrNewButton.setBackground(Color.green);
|
||||
cancelButton.setEnabled(true);
|
||||
fileButton.setEnabled(true);
|
||||
filename = null; // ready for next round
|
||||
filename_lastnode = null; // ready for next round
|
||||
|
||||
// Clear The Text
|
||||
ToTextField.setText (blank);
|
||||
CcTextField.setText (blank);
|
||||
SubjTextField.setText(blank);
|
||||
textArea.setText (blank);
|
||||
FileTextField.setText (blank);
|
||||
|
||||
// Make them writable
|
||||
ToTextField.setEnabled(true);
|
||||
CcTextField.setEnabled(true);
|
||||
SubjTextField.setEnabled(true);
|
||||
textArea.setEnabled(true);
|
||||
|
||||
b_sending = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// -- File Button was pressed --------
|
||||
fileButton.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed (ActionEvent e)
|
||||
{
|
||||
filename = (selectFile()).trim();
|
||||
|
||||
if (filename != null)
|
||||
{
|
||||
fileButton.setEnabled(false);
|
||||
FileTextField.setText (filename);
|
||||
}
|
||||
else
|
||||
FileTextField.setText (null);
|
||||
}
|
||||
});
|
||||
|
||||
// -- config (SetUP) Button was pressed --------
|
||||
configButton.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed (ActionEvent e)
|
||||
{
|
||||
setEnabled(false);
|
||||
config.display();
|
||||
}
|
||||
});
|
||||
|
||||
// -- Cancel Button was pressed --------
|
||||
cancelButton.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed (ActionEvent e)
|
||||
{
|
||||
sendOrNewButton.setLabel ("NewMessage");
|
||||
sendOrNewButton.setBackground(Color.yellow);
|
||||
b_sending = false;
|
||||
cancelButton.setEnabled(false);
|
||||
fileButton.setEnabled(false);
|
||||
|
||||
ToTextField.setEnabled(false);
|
||||
CcTextField.setEnabled(false);
|
||||
SubjTextField.setEnabled(false);
|
||||
textArea.setEnabled(false);
|
||||
}
|
||||
});
|
||||
|
||||
// -- Exit Button was pressed --------
|
||||
exitButton.addActionListener (new ActionListener()
|
||||
{
|
||||
public void actionPerformed (ActionEvent e)
|
||||
{
|
||||
System.exit (0);
|
||||
}
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Set the Frame's title etc.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
setTitle ("Netscape Messaging SDK - Send Message Application");
|
||||
|
||||
//setLocation(500,200);
|
||||
//setLocation(0,0);
|
||||
|
||||
setResizable(false);
|
||||
pack();
|
||||
|
||||
// Make Config stuff ready to display
|
||||
config = new Config (this);
|
||||
configPopup = new OKDialog (this, "Error!", "Please SetUp First!");
|
||||
|
||||
// set up default tmpdir
|
||||
String sep = System.getProperty ("path.separator");
|
||||
if (sep.equals (";"))
|
||||
tmpdir = "C:\\temp"; // its windoz
|
||||
else
|
||||
tmpdir = "/tmp";
|
||||
|
||||
m_fd = new FileDialog (this, "Pick a File", FileDialog.LOAD);
|
||||
|
||||
m_smtpSink = new SMTPTestSink();
|
||||
m_SMTPclnt = new SMTPClient(m_smtpSink);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println ("SendMsgClnt Constructor caught Exception>>> " + e );
|
||||
}
|
||||
|
||||
} // init ()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// Display and Let the user Select File
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
public String selectFile ()
|
||||
{
|
||||
m_fd.setDirectory (".");
|
||||
m_fd.setVisible (true);
|
||||
//m_fd.show ();
|
||||
String file = m_fd.getFile();
|
||||
|
||||
if (file == null || file.length() <= 0)
|
||||
return null;
|
||||
|
||||
filename_lastnode = file;
|
||||
|
||||
return (new String (m_fd.getDirectory() + file));
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// Just the Destroy Event. The EXIT button takes care of that
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// public boolean handleEvent (Event evt)
|
||||
// {
|
||||
// if (evt.id == Event.WINDOW_DESTROY && evt.target == this)
|
||||
// {
|
||||
// System.exit(0);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return super.handleEvent (evt);
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// Send the Message out. On success return false and true on failure.
|
||||
// On detection of any errors Pop up a Dialog Box asking user to check
|
||||
// for the needed fields.
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
public boolean sendIt ()
|
||||
{
|
||||
String[] l_addrs;
|
||||
|
||||
// make sure needed items are present
|
||||
|
||||
if (sender == null || sender.length() == 0 || sender.equals ("user@domain.com"))
|
||||
{
|
||||
showFailPopUp("Error!", "Please SetUp Msg Sender!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (host == null || host.length() == 0 || host.equals ("host.mcom.com"))
|
||||
{
|
||||
showFailPopUp("Error!", "Please SetUp SMTP Host!");
|
||||
return true;
|
||||
}
|
||||
|
||||
ToField = ToTextField.getText();
|
||||
|
||||
if (ToField == null || ToField.length() == 0 || ToField.equals (blank))
|
||||
{
|
||||
showFailPopUp("Error!", "Please specify a recipient in To:");
|
||||
return true;
|
||||
}
|
||||
|
||||
CcField = CcTextField.getText();
|
||||
SubjField = SubjTextField.getText();
|
||||
|
||||
try
|
||||
{
|
||||
m_SMTPclnt.connect (host, port);
|
||||
|
||||
if (!m_smtpSink.tryProcessResponses(m_SMTPclnt))
|
||||
{
|
||||
showFailPopUp("Error!", "Unable to connect to SMTP host: " + host);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
showFailPopUp("Error!", "Unable to connect to SMTP host: " + host);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
m_SMTPclnt.mailFrom (sender, null);
|
||||
|
||||
if (!m_smtpSink.tryProcessResponses(m_SMTPclnt))
|
||||
{
|
||||
showFailPopUp("Error!", "Invalid Msg Sender Configured!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
boolean someFailed = false;
|
||||
boolean allFailed = true;
|
||||
|
||||
l_addrs = parseAddrs (ToField);
|
||||
|
||||
for (int i = 0, len = l_addrs.length; i < len; i++)
|
||||
{
|
||||
m_SMTPclnt.rcptTo (l_addrs[i], null);
|
||||
if (!m_smtpSink.tryProcessResponses(m_SMTPclnt))
|
||||
someFailed = true;
|
||||
else
|
||||
allFailed = false;
|
||||
}
|
||||
|
||||
if (CcField != null && !CcField.equals (blank))
|
||||
{
|
||||
l_addrs = parseAddrs (CcField);
|
||||
for (int i = 0, len = l_addrs.length; i < len; i++)
|
||||
{
|
||||
m_SMTPclnt.rcptTo (l_addrs[i], null);
|
||||
|
||||
if (!m_smtpSink.tryProcessResponses(m_SMTPclnt))
|
||||
someFailed = true;
|
||||
else
|
||||
allFailed = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (allFailed)
|
||||
{
|
||||
showFailPopUp("Error!", "Server rejected all recipients");
|
||||
return true;
|
||||
}
|
||||
|
||||
InputStream is = getMIMEMessage (sender, ToField, CcField, SubjField,
|
||||
filename);
|
||||
|
||||
m_SMTPclnt.data ();
|
||||
|
||||
if (!m_smtpSink.tryProcessResponses(m_SMTPclnt))
|
||||
{
|
||||
showFailPopUp("Error!", "Could not intiate Data transfer. Server Code ="
|
||||
+ m_smtpSink.m_failCode);
|
||||
return true;
|
||||
}
|
||||
|
||||
m_SMTPclnt.send (is);
|
||||
|
||||
if (!m_smtpSink.tryProcessResponses(m_SMTPclnt))
|
||||
{
|
||||
showFailPopUp("Error!", "Data transfer failure! Server code = "
|
||||
+ m_smtpSink.m_failCode);
|
||||
return true;
|
||||
}
|
||||
|
||||
m_SMTPclnt.quit();
|
||||
|
||||
if (!m_smtpSink.tryProcessResponses(m_SMTPclnt))
|
||||
{
|
||||
showFailPopUp("Error!", "Unbale to quit from server! Server code = "
|
||||
+ m_smtpSink.m_failCode);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
showFailPopUp("Exception!", e.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
// On success return false
|
||||
return false;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Build a MIME Message and return an inputStream
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public InputStream getMIMEMessage (String sender, String To, String Cc, String subject,
|
||||
String filefullname)
|
||||
{
|
||||
if (filename == null)
|
||||
return TextMIMEMessage (sender, To, Cc, subject);
|
||||
else
|
||||
return MultiPartMIMEMessage (sender, To, Cc, subject, filefullname);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Build and return an InputStream for MIME-Text-Message
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
public InputStream TextMIMEMessage (String sender, String To, String Cc, String subject)
|
||||
{
|
||||
FileInputStream fis;
|
||||
FileOutputStream fos;
|
||||
ByteArrayInputStream bins;
|
||||
|
||||
MIMEMessage mmsg;
|
||||
|
||||
try
|
||||
{
|
||||
// >>>> Build and retrun a text MIME Message <<<<
|
||||
|
||||
// Get an inputStream to user entered text
|
||||
bins = new ByteArrayInputStream ((textArea.getText()).getBytes());
|
||||
|
||||
// Create text MIMEMessage with the above text
|
||||
mmsg = new MIMEMessage(bins, null, 0);
|
||||
|
||||
// set the user entered headers on the message
|
||||
mmsg.setHeader ("From", sender);
|
||||
mmsg.setHeader ("Reply-To", sender);
|
||||
mmsg.setHeader ("To", To);
|
||||
|
||||
if (Cc != null && Cc.length() != 0 && !Cc.equals (blank))
|
||||
mmsg.setHeader ("Cc", Cc);
|
||||
|
||||
if (subject != null && subject.length() != 0 && !subject.equals (blank))
|
||||
mmsg.setHeader ("Subject", subject);
|
||||
|
||||
// Add any other desired headers.
|
||||
mmsg.setHeader ("X-MsgSdk-Header", "This is a Text Message");
|
||||
|
||||
String mimefile = new String (tmpdir + "/SDKMIMEMsg.out");
|
||||
fos = new FileOutputStream (mimefile);
|
||||
|
||||
// Encode the message in MIME Canaonical form for transmission
|
||||
mmsg.putByteStream (fos);
|
||||
|
||||
// Return an inputStream to the encoded MIME message
|
||||
fis = new FileInputStream (mimefile);
|
||||
return fis;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
showFailPopUp ("Exception", e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Build and return an InputStream for MIME-Multi-Part-Message
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
public InputStream MultiPartMIMEMessage (String sender, String To, String Cc,
|
||||
String subject, String fullfilename)
|
||||
{
|
||||
FileInputStream fis, fdis;
|
||||
FileOutputStream fos;
|
||||
ByteArrayInputStream bins;
|
||||
|
||||
MIMEMessage mmsg;
|
||||
|
||||
try
|
||||
{
|
||||
// >>>> Build and retrun a Multi-pArt MIME Message <<<<
|
||||
|
||||
// Get an inputStream to user entered text
|
||||
bins = new ByteArrayInputStream ((textArea.getText()).getBytes());
|
||||
|
||||
// Create a new Multi-part MIMEMessage with the above text and the file passed
|
||||
mmsg = new MIMEMessage(bins, fullfilename, -1);
|
||||
|
||||
// set the user entered headers on the message
|
||||
mmsg.setHeader ("From", sender);
|
||||
mmsg.setHeader ("Reply-To", sender);
|
||||
mmsg.setHeader ("To", To);
|
||||
|
||||
if (Cc != null && Cc.length() != 0 && !Cc.equals (blank))
|
||||
mmsg.setHeader ("Cc", Cc);
|
||||
|
||||
if (subject != null && subject.length() != 0 && !subject.equals (blank))
|
||||
mmsg.setHeader ("Subject", subject);
|
||||
|
||||
// Add any other desired headers.
|
||||
mmsg.setHeader ("X-MsgSdk-Header", "This is a Text Message");
|
||||
|
||||
String mimefile = new String (tmpdir + "/SDKMIMEMsg.out");
|
||||
fos = new FileOutputStream (mimefile);
|
||||
|
||||
// Encode the message in MIME Canaonical form for transmission
|
||||
mmsg.putByteStream (fos);
|
||||
|
||||
// Return an inputStream to the encoded MIME message
|
||||
fis = new FileInputStream (mimefile);
|
||||
return fis;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
showFailPopUp ("Exception", e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Parse space or comma separated addresses
|
||||
///////////////////////////////////////////////////////////////
|
||||
String [] parseAddrs (String mailAddrs)
|
||||
{
|
||||
String [] retAddrs;
|
||||
int count;
|
||||
|
||||
String inAddrs = mailAddrs.trim();
|
||||
|
||||
StringTokenizer stz = new StringTokenizer (inAddrs, " ,");
|
||||
|
||||
count = stz.countTokens();
|
||||
|
||||
if (count <= 0)
|
||||
return null;
|
||||
|
||||
retAddrs = new String [count];
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
retAddrs [i] = stz.nextToken();
|
||||
}
|
||||
|
||||
|
||||
return retAddrs;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Show the messages via PopUP
|
||||
//////////////////////////////////////////////////////////////
|
||||
public void showFailPopUp (String err, String msg)
|
||||
{
|
||||
errPopup = new OKDialog (this, err, msg);
|
||||
errPopup.display();
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// ----------------- MAIN -------------------------------
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
public static void main (String args[])
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Create the SendMsgClnt Frame, set the size, and display it.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SendMsgClnt client = new SendMsgClnt();
|
||||
//client.resize (200, 300);
|
||||
client.setVisible (true);
|
||||
//client.show ();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,179 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Netscape Messaging Access SDK Version 3.5 code,
|
||||
* released on or about June 15, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998 Netscape
|
||||
* Communications Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 and 1998 Netscape Communications Corporation
|
||||
* (http://home.netscape.com/misc/trademarks.html)
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
|
||||
import netscape.messaging.mime.*;
|
||||
|
||||
|
||||
/* Demo MIME encode Application using Netscape Messaging SDK MIME API.
|
||||
* creates a multi-part message given a text buffer and a file.
|
||||
* Note: In this example a default String (see textMsg) is used for
|
||||
* the text buffer for simplicity.
|
||||
*/
|
||||
|
||||
public class MIMEEncodeTest
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Private data members.
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private String filename = null;
|
||||
private String sender, To, subject;
|
||||
public String tmpdir = "/tmp/";
|
||||
private static String textMsg = "Hello this is a test Message";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
public MIMEEncodeTest ()
|
||||
{
|
||||
String sep = System.getProperty ("path.separator");
|
||||
if (sep.equals (";"))
|
||||
tmpdir = "C:\\temp"; // its windoz
|
||||
else
|
||||
tmpdir = "/tmp";
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// Build a Multi-Part MIME Message with the input parameters.
|
||||
// MIME encode the message and return an inputStream to encoded data.
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
public InputStream endcodeit (String sender, String To,
|
||||
String subject, String filename, int encoding) throws MIMEException
|
||||
{
|
||||
try
|
||||
{
|
||||
return MultiPartMIMEMessage (sender, To, subject, filename, encoding);
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
throw new MIMEException (e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Build and return an InputStream for MIME-Multi-Part-Message
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
public InputStream MultiPartMIMEMessage (String sender, String To,
|
||||
String subject, String fullfilename,
|
||||
int encoding)
|
||||
{
|
||||
FileInputStream fis, fdis;
|
||||
FileOutputStream fos;
|
||||
ByteArrayInputStream bins;
|
||||
|
||||
MIMEMessage mmsg;
|
||||
|
||||
try
|
||||
{
|
||||
// >>>> Build and retrun a Multi-Part MIME Message <<<<
|
||||
|
||||
// Get an inputStream to user entered text
|
||||
bins = new ByteArrayInputStream (textMsg.getBytes());
|
||||
|
||||
// Create a new Multi-part MIMEMessage with the above text and the file passed
|
||||
mmsg = new MIMEMessage(bins, fullfilename, encoding);
|
||||
|
||||
// set the user entered headers on the message
|
||||
mmsg.setHeader ("From", sender); // example sender = prasad@netscape.com
|
||||
mmsg.setHeader ("Reply-To", sender);
|
||||
mmsg.setHeader ("To", To);
|
||||
|
||||
if (subject != null && subject.length() != 0 )
|
||||
mmsg.setHeader ("Subject", subject);
|
||||
|
||||
// Add any other desired headers.
|
||||
mmsg.setHeader ("X-MsgSdk-Header", "This is a Text Message");
|
||||
|
||||
String mimefile = new String (tmpdir + "/SDKMIMEMsg.out");
|
||||
fos = new FileOutputStream (mimefile);
|
||||
|
||||
// Encode the message in MIME Canaonical form for transmission
|
||||
mmsg.putByteStream (fos);
|
||||
|
||||
// Return an inputStream to the encoded MIME message
|
||||
fis = new FileInputStream (mimefile);
|
||||
return fis;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("Exception!"+ e.getMessage());
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// ----------------- MAIN -------------------------------
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
public static void main (String args[])
|
||||
{
|
||||
if (args.length != 4 && args.length != 5)
|
||||
{
|
||||
System.out.println("usage: java MIMEEncodeTest sender To subject <file-name> <B|Q>");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
MIMEEncodeTest testClient = new MIMEEncodeTest();
|
||||
|
||||
testClient.sender = args[0];
|
||||
testClient.To = args[1];
|
||||
testClient.subject = args[2];
|
||||
testClient.filename = args[3];
|
||||
|
||||
int encoding = -1;
|
||||
|
||||
if (args.length > 5)
|
||||
{
|
||||
if (args[5].equalsIgnoreCase("B"))
|
||||
encoding = MIMEBodyPart.BASE64;
|
||||
|
||||
if (args[5].equalsIgnoreCase("Q"))
|
||||
encoding = MIMEBodyPart.QP;
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
testClient.endcodeit (testClient.sender,
|
||||
testClient.To,
|
||||
testClient.subject,
|
||||
testClient.filename,
|
||||
encoding);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("Exception!"+ e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
This directory contains an example program that demonstrates the use of the Netscape
|
||||
Messaging MIME Encoder java API.
|
||||
|
||||
To compile and run:
|
||||
-------------------
|
||||
|
||||
(1) Make sure CLASSPATH includes the msg-sdk jar file (proapi.jar).
|
||||
When installed proapi.jar is located at <install-root>/packages/proapi.jar.
|
||||
Make sure CLASSPATH also includes the directory you are compiling in.
|
||||
|
||||
(2) Compile: javac *.java
|
||||
(3) Run: java MIMEEncodeTest
|
||||
|
||||
This shows the usage:
|
||||
|
||||
java MIMEEncodeTest sender To subject <file-name> <B|Q>
|
||||
|
||||
Explanation of parameters above:
|
||||
sender: Sender of the message
|
||||
To: recipient of the message.
|
||||
Subject: Subject of the message.
|
||||
<file-name>: Name of file to attach (e.g. /tmp/x.txt C:image.jpg)
|
||||
<B|Q>: Type of MIME encoding desired. B = Base64. Q = QP.
|
||||
Assumes default based on filename extension if left out.
|
||||
|
||||
(4) Run again with appropriate parameters. For example:
|
||||
|
||||
java MIMEEncodeTest prasad@netscape.com prasad@netscape Test-Msg IMAG.JPG B
|
Загрузка…
Ссылка в новой задаче