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 android.support.v7.mms.pdu;
     19 
     20 /**
     21  * Multimedia message PDU.
     22  */
     23 public class MultimediaMessagePdu extends GenericPdu{
     24     /**
     25      * The body.
     26      */
     27     private PduBody mMessageBody;
     28 
     29     /**
     30      * Constructor.
     31      */
     32     public MultimediaMessagePdu() {
     33         super();
     34     }
     35 
     36     /**
     37      * Constructor.
     38      *
     39      * @param header the header of this PDU
     40      * @param body the body of this PDU
     41      */
     42     public MultimediaMessagePdu(PduHeaders header, PduBody body) {
     43         super(header);
     44         mMessageBody = body;
     45     }
     46 
     47     /**
     48      * Constructor with given headers.
     49      *
     50      * @param headers Headers for this PDU.
     51      */
     52     MultimediaMessagePdu(PduHeaders headers) {
     53         super(headers);
     54     }
     55 
     56     /**
     57      * Get body of the PDU.
     58      *
     59      * @return the body
     60      */
     61     public PduBody getBody() {
     62         return mMessageBody;
     63     }
     64 
     65     /**
     66      * Set body of the PDU.
     67      *
     68      * @param body the body
     69      */
     70     public void setBody(PduBody body) {
     71         mMessageBody = body;
     72     }
     73 
     74     /**
     75      * Get subject.
     76      *
     77      * @return the value
     78      */
     79     public EncodedStringValue getSubject() {
     80         return mPduHeaders.getEncodedStringValue(PduHeaders.SUBJECT);
     81     }
     82 
     83     /**
     84      * Set subject.
     85      *
     86      * @param value the value
     87      * @throws NullPointerException if the value is null.
     88      */
     89     public void setSubject(EncodedStringValue value) {
     90         mPduHeaders.setEncodedStringValue(value, PduHeaders.SUBJECT);
     91     }
     92 
     93     /**
     94      * Get To value.
     95      *
     96      * @return the value
     97      */
     98     public EncodedStringValue[] getTo() {
     99         return mPduHeaders.getEncodedStringValues(PduHeaders.TO);
    100     }
    101 
    102     /**
    103      * Add a "To" value.
    104      *
    105      * @param value the value
    106      * @throws NullPointerException if the value is null.
    107      */
    108     public void addTo(EncodedStringValue value) {
    109         mPduHeaders.appendEncodedStringValue(value, PduHeaders.TO);
    110     }
    111 
    112     /**
    113      * Get X-Mms-Priority value.
    114      *
    115      * @return the value
    116      */
    117     public int getPriority() {
    118         return mPduHeaders.getOctet(PduHeaders.PRIORITY);
    119     }
    120 
    121     /**
    122      * Set X-Mms-Priority value.
    123      *
    124      * @param value the value
    125      * @throws InvalidHeaderValueException if the value is invalid.
    126      */
    127     public void setPriority(int value) throws InvalidHeaderValueException {
    128         mPduHeaders.setOctet(value, PduHeaders.PRIORITY);
    129     }
    130 
    131     /**
    132      * Get Date value.
    133      *
    134      * @return the value
    135      */
    136     public long getDate() {
    137         return mPduHeaders.getLongInteger(PduHeaders.DATE);
    138     }
    139 
    140     /**
    141      * Set Date value in seconds.
    142      *
    143      * @param value the value
    144      */
    145     public void setDate(long value) {
    146         mPduHeaders.setLongInteger(value, PduHeaders.DATE);
    147     }
    148 }
    149