|
1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Inline methods for operations on PDU elements |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 */ |
|
21 |
|
22 #include <s32strm.h> |
|
23 #include <badesca.h> |
|
24 |
|
25 |
|
26 /** |
|
27 * Leaves with KErrGsmuDecoding. |
|
28 */ |
|
29 inline void TGsmuLex8::LeaveL() const |
|
30 { |
|
31 User::Leave(KErrGsmuDecoding); |
|
32 } |
|
33 |
|
34 |
|
35 /** |
|
36 * Constructor, initialising the octet value with a TInt8. |
|
37 * |
|
38 * @param aValue Octet value |
|
39 */ |
|
40 inline TSmsOctet::TSmsOctet(TUint8 aValue) |
|
41 : iValue(aValue) |
|
42 { |
|
43 // NOP |
|
44 } |
|
45 |
|
46 |
|
47 /** |
|
48 * Constructor, initialising the octet value with a TInt. |
|
49 * |
|
50 * @param aValue Octet value |
|
51 */ |
|
52 inline TSmsOctet::TSmsOctet(TInt aValue) |
|
53 :iValue(static_cast<TUint8>(aValue)) |
|
54 { |
|
55 } |
|
56 |
|
57 |
|
58 /** |
|
59 * Sets the octet value to the next byte in TGsmuLex8 PDU. |
|
60 * |
|
61 * @param aPdu PDU to read value from |
|
62 */ |
|
63 inline void TSmsOctet::DecodeL(TGsmuLex8& aPdu) |
|
64 { |
|
65 iValue=aPdu.GetL(); |
|
66 } |
|
67 |
|
68 |
|
69 /** |
|
70 * @return The octet value |
|
71 */ |
|
72 inline TSmsOctet::operator TInt() const |
|
73 { |
|
74 return iValue; |
|
75 } |
|
76 |
|
77 |
|
78 /** |
|
79 * Converts an integer to semi-octet format and set the object's data to this |
|
80 * value. |
|
81 * |
|
82 * @param aNum Value to convert to semi-octet |
|
83 */ |
|
84 inline void TSmsOctet::FillSemiOctets(TInt aNum) |
|
85 { |
|
86 *this=(aNum/10)|((aNum%10)<<4); |
|
87 } |
|
88 |
|
89 |
|
90 /** |
|
91 * Converts a semi-octet value to an integer. |
|
92 * |
|
93 * @return Object's data as an integer |
|
94 */ |
|
95 inline TInt TSmsOctet::SemiOctetsToNum() const |
|
96 { |
|
97 return ((iValue&0x0F)*10) + ((iValue&0xF0)>>4); |
|
98 } |
|
99 |
|
100 |
|
101 /** |
|
102 * Internalises the object. |
|
103 * |
|
104 * @param aStream Stream to read from |
|
105 */ |
|
106 inline void TSmsOctet::InternalizeL(RReadStream& aStream) |
|
107 { |
|
108 aStream >> iValue; |
|
109 } |
|
110 |
|
111 |
|
112 /** |
|
113 * Externalises the object. |
|
114 * |
|
115 * @param aStream Stream to write to |
|
116 */ |
|
117 inline void TSmsOctet::ExternalizeL(RWriteStream& aStream) const |
|
118 { |
|
119 aStream << iValue; |
|
120 } |
|
121 |
|
122 |
|
123 /** |
|
124 * Gets the error code. |
|
125 * |
|
126 * @return Error code |
|
127 */ |
|
128 inline TInt TSmsFailureCause::Error() const |
|
129 { |
|
130 return iValue; |
|
131 } |
|
132 |
|
133 |
|
134 /** |
|
135 * Sets the error code. |
|
136 * |
|
137 * @param aError Error code |
|
138 */ |
|
139 inline void TSmsFailureCause::SetError(TSmsFailureCauseError aError) |
|
140 { |
|
141 iValue=(TUint8) aError; |
|
142 } |
|
143 |
|
144 |
|
145 /** |
|
146 * Gets status value. |
|
147 * |
|
148 * @return Status value |
|
149 */ |
|
150 TSmsStatus::TSmsStatusValue TSmsStatus::Status() const |
|
151 { |
|
152 return (TSmsStatusValue) iValue; |
|
153 } |
|
154 |
|
155 |
|
156 /** |
|
157 * Sets status value. |
|
158 * |
|
159 * @param aValue Status value |
|
160 */ |
|
161 inline void TSmsStatus::SetStatus(TSmsStatusValue aValue) |
|
162 { |
|
163 iValue=(TUint8) aValue; |
|
164 } |
|
165 |
|
166 |
|
167 /** |
|
168 * Gets command type. |
|
169 * |
|
170 * @return Command type |
|
171 */ |
|
172 inline TInt TSmsCommandType::CommandType() const |
|
173 { |
|
174 return iValue; |
|
175 } |
|
176 |
|
177 |
|
178 /** |
|
179 * Sets command type. |
|
180 * |
|
181 * @param aType Command type |
|
182 */ |
|
183 inline void TSmsCommandType::SetCommandType(TSmsCommandTypeValue aType) |
|
184 { |
|
185 iValue=(TUint8) aType; |
|
186 } |
|
187 |
|
188 |
|
189 /** |
|
190 * Tests if the extension flag is set. |
|
191 * |
|
192 * @return True if data contains a PID extension |
|
193 */ |
|
194 inline TBool TSmsParameterIndicator::Extension() const |
|
195 { |
|
196 return iValue&ESmsPIDExtension; |
|
197 } |
|
198 |
|
199 |
|
200 /** |
|
201 * Sets extension flag. |
|
202 * |
|
203 * @param aExtension Extension flag |
|
204 */ |
|
205 inline void TSmsParameterIndicator::SetExtension(TBool aExtension) |
|
206 { |
|
207 iValue=(TUint8) (aExtension? iValue|ESmsPIDExtension: (iValue&(~ESmsPIDExtension))); |
|
208 } |
|
209 |
|
210 |
|
211 /** |
|
212 * Tests user data present flag. |
|
213 * |
|
214 * @return True if User Data is indicated |
|
215 */ |
|
216 inline TBool TSmsParameterIndicator::UserDataPresent() const |
|
217 { |
|
218 return iValue&ESmsPIDUserDataPresent; |
|
219 } |
|
220 |
|
221 |
|
222 /** |
|
223 * Sets user data present flag. |
|
224 * |
|
225 * @param aPresent Set to True/False to indicate/clear User Data |
|
226 */ |
|
227 inline void TSmsParameterIndicator::SetUserDataPresent(TBool aPresent) |
|
228 { |
|
229 iValue=(TUint8) (aPresent? iValue|ESmsPIDUserDataPresent: iValue&(~ESmsPIDUserDataPresent)); |
|
230 } |
|
231 |
|
232 |
|
233 /** |
|
234 * Tests data coding scheme present flag. |
|
235 * |
|
236 * @return True to indicate Data Coding Scheme present |
|
237 */ |
|
238 inline TBool TSmsParameterIndicator::DataCodingSchemePresent() const |
|
239 { |
|
240 return iValue&ESmsPIDDataCodingSchemePresent; |
|
241 } |
|
242 |
|
243 |
|
244 /** |
|
245 * Sets data coding scheme present flag. |
|
246 * |
|
247 * @param aPresent Set to True/False to indicate/clear Data Coding Scheme present |
|
248 */ |
|
249 inline void TSmsParameterIndicator::SetDataCodingSchemePresent(TBool aPresent) |
|
250 { |
|
251 iValue=(TUint8) (aPresent? iValue|ESmsPIDDataCodingSchemePresent: iValue&(~ESmsPIDDataCodingSchemePresent)); |
|
252 } |
|
253 |
|
254 |
|
255 /** |
|
256 * Tests protocol identifier present flag. |
|
257 * |
|
258 * @return True to indicate Protocol ID present |
|
259 */ |
|
260 inline TBool TSmsParameterIndicator::ProtocolIdentifierPresent() const |
|
261 { |
|
262 return iValue&ESmsPIDProtocolIdentifierPresent; |
|
263 } |
|
264 |
|
265 |
|
266 /** |
|
267 * Sets protocol identifier present flag. |
|
268 * |
|
269 * @param aPresent PSet to True/False to indicate/clear Protocol ID present |
|
270 */ |
|
271 inline void TSmsParameterIndicator::SetProtocolIdentifierPresent(TBool aPresent) |
|
272 { |
|
273 iValue=(TUint8) (aPresent? iValue|ESmsPIDProtocolIdentifierPresent: iValue&(~ESmsPIDProtocolIdentifierPresent)); |
|
274 } |
|
275 |
|
276 |
|
277 /** |
|
278 * Gets the Protocol ID type. |
|
279 * |
|
280 * @return Protocol ID type |
|
281 */ |
|
282 inline TSmsProtocolIdentifier::TSmsPIDType TSmsProtocolIdentifier::PIDType() const |
|
283 { |
|
284 return (TSmsPIDType) (iValue&ESmsPIDTypeMask); |
|
285 } |
|
286 |
|
287 |
|
288 /** |
|
289 * Sets the Protocol ID type. |
|
290 * |
|
291 * @param aSmsPIDType Protocol ID type |
|
292 */ |
|
293 inline void TSmsProtocolIdentifier::SetPIDType(TSmsPIDType aSmsPIDType) |
|
294 { |
|
295 iValue=(TUint8) aSmsPIDType; |
|
296 } |
|
297 |
|
298 |
|
299 /** |
|
300 * Gets bits 7 - 4 of the Data Coding Scheme. |
|
301 * |
|
302 * @return Bits 7 - 4 of the Data Coding Scheme |
|
303 */ |
|
304 inline TSmsDataCodingScheme::TSmsDCSBits7To4 TSmsDataCodingScheme::Bits7To4() const |
|
305 { |
|
306 return (TSmsDCSBits7To4) (iValue&ESmsDCSBits7To4Mask); |
|
307 } |
|
308 |
|
309 |
|
310 /** |
|
311 * Sets bits 7 - 4 of the Data Coding Scheme. |
|
312 * |
|
313 * @param aBits7To4 Bits 7 - 4 of the Data Coding Scheme |
|
314 */ |
|
315 inline void TSmsDataCodingScheme::SetBits7To4(TSmsDCSBits7To4 aBits7To4) |
|
316 { |
|
317 iValue=(TUint8) (aBits7To4); |
|
318 } |
|
319 |
|
320 |
|
321 /** |
|
322 * Constructor, specifying an octet value. |
|
323 * |
|
324 * @param aValue Octet value |
|
325 */ |
|
326 inline TGsmSmsTypeOfAddress::TGsmSmsTypeOfAddress(TInt aValue) |
|
327 : TSmsOctet(aValue) |
|
328 { |
|
329 } |
|
330 |
|
331 |
|
332 /** |
|
333 * Constructor, specifying type of numbering and numbering plan identification. |
|
334 * |
|
335 * @param aTon Type of numbering |
|
336 * @param aNPI Numbering plan identification |
|
337 */ |
|
338 inline TGsmSmsTypeOfAddress::TGsmSmsTypeOfAddress(TGsmSmsTypeOfNumber aTon, TGsmSmsNumberingPlanIdentification aNPI) |
|
339 : TSmsOctet(EGsmSmsFirstBitMask) |
|
340 { |
|
341 SetTON(aTon); |
|
342 SetNPI(aNPI); |
|
343 } |
|
344 |
|
345 |
|
346 /** |
|
347 * Gets the type of numbering. |
|
348 * |
|
349 * @return Type of numbering |
|
350 */ |
|
351 inline TGsmSmsTypeOfNumber TGsmSmsTypeOfAddress::TON() const |
|
352 { |
|
353 return (TGsmSmsTypeOfNumber) (iValue & EGsmSmsTONMask); |
|
354 } |
|
355 |
|
356 |
|
357 /** |
|
358 * Sets the type of numbering. |
|
359 * |
|
360 * @param aTON Type of numbering |
|
361 */ |
|
362 inline void TGsmSmsTypeOfAddress::SetTON(TGsmSmsTypeOfNumber aTON) |
|
363 { |
|
364 iValue = (TUint8) ((iValue & (~EGsmSmsTONMask)) | aTON); |
|
365 } |
|
366 |
|
367 |
|
368 /** |
|
369 * Gets the numbering plan identification. |
|
370 * |
|
371 * @return Numbering plan identification |
|
372 */ |
|
373 inline TGsmSmsNumberingPlanIdentification TGsmSmsTypeOfAddress::NPI() const |
|
374 { |
|
375 return (TGsmSmsNumberingPlanIdentification) (iValue & EGsmSmsNPIMask); |
|
376 } |
|
377 |
|
378 |
|
379 /** |
|
380 * Set the Numbering Plan Identification |
|
381 */ |
|
382 inline void TGsmSmsTypeOfAddress::SetNPI(TGsmSmsNumberingPlanIdentification aNumberingPlanIdentification) |
|
383 { |
|
384 iValue = (TUint8) ((iValue &(~EGsmSmsNPIMask)) | aNumberingPlanIdentification); |
|
385 } |
|
386 |
|
387 |
|
388 /** |
|
389 * Constructor |
|
390 */ |
|
391 inline TGsmSmsTelNumber::TGsmSmsTelNumber() |
|
392 { |
|
393 } |
|
394 |
|
395 |
|
396 /** |
|
397 * Gets the time zone offset from GMT in +/- quarter hours. |
|
398 * The allowed range is +/-79 per 23.040 V4.4.0 9.2.3.11. |
|
399 * |
|
400 * @return Time zone offset |
|
401 */ |
|
402 inline TInt TSmsServiceCenterTimeStamp::TimeOffset() const |
|
403 { |
|
404 return iTimeZoneNumQuarterHours; |
|
405 } |
|
406 |
|
407 |
|
408 /** |
|
409 * Gets the Service Center Time in Universal Time. |
|
410 * |
|
411 * @return The Service Center Time |
|
412 */ |
|
413 inline const TTime& TSmsServiceCenterTimeStamp::Time() const |
|
414 { |
|
415 return iTime; |
|
416 } |
|
417 |
|
418 |
|
419 /** |
|
420 * Sets the Service Center Time Stamp in Universal Time. |
|
421 * |
|
422 * @param aTime The Service Center Time |
|
423 */ |
|
424 inline void TSmsServiceCenterTimeStamp::SetTime(const TTime& aTime) |
|
425 { |
|
426 iTime=aTime; |
|
427 } |
|
428 |
|
429 |
|
430 /** |
|
431 * Gets the message Validity Period Format. |
|
432 * |
|
433 * @return The message Validity Period Format |
|
434 */ |
|
435 inline TSmsFirstOctet::TSmsValidityPeriodFormat TSmsValidityPeriod::ValidityPeriodFormat() const |
|
436 { |
|
437 return (TSmsFirstOctet::TSmsValidityPeriodFormat) (iFirstOctet&TSmsFirstOctet::ESmsVPFMask); |
|
438 } |
|
439 |
|
440 |
|
441 /** |
|
442 * Sets the message Validity Period Format. |
|
443 * |
|
444 * @param aValidityPeriodFormat The message Validity Period Format |
|
445 */ |
|
446 inline void TSmsValidityPeriod::SetValidityPeriodFormat(TSmsFirstOctet::TSmsValidityPeriodFormat aValidityPeriodFormat) |
|
447 { |
|
448 iFirstOctet=(iFirstOctet&(~TSmsFirstOctet::ESmsVPFMask)|aValidityPeriodFormat); |
|
449 } |
|
450 |
|
451 |
|
452 /** |
|
453 * Gets the message Validity Period in minutes. |
|
454 * |
|
455 * @return The message Validity Period in minutes |
|
456 */ |
|
457 inline const TTimeIntervalMinutes& TSmsValidityPeriod::TimeIntervalMinutes() const |
|
458 { |
|
459 return iTimeIntervalMinutes; |
|
460 } |
|
461 |
|
462 |
|
463 /** |
|
464 * Sets the message Validity Period in minutes. |
|
465 * |
|
466 * @param aTimeIntervalMinutes The message Validity Period in minutes |
|
467 */ |
|
468 inline void TSmsValidityPeriod::SetTimeIntervalMinutes(const TTimeIntervalMinutes& aTimeIntervalMinutes) |
|
469 { |
|
470 iTimeIntervalMinutes=aTimeIntervalMinutes; |
|
471 } |
|
472 |
|
473 |
|
474 /** |
|
475 * Resets the unconverted native character buffer. |
|
476 */ |
|
477 inline void CSmsAlphabetConverter::ResetUnconvertedNativeCharacters() |
|
478 { |
|
479 iUnconvertedNativeCharactersPtr.Zero(); |
|
480 } |
|
481 |
|
482 |
|
483 /** |
|
484 * Resets the unconverted user data elements buffer. |
|
485 */ |
|
486 inline void CSmsAlphabetConverter::ResetUnconvertedUDElements() |
|
487 { |
|
488 iUnconvertedUDElementsPtr.Zero(); |
|
489 } |
|
490 |
|
491 |
|
492 /** |
|
493 * Gets the unconverted native characters. |
|
494 * |
|
495 * @return Unconverted native characters |
|
496 */ |
|
497 inline TPtrC CSmsAlphabetConverter::UnconvertedNativeCharacters() |
|
498 { |
|
499 return iUnconvertedNativeCharactersPtr; |
|
500 } |
|
501 |
|
502 |
|
503 /** |
|
504 * Gets the unconverted user data elements. |
|
505 * |
|
506 * @return Unconverted user data elements |
|
507 */ |
|
508 inline TPtrC8 CSmsAlphabetConverter::UnconvertedUDElements() |
|
509 { |
|
510 return iUnconvertedUDElementsPtr; |
|
511 } |
|
512 |
|
513 |
|
514 /** |
|
515 * Gets the coding scheme alphabet. |
|
516 * |
|
517 * @return Coding scheme alphabet |
|
518 */ |
|
519 inline TSmsDataCodingScheme::TSmsAlphabet CSmsAlphabetConverter::Alphabet() const |
|
520 { |
|
521 return iSmsAlphabet; |
|
522 } |
|
523 |
|
524 |
|
525 /** |
|
526 * @publishedAll |
|
527 * @released |
|
528 */ |
|
529 inline CSmsInformationElement::CSmsInformationElement(TSmsInformationElementIdentifier aInformationElementIdentifier):iIdentifier(aInformationElementIdentifier) |
|
530 { |
|
531 } |
|
532 |
|
533 |
|
534 /** |
|
535 * Gets the number of information elements. |
|
536 * |
|
537 * @return Number of information elements |
|
538 */ |
|
539 inline TInt CSmsUserData::NumInformationElements() const |
|
540 { |
|
541 return iInformationElementArray.Count(); |
|
542 } |
|
543 |
|
544 |
|
545 /** |
|
546 * @return The number of Command Information Elements |
|
547 * @publishedAll |
|
548 * @released |
|
549 */ |
|
550 inline TInt CSmsCommandData::NumInformationElements() const |
|
551 { |
|
552 return iInformationElementArray.Count(); |
|
553 } |
|
554 |
|
555 |
|
556 /** |
|
557 * @return The amount of space in the Command buffer |
|
558 * @publishedAll |
|
559 * @released |
|
560 */ |
|
561 inline TInt CSmsCommandData::MaxDataLength() const |
|
562 { |
|
563 return KSmsMaxDataSize-iBuffer->Des().Length(); |
|
564 } |