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