smsprotocols/smsstack/gsmu/src/gsmupdu.cpp
changeset 0 3553901f7fa8
child 14 7ef16719d8cb
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2003-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 // Contains implementations for the classes defined in gsmpdu.h
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20 */
       
    21 
       
    22 #include <etelmm.h>
       
    23 #include "gsmuNmspaceMobMsg.h"
       
    24 #include "gsmuetel.h"
       
    25 #include <exterror.h>
       
    26 #include <e32uid.h>
       
    27 
       
    28 #include "gsmupdu.h"
       
    29 #include "Gsmumain.h"
       
    30 #include "Gsmumsg.h"
       
    31 
       
    32 /**
       
    33  *  Restores a CSmsPDU from a stream where the object has bean previously persisted.
       
    34  *  
       
    35  *  The type is determined from the first byte in the stream.
       
    36  *  
       
    37  *  @param aStream Stream from which to restore this CSmsPDU
       
    38  *  @param aCharacterSetConverter Character converter utility, required for encoding
       
    39  *  and decoding this PDU
       
    40  *  @param aFs File system handle, required for encoding and decoding this PDU
       
    41  *  @return Newly constructed CSmsPDU-derived object restored from aStream
       
    42  *  @capability None
       
    43  */
       
    44 EXPORT_C CSmsPDU* CSmsPDU::NewL(RReadStream& aStream,CCnvCharacterSetConverter& aCharacterSetConverter,RFs& aFs)
       
    45 	{
       
    46 	LOGGSMU1("CSmsPDU::NewL()");
       
    47 
       
    48 	TInt type=aStream.ReadUint8L();
       
    49 	CSmsPDU* smspdu=NULL;
       
    50 	switch (type)
       
    51 		{
       
    52 		case ESmsDeliver:
       
    53 			{
       
    54 			smspdu=new(ELeave) CSmsDeliver();
       
    55 			break;
       
    56 			}
       
    57 		case ESmsSubmit:
       
    58 			{
       
    59 			smspdu=new(ELeave) CSmsSubmit();
       
    60 			break;
       
    61 			}
       
    62 		case ESmsDeliverReport:
       
    63 			{
       
    64 			smspdu=new(ELeave) CSmsDeliverReport();
       
    65 			break;
       
    66 			}
       
    67 		case ESmsSubmitReport:
       
    68 			{
       
    69 			smspdu=new(ELeave) CSmsSubmitReport();
       
    70 			break;
       
    71 			}
       
    72 		case ESmsStatusReport:
       
    73 			{
       
    74 			smspdu=new(ELeave) CSmsStatusReport();
       
    75 			break;
       
    76 			}
       
    77 		case ESmsCommand:
       
    78 			{
       
    79 			smspdu=new(ELeave) CSmsCommand();
       
    80 			break;
       
    81 			}
       
    82 		default:
       
    83 			User::Leave(KErrNotSupported);
       
    84 		};
       
    85 	CleanupStack::PushL(smspdu);
       
    86 	smspdu->ConstructL(aCharacterSetConverter,aFs);
       
    87 	smspdu->InternalizeMessagePDUL(aStream);
       
    88 	CleanupStack::Pop();
       
    89 	return smspdu;
       
    90 	} // CSmsPDU::NewL
       
    91 
       
    92 
       
    93 /**
       
    94  *  Allocates and constructs a CSmsPDU from a TGsmSms.
       
    95  *  
       
    96  *  The type of SMS to construct is determined from the first octet in aGsmSms
       
    97  *  and whether the SMS is mobile terminated.
       
    98  *  
       
    99  *  @param aGsmSms Encoded (raw) GSM SMS PDU
       
   100  *  @param aCharacterSetConverter Character converter utility, required for encoding
       
   101  *  and decoding this PDU
       
   102  *  @param aFs File system handle, required for encoding and decoding this PDU
       
   103  *  @param aIsRPError True if the PDU is part of an RP Error. This is used only
       
   104  *  for SUBMIT REPORT (CSmsSubmitReport) and DELIVER REPORT (CSmsDeliverReport),
       
   105  *  as the format of these PDUs differs depending on whether the PDU is part of
       
   106  *  an RP Ack or RP Error.
       
   107  *  @param aIsMobileTerminated Used to determine (with the first octet in aGsmSms)
       
   108  *  the TSmsPDUType
       
   109  *  @return Newly constructed CSmsPDU-derived object restored from aGsmSms
       
   110  *  @capability None
       
   111  */
       
   112 EXPORT_C CSmsPDU* CSmsPDU::NewL(const TGsmSms& aGsmSms,CCnvCharacterSetConverter& aCharacterSetConverter,RFs& aFs, TBool aIsRPError,TBool aIsMobileTerminated)
       
   113 	{
       
   114 	LOGGSMU3("CSmsPDU::NewL(): aIsRPError=%d, aIsMobileTerminated=%d",
       
   115 			 aIsRPError, aIsMobileTerminated);
       
   116 
       
   117     const TUint8* ptr1=aGsmSms.Pdu().Ptr();
       
   118 
       
   119     TInt mti=*ptr1 & TSmsFirstOctet::ESmsMTIMask; // mask first two bits
       
   120 	CSmsPDU* smspdu=NULL;
       
   121 	switch (mti)
       
   122 		{
       
   123 		case TSmsFirstOctet::ESmsMTIDeliverOrDeliverReport:
       
   124 			{
       
   125 			if (aIsMobileTerminated)
       
   126 				smspdu=new(ELeave) CSmsDeliver();
       
   127 			else
       
   128 				smspdu=new(ELeave) CSmsDeliverReport(aIsRPError);
       
   129 			break;
       
   130 			}
       
   131 		case TSmsFirstOctet::ESmsMTISubmitOrSubmitReport:
       
   132 			{
       
   133 			if (aIsMobileTerminated)
       
   134 				smspdu=new(ELeave) CSmsSubmitReport(aIsRPError);
       
   135 			else
       
   136 				smspdu=new(ELeave) CSmsSubmit();
       
   137 			break;
       
   138 			}
       
   139 		case TSmsFirstOctet::ESmsMTIStatusReportOrCommand:
       
   140 			{
       
   141 			if (aIsMobileTerminated)
       
   142 				smspdu=new(ELeave) CSmsStatusReport();
       
   143 			else
       
   144 				smspdu=new(ELeave) CSmsCommand();
       
   145 			break;
       
   146 			}
       
   147 		default:
       
   148 			User::Leave(KErrNotSupported);
       
   149 		};
       
   150 	CleanupStack::PushL(smspdu);
       
   151 	smspdu->ConstructL(aCharacterSetConverter,aFs);
       
   152 
       
   153 	TGsmuLex8 lex(aGsmSms.Pdu());
       
   154 	smspdu->DecodeL(lex);
       
   155 
       
   156 	// TODO Service centre address should be in rigth format when it comes from TSY
       
   157 	smspdu->SetParsedServiceCenterAddressL(aGsmSms.Sca());
       
   158 
       
   159 	CleanupStack::Pop(smspdu);
       
   160 	return smspdu;
       
   161 	} // CSmsPDU::NewL
       
   162 
       
   163 
       
   164 /**
       
   165  *  Allocates and constructs a CSmsPDU, with the type specified by a TSmsPDUType.
       
   166  *  
       
   167  *  @param aType The PDU type to construct
       
   168  *  @param aCharacterSetConverter Character converter utility, required for encoding
       
   169  *  and decoding this PDU
       
   170  *  @param aFs File system handle, required for encoding and decoding this PDU
       
   171  *  @param aIsRPError True if the PDU is part of an RP Error. This is used only
       
   172  *  for SUBMIT REPORT (CSmsSubmitReport) and DELIVER REPORT (CSmsDeliverReport),
       
   173  *  as the format of these PDUs differs depending on whether the PDU is part of
       
   174  *  an RP Ack or RP Error.
       
   175  *  @return Newly constructed CSmsPDU-derived object
       
   176  *  @capability None
       
   177  */
       
   178 EXPORT_C CSmsPDU* CSmsPDU::NewL(TSmsPDUType aType,CCnvCharacterSetConverter& aCharacterSetConverter,RFs& aFs,TBool aIsRPError)
       
   179 	{
       
   180 	LOGGSMU2("CSmsPDU::NewL(): aIsRPError=%d", aIsRPError);
       
   181 
       
   182 	CSmsPDU* smspdu=NULL;
       
   183 	switch (aType)
       
   184 		{
       
   185 		case ESmsDeliver:
       
   186 			{
       
   187 			smspdu=new(ELeave) CSmsDeliver();
       
   188 			break;
       
   189 			}
       
   190 		case ESmsSubmit:
       
   191 			{
       
   192 			smspdu=new(ELeave) CSmsSubmit();
       
   193 			break;
       
   194 			}
       
   195 		case ESmsDeliverReport:
       
   196 			{
       
   197 			smspdu=new(ELeave) CSmsDeliverReport(aIsRPError);
       
   198 			break;
       
   199 			}
       
   200 		case ESmsSubmitReport:
       
   201 			{
       
   202 			smspdu=new(ELeave) CSmsSubmitReport(aIsRPError);
       
   203 			break;
       
   204 			}
       
   205 		case ESmsStatusReport:
       
   206 			{
       
   207 			smspdu=new(ELeave) CSmsStatusReport();
       
   208 			break;
       
   209 			}
       
   210 		case ESmsCommand:
       
   211 			{
       
   212 			smspdu=new(ELeave) CSmsCommand();
       
   213 			break;
       
   214 			}
       
   215 		default:
       
   216 			User::Leave(KErrNotSupported);
       
   217 		};
       
   218 	CleanupStack::PushL(smspdu);
       
   219 	smspdu->ConstructL(aCharacterSetConverter,aFs);
       
   220 	CleanupStack::Pop();
       
   221 	return smspdu;
       
   222 	} // CSmsPDU::NewL
       
   223 
       
   224 
       
   225 /**
       
   226  *  Allocates and constructs a CSmsPDU as a copy of another CSmsPDU.
       
   227  *  
       
   228  *  @return Newly constructed CSmsPDU-derived object
       
   229  *  @capability None
       
   230  */
       
   231 EXPORT_C CSmsPDU* CSmsPDU::DuplicateL() const
       
   232 	{
       
   233 	LOGGSMU1("CSmsPDU::DuplicateL()");
       
   234 
       
   235 	CSmsPDU*  smsPDU = NULL;
       
   236 
       
   237 	switch (Type())
       
   238 		{
       
   239 		case ESmsDeliver:
       
   240 			{
       
   241 			smsPDU = ((CSmsDeliver*) this)->DuplicateL();
       
   242 			}
       
   243 			break;
       
   244 
       
   245 		case ESmsDeliverReport:
       
   246 			{
       
   247 			smsPDU = ((CSmsDeliverReport*) this)->DuplicateL();
       
   248 			}
       
   249 			break;
       
   250 
       
   251 		case ESmsSubmit:
       
   252 			{
       
   253 			smsPDU = ((CSmsSubmit*) this)->DuplicateL();
       
   254 			}
       
   255 			break;
       
   256 
       
   257 		case ESmsSubmitReport:
       
   258 			{
       
   259 			smsPDU = ((CSmsSubmitReport*) this)->DuplicateL();
       
   260 			}
       
   261 			break;
       
   262 
       
   263 		case ESmsStatusReport:
       
   264 			{
       
   265 			smsPDU = ((CSmsStatusReport*) this)->DuplicateL();
       
   266 			}
       
   267 			break;
       
   268 
       
   269 		case ESmsCommand:
       
   270 			{
       
   271 			smsPDU = ((CSmsCommand*) this)->DuplicateL();
       
   272 			}
       
   273 			break;
       
   274 
       
   275 		default:
       
   276 			{
       
   277 			User::Leave(KErrNotSupported);
       
   278 			}
       
   279 			break;
       
   280 		};
       
   281 
       
   282 	return smsPDU;
       
   283 	} // CSmsPDU::DuplicateL
       
   284 
       
   285 
       
   286 /**
       
   287  *  Externalises the object.
       
   288  *  
       
   289  *  @param aStream Stream to write to
       
   290  *  @capability None
       
   291  */
       
   292 EXPORT_C void CSmsPDU::ExternalizeL(RWriteStream& aStream) const
       
   293 	{
       
   294 	aStream.WriteUint8L(iSmsPDUType);
       
   295 	ExternalizeMessagePDUL(aStream);
       
   296 	} // CSmsPDU::ExternalizeL
       
   297 
       
   298 
       
   299 /**
       
   300  *  Encodes a TGsmSms for the given type of CSmsPDU.
       
   301  *  
       
   302  *  @param aGsmSms On return, encoded GSM SMS PDU
       
   303  *  @capability None
       
   304  */
       
   305 EXPORT_C void CSmsPDU::EncodeMessagePDUL(TGsmSms& aGsmSms) const
       
   306 	{
       
   307 	LOGGSMU1("CSmsPDU::EncodeMessagePDUL()");
       
   308 
       
   309 	NMobileSmsMessaging::TMobileSmsGsmTpdu pdu;
       
   310 	pdu.SetLength(NMobileSmsMessaging::KGsmTpduSize);
       
   311 	TUint8 *ptr1=(TUint8*) pdu.Ptr();
       
   312 	TUint8 *ptr2=ptr1;
       
   313 
       
   314 	TGsmSmsTelNumber parsedAddress;
       
   315 	iServiceCenterAddress->ParsedAddress(parsedAddress);
       
   316 	aGsmSms.SetSca(parsedAddress);
       
   317 
       
   318 	ptr2=EncodeL(ptr1);
       
   319 	pdu.SetLength(ptr2-ptr1);
       
   320 	aGsmSms.SetPdu(pdu);
       
   321 	} // CSmsPDU::EncodeMessagePDUL
       
   322 
       
   323 void CSmsPDU::EncodeMessagePDUL(TGsmSms& aGsmSms, const TEncodeParams* aEncodeParams) const
       
   324 	{
       
   325 	LOGGSMU1("CSmsPDU::EncodeMessagePDUL()");
       
   326 
       
   327 	NMobileSmsMessaging::TMobileSmsGsmTpdu pdu;
       
   328 	pdu.SetLength(NMobileSmsMessaging::KGsmTpduSize);
       
   329 	TUint8 *ptr1=(TUint8*) pdu.Ptr();
       
   330 	TUint8 *ptr2=ptr1;
       
   331 
       
   332 	TGsmSmsTelNumber parsedAddress;
       
   333 	iServiceCenterAddress->ParsedAddress(parsedAddress);
       
   334 	aGsmSms.SetSca(parsedAddress);
       
   335 
       
   336 	ptr2=EncodeL(ptr1, aEncodeParams);
       
   337 	pdu.SetLength(ptr2-ptr1);
       
   338 	aGsmSms.SetPdu(pdu);
       
   339 	} // CSmsPDU::EncodeMessagePDUL	
       
   340 
       
   341 /**
       
   342  *  Gets the service center address.
       
   343  *  
       
   344  *  It is assumed that the address is Unicode, and can contain spaces and alphabetic
       
   345  *  characters.
       
   346  *  
       
   347  *  @return Service center address
       
   348  *  @capability None
       
   349  */
       
   350 EXPORT_C TPtrC CSmsPDU::ServiceCenterAddress() const
       
   351 	{
       
   352 	LOGGSMU1("CSmsPDU::ServiceCenterAddress()");
       
   353 
       
   354 	return iServiceCenterAddress->Address();
       
   355 	} // CSmsPDU::ServiceCenterAddress
       
   356 
       
   357 
       
   358 /**
       
   359  *  Sets the service center address.
       
   360  *  
       
   361  *  A prepended '+' is used to indicate an international number.
       
   362  *  
       
   363  *  @param aAddress Service center address
       
   364  *  @capability None
       
   365  */
       
   366 EXPORT_C void CSmsPDU::SetServiceCenterAddressL(const TDesC& aAddress)
       
   367 	{
       
   368 	LOGGSMU1("CSmsPDU::SetServiceCenterAddressL()");
       
   369 
       
   370 	iServiceCenterAddress->SetAddressL(aAddress);
       
   371 	} // CSmsPDU::SetServiceCenterAddressL
       
   372 
       
   373 
       
   374 /**
       
   375  *  Gets the service center address in a TGsmSmsTelNumber object.
       
   376  *  
       
   377  *  A prepended '+', spaces and aphabetic characters are removed.
       
   378  *  
       
   379  *  @param aParsedAddress Service center address
       
   380  *  @capability None
       
   381  */
       
   382 EXPORT_C void CSmsPDU::ParsedServiceCenterAddress(TGsmSmsTelNumber& aParsedAddress) const
       
   383 	{
       
   384 	LOGGSMU1("CSmsPDU::ParsedServiceCenterAddress()");
       
   385 
       
   386 	iServiceCenterAddress->ParsedAddress(aParsedAddress);
       
   387 	} // CSmsPDU::ParsedServiceCenterAddress
       
   388 
       
   389 
       
   390 /**
       
   391  *  Sets the service center address through a TGsmSmsTelNumber object.
       
   392  *  
       
   393  *  These functions panic for a DELIVER REPORT (CSmsDeliverReport) or a SUBMIT REPORT (CSmsSubmitReport).
       
   394  *  
       
   395  *  @param aParsedAddress Service center address
       
   396  *  @capability None
       
   397  */
       
   398 EXPORT_C void CSmsPDU::SetParsedServiceCenterAddressL(const TGsmSmsTelNumber& aParsedAddress)
       
   399 	{
       
   400 	LOGGSMU1("CSmsPDU::SetParsedServiceCenterAddressL()");
       
   401 
       
   402 	iServiceCenterAddress->SetParsedAddressL(aParsedAddress);
       
   403 	} // CSmsPDU::SetParsedServiceCenterAddressL
       
   404 
       
   405 
       
   406 /**
       
   407  *  Gets the "to from" address.
       
   408  *  
       
   409  *  This address is the original (sender's) address for a DELIVER (CSmsDeliver),
       
   410  *  the destination address for a SUBMIT (CSmsSubmit), the recipient (sender's)
       
   411  *  address for a STATUS REPORT (CSmsStatusReport) and the destination address
       
   412  *  for a COMMAND (CSmsCommand).
       
   413  *  
       
   414  *  The function panics for a DELIVER REPORT (CSmsDeliverReport) or a SUBMIT REPORT
       
   415  *  (CSmsSubmitReport).
       
   416  *  
       
   417  *  It is assumed that the address is Unicode, and can contain spaces and alphabetic
       
   418  *  characters.
       
   419  *  
       
   420  *  @return The destination or sender address
       
   421  *  @capability None
       
   422  */
       
   423 EXPORT_C TPtrC CSmsPDU::ToFromAddress() const
       
   424 	{
       
   425 	LOGGSMU1("CSmsPDU::SetParsedServiceCenterAddressL()");
       
   426 
       
   427 	if (ToFromAddressPtr() == NULL)
       
   428 		{
       
   429 		return TPtrC(KNullDesC16);
       
   430 		}
       
   431 
       
   432 	return ToFromAddressPtr()->Address();
       
   433 	} // CSmsPDU::ToFromAddress
       
   434 
       
   435 
       
   436 /**
       
   437  *  Sets the "to from" address.
       
   438  *  
       
   439  *  The function panics for a DELIVER REPORT (CSmsDeliverReport) or a SUBMIT REPORT
       
   440  *  (CSmsSubmitReport).
       
   441  *  
       
   442  *  A prepended '+' is used to indicate an international number.
       
   443  *  
       
   444  *  @param aAddress The destination or sender address
       
   445  *  @capability None
       
   446  */
       
   447 EXPORT_C void CSmsPDU::SetToFromAddressL(const TDesC& aAddress)
       
   448 	{
       
   449 	LOGGSMU1("CSmsPDU::SetToFromAddressL()");
       
   450 
       
   451 	__ASSERT_DEBUG(ToFromAddressPtr()!=NULL,Panic(KGsmuPanicToFromAddressNotPresent));
       
   452 	CSmsAddress* tofromaddress=(CSmsAddress*) ToFromAddressPtr();
       
   453 	tofromaddress->SetAddressL(aAddress);
       
   454 	} // CSmsPDU::SetToFromAddressL
       
   455 
       
   456 
       
   457 /**
       
   458  *  Gets the "to from" in a TGsmSmsTelNumber object.
       
   459  *  
       
   460  *  A prepended '+', spaces and aphabetic characters are removed.
       
   461  *  
       
   462  *  @param aParsedAddress The destination or sender address
       
   463  *  @capability None
       
   464  */
       
   465 EXPORT_C void CSmsPDU::ParsedToFromAddress(TGsmSmsTelNumber& aParsedAddress) const
       
   466 	{
       
   467 	LOGGSMU1("CSmsPDU::ParsedToFromAddress()");
       
   468 
       
   469 	__ASSERT_DEBUG(ToFromAddressPtr()!=NULL,Panic(KGsmuPanicToFromAddressNotPresent));
       
   470 	ToFromAddressPtr()->ParsedAddress(aParsedAddress);
       
   471 	} // CSmsPDU::ParsedToFromAddress
       
   472 
       
   473 
       
   474 /**
       
   475  *  Sets the "to from" with a TGsmSmsTelNumber object.
       
   476  *  
       
   477  *  @param aParsedAddress The destination or sender address
       
   478  *  @capability None
       
   479  */
       
   480 EXPORT_C void CSmsPDU::SetParsedToFromAddressL(const TGsmSmsTelNumber& aParsedAddress)
       
   481 	{
       
   482 	LOGGSMU1("CSmsPDU::SetParsedToFromAddressL()");
       
   483 
       
   484 	__ASSERT_DEBUG(ToFromAddressPtr()!=NULL,Panic(KGsmuPanicToFromAddressNotPresent));
       
   485 	CSmsAddress* tofromaddress=(CSmsAddress*) ToFromAddressPtr();
       
   486 	tofromaddress->SetParsedAddressL(aParsedAddress);
       
   487 	} // CSmsPDU::SetParsedToFromAddressL
       
   488 
       
   489 
       
   490 //
       
   491 //  TODO move this to the DCS descriptions
       
   492 //  Also, the functions available are dependant on bits 7 to 4 in the data coding scheme.
       
   493 //  Functions panic when they are not available.
       
   494 //  This requires the caller to have some knowledge of ETSI GSM 03.38 in order to keep the data coding scheme in a consistent state.
       
   495 //
       
   496 /**
       
   497  *  Updates the three pieces of concatenation data (reference number,
       
   498  *  pdu index and max pdu number) in this PDU.
       
   499  * 
       
   500  *  @param aRef       Reference number.
       
   501  *  @param aPduIndex  Current PDU number.
       
   502  *  @param aMaxPdu    Total PDU number.
       
   503  */
       
   504 void CSmsPDU::UpdateConcatenationDataL(TInt aRef, TInt aPduIndex, TInt aMaxPdu)
       
   505 	{
       
   506 	LOGGSMU1("CSmsPDU::UpdateConcatenationDataL()");
       
   507 
       
   508 	SetConcatenatedMessageReference(aRef);
       
   509 	SetConcatenatedMessagePDUIndex(aPduIndex);
       
   510 	SetNumConcatenatedMessagePDUs(aMaxPdu);
       
   511 	} // CSmsPDU::UpdateConcatenationDataL
       
   512 
       
   513 
       
   514 /**
       
   515  *  Updates the email header data in this PDU.
       
   516  * 
       
   517  *  @param aEmailOverallHeaderLength  Length of the email header.
       
   518  */
       
   519 void CSmsPDU::UpdateEmailHeaderDataL(TInt& aEmailOverallHeaderLength)
       
   520 	{
       
   521 	LOGGSMU1("CSmsPDU::UpdateEmailHeaderDataL()");
       
   522 
       
   523 	TInt emailIndex(0);
       
   524 	TInt udLength=0;
       
   525 	TInt headerPortionLength=0;
       
   526 	if(UserData().InformationElementIndex(CSmsInformationElement::ESmsIEIRFC822EmailHeader,emailIndex))
       
   527 		{
       
   528 		if(aEmailOverallHeaderLength<=0)
       
   529 			headerPortionLength=0;
       
   530 		else
       
   531 			{
       
   532 			udLength=UserData().Body().Length();
       
   533 			if(Alphabet() == TSmsDataCodingScheme::ESmsAlphabetUCS2)
       
   534 				udLength/=2;
       
   535 			if(aEmailOverallHeaderLength>=udLength)
       
   536 				headerPortionLength=udLength;
       
   537 			else
       
   538 				headerPortionLength=aEmailOverallHeaderLength;
       
   539 			aEmailOverallHeaderLength-=udLength;
       
   540 			}
       
   541 		UserData().InformationElement(emailIndex).Data()[0]=static_cast<TUint8>(headerPortionLength);
       
   542 		}
       
   543 	else
       
   544 		User::Leave(KErrCorrupt);
       
   545 	} // CSmsPDU::UpdateEmailHeaderDataL
       
   546 
       
   547 	
       
   548 /**
       
   549  *  Updates the SMSC control parameter in this PDU.
       
   550  * 
       
   551  *  @param aOctet  Value to store in the SMSC control parameter.
       
   552  */
       
   553 TBool CSmsPDU::UpdateSMSCCtrlParameterL(const TUint8 aOctet)
       
   554 	{
       
   555 	TInt smscIndex(0);
       
   556 	if(UserData().InformationElementIndex(CSmsInformationElement::ESmsIEISMSCControlParameters,smscIndex))
       
   557 		{
       
   558 		UserData().InformationElement(smscIndex).Data()[0] = aOctet;
       
   559 		if (Type() == ESmsSubmit)
       
   560 			{
       
   561 			CSmsSubmit* smsSubmit = (CSmsSubmit*)this;
       
   562 			smsSubmit->SetStatusReportRequest(ETrue);	
       
   563 			}
       
   564 		else if (Type() == ESmsDeliver)
       
   565 			{
       
   566 			CSmsDeliver* smsDeliver = (CSmsDeliver*)this;
       
   567 			smsDeliver->SetStatusReportIndication(ETrue);
       
   568 			}
       
   569 		}
       
   570 	else
       
   571 		{
       
   572 		User::Leave(KErrCorrupt);	
       
   573 		} 
       
   574 
       
   575 	return ETrue;
       
   576 	} // CSmsPDU::UpdateSMSCCtrlParameterL
       
   577 
       
   578 	
       
   579 /**
       
   580  *  Updates the TPSRRL control parameter in this PDU.
       
   581  * 
       
   582  *  @param aSmsReportRequest  Status Report Request setting.
       
   583  * 
       
   584  *  @return  Always returns ETrue.
       
   585  */
       
   586 TBool CSmsPDU::UpdateTPSRRL(TSmsFirstOctet aSmsReportRequest)
       
   587 	{
       
   588 	if (Type() == ESmsSubmit)
       
   589 		{
       
   590 		CSmsSubmit* smsSubmit = (CSmsSubmit*)this;
       
   591 		if (aSmsReportRequest)
       
   592 			{
       
   593 			smsSubmit->SetStatusReportRequest(ETrue);
       
   594 			}
       
   595 		else
       
   596 			{
       
   597 			smsSubmit->SetStatusReportRequest(EFalse);	
       
   598 			}
       
   599 		}
       
   600 	else if (Type() == ESmsDeliver)
       
   601 			{
       
   602 			CSmsDeliver* smsDeliver = (CSmsDeliver*)this;
       
   603 			if (aSmsReportRequest)
       
   604 				{
       
   605 				smsDeliver->SetStatusReportIndication(ETrue);
       
   606 				}
       
   607 			else
       
   608 				{
       
   609 				smsDeliver->SetStatusReportIndication(EFalse);	
       
   610 				}
       
   611 			}
       
   612 	
       
   613 	return ETrue;
       
   614 	} // CSmsPDU::UpdateTPSRRL
       
   615 
       
   616 
       
   617 EXPORT_C TSmsEncoding CSmsPDU::NationalLanguageEncoding() const
       
   618 	{
       
   619 	LOGGSMU1("CSmsPDU::NationalLanguageEncoding()");
       
   620 	
       
   621 	TSmsEncoding  encodingUsed = ESmsEncodingNone;
       
   622 	
       
   623 	//
       
   624 	// Only valid in 7bit...
       
   625 	//
       
   626 	if (Alphabet() != TSmsDataCodingScheme::ESmsAlphabet7Bit)
       
   627 		{
       
   628 		return ESmsEncodingNone;
       
   629 		}
       
   630 	
       
   631 	//
       
   632 	// Get the locking shift setting...
       
   633 	//
       
   634 	TInt  lockingIndex = 0;
       
   635 	TSmsNationalLanguageIdentifier  lockingShiftValue  = (TSmsNationalLanguageIdentifier) 0;
       
   636 	
       
   637 	if (UserData().InformationElementLastIndex(CSmsInformationElement::ESmsNationalLanguageLockingShift, lockingIndex))
       
   638 		{
       
   639 		lockingShiftValue = (TSmsNationalLanguageIdentifier) UserData().InformationElement(lockingIndex).Data()[0];
       
   640 		
       
   641 		//
       
   642 		// Store the locking shift value. We will combine this with the single
       
   643 		// shift value later.
       
   644 		//
       
   645 		switch (lockingShiftValue)
       
   646 			{
       
   647 			case ESmsNationalLanguageIdentifierTurkish:
       
   648 				{
       
   649 				encodingUsed = ESmsEncodingTurkishLockingShift;
       
   650 				}
       
   651 				break;
       
   652 
       
   653 			case ESmsNationalLanguageIdentifierPortuguese:
       
   654 				{
       
   655 				encodingUsed = ESmsEncodingPortugueseLockingShift;
       
   656 				}
       
   657 				break;
       
   658 
       
   659 			default:
       
   660 				{
       
   661 				//
       
   662 				// Invalid or not understood, so ignore it!
       
   663 				//
       
   664 				}
       
   665 			};
       
   666 		}
       
   667 	
       
   668 	//
       
   669 	// Get the single shift setting...
       
   670 	//
       
   671 	TInt  singleIndex = 0;
       
   672 	TSmsNationalLanguageIdentifier  singleShiftValue  = (TSmsNationalLanguageIdentifier) 0;
       
   673 	
       
   674 	if (UserData().InformationElementLastIndex(CSmsInformationElement::ESmsNationalLanguageSingleShift, singleIndex))
       
   675 		{
       
   676 		singleShiftValue = (TSmsNationalLanguageIdentifier) UserData().InformationElement(singleIndex).Data()[0];
       
   677 		
       
   678 		//
       
   679 		// Combine the single shift value into the encoding setting. If any
       
   680 		// single shift does not match an accepted locking shift, then it is
       
   681 		// ignored as the locking table has more value.
       
   682 		//
       
   683 		switch (singleShiftValue)
       
   684 			{
       
   685 			case ESmsNationalLanguageIdentifierTurkish:
       
   686 				{
       
   687 				if (encodingUsed == ESmsEncodingNone)
       
   688 					{
       
   689 					encodingUsed = ESmsEncodingTurkishSingleShift;
       
   690 					}
       
   691 				else if (encodingUsed == ESmsEncodingTurkishLockingShift)
       
   692 					{
       
   693 					encodingUsed = ESmsEncodingTurkishLockingAndSingleShift;
       
   694 					}
       
   695 				}
       
   696 				break;
       
   697 
       
   698 			case ESmsNationalLanguageIdentifierSpanish:
       
   699 				{
       
   700 				if (encodingUsed == ESmsEncodingNone)
       
   701 					{
       
   702 					encodingUsed = ESmsEncodingSpanishSingleShift;
       
   703 					}
       
   704 				}
       
   705 				break;
       
   706 
       
   707 			case ESmsNationalLanguageIdentifierPortuguese:
       
   708 				{
       
   709 				if (encodingUsed == ESmsEncodingNone)
       
   710 					{
       
   711 					encodingUsed = ESmsEncodingPortugueseSingleShift;
       
   712 					}
       
   713 				else if (encodingUsed == ESmsEncodingPortugueseLockingShift)
       
   714 					{
       
   715 					encodingUsed = ESmsEncodingPortugueseLockingAndSingleShift;
       
   716 					}
       
   717 				}
       
   718 				break;
       
   719 
       
   720 			default:
       
   721 				{
       
   722 				//
       
   723 				// Invalid or not understood, so ignore it!
       
   724 				//
       
   725 				}
       
   726 			};
       
   727 		}
       
   728 	
       
   729 	LOGGSMU2("CSmsPDU::NationalLanguageEncoding(): lockingShift=%d", lockingShiftValue);
       
   730 	LOGGSMU2("CSmsPDU::NationalLanguageEncoding(): singleShift=%d", singleShiftValue);
       
   731 	LOGGSMU2("CSmsPDU::NationalLanguageEncoding(): encodingUsed=%d", encodingUsed);
       
   732 	
       
   733 	return encodingUsed;
       
   734 	} // CSmsPDU::NationalLanguageEncoding
       
   735 
       
   736 
       
   737 EXPORT_C void CSmsPDU::SetNationalLanguageEncodingL(TSmsEncoding aEncoding)
       
   738 	{
       
   739 	LOGGSMU2("CSmsPDU::SetNationalLanguageEncodingL(): aEncoding=%d", aEncoding);
       
   740 	
       
   741 	//
       
   742 	// Convert the encoding enum into two parts: Single Shift and Locking Shift
       
   743 	//
       
   744 	TSmsNationalLanguageIdentifier  lockingShiftValue = (TSmsNationalLanguageIdentifier) 0;
       
   745 	TSmsNationalLanguageIdentifier  singleShiftValue  = (TSmsNationalLanguageIdentifier) 0;
       
   746 	TBool  lockingIERequired = EFalse;
       
   747 	TBool  singleIERequired = EFalse;
       
   748 
       
   749 	switch (aEncoding)
       
   750 		{
       
   751 		case ESmsEncodingNone:
       
   752 			{
       
   753 			// Nothing to set.
       
   754 			}
       
   755 			break;
       
   756 		
       
   757 		case ESmsEncodingTurkishSingleShift:
       
   758 			{
       
   759 			singleShiftValue = ESmsNationalLanguageIdentifierTurkish;
       
   760 			singleIERequired = ETrue;
       
   761 			}
       
   762 			break;
       
   763 		
       
   764 		case ESmsEncodingTurkishLockingShift:
       
   765 			{
       
   766 			lockingShiftValue = ESmsNationalLanguageIdentifierTurkish;
       
   767 			lockingIERequired = ETrue;
       
   768 			}
       
   769 			break;
       
   770 		
       
   771 		case ESmsEncodingTurkishLockingAndSingleShift:
       
   772 			{
       
   773 			lockingShiftValue = ESmsNationalLanguageIdentifierTurkish;
       
   774 			singleShiftValue  = ESmsNationalLanguageIdentifierTurkish;
       
   775 			lockingIERequired = ETrue;
       
   776 			singleIERequired  = ETrue;
       
   777 			}
       
   778 			break;
       
   779 		
       
   780 		case ESmsEncodingSpanishSingleShift:
       
   781 			{
       
   782 			singleShiftValue = ESmsNationalLanguageIdentifierSpanish;
       
   783 			singleIERequired = ETrue;
       
   784 			}
       
   785 			break;
       
   786 		
       
   787 		case ESmsEncodingPortugueseSingleShift:
       
   788 			{
       
   789 			singleShiftValue = ESmsNationalLanguageIdentifierPortuguese;
       
   790 			singleIERequired = ETrue;
       
   791 			}
       
   792 			break;
       
   793 		
       
   794 		case ESmsEncodingPortugueseLockingShift:
       
   795 			{
       
   796 			lockingShiftValue = ESmsNationalLanguageIdentifierPortuguese;
       
   797 			lockingIERequired = ETrue;
       
   798 			}
       
   799 			break;
       
   800 		
       
   801 		case ESmsEncodingPortugueseLockingAndSingleShift:
       
   802 			{
       
   803 			lockingShiftValue = ESmsNationalLanguageIdentifierPortuguese;
       
   804 			singleShiftValue  = ESmsNationalLanguageIdentifierPortuguese;
       
   805 			lockingIERequired = ETrue;
       
   806 			singleIERequired  = ETrue;
       
   807 			}
       
   808 			break;
       
   809 
       
   810 		default:
       
   811 			{
       
   812 			//
       
   813 			// Invalid encoder method!
       
   814 			//
       
   815 			User::Leave(KErrArgument);
       
   816 			}
       
   817 		};
       
   818 	
       
   819 	LOGGSMU2("CSmsPDU::SetNationalLanguageEncodingL(): lockingShift=%d", lockingShiftValue);
       
   820 	LOGGSMU2("CSmsPDU::SetNationalLanguageEncodingL(): singleShift=%d", singleShiftValue);
       
   821 	
       
   822 	//
       
   823 	// Update the locking shift setting...
       
   824 	//
       
   825 	TInt  lockingIndex = 0;
       
   826 	TBool  lockingExists = UserData().InformationElementIndex(
       
   827 							CSmsInformationElement::ESmsNationalLanguageLockingShift, lockingIndex);
       
   828 	
       
   829 	if (lockingExists)
       
   830 		{
       
   831 		if (lockingIERequired)
       
   832 			{
       
   833 			// Update the IE...
       
   834 			UserData().InformationElement(lockingIndex).Data()[0] = (TUint8) lockingShiftValue;
       
   835 			}
       
   836 		else
       
   837 			{
       
   838 			// Remove the element as it is not needed...
       
   839 			UserData().RemoveInformationElement(lockingIndex);
       
   840 			}
       
   841 		}
       
   842 	else
       
   843 		{
       
   844 		if (lockingIERequired)
       
   845 			{
       
   846 			// Add the IE...
       
   847 			TBuf8<1> data;
       
   848 			data.SetLength(1);
       
   849 			data[0] = lockingShiftValue;
       
   850 			UserData().AddInformationElementL(CSmsInformationElement::ESmsNationalLanguageLockingShift, data);
       
   851 			}
       
   852 		else
       
   853 			{
       
   854 			// Nothing to do!
       
   855 			}
       
   856 		}
       
   857 
       
   858 	//
       
   859 	// Update the single shift setting...
       
   860 	//
       
   861 	TInt  singleIndex = 0;
       
   862 	TBool  singleExists = UserData().InformationElementIndex(
       
   863 							CSmsInformationElement::ESmsNationalLanguageSingleShift, singleIndex);
       
   864 	
       
   865 	if (singleExists)
       
   866 		{
       
   867 		if (singleIERequired)
       
   868 			{
       
   869 			// Update the IE...
       
   870 			UserData().InformationElement(singleIndex).Data()[0] = (TUint8) singleShiftValue;
       
   871 			}
       
   872 		else
       
   873 			{
       
   874 			// Remove the element as it is not needed...
       
   875 			UserData().RemoveInformationElement(singleIndex);
       
   876 			}
       
   877 		}
       
   878 	else
       
   879 		{
       
   880 		if (singleIERequired)
       
   881 			{
       
   882 			// Add the IE...
       
   883 			TBuf8<1> data;
       
   884 			data.SetLength(1);
       
   885 			data[0] = singleShiftValue;
       
   886 			UserData().AddInformationElementL(CSmsInformationElement::ESmsNationalLanguageSingleShift, data);
       
   887 			}
       
   888 		else
       
   889 			{
       
   890 			// Nothing to do!
       
   891 			}
       
   892 		}
       
   893 	} // CSmsPDU::SetNationalLanguageEncodingL
       
   894 
       
   895 
       
   896 /**
       
   897  *  Gets bits 7 to 4 on the data coding scheme.
       
   898  *  
       
   899  *  The value of bits 7 to 4 effects the meaning of the lower order bits.
       
   900  *  
       
   901  *  The function panics if the data coding scheme is not present.
       
   902  *  
       
   903  *  @return Bits 7 to 4
       
   904  *  @capability None
       
   905  */
       
   906 EXPORT_C TSmsDataCodingScheme::TSmsDCSBits7To4 CSmsPDU::Bits7To4() const
       
   907 	{
       
   908 	LOGGSMU1("CSmsPDU::Bits7To4()");
       
   909 
       
   910 	__ASSERT_DEBUG(DataCodingScheme()!=NULL,Panic(KGsmuPanicDataCodingSchemeNotPresent));
       
   911 
       
   912 	return DataCodingScheme()->Bits7To4();
       
   913 	} // TSmsDataCodingScheme::TSmsDCSBits7To4
       
   914 
       
   915 
       
   916 /**
       
   917  *  Sets key bits 7 to 4 of the data coding scheme.
       
   918  *  
       
   919  *  This is designed to be used for message waiting indication, as it is not needed
       
   920  *  for the normal type of data coding scheme where the alphabet and class are
       
   921  *  defined in the lower order bits.
       
   922  *  
       
   923  *  The function panics if the data coding scheme is not present.
       
   924  *  
       
   925  *  @param aBits7To4 Bits 7 to 4
       
   926  *  @capability None
       
   927  */
       
   928 EXPORT_C void CSmsPDU::SetBits7To4(TSmsDataCodingScheme::TSmsDCSBits7To4 aBits7To4)
       
   929 	{
       
   930 	LOGGSMU1("CSmsPDU::SetBits7To4()");
       
   931 
       
   932 	__ASSERT_DEBUG(DataCodingScheme()!=NULL,Panic(KGsmuPanicDataCodingSchemeNotPresent));
       
   933 	TSmsDataCodingScheme* datacodingscheme=(TSmsDataCodingScheme*) DataCodingScheme();
       
   934 	datacodingscheme->SetBits7To4(aBits7To4);
       
   935 	} // CSmsPDU::SetBits7To4
       
   936 
       
   937 
       
   938 /**
       
   939  *  Gets the alphabet encoded in the data coding scheme.
       
   940  *  
       
   941  *  The function panics if the data coding scheme is not present.
       
   942  *  
       
   943  *  @return Alphabet
       
   944  *  @capability None
       
   945  */
       
   946 EXPORT_C TSmsDataCodingScheme::TSmsAlphabet CSmsPDU::Alphabet() const
       
   947 	{
       
   948 	LOGGSMU1("CSmsPDU::Alphabet()");
       
   949 
       
   950 	__ASSERT_DEBUG(DataCodingScheme()!=NULL,Panic(KGsmuPanicDataCodingSchemeNotPresent));
       
   951 	return DataCodingScheme()->Alphabet();
       
   952 	} // TSmsDataCodingScheme::TSmsAlphabet
       
   953 
       
   954 
       
   955 /**
       
   956  *  Sets the alphabet encoded in the data coding scheme.
       
   957  *  
       
   958  *  The function panics if the data coding scheme is not present.
       
   959  *  
       
   960  *  @param aAlphabet Alphabet
       
   961  *  @capability None
       
   962  */
       
   963 EXPORT_C void CSmsPDU::SetAlphabet(TSmsDataCodingScheme::TSmsAlphabet aAlphabet)
       
   964 	{
       
   965 	LOGGSMU1("CSmsPDU::SetAlphabet()");
       
   966 
       
   967 	__ASSERT_DEBUG(DataCodingScheme()!=NULL,Panic(KGsmuPanicDataCodingSchemeNotPresent));
       
   968 	TSmsDataCodingScheme* datacodingscheme=(TSmsDataCodingScheme*) DataCodingScheme();
       
   969 	datacodingscheme->SetAlphabet(aAlphabet);
       
   970 	} // CSmsPDU::SetAlphabet
       
   971 
       
   972 
       
   973 /**
       
   974  *  Gets the GSM SMS PDU class in the data coding scheme.
       
   975  *  
       
   976  *  The function panics if the data coding scheme is not present.
       
   977  *  
       
   978  *  @param aClass Sms class 0 - 3 encoded in the data coding scheme
       
   979  *  @return True if SMS class is defined, else false
       
   980  *  @capability None
       
   981  */
       
   982 EXPORT_C TBool CSmsPDU::Class(TSmsDataCodingScheme::TSmsClass& aClass) const
       
   983 	{
       
   984 	LOGGSMU1("CSmsPDU::Class()");
       
   985 
       
   986 	__ASSERT_DEBUG(DataCodingScheme()!=NULL,Panic(KGsmuPanicDataCodingSchemeNotPresent));
       
   987 	return DataCodingScheme()->Class(aClass);
       
   988 	} // CSmsPDU::Class
       
   989 
       
   990 
       
   991 /**
       
   992  *  Sets the GSM SMS PDU class in the data coding scheme.
       
   993  *  
       
   994  *  The function panics if the data coding scheme is not present.
       
   995  *  
       
   996  *  @param aClassDefined True if SMS class is defined, else false
       
   997  *  @param aClass Sms class 0 - 3 encoded in the data coding scheme
       
   998  *  @capability None
       
   999  */
       
  1000 EXPORT_C void CSmsPDU::SetClass(TBool aClassDefined,TSmsDataCodingScheme::TSmsClass aClass)
       
  1001 	{
       
  1002 	LOGGSMU1("CSmsPDU::SetClass()");
       
  1003 
       
  1004 	__ASSERT_DEBUG(DataCodingScheme()!=NULL,Panic(KGsmuPanicDataCodingSchemeNotPresent));
       
  1005 	TSmsDataCodingScheme* datacodingscheme=(TSmsDataCodingScheme*) DataCodingScheme();
       
  1006 	datacodingscheme->SetClass(aClassDefined,aClass);
       
  1007 	} // CSmsPDU::SetClass
       
  1008 
       
  1009 
       
  1010 /**
       
  1011  *  True if Text Compressed is encoded in the data coding scheme.
       
  1012  *  
       
  1013  *  The function panics if the data coding scheme is not present.
       
  1014  *  
       
  1015  *  @return True if Text Compressed is encoded
       
  1016  *  @capability None
       
  1017  */
       
  1018 EXPORT_C TBool CSmsPDU::TextCompressed() const
       
  1019 	{
       
  1020 	LOGGSMU1("CSmsPDU::TextCompressed()");
       
  1021 
       
  1022 	__ASSERT_DEBUG(DataCodingScheme()!=NULL,Panic(KGsmuPanicDataCodingSchemeNotPresent));
       
  1023 	return DataCodingScheme()->TextCompressed();
       
  1024 	} // CSmsPDU::TextCompressed
       
  1025 
       
  1026 
       
  1027 /**
       
  1028  *  Set to encode Text Compressed in the data coding scheme.
       
  1029  *  
       
  1030  *  The function panics if the data coding scheme is not present.
       
  1031  *  
       
  1032  *  @param aCompressed True to encode Text Compressed
       
  1033  *  @capability None
       
  1034  */
       
  1035 EXPORT_C void CSmsPDU::SetTextCompressed(TBool aCompressed)
       
  1036 	{
       
  1037 	LOGGSMU1("CSmsPDU::SetTextCompressed()");
       
  1038 
       
  1039 	__ASSERT_DEBUG(DataCodingScheme()!=NULL,Panic(KGsmuPanicDataCodingSchemeNotPresent));
       
  1040 	TSmsDataCodingScheme* datacodingscheme=(TSmsDataCodingScheme*) DataCodingScheme();
       
  1041 	datacodingscheme->SetTextCompressed(aCompressed);
       
  1042 	} // CSmsPDU::SetTextCompressed
       
  1043 
       
  1044 
       
  1045 /**
       
  1046  *  Gets the Indication State encoded in the data coding scheme.
       
  1047  *  
       
  1048  *  The function panics if the data coding scheme is not present.
       
  1049  *  
       
  1050  *  @return Indication State
       
  1051  *  @capability None
       
  1052  */
       
  1053 EXPORT_C TSmsDataCodingScheme::TSmsIndicationState CSmsPDU::IndicationState() const
       
  1054 	{
       
  1055 	LOGGSMU1("CSmsPDU::IndicationState()");
       
  1056 
       
  1057 	__ASSERT_DEBUG(DataCodingScheme()!=NULL,Panic(KGsmuPanicDataCodingSchemeNotPresent));
       
  1058 	return DataCodingScheme()->IndicationState();
       
  1059 	} // TSmsDataCodingScheme::TSmsIndicationState
       
  1060 
       
  1061 
       
  1062 /**
       
  1063  *  Sets the Indication State encoded in the data coding scheme.
       
  1064  *  
       
  1065  *  The function panics if the data coding scheme is not present.
       
  1066  *  
       
  1067  *  @param aState Indication State
       
  1068  *  @capability None
       
  1069  */
       
  1070 EXPORT_C void CSmsPDU::SetIndicationState(TSmsDataCodingScheme::TSmsIndicationState aState)
       
  1071 	{
       
  1072 	LOGGSMU1("CSmsPDU::SetIndicationState()");
       
  1073 
       
  1074 	__ASSERT_DEBUG(DataCodingScheme()!=NULL,Panic(KGsmuPanicDataCodingSchemeNotPresent));
       
  1075 	TSmsDataCodingScheme* datacodingscheme=(TSmsDataCodingScheme*) DataCodingScheme();
       
  1076 	datacodingscheme->SetIndicationState(aState);
       
  1077 	} // CSmsPDU::SetIndicationState
       
  1078 
       
  1079 
       
  1080 /**
       
  1081  *  Gets the Indication Type encoded in the data coding scheme.
       
  1082  *  
       
  1083  *  The function panics if the data coding scheme is not present.
       
  1084  *  
       
  1085  *  @return Indication Type
       
  1086  *  @capability None
       
  1087  */
       
  1088 EXPORT_C TSmsDataCodingScheme::TSmsIndicationType CSmsPDU::IndicationType() const
       
  1089 	{
       
  1090 	LOGGSMU1("CSmsPDU::IndicationType()");
       
  1091 
       
  1092 	__ASSERT_DEBUG(DataCodingScheme()!=NULL,Panic(KGsmuPanicDataCodingSchemeNotPresent));
       
  1093 	return DataCodingScheme()->IndicationType();
       
  1094 	} // TSmsDataCodingScheme::TSmsIndicationType
       
  1095 
       
  1096 
       
  1097 /**
       
  1098  *  Sets the Indication Type encoded in the data coding scheme.
       
  1099  *  
       
  1100  *  The function panics if the data coding scheme is not present.
       
  1101  *  
       
  1102  *  @param aType Indication Type
       
  1103  *  @capability None
       
  1104  */
       
  1105 EXPORT_C void CSmsPDU::SetIndicationType(TSmsDataCodingScheme::TSmsIndicationType aType)
       
  1106 	{
       
  1107 	LOGGSMU1("CSmsPDU::SetIndicationType()");
       
  1108 
       
  1109 	__ASSERT_DEBUG(DataCodingScheme()!=NULL,Panic(KGsmuPanicDataCodingSchemeNotPresent));
       
  1110 	TSmsDataCodingScheme* datacodingscheme=(TSmsDataCodingScheme*) DataCodingScheme();
       
  1111 	datacodingscheme->SetIndicationType(aType);
       
  1112 	} // CSmsPDU::SetIndicationType
       
  1113 
       
  1114 
       
  1115 /**
       
  1116  *  Tests if the PDU is part of a concatenated message.
       
  1117  *  
       
  1118  *  @param aIs16Bit Content is set true if Concatenation Information Element is
       
  1119  *  16-bit. Default is null.
       
  1120  *  @return True if the PDU is part of a concatenated message.
       
  1121  *  @capability None
       
  1122  */
       
  1123 EXPORT_C TBool CSmsPDU::TextConcatenated(TBool* aIs16Bit) const
       
  1124 	{
       
  1125 	LOGGSMU1("CSmsPDU::TextConcatenated()");
       
  1126 
       
  1127 	TInt index;
       
  1128 	return DoTextConcatenated(index,aIs16Bit);
       
  1129 	} // CSmsPDU::TextConcatenated
       
  1130 
       
  1131 
       
  1132 /**
       
  1133  *  Sets whether the PDU is part of a concatenated message or not.
       
  1134  *  
       
  1135  *  It is a leaving function as it is inserting an information element into the
       
  1136  *  user data.
       
  1137  *  
       
  1138  *  @param aConcatenated True if message is concatenated
       
  1139  *  @param aIs16Bit True if type of Concatenation Information Element is 16 bit
       
  1140  *  @capability None
       
  1141  */
       
  1142 EXPORT_C void CSmsPDU::SetTextConcatenatedL(TBool aConcatenated,TBool aIs16Bit)
       
  1143 	{
       
  1144 	LOGGSMU1("CSmsPDU::SetTextConcatenatedL()");
       
  1145 
       
  1146 	TInt index=0;
       
  1147 	TInt is16bit;
       
  1148 	TBool textconcatenated=DoTextConcatenated(index,&is16bit);
       
  1149 	if (aConcatenated)
       
  1150 		{
       
  1151 		if (!textconcatenated)
       
  1152 			{
       
  1153 			DoSetTextConcatenatedL(aIs16Bit);
       
  1154 			}
       
  1155 		else
       
  1156 			{
       
  1157 			if (((!aIs16Bit) && (is16bit)) || (aIs16Bit && (!is16bit)))
       
  1158 				{
       
  1159 				UserData().RemoveInformationElement(index);
       
  1160 				DoSetTextConcatenatedL(aIs16Bit);
       
  1161 				}
       
  1162 			}
       
  1163 		}
       
  1164 	else
       
  1165 		{
       
  1166 		if (textconcatenated)
       
  1167 			{
       
  1168 			UserData().RemoveInformationElement(index);
       
  1169 			}
       
  1170 		}
       
  1171 	} // CSmsPDU::SetTextConcatenatedL
       
  1172 
       
  1173 
       
  1174 /**
       
  1175  *  Gets the reference contained in the Concatenation Information Element.
       
  1176  *  
       
  1177  *  @return Reference contained in the Concatenation Information Element
       
  1178  *  @capability None
       
  1179  */
       
  1180 EXPORT_C TInt CSmsPDU::ConcatenatedMessageReference() const
       
  1181 	{
       
  1182 	LOGGSMU1("CSmsPDU::ConcatenatedMessageReference()");
       
  1183 
       
  1184 	TInt index=0;
       
  1185 	TBool is16bit;
       
  1186 	TInt reference=0;
       
  1187 	TBool textconcatenated=DoTextConcatenated(index,&is16bit);
       
  1188 	__ASSERT_ALWAYS(textconcatenated,Panic(KGsmuPanicMessageNotConcatenated));
       
  1189 	if (is16bit)
       
  1190 		{
       
  1191 		reference=UserData().InformationElement(index).Data()[0]<<8;
       
  1192 		reference+=UserData().InformationElement(index).Data()[1];
       
  1193 		}
       
  1194 	else
       
  1195 		reference=UserData().InformationElement(index).Data()[0];
       
  1196 	return reference;
       
  1197 	} // CSmsPDU::ConcatenatedMessageReference
       
  1198 
       
  1199 
       
  1200 /**
       
  1201  *  Sets the reference contained in the Concatenation Information Element.
       
  1202  *  
       
  1203  *  The function panics if aReference is out of range for the message type.
       
  1204  *  
       
  1205  *  @param aReference Value to set the Concatenated Message Reference.
       
  1206  *  @capability None
       
  1207  */
       
  1208 EXPORT_C void CSmsPDU::SetConcatenatedMessageReference(TInt aReference)
       
  1209 	{
       
  1210 	LOGGSMU1("CSmsPDU::SetConcatenatedMessageReference()");
       
  1211 
       
  1212 	TInt index=0;
       
  1213 	TBool is16bit;
       
  1214 	TBool textconcatenated=DoTextConcatenated(index,&is16bit);
       
  1215 	__ASSERT_ALWAYS(textconcatenated,Panic(KGsmuPanicMessageNotConcatenated));
       
  1216 	if (is16bit)
       
  1217 		{
       
  1218 		__ASSERT_DEBUG((aReference>=0x00) && (aReference<=0xFFFF),Panic(KGsmuPanicConcatenatedMessageReferenceOutOfRange));
       
  1219 		UserData().InformationElement(index).Data()[0]=(TUint8) (aReference >> 8);
       
  1220 		UserData().InformationElement(index).Data()[1]=(TUint8) aReference;
       
  1221 		}
       
  1222 	else
       
  1223 		{
       
  1224 		__ASSERT_DEBUG((aReference>=0x00) && (aReference<=0xFF),Panic(KGsmuPanicConcatenatedMessageReferenceOutOfRange));
       
  1225 		UserData().InformationElement(index).Data()[0]=(TUint8) aReference;
       
  1226 		}
       
  1227 	} // CSmsPDU::SetConcatenatedMessageReference
       
  1228 
       
  1229 
       
  1230 /**
       
  1231  *  Gets the number of PDU's in a Concatenated Message.
       
  1232  *  
       
  1233  *  The function panics if the PDU is not concatenated.
       
  1234  *  
       
  1235  *  @return Number of PDU's in a Concatenated Message
       
  1236  *  @capability None
       
  1237  */
       
  1238 EXPORT_C TInt CSmsPDU::NumConcatenatedMessagePDUs() const
       
  1239 	{
       
  1240 	LOGGSMU1("CSmsPDU::NumConcatenatedMessagePDUs()");
       
  1241 
       
  1242 	TInt index=0;
       
  1243 	TBool is16bit;
       
  1244 	TBool textconcatenated=DoTextConcatenated(index,&is16bit);
       
  1245 	__ASSERT_ALWAYS(textconcatenated,Panic(KGsmuPanicMessageNotConcatenated));
       
  1246 	TInt offset=is16bit? 2: 1;
       
  1247 	return UserData().InformationElement(index).Data()[offset];
       
  1248 	} // CSmsPDU::NumConcatenatedMessagePDUs
       
  1249 
       
  1250 
       
  1251 /**
       
  1252  *  Sets the number of PDU's in a Concatenated Message.
       
  1253  *  
       
  1254  *  The function panics if the PDU is not concatenated or if aNum is out of range.
       
  1255  *  
       
  1256  *  @param aNum Number of PDU's in a Concatenated Message
       
  1257  *  @capability None
       
  1258  */
       
  1259 EXPORT_C void CSmsPDU::SetNumConcatenatedMessagePDUs(TInt aNum)
       
  1260 	{
       
  1261 	LOGGSMU1("CSmsPDU::SetNumConcatenatedMessagePDUs()");
       
  1262 
       
  1263 	TInt index=0;
       
  1264 	TBool is16bit;
       
  1265 	TBool textconcatenated=DoTextConcatenated(index,&is16bit);
       
  1266 	__ASSERT_ALWAYS(textconcatenated,Panic(KGsmuPanicMessageNotConcatenated));
       
  1267 	__ASSERT_DEBUG(((aNum>=0x01) && (aNum<=0xFF)),Panic(KGsmuPanicNumConcatenatedMessagePDUsOutOfRange));
       
  1268 	TInt offset=is16bit? 2: 1;
       
  1269 	UserData().InformationElement(index).Data()[offset]=(TUint8) aNum;
       
  1270 	} // CSmsPDU::SetNumConcatenatedMessagePDUs
       
  1271 
       
  1272 
       
  1273 /**
       
  1274  *  Gets the index of the PDU within the Concatenated Message.
       
  1275  *  
       
  1276  *  The function panics if the PDU is not concatenated.
       
  1277  *  
       
  1278  *  @return Index of the PDU within the Concatenated Message
       
  1279  *  @capability None
       
  1280  */
       
  1281 EXPORT_C TInt CSmsPDU::ConcatenatedMessagePDUIndex() const
       
  1282 	{
       
  1283 	LOGGSMU1("CSmsPDU::ConcatenatedMessagePDUIndex()");
       
  1284 
       
  1285 	TInt index=0;
       
  1286 	TBool is16bit;
       
  1287 	TBool textconcatenated=DoTextConcatenated(index,&is16bit);
       
  1288 	__ASSERT_ALWAYS(textconcatenated,Panic(KGsmuPanicMessageNotConcatenated));
       
  1289 	TInt offset=is16bit? 3: 2;
       
  1290 	return UserData().InformationElement(index).Data()[offset];
       
  1291 	} // CSmsPDU::ConcatenatedMessagePDUIndex
       
  1292 
       
  1293 
       
  1294 /**
       
  1295  *  Sets the index of the PDU within the Concatenated Message.
       
  1296  *  
       
  1297  *  The function panics if the PDU is not concatenated or aIndex is out of range.
       
  1298  *  
       
  1299  *  @param aIndex Index of the PDU within the Concatenated Message
       
  1300  *  @capability None
       
  1301  */
       
  1302 EXPORT_C void CSmsPDU::SetConcatenatedMessagePDUIndex(TInt aIndex)
       
  1303 	{
       
  1304 	LOGGSMU1("CSmsPDU::SetConcatenatedMessagePDUIndex()");
       
  1305 
       
  1306 	TInt index=0;
       
  1307 	TBool is16bit;
       
  1308 	TBool textconcatenated=DoTextConcatenated(index,&is16bit);
       
  1309 	__ASSERT_ALWAYS(textconcatenated,Panic(KGsmuPanicMessageNotConcatenated));
       
  1310 	__ASSERT_DEBUG(((aIndex>=0x01) && (aIndex<=0xFF)),Panic(KGsmuPanicConcatenatedMessagePDUIndexOutOfRange));
       
  1311 	TInt offset=is16bit? 3: 2;
       
  1312 	UserData().InformationElement(index).Data()[offset]=(TUint8) aIndex;
       
  1313 	} // CSmsPDU::SetConcatenatedMessagePDUIndex
       
  1314 
       
  1315 
       
  1316 /**
       
  1317  *  Gets application port addressing information in the user data.
       
  1318  *  
       
  1319  *  @param aDestination The destination port address
       
  1320  *  @param aOriginator The originating port address
       
  1321  *  @param aIs16Bit Set to true if the addressing is 16 bit. Default is null.
       
  1322  *  @return True if there is an application port addressing information element
       
  1323  *  in the user data
       
  1324  *  @capability None
       
  1325  */
       
  1326 EXPORT_C TBool CSmsPDU::ApplicationPortAddressing(TInt& aDestination,TInt& aOriginator,TBool* aIs16Bit) const
       
  1327 	{
       
  1328 	LOGGSMU1("CSmsPDU::ApplicationPortAddressing()");
       
  1329 
       
  1330 	TInt index;
       
  1331 	return DoApplicationPortAddressing(index,aDestination,aOriginator,aIs16Bit);
       
  1332 	} // CSmsPDU::ApplicationPortAddressing
       
  1333 
       
  1334 
       
  1335 /**
       
  1336  *  Sets application port addressing information in the user data.
       
  1337  *  
       
  1338  *  @param aAddressing If true, set application port addressing in the PDU. If
       
  1339  *  false, removes addressing if it's already set
       
  1340  *  @param aDestination The destination port address to set in the PDU
       
  1341  *  @param aOriginator The originating port address to set in the PDU
       
  1342  *  @param aIs16Bit True if the addresses are 16 bit, false if 8 bit
       
  1343  *  @capability None
       
  1344  */
       
  1345 EXPORT_C void CSmsPDU::SetApplicationPortAddressingL(TBool aAddressing,TInt aDestination,TInt aOriginator,TBool aIs16Bit)
       
  1346 	{
       
  1347 	LOGGSMU1("CSmsPDU::SetApplicationPortAddressingL()");
       
  1348 
       
  1349 	TInt index=0;
       
  1350 	TInt is16bit;
       
  1351 	TBool addressing=DoApplicationPortAddressing(index,aDestination,aOriginator,&is16bit);
       
  1352 	if (aAddressing)
       
  1353 		{
       
  1354 		if (!addressing)
       
  1355 			{
       
  1356 			DoSetApplicationPortAddressingL(aDestination,aOriginator,aIs16Bit);
       
  1357 			}
       
  1358 		else
       
  1359 			{
       
  1360 			if (((!aIs16Bit) && (is16bit)) || (aIs16Bit && (!is16bit)))
       
  1361 				{
       
  1362 				UserData().RemoveInformationElement(index);
       
  1363 				DoSetApplicationPortAddressingL(aDestination,aOriginator,aIs16Bit);
       
  1364 				}
       
  1365 			}
       
  1366 		}
       
  1367 	else
       
  1368 		{
       
  1369 		if (addressing)
       
  1370 			{
       
  1371 			UserData().RemoveInformationElement(index);
       
  1372 			}
       
  1373 		}
       
  1374 	} // CSmsPDU::SetApplicationPortAddressingL
       
  1375 
       
  1376 
       
  1377 /**
       
  1378  *  Gets key bits 7 and 6 of the PID field.
       
  1379  *  
       
  1380  *  @return Bits 7 and 6 of the PID field
       
  1381  *  @capability None
       
  1382  */
       
  1383 EXPORT_C TSmsProtocolIdentifier::TSmsPIDType CSmsPDU::PIDType() const
       
  1384 	{
       
  1385 	LOGGSMU1("CSmsPDU::PIDType()");
       
  1386 
       
  1387 	__ASSERT_DEBUG(ProtocolIdentifier()!=NULL,Panic(KGsmuPanicProtocolIdentifierNotPresent));
       
  1388 	return ProtocolIdentifier()->PIDType();
       
  1389 	} // TSmsProtocolIdentifier::TSmsPIDType
       
  1390 
       
  1391 
       
  1392 /**
       
  1393  *  Sets key bits 7 and 6 of the PID field.
       
  1394  *  
       
  1395  *  @param aSmsPIDType Bits 7 and 6 of the PID field
       
  1396  *  @capability None
       
  1397  */
       
  1398 EXPORT_C void CSmsPDU::SetPIDType(TSmsProtocolIdentifier::TSmsPIDType aSmsPIDType)
       
  1399 	{
       
  1400 	LOGGSMU1("CSmsPDU::SetPIDType()");
       
  1401 
       
  1402 	__ASSERT_DEBUG(ProtocolIdentifier()!=NULL,Panic(KGsmuPanicProtocolIdentifierNotPresent));
       
  1403 	TSmsProtocolIdentifier* protocolidentifier=(TSmsProtocolIdentifier*) ProtocolIdentifier();
       
  1404 	protocolidentifier->SetPIDType(aSmsPIDType);
       
  1405 	} // CSmsPDU::SetPIDType
       
  1406 
       
  1407 
       
  1408 /**
       
  1409  *  Gets the Telematic device indicator from the PID field.
       
  1410  *  
       
  1411  *  @return Telematic device indicator
       
  1412  *  @capability None
       
  1413  */
       
  1414 EXPORT_C TSmsProtocolIdentifier::TSmsTelematicDeviceIndicator CSmsPDU::TelematicDeviceIndicator() const
       
  1415 	{
       
  1416 	LOGGSMU1("CSmsPDU::TelematicDeviceIndicator()");
       
  1417 
       
  1418 	__ASSERT_DEBUG(ProtocolIdentifier()!=NULL,Panic(KGsmuPanicProtocolIdentifierNotPresent));
       
  1419 	return ProtocolIdentifier()->TelematicDeviceIndicator();
       
  1420 	} // TSmsProtocolIdentifier::TSmsTelematicDeviceIndicator
       
  1421 
       
  1422 
       
  1423 /**
       
  1424  *  Sets the Telematic device indicator from the PID field.
       
  1425  *  
       
  1426  *  @param aIndicator Telematic device indicator
       
  1427  *  @capability None
       
  1428  */
       
  1429 EXPORT_C void CSmsPDU::SetTelematicDeviceIndicator(TSmsProtocolIdentifier::TSmsTelematicDeviceIndicator aIndicator)
       
  1430 	{
       
  1431 	LOGGSMU1("CSmsPDU::SetTelematicDeviceIndicator()");
       
  1432 
       
  1433 	__ASSERT_DEBUG(ProtocolIdentifier()!=NULL,Panic(KGsmuPanicProtocolIdentifierNotPresent));
       
  1434 	TSmsProtocolIdentifier* protocolidentifier=(TSmsProtocolIdentifier*) ProtocolIdentifier();
       
  1435 	protocolidentifier->SetTelematicDeviceIndicator(aIndicator);
       
  1436 	} // CSmsPDU::SetTelematicDeviceIndicator
       
  1437 
       
  1438 
       
  1439 /**
       
  1440  *  Gets the Short Message Type in the PID field.
       
  1441  *  
       
  1442  *  @return Short Message Type
       
  1443  *  @capability None
       
  1444  */
       
  1445 EXPORT_C TSmsProtocolIdentifier::TSmsShortMessageType CSmsPDU::ShortMessageType() const
       
  1446 	{
       
  1447 	LOGGSMU1("CSmsPDU::ShortMessageType()");
       
  1448 
       
  1449 	__ASSERT_DEBUG(ProtocolIdentifier()!=NULL,Panic(KGsmuPanicProtocolIdentifierNotPresent));
       
  1450 	return (TSmsProtocolIdentifier::TSmsShortMessageType) ProtocolIdentifier()->ShortMessageType();
       
  1451 	} // TSmsProtocolIdentifier::TSmsShortMessageType
       
  1452 
       
  1453 
       
  1454 /**
       
  1455  *  Sets the Short Message Type in the PID field.
       
  1456  *  
       
  1457  *  @param aShortMessageType Short Message Type
       
  1458  *  @capability None
       
  1459  */
       
  1460 EXPORT_C void CSmsPDU::SetShortMessageType(TSmsProtocolIdentifier::TSmsShortMessageType aShortMessageType)
       
  1461 	{
       
  1462 	LOGGSMU1("CSmsPDU::SetShortMessageType()");
       
  1463 
       
  1464 	__ASSERT_DEBUG(ProtocolIdentifier()!=NULL,Panic(KGsmuPanicProtocolIdentifierNotPresent));
       
  1465 	TSmsProtocolIdentifier* protocolidentifier=(TSmsProtocolIdentifier*) ProtocolIdentifier();
       
  1466 	protocolidentifier->SetShortMessageType(aShortMessageType);
       
  1467 	} // CSmsPDU::SetShortMessageType
       
  1468 
       
  1469 
       
  1470 /**
       
  1471  *  Gets the Telematic device type in the PID field.
       
  1472  *  
       
  1473  *  @return Telematic device type
       
  1474  *  @capability None
       
  1475  */
       
  1476 EXPORT_C TSmsProtocolIdentifier::TSmsTelematicDeviceType CSmsPDU::TelematicDeviceType() const
       
  1477 	{
       
  1478 	LOGGSMU1("CSmsPDU::TelematicDeviceType()");
       
  1479 
       
  1480 	__ASSERT_DEBUG(ProtocolIdentifier()!=NULL,Panic(KGsmuPanicProtocolIdentifierNotPresent));
       
  1481 	return ProtocolIdentifier()->TelematicDeviceType();
       
  1482 	} // TSmsProtocolIdentifier::TSmsTelematicDeviceType
       
  1483 
       
  1484 
       
  1485 /**
       
  1486  *  Sets the Telematic device type in the PID field.
       
  1487  *  
       
  1488  *  @param aDeviceType Telematic device type
       
  1489  *  @capability None
       
  1490  */
       
  1491 EXPORT_C void CSmsPDU::SetTelematicDeviceType(TSmsProtocolIdentifier::TSmsTelematicDeviceType aDeviceType)
       
  1492 	{
       
  1493 	LOGGSMU1("CSmsPDU::SetTelematicDeviceType()");
       
  1494 
       
  1495 	__ASSERT_DEBUG(ProtocolIdentifier()!=NULL,Panic(KGsmuPanicProtocolIdentifierNotPresent));
       
  1496 	TSmsProtocolIdentifier* protocolidentifier=(TSmsProtocolIdentifier*) ProtocolIdentifier();
       
  1497 	protocolidentifier->SetTelematicDeviceType(aDeviceType);
       
  1498 	} // CSmsPDU::SetTelematicDeviceType
       
  1499 
       
  1500 
       
  1501 /**
       
  1502  *  Tests if the User Data Header Indicator is set.
       
  1503  *  
       
  1504  *  It panics if PDU type is unsupported.
       
  1505  *  
       
  1506  *  @return True if the User Data Header Indicator is set
       
  1507  *  @capability None
       
  1508  */
       
  1509 EXPORT_C TBool CSmsPDU::UserDataPresent() const
       
  1510 	{
       
  1511 	LOGGSMU1("CSmsPDU::UserDataPresent()");
       
  1512 
       
  1513 	TBool udPresent=ETrue;
       
  1514 	switch (iSmsPDUType)
       
  1515 		{
       
  1516 		case ESmsDeliver:
       
  1517 		case ESmsSubmit:
       
  1518 			break;
       
  1519 		case ESmsDeliverReport:
       
  1520 		case ESmsSubmitReport:
       
  1521 			udPresent=ParameterIndicator()->UserDataPresent();
       
  1522 			break;
       
  1523 		case ESmsStatusReport:
       
  1524 			udPresent=((CSmsStatusReport*)this)->ParameterIndicatorPresent()
       
  1525 				&& ParameterIndicator()->UserDataPresent();
       
  1526 			break;
       
  1527 		default:
       
  1528 			Panic(KGsmuPanicUnsupportedPduType);
       
  1529 		}
       
  1530 	return udPresent;
       
  1531 	} // CSmsPDU::UserDataPresent
       
  1532 
       
  1533 
       
  1534 /**
       
  1535  *  Sets or unsets the User Data Header Indicator.
       
  1536  *  
       
  1537  *  It panics if PDU type is unsupported.
       
  1538  *  
       
  1539  *  @param aPresent True to set the User Data Header Indicator
       
  1540  *  @capability None
       
  1541  */
       
  1542 EXPORT_C void CSmsPDU::SetUserDataPresent(TBool aPresent)
       
  1543 	{
       
  1544 	LOGGSMU2("CSmsPDU::SetUserDataPresent(): aPresent=%d", aPresent);
       
  1545 
       
  1546 	__ASSERT_DEBUG(ParameterIndicator()!=NULL,Panic(KGsmuPanicParameterIndicatorNotPresent));
       
  1547 	TSmsParameterIndicator* parameterindicator=(TSmsParameterIndicator*) ParameterIndicator();
       
  1548 	parameterindicator->SetUserDataPresent(aPresent);
       
  1549 	} // CSmsPDU::SetUserDataPresent
       
  1550 
       
  1551 
       
  1552 /**
       
  1553  *  Tests if data coding scheme is present.
       
  1554  *  
       
  1555  *  Panics if PDU type is unsupported.
       
  1556  *  
       
  1557  *  @return True if data coding scheme is present
       
  1558  *  @capability None
       
  1559  */
       
  1560 EXPORT_C TBool CSmsPDU::DataCodingSchemePresent() const
       
  1561 	{
       
  1562 	LOGGSMU1("CSmsPDU::DataCodingSchemePresent()");
       
  1563 
       
  1564 	TBool dcsPresent=ETrue;
       
  1565 	switch (iSmsPDUType)
       
  1566 		{
       
  1567 		case ESmsDeliver:
       
  1568 		case ESmsSubmit:
       
  1569 			break;
       
  1570 		case ESmsDeliverReport:
       
  1571 		case ESmsSubmitReport:
       
  1572 			dcsPresent=ParameterIndicator()->DataCodingSchemePresent();
       
  1573 			break;
       
  1574 		case ESmsStatusReport:
       
  1575 			dcsPresent=((CSmsStatusReport*)this)->ParameterIndicatorPresent()
       
  1576 				&& ParameterIndicator()->DataCodingSchemePresent();
       
  1577 			break;
       
  1578 		case ESmsCommand:
       
  1579 			dcsPresent=EFalse;
       
  1580 			break;
       
  1581 		default:
       
  1582 			Panic(KGsmuPanicUnsupportedPduType);
       
  1583 		}
       
  1584 	return dcsPresent;
       
  1585 	} // CSmsPDU::DataCodingSchemePresent
       
  1586 
       
  1587 
       
  1588 /**
       
  1589  *  Sets if data coding scheme is present.
       
  1590  *  
       
  1591  *  @param aPresent True if data coding scheme is present
       
  1592  *  @capability None
       
  1593  */
       
  1594 EXPORT_C void CSmsPDU::SetDataCodingSchemePresent(TBool aPresent)
       
  1595 	{
       
  1596 	LOGGSMU2("CSmsPDU::SetDataCodingSchemePresent(): aPresent=%d", aPresent);
       
  1597 
       
  1598 	__ASSERT_DEBUG(ParameterIndicator()!=NULL,Panic(KGsmuPanicParameterIndicatorNotPresent));
       
  1599 	TSmsParameterIndicator* parameterindicator=(TSmsParameterIndicator*) ParameterIndicator();
       
  1600 	parameterindicator->SetDataCodingSchemePresent(aPresent);
       
  1601 	} // CSmsPDU::SetDataCodingSchemePresent
       
  1602 
       
  1603 
       
  1604 /**
       
  1605  *  Tests if Protocol Identifier is present.
       
  1606  *  
       
  1607  *  It panics if the PDU type is unsupported.
       
  1608  *  
       
  1609  *  @return True if Protocol Identifier is present
       
  1610  *  @capability None
       
  1611  */
       
  1612 EXPORT_C TBool CSmsPDU::ProtocolIdentifierPresent() const
       
  1613 	{
       
  1614 	LOGGSMU1("CSmsPDU::ProtocolIdentifierPresent()");
       
  1615 
       
  1616 	TBool pidPresent=ETrue;
       
  1617 	switch (iSmsPDUType)
       
  1618 		{
       
  1619 		case ESmsDeliver:
       
  1620 		case ESmsSubmit:
       
  1621 		case ESmsCommand:
       
  1622 			break;
       
  1623 		case ESmsDeliverReport:
       
  1624 		case ESmsSubmitReport:
       
  1625 			pidPresent=ParameterIndicator()->ProtocolIdentifierPresent();
       
  1626 			break;
       
  1627 		case ESmsStatusReport:
       
  1628 			pidPresent=((CSmsStatusReport*)this)->ParameterIndicatorPresent()
       
  1629 				&& ParameterIndicator()->ProtocolIdentifierPresent();
       
  1630 			break;
       
  1631 		default:
       
  1632 			Panic(KGsmuPanicUnsupportedPduType);
       
  1633 		}
       
  1634 	return pidPresent;
       
  1635 	} // CSmsPDU::ProtocolIdentifierPresent
       
  1636 
       
  1637 
       
  1638 /**
       
  1639  *  Sets if Protocol Identifier is present.
       
  1640  *  
       
  1641  *  It panics if the PDU type is unsupported.
       
  1642  *  
       
  1643  *  @param aPresent True if Protocol Identifier is present
       
  1644  *  @capability None
       
  1645  */
       
  1646 EXPORT_C void CSmsPDU::SetProtocolIdentifierPresent(TBool aPresent)
       
  1647 	{
       
  1648 	LOGGSMU2("CSmsPDU::SetProtocolIdentifierPresent(): aPresent=%d", aPresent);
       
  1649 
       
  1650 	__ASSERT_DEBUG(ParameterIndicator()!=NULL,Panic(KGsmuPanicParameterIndicatorNotPresent));
       
  1651 	TSmsParameterIndicator* parameterindicator=(TSmsParameterIndicator*) ParameterIndicator();
       
  1652 	parameterindicator->SetProtocolIdentifierPresent(aPresent);
       
  1653 	} // CSmsPDU::SetProtocolIdentifierPresent
       
  1654 
       
  1655 
       
  1656 /**
       
  1657  *  
       
  1658  *  Gets User Data (non-const).
       
  1659  *  
       
  1660  *  @return User Data
       
  1661  *  @capability None
       
  1662  */
       
  1663 EXPORT_C CSmsUserData& CSmsPDU::UserData()
       
  1664 	{
       
  1665 	LOGGSMU1("CSmsPDU::UserData()");
       
  1666 
       
  1667 	__ASSERT_DEBUG(UserDataPtr()!=NULL,Panic(KGsmuPanicUserDataNotPresent));
       
  1668 	CSmsUserData* userdata=(CSmsUserData*) UserDataPtr();
       
  1669 	return *userdata;
       
  1670 	} // CSmsPDU::UserData
       
  1671 
       
  1672 
       
  1673 /**
       
  1674  *  Gets User Data (const).
       
  1675  *  
       
  1676  *  @return User Data
       
  1677  *  @capability None
       
  1678  */
       
  1679 EXPORT_C const CSmsUserData& CSmsPDU::UserData() const
       
  1680 	{
       
  1681 	LOGGSMU1("CSmsPDU::UserData()");
       
  1682 
       
  1683 	__ASSERT_DEBUG(UserDataPtr()!=NULL,Panic(KGsmuPanicUserDataNotPresent));
       
  1684 	return *UserDataPtr();
       
  1685 	} // CSmsPDU::UserData
       
  1686 
       
  1687 
       
  1688 CSmsPDU::CSmsPDU(TSmsPDUType aSmsPDUType):
       
  1689 	iSmsPDUType(aSmsPDUType)
       
  1690 	{
       
  1691 	// NOP
       
  1692 	} // CSmsPDU::CSmsPDU
       
  1693 
       
  1694 
       
  1695 const TSmsDataCodingScheme* CSmsPDU::DataCodingScheme() const
       
  1696     {
       
  1697     // Ignore in code coverage - for PDUs that are meant to have a DCS
       
  1698     // this method is overridden; the base class implementation is not
       
  1699     // intended to be used.
       
  1700     BULLSEYE_OFF
       
  1701     return NULL;
       
  1702     BULLSEYE_RESTORE
       
  1703     }
       
  1704 
       
  1705 const TSmsProtocolIdentifier* CSmsPDU::ProtocolIdentifier() const
       
  1706     {
       
  1707     // Ignore in code coverage - for PDUs that are meant to have a PID
       
  1708     // this method is overridden; the base class implementation is not
       
  1709     // intended to be used.
       
  1710     BULLSEYE_OFF
       
  1711     return NULL;
       
  1712     BULLSEYE_RESTORE
       
  1713     }
       
  1714 
       
  1715 const TSmsParameterIndicator* CSmsPDU::ParameterIndicator() const
       
  1716     {
       
  1717     // Ignore in code coverage - for PDUs that are meant to have a PI
       
  1718     // this method is overridden; the base class implementation is not
       
  1719     // intended to be used.
       
  1720     BULLSEYE_OFF
       
  1721     return NULL;
       
  1722     BULLSEYE_RESTORE
       
  1723     }
       
  1724 
       
  1725 const CSmsUserData* CSmsPDU::UserDataPtr() const
       
  1726     {
       
  1727     // Ignore in code coverage - for PDUs that are meant to have a UD
       
  1728     // this method is overridden; the base class implementation is not
       
  1729     // intended to be used.
       
  1730     BULLSEYE_OFF
       
  1731     return NULL;
       
  1732     BULLSEYE_RESTORE
       
  1733     }
       
  1734 
       
  1735 const CSmsAddress* CSmsPDU::ToFromAddressPtr() const
       
  1736     {
       
  1737     return NULL;
       
  1738     }
       
  1739 
       
  1740 TBool CSmsPDU::DoTextConcatenated(TInt& aIndex,TBool* aIs16Bit) const
       
  1741 	{
       
  1742 	LOGGSMU1("CSmsPDU::DoTextConcatenated()");
       
  1743 
       
  1744 	TBool is8bit=UserData().InformationElementIndex(CSmsInformationElement::ESmsIEIConcatenatedShortMessages8BitReference,aIndex);
       
  1745 	TBool is16bit=EFalse;
       
  1746 	if (!is8bit)
       
  1747 		is16bit=UserData().InformationElementIndex(CSmsInformationElement::ESmsIEIConcatenatedShortMessages16BitReference,aIndex);
       
  1748 	if (aIs16Bit!=NULL)
       
  1749 		*aIs16Bit=is16bit;
       
  1750 	return is8bit || is16bit;
       
  1751 	} // CSmsPDU::DoTextConcatenated
       
  1752 
       
  1753 
       
  1754 void CSmsPDU::DoSetTextConcatenatedL(TBool aIs16Bit)
       
  1755 	{
       
  1756 	LOGGSMU2("CSmsPDU::DoSetTextConcatenatedL(): aIs16Bit=%d", aIs16Bit);
       
  1757 
       
  1758 	if (!aIs16Bit)
       
  1759 		{
       
  1760 		TBuf8<3> data;
       
  1761 		data.SetLength(3);
       
  1762 		data[0]=1;
       
  1763 		data[1]=1;
       
  1764 		data[2]=1;
       
  1765 		UserData().AddInformationElementL(CSmsInformationElement::ESmsIEIConcatenatedShortMessages8BitReference,data);
       
  1766 		}
       
  1767 	else
       
  1768 		{
       
  1769 		TBuf8<4> data;
       
  1770 		data.SetLength(4);
       
  1771 		data[0]=0;
       
  1772 		data[1]=1;
       
  1773 		data[2]=1;
       
  1774 		data[3]=1;
       
  1775 		UserData().AddInformationElementL(CSmsInformationElement::ESmsIEIConcatenatedShortMessages16BitReference,data);
       
  1776 		}
       
  1777 	} // CSmsPDU::DoSetTextConcatenatedL
       
  1778 
       
  1779 
       
  1780 TBool CSmsPDU::DoApplicationPortAddressing(TInt& aIndex,TInt& aDestination,TInt& aOriginator,TBool* aIs16Bit) const
       
  1781 	{
       
  1782 	LOGGSMU1("CSmsPDU::DoApplicationPortAddressing()");
       
  1783 
       
  1784 	TBool is8bit=UserData().InformationElementIndex(CSmsInformationElement::ESmsIEIApplicationPortAddressing8Bit,aIndex);
       
  1785 	TBool is16bit=EFalse;
       
  1786 	if (is8bit)
       
  1787 		{
       
  1788 		TPtr8 data=UserData().InformationElement(aIndex).Data();
       
  1789 		aDestination=data[0];
       
  1790 		aOriginator=data[1];
       
  1791 		}
       
  1792 	else
       
  1793 		{
       
  1794 		is16bit=UserData().InformationElementIndex(CSmsInformationElement::ESmsIEIApplicationPortAddressing16Bit,aIndex);
       
  1795 		if (is16bit)
       
  1796 			{
       
  1797 			TPtr8 data=UserData().InformationElement(aIndex).Data();
       
  1798 			aDestination=data[0]<<8;
       
  1799 			aDestination+=data[1];
       
  1800 			aOriginator=data[2]<<8;
       
  1801 			aOriginator+=data[3];
       
  1802 			}
       
  1803 		}
       
  1804 	if (aIs16Bit!=NULL)
       
  1805 		*aIs16Bit=is16bit;
       
  1806 	return is8bit || is16bit;
       
  1807 	} // CSmsPDU::DoApplicationPortAddressing
       
  1808 
       
  1809 
       
  1810 void CSmsPDU::DoSetApplicationPortAddressingL(TInt aDestination,TInt aOriginator,TBool aIs16Bit)
       
  1811 	{
       
  1812 	LOGGSMU4("CSmsPDU::DoSetApplicationPortAddressingL(): aDestination=%d, aOriginator=%d, aIs16Bit=%d",
       
  1813 			 aDestination, aOriginator, aIs16Bit);
       
  1814 
       
  1815 	if (!aIs16Bit)
       
  1816 		{
       
  1817 		__ASSERT_ALWAYS((aDestination>=0x00) && (aDestination<=0xFF) && (aOriginator>=0x00) && (aOriginator<=0xFF),Panic(KGsmuPanicPortOutOfRange));
       
  1818 		TBuf8<2> data;
       
  1819 		data.SetLength(2);
       
  1820 		data[0]=(TUint8) aDestination;
       
  1821 		data[1]=(TUint8) aOriginator;
       
  1822 		UserData().AddInformationElementL(CSmsInformationElement::ESmsIEIApplicationPortAddressing8Bit,data);
       
  1823 		}
       
  1824 	else
       
  1825 		{
       
  1826 		__ASSERT_ALWAYS((aDestination>=0x00) && (aDestination<=0xFFFF) && (aOriginator>=0x00) && (aOriginator<=0xFFFF),Panic(KGsmuPanicPortOutOfRange));
       
  1827 		TBuf8<4> data;
       
  1828 		data.SetLength(4);
       
  1829 		data[0]=(TUint8) (aDestination>>8);
       
  1830 		data[1]=(TUint8) aDestination;
       
  1831 		data[2]=(TUint8) (aOriginator>>8);
       
  1832 		data[3]=(TUint8) aOriginator;
       
  1833 		UserData().AddInformationElementL(CSmsInformationElement::ESmsIEIApplicationPortAddressing16Bit,data);
       
  1834 		}
       
  1835 	} // CSmsPDU::DoSetApplicationPortAddressingL
       
  1836 
       
  1837 
       
  1838 CSmsDeliver::CSmsDeliver():
       
  1839 	CSmsPDU(ESmsDeliver),
       
  1840 	iFirstOctet(TSmsFirstOctet::ESmsMTIDeliverOrDeliverReport)
       
  1841 	{
       
  1842 	//NOP
       
  1843 	} // TSmsFirstOctet::ESmsMTIDeliverOrDeliverReport
       
  1844 
       
  1845 
       
  1846 /**
       
  1847  *  Gets More Messages to Send flag.
       
  1848  *  
       
  1849  *  @return True if More Messages to Send flag set
       
  1850  *  @capability None
       
  1851  */
       
  1852 EXPORT_C TBool CSmsDeliver::MoreMessagesToSend() const
       
  1853 	{
       
  1854 	LOGGSMU1("CSmsDeliver::MoreMessagesToSend");
       
  1855 
       
  1856 	return (iFirstOctet&TSmsFirstOctet::ESmsMoreMessagesToSendMask)==TSmsFirstOctet::ESmsMoreMessagesToSend;
       
  1857 	} // CSmsDeliver::MoreMessagesToSend
       
  1858 
       
  1859 
       
  1860 /**
       
  1861  *  Sets More Messages to Send flag.
       
  1862  *  
       
  1863  *  @param aMore True if More Messages to Send
       
  1864  *  @capability None
       
  1865  */
       
  1866 EXPORT_C void CSmsDeliver::SetMoreMessagesToSend(TBool aMore)
       
  1867 	{
       
  1868 	LOGGSMU2("CSmsDeliver::SetMoreMessagesToSend(): aMore=%d", aMore);
       
  1869 
       
  1870 	iFirstOctet=aMore? (iFirstOctet&(~TSmsFirstOctet::ESmsMoreMessagesToSendMask)|TSmsFirstOctet::ESmsMoreMessagesToSend):
       
  1871 	                   (iFirstOctet&(~TSmsFirstOctet::ESmsMoreMessagesToSendMask)|TSmsFirstOctet::ESmsNoMoreMessagesToSend);
       
  1872 	} // CSmsDeliver::SetMoreMessagesToSend
       
  1873 
       
  1874 
       
  1875 /**
       
  1876  *  Gets Reply Path flag.
       
  1877  *  
       
  1878  *  If a reply path exists, the service center encoded in the DELIVER can be used
       
  1879  *  to construct a SUBMIT reply.
       
  1880  *  
       
  1881  *  @return True if Reply Path exists
       
  1882  *  @capability None
       
  1883  */
       
  1884 EXPORT_C TBool CSmsDeliver::ReplyPath() const
       
  1885 	{
       
  1886 	LOGGSMU1("CSmsDeliver::ReplyPath");
       
  1887 
       
  1888 	return (iFirstOctet&TSmsFirstOctet::ESmsReplyPathMask)==TSmsFirstOctet::ESmsReplyPathExists;
       
  1889 	} // CSmsDeliver::ReplyPath
       
  1890 
       
  1891 
       
  1892 /**
       
  1893  *  Sets Reply Path flag.
       
  1894  *  
       
  1895  *  @param aReplyPath True to set Reply Path
       
  1896  *  @capability None
       
  1897  */
       
  1898 EXPORT_C void CSmsDeliver::SetReplyPath(TBool aReplyPath)
       
  1899 	{
       
  1900 	LOGGSMU2("CSmsDeliver::SetReplyPath(): aReplyPath=%d", aReplyPath);
       
  1901 
       
  1902 	iFirstOctet=aReplyPath? (iFirstOctet&(~TSmsFirstOctet::ESmsReplyPathMask)|TSmsFirstOctet::ESmsReplyPathExists):
       
  1903 	                        (iFirstOctet&(~TSmsFirstOctet::ESmsReplyPathMask)|TSmsFirstOctet::ESmsReplyPathNone);
       
  1904 	} // CSmsDeliver::SetReplyPath
       
  1905 
       
  1906 
       
  1907 /**
       
  1908  *  Gets Status Report flag.
       
  1909  *  
       
  1910  *  @return True if Status Report to be returned.
       
  1911  *  @capability None
       
  1912  */
       
  1913 EXPORT_C TBool CSmsDeliver::StatusReportIndication() const
       
  1914 	{
       
  1915 	LOGGSMU1("CSmsDeliver::StatusReportIndication");
       
  1916 
       
  1917 	return (iFirstOctet&TSmsFirstOctet::ESmsStatusReportIndicatorMask)==TSmsFirstOctet::ESmsStatusReportReturned;
       
  1918 	} // CSmsDeliver::StatusReportIndication
       
  1919 
       
  1920 
       
  1921 /**
       
  1922  *  Sets Status Report flag.
       
  1923  *  
       
  1924  *  @param aIndication Set True to request Status Report
       
  1925  *  @capability None
       
  1926  */
       
  1927 EXPORT_C void CSmsDeliver::SetStatusReportIndication(TBool aIndication)
       
  1928 	{
       
  1929 	LOGGSMU2("CSmsDeliver::SetStatusReportIndication(): aIndication=%d", aIndication);
       
  1930 
       
  1931 	iFirstOctet=aIndication? (iFirstOctet&(~TSmsFirstOctet::ESmsStatusReportIndicatorMask)|TSmsFirstOctet::ESmsStatusReportReturned):
       
  1932 	                         (iFirstOctet&(~TSmsFirstOctet::ESmsStatusReportIndicatorMask)|TSmsFirstOctet::ESmsStatusReportNotReturned);
       
  1933 	} // CSmsDeliver::SetStatusReportIndication
       
  1934 
       
  1935 
       
  1936 /**
       
  1937  *  Destructor.
       
  1938  */
       
  1939 CSmsDeliver::~CSmsDeliver()
       
  1940 	{
       
  1941 	delete iServiceCenterAddress;
       
  1942 	delete iOriginalAddress;
       
  1943 	delete iUserData;
       
  1944 	} // CSmsDeliver::SetStatusReportIndication
       
  1945 
       
  1946 
       
  1947 /**
       
  1948  *  Gets Service Center Time Stamp.
       
  1949  *  
       
  1950  *  @param aTime Service Center Time Stamp represented in Universal Time
       
  1951  *  @param aNumQuarterHours +/- Time Zone difference to GMT in quarter hours
       
  1952  *  @capability None
       
  1953  */
       
  1954 EXPORT_C void CSmsDeliver::ServiceCenterTimeStamp(TTime& aTime,TInt& aNumQuarterHours)
       
  1955 	{
       
  1956 	LOGGSMU1("CSmsDeliver::ServiceCenterTimeStamp()");
       
  1957 
       
  1958 	aTime=iServiceCenterTimeStamp.Time();
       
  1959 	aNumQuarterHours=iServiceCenterTimeStamp.TimeOffset();
       
  1960 	} // CSmsDeliver::ServiceCenterTimeStamp
       
  1961 
       
  1962 
       
  1963 /**
       
  1964  *  Sets Service Center Time Stamp.
       
  1965  *  
       
  1966  *  @param aTime Service Center Time Stamp represented in Universal Time
       
  1967  *  @param aNumQuarterHours +/- Time Zone difference to GMT in quarter hours
       
  1968  *  @capability None
       
  1969  */
       
  1970 EXPORT_C void CSmsDeliver::SetServiceCenterTimeStamp(const TTime& aTime,TInt aNumQuarterHours)
       
  1971 	{
       
  1972 	LOGGSMU2("CSmsDeliver::ServiceCenterTimeStamp(): aNumQuarterHours=%d", aNumQuarterHours);
       
  1973 
       
  1974 	iServiceCenterTimeStamp.SetTime(aTime);
       
  1975 	iServiceCenterTimeStamp.SetTimeOffset(aNumQuarterHours);
       
  1976 	} // CSmsDeliver::SetServiceCenterTimeStamp
       
  1977 
       
  1978 
       
  1979 void CSmsDeliver::ConstructL(CCnvCharacterSetConverter& aCharacterSetConverter,RFs& aFs)
       
  1980 	{
       
  1981 	LOGGSMU1("CSmsDeliver::ConstructL()");
       
  1982 
       
  1983 	iServiceCenterAddress=CSmsAddress::NewL(aCharacterSetConverter,aFs);
       
  1984 	iOriginalAddress=CSmsAddress::NewL(aCharacterSetConverter,aFs);
       
  1985 	iUserData=CSmsUserData::NewL(aCharacterSetConverter,aFs,iFirstOctet,iDataCodingScheme);
       
  1986 	} // CSmsDeliver::ConstructL
       
  1987 
       
  1988 
       
  1989 /**
       
  1990  *  Duplicates this CSmsDeliver object.
       
  1991  * 
       
  1992  *  @return  Pointer to the newly created CSmsDeliver object.
       
  1993  */
       
  1994 EXPORT_C CSmsDeliver* CSmsDeliver::DuplicateL() const
       
  1995 	{
       
  1996 	LOGGSMU1("CSmsDeliver::DuplicateL()");
       
  1997 
       
  1998 	CSmsDeliver*  smsDeliver = new (ELeave) CSmsDeliver();
       
  1999 	CleanupStack::PushL(smsDeliver);
       
  2000 
       
  2001 	smsDeliver->iServiceCenterAddress   = iServiceCenterAddress->DuplicateL();
       
  2002 	smsDeliver->iFirstOctet             = iFirstOctet;
       
  2003 	smsDeliver->iOriginalAddress        = iOriginalAddress->DuplicateL();
       
  2004 	smsDeliver->iProtocolIdentifier     = iProtocolIdentifier;
       
  2005 	smsDeliver->iDataCodingScheme       = iDataCodingScheme;
       
  2006 	smsDeliver->iServiceCenterTimeStamp = iServiceCenterTimeStamp;
       
  2007 	smsDeliver->iUserData               = iUserData->DuplicateL(smsDeliver->iFirstOctet,
       
  2008 																smsDeliver->iDataCodingScheme);
       
  2009 
       
  2010 	CleanupStack::Pop(smsDeliver);
       
  2011 
       
  2012 	return smsDeliver;
       
  2013 	} // CSmsDeliver::DuplicateL
       
  2014 
       
  2015 
       
  2016 TUint8* CSmsDeliver::EncodeL(TUint8* aPtr) const
       
  2017 	{
       
  2018 	LOGGSMU1("CSmsDeliver::EncodeL()");
       
  2019 
       
  2020 	aPtr=iFirstOctet.EncodeL(aPtr);
       
  2021 	aPtr=iOriginalAddress->EncodeL(aPtr);
       
  2022 	aPtr=iProtocolIdentifier.EncodeL(aPtr);
       
  2023 	aPtr=iDataCodingScheme.EncodeL(aPtr);
       
  2024 	aPtr=iServiceCenterTimeStamp.EncodeL(aPtr);
       
  2025 	return iUserData->EncodeL(aPtr);
       
  2026 	} // CSmsDeliver::EncodeL
       
  2027 
       
  2028 TUint8* CSmsDeliver::EncodeL(TUint8* aPtr, const TEncodeParams* ) const
       
  2029 	{
       
  2030 	return EncodeL(aPtr);		
       
  2031 	}	
       
  2032 
       
  2033 void CSmsDeliver::DecodeL(TGsmuLex8& aPdu)
       
  2034 	{
       
  2035 	LOGGSMU1("CSmsDeliver::DecodeL()");
       
  2036 
       
  2037 	iFirstOctet.DecodeL(aPdu);
       
  2038 	iOriginalAddress->DecodeL(aPdu);
       
  2039 	iProtocolIdentifier.DecodeL(aPdu);
       
  2040 	iDataCodingScheme.DecodeL(aPdu);
       
  2041 	TInt bit7to4=iDataCodingScheme.Bits7To4();
       
  2042 	TInt lowerLimit = TSmsDataCodingScheme::ESmsDCSReserved5;
       
  2043 	TInt upperLimit = TSmsDataCodingScheme::ESmsDCSReserved8;
       
  2044 	if ((bit7to4>=lowerLimit) &&
       
  2045 	    (bit7to4<=upperLimit))
       
  2046 		User::Leave(KErrGsmSMSUnspecifiedDCSError);
       
  2047 
       
  2048 	TInt timeError = KErrNone;
       
  2049 	iServiceCenterTimeStamp.DecodeL(aPdu, timeError);  //  Review, fix for bug
       
  2050 	if (timeError != KErrNone)
       
  2051 		{
       
  2052 		TTime time;
       
  2053 		time.UniversalTime();
       
  2054 		iServiceCenterTimeStamp.SetTime(time);
       
  2055 		iServiceCenterTimeStamp.SetTimeOffset((User::UTCOffset().Int()) / CSmsMessage::E15MinutesRepresentedInSeconds);
       
  2056 		}
       
  2057 
       
  2058 	iUserData->DecodeL(aPdu);
       
  2059 	} // CSmsDeliver::DecodeL
       
  2060 
       
  2061 
       
  2062 void CSmsDeliver::InternalizeMessagePDUL(RReadStream& aStream)
       
  2063 	{
       
  2064 	LOGGSMU1("CSmsDeliver::InternalizeMessagePDUL()");
       
  2065 
       
  2066 	iServiceCenterAddress->InternalizeL(aStream);
       
  2067 
       
  2068 	aStream >> iFirstOctet;
       
  2069 	iOriginalAddress->InternalizeL(aStream);
       
  2070 /*	TUint8 tmp;
       
  2071 	aStream >> tmp;
       
  2072 	SetMessageConversion((TSmsProtocolIdentifier::TSmsPIDConversion)tmp);
       
  2073 */	aStream >> iProtocolIdentifier;
       
  2074 	aStream >> iDataCodingScheme;
       
  2075 	aStream >> iServiceCenterTimeStamp;
       
  2076 
       
  2077 	aStream >> *iUserData;
       
  2078 	} // CSmsDeliver::InternalizeMessagePDUL
       
  2079 
       
  2080 
       
  2081 void CSmsDeliver::ExternalizeMessagePDUL(RWriteStream& aStream) const
       
  2082 	{
       
  2083 	LOGGSMU1("CSmsDeliver::ExternalizeMessagePDUL()");
       
  2084 
       
  2085 	iServiceCenterAddress->ExternalizeL(aStream);
       
  2086 
       
  2087 	aStream << iFirstOctet;
       
  2088 	iOriginalAddress->ExternalizeL(aStream);
       
  2089 /*	TSmsProtocolIdentifier::TSmsPIDConversion tmp;
       
  2090 	tmp=MessageConversion();
       
  2091 	aStream << (TUint8)tmp;
       
  2092 */	aStream << iProtocolIdentifier;
       
  2093 	aStream << iDataCodingScheme;
       
  2094 	aStream << iServiceCenterTimeStamp;
       
  2095 
       
  2096 	aStream << *iUserData;
       
  2097 	} // CSmsDeliver::ExternalizeMessagePDUL
       
  2098 
       
  2099 
       
  2100 const TSmsDataCodingScheme* CSmsDeliver::DataCodingScheme() const
       
  2101 	{
       
  2102 	LOGGSMU1("CSmsDeliver::DataCodingScheme()");
       
  2103 
       
  2104 	return &iDataCodingScheme;
       
  2105 	} // CSmsDeliver::DataCodingScheme
       
  2106 
       
  2107 
       
  2108 /**
       
  2109  *  Gets the Deliver PID field.
       
  2110  *  
       
  2111  *  @return The Deliver PID field
       
  2112  *  @capability None
       
  2113  */
       
  2114 EXPORT_C const TSmsProtocolIdentifier* CSmsDeliver::ProtocolIdentifier() const
       
  2115 	{
       
  2116 	LOGGSMU1("CSmsDeliver::ProtocolIdentifier()");
       
  2117 
       
  2118 	return &iProtocolIdentifier;
       
  2119 	} // CSmsDeliver::ProtocolIdentifier
       
  2120 
       
  2121 
       
  2122 const CSmsUserData* CSmsDeliver::UserDataPtr() const
       
  2123 	{
       
  2124 	LOGGSMU1("CSmsDeliver::UserDataPtr()");
       
  2125 
       
  2126 	return iUserData;
       
  2127 	} // CSmsDeliver::UserDataPtr
       
  2128 
       
  2129 
       
  2130 const CSmsAddress* CSmsDeliver::ToFromAddressPtr() const
       
  2131 	{
       
  2132 	LOGGSMU1("CSmsDeliver::ToFromAddressPtr()");
       
  2133 
       
  2134 	return iOriginalAddress;
       
  2135 	} // CSmsDeliver::ToFromAddressPtr
       
  2136 
       
  2137 
       
  2138 CSmsSubmit::CSmsSubmit():
       
  2139 	CSmsPDU(ESmsSubmit),
       
  2140 	iFirstOctet(TSmsFirstOctet::ESmsMTISubmitOrSubmitReport|TSmsFirstOctet::ESmsNoMoreMessagesToSend|TSmsFirstOctet::ESmsVPFInteger),
       
  2141 	iValidityPeriod(iFirstOctet)
       
  2142 	{
       
  2143 	// NOP
       
  2144 	} // TSmsFirstOctet::ESmsMTISubmitOrSubmitReport
       
  2145 
       
  2146 
       
  2147 /**
       
  2148  *  Destructor.
       
  2149  */
       
  2150 CSmsSubmit::~CSmsSubmit()
       
  2151 	{
       
  2152 	delete iServiceCenterAddress;
       
  2153 	delete iDestinationAddress;
       
  2154 	delete iUserData;
       
  2155 	} // TSmsFirstOctet::ESmsMTISubmitOrSubmitReport
       
  2156 
       
  2157 
       
  2158 /**
       
  2159  *  Gets Reject Duplicates flag.
       
  2160  *  
       
  2161  *  SUBMITs with duplicate message reference and destination address can be rejected.
       
  2162  *  
       
  2163  *  @return True if the SC is being instructed to reject duplicates
       
  2164  *  @capability None
       
  2165  */
       
  2166 EXPORT_C TBool CSmsSubmit::RejectDuplicates() const
       
  2167 	{
       
  2168 	LOGGSMU1("CSmsSubmit::RejectDuplicates()");
       
  2169 
       
  2170 	return (iFirstOctet&TSmsFirstOctet::ESmsRejectDuplicatesMask)==TSmsFirstOctet::ESmsRejectDuplicates;
       
  2171 	} // CSmsSubmit::RejectDuplicates
       
  2172 
       
  2173 
       
  2174 /**
       
  2175  *  Sets Reject Duplicates flag.
       
  2176  *  
       
  2177  *  @param aRejectDuplicates True to instruct the SC to reject duplicates
       
  2178  *  @capability None
       
  2179  */
       
  2180 EXPORT_C void CSmsSubmit::SetRejectDuplicates(TBool aRejectDuplicates)
       
  2181 	{
       
  2182 	LOGGSMU2("CSmsSubmit::SetRejectDuplicates(): aRejectDuplicates=%d", aRejectDuplicates);
       
  2183 
       
  2184 	iFirstOctet=aRejectDuplicates? (iFirstOctet&(~TSmsFirstOctet::ESmsRejectDuplicatesMask)|TSmsFirstOctet::ESmsRejectDuplicates):
       
  2185 	                        (iFirstOctet&(~TSmsFirstOctet::ESmsRejectDuplicatesMask)|TSmsFirstOctet::ESmsAcceptDuplicates);
       
  2186 	} // CSmsSubmit::SetRejectDuplicates
       
  2187 
       
  2188 
       
  2189 /**
       
  2190  *  Gets the Validity Period Format.
       
  2191  *  
       
  2192  *  @return Validity Period Format
       
  2193  *  @capability None
       
  2194  */
       
  2195 EXPORT_C TSmsFirstOctet::TSmsValidityPeriodFormat CSmsSubmit::ValidityPeriodFormat() const
       
  2196 	{
       
  2197 	LOGGSMU1("CSmsSubmit::ValidityPeriodFormat()");
       
  2198 
       
  2199 	return iValidityPeriod.ValidityPeriodFormat();
       
  2200 	} // TSmsFirstOctet::TSmsValidityPeriodFormat
       
  2201 
       
  2202 
       
  2203 /**
       
  2204  *  Sets the Validity Period Format.
       
  2205  *  
       
  2206  *  @param aValidityPeriodFormat Validity Period Format
       
  2207  *  @capability None
       
  2208  */
       
  2209 EXPORT_C void CSmsSubmit::SetValidityPeriodFormat(TSmsFirstOctet::TSmsValidityPeriodFormat aValidityPeriodFormat)
       
  2210 	{
       
  2211 	LOGGSMU1("CSmsSubmit::SetValidityPeriodFormat()");
       
  2212 
       
  2213 	iValidityPeriod.SetValidityPeriodFormat(aValidityPeriodFormat);
       
  2214 	} // CSmsSubmit::SetValidityPeriodFormat
       
  2215 
       
  2216 
       
  2217 /**
       
  2218  *  Gets Reply Path flag.
       
  2219  *  
       
  2220  *  If a Reply Path exists, the recipient of the SMS can reply using the same
       
  2221  *  service center address.
       
  2222  *  
       
  2223  *  @return True if Reply Path exists
       
  2224  *  @capability None
       
  2225  */
       
  2226 EXPORT_C TBool CSmsSubmit::ReplyPath() const
       
  2227 	{
       
  2228 	LOGGSMU1("CSmsSubmit::ReplyPath()");
       
  2229 
       
  2230 	return (iFirstOctet&TSmsFirstOctet::ESmsReplyPathMask)==TSmsFirstOctet::ESmsReplyPathExists;
       
  2231 	} // CSmsSubmit::ReplyPath
       
  2232 
       
  2233 
       
  2234 /**
       
  2235  *  Sets Reply Path flag.
       
  2236  *  
       
  2237  *  @param aReplyPath Set to True to set Reply Path
       
  2238  *  @capability None
       
  2239  */
       
  2240 EXPORT_C void CSmsSubmit::SetReplyPath(TBool aReplyPath)
       
  2241 	{
       
  2242 	LOGGSMU2("CSmsSubmit::SetReplyPath(): aReplyPath=%d", aReplyPath);
       
  2243 
       
  2244 	iFirstOctet=aReplyPath? (iFirstOctet&(~TSmsFirstOctet::ESmsReplyPathMask)|TSmsFirstOctet::ESmsReplyPathExists):
       
  2245 	                        (iFirstOctet&(~TSmsFirstOctet::ESmsReplyPathMask)|TSmsFirstOctet::ESmsReplyPathNone);
       
  2246 	} // CSmsSubmit::SetReplyPath
       
  2247 
       
  2248 
       
  2249 /**
       
  2250  *  Gets Status Report Request flag.
       
  2251  *  
       
  2252  *  A sender can request STATUS REPORTs for the SUBMIT being sent.
       
  2253  *  
       
  2254  *  @return True if the sender is requesting Status Reports
       
  2255  *  @capability None
       
  2256  */
       
  2257 EXPORT_C TBool CSmsSubmit::StatusReportRequest() const
       
  2258 	{
       
  2259 	LOGGSMU1("CSmsSubmit::StatusReportRequest()");
       
  2260 
       
  2261 	return (iFirstOctet&TSmsFirstOctet::ESmsStatusReportRequestMask)==TSmsFirstOctet::ESmsStatusReportRequested;
       
  2262 	} // CSmsSubmit::StatusReportRequest
       
  2263 
       
  2264 
       
  2265 /**
       
  2266  *  Sets Status Report Request flag.
       
  2267  *  
       
  2268  *  @param aRequest Status Report Request flag
       
  2269  *  @capability None
       
  2270  */
       
  2271 EXPORT_C void CSmsSubmit::SetStatusReportRequest(TBool aRequest)
       
  2272 	{
       
  2273 	LOGGSMU2("CSmsSubmit::SetStatusReportRequest(): aRequest=%d", aRequest);
       
  2274 
       
  2275 	iFirstOctet=aRequest? (iFirstOctet&(~TSmsFirstOctet::ESmsStatusReportRequestMask)|TSmsFirstOctet::ESmsStatusReportRequested):
       
  2276 	                      (iFirstOctet&(~TSmsFirstOctet::ESmsStatusReportRequestMask)|TSmsFirstOctet::ESmsStatusReportNotRequested);
       
  2277 	} // CSmsSubmit::SetStatusReportRequest
       
  2278 
       
  2279 
       
  2280 /**
       
  2281  *  Gets the Message Reference.
       
  2282  *  
       
  2283  *  @return Message Reference
       
  2284  *  @capability None
       
  2285  */
       
  2286 EXPORT_C TInt CSmsSubmit::MessageReference() const
       
  2287 	{
       
  2288 	LOGGSMU1("CSmsSubmit::MessageReference()");
       
  2289 
       
  2290 	return iMessageReference;
       
  2291 	} // CSmsSubmit::MessageReference
       
  2292 
       
  2293 
       
  2294 /**
       
  2295  *  Sets the Message Reference.
       
  2296  *  
       
  2297  *  @param aMessageReference Message Reference
       
  2298  *  @capability None
       
  2299  */
       
  2300 EXPORT_C void CSmsSubmit::SetMessageReference(TInt aMessageReference)
       
  2301 	{
       
  2302 	LOGGSMU2("CSmsSubmit::SetMessageReference(): aMessageReference=%d",
       
  2303 			 aMessageReference);
       
  2304 	iMessageReference=aMessageReference;
       
  2305 	} // CSmsSubmit::SetMessageReference
       
  2306 
       
  2307 
       
  2308 /**
       
  2309  *  Gets the Validity Period for the SUBMIT.
       
  2310  *  
       
  2311  *  @return Validity Period
       
  2312  *  @capability None
       
  2313  */
       
  2314 EXPORT_C const TTimeIntervalMinutes&  CSmsSubmit::ValidityPeriod() const
       
  2315 	{
       
  2316 	LOGGSMU1("CSmsSubmit::ValidityPeriod()");
       
  2317 
       
  2318 	return iValidityPeriod.TimeIntervalMinutes();
       
  2319 	} // CSmsSubmit::ValidityPeriod
       
  2320 
       
  2321 
       
  2322 /**
       
  2323  *  Sets the Validity Period for the SUBMIT.
       
  2324  *  
       
  2325  *  @param aTimeIntervalMinutes Validity Period
       
  2326  *  @capability None
       
  2327  */
       
  2328 EXPORT_C void CSmsSubmit::SetValidityPeriod(const TTimeIntervalMinutes& aTimeIntervalMinutes)
       
  2329 	{
       
  2330 	LOGGSMU2("CSmsSubmit::SetValidityPeriod(): aTimeIntervalMinutes",
       
  2331 			 aTimeIntervalMinutes.Int());
       
  2332 
       
  2333 	iValidityPeriod.SetTimeIntervalMinutes(aTimeIntervalMinutes);
       
  2334 	} // CSmsSubmit::SetValidityPeriod
       
  2335 
       
  2336 
       
  2337 const TSmsDataCodingScheme* CSmsSubmit::DataCodingScheme() const
       
  2338 	{
       
  2339 	LOGGSMU1("CSmsSubmit::DataCodingScheme()");
       
  2340 
       
  2341 	return &iDataCodingScheme;
       
  2342 	} // CSmsSubmit::DataCodingScheme
       
  2343 
       
  2344 
       
  2345 const TSmsProtocolIdentifier* CSmsSubmit::ProtocolIdentifier() const
       
  2346 	{
       
  2347 	LOGGSMU1("CSmsSubmit::ProtocolIdentifier()");
       
  2348 
       
  2349 	return &iProtocolIdentifier;
       
  2350 	} // CSmsSubmit::ProtocolIdentifier
       
  2351 
       
  2352 
       
  2353 const CSmsUserData* CSmsSubmit::UserDataPtr() const
       
  2354 	{
       
  2355 	LOGGSMU1("CSmsSubmit::UserDataPtr()");
       
  2356 
       
  2357 	return iUserData;
       
  2358 	} // CSmsSubmit::UserDataPtr
       
  2359 
       
  2360 
       
  2361 const CSmsAddress* CSmsSubmit::ToFromAddressPtr() const
       
  2362 	{
       
  2363 	LOGGSMU1("CSmsSubmit::ToFromAddressPtr()");
       
  2364 
       
  2365 	return iDestinationAddress;
       
  2366 	} // CSmsSubmit::ToFromAddressPtr
       
  2367 
       
  2368 
       
  2369 void CSmsSubmit::ConstructL(CCnvCharacterSetConverter& aCharacterSetConverter,RFs& aFs)
       
  2370 	{
       
  2371 	LOGGSMU1("CSmsSubmit::ConstructL()");
       
  2372 
       
  2373 	iServiceCenterAddress=CSmsAddress::NewL(aCharacterSetConverter,aFs);
       
  2374 	iDestinationAddress=CSmsAddress::NewL(aCharacterSetConverter,aFs);
       
  2375 	iUserData=CSmsUserData::NewL(aCharacterSetConverter,aFs,iFirstOctet,iDataCodingScheme);
       
  2376 	} // CSmsSubmit::ConstructL
       
  2377 
       
  2378 
       
  2379 /**
       
  2380  *  Duplicates this CSmsSubmit object.
       
  2381  * 
       
  2382  *  @return  Pointer to the newly created CSmsSubmit object.
       
  2383  */
       
  2384 EXPORT_C CSmsSubmit* CSmsSubmit::DuplicateL() const
       
  2385 	{
       
  2386 	LOGGSMU1("CSmsSubmit::DuplicateL()");
       
  2387 
       
  2388 	CSmsSubmit*  smsSubmit = new (ELeave) CSmsSubmit();
       
  2389 	CleanupStack::PushL(smsSubmit);
       
  2390 	
       
  2391 	smsSubmit->iServiceCenterAddress = iServiceCenterAddress->DuplicateL();
       
  2392 	smsSubmit->iDestinationAddress   = iDestinationAddress->DuplicateL();
       
  2393 	smsSubmit->iUserData             = iUserData->DuplicateL(smsSubmit->iFirstOctet,
       
  2394 															 smsSubmit->iDataCodingScheme);
       
  2395 	smsSubmit->iFirstOctet           = iFirstOctet;
       
  2396 	smsSubmit->iMessageReference     = iMessageReference;
       
  2397 	smsSubmit->iProtocolIdentifier   = iProtocolIdentifier;
       
  2398 	smsSubmit->iDataCodingScheme     = iDataCodingScheme;
       
  2399 	smsSubmit->iValidityPeriod.SetValidityPeriodFormat(iValidityPeriod.ValidityPeriodFormat());
       
  2400 	smsSubmit->iValidityPeriod.SetTimeIntervalMinutes(iValidityPeriod.TimeIntervalMinutes());
       
  2401 	
       
  2402 	CleanupStack::Pop(smsSubmit);
       
  2403 
       
  2404 	return smsSubmit;
       
  2405 	} // CSmsSubmit::DuplicateL
       
  2406 
       
  2407 
       
  2408 TUint8* CSmsSubmit::EncodeL(TUint8* aPtr) const
       
  2409 	{
       
  2410 	LOGGSMU1("CSmsSubmit::EncodeL()");
       
  2411 
       
  2412 	aPtr=iFirstOctet.EncodeL(aPtr);
       
  2413 	aPtr=iMessageReference.EncodeL(aPtr);
       
  2414 	aPtr=iDestinationAddress->EncodeL(aPtr);
       
  2415 	aPtr=iProtocolIdentifier.EncodeL(aPtr);
       
  2416 	aPtr=iDataCodingScheme.EncodeL(aPtr);
       
  2417 	aPtr=iValidityPeriod.EncodeL(aPtr);
       
  2418 	return iUserData->EncodeL(aPtr);
       
  2419 	} // CSmsSubmit::EncodeL
       
  2420 
       
  2421 TUint8* CSmsSubmit::EncodeL(TUint8* aPtr, const TEncodeParams* aEncodeParams) const		
       
  2422 	{
       
  2423 	LOGGSMU1("CSmsSubmit::EncodeL()");
       
  2424 
       
  2425 	aPtr=iFirstOctet.EncodeL(aPtr);
       
  2426 	aPtr=iMessageReference.EncodeL(aPtr);
       
  2427 	aPtr=iDestinationAddress->EncodeL(aPtr);
       
  2428 	aPtr=iProtocolIdentifier.EncodeL(aPtr);
       
  2429 	aPtr=iDataCodingScheme.EncodeL(aPtr);
       
  2430 	aPtr=iValidityPeriod.EncodeL(aPtr, aEncodeParams);
       
  2431 	return iUserData->EncodeL(aPtr);
       
  2432 	} // CSmsSubmit::EncodeL
       
  2433 
       
  2434 void CSmsSubmit::DecodeL(TGsmuLex8& aPdu)
       
  2435 	{
       
  2436 	LOGGSMU1("CSmsSubmit::DecodeL()");
       
  2437 
       
  2438 	iFirstOctet.DecodeL(aPdu);
       
  2439 	iMessageReference.DecodeL(aPdu);
       
  2440 	iDestinationAddress->DecodeL(aPdu);
       
  2441 	iProtocolIdentifier.DecodeL(aPdu);
       
  2442 	iDataCodingScheme.DecodeL(aPdu);
       
  2443 	TInt bit7to4=iDataCodingScheme.Bits7To4();
       
  2444 	TInt lowerLimit = TSmsDataCodingScheme::ESmsDCSReserved5;
       
  2445 	TInt upperLimit = TSmsDataCodingScheme::ESmsDCSReserved8;
       
  2446 	if ((bit7to4>=lowerLimit) &&
       
  2447 	    (bit7to4<=upperLimit))
       
  2448 		User::Leave(KErrGsmSMSUnspecifiedDCSError);
       
  2449 	iValidityPeriod.DecodeL(aPdu);
       
  2450 	iUserData->DecodeL(aPdu);
       
  2451 	} // CSmsSubmit::DecodeL
       
  2452 
       
  2453 
       
  2454 void CSmsSubmit::InternalizeMessagePDUL(RReadStream& aStream)
       
  2455 	{
       
  2456 	LOGGSMU1("CSmsSubmit::InternalizeMessagePDUL()");
       
  2457 
       
  2458 	iServiceCenterAddress->InternalizeL(aStream);
       
  2459 
       
  2460 	aStream >> iFirstOctet;
       
  2461 	aStream >> iMessageReference;
       
  2462 	iDestinationAddress->InternalizeL(aStream);
       
  2463 	aStream >> iProtocolIdentifier;
       
  2464 	aStream >> iDataCodingScheme;
       
  2465 	aStream >> iValidityPeriod;
       
  2466 
       
  2467 	aStream >> *iUserData;
       
  2468 	} // CSmsSubmit::InternalizeMessagePDUL
       
  2469 
       
  2470 
       
  2471 void CSmsSubmit::ExternalizeMessagePDUL(RWriteStream& aStream) const
       
  2472 	{
       
  2473 	iServiceCenterAddress->ExternalizeL(aStream);
       
  2474 
       
  2475 	aStream << iFirstOctet;
       
  2476 	aStream << iMessageReference;
       
  2477 	iDestinationAddress->ExternalizeL(aStream);
       
  2478 	aStream << iProtocolIdentifier;
       
  2479 	aStream << iDataCodingScheme;
       
  2480 	aStream << iValidityPeriod;
       
  2481 
       
  2482 	aStream << *iUserData;
       
  2483 	} // CSmsSubmit::ExternalizeMessagePDUL
       
  2484 
       
  2485 
       
  2486 CSmsDeliverReport::CSmsDeliverReport(TBool aIsRPError):
       
  2487 	CSmsPDU(ESmsDeliverReport),
       
  2488 	iIsRPError((TUint8) aIsRPError),
       
  2489 	iFirstOctet(TSmsFirstOctet::ESmsMTIDeliverOrDeliverReport)
       
  2490 	{
       
  2491 	} // TSmsFirstOctet::ESmsMTIDeliverOrDeliverReport
       
  2492 
       
  2493 
       
  2494 /**
       
  2495  *  Destructor.
       
  2496  */
       
  2497 CSmsDeliverReport::~CSmsDeliverReport()
       
  2498 	{
       
  2499 	delete iServiceCenterAddress;
       
  2500 	delete iUserData;
       
  2501 	} // TSmsFirstOctet::ESmsMTIDeliverOrDeliverReport
       
  2502 
       
  2503 
       
  2504 /**
       
  2505  *  Gets the Failure Cause.
       
  2506  *  
       
  2507  *  @return The Failure Cause
       
  2508  *  @capability None
       
  2509  */
       
  2510 EXPORT_C TInt CSmsDeliverReport::FailureCause() const
       
  2511 	{
       
  2512 	LOGGSMU1("CSmsDeliverReport::FailureCause()");
       
  2513 
       
  2514 	__ASSERT_DEBUG(iIsRPError,Panic(KGsmuPanicNotRPError));
       
  2515 	return iFailureCause.Error();
       
  2516 	} // CSmsDeliverReport::FailureCause
       
  2517 
       
  2518 
       
  2519 /**
       
  2520  *  Sets the Failure Cause.
       
  2521  *  
       
  2522  *  @param aFailureCause The Failure Cause
       
  2523  *  @capability None
       
  2524  */
       
  2525 EXPORT_C void CSmsDeliverReport::SetFailureCause(TSmsFailureCause::TSmsFailureCauseError aFailureCause)
       
  2526 	{
       
  2527 	LOGGSMU1("CSmsDeliverReport::SetFailureCause()");
       
  2528 
       
  2529 	__ASSERT_DEBUG(iIsRPError,Panic(KGsmuPanicNotRPError));
       
  2530 	iFailureCause.SetError(aFailureCause);
       
  2531 	} // CSmsDeliverReport::SetFailureCause
       
  2532 
       
  2533 
       
  2534 const TSmsDataCodingScheme* CSmsDeliverReport::DataCodingScheme() const
       
  2535 	{
       
  2536 	LOGGSMU1("CSmsDeliverReport::DataCodingScheme()");
       
  2537 
       
  2538 	__ASSERT_DEBUG(DataCodingSchemePresent(),Panic(KGsmuPanicDataCodingSchemeNotPresent));
       
  2539 	return &iDataCodingScheme;
       
  2540 	} // CSmsDeliverReport::DataCodingScheme
       
  2541 
       
  2542 
       
  2543 const TSmsProtocolIdentifier* CSmsDeliverReport::ProtocolIdentifier() const
       
  2544 	{
       
  2545 	LOGGSMU1("CSmsDeliverReport::ProtocolIdentifier()");
       
  2546 
       
  2547 	__ASSERT_DEBUG(ProtocolIdentifierPresent(),Panic(KGsmuPanicProtocolIdentifierNotPresent));
       
  2548 	return &iProtocolIdentifier;
       
  2549 	} // CSmsDeliverReport::ProtocolIdentifier
       
  2550 
       
  2551 
       
  2552 const TSmsParameterIndicator* CSmsDeliverReport::ParameterIndicator() const
       
  2553 	{
       
  2554 	LOGGSMU1("CSmsDeliverReport::ParameterIndicator()");
       
  2555 
       
  2556 	return &iParameterIndicator;
       
  2557 	} // CSmsDeliverReport::ParameterIndicator
       
  2558 
       
  2559 
       
  2560 const CSmsUserData* CSmsDeliverReport::UserDataPtr() const
       
  2561 	{
       
  2562 	LOGGSMU1("CSmsDeliverReport::UserDataPtr()");
       
  2563 
       
  2564 	__ASSERT_DEBUG(UserDataPresent(),Panic(KGsmuPanicUserDataNotPresent));
       
  2565 	return iUserData;
       
  2566 	} // CSmsDeliverReport::UserDataPtr
       
  2567 
       
  2568 
       
  2569 void CSmsDeliverReport::ConstructL(CCnvCharacterSetConverter& aCharacterSetConverter,RFs& aFs)
       
  2570 	{
       
  2571 	LOGGSMU1("CSmsDeliverReport::ConstructL()");
       
  2572 
       
  2573 	iServiceCenterAddress=CSmsAddress::NewL(aCharacterSetConverter,aFs);
       
  2574 	iUserData=CSmsUserData::NewL(aCharacterSetConverter,aFs,iFirstOctet,iDataCodingScheme);
       
  2575 	} // CSmsDeliverReport::ConstructL
       
  2576 
       
  2577 
       
  2578 /**
       
  2579  *  Duplicates this CSmsDeliverReport object.
       
  2580  * 
       
  2581  *  @return  Pointer to the newly created CSmsDeliverReport object.
       
  2582  */
       
  2583 EXPORT_C CSmsDeliverReport* CSmsDeliverReport::DuplicateL() const
       
  2584 	{
       
  2585 	LOGGSMU1("CSmsDeliverReport::DuplicateL()");
       
  2586 
       
  2587 	CSmsDeliverReport*  smsDeliverReport = new (ELeave) CSmsDeliverReport(iIsRPError);
       
  2588 	CleanupStack::PushL(smsDeliverReport);
       
  2589 
       
  2590 	smsDeliverReport->iServiceCenterAddress = iServiceCenterAddress->DuplicateL();
       
  2591 	smsDeliverReport->iFirstOctet           = iFirstOctet;
       
  2592 	smsDeliverReport->iFailureCause         = iFailureCause;
       
  2593 	smsDeliverReport->iParameterIndicator   = iParameterIndicator;
       
  2594 	smsDeliverReport->iProtocolIdentifier   = iProtocolIdentifier;
       
  2595 	smsDeliverReport->iDataCodingScheme     = iDataCodingScheme;
       
  2596 	smsDeliverReport->iUserData             = iUserData->DuplicateL(smsDeliverReport->iFirstOctet,
       
  2597 																	smsDeliverReport->iDataCodingScheme);
       
  2598 
       
  2599 	CleanupStack::Pop(smsDeliverReport);
       
  2600 
       
  2601 	return smsDeliverReport;
       
  2602 	} // CSmsDeliverReport::DuplicateL
       
  2603 
       
  2604 
       
  2605 TUint8* CSmsDeliverReport::EncodeL(TUint8* aPtr) const
       
  2606 	{
       
  2607 	LOGGSMU1("CSmsDeliverReport::EncodeL()");
       
  2608 
       
  2609 	aPtr=iFirstOctet.EncodeL(aPtr);
       
  2610 	if (iIsRPError)
       
  2611 		aPtr=iFailureCause.EncodeL(aPtr);
       
  2612 	aPtr=iParameterIndicator.EncodeL(aPtr);
       
  2613 	if (iParameterIndicator.ProtocolIdentifierPresent())
       
  2614 		aPtr=iProtocolIdentifier.EncodeL(aPtr);
       
  2615 	if (iParameterIndicator.DataCodingSchemePresent())
       
  2616 		aPtr=iDataCodingScheme.EncodeL(aPtr);
       
  2617 	if (iParameterIndicator.UserDataPresent())
       
  2618 		aPtr=iUserData->EncodeL(aPtr);
       
  2619 	return aPtr;
       
  2620 	} // CSmsDeliverReport::EncodeL
       
  2621 
       
  2622 TUint8* CSmsDeliverReport::EncodeL(TUint8* aPtr, const TEncodeParams* ) const
       
  2623 	{
       
  2624 	return EncodeL(aPtr);		
       
  2625 	}	
       
  2626 
       
  2627 void CSmsDeliverReport::DecodeL(TGsmuLex8& aPdu)
       
  2628 	{
       
  2629 	LOGGSMU1("CSmsDeliverReport::DecodeL()");
       
  2630 
       
  2631 	iFirstOctet.DecodeL(aPdu);
       
  2632 	if (iIsRPError)
       
  2633 		iFailureCause.DecodeL(aPdu);
       
  2634 	iParameterIndicator.DecodeL(aPdu);
       
  2635 	if (iParameterIndicator.Extension())
       
  2636 		{
       
  2637 		//
       
  2638 		//  Throw away rest of the pdu - some pdus received with this bit set don't appear to conform to 03.40 v7.4.0 spec.
       
  2639 		//  TODO Will need to review later, though this appears safest option now.
       
  2640 		//
       
  2641 		((TSmsOctet&)iParameterIndicator)=TSmsParameterIndicator::ESmsPIDExtension;
       
  2642 		return;
       
  2643 		}
       
  2644 	if (iParameterIndicator.ProtocolIdentifierPresent())
       
  2645 		iProtocolIdentifier.DecodeL(aPdu);
       
  2646 	if (iParameterIndicator.DataCodingSchemePresent())
       
  2647 		{
       
  2648 		iDataCodingScheme.DecodeL(aPdu);
       
  2649 		TInt bit7to4=iDataCodingScheme.Bits7To4();
       
  2650 		TInt lowerLimit = TSmsDataCodingScheme::ESmsDCSReserved5;
       
  2651 	    TInt upperLimit = TSmsDataCodingScheme::ESmsDCSReserved8;
       
  2652        	if ((bit7to4>=lowerLimit) &&
       
  2653 	        (bit7to4<=upperLimit))
       
  2654 		    User::Leave(KErrGsmSMSUnspecifiedDCSError);
       
  2655 		}
       
  2656 	if (iParameterIndicator.UserDataPresent())
       
  2657 		{
       
  2658 		if (!iParameterIndicator.DataCodingSchemePresent())
       
  2659 		    {
       
  2660 		    iParameterIndicator.SetDataCodingSchemePresent(TBool (ETrue));
       
  2661 		    iDataCodingScheme = TSmsDataCodingScheme();
       
  2662 		    }
       
  2663 
       
  2664 		iUserData->DecodeL(aPdu);
       
  2665 		}
       
  2666 	} // CSmsDeliverReport::DecodeL
       
  2667 
       
  2668 
       
  2669 void CSmsDeliverReport::InternalizeMessagePDUL(RReadStream& aStream)
       
  2670 	{
       
  2671 	iServiceCenterAddress->InternalizeL(aStream);
       
  2672 
       
  2673 	aStream >> iIsRPError;
       
  2674 
       
  2675 	aStream >> iFirstOctet;
       
  2676 	aStream >> iFailureCause;
       
  2677 	aStream >> iParameterIndicator;
       
  2678 	aStream >> iProtocolIdentifier;
       
  2679 	aStream >> iDataCodingScheme;
       
  2680 	aStream >> *iUserData;
       
  2681 	} // CSmsDeliverReport::InternalizeMessagePDUL
       
  2682 
       
  2683 
       
  2684 void CSmsDeliverReport::ExternalizeMessagePDUL(RWriteStream& aStream) const
       
  2685 	{
       
  2686 	iServiceCenterAddress->ExternalizeL(aStream);
       
  2687 
       
  2688 	aStream << iIsRPError;
       
  2689 
       
  2690 	aStream << iFirstOctet;
       
  2691 	aStream << iFailureCause;
       
  2692 	aStream << iParameterIndicator;
       
  2693 	aStream << iProtocolIdentifier;
       
  2694 	aStream << iDataCodingScheme;
       
  2695 	aStream << *iUserData;
       
  2696 	} // CSmsDeliverReport::ExternalizeMessagePDUL
       
  2697 
       
  2698 
       
  2699 CSmsSubmitReport::CSmsSubmitReport(TBool aIsRPError):
       
  2700 	CSmsPDU(ESmsSubmitReport),
       
  2701 	iIsRPError((TUint8) aIsRPError),
       
  2702 	iFirstOctet(TSmsFirstOctet::ESmsMTISubmitOrSubmitReport)
       
  2703 	{
       
  2704 	} // TSmsFirstOctet::ESmsMTISubmitOrSubmitReport
       
  2705 
       
  2706 
       
  2707 /**
       
  2708  *  Destructor.
       
  2709  */
       
  2710 CSmsSubmitReport::~CSmsSubmitReport()
       
  2711 	{
       
  2712 	delete iServiceCenterAddress;
       
  2713 	delete iUserData;
       
  2714 	} // TSmsFirstOctet::ESmsMTISubmitOrSubmitReport
       
  2715 
       
  2716 
       
  2717 /**
       
  2718  *  Gets the Failure Cause.
       
  2719  *  
       
  2720  *  @return The Failure Cause
       
  2721  *  @capability None
       
  2722  */
       
  2723 EXPORT_C TInt CSmsSubmitReport::FailureCause() const
       
  2724 	{
       
  2725 	LOGGSMU1("CSmsSubmitReport::FailureCause()");
       
  2726 
       
  2727 	__ASSERT_DEBUG(iIsRPError,Panic(KGsmuPanicNotRPError));
       
  2728 	return iFailureCause.Error();
       
  2729 	} // CSmsSubmitReport::FailureCause
       
  2730 
       
  2731 
       
  2732 /**
       
  2733  *  Sets the Failure Cause.
       
  2734  *  
       
  2735  *  @param aFailureCause The Failure Cause
       
  2736  *  @capability None
       
  2737  */
       
  2738 EXPORT_C void CSmsSubmitReport::SetFailureCause(TSmsFailureCause::TSmsFailureCauseError aFailureCause)
       
  2739 	{
       
  2740 	LOGGSMU1("CSmsSubmitReport::SetFailureCause()");
       
  2741 
       
  2742 	__ASSERT_DEBUG(iIsRPError,Panic(KGsmuPanicNotRPError));
       
  2743 	iFailureCause.SetError(aFailureCause);
       
  2744 	} // CSmsSubmitReport::SetFailureCause
       
  2745 
       
  2746 
       
  2747 const TSmsDataCodingScheme* CSmsSubmitReport::DataCodingScheme() const
       
  2748 	{
       
  2749 	LOGGSMU1("CSmsSubmitReport::DataCodingScheme()");
       
  2750 
       
  2751 	__ASSERT_DEBUG(DataCodingSchemePresent(),Panic(KGsmuPanicDataCodingSchemeNotPresent));
       
  2752 	return &iDataCodingScheme;
       
  2753 	} // CSmsSubmitReport::DataCodingScheme
       
  2754 
       
  2755 
       
  2756 const TSmsProtocolIdentifier* CSmsSubmitReport::ProtocolIdentifier() const
       
  2757 	{
       
  2758 	LOGGSMU1("CSmsSubmitReport::ProtocolIdentifier()");
       
  2759 
       
  2760 	__ASSERT_DEBUG(ProtocolIdentifierPresent(),Panic(KGsmuPanicProtocolIdentifierNotPresent));
       
  2761 	return &iProtocolIdentifier;
       
  2762 	} // CSmsSubmitReport::ProtocolIdentifier
       
  2763 
       
  2764 
       
  2765 const TSmsParameterIndicator* CSmsSubmitReport::ParameterIndicator() const
       
  2766 	{
       
  2767 	LOGGSMU1("CSmsSubmitReport::ParameterIndicator()");
       
  2768 
       
  2769 	return &iParameterIndicator;
       
  2770 	} // CSmsSubmitReport::ParameterIndicator
       
  2771 
       
  2772 
       
  2773 const CSmsUserData* CSmsSubmitReport::UserDataPtr() const
       
  2774 	{
       
  2775 	LOGGSMU1("CSmsSubmitReport::UserDataPtr()");
       
  2776 
       
  2777 	__ASSERT_DEBUG(UserDataPresent(),Panic(KGsmuPanicUserDataNotPresent));
       
  2778 	return iUserData;
       
  2779 	} // CSmsSubmitReport::UserDataPtr
       
  2780 
       
  2781 
       
  2782 void CSmsSubmitReport::ConstructL(CCnvCharacterSetConverter& aCharacterSetConverter,RFs& aFs)
       
  2783 	{
       
  2784 	LOGGSMU1("CSmsSubmitReport::ConstructL()");
       
  2785 
       
  2786 	iServiceCenterAddress=CSmsAddress::NewL(aCharacterSetConverter,aFs);
       
  2787 	iUserData=CSmsUserData::NewL(aCharacterSetConverter,aFs,iFirstOctet,iDataCodingScheme);
       
  2788 	} // CSmsSubmitReport::ConstructL
       
  2789 
       
  2790 
       
  2791 /**
       
  2792  *  Duplicates this CSmsSubmitReport object.
       
  2793  * 
       
  2794  *  @return  Pointer to the newly created CSmsSubmitReport object.
       
  2795  */
       
  2796 EXPORT_C CSmsSubmitReport* CSmsSubmitReport::DuplicateL() const
       
  2797 	{
       
  2798 	LOGGSMU1("CSmsSubmitReport::DuplicateL()");
       
  2799 
       
  2800 	CSmsSubmitReport*  smsSubmitReport = new (ELeave) CSmsSubmitReport(iIsRPError);
       
  2801 	CleanupStack::PushL(smsSubmitReport);
       
  2802 
       
  2803 	smsSubmitReport->iServiceCenterAddress   = iServiceCenterAddress->DuplicateL();
       
  2804 	smsSubmitReport->iFirstOctet             = iFirstOctet;
       
  2805 	smsSubmitReport->iFailureCause           = iFailureCause;
       
  2806 	smsSubmitReport->iParameterIndicator     = iParameterIndicator;
       
  2807 	smsSubmitReport->iServiceCenterTimeStamp = iServiceCenterTimeStamp;
       
  2808 	smsSubmitReport->iProtocolIdentifier     = iProtocolIdentifier;
       
  2809 	smsSubmitReport->iDataCodingScheme       = iDataCodingScheme;
       
  2810 	smsSubmitReport->iUserData               = iUserData->DuplicateL(smsSubmitReport->iFirstOctet,
       
  2811 																	 smsSubmitReport->iDataCodingScheme);
       
  2812 
       
  2813 	CleanupStack::Pop(smsSubmitReport);
       
  2814 
       
  2815 	return smsSubmitReport;
       
  2816 	} // CSmsSubmitReport::DuplicateL
       
  2817 
       
  2818 
       
  2819 TUint8* CSmsSubmitReport::EncodeL(TUint8* aPtr) const
       
  2820 	{
       
  2821 	LOGGSMU1("CSmsSubmitReport::EncodeL()");
       
  2822 
       
  2823 	aPtr=iFirstOctet.EncodeL(aPtr);
       
  2824 	if (iIsRPError)
       
  2825 		aPtr=iFailureCause.EncodeL(aPtr);
       
  2826 	aPtr=iParameterIndicator.EncodeL(aPtr);
       
  2827 	aPtr=iServiceCenterTimeStamp.EncodeL(aPtr);
       
  2828 	if (iParameterIndicator.ProtocolIdentifierPresent())
       
  2829 		aPtr=iProtocolIdentifier.EncodeL(aPtr);
       
  2830 	if (iParameterIndicator.DataCodingSchemePresent())
       
  2831 		aPtr=iDataCodingScheme.EncodeL(aPtr);
       
  2832 	if (iParameterIndicator.UserDataPresent())
       
  2833 		aPtr=iUserData->EncodeL(aPtr);
       
  2834 	return aPtr;
       
  2835 	} // CSmsSubmitReport::EncodeL
       
  2836 
       
  2837 TUint8* CSmsSubmitReport::EncodeL(TUint8* aPtr, const TEncodeParams* ) const
       
  2838 	{
       
  2839 	return EncodeL(aPtr);		
       
  2840 	}	
       
  2841 
       
  2842 void CSmsSubmitReport::DecodeL(TGsmuLex8& aPdu)
       
  2843 	{
       
  2844 	LOGGSMU1("CSmsSubmitReport::DecodeL()");
       
  2845 
       
  2846 	iFirstOctet.DecodeL(aPdu);
       
  2847 	if (iIsRPError)
       
  2848 		iFailureCause.DecodeL(aPdu);
       
  2849 	iParameterIndicator.DecodeL(aPdu);
       
  2850 
       
  2851 	if (iParameterIndicator.Extension())
       
  2852 		{
       
  2853 		//
       
  2854 		//  Throw away rest of the pdu - some pdus received with this bit set don't appear to conform to 03.40 v7.4.0 spec.
       
  2855 		//  TODO Will need to review later, though this appears safest option now.
       
  2856 		//
       
  2857 		((TSmsOctet&)iParameterIndicator)=TSmsParameterIndicator::ESmsPIDExtension;
       
  2858 		return;
       
  2859 		}
       
  2860 
       
  2861 	TInt timeError;
       
  2862 	iServiceCenterTimeStamp.DecodeL(aPdu, timeError);
       
  2863 	if (timeError != KErrNone)
       
  2864 		{
       
  2865 		TTime time;
       
  2866 		time.UniversalTime();
       
  2867 		iServiceCenterTimeStamp.SetTime(time);
       
  2868 		iServiceCenterTimeStamp.SetTimeOffset((User::UTCOffset().Int())/CSmsMessage::E15MinutesRepresentedInSeconds);
       
  2869 		}
       
  2870 
       
  2871 	if (iParameterIndicator.ProtocolIdentifierPresent())
       
  2872 		iProtocolIdentifier.DecodeL(aPdu);
       
  2873 
       
  2874 	if (iParameterIndicator.DataCodingSchemePresent())
       
  2875 		{
       
  2876 		iDataCodingScheme.DecodeL(aPdu);
       
  2877     	TInt bit7to4=iDataCodingScheme.Bits7To4();
       
  2878 	    TInt lowerLimit = TSmsDataCodingScheme::ESmsDCSReserved5;
       
  2879 	    TInt upperLimit = TSmsDataCodingScheme::ESmsDCSReserved8;
       
  2880 	    if ((bit7to4>=lowerLimit) &&
       
  2881 	        (bit7to4<=upperLimit))
       
  2882 
       
  2883 			User::Leave(KErrGsmSMSUnspecifiedDCSError);
       
  2884 		}
       
  2885 	if (iParameterIndicator.UserDataPresent())
       
  2886 		{
       
  2887 		if (!iParameterIndicator.DataCodingSchemePresent())
       
  2888 		    {
       
  2889 		    iParameterIndicator.SetDataCodingSchemePresent(TBool (ETrue));
       
  2890 		    iDataCodingScheme = TSmsDataCodingScheme();
       
  2891 		    }
       
  2892 
       
  2893 		iUserData->DecodeL(aPdu);
       
  2894 		}
       
  2895 	} // CSmsSubmitReport::DecodeL
       
  2896 
       
  2897 
       
  2898 void CSmsSubmitReport::InternalizeMessagePDUL(RReadStream& aStream)
       
  2899 	{
       
  2900 	iServiceCenterAddress->InternalizeL(aStream);
       
  2901 
       
  2902 	aStream >> iIsRPError;
       
  2903 
       
  2904 	aStream >> iFirstOctet;
       
  2905 	aStream >> iFailureCause;
       
  2906 	aStream >> iParameterIndicator;
       
  2907 	aStream >> iServiceCenterTimeStamp;
       
  2908 	aStream >> iProtocolIdentifier;
       
  2909 	aStream >> iDataCodingScheme;
       
  2910 	aStream >> *iUserData;
       
  2911 	} // CSmsSubmitReport::InternalizeMessagePDUL
       
  2912 
       
  2913 
       
  2914 void CSmsSubmitReport::ExternalizeMessagePDUL(RWriteStream& aStream) const
       
  2915 	{
       
  2916 	iServiceCenterAddress->ExternalizeL(aStream);
       
  2917 
       
  2918 	aStream << iIsRPError;
       
  2919 
       
  2920 	aStream << iFirstOctet;
       
  2921 	aStream << iFailureCause;
       
  2922 	aStream << iParameterIndicator;
       
  2923 	aStream << iServiceCenterTimeStamp;
       
  2924 	aStream << iProtocolIdentifier;
       
  2925 	aStream << iDataCodingScheme;
       
  2926 	aStream << *iUserData;
       
  2927 	} // CSmsSubmitReport::ExternalizeMessagePDUL
       
  2928 
       
  2929 
       
  2930 /**
       
  2931  *  Gets More Messages to Send flag.
       
  2932  *  
       
  2933  *  @return True if More Messages to Send flag set
       
  2934  *  @capability None
       
  2935  */
       
  2936 EXPORT_C TBool CSmsStatusReport::MoreMessagesToSend() const
       
  2937 	{
       
  2938 	LOGGSMU1("CSmsStatusReport::MoreMessagesToSend()");
       
  2939 
       
  2940 	return (iFirstOctet&TSmsFirstOctet::ESmsMoreMessagesToSendMask)==TSmsFirstOctet::ESmsMoreMessagesToSend;
       
  2941 	} // CSmsStatusReport::MoreMessagesToSend
       
  2942 
       
  2943 
       
  2944 /**
       
  2945  *  Sets More Messages to Send flag.
       
  2946  *  
       
  2947  *  @param aMore True if More Messages to Send
       
  2948  *  @capability None
       
  2949  */
       
  2950 EXPORT_C void CSmsStatusReport::SetMoreMessagesToSend(TBool aMore)
       
  2951 	{
       
  2952 	LOGGSMU1("CSmsStatusReport::SetMoreMessagesToSend()");
       
  2953 
       
  2954 	iFirstOctet=aMore? (iFirstOctet&(~TSmsFirstOctet::ESmsMoreMessagesToSendMask)|TSmsFirstOctet::ESmsMoreMessagesToSend):
       
  2955 	                   (iFirstOctet&(~TSmsFirstOctet::ESmsMoreMessagesToSendMask)|TSmsFirstOctet::ESmsNoMoreMessagesToSend);
       
  2956 	} // CSmsStatusReport::SetMoreMessagesToSend
       
  2957 
       
  2958 
       
  2959 /**
       
  2960  *  Gets Status Report Qualifier: the field in the Status Report which determines whether it's
       
  2961  *  the result of a SUBMIT or COMMAND.
       
  2962  *  
       
  2963  *  @return Status Report Qualifier
       
  2964  *  @capability None
       
  2965  */
       
  2966 EXPORT_C TSmsFirstOctet::TSmsStatusReportQualifier CSmsStatusReport::StatusReportQualifier() const
       
  2967 	{
       
  2968 	LOGGSMU1("TSmsFirstOctet::TSmsStatusReportQualifier()");
       
  2969 
       
  2970 	return (TSmsFirstOctet::TSmsStatusReportQualifier) (iFirstOctet&TSmsFirstOctet::ESmsStatusReportQualifierMask);
       
  2971 	} // TSmsFirstOctet::TSmsStatusReportQualifier
       
  2972 
       
  2973 
       
  2974 /**
       
  2975  *  Sets Status Report Qualifier to SUBMIT or COMMAND.
       
  2976  *  
       
  2977  *  @param aQualifier Status Report Qualifier
       
  2978  *  @capability None
       
  2979  */
       
  2980 EXPORT_C void CSmsStatusReport::SetStatusReportQualifier(TSmsFirstOctet::TSmsStatusReportQualifier aQualifier)
       
  2981 	{
       
  2982 	LOGGSMU1("CSmsStatusReport::SetStatusReportQualifier()");
       
  2983 
       
  2984 	iFirstOctet=iFirstOctet&(~TSmsFirstOctet::ESmsStatusReportQualifierMask)|aQualifier;
       
  2985 	} // CSmsStatusReport::SetStatusReportQualifier
       
  2986 
       
  2987 
       
  2988 CSmsStatusReport::CSmsStatusReport():
       
  2989 	CSmsPDU(ESmsStatusReport),
       
  2990 	iFirstOctet(TSmsFirstOctet::ESmsMTIStatusReportOrCommand|TSmsFirstOctet::ESmsNoMoreMessagesToSend|TSmsFirstOctet::ESmsStatusReportResultOfSubmit)
       
  2991 	{
       
  2992 	} // TSmsFirstOctet::ESmsMTIStatusReportOrCommand
       
  2993 
       
  2994 
       
  2995 /**
       
  2996  *  Destructor.
       
  2997  */
       
  2998 CSmsStatusReport::~CSmsStatusReport()
       
  2999 	{
       
  3000 	delete iServiceCenterAddress;
       
  3001 	delete iRecipientAddress;
       
  3002 	delete iUserData;
       
  3003 	} // TSmsFirstOctet::ESmsMTIStatusReportOrCommand
       
  3004 
       
  3005 
       
  3006 /**
       
  3007  *  Gets the Message Reference.
       
  3008  *  
       
  3009  *  @return Message Reference
       
  3010  *  @capability None
       
  3011  */
       
  3012 EXPORT_C TInt CSmsStatusReport::MessageReference() const
       
  3013 	{
       
  3014 	LOGGSMU2("CSmsStatusReport::MessageReference %d", (TInt)iMessageReference );
       
  3015 	return iMessageReference;
       
  3016 	} // CSmsStatusReport::MessageReference
       
  3017 
       
  3018 
       
  3019 /**
       
  3020  *  Sets the Message Reference.
       
  3021  *  
       
  3022  *  @param aMessageReference Message Reference
       
  3023  *  @capability None
       
  3024  */
       
  3025 EXPORT_C void CSmsStatusReport::SetMessageReference(TInt aMessageReference)
       
  3026 	{
       
  3027 	iMessageReference=aMessageReference;
       
  3028 	LOGGSMU2("CSmsStatusReport::SetMessageReference %d", (TInt)iMessageReference );
       
  3029 	} // CSmsStatusReport::SetMessageReference
       
  3030 
       
  3031 
       
  3032 /**
       
  3033  *  Gets Service Center Time Stamp.
       
  3034  *  
       
  3035  *  @param aTime Service Center Time Stamp represented in Universal Time.
       
  3036  *  @param aNumQuarterHours +/- Time Zone difference to GMT in quarter hours.
       
  3037  *  @capability None
       
  3038  */
       
  3039 EXPORT_C void CSmsStatusReport::ServiceCenterTimeStamp(TTime& aTime,TInt& aNumQuarterHours)
       
  3040 	{
       
  3041 	LOGGSMU1("CSmsStatusReport::ServiceCenterTimeStamp()");
       
  3042 
       
  3043 	aTime=iServiceCenterTimeStamp.Time();
       
  3044 	aNumQuarterHours=iServiceCenterTimeStamp.TimeOffset();
       
  3045 	} // CSmsStatusReport::ServiceCenterTimeStamp
       
  3046 
       
  3047 
       
  3048 /**
       
  3049  *  Sets the Service Center Time Stamp.
       
  3050  *  
       
  3051  *  @param aTime Service Center Time Stamp represented in Universal Time.
       
  3052  *  @param aNumQuarterHours +/- Time Zone difference to GMT in quarter hours.
       
  3053  *  @capability None
       
  3054  */
       
  3055 EXPORT_C void CSmsStatusReport::SetServiceCenterTimeStamp(const TTime& aTime,TInt& aNumQuarterHours)
       
  3056 	{
       
  3057 	LOGGSMU1("CSmsStatusReport::SetServiceCenterTimeStamp()");
       
  3058 
       
  3059 	iServiceCenterTimeStamp.SetTime(aTime);
       
  3060 	iServiceCenterTimeStamp.SetTimeOffset(aNumQuarterHours);
       
  3061 	} // CSmsStatusReport::SetServiceCenterTimeStamp
       
  3062 
       
  3063 
       
  3064 /**
       
  3065  *  Gets the Discharge Time.
       
  3066  *  
       
  3067  *  @param aTime The Discharge Time represented in Universal Time.
       
  3068  *  @param aNumQuarterHours +/- Time Zone difference to GMT in quarter hours
       
  3069  *  @capability None
       
  3070  */
       
  3071 EXPORT_C void CSmsStatusReport::DischargeTime(TTime& aTime,TInt& aNumQuarterHours)
       
  3072 	{
       
  3073 	LOGGSMU1("CSmsStatusReport::DischargeTime()");
       
  3074 
       
  3075 	aTime=iDischargeTime.Time();
       
  3076 	aNumQuarterHours=iDischargeTime.TimeOffset();
       
  3077 	} // CSmsStatusReport::DischargeTime
       
  3078 
       
  3079 
       
  3080 /**
       
  3081  *  Sets the Discharge Time.
       
  3082  *  
       
  3083  *  @param aTime The Discharge Time represented in Universal Time.
       
  3084  *  @param aNumQuarterHours +/- Time Zone difference to GMT in quarter hours
       
  3085  *  @capability None
       
  3086  */
       
  3087 EXPORT_C void CSmsStatusReport::SetDischargeTime(const TTime& aTime,TInt& aNumQuarterHours)
       
  3088 	{
       
  3089 	LOGGSMU1("CSmsStatusReport::SetDischargeTime()");
       
  3090 
       
  3091 	iDischargeTime.SetTime(aTime);
       
  3092 	iDischargeTime.SetTimeOffset(aNumQuarterHours);
       
  3093 	} // CSmsStatusReport::SetDischargeTime
       
  3094 
       
  3095 
       
  3096 /**
       
  3097  *  Gets the Status of the Message.
       
  3098  *  
       
  3099  *  @return Status
       
  3100  *  @capability None
       
  3101  */
       
  3102 EXPORT_C TSmsStatus::TSmsStatusValue CSmsStatusReport::Status() const
       
  3103 	{
       
  3104 	LOGGSMU2("CSmsStatusReport::Status %d", iStatus.Status());
       
  3105 	return iStatus.Status();
       
  3106 	} // TSmsStatus::TSmsStatusValue
       
  3107 
       
  3108 
       
  3109 /**
       
  3110  *  Sets the Status of the Message.
       
  3111  *  
       
  3112  *  @param aValue Status
       
  3113  *  @capability None
       
  3114  */
       
  3115 EXPORT_C void CSmsStatusReport::SetStatus(TSmsStatus::TSmsStatusValue aValue)
       
  3116 	{
       
  3117 	LOGGSMU1("CSmsStatusReport::SetStatus()");
       
  3118 
       
  3119 	iStatus.SetStatus(aValue);
       
  3120 	} // CSmsStatusReport::SetStatus
       
  3121 
       
  3122 
       
  3123 const TSmsDataCodingScheme* CSmsStatusReport::DataCodingScheme() const
       
  3124 	{
       
  3125 	LOGGSMU1("CSmsStatusReport::DataCodingScheme()");
       
  3126 
       
  3127 	__ASSERT_DEBUG(DataCodingSchemePresent(),Panic(KGsmuPanicDataCodingSchemeNotPresent));
       
  3128 	return &iDataCodingScheme;
       
  3129 	} // CSmsStatusReport::DataCodingScheme
       
  3130 
       
  3131 
       
  3132 const TSmsProtocolIdentifier* CSmsStatusReport::ProtocolIdentifier() const
       
  3133 	{
       
  3134 	LOGGSMU1("CSmsStatusReport::ProtocolIdentifier()");
       
  3135 
       
  3136 	__ASSERT_DEBUG(ProtocolIdentifierPresent(),Panic(KGsmuPanicProtocolIdentifierNotPresent));
       
  3137 	return &iProtocolIdentifier;
       
  3138 	} // CSmsStatusReport::ProtocolIdentifier
       
  3139 
       
  3140 
       
  3141 const TSmsParameterIndicator* CSmsStatusReport::ParameterIndicator() const
       
  3142 	{
       
  3143 	LOGGSMU1("CSmsStatusReport::ParameterIndicator()");
       
  3144 
       
  3145 	__ASSERT_DEBUG(iParameterIndicatorPresent,Panic(KGsmuPanicParameterIndicatorNotPresent));
       
  3146 	return &iParameterIndicator;
       
  3147 	} // CSmsStatusReport::ParameterIndicator
       
  3148 
       
  3149 
       
  3150 const CSmsUserData* CSmsStatusReport::UserDataPtr() const
       
  3151 	{
       
  3152 	LOGGSMU1("CSmsStatusReport::UserDataPtr()");
       
  3153 
       
  3154 	__ASSERT_DEBUG(UserDataPresent(),Panic(KGsmuPanicUserDataNotPresent));
       
  3155 	return iUserData;
       
  3156 	} // CSmsStatusReport::UserDataPtr
       
  3157 
       
  3158 
       
  3159 const CSmsAddress* CSmsStatusReport::ToFromAddressPtr() const
       
  3160 	{
       
  3161 	LOGGSMU1("CSmsStatusReport::ToFromAddressPtr()");
       
  3162 
       
  3163 	return iRecipientAddress;
       
  3164 	} // CSmsStatusReport::ToFromAddressPtr
       
  3165 
       
  3166 
       
  3167 void CSmsStatusReport::ConstructL(CCnvCharacterSetConverter& aCharacterSetConverter,RFs& aFs)
       
  3168 	{
       
  3169 	LOGGSMU1("CSmsStatusReport::ConstructL()");
       
  3170 
       
  3171 	iServiceCenterAddress=CSmsAddress::NewL(aCharacterSetConverter,aFs);
       
  3172 	iRecipientAddress=CSmsAddress::NewL(aCharacterSetConverter,aFs);
       
  3173 	iUserData=CSmsUserData::NewL(aCharacterSetConverter,aFs,iFirstOctet,iDataCodingScheme);
       
  3174 	} // CSmsStatusReport::ConstructL
       
  3175 
       
  3176 
       
  3177 /**
       
  3178  *  Duplicates this CSmsStatusReport object.
       
  3179  * 
       
  3180  *  @return  Pointer to the newly created CSmsStatusReport object.
       
  3181  */
       
  3182 EXPORT_C CSmsStatusReport* CSmsStatusReport::DuplicateL() const
       
  3183 	{
       
  3184 	LOGGSMU1("CSmsStatusReport::DuplicateL()");
       
  3185 
       
  3186 	CSmsStatusReport*  smsStatusReport = new (ELeave) CSmsStatusReport();
       
  3187 	CleanupStack::PushL(smsStatusReport);
       
  3188 
       
  3189 	smsStatusReport->iServiceCenterAddress      = iServiceCenterAddress->DuplicateL();
       
  3190 	smsStatusReport->iParameterIndicatorPresent = iParameterIndicatorPresent;
       
  3191 	smsStatusReport->iFirstOctet                = iFirstOctet;
       
  3192 	smsStatusReport->iMessageReference          = iMessageReference;
       
  3193 	smsStatusReport->iRecipientAddress          = iRecipientAddress->DuplicateL();
       
  3194 	smsStatusReport->iServiceCenterTimeStamp    = iServiceCenterTimeStamp;
       
  3195 	smsStatusReport->iDischargeTime             = iDischargeTime;
       
  3196 	smsStatusReport->iStatus                    = iStatus;
       
  3197 	smsStatusReport->iParameterIndicator        = iParameterIndicator;
       
  3198 	smsStatusReport->iProtocolIdentifier        = iProtocolIdentifier;
       
  3199 	smsStatusReport->iDataCodingScheme          = iDataCodingScheme;
       
  3200 	smsStatusReport->iUserData                  = iUserData->DuplicateL(smsStatusReport->iFirstOctet,
       
  3201 																		smsStatusReport->iDataCodingScheme);
       
  3202 
       
  3203 	CleanupStack::Pop(smsStatusReport);
       
  3204 
       
  3205 	return smsStatusReport;
       
  3206 	} // CSmsStatusReport::DuplicateL
       
  3207 
       
  3208 
       
  3209 TUint8* CSmsStatusReport::EncodeL(TUint8* aPtr) const
       
  3210 	{
       
  3211 	LOGGSMU1("CSmsStatusReport::EncodeL()");
       
  3212 
       
  3213 	aPtr=iFirstOctet.EncodeL(aPtr);
       
  3214 	aPtr=iMessageReference.EncodeL(aPtr);
       
  3215 	aPtr=iRecipientAddress->EncodeL(aPtr);
       
  3216 	aPtr=iServiceCenterTimeStamp.EncodeL(aPtr);
       
  3217 	aPtr=iDischargeTime.EncodeL(aPtr);
       
  3218 	aPtr=iStatus.EncodeL(aPtr);
       
  3219 	if (iParameterIndicatorPresent)
       
  3220 		{
       
  3221 		aPtr=iParameterIndicator.EncodeL(aPtr);
       
  3222 		if (iParameterIndicator.ProtocolIdentifierPresent())
       
  3223 			aPtr=iProtocolIdentifier.EncodeL(aPtr);
       
  3224 		if (iParameterIndicator.DataCodingSchemePresent())
       
  3225 			aPtr=iDataCodingScheme.EncodeL(aPtr);
       
  3226 		if (iParameterIndicator.UserDataPresent())
       
  3227 			aPtr=iUserData->EncodeL(aPtr);
       
  3228 		}
       
  3229 	return aPtr;
       
  3230 	} // CSmsStatusReport::EncodeL
       
  3231 
       
  3232 TUint8* CSmsStatusReport::EncodeL(TUint8* aPtr, const TEncodeParams* ) const
       
  3233 	{
       
  3234 	return EncodeL(aPtr);	
       
  3235 	}
       
  3236 
       
  3237 void CSmsStatusReport::DecodeL(TGsmuLex8& aPdu)
       
  3238 	{
       
  3239 	LOGGSMU1("CSmsStatusReport::DecodeL()");
       
  3240 
       
  3241 	iFirstOctet.DecodeL(aPdu);
       
  3242 	iMessageReference.DecodeL(aPdu);
       
  3243 	iRecipientAddress->DecodeL(aPdu);
       
  3244 
       
  3245 	TInt timeError;
       
  3246 	iServiceCenterTimeStamp.DecodeL(aPdu, timeError);
       
  3247 	if (timeError != KErrNone)
       
  3248 		{
       
  3249 		TTime time;
       
  3250 		time.UniversalTime();
       
  3251 		iServiceCenterTimeStamp.SetTime(time);
       
  3252 		iServiceCenterTimeStamp.SetTimeOffset((User::UTCOffset().Int()) / CSmsMessage::E15MinutesRepresentedInSeconds);
       
  3253 		}
       
  3254 
       
  3255 	iDischargeTime.DecodeL(aPdu, timeError);
       
  3256 	if (timeError != KErrNone)
       
  3257 		{
       
  3258 		TTime time;
       
  3259 		time.UniversalTime();
       
  3260 		iDischargeTime.SetTime(time);
       
  3261 		iDischargeTime.SetTimeOffset((User::UTCOffset().Int()) / CSmsMessage::E15MinutesRepresentedInSeconds);
       
  3262 		}
       
  3263 
       
  3264 	iStatus.DecodeL(aPdu);
       
  3265 
       
  3266 	iParameterIndicatorPresent = (aPdu.Remainder().Length() > 0);
       
  3267 
       
  3268 	if (iParameterIndicatorPresent)
       
  3269 		{
       
  3270 		iParameterIndicator.DecodeL(aPdu);
       
  3271 		if (!iParameterIndicator.Extension())
       
  3272 			{
       
  3273 			if (iParameterIndicator.ProtocolIdentifierPresent())
       
  3274 				iProtocolIdentifier.DecodeL(aPdu);
       
  3275 			if (iParameterIndicator.DataCodingSchemePresent())
       
  3276 				{
       
  3277 				iDataCodingScheme.DecodeL(aPdu);
       
  3278 	            TInt bit7to4=iDataCodingScheme.Bits7To4();
       
  3279 	            TInt lowerLimit = TSmsDataCodingScheme::ESmsDCSReserved5;
       
  3280 	            TInt upperLimit = TSmsDataCodingScheme::ESmsDCSReserved8;
       
  3281 	            if ((bit7to4>=lowerLimit) &&
       
  3282 	                (bit7to4<=upperLimit))
       
  3283                     {
       
  3284                     //
       
  3285                     // defect fix for:  HOE-56GLND
       
  3286                     // Enumerating of status reports with 6210 leaves with
       
  3287                     // (-4688) KErrGsmSMSTpduNotSupported
       
  3288                     // && problems with
       
  3289                     // (-4671) KErrGsmSMSUnspecifiedDCSError
       
  3290 					//User::Leave(KErrGsmSMSUnspecifiedDCSError);
       
  3291                     iParameterIndicator.SetExtension(EFalse);
       
  3292                     iParameterIndicator.SetUserDataPresent(EFalse);
       
  3293                     iParameterIndicator.SetDataCodingSchemePresent(EFalse);
       
  3294                     iParameterIndicator.SetProtocolIdentifierPresent(EFalse);
       
  3295 					aPdu.UnGet();
       
  3296                     }
       
  3297 				}
       
  3298 			if (iParameterIndicator.UserDataPresent())
       
  3299 				{
       
  3300 				if (!iParameterIndicator.DataCodingSchemePresent())
       
  3301                     {
       
  3302 		            iParameterIndicator.SetDataCodingSchemePresent(TBool (ETrue));
       
  3303 		            iDataCodingScheme = TSmsDataCodingScheme();
       
  3304                     }
       
  3305 				// PDEF137451: ETrue parameter indicates that a mismatch between length indicator and actual length is acceptable 
       
  3306 				// (Service Centre may occasionally truncate the user data of a status report PDU) 
       
  3307 				iUserData->DecodeL(aPdu,ETrue);
       
  3308 				}
       
  3309 			}
       
  3310 		else
       
  3311 			{
       
  3312 			// Throw away rest of the pdu - some pdus received with this bit set don't
       
  3313 			// appear to conform to 03.40 v7.4.0 spec.  Will need to review later, though
       
  3314 			// this appears safest option now.
       
  3315 			((TSmsOctet&)iParameterIndicator)=TSmsParameterIndicator::ESmsPIDExtension;
       
  3316 			return;
       
  3317 			}
       
  3318 		}
       
  3319 	} // CSmsStatusReport::DecodeL
       
  3320 
       
  3321 
       
  3322 void CSmsStatusReport::InternalizeMessagePDUL(RReadStream& aStream)
       
  3323 	{
       
  3324 	iServiceCenterAddress->InternalizeL(aStream);
       
  3325 
       
  3326 	iParameterIndicatorPresent=aStream.ReadUint8L();
       
  3327 
       
  3328 	aStream >> iFirstOctet;
       
  3329 	aStream >> iMessageReference;
       
  3330 	iRecipientAddress->InternalizeL(aStream);
       
  3331 	aStream >> iServiceCenterTimeStamp;
       
  3332 	aStream >> iDischargeTime;
       
  3333 	aStream >> iStatus;
       
  3334 	aStream >> iParameterIndicator;
       
  3335 	aStream >> iProtocolIdentifier;
       
  3336 	aStream >> iDataCodingScheme;
       
  3337 	aStream >> *iUserData;
       
  3338 	} // CSmsStatusReport::InternalizeMessagePDUL
       
  3339 
       
  3340 
       
  3341 void CSmsStatusReport::ExternalizeMessagePDUL(RWriteStream& aStream) const
       
  3342 	{
       
  3343 	iServiceCenterAddress->ExternalizeL(aStream);
       
  3344 
       
  3345 	aStream.WriteUint8L(iParameterIndicatorPresent);
       
  3346 
       
  3347 	aStream << iFirstOctet;
       
  3348 	aStream << iMessageReference;
       
  3349 	iRecipientAddress->ExternalizeL(aStream);
       
  3350 	aStream << iServiceCenterTimeStamp;
       
  3351 	aStream << iDischargeTime;
       
  3352 	aStream << iStatus;
       
  3353 	aStream << iParameterIndicator;
       
  3354 	aStream << iProtocolIdentifier;
       
  3355 	aStream << iDataCodingScheme;
       
  3356 	aStream << *iUserData;
       
  3357 	} // CSmsStatusReport::ExternalizeMessagePDUL
       
  3358 
       
  3359 
       
  3360 CSmsCommand::CSmsCommand():
       
  3361 	CSmsPDU(ESmsCommand),
       
  3362 	iFirstOctet(TSmsFirstOctet::ESmsMTIStatusReportOrCommand | TSmsFirstOctet::ESmsStatusReportNotRequested)
       
  3363 	{
       
  3364 	} // TSmsFirstOctet::ESmsMTIStatusReportOrCommand
       
  3365 
       
  3366 
       
  3367 /**
       
  3368  *  Destructor.
       
  3369  */
       
  3370 CSmsCommand::~CSmsCommand()
       
  3371 	{
       
  3372 	delete iServiceCenterAddress;
       
  3373 	delete iDestinationAddress;
       
  3374 	delete iCommandData;
       
  3375 	} // TSmsFirstOctet::ESmsMTIStatusReportOrCommand
       
  3376 
       
  3377 
       
  3378 /**
       
  3379  *  Gets Status Report Request flag.
       
  3380  *  
       
  3381  *  @return True if the sender is requesting Status Reports
       
  3382  *  @capability None
       
  3383  */
       
  3384 EXPORT_C TBool CSmsCommand::StatusReportRequest() const
       
  3385 	{
       
  3386 	LOGGSMU1("CSmsCommand::StatusReportRequest()");
       
  3387 
       
  3388 	return (iFirstOctet&TSmsFirstOctet::ESmsStatusReportRequestMask)==TSmsFirstOctet::ESmsStatusReportRequested;
       
  3389 	} // CSmsCommand::StatusReportRequest
       
  3390 
       
  3391 
       
  3392 /**
       
  3393  *  Sets Status Report Request flag.
       
  3394  *  
       
  3395  *  @param aRequest  Set to True to Request Status Report
       
  3396  *  @capability None
       
  3397  */
       
  3398 EXPORT_C void CSmsCommand::SetStatusReportRequest(TBool aRequest)
       
  3399 	{
       
  3400 	LOGGSMU1("CSmsCommand::SetStatusReportRequest()");
       
  3401 
       
  3402 	__ASSERT_DEBUG(CommandType()==TSmsCommandType::ESmsCommandTypeEnableStatusReportRequest,Panic(KGsmuPanicSetStatusReportRequestNotSupportedForCommandType));
       
  3403 	DoSetStatusReportRequest(aRequest);
       
  3404 	} // CSmsCommand::SetStatusReportRequest
       
  3405 
       
  3406 
       
  3407 /**
       
  3408  *  Gets the Message Reference.
       
  3409  *  
       
  3410  *  @return Message Reference
       
  3411  *  @capability None
       
  3412  */
       
  3413 EXPORT_C TInt CSmsCommand::MessageReference() const
       
  3414 	{
       
  3415 	LOGGSMU1("CSmsCommand::MessageReference()");
       
  3416 
       
  3417 	return iMessageReference;
       
  3418 	} // CSmsCommand::MessageReference
       
  3419 
       
  3420 
       
  3421 /**
       
  3422  *  Sets the Message Reference.
       
  3423  *  
       
  3424  *  @param aMessageReference Message Reference
       
  3425  *  @capability None
       
  3426  */
       
  3427 EXPORT_C void CSmsCommand::SetMessageReference(TInt aMessageReference)
       
  3428 	{
       
  3429 	LOGGSMU1("CSmsCommand::SetMessageReference()");
       
  3430 
       
  3431 	iMessageReference=aMessageReference;
       
  3432 	} // CSmsCommand::SetMessageReference
       
  3433 
       
  3434 
       
  3435 /**
       
  3436  *  Gets the Command Type.
       
  3437  *  
       
  3438  *  @return Command Type
       
  3439  *  @capability None
       
  3440  */
       
  3441 EXPORT_C TInt CSmsCommand::CommandType() const
       
  3442 	{
       
  3443 	LOGGSMU1("CSmsCommand::CommandType()");
       
  3444 
       
  3445 	return iCommandType.CommandType();
       
  3446 	} // CSmsCommand::CommandType
       
  3447 
       
  3448 
       
  3449 /**
       
  3450  *  Sets the Command Type.
       
  3451  *  
       
  3452  *  @param aCommandType Command Type
       
  3453  *  @capability None
       
  3454  */
       
  3455 EXPORT_C void CSmsCommand::SetCommandType(TSmsCommandType::TSmsCommandTypeValue aCommandType)
       
  3456 	{
       
  3457 	LOGGSMU1("CSmsCommand::SetCommandType()");
       
  3458 
       
  3459 	//  Some command types have default status report request
       
  3460 	switch (aCommandType)
       
  3461 		{
       
  3462 		case TSmsCommandType::ESmsCommandTypeEnquiry:
       
  3463 			{
       
  3464 			DoSetStatusReportRequest(ETrue);
       
  3465 			break;
       
  3466 			}
       
  3467 		case TSmsCommandType::ESmsCommandTypeCancel:
       
  3468 		case TSmsCommandType::ESmsCommandTypeDelete:
       
  3469 		case TSmsCommandType::ESmsCommandTypeEnableStatusReportRequest:
       
  3470 			{
       
  3471 			DoSetStatusReportRequest(EFalse);
       
  3472 			break;
       
  3473 			}
       
  3474 		default:
       
  3475 			{
       
  3476 			}
       
  3477 		}
       
  3478 	iCommandType.SetCommandType(aCommandType);
       
  3479 	} // CSmsCommand::SetCommandType
       
  3480 
       
  3481 
       
  3482 /**
       
  3483  *  Gets the Message Number.
       
  3484  *  
       
  3485  *  @return Message Number
       
  3486  *  @capability None
       
  3487  */
       
  3488 EXPORT_C TInt CSmsCommand::MessageNumber() const
       
  3489 	{
       
  3490 	LOGGSMU1("CSmsCommand::MessageNumber()");
       
  3491 
       
  3492 	return iMessageNumber;
       
  3493 	} // CSmsCommand::MessageNumber
       
  3494 
       
  3495 
       
  3496 /**
       
  3497  *  Sets the Message Number.
       
  3498  *  
       
  3499  *  @param aMessageNumber Message Number
       
  3500  *  @capability None
       
  3501  */
       
  3502 EXPORT_C void CSmsCommand::SetMessageNumber(TInt aMessageNumber)
       
  3503 	{
       
  3504 	LOGGSMU1("CSmsCommand::SetMessageNumber()");
       
  3505 
       
  3506 	iMessageNumber=aMessageNumber;
       
  3507 	} // CSmsCommand::SetMessageNumber
       
  3508 
       
  3509 
       
  3510 /**
       
  3511  *  Gets the number of Information Elements in the User Data.
       
  3512  *  
       
  3513  *  @return Number of Information Elements in the User Data
       
  3514  *  @capability None
       
  3515  */
       
  3516 EXPORT_C TInt CSmsCommand::NumInformationElements() const
       
  3517 	{
       
  3518 	LOGGSMU1("CSmsCommand::NumInformationElements()");
       
  3519 
       
  3520 	return iCommandData->NumInformationElements();
       
  3521 	} // CSmsCommand::NumInformationElements
       
  3522 
       
  3523 
       
  3524 /**
       
  3525  *  Gets an Information Element.
       
  3526  *  
       
  3527  *  @param aIndex The Information Element Index within the PDU
       
  3528  *  @return Information Element
       
  3529  *  @capability None
       
  3530  */
       
  3531 EXPORT_C CSmsInformationElement& CSmsCommand::InformationElement(TInt aIndex) const
       
  3532 	{
       
  3533 	LOGGSMU1("CSmsCommand::InformationElement()");
       
  3534 
       
  3535 	return iCommandData->InformationElement(aIndex);
       
  3536 	} // CSmsCommand::InformationElement
       
  3537 
       
  3538 
       
  3539 /**
       
  3540  *  Gets a pointer to the Information Element located at aIndex.
       
  3541  *  
       
  3542  *  @param aIndex The Information Element Index within the PDU
       
  3543  *  @return Pointer to Information Element
       
  3544  *  @capability None
       
  3545  */
       
  3546 CSmsInformationElement*& CSmsCommand::InformationElementPtr(TInt aIndex) const
       
  3547     {
       
  3548     // Ignore in code coverage - not used in SMS stack and not exported
       
  3549     // but cannot be removed as impacts public header.
       
  3550     BULLSEYE_OFF    
       
  3551     LOGGSMU1("CSmsCommand::InformationElementPtr()");
       
  3552     return iCommandData->InformationElementPtr(aIndex);
       
  3553     BULLSEYE_RESTORE
       
  3554     }
       
  3555 
       
  3556 /**
       
  3557  *  Gets index of a specified Information Element.
       
  3558  *  
       
  3559  *  @param aIdentifier Information Element Identifier to match
       
  3560  *  @param aIndex On return, index of the Information Element matching aIdentifier
       
  3561  *  @return True if Information Element present matching aIdentifier
       
  3562  *  @capability None
       
  3563  */
       
  3564 EXPORT_C TBool CSmsCommand::InformationElementIndex(CSmsInformationElement::TSmsInformationElementIdentifier aIdentifier,
       
  3565 		TInt& aIndex) const
       
  3566 	{
       
  3567 	LOGGSMU1("CSmsCommand::InformationElementIndex()");
       
  3568 
       
  3569 	return iCommandData->InformationElementIndex(aIdentifier,aIndex);
       
  3570 	} // CSmsCommand::InformationElementIndex
       
  3571 
       
  3572 
       
  3573 /**
       
  3574  *  Adds an Information Element.
       
  3575  *  
       
  3576  *  @param aIdentifier Information Element Identifier to add
       
  3577  *  @param aData The Information Element data
       
  3578  *  @capability None
       
  3579  */
       
  3580 EXPORT_C void CSmsCommand::AddInformationElementL(CSmsInformationElement::TSmsInformationElementIdentifier aIdentifier, TDesC8& aData)
       
  3581 	{
       
  3582 	LOGGSMU1("CSmsCommand::AddInformationElementL()");
       
  3583 
       
  3584 	iCommandData->AddInformationElementL(aIdentifier,aData);
       
  3585 	} // CSmsCommand::AddInformationElementL
       
  3586 
       
  3587 
       
  3588 /**
       
  3589  *  Removes an Information Element.
       
  3590  *  
       
  3591  *  @param aIndex Index of the Information Element to be removed
       
  3592  *  @capability None
       
  3593  */
       
  3594 EXPORT_C void CSmsCommand::RemoveInformationElement(TInt aIndex)
       
  3595 	{
       
  3596 	LOGGSMU1("CSmsCommand::RemoveInformationElement()");
       
  3597 
       
  3598 	iCommandData->RemoveInformationElement(aIndex);
       
  3599 	} // CSmsCommand::RemoveInformationElement
       
  3600 
       
  3601 
       
  3602 /**
       
  3603  *  Gets the Maximum Data Length of the Command.
       
  3604  *  
       
  3605  *  @return Maximum Data Length of the Command
       
  3606  *  @capability None
       
  3607  */
       
  3608 EXPORT_C TInt CSmsCommand::MaxCommandDataLength() const
       
  3609 	{
       
  3610 	LOGGSMU1("CSmsCommand::MaxCommandDataLength()");
       
  3611 
       
  3612 	return iCommandData->MaxDataLength();
       
  3613 	} // CSmsCommand::MaxCommandDataLength
       
  3614 
       
  3615 
       
  3616 /**
       
  3617  *  Gets the Command Data.
       
  3618  *  
       
  3619  *  @return The Command Data
       
  3620  *  @capability None
       
  3621  */
       
  3622 EXPORT_C TPtrC8 CSmsCommand::CommandData() const
       
  3623 	{
       
  3624 	LOGGSMU1("CSmsCommand::CommandData()");
       
  3625 
       
  3626 	return iCommandData->Data();
       
  3627 	} // CSmsCommand::CommandData
       
  3628 
       
  3629 
       
  3630 /**
       
  3631  *  Sets the Command Data.
       
  3632  *  
       
  3633  *  @param aData The Command Data
       
  3634  *  @capability None
       
  3635  */
       
  3636 EXPORT_C void CSmsCommand::SetCommandDataL(const TDesC8& aData)
       
  3637 	{
       
  3638 	LOGGSMU1("CSmsCommand::SetCommandDataL()");
       
  3639 
       
  3640 	iCommandData->SetDataL(aData);
       
  3641 	} // CSmsCommand::SetCommandDataL
       
  3642 
       
  3643 
       
  3644 const TSmsProtocolIdentifier* CSmsCommand::ProtocolIdentifier() const
       
  3645 	{
       
  3646 	LOGGSMU1("CSmsCommand::ProtocolIdentifier()");
       
  3647 
       
  3648 	return &iProtocolIdentifier;
       
  3649 	} // CSmsCommand::ProtocolIdentifier
       
  3650 
       
  3651 
       
  3652 const CSmsAddress* CSmsCommand::ToFromAddressPtr() const
       
  3653 	{
       
  3654 	LOGGSMU1("CSmsCommand::ToFromAddressPtr()");
       
  3655 
       
  3656 	return iDestinationAddress;
       
  3657 	} // CSmsCommand::ToFromAddressPtr
       
  3658 
       
  3659 
       
  3660 void CSmsCommand::ConstructL(CCnvCharacterSetConverter& aCharacterSetConverter,RFs& aFs)
       
  3661 	{
       
  3662 	LOGGSMU1("CSmsCommand::ConstructL()");
       
  3663 
       
  3664 	iServiceCenterAddress=CSmsAddress::NewL(aCharacterSetConverter,aFs);
       
  3665 	iDestinationAddress=CSmsAddress::NewL(aCharacterSetConverter,aFs);
       
  3666 	iCommandData=CSmsCommandData::NewL(iFirstOctet);
       
  3667 	} // CSmsCommand::ConstructL
       
  3668 
       
  3669 
       
  3670 /**
       
  3671  *  Duplicates this CSmsCommand object.
       
  3672  * 
       
  3673  *  @return  Pointer to the newly created CSmsCommand object.
       
  3674  */
       
  3675 EXPORT_C CSmsCommand* CSmsCommand::DuplicateL() const
       
  3676 	{
       
  3677 	LOGGSMU1("CSmsCommand::DuplicateL()");
       
  3678 
       
  3679 	CSmsCommand*  smsCommand = new (ELeave) CSmsCommand();
       
  3680 	CleanupStack::PushL(smsCommand);
       
  3681 
       
  3682 	smsCommand->iServiceCenterAddress      = iServiceCenterAddress->DuplicateL();
       
  3683 	smsCommand->iFirstOctet                = iFirstOctet;
       
  3684 	smsCommand->iMessageReference          = iMessageReference;
       
  3685 	smsCommand->iProtocolIdentifier        = iProtocolIdentifier;
       
  3686 	smsCommand->iCommandType               = iCommandType;
       
  3687 	smsCommand->iMessageNumber             = iMessageNumber;
       
  3688 	smsCommand->iDestinationAddress        = iDestinationAddress->DuplicateL();
       
  3689 	smsCommand->iCommandData               = iCommandData->DuplicateL();
       
  3690 
       
  3691 	CleanupStack::Pop(smsCommand);
       
  3692 
       
  3693 	return smsCommand;
       
  3694 	} // CSmsCommand::DuplicateL
       
  3695 
       
  3696 
       
  3697 TUint8* CSmsCommand::EncodeL(TUint8* aPtr) const
       
  3698 	{
       
  3699 	LOGGSMU1("CSmsCommand::EncodeL()");
       
  3700 
       
  3701 	aPtr=iFirstOctet.EncodeL(aPtr);
       
  3702 	aPtr=iMessageReference.EncodeL(aPtr);
       
  3703 	aPtr=iProtocolIdentifier.EncodeL(aPtr);
       
  3704 	aPtr=iCommandType.EncodeL(aPtr);
       
  3705 	aPtr=iMessageNumber.EncodeL(aPtr);
       
  3706 	aPtr=iDestinationAddress->EncodeL(aPtr);
       
  3707 	return iCommandData->EncodeL(aPtr);
       
  3708 	} // CSmsCommand::EncodeL
       
  3709 
       
  3710 TUint8* CSmsCommand::EncodeL(TUint8* aPtr, const TEncodeParams* ) const
       
  3711     {
       
  3712     // Ignore in code coverage - not used in SMS stack and not exported
       
  3713     // but cannot be removed as impacts public header.
       
  3714     BULLSEYE_OFF
       
  3715     return EncodeL(aPtr);
       
  3716     BULLSEYE_RESTORE
       
  3717     }	
       
  3718 
       
  3719 void CSmsCommand::DecodeL(TGsmuLex8& aPdu)
       
  3720 	{
       
  3721 	LOGGSMU1("CSmsCommand::DecodeL()");
       
  3722 
       
  3723 	iFirstOctet.DecodeL(aPdu);
       
  3724 	iMessageReference.DecodeL(aPdu);
       
  3725 	iProtocolIdentifier.DecodeL(aPdu);
       
  3726 	iCommandType.DecodeL(aPdu);
       
  3727 	iMessageNumber.DecodeL(aPdu);
       
  3728 	iDestinationAddress->DecodeL(aPdu);
       
  3729 	iCommandData->DecodeL(aPdu);
       
  3730 	} // CSmsCommand::DecodeL
       
  3731 
       
  3732 
       
  3733 void CSmsCommand::InternalizeMessagePDUL(RReadStream& aStream)
       
  3734 	{
       
  3735 	iServiceCenterAddress->InternalizeL(aStream);
       
  3736 
       
  3737 	aStream >> iFirstOctet;
       
  3738 	aStream >> iMessageReference;
       
  3739 	aStream >> iProtocolIdentifier;
       
  3740 	aStream >> iCommandType;
       
  3741 	aStream >> iMessageNumber;
       
  3742 	iDestinationAddress->InternalizeL(aStream);
       
  3743 	iCommandData->InternalizeL(aStream);
       
  3744 	} // CSmsCommand::InternalizeMessagePDUL
       
  3745 
       
  3746 
       
  3747 void CSmsCommand::ExternalizeMessagePDUL(RWriteStream& aStream) const
       
  3748 	{
       
  3749 	iServiceCenterAddress->ExternalizeL(aStream);
       
  3750 
       
  3751 	aStream << iFirstOctet;
       
  3752 	aStream << iMessageReference;
       
  3753 	aStream << iProtocolIdentifier;
       
  3754 	aStream << iCommandType;
       
  3755 	aStream << iMessageNumber;
       
  3756 	iDestinationAddress->ExternalizeL(aStream);
       
  3757 	iCommandData->ExternalizeL(aStream);
       
  3758 	} // CSmsCommand::ExternalizeMessagePDUL
       
  3759 
       
  3760 
       
  3761 void CSmsCommand::DoSetStatusReportRequest(TBool aRequest)
       
  3762 	{
       
  3763 	LOGGSMU1("CSmsCommand::DoSetStatusReportRequest()");
       
  3764 
       
  3765 	iFirstOctet=aRequest? (iFirstOctet&(~TSmsFirstOctet::ESmsStatusReportRequestMask)|TSmsFirstOctet::ESmsStatusReportRequested):
       
  3766 	                      (iFirstOctet&(~TSmsFirstOctet::ESmsStatusReportRequestMask)|TSmsFirstOctet::ESmsAcceptDuplicates);
       
  3767 	} // CSmsCommand::DoSetStatusReportRequest