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
18package com.android.messaging.mmslib.pdu;
19
20import com.android.messaging.mmslib.InvalidHeaderValueException;
21
22/**
23 * M-Acknowledge.ind PDU.
24 */
25public class AcknowledgeInd extends GenericPdu {
26    /**
27     * Constructor, used when composing a M-Acknowledge.ind pdu.
28     *
29     * @param mmsVersion    current viersion of mms
30     * @param transactionId the transaction-id value
31     * @throws InvalidHeaderValueException if parameters are invalid.
32     * @throws NullPointerException if transactionId is null.
33     */
34    public AcknowledgeInd(int mmsVersion, byte[] transactionId)
35            throws InvalidHeaderValueException {
36        super();
37
38        setMessageType(PduHeaders.MESSAGE_TYPE_ACKNOWLEDGE_IND);
39        setMmsVersion(mmsVersion);
40        setTransactionId(transactionId);
41    }
42
43    /**
44     * Constructor with given headers.
45     *
46     * @param headers Headers for this PDU.
47     */
48    AcknowledgeInd(PduHeaders headers) {
49        super(headers);
50    }
51
52    /**
53     * Get X-Mms-Report-Allowed field value.
54     *
55     * @return the X-Mms-Report-Allowed value
56     */
57    public int getReportAllowed() {
58        return mPduHeaders.getOctet(PduHeaders.REPORT_ALLOWED);
59    }
60
61    /**
62     * Set X-Mms-Report-Allowed field value.
63     *
64     * @param value the value
65     * @throws InvalidHeaderValueException if the value is invalid.
66     */
67    public void setReportAllowed(int value) throws InvalidHeaderValueException {
68        mPduHeaders.setOctet(value, PduHeaders.REPORT_ALLOWED);
69    }
70
71    /**
72     * Get X-Mms-Transaction-Id field value.
73     *
74     * @return the X-Mms-Report-Allowed value
75     */
76    public byte[] getTransactionId() {
77        return mPduHeaders.getTextString(PduHeaders.TRANSACTION_ID);
78    }
79
80    /**
81     * Set X-Mms-Transaction-Id field value.
82     *
83     * @param value the value
84     * @throws NullPointerException if the value is null.
85     */
86    public void setTransactionId(byte[] value) {
87        mPduHeaders.setTextString(value, PduHeaders.TRANSACTION_ID);
88    }
89}
90