buildverification/autosmoketest/messaging/Src/TestMessCreateGsmSmsUtil.cpp
changeset 0 9736f095102e
equal deleted inserted replaced
-1:000000000000 0:9736f095102e
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // This class creates the Gsm sms header and service settings. It fills up the
       
    15 // fields using data read from the ini file
       
    16  
       
    17 
       
    18 #include "TestMessCreateGsmSmsUtil.h"
       
    19 
       
    20 /** 
       
    21  Constructor
       
    22 */
       
    23 CTestMessCreateGsmSmsUtil::CTestMessCreateGsmSmsUtil(CTestMessBase &aTestStep)
       
    24 : 	CTestMessCreateSmsUtilBase(aTestStep)
       
    25 	{
       
    26 	aTestStep.INFO_PRINTF1(_L("The GSM SMS util is created"));
       
    27 	}
       
    28 
       
    29 /**
       
    30  Prepares the SMS account details for CSendAs/RSendAs
       
    31  @leave - KErrNoMemory
       
    32  @leave - System wide error codes
       
    33 */
       
    34 void CTestMessCreateGsmSmsUtil::PrepareAccountL(CMsvSession& /*aSession*/)
       
    35 	{
       
    36 	}
       
    37 
       
    38 /**
       
    39  Creates the header object for the GSM sms message
       
    40  @param aBodyText - body text of the message
       
    41  @return CSmsHeader* - pointer to CSmsHeader
       
    42  @leave - KErrNoMemory
       
    43  @leave - system wide error codes
       
    44 */
       
    45 CSmsHeader* CTestMessCreateGsmSmsUtil::NewHeaderL(CRichText &aBodyText)
       
    46 	{
       
    47 	return CSmsHeader::NewL(CSmsPDU::ESmsSubmit, aBodyText);
       
    48 	}
       
    49 
       
    50 /**
       
    51  Fills up the header object with the data read from the ini file.
       
    52  @param aSmsHeader - sms header object ofthe sms message
       
    53  @leave - system wide error codes
       
    54 */
       
    55 void CTestMessCreateGsmSmsUtil::PrepareHeaderL(CSmsHeader &aSmsHeader)
       
    56 	{
       
    57 	//	Get bearer data
       
    58 	TPtrC	ptrBearer;
       
    59 	TBool	returnValue=iTestStep.GetStringFromConfig(iTestStep.ConfigSection(), KBearer, ptrBearer);
       
    60 	if ( !returnValue )
       
    61 		{
       
    62 		//If bearer is not provided, read from the default section of the ini file
       
    63 		returnValue=iTestStep.GetStringFromConfig(KDef, KDefBearer, ptrBearer);
       
    64 		}
       
    65 
       
    66 	if ( returnValue )
       
    67 		{
       
    68 		//default value for Bio message ID type
       
    69 		TBioMsgIdType	bearer = EBioMsgIdNbs;
       
    70 
       
    71 		iTestStep.INFO_PRINTF2(_L("Bearer = %S"), &ptrBearer);
       
    72 		if (ptrBearer.CompareF(KBearerWap) == 0)
       
    73 			{
       
    74 			//Set Wap message ID
       
    75 			bearer = EBioMsgIdWap;
       
    76 			}
       
    77 		else if (ptrBearer.CompareF(KBearerWapSecure) == 0)
       
    78 			{
       
    79 			//Set WapSecure message ID
       
    80 			bearer = EBioMsgIdWapSecure;
       
    81 			}
       
    82 		else
       
    83 			{
       
    84 			iTestStep.INFO_PRINTF1(_L("No supported bearer is provided. Default is used"));
       
    85 			}
       
    86 
       
    87 		//Set the Bio message ID type.
       
    88 #if (defined CDMA_API_ENABLED)
       
    89 		aSmsHeader.BioMessage().SetBioMsgIdType(bearer);
       
    90 #else
       
    91 		aSmsHeader.SetBioMsgIdType(bearer);
       
    92 #endif
       
    93 		}
       
    94 
       
    95 	//	Get encoding data
       
    96 	TInt	encoding;
       
    97 	returnValue=iTestStep.GetIntFromConfig(iTestStep.ConfigSection(), KEncoding, encoding);
       
    98 	if ( !returnValue )
       
    99 		{
       
   100 		//If encoding is not provied, read it from the default section of the ini file
       
   101 		returnValue=iTestStep.GetIntFromConfig(KDef, KDefEncoding, encoding);
       
   102 		}
       
   103 	if ( returnValue )
       
   104 		{
       
   105 		iTestStep.INFO_PRINTF2(_L("Encoding = %d"), encoding);
       
   106 #if (defined CDMA_API_ENABLED)
       
   107 		TSmsCharacterEncoding	charEncoding;
       
   108 
       
   109 		switch (encoding)
       
   110 			{
       
   111 		case 7:
       
   112 			//7 bit encoding format
       
   113 			charEncoding = KSmsEncoding7BitGsm;
       
   114 			break;
       
   115 		case 8:
       
   116 			//8 bit encoding format
       
   117 			charEncoding = KSmsEncodingBinary;
       
   118 			break;
       
   119 		case 16:
       
   120 			//Unicode encoding format
       
   121 			charEncoding = KSmsEncodingUnicode;
       
   122 			break;
       
   123 		default:
       
   124 			//default encoding format
       
   125 			charEncoding = KSmsEncoding7BitGsm;
       
   126 			break;
       
   127 			}
       
   128 
       
   129 		//Set the character encoding
       
   130 		aSmsHeader.BioMessage().SetEncoding(charEncoding);
       
   131 #else
       
   132 		TSmsDataCodingScheme::TSmsAlphabet	alpha = TSmsDataCodingScheme::ESmsAlphabet7Bit;
       
   133 
       
   134 		switch (encoding)
       
   135 			{
       
   136 		case 7:
       
   137 			alpha = TSmsDataCodingScheme::ESmsAlphabet7Bit;
       
   138 			break;
       
   139 		case 8:
       
   140 			alpha = TSmsDataCodingScheme::ESmsAlphabet8Bit;
       
   141 			break;
       
   142 		case 16:
       
   143 			alpha = TSmsDataCodingScheme::ESmsAlphabetUCS2;
       
   144 			break;
       
   145 		default:
       
   146 			alpha = TSmsDataCodingScheme::ESmsAlphabet7Bit;
       
   147 			break;
       
   148 			}
       
   149 
       
   150 		CSmsPDU&	pdu=aSmsHeader.Message().SmsPDU();
       
   151 		if ( pdu.DataCodingSchemePresent() )
       
   152 			{
       
   153 			pdu.SetAlphabet(alpha);
       
   154 			}
       
   155 #endif
       
   156 		}
       
   157 
       
   158 	//	Get delivery report data
       
   159 	TPtrC	ptrDeliveryReport;
       
   160 	returnValue=iTestStep.GetStringFromConfig(iTestStep.ConfigSection(), KDeliveryReport, ptrDeliveryReport);
       
   161 	if ( !returnValue )
       
   162 		{
       
   163 		returnValue=iTestStep.GetStringFromConfig(KDef, KDefDeliveryReport, ptrDeliveryReport);
       
   164 		}
       
   165 	if ( returnValue )
       
   166 		{
       
   167 		TBool	changeDR = EFalse;
       
   168 		TBool	deliveryReport = EFalse;
       
   169 
       
   170 		iTestStep.INFO_PRINTF2(_L("Delivery Report = %S"), &ptrDeliveryReport);
       
   171 		if (ptrDeliveryReport.CompareF(_L("NO")) == 0)
       
   172 			{
       
   173 			changeDR = ETrue;
       
   174 			deliveryReport = EFalse;
       
   175 			}
       
   176 		else if (ptrDeliveryReport.CompareF(_L("YES")) == 0)
       
   177 			{
       
   178 			changeDR = ETrue;
       
   179 			deliveryReport = ETrue;
       
   180 			}
       
   181 
       
   182 		if ( changeDR )
       
   183 			{
       
   184 #if (defined CDMA_API_ENABLED)
       
   185 			aSmsHeader.SetAcknowledgementRequest(ESmsAckTypeDelivery, deliveryReport);
       
   186 #else
       
   187 			switch ( aSmsHeader.Type() )
       
   188 				{
       
   189 			case CSmsPDU::ESmsSubmit:
       
   190 				aSmsHeader.Submit().SetStatusReportRequest(deliveryReport);
       
   191 				break;
       
   192 			case CSmsPDU::ESmsCommand:
       
   193 				aSmsHeader.Command().SetStatusReportRequest(deliveryReport);
       
   194 				break;
       
   195 			default:
       
   196 				User::Leave(KErrNotSupported);
       
   197 				}
       
   198 #endif
       
   199 			}
       
   200 		}
       
   201 	}
       
   202 /**
       
   203  Sets the fields for the sms account settings using data read from the ini file
       
   204  If no data is given in ini file, the default settings in the account is used.
       
   205  @param aSmsSettings - CSmsSettings reference
       
   206 */
       
   207 void CTestMessCreateGsmSmsUtil::SetSmsAccountSettings(CSmsSettings &aSmsSettings)
       
   208 	{
       
   209 	iTestStep.INFO_PRINTF1(_L("Set SMS account Settings...."));
       
   210 	TBool	boolTemp;
       
   211 
       
   212 	//	Set the Reply quoted setting.
       
   213 	if ( iTestStep.GetBoolFromConfig(iTestStep.ConfigSection(), KReplyQuoted, boolTemp) )
       
   214 		{
       
   215 		aSmsSettings.SetReplyQuoted(boolTemp);
       
   216 		}
       
   217 
       
   218 	//	Set the Reject duplicate settings.
       
   219 	if ( iTestStep.GetBoolFromConfig(iTestStep.ConfigSection(), KRejectDuplicate, boolTemp) )
       
   220 		{
       
   221 #if (defined CDMA_API_ENABLED)
       
   222 		aSmsSettings.MessageSettings().Gsm().SetRejectDuplicate(boolTemp);
       
   223 #else
       
   224 		aSmsSettings.SetRejectDuplicate(boolTemp);
       
   225 #endif
       
   226 		}
       
   227 
       
   228 	//	Set the option for delivery report.
       
   229 	if ( iTestStep.GetBoolFromConfig(iTestStep.ConfigSection(), KDeliveryReport, boolTemp) )
       
   230 		{
       
   231 		aSmsSettings.SetDeliveryReport(boolTemp);
       
   232 		}
       
   233 
       
   234 	//	Set the concatenate feature
       
   235 	if ( iTestStep.GetBoolFromConfig(iTestStep.ConfigSection(), KConCatenate, boolTemp) )
       
   236 		{
       
   237 #if (defined CDMA_API_ENABLED)
       
   238 		aSmsSettings.MessageSettings().Gsm().SetCanConcatenate(boolTemp);
       
   239 #else
       
   240 		aSmsSettings.SetCanConcatenate(boolTemp);
       
   241 #endif
       
   242 		}
       
   243 
       
   244 	//	Set whether to use the same path while replying.
       
   245 	if(iTestStep.GetBoolFromConfig(iTestStep.ConfigSection(), KReplyPath, boolTemp))
       
   246 		{
       
   247 #if (defined CDMA_API_ENABLED)
       
   248 		aSmsSettings.MessageSettings().Gsm().SetReplyPath(boolTemp);
       
   249 #else
       
   250 		aSmsSettings.SetReplyPath(boolTemp);
       
   251 #endif
       
   252 		}
       
   253 
       
   254 	//can implement these features later...
       
   255 	aSmsSettings.SetValidityPeriod(ESmsVPWeek);	// week 
       
   256 	aSmsSettings.SetValidityPeriodFormat(TSmsFirstOctet::ESmsVPFInteger); //relative
       
   257 	aSmsSettings.SetDelivery(ESmsDeliveryImmediately);
       
   258 	aSmsSettings.SetMessageConversion(ESmsConvPIDNone);
       
   259 	}