24
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <cdbcols.h>
|
|
20 |
#include <e32base.h>
|
|
21 |
#include <e32def.h>
|
|
22 |
|
|
23 |
// User Includes
|
|
24 |
#include "T_RMmCustomAPIData.h"
|
|
25 |
|
|
26 |
_LIT(KMobilePhoneKey, "RMobilePhone");
|
|
27 |
|
|
28 |
_LIT(KChangeMode, "ChangeMode");
|
|
29 |
_LIT(KCheckMode, "CheckMode");
|
|
30 |
|
|
31 |
// Mode Change
|
|
32 |
_LIT(KCmdSetSystemNetworkMode, "SetSystemNetworkMode");
|
|
33 |
_LIT(KCmdGetCurrentSystemNetworkModes, "GetCurrentSystemNetworkModes");
|
|
34 |
_LIT(KCmdUtilityModeCheck, "UtilityModeCheck");
|
|
35 |
_LIT(KCmdOpen, "Open");
|
|
36 |
_LIT(KCmdClose, "Close");
|
|
37 |
|
|
38 |
_LIT(KGSM, "GSM");
|
|
39 |
_LIT(KWCDMA, "WCDMA");
|
|
40 |
_LIT(KDUAL, "Dual");
|
|
41 |
|
|
42 |
const CDataWrapperBase::TEnumEntryTable CT_RMmCustomApiData::iEnumTestCaseMode[] =
|
|
43 |
{
|
|
44 |
{ KGSM, RMmCustomAPI::KCapsNetworkModeGsm }, //GSM
|
|
45 |
{ KWCDMA, RMmCustomAPI::KCapsNetworkModeUmts }, //WCDMA(3G)
|
|
46 |
{ KDUAL, RMmCustomAPI::KCapsNetworkModeDual } //Dual, Phone decides
|
|
47 |
};
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
/**
|
|
52 |
* Two phase constructor
|
|
53 |
*
|
|
54 |
* @leave system wide error
|
|
55 |
*/
|
|
56 |
CT_RMmCustomApiData* CT_RMmCustomApiData::NewL()
|
|
57 |
{
|
|
58 |
CT_RMmCustomApiData* ret = new(ELeave) CT_RMmCustomApiData();
|
|
59 |
CleanupStack::PushL(ret);
|
|
60 |
ret->ConstructL();
|
|
61 |
CleanupStack::Pop(ret);
|
|
62 |
return ret;
|
|
63 |
}
|
|
64 |
|
|
65 |
|
|
66 |
/**
|
|
67 |
* Protected constructor. First phase construction
|
|
68 |
*/
|
|
69 |
CT_RMmCustomApiData::CT_RMmCustomApiData()
|
|
70 |
: iActiveCallback(NULL),
|
|
71 |
iNetworkMode(0),
|
|
72 |
iCustomPhone(NULL)
|
|
73 |
{
|
|
74 |
}
|
|
75 |
|
|
76 |
/**
|
|
77 |
* Second phase construction
|
|
78 |
*
|
|
79 |
* @internalComponent
|
|
80 |
*
|
|
81 |
* @return N/A
|
|
82 |
*
|
|
83 |
* @pre None
|
|
84 |
* @post None
|
|
85 |
*
|
|
86 |
* @leave system wide error
|
|
87 |
*/
|
|
88 |
void CT_RMmCustomApiData::ConstructL()
|
|
89 |
{
|
|
90 |
iCustomPhone = new (ELeave) RMmCustomAPI();
|
|
91 |
iActiveCallback = CActiveCallback::NewL(*this);
|
|
92 |
}
|
|
93 |
|
|
94 |
/**
|
|
95 |
* Public destructor
|
|
96 |
*/
|
|
97 |
CT_RMmCustomApiData::~CT_RMmCustomApiData()
|
|
98 |
{
|
|
99 |
if(iCustomPhone)
|
|
100 |
{
|
|
101 |
delete iCustomPhone;
|
|
102 |
iCustomPhone = NULL;
|
|
103 |
}
|
|
104 |
|
|
105 |
if(iActiveCallback)
|
|
106 |
{
|
|
107 |
delete iActiveCallback;
|
|
108 |
iActiveCallback = NULL;
|
|
109 |
}
|
|
110 |
|
|
111 |
}
|
|
112 |
|
|
113 |
/**
|
|
114 |
* Return a pointer to the object that the data wraps
|
|
115 |
*
|
|
116 |
* @return pointer to the object that the data wraps
|
|
117 |
*/
|
|
118 |
TAny* CT_RMmCustomApiData::GetObject()
|
|
119 |
{
|
|
120 |
return iCustomPhone;
|
|
121 |
}
|
|
122 |
|
|
123 |
void CT_RMmCustomApiData::RunL(CActive* aActive, TInt aIndex)
|
|
124 |
{
|
|
125 |
DecOutstanding(); // One of the async calls has completed
|
|
126 |
TInt err = aActive->iStatus.Int();
|
|
127 |
if( err != KErrNone )
|
|
128 |
{
|
|
129 |
ERR_PRINTF2(_L("RunL Error %d"), err);
|
|
130 |
SetAsyncError( aIndex, err );
|
|
131 |
}
|
|
132 |
else
|
|
133 |
{
|
|
134 |
INFO_PRINTF1(_L("RunL completed successfully"));
|
|
135 |
}
|
|
136 |
}
|
|
137 |
|
|
138 |
TBool CT_RMmCustomApiData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
|
|
139 |
{
|
|
140 |
TBool ret = ETrue;
|
|
141 |
|
|
142 |
if ( aCommand==KCmdUtilityModeCheck )
|
|
143 |
{
|
|
144 |
DoCmdUtilityModeCheck(aSection);
|
|
145 |
}
|
|
146 |
else if ( aCommand==KCmdGetCurrentSystemNetworkModes )
|
|
147 |
{
|
|
148 |
DoCmdGetCurrentSystemNetworkModes(aAsyncErrorIndex);
|
|
149 |
}
|
|
150 |
else if ( aCommand==KCmdSetSystemNetworkMode )
|
|
151 |
{
|
|
152 |
DoCmdSetSystemNetworkMode(aSection, aAsyncErrorIndex);
|
|
153 |
}
|
|
154 |
else if (aCommand==KCmdOpen)
|
|
155 |
{
|
|
156 |
DoCmdOpen(aSection);
|
|
157 |
}
|
|
158 |
else if (aCommand==KCmdClose)
|
|
159 |
{
|
|
160 |
DoCmdClose();
|
|
161 |
}
|
|
162 |
else
|
|
163 |
{
|
|
164 |
ERR_PRINTF1(_L("Unknown command"));
|
|
165 |
ret = EFalse;
|
|
166 |
}
|
|
167 |
return ret;
|
|
168 |
}
|
|
169 |
|
|
170 |
void CT_RMmCustomApiData::DoCmdClose()
|
|
171 |
{
|
|
172 |
INFO_PRINTF1(_L("*START*CT_RMmCustomApiData::DoCmdCloseCustomApi"));
|
|
173 |
iCustomPhone->Close();
|
|
174 |
INFO_PRINTF1(_L("*END*CT_RMmCustomApiData::DoCmdCloseCustomApi"));
|
|
175 |
}
|
|
176 |
|
|
177 |
/**
|
|
178 |
* Selects the network phone that is currently used.
|
|
179 |
* @param aNetworkMode is the new network mode.
|
|
180 |
* @return Request status.
|
|
181 |
*/
|
|
182 |
void CT_RMmCustomApiData::DoCmdSetSystemNetworkMode(const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
|
|
183 |
{
|
|
184 |
INFO_PRINTF1(_L("*START*CT_RMmCustomApiData::ModeChange"));
|
|
185 |
|
|
186 |
TInt mode = 0;
|
|
187 |
if (!GetEnumFromConfig(aSection, KChangeMode, iEnumTestCaseMode, mode))
|
|
188 |
{
|
|
189 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KChangeMode);
|
|
190 |
SetBlockResult(EFail);
|
|
191 |
}
|
|
192 |
else
|
|
193 |
{
|
|
194 |
INFO_PRINTF2(_L("Change network mode to: %d"), mode);
|
|
195 |
// Setting the network mode, with aNetworkMode
|
|
196 |
INFO_PRINTF1(_L("Use RMmCustomAPI to set the phone mode."));
|
|
197 |
iCustomPhone->SetSystemNetworkMode(iActiveCallback->iStatus, static_cast<RMmCustomAPI::TNetworkModeCaps>(mode));
|
|
198 |
iActiveCallback->Activate(aAsyncErrorIndex);
|
|
199 |
IncOutstanding();
|
|
200 |
}
|
|
201 |
INFO_PRINTF1(_L("*END*CT_RMmCustomApiData::ModeChange"));
|
|
202 |
}
|
|
203 |
|
|
204 |
/**
|
|
205 |
* Checks that the network mode of phone is the same as defined in parameter.
|
|
206 |
*/
|
|
207 |
void CT_RMmCustomApiData::DoCmdGetCurrentSystemNetworkModes(const TInt aAsyncErrorIndex)
|
|
208 |
{
|
|
209 |
INFO_PRINTF1(_L("*START*CT_RMmCustomApiData::DoCmdGetCurrentSystemNetworkModes"));
|
|
210 |
|
|
211 |
INFO_PRINTF1(_L("Get the current network mode from RMmCustomAPI."));
|
|
212 |
|
|
213 |
iCustomPhone->GetCurrentSystemNetworkModes(iActiveCallback->iStatus, iNetworkMode);
|
|
214 |
iActiveCallback->Activate(aAsyncErrorIndex);
|
|
215 |
IncOutstanding();
|
|
216 |
|
|
217 |
INFO_PRINTF1(_L("*END*CT_RMmCustomApiData::DoCmdGetCurrentSystemNetworkModes"));
|
|
218 |
}
|
|
219 |
|
|
220 |
/**
|
|
221 |
* Checks that the network mode of phone is the same as defined in parameter.
|
|
222 |
*/
|
|
223 |
void CT_RMmCustomApiData::DoCmdUtilityModeCheck(const TTEFSectionName& aSection)
|
|
224 |
{
|
|
225 |
INFO_PRINTF1(_L("*START*CT_RMmCustomApiData::ModeCheck"));
|
|
226 |
TInt mode;
|
|
227 |
if (!GetEnumFromConfig(aSection, KCheckMode, iEnumTestCaseMode, mode))
|
|
228 |
{
|
|
229 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KChangeMode);
|
|
230 |
SetBlockResult(EFail);
|
|
231 |
}
|
|
232 |
else
|
|
233 |
{
|
|
234 |
INFO_PRINTF2(_L("Check network mode to: %d"), mode);
|
|
235 |
if ( iNetworkMode != static_cast<RMmCustomAPI::TNetworkModeCaps>(mode))
|
|
236 |
{
|
|
237 |
ERR_PRINTF1(_L("Network mode of phone is different to expected."));
|
|
238 |
SetBlockResult(EFail);
|
|
239 |
}
|
|
240 |
else
|
|
241 |
{
|
|
242 |
INFO_PRINTF1(_L("Mode check succeeded"));
|
|
243 |
}
|
|
244 |
}
|
|
245 |
INFO_PRINTF1(_L("*END*CT_RMmCustomApiData::ModeCheck"));
|
|
246 |
}
|
|
247 |
|
|
248 |
|
|
249 |
void CT_RMmCustomApiData::DoCmdOpen(const TTEFSectionName& aSection)
|
|
250 |
{
|
|
251 |
INFO_PRINTF1(_L("*START*CT_RMmCustomApiData::DoCmdOpen"));
|
|
252 |
TPtrC mobilePhoneName;
|
|
253 |
if ( !GetStringFromConfig(aSection, KMobilePhoneKey(), mobilePhoneName) )
|
|
254 |
{
|
|
255 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KMobilePhoneKey);
|
|
256 |
SetBlockResult(EFail);
|
|
257 |
}
|
|
258 |
else
|
|
259 |
{
|
|
260 |
RMobilePhone* mobilePhoneObject = static_cast<RMobilePhone*>(GetDataObjectL(mobilePhoneName));
|
|
261 |
INFO_PRINTF1(_L("Initializing the custom phone API"));
|
|
262 |
TRAPD( error, iCustomPhone->Open(*mobilePhoneObject) );
|
|
263 |
if (error != KErrNone)
|
|
264 |
{
|
|
265 |
ERR_PRINTF2(_L("Failed to initialize the custom phone API with error %d"), error);
|
|
266 |
SetError(error);
|
|
267 |
}
|
|
268 |
else
|
|
269 |
{
|
|
270 |
INFO_PRINTF1(_L("Initialize the custom phone API Succeeded"));
|
|
271 |
}
|
|
272 |
}
|
|
273 |
INFO_PRINTF1(_L("*END*CT_RMmCustomApiData::DoCmdOpen"));
|
|
274 |
}
|
|
275 |
|
|
276 |
|
|
277 |
|
|
278 |
|
|
279 |
|
|
280 |
|