messagingfw/msgtestfw/TestActions/Sms/src/CMtfTestActionSetSchSendSettings.cpp
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     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 // __ACTION_INFO_BEGIN__ 
       
    15 // [Action Name]
       
    16 // SetSchSendSettings
       
    17 // [Action Parameters]
       
    18 // CMsvSession& Session    <input>: Reference to the session.
       
    19 // TMsvId       ServiceId  <input>: Value of the SMS service id.
       
    20 // TInt         Index      <input>: Selects what defaults file to use
       
    21 // [Action Description]
       
    22 // Modifies the settings related to schedule send (namely, system agent condition action array, 
       
    23 // CMsvScheduleSettings), of the specified SMS service to match the ones specified on a file.
       
    24 // [APIs Used]
       
    25 // CMsvEntry::EditStoreL
       
    26 // CSmsSettings::StoreL
       
    27 // CMsvStore::CommitL
       
    28 // __ACTION_INFO_END__
       
    29 // 
       
    30 //
       
    31 
       
    32 #include <msvapi.h>
       
    33 #include <msvsysagentaction.h>
       
    34 #include <msvschedulesettings.h>
       
    35 
       
    36 
       
    37 #include <csmsaccount.h>
       
    38 #include <msvoffpeaktime.h>
       
    39 
       
    40 
       
    41 #include "CMtfTestActionSetSchSendSettings.h"
       
    42 #include "CMtfTestCase.h"
       
    43 #include "CMtfTestActionParameters.h"
       
    44 #include "TMtfTestActionUtilsSchSendScripts.h"
       
    45 
       
    46 
       
    47 CMtfTestAction* CMtfTestActionSetSchSendSettings::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    48 	{
       
    49 	CMtfTestActionSetSchSendSettings* self = new (ELeave) CMtfTestActionSetSchSendSettings(aTestCase);
       
    50 	CleanupStack::PushL(self);
       
    51 	self->ConstructL(aActionParameters);
       
    52 	CleanupStack::Pop(self);
       
    53 	return self;
       
    54 	}
       
    55 	
       
    56 
       
    57 CMtfTestActionSetSchSendSettings::CMtfTestActionSetSchSendSettings(CMtfTestCase& aTestCase)
       
    58 	: CMtfSynchronousTestAction(aTestCase)
       
    59 	{
       
    60 	}
       
    61 
       
    62 
       
    63 void CMtfTestActionSetSchSendSettings::ExecuteActionL()
       
    64 	{
       
    65 
       
    66 
       
    67 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSetSchSendSettings);
       
    68 
       
    69 	// PARAMS 0 & 1 are ignored for the plat sec test action - they should be removed eventually
       
    70 	TInt paramDefaultIndex = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2));			
       
    71 	// Get the settings file name from the test case
       
    72 	const TPtrC settingsFile = TestCase().GetConfigurationFileL(CMtfConfigurationType::EMtfSmsSettings, paramDefaultIndex);
       
    73 	CMsvScheduleSettings* scheduleSettings = CMsvScheduleSettings::NewLC();
       
    74 	TMtfTestActionUtilsSchSendScripts::ReadScheduleSettingsFromConfigurationFileL(TestCase(), settingsFile, *scheduleSettings);
       
    75 
       
    76 	CMsvOffPeakTimes* offPeakTimes = new (ELeave) CMsvOffPeakTimes;
       
    77 	CleanupStack::PushL(offPeakTimes);	
       
    78 	// TODO ? - add some actions to offpeak times using TMsvOffPeakTime API
       
    79 	// not done in pre __MESSAGING_API_V2__ testaction
       
    80 	
       
    81 	CMsvSendErrorActions* sendErrorActions = CMsvSendErrorActions::NewL();
       
    82 	CleanupStack::PushL(sendErrorActions);
       
    83 	// TODO ? - add some send error actions using TMsvSendErrorAction API
       
    84 	// not done in pre __MESSAGING_API_V2__ testaction
       
    85 	
       
    86 	CMsvSysAgentActions* sysAgentActions = new (ELeave) CMsvSysAgentActions;
       
    87 	CleanupStack::PushL(sysAgentActions);
       
    88 	TMtfTestActionUtilsSchSendScripts::ReadScheduleSettingsFromConfigurationFileL(TestCase(), settingsFile, *sysAgentActions);
       
    89 	// TODO ? - add some sys agent actions using TMsvSysAgentConditionAction API
       
    90 	// not done in pre __MESSAGING_API_V2__ testaction
       
    91 	
       
    92 	// save the settings to the central repository 
       
    93 	CSmsAccount *smsAccount = CSmsAccount::NewLC();
       
    94 	smsAccount->SaveSettingsL( *scheduleSettings, *offPeakTimes, *sendErrorActions, *sysAgentActions);
       
    95 
       
    96 	CleanupStack::PopAndDestroy(5, scheduleSettings); // scheduleSettings, offPeakTimes, sendErrorActions, sysAgentActions, smsAccount
       
    97 
       
    98 	
       
    99 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSetSchSendSettings);
       
   100 	TestCase().ActionCompletedL(*this);
       
   101 
       
   102 	}
       
   103