1196 } |
1196 } |
1197 TInt RSCPClient :: SetSecurityCodeL(RMobilePhone :: TMobilePassword& aPassword, |
1197 TInt RSCPClient :: SetSecurityCodeL(RMobilePhone :: TMobilePassword& aPassword, |
1198 TSCPButtonConfig aButtonsShown, TBool aECSSupport, TInt aFlags, TInt& aResFileSCP, TInt& aResFileSecUi) { |
1198 TSCPButtonConfig aButtonsShown, TBool aECSSupport, TInt aFlags, TInt& aResFileSCP, TInt& aResFileSecUi) { |
1199 Dprint((_L("[RSCPClient]-> SetSecurityCodeL() >>>"))); |
1199 Dprint((_L("[RSCPClient]-> SetSecurityCodeL() >>>"))); |
1200 Dprint((_L("[RSCPClient]-> input params - aButtonsShown=%d, aECSSupport=%d"), aButtonsShown, aECSSupport)); |
1200 Dprint((_L("[RSCPClient]-> input params - aButtonsShown=%d, aECSSupport=%d"), aButtonsShown, aECSSupport)); |
1201 |
1201 |
1202 if(EFalse == isFlagEnabled) { |
1202 if(EFalse == isFlagEnabled) { |
1203 (void)aPassword; |
1203 (void)aPassword; |
1204 Dprint((_L("[RSCPClient]-> ERROR: Function not supported in this variant"))); |
1204 Dprint((_L("[RSCPClient]-> ERROR: Function not supported in this variant"))); |
1205 User :: Invariant(); |
1205 User :: Invariant(); |
1206 return KErrNotSupported; |
1206 return KErrNotSupported; |
1207 } |
1207 } |
|
1208 |
1208 TInt lRet = LoadResources(aResFileSCP, aResFileSecUi); |
1209 TInt lRet = LoadResources(aResFileSCP, aResFileSecUi); |
|
1210 |
1209 if(lRet != KErrNone) { |
1211 if(lRet != KErrNone) { |
1210 return lRet; |
1212 return lRet; |
1211 } |
1213 } |
|
1214 |
1212 TInt lDefCode = 0; |
1215 TInt lDefCode = 0; |
1213 CRepository* lRepository = CRepository :: NewLC(KCRUidSCPLockCode); |
1216 CRepository* lRepository = CRepository :: NewLC(KCRUidSCPLockCode); |
1214 lRet = lRepository->Get(KSCPLockCodeDefaultLockCode, lDefCode); |
1217 lRet = lRepository->Get(KSCPLockCodeDefaultLockCode, lDefCode); |
|
1218 |
1215 if(lRet != KErrNone) { |
1219 if(lRet != KErrNone) { |
1216 Dprint(_L("[RSCPClient]-> ERROR: Unable to perform get on CenRep, lErr=%d"), lRet); |
1220 Dprint(_L("[RSCPClient]-> ERROR: Unable to perform get on CenRep, lErr=%d"), lRet); |
1217 CleanupStack :: PopAndDestroy(lRepository); |
1221 CleanupStack :: PopAndDestroy(lRepository); |
1218 return lRet; |
1222 return lRet; |
1219 } |
1223 } |
|
1224 |
1220 HBufC* codeHBuf = HBufC :: NewLC(KSCPPasscodeMaxLength + 1); |
1225 HBufC* codeHBuf = HBufC :: NewLC(KSCPPasscodeMaxLength + 1); |
1221 HBufC8* addParamsHBuf = HBufC8 :: NewLC(KSCPMaxTARMNotifParamLen); |
1226 HBufC8* addParamsHBuf = HBufC8 :: NewLC(KSCPMaxTARMNotifParamLen); |
1222 TPtr codeBuffer = codeHBuf->Des(); |
1227 TPtr codeBuffer = codeHBuf->Des(); |
1223 TPtr8 addParams = addParamsHBuf->Des(); |
1228 TPtr8 addParams = addParamsHBuf->Des(); |
|
1229 |
1224 if(lDefCode == 0) { |
1230 if(lDefCode == 0) { |
1225 Dprint(_L("[RSCPClient]-> INFO: Default lock code has been set already by the user...")); |
1231 Dprint(_L("[RSCPClient]-> INFO: Default lock code has been set already by the user...")); |
|
1232 |
1226 lRet = RunDialogL(codeBuffer, aButtonsShown, KSCPPasscodeMinLength, KSCPPasscodeMaxLength, |
1233 lRet = RunDialogL(codeBuffer, aButtonsShown, KSCPPasscodeMinLength, KSCPPasscodeMaxLength, |
1227 R_SECUI_TEXT_ENTER_SEC_CODE, NULL, aECSSupport); |
1234 R_SECUI_TEXT_ENTER_SEC_CODE, NULL, aECSSupport); |
|
1235 |
1228 if((lRet) && (lRet != ESecUiEmergencyCall) && (lRet != EAknSoftkeyEmergencyCall)) { |
1236 if((lRet) && (lRet != ESecUiEmergencyCall) && (lRet != EAknSoftkeyEmergencyCall)) { |
1229 Dprint(_L("[RSCPClient]-> INFO: User has updated the lock code...")); |
1237 Dprint(_L("[RSCPClient]-> INFO: User has updated the lock code...")); |
|
1238 |
1230 lRet = SendReceive( ESCPServAuthenticateS60, TIpcArgs( &codeBuffer, &aPassword, &addParams, aFlags)); |
1239 lRet = SendReceive( ESCPServAuthenticateS60, TIpcArgs( &codeBuffer, &aPassword, &addParams, aFlags)); |
|
1240 |
1231 Dprint((_L("[RSCPClient]-> INFO: addParams.Length()=%d")), addParams.Length()); |
1241 Dprint((_L("[RSCPClient]-> INFO: addParams.Length()=%d")), addParams.Length()); |
1232 Dprint((_L("[RSCPClient]-> INFO: lRet=%d")), lRet); |
1242 Dprint((_L("[RSCPClient]-> INFO: lRet=%d")), lRet); |
1233 } |
1243 } |
1234 else { |
1244 else { |
1235 switch(lRet) { |
1245 switch(lRet) { |
1236 case 0: |
1246 case 0: |
|
1247 lRet = KErrCancel; |
|
1248 break; |
1237 case EAknSoftkeyEmergencyCall: |
1249 case EAknSoftkeyEmergencyCall: |
1238 //lRet = KErrCancel; |
1250 //lRet = KErrCancel; |
1239 break; |
1251 break; |
1240 case ESecUiEmergencyCall: |
1252 case ESecUiEmergencyCall: |
1241 lRet = ESecUiEmergencyCall; |
1253 lRet = ESecUiEmergencyCall; |
1249 TRequestStatus statusSave; |
1261 TRequestStatus statusSave; |
1250 Dprint(_L("[RSCPClient]-> INFO: Default lock code not set by the user, requesting for the same")); |
1262 Dprint(_L("[RSCPClient]-> INFO: Default lock code not set by the user, requesting for the same")); |
1251 |
1263 |
1252 HBufC* msgConfirmSave = NULL; |
1264 HBufC* msgConfirmSave = NULL; |
1253 CAknGlobalConfirmationQuery* query = CAknGlobalConfirmationQuery :: NewLC(); |
1265 CAknGlobalConfirmationQuery* query = CAknGlobalConfirmationQuery :: NewLC(); |
1254 |
1266 |
1255 if(aButtonsShown == SCP_OK || aButtonsShown == SCP_OK_ETEL) { |
1267 if(aButtonsShown == SCP_OK || aButtonsShown == SCP_OK_ETEL) { |
1256 //msgConfirmSave = CEikonEnv :: Static()->AllocReadResourceLC(R_SET_SEC_CODE_STARTUP_QUERY); |
1268 //msgConfirmSave = CEikonEnv :: Static()->AllocReadResourceLC(R_SET_SEC_CODE_STARTUP_QUERY); |
1257 msgConfirmSave = CEikonEnv :: Static()->AllocReadResourceLC(R_SET_SEC_CODE); |
1269 msgConfirmSave = CEikonEnv :: Static()->AllocReadResourceLC(R_SET_SEC_CODE); |
1258 query->ShowConfirmationQueryL(statusSave, *msgConfirmSave, R_AVKON_SOFTKEYS_OK_EMPTY__OK, R_QGN_NOTE_INFO_ANIM); |
1270 query->ShowConfirmationQueryL(statusSave, *msgConfirmSave, R_AVKON_SOFTKEYS_OK_EMPTY__OK, R_QGN_NOTE_INFO_ANIM); |
1259 } |
1271 } |
1260 else { |
1272 else { |
1261 msgConfirmSave = CEikonEnv :: Static()->AllocReadResourceLC(R_SET_SEC_CODE); |
1273 msgConfirmSave = CEikonEnv :: Static()->AllocReadResourceLC(R_SET_SEC_CODE); |
1262 query->ShowConfirmationQueryL(statusSave, *msgConfirmSave, R_AVKON_SOFTKEYS_YES_NO__YES, R_QGN_NOTE_QUERY_ANIM); |
1274 query->ShowConfirmationQueryL(statusSave, *msgConfirmSave, R_AVKON_SOFTKEYS_YES_NO__YES, R_QGN_NOTE_QUERY_ANIM); |
1263 } |
1275 } |
1264 |
1276 |
1265 User :: WaitForRequest(statusSave); |
1277 User :: WaitForRequest(statusSave); |
1266 CleanupStack :: PopAndDestroy(2); // msgConfirmSave query |
1278 CleanupStack :: PopAndDestroy(2); // msgConfirmSave query |
1267 |
1279 |
1268 if((statusSave == EAknSoftkeyYes) || (statusSave == EAknSoftkeyOk)) { |
1280 if((statusSave == EAknSoftkeyYes) || (statusSave == EAknSoftkeyOk)) { |
1269 Dprint(_L("[RSCPClient]-> INFO: calling GetNewCodeAndChange() ...")); |
1281 Dprint(_L("[RSCPClient]-> INFO: calling GetNewCodeAndChange() ...")); |
1270 |
1282 |
1271 TBufC<10> NBuf(KSCPDefaultEnchSecCode); |
1283 TBufC<10> NBuf(KSCPDefaultEnchSecCode); |
1272 TPtr codeBuf = NBuf.Des(); |
1284 TPtr codeBuf = NBuf.Des(); |
1273 |
1285 |
1274 TSCPSecCode lNewSecCode; |
1286 TSCPSecCode lNewSecCode; |
1275 TInt lButtonCfg = (aButtonsShown == SCP_OK || aButtonsShown == SCP_OK_ETEL) ? KSCPForcedChange : KSCPNormalChange; |
1287 TInt lButtonCfg = (aButtonsShown == SCP_OK || aButtonsShown == SCP_OK_ETEL) ? KSCPForcedChange : KSCPNormalChange; |
1276 HBufC* lNewLkCodeBuf = NULL; |
1288 HBufC* lNewLkCodeBuf = NULL; |
1277 lRet = GetNewCodeAndChange(codeBuf, lButtonCfg, &lNewSecCode, &lNewLkCodeBuf); |
1289 lRet = GetNewCodeAndChange(codeBuf, lButtonCfg, &lNewSecCode, &lNewLkCodeBuf); |
1278 |
1290 |
1279 Dprint(_L("[RSCPClient]-> INFO: GetNewCodeAndChange() complete, err=%d"), lRet); |
1291 Dprint(_L("[RSCPClient]-> INFO: GetNewCodeAndChange() complete, err=%d"), lRet); |
1280 |
1292 |
1281 if(KErrNone == lRet) { |
1293 if(KErrNone == lRet) { |
1282 /* This is being called as a workaround for a freezing issue with SecUI. This is in place |
1294 /* This is being called as a workaround for a freezing issue with SecUI. This is in place |
1283 * as a temporary measure until the source is identified. |
1295 * as a temporary measure until the source is identified. |
1284 */ |
1296 */ |
1285 TInt lTmpRet = SendReceive(ESCPServAuthenticateS60, TIpcArgs(&lNewLkCodeBuf->Des(), &aPassword, &addParams, aFlags)); |
1297 TInt lTmpRet = SendReceive(ESCPServAuthenticateS60, TIpcArgs(&lNewLkCodeBuf->Des(), &aPassword, &addParams, aFlags)); |
1286 |
1298 |
1287 Dprint(_L("[RSCPClient]-> INFO: lTmpRet from SendReceive()=%d"), lTmpRet); |
1299 Dprint(_L("[RSCPClient]-> INFO: lTmpRet from SendReceive()=%d"), lTmpRet); |
1288 if(KErrNone == lRet) { |
1300 if(KErrNone == lRet) { |
1289 Dprint(_L("[RSCPClient]-> INFO: updating CenRep ...")); |
1301 Dprint(_L("[RSCPClient]-> INFO: updating CenRep ...")); |
1290 lRepository->Set(KSCPLockCodeDefaultLockCode, 0); |
1302 lRepository->Set(KSCPLockCodeDefaultLockCode, 0); |
1291 Dprint(_L("[RSCPClient]-> INFO: User updated lock code for the first time...err= %d"), lRet); |
1303 Dprint(_L("[RSCPClient]-> INFO: User updated lock code for the first time...err= %d"), lRet); |
1292 } |
1304 } |
1293 } |
1305 } |
1294 |
1306 |
1295 if(lNewLkCodeBuf) { |
1307 if(lNewLkCodeBuf) { |
1296 delete lNewLkCodeBuf; |
1308 delete lNewLkCodeBuf; |
1297 } |
1309 } |
1298 } |
1310 } |
1299 else { |
1311 else { |
1300 Dprint(_L("[RSCPClient]-> INFO: Returning KErrCancel")); |
1312 Dprint(_L("[RSCPClient]-> INFO: Returning KErrCancel")); |
1301 lRet = KErrCancel; |
1313 lRet = KErrCancel; |
1302 } |
1314 } |
1303 |
1315 |
1304 if(KErrAbort == lRet) { |
1316 if(KErrAbort == lRet) { |
1305 Dprint(_L("[RSCPClient]-> INFO: Returning KErrCancel")); |
1317 Dprint(_L("[RSCPClient]-> INFO: Returning KErrCancel")); |
1306 lRet = KErrCancel; |
1318 lRet = KErrCancel; |
1307 } |
1319 } |
1308 |
1320 |
1309 } |
1321 } |
1310 |
1322 |
1311 if(addParams.Length() > 0) { |
1323 if(addParams.Length() > 0) { |
1312 CSCPParamObject* tmp = CSCPParamObject :: NewLC(); |
1324 CSCPParamObject* tmp = CSCPParamObject :: NewLC(); |
1313 TInt lTempRet = tmp->Parse(addParams); |
1325 TInt lTempRet = tmp->Parse(addParams); |
1314 |
1326 |
1315 if(lTempRet == KErrNone) { |
1327 if(lTempRet == KErrNone) { |
1316 lTempRet = tmp->Set(KSCPParamPassword, codeBuffer); |
1328 lTempRet = tmp->Set(KSCPParamPassword, codeBuffer); |
1317 } |
1329 } |
1318 |
1330 |
1319 if(lTempRet == KErrNone) { |
1331 if(lTempRet == KErrNone) { |
1320 addParams.Zero(); |
1332 addParams.Zero(); |
1321 HBufC8* tmpBuf; |
1333 HBufC8* tmpBuf; |
1322 lTempRet = tmp->GetBuffer(tmpBuf); |
1334 lTempRet = tmp->GetBuffer(tmpBuf); |
1323 |
1335 |
1324 if(lTempRet == KErrNone) { |
1336 if(lTempRet == KErrNone) { |
1325 addParams.Copy(tmpBuf->Des()); |
1337 addParams.Copy(tmpBuf->Des()); |
1326 delete tmpBuf; |
1338 delete tmpBuf; |
1327 } |
1339 } |
1328 } |
1340 } |
1329 |
1341 |
1330 if(lTempRet == KErrNone) { |
1342 if(lTempRet == KErrNone) { |
1331 CSCPParamObject* outParams = NULL; |
1343 CSCPParamObject* outParams = NULL; |
1332 ProcessServerCommandsL(addParams, &outParams); |
1344 ProcessServerCommandsL(addParams, &outParams); |
1333 |
1345 |
1334 if(outParams != NULL) { |
1346 if(outParams != NULL) { |
1335 TSCPSecCode newSecCode; |
1347 TSCPSecCode newSecCode; |
1336 if(outParams->Get(KSCPParamPassword, newSecCode) == KErrNone) { |
1348 if(outParams->Get(KSCPParamPassword, newSecCode) == KErrNone) { |
1337 Dprint((_L("[RSCPClient]-> INFO: Updating encoded password received from the server into aPassword..."))); |
1349 Dprint((_L("[RSCPClient]-> INFO: Updating encoded password received from the server into aPassword..."))); |
1338 aPassword.Copy(newSecCode); |
1350 aPassword.Copy(newSecCode); |
1339 } |
1351 } |
|
1352 |
1340 delete outParams; |
1353 delete outParams; |
1341 } |
1354 } |
1342 } |
1355 } |
|
1356 |
1343 CleanupStack :: PopAndDestroy(tmp); |
1357 CleanupStack :: PopAndDestroy(tmp); |
1344 } |
1358 } |
|
1359 |
1345 CleanupStack :: PopAndDestroy(3); // repository, addParamsHBuf, codeHBuf |
1360 CleanupStack :: PopAndDestroy(3); // repository, addParamsHBuf, codeHBuf |
1346 Dprint(_L("[RSCPClient]-> SetSecurityCodeL() <<< lRet=%d"), lRet); |
1361 Dprint(_L("[RSCPClient]-> SetSecurityCodeL() <<< lRet=%d"), lRet); |
1347 return lRet; |
1362 return lRet; |
1348 } |
1363 } |
|
1364 |
1349 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
1365 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
1350 // <<-- *********** Device lock new features ************* |
1366 // <<-- *********** Device lock new features ************* |
1351 |
1367 |
1352 |
1368 |
1353 // ================= OTHER EXPORTED FUNCTIONS ============== |
1369 // ================= OTHER EXPORTED FUNCTIONS ============== |