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.android.messaging.mmslib.pdu;
     19 
     20 import com.android.messaging.mmslib.InvalidHeaderValueException;
     21 
     22 /**
     23  * M-Retrive.conf Pdu.
     24  */
     25 public class RetrieveConf extends MultimediaMessagePdu {
     26     /**
     27      * Empty constructor.
     28      * Since the Pdu corresponding to this class is constructed
     29      * by the Proxy-Relay server, this class is only instantiated
     30      * by the Pdu Parser.
     31      *
     32      * @throws InvalidHeaderValueException if error occurs.
     33      */
     34     public RetrieveConf() throws InvalidHeaderValueException {
     35         super();
     36         setMessageType(PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF);
     37     }
     38 
     39     /**
     40      * Constructor with given headers.
     41      *
     42      * @param headers Headers for this PDU.
     43      */
     44     RetrieveConf(PduHeaders headers) {
     45         super(headers);
     46     }
     47 
     48     /**
     49      * Constructor with given headers and body
     50      *
     51      * @param headers Headers for this PDU.
     52      * @param body    Body of this PDu.
     53      */
     54     RetrieveConf(PduHeaders headers, PduBody body) {
     55         super(headers, body);
     56     }
     57 
     58     /**
     59      * Get CC value.
     60      *
     61      * @return the value
     62      */
     63     public EncodedStringValue[] getCc() {
     64         return mPduHeaders.getEncodedStringValues(PduHeaders.CC);
     65     }
     66 
     67     /**
     68      * Add a "CC" value.
     69      *
     70      * @param value the value
     71      * @throws NullPointerException if the value is null.
     72      */
     73     public void addCc(EncodedStringValue value) {
     74         mPduHeaders.appendEncodedStringValue(value, PduHeaders.CC);
     75     }
     76 
     77     /**
     78      * Get Content-type value.
     79      *
     80      * @return the value
     81      */
     82     public byte[] getContentType() {
     83         return mPduHeaders.getTextString(PduHeaders.CONTENT_TYPE);
     84     }
     85 
     86     /**
     87      * Set Content-type value.
     88      *
     89      * @param value the value
     90      * @throws NullPointerException if the value is null.
     91      */
     92     public void setContentType(byte[] value) {
     93         mPduHeaders.setTextString(value, PduHeaders.CONTENT_TYPE);
     94     }
     95 
     96     /**
     97      * Get X-Mms-Delivery-Report value.
     98      *
     99      * @return the value
    100      */
    101     public int getDeliveryReport() {
    102         return mPduHeaders.getOctet(PduHeaders.DELIVERY_REPORT);
    103     }
    104 
    105     /**
    106      * Set X-Mms-Delivery-Report value.
    107      *
    108      * @param value the value
    109      * @throws InvalidHeaderValueException if the value is invalid.
    110      */
    111     public void setDeliveryReport(int value) throws InvalidHeaderValueException {
    112         mPduHeaders.setOctet(value, PduHeaders.DELIVERY_REPORT);
    113     }
    114 
    115     /**
    116      * Get From value.
    117      * From-value = Value-length
    118      *      (Address-present-token Encoded-string-value | Insert-address-token)
    119      *
    120      * @return the value
    121      */
    122     public EncodedStringValue getFrom() {
    123         return mPduHeaders.getEncodedStringValue(PduHeaders.FROM);
    124     }
    125 
    126     /**
    127      * Set From value.
    128      *
    129      * @param value the value
    130      * @throws NullPointerException if the value is null.
    131      */
    132     public void setFrom(EncodedStringValue value) {
    133         mPduHeaders.setEncodedStringValue(value, PduHeaders.FROM);
    134     }
    135 
    136     /**
    137      * Get X-Mms-Message-Class value.
    138      * Message-class-value = Class-identifier | Token-text
    139      * Class-identifier = Personal | Advertisement | Informational | Auto
    140      *
    141      * @return the value
    142      */
    143     public byte[] getMessageClass() {
    144         return mPduHeaders.getTextString(PduHeaders.MESSAGE_CLASS);
    145     }
    146 
    147     /**
    148      * Set X-Mms-Message-Class value.
    149      *
    150      * @param value the value
    151      * @throws NullPointerException if the value is null.
    152      */
    153     public void setMessageClass(byte[] value) {
    154         mPduHeaders.setTextString(value, PduHeaders.MESSAGE_CLASS);
    155     }
    156 
    157     /**
    158      * Get Message-ID value.
    159      *
    160      * @return the value
    161      */
    162     public byte[] getMessageId() {
    163         return mPduHeaders.getTextString(PduHeaders.MESSAGE_ID);
    164     }
    165 
    166     /**
    167      * Set Message-ID value.
    168      *
    169      * @param value the value
    170      * @throws NullPointerException if the value is null.
    171      */
    172     public void setMessageId(byte[] value) {
    173         mPduHeaders.setTextString(value, PduHeaders.MESSAGE_ID);
    174     }
    175 
    176     /**
    177      * Get X-Mms-Read-Report value.
    178      *
    179      * @return the value
    180      */
    181     public int getReadReport() {
    182         return mPduHeaders.getOctet(PduHeaders.READ_REPORT);
    183     }
    184 
    185     /**
    186      * Set X-Mms-Read-Report value.
    187      *
    188      * @param value the value
    189      * @throws InvalidHeaderValueException if the value is invalid.
    190      */
    191     public void setReadReport(int value) throws InvalidHeaderValueException {
    192         mPduHeaders.setOctet(value, PduHeaders.READ_REPORT);
    193     }
    194 
    195     /**
    196      * Get X-Mms-Retrieve-Status value.
    197      *
    198      * @return the value
    199      */
    200     public int getRetrieveStatus() {
    201         /*
    202          * If the header is not there, assuming it is OK status.
    203          * Some carriers may choose to not send this header.
    204          */
    205         return mPduHeaders.hasHeader(PduHeaders.RETRIEVE_STATUS) ?
    206                 mPduHeaders.getOctet(PduHeaders.RETRIEVE_STATUS) : PduHeaders.RETRIEVE_STATUS_OK;
    207     }
    208 
    209     /**
    210      * Set X-Mms-Retrieve-Status value.
    211      *
    212      * @param value the value
    213      * @throws InvalidHeaderValueException if the value is invalid.
    214      */
    215     public void setRetrieveStatus(int value) throws InvalidHeaderValueException {
    216         mPduHeaders.setOctet(value, PduHeaders.RETRIEVE_STATUS);
    217     }
    218 
    219     /**
    220      * Get X-Mms-Retrieve-Text value.
    221      *
    222      * @return the value
    223      */
    224     public EncodedStringValue getRetrieveText() {
    225         return mPduHeaders.getEncodedStringValue(PduHeaders.RETRIEVE_TEXT);
    226     }
    227 
    228     /**
    229      * Set X-Mms-Retrieve-Text value.
    230      *
    231      * @param value the value
    232      * @throws NullPointerException if the value is null.
    233      */
    234     public void setRetrieveText(EncodedStringValue value) {
    235         mPduHeaders.setEncodedStringValue(value, PduHeaders.RETRIEVE_TEXT);
    236     }
    237 
    238     /**
    239      * Get X-Mms-Transaction-Id.
    240      *
    241      * @return the value
    242      */
    243     public byte[] getTransactionId() {
    244         return mPduHeaders.getTextString(PduHeaders.TRANSACTION_ID);
    245     }
    246 
    247     /**
    248      * Set X-Mms-Transaction-Id.
    249      *
    250      * @param value the value
    251      * @throws NullPointerException if the value is null.
    252      */
    253     public void setTransactionId(byte[] value) {
    254         mPduHeaders.setTextString(value, PduHeaders.TRANSACTION_ID);
    255     }
    256 
    257     /*
    258      * Optional, not supported header fields:
    259      *
    260      *     public byte[] getApplicId() {return null;}
    261      *     public void setApplicId(byte[] value) {}
    262      *
    263      *     public byte[] getAuxApplicId() {return null;}
    264      *     public void getAuxApplicId(byte[] value) {}
    265      *
    266      *     public byte getContentClass() {return 0x00;}
    267      *     public void setApplicId(byte value) {}
    268      *
    269      *     public byte getDrmContent() {return 0x00;}
    270      *     public void setDrmContent(byte value) {}
    271      *
    272      *     public byte getDistributionIndicator() {return 0x00;}
    273      *     public void setDistributionIndicator(byte value) {}
    274      *
    275      *     public PreviouslySentByValue getPreviouslySentBy() {return null;}
    276      *     public void setPreviouslySentBy(PreviouslySentByValue value) {}
    277      *
    278      *     public PreviouslySentDateValue getPreviouslySentDate() {}
    279      *     public void setPreviouslySentDate(PreviouslySentDateValue value) {}
    280      *
    281      *     public MmFlagsValue getMmFlags() {return null;}
    282      *     public void setMmFlags(MmFlagsValue value) {}
    283      *
    284      *     public MmStateValue getMmState() {return null;}
    285      *     public void getMmState(MmStateValue value) {}
    286      *
    287      *     public byte[] getReplaceId() {return 0x00;}
    288      *     public void setReplaceId(byte[] value) {}
    289      *
    290      *     public byte[] getReplyApplicId() {return 0x00;}
    291      *     public void setReplyApplicId(byte[] value) {}
    292      *
    293      *     public byte getReplyCharging() {return 0x00;}
    294      *     public void setReplyCharging(byte value) {}
    295      *
    296      *     public byte getReplyChargingDeadline() {return 0x00;}
    297      *     public void setReplyChargingDeadline(byte value) {}
    298      *
    299      *     public byte[] getReplyChargingId() {return 0x00;}
    300      *     public void setReplyChargingId(byte[] value) {}
    301      *
    302      *     public long getReplyChargingSize() {return 0;}
    303      *     public void setReplyChargingSize(long value) {}
    304      */
    305 }
    306