/*
* Copyright (C) 2008 Andrea Zito
*
* This file is part of jMmsLib.
*
* jMmsLib is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* jMmsLib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with jMmsLib. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sourceforge.jmmslib;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
/**
* Represents an mms message.<br>
* <p>This class is used to fill the field of an mms message and do some basic data
* validation.</p>
*
* <p>The field required for the various type of mms messages are listed on the document
* <i>WAP-209-MMSEncapsulation-20020105-a</i>, avaiable at the
* <a href="http://www.openmobilealliance.org/tech/affiliates/wap/wapindex.html">Open Mobile Alliance</a> web site.
*
* @author Andrea Zito
*
*/
public class MmsMessage {
private static final String NL = "\r\n";
/*=========================================================================
* Header Name Constants
*=========================================================================*/
public static final String MMS_MESSAGE_TYPE = "X-Mms-Message-Type";
public static final String MMS_TRANSACTION_ID = "X-Mms-Transaction-ID";
public static final String MMS_VERSION = "X-Mms-MMS-Version";
public static final String MMS_DATE = "Date";
public static final String MMS_FROM = "From";
public static final String MMS_TO = "To";
public static final String MMS_CC = "CC";
public static final String MMS_BCC = "BCC";
public static final String MMS_SUBJECT = "Subject";
public static final String MMS_CLASS = "X-Mms-Message-Class";
public static final String MMS_EXPIRY = "X-Mms-Expiry";
public static final String MMS_DELIVERY_TIME = "X-Mms-Delivery-Time";
public static final String MMS_PRIORITY = "X-Mms-Priority";
public static final String MMS_SENDER_VISIBILITY = "X-Mms-Sender-Visibility";
public static final String MMS_DELIVERY_REPORT = "X-Mms-Delivery-Report";
public static final String MMS_READ_REPLY = "X-Mms-Read-Reply";
public static final String MMS_CONTENT_TYPE = "Content-Type";
public static final String MMS_RESPONSE_STATUS = "X-Mms-Response-Status";
public static final String MMS_RESPONSE_TEXT = "X-Mms-Response-Text";
public static final String MMS_MESSAGE_ID = "Message-ID";
/*=========================================================================
* Header Value Constants
*=========================================================================*/
public static final String CHARSET_US_ASCII = "us-ascii";
public static final String CHARSET_UTF8 = "utf-8";
public static final String MMS_MESSAGE_TYPE_SEND_REQUEST = "m-send-req";
public static final String MMS_MESSAGE_TYPE_SEND_CONF = "m-send-conf";
public static final String MMS_VERSION_1 = "1.0";
public static final String MMS_DELIVERY_REPORT_YES = "Yes";
public static final String MMS_DELIVERY_REPORT_NO = "No";
public static final String MMS_CLASS_PERSONAL = "Personal";
public static final String MMS_CLASS_ADVERTISEMENT = "Advertisement";
public static final String MMS_CLASS_INFORMATIONAL = "Informational";
public static final String MMS_CLASS_AUTO = "Auto";
public static final String MMS_PRIORITY_LOW = "Low";
public static final String MMS_PRIORITY_NORMAL = "Normal";
public static final String MMS_PRIORITY_HIGH = "High";
public static final String MMS_READ_REPLY_YES = "Yes";
public static final String MMS_READ_REPLY_NO = "No";
public static final String MMS_RESPONSE_STATUS_OK = "OK";
public static final String MMS_RESPONSE_STATUS_ERROR_UNSPECIFIED = "Error-unspecified";
public static final String MMS_RESPONSE_STATUS_ERROR_SERVICE_DENIED = "Error-service-denied";
public static final String MMS_RESPONSE_STATUS_ERROR_MESSAGE_FORMAT_CORRUPT = "Error-message-format-corrupt";
public static final String MMS_RESPONSE_STATUS_ERROR_SENDING_ADDRESS_UNRESOLVED = "Error-sending-address-unresolved";
public static final String MMS_RESPONSE_STATUS_ERROR_MESSAGE_NOT_FOUND = "Error-message-not-found";
public static final String MMS_RESPONSE_STATUS_ERROR_NETWORK_PROBLEM = "Error-network-problem";
public static final String MMS_RESPONSE_STATUS_ERROR_CONTENT_NOT_ACCEPTED = "Error-contant-not-accepted";
public static final String MMS_RESPONSE_STATUS_ERROR_UNSUPPORTED_MESSAGE = "Error-unsupported-message";
public static final String MMS_SENDER_VISIBILITY_HIDE = "Hide";
public static final String MMS_SENDER_VISIBILITY_SHOW = "Show";
public static final String MMS_ADDRESS_TYPE_MOBILE_NUMBER = "/TYPE=PLMN";
public static final String MMS_ADDRESS_TYPE_MAIL = "";
public static final String MMS_ADDRESS_TYPE_IPV4 = "/TYPE=IPV4";
public static final String MMS_ADDRESS_TYPE_IPV6 = "/TYPE=IPV6";
/*=========================================================================
* CONTENT TYPE CONSTANTS
*=========================================================================*/
public static final String CTYPE_UNKNOWN = "*/*";
public static final String CTYPE_TEXT = "text/*";
public static final String CTYPE_TEXT_PLAIN = "text/plain";
public static final String CTYPE_TEXT_HTML = "text/html";
public static final String CTYPE_TEXT_WML = "text/wnd.vap.wml";
public static final String CTYPE_IMAGE = "image/*";
public static final String CTYPE_IMAGE_JPEG = "image/jpeg";
public static final String CTYPE_IMAGE_GIF = "image/gif";
public static final String CTYPE_IMAGE_TIFF = "image/tiff";
public static final String CTYPE_IMAGE_PNG = "image/png";
public static final String CTYPE_IMAGE_VND_WAP_WBMP = "image/vnd.wap.wbmp";
public static final String CTYPE_MULTIPART = "multipart/*";
public static final String CTYPE_MULTIPART_MIXED = "multipart/mixed";
public static final String CTYPE_APPLICATION_MULTIPART_MIXED = "application/vnd.wap.multipart.mixed";
public static final String CTYPE_APPLICATION_MULTIPART_RELATED = "application/vnd.wap.multipart.related";
/*=========================================================================
* CLASS VARIABLES
*=========================================================================*/
private String mmsMessageType;
private String mmsTransactionId;
private String mmsVersion;
private Date mmsDate;
private String mmsFrom;
private ArrayList<String> mmsTo;
private ArrayList<String> mmsCC;
private ArrayList<String> mmsBCC;
private String mmsSubject;
private String mmsClass;
private Date mmsExpiryTime;
private Boolean mmsExpiryTimeAbsolute;
private Date mmsDeliveryTime;
private Boolean mmsDeliveryTimeAbsolute;
private String mmsPriority;
private String mmsSenderVisibility;
private Boolean mmsDeliveryReport;
private Boolean mmsReadReply;
private String mmsContentType;
private String mmsResponseStatus;
private String mmsResponseText;
private String mmsMessageID;
private ArrayList<MmsPart> mmsParts;
/*=========================================================================
* CONSTRUCTORS
*=========================================================================*/
/**
* Creates an MmsMessage object.
*/
public MmsMessage(){
this.mmsTo = new ArrayList<String>();
this.mmsCC = new ArrayList<String>();
this.mmsBCC = new ArrayList<String>();
this.mmsParts = new ArrayList<MmsPart>();
}
/*=========================================================================
* METHODS
*=========================================================================*/
/**
* Sets the MMS message typ
抱书眠
- 粉丝: 0
- 资源: 7