37 #include "SCPLockCode.h" |
39 #include "SCPLockCode.h" |
38 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
40 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
39 #include <TerminalControl3rdPartyAPI.h> |
41 #include <TerminalControl3rdPartyAPI.h> |
40 #include <SCPServerInterface.h> |
42 #include <SCPServerInterface.h> |
41 #include <SecUi.rsg> |
43 #include <SecUi.rsg> |
|
44 #include <scptimestamppluginlang.rsg> |
42 #include <secui.hrh> |
45 #include <secui.hrh> |
43 #include <StringLoader.h> |
46 #include <StringLoader.h> |
44 #include <bautils.h> |
47 #include <bautils.h> |
45 //#endif // DEVICE_LOCK_ENHANCEMENTS |
48 //#endif // DEVICE_LOCK_ENHANCEMENTS |
|
49 #include <DevManInternalCRKeys.h> |
46 |
50 |
47 #include <featmgr.h> |
51 #include <featmgr.h> |
48 #include "SCPDebug.h" |
52 #include "SCPDebug.h" |
49 #include <e32property.h> |
53 #include <e32property.h> |
|
54 #include <SCPPServerPluginDefs.hrh> |
|
55 #include <apgtask.h> |
|
56 #include <e32property.h> |
|
57 #include <PSVariables.h> |
|
58 #include <coreapplicationuisdomainpskeys.h> |
|
59 |
50 /*#ifdef _DEBUG |
60 /*#ifdef _DEBUG |
51 #define __SCP_DEBUG |
61 #define __SCP_DEBUG |
52 #endif // _DEBUG |
62 #endif // _DEBUG |
53 |
63 |
54 // Define this so the precompiler in CW 3.1 won't complain about token pasting, |
64 // Define this so the precompiler in CW 3.1 won't complain about token pasting, |
61 #define Dprint(a) |
71 #define Dprint(a) |
62 #endif // _DEBUG*/ |
72 #endif // _DEBUG*/ |
63 |
73 |
64 static const TUint KDefaultMessageSlots = 3; |
74 static const TUint KDefaultMessageSlots = 3; |
65 static const TInt KSCPConnectRetries( 2 ); |
75 static const TInt KSCPConnectRetries( 2 ); |
66 |
76 const TInt KLockedbyLawmo (30); |
67 |
77 |
68 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
78 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
69 _LIT( KDriveZ, "Z:" ); |
79 _LIT( KDriveZ, "Z:" ); |
70 _LIT( KSCPResourceFilename, "\\Resource\\SCPNotifier.RSC" ); |
80 _LIT( KSCPResourceFilename, "\\Resource\\SCPNotifier.RSC" ); |
71 _LIT( KSCPSecUIResourceFilename, "\\Resource\\SecUi.RSC" ); |
81 _LIT( KSCPSecUIResourceFilename, "\\Resource\\SecUi.RSC" ); |
|
82 _LIT( KSCPTimestampPluginResFilename, "\\Resource\\SCPTimestampPluginLang.rsc"); |
72 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
83 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
73 |
84 |
74 // Uid for the application; this should match the mmp file |
85 // Uid for the application; this should match the mmp file |
75 const TUid KServerUid3 = {0x10207836}; |
86 const TUid KServerUid3 = {0x10207836}; |
76 |
87 |
463 // --------------------------------------------------------- |
474 // --------------------------------------------------------- |
464 // |
475 // |
465 EXPORT_C TInt RSCPClient::SetPhoneLock( TBool aLocked ) |
476 EXPORT_C TInt RSCPClient::SetPhoneLock( TBool aLocked ) |
466 { |
477 { |
467 Dprint( (_L("--> RSCPClient::SetPhoneLock( %d)"), aLocked )); |
478 Dprint( (_L("--> RSCPClient::SetPhoneLock( %d)"), aLocked )); |
468 |
479 TInt autolockState = -1; |
|
480 RProperty aProperty; |
|
481 aProperty.Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState); |
|
482 Dprint( (_L("RSCPClient::SetPhoneLock()Autolock state before %d"), autolockState )); |
|
483 |
|
484 if((aLocked==0)&&(autolockState != EAutolockStatusUninitialized)) |
|
485 InformAutolockTask(); |
|
486 Dprint( (_L("RSCPClient sendreceive") )); |
469 TInt ret = SendReceive(ESCPServSetPhoneLock, TIpcArgs( aLocked ) ); |
487 TInt ret = SendReceive(ESCPServSetPhoneLock, TIpcArgs( aLocked ) ); |
470 |
488 Dprint( (_L("RSCPClient sendreceive done") )); |
|
489 aProperty.Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState); |
|
490 Dprint( (_L("RSCPClient::SetPhoneLock()Autolock state after %d"), autolockState )); |
|
491 // Put it here because, we cant change autolock status before sendreceive |
|
492 // Uninitialised state is Only at Bootup. |
|
493 if((autolockState == EAutolockStatusUninitialized)&&(aLocked==0)&&(ret==KErrNone)) |
|
494 { |
|
495 Dprint( (_L("RSCPClient::SetPhoneLock()setting autolock status") )); |
|
496 aProperty.Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EAutolockOff); |
|
497 // This is startup and we are done with ISA unlock |
|
498 // So set the Startup cenrep key so tht it is used in SeccodeQuery |
|
499 CRepository* lRepository = NULL; |
|
500 TInt returnv; |
|
501 TRAP(returnv, lRepository = CRepository :: NewL(KCRUidSCPLockCode)); |
|
502 returnv = lRepository->Set(KSCPStartupQuery, 1); |
|
503 if(returnv==KErrNone) |
|
504 Dprint( (_L("RSCPClient::SetPhoneLock()setting KSCPStartupQuery") )); |
|
505 delete lRepository; |
|
506 } |
471 Dprint( (_L("<-- RSCPClient::SetPhoneLock(): %d"), ret )); |
507 Dprint( (_L("<-- RSCPClient::SetPhoneLock(): %d"), ret )); |
472 return ret; |
508 return ret; |
|
509 } |
|
510 |
|
511 void RSCPClient::InformAutolockTask() |
|
512 { |
|
513 Dprint( (_L("RSCPClient::InformAutolockTask") )); |
|
514 // Deactivation call, send the deactivation message to Autolock |
|
515 RWsSession wsSession; |
|
516 if ( wsSession.Connect() != KErrNone ) |
|
517 { |
|
518 Dprint( (_L("RSCPClient::InformAutolockTask():\ |
|
519 WsSession connection failed") )); |
|
520 User::Leave( KErrGeneral ); |
|
521 } |
|
522 CleanupClosePushL( wsSession ); |
|
523 |
|
524 TApaTaskList taskList( wsSession ); |
|
525 TApaTask task = taskList.FindApp( TUid::Uid( 0x100059B5 ) ); // Autolock |
|
526 |
|
527 if ( task.Exists() ) |
|
528 { |
|
529 Dprint( (_L("RSCPClient::InformAutolockTask():\ |
|
530 Autolock task found, sending msg") )); |
|
531 // No parameters, just a dummy buffer |
|
532 TBuf8<8> buf; |
|
533 buf.Zero(); |
|
534 const TPtrC8& message = buf; |
|
535 User::LeaveIfError( |
|
536 task.SendMessage( TUid::Uid( SCP_CMDUID_UNLOCK+1 ), message ) |
|
537 ); |
|
538 } |
|
539 else |
|
540 { |
|
541 Dprint( (_L("RSCPClient::InformAutolockTask():\ |
|
542 Autolock task not found") )); |
|
543 User::Leave( KErrNotFound ); |
|
544 } |
|
545 |
|
546 CleanupStack::PopAndDestroy(); // wsSession |
473 } |
547 } |
474 |
548 |
475 // --------------------------------------------------------- |
549 // --------------------------------------------------------- |
476 // TBool RSCPClient::QueryAdminCmd( TSCPAdminCommand aCommand ) |
550 // TBool RSCPClient::QueryAdminCmd( TSCPAdminCommand aCommand ) |
477 // Packs the command parameter into a buffer, and propagates |
551 // Packs the command parameter into a buffer, and propagates |
584 |
658 |
585 CCoeEnv :: Static()->DeleteResourceFile(lResFileSecUi); |
659 CCoeEnv :: Static()->DeleteResourceFile(lResFileSecUi); |
586 } |
660 } |
587 |
661 |
588 Dprint((_L("<-- RSCPClient::SecCodeQuery(): lStatus= %d, lErr= %d"), lStatus, lErr)); |
662 Dprint((_L("<-- RSCPClient::SecCodeQuery(): lStatus= %d, lErr= %d"), lStatus, lErr)); |
|
663 CRepository* lRepository = NULL; |
|
664 TInt startup = 0; |
|
665 TInt returnv; |
|
666 TRAP(returnv, lRepository = CRepository :: NewL(KCRUidSCPLockCode)); |
|
667 returnv = lRepository->Get(KSCPStartupQuery, startup); |
|
668 if(returnv == KErrNone) |
|
669 Dprint( (_L("RSCPClient::SecCodeQuery()KSCPStartupQuery get done"))); |
|
670 lRepository->Set(KSCPStartupQuery, 0); |
|
671 delete lRepository; |
|
672 Dprint((_L("RSCPClient::SecCodeQuery(): startup ? %d"), startup )); |
|
673 //Check if this is Startup Query and tht device is remote unlocked now ? |
|
674 if(startup) |
|
675 { |
|
676 Dprint((_L("[RSCPClient] SecCodeQuery() startup remote Unlocked"))); |
|
677 return KErrNone; |
|
678 } |
|
679 else |
589 return (lErr != KErrNone) ? lErr : lStatus; |
680 return (lErr != KErrNone) ? lErr : lStatus; |
590 } |
681 } |
591 |
682 |
592 // --------------------------------------------------------- |
683 // --------------------------------------------------------- |
593 // RSCPClient::ChangeCodeRequest() |
684 // RSCPClient::ChangeCodeRequest() |
777 lWriteStream.WriteInt32L(aAppIDs[i].iUid); |
869 lWriteStream.WriteInt32L(aAppIDs[i].iUid); |
778 } |
870 } |
779 lWriteStream.CommitL(); |
871 lWriteStream.CommitL(); |
780 TInt lStatus = SendReceive(ESCPApplicationUninstalled, TIpcArgs(ESCPApplicationUninstalled, &lBuff->Des())); |
872 TInt lStatus = SendReceive(ESCPApplicationUninstalled, TIpcArgs(ESCPApplicationUninstalled, &lBuff->Des())); |
781 CleanupStack :: PopAndDestroy(2); // lBuff, lWriteStream |
873 CleanupStack :: PopAndDestroy(2); // lBuff, lWriteStream |
|
874 Dprint((_L("RSCPClient::PerformCleanupL() <<<"))); |
782 return lStatus; |
875 return lStatus; |
783 } |
876 } |
784 // --------------------------------------------------------- |
877 // --------------------------------------------------------- |
785 // The server contains all the logic for the parameters, just |
878 // The server contains all the logic for the parameters, just |
786 // propagate the call. |
879 // propagate the call. |
896 bConfig, |
989 bConfig, |
897 minLen, |
990 minLen, |
898 maxLen, |
991 maxLen, |
899 R_SECUI_TEXT_ENTER_NEW_SEC_CODE, |
992 R_SECUI_TEXT_ENTER_NEW_SEC_CODE, |
900 NULL, |
993 NULL, |
901 ecSupport, |
994 ecSupport) ); |
902 CSCPQueryDialog :: EAlphaNumeric) ); |
|
903 |
995 |
904 if ( ( ret ) && ( ret != ESecUiEmergencyCall ) && ( err == KErrNone ) ) |
996 if ( ( ret ) && ( ret != ESecUiEmergencyCall ) && ( err == KErrNone ) ) |
905 { |
997 { |
906 verifyCodeBuffer.Zero(); |
998 verifyCodeBuffer.Zero(); |
907 TChar ch = static_cast<TChar>(newCodeBuffer[0]); |
999 /*TChar ch = static_cast<TChar>(newCodeBuffer[0]); |
908 |
1000 |
909 CSCPQueryDialog :: TKeypadContext lKPContext = |
1001 CSCPQueryDialog :: TKeypadContext lKPContext = |
910 (ch.IsDigit() ? CSCPQueryDialog :: ENumeric : CSCPQueryDialog :: EAlphaNumeric); |
1002 (ch.IsDigit() ? CSCPQueryDialog :: ENumeric : CSCPQueryDialog :: EAlphaNumeric);*/ |
911 |
1003 |
912 TRAP( err, ret = RunDialogL( verifyCodeBuffer, |
1004 TRAP( err, ret = RunDialogL( verifyCodeBuffer, |
913 bConfig, |
1005 bConfig, |
914 minLen, |
1006 minLen, |
915 maxLen, |
1007 maxLen, |
916 R_SECUI_TEXT_VERIFY_NEW_SEC_CODE, |
1008 R_SECUI_TEXT_VERIFY_NEW_SEC_CODE, |
917 NULL, |
1009 NULL, |
918 ecSupport, |
1010 ecSupport)); |
919 lKPContext)); |
|
920 } |
1011 } |
921 |
1012 |
922 if ( ( !ret ) || ( err != KErrNone ) || ( ret == ESecUiEmergencyCall ) ) |
1013 if ( ( !ret ) || ( err != KErrNone ) || ( ret == ESecUiEmergencyCall ) ) |
923 { |
1014 { |
924 break; |
1015 break; |
1068 |
1159 |
1069 TPtr codeBuf = codeHBuf->Des(); |
1160 TPtr codeBuf = codeHBuf->Des(); |
1070 codeBuf.Zero(); |
1161 codeBuf.Zero(); |
1071 |
1162 |
1072 ret = theParams->Get( KSCPParamPassword, codeBuf ); |
1163 ret = theParams->Get( KSCPParamPassword, codeBuf ); |
|
1164 |
1073 if ( ret == KErrNone ) |
1165 if ( ret == KErrNone ) |
1074 { |
1166 { |
|
1167 TInt lResFile = 0; |
|
1168 TFileName resFile; |
|
1169 resFile.Copy( KDriveZ ); |
|
1170 resFile.Append( KSCPTimestampPluginResFilename ); |
|
1171 BaflUtils :: NearestLanguageFile( CCoeEnv :: Static()->FsSession(), resFile ); |
|
1172 lResFile = CCoeEnv :: Static()->AddResourceFileL(resFile); |
|
1173 |
|
1174 CAknNoteDialog* lNoteDlg = new (ELeave) CAknNoteDialog(CAknNoteDialog :: ENoTone, CAknNoteDialog :: ELongTimeout); |
|
1175 CleanupStack :: PushL(lNoteDlg); |
|
1176 |
|
1177 HBufC* lExpNoteMsg = CEikonEnv :: Static()->AllocReadResourceLC(R_SET_SEC_CODE_AGING); |
|
1178 lNoteDlg->SetTextL(lExpNoteMsg->Des()); |
|
1179 |
|
1180 lNoteDlg->ExecuteLD(R_DIALOG_WARNING); |
|
1181 CleanupStack :: PopAndDestroy(1); //lExpNoteMsg |
|
1182 CleanupStack :: Pop(1); //lNoteDlg |
|
1183 |
|
1184 CCoeEnv :: Static()->DeleteResourceFile( lResFile ); |
|
1185 |
1075 TSCPSecCode newDOSCode; |
1186 TSCPSecCode newDOSCode; |
1076 ret = GetNewCodeAndChange( codeBuf, KSCPForcedChange, &newDOSCode ); |
1187 ret = GetNewCodeAndChange( codeBuf, KSCPForcedChange, &newDOSCode ); |
1077 |
1188 |
1078 // If aOutParams is defined, return the new code |
1189 // If aOutParams is defined, return the new code |
1079 if ( aOutParams != NULL ) |
1190 if ( aOutParams != NULL ) |
1231 if(lRet != KErrNone) { |
1342 if(lRet != KErrNone) { |
1232 Dprint(_L("[RSCPClient]-> ERROR: Unable to perform get on CenRep, lErr=%d"), lRet); |
1343 Dprint(_L("[RSCPClient]-> ERROR: Unable to perform get on CenRep, lErr=%d"), lRet); |
1233 CleanupStack :: PopAndDestroy(lRepository); |
1344 CleanupStack :: PopAndDestroy(lRepository); |
1234 return lRet; |
1345 return lRet; |
1235 } |
1346 } |
1236 |
1347 TInt currentLawmoState(0); |
|
1348 Dprint( (_L("CSCPClient::lawmo cenrep") )); |
|
1349 CRepository* crep = CRepository::NewLC( KCRUidDeviceManagementInternalKeys ); |
|
1350 TInt reterr = crep->Get( KLAWMOPhoneLock, currentLawmoState ); |
|
1351 Dprint( (_L("CSCPClient::lawmo cenrep done") )); |
|
1352 if(reterr != KErrNone) |
|
1353 { |
|
1354 Dprint(_L("[RSCPClient]-> ERROR: Unable to perform get on CenRep lawmo, lErr=%d"), lRet); |
|
1355 CleanupStack :: PopAndDestroy(crep); |
|
1356 return reterr; |
|
1357 } |
1237 HBufC* codeHBuf = HBufC :: NewLC(KSCPPasscodeMaxLength + 1); |
1358 HBufC* codeHBuf = HBufC :: NewLC(KSCPPasscodeMaxLength + 1); |
1238 HBufC8* addParamsHBuf = HBufC8 :: NewLC(KSCPMaxTARMNotifParamLen); |
1359 HBufC8* addParamsHBuf = HBufC8 :: NewLC(KSCPMaxTARMNotifParamLen); |
1239 TPtr codeBuffer = codeHBuf->Des(); |
1360 TPtr codeBuffer = codeHBuf->Des(); |
1240 TPtr8 addParams = addParamsHBuf->Des(); |
1361 TPtr8 addParams = addParamsHBuf->Des(); |
1241 |
1362 if(currentLawmoState!=KLockedbyLawmo) |
1242 if(lDefCode == 0) { |
1363 { |
|
1364 // rundialog with a new resource file |
|
1365 Dprint((_L("[RSCPClient]-> lawmo current state !=30"))); |
|
1366 TBuf<255> serverId; |
|
1367 serverId.Zero(); |
|
1368 reterr = crep->Get( KLAWMOfactoryDmServerName, serverId ); |
|
1369 Dprint( (_L("RSCPClient::SetSecurityCode serverid: %s"), serverId.PtrZ() )); |
|
1370 HBufC* prompt = StringLoader::LoadLC(R_SCP_LAWMO_LOCKED, serverId); |
|
1371 Dprint( (_L("RSCPClient::SetSecurityCode stringval: %s"), (prompt->Des()).PtrZ() )); |
|
1372 |
|
1373 lRet = RunDialogL(codeBuffer, aButtonsShown, KSCPPasscodeMinLength, KSCPPasscodeMaxLength, |
|
1374 0, prompt, aECSSupport); |
|
1375 if((lRet) && (lRet != ESecUiEmergencyCall) && (lRet != EAknSoftkeyEmergencyCall)) |
|
1376 { |
|
1377 Dprint(_L("[RSCPClient]-> INFO: LL User has updated the lock code...")); |
|
1378 |
|
1379 lRet = SendReceive( ESCPServAuthenticateS60, TIpcArgs( &codeBuffer, &aPassword, &addParams, aFlags)); |
|
1380 |
|
1381 Dprint((_L("[RSCPClient]-> INFO: LL addParams.Length()=%d")), addParams.Length()); |
|
1382 Dprint((_L("[RSCPClient]-> INFO: LL lRet=%d")), lRet); |
|
1383 } |
|
1384 else |
|
1385 { |
|
1386 switch(lRet) |
|
1387 { |
|
1388 case 0: |
|
1389 lRet = KErrCancel; |
|
1390 break; |
|
1391 } |
|
1392 } |
|
1393 CleanupStack::PopAndDestroy(1); |
|
1394 } |
|
1395 else if(lDefCode == 0) { |
1243 Dprint(_L("[RSCPClient]-> INFO: Default lock code has been set already by the user...")); |
1396 Dprint(_L("[RSCPClient]-> INFO: Default lock code has been set already by the user...")); |
1244 |
1397 |
1245 lRet = RunDialogL(codeBuffer, aButtonsShown, KSCPPasscodeMinLength, KSCPPasscodeMaxLength, |
1398 lRet = RunDialogL(codeBuffer, aButtonsShown, KSCPPasscodeMinLength, KSCPPasscodeMaxLength, |
1246 R_SECUI_TEXT_ENTER_SEC_CODE, NULL, aECSSupport); |
1399 R_SECUI_TEXT_ENTER_SEC_CODE, NULL, aECSSupport); |
1247 |
1400 |
1351 } |
1504 } |
1352 } |
1505 } |
1353 |
1506 |
1354 if(lTempRet == KErrNone) { |
1507 if(lTempRet == KErrNone) { |
1355 CSCPParamObject* outParams = NULL; |
1508 CSCPParamObject* outParams = NULL; |
1356 ProcessServerCommandsL(addParams, &outParams); |
1509 /* |
|
1510 * aECSSupport when passed to ProcessServerCommandsL decides if the expiry note and subsequently change device lock |
|
1511 * code has to be shown or not. Normally if the lock code has expired, the same has to be prompted from the user and |
|
1512 * has to be done only during device unlock. aECSSupport value is being passed to ensure that new lock code is prompted |
|
1513 * only during device unlock. |
|
1514 */ |
|
1515 ProcessServerCommandsL(addParams, &outParams, !aECSSupport); |
1357 |
1516 |
1358 if(outParams != NULL) { |
1517 if(outParams != NULL) { |
1359 TSCPSecCode newSecCode; |
1518 TSCPSecCode newSecCode; |
1360 if(outParams->Get(KSCPParamPassword, newSecCode) == KErrNone) { |
1519 if(outParams->Get(KSCPParamPassword, newSecCode) == KErrNone) { |
1361 Dprint((_L("[RSCPClient]-> INFO: Updating encoded password received from the server into aPassword..."))); |
1520 Dprint((_L("[RSCPClient]-> INFO: Updating encoded password received from the server into aPassword..."))); |