|
1 // Copyright (c) 1999-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 // InitializeSimTsy |
|
17 // [Action Parameters] |
|
18 // TInt Section <input>: Section of the SimTsy configuration file to use. |
|
19 // HBufC TsyName <input-optional>: Name of the Tsy to use. Defaults to "SIM". |
|
20 // [Action Description] |
|
21 // Initializes SimTsy with the configuration section specified. |
|
22 // The name of the TSY to use can be specified using the second parameter. |
|
23 // [APIs Used] |
|
24 // __ACTION_INFO_END__ |
|
25 // |
|
26 // |
|
27 |
|
28 |
|
29 #include <e32base.h> |
|
30 #include <e32property.h> |
|
31 #include <simtsy.h> |
|
32 #include <etelmm.h> |
|
33 #include <es_ini.h> |
|
34 #include <commsdattypesv1_1.h> |
|
35 #include <commsdat.h> |
|
36 using namespace CommsDat; |
|
37 #include "CMtfTestActionInitializeSimTsy.h" |
|
38 #include "CMtfTestCase.h" |
|
39 #include "CMtfTestActionParameters.h" |
|
40 |
|
41 |
|
42 const TInt KMsvTestUidPhonePwrValue=0x100052C5; |
|
43 enum TMsvTestPhoneStatus |
|
44 { |
|
45 EMsvTestPhoneOff = 0, |
|
46 EMsvTestPhoneOn |
|
47 }; |
|
48 |
|
49 |
|
50 CMtfTestAction* CMtfTestActionInitializeSimTsy::NewL(CMtfTestCase& aTestCase, CMtfTestActionParameters* aActionParameters) |
|
51 { |
|
52 CMtfTestActionInitializeSimTsy* self = new (ELeave) CMtfTestActionInitializeSimTsy(aTestCase); |
|
53 CleanupStack::PushL(self); |
|
54 self->ConstructL(aActionParameters); |
|
55 CleanupStack::Pop(self); |
|
56 return self; |
|
57 } |
|
58 |
|
59 CMtfTestActionInitializeSimTsy::CMtfTestActionInitializeSimTsy(CMtfTestCase& aTestCase) |
|
60 : CMtfSynchronousTestAction(aTestCase) |
|
61 { |
|
62 } |
|
63 |
|
64 void CMtfTestActionInitializeSimTsy::ExecuteActionL() |
|
65 { |
|
66 TestCase().Logger().Write(_L("CMtfTestActionInitializeSimTsy::ExecuteActionL IN")); |
|
67 _LIT(KDefaultTsyName, "SIM"); |
|
68 TPtrC defaultTsyName(KDefaultTsyName); |
|
69 HBufC* defaultTsyNameBuf = defaultTsyName.AllocLC(); |
|
70 TInt testNumber = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(0)); |
|
71 HBufC* tsyName = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(1), defaultTsyNameBuf); |
|
72 |
|
73 InitializeSimTsyL(testNumber, tsyName); |
|
74 |
|
75 CMDBSession* dbSession = CMDBSession::NewL(CMDBSession::LatestVersion()); |
|
76 CleanupStack::PushL(dbSession); |
|
77 CMDBRecordSet<CCDGlobalSettingsRecord> globalSettingsRecord(KCDTIdGlobalSettingsRecord); |
|
78 TRAPD(err, globalSettingsRecord.LoadL(*dbSession)); |
|
79 if(err != KErrNone) |
|
80 { |
|
81 User::Leave(KErrNotFound); |
|
82 } |
|
83 |
|
84 CCDModemBearerRecord *modemRecord = static_cast<CCDModemBearerRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdModemBearerRecord)); |
|
85 CleanupStack::PushL(modemRecord); |
|
86 modemRecord->SetRecordId(((CCDGlobalSettingsRecord*)globalSettingsRecord.iRecords[0])->iModemForPhoneServicesAndSMS); |
|
87 modemRecord->LoadL(*dbSession); |
|
88 modemRecord->iTsyName.SetMaxLengthL(tsyName->Des().Length()); |
|
89 modemRecord->iTsyName = tsyName->Des(); |
|
90 modemRecord->ModifyL(*dbSession); |
|
91 CleanupStack::PopAndDestroy(3, defaultTsyNameBuf); //tsyName, dbSession, modemRecord |
|
92 |
|
93 TestCase().ActionCompletedL(*this); |
|
94 TestCase().Logger().Write(_L("CMtfTestActionInitializeSimTsy::ExecuteActionL OUT")); |
|
95 } |
|
96 |
|
97 |
|
98 void CMtfTestActionInitializeSimTsy::InitializeSimTsyL(TInt aTestNumber, HBufC* aTsyName) |
|
99 { |
|
100 //Initialize TSY using the System Agent |
|
101 TInt testState; |
|
102 if(KErrNone != RProperty::Get(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testState)) |
|
103 { |
|
104 User::LeaveIfError(RProperty::Define(KUidPSSimTsyCategory, KPSSimTsyTestNumber, RProperty::EInt)); |
|
105 } |
|
106 TestCase().Logger().WriteFormat(_L("CMtfTestActionInitializeSimTsy::ExecuteActionL Setting test number to %d"), aTestNumber); |
|
107 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, aTestNumber)); |
|
108 if(KErrNone != RProperty::Get(KUidSystemCategory, KMsvTestUidPhonePwrValue, testState)) |
|
109 { |
|
110 User::LeaveIfError(RProperty::Define(KUidSystemCategory, KMsvTestUidPhonePwrValue, RProperty::EInt)); |
|
111 } |
|
112 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KMsvTestUidPhonePwrValue, EMsvTestPhoneOn)); |
|
113 |
|
114 User::LeaveIfError(RProperty::Get(KUidPSSimTsyCategory, KPSSimTsyTestNumber, aTestNumber)); |
|
115 TestCase().Logger().WriteFormat(_L("CMtfTestActionInitializeSimTsy::ExecuteActionL Got test number %d"), aTestNumber); |
|
116 |
|
117 RTelServer etelServer; |
|
118 TInt err = etelServer.Connect(); |
|
119 // Fail the Test Case if the connection is not established |
|
120 if (err != KErrNone) |
|
121 { |
|
122 TestCase().ERR_PRINTF2(_L("Connection with the eTelServer server is failed with error %d "), err); |
|
123 TestCase().SetTestStepResult(EFail); |
|
124 } |
|
125 User::LeaveIfError(etelServer.LoadPhoneModule(aTsyName->Des())); |
|
126 |
|
127 // Find the phone corresponding to this TSY and open a number of handles on it |
|
128 TInt numPhones; |
|
129 User::LeaveIfError(etelServer.EnumeratePhones(numPhones)); |
|
130 TBool found=EFalse; |
|
131 |
|
132 RMobilePhone iPhone; |
|
133 while (!found && numPhones--) |
|
134 { |
|
135 TName phoneTsy; |
|
136 User::LeaveIfError(etelServer.GetTsyName(numPhones,phoneTsy)); |
|
137 if (phoneTsy.CompareF(aTsyName->Des())==KErrNone) |
|
138 { |
|
139 found = ETrue; |
|
140 RTelServer::TPhoneInfo info; |
|
141 User::LeaveIfError(etelServer.GetPhoneInfo(numPhones,info)); |
|
142 CleanupClosePushL(iPhone); |
|
143 User::LeaveIfError(iPhone.Open(etelServer,info.iName)); |
|
144 User::LeaveIfError(iPhone.Initialise()); |
|
145 CleanupStack::PopAndDestroy(&iPhone); |
|
146 } |
|
147 } |
|
148 StoreParameterL<RTelServer>(TestCase(),etelServer,ActionParameters().Parameter(2)); |
|
149 } |
|
150 |