|
1 /* |
|
2 * Copyright (c) 2010 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 * Initial Contributors: |
|
9 * Nokia Corporation - initial contribution. |
|
10 * |
|
11 * Contributors: |
|
12 * Description : |
|
13 * |
|
14 */ |
|
15 |
|
16 #include "clckcommandhandler.h" |
|
17 |
|
18 #include <startupdomainpskeys.h> |
|
19 #include <e32property.h> |
|
20 |
|
21 #include "securitycodeverifier.h" |
|
22 #include "securityeventhandler.h" |
|
23 #include "cbsettinghandler.h" |
|
24 |
|
25 #include "atmisccmdpluginconsts.h" |
|
26 #include "debug.h" |
|
27 |
|
28 const TInt KSCPMaxHashLength( 32 ); |
|
29 |
|
30 CCLCKCommandHandler* CCLCKCommandHandler::NewL(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) |
|
31 { |
|
32 TRACE_FUNC_ENTRY |
|
33 CCLCKCommandHandler* self = new (ELeave) CCLCKCommandHandler(aCallback, aATCmdParser, aPhone); |
|
34 CleanupStack::PushL(self); |
|
35 self->ConstructL(); |
|
36 CleanupStack::Pop(self); |
|
37 TRACE_FUNC_EXIT |
|
38 return self; |
|
39 } |
|
40 |
|
41 CCLCKCommandHandler::CCLCKCommandHandler(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) : |
|
42 CATCmdAsyncBase(aCallback, aATCmdParser, aPhone), |
|
43 iLockInfoPckg(iLockInfo) |
|
44 { |
|
45 TRACE_FUNC_ENTRY |
|
46 TRACE_FUNC_EXIT |
|
47 } |
|
48 |
|
49 void CCLCKCommandHandler::ConstructL() |
|
50 { |
|
51 TRACE_FUNC_ENTRY |
|
52 iReply.CreateL(KDefaultCmdBufLength); |
|
53 |
|
54 // initialise AOs |
|
55 iCBRetrieve = CRetrieveMobilePhoneCBList::NewL(iPhone); |
|
56 iCBSettingHandler = CCBSettingHandler::NewL(iPhone); |
|
57 iSecurityEventHandler = CSecurityEventHandler::NewL(this, iPhone); |
|
58 iSecurityCodeVerifier = CSecurityCodeVerifier::NewL(this, iPhone); |
|
59 |
|
60 TRACE_FUNC_EXIT |
|
61 } |
|
62 |
|
63 CCLCKCommandHandler::~CCLCKCommandHandler() |
|
64 { |
|
65 TRACE_FUNC_ENTRY |
|
66 Cancel(); |
|
67 |
|
68 delete iCBRetrieve; |
|
69 delete iCBSettingHandler; |
|
70 delete iSecurityEventHandler; |
|
71 delete iSecurityCodeVerifier; |
|
72 |
|
73 iPassword.Close(); |
|
74 iReply.Close(); |
|
75 TRACE_FUNC_EXIT |
|
76 } |
|
77 |
|
78 void CCLCKCommandHandler::DoCancel() |
|
79 { |
|
80 TRACE_FUNC_ENTRY |
|
81 switch (iCLCKCommandType) |
|
82 { |
|
83 case (CCLCKCommandHandler::ECLCKLockGet): |
|
84 { |
|
85 iPhone.CancelAsyncRequest(EMobilePhoneGetLockInfo); |
|
86 break; |
|
87 } |
|
88 case (CCLCKCommandHandler::ECLCKLockSet): |
|
89 { |
|
90 iPhone.CancelAsyncRequest(EMobilePhoneSetLockSetting); |
|
91 iSecurityCodeVerifier->Cancel(); |
|
92 iSecurityEventHandler->Cancel(); |
|
93 break; |
|
94 } |
|
95 case (CCLCKCommandHandler::ECLCKBarringGet): |
|
96 { |
|
97 iCBRetrieve->Cancel(); |
|
98 break; |
|
99 } |
|
100 case (CCLCKCommandHandler::ECLCKBarringSet): |
|
101 { |
|
102 iCBSettingHandler->Cancel(); |
|
103 break; |
|
104 } |
|
105 } |
|
106 TRACE_FUNC_EXIT |
|
107 } |
|
108 |
|
109 void CCLCKCommandHandler::HandleCommand( const TDesC8& /*aCmd*/, RBuf8& /*aReply*/, TBool /*aReplyNeeded*/) |
|
110 { |
|
111 TRACE_FUNC_ENTRY |
|
112 TAtCommandParser::TCommandHandlerType cmdHandlerType = iATCmdParser.CommandHandlerType(); |
|
113 Trace(KDebugPrintD, "cmdHandlerType: ", cmdHandlerType); |
|
114 |
|
115 switch (cmdHandlerType) |
|
116 { |
|
117 case (TAtCommandParser::ECmdHandlerTypeTest): |
|
118 { |
|
119 iCallback->CreateReplyAndComplete(EReplyTypeOther, KCLCKSupportedCmdsList); |
|
120 break; |
|
121 } |
|
122 case (TAtCommandParser::ECmdHandlerTypeSet): |
|
123 { |
|
124 if (ParseCCLCKCommand() == KErrNone) |
|
125 { |
|
126 IssueCLCKCommand(); |
|
127 } |
|
128 else |
|
129 { |
|
130 iCallback->CreateReplyAndComplete(EReplyTypeError); |
|
131 } |
|
132 break; |
|
133 } |
|
134 default: |
|
135 { |
|
136 iCallback->CreateReplyAndComplete(EReplyTypeError); |
|
137 break; |
|
138 } |
|
139 } |
|
140 TRACE_FUNC_EXIT |
|
141 } |
|
142 |
|
143 void CCLCKCommandHandler::RunL() |
|
144 { |
|
145 TRACE_FUNC_ENTRY |
|
146 Trace(KDebugPrintD, "iStatus.Int(): ", iStatus.Int()); |
|
147 TInt err = iStatus.Int(); |
|
148 if (err == KErrNone) |
|
149 { |
|
150 switch ( iCLCKCommandType ) |
|
151 { |
|
152 case (CCLCKCommandHandler::ECLCKLockGet): |
|
153 { |
|
154 iReply.Append(KAtCLCK); |
|
155 if (iLockInfo.iStatus == RMobilePhone::EStatusUnlocked) |
|
156 { |
|
157 iReply.AppendNum(0); |
|
158 iReply.Append(KCRLF); |
|
159 } |
|
160 else if (iLockInfo.iStatus == RMobilePhone::EStatusLocked) |
|
161 { |
|
162 iReply.AppendNum(1); |
|
163 iReply.Append(KCRLF); |
|
164 } |
|
165 else |
|
166 { |
|
167 err = KErrArgument; |
|
168 } |
|
169 break; |
|
170 } |
|
171 case(CCLCKCommandHandler::ECLCKBarringGet): |
|
172 { |
|
173 err = ReceiveCBList(); |
|
174 break; |
|
175 } |
|
176 case (CCLCKCommandHandler::ECLCKLockSet): |
|
177 { |
|
178 iLockSettingState = ELockSettingIdle; |
|
179 iSecurityCodeVerifier->Cancel(); |
|
180 iSecurityEventHandler->Cancel(); |
|
181 break; |
|
182 } |
|
183 case(CCLCKCommandHandler::ECLCKBarringSet): |
|
184 default: |
|
185 { |
|
186 // no action required |
|
187 break; |
|
188 } |
|
189 } |
|
190 } |
|
191 |
|
192 if (err != KErrNone) |
|
193 { |
|
194 if (iCLCKCommandType == CCLCKCommandHandler::ECLCKLockSet) |
|
195 { |
|
196 iLockSettingState =ELockSettingIdle; |
|
197 iSecurityCodeVerifier->Cancel(); |
|
198 iSecurityEventHandler->Cancel(); |
|
199 } |
|
200 iCallback->CreateCMEReplyAndComplete(err); |
|
201 } |
|
202 else |
|
203 { |
|
204 iCallback->CreateReplyAndComplete( EReplyTypeOther, iReply ); |
|
205 } |
|
206 |
|
207 TRACE_FUNC_EXIT |
|
208 } |
|
209 |
|
210 TInt CCLCKCommandHandler::ReceiveCBList() |
|
211 { |
|
212 TRACE_FUNC_ENTRY |
|
213 iInfoClass = 0; |
|
214 CMobilePhoneCBList* callBarringList=NULL; |
|
215 TRAPD(leaveCode, callBarringList=iCBRetrieve->RetrieveListL();); |
|
216 if (leaveCode != KErrNone) |
|
217 { |
|
218 TRACE_FUNC_EXIT |
|
219 return leaveCode; |
|
220 } |
|
221 |
|
222 TInt count = callBarringList->Enumerate(); |
|
223 while (count-- > 0) |
|
224 { |
|
225 RMobilePhone::TMobilePhoneCBInfoEntryV1 entry; |
|
226 TRAP(leaveCode, entry = callBarringList->GetEntryL(count);); |
|
227 if (leaveCode != KErrNone) |
|
228 { |
|
229 TRACE_FUNC_EXIT |
|
230 return leaveCode; |
|
231 } |
|
232 if (entry.iCondition == iCondition && |
|
233 entry.iStatus == RMobilePhone::ECallBarringStatusActive) |
|
234 { |
|
235 switch (entry.iServiceGroup) |
|
236 { |
|
237 case(RMobilePhone::ETelephony): |
|
238 { |
|
239 iInfoClass |= EInfoClassVoice; |
|
240 break; |
|
241 } |
|
242 case(RMobilePhone::EAllBearer): |
|
243 { |
|
244 iInfoClass |= EInfoClassData; |
|
245 break; |
|
246 } |
|
247 case(RMobilePhone::EFaxService): |
|
248 { |
|
249 iInfoClass |= EInfoClassFax; |
|
250 break; |
|
251 } |
|
252 case(RMobilePhone::EShortMessageService): |
|
253 { |
|
254 iInfoClass |= EInfoClassSMS; |
|
255 break; |
|
256 } |
|
257 case(RMobilePhone::ESyncData): |
|
258 { |
|
259 iInfoClass |= EInfoClassSyncData; |
|
260 break; |
|
261 } |
|
262 case(RMobilePhone::EAsyncData): |
|
263 { |
|
264 iInfoClass |= EInfoClassASyncData; |
|
265 break; |
|
266 } |
|
267 case(RMobilePhone::EPacketData): |
|
268 { |
|
269 iInfoClass |= EInfoClassPacketData; |
|
270 break; |
|
271 } |
|
272 case(RMobilePhone::EPadAccess): |
|
273 { |
|
274 iInfoClass |= EInfoClassPadAccess; |
|
275 break; |
|
276 } |
|
277 } |
|
278 } |
|
279 } |
|
280 |
|
281 // There are no services with barring active - therefore report |
|
282 // - status = 0 (inactive) |
|
283 // - class = 7 (default value; voice, fax and data) |
|
284 TInt status; |
|
285 if (iInfoClass == 0) |
|
286 { |
|
287 status = 0; |
|
288 iInfoClass = 7; // Default value, see ETSI TS 127 007 V6.9.0 (2007-06) |
|
289 } |
|
290 else |
|
291 { |
|
292 // There is at least one service with barring active - report status 1 (active) |
|
293 status = 1; |
|
294 } |
|
295 |
|
296 iReply.Append(KAtCLCK); |
|
297 iReply.AppendNum(status); |
|
298 iReply.Append(','); |
|
299 iReply.AppendNum(iInfoClass); |
|
300 iReply.Append(KCRLF); |
|
301 |
|
302 delete callBarringList; |
|
303 TRACE_FUNC_EXIT |
|
304 return KErrNone; |
|
305 } |
|
306 |
|
307 void CCLCKCommandHandler::HandleCommandCancel() |
|
308 { |
|
309 TRACE_FUNC_ENTRY |
|
310 Cancel(); |
|
311 TRACE_FUNC_EXIT |
|
312 } |
|
313 |
|
314 void CCLCKCommandHandler::IssueCLCKCommand() |
|
315 { |
|
316 TRACE_FUNC_ENTRY |
|
317 Trace(KDebugPrintD, "iCLCKCommandType: ", iCLCKCommandType); |
|
318 iReply.Zero(); |
|
319 |
|
320 switch (iCLCKCommandType) |
|
321 { |
|
322 case (CCLCKCommandHandler::ECLCKLockGet): |
|
323 { |
|
324 iPhone.GetLockInfo(iStatus, iLockType, iLockInfoPckg); |
|
325 SetActive(); |
|
326 break; |
|
327 } |
|
328 case (CCLCKCommandHandler::ECLCKLockSet): |
|
329 { |
|
330 if (iPassword.Compare(KNullDesC8) == 0) |
|
331 { |
|
332 iCallback->CreateReplyAndComplete( EReplyTypeError); |
|
333 } |
|
334 else |
|
335 { |
|
336 // Set the property to ignore security events in other clients |
|
337 // it allows to avoid GUI promt for security code |
|
338 TInt ret = KErrNone; |
|
339 // TODO: reenable when KIgnoreSecurityEvent propety definition is submitted to codeline |
|
340 // if (iLockType == RMobilePhone::ELockICC) |
|
341 // { |
|
342 // ret = RProperty::Set(KPSUidStartup, KIgnoreSecurityEvent, EPSIgnoreSecurityEventEPin1Required); |
|
343 // } |
|
344 // else |
|
345 // { |
|
346 // ret = RProperty::Set(KPSUidStartup, KIgnoreSecurityEvent, EPSIgnoreSecurityEventEPhonePasswordRequired); |
|
347 // } |
|
348 Trace(KDebugPrintD, "RProperty::Set: ", ret); |
|
349 if (ret == KErrNone) |
|
350 { |
|
351 // Start security event handler - this will notify whether a |
|
352 // password is required to complete the set lock request. |
|
353 iSecurityEventHandler->Start(); |
|
354 |
|
355 Trace(KDebugPrintD, "SetLockSetting iLockType: ", iLockType); |
|
356 Trace(KDebugPrintD, "SetLockSetting iLockChange: ", iLockChange); |
|
357 iPhone.SetLockSetting(iStatus, iLockType, iLockChange); |
|
358 iLockSettingState = ELockSettingRequested; |
|
359 SetActive(); |
|
360 } |
|
361 else |
|
362 { |
|
363 iCallback->CreateReplyAndComplete( EReplyTypeError); |
|
364 } |
|
365 } |
|
366 break; |
|
367 } |
|
368 case (CCLCKCommandHandler::ECLCKBarringGet): |
|
369 { |
|
370 iCBRetrieve->Start(iStatus, iCondition, RMobilePhone::RMobilePhone::EInfoLocationNetwork); |
|
371 SetActive(); |
|
372 break; |
|
373 } |
|
374 case (CCLCKCommandHandler::ECLCKBarringSet): |
|
375 { |
|
376 if (iPassword.Compare(KNullDesC8) == 0) |
|
377 { |
|
378 iCallback->CreateReplyAndComplete(EReplyTypeError); |
|
379 } |
|
380 else |
|
381 { |
|
382 iCBSettingHandler->Start(iStatus, iInfoClass, iCondition, &iCBInfo); |
|
383 SetActive(); |
|
384 } |
|
385 break; |
|
386 } |
|
387 default: |
|
388 { |
|
389 iCallback->CreateReplyAndComplete(EReplyTypeError); |
|
390 break; |
|
391 } |
|
392 } |
|
393 TRACE_FUNC_EXIT |
|
394 } |
|
395 |
|
396 void CCLCKCommandHandler::HandlePasswordVerification(TInt aError) |
|
397 { |
|
398 TRACE_FUNC_ENTRY |
|
399 |
|
400 if (aError != KErrNone) |
|
401 { |
|
402 iCallback->CreateCMEReplyAndComplete(aError); |
|
403 Cancel(); |
|
404 TRACE_FUNC_EXIT |
|
405 return; |
|
406 } |
|
407 |
|
408 switch (iLockSettingState) |
|
409 { |
|
410 case (ELockSettingIdle): |
|
411 { |
|
412 // Security code setting request has already been completed |
|
413 iSecurityEventHandler->Cancel(); |
|
414 break; |
|
415 } |
|
416 case (ELockSettingPasswordRequested): |
|
417 { |
|
418 // after password has been verified go back to the previous state |
|
419 iLockSettingState = ELockSettingRequested; |
|
420 break; |
|
421 } |
|
422 case (ELockSettingRequested): |
|
423 default: |
|
424 { |
|
425 // should never be in this state |
|
426 __ASSERT_DEBUG(EFalse, User::Invariant()); |
|
427 break; |
|
428 } |
|
429 } |
|
430 |
|
431 TRACE_FUNC_EXIT |
|
432 } |
|
433 |
|
434 void CCLCKCommandHandler::HandleSecurityEvent(TInt aError, RMobilePhone::TMobilePhoneSecurityEvent aSecurityEvent) |
|
435 { |
|
436 TRACE_FUNC_ENTRY |
|
437 if (aError != KErrNone) |
|
438 { |
|
439 iCallback->CreateCMEReplyAndComplete(aError); |
|
440 Cancel(); |
|
441 TRACE_FUNC_EXIT |
|
442 return; |
|
443 } |
|
444 |
|
445 Trace(KDebugPrintD, "iLockSettingState: ", iLockSettingState); |
|
446 Trace(KDebugPrintD, "aSecurityEvent: ", aSecurityEvent); |
|
447 switch (iLockSettingState) |
|
448 { |
|
449 case (ELockSettingIdle): |
|
450 { |
|
451 // Set Lock request has already been completed |
|
452 iSecurityCodeVerifier->Cancel(); |
|
453 break; |
|
454 } |
|
455 case (ELockSettingRequested): |
|
456 { |
|
457 switch (aSecurityEvent) |
|
458 { |
|
459 case(RMobilePhone::EPin1Required): |
|
460 case(RMobilePhone::EPhonePasswordRequired): |
|
461 { |
|
462 iSecurityEventHandler->Start(); |
|
463 if( iSecurityCode == RMobilePhone::ESecurityCodePin1 && |
|
464 aSecurityEvent == RMobilePhone::EPin1Required || |
|
465 iSecurityCode == RMobilePhone::ESecurityCodePhonePassword && |
|
466 aSecurityEvent == RMobilePhone::EPhonePasswordRequired) |
|
467 { |
|
468 // security code request has been triggered, reissue the security notification |
|
469 // request and provide the code if this is expected |
|
470 iSecurityCodeVerifier->Start(iPassword, iSecurityCode); |
|
471 iLockSettingState =ELockSettingPasswordRequested; |
|
472 } |
|
473 break; |
|
474 } |
|
475 case(RMobilePhone::ENoICCFound): |
|
476 case(RMobilePhone::EICCTerminated): |
|
477 { |
|
478 // No SIM present or it is unusable |
|
479 iCallback->CreateCMEReplyAndComplete(aError); |
|
480 Cancel(); |
|
481 break; |
|
482 } |
|
483 default: |
|
484 { |
|
485 // other processes may trigger various security events, ignore them |
|
486 // if not related and reissue the notification request |
|
487 iSecurityEventHandler->Start(); |
|
488 break; |
|
489 } |
|
490 } |
|
491 break; |
|
492 } |
|
493 case (ELockSettingPasswordRequested): |
|
494 { |
|
495 switch (aSecurityEvent) |
|
496 { |
|
497 case(RMobilePhone::EPin1Verified): |
|
498 { |
|
499 // PIN1 has been verified, ignore if not applicable |
|
500 // otherwise security event handler and security code verifier |
|
501 // no longer needed |
|
502 // (note that another client could have provided the PIN1) |
|
503 if (iSecurityCode == RMobilePhone::ESecurityCodePin1) |
|
504 { |
|
505 iLockSettingState =ELockSettingRequested; |
|
506 } |
|
507 break; |
|
508 } |
|
509 case(RMobilePhone::EPhonePasswordVerified): |
|
510 { |
|
511 if (iSecurityCode == RMobilePhone::ESecurityCodePhonePassword) |
|
512 { |
|
513 iLockSettingState =ELockSettingRequested; |
|
514 } |
|
515 break; |
|
516 } |
|
517 case(RMobilePhone::ENoICCFound): |
|
518 case(RMobilePhone::EICCTerminated): |
|
519 { |
|
520 // No SIM present or it is unusable, terminate the operation |
|
521 Cancel(); |
|
522 iCallback->CreateCMEReplyAndComplete(aError); |
|
523 break; |
|
524 } |
|
525 default: |
|
526 { |
|
527 // other processes may trigger various security events, ignore them if not related |
|
528 // and reissue the notification request |
|
529 iSecurityEventHandler->Start(); |
|
530 break; |
|
531 } |
|
532 } |
|
533 break; |
|
534 } |
|
535 default: |
|
536 { |
|
537 // lock setting state value is out of boundies, complete with error |
|
538 iCallback->CreateCMEReplyAndComplete(aError); |
|
539 Cancel(); |
|
540 break; |
|
541 } |
|
542 } |
|
543 TRACE_FUNC_EXIT |
|
544 } |
|
545 |
|
546 TInt CCLCKCommandHandler::ParseCCLCKCommand() |
|
547 { |
|
548 TRACE_FUNC_ENTRY |
|
549 TCmdFacilityType facilityType = ECmdFacilityTypeUnknown; |
|
550 TInt mode = 0; |
|
551 TInt ret = KErrNone; |
|
552 |
|
553 TPtrC8 command = iATCmdParser.NextTextParam(ret); |
|
554 if (!command.Compare(KNullDesC8) || ret != KErrNone) |
|
555 { |
|
556 TRACE_FUNC_EXIT |
|
557 return KErrArgument; |
|
558 } |
|
559 |
|
560 ret = iATCmdParser.NextIntParam(mode); |
|
561 if (!command.Compare(KNullDesC8) || ret != KErrNone) |
|
562 { |
|
563 TRACE_FUNC_EXIT |
|
564 return KErrArgument; |
|
565 } |
|
566 |
|
567 iPassword.Create(iATCmdParser.NextTextParam(ret)); |
|
568 Trace(KDebugPrintD, "NextTextParam returned: ", ret); |
|
569 if (ret != KErrNone && ret != KErrNotFound) |
|
570 { |
|
571 TRACE_FUNC_EXIT |
|
572 return KErrArgument; |
|
573 } |
|
574 |
|
575 if (iPassword.Compare(KNullDesC8) != 0) |
|
576 { |
|
577 ret = iATCmdParser.NextIntParam(iInfoClass); |
|
578 Trace(KDebugPrintD, "NextIntParam(iInfoClass): ", ret); |
|
579 if (ret == KErrNotFound) |
|
580 { |
|
581 iInfoClass = 7; |
|
582 } |
|
583 if ((ret != KErrNone && ret != KErrNotFound ) || |
|
584 iATCmdParser.NextParam().Compare(KNullDesC8) != 0) |
|
585 { |
|
586 TRACE_FUNC_EXIT |
|
587 return KErrArgument; |
|
588 } |
|
589 } |
|
590 |
|
591 if (command.Compare(KATCLCKPS) == 0) |
|
592 { |
|
593 // Lock phone to SIM on/off |
|
594 iSecurityCode = RMobilePhone::ESecurityCodePhonePassword; |
|
595 iLockType = RMobilePhone::ELockPhoneToICC; |
|
596 facilityType = ECmdFacilityTypeLock; |
|
597 } |
|
598 else if (command.Compare(KATCLCKSC) == 0) |
|
599 { |
|
600 // PIN on/off |
|
601 iSecurityCode = RMobilePhone::ESecurityCodePin1; |
|
602 iLockType = RMobilePhone::ELockICC; |
|
603 facilityType = ECmdFacilityTypeLock; |
|
604 } |
|
605 else if (command.Compare(KATCLCKAO) == 0) |
|
606 { |
|
607 iCondition = RMobilePhone::EBarAllOutgoing; |
|
608 facilityType = ECmdFacilityTypeBarring; |
|
609 } |
|
610 else if (command.Compare(KATCLCKOI) == 0) |
|
611 { |
|
612 iCondition = RMobilePhone::EBarOutgoingInternational; |
|
613 facilityType = ECmdFacilityTypeBarring; |
|
614 } |
|
615 else if (command.Compare(KATCLCKOX) == 0) |
|
616 { |
|
617 iCondition = RMobilePhone::EBarOutgoingInternationalExHC; |
|
618 facilityType = ECmdFacilityTypeBarring; |
|
619 } |
|
620 else if (command.Compare(KATCLCKAI) == 0) |
|
621 { |
|
622 iCondition = RMobilePhone::EBarAllIncoming; |
|
623 facilityType = ECmdFacilityTypeBarring; |
|
624 } |
|
625 else if (command.Compare(KATCLCKIR) == 0) |
|
626 { |
|
627 iCondition = RMobilePhone::EBarIncomingRoaming; |
|
628 facilityType = ECmdFacilityTypeBarring; |
|
629 } |
|
630 else if (command.Compare(KATCLCKAB) == 0) |
|
631 { |
|
632 iCondition = RMobilePhone::EBarAllCases; |
|
633 facilityType = ECmdFacilityTypeAllBarring; |
|
634 } |
|
635 else if (command.Compare(KATCLCKAG) == 0) |
|
636 { |
|
637 iCondition = RMobilePhone::EBarAllOutgoingServices; |
|
638 facilityType = ECmdFacilityTypeAllBarring; |
|
639 } |
|
640 else if (command.Compare(KATCLCKAC) == 0) |
|
641 { |
|
642 iCondition = RMobilePhone::EBarAllIncomingServices; |
|
643 facilityType = ECmdFacilityTypeAllBarring; |
|
644 } |
|
645 else |
|
646 { |
|
647 TRACE_FUNC_EXIT |
|
648 return KErrArgument; |
|
649 } |
|
650 |
|
651 switch (facilityType) |
|
652 { |
|
653 case (ECmdFacilityTypeLock): |
|
654 { |
|
655 switch (mode) |
|
656 { |
|
657 case 0: // e.g. AT+CLCK="SC",0,"0000" |
|
658 { |
|
659 iCLCKCommandType = ECLCKLockSet; |
|
660 iLockChange = RMobilePhone::ELockSetDisabled; |
|
661 break; |
|
662 } |
|
663 case 1: // e.g. AT+CLCK="SC",1 |
|
664 { |
|
665 iCLCKCommandType = ECLCKLockSet; |
|
666 iLockChange = RMobilePhone::ELockSetEnabled; |
|
667 break; |
|
668 } |
|
669 case 2: // e.g. AT+CLCK="SC",2 |
|
670 { |
|
671 iCLCKCommandType = ECLCKLockGet; |
|
672 break; |
|
673 } |
|
674 default: |
|
675 { |
|
676 TRACE_FUNC_EXIT |
|
677 return KErrArgument; |
|
678 } |
|
679 } |
|
680 break; |
|
681 } |
|
682 case (ECmdFacilityTypeBarring): |
|
683 { |
|
684 iCBInfo.iPassword.Copy(iPassword); |
|
685 if (iInfoClass == 0) |
|
686 { |
|
687 iInfoClass = 7; // Default value, see ETSI TS 127 007 V6.9.0 (2007-06) |
|
688 } |
|
689 switch (mode) |
|
690 { |
|
691 case 0: // AT+CLCK="AO",0 |
|
692 { |
|
693 iCLCKCommandType = ECLCKBarringSet; |
|
694 iCBInfo.iAction = RMobilePhone::EServiceActionDeactivate; |
|
695 break; |
|
696 } |
|
697 case 1: // AT+CLCK="AO",1,"1919",1 |
|
698 { |
|
699 iCLCKCommandType = ECLCKBarringSet; |
|
700 iCBInfo.iAction = RMobilePhone::EServiceActionActivate; |
|
701 break; |
|
702 } |
|
703 case 2: // AT+CLCK="AO",2 |
|
704 { |
|
705 iCLCKCommandType = ECLCKBarringGet; |
|
706 break; |
|
707 } |
|
708 default: |
|
709 { |
|
710 TRACE_FUNC_EXIT |
|
711 return KErrArgument; |
|
712 } |
|
713 } |
|
714 break; |
|
715 } |
|
716 case (ECmdFacilityTypeAllBarring): |
|
717 { |
|
718 iCBInfo.iPassword.Copy(iPassword); |
|
719 if (iInfoClass == 0) |
|
720 { |
|
721 iInfoClass = 7; // Default value, see ETSI TS 127 007 V6.9.0 (2007-06) |
|
722 } |
|
723 |
|
724 if ( mode == 0) |
|
725 { |
|
726 iCLCKCommandType = ECLCKBarringSet; |
|
727 iCBInfo.iAction = RMobilePhone::EServiceActionDeactivate; |
|
728 } |
|
729 else |
|
730 // only deactivation is supported |
|
731 { |
|
732 TRACE_FUNC_EXIT |
|
733 return KErrArgument; |
|
734 } |
|
735 break; |
|
736 } |
|
737 default: |
|
738 { |
|
739 TRACE_FUNC_EXIT |
|
740 return KErrArgument; |
|
741 } |
|
742 } |
|
743 |
|
744 // if phone password is required it needs to be hashed before verification |
|
745 if (iSecurityCode == RMobilePhone::ESecurityCodePhonePassword |
|
746 && iCLCKCommandType == ECLCKLockSet) |
|
747 { |
|
748 TBuf8<KSCPMaxHashLength> hashedPwd; |
|
749 iATCmdParser.HashSecurityCode(iPassword, hashedPwd); |
|
750 if (hashedPwd.Length() > iPassword.MaxLength()) |
|
751 { |
|
752 TInt ret = iPassword.ReAlloc(hashedPwd.Length()); |
|
753 if (ret != KErrNone) |
|
754 { |
|
755 TRACE_FUNC_EXIT |
|
756 return ret; |
|
757 } |
|
758 } |
|
759 iPassword = hashedPwd; |
|
760 } |
|
761 |
|
762 TRACE_FUNC_EXIT |
|
763 return KErrNone; |
|
764 } |