Revision: 201023
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 23 Jun 2010 19:10:54 +0300
changeset 37 7bad16cccaca
parent 26 aad866c37519
child 38 e0432375ea67
Revision: 201023 Kit: 2010125
boottimeintegritycheck/TrkDummy/group/TrkDummy.mmp
boottimeintegritycheck/TrkDummy/group/TrkDummy1.mmp
boottimeintegritycheck/TrkDummy/group/TrkDummy2.mmp
cpsecplugins/cpadvancedsecplugin/inc/cpcertview.h
cpsecplugins/cpadvancedsecplugin/inc/cpmoduleview.h
cpsecplugins/cpadvancedsecplugin/inc/cpsecurityview.h
cpsecplugins/cpadvancedsecplugin/src/cpcertdatacontainer.cpp
cpsecplugins/cpadvancedsecplugin/src/cpcertdetailview.cpp
cpsecplugins/cpadvancedsecplugin/src/cpcertmanuisyncwrapper.cpp
cpsecplugins/cpadvancedsecplugin/src/cpcertpluginloader.cpp
cpsecplugins/cpadvancedsecplugin/src/cpcerttrustview.cpp
cpsecplugins/cpadvancedsecplugin/src/cpcertview.cpp
cpsecplugins/cpadvancedsecplugin/src/cpmoduleview.cpp
cpsecplugins/cpadvancedsecplugin/src/cpsecmodmodel.cpp
cpsecplugins/cpadvancedsecplugin/src/cpsecmodsyncwrapper.cpp
cpsecplugins/cpadvancedsecplugin/src/cpsecmoduleinfoview.cpp
cpsecplugins/cpadvancedsecplugin/src/cpsecmodview.cpp
cpsecplugins/cpadvancedsecplugin/src/cpsecurityview.cpp
cpsecplugins/devicelockplugin/src/cpdevicelockplugin.cpp
cpsecplugins/devicelockplugin/src/cpdevicelockpluginview.cpp
cpsecplugins/devicelockplugin/src/cpremotelockdataformviewitem.cpp
cpsecplugins/inc/cpsecplugins.h
cpsecplugins/simpincodeplugin/src/cppincodeplugin.cpp
cpsecplugins/simpincodeplugin/src/cppincodepluginview.cpp
cpsecplugins/simpincodeplugin/src/seccodeedit.cpp
cpsecplugins/simpincodeplugin/src/seccodeeditdataformviewitem.cpp
cpsecplugins/simpincodeplugin/src/seccodemodel.cpp
cpsecplugins/simpincodeplugin/src/seccodemodel_symbian.cpp
cpsecplugins/simpincodeplugin/src/seccodemodel_win.cpp
cpsecplugins/simpincodeplugin/src/seccodesettings.cpp
package_definition.xml
package_map.xml
pkiutilities/CTSecurityDialogs/Group/CTSecDialogImpl.mmp
pkiutilities/CTSecurityDialogs/NotifInc/CTNoTrustQuery.h
pkiutilities/CTSecurityDialogs/NotifInc/CTSecurityDialogsAO.h
pkiutilities/CTSecurityDialogs/NotifInc/CTUntrustedCertQuery.h
pkiutilities/CTSecurityDialogs/NotifSrc/CTNoTrustQuery.cpp
pkiutilities/CTSecurityDialogs/NotifSrc/CTSecurityDialogsAO.cpp
pkiutilities/CTSecurityDialogs/NotifSrc/CTUntrustedCertQuery.cpp
pkiutilities/CertSaver/data/CertSaver.rss
pkiutilities/CertSaver/group/CertSaver.mmp
pkiutilities/CertSaver/inc/CertSaverModel.h
pkiutilities/CertSaver/loc/certsaver.loc
pkiutilities/CertSaver/src/CertSaverAppUi.cpp
pkiutilities/CertSaver/src/CertSaverDocument.cpp
pkiutilities/CertSaver/src/CertSaverModel.cpp
pkiutilities/CertSaver/src/certparser.cpp
pkiutilities/untrustedcertificatedialog/inc/untrustedcertificatedialog.h
pkiutilities/untrustedcertificatedialog/inc/untrustedcertificateinfo_symbian.h
pkiutilities/untrustedcertificatedialog/inc/untrustedcertificateinfobase.h
pkiutilities/untrustedcertificatedialog/inc/untrustedcertificatewidget.h
pkiutilities/untrustedcertificatedialog/src/untrustedcertificatedialog.cpp
pkiutilities/untrustedcertificatedialog/src/untrustedcertificateinfo_symbian.cpp
pkiutilities/untrustedcertificatedialog/src/untrustedcertificateinfobase.cpp
pkiutilities/untrustedcertificatedialog/src/untrustedcertificateplugin.cpp
pkiutilities/untrustedcertificatedialog/src/untrustedcertificatewidget.cpp
pkiutilities/untrustedcertificatedialog/src/untrustedcertificatewidget_symbian.cpp
pkiutilities/untrustedcertificatedialog/tsrc/dialoglauncher/dialoglauncher.cpp
pkiutilities/untrustedcertificatedialog/tsrc/dialoglauncher/dialoglauncher.iby
pkiutilities/untrustedcertificatedialog/tsrc/dialoglauncher/dialoglauncher.pkg
pkiutilities/untrustedcertificatedialog/tsrc/dialoglauncher/dialoglauncher.pro
pkiutilities/untrustedcertificatedialog/tsrc/dialoglauncher/test_cert_expired.crt
pkiutilities/untrustedcertificatedialog/tsrc/dialoglauncher/test_cert_server.crt
pkiutilities/untrustedcertificatedialog/tsrc/dialoglauncher/test_cert_sha2.crt
pkiutilities/untrustedcertificatedialog/tsrc/tlsconntest/tlsconnection.cpp
pkiutilities/untrustedcertificatedialog/tsrc/tlsconntest/tlsconnection.h
pkiutilities/untrustedcertificatedialog/tsrc/tlsconntest/tlsconnectionapp.cpp
pkiutilities/untrustedcertificatedialog/tsrc/tlsconntest/tlsconnectionapp.h
pkiutilities/untrustedcertificatedialog/tsrc/tlsconntest/tlsconnectionmain.cpp
pkiutilities/untrustedcertificatedialog/tsrc/tlsconntest/tlsconnectionobserver.h
pkiutilities/untrustedcertificatedialog/tsrc/tlsconntest/tlsconntest.iby
pkiutilities/untrustedcertificatedialog/tsrc/tlsconntest/tlsconntest.loc
pkiutilities/untrustedcertificatedialog/tsrc/tlsconntest/tlsconntest.pkg
pkiutilities/untrustedcertificatedialog/tsrc/tlsconntest/tlsconntest.pro
pkiutilities/untrustedcertificatedialog/untrustedcertificateplugin.pro
securitydialogs/Autolock/autolock.qcrml
securitydialogs/Autolock/src/Autolock.cpp
securitydialogs/Autolock/src/Autolock.h
securitydialogs/SecUi/Inc/SecQueryUi.h
securitydialogs/SecUi/Src/SecQueryUi.cpp
securitydialogs/SecUi/Src/SecUi.cpp
securitydialogs/SecUi/Src/SecUiSecurityHandler.cpp
securitydialogs/SecUi/Src/SecUiSecuritySettings.cpp
securitydialogs/SecUi/group/SecUi.mmp
securitydialogs/lockapp/src/lockapp.cpp
securitydialogs/secuinotifications/secuinotificationdialogplugin/inc/secuinotificationcontentwidget.h
securitydialogs/secuinotifications/secuinotificationdialogplugin/inc/secuinotificationdialog.h
securitydialogs/secuinotifications/secuinotificationdialogplugin/inc/secuinotificationdialogpluginkeys.h
securitydialogs/secuinotifications/secuinotificationdialogplugin/rom/secuinotificationdialogplugin.iby
securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationcontentwidget.cpp
securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationdialog.cpp
securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationdialogplugin.cpp
--- a/boottimeintegritycheck/TrkDummy/group/TrkDummy.mmp	Fri Jun 11 14:28:40 2010 +0300
+++ b/boottimeintegritycheck/TrkDummy/group/TrkDummy.mmp	Wed Jun 23 19:10:54 2010 +0300
@@ -12,7 +12,7 @@
 * Contributors:
 *
 * Description:  Dummy exe to prevent installing too liberal TrkApp
-*  Version     : %version: tr1sido#9 %
+*  Version     : %version: tr1sido#10 %
 *
 */
 
@@ -26,9 +26,9 @@
 // This component is built-in'.
 
 
-#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
-  #include <platform_paths.hrh>
-#endif
+
+#include <platform_paths.hrh>
+
 
 CAPABILITY      None
 
@@ -45,13 +45,9 @@
 SOURCE          TrkDummy.cpp
 SOURCE          TrkDummyApplication.cpp
 
-USERINCLUDE     ../inc 
-#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
-	SYSTEMINCLUDE	/epoc32/include  
-#else
-    MW_LAYER_SYSTEMINCLUDE    
-#endif
+USERINCLUDE     ../inc
 
+MW_LAYER_SYSTEMINCLUDE    
 
 LIBRARY         euser.lib
 LIBRARY         apparc.lib
--- a/boottimeintegritycheck/TrkDummy/group/TrkDummy1.mmp	Fri Jun 11 14:28:40 2010 +0300
+++ b/boottimeintegritycheck/TrkDummy/group/TrkDummy1.mmp	Wed Jun 23 19:10:54 2010 +0300
@@ -12,7 +12,7 @@
 * Contributors:
 *
 * Description:  Dummy exe to prevent installing too liberal TrkApp
-*  Version     : %version: 7 %
+*  Version     : %version: 8 %
 *
 */
 
@@ -26,9 +26,9 @@
 // This component is built-in'.
 
 
-#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
-  #include <platform_paths.hrh>
-#endif
+
+#include <platform_paths.hrh>
+
 
 CAPABILITY      None
 
@@ -45,12 +45,9 @@
 SOURCE          TrkDummy.cpp
 SOURCE          TrkDummyApplication.cpp
 
-USERINCLUDE     ../inc 
-#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
-	SYSTEMINCLUDE	/epoc32/include  
-#else
-    MW_LAYER_SYSTEMINCLUDE    
-#endif
+USERINCLUDE     ../inc
+
+MW_LAYER_SYSTEMINCLUDE    
 
 LIBRARY         euser.lib
 LIBRARY         apparc.lib
--- a/boottimeintegritycheck/TrkDummy/group/TrkDummy2.mmp	Fri Jun 11 14:28:40 2010 +0300
+++ b/boottimeintegritycheck/TrkDummy/group/TrkDummy2.mmp	Wed Jun 23 19:10:54 2010 +0300
@@ -12,7 +12,7 @@
 * Contributors:
 *
 * Description:  Dummy exe to prevent installing too liberal TrkApp
-*  Version     : %version: 7 %
+*  Version     : %version: 8 %
 *
 */
 
@@ -26,9 +26,8 @@
 // This component is built-in'.
 
 
-#if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
-  #include <platform_paths.hrh>
-#endif
+
+#include <platform_paths.hrh>
 
 
 CAPABILITY      None
@@ -46,13 +45,9 @@
 SOURCE          TrkDummy.cpp
 SOURCE          TrkDummyApplication.cpp
 
-USERINCLUDE     ../inc 
-#if defined (__SERIES60_30__) || defined(__SERIES60_31__)
-	SYSTEMINCLUDE	/epoc32/include  
-#else
-    MW_LAYER_SYSTEMINCLUDE    
-#endif
+USERINCLUDE     ../inc
 
+MW_LAYER_SYSTEMINCLUDE    
 
 LIBRARY         euser.lib
 LIBRARY         apparc.lib
--- a/cpsecplugins/cpadvancedsecplugin/inc/cpcertview.h	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/cpadvancedsecplugin/inc/cpcertview.h	Wed Jun 23 19:10:54 2010 +0300
@@ -70,7 +70,7 @@
 	private:
 		const CCTCertInfo* certAt(TInt index) const;
 		QString certLabel(TInt index) const;
-		void deleteCerts( RArray<TInt>& indexList );
+		void deleteCertsL( RArray<TInt>& indexList );
 		void setDetails(CpCertView::TCertificateViews currentView);
 		void moveCertList( RArray<TInt>& indexList );
 
@@ -90,6 +90,7 @@
 		HbListView* mSelectAllView;	
 		HbView* mOriginalView;
 		HbMessageBox* mNote;
+		HbMenu* mContextMenu;
 	};
 
 #endif /* CPCERTVIEW_H */
--- a/cpsecplugins/cpadvancedsecplugin/inc/cpmoduleview.h	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/cpadvancedsecplugin/inc/cpmoduleview.h	Wed Jun 23 19:10:54 2010 +0300
@@ -69,6 +69,7 @@
     CpSecModView::TSecModViews mCurrentView;
     CSecModUIModel& mSecModUIModel;
     TInt mPos;
+    HbMenu* mContextMenu;
 };
 
 #endif /* CPMODULEVIEW_H */
--- a/cpsecplugins/cpadvancedsecplugin/inc/cpsecurityview.h	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/cpadvancedsecplugin/inc/cpsecurityview.h	Wed Jun 23 19:10:54 2010 +0300
@@ -56,6 +56,7 @@
 	HbView* mCurrentView;
 	TInt mPos;
 	HbMessageBox* mNote;
+	HbMenu* mContextMenu;
 
 };
 
--- a/cpsecplugins/cpadvancedsecplugin/src/cpcertdatacontainer.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/cpadvancedsecplugin/src/cpcertdatacontainer.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -27,7 +27,7 @@
 #include <HbMessageBox>
 
 #include <QErrorMessage>
-
+#include <../../inc/cpsecplugins.h>
 #include "cpcertdatacontainer.h"
 #include "cpcertmanuisyncwrapper.h"
 
@@ -108,6 +108,7 @@
 // Releases Certificate entries.
 void CpCertManUICertData::Release()
     {
+    RDEBUG("0", 0);
     if ( iCAEntry )
         {
         iCAEntry->Release();
@@ -210,6 +211,7 @@
 //
 void CpCertDataContainer::ConstructL()
     {
+    RDEBUG("0", 0);
     // Ensure that file server session is succesfully created
     User::LeaveIfError( iRfs.Connect() );
 
@@ -272,6 +274,7 @@
 //
 void CpCertDataContainer::RefreshCAEntriesL()
     {
+    RDEBUG("0", 0);
     iFilter->SetOwnerType( ECACertificate );
     iCAEntries.Close();
     CUnifiedCertStore*& store = CertManager();
@@ -378,6 +381,7 @@
 //
 void CpCertDataContainer::RefreshPeerCertEntriesL()
     {
+    RDEBUG("0", 0);
     iFilter->SetOwnerType( EPeerCertificate );
     iPeerEntries.Close();
     CUnifiedCertStore*& store = CertManager();
@@ -458,6 +462,7 @@
 //
 void CpCertDataContainer::RefreshUserCertEntriesL()
     {
+    RDEBUG("0", 0);
     iFilter->SetOwnerType( EUserCertificate );
     iUserEntries.Close();
     CUnifiedCertStore*& store = CertManager();
@@ -594,6 +599,7 @@
 //
 void CpCertDataContainer::RefreshDeviceCertEntriesL()
     {
+    RDEBUG("0", 0);
     iFilter->SetOwnerType( EUserCertificate );
     iDeviceEntries.Close();
     CUnifiedCertStore*& store = CertManager();
--- a/cpsecplugins/cpadvancedsecplugin/src/cpcertdetailview.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/cpadvancedsecplugin/src/cpcertdetailview.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -45,7 +45,7 @@
 #include <hbdataform.h>
 #include <hbdataformmodel.h>
 #include <hbdataformmodelitem.h>
-
+#include <../../inc/cpsecplugins.h>
 #include "cpcertdetailview.h"
 #include "cpcertview.h"
 #include "cpcertdatacontainer.h"
@@ -117,7 +117,7 @@
 
 void CpCertDetailView::viewCertificateDetailsL( TInt aIndex, CpCertView::TCertificateViews aType )
 	{
-	
+	RDEBUG("0", 0);
 	QGraphicsLinearLayout *layout = q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical));	
 	setLayout(layout);
 	
@@ -151,7 +151,7 @@
         {
 		addLabel(*entry, *mCertDetails);
         }
-
+		RDEBUG("0", 0);
     // certificate issuer and owner
     if( certificateFormat == EX509Certificate )
         {
@@ -168,7 +168,7 @@
 		TKeyUsagePKCS15 usage = keyUsageAndLocationL( *entry, &keyLocation );
         addCertUsage(usage, *mCertDetails);		
         }
-
+		RDEBUG("0", 0);
     if( certificateFormat == EX509Certificate )
         {
 		addValidityPeriod( *details, *mCertDetails );                
@@ -205,7 +205,7 @@
         {
         // SetUrlCertAlgorihm()
         }
-
+		RDEBUG("0", 0);
     if( certificateFormat != EX509CertificateUrl )
         {
         CleanupStack::PopAndDestroy( details );
@@ -220,6 +220,7 @@
 
 const CCTCertInfo* CpCertDetailView::certInfo( TInt index, CpCertView::TCertificateViews certView )
 	{
+	RDEBUG("0", 0);
 	const CCTCertInfo* certinfo = NULL;
 	
 	if( certView == CpCertView::EAuthorityView )
@@ -243,6 +244,7 @@
 
 void CpCertDetailView::addTrustedSitesL( const CCertificate& certDetails, HbListWidget& certDisplayDetails )
 	{
+	RDEBUG("0", 0);
 	CTrustSitesStore* trustedSitesStore = CTrustSitesStore::NewL();
 	CleanupStack::PushL( trustedSitesStore );
 
@@ -271,6 +273,7 @@
 
 void CpCertDetailView::addLabel( const CCTCertInfo& aCertInfo, HbListWidget& certDisplayDetails )
 	{
+	RDEBUG("0", 0);
 	QString sLabel("Label:");
 	QString sLabelDetails = "(No label)"; 
 	if(aCertInfo.Label().Length()  != 0)
@@ -301,6 +304,7 @@
 void CpCertDetailView::addSubjectL( const CCertificate& aCertDetails, 
 									HbListWidget& certDisplayDetails )
 	{
+	RDEBUG("0", 0);
 	HBufC* subject = NULL;
 	X509CertNameParser::SubjectFullNameL( (CX509Certificate&)aCertDetails, subject );
 	CleanupStack::PushL( subject );
@@ -319,6 +323,7 @@
 
 void CpCertDetailView::addCertUsage( TKeyUsagePKCS15 usage, HbListWidget& certDisplayDetails )
 	{
+	RDEBUG("0", 0);
 	QString strUsage;
 	switch( usage )
 		{
@@ -341,6 +346,7 @@
 void CpCertDetailView::addValidityPeriod( 	const CCertificate& aCertDetails, 
 											HbListWidget& certDisplayDetails)
 	{
+	RDEBUG("0", 0);
 	// Certificate validity period
 	// Hometime's offset to UTC
 	TLocale locale;
@@ -375,6 +381,7 @@
 
 void CpCertDetailView::setURLLocation( HBufC8& urlDetails, HbListWidget& certDisplayDetails )
 	{
+	RDEBUG("0", 0);
 	TPtr8 urlPtr = urlDetails.Des();
 		
 	QString certUrl = "Location:"; 
@@ -389,6 +396,7 @@
 
 void CpCertDetailView::addCertFormat( TCertificateFormat aCertFormat, HbListWidget& certDisplayDetails )
 	{
+	RDEBUG("0", 0);
 	// certificate format
 	QString certFormat = "Certificate format:";
 	QString certFormatDetails = "(Not defined)";
@@ -402,6 +410,7 @@
 void CpCertDetailView::addAlgoDetails( 	const CCertificate& certificate, 
 										HbListWidget& certDisplayDetails )
 	{
+	RDEBUG("0", 0);
 	// certificate algorithms
 	QString sDgstAlgoDetails = "Unknown";
 	// digest algorithm
@@ -440,6 +449,7 @@
 void CpCertDetailView::addSerialNo( const CCertificate& certificate, 
 									HbListWidget& certDisplayDetails )
 	{
+	RDEBUG("0", 0);
 	// certificate serial number
 	QString sCertSerialNo("Serial number:");
 	QString sCertSerialNoDetails = 0;
@@ -457,37 +467,47 @@
 void CpCertDetailView::addFingerprint(	const CCertificate& certificate, 
 										HbListWidget& certDisplayDetails)
 	{
+	RDEBUG("0", 0);
 	// certificate fingerprint SHA-1
 	QString sSha1("Fingerprint (SHA1):");
 	TPtrC8 sha1_fingerprint = certificate.Fingerprint();
 	HBufC* finalSha1 = NULL;
-	QT_TRAP_THROWING(	 finalSha1 = HBufC::NewLC(100));
-	TPtr finalShaPtr = finalSha1->Des();
-	divideIntoBlocks( sha1_fingerprint, finalShaPtr );
-	QString sSha1Details = QString( (QChar*)finalShaPtr.Ptr(), finalShaPtr.Length() );
-	CleanupStack::PopAndDestroy(finalSha1);
+	QString sSha1Details = NULL;
+	
+	QT_TRAP_THROWING
+		(	 
+		finalSha1 = HBufC::NewLC(100);
+		TPtr finalShaPtr = finalSha1->Des();
+		divideIntoBlocks( sha1_fingerprint, finalShaPtr );
+		sSha1Details = QString( (QChar*)finalShaPtr.Ptr(), finalShaPtr.Length() );
+		CleanupStack::PopAndDestroy(finalSha1);
+		)
 	
 	addToListWidget(certDisplayDetails, sSha1, sSha1Details);
 		
 	// certificate fingerprint MD5
 	QString sMd5("Fingerprint (MD5):");
 	CMD5* md5= NULL;
-	QT_TRAP_THROWING(	 md5 = CMD5::NewL());
-	QT_TRAP_THROWING(CleanupStack::PushL( md5 ));
-	TBuf8<20> fingerprint = md5->Hash( certificate.Encoding() );
-	CleanupStack::PopAndDestroy( md5 );
-	HBufC* finalMd5 = NULL;
-	QT_TRAP_THROWING(	finalMd5 = HBufC::NewLC(100));
-	TPtr finalMd5Ptr = finalMd5->Des();
-	divideIntoBlocks( fingerprint, finalMd5Ptr );
-	QString sMd5Details = QString( (QChar*)finalMd5Ptr.Ptr(), finalMd5Ptr.Length());
-	CleanupStack::PopAndDestroy(finalMd5);
-	addToListWidget(certDisplayDetails, sMd5, sMd5Details);
+	QT_TRAP_THROWING
+		(	 
+		md5 = CMD5::NewL();
+		CleanupStack::PushL( md5 );
+		TBuf8<20> fingerprint = md5->Hash( certificate.Encoding() );
+		CleanupStack::PopAndDestroy( md5 );
+		HBufC* finalMd5 = NULL;
+		finalMd5 = HBufC::NewLC(100);
+		TPtr finalMd5Ptr = finalMd5->Des();
+		divideIntoBlocks( fingerprint, finalMd5Ptr );
+		QString sMd5Details = QString( (QChar*)finalMd5Ptr.Ptr(), finalMd5Ptr.Length());
+		CleanupStack::PopAndDestroy(finalMd5);
+		addToListWidget(certDisplayDetails, sMd5, sMd5Details);
+		)
 	}
 
 void CpCertDetailView::addPublicKeyDetailsL(	const CCertificate& certificate, 
 											HbListWidget& certDisplayDetails )
 	{
+	RDEBUG("0", 0);
 	// Public key
     // Should look like: "Public key (%0U %1N bit):"
         
@@ -574,6 +594,7 @@
 
 QString CpCertDetailView::asymmetricAlgoId( const CCertificate& certificate )
 	{
+	RDEBUG("0", 0);
 	QString sAsymmetricAlgoId = 0;
 	// public-key algorithm
 	TAlgorithmId algorithmId = certificate.SigningAlgorithm().AsymmetricAlgorithm().Algorithm();
@@ -625,7 +646,7 @@
 void CpCertDetailView::validateCertificateL(
     TInt aIndex, const CCertificate& certDetails, const CCTCertInfo& aCertInfo, CpCertView::TCertificateViews aType )
     {
-    
+    RDEBUG("0", 0);
     TInt poppableItems = 0;
     // Check allways first the validity period
     // Show Expired/Not yet valid notes
@@ -738,6 +759,7 @@
 
 CArrayFixFlat<TValidationError>* CpCertDetailView::validateX509CertificateL( const CX509Certificate& certDetails )
     {
+    RDEBUG("0", 0);
     TInt poppableItems = 0;
     CArrayFixFlat<TValidationError>* validationError =
         new ( ELeave ) CArrayFixFlat<TValidationError>( 1 );
@@ -774,7 +796,7 @@
                                                         TUid* keyLocation )
     {
     TKeyUsagePKCS15 keyUsage;
-
+		RDEBUG("0", 0);
     // Check whether we have key for this certificate
     RMPointerArray<CCTKeyInfo> keyEntry;
     TCTKeyAttributeFilter filter;
@@ -806,7 +828,7 @@
 //
 void CpCertDetailView::setLocationInfo(TBool certificate, TUid locUid, HbListWidget& certDisplayDetails)
     {
-    
+    RDEBUG("0", 0);
     QString locationDetails = "(Not defined)";
 
     switch ( locUid.iUid )
@@ -847,6 +869,7 @@
 //
 void CpCertDetailView::divideIntoBlocks( const TDesC8& input, TPtr& output )
     {
+    RDEBUG("0", 0);
     const TInt KBlockLength = 2;
     TInt blockIndex = 0;
     for ( TInt j = 0 ; j < input.Length() ; j++ )
--- a/cpsecplugins/cpadvancedsecplugin/src/cpcertmanuisyncwrapper.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/cpadvancedsecplugin/src/cpcertmanuisyncwrapper.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -23,7 +23,7 @@
 #include <mctwritablecertstore.h>
 #include <x509cert.h>
 #include <pkixcertchain.h>
-
+#include <../../inc/cpsecplugins.h>
 #include "cpcertmanuisyncwrapper.h"
 
 // CONSTANTS
@@ -42,7 +42,7 @@
     const CCertAttributeFilter& aFilter,
     const TUid aTokenUid )
     {
-    
+    RDEBUG("0", 0);
     if ( IsActive() )
         {
         // Wrapper is active. Don't go further
@@ -78,7 +78,7 @@
     RMPointerArray<CCTKeyInfo>* aArray,
     const TCTKeyAttributeFilter& aFilter )
     {
-    
+    RDEBUG("0", 0);
     if ( IsActive() )
         {
         // Wrapper is active. Don't go further
@@ -104,7 +104,7 @@
     TUid aTokenUid )
     {
     aCert = NULL;
-    
+    RDEBUG("0", 0);
     HBufC8* buf = HBufC8::NewLC( KMaxCertificateLength );
     iCertPtr.Set( buf->Des() );
 
@@ -156,7 +156,7 @@
 void CpCertManUISyncWrapper::DeleteCertL( CUnifiedCertStore*& aStore,
     const CCTCertInfo& aCertInfo )
     {
-    
+    RDEBUG("0", 0);
     aStore->Remove( aCertInfo, iStatus );
     iOperation = EOperationDelete;
     iStore = aStore;
@@ -174,7 +174,7 @@
     const CCTCertInfo& aCertInfo,
     TUid aTokenUid )
     {
-        
+    RDEBUG("0", 0);
     TInt count = aStore->WritableCertStoreCount();
     for (TInt i = 0; i < count; i++)
         {
@@ -256,7 +256,7 @@
 
 void CpCertManUISyncWrapper::RunL()
     {
-    
+    RDEBUG("0", 0);
     if ( iWait.IsStarted() )
         {
         iWait.AsyncStop();
@@ -271,6 +271,7 @@
 //
 void CpCertManUISyncWrapper::DoCancel()
     {
+    RDEBUG("iOperation", iOperation);
     switch ( iOperation )
         {
         case EOperationInit:
--- a/cpsecplugins/cpadvancedsecplugin/src/cpcertpluginloader.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/cpadvancedsecplugin/src/cpcertpluginloader.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -20,9 +20,11 @@
 #include "cpcertpluginloader.h"
 #include "cpsecurityview.h"
 #include <hbapplication.h>
+#include <../../inc/cpsecplugins.h>
 
 CpCertPluginLoader::CpCertPluginLoader()
 	{
+		RDEBUG("0", 0);
 		mTranslator =q_check_ptr( new QTranslator());
 		// to be uncommented after translation sumission.
 		//  QString lang = QLocale::system().name();
@@ -43,6 +45,7 @@
 
 QList<CpSettingFormItemData*> CpCertPluginLoader::createSettingFormItemData(CpItemDataHelper &itemDataHelper) const
 		{
+		RDEBUG("0", 0);
   return QList<CpSettingFormItemData*>() 
            << new CpSettingFormEntryItemDataImpl<CpSecurityView>(itemDataHelper,tr("Advanced Security"), QString());			
 		}
--- a/cpsecplugins/cpadvancedsecplugin/src/cpcerttrustview.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/cpadvancedsecplugin/src/cpcerttrustview.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -35,7 +35,7 @@
 #include <hblistwidget.h>
 
 #include <memory>
-
+#include <../../inc/cpsecplugins.h>
 #include "cpcerttrustview.h"
 #include "cpcertdatacontainer.h"
 #include "cpcertmanuisyncwrapper.h"
@@ -71,6 +71,7 @@
 
 void CpCertTrustView::viewTrustSettings()
 	{
+	RDEBUG("0", 0);
 	mTrustedClients << " \tWAP connection\t\t";
 	mTrustedClients << " \tMail and Image conn.\t\t";
 	mTrustedClients << " \tNative installing\t\t";
@@ -111,6 +112,7 @@
 //
 void CpCertTrustView::updateListBoxL()
     {
+    RDEBUG("0", 0);
     mClientUids.Reset();
 
     TInt clientCount = 0;
@@ -196,7 +198,7 @@
 	certLabel->setText(QString( (QChar*)label.Ptr(),label.Length() ) );
 	mCertLabelList->addItem(certLabel.get());
 	certLabel.release();
-	
+	RDEBUG("0", 0);
 	int count = mTrustedClients.size();
 	for( int index = 0 ;index < count; ++index)
 		{
@@ -226,6 +228,7 @@
 
 void CpCertTrustView::saveTrustSettings()
 	{
+	RDEBUG("0", 0);
 	CCTCertInfo& entry = *( mCertDataContainer.iCALabelEntries[ mCertificateIndex ]->iCAEntry );
 	if ( entry.IsDeletable() )
 		{
@@ -249,6 +252,7 @@
 
 TUid CpCertTrustView::trusterId(const QString& clientDescription) const
 	{
+	RDEBUG("0", 0);
 	TUid retValue = TUid::Uid(0);
 	if( clientDescription ==  " \tWAP connection\t\t" )
 		retValue = KCertManUIViewTrustWapConnectionId;
@@ -273,6 +277,7 @@
 //
 TInt CpCertTrustView::trustIdIndex( TUid trustUid ) const
     {
+    RDEBUG("0", 0);
     TInt resIndex = KErrNotFound;
     
     if ( trustUid == KCertManUIViewTrustApplicationControllerId )
@@ -322,6 +327,7 @@
 TBool CpCertTrustView::checkCertificateClientTrustL(
     const TUid clientUid, const CCTCertInfo& entry ) const
     {
+    RDEBUG("0", 0);
     TBool trustSettingTrusted = EFalse;
     TCertificateFormat format = entry.CertificateFormat();
 
--- a/cpsecplugins/cpadvancedsecplugin/src/cpcertview.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/cpadvancedsecplugin/src/cpcertview.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -42,7 +42,7 @@
 #include <QModelIndexList>
 #include <hbmessagebox.h>
 #include <memory>
-
+#include <../../inc/cpsecplugins.h>
 #include "cpcertdetailview.h"
 #include "cpcertview.h"
 #include "cpcertdatacontainer.h"
@@ -61,7 +61,7 @@
 	  mOriginalView(NULL),
 	  mNote(NULL)
 	{
-	
+	RDEBUG("0", 0);
 	mOriginalView = mainWindow()->currentView();
 	
 	HbMenu* menu = this->menu();   
@@ -89,11 +89,15 @@
 		{
 		title = "Move to Personal";  
 		}
-	std::auto_ptr<HbAction> moveToDeviceAction(q_check_ptr(new HbAction(title)));   
-	connect(moveToDeviceAction.get(), SIGNAL(triggered()), this, SLOT(moveCert()));    
-	menu->addAction(moveToDeviceAction.get());
-	moveToDeviceAction.release();
-			
+	RDEBUG("0", 0);
+	if(currentView == EPersonalView || currentView == EDeviceView)
+		{
+		std::auto_ptr<HbAction> moveToDeviceAction(q_check_ptr(new HbAction(title)));   
+		connect(moveToDeviceAction.get(), SIGNAL(triggered()), this, SLOT(moveCert()));    
+		menu->addAction(moveToDeviceAction.get());
+		moveToDeviceAction.release();
+		}	
+	
 	setDetails(currentView);
 	TInt count = 0;
 	try
@@ -106,7 +110,7 @@
 		HbMessageBox::information(exception.what());
 		throw(exception);
 		}
-	
+	RDEBUG("0", 0);
 	for(int index = 0; index< count; index++)
 		{
 		QString certificateLabel = certLabel(index);
@@ -122,13 +126,18 @@
 	layout->addItem(certificateList);
 	setLayout(layout.get());
 	layout.release();
+	
+	mPopup = q_check_ptr(new HbDialog());
+	mContextMenu = q_check_ptr(new HbMenu());
+	
+	RDEBUG("0", 0);
 	}
 
 CpCertView::~CpCertView()
 	{
 	delete mCertDataContainer;
 	mCertDataContainer = NULL;
-	
+	RDEBUG("0", 0);
 	if(mPrevView)
 		{
 		mPrevView->deleteLater();
@@ -164,10 +173,14 @@
 	
 	delete mNote;
 	mNote = NULL;
+	
+	delete mContextMenu;
+	
 	}
 	
 void CpCertView::setDetails(CpCertView::TCertificateViews currentView)
 	{
+	RDEBUG("0", 0);
 	switch(currentView)
 		{
 		case EAuthorityView:
@@ -194,12 +207,13 @@
 
 void CpCertView::indicateLongPress(HbAbstractViewItem *item,QPointF coords)
 	{
-	std::auto_ptr<HbMenu> contextMenu(q_check_ptr(new HbMenu()));
+	RDEBUG("0", 0);
 	mPos = item->modelIndex().row();   // Pos will tell you what is the certificate clicked in particular view.
 	
-	std::auto_ptr<HbAction> open(q_check_ptr(new HbAction(hbTrId("txt_common_menu_open"))));     
-	connect(open.get(), SIGNAL(triggered()), this, SLOT( openCertificate()));    
-	contextMenu->addAction(open.get());			
+	mContextMenu->clearActions();
+	std::auto_ptr<HbAction> open(q_check_ptr(new HbAction(hbTrId("txt_common_menu_open"))));
+	connect(open.get(), SIGNAL(triggered()), this, SLOT( openCertificate()));
+	mContextMenu->addAction(open.get());			
 	open.release();
 	
 	QString moveTitle;
@@ -208,7 +222,7 @@
 		{
 		std::auto_ptr<HbAction> trustSettings(q_check_ptr(new HbAction(hbTrId("txt_certificate_manager_menu_trust_settings")))); 
 		connect(trustSettings.get(), SIGNAL(triggered()), this, SLOT(showTrustSettings()));    
-		contextMenu->addAction(trustSettings.get());
+		mContextMenu->addAction(trustSettings.get());
 		trustSettings.release();
 		}
 	else if(mCertView == EPersonalView)
@@ -219,31 +233,38 @@
 		{
 		moveTitle = hbTrId("txt_certificate_manager_menu_move_to_personal_cert");
 		}	
-	std::auto_ptr<HbAction> moveCert(q_check_ptr(new HbAction(moveTitle)));     
-	connect(moveCert.get(), SIGNAL(triggered()), this, SLOT(moveSelectedCert()));    
-	contextMenu->addAction(moveCert.get());
-	moveCert.release();
-			
+	
+	if(mCertView == EPersonalView || mCertView == EDeviceView )
+		{
+		std::auto_ptr<HbAction> moveCert(q_check_ptr(new HbAction(moveTitle)));     
+		connect(moveCert.get(), SIGNAL(triggered()), this, SLOT(moveSelectedCert()));    
+		mContextMenu->addAction(moveCert.get());
+		moveCert.release();
+		}
+	
+	RDEBUG("0", 0);
 	if( certAt(mPos)->IsDeletable() )
 		{
 		std::auto_ptr<HbAction> menuDelete(q_check_ptr(new HbAction(hbTrId("txt_common_menu_delete")))); 
 		connect(menuDelete.get(), SIGNAL(triggered()), this, SLOT(deleteCertificate()));    
-		contextMenu->addAction(menuDelete.get());
+		mContextMenu->addAction(menuDelete.get());
 		menuDelete.release();
 		}
-	contextMenu->open();
-	contextMenu->setPreferredPos(coords);
+	mContextMenu->setPreferredPos(coords);
+	mContextMenu->open();
 	}
 
 void CpCertView::openCertFromList(const QModelIndex& modelIndex)
 	{	
+	RDEBUG("0", 0);
 	// Pos will tell you what is the certificate clicked in particular view.
 	mPos = modelIndex.row();   
 	openCertificate();
 	}
 
 void CpCertView::openCertificate()
-	{	
+	{
+	RDEBUG("0", 0);
 	mCurrentView = q_check_ptr(new CpCertDetailView(mCertView,mPos,*mCertDataContainer));    
 	connect(mCurrentView, SIGNAL(aboutToClose()), this, SLOT(displayPreviousView()));
 	mPrevView = mainWindow()->currentView();   
@@ -253,6 +274,7 @@
 	
 void CpCertView::displayPreviousView()  
 	{
+	RDEBUG("0", 0);
 	mainWindow()->removeView(mCurrentView);    
 	mCurrentView->deleteLater();
 	mCurrentView= NULL;
@@ -261,16 +283,16 @@
 	
 void CpCertView::deleteCertificate()
 	{
+	RDEBUG("0", 0);
 	RArray<TInt> pos;
 	pos.Append(mPos);
-	QT_TRAP_THROWING(deleteCerts(pos));
+	QT_TRAP_THROWING(deleteCertsL(pos));
 	}		
 	
 void CpCertView::deleteList()
 	{
+	RDEBUG("0", 0);
 	mSelectAll = EFalse;
-	mPopup = new HbDialog();
-
 	mPopup->setDismissPolicy(HbDialog::NoDismiss);
 	// Set the label as heading widget
 	mPopup->setHeadingWidget(q_check_ptr(new HbLabel(hbTrId("txt_certificate_manager_setlabel_certificates"))));
@@ -298,7 +320,7 @@
 	QStandardItemModel* model = q_check_ptr(new QStandardItemModel(this));
 	TInt count=0;
 	QT_TRAP_THROWING( count = refreshListL());
-	
+	RDEBUG("0", 0);
 	for(TInt index = 0; index < count ; ++index)
 		{
 		const CCTCertInfo* cert = certAt(index);
@@ -327,7 +349,7 @@
 	mPopup->setPrimaryAction(q_check_ptr(new HbAction(hbTrId("txt_common_opt_delete"))));
 	mPopup->setSecondaryAction(q_check_ptr(new HbAction(hbTrId("txt_common_button_cancel"))));
 	mPopup->setTimeout(HbPopup::NoTimeout);
-	
+	RDEBUG("0", 0);
 	// Launch popup syncronously
 	mPopup->open(this, SLOT(handleMultipleDelete(HbAction*)));
 
@@ -335,6 +357,7 @@
 
 void CpCertView::handleMultipleDelete(HbAction* action)
 {
+	RDEBUG("0", 0);
 	if(action == mPopup->primaryAction())
 		{
 		QItemSelectionModel *selectionModel = mListView->selectionModel();
@@ -343,27 +366,29 @@
 		// start deleting from end of array so that the indexes do not changes of the ones
 		// at the front.
 		RArray<TInt> actualIndex;
-		QT_TRAP_THROWING(CleanupClosePushL(actualIndex));
-		for (TInt index = deleteCount-1; index>= 0 ; --index) 
-			{
-			TInt selectedItemIndex = mWidgetItemsToRemove[index].row();
-			actualIndex.Append( mSelectionIndex[selectedItemIndex] );
-			}
-		deleteCerts(actualIndex);
-		 CleanupStack::PopAndDestroy(&actualIndex);
+		QT_TRAP_THROWING
+			(
+			CleanupClosePushL(actualIndex);
+			for (TInt index = deleteCount-1; index>= 0 ; --index) 
+				{
+				TInt selectedItemIndex = mWidgetItemsToRemove[index].row();
+				actualIndex.Append( mSelectionIndex[selectedItemIndex] );
+				}
+			deleteCertsL(actualIndex);
+			CleanupStack::PopAndDestroy(&actualIndex);
+			) // QT_TRAP_THROWING
 		}
+	RDEBUG("0", 0);
 	mListView->deleteLater();
 	mListView = NULL;
 	mSelectAllView->deleteLater();
 	mSelectAllView = NULL; 
-	delete mPopup;
-	mPopup = NULL;
 	}
 
 void CpCertView::moveCert()
 	{
+	RDEBUG("0", 0);
 	mSelectAll = EFalse;
-	mPopup = new HbDialog();
 	mPopup->setDismissPolicy(HbDialog::NoDismiss);
 	// Set the label as heading widget
 	if(mCertView == EPersonalView)
@@ -396,6 +421,7 @@
 	// Create a model
 	QStandardItemModel* model = q_check_ptr(new QStandardItemModel(this));
 	TInt count =0;
+	RDEBUG("0", 0);
 	QT_TRAP_THROWING(count = refreshListL());
 	for(TInt index = 0; index < count ; ++index)
 		{
@@ -418,17 +444,19 @@
 	layout.release();
 	mPopup->setContentWidget(widget.get());
 	widget.release();
-	
+	RDEBUG("0", 0);
 	mPopup->setPrimaryAction(q_check_ptr(new HbAction(tr("Yes"))));
 	mPopup->setSecondaryAction(q_check_ptr(new HbAction(tr("No"))));
 	mPopup->setTimeout(HbPopup::NoTimeout);
 	
 	// Launch popup syncronously
 	 mPopup->open(this, SLOT(handleMoveCertDialog(HbAction*)));
+	 RDEBUG("0", 0);
 }
 
 void CpCertView::handleMoveCertDialog(HbAction* action)
 {	
+	RDEBUG("0", 0);
 	if(action == mPopup->primaryAction())
 		{
 		QItemSelectionModel *selectionModel = mListView->selectionModel();
@@ -437,25 +465,29 @@
 		// start deleting from end of array so that the indexes do not changes of the ones
 		// at the front.
 		RArray<TInt> actualIndex;
-		QT_TRAP_THROWING(CleanupClosePushL(actualIndex));
-		 for (TInt index = deleteCount-1; index>= 0 ; --index) 
-			 {
-			 TInt selectedItemIndex = mWidgetItemsToRemove[index].row();
-			 actualIndex.Append(mSelectionIndex[selectedItemIndex]);	 
-			 }
-		 moveCertList(actualIndex);
-		 CleanupStack::PopAndDestroy(&actualIndex); 
+		RDEBUG("0", 0);
+		QT_TRAP_THROWING
+			(
+			CleanupClosePushL(actualIndex);
+			 for (TInt index = deleteCount-1; index>= 0 ; --index) 
+				 {
+				 TInt selectedItemIndex = mWidgetItemsToRemove[index].row();
+				 actualIndex.Append(mSelectionIndex[selectedItemIndex]);	 
+				 }
+			 moveCertList(actualIndex);
+			 CleanupStack::PopAndDestroy(&actualIndex);
+			 )
 		}
 	mListView->deleteLater();
 	mListView = NULL;	
 	mSelectAllView->deleteLater();
 	mSelectAllView = NULL;
-	delete mPopup;
-	mPopup = NULL;
+	RDEBUG("0", 0);
 	}
 
 void CpCertView::selectAll()
 	{
+	RDEBUG("0", 0);
 	if(mSelectAll == EFalse)
 		{
 		mListView->selectAll();
@@ -468,12 +500,16 @@
 		}
 	}
 
-void CpCertView::deleteCerts( RArray<TInt>& indexList )
+void CpCertView::deleteCertsL( RArray<TInt>& indexList )
     {
-  	mIndexList = indexList;
-	TInt count = indexList.Count();
-	    
-	mNote = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
+    RDEBUG("0", 0);
+    TInt count = indexList.Count();
+    for(int index = 0;index <count;++index )
+    	{
+		mIndexList.Append(indexList[index]);
+    	}
+    
+  	mNote = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
 	QString deleteMsg;
 	QString sCount;
 	if(count == 1)
@@ -487,11 +523,9 @@
 		deleteMsg = "Delete %1 items?";
 		sCount.setNum(count);
 		}
-	
+	RDEBUG("0", 0);
 	deleteMsg = deleteMsg.arg(sCount);
 	mNote->setText(deleteMsg);
-	mNote->setPrimaryAction(q_check_ptr(new HbAction("Yes")));
-	mNote->setSecondaryAction(q_check_ptr(new HbAction("No")));
 	mNote->setTimeout(HbPopup::NoTimeout);
 	mNote->open(this,SLOT(handleDeleteDialog(HbAction*)));
 
@@ -499,7 +533,7 @@
 
 void CpCertView::handleDeleteDialog(HbAction* action)
 {
-	
+	RDEBUG("0", 0);
 	TInt count = mIndexList.Count();
 	
 	if (action != mNote->primaryAction() || count == 0 )
@@ -508,53 +542,57 @@
 		}
 		
     RPointerArray<CCTCertInfo> errCerts;
-    QT_TRAP_THROWING(CleanupClosePushL(errCerts));
+    QT_TRAP_THROWING(
+    		CleanupClosePushL(errCerts);
     
-    for(TInt index = 0; index < count; ++index)
-    	{
-		const CCTCertInfo* entry = certAt(mIndexList[index]);
-		
-		if( mCertView == EPersonalView || mCertView == EAuthorityView )
-			{
-			QT_TRAP_THROWING( mCertDataContainer->iWrapper->DeleteCertL( 
-						mCertDataContainer->CertManager(), *entry ));
-			}
-		else if( mCertView == ETrustedView )
-			{
-			QT_TRAP_THROWING( mCertDataContainer->iWrapper->DeleteCertL( 
-						mCertDataContainer->CertManager(),*entry, KCMTrustedServerTokenUid ));
-			}
-		else if( mCertView == EDeviceView )
+		for(TInt index = 0; index < count; ++index)
 			{
-			QT_TRAP_THROWING( mCertDataContainer->iWrapper->DeleteCertL(
-						mCertDataContainer->CertManager(), *entry, KCMDeviceCertStoreTokenUid ));
-			}	
-		QT_TRAP_THROWING( errCerts.AppendL(entry));
-    	}
+			const CCTCertInfo* entry = certAt(mIndexList[index]);
+			
+			if( mCertView == EPersonalView || mCertView == EAuthorityView )
+				{
+				mCertDataContainer->iWrapper->DeleteCertL( 
+							mCertDataContainer->CertManager(), *entry );
+				}
+			else if( mCertView == ETrustedView )
+				{
+				mCertDataContainer->iWrapper->DeleteCertL( 
+							mCertDataContainer->CertManager(),*entry, KCMTrustedServerTokenUid );
+				}
+			else if( mCertView == EDeviceView )
+				{
+				mCertDataContainer->iWrapper->DeleteCertL(
+							mCertDataContainer->CertManager(), *entry, KCMDeviceCertStoreTokenUid );
+				}	
+			errCerts.AppendL(entry);
+			}
+		RDEBUG("0", 0);
+		if(errCerts.Count() > 0)
+			{
+			QString message("Unable to delete the following certificate: \n");
+			TInt count = errCerts.Count();
+			for(TInt index=0;index<count;++index)
+				{
+				const TDesC& certLabel = errCerts[index]->Label();
+				QString certName = QString((QChar*)certLabel.Ptr(),certLabel.Length());
+				message.append(certName).append("\n");
+				}
+			HbMessageBox::warning(message);
+			}
+		count = refreshListL();
+		refreshView(count);
+		
+		CleanupStack::PopAndDestroy(&errCerts);
+		) // QT_TRAP_THROWING
     
-    if(errCerts.Count() > 0)
-    	{
-		QString message("Unable to delete the following certificate: \n");
-		TInt count = errCerts.Count();
-		for(TInt index=0;index<count;++index)
-			{
-			const TDesC& certLabel = errCerts[index]->Label();
-			QString certName = QString((QChar*)certLabel.Ptr(),certLabel.Length());
-			message.append(certName).append("\n");
-			}
-		HbMessageBox::warning(message);
-    	}
-    QT_TRAP_THROWING( count = refreshListL());
-	refreshView(count);
-	
-	CleanupStack::PopAndDestroy(&errCerts);
 	delete mNote;
 	mNote = NULL;
-	
+	RDEBUG("0", 0);
     }
 
 const CCTCertInfo* CpCertView::certAt(TInt index) const
 	{
+	RDEBUG("0", 0);
 	CCTCertInfo* currentCert = NULL;
 	switch(mCertView)
 		{
@@ -584,6 +622,7 @@
 
 QString CpCertView::certLabel(TInt index) const
 	{
+	RDEBUG("0", 0);
 	CpCertManUICertData* certData = NULL;
 	HBufC* label = NULL;
 	TInt length = 0;
@@ -623,6 +662,7 @@
 
 TInt CpCertView::refreshListL()
 	{
+	RDEBUG("0", 0);
 	TInt count = 0;
 	switch(mCertView)
 		{
@@ -649,6 +689,7 @@
 
 void CpCertView::refreshView( TInt count )
 	{
+	RDEBUG("0", 0);
 	if(mRefreshedView)
 		{
 		mRefreshedView->deleteLater();
@@ -681,7 +722,7 @@
 		}	
 	
 	HbMenu* menu = mRefreshedView->menu();   
-		
+	RDEBUG("0", 0);
 	std::auto_ptr<HbAction> endAction( q_check_ptr(new HbAction(hbTrId("txt_common_opt_delete"))) );
 	connect(endAction.get(), SIGNAL(triggered()), this, SLOT(deleteList()));    
 	menu->addAction(endAction.get());
@@ -700,7 +741,7 @@
 	connect(moveAction.get(), SIGNAL(triggered()), this, SLOT(moveCert()));    
 	menu->addAction(moveAction.get());
 	moveAction.release();
-			
+	RDEBUG("0", 0);
 	std::auto_ptr<QGraphicsLinearLayout> layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical)));
 			
 	HbListWidget* mCertificateList = q_check_ptr(new HbListWidget(this)); 
@@ -718,7 +759,7 @@
 	connect(mCertificateList, SIGNAL(longPressed(HbAbstractViewItem*, QPointF )), this, SLOT(indicateLongPress(HbAbstractViewItem*, QPointF))); 
 	
 	layout->addItem(mCertificateList);
-	
+	RDEBUG("0", 0);
 	// Refresh current view
 	QObject::connect(mRefreshedView , SIGNAL(aboutToClose()), this, SLOT(viewDone()));
 	mPrevView = mainWindow()->currentView();   
@@ -726,11 +767,13 @@
 	mainWindow()->setCurrentView(mRefreshedView); 
 	mRefreshedView->setLayout(layout.get());
 	layout.release();
+	RDEBUG("0", 0);
 	}
 
 
 void CpCertView::viewDone()  
 	{
+	RDEBUG("0", 0);
 	mCurrentView = mainWindow()->currentView();
 	mCurrentView->deleteLater();
 	mCurrentView= NULL;
@@ -738,6 +781,7 @@
 	}
 void CpCertView::showTrustSettings()
 	{
+	RDEBUG("0", 0);
 	mCurrentView = q_check_ptr(new CpCertTrustView(mPos, *mCertDataContainer));    
 	connect(mCurrentView , SIGNAL(aboutToClose()), this, SLOT(saveTrustSettings()));
 	mPrevView = mainWindow()->currentView();   
@@ -753,6 +797,7 @@
 
 void CpCertView::moveSelectedCert()
 	{
+	RDEBUG("0", 0);
 	RArray<TInt> pos;
 	pos.Append(mPos);
 	moveCertList(pos);
@@ -760,7 +805,7 @@
 
 void CpCertView::moveCertList(RArray<TInt>& indexList)
 	{
-		
+	RDEBUG("0", 0);
 	mIndexList = indexList;
 	mNote = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
 	mNote->setHeadingWidget(q_check_ptr(new HbLabel(hbTrId("txt_certificate_manager_info_move"))));
@@ -773,16 +818,15 @@
 		mNote->setText("Use of Personal certificates may require user confirmation. Proceed?");
 		}
 	
-	mNote->setPrimaryAction(q_check_ptr(new HbAction("Yes")));
-	mNote->setSecondaryAction(q_check_ptr(new HbAction("No")));
 	mNote->setTimeout(HbPopup::NoTimeout);
 	mNote->setIconVisible (EFalse);
 	mNote->open(this,SLOT(handleMoveDialog(HbAction*)));
+	RDEBUG("0", 0);
 }
 
 void CpCertView::handleMoveDialog(HbAction* action)
 {
-
+	RDEBUG("0", 0);
 	if (action != mNote->primaryAction())
 	    {
 		return;
@@ -806,7 +850,7 @@
 		TCTKeyAttributeFilter keyFilter;
 		keyFilter.iKeyId = entry->SubjectKeyId();
 		keyFilter.iPolicyFilter =  TCTKeyAttributeFilter::EAllKeys;
-	
+		RDEBUG("0", 0);
 		TUid sourceCertStoreUid = TUid::Uid(0);
 		TUid targetCertStoreUid = TUid::Uid(0);
 		TUid sourceKeyStoreUid = TUid::Uid(0);
@@ -826,6 +870,7 @@
 			sourceCertStoreUid = KCMDeviceCertStoreTokenUid;
 			targetCertStoreUid = KCMFileCertStoreTokenUid;
 			}
+		RDEBUG("0", 0);
 		try
 			{
 			
@@ -843,7 +888,7 @@
 			QT_TRAP_THROWING(mCertDataContainer->ShowErrorNoteL( error.toInt() ));
 			User::Exit( KErrNone );
 			}
-		
+		RDEBUG("0", 0);
 		try
 			{
 			if(mCertView == EPersonalView)
@@ -872,5 +917,6 @@
 	QT_TRAP_THROWING(refreshView(refreshListL()));	
 	delete mNote;
 	mNote = NULL;
+	RDEBUG("0", 0);
 	}
 
--- a/cpsecplugins/cpadvancedsecplugin/src/cpmoduleview.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/cpadvancedsecplugin/src/cpmoduleview.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -41,7 +41,7 @@
 #include <hbabstractviewitem.h>
 
 #include <memory>
-
+#include <../../inc/cpsecplugins.h>
 #include "cpmoduleview.h"
 #include "cpsecmodmodel.h"
 #include "cpsecmodview.h"
@@ -53,9 +53,12 @@
   mCurrentView(currentView),
   mSecModUIModel(secModUIModel)
 	{
+	RDEBUG("0", 0);
 	QString title = mSecModUIModel.TokenLabelForTitle();
 	setTitle(title);
 	
+	mContextMenu = (q_check_ptr(new HbMenu()));
+	
 	if(currentView == CpSecModView::EAccessView)
 		{	
 		showAccessView();
@@ -71,6 +74,7 @@
 
 void CpModuleView::showAccessView()
 	{
+	RDEBUG("0", 0);
 	HbMenu* menu = this->menu();   
 	std::auto_ptr<HbAction> endAction(q_check_ptr(new HbAction("Module Info")));     
 	connect(endAction.get(), SIGNAL(triggered()), this, SLOT(saveProv()));    
@@ -95,7 +99,7 @@
 		const TDesC& label = mSecModUIModel.AuthObj(KPinGSettIndex).Label();
 		titleName = QString((QChar*)label.Ptr(), label.Length());
 		}
-	
+	RDEBUG("0", 0);
 	HbListWidget* accessDetails = q_check_ptr(new HbListWidget(this)); 
 	
 	std::auto_ptr<HbListWidgetItem> codeLabel(q_check_ptr(new HbListWidgetItem()));
@@ -122,7 +126,7 @@
 		}	
 	accessDetails->addItem(requestText.get());
 	requestText.release();
-	
+	RDEBUG("0", 0);
 	std::auto_ptr<HbListWidgetItem> statusLabel(q_check_ptr(new HbListWidgetItem()));
 	statusLabel->setText("Status");
 	accessDetails->addItem(statusLabel.get());
@@ -142,10 +146,12 @@
 	form.release();
 	setLayout(layout.get());
 	layout.release();
+	RDEBUG("0", 0);
 	}
 
 void CpModuleView::showSignatureView(TBool showBlockedNote)
 	{
+	RDEBUG("0", 0);
 	mCurrentView = CpSecModView::ESignatureView;
 	std::auto_ptr<QGraphicsLinearLayout> layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical)));
 	std::auto_ptr<HbDataForm> form(q_check_ptr(new HbDataForm()));
@@ -158,8 +164,7 @@
 		
 	while(authDetailsIter.hasNext())
 		{
-		authDetailsIter.next();
-		QPair<QString, TUint32> pair;
+		QPair<QString, TUint32> pair = authDetailsIter.next();
 		QString label = pair.first;
 		TUint32 status = pair.second;
 		QString blockedDetails = NULL;
@@ -176,7 +181,7 @@
 				HbMessageBox::information(totalBlocked);
 				}
 			blockedDetails = label.append(" Blocked");
-		
+		RDEBUG("0", 0);
 		std::auto_ptr<HbListWidgetItem> statusLabel(q_check_ptr(new HbListWidgetItem()));
 		statusLabel->setText(tr("Status"));
 		accessDetails->addItem(statusLabel.get());
@@ -212,13 +217,15 @@
 	form.release();
 	setLayout(layout.get());
 	layout.release();
+	RDEBUG("0", 0);
 	}
 
 void CpModuleView::indicateLongPress(HbAbstractViewItem *item,QPointF coords)
 	{
+	RDEBUG("0", 0);
 	try
 		{
-		std::auto_ptr<HbMenu> contextMenu(q_check_ptr(new HbMenu()));
+		mContextMenu->clearActions();
 		mPos = item->modelIndex().row();   
 		
 		if(mCurrentView == CpSecModView::EAccessView)
@@ -229,21 +236,21 @@
 				{
 				std::auto_ptr<HbAction> changePIN(q_check_ptr(new HbAction("Change")));     
 				connect(changePIN.get(), SIGNAL(triggered()), this, SLOT( handleAccessView()));    
-				contextMenu->addAction(changePIN.get());
+				mContextMenu->addAction(changePIN.get());
 				changePIN.release();
 				}
 			if( mSecModUIModel.PinUnblockable(KPinGSettIndex) )
 				{
 				std::auto_ptr<HbAction> unblockPIN(q_check_ptr(new HbAction("Unblock")));     
 				connect(unblockPIN.get(), SIGNAL(triggered()), this, SLOT( handleAccessView()));    
-				contextMenu->addAction(unblockPIN.get());
+				mContextMenu->addAction(unblockPIN.get());
 				unblockPIN.release();
 				}
 			if( mSecModUIModel.PinOpen(KPinGSettIndex) )
 				{
 				std::auto_ptr<HbAction> closePIN(q_check_ptr(new HbAction("Close")));     
 				connect(closePIN.get(), SIGNAL(triggered()), this, SLOT( handleAccessView()));    
-				contextMenu->addAction(closePIN.get());
+				mContextMenu->addAction(closePIN.get());
 				closePIN.release();
 				}
 			}
@@ -253,29 +260,31 @@
 				{
 				std::auto_ptr<HbAction> changePIN(q_check_ptr(new HbAction("Change")));     
 				connect(changePIN.get(), SIGNAL(triggered()), this, SLOT( handleSigViewCommand()));    
-				contextMenu->addAction(changePIN.get());
+				mContextMenu->addAction(changePIN.get());
 				changePIN.release();
 				}
 			if (mSecModUIModel.PinUnblockable(KPinNrSettIndex))
 				{
 				std::auto_ptr<HbAction> unblockPIN(q_check_ptr(new HbAction("Unblock")));     
 				connect(unblockPIN.get(), SIGNAL(triggered()), this, SLOT( handleSigViewCommand()));    
-				contextMenu->addAction(unblockPIN.get());
+				mContextMenu->addAction(unblockPIN.get());
 				unblockPIN.release();
 				}
 			}
 				
-		contextMenu->open();
-		contextMenu->setPreferredPos(coords);
+		mContextMenu->setPreferredPos(coords);
+		mContextMenu->open();
 		}
 	catch(const std::exception& exception)
 		{
 		HbMessageBox::information(exception.what());
 		}
+	RDEBUG("0", 0);
 	}
 
 void CpModuleView::handleAccessView( const QModelIndex& modelIndex )
 	{
+	RDEBUG("0", 0);
 	try
 		{
 		mPos = modelIndex.row();
@@ -289,6 +298,7 @@
 
 void CpModuleView::handleAccessView()
 	{
+	RDEBUG("0", 0);
 	try
 		{
 		if(mPos == EIndexCodeLabel)
@@ -316,6 +326,7 @@
 
 void CpModuleView::handleSigView()
 	{
+	RDEBUG("0", 0);
 	try
 		{
 		QT_TRAP_THROWING(mSecModUIModel.ChangeOrUnblockPinL(KPinNrSettIndex));
@@ -329,6 +340,7 @@
 
 void CpModuleView::handleSigViewCommand()
 	{
+	RDEBUG("0", 0);
 	try
 		{
 		switch(mPos)
--- a/cpsecplugins/cpadvancedsecplugin/src/cpsecmodmodel.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/cpadvancedsecplugin/src/cpsecmodmodel.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -27,7 +27,7 @@
 #include <qstring.h>
 
 #include <hbmessagebox.h>
-
+#include <../../inc/cpsecplugins.h>
 #include "cpsecmodmodel.h"
 #include "cpsecmodsyncwrapper.h"
 
@@ -47,6 +47,7 @@
 //
 CSecModUIModel* CSecModUIModel::NewL()
     {
+    RDEBUG("0", 0);
     CSecModUIModel* self = new( ELeave ) CSecModUIModel();
     CleanupStack::PushL( self );
     self->ConstructL();
@@ -93,6 +94,7 @@
 //
 void CSecModUIModel::ResetAndDestroyAOs()
     {
+    RDEBUG("0", 0);
     if (iAOList)
         {
         iAOList->Release();
@@ -125,6 +127,7 @@
 //
 void CSecModUIModel::InitializeKeyStoreL()
     {
+    RDEBUG("0", 0);
     ResetAndDestroyCTObjects();
     
     // Ensure that file server session is succesfully created
@@ -184,7 +187,7 @@
 //
 QMap<QString,QString> CSecModUIModel::LoadTokenLabelsL()
     {
-	
+		RDEBUG("0", 0);
     TInt keyStoreCount = iAOKeyStores.Count();
     QMap<QString, QString> labelList;
     
@@ -222,6 +225,7 @@
 //
 QString CSecModUIModel::Location( TUid aUid ) const
     {
+    RDEBUG("0", 0);
     QString location = 0;
 
     switch ( aUid.iUid )
@@ -252,7 +256,7 @@
 void CSecModUIModel::ShowErrorNote(TInt aError) const
     {
 	QString sError;
-
+		RDEBUG("aError", aError);
     switch (aError)
         {
         case KErrCancel:
@@ -292,6 +296,7 @@
 //
 void CSecModUIModel::OpenTokenL(TInt aTokenIndex)
     {
+    RDEBUG("0", 0);
     ResetAndDestroyAOs();
     iKeyStore = iAOKeyStores[aTokenIndex];
     }
@@ -316,6 +321,7 @@
 //
 void CSecModUIModel::InitAuthObjectsL()
     {
+    RDEBUG("0", 0);
     TInt err = KErrNone;
     // Symbian's file key store does not support
     // MCTAuthenticationObjectList interface, so we need to use
@@ -369,6 +375,7 @@
 //
 void CSecModUIModel::ListAuthObjectsL()
     {
+    RDEBUG("0", 0);
     if (0 >= iAOArray.Count())
         {
         __ASSERT_ALWAYS(iAOList, Panic(EPanicNullPointer));
@@ -420,6 +427,7 @@
 //
 QString CSecModUIModel::PINStatus(  TInt aIndex, TBool aShowBlockedNote ) const
     {
+    RDEBUG("0", 0);
     __ASSERT_ALWAYS(aIndex < iAOArray.Count(), Panic(EPanicIndexOutOfRange));
     QString pinStatus;
     TUint32 status = iAOArray[aIndex]->Status();
@@ -486,6 +494,7 @@
 //
 void CSecModUIModel::ChangeOrUnblockPinL(TInt aIndex)
     {
+    RDEBUG("0", 0);
     __ASSERT_ALWAYS(aIndex < iAOArray.Count(), Panic(EPanicIndexOutOfRange));
     TUint32 status = iAOArray[aIndex]->Status();
 
@@ -531,6 +540,7 @@
 //
 void CSecModUIModel::ChangePinL(TInt aIndex)
     {
+    RDEBUG("0", 0);
     __ASSERT_ALWAYS(aIndex < iAOArray.Count(), Panic(EPanicIndexOutOfRange));
     TInt err = KErrNone;
   
@@ -596,6 +606,7 @@
 //
 void CSecModUIModel::DeleteKeysL(TInt aTokenIndex)
     {
+    RDEBUG("0", 0);
     __ASSERT_ALWAYS(aTokenIndex < iAOKeyStores.Count(), Panic(EPanicIndexOutOfRange));
     RMPointerArray<CCTKeyInfo> keyInfos;
 	CleanupClosePushL(keyInfos);
@@ -647,6 +658,7 @@
 //
 QVector< QPair<QString,QString> > CSecModUIModel::GetSecModDetailsL()
     {
+    RDEBUG("0", 0);
     MCTToken& token = iKeyStore->Token();
     QVector< QPair<QString,QString> > securityModDetails;
     
@@ -723,6 +735,7 @@
 									const TDesC& aValue, 
 									QString aNullDescription)
 	{
+	RDEBUG("0", 0);
 	if( aValue.Length() == 0 )
 		{
 		aSecModDetails.append(QPair<QString,QString>(aLabel, aNullDescription));
@@ -785,6 +798,7 @@
 //
 void CSecModUIModel::ChangePinNrL(TInt aIndex)
     {
+    RDEBUG("0", 0);
     ChangePinL(aIndex+1);
     }
 
@@ -826,6 +840,7 @@
 //
 TBool CSecModUIModel::PinChangeable(TInt aIndex) const
     {
+    RDEBUG("0", 0);
     __ASSERT_ALWAYS(aIndex < iAOArray.Count(), Panic(EPanicIndexOutOfRange));
     TUint32 status = iAOArray[aIndex]->Status();
     TBool ret = ETrue;
@@ -875,6 +890,7 @@
 //
 TBool CSecModUIModel::PinRequestChangeable(TInt aIndex) const
     {
+    RDEBUG("0", 0);
     __ASSERT_ALWAYS(aIndex < iAOArray.Count(), Panic(EPanicIndexOutOfRange));
     TUint32 status = iAOArray[aIndex]->Status();
     TBool ret = EFalse;
--- a/cpsecplugins/cpadvancedsecplugin/src/cpsecmodsyncwrapper.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/cpadvancedsecplugin/src/cpsecmodsyncwrapper.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -26,7 +26,7 @@
 #include <mctauthobject.h>
 #include <unifiedkeystore.h>
 #include <mctkeystore.h>
-
+#include <../../inc/cpsecplugins.h>
 
 
 // ============================ MEMBER FUNCTIONS ===============================
@@ -62,6 +62,7 @@
 //
 CSecModUISyncWrapper* CSecModUISyncWrapper::NewL()
     {
+    RDEBUG("0", 0);
     CSecModUISyncWrapper* wrap = CSecModUISyncWrapper::NewLC();
     CleanupStack::Pop(wrap);
     return wrap;
@@ -102,6 +103,7 @@
 TInt CSecModUISyncWrapper::GetAuthObjectInterface(
     MCTToken& aToken, MCTTokenInterface*& aTokenInterface)
     {
+    RDEBUG("0", 0);
     if( !IsActive() && !iWait.IsStarted() )
         {
         iOperation = EOperationGetAOInterface;
@@ -148,6 +150,7 @@
     RMPointerArray<CCTKeyInfo>& aKeysInfos,
     const TCTKeyAttributeFilter& aFilter)
     {
+    RDEBUG("0", 0);
     if( !IsActive() && !iWait.IsStarted() )
         {
         iOperation = EOperationListKeys;
@@ -169,6 +172,7 @@
     CUnifiedKeyStore& aKeyStore,
     TCTTokenObjectHandle aHandle)
     {
+    RDEBUG("0", 0);
     if( !IsActive() && !iWait.IsStarted() )
         {
         iOperation = EOperationDelKey;
@@ -189,6 +193,7 @@
 TInt CSecModUISyncWrapper::ChangeReferenceData(
     MCTAuthenticationObject& aAuthObject)
     {
+    RDEBUG("0", 0);
     if( !IsActive() && !iWait.IsStarted() )
         {
         iOperation = EOperationChangeReferenceData;
@@ -209,6 +214,7 @@
 TInt CSecModUISyncWrapper::UnblockAuthObject(
     MCTAuthenticationObject& aAuthObject)
     {
+    RDEBUG("0", 0);
     if( !IsActive() && !iWait.IsStarted() )
         {
         iOperation = EOperationUnblockAO;
@@ -229,6 +235,7 @@
 TInt CSecModUISyncWrapper::EnableAuthObject(
     MCTAuthenticationObject& aAuthObject)
     {
+    RDEBUG("0", 0);
     if( !IsActive() && !iWait.IsStarted() )
         {
         iOperation = EOperationEnableAO;
@@ -291,6 +298,7 @@
     MCTAuthenticationObject& aAuthObject,
     TInt& aStime )
     {
+    RDEBUG("0", 0);
     if( !IsActive() && !iWait.IsStarted() )
         {
         iOperation = EOperationTimeRemAO;
@@ -311,6 +319,7 @@
 //
 void CSecModUISyncWrapper::DoCancel()
     {
+    RDEBUG("iOperation", iOperation);
     switch ( iOperation )
         {
         case EOperationInit:
--- a/cpsecplugins/cpadvancedsecplugin/src/cpsecmoduleinfoview.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/cpadvancedsecplugin/src/cpsecmoduleinfoview.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -44,13 +44,14 @@
 #include <QModelIndexList>
 
 #include <memory>
-
+#include <../../inc/cpsecplugins.h>
 #include "cpsecmoduleinfoview.h"
 
 
 CpSecmoduleInfoView::CpSecmoduleInfoView(const QVector< QPair<QString,QString> >& securityDetails, QGraphicsItem *parent /*= 0*/)
 	: CpBaseSettingView(0,parent)
 	{
+	RDEBUG("0", 0);
 	setTitle(tr("Module info"));
 		
 	std::auto_ptr<QGraphicsLinearLayout> layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical)));
@@ -75,6 +76,7 @@
 	layout->addItem(listSecurityDetails);		
 	setLayout(layout.get());
 	layout.release();
+	RDEBUG("0", 0);
 	}	
 
 CpSecmoduleInfoView::~CpSecmoduleInfoView()
--- a/cpsecplugins/cpadvancedsecplugin/src/cpsecmodview.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/cpadvancedsecplugin/src/cpsecmodview.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -42,7 +42,7 @@
 #include <HbMessageBox>
 
 #include <memory>
-
+#include <../../inc/cpsecplugins.h>
 #include "cpsecmodview.h"
 #include "cpsecmodmodel.h"
 #include "cpmoduleview.h"
@@ -55,6 +55,7 @@
   mAccessView(NULL),
   mPrevView(NULL)
 	{
+	RDEBUG("0", 0);
 	try
 	{
 	QT_TRAP_THROWING(mSecModUIModel.OpenTokenL(mPos));
@@ -72,7 +73,7 @@
 	moduleWidget->setText("\tModule PIN");
 	listSecView->addItem(moduleWidget.get());
 	moduleWidget.release();
-	
+	RDEBUG("count", count);
 	if( count == 2 )
 		{
 		std::auto_ptr<HbListWidgetItem> signingWidget(q_check_ptr(new HbListWidgetItem()));
@@ -112,6 +113,7 @@
 
 void CpSecModView::showNextView( const QModelIndex& modelIndex )
 	{
+	RDEBUG("0", 0);
 	try
 		{
 		mAccessView = q_check_ptr(new CpModuleView((TSecModViews)modelIndex.row(),mSecModUIModel));
@@ -128,6 +130,7 @@
 
 void CpSecModView::displayPrevious()
 	{
+	RDEBUG("0", 0);
 	try
 		{
 		mainWindow()->removeView(mAccessView);
--- a/cpsecplugins/cpadvancedsecplugin/src/cpsecurityview.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/cpadvancedsecplugin/src/cpsecurityview.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -41,6 +41,8 @@
 
 #include <memory>
 
+#include <../../inc/cpsecplugins.h>
+
 #include "cpsecurityview.h"
 #include "cpsecmodview.h"
 #include "cpcertview.h"
@@ -57,6 +59,7 @@
 	  mPos(0),
 	  mNote(NULL)
 	{
+	RDEBUG("0", 0);
 	setTitle(hbTrId("txt_certificate_manager_setlabel_advanced_security"));
 	
 	std::auto_ptr<QGraphicsLinearLayout> layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical)));
@@ -87,7 +90,7 @@
         
     HbListWidget* listSecView = q_check_ptr(new HbListWidget(this)); 
     QMap<QString,QString> keystoreLabels;
-    
+    RDEBUG("0", 0);
     try
 		{
 		QT_TRAP_THROWING(
@@ -123,7 +126,7 @@
     	listSecView->addItem(emptyWidget.get());
     	emptyWidget.release();
     	}
-    
+    RDEBUG("0", 0);
     std::auto_ptr<HbGroupBox> certificatesList(q_check_ptr(new HbGroupBox()));
 	certificatesList->setHeading(hbTrId("txt_certificate_manager_setlabel_certificates"));
 	certificatesList->setContentWidget(listCertView);
@@ -144,6 +147,8 @@
 	layout->addItem(securityModuleList.get());
 	securityModuleList.release();
 	
+	mContextMenu = q_check_ptr(new HbMenu());
+	
 	setLayout(layout.get()); 
 	layout.release();
 	}
@@ -174,10 +179,12 @@
 	delete mSecModUIModel;  
 	
 	delete mNote;
+	delete mContextMenu;
 	}
 
 void CpSecurityView::showCodeView()
 	{
+	RDEBUG("0", 0);
 	try
 		{
 		mSecModView = q_check_ptr(new CpSecModView(mPos, *mSecModUIModel));    
@@ -200,6 +207,7 @@
 
 void CpSecurityView::showWIMview()
 	{
+	RDEBUG("0", 0);
 	try
 		{
 		QObject::connect(mSecModView , SIGNAL(aboutToClose()), this, SLOT(viewDone()));
@@ -230,6 +238,7 @@
 
 void CpSecurityView::displayCert(const QModelIndex& modelIndex)
 	{
+	RDEBUG("0", 0);
 	try
 	{
 	mCertView = q_check_ptr(new CpCertView(modelIndex));    
@@ -246,6 +255,7 @@
 
 void CpSecurityView::displayPrevious()  
 	{
+	RDEBUG("0", 0);
 	try
 		{
 		mainWindow()->removeView(mCertView);    
@@ -261,31 +271,32 @@
 
 void CpSecurityView::indicateLongPress(HbAbstractViewItem *item,QPointF coords)
 	{
+	RDEBUG("0", 0);
 	try
 		{
-		std::auto_ptr<HbMenu> contextMenu(q_check_ptr(new HbMenu()));
+		mContextMenu->clearActions();
 		mPos = item->modelIndex().row();   
 		
 		std::auto_ptr<HbAction> openModule(q_check_ptr(new HbAction("Open")));     
 		connect(openModule.get(), SIGNAL(triggered()), this, SLOT( showCodeView()));    
-		contextMenu->addAction(openModule.get());
+		mContextMenu->addAction(openModule.get());
 		openModule.release();
 		
 		if(mSecModUIModel->IsTokenDeletable(mPos))
 			{
 			std::auto_ptr<HbAction> deleteModule(q_check_ptr(new HbAction("Delete")));     
 			connect(deleteModule.get(), SIGNAL(triggered()), this, SLOT( deleteModule()));    
-			contextMenu->addAction(deleteModule.get());
+			mContextMenu->addAction(deleteModule.get());
 			deleteModule.release();
 			}
 		
 		std::auto_ptr<HbAction> moduleInfo(q_check_ptr(new HbAction("Module Info")));     
 		connect(moduleInfo.get(), SIGNAL(triggered()), this, SLOT( moduleDetails()));    
-		contextMenu->addAction(moduleInfo.get());
+		mContextMenu->addAction(moduleInfo.get());
 		moduleInfo.release();
 				
-		contextMenu->open();
-		contextMenu->setPreferredPos(coords);
+		mContextMenu->setPreferredPos(coords);
+		mContextMenu->open();
 		}
 	catch(const std::exception& exception)
 		{
@@ -295,6 +306,7 @@
 
 void CpSecurityView::deleteModule()
 	{
+	RDEBUG("0", 0);
 	try
 		{
 		
@@ -320,6 +332,7 @@
 }
 void CpSecurityView::dialogClosed(HbAction* action)
 {
+	RDEBUG("0", 0);
 	if (action != mNote->primaryAction())
 		{
 		return;
@@ -339,6 +352,7 @@
 
 void CpSecurityView::moduleDetails()
 	{
+	RDEBUG("0", 0);
 	try
 		{
 		QVector< QPair<QString,QString> > securityDetails;
@@ -358,6 +372,7 @@
 
 void CpSecurityView::displayPreviousFromModInfo()  
 	{
+	RDEBUG("0", 0);
 	try
 		{
 		mainWindow()->removeView(mModuleinfoView);    
--- a/cpsecplugins/devicelockplugin/src/cpdevicelockplugin.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/devicelockplugin/src/cpdevicelockplugin.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -17,7 +17,7 @@
 #include "cpdevicelockplugin.h"
 #include "cpdevicelockpluginview.h"
 #include <cpsettingformentryitemdataimpl.h>
-
+#include <../../inc/cpsecplugins.h>
 
 
 /*
@@ -30,6 +30,7 @@
  */
 CpDeviceLockPlugin::CpDeviceLockPlugin()
 {
+	RDEBUG("0", 0);
 }
 
 
@@ -56,6 +57,7 @@
  */
 QList<CpSettingFormItemData*> CpDeviceLockPlugin::createSettingFormItemData(CpItemDataHelper &itemDataHelper) const
 {
+		RDEBUG("0", 0);
     return QList<CpSettingFormItemData*>() 
            << new CpSettingFormEntryItemDataImpl<CpDeviceLockPluginView>(itemDataHelper,tr("Device lock"), QString());
 }
--- a/cpsecplugins/devicelockplugin/src/cpdevicelockpluginview.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/devicelockplugin/src/cpdevicelockpluginview.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -43,7 +43,7 @@
 #include "debug.h"
 #include <qapplication.h>
 #include <qtranslator.h>
-
+#include <../../inc/cpsecplugins.h>
 
    
         
@@ -112,6 +112,9 @@
         TInt err = iALPeriodRep->Get(KSettingsAutoLockTime, autoLockVal);
         TInt index = GetAutoLockIndex(autoLockVal);
         Dprint((_L("Current AL period value %d"),autoLockVal));
+        RDEBUG("err", err);
+        RDEBUG("index", index);
+        RDEBUG("autoLockVal", autoLockVal);
         //TODO: need to set autoLockVal in editor
         QStringList autolockPeriodList;
         autolockPeriodList << hbTrId("txt_devicelocking_button_off")
@@ -141,6 +144,7 @@
         TBool lockVal = mUiSecuSettings->IsLockEnabledL(
                 RMobilePhone::ELockPhoneToICC);
         Dprint((_L("LockWhenSimChange enabled %d"),lockVal));
+        RDEBUG("lockVal", lockVal);
         if (lockVal)
             {
             mLockWhenSimChangeItem->setContentWidgetData("text", hbTrId(
@@ -167,6 +171,7 @@
         TBool enabled = true;
         TBool val = mRemoteLockSettings->GetEnabled(enabled);
         Dprint((_L("Remote Lock Setting enabled %d"),val));
+        RDEBUG("val", val);
         mDeviceRemoteLockItem = new HbDataFormModelItem(
                 HbDataFormModelItem::ToggleValueItem, hbTrId(
                         "txt_devicelocking_subhead_remote_locking"));
@@ -245,6 +250,7 @@
 void CpDeviceLockPluginView::onLockCodeClicked()
     {
     Dprint(_L("CpDeviceLockPluginView::onLockCodeClicked()..Enter"));
+    RDEBUG("0", 0);
     mUiSecuSettings->ChangeSecCodeL();
     Dprint(_L("CpDeviceLockPluginView::onLockCodeClicked()..Exit"));
 }
@@ -261,21 +267,27 @@
 void CpDeviceLockPluginView::onAutoLockChanged(int index)
     {
     Dprint(_L("CpDeviceLockPluginView::onAutoLockChanged()..Enter"));
+    RDEBUG("index", index);
     if (index != mThemeComboPrevIndex)
         {
         //TODO: need to set user entered/selected value
         TInt lockValue = GetValueAtIndex(index);
         TInt newAutoLockVal = mUiSecuSettings->ChangeAutoLockPeriodL(
                 lockValue);
+        RDEBUG("newAutoLockVal", newAutoLockVal);
+        RDEBUG("lockValue", lockValue);
         if (newAutoLockVal == lockValue)
             {
             Dprint(_L("onAutoLockChanged().AL setting success !!"));
+            RDEBUG("success", 1);
             TInt err = iALPeriodRep->Set(KSettingsAutoLockTime, lockValue);
+            RDEBUG("err", err);
             mThemeComboPrevIndex = index;
             }
         else
             {
             Dprint(_L("onAutoLockChanged()..Setting to previous value"));
+            RDEBUG("previous", 0);
             QVariant data(mThemeComboPrevIndex);
             mAutolockPeriodItem->setContentWidgetData(
                     QString("currentIndex"), data);
@@ -283,6 +295,7 @@
 
         }
     Dprint(_L("CpDeviceLockPluginView::onAutoLockChanged()..Exit"));
+    RDEBUG("0", 0);
 }
 
 
@@ -298,21 +311,28 @@
 void CpDeviceLockPluginView::onLockMessageClicked()
     {
     Dprint(_L("CpDeviceLockPluginView::onLockMessageClicked()..Exit"));
+    RDEBUG("0", 0);
     TBuf<KRLockMaxLockCodeLength> remoteLockCode;
     TBool remoteLockStatus(EFalse);
     TInt retVal = KErrNone;
     TInt autoLockVal = -1;
     retVal = mUiSecuSettings->ChangeRemoteLockStatusL(remoteLockStatus,
             remoteLockCode, autoLockVal);
+    RDEBUG("retVal", retVal);
+    RDEBUG("autoLockVal", autoLockVal);
+    RDEBUG("remoteLockStatus", remoteLockStatus);
     if (retVal)
         {
         Dprint(_L("CpDeviceLockPluginView::onLockMessageClicked()..ChangeRemoteLockStatusL sucess"));
+        RDEBUG("sucess", 1);
         }
     else
         {
         Dprint(_L("CpDeviceLockPluginView::onLockMessageClicked()..ChangeRemoteLockStatusL failed"));
+        RDEBUG("failed", 0);
         }
     Dprint(_L("CpDeviceLockPluginView::onLockMessageClicked()..Exit"));
+    RDEBUG("0", 0);
 }
 
 
@@ -332,9 +352,10 @@
 void CpDeviceLockPluginView::onAutoTextChanged(const QString& aText)
     {
     Dprint(_L("CpDeviceLockPluginView::onAutoTextChanged()..Enter"));
+    RDEBUG("0", 0);
     //TBool ret = DisplaySecurityDialog(); 
     Dprint(_L("CpDeviceLockPluginView::onAutoTextChanged()..Exit"));
-    
+    RDEBUG("0", 0);
     }
 #endif
 
@@ -350,13 +371,14 @@
     {
     Q_UNUSED(aEndIn);
     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..Enter"));
+    RDEBUG("0", 0);
     HbDataFormModelItem *item = formModel->itemFromIndex(aStartIn);
 
     if ((item->type() == HbDataFormModelItem::ToggleValueItem)
             && (item->data(HbDataFormModelItem::LabelRole).toString()
                     == hbTrId("txt_devicelocking_subhead_remote_locking")))
         {
-
+				RDEBUG("mHack", mHack);
         //The following If-Else condition should be removed once orbit team fix the issue with datachanged() signal
         /****************************************************************************************************************/
         if ((mHack % 2) == 0) //need to capture second datachanged() signal , not first one.
@@ -375,6 +397,9 @@
         TBool remoteLockStatus(EFalse);
         CRemoteLockSettings *remoteLockSetting = CRemoteLockSettings::NewL();
         TInt err = iALPeriodRep->Get(KSettingsAutoLockTime, autoLockVal);
+        RDEBUG("err", err);
+        RDEBUG("autoLockVal", autoLockVal);
+        RDEBUG("retVal", retVal);
         QVariant remLockData = mDeviceRemoteLockItem->contentWidgetData(
                 QString("text"));
         if (remLockData.toString() == hbTrId(
@@ -390,13 +415,16 @@
             retVal = mUiSecuSettings->ChangeRemoteLockStatusL(
                     remoteLockStatus, remoteLockCode, autoLockVal);
             }
+        RDEBUG("retVal", retVal);
         if (retVal == KErrNone)
             {
+            RDEBUG("remoteLockStatus", remoteLockStatus);
             if (remoteLockStatus)
                 {
                 if (remoteLockSetting->SetEnabledL(remoteLockCode))
                     {
                     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..remoteLockSetting->SetEnabledL success"));
+                    RDEBUG("success", 1);
                     mPrevRemLockData
                             = mDeviceRemoteLockItem->contentWidgetData(
                                     QString("text"));
@@ -405,6 +433,7 @@
                     {
                     RollbackRemoteLockSettingState();
                     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..remoteLockSetting->SetEnabledL failed"));
+                    RDEBUG("failed", 0);
                     }
                 }
             else
@@ -412,6 +441,7 @@
                 if (mRemoteLockSettings->SetDisabled())
                     {
                     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..remoteLockSetting->SetDisabled success"));
+                    RDEBUG("success", 1);
                     mPrevRemLockData
                             = mDeviceRemoteLockItem->contentWidgetData(
                                     QString("text"));
@@ -420,17 +450,20 @@
                     {
                     RollbackRemoteLockSettingState();
                     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..remoteLockSetting->SetDisabled failed"));
+                    RDEBUG("failed", 0);
                     }
                 }
             }
         else
             {
             Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..RollbackRemoteLockSettingState"));
+            RDEBUG("Rollback", 0);
             RollbackRemoteLockSettingState();
             }
         delete remoteLockSetting;
         }
     Dprint(_L("CpDeviceLockPluginView::onRemoteLockDataChanged..Exit"));
+    RDEBUG("0", 0);
 }
 
 
@@ -453,6 +486,7 @@
                     == hbTrId(
                             "txt_devicelocking_formlabel_lock_when_sim_changed")))
         {
+        RDEBUG("mHack", mHack);
         //The following If-Else condition should be removed once orbit team fix the issue with datachanged() signal
         /****************************************************************************************************************/
         if ((mHack % 2) == 0) //need to capture second datachanged() signal , not first one.
@@ -467,6 +501,7 @@
         /****************************************************************************************************************/
 
         TBool ret = mUiSecuSettings->ChangeSimSecurityL();
+        RDEBUG("ret", ret);
         if (!ret)
             {
             /* 
@@ -507,6 +542,7 @@
 TInt CpDeviceLockPluginView::GetAutoLockIndex(TInt aValue)
     {
     TInt index = 0;
+    RDEBUG("ret", aValue);
     switch (aValue)
         {
         case 0:
@@ -527,7 +563,7 @@
         default:
             break;
         }
-
+		RDEBUG("index", index);
     return index;
     }
 
@@ -544,7 +580,7 @@
 TInt CpDeviceLockPluginView::GetValueAtIndex(TInt aIndex)
     {
     TInt value = 0;
-
+		RDEBUG("aIndex", aIndex);
     switch (aIndex)
         {
         case 0:
@@ -565,7 +601,7 @@
         default:
             break;
         }
-
+		RDEBUG("value", value);
     return value;
 }
 
@@ -581,6 +617,7 @@
  */
 void CpDeviceLockPluginView::RollbackRemoteLockSettingState()
     {
+    RDEBUG("0", 0);
     /* 
      * disconnect to datachanged() signal as we are not interested in this signal
      * generated as a part of setContentWidgetData() API call below
@@ -606,5 +643,5 @@
         mRemoteLockMessageItem->setEnabled(true);
     else
         mRemoteLockMessageItem->setEnabled(false);
-
+		RDEBUG("0", 0);
     }
--- a/cpsecplugins/devicelockplugin/src/cpremotelockdataformviewitem.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/devicelockplugin/src/cpremotelockdataformviewitem.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -18,7 +18,7 @@
 #include "cpremotelockdataformviewitem.h"
 #include <hblabel.h>
 #include <QGraphicsSceneMouseEvent>
-
+#include <../../inc/cpsecplugins.h>
 
 
 /*
@@ -58,6 +58,7 @@
  */
 HbAbstractViewItem* CpRemoteLockDataFormViewItem::createItem()
 {
+	RDEBUG("0", 0);
 	return new CpRemoteLockDataFormViewItem(*this);
 }
 
@@ -73,6 +74,7 @@
 bool CpRemoteLockDataFormViewItem::canSetModelIndex(const QModelIndex &index) const
 {
 	int type = index.data(HbDataFormModelItem::ItemTypeRole).toInt();
+	RDEBUG("type", type);
 	return ((type == CpRemoteLockItem) || (type == CpCodeEditItem));
 }
 
@@ -88,6 +90,7 @@
 HbWidget *CpRemoteLockDataFormViewItem::createCustomWidget()
     {
     int type = modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt();
+    RDEBUG("type", type);
     if (type == CpCodeEditItem)
         {
         CpLockEdit *edit = new CpLockEdit("1234");
@@ -140,6 +143,7 @@
  */
 void CpLockEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
 {
+		RDEBUG("0", 0);
     if (event->button() != Qt::LeftButton) {
         event->ignore();
         return;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cpsecplugins/inc/cpsecplugins.h	Wed Jun 23 19:10:54 2010 +0300
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 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""
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:  
+ *
+ */
+
+#ifndef CPSECPLUGINS_H
+#define CPSECPLUGINS_H
+
+#include <e32debug.h>
+
+// #if defined _DEBUG
+#ifdef _DEBUG
+#define RDEBUG( x, y ) RDebug::Printf( "%s %s (%u) %s=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, x, y );
+#else
+#define RDEBUG( x, y )
+#endif
+
+#endif //CPSECPLUGINS_H
--- a/cpsecplugins/simpincodeplugin/src/cppincodeplugin.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/simpincodeplugin/src/cppincodeplugin.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -17,6 +17,7 @@
 
 // System includes
 #include <cpsettingformentryitemdataimpl.h>
+#include <../../inc/cpsecplugins.h>
 
 // User includes
 #include "cppincodeplugin.h"
@@ -36,6 +37,7 @@
 */
 CpPinCodePlugin::CpPinCodePlugin()
 {
+RDEBUG("0", 0);
 }
 
 /*!
@@ -51,6 +53,7 @@
 QList<CpSettingFormItemData *> CpPinCodePlugin::createSettingFormItemData(
     CpItemDataHelper &itemDataHelper) const
 {
+		RDEBUG("0", 0);
     return  QList<CpSettingFormItemData *>()
         << new CpSettingFormEntryItemDataImpl<CpPinCodePluginView>
         (itemDataHelper, tr("PIN code"), QString());
--- a/cpsecplugins/simpincodeplugin/src/cppincodepluginview.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/simpincodeplugin/src/cppincodepluginview.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -25,6 +25,7 @@
 
 // User includes
 #include "cppincodepluginview.h"
+#include <../../inc/cpsecplugins.h>
 
 /*!
     \class CpPinCodePluginView
@@ -41,6 +42,7 @@
 CpPinCodePluginView::CpPinCodePluginView(QGraphicsItem *parent /*= 0*/)
 	: CpBaseSettingView(0,parent), mSecCodeSettings(new SecCodeSettings())
 {
+		RDEBUG("0", 0);
     HbDataForm *form = qobject_cast<HbDataForm*>(widget());
     if (form) {
         QList<HbAbstractViewItem *> protoTypeList = form->itemPrototypes();
@@ -60,7 +62,7 @@
             mPinCodeRequestItem->setContentWidgetData("text",tr("Off"));
             mPinCodeRequestItem->setContentWidgetData("additionalText", tr("Off"));
         }
-
+				RDEBUG("form->addConnection", 1);
         form->addConnection(mPinCodeRequestItem, SIGNAL(clicked()), this,
         		SLOT(changePinCodeRequest()));
         formModel->appendDataFormItem(mPinCodeRequestItem);
@@ -84,7 +86,7 @@
         form->addConnection(pin2CodeItem, SIGNAL(clicked()), this,
         		SLOT(changePin2Code()));
         formModel->appendDataFormItem(pin2CodeItem);
-
+				RDEBUG("form->setModel", 1);
         form->setModel(formModel);
     }
 }
@@ -102,6 +104,7 @@
 */
 void CpPinCodePluginView::changePinCode()
 {
+		RDEBUG("0", 0);
     mSecCodeSettings->changePinCode();
 }
 
@@ -110,6 +113,7 @@
 */
 void CpPinCodePluginView::changePin2Code()
 {
+		RDEBUG("0", 0);
     mSecCodeSettings->changePin2Code();
 }
 
@@ -118,14 +122,17 @@
 */
 void CpPinCodePluginView::changePinCodeRequest()
 {
+		RDEBUG("0", 0);
     if (mSecCodeSettings->changePinCodeRequest()) {
         QString text = mPinCodeRequestItem->contentWidgetData("text").toString();
         if (0 == text.compare("On")) {
+        		RDEBUG("On->Off", 0);
             mPinCodeRequestItem->setContentWidgetData("text", 
                     tr("Off"));
             mPinCodeRequestItem->setContentWidgetData("additionalText", 
                     tr("Off"));
         } else {
+        		RDEBUG("Off->On", 0);
             mPinCodeRequestItem->setContentWidgetData("text", 
                     tr("On"));
             mPinCodeRequestItem->setContentWidgetData("additionalText", 
--- a/cpsecplugins/simpincodeplugin/src/seccodeedit.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/simpincodeplugin/src/seccodeedit.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -20,6 +20,7 @@
 
 // User includes
 #include "seccodeedit.h"
+#include <../../inc/cpsecplugins.h>
 
 // ======== MEMBER FUNCTIONS ========
 
@@ -43,6 +44,7 @@
 */
 void SecCodeEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
 {
+		RDEBUG("0", 0);
     if (event->button() != Qt::LeftButton) {
         event->ignore();
         return;
--- a/cpsecplugins/simpincodeplugin/src/seccodeeditdataformviewitem.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/simpincodeplugin/src/seccodeeditdataformviewitem.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -18,6 +18,7 @@
 // User includes
 #include "seccodeeditdataformviewitem.h"
 #include "seccodeedit.h"
+#include <../../inc/cpsecplugins.h>
 
 // ======== MEMBER FUNCTIONS ========
 
@@ -27,6 +28,7 @@
 SecCodeEditDataFormViewItem::SecCodeEditDataFormViewItem(
     QGraphicsItem *parent): HbDataFormViewItem(parent)
 {
+	RDEBUG("0", 0);
 }
 
 /*!
@@ -41,6 +43,7 @@
 */
 HbAbstractViewItem *SecCodeEditDataFormViewItem::createItem()
 {
+		RDEBUG("0", 0);
     return new SecCodeEditDataFormViewItem( *this);
 }
    
@@ -51,6 +54,7 @@
     const QModelIndex &index) const
 {
     int type = index.data(HbDataFormModelItem::ItemTypeRole).toInt();
+    RDEBUG("type", type);
     return type == SecCodeEditItem;
 }
 
@@ -60,13 +64,15 @@
 HbWidget *SecCodeEditDataFormViewItem::createCustomWidget()
 {
     int type = modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt();
+    RDEBUG("type", type);
 
     if (type == SecCodeEditItem) {
         SecCodeEdit *edit = new SecCodeEdit("1234");
         edit->setEchoMode(HbLineEdit::Password);
+        RDEBUG("edit->setReadOnly", 1);
         edit->setReadOnly(true);
         return edit;
     }
-
+		RDEBUG("0", 0);
     return 0;
 }
--- a/cpsecplugins/simpincodeplugin/src/seccodemodel.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/simpincodeplugin/src/seccodemodel.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -18,6 +18,7 @@
 // User includes
 #include "seccodemodel.h"
 #include "seccodemodel_p.h"
+#include <../../inc/cpsecplugins.h>
 
 // ======== MEMBER FUNCTIONS ========
 
@@ -43,6 +44,7 @@
 */
 bool SecCodeModel::pinCodeRequest() const
 {
+		RDEBUG("0", 0);
     return d_ptr->pinCodeRequest();
 }
 
@@ -51,6 +53,7 @@
 */
 bool SecCodeModel::changePinCodeRequest()
 {
+		RDEBUG("0", 0);
     return d_ptr->changePinCodeRequest();
 }
 
@@ -59,6 +62,7 @@
 */
 int SecCodeModel::changePinCode()
 {
+		RDEBUG("0", 0);
     return d_ptr->changePinCode();
 }
 
@@ -67,5 +71,6 @@
 */
 int SecCodeModel::changePin2Code()
 {
+		RDEBUG("0", 0);
     return d_ptr->changePin2Code();
 }
--- a/cpsecplugins/simpincodeplugin/src/seccodemodel_symbian.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/simpincodeplugin/src/seccodemodel_symbian.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -23,6 +23,7 @@
 // User includes
 #include "seccodemodel_p.h"
 #include "seccodeuiglobal.h"
+#include <../../inc/cpsecplugins.h>
 
 // ======== MEMBER FUNCTIONS ========
 
@@ -50,6 +51,7 @@
 */
 void SecCodeModelPrivate::ConstructL()
 {
+	RDEBUG("0", 0);
 	iSecurity = CSecuritySettings::NewL(); 
 }
 
@@ -68,9 +70,11 @@
 */
 bool SecCodeModelPrivate::pinCodeRequest() const
 {
+	RDEBUG("0", 0);
 	bool isLockEnabled = false;
 	QT_TRAP_THROWING(isLockEnabled = iSecurity->IsLockEnabledL(
 		RMobilePhone::ELockICC));
+	RDEBUG("isLockEnabled", isLockEnabled);
 	return isLockEnabled;
 }
 
@@ -79,8 +83,10 @@
 */
 bool SecCodeModelPrivate::changePinCodeRequest()
 {
+	RDEBUG("0", 0);
     bool result = false;
 	QT_TRAP_THROWING(result =iSecurity->ChangePinRequestL());
+	RDEBUG("result", result);
 	return result;
 }
 
@@ -89,7 +95,9 @@
 */
 int SecCodeModelPrivate::changePinCode()
 {
+	RDEBUG("0", 0);
 	QT_TRAP_THROWING(iSecurity->ChangePinL());
+	RDEBUG("0", 0);
 	return 0;
 }
 
@@ -98,6 +106,8 @@
 */
 int SecCodeModelPrivate::changePin2Code()
 {
+	RDEBUG("0", 0);
 	QT_TRAP_THROWING(iSecurity->ChangePin2L());
+	RDEBUG("0", 0);
 	return 0;
 }
--- a/cpsecplugins/simpincodeplugin/src/seccodemodel_win.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/simpincodeplugin/src/seccodemodel_win.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -17,6 +17,7 @@
 
 // User includes
 #include "seccodemodel_p.h"
+#include <../../inc/cpsecplugins.h>
 
 // ======== MEMBER FUNCTIONS ========
 /*!
@@ -54,6 +55,7 @@
 */
 bool SecCodeModelPrivate::pinCodeRequest() const
 {
+		RDEBUG("0", 0);
     QString information;
     information = QString("Emulator NOT supported!");
     HbMessageBox messageBox(information);
@@ -66,6 +68,7 @@
 */
 bool SecCodeModelPrivate::changePinCodeRequest()
 {
+		RDEBUG("0", 0);
     QString information;
     information = QString("Emulator NOT supported!");
     HbMessageBox messageBox(information);
@@ -78,6 +81,7 @@
 */
 int SecCodeModelPrivate::changePinCode()
 {
+		RDEBUG("0", 0);
     QString information;
     information = QString("Emulator NOT supported!");
     HbMessageBox messageBox(information);
@@ -90,6 +94,7 @@
 */
 int SecCodeModelPrivate::changePin2Code()
 {
+		RDEBUG("0", 0);
     QString information;
     information = QString("Emulator NOT supported!");
     HbMessageBox messageBox(information);
--- a/cpsecplugins/simpincodeplugin/src/seccodesettings.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/cpsecplugins/simpincodeplugin/src/seccodesettings.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -18,6 +18,7 @@
 // User includes
 #include "seccodesettings.h"
 #include "seccodemodel.h"
+#include <../../inc/cpsecplugins.h>
 
 // Class declaration
 class SecCodeSettingsPrivate
@@ -44,7 +45,7 @@
 SecCodeSettings::SecCodeSettings(QObject * parent /*= 0*/)
     : QObject(parent), d_ptr(new SecCodeSettingsPrivate())
 {
-
+RDEBUG("0", 0);
 }
 
 /*!
@@ -60,6 +61,7 @@
 */
 bool SecCodeSettings::pinCodeRequest() const
 {
+		RDEBUG("0", 0);
     return d_ptr->mSecCodeModel->pinCodeRequest();
 }
 
@@ -68,6 +70,7 @@
 */
 bool SecCodeSettings::changePinCodeRequest()
 {
+		RDEBUG("0", 0);
     return d_ptr->mSecCodeModel->changePinCodeRequest();
 }
 
@@ -76,6 +79,7 @@
 */
 void SecCodeSettings::changePinCode()
 {
+		RDEBUG("0", 0);
     d_ptr->mSecCodeModel->changePinCode();
 }
 
@@ -84,5 +88,6 @@
 */
 void SecCodeSettings::changePin2Code()
 {    
+		RDEBUG("0", 0);
     d_ptr->mSecCodeModel->changePin2Code();
 }
--- a/package_definition.xml	Fri Jun 11 14:28:40 2010 +0300
+++ b/package_definition.xml	Wed Jun 23 19:10:54 2010 +0300
@@ -1,113 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <SystemDefinition schema="3.0.0">
   <package id="securitysrv" name="Security Services" levels="plugin framework server generic specific">
-    <collection id="gba" name="Generic Bootstrapping Architecture" level="server">
-      <component id="uicc" filter="s60" name="UICC" class="plugin" introduced="^2">
-        <unit bldFile="gba/uicc/group"/>
-      </component>
-      <component id="bootstrap" filter="s60" name="Bootstrap" introduced="^2">
-        <unit bldFile="gba/bootstrap/group"/>
-      </component>
-      <component id="gbaserver" filter="s60" name="GBA Server" introduced="^2">
-        <unit bldFile="gba/gbaserver/group"/>
-      </component>
-      <component id="gbaapi" filter="s60" name="GBA API" introduced="^2">
-        <unit bldFile="gba/gbaapi/group"/>
-      </component>
-      <component id="gbafilter" filter="s60" name="GBA HTTP Filter" class="plugin" introduced="^2">
-        <unit bldFile="gba/gbafilter/group"/>
-      </component>
-      <component id="gba_build" filter="s60" name="Generic Boot Architecture Build" introduced="^2">
-        <unit bldFile="gba/group"/>
-      </component>
-    </collection>
-    <collection id="wim" name="Wireless Identity Module " level="framework">
-      <component id="swimreader" filter="s60" name="SWIM Reader"/>
-      <component id="scard" filter="s60" name="Smart Card"/>
-      <component id="wimutil" filter="s60" name="WIM Utils"/>
-      <component id="wimserver" filter="s60" name="WIM Server"/>
-      <component id="wimclient" filter="s60" name="WIM Client"/>
-      <component id="wimplugin" filter="s60" name="WIM Plugin" class="plugin"/>
-      <component id="wim_build" filter="s60" name="WIM Build">
-           <!-- need to distribute bld.inf to empty components or collapse into a single component -->
-        <unit bldFile="wim/group"/>
-      </component>
-    </collection>
     <collection id="pkiutilities" name="PKI Utilities" level="plugin">
-      <component id="x509certnameparser" filter="s60" name="X.509 Certificate Name Parser">
-        <unit bldFile="pkiutilities/x509certnameparser/group"/>
-      </component>
-      <component id="pkcs12" filter="s60" name="PKCS #12">
-        <unit bldFile="pkiutilities/pkcs12/group"/>
-      </component>
-      <component id="certmanui" filter="s60" name="Certificate Management UI">
-        <unit bldFile="pkiutilities/certmanui/group"/>
-      </component>
-      <component id="ctsecuritydialogs" filter="s60" name="Crypto Token Security Dialogs">
-        <unit bldFile="pkiutilities/ctsecuritydialogs/group"/>
-      </component>
-      <component id="certsaver" filter="s60" name="Certificate Saver">
-        <unit bldFile="pkiutilities/certsaver/group"/>
-      </component>
-      <component id="secmodui" filter="s60" name="Security Module UI">
-        <unit bldFile="pkiutilities/secmodui/group"/>
-      </component>
-      <component id="devicetoken" filter="s60" name="Device Token">
-        <unit bldFile="pkiutilities/devicetoken/group"/>
-      </component>
-      <component id="certificates" filter="s60" name="Certificates">
-        <unit bldFile="pkiutilities/certificates/group"/>
-      </component>
-      <component id="pkiutilities_build" filter="s60" name="PKI Utilities Build">
-        <unit bldFile="pkiutilities/group"/>
-      </component>
      <component id="ocsp" name="Online Certificate Status Protocol" introduced="^2" purpose="optional">
        <unit bldFile="pkiutilities/ocsp/group" mrp="pkiutilities/ocsp/group/securitysrv_ocsp.mrp"/>
       </component>
     </collection>
-    <collection id="remotelock" name="Remote Lock" level="generic">
-      <component id="remotelocksettings" filter="s60" name="Remote Lock Settings"/>
-      <component id="remotelockengine" filter="s60" name="Remote Lock Engine"/>
-      <component id="remotelock_build" filter="s60" name="Remote Lock Build">
-           <!-- need to distribute bld.inf to empty components or collapse into a single component -->
-        <unit bldFile="remotelock/group"/>
-      </component>
-    </collection>
-    <collection id="boottimeintegritycheck" name="Boot Time Integrity Check" level="plugin">
-      <component id="trkdummy" filter="s60" name="Trk Dummy">
-        <!-- <unit bldFile="boottimeintegritycheck/trkdummy/group"/> -->
-      </component>
-      <component id="boottimeintegritycheck_build" filter="s60" name="Boot Time Integrity Check Build">
-        <unit bldFile="boottimeintegritycheck/group"/>
-      </component>
-    </collection>
-    <collection id="securitydialogs" name="Security Dialogs" level="specific">
-      <component id="keylockpolicyapi" filter="s60" name="Keylock Policy API">
-        <unit bldFile="securitydialogs/keylockpolicyapi/group"/>
-      </component>
-      <component id="autolock" name="Autolock" filter="s60">
-        <unit bldFile="securitydialogs/autolock/group"/>
-      </component>
-      <component id="secui" filter="s60" name="Security UI">
-        <unit bldFile="securitydialogs/secui/group"/>
-      </component>
-      <component id="securitynotifier" filter="s60" name="Security Notifier">
-        <unit bldFile="securitydialogs/securitynotifier/group"/>
-      </component>
-      <component id="securityobserver" filter="s60" name="Security Observer">
-        <unit bldFile="securitydialogs/securityobserver/group"/>
-      </component>
-    </collection>
     <collection id="securitysrv_info" name="Security Services Info" level="specific">
-      <component id="secsrv_plat" name="Security Services Platform Interfaces" filter="s60" class="api">
-        <unit bldFile="secsrv_plat/group"/>
-        <!-- <unit bldFile="secsrv_plat/devicelock_access_api/group"/> -->
-        <!-- <unit bldFile="secsrv_plat/keyguard_access_api/group"/> -->
-        <!-- <unit bldFile="secsrv_plat/lockapp_server_api/group"/> -->
-      </component>
-      <component id="securitysrv_test" filter="s60" purpose="development" name="Security Services Test">
-        <!-- <unit bldFile="tsrc/group"/> -->
-      </component>
       <component id="securitysrv_metadata" name="Security Services Metadata" class="config" introduced="^2" purpose="development" target="desktop">
         <unit mrp="securitysrv_info/securitysrv_metadata/securitysrv_metadata.mrp"/>
       </component>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/package_map.xml	Wed Jun 23 19:10:54 2010 +0300
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<PackageMap root="sf" layer="mw" />
\ No newline at end of file
--- a/pkiutilities/CTSecurityDialogs/Group/CTSecDialogImpl.mmp	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/CTSecurityDialogs/Group/CTSecDialogImpl.mmp	Wed Jun 23 19:10:54 2010 +0300
@@ -63,7 +63,7 @@
 SOURCE    CTPinPinQueryDialog.cpp
 SOURCE    CTCertificateQuery.cpp
 SOURCE    CTSecurityDialogsAO.cpp
-SOURCE    CTNoTrustQuery.cpp
+SOURCE    CTUntrustedCertQuery.cpp
 SOURCE    CTInvalidCertNote.cpp
 
 LIBRARY   EUSER.LIB
@@ -88,6 +88,7 @@
 LIBRARY   aknlayout.lib
 LIBRARY   X500.lib
 LIBRARY   DevTokenClient.lib
+LIBRARY   HbCore.lib                // CHbDeviceDialog
 
 DEBUGLIBRARY     flogger.lib
 
--- a/pkiutilities/CTSecurityDialogs/NotifInc/CTNoTrustQuery.h	Fri Jun 11 14:28:40 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
-* Copyright (c) 2002-2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  
-*
-*/
-
-
-
-#ifndef CTNOTRUSTQUERY_H
-#define CTNOTRUSTQUERY_H
-
-//  INCLUDES
-
-#include <AknQueryDialog.h>
-
-// FORWARD DECLARATIONS
-
-class CCTSecurityDialogsAO;
-class CAknSinglePopupMenuStyleListBox;
-
-// CLASS DECLARATION
-
-/**
-*  Notifier class for showing SSL security dialogs
-*/
-NONSHARABLE_CLASS( CCTNoTrustQuery ): public CAknQueryDialog
-    {
-    public:     // constructors and destructor
-
-        CCTNoTrustQuery(
-            CCTSecurityDialogsAO& aNotifier,
-            TBool& aRetVal,
-            TRequestStatus& aClientStatus,
-            HBufC* aServerName,
-            TBool aShowPermAccept,
-            TBool& aIsDeleted );
-            
-        virtual ~CCTNoTrustQuery();
-
-    private:    // from CEikDialog
-        TBool OkToExitL( TInt aButtonId );
-        void PostLayoutDynInitL();
-
-    private: // New functions
-        TBool OptionsMenuL();
-
-    private:    // data
-        CCTSecurityDialogsAO& iNotifier;
-        TBool& iRetVal; 		//Dialog response
-        TRequestStatus* iClientStatus;
-        HBufC* iServerName;
-        TBool iShowPermAccept;
-        TBool& iDeleted;
-    };
-
-#endif  // CTNOTRUSTQUERY_H
-
--- a/pkiutilities/CTSecurityDialogs/NotifInc/CTSecurityDialogsAO.h	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/CTSecurityDialogs/NotifInc/CTSecurityDialogsAO.h	Wed Jun 23 19:10:54 2010 +0300
@@ -323,9 +323,6 @@
 
         TBool& iDeleted;
 
-        CAknQueryDialog* iQueryDialog;
-        TBool iQueryDialogDeleted;
-
         CCTPinQueryDialog* iPinQueryDialog;
         TBool iPinQueryDialogDeleted;
         };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pkiutilities/CTSecurityDialogs/NotifInc/CTUntrustedCertQuery.h	Wed Jun 23 19:10:54 2010 +0300
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Displays untrusted certificate dialog.
+*
+*/
+
+#ifndef CTUNTRUSTEDCERTQUERY_H
+#define CTUNTRUSTEDCERTQUERY_H
+
+#include <e32base.h>                            // CActive
+#include <hb/hbcore/hbdevicedialogsymbian.h>    // MHbDeviceDialogObserver
+#include <securitydefs.h>                       // TValidationError
+
+class CHbDeviceDialogSymbian;
+class CHbSymbianVariantMap;
+
+
+/**
+* Displays untrusted certificate query.
+* Untrusted certificate query dialog is displayed for secure connection
+* (SSL/TLS) server authentication failure errors. CCTUntrustedCertQuery
+* class uses UntrustedCertificateDialog device dialog to show the query.
+*/
+NONSHARABLE_CLASS( CCTUntrustedCertQuery ) : public CActive, public MHbDeviceDialogObserver
+    {
+    public:     // constructors and destructor
+        static CCTUntrustedCertQuery* NewLC( TValidationError aValidationError,
+                const TDesC8& aCertificate, const TDesC& aServerName,
+                TBool aCanHandlePermanentAccept );
+        ~CCTUntrustedCertQuery();
+
+    public:     // new functions
+        enum TResponse {
+            EQueryRejected,
+            EQueryAccepted,
+            EQueryAcceptedPermanently
+        };
+        void ShowQueryAndWaitForResponseL( TResponse& aResponse );
+
+    protected:  // from CActive
+        void DoCancel();
+        void RunL();
+
+    private:    // from MHbDeviceDialogObserver
+        void DataReceived( CHbSymbianVariantMap& aData );
+        void DeviceDialogClosed( TInt aCompletionCode );
+
+    private:    // new functions
+        CCTUntrustedCertQuery( TValidationError aValidationError,
+                const TDesC8& aCertificate, const TDesC& aServerName,
+                TBool aCanHandlePermanentAccept );
+        void ConstructL();
+
+    private:    // data
+        TValidationError iValidationError;
+        const TDesC8& iCertificate;
+        const TDesC& iServerName;
+        TBool iCanHandlePermanentAccept;
+        CActiveSchedulerWait *iWait;
+        TInt iWaitCompletionCode;
+        CHbDeviceDialogSymbian* iDeviceDialog;
+        CHbSymbianVariantMap* iVariantMap;
+        TResponse iResponse;
+    };
+
+#endif  // CTUNTRUSTEDCERTQUERY_H
+
--- a/pkiutilities/CTSecurityDialogs/NotifSrc/CTNoTrustQuery.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,213 +0,0 @@
-/*
-* Copyright (c) 2006-2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  
-*
-*/
-
-
-
-// INCLUDE FILES
-
-#include <platform/e32notif.h>
-#include "CTNoTrustQuery.h"
-#include "CTSecurityDialogsAO.h"
-#include "CTCertificateQuery.h"
-#include <aknlists.h>
-#include <CTSecDlgs.rsg>
-#include <uikon/eiksrvui.h>
-#include <StringLoader.h>
-
-
-// ================= MEMBER FUNCTIONS ==========================================
-
-// -----------------------------------------------------------------------------
-// CSecNotNoTrustQuery::CCTNoTrustQuery()
-// -----------------------------------------------------------------------------
-//
-CCTNoTrustQuery::CCTNoTrustQuery(
-    CCTSecurityDialogsAO& aNotifier,
-    TBool& aRetVal,
-    TRequestStatus& aClientStatus,
-    HBufC* aServerName,
-    TBool aShowPermAccept,
-    TBool& aIsDeleted ):
-    CAknQueryDialog( CAknQueryDialog::ENoTone ),
-    iNotifier( aNotifier ),
-    iRetVal( aRetVal ),
-    iClientStatus( &aClientStatus ),
-    iServerName( aServerName ),
-    iShowPermAccept( aShowPermAccept ),
-    iDeleted( aIsDeleted )
-    {
-    iDeleted = EFalse;
-    }
-
-// -----------------------------------------------------------------------------
-// CSecNotNoTrustQuery::~CCTNoTrustQuery()
-// -----------------------------------------------------------------------------
-//
-CCTNoTrustQuery::~CCTNoTrustQuery()
-    {
-    // Allow application switching again
-    CEikonEnv* eikonEnv = CEikonEnv::Static();
-    if( eikonEnv )
-        {
-        CEikServAppUi* eikServAppUi = static_cast<CEikServAppUi*>( eikonEnv->EikAppUi() );
-        if( eikServAppUi )
-            {
-            eikServAppUi->SuppressAppSwitching( EFalse );
-            }
-        }
-
-    // Complete the client request
-    if( iClientStatus && *iClientStatus == KRequestPending )
-        {
-        iRetVal = EFalse;
-        User::RequestComplete( iClientStatus, KErrNone );
-        }
-    
-    // Notify that the dialog has been deleted
-    iDeleted = ETrue;
-    }
-
-// -----------------------------------------------------------------------------
-// CSecNotNoTrustQuery::OkToExitL()
-// -----------------------------------------------------------------------------
-//
-TBool CCTNoTrustQuery::OkToExitL( TInt aButtonId )
-    {
-    if ( aButtonId == EAknSoftkeyOptions || aButtonId == EAknSoftkeyOk )
-        {
-        return OptionsMenuL();
-        }
-    else
-        {
-        iRetVal = EFalse;
-        User::RequestComplete( iClientStatus, KErrNone );
-        }
-    return ETrue;
-    }
-
-// -----------------------------------------------------------------------------
-// CCTNoTrustQuery::PostLayoutDynInitL()
-// -----------------------------------------------------------------------------
-//
-void CCTNoTrustQuery::PostLayoutDynInitL()
-    {
-    CAknQueryControl* control = QueryControl();
-    if (control)
-        control->StartAnimationL();
-    ((CEikServAppUi*)(CEikonEnv::Static())->EikAppUi())->SuppressAppSwitching( ETrue );
-    }
-
-// -----------------------------------------------------------------------------
-// CCTNoTrustQuery::OptionsMenuL()
-// -----------------------------------------------------------------------------
-TBool CCTNoTrustQuery::OptionsMenuL()
-    {
-    TBool ret = EFalse;
-    CAknSinglePopupMenuStyleListBox* list =
-        new( ELeave ) CAknSinglePopupMenuStyleListBox;
-    CleanupStack::PushL( list );
-    CAknPopupList* popupList = CAknPopupList::NewL(
-        list, R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT, AknPopupLayouts::EMenuWindow );
-    CleanupStack::PushL( popupList );
-    list->ConstructL( popupList, CEikListBox::ELeftDownInViewRect );
-    list->CreateScrollBarFrameL( ETrue );
-    list->ScrollBarFrame()->SetScrollBarVisibilityL(
-        CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
-
-    TInt resourceid;
-
-    if ( iShowPermAccept )
-        {
-        resourceid = R_NOTRUST_MENUPANE;
-        }
-    else
-        {
-        resourceid = R_NOTRUST_MENUPANE_NO_PERM;
-        }
-
-     CDesCArrayFlat* items =
-            CEikonEnv::Static()->ReadDesCArrayResourceL( resourceid );
-
-    CTextListBoxModel* model = list->Model();
-    model->SetOwnershipType( ELbmOwnsItemArray );
-    model->SetItemTextArray( items );
-
-    CleanupStack::Pop( popupList ); //popupList
-    if ( popupList->ExecuteLD() )
-        {
-        if( !iDeleted )
-            {
-            TInt index = list->CurrentItemIndex();
-            if ( index == 0 )       // Accept now
-                {
-                iRetVal = EServerCertAcceptedTemporarily;
-                User::RequestComplete(iClientStatus, KErrNone);
-                ret = ETrue;
-                }
-            else if (( index == 1 ) && ( resourceid == R_NOTRUST_MENUPANE ))  // Accept permanently
-                {
-    
-                HBufC* prompt = StringLoader::LoadLC( R_QTN_HTTPSEC_QUERY_PERM_ACCEPT_TEXT, *iServerName );
-    
-                CAknMessageQueryDialog* note = CAknMessageQueryDialog::NewL( *prompt );
-    
-                note->PrepareLC( R_HTTPSEC_QUERY_PERM_ACCEPT );
-                note->SetPromptL( *prompt );
-    
-                if ( note->RunLD() )
-                    {
-                    iRetVal = EServerCertAcceptedPermanently;
-                    User::RequestComplete( iClientStatus, KErrNone );
-                    ret = ETrue;
-                    }
-                else
-                    {
-                    ret = EFalse;
-                    }
-    
-                CleanupStack::PopAndDestroy( prompt );
-                }
-            else if ((( index == 2 ) && ( resourceid == R_NOTRUST_MENUPANE ))  ||
-                     (( index == 1 ) && ( resourceid == R_NOTRUST_MENUPANE_NO_PERM )) ) // Details
-                {
-                // We need to delay this implementation in other releases, because
-                // separate ICD was taken to 3.0.
-                CCTCertificateQuery* query =
-                CCTCertificateQuery::NewL( iNotifier );
-                query->ExecuteLD( R_NOTRUST_CERTIFICATE_QUERY );
-                ret = EFalse;
-                }
-            else
-                {
-                iRetVal = EServerCertNotAccepted;
-                User::RequestComplete( iClientStatus, KErrNone );
-                ret = ETrue;
-                }
-            }
-        else
-            {
-            ret = EFalse;
-            }
-        }
-    else
-        {
-        ret = EFalse;
-        }
-    CleanupStack::PopAndDestroy( list );  // list
-    return ret;
-    }
-
--- a/pkiutilities/CTSecurityDialogs/NotifSrc/CTSecurityDialogsAO.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/CTSecurityDialogs/NotifSrc/CTSecurityDialogsAO.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -24,7 +24,7 @@
 #include "CTSelectCertificateDialog.h"
 #include "CTQueryDialog.h"
 #include "CTPinPinQueryDialog.h"
-#include "CTNoTrustQuery.h"
+#include "CTUntrustedCertQuery.h"
 #include "CTInvalidCertNote.h"
 #include <PKIDlg.h>
 #include <badesca.h>
@@ -53,8 +53,6 @@
 const TInt KMaxLengthTextCertLabelVisible = 200;
 // "dd/mm/yyyy0"
 const TInt KMaxLengthTextDateString = 20;
-// HH0
-const TInt KMaxLengthTextSerialNumberFormatting = 3;
 // Maximum length of a certificate
 const TInt KMaxCertificateLength = 5000;
 
@@ -63,12 +61,8 @@
 
 const TInt KMinImportKeyPwLen = 1;
 
-const TInt KMaxCNLength = 64;
+const TInt KMaxCommonNameLength = 64;
 
-_LIT(KCertManUIDetailsViewHexFormat, "%02X");
-
-const TInt KFileCertStoreUid( 0x101F501A );
-const TInt KWIMCertStoreUid ( 0x101F79D9 );
 const TUid KTrustedServerTokenUid = { 0x101FB66F };
 const TUid KDeviceCertStoreTokenUid = { 0x101FB668 };
 
@@ -81,6 +75,18 @@
 _LIT( KKeyStoreExportKeyLabel, "Passphrase of the exported key file" );
 _LIT( KPKCS12TokenLabel, "PKCS12");
 
+
+// TODO: replace with OST tracing
+#ifdef _DEBUG
+#include <e32debug.h>
+#define TRACE(x)        RDebug::Printf(x)
+#define TRACE1(x,y)     RDebug::Printf(x,y)
+#else
+#define TRACE(x)
+#define TRACE1(x,y)
+#endif
+
+
 // ============================ MEMBER FUNCTIONS ===============================
 
 // -----------------------------------------------------------------------------
@@ -106,9 +112,6 @@
 void CCTSecurityDialogsAO::ConstructL()
     {
     iDeleted = EFalse;
-
-    iQueryDialog = NULL;
-    iQueryDialogDeleted = ETrue;
     }
 
 // -----------------------------------------------------------------------------
@@ -184,6 +187,7 @@
     iMessagePtr = aMessage;
 
     WIMSECURITYDIALOGS_WRITE_FORMAT( "CCTSecurityDialogsAO::StartLD iOperation=%d", iOperation );
+    TRACE1( "CCTSecurityDialogsAO::StartLD iOperation=%d", iOperation );
 
     MapTlsProviderOperation( iOperation );
 
@@ -338,6 +342,8 @@
 //
 void CCTSecurityDialogsAO::DoHandleServerAuthFailL( const TDesC8& aBuffer )
     {
+    TRACE( "CCTSecurityDialogsAO::DoHandleServerAuthFailL" );
+
     CServerAuthenticationFailureInput* srvAuthFail =
         CServerAuthenticationFailureInput::NewLC( aBuffer );
     TPtrC8 cert;
@@ -350,33 +356,31 @@
 
     iServerName = HBufC::NewL( serverName.Length() );
     iServerName->Des().Copy( serverName );
+    iCertLabel = NULL;
 
-    HBufC* cn = NULL;
-    iCertLabel = NULL;
     // Site will be checked later. For now it is not trusted
     iTrustedSite = EFalse;
 
-
     CX509Certificate* serverCert = CX509Certificate::NewLC( cert );
-    // Retrieve subject name
     const CX500DistinguishedName& dName = serverCert->SubjectName();
-    // Retrieve CN
-    cn = dName.ExtractFieldL( KX520CommonName );
-    if ( cn != NULL )
+
+    HBufC* commonName = dName.ExtractFieldL( KX520CommonName );
+    CleanupStack::PushL( commonName );
+    if( commonName != NULL )
         {
-        // commonName exist in the certificate.
         // Check the length of CN. RFC 3280 states
         // that max length of CN is 64.
-        if ( cn->Length() <= KMaxCNLength )
+        if( commonName->Length() <= KMaxCommonNameLength )
             {
-            iCertLabel = HBufC::NewL( cn->Length() );
-            iCertLabel->Des().Append( cn->Des() );
+            iCertLabel = HBufC::NewL( commonName->Length() );
+            iCertLabel->Des().Append( commonName->Des() );
             }
         }
+    CleanupStack::PopAndDestroy( commonName );
 
-    if ( iCertLabel == NULL )
+    if( iCertLabel == NULL )
         {
-        // No or invalid commonName. Use domain name as label
+        // No or invalid commonName. Use domain name as label.
         iCertLabel = HBufC::NewL( iServerName->Length() );
         iCertLabel->Des().Append( iServerName->Des() );
         }
@@ -801,6 +805,8 @@
 //
 void CCTSecurityDialogsAO::InitCertStoreL()
     {
+    TRACE( "CCTSecurityDialogsAO::InitCertStoreL" );
+
     switch(iOperation)
         {
         case ESignText:
@@ -936,13 +942,15 @@
     {
     WIMSECURITYDIALOGS_WRITE_FORMAT( "CCTSecurityDialogsAO::RunL, iStatus %d", iStatus.Int() );
     WIMSECURITYDIALOGS_WRITE_FORMAT( "  iNextStep %d", iNextStep );
+    TRACE1( "CCTSecurityDialogsAO::RunL, iStatus.Int()=%d", iStatus.Int() );
 
-    if ( iStatus != KErrNone )
+    if( iStatus != KErrNone )
         {
         User::Leave( iStatus.Int() );
-        } // if
+        }
 
-    switch ( iNextStep )
+    TRACE1( "CCTSecurityDialogsAO::RunL, iNextStep=%d", iNextStep );
+    switch( iNextStep )
       {
       case EOperationCompleted:
         {
@@ -950,35 +958,34 @@
         HandleResponseAndCompleteL();
         break;
         }
+
       case ECheckServerCerts:
         {
         WIMSECURITYDIALOGS_WRITE( "ECheckServerCerts" );
 
         TBool foundCert( EFalse );
 
-        if ( iServerCerts.Count() )
+        if( iServerCerts.Count() )
             {
             // Found certificates in the trusted site certificate storage.
             // Compare them with the one received from TlsProvider
             iCertPtr.Set( iCertBuf->Des() );
             CX509Certificate* serverCert = CX509Certificate::NewLC( iCertPtr );
 
-            for (TInt i=0; i<iServerCerts.Count(); i++ )
+            for( TInt i = 0; i < iServerCerts.Count(); i++ )
                 {
                 TPtr8 certPtr( iServerCerts[i]->Des() );
-
                 CX509Certificate* cert = CX509Certificate::NewLC( certPtr );
-
-                // Compare fingerprints
-                if ( cert->Fingerprint() == serverCert->Fingerprint() )
+                if( cert->Fingerprint() == serverCert->Fingerprint() )
                     {
-                    // Fingerprints match
                     foundCert = ETrue;
                     }
                 CleanupStack::PopAndDestroy( cert );
                 }
+
              CleanupStack::PopAndDestroy( serverCert );
-             if ( foundCert )
+
+             if( foundCert )
                 {
                 // Found matching certificate. Complete the operation
                 iRetValue = EServerCertAcceptedPermanently;
@@ -987,24 +994,26 @@
                 }
             }
 
-            if ( !foundCert )
-                {
-                // Couldn't find matching certificate. Prompt user
-                ShowNoTrustDialogL();
-                }
-
+        if ( !foundCert )
+            {
+            // Couldn't find matching certificate. Prompt user
+            ShowNoTrustDialogL();
+            }
         break;
         }
+
       case EProcessTrustedSite:
         {
         WIMSECURITYDIALOGS_WRITE( "EProcessTrustedSite" );
+        TRACE( "CCTSecurityDialogsAO::RunL, EProcessTrustedSite" );
+
         TInt count = iCertStore->WritableCertStoreCount();
-        for ( TInt i = 0; i < count; i++ )
+        for( TInt i = 0; i < count; i++ )
             {
             MCTWritableCertStore *certstore = &iCertStore->WritableCertStore( i );
             MCTToken& token = certstore->Token();
             TUid tokenuid = token.Handle().iTokenTypeUid;
-            if ( tokenuid == KTrustedServerTokenUid )
+            if( tokenuid == KTrustedServerTokenUid )
                 {
                 iTrustedSiteCertStore = certstore;
                 }
@@ -1016,11 +1025,11 @@
         // Find out whether or not site associated with certificate is trusted
         iTrustedSite = trustedSitesStore->IsTrustedSiteL( *iCertBuf, *iServerName );
 
-        if ( iTrustedSite )
+        if( iTrustedSite )
             {
             TBool allowOutOfDate = trustedSitesStore->IsOutOfDateAllowedL(*iCertBuf, *iServerName);
 
-            if (!allowOutOfDate)
+            if( !allowOutOfDate )
                 {
                 CX509Certificate* cert = CX509Certificate::NewLC( iCertBuf->Des() );
 
@@ -1041,7 +1050,7 @@
             }
         CleanupStack::PopAndDestroy( trustedSitesStore );
 
-        if ( iTrustedSite )
+        if( iTrustedSite )
             {
             // Site is trusted. Next step is to check that server
             // certificate is in the trusted site certificate storage
@@ -1108,9 +1117,11 @@
             }
         break;
         }
+
       case EAddTrustedSite:
           {
-          if ( iStatus.Int() == KErrNone )
+          TRACE( "CCTSecurityDialogsAO::RunL, EAddTrustedSite" );
+          if( iStatus.Int() == KErrNone )
               {
               //Added server certificate succesfully
               CTrustSitesStore* trustedSitesStore = CTrustSitesStore::NewL();
@@ -1119,7 +1130,7 @@
               TInt status = trustedSitesStore->AddL( *iCertBuf, *iServerName );
 
               CleanupStack::PopAndDestroy( trustedSitesStore );
-              if ( status  == KErrNone )
+              if( status  == KErrNone )
                   {
                   iRetValue = EServerCertAcceptedPermanently;
                   }
@@ -1134,23 +1145,27 @@
           else
               {
               //Adding server certificate failed
+              // TODO: unreached code?
               iNextStep = EOperationCompleted;
               iRetValue = EServerCertNotAccepted;
               HandleResponseAndCompleteL();
               }
-              break;
+          break;
           }
 
       case ESaveServerCert:
           {
           WIMSECURITYDIALOGS_WRITE( "ESaveServerCert" );
+          TRACE( "CCTSecurityDialogsAO::RunL, ESaveServerCert" );
           DoHandleSaveServerCertL();
           break;
           }
+
       case EServerCertCheckUserResp:
           {
           WIMSECURITYDIALOGS_WRITE( "EServerCertCheckUserResp" );
-          if ( iRetValue == EServerCertAcceptedPermanently )
+          TRACE( "CCTSecurityDialogsAO::RunL, EServerCertCheckUserResp" );
+          if( iRetValue == EServerCertAcceptedPermanently )
               {
               // User accepted to select certificate permanently.
               // First add server certificate
@@ -1167,6 +1182,7 @@
               }
           break;
           }
+
       case EOperationSignTextShown:
           {
           if ( iRetValue || iOperation == EUserAuthentication )
@@ -1183,6 +1199,7 @@
           User::RequestComplete( status, KErrNone );
           break;
           }
+
       case EOperationInitCertStore:
           {
           TInt err = KErrNone;
@@ -1200,6 +1217,7 @@
           iNextStep = EOperationRetrieveCertInfos;
           break;
           }
+
       case EOperationRetrieveCertInfos:
           {
           if ( iCertInfo )
@@ -1235,11 +1253,13 @@
               }
           break;
           }
+
       case EOperationSelectCert:
           {
           DoHandleSelectCertificateL();
           break;
           }
+
       case EGetCertInfo:
           {
           iStatus = KRequestPending;
@@ -1249,6 +1269,7 @@
           SetActive();
           break;
           }
+
       case EGetCertificate:
           {
           iStatus = KRequestPending;
@@ -1268,36 +1289,42 @@
           iNextStep = EInitKeyStore;
           break;
           }
+
       case EInitKeyStore:
           {
           InitKeyStoreL();
           iNextStep = EGetKeyInfos;
           break;
           }
+
       case EGetKeyInfos:
           {
           GetKeyInfosL();
           iNextStep = EShowCertDialog;
           break;
           }
+
       case EGetKeyInfoByHandle:
           {
           GetKeyInfoByHandleL();
           iNextStep = EShowCSRDialog;
           break;
           }
+
       case EShowCSRDialog:
           {
           ShowCSRDialogL();
           iNextStep = EOperationCompleted;
           break;
           }
+
       case EShowCertDialog:
           {
           ShowCertDialogL();
           iNextStep = EOperationCompleted;
           break;
           }
+
       /////////////
       // PIN steps
       /////////////
@@ -1340,11 +1367,13 @@
               }
           break;
           }
+
       case EVerifyPINs:
           {
           VerifyPinsL();
           break;
           }
+
       default:
           {
           User::Panic( _L("CTestSecDlgNotifier"), 0 );
@@ -1434,84 +1463,40 @@
 //
 void CCTSecurityDialogsAO::ShowNoTrustDialogL()
     {
-    CX509Certificate* cert = CX509Certificate::NewLC( iCertBuf->Des() );
-    TInt resourceid = R_WIM_NO_TRUST_QUERY_UNTRUSTED;
-    TBool showPermAccept = ETrue;
+    TRACE( "CCTSecurityDialogsAO::ShowNoTrustDialogL, begin" );
 
-    if( iAuthFailReason == ESignatureInvalid || iAuthFailReason == ECertificateRevoked )
-        {
-        // Invalid or revoked certificate
-        CCTInvalidCertificateNote* note =
-            new( ELeave ) CCTInvalidCertificateNote( *this, iStatus );
-        note->ExecuteLD( R_WIM_INVALID_CERTIFICATE_INFORMATION_NOTE );
-        iRetValue = EServerCertNotAccepted;
-        }
-    else
-        {
-        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 );
+    // If trusted site certstore open has failed, then it is not possible to save
+    // the host name for permanent use. Hence, choice for permanent accept is not
+    // displayed if trusted site certstore open has failed. Other restrictions for
+    // permanent accept are defined in device dialog (UntrustedCertificateWidget).
+    TBool isTrustedSiteCertStoreOpened = ( iTrustedSiteCertStore != NULL );
+    CCTUntrustedCertQuery *untrustedCertDlg = CCTUntrustedCertQuery::NewLC(
+            iAuthFailReason, *iCertBuf, *iServerName, isTrustedSiteCertStoreOpened );
 
-            // Check common name first and then date
-            if( !cn )
-                {
-                // Couldn't retrieve CN from certificate
-                resourceid = R_WIM_NO_TRUST_QUERY_UNTRUSTED;
-                }
-            else if( iServerName->Des() != cn->Des() )
-                {
-                // Domain name doesn't match with CN
-                resourceid = R_WIM_NO_TRUST_QUERY_SITE;
-                }
-            else if( iAuthFailReason == EDateOutOfRange )
-                {
-                // Certificate is out of date
-                resourceid = R_WIM_NO_TRUST_QUERY_OOD;
-                showPermAccept = EFalse;
-                }
-            else
-                {
-                // Otherwise show general untrusted note
-                resourceid = R_WIM_NO_TRUST_QUERY_UNTRUSTED;
-                }
-            }
-        else
-            {
-            // Untrusted certificate
-            resourceid = R_WIM_NO_TRUST_QUERY_UNTRUSTED;
-            }
-
-        // No "Accept Permanently" option if certificate is out of date, or
-        // if domain name is not defined, or if trusted site store failed to
-        // open (and it's not possible to save the server certificate).
-        const CValidityPeriod& validityPeriod = cert->ValidityPeriod();
-        const TTime& startValue = validityPeriod.Start();
-        const TTime& finishValue = validityPeriod.Finish();
-        TTime current;
-        current.UniversalTime();
-
-        if( (( startValue > current ) || ( finishValue < current )) ||
-                ( iServerName->Des().Length() == 0 ) ||
-                ( !iTrustedSiteCertStore ) )
-            {
-            showPermAccept = EFalse;
-            }
-
-        iQueryDialog = new( ELeave ) CCTNoTrustQuery( *this, iRetValue, iStatus, iServerName,
-                    showPermAccept, iQueryDialogDeleted );
-        iQueryDialog->ExecuteLD( resourceid );
+    CCTUntrustedCertQuery::TResponse response = CCTUntrustedCertQuery::EQueryRejected;
+    untrustedCertDlg->ShowQueryAndWaitForResponseL( response );
+    switch( response )
+        {
+        case CCTUntrustedCertQuery::EQueryAccepted:
+            iRetValue = EServerCertAcceptedTemporarily;
+            break;
+        case CCTUntrustedCertQuery::EQueryAcceptedPermanently:
+            // TODO: show confirmation note, qtn_httpsec_query_perm_accept_text
+            // "Connection to site %U will be made in future without any warnings. Continue?""
+            iRetValue = EServerCertAcceptedPermanently;
+            break;
+        case CCTUntrustedCertQuery::EQueryRejected:
+        default:
+            iRetValue = EServerCertNotAccepted;
+            break;
         }
-
-    CleanupStack::PopAndDestroy( cert );
+    CleanupStack::PopAndDestroy( untrustedCertDlg );
+    TRACE1( "CCTSecurityDialogsAO::ShowNoTrustDialogL, iRetValue=%d", iRetValue );
 
     iNextStep = EServerCertCheckUserResp;
     iStatus = KRequestPending;
+    TRequestStatus* status = &iStatus;
+    User::RequestComplete( status, KErrNone );
     SetActive();
     }
 
@@ -2028,9 +2013,9 @@
 // CCTSecurityDialogsAO::AddCertFormatL(...)
 // -----------------------------------------------------------------------------
 //
-void CCTSecurityDialogsAO::AddCertFormatL( TDes& aMessage, TCertificateFormat aCertFormat)
+void CCTSecurityDialogsAO::AddCertFormatL( TDes& /*aMessage*/, TCertificateFormat aCertFormat)
     {
-    TInt fieldType = 0;
+    //TInt fieldType = 0;
     switch ( aCertFormat )
         {
         case EX509CertificateUrl:
@@ -2312,6 +2297,7 @@
             iMessagePtr.WriteL( iReplySlot, pinValueBufPtr );
             break;
             }
+
         case EChangePIN:
         case EUnblockPIN:
             {
@@ -2322,6 +2308,7 @@
             iMessagePtr.WriteL( iReplySlot, twoPINOutputBuf );
             break;
             }
+
         case ESignText: // flow thru
         case EUserAuthenticationText: // flow thru
         case EUserAuthentication:
@@ -2330,13 +2317,14 @@
             iMessagePtr.WriteL( iReplySlot, tokenObjectHandleBuf );
             break;
             }
+
         case EServerAuthenticationFailure:
             {
             TServerAuthenticationFailureDialogResult result = EStop;
 
-            if ( iRetValue != EServerCertAcceptedPermanently )
+            if( iRetValue != EServerCertAcceptedPermanently )
                 {
-                if ( iRetValue == EServerCertAcceptedTemporarily )
+                if( iRetValue == EServerCertAcceptedTemporarily )
                     {
                     result = EContinue;
                     }
@@ -2357,12 +2345,14 @@
 
             break;
             }
+
         case EPINBlocked:
         case EUnblockPINInClear:
             {
             User::Leave( KErrNotSupported );
             break;
             }
+
         case ECreateCSR:
         case ECertDetails:
         case ESaveCert:
@@ -2378,6 +2368,7 @@
             {
             break; // Complete is enough
             }
+
         default:
             User::Panic( _L("CTestSecDlgNotifier"), 0 );
         }
@@ -2425,18 +2416,7 @@
 void CCTSecurityDialogsAO::DoCancel()
     {
     WIMSECURITYDIALOGS_WRITE( "CCTSecurityDialogsAO::DoCancel" );
-
-    // Note that iQueryDialog may point to already deleted memory.
-    // Dialogs need to set and reset iQueryDialogDeleted flag to
-    // allow deleting the dialog from CCTSecurityDialogsAO.
-    if( !iQueryDialogDeleted )
-        {
-        delete iQueryDialog;
-        iQueryDialogDeleted = ETrue;
-        }
-    iQueryDialog = NULL;
-
-    if ( !iPinQueryDialogDeleted )
+    if( !iPinQueryDialogDeleted )
         {
         delete iPinQueryDialog;
         iPinQueryDialogDeleted = ETrue;
@@ -2469,10 +2449,12 @@
 //
 void CCTSecurityDialogsAO::DoHandleSaveServerCertL()
     {
+    TRACE( "CCTSecurityDialogsAO::DoHandleSaveServerCertL" );
+
     if ( iTrustedSiteCertStore )
         {
         iTrustedSiteCertStore->Add( *iCertLabel, EX509Certificate,
-                                EPeerCertificate, NULL, NULL, *iCertBuf, iStatus );
+            EPeerCertificate, NULL, NULL, *iCertBuf, iStatus );
 
         // Next step is to update trust site db
         iNextStep = EAddTrustedSite;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pkiutilities/CTSecurityDialogs/NotifSrc/CTUntrustedCertQuery.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -0,0 +1,238 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Displays untrusted certificate dialog.
+*
+*/
+
+#include "CTUntrustedCertQuery.h"           // CCTUntrustedCertQuery
+#include <hb/hbcore/hbsymbianvariant.h>     // CHbSymbianVariantMap
+
+// Note that the dialog type string, the parameters name strings, and the return code
+// name string and values must match to those defined in Qt-side untrusted certificate
+// dialog (in untrustedcertificatedefinitions.h file).
+
+// Device dialog type for untrusted certificate dialog
+_LIT( KUntrustedCertificateDialog, "com.nokia.untrustedcert/1.0" );
+
+// Variant map parameter names for untrusted certificate dialog
+_LIT( KUntrustedCertEncodedCertificate, "cert" );   // bytearray, mandatory
+_LIT( KUntrustedCertServerName, "host" );           // string, mandatory
+_LIT( KUntrustedCertValidationError, "err" );       // int (TValidationError), mandatory
+_LIT( KUntrustedCertTrustedSiteStoreFail, "tss" );  // any, prevents permanent acceptance
+
+// Dialog return code name and values
+_LIT( KUntrustedCertDialogResult, "result" );       // int
+const TInt KUntrustedCertDialogRejected = 0;
+const TInt KUntrustedCertDialogAccepted = 1;
+const TInt KUntrustedCertDialogAcceptedPermanently = 2;
+
+// TODO: replace with OST tracing
+#ifdef _DEBUG
+#include <e32debug.h>
+#define TRACE(x)        RDebug::Printf(x)
+#define TRACE1(x,y)     RDebug::Printf(x,y)
+#else
+#define TRACE(x)
+#define TRACE1(x,y)
+#endif
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CCTUntrustedCertQuery::NewLC()
+// ---------------------------------------------------------------------------
+//
+CCTUntrustedCertQuery* CCTUntrustedCertQuery::NewLC(
+        TValidationError aValidationError, const TDesC8& aCertificate,
+        const TDesC& aServerName, TBool aCanHandlePermanentAccept )
+    {
+    TRACE( "CCTUntrustedCertQuery::NewLC" );
+    CCTUntrustedCertQuery* self = new ( ELeave ) CCTUntrustedCertQuery(
+            aValidationError, aCertificate, aServerName,
+            aCanHandlePermanentAccept );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CCTUntrustedCertQuery::~CCTUntrustedCertQuery()
+// ---------------------------------------------------------------------------
+//
+CCTUntrustedCertQuery::~CCTUntrustedCertQuery()
+    {
+    TRACE( "CCTUntrustedCertQuery::~CCTUntrustedCertQuery" );
+    Cancel();
+    delete iWait;
+    delete iDeviceDialog;
+    delete iVariantMap;
+    }
+
+// ---------------------------------------------------------------------------
+// CCTUntrustedCertQuery::ShowQueryAndWaitForResponseL()
+// ---------------------------------------------------------------------------
+//
+void CCTUntrustedCertQuery::ShowQueryAndWaitForResponseL( TResponse& aResponse )
+    {
+    TRACE( "CCTUntrustedCertQuery::ShowQueryAndWaitForResponseL" );
+    if( !iDeviceDialog )
+        {
+        iDeviceDialog = CHbDeviceDialogSymbian::NewL();
+        }
+    if( !iVariantMap )
+        {
+        iVariantMap = CHbSymbianVariantMap::NewL();
+        }
+
+    CHbSymbianVariant *variant = NULL;
+    variant = CHbSymbianVariant::NewL( &iCertificate, CHbSymbianVariant::EBinary );
+    User::LeaveIfError( iVariantMap->Add( KUntrustedCertEncodedCertificate, variant ) );
+    variant = CHbSymbianVariant::NewL( &iValidationError, CHbSymbianVariant::EInt );
+    User::LeaveIfError( iVariantMap->Add( KUntrustedCertValidationError, variant ) );
+    variant = CHbSymbianVariant::NewL( &iServerName, CHbSymbianVariant::EDes );
+    User::LeaveIfError( iVariantMap->Add( KUntrustedCertServerName, variant ) );
+    if( !iCanHandlePermanentAccept )
+        {
+        variant = CHbSymbianVariant::NewL( &iCanHandlePermanentAccept, CHbSymbianVariant::EBool );
+        User::LeaveIfError( iVariantMap->Add( KUntrustedCertTrustedSiteStoreFail, variant ) );
+        }
+
+    User::LeaveIfError( iDeviceDialog->Show( KUntrustedCertificateDialog, *iVariantMap, this ) );
+
+    iStatus = KRequestPending;
+    SetActive();
+    TRACE( "CCTUntrustedCertQuery::ShowQueryAndWaitForResponseL, wait start" );
+    iWait->Start();
+    TRACE( "CCTUntrustedCertQuery::ShowQueryAndWaitForResponseL, wait end" );
+    TRACE1( "CCTUntrustedCertQuery::ShowQueryAndWaitForResponseL, iWaitCompletionCode=%d", iWaitCompletionCode );
+    User::LeaveIfError( iWaitCompletionCode );
+    TRACE1( "CCTUntrustedCertQuery::ShowQueryAndWaitForResponseL, iResponse=%d", iResponse );
+    aResponse = iResponse;
+    }
+
+// ---------------------------------------------------------------------------
+// CCTUntrustedCertQuery::DoCancel()
+// ---------------------------------------------------------------------------
+//
+void CCTUntrustedCertQuery::DoCancel()
+    {
+    TRACE( "CCTUntrustedCertQuery::DoCancel begin" );
+    if( iDeviceDialog )
+        {
+        TRACE( "CCTUntrustedCertQuery::DoCancel, iDeviceDialog->Cancel()" );
+        iDeviceDialog->Cancel();
+        }
+    if( iWait && iWait->IsStarted() && iWait->CanStopNow() )
+        {
+        TRACE( "CCTUntrustedCertQuery::DoCancel, iWait->AsyncStop()" );
+        iWaitCompletionCode = KErrCancel;
+        iWait->AsyncStop();
+        }
+    TRACE( "CCTUntrustedCertQuery::DoCancel end" );
+    }
+
+// ---------------------------------------------------------------------------
+// CCTUntrustedCertQuery::RunL()
+// ---------------------------------------------------------------------------
+//
+void CCTUntrustedCertQuery::RunL()
+    {
+    TRACE1( "CCTUntrustedCertQuery::RunL, iStatus.Int()=%d", iStatus.Int() );
+    iWaitCompletionCode = iStatus.Int();
+    if( iWait )
+        {
+        iWait->AsyncStop();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CCTUntrustedCertQuery::DataReceived()
+// ---------------------------------------------------------------------------
+//
+void CCTUntrustedCertQuery::DataReceived( CHbSymbianVariantMap& aData )
+    {
+    TRACE( "CCTUntrustedCertQuery::DataReceived" );
+    const CHbSymbianVariant* variant = aData.Get( KUntrustedCertDialogResult );
+    if( variant )
+        {
+        TInt* value = variant->Value<TInt>();
+        if( value )
+            {
+            switch( *value )
+                {
+                case KUntrustedCertDialogRejected:
+                    TRACE( "CCTUntrustedCertQuery::DataReceived, rejected" );
+                    iResponse = EQueryRejected;
+                    break;
+                case KUntrustedCertDialogAccepted:
+                    TRACE( "CCTUntrustedCertQuery::DataReceived, accepted" );
+                    iResponse = EQueryAccepted;
+                    break;
+                case KUntrustedCertDialogAcceptedPermanently:
+                    TRACE( "CCTUntrustedCertQuery::DataReceived, accepted permanently" );
+                    iResponse = EQueryAcceptedPermanently;
+                    break;
+                default:
+                    __ASSERT_DEBUG( EFalse, User::Invariant() );
+                    break;
+                }
+            }
+        else
+            {
+            __ASSERT_DEBUG( EFalse, User::Invariant() );
+            }
+        }
+    else
+        {
+        __ASSERT_DEBUG( EFalse, User::Invariant() );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CCTUntrustedCertQuery::DeviceDialogClosed()
+// ---------------------------------------------------------------------------
+//
+void CCTUntrustedCertQuery::DeviceDialogClosed( TInt aCompletionCode )
+    {
+    TRACE1( "CCTUntrustedCertQuery::DeviceDialogClosed aCompletionCode=%d", aCompletionCode );
+    TRequestStatus* status( &iStatus );
+    User::RequestComplete( status, aCompletionCode );
+    }
+
+// ---------------------------------------------------------------------------
+// CCTUntrustedCertQuery::CCTUntrustedCertQuery()
+// ---------------------------------------------------------------------------
+//
+CCTUntrustedCertQuery::CCTUntrustedCertQuery(
+        TValidationError aValidationError, const TDesC8& aCertificate,
+        const TDesC& aServerName, TBool aCanHandlePermanentAccept ) :
+        CActive( CActive::EPriorityStandard ), iValidationError( aValidationError ),
+        iCertificate( aCertificate ), iServerName( aServerName ),
+        iCanHandlePermanentAccept( aCanHandlePermanentAccept ),
+        iResponse( EQueryRejected )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+// CCTUntrustedCertQuery::ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CCTUntrustedCertQuery::ConstructL()
+    {
+    TRACE( "CCTUntrustedCertQuery::ConstructL" );
+    iWait = new( ELeave ) CActiveSchedulerWait;
+    }
+
--- a/pkiutilities/CertSaver/data/CertSaver.rss	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/CertSaver/data/CertSaver.rss	Wed Jun 23 19:10:54 2010 +0300
@@ -22,14 +22,9 @@
 
 //  INCLUDES
 #include <eikon.rh>
-#include <eikon.rsg>
 #include <avkon.rsg>
-#include <avkon.hrh>
 #include <avkon.rh>
-#include <avkon.mbg>
-#include <avkon.loc>
 #include <appinfo.rh>
-//#include <certmanui.loc>  //qtn_cm_not_valid_yet
 #include <certsaver.loc>
 #include "certsaver.hrh"
 
@@ -158,6 +153,7 @@
     buf = qtn_cm_not_defined;
     }
 
+
 //----------------------------------------------------
 //
 //    r_certsaver_softkeys_save_discard
@@ -209,8 +205,6 @@
         };
     }
 
-
-
 //----------------------------------------------------
 //
 //    r_message_query_dosave
@@ -282,24 +276,28 @@
 //
 //----------------------------------------------------
 //
-RESOURCE DIALOG r_certsaver_warning_note
-    {
-    flags = EGeneralQueryFlags;
-    buttons = r_certsaver_softkeys_save_discard;
-    items=
-        {
-        DLG_LINE
-            {
-            type=EAknCtQuery;
-            id=EGeneralQuery;
-            control= AVKON_CONFIRMATION_QUERY
-                {
-                layout = EConfirmationLayout;
+RESOURCE TBUF r_certsaver_warning_note { buf = qtn_httpsec_save_rootcertificate; }
+
+/*
+RESOURCE DIALOG r_certsaver_warning_note                 
+    {                                                    
+    flags = EGeneralQueryFlags;                          
+    buttons = r_certsaver_softkeys_save_discard;         
+    items=                                               
+        {                                                
+        DLG_LINE                                         
+            {                                            
+            type=EAknCtQuery;                            
+            id=EGeneralQuery;                            
+            control= AVKON_CONFIRMATION_QUERY            
+                {                                        
+                layout = EConfirmationLayout;            
                 label = qtn_httpsec_save_rootcertificate;
-                };
-            }
-        };
-    }
+                };                                       
+            }                                            
+        };                                               
+    }                                                    
+*/
 
 //-----------------------------------------------------------------------------
 //
@@ -472,6 +470,7 @@
 RESOURCE TBUF r_certsaver_one_private_key{ buf = qtn_cm_one_private_key; }
 RESOURCE TBUF r_certsaver_one_personal_certificate { buf = qtn_cm_one_personal_certificate; }
 RESOURCE TBUF r_certsaver_one_authority_certificate { buf = qtn_cm_one_authority_certificate; }
-RESOURCE TBUF r_certsaver_trustedsite_warning { buf = qtn_cm_save_trustedsite_certificate_warning_text; }
+RESOURCE TBUF r_certsaver_trustedsite_warning 
+                { buf = qtn_cm_save_trustedsite_certificate_warning_text; }
 
 // End of File
--- a/pkiutilities/CertSaver/group/CertSaver.mmp	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/CertSaver/group/CertSaver.mmp	Wed Jun 23 19:10:54 2010 +0300
@@ -54,11 +54,16 @@
 
 USERINCLUDE ../inc
 USERINCLUDE ../../Include
+USERINCLUDE ../../../securitydialogs/SecUi/Inc
 
 MW_LAYER_SYSTEMINCLUDE
 SYSTEMINCLUDE   ../../PKCS12/CrPkcs12/Inc
 SYSTEMINCLUDE   ../../DeviceToken/Inc
 
+SYSTEMINCLUDE   /epoc32/include/mw/hb/hbcore 
+SYSTEMINCLUDE   /epoc32/include/mw/hb/hbwidgets
+
+
 LIBRARY euser.lib
 LIBRARY apparc.lib
 LIBRARY cone.lib
@@ -81,5 +86,9 @@
 LIBRARY aknskins.lib
 LIBRARY DevTokenClient.lib
 
+LIBRARY HbCore.lib
+LIBRARY HbWidgets.lib
+LIBRARY	secui.lib
+
 SMPSAFE
 
--- a/pkiutilities/CertSaver/inc/CertSaverModel.h	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/CertSaver/inc/CertSaverModel.h	Wed Jun 23 19:10:54 2010 +0300
@@ -310,10 +310,12 @@
         */
         void DivideToBlocks( const TDesC8& aInput, TDes& aOutput ) const;
 
-        TBool DoMessageQueryL(
-            TInt aDialogResId,
+/*
+        TBool DoMessageQueryL( 
+            TInt aDialogResId, 
             TInt aHeadingResId,
-            TDesC& aMessage );
+            TDesC& aMessage ); 
+*/
 
     private: //data
         TCertificateOwnerType     iCertOwnerType;
@@ -336,6 +338,8 @@
         TInt  iSavedUserCertsCount;
         TInt  iSelectedKeyStore;
         TBool iKeyAlreadyExists;
+
+        CEikonEnv*        iEikEnv;
     };
 
 #endif
--- a/pkiutilities/CertSaver/loc/certsaver.loc	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/CertSaver/loc/certsaver.loc	Wed Jun 23 19:10:54 2010 +0300
@@ -30,6 +30,7 @@
 //l:control_pane_t1/opt7
 #define text_wmls_list_disc_recvd_cert    "Discard"
 
+
 //d:Item in save-confirmation query pop up.
 //d:This represents to whom the certificate
 //d:has been issued to.
--- a/pkiutilities/CertSaver/src/CertSaverAppUi.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/CertSaver/src/CertSaverAppUi.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -18,7 +18,6 @@
 
 // INCLUDE FILES
 #include <sysutil.h>            // For FFSSpaceBelowCriticalLevelL(..)
-#include <aknnotewrappers.h>    // Note dialogs
 #include <mpkcs12.h>
 #include <cryptostrength.h>
 #include <CertSaver.rsg>
--- a/pkiutilities/CertSaver/src/CertSaverDocument.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/CertSaver/src/CertSaverDocument.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -112,7 +112,7 @@
 
     OpenFileL( docStore, file );
 
-    CleanupStack::PopAndDestroy(); // Close file
+    CleanupStack::PopAndDestroy(&file); // Close file
 
     return docStore;
     }
@@ -137,7 +137,7 @@
     iAO = new (ELeave) CShutterAO;
     iAO->Exit();
     #ifdef _DEBUG
-        RDebug::Print( _L("Exiting OpenFileL") );
+        
     #endif
     }
 
--- a/pkiutilities/CertSaver/src/CertSaverModel.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/CertSaver/src/CertSaverModel.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -18,7 +18,9 @@
 
 // INCLUDE FILES
 #include <aknnotewrappers.h>        // Note dialogs
-#include <aknmessagequerydialog.h>  // For CAknMessageQueryDialog
+
+
+
 #include <StringLoader.h>           // For loading resource strings
 #include <unifiedcertstore.h>       // For saving the certificates
 #include <mctwritablecertstore.h>   // For saving the certificates
@@ -44,7 +46,14 @@
 #include "certsaver.hrh"
 #include "securityuisvariant.hrh"
 
+#include <hbdevicemessageboxsymbian.h>
+#include <hbdevicenotificationdialogsymbian.h>
+#include <hbsymbianvariant.h>
+
+#include "SecQueryUi.h"                   // needed for label dialog
+
 // CONSTANTS
+
 const TInt32 KWTLSTrusterUID( 268479059 );
 const TInt32 KInternetTrusterUID( 268441661 );
 const TInt32 KApplicationControllerTrusterUID( 268452523 );
@@ -56,12 +65,14 @@
 
 const TInt KMaxLengthTextMeassageBody( 5000 );
 const TInt KMaxLengthTextDateString( 11 );    // "dd/mm/yyyy0"
+const TInt KMaxLengthTextCheckBoxData( 255 );    // "dd/mm/yyyy0"
 
 //Issuer and Owner max visible length
 const TInt KMaxLengthTextCertIdentifierVisible( 1000 );
 const TInt KAttempts( 3 );
 
 const TInt KFingerprintLength( 50 );
+const TInt KTokenLength( 32 );
 
 _LIT( KCertSaverListBoxItemPrefix, "1\t" );
 const TInt KItemBufLen = 2 + KMaxName;
@@ -116,6 +127,7 @@
             const TCertificateOwnerType& aOwnerType,
             const TCertificateFormat& aCertFormat )
     {
+
     iCertOwnerType = aOwnerType;
     iCertFormat = aCertFormat;
     iNewCert = &aCertificate;
@@ -139,6 +151,7 @@
 //
 void CCertSaverModel::DoSavePrivateKeyL( const TDesC8& aKey )
     {
+
     CheckFSSpaceL( aKey );
 
     TKeyIdentifier keyIdentifier;
@@ -158,7 +171,8 @@
     CleanupStack::PopAndDestroy( pkcs8Data );
     if (KeyAlreadyExistsL( startDate, endDate, keyIdentifier, keyUsage) )
         {
-        User::Leave( KErrNone );
+        // used to leave with error none
+        return;
         }
 
     TInt accessType( 0 );
@@ -254,6 +268,7 @@
     const TKeyIdentifier& aKeyIdentifier,
     TKeyUsagePKCS15& aKeyUsage )
     {
+
     TBool ret = EFalse;
     TCTKeyAttributeFilter keyFilter;
     keyFilter.iKeyAlgorithm = CKeyInfoBase::EInvalidAlgorithm;
@@ -304,6 +319,7 @@
     const TKeyIdentifier& aKeyIdentifier )
     {
 
+
     for ( TInt i = 0; i < iParser.UserCertificates().Count(); i++ )
         {
         const CX509Certificate* cert = iParser.UserCertificates().At( i );
@@ -330,6 +346,7 @@
 //
 void CCertSaverModel::CreateKeyLabelL( TDes& aLabel )
     {
+
     TTime time;
     time.UniversalTime();
     TBuf<KPrivaKeyLabelLength> dateBuf;
@@ -349,6 +366,7 @@
 //
 void CCertSaverModel::SavePrivateKeyL()
     {
+
     if ( iParser.Keys().Count() <= 0 )
         {
         return;
@@ -397,6 +415,7 @@
     TAlgorithmId aAlgorithm )
     {
 
+
     TKeyUsagePKCS15 pkcs15KeyUsage = EPKCS15UsageNone;
     TKeyUsageX509 x509Usage = EX509UsageNone;
 
@@ -485,16 +504,15 @@
 //
 void CCertSaverModel::CheckFSSpaceL( const TDesC8& aDataToSave )
     {
+
     if (SysUtil::FFSSpaceBelowCriticalLevelL( &iFs, aDataToSave.Size() ))
         {
         HBufC* p = StringLoader::LoadLC( R_CERTSAVER_MEMORY );
-        CAknErrorNote* note = new (ELeave) CAknErrorNote( ETrue );
-        note->ExecuteLD( p->Des() );
+        CHbDeviceMessageBoxSymbian::WarningL(p->Des()); 
         CleanupStack::PopAndDestroy( p );
         User::Leave( KErrExitApp );
         }
     }
-
 // ----------------------------------------------------------
 // CCertSaverModel::SaveCertL()
 // Saves certificate
@@ -502,38 +520,33 @@
 //
 void CCertSaverModel::SaveCertL()
   {
+
     if ( !CertificateOkL() )
         {
         User::Leave( KErrCancel );
         }
-
+ 
     HBufC* message = HBufC::NewLC( KMaxLengthTextMeassageBody );
     TPtr msgPtr = message->Des();
     ConstructMessageL( msgPtr );
-    CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( *message );
-    CleanupStack::PopAndDestroy( message );
-    CleanupStack::PushL( dlg );
-
-
-    dlg->PrepareLC( R_MESSAGE_QUERY_DOSAVE );
-
-    HBufC* header = StringLoader::LoadLC( R_CERTSAVER_DETAILS_HEADING );
-    dlg->QueryHeading()->SetTextL( header->Des() );
-    CleanupStack::PopAndDestroy( header );
-    CleanupStack::Pop( dlg );
-    TBool doSave = dlg->RunLD();
+    CHbDeviceMessageBoxSymbian::TButtonId selection = 
+        CHbDeviceMessageBoxSymbian::QuestionL(msgPtr, KNullDesC, KNullDesC);
+    TBool doSave= (selection == CHbDeviceMessageBoxSymbian::EAcceptButton);
+    CleanupStack::PopAndDestroy(message);
 
     if ( doSave && iCertOwnerType == ECACertificate )
         {
         // warn user about security risk
-        CAknQueryDialog* warningDialog = CAknQueryDialog::NewL();
-        doSave = warningDialog->ExecuteLD( R_CERTSAVER_WARNING_NOTE );
+        HBufC* stringHolder = StringLoader::LoadLC( R_CERTSAVER_WARNING_NOTE );
+        CHbDeviceMessageBoxSymbian::TButtonId selection = 
+            CHbDeviceMessageBoxSymbian::QuestionL(stringHolder->Des(),KNullDesC, KNullDesC);
+        CleanupStack::PopAndDestroy(stringHolder);
+	    doSave=(selection == CHbDeviceMessageBoxSymbian::EAcceptButton);
         }
 
     if ( doSave )
         {
-        //Check that there still is enough space to store the
-        //certificate.
+        //Check that there still is enough space to store the certificate.
         CheckFSSpaceL( iNewCert->Encoding() );
         DoSaveCertL();
         }
@@ -544,6 +557,7 @@
         }
   }
 
+
 // ----------------------------------------------------------
 // CCertSaverModel::InitCertStoreL()
 //
@@ -551,6 +565,7 @@
 //
 void CCertSaverModel::InitCertStoreL()
     {
+
     if ( !iUnifiedCertStore )
         {
         TRAPD( status, iUnifiedCertStore = CUnifiedCertStore::NewL( iFs, ETrue ) );
@@ -576,6 +591,7 @@
 //
 void CCertSaverModel::DoSaveCertL()
     {
+
     TInt status = KErrNone;
     CCertAttributeFilter* filter = NULL;
     TCertificateFormat certFormat = EX509Certificate;
@@ -678,7 +694,8 @@
 
             MCTToken& token = writableCertStore.Token();
             TUid tokenuid = token.Handle().iTokenTypeUid;
-            if ( ( tokenuid == KTrustedServerTokenUid ) && ( iCertOwnerType == EPeerCertificate ) ||
+            if ( ( tokenuid == KTrustedServerTokenUid ) && 
+                 ( iCertOwnerType == EPeerCertificate ) ||
                  ( tokenuid == KFileTokensUid ) && ( iCertOwnerType == ECACertificate ) ||
                  ( tokenuid == KFileTokensUid ) && ( iCertOwnerType == EUserCertificate ) )
                 {
@@ -786,6 +803,7 @@
 //
 TInt CCertSaverModel::QueryLabelL( TCertLabel& aLabel, CUnifiedCertStore& aStore )
     {
+
     CCertAttributeFilter* filter = NULL;
     TInt status = KErrNone;
     RMPointerArray<CCTCertInfo> entries;
@@ -793,8 +811,18 @@
 
     while ( loop )
         {
-        CAknTextQueryDialog* dialog = CAknTextQueryDialog::NewL( aLabel );
-      if ( !dialog->ExecuteLD( R_CERTSAVER_LABEL_QUERY ) )
+    HBufC* labelprompt =  CEikonEnv::Static()->AllocReadResourceLC( R_CERTSAVER_ENTER_LABEL );
+    CSecQueryUi* SecQueryUi = CSecQueryUi::NewL();                                       
+    TInt queryAccepted = SecQueryUi->SecQueryDialog(labelprompt->Des(), aLabel,
+                                                1,KMaxCertLabelLength,          
+                                                ESecUiAlphaSupported |          
+                                                ESecUiCancelSupported |         
+                                                ESecUiEmergencyNotSupported);   
+    CleanupStack::PopAndDestroy( labelprompt );
+    delete SecQueryUi;  
+    SecQueryUi=NULL;
+
+      if ( queryAccepted!=KErrNone )
             {
             // cancel
             ShowConfirmationNoteL( R_CERTSAVER_CERT_DISCARDED );
@@ -840,6 +868,7 @@
 //
 void CCertSaverModel::HandleSaveErrorL( TInt aStatus ) const
     {
+
     switch ( aStatus )
         {
         case KErrNone:
@@ -884,6 +913,7 @@
 void CCertSaverModel::AddToMessageWithStringL(
     TDes& aMessage, TInt aStringResID, const TDesC& aString ) const
     {
+
     HBufC* promptPtr = NULL;
     promptPtr = StringLoader::LoadL( aStringResID, aString );
     CleanupStack::PushL( promptPtr );
@@ -904,6 +934,7 @@
     TInt aStringResID,
     TInt aInt ) const
     {
+
     HBufC* promptPtr = NULL;
     promptPtr = StringLoader::LoadL( aStringResID, aInt );
     CleanupStack::PushL( promptPtr );
@@ -922,6 +953,7 @@
 //
 void CCertSaverModel::AddToMessageL( TDes& aMessage, TInt aStringResID ) const
     {
+
     HBufC* promptPtr = NULL;
     promptPtr = StringLoader::LoadL( aStringResID );
     CleanupStack::PushL( promptPtr );
@@ -940,6 +972,7 @@
 //
 void CCertSaverModel::ConstructMessageL( TDes& aMessage ) const
     {
+
     HBufC16* issuerName = NULL;
     HBufC16* subjectName = NULL;
 
@@ -996,6 +1029,7 @@
 //
 void CCertSaverModel::AddKeyUsageL( TDes& aMessage, const CX509Certificate& aCert ) const
     {
+
     TKeyUsageX509 x509Usage = EX509UsageNone;
     TKeyUsagePKCS15 pkcs15KeyUsage = EPKCS15UsageNone;
     const CX509CertExtension* ext = aCert.Extension( KKeyUsage );
@@ -1079,6 +1113,7 @@
 void CCertSaverModel::AddValidityPeriodL(
     TDes& aMessage, const CX509Certificate& aCert ) const
     {
+
     // Hometime's offset to UTC
     TLocale locale;
     TTimeIntervalSeconds offSet = locale.UniversalTimeOffset();
@@ -1108,7 +1143,7 @@
     // format the date to user readable format. The format is locale dependent
     finishValue.FormatL( finishString, *dateFormatString );
     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( finishString );
-    CleanupStack::PopAndDestroy(); // dateFormatString
+    CleanupStack::PopAndDestroy(dateFormatString); // dateFormatString
     aMessage.Append( finishString );
     AddNewlinesToMessage( aMessage );
     }
@@ -1120,6 +1155,7 @@
 //
 void CCertSaverModel::AddNewlinesToMessage( TDes& aMessage ) const
     {
+
     aMessage.Append( KDoubleEnter );
     }
 
@@ -1130,6 +1166,7 @@
 //
 TBool CCertSaverModel::CertificateSupported() const
     {
+
     if ( iCertFormat == EX509Certificate &&
        ( iCertOwnerType == ECACertificate ||
          iCertOwnerType == EPeerCertificate ||
@@ -1151,14 +1188,15 @@
 //
 TBool CCertSaverModel::CertificateOkL() const
     {
-    if ( !CertificateSupported() )
+
+    if ( !CertificateSupported() ) 
         {
-        ShowErrorNoteL( R_CERTSAVER_ERROR_UNSUPPORTED_CERT );
+        ShowErrorNoteL( R_CERTSAVER_ERROR_UNSUPPORTED_CERT   ); 
         return EFalse;
         }
     if ( CertNotValidAnymore() )
         {
-        ShowErrorNoteL( R_CERTSAVER_ERROR_CERT_NOT_VALID );
+        ShowErrorNoteL(R_CERTSAVER_ERROR_CERT_NOT_VALID);
         return ETrue;
         }
     else if ( CertNotValidYet() )
@@ -1175,6 +1213,7 @@
 //
 TBool CCertSaverModel::CertNotValidAnymore() const
     {
+
     TTime homeTime;
     homeTime.HomeTime();
     if ( iNewCert->ValidityPeriod().Finish() < homeTime )
@@ -1191,6 +1230,7 @@
 //
 TBool CCertSaverModel::CertNotValidYet() const
     {
+
     TTime homeTime;
     homeTime.HomeTime();
     if ( iNewCert->ValidityPeriod().Start() > homeTime )
@@ -1207,9 +1247,9 @@
 //
 void CCertSaverModel::ShowInformationNoteL( TInt aResourceID ) const
     {
+
     HBufC* buffer = iAppUi->CoeEnv()->AllocReadResourceLC( aResourceID );
-    CAknInformationNote* note = new (ELeave) CAknInformationNote( ETrue );
-    note->ExecuteLD( buffer->Des() );
+    CHbDeviceMessageBoxSymbian::InformationL(buffer->Des()); 
     CleanupStack::PopAndDestroy( buffer );
     }
 // ----------------------------------------------------------
@@ -1219,9 +1259,9 @@
 //
 void CCertSaverModel::ShowConfirmationNoteL( TInt aResourceID ) const
     {
+
     HBufC* buffer = iAppUi->CoeEnv()->AllocReadResourceLC( aResourceID );
-    CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote( ETrue );
-    note->ExecuteLD( buffer->Des() );
+    CHbDeviceMessageBoxSymbian::WarningL(buffer->Des()); 
     CleanupStack::PopAndDestroy( buffer );
     }
 
@@ -1232,9 +1272,10 @@
 //
 void CCertSaverModel::ShowErrorNoteL( TInt aResourceID ) const
     {
+
     HBufC* buffer = iAppUi->CoeEnv()->AllocReadResourceLC( aResourceID );
-    CAknErrorNote* note = new (ELeave) CAknErrorNote( ETrue );
-    note->ExecuteLD(buffer->Des());
+    //TODO: can be changed when hb supports ErrorL
+    CHbDeviceMessageBoxSymbian::WarningL(buffer->Des()); 
     CleanupStack::PopAndDestroy( buffer );
     }
 
@@ -1247,6 +1288,7 @@
 //
 TPtrC CCertSaverModel::TrimCertificateFields( TPtrC aField ) const
     {
+
     TPtrC cutField = CutCertificateField( aField );
     // Find one semicolon at a time and crop the
     // helpField from the left to search for the next semicolon
@@ -1298,6 +1340,7 @@
 //
 TPtrC CCertSaverModel::CutCertificateField( TPtrC aField ) const
     {
+
     TInt fieldLength = aField.Length();
     if ( fieldLength >= KMaxLengthTextCertIdentifierVisible )
         {
@@ -1314,10 +1357,8 @@
 //
 TInt CCertSaverModel::QueryTrusterUidsL( RArray<TUid>& aUids )
     {
+
     TInt ret = KErrCancel;
-    CArrayFixFlat<TInt>* selectionArray =
-        new (ELeave)  CArrayFixFlat<TInt>( KTrusterArrayInitSize );
-    CleanupStack::PushL( selectionArray );
     CDesCArray* itemsArray = new (ELeave) CDesCArrayFlat( KTrusterArrayInitSize );
     CleanupStack::PushL( itemsArray );
 
@@ -1330,18 +1371,38 @@
     CleanupClosePushL( appsInItemArray );
     UpdateTrustListboxItemL( apps, appsInItemArray, *itemsArray );
 
-    CAknListQueryDialog* dlg = new (ELeave) CAknListQueryDialog( selectionArray );
-    CleanupStack::PushL( dlg );
-    dlg->PrepareLC( R_CERTSAVER_TRUST_SETTINGS_QUERY );
-    dlg->SetItemTextArray( itemsArray );
-    dlg->SetOwnershipType( ELbmDoesNotOwnItemArray );
-    if ( dlg->RunLD() )
+    HBufC* title = CEikonEnv::Static()->AllocReadResourceLC( R_CERTSAVER_SELECT_TRUSTED_APPS);
+
+    RBuf rBuf;     // buffer for items with big enough space
+    rBuf.CreateL(KMaxLengthTextMeassageBody);
+    CleanupClosePushL(rBuf);
+    for(TInt i = 0; i<itemsArray->Count(); i++) 
+        rBuf.Append( (*itemsArray)[i] ); 
+
+    CSecQueryUi* SecQueryUi = CSecQueryUi::NewL();     
+    TInt saved = SecQueryUi->SecQueryDialog(*title, rBuf,1,KTokenLength,              
+                                             ESecUiAlphaSupported | ESecUiCancelSupported |
+                                             ESecUiBasicTypeMultiCheck |
+                                             ESecUiEmergencyNotSupported);   
+    delete SecQueryUi;
+    SecQueryUi=NULL;
+
+    if (saved==KErrNone)
         {
-        for ( TInt i = 0; i < selectionArray->Count(); ++i )
-            {
-            TInt ii = (*selectionArray)[ i ];
-            aUids.Append( appsInItemArray[ ii ].Id() );
-            }
+        TLex16 lex(rBuf);
+        TChar ch;                                        
+        TBuf16<KTokenLength> token;          
+        TInt  val;
+        while((ch = lex.Get()) != 0 ){                   
+           while ((ch = lex.Peek()) != '|' && ch!=0) lex.Inc();
+           token.Copy(lex.MarkedToken());                
+           TLex lexc(token);
+           if(lexc.Val(val)!=KErrNone) val=0;
+           if(val<=appsInItemArray.Count()-1)
+               aUids.Append( appsInItemArray[ val ].Id() );
+           lex.Inc();                                    
+           lex.Mark();                                   
+         }  
         ret = KErrNone;
         }
     else
@@ -1349,8 +1410,13 @@
         ShowConfirmationNoteL( R_CERTSAVER_CERT_DISCARDED );
         ret = KErrCancel;
         }
-    CleanupStack::Pop( dlg );
-    CleanupStack::PopAndDestroy( 4, selectionArray );
+
+    rBuf.Close();
+    CleanupStack::PopAndDestroy(&rBuf);
+    CleanupStack::PopAndDestroy(title);
+    CleanupStack::PopAndDestroy(&appsInItemArray);
+    CleanupStack::PopAndDestroy(appInfoManager);
+    CleanupStack::PopAndDestroy(itemsArray);
     return ret;
     }
 
@@ -1361,6 +1427,7 @@
 //
 TInt CCertSaverModel::QueryTrustedSiteL()
     {
+
     TInt ret = KErrCancel;
     HBufC* label = NULL;
     HBufC* secondaryName = NULL;
@@ -1372,16 +1439,10 @@
     delete secondaryName;
     secondaryName = NULL;
     labelBuf = label->Des().Left( CERTSAVER_MAX_LABEL_LEN );
-
-
     HBufC* prompt = StringLoader::LoadLC( R_CERTSAVER_TRUSTEDSITE_WARNING, labelBuf );
-
-    CAknMessageQueryDialog* note = CAknMessageQueryDialog::NewL( *prompt );
-
-    note->PrepareLC( R_CERTSAVER_TRUSTED_SITE_QUERY );
-    note->SetPromptL( *prompt );
-
-    if ( note->RunLD() )
+    CHbDeviceMessageBoxSymbian::TButtonId selection =
+        CHbDeviceMessageBoxSymbian::QuestionL(prompt->Des(), KNullDesC, KNullDesC);
+    if ( selection == CHbDeviceMessageBoxSymbian::EAcceptButton)
         {
         ret = KErrNone;
         }
@@ -1390,9 +1451,7 @@
         ShowConfirmationNoteL( R_CERTSAVER_CERT_DISCARDED );
         ret = KErrCancel;
         }
-
     CleanupStack::PopAndDestroy( prompt );
-
     CleanupStack::PopAndDestroy( label );
     return ret;
     }
@@ -1407,6 +1466,7 @@
     RArray<TCertificateAppInfo>& aAppsInItemArray,
     CDesCArray& aItemsArray ) const
   {
+
     for ( TInt i = 0; i < aApps.Count(); i++ )
         {
         TCertificateAppInfo appInfo = aApps[ i ];
@@ -1469,6 +1529,7 @@
 //
 void CCertSaverModel::DivideToBlocks( const TDesC8& aInput, TDes& aOutput ) const
     {
+
     _LIT( KBlockSeparator, " " );
     const TInt KBlockLength = 2;
     TInt blockIndex = 0;
@@ -1491,17 +1552,27 @@
 //
 void CCertSaverModel::SavePKCS12L()
     {
+
     HBufC* message = HBufC::NewLC( KMaxLengthTextMeassageBody );
     TPtr msgPtr = message->Des();
     ConstructPKCS12QueryMsgL(msgPtr, iParser.Keys().Count(),
                             iParser.UserCertificates().Count(),
                             iParser.CACertificates().Count() );
-    TBool save = DoMessageQueryL(
-        R_MESSAGE_QUERY_DOSAVE, R_CERTSAVER_HEADER_PKCS12_FILE_CONTAINS,
-        *message );
-    CleanupStack::PopAndDestroy( message );
+
+    //TODO: Should be in loc file but hardcoded now
+    _LIT(KCheckBoxCaption,"Protect with Password|1");
+    TBuf<KMaxLengthTextCheckBoxData> CheckeBoxData(KCheckBoxCaption);
+
+    CSecQueryUi* SecQueryUi = CSecQueryUi::NewL();    
+    TInt save = SecQueryUi->SecQueryDialog(*message, CheckeBoxData,1,1,
+                                            ESecUiAlphaSupported | ESecUiCancelSupported |
+                                            ESecUiBasicTypeCheck | ESecUiEmergencyNotSupported);
+    CleanupStack::Pop(message);
     message = NULL;
-    if ( !save )
+    delete SecQueryUi;
+    SecQueryUi=NULL;
+
+    if ( save!=KErrNone )
         {
         ShowInformationNoteL( R_CERTSAVER_PKCS12_DISCARDED );
         User::Leave( KErrExitApp );
@@ -1545,42 +1616,24 @@
     if ( iSavedCACertsCount != 0 || iSavedKeysCount != 0
         || iSavedUserCertsCount != 0 )
         {
+        HBufC* p = StringLoader::LoadLC( R_CERTSAVER_HEADER_SAVED );
         message = HBufC::NewLC( KMaxLengthTextMeassageBody );
+        message->Des().Append(p->Des());   
         TPtr msgPtr2 = message->Des();
         ConstructPKCS12QueryMsgL(
             msgPtr2, iSavedKeysCount, iSavedUserCertsCount, iSavedCACertsCount );
-        DoMessageQueryL(
-            R_MESSAGE_QUERY_SAVED, R_CERTSAVER_HEADER_SAVED, *message );
+        CHbDeviceMessageBoxSymbian::InformationL(message->Des()); 
         CleanupStack::PopAndDestroy( message );
+        CleanupStack::PopAndDestroy( p );       
         }
     else
         {
         ShowInformationNoteL( R_QTN_CM_PKCS12_SAVING_FAILED );
+        CleanupStack::PopAndDestroy( message );
         }
     }
 
 // ----------------------------------------------------------
-// CCertSaverModel::DoMessageQuery()
-// Displays message query dialog for user.
-// ----------------------------------------------------------
-//
-TBool CCertSaverModel::DoMessageQueryL(
-    TInt aDialogResId,
-    TInt aHeadingResId,
-    TDesC& aMessage )
-    {
-    CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( aMessage );
-    CleanupStack::PushL( dlg );
-    dlg->PrepareLC( aDialogResId );
-
-    HBufC* header = StringLoader::LoadLC( aHeadingResId );
-    dlg->QueryHeading()->SetTextL( header->Des() );
-    CleanupStack::PopAndDestroy( header );
-    CleanupStack::Pop( dlg );
-    return dlg->RunLD();
-    }
-
-// ----------------------------------------------------------
 // CCertSaverModel::ConstructPKCS12QueryMsgL() const
 // Creates the certificate details message shown to the user.
 // ----------------------------------------------------------
@@ -1591,6 +1644,7 @@
     TInt aUserCerts,
     TInt aCACerts ) const
     {
+
     if ( aPrivateKeys > 0 )
         {
         if ( aPrivateKeys == 1 )
--- a/pkiutilities/CertSaver/src/certparser.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/CertSaver/src/certparser.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -25,14 +25,17 @@
 #include <X509CertNameParser.h>
 #include <featmgr.h>
 #include <data_caging_path_literals.hrh>
-#include <AknQueryDialog.h>
 #include <CertSaver.rsg>
 #include <StringLoader.h>
 #include <securityerr.h>
-#include <aknnotewrappers.h>              // Note dialogs
+#include <aknnotewrappers.h>              // Note dialogs text, TODO: could be removed after localization is ready
 #include <apmrec.h>
 #include "certparser.h"
 
+#include "SecQueryUi.h"                   // needed for password dialog
+
+#include <hbdevicemessageboxsymbian.h>    // needed for Note dialogs    
+
 // CONSTANTS
 _LIT( KPKCS12DllName, "crpkcs12.dll" );   // PKCS12 DLL name
 const TInt KX509Version3 = 3;
@@ -94,6 +97,7 @@
 //
 void CCertParser::SetContentL( RFile& aFile )
     {
+
     delete iCert;
     iCert = NULL;
     TInt fileSize = 0;
@@ -126,7 +130,8 @@
 //
 void CCertParser::CreatePKCS12L()
     {
-    // Load PKCS#12 dll
+
+        // Load PKCS#12 dll
 #ifdef __WINS__
     User::LeaveIfError ( iLibrary.Load( KPKCS12DllName ) );
 #else
@@ -151,6 +156,7 @@
     const TDesC8& aPKCS12,
     const TDesC& aFileName )
     {
+
     CreatePKCS12L();
 
     if ( !iPKCS12->IsPKCS12Data( aPKCS12 ) )
@@ -173,8 +179,7 @@
         if ( !GetPasswordL( password, aFileName ) )
             {
             buffer = iEikEnv->AllocReadResourceLC( R_CERTSAVER_PKCS12_DISCARDED );
-            CAknInformationNote* note = new (ELeave) CAknInformationNote( ETrue );
-            note->ExecuteLD(buffer->Des());
+            CHbDeviceMessageBoxSymbian::InformationL(buffer->Des()); 
             CleanupStack::PopAndDestroy( buffer );
             User::Leave( KErrExitApp );
             }
@@ -226,15 +231,19 @@
 //
 TInt CCertParser::GetPasswordL( TDes& aPassword, const TDesC& aFileName )
     {
-    CAknTextQueryDialog* query = CAknTextQueryDialog::NewL( aPassword );
-    CleanupStack::PushL( query );
-    HBufC* prompt =
-        StringLoader::LoadLC( R_QTN_CM_TITLE_P12_PASSWORD, aFileName );
-    query->SetPromptL( *prompt );
-    CleanupStack::PopAndDestroy( prompt );
-    CleanupStack::Pop( query );
-    return query->ExecuteLD( R_PKCS12_PW_QUERY_DIALOG );
-    }
+    CSecQueryUi* SecQueryUi = CSecQueryUi::NewL();                                       
+    HBufC* prompt =StringLoader::LoadLC( R_QTN_CM_TITLE_P12_PASSWORD, aFileName );        
+    TInt queryAccepted = SecQueryUi->SecQueryDialog(prompt->Des(), aPassword,                
+                                                1,KPwMaxLength,                               
+                                                ESecUiAlphaSupported |                        
+                                                ESecUiCancelSupported |                       
+                                                ESecUiSecretSupported |                
+                                                ESecUiEmergencyNotSupported); 
+    CleanupStack::PopAndDestroy( prompt );                                                
+    delete SecQueryUi;                                                                   
+    SecQueryUi=NULL;
+    return (queryAccepted==KErrNone);
+  }
 
 // ----------------------------------------------------------
 // CCertParser::CheckIfX509CertificateL()
@@ -243,6 +252,7 @@
 //
 TBool CCertParser::CheckIfX509CertificateL(const TDesC8& aCert)
     {
+
     TRAPD( err,
            iCert = CX509Certificate::NewL(aCert);
          );
@@ -302,6 +312,7 @@
 //
 const CArrayPtr<CX509Certificate>&  CCertParser::CACertificates() const
     {
+
     __ASSERT_ALWAYS( iPKCS12, User::Panic( KCertSaverPanic, KPanicNullPointer ) );
     return iPKCS12->CACertificates();
     }
@@ -312,6 +323,7 @@
 //
 const CArrayPtr<CX509Certificate>&  CCertParser::UserCertificates() const
     {
+
     __ASSERT_ALWAYS( iPKCS12, User::Panic( KCertSaverPanic, KPanicNullPointer ) );
     return iPKCS12->UserCertificates();
     }
@@ -322,6 +334,7 @@
 //
 const CArrayPtr<HBufC8>& CCertParser::Keys() const
     {
+
     __ASSERT_ALWAYS( iPKCS12, User::Panic( KCertSaverPanic, KPanicNullPointer ) );
     return iPKCS12->PrivateKeys();
     }
@@ -332,6 +345,7 @@
 //
  CCertParser::TCertType CCertParser::CertType() const
     {
+
     return iCertType;
     }
 
@@ -342,6 +356,7 @@
 //
 const TPtrC8 CCertParser::CertificateBuf() const
     {
+
     __ASSERT_ALWAYS( iCert, User::Panic( KCertSaverPanic, KPanicNullPointer ) );
     return iCert->Encoding();
     }
@@ -353,6 +368,7 @@
 //
 const CX509Certificate& CCertParser::Certificate() const
     {
+
     __ASSERT_ALWAYS( iCert, User::Panic( KCertSaverPanic, KPanicNullPointer ) );
     return *((CX509Certificate*)iCert);
     }
@@ -369,8 +385,7 @@
         iEikEnv = CEikonEnv::Static();
         }
     HBufC* buffer = iEikEnv->AllocReadResourceLC( aResourceID );
-    CAknErrorNote* note = new (ELeave) CAknErrorNote( ETrue );
-    note->ExecuteLD(buffer->Des());
+    CHbDeviceMessageBoxSymbian::WarningL(buffer->Des()); 
     CleanupStack::PopAndDestroy( buffer );
     }
 
--- a/pkiutilities/untrustedcertificatedialog/inc/untrustedcertificatedialog.h	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/untrustedcertificatedialog/inc/untrustedcertificatedialog.h	Wed Jun 23 19:10:54 2010 +0300
@@ -59,19 +59,22 @@
     bool constructDialog(const QVariantMap &parameters);
     bool updateFromParameters(const QVariantMap &parameters);
     void sendResult(int result);
+    void confirmPermanentAccept();
 
 private slots:  // new slots
     void handleAccepted();
     void handleRejected();
+    void handlePermanentAcceptance();
 
 private:    // new functions
     Q_DISABLE_COPY(UntrustedCertificateDialog)
 
 private:    // data
     int mLastError;
-    bool mShowEventReceived;
     UntrustedCertificateWidget *mContent;
     QVariantMap mResultMap;
+    bool mShowEventReceived;
+    HbAction *mOkAction;
 };
 
 #endif // UNTRUSTEDCERTIFICATEDIALOG_H
--- a/pkiutilities/untrustedcertificatedialog/inc/untrustedcertificateinfo_symbian.h	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/untrustedcertificatedialog/inc/untrustedcertificateinfo_symbian.h	Wed Jun 23 19:10:54 2010 +0300
@@ -30,20 +30,21 @@
 class UntrustedCertificateInfoSymbian : public UntrustedCertificateInfoBase
 {
 public:     // constructor and destructor
-    UntrustedCertificateInfoSymbian(const CX509Certificate& aCert);
+    UntrustedCertificateInfoSymbian(const QByteArray &aEncodedCert);
     ~UntrustedCertificateInfoSymbian();
 
 public:     // from UntrustedCertificateInfoBase
     bool commonNameMatches(const QString &siteName) const;
-    bool isPermanentAcceptAllowed() const;
-    QString certificateDetails() const;
+    QString certificateDetails(const QString &siteName) const;
 
 private:    // new functions
-    void ConstructL(const CX509Certificate& aCert);
+    void ConstructL(const QByteArray &aEncodedCert);
     bool CommonNameMatchesL(const QString &siteName) const;
+    QByteArray Md5FingerprintL( const TDesC8& aEncodedCert ) const;
 
 private:    // data
-    CX509Certificate* iCert;
+    CX509Certificate* mCert;
+    QByteArray mMd5Fingerprint;
 };
 
 #endif // UNTRUSTEDCERTIFICATEINFOSYMBIAN_H
--- a/pkiutilities/untrustedcertificatedialog/inc/untrustedcertificateinfobase.h	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/untrustedcertificatedialog/inc/untrustedcertificateinfobase.h	Wed Jun 23 19:10:54 2010 +0300
@@ -61,21 +61,20 @@
     virtual const QString subjectName() const;
     virtual const QString issuerName() const;
     virtual const QByteArray fingerprint() const;
-    virtual const QString formattedFingerprint() const;
     virtual const QByteArray serialNumber() const;
-    virtual const QString formattedSerialNumber() const;
     virtual const QDateTime validFrom() const;
     virtual const QDateTime validTo() const;
     virtual const QString format() const;
     virtual const QString digestAlgorithm() const;
     virtual const QString asymmetricAlgorithm() const;
     virtual const QString combinedAlgorithmName() const;
+    virtual const QString formattedFingerprint(const QByteArray &fingerprint) const;
+    virtual const QString formattedSerialNumber(const QByteArray &serialNumber) const;
     virtual bool isDateValid() const;
 
 public:     // new abstract functions
     virtual bool commonNameMatches(const QString &siteName) const = 0;
-    virtual bool isPermanentAcceptAllowed() const = 0;
-    virtual QString certificateDetails() const = 0;
+    virtual QString certificateDetails(const QString &siteName) const = 0;
 
 private:    // new functions
     const QString algorithmName(Algorithm algorithm) const;
--- a/pkiutilities/untrustedcertificatedialog/inc/untrustedcertificatewidget.h	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/untrustedcertificatedialog/inc/untrustedcertificatewidget.h	Wed Jun 23 19:10:54 2010 +0300
@@ -44,7 +44,9 @@
 
     void constructFromParameters(const QVariantMap &parameters);
     void updateFromParameters(const QVariantMap &parameters);
+    bool isPermanentAcceptAllowed() const;
     bool isPermanentAcceptChecked() const;
+    QString serverName() const;
 
 public:     // new platform specific functions
     bool isCertificateValid();
--- a/pkiutilities/untrustedcertificatedialog/src/untrustedcertificatedialog.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/untrustedcertificatedialog/src/untrustedcertificatedialog.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -21,17 +21,30 @@
 #include "untrustedcertificatewidget.h"
 #include <hblabel.h>
 #include <hbaction.h>
+#include <hbmessagebox.h>
+#include <QGraphicsLinearLayout>
 
 const int KNoError = 0;             // KErrNone
 const int KParameterError = -6;     // KErrArgument
 
+// TODO: replace with OST tracing
+#ifdef _DEBUG
+#include <QDebug>
+#define TRACE(x)        qDebug() << x
+#define TRACE1(x,y)     qDebug() << x << y
+#else
+#define TRACE(x)
+#define TRACE1(x,y)
+#endif
+
 
 // ----------------------------------------------------------------------------
 // UntrustedCertificateDialog::UntrustedCertificateDialog()
 // ----------------------------------------------------------------------------
 //
-UntrustedCertificateDialog::UntrustedCertificateDialog(const QVariantMap &parameters) : HbDialog(),
-    mLastError(KNoError), mShowEventReceived(false), mContent(0)
+UntrustedCertificateDialog::UntrustedCertificateDialog(const QVariantMap &parameters) :
+    HbDialog(), mLastError(KNoError), mContent(0), mResultMap(),
+    mShowEventReceived(false), mOkAction(0)
 {
     constructDialog(parameters);
 }
@@ -69,6 +82,7 @@
 void UntrustedCertificateDialog::closeDeviceDialog(bool byClient)
 {
     Q_UNUSED(byClient);
+    TRACE("UntrustedCertificateDialog::closeDeviceDialog");
     close();
 
     // If show event has been received, close is signalled from hide event.
@@ -93,6 +107,7 @@
 //
 void UntrustedCertificateDialog::hideEvent(QHideEvent *event)
 {
+    TRACE("UntrustedCertificateDialog::hideEvent");
     HbDialog::hideEvent(event);
     emit deviceDialogClosed();
 }
@@ -103,6 +118,7 @@
 //
 void UntrustedCertificateDialog::showEvent(QShowEvent *event)
 {
+    TRACE("UntrustedCertificateDialog::showEvent");
     HbDialog::showEvent(event);
     mShowEventReceived = true;
 }
@@ -128,6 +144,7 @@
 //
 bool UntrustedCertificateDialog::constructDialog(const QVariantMap &parameters)
 {
+    TRACE("UntrustedCertificateDialog::constructDialog");
     if (!isParametersValid(parameters)) {
         return false;
     }
@@ -152,17 +169,20 @@
     setContentWidget(mContent);
 
     if (mContent->isCertificateValid()) {
-        HbAction *okAction = new HbAction(qtTrId("txt_common_button_ok"), this);
-        connect(okAction, SIGNAL(triggered()), this, SLOT(handleAccepted()));
-        addAction(okAction);
+        mOkAction = new HbAction(qtTrId("txt_common_button_ok"), this);
+        addAction(mOkAction);
+        disconnect(mOkAction, SIGNAL(triggered()), this, SLOT(close()));
+        connect(mOkAction, SIGNAL(triggered()), this, SLOT(handleAccepted()));
 
         HbAction *cancelAction = new HbAction(qtTrId("txt_common_button_cancel"), this);
+        addAction(cancelAction);
+        disconnect(cancelAction, SIGNAL(triggered()), this, SLOT(close()));
         connect(cancelAction, SIGNAL(triggered()), this, SLOT(handleRejected()));
-        addAction(cancelAction);
     } else {
         HbAction *closeAction = new HbAction(qtTrId("txt_common_button_close"), this);
+        addAction(closeAction);
+        disconnect(closeAction, SIGNAL(triggered()), this, SLOT(close()));
         connect(closeAction, SIGNAL(triggered()), this, SLOT(handleRejected()));
-        addAction(closeAction);
     }
 
     return true;
@@ -174,6 +194,7 @@
 //
 bool UntrustedCertificateDialog::updateFromParameters(const QVariantMap &parameters)
 {
+    TRACE("UntrustedCertificateDialog::updateFromParameters");
     if (!isParametersValid(parameters)) {
         return false;
     }
@@ -189,21 +210,63 @@
 //
 void UntrustedCertificateDialog::sendResult(int result)
 {
+    TRACE1("UntrustedCertificateDialog::sendResult", result);
     QVariant resultValue(result);
     mResultMap.insert(KUntrustedCertificateDialogResult, resultValue);
     emit deviceDialogData(mResultMap);
 }
 
 // ----------------------------------------------------------------------------
+// UntrustedCertificateDialog::confirmPermanentAccept()
+// ----------------------------------------------------------------------------
+//
+void UntrustedCertificateDialog::confirmPermanentAccept()
+{
+    TRACE("UntrustedCertificateDialog::confirmPermanentAccept");
+
+    HbDialog *dialog = new HbDialog();
+    dialog->setAttribute(Qt::WA_DeleteOnClose, true);
+    dialog->setTimeout(HbPopup::NoTimeout);
+    dialog->setDismissPolicy(HbDialog::NoDismiss);
+    dialog->setModal(true);
+
+    // TODO: localised UI string needed
+    QString questionTitle = tr("Certificate access");
+    dialog->setHeadingWidget(new HbLabel(questionTitle));
+
+    HbWidget *widget = new HbWidget();
+    QGraphicsLinearLayout* layout = new QGraphicsLinearLayout();
+    // TODO: localized UI string needed
+    QString questionText =
+        tr("Connections to '%1' will be made without warnings. Continue?")
+        .arg(mContent->serverName());
+    HbLabel *textLabel = new HbLabel(questionText);
+    textLabel->setTextWrapping(Hb::TextWordWrap);
+    layout->addItem(textLabel);
+    widget->setLayout(layout);
+    dialog->setContentWidget(widget);
+
+    HbAction *yesAction = new HbAction(hbTrId("txt_common_button_yes"));
+    dialog->addAction(yesAction);
+    disconnect(yesAction, SIGNAL(triggered()), this, SLOT(close()));
+    connect(yesAction, SIGNAL(triggered()), this, SLOT(handlePermanentAcceptance()));
+    dialog->addAction(new HbAction(hbTrId("txt_common_button_no")));
+
+    dialog->show();
+}
+
+// ----------------------------------------------------------------------------
 // UntrustedCertificateDialog::handleAccepted()
 // ----------------------------------------------------------------------------
 //
 void UntrustedCertificateDialog::handleAccepted()
 {
+    TRACE("UntrustedCertificateDialog::handleAccepted");
     if (mContent->isPermanentAcceptChecked()) {
-        sendResult(KDialogAcceptedPermanently);
+        confirmPermanentAccept();
     } else {
         sendResult(KDialogAccepted);
+		close();
     }
 }
 
@@ -213,6 +276,19 @@
 //
 void UntrustedCertificateDialog::handleRejected()
 {
+    TRACE("UntrustedCertificateDialog::handleRejected");
     sendResult(KDialogRejected);
+    close();
 }
 
+// ----------------------------------------------------------------------------
+// UntrustedCertificateDialog::handlePermanentAcceptance()
+// ----------------------------------------------------------------------------
+//
+void UntrustedCertificateDialog::handlePermanentAcceptance()
+{
+    TRACE("UntrustedCertificateDialog::handlePermanentAcceptance");
+    sendResult(KDialogAcceptedPermanently);
+    close();
+}
+
--- a/pkiutilities/untrustedcertificatedialog/src/untrustedcertificateinfo_symbian.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/untrustedcertificatedialog/src/untrustedcertificateinfo_symbian.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -18,7 +18,8 @@
 #include "untrustedcertificateinfo_symbian.h"
 #include <signed.h>                             // TAlgorithmId
 #include <x509cert.h>                           // CX509Certificate
-#include <QTextStream>
+#include <X509CertNameParser.h>                 // X509CertNameParser
+#include <hash.h>                               // CMD5
 
 
 // ======== LOCAL FUNCTIONS ========
@@ -72,17 +73,14 @@
 // convertDateTime()
 // ----------------------------------------------------------------------------
 //
-QDateTime convertDateTime(const TTime& aTime)
+void convertDateTime(const TTime& aFromTime, QDateTime& aToDateTime)
 {
-    const TDateTime &symbianDateTime = aTime.DateTime();
+    const TDateTime &symbianDateTime = aFromTime.DateTime();
 
-    QDateTime dateTime;
     QDate date(symbianDateTime.Year(), symbianDateTime.Month()+1, symbianDateTime.Day()+1);
     QTime time(symbianDateTime.Hour(), symbianDateTime.Minute(), symbianDateTime.Second());
-    dateTime.setDate(date);
-    dateTime.setTime(time);
-
-    return dateTime;
+    aToDateTime.setDate(date);
+    aToDateTime.setTime(time);
 }
 
 
@@ -93,9 +91,10 @@
 // ----------------------------------------------------------------------------
 //
 UntrustedCertificateInfoSymbian::UntrustedCertificateInfoSymbian(
-    const CX509Certificate& aCert) : UntrustedCertificateInfoBase(), iCert(0)
+    const QByteArray &aEncodedCert) : UntrustedCertificateInfoBase(),
+    mCert(0), mMd5Fingerprint()
 {
-    QT_TRAP_THROWING(ConstructL(aCert));
+    QT_TRAP_THROWING(ConstructL(aEncodedCert));
 }
 
 // ----------------------------------------------------------------------------
@@ -104,7 +103,7 @@
 //
 UntrustedCertificateInfoSymbian::~UntrustedCertificateInfoSymbian()
 {
-    delete iCert;
+    delete mCert;
 }
 
 // ----------------------------------------------------------------------------
@@ -119,39 +118,26 @@
 }
 
 // ----------------------------------------------------------------------------
-// UntrustedCertificateInfoSymbian::isPermanentAcceptAllowed()
-// ----------------------------------------------------------------------------
-//
-bool UntrustedCertificateInfoSymbian::isPermanentAcceptAllowed() const
-{
-    return isDateValid();
-}
-
-// ----------------------------------------------------------------------------
 // UntrustedCertificateInfoSymbian::certificateDetails()
 // ----------------------------------------------------------------------------
 //
-QString UntrustedCertificateInfoSymbian::certificateDetails() const
+QString UntrustedCertificateInfoSymbian::certificateDetails(const QString &siteName) const
 {
-    QString details;
-    QTextStream stream(&details);
-    // TODO: localised UI strings needed
-    stream << tr("Issuer:\n%1\n").arg(issuerName());
-    stream << endl;
-    stream << tr("Subject:\n%1\n").arg(subjectName());
-    stream << endl;
-    stream << tr("Valid from:\n%1\n").arg(validFrom().toString());
-    stream << endl;
-    stream << tr("Valid until:\n%1\n").arg(validTo().toString());
-    stream << endl;
-    stream << tr("Certificate format:\n%1\n").arg(format());
-    stream << endl;
-    stream << tr("Algorithm:\n%1\n").arg(combinedAlgorithmName());
-    stream << endl;
-    stream << tr("Serial number:\n%1\n").arg(formattedSerialNumber());
-    stream << endl;
-    stream << tr("Fingerprint (SHA1):\n%1\n").arg(formattedFingerprint());
-    // TODO: MD5 fingerprint missing
+    // TODO: localized UI string needed
+    QString details = tr("Service:\n%1\n\nIssuer:\n%2\n\nSubject:\n%3\n\n"
+        "Valid from:\n%4\n\nValid until:\n%5\n\nCertificate format:\n%6\n\n"
+        "Algorithm:\n%7\n\nSerial number:\n%8\n\n"
+        "Fingerprint (SHA1):\n%9\n\nFingerprint (MD5):\n%10")
+        .arg(siteName)                                  // %1
+        .arg(issuerName())                              // %2
+        .arg(subjectName())                             // %3
+        .arg(validFrom().toString())                    // %4
+        .arg(validTo().toString())                      // %5
+        .arg(format())                                  // %6
+        .arg(combinedAlgorithmName())                   // %7
+        .arg(formattedSerialNumber(serialNumber()))     // %8
+        .arg(formattedFingerprint(fingerprint()))       // %9
+        .arg(formattedFingerprint(mMd5Fingerprint));    // %10
     return details;
 }
 
@@ -159,34 +145,45 @@
 // UntrustedCertificateInfoSymbian::ConstructL()
 // ----------------------------------------------------------------------------
 //
-void UntrustedCertificateInfoSymbian::ConstructL(const CX509Certificate& aCert)
+void UntrustedCertificateInfoSymbian::ConstructL(const QByteArray &aEncodedCert)
 {
-    ASSERT( iCert == 0 );
-    iCert = CX509Certificate::NewL( aCert );
+    TPtrC8 encodedCert( reinterpret_cast<const TText8*>( aEncodedCert.constData() ),
+        aEncodedCert.length() );
+
+    ASSERT( mCert == 0 );
+    mCert = CX509Certificate::NewL( encodedCert );
 
-    HBufC16* subjectBuf = iCert->SubjectL();
-    mSubjectName = QString::fromUtf16(subjectBuf->Ptr(), subjectBuf->Length());
-    delete subjectBuf;
+    HBufC16* subjectBuf = NULL;
+    X509CertNameParser::SubjectFullNameL( *mCert, subjectBuf );
+    CleanupStack::PushL( subjectBuf );
+    QT_TRYCATCH_LEAVING( mSubjectName =
+        QString::fromUtf16(subjectBuf->Ptr(), subjectBuf->Length()) );
+    CleanupStack::PopAndDestroy( subjectBuf );
 
-    HBufC16* issuerBuf = iCert->IssuerL();
-    mIssuerName = QString::fromUtf16(issuerBuf->Ptr(), issuerBuf->Length());
-    delete issuerBuf;
-
-    TPtrC8 fingerprint = iCert->Fingerprint();
-    mFingerprint = QByteArray::fromRawData(
-        reinterpret_cast<const char*>(fingerprint.Ptr()), fingerprint.Length());
+    HBufC16* issuerBuf = NULL;
+    X509CertNameParser::IssuerFullNameL( *mCert, issuerBuf );
+    CleanupStack::PushL( issuerBuf );
+    QT_TRYCATCH_LEAVING( mIssuerName =
+        QString::fromUtf16(issuerBuf->Ptr(), issuerBuf->Length()));
+    CleanupStack::PopAndDestroy( issuerBuf );
 
-    TPtrC8 serialNumber = iCert->SerialNumber();
-    mSerialNumber = QByteArray::fromRawData(
-        reinterpret_cast<const char*>(serialNumber.Ptr()), serialNumber.Length());
+    TPtrC8 fingerprint = mCert->Fingerprint();
+    QT_TRYCATCH_LEAVING( mFingerprint = QByteArray::fromRawData(
+        reinterpret_cast<const char*>(fingerprint.Ptr()), fingerprint.Length()) );
+
+    mMd5Fingerprint = Md5FingerprintL( mCert->Encoding() );
 
-    const CValidityPeriod& validityPeriod = iCert->ValidityPeriod();
-    mValidFrom = convertDateTime(validityPeriod.Start());
-    mValidTo = convertDateTime(validityPeriod.Finish());
+    TPtrC8 serialNumber = mCert->SerialNumber();
+    QT_TRYCATCH_LEAVING( mSerialNumber = QByteArray::fromRawData(
+        reinterpret_cast<const char*>(serialNumber.Ptr()), serialNumber.Length()) );
+
+    const CValidityPeriod& validityPeriod = mCert->ValidityPeriod();
+    convertDateTime(validityPeriod.Start(), mValidFrom);
+    convertDateTime(validityPeriod.Finish(), mValidTo);
 
     mFormat = X509Certificate;
 
-    const CSigningAlgorithmIdentifier& alg = iCert->SigningAlgorithm();
+    const CSigningAlgorithmIdentifier& alg = mCert->SigningAlgorithm();
     mDigestAlgorithm = mapAlgorithm(alg.DigestAlgorithm().Algorithm());
     mAsymmetricAlgorithm = mapAlgorithm(alg.AsymmetricAlgorithm().Algorithm());
 }
@@ -198,7 +195,7 @@
 bool UntrustedCertificateInfoSymbian::CommonNameMatchesL(const QString &siteName) const
 {
     bool matches = false;
-    const CX500DistinguishedName& distinguishedName = iCert->SubjectName();
+    const CX500DistinguishedName& distinguishedName = mCert->SubjectName();
     HBufC* commonNameSymbian = distinguishedName.ExtractFieldL( KX520CommonName );
     if (commonNameSymbian) {
         CleanupStack::PushL(commonNameSymbian);
@@ -211,3 +208,20 @@
     return matches;
 }
 
+// ----------------------------------------------------------------------------
+// UntrustedCertificateInfoSymbian::Md5FingerprintL()
+// ----------------------------------------------------------------------------
+//
+QByteArray UntrustedCertificateInfoSymbian::Md5FingerprintL( const TDesC8& aEncodedCert ) const
+{
+    CMD5* md5 = CMD5::NewL();
+    CleanupStack::PushL( md5 );
+
+    const TPtrC8 fingerprintSymbian = md5->Hash( aEncodedCert );
+    QByteArray fingerprint( reinterpret_cast<const char*>( fingerprintSymbian.Ptr() ),
+        fingerprintSymbian.Length() );
+
+    CleanupStack::PopAndDestroy( md5 );
+    return fingerprint;
+}
+
--- a/pkiutilities/untrustedcertificatedialog/src/untrustedcertificateinfobase.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/untrustedcertificatedialog/src/untrustedcertificateinfobase.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -71,32 +71,6 @@
 }
 
 // ----------------------------------------------------------------------------
-// UntrustedCertificateInfoBase::formattedFingerprint()
-// ----------------------------------------------------------------------------
-//
-const QString UntrustedCertificateInfoBase::formattedFingerprint() const
-{
-    QString formatted;
-    QByteArray fp = fingerprint();
-
-    QString number;
-    int blockIndex = 0;
-    int count = fp.count();
-    for (int index = 0; index < count; ++index) {
-        if (blockIndex == KCharsPerBlock) {
-            formatted.append(KBlockSeparator);
-            blockIndex = 0;
-        }
-        number.sprintf(KHexNumberFormatTwoDigitsWithLeadingZeroes,
-            static_cast<unsigned char>(fp.at(index)));
-        formatted.append(number);
-        ++blockIndex;
-    }
-
-    return formatted;
-}
-
-// ----------------------------------------------------------------------------
 // UntrustedCertificateInfoBase::serialNumber()
 // ----------------------------------------------------------------------------
 //
@@ -106,26 +80,6 @@
 }
 
 // ----------------------------------------------------------------------------
-// UntrustedCertificateInfoBase::formattedSerialNumber()
-// ----------------------------------------------------------------------------
-//
-const QString UntrustedCertificateInfoBase::formattedSerialNumber() const
-{
-    QString formatted;
-    QByteArray sn = serialNumber();
-
-    QString number;
-    int count = sn.count();
-    for (int index = 0; index < count; ++index) {
-        number.sprintf(KHexNumberFormatSimple,
-            static_cast<unsigned char>(sn.at(index)));
-        formatted.append(number);
-    }
-
-    return formatted;
-}
-
-// ----------------------------------------------------------------------------
 // UntrustedCertificateInfoBase::validFrom()
 // ----------------------------------------------------------------------------
 //
@@ -154,7 +108,7 @@
         case X509Certificate:
             //: Type name for X509 certificates displayed in certificate details.
             // TODO: localised UI string
-            format = tr("X509");
+            format = tr("X.509");
             break;
         default:
             //: Type name for unknown certificates displayed in certificate details.
@@ -201,6 +155,52 @@
 }
 
 // ----------------------------------------------------------------------------
+// UntrustedCertificateInfoBase::formattedFingerprint()
+// ----------------------------------------------------------------------------
+//
+const QString UntrustedCertificateInfoBase::formattedFingerprint(
+    const QByteArray &byteArray) const
+{
+    QString formatted;
+
+    QString number;
+    int blockIndex = 0;
+    int count = byteArray.count();
+    for (int index = 0; index < count; ++index) {
+        if (blockIndex == KCharsPerBlock) {
+            formatted.append(KBlockSeparator);
+            blockIndex = 0;
+        }
+        number.sprintf(KHexNumberFormatTwoDigitsWithLeadingZeroes,
+            static_cast<unsigned char>(byteArray.at(index)));
+        formatted.append(number);
+        ++blockIndex;
+    }
+
+    return formatted;
+}
+
+// ----------------------------------------------------------------------------
+// UntrustedCertificateInfoBase::formattedSerialNumber()
+// ----------------------------------------------------------------------------
+//
+const QString UntrustedCertificateInfoBase::formattedSerialNumber(
+    const QByteArray &serialNumber) const
+{
+    QString formatted;
+
+    QString number;
+    int count = serialNumber.count();
+    for (int index = 0; index < count; ++index) {
+        number.sprintf(KHexNumberFormatSimple,
+            static_cast<unsigned char>(serialNumber.at(index)));
+        formatted.append(number);
+    }
+
+    return formatted;
+}
+
+// ----------------------------------------------------------------------------
 // UntrustedCertificateInfoBase::isDateValid()
 // ----------------------------------------------------------------------------
 //
--- a/pkiutilities/untrustedcertificatedialog/src/untrustedcertificateplugin.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/untrustedcertificatedialog/src/untrustedcertificateplugin.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -82,7 +82,7 @@
     Q_UNUSED(deviceDialogType);
     Q_UNUSED(parameters);
 
-    info->group = DeviceNotificationDialogGroup;    // TODO: SecurityGroup ?
+    info->group = GenericDeviceDialogGroup;
     info->flags = NoDeviceDialogFlags;
     info->priority = DefaultPriority;
 
--- a/pkiutilities/untrustedcertificatedialog/src/untrustedcertificatewidget.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/untrustedcertificatedialog/src/untrustedcertificatewidget.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -24,7 +24,6 @@
 #include <hbgroupbox.h>
 #include <hbtextedit.h>
 #include <QGraphicsLinearLayout>
-#include <QTextStream>
 
 const int KUnknownError = -5;           // KErrNotSupported
 
@@ -71,7 +70,7 @@
     mProblemDescription->setTextWrapping(Hb::TextWordWrap);
     mMainLayout->addItem(mProblemDescription);
 
-    if (mIsSavingServerNamePossible && mCertificateInfo->isPermanentAcceptAllowed()) {
+    if (isPermanentAcceptAllowed()) {
         Q_ASSERT(mAcceptPermanently == 0);
         // TODO: localised UI string needed
         mAcceptPermanently = new HbCheckBox(tr("Accept permanently"));
@@ -85,16 +84,12 @@
 
     Q_ASSERT(mCertificateDetailsText == 0);
     mCertificateDetailsText = new HbTextEdit;
-    QString certificateDetails;
-    QTextStream stream(&certificateDetails);
-    // TODO: localized UI string needed
-    stream << tr("Service:\n%1\n").arg(mServerName);
-    stream << endl;
-    stream << mCertificateInfo->certificateDetails();
+    QString certificateDetails = mCertificateInfo->certificateDetails(mServerName);
     mCertificateDetailsText->setPlainText(certificateDetails);
     mCertificateDetailsText->setReadOnly(true);
 
     mCertificateDetailsGroupBox->setContentWidget(mCertificateDetailsText);
+    mCertificateDetailsGroupBox->setCollapsed(true);
     mMainLayout->addItem(mCertificateDetailsGroupBox);
 
     setLayout(mMainLayout);
@@ -111,6 +106,16 @@
 }
 
 // ----------------------------------------------------------------------------
+// UntrustedCertificateWidget::isPermanentAcceptAllowed()
+// ----------------------------------------------------------------------------
+//
+bool UntrustedCertificateWidget::isPermanentAcceptAllowed() const
+{
+    return (mCertificateInfo->isDateValid() && (mServerName.length() > 0) &&
+        mIsSavingServerNamePossible);
+}
+
+// ----------------------------------------------------------------------------
 // UntrustedCertificateWidget::isPermanentAcceptChecked()
 // ----------------------------------------------------------------------------
 //
@@ -123,6 +128,15 @@
 }
 
 // ----------------------------------------------------------------------------
+// UntrustedCertificateWidget::serverName()
+// ----------------------------------------------------------------------------
+//
+QString UntrustedCertificateWidget::serverName() const
+{
+    return mServerName;
+}
+
+// ----------------------------------------------------------------------------
 // UntrustedCertificateWidget::processParameters()
 // ----------------------------------------------------------------------------
 //
--- a/pkiutilities/untrustedcertificatedialog/src/untrustedcertificatewidget_symbian.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/untrustedcertificatedialog/src/untrustedcertificatewidget_symbian.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -20,26 +20,7 @@
 #include "untrustedcertificatedefinitions.h"
 #include "untrustedcertificateinfobase.h"
 #include "untrustedcertificateinfo_symbian.h"
-#include <x509cert.h>                   // CX509Certificate
-
-
-// ======== LOCAL FUNCTIONS ========
-
-// ----------------------------------------------------------------------------
-// DoProcessEncodedCertificateL()
-// ----------------------------------------------------------------------------
-//
-UntrustedCertificateInfoBase* DoProcessEncodedCertificateL( const QByteArray &encodedCert )
-{
-    TPtrC8 ptr8( reinterpret_cast<const TText8*>(encodedCert.constData()), encodedCert.length());
-    CX509Certificate* cert = CX509Certificate::NewLC( ptr8 );
-
-    UntrustedCertificateInfoSymbian *info = 0;
-    info = new UntrustedCertificateInfoSymbian(*cert);
-    CleanupStack::PopAndDestroy( cert );
-
-    return info;
-}
+#include <securitydefs.h>                           // TValidationError
 
 
 // ======== MEMBER FUNCTIONS ========
@@ -59,8 +40,7 @@
 //
 void UntrustedCertificateWidget::processEncodedCertificate(const QByteArray &encodedCert)
 {
-    UntrustedCertificateInfoBase *info = 0;
-    QT_TRAP_THROWING(info = DoProcessEncodedCertificateL(encodedCert));
+    UntrustedCertificateInfoBase *info = new UntrustedCertificateInfoSymbian(encodedCert);
     if (mCertificateInfo) {
         delete mCertificateInfo;
         mCertificateInfo = 0;
--- a/pkiutilities/untrustedcertificatedialog/tsrc/dialoglauncher/dialoglauncher.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/untrustedcertificatedialog/tsrc/dialoglauncher/dialoglauncher.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -33,7 +33,7 @@
 #include <securitydefs.h>       // EValidatedOK, ESignatureInvalid, EDateOutOfRange
 #endif
 
-const QString RootDir = "c:/";
+const QString KTestCertDir = "c:/data/testCerts";
 
 
 UntrustedCertDialogLauncher::UntrustedCertDialogLauncher(int& argc, char* argv[])
@@ -50,7 +50,7 @@
 
     mFilesList = new HbComboBox;
     mFilesList->setEditable(false);
-    QDir dir(RootDir);
+    QDir dir(KTestCertDir);
     if (dir.exists()) {
         QFileInfoList list = dir.entryInfoList(QDir::Files);
         QListIterator<QFileInfo> iter(list);
@@ -61,7 +61,7 @@
     }
     layout->addItem(mFilesList);
 
-    mHostName = new HbTextEdit(tr("some.host.name.com"));
+    mHostName = new HbTextEdit(tr("some.host.com"));
     layout->addItem(mHostName);
 
     HbPushButton *button = 0;
@@ -115,7 +115,7 @@
 
     QString fileName = mFilesList->currentText();
     QFile file;
-    QDir::setCurrent(RootDir);
+    QDir::setCurrent(KTestCertDir);
     file.setFileName(fileName);
     file.open(QIODevice::ReadOnly);
     QByteArray fileContent = file.readAll();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pkiutilities/untrustedcertificatedialog/tsrc/dialoglauncher/dialoglauncher.iby	Wed Jun 23 19:10:54 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Test application for untrusted certificate dialog.
+*
+*/
+
+
+#ifndef __DIALOGLAUNCHER_IBY__
+#define __DIALOGLAUNCHER_IBY__
+
+file=ABI_DIR/BUILD_DIR/dialoglauncher.exe SHARED_LIB_DIR/dialoglauncher.exe
+HB_UPGRADABLE_APP_REG_RSC( dialoglauncher )
+
+#endif  // __DIALOGLAUNCHER_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pkiutilities/untrustedcertificatedialog/tsrc/dialoglauncher/dialoglauncher.pkg	Wed Jun 23 19:10:54 2010 +0300
@@ -0,0 +1,43 @@
+;
+; Copyright (c) 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"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+; 
+; Description:  Test application for untrusted certificate dialog.
+;
+
+; Language
+&EN
+
+; SIS header: name, uid, version
+#{"dialoglauncher"},(0xE9bbd80d),1,0,0
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Manual PKG pre-rules from PRO files
+; Default dependency to Qt libraries
+(0x2001E61C), 4, 6, 3, {"Qt"}
+
+; Default HW/platform dependencies
+[0x101F7961],0,0,0,{"S60ProductID"}
+[0x102032BE],0,0,0,{"S60ProductID"}
+[0x102752AE],0,0,0,{"S60ProductID"}
+[0x1028315F],0,0,0,{"S60ProductID"}
+
+; Executable and default resource files
+"/epoc32/release/armv5/urel/dialoglauncher.exe" - "!:\sys\bin\dialoglauncher.exe"
+"/epoc32/data/z/resource/apps/dialoglauncher.rsc" - "!:\resource\apps\dialoglauncher.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/dialoglauncher_reg.rsc" - "!:\private\10003a3f\import\apps\dialoglauncher_reg.rsc"
+
--- a/pkiutilities/untrustedcertificatedialog/tsrc/dialoglauncher/dialoglauncher.pro	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/untrustedcertificatedialog/tsrc/dialoglauncher/dialoglauncher.pro	Wed Jun 23 19:10:54 2010 +0300
@@ -27,3 +27,10 @@
     TARGET.CAPABILITY = CAP_APPLICATION
 }
 
+BLD_INF_RULES.prj_exports += \
+  "$${LITERAL_HASH}include <platform_paths.hrh>" \
+  "dialoglauncher.iby CORE_APP_LAYER_IBY_EXPORT_PATH(dialoglauncher.iby)" \
+  "test_cert_expired.crt /epoc32/winscw/c/data/testCerts/test_cert_expired.crt" \
+  "test_cert_server.crt /epoc32/winscw/c/data/testCerts/test_cert_server.crt" \
+  "test_cert_sha2.crt /epoc32/winscw/c/data/testCerts/test_cert_sha2.crt"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pkiutilities/untrustedcertificatedialog/tsrc/dialoglauncher/test_cert_expired.crt	Wed Jun 23 19:10:54 2010 +0300
@@ -0,0 +1,17 @@
+-----BEGIN CERTIFICATE-----
+MIICpTCCAg6gAwIBAgIBBDANBgkqhkiG9w0BAQUFADBwMQswCQYDVQQGEwJGSTEQ
+MA4GA1UECBMHVGFtcGVyZTEQMA4GA1UEBxMHVGFtcGVyZTEOMAwGA1UEChMFTm9r
+aWExFTATBgNVBAsTDFM2MCBTZWN1cml0eTEWMBQGA1UEAxMNc29tZS5ob3N0LmNv
+bTAeFw0xMDA2MDIxMTQwMDFaFw0wNjA2MDIxMzU0MTdaMHAxCzAJBgNVBAYTAkZJ
+MRAwDgYDVQQIEwdUYW1wZXJlMRAwDgYDVQQHEwdUYW1wZXJlMQ4wDAYDVQQKEwVO
+b2tpYTEVMBMGA1UECxMMUzYwIFNlY3VyaXR5MRYwFAYDVQQDEw1zb21lLmhvc3Qu
+Y29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC/31fdPI+OcFPpaUC0D2XO
+SmmDbRdouyUa0LCQ9sP9ChiGBqT6g2uv/irhcezA+gUdlERrEQsmmeXuMqktG0Jb
+dxHJNSEboERr+65q7F4g3nJlxeNOlVllCKd4cFO7/oGRtduAJALkQmeKkPwgHPW+
+AFtG7U3rAd5xRjxzK8q7SQIDAQABo08wTTAMBgNVHRMBAf8EAjAAMB0GA1UdDgQW
+BBSJJ8UI5B6SWTG05XFyD3N+/6/+CTALBgNVHQ8EBAMCBeAwEQYJYIZIAYb4QgEB
+BAQDAgZAMA0GCSqGSIb3DQEBBQUAA4GBAB+kN6paDHW46pLwCR5yJLp5m7DoEJ/L
+IMWCmxKB90FADiBz+jvNQue3hO8SJVpvuRsy1y/e915LXYD4JAlIhZektB2DmYqg
+6Tic9tlcQh101myX9sV5ORC2BKg4Tol2PUDaiVsaXSU2cgfWmxPmza2d4RvMvkGp
+4L/EpR5ol37y
+-----END CERTIFICATE-----
Binary file pkiutilities/untrustedcertificatedialog/tsrc/dialoglauncher/test_cert_server.crt has changed
Binary file pkiutilities/untrustedcertificatedialog/tsrc/dialoglauncher/test_cert_sha2.crt has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pkiutilities/untrustedcertificatedialog/tsrc/tlsconntest/tlsconnection.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -0,0 +1,471 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Secure connections test application
+*
+*/
+
+#include "tlsconnection.h"
+#include <e32debug.h>
+#include <SecureSocket.h>
+#include <ssl_internal.h>       // KSolInetSSL, KSoSSLDomainName
+
+_LIT( KData, "GET index.html" );
+_LIT( KSecureProtocol, "TLS1.0" );
+_LIT( KCommDBIapId, "IAP\\Id" );
+_LIT8( KNewLine, "\n" );
+
+const TInt KRecvBufferLength = 0x4000;
+const TInt KOneSecondInMicroseconds = 1000000;
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------
+// CTlsConnection::NewL
+// ---------------------------------------------------------
+//
+CTlsConnection* CTlsConnection::NewL( MTlsConnectionObserver& aObs )
+    {
+    RDebug::Print( _L("CTlsConnection::NewL()") );
+    CTlsConnection* self = new ( ELeave ) CTlsConnection( aObs );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CTlsConnection::~CTlsConnection()
+// -----------------------------------------------------------------------------
+//
+CTlsConnection::~CTlsConnection()
+    {
+    RDebug::Print( _L("CTlsConnection::~CTlsConnection()") );
+    Cancel();
+    iDelayTimer.Close();
+    CloseSession();
+    delete iSendBuffer;
+    delete iSendBufPtr;
+    }
+
+// -----------------------------------------------------------------------------
+// CTlsConnection::ConnectL()
+// -----------------------------------------------------------------------------
+//
+void CTlsConnection::ConnectL( const TDesC& aHostName, TInt aPort, TInt aDelay )
+    {
+    RDebug::Print( _L("CTlsConnection::Connect() host '%S', port %d, delay %d"),
+        &aHostName, aPort, aDelay );
+    CloseConnection();
+
+    // Parameters
+    if( iHostName )
+        {
+        delete iHostName;
+        iHostName = NULL;
+        }
+    iHostName = aHostName.AllocL();
+    iPort = aPort;
+    iDelay = aDelay;
+
+    // Save host name in 8-bit form for server certificate checking
+    if( iHostNameForCertCheck )
+        {
+        delete iHostNameForCertCheck;
+        iHostNameForCertCheck = NULL;
+        }
+    iHostNameForCertCheck = HBufC8::NewL( aHostName.Length() );
+    TPtr8 ptr( iHostNameForCertCheck->Des() );
+    ptr.Copy( aHostName );
+
+    // Convert send data to 8-bit and add newline at the end
+    if( iSendBuffer || iSendBufPtr )
+        {
+        delete iSendBuffer;
+        iSendBuffer = NULL;
+        delete iSendBufPtr;
+        iSendBufPtr = NULL;
+        }
+    iSendBuffer = HBufC8::NewL( KData().Length() + 1 );
+    iSendBufPtr = new( ELeave ) TPtr8( iSendBuffer->Des() );
+    iSendBufPtr->Copy( KData );
+    iSendBufPtr->Append( KNewLine );
+
+    // Connect
+    RDebug::Printf( "CTlsConnection::ConnectL iConnection.Open" );
+    User::LeaveIfError( iConnection.Open( iSockServer ) );
+    RDebug::Printf( "CTlsConnection::ConnectL iConnPref.SetDirection" );
+    iConnPref.SetDirection( ECommDbConnectionDirectionOutgoing );
+    if( iCurrentIap )
+        {
+        // uses the same IAP as before
+        RDebug::Printf( "CTlsConnection::ConnectL SetIapId(%d)", iCurrentIap );
+        iConnPref.SetIapId( iCurrentIap );
+        iConnPref.SetDialogPreference( ECommDbDialogPrefDoNotPrompt );
+        }
+    else
+        {
+        // not defined, prompts the IAP from user
+        RDebug::Printf( "CTlsConnection::ConnectL ECommDbDialogPrefPrompt" );
+        iConnPref.SetDialogPreference( ECommDbDialogPrefPrompt );
+        }
+    StateChange( EConnectingNetwork );
+    RDebug::Printf( "CTlsConnection::ConnectL iConnection.Start" );
+    iConnection.Start( iConnPref, iStatus );
+    SetActive();
+    RDebug::Printf( "CTlsConnection::ConnectL end" );
+    }
+
+// -----------------------------------------------------------------------------
+// CTlsConnection::Disconnect()
+// -----------------------------------------------------------------------------
+//
+void CTlsConnection::Disconnect()
+    {
+    Cancel();
+    CloseConnection();
+    StateChange( EDisconnected );
+    }
+
+// -----------------------------------------------------------------------------
+// CTlsConnection::RunL
+// -----------------------------------------------------------------------------
+//
+void CTlsConnection::RunL()
+    {
+    if( iState == EReading && ( iStatus.Int() == KErrEof || iStatus.Int() == KErrSSLAlertCloseNotify ) )
+        {
+        RDebug::Printf( "CTlsConnection::RunL: EReading, EOF: iStatus = %d", iStatus.Int() );
+        StateChange( EAllDone );
+        }
+    else if( iStatus.Int() == KErrNone )
+        {
+        switch ( iState )
+            {
+            case EConnectingNetwork:
+                RDebug::Printf( "CTlsConnection::RunL: EConnectingNetwork" );
+                if( !iCurrentIap )
+                    {
+                    iConnection.GetIntSetting( KCommDBIapId, iCurrentIap );
+                    }
+                if( iDelay )
+                    {
+                    TTimeIntervalMicroSeconds32 delay( iDelay * KOneSecondInMicroseconds );
+                    iDelayTimer.After( iStatus, delay );
+                    StateChange( EOpeningDelay );
+                    }
+                else
+                    {
+                    iConnection.ProgressNotification( iProgress, iStatus );
+                    StateChange( EResolvingHostName );
+                    }
+                SetActive();
+                break;
+
+            case EOpeningDelay:
+                iConnection.ProgressNotification( iProgress, iStatus );
+                StateChange( EResolvingHostName );
+                SetActive();
+                break;
+
+            case EResolvingHostName:
+                {
+                RDebug::Printf( "CTlsConnection::RunL: EResolvingHostName" );
+                TInt err = iHostResolver.Open( iSockServer, KAfInet, KProtocolInetUdp, iConnection );
+                User::LeaveIfError( err );
+                iHostResolver.GetByName( *iHostName, iNameEntry, iStatus );
+                StateChange( EConnectingServer );
+                SetActive();
+                }
+                break;
+
+            case EConnectingServer:
+                {
+                iRemoteAddr.SetFamily( KAfInet );
+                iRemoteAddr = TInetAddr( iNameEntry().iAddr );
+                iRemoteAddr.SetPort( iPort );
+
+                RDebug::Printf( "CTlsConnection::RunL: EConnectingServer" );
+                TInt err = iSocket.Open( iSockServer, KAfInet, KSockStream, KProtocolInetTcp, iConnection );
+                RDebug::Printf( "CTlsConnection::RunL: iSocket.Open ret %d", err );
+                User::LeaveIfError( err );
+                iSocket.Connect( iRemoteAddr, iStatus );
+                StateChange( EHandshaking );
+                SetActive();
+                }
+                break;
+
+            case EHandshaking:
+                {
+                RDebug::Printf( "CTlsConnection::RunL: EHandshaking" );
+                if( iSecureSocket )
+                    {
+                    delete iSecureSocket;
+                    iSecureSocket = NULL;
+                    }
+                iSecureSocket = CSecureSocket::NewL( iSocket, KSecureProtocol );
+                iSecureSocket->SetDialogMode( EDialogModeAttended );
+                // Server name must be set, otherwise CCTSecurityDialogsAO fails with KErrArgument
+                iSecureSocket->SetOpt( KSoSSLDomainName, KSolInetSSL, *iHostNameForCertCheck );
+                iSecureSocket->StartClientHandshake( iStatus );
+                StateChange( EConnecting );
+                SetActive();
+                }
+                break;
+
+            case EConnecting:
+                {
+                RDebug::Printf( "CTlsConnection::RunL: EConnecting" );
+                // Check if connection is closed
+                const TInt stage( iProgress().iStage );
+                if( stage == KConnectionClosed || stage == KLinkLayerClosed )
+                    {
+                    StateChange( EDisconnected );
+                    }
+                else
+                    {
+                    iConnection.ProgressNotification( iProgress, iStatus );
+                    StateChange( ESending );
+                    SetActive();
+                    }
+                }
+                break;
+
+            case ESending:
+                RDebug::Printf( "CTlsConnection::RunL: ESending" );
+                iSecureSocket->Send( *iSendBufPtr, iStatus, iSendLength );
+                StateChange( EReading );
+                SetActive();
+                break;
+
+            case EReading:
+                iTotalRecvCount += iRecvLength();
+                RDebug::Printf( "CTlsConnection::RunL: EReading, read %d bytes", iTotalRecvCount );
+                iObserver.HandleTransferData( iRecvBuffer->Des(), iTotalRecvCount );
+
+                iRecvBufPtr->Zero();
+                iSecureSocket->RecvOneOrMore( *iRecvBufPtr, iStatus, iRecvLength );
+                SetActive();
+                break;
+
+            default:
+                break;
+            }
+        }
+    else
+        {
+        RDebug::Printf( "CTlsConnection::RunL: ERROR iStatus %d", iStatus.Int() );
+        CloseConnection();
+        StateChange( EDisconnected, iStatus.Int() );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CTlsConnection::DoCancel()
+// ---------------------------------------------------------------------------
+//
+void CTlsConnection::DoCancel()
+    {
+    RDebug::Printf( "CTlsConnection::DoCancel(), iState=%d", iState );
+
+    switch( iState )
+        {
+        case EConnectingNetwork:
+            iConnection.Stop();
+            break;
+
+        case EOpeningDelay:
+            iDelayTimer.Cancel();
+            iConnection.Stop();
+            break;
+
+        case EResolvingHostName:
+            iConnection.CancelProgressNotification();
+            iConnection.Stop();
+            break;
+
+        case EConnectingServer:
+            iHostResolver.Cancel();
+            iConnection.Stop();
+            break;
+
+        case EHandshaking:
+            iSocket.CancelConnect();
+            iConnection.Stop();
+            break;
+
+        case EConnecting:
+            if( iSecureSocket )
+                {
+                iSecureSocket->CancelHandshake();
+                delete iSecureSocket;
+                iSecureSocket = NULL;
+                }
+            iSocket.Close();
+            iConnection.Stop();
+            break;
+
+        case ESending:
+            if( iSecureSocket )
+                {
+                iSecureSocket->CancelSend();
+                delete iSecureSocket;
+                iSecureSocket = NULL;
+                }
+            iSocket.Close();
+            iConnection.Stop();
+            break;
+
+        case EReading:
+            if( iSecureSocket )
+                {
+                iSecureSocket->CancelRecv();
+                delete iSecureSocket;
+                iSecureSocket = NULL;
+                }
+            iSocket.Close();
+            iConnection.Stop();
+            break;
+
+        case EAllDone:
+        case EIdle:
+        case EDisconnected:
+        default:
+            break;
+        }
+
+    StateChange( EDisconnected );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTlsConnection::RunError()
+// -----------------------------------------------------------------------------
+//
+TInt CTlsConnection::RunError( TInt aError )
+    {
+    RDebug::Printf( "CTlsConnection::RunError, aError: %d", aError );
+    CloseConnection();
+    StateChange( EDisconnected, aError );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CTlsConnection::CTlsConnection()
+// -----------------------------------------------------------------------------
+//
+CTlsConnection::CTlsConnection( MTlsConnectionObserver& aObs ) :
+        CActive( CActive::EPriorityStandard ), iObserver( aObs ), iState( ENotInitialized )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// -----------------------------------------------------------------------------
+// CTlsConnection::ConstructL()
+// -----------------------------------------------------------------------------
+//
+void CTlsConnection::ConstructL()
+    {
+    RDebug::Printf( "CTlsConnection::ConstructL begin" );
+
+    User::LeaveIfError( iDelayTimer.CreateLocal() );
+    RDebug::Printf( "CTlsConnection::ConstructL iSockServer" );
+    User::LeaveIfError( iSockServer.Connect() );
+    RDebug::Printf( "CTlsConnection::ConstructL iConnection" );
+    User::LeaveIfError( iConnection.Open( iSockServer ) );
+    RDebug::Printf( "CTlsConnection::ConstructL buffers" );
+    iRecvBuffer = HBufC8::NewL( KRecvBufferLength );
+    iRecvBufPtr = new( ELeave ) TPtr8( iRecvBuffer->Des() );
+    StateChange( EIdle );
+
+    RDebug::Printf( "CTlsConnection::ConstructL end" );
+    }
+
+// ---------------------------------------------------------------------------
+// CTlsConnection::CloseConnection()
+// ---------------------------------------------------------------------------
+//
+void CTlsConnection::CloseConnection()
+    {
+    RDebug::Printf( "CTlsConnection::CloseConnection begin" );
+    if( iSecureSocket )
+        {
+        delete iSecureSocket;
+        iSecureSocket = NULL;
+        }
+    iSocket.Close();
+    iHostResolver.Close();
+    if( iConnection.SubSessionHandle() )
+        {
+        if( iState >= EConnectingNetwork )
+            {
+            TInt err = iConnection.Stop();
+            if( err != KErrNone )
+                {
+                RDebug::Printf( "iConnection.Stop() failed: %d", err );
+                }
+            }
+        iConnection.Close();
+        }
+    RDebug::Printf( "CTlsConnection::CloseConnection end" );
+    }
+
+// ---------------------------------------------------------------------------
+// CTlsConnection::CloseSession()
+// ---------------------------------------------------------------------------
+//
+void CTlsConnection::CloseSession()
+    {
+    RDebug::Printf( "CTlsConnection::CloseSession" );
+    CloseConnection();
+    iSockServer.Close();
+    delete iHostName;
+    iHostName = NULL;
+    delete iHostNameForCertCheck;
+    iHostNameForCertCheck = NULL;
+    delete iRecvBuffer;
+    iRecvBuffer = NULL;
+    delete iRecvBufPtr;
+    iRecvBufPtr = NULL;
+    StateChange( EDisconnected );
+    }
+
+// -----------------------------------------------------------------------------
+// CTlsConnection::StateChange()
+// -----------------------------------------------------------------------------
+//
+void CTlsConnection::StateChange( TTlsConnectionState aNewState, TInt aError )
+    {
+    RDebug::Printf( "CTlsConnection::StateChange, aNewState=%d, aError=%d", aNewState, aError );
+    if( aNewState != iState && iState != EAllDone )
+        {
+        iState = aNewState;
+        iObserver.HandleNetworkEvent( aNewState, aError );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CTlsConnection::ReadL()
+// ---------------------------------------------------------------------------
+//
+void CTlsConnection::ReadL()
+    {
+    RDebug::Printf( "CTlsConnection::ReadL(), iState=%d", iState );
+
+    TPtr8 recvBuffer = iRecvBuffer->Des();
+    recvBuffer.Zero();
+    iSecureSocket->RecvOneOrMore( recvBuffer, iStatus, iRecvLength );
+    SetActive();
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pkiutilities/untrustedcertificatedialog/tsrc/tlsconntest/tlsconnection.h	Wed Jun 23 19:10:54 2010 +0300
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Secure connections test application
+*
+*/
+
+#ifndef C_TESTTLSCONNECTION_H
+#define C_TESTTLSCONNECTION_H
+
+#include <es_sock.h>                    // RConnection
+#include <in_sock.h>                    // TInetAddr
+#include <commdbconnpref.h>             // TCommDbConnPref
+#include "tlsconnectionobserver.h"      // MTlsConnectionObserver, TTlsConnectionState
+
+class CSecureSocket;
+
+
+class CTlsConnection : public CActive
+    {
+    public:     // new functions
+        static CTlsConnection* NewL( MTlsConnectionObserver& aObs );
+        ~CTlsConnection();
+        void ConnectL( const TDesC& aHostName, TInt aPort, TInt aDelay );
+        void Disconnect();
+
+    protected:  // from CActive
+        void RunL();
+        void DoCancel();
+        TInt RunError( TInt aError );
+
+    private:    // constructors
+        CTlsConnection( MTlsConnectionObserver& aObs );
+        void ConstructL();
+
+    private:    // new functions
+        void CloseConnection();
+        void CloseSession();
+        void StateChange( TTlsConnectionState aNewState, TInt aError = KErrNone );
+        void ReadL();
+
+    private:    // data
+        MTlsConnectionObserver& iObserver;
+        RConnection iConnection;
+        RSocketServ iSockServer;
+        TCommDbConnPref iConnPref;
+        TUint32 iCurrentIap;
+        TNifProgressBuf iProgress;
+        HBufC* iHostName;
+        HBufC8* iHostNameForCertCheck;
+        TInt iPort;
+        TInt iDelay;
+        RHostResolver iHostResolver;
+        TNameEntry iNameEntry;
+        TInetAddr iRemoteAddr;
+        RSocket iSocket;
+        CSecureSocket* iSecureSocket;
+        HBufC8* iRecvBuffer;
+        TPtr8* iRecvBufPtr;
+        TSockXfrLength iRecvLength;
+        HBufC8* iSendBuffer;
+        TPtr8* iSendBufPtr;
+        TSockXfrLength iSendLength;
+        TInt iTotalRecvCount;
+        TTlsConnectionState iState;
+        RTimer iDelayTimer;
+    };
+
+
+#endif // C_TESTTLSCONNECTION_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pkiutilities/untrustedcertificatedialog/tsrc/tlsconntest/tlsconnectionapp.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -0,0 +1,197 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Secure connections test application
+*
+*/
+
+#include "tlsconnectionapp.h"
+#include "tlsconnection.h"
+#include <hbmainwindow.h>
+#include <hbview.h>
+#include <QDebug>
+#include <QGraphicsLinearLayout>
+#include <hbcombobox.h>
+#include <hblineedit.h>
+#include <hblabel.h>
+#include <hbpushbutton.h>
+#include <hbmessagebox.h>
+
+
+TlsConnectionApplication::TlsConnectionApplication(int& aArgc, char* aArgv[])
+    : HbApplication(aArgc, aArgv), mMainWindow(0), mMainView(0), mHost(0),
+      mPort(0), mOpeningDelay(0), mStatusLabel(0), mConnection(0)
+{
+    qDebug() << "TLStest TlsConnectionApplication begin";
+
+    mMainWindow = new HbMainWindow();
+    mMainView = new HbView();
+    mMainView->setTitle(tr("TLS Test"));
+
+    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
+
+    mHost = new HbComboBox;
+    QStringList defaultHosts;
+    defaultHosts << "www.nokia.com"
+        << "www.f-secure.com"
+        << "www.google.fi"
+        << "www.tut.fi";
+    mHost->addItems(defaultHosts);
+    connect(mHost, SIGNAL(editingFinished()), this, SLOT(addHostName()));
+    mHost->setEditable(true);
+    layout->addItem(mHost);
+
+    mPort = new HbLineEdit(tr("Port?"));
+    mPort->setText(tr("443"));
+    layout->addItem(mPort);
+
+    mOpeningDelay = new HbLineEdit(tr("Opening delay?"));
+    mOpeningDelay->setText(tr("0"));
+    layout->addItem(mOpeningDelay);
+
+    mStatusLabel = new HbLabel(tr("Inactive"));
+    layout->addItem(mStatusLabel);
+
+    HbPushButton *activateButton = new HbPushButton(tr("Run Test"));
+    connect(activateButton, SIGNAL(clicked()), this, SLOT(runTestPressed()));
+    layout->addItem(activateButton);
+
+    HbPushButton *closeButton = new HbPushButton("Close");
+    connect(closeButton, SIGNAL(clicked()), qApp, SLOT(quit()));
+    layout->addItem(closeButton);
+
+    mMainView->setLayout(layout);
+    mMainWindow->addView(mMainView);
+    mMainWindow->show();
+
+    qDebug() << "TLStest TlsConnectionApplication end";
+}
+
+TlsConnectionApplication::~TlsConnectionApplication()
+{
+    qDebug() << "TLStest ~TlsConnectionApplication begin";
+
+    delete mConnection;
+    delete mMainView;
+    delete mMainWindow;
+
+    qDebug() << "TLStest ~TlsConnectionApplication end";
+}
+
+void TlsConnectionApplication::HandleNetworkEvent( TTlsConnectionState aEvent, TInt aError )
+{
+    switch( aEvent ) {
+	case ENotInitialized:
+		showProgress( tr("NotInitialized"), aError );
+		break;
+	case EDisconnected:
+		showProgress( tr("Disconnected"), aError );
+		break;
+	case EIdle:
+		showProgress( tr("Idle"), aError );
+		break;
+	case EConnectingNetwork:
+		showProgress( tr("ConnectingNetwork"), aError );
+		break;
+	case EOpeningDelay:
+		showProgress( tr("OpeningDelay"), aError );
+		break;
+	case EResolvingHostName:
+		showProgress( tr("ResolvingHostName"), aError );
+		break;
+	case EConnectingServer:
+		showProgress( tr("ConnectingServer"), aError );
+		break;
+	case EHandshaking:
+		showProgress( tr("Handshaking"), aError );
+		break;
+	case EConnecting:
+		showProgress( tr("Connecting"), aError );
+		break;
+	case ESending:
+		showProgress( tr("Sending"), aError );
+		break;
+	case EReading:
+		showProgress( tr("Reading"), aError );
+		break;
+	case EAllDone:
+		showProgress( tr("AllDone"), aError );
+		break;
+	default:
+		showProgress( tr("unknown"), aError );
+		break;
+	}
+}
+
+void TlsConnectionApplication::HandleTransferData( const TDesC8& /*aData*/, TInt aLength )
+{
+    qDebug() << "TLStest HandleTransferData, length:" << aLength;
+}
+
+void TlsConnectionApplication::runTestPressed()
+{
+    qDebug() << "TLStest runTestPressed begin";
+
+    if (mConnection) {
+        delete mConnection;
+        mConnection = NULL;
+    }
+
+    TPtrC host( reinterpret_cast<const TText*>( mHost->currentText().constData() ));
+    TInt port = getInt(mPort->text(), 443);
+    TInt delay = getInt(mOpeningDelay->text(), 0);
+    qDebug() << "TLStest runTestPressed host:" << mHost->currentText() << "port" << port << "delay" << delay;
+    TRAPD( err, mConnection = CTlsConnection::NewL( *this ) );
+    qDebug() << "TLStest runTestPressed err:" << err;
+    if( !err ) {
+        qDebug() << "TLStest runTestPressed CTlsConnection created, connecting";
+        TRAP( err, mConnection->ConnectL( host, port, delay ) );
+        qDebug() << "TLStest runTestPressed err:" << err;
+    }
+
+    qDebug() << "TLStest runTestPressed end";
+}
+
+void TlsConnectionApplication::addHostName()
+{
+    QString newHostName = mHost->currentText();
+    mHost->addItem(newHostName);
+}
+
+void TlsConnectionApplication::showProgress(const QString& aStep, int aError)
+{
+    qDebug() << "TLStest showProgress step" << aStep << "error" << aError;
+    if (mStatusLabel) {
+        if (!aError) {
+            mStatusLabel->setPlainText(aStep);
+        } else {
+            QString msg(aStep);
+            msg.append(tr(" error %1").arg(aError));
+            mStatusLabel->setPlainText(msg);
+        }
+    }
+}
+
+TInt TlsConnectionApplication::getInt(const QString& aString, int defaultValue)
+{
+    qDebug() << "TLStest getInt" << aString << "defaultValue" << defaultValue;
+
+    bool ok = false;
+    TInt value = aString.toInt(&ok, 10);
+    if (!ok) {
+        value = defaultValue;
+    }
+
+    qDebug() << "TLStest getInt returns " << value;
+    return value;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pkiutilities/untrustedcertificatedialog/tsrc/tlsconntest/tlsconnectionapp.h	Wed Jun 23 19:10:54 2010 +0300
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Secure connections test application
+*
+*/
+
+#ifndef TLSCONNECTIONAPP_H
+#define TLSCONNECTIONAPP_H
+
+#include <hbapplication.h>
+#include "tlsconnectionobserver.h"
+
+class HbMainWindow;
+class HbView;
+class HbComboBox;
+class HbLineEdit;
+class HbLabel;
+class CTlsConnection;
+
+
+class TlsConnectionApplication : public HbApplication, public MTlsConnectionObserver
+{
+    Q_OBJECT
+
+public:     // constructor and destructor
+    TlsConnectionApplication(int& aArgc, char* aArgv[]);
+    virtual ~TlsConnectionApplication();
+
+public:		// from MTlsConnectionObserver
+    void HandleNetworkEvent(TTlsConnectionState aEvent, TInt aError);
+    void HandleTransferData(const TDesC8& aData, TInt aLength);
+
+private slots:
+    void runTestPressed();
+    void addHostName();
+
+private:    // new functions
+    void showProgress(const QString& aStep, int aError);
+    TInt getInt(const QString& aString, int defaultValue);
+
+private:    // data
+    HbMainWindow *mMainWindow;
+    HbView       *mMainView;
+    HbComboBox   *mHost;
+    HbLineEdit   *mPort;
+    HbLineEdit   *mOpeningDelay;
+    HbLabel      *mStatusLabel;
+    CTlsConnection *mConnection;
+};
+
+#endif  // TLSCONNECTIONAPP_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pkiutilities/untrustedcertificatedialog/tsrc/tlsconntest/tlsconnectionmain.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Secure connections test application
+*
+*/
+
+#include "tlsconnectionapp.h"
+#include <QDebug>
+#include <e32base.h>                // CTrapCleanup
+
+
+int DoMainL(int argc, char *argv[])
+{
+    TlsConnectionApplication app(argc, argv);
+    return app.exec();
+}
+
+int main(int argc, char *argv[])
+{
+    qDebug() << "TLStest main begin";
+
+    int err = 0;
+    CTrapCleanup *cleanup = CTrapCleanup::New();
+    if (cleanup) {
+        TRAP(err, DoMainL(argc, argv));
+        delete cleanup;
+    }
+
+    qDebug() << "TLStest main returns" << err;
+    return err;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pkiutilities/untrustedcertificatedialog/tsrc/tlsconntest/tlsconnectionobserver.h	Wed Jun 23 19:10:54 2010 +0300
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Secure connections test application
+*
+*/
+
+#ifndef M_MTLSCONNECTIONOBSERVER_H
+#define M_MTLSCONNECTIONOBSERVER_H
+
+enum TTlsConnectionState
+    {
+    ENotInitialized = 0,
+    EDisconnected,
+    EIdle,
+    EConnectingNetwork,
+    EOpeningDelay,
+    EResolvingHostName,
+    EConnectingServer,
+    EHandshaking,
+    EConnecting,
+    ESending,
+    EReading,
+    EAllDone
+    };
+
+class MTlsConnectionObserver
+    {
+    public:
+        virtual void HandleNetworkEvent( TTlsConnectionState aEvent, TInt aError ) = 0;
+        virtual void HandleTransferData( const TDesC8& aData, TInt aLength ) = 0;
+    };
+
+#endif // M_MTLSCONNECTIONOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pkiutilities/untrustedcertificatedialog/tsrc/tlsconntest/tlsconntest.iby	Wed Jun 23 19:10:54 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Secure connections test application
+*
+*/
+
+
+#ifndef __TLSCONNTEST_IBY__
+#define __TLSCONNTEST_IBY__
+
+file=ABI_DIR/BUILD_DIR/tlsconntest.exe SHARED_LIB_DIR/tlsconntest.exe
+HB_UPGRADABLE_APP_REG_RSC( tlsconntest )
+
+#endif  // __TLSCONNTEST_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pkiutilities/untrustedcertificatedialog/tsrc/tlsconntest/tlsconntest.loc	Wed Jun 23 19:10:54 2010 +0300
@@ -0,0 +1,19 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Secure connections test application
+*
+*/
+
+#define STRING_r_short_caption "TlsConnTest"
+#define STRING_r_caption "TlsConnTest"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pkiutilities/untrustedcertificatedialog/tsrc/tlsconntest/tlsconntest.pkg	Wed Jun 23 19:10:54 2010 +0300
@@ -0,0 +1,41 @@
+;
+; Copyright (c) 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"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:  Secure connections test application
+;
+;
+
+; Language
+&EN
+
+; SIS header: name, uid, version
+#{"TlsConnTest"},(0xE8DC94B1),1,0,0
+
+; Vendor name, localised and unique
+%{"Nokia"}
+:"Nokia"
+
+; Default dependency to Qt libraries
+(0x2001E61C), *, *, *, {"Qt"}
+
+; Default platform dependencies
+[0x101F7961],0,0,0,{"S60ProductID"}
+[0x102032BE],0,0,0,{"S60ProductID"}
+[0x102752AE],0,0,0,{"S60ProductID"}
+[0x1028315F],0,0,0,{"S60ProductID"}
+
+; Executable and default resource files
+"/epoc32/release/armv5/urel/tlsconntest.exe" - "!:\sys\bin\tlsconntest.exe"
+"/epoc32/data/z/resource/apps/tlsconntest.rsc" - "!:\resource\apps\tlsconntest.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/tlsconntest_reg.rsc" - "!:\private\10003a3f\import\apps\tlsconntest_reg.rsc"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pkiutilities/untrustedcertificatedialog/tsrc/tlsconntest/tlsconntest.pro	Wed Jun 23 19:10:54 2010 +0300
@@ -0,0 +1,39 @@
+#
+# Copyright (c) 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"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+# 
+# Description:  Secure connections test application
+#
+
+TEMPLATE = app
+TARGET = tlsconntest
+CONFIG += hb
+DEPENDPATH += .
+INCLUDEPATH += .
+
+HEADERS += tlsconnection.h tlsconnectionobserver.h tlsconnectionapp.h tlsconntest.loc
+SOURCES += tlsconnectionmain.cpp tlsconnection.cpp tlsconnectionapp.cpp
+LIBS += -lesock -lcommdb -linsock -linetprotutil -lsecuresocket
+
+symbian {
+    BLD_INF_RULES.prj_exports += "tlsconntest.loc APP_LAYER_LOC_EXPORT_PATH(tlsconntest.loc)"
+    
+    TARGET.UID2 = 0x100039CE
+    TARGET.UID3 = 0xE8DC94B1        # random uid
+    TARGET.CAPABILITY = CAP_APPLICATION
+}
+
+BLD_INF_RULES.prj_exports += \
+  "$${LITERAL_HASH}include <platform_paths.hrh>" \
+  "tlsconntest.iby CORE_APP_LAYER_IBY_EXPORT_PATH(tlsconntest.iby)"
+
+ 
\ No newline at end of file
--- a/pkiutilities/untrustedcertificatedialog/untrustedcertificateplugin.pro	Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/untrustedcertificatedialog/untrustedcertificateplugin.pro	Wed Jun 23 19:10:54 2010 +0300
@@ -43,7 +43,7 @@
     SOURCES += src/untrustedcertificatewidget_symbian.cpp \
         src/untrustedcertificateinfo_symbian.cpp
     
-    LIBS += -lcrypto -lx509 -lx500
+    LIBS += -lcrypto -lx509 -lx500 -lhash -lX509CertNameParser
     
     pluginstub.sources = untrustedcertdialog.dll
     pluginstub.path = /resource/plugins/devicedialogs
--- a/securitydialogs/Autolock/autolock.qcrml	Fri Jun 11 14:28:40 2010 +0300
+++ b/securitydialogs/Autolock/autolock.qcrml	Wed Jun 23 19:10:54 2010 +0300
@@ -12,13 +12,15 @@
 <repository target="CRepository" uidValue="0x101f8798">
     <key int="0x7e000001"  ref="/KCRUidProfileEngine/KProEngActiveProfile"></key>
 </repository>
-
+<repository target="RProperty" uidValue="0x101F8767">
+    <key int="0x00000501"  ref="/KPSUidCoreApplicationUIs/KCoreAppUIsAutolockStatus"></key>
+</repository>
+<repository target="RProperty" uidValue="0x100059b5">
+    <key int="0x00000309"  ref="/KPSUidSecurityUIs/KSecurityUIsDismissDialog"></key>
+</repository>
 <repository target="RProperty" uidValue="0x20022F35">
     <key int="0x1"  ref="/KPSUidHWRM/KHWRMGripStatus"></key>
 </repository>
 <repository target="RProperty" uidValue="0x10207218">
     <key int="0x00000001"  ref="/KPSUidAvkonDomain/KAknKeyguardStatus"></key>
 </repository>
-<repository target="RProperty" uidValue="0x101F8767">
-    <key int="0x00000501"  ref="/KPSUidCoreApplicationUIs/KCoreAppUIsAutolockStatus"></key>
-</repository>
--- a/securitydialogs/Autolock/src/Autolock.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/securitydialogs/Autolock/src/Autolock.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -87,6 +87,12 @@
 
 _LIT( KMmTsyModuleName, "PhoneTsy");
 
+// Constant definitions to control screensaver view types
+static const char *KSnsrViewTypeKey = "view_type";
+static const int KSnsrViewTypeValueActive = 1;
+static const int KSnsrViewTypeValueStandby = 2;
+static const char *KSnsrCmdUnlock = "unlock";
+
 Autolock::Autolock(QWidget *parent, Qt::WFlags f) :
     QWidget(parent, f), mService(NULL)
     {
@@ -241,6 +247,11 @@
     connect(subscriberKProEngActiveProfile, SIGNAL(contentsChanged()), this,
             SLOT(subscriberKProEngActiveProfileChanged()));
 
+    subscriberKSecurityUIsDismissDialog = new QValueSpaceSubscriber(
+            "/KPSUidSecurityUIs/KSecurityUIsDismissDialog", this);
+    connect(subscriberKSecurityUIsDismissDialog, SIGNAL(contentsChanged()), this,
+            SLOT(subscriberKSecurityUIsDismissDialogChanged()));
+
     // subscribe to environment changes
     subscriberKHWRMGripStatus = new QValueSpaceSubscriber(
             "/KPSUidHWRM/KHWRMGripStatus");
@@ -284,13 +295,19 @@
     TryChangeStatus( ELockNotActive);
     lower();
     hide();
-    // not needed:   new AutolockService(this);
+
+    // screensaver standby mode timer
+    mScreensaverModeTimer = new QTimer( this );
+    mScreensaverModeTimer->setInterval( 5*1000 ); // milliseconds, TODO: read from cenrep
+    connect( mScreensaverModeTimer, SIGNAL(timeout()), SLOT(switchScreensaverToPowerSaveMode()) );
     }
 
 Autolock::~Autolock()
     {
     RDEBUG("0", 0);
     delete mService;
+    delete mScreensaverModeTimer;
+    RDEBUG("1", 1);
     }
 
 void Autolock::adjustInactivityTimers(int aReason)
@@ -806,26 +823,29 @@
 int Autolock::showNoteIfRequested(int aReason)
     {
     RDEBUG("aReason", aReason);
-
+		// These do nothing. The reason are:
+		// - the screensaver already displays/hides
+		// - the notes are shown behing the icon because they have lower priorities
+		// - they are annoying
     if (aReason == ELockNotActive)
         {
         if (iShowKeyguardNote == 1)
             {
-            HbDeviceMessageBox::information("Keyguard deactivated");
+            // HbDeviceMessageBox::information("Keyguard deactivated");
             }
         }
     else if (aReason == EKeyguardActive)
         {
         if (iShowKeyguardNote == 1)
             {
-            HbDeviceMessageBox::information("Keyguard activated");
+            // HbDeviceMessageBox::information("Keyguard activated");
             }
         }
     else if (aReason >= EDevicelockActive) // this doesn't happen, but we are prepared nevertheless
         {
         if (iShowKeyguardNote == 1)
             {
-            HbDeviceMessageBox::information("Devicelock activated");
+            // HbDeviceMessageBox::information("Devicelock activated");
             }
         }
     return KErrNone;
@@ -838,6 +858,8 @@
     int errorInProcess = KErrNone;
     DebugRequest(ret);
 
+		// this will cancel any previous dialog, i.e. PIN query, or any previous code-request.
+		// not sure about the screensaver, but nevertheless will be cancelled when the status is changed.
     TInt err = RProperty::Set(KPSUidSecurityUIs,
             KSecurityUIsDismissDialog,
             ESecurityUIsDismissDialogOn);
@@ -925,7 +947,7 @@
                 }
             if (errorInProcess != KErrNone)
                 { // re-lock. For example, if password is wrong
-               	if( iLockStatus >=EDevicelockActive)	// this skips the case "unlocking although it wan't locked"
+               	if( iLockStatus >=EDevicelockActive)	// this skips the case "unlocking although it wasn't locked"
                 	setLockDialog(aReason, 1);
                 }
             // this never shows a note
@@ -937,6 +959,8 @@
             DebugError(errorInProcess);
             if (errorInProcess == KErrNone)
                 {
+                // no need to dismiss screensaver, because it's not active
+                // TODO what about any PIN-query, i.e. from settings ? In this case, the query will show after the PIN query is finished. somehow this is good because PIN is more important
                 bool value = HbDeviceMessageBox::question("Enable Keyguard?");	// this doesn't block other events, so after return everything might be messed up.
                 // TODO what about a nice icon?
                 RDEBUG("value", value);
@@ -998,6 +1022,8 @@
     RDEBUG("err", err);
     RDEBUG("secUiOriginatedQuery", secUiOriginatedQuery);
 
+		RWindowGroup& groupWin = CEikonEnv::Static()->RootWin();
+		
     if (status == 0) // hide
         {
         // secUiOriginatedQuery should be ESecurityUIsSystemLockOriginated . If not, this is not correctly setting it
@@ -1011,6 +1037,11 @@
                     KSecurityUIsSecUIOriginatedQuery,
                     ESecurityUIsSecUIOriginatedUninitialized);
             RDEBUG("err", err);
+            // Cancel power key and application key capturing
+            groupWin.CancelCaptureKey( mPowerKeyCaptureHandle );
+            groupWin.CancelCaptureKey( mApplicationKeyCaptureHandle );
+            groupWin.CancelCaptureLongKey( mApplicationLongKeyCaptureHandle );
+            RDEBUG("done CancelCaptureKey", 1);
             }
         }
     else if (status == 1) // show
@@ -1035,6 +1066,8 @@
             {
             RDEBUG("creating iDeviceDialog", 0);
             iDeviceDialog = new HbDeviceDialog(HbDeviceDialog::NoFlags, this);
+            connect( iDeviceDialog, SIGNAL(dataReceived(QVariantMap)), 
+                     SLOT(handleMessageFromScreensaver(QVariantMap)) );
             iDeviceDialogCreated = 1;
             }
         else
@@ -1045,19 +1078,39 @@
             RDEBUG("err", err);
             iDeviceDialogCreated = 2;
             }
-        const QString KSecQueryUiDeviceDialog("com.nokia.secuinotificationdialog/1.0");
+        const QString KScreensaverDeviceDialog("com.nokia.screensaver.snsrdevicedialogplugin/1.0");
         RDEBUG("pre show", aReason);
-        err = iDeviceDialog->show(KSecQueryUiDeviceDialog, params); // and continue processing
+        err = iDeviceDialog->show(KScreensaverDeviceDialog, params); // and continue processing
         RDEBUG("post show. err", err);
         err = iDeviceDialog->error();
-        RDEBUG("err", err);
+        RDEBUG("iDeviceDialog->error", err);
+        if(!err)
+        	{
+        	switchScreensaverToActiveMode();	// TODO not sure if this is needed
+        	}
+        else	// some err
+        	{
+        		// screensaver has failed. Probably because it's not installed. Then, try the standard lock-icon
+        	err = iDeviceDialog->error();
+        	RDEBUG("err", err);
+        	const QString KSecQueryUiDeviceDialog("com.nokia.secuinotificationdialog/1.0");
+        	err = iDeviceDialog->show(KSecQueryUiDeviceDialog, params); // and continue processing
+        	}
+      	err = iDeviceDialog->error();
+      	RDEBUG("err", err);
         // This won't be needed when screensaver is in place, as the dialogs will be different, and therefore both can be present
         // Somehow this should be handled by Orbit, but unfortunatelly they don't allow the same dialog twice
         err = RProperty::Set(KPSUidSecurityUIs,
                 KSecurityUIsSecUIOriginatedQuery,
                 ESecurityUIsSecUIOriginatedUninitialized);	// TODO this should be ESecurityUIsSystemLockOriginated ?
         RDEBUG("err", err);
-
+        // Capture power and application keys while screen saver is open
+        mPowerKeyCaptureHandle = groupWin.CaptureKey( EKeyDevice2, 0, 0 );
+        mApplicationKeyCaptureHandle = groupWin.CaptureKey( EKeyApplication0, 0, 0 );
+        mApplicationLongKeyCaptureHandle = groupWin.CaptureLongKey( 
+                EKeyApplication0, EKeyApplication0, 0, 0, 0, 
+                ELongCaptureShortEventImmediately|ELongCaptureRepeatEvents );
+				RDEBUG("keys captured", err);
         }
     else
         {
@@ -1130,6 +1183,15 @@
     if (iLockStatus == ELockNotActive) // not possible if it's keyguarded, or locked
         {
         ret = TryChangeStatus(ELockAppEnableKeyguard);
+        RDEBUG("ret", ret);
+        }
+    else
+    		{
+        // switch-off the lights. The scenario is: keyguard->screensaver->CriticalNote->lightsOn . Therefore we need lightsOff
+        // this is done when keyguard can't be enabled because it's already enabled
+        // Note that this happens only once, so it's fine to show the screensaver in full light.
+        if(ret==KErrAlreadyExists)
+        	switchScreensaverToActiveMode();
         }
     RDEBUG("ret", ret);
     }
@@ -1154,6 +1216,57 @@
 
     }
 
+void Autolock::switchScreensaverToActiveMode()
+    {
+    RDEBUG("0", 0);
+    if ( iDeviceDialog )
+        {
+        RDEBUG("got iDeviceDialog", 1);
+        QVariantMap params;
+        params.insert( KSnsrViewTypeKey, KSnsrViewTypeValueActive );
+        iDeviceDialog->update(params);
+        
+        // (re)start timer to switch to the power save mode
+        if ( mScreensaverModeTimer )
+            {
+            RDEBUG("start mScreensaverModeTimer", 0);
+            mScreensaverModeTimer->start();
+            }
+        }
+    RDEBUG("1", 1);
+    }
+
+void Autolock::switchScreensaverToPowerSaveMode()
+    {
+    RDEBUG("0", 0);
+    if ( iDeviceDialog )
+        {
+        RDEBUG("got iDeviceDialog", 1);
+        QVariantMap params;
+        params.insert( KSnsrViewTypeKey, KSnsrViewTypeValueStandby );
+        iDeviceDialog->update(params);
+        
+        if ( mScreensaverModeTimer )
+            {
+            RDEBUG("stop mScreensaverModeTimer", 0);
+            mScreensaverModeTimer->stop();
+            }
+        }
+    RDEBUG("1", 1);
+    }
+
+void Autolock::handleMessageFromScreensaver( const QVariantMap &data )
+    {
+    RDEBUG("0", 0);
+    RDEBUG("iLockStatus", iLockStatus);
+    QVariantMap::const_iterator it = data.find( KSnsrCmdUnlock );
+    if ( it != data.end() && iLockStatus != ELockNotActive )
+        {
+        RDEBUG("calling handleLockSwitch", 0);
+        handleLockSwitch();
+        }
+    }
+
 // some key is pressed
 bool Autolock::event(QEvent *ev)
     {
@@ -1167,29 +1280,38 @@
             RDEBUG("KeyPress", keyEvent->key());
             RDEBUG("KeyPress nativeScanCode", keyEvent->nativeScanCode());
             RDEBUG("EStdKeyDeviceF", EStdKeyDeviceF);
+            RDEBUG("EStdKeyDeviceF", EKeyInsert);
             RDEBUG("keyEvent->isAutoRepeat()", keyEvent->isAutoRepeat());
             if( !keyEvent->isAutoRepeat() )
             	{
-	            if ((keyEvent->key() & 0xFF) == (EKeyInsert & 0xFF))
+	            if (keyEvent->key() == EKeyInsert )
 	                {
+	                // on WINS, this is handled with the "Ins" key in the numeric keypad
 	                RDEBUG("EKeyInsert", EKeyInsert);
 	                // only reacts on release, not on press
 	                isSwitchKey = 1;
 	                }
-	            if ((keyEvent->key() & 0xFF) == (EKeyDeviceF & 0xFF))
+	            else if (keyEvent->key() == EKeyDeviceF )
 	                {
+	                // this never seem to happen. Nevertheless we are not doing anything
 	                RDEBUG("EKeyDeviceF", EKeyDeviceF);
 	                }
-	            if (keyEvent->key() == 0x1ffffff)
-	                {
-	                RDEBUG("0x1ffffff", 0x1ffffff);	// som unknown key is received. Nothing to do
-	                }
-	            if (keyEvent->nativeScanCode() == EStdKeyDeviceF)
+	            else if (keyEvent->nativeScanCode() == EStdKeyDeviceF)
 	                {
 	                RDEBUG("got EStdKeyDeviceF", EStdKeyDeviceF);
 	                isSwitchKey = 1;
 	                }
+              else if ( keyEvent->nativeScanCode() == EStdKeyApplication0 || keyEvent->nativeScanCode() == EStdKeyDevice2 )
+                {
+                // switch to active screensaver if application key or power key pressed while screensaver active
+                switchScreensaverToActiveMode();
+                }
+              else if (keyEvent->key() == 0x1ffffff)
+                {
+                RDEBUG("0x1ffffff", 0x1ffffff);	// some unknown key is received. Nothing to do
+                }
 	            }
+	           }
 	        else if (ev->type() == QEvent::KeyRelease)
 	            {
 	            QKeyEvent *keyEvent = static_cast<QKeyEvent *> (ev);
@@ -1201,37 +1323,43 @@
 	                // isSwitchKey=1; this should happen is   pressed  was not processed (hint: if it is/was in background)
 	                }
 	            }
-	           }
         RDEBUG("isSwitchKey", isSwitchKey);
         if (isSwitchKey)
             {
-            int ret = KErrNone;
-            DebugStatus( iLockStatus);
-            if (iLockStatus == ELockNotActive)
-                {
-                iShowKeyguardNote = 1; // note on enable keyguard
-                ret = TryChangeStatus(ELockAppEnableKeyguard); // this should not ask confirmation
-                }
-            else if (iLockStatus == EKeyguardActive)
-                {
-                iShowKeyguardNote = 1; // note on disable keyguard
-                ret = TryChangeStatus(ELockAppDisableKeyguard);
-                }
-            else if (iLockStatus == EDevicelockActive)
-                {
-                ret = TryChangeStatus(ELockAppDisableDevicelock);
-                }
-            else
-                {
-                RDEBUG("unknown iLockStatus", iLockStatus);
-                }
-            RDEBUG("ret", ret);
+            handleLockSwitch();
+            RDEBUG("0", 0);
             } // isSwitchKey
         } // ev
     // Process if not done before. For example, redraw or quit
     return QWidget::event(ev);
     }
 
+void Autolock::handleLockSwitch()
+    {
+    
+    int ret = KErrNone;
+    DebugStatus( iLockStatus);
+    if (iLockStatus == ELockNotActive)
+        {
+        iShowKeyguardNote = 1; // note on enable keyguard
+        ret = TryChangeStatus(ELockAppEnableKeyguard); // this should not ask confirmation
+        }
+    else if (iLockStatus == EKeyguardActive)
+        {
+        iShowKeyguardNote = 1; // note on disable keyguard
+        ret = TryChangeStatus(ELockAppDisableKeyguard);
+        }
+    else if (iLockStatus == EDevicelockActive)
+        {
+        ret = TryChangeStatus(ELockAppDisableDevicelock);
+        }
+    else
+        {
+        RDEBUG("unknown iLockStatus", iLockStatus);
+        }
+    RDEBUG("ret", ret);
+    }
+
 bool Autolock::eventFilter(QObject *o, QEvent *ev)
     {
     // this never happens
@@ -1312,7 +1440,14 @@
           }
     	}
     }
-
+// SecUiNotificationDialog::subscriberKSecurityUIsDismissDialogChanged()
+// A way for Autolock to dismiss any possible PIN dialog
+// ----------------------------------------------------------------------------
+//
+void Autolock::subscriberKSecurityUIsDismissDialogChanged()
+    {
+    RDEBUG("0", 0);
+		}
 // ----------AutolockService---------------
 
 AutolockService::AutolockService(Autolock* parent) :
--- a/securitydialogs/Autolock/src/Autolock.h	Fri Jun 11 14:28:40 2010 +0300
+++ b/securitydialogs/Autolock/src/Autolock.h	Wed Jun 23 19:10:54 2010 +0300
@@ -34,7 +34,6 @@
 #include <QMap>
 #include <QStringList>
 #include <xqserviceprovider.h>
-#include <xqsharablefile.h>
 #include <QToolButton>
 #include <qmobilityglobal.h>
 
@@ -65,6 +64,7 @@
 	EDevicelockTimer
 	};
 
+class QTimer;
 
 class AutolockService;
 
@@ -109,12 +109,17 @@
     void subscriberKAknKeyguardStatusChanged();
     void subscriberKCoreAppUIsAutolockStatusChanged();
     void subscriberKHWRMGripStatusChanged();
+    void subscriberKSecurityUIsDismissDialogChanged();
 
 private slots:
     void activeKeyguard();
     void notActiveKeyguard();
     void activeDevicelock();
     void notActiveDevicelock();
+    void switchScreensaverToActiveMode();
+    void switchScreensaverToPowerSaveMode();
+    void handleMessageFromScreensaver( const QVariantMap &data );
+    void handleLockSwitch();
 
 private:
     AutolockService* mService;
@@ -128,6 +133,7 @@
     QValueSpaceSubscriber *subscriberKAknKeyguardStatus;
     QValueSpaceSubscriber *subscriberKCoreAppUIsAutolockStatus;
     QValueSpaceSubscriber *subscriberKHWRMGripStatus;
+    QValueSpaceSubscriber *subscriberKSecurityUIsDismissDialog;
 
 		AutolockUserActivityService* serviceKeyguard;
 		AutolockUserActivityService* serviceDevicelock;
@@ -138,6 +144,11 @@
 		int iSecQueryUiCreated;
 		HbDeviceDialog *iDeviceDialog;
 		int iDeviceDialogCreated;
+    TInt32 mPowerKeyCaptureHandle;
+    TInt32 mApplicationKeyCaptureHandle;
+    TInt32 mApplicationLongKeyCaptureHandle;
+    
+    QTimer *mScreensaverModeTimer;
 };
 
 class AutolockService : public XQServiceProvider
--- a/securitydialogs/SecUi/Inc/SecQueryUi.h	Fri Jun 11 14:28:40 2010 +0300
+++ b/securitydialogs/SecUi/Inc/SecQueryUi.h	Wed Jun 23 19:10:54 2010 +0300
@@ -25,6 +25,7 @@
 #include <e32property.h>
 
 #define ESecUiTypeMask  0x0FFFFFF
+#define ESecUiBasicTypeMask    0x00F0000
 
 #define ESecUiCancelSupported  0x1000000
 #define ESecUiCancelNotSupported  0x0000000
@@ -38,6 +39,9 @@
 #define ESecUiSecretSupported  0x8000000
 #define ESecUiSecretNotSupported  0x0000000
 
+#define ESecUiBasicTypeCheck   0x0010000
+#define ESecUiBasicTypeMultiCheck   0x0020000
+
 class MSecQueryUiCertificateDetailsProvider;
 class MSecQueryUiDrmDetailsProvider;
 class CHbDeviceDialogSymbian;
@@ -81,6 +85,8 @@
  * @lib SecQueryUi.lib
  * @since 10.1
  */
+typedef TBuf<80> TSecUiPassword;
+
 class CSecQueryUi : public CActive, public MHbDeviceDialogObserver
     {
     public:  // constructor and destructor
@@ -234,7 +240,8 @@
         TInt iCompletionCode;
         TInt iReturnValue;
 public:
-	      TSecUiPassword iPassword;
+	   // previoulsy it was RMobilePhone::TMobilePassword iPassword; but this was only 10 bytes
+        TSecUiPassword iPassword;
     };
 
 
--- a/securitydialogs/SecUi/Src/SecQueryUi.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/securitydialogs/SecUi/Src/SecQueryUi.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -101,10 +101,15 @@
     RDEBUG("secUiOriginatedQuery", secUiOriginatedQuery);
     if (secUiOriginatedQuery != ESecurityUIsSecUIOriginatedUninitialized)
         {
+        RDEBUG("!!!! warning: secUiOriginatedQuery", secUiOriginatedQuery);
         // The query is already shown. This is valid for ESecurityUIsSecUIOriginated, and maybe for ESecurityUIsETelAPIOriginated
         // For ESecurityUIsSystemLockOriginated it means that the "lock" dialog is already present.
-        // What to do? Can't dismiss the dialog because it's not owned. Can't device-unlock without asking code. Only can disable keyguard
-        RDEBUG("!!!! warning: secUiOriginatedQuery", secUiOriginatedQuery);
+        // Try to dismiss the dialog. Do same as CSecurityHandler::CancelSecCodeQuery
+        TInt aDismissDialog = -1;
+        err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsDismissDialog, aDismissDialog);
+        // it might happen that the dialog is already dismissing. Well, it won't harm to try again.
+        RDEBUG("aDismissDialog", aDismissDialog);
+        err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogOn);
         }
     else
         {
@@ -114,7 +119,7 @@
                 ESecurityUIsETelAPIOriginated);
         RDEBUG("setting secUiOriginatedQuery", ESecurityUIsETelAPIOriginated);
         }
-
+		RDEBUG("calling ClearParamsAndSetNoteTypeL aMode=", aMode);
     ClearParamsAndSetNoteTypeL(aMode);
     AddParamL(_L("KSecQueryUiApplicationName"), aCaption);
 
@@ -124,9 +129,24 @@
     AddParamL(_L("MinLength"), aMinLength);
     AddParamL(_L("MaxLength"), aMaxLength);
 
-    _LIT(KCodeTop, "codeTop");
-    _LIT(KCodeTopValue, "codeTop");
-    AddParamL(KCodeTop, KCodeTopValue);
+// ESecUiBasicTypeMultiCheck
+
+    switch (aMode & ESecUiBasicTypeMask) {
+    case ESecUiBasicTypeCheck:
+                             _LIT(KChecboxDialog, "ChecboxDialog");
+                             _LIT(KChecbox, "ChecboxDialog");
+                             AddParamL(KChecboxDialog,KChecbox);
+                             break;
+    case ESecUiBasicTypeMultiCheck:
+                            _LIT(KMultiChecboxDialog, "MultiChecboxDialog");
+                            _LIT(KMultiChecbox, "MultiChecboxDialog");
+                            AddParamL(KMultiChecboxDialog,KMultiChecbox);
+                            break;
+    default:
+                            _LIT(KCodeTop, "codeTop");
+                            _LIT(KCodeTopValue, "codeTop");
+                            AddParamL(KCodeTop, KCodeTopValue);
+    }
 
     if (aCaption.Find(_L("|")) > 0)
         {
@@ -144,10 +164,12 @@
 
     RDEBUG("0", 0);
     DisplayDeviceDialogL();
+    TSecUi::UnInitializeLib();	// the counterpart is at DisplayDeviceDialogL
     TInt error = WaitUntilDeviceDialogClosed();
     RDEBUG("error", error);
     User::LeaveIfError(error);
-
+    RDEBUG("iPassword", 0);
+		RDebug::Print(iPassword);
     aDataText.Copy(iPassword);
 
     err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery,
@@ -520,14 +542,6 @@
     iVariantMap->Add(aKey, variant);
     }
 
-TInt strlen(const char* aStr)
-    {
-    TInt len = 0;
-    while (*aStr++ != 0)
-        ++len;
-    return len;
-    }
-
 // ---------------------------------------------------------------------------
 // CSecQueryUi::DisplayDeviceDialogL()
 // ---------------------------------------------------------------------------
@@ -535,19 +549,26 @@
 void CSecQueryUi::DisplayDeviceDialogL()
     {
     RDEBUG("0", 0);
+    TInt err = KErrNone;
+    RDEBUG("iIsDisplayingDialog", iIsDisplayingDialog);
     if (iDeviceDialog && iIsDisplayingDialog)
         {
+    		RDEBUG("iDeviceDialog", 1);
         iDeviceDialog->Update(*iVariantMap);
         }
     else
         {
+    		RDEBUG("!iDeviceDialog", 0);
         if (!iDeviceDialog)
             {
+            RDEBUG("new iDeviceDialog", 0);
             iDeviceDialog = CHbDeviceDialogSymbian::NewL();
             }
         _LIT(KSecQueryUiDeviceDialog, "com.nokia.secuinotificationdialog/1.0");
         RDEBUG("Show", 0);
-        iDeviceDialog->Show(KSecQueryUiDeviceDialog, *iVariantMap, this);
+        err = iDeviceDialog->Show(KSecQueryUiDeviceDialog, *iVariantMap, this);
+        RDEBUG("err", err);
+        TSecUi::InitializeLibL();
         RDEBUG("iIsDisplayingDialog", iIsDisplayingDialog);
         iIsDisplayingDialog = ETrue;
         RDEBUG("iIsDisplayingDialog", iIsDisplayingDialog);
@@ -566,6 +587,7 @@
     iReturnValue = KErrUnknown;
     if (!IsActive() && iWait && !iWait->IsStarted())
         {
+        RDEBUG("KRequestPending", KRequestPending);
         iStatus = KRequestPending;
         SetActive();
         RDEBUG("Start", 0);
--- a/securitydialogs/SecUi/Src/SecUi.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/securitydialogs/SecUi/Src/SecUi.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -39,6 +39,7 @@
         TSecUi* instance=(TSecUi*) Dll::Tls();
         instance->IncreaseClientCount();
         instance->iDialogOpened++;
+        RDEBUG("instance->iDialogOpened", instance->iDialogOpened);
         return;
     }
     RDEBUG("First initialization", 0);
@@ -58,8 +59,12 @@
 //
 EXPORT_C void TSecUi::UnInitializeLib()
 	{
+    RDEBUG("0", 0);
     if (Dll::Tls()==NULL)
+    		{
+    		RDEBUG("!!!!!!!!!! Dll::Tls not yet initialized: 0", 0);
         return;
+      	}
     RDEBUG("0", 0);
 	TSecUi* instance=(TSecUi*) Dll::Tls();
     instance->DecreaseClientCount();
@@ -98,6 +103,7 @@
 //
 void TSecUi::ConstructL()
 	{
+		RDEBUG("iClientCount", iClientCount);
     iClientCount = 0;
 	}
 
--- a/securitydialogs/SecUi/Src/SecUiSecurityHandler.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/securitydialogs/SecUi/Src/SecUiSecurityHandler.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -29,6 +29,7 @@
 #include <centralrepository.h> 
 #include <starterclient.h>     //used for RemoveSplashScreen
 #include <e32property.h>
+
 #include <PSVariables.h>   // Property values
 #include <coreapplicationuisdomainpskeys.h>
 #include <startupdomainpskeys.h>
@@ -351,6 +352,10 @@
 // qtdone
 EXPORT_C void CSecurityHandler::CancelSecCodeQuery()
     {
+		RDEBUG("0", 0);
+		// notify all dialogs, in particular SecUiNotificationDialog::subscriberKSecurityUIsDismissDialogChanged
+    TInt err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogOn );
+    RDEBUG("err", err);
 		RDEBUG("iQueryCanceled", iQueryCanceled);
     if (!iQueryCanceled)
         {
@@ -580,7 +585,7 @@
     RDEBUG("err", err);
     if (!StartUp)
     		{
-    		RDebug::Printf( "%s %s (%u) Leaving because StartUp=0 and err=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, err );
+    		RDebug::Printf( "%s %s (%u) might leave if StartUp=0 and err=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, err );
         User::LeaveIfError(err);
       	}
     TBool isConditionSatisfied = EFalse;
@@ -844,14 +849,14 @@
         case KErrGsm0707IncorrectPassword:
         case KErrAccessDenied:
             RDEBUG("KErrAccessDenied", KErrAccessDenied);
-            // TODO should this try again? It seems that it's not asked again.
+            // The Settings caller might retry
             CSecuritySettings::ShowResultNoteL(R_CODE_ERROR,
                     CAknNoteDialog::EErrorTone);
             break;
         default:
             RDEBUG("default", status);
             CSecuritySettings::ShowErrorNoteL(status);
-            // TODO should this try again? It seems that it's not asked again.
+            // The Settings caller might retry
             break;
         }
     RDEBUG("returnValue", returnValue);
--- a/securitydialogs/SecUi/Src/SecUiSecuritySettings.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/securitydialogs/SecUi/Src/SecUiSecuritySettings.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -1397,8 +1397,13 @@
     RDEBUG("aResourceID", aResourceID);
     RDebug::Print(titleTr);
 
-    _LIT(KIconName, "qtg_small_smiley_wondering");
-    messageBox->SetIconNameL(KIconName);
+    _LIT(KIconNameWondering, "qtg_small_smiley_wondering");
+    _LIT(KIconNameSmile, "qtg_small_smiley_smile");
+    if(aResourceID==0 || aResourceID==R_CONFIRMATION_NOTE)
+    	messageBox->SetIconNameL(KIconNameSmile);
+    else
+    	messageBox->SetIconNameL(KIconNameWondering);
+
     if (aTone == CAknNoteDialog::EErrorTone) // another case is EConfirmationTone
         {
         messageBox->SetTimeout(messageBox->Timeout() * 2); // errors are displayed double time
--- a/securitydialogs/SecUi/group/SecUi.mmp	Fri Jun 11 14:28:40 2010 +0300
+++ b/securitydialogs/SecUi/group/SecUi.mmp	Wed Jun 23 19:10:54 2010 +0300
@@ -55,6 +55,7 @@
 SOURCE  ../Src/SecUiWait.cpp
 SOURCE  ../Src/SecQueryUi.cpp
 
+// library avkon.lib  eikdlg.lib 
 library     euser.lib
 library     etel.lib etelmm.lib
 library     commonengine.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/securitydialogs/lockapp/src/lockapp.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2000 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: Very small version of lockapp, which simply launches Autolock
+ * This is needed becauses starter has the hardcoded name "lockapp"
+ *
+ */
+
+// INCLUDES
+
+#include <e32svr.h>
+#include <centralrepository.h>
+
+#include <aknglobalpopupprioritycontroller.h>
+#include <apgcli.h>
+#include <apgtask.h>
+#include <eikenv.h>
+#include <e32property.h>
+#include <secuisecuritysettings.h>
+#include <coreapplicationuisdomainpskeys.h>
+
+// ----------------------------------------------------------------------------------------
+// Server startup code
+// ----------------------------------------------------------------------------------------
+static void RunServerL()
+    {
+    CActiveScheduler* s = new (ELeave) CActiveScheduler;
+    CleanupStack::PushL(s);
+    CActiveScheduler::Install(s);
+
+    // start autolock instead of lockapp . This is a backup solution to use in case that not all SysAp and Avkon changes are implemented
+    /* No need to check the task. A process should not run twice
+     TApaTaskList taskList( CCoeEnv::Static()->WsSession() );	// can also use CCoeEnv::Static()	CEikonEnv::Static()
+     const TUid KAutolockSrvAppUid = { 0x100059B5 };
+     TApaTask task( taskList.FindApp( KAutolockSrvAppUid ) );
+     if( !task.Exists())
+     */
+
+    RApaLsSession ls;
+    User::LeaveIfError(ls.Connect());
+    CleanupClosePushL(ls);
+
+		/************/
+    _LIT_SECURITY_POLICY_C1(KWritePolicy, ECapabilityWriteDeviceData);
+    TInt ret = RProperty::Define(KPSUidCoreApplicationUIs,
+            KCoreAppUIsAutolockStatus, RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass),
+            TSecurityPolicy(TSecurityPolicy::EAlwaysPass));
+
+    TInt autolockState;
+    RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState);
+    if(autolockState==EAutolockStatusUninitialized)
+    	{
+    	autolockState = EAutolockOff;	// not-initialized means that the unlock-query hasn't been displayed. Therefore the device should not stay locked.
+    	}
+    ret = RProperty::Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus,	
+                   autolockState);	// this might re-set it. That's not bad. It will re-notify all listeners.
+    RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState);
+    RDebug::Printf("%s %s (%u) autolockState=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, autolockState);
+		/************/
+
+    CApaCommandLine* commandLine = CApaCommandLine::NewLC();
+    commandLine->SetExecutableNameL(_L("autolock.exe"));
+    commandLine->SetCommandL(EApaCommandRun);
+    // Try to launch the application.        
+    TInt err = ls.StartApp(*commandLine); // this migh fail
+    RDebug::Printf("%s %s (%u) Start: autolock.exe err=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, err);
+
+    CleanupStack::PopAndDestroy(2); // commandLine, ls
+
+    // Initialisation complete, now signal the client
+    RProcess::Rendezvous( KErrNone);
+
+    // Ready to run
+    CActiveScheduler::Start();
+
+    // Cleanup the server and scheduler
+    CleanupStack::PopAndDestroy(2);
+    }
+
+// Server process entry-point
+TInt E32Main()
+    {
+    CTrapCleanup* cleanup = CTrapCleanup::New();
+    TInt r = KErrNoMemory;
+    if (cleanup)
+        {
+        TRAP(r, RunServerL());
+        delete cleanup;
+        }
+    RDebug::Printf("%s %s (%u) r=%x", __FILE__, __PRETTY_FUNCTION__,
+            __LINE__, r);
+    return r;
+    }
+
+// End of file
--- a/securitydialogs/secuinotifications/secuinotificationdialogplugin/inc/secuinotificationcontentwidget.h	Fri Jun 11 14:28:40 2010 +0300
+++ b/securitydialogs/secuinotifications/secuinotificationdialogplugin/inc/secuinotificationcontentwidget.h	Wed Jun 23 19:10:54 2010 +0300
@@ -21,7 +21,12 @@
 #include <hbwidget.h>       // HbWidget
 #include <hblineedit.h>       // HbWidget
 
+#include <HbCheckBox>
+#include <HbListWidget>
+#include <HbListWidgetItem>
 class HbLabel;
+class HbCheckBox;
+class HbListWidget;
 
 
 class SecUiNotificationContentWidget : public HbWidget
@@ -50,6 +55,9 @@
 public:
 		HbLineEdit *codeTop;
 		HbLineEdit *codeBottom;
+        HbCheckBox *checkbox;
+        HbLabel *DialogText;
+        HbListWidget *listWidget;
     int queryType;
     int lMinLength;
     int lMaxLength;
--- a/securitydialogs/secuinotifications/secuinotificationdialogplugin/inc/secuinotificationdialog.h	Fri Jun 11 14:28:40 2010 +0300
+++ b/securitydialogs/secuinotifications/secuinotificationdialogplugin/inc/secuinotificationdialog.h	Wed Jun 23 19:10:54 2010 +0300
@@ -18,14 +18,20 @@
 #ifndef SECUINOTIFICATIONDIALOG_H
 #define SECUINOTIFICATIONDIALOG_H
 
-// #define RDEBUG( x, y ) RDebug::Printf( "%s %s (%u) %s=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, x, y );
+#include <e32debug.h>
+#ifdef _DEBUG
+#define RDEBUG( x, y ) RDebug::Printf( "%s %s (%u) %s=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, x, y );
+#else
 #define RDEBUG( x, y )
+#endif
 
 #include <hbdialog.h>                   // HbDialog
 #include <hbdevicedialoginterface.h>    // HbDeviceDialogInterface
 #include <hbwidget.h>       // HbWidget
 #include <hblineedit.h>       // HbWidget
 #include <hblabel.h>
+#include <HbCheckBox>
+#include <HbListWidget>
 
 #include <qmobilityglobal.h>
 
@@ -86,6 +92,8 @@
     QVariantMap mResultMap;
     HbLineEdit *codeTop;
     HbLineEdit *codeBottom;
+    HbCheckBox *checkBox;
+    HbListWidget *listWidget;
     HbAction *okAction;
     HbAction *cancelAction;
     HbLabel *title;
--- a/securitydialogs/secuinotifications/secuinotificationdialogplugin/inc/secuinotificationdialogpluginkeys.h	Fri Jun 11 14:28:40 2010 +0300
+++ b/securitydialogs/secuinotifications/secuinotificationdialogplugin/inc/secuinotificationdialogpluginkeys.h	Wed Jun 23 19:10:54 2010 +0300
@@ -41,6 +41,8 @@
 const QString KInvalidNewLockCode = "invalidNewLockCode";
 const QString KDefaultCode = "DefaultCode";
 
+const QString KChecboxType = "ChecboxDialog";
+const QString KMultiChecboxType = "MultiChecboxDialog";
 // Keys for the return values passed back to calling application
 const QString KResultAccepted = "accepted";         // int
 const QString KSelectedMemoryIndex = "memory";      // int
--- a/securitydialogs/secuinotifications/secuinotificationdialogplugin/rom/secuinotificationdialogplugin.iby	Fri Jun 11 14:28:40 2010 +0300
+++ b/securitydialogs/secuinotifications/secuinotificationdialogplugin/rom/secuinotificationdialogplugin.iby	Wed Jun 23 19:10:54 2010 +0300
@@ -21,6 +21,7 @@
 REM DLL
 file=ABI_DIR\UREL\secuinotificationdialogplugin.dll SHARED_LIB_DIR\secuinotificationdialogplugin.dll UNPAGED
 data=\epoc32\data\z\pluginstub\secuinotificationdialogplugin.qtplugin \resource\plugins\devicedialogs\secuinotificationdialogplugin.qtplugin
+data=\epoc32\data\z\resource\qt\crml\secuinotificationdialogplugin.qcrml \resource\qt\crml\secuinotificationdialogplugin.qcrml
 
 /* This is for testing purposes
 file=ABI_DIR\UREL\SecUiTest.exe SHARED_LIB_DIR\SecUiTest.exe
--- a/securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationcontentwidget.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationcontentwidget.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -28,6 +28,10 @@
 #include <hbinputeditorinterface.h>
 #include <QDebug>
 
+#include <HbCheckBox>  // needed for a checkbox dialog
+#include <HbListWidget>  // needed for multicheckbox dialog
+#include <HbListWidgetItem>
+#include <HbAbstractItemView>
 #include <HbEmailAddressFilter>
 
 #define ESecUiCancelSupported  0x1000000
@@ -85,6 +89,7 @@
     lMaxLength = 8;	// might be replaced later
  		queryDual=0;
  		isEmergency=0;
+       codeTop=0;
 
     // KApplicationSize
     if (parameters.contains(KQueryType)) {
@@ -265,6 +270,53 @@
 
     }
 
+    if (parameters.contains(KChecboxType)) {
+    		qDebug() << "SecUiNotificationContentWidget::KChecboxType";
+        if (parameters.contains(KDialogTitle)) {
+            //TODO position of the label is not centered
+            QString tmpText=parameters.value(KDialogTitle).toString();
+            if (tmpText.endsWith("\n"))  tmpText=tmpText.left(tmpText.length()-1);
+            DialogText= new HbLabel(tmpText);   
+            DialogText->setTextWrapping(Hb::TextWordWrap);
+            DialogText->setAlignment(Qt::AlignVCenter);
+            mainLayout->addItem(DialogText);                   
+        }
+
+        checkbox = new HbCheckBox("Caption");   
+        if (parameters.contains(KDefaultCode)) {
+    				qDebug() << "SecUiNotificationContentWidget::KDefaultCode";
+            QStringList list1 = parameters.value(KDefaultCode).toString().split("|");
+            if (!list1.isEmpty() && list1.count()==2) {
+                if (!list1[0].isNull() && !list1[0].isEmpty()) checkbox->setText(list1[0]);
+                if (!list1[1].isNull() && !list1[1].isEmpty()) checkbox->setChecked(list1[1].toInt());
+            }
+
+        }
+        mainLayout->addItem(checkbox);
+    }
+
+    if (parameters.contains(KMultiChecboxType) && parameters.contains(KDefaultCode)) 
+    	{
+ 				qDebug() << "SecUiNotificationContentWidget::KMultiChecboxType";
+        QStringList list1 = parameters.value(KDefaultCode).toString().split("1\t");
+        if (!list1.isEmpty()) {
+            listWidget = new HbListWidget();
+            for (int i = 0; (i < list1.count()); i++)
+                if (!list1[i].isEmpty() && !list1[i].isNull()) {
+                    HbListWidgetItem* modelItem = new HbListWidgetItem();
+                    modelItem->setData(QVariant(list1[i]), Qt::DisplayRole);
+                    listWidget->addItem(modelItem);  
+                }
+            listWidget->setCurrentRow(0);
+            listWidget->setSelectionMode(HbAbstractItemView::MultiSelection);
+            //listWidget->setClampingStyle(HbScrollArea::BounceBackClamping);
+            listWidget->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded);
+            listWidget->setMaximumHeight(150);
+            mainLayout->addItem(listWidget); 
+            //     delete listWidget;
+            }
+        }
+
     setLayout(mainLayout);
     }
 
--- a/securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationdialog.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationdialog.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -33,6 +33,10 @@
 
 #include <qvaluespacesubscriber.h>
 #include <qvaluespacepublisher.h>
+#define ESecUiBasicTypeText    0x0000000
+#define ESecUiBasicTypeCheck   0x0010000
+#define ESecUiBasicTypeCheckMulti   0x0020000
+#define ESecUiBasicTypeMask    0x00F0000
 
 #define ESecUiCancelSupported  0x1000000
 #define ESecUiCancelNotSupported  0x0000000
@@ -59,6 +63,15 @@
 const TUid KPSUidSecurityUIs = { 0x100059b5 };
 const TUint32 KSecurityUIsDismissDialog  = 0x00000309;
 
+enum TSecurityUIsDismissDialogValues
+    {
+    ESecurityUIsDismissDialogUninitialized = 0,
+    ESecurityUIsDismissDialogOn,
+    ESecurityUIsDismissDialogProcessing,
+    ESecurityUIsDismissDialogDone,
+    ESecurityUIsDismissDialogLastValue
+    };
+
 // ----------------------------------------------------------------------------
 // SecUiNotificationDialog::SecUiNotificationDialog()
 // ----------------------------------------------------------------------------
@@ -66,7 +79,7 @@
 SecUiNotificationDialog::SecUiNotificationDialog(
         const QVariantMap &parameters) : HbDialog(), mLastError(KNoError)
 {
-		qDebug() << "SecUiNotificationDialog::SecUiNotificationDialog";
+		RDEBUG("0", 0);
     constructDialog(parameters);
 }
 
@@ -84,7 +97,7 @@
 //
 bool SecUiNotificationDialog::setDeviceDialogParameters(const QVariantMap &parameters)
 {
-		qDebug() << "SecUiNotificationDialog::setDeviceDialogParameters";
+	 RDEBUG("0", 0);
    return constructDialog(parameters);
 }
 
@@ -94,8 +107,7 @@
 //
 int SecUiNotificationDialog::deviceDialogError() const
 {
-		qDebug() << "SecUiNotificationDialog::deviceDialogError";
-		qDebug() << mLastError;
+		RDEBUG("mLastError", mLastError);
     return mLastError;
 }
 
@@ -106,9 +118,9 @@
 void SecUiNotificationDialog::closeDeviceDialog(bool byClient)
 {
     Q_UNUSED(byClient);
-		qDebug() << "SecUiNotificationDialog::closeDeviceDialog 0";
+		RDEBUG("0", 0);
     close();
-		qDebug() << "SecUiNotificationDialog::closeDeviceDialog 1";
+		RDEBUG("mShowEventReceived", mShowEventReceived);
 
     // If show event has been received, close is signalled from hide event.
     // If not, hide event does not come and close is signalled from here.
@@ -132,9 +144,14 @@
 //
 void SecUiNotificationDialog::hideEvent(QHideEvent *event)
 {
-		qDebug() << "SecUiNotificationDialog::hideEvent";
+		RDEBUG("0", 0);
     HbDialog::hideEvent(event);
-    emit deviceDialogClosed();
+		RDEBUG("close", 0);
+		close();
+		RDEBUG("deviceDialogClosed", 0);
+		emit deviceDialogClosed();
+		RDEBUG("deviceDialogClosed", 1);
+    // old method was   emit deviceDialogClosed();
 }
 
 // ----------------------------------------------------------------------------
@@ -143,23 +160,27 @@
 //
 void SecUiNotificationDialog::showEvent(QShowEvent *event)
 {
-		qDebug() << "SecUiNotificationDialog::showEvent";
+		RDEBUG("0", 0);
     HbDialog::showEvent(event);
 
 		if(!(queryType & ESecUiTypeMaskLock))
 			{	// not for the "lock icon"
-			qDebug() << "SecUiNotificationDialog::showEvent check default";
-			if(codeTop->text().length()>0)	// there's a default value. Verify it and (might) enable OK
-				{
-				qDebug() << "SecUiNotificationDialog::showEvent checked default";
-				handleCodeTopChanged(codeTop->text());
-				}
-			// for automated testing, read a P&S and use this value as if the user typed it
+			RDEBUG("check default.1", 0);
+			if(codeTop!=NULL)
+            {
+                RDEBUG("check default.2", 0);
+                if(codeTop->text().length()>0)	// there's a default value. Verify it and (might) enable OK
+                {
+                RDEBUG("check default.3", 0);
+                handleCodeTopChanged(codeTop->text());
+                }
+            
+            }
 			const TUint32 KSecurityUIsTestCode  = 0x00000307;
 			TInt value = 0;
 			TInt err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsTestCode, value );
-			qDebug() << "SecUiNotificationDialog::faking KSecurityUIsTestCode err=" << err;
-			qDebug() << "SecUiNotificationDialog::faking value=" << value;
+			RDEBUG("KSecurityUIsTestCode err", err);
+			RDEBUG("faking value", value);
 			if(value>0 && mShowEventReceived==true)	// show happens 2 times. Dialog can be closed only the second.
 				{
 				QString myString = "";
@@ -169,7 +190,7 @@
 		    TInt err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsTestCode, 0 );	// clear after using it
 				qDebug() << "SecUiNotificationDialog::calling handleAccepted=" << myString;
 		    emit handleAccepted();
-				emit closeDeviceDialog(false);	// false means "not by client", although it's not really used
+				// handleAccepted already   emit closeDeviceDialog(false);	// false means "not by client", although it's not really used
 				}
 			}
     mShowEventReceived = true;
@@ -181,7 +202,7 @@
 //
 bool SecUiNotificationDialog::constructDialog(const QVariantMap &parameters)
     {
-		qDebug() << "SecUiNotificationDialog::constructDialog";
+		RDEBUG("0", 0);
     setTimeout(HbPopup::NoTimeout);
     setDismissPolicy(HbPopup::NoDismiss);
     setModal(true);
@@ -200,7 +221,7 @@
     				titleAttempts = titleText.right(titleText.length()-titleText.indexOf('#')-1);
     				qDebug() << "SecUiNotificationDialog::titleAttempts=" << titleAttempts;
     				int nAttempts = titleAttempts.toInt();
-    				qDebug() << "SecUiNotificationDialog::nAttempts=" << nAttempts;
+    				RDEBUG("nAttempts", nAttempts);
     				titleText = titleText.left(titleText.indexOf('#'));
     				if(nAttempts>0)
     					titleText = titleText + " attempts=" + QString::number(nAttempts);
@@ -210,12 +231,12 @@
     }
 
 	    if (parameters.contains(KEmergency)) {
-					qDebug() << "SecUiNotificationDialog::KEmergency";
+					RDEBUG("KEmergency", 1);
 	        QString emergencyText = parameters.value(KEmergency).toString();
 	        qDebug() << emergencyText;
 	        if(!emergencyText.compare("emergencyYes"))
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KEmergency emergencyYes";
+	        	RDEBUG("emergencyYes", 1);
 	        	isEmergency = 1;
 	        	okAction->setEnabled(true);
 	        	okAction->setText("Call");
@@ -223,7 +244,7 @@
 	        	}
 	        if(!emergencyText.compare("emergencyNo"))
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KEmergency emergencyNo";
+	        	RDEBUG("emergencyNo", 1);
 	        	isEmergency = 0;
 	        	okAction->setEnabled(false);	// 112 -> 1122 (=password) . This is handled by   < lMinLength 
 	        	okAction->setText("Ok");
@@ -232,107 +253,107 @@
 	    }
 	    // after TARM validation.
 	    if (parameters.contains(KInvalidNewLockCode)) {
-					qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode";
+					RDEBUG("KInvalidNewLockCode", 0);
 	        QString invalidText = parameters.value(KInvalidNewLockCode).toString();
 	        qDebug() << invalidText;
 
 	        title->setPlainText("Lock Code");	// TODO take from the original one
 	        QString invalidStr = invalidText.right(invalidText.length()-invalidText.indexOf('#')-1);
 	        int invalidNumber = invalidStr.toInt();
-	        qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode invalidNumber" << invalidNumber;
+	        RDEBUG("invalidNumber", invalidNumber);
 	        if(invalidNumber<0)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode ???";
+	        	RDEBUG("invalidNumber<0", invalidNumber );
 	        	// nothing to do
 	        	}
-			if(invalidNumber==EDeviceLockAutolockperiod)
+				if(invalidNumber==EDeviceLockAutolockperiod)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockAutolockperiod";
+	        	RDEBUG("EDeviceLockAutolockperiod", invalidNumber );
 	        	title->setPlainText("EDeviceLockAutolockperiod");
 	        	}
 	        if(invalidNumber==EDeviceLockMaxAutolockPeriod)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMaxAutolockPeriod";
+	        	RDEBUG("EDeviceLockAutolockperiod", invalidNumber );
 	        	title->setPlainText("EDeviceLockMaxAutolockPeriod");
 	        	}
 	        if(invalidNumber==EDeviceLockMinlength)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinlength";
+	        	RDEBUG("EDeviceLockMinlength", invalidNumber );
 	        	title->setPlainText("EDeviceLockMinlength");
 	        	}
 	        if(invalidNumber==EDeviceLockMaxlength)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMaxlength";
+	        	RDEBUG("EDeviceLockMaxlength", invalidNumber );
 	        	title->setPlainText("EDeviceLockMaxlength");
 	        	}
 	        if(invalidNumber==EDeviceLockRequireUpperAndLower)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockRequireUpperAndLower";
+	        	RDEBUG("EDeviceLockRequireUpperAndLower", invalidNumber );
 	        	title->setPlainText("EDeviceLockRequireUpperAndLower");
 	        	}
 	        if(invalidNumber==EDeviceLockRequireCharsAndNumbers)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockRequireCharsAndNumbers";
+	        	RDEBUG("EDeviceLockMaxlength", invalidNumber );
 	        	title->setPlainText("EDeviceLockMaxlength");
 	        	}
 	        if(invalidNumber==EDeviceLockAllowedMaxRepeatedChars)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockAllowedMaxRepeatedChars";
+	        	RDEBUG("EDeviceLockAllowedMaxRepeatedChars", invalidNumber );
 	        	title->setPlainText("EDeviceLockAllowedMaxRepeatedChars");
 	        	}
 	        if(invalidNumber==EDeviceLockHistoryBuffer)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockHistoryBuffer";
+	        	RDEBUG("EDeviceLockHistoryBuffer", invalidNumber );
 	        	title->setPlainText("EDeviceLockHistoryBuffer");
 	        	}
 	        if(invalidNumber==EDeviceLockPasscodeExpiration)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockPasscodeExpiration";
+	        	RDEBUG("EDeviceLockPasscodeExpiration", invalidNumber );
 	        	title->setPlainText("EDeviceLockPasscodeExpiration");
 	        	}
 	        if(invalidNumber==EDeviceLockMinChangeTolerance)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinChangeTolerance";
+	        	RDEBUG("EDeviceLockMinChangeTolerance", invalidNumber );
 	        	title->setPlainText("EDeviceLockMinChangeTolerance");
 	        	}
 	        if(invalidNumber==EDeviceLockMinChangeInterval)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinChangeInterval";
+	        	RDEBUG("EDeviceLockMinChangeInterval", invalidNumber );
 	        	title->setPlainText("EDeviceLockMinChangeInterval");
 	        	}
 	        if(invalidNumber==EDeviceLockDisallowSpecificStrings)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockDisallowSpecificStrings";
+	        	RDEBUG("EDeviceLockDisallowSpecificStrings", invalidNumber );
 	        	title->setPlainText("EDeviceLockDisallowSpecificStrings");
 	        	}
 	        if(invalidNumber==EDeviceLockAllowedMaxAtempts)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockAllowedMaxAtempts";
+	        	RDEBUG("EDeviceLockAllowedMaxAtempts", invalidNumber );
 	        	title->setPlainText("EDeviceLockAllowedMaxAtempts");
 	        	}
 	        if(invalidNumber==EDeviceLockConsecutiveNumbers)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockConsecutiveNumbers";
+	        	RDEBUG("EDeviceLockConsecutiveNumbers", invalidNumber );
 	        	title->setPlainText("EDeviceLockConsecutiveNumbers");
 	        	}
 	        if(invalidNumber==EDeviceLockMinSpecialCharacters)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinSpecialCharacters";
+	        	RDEBUG("EDeviceLockMinSpecialCharacters", invalidNumber );
 	        	title->setPlainText("EDeviceLockMinSpecialCharacters");
 	        	}
 	        if(invalidNumber==EDeviceLockSingleCharRepeatNotAllowed)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockSingleCharRepeatNotAllowed";
+	        	RDEBUG("EDeviceLockSingleCharRepeatNotAllowed", invalidNumber );
 	        	title->setPlainText("EDeviceLockSingleCharRepeatNotAllowed");
 	        	}
 	        if(invalidNumber==EDevicelockConsecutiveCharsNotAllowed)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDevicelockConsecutiveCharsNotAllowed";
+	        	RDEBUG("EDevicelockConsecutiveCharsNotAllowed", invalidNumber );
 	        	title->setPlainText("EDevicelockConsecutiveCharsNotAllowed");
 	        	}
 	        if(invalidNumber>=EDevicelockTotalPolicies)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDevicelockTotalPolicies";
+	        	RDEBUG("EDevicelockTotalPolicies", invalidNumber );
 	        	title->setPlainText("EDevicelockTotalPolicies");
 	        	}
 	        if(invalidNumber<0)	// everything is ok
@@ -360,7 +381,10 @@
 		queryType = content->queryType;
 		queryDual = content->queryDual;
 		isEmergency = content->isEmergency;
+    codeTop=NULL;
 		codeTop = content->codeTop;
+    checkBox = content->checkbox;
+    listWidget = content->listWidget;
 		codeBottom = content->codeBottom;
 		lMinLength = content->lMinLength;
 		lMaxLength = content->lMaxLength;
@@ -372,8 +396,7 @@
     connect(content, SIGNAL(but1Changed()), this, SLOT(handlebut1Changed()));
     connect(content, SIGNAL(but2Changed()), this, SLOT(handlebut2Changed()));
     connect(content, SIGNAL(but3Changed()), this, SLOT(handlebut3Changed()));
-		qDebug() << "SecUiNotificationDialog::queryType=";
-		qDebug() << queryType;
+		RDEBUG("queryType", queryType);
     // Buttons
     if( (queryType & ESecUiTypeMaskLock))
     	{
@@ -382,35 +405,56 @@
     	}
 
     okAction = new HbAction(tr("Ok"));
+    RDEBUG("created HbAction okAction", 1);
     okAction->setEnabled(false);	// initially the OK is disabled because codeTop is empty
+    if((queryType & ESecUiBasicTypeMask) ==ESecUiBasicTypeCheck) {
+        okAction->setEnabled(true);
+        setHeadingWidget(0); // had to remove this no multiline
+    }
+    else if ((queryType & ESecUiBasicTypeMask) ==ESecUiBasicTypeCheckMulti){
+        okAction->setEnabled(true);
+    }
+
     // setAction(okAction, QDialogButtonBox::AcceptRole);	// it's supposed to use this, when deprecated
-    setPrimaryAction(okAction);
+    // setPrimaryAction(okAction);
+    addAction(okAction);
+    disconnect(okAction, SIGNAL(triggered()), this, SLOT(close()));	// the close will be done in handleAccepted
     connect(okAction, SIGNAL(triggered()), this, SLOT(handleAccepted()));
     
     cancelAction = new HbAction(tr("Cancel"));    // qtTrId("txt_common_button_cancel")
+    addAction(cancelAction);
+    disconnect(cancelAction, SIGNAL(triggered()), this, SLOT(close()));	// the close will be done in handleCancelled
     connect(cancelAction, SIGNAL(triggered()), this, SLOT(handleCancelled()));
     // setAction(cancelAction, QDialogButtonBox::RejectRole);		// it's supposed to use this, when deprecated
-    setSecondaryAction(cancelAction);
+    // setSecondaryAction(cancelAction);
 
 		// this should had been set by Autolock, but just to be sure
     TInt ret = RProperty::Define(KPSUidSecurityUIs, KSecurityUIsDismissDialog,
             RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass),
             TSecurityPolicy(TSecurityPolicy::EAlwaysPass));
     RDEBUG("defined KSecurityUIsDismissDialog", ret);
+    TInt aDismissDialog = -1;
+    ret = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsDismissDialog, aDismissDialog );
+    RDEBUG("ret", ret);
+    RDEBUG("aDismissDialog", aDismissDialog);
+    if(aDismissDialog==ESecurityUIsDismissDialogOn || aDismissDialog==ESecurityUIsDismissDialogProcessing)
+    	{
+    	RDebug::Printf( "potential error: %s %s (%u) aDismissDialog=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aDismissDialog );
+    	}
     subscriberKSecurityUIsDismissDialog = new QValueSpaceSubscriber(
             "/KPSUidSecurityUIs/KSecurityUIsDismissDialog", this);
     connect(subscriberKSecurityUIsDismissDialog, SIGNAL(contentsChanged()), this,
             SLOT(subscriberKSecurityUIsDismissDialogChanged()));
-	qDebug() << "subscribed to KSecurityUIsDismissDialog";
+		RDEBUG("subscriberKSecurityUIsDismissDialog", 1);
 	
-		qDebug() << "SecUiNotificationDialog check Cancel";
+		RDEBUG("check cancel", 0);
     if ((queryType & ESecUiCancelSupported)==ESecUiCancelSupported)
     	{
     		// nothing to do. Cancel is enabled by default
     	}
   	else
   		{
-				qDebug() << "disable Cancel";
+				RDEBUG("disable Cancel", 1);
   			cancelAction->setEnabled(false);
   		}
     
@@ -423,14 +467,14 @@
 //
 void SecUiNotificationDialog::sendResult(int accepted)
 {
-		qDebug() << "SecUiNotificationDialog::sendResult 1.2";
+		RDEBUG("0", 0);
     QVariant acceptedValue(accepted);
-		qDebug() << "SecUiNotificationDialog::sendResult 2";
+		RDEBUG("0", 0);
     mResultMap.insert(KResultAccepted, acceptedValue);
-		qDebug() << "SecUiNotificationDialog::sendResult 3";
+		RDEBUG("0", 0);
 		qDebug() << mResultMap;
     emit deviceDialogData(mResultMap);
-		qDebug() << "SecUiNotificationDialog::sendResult end";
+		RDEBUG("0", 0);
 }
 
 // ----------------------------------------------------------------------------
@@ -439,21 +483,40 @@
 //
 void SecUiNotificationDialog::handleAccepted()
 {
-		qDebug() << "SecUiNotificationDialog::handleAccepted";
+		RDEBUG("0", 0);
 		// okAction
-		QString codeTopText;
+		QString codeTopText="";
 
 		if( (queryType & ESecUiTypeMaskLock))
     	{
     	codeTopText = "Unlock-Request";
     	}
-    else
+    else if( (queryType & ESecUiBasicTypeMask)==ESecUiBasicTypeCheck)
+    	{
+        codeTopText=(checkBox->isChecked() ?  "1":"0");
+        mResultMap.insert(KCodeTopIndex,  codeTopText);
+    	}
+    else if( (queryType & ESecUiBasicTypeMask)==ESecUiBasicTypeCheckMulti)
     	{
-    	codeTopText = codeTop->text();
+        QItemSelectionModel *selectionModel = listWidget->selectionModel();
+        QModelIndexList selectedItems = selectionModel->selectedIndexes();
+        QModelIndex index;
+        codeTopText="";
+         foreach(index, selectedItems) { 
+		 		 codeTopText+=QString::number(index.row());
+                //could also use  if(index.row()!=selectedItems.count()-1) codeTopText+= "|";
+                codeTopText+= "|";
+                }
+         mResultMap.insert(KCodeTopIndex,  codeTopText);
     	}
+    else
+        codeTopText = codeTop->text();
     // TODO check last time for codeBottom
    	qDebug() << "codeTopText=" << codeTopText;
     sendResult(KErrNone);
+    close();	// this is needed because Cancel doesn't automatically closes the dialog
+		RDEBUG("close", 0);
+		emit deviceDialogClosed();
 }
 
 // ----------------------------------------------------------------------------
@@ -462,8 +525,11 @@
 //
 void SecUiNotificationDialog::handleCancelled()
 {
-		qDebug() << "SecUiNotificationDialog::handleCancelled";
+		RDEBUG("0", 0);
     sendResult(KErrCancel);
+    close();	// this is needed because Cancel doesn't automatically closes the dialog
+		RDEBUG("close", 0);
+		emit deviceDialogClosed();
 }
 
 // ----------------------------------------------------------------------------
@@ -472,7 +538,7 @@
 //
 void SecUiNotificationDialog::handleMemorySelectionChanged(const QString &text)
     {
-    	qDebug() << "SecUiNotificationDialog::handleMemorySelectionChanged";
+		RDEBUG("0", 0);
     	qDebug() << text;
     QVariant memorySelection(text);
     mResultMap.insert(KSelectedMemoryIndex, memorySelection);
@@ -482,7 +548,7 @@
 
 void SecUiNotificationDialog::handleCodeTopContentChanged()
     {
-    	qDebug() << "SecUiNotificationDialog::handleCodeTopContentChanged";
+		RDEBUG("0", 0);
     	qDebug() << codeTop->text();
     	handleCodeTopChanged(codeTop->text());
     }
@@ -493,7 +559,7 @@
 //
 void SecUiNotificationDialog::handleCodeTopChanged(const QString &text)
     {
-    	qDebug() << "SecUiNotificationDialog::handleCodeTopChanged";
+		RDEBUG("0", 0);
     	qDebug() << "SecUiNotificationDialog::handleCodeTopChanged=" << text ;
     	if(queryDual)
     		{
@@ -501,19 +567,19 @@
     		}
     	if( queryType == 0x1000004 )	// new codeLock
     		{	// ChangeSecCodeParamsL change RMobilePhone::ESecurityCodePhonePassword
-			    QVariant codeTop(text);
-			    mResultMap.insert(KCodeTopIndex, codeTop);
+			    QVariant codeTopVar(text);
+			    mResultMap.insert(KCodeTopIndex, codeTopVar);
 					sendResult(KErrCompletion);	// send the current password back to the client for further TARM validation. This is done on any key-press, not in the OK
     		}
     	if(text.length() < lMinLength )
     		{
     		qDebug() << "SecUiNotificationDialog::handleCodeTopChanged too short:" << text ;
     		okAction->setEnabled(false);
-
+				RDEBUG("lEmergencySupported", lEmergencySupported);
 				if( lEmergencySupported && text.length() > 2 )	// emergency numbers need at least 3 digits
 					{	// check whether it's a emergency number
-					QVariant codeTop(text);
-  				mResultMap.insert(KCodeTopIndex, codeTop);
+					QVariant codeTopVar(text);
+  				mResultMap.insert(KCodeTopIndex, codeTopVar);
 					sendResult(KErrAbort);	// send the current password back to the client. Perhaps it's an emergency number and decides to Ok->Call
 					}
     		}
@@ -525,8 +591,8 @@
     		if(queryDual==0)	// only if Bottom is not used
     			okAction->setEnabled(true);
     		}
-    QVariant codeTop(text);
-    mResultMap.insert(KCodeTopIndex, codeTop);
+    QVariant codeTopVar(text);
+    mResultMap.insert(KCodeTopIndex, codeTopVar);
     }
 // ----------------------------------------------------------------------------
 // SecUiNotificationDialog::handleCodeBottomChanged()
@@ -534,7 +600,7 @@
 //
 void SecUiNotificationDialog::handleCodeBottomChanged(const QString &text)
     {
-    	qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged";
+		RDEBUG("0", 0);
     	qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged" << text ;
     	qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged. codeTop=" << codeTop->text() ;
     	// TODO compare 
@@ -566,7 +632,7 @@
 //
 void SecUiNotificationDialog::handlebut1Changed()
     {
-    	qDebug() << "SecUiNotificationDialog::handlebut1Changed";
+		RDEBUG("0", 0);
     	codeTop->setText("1234");
     }
 // ----------------------------------------------------------------------------
@@ -575,7 +641,7 @@
 //
 void SecUiNotificationDialog::handlebut2Changed()
     {
-    	qDebug() << "SecUiNotificationDialog::handlebut2Changed";
+		RDEBUG("0", 0);
     	QString codeTopText = codeTop->text();
     	qDebug() << "codeTopText";
     	qDebug() << codeTopText;
@@ -617,14 +683,6 @@
 //
 void SecUiNotificationDialog::subscriberKSecurityUIsDismissDialogChanged()
     {
-enum TSecurityUIsDismissDialogValues
-    {
-    ESecurityUIsDismissDialogUninitialized = 0,
-    ESecurityUIsDismissDialogOn,
-    ESecurityUIsDismissDialogProcessing,
-    ESecurityUIsDismissDialogDone,
-    ESecurityUIsDismissDialogLastValue
-    };
 
     RDEBUG("0", 0);
     TInt aDismissDialog = ESecurityUIsDismissDialogUninitialized;
@@ -636,10 +694,14 @@
 		err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogProcessing );
 		RDEBUG("err", err);
 		// TODO perhaps do this only if Cancel is allowed?
-		RDEBUG("sendResult(KErrDied)", 0);
-		sendResult(KErrDied);	// similar to     emit handleCancelled();
+		RDEBUG("sendResult(KErrCancel)", KErrCancel);	// another option is KErrDied
+		sendResult(KErrCancel);	// similar to     emit handleCancelled();
+		RDEBUG("close", 0);
+		close();
 		RDEBUG("emit closeDeviceDialog", 0);
-		emit closeDeviceDialog(false);	// false means "not by client", although it's not really used
+		emit deviceDialogClosed();
+		// RDEBUG("emit closeDeviceDialog", 0);
+		// this is old method    emit closeDeviceDialog(false);	// false means "not by client", although it's not really used
 		RDEBUG("all emited", 0);
 		err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogDone );	// clear after using it
 		RDEBUG("err", err);
--- a/securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationdialogplugin.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationdialogplugin.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -19,6 +19,8 @@
 #include "secuinotificationdialog.h"
 #include "secuinotificationdialogpluginkeys.h"
 
+#include <etelmm.h>
+
 // This plugin implements one device dialog type
 static const struct {
     const char *mTypeString;
@@ -50,6 +52,7 @@
 bool SecUiNotificationDialogPlugin::accessAllowed(const QString &deviceDialogType,
     const QVariantMap &parameters, const QVariantMap &securityInfo) const
 {
+		RDEBUG("0", 0);
     Q_UNUSED(deviceDialogType)
     Q_UNUSED(parameters)
     Q_UNUSED(securityInfo)
@@ -67,6 +70,7 @@
     const QString &deviceDialogType, const QVariantMap &parameters)
 {
     //  Create device dialog widget
+    RDEBUG("0", 0);
     Q_UNUSED(deviceDialogType)
 
     SecUiNotificationDialog *deviceDialog = new SecUiNotificationDialog(parameters);
@@ -86,15 +90,39 @@
 bool SecUiNotificationDialogPlugin::deviceDialogInfo( const QString &deviceDialogType,
         const QVariantMap &parameters, DeviceDialogInfo *info) const
 {
-    // Return device dialog flags
+		// For some unknown reason, this function doesn't print the signature 
+		RDEBUG("0", 0);
+		#ifdef _DEBUG
+		RDebug::Printf( "SecUiNotificationDialogPlugin::deviceDialogInfo=%x", 0 );
+		#endif
+
     Q_UNUSED(deviceDialogType);
-    Q_UNUSED(parameters);
 
-    //info->group = DeviceNotificationDialogGroup;	// TODO this should be SecurityGroup , but it's still not available, Commented out by 10.1 Integration
-	info->group = SecurityGroup;	// Added by 10.1 Integration... It's working better with this layer.
+		info->group = SecurityGroup;
     info->flags = NoDeviceDialogFlags;
     info->priority = DefaultPriority;
 
+		// The unlock-query must have higher priority, to get over Telephony.
+		if (parameters.contains(KQueryType)) {
+				#ifdef _DEBUG
+				RDebug::Printf( "SecUiNotificationDialogPlugin::deviceDialogInfo KQueryType=%x", 1 );
+				#endif
+        int iqueryType = parameters.value(KQueryType).toUInt();
+        RDEBUG("iqueryType", iqueryType);
+				#ifdef _DEBUG
+				RDebug::Printf( "SecUiNotificationDialogPlugin::deviceDialogInfo iqueryType=%x", iqueryType );
+				#endif
+				if( (iqueryType & 0xFFFF) == RMobilePhone::ESecurityCodePhonePassword )
+					{
+					RDEBUG("CriticalGroup", CriticalGroup);
+					#ifdef _DEBUG
+					RDebug::Printf( "SecUiNotificationDialogPlugin::deviceDialogInfo CriticalGroup=%x", CriticalGroup );
+					#endif
+					info->group = CriticalGroup;
+					}
+				}
+    // Return device dialog flags
+
     return true;
 }
 
@@ -104,6 +132,7 @@
 //
 QStringList SecUiNotificationDialogPlugin::deviceDialogTypes() const
 {
+		RDEBUG("0", 0);
     // Return device dialog types this plugin implements
 
     QStringList types;
@@ -121,6 +150,7 @@
 //
 HbDeviceDialogPlugin::PluginFlags SecUiNotificationDialogPlugin::pluginFlags() const
 {
+		RDEBUG("0", 0);
     // Return plugin flags
     return NoPluginFlags;
 }
@@ -131,6 +161,7 @@
 //
 int SecUiNotificationDialogPlugin::error() const
 {
+		RDEBUG("mError", mError);
     // Return last error
     return mError;
 }