Revision: 201003 RCL_3 PDK_3.0.h
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 19 Feb 2010 23:42:03 +0200
branchRCL_3
changeset 5 3b17fc5c9564
parent 1 d5423fbb4f29
child 7 6e226572c5f0
Revision: 201003 Kit: 201007
gba/common/GBALogger.cpp
gba/gbafilter/src/HTTPFilterGBA.cpp
gba/gbaserver/src/dataretriever.cpp
gba/inc/GBALogger.h
gba/sis/gba.pkg
gba/uicc/src/GbaAkaIsa.cpp
pkiutilities/CTSecurityDialogs/NotifInc/CTSecurityDialogsAO.h
pkiutilities/CTSecurityDialogs/NotifSrc/CTSecurityDialogsAO.cpp
pkiutilities/CertmanUi/SRC/CertmanuicontainerAuthority.cpp
pkiutilities/CertmanUi/SRC/CertmanuicontainerDevice.cpp
pkiutilities/CertmanUi/SRC/CertmanuicontainerPersonal.cpp
pkiutilities/CertmanUi/SRC/CertmanuicontainerTrustedSite.cpp
pkiutilities/CertmanUi/SRC/CertmanuiviewPersonal.cpp
pkiutilities/DeviceToken/Src/Generic/Client/DevTokenClientSession.cpp
pkiutilities/DeviceToken/Src/Generic/Server/DevTokenUtil.cpp
pkiutilities/PKCS12/CrBer/Src/Crberset.cpp
pkiutilities/PKCS12/CrBer/Src/crdata.cpp
pkiutilities/PKCS12/CrPkcs12/Inc/crcrypto.h
pkiutilities/PKCS12/CrPkcs12/Src/crcrypto.cpp
pkiutilities/PKCS12/CrPkcs12/Src/crpkcs12.cpp
pkiutilities/SecModUI/inc/SecModUISyncWrapper.h
pkiutilities/SecModUI/src/SecModUISyncWrapper.cpp
pkiutilities/SecModUI/src/SecModUIViewAccess.cpp
pkiutilities/SecModUI/src/SecModUIViewSignature.cpp
securitydialogs/Autolock/src/AutolockAppUi.cpp
securitydialogs/SecUi/Src/SecUiSecuritySettings.cpp
securitydialogs/Securitynotifier/Group/Securitynotifier.mmp
securitydialogs/Securitynotifier/Src/SecurityNotifier.cpp
securitydialogs/simlockui/data/SimLockUI.rss
securitydialogs/simlockui/data/SimLockUI_reg.rss
securitydialogs/simlockui/group/SimLockUI.mmp
securitydialogs/simlockui/group/bld.inf
securitydialogs/simlockui/inc/SimLockTelephonyProxy.h
securitydialogs/simlockui/inc/SimLockUI.hrh
securitydialogs/simlockui/inc/SimLockUIAppui.h
securitydialogs/simlockui/inc/SimLockUIDocument.h
securitydialogs/simlockui/src/SimLockDataHandlingDelegate.cpp
securitydialogs/simlockui/src/SimLockTelephonyProxy.cpp
securitydialogs/simlockui/src/SimLockUI.cpp
securitydialogs/simlockui/src/SimLockUIApplication.cpp
securitydialogs/simlockui/src/SimLockUIAppui.cpp
securitydialogs/simlockui/src/SimLockUIBackgroundControl.cpp
securitydialogs/simlockui/src/SimLockUIDocument.cpp
wim/Scard/src/ScardAccessControl.cpp
wim/SwimReader/inc/SwimLauncher.h
wim/SwimReader/inc/SwimReaderIF.h
wim/SwimReader/src/SwimReaderIF.cpp
wim/WimClient/inc/WimSecModule.h
wim/WimClient/src/WimCert.cpp
wim/WimClient/src/WimSecModule.cpp
wim/WimServer/inc/WimCertHandler.h
wim/WimServer/inc/WimServer.h
wim/WimServer/src/WimCertHandler.cpp
wim/WimServer/src/WimMemMgmt.cpp
wim/WimServer/src/WimServer.cpp
wim/inc/ScardReader.h
--- a/gba/common/GBALogger.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/gba/common/GBALogger.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -22,155 +22,159 @@
 #include    <flogger.h>
 
 const TInt KDebugBufferSize1024 = 1024;
-const TInt KDebugBufferSize240 = 240;
-const TInt KDebugBufferSize120 = 120;
+const TInt KDebugBufferSize512  = 512;
+const TInt KDebugBufferSize240  = 240;
+const TInt KDebugBufferSize120  = 120;
 
 _LIT(KTimeFormat, "%F%D/%M/%Y %J:%T:%S");
 
-void debuglineL(const char *a, void *arg1, void* arg1b, void *arg2, void *arg3, const char *arg4) 
+void debugline(const char *a, void *arg1, void* arg1b, void *arg2, void *arg3, const char *arg4) 
     {
-    
-    HBufC8* logbuf = HBufC8::NewLC( KDebugBufferSize1024 );
-    TPtr8 ptrlogbuf = logbuf->Des();
+    TBuf8<KDebugBufferSize1024> logbuffer;
+    TPtrC8 p((const TUint8 *)a);
+    TPtrC8 temp_arg4((const TUint8 *)arg4);
     
-    TPtrC8 p((const unsigned char *)a);
-    TPtrC8 temp_arg4((TUint8 *)arg4);
-    ptrlogbuf.Format(p, arg1,arg1b, arg2, arg3);
-    ptrlogbuf.Append(temp_arg4);
+    if( temp_arg4.Length() > KDebugBufferSize1024 - KDebugBufferSize120  )
+        return;
     
-    if ( logbuf->Length() <= KDebugBufferSize120 )
+    logbuffer.Format(p, arg1,arg1b, arg2, arg3);
+    logbuffer.Append(temp_arg4);
+    
+    if ( logbuffer.Length() <= KDebugBufferSize120 )
         {
         RFileLogger::WriteFormat( KGBALogDir, KGBALogFileName,
                                   EFileLoggingModeAppend, 
-                                  *logbuf );
+                                  logbuffer );
         }
     else
         {
         RFileLogger::WriteFormat( KGBALogDir, KGBALogFileName,
                                   EFileLoggingModeAppend, 
-                                  logbuf->Left( KDebugBufferSize120 ) );
+                                  logbuffer.Left( KDebugBufferSize120 ) );
         //max length is 150, print another line 
-        if (logbuf->Mid(KDebugBufferSize120).Length()<= KDebugBufferSize120 )
+        if (logbuffer.Mid(KDebugBufferSize120).Length()<= KDebugBufferSize120 )
             { 
             RFileLogger::WriteFormat( KGBALogDir, KGBALogFileName,
                                       EFileLoggingModeAppend, 
-                                      logbuf->Mid(KDebugBufferSize120) );
+                                      logbuffer.Mid(KDebugBufferSize120) );
             }
         else
             {
             RFileLogger::WriteFormat( KGBALogDir, KGBALogFileName,
                                       EFileLoggingModeAppend, 
-                                      logbuf->Mid(KDebugBufferSize120, KDebugBufferSize120) );
+                                      logbuffer.Mid(KDebugBufferSize120, KDebugBufferSize120) );
             RFileLogger::WriteFormat( KGBALogDir, KGBALogFileName,
                                       EFileLoggingModeAppend, 
-                                      logbuf->Mid(KDebugBufferSize240) );                           
-            }  
-                                  
-          }     
-    CleanupStack::PopAndDestroy( logbuf );
+                                      logbuffer.Mid(KDebugBufferSize240) );                           
+            }                
+          }
     }
 
 
-void debuglineL(const char *a, void *arg1, void* arg1b, void *arg2, void *arg3, const TDesC &arg4) 
+void debugline(const char *a, void *arg1, void* arg1b, void *arg2, void *arg3, const TDesC &arg4) 
     {
-    
-    HBufC8* logbuf = HBufC8::NewLC( KDebugBufferSize1024 );
-    TPtr8 ptrlogbuf = logbuf->Des();
+    TBuf8<KDebugBufferSize1024> logbuffer;
     
-    TPtrC8 p((const unsigned char *)a);
-    ptrlogbuf.Format(p, arg1,arg1b, arg2, arg3);
-    ptrlogbuf.Append(arg4);
+    if( arg4.Length() > KDebugBufferSize1024 - KDebugBufferSize120  )
+        return;
     
-    if ( logbuf->Length() <= KDebugBufferSize120 )
+    TPtrC8 p((const TUint8 *)a);
+    logbuffer.Format(p, arg1,arg1b, arg2, arg3);
+    logbuffer.Append(arg4);
+    
+    if ( logbuffer.Length() <= KDebugBufferSize120 )
         {
         RFileLogger::WriteFormat( KGBALogDir, KGBALogFileName,
                                   EFileLoggingModeAppend, 
-                                  *logbuf );
+                                  logbuffer );
         }
     else
         {
         RFileLogger::WriteFormat( KGBALogDir, KGBALogFileName,
                                   EFileLoggingModeAppend, 
-                                  logbuf->Left( KDebugBufferSize120 ) );
+                                  logbuffer.Left( KDebugBufferSize120 ) );
         //max length is 150, print another line 
-        if (logbuf->Mid(KDebugBufferSize120).Length()<= KDebugBufferSize120 )
+        if (logbuffer.Mid(KDebugBufferSize120).Length()<= KDebugBufferSize120 )
             { 
             RFileLogger::WriteFormat( KGBALogDir, KGBALogFileName,
                                       EFileLoggingModeAppend, 
-                                      logbuf->Mid(KDebugBufferSize120) );
+                                      logbuffer.Mid(KDebugBufferSize120) );
             }
         else
             {
             RFileLogger::WriteFormat( KGBALogDir, KGBALogFileName,
                                       EFileLoggingModeAppend, 
-                                      logbuf->Mid(KDebugBufferSize120, KDebugBufferSize120) );
+                                      logbuffer.Mid(KDebugBufferSize120, KDebugBufferSize120) );
             RFileLogger::WriteFormat( KGBALogDir, KGBALogFileName,
                                       EFileLoggingModeAppend, 
-                                      logbuf->Mid(KDebugBufferSize240) );                          	
-            }  
-                                  
-    	  }     
-    CleanupStack::PopAndDestroy( logbuf );
+                                      logbuffer.Mid(KDebugBufferSize240) );                          	
+            }        
+    	  }
     }
 
-void debuglineL(const char *a, void *arg1, void *arg1b, void *arg2, void *arg3, const TDesC8 &arg4) 
-    {
-    HBufC8* logbuf = HBufC8::NewLC( KDebugBufferSize1024 );
-    TPtr8 ptrlogbuf = logbuf->Des();
-    TPtrC8 p((const unsigned char *)a);
-    ptrlogbuf.Format(p, arg1,arg1b, arg2, arg3);
-    ptrlogbuf.Append(arg4);
-    if ( logbuf->Length() <= KDebugBufferSize120 )
+void debugline(const char *a, void *arg1, void *arg1b, void *arg2, void *arg3, const TDesC8 &arg4) 
+    {  
+    TBuf8<KDebugBufferSize1024> logbuffer;
+    
+    if( arg4.Length() > KDebugBufferSize1024 - KDebugBufferSize120)
+        return;
+    
+    TPtrC8 p((const TUint8 *)a);
+    logbuffer.Format(p, arg1,arg1b, arg2, arg3);
+    logbuffer.Append(arg4); 
+    
+    if ( logbuffer.Length() <= KDebugBufferSize120 )
         {
         RFileLogger::WriteFormat( KGBALogDir, KGBALogFileName,
                                   EFileLoggingModeAppend, 
-                                  *logbuf );
+                                  logbuffer );
         }
     else
         {
         RFileLogger::WriteFormat( KGBALogDir, KGBALogFileName,
                                   EFileLoggingModeAppend, 
-                                  logbuf->Left(KDebugBufferSize120) );
+                                  logbuffer.Left(KDebugBufferSize120) );
         //max length is 150, print another line 
         
-        if (logbuf->Mid(KDebugBufferSize120).Length()<= KDebugBufferSize120 )
+        if (logbuffer.Mid(KDebugBufferSize120).Length()<= KDebugBufferSize120 )
             { 
             RFileLogger::WriteFormat( KGBALogDir, KGBALogFileName,
                                       EFileLoggingModeAppend, 
-                                      logbuf->Mid(KDebugBufferSize120) );
+                                      logbuffer.Mid(KDebugBufferSize120) );
             }
         else
             {
             RFileLogger::WriteFormat( KGBALogDir, KGBALogFileName,
                                       EFileLoggingModeAppend, 
-                                      logbuf->Mid(KDebugBufferSize120, KDebugBufferSize120) );
+                                      logbuffer.Mid(KDebugBufferSize120, KDebugBufferSize120) );
             RFileLogger::WriteFormat( KGBALogDir, KGBALogFileName,
                                       EFileLoggingModeAppend, 
-                                      logbuf->Mid(KDebugBufferSize240) );                          	
+                                      logbuffer.Mid(KDebugBufferSize240) );                          	
             }                               
     	  }     
-    CleanupStack::PopAndDestroy( logbuf );     
     }
 
-void debuglineL(const char *a, void *arg1, void *arg1b, void *arg2, void *arg3, const char *arg4, const TInt& aNum ) 
+void debugline(const char *a, void *arg1, void *arg1b, void *arg2, void *arg3, const char *arg4, const TInt& aNum ) 
     {
-    HBufC8* logbuf = HBufC8::NewLC( KDebugBufferSize120 );
-    TPtr8 ptrlogbuf = logbuf->Des();
+    TBuf8<KDebugBufferSize512> logbuf;
     TPtrC8 temp_arg4((TUint8 *)arg4);
-    ptrlogbuf.Format( temp_arg4, aNum );
-     
-    debuglineL(a, arg1, arg1b, arg2, arg3, *logbuf);
-    CleanupStack::PopAndDestroy( logbuf );
+    
+    if( temp_arg4.Length() > KDebugBufferSize512 - KDebugBufferSize120)
+        return;
+    
+    logbuf.Format( temp_arg4, aNum );
+    debugline(a, arg1, arg1b, arg2, arg3, logbuf);
     }
 
-void debuglineL(const char *a, void *arg1, void *arg1b, void *arg2, void *arg3, const TDesC &arg4, const TInt& aNum ) 
+void debugline(const char *a, void *arg1, void *arg1b, void *arg2, void *arg3, const TDesC &arg4, const TInt& aNum ) 
     {
-    HBufC* logbuf = HBufC::NewLC(KDebugBufferSize120);
-    TPtr ptrlogbuf = logbuf->Des();
-    ptrlogbuf.Format( arg4, aNum );
+    TBuf<KDebugBufferSize512> logbuf;
     
-    debuglineL(a, arg1, arg1b, arg2, arg3, *logbuf);
-    CleanupStack::PopAndDestroy( logbuf );
+    if( arg4.Length() > KDebugBufferSize512 - KDebugBufferSize120 )
+        return;
+    
+    logbuf.Format( arg4, aNum );
+    debugline(a, arg1, arg1b, arg2, arg3, logbuf);
     }    
 
 void DebugBinary( const TDesC8 &buf ) 
@@ -180,10 +184,12 @@
        NULL, NULL , buf.Ptr(), buf.Length() );
     } 
 
-void debugTTimeL( TTime& aTime )
+void debugTTime( TTime& aTime )
     {
     TBuf<KDebugBufferSize120> buf;
-    aTime.FormatL( buf, KTimeFormat);
+    TRAPD(error , aTime.FormatL( buf, KTimeFormat));
+    if(error != KErrNone)
+        return;
     RFileLogger::WriteFormat( KGBALogDir, KGBALogFileName,
                              EFileLoggingModeAppend, 
                              buf );
--- a/gba/gbafilter/src/HTTPFilterGBA.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/gba/gbafilter/src/HTTPFilterGBA.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -298,6 +298,7 @@
             GBA_TRACE_DEBUG(("Event: EFailed"));			
 			Cleanup( aTransaction );		
 		}
+		break;
 		default: 
 		{
             GBA_TRACE_DEBUG_NUM(("Unknow Event: ID - %d" ), aEvent.iStatus );
@@ -752,7 +753,9 @@
     {
 	THTTPHdrVal fieldVal;// The name of the current field.
 	THTTPHdrVal hdrVal;//A scratch hdrVal
-	headers.GetField(wwwAuthenticate, ii, fieldVal);
+	TInt error = headers.GetField(wwwAuthenticate, ii, fieldVal);
+	if( error != KErrNone )
+	    return lastGoodBasic;
 	TInt x = fieldVal.StrF().Index(RHTTPSession::GetTable());
 	GBA_TRACE_DEBUG_NUM((" FindHeaderPartToUseL part no:1 = %d"), x );
 	switch (fieldVal.StrF().Index(RHTTPSession::GetTable()))
--- a/gba/gbaserver/src/dataretriever.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/gba/gbaserver/src/dataretriever.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -829,7 +829,14 @@
            {
            THTTPHdrVal requestUri;
            RHTTPTransactionPropertySet propSet = aTransaction.PropertySet();
-           propSet.Property( stringPool.StringF(HTTP::EUri,RHTTPSession::GetTable()), requestUri );
+           TBool exist = propSet.Property( stringPool.StringF(HTTP::EUri,RHTTPSession::GetTable()), requestUri );
+           
+           if(!exist)
+               {
+               CleanupStack::PopAndDestroy( pushCount ); 
+               return KErrNotFound;
+               }
+           
            //save rsp auth calcuation
            //Save the string handle for rsp auth checking
            //Close the previous handle, then set new one
@@ -906,7 +913,14 @@
     {
     THTTPHdrVal fieldVal;// The name of the current field.
     THTTPHdrVal hdrVal;//A scratch hdrVal
-    headers.GetField(wwwAuthenticate, i, fieldVal);
+    
+    TInt error = headers.GetField(wwwAuthenticate, i, fieldVal);
+    
+    if(error != KErrNone)
+        {
+        return KErrNotFound;
+        }
+    
     switch ( fieldVal.StrF().Index(RHTTPSession::GetTable() ) )
         {
         case HTTP::EDigest:
--- a/gba/inc/GBALogger.h	Tue Feb 02 00:44:34 2010 +0200
+++ b/gba/inc/GBALogger.h	Fri Feb 19 23:42:03 2010 +0200
@@ -27,17 +27,17 @@
 
 #ifdef _DEBUG
 
-    void debuglineL(const char *a, void *arg1, void* f, void *arg2, void *arg3, const TDesC &arg4);
-    void debuglineL(const char *a, void *arg1, void* f, void *arg2, void *arg3, const TDesC8 &arg4);
-    void debuglineL(const char *a, void *arg1, void* f, void *arg2, void *arg3, const char *arg4, const TInt &aNum);
-    void debuglineL(const char *a, void *arg1, void* f, void *arg2, void *arg3, const TDesC8 &arg4, const TInt &aNum);
+    void debugline(const char *a, void *arg1, void* f, void *arg2, void *arg3, const TDesC &arg4);
+    void debugline(const char *a, void *arg1, void* f, void *arg2, void *arg3, const TDesC8 &arg4);
+    void debugline(const char *a, void *arg1, void* f, void *arg2, void *arg3, const char *arg4, const TInt &aNum);
+    void debugline(const char *a, void *arg1, void* f, void *arg2, void *arg3, const TDesC8 &arg4, const TInt &aNum);
     void DebugBinary(const TDesC8 &buf);
-    void debugTTimeL( TTime& aTime );
-    void debuglineL(const char *a, void *arg1, void* f, void *arg2, void *arg3, const char *arg4);
+    void debugTTime( TTime& aTime );
+    void debugline(const char *a, void *arg1, void* f, void *arg2, void *arg3, const char *arg4);
 
     #define GBA_DEBUG
-    #define GBA_TRACE_DEBUG_DESC(a) debuglineL("%s:%s %d: %d",(void *) __FILE__, (void *) __func__, (void *)__LINE__, (void *)User::TickCount(),(a))
-    #define GBA_TRACE_DEBUG_NUM( a,b ) debuglineL("%s:%s %d: %d",(void *) __FILE__, (void *) __func__, (void *)__LINE__, (void *)User::TickCount(),(a),b)
+    #define GBA_TRACE_DEBUG_DESC(a) debugline("%s:%s %d: %d",(void *) __FILE__, (void *) __func__, (void *)__LINE__, (void *)User::TickCount(),(a))
+    #define GBA_TRACE_DEBUG_NUM( a,b ) debugline("%s:%s %d: %d",(void *) __FILE__, (void *) __func__, (void *)__LINE__, (void *)User::TickCount(),(a),b)
     
 #ifdef LOG_GBA_KEYS
     #define GBA_TRACE_DEBUG_BINARY(a) DebugBinary((a));
@@ -45,10 +45,10 @@
     #define GBA_TRACE_DEBUG_BINARY(a)
 #endif 
     
-    #define GBA_TRACE_BEGIN() debuglineL("%s:%s %d: %d",(void *) __FILE__, (void *) __func__, (void *)__LINE__, (void *)User::TickCount(),(KEnter))
-    #define GBA_TRACE_END() debuglineL("%s:%s %d: %d",(void *) __FILE__, (void *) __func__, (void *)__LINE__, (void *)User::TickCount(),(KEnd))
-    #define GBA_TRACE_TIME( a ) debugTTimeL( (a) );
-    #define GBA_TRACE_DEBUG(a) debuglineL("%s:%s %d: %d",(void *) __FILE__, (void *) __func__, (void *)__LINE__, (void *)User::TickCount(),(a))
+    #define GBA_TRACE_BEGIN() debugline("%s:%s %d: %d",(void *) __FILE__, (void *) __func__, (void *)__LINE__, (void *)User::TickCount(),(KEnter))
+    #define GBA_TRACE_END() debugline("%s:%s %d: %d",(void *) __FILE__, (void *) __func__, (void *)__LINE__, (void *)User::TickCount(),(KEnd))
+    #define GBA_TRACE_TIME( a ) debugTTime( (a) );
+    #define GBA_TRACE_DEBUG(a) debugline("%s:%s %d: %d",(void *) __FILE__, (void *) __func__, (void *)__LINE__, (void *)User::TickCount(),(a))
 
 #else
 
--- a/gba/sis/gba.pkg	Tue Feb 02 00:44:34 2010 +0200
+++ b/gba/sis/gba.pkg	Fri Feb 19 23:42:03 2010 +0200
@@ -17,7 +17,7 @@
 &EN
 
 ; Header
-#{"GBA (Beta)"},(0x2000F867), 0, 3, 0, TYPE=SA,RU
+#{"GBA (Beta)"},(0x2000F867), 0, 4, 0, TYPE=SA,RU
 
 ; Localised Vendor name
 %{"Nokia"}
--- a/gba/uicc/src/GbaAkaIsa.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/gba/uicc/src/GbaAkaIsa.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -34,6 +34,7 @@
 const TInt KIntegerConstant4 = 4;
 const TInt KIntegerConstant16 = 16;
 const TInt KIntegerConstant32 = 32;
+const TInt KMaximumKcSize     = 8;
 
 _LIT8( KAT, "@" );
 _LIT8( KIMSMNC, "ims.mnc" );
@@ -330,19 +331,21 @@
     
     GBA_TRACE_DEBUG(("Creating 2G authentication vector KDF(key,\"3gpp-gba-res\",sres)"));
     GBA_TRACE_DEBUG_BINARY(authSIMdata.iSRES);
+    GBA_TRACE_DEBUG_NUM(("SRES size = %d"), authSIMdata.iSRES.Size() );
     GBA_TRACE_DEBUG_BINARY(authSIMdata.iKC);
+    GBA_TRACE_DEBUG_NUM(("Kc size = %d"), authSIMdata.iKC.Size() );
     
     TBuf8<KMaxBufferSize> lastSRESKC;
-    TBuf8<2*RMmCustomAPI::KMaxKCLength+KAKA_RAND_LENGTH> kc2;
+    TBuf8< 2*KMaximumKcSize + KAKA_RAND_LENGTH > kc2;
     
     // COPYING Kc twice
     GBA_TRACE_DEBUG(("Copying iKC"));
-    for( TInt  i=0; i<(RMmCustomAPI::KMaxKCLength) ; i++ )
+    for( TInt  i=0; i<KMaximumKcSize; i++ )
         {
         kc2.Append(  (TUint8)(authSIMdata.iKC[i]) );
         }
     GBA_TRACE_DEBUG(("Copying iKC"));
-    for( TInt  i=0;i<(RMmCustomAPI::KMaxKCLength);i++ )
+    for( TInt  i=0; i<KMaximumKcSize; i++ )
         {
         kc2.Append(  (TUint8)(authSIMdata.iKC[i]) );
         }
@@ -351,7 +354,7 @@
     
     GBA_TRACE_DEBUG(("K part"));
     GBA_TRACE_DEBUG_BINARY(kc2);
-    
+    GBA_TRACE_DEBUG_NUM(("Key size = %d"), kc2.Size() );
     // appending RAND
     lastSRESKC.Append( 0x01);
     lastSRESKC.Append(K3GPPGBARES);
@@ -803,8 +806,9 @@
 
         GBA_TRACE_DEBUG_NUM(("QueryCardInterfaceL: GBA_U avail checking is Done, err = %d"), status.Int());
     
-        if ( status.Int() == KErrNotFound )
+        if ( status.Int() == KErrNotFound ||  status.Int() == KErrNotSupported)
             {
+			//If the GetUSIMServiceSupport API returnS KErrNotSupported,need to force 3G GBA_ME[E3GInterface]
             //Not gba-u service available
             GBA_TRACE_DEBUG(("QueryCardInterfaceL: it returns KErrNotFound, No GBA-U "));
             // set interface as 3g then
@@ -839,7 +843,8 @@
         }
     else
         {
-        //nothing	
+        // leave
+        User::LeaveIfError(KErrNotSupported);
         }
     }
 
--- a/pkiutilities/CTSecurityDialogs/NotifInc/CTSecurityDialogsAO.h	Tue Feb 02 00:44:34 2010 +0200
+++ b/pkiutilities/CTSecurityDialogs/NotifInc/CTSecurityDialogsAO.h	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-2010 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"
@@ -264,8 +264,6 @@
 
         void MapTlsProviderOperation( TUint aOperation );
 
-        TPtrC CutCertificateField(const TDesC&  aField);
-
         /**
         * Completes client's request
         */
@@ -275,7 +273,7 @@
         * Checks that are two PINs the same
         */
         void VerifyPinsL();
-        
+
     private:    // Data
         RMessagePtr2 iMessagePtr;
         TSecurityDialogNotification iOperation;
@@ -302,7 +300,7 @@
         CCertAttributeFilter* iFilter;
         RFs iFs;
         CCTCertInfo* iCertInfo;
-        CDesCArrayFlat*  iCertArray;        
+        CDesCArrayFlat*  iCertArray;
         RMPointerArray<CCTCertInfo> iCertInfos;
         HBufC8* iCertBuf;
         MCTWritableCertStore *iTrustedSiteCertStore;
@@ -322,12 +320,12 @@
 
         TSaveCertInput iSaveCertInput;
         TValidationError iAuthFailReason;
-        
+
         TBool& iDeleted;
-        
+
         CAknQueryDialog* iQueryDialog;
         TBool iQueryDialogDeleted;
-        
+
         CCTPinQueryDialog* iPinQueryDialog;
         TBool iPinQueryDialogDeleted;
         };
--- a/pkiutilities/CTSecurityDialogs/NotifSrc/CTSecurityDialogsAO.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/pkiutilities/CTSecurityDialogs/NotifSrc/CTSecurityDialogsAO.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-2010 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"
@@ -11,7 +11,7 @@
 *
 * Contributors:
 *
-* Description: 
+* Description:
 *
 */
 
@@ -49,8 +49,6 @@
 // LOCAL CONSTANTS AND MACROS
 const TInt KCertArrayGranularity = 3;
 const TInt KMaxLengthTextDetailsBody = 5000;
-// CertLabel, Issuer, Owner max length 510 bytes
-const TInt KMaxLengthTextCertLabel = 510;
 // CertLabel, Issuer, Owner max visible length
 const TInt KMaxLengthTextCertLabelVisible = 200;
 // "dd/mm/yyyy0"
@@ -165,7 +163,7 @@
     delete iKeyStore;
     delete iCertStore;
     iFs.Close();
-    
+
     iDeleted = ETrue;
     }
 
@@ -186,7 +184,7 @@
     iMessagePtr = aMessage;
 
     WIMSECURITYDIALOGS_WRITE_FORMAT( "CCTSecurityDialogsAO::StartLD iOperation=%d", iOperation );
-    
+
     MapTlsProviderOperation( iOperation );
 
     switch ( iOperation )
@@ -326,7 +324,7 @@
             User::Panic( _L("CTestSecDlgNotifier"), 0 );
             break;
         }
-    
+
     // Note that CCTSecurityDialogsAO::StartLD() must complete the given message and
     // delete itself when ready. However, there may be several steps before it can be
     // deleted. CCTSecurityDialogsAO::HandleResponseAndCompleteL() completes the given
@@ -543,7 +541,7 @@
         DoHandleMessageL( EErrorPukCodeIncorrect, KNullDesC, KNullDesC, 0, 0 );
       }
     // Ask the PUK code
-    // The label is iPIN instead of iUnblockPIN, since we need to show to 
+    // The label is iPIN instead of iUnblockPIN, since we need to show to
     // the user which PIN to unblock
     DoHandleMessageL( EEnterPukNR, iPIN.iPINLabel,
         iPIN.iTokenLabel, iUnblockPIN.iMinLength, iUnblockPIN.iMaxLength );
@@ -762,8 +760,8 @@
                                         aMinLength,
                                         aMaxLength,
                                         iRetValue,
-                                        resource, 
-                                        iPinQueryDialog, 
+                                        resource,
+                                        iPinQueryDialog,
                                         iPinQueryDialogDeleted );
                 break;
             }
@@ -1000,64 +998,64 @@
       case EProcessTrustedSite:
         {
         WIMSECURITYDIALOGS_WRITE( "EProcessTrustedSite" );
-            TInt count = iCertStore->WritableCertStoreCount();
-            for ( TInt i = 0; i < count; i++ )
+        TInt count = iCertStore->WritableCertStoreCount();
+        for ( TInt i = 0; i < count; i++ )
+            {
+            MCTWritableCertStore *certstore = &iCertStore->WritableCertStore( i );
+            MCTToken& token = certstore->Token();
+            TUid tokenuid = token.Handle().iTokenTypeUid;
+            if ( tokenuid == KTrustedServerTokenUid )
                 {
-                MCTWritableCertStore *certstore = &iCertStore->WritableCertStore( i );
-                MCTToken& token = certstore->Token();
-                TUid tokenuid = token.Handle().iTokenTypeUid;
-                if ( tokenuid == KTrustedServerTokenUid )
-                    {
-                    iTrustedSiteCertStore = certstore;
-                    }
+                iTrustedSiteCertStore = certstore;
                 }
+            }
 
-                CTrustSitesStore* trustedSitesStore = CTrustSitesStore::NewL();
-                CleanupStack::PushL( trustedSitesStore );
+        CTrustSitesStore* trustedSitesStore = CTrustSitesStore::NewL();
+        CleanupStack::PushL( trustedSitesStore );
 
-                // Find out whether or not site associated with certificate is trusted
-                iTrustedSite = trustedSitesStore->IsTrustedSiteL( *iCertBuf, *iServerName );
+        // Find out whether or not site associated with certificate is trusted
+        iTrustedSite = trustedSitesStore->IsTrustedSiteL( *iCertBuf, *iServerName );
 
-                if ( iTrustedSite )
-                    {
-                    TBool allowOutOfDate = trustedSitesStore->IsOutOfDateAllowedL(*iCertBuf, *iServerName );	
-                
-                    if (!allowOutOfDate)
-                        {
-                        CX509Certificate* cert = CX509Certificate::NewLC( iCertBuf->Des() );
+        if ( iTrustedSite )
+            {
+            TBool allowOutOfDate = trustedSitesStore->IsOutOfDateAllowedL(*iCertBuf, *iServerName);
+
+            if (!allowOutOfDate)
+                {
+                CX509Certificate* cert = CX509Certificate::NewLC( iCertBuf->Des() );
 
-                        const CValidityPeriod& validityPeriod = cert->ValidityPeriod();
-                        const TTime& startValue = validityPeriod.Start();
-                        const TTime& finishValue = validityPeriod.Finish();
-                        TTime current;
-                        current.UniversalTime();
+                const CValidityPeriod& validityPeriod = cert->ValidityPeriod();
+                const TTime& startValue = validityPeriod.Start();
+                const TTime& finishValue = validityPeriod.Finish();
+                TTime current;
+                current.UniversalTime();
 
-                        // First check certificate validity period
-                        if ( ( startValue > current ) || ( finishValue < current ) )
-                            {
-                            iTrustedSite = EFalse;	
-                            }
-                    
-                        CleanupStack::PopAndDestroy(); //cert
-                        }
+                // First check certificate validity period
+                if ( ( startValue > current ) || ( finishValue < current ) )
+                    {
+                    iTrustedSite = EFalse;
                     }
-                CleanupStack::PopAndDestroy( trustedSitesStore ); // trustedSitesStore
+
+                CleanupStack::PopAndDestroy( cert );
+                }
+            }
+        CleanupStack::PopAndDestroy( trustedSitesStore );
 
-                if ( iTrustedSite )
-                    {
-                    // Site is trusted. Next step is to check that server
-                    // certificate is in the trusted site certificate storage
-                    iNextStep = ERetrieveServerCerts;
-                    iStatus = KRequestPending;
-                    SetActive();
-                    TRequestStatus* status = &iStatus;
-                    User::RequestComplete( status, KErrNone );
-                    }
-                 else
-                    {
-                    // Site is not trusted. Prompt user
-                    ShowNoTrustDialogL();
-                    }
+        if ( iTrustedSite )
+            {
+            // Site is trusted. Next step is to check that server
+            // certificate is in the trusted site certificate storage
+            iNextStep = ERetrieveServerCerts;
+            iStatus = KRequestPending;
+            SetActive();
+            TRequestStatus* status = &iStatus;
+            User::RequestComplete( status, KErrNone );
+            }
+         else
+            {
+            // Site is not trusted. Prompt user
+            ShowNoTrustDialogL();
+            }
 
         break;
         }
@@ -1394,7 +1392,7 @@
 void CCTSecurityDialogsAO::DoHandleSelectCertificateL()
     {
     TBool foundDevCert = EFalse;
-    
+
     // Check certificate list to find out if there is certificate from
     // Device Certificate Store.
     for ( TInt ii = 0; ii < iCertHandleList.Count(); ii++)
@@ -1402,28 +1400,28 @@
         TCTTokenObjectHandle handle = iCertHandleList[ii];
         if ( handle.iTokenHandle.iTokenTypeUid == KDeviceCertStoreTokenUid )
             {
-            // Found a certificate from Device Certificate Store. 
+            // Found a certificate from Device Certificate Store.
             foundDevCert = ETrue;
-            iTokenHandle = handle;                        
-            iRetValue = ETrue;            
+            iTokenHandle = handle;
+            iRetValue = ETrue;
             iNextStep = EOperationCompleted;
             iStatus = KRequestPending;
             SetActive();
             TRequestStatus* status = &iStatus;
-            User::RequestComplete( status, KErrNone );            
+            User::RequestComplete( status, KErrNone );
             break;
             }
-        
+
         }
-    
+
     if ( !foundDevCert )
-        { 
+        {
         // No certificate from Device Certificate Store. Prompt user
         // for certificate selection
         CCTSelectCertificateDialog::RunDlgLD(
             iCertArray, iCertHandleList, iTokenHandle,
             iStatus, iRetValue ); // Takes ownerhip of array
-        
+
         iNextStep = EOperationCompleted;
         iStatus = KRequestPending;
         SetActive();
@@ -1439,7 +1437,7 @@
     CX509Certificate* cert = CX509Certificate::NewLC( iCertBuf->Des() );
     TInt resourceid = R_WIM_NO_TRUST_QUERY_UNTRUSTED;
     TBool showPermAccept = ETrue;
-    
+
     if( iAuthFailReason == ESignatureInvalid || iAuthFailReason == ECertificateRevoked )
         {
         // Invalid or revoked certificate
@@ -1453,13 +1451,13 @@
         if( iAuthFailReason == EValidatedOK || iAuthFailReason == EDateOutOfRange )
             {
             // Trusted certificate, but problems with CN or date
-            
+
             // Retrieve subject name
             const CX500DistinguishedName& dName = cert->SubjectName();
-    
+
             // Retrieve common name
             HBufC* cn = dName.ExtractFieldL( KX520CommonName );
-    
+
             // Check common name first and then date
             if( !cn )
                 {
@@ -1496,7 +1494,7 @@
         const TTime& finishValue = validityPeriod.Finish();
         TTime current;
         current.UniversalTime();
-    
+
         if( (( startValue > current ) || ( finishValue < current )) ||
                 ( iServerName->Des().Length() == 0 ) )
             {
@@ -2234,47 +2232,32 @@
 // HBufC& aMessage, TPtrC aValue, TInt aResourceOne)
 // Reads dynamic text, if the string is empty
 // put a not defined text from the resource in its place
-// KMaxLengthTextCertLabel = 510, used by CertLabel(), Issuer(), Owner()
 // ---------------------------------------------------------
 //
 void CCTSecurityDialogsAO::DetailsDynamicL(
     TDes& aMessage, const TDesC& aValue, TInt aResource)
     {
-    HBufC* buf = HBufC::NewLC( KMaxLengthTextCertLabel );
-    buf->Des() = aValue;
-    buf->Des().TrimLeft();
-    // Cut CertLabel after fourth semi colon
-    TPtrC trimmedCertLabel = CutCertificateField( buf->Des() );
-    buf->Des().Copy( trimmedCertLabel );
-    TInt length = buf->Des().Length();
-    if (length == 0 )
+    HBufC* buf = aValue.AllocLC();
+    TPtr trimmedValue( buf->Des() );
+    trimmedValue.TrimLeft();
+
+    if( trimmedValue.Length() > KMaxLengthTextCertLabelVisible )
+        {
+        trimmedValue.SetLength( KMaxLengthTextCertLabelVisible - 1 );
+        trimmedValue.Append( KTextUtilClipEndChar );
+        }
+
+    if( trimmedValue.Length() == 0 )
         {
         DetailsResourceL( aMessage, aResource );
         }
     else
         {
-        aMessage.Append( buf->Des() );
+        aMessage.Append( trimmedValue );
         aMessage.Append( KEnter );
         }
-    CleanupStack::PopAndDestroy();  // buf
-    }
 
-// ---------------------------------------------------------
-// CCTSecurityDialogsAO::CutCertificateField(TPtrC aField)
-// If CertLabel, Issuer and Owner length is over 80 characters,
-// cut it down to 80
-// Returns the cut certificate field.
-// ---------------------------------------------------------
-//
-TPtrC CCTSecurityDialogsAO::CutCertificateField( const TDesC&  aField )
-    {
-    TInt fieldLength = aField.Length();
-    if ( fieldLength >= KMaxLengthTextCertLabelVisible )
-        {
-        TPtrC cutCertLabel = aField.Mid( 0, KMaxLengthTextCertLabelVisible );
-        return cutCertLabel;
-        }
-    return aField;
+    CleanupStack::PopAndDestroy( buf );
     }
 
 // -----------------------------------------------------------------------------
@@ -2375,12 +2358,12 @@
         default:
             User::Panic( _L("CTestSecDlgNotifier"), 0 );
         }
-    
+
     if( iOperation != EServerAuthenticationFailure )
         {
         iMessagePtr.Complete( iRetValue ? KErrNone : KErrCancel );
         }
-    
+
     delete this;
     }
 
@@ -2429,14 +2412,14 @@
         iQueryDialogDeleted = ETrue;
         }
     iQueryDialog = NULL;
-    
+
     if ( !iPinQueryDialogDeleted )
         {
         delete iPinQueryDialog;
         iPinQueryDialogDeleted = ETrue;
         }
     iPinQueryDialog = NULL;
-    
+
     // Complete message if it has not been completed earlier.
     if( !iMessagePtr.IsNull() )
         {
--- a/pkiutilities/CertmanUi/SRC/CertmanuicontainerAuthority.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/pkiutilities/CertmanUi/SRC/CertmanuicontainerAuthority.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2003-2010 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"
@@ -79,12 +79,7 @@
     CreateWindowL();
     CreateListBoxL();
     UpdateListBoxL( aCurrentPosition, aTopItem );
-    if ( iListBox )
-        {
-        // Creates graphic.
-        iListBox->ItemDrawer()->ColumnData()->
-            SetIconArray( iIconHandler->CreateIconArrayL() );
-        }
+    iListBox->ItemDrawer()->ColumnData()->SetIconArray( iIconHandler->CreateIconArrayL() );
     SetRect( aRect );
 
     CERTMANUILOGGER_LEAVEFN( " CCertManUIContainerAuthority::ConstructL" );
--- a/pkiutilities/CertmanUi/SRC/CertmanuicontainerDevice.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/pkiutilities/CertmanUi/SRC/CertmanuicontainerDevice.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2003-2010 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"
@@ -80,14 +80,7 @@
     CreateWindowL();
     CreateListBoxL();
     UpdateListBoxL( aCurrentPosition, aTopItem );
-
-    if ( iListBox )
-        {
-        // Creates graphic.
-        iListBox->ItemDrawer()->ColumnData()->
-        SetIconArray( iIconHandler->CreateIconArrayL() );
-    }
-
+    iListBox->ItemDrawer()->ColumnData()->SetIconArray( iIconHandler->CreateIconArrayL() );
     SetRect( aRect );
 
     CERTMANUILOGGER_LEAVEFN( " CCertManUIContainerDevice::ConstructL" );
--- a/pkiutilities/CertmanUi/SRC/CertmanuicontainerPersonal.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/pkiutilities/CertmanUi/SRC/CertmanuicontainerPersonal.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2003-2010 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"
@@ -79,12 +79,7 @@
     CreateWindowL();
     CreateListBoxL();
     UpdateListBoxL( aCurrentPosition, aTopItem );
-    if ( iListBox )
-        {
-        // Creates graphic.
-        iListBox->ItemDrawer()->ColumnData()->
-            SetIconArray( iIconHandler->CreateIconArrayL() );
-        }
+    iListBox->ItemDrawer()->ColumnData()->SetIconArray( iIconHandler->CreateIconArrayL() );
     SetRect( aRect );
 
     CERTMANUILOGGER_LEAVEFN( " CCertManUIContainerPersonal::ConstructL" );
--- a/pkiutilities/CertmanUi/SRC/CertmanuicontainerTrustedSite.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/pkiutilities/CertmanUi/SRC/CertmanuicontainerTrustedSite.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2003-2010 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"
@@ -78,12 +78,7 @@
     CreateWindowL();
     CreateListBoxL();
     UpdateListBoxL( aCurrentPosition, aTopItem );
-    if ( iListBox )
-        {
-        // Creates graphic.
-        iListBox->ItemDrawer()->ColumnData()->
-             SetIconArray( iIconHandler->CreateIconArrayL() );
-    }
+    iListBox->ItemDrawer()->ColumnData()->SetIconArray( iIconHandler->CreateIconArrayL() );
     SetRect( aRect );
 
     CERTMANUILOGGER_LEAVEFN( " CCertManUIContainerTrustedSite::ConstructL" );
--- a/pkiutilities/CertmanUi/SRC/CertmanuiviewPersonal.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/pkiutilities/CertmanUi/SRC/CertmanuiviewPersonal.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2003-2010 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"
@@ -496,11 +496,17 @@
     {
     CERTMANUILOGGER_ENTERFN( "CCertManUIViewPersonal::DoDeactivate" );
 
-    iCurrentPosition = iContainerPersonal->iListBox->CurrentItemIndex();
-    iTopItem = iContainerPersonal->iListBox->TopItemIndex();
-    if ( iContainerPersonal )
+    if( iContainerPersonal )
         {
-        ((CAknViewAppUi*)iAvkonAppUi)->RemoveFromViewStack(*this, iContainerPersonal);
+        CEikColumnListBox* listBox = iContainerPersonal->iListBox;
+        if( listBox )
+            {
+            iCurrentPosition = listBox->CurrentItemIndex();
+            iTopItem = listBox->TopItemIndex();
+            }
+
+        iAvkonAppUi->RemoveFromViewStack( *this, iContainerPersonal );
+
         delete iContainerPersonal;
         iContainerPersonal = NULL;
         }
--- a/pkiutilities/DeviceToken/Src/Generic/Client/DevTokenClientSession.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/pkiutilities/DeviceToken/Src/Generic/Client/DevTokenClientSession.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -50,11 +50,11 @@
     RProcess server;  
     TInt r = server.Create(KDevTokenServerImg, KNullDesC, serverUid);
     
-    RDebug::Print( _L(" StartServer ") );
+    TRACE_PRINT( "StartServer" );
     
     if ( r != KErrNone )
         {
-        RDebug::Print( _L("StartServer1 %d"), r );
+        TRACE_PRINT_NUM("StartServer1 %d", r );
         return r;
         }
 
@@ -72,19 +72,19 @@
         server.Resume();
         }
 
-    RDebug::Print( _L(" StartServer 2") );
+    TRACE_PRINT(" StartServer 2");
 
     // Wait to synchronise with server - if it dies in the meantime, it
     // also gets completed
     User::WaitForRequest(stat); 
     
-    RDebug::Print( _L(" StartServer 3") );
+    TRACE_PRINT(" StartServer 3");
     // We can't use the 'exit reason' if the server panicked as this
     // is the panic 'reason' and may be '0' which cannot be distinguished
     // from KErrNone
     r = (server.ExitType()==EExitPanic) ? KErrGeneral : stat.Int();
     
-    RDebug::Print( _L(" StartServer 4 %d"), r );
+    TRACE_PRINT_NUM(" StartServer 4 %d", r );
     
     server.Close();
     return (r);
@@ -159,13 +159,13 @@
         
         if ( r!=KErrNotFound && r!=KErrServerTerminated )
             {
-            RDebug::Print( _L("connect1 %d"), r );
+            TRACE_PRINT_NUM("connect1 %d", r );
             return r; 
             }
 
         if (--retry==0)
             {
-            RDebug::Print( _L(" connect2 %d"), r );
+            TRACE_PRINT_NUM(" connect2 %d", r );
             return r; 
             }
 
@@ -173,7 +173,7 @@
         
         if ( r!=KErrNone && r!=KErrAlreadyExists )
             {
-            RDebug::Print( _L(" connect3 %d"), r );
+            TRACE_PRINT_NUM(" connect3 %d", r );
             return r;  
             }
 
--- a/pkiutilities/DeviceToken/Src/Generic/Server/DevTokenUtil.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/pkiutilities/DeviceToken/Src/Generic/Server/DevTokenUtil.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -20,6 +20,7 @@
 #include <s32file.h>
 #include "DevTokenUtil.h"
 
+
 /// Read/write drive the stores reside on
 _LIT(KFileStoreStandardDrive, "C:");
 /// Rom drive where the initial store data is
@@ -59,18 +60,23 @@
 // ---------------------------------------------------------------------------
 // 
 TBool FileUtils::ExistsL(RFs& aFs, const TDesC& aFile)
-    {
+    {      
     TBool result = EFalse;
-    TBool open;
-    TInt err = aFs.IsFileOpen(aFile, open);
-
-    if (err == KErrNone)
+    TUint attributes;
+    
+    TInt err = aFs.Att( aFile, attributes );
+           
+    if ( err == KErrNone )
         {
         result = ETrue;
         }
-    else if (err != KErrNotFound && err != KErrPathNotFound)
+    else if ( err == KErrNotFound || err == KErrPathNotFound  ) 
         {
-        User::Leave(err);
+        result = EFalse;
+        }
+    else 
+        {
+        User::Leave( err );
         }
 
     return result;
--- a/pkiutilities/PKCS12/CrBer/Src/Crberset.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/pkiutilities/PKCS12/CrBer/Src/Crberset.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2000, 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2000, 2004, 2010 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"
@@ -817,8 +817,8 @@
             {
             handleThisTime = left;
             }
-        aData->Read(handled, ptr, handleThisTime);
-        iTarget->Write(ptr);
+        User::LeaveIfError( aData->Read(handled, ptr, handleThisTime) );
+        User::LeaveIfError( iTarget->Write(ptr) );
         ptr.Zero();
 
         handled = handled + handleThisTime;
--- a/pkiutilities/PKCS12/CrBer/Src/crdata.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/pkiutilities/PKCS12/CrBer/Src/crdata.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2000, 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2000, 2004, 2010 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"
@@ -519,7 +519,13 @@
         TDes8 tempDes = tempBuf->Des();
 
         // Read data to a buffer from iPointer to end of file
-        Read(currentPlace, tempDes, neededLengthToFind);
+        TInt readErr = Read(currentPlace, tempDes, neededLengthToFind);
+        if (readErr)
+            {
+            delete tempBuf;
+            tempBuf = NULL;
+            return readErr;
+            }
 
         // Find the next new line character
         newLinePlace = tempDes.Find(newLine);
--- a/pkiutilities/PKCS12/CrPkcs12/Inc/crcrypto.h	Tue Feb 02 00:44:34 2010 +0200
+++ b/pkiutilities/PKCS12/CrPkcs12/Inc/crcrypto.h	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2000, 2002, 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2000, 2002, 2004, 2010 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"
@@ -178,8 +178,8 @@
             const TInt        aBlockSize,
             CCrAlgInfo*       algInfo);
 
-        TInt MesDigestInputSize(TCrAlgorithm aDigestAlg);
-        TInt MesDigestOutputSize(TCrAlgorithm aDigestAlg);
+        TInt MesDigestInputSizeL(TCrAlgorithm aDigestAlg);
+        TInt MesDigestOutputSizeL(TCrAlgorithm aDigestAlg);
         void Reset();
     
     private: // Data.
--- a/pkiutilities/PKCS12/CrPkcs12/Src/crcrypto.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/pkiutilities/PKCS12/CrPkcs12/Src/crcrypto.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2000, 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2000, 2004, 2010 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"
@@ -41,10 +41,10 @@
 // -----------------------------------------------------------------------------
 CCrCrypto::~CCrCrypto()
     {
-    Reset();
-
     if( iAlgorithmInfos )
         {
+        Reset();
+
         iAlgorithmInfos->Reset();
         delete iAlgorithmInfos;
         iAlgorithmInfos = NULL;
@@ -713,8 +713,8 @@
     TInt remainder = 0;
     TInt rounds = 0;
     TInt pushedToCStack = 0;
-    TInt inputSize = MesDigestInputSize(aHashFunc);
-    TInt outputSize = MesDigestOutputSize(aHashFunc);
+    TInt inputSize = MesDigestInputSizeL(aHashFunc);
+    TInt outputSize = MesDigestOutputSizeL(aHashFunc);
 
     // Step 1: Construct D by concatenating copies of ID.
     // Construct a string D
@@ -865,12 +865,12 @@
 }
 
 // -----------------------------------------------------------------------------
-// CCrCrypto::MesDigestInputSize
+// CCrCrypto::MesDigestInputSizeL
 // Returns input size of the message digest algorithm. 
 // Return Values:      Input size of the message digest algorithm in bytes.
-//                     If unknown algorithm returns -1.      
+//                     If unknown algorithm, leaves with KErrNotSupported.
 // -----------------------------------------------------------------------------
-TInt CCrCrypto::MesDigestInputSize(TCrAlgorithm aDigestAlg)
+TInt CCrCrypto::MesDigestInputSizeL( TCrAlgorithm aDigestAlg )
     {
     switch(aDigestAlg)
         {
@@ -882,19 +882,20 @@
             }
         default:
             {
-            return -1;
+            User::Leave( KErrNotSupported );
+            return -1;  // keeps compiler happy
             }
         }
     }
 
 // -----------------------------------------------------------------------------
-// CCrCrypto::MesDigestOutputSize
+// CCrCrypto::MesDigestOutputSizeL
 // Returns output size of the message digest algorithm. 
 // Parameters:         aDigestAlg           message digest algortihm
 // Return Values:      Output size of the message digest algorithm in bytes.
-//                     If unknown algorithm returns -1.      
+//                     If unknown algorithm, leaves with KErrNotSupported.
 // -----------------------------------------------------------------------------
-TInt CCrCrypto::MesDigestOutputSize(TCrAlgorithm aDigestAlg)
+TInt CCrCrypto::MesDigestOutputSizeL( TCrAlgorithm aDigestAlg )
     {
     switch(aDigestAlg)
         {
@@ -909,7 +910,8 @@
             }
         default:
             {
-            return -1;
+            User::Leave( KErrNotSupported );
+            return -1;  // keeps compiler happy
             }
         }
     }
--- a/pkiutilities/PKCS12/CrPkcs12/Src/crpkcs12.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/pkiutilities/PKCS12/CrPkcs12/Src/crpkcs12.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2004, 2010 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"
@@ -1130,10 +1130,17 @@
                 }
             }
         }
+
+    if( !pkcs7EncryptedDataBuf )
+        {
+        CleanupStack::PopAndDestroy(numberOfItemsInCStack); // set
+        numberOfItemsInCStack = 0;
+        return EFalse;
+        }
+
     // OK, now we have buffer to be decrypted, used algorithm, salt and
     // an iteration count. Next we decrypt buffer and append it to iBags.
-	
-	DecryptPkcs7EncryptedDataL( pkcs7EncryptedDataBuf,salt,iter,algorithm );
+	DecryptPkcs7EncryptedDataL( pkcs7EncryptedDataBuf, salt, iter, algorithm );
 
     CleanupStack::PopAndDestroy(numberOfItemsInCStack);
     numberOfItemsInCStack = 0;
@@ -1309,7 +1316,6 @@
     {
     TInt numberOfItemsinCStack = 0;
     CCrBerSet* set = NULL;
-    TInt errData = KErrNone;
 
     set = CCrBerSet::NewLC( 1 );
     ++numberOfItemsinCStack;
@@ -1403,11 +1409,6 @@
     CleanupStack::PushL(encryptedPrivateKeyInfo);
     ++numberOfItemsinCStack;
     
-    if ( errData < KErrNone )
-        {
-        User::Leave(KErrArgument);
-        }
-
     // Decrypt
     if ( !DecryptPrivateKeyL( encryptedPrivateKeyInfo,
                                                  salt,
--- a/pkiutilities/SecModUI/inc/SecModUISyncWrapper.h	Tue Feb 02 00:44:34 2010 +0200
+++ b/pkiutilities/SecModUI/inc/SecModUISyncWrapper.h	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2005-2010 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"
@@ -15,18 +15,14 @@
 *
 */
 
-
 #ifndef SECMODUISYNCWRAPPER_H
 #define SECMODUISYNCWRAPPER_H
 
-
-// INCLUDES
 #include <e32base.h>
 #include <f32file.h>
 #include <ct/rcpointerarray.h>
 #include <ct/rmpointerarray.h>
 
-// FORWARD DECLERATIONS
 class MCTToken;
 class MCTAuthenticationObject;
 class MCTAuthenticationObjectList;
@@ -36,7 +32,7 @@
 class TCTKeyAttributeFilter;
 class MCTKeyStore;
 class TCTTokenObjectHandle;
-// CLASS DECLARATION
+
 
 /**
 *  class CSecModUISyncWrapper
@@ -47,88 +43,66 @@
 */
 class CSecModUISyncWrapper : public CActive
     {
-    public:
-
-        /**
-        * Two-phased constructor.
-        */
-        static CSecModUISyncWrapper* NewLC();
+    public:     // Constructors and destructor
 
-        /**
-        * Two-phased constructor.
-        */
+        static CSecModUISyncWrapper* NewLC();
         static CSecModUISyncWrapper* NewL();
-
-        /**
-        * Destructor.
-        */
         virtual ~CSecModUISyncWrapper();
 
-    public: // New functions
-
-        /**
-        * TInt ListL
-        * @since S60 2.0
-        * @param aStore reference to store where operation is done.
-        * @param aArray certificates are stored here.
-        * @param aFilter Information on what kind certificates are looked.
-        * @return TInt Status Symbian's API's call.
-        */
-        
+    public:     // New functions
 
         TInt Initialize(CUnifiedKeyStore& aKeyStore );
 
         TInt OpenWIM();
 
         TInt GetAuthObjectInterface(
-            MCTToken& aToken, 
+            MCTToken& aToken,
             MCTTokenInterface*& aTokenInterface);
 
-        TInt ListAuthObjects( 
-            MCTAuthenticationObjectList& aAuthObjList, 
+        TInt ListAuthObjects(
+            MCTAuthenticationObjectList& aAuthObjList,
             RMPointerArray<MCTAuthenticationObject>& aAuthObjects );
-                             
+
         TInt ListKeys(
-            MCTKeyStore& aKeyStore, 
-            RMPointerArray<CCTKeyInfo>& aKeysInfos, 
+            MCTKeyStore& aKeyStore,
+            RMPointerArray<CCTKeyInfo>& aKeysInfos,
 		    const TCTKeyAttributeFilter& aFilter);
-					  
+
 	    TInt DeleteKey(
-	        CUnifiedKeyStore& aKeyStore, 
-	        TCTTokenObjectHandle aHandle);				                       
-    
+	        CUnifiedKeyStore& aKeyStore,
+	        TCTTokenObjectHandle aHandle);
+
         TInt ChangeReferenceData( MCTAuthenticationObject& aAuthObject );
 
         TInt UnblockAuthObject( MCTAuthenticationObject& aAuthObject );
-        
+
         TInt EnableAuthObject( MCTAuthenticationObject& aAuthObject );
-        
+
         TInt DisableAuthObject( MCTAuthenticationObject& aAuthObject );
-        
+
         TInt CloseAuthObject( MCTAuthenticationObject& aAuthObject );
-        
+
         TInt TimeRemaining( MCTAuthenticationObject& aAuthObject, TInt& aStime );
 
-    protected:
-        
+    protected:      // From CActive
+
         void DoCancel();
 	    void RunL();
 
-    private:
+    private:        // New functions
 
         CSecModUISyncWrapper();
-        void HandleErrorL();
 
-    private:    //Data
+    private:        // Data
 
         // Internal operation states.
         enum TOperation
             {
-            EOperationInit,            
+            EOperationInit,
             EOperationGetAOInterface,
             EOperationListAOs,
             EOperationListKeys,
-            EOperationDelKey,                                  
+            EOperationDelKey,
             EOperationChangeReferenceData,
             EOperationUnblockAO,
             EOperationEnableAO,
@@ -140,13 +114,12 @@
 
         // For wrapping asynchronous calls.
         CActiveSchedulerWait    iWait;
+
         // Internal state of operation.
         TOperation              iOperation;
-        
+
         // CT objects
         TAny* iObject;
     };
 
 #endif // SECMODUISYNCWRAPPER_H
-
-// End of File
--- a/pkiutilities/SecModUI/src/SecModUISyncWrapper.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/pkiutilities/SecModUI/src/SecModUISyncWrapper.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2005-2010 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"
@@ -18,8 +18,6 @@
 */
 
 
-
-// INCLUDE FILES
 #include "SecModUISyncWrapper.h"
 #include <ct/ccttokentypeinfo.h>
 #include <ct/mcttokentype.h>
@@ -51,7 +49,7 @@
 CSecModUISyncWrapper* CSecModUISyncWrapper::NewLC()
     {
     CSecModUISyncWrapper* wrap = new (ELeave) CSecModUISyncWrapper();
-    CleanupStack::PushL(wrap);    
+    CleanupStack::PushL(wrap);
     return wrap;
     }
 
@@ -86,14 +84,19 @@
 TInt CSecModUISyncWrapper::Initialize(CUnifiedKeyStore& aKeyStore)
     {
     LOG_ENTERFN("CSecModUISyncWrapper::Initialize");
-    iOperation = EOperationInit;    
-    iObject = STATIC_CAST(TAny*, &aKeyStore);
-    aKeyStore.Initialize(iStatus);    
-    SetActive();
-    iWait.Start();
-    iOperation = EOperationNone;
-    LOG_LEAVEFN("CSecModUISyncWrapper::Initialize");    
-    return iStatus.Int();
+    if( !IsActive() && !iWait.IsStarted() )
+        {
+        iOperation = EOperationInit;
+        iObject = STATIC_CAST(TAny*, &aKeyStore);
+        aKeyStore.Initialize(iStatus);
+        SetActive();
+        iWait.Start();
+        iOperation = EOperationNone;
+        LOG_LEAVEFN("CSecModUISyncWrapper::Initialize");
+        return iStatus.Int();
+        }
+    LOG_LEAVEFN("CSecModUISyncWrapper::Initialize - KErrInUse");
+    return KErrInUse;
     }
 
 // -----------------------------------------------------------------------------
@@ -104,18 +107,23 @@
     MCTToken& aToken, MCTTokenInterface*& aTokenInterface)
     {
     LOG_ENTERFN("CSecModUISyncWrapper::GetAuthObjectInterface");
-    iOperation = EOperationGetAOInterface;    
-    iObject = STATIC_CAST(TAny*, &aToken);
-    const TUid KUidInterfaceAO = { KCTInterfaceAuthenticationObject };    
-    aToken.GetInterface(KUidInterfaceAO, aTokenInterface, iStatus);
-    iOperation = EOperationGetAOInterface;
-    SetActive();
-	iWait.Start();
-	iOperation = EOperationNone;
-	LOG_LEAVEFN("CSecModUISyncWrapper::GetAuthObjectInterface");	
-    return iStatus.Int();
+    if( !IsActive() && !iWait.IsStarted() )
+        {
+        iOperation = EOperationGetAOInterface;
+        iObject = STATIC_CAST(TAny*, &aToken);
+        const TUid KUidInterfaceAO = { KCTInterfaceAuthenticationObject };
+        aToken.GetInterface(KUidInterfaceAO, aTokenInterface, iStatus);
+        iOperation = EOperationGetAOInterface;
+        SetActive();
+        iWait.Start();
+        iOperation = EOperationNone;
+        LOG_LEAVEFN("CSecModUISyncWrapper::GetAuthObjectInterface");
+        return iStatus.Int();
+        }
+    LOG_LEAVEFN("CSecModUISyncWrapper::GetAuthObjectInterface - KErrInUse");
+    return KErrInUse;
     }
-    
+
 // -----------------------------------------------------------------------------
 // CSecModUISyncWrapper::ListAuthObjects(...)
 // -----------------------------------------------------------------------------
@@ -125,56 +133,71 @@
     RMPointerArray<MCTAuthenticationObject>& aAuthObjects)
     {
     LOG_ENTERFN("CSecModUISyncWrapper::ListAuthObjects");
-    iOperation = EOperationListAOs;
-    iObject = STATIC_CAST(TAny*, &aAuthObjList);    
-    aAuthObjList.List( aAuthObjects, iStatus );    
-    iOperation = EOperationListAOs;
-    SetActive();
-	iWait.Start();
-	iOperation = EOperationNone;
-	LOG_LEAVEFN("CSecModUISyncWrapper::ListAuthObjects");
-    return iStatus.Int();
+    if( !IsActive() && !iWait.IsStarted() )
+        {
+        iOperation = EOperationListAOs;
+        iObject = STATIC_CAST(TAny*, &aAuthObjList);
+        aAuthObjList.List( aAuthObjects, iStatus );
+        iOperation = EOperationListAOs;
+        SetActive();
+        iWait.Start();
+        iOperation = EOperationNone;
+        LOG_LEAVEFN("CSecModUISyncWrapper::ListAuthObjects");
+        return iStatus.Int();
+        }
+    LOG_LEAVEFN("CSecModUISyncWrapper::ListAuthObjects - KErrInUse");
+    return KErrInUse;
     }
- 
+
 // -----------------------------------------------------------------------------
 // CSecModUISyncWrapper::ListKeys(...)
 // -----------------------------------------------------------------------------
-// 
+//
 TInt CSecModUISyncWrapper::ListKeys(
-    MCTKeyStore& aKeyStore, 
-    RMPointerArray<CCTKeyInfo>& aKeysInfos, 
+    MCTKeyStore& aKeyStore,
+    RMPointerArray<CCTKeyInfo>& aKeysInfos,
     const TCTKeyAttributeFilter& aFilter)
     {
     LOG_ENTERFN("CSecModUISyncWrapper::ListKeys");
-    iOperation = EOperationListKeys;
-    iObject = STATIC_CAST(TAny*, &aKeyStore);    
-    aKeyStore.List(aKeysInfos, aFilter, iStatus);
-    SetActive();
-	iWait.Start();
-	iOperation = EOperationNone;
-	LOG_LEAVEFN("CSecModUISyncWrapper::ListKeys");
-	return iStatus.Int();
+    if( !IsActive() && !iWait.IsStarted() )
+        {
+        iOperation = EOperationListKeys;
+        iObject = STATIC_CAST(TAny*, &aKeyStore);
+        aKeyStore.List(aKeysInfos, aFilter, iStatus);
+        SetActive();
+        iWait.Start();
+        iOperation = EOperationNone;
+        LOG_LEAVEFN("CSecModUISyncWrapper::ListKeys");
+        return iStatus.Int();
+        }
+    LOG_LEAVEFN("CSecModUISyncWrapper::ListKeys - KErrInUse");
+    return KErrInUse;
     }
 
 // -----------------------------------------------------------------------------
 // CSecModUISyncWrapper::DeleteKey(...)
 // -----------------------------------------------------------------------------
-//    
+//
 TInt CSecModUISyncWrapper::DeleteKey(
-    CUnifiedKeyStore& aKeyStore, 
+    CUnifiedKeyStore& aKeyStore,
     TCTTokenObjectHandle aHandle)
     {
     LOG_ENTERFN("CSecModUISyncWrapper::DeleteKey");
-    iOperation = EOperationDelKey;
-    iObject = STATIC_CAST(TAny*, &aKeyStore);    
-    aKeyStore.DeleteKey(aHandle, iStatus);
-    SetActive();
-	iWait.Start();
-	iOperation = EOperationNone;
-	LOG_LEAVEFN("CSecModUISyncWrapper::DeleteKey");
-	return iStatus.Int();
+    if( !IsActive() && !iWait.IsStarted() )
+        {
+        iOperation = EOperationDelKey;
+        iObject = STATIC_CAST(TAny*, &aKeyStore);
+        aKeyStore.DeleteKey(aHandle, iStatus);
+        SetActive();
+        iWait.Start();
+        iOperation = EOperationNone;
+        LOG_LEAVEFN("CSecModUISyncWrapper::DeleteKey");
+        return iStatus.Int();
+        }
+    LOG_LEAVEFN("CSecModUISyncWrapper::DeleteKey - KErrInUse");
+    return KErrInUse;
     }
-    
+
 // -----------------------------------------------------------------------------
 // CSecModUISyncWrapper::ChangeReferenceData(MCTAuthenticationObject& aAuthObject)
 // -----------------------------------------------------------------------------
@@ -183,14 +206,19 @@
     MCTAuthenticationObject& aAuthObject)
     {
     LOG_ENTERFN("CSecModUISyncWrapper::ChangeReferenceData");
-    iOperation = EOperationChangeReferenceData;    
-    iObject = STATIC_CAST(TAny*, &aAuthObject);
-    aAuthObject.ChangeReferenceData(iStatus);
-    SetActive();
-    iWait.Start();
-    iOperation = EOperationNone;
-    LOG_LEAVEFN("CSecModUISyncWrapper::ChangeReferenceData");
-    return iStatus.Int();
+    if( !IsActive() && !iWait.IsStarted() )
+        {
+        iOperation = EOperationChangeReferenceData;
+        iObject = STATIC_CAST(TAny*, &aAuthObject);
+        aAuthObject.ChangeReferenceData(iStatus);
+        SetActive();
+        iWait.Start();
+        iOperation = EOperationNone;
+        LOG_LEAVEFN("CSecModUISyncWrapper::ChangeReferenceData");
+        return iStatus.Int();
+        }
+    LOG_LEAVEFN("CSecModUISyncWrapper::ChangeReferenceData - KErrInUse");
+    return KErrInUse;
     }
 
 // -----------------------------------------------------------------------------
@@ -201,53 +229,68 @@
     MCTAuthenticationObject& aAuthObject)
     {
     LOG_ENTERFN("CSecModUISyncWrapper::UnblockAuthObject");
-    iOperation = EOperationUnblockAO;
-    iObject = STATIC_CAST(TAny*, &aAuthObject);
-    aAuthObject.Unblock(iStatus);    
-    SetActive();
-    iWait.Start();
-    iOperation = EOperationNone;
-    LOG_LEAVEFN("CSecModUISyncWrapper::UnblockAuthObject");
-    return iStatus.Int();
+    if( !IsActive() && !iWait.IsStarted() )
+        {
+        iOperation = EOperationUnblockAO;
+        iObject = STATIC_CAST(TAny*, &aAuthObject);
+        aAuthObject.Unblock(iStatus);
+        SetActive();
+        iWait.Start();
+        iOperation = EOperationNone;
+        LOG_LEAVEFN("CSecModUISyncWrapper::UnblockAuthObject");
+        return iStatus.Int();
+        }
+    LOG_LEAVEFN("CSecModUISyncWrapper::UnblockAuthObject - KErrInUse");
+    return KErrInUse;
     }
 
 // -----------------------------------------------------------------------------
 // CSecModUIModel::EnableAuthObject(MCTAuthenticationObject& aAuthObject)
 // -----------------------------------------------------------------------------
-//    
-TInt CSecModUISyncWrapper::EnableAuthObject( 
+//
+TInt CSecModUISyncWrapper::EnableAuthObject(
     MCTAuthenticationObject& aAuthObject)
     {
     LOG_ENTERFN("CSecModUISyncWrapper::EnableAuthObject");
-    iOperation = EOperationEnableAO;
-    iObject = STATIC_CAST(TAny*, &aAuthObject);
-    aAuthObject.Enable(iStatus);
-    iOperation = EOperationUnblockAO;
-    SetActive();
-    iWait.Start();
-    iOperation = EOperationNone;
-    LOG_LEAVEFN("CSecModUISyncWrapper::EnableAuthObject");
-    return iStatus.Int();
+    if( !IsActive() && !iWait.IsStarted() )
+        {
+        iOperation = EOperationEnableAO;
+        iObject = STATIC_CAST(TAny*, &aAuthObject);
+        aAuthObject.Enable(iStatus);
+        iOperation = EOperationUnblockAO;
+        SetActive();
+        iWait.Start();
+        iOperation = EOperationNone;
+        LOG_LEAVEFN("CSecModUISyncWrapper::EnableAuthObject");
+        return iStatus.Int();
+        }
+    LOG_LEAVEFN("CSecModUISyncWrapper::EnableAuthObject - KErrInUse");
+    return KErrInUse;
     }
-  
+
 // -----------------------------------------------------------------------------
 // CSecModUIModel::DisableAuthObject(MCTAuthenticationObject& aAuthObject)
 // -----------------------------------------------------------------------------
-//  
+//
 TInt CSecModUISyncWrapper::DisableAuthObject(
     MCTAuthenticationObject& aAuthObject)
     {
     LOG_ENTERFN("CSecModUISyncWrapper::DisableAuthObject");
-    iOperation = EOperationDisableAO;
-    iObject = STATIC_CAST(TAny*, &aAuthObject);
-    aAuthObject.Disable(iStatus);    
-    SetActive();
-    iWait.Start();
-    iOperation = EOperationNone;
-    LOG_LEAVEFN("CSecModUISyncWrapper::DisableAuthObject");
-    return iStatus.Int();
-    }    
-    
+    if( !IsActive() && !iWait.IsStarted() )
+        {
+        iOperation = EOperationDisableAO;
+        iObject = STATIC_CAST(TAny*, &aAuthObject);
+        aAuthObject.Disable(iStatus);
+        SetActive();
+        iWait.Start();
+        iOperation = EOperationNone;
+        LOG_LEAVEFN("CSecModUISyncWrapper::DisableAuthObject");
+        return iStatus.Int();
+        }
+    LOG_LEAVEFN("CSecModUISyncWrapper::DisableAuthObject - KErrInUse");
+    return KErrInUse;
+    }
+
 // -----------------------------------------------------------------------------
 // CSecModUISyncWrapper::CloseAuthObject(MCTAuthenticationObject& aAuthObject)
 // -----------------------------------------------------------------------------
@@ -256,33 +299,43 @@
     MCTAuthenticationObject& aAuthObject)
     {
     LOG_ENTERFN("CSecModUISyncWrapper::CloseAuthObject");
-    iOperation = EOperationCloseAO;
-    iObject = STATIC_CAST(TAny*, &aAuthObject);
-    aAuthObject.Close(iStatus);    
-    SetActive();
-    iWait.Start();
-    iOperation = EOperationNone;
-    LOG_LEAVEFN("CSecModUISyncWrapper::CloseAuthObject");
-    return iStatus.Int();
+    if( !IsActive() && !iWait.IsStarted() )
+        {
+        iOperation = EOperationCloseAO;
+        iObject = STATIC_CAST(TAny*, &aAuthObject);
+        aAuthObject.Close(iStatus);
+        SetActive();
+        iWait.Start();
+        iOperation = EOperationNone;
+        LOG_LEAVEFN("CSecModUISyncWrapper::CloseAuthObject");
+        return iStatus.Int();
+        }
+    LOG_LEAVEFN("SecModUISyncWrapper::CloseAuthObject - KErrInUse");
+    return KErrInUse;
     }
 
 // -----------------------------------------------------------------------------
 // CSecModUIModel::TimeRemaining(...)
 // -----------------------------------------------------------------------------
-//    
-TInt CSecModUISyncWrapper::TimeRemaining( 
-    MCTAuthenticationObject& aAuthObject, 
+//
+TInt CSecModUISyncWrapper::TimeRemaining(
+    MCTAuthenticationObject& aAuthObject,
     TInt& aStime )
     {
     LOG_ENTERFN("CSecModUISyncWrapper::TimeRemaining");
-    iOperation = EOperationTimeRemAO;
-    iObject = STATIC_CAST(TAny*, &aAuthObject);
-    aAuthObject.TimeRemaining(aStime, iStatus);
-    SetActive();
-    iWait.Start();
-    iOperation = EOperationNone;
-    LOG_LEAVEFN("CSecModUISyncWrapper::TimeRemaining");
-    return iStatus.Int();
+    if( !IsActive() && !iWait.IsStarted() )
+        {
+        iOperation = EOperationTimeRemAO;
+        iObject = STATIC_CAST(TAny*, &aAuthObject);
+        aAuthObject.TimeRemaining(aStime, iStatus);
+        SetActive();
+        iWait.Start();
+        iOperation = EOperationNone;
+        LOG_LEAVEFN("CSecModUISyncWrapper::TimeRemaining");
+        return iStatus.Int();
+        }
+    LOG_LEAVEFN("CSecModUISyncWrapper::TimeRemaining - KErrInUse");
+    return KErrInUse;
     }
 
 // -----------------------------------------------------------------------------
@@ -296,72 +349,72 @@
     switch ( iOperation )
         {
         case EOperationInit:
-            {  
-            LOG_WRITE("CSecModUISyncWrapper::DoCancel: EOperationInit");          
+            {
+            LOG_WRITE("CSecModUISyncWrapper::DoCancel: EOperationInit");
             STATIC_CAST(CUnifiedKeyStore*, iObject)->CancelInitialize();
             break;
             }
         case EOperationGetAOInterface:
-            {            
-            LOG_WRITE("CSecModUISyncWrapper::DoCancel: EOperationGetAOInterface");          
+            {
+            LOG_WRITE("CSecModUISyncWrapper::DoCancel: EOperationGetAOInterface");
             STATIC_CAST(MCTToken*, iObject)->CancelGetInterface();
             break;
-            }        
+            }
         case EOperationListAOs:
             {
-            LOG_WRITE("CSecModUISyncWrapper::DoCancel: EOperationListAOs");          
+            LOG_WRITE("CSecModUISyncWrapper::DoCancel: EOperationListAOs");
             STATIC_CAST(MCTAuthenticationObjectList*, iObject)->CancelList();
             break;
             }
         case EOperationListKeys:
             {
-            LOG_WRITE("CSecModUISyncWrapper::DoCancel: EOperationListKeys");          
+            LOG_WRITE("CSecModUISyncWrapper::DoCancel: EOperationListKeys");
             STATIC_CAST(MCTKeyStore*, iObject)->CancelList();
             break;
-            }            
+            }
         case EOperationDelKey:
             {
-            LOG_WRITE("CSecModUISyncWrapper::DoCancel: EOperationDelKey");          
+            LOG_WRITE("CSecModUISyncWrapper::DoCancel: EOperationDelKey");
             STATIC_CAST(CUnifiedKeyStore*, iObject)->CancelDeleteKey();
             break;
             }
         case EOperationChangeReferenceData:
             {
-            LOG_WRITE("CSecModUISyncWrapper::DoCancel: EOperationChangeReferenceData");          
+            LOG_WRITE("CSecModUISyncWrapper::DoCancel: EOperationChangeReferenceData");
             STATIC_CAST(MCTAuthenticationObject*, iObject)->
                 CancelChangeReferenceData();
             break;
             }
         case EOperationUnblockAO:
             {
-            LOG_WRITE("CSecModUISyncWrapper::DoCancel: EOperationInit");          
+            LOG_WRITE("CSecModUISyncWrapper::DoCancel: EOperationInit");
             STATIC_CAST(MCTAuthenticationObject*, iObject)->CancelUnblock();
             break;
             }
         case EOperationEnableAO:
             {
-            LOG_WRITE("CSecModUISyncWrapper::DoCancel: EOperationEnableAO");          
+            LOG_WRITE("CSecModUISyncWrapper::DoCancel: EOperationEnableAO");
             STATIC_CAST(MCTAuthenticationObject*, iObject)->CancelEnable();
             break;
             }
         case EOperationDisableAO:
             {
-            LOG_WRITE("CSecModUISyncWrapper::DoCancel: EOperationDisableAO");          
+            LOG_WRITE("CSecModUISyncWrapper::DoCancel: EOperationDisableAO");
             STATIC_CAST(MCTAuthenticationObject*, iObject)->CancelDisable();
             break;
             }
         case EOperationCloseAO:
             {
-            LOG_WRITE("CSecModUISyncWrapper::DoCancel: EOperationCloseAO");          
+            LOG_WRITE("CSecModUISyncWrapper::DoCancel: EOperationCloseAO");
             STATIC_CAST(MCTAuthenticationObject*, iObject)->CancelClose();
             break;
             }
         case EOperationTimeRemAO:
             {
-            LOG_WRITE("CSecModUISyncWrapper::DoCancel: EOperationTimeRemAO");          
+            LOG_WRITE("CSecModUISyncWrapper::DoCancel: EOperationTimeRemAO");
             STATIC_CAST(MCTAuthenticationObject*, iObject)->CancelTimeRemaining();
             break;
-            }        
+            }
         default:
             {
             break;
@@ -371,7 +424,7 @@
         {
         iWait.AsyncStop();
         }
-    LOG_LEAVEFN("CSecModUISyncWrapper::DoCancel");    
+    LOG_LEAVEFN("CSecModUISyncWrapper::DoCancel");
     }
 
 // -----------------------------------------------------------------------------
@@ -380,20 +433,7 @@
 // -----------------------------------------------------------------------------
 //
 void CSecModUISyncWrapper::RunL()
-    {    
-    iWait.AsyncStop();    
+    {
+    iWait.AsyncStop();
     }
 
-// -----------------------------------------------------------------------------
-// CSecModUISyncWrapper::HandleErrorL()
-// Shows an error note according to status of operation,
-// -----------------------------------------------------------------------------
-//
-void CSecModUISyncWrapper::HandleErrorL()
-    {
-        
-    }
-
-
-// End of File
-
--- a/pkiutilities/SecModUI/src/SecModUIViewAccess.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/pkiutilities/SecModUI/src/SecModUIViewAccess.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2005-2010 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"
@@ -349,9 +349,9 @@
     {
     if( R_SECMODUI_VIEW_ACCESS_MENU == aResourceId )
         {        
-        if( aResourceId == !FeatureManager::FeatureSupported( KFeatureIdHelp ) )
+        if( !FeatureManager::FeatureSupported( KFeatureIdHelp ) )
             {
-            aMenuPane->DeleteMenuItem( EAknCmdHelp ); //remove help
+            aMenuPane->DeleteMenuItem( EAknCmdHelp );
             }     
 
         TInt currentItem = iContainer->ListBox().CurrentItemIndex();
--- a/pkiutilities/SecModUI/src/SecModUIViewSignature.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/pkiutilities/SecModUI/src/SecModUIViewSignature.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2005-2010 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"
@@ -172,9 +172,9 @@
         {
         case R_SECMODUI_VIEW_SIGNATURE_MENU:
             {
-            if( aResourceId == !FeatureManager::FeatureSupported( KFeatureIdHelp ) )
+            if( !FeatureManager::FeatureSupported( KFeatureIdHelp ) )
                 {
-                aMenuPane->DeleteMenuItem( EAknCmdHelp ); //remove help
+                aMenuPane->DeleteMenuItem( EAknCmdHelp );
                 } 
             // The security module list is empty.  
             // All except Exit and Help is dimmed.
--- a/securitydialogs/Autolock/src/AutolockAppUi.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/securitydialogs/Autolock/src/AutolockAppUi.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -959,7 +959,25 @@
 	if (!iAppKey)
 		{
 		RWindowGroup& groupWin=iCoeEnv->RootWin();
-		iAppKey = groupWin.CaptureKeyUpAndDowns(EStdKeyApplication0, 0, 0); // Capture app key
+		#if defined(_DEBUG)
+		RDebug::Printf( "%s %s (%u) searching for popupclock.exe =%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x0 );
+		#endif
+		TApaTaskList taskList( CCoeEnv::Static()->WsSession() );
+		const TUid KBigClockUid = { 0x2000FDC3 };
+		TApaTask task( taskList.FindApp( KBigClockUid ) );
+		if ( task.Exists() )
+			{
+			#if defined(_DEBUG)
+			RDebug::Printf( "%s %s (%u) popupclock.exe is running. Not capturing EStdKeyApplication0=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, EStdKeyApplication0 );
+			#endif
+			}
+		else
+			{
+			#if defined(_DEBUG)
+			RDebug::Printf( "%s %s (%u) popupclock.exe not running. Not capturing EStdKeyApplication0=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, EStdKeyApplication0 );
+			#endif
+			iAppKey = groupWin.CaptureKeyUpAndDowns(EStdKeyApplication0, 0, 0); // Capture app key
+			}
 		}
 	LockSideKeyL();
 	}
@@ -1257,7 +1275,7 @@
 	    	        if(pointer->iType==TPointerEvent::EButton1Up)
 	    	        	{
 		    	        TPoint iPosition = pointer->iPosition;
-						if(aCallButtonRect.iBr.iX<iPosition.iX && iPosition.iX<aCallButtonRect.iBr.iX+aCallButtonRect.iTl.iX && iPosition.iY<400 )
+						if(aCallButtonRect.iBr.iX<iPosition.iX && iPosition.iX<aCallButtonRect.iBr.iX+aCallButtonRect.iTl.iX && iPosition.iY>400 )
 	    		        	{
 	    		        		#define KPhoneAppUid1 TUid::Uid(0x100058B3)
 	    		        		TApaTaskList tasklist( iCoeEnv->WsSession() );
--- a/securitydialogs/SecUi/Src/SecUiSecuritySettings.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/securitydialogs/SecUi/Src/SecUiSecuritySettings.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -993,34 +993,6 @@
     
     CleanupStack::PopAndDestroy();    // items
     
-    if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ))
-		{
-    TBool allow = ETrue;               
-               
-    if ((aPeriod == 0) && (maxPeriod > 0))
-       {
-        #if defined(_DEBUG)
-        RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() \
-        The period: %d is not allowed by TARM; max: %d"),aPeriod, maxPeriod );
-        #endif                
-        allow = EFalse;                                                
-        HBufC* prompt;
-        prompt = StringLoader::LoadLC( R_SECUI_TEXT_AUTOLOCK_MUST_BE_ACTIVE );
-        CAknNoteDialog* noteDlg = new (ELeave) CAknNoteDialog( REINTERPRET_CAST(CEikDialog**,&noteDlg) );
-        noteDlg->PrepareLC( R_CODE_ERROR );
-        noteDlg->SetTextL( *prompt );
-        noteDlg->SetTimeout( CAknNoteDialog::ELongTimeout );
-        noteDlg->SetTone( CAknNoteDialog::EErrorTone );
-        noteDlg->RunLD();                    
-                    
-        CleanupStack::PopAndDestroy( prompt );                      
-        }          
-        
-    if ( !allow ) 
-        {
-         return ChangeAutoLockPeriodL( oldPeriod );
-        }                       
-  }
 
     if (aPeriod == 0)
         {
--- a/securitydialogs/Securitynotifier/Group/Securitynotifier.mmp	Tue Feb 02 00:44:34 2010 +0200
+++ b/securitydialogs/Securitynotifier/Group/Securitynotifier.mmp	Fri Feb 19 23:42:03 2010 +0200
@@ -51,7 +51,7 @@
 #if defined(WINSCW)
 DEFFILE ../BWinsCw/SecurityNotifierU.def
 #endif
-LIBRARY                 featmgr.lib
+LIBRARY                 featmgr.lib  apgrfx.lib apparc.lib
 
 SMPSAFE
 
--- a/securitydialogs/Securitynotifier/Src/SecurityNotifier.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/securitydialogs/Securitynotifier/Src/SecurityNotifier.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -31,6 +31,7 @@
 #include <AknQueryDialog.h>
 #include <featmgr.h>
 #include <SCPClient.h>
+#include <apgcli.h>
 
 //  LOCAL CONSTANTS AND MACROS
 	/*****************************************************
@@ -224,6 +225,33 @@
 //
 void CSecurityNotifier::GetParamsL(const TDesC8& aBuffer, TInt aReturnVal, const RMessagePtr2& aMessage)
     {
+	#if defined(_DEBUG)
+	RDebug::Printf( "%s %s (%u) searching for autolock.exe =%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x0 );
+	#endif
+	TApaTaskList taskList( CCoeEnv::Static()->WsSession() );
+	const TUid KAutolockUid = { 0x100059B5 };
+	TApaTask task( taskList.FindApp( KAutolockUid ) );
+	if ( !task.Exists() )
+		{
+		#if defined(_DEBUG)
+		RDebug::Printf( "%s %s (%u) autolock.exe not running. Starting now=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x1 );
+		#endif
+		RApaLsSession ls;                   
+		User::LeaveIfError(ls.Connect());   
+		CleanupClosePushL(ls);         
+		
+		CApaCommandLine* commandLine = CApaCommandLine::NewLC();
+		commandLine->SetExecutableNameL( _L("autolock.exe" ) );     
+		commandLine->SetCommandL( EApaCommandRun );
+		
+		// Try to launch the application.        
+		User::LeaveIfError(ls.StartApp(*commandLine));
+		#if defined(_DEBUG)
+		RDebug::Printf( "%s %s (%u) autolock.exe created=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x2 );
+		#endif
+		
+		CleanupStack::PopAndDestroy(2); // commandLine, ls
+		}
 	/*****************************************************
 	*	Series 60 Customer / ETel
 	*	Series 60  ETel API
--- a/securitydialogs/simlockui/data/SimLockUI.rss	Tue Feb 02 00:44:34 2010 +0200
+++ b/securitydialogs/simlockui/data/SimLockUI.rss	Fri Feb 19 23:42:03 2010 +0200
@@ -31,8 +31,8 @@
 #include <avkon.rsg>
 #include <appinfo.rh>
 
-#include "SimLockUI.hrh"
-#include "SimLockUI.loc"
+#include "simlockui.hrh"
+#include "simlockui.loc"
 
 // Resource Identifiers
 RESOURCE RSS_SIGNATURE { }
--- a/securitydialogs/simlockui/data/SimLockUI_reg.rss	Tue Feb 02 00:44:34 2010 +0200
+++ b/securitydialogs/simlockui/data/SimLockUI_reg.rss	Fri Feb 19 23:42:03 2010 +0200
@@ -24,9 +24,9 @@
 //SimLockUI application's registration resource file 
 
 #include <appinfo.rh>
-#include <SimLockUI.rsg>
+#include <simlockui.rsg>
 
-#include "SimLockUI.hrh"
+#include "simlockui.hrh"
 
 UID2 KUidAppRegistrationResourceFile
 UID3 SIMLOCK_UI_UID3
--- a/securitydialogs/simlockui/group/SimLockUI.mmp	Tue Feb 02 00:44:34 2010 +0200
+++ b/securitydialogs/simlockui/group/SimLockUI.mmp	Fri Feb 19 23:42:03 2010 +0200
@@ -21,13 +21,13 @@
 * ============================================================================
 */
 
-#include "../inc/SimLockUI.hrh"
+#include "../inc/simlockui.hrh"
 #include <data_caging_paths.hrh>
 #include <platform_paths.hrh>
 CAPABILITY ALL -TCB
 
 TARGETPATH        /sys/bin
-TARGET            SimLockUI.exe
+TARGET            simlockui.exe
 TARGETTYPE        exe
 
 UID               0x00000000 SIMLOCK_UI_UID3
@@ -36,13 +36,13 @@
 LANG              SC
 
 SOURCEPATH        ../src
-SOURCE            SimLockUI.cpp
-SOURCE            SimLockUIApplication.cpp 
-SOURCE            SimLockUIBackgroundControl.cpp
-SOURCE            SimLockUIAppUi.cpp
-SOURCE            SimLockUIDocument.cpp 
-SOURCE            SimLockDataHandlingDelegate.cpp
-SOURCE            SimLockTelephonyProxy.cpp
+SOURCE            simlockui.cpp
+SOURCE            simlockuiapplication.cpp 
+SOURCE            simlockuibackgroundcontrol.cpp
+SOURCE            simlockuiappui.cpp
+SOURCE            simlockuidocument.cpp 
+SOURCE            simlockdatahandlingdelegate.cpp
+SOURCE            simlocktelephonyproxy.cpp
 
 USERINCLUDE       ../inc 
 SYSTEMINCLUDE     /epoc32/include/internal
@@ -57,13 +57,13 @@
 LIBRARY       etel.lib
 LIBRARY       etelmm.lib
 LIBRARY       customapi.lib
-LIBRARY       CommonEngine.lib
+LIBRARY       commonengine.lib
 LIBRARY       aknskins.lib  
 LIBRARY       aknskinsrv.lib
 LIBRARY       aknswallpaperutils.lib
 LIBRARY       aknlayout2.lib
-LIBRARY       AknLayout2Scalable.lib
-LIBRARY       CdlEngine.lib
+LIBRARY       aknlayout2scalable.lib
+LIBRARY       cdlengine.lib
 LIBRARY       ws32.lib
 LIBRARY       etel3rdparty.lib
 LIBRARY       eikcoctl.lib
@@ -71,14 +71,14 @@
 SOURCEPATH    ../data
 
 // Main resource file
-START RESOURCE  SimLockUI.RSS
+START RESOURCE  simlockui.rss
 HEADER
 TARGETPATH  /resource/apps
 LANG    SC
 END
 
 // Resource registration file
-START RESOURCE  SimLockUI_reg.rss
+START RESOURCE  simlockui_reg.rss
 TARGETPATH  /private/10003a3f/apps
 END
 
--- a/securitydialogs/simlockui/group/bld.inf	Tue Feb 02 00:44:34 2010 +0200
+++ b/securitydialogs/simlockui/group/bld.inf	Fri Feb 19 23:42:03 2010 +0200
@@ -27,16 +27,16 @@
 PRJ_MMPFILES
 
 // Project File
-SimLockUI.mmp
+simlockui.mmp
 
 // Icon File
 
 PRJ_EXPORTS
 // Export IBY files
-..\rom\simlockui.iby            CORE_MW_LAYER_IBY_EXPORT_PATH( simlockui.iby) 
-..\rom\simlockui_resources.iby  LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(simlockui_resources.iby)   
+../rom/simlockui.iby            CORE_MW_LAYER_IBY_EXPORT_PATH( simlockui.iby) 
+../rom/simlockui_resources.iby  LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(simlockui_resources.iby)   
 
 // For EE texts
-..\rom\simlockui_resources.iby  CORE_APP_LAYER_IBY_EXPORT_PATH(simlockui_resources.iby)    		
+../rom/simlockui_resources.iby  CORE_APP_LAYER_IBY_EXPORT_PATH(simlockui_resources.iby)    		
 
-..\inc\simlockuikeys.h                  \epoc32\include\oem\simlockuikeys.h
\ No newline at end of file
+../inc/simlockuikeys.h                  /epoc32/include/oem/simlockuikeys.h
\ No newline at end of file
--- a/securitydialogs/simlockui/inc/SimLockTelephonyProxy.h	Tue Feb 02 00:44:34 2010 +0200
+++ b/securitydialogs/simlockui/inc/SimLockTelephonyProxy.h	Fri Feb 19 23:42:03 2010 +0200
@@ -26,7 +26,7 @@
 
 // System Includes
 #include <e32base.h>
-#include <Etel3rdParty.h> // CTelephony members
+#include <etel3rdparty.h> // CTelephony members
 
 // Forward Declarations
 class CPeriodic;
--- a/securitydialogs/simlockui/inc/SimLockUI.hrh	Tue Feb 02 00:44:34 2010 +0200
+++ b/securitydialogs/simlockui/inc/SimLockUI.hrh	Fri Feb 19 23:42:03 2010 +0200
@@ -21,12 +21,12 @@
 * ============================================================================
 */
 
-#ifndef __SimLockUI_HRH__
-#define __SimLockUI_HRH__
+#ifndef __simlockui_HRH__
+#define __simlockui_HRH__
 
 #define SIMLOCK_UI_UID3               0x2000B0FA
 #define SEC_ATT_PASSWORD_MAX_BUFFER   32
 
-#endif // __SimLockUI_HRH__
+#endif // __simLockui_HRH__
 
 // End of file.
--- a/securitydialogs/simlockui/inc/SimLockUIAppui.h	Tue Feb 02 00:44:34 2010 +0200
+++ b/securitydialogs/simlockui/inc/SimLockUIAppui.h	Fri Feb 19 23:42:03 2010 +0200
@@ -33,7 +33,7 @@
 // FORWARD DECLARATIONS
 class RProperty;
 // User includes
-#include "SimLockUIBackgroundControl.h" // CSimLockUIBackgroundControl::TBackgroundText
+#include "simlockuibackgroundcontrol.h" // CSimLockUIBackgroundControl::TBackgroundText
 
 // Forward reference
 class CSimLockUIBackgroundControl;
--- a/securitydialogs/simlockui/inc/SimLockUIDocument.h	Tue Feb 02 00:44:34 2010 +0200
+++ b/securitydialogs/simlockui/inc/SimLockUIDocument.h	Fri Feb 19 23:42:03 2010 +0200
@@ -25,8 +25,8 @@
 #define __SIMLOCKUI_DOCUMENT_H__
 
 // INCLUDES
-#include <akndoc.h>
-#include <RMmCustomAPI.h> // RMmCustomAPI, RTelServer, RMobilePhone
+#include <AknDoc.h>
+#include <rmmcustomapi.h> // RMmCustomAPI, RTelServer, RMobilePhone
 
 // CONSTANTS
 
--- a/securitydialogs/simlockui/src/SimLockDataHandlingDelegate.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/securitydialogs/simlockui/src/SimLockDataHandlingDelegate.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -22,12 +22,12 @@
 */
 
 // System Include Files
-#include <RMmCustomAPI.h>           // RMmCustomAPI, RMobilePhone
+#include <rmmcustomapi.h>           // RMmCustomAPI, RMobilePhone
 
 // User Include Files
-#include "SimLockDataHandlingDelegate.h"
-#include "SimLockUI.pan"
-#include "SimLockISAServerDefinitions.h"
+#include "simlockdatahandlingdelegate.h"
+#include "simlockui.pan"
+#include "simlockisaserverdefinitions.h"
 
 
 TInt KSimLockTimeoutDelay = 5000000;       // 5 seconds
--- a/securitydialogs/simlockui/src/SimLockTelephonyProxy.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/securitydialogs/simlockui/src/SimLockTelephonyProxy.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -22,11 +22,11 @@
 */
 
 // System Includes
-#include <Etel3rdParty.h>           // CTelephony
+#include <etel3rdparty.h>           // CTelephony
 
 // User Includes
-#include "SimLockTelephonyProxy.h"
-#include "SimLockUi.pan"
+#include "simlocktelephonyproxy.h"
+#include "simlockui.pan"
 
 
 TInt KSimLockProxyTimeout = 5000000;    // 5 seconds
--- a/securitydialogs/simlockui/src/SimLockUI.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/securitydialogs/simlockui/src/SimLockUI.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -1,6 +1,6 @@
 /*
 * ============================================================================
-*  Name        : SimLockUI.cpp
+*  Name        : simlockui.cpp
 *  Part of     : Sim Lock UI Application
 *  Description : Sim Lock UI App framework code
 *  Version     : 
@@ -25,7 +25,7 @@
 #include <eikstart.h>
 
 // User Includes
-#include "SimLockUIApplication.h"
+#include "simlockuiapplication.h"
 
 // ---------------------------------------------------------------------------
 // NewApplication
--- a/securitydialogs/simlockui/src/SimLockUIApplication.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/securitydialogs/simlockui/src/SimLockUIApplication.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -1,6 +1,6 @@
 /*
 * ============================================================================
-*  Name        : SimLockUIApplication.cpp
+*  Name        :simlockuiapplication.cpp
 *  Part of     : Sim Lock UI Application
 *  Description : Implementation of Sim Lock UI Application UI Methods
 *  Version     : 
@@ -22,9 +22,9 @@
 */
 
 // User include files
-#include "SimLockUIDocument.h"
-#include "SimLockUIApplication.h"
-#include "SimLockUI.hrh"
+#include "simlockuidocument.h"
+#include "simlockuiapplication.h"
+#include "simlockui.hrh"
 
 // UID for the application, this should correspond to the uid defined in the mmp file
 static const TUid KUidSimLockUIApp = {SIMLOCK_UI_UID3};
--- a/securitydialogs/simlockui/src/SimLockUIAppui.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/securitydialogs/simlockui/src/SimLockUIAppui.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -24,24 +24,24 @@
 // Platform Includes
 #include <avkon.hrh>
 #include <aknnotewrappers.h>    // CAknNoteDialog
-#include <stringloader.h>       // StringLoader
+#include <StringLoader.h>       // StringLoader
 #include <exterror.h>           // KErrGsm0707OperationNotAllowed
 #include <eikspane.h>     // CEikStatusPane
 #include <aknmessagequerydialog.h> // CAknMessageQueryDialog
 #include <e32base.h>
 #include <e32property.h> //Rproperty
 // Local Includes
-#include "SimLockISAServerDefinitions.h"
-#include "SimLockUI.pan"
-#include "SimLockUIAppUi.h"
-#include "SimLockUIBackgroundControl.h"
-#include "SimLockUI.hrh"
-#include "SimLockDataHandlingDelegate.h"
-#include "SimLockTelephonyProxy.h"
-#include "SimLockUiKeys.h"
+#include "simlockisaserverdefinitions.h"
+#include "simlockui.pan"
+#include "simlockuiappui.h"
+#include "simlockuibackgroundcontrol.h"
+#include "simlockui.hrh"
+#include "simlockdatahandlingdelegate.h"
+#include "simlocktelephonyproxy.h"
+#include "simlockuikeys.h"
 
 // Resource Includes
-#include <SimLockUI.rsg>
+#include <simlockui.rsg>
 
 // ---------------------------------------------------------------------------
 // CSimLockUIAppUi::CSimLockUIAppUi
--- a/securitydialogs/simlockui/src/SimLockUIBackgroundControl.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/securitydialogs/simlockui/src/SimLockUIBackgroundControl.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -24,17 +24,17 @@
 
 // System Includes
 #include <coemain.h>
-#include <aknsdrawutils.h>                      // AknsDrawUtils
-#include <aknsskininstance.h>                   // MAknsSkinInstance
-#include <aknscontrolcontext.h>                 // MAknsControlContext
-#include <aknsbasicbackgroundcontrolcontext.h>  // CAknsBasicBackgroundControlContext
-#include <AknLayoutScalable_Avkon.cdl.h>        // AknLayoutScalable_Avkon
-#include <aknutils.h>                           // AknsUtils
+#include <AknsDrawUtils.h>                      // AknsDrawUtils
+#include <AknsSkinInstance.h>                   // MAknsSkinInstance
+#include <AknsControlContext.h>                 // MAknsControlContext
+#include <AknsBasicBackgroundControlContext.h>  // CAknsBasicBackgroundControlContext
+#include <aknlayoutscalable_avkon.cdl.h>        // AknLayoutScalable_Avkon
+#include <AknUtils.h>                           // AknsUtils
 
 // User Includes
-#include "SimLockUIBackgroundControl.h"
-#include "SimLockISAServerDefinitions.h"
-#include <SimLockUI.rsg>
+#include "simlockuibackgroundcontrol.h"
+#include "simlockisaserverdefinitions.h"
+#include <simlockui.rsg>
 
 static const TInt KSkinLayoutOption = 2;
 
--- a/securitydialogs/simlockui/src/SimLockUIDocument.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/securitydialogs/simlockui/src/SimLockUIDocument.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -23,15 +23,14 @@
 */
 
 // System Include Files
-#include <RMmCustomAPI.h>           // RMmCustomAPI, RMobilePhone
-#include <MmTsy_names.h>            // KMmTsyModuleName
-#include <RMmCustomAPI.h>
+#include <rmmcustomapi.h>           // RMmCustomAPI, RMobilePhone
+#include <mmtsy_names.h>            // KMmTsyModuleName
 
 // User Include Files
-#include "SimLockDataHandlingDelegate.h"
-#include "SimLockISAServerDefinitions.h"
-#include "SimLockUIAppUi.h"
-#include "SimLockUIDocument.h"
+#include "simlockdatahandlingdelegate.h"
+#include "simlockisaserverdefinitions.h"
+#include "simlockuiappui.h"
+#include "simlockuidocument.h"
 
 // Local Constants
 const TInt KTriesToConnectServer( 2 );
--- a/wim/Scard/src/ScardAccessControl.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/wim/Scard/src/ScardAccessControl.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2003-2010 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"
@@ -693,7 +693,7 @@
             EFileLoggingModeAppend, 
             _L( "CScardAccessControl::InitialiseReader: Opening Reader\n" ) );
 #endif
-        iReader->Open( iStatus );
+        iReader->OpenAsync( iStatus );
         }
 #ifdef _DEBUG    
     else 
--- a/wim/SwimReader/inc/SwimLauncher.h	Tue Feb 02 00:44:34 2010 +0200
+++ b/wim/SwimReader/inc/SwimLauncher.h	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2003-2010 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"
@@ -29,7 +29,7 @@
 *  @lib SwimReader.lib
 *  @since Series60 2.1
 */
-class CSwimReaderLauncher : public MScardReaderLauncher, public CBase 
+class CSwimReaderLauncher : public MScardReaderLauncher, public CBase
     {
     public: // Constructors and destructor
      
--- a/wim/SwimReader/inc/SwimReaderIF.h	Tue Feb 02 00:44:34 2010 +0200
+++ b/wim/SwimReader/inc/SwimReaderIF.h	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2003-2010 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,9 +105,9 @@
         /**
         * Open connection to Etel server
         * @param  aStatus TRequestStatus
-        * @return void 
-        */            
-        void Open( TRequestStatus& aStatus );
+        * @return void
+        */
+        void OpenAsync( TRequestStatus& aStatus );
 
         /**
         * Send a CommandAPDU on a slot and return ResponseAPDU from slot
--- a/wim/SwimReader/src/SwimReaderIF.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/wim/SwimReader/src/SwimReaderIF.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2003-2010 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"
@@ -215,13 +215,13 @@
     }
 
 // -----------------------------------------------------------------------------
-// CSwimReaderIF::Open
+// CSwimReaderIF::OpenAsync
 // Uses CSwimReader::WakeUpL to initialize a connection to the ETEL server.
 // -----------------------------------------------------------------------------
 //
-void CSwimReaderIF::Open( TRequestStatus& aStatus )
+void CSwimReaderIF::OpenAsync( TRequestStatus& aStatus )
     {
-    _WIMTRACE(_L("WIM|SwimReader|CSwimReaderIF::Open|Begin"));
+    _WIMTRACE(_L("WIM|SwimReader|CSwimReaderIF::OpenAsync|Begin"));
     iClientStatus = &aStatus;
     aStatus = KRequestPending;
     
--- a/wim/WimClient/inc/WimSecModule.h	Tue Feb 02 00:44:34 2010 +0200
+++ b/wim/WimClient/inc/WimSecModule.h	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2002-2010 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"
@@ -183,10 +183,10 @@
         TInt GetWIMInfoL(); 
 
         /** 
-        * Handles cleanup for an object which is not derived from CBase
-        * @param aObject -object to be cleaned up
+        * Handles cleanup for an TPinAddress array allocated using new[].
+        * @param aObject - TPinAddress list to be cleaned up
         */
-        static void Cleanup( TAny* aObject );
+        static void CleanupPinAddressList( TAny* aObject );
 
         /** 
         * Converts serialnumber to 8-bit form. Conversion reads
--- a/wim/WimClient/src/WimCert.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/wim/WimClient/src/WimCert.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2002-2010 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"
@@ -330,10 +330,8 @@
             else
                 {
                 TCertificateAddressList  certRefLst = 
-                     new( ELeave ) TCertificateAddress[iCertCount]; 
-
-                CleanupStack::PushL( TCleanupItem( CleanupRefLst,
-                                                   certRefLst ) );
+                     new( ELeave ) TCertificateAddress[ iCertCount ];
+                CleanupStack::PushL( TCleanupItem( CleanupRefLst, certRefLst ) );
 
                 TWimCertInfo* certInfoArr = new( ELeave ) 
                                         TWimCertInfo[iCertCount];
@@ -681,13 +679,14 @@
 
 // -----------------------------------------------------------------------------
 // CWimCert::CleanupRefLst()
-// Handles cleanup for an object which is not derived from CBase
+// Handles cleanup of an TCertificateAddressList array
 // -----------------------------------------------------------------------------
 //
 void CWimCert::CleanupRefLst( TAny* aObject )
     {
     _WIMTRACE ( _L( "CWimCert::CleanupRefLst()" ) );
-    delete[] aObject;  
+    TCertificateAddressList* certRefLst = static_cast< TCertificateAddressList* >( aObject );
+    delete[] certRefLst;
     aObject = NULL;
     }
 
--- a/wim/WimClient/src/WimSecModule.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/wim/WimClient/src/WimSecModule.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2002-2010 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"
@@ -481,8 +481,8 @@
     
     if ( pinCount )
         {
-        TPinAddress* pinLst = new( ELeave ) TPinAddress[pinCount];  
-        CleanupStack::PushL( TCleanupItem( Cleanup, pinLst ) );
+        TPinAddress* pinLst = new( ELeave ) TPinAddress[ pinCount ];
+        CleanupStack::PushL( TCleanupItem( CleanupPinAddressList, pinLst ) );
         
         status = iClientSession->PINRefs( iReference, iPinLstAddr, pinLst,
                                         ( TText8 )pinCount );
@@ -549,9 +549,8 @@
     
     if ( pinCount )
         {
-        TPinAddress* pinLst = new( ELeave ) TPinAddress[pinCount];  
-        
-        CleanupStack::PushL( TCleanupItem( Cleanup, pinLst ) );
+        TPinAddress* pinLst = new( ELeave ) TPinAddress[ pinCount ];
+        CleanupStack::PushL( TCleanupItem( CleanupPinAddressList, pinLst ) );
         
         status = iClientSession->PINRefs( iReference, iPinLstAddr, pinLst,
                                         ( TText8 )pinCount );
@@ -610,14 +609,15 @@
 
 
 // -----------------------------------------------------------------------------
-// CWimSecModule::Cleanup()
-// Handles cleanup for an object which is not derived from CBase
+// CWimSecModule::CleanupPinAddressList()
+// Handles cleanup of an TPinAddress array
 // -----------------------------------------------------------------------------
 //
-void CWimSecModule::Cleanup( TAny* aObject )
+void CWimSecModule::CleanupPinAddressList( TAny* aObject )
     {
     _WIMTRACE ( _L( "CWimSecModule::Cleanup()" ) );
-    delete aObject;
+    TPinAddress* pinLst = static_cast< TPinAddress* >( aObject );
+    delete[] pinLst;
     aObject = NULL;
     }
 
--- a/wim/WimServer/inc/WimCertHandler.h	Tue Feb 02 00:44:34 2010 +0200
+++ b/wim/WimServer/inc/WimCertHandler.h	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2002-2010 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"
@@ -31,33 +31,33 @@
 
 /**
 *  Class for handling certificates in WIM card
-*  
+*
 *  @since Series60 2.1
 */
 class CWimCertHandler : public CBase
     {
     public:  // Constructors and destructor
-        
+
         /**
         * Two-phased constructor.
         */
         static CWimCertHandler* NewL();
-        
+
         /**
         * Destructor.
         */
         virtual ~CWimCertHandler();
 
     public: // New functions
-        
+
         /**
         * Fetches certificates from WIM card.
         * @param aMessage Encapsulates a client request.
         * @param aWimMgmt Pointer to WIM reference management class.
         */
-        void GetCertificatesFromWimL( const RMessage2& aMessage, 
+        void GetCertificatesFromWimL( const RMessage2& aMessage,
                                       CWimMemMgmt* aWimMgmt );
-        
+
         /**
         * Fetches certificate extra information from WIM card.
         * Extra information includes trusted usage and CDF referense
@@ -65,23 +65,23 @@
         * @param aMessage Encapsulates a client request.
         * @param aWimMgmt Pointer to WIM reference management class.
         */
-        void GetExtrasFromWimL( const RMessage2& aMessage, 
+        void GetExtrasFromWimL( const RMessage2& aMessage,
                                 CWimMemMgmt* aWimMgmt );
-        
+
         /**
         * Fetches count of certicates in certain WIM card.
         * @param aMessage Encapsulates a client request.
         * @param aWimMgmt Pointer to WIM reference management class.
         */
-        void GetCerticateCountL( const RMessage2& aMessage, 
+        void GetCerticateCountL( const RMessage2& aMessage,
                                  CWimMemMgmt* aWimMgmt ) const;
 
 
         /**
         * Stores certificate to the WIM card.
         * @since Series60 2.6
-        * @param aRequest Enumerator used in message 
-                          passing between client and server.   
+        * @param aRequest Enumerator used in message
+                          passing between client and server.
         * @param aMessage Encapsulates a client request.
         */
         void StoreCertificateL( TWimServRqst aRequest,
@@ -95,11 +95,11 @@
         */
         void RemoveCertificateL( const RMessage2& aMessage,
                                  CWimMemMgmt* aWimMgmt ) const;
-        
+
         /**
         * Fetches certificate details.
-        * @param aOpCode Enumerator used in message 
-                          passing between client and server.   
+        * @param aOpCode Enumerator used in message
+                          passing between client and server.
         * @param aMessage Encapsulates a client request.
         */
         void GetCertificateDetailsL( TWimServRqst aOpCode,
@@ -111,14 +111,14 @@
         * @param aMessage Encapsulates a client request.
         */
         void ExportPublicKeyL( const RMessage2& aMessage ) const;
-        
-        
+
+
         TBool SanityCheck( TUint32 aCertRef );
-        
+
         TBool CheckReadCapsForUsage( const RMessage2& aMsg,
                                        TUint8 aUsage );
-        
-        
+
+
         WIMI_STAT ResolveCertUsage( const RMessage2& aMsg,
                                                 TUint8& aUsage );
 
@@ -143,7 +143,7 @@
                                              TInt8 aUsage,
                                              TUint8& aCertNum,
                                              TUint32* aCertRefLst,
-                                             TWimCertInfo* aCertInfoLst,  
+                                             TWimCertInfo* aCertInfoLst,
                                              const RMessage2& aMessage );
 
         /**
@@ -154,7 +154,7 @@
         * @return TInt      KErrNone or KErrArgument
         */
         TInt CopyCertificateInfo( TWimCertInfo& aCertInfo,
-                                   WIMI_Ref_t* aCert,  
+                                   WIMI_Ref_t* aCert,
                                    const RMessage2& aMessage );
 
         /**
@@ -165,7 +165,7 @@
         * @param aMessage   Encapsulates a client request.
         * @return Status returned by WIMI. See in WimClsv.h.
         */
-        WIMI_STAT GetExtrasFromWimRefL( WIMI_Ref_t* aTmpWimRef,                                  
+        WIMI_STAT GetExtrasFromWimRefL( WIMI_Ref_t* aTmpWimRef,
                                         TInt8 aUsage,
                                         TDesC8& aKeyHash,
                                         const RMessage2& aMessage );
@@ -187,8 +187,8 @@
         * @param aUsage     Certificate usage.
         * @return Status returned by WIMI. See in wimclsv.h.
         */
-        WIMI_STAT GetCertificateCountByWIM( WIMI_Ref_t* aRef, 
-                                            TUint8& aCertCount, 
+        WIMI_STAT GetCertificateCountByWIM( WIMI_Ref_t* aRef,
+                                            TUint8& aCertCount,
                                             TUint8 aUsage ) const;
 
         /**
@@ -202,6 +202,13 @@
                                   TDes8& aPublicKey,
                                   const TUint8 aCertType ) const;
 
+        /**
+         * Returns WIM reference. Returns WIM ref cached in aWimMgmt, or
+         * fetches new using WIMI_GetWIMRef() and caches it in aWimMgmt.
+         * @since Serier60 5.2
+         * @param aWimMgmt  WIM memory manager
+         */
+        WIMI_Ref_t* MainWimRef( CWimMemMgmt& aWimMgmt ) const;
 
     private:    // Data
         CWimUtilityFuncs* iWimUtilFuncs;
@@ -209,5 +216,5 @@
     };
 
 #endif      // CWIMCERTHANDLER_H
-    
+
 //End of File
--- a/wim/WimServer/inc/WimServer.h	Tue Feb 02 00:44:34 2010 +0200
+++ b/wim/WimServer/inc/WimServer.h	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2003-2010 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"
@@ -137,20 +137,20 @@
  * close.
  *
  *  @lib
- *  @since S60 
+ *  @since S60
  */
 class CShutdown : public CTimer
-    {  
+    {
     public:
-    
+
         inline CShutdown();
-        
+
         inline void ConstructL();
-        
+
         inline void Start();
-        
+
     private:
-        
+
         void RunL();
     };
 
@@ -219,23 +219,26 @@
         /**
         * Initializes WIMI if not yet initialized.
         * In initalization WIM data from card is fetched to WIMI.
+        * @param aMessage  Client request, completed to return initialization status.
         * @return void
         */
         void WimInitialize( const RMessage2& aMessage );
-        
+
         /**
         * Cancel Initializes WIMI if not yet initialized.
         * Stop the apdu sending
+        * @param aMessage  Client request, completed with KErrNone.
         * @return void
         */
         void CancelWimInitialize( const RMessage2& aMessage );
 
         /**
         * Set WimInitialized flag
-        * @param aInitialized ETrue/EFalse whether WIM is initialized
+        * @param aInitialized  ETrue/EFalse whether WIM is initialized
+        * @param aWimStatus    KErrNone or other error code
         * @return void
         */
-        static void SetWimInitialized( TBool aInitialized, TInt aStatus  );
+        static void SetWimInitialized( TBool aInitialized, TInt aWimStatus );
 
         /**
         * Get TrustSettingsStore pointer
@@ -276,17 +279,17 @@
         * @param  TBool  Refresh event received from SAT.
         */
         void SetRefreshNotificationReceived( TBool aValue );
-        
+
         /**
         * Return the pointer of Timer
         */
         CWimTimer* WimTimer();
-        
+
         /**
         * Interface derived from MWimTimerListener
         */
         void TimerExpired();
-        
+
 #ifdef WIMSERVER_SHUTDOWN
         void AddSession();
 
@@ -421,7 +424,7 @@
         // Pointer to CServer object
         static CWimServer*   iWimServer;
         // Callback structure for WIMI
-       
+
         /**
         * Current service is accessing physical token.
         * Used to determine if SIM Refresh can be allowed.
@@ -444,13 +447,13 @@
         *
         */
    		CWimBTSapObserver* iBTSapObserver;
-   		  
-   		  // Pointer to Timer. Owned
-   		  CWimTimer* iWimTimer;
+
+        // Pointer to Timer. Owned
+        CWimTimer* iWimTimer;
 
-#ifdef WIMSERVER_SHUTDOWN   		  
+#ifdef WIMSERVER_SHUTDOWN
    		CShutdown iShutdown;
-#endif   		
+#endif
     };
 
 #endif      // CWIMSERVER_H
--- a/wim/WimServer/src/WimCertHandler.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/wim/WimServer/src/WimCertHandler.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2002-2010 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"
@@ -68,7 +68,7 @@
 // Two-phased constructor.
 // -----------------------------------------------------------------------------
 //
-CWimCertHandler* CWimCertHandler::NewL() 
+CWimCertHandler* CWimCertHandler::NewL()
     {
     _WIMTRACE(_L("WIM | WIMServer | CWimCertHandler::NewL | Begin"));
     CWimCertHandler* self = new( ELeave ) CWimCertHandler;
@@ -78,7 +78,7 @@
     return self;
     }
 
-    
+
 // Destructor
 CWimCertHandler::~CWimCertHandler()
     {
@@ -101,7 +101,7 @@
 // -----------------------------------------------------------------------------
 //
 void CWimCertHandler::GetCertificatesFromWimL(
-    const RMessage2& aMessage, 
+    const RMessage2& aMessage,
     CWimMemMgmt* aWimMgmt )
     {
     _WIMTRACE(_L("WIM | WIMServer | CWimCertHandler::GetCertificatesFromWimL | Begin"));
@@ -117,16 +117,12 @@
     TUint32* pCertRefLst = ( TUint32* )( certRefLst->Des().Ptr() );
     TWimCertInfo* pCertInfoLst = ( TWimCertInfo* )( certInfoLst->Des().Ptr() );
 
-    temp = aWimMgmt->WimRef();
-    if ( !temp )
-        { 
-        temp = WIMI_GetWIMRef( 0 );
-        aWimMgmt->SetWIMRef( temp );    // takes ownership
-        }
+    __ASSERT_ALWAYS( aWimMgmt, User::Leave( KErrArgument ) );
+    temp = MainWimRef( *aWimMgmt );
 
     if ( temp )
         {
-        if ( EWimEntryTypeAll == certEntryType || 
+        if ( EWimEntryTypeAll == certEntryType ||
              EWimEntryTypeCA == certEntryType )
             {
             callStatus = GetCertificateFromWimRefL( temp, WIMI_CU_CA,
@@ -134,7 +130,7 @@
                                                     pCertInfoLst, aMessage );
 
             }
-        if ( callStatus == WIMI_Ok && ( EWimEntryTypeAll == certEntryType || 
+        if ( callStatus == WIMI_Ok && ( EWimEntryTypeAll == certEntryType ||
                                    EWimEntryTypePersonal == certEntryType ) )
             {
             callStatus = GetCertificateFromWimRefL( temp, WIMI_CU_Client,
@@ -142,7 +138,7 @@
                                                     pCertInfoLst, aMessage );
 
             }
-        
+
         //record the ref for sanity checking, deallocate old refs first
         for( TInt index = 0; index < iCertRefLst.Count(); ++index )
             {
@@ -157,7 +153,7 @@
             _WIMTRACE2(_L("WIM | WIMServer | CWimCertHandler::GetCertificatesFromWimL, +ref 0x%08x"), pCertRefLst[ index ]);
             iCertRefLst.AppendL( pCertRefLst[ index ] );
             }
-        
+
         aMessage.WriteL( 0, certRefLst->Des() );
         aMessage.WriteL( 1, certInfoLst->Des() );
         }
@@ -185,13 +181,13 @@
     _WIMTRACE(_L("WIM | WIMServer | CWimCertHandler::GetCertificateFromWimRefL | Begin"));
     TUint8 tempCrtCount;
     WIMI_RefList_t refList = NULL;
-    WIMI_STAT callStatus = WIMI_Ok;
+    WIMI_STAT callStatus = WIMI_ERR_BadReference;
 
     if ( aTmpWimRef )
         {
-        callStatus = WIMI_GetCertificateListByWIM( aTmpWimRef, 
-                                                   aUsage, 
-                                                   &tempCrtCount, 
+        callStatus = WIMI_GetCertificateListByWIM( aTmpWimRef,
+                                                   aUsage,
+                                                   &tempCrtCount,
                                                    &refList );
 
         if ( callStatus == WIMI_Ok )
@@ -218,8 +214,8 @@
                     free_WIMI_Ref_t( refList[certIndex] );
                     }
                 }
-            //variable step is equal to the number of certificate in CDF whose 
-            //length is set as 0.     
+            //variable step is equal to the number of certificate in CDF whose
+            //length is set as 0.
             aCertNum = static_cast< TUint8 >( aCertNum + tempCrtCount - step );
 
             // Because list items are moved to aCertRefLst, only refList array
@@ -255,7 +251,7 @@
     TUint8 type;
     TUint16 certLen;
     TUint8 modifiable = 0;
-    WIMI_STAT callStatus = WIMI_GetCertificateInfo( 
+    WIMI_STAT callStatus = WIMI_GetCertificateInfo(
                                 aCert,
                                 &tempRef,
                                 &ptLabel,
@@ -265,10 +261,10 @@
                                 &ptTrustedUsage,
                                 &uiCDFRefs,
                                 &usage,  /* 0 = client, 1 = CA */
-                                &type,   /* WTLSCert(1), 
-                                            X509Cert(2), 
-                                            X968Cert(3), 
-                                            CertURL(4) */ 
+                                &type,   /* WTLSCert(1),
+                                            X509Cert(2),
+                                            X968Cert(3),
+                                            CertURL(4) */
                                 &certLen,   /* cert. content or URL length */
                                 &modifiable );
 
@@ -289,7 +285,7 @@
             }
 
         // it is x509cert
-        if ( type == 2 && certLen != 0 )
+        if ( type == WIMI_CT_X509 && certLen != 0 )
             {
             //use this rough sanity checking for temp
             if ( certLen < 10 )
@@ -307,33 +303,33 @@
 
         aCertInfo.iLabel.Copy(
             TPtr8(
-                ptLabel.pb_buf, 
-                ptLabel.ui_buf_length, 
+                ptLabel.pb_buf,
+                ptLabel.ui_buf_length,
                 ptLabel.ui_buf_length ) );
 
         aCertInfo.iKeyId.Copy(
             TPtr8(
-                ptKeyID.pb_buf, 
-                ptKeyID.ui_buf_length, 
+                ptKeyID.pb_buf,
+                ptKeyID.ui_buf_length,
                 ptKeyID.ui_buf_length ) );
-        
+
         aCertInfo.iCAId.Copy(
             TPtr8(
-                ptCAID.pb_buf, 
-                ptCAID.ui_buf_length, 
+                ptCAID.pb_buf,
+                ptCAID.ui_buf_length,
                 ptCAID.ui_buf_length ) );
-        
+
         aCertInfo.iIssuerHash.Copy(
             TPtr8(
-                ptIssuerHash.pb_buf, 
-                ptIssuerHash.ui_buf_length, 
+                ptIssuerHash.pb_buf,
+                ptIssuerHash.ui_buf_length,
                 ptIssuerHash.ui_buf_length ) );
 
         aCertInfo.iUsage = usage;
         aCertInfo.iType = type;
         aCertInfo.iCertlen = certLen;
         aCertInfo.iModifiable = modifiable;
-        
+
         // Certificate location
         aCertInfo.iCDFRefs = iWimUtilFuncs->MapCertLocation( uiCDFRefs );
 
@@ -357,23 +353,19 @@
 // -----------------------------------------------------------------------------
 //
 void CWimCertHandler::GetExtrasFromWimL(
-    const RMessage2& aMessage, 
+    const RMessage2& aMessage,
     CWimMemMgmt* aWimMgmt )
     {
     _WIMTRACE(_L("WIM | WIMServer | CWimCertHandler::GetExtrasFromWimL | Begin"));
 
     WIMI_STAT callStatus = WIMI_Ok;
     TInt8 certUsage = 0;
-    
+
     HBufC8* keyIdBuf = iWimUtilFuncs->DesLC( 0, aMessage );
     TPtrC8 keyIdHash = keyIdBuf->Des();
 
-    WIMI_Ref_t* wimTempRef = aWimMgmt->WimRef();
-    if ( !wimTempRef )
-        { 
-        wimTempRef = WIMI_GetWIMRef( 0 );
-        aWimMgmt->SetWIMRef( wimTempRef );  // takes ownership
-        }
+    __ASSERT_ALWAYS( aWimMgmt, User::Leave( KErrArgument ) );
+    WIMI_Ref_t* wimTempRef = MainWimRef( *aWimMgmt );
 
     if ( wimTempRef )
         {
@@ -427,7 +419,7 @@
     const RMessage2& aMessage )
     {
     _WIMTRACE(_L("WIM | WIMServer | CWimCertHandler::GetExtrasFromWimRefL | Begin"));
-  
+
     TUint8 tempCertCount = 0;
     WIMI_RefList_t certRefList = NULL;
     WIMI_STAT callStatus = WIMI_Ok;
@@ -437,19 +429,20 @@
     if ( aTmpWimRef )
         {
         // List all certificates (by WIM and usage)
-        callStatus = WIMI_GetCertificateListByWIM( aTmpWimRef, 
-                                                   aUsage, 
-                                                   &tempCertCount, 
+        callStatus = WIMI_GetCertificateListByWIM( aTmpWimRef,
+                                                   aUsage,
+                                                   &tempCertCount,
                                                    &certRefList );
         }
     else
         {
         callStatus = WIMI_ERR_BadReference;
         }
-    CleanupPushWimRefListL( certRefList );
-    
+
     if ( callStatus == WIMI_Ok )
         {
+        CleanupPushWimRefListL( certRefList );
+
         WIMI_Ref_t* tempRef = NULL;
         WIMI_BinData_t ptLabel;
         WIMI_BinData_t ptKeyID;
@@ -474,7 +467,7 @@
                                                   &ptTrustedUsage,
                                                   &uiCDFRefs,
                                                   &usage,
-                                                  &certType,   
+                                                  &certType,
                                                   &certLen,
                                                   &modifiable );
             if ( callStatus == WIMI_Ok )
@@ -548,7 +541,7 @@
     certExtraInfo.iCDFRefs = 0;
     certExtraInfo.iTrustedUsage = NULL;
 
-    WIMI_STAT callStatus = WIMI_GetCertificateInfo( 
+    WIMI_STAT callStatus = WIMI_GetCertificateInfo(
                                 aCert,
                                 &tempref,
                                 &ptLabel,
@@ -558,9 +551,9 @@
                                 &ptTrustedUsage,
                                 &uiCDFRefs,
                                 &usage,  /* 0 = client, 1 = CA */
-                                &type,   
+                                &type,
                                 &certlen,   /* cert. content or URL length */
-                                &modifiable); 
+                                &modifiable);
     if ( callStatus == WIMI_Ok )
         {
         free_WIMI_Ref_t( tempref );
@@ -573,7 +566,7 @@
         pushedItemCount++;
 
         TPtrC8 undecodedUsage;
-        undecodedUsage.Set( ptTrustedUsage.pb_buf ); 
+        undecodedUsage.Set( ptTrustedUsage.pb_buf );
 
         if ( ptTrustedUsage.ui_buf_length == 0 ) // No OIDs
             {
@@ -606,7 +599,7 @@
                         }
                     else    // Not found OID from buffer
                         {
-                        found = EFalse;    
+                        found = EFalse;
                         CleanupStack::PopAndDestroy( decodedOIDs );
                         }
                     decodedOIDs = NULL;
@@ -633,7 +626,7 @@
             pushedItemCount++;
 
             trustedUsage.Set( trustedUsagesBuf->Des() );
-       
+
             // Add OID's to one buffer from separate buffers
             for ( TInt i = 0; i < decodedOIDArray.Count(); i++ )
                 {
@@ -651,9 +644,9 @@
 
         TPckgBuf<TCertExtrasInfo> wimCertExtraPckg( certExtraInfo );
         aMessage.ReadL( 1, wimCertExtraPckg );
-        
+
         wimCertExtraPckg().iCDFRefs = iWimUtilFuncs->MapCertLocation( uiCDFRefs );
-        
+
         if ( oidsLength > 0 ) // OID's found, write buffer to client
             {
             aMessage.WriteL( 3, trustedUsage );
@@ -670,13 +663,13 @@
 // -----------------------------------------------------------------------------
 //
 void CWimCertHandler::GetCerticateCountL(
-    const RMessage2& aMessage, 
+    const RMessage2& aMessage,
     CWimMemMgmt* aWimMgmt ) const
     {
     _WIMTRACE(_L("WIM | WIMServer | CWimCertHandler::GetCerticateCountL | Begin"));
     WIMI_STAT callStatus = WIMI_Ok;
     TWimEntryType certEntryType = ( TWimEntryType )aMessage.Int1();
-    
+
     __ASSERT_ALWAYS( certEntryType != EWimEntryTypeAll ||
         certEntryType != EWimEntryTypeCA ||
         certEntryType != EWimEntryTypePersonal, User::Leave( KErrArgument ) );
@@ -684,28 +677,24 @@
     WIMI_Ref_t* wimRef = NULL;
     TUint8 certCount = 0;
 
-    wimRef = aWimMgmt->WimRef();
-    if ( !wimRef )
-        {
-        wimRef = WIMI_GetWIMRef( 0 );
-        aWimMgmt->SetWIMRef( wimRef );  // takes ownership
-        }
+    __ASSERT_ALWAYS( aWimMgmt, User::Leave( KErrArgument ) );
+    wimRef = MainWimRef( *aWimMgmt );
 
     if ( wimRef )
         {
-        if ( EWimEntryTypeAll == certEntryType || 
+        if ( EWimEntryTypeAll == certEntryType ||
             EWimEntryTypeCA == certEntryType )
             {
-            callStatus = GetCertificateCountByWIM( wimRef, 
-                                                   certCount, 
-                                                   WIMI_CU_CA );            
+            callStatus = GetCertificateCountByWIM( wimRef,
+                                                   certCount,
+                                                   WIMI_CU_CA );
             }
 
-        if ( callStatus == WIMI_Ok && ( EWimEntryTypeAll == certEntryType || 
+        if ( callStatus == WIMI_Ok && ( EWimEntryTypeAll == certEntryType ||
                                      EWimEntryTypePersonal == certEntryType ) )
             {
-            callStatus = GetCertificateCountByWIM( wimRef, 
-                                                   certCount, 
+            callStatus = GetCertificateCountByWIM( wimRef,
+                                                   certCount,
                                                    WIMI_CU_Client );
             }
         }
@@ -730,25 +719,25 @@
 // -----------------------------------------------------------------------------
 //
 WIMI_STAT CWimCertHandler::GetCertificateCountByWIM(
-    WIMI_Ref_t* aRef, 
-    TUint8& aCertCount, 
+    WIMI_Ref_t* aRef,
+    TUint8& aCertCount,
     TUint8 aUsage ) const
     {
     _WIMTRACE(_L("WIM | WIMServer | CWimCertHandler::GetCertificateCountByWIM | Begin"));
-    
+
     // Get the number of certificates from smart card.
     TUint8 certNum = 0;
     WIMI_RefList_t refList ;
-    WIMI_STAT callStatus = WIMI_GetCertificateListByWIM( aRef, 
+    WIMI_STAT callStatus = WIMI_GetCertificateListByWIM( aRef,
                                                          aUsage,
-                                                         &certNum, 
+                                                         &certNum,
                                                          &refList );
 
-    if ( callStatus != WIMI_Ok )   
+    if ( callStatus != WIMI_Ok )
         {
     	return callStatus;
         }
-    
+
     // Find out how many certificate has zero length
     TInt certLenZero = 0;
     TInt certMalformat = 0;
@@ -765,7 +754,7 @@
 	    TUint8 type;
 	    TUint16 certLen;
 	    TUint8 modifiable = 0;
-	    callStatus = WIMI_GetCertificateInfo( 
+	    callStatus = WIMI_GetCertificateInfo(
 	                                refList[i],
 	                                &tempRef,
 	                                &ptLabel,
@@ -775,24 +764,24 @@
 	                                &ptTrustedUsage,
 	                                &uiCDFRefs,
 	                                &usage,  /* 0 = client, 1 = CA */
-	                                &type,   /* WTLSCert(1), 
-	                                            X509Cert(2), 
-	                                            X968Cert(3), 
-	                                            CertURL(4) */ 
+	                                &type,   /* WTLSCert(1),
+	                                            X509Cert(2),
+	                                            X968Cert(3),
+	                                            CertURL(4) */
 	                                &certLen,   /* cert. content or URL length */
 	                                &modifiable );
 
 	    if ( callStatus == WIMI_Ok )
 	        {
 	        free_WIMI_Ref_t( tempRef );
-	        
+
 	        if ( certLen == 0 )
 	            {
 	            certLenZero++;
 	            }
 
             // it is x509cert
-            if ( type == 2 && certLen != 0 )
+            if ( type == WIMI_CT_X509 && certLen != 0 )
                 {
 
                 //use this rough sanity checking
@@ -826,7 +815,7 @@
 // Stores certificate to the WIM card.
 // -----------------------------------------------------------------------------
 //
-void CWimCertHandler::StoreCertificateL( 
+void CWimCertHandler::StoreCertificateL(
     TWimServRqst /*aOpcode*/,
     const RMessage2& aMessage ) const
     {
@@ -839,7 +828,7 @@
 // Removes certificate from a WIM card.
 // -----------------------------------------------------------------------------
 //
-void CWimCertHandler::RemoveCertificateL( 
+void CWimCertHandler::RemoveCertificateL(
     const RMessage2& aMessage,
     CWimMemMgmt* /*aWimMgmt*/ ) const
     {
@@ -858,7 +847,7 @@
         {
         return EFalse;
         }
-    
+
     for ( TInt index = 0; index < certNum; ++index )
         {
         if( aCertRef == iCertRefLst[ index ] )
@@ -875,8 +864,8 @@
 // -----------------------------------------------------------------------------
 //
 void CWimCertHandler::GetCertificateDetailsL(
-    TWimServRqst aOpCode, 
-    const RMessage2& aMessage ) 
+    TWimServRqst aOpCode,
+    const RMessage2& aMessage )
     {
     _WIMTRACE(_L("WIM | WIMServer | CWimCertHandler::GetCertificateDetailsL | Begin"));
     TBool IsOk = SanityCheck( (TUint32)aMessage.Ptr0() );
@@ -885,7 +874,7 @@
         aMessage.Panic(_L("WIM"), KErrBadHandle );
         return;
         }
-    
+
     //capability checking
     TUint8 usage = 255;
     WIMI_STAT callStatus = ResolveCertUsage( aMessage, usage );
@@ -893,7 +882,7 @@
         {
         if( !CheckReadCapsForUsage( aMessage, usage  ) )
               {
-              aMessage.Complete(KErrPermissionDenied);  
+              aMessage.Complete(KErrPermissionDenied);
               return;
               }
         }
@@ -926,7 +915,7 @@
     _WIMTRACE(_L("CWimServer::ResolveCertUsage | Begin"));
 
     // aMsg.Ptr0 contains reference to certificate
-    
+
     WIMI_Ref_pt pCertRef = const_cast< WIMI_Ref_pt >( aMsg.Ptr0() );
     _WIMTRACE2(_L("CWimServer::ResolveCertUsage | Begin aMsg.Ptr0() = %d"), aMsg.Ptr0());
 
@@ -998,7 +987,7 @@
                                TUint8 aUsage )
     {
     TBool result = EFalse;
-    
+
     switch ( aUsage )
         {
         case WIMI_CU_CA:
@@ -1041,13 +1030,13 @@
 //
 void CWimCertHandler::ExportPublicKeyL( const RMessage2& aMessage ) const
     {
-    _WIMTRACE(_L("WIM | WIMServer | CWimPublicKeyHandler::ExportPublicKeyParamsL | Begin"));
+    _WIMTRACE(_L("WIM | WIMServer | CWimPublicKeyHandler::ExportPublicKeyL | Begin"));
 
     TUint8 certType = 0;
 
     TPckgBuf<TExportPublicKey> keyExportPckg;
     aMessage.ReadL( 0, keyExportPckg );
-    
+
     HBufC8* publicKeyBuf = HBufC8::NewLC( KPublicKeyLength );
 
     TBuf8<KKeyIdLen> keyIdBuf = keyExportPckg().iKeyId;
@@ -1118,7 +1107,7 @@
                                                   &ptTrustedUsage,
                                                   &uiCDFRefs,
                                                   &usage,
-                                                  &certType,   
+                                                  &certType,
                                                   &certLen,
                                                   &modifiable );
             if ( callStatus == WIMI_Ok )
@@ -1142,7 +1131,7 @@
                     }
                 }
             }
-    
+
         // Retrieve certificate data from WIM
         if ( callStatus == WIMI_Ok )
             {
@@ -1154,8 +1143,9 @@
                 TPtrC8 certPtr( ptCertData.pb_buf, ptCertData.ui_buf_length );
                 TPtr8 publicKeyPtr = publicKeyBuf->Des();
 
-                TRAPD( parseOk, ParseCertPublicKeyL( certPtr, publicKeyPtr, certType ) );
-                if ( parseOk )
+                TRAPD( parseError, ParseCertPublicKeyL( certPtr, publicKeyPtr, certType ) );
+                _WIMTRACE2(_L("WIM | WIMServer | CWimPublicKeyHandler::ExportPublicKeyL parseError %d"), parseError );
+                if ( !parseError )
                     {
                     aMessage.WriteL( 1, publicKeyPtr );
                     }
@@ -1167,13 +1157,15 @@
                 CleanupStack::PopAndDestroy( ptCertData.pb_buf );
                 }
             }
-        
+
         CleanupStack::PopAndDestroy( certRefList );
         }
 
     CleanupStack::PopAndDestroy( publicKeyBuf );
 
+    _WIMTRACE2(_L("WIM | WIMServer | CWimPublicKeyHandler::ExportPublicKeyL callStatus %d"), callStatus);
     aMessage.Complete( CWimUtilityFuncs::MapWIMError( callStatus ) );
+    _WIMTRACE(_L("WIM | WIMServer | CWimPublicKeyHandler::ExportPublicKeyL | End"));
     }
 
 // -----------------------------------------------------------------------------
@@ -1186,6 +1178,7 @@
     TDes8& aPublicKey,
     const TUint8 aCertType ) const
     {
+    _WIMTRACE2(_L("WIM | WIMServer | CWimPublicKeyHandler::ParseCertPublicKeyL | Begin, type %d"), aCertType);
     CCertificate* certificate = NULL;
     CRSAPublicKey* publicKey = NULL;
 
@@ -1197,7 +1190,7 @@
             publicKey = CWTLSRSAPublicKey::NewLC( certificate->PublicKey().KeyData() );
             break;
             }
-    
+
         case WIMI_CT_X509:
             {
             certificate = CX509Certificate::NewLC( aCertData );
@@ -1227,6 +1220,24 @@
     encoded->WriteDERL( aPublicKey, pos );
 
     CleanupStack::PopAndDestroy( 3, certificate );  // encoded, publicKey, certificate
+    _WIMTRACE(_L("WIM | WIMServer | CWimPublicKeyHandler::ParseCertPublicKeyL | End"));
     }
 
+// -----------------------------------------------------------------------------
+// CWimCertHandler::MainWimRef()
+// Returns cached WIM ref using WIM memory manager
+// -----------------------------------------------------------------------------
+//
+WIMI_Ref_t* CWimCertHandler::MainWimRef( CWimMemMgmt& aWimMgmt ) const
+    {
+    WIMI_Ref_t* ref = aWimMgmt.WimRef();
+    if( !ref )
+        {
+        ref = WIMI_GetWIMRef( 0 );
+        aWimMgmt.SetWIMRef( ref );    // takes ownership
+        }
+    return ref;
+    }
+
+
 //  End of File
--- a/wim/WimServer/src/WimMemMgmt.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/wim/WimServer/src/WimMemMgmt.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2002-2010 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"
@@ -61,7 +61,7 @@
     CleanupStack::Pop( self );
     return self;
     }
-    
+
 // Destructor
 CWimMemMgmt::~CWimMemMgmt()
     {
@@ -185,7 +185,7 @@
 void CWimMemMgmt::FreeWIMRefs( const RMessage2& aMessage )
     {
     _WIMTRACE(_L("WIM | WIMServer | CWimMemMgmt::FreeWIMRefsL | Begin"));
-    TUint wimCount = aMessage.Int1(); 
+    TUint wimCount = aMessage.Int1();
     WIMI_Ref_pt ref = reinterpret_cast< WIMI_Ref_pt >( aMessage.Int0() );
     _WIMTRACE3(_L("WIM | WIMServer | CWimMemMgmt::FreeWIMRefsL | ref 0x%08x, wimCount %d"),
             ref, wimCount);
@@ -193,7 +193,7 @@
     for( TUint8 wimIndex = 0; wimIndex < wimCount; wimIndex++ )
         {
         _WIMTRACE2(_L("WIM | WIMServer | CWimMemMgmt::FreeWIMRefsL | index=%d"), wimIndex);
-        FreeRef( ref );     // TODO: fix, now deallocating the same ref in each loop?
+        FreeRef( ref );
         }
 
     _WIMTRACE(_L("WIM | WIMServer | CWimMemMgmt::FreeWIMRefsL | End"));
@@ -225,7 +225,7 @@
             }
         }
     _WIMTRACE(_L("WIM | WIMServer | CWimMemMgmt::FreeRefLst | not found") );
-    aMessage.Complete( KErrNotFound );              
+    aMessage.Complete( KErrNotFound );
     }
 
 // -----------------------------------------------------------------------------
@@ -239,7 +239,7 @@
     for( TUint8 index = 0; index < count; index++ )
         {
         TWimiAllocRef* allocRef = iRefs[ index ];
-        if( allocRef->ref == aRef )
+        if( allocRef && ( allocRef->ref == aRef ) )
             {
             _WIMTRACE(_L("WIM | WIMServer | CWimMemMgmt::ValidateWIMRefL, valid"));
             return ETrue;
--- a/wim/WimServer/src/WimServer.cpp	Tue Feb 02 00:44:34 2010 +0200
+++ b/wim/WimServer/src/WimServer.cpp	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2003-2010 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"
@@ -38,7 +38,7 @@
 #include    <PSVariables.h>     // Property values
 
 #ifdef WIMSERVER_SHUTDOWN
-const TInt KServerShutdownDelay = 0x200000; 
+const TInt KServerShutdownDelay = 0x200000;
 #endif
 // Initialize static variables. These variables are static because static
 // callback functions in CWimCallBack.
@@ -60,23 +60,23 @@
     _WIMTRACE(_L("WIM | WIMServer | StartServer | Enter"));
     User::LeaveIfError( User::RenameThread( KWIMServerName ) );
     _WIMTRACE(_L("WIM | WIMServer | StartServer | Create AS"));
- 
+
     CActiveScheduler* s = new(ELeave) CActiveScheduler;
-    CleanupStack::PushL( s );    
+    CleanupStack::PushL( s );
 
     CActiveScheduler::Install( s );
-    
+
     _WIMTRACE(_L("WIM | WIMServer | StartServer | Create server"));
-        
+
     CWimServer::NewL();
-      
+
     _WIMTRACE(_L("WIM | WIMServer | StartServer | Notify client"));
     // Notify Client that server has starter
-    RProcess::Rendezvous( KErrNone );       
+    RProcess::Rendezvous( KErrNone );
 
     _WIMTRACE(_L("WIM | WIMServer | StartServer | Start ActiveScheduler"));
     CActiveScheduler::Start();
-       
+
     CleanupStack::PopAndDestroy( s );
     }
 
@@ -91,17 +91,17 @@
     {
     __UHEAP_MARK;
     _WIMTRACE(_L("WIM | WIMServer | E32Main | Begin"));
-  
+
     CTrapCleanup* cleanup=CTrapCleanup::New();
     TInt r=KErrNoMemory;
-    
+
     if ( cleanup )
         {
         TRAP( r, StartServerL() );
         delete cleanup;
         }
-    _WIMTRACE(_L("WIM | WIMServer | E32Main Memory leak checking line"));    
-    __UHEAP_MARKEND;    
+    _WIMTRACE(_L("WIM | WIMServer | E32Main Memory leak checking line"));
+    __UHEAP_MARKEND;
     _WIMTRACE(_L("WIM | WIMServer | E32Main Memory checking passed"));
     return r;
     }
@@ -137,10 +137,10 @@
     iWimSessionRegistry = CWimSessionRegistry::NewL();
     iWimTrustSettingsStore = CWimTrustSettingsStore::NewL();
     iWimTimer = CWimTimer::NewL( this );
-#ifdef WIMSERVER_SHUTDOWN    
+#ifdef WIMSERVER_SHUTDOWN
     iShutdown.ConstructL();
     iShutdown.Start();
-#endif    
+#endif
      _WIMTRACE(_L("WIM | WIMServer | CWimServer::ConstructL | End"));
     }
 
@@ -179,7 +179,7 @@
         WIMI_CloseDownReq();
         _WIMTRACE(_L("WIM | WIMServer | CWimServer::~CWimServer | WIMI_CloseDownReq"));
         }
-    //iWimTrustSettingsStore->CloseD();
+
     delete iWimTrustSettingsStore;
     delete iWimSessionRegistry;
     delete iWimTimer;
@@ -272,14 +272,14 @@
 // Set iWimInitialized flag
 // -----------------------------------------------------------------------------
 //
-void CWimServer::SetWimInitialized( TBool aInitialized, TInt aStatus )
+void CWimServer::SetWimInitialized( TBool aInitialized, TInt aWimStatus )
     {
     _WIMTRACE2(_L("WIM|WIMServer|CWimServer::SetWimInitialized|Value=%d"), aInitialized);
     iWimInitialized = aInitialized;
 
     if ( !aInitialized )
         {
-        iWimStatus = aStatus;
+        iWimStatus = aWimStatus;
         }
     }
 
@@ -348,11 +348,9 @@
 void CWimServer::PanicServer( TWimServerPanic aPanic )
     {
     _WIMTRACE(_L("WIM | WIMServer | CWimServer::PanicServer | Begin"));
-    // Set server state to EWimServerNotRunning
-    TInt retVal = RProperty::Set( KUidSystemCategory,
-                                  KWimServerUid.iUid,
-                                  EWimServerNotRunning );
-    retVal = retVal; // To prevent warning
+
+    // Set server state to EWimServerNotRunning.
+    (void)RProperty::Set( KUidSystemCategory, KWimServerUid.iUid, EWimServerNotRunning );
 
     User::Panic( KWIMServerName, aPanic );
     }
@@ -724,16 +722,16 @@
     	return callStatus;
         }
     free_WIMI_RefList_t( clicertRefList );
-    
+
     if ( clicertCount > 0 )
         {
     	usage = WIMI_CU_Client;
-        }    
+        }
     else
         {
     	TUint8 cacertCount = 0;
         WIMI_RefList_t cacertRefList = NULL;
-    
+
         callStatus = WIMI_GetCertificateListByKeyHash( ( TUint8* ) keyIdBuf.Ptr(),
                                             WIMI_CU_CA,
                                             &cacertCount,
@@ -753,7 +751,7 @@
         	aMsg.Complete( KErrBadHandle );
             }
         }
-    
+
     aUsage = static_cast< TUint8 >( usage );
 
     _WIMTRACE2(_L("CWimServer::ResolveExportPublicReqL | End, heap=%d"),
@@ -919,7 +917,7 @@
 
 // -----------------------------------------------------------------------------
 // CWimServer::TimerExpired()
-// Interface derived from 
+// Interface derived from MWimTimerListener
 // -----------------------------------------------------------------------------
 //
 void CWimServer::TimerExpired()
@@ -928,18 +926,17 @@
     WIMI_Ref_pt pWimRefTemp = NULL;
 
     pWimRefTemp = WIMI_GetWIMRef( 0 );
- 
+
     if ( pWimRefTemp )  // Close the WIM
         {
         WIMI_CloseWIM( pWimRefTemp );
         free_WIMI_Ref_t( pWimRefTemp );
         }
-    //SetWimInitialized( EFalse );
     }
 
 // -----------------------------------------------------------------------------
 // CWimServer::WimTimer()
-// Return the pointer of Timer 
+// Return the pointer of Timer
 // -----------------------------------------------------------------------------
 //
 CWimTimer* CWimServer::WimTimer()
@@ -950,16 +947,16 @@
 
 // -----------------------------------------------------------------------------
 // CWimServer::CancelWimInitialize()
-// Cancel Wim Initialize 
+// Cancel Wim Initialize
 // -----------------------------------------------------------------------------
 //
 void CWimServer::CancelWimInitialize( const RMessage2& aMessage )
     {
 	 if ( !iWimInitialized )
 		 {
-		 CWimCallBack::CancelWimInitialize();	
+		 CWimCallBack::CancelWimInitialize();
 		 }
-	aMessage.Complete( KErrNone );	 
+	aMessage.Complete( KErrNone );
     }
 
 
--- a/wim/inc/ScardReader.h	Tue Feb 02 00:44:34 2010 +0200
+++ b/wim/inc/ScardReader.h	Fri Feb 19 23:42:03 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2003-2010 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"
@@ -54,7 +54,7 @@
         * @param aStatus Request status
         * @return void
         */
-        virtual void Open( TRequestStatus& aStatus ) = 0; 
+        virtual void OpenAsync( TRequestStatus& aStatus ) = 0;
 
         /**
         * Closes the Card Reader. Implementations of this method must carry out