398 RMobilePhone::TMobilePassword securityCode; |
398 RMobilePhone::TMobilePassword securityCode; |
399 RMobilePhone::TMobilePassword unblockCode; // Required here only as a dummy parameter |
399 RMobilePhone::TMobilePassword unblockCode; // Required here only as a dummy parameter |
400 |
400 |
401 |
401 |
402 /* TODO not sure if needs to check against the typed, or the hashed */ |
402 /* TODO not sure if needs to check against the typed, or the hashed */ |
403 /* |
|
404 RArray<TDevicelockPolicies> aFailedPolicies; |
403 RArray<TDevicelockPolicies> aFailedPolicies; |
405 TDevicelockPolicies failedPolicy; |
|
406 TInt retLockcode = KErrNone; |
404 TInt retLockcode = KErrNone; |
407 RMobilePhone::TMobilePassword aISACode; |
405 RMobilePhone::TMobilePassword aISACode; |
408 TInt scpFlags = 0; |
406 TInt scpFlags = 0; |
409 RDEBUG("scpClient.VerifyCurrentLockcode", 0); |
407 RDEBUG("scpClient.VerifyCurrentLockcode", 0); |
410 // this validate on ISA . No need to do iPhone.VerifySecurityCode |
408 // get hashed code, to verify that message is different than code |
|
409 RSCPClient scpClient; |
|
410 TInt ret = scpClient.Connect(); |
|
411 RDEBUG("ret", ret); |
411 retLockcode = scpClient.VerifyCurrentLockcode(aRemoteLockCode, aISACode, aFailedPolicies, scpFlags); |
412 retLockcode = scpClient.VerifyCurrentLockcode(aRemoteLockCode, aISACode, aFailedPolicies, scpFlags); |
412 RDEBUG("retLockcode", retLockcode); |
413 RDEBUG("retLockcode", retLockcode); |
|
414 scpClient.Close(); |
413 |
415 |
414 RDEBUG("aISACode", 0); |
416 RDEBUG("aISACode", 0); |
415 RDEBUGSTR(aISACode); |
417 RDEBUGSTR(aISACode); |
416 */ |
418 |
417 |
419 securityCode = aISACode; // aRemoteLockCode; |
418 securityCode = aRemoteLockCode; |
|
419 RDEBUG( "EMobilePhoneVerifySecurityCode", EMobilePhoneVerifySecurityCode ); |
420 RDEBUG( "EMobilePhoneVerifySecurityCode", EMobilePhoneVerifySecurityCode ); |
420 iWait->SetRequestType(EMobilePhoneVerifySecurityCode); |
421 iWait->SetRequestType(EMobilePhoneVerifySecurityCode); |
421 RDEBUG( "VerifySecurityCode", 0 ); |
422 RDEBUG( "VerifySecurityCode", 0 ); |
422 iPhone.VerifySecurityCode(iWait->iStatus, secCodeType, securityCode, unblockCode); |
423 iPhone.VerifySecurityCode(iWait->iStatus, secCodeType, securityCode, unblockCode); |
423 RDEBUG( "WaitForRequestL", 0 ); |
424 RDEBUG( "WaitForRequestL", 0 ); |
2244 |
2262 |
2245 // confirm that it can be changed now |
2263 // confirm that it can be changed now |
2246 { |
2264 { |
2247 RArray<TDevicelockPolicies> aFailedPolicies; |
2265 RArray<TDevicelockPolicies> aFailedPolicies; |
2248 TDevicelockPolicies failedPolicy; |
2266 TDevicelockPolicies failedPolicy; |
2249 TInt retLockcode = KErrNone; |
|
2250 RSCPClient scpClient; |
2267 RSCPClient scpClient; |
2251 retLockcode = scpClient.Connect(); |
2268 res = scpClient.Connect(); |
2252 RDEBUG( "retLockcode", retLockcode ); |
2269 RDEBUG( "res", res ); |
2253 if(retLockcode == KErrNone ) |
2270 if(res == KErrNone ) |
2254 { |
2271 { |
2255 RDEBUG( "scpClient.VerifyNewLockcodeAgainstPolicies", 0 ); |
2272 RDEBUG( "scpClient.VerifyNewLockcodeAgainstPolicies", 0 ); |
2256 retLockcode = scpClient.IsLockcodeChangeAllowedNow( aFailedPolicies ); |
2273 TBool changeAllowed = scpClient.IsLockcodeChangeAllowedNow( aFailedPolicies ); |
2257 RDEBUG( "retLockcode", retLockcode ); |
2274 RDEBUG( "bool changeAllowed", changeAllowed ); |
2258 RDEBUG( "aFailedPolicies.Count()", aFailedPolicies.Count() ); |
2275 RDEBUG( "aFailedPolicies.Count()", aFailedPolicies.Count() ); |
2259 res = retLockcode; |
2276 if(changeAllowed) |
|
2277 res = KErrNone; |
|
2278 else |
|
2279 res = KErrAccessDenied; |
2260 for(TInt i=0; i<aFailedPolicies.Count(); i++) |
2280 for(TInt i=0; i<aFailedPolicies.Count(); i++) |
2261 { |
2281 { |
2262 failedPolicy = aFailedPolicies[i]; |
2282 failedPolicy = aFailedPolicies[i]; |
2263 RDEBUG( "failedPolicy", failedPolicy ); |
2283 RDEBUG( "failedPolicy", failedPolicy ); |
2264 // it could also be res = KErrGsm0707IncorrectPassword; |
2284 // it could also be res = KErrGsm0707IncorrectPassword; |
2265 res = KErrTDevicelockPolicies + failedPolicy; |
2285 res = KErrTDevicelockPolicies + failedPolicy; |
2266 } |
2286 } |
2267 scpClient.Close(); |
2287 scpClient.Close(); |
2268 if(retLockcode!=KErrNone) |
2288 if(res!=KErrNone) |
2269 { |
2289 { |
2270 ShowResultNoteL(res, CAknNoteDialog::EErrorTone); |
2290 ShowResultNoteL(res, CAknNoteDialog::EErrorTone); |
2271 return res; |
2291 return res; |
2272 } |
2292 } |
2273 } |
2293 } |
2274 else |
2294 else |
2275 { |
2295 { |
2276 RDEBUG( "failed connecting to SCP", retLockcode ); |
2296 RDEBUG( "failed connecting to SCP", res ); |
2277 // what to do? let's assume that we don't need special policies. |
2297 // what to do? let's assume that we don't need special policies. |
2278 } |
2298 } |
2279 } |
2299 } |
2280 |
2300 |
2281 RDEBUG("aOldPassword.Length()", aOldPassword.Length()); |
2301 RDEBUG("aOldPassword.Length()", aOldPassword.Length()); |
2383 // Confirm that the new code is nice. |
2403 // Confirm that the new code is nice. |
2384 // This is also done on every key-press in the dialog, but it doesn't harm to repeat. |
2404 // This is also done on every key-press in the dialog, but it doesn't harm to repeat. |
2385 // In fact this is needed for the case when newPassword is provided. |
2405 // In fact this is needed for the case when newPassword is provided. |
2386 RArray<TDevicelockPolicies> aFailedPolicies; |
2406 RArray<TDevicelockPolicies> aFailedPolicies; |
2387 TDevicelockPolicies failedPolicy; |
2407 TDevicelockPolicies failedPolicy; |
2388 TInt retLockcode = KErrNone; |
|
2389 RSCPClient scpClient; |
2408 RSCPClient scpClient; |
2390 retLockcode = scpClient.Connect(); |
2409 res = scpClient.Connect(); |
2391 RDEBUG( "retLockcode", retLockcode ); |
2410 RDEBUG( "res", res ); |
2392 if(retLockcode == KErrNone ) |
2411 if(res == KErrNone ) |
2393 { |
2412 { |
2394 RDEBUG( "scpClient.VerifyNewLockcodeAgainstPolicies", 0 ); |
2413 RDEBUG( "scpClient.VerifyNewLockcodeAgainstPolicies", 0 ); |
2395 RDEBUGSTR( newPassword ); |
2414 RDEBUGSTR( newPassword ); |
2396 retLockcode = scpClient.VerifyNewLockcodeAgainstPolicies( newPassword, aFailedPolicies ); |
2415 res = scpClient.VerifyNewLockcodeAgainstPolicies( newPassword, aFailedPolicies ); |
2397 RDEBUG( "retLockcode", retLockcode ); |
2416 RDEBUG( "res", res ); |
2398 RDEBUG( "aFailedPolicies.Count()", aFailedPolicies.Count() ); |
2417 RDEBUG( "aFailedPolicies.Count()", aFailedPolicies.Count() ); |
2399 for(TInt i=0; i<aFailedPolicies.Count(); i++) |
2418 for(TInt i=0; i<aFailedPolicies.Count(); i++) |
2400 { |
2419 { |
2401 failedPolicy = aFailedPolicies[i]; |
2420 failedPolicy = aFailedPolicies[i]; |
2402 RDEBUG( "failedPolicy", failedPolicy ); |
2421 RDEBUG( "failedPolicy", failedPolicy ); |
2405 } |
2424 } |
2406 scpClient.Close(); |
2425 scpClient.Close(); |
2407 } |
2426 } |
2408 else |
2427 else |
2409 { |
2428 { |
2410 RDEBUG( "failed connecting to SCP", retLockcode ); |
2429 RDEBUG( "failed connecting to SCP", res ); |
2411 // what to do? let's assume that we don't need special policies. |
2430 // what to do? let's assume that we don't need special policies. |
2412 } |
2431 } |
2413 |
2432 |
2414 // change code |
2433 // change code |
2415 RDEBUG("res", res); |
2434 RDEBUG("res", res); |
2416 if (res == KErrNone) |
2435 // let's see if TARM rejects it |
2417 { |
2436 if(res==KErrNone) |
2418 passwords.iOldPassword = oldPassword; |
2437 { |
2419 passwords.iNewPassword = newPassword; |
2438 // Send the changed code to the SCP server, even with device lock enhancements. |
2420 iWait->SetRequestType(EMobilePhoneChangeSecurityCode); |
2439 RDEBUG("scpClient.Connect", 0); |
2421 RDEBUG("ChangeSecurityCode", 0); |
2440 RSCPClient scpClient; |
2422 iPhone.ChangeSecurityCode(iWait->iStatus, secCodeType, passwords); |
2441 TBuf<32> newScpCode; |
2423 RDEBUG("WaitForRequestL", 0); |
2442 TBuf<32> oldScpCode; |
2424 res = iWait->WaitForRequestL(); |
2443 newScpCode.Copy(newPassword); |
2425 RDEBUG("WaitForRequestL res", res); |
2444 oldScpCode.Copy(oldPassword); |
2426 #ifdef __WINS__ |
2445 if (scpClient.Connect() == KErrNone) |
2427 if (res == KErrNotSupported) |
2446 { |
2428 res = KErrNone; |
2447 RDEBUG("scpClient.StoreLockcode", 0); |
2429 #endif |
2448 // this is the old method. Obsolete now |
2430 |
2449 // scpClient.StoreCode( newCode ); |
2431 if (res == KErrNone && 1 == 0) // TODO not possible to enable because it asks code again |
2450 RArray<TDevicelockPolicies> aFailedPolicies; |
2432 { |
2451 TDevicelockPolicies failedPolicy; |
2433 RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice; |
2452 RDEBUG("newScpCode", 0); |
2434 RMobilePhone::TMobilePhoneLockSetting lockChangeSetting = RMobilePhone::ELockSetEnabled; |
2453 RDEBUGSTR( newScpCode ); |
2435 iWait->SetRequestType(EMobilePhoneSetLockSetting); |
2454 RDEBUG("oldScpCode", 0); |
2436 RDEBUG("SetLockSetting", 0); |
2455 RDEBUGSTR( oldScpCode ); |
2437 iPhone.SetLockSetting(iWait->iStatus, lockType, lockChangeSetting); |
2456 RDEBUG( "StoreLockcode", 0 ); |
2438 RDEBUG("WaitForRequestL", 0); |
2457 res = scpClient.StoreLockcode(newScpCode, oldScpCode, aFailedPolicies); // this does iPhone.ChangeSecurityCode |
2439 res = iWait->WaitForRequestL(); |
2458 RDEBUG( "res", res ); |
2440 RDEBUG("WaitForRequestL res", res); |
2459 RDEBUG( "KErrAccessDenied", KErrAccessDenied ); |
2441 #ifdef __WINS__ |
2460 #ifdef __WINS__ |
2442 if (res == KErrNotSupported || res == KErrTimedOut) |
2461 if (res == KErrNotSupported) |
2443 res = KErrNone; |
2462 res = KErrNone; |
2444 #endif |
2463 #endif |
2445 } |
2464 RDEBUG( "aFailedPolicies.Count()", aFailedPolicies.Count() ); |
2446 } |
2465 for (TInt i = 0; i < aFailedPolicies.Count(); i++) |
2447 |
2466 { |
2448 RDEBUG("res", res); |
2467 failedPolicy = aFailedPolicies[i]; |
2449 switch (res) |
2468 RDEBUG( "failedPolicy", failedPolicy ); |
2450 { |
2469 } |
2451 case KErrNone: |
2470 scpClient.Close(); |
2452 { |
2471 // Don't know what to do if TARM fails. Hopefully it was stopped at typing, as well as VerifyNewLockcodeAgainstPolicies |
2453 // code changed ... unless TARM rejects it |
2472 switch (res) |
2454 { |
2473 { |
2455 // Send the changed code to the SCP server, even with device lock enhancements. |
2474 case KErrNone: |
2456 RDEBUG("scpClient.Connect", 0); |
2475 { |
2457 RSCPClient scpClient; |
2476 RDEBUG( "showing R_SECURITY_CODE_CHANGED_NOTE", R_SECURITY_CODE_CHANGED_NOTE ); |
2458 TSCPSecCode newScpCode; |
2477 ShowResultNoteL(R_SECURITY_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone); |
2459 TSCPSecCode oldScpCode; |
2478 break; |
2460 newScpCode.Copy(newPassword); |
2479 } |
2461 oldScpCode.Copy(oldPassword); |
2480 case KErrAccessDenied: // TARM has wrong UID |
2462 if (scpClient.Connect() == KErrNone) |
2481 { |
2463 { |
2482 res = KErrTDevicelockPolicies+EDevicelockTotalPolicies+1; |
2464 RDEBUG("scpClient.StoreLockcode", 0); |
2483 RDEBUG( "res", res ); |
2465 // this is the old method. Obsolete now |
2484 ShowResultNoteL(res, CAknNoteDialog::EConfirmationTone); |
2466 // scpClient.StoreCode( newCode ); |
2485 res = KErrAccessDenied; // no reason for retry, as it will fail again and again |
2467 RArray<TDevicelockPolicies> aFailedPolicies; |
2486 break; |
2468 TDevicelockPolicies failedPolicy; |
2487 } |
2469 TInt retLockcode = KErrNone; |
2488 case KErrGsmSSPasswordAttemptsViolation: |
2470 RDEBUG("newScpCode", 0); |
2489 case KErrLocked: |
2471 RDEBUGSTR( newScpCode ); |
2490 { |
2472 RDEBUG("oldScpCode", 0); |
2491 RDEBUG( "KErrLocked", KErrLocked ); |
2473 RDEBUGSTR( oldScpCode ); |
2492 ShowResultNoteL(R_SEC_BLOCKED, CAknNoteDialog::EErrorTone); |
2474 retLockcode = scpClient.StoreLockcode(newScpCode, oldScpCode, aFailedPolicies); |
2493 goto askChangeSecCodeParamsL; |
2475 RDEBUG( "retLockcode", retLockcode ); |
2494 // break; |
2476 RDEBUG( "KErrAccessDenied", KErrAccessDenied ); |
2495 } |
2477 RDEBUG( "aFailedPolicies.Count()", aFailedPolicies.Count() ); |
2496 case KErrGsm0707IncorrectPassword: |
2478 for (TInt i = 0; i < aFailedPolicies.Count(); i++) |
2497 { |
2479 { |
2498 // code was entered erroneously |
2480 failedPolicy = aFailedPolicies[i]; |
2499 RDEBUG( "KErrGsm0707IncorrectPassword", KErrGsm0707IncorrectPassword ); |
2481 RDEBUG( "failedPolicy", failedPolicy ); |
2500 ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); |
2482 } |
2501 goto askChangeSecCodeParamsL; |
2483 // Don't know what to do if TARM fails. Hopefully it was stopped at typing, as well as VerifyNewLockcodeAgainstPolicies |
2502 // break; |
2484 // The code is already changed in iPhone ! |
2503 } |
2485 // For now, just undo the changed password |
2504 case KErrAbort: |
2486 if(retLockcode!=KErrNone) |
2505 { |
2487 { |
2506 RDEBUG( "KErrAbort", KErrAbort ); |
2488 RDEBUG("Undo password change because retLockcode", retLockcode); |
2507 break; |
2489 if(retLockcode==KErrAccessDenied) // this happens if CSCPSession::HandleAuthenticationMessageL doesn't include the UID |
2508 } |
2490 retLockcode = KErrTDevicelockPolicies+EDevicelockTotalPolicies+1; |
2509 default: |
2491 ShowResultNoteL(retLockcode, CAknNoteDialog::EConfirmationTone); |
2510 { |
2492 |
2511 ShowErrorNoteL(res); |
2493 // go back to previous password. |
2512 goto askChangeSecCodeParamsL; |
2494 passwords.iOldPassword = newPassword; |
2513 // break; |
2495 passwords.iNewPassword = oldPassword; |
2514 } |
2496 iWait->SetRequestType(EMobilePhoneChangeSecurityCode); |
2515 } // switch |
2497 RDEBUG("ChangeSecurityCode", 0); |
2516 } // scpClient.Connect |
2498 iPhone.ChangeSecurityCode(iWait->iStatus, secCodeType, passwords); |
2517 } |
2499 RDEBUG("WaitForRequestL", 0); |
2518 |
2500 res = iWait->WaitForRequestL(); // this can't fail. ISA is always allowing to undo the password change. |
|
2501 RDEBUG("WaitForRequestL res", res); |
|
2502 #ifdef __WINS__ |
|
2503 if (res == KErrNotSupported) |
|
2504 res = KErrNone; |
|
2505 #endif |
|
2506 res = retLockcode; |
|
2507 } |
|
2508 scpClient.Close(); |
|
2509 } |
|
2510 if(res==KErrNone) |
|
2511 { |
|
2512 RDEBUG( "showing R_SECURITY_CODE_CHANGED_NOTE", R_SECURITY_CODE_CHANGED_NOTE ); |
|
2513 ShowResultNoteL(R_SECURITY_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone); |
|
2514 } |
|
2515 } |
|
2516 break; |
|
2517 } |
|
2518 case KErrGsmSSPasswordAttemptsViolation: |
|
2519 case KErrLocked: |
|
2520 { |
|
2521 ShowResultNoteL(R_SEC_BLOCKED, CAknNoteDialog::EErrorTone); |
|
2522 ChangeSecCodeParamsL(aOldPassword, aNewPassword, aFlags, aCaption, aShowError); |
|
2523 break; |
|
2524 } |
|
2525 case KErrGsm0707IncorrectPassword: |
|
2526 case KErrAccessDenied: |
|
2527 { |
|
2528 // code was entered erroneously |
|
2529 ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); |
|
2530 ChangeSecCodeParamsL(aOldPassword, aNewPassword, aFlags, aCaption, aShowError); |
|
2531 break; |
|
2532 } |
|
2533 case KErrAbort: |
|
2534 { |
|
2535 break; |
|
2536 } |
|
2537 default: |
|
2538 { |
|
2539 ShowErrorNoteL(res); |
|
2540 ChangeSecCodeParamsL(aOldPassword, aNewPassword, aFlags, aCaption, aShowError); |
|
2541 break; |
|
2542 } |
|
2543 } // switch |
|
2544 RDEBUG("return res", res); |
2519 RDEBUG("return res", res); |
2545 return res; |
2520 return res; |
2546 } |
2521 } |
2547 |
2522 |
2548 /**************************************/ |
2523 /**************************************/ |
2549 // qtdone |
2524 // qtdone |
2550 // the params are changed in the settings,. This only asks for password. |
2525 // the params are changed in the settings,. This only asks for password. |
2551 EXPORT_C TInt CSecuritySettings::ChangeAutoLockPeriodParamsL(TInt aPeriod, RMobilePhone::TMobilePassword aOldPassword, TInt aFlags, TDes& aCaption, TInt aShowError) |
2526 EXPORT_C TInt CSecuritySettings::ChangeAutoLockPeriodParamsL(TInt aPeriod, RMobilePhone::TMobilePassword aOldPassword, TInt aFlags, TDes& aCaption, TInt aShowError) |
2552 { |
2527 { |
|
2528 askChangeAutoLockPeriodParamsL: |
2553 RDEBUG("aPeriod", aPeriod); |
2529 RDEBUG("aPeriod", aPeriod); |
2554 RDEBUG("aFlags", aFlags); |
2530 RDEBUG("aFlags", aFlags); |
2555 /***************************************************** |
2531 /***************************************************** |
2556 * Series 60 Customer / ETel |
2532 * Series 60 Customer / ETel |
2557 * Series 60 ETel API |
2533 * Series 60 ETel API |
2676 case KErrGsmSSPasswordAttemptsViolation: |
2652 case KErrGsmSSPasswordAttemptsViolation: |
2677 case KErrLocked: |
2653 case KErrLocked: |
2678 RDEBUG("KErrLocked", KErrLocked) |
2654 RDEBUG("KErrLocked", KErrLocked) |
2679 ; |
2655 ; |
2680 ShowResultNoteL(KErrLocked, CAknNoteDialog::EErrorTone); // the old code didn't show messages |
2656 ShowResultNoteL(KErrLocked, CAknNoteDialog::EErrorTone); // the old code didn't show messages |
2681 return ChangeAutoLockPeriodParamsL(oldPeriod, aOldPassword, aFlags, aCaption, aShowError); // ask again |
2657 goto askChangeAutoLockPeriodParamsL; // ask again |
2682 case KErrGsm0707IncorrectPassword: |
2658 case KErrGsm0707IncorrectPassword: |
|
2659 RDEBUG("KErrGsm0707IncorrectPassword", KErrGsm0707IncorrectPassword) |
|
2660 ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); // the old code didn't show messages |
|
2661 goto askChangeAutoLockPeriodParamsL; // ask again |
2683 case KErrAccessDenied: |
2662 case KErrAccessDenied: |
2684 RDEBUG("KErrAccessDenied", KErrAccessDenied) |
2663 RDEBUG("KErrAccessDenied", KErrAccessDenied) |
2685 ; |
2664 ; |
2686 // code was entered erroneously |
2665 // code was entered erroneously |
2687 ShowResultNoteL(KErrAccessDenied, CAknNoteDialog::EErrorTone); // the old code didn't show messages |
2666 ShowResultNoteL(KErrAccessDenied, CAknNoteDialog::EErrorTone); // the old code didn't show messages |
2688 return ChangeAutoLockPeriodParamsL(oldPeriod, aOldPassword, aFlags, aCaption, aShowError); // ask again |
2667 goto askChangeAutoLockPeriodParamsL; // ask again |
2689 case KErrAbort: |
2668 case KErrAbort: |
2690 // User pressed "cancel" in the code query dialog. |
2669 // User pressed "cancel" in the code query dialog. |
2691 return oldPeriod; |
2670 RDEBUG("KErrAbort", KErrAbort) |
|
2671 return KErrAbort; |
2692 default: |
2672 default: |
2693 RDEBUG("default", status) |
2673 RDEBUG("default", status) |
2694 ; |
2674 ; |
2695 ShowResultNoteL(status, CAknNoteDialog::EErrorTone); // the old code didn't show messages |
2675 ShowResultNoteL(status, CAknNoteDialog::EErrorTone); // the old code didn't show messages |
2696 return ChangeAutoLockPeriodParamsL(oldPeriod, aOldPassword, aFlags, aCaption, aShowError); // ask again |
2676 goto askChangeAutoLockPeriodParamsL; // ask again |
2697 } |
2677 } |
2698 RDEBUG("aPeriod", aPeriod); |
2678 RDEBUG("aPeriod", aPeriod); |
2699 return aPeriod; |
2679 return aPeriod; |
2700 } |
2680 } |
2701 /*****************************/ |
2681 /*****************************/ |