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