|
1 // Copyright (c) 2007-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 #include "miscadaptationref.h" |
|
17 #include <ssm/startupadaptationcommands.h> |
|
18 |
|
19 _LIT(KTestCmdSecurityCheckTestFile, "c:\\cmdsecuritychecktest\\pinchecksecuritycaseno.txt"); |
|
20 |
|
21 /** |
|
22 Function to create new Misc Adaptation Plugin. Used for a collection of activities. |
|
23 |
|
24 @return new instance of MEmergencyCallRfAdaptation for Miscellaneous Adaptations. |
|
25 |
|
26 @internalComponent |
|
27 @released |
|
28 */ |
|
29 EXPORT_C MMiscAdaptation* CreateMiscAdaptationRefL() |
|
30 { |
|
31 CMiscAdaptationRef* miscAdaptationRef = CMiscAdaptationRef::NewL(); |
|
32 return (static_cast<MMiscAdaptation*>(miscAdaptationRef)); |
|
33 } |
|
34 |
|
35 CMiscAdaptationRef* CMiscAdaptationRef::NewL() |
|
36 { |
|
37 CMiscAdaptationRef* self = new(ELeave) CMiscAdaptationRef; |
|
38 self->ConstructL(); |
|
39 return self; |
|
40 } |
|
41 |
|
42 CMiscAdaptationRef::~CMiscAdaptationRef() |
|
43 { |
|
44 iFs.Close(); |
|
45 } |
|
46 |
|
47 CMiscAdaptationRef::CMiscAdaptationRef() |
|
48 { |
|
49 } |
|
50 |
|
51 void CMiscAdaptationRef::ConstructL() |
|
52 { |
|
53 iTestCaseNum = 1; |
|
54 User::LeaveIfError(iFs.Connect()); |
|
55 } |
|
56 |
|
57 /** |
|
58 Deletes and frees memory allocated. |
|
59 */ |
|
60 void CMiscAdaptationRef::Release() |
|
61 { |
|
62 delete this; |
|
63 } |
|
64 |
|
65 /** |
|
66 Get the start-up mode from the Cooperating System. |
|
67 Reference implementation completes with KErrNone as a cooperating system does not exist on Techview/H4 hrp. |
|
68 |
|
69 @param aModePckg should contain start-up of the Cooperating System on completion |
|
70 @param aStatus to complete when the operation has finished |
|
71 |
|
72 @see TRequestStatus |
|
73 */ |
|
74 void CMiscAdaptationRef::GetGlobalStartupMode(TDes8& /*aModePckg*/, TRequestStatus& aStatus) |
|
75 { |
|
76 aStatus = KRequestPending; |
|
77 TRequestStatus* status = &aStatus; |
|
78 User::RequestComplete(status, KErrNone); |
|
79 } |
|
80 |
|
81 /** |
|
82 Prepare language codes stored in the SIM in preferred language lists. The next call should be GetSimLanguagesL() |
|
83 Reference implementation completes with KErrNotSupported as SIM support is not available on Techview/H4 hrp. |
|
84 |
|
85 @param aPriority priority for which the language lists need to be prepared |
|
86 @param aSizePckg on return contains the size of the buffer, which a client should allocate and pass as one of the parameters (TInt aCount) to GetSimLanguagesL() |
|
87 @param aStatus to complete when the operation has finished |
|
88 |
|
89 @see TSsmLanguageListPriority |
|
90 @see TRequestStatus |
|
91 @see GetSimLanguagesL |
|
92 */ |
|
93 void CMiscAdaptationRef::PrepareSimLanguages(TSsmLanguageListPriority /*aPriority*/, TDes8& /*aSizePckg*/, TRequestStatus& aStatus) |
|
94 { |
|
95 aStatus = KRequestPending; |
|
96 TRequestStatus* status = &aStatus; |
|
97 // No support for SIM on H4hrp/Techview. |
|
98 User::RequestComplete(status, KErrNotSupported); |
|
99 } |
|
100 |
|
101 /** |
|
102 Get language codes stored in the SIM in preferred language lists. PrepareSimLanguages() call should precede this call. |
|
103 Reference implementation completes with KErrNotSupported as SIM support is not available on Techview/H4 hrp. |
|
104 |
|
105 @param aBuf should contain the language lists on completion |
|
106 @param aCount to contain the count of the languages |
|
107 |
|
108 @see PrepareSimLanguages |
|
109 */ |
|
110 void CMiscAdaptationRef::GetSimLanguagesL(CBufBase* /*aBuf*/, TInt /*aCount*/) |
|
111 { |
|
112 User::Leave(KErrNotSupported); |
|
113 } |
|
114 |
|
115 void CMiscAdaptationRef::GetHiddenReset(TDes8& /*aHiddenResetPckg*/, TRequestStatus& aStatus) |
|
116 { |
|
117 aStatus = KRequestPending; |
|
118 TRequestStatus* status = &aStatus; |
|
119 // No support for Reset in HRP/Techview. |
|
120 User::RequestComplete(status, KErrNotSupported); |
|
121 } |
|
122 |
|
123 |
|
124 /** |
|
125 Cancel the outstanding request. Reference implementation completes the requests immediately so there is nothing to Cancel. |
|
126 On a device, Cancel() needs an implementation as the Request might be outstanding and it needs to be cancelled. |
|
127 */ |
|
128 void CMiscAdaptationRef::Cancel() |
|
129 { |
|
130 } |
|
131 |
|
132 /** |
|
133 Request the next security state. |
|
134 Techview/H4hrp does not support SIM operations so a reference implementation would always return 'KErrNotSupported'. |
|
135 The function is modified to suit testing needs for PinCheck Security Command. |
|
136 A real implementation is intended to differ a lot based on the runtime changes/events on the device. |
|
137 |
|
138 Each switch case represents a PIN Check security plug-in functionality in different status are as follows.. |
|
139 |
|
140 EPINCHECK01 : SIM present and PIN1 required. |
|
141 EPINCHECK02 : SIM present and rejected |
|
142 EPINCHECK03 : SIM blocked PUK required |
|
143 EPINCHECK04 : SIM locked security code required. |
|
144 EPINCHECK05 : SIM locked security code required when sim lockRestrictionOn |
|
145 EPINCHECK06 : SIM blocked and UPUK. |
|
146 EPINCHECK07 : SIM blocked security code required when sim lockRestrictionOn |
|
147 EPINCHECK08 : SIM present and PIN1 required and SimLock status is wrong |
|
148 iTestCaseNum will be reset to 1 at EPINCHECK08 to test all above scenarios for wrong entered pin |
|
149 |
|
150 @param aState next security state |
|
151 @param aResponsePckg response to state change request on completion |
|
152 @param aStatus to complete when the operation has finished |
|
153 |
|
154 @see TRequestStatus |
|
155 */ |
|
156 void CMiscAdaptationRef::SecurityStateChange(TInt aState, TDes8& aResponsePckg, TRequestStatus& aStatus) |
|
157 { |
|
158 aStatus = KRequestPending; |
|
159 TRequestStatus* status = &aStatus; |
|
160 StartupAdaptation::TSecurityStateInfo info = StartupAdaptation::EYes; |
|
161 |
|
162 //Read Test case number from the file |
|
163 TInt err = iFile.Open(iFs, KTestCmdSecurityCheckTestFile, EFileRead); |
|
164 if (err == KErrNone) |
|
165 { |
|
166 TRAP(err,iTestCaseNum = iFile.ReadInt32L()); |
|
167 iFile.Close(); |
|
168 if(err) |
|
169 { |
|
170 RDebug::Printf("Error while reading tst case number from the file pinchecksecuritycaseno.txt"); |
|
171 User::RequestComplete(status, err); |
|
172 return; |
|
173 } |
|
174 } |
|
175 switch(iTestCaseNum) |
|
176 { |
|
177 case EPINCHECK01: |
|
178 switch(aState) |
|
179 { |
|
180 case StartupAdaptation::ESIMPresent: |
|
181 info = StartupAdaptation::EYes; |
|
182 break; |
|
183 case StartupAdaptation::ESIMInvalid: |
|
184 info = StartupAdaptation::ENo; |
|
185 break; |
|
186 case StartupAdaptation::ESIMRejected: |
|
187 info = StartupAdaptation::ENo; |
|
188 break; |
|
189 case StartupAdaptation::ESIMBlocked: |
|
190 info = StartupAdaptation::ENo; |
|
191 break; |
|
192 case StartupAdaptation::EPINRequired: |
|
193 info = StartupAdaptation::EPIN1Required; |
|
194 break; |
|
195 case StartupAdaptation::ESIMLock: |
|
196 info = StartupAdaptation::ESimLockOk; |
|
197 break; |
|
198 case StartupAdaptation::ESecurityCheckOK: |
|
199 info = StartupAdaptation::EYes; |
|
200 break; |
|
201 case StartupAdaptation::ESecurityCheckFailed: |
|
202 info = StartupAdaptation::EYes; |
|
203 break; |
|
204 default: |
|
205 break; |
|
206 } |
|
207 break; |
|
208 case EPINCHECK02: |
|
209 switch(aState) |
|
210 { |
|
211 case StartupAdaptation::ESIMPresent: |
|
212 info = StartupAdaptation::EYes; |
|
213 break; |
|
214 case StartupAdaptation::ESIMInvalid: |
|
215 info = StartupAdaptation::ENo; |
|
216 break; |
|
217 case StartupAdaptation::ESIMRejected: |
|
218 info = StartupAdaptation::EYes; |
|
219 break; |
|
220 case StartupAdaptation::ESecurityCheckFailed: |
|
221 info = StartupAdaptation::EYes; |
|
222 break; |
|
223 default: |
|
224 break; |
|
225 } |
|
226 break; |
|
227 case EPINCHECK03: |
|
228 switch(aState) |
|
229 { |
|
230 case StartupAdaptation::ESIMPresent: |
|
231 info = StartupAdaptation::EYes; |
|
232 break; |
|
233 case StartupAdaptation::ESIMInvalid: |
|
234 info = StartupAdaptation::ENo; |
|
235 break; |
|
236 case StartupAdaptation::ESIMRejected: |
|
237 info = StartupAdaptation::ENo; |
|
238 break; |
|
239 case StartupAdaptation::ESIMBlocked: |
|
240 info = StartupAdaptation::EPUK1Required; |
|
241 break; |
|
242 case StartupAdaptation::ESIMLock: |
|
243 info = StartupAdaptation::ESimLockOk; |
|
244 break; |
|
245 case StartupAdaptation::ESecurityCheckOK: |
|
246 info = StartupAdaptation::EYes; |
|
247 break; |
|
248 case StartupAdaptation::ESecurityCheckFailed: |
|
249 info = StartupAdaptation::EYes; |
|
250 break; |
|
251 default: |
|
252 break; |
|
253 } |
|
254 break; |
|
255 case EPINCHECK04: |
|
256 switch(aState) |
|
257 { |
|
258 case StartupAdaptation::ESIMPresent: |
|
259 info = StartupAdaptation::EYes; |
|
260 break; |
|
261 case StartupAdaptation::ESIMInvalid: |
|
262 info = StartupAdaptation::ENo; |
|
263 break; |
|
264 case StartupAdaptation::ESIMRejected: |
|
265 info = StartupAdaptation::ENo; |
|
266 break; |
|
267 case StartupAdaptation::ESIMBlocked: |
|
268 info = StartupAdaptation::EPUK1Required; |
|
269 break; |
|
270 case StartupAdaptation::ESIMLock: |
|
271 info = StartupAdaptation::ESimLockOk; |
|
272 break; |
|
273 case StartupAdaptation::ESecurityCheckOK: |
|
274 info = StartupAdaptation::EYes; |
|
275 break; |
|
276 case StartupAdaptation::ESecurityCheckFailed: |
|
277 info = StartupAdaptation::EYes; |
|
278 break; |
|
279 default: |
|
280 break; |
|
281 } |
|
282 break; |
|
283 case EPINCHECK05: |
|
284 switch(aState) |
|
285 { |
|
286 case StartupAdaptation::ESIMPresent: |
|
287 info = StartupAdaptation::EYes; |
|
288 break; |
|
289 case StartupAdaptation::ESIMInvalid: |
|
290 info = StartupAdaptation::ENo; |
|
291 break; |
|
292 case StartupAdaptation::ESIMRejected: |
|
293 info = StartupAdaptation::ENo; |
|
294 break; |
|
295 case StartupAdaptation::ESIMBlocked: |
|
296 info = StartupAdaptation::EUPUKRequired; |
|
297 break; |
|
298 case StartupAdaptation::ESIMLock: |
|
299 info = StartupAdaptation::ESimLockRestrictionOn; |
|
300 break; |
|
301 case StartupAdaptation::ESecurityCheckOK: |
|
302 info = StartupAdaptation::EYes; |
|
303 break; |
|
304 case StartupAdaptation::ESecurityCheckFailed: |
|
305 info = StartupAdaptation::EYes; |
|
306 break; |
|
307 default: |
|
308 break; |
|
309 } |
|
310 break; |
|
311 case EPINCHECK06: |
|
312 switch(aState) |
|
313 { |
|
314 case StartupAdaptation::ESIMPresent: |
|
315 info = StartupAdaptation::EYes; |
|
316 break; |
|
317 case StartupAdaptation::ESIMInvalid: |
|
318 info = StartupAdaptation::ENo; |
|
319 break; |
|
320 case StartupAdaptation::ESIMRejected: |
|
321 info = StartupAdaptation::ENo; |
|
322 break; |
|
323 case StartupAdaptation::ESIMBlocked: |
|
324 info = StartupAdaptation::EUPUKRequired; |
|
325 break; |
|
326 case StartupAdaptation::ESIMLock: |
|
327 info = StartupAdaptation::ESimLockRestrictionPending; |
|
328 break; |
|
329 case StartupAdaptation::ESecurityCheckOK: |
|
330 info = StartupAdaptation::EYes; |
|
331 break; |
|
332 case StartupAdaptation::ESecurityCheckFailed: |
|
333 info = StartupAdaptation::EYes; |
|
334 break; |
|
335 default: |
|
336 break; |
|
337 } |
|
338 break; |
|
339 case EPINCHECK07: |
|
340 switch(aState) |
|
341 { |
|
342 case StartupAdaptation::ESIMPresent: |
|
343 info = StartupAdaptation::EYes; |
|
344 break; |
|
345 case StartupAdaptation::ESIMInvalid: |
|
346 info = StartupAdaptation::ENo; |
|
347 break; |
|
348 case StartupAdaptation::ESIMRejected: |
|
349 info = StartupAdaptation::ENo; |
|
350 break; |
|
351 case StartupAdaptation::ESIMBlocked: |
|
352 info = StartupAdaptation::EUPUKRequired; |
|
353 break; |
|
354 case StartupAdaptation::ESIMLock: |
|
355 info = StartupAdaptation::ESimLockRestricted; |
|
356 break; |
|
357 case StartupAdaptation::ESecurityCheckOK: |
|
358 info = StartupAdaptation::EYes; |
|
359 break; |
|
360 case StartupAdaptation::ESecurityCheckFailed: |
|
361 info = StartupAdaptation::EYes; |
|
362 break; |
|
363 default: |
|
364 break; |
|
365 } |
|
366 break; |
|
367 case EPINCHECK08: |
|
368 switch(aState) |
|
369 { |
|
370 case StartupAdaptation::ESIMPresent: |
|
371 info = StartupAdaptation::EYes; |
|
372 break; |
|
373 case StartupAdaptation::ESIMInvalid: |
|
374 info = StartupAdaptation::ENo; |
|
375 break; |
|
376 case StartupAdaptation::ESIMRejected: |
|
377 info = StartupAdaptation::ENo; |
|
378 break; |
|
379 case StartupAdaptation::ESIMBlocked: |
|
380 info = StartupAdaptation::ENo; |
|
381 break; |
|
382 case StartupAdaptation::EPINRequired: |
|
383 info = StartupAdaptation::EPIN1Required; |
|
384 break; |
|
385 case StartupAdaptation::ESIMLock: |
|
386 info = StartupAdaptation::ESimLockOk; |
|
387 break; |
|
388 case StartupAdaptation::ESecurityCheckOK: |
|
389 info = StartupAdaptation::EYes; |
|
390 break; |
|
391 case StartupAdaptation::ESecurityCheckFailed: |
|
392 info = StartupAdaptation::EYes; |
|
393 break; |
|
394 default: |
|
395 break; |
|
396 } |
|
397 break; |
|
398 default: |
|
399 break; |
|
400 } |
|
401 TPckgBuf<StartupAdaptation::TSecurityStateInfo> securityStateInfoResult(info); |
|
402 aResponsePckg = securityStateInfoResult; |
|
403 User::RequestComplete(status, KErrNone); |
|
404 } |
|
405 |