smsprotocols/smsstack/gsmu/src/Gsmumsg.cpp
branchRCL_3
changeset 65 630d2f34d719
parent 21 2492a6e4aed7
child 66 07a122eea281
equal deleted inserted replaced
61:17af172ffa5f 65:630d2f34d719
     1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 1999-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    17 
    17 
    18 /**
    18 /**
    19  @file
    19  @file
    20 */
    20 */
    21 
    21 
       
    22 
       
    23 #include "OstTraceDefinitions.h"
       
    24 #ifdef OST_TRACE_COMPILER_IN_USE
       
    25 #include "GsmumsgTraces.h"
       
    26 #endif
       
    27 
    22 #include <gsmumsg.h>
    28 #include <gsmumsg.h>
    23 #include "Gsmumain.h"
    29 #include "Gsmumain.h"
    24 #include <gsmubuf.h>
    30 #include <gsmubuf.h>
    25 #include <gsmuset.h>
    31 #include <gsmuset.h>
    26 #include <gsmusar.h>
    32 #include <gsmusar.h>
    27 #include "gsmumsgadditionalattributes.h"
    33 #include "gsmumsgadditionalattributes.h"
    28 #include <gsmuieoperations.h>
    34 #include <gsmuieoperations.h>
    29 #include <gsmunonieoperations.h>
    35 #include <gsmunonieoperations.h>
    30 
    36 
    31 #include <logwrap.h> //  Used for KLogNullId only
    37 #include <logwraplimits.h>
    32 #include <e32uid.h>
    38 #include <e32uid.h>
    33 #include <etelmm.h>
    39 #include <etelmm.h>
    34 #include <logwraplimits.h>
       
    35 
    40 
    36 #include <emsinformationelement.h>
    41 #include <emsinformationelement.h>
    37 #include <emsformatie.h>
    42 #include <emsformatie.h>
    38 #include <emsuserpromptie.h>
    43 #include <emsuserpromptie.h>
    39 #include <emsobjectdistributionie.h>
    44 #include <emsobjectdistributionie.h>
    56  *  @return New CSmsMessage object
    61  *  @return New CSmsMessage object
    57  *  @capability None
    62  *  @capability None
    58  */
    63  */
    59 EXPORT_C CSmsMessage* CSmsMessage::NewL(RFs& aFs, const TGsmSms& aGsmSms,CSmsBufferBase* aBuffer, TBool aIsRPError,TBool aIsMobileTerminated)
    64 EXPORT_C CSmsMessage* CSmsMessage::NewL(RFs& aFs, const TGsmSms& aGsmSms,CSmsBufferBase* aBuffer, TBool aIsRPError,TBool aIsMobileTerminated)
    60 	{
    65 	{
    61 	LOGGSMU1("CSmsMessage::NewL()");
    66 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_NEWL_1, "CSmsMessage::NewL()");
    62 	
    67 	
    63 	CleanupStack::PushL(aBuffer);
    68 	CleanupStack::PushL(aBuffer);
    64 	CSmsMessage* smsmessage=new(ELeave) CSmsMessage(aFs, aBuffer);
    69 	CSmsMessage* smsmessage=new(ELeave) CSmsMessage(aFs, aBuffer);
    65 	CleanupStack::Pop();
    70 	CleanupStack::Pop();
    66 	CleanupStack::PushL(smsmessage);
    71 	CleanupStack::PushL(smsmessage);
    83  *  @return New CSmsMessage object
    88  *  @return New CSmsMessage object
    84  *  @capability None
    89  *  @capability None
    85  */
    90  */
    86 EXPORT_C CSmsMessage* CSmsMessage::NewL(RFs& aFs, CSmsPDU::TSmsPDUType aType,CSmsBufferBase* aBuffer,TBool aIsRPError)
    91 EXPORT_C CSmsMessage* CSmsMessage::NewL(RFs& aFs, CSmsPDU::TSmsPDUType aType,CSmsBufferBase* aBuffer,TBool aIsRPError)
    87 	{
    92 	{
    88 	LOGGSMU1("CSmsMessage::NewL()");
    93 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_NEWL1_1, "CSmsMessage::NewL()");
    89 
    94 
    90 	CleanupStack::PushL(aBuffer);
    95 	CleanupStack::PushL(aBuffer);
    91 	CSmsMessage* smsmessage=new(ELeave) CSmsMessage(aFs, aBuffer);
    96 	CSmsMessage* smsmessage=new(ELeave) CSmsMessage(aFs, aBuffer);
    92 	CleanupStack::Pop();
    97 	CleanupStack::Pop();
    93 	CleanupStack::PushL(smsmessage);
    98 	CleanupStack::PushL(smsmessage);
   101  *  Destructor, frees resources.
   106  *  Destructor, frees resources.
   102  *  @capability None
   107  *  @capability None
   103  */
   108  */
   104 EXPORT_C CSmsMessage::~CSmsMessage()
   109 EXPORT_C CSmsMessage::~CSmsMessage()
   105 	{
   110 	{
   106 	LOGGSMU1("CSmsMessage::~CSmsMessage()");
   111 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_DTOR_1, "CSmsMessage::~CSmsMessage()");
   107 
   112 
   108 	delete iSmsPDU;
   113 	delete iSmsPDU;
   109 	delete iBuffer;
   114 	delete iBuffer;
   110 	delete iCharacterSetConverter;
   115 	delete iCharacterSetConverter;
   111 
   116 
   127  *  @param aStream Stream to read from
   132  *  @param aStream Stream to read from
   128  *  @capability None
   133  *  @capability None
   129  */
   134  */
   130 EXPORT_C void CSmsMessage::InternalizeWithoutBufferL(RReadStream& aStream)
   135 EXPORT_C void CSmsMessage::InternalizeWithoutBufferL(RReadStream& aStream)
   131 	{
   136 	{
   132 	LOGGSMU1("CSmsMessage::InternalizeWithoutBufferL()");
   137 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_INTERNALIZEWITHOUTBUFFERL_1, "CSmsMessage::InternalizeWithoutBufferL()");
   133 
   138 
   134 	InternalizeWithoutBufferAndVersionL(aStream);
   139 	InternalizeWithoutBufferAndVersionL(aStream);
   135 	InternalizeVersionL(aStream);
   140 	InternalizeVersionL(aStream);
   136 
   141 
   137 	iAdditionalInfo->ResetAttributesL();
   142 	iAdditionalInfo->ResetAttributesL();
   151  *  @param aStream Stream to write to
   156  *  @param aStream Stream to write to
   152  *  @capability None
   157  *  @capability None
   153  */
   158  */
   154 EXPORT_C void CSmsMessage::ExternalizeWithoutBufferL(RWriteStream& aStream) const
   159 EXPORT_C void CSmsMessage::ExternalizeWithoutBufferL(RWriteStream& aStream) const
   155 	{
   160 	{
   156 	LOGGSMU1("CSmsMessage::ExternalizeWithoutBufferL()");
   161 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_EXTERNALIZEWITHOUTBUFFERL_1, "CSmsMessage::ExternalizeWithoutBufferL()");
   157 
   162 
   158 	ExternalizeWithoutBufferAndVersionL(aStream);
   163 	ExternalizeWithoutBufferAndVersionL(aStream);
   159 	ExternalizeVersionL(aStream);
   164 	ExternalizeVersionL(aStream);
   160 
   165 
   161 	if (iVersion > ESmsMessageV0)
   166 	if (iVersion > ESmsMessageV0)
   171  *  @param aStream Stream to read from
   176  *  @param aStream Stream to read from
   172  *  @capability None
   177  *  @capability None
   173  */
   178  */
   174 EXPORT_C void CSmsMessage::InternalizeL(RReadStream& aStream)
   179 EXPORT_C void CSmsMessage::InternalizeL(RReadStream& aStream)
   175 	{
   180 	{
   176 	LOGGSMU1("CSmsMessage::InternalizeL()");
   181 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_INTERNALIZEL_1, "CSmsMessage::InternalizeL()");
   177 
   182 
   178 	InternalizeWithoutBufferAndVersionL(aStream);
   183 	InternalizeWithoutBufferAndVersionL(aStream);
   179 	InternalizeBufferL(aStream);
   184 	InternalizeBufferL(aStream);
   180 	InternalizeVersionL(aStream);
   185 	InternalizeVersionL(aStream);
   181 
   186 
   193  *  @param aStream Stream to write to
   198  *  @param aStream Stream to write to
   194  *  @capability None
   199  *  @capability None
   195  */
   200  */
   196 EXPORT_C void CSmsMessage::ExternalizeL(RWriteStream& aStream) const
   201 EXPORT_C void CSmsMessage::ExternalizeL(RWriteStream& aStream) const
   197 	{
   202 	{
   198 	LOGGSMU1("CSmsMessage::ExternalizeL()");
   203 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_EXTERNALIZEL_1, "CSmsMessage::ExternalizeL()");
   199 
   204 
   200 	ExternalizeWithoutBufferAndVersionL(aStream);
   205 	ExternalizeWithoutBufferAndVersionL(aStream);
   201 	ExternalizeBufferL(aStream);
   206 	ExternalizeBufferL(aStream);
   202 	ExternalizeVersionL(aStream);
   207 	ExternalizeVersionL(aStream);
   203 
   208 
   214  *  @return True if the message contains text
   219  *  @return True if the message contains text
   215  *  @capability None
   220  *  @capability None
   216  */
   221  */
   217 EXPORT_C TBool CSmsMessage::TextPresent() const
   222 EXPORT_C TBool CSmsMessage::TextPresent() const
   218 	{
   223 	{
   219 	LOGGSMU1("CSmsMessage::TextPresent()");
   224 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_TEXTPRESENT_1, "CSmsMessage::TextPresent()");
   220 
   225 
   221 	CSmsPDU::TSmsPDUType pdutype=SmsPDU().Type();
   226 	CSmsPDU::TSmsPDUType pdutype=SmsPDU().Type();
   222 	return (pdutype==CSmsPDU::ESmsSubmit) ||
   227 	return (pdutype==CSmsPDU::ESmsSubmit) ||
   223 	       (pdutype==CSmsPDU::ESmsDeliver) ||
   228 	       (pdutype==CSmsPDU::ESmsDeliver) ||
   224 	     (((pdutype==CSmsPDU::ESmsSubmitReport) || (pdutype==CSmsPDU::ESmsDeliverReport) ||
   229 	     (((pdutype==CSmsPDU::ESmsSubmitReport) || (pdutype==CSmsPDU::ESmsDeliverReport) ||
   235  *  @return Number of PDU's
   240  *  @return Number of PDU's
   236  *  @capability None
   241  *  @capability None
   237  */
   242  */
   238 EXPORT_C TInt CSmsMessage::NumMessagePDUsL()
   243 EXPORT_C TInt CSmsMessage::NumMessagePDUsL()
   239 	{
   244 	{
   240 	LOGGSMU1("CSmsMessage::NumMessagePDUsL()");
   245 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_NUMMESSAGEPDUSL_1, "CSmsMessage::NumMessagePDUsL()");
   241 
   246 
   242 	TInt nummessagepdus=1;
   247 	TInt nummessagepdus=1;
   243 	if (IsDecoded())
   248 	if (IsDecoded())
   244 		{
   249 		{
   245 		if (TextPresent())
   250 		if (TextPresent())
   256 	else if (TextPresent() && SmsPDU().TextConcatenated())
   261 	else if (TextPresent() && SmsPDU().TextConcatenated())
   257 		{
   262 		{
   258 		nummessagepdus=SmsPDU().NumConcatenatedMessagePDUs();
   263 		nummessagepdus=SmsPDU().NumConcatenatedMessagePDUs();
   259 		}
   264 		}
   260 
   265 
   261 	LOGGSMU2("CSmsMessage::NumMessagePDUsL() returns %d", nummessagepdus);
   266 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_NUMMESSAGEPDUSL_2, "CSmsMessage::NumMessagePDUsL() returns %d", nummessagepdus);
   262 
   267 
   263 	return nummessagepdus;
   268 	return nummessagepdus;
   264 	} // CSmsMessage::NumMessagePDUsL
   269 	} // CSmsMessage::NumMessagePDUsL
   265 
   270 
   266 
   271 
   280 	if (SmsPDU().TextConcatenated())
   285 	if (SmsPDU().TextConcatenated())
   281 		{
   286 		{
   282 		maxmessagelength=maxmessagelength*0xFF;
   287 		maxmessagelength=maxmessagelength*0xFF;
   283 		}
   288 		}
   284 
   289 
   285 	LOGGSMU2("CSmsMessage::MaxMessageLength() returns %d", maxmessagelength);
   290 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_MAXMESSAGELENGTH_1, "CSmsMessage::MaxMessageLength() returns %d", maxmessagelength);
   286 
   291 
   287 	return maxmessagelength;
   292 	return maxmessagelength;
   288 	} // CSmsMessage::MaxMessageLength
   293 	} // CSmsMessage::MaxMessageLength
   289 
   294 
   290 
   295 
   296 TInt CSmsMessage::ConvertedBufferLengthL(const CSmsBufferBase& aBuffer)
   301 TInt CSmsMessage::ConvertedBufferLengthL(const CSmsBufferBase& aBuffer)
   297     {
   302     {
   298     // Ignore in code coverage - not used in SMS stack and not exported
   303     // Ignore in code coverage - not used in SMS stack and not exported
   299     // but cannot be removed as impacts public header.
   304     // but cannot be removed as impacts public header.
   300     BULLSEYE_OFF    
   305     BULLSEYE_OFF    
   301     LOGGSMU1("CSmsMessage::ConvertedBufferLengthL()");
   306     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_CONVERTEDBUFFERLENGTHL_1, "CSmsMessage::ConvertedBufferLengthL()");
   302     
   307     
   303     TInt convertedBufferLength=0;
   308     TInt convertedBufferLength=0;
   304     CSmsAlphabetConverter* converter=CSmsAlphabetConverter::NewLC(*iCharacterSetConverter,iFs,SmsPDU().Alphabet(),BinaryData());
   309     CSmsAlphabetConverter* converter=CSmsAlphabetConverter::NewLC(*iCharacterSetConverter,iFs,SmsPDU().Alphabet(),BinaryData());
   305     CSmsBufferSegmenter* segmenter=CSmsBufferSegmenter::NewLC(*converter,aBuffer);
   310     CSmsBufferSegmenter* segmenter=CSmsBufferSegmenter::NewLC(*converter,aBuffer);
   306     convertedBufferLength=segmenter->TotalConvertedLengthL(iAdditionalInfo->Alternative7bitEncoding());
   311     convertedBufferLength=segmenter->TotalConvertedLengthL(iAdditionalInfo->Alternative7bitEncoding());
   307     CleanupStack::PopAndDestroy(2, converter);
   312     CleanupStack::PopAndDestroy(2, converter);
   308     
   313     
   309     LOGGSMU2("CSmsMessage::ConvertedBufferLengthL() returns %d", convertedBufferLength);
   314     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_CONVERTEDBUFFERLENGTHL_2, "CSmsMessage::ConvertedBufferLengthL() returns %d", convertedBufferLength);
   310     
   315     
   311     return convertedBufferLength;
   316     return convertedBufferLength;
   312     BULLSEYE_RESTORE
   317     BULLSEYE_RESTORE
   313     }
   318     }
   314 
   319 
   324  *  @return Message length
   329  *  @return Message length
   325  *  @capability None
   330  *  @capability None
   326  */
   331  */
   327 EXPORT_C TInt CSmsMessage::MessageLengthL()
   332 EXPORT_C TInt CSmsMessage::MessageLengthL()
   328 	{
   333 	{
   329 	LOGGSMU1("CSmsMessage::MessageLengthL()");
   334 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_MESSAGELENGTHL_1, "CSmsMessage::MessageLengthL()");
   330 
   335 
   331 	TInt messagelength=0;
   336 	TInt messagelength=0;
   332 	if (!SmsPDU().TextCompressed())
   337 	if (!SmsPDU().TextCompressed())
   333 		{
   338 		{
   334 		messagelength=iBuffer->Length();
   339 		messagelength=iBuffer->Length();
   343 
   348 
   344 
   349 
   345 EXPORT_C void CSmsMessage::GetEncodingInfoL(TInt& aPdus, TInt& aUnconvertedChars,
   350 EXPORT_C void CSmsMessage::GetEncodingInfoL(TInt& aPdus, TInt& aUnconvertedChars,
   346 		                                    TInt& aDowngradedChars, TInt& aFreeUDUnitsInLastPDU)
   351 		                                    TInt& aDowngradedChars, TInt& aFreeUDUnitsInLastPDU)
   347 	{
   352 	{
   348 	LOGGSMU1("CSmsMessage::GetEncodingInfoL()");
   353 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_GETENCODINGINFOL_1, "CSmsMessage::GetEncodingInfoL()");
   349 
   354 
   350 	aPdus                 = 1;
   355 	aPdus                 = 1;
   351 	aUnconvertedChars     = 0;
   356 	aUnconvertedChars     = 0;
   352 	aDowngradedChars      = 0;
   357 	aDowngradedChars      = 0;
   353 	aFreeUDUnitsInLastPDU = 0;
   358 	aFreeUDUnitsInLastPDU = 0;
   393 			aDowngradedChars      = 0;
   398 			aDowngradedChars      = 0;
   394 			aFreeUDUnitsInLastPDU = 0;
   399 			aFreeUDUnitsInLastPDU = 0;
   395 			}
   400 			}
   396 		}
   401 		}
   397 
   402 
   398 	LOGGSMU2("CSmsMessage::GetEncodingInfoL(): aPdus=%d", aPdus);
   403 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_GETENCODINGINFOL_2, "CSmsMessage::GetEncodingInfoL(): aPdus=%d", aPdus);
   399 	LOGGSMU2("CSmsMessage::GetEncodingInfoL(): aUnconvertedChars=%d", aUnconvertedChars);
   404 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_GETENCODINGINFOL_3, "CSmsMessage::GetEncodingInfoL(): aUnconvertedChars=%d", aUnconvertedChars);
   400 	LOGGSMU2("CSmsMessage::GetEncodingInfoL(): aDowngradedChars=%d", aDowngradedChars);
   405 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_GETENCODINGINFOL_4, "CSmsMessage::GetEncodingInfoL(): aDowngradedChars=%d", aDowngradedChars);
   401 	LOGGSMU2("CSmsMessage::GetEncodingInfoL(): aFreeUDUnitsInLastPDU=%d", aFreeUDUnitsInLastPDU);
   406 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_GETENCODINGINFOL_5, "CSmsMessage::GetEncodingInfoL(): aFreeUDUnitsInLastPDU=%d", aFreeUDUnitsInLastPDU);
   402 	} // CSmsMessage::GetEncodingInfoL
   407 	} // CSmsMessage::GetEncodingInfoL
   403 
   408 
   404 
   409 
   405 /**
   410 /**
   406  *  Gets the User Data Settings.
   411  *  Gets the User Data Settings.
   408  *  @param aSettings User Data Settings
   413  *  @param aSettings User Data Settings
   409  *  @capability None
   414  *  @capability None
   410  */
   415  */
   411 EXPORT_C void CSmsMessage::UserDataSettings(TSmsUserDataSettings& aSettings) const
   416 EXPORT_C void CSmsMessage::UserDataSettings(TSmsUserDataSettings& aSettings) const
   412 	{
   417 	{
   413 	LOGGSMU1("CSmsMessage::UserDataSettings()");
   418 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_USERDATASETTINGS_1, "CSmsMessage::UserDataSettings()");
   414 
   419 
   415 	__ASSERT_DEBUG(TextPresent(),Panic(KGsmuPanicTextNotPresent));
   420 	__ASSERT_DEBUG(TextPresent(),Panic(KGsmuPanicTextNotPresent));
   416 	aSettings.SetAlphabet(SmsPDU().Alphabet());
   421 	aSettings.SetAlphabet(SmsPDU().Alphabet());
   417 	aSettings.SetTextCompressed(SmsPDU().TextCompressed());
   422 	aSettings.SetTextCompressed(SmsPDU().TextCompressed());
   418 	TBool is16bit;
   423 	TBool is16bit;
   427  *  @param aSettings User Data Settings
   432  *  @param aSettings User Data Settings
   428  *  @capability None
   433  *  @capability None
   429  */
   434  */
   430 EXPORT_C void CSmsMessage::SetUserDataSettingsL(const TSmsUserDataSettings& aSettings)
   435 EXPORT_C void CSmsMessage::SetUserDataSettingsL(const TSmsUserDataSettings& aSettings)
   431 	{
   436 	{
   432 	LOGGSMU1("CSmsMessage::SetUserDataSettingsL()");
   437 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_SETUSERDATASETTINGSL_1, "CSmsMessage::SetUserDataSettingsL()");
   433 
   438 
   434 	__ASSERT_DEBUG(TextPresent(),Panic(KGsmuPanicTextNotPresent));
   439 	__ASSERT_DEBUG(TextPresent(),Panic(KGsmuPanicTextNotPresent));
   435 	SmsPDU().SetAlphabet(aSettings.Alphabet());
   440 	SmsPDU().SetAlphabet(aSettings.Alphabet());
   436 	SmsPDU().SetTextCompressed(aSettings.TextCompressed());
   441 	SmsPDU().SetTextCompressed(aSettings.TextCompressed());
   437 	TBool is16bit;
   442 	TBool is16bit;
   463  *  @param aOptions Combination of TSmsOptimizationFlags
   468  *  @param aOptions Combination of TSmsOptimizationFlags
   464  *  @capability None
   469  *  @capability None
   465  */
   470  */
   466 EXPORT_C void CSmsMessage::OptimizeSettingsL(TInt aOptions)
   471 EXPORT_C void CSmsMessage::OptimizeSettingsL(TInt aOptions)
   467 	{
   472 	{
   468 	LOGGSMU1("CSmsMessage::OptimizeSettingsL()");
   473 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_OPTIMIZESETTINGSL_1, "CSmsMessage::OptimizeSettingsL()");
   469 
   474 
   470 	__ASSERT_DEBUG(TextPresent(),Panic(KGsmuPanicTextNotPresent));
   475 	__ASSERT_DEBUG(TextPresent(),Panic(KGsmuPanicTextNotPresent));
   471 	__ASSERT_DEBUG(IsDecoded(),Panic(KGsmuPanicNotDecoded));
   476 	__ASSERT_DEBUG(IsDecoded(),Panic(KGsmuPanicNotDecoded));
   472 
   477 
   473 	if (aOptions&ESmsFlagOptimizeAlphabet && (SmsPDU().Alphabet()==TSmsDataCodingScheme::ESmsAlphabet7Bit))
   478 	if (aOptions&ESmsFlagOptimizeAlphabet && (SmsPDU().Alphabet()==TSmsDataCodingScheme::ESmsAlphabet7Bit))
   520  * 
   525  * 
   521  *  @capability None
   526  *  @capability None
   522  */
   527  */
   523 EXPORT_C TSmsEncoding CSmsMessage::Alternative7bitEncoding() const
   528 EXPORT_C TSmsEncoding CSmsMessage::Alternative7bitEncoding() const
   524 	{
   529 	{
   525 	LOGGSMU1("CSmsMessage::Alternative7bitEncoding()");
   530 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_ALTERNATIVE7BITENCODING_1, "CSmsMessage::Alternative7bitEncoding()");
   526 
   531 
   527 	return iAdditionalInfo->Alternative7bitEncoding();
   532 	return iAdditionalInfo->Alternative7bitEncoding();
   528 	} // CSmsMessage::Alternative7bitEncoding
   533 	} // CSmsMessage::Alternative7bitEncoding
   529 
   534 
   530 
   535 
   541  * 
   546  * 
   542  *  @capability None
   547  *  @capability None
   543  */
   548  */
   544 EXPORT_C TInt CSmsMessage::SetAlternative7bitEncoding(TSmsEncoding aEncoding)
   549 EXPORT_C TInt CSmsMessage::SetAlternative7bitEncoding(TSmsEncoding aEncoding)
   545 	{
   550 	{
   546 	LOGGSMU2("CSmsMessage::SetAlternative7bitEncoding(%d)", aEncoding);
   551 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_SETALTERNATIVE7BITENCODING_1, "CSmsMessage::SetAlternative7bitEncoding(%d)", aEncoding);
   547 
   552 
   548 	//
   553 	//
   549 	// Get the encoders that would be used for this encoding method.
   554 	// Get the encoders that would be used for this encoding method.
   550 	// The function will also check that the required encoder is present.
   555 	// The function will also check that the required encoder is present.
   551 	//
   556 	//
   576  *  
   581  *  
   577  *  @param aEncoding  Encoding setting to merge.
   582  *  @param aEncoding  Encoding setting to merge.
   578  */
   583  */
   579 void CSmsMessage::MergeAlternative7bitEncoding(TSmsEncoding aEncoding) const
   584 void CSmsMessage::MergeAlternative7bitEncoding(TSmsEncoding aEncoding) const
   580 	{
   585 	{
   581 	LOGGSMU3("CSmsMessage::MergeAlternative7bitEncoding(): aEncoding=%d (currently %d)",
   586 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_MERGEALTERNATIVE7BITENCODING_1, "CSmsMessage::MergeAlternative7bitEncoding(): aEncoding=%d (currently %d)",aEncoding, iAdditionalInfo->Alternative7bitEncoding());
   582 			 aEncoding, iAdditionalInfo->Alternative7bitEncoding());
       
   583 
   587 
   584 	switch (iAdditionalInfo->Alternative7bitEncoding())
   588 	switch (iAdditionalInfo->Alternative7bitEncoding())
   585 		{
   589 		{
   586 		case ESmsEncodingNone:
   590 		case ESmsEncodingNone:
   587 			{
   591 			{
   637 			{
   641 			{
   638 			// NOP - Cannot merge anything into these...
   642 			// NOP - Cannot merge anything into these...
   639 			}
   643 			}
   640 		};
   644 		};
   641 
   645 
   642 	LOGGSMU2("CSmsMessage::MergeAlternative7bitEncoding(): New encoding=%d",
   646 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_MERGEALTERNATIVE7BITENCODING_2, "CSmsMessage::MergeAlternative7bitEncoding(): New encoding=%d",iAdditionalInfo->Alternative7bitEncoding());
   643 			 iAdditionalInfo->Alternative7bitEncoding());
       
   644 	} // CSmsMessage::MergeAlternative7bitEncoding
   647 	} // CSmsMessage::MergeAlternative7bitEncoding
   645 
   648 
   646 
   649 
   647 /**
   650 /**
   648  *  Tests if a buffer can be encoded without loss of information.
   651  *  Tests if a buffer can be encoded without loss of information.
   658  *  @capability None
   661  *  @capability None
   659  */
   662  */
   660 EXPORT_C TBool CSmsMessage::IsSupportedL(const TDesC& aDes, TInt& aNumberOfUnconvertibleCharacters,
   663 EXPORT_C TBool CSmsMessage::IsSupportedL(const TDesC& aDes, TInt& aNumberOfUnconvertibleCharacters,
   661 		                                 TInt& aIndexOfFirstUnconvertibleCharacter)
   664 		                                 TInt& aIndexOfFirstUnconvertibleCharacter)
   662 	{
   665 	{
   663 	LOGGSMU1("[1] CSmsMessage::IsSupportedL()");
   666 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_ISSUPPORTEDL_1, "[1] CSmsMessage::IsSupportedL()");
   664 
   667 
   665 	__ASSERT_DEBUG(TextPresent(), Panic(KGsmuPanicTextNotPresent));
   668 	__ASSERT_DEBUG(TextPresent(), Panic(KGsmuPanicTextNotPresent));
   666 
   669 
   667 	aNumberOfUnconvertibleCharacters    = 0;
   670 	aNumberOfUnconvertibleCharacters    = 0;
   668 	aIndexOfFirstUnconvertibleCharacter = aDes.Length();
   671 	aIndexOfFirstUnconvertibleCharacter = aDes.Length();
   698 EXPORT_C TBool CSmsMessage::IsSupportedL(const TDesC& aDes, TInt& aNumberOfUnconvertibleCharacters,
   701 EXPORT_C TBool CSmsMessage::IsSupportedL(const TDesC& aDes, TInt& aNumberOfUnconvertibleCharacters,
   699 		                                 TInt& aNumberOfDowngradedCharacters,
   702 		                                 TInt& aNumberOfDowngradedCharacters,
   700 		                                 TInt& aNumberRequiringAlternativeEncoding,
   703 		                                 TInt& aNumberRequiringAlternativeEncoding,
   701 		                                 TInt& aIndexOfFirstUnconvertibleCharacter) const
   704 		                                 TInt& aIndexOfFirstUnconvertibleCharacter) const
   702 	{
   705 	{
   703 	LOGGSMU1("[2] CSmsMessage::IsSupportedL()");
   706 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_ISSUPPORTEDL1_1, "[2] CSmsMessage::IsSupportedL()");
   704 
   707 
   705 	__ASSERT_DEBUG(TextPresent(), Panic(KGsmuPanicTextNotPresent));
   708 	__ASSERT_DEBUG(TextPresent(), Panic(KGsmuPanicTextNotPresent));
   706 
   709 
   707 	aNumberOfUnconvertibleCharacters    = 0;
   710 	aNumberOfUnconvertibleCharacters    = 0;
   708 	aNumberOfDowngradedCharacters       = 0;
   711 	aNumberOfDowngradedCharacters       = 0;
   732  *  @param aReference Sets a Concatenated Message Reference (default 0)
   735  *  @param aReference Sets a Concatenated Message Reference (default 0)
   733  *  @capability None
   736  *  @capability None
   734  */
   737  */
   735 EXPORT_C void CSmsMessage::EncodeMessagePDUsL(CArrayFix<TGsmSms>& aSmsArray, TInt aReference)
   738 EXPORT_C void CSmsMessage::EncodeMessagePDUsL(CArrayFix<TGsmSms>& aSmsArray, TInt aReference)
   736 	{
   739 	{
   737 	LOGGSMU2("CSmsMessage::EncodeMessagePDUsL(): aReference=%d", aReference);
   740 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_ENCODEMESSAGEPDUSL_1, "CSmsMessage::EncodeMessagePDUsL(): aReference=%d", aReference);
   738 
   741 
   739 	__ASSERT_DEBUG((aSmsArray.Count()==0),Panic(KGsmuPanicSmsArrayNotEmpty));
   742 	__ASSERT_DEBUG((aSmsArray.Count()==0),Panic(KGsmuPanicSmsArrayNotEmpty));
   740 	
   743 	
   741 	if (TextPresent())
   744 	if (TextPresent())
   742 		{
   745 		{
   789  *  
   792  *  
   790  *  @leave KErrAlreadyExists or KErrAlreadyExists
   793  *  @leave KErrAlreadyExists or KErrAlreadyExists
   791  */
   794  */
   792 void CSmsMessage::PrepareCommandMessageL()
   795 void CSmsMessage::PrepareCommandMessageL()
   793     {
   796     {
   794     LOGGSMU1("CSmsMessage::PrepareCommandMessageL()");
   797     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_PREPARECOMMANDMESSAGEL_1, "CSmsMessage::PrepareCommandMessageL()");
   795 
   798 
   796     if (SmsPDU().Type()==CSmsPDU::ESmsCommand)
   799     if (SmsPDU().Type()==CSmsPDU::ESmsCommand)
   797         {
   800         {
   798         CSmsCommand& command = static_cast<CSmsCommand&>(SmsPDU());
   801         CSmsCommand& command = static_cast<CSmsCommand&>(SmsPDU());
   799 
   802 
   812                         command.AddInformationElementL(informationElement.Identifier(), data);
   815                         command.AddInformationElementL(informationElement.Identifier(), data);
   813                         }
   816                         }
   814                     break;
   817                     break;
   815                     }
   818                     }
   816                 default:
   819                 default:
   817                 LOGGSMU2("CSmsMessage::PrepareCommandMessageL,default switch category = %d, id = %d", category);
   820                 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_PREPARECOMMANDMESSAGEL_2, "CSmsMessage::PrepareCommandMessageL,default switch category = %d", category);
   818                     break;
   821                     break;
   819                 }
   822                 }
   820             }
   823             }
   821         }
   824         }
   822     } // CSmsMessage::PrepareCommandMessageL
   825     } // CSmsMessage::PrepareCommandMessageL
   831  *  @param aSmsArray Concatenated message
   834  *  @param aSmsArray Concatenated message
   832  *  @capability None
   835  *  @capability None
   833  */
   836  */
   834 EXPORT_C void CSmsMessage::DecodeMessagePDUsL(const CArrayFix<TGsmSms>& aSmsArray)
   837 EXPORT_C void CSmsMessage::DecodeMessagePDUsL(const CArrayFix<TGsmSms>& aSmsArray)
   835 	{
   838 	{
   836     LOGGSMU2("CSmsMessage::DecodeMessagePDUsL(): PDUs=%d", aSmsArray.Count());
   839     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_DECODEMESSAGEPDUSL_1, "CSmsMessage::DecodeMessagePDUsL(): PDUs=%d", aSmsArray.Count());
   837 
   840 
   838 	TInt count=aSmsArray.Count();
   841 	TInt count=aSmsArray.Count();
   839 	SetIsComplete(ETrue);
   842 	SetIsComplete(ETrue);
   840 	CArrayPtrFlat<CSmsPDU>* smspduarray=new(ELeave) CArrayPtrFlat<CSmsPDU>(8);
   843 	CArrayPtrFlat<CSmsPDU>* smspduarray=new(ELeave) CArrayPtrFlat<CSmsPDU>(8);
   841 	CleanupStack::PushL(smspduarray);
   844 	CleanupStack::PushL(smspduarray);
   889  *			incomplete message for a particular concatenated message.
   892  *			incomplete message for a particular concatenated message.
   890  *  @capability None
   893  *  @capability None
   891  */
   894  */
   892 EXPORT_C void CSmsMessage::DecodePartialCompleteMessagePDUsL(const CArrayFix<TGsmSms>& aSmsArray, TBool aLastPartialCompleteMsg)
   895 EXPORT_C void CSmsMessage::DecodePartialCompleteMessagePDUsL(const CArrayFix<TGsmSms>& aSmsArray, TBool aLastPartialCompleteMsg)
   893 	{
   896 	{
   894 	LOGGSMU2("CSmsMessage::DecodePartialCompleteMessagePDUsL(): PDUs=%d", aSmsArray.Count());
   897 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_DECODEPARTIALCOMPLETEMESSAGEPDUSL_1, "CSmsMessage::DecodePartialCompleteMessagePDUsL(): PDUs=%d", aSmsArray.Count());
   895 
   898 
   896 	TInt count=aSmsArray.Count();
   899 	TInt count=aSmsArray.Count();
   897 	SetIsComplete(EFalse);
   900 	SetIsComplete(EFalse);
   898 	CArrayPtrFlat<CSmsPDU>* smspduarray=new(ELeave) CArrayPtrFlat<CSmsPDU>(8);
   901 	CArrayPtrFlat<CSmsPDU>* smspduarray=new(ELeave) CArrayPtrFlat<CSmsPDU>(8);
   899 	CleanupStack::PushL(smspduarray);
   902 	CleanupStack::PushL(smspduarray);
   976     __ASSERT_DEBUG(result, Panic(KGSMUPanicUserTimeZoneOffsetOutOfRange));
   979     __ASSERT_DEBUG(result, Panic(KGSMUPanicUserTimeZoneOffsetOutOfRange));
   977     } // NMobileSmsStore::EStoredMessageUnread
   980     } // NMobileSmsStore::EStoredMessageUnread
   978 
   981 
   979 void CSmsMessage::ConstructL(const TGsmSms& aGsmSms, TBool aIsRPError,TBool aIsMobileTerminated)
   982 void CSmsMessage::ConstructL(const TGsmSms& aGsmSms, TBool aIsRPError,TBool aIsMobileTerminated)
   980 	{
   983 	{
   981     LOGGSMU1("CSmsMessage::ConstructL()");
   984     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_CONSTRUCTL_1, "CSmsMessage::ConstructL()");
   982 
   985 
   983 	iCharacterSetConverter=CCnvCharacterSetConverter::NewL();
   986 	iCharacterSetConverter=CCnvCharacterSetConverter::NewL();
   984 	iInformationElementArray = new (ELeave) RPointerArray<CEmsInformationElement>(8);
   987 	iInformationElementArray = new (ELeave) RPointerArray<CEmsInformationElement>(8);
   985 
   988 
   986 	iAdditionalInfo = CSmsMessageAdditionalAttributes::NewL();
   989 	iAdditionalInfo = CSmsMessageAdditionalAttributes::NewL();
  1035 	} // CSmsMessage::ConstructL
  1038 	} // CSmsMessage::ConstructL
  1036 
  1039 
  1037 
  1040 
  1038 void CSmsMessage::ConstructL(CSmsPDU::TSmsPDUType aType,TBool aIsRPError)
  1041 void CSmsMessage::ConstructL(CSmsPDU::TSmsPDUType aType,TBool aIsRPError)
  1039 	{
  1042 	{
  1040     LOGGSMU3("CSmsMessage::ConstructL(): aType=%d, aIsRPError=%d", (TInt) aType,
  1043     OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_CONSTRUCTL1_1, "CSmsMessage::ConstructL(): aType=%d, aIsRPError=%d", (TInt) aType,aIsRPError);
  1041     		 aIsRPError);
       
  1042 
  1044 
  1043 	iCharacterSetConverter=CCnvCharacterSetConverter::NewL();
  1045 	iCharacterSetConverter=CCnvCharacterSetConverter::NewL();
  1044 	iInformationElementArray = new (ELeave) RPointerArray<CEmsInformationElement>(2);
  1046 	iInformationElementArray = new (ELeave) RPointerArray<CEmsInformationElement>(2);
  1045 
  1047 
  1046 	iAdditionalInfo = CSmsMessageAdditionalAttributes::NewL();
  1048 	iAdditionalInfo = CSmsMessageAdditionalAttributes::NewL();
  1061  * 
  1063  * 
  1062  *  @return  Number of PDUs required.
  1064  *  @return  Number of PDUs required.
  1063  */
  1065  */
  1064 TInt CSmsMessage::NumMessageEmsPDUsL()
  1066 TInt CSmsMessage::NumMessageEmsPDUsL()
  1065 	{
  1067 	{
  1066 	LOGGSMU1("CSmsMessage::NumMessageEmsPDUsL()");
  1068 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_NUMMESSAGEEMSPDUSL_1, "CSmsMessage::NumMessageEmsPDUsL()");
  1067 
  1069 
  1068 	//
  1070 	//
  1069 	// Clear the concatenated flag, EncodeBufferL() will add it if needed.
  1071 	// Clear the concatenated flag, EncodeBufferL() will add it if needed.
  1070 	//
  1072 	//
  1071 	SmsPDU().SetTextConcatenatedL(EFalse, EFalse);
  1073 	SmsPDU().SetTextConcatenatedL(EFalse, EFalse);
  1088 		numMsgs = iAdditionalInfo->SmsPDUArray().Count();
  1090 		numMsgs = iAdditionalInfo->SmsPDUArray().Count();
  1089 		}
  1091 		}
  1090 
  1092 
  1091 	CleanupStack::PopAndDestroy(tmpArray);
  1093 	CleanupStack::PopAndDestroy(tmpArray);
  1092 	
  1094 	
  1093     LOGGSMU2("CSmsMessage::NumMessageEmsPDUsL() returns %d", numMsgs);
  1095     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_NUMMESSAGEEMSPDUSL_2, "CSmsMessage::NumMessageEmsPDUsL() returns %d", numMsgs);
  1094 
  1096 
  1095 	return numMsgs;
  1097 	return numMsgs;
  1096 	} // CSmsMessage::NumMessageEmsPDUsL
  1098 	} // CSmsMessage::NumMessageEmsPDUsL
  1097 
  1099 
  1098 
  1100 
  1106  *  
  1108  *  
  1107  *  @leave KErrAlreadyExists or KErrAlreadyExists
  1109  *  @leave KErrAlreadyExists or KErrAlreadyExists
  1108  */
  1110  */
  1109 void CSmsMessage::ResetWorkingPDUL()
  1111 void CSmsMessage::ResetWorkingPDUL()
  1110 	{
  1112 	{
  1111 	LOGGSMU1("CSmsMessage::ResetWorkingPDUL()");
  1113 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_RESETWORKINGPDUL_1, "CSmsMessage::ResetWorkingPDUL()");
  1112 	
  1114 	
  1113 	CSmsUserData& uData = SmsPDU().UserData();
  1115 	CSmsUserData& uData = SmsPDU().UserData();
  1114 	//remove non-mandatory EMS information elements
  1116 	//remove non-mandatory EMS information elements
  1115 	for (TInt a=uData.NumInformationElements(); a>0; --a)
  1117 	for (TInt a=uData.NumInformationElements(); a>0; --a)
  1116         {
  1118         {
  1133 
  1135 
  1134 void CSmsMessage::CorrectFormattingL(TUint aCharsAddedToCurrentPDU,
  1136 void CSmsMessage::CorrectFormattingL(TUint aCharsAddedToCurrentPDU,
  1135 									 RPointerArray<CEmsInformationElement>& aCorrectedFormattingIEArray,
  1137 									 RPointerArray<CEmsInformationElement>& aCorrectedFormattingIEArray,
  1136 									 TUint aCharsAlreadyAdded)
  1138 									 TUint aCharsAlreadyAdded)
  1137 	{
  1139 	{
  1138 	LOGGSMU3("CSmsMessage::CorrectFormattingL(): aCharsAddedToCurrentPDU=%d, aCharsAlreadyAdded=%d",
  1140 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_CORRECTFORMATTINGL_1, "CSmsMessage::CorrectFormattingL(): aCharsAddedToCurrentPDU=%u, aCharsAlreadyAdded=%u",aCharsAddedToCurrentPDU, aCharsAlreadyAdded);
  1139 			 aCharsAddedToCurrentPDU, aCharsAlreadyAdded);
       
  1140 
  1141 
  1141 	CSmsUserData& uData = SmsPDU().UserData();
  1142 	CSmsUserData& uData = SmsPDU().UserData();
  1142 	for (TInt a= 0; a < uData.NumInformationElements(); a++)
  1143 	for (TInt a= 0; a < uData.NumInformationElements(); a++)
  1143 		{
  1144 		{
  1144 		CSmsInformationElement& ie = uData.InformationElement(a);
  1145 		CSmsInformationElement& ie = uData.InformationElement(a);
  1161 					{
  1162 					{
  1162 					CEmsFormatIE* newie=static_cast<CEmsFormatIE*>(formatIE.DuplicateL());
  1163 					CEmsFormatIE* newie=static_cast<CEmsFormatIE*>(formatIE.DuplicateL());
  1163 					CleanupStack::PushL(newie);
  1164 					CleanupStack::PushL(newie);
  1164 					newie->SetFormatLength(oldFormatLen - newFormatLen);
  1165 					newie->SetFormatLength(oldFormatLen - newFormatLen);
  1165 					newie->SetStartPosition(aCharsAlreadyAdded+aCharsAddedToCurrentPDU);
  1166 					newie->SetStartPosition(aCharsAlreadyAdded+aCharsAddedToCurrentPDU);
  1166 					LOGGSMU2("CSmsMessage::CorrectFormattingL",aCorrectedFormattingIEArray.Count());
  1167 					OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_CORRECTFORMATTINGL_2, "CSmsMessage::CorrectFormattingL Count=%d",aCorrectedFormattingIEArray.Count());
  1167 					aCorrectedFormattingIEArray.Append(newie);
  1168 					User::LeaveIfError(aCorrectedFormattingIEArray.Append(newie));
  1168 					CleanupStack::Pop(newie);
  1169 					CleanupStack::Pop(newie);
  1169 					}
  1170 					}
  1170 				}
  1171 				}
  1171 			}
  1172 			}
  1172 		}
  1173 		}
  1173 	} // CSmsMessage::CorrectFormattingL
  1174 	} // CSmsMessage::CorrectFormattingL
  1174 
  1175 
  1175 
  1176 
  1176 void CSmsMessage::CorrectFormattingInSinglePDUL()
  1177 void CSmsMessage::CorrectFormattingInSinglePDUL()
  1177 	{
  1178 	{
  1178 	LOGGSMU1("CSmsMessage::CorrectFormattingInSinglePDUL()");
  1179 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_CORRECTFORMATTINGINSINGLEPDUL_1, "CSmsMessage::CorrectFormattingInSinglePDUL()");
  1179 
  1180 
  1180 	CSmsUserData& uData = SmsPDU().UserData();
  1181 	CSmsUserData& uData = SmsPDU().UserData();
  1181 	for (TInt a= 0; a < uData.NumInformationElements(); a++)
  1182 	for (TInt a= 0; a < uData.NumInformationElements(); a++)
  1182 		{
  1183 		{
  1183 		CSmsInformationElement& ie = uData.InformationElement(a);
  1184 		CSmsInformationElement& ie = uData.InformationElement(a);
  1207  *                     PDUs to be quickly counted if the encoded PDUs are of
  1208  *                     PDUs to be quickly counted if the encoded PDUs are of
  1208  *                     no further use.
  1209  *                     no further use.
  1209  */
  1210  */
  1210 void CSmsMessage::AddCurrentPDUToPDUArrayL(TBool aDoEncode)
  1211 void CSmsMessage::AddCurrentPDUToPDUArrayL(TBool aDoEncode)
  1211 	{
  1212 	{
  1212 	LOGGSMU2("CSmsMessage::AddCurrentPDUToPDUArrayL(): Adding PDU number %d",
  1213 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ADDCURRENTPDUTOPDUARRAYL_1, "CSmsMessage::AddCurrentPDUToPDUArrayL(): Adding PDU number %d",iAdditionalInfo->SmsPDUArray().Count() + 1);
  1213 			 iAdditionalInfo->SmsPDUArray().Count() + 1);
       
  1214 	
  1214 	
  1215 	//
  1215 	//
  1216 	// Maximum number of PDU is 255, so if we have that already then we cannot
  1216 	// Maximum number of PDU is 255, so if we have that already then we cannot
  1217 	// continue.
  1217 	// continue.
  1218 	//
  1218 	//
  1259 	} // CSmsMessage::AddCurrentPDUToPDUArrayL
  1259 	} // CSmsMessage::AddCurrentPDUToPDUArrayL
  1260 
  1260 
  1261 
  1261 
  1262 TBool CSmsMessage::AddIEToUserDataL(CEmsInformationElement* aIE, TInt aCharsAlreadyAdded,TUint& aCharsAddedToCurrentPDU,CSmsEMSBufferSegmenter& aSeg)
  1262 TBool CSmsMessage::AddIEToUserDataL(CEmsInformationElement* aIE, TInt aCharsAlreadyAdded,TUint& aCharsAddedToCurrentPDU,CSmsEMSBufferSegmenter& aSeg)
  1263 	{
  1263 	{
  1264 	LOGGSMU1("CSmsMessage::AddIEToUserDataL()");
  1264 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ADDIETOUSERDATAL_1, "CSmsMessage::AddIEToUserDataL()");
  1265 
  1265 
  1266 	TBool ieAdded=EFalse;
  1266 	TBool ieAdded=EFalse;
  1267 	if (SmsPDU().UserData().EmsInformationElementWillFitL(aIE,aSeg,aCharsAddedToCurrentPDU))
  1267 	if (SmsPDU().UserData().EmsInformationElementWillFitL(aIE,aSeg,aCharsAddedToCurrentPDU))
  1268 		{
  1268 		{
  1269 		CEmsInformationElement* newIE=aIE->DuplicateL();
  1269 		CEmsInformationElement* newIE=aIE->DuplicateL();
  1286  * 
  1286  * 
  1287  *  @return TInt Number of native characters added
  1287  *  @return TInt Number of native characters added
  1288  */
  1288  */
  1289 TInt CSmsMessage::FillPduL(CSmsEMSBufferSegmenter& aSeg, TInt aNumChars, TSmsEncoding aEncoding)
  1289 TInt CSmsMessage::FillPduL(CSmsEMSBufferSegmenter& aSeg, TInt aNumChars, TSmsEncoding aEncoding)
  1290 	{
  1290 	{
  1291 	LOGGSMU1("CSmsMessage::FillPduL()");
  1291 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_FILLPDUL_1, "CSmsMessage::FillPduL()");
  1292 
  1292 
  1293 	TUint maxUDUnitsREmaining=SmsPDU().UserData().MaxPackedUDUnitsInBodyRemaining();
  1293 	TUint maxUDUnitsREmaining=SmsPDU().UserData().MaxPackedUDUnitsInBodyRemaining();
  1294 
  1294 
  1295 	if (aNumChars==0 || maxUDUnitsREmaining==0)
  1295 	if (aNumChars==0 || maxUDUnitsREmaining==0)
  1296 		{
  1296 		{
  1331  *                          a PDU that contains only the mandatory elements.
  1331  *                          a PDU that contains only the mandatory elements.
  1332  */
  1332  */
  1333 void CSmsMessage::AddControlInformationElementsToMultiSegmentMessageL(TSmsInformationElementCategories::TInformationElementCategory aCategory,
  1333 void CSmsMessage::AddControlInformationElementsToMultiSegmentMessageL(TSmsInformationElementCategories::TInformationElementCategory aCategory,
  1334 			                                                          TBool aMandatoryInPDU, TBool aDoEncode)
  1334 			                                                          TBool aMandatoryInPDU, TBool aDoEncode)
  1335     {
  1335     {
  1336     LOGGSMU1("CSmsMessage::AddControlInformationElementsToMultiSegmentMessageL()");
  1336     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ADDCONTROLINFORMATIONELEMENTSTOMULTISEGMENTMESSAGEL_1, "CSmsMessage::AddControlInformationElementsToMultiSegmentMessageL()");
  1337 
  1337 
  1338     TUint numberOfInformationElements = iAdditionalInfo->NumberOfControlInformationElements(aCategory);
  1338     TUint numberOfInformationElements = iAdditionalInfo->NumberOfControlInformationElements(aCategory);
  1339 
  1339 
  1340     for (TInt i = 0; i < numberOfInformationElements; i++)
  1340     for (TInt i = 0; i < numberOfInformationElements; i++)
  1341         {
  1341         {
  1363                 // It is possible to make Enhanced Voice Mail Information Elements
  1363                 // It is possible to make Enhanced Voice Mail Information Elements
  1364                 // bigger than the available space in the PDU.
  1364                 // bigger than the available space in the PDU.
  1365                 TBool canFit = SmsPDU().UserData().ControlInformationElementWillFitL(cloneInformationElement);
  1365                 TBool canFit = SmsPDU().UserData().ControlInformationElementWillFitL(cloneInformationElement);
  1366                 if (canFit == EFalse)
  1366                 if (canFit == EFalse)
  1367                     {
  1367                     {
  1368                     LOGGSMU1("CSmsMessage::AddControlInformationElementsToMultiSegmentMessage, IE too bit to fit in any PDUL");
  1368                     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ADDCONTROLINFORMATIONELEMENTSTOMULTISEGMENTMESSAGEL_2, "CSmsMessage::AddControlInformationElementsToMultiSegmentMessage, IE too bit to fit in any PDUL");
  1369                     User::Leave(KErrArgument);
  1369                     User::Leave(KErrArgument);
  1370                     }
  1370                     }
  1371                 i--;
  1371                 i--;
  1372                 }
  1372                 }
  1373 
  1373 
  1387  *  @leave KErrArgument  If the category is mandatory but one or more elements
  1387  *  @leave KErrArgument  If the category is mandatory but one or more elements
  1388  *                       cannot be added then the encoding will fail.
  1388  *                       cannot be added then the encoding will fail.
  1389  */
  1389  */
  1390 void CSmsMessage::AddControlInformationElementsToMultiSegmentMessageL(TBool aDoEncode)
  1390 void CSmsMessage::AddControlInformationElementsToMultiSegmentMessageL(TBool aDoEncode)
  1391     {
  1391     {
  1392     LOGGSMU1("CSmsMessage::AddControlInformationElementsToMultiSegmentMessageL() 1");
  1392     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ADDCONTROLINFORMATIONELEMENTSTOMULTISEGMENTMESSAGEL1_1, "CSmsMessage::AddControlInformationElementsToMultiSegmentMessageL() 1");
  1393 
  1393 
  1394     TBool mandatoryInEachPDU = ETrue;
  1394     TBool mandatoryInEachPDU = ETrue;
  1395     AddControlInformationElementsToMultiSegmentMessageL(TSmsInformationElementCategories::ECtrlMandatoryIn1stPDUOnly,
  1395     AddControlInformationElementsToMultiSegmentMessageL(TSmsInformationElementCategories::ECtrlMandatoryIn1stPDUOnly,
  1396     													mandatoryInEachPDU, aDoEncode);
  1396     													mandatoryInEachPDU, aDoEncode);
  1397     mandatoryInEachPDU = EFalse;
  1397     mandatoryInEachPDU = EFalse;
  1423 																   TSmsEncoding& aEncoding,
  1423 																   TSmsEncoding& aEncoding,
  1424 																   RPointerArray<CEmsInformationElement>& aCorrectedFormatingIEArray,
  1424 																   RPointerArray<CEmsInformationElement>& aCorrectedFormatingIEArray,
  1425 																   TUint& aCurrEMSIEno,
  1425 																   TUint& aCurrEMSIEno,
  1426 																   TUint& aCharsAlreadyAdded)
  1426 																   TUint& aCharsAlreadyAdded)
  1427 	{
  1427 	{
  1428 	LOGGSMU1("CSmsMessage::AddEMSInformationElementsToMultiSegmentMessageL()");
  1428 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ADDEMSINFORMATIONELEMENTSTOMULTISEGMENTMESSAGEL_1, "CSmsMessage::AddEMSInformationElementsToMultiSegmentMessageL()");
  1429 
  1429 
  1430 	TUint startPosition=0;
  1430 	TUint startPosition=0;
  1431 
  1431 
  1432 	 // number of chars added to the current PDU
  1432 	 // number of chars added to the current PDU
  1433 	TUint no=iInformationElementArray->Count();
  1433 	TUint no=iInformationElementArray->Count();
  1434 	LOGGSMU2("CSmsMessage::AddEMSInformationElementsToMultiSegmentMessageL no of IE %d",no);
  1434 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ADDEMSINFORMATIONELEMENTSTOMULTISEGMENTMESSAGEL_2, "CSmsMessage::AddEMSInformationElementsToMultiSegmentMessageL no of IE %d",no);
  1435 	CEmsInformationElement* ie = NULL;
  1435 	CEmsInformationElement* ie = NULL;
  1436 	TUint msgLen=iBuffer->Length();
  1436 	TUint msgLen=iBuffer->Length();
  1437 	TUint filledChars=0;
  1437 	TUint filledChars=0;
  1438 
  1438 
  1439 	while(aCurrEMSIEno < no || aCorrectedFormatingIEArray.Count() > 0)
  1439 	while(aCurrEMSIEno < no || aCorrectedFormatingIEArray.Count() > 0)
  1470 				{
  1470 				{
  1471 				filledChars = FillPduL(aSegmenter, startPosition-aCharsAddedToCurrentPDU, aEncoding);
  1471 				filledChars = FillPduL(aSegmenter, startPosition-aCharsAddedToCurrentPDU, aEncoding);
  1472 				aCharsAddedToCurrentPDU+=filledChars;
  1472 				aCharsAddedToCurrentPDU+=filledChars;
  1473 				}
  1473 				}
  1474 
  1474 
  1475 			LOGGSMU2("CSmsMessage::AddEMSInformationElementsToMultiSegmentMessageL: filled %d chars", filledChars);
  1475 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ADDEMSINFORMATIONELEMENTSTOMULTISEGMENTMESSAGEL_3, "CSmsMessage::AddEMSInformationElementsToMultiSegmentMessageL: filled %d chars", filledChars);
  1476 
  1476 
  1477 			if (aCharsAddedToCurrentPDU==startPosition)
  1477 			if (aCharsAddedToCurrentPDU==startPosition)
  1478 				{
  1478 				{
  1479 				// Try adding the IE.
  1479 				// Try adding the IE.
  1480 				if (AddIEToUserDataL(ie, aCharsAlreadyAdded,aCharsAddedToCurrentPDU,aSegmenter))
  1480 				if (AddIEToUserDataL(ie, aCharsAlreadyAdded,aCharsAddedToCurrentPDU,aSegmenter))
  1490 					else aCurrEMSIEno++;
  1490 					else aCurrEMSIEno++;
  1491 					}
  1491 					}
  1492 				else
  1492 				else
  1493 					{
  1493 					{
  1494 					// Information Element will not fit send PDU
  1494 					// Information Element will not fit send PDU
  1495 					LOGGSMU1("CSmsMessage::AddEMSInformationElementsToMultiSegmentMessageL: ie will not fit send Message");
  1495 					OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ADDEMSINFORMATIONELEMENTSTOMULTISEGMENTMESSAGEL_4, "CSmsMessage::AddEMSInformationElementsToMultiSegmentMessageL: ie will not fit send Message");
  1496 					CorrectFormattingL(aCharsAddedToCurrentPDU,aCorrectedFormatingIEArray,aCharsAlreadyAdded);
  1496 					CorrectFormattingL(aCharsAddedToCurrentPDU,aCorrectedFormatingIEArray,aCharsAlreadyAdded);
  1497 
  1497 
  1498 					aCharsAlreadyAdded += aCharsAddedToCurrentPDU;
  1498 					aCharsAlreadyAdded += aCharsAddedToCurrentPDU;
  1499 					aCharsAddedToCurrentPDU=0;
  1499 					aCharsAddedToCurrentPDU=0;
  1500 
  1500 
  1511 					}
  1511 					}
  1512 				}
  1512 				}
  1513 			else
  1513 			else
  1514 				{
  1514 				{
  1515 				// native chars upto start position will not fit send PDu.
  1515 				// native chars upto start position will not fit send PDu.
  1516 				LOGGSMU1("CSmsMessage::AddEMSInformationElementsToMultiSegmentMessageL: PDU is filled with chars sending");
  1516 				OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ADDEMSINFORMATIONELEMENTSTOMULTISEGMENTMESSAGEL_5, "CSmsMessage::AddEMSInformationElementsToMultiSegmentMessageL: PDU is filled with chars sending");
  1517 
  1517 
  1518 				CorrectFormattingL(aCharsAddedToCurrentPDU,aCorrectedFormatingIEArray,aCharsAlreadyAdded);
  1518 				CorrectFormattingL(aCharsAddedToCurrentPDU,aCorrectedFormatingIEArray,aCharsAlreadyAdded);
  1519 
  1519 
  1520 				aCharsAlreadyAdded += aCharsAddedToCurrentPDU;
  1520 				aCharsAlreadyAdded += aCharsAddedToCurrentPDU;
  1521 				aCharsAddedToCurrentPDU=0;
  1521 				aCharsAddedToCurrentPDU=0;
  1549  *  @return TBool whether EMS IEs have been added to segment
  1549  *  @return TBool whether EMS IEs have been added to segment
  1550  */
  1550  */
  1551 TBool CSmsMessage::AddEMSInformationElementsToSingleSegmentMessageL(CSmsEMSBufferSegmenter& aSegmenter,
  1551 TBool CSmsMessage::AddEMSInformationElementsToSingleSegmentMessageL(CSmsEMSBufferSegmenter& aSegmenter,
  1552 																	TSmsEncoding aEncoding)
  1552 																	TSmsEncoding aEncoding)
  1553 	{
  1553 	{
  1554 	LOGGSMU1("CSmsMessage::AddEMSInformationElementsToSingleSegmentMessageL()");
  1554 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ADDEMSINFORMATIONELEMENTSTOSINGLESEGMENTMESSAGEL_1, "CSmsMessage::AddEMSInformationElementsToSingleSegmentMessageL()");
  1555 
  1555 
  1556 	TUint charsAddedToCurrentPDU=0;
  1556 	TUint charsAddedToCurrentPDU=0;
  1557 	TUint numOfEmsIE=iInformationElementArray->Count();
  1557 	TUint numOfEmsIE=iInformationElementArray->Count();
  1558 	TUint currEmsIEindex=0;
  1558 	TUint currEmsIEindex=0;
  1559 	CEmsInformationElement* ie = NULL;
  1559 	CEmsInformationElement* ie = NULL;
  1606 void CSmsMessage::EncodeBufferL(CArrayFix<TGsmSms>& aSmsArray, TInt aReference,
  1606 void CSmsMessage::EncodeBufferL(CArrayFix<TGsmSms>& aSmsArray, TInt aReference,
  1607 								const CSmsBufferBase& aBuffer,
  1607 								const CSmsBufferBase& aBuffer,
  1608 								TInt& aUnconvertedChars, TInt& aDowngradedChars,
  1608 								TInt& aUnconvertedChars, TInt& aDowngradedChars,
  1609 						        TInt& aFreeUDUnitsInLastPDU, TBool aDoEncode)
  1609 						        TInt& aFreeUDUnitsInLastPDU, TBool aDoEncode)
  1610 	{
  1610 	{
  1611 	LOGGSMU1("CSmsMessage::EncodeBufferL()");
  1611 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ENCODEBUFFERL_1, "CSmsMessage::EncodeBufferL()");
  1612 
  1612 
  1613 	aUnconvertedChars     = 0;
  1613 	aUnconvertedChars     = 0;
  1614 	aDowngradedChars      = 0;
  1614 	aDowngradedChars      = 0;
  1615 	aFreeUDUnitsInLastPDU = 0;
  1615 	aFreeUDUnitsInLastPDU = 0;
  1616 	
  1616 	
  1710 	// While there is still data to encode see how much space is left in this
  1710 	// While there is still data to encode see how much space is left in this
  1711 	// PDU and attempt to encode something into it...
  1711 	// PDU and attempt to encode something into it...
  1712 	//
  1712 	//
  1713 	while (segmenter->MoreL())
  1713 	while (segmenter->MoreL())
  1714 			{
  1714 			{
  1715 			LOGGSMU1("CSmsMessage::EncodeBufferL - there is MoreL");
  1715 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ENCODEBUFFERL_2, "CSmsMessage::EncodeBufferL - there is MoreL");
  1716 			
  1716 			
  1717 			//
  1717 			//
  1718 			// Calculate the space left to use in this PDU...
  1718 			// Calculate the space left to use in this PDU...
  1719 			//
  1719 			//
  1720 			TInt size = SmsPDU().UserData().MaxPackedUDUnitsInBodyRemaining();
  1720 			TInt size = SmsPDU().UserData().MaxPackedUDUnitsInBodyRemaining();
  1721 			LOGGSMU2("CSmsMessage::EncodeBufferL - remaining size in PDU is %d",size);
  1721 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ENCODEBUFFERL_3, "CSmsMessage::EncodeBufferL - remaining size in PDU is %d",size);
  1722 
  1722 
  1723 			//
  1723 			//
  1724 			// While there is no space, correct the formatting (which may
  1724 			// While there is no space, correct the formatting (which may
  1725 			// introduce any un-placed EMS Elements into the corrected format
  1725 			// introduce any un-placed EMS Elements into the corrected format
  1726 			// array) and then start a new PDU...
  1726 			// array) and then start a new PDU...
  1753 
  1753 
  1754 				//
  1754 				//
  1755 				// Add any elements that can be placed now (from previous
  1755 				// Add any elements that can be placed now (from previous
  1756 				// PDUs and above)... 
  1756 				// PDUs and above)... 
  1757 				//
  1757 				//
  1758 				LOGGSMU3("CSmsMessage::EncodeBufferL: IE count  %d corrected  count %d",iInformationElementArray->Count(),correctedFormatingIEArray.Count() );
  1758 				OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ENCODEBUFFERL_4, "CSmsMessage::EncodeBufferL: IE count  %d corrected  count %d",iInformationElementArray->Count(),correctedFormatingIEArray.Count() );
  1759 				if ((TUint)iInformationElementArray->Count() > currEMSIEno  ||
  1759 				if ((TUint)iInformationElementArray->Count() > currEMSIEno  ||
  1760 					correctedFormatingIEArray.Count() > 0)
  1760 					correctedFormatingIEArray.Count() > 0)
  1761 					{
  1761 					{
  1762 					AddEMSInformationElementsToMultiSegmentMessageL(*segmenter,charsAdded2CurrentPDU,
  1762 					AddEMSInformationElementsToMultiSegmentMessageL(*segmenter,charsAdded2CurrentPDU,
  1763 																	aDoEncode, encodingToUse,
  1763 																	aDoEncode, encodingToUse,
  1767 
  1767 
  1768 				//
  1768 				//
  1769 				// Calculate the space left remaining in this new PDU...
  1769 				// Calculate the space left remaining in this new PDU...
  1770 				//
  1770 				//
  1771 				size = SmsPDU().UserData().MaxPackedUDUnitsInBodyRemaining();
  1771 				size = SmsPDU().UserData().MaxPackedUDUnitsInBodyRemaining();
  1772 				LOGGSMU2("CSmsMessage::EncodeBufferL - remaining size in PDU is %d",size);
  1772 				OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ENCODEBUFFERL_5, "CSmsMessage::EncodeBufferL - remaining size in PDU is %d",size);
  1773 				}
  1773 				}
  1774 			
  1774 			
  1775 			//
  1775 			//
  1776 			// We have space in this PDU and no elements to place, so obtain
  1776 			// We have space in this PDU and no elements to place, so obtain
  1777 			// the next peice of text that can fit and append it.
  1777 			// the next peice of text that can fit and append it.
  1778 			//
  1778 			//
  1779 			segmenter->SegmentNextL(ptr, size, aUnconvertedChars, aDowngradedChars, encodingToUse);
  1779 			segmenter->SegmentNextL(ptr, size, aUnconvertedChars, aDowngradedChars, encodingToUse);
  1780 			SmsPDU().UserData().AppendBodyL(ptr);
  1780 			SmsPDU().UserData().AppendBodyL(ptr);
  1781 
  1781 
  1782 			TUint charsInSegment= isUnicode ? ptr.Length()/2 : ptr.Length();
  1782 			TUint charsInSegment= isUnicode ? ptr.Length()/2 : ptr.Length();
  1783 			LOGGSMU2("CSmsMessage::EncodeBufferL: segmenting added %d chars", charsInSegment);
  1783 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ENCODEBUFFERL_6, "CSmsMessage::EncodeBufferL: segmenting added %d chars", charsInSegment);
  1784 
  1784 
  1785 			//
  1785 			//
  1786 			// At this point the working PDU is either full (e.g. we filled the
  1786 			// At this point the working PDU is either full (e.g. we filled the
  1787 			// remaining space with a chuck of text, or the is some space as we
  1787 			// remaining space with a chuck of text, or the is some space as we
  1788 			// stored the last part of the text.
  1788 			// stored the last part of the text.
  1791 			// formatting array...
  1791 			// formatting array...
  1792 			//
  1792 			//
  1793 			charsAdded2CurrentPDU+=charsInSegment;
  1793 			charsAdded2CurrentPDU+=charsInSegment;
  1794 			CorrectFormattingL(charsAdded2CurrentPDU, correctedFormatingIEArray, charsAlreadyAdded);
  1794 			CorrectFormattingL(charsAdded2CurrentPDU, correctedFormatingIEArray, charsAlreadyAdded);
  1795 			charsAlreadyAdded+=charsAdded2CurrentPDU;
  1795 			charsAlreadyAdded+=charsAdded2CurrentPDU;
  1796 			LOGGSMU2("CSmsMessage::EncodeBufferL(): charsAlreadyAdded=%d", charsAlreadyAdded);
  1796 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ENCODEBUFFERL_7, "CSmsMessage::EncodeBufferL(): charsAlreadyAdded=%d", charsAlreadyAdded);
  1797 			
  1797 			
  1798 			//
  1798 			//
  1799 			// Now store this PDU and reset the working PDU...
  1799 			// Now store this PDU and reset the working PDU...
  1800 			//
  1800 			//
  1801 			aFreeUDUnitsInLastPDU = SmsPDU().UserData().MaxPackedUDUnitsInBodyRemaining();
  1801 			aFreeUDUnitsInLastPDU = SmsPDU().UserData().MaxPackedUDUnitsInBodyRemaining();
  1814 
  1814 
  1815 			//
  1815 			//
  1816 			// Add any elements that can be placed now given we have a new
  1816 			// Add any elements that can be placed now given we have a new
  1817 			// empty PDU... 
  1817 			// empty PDU... 
  1818 			//
  1818 			//
  1819 			LOGGSMU3("CSmsMessage::EncodeBufferL: IE count  %d corrected  count %d",
  1819 			OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ENCODEBUFFERL_8, "CSmsMessage::EncodeBufferL: IE count  %d corrected  count %d",iInformationElementArray->Count(), correctedFormatingIEArray.Count() );
  1820 			         iInformationElementArray->Count(), correctedFormatingIEArray.Count() );
       
  1821 			if ((TUint)iInformationElementArray->Count() > currEMSIEno  ||
  1820 			if ((TUint)iInformationElementArray->Count() > currEMSIEno  ||
  1822 				correctedFormatingIEArray.Count() > 0)
  1821 				correctedFormatingIEArray.Count() > 0)
  1823 				{
  1822 				{
  1824 				AddEMSInformationElementsToMultiSegmentMessageL(*segmenter, charsAdded2CurrentPDU,
  1823 				AddEMSInformationElementsToMultiSegmentMessageL(*segmenter, charsAdded2CurrentPDU,
  1825 																aDoEncode, encodingToUse,
  1824 																aDoEncode, encodingToUse,
  1826 																correctedFormatingIEArray,
  1825 																correctedFormatingIEArray,
  1827 																currEMSIEno, charsAlreadyAdded);
  1826 																currEMSIEno, charsAlreadyAdded);
  1828 				}
  1827 				}
  1829 			LOGGSMU1("CSmsMessage::EncodeBufferL end Moreloop");
  1828 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ENCODEBUFFERL_9, "CSmsMessage::EncodeBufferL end Moreloop");
  1830 			}
  1829 			}
  1831 	CleanupStack::PopAndDestroy(buf);
  1830 	CleanupStack::PopAndDestroy(buf);
  1832 
  1831 
  1833 	LOGGSMU1("CSmsMessage::EncodeBufferL - last PDU");
  1832 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ENCODEBUFFERL_10, "CSmsMessage::EncodeBufferL - last PDU");
  1834 	
  1833 	
  1835 	//
  1834 	//
  1836 	// This is the last PDU. We need to check if there is a partial PDU left over
  1835 	// This is the last PDU. We need to check if there is a partial PDU left over
  1837 	// and add it if needed.
  1836 	// and add it if needed.
  1838 	//
  1837 	//
  1863 	// Note: In the case were aDoEncode is EFalse, iSmsPDUArray will be full
  1862 	// Note: In the case were aDoEncode is EFalse, iSmsPDUArray will be full
  1864 	//       of NULL pointers as it is only the count that we need in that case.
  1863 	//       of NULL pointers as it is only the count that we need in that case.
  1865 	//
  1864 	//
  1866 	TInt  numPDUs = iAdditionalInfo->SmsPDUArray().Count();
  1865 	TInt  numPDUs = iAdditionalInfo->SmsPDUArray().Count();
  1867 
  1866 
  1868 	LOGGSMU2("CSmsMessage::EncodeBufferL number of PDUs: %d", iAdditionalInfo->SmsPDUArray().Count());
  1867 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ENCODEBUFFERL_11, "CSmsMessage::EncodeBufferL number of PDUs: %d", iAdditionalInfo->SmsPDUArray().Count());
  1869 	
  1868 	
  1870 	if (aDoEncode)
  1869 	if (aDoEncode)
  1871 		{
  1870 		{
  1872 		CSmsMessageAdditionalAttributes::CSmsStatusReportScheme&  scheme = iAdditionalInfo->GetStatusReportScheme();
  1871 		CSmsMessageAdditionalAttributes::CSmsStatusReportScheme&  scheme = iAdditionalInfo->GetStatusReportScheme();
  1873 		TGsmSms  gsmSms;
  1872 		TGsmSms  gsmSms;
  1954  *                                 in the last PDU.
  1953  *                                 in the last PDU.
  1955  */
  1954  */
  1956 TBool CSmsMessage::EncodeIntoSinglePDUL(CArrayFix<TGsmSms>& aSmsArray, TInt& aUnconvertedChars,
  1955 TBool CSmsMessage::EncodeIntoSinglePDUL(CArrayFix<TGsmSms>& aSmsArray, TInt& aUnconvertedChars,
  1957 		                                TInt& aDowngradedChars, TInt& aFreeUDUnitsInLastPDU)
  1956 		                                TInt& aDowngradedChars, TInt& aFreeUDUnitsInLastPDU)
  1958 	{
  1957 	{
  1959 	LOGGSMU1("CSmsMessage::EncodeIntoSinglePDUL()");
  1958 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ENCODEINTOSINGLEPDUL_1, "CSmsMessage::EncodeIntoSinglePDUL()");
  1960 
  1959 
  1961 	__ASSERT_DEBUG((aSmsArray.Count()==0),Panic(KGsmuPanicSmsArrayNotEmpty));
  1960 	__ASSERT_DEBUG((aSmsArray.Count()==0),Panic(KGsmuPanicSmsArrayNotEmpty));
  1962 
  1961 
  1963 	aUnconvertedChars     = 0;
  1962 	aUnconvertedChars     = 0;
  1964 	aDowngradedChars      = 0;
  1963 	aDowngradedChars      = 0;
  2001                 }
  2000                 }
  2002             default:
  2001             default:
  2003                 break;
  2002                 break;
  2004             }
  2003             }
  2005         }
  2004         }
  2006     LOGGSMU2("CSmsMessage::EncodeIntoSinglePDUL, ctrl elem len = %d", ieLength);
  2005     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ENCODEINTOSINGLEPDUL_2, "CSmsMessage::EncodeIntoSinglePDUL, ctrl elem len = %d", ieLength);
  2007 
  2006 
  2008 	CEmsInformationElement* emsIE =NULL;
  2007 	CEmsInformationElement* emsIE =NULL;
  2009 	for (TInt num=0; num<iInformationElementArray->Count();num++)
  2008 	for (TInt num=0; num<iInformationElementArray->Count();num++)
  2010 		{
  2009 		{
  2011 		emsIE = (*iInformationElementArray)[num];
  2010 		emsIE = (*iInformationElementArray)[num];
  2016 
  2015 
  2017 	TInt msgLength=MessageLengthL(); // in octets
  2016 	TInt msgLength=MessageLengthL(); // in octets
  2018 
  2017 
  2019 	if( msgLength > remainInBody) return EFalse;
  2018 	if( msgLength > remainInBody) return EFalse;
  2020 
  2019 
  2021     LOGGSMU4("CSmsMessage::EncodeIntoSinglePDUL, ie len = %d, remainInBody = %d, msgLength = %d", ieLength, msgLength, remainInBody);
  2020     OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ENCODEINTOSINGLEPDUL_3, "CSmsMessage::EncodeIntoSinglePDUL, ie len = %d, remainInBody = %d, msgLength = %d", ieLength, msgLength, remainInBody);
  2022     //  add all control information elements into working PDU.
  2021     //  add all control information elements into working PDU.
  2023     //
  2022     //
  2024     for (TUint8 category = 0; category <  TSmsInformationElementCategories::ENumberOfCategories; category++)
  2023     for (TUint8 category = 0; category <  TSmsInformationElementCategories::ENumberOfCategories; category++)
  2025         {
  2024         {
  2026         switch (category)
  2025         switch (category)
  2134  *  
  2133  *  
  2135  *  @capability None
  2134  *  @capability None
  2136  */
  2135  */
  2137 EXPORT_C TBool CSmsMessage::EncodeIntoSinglePDUL(CArrayFix<TGsmSms>& aSmsArray)
  2136 EXPORT_C TBool CSmsMessage::EncodeIntoSinglePDUL(CArrayFix<TGsmSms>& aSmsArray)
  2138 	{
  2137 	{
  2139 	LOGGSMU1("CSmsMessage::EncodeIntoSinglePDUL()");
  2138 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_ENCODEINTOSINGLEPDUL1_1, "CSmsMessage::EncodeIntoSinglePDUL()");
  2140 	
  2139 	
  2141 	TInt  unconvertedChars, downgradedChars, freeUDUnitsInLastPDU;
  2140 	TInt  unconvertedChars, downgradedChars, freeUDUnitsInLastPDU;
  2142 	
  2141 	
  2143 	return EncodeIntoSinglePDUL(aSmsArray, unconvertedChars,
  2142 	return EncodeIntoSinglePDUL(aSmsArray, unconvertedChars,
  2144                                 downgradedChars, freeUDUnitsInLastPDU);
  2143                                 downgradedChars, freeUDUnitsInLastPDU);
  2217  *  of the UserData.
  2216  *  of the UserData.
  2218  */
  2217  */
  2219 void CSmsMessage::DecodeBufferL(CArrayPtr<CSmsPDU>& aSmsPDUArray,
  2218 void CSmsMessage::DecodeBufferL(CArrayPtr<CSmsPDU>& aSmsPDUArray,
  2220 								CSmsBufferBase& aBuffer)
  2219 								CSmsBufferBase& aBuffer)
  2221 	{
  2220 	{
  2222 	LOGGSMU1("CSmsMessage::DecodeBufferL()");
  2221 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_DECODEBUFFERL_1, "CSmsMessage::DecodeBufferL()");
  2223 
  2222 
  2224 	iInformationElementArray->ResetAndDestroy();
  2223 	iInformationElementArray->ResetAndDestroy();
  2225 
  2224 
  2226 	TSmsStatusReportScheme schemeId = FindSchemeL(aSmsPDUArray);
  2225 	TSmsStatusReportScheme schemeId = FindSchemeL(aSmsPDUArray);
  2227 	
  2226 	
  2279  *
  2278  *
  2280  */
  2279  */
  2281 void CSmsMessage::DecodeOnlyTextL(CArrayPtr<CSmsPDU>& aSmsPDUArray,
  2280 void CSmsMessage::DecodeOnlyTextL(CArrayPtr<CSmsPDU>& aSmsPDUArray,
  2282 								CSmsBufferBase& aBuffer)
  2281 								CSmsBufferBase& aBuffer)
  2283 	{
  2282 	{
  2284 	LOGGSMU1("CSmsMessage::DecodeOnlyTextL()");
  2283 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_DECODEONLYTEXTL_1, "CSmsMessage::DecodeOnlyTextL()");
  2285 
  2284 
  2286 	for (TInt i=0; i<aSmsPDUArray.Count(); i++)
  2285 	for (TInt i=0; i<aSmsPDUArray.Count(); i++)
  2287 		{
  2286 		{
  2288         CSmsAlphabetConverter* converter=CSmsAlphabetConverter::NewLC(*iCharacterSetConverter,iFs,aSmsPDUArray[i]->Alphabet(),BinaryData());
  2287         CSmsAlphabetConverter* converter=CSmsAlphabetConverter::NewLC(*iCharacterSetConverter,iFs,aSmsPDUArray[i]->Alphabet(),BinaryData());
  2289         TSmsBufferReassembler reassembler(*converter,aBuffer);
  2288         TSmsBufferReassembler reassembler(*converter,aBuffer);
  2306  *  @param aLastPartialCompleteMsg boolean value indicating whether 
  2305  *  @param aLastPartialCompleteMsg boolean value indicating whether 
  2307  				this message is the last incomplete message sent to client.
  2306  				this message is the last incomplete message sent to client.
  2308  */
  2307  */
  2309 void CSmsMessage::AddIncompleteMessageInfoL(TInt aStartPDU, TInt aEndPDU, TBool aLastPartialCompleteMsg)
  2308 void CSmsMessage::AddIncompleteMessageInfoL(TInt aStartPDU, TInt aEndPDU, TBool aLastPartialCompleteMsg)
  2310 	{
  2309 	{
  2311 	LOGGSMU1("CSmsMessage::AddIncompleteMessageInfoL()");
  2310 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ADDINCOMPLETEMESSAGEINFOL_1, "CSmsMessage::AddIncompleteMessageInfoL()");
  2312 
  2311 
  2313 	CIncompleteClass0MessageInfo& incompleteClass0MsgInfo = (CIncompleteClass0MessageInfo&) iAdditionalInfo->GetNonIEOperationL(ESmsIncompleteClass0MessageParameter);
  2312 	CIncompleteClass0MessageInfo& incompleteClass0MsgInfo = (CIncompleteClass0MessageInfo&) iAdditionalInfo->GetNonIEOperationL(ESmsIncompleteClass0MessageParameter);
  2314 	incompleteClass0MsgInfo.SetVersion(CIncompleteClass0MessageInfo::ESmsIncompleteClass0MessageV0);
  2313 	incompleteClass0MsgInfo.SetVersion(CIncompleteClass0MessageInfo::ESmsIncompleteClass0MessageV0);
  2315 	incompleteClass0MsgInfo.SetIncompleteMessageInfoL(aStartPDU, aEndPDU, aLastPartialCompleteMsg);
  2314 	incompleteClass0MsgInfo.SetIncompleteMessageInfoL(aStartPDU, aEndPDU, aLastPartialCompleteMsg);
  2316 	}
  2315 	}
  2330  *  @internalComponent
  2329  *  @internalComponent
  2331  */
  2330  */
  2332 void CSmsMessage::InstallControlInformationElementsL(CSmsUserData& aUserData, TInt aSegmentSequenceNum)
  2331 void CSmsMessage::InstallControlInformationElementsL(CSmsUserData& aUserData, TInt aSegmentSequenceNum)
  2333     {
  2332     {
  2334 	// Installs all the information elements within the subsequent PDUs.
  2333 	// Installs all the information elements within the subsequent PDUs.
  2335 	LOGGSMU1("CSmsMessage::InstallControlInformationElements()");
  2334 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_INSTALLCONTROLINFORMATIONELEMENTSL_1, "CSmsMessage::InstallControlInformationElements()");
  2336 
  2335 
  2337     CSmsMessageAdditionalAttributes::CSmsStatusReportScheme& scheme = iAdditionalInfo->GetStatusReportScheme();
  2336     CSmsMessageAdditionalAttributes::CSmsStatusReportScheme& scheme = iAdditionalInfo->GetStatusReportScheme();
  2338     
  2337     
  2339 	for (TInt z=0; z<aUserData.NumInformationElements(); z++)
  2338 	for (TInt z=0; z<aUserData.NumInformationElements(); z++)
  2340 		{
  2339 		{
  2345         if (TSmsInformationElementCategories::GetCategoryDefinition(ie.Identifier(), category))
  2344         if (TSmsInformationElementCategories::GetCategoryDefinition(ie.Identifier(), category))
  2346         	{
  2345         	{
  2347             switch (category)
  2346             switch (category)
  2348                 {
  2347                 {
  2349                 case  TSmsInformationElementCategories::ECtrlMandatoryInEveryPDUMultipleInstancesPerPDU: // e.g. Special SMS Message Indication
  2348                 case  TSmsInformationElementCategories::ECtrlMandatoryInEveryPDUMultipleInstancesPerPDU: // e.g. Special SMS Message Indication
  2350                     LOGGSMU2("CSmsMessage::InstallControlInformationElements \
  2349                     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_INSTALLCONTROLINFORMATIONELEMENTSL_2, "CSmsMessage::InstallControlInformationElements \ECtrlMandatoryInEveryPDUMultipleInstancesPerPDU id = %d", ie.Identifier());
  2351                     ECtrlMandatoryInEveryPDUMultipleInstancesPerPDU id = %d", ie.Identifier());
       
  2352 
  2350 
  2353                     if (ie.Identifier()== CSmsInformationElement::ESmsIEISpecialSMSMessageIndication)
  2351                     if (ie.Identifier()== CSmsInformationElement::ESmsIEISpecialSMSMessageIndication)
  2354                         {
  2352                         {
  2355                         TBool found = EFalse;
  2353                         TBool found = EFalse;
  2356                         CArrayFixFlat<TInt>* indices = new(ELeave) CArrayFixFlat<TInt>(4);
  2354                         CArrayFixFlat<TInt>* indices = new(ELeave) CArrayFixFlat<TInt>(4);
  2378                             }
  2376                             }
  2379                         }
  2377                         }
  2380                     else
  2378                     else
  2381                         {
  2379                         {
  2382                         // Unknown category.
  2380                         // Unknown category.
  2383                         LOGGSMU3("CSmsMessage::InstallControlInformationElementsL category = %d, id = %d", category, ie.Identifier());
  2381                         OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_INSTALLCONTROLINFORMATIONELEMENTSL_3, "CSmsMessage::InstallControlInformationElementsL category = %d, id = %d", category, ie.Identifier());
  2384                         User::Leave(KErrArgument);
  2382                         User::Leave(KErrArgument);
  2385                         }
  2383                         }
  2386                     break;
  2384                     break;
  2387                 case  TSmsInformationElementCategories::ECtrlMandatoryIn1stPDUOnly:
  2385                 case  TSmsInformationElementCategories::ECtrlMandatoryIn1stPDUOnly:
  2388                 case  TSmsInformationElementCategories::ECtrlSingleInstanceOnly:
  2386                 case  TSmsInformationElementCategories::ECtrlSingleInstanceOnly:
  2389                     {
  2387                     {
  2390                     LOGGSMU2("CSmsMessage::InstallControlInformationElements ECtrlMandatoryIn1stPDUOnly "
  2388                     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_INSTALLCONTROLINFORMATIONELEMENTSL_4, "CSmsMessage::InstallControlInformationElements ECtrlMandatoryIn1stPDUOnly ""ECtrlSingleInstanceOnly, id = %d", ie.Identifier());
  2391                                  "ECtrlSingleInstanceOnly, id = %d", ie.Identifier());
       
  2392 
  2389 
  2393                     TUint index = 0;
  2390                     TUint index = 0;
  2394                     if (iAdditionalInfo->Find1stInstanceOfControlInformationElement(ie.Identifier(), index))
  2391                     if (iAdditionalInfo->Find1stInstanceOfControlInformationElement(ie.Identifier(), index))
  2395                         {
  2392                         {
  2396                         iAdditionalInfo->DeleteControlInformationElement(category, index); //  might want to pass the
  2393                         iAdditionalInfo->DeleteControlInformationElement(category, index); //  might want to pass the
  2411                         }
  2408                         }
  2412                     break;
  2409                     break;
  2413                     }
  2410                     }
  2414                 case  TSmsInformationElementCategories::ECtrlMandatoryInEveryPDUAndWithIdenticalValues:
  2411                 case  TSmsInformationElementCategories::ECtrlMandatoryInEveryPDUAndWithIdenticalValues:
  2415                     {
  2412                     {
  2416                     LOGGSMU2("CSmsMessage::InstallControlInformationElements ECtrlMandatoryInEveryPDUAndWithIdenticalValues "
  2413                     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_INSTALLCONTROLINFORMATIONELEMENTSL_5, "CSmsMessage::InstallControlInformationElements ECtrlMandatoryInEveryPDUAndWithIdenticalValues ""ECtrlSingleInstanceOnly, id = %d", ie.Identifier());
  2417                                  "ECtrlSingleInstanceOnly, id = %d", ie.Identifier());
       
  2418                     TInt index = 0;
  2414                     TInt index = 0;
  2419                     if (SmsPDU().UserData().InformationElementIndex(ie.Identifier(),index))
  2415                     if (SmsPDU().UserData().InformationElementIndex(ie.Identifier(),index))
  2420                         {
  2416                         {
  2421                         CSmsInformationElement* newInformationElement = CSmsInformationElement::NewL(ie.Identifier(),ie.Data());
  2417                         CSmsInformationElement* newInformationElement = CSmsInformationElement::NewL(ie.Identifier(),ie.Data());
  2422 
  2418 
  2436                     break;
  2432                     break;
  2437                     }
  2433                     }
  2438 
  2434 
  2439                 case  TSmsInformationElementCategories::ECtrlMultipleInstancesAllowed:
  2435                 case  TSmsInformationElementCategories::ECtrlMultipleInstancesAllowed:
  2440                     {
  2436                     {
  2441                     LOGGSMU2("CSmsMessage::InstallControlInformationElements ECtrlMandatoryInEveryPDUAndWithIdenticalValues "
  2437                     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_INSTALLCONTROLINFORMATIONELEMENTSL_6, "CSmsMessage::InstallControlInformationElements ECtrlMandatoryInEveryPDUAndWithIdenticalValues ""ECtrlSingleInstanceOnly, id = %d", ie.Identifier() );
  2442                                  "ECtrlSingleInstanceOnly, id = %d", ie.Identifier() );
       
  2443 
  2438 
  2444                     CSmsInformationElement* cloneInformationElement = CSmsInformationElement::NewL( ie.Identifier(),ie.Data() );
  2439                     CSmsInformationElement* cloneInformationElement = CSmsInformationElement::NewL( ie.Identifier(),ie.Data() );
  2445                     CleanupStack::PushL(cloneInformationElement);
  2440                     CleanupStack::PushL(cloneInformationElement);
  2446                     iAdditionalInfo->AddControlInformationElementL( TSmsInformationElementCategories::ECtrlMultipleInstancesAllowed, cloneInformationElement);
  2441                     iAdditionalInfo->AddControlInformationElementL( TSmsInformationElementCategories::ECtrlMultipleInstancesAllowed, cloneInformationElement);
  2447                     CleanupStack::Pop(cloneInformationElement);
  2442                     CleanupStack::Pop(cloneInformationElement);
  2448                     break;
  2443                     break;
  2449                     }
  2444                     }
  2450                 case  TSmsInformationElementCategories::ECtrlMandatoryInEveryPDUButWithValueSpecificToPDU:
  2445                 case  TSmsInformationElementCategories::ECtrlMandatoryInEveryPDUButWithValueSpecificToPDU:
  2451                     LOGGSMU2("CSmsMessage::InstallControlInformationElements ECtrlMandatoryInEveryPDUButWithValueSpecificToPDU "
  2446                     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_INSTALLCONTROLINFORMATIONELEMENTSL_7, "CSmsMessage::InstallControlInformationElements ECtrlMandatoryInEveryPDUButWithValueSpecificToPDU ""ECtrlSingleInstanceOnly, id = %d", ie.Identifier() );
  2452                                  "ECtrlSingleInstanceOnly, id = %d", ie.Identifier() );
       
  2453                     
  2447                     
  2454                     if (ie.Identifier() == CSmsInformationElement::ESmsIEISMSCControlParameters)
  2448                     if (ie.Identifier() == CSmsInformationElement::ESmsIEISMSCControlParameters)
  2455                     	{
  2449                     	{
  2456                        	if(scheme.Id() == EControlParametersScheme)
  2450                        	if(scheme.Id() == EControlParametersScheme)
  2457                     		{
  2451                     		{
  2474                     // e.g  Email Header / Concatenation Elements.
  2468                     // e.g  Email Header / Concatenation Elements.
  2475                     // Consider whether EMail Header should be ported here.
  2469                     // Consider whether EMail Header should be ported here.
  2476                     // or left as is.
  2470                     // or left as is.
  2477                     break;
  2471                     break;
  2478                 case  TSmsInformationElementCategories::EEmsInformationElement:
  2472                 case  TSmsInformationElementCategories::EEmsInformationElement:
  2479                     LOGGSMU2("CSmsMessage::InstallControlInformationElements ECtrlMandatoryInEveryPDUButWithValueSpecificToPDU "
  2473                     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_INSTALLCONTROLINFORMATIONELEMENTSL_8, "CSmsMessage::InstallControlInformationElements ECtrlMandatoryInEveryPDUButWithValueSpecificToPDU ""ECtrlSingleInstanceOnly, id = %d", ie.Identifier() );
  2480                                  "ECtrlSingleInstanceOnly, id = %d", ie.Identifier() );
       
  2481                     // Will be handled in the method InstallEmsInformationElements, nothing to do here
  2474                     // Will be handled in the method InstallEmsInformationElements, nothing to do here
  2482                     break;
  2475                     break;
  2483                 default:
  2476                 default:
  2484                     LOGGSMU3("CSmsMessage::InstallControlInformationElementsToMultiSegmentMessageL, default switch, category = %d, id= %d", category, ie.Identifier() );
  2477                     OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_INSTALLCONTROLINFORMATIONELEMENTSL_9, "CSmsMessage::InstallControlInformationElementsToMultiSegmentMessageL, default switch, category = %d, id= %d", category, ie.Identifier() );
  2485                     break;
  2478                     break;
  2486                 }
  2479                 }
  2487             }
  2480             }
  2488     	}
  2481     	}
  2489     } // CSmsMessage::InstallControlInformationElementsL
  2482     } // CSmsMessage::InstallControlInformationElementsL
  2497  *  of the UserData.
  2490  *  of the UserData.
  2498  */
  2491  */
  2499 void  CSmsMessage::InstallEmsInformationElementsL(CSmsUserData& aUserData, TInt aCharsAlreadyAdded)
  2492 void  CSmsMessage::InstallEmsInformationElementsL(CSmsUserData& aUserData, TInt aCharsAlreadyAdded)
  2500 	{
  2493 	{
  2501 	// Installs all the information elements within the subsequent PDUs.
  2494 	// Installs all the information elements within the subsequent PDUs.
  2502 	LOGGSMU1("CSmsMessage::InstallEmsInformationElements()");
  2495 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_INSTALLEMSINFORMATIONELEMENTSL_1, "CSmsMessage::InstallEmsInformationElements()");
  2503 
  2496 
  2504 	CSmsInformationElement::TSmsInformationElementIdentifier id;
  2497 	CSmsInformationElement::TSmsInformationElementIdentifier id;
  2505 	CEmsInformationElement* newIE =NULL;
  2498 	CEmsInformationElement* newIE =NULL;
  2506 
  2499 
  2507 	for (TInt z=0; z<aUserData.NumInformationElements(); z++)
  2500 	for (TInt z=0; z<aUserData.NumInformationElements(); z++)
  2545     {
  2538     {
  2546     // Ignore in code coverage - not used in SMS stack and not exported
  2539     // Ignore in code coverage - not used in SMS stack and not exported
  2547     // but cannot be removed as impacts public header.
  2540     // but cannot be removed as impacts public header.
  2548     BULLSEYE_OFF    
  2541     BULLSEYE_OFF    
  2549     // Installs all the information elements within the subsequent PDUs.
  2542     // Installs all the information elements within the subsequent PDUs.
  2550     LOGGSMU1("CSmsMessage::InstallEmsInformationElements()");
  2543     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_INSTALLEMSINFORMATIONELEMENTSL1_1, "CSmsMessage::InstallEmsInformationElements()");
  2551     
  2544     
  2552     CSmsInformationElement::TSmsInformationElementIdentifier id;
  2545     CSmsInformationElement::TSmsInformationElementIdentifier id;
  2553     CEmsInformationElement* newIE=NULL;
  2546     CEmsInformationElement* newIE=NULL;
  2554     
  2547     
  2555     for (TInt z=0; z<aCommand.NumInformationElements(); z++)
  2548     for (TInt z=0; z<aCommand.NumInformationElements(); z++)
  2671  *  
  2664  *  
  2672  *  @capability None
  2665  *  @capability None
  2673  */
  2666  */
  2674 EXPORT_C void CSmsMessage::AddEMSInformationElementL(const CEmsInformationElement& aEmsIE)
  2667 EXPORT_C void CSmsMessage::AddEMSInformationElementL(const CEmsInformationElement& aEmsIE)
  2675 	{
  2668 	{
  2676 	LOGGSMU1("CSmsMessage::AddEMSInformationElementL()");
  2669 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_ADDEMSINFORMATIONELEMENTL_1, "CSmsMessage::AddEMSInformationElementL()");
  2677 
  2670 
  2678 	if(aEmsIE.StartPosition() > (TUint)iBuffer->Length())
  2671 	if(aEmsIE.StartPosition() > (TUint)iBuffer->Length())
  2679 		{
  2672 		{
  2680 		User::Leave(KErrOverflow);
  2673 		User::Leave(KErrOverflow);
  2681 		}
  2674 		}
  2713 	} // CSmsMessage::AddEMSInformationElementL
  2706 	} // CSmsMessage::AddEMSInformationElementL
  2714 
  2707 
  2715 
  2708 
  2716 TBool CSmsMessage::CanBeRemoved(const CEmsInformationElement& aIE, const TUint aIEIndex)
  2709 TBool CSmsMessage::CanBeRemoved(const CEmsInformationElement& aIE, const TUint aIEIndex)
  2717 	{
  2710 	{
  2718 	LOGGSMU1("CSmsMessage::CanBeRemoved()");
  2711 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_CANBEREMOVED_1, "CSmsMessage::CanBeRemoved()");
  2719 
  2712 
  2720 	TBool ret=ETrue;
  2713 	TBool ret=ETrue;
  2721 	if(CSmsInformationElement::ESmsEnhancedODI == aIE.Identifier())
  2714 	if(CSmsInformationElement::ESmsEnhancedODI == aIE.Identifier())
  2722 		return ret;
  2715 		return ret;
  2723 
  2716 
  2738 		    if ((static_cast<CEmsObjectDistribution*>(ie)->ObjectCount()+i) >= aIEIndex || static_cast<CEmsObjectDistribution*>(ie)->ObjectCount() == 0)
  2731 		    if ((static_cast<CEmsObjectDistribution*>(ie)->ObjectCount()+i) >= aIEIndex || static_cast<CEmsObjectDistribution*>(ie)->ObjectCount() == 0)
  2739 		        ret=EFalse;
  2732 		        ret=EFalse;
  2740 		    }
  2733 		    }
  2741 		}
  2734 		}
  2742 
  2735 
  2743 	LOGGSMU2("CSmsMessage::CanBeRemoved() returns %d", ret);
  2736 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_CANBEREMOVED_2, "CSmsMessage::CanBeRemoved() returns %d", ret);
  2744 
  2737 
  2745 	return ret;
  2738 	return ret;
  2746 	} // CSmsMessage::CanBeRemoved
  2739 	} // CSmsMessage::CanBeRemoved
  2747 
  2740 
  2748 
  2741 
  2751  *  
  2744  *  
  2752  *  @param aEmsIE EMS object to be added.
  2745  *  @param aEmsIE EMS object to be added.
  2753  */
  2746  */
  2754 void CSmsMessage::AddEmsUserPromptL(const CEmsUserPrompt& aUserPromptIE)
  2747 void CSmsMessage::AddEmsUserPromptL(const CEmsUserPrompt& aUserPromptIE)
  2755 	{
  2748 	{
  2756 	LOGGSMU1("CSmsMessage::AddEmsUserPromptL()");
  2749 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ADDEMSUSERPROMPTL_1, "CSmsMessage::AddEmsUserPromptL()");
  2757 
  2750 
  2758 		if(aUserPromptIE.ObjectCount() == 0 )User::Leave(KErrArgument);
  2751 		if(aUserPromptIE.ObjectCount() == 0 )User::Leave(KErrArgument);
  2759 
  2752 
  2760 		TUint count=iInformationElementArray->Count();
  2753 		TUint count=iInformationElementArray->Count();
  2761 		TUint userPromptStartPosition=aUserPromptIE.StartPosition();
  2754 		TUint userPromptStartPosition=aUserPromptIE.StartPosition();
  2828  *  
  2821  *  
  2829  *  @param aEmsIE EMS object to be added.
  2822  *  @param aEmsIE EMS object to be added.
  2830  */
  2823  */
  2831 void CSmsMessage::AddEmsObjectDistributionL(const CEmsObjectDistribution& aObjectDistributionIE)
  2824 void CSmsMessage::AddEmsObjectDistributionL(const CEmsObjectDistribution& aObjectDistributionIE)
  2832     {
  2825     {
  2833 	LOGGSMU1("CSmsMessage::AddEmsObjectDistributionL()");
  2826 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ADDEMSOBJECTDISTRIBUTIONL_1, "CSmsMessage::AddEmsObjectDistributionL()");
  2834 
  2827 
  2835     TUint count=iInformationElementArray->Count();
  2828     TUint count=iInformationElementArray->Count();
  2836     TUint objectDistributionStartPosition=aObjectDistributionIE.StartPosition();
  2829     TUint objectDistributionStartPosition=aObjectDistributionIE.StartPosition();
  2837 
  2830 
  2838     TBool firstIndexFound=EFalse;
  2831     TBool firstIndexFound=EFalse;
  2880  *  @capability
  2873  *  @capability
  2881  *  @capability None
  2874  *  @capability None
  2882  */
  2875  */
  2883 EXPORT_C CEmsInformationElement* CSmsMessage::RemoveEMSInformationElementL(const TUint aStartPosition,const TSmsId aEmsId)
  2876 EXPORT_C CEmsInformationElement* CSmsMessage::RemoveEMSInformationElementL(const TUint aStartPosition,const TSmsId aEmsId)
  2884 	{
  2877 	{
  2885 	LOGGSMU1("CSmsMessage::RemoveEMSInformationElementL()");
  2878 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_REMOVEEMSINFORMATIONELEMENTL_1, "CSmsMessage::RemoveEMSInformationElementL()");
  2886 
  2879 
  2887 	CEmsInformationElement* emsIE=NULL;
  2880 	CEmsInformationElement* emsIE=NULL;
  2888 	CEmsInformationElement* ie=NULL;
  2881 	CEmsInformationElement* ie=NULL;
  2889 
  2882 
  2890 	TUint count=iInformationElementArray->Count();
  2883 	TUint count=iInformationElementArray->Count();
  2918  *  
  2911  *  
  2919  *  @capability None
  2912  *  @capability None
  2920  */
  2913  */
  2921 EXPORT_C RPointerArray<CEmsInformationElement>* CSmsMessage::RemoveEMSInformationElementsL(const TUint aStartPosition,const TSmsId aEmsId)
  2914 EXPORT_C RPointerArray<CEmsInformationElement>* CSmsMessage::RemoveEMSInformationElementsL(const TUint aStartPosition,const TSmsId aEmsId)
  2922 	{
  2915 	{
  2923 	LOGGSMU1("CSmsMessage::RemoveEMSInformationElementsL()");
  2916 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_REMOVEEMSINFORMATIONELEMENTSL_1, "CSmsMessage::RemoveEMSInformationElementsL()");
  2924 
  2917 
  2925 	CEmsInformationElement* ie=NULL;
  2918 	CEmsInformationElement* ie=NULL;
  2926 	RPointerArray<CEmsInformationElement>* selectedIEs = NULL;
  2919 	RPointerArray<CEmsInformationElement>* selectedIEs = NULL;
  2927 	TUint count=iInformationElementArray->Count();
  2920 	TUint count=iInformationElementArray->Count();
  2928 
  2921 
  2949  *  
  2942  *  
  2950  *  @capability None
  2943  *  @capability None
  2951  */
  2944  */
  2952 EXPORT_C void  CSmsMessage::ResetEMSL()
  2945 EXPORT_C void  CSmsMessage::ResetEMSL()
  2953 	{
  2946 	{
  2954 	LOGGSMU1("CSmsMessage::ResetEMSL()");
  2947 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_RESETEMSL_1, "CSmsMessage::ResetEMSL()");
  2955 
  2948 
  2956 	iInformationElementArray->ResetAndDestroy();
  2949 	iInformationElementArray->ResetAndDestroy();
  2957 	} // CSmsMessage::ResetEMSL
  2950 	} // CSmsMessage::ResetEMSL
  2958 
  2951 
  2959 /**
  2952 /**
  2963  *  
  2956  *  
  2964  *  @capability None
  2957  *  @capability None
  2965  */
  2958  */
  2966 EXPORT_C const RPointerArray<const CEmsInformationElement>& CSmsMessage::GetEMSInformationElementsL()const
  2959 EXPORT_C const RPointerArray<const CEmsInformationElement>& CSmsMessage::GetEMSInformationElementsL()const
  2967 	{
  2960 	{
  2968 	LOGGSMU1("CSmsMessage::GetEMSInformationElementsL()");
  2961 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_GETEMSINFORMATIONELEMENTSL_1, "CSmsMessage::GetEMSInformationElementsL()");
  2969 
  2962 
  2970 	 return (const RPointerArray<const CEmsInformationElement>&)(*iInformationElementArray);
  2963 	 return (const RPointerArray<const CEmsInformationElement>&)(*iInformationElementArray);
  2971 	} // CSmsMessage::GetEMSInformationElementsL
  2964 	} // CSmsMessage::GetEMSInformationElementsL
  2972 
  2965 
  2973 
  2966 
  2974 void CSmsMessage::UpdateUserPromptAndODIElementsStartPosition()
  2967 void CSmsMessage::UpdateUserPromptAndODIElementsStartPosition()
  2975 	{
  2968 	{
  2976 	LOGGSMU1("CSmsMessage::UpdateUserPromptAndODIElementsStartPosition()");
  2969 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_UPDATEUSERPROMPTANDODIELEMENTSSTARTPOSITION_1, "CSmsMessage::UpdateUserPromptAndODIElementsStartPosition()");
  2977 
  2970 
  2978 		TUint num=iInformationElementArray->Count();
  2971 		TUint num=iInformationElementArray->Count();
  2979 		TInt startPosition=-1;
  2972 		TInt startPosition=-1;
  2980 		CEmsInformationElement* ie = NULL;
  2973 		CEmsInformationElement* ie = NULL;
  2981 
  2974 
  2999 	} // CSmsMessage::UpdateUserPromptAndODIElementsStartPosition
  2992 	} // CSmsMessage::UpdateUserPromptAndODIElementsStartPosition
  3000 
  2993 
  3001 
  2994 
  3002 TInt CSmsMessage::AddReceivedEmsInformationElement(CEmsInformationElement* aEmsIE)
  2995 TInt CSmsMessage::AddReceivedEmsInformationElement(CEmsInformationElement* aEmsIE)
  3003 	{
  2996 	{
  3004 	LOGGSMU1("CSmsMessage::AddReceivedEmsInformationElement()");
  2997 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_ADDRECEIVEDEMSINFORMATIONELEMENT_1, "CSmsMessage::AddReceivedEmsInformationElement()");
  3005 
  2998 
  3006 	TInt ret=KErrNone;
  2999 	TInt ret=KErrNone;
  3007 	if(CSmsInformationElement::ESmsEnhancedUserPromptIndicator == aEmsIE->Identifier() || CSmsInformationElement::ESmsEnhancedODI == aEmsIE->Identifier())
  3000 	if(CSmsInformationElement::ESmsEnhancedUserPromptIndicator == aEmsIE->Identifier() || CSmsInformationElement::ESmsEnhancedODI == aEmsIE->Identifier())
  3008 		ret=iInformationElementArray->Append(aEmsIE);
  3001 		ret=iInformationElementArray->Append(aEmsIE);
  3009 	else
  3002 	else
  3032  *  
  3025  *  
  3033  *  @capability None
  3026  *  @capability None
  3034  */
  3027  */
  3035 EXPORT_C void CSmsMessage::UpdateSlotsL(TDesC8& aDesc)
  3028 EXPORT_C void CSmsMessage::UpdateSlotsL(TDesC8& aDesc)
  3036     {
  3029     {
  3037 	LOGGSMU1("CSmsMessage::UpdateSlotsL()");
  3030 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_UPDATESLOTSL_1, "CSmsMessage::UpdateSlotsL()");
  3038 
  3031 
  3039     TGsmSmsSlotEntry newSlot;
  3032     TGsmSmsSlotEntry newSlot;
  3040 
  3033 
  3041     switch (aDesc[0])
  3034     switch (aDesc[0])
  3042         {
  3035         {
  3075  *  
  3068  *  
  3076  *  @capability None
  3069  *  @capability None
  3077  */
  3070  */
  3078 EXPORT_C void CSmsMessage::CopyEmsElementsL(CSmsMessage& aToMessage) const
  3071 EXPORT_C void CSmsMessage::CopyEmsElementsL(CSmsMessage& aToMessage) const
  3079 	{
  3072 	{
  3080 	LOGGSMU1("CSmsMessage::CopyEmsElementsL()");
  3073 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_COPYEMSELEMENTSL_1, "CSmsMessage::CopyEmsElementsL()");
  3081 
  3074 
  3082 	// CSmsMessage extended EMS API method creates array of references to EMS elements in
  3075 	// CSmsMessage extended EMS API method creates array of references to EMS elements in
  3083 	// the source message
  3076 	// the source message
  3084 	// Loop through the array copying each individual method using the CSmsMessage
  3077 	// Loop through the array copying each individual method using the CSmsMessage
  3085 	// and CEmsInformationElement API's
  3078 	// and CEmsInformationElement API's
  3097 /**
  3090 /**
  3098  *  @capability None
  3091  *  @capability None
  3099  */
  3092  */
  3100 EXPORT_C void CSmsMessage::AddSlotL(const TGsmSmsSlotEntry& aSlot)
  3093 EXPORT_C void CSmsMessage::AddSlotL(const TGsmSmsSlotEntry& aSlot)
  3101 	{
  3094 	{
  3102 	LOGGSMU1("CSmsMessage::AddSlotL()");
  3095 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_ADDSLOTL_1, "CSmsMessage::AddSlotL()");
  3103 
  3096 
  3104 		TInt count = iSlotArray.Count();
  3097 		TInt count = iSlotArray.Count();
  3105 		TInt i(0);
  3098 		TInt i(0);
  3106 		TBool found(EFalse);
  3099 		TBool found(EFalse);
  3107 		while(!found && i<count)
  3100 		while(!found && i<count)
  3108 		{
  3101 		{
  3109 			if(aSlot.iIndex == iSlotArray[i].iIndex)found=ETrue;
  3102 			if(aSlot.iIndex == iSlotArray[i].iIndex)found=ETrue;
  3110 			else ++i;
  3103 			else ++i;
  3111 		}
  3104 		}
  3112 		LOGGSMU3("CSmsMessage::AddSlotL current no in: %d, adds index %d", count,aSlot.iIndex );
  3105 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_ADDSLOTL_2, "CSmsMessage::AddSlotL current no in: %d, adds index %d", count,aSlot.iIndex );
  3113 		LOGGSMU3("found %d at position %d",found,i);
  3106 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_ADDSLOTL_3, "found %d at position %d",found,i);
  3114 		iSlotArray.AppendL(aSlot);
  3107 		iSlotArray.AppendL(aSlot);
  3115 	} // CSmsMessage::AddSlotL
  3108 	} // CSmsMessage::AddSlotL
  3116 
  3109 
  3117 /**
  3110 /**
  3118  *  @capability None
  3111  *  @capability None
  3119  */
  3112  */
  3120 EXPORT_C TBool CSmsMessage::MatchSlots(const CArrayFixFlat<TGsmSmsSlotEntry>& aSlotArray)
  3113 EXPORT_C TBool CSmsMessage::MatchSlots(const CArrayFixFlat<TGsmSmsSlotEntry>& aSlotArray)
  3121 	{
  3114 	{
  3122 	LOGGSMU1("CSmsMessage::MatchSlots()");
  3115 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_MATCHSLOTS_1, "CSmsMessage::MatchSlots()");
  3123 
  3116 
  3124 		TBool match = EFalse;
  3117 		TBool match = EFalse;
  3125 		TInt count = aSlotArray.Count();
  3118 		TInt count = aSlotArray.Count();
  3126 		if(iSlotArray.Count() == count)
  3119 		if(iSlotArray.Count() == count)
  3127 		{
  3120 		{
  3178   *  of the UserData.
  3171   *  of the UserData.
  3179   */
  3172   */
  3180 void  CSmsMessage::InstallEmailHeaderInformationElementL(CSmsUserData& aUserData,TInt& aHeaderLength)
  3173 void  CSmsMessage::InstallEmailHeaderInformationElementL(CSmsUserData& aUserData,TInt& aHeaderLength)
  3181  	{
  3174  	{
  3182  	// Installs all the information elements within the subsequent PDUs.
  3175  	// Installs all the information elements within the subsequent PDUs.
  3183  	LOGGSMU1("CSmsMessage::InstallEmailHeaderInformationElementL()");
  3176  	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_INSTALLEMAILHEADERINFORMATIONELEMENTL_1, "CSmsMessage::InstallEmailHeaderInformationElementL()");
  3184 
  3177 
  3185  	CSmsInformationElement::TSmsInformationElementIdentifier id;
  3178  	CSmsInformationElement::TSmsInformationElementIdentifier id;
  3186 
  3179 
  3187  	for (TInt z=0; z<aUserData.NumInformationElements(); z++)
  3180  	for (TInt z=0; z<aUserData.NumInformationElements(); z++)
  3188  		{
  3181  		{
  3207     {
  3200     {
  3208     // Ignore in code coverage - not used in SMS stack and not exported
  3201     // Ignore in code coverage - not used in SMS stack and not exported
  3209     // but cannot be removed as impacts public header.
  3202     // but cannot be removed as impacts public header.
  3210     BULLSEYE_OFF    
  3203     BULLSEYE_OFF    
  3211     // Installs all the information elements within the subsequent PDUs.
  3204     // Installs all the information elements within the subsequent PDUs.
  3212     LOGGSMU1("CSmsMessage::InstallEmailHeaderInformationElementL()");
  3205     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_INSTALLEMAILHEADERINFORMATIONELEMENTL1_1, "CSmsMessage::InstallEmailHeaderInformationElementL()");
  3213     
  3206     
  3214     CSmsInformationElement::TSmsInformationElementIdentifier id;
  3207     CSmsInformationElement::TSmsInformationElementIdentifier id;
  3215     
  3208     
  3216     for (TInt z=0; z<aCommand.NumInformationElements(); z++)
  3209     for (TInt z=0; z<aCommand.NumInformationElements(); z++)
  3217         {
  3210         {
  3238  *  
  3231  *  
  3239  *  @capability None
  3232  *  @capability None
  3240  */
  3233  */
  3241 EXPORT_C void CSmsMessage::AddEmailHeaderL(const TDesC& aEmailHeader, const TDesC& aEmailBody)
  3234 EXPORT_C void CSmsMessage::AddEmailHeaderL(const TDesC& aEmailHeader, const TDesC& aEmailBody)
  3242  	{
  3235  	{
  3243  	LOGGSMU1("CSmsMessage::AddEmailHeaderL()");
  3236  	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_ADDEMAILHEADERL_1, "CSmsMessage::AddEmailHeaderL()");
  3244 
  3237 
  3245  	if(IsEmailHeader())
  3238  	if(IsEmailHeader())
  3246  		User::Leave(KErrAlreadyExists);
  3239  		User::Leave(KErrAlreadyExists);
  3247 
  3240 
  3248  	TInt len =aEmailHeader.Length();
  3241  	TInt len =aEmailHeader.Length();
  3286   *  
  3279   *  
  3287   *  @capability None
  3280   *  @capability None
  3288   */
  3281   */
  3289 EXPORT_C TBool CSmsMessage::IsEmailHeader() const
  3282 EXPORT_C TBool CSmsMessage::IsEmailHeader() const
  3290  	{
  3283  	{
  3291  	LOGGSMU1("CSmsMessage::IsEmailHeader()");
  3284  	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_ISEMAILHEADER_1, "CSmsMessage::IsEmailHeader()");
  3292 
  3285 
  3293 	TInt emailIndex;
  3286 	TInt emailIndex;
  3294 	return SmsPDU().UserData().InformationElementIndex(CSmsInformationElement::ESmsIEIRFC822EmailHeader,emailIndex);
  3287 	return SmsPDU().UserData().InformationElementIndex(CSmsInformationElement::ESmsIEIRFC822EmailHeader,emailIndex);
  3295  	} // CSmsMessage::IsEmailHeader
  3288  	} // CSmsMessage::IsEmailHeader
  3296 
  3289 
  3305   *  
  3298   *  
  3306   *  @capability None
  3299   *  @capability None
  3307   */
  3300   */
  3308 EXPORT_C TBool CSmsMessage::GetEmailHeaderL(HBufC** aEmailHeader,HBufC** aEmailBody)
  3301 EXPORT_C TBool CSmsMessage::GetEmailHeaderL(HBufC** aEmailHeader,HBufC** aEmailBody)
  3309  	{
  3302  	{
  3310  	LOGGSMU1("CSmsMessage::GetEmailHeaderL()");
  3303  	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_GETEMAILHEADERL_1, "CSmsMessage::GetEmailHeaderL()");
  3311 
  3304 
  3312  	if(IsEmailHeader())
  3305  	if(IsEmailHeader())
  3313  		{
  3306  		{
  3314  			TInt bufLen=iBuffer->Length();
  3307  			TInt bufLen=iBuffer->Length();
  3315  			TInt emailHeaderLen(0);
  3308  			TInt emailHeaderLen(0);
  3352   *  @publishedAll
  3345   *  @publishedAll
  3353   *  @capability None
  3346   *  @capability None
  3354   */
  3347   */
  3355 EXPORT_C TTimeIntervalSeconds CSmsMessage::UTCOffset() const
  3348 EXPORT_C TTimeIntervalSeconds CSmsMessage::UTCOffset() const
  3356     {
  3349     {
  3357     LOGGSMU1("CSmsMessage::UTCOffset()");
  3350     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_UTCOFFSET_1, "CSmsMessage::UTCOffset()");
  3358 
  3351 
  3359     TUint timeZoneOffset = ((iFlags & ESmsUTCOffsetSecondGranularityMask) >> ESecondBitOffset);
  3352     TUint timeZoneOffset = ((iFlags & ESmsUTCOffsetSecondGranularityMask) >> ESecondBitOffset);
  3360 
  3353 
  3361     if (iFlags & ESmsUTCOffsetSignBit)
  3354     if (iFlags & ESmsUTCOffsetSignBit)
  3362         {
  3355         {
  3378   *  @publishedAll
  3371   *  @publishedAll
  3379   *  @capability None
  3372   *  @capability None
  3380   */
  3373   */
  3381 EXPORT_C TBool CSmsMessage::SetUTCOffset(const TTimeIntervalSeconds& aTimeOffset)
  3374 EXPORT_C TBool CSmsMessage::SetUTCOffset(const TTimeIntervalSeconds& aTimeOffset)
  3382     {
  3375     {
  3383     LOGGSMU1("CSmsMessage::SetUTCOffset()");
  3376     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_SETUTCOFFSET_1, "CSmsMessage::SetUTCOffset()");
  3384 
  3377 
  3385     TBool rc = ETrue;
  3378     TBool rc = ETrue;
  3386 
  3379 
  3387     TInt timeOffset = aTimeOffset.Int();
  3380     TInt timeOffset = aTimeOffset.Int();
  3388 
  3381 
  3401 
  3394 
  3402         iFlags |= (timeOffset << ESecondBitOffset);
  3395         iFlags |= (timeOffset << ESecondBitOffset);
  3403         }
  3396         }
  3404     else
  3397     else
  3405         {
  3398         {
  3406         LOGGSMU2("CSmsMessage::SetUTCOffset offset [out of range] = %d",timeOffset);
  3399         OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_SETUTCOFFSET_2, "CSmsMessage::SetUTCOffset offset [out of range] = %d",timeOffset);
  3407         rc = EFalse;
  3400         rc = EFalse;
  3408         }
  3401         }
  3409 
  3402 
  3410     return rc;
  3403     return rc;
  3411 } // CSmsMessage::SetUTCOffset
  3404 } // CSmsMessage::SetUTCOffset
  3415  *  Returns the message version number.
  3408  *  Returns the message version number.
  3416  *  @capability
  3409  *  @capability
  3417  */
  3410  */
  3418 EXPORT_C TInt CSmsMessage::Version()
  3411 EXPORT_C TInt CSmsMessage::Version()
  3419  	{
  3412  	{
  3420  	LOGGSMU1("CSmsMessage::Version()");
  3413  	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_VERSION_1, "CSmsMessage::Version()");
  3421 
  3414 
  3422  	return iVersion;
  3415  	return iVersion;
  3423  	} // CSmsMessage::Version
  3416  	} // CSmsMessage::Version
  3424 
  3417 
  3425 
  3418 
  3431  *  @return KErrNone if aVersion is valid and successfully set, KErrArgument otherwise.
  3424  *  @return KErrNone if aVersion is valid and successfully set, KErrArgument otherwise.
  3432  *  @capability None
  3425  *  @capability None
  3433  */
  3426  */
  3434 EXPORT_C TInt CSmsMessage::SetVersion(TInt aVersion)
  3427 EXPORT_C TInt CSmsMessage::SetVersion(TInt aVersion)
  3435 	{
  3428 	{
  3436  	LOGGSMU2("CSmsMessage::SetVersion()", aVersion);
  3429  	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_SETVERSION_1, "CSmsMessage::SetVersion(), version = %d", aVersion);
  3437 
  3430 
  3438 	if((aVersion>=ESmsMessageV0) && (aVersion<=ESmsMessageV4))
  3431 	if((aVersion>=ESmsMessageV0) && (aVersion<=ESmsMessageV4))
  3439 		{
  3432 		{
  3440 		iVersion=aVersion;
  3433 		iVersion=aVersion;
  3441 		return KErrNone;
  3434 		return KErrNone;
  3454  *  @param aStream Stream to read from
  3447  *  @param aStream Stream to read from
  3455  *  @capability None
  3448  *  @capability None
  3456  */
  3449  */
  3457 EXPORT_C void CSmsMessage::InternalizeWithoutBufferAndVersionL(RReadStream& aStream)
  3450 EXPORT_C void CSmsMessage::InternalizeWithoutBufferAndVersionL(RReadStream& aStream)
  3458 	{
  3451 	{
  3459  	LOGGSMU1("CSmsMessage::InternalizeWithoutBufferAndVersionL()");
  3452  	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_INTERNALIZEWITHOUTBUFFERANDVERSIONL_1, "CSmsMessage::InternalizeWithoutBufferAndVersionL()");
  3460 
  3453 
  3461 	iFlags=aStream.ReadInt32L();
  3454 	iFlags=aStream.ReadInt32L();
  3462 	iStatus=(NMobileSmsStore::TMobileSmsStoreStatus) aStream.ReadInt32L();
  3455 	iStatus=(NMobileSmsStore::TMobileSmsStoreStatus) aStream.ReadInt32L();
  3463 	iLogServerId=aStream.ReadInt32L();
  3456 	iLogServerId=aStream.ReadInt32L();
  3464 	TInt64 time;
  3457 	TInt64 time;
  3494  *  @param aStream Stream to write to
  3487  *  @param aStream Stream to write to
  3495  *  @capability None
  3488  *  @capability None
  3496  */
  3489  */
  3497 EXPORT_C void CSmsMessage::ExternalizeWithoutBufferAndVersionL(RWriteStream& aStream) const
  3490 EXPORT_C void CSmsMessage::ExternalizeWithoutBufferAndVersionL(RWriteStream& aStream) const
  3498 	{
  3491 	{
  3499  	LOGGSMU1("CSmsMessage::ExternalizeWithoutBufferAndVersionL()");
  3492  	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_EXTERNALIZEWITHOUTBUFFERANDVERSIONL_1, "CSmsMessage::ExternalizeWithoutBufferAndVersionL()");
  3500 
  3493 
  3501 	aStream.WriteInt32L(iFlags);
  3494 	aStream.WriteInt32L(iFlags);
  3502 	aStream.WriteInt32L(iStatus);
  3495 	aStream.WriteInt32L(iStatus);
  3503 	aStream.WriteInt32L(iLogServerId);
  3496 	aStream.WriteInt32L(iLogServerId);
  3504 	aStream << Time().Int64();
  3497 	aStream << Time().Int64();
  3590  *  When there is not accessor class available for the specified type of information element.
  3583  *  When there is not accessor class available for the specified type of information element.
  3591  *  @capability None
  3584  *  @capability None
  3592  */
  3585  */
  3593 EXPORT_C CSmsIEOperation& CSmsMessage::GetOperationsForIEL(CSmsInformationElement::TSmsInformationElementIdentifier aId) const
  3586 EXPORT_C CSmsIEOperation& CSmsMessage::GetOperationsForIEL(CSmsInformationElement::TSmsInformationElementIdentifier aId) const
  3594     {
  3587     {
  3595     LOGGSMU1("CSmsMessage::GetOperationsForIEL()");
  3588     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_GETOPERATIONSFORIEL_1, "CSmsMessage::GetOperationsForIEL()");
  3596 
  3589 
  3597     if (iVersion < CSmsMessage::ESmsMessageV1)
  3590     if (iVersion < CSmsMessage::ESmsMessageV1)
  3598         {
  3591         {
  3599         LOGGSMU2("CSmsMessage::GetOperationsForIEL, Operation not supported, Msg Version %d", iVersion);
  3592         OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_GETOPERATIONSFORIEL_2, "CSmsMessage::GetOperationsForIEL, Operation not supported, Msg Version %d", iVersion);
  3600         User::Leave(KErrNotSupported);
  3593         User::Leave(KErrNotSupported);
  3601         }
  3594         }
  3602 
  3595 
  3603     return iAdditionalInfo->GetIEOperationL(aId);
  3596     return iAdditionalInfo->GetIEOperationL(aId);
  3604     } // CSmsMessage::GetOperationsForIEL
  3597     } // CSmsMessage::GetOperationsForIEL
  3605 
  3598 
  3606 EXPORT_C CSmsNonIEOperation& CSmsMessage::GetOperationsForNonIEL(TSmsNonIEIdentifier aId) const
  3599 EXPORT_C CSmsNonIEOperation& CSmsMessage::GetOperationsForNonIEL(TSmsNonIEIdentifier aId) const
  3607 	{
  3600 	{
  3608 	LOGGSMU1("CSmsMessage::GetOperationsForNonIEL");
  3601 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_GETOPERATIONSFORNONIEL_1, "CSmsMessage::GetOperationsForNonIEL");
  3609 
  3602 
  3610 	if (iVersion < CSmsMessage::ESmsMessageV2)
  3603 	if (iVersion < CSmsMessage::ESmsMessageV2)
  3611 		{
  3604 		{
  3612 		LOGGSMU2("GetOperationsForNonIEL not supported, Msg Version %d", iVersion);
  3605 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_GETOPERATIONSFORNONIEL_2, "GetOperationsForNonIEL not supported, Msg Version %d", iVersion);
  3613 		User::Leave(KErrNotSupported);
  3606 		User::Leave(KErrNotSupported);
  3614 		}
  3607 		}
  3615 
  3608 
  3616 	return iAdditionalInfo->GetNonIEOperationL(aId);
  3609 	return iAdditionalInfo->GetNonIEOperationL(aId);
  3617 	} // CSmsMessage::GetOperationsForNonIEL
  3610 	} // CSmsMessage::GetOperationsForNonIEL
  3618 
  3611 
  3619 
  3612 
  3620 void CSmsMessage::CreateControlIEOperationsClassesL()
  3613 void CSmsMessage::CreateControlIEOperationsClassesL()
  3621     {
  3614     {
  3622  	LOGGSMU1("CSmsMessage::CreateControlIEOperationsClassesL()");
  3615  	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSMESSAGE_CREATECONTROLIEOPERATIONSCLASSESL_1, "CSmsMessage::CreateControlIEOperationsClassesL()");
  3623 
  3616 
  3624     CSmsIEOperation* iEOperation = NULL;
  3617     CSmsIEOperation* iEOperation = NULL;
  3625 
  3618 
  3626     iEOperation = CSmsIEOperation::NewL(CSmsInformationElement::ESmsHyperLinkFormat, *this,	*iCharacterSetConverter, iFs);
  3619     iEOperation = CSmsIEOperation::NewL(CSmsInformationElement::ESmsHyperLinkFormat, *this,	*iCharacterSetConverter, iFs);
  3627     iAdditionalInfo->SetIEOperationL(iEOperation);
  3620     iAdditionalInfo->SetIEOperationL(iEOperation);
  3674  *  Used to indicate that the message was on the SIM when it was decoded.
  3667  *  Used to indicate that the message was on the SIM when it was decoded.
  3675  *  @capability None
  3668  *  @capability None
  3676  */
  3669  */
  3677 EXPORT_C void  CSmsMessage::SetDecodedOnSIM(TBool aOnSim)
  3670 EXPORT_C void  CSmsMessage::SetDecodedOnSIM(TBool aOnSim)
  3678     {
  3671     {
  3679  	LOGGSMU2("CSmsMessage::SetDecodedOnSIM(): %d", aOnSim);
  3672  	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_SETDECODEDONSIM_1, "CSmsMessage::SetDecodedOnSIM(): %d", aOnSim);
  3680 
  3673 
  3681     if (aOnSim)
  3674     if (aOnSim)
  3682         {
  3675         {
  3683         iFlags = iFlags | EDecodedOnSimBit;
  3676         iFlags = iFlags | EDecodedOnSimBit;
  3684         }
  3677         }
  3702  *  False otherwise.
  3695  *  False otherwise.
  3703  *  @capability None
  3696  *  @capability None
  3704  */
  3697  */
  3705 EXPORT_C TBool CSmsMessage::DecodedOnSim()
  3698 EXPORT_C TBool CSmsMessage::DecodedOnSim()
  3706     {
  3699     {
  3707     LOGGSMU1("CSmsMessage::DecodedOnSim()");
  3700     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_DECODEDONSIM_1, "CSmsMessage::DecodedOnSim()");
  3708 
  3701 
  3709     if (iFlags & EDecodedOnSimBit)
  3702     if (iFlags & EDecodedOnSimBit)
  3710         {
  3703         {
  3711         return ETrue;
  3704         return ETrue;
  3712         }
  3705         }
  3728  *  Used to indicate that the message needs to be forwarded to clients.
  3721  *  Used to indicate that the message needs to be forwarded to clients.
  3729  *  @capability None
  3722  *  @capability None
  3730  */
  3723  */
  3731 EXPORT_C void CSmsMessage::SetForwardToClient(TBool aForward)
  3724 EXPORT_C void CSmsMessage::SetForwardToClient(TBool aForward)
  3732     {
  3725     {
  3733  	LOGGSMU2("CSmsMessage::SetForwardToClient(): %d", aForward);
  3726  	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_SETFORWARDTOCLIENT_1, "CSmsMessage::SetForwardToClient(): %d", aForward);
  3734 
  3727 
  3735     if (aForward)
  3728     if (aForward)
  3736         {
  3729         {
  3737         iFlags = iFlags | EForwardToClientBit;
  3730         iFlags = iFlags | EForwardToClientBit;
  3738         }
  3731         }
  3755  *  False otherwise.
  3748  *  False otherwise.
  3756  *  @capability None
  3749  *  @capability None
  3757  */
  3750  */
  3758 EXPORT_C TBool CSmsMessage::ForwardToClient()
  3751 EXPORT_C TBool CSmsMessage::ForwardToClient()
  3759     {
  3752     {
  3760     LOGGSMU1("CSmsMessage::ForwardToClient()");
  3753     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSMSMESSAGE_FORWARDTOCLIENT_1, "CSmsMessage::ForwardToClient()");
  3761 
  3754 
  3762     if (iFlags & EForwardToClientBit)
  3755     if (iFlags & EForwardToClientBit)
  3763         {
  3756         {
  3764         return ETrue;
  3757         return ETrue;
  3765         }
  3758         }