buildverification/smoketest/messaging/Src/TestMessCreateSMSaccount.cpp
branchRCL_3
changeset 19 4ca382093dae
parent 5 6beaa9cf4752
child 20 493058e57c8c
equal deleted inserted replaced
5:6beaa9cf4752 19:4ca382093dae
     1 // Copyright (c) 2002-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 contains CTestMessCreateSmsAccount which creates an SMS
       
    15 // account folder for GSM or CDMA
       
    16 // 
       
    17 //
       
    18 
       
    19 #include "TestMessCreateSmsAccount.h"
       
    20 #include "TestMess.h"
       
    21 #include "Configuration.cfg"
       
    22 
       
    23 // EPOC includes
       
    24 #include <msvids.h>
       
    25 #include <miutset.h>
       
    26 #include <msvstore.h>
       
    27 
       
    28 #include "TestMessCreateGsmSmsUtil.h"
       
    29 //Usage of Macro for CDMA mtm
       
    30 #if (defined CDMA_API_ENABLED)
       
    31 #include "TestMessCreateCdmaSmsUtil.h"
       
    32 #endif
       
    33 
       
    34 #include <csmsaccount.h>
       
    35 #include <msvschedulesettings.h>
       
    36 #include <msvoffpeaktime.h>
       
    37 #include <msvsenderroraction.h>
       
    38 #include <msvsysagentaction.h>
       
    39 
       
    40 /*@{*/
       
    41 _LIT(KSCName,				"scname");
       
    42 _LIT(KSCNumber,				"scnumber");
       
    43 
       
    44 _LIT(KPtGSM,				"GSM");
       
    45 #if (defined CDMA_API_ENABLED)
       
    46 _LIT(KPtMessageBearerType,	"MessageBearerType");
       
    47 _LIT(KPtCDMA,				"CDMA");		
       
    48 #endif
       
    49 /*@}*/
       
    50 
       
    51 CTestMessCreateSmsAccount::CTestMessCreateSmsAccount()
       
    52 :	CTestMessBase(EFalse)
       
    53 	{
       
    54 	SetTestStepName(_L("CreateSmsAccount"));
       
    55 	}
       
    56 
       
    57 /**
       
    58  Creates the SMS account folder for GSM or CDMA. For CDMA mtm,
       
    59  it creates the respective utility class for creating the account
       
    60  @return TVerdict
       
    61 */
       
    62 TVerdict CTestMessCreateSmsAccount::doTestStepL()
       
    63 	{
       
    64 	// Printing to the console and log file
       
    65 	INFO_PRINTF1(_L("Create SMS account"));
       
    66 
       
    67 	TPtrC	ptrSCName;
       
    68 	TBool	returnValue =GetStringFromConfig(ConfigSection(), KSCName, ptrSCName);
       
    69 	INFO_PRINTF2(_L("SC Name = %S"), &ptrSCName);
       
    70 
       
    71 	TPtrC	ptrSCNumber;
       
    72 	returnValue =GetStringFromConfig(ConfigSection(), KSCNumber, ptrSCNumber);
       
    73 	INFO_PRINTF2(_L("SC Number = %S"), &ptrSCNumber);
       
    74 
       
    75 	CSmsAccount*			smsAccount = CSmsAccount::NewLC();
       
    76 	CMsvScheduleSettings*	scheduleSetting = CMsvScheduleSettings::NewLC();
       
    77 	CMsvOffPeakTimes*		offPeakTimes=new (ELeave) CMsvOffPeakTimes();
       
    78 	CleanupStack::PushL(offPeakTimes);
       
    79 	CMsvSendErrorActions*	errorActions=CMsvSendErrorActions::NewLC();
       
    80 	CMsvSysAgentActions*	sysAgentActions=new (ELeave) CMsvSysAgentActions();
       
    81 	CleanupStack::PushL(sysAgentActions);
       
    82 	CSmsSettings*		smsSettings = CSmsSettings::NewL();
       
    83 	CleanupStack::PushL(smsSettings);
       
    84 	SetEntryL(KMsvRootIndexEntryId);
       
    85 
       
    86 	EntryL().SetSortTypeL(SelectionOrdering());
       
    87 	CMsvEntrySelection*	selection=EntryL().ChildrenWithTypeL(KUidMsvServiceEntry);
       
    88 	CleanupStack::PushL(selection);
       
    89 	TInt				count=selection->Count();
       
    90 	TBool				found=EFalse;
       
    91 	for (TInt i=count; i>0 && !found; )
       
    92 		{
       
    93 		SetEntryL(selection->At(--i));
       
    94 
       
    95 		// Only one Sms Service allowed
       
    96 		if	(	EntryL().Entry().iMtm == KUidMsgTypeSMS &&
       
    97 				EntryL().Entry().iType == KUidMsvServiceEntry
       
    98 			)
       
    99 			{
       
   100 			found=ETrue;
       
   101 			}
       
   102 		}
       
   103 
       
   104 	if ( !found )
       
   105 		{
       
   106 		smsAccount->InitialiseDefaultSettingsL(*smsSettings);
       
   107 		smsAccount->InitialiseDefaultSettingsL(*scheduleSetting, *offPeakTimes, *errorActions, *sysAgentActions);
       
   108 
       
   109 		TPtrC	messageBearerType;
       
   110 		messageBearerType.Set(KPtGSM);
       
   111 #if (defined CDMA_API_ENABLED)
       
   112 		GetStringFromConfig(ConfigSection(), KPtMessageBearerType, messageBearerType);
       
   113 		INFO_PRINTF2(_L("The message bearer type is : %S"), &messageBearerType);
       
   114 #endif
       
   115 
       
   116 		CTestMessCreateSmsUtilBase*	createSmsUtil = NULL;
       
   117 		//Creates the util class for GSM or CDMA
       
   118 		if ( messageBearerType.Compare(KPtGSM)==0 )
       
   119 			{
       
   120 			createSmsUtil = new (ELeave) CTestMessCreateGsmSmsUtil(*this);
       
   121 			}
       
   122 #if (defined CDMA_API_ENABLED)
       
   123 		else if( messageBearerType.Compare(KPtCDMA)==0 )
       
   124 			{
       
   125 			createSmsUtil = new (ELeave) CTestMessCreateCdmaSmsUtil(*this);
       
   126 			}
       
   127 #endif
       
   128 		else
       
   129 			{
       
   130 			WARN_PRINTF1(_L("Unknown bearer type using Gsm"));
       
   131 			createSmsUtil= new (ELeave) CTestMessCreateGsmSmsUtil(*this);
       
   132 			}
       
   133 		CleanupStack::PushL(createSmsUtil);
       
   134 
       
   135 		//Changes the new account settings
       
   136 		createSmsUtil->SetSmsAccountSettings(*smsSettings);
       
   137 		CleanupStack::PopAndDestroy(createSmsUtil);
       
   138 
       
   139 		smsAccount->SaveSettingsL(*smsSettings);
       
   140 		smsAccount->SaveSettingsL(*scheduleSetting, *offPeakTimes, *errorActions, *sysAgentActions);
       
   141 		}
       
   142 
       
   143 	if ( TestStepResult()==EPass )
       
   144 		{
       
   145 		smsAccount->LoadSettingsL(*smsSettings);
       
   146 		smsSettings->AddServiceCenterL(ptrSCName, ptrSCNumber);
       
   147 		smsAccount->SaveSettingsL(*smsSettings);
       
   148 		}
       
   149 
       
   150 	CleanupStack::PopAndDestroy(2, smsSettings);
       
   151 	CleanupStack::PopAndDestroy(5, smsAccount);
       
   152 
       
   153 	return TestStepResult();
       
   154 	}