Revision: 201039 RCL_3 PDK_3.0.4
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 13 Oct 2010 15:30:47 +0300
branchRCL_3
changeset 67 79bd6bd83ec3
parent 57 ead42e28e519
Revision: 201039 Kit: 201041
pkiutilities/CertSaver/data/CertSaver.rss
pkiutilities/CertSaver/inc/CertSaverModel.h
pkiutilities/CertSaver/loc/certsaver.loc
pkiutilities/CertSaver/src/CertSaverModel.cpp
securitydialogs/Autolock/src/AutoLockValueObserver.cpp
securitydialogs/SecUi/Src/SecUiManualSecuritySettings.cpp
wim/Scard/inc/ScardConnector.h
wim/Scard/src/ScardConnectionRegistry.cpp
wim/Scard/src/ScardConnector.cpp
--- a/pkiutilities/CertSaver/data/CertSaver.rss	Wed Sep 15 13:09:05 2010 +0300
+++ b/pkiutilities/CertSaver/data/CertSaver.rss	Wed Oct 13 15:30:47 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2003-2007 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -474,45 +474,4 @@
 RESOURCE TBUF r_certsaver_one_authority_certificate { buf = qtn_cm_one_authority_certificate; }
 RESOURCE TBUF r_certsaver_trustedsite_warning { buf = qtn_cm_save_trustedsite_certificate_warning_text; }
 
-
-//----------------------------------------------------
-//
-//    r_certsaver_protect_with_password
-//
-//----------------------------------------------------
-//
-RESOURCE DIALOG r_certsaver_protect_with_password
-    {
-    flags = EGeneralQueryFlags;
-    buttons = r_certsaver_softkeys_no_yes_no;
-    items=
-        {
-        DLG_LINE
-            {
-            type=EAknCtQuery;
-            id=EGeneralQuery;
-            control= AVKON_CONFIRMATION_QUERY
-                {
-                layout = EConfirmationLayout;
-                label = qtn_certsaver_protect_with_password_query;
-                };
-            }
-        };
-    }
-
-//----------------------------------------------------
-//
-//    r_certsaver_softkeys_no_yes_no
-//
-//----------------------------------------------------
-//
-RESOURCE CBA r_certsaver_softkeys_no_yes_no
-    {
-    buttons =
-        {
-        CBA_BUTTON { id=EAknSoftkeyNo; txt=text_softkey_no; },
-        CBA_BUTTON { id=EAknSoftkeyYes; txt=text_softkey_yes; },
-        CBA_BUTTON { id=EAknSoftkeyNo; txt=text_softkey_no; }
-        };
-    }
-
+// End of File
--- a/pkiutilities/CertSaver/inc/CertSaverModel.h	Wed Sep 15 13:09:05 2010 +0300
+++ b/pkiutilities/CertSaver/inc/CertSaverModel.h	Wed Oct 13 15:30:47 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2003-2007 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -107,12 +107,6 @@
         void GetKeyValidityPeriodL(
             TTime& aStartDate,
             TTime& aEndDate,
-            const TKeyIdentifier& aKeyIdentifier,
-            const CArrayPtr<CX509Certificate>& aCertArray );
-        
-        void GetKeyValidityPeriodL(
-            TTime& aStartDate,
-            TTime& aEndDate,
             const TKeyIdentifier& aKeyIdentifier );
 
         TKeyUsagePKCS15 KeyUsageL(
@@ -340,11 +334,8 @@
         TInt  iSavedCACertsCount;
         TInt  iSavedKeysCount;
         TInt  iSavedUserCertsCount;
+        TInt  iSelectedKeyStore;
         TBool iKeyAlreadyExists;
-        
-        TUid  iSelectedKeyStoreToken;
-        TUid  iSelectedCertStoreToken;
-        TInt  iSelectedKeyStoreIndex;
     };
 
 #endif
--- a/pkiutilities/CertSaver/loc/certsaver.loc	Wed Sep 15 13:09:05 2010 +0300
+++ b/pkiutilities/CertSaver/loc/certsaver.loc	Wed Oct 13 15:30:47 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2003-2007 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -243,19 +243,4 @@
 //
 #define qtn_cm_save_trustedsite_certificate_warning_text    "Certificate will be added as a Trusted site certificate. Future connections to site %U will be made without certificate warning. Save anyway?"
 
-//d:Confirmation query for selecting the certificate store
-//d:where new certificate will be saved. Alternatives are
-//d:device certificate store and personal certificate store.
-//d:Difference is that personal certificate store is password
-//d:protected, and password is prompted when certificates are
-//d:used. The default is to save in device certificate store
-//d:that can be used without passwords (no protection). Left
-//d:softkey is text_softkey_no, and right is text_softkey_yes.
-//d:User can move the certs between device and personal
-//d:certificate stores later by using Certificate Manager
-//d:(in Control Panel).
-//l:popup_note_window
-//r:9.2
-//
-#define qtn_certsaver_protect_with_password_query           "Protect with password?"
-
+// End of File
--- a/pkiutilities/CertSaver/src/CertSaverModel.cpp	Wed Sep 15 13:09:05 2010 +0300
+++ b/pkiutilities/CertSaver/src/CertSaverModel.cpp	Wed Oct 13 15:30:47 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2003-2007 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -75,12 +75,7 @@
 _LIT( KEnter, "\n" );
 
 const TUid KTrustedServerTokenUid = { 0x101FB66F };
-const TUid KFileCertStoreTokenUid = { 0x101F501A };
-const TUid KDeviceCertStoreTokenUid = { 0x101FB668 };
-const TUid KFileKeyStoreTokenUid = { KTokenTypeFileKeystore };  // 0x101F7333
-const TUid KDeviceKeyStoreTokenUid = { 0x101FB66A };
-
-const TInt64 KZeroTime = 0;
+const TUid KFileTokensUid = { 0x101F501A };
 
 _LIT_SECURITY_POLICY_V1( KSymbianKeyStoreMgmtPolicy,
                          VID_DEFAULT, ECapabilityWriteUserData );
@@ -99,16 +94,16 @@
     }
 
 // ----------------------------------------------------------
-// CCertSaverModel::CCertSaverModel()
+// CCertSaverModel::CCertSaverModel(
+//    const CCertSaverDocument* aDocument, CCertSaverAppUi* aAppUi)
 // ----------------------------------------------------------
 //
-CCertSaverModel::CCertSaverModel( CCertSaverAppUi* aAppUi, const CCertParser& aParser ) :
+CCertSaverModel::CCertSaverModel(
+    CCertSaverAppUi* aAppUi,
+    const CCertParser& aParser ):
     iAppUi( aAppUi ), iFs( iAppUi->CoeEnv()->FsSession() ), iParser( aParser ),
     iSavedCACertsCount( 0 ), iSavedKeysCount( 0 ),
-    iSavedUserCertsCount( 0 ), iKeyAlreadyExists( EFalse ),
-    iSelectedKeyStoreToken( KFileKeyStoreTokenUid ),
-    iSelectedCertStoreToken( KFileCertStoreTokenUid ),
-    iSelectedKeyStoreIndex( KErrNotFound )
+    iSavedUserCertsCount( 0 ), iKeyAlreadyExists( EFalse )
     {
     }
 
@@ -124,8 +119,6 @@
     iCertOwnerType = aOwnerType;
     iCertFormat = aCertFormat;
     iNewCert = &aCertificate;
-    iSelectedKeyStoreToken = KFileKeyStoreTokenUid;
-    iSelectedCertStoreToken = KFileCertStoreTokenUid;
 
     if ( aOwnerType == EPeerCertificate )
         {
@@ -154,8 +147,8 @@
     MPKCS8DecodedKeyPairData* keyPairData = pkcs8Data->KeyPairData();
     keyPairData->GetKeyIdentifierL( keyIdentifier );
 
-    TTime startDate( KZeroTime );
-    TTime endDate( KZeroTime );
+    TTime startDate;
+    TTime endDate;
     GetKeyValidityPeriodL( startDate, endDate, keyIdentifier );
 
     TInt err = KErrNone;
@@ -163,9 +156,9 @@
     TBuf<KPrivaKeyLabelLength> keyLabel( KPrivateKeyLabel );
     TKeyUsagePKCS15 keyUsage = KeyUsageL( keyIdentifier, pkcs8Data->Algorithm() );
     CleanupStack::PopAndDestroy( pkcs8Data );
-    if ( KeyAlreadyExistsL( startDate, endDate, keyIdentifier, keyUsage) )
+    if (KeyAlreadyExistsL( startDate, endDate, keyIdentifier, keyUsage) )
         {
-        return;
+        User::Leave( KErrNone );
         }
 
     TInt accessType( 0 );
@@ -175,7 +168,8 @@
     for ( TInt i = 0; i < KAttempts; i++ )
         {
         CreateKeyLabelL( keyLabel );
-        err = iWrapper->AddKey( iSelectedKeyStoreIndex, aKey, keyUsage, keyLabel,
+        // Should not use hardcoded index
+        err = iWrapper->AddKey( 0, aKey, keyUsage, keyLabel,
             accessType, startDate, endDate, keyInfo );
         if ( err != KErrAlreadyExists )
             {
@@ -304,21 +298,24 @@
 //
 // ----------------------------------------------------------
 //
-void CCertSaverModel::GetKeyValidityPeriodL( TTime& aStartDate, TTime& aEndDate,
-        const TKeyIdentifier& aKeyIdentifier, const CArrayPtr<CX509Certificate>& aCertArray )
+void CCertSaverModel::GetKeyValidityPeriodL(
+    TTime& aStartDate,
+    TTime& aEndDate,
+    const TKeyIdentifier& aKeyIdentifier )
     {
-    const TTime timeNotSet( KZeroTime );
 
-    for( TInt index = 0; index < aCertArray.Count(); index++ )
+    for ( TInt i = 0; i < iParser.UserCertificates().Count(); i++ )
         {
-        const CX509Certificate* cert = aCertArray.At( index );
-        if( cert->KeyIdentifierL() == aKeyIdentifier )
+        const CX509Certificate* cert = iParser.UserCertificates().At( i );
+        if ( cert->KeyIdentifierL() == aKeyIdentifier )
             {
-            if ( aStartDate == timeNotSet || aStartDate > cert->ValidityPeriod().Start() )
+            // Associated certificate found
+            // In the first round aStartDate and aEndDate is initialised.
+            if ( i == 0 || aStartDate > cert->ValidityPeriod().Start() )
                 {
                 aStartDate = cert->ValidityPeriod().Start();
                 }
-            if ( aEndDate == timeNotSet || aEndDate < cert->ValidityPeriod().Finish() )
+            if ( i == 0 || aEndDate < cert->ValidityPeriod().Finish() )
                 {
                 aEndDate = cert->ValidityPeriod().Finish();
                 }
@@ -327,18 +324,6 @@
     }
 
 // ----------------------------------------------------------
-// CCertSaverModel::GetKeyValidityPeriodL()
-//
-// ----------------------------------------------------------
-//
-void CCertSaverModel::GetKeyValidityPeriodL( TTime& aStartDate, TTime& aEndDate,
-        const TKeyIdentifier& aKeyIdentifier )
-    {
-    GetKeyValidityPeriodL( aStartDate, aEndDate, aKeyIdentifier, iParser.UserCertificates() );
-    GetKeyValidityPeriodL( aStartDate, aEndDate, aKeyIdentifier, iParser.CACertificates() );
-    }
-
-// ----------------------------------------------------------
 // CCertSaverModel::CreateKeyLabelL()
 //
 // ----------------------------------------------------------
@@ -385,11 +370,11 @@
             {
             TUid uid =
             iWrapper->UnifiedKeyStore().KeyStoreManager(i).Token().TokenType().Type();
-            if ( uid == iSelectedKeyStoreToken )
+            if ( uid == TUid::Uid( KTokenTypeFileKeystore ) )
                 // if this is not found, we use the first one,
                 // which is already initialised
                 {
-                iSelectedKeyStoreIndex = i;
+                iSelectedKeyStore = i;
                 }
             }
         }
@@ -529,6 +514,7 @@
     CleanupStack::PopAndDestroy( message );
     CleanupStack::PushL( dlg );
 
+
     dlg->PrepareLC( R_MESSAGE_QUERY_DOSAVE );
 
     HBufC* header = StringLoader::LoadLC( R_CERTSAVER_DETAILS_HEADING );
@@ -634,7 +620,7 @@
         // If the certificate is already in CACerts.dat,
         // then don't save it
         if ( iNewCert->Fingerprint() == certificate->Fingerprint() &&
-            (( *iEntries[i]).Handle().iTokenHandle.iTokenTypeUid == iSelectedCertStoreToken ) )
+            (( *iEntries[i]).Handle().iTokenHandle.iTokenTypeUid == KFileTokensUid ) )
             {
             found = ETrue;
             }
@@ -680,26 +666,8 @@
             }
         }
 
-    // Select which store to use
-    TUid certstoreToken;
-    switch( iCertOwnerType )
-        {
-        case ECACertificate:
-            certstoreToken = KFileCertStoreTokenUid;
-            break;
-        case EUserCertificate:
-            certstoreToken = iSelectedCertStoreToken;
-            break;
-        case EPeerCertificate:
-            certstoreToken = KTrustedServerTokenUid;
-            break;
-        default:
-            certstoreToken = KFileCertStoreTokenUid;
-            break;
-        }
-
     // Get interface to writable store.
-    TInt certstoreIndex = -1;
+    TInt certstoreIndex( -1 );
     TInt count = iUnifiedCertStore->WritableCertStoreCount();
     if ( count > 0 )
         {
@@ -710,7 +678,9 @@
 
             MCTToken& token = writableCertStore.Token();
             TUid tokenuid = token.Handle().iTokenTypeUid;
-            if ( tokenuid == certstoreToken )
+            if ( ( tokenuid == KTrustedServerTokenUid ) && ( iCertOwnerType == EPeerCertificate ) ||
+                 ( tokenuid == KFileTokensUid ) && ( iCertOwnerType == ECACertificate ) ||
+                 ( tokenuid == KFileTokensUid ) && ( iCertOwnerType == EUserCertificate ) )
                 {
                 certstoreIndex = i;
                 break;
@@ -788,8 +758,7 @@
 
         // takes ownership of trusterUids
         status = iWrapper->SetApplicability(
-            iUnifiedCertStore->WritableCertStore( certstoreIndex ),
-            *( iEntries[ 0 ] ), iTrusterUids );
+            iUnifiedCertStore->WritableCertStore( certstoreIndex ), *(iEntries[0]), iTrusterUids );
 
         // If error happened, show error note and give up. Otherwise, continue
         if ( status )
@@ -800,8 +769,7 @@
 
         // Downloaded certificate is trusted by default
         status = iWrapper->SetTrust(
-            iUnifiedCertStore->WritableCertStore( certstoreIndex ),
-            *( iEntries [ 0 ] ), ETrue );
+            iUnifiedCertStore->WritableCertStore(certstoreIndex), *(iEntries[0]), ETrue );
         if ( status )
             {
             HandleSaveErrorL( status );
@@ -1140,7 +1108,7 @@
     // format the date to user readable format. The format is locale dependent
     finishValue.FormatL( finishString, *dateFormatString );
     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( finishString );
-    CleanupStack::PopAndDestroy( dateFormatString );
+    CleanupStack::PopAndDestroy(); // dateFormatString
     aMessage.Append( finishString );
     AddNewlinesToMessage( aMessage );
     }
@@ -1526,12 +1494,12 @@
     {
     HBufC* message = HBufC::NewLC( KMaxLengthTextMeassageBody );
     TPtr msgPtr = message->Des();
-	TInt keysCount = iParser.Keys().Count();
-    TInt userCertificateCount = iParser.UserCertificates().Count();
-    TInt caCertificateCount = iParser.CACertificates().Count();
-    ConstructPKCS12QueryMsgL( msgPtr, keysCount, userCertificateCount, caCertificateCount );
-    TBool save = DoMessageQueryL( R_MESSAGE_QUERY_DOSAVE,
-            R_CERTSAVER_HEADER_PKCS12_FILE_CONTAINS, *message );
+    ConstructPKCS12QueryMsgL(msgPtr, iParser.Keys().Count(),
+                            iParser.UserCertificates().Count(),
+                            iParser.CACertificates().Count() );
+    TBool save = DoMessageQueryL(
+        R_MESSAGE_QUERY_DOSAVE, R_CERTSAVER_HEADER_PKCS12_FILE_CONTAINS,
+        *message );
     CleanupStack::PopAndDestroy( message );
     message = NULL;
     if ( !save )
@@ -1539,31 +1507,14 @@
         ShowInformationNoteL( R_CERTSAVER_PKCS12_DISCARDED );
         User::Leave( KErrExitApp );
         }
-
-    if ( keysCount )
-        {
-        CAknQueryDialog* protectWithPasswordQuery = CAknQueryDialog::NewL();
-        TInt buttonId = protectWithPasswordQuery->ExecuteLD( R_CERTSAVER_PROTECT_WITH_PASSWORD );
-        if ( buttonId == EAknSoftkeyYes )
-            {
-            iSelectedKeyStoreToken = KFileKeyStoreTokenUid;
-            iSelectedCertStoreToken = KFileCertStoreTokenUid;
-            }
-        else
-            {
-            iSelectedKeyStoreToken = KDeviceKeyStoreTokenUid;
-            iSelectedCertStoreToken = KDeviceCertStoreTokenUid;
-            }
-        }
-
     TInt status = KErrNone;
     // save private keys
     TRAP( status, SavePrivateKeyL() );
 
     // save user certificates if private key was saved.
-    if ( ( iSavedKeysCount > 0 || iKeyAlreadyExists ) && userCertificateCount > 0 )
+    if ( ( iSavedKeysCount > 0 || iKeyAlreadyExists ) && iParser.UserCertificates().Count() > 0 )
         {
-        for ( TInt i = 0; i < userCertificateCount; i++ )
+        for ( TInt i = 0; i < iParser.UserCertificates().Count(); i++ )
             {
             const CX509Certificate* cert = iParser.UserCertificates().At(i);
             iCertOwnerType = EUserCertificate;
@@ -1576,11 +1527,10 @@
                 }
             }
         }
-
     // save CA certificates
-    if ( caCertificateCount > 0 )
+    if ( iParser.CACertificates().Count() > 0 )
         {
-        for ( TInt i = 0; i < caCertificateCount; i++ )
+        for ( TInt i = 0; i < iParser.CACertificates().Count(); i++ )
             {
             const CX509Certificate* cert = iParser.CACertificates().At( i );
             iCertOwnerType = ECACertificate;
@@ -1593,7 +1543,6 @@
                 }
             }
         }
-
     if ( iSavedCACertsCount != 0 || iSavedKeysCount != 0
         || iSavedUserCertsCount != 0 )
         {
@@ -1601,7 +1550,8 @@
         TPtr msgPtr2 = message->Des();
         ConstructPKCS12QueryMsgL(
             msgPtr2, iSavedKeysCount, iSavedUserCertsCount, iSavedCACertsCount );
-        DoMessageQueryL( R_MESSAGE_QUERY_SAVED, R_CERTSAVER_HEADER_SAVED, *message );
+        DoMessageQueryL(
+            R_MESSAGE_QUERY_SAVED, R_CERTSAVER_HEADER_SAVED, *message );
         CleanupStack::PopAndDestroy( message );
         }
     else
--- a/securitydialogs/Autolock/src/AutoLockValueObserver.cpp	Wed Sep 15 13:09:05 2010 +0300
+++ b/securitydialogs/Autolock/src/AutoLockValueObserver.cpp	Wed Oct 13 15:30:47 2010 +0300
@@ -206,6 +206,7 @@
 void CValueObserver::DoCancel()
     {
     iProperty.Cancel();
+    iProperty.Close();
     }
 
 // End of file
--- a/securitydialogs/SecUi/Src/SecUiManualSecuritySettings.cpp	Wed Sep 15 13:09:05 2010 +0300
+++ b/securitydialogs/SecUi/Src/SecUiManualSecuritySettings.cpp	Wed Oct 13 15:30:47 2010 +0300
@@ -399,40 +399,44 @@
     RDebug::Print(_L("(SECUI)CManualSecuritySettings::LockSimL(): Param length: %d"), length);
     #endif
 
-    if (aType.CompareF(Operator) == 0)
-        {
-        aLockType = RMmCustomAPI::EOperator;
-        ret = iCustomPhone.ActivateSimLock( aLockCode,aLockType );
-        }
-
-    if (aType.CompareF(Gid1) == 0)
-        {
-        aLockType = RMmCustomAPI::EGid1;
-        ret = iCustomPhone.ActivateSimLock( aLockCode,aLockType );
-        }
-
-    if (aType.CompareF(Gid2) == 0)
+    // make sure aLockCode's length won't exceed KSimLockMaxPasswordSize
+    if( aLockCode.Length() <= KSimLockMaxPasswordSize )
         {
-        aLockType = RMmCustomAPI::EGid2;
-        ret = iCustomPhone.ActivateSimLock( aLockCode,aLockType );
-        }
+        if ( aType.CompareF( Operator ) == 0 )
+            {
+            aLockType = RMmCustomAPI::EOperator;
+            ret = iCustomPhone.ActivateSimLock( aLockCode, aLockType );
+            }
 
-    if (aType.CompareF(Imsi) == 0)
-        {
-        aLockType = RMmCustomAPI::EImsi;
-        ret = iCustomPhone.ActivateSimLock( aLockCode,aLockType );
-        }
+        if ( aType.CompareF( Gid1 ) == 0 )
+            {
+            aLockType = RMmCustomAPI::EGid1;
+            ret = iCustomPhone.ActivateSimLock( aLockCode, aLockType );
+            }
+
+        if ( aType.CompareF( Gid2 ) == 0 )
+            {
+            aLockType = RMmCustomAPI::EGid2;
+            ret = iCustomPhone.ActivateSimLock( aLockCode, aLockType );
+            }
 
-    if (aType.CompareF(Operator_Gid1) == 0)
-        {    
-        aLockType = RMmCustomAPI::EOperator_Gid1;
-        ret = iCustomPhone.ActivateSimLock( aLockCode,aLockType );
-        }
+        if ( aType.CompareF( Imsi ) == 0 )
+            {
+            aLockType = RMmCustomAPI::EImsi;
+            ret = iCustomPhone.ActivateSimLock( aLockCode, aLockType );
+            }
 
-    if (aType.CompareF(Operator_Gid2) == 0)
-        {
-        aLockType = RMmCustomAPI::EOperator_Gid2;
-        ret = iCustomPhone.ActivateSimLock( aLockCode,aLockType );
+        if ( aType.CompareF( Operator_Gid1 ) == 0 )
+            {    
+            aLockType = RMmCustomAPI::EOperator_Gid1;
+            ret = iCustomPhone.ActivateSimLock( aLockCode, aLockType );
+            }
+
+        if ( aType.CompareF( Operator_Gid2 ) == 0 )
+            {
+            aLockType = RMmCustomAPI::EOperator_Gid2;
+            ret = iCustomPhone.ActivateSimLock( aLockCode, aLockType );
+            }
         }
 
     #if defined(_DEBUG)
@@ -500,48 +504,51 @@
     #if defined(_DEBUG)
     RDebug::Print(_L("(SECUI)CManualSecuritySettings::UnLockSimL(): Param length: %d"), length);
     #endif
-    
-    if (aType.CompareF(Operator) == 0)
-        {
-        aLockType = RMmCustomAPI::EOperator;
-        ret = iCustomPhone.DeActivateSimLock( aUnlockCode,aLockType );
-        }
 
-    if (aType.CompareF(Gid1) == 0)
-        {
-        aLockType = RMmCustomAPI::EGid1;
-        ret = iCustomPhone.DeActivateSimLock( aUnlockCode,aLockType );
-        }
-
-    if (aType.CompareF(Gid2) == 0)
-        {
-        aLockType = RMmCustomAPI::EGid2;
-        ret = iCustomPhone.DeActivateSimLock( aUnlockCode,aLockType );
-        }
-
-    if (aType.CompareF(Imsi) == 0)
+    // make sure aUnlockCode's length won't exceed KSimLockMaxPasswordSize
+    if( aUnlockCode.Length() <= KSimLockMaxPasswordSize )
         {
-        aLockType = RMmCustomAPI::EImsi;
-        ret = iCustomPhone.DeActivateSimLock( aUnlockCode,aLockType );
-        }
+        if ( aType.CompareF( Operator ) == 0 )
+            {
+            aLockType = RMmCustomAPI::EOperator;
+            ret = iCustomPhone.DeActivateSimLock( aUnlockCode, aLockType );
+            }
 
-    if (aType.CompareF(Operator_Gid1) == 0)
-        {    
-        aLockType = RMmCustomAPI::EOperator_Gid1;
-        ret = iCustomPhone.DeActivateSimLock( aUnlockCode,aLockType );
-        }
+        if ( aType.CompareF( Gid1 ) == 0 )
+            {
+            aLockType = RMmCustomAPI::EGid1;
+            ret = iCustomPhone.DeActivateSimLock( aUnlockCode, aLockType );
+            }
+
+        if ( aType.CompareF( Gid2 ) == 0 )
+            {
+            aLockType = RMmCustomAPI::EGid2;
+            ret = iCustomPhone.DeActivateSimLock( aUnlockCode, aLockType );
+            }
 
-    if (aType.CompareF(Operator_Gid2) == 0)
-        {
-        aLockType = RMmCustomAPI::EOperator_Gid2;
-        ret = iCustomPhone.DeActivateSimLock( aUnlockCode,aLockType );
+        if ( aType.CompareF( Imsi ) == 0 )
+            {
+            aLockType = RMmCustomAPI::EImsi;
+            ret = iCustomPhone.DeActivateSimLock( aUnlockCode, aLockType );
+            }
+
+        if ( aType.CompareF( Operator_Gid1 ) == 0 )
+            {    
+            aLockType = RMmCustomAPI::EOperator_Gid1;
+            ret = iCustomPhone.DeActivateSimLock( aUnlockCode, aLockType );
+            }
+
+        if ( aType.CompareF( Operator_Gid2 ) == 0 )
+            {
+            aLockType = RMmCustomAPI::EOperator_Gid2;
+            ret = iCustomPhone.DeActivateSimLock( aUnlockCode, aLockType );
+            }
+        if ( aType.CompareF( GlobalUnlock ) == 0 )
+            {
+            aLockType = RMmCustomAPI::EGlobalUnlock;
+            ret = iCustomPhone.DeActivateSimLock( aUnlockCode, aLockType );
+            }
         }
-    if (aType.CompareF(GlobalUnlock) == 0)
-        {
-        aLockType = RMmCustomAPI::EGlobalUnlock;
-        ret = iCustomPhone.DeActivateSimLock( aUnlockCode,aLockType );
-        }    
-        
     #if defined(_DEBUG)
     RDebug::Print(_L("(SECUI)CManualSecuritySettings::UnLockSimL() RESULT: %d"), ret);
     #endif
--- a/wim/Scard/inc/ScardConnector.h	Wed Sep 15 13:09:05 2010 +0300
+++ b/wim/Scard/inc/ScardConnector.h	Wed Oct 13 15:30:47 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -97,11 +97,13 @@
         /**
         * Two-phased constructor.
         * @param aConnRegistry Pointer to connection registry
+        * @param aClient Client thread
         * @param aMessage Client message
-        */
+        */ 
         static CScardConnector* NewL( CScardConnectionRegistry* aConnRegistry,
-            const RMessage2& aMessage );
-
+                                      RThread& aClient, 
+                                      const RMessage2& aMessage );
+        
         /**
         * Destructor.
         */
@@ -163,8 +165,10 @@
         /**
         * C++ default constructor.
         * @param aConnRegistry Pointer to connection registry
+        * @param aClient Client thread
         */
-        CScardConnector( CScardConnectionRegistry* aConnRegistry );
+        CScardConnector( CScardConnectionRegistry* aConnRegistry, 
+                         RThread& aClient );
 
         /**
         * By default Symbian 2nd phase constructor is private.
--- a/wim/Scard/src/ScardConnectionRegistry.cpp	Wed Sep 15 13:09:05 2010 +0300
+++ b/wim/Scard/src/ScardConnectionRegistry.cpp	Wed Oct 13 15:30:47 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -105,8 +105,16 @@
     TConnectionHandle handle;
     handle.iClient = aClient;
     CScardConnector* conn = NULL;
+    RThread thread;
+    
+    TInt err1 = thread.Open( KScardServerName );
+    
+    if ( err1 != KErrNone )
+        {
+        _WIMTRACE(_L("WIM|Scard|CScardConnectionRegistry::ConnectToReaderL|Thread open failed"));
+        }
 
-    TRAPD( err, conn = CScardConnector::NewL( this, aMessage ) );
+    TRAPD( err, conn = CScardConnector::NewL( this, thread, aMessage ) );
     if ( err )
         {
 #ifdef _DEBUG
--- a/wim/Scard/src/ScardConnector.cpp	Wed Sep 15 13:09:05 2010 +0300
+++ b/wim/Scard/src/ScardConnector.cpp	Wed Oct 13 15:30:47 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -89,12 +89,17 @@
 // might leave.
 // -----------------------------------------------------------------------------
 //
-CScardConnector::CScardConnector( CScardConnectionRegistry* aConnRegistry ) :
-        CScardSession(), iConnectionRegistry( aConnRegistry ), iState( EActive )
+CScardConnector::CScardConnector(
+    CScardConnectionRegistry* aConnRegistry, 
+    RThread& /*aClient*/ )
+    : CScardSession(),
+      iConnectionRegistry( aConnRegistry ),
+      iState( EActive )
     {
     _WIMTRACE(_L("WIM|Scard|CScardConnector::CScardConnector|Begin"));
     }
 
+
 // -----------------------------------------------------------------------------
 // CScardConnector::ConstructL
 // Symbian 2nd phase constructor can leave.
@@ -115,12 +120,14 @@
 // -----------------------------------------------------------------------------
 //
 CScardConnector* CScardConnector::NewL(
-    CScardConnectionRegistry* aConnRegistry,
+    CScardConnectionRegistry* aConnRegistry, 
+    RThread& aClient, 
     const RMessage2& aMessage )
     {
     _WIMTRACE(_L("WIM|Scard|CScardConnector::NewL|Begin"));
-    CScardConnector* self = new( ELeave ) CScardConnector( aConnRegistry );
-
+    CScardConnector* self = new( ELeave ) CScardConnector( aConnRegistry, 
+        aClient );
+    
     CleanupStack::PushL( self );
     self->ConstructL( aMessage );
     CleanupStack::Pop( self );