1278 #endif // __SCP_DEBUG |
1277 #endif // __SCP_DEBUG |
1279 |
1278 |
1280 TInt lRetStatus(KErrNone); |
1279 TInt lRetStatus(KErrNone); |
1281 Dprint(_L("[CSCPServer]-> Initiating branching on parameter...")); |
1280 Dprint(_L("[CSCPServer]-> Initiating branching on parameter...")); |
1282 |
1281 |
1283 switch(aID) { |
1282 switch ( aID ) |
1284 case ESCPAutolockPeriod: |
1283 { |
1285 case ESCPMaxAutolockPeriod: { |
1284 case ( ESCPAutolockPeriod ): |
|
1285 // Flow through |
|
1286 case ( ESCPMaxAutolockPeriod ): |
|
1287 { |
1286 // Convert the value, and set it |
1288 // Convert the value, and set it |
1287 TInt value; |
1289 TInt value; |
1288 TLex lex(aValue); |
1290 TLex lex(aValue); |
1289 lRetStatus = lex.Val(value); |
1291 lRetStatus = lex.Val(value); |
|
1292 |
1290 |
1293 |
1291 if((lRetStatus != KErrNone ) || ( value < 0) || ( value > KSCPAutolockPeriodMaximum )) { |
1294 if((lRetStatus != KErrNone ) || ( value < 0) || ( value > KSCPAutolockPeriodMaximum )) { |
1292 lRetStatus = KErrArgument; |
1295 lRetStatus = KErrArgument; |
1293 break; |
1296 break; |
1294 } |
1297 } |
1295 |
1298 |
1296 //Check if the device memory is encrypted or not. |
1299 //Check if the device memory is encrypted or not. |
1297 TBool encryptionEnabled = IsDeviceMemoryEncrypted(); |
1300 TBool encryptionEnabled = IsDeviceMemoryEncrypted(); |
1298 CSCPParamDBController* lParamDB = CSCPParamDBController :: NewLC(); |
|
1299 |
1301 |
1300 // Value OK |
1302 // Value OK |
1301 if(aID == ESCPMaxAutolockPeriod) { |
1303 if(aID == ESCPMaxAutolockPeriod) |
1302 if( encryptionEnabled ) { |
1304 { |
1303 Dprint(_L("[CSCPServer]-> Memory is encrypted")); |
1305 if ( encryptionEnabled ) |
|
1306 { |
|
1307 Dprint(_L("Memory is encrypted")); |
|
1308 if (( 0 == value) || value > KMaxAutolockPeriod) |
|
1309 { |
|
1310 Dprint((_L("Denying setting of max auto lock as value is %d"), value)); |
|
1311 User::Leave( KErrPermissionDenied ); |
|
1312 } |
|
1313 |
|
1314 } |
|
1315 else |
|
1316 { |
|
1317 Dprint(_L("Memory is decrypted, hence no restrictions to max autolock")); |
|
1318 } |
1304 |
1319 |
1305 if(( 0 == value) || value > KMaxAutolockPeriod) { |
1320 Dprint(_L("[CSCPServer]-> Branched to ESCPMaxAutolockPeriod...")); |
1306 Dprint((_L("[CSCPServer]-> Denying setting of max auto lock as value is %d"), value)); |
1321 CSCPParamDBController* lParamDB = CSCPParamDBController :: NewLC(); |
1307 User :: Leave( KErrPermissionDenied ); |
|
1308 } |
|
1309 } |
|
1310 else { |
|
1311 Dprint(_L("Memory is decrypted, hence no restrictions to max autolock")); |
|
1312 } |
|
1313 |
|
1314 Dprint(_L("[CSCPServer]-> Branched to ESCPMaxAutolockPeriod...")); |
|
1315 lRetStatus = SetBestPolicyL(RTerminalControl3rdPartySession :: EMaxTimeout, aValue, aCallerIdentity, lParamDB); |
1322 lRetStatus = SetBestPolicyL(RTerminalControl3rdPartySession :: EMaxTimeout, aValue, aCallerIdentity, lParamDB); |
1316 |
1323 |
1317 if(lRetStatus == KErrNone) { |
1324 if(lRetStatus == KErrNone) |
|
1325 { |
1318 // Do we have to change the Autolock period as well? |
1326 // Do we have to change the Autolock period as well? |
1319 TInt currentALperiod; |
1327 TInt currentALperiod; |
1320 lRetStatus = GetAutolockPeriodL(currentALperiod); |
1328 lRetStatus = GetAutolockPeriodL(currentALperiod); |
1321 |
1329 |
1322 if(lRetStatus == KErrNone) { |
1330 if(lRetStatus == KErrNone) |
1323 if( (iConfiguration.iMaxTimeout > 0) && |
1331 { |
1324 ((iConfiguration.iMaxTimeout < currentALperiod) || |
1332 if((iConfiguration.iMaxTimeout > 0) && ((iConfiguration.iMaxTimeout < currentALperiod) || (currentALperiod == 0))) |
1325 (currentALperiod == 0))) { |
1333 { |
1326 |
|
1327 Dprint((_L("[CSCPServer]-> Changing AL period to Max. AL period (Current ALP: %d, Max. ALP: %d)"), currentALperiod, value)); |
1334 Dprint((_L("[CSCPServer]-> Changing AL period to Max. AL period (Current ALP: %d, Max. ALP: %d)"), currentALperiod, value)); |
1328 //lRetStatus = SetAutolockPeriodL(value); |
1335 lRetStatus = SetAutolockPeriodL(value); |
1329 /* |
|
1330 * Call to SetBestPolicyL will not check for Stronger/Weaker. The value of ETimeout just gets stored in |
|
1331 * both the internal DB and the CenRep |
|
1332 */ |
|
1333 lRetStatus = SetBestPolicyL(RTerminalControl3rdPartySession :: ETimeout, aValue, aCallerIdentity, lParamDB); |
|
1334 } |
1336 } |
1335 } |
1337 } |
1336 else { |
1338 else |
|
1339 { |
1337 Dprint((_L("[CSCPServer]-> ERROR: Couldn't get the Autolock period: %d"), lRetStatus)); |
1340 Dprint((_L("[CSCPServer]-> ERROR: Couldn't get the Autolock period: %d"), lRetStatus)); |
1338 } |
1341 } |
1339 } |
1342 } |
1340 } |
1343 |
1341 // Autolock Period |
1344 CleanupStack :: PopAndDestroy(); //lParamDB |
1342 else { |
1345 } |
1343 //Code is commented as it is already taken care by the below condition #1343 irrespective of the drive encryption state. |
1346 |
1344 /* if ( 0 == value ) { |
1347 else |
1345 if(encryptionEnabled) { |
1348 { // Autolock Period |
|
1349 |
|
1350 //Code is commented as it is already taken care by the below condition #1343 irrespective of the drive encryption state. |
|
1351 /* if ( 0 == value ) |
|
1352 { |
|
1353 if ( encryptionEnabled ) |
|
1354 { |
1346 Dprint(_L("Permission denied!")); |
1355 Dprint(_L("Permission denied!")); |
1347 User :: Leave(KErrPermissionDenied); |
1356 User::Leave( KErrPermissionDenied ); |
1348 } |
1357 } |
1349 }*/ |
1358 }*/ |
1350 |
1359 |
1351 Dprint(_L("[CSCPServer]-> Branched to ESCPAutolockPeriod...")); |
1360 Dprint(_L("[CSCPServer]-> Branched to ESCPAutolockPeriod...")); |
1352 // Check if this value is not allowed by the Max. Autolock period |
1361 // Check if this value is not allowed by the Max. Autolock period |
1353 if ((iConfiguration.iMaxTimeout > 0) && ((iConfiguration.iMaxTimeout < value) || (value == 0))) { |
1362 if ((iConfiguration.iMaxTimeout > 0) && ((iConfiguration.iMaxTimeout < value) || (value == 0))) { |
1354 Dprint((_L("[CSCPServer]-> ERROR: The value %d for AL period not allowed (Max. AL period: %d)"), value, iConfiguration.iMaxTimeout)); |
1363 Dprint((_L("[CSCPServer]-> ERROR: The value %d for AL period not allowed (Max. AL period: %d)"), value, iConfiguration.iMaxTimeout)); |
1355 |
1364 |
1356 lRetStatus = KErrArgument; |
1365 lRetStatus = KErrArgument; |
1357 } |
1366 } |
1358 else { |
1367 else { |
1359 //lRetStatus = SetAutolockPeriodL(value); |
1368 lRetStatus = SetAutolockPeriodL(value); |
1360 /* |
|
1361 * Call to SetBestPolicyL will not check for Stronger/Weaker. The value of ETimeout just gets stored in |
|
1362 * both the internal DB and the CenRep |
|
1363 */ |
|
1364 lRetStatus = SetBestPolicyL(RTerminalControl3rdPartySession :: ETimeout, aValue, aCallerIdentity, lParamDB); |
|
1365 |
1369 |
1366 if(lRetStatus != KErrNone) { |
1370 if(lRetStatus != KErrNone) { |
1367 Dprint((_L("[CSCPServer]-> ERROR: Couldn't set the Autolock period: %d"), lRetStatus)); |
1371 Dprint((_L("[CSCPServer]-> ERROR: Couldn't set the Autolock period: %d"), lRetStatus)); |
1368 } |
1372 } |
1369 } |
1373 } |
1370 } |
1374 } |
1371 |
|
1372 CleanupStack :: PopAndDestroy(); //lParamDB |
|
1373 } |
1375 } |
1374 break; |
1376 break; |
1375 case ESCPCodeChangePolicy: |
1377 case ESCPCodeChangePolicy: |
1376 Dprint(_L("[CSCPServer]-> Branched to ESCPCodeChangePolicy...")); |
1378 Dprint(_L("[CSCPServer]-> Branched to ESCPCodeChangePolicy...")); |
1377 lRetStatus = ChangeCodePolicy( aValue ); |
1379 lRetStatus = ChangeCodePolicy( aValue ); |
2770 * from iPluginEventHandler->GetParameters() fails. |
2762 * from iPluginEventHandler->GetParameters() fails. |
2771 * (WriteToFileL() is called in some destructor when the SCPServer terminates) |
2763 * (WriteToFileL() is called in some destructor when the SCPServer terminates) |
2772 */ |
2764 */ |
2773 if (lRetStatus == KErrNone) { |
2765 if (lRetStatus == KErrNone) { |
2774 switch (aID) { |
2766 switch (aID) { |
2775 case RTerminalControl3rdPartySession :: ETimeout: |
|
2776 lRetStatus = SetAutolockPeriodL(TInt(lNumValue)); |
|
2777 Dprint(_L("[CSCPServer]-> After setting ETimeout lRetStatus = %d "), lRetStatus); |
|
2778 break; |
|
2779 |
|
2780 case RTerminalControl3rdPartySession :: EMaxTimeout: |
2767 case RTerminalControl3rdPartySession :: EMaxTimeout: |
2781 iConfiguration.iMaxTimeout = lNumValue; |
2768 iConfiguration.iMaxTimeout = lNumValue; |
2782 lRetStatus = iConfiguration.WriteSetupL(); |
2769 lRetStatus = iConfiguration.WriteSetupL(); |
2783 Dprint(_L("[CSCPServer]-> After setting EMaxTimeout lRetStatus = %d "), lRetStatus); |
2770 Dprint(_L("[CSCPServer]-> After setting EMaxTimeout lRetStatus = %d "), lRetStatus); |
2784 break; |
2771 break; |
2785 |
|
2786 default: |
2772 default: |
2787 TUint16* ptr = const_cast<TUint16*>(aValue.Ptr()); |
2773 TUint16* ptr = const_cast<TUint16*>(aValue.Ptr()); |
2788 TPtr valBuf(ptr, aValue.Length(), aValue.Length()); |
2774 TPtr valBuf(ptr, aValue.Length(), aValue.Length()); |
2789 lRetStatus = iPluginEventHandler->GetParameters().Set(aID, valBuf); |
2775 lRetStatus = iPluginEventHandler->GetParameters().Set(aID, valBuf); |
2790 Dprint(_L("[CSCPServer]-> After setting (%d ) lRetStatus = %d "), aID, lRetStatus); |
2776 Dprint(_L("[CSCPServer]-> After setting (%d ) lRetStatus = %d "), aID, lRetStatus); |
2875 lParamIds[lMinTolIndex] = RTerminalControl3rdPartySession :: EPasscodeHistoryBuffer; |
2861 lParamIds[lMinTolIndex] = RTerminalControl3rdPartySession :: EPasscodeHistoryBuffer; |
2876 Dprint(_L("[CSCPServer]-> Switching the cleanup order of EPasscodeHistoryBuffer and EPasscodeMinChangeTolerance")); |
2862 Dprint(_L("[CSCPServer]-> Switching the cleanup order of EPasscodeHistoryBuffer and EPasscodeMinChangeTolerance")); |
2877 Dprint(_L("[CSCPServer]-> Old Index of EPasscodeHistoryBuffer=%d"), lHistBuffIndex); |
2863 Dprint(_L("[CSCPServer]-> Old Index of EPasscodeHistoryBuffer=%d"), lHistBuffIndex); |
2878 Dprint(_L("[CSCPServer]-> Old Index of EPasscodeMinChangeTolerance=%d"), lMinTolIndex); |
2864 Dprint(_L("[CSCPServer]-> Old Index of EPasscodeMinChangeTolerance=%d"), lMinTolIndex); |
2879 } |
2865 } |
2880 |
|
2881 /* |
|
2882 * If both ETimeout and EMaxTimeout are marked for cleanup then interchange the cleanup order of |
|
2883 * ETimeout and EMaxTimeout since AutoLock (ETimeout) cannot be disabled |
|
2884 * if MaxAutolock (EMaxTimeout) is still enabled |
|
2885 */ |
|
2886 if( lParamIds[0] == RTerminalControl3rdPartySession :: ETimeout && |
|
2887 lParamIds[1] == RTerminalControl3rdPartySession :: EMaxTimeout) { |
|
2888 |
|
2889 lParamIds[0] = RTerminalControl3rdPartySession :: EMaxTimeout; |
|
2890 lParamIds[1] = RTerminalControl3rdPartySession :: ETimeout; |
|
2891 } |
|
2892 } |
2866 } |
2893 |
2867 |
2894 for(TInt j=0; j < lCount; j++) { |
2868 for(TInt j=0; j < lCount; j++) { |
2895 TInt lCurrParamID = lParamIds[j]; |
2869 TInt lCurrParamID = lParamIds[j]; |
2896 lDefValueBuf->Des().Zero(); |
2870 lDefValueBuf->Des().Zero(); |
2897 lDefValueBuf->Des().Format(_L("%d "), 0); |
2871 lDefValueBuf->Des().Format(_L("%d "), 0); |
2898 |
|
2899 // Initialize the default values here... |
2872 // Initialize the default values here... |
2900 switch(lCurrParamID) { |
2873 switch(lCurrParamID) { |
2901 case RTerminalControl3rdPartySession :: ETimeout: |
|
2902 // lDefValueBuf already has the default value, 0 initialized... |
|
2903 lCurrParamID = ESCPAutolockPeriod; |
|
2904 break; |
|
2905 case RTerminalControl3rdPartySession :: EMaxTimeout: |
2874 case RTerminalControl3rdPartySession :: EMaxTimeout: |
2906 // lDefValueBuf already has the default value, 0 initialized... |
2875 // lDefValueBuf already has the default value, 0 initialized... |
2907 lCurrParamID = ESCPMaxAutolockPeriod; |
2876 lCurrParamID = ESCPMaxAutolockPeriod; |
2908 break; |
2877 break; |
2909 case RTerminalControl3rdPartySession :: EPasscodeMinLength: |
2878 case RTerminalControl3rdPartySession :: EPasscodeMinLength: |
2942 |
2910 |
2943 lDesArr.ResetAndDestroy(); |
2911 lDesArr.ResetAndDestroy(); |
2944 CleanupStack :: PopAndDestroy(1); // lDesArray |
2912 CleanupStack :: PopAndDestroy(1); // lDesArray |
2945 } |
2913 } |
2946 break; |
2914 break; |
2947 |
|
2948 case ESCPAutolockPeriod: { |
|
2949 TInt32 lParamValueDB(0); |
|
2950 TInt lParamValueCenRep(0); |
|
2951 TInt32 lCurrParamOwner(0); |
|
2952 |
|
2953 lStatus = lParamDB->GetValueL(RTerminalControl3rdPartySession :: ETimeout, lParamValueDB, lCurrParamOwner); |
|
2954 |
|
2955 if(lStatus != KErrNone) { |
|
2956 Dprint(_L("[CSCPServer]-> ERROR: Unable to get current value of ETimeout from DB...")); |
|
2957 lSubOpsFailed = ETrue; |
|
2958 break; |
|
2959 } |
|
2960 |
|
2961 lStatus = GetAutolockPeriodL(lParamValueCenRep); |
|
2962 |
|
2963 if(lStatus != KErrNone) { |
|
2964 Dprint(_L("[CSCPServer]-> ERROR: Unable to get current value of ETimeout from CenRep...")); |
|
2965 lSubOpsFailed = ETrue; |
|
2966 break; |
|
2967 } |
|
2968 |
|
2969 /* |
|
2970 * It is possible that AutoLock set from UI is different. In that case internal DB and CenRep |
|
2971 * are not in sync. Compare the two values and if they are same assume that the values are in sync. |
|
2972 * Limitation is that if the user sets the AutoLock with the same value as set by the current app then |
|
2973 * AutoLock will get disabled. |
|
2974 * |
|
2975 */ |
|
2976 if(lParamValueCenRep != lParamValueDB) { |
|
2977 break; |
|
2978 } |
|
2979 } |
|
2980 |
|
2981 default: { |
2915 default: { |
2982 iOverrideForCleanup = ETrue; |
2916 iOverrideForCleanup = ETrue; |
2983 TRAP(lStatus, lStatus = SetParameterValueL(lCurrParamID, lDefValueBuf->Des(), lAppID)); |
2917 TRAP(lStatus, lStatus = SetParameterValueL(lCurrParamID, lDefValueBuf->Des(), lAppID)); |
2984 iOverrideForCleanup = EFalse; |
2918 iOverrideForCleanup = EFalse; |
2985 |
2919 |