0
|
1 |
// Copyright (c) 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 |
@file
|
|
18 |
@internalTechnology
|
|
19 |
*/
|
|
20 |
|
|
21 |
#include "t_scm_config.h"
|
|
22 |
|
|
23 |
_LIT(KConfigureOn, "ConfigureOn");
|
|
24 |
_LIT(KConfigureOff, "ConfigureOff");
|
|
25 |
_LIT(KKeyValue, "value");
|
|
26 |
|
|
27 |
CSCMConfigurationWrapper::CSCMConfigurationWrapper()
|
|
28 |
{}
|
|
29 |
|
|
30 |
CSCMConfigurationWrapper::~CSCMConfigurationWrapper()
|
|
31 |
{
|
|
32 |
iCoreDumpSession.Close();
|
|
33 |
}
|
|
34 |
|
|
35 |
/**
|
|
36 |
* Two phase constructor for CSCMConfigurationWrapper
|
|
37 |
* @return CSCMConfigurationWrapper object
|
|
38 |
* @leave
|
|
39 |
*/
|
|
40 |
CSCMConfigurationWrapper* CSCMConfigurationWrapper::NewL()
|
|
41 |
{
|
|
42 |
CSCMConfigurationWrapper* ret = new (ELeave) CSCMConfigurationWrapper();
|
|
43 |
CleanupStack::PushL(ret);
|
|
44 |
ret->ConstructL();
|
|
45 |
CleanupStack::Pop(ret);
|
|
46 |
return ret;
|
|
47 |
}
|
|
48 |
|
|
49 |
/**
|
|
50 |
* Safe construction
|
|
51 |
* @leave
|
|
52 |
*/
|
|
53 |
void CSCMConfigurationWrapper::ConstructL()
|
|
54 |
{
|
|
55 |
User::LeaveIfError(iCoreDumpSession.Connect());
|
|
56 |
}
|
|
57 |
|
|
58 |
/**
|
|
59 |
* Handle a command invoked from the script
|
|
60 |
* @param aCommand Is the name of the command for a TBuf
|
|
61 |
* @param aSection Is the .ini file section where parameters to the command are located
|
|
62 |
* @param aAsyncErrorIndex Is used by the TEF Block framework to handle asynchronous commands.
|
|
63 |
* @leaves One of the system wide error codes
|
|
64 |
*/
|
|
65 |
TBool CSCMConfigurationWrapper::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
|
|
66 |
{
|
|
67 |
//Get the enum value from the ini file
|
|
68 |
TConfigItem::TSCMDataType type;
|
|
69 |
TInt enumValue;
|
|
70 |
|
|
71 |
if(GetIntFromConfig(aSection,KKeyValue, enumValue))
|
|
72 |
{
|
|
73 |
type = (TConfigItem::TSCMDataType)enumValue;
|
|
74 |
}
|
|
75 |
else
|
|
76 |
{
|
|
77 |
ERR_PRINTF1(_L("Unable to get the proper config option from ini file. Are you sure its valid?"));
|
|
78 |
return EFalse;
|
|
79 |
}
|
|
80 |
|
|
81 |
//Look at the command to see what we need to do
|
|
82 |
if(KConfigureOn() == aCommand)
|
|
83 |
{
|
|
84 |
TurnOnConfigOptionL(type);
|
|
85 |
}
|
|
86 |
else if(KConfigureOff() == aCommand)
|
|
87 |
{
|
|
88 |
TurnOffConfigOptionL(type);
|
|
89 |
}
|
|
90 |
else
|
|
91 |
{
|
|
92 |
ERR_PRINTF1(_L("Unable to get the proper command from script file. Are you sure its valid?"));
|
|
93 |
return EFalse;
|
|
94 |
}
|
|
95 |
|
|
96 |
return ETrue;
|
|
97 |
}
|
|
98 |
|
|
99 |
/**
|
|
100 |
* This method allows the test wrapper to configure the SCM to not dump one of the
|
|
101 |
* possible options
|
|
102 |
* @param aParameter The param we wish to set
|
|
103 |
* @leaves One of the system wide error codes
|
|
104 |
*/
|
|
105 |
void CSCMConfigurationWrapper::TurnOffConfigOptionL(TConfigItem::TSCMDataType& aParameter)
|
|
106 |
{
|
|
107 |
TInt zeroPriority = 0;
|
|
108 |
SetSCMParameterL(aParameter, zeroPriority);
|
|
109 |
}
|
|
110 |
|
|
111 |
/**
|
|
112 |
* This method allows the test wrapper to configure the SCM to dump one of the
|
|
113 |
* possible options
|
|
114 |
* @param aParameter The param we wish to set
|
|
115 |
* @leaves One of the system wide error codes
|
|
116 |
*/
|
|
117 |
void CSCMConfigurationWrapper::TurnOnConfigOptionL(TConfigItem::TSCMDataType& aParameter)
|
|
118 |
{
|
|
119 |
TInt highestPriority = 255;
|
|
120 |
SetSCMParameterL(aParameter, highestPriority);
|
|
121 |
}
|
|
122 |
|
|
123 |
/**
|
|
124 |
* Sets an SCM parameter to a given priority
|
|
125 |
* @param aParameter The SCM parameter we wish to change
|
|
126 |
* @param aPriority The new priority
|
|
127 |
* @leaves One of the System wide codes
|
|
128 |
*/
|
|
129 |
void CSCMConfigurationWrapper::SetSCMParameterL(TConfigItem::TSCMDataType& aParameter, const TInt aPriority)
|
|
130 |
{
|
|
131 |
//Unfortunately, there is no "get by instance" method (just a get by index - which we dont know
|
|
132 |
TInt numConfigParams = iCoreDumpSession.GetNumberConfigParametersL();
|
|
133 |
for(TUint cnt = 0; cnt < numConfigParams; cnt++)
|
|
134 |
{
|
|
135 |
COptionConfig* conf = iCoreDumpSession.GetConfigParameterL(cnt);
|
|
136 |
CleanupStack::PushL(conf);
|
|
137 |
|
|
138 |
if (conf->Source()== COptionConfig::ESCMConfig && conf->Instance() == aParameter)
|
|
139 |
{
|
|
140 |
//Found the one of interest. Set config to desired value
|
|
141 |
INFO_PRINTF3(_L("Setting config value %d to be %d"), aParameter, aPriority);
|
|
142 |
|
|
143 |
conf->Value(aPriority);
|
|
144 |
iCoreDumpSession.SetConfigParameterL(*conf);
|
|
145 |
}
|
|
146 |
CleanupStack::PopAndDestroy(conf);
|
|
147 |
}
|
|
148 |
}
|
|
149 |
|
|
150 |
//eof
|