Home | History | Annotate | Download | only in pdu
      1 /*
      2  * Copyright (C) 2007 Esmertec AG.
      3  * Copyright (C) 2007 The Android Open Source Project
      4  *
      5  * Licensed under the Apache License, Version 2.0 (the "License");
      6  * you may not use this file except in compliance with the License.
      7  * You may obtain a copy of the License at
      8  *
      9  *      http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  * Unless required by applicable law or agreed to in writing, software
     12  * distributed under the License is distributed on an "AS IS" BASIS,
     13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  * See the License for the specific language governing permissions and
     15  * limitations under the License.
     16  */
     17 
     18 package com.google.android.mms.pdu;
     19 
     20 import com.google.android.mms.InvalidHeaderValueException;
     21 
     22 /**
     23  * Multimedia message PDU.
     24  */
     25 public class MultimediaMessagePdu extends GenericPdu{
     26     /**
     27      * The body.
     28      */
     29     private PduBody mMessageBody;
     30 
     31     /**
     32      * Constructor.
     33      */
     34     public MultimediaMessagePdu() {
     35         super();
     36     }
     37 
     38     /**
     39      * Constructor.
     40      *
     41      * @param header the header of this PDU
     42      * @param body the body of this PDU
     43      */
     44     public MultimediaMessagePdu(PduHeaders header, PduBody body) {
     45         super(header);
     46         mMessageBody = body;
     47     }
     48 
     49     /**
     50      * Constructor with given headers.
     51      *
     52      * @param headers Headers for this PDU.
     53      */
     54     MultimediaMessagePdu(PduHeaders headers) {
     55         super(headers);
     56     }
     57 
     58     /**
     59      * Get body of the PDU.
     60      *
     61      * @return the body
     62      */
     63     public PduBody getBody() {
     64         return mMessageBody;
     65     }
     66 
     67     /**
     68      * Set body of the PDU.
     69      *
     70      * @param body the body
     71      */
     72     public void setBody(PduBody body) {
     73         mMessageBody = body;
     74     }
     75 
     76     /**
     77      * Get subject.
     78      *
     79      * @return the value
     80      */
     81     public EncodedStringValue getSubject() {
     82         return mPduHeaders.getEncodedStringValue(PduHeaders.SUBJECT);
     83     }
     84 
     85     /**
     86      * Set subject.
     87      *
     88      * @param value the value
     89      * @throws NullPointerException if the value is null.
     90      */
     91     public void setSubject(EncodedStringValue value) {
     92         mPduHeaders.setEncodedStringValue(value, PduHeaders.SUBJECT);
     93     }
     94 
     95     /**
     96      * Get To value.
     97      *
     98      * @return the value
     99      */
    100     public EncodedStringValue[] getTo() {
    101         return mPduHeaders.getEncodedStringValues(PduHeaders.TO);
    102     }
    103 
    104     /**
    105      * Add a "To" value.
    106      *
    107      * @param value the value
    108      * @throws NullPointerException if the value is null.
    109      */
    110     public void addTo(EncodedStringValue value) {
    111         mPduHeaders.appendEncodedStringValue(value, PduHeaders.TO);
    112     }
    113 
    114     /**
    115      * Get X-Mms-Priority value.
    116      *
    117      * @return the value
    118      */
    119     public int getPriority() {
    120         return mPduHeaders.getOctet(PduHeaders.PRIORITY);
    121     }
    122 
    123     /**
    124      * Set X-Mms-Priority value.
    125      *
    126      * @param value the value
    127      * @throws InvalidHeaderValueException if the value is invalid.
    128      */
    129     public void setPriority(int value) throws InvalidHeaderValueException {
    130         mPduHeaders.setOctet(value, PduHeaders.PRIORITY);
    131     }
    132 
    133     /**
    134      * Get Date value.
    135      *
    136      * @return the value
    137      */
    138     public long getDate() {
    139         return mPduHeaders.getLongInteger(PduHeaders.DATE);
    140     }
    141 
    142     /**
    143      * Set Date value in seconds.
    144      *
    145      * @param value the value
    146      */
    147     public void setDate(long value) {
    148         mPduHeaders.setLongInteger(value, PduHeaders.DATE);
    149     }
    150 }
    151