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