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 android.support.v7.mms.pdu;
19
20/**
21 * M-Notification.ind PDU.
22 */
23public class NotificationInd extends GenericPdu {
24    /**
25     * Empty constructor.
26     * Since the Pdu corresponding to this class is constructed
27     * by the Proxy-Relay server, this class is only instantiated
28     * by the Pdu Parser.
29     *
30     * @throws InvalidHeaderValueException if error occurs.
31     *         RuntimeException if an undeclared error occurs.
32     */
33    public NotificationInd() throws InvalidHeaderValueException {
34        super();
35        setMessageType(PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND);
36    }
37
38    /**
39     * Constructor with given headers.
40     *
41     * @param headers Headers for this PDU.
42     */
43    NotificationInd(PduHeaders headers) {
44        super(headers);
45    }
46
47    /**
48     * Get X-Mms-Content-Class Value.
49     *
50     * @return the value
51     */
52    public int getContentClass() {
53        return mPduHeaders.getOctet(PduHeaders.CONTENT_CLASS);
54    }
55
56    /**
57     * Set X-Mms-Content-Class Value.
58     *
59     * @param value the value
60     * @throws InvalidHeaderValueException if the value is invalid.
61     *         RuntimeException if an undeclared error occurs.
62     */
63    public void setContentClass(int value) throws InvalidHeaderValueException {
64        mPduHeaders.setOctet(value, PduHeaders.CONTENT_CLASS);
65    }
66
67    /**
68     * Get X-Mms-Content-Location value.
69     * When used in a PDU other than M-Mbox-Delete.conf and M-Delete.conf:
70     * Content-location-value = Uri-value
71     *
72     * @return the value
73     */
74    public byte[] getContentLocation() {
75        return mPduHeaders.getTextString(PduHeaders.CONTENT_LOCATION);
76    }
77
78    /**
79     * Set X-Mms-Content-Location value.
80     *
81     * @param value the value
82     * @throws NullPointerException if the value is null.
83     *         RuntimeException if an undeclared error occurs.
84     */
85    public void setContentLocation(byte[] value) {
86        mPduHeaders.setTextString(value, PduHeaders.CONTENT_LOCATION);
87    }
88
89    /**
90     * Get X-Mms-Expiry value.
91     *
92     * Expiry-value = Value-length
93     *      (Absolute-token Date-value | Relative-token Delta-seconds-value)
94     *
95     * @return the value
96     */
97    public long getExpiry() {
98        return mPduHeaders.getLongInteger(PduHeaders.EXPIRY);
99    }
100
101    /**
102     * Set X-Mms-Expiry value.
103     *
104     * @param value the value
105     * @throws RuntimeException if an undeclared error occurs.
106     */
107    public void setExpiry(long value) {
108        mPduHeaders.setLongInteger(value, PduHeaders.EXPIRY);
109    }
110
111    /**
112     * Get From value.
113     * From-value = Value-length
114     *      (Address-present-token Encoded-string-value | Insert-address-token)
115     *
116     * @return the value
117     */
118    public EncodedStringValue getFrom() {
119       return mPduHeaders.getEncodedStringValue(PduHeaders.FROM);
120    }
121
122    /**
123     * Set From value.
124     *
125     * @param value the value
126     * @throws NullPointerException if the value is null.
127     *         RuntimeException if an undeclared error occurs.
128     */
129    public void setFrom(EncodedStringValue value) {
130        mPduHeaders.setEncodedStringValue(value, PduHeaders.FROM);
131    }
132
133    /**
134     * Get X-Mms-Message-Class value.
135     * Message-class-value = Class-identifier | Token-text
136     * Class-identifier = Personal | Advertisement | Informational | Auto
137     *
138     * @return the value
139     */
140    public byte[] getMessageClass() {
141        return mPduHeaders.getTextString(PduHeaders.MESSAGE_CLASS);
142    }
143
144    /**
145     * Set X-Mms-Message-Class value.
146     *
147     * @param value the value
148     * @throws NullPointerException if the value is null.
149     *         RuntimeException if an undeclared error occurs.
150     */
151    public void setMessageClass(byte[] value) {
152        mPduHeaders.setTextString(value, PduHeaders.MESSAGE_CLASS);
153    }
154
155    /**
156     * Get X-Mms-Message-Size value.
157     * Message-size-value = Long-integer
158     *
159     * @return the value
160     */
161    public long getMessageSize() {
162        return mPduHeaders.getLongInteger(PduHeaders.MESSAGE_SIZE);
163    }
164
165    /**
166     * Set X-Mms-Message-Size value.
167     *
168     * @param value the value
169     * @throws RuntimeException if an undeclared error occurs.
170     */
171    public void setMessageSize(long value) {
172        mPduHeaders.setLongInteger(value, PduHeaders.MESSAGE_SIZE);
173    }
174
175    /**
176     * Get subject.
177     *
178     * @return the value
179     */
180    public EncodedStringValue getSubject() {
181        return mPduHeaders.getEncodedStringValue(PduHeaders.SUBJECT);
182    }
183
184    /**
185     * Set subject.
186     *
187     * @param value the value
188     * @throws NullPointerException if the value is null.
189     *         RuntimeException if an undeclared error occurs.
190     */
191    public void setSubject(EncodedStringValue value) {
192        mPduHeaders.setEncodedStringValue(value, PduHeaders.SUBJECT);
193    }
194
195    /**
196     * Get X-Mms-Transaction-Id.
197     *
198     * @return the value
199     */
200    public byte[] getTransactionId() {
201        return mPduHeaders.getTextString(PduHeaders.TRANSACTION_ID);
202    }
203
204    /**
205     * Set X-Mms-Transaction-Id.
206     *
207     * @param value the value
208     * @throws NullPointerException if the value is null.
209     *         RuntimeException if an undeclared error occurs.
210     */
211    public void setTransactionId(byte[] value) {
212        mPduHeaders.setTextString(value, PduHeaders.TRANSACTION_ID);
213    }
214
215    /**
216     * Get X-Mms-Delivery-Report Value.
217     *
218     * @return the value
219     */
220    public int getDeliveryReport() {
221        return mPduHeaders.getOctet(PduHeaders.DELIVERY_REPORT);
222    }
223
224    /**
225     * Set X-Mms-Delivery-Report Value.
226     *
227     * @param value the value
228     * @throws InvalidHeaderValueException if the value is invalid.
229     *         RuntimeException if an undeclared error occurs.
230     */
231    public void setDeliveryReport(int value) throws InvalidHeaderValueException {
232        mPduHeaders.setOctet(value, PduHeaders.DELIVERY_REPORT);
233    }
234
235    /*
236     * Optional, not supported header fields:
237     *
238     *     public byte[] getApplicId() {return null;}
239     *     public void setApplicId(byte[] value) {}
240     *
241     *     public byte[] getAuxApplicId() {return null;}
242     *     public void getAuxApplicId(byte[] value) {}
243     *
244     *     public byte getDrmContent() {return 0x00;}
245     *     public void setDrmContent(byte value) {}
246     *
247     *     public byte getDistributionIndicator() {return 0x00;}
248     *     public void setDistributionIndicator(byte value) {}
249     *
250     *     public ElementDescriptorValue getElementDescriptor() {return null;}
251     *     public void getElementDescriptor(ElementDescriptorValue value) {}
252     *
253     *     public byte getPriority() {return 0x00;}
254     *     public void setPriority(byte value) {}
255     *
256     *     public byte getRecommendedRetrievalMode() {return 0x00;}
257     *     public void setRecommendedRetrievalMode(byte value) {}
258     *
259     *     public byte getRecommendedRetrievalModeText() {return 0x00;}
260     *     public void setRecommendedRetrievalModeText(byte value) {}
261     *
262     *     public byte[] getReplaceId() {return 0x00;}
263     *     public void setReplaceId(byte[] value) {}
264     *
265     *     public byte[] getReplyApplicId() {return 0x00;}
266     *     public void setReplyApplicId(byte[] value) {}
267     *
268     *     public byte getReplyCharging() {return 0x00;}
269     *     public void setReplyCharging(byte value) {}
270     *
271     *     public byte getReplyChargingDeadline() {return 0x00;}
272     *     public void setReplyChargingDeadline(byte value) {}
273     *
274     *     public byte[] getReplyChargingId() {return 0x00;}
275     *     public void setReplyChargingId(byte[] value) {}
276     *
277     *     public long getReplyChargingSize() {return 0;}
278     *     public void setReplyChargingSize(long value) {}
279     *
280     *     public byte getStored() {return 0x00;}
281     *     public void setStored(byte value) {}
282     */
283}
284