messagingfw/msgtestfw/TestActionUtils/src/TMtfTestActionUtilsSchSendScripts.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     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 //
       
    15 
       
    16 
       
    17 #include "TMtfTestActionUtilsSchSendScripts.h"
       
    18 #include "CMtfTestActionUtilsConfigFileParser.h"
       
    19 #include "CMtfTestCase.h"
       
    20 
       
    21 #include <msvsysagentaction.h>
       
    22 #include <msvschedulesettings.h>
       
    23 #include <e32property.h>
       
    24 
       
    25 _LIT(KCfgConditionActionTotal, "ConditionActionTotal");
       
    26 _LIT(KCfgDefaultErrorActionIndex, "DefaultErrorActionIndex");
       
    27 
       
    28 _LIT(KCfgAgentCondition, "AgentCondition");
       
    29 _LIT(KCfgAgentConditionVariable, ".Variable");
       
    30 _LIT(KCfgAgentConditionState, ".State");
       
    31 _LIT(KCfgAgentConditionType, ".Type");
       
    32 
       
    33 _LIT(KCfgConditionErrorAction, "ConditionErrorAction");
       
    34 
       
    35 _LIT(KCfgErrorActionError, ".Error");
       
    36 _LIT(KCfgErrorActionAction, ".Action");
       
    37 _LIT(KCfgErrorActionRetries, ".Retries");
       
    38 _LIT(KCfgErrorActionRetrySpacing, ".RetrySpacing");
       
    39 _LIT(KCfgErrorActionMaxRetries, ".MaxRetries");
       
    40 _LIT(KCfgConditionActionUseDefault, "UseDefaultErrorAction");
       
    41 
       
    42 _LIT(KCfgPendingConditionTimeOut, "PendingConditionTimeOut");
       
    43 
       
    44 _LIT(KCfgValidityPeriod, "ValidityPeriod");
       
    45 _LIT(KCfgIntervalType, "IntervalType");
       
    46 _LIT(KCfgShortInterval, "ShortInterval");
       
    47 _LIT(KCfgLongInterval, "LongInterval");
       
    48 _LIT(KCfgLatency, "Latency");
       
    49 _LIT(KCfgVariableIntervalCount, "VariableIntervalCount");
       
    50 _LIT(KCfgVariableInterval, "VariableInterval");
       
    51 
       
    52 /**
       
    53 The method reads the CMsvSysAgentActions settings from the configuration file.
       
    54 
       
    55 @param aTestCase			A reference to the current test case
       
    56 @param aSettingsFile		The configuration file name
       
    57 @param aSysAgentActions		A reference to the CMsvSysAgentActions object which is to be set from the configuration file.
       
    58 
       
    59 @internalTechnology
       
    60 */
       
    61 void TMtfTestActionUtilsSchSendScripts::ReadScheduleSettingsFromConfigurationFileL(CMtfTestCase& /** aTestCase */, const TDesC& aSettingsFile, CMsvSysAgentActions& aSysAgentActions)
       
    62 	{
       
    63 	CMtfTestActionUtilsConfigFileParser* scriptFileParser = CMtfTestActionUtilsConfigFileParser::NewL(aSettingsFile);
       
    64 	CleanupStack::PushL(scriptFileParser);
       
    65 
       
    66 	TInt count = 0;
       
    67 	TInt defaultIndex = 0;
       
    68 
       
    69 	// Total number of Condition Actions
       
    70 	scriptFileParser->GetFieldAsInteger(KCfgConditionActionTotal, count);
       
    71 				
       
    72 	// Default Error Action Index
       
    73 	scriptFileParser->GetFieldAsInteger(KCfgDefaultErrorActionIndex, defaultIndex);
       
    74 			
       
    75 	TInt i=0;
       
    76 	TBuf<100> sectionName;	
       
    77 	while(i < count)
       
    78 		{
       
    79 		
       
    80 		TMsvCondition condition; 
       
    81 
       
    82 		sectionName.Copy(KCfgAgentCondition);
       
    83 		sectionName.AppendNum(i);
       
    84 		TInt pos = sectionName.Length();
       
    85 		sectionName.Append(KCfgAgentConditionVariable);
       
    86 		TInt variable = 0;
       
    87 		scriptFileParser->GetFieldAsInteger(sectionName, variable);
       
    88 
       
    89 		condition.iVariable.iUid = variable;
       
    90 			
       
    91 		sectionName.Replace(pos, KCfgAgentConditionVariable().Length(), KCfgAgentConditionState);	
       
    92 		scriptFileParser->GetFieldAsInteger(sectionName, condition.iState);
       
    93 			
       
    94 		variable = 0;
       
    95 		sectionName.Replace(pos, KCfgAgentConditionState().Length(), KCfgAgentConditionType);
       
    96 		scriptFileParser->GetFieldAsInteger(sectionName, variable);
       
    97 		//ESysAgentEquals=32, but EMsvSchSendEquals start with 0
       
    98 		variable -= 32;
       
    99 		condition.iType = static_cast<TMsvCondition::TMsvSchSendConditionType>(variable); 
       
   100 			
       
   101 		TMsvSendErrorAction action;
       
   102 		sectionName.Copy(KCfgConditionErrorAction);
       
   103 		sectionName.AppendNum(i);
       
   104 		pos = sectionName.Length();
       
   105 		sectionName.Append(KCfgErrorActionError);
       
   106 		scriptFileParser->GetFieldAsInteger(sectionName, action.iError);
       
   107 			
       
   108 		variable = 0;
       
   109 		sectionName.Replace(pos, KCfgErrorActionError().Length(), KCfgErrorActionAction);
       
   110 		scriptFileParser->GetFieldAsInteger(sectionName, variable);
       
   111 		action.iAction = static_cast<TMsvSendAction>(variable);	
       
   112 		
       
   113 		variable = 0;
       
   114 		sectionName.Replace(pos, KCfgErrorActionAction().Length(), KCfgErrorActionRetries);			
       
   115 		scriptFileParser->GetFieldAsInteger(sectionName, variable);
       
   116 		action.iRetries = static_cast<TMsvSendRetries>(variable);
       
   117 		
       
   118 		variable = 0;
       
   119 		sectionName.Replace(pos, KCfgErrorActionRetries().Length(), KCfgErrorActionRetrySpacing);	
       
   120 		scriptFileParser->GetFieldAsInteger(sectionName, variable);
       
   121 		action.iRetrySpacing = static_cast<TMsvSendRetrySpacing>(variable);
       
   122 		
       
   123 		variable = 0;
       
   124 		sectionName.Replace(pos, KCfgErrorActionRetrySpacing().Length(), KCfgErrorActionMaxRetries);
       
   125 		scriptFileParser->GetFieldAsInteger(sectionName, variable);
       
   126 		action.SetMaxRetries( static_cast<TInt16>(variable) );
       
   127 
       
   128 		TMsvSysAgentConditionAction conditionAction;
       
   129 		conditionAction.iCondition = condition;
       
   130 		conditionAction.iErrorAction = action;	 						
       
   131 		
       
   132 		sectionName.Copy(KCfgConditionActionUseDefault);
       
   133 		sectionName.AppendNum(i);
       
   134 		scriptFileParser->GetFieldAsInteger(sectionName, conditionAction.iUseDefaultSysAgentAction);		
       
   135 		
       
   136 		aSysAgentActions.AppendL(conditionAction);
       
   137 	
       
   138 		if(i == defaultIndex)
       
   139 			{
       
   140 			aSysAgentActions.iDefault = action;
       
   141 			}
       
   142 		++i;					 					
       
   143 		}
       
   144 	CleanupStack::PopAndDestroy(scriptFileParser);
       
   145 	}
       
   146 
       
   147 /**
       
   148 The method reads the CMsvScheduleSettings settings from the configuration file.
       
   149 
       
   150 @param aTestCase			A reference to the current test case
       
   151 @param aSettingsFile		The configuration file name
       
   152 @param aSysAgentActions		A reference to the CMsvScheduleSettings object which is to be set from the configuration file.
       
   153 
       
   154 @internalTechnology
       
   155 */	
       
   156 void TMtfTestActionUtilsSchSendScripts::ReadScheduleSettingsFromConfigurationFileL(CMtfTestCase& /** aTestCase*/, const TDesC& aSettingsFile, CMsvScheduleSettings& aScheduleSettings)
       
   157 	{
       
   158 	CMtfTestActionUtilsConfigFileParser* scriptFileParser = CMtfTestActionUtilsConfigFileParser::NewL(aSettingsFile);
       
   159 	CleanupStack::PushL(scriptFileParser);
       
   160 	
       
   161 	TInt variable = 0;
       
   162 	TTimeIntervalMinutes minutes;
       
   163 	TTimeIntervalSeconds seconds;
       
   164 	TTimeIntervalMicroSeconds32 microSeconds;
       
   165 	if(scriptFileParser->GetFieldAsInteger(KCfgValidityPeriod, variable) == KErrNone)
       
   166 		{
       
   167 		minutes = variable;
       
   168 		aScheduleSettings.SetValidityPeriod(minutes);
       
   169 		}
       
   170 		
       
   171 	variable = 0;
       
   172 	if(scriptFileParser->GetFieldAsInteger(KCfgIntervalType, variable) == KErrNone)
       
   173 		{
       
   174 		TIntervalType intervalType = static_cast<TIntervalType>(variable);
       
   175 		aScheduleSettings.SetIntervalType(intervalType);
       
   176 		}
       
   177 	
       
   178 	variable = 0;
       
   179 	if(scriptFileParser->GetFieldAsInteger(KCfgShortInterval, variable) == KErrNone)
       
   180 		{
       
   181 		seconds = variable;
       
   182 		aScheduleSettings.SetShortInterval(seconds);
       
   183 		}
       
   184 	
       
   185 	variable = 0;
       
   186 	if(scriptFileParser->GetFieldAsInteger(KCfgLongInterval, variable) == KErrNone)
       
   187 		{
       
   188 		seconds = variable;
       
   189 		aScheduleSettings.SetLongInterval(seconds);
       
   190 		}
       
   191 	
       
   192 	variable = 0;
       
   193 	if(scriptFileParser->GetFieldAsInteger(KCfgLatency, variable) == KErrNone)
       
   194 		{
       
   195 		microSeconds = variable;
       
   196 		aScheduleSettings.SetLatency(microSeconds);
       
   197 		}
       
   198 					
       
   199 	CArrayFixFlat<TTimeIntervalSeconds>* variableIntervals = new (ELeave) CArrayFixFlat<TTimeIntervalSeconds>(1);
       
   200 	CleanupStack::PushL(variableIntervals);
       
   201 	
       
   202 	TInt count = 0;
       
   203 	scriptFileParser->GetFieldAsInteger(KCfgVariableIntervalCount, count);
       
   204 	TBuf<100> sectionName;	
       
   205 	TInt i=0;
       
   206 	while(i < count)
       
   207 		{
       
   208 		sectionName.Copy(KCfgVariableInterval);
       
   209 		sectionName.AppendNum(i);		
       
   210 		scriptFileParser->GetFieldAsInteger(sectionName, variable);
       
   211 		seconds = variable;
       
   212 		variableIntervals->AppendL(seconds);
       
   213 		++i;
       
   214 		}	
       
   215 	
       
   216 	aScheduleSettings.SetVariableIntervalsL(*variableIntervals);
       
   217 	CleanupStack::PopAndDestroy(variableIntervals);
       
   218 	
       
   219 	variable = 0;	
       
   220 	if(scriptFileParser->GetFieldAsInteger(KCfgPendingConditionTimeOut, variable) == KErrNone)
       
   221 		{
       
   222 		minutes = variable;
       
   223 		aScheduleSettings.SetPendingConditionsTimeout(minutes);
       
   224 		}
       
   225 	
       
   226 	CleanupStack::PopAndDestroy(scriptFileParser);
       
   227 	}