terminalsecurity/SCP/SCPClient/src/SCPClient.cpp
changeset 1 a9c0ce913924
parent 0 b497e44ab2fc
child 2 5594fba90824
--- a/terminalsecurity/SCP/SCPClient/src/SCPClient.cpp	Thu Dec 17 09:07:52 2009 +0200
+++ b/terminalsecurity/SCP/SCPClient/src/SCPClient.cpp	Thu Jan 07 13:15:03 2010 +0200
@@ -1198,42 +1198,54 @@
             TSCPButtonConfig aButtonsShown, TBool aECSSupport, TInt aFlags, TInt& aResFileSCP, TInt& aResFileSecUi) {
     Dprint((_L("[RSCPClient]-> SetSecurityCodeL() >>>")));
     Dprint((_L("[RSCPClient]-> input params - aButtonsShown=%d, aECSSupport=%d"), aButtonsShown, aECSSupport));
-    
+
     if(EFalse == isFlagEnabled) {
         (void)aPassword;
         Dprint((_L("[RSCPClient]-> ERROR: Function not supported in this variant")));
         User :: Invariant();
         return KErrNotSupported;
     }
+
     TInt lRet = LoadResources(aResFileSCP, aResFileSecUi);
+
     if(lRet != KErrNone) {
         return lRet;
     }
+
     TInt lDefCode = 0;
     CRepository* lRepository = CRepository :: NewLC(KCRUidSCPLockCode);
     lRet = lRepository->Get(KSCPLockCodeDefaultLockCode, lDefCode);
+
     if(lRet != KErrNone) {
         Dprint(_L("[RSCPClient]-> ERROR: Unable to perform get on CenRep, lErr=%d"), lRet);
         CleanupStack :: PopAndDestroy(lRepository);
         return lRet;
     }
+
     HBufC* codeHBuf = HBufC :: NewLC(KSCPPasscodeMaxLength + 1);
     HBufC8* addParamsHBuf = HBufC8 :: NewLC(KSCPMaxTARMNotifParamLen);
     TPtr codeBuffer = codeHBuf->Des();
     TPtr8 addParams = addParamsHBuf->Des();
+
     if(lDefCode == 0) {
         Dprint(_L("[RSCPClient]-> INFO: Default lock code has been set already by the user..."));
+
         lRet = RunDialogL(codeBuffer, aButtonsShown, KSCPPasscodeMinLength, KSCPPasscodeMaxLength,
                 R_SECUI_TEXT_ENTER_SEC_CODE, NULL, aECSSupport);
+
         if((lRet) && (lRet != ESecUiEmergencyCall) && (lRet != EAknSoftkeyEmergencyCall)) {
             Dprint(_L("[RSCPClient]-> INFO: User has updated the lock code..."));
+
             lRet = SendReceive( ESCPServAuthenticateS60, TIpcArgs( &codeBuffer, &aPassword, &addParams, aFlags));
+
             Dprint((_L("[RSCPClient]-> INFO: addParams.Length()=%d")), addParams.Length());
             Dprint((_L("[RSCPClient]-> INFO: lRet=%d")), lRet);
         }
         else {
             switch(lRet) {
             case 0:
+				lRet = KErrCancel;
+				break;
             case EAknSoftkeyEmergencyCall:
                 //lRet = KErrCancel;
                 break;
@@ -1251,7 +1263,7 @@
 
         HBufC* msgConfirmSave = NULL;
         CAknGlobalConfirmationQuery* query = CAknGlobalConfirmationQuery :: NewLC();
-        
+
         if(aButtonsShown == SCP_OK || aButtonsShown == SCP_OK_ETEL) {
             //msgConfirmSave = CEikonEnv :: Static()->AllocReadResourceLC(R_SET_SEC_CODE_STARTUP_QUERY);
             msgConfirmSave = CEikonEnv :: Static()->AllocReadResourceLC(R_SET_SEC_CODE);
@@ -1259,31 +1271,31 @@
         }
         else {
             msgConfirmSave = CEikonEnv :: Static()->AllocReadResourceLC(R_SET_SEC_CODE);
-        query->ShowConfirmationQueryL(statusSave, *msgConfirmSave, R_AVKON_SOFTKEYS_YES_NO__YES, R_QGN_NOTE_QUERY_ANIM);
+        	query->ShowConfirmationQueryL(statusSave, *msgConfirmSave, R_AVKON_SOFTKEYS_YES_NO__YES, R_QGN_NOTE_QUERY_ANIM);
         }
-        
+
         User :: WaitForRequest(statusSave);
         CleanupStack :: PopAndDestroy(2); // msgConfirmSave query
 
         if((statusSave == EAknSoftkeyYes) || (statusSave == EAknSoftkeyOk)) {
             Dprint(_L("[RSCPClient]-> INFO: calling GetNewCodeAndChange() ..."));
-            
+
             TBufC<10> NBuf(KSCPDefaultEnchSecCode);
             TPtr codeBuf = NBuf.Des();
-            
+
             TSCPSecCode lNewSecCode;
             TInt lButtonCfg = (aButtonsShown == SCP_OK || aButtonsShown == SCP_OK_ETEL) ? KSCPForcedChange : KSCPNormalChange;
             HBufC* lNewLkCodeBuf = NULL;
             lRet = GetNewCodeAndChange(codeBuf, lButtonCfg, &lNewSecCode, &lNewLkCodeBuf);
-            
+
             Dprint(_L("[RSCPClient]-> INFO: GetNewCodeAndChange() complete, err=%d"), lRet);
-            
+
             if(KErrNone == lRet) {
-                /* This is being called as a workaround for a freezing issue with SecUI. This is in place 
+                /* This is being called as a workaround for a freezing issue with SecUI. This is in place
                  * as a temporary measure until the source is identified.
                 */
                 TInt lTmpRet = SendReceive(ESCPServAuthenticateS60, TIpcArgs(&lNewLkCodeBuf->Des(), &aPassword, &addParams, aFlags));
-                
+
                 Dprint(_L("[RSCPClient]-> INFO: lTmpRet from SendReceive()=%d"), lTmpRet);
                 if(KErrNone == lRet) {
                     Dprint(_L("[RSCPClient]-> INFO: updating CenRep ..."));
@@ -1291,7 +1303,7 @@
                     Dprint(_L("[RSCPClient]-> INFO: User updated lock code for the first time...err= %d"), lRet);
                 }
             }
-            
+
             if(lNewLkCodeBuf) {
                 delete lNewLkCodeBuf;
             }
@@ -1300,52 +1312,56 @@
             Dprint(_L("[RSCPClient]-> INFO: Returning KErrCancel"));
             lRet = KErrCancel;
         }
-        
+
         if(KErrAbort == lRet) {
             Dprint(_L("[RSCPClient]-> INFO: Returning KErrCancel"));
             lRet = KErrCancel;
         }
 
     }
-    
+
     if(addParams.Length() > 0) {
-        CSCPParamObject* tmp = CSCPParamObject :: NewLC();            
+        CSCPParamObject* tmp = CSCPParamObject :: NewLC();
         TInt lTempRet = tmp->Parse(addParams);
-        
+
         if(lTempRet == KErrNone) {
             lTempRet = tmp->Set(KSCPParamPassword, codeBuffer);
         }
-        
+
         if(lTempRet == KErrNone) {
             addParams.Zero();
             HBufC8* tmpBuf;
             lTempRet = tmp->GetBuffer(tmpBuf);
-            
+
             if(lTempRet == KErrNone) {
                 addParams.Copy(tmpBuf->Des());
                 delete tmpBuf;
             }
         }
-        
+
         if(lTempRet == KErrNone) {
             CSCPParamObject* outParams = NULL;
             ProcessServerCommandsL(addParams, &outParams);
-            
+
             if(outParams != NULL) {
                 TSCPSecCode newSecCode;
                 if(outParams->Get(KSCPParamPassword, newSecCode) == KErrNone) {
                     Dprint((_L("[RSCPClient]-> INFO: Updating encoded password received from the server into aPassword...")));
                     aPassword.Copy(newSecCode);
                 }
+
                 delete outParams;
             }
         }
+
         CleanupStack :: PopAndDestroy(tmp);
     }
+
     CleanupStack :: PopAndDestroy(3); // repository, addParamsHBuf, codeHBuf
     Dprint(_L("[RSCPClient]-> SetSecurityCodeL() <<< lRet=%d"), lRet);
     return lRet;
 }
+
 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS
 // <<-- *********** Device lock new features *************