securitydialogs/SecUi/Src/SecUiSecuritySettings.cpp
changeset 56 25a3fbb5e4d3
parent 51 f479c7dc25d6
child 61 1cc4c46c2963
equal deleted inserted replaced
51:f479c7dc25d6 56:25a3fbb5e4d3
    38 #include <hb/hbcore/hbtextresolversymbian.h>
    38 #include <hb/hbcore/hbtextresolversymbian.h>
    39 #include <aknnotewrappers.h>
    39 #include <aknnotewrappers.h>
    40 #include <StringLoader.h>
    40 #include <StringLoader.h>
    41 #include <RemoteLockSettings.h>
    41 #include <RemoteLockSettings.h>
    42 #include <featmgr.h>
    42 #include <featmgr.h>
    43 
    43 #include <hb/hbwidgets/restricted/hbdevicedialogsextensionsymbian_r.h>
    44 #include "SecQueryUi.h"
    44 #include "SecQueryUi.h"
    45 #include <hb/hbwidgets/hbdevicemessageboxsymbian.h>
    45 #include <hb/hbwidgets/hbdevicemessageboxsymbian.h>
    46 
    46 
    47 /*****************************************************
    47 /*****************************************************
    48  *    Series 60 Customer / TSY
    48  *    Series 60 Customer / TSY
   396     // Check that the new remote lock code doesn't match the security code of the device.
   396     // Check that the new remote lock code doesn't match the security code of the device.
   397     RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityCodePhonePassword;
   397     RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityCodePhonePassword;
   398     RMobilePhone::TMobilePassword securityCode;
   398     RMobilePhone::TMobilePassword securityCode;
   399     RMobilePhone::TMobilePassword unblockCode; // Required here only as a dummy parameter 
   399     RMobilePhone::TMobilePassword unblockCode; // Required here only as a dummy parameter 
   400 
   400 
       
   401 
       
   402 		/* TODO not sure if needs to check against the typed, or the hashed */
       
   403 		/*
       
   404     RArray<TDevicelockPolicies> aFailedPolicies;
       
   405     TDevicelockPolicies failedPolicy;
       
   406     TInt retLockcode = KErrNone;
       
   407     RMobilePhone::TMobilePassword aISACode;
       
   408     TInt scpFlags = 0;
       
   409     RDEBUG("scpClient.VerifyCurrentLockcode", 0);
       
   410     // this validate on ISA . No need to do iPhone.VerifySecurityCode
       
   411     retLockcode = scpClient.VerifyCurrentLockcode(aRemoteLockCode, aISACode, aFailedPolicies, scpFlags);
       
   412     RDEBUG("retLockcode", retLockcode);
       
   413 
       
   414     RDEBUG("aISACode", 0);
       
   415     RDEBUGSTR(aISACode);
       
   416 		*/
   401 
   417 
   402     securityCode = aRemoteLockCode;
   418     securityCode = aRemoteLockCode;
   403     RDEBUG( "EMobilePhoneVerifySecurityCode", EMobilePhoneVerifySecurityCode );
   419     RDEBUG( "EMobilePhoneVerifySecurityCode", EMobilePhoneVerifySecurityCode );
   404     iWait->SetRequestType(EMobilePhoneVerifySecurityCode);
   420     iWait->SetRequestType(EMobilePhoneVerifySecurityCode);
   405     RDEBUG( "VerifySecurityCode", 0 );
   421     RDEBUG( "VerifySecurityCode", 0 );
  1218 void CSecuritySettings::ShowResultNoteL(TInt aResourceID, CAknNoteDialog::TTone aTone)
  1234 void CSecuritySettings::ShowResultNoteL(TInt aResourceID, CAknNoteDialog::TTone aTone)
  1219     {
  1235     {
  1220     RDEBUG("aResourceID", aResourceID);
  1236     RDEBUG("aResourceID", aResourceID);
  1221 
  1237 
  1222     CHbDeviceMessageBoxSymbian* messageBox = CHbDeviceMessageBoxSymbian::NewL(CHbDeviceMessageBoxSymbian::EWarning);
  1238     CHbDeviceMessageBoxSymbian* messageBox = CHbDeviceMessageBoxSymbian::NewL(CHbDeviceMessageBoxSymbian::EWarning);
       
  1239     const TInt KCriticalLevel = 2;
       
  1240     RDEBUG("KCriticalLevel", KCriticalLevel);
       
  1241     HbDeviceDialogsExtensionSymbian::SetShowLevel(messageBox, KCriticalLevel);
       
  1242     RDEBUG("done KCriticalLevel", KCriticalLevel);
  1223     CleanupStack::PushL(messageBox);
  1243     CleanupStack::PushL(messageBox);
  1224     TInt satisfactoryIcon = 0;	// might change later, in some scenarios
  1244     TInt satisfactoryIcon = 0;	// might change later, in some scenarios
  1225     _LIT(KText, "ShowResultNoteL: ");
  1245     _LIT(KText, "ShowResultNoteL: ");
  1226     TBuf<0x200> title;
  1246     TBuf<0x200> title;
  1227     TBuf<0x200> titleTr;
  1247     TBuf<0x200> titleTr;
  1427             title.Append(_L("EDeviceLockSingleCharRepeatNotAllowed"));
  1447             title.Append(_L("EDeviceLockSingleCharRepeatNotAllowed"));
  1428             break;
  1448             break;
  1429         case KErrTDevicelockPolicies+EDevicelockTotalPolicies:
  1449         case KErrTDevicelockPolicies+EDevicelockTotalPolicies:
  1430             titleTr.Append(_L("EDevicelockTotalPolicies"));
  1450             titleTr.Append(_L("EDevicelockTotalPolicies"));
  1431             title.Append(_L("EDevicelockTotalPolicies"));
  1451             title.Append(_L("EDevicelockTotalPolicies"));
       
  1452             break;
       
  1453         case KErrTDevicelockPolicies+EDevicelockTotalPolicies+1:
       
  1454             titleTr.Append(_L("SCP server doesn't support this UID"));
       
  1455             title.Append(_L("SCP server doesn't support this UID"));
  1432             break;
  1456             break;
  1433 
  1457 
  1434         default: // " "
  1458         default: // " "
  1435             titleTr.Append(_L("Specific Error"));
  1459             titleTr.Append(_L("Specific Error"));
  1436             title.Append(_L("Specific Error"));
  1460             title.Append(_L("Specific Error"));
  2282         oldPassword.Copy(aOldPassword);
  2306         oldPassword.Copy(aOldPassword);
  2283         newPassword.Copy(aNewPassword);
  2307         newPassword.Copy(aNewPassword);
  2284         }
  2308         }
  2285 
  2309 
  2286     // check current code before proceeding
  2310     // check current code before proceeding
       
  2311     RSCPClient scpCurrClient;
       
  2312     TInt tCurrRet = scpCurrClient.Connect();
       
  2313     RDEBUG("tCurrRet", tCurrRet);
       
  2314     CleanupClosePushL(scpCurrClient);
       
  2315     RArray<TDevicelockPolicies> aCurrFailedPolicies;
       
  2316     TInt retCurrLockcode = KErrNone;
       
  2317     RMobilePhone::TMobilePassword aCurrISACode;
       
  2318     TInt scpCurrFlags = 0;
       
  2319     RDEBUG("scpClient.VerifyCurrentLockcode", 0);
       
  2320     // this validate on ISA . No need to do iPhone.VerifySecurityCode
       
  2321     retCurrLockcode = scpCurrClient.VerifyCurrentLockcode(oldPassword, aCurrISACode, aCurrFailedPolicies, scpCurrFlags);
       
  2322     RDEBUG("retCurrLockcode", retCurrLockcode);
       
  2323 
       
  2324     RDEBUG("aCurrISACode", 0);
       
  2325     RDEBUGSTR(aCurrISACode);
       
  2326     scpCurrClient.Close();
       
  2327     RDEBUG("PopAndDestroy", 0);
       
  2328     CleanupStack::PopAndDestroy(); //scpCurrClient
       
  2329 
  2287     RDEBUG("EMobilePhoneVerifySecurityCode", EMobilePhoneVerifySecurityCode);
  2330     RDEBUG("EMobilePhoneVerifySecurityCode", EMobilePhoneVerifySecurityCode);
  2288     iWait->SetRequestType(EMobilePhoneVerifySecurityCode);	// 0x59F1
  2331     iWait->SetRequestType(EMobilePhoneVerifySecurityCode);	// 0x59F1
  2289     RDEBUG("VerifySecurityCode", 0);
  2332     RDEBUG("VerifySecurityCode", 0);
  2290     iPhone.VerifySecurityCode(iWait->iStatus, secCodeType, oldPassword, required_fourth);
  2333     iPhone.VerifySecurityCode(iWait->iStatus, secCodeType, aCurrISACode /* not oldPassword !!! */, required_fourth);
  2291     RDEBUG("WaitForRequestL", 0);
  2334     RDEBUG("WaitForRequestL", 0);
  2292     res = iWait->WaitForRequestL();
  2335     res = iWait->WaitForRequestL();
  2293     RDEBUG("WaitForRequestL res", res);
  2336     RDEBUG("WaitForRequestL res", res);
  2294 #ifdef __WINS__
  2337 #ifdef __WINS__
  2295     if (res == KErrNotSupported)
  2338     if (res == KErrNotSupported)
  2347        retLockcode = scpClient.Connect();
  2390        retLockcode = scpClient.Connect();
  2348        RDEBUG( "retLockcode", retLockcode );
  2391        RDEBUG( "retLockcode", retLockcode );
  2349        if(retLockcode == KErrNone )
  2392        if(retLockcode == KErrNone )
  2350        	{
  2393        	{
  2351 	       RDEBUG( "scpClient.VerifyNewLockcodeAgainstPolicies", 0 );
  2394 	       RDEBUG( "scpClient.VerifyNewLockcodeAgainstPolicies", 0 );
       
  2395 	       RDEBUGSTR( newPassword );
  2352 	       retLockcode = scpClient.VerifyNewLockcodeAgainstPolicies( newPassword, aFailedPolicies );
  2396 	       retLockcode = scpClient.VerifyNewLockcodeAgainstPolicies( newPassword, aFailedPolicies );
  2353 	       RDEBUG( "retLockcode", retLockcode );
  2397 	       RDEBUG( "retLockcode", retLockcode );
  2354 	       RDEBUG( "aFailedPolicies.Count()", aFailedPolicies.Count() );
  2398 	       RDEBUG( "aFailedPolicies.Count()", aFailedPolicies.Count() );
  2355 	       for(TInt i=0; i<aFailedPolicies.Count(); i++)
  2399 	       for(TInt i=0; i<aFailedPolicies.Count(); i++)
  2356 		       {
  2400 		       {
  2421                     // this is the old method. Obsolete now
  2465                     // this is the old method. Obsolete now
  2422                     // scpClient.StoreCode( newCode );
  2466                     // scpClient.StoreCode( newCode );
  2423                     RArray<TDevicelockPolicies> aFailedPolicies;
  2467                     RArray<TDevicelockPolicies> aFailedPolicies;
  2424                     TDevicelockPolicies failedPolicy;
  2468                     TDevicelockPolicies failedPolicy;
  2425                     TInt retLockcode = KErrNone;
  2469                     TInt retLockcode = KErrNone;
       
  2470                     RDEBUG("newScpCode", 0);
       
  2471                     RDEBUGSTR( newScpCode );
       
  2472                     RDEBUG("oldScpCode", 0);
       
  2473                     RDEBUGSTR( oldScpCode );
  2426                     retLockcode = scpClient.StoreLockcode(newScpCode, oldScpCode, aFailedPolicies);
  2474                     retLockcode = scpClient.StoreLockcode(newScpCode, oldScpCode, aFailedPolicies);
  2427                     RDEBUG( "retLockcode", retLockcode );
  2475                     RDEBUG( "retLockcode", retLockcode );
  2428                     RDEBUG( "KErrAccessDenied", KErrAccessDenied );
  2476                     RDEBUG( "KErrAccessDenied", KErrAccessDenied );
  2429                     RDEBUG( "aFailedPolicies.Count()", aFailedPolicies.Count() );
  2477                     RDEBUG( "aFailedPolicies.Count()", aFailedPolicies.Count() );
  2430                     for (TInt i = 0; i < aFailedPolicies.Count(); i++)
  2478                     for (TInt i = 0; i < aFailedPolicies.Count(); i++)
  2436                     // The code is already changed in iPhone !
  2484                     // The code is already changed in iPhone !
  2437                     // For now, just undo the changed password
  2485                     // For now, just undo the changed password
  2438                     if(retLockcode!=KErrNone)
  2486                     if(retLockcode!=KErrNone)
  2439                     	{
  2487                     	{
  2440                     	RDEBUG("Undo password change because retLockcode", retLockcode);
  2488                     	RDEBUG("Undo password change because retLockcode", retLockcode);
       
  2489                     	if(retLockcode==KErrAccessDenied)	// this happens if CSCPSession::HandleAuthenticationMessageL doesn't include the UID
       
  2490                     		retLockcode = KErrTDevicelockPolicies+EDevicelockTotalPolicies+1;
  2441                     	ShowResultNoteL(retLockcode, CAknNoteDialog::EConfirmationTone);
  2491                     	ShowResultNoteL(retLockcode, CAknNoteDialog::EConfirmationTone);
  2442                     	
  2492                     	
  2443                     	// go back to previous password.
  2493                     	// go back to previous password.
  2444 	           	        passwords.iOldPassword = newPassword;
  2494 	           	        passwords.iOldPassword = newPassword;
  2445 							        passwords.iNewPassword = oldPassword;
  2495 							        passwords.iNewPassword = oldPassword;