terminalsecurity/SCP/SCPClient/src/SCPClient.cpp
branchRCL_3
changeset 76 3cdbd92ee07b
parent 65 5cc2995847ea
equal deleted inserted replaced
69:a082c848c9a9 76:3cdbd92ee07b
    30 
    30 
    31 #include "SCPClient.h"
    31 #include "SCPClient.h"
    32 #include "SCPQueryDialog.h"
    32 #include "SCPQueryDialog.h"
    33 #include "SCPParamObject.h"
    33 #include "SCPParamObject.h"
    34 
    34 
    35 #include <scpnotifier.rsg>
    35 #include <SCPNotifier.rsg>
    36 #include "SCP_IDs.h"
    36 #include "SCP_IDs.h"
    37 
    37 
    38 #include <centralrepository.h>
    38 #include <centralrepository.h>
    39 #include "SCPLockCode.h"
    39 #include "SCPLockCode.h"
    40 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS
    40 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS
    41 #include <TerminalControl3rdPartyAPI.h>
    41 #include <TerminalControl3rdPartyAPI.h>
    42 #include <SCPServerInterface.h>
    42 #include <SCPServerInterface.h>
    43 #include <secui.rsg>
    43 #include <SecUi.rsg>
    44 #include <scptimestamppluginlang.rsg>
    44 #include <scptimestamppluginlang.rsg>
    45 #include <secui.hrh>
    45 #include <secui.hrh>
    46 #include <StringLoader.h>
    46 #include <StringLoader.h>
    47 #include <bautils.h>
    47 #include <bautils.h>
    48 //#endif // DEVICE_LOCK_ENHANCEMENTS
    48 //#endif // DEVICE_LOCK_ENHANCEMENTS
    49 #include <DevManInternalCRKeys.h>
       
    50 
    49 
    51 #include <featmgr.h>
    50 #include <featmgr.h>
    52 #include "SCPDebug.h"
    51 #include "SCPDebug.h"
    53 #include <e32property.h>
    52 #include <e32property.h>
    54 #include <SCPPServerPluginDefs.hrh>
    53 #include <SCPPServerPluginDefs.hrh>
    55 #include <apgtask.h>
    54 #include <apgtask.h>
    56 #include    <e32property.h>
       
    57 #include    <PSVariables.h>
       
    58 #include    <coreapplicationuisdomainpskeys.h>
       
    59 
       
    60 /*#ifdef _DEBUG
    55 /*#ifdef _DEBUG
    61 #define __SCP_DEBUG
    56 #define __SCP_DEBUG
    62 #endif // _DEBUG
    57 #endif // _DEBUG
    63 
    58 
    64 // Define this so the precompiler in CW 3.1 won't complain about token pasting,
    59 // Define this so the precompiler in CW 3.1 won't complain about token pasting,
    71 #define Dprint(a)
    66 #define Dprint(a)
    72 #endif // _DEBUG*/
    67 #endif // _DEBUG*/
    73 
    68 
    74 static const TUint KDefaultMessageSlots = 3;
    69 static const TUint KDefaultMessageSlots = 3;
    75 static const TInt KSCPConnectRetries( 2 );
    70 static const TInt KSCPConnectRetries( 2 );
    76 const TInt KLockedbyLawmo (30);
    71 
    77 
    72 
    78 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS
    73 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS
    79 _LIT( KDriveZ, "Z:" );
    74 _LIT( KDriveZ, "Z:" );
    80 _LIT( KSCPResourceFilename, "\\Resource\\SCPNotifier.RSC" );
    75 _LIT( KSCPResourceFilename, "\\Resource\\SCPNotifier.RSC" );
    81 _LIT( KSCPSecUIResourceFilename, "\\Resource\\SecUi.RSC" );
    76 _LIT( KSCPSecUIResourceFilename, "\\Resource\\SecUi.RSC" );
   474 // ---------------------------------------------------------
   469 // ---------------------------------------------------------
   475 //
   470 //
   476 EXPORT_C TInt RSCPClient::SetPhoneLock( TBool aLocked )
   471 EXPORT_C TInt RSCPClient::SetPhoneLock( TBool aLocked )
   477     {
   472     {
   478     Dprint( (_L("--> RSCPClient::SetPhoneLock( %d)"), aLocked ));
   473     Dprint( (_L("--> RSCPClient::SetPhoneLock( %d)"), aLocked ));
   479     TInt autolockState = -1;
   474             
   480     RProperty aProperty;
   475     if(aLocked==0)
   481     aProperty.Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState);
   476     InformAutolockTask();      
   482     Dprint( (_L("RSCPClient::SetPhoneLock()Autolock state before %d"), autolockState ));
   477 	
   483 
       
   484     if((aLocked==0)&&(autolockState != EAutolockStatusUninitialized))
       
   485     InformAutolockTask();            
       
   486     Dprint( (_L("RSCPClient sendreceive") ));
       
   487     TInt ret = SendReceive(ESCPServSetPhoneLock, TIpcArgs( aLocked ) );
   478     TInt ret = SendReceive(ESCPServSetPhoneLock, TIpcArgs( aLocked ) );
   488     Dprint( (_L("RSCPClient sendreceive done") ));
   479   
   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         }
       
   507     Dprint( (_L("<-- RSCPClient::SetPhoneLock(): %d"), ret ));
   480     Dprint( (_L("<-- RSCPClient::SetPhoneLock(): %d"), ret ));
   508     return ret;
   481     return ret;
   509     }   
   482     }   
   510 
   483 	
       
   484 // ---------------------------------------------------------
       
   485 // TInt RSCPClient::InformAutolockTask()
       
   486 // Informs the autolock to Unlock the homescreen
       
   487 // Status : Approved
       
   488 // ---------------------------------------------------------
       
   489 //
   511 void RSCPClient::InformAutolockTask()
   490 void RSCPClient::InformAutolockTask()
   512     {
   491     {
   513     Dprint( (_L("RSCPClient::InformAutolockTask") ));
   492     Dprint( (_L("RSCPClient::InformAutolockTask") ));
   514     // Deactivation call, send the deactivation message to Autolock
   493     // Deactivation call, send the deactivation message to Autolock
   515         RWsSession wsSession;
   494         RWsSession wsSession;
   658     
   637     
   659         CCoeEnv :: Static()->DeleteResourceFile(lResFileSecUi);
   638         CCoeEnv :: Static()->DeleteResourceFile(lResFileSecUi);
   660     }
   639     }
   661     
   640     
   662     Dprint((_L("<-- RSCPClient::SecCodeQuery(): lStatus= %d, lErr= %d"), lStatus, lErr));
   641     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
       
   680     return (lErr != KErrNone) ? lErr : lStatus;
   642     return (lErr != KErrNone) ? lErr : lStatus;
   681 }
   643 }
   682 
   644 
   683 // ---------------------------------------------------------
   645 // ---------------------------------------------------------
   684 // RSCPClient::ChangeCodeRequest()
   646 // RSCPClient::ChangeCodeRequest()
   849   
   811   
   850     Dprint( (_L("<-- RSCPClient::CheckConfiguration(): %d"), status ));
   812     Dprint( (_L("<-- RSCPClient::CheckConfiguration(): %d"), status ));
   851     
   813     
   852     return ret;
   814     return ret;
   853     }
   815     }
       
   816 	
   854 EXPORT_C TInt RSCPClient :: PerformCleanupL(RArray<TUid>& aAppIDs) {
   817 EXPORT_C TInt RSCPClient :: PerformCleanupL(RArray<TUid>& aAppIDs) {
   855     Dprint((_L("RSCPClient::PerformCleanupL() >>>")));
   818     Dprint((_L("RSCPClient::PerformCleanupL() >>>")));
       
   819 	
   856     TInt lCount = aAppIDs.Count();
   820     TInt lCount = aAppIDs.Count();
   857     
   821     
   858     if(lCount < 1) {
   822     if(lCount < 1) {
   859         return KErrNone; 
   823         return KErrNone; 
   860     }
   824     }
   872     TInt lStatus = SendReceive(ESCPApplicationUninstalled, TIpcArgs(ESCPApplicationUninstalled, &lBuff->Des()));
   836     TInt lStatus = SendReceive(ESCPApplicationUninstalled, TIpcArgs(ESCPApplicationUninstalled, &lBuff->Des()));
   873     CleanupStack :: PopAndDestroy(2); // lBuff, lWriteStream
   837     CleanupStack :: PopAndDestroy(2); // lBuff, lWriteStream
   874     Dprint((_L("RSCPClient::PerformCleanupL() <<<")));
   838     Dprint((_L("RSCPClient::PerformCleanupL() <<<")));
   875     return lStatus;
   839     return lStatus;
   876 }
   840 }
       
   841 
   877 // ---------------------------------------------------------
   842 // ---------------------------------------------------------
   878 // The server contains all the logic for the parameters, just
   843 // The server contains all the logic for the parameters, just
   879 // propagate the call.
   844 // propagate the call.
   880 //
   845 //
   881 // ---------------------------------------------------------
   846 // ---------------------------------------------------------
   994                                  ecSupport) );
   959                                  ecSupport) );
   995     
   960     
   996         if ( ( ret ) && ( ret != ESecUiEmergencyCall ) && ( err == KErrNone ) )
   961         if ( ( ret ) && ( ret != ESecUiEmergencyCall ) && ( err == KErrNone ) )
   997             {
   962             {
   998             verifyCodeBuffer.Zero();
   963             verifyCodeBuffer.Zero();
       
   964 			
   999             /*TChar ch = static_cast<TChar>(newCodeBuffer[0]);
   965             /*TChar ch = static_cast<TChar>(newCodeBuffer[0]);
  1000 
   966 
  1001             CSCPQueryDialog :: TKeypadContext lKPContext =
   967             CSCPQueryDialog :: TKeypadContext lKPContext =
  1002                     (ch.IsDigit() ? CSCPQueryDialog :: ENumeric : CSCPQueryDialog :: EAlphaNumeric);*/
   968                     (ch.IsDigit() ? CSCPQueryDialog :: ENumeric : CSCPQueryDialog :: EAlphaNumeric);*/
  1003                     
   969                     
  1342     if(lRet != KErrNone) {
  1308     if(lRet != KErrNone) {
  1343         Dprint(_L("[RSCPClient]-> ERROR: Unable to perform get on CenRep, lErr=%d"), lRet);
  1309         Dprint(_L("[RSCPClient]-> ERROR: Unable to perform get on CenRep, lErr=%d"), lRet);
  1344         CleanupStack :: PopAndDestroy(lRepository);
  1310         CleanupStack :: PopAndDestroy(lRepository);
  1345         return lRet;
  1311         return lRet;
  1346     }
  1312     }
  1347     TInt currentLawmoState(0); 
  1313 
  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         }
       
  1358     HBufC* codeHBuf = HBufC :: NewLC(KSCPPasscodeMaxLength + 1);
  1314     HBufC* codeHBuf = HBufC :: NewLC(KSCPPasscodeMaxLength + 1);
  1359     HBufC8* addParamsHBuf = HBufC8 :: NewLC(KSCPMaxTARMNotifParamLen);
  1315     HBufC8* addParamsHBuf = HBufC8 :: NewLC(KSCPMaxTARMNotifParamLen);
  1360     TPtr codeBuffer = codeHBuf->Des();
  1316     TPtr codeBuffer = codeHBuf->Des();
  1361     TPtr8 addParams = addParamsHBuf->Des();
  1317     TPtr8 addParams = addParamsHBuf->Des();
  1362     if(currentLawmoState!=KLockedbyLawmo)
  1318 
  1363         {
  1319     if(lDefCode == 0) {
  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) {
       
  1396         Dprint(_L("[RSCPClient]-> INFO: Default lock code has been set already by the user..."));
  1320         Dprint(_L("[RSCPClient]-> INFO: Default lock code has been set already by the user..."));
  1397 
  1321 
  1398         lRet = RunDialogL(codeBuffer, aButtonsShown, KSCPPasscodeMinLength, KSCPPasscodeMaxLength,
  1322         lRet = RunDialogL(codeBuffer, aButtonsShown, KSCPPasscodeMinLength, KSCPPasscodeMaxLength,
  1399                 R_SECUI_TEXT_ENTER_SEC_CODE, NULL, aECSSupport);
  1323                 R_SECUI_TEXT_ENTER_SEC_CODE, NULL, aECSSupport);
  1400 
  1324 
  1526         }
  1450         }
  1527 
  1451 
  1528         CleanupStack :: PopAndDestroy(tmp);
  1452         CleanupStack :: PopAndDestroy(tmp);
  1529     }
  1453     }
  1530 
  1454 
  1531     CleanupStack :: PopAndDestroy(4); // repository * 2, addParamsHBuf, codeHBuf 
  1455     CleanupStack :: PopAndDestroy(3); // repository, addParamsHBuf, codeHBuf
  1532     Dprint(_L("[RSCPClient]-> SetSecurityCodeL() <<< lRet=%d"), lRet);
  1456     Dprint(_L("[RSCPClient]-> SetSecurityCodeL() <<< lRet=%d"), lRet);
  1533     return lRet;
  1457     return lRet;
  1534 }
  1458 }
  1535 
  1459 
  1536 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS
  1460 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS