Revision: 201019
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 27 May 2010 13:44:17 +0300
changeset 22 6b63ca65093a
parent 19 098e361762d2
child 26 aad866c37519
Revision: 201019 Kit: 2010121
cpsecplugins/cpadvancedsecplugin/inc/cpcertpluginloader.h
cpsecplugins/cpadvancedsecplugin/inc/cpcertview.h
cpsecplugins/cpadvancedsecplugin/inc/cpsecurityview.h
cpsecplugins/cpadvancedsecplugin/src/cpcertpluginloader.cpp
cpsecplugins/cpadvancedsecplugin/src/cpcertview.cpp
cpsecplugins/cpadvancedsecplugin/src/cpsecurityview.cpp
cpsecplugins/cpsecplugins.pro
cpsecplugins/devicelockplugin/devicelockplugin.pri
cpsecplugins/devicelockplugin/devicelockplugin.pro
cpsecplugins/devicelockplugin/rom/devicelockplugin.iby
cpsecplugins/devicelockplugin/src/cpdevicelockpluginview.cpp
cpsecplugins/devicelockplugin/src/debug.h
cpsecplugins/simpincodeplugin/rom/pincodeplugin.iby
cpsecplugins/simpincodeplugin/src/cppincodepluginview.cpp
gba/data/gba_license.txt
gba/sis/gba.pkg
securitydialogs/Autolock/PubSub/SecurityUIsPrivatePSKeys.h
securitydialogs/AutolockSrv/autolocksrv.qcrml
securitydialogs/AutolockSrv/rom/AutolockSrv.iby
securitydialogs/AutolockSrv/src/AutolockSrv.cpp
securitydialogs/AutolockSrv/src/AutolockSrv.h
securitydialogs/SecUi/Src/SecQueryUi.cpp
securitydialogs/SecUi/Src/SecUiManualSecuritySettings.cpp
securitydialogs/SecUi/Src/SecUiSecurityHandler.cpp
securitydialogs/SecUi/Src/SecUiSecuritySettings.cpp
securitydialogs/Securitynotifier/Src/SecurityNotifier.cpp
securitydialogs/lockapp/pubsub/SecurityUIsPrivatePSKeys.h
securitydialogs/lockapp/src/lockappappui.cpp
securitydialogs/secuinotifications/secuinotificationdialogplugin/inc/secuinotificationdialog.h
securitydialogs/secuinotifications/secuinotificationdialogplugin/secuinotificationdialogplugin.pro
securitydialogs/secuinotifications/secuinotificationdialogplugin/secuinotificationdialogplugin.qcrml
securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationcontentwidget.cpp
securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationdialog.cpp
wim/WimServer/src/WimSatRefreshObserver.cpp
--- a/cpsecplugins/cpadvancedsecplugin/inc/cpcertpluginloader.h	Fri May 14 16:43:26 2010 +0300
+++ b/cpsecplugins/cpadvancedsecplugin/inc/cpcertpluginloader.h	Thu May 27 13:44:17 2010 +0300
@@ -18,16 +18,16 @@
 #define	CPCERTPLUGINLOADER_H
 
 #include <qobject.h>
-#include <cppluginplatinterface.h>
+#include <cpplugininterface.h>
 #include <QTranslator>
-class CpCertPluginLoader : public QObject, public CpPluginPlatInterface
+class CpCertPluginLoader : public QObject, public CpPluginInterface
 {
     Q_OBJECT
-    Q_INTERFACES(CpPluginPlatInterface)
+    Q_INTERFACES(CpPluginInterface)
 public:
     CpCertPluginLoader();
     virtual ~CpCertPluginLoader();
-    virtual CpSettingFormItemData *createSettingFormItemData(CpItemDataHelper &itemDataHelper) const;
+      virtual QList<CpSettingFormItemData*>createSettingFormItemData(CpItemDataHelper &itemDataHelper) const;
 private:
 	  QTranslator* mTranslator;
 };
--- a/cpsecplugins/cpadvancedsecplugin/inc/cpcertview.h	Fri May 14 16:43:26 2010 +0300
+++ b/cpsecplugins/cpadvancedsecplugin/inc/cpcertview.h	Thu May 27 13:44:17 2010 +0300
@@ -24,7 +24,9 @@
 class CpCertDataContainer;
 class CCTCertInfo;
 class HbListView;
-
+class HbAction;
+class HbDialog;
+class HbMessageBox;
 class CpCertView : public CpBaseSettingView
 	{
 	Q_OBJECT
@@ -61,7 +63,10 @@
 		void selectAll();
 		void moveCert();
 		void viewDone();
-		
+		void handleMultipleDelete(HbAction* action);
+		void handleMoveDialog(HbAction* action);
+		void handleDeleteDialog(HbAction* action);
+		void handleMoveCertDialog(HbAction* action);
 	private:
 		const CCTCertInfo* certAt(TInt index) const;
 		QString certLabel(TInt index) const;
@@ -74,12 +79,17 @@
 		TInt mPos;
 		CpCertDataContainer* mCertDataContainer;
 		TBool mSelectAll;
+		RArray<TInt> mSelectionIndex;
+		RArray<TInt> mIndexList;
 		
+		HbDialog* mPopup;
 		HbView* mPrevView;
 		HbView* mCurrentView;
 		CpBaseSettingView* mRefreshedView;
-		HbListView* mListView;		
+		HbListView* mListView;	
+		HbListView* mSelectAllView;	
 		HbView* mOriginalView;
+		HbMessageBox* mNote;
 	};
 
 #endif /* CPCERTVIEW_H */
--- a/cpsecplugins/cpadvancedsecplugin/inc/cpsecurityview.h	Fri May 14 16:43:26 2010 +0300
+++ b/cpsecplugins/cpadvancedsecplugin/inc/cpsecurityview.h	Thu May 27 13:44:17 2010 +0300
@@ -27,6 +27,7 @@
 class CSecModUIModel;
 class QModelIndex;
 class CpSecmoduleInfoView;
+class HbMessageBox;
 class CpSecurityView : public CpBaseSettingView
 {
     Q_OBJECT
@@ -45,7 +46,7 @@
     void deleteModule();
     void moduleDetails();
     void displayPreviousFromModInfo();
-    
+    void dialogClosed(HbAction* action);
 private:
     CSecModUIModel* mSecModUIModel;  
     CpSecModView* mSecModView;
@@ -54,6 +55,7 @@
 	CpSecmoduleInfoView* mModuleinfoView;
 	HbView* mCurrentView;
 	TInt mPos;
+	HbMessageBox* mNote;
 
 };
 
--- a/cpsecplugins/cpadvancedsecplugin/src/cpcertpluginloader.cpp	Fri May 14 16:43:26 2010 +0300
+++ b/cpsecplugins/cpadvancedsecplugin/src/cpcertpluginloader.cpp	Thu May 27 13:44:17 2010 +0300
@@ -41,10 +41,10 @@
         }	
 	}
 
-CpSettingFormItemData *CpCertPluginLoader::createSettingFormItemData(CpItemDataHelper &itemDataHelper) const
+QList<CpSettingFormItemData*> CpCertPluginLoader::createSettingFormItemData(CpItemDataHelper &itemDataHelper) const
 		{
-		 return new CpSettingFormEntryItemDataImpl<CpSecurityView>(
-			itemDataHelper,tr("Advanced Security"), QString());    
+  return QList<CpSettingFormItemData*>() 
+           << new CpSettingFormEntryItemDataImpl<CpSecurityView>(itemDataHelper,tr("Advanced Security"), QString());			
 		}
 
 Q_EXPORT_PLUGIN2(cpcertpluginloader, CpCertPluginLoader);
--- a/cpsecplugins/cpadvancedsecplugin/src/cpcertview.cpp	Fri May 14 16:43:26 2010 +0300
+++ b/cpsecplugins/cpadvancedsecplugin/src/cpcertview.cpp	Thu May 27 13:44:17 2010 +0300
@@ -52,11 +52,14 @@
 
 CpCertView::CpCertView(const QModelIndex& modelIndex, QGraphicsItem *parent /*= 0*/)
 	: CpBaseSettingView(0,parent),
+	  mPopup(NULL),
 	  mPrevView(NULL),
 	  mCurrentView(NULL),
 	  mRefreshedView(NULL),
 	  mListView(NULL),
-	  mOriginalView(NULL)
+	  mSelectAllView(NULL),
+	  mOriginalView(NULL),
+	  mNote(NULL)
 	{
 	
 	mOriginalView = mainWindow()->currentView();
@@ -146,6 +149,21 @@
 		mListView->deleteLater();
 		mListView= NULL;
 		}
+		
+	if(mSelectAllView)
+	{
+	mSelectAllView->deleteLater();
+	mSelectAllView = NULL;
+	}
+	
+	mSelectionIndex.Close();
+	
+	mIndexList.Close();
+	
+	delete mPopup;
+	
+	delete mNote;
+	mNote = NULL;
 	}
 	
 void CpCertView::setDetails(CpCertView::TCertificateViews currentView)
@@ -251,14 +269,15 @@
 void CpCertView::deleteList()
 	{
 	mSelectAll = EFalse;
-	HbDialog popup;
-	popup.setDismissPolicy(HbDialog::NoDismiss);
+	mPopup = new HbDialog();
+
+	mPopup->setDismissPolicy(HbDialog::NoDismiss);
 	// Set the label as heading widget
-	popup.setHeadingWidget(q_check_ptr(new HbLabel(hbTrId("txt_certificate_manager_setlabel_certificates"))));
+	mPopup->setHeadingWidget(q_check_ptr(new HbLabel(hbTrId("txt_certificate_manager_setlabel_certificates"))));
 	
 	std::auto_ptr<QGraphicsLinearLayout> layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical)));
 		
-	HbListView* selectAllView = q_check_ptr(new HbListView(this));
+	mSelectAllView = q_check_ptr(new HbListView(this));
 	QStandardItemModel* selectAllModel = q_check_ptr(new QStandardItemModel(this));
 	// Populate the model with content
 	std::auto_ptr<QStandardItem> selectAllItem(q_check_ptr(new QStandardItem()));
@@ -266,10 +285,10 @@
 	selectAllModel->appendRow(selectAllItem.get());
 	selectAllItem.release();
 	
-	connect(selectAllView, SIGNAL(activated(QModelIndex)), this, SLOT(selectAll()));
-	selectAllView->setModel(selectAllModel);
-	selectAllView->setSelectionMode(HbListView::MultiSelection);
-	layout->addItem(selectAllView);
+	connect(mSelectAllView, SIGNAL(activated(QModelIndex)), this, SLOT(selectAll()));
+	mSelectAllView->setModel(selectAllModel);
+	mSelectAllView->setSelectionMode(HbListView::MultiSelection);
+	layout->addItem(mSelectAllView);
 	
 	mListView = q_check_ptr(new HbListView(this));
 	// Connect to "activated" signal
@@ -279,8 +298,6 @@
 	QStandardItemModel* model = q_check_ptr(new QStandardItemModel(this));
 	TInt count=0;
 	QT_TRAP_THROWING( count = refreshListL());
-	RArray<TInt> selectionIndex;
-	QT_TRAP_THROWING(CleanupClosePushL(selectionIndex));
 	
 	for(TInt index = 0; index < count ; ++index)
 		{
@@ -292,7 +309,7 @@
 			QString certificateLabel = certLabel(index);
 			certItem->setData( certificateLabel, Qt::DisplayRole);
 			model->appendRow(certItem.get());
-			selectionIndex.Append(index);
+			mSelectionIndex.Append(index);
 			certItem.release();
 			}
 		}	
@@ -304,16 +321,21 @@
 	std::auto_ptr<HbWidget> widget( q_check_ptr(new HbWidget()));
 	widget->setLayout(layout.get());
 	layout.release();
-	popup.setContentWidget(widget.get());
+	mPopup->setContentWidget(widget.get());
 	widget.release();
 	
-	popup.setPrimaryAction(q_check_ptr(new HbAction(hbTrId("txt_common_opt_delete"))));
-	popup.setSecondaryAction(q_check_ptr(new HbAction(hbTrId("txt_common_button_cancel"))));
-	popup.setTimeout(HbPopup::NoTimeout);
+	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);
 	
 	// Launch popup syncronously
-	HbAction* result = popup.exec();		
-	if(result == popup.primaryAction())
+	mPopup->open(this, SLOT(handleMultipleDelete(HbAction*)));
+
+}
+
+void CpCertView::handleMultipleDelete(HbAction* action)
+{
+	if(action == mPopup->primaryAction())
 		{
 		QItemSelectionModel *selectionModel = mListView->selectionModel();
 		QModelIndexList mWidgetItemsToRemove = selectionModel->selectedIndexes();
@@ -325,46 +347,47 @@
 		for (TInt index = deleteCount-1; index>= 0 ; --index) 
 			{
 			TInt selectedItemIndex = mWidgetItemsToRemove[index].row();
-			actualIndex.Append( selectionIndex[selectedItemIndex] );
+			actualIndex.Append( mSelectionIndex[selectedItemIndex] );
 			}
 		deleteCerts(actualIndex);
 		 CleanupStack::PopAndDestroy(&actualIndex);
 		}
-	CleanupStack::PopAndDestroy(&selectionIndex);
 	mListView->deleteLater();
 	mListView = NULL;
-	selectAllView->deleteLater();
-	selectAllView = NULL;
+	mSelectAllView->deleteLater();
+	mSelectAllView = NULL; 
+	delete mPopup;
+	mPopup = NULL;
 	}
 
 void CpCertView::moveCert()
 	{
 	mSelectAll = EFalse;
-	HbDialog popup;
-	popup.setDismissPolicy(HbDialog::NoDismiss);
+	mPopup = new HbDialog();
+	mPopup->setDismissPolicy(HbDialog::NoDismiss);
 	// Set the label as heading widget
 	if(mCertView == EPersonalView)
 		{
-		popup.setHeadingWidget(q_check_ptr(new HbLabel(tr("Move To Device"))));
+		mPopup->setHeadingWidget(q_check_ptr(new HbLabel(tr("Move To Device"))));
 		}
 	else if(mCertView == EDeviceView)
 		{
-		popup.setHeadingWidget(q_check_ptr(new HbLabel(tr("Move To Personal"))));
+		mPopup->setHeadingWidget(q_check_ptr(new HbLabel(tr("Move To Personal"))));
 		}
 		
 	std::auto_ptr<QGraphicsLinearLayout> layout(q_check_ptr(new QGraphicsLinearLayout(Qt::Vertical)));
 			
-	HbListView* selectAllView = q_check_ptr(new HbListView(this));
+	mSelectAllView = q_check_ptr(new HbListView(this));
 	QStandardItemModel* selectAllModel = q_check_ptr(new QStandardItemModel(this));
 	// Populate the model with content
 	std::auto_ptr<QStandardItem> selectAllItem(q_check_ptr(new QStandardItem()));
 	selectAllItem->setData(QString("Select All"),Qt::DisplayRole);
 	selectAllModel->appendRow(selectAllItem.get());
 	selectAllItem.release();
-	connect(selectAllView, SIGNAL(activated(QModelIndex)), this, SLOT(selectAll()));
-	selectAllView->setModel(selectAllModel);
-	selectAllView->setSelectionMode(HbListView::MultiSelection);
-	layout->addItem(selectAllView);
+	connect(mSelectAllView, SIGNAL(activated(QModelIndex)), this, SLOT(selectAll()));
+	mSelectAllView->setModel(selectAllModel);
+	mSelectAllView->setSelectionMode(HbListView::MultiSelection);
+	layout->addItem(mSelectAllView);
 	
 	mListView = q_check_ptr(new HbListView(this));
 	// Connect to "activated" signal
@@ -374,8 +397,6 @@
 	QStandardItemModel* model = q_check_ptr(new QStandardItemModel(this));
 	TInt count =0;
 	QT_TRAP_THROWING(count = refreshListL());
-	RArray<TInt> selectionIndex;
-	QT_TRAP_THROWING(CleanupClosePushL(selectionIndex));
 	for(TInt index = 0; index < count ; ++index)
 		{
 		// Populate the model with content
@@ -383,7 +404,7 @@
 		QString certificateLabel = certLabel(index);
 		certItem->setData( certificateLabel, Qt::DisplayRole);
 		model->appendRow(certItem.get());
-		selectionIndex.Append(index);
+		mSelectionIndex.Append(index);
 		certItem.release();
 		}	
 	
@@ -395,16 +416,20 @@
 	std::auto_ptr<HbWidget> widget(q_check_ptr(new HbWidget()));
 	widget->setLayout(layout.get());	
 	layout.release();
-	popup.setContentWidget(widget.get());
+	mPopup->setContentWidget(widget.get());
 	widget.release();
 	
-	popup.setPrimaryAction(q_check_ptr(new HbAction(tr("Yes"),&popup)));
-	popup.setSecondaryAction(q_check_ptr(new HbAction(tr("No"),&popup)));
-	popup.setTimeout(HbPopup::NoTimeout);
+	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
-	HbAction* result = popup.exec();		
-	if(result == popup.primaryAction())
+	 mPopup->open(this, SLOT(handleMoveCertDialog(HbAction*)));
+}
+
+void CpCertView::handleMoveCertDialog(HbAction* action)
+{	
+	if(action == mPopup->primaryAction())
 		{
 		QItemSelectionModel *selectionModel = mListView->selectionModel();
 		QModelIndexList mWidgetItemsToRemove = selectionModel->selectedIndexes();
@@ -416,16 +441,17 @@
 		 for (TInt index = deleteCount-1; index>= 0 ; --index) 
 			 {
 			 TInt selectedItemIndex = mWidgetItemsToRemove[index].row();
-			 actualIndex.Append(selectionIndex[selectedItemIndex]);	 
+			 actualIndex.Append(mSelectionIndex[selectedItemIndex]);	 
 			 }
 		 moveCertList(actualIndex);
 		 CleanupStack::PopAndDestroy(&actualIndex); 
 		}
-	CleanupStack::PopAndDestroy(&selectionIndex); 
 	mListView->deleteLater();
 	mListView = NULL;	
-	selectAllView->deleteLater();
-	selectAllView = NULL;
+	mSelectAllView->deleteLater();
+	mSelectAllView = NULL;
+	delete mPopup;
+	mPopup = NULL;
 	}
 
 void CpCertView::selectAll()
@@ -444,9 +470,10 @@
 
 void CpCertView::deleteCerts( RArray<TInt>& indexList )
     {
+  	mIndexList = indexList;
 	TInt count = indexList.Count();
 	    
-	HbMessageBox note(HbMessageBox::MessageTypeQuestion);
+	mNote = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
 	QString deleteMsg;
 	QString sCount;
 	if(count == 1)
@@ -462,13 +489,20 @@
 		}
 	
 	deleteMsg = deleteMsg.arg(sCount);
-	note.setText(deleteMsg);
-	note.setPrimaryAction(q_check_ptr(new HbAction("Yes")));
-	note.setSecondaryAction(q_check_ptr(new HbAction("No")));
-	note.setTimeout(HbPopup::NoTimeout);
-	HbAction* result = note.exec();
+	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*)));
 
-	if (result != note.primaryAction() || count == 0 )
+}
+
+void CpCertView::handleDeleteDialog(HbAction* action)
+{
+	
+	TInt count = mIndexList.Count();
+	
+	if (action != mNote->primaryAction() || count == 0 )
 		{
 		return;
 		}
@@ -478,7 +512,7 @@
     
     for(TInt index = 0; index < count; ++index)
     	{
-		const CCTCertInfo* entry = certAt(indexList[index]);
+		const CCTCertInfo* entry = certAt(mIndexList[index]);
 		
 		if( mCertView == EPersonalView || mCertView == EAuthorityView )
 			{
@@ -514,6 +548,8 @@
 	refreshView(count);
 	
 	CleanupStack::PopAndDestroy(&errCerts);
+	delete mNote;
+	mNote = NULL;
 	
     }
 
@@ -724,40 +760,46 @@
 
 void CpCertView::moveCertList(RArray<TInt>& indexList)
 	{
-	HbMessageBox note(HbMessageBox::MessageTypeQuestion);
-	note.setHeadingWidget(q_check_ptr(new HbLabel(hbTrId("txt_certificate_manager_info_move"))));
+		
+	mIndexList = indexList;
+	mNote = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
+	mNote->setHeadingWidget(q_check_ptr(new HbLabel(hbTrId("txt_certificate_manager_info_move"))));
 	if( mCertView == EPersonalView )
 		{
-		note.setText(hbTrId("txt_certificate_manager_info_device_certificates_c"));
+		mNote->setText(hbTrId("txt_certificate_manager_info_device_certificates_c"));
 		}
 	else if( mCertView == EDeviceView )
 		{
-		note.setText("Use of Personal certificates may require user confirmation. Proceed?");
+		mNote->setText("Use of Personal certificates may require user confirmation. Proceed?");
 		}
 	
-	note.setPrimaryAction(q_check_ptr(new HbAction("Yes")));
-	note.setSecondaryAction(q_check_ptr(new HbAction("No")));
-	note.setTimeout(HbPopup::NoTimeout);
-	note.setIconVisible (EFalse);
-	HbAction* result = note.exec();
+	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*)));
+}
 
-	if (result != note.primaryAction())
+void CpCertView::handleMoveDialog(HbAction* action)
+{
+
+	if (action != mNote->primaryAction())
 	    {
 		return;
 	    }
 	
-	TInt count = indexList.Count();
+	TInt count = mIndexList.Count();
 	
 	for(TInt index = 0 ; index < count; ++index)
 		{
 		CCTCertInfo* entry = NULL;
 		if(mCertView == EPersonalView)
 			{
-			entry = mCertDataContainer->iUserLabelEntries[ indexList[index] ]->iUserEntry;
+			entry = mCertDataContainer->iUserLabelEntries[ mIndexList[index] ]->iUserEntry;
 			}
 		else if(mCertView == EDeviceView)
 			{
-			entry = mCertDataContainer->iDeviceLabelEntries[ indexList[index] ]->iDeviceEntry;
+			entry = mCertDataContainer->iDeviceLabelEntries[ mIndexList[index] ]->iDeviceEntry;
 			}
 			
 		// Move key first
@@ -828,5 +870,7 @@
 		} // for
 	// Refresh current view
 	QT_TRAP_THROWING(refreshView(refreshListL()));	
+	delete mNote;
+	mNote = NULL;
 	}
 
--- a/cpsecplugins/cpadvancedsecplugin/src/cpsecurityview.cpp	Fri May 14 16:43:26 2010 +0300
+++ b/cpsecplugins/cpadvancedsecplugin/src/cpsecurityview.cpp	Thu May 27 13:44:17 2010 +0300
@@ -54,7 +54,8 @@
 	  mPreView(NULL),
 	  mCertView(NULL),
 	  mCurrentView(NULL),
-	  mPos(0)
+	  mPos(0),
+	  mNote(NULL)
 	{
 	setTitle(hbTrId("txt_certificate_manager_setlabel_advanced_security"));
 	
@@ -153,29 +154,26 @@
 	if(mSecModView)
 		{
 		mSecModView->deleteLater();
-		mSecModView= NULL;
 		}
 	
 	if(mPreView)
 		{
 		mPreView->deleteLater();
-		mPreView= NULL;
 		}
 	
 	if(mCertView)
 		{
 		mCertView->deleteLater();
-		mCertView= NULL;
 		}
 	
 	if(mCurrentView)
 		{
 		mCurrentView->deleteLater();
-		mCurrentView= NULL;
 		}
 	
 	delete mSecModUIModel;  
-	mSecModUIModel = NULL;
+	
+	delete mNote;
 	}
 
 void CpSecurityView::showCodeView()
@@ -299,27 +297,44 @@
 	{
 	try
 		{
-		HbMessageBox note(HbMessageBox::MessageTypeQuestion);
-		note.setHeadingWidget(q_check_ptr(new HbLabel(tr("Delete..."))));
-		note.setText("Delete keystore and password?");
-		note.setPrimaryAction(q_check_ptr(new HbAction("Yes")));
-		note.setSecondaryAction(q_check_ptr(new HbAction("No")));
-		note.setTimeout(HbPopup::NoTimeout);
-		note.setIconVisible (EFalse);
-		HbAction* result = note.exec();
-	
-		if (result != note.primaryAction())
-			{
-			return;
-			}
-	
-		QT_TRAP_THROWING(mSecModUIModel->DeleteKeysL(mPos));
+		
+		delete mNote;
+		mNote = NULL;
+		
+		mNote = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
+		mNote->setHeadingWidget(q_check_ptr(new HbLabel(tr("Delete..."))));
+		mNote->setText("Delete keystore and password?");
+		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(dialogClosed(HbAction*)));
 		}
 	catch(const std::exception& exception)
 		{
-		HbMessageBox::information(exception.what());
+	    HbMessageBox *box = new HbMessageBox(exception.what());
+    	box->setAttribute(Qt::WA_DeleteOnClose);
+    	box->open();	
+		}
+
+}
+void CpSecurityView::dialogClosed(HbAction* action)
+{
+	if (action != mNote->primaryAction())
+		{
+		return;
 		}
-	// refresh current view
+		
+	try
+		{
+		QT_TRAP_THROWING(mSecModUIModel->DeleteKeysL(mPos));
+   		}		
+	catch(const std::exception& exception)
+		{
+	    HbMessageBox *box = new HbMessageBox(exception.what());
+    	box->setAttribute(Qt::WA_DeleteOnClose);
+    	box->open();
+		}
 	}
 
 void CpSecurityView::moduleDetails()
--- a/cpsecplugins/cpsecplugins.pro	Fri May 14 16:43:26 2010 +0300
+++ b/cpsecplugins/cpsecplugins.pro	Thu May 27 13:44:17 2010 +0300
@@ -17,6 +17,6 @@
 TEMPLATE = subdirs
 
 # temporarilly skip, because too many deprecations
-# SUBDIRS += devicelockplugin/devicelockplugin.pro
-# SUBDIRS += simpincodeplugin/pincodeplugin.pro
-# SUBDIRS += cpadvancedsecplugin/group/advancedsecplugin.pro
+SUBDIRS += devicelockplugin/devicelockplugin.pro
+SUBDIRS += simpincodeplugin/pincodeplugin.pro
+SUBDIRS += cpadvancedsecplugin/group/advancedsecplugin.pro
--- a/cpsecplugins/devicelockplugin/devicelockplugin.pri	Fri May 14 16:43:26 2010 +0300
+++ b/cpsecplugins/devicelockplugin/devicelockplugin.pri	Thu May 27 13:44:17 2010 +0300
@@ -20,6 +20,5 @@
 
 INCLUDEPATH += ../../seccodeui/src \
 			   ../../seccodeui/inc \
-			   /sf/mw/securitysrv/securitydialogs
-		   
-		
\ No newline at end of file
+			  
+	   
--- a/cpsecplugins/devicelockplugin/devicelockplugin.pro	Fri May 14 16:43:26 2010 +0300
+++ b/cpsecplugins/devicelockplugin/devicelockplugin.pro	Thu May 27 13:44:17 2010 +0300
@@ -19,8 +19,10 @@
 
 CONFIG += hb plugin		  
 
-LIBS +=  -lseccodeui \
-		 -lsecuinotificationdialogplugin \
+LIBS +=  -lsecuinotificationdialogplugin \
+		 -llockclient \
+		 -lautolockuseractivityservice \
+		 -lIndicatorAutolockPlugin \
 		 -lsecui \
 		 -letelmm \
 		 -letel \
@@ -35,5 +37,8 @@
 include ( rom/devicelockplugin_rom.pri )
 
 symbian { 
-    TARGET.UID3 = 0X2002E68
+    TARGET.UID3 = 0X2002E683
+    
+    INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
+    
 }
\ No newline at end of file
--- a/cpsecplugins/devicelockplugin/rom/devicelockplugin.iby	Fri May 14 16:43:26 2010 +0300
+++ b/cpsecplugins/devicelockplugin/rom/devicelockplugin.iby	Thu May 27 13:44:17 2010 +0300
@@ -23,7 +23,6 @@
 
 file=ABI_DIR\BUILD_DIR\devicelockplugin.dll    SHARED_LIB_DIR\devicelockplugin.dll
 
-data=\epoc32\data\c\resource\qt\plugins\controlpanel\devicelockplugin.qtplugin 
-resource\qt\plugins\controlpanel\devicelockplugin.qtplugin
+data=\epoc32\data\c\resource\qt\plugins\controlpanel\devicelockplugin.qtplugin resource\qt\plugins\controlpanel\devicelockplugin.qtplugin
 
 #endif
--- a/cpsecplugins/devicelockplugin/src/cpdevicelockpluginview.cpp	Fri May 14 16:43:26 2010 +0300
+++ b/cpsecplugins/devicelockplugin/src/cpdevicelockpluginview.cpp	Thu May 27 13:44:17 2010 +0300
@@ -27,7 +27,6 @@
 #include <hbmessagebox>
 #include <hbdataform.h>
 #include <QGraphicsLinearLayout>
-//#include <seccodeeditdataformviewitem.h>
 #include <secuisecuritysettings.h>
 #include <secuisecurityhandler.h>
 #include <etelmm.h>
@@ -45,6 +44,7 @@
 #include <qapplication.h>
 #include <qtranslator.h>
 
+
    
         
 /*
@@ -57,148 +57,167 @@
  */
 CpDeviceLockPluginView::CpDeviceLockPluginView(QGraphicsItem *parent /*= 0*/)
 : CpBaseSettingView(0,parent)
-{
-        QTranslator *translator = new QTranslator();
-        QString lang = QLocale::system().name();
-        QString path = "Z:/resource/qt/translations/";
-        bool fine = translator->load("devicelocking_en.qm", path);
-        if (fine)
-            qApp->installTranslator(translator);
+    {
+    QTranslator *translator = new QTranslator();
+    QString lang = QLocale::system().name();
+    QString path = "Z:/resource/qt/translations/";
+    bool fine = translator->load("devicelocking_en.qm", path);
+    if (fine)
+        qApp->installTranslator(translator);
 
-        QTranslator *commontranslator = new QTranslator();
+    QTranslator *commontranslator = new QTranslator();
 
-        fine = commontranslator->load("common_" + lang, path);
-        if (fine)
-            qApp->installTranslator(commontranslator);
+    fine = commontranslator->load("common_" + lang, path);
+    if (fine)
+        qApp->installTranslator(commontranslator);
 
-
-    
     TSecUi::InitializeLibL();
     mUiSecuSettings = CSecuritySettings::NewL();
     mRemoteLockSettings = CRemoteLockSettings::NewL();
-    iALPeriodRep = CRepository::NewL( KCRUidSecuritySettings );  
-    
-    
+    iALPeriodRep = CRepository::NewL(KCRUidSecuritySettings);
+
     mRemoteLockSettingClicked = false;
-    mHack = 0; 
-	if (HbDataForm *form = settingForm()) 
-	    {
-        QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
-		QList<HbAbstractViewItem *> protoTypeList = form->itemPrototypes();
-		protoTypeList.append(new CpRemoteLockDataFormViewItem());
+    mHack = 0;
+    HbDataForm *form = qobject_cast<HbDataForm*> (widget());
+    if (form)
+        {
+        QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(
+                Qt::Vertical);
+        QList<HbAbstractViewItem *> protoTypeList = form->itemPrototypes();
+        protoTypeList.append(new CpRemoteLockDataFormViewItem());
         form->setItemPrototypes(protoTypeList);
         form->setHeading(hbTrId("txt_cp_dblist_device_lock"));
-        
+
         //DataFormModel
-		formModel = new HbDataFormModel();
-		
-		
-		//lockcode
-		HbDataFormModelItem *lockCodeItem = new HbDataFormModelItem(
-		        static_cast<HbDataFormModelItem::DataItemType>(CpRemoteLockDataFormViewItem::CpCodeEditItem),
-		        hbTrId("txt_devicelocking_dialog_lock_code"));		
-		lockCodeItem->setContentWidgetData("echomode",HbLineEdit::Password);
-		lockCodeItem->setContentWidgetData("text","1234");
-		lockCodeItem->setContentWidgetData("readonly",true);
-		form->addConnection(lockCodeItem,SIGNAL(clicked()),this,SLOT(onLockCodeClicked()));
-		formModel->appendDataFormItem(lockCodeItem);
-	
-		
-		//Autolock period
-		mAutolockPeriodItem= new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem,
-                                                        hbTrId("txt_devicelocking_formlabel_automatic_locking"));
-		TInt autoLockVal;
-		TInt err = iALPeriodRep->Get(KSettingsAutoLockTime, autoLockVal);
-		TInt index = GetAutoLockIndex(autoLockVal);
-		Dprint((_L("Current AL period value %d"),autoLockVal));
-		//TODO: need to set autoLockVal in editor
-		QStringList autolockPeriodList;
-		autolockPeriodList<< hbTrId("txt_devicelocking_button_off")
-		                  << hbTrId("txt_devicelocking_setlabel_val_when_keys_screen")
-		                  << hbTrId("txt_devicelocking_setlabel_val_5_minutes")
-		                  << hbTrId("txt_devicelocking_setlabel_val_30_minutes")
-		                  << hbTrId("txt_devicelocking_setlabel_val_60_minutes");
-		mAutolockPeriodItem->setContentWidgetData(QString("items"),autolockPeriodList);
-		mAutolockPeriodItem->setContentWidgetData(QString("currentIndex"),index);
-		mAutolockPeriodItem->setContentWidgetData(QString("editable"),true);		
-		QVariant themeComboData = mAutolockPeriodItem->contentWidgetData(QString("currentIndex"));
-		mThemeComboPrevIndex = themeComboData.toInt();
-		
-		form->addConnection(mAutolockPeriodItem,SIGNAL(currentIndexChanged(int)),this,SLOT(onAutoLockChanged(int)));
-		//form->addConnection(mAutolockPeriodItem,SIGNAL(editTextChanged(const QString&)), this, SLOT(onAutoTextChanged(const QString&)));
-		formModel->appendDataFormItem(mAutolockPeriodItem);
-		
-		
-		//LockWhenSimChange
-		mLockWhenSimChangeItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem,
-                                                  hbTrId("txt_devicelocking_formlabel_lock_when_sim_changed"));
-    	TBool lockVal = mUiSecuSettings->IsLockEnabledL(RMobilePhone::ELockPhoneToICC);
-    	Dprint((_L("LockWhenSimChange enabled %d"),lockVal));
-		if(lockVal)
-		    {
-            mLockWhenSimChangeItem->setContentWidgetData("text",hbTrId("txt_remotelocking_button_sim_changed_on"));
+        formModel = new HbDataFormModel();
+
+        //lockcode
+        HbDataFormModelItem
+                *lockCodeItem =
+                        new HbDataFormModelItem(
+                                static_cast<HbDataFormModelItem::DataItemType> (CpRemoteLockDataFormViewItem::CpCodeEditItem),
+                                hbTrId("txt_devicelocking_dialog_lock_code"));
+        lockCodeItem->setContentWidgetData("echomode", HbLineEdit::Password);
+        lockCodeItem->setContentWidgetData("text", "1234");
+        lockCodeItem->setContentWidgetData("readonly", true);
+        form->addConnection(lockCodeItem, SIGNAL(clicked()), this,
+                SLOT(onLockCodeClicked()));
+        formModel->appendDataFormItem(lockCodeItem);
+
+        //Autolock period
+        mAutolockPeriodItem = new HbDataFormModelItem(
+                HbDataFormModelItem::ComboBoxItem, hbTrId(
+                        "txt_devicelocking_formlabel_automatic_locking"));
+        TInt autoLockVal;
+        TInt err = iALPeriodRep->Get(KSettingsAutoLockTime, autoLockVal);
+        TInt index = GetAutoLockIndex(autoLockVal);
+        Dprint((_L("Current AL period value %d"),autoLockVal));
+        //TODO: need to set autoLockVal in editor
+        QStringList autolockPeriodList;
+        autolockPeriodList << hbTrId("txt_devicelocking_button_off")
+                << hbTrId("txt_devicelocking_setlabel_val_when_keys_screen")
+                << hbTrId("txt_devicelocking_setlabel_val_5_minutes")
+                << hbTrId("txt_devicelocking_setlabel_val_30_minutes")
+                << hbTrId("txt_devicelocking_setlabel_val_60_minutes");
+        mAutolockPeriodItem->setContentWidgetData(QString("items"),
+                autolockPeriodList);
+        mAutolockPeriodItem->setContentWidgetData(QString("currentIndex"),
+                index);
+        mAutolockPeriodItem->setContentWidgetData(QString("editable"), true);
+        QVariant themeComboData = mAutolockPeriodItem->contentWidgetData(
+                QString("currentIndex"));
+        mThemeComboPrevIndex = themeComboData.toInt();
+
+        form->addConnection(mAutolockPeriodItem,
+                SIGNAL(currentIndexChanged(int)), this,
+                SLOT(onAutoLockChanged(int)));
+        //form->addConnection(mAutolockPeriodItem,SIGNAL(editTextChanged(const QString&)), this, SLOT(onAutoTextChanged(const QString&)));
+        formModel->appendDataFormItem(mAutolockPeriodItem);
+
+        //LockWhenSimChange
+        mLockWhenSimChangeItem = new HbDataFormModelItem(
+                HbDataFormModelItem::ToggleValueItem, hbTrId(
+                        "txt_devicelocking_formlabel_lock_when_sim_changed"));
+        TBool lockVal = mUiSecuSettings->IsLockEnabledL(
+                RMobilePhone::ELockPhoneToICC);
+        Dprint((_L("LockWhenSimChange enabled %d"),lockVal));
+        if (lockVal)
+            {
+            mLockWhenSimChangeItem->setContentWidgetData("text", hbTrId(
+                    "txt_remotelocking_button_sim_changed_on"));
+            mLockWhenSimChangeItem->setContentWidgetData("additionalText",
+                    hbTrId("txt_devicelocking_button_sim_changed_off"));
+            }
+        else
+            {
+            mLockWhenSimChangeItem->setContentWidgetData("text", hbTrId(
+                    "txt_devicelocking_button_sim_changed_off"));
             mLockWhenSimChangeItem->setContentWidgetData("additionalText",
-                                                            hbTrId("txt_devicelocking_button_sim_changed_off"));
-		    }
-		else
-		    {
-            mLockWhenSimChangeItem->setContentWidgetData("text",hbTrId("txt_devicelocking_button_sim_changed_off"));
-		    mLockWhenSimChangeItem->setContentWidgetData("additionalText",
-                                                            hbTrId("txt_remotelocking_button_sim_changed_on"));
-		    }
-		mLockWhenSimChangeItem->setContentWidgetData("readonly",true);
-		mPrevSIMLockData = mLockWhenSimChangeItem->contentWidgetData(QString("text"));
-		
-		connect(formModel,SIGNAL(dataChanged(QModelIndex, QModelIndex)),
-                                     this,SLOT(onSIMLockDataChanged(QModelIndex,QModelIndex)));
-		formModel->appendDataFormItem(mLockWhenSimChangeItem);
-		
-		
-		
-		//Remote Lock Setting
-		TBool enabled = true;
-		TBool val = mRemoteLockSettings->GetEnabled(enabled);
-		Dprint((_L("Remote Lock Setting enabled %d"),val));
-		mDeviceRemoteLockItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem,
-                                                            hbTrId("txt_devicelocking_subhead_remote_locking"));
+                    hbTrId("txt_remotelocking_button_sim_changed_on"));
+            }
+        mLockWhenSimChangeItem->setContentWidgetData("readonly", true);
+        mPrevSIMLockData = mLockWhenSimChangeItem->contentWidgetData(QString(
+                "text"));
+
+        connect(formModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
+                this, SLOT(onSIMLockDataChanged(QModelIndex,QModelIndex)));
+        formModel->appendDataFormItem(mLockWhenSimChangeItem);
+
+        //Remote Lock Setting
+        TBool enabled = true;
+        TBool val = mRemoteLockSettings->GetEnabled(enabled);
+        Dprint((_L("Remote Lock Setting enabled %d"),val));
+        mDeviceRemoteLockItem = new HbDataFormModelItem(
+                HbDataFormModelItem::ToggleValueItem, hbTrId(
+                        "txt_devicelocking_subhead_remote_locking"));
+
+        if (val && enabled)
+            {
+            mDeviceRemoteLockItem->setContentWidgetData("text", hbTrId(
+                    "txt_devicelocking_button_remote_on"));
+            mDeviceRemoteLockItem->setContentWidgetData("additionalText",
+                    hbTrId("txt_devicelocking_button_remote_off"));
+            }
+        else
+            {
+            mDeviceRemoteLockItem->setContentWidgetData("text", hbTrId(
+                    "txt_devicelocking_button_remote_off"));
+            mDeviceRemoteLockItem->setContentWidgetData("additionalText",
+                    hbTrId("txt_devicelocking_button_remote_on"));
+            }
 
-		if(val && enabled)
-		    {
-            mDeviceRemoteLockItem->setContentWidgetData("text",hbTrId("txt_devicelocking_button_remote_on"));
-            mDeviceRemoteLockItem->setContentWidgetData("additionalText",hbTrId("txt_devicelocking_button_remote_off"));
-		    }
-		else
-		    {
-            mDeviceRemoteLockItem->setContentWidgetData("text",hbTrId("txt_devicelocking_button_remote_off"));
-            mDeviceRemoteLockItem->setContentWidgetData("additionalText",hbTrId("txt_devicelocking_button_remote_on"));
-	        }		    
+        mPrevRemLockData = mDeviceRemoteLockItem->contentWidgetData(QString(
+                "text"));
+        QString s = mPrevRemLockData.toString();
+        connect(formModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
+                this, SLOT(onRemoteLockDataChanged(QModelIndex,QModelIndex)));
+        formModel->appendDataFormItem(mDeviceRemoteLockItem);
 
-		mPrevRemLockData = mDeviceRemoteLockItem->contentWidgetData(QString("text"));
-		QString s = mPrevRemLockData.toString();
-        connect(formModel,SIGNAL(dataChanged(QModelIndex, QModelIndex)),this,SLOT(onRemoteLockDataChanged(QModelIndex,QModelIndex)));
-		formModel->appendDataFormItem(mDeviceRemoteLockItem);	
-		
-		//Remote lock message
-		mRemoteLockMessageItem = new HbDataFormModelItem(
-		        static_cast<HbDataFormModelItem::DataItemType>(CpRemoteLockDataFormViewItem::CpCodeEditItem),
-		        hbTrId("txt_devicelocking_formlabel_locking_message"));
-		mRemoteLockMessageItem->setContentWidgetData("echoMode",HbLineEdit::Password);
-		mRemoteLockMessageItem->setContentWidgetData("text","1111");
-		mRemoteLockMessageItem->setContentWidgetData("readOnly",true);
-		
-		if(mPrevRemLockData.toString()== hbTrId("txt_devicelocking_button_remote_on"))
-		    mRemoteLockMessageItem->setEnabled(true);
-		else
-		    mRemoteLockMessageItem->setEnabled(false);
-		
-		form->addConnection(mRemoteLockMessageItem,SIGNAL(clicked()),this,SLOT(onLockMessageClicked()));
-		formModel->appendDataFormItem(mRemoteLockMessageItem);
-		
-		form->setModel(formModel);
-		layout->addItem(form);
-		setLayout(layout);
-	}
-}
+        //Remote lock message
+        mRemoteLockMessageItem
+                = new HbDataFormModelItem(
+                        static_cast<HbDataFormModelItem::DataItemType> (CpRemoteLockDataFormViewItem::CpCodeEditItem),
+                        hbTrId("txt_devicelocking_formlabel_locking_message"));
+        mRemoteLockMessageItem->setContentWidgetData("echoMode",
+                HbLineEdit::Password);
+        mRemoteLockMessageItem->setContentWidgetData("text", "1111");
+        mRemoteLockMessageItem->setContentWidgetData("readOnly", true);
+
+        if (mPrevRemLockData.toString() == hbTrId(
+                "txt_devicelocking_button_remote_on"))
+            mRemoteLockMessageItem->setEnabled(true);
+        else
+            mRemoteLockMessageItem->setEnabled(false);
+
+        form->addConnection(mRemoteLockMessageItem, SIGNAL(clicked()), this,
+                SLOT(onLockMessageClicked()));
+        formModel->appendDataFormItem(mRemoteLockMessageItem);
+
+        form->setModel(formModel);
+        layout->addItem(form);
+        setLayout(layout);
+        }
+    }
 
 
 /*
@@ -210,7 +229,7 @@
  *****************************************************************
  */
 CpDeviceLockPluginView::~CpDeviceLockPluginView()
-{
+    {
     TSecUi::UnInitializeLib();
 }
 
@@ -224,7 +243,7 @@
  *****************************************************************
  */
 void CpDeviceLockPluginView::onLockCodeClicked()
-{
+    {
     Dprint(_L("CpDeviceLockPluginView::onLockCodeClicked()..Enter"));
     mUiSecuSettings->ChangeSecCodeL();
     Dprint(_L("CpDeviceLockPluginView::onLockCodeClicked()..Exit"));
@@ -250,7 +269,7 @@
                 lockValue);
         if (newAutoLockVal == lockValue)
             {
-        Dprint(_L("onAutoLockChanged().AL setting success !!"));
+            Dprint(_L("onAutoLockChanged().AL setting success !!"));
             TInt err = iALPeriodRep->Set(KSettingsAutoLockTime, lockValue);
             mThemeComboPrevIndex = index;
             }
@@ -294,7 +313,7 @@
         Dprint(_L("CpDeviceLockPluginView::onLockMessageClicked()..ChangeRemoteLockStatusL failed"));
         }
     Dprint(_L("CpDeviceLockPluginView::onLockMessageClicked()..Exit"));
-    }
+}
 
 
 /*
@@ -358,7 +377,8 @@
         TInt err = iALPeriodRep->Get(KSettingsAutoLockTime, autoLockVal);
         QVariant remLockData = mDeviceRemoteLockItem->contentWidgetData(
                 QString("text"));
-        if (remLockData.toString() == hbTrId("txt_devicelocking_button_remote_on"))
+        if (remLockData.toString() == hbTrId(
+                "txt_devicelocking_button_remote_on"))
             {
             remoteLockStatus = ETrue;
             retVal = mUiSecuSettings->ChangeRemoteLockStatusL(
@@ -430,7 +450,8 @@
 
     if ((item->type() == HbDataFormModelItem::ToggleValueItem)
             && (item->data(HbDataFormModelItem::LabelRole).toString()
-                    == hbTrId("txt_devicelocking_formlabel_lock_when_sim_changed")))
+                    == hbTrId(
+                            "txt_devicelocking_formlabel_lock_when_sim_changed")))
         {
         //The following If-Else condition should be removed once orbit team fix the issue with datachanged() signal
         /****************************************************************************************************************/
@@ -452,19 +473,27 @@
              * disconnect to datachanged() signal as we are not interested in this signal
              * generated as a part of setContentWidgetData() API call below
              */
-            disconnect(formModel,SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,SLOT(onSIMLockDataChanged(QModelIndex,QModelIndex)));
-            QVariant txt = mLockWhenSimChangeItem->contentWidgetData(QString("text"));
-            QVariant additionalText =mLockWhenSimChangeItem->contentWidgetData(QString("additionalText"));
+            disconnect(formModel,
+                    SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
+                    SLOT(onSIMLockDataChanged(QModelIndex,QModelIndex)));
+            QVariant txt = mLockWhenSimChangeItem->contentWidgetData(QString(
+                    "text"));
+            QVariant additionalText =
+                    mLockWhenSimChangeItem->contentWidgetData(QString(
+                            "additionalText"));
 
-            mLockWhenSimChangeItem->setContentWidgetData(QString("text"),additionalText);
-            mLockWhenSimChangeItem->setContentWidgetData(QString("additionalText"), txt);
+            mLockWhenSimChangeItem->setContentWidgetData(QString("text"),
+                    additionalText);
+            mLockWhenSimChangeItem->setContentWidgetData(QString(
+                    "additionalText"), txt);
             /*
              * Now connect back to datachanged() signal .
              */
-            connect(formModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),this, SLOT(onSIMLockDataChanged(QModelIndex,QModelIndex)));
+            connect(formModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
+                    this, SLOT(onSIMLockDataChanged(QModelIndex,QModelIndex)));
             }
         }
-    }
+}
 
 
 /*
@@ -477,29 +506,29 @@
  */
 TInt CpDeviceLockPluginView::GetAutoLockIndex(TInt aValue)
     {
-        TInt index = 0;
-        switch(aValue)
-            {
-            case 0:
-                    index = 0;
-                    break;
-            case 65535:
-                    index = 1;
-                    break;
-            case 5:
-                    index = 2;
-                    break;
-            case 30:
-                    index = 3;
-                    break;
-            case 60:
-                    index = 4;
-                    break;
-            default:
-                    break;
-            }  
-        
-        return index;    
+    TInt index = 0;
+    switch (aValue)
+        {
+        case 0:
+            index = 0;
+            break;
+        case 65535:
+            index = 1;
+            break;
+        case 5:
+            index = 2;
+            break;
+        case 30:
+            index = 3;
+            break;
+        case 60:
+            index = 4;
+            break;
+        default:
+            break;
+        }
+
+    return index;
     }
 
 
@@ -514,49 +543,66 @@
  */
 TInt CpDeviceLockPluginView::GetValueAtIndex(TInt aIndex)
     {
-        TInt value = 0;
-        
-        switch(aIndex)
-            {
-            case 0:
-                    value = 0;
-                    break;
-            case 1:
-                    value = 65535;
-                    break;
-            case 2:
-                    value = 5;
-                    break;
-            case 3:
-                    value = 30;
-                    break;
-            case 4:
-                    value = 60;
-                    break;
-            default:
-                    break;
-            }
-        
-        return value;
-    }
+    TInt value = 0;
+
+    switch (aIndex)
+        {
+        case 0:
+            value = 0;
+            break;
+        case 1:
+            value = 65535;
+            break;
+        case 2:
+            value = 5;
+            break;
+        case 3:
+            value = 30;
+            break;
+        case 4:
+            value = 60;
+            break;
+        default:
+            break;
+        }
+
+    return value;
+}
+
+
+/*
+ *************************************************************************
+ * Name        : RollbackRemoteLockSettingState()
+ * Parameters  : None
+ * Return value: None
+ * Description : If Remote Lock Settings fails or user cancels the settings
+ *               then this function resets to previous value.
+ **************************************************************************
+ */
 void CpDeviceLockPluginView::RollbackRemoteLockSettingState()
     {
     /* 
      * disconnect to datachanged() signal as we are not interested in this signal
      * generated as a part of setContentWidgetData() API call below
      */
-    disconnect(formModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),this, SLOT(onRemoteLockDataChanged(QModelIndex,QModelIndex)));
+    disconnect(formModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
+            this, SLOT(onRemoteLockDataChanged(QModelIndex,QModelIndex)));
 
     QVariant txt = mDeviceRemoteLockItem->contentWidgetData(QString("text"));
-    QVariant additionaltxt = mDeviceRemoteLockItem->contentWidgetData(QString("additionalText"));
-    mDeviceRemoteLockItem->setContentWidgetData(QString("text"),additionaltxt);
-    mDeviceRemoteLockItem->setContentWidgetData(QString("additionalText"),txt);
+    QVariant additionaltxt = mDeviceRemoteLockItem->contentWidgetData(
+            QString("additionalText"));
+    mDeviceRemoteLockItem->setContentWidgetData(QString("text"),
+            additionaltxt);
+    mDeviceRemoteLockItem->setContentWidgetData(QString("additionalText"),
+            txt);
     /*
      * Now connect back to datachanged() signal .
      */
-    connect(formModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,SLOT(onRemoteLockDataChanged(QModelIndex,QModelIndex)));
+    connect(formModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
+            SLOT(onRemoteLockDataChanged(QModelIndex,QModelIndex)));
 
-    if (mPrevRemLockData.toString() == hbTrId("txt_devicelocking_button_remote_on"))
+    if (mPrevRemLockData.toString() == hbTrId(
+            "txt_devicelocking_button_remote_on"))
         mRemoteLockMessageItem->setEnabled(true);
     else
         mRemoteLockMessageItem->setEnabled(false);
--- a/cpsecplugins/devicelockplugin/src/debug.h	Fri May 14 16:43:26 2010 +0300
+++ b/cpsecplugins/devicelockplugin/src/debug.h	Thu May 27 13:44:17 2010 +0300
@@ -15,44 +15,26 @@
  *
  */
 
-#if 0
-#ifndef DEBUG_H_
-#define DEBUG_H_
-
-#define DL_TRACE( x ) RDebug::Printf( "%s %s (%u) %s", __FILE__, __PRETTY_FUNCTION__, __LINE__, x );
-#define DL_TRACE_NUM( x, y ) RDebug::Printf( "%s %s (%u) %s=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, x, y );
-
-
-#endif /* DEBUG_H_ */
-#endif
+#if defined (_DEBUG)
 
-
-
-
-
-#ifndef SCPDEBUG_H
-#define SCPDEBUG_H
-
-   _LIT( KLogFile, "SCP.log" );
-   _LIT( KLogDir, "tarm" );
-   
-
+_LIT( KLogFile, "Devicelockplugin.log" );
+_LIT( KLogDir, "Devicelockplugin" );
 
 #include <e32std.h>
 #include <f32file.h>
 #include <flogger.h>
 #include <e32svr.h>
 
-        inline void FWrite (TRefByValue<const TDesC> aFmt,...)
-            {
-            VA_LIST list;
-            VA_START( list, aFmt );
-            RFileLogger::WriteFormat( KLogDir,KLogFile,EFileLoggingModeAppend ,TPtrC(aFmt) ,list );
-            }
+inline void FWrite (TRefByValue<const TDesC> aFmt,...)
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    RFileLogger::WriteFormat( KLogDir,KLogFile,EFileLoggingModeAppend ,TPtrC(aFmt) ,list );
+    }
 
-                #define Dprint(arg...)    FWrite arg;
+    #define Dprint(arg...)    FWrite arg;
 #else
-                #define Dprint(arg...)
+    #define Dprint(arg...)
 #endif  // _DEBUG
-       
 
+
--- a/cpsecplugins/simpincodeplugin/rom/pincodeplugin.iby	Fri May 14 16:43:26 2010 +0300
+++ b/cpsecplugins/simpincodeplugin/rom/pincodeplugin.iby	Thu May 27 13:44:17 2010 +0300
@@ -23,7 +23,6 @@
 
 file=ABI_DIR\BUILD_DIR\pincodeplugin.dll    SHARED_LIB_DIR\pincodeplugin.dll
 
-data=\epoc32\data\c\resource\qt\plugins\controlpanel\pincodeplugin.qtplugin 
-resource\qt\plugins\controlpanel\pincodeplugin.qtplugin
+data=/epoc32/data/c/resource/qt/plugins/controlpanel/pincodeplugin.qtplugin resource/qt/plugins/controlpanel/pincodeplugin.qtplugin
 
 #endif
--- a/cpsecplugins/simpincodeplugin/src/cppincodepluginview.cpp	Fri May 14 16:43:26 2010 +0300
+++ b/cpsecplugins/simpincodeplugin/src/cppincodepluginview.cpp	Thu May 27 13:44:17 2010 +0300
@@ -41,7 +41,7 @@
 CpPinCodePluginView::CpPinCodePluginView(QGraphicsItem *parent /*= 0*/)
 	: CpBaseSettingView(0,parent), mSecCodeSettings(new SecCodeSettings())
 {
-    HbDataForm *form = settingForm();
+    HbDataForm *form = qobject_cast<HbDataForm*>(widget());
     if (form) {
         QList<HbAbstractViewItem *> protoTypeList = form->itemPrototypes();
         protoTypeList.append(new SecCodeEditDataFormViewItem());
--- a/gba/data/gba_license.txt	Fri May 14 16:43:26 2010 +0300
+++ b/gba/data/gba_license.txt	Thu May 27 13:44:17 2010 +0300
@@ -1,8 +1,2 @@
-End-User License Agreement: 
-By installing or using this software you are confirming acceptance of this software and agree to be bound by the terms and conditions of this Licence.
-
-Grant of License: 
-Nokia grants you a non-exclusive, non-transferable limited end-user right to use this software for the sole purpose of developing and testing applications or middleware software for the Symbian Platform.
-
 Disclaimer of Warranty: 
-THIS SOFTWARE IS PROVIDED TO YOU "AS IS"AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NOKIA, ITS MEMBERS, SUPPLIERS AND LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATE, OR PROFITS; OR INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+THIS SOFTWARE IS PROVIDED TO YOU "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NOKIA, ITS MEMBERS, SUPPLIERS AND LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, OR EXEMPLARY DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATE, OR PROFITS; OR INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--- a/gba/sis/gba.pkg	Fri May 14 16:43:26 2010 +0300
+++ b/gba/sis/gba.pkg	Thu May 27 13:44:17 2010 +0300
@@ -17,7 +17,7 @@
 &EN
 
 ; Header
-#{"GBA (Beta)"},(0x20029F08), 0, 5, 0, TYPE=SA,RU
+#{"GBA"},(0x20029F08), 1, 0, 0, TYPE=SA,RU
 
 ; Localised Vendor name
 %{"Nokia"}
--- a/securitydialogs/Autolock/PubSub/SecurityUIsPrivatePSKeys.h	Fri May 14 16:43:26 2010 +0300
+++ b/securitydialogs/Autolock/PubSub/SecurityUIsPrivatePSKeys.h	Thu May 27 13:44:17 2010 +0300
@@ -12,8 +12,8 @@
 * Contributors:
 *
 * Description:  Private Publish&Subscribe definitions of the
-*               Security UIs subsystem
-*
+ *                Security UIs subsystem
+ *
 */
 
 
@@ -32,24 +32,25 @@
 // Use TUid KPSUidSecurityUIs = { 0x100059b5 } 
 
 /**
-* Used by SecUI to differentiate between ETel API originated and SecUI originated
-* security queries.
-* Old Shared Data constant name: KSecUIOriginatedQuery
-*/
+ * Used by SecUI to differentiate between ETel API originated and SecUI originated
+ * security queries.
+ * Old Shared Data constant name: KSecUIOriginatedQuery
+ */
 const TUint32 KSecurityUIsSecUIOriginatedQuery = 0x00000301;
 enum TSecurityUIsSecUIOriginatedQuery
     {
     ESecurityUIsSecUIOriginatedUninitialized = 0,
     ESecurityUIsETelAPIOriginated,
     ESecurityUIsSecUIOriginated,
-    ESecurityUIsSystemLockOriginated
+    ESecurityUIsSystemLockOriginated,
+    ESecurityUIsFpsOriginated
     };
 
 /**
-* Used by SecUI to tell if a query request set by some ETELMM API lock setting function (i.e. SetXXXXSetting)
-* has been canceled sinnce canceling the setting request does not prompt a query cancel event from ETEL.
-* Old Shared Data constant name: KSecUIOriginatedQuery
-*/    
+ * Used by SecUI to tell if a query request set by some ETELMM API lock setting function (i.e. SetXXXXSetting)
+ * has been canceled since canceling the setting request does not prompt a query cancel event from ETEL.
+ * Old Shared Data constant name: KSecUIOriginatedQuery
+ */    
 const TUint32 KSecurityUIsQueryRequestCancel = 0x00000302;
 enum TSecurityUIsQueryRequestCancel
     {
@@ -58,7 +59,58 @@
     ESecurityUIsQueryRequestCanceled
     };
 
-#endif      // SECURITYUISPRIVATEPSKEYS_H
+/**
+ * Used by Autolock to tell which application has enabled/disabled the keyguard/devicelock , and at which moment.
+ */    
+const TUint32 KSecurityUIsLockInitiatorUID  = 0x00000303;
+const TUint32 KSecurityUIsLockInitiatorTimeHigh = 0x00000304;
+const TUint32 KSecurityUIsLockInitiatorTimeLow  = 0x00000305;
+
+/**
+ * Used by Autolock to tell the status of screensaver 
+ */    
+const TUint32 KSecurityUIsScreenSaverStatus  = 0x00000306;
+enum TSecurityUIsScreenSaverValues
+    {
+    ESecurityUIsScreenSaverUninitialized = 0,
+    ESecurityUIsScreenSaverOn,
+    ESecurityUIsScreenSaverOff,
+    ESecurityUIsScreenSaverOffWhileUnguardQuery,
+    ESecurityUIsScreenSaverOffWhileUnlockQuery,
+    ESecurityUIsScreenSaverLastValue
+    };
+
+/**
+ * Used by any applicattion, to send a Code for Secui
+ */    
+const TUint32 KSecurityUIsTestCode  = 0x00000307;
+
+/**
+ * Used to tell SysAp to switch-on the lights.
+ */    
+const TUint32 KSecurityUIsLights  = 0x00000308;
+enum TSecurityUIsLights
+    {
+    ESecurityUIsLightsUninitialized = 0,
+    ESecurityUIsLightsLockOnRequest,
+    ESecurityUIsLightsQueryOnRequest,
+    ESecurityUIsLightsLockOffRequest,
+    ESecurityUIsLightsLastValue
+    };
+
+/**
+ * Used by Autolock to tell the dialog to dismiss. In fact, any app can do this.
+ */    
+const TUint32 KSecurityUIsDismissDialog  = 0x00000309;
+enum TSecurityUIsDismissDialogValues
+    {
+    ESecurityUIsDismissDialogUninitialized = 0,
+    ESecurityUIsDismissDialogOn,
+    ESecurityUIsDismissDialogProcessing,
+    ESecurityUIsDismissDialogDone,
+    ESecurityUIsDismissDialogLastValue
+    };
+
+#endif // SECURITYUISPRIVATEPSKEYS_H
 
 // End of File
-
--- a/securitydialogs/AutolockSrv/autolocksrv.qcrml	Fri May 14 16:43:26 2010 +0300
+++ b/securitydialogs/AutolockSrv/autolocksrv.qcrml	Thu May 27 13:44:17 2010 +0300
@@ -12,3 +12,13 @@
 <repository target="CRepository" uidValue="0x101f8798">
     <key int="0x7e000001"  ref="/KCRUidProfileEngine/KProEngActiveProfile"></key>
 </repository>
+
+<repository target="RProperty" uidValue="0x10205047">
+    <key int="0x00000101"  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/AutolockSrv/rom/AutolockSrv.iby	Fri May 14 16:43:26 2010 +0300
+++ b/securitydialogs/AutolockSrv/rom/AutolockSrv.iby	Thu May 27 13:44:17 2010 +0300
@@ -17,9 +17,7 @@
 #ifndef __AUTOLOCKSRV_IBY__
 #define __AUTOLOCKSRV_IBY__
 
-/*
 #include <data_caging_paths_for_iby.hrh>
-*/
 
 S60_APP_EXE(AutolockSrv)
 S60_APP_BITMAP(AutolockSrv)
@@ -29,9 +27,7 @@
 file=ABI_DIR\BUILD_DIR\autolockuseractivityservice.dll             SHARED_LIB_DIR\autolockuseractivityservice.dll
 file=ABI_DIR\BUILD_DIR\IndicatorAutolockPlugin.dll             SHARED_LIB_DIR\IndicatorAutolockPlugin.dll
 
-data=\epoc32\data\z\private\10003a3f\import\apps\AutolockSrv_reg.rsc \epoc32\data\z\private\10003a3f\apps\AutolockSrv_reg.rsc
-
-file=\epoc32\data\z\private\10003a3f\import\apps\AutolockSrv_reg.rsc \epoc32\data\z\private\10003a3f\apps\AutolockSrv_reg.rsc
+// this needs to be also in  apps  because this is where QtHighway searches for it.
 data=ZPRIVATE\10003a3f\import\apps\AutolockSrv_reg.rsc          private\10003a3f\apps\AutolockSrv_reg.rsc
 
 #endif // __AUTOLOCKSRV_IBY__
--- a/securitydialogs/AutolockSrv/src/AutolockSrv.cpp	Fri May 14 16:43:26 2010 +0300
+++ b/securitydialogs/AutolockSrv/src/AutolockSrv.cpp	Thu May 27 13:44:17 2010 +0300
@@ -28,7 +28,6 @@
 #include <QVBoxLayout>
 #include <QStackedWidget>
 #include <QImageReader>
-#include <QDebug>
 #include <QTimer>
 #include <QPushButton>
 #include <QLineEdit>
@@ -59,7 +58,7 @@
 #include "autolockuseractivityservice.h"
 
 #include <settingsinternalcrkeys.h>		// CenRep keys
-#include <W32STD.H>
+#include <w32std.h>
 #include <eikenv.h>
 
 #include <qapplication.h>
@@ -78,6 +77,7 @@
 #include <coreapplicationuisdomainpskeys.h>
 #include "../../../inc/securityuisprivatepskeys.h"
 #include <avkondomainpskeys.h>
+#include <hwrmdomainpskeys.h>
 
 #include <hbdevicedialog.h>
 
@@ -89,13 +89,10 @@
 
 _LIT( KMmTsyModuleName, "PhoneTsy");
 
-#define XQSERVICE_DEBUG_PRINT(a) qDebug() << (a)
-
 AutolockSrv::AutolockSrv(QWidget *parent, Qt::WFlags f) :
     QWidget(parent, f), mService(NULL)
     {
-    XQSERVICE_DEBUG_PRINT("AutolockSrv::AutolockSrv");
-    RDEBUG("start", 0);
+    RDEBUG("start autolocksrv", 0);
     mService = new AutolockSrvService(this);
 
     /* Adjust the palette */
@@ -122,12 +119,14 @@
     QPushButton *quitButton = new QPushButton(tr("Quit"));
     QPushButton *test1Button = new QPushButton(tr("Autolock 10 seconds"));
     QPushButton *test2Button = new QPushButton(tr("Autolock never"));
+    QPushButton *test3Button = new QPushButton(tr("SecUiTest"));
     connect(quitButton, SIGNAL(clicked()), this, SLOT(quit()));
     connect(lockButton, SIGNAL(clicked()), this, SLOT(lockAction()));
     connect(unlockButton, SIGNAL(clicked()), this, SLOT(unlockAction()));
     connect(unguardButton, SIGNAL(clicked()), this, SLOT(unguardAction()));
     connect(test1Button, SIGNAL(clicked()), this, SLOT(test1Action()));
     connect(test2Button, SIGNAL(clicked()), this, SLOT(test2Action()));
+    connect(test3Button, SIGNAL(clicked()), this, SLOT(test3Action()));
     RDEBUG("connect", 1);
 
     /* there's no use for this */
@@ -163,7 +162,8 @@
     vl->addWidget(quitButton);
     vl->addWidget(test1Button);
     vl->addWidget(test2Button);
-    RDEBUG("added test2Button", 1);
+    vl->addWidget(test3Button);
+    RDEBUG("added test3Button", 1);
 
     mLabelIcon = new QToolButton;
     mLabelIcon->setIcon(QIcon(
@@ -191,12 +191,12 @@
 
     TInt lockValue = 0;
     TInt lightsTimeout = 0;
-    CRepository* repository;
+    CRepository* repository = NULL;
     TInt cRresult = 0;
 
     iLockStatusPrev = ELockNotActive;
     iLockStatus = ELockNotActive;
-    repository = CRepository::NewL(KCRUidSecuritySettings);
+    QT_TRAP_THROWING( repository = CRepository::NewL(KCRUidSecuritySettings) );
     cRresult = repository->Get(KSettingsAutolockStatus, lockValue);
     RDEBUG("KSettingsAutolockStatus", KSettingsAutolockStatus);
     RDEBUG("cRresult", cRresult);
@@ -207,16 +207,17 @@
 
     adjustInactivityTimers(0);
 
-    repository = CRepository::NewL(KCRUidProfileEngine);
+    QT_TRAP_THROWING( repository = CRepository::NewL(KCRUidProfileEngine) );
     cRresult = repository->Get(KProEngActiveProfile, lightsTimeout);
+    // this value is not used for now
     delete repository;
 
-    repository = CRepository::NewL(KCRUidLightSettings);
+    QT_TRAP_THROWING( repository = CRepository::NewL(KCRUidLightSettings) );
     cRresult = repository->Get(KDisplayLightsTimeout, lightsTimeout);
+    // this value is not used for now
     delete repository;
 
-    // TODO flip
-
+    // subscribe to settings changes
     subscriberKSettingsAutolockStatus = new QValueSpaceSubscriber(
             "/KCRUidSecuritySettings/KSettingsAutolockStatus", this);
     connect(subscriberKSettingsAutolockStatus, SIGNAL(contentsChanged()),
@@ -239,6 +240,23 @@
     connect(subscriberKProEngActiveProfile, SIGNAL(contentsChanged()), this,
             SLOT(subscriberKProEngActiveProfileChanged()));
 
+    // subscribe to environment changes
+    subscriberKHWRMGripStatus = new QValueSpaceSubscriber(
+            "/KPSUidHWRM/KHWRMGripStatus", this);
+    connect(subscriberKHWRMGripStatus, SIGNAL(contentsChanged()), this,
+            SLOT(subscriberKHWRMGripStatusChanged()));
+
+    subscriberKAknKeyguardStatus = new QValueSpaceSubscriber(
+            "/KPSUidAvkonDomain/KAknKeyguardStatus", this);
+    connect(subscriberKAknKeyguardStatus, SIGNAL(contentsChanged()), this,
+            SLOT(subscriberKAknKeyguardStatusChanged()));
+
+    subscriberKCoreAppUIsAutolockStatus = new QValueSpaceSubscriber(
+            "/KPSUidCoreApplicationUIs/KCoreAppUIsAutolockStatus", this);
+    connect(subscriberKCoreAppUIsAutolockStatus, SIGNAL(contentsChanged()), this,
+            SLOT(subscriberKCoreAppUIsAutolockStatusChanged()));
+
+		/////////////
     TSecurityPolicy readPolicy(ECapabilityReadDeviceData);
     TSecurityPolicy writePolicy(ECapabilityWriteDeviceData);
     TInt ret = RProperty::Define(KPSUidSecurityUIs,
@@ -255,6 +273,10 @@
     ret = RProperty::Define(KPSUidCoreApplicationUIs,
             KCoreAppUIsAutolockStatus, RProperty::EInt, KReadPolicy,
             KWritePolicy);
+    //User::LeaveIfError( RProperty::Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus,	
+    //               EAutolockOff));        
+    RProperty::Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus,	
+                   EAutolockOff);
     RDEBUG("defined KCoreAppUIsAutolockStatus", ret);
 
     ret = RProperty::Define(KPSUidAvkonDomain, KAknKeyguardStatus,
@@ -281,6 +303,11 @@
             TSecurityPolicy(TSecurityPolicy::EAlwaysPass));
     RDEBUG("defined KAknKeyguardStatus", ret);
 
+    ret = RProperty::Define(KPSUidSecurityUIs, KSecurityUIsDismissDialog,
+            RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass),
+            TSecurityPolicy(TSecurityPolicy::EAlwaysPass));
+    RDEBUG("defined KSecurityUIsDismissDialog", ret);
+
     // inactivity
     connect(serviceKeyguard, SIGNAL(active()), this, SLOT(activeKeyguard()));
     connect(serviceKeyguard, SIGNAL(notActive()), this, SLOT(
@@ -321,10 +348,10 @@
     RDEBUG("aReason", aReason);
     TInt keyguardTime = 0;
     TInt lockTime = 0;
-    CRepository* repository;
+    CRepository* repository = NULL;
     TInt cRresult = 0;
 
-    repository = CRepository::NewL(KCRUidSecuritySettings);
+    QT_TRAP_THROWING( repository = CRepository::NewL(KCRUidSecuritySettings) );
     cRresult = repository->Get(KSettingsAutoLockTime, lockTime);	// in minutes, handled internally as seconds
     lockTime *= 60;
     RDEBUG("KSettingsAutoLockTime", KSettingsAutoLockTime);
@@ -363,20 +390,23 @@
 void AutolockSrv::unlockAction()
     {
     RDEBUG("0", 0);
-    TryChangeStatus( ELockAppDisableDevicelock);
+    TInt err = TryChangeStatus( ELockAppDisableDevicelock);
+    RDEBUG("err", err);
     }
 
 void AutolockSrv::unguardAction()
     {
     RDEBUG("0", 0);
-    TryChangeStatus( ELockAppDisableKeyguard);
+    TInt err = TryChangeStatus( ELockAppDisableKeyguard);
+    RDEBUG("err", err);
     }
 
 void AutolockSrv::test1Action()
     {
     RDEBUG("Set(KSettingsAutoLockTime, 2)", 2);
 
-    CRepository* repositorySet = CRepository::NewL(KCRUidSecuritySettings);
+    CRepository* repositorySet = NULL;
+    QT_TRAP_THROWING( repositorySet = CRepository::NewL(KCRUidSecuritySettings) );
     repositorySet->Set(KSettingsAutoLockTime, 2);	// in minutes
     delete repositorySet;
     }
@@ -385,10 +415,16 @@
     {
     RDEBUG("Set(KSettingsAutoLockTime, 0)", 0);
 
-    CRepository* repositorySet = CRepository::NewL(KCRUidSecuritySettings);
+    CRepository* repositorySet = NULL;
+    QT_TRAP_THROWING( repositorySet = CRepository::NewL(KCRUidSecuritySettings) );
     repositorySet->Set(KSettingsAutoLockTime, 0);	// minutes
     delete repositorySet;
     }
+void AutolockSrv::test3Action()
+    {
+    RDEBUG("SecUiTest", 0);
+    RDEBUG("This should start SecUiTest, but it's not done yet", 0);
+    }
 
 int AutolockSrv::AskValidSecCode(int aReason)
     {
@@ -417,22 +453,22 @@
         }
     err = iTelServer.LoadPhoneModule(KMmTsyModuleName);
     RTelServer::TPhoneInfo PhoneInfo;
-    RDEBUG("err", err);
+    RDEBUG("LoadPhoneModule err", err);
     err = iTelServer.SetExtendedErrorGranularity(RTelServer::EErrorExtended);
-    RDEBUG("err", err);
+    RDEBUG("SetExtendedErrorGranularity err", err);
     err = iTelServer.GetPhoneInfo(KPhoneIndex, PhoneInfo);
-    RDEBUG("err", err);
+    RDEBUG("GetPhoneInfo err", err);
     err = iPhone.Open(iTelServer, PhoneInfo.iName);
-    RDEBUG("err", err);
+    RDEBUG("Open err", err);
     err = iCustomPhone.Open(iPhone);
-    RDEBUG("err", err);
+    RDEBUG("Open2 err", err);
 
     RDEBUG("CSecurityHandler", 0);
     CSecurityHandler* handler = new (ELeave) CSecurityHandler(iPhone);
     if (aReason == ELockAppDisableDevicelock)
         {
         RDEBUG("calling AskSecCodeInAutoLockL", 0);
-        validCode = handler->AskSecCodeInAutoLockL(); // this returns true/false
+        QT_TRAP_THROWING( validCode = handler->AskSecCodeInAutoLockL() ); // this returns true/false
         // TODO should this also do iPhone.SetLockSetting(status, lockType, lockChange); ???
         }
     else if (aReason == ELockAppEnableDevicelock)
@@ -480,11 +516,11 @@
 #else
                 RDEBUG("! OLD_METHOD", 0);
                 CWait *iWait = NULL;
-                iWait = CWait::NewL();
+                QT_TRAP_THROWING( iWait = CWait::NewL() );
                 iWait->SetRequestType(EMobilePhoneSetLockSetting);
                 iPhone.SetLockSetting(iWait->iStatus, lockType, lockChange); // ask for PassPhraseRequiredL
                 RDEBUG("WaitForRequestL", 0);
-                ret = iWait->WaitForRequestL();
+                QT_TRAP_THROWING( ret = iWait->WaitForRequestL() );
                 RDEBUG("WaitForRequestL ret", ret);
                 if (iWait)
                     {
@@ -510,10 +546,17 @@
                     validCode = 0;
                 }
             else
+            		{
+            		RDEBUG("RMobilePhone::ELockSetEnabled", RMobilePhone::ELockSetEnabled);
+            		RDEBUG("lockInfo.iSetting = RMobilePhone::ELockSetEnabled", RMobilePhone::ELockSetEnabled);
                 validCode = 0x20;
+              	}
             }
         else
+            {
+            RDEBUG("Error: ret", ret);
             validCode = 0x21;
+          	}
 
         /* Alternative way to ask for password
          RMobilePhone::TMobilePhoneSecurityEvent iEvent;
@@ -528,8 +571,8 @@
          */
         }
     // TODO this doesn't wait on WINS , so how do I get the Acceptation?
-    RDEBUG("validCode (true/false)", validCode);
-    if (validCode)
+    RDEBUG("validCode", validCode);
+    if (validCode>0)
         return KErrNone;
 
 		// no valid code -> switch off the lights
@@ -542,10 +585,7 @@
 void AutolockSrv::lockAction()
     {
     RDEBUG("0", 0);
-
-    XQSERVICE_DEBUG_PRINT("AutolockSrv::lockAction");
     TryChangeStatus( ELockAppOfferDevicelock);
-
     }
 
 void AutolockSrv::handleAnswerDelivered()
@@ -798,12 +838,13 @@
     {
     RDEBUG("aReason", aReason);
     TInt err;
+    // can't use include file because it's private file. However it gives permissions
     const TUid KCRUidCoreApplicationUIsSysAp = { 0x101F8765 };
     const TUint32 KSysApKeyguardActive = 0x00000001;
-    CRepository* repositoryDevicelock;
-    CRepository* repositoryKeyguard;
-    repositoryDevicelock = CRepository::NewL(KCRUidSecuritySettings);
-    repositoryKeyguard = CRepository::NewL(KCRUidCoreApplicationUIsSysAp);
+    CRepository* repositoryDevicelock = NULL;
+    CRepository* repositoryKeyguard = NULL;
+    QT_TRAP_THROWING( repositoryDevicelock = CRepository::NewL(KCRUidSecuritySettings) );
+    QT_TRAP_THROWING( repositoryKeyguard = CRepository::NewL(KCRUidCoreApplicationUIsSysAp) );
     TInt cRresult = KErrNone;
     if (1 == 1) // this is a quick way to disable this functionality, for testing
         {
@@ -842,7 +883,7 @@
             else if (aReason >= EDevicelockActive)
                 {
                 err = RProperty::Set(KPSUidAvkonDomain, KAknKeyguardStatus,
-                        EKeyguardAutolockEmulation); // not EKeyguardLocked, not EKeyguardNotActive
+                        EKeyguardAutolockEmulation); // Other candidates might be: EKeyguardLocked and EKeyguardNotActive
             		RDEBUG("KAknKeyguardStatus err", err);
                 err = RProperty::Set(KPSUidCoreApplicationUIs,
                         KCoreAppUIsAutolockStatus, EManualLocked);
@@ -900,6 +941,10 @@
     int errorInProcess = KErrNone;
     DebugRequest(ret);
 
+    TInt err = RProperty::Set(KPSUidSecurityUIs,
+            KSecurityUIsDismissDialog,
+            ESecurityUIsDismissDialogOn);
+		RDEBUG("err", err);
     switch (ret)
         {
         case ELockAppEnableKeyguard: // 1
@@ -958,11 +1003,12 @@
                 if (!callerHasECapabilityWriteDeviceData) // check permissions for calling process, because doesn't AskValidSecCode
                     errorInProcess = KErrPermissionDenied;
                 DebugError(errorInProcess);
+                break;	// so that "disable while disabled" doesn't mess up
                 }
             if (errorInProcess == KErrNone)
                 {
                 RDEBUG(" calling HbDeviceMessageBox::question", 0);
-                bool value = HbDeviceMessageBox::question("Disable Lock?");
+                bool value = HbDeviceMessageBox::question("Disable Lock?");	// this doesn't block other events, so after return everything might be messed up.
                 RDEBUG("value", value);
                 if (!value)
                     errorInProcess = KErrCancel;
@@ -982,7 +1028,8 @@
                 }
             if (errorInProcess != KErrNone)
                 { // re-lock. For example, if password is wrong
-                setLockDialog(aReason, 1);
+               	if( iLockStatus >=EDevicelockActive)	// this skips the case when unlocking, although it wan't locked.
+                	setLockDialog(aReason, 1);
                 }
             // this never shows a note
             }
@@ -993,7 +1040,7 @@
             DebugError(errorInProcess);
             if (errorInProcess == KErrNone)
                 {
-                bool value = HbDeviceMessageBox::question("Enable Keyguard?");
+                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);
                 if (!value)
@@ -1014,6 +1061,7 @@
             errorInProcess = AskValidSecCode(ELockAppEnableDevicelock);
             if (errorInProcess == KErrNone)
                 {
+                RDEBUG("ELockAppOfferDevicelock calling ELockAppEnableDevicelock", ELockAppEnableDevicelock);
                 errorInProcess = TryChangeStatus(ELockAppEnableDevicelock);
                 }
             // this never shows a note. Perhaps ELockAppEnableDevicelock does.
@@ -1092,8 +1140,7 @@
             RDEBUG("err", err);
             iDeviceDialogCreated = 2;
             }
-        const QString KSecQueryUiDeviceDialog(
-                "com.nokia.secuinotificationdialog/1.0");
+        const QString KSecQueryUiDeviceDialog("com.nokia.secuinotificationdialog/1.0");
         RDEBUG("pre show", aReason);
         err = iDeviceDialog->show(KSecQueryUiDeviceDialog, params); // and continue processing
         RDEBUG("post show. err", err);
@@ -1149,7 +1196,7 @@
     RDEBUG("aReason", aReason);
     QList<QVariant> list;
     list.insert(0, 1);
-    list.insert(1, "aaa");
+    list.insert(1, "dummy");
     list.insert(2, 2);
 
     HbIndicator indicator;
@@ -1218,36 +1265,31 @@
         if (ev->type() == QEvent::KeyPress)
             {
             QKeyEvent *keyEvent = static_cast<QKeyEvent *> (ev);
-            qDebug() << QString("KeyPress:%1\n").arg(keyEvent->key(), 0, 16);
-            qDebug() << keyEvent->key();
-            qDebug() << EKeyInsert;
-            qDebug() << (keyEvent->key() & 0xFF);
-            qDebug() << (EKeyInsert & 0xFF);
+            RDEBUG("KeyPress", keyEvent->key());
             if ((keyEvent->key() & 0xFF) == (EKeyInsert & 0xFF))
                 {
-                qDebug() << "pressed EKeyInsert";
+                RDEBUG("EKeyInsert", EKeyInsert);
                 // only reacts on release, not on press
                 isSwitchKey = 1;
                 }
             if ((keyEvent->key() & 0xFF) == (EKeyTab & 0xFF))
                 {
-                qDebug() << "pressed EKeyTab";
+                RDEBUG("EKeyTab", EKeyTab);
                 }
             if ((keyEvent->key() & 0xFF) == (EKeyDeviceF & 0xFF))
                 {
-                qDebug() << "pressed EKeyDeviceF";
+                RDEBUG("EKeyDeviceF", EKeyDeviceF);
                 }
             if (keyEvent->key() == 0x1ffffff)
                 {
-                qDebug() << "pressed EKeyDeviceF-1ffffff";
+                RDEBUG("0x1ffffff", 0x1ffffff);
                 isSwitchKey = 1;
                 }
             }
         else if (ev->type() == QEvent::KeyRelease)
             {
             QKeyEvent *keyEvent = static_cast<QKeyEvent *> (ev);
-            qDebug()
-                    << QString("KeyRelease:%1\n").arg(keyEvent->key(), 0, 16);
+            RDEBUG("KeyRelease", keyEvent->key());
             if (keyEvent->key() == 0x1ffffff)
                 {
                 RDEBUG("released EKeyDeviceF-1ffffff", 1);
@@ -1291,14 +1333,13 @@
     return QWidget::eventFilter(o, ev);
 
     }
-
+// some setting changed
 void AutolockSrv::subscriberKSettingsAutolockStatusChanged()
     {
     RDEBUG("0", 0);
     QVariant v = subscriberKSettingsAutolockStatus->value(
             "/KCRUidSecuritySettings/KSettingsAutolockStatus");
     adjustInactivityTimers( KSettingsAutolockStatus);
-    qDebug() << "AutolockSrv::subscriberKSettingsAutolockStatusChanged" << v;
     }
 void AutolockSrv::subscriberKSettingsAutoLockTimeChanged()
     {
@@ -1306,7 +1347,6 @@
     QVariant v = subscriberKSettingsAutoLockTime->value(
             "/KCRUidSecuritySettings/KSettingsAutoLockTime");
     adjustInactivityTimers( KSettingsAutoLockTime);
-    qDebug() << "AutolockSrv::subscriberKSettingsAutoLockTimeChanged" << v;
     }
 void AutolockSrv::subscriberKSettingsAutomaticKeyguardTimeChanged()
     {
@@ -1314,9 +1354,6 @@
     QVariant v = subscriberKSettingsAutomaticKeyguardTime->value(
             "/KCRUidSecuritySettings/KSettingsAutomaticKeyguardTime");
     adjustInactivityTimers( KSettingsAutoLockTime);
-    qDebug()
-            << "AutolockSrv::subscriberKSettingsAutomaticKeyguardTimeChanged"
-            << v;
     }
 void AutolockSrv::subscriberKDisplayLightsTimeoutChanged()
     {
@@ -1324,7 +1361,6 @@
     QVariant v = subscriberKDisplayLightsTimeout->value(
             "/KCRUidLightSettings/KDisplayLightsTimeout");
     // nothing to do
-    qDebug() << "AutolockSrv::subscriberKDisplayLightsTimeoutChanged" << v;
     }
 void AutolockSrv::subscriberKProEngActiveProfileChanged()
     {
@@ -1332,7 +1368,44 @@
     QVariant v = subscriberKProEngActiveProfile->value(
             "/KCRUidProfileEngine/KProEngActiveProfile");
     // nothing to do
-    qDebug() << "AutolockSrv::subscriberKProEngActiveProfileChanged" << v;
+    }
+// some environment changed
+void AutolockSrv::subscriberKAknKeyguardStatusChanged()
+    {
+    RDEBUG("Error only AutolockSrv should be able to change it", 0);
+  	}
+void AutolockSrv::subscriberKCoreAppUIsAutolockStatusChanged()
+    {
+    RDEBUG("Error only AutolockSrv should be able to change it", 0);
+  	}
+void AutolockSrv::subscriberKHWRMGripStatusChanged()
+    {
+    TInt ret;
+    RDEBUG("0", 0);
+    TInt aGripStatus;
+    TInt err = RProperty::Get(KPSUidHWRM, KHWRMGripStatus, aGripStatus );
+    RDEBUG("err", err);
+    RDEBUG("value", aGripStatus);
+    if( aGripStatus == EPSHWRMGripOpen )
+    	{
+      if (iLockStatus == EKeyguardActive)
+          {
+          iShowKeyguardNote = 1; // note on disable keyguard
+          ret = TryChangeStatus(ELockAppDisableKeyguard);
+          }
+      else if (iLockStatus == EDevicelockActive)
+          {
+          ret = TryChangeStatus(ELockAppDisableDevicelock);
+          }
+      }
+    else if( aGripStatus == EPSHWRMGripClosed )
+    	{
+      if (iLockStatus == ELockNotActive)
+          {
+          iShowKeyguardNote = 1; // note on enable keyguard
+          ret = TryChangeStatus(ELockAppEnableKeyguard);
+          }
+    	}
     }
 
 // ----------AutolockSrvService---------------
@@ -1358,19 +1431,18 @@
     RDEBUG("0", 0);
     if (mAsyncReqId == -1)
         return;
-    XQSERVICE_DEBUG_PRINT("AutolockSrvService::complete");
     completeRequest(mAsyncReqId, number.toInt());
     }
 
-// gor API request
+// got API request from lockaccessextension
 int AutolockSrvService::service(const QString& number,
         const QString& aParam1, const QString& aParam2)
     {
     RDEBUG("0", 0);
     TInt err = KErrNone;
-    qDebug() << "number=" << number;
-    qDebug() << "aParam1=" << aParam1;
-    qDebug() << "aParam2=" << aParam2;
+    RDEBUG("number", number.toInt());
+    RDEBUG("aParam1", aParam1.toInt());
+    RDEBUG("aParam2", aParam2.toInt());
     mAsyncAnswer = false;
     XQRequestInfo info = requestInfo();
     QSet<int> caps = info.clientCapabilities();
@@ -1405,8 +1477,8 @@
     RDEBUG("err", err);
     RDEBUG("myTimeLow", myTimeLow);
     
-    myTimeHigh = myTime.Int64() >> 16;
-    myTimeLow = myTime.Int64() & 0xFFFFFFFF ;
+    myTimeHigh = I64HIGH( myTime.Int64() );
+    myTimeLow = I64LOW( myTime.Int64() );
     RDEBUG("myTimeHigh", myTimeHigh);
     RDEBUG("myTimeLow", myTimeLow);
     err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsLockInitiatorTimeHigh, myTimeHigh );
--- a/securitydialogs/AutolockSrv/src/AutolockSrv.h	Fri May 14 16:43:26 2010 +0300
+++ b/securitydialogs/AutolockSrv/src/AutolockSrv.h	Thu May 27 13:44:17 2010 +0300
@@ -36,7 +36,7 @@
 #include <qmobilityglobal.h>
 
 #include "autolockuseractivityservice.h"
-#include "../../SecUi/inc/SecQueryUi.h"
+#include "../../SecUi/Inc/SecQueryUi.h"
 
 QTM_BEGIN_NAMESPACE
     class QValueSpacePublisher;
@@ -108,12 +108,16 @@
     void lockAction();
     void test1Action();
     void test2Action();
+    void test3Action();
     void handleAnswerDelivered();
     void subscriberKSettingsAutolockStatusChanged();
     void subscriberKSettingsAutoLockTimeChanged();
     void subscriberKSettingsAutomaticKeyguardTimeChanged();
     void subscriberKDisplayLightsTimeoutChanged();
     void subscriberKProEngActiveProfileChanged();
+    void subscriberKAknKeyguardStatusChanged();
+    void subscriberKCoreAppUIsAutolockStatusChanged();
+    void subscriberKHWRMGripStatusChanged();
 
 private slots:
     void activeKeyguard();
@@ -135,6 +139,9 @@
     QValueSpaceSubscriber *subscriberKSettingsAutomaticKeyguardTime;
     QValueSpaceSubscriber *subscriberKDisplayLightsTimeout;
     QValueSpaceSubscriber *subscriberKProEngActiveProfile;
+    QValueSpaceSubscriber *subscriberKAknKeyguardStatus;
+    QValueSpaceSubscriber *subscriberKCoreAppUIsAutolockStatus;
+    QValueSpaceSubscriber *subscriberKHWRMGripStatus;
 
 		AutolockUserActivityService* serviceKeyguard;
 		AutolockUserActivityService* serviceDevicelock;
--- a/securitydialogs/SecUi/Src/SecQueryUi.cpp	Fri May 14 16:43:26 2010 +0300
+++ b/securitydialogs/SecUi/Src/SecQueryUi.cpp	Thu May 27 13:44:17 2010 +0300
@@ -22,20 +22,10 @@
 #include <apgicnfl.h>                           // CApaMaskedBitmap
 #include <securityuisprivatepskeys.h>
 
-#include <CPhCltEmergencyCall.h>
+#include <cphcltemergencycall.h>
 #include <SCPClient.h>
 #include "SecUiWait.h"
 
-// Variant map keys for notification device dialog
-_LIT( KNotifDeviceDialogKeyTimeOut, "timeout" );
-_LIT( KNotifDeviceDialogKeyIconName, "iconName" );
-_LIT( KNotifDeviceDialogKeyText, "text" );
-_LIT( KNotifDeviceDialogKeyTitle, "title" );
-_LIT( KNotifDeviceDialogKeyTouchActivation, "touchActivation" );
-_LIT( KNotifDeviceDialogKeyActivated, "result" );
-_LIT( KNotifDeviceDialogKeyActivatedValue, "activated" );
-_LIT( KNotifDeviceDialogKeyTitleTextWrapping, "titleTextWrapping" );
-
 const TUid KSWInstHelpUid =
     {
     0x101F8512
@@ -349,8 +339,6 @@
             {
             _LIT(KInvalidNewLockCode, "invalidNewLockCode");
             _LIT(KInvalidNewLockCode0, "invalidNewLockCode#0");
-            _LIT(KInvalidNewLockCode1, "invalidNewLockCode#1");
-            _LIT(KInvalidNewLockCode2, "invalidNewLockCode#2");
             AddParamL(KInvalidNewLockCode, KInvalidNewLockCode0); // for starter
             RSCPClient scpClient;
             TSCPSecCode newCode;
@@ -358,7 +346,6 @@
             RDEBUG("scpClient.Connect", 0);
             if (scpClient.Connect() == KErrNone)
                 {
-                /*
                  RArray<TDevicelockPolicies> aFailedPolicies;
                  TDevicelockPolicies failedPolicy;
                  TInt retLockcode = KErrNone;
@@ -374,7 +361,6 @@
                  KInvalidNewLockCodeX.AppendNum(failedPolicy);
                  AddParamL( KInvalidNewLockCode, KInvalidNewLockCodeX );
                  }
-                 */
                 // TODO this should be able to modify MinLenght, MaxLenght
                 scpClient.Close();
                 }
--- a/securitydialogs/SecUi/Src/SecUiManualSecuritySettings.cpp	Fri May 14 16:43:26 2010 +0300
+++ b/securitydialogs/SecUi/Src/SecUiManualSecuritySettings.cpp	Thu May 27 13:44:17 2010 +0300
@@ -20,6 +20,7 @@
 #include <rmmcustomapi.h>
 #include <SecUi.rsg>
 #include "secuimanualsecuritysettings.h"
+#include "secuisecuritysettings.h"
 #include <exterror.h>
 #include "SecUiWait.h"
 #include <mmtsy_names.h>
@@ -600,10 +601,7 @@
     #if defined(_DEBUG)
     RDebug::Print(_L("(SECUI)CManualSecuritySettings::CancelUnLockSimL()"));
     #endif
-    iNote = new (ELeave) CAknNoteDialog(REINTERPRET_CAST(CEikDialog**,&iNote));
-    iNote->SetTimeout(CAknNoteDialog::ELongTimeout);
-    iNote->SetTone(aTone);
-    iNote->ExecuteLD(aResourceID);
+    CSecuritySettings::ShowResultNoteL(aResourceID, aTone);
     }
 
 // End of file
--- a/securitydialogs/SecUi/Src/SecUiSecurityHandler.cpp	Fri May 14 16:43:26 2010 +0300
+++ b/securitydialogs/SecUi/Src/SecUiSecurityHandler.cpp	Thu May 27 13:44:17 2010 +0300
@@ -16,7 +16,6 @@
 *
 */
 
-
 #include <aknnotedialog.h>
 #include <etelmm.h>
 #include <SecUi.rsg>
@@ -57,7 +56,8 @@
 //  LOCAL CONSTANTS AND MACROS
 const TInt KMaxNumberOfPUKAttempts(10);
 const TInt KMaxNumberOfPINAttempts(3);
-const TInt KLastRemainingInputAttempt(1);
+// not used
+// const TInt KLastRemainingInputAttempt(1);
 
 const TInt KTriesToConnectServer(2);
 const TInt KTimeBeforeRetryingRequest(50000);
@@ -389,10 +389,6 @@
      *****************************************************/
 
     RDEBUG("0", 0);
-
-#if defined(_DEBUG)
-    RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL()"));
-#endif
     TInt res;
     CWait* wait;
 
@@ -400,10 +396,6 @@
             RMobilePhone::ELockSetDisabled);
     RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice;
 
-#if defined(_DEBUG)
-    RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() get autolock period"));
-#endif
-
     // get autolock period from Central Repository.
     CRepository* repository = CRepository::NewL(KCRUidSecuritySettings);
     TInt period = 0;
@@ -411,21 +403,15 @@
     delete repository;
 
     RDEBUG("res", res);
+    RDEBUG("period", period);
 
-#if defined(_DEBUG)
-    RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() autolock period:%d"), res);
-#endif
     if (res == KErrNone)
         {
         // disable autolock in Domestic OS side too if autolock period is 0.
-        RDEBUG("period", period);
         if (period == 0)
             {
-#if defined(_DEBUG)
-            RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() Call SetLockSetting"));
-#endif
+						RDEBUG("period", period);
 
-#ifdef RD_REMOTELOCK
             // If remote lock is enabled, don't disable the domestic OS device lock
             // since that would render the RemoteLock useless.
             // Instead just re-set the DOS lock to enabled which as a side effect
@@ -440,35 +426,25 @@
                 if ( remoteLockStatus )
                     {
                     // Remote lock is enabled
-#ifdef _DEBUG
-                    RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - RemoteLock is enabled: lockChange = RMobilePhone::ELockSetEnabled" ) );
-#endif // _DEBUG
                     lockChange = RMobilePhone::ELockSetEnabled;
+                    RDEBUG("lockChange", lockChange);
                     }
                 else
                     {
                     // Remote lock is disabled
-#ifdef _DEBUG
-                    RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - RemoteLock is disabled: lockChange = RMobilePhone::ELockSetDisabled" ) );
-#endif // _DEBUG
                     lockChange = RMobilePhone::ELockSetDisabled;
+                    RDEBUG("lockChange", lockChange);
                     }
                 }
             else
                 {
                 // Failed to get remote lock status
-#ifdef _DEBUG
-                RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - Failed to get RemoteLock status" ) );
-#endif // _DEBUG
+								RDEBUG("Failed", lockChange);
                 }
 
             delete remoteLockSettings;
             remoteLockSettings = NULL;
 
-#else // not defined RD_REMOTELOCK
-            lockChange = RMobilePhone::ELockSetDisabled;
-
-#endif // RD_REMOTELOCK
             RDEBUG("lockChange", lockChange);
             wait = CWait::NewL();
             RDEBUG("0", 0);
@@ -480,16 +456,10 @@
             res = wait->WaitForRequestL();
             RDEBUG("res", res);
             delete wait;
-#if defined(_DEBUG)
-            RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() SetLockSetting RESULT:%d"), res);
-#endif
             } // from   period == 0
         else
             { // ask security code
-#if defined(_DEBUG)
-            RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() Ask sec code via notifier"));
-#endif
-            RDEBUG("0", 0);
+            RDEBUG("codeQueryNotifier 0", 0);
             RNotifier codeQueryNotifier;
             User::LeaveIfError(codeQueryNotifier.Connect());
             CWait* wait = CWait::NewL();
@@ -501,10 +471,7 @@
             params().iEvent
                     = static_cast<TInt> (RMobilePhone::EPhonePasswordRequired);
             params().iStartup = EFalse;
-#if defined(_DEBUG)
-            RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() Start Notifier"));
-#endif
-            RDEBUG("0", 0);
+
             RDEBUG("StartNotifierAndGetResponse", 0);
             codeQueryNotifier.StartNotifierAndGetResponse(wait->iStatus,
                     KSecurityNotifierUid, params, response);
@@ -523,8 +490,6 @@
         { // can't read repository for KSettingsAutoLockTime
         RDEBUG("KERRSOMETHING:Call SetLockSetting", 0);
 
-#ifdef RD_REMOTELOCK
-
         // If remote lock is enabled, don't disable the domestic OS device lock
         // since that would render the RemoteLock useless.
         // Instead just re-set the DOS lock to enabled which as a side effect
@@ -538,48 +503,33 @@
             if ( remoteLockStatus )
                 {
                 // Remote lock is enabled
-#ifdef _DEBUG
-                RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - Failed to get AutoLock status and RemoteLock is enabled: lockChange = RMobilePhone::ELockSetEnabled" ) );
-#endif // _DEBUG
                 lockChange = RMobilePhone::ELockSetEnabled;
+                RDEBUG("lockChange", lockChange);
                 }
             else
                 {
                 // Remote lock is disabled
-#ifdef _DEBUG
-                RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - Failed to get AutoLock status and RemoteLock is disabled: lockChange = RMobilePhone::ELockSetDisabled" ) );
-#endif // _DEBUG
                 lockChange = RMobilePhone::ELockSetDisabled;
+                RDEBUG("lockChange", lockChange);
                 }
             }
         else
             {
             // Failed to get remote lock status
-#ifdef _DEBUG
-            RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - Failed to get AutoLock status and failed to get RemoteLock status" ) );
-#endif // _DEBUG
+            RDEBUG("Failed", lockChange);
             }
 
         delete remoteLockSettings;
         remoteLockSettings = NULL;
 
-#else // not defined RD_REMOTELOCK
-        // could not get the current autolock time... disable autolock in Domestic OS side.
-        lockChange = RMobilePhone::ELockSetDisabled;
-
-#endif // RD_REMOTELOCK
         RDEBUG("0", 0);
-
         wait = CWait::NewL();
         RDEBUG("SetLockSetting", 0);
         iPhone.SetLockSetting(wait->iStatus, lockType, lockChange);
         RDEBUG("WaitForRequestL", 0);
         res = wait->WaitForRequestL();
-        RDEBUG("WaitForRequestL", 1);
+        RDEBUG("WaitForRequestL res", res);
         delete wait;
-#if defined(_DEBUG)
-        RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() KES: SetLockSetting RESULT:%d"), res);
-#endif
         }
 
     RDEBUG("res", res);
@@ -667,9 +617,7 @@
         if (StartUp)
             isConditionSatisfied = ETrue;
         }
-#if defined(_DEBUG)
-    RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() Dialog 1"));
-#endif
+
     // Security code at bootup: No "cancel" softkey; Emergency calls enabled.
     RMobilePhone::TMobilePhoneSecurityCode secCodeTypeToAsk =
             RMobilePhone::ESecurityCodePhonePassword; // for starters
@@ -732,7 +680,7 @@
             RMobilePhone::ESecurityCodePhonePassword;
     CWait* wait = NULL;
     TInt status = KErrNone;
-    ;
+    
     wait = CWait::NewL();
     RDEBUG("VerifySecurityCode", 0);
     iPhone.VerifySecurityCode(wait->iStatus, secCodeType, iSecUi_password,
@@ -752,13 +700,12 @@
     TInt returnValue = status;
     RDEBUG("tarmFlag", tarmFlag);
     RDEBUG("StartUp", StartUp);
+    RDEBUG("status", status);
     switch (status)
         {
         case KErrNone:
-#if defined(_DEBUG)
-            RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() KErrNone"));
-#endif
-            // code approved 
+            // code approved
+            RDEBUG( "KErrNone", KErrNone );
             CSecuritySettings::ShowResultNoteL(R_CONFIRMATION_NOTE,
                     CAknNoteDialog::EConfirmationTone);
             RDEBUG("R_CONFIRMATION_NOTE", R_CONFIRMATION_NOTE);
@@ -781,10 +728,7 @@
 
                     if (tRet != KErrNone)
                         {
-#if defined(_DEBUG)
-                        RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL():\
-                            FAILED to unset TARM Admin Flag"));
-#endif
+                        RDEBUG( "FAILED to unset TARM Admin Flag tRet=", tRet );
                         }
                     }
                 if (!FeatureManager::FeatureSupported(
@@ -808,16 +752,14 @@
             RDEBUG("StartUp", StartUp);
             if (StartUp)
                 {
-#if defined(_DEBUG)
-                RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()KErrNone: Startup; get autolock period."));
-#endif
-
                 // get autolock period from Central Repository.
                 CRepository* repository = CRepository::NewL(
                         KCRUidSecuritySettings);
                 TInt period = 0;
                 TInt res = repository->Get(KSettingsAutoLockTime, period);
                 delete repository;
+                RDEBUG("res", res);
+                RDEBUG("period", period);
 
                 _LIT_SECURITY_POLICY_PASS( KReadPolicy);
                 _LIT_SECURITY_POLICY_C1(KWritePolicy,
@@ -827,9 +769,7 @@
                         KReadPolicy, KWritePolicy);
                 RProperty::Set(KPSUidCoreApplicationUIs,
                         KCoreAppUIsAutolockStatus, EAutolockOff);
-#if defined(_DEBUG)
-                RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() EAutolockOff"));
-#endif                                                              
+                RDEBUG("KCoreAppUIsAutolockStatus", KCoreAppUIsAutolockStatus);
 
                 if (res == KErrNone)
                     {
@@ -848,24 +788,21 @@
                             if ( !remoteLockStatus )
                                 {
                                 // Remote lock is disabled
-#ifdef _DEBUG
-                                RDebug::Print( _L( "(SecUi)CSecurityHandler::PassPhraseRequiredL() - Autolock and RemoteLock are disabled -> disable DOS device lock" ) );
-#endif // _DEBUG
+                                RDEBUG("Autolock and RemoteLock are disabled -> disable DOS device lock", 0);
                                 // Disable DOS device lock setting
                                 RDEBUG( "iCustomPhone.DisablePhoneLock", 0 );
                                 wait = CWait::NewL();
                                 iCustomPhone.DisablePhoneLock(wait->iStatus,iSecUi_password);
-                                wait->WaitForRequestL();
-                                RDEBUG( "iCustomPhone.DisablePhoneLock", 1 );
+                                RDEBUG( "WaitForRequestL", 0 );
+                                status = wait->WaitForRequestL();
+                                RDEBUG( "WaitForRequestL", status );
                                 delete wait;
                                 }
                             }
                         else
                             {
                             // Failed to get remote lock status
-#ifdef _DEBUG
-                            RDebug::Print( _L( "(SecUi)CSecurityHandler::PassPhraseRequiredL() - Autolock is disabled, but failed to get RemoteLock status, so do nothing." ) );
-#endif // _DEBUG
+                            RDEBUG( "Autolock is disabled, but failed to get RemoteLock status, so do nothing", 0 );
                             }
 
                         delete remoteLockSettings;
@@ -876,8 +813,9 @@
                         wait = CWait::NewL();
                         iCustomPhone.DisablePhoneLock(wait->iStatus,
                                 iSecUi_password);
-                        wait->WaitForRequestL();
-                        RDEBUG("iCustomPhone.DisablePhoneLock", 1);
+                        RDEBUG( "WaitForRequestL", 0 );
+                        status = wait->WaitForRequestL();
+                        RDEBUG( "WaitForRequestL status", status );
                         delete wait;
 #endif // RD_REMOTELOCK
                         }
@@ -900,17 +838,16 @@
                             RDEBUG( "iCustomPhone.DisablePhoneLock", 0 );
                             wait = CWait::NewL();
                             iCustomPhone.DisablePhoneLock(wait->iStatus,iSecUi_password);
-                            wait->WaitForRequestL();
-                            RDEBUG( "iCustomPhone.DisablePhoneLock", 1 );
+		                        RDEBUG( "WaitForRequestL", 0 );
+		                        status = wait->WaitForRequestL();
+		                        RDEBUG( "WaitForRequestL status", status );
                             delete wait;
                             }
                         }
                     else
                         {
                         // Failed to get remote lock status
-#ifdef _DEBUG
-                        RDebug::Print( _L( "(SecUi)CSecurityHandler::PassPhraseRequiredL() - Failed to get Autolock period and RemoteLock status, so do nothing." ) );
-#endif // _DEBUG
+                        RDEBUG( "Failed to get Autolock period and RemoteLock status, so do nothing", 0 );
                         }
 
                     delete remoteLockSettings;
@@ -922,8 +859,9 @@
                     wait = CWait::NewL();
                     iCustomPhone.DisablePhoneLock(wait->iStatus,
                             iSecUi_password);
-                    wait->WaitForRequestL();
-                    RDEBUG("iCustomPhone.DisablePhoneLock", 1);
+                    RDEBUG( "WaitForRequestL", 0 );
+                    status = wait->WaitForRequestL();
+                    RDEBUG( "WaitForRequestL status", status );
                     delete wait;
 
 #endif // RD_REMOTELOCK
@@ -945,9 +883,6 @@
         case KErrAccessDenied:
             RDEBUG("KErrAccessDenied", KErrAccessDenied);
             // TODO should this try again? It seems that it's not asked again.
-#if defined(_DEBUG)
-            RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() KErrGsm0707IncorrectPassword"));
-#endif
             CSecuritySettings::ShowResultNoteL(R_CODE_ERROR,
                     CAknNoteDialog::EErrorTone);
             break;
@@ -999,26 +934,11 @@
         // read a flag to see whether the query is SecUi originated. For example, from CSecuritySettings::ChangePinRequestParamsL
         err = RProperty::Get(KPSUidSecurityUIs,
                 KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery);
-
         if (err != KErrNone)
             {
-#if defined(_DEBUG)
-            RDebug::Print(_L("(SECUI)CSecurityHandler::Pin1RequiredL():\
-            FAILED to get the SECUI query Flag: %d"), err);
-#endif
-            }
-        else
-            {
-#if defined(_DEBUG)
-            RDebug::Print(_L("(SECUI)CSecurityHandler::Pin1RequiredL():\
-                    SECUI query Flag: %d"), secUiOriginatedQuery);
-#endif 
+						RDEBUG("FAILED to get the SECUI query Flag err", err);
             }
         }
-#if defined(_DEBUG)
-    RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() Execute dlg"));
-#endif
-
     RDEBUG("StartUp", StartUp);
     RDEBUG("secUiOriginatedQuery", secUiOriginatedQuery);
     RDEBUG("ESecurityUIsSecUIOriginated", ESecurityUIsSecUIOriginated);
@@ -1080,9 +1000,7 @@
 
     if (queryAccepted == KErrAbort) // emergency call
         {
-#if defined(_DEBUG)
-        RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() R_PIN_REQUEST_QUERY CANCEL!"));
-#endif
+				RDEBUG("queryAccepted", queryAccepted);
         CleanupStack::PopAndDestroy(wait); // this is needed
         return KErrCancel;
         }
@@ -1110,12 +1028,13 @@
     switch (res)
         {
         case KErrNone:
-            // code approved 
-#if defined(_DEBUG)
-            RDebug::Print(_L("CSecurityHandler::Pin1RequiredL()code approved "));
-#endif
-            CSecuritySettings::ShowResultNoteL(R_CONFIRMATION_NOTE,
+            // code approved
+            RDEBUG("code approved", res);
+            if(lCancelSupported == ESecUiCancelNotSupported)
+            	{	// OK note is not displayed in boot-up, to make things faster
+	            CSecuritySettings::ShowResultNoteL(R_CONFIRMATION_NOTE,
                     CAknNoteDialog::EConfirmationTone);
+              }
             break;
         case KErrGsm0707IncorrectPassword:
         case KErrAccessDenied:
@@ -1204,18 +1123,17 @@
 #endif
 
     RDEBUG("StartUp", StartUp);
-    RDEBUG("codeInfo.iRemainingEntryAttempts",
-            codeInfo.iRemainingEntryAttempts);
+  	TInt attempts(codeInfo.iRemainingEntryAttempts);
+  	RDEBUG( "attempts", attempts );
     //show the last "Code Error" note of PIN verify result here so it won't be left under the PUK1 dialog
-    if (!StartUp && (codeInfo.iRemainingEntryAttempts
+    if (!StartUp && (attempts
             == KMaxNumberOfPUKAttempts))
         CSecuritySettings::ShowResultNoteL(R_CODE_ERROR,
                 CAknNoteDialog::EErrorTone);
 
-    RDEBUG("codeInfo.iRemainingEntryAttempts",
-            codeInfo.iRemainingEntryAttempts);
-    if (codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts)
-        codeInfo.iRemainingEntryAttempts = -1;
+
+    if (attempts == KMaxNumberOfPINAttempts)
+        attempts = -1;
 
     // ask PUK code
     /* request PIN using QT */
@@ -1229,7 +1147,7 @@
     title.Zero();
     title.Append(_L("Puk1RequiredL"));
     title.Append(_L("#"));
-    title.AppendNum(codeInfo.iRemainingEntryAttempts);
+    title.AppendNum(attempts);
     queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password,
             SEC_C_PUK_CODE_MIN_LENGTH, SEC_C_PUK_CODE_MAX_LENGTH,
             ESecUiSecretNotSupported | ESecUiAlphaNotSupported
--- a/securitydialogs/SecUi/Src/SecUiSecuritySettings.cpp	Fri May 14 16:43:26 2010 +0300
+++ b/securitydialogs/SecUi/Src/SecUiSecuritySettings.cpp	Thu May 27 13:44:17 2010 +0300
@@ -316,117 +316,63 @@
 EXPORT_C TInt CSecuritySettings::ChangeRemoteLockStatusL(
         TBool& aRemoteLockStatus, TDes& aRemoteLockCode, TInt aAutoLockPeriod)
     {
-#ifdef RD_REMOTELOCK
     TInt retValue( KErrNone );
+		RDEBUG("aRemoteLockStatus", aRemoteLockStatus);
+		RDEBUG("aAutoLockPeriod", aAutoLockPeriod);
 
-#ifdef _DEBUG
-    RDebug::Print(_L("(SecUi)CSecuritySettings::ChangeRemoteLockStatusL() - Enter, aRemoteLockStatus == %d, aAutoLockPeriod == %d" ), aRemoteLockStatus, aAutoLockPeriod );
-#endif // _DEBUG
-    CCoeEnv* coeEnv = CCoeEnv::Static();
-    CDesCArrayFlat* items = coeEnv->ReadDesC16ArrayResourceL( R_REMOTELOCK_LBX );
-    CleanupStack::PushL( items );
-
-    // Store the current remote lock setting 
-    TInt previousItem( 0 );
     TInt currentItem( 0 );
 
     if ( aRemoteLockStatus )
         {
-        previousItem = KRemoteLockSettingItemOn;
         currentItem = KRemoteLockSettingItemOn;
         }
     else
         {
-        previousItem = KRemoteLockSettingItemOff;
         currentItem = KRemoteLockSettingItemOff;
         }
-
-    // Create Remote Lock setting page for user to enable or disable remote locking 
-    CRemoteLockSettingPage* remoteLockSettingPage = new( ELeave ) CRemoteLockSettingPage( R_REMOTELOCK_SETTING_PAGE, currentItem, items );
-
-#ifdef _DEBUG
-    RDebug::Print( _L( "(SecUi)CSecuritySettings::ChangeRemoteLockStatusL() - Executing CRemoteLockSettingPage dialog" ) );
-#endif // _DEBUG
-    // Execute the remote lock enable/disable dialog
-    TBool ret = remoteLockSettingPage->ExecuteLD( CAknSettingPage::EUpdateWhenChanged );
+		RDEBUG("currentItem", currentItem);
 
-    // Setting page list box items (texts) no longer needed
-    CleanupStack::PopAndDestroy( items );
-
-    if ( ret )
+    if ( currentItem == KRemoteLockSettingItemOn )
         {
-        if ( currentItem == KRemoteLockSettingItemOn )
-            {
-#ifdef _DEBUG
-            RDebug::Print( _L( "(SecUi)CSecuritySettings::ChangeRemoteLockStatusL() - Remote lock status set to ON" ) );
-#endif // _DEBUG
-            aRemoteLockStatus = ETrue;
+				RDEBUG("KRemoteLockSettingItemOn", KRemoteLockSettingItemOn);
+        aRemoteLockStatus = ETrue;
 
-            // If user wishes to enable remote lock
-            // a new remote lock code is required.
-            // RemoteLockCodeQueryL also 
-            retValue = RemoteLockCodeQueryL( aRemoteLockCode );
-            }
-        else if ( currentItem == KRemoteLockSettingItemOff )
-            {
-#ifdef _DEBUG
-            RDebug::Print( _L( "(SecUi)CSecuritySettings::ChangeRemoteLockStatusL() - Remote lock status set to OFF" ) );
-#endif // _DEBUG
-            aRemoteLockStatus = EFalse;
-            retValue = KErrNone;
+        // If user wishes to enable remote lock
+        // a new remote lock code is required.
+        // RemoteLockCodeQueryL also 
+        retValue = RemoteLockCodeQueryL( aRemoteLockCode );
+        }
+    else if ( currentItem == KRemoteLockSettingItemOff )
+        {
+				RDEBUG("KRemoteLockSettingItemOff", KRemoteLockSettingItemOff);
+        aRemoteLockStatus = EFalse;
+        retValue = KErrNone;
+				// TODO this should calculate aAutoLockPeriod itself, and not trust the input
 
-            // Check whether the status was already off
-            // If not don't make the user enter the security code
-            // (which occurs when setting the DOS lock setting) for no reason.
-            if ( currentItem != previousItem )
-                {
-                // Check whether AutoLock is enabled (timeout value greater 
-                // than zero) or not. If AutoLock is enabled the domestic OS 
-                // device lock should be left enabled.
-                if ( aAutoLockPeriod == 0 )
-                    {
-                    // Disable lock setting from domestic OS
-                    retValue = RemoteLockSetLockSettingL( EFalse );
-                    }
-                else
-                    {
-                    // If AutoLock is enabled, don't disable the DOS device lock
-                    // Re-set (enable) the domestic OS device lock because as a 
-                    // side effect it requires the security code from the user
-                    retValue = RemoteLockSetLockSettingL( ETrue );
-                    }
-                }
+        // Check whether AutoLock is enabled (timeout value greater 
+        // than zero) or not. If AutoLock is enabled the domestic OS 
+        // device lock should be left enabled.
+        if ( aAutoLockPeriod == 0 )
+            {
+            // Disable lock setting from domestic OS
+            retValue = RemoteLockSetLockSettingL( EFalse );
             }
         else
             {
-            // This should never happen. But if it does don't change anything
-            retValue = KErrUnknown;
+            // If AutoLock is enabled, don't disable the DOS device lock
+            // Re-set (enable) the domestic OS device lock because as a 
+            // side effect it requires the security code from the user
+            retValue = RemoteLockSetLockSettingL( ETrue );
             }
         }
-    else
-        {
-        // Something went wrong with the RemoteLockSettingPage dialog 
-        retValue = KErrGeneral;
-
-#ifdef _DEBUG
-        RDebug::Print( _L( "(SecUi)CSecuritySettings::ChangeRemoteLockStatusL() - CRemoteLockSettingPage::ExecuteLD() failed" ) );
-#endif // _DEBUG
-        }
-
-#ifdef _DEBUG
-    RDebug::Print(_L("(SecUi)CSecuritySettings::ChangeRemoteLockStatusL() - Exit" ) );
-#endif
-
+		RDEBUG( "retValue", retValue );
     return retValue;
-#else //! RD_REMOTELOCK
-    return KErrNotSupported;
-#endif //RD_REMOTELOCK
     }
 //
 // ----------------------------------------------------------
 // CSecuritySettings::RemoteLockCodeQueryL()
 // Pops up remote lock code query. Requires user to enter a new remote lock 
-// code twice and if they match enables the domestic OS device lock (which as 
+// code (RemoteMsg) twice and if they match enables the domestic OS device lock (which as 
 // a side effect pops up security code query).
 // ----------------------------------------------------------
 // no qtdone
@@ -435,91 +381,28 @@
 #ifdef RD_REMOTELOCK
     TInt retValue( KErrNone );
 
-#ifdef _DEBUG
-    RDebug::Print(_L("(SecUi)CSecuritySettings::ChangeRemoteLockCodeL() - Enter" ) );
-#endif // _DEBUG
-    // Clear the remote lock code buffer
+		RDEBUG( "retValue", retValue );
     aRemoteLockCode.Zero();
 
-    // ----- Remote lock code query -------------------------------------------
-
-    // Execute Remote Lock code query
-#ifdef _DEBUG
-    RDebug::Print( _L( "(SecUi)CSecuritySettings::ChangeRemoteLockCodeL() - Executing remote lock code query" ) );
-#endif // _DEBUG
-    // Load the query prompt from resources
-    CCodeQueryDialog* codeQuery = new( ELeave ) CCodeQueryDialog( aRemoteLockCode, SEC_REMOTELOCK_CODE_MIN_LENGTH,SEC_REMOTELOCK_CODE_MAX_LENGTH, ESecUiNone, ETrue );
-    TInt buttonId = codeQuery->ExecuteLD( R_REMOTELOCK_CODE_QUERY );
-    if ( buttonId == EEikBidOk )
-        {
-        // Ok was pressed and the remote lock code seems fine
-        retValue = KErrNone;
-        }
-    else
-        {
-        // User pressed Cancel
-        // Set the code length to zero leaving no trash for possible retry
-        aRemoteLockCode.Zero();
-        retValue = KErrAbort;
-        }
-
-    if ( retValue != KErrNone )
-        {
-#ifdef _DEBUG
-        RDebug::Print(_L("(SecUi)CSecuritySettings::ChangeRemoteLockCodeL() - Exit, Remote lock code error" ) );
-#endif // _DEBUG
-        // Can't continue beyond this 
-        return retValue;
-        }
-
-    // ----- Remote lock code confirm query -----------------------------------
-
-    // Confirm the code by asking it again
-#ifdef _DEBUG
-    RDebug::Print( _L( "(SecUi)CSecuritySettings::ChangeRemoteLockCodeL() - Executing remote lock code verify query" ) );
-#endif // _DEBUG
-    // Buffer for the confirmation code
-    TBuf<KRLockMaxLockCodeLength> confirmCode;
+    TInt queryAccepted = KErrCancel;
+        queryAccepted = KErrCancel;
+        CSecQueryUi * iSecQueryUi;
+        iSecQueryUi = CSecQueryUi::NewL();
+        // this queries both, and verifies itself
+        queryAccepted = iSecQueryUi->SecQueryDialog(
+                _L("RemoteMsg-New|RemoteMsg-Ver"), aRemoteLockCode,
+                SEC_REMOTELOCK_CODE_MIN_LENGTH, SEC_REMOTELOCK_CODE_MAX_LENGTH,
+                ESecUiAlphaSupported | ESecUiCancelSupported
+                        | ESecUiEmergencyNotSupported | ESecUiNone);
+        RDEBUG("aRemoteLockCode", 0);
+        RDebug::Print(aRemoteLockCode);
+        RDEBUG("queryAccepted", queryAccepted);
+        delete iSecQueryUi;
+        if (queryAccepted != KErrNone)
+            return KErrAbort;
 
-    // Load the confirmation query prompt from resources
-    CCodeQueryDialog* codeConfirmQuery = new( ELeave ) CCodeQueryDialog( confirmCode, SEC_REMOTELOCK_CODE_MIN_LENGTH, SEC_REMOTELOCK_CODE_MAX_LENGTH, ESecUiNone, ETrue );
-    buttonId = codeConfirmQuery->ExecuteLD( R_VERIFY_REMOTELOCK_CODE_QUERY);
-
-    if ( buttonId == EEikBidOk )
-        {
-        // Compare codes. Compare returns zero if descriptors have
-        // the same length and the same content
-        while ( (aRemoteLockCode.CompareF( confirmCode ) != 0) && (buttonId == EEikBidOk))
-            {
-            //Codes didn't match; zero the bufffers and show the dialog again
-            aRemoteLockCode.Zero();
-            confirmCode.Zero();
-            // Codes don't match. Notify user
-            ShowResultNoteL( R_REMOTELOCK_CODES_DONT_MATCH, CAknNoteDialog::EErrorTone );
-            codeQuery = new( ELeave ) CCodeQueryDialog( aRemoteLockCode, SEC_REMOTELOCK_CODE_MIN_LENGTH,SEC_REMOTELOCK_CODE_MAX_LENGTH, ESecUiNone, ETrue );
-            buttonId = codeQuery->ExecuteLD( R_REMOTELOCK_CODE_QUERY );
-            //Unless user pressed Cancel show the verification query
-            if(buttonId == EEikBidOk)
-                {
-                codeConfirmQuery = new( ELeave ) CCodeQueryDialog( confirmCode, SEC_REMOTELOCK_CODE_MIN_LENGTH, SEC_REMOTELOCK_CODE_MAX_LENGTH, ESecUiNone, ETrue );
-                buttonId = codeConfirmQuery->ExecuteLD( R_VERIFY_REMOTELOCK_CODE_QUERY);
-                }
-
-            }
-        //User pressed cancel        
-        if(buttonId != EEikBidOk)
-            {
-            // Set the code length to zero leaving no trash for possible retry
-            // Report error and let the user try again 
-            aRemoteLockCode.Zero();
-            confirmCode.Zero();
-            retValue = KErrAbort;
-            }
-        else
-            {
-            // Codes match
-            confirmCode.Zero();
-
+		// TODO it should ask first for the code, and _later_ for the RemoteMsg
+		
             // ----- Check against security code ------------------------------
 
             // Check that the new remote lock code doesn't match the security 
@@ -530,8 +413,8 @@
             RMobilePhone::TMobilePassword securityCode;
             RMobilePhone::TMobilePassword unblockCode; // Required here only as a dummy parameter 
 
-            if ( aRemoteLockCode.Length() <= RMobilePhone::KMaxMobilePasswordSize )
-                {
+						RDEBUG( "RMobilePhone::KMaxMobilePasswordSize", RMobilePhone::KMaxMobilePasswordSize );
+
                 securityCode = aRemoteLockCode;
                 iWait->SetRequestType( EMobilePhoneVerifySecurityCode );
                 RDEBUG( "VerifySecurityCode", 0 );
@@ -543,85 +426,15 @@
                 if (res == KErrNotSupported || res == KErrTimedOut)
                 res = KErrNone;
 #endif
-                // The remote lock code matches the security code 
-                // and that is not allowed
-                while ( (res == KErrNone) && (buttonId == EEikBidOk))
+                if(res != KErrNone)
                     {
-#ifdef _DEBUG
-                    RDebug::Print(_L("(SecUi)CSecuritySettings::ChangeRemoteLockCodeL() - Unacceptable remote lock code" ) );
-#endif // _DEBUG
-                    aRemoteLockCode.Zero();
-                    confirmCode.Zero();
-
-                    ShowResultNoteL( R_REMOTELOCK_INVALID_CODE, CAknNoteDialog::EErrorTone );
-
-                    codeQuery = new( ELeave ) CCodeQueryDialog( aRemoteLockCode, SEC_REMOTELOCK_CODE_MIN_LENGTH,SEC_REMOTELOCK_CODE_MAX_LENGTH, ESecUiNone, ETrue );
-                    buttonId = codeQuery->ExecuteLD( R_REMOTELOCK_CODE_QUERY );
-                    //Unless user pressed Cancel show the verification query
-                    if(buttonId == EEikBidOk)
-                        {
-                        codeConfirmQuery = new( ELeave ) CCodeQueryDialog( confirmCode, SEC_REMOTELOCK_CODE_MIN_LENGTH, SEC_REMOTELOCK_CODE_MAX_LENGTH, ESecUiNone, ETrue );
-                        buttonId = codeConfirmQuery->ExecuteLD( R_VERIFY_REMOTELOCK_CODE_QUERY);
-
-                        // Compare codes. Compare returns zero if descriptors have
-                        // the same length and the same content
-                        while ( (aRemoteLockCode.CompareF( confirmCode ) != 0) && (buttonId == EEikBidOk))
-                            {
-                            //Codes didn't match; zero the bufffers and show the dialog again
-                            aRemoteLockCode.Zero();
-                            confirmCode.Zero();
-                            // Codes don't match. Notify user
-                            ShowResultNoteL( R_REMOTELOCK_CODES_DONT_MATCH, CAknNoteDialog::EErrorTone );
-                            codeQuery = new( ELeave ) CCodeQueryDialog( aRemoteLockCode, SEC_REMOTELOCK_CODE_MIN_LENGTH,SEC_REMOTELOCK_CODE_MAX_LENGTH, ESecUiNone, ETrue );
-                            buttonId = codeQuery->ExecuteLD( R_REMOTELOCK_CODE_QUERY );
-                            //Unless user pressed Cancel show the verification query
-                            if(buttonId == EEikBidOk)
-                                {
-                                codeConfirmQuery = new( ELeave ) CCodeQueryDialog( confirmCode, SEC_REMOTELOCK_CODE_MIN_LENGTH, SEC_REMOTELOCK_CODE_MAX_LENGTH, ESecUiNone, ETrue );
-                                buttonId = codeConfirmQuery->ExecuteLD( R_VERIFY_REMOTELOCK_CODE_QUERY);
-                                }
-
-                            }
-                        //User pressed cancel        
-                        if(buttonId != EEikBidOk)
-                            {
-                            // Set the code length to zero leaving no trash for possible retry
-                            // Report error and let the user try again 
-                            aRemoteLockCode.Zero();
-                            confirmCode.Zero();
-                            retValue = KErrAbort;
-                            }
-                        else //Check against security code
-
-                            {
-                            securityCode = aRemoteLockCode;
-                            iWait->SetRequestType( EMobilePhoneVerifySecurityCode );
-                            RDEBUG( "VerifySecurityCode", 0 );
-                            iPhone.VerifySecurityCode( iWait->iStatus, secCodeType, securityCode, unblockCode );
-                            RDEBUG( "WaitForRequestL", 0 );
-                            res = iWait->WaitForRequestL();
-#ifdef __WINS__
-                            if (res == KErrNotSupported || res == KErrTimedOut)
-                            res = KErrNone;
-#endif
-                            RDEBUG( "WaitForRequestL res", res );
-                            }
-                        }
-
+		                // The remote lock code matches the security code 
+		                // and that is not allowed
+		                RDEBUG( "res", res );
+		                return res;
                     }
-                //User pressed cancel        
-                if(buttonId != EEikBidOk)
-                    {
-                    // Set the code length to zero leaving no trash for possible retry
-                    // Report error and let the user try again 
-                    aRemoteLockCode.Zero();
-                    confirmCode.Zero();
-                    retValue = KErrAbort;
-                    }
-                }
 
             // ----- Enable DOS device lock (Security code query) -------------
-
             if ( retValue == KErrNone )
                 {
                 // Enable lock setting in domestic OS. It is safe to enable the 
@@ -629,17 +442,7 @@
                 // be enabled when changing or setting the remote lock message.
                 retValue = RemoteLockSetLockSettingL( ETrue );
                 }
-            }
-        }
-    else //User pressed Cancel
-
-        {
-        // Set the code length to zero leaving no trash for possible retry
-        aRemoteLockCode.Zero();
-        confirmCode.Zero();
-        retValue = KErrAbort;
-        }
-
+RDEBUG( "retValue", retValue );
 #ifdef _DEBUG
     RDebug::Print(_L("(SecUi)CSecuritySettings::ChangeRemoteLockCodeL() - Exit" ) );
 #endif // _DEBUG
@@ -657,12 +460,9 @@
 // no qtdone
 TInt CSecuritySettings::RemoteLockSetLockSettingL(TBool aLockSetting)
     {
-#ifdef RD_REMOTELOCK
     TInt retValue( KErrNone );
+		RDEBUG( "aLockSetting", aLockSetting );
 
-#ifdef _DEBUG
-    RDebug::Print(_L("(SecUi)CSecuritySettings::RemoteLockSetLockSettingL( %d ) - Enter" ), aLockSetting );
-#endif // _DEBUG
     RMobilePhone::TMobilePhoneLockSetting lockSetting = RMobilePhone::ELockSetEnabled;
     RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice;
 
@@ -674,13 +474,12 @@
         {
         lockSetting = RMobilePhone::ELockSetDisabled;
         }
+		RDEBUG("lockSetting", lockSetting);
 
     iWait->SetRequestType( EMobilePhoneSetLockSetting );
     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, ESecurityUIsQueryRequestOk);
     RDEBUG( "SetLockSetting", 0 );
-    iPhone.SetLockSetting( iWait->iStatus, lockType, lockSetting );
-
-    // Wait for code verify to complete
+    iPhone.SetLockSetting( iWait->iStatus, lockType, lockSetting );	// this will PassPhraseRequiredL
     RDEBUG( "WaitForRequestL", 0 );
     retValue = iWait->WaitForRequestL();
     RDEBUG( "WaitForRequestL retValue", retValue );
@@ -692,48 +491,25 @@
     switch( retValue )
         {
         case KErrNone:
-#ifdef _DEBUG
-        RDebug::Print( _L( "(SecUi)CSecuritySettings::RemoteLockSetLockSettingL() - EMobilePhoneSetLockSetting request returned KErrNone" ) );
-#endif // _DEBUG
         break;
 
         case KErrGsmSSPasswordAttemptsViolation:
         case KErrLocked:
-#ifdef _DEBUG
-        RDebug::Print( _L( "(SecUi)CSecuritySettings::RemoteLockSetLockSettingL() - EMobilePhoneSetLockSetting request returned KErrLocked" ) );
-#endif // _DEBUG
-        //Error note is shown in CSecurityHandler::PassPhraseRequired()
-        break;
-
         case KErrGsm0707IncorrectPassword:
         case KErrAccessDenied:
-#ifdef _DEBUG
-        RDebug::Print( _L( "(SecUi)CSecuritySettings::RemoteLockSetLockSettingL() - EMobilePhoneSetLockSetting request returned KErrAccessDenied" ) );
-#endif // _DEBUG
         // Security code was entered erroneously
         //Error note is shown in CSecurityHandler::PassPhraseRequired()
         break;
 
         case KErrAbort:
-#ifdef _DEBUG
-        RDebug::Print( _L( "(SecUi)CSecuritySettings::RemoteLockSetLockSettingL() - EMobilePhoneSetLockSetting request returned KErrAbort" ) );
-#endif // _DEBUG
         break;
 
         default:
-#ifdef _DEBUG
-        RDebug::Print( _L( "(SecUi)CSecuritySettings::RemoteLockSetLockSettingL() - EMobilePhoneSetLockSetting request returned: %d"), retValue );
-#endif // _DEBUG
         break;
         }
 
-#ifdef _DEBUG
-    RDebug::Print(_L("(SecUi)CSecuritySettings::RemoteLockSetLockSettingL() - Exit" ) );
-#endif // _DEBUG
+		RDEBUG( "retValue", retValue );
     return retValue;
-#else //! RD_REMOTELOCK
-    return KErrNotSupported;
-#endif //RD_REMOTELOCK
     }
 
 //
@@ -858,7 +634,7 @@
     iCaption.Copy(_L("ChangePinRequestL"));
     TInt iShowError = 1;
     ChangePinRequestParamsL(
-            1/* TODO it's imposible to know if we want to set or clear*/,
+            1/* it's imposible to know if we want to set or clear*/,
             iOldPassword, iFlags, iCaption, iShowError);
     RDEBUG("0", 0);
 
@@ -1653,6 +1429,18 @@
             titleTr.Append(_L("KErrArgument"));
             title.Append(_L("Error Argument"));
             break;
+        case R_SIM_OFF:
+            titleTr.Append(_L("R_SIM_OFF"));
+            title.Append(_L("SIM OFF"));
+            break;
+        case R_SIM_ALLREADY_OFF:
+            titleTr.Append(_L("R_SIM_ALLREADY_OFF"));
+            title.Append(_L("SIM ALLREADY OFF"));
+            break;
+        case R_SIM_NOT_ALLOWED:
+            titleTr.Append(_L("R_SIM_NOT_ALLOWED"));
+            title.Append(_L("SIM NOT ALLOWED"));
+            break;
 
         default: // " "
             titleTr.Append(_L("Specific Error"));
@@ -2536,12 +2324,6 @@
                     RMobilePhone::ELockPhoneDevice;
             RMobilePhone::TMobilePhoneLockSetting lockChangeSetting =
                     RMobilePhone::ELockSetEnabled;
-            if (oldPassword.Length() == 6)
-                {
-                lockChangeSetting = RMobilePhone::ELockSetDisabled;
-                RDEBUG("RMobilePhone::ELockSetDisabled",
-                        RMobilePhone::ELockSetDisabled);
-                }
             iWait->SetRequestType(EMobilePhoneSetLockSetting);
             RDEBUG("SetLockSetting", 0);
             iPhone.SetLockSetting(iWait->iStatus, lockType, lockChangeSetting);
@@ -2626,6 +2408,7 @@
 
 /**************************************/
 // qtdone
+// the params are changed in the settings,. This only asks for password.
 EXPORT_C TInt CSecuritySettings::ChangeAutoLockPeriodParamsL(TInt aPeriod,
         RMobilePhone::TMobilePassword aOldPassword, TInt aFlags,
         TDes& aCaption, TInt aShowError)
@@ -2661,7 +2444,6 @@
                 if ((lex.Val(maxPeriod) == KErrNone) && (maxPeriod > 0))
                     {
                     RDEBUG("from SCP maxPeriod", maxPeriod);
-                    // nothing to do
                     }
                 else
                     {
@@ -2687,10 +2469,8 @@
 
         if ((aPeriod == 0) && (maxPeriod > 0))
             {
-#if defined(_DEBUG)
-            RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() \
-        The period: %d is not allowed by TARM; max: %d"),aPeriod, maxPeriod );
-#endif                
+            	RDEBUG("The period is not allowed by TARM", aPeriod);
+            	RDEBUG( "maxPeriod", maxPeriod );
             allow = EFalse;
             ShowResultNoteL(R_SECUI_TEXT_AUTOLOCK_MUST_BE_ACTIVE,
                     CAknNoteDialog::EErrorTone);
@@ -2704,8 +2484,6 @@
 
     if (aPeriod == 0)
         {
-#ifdef RD_REMOTELOCK
-
         // If remote lock is enabled, don't disable the domestic OS device lock
         // since that would render the RemoteLock useless.
         // Instead just re-set the DOS lock to enabled which as a side effect
@@ -2738,10 +2516,6 @@
         delete remoteLockSettings;
         remoteLockSettings = NULL;
 
-#else // not defined RD_REMOTELOCK
-        lockChange = RMobilePhone::ELockSetDisabled;
-
-#endif // RD_REMOTELOCK
         }
     else
         {
@@ -2750,6 +2524,7 @@
         }
 
     iWait->SetRequestType(EMobilePhoneSetLockSetting);
+    RDEBUG("lockChange", lockChange);
     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel,
             ESecurityUIsQueryRequestOk);
     RDEBUG("SetLockSetting", 0);
@@ -2765,23 +2540,16 @@
     switch (status)
         {
         case KErrNone:
-#if defined(_DEBUG)
-            RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() KErrNone"));
-#endif
             break;
         case KErrGsmSSPasswordAttemptsViolation:
         case KErrLocked:
-#if defined(_DEBUG)
-            RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() PasswordAttemptsViolation"));
-#endif
+        		RDEBUG("KErrLocked", KErrLocked);
             ShowResultNoteL(KErrLocked, CAknNoteDialog::EErrorTone); // the old code didn't show messages
             return ChangeAutoLockPeriodParamsL(oldPeriod, aOldPassword,
                     aFlags, aCaption, aShowError); // ask again
         case KErrGsm0707IncorrectPassword:
         case KErrAccessDenied:
-#if defined(_DEBUG)
-            RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() IncorrectPassword"));
-#endif
+        		RDEBUG("KErrAccessDenied", KErrAccessDenied);
             // code was entered erroneously
             ShowResultNoteL(KErrAccessDenied, CAknNoteDialog::EErrorTone); // the old code didn't show messages
             return ChangeAutoLockPeriodParamsL(oldPeriod, aOldPassword,
@@ -2790,16 +2558,12 @@
             // User pressed "cancel" in the code query dialog.
             return oldPeriod;
         default:
-#if defined(_DEBUG)
-            RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() default"));
-#endif
+        		RDEBUG("default", status);
             ShowResultNoteL(status, CAknNoteDialog::EErrorTone); // the old code didn't show messages
             return ChangeAutoLockPeriodParamsL(oldPeriod, aOldPassword,
                     aFlags, aCaption, aShowError); // ask again
         }
-#if defined(_DEBUG)
-    RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() END"));
-#endif
+ 		RDEBUG("aPeriod", aPeriod);
     return aPeriod;
     }
 /*****************************/
@@ -2810,13 +2574,6 @@
     {
     RDEBUG("aEnable", aEnable);
     RDEBUG("aFlags", aFlags);
-    /*****************************************************
-     *    Series 60 Customer / ETel
-     *    Series 60  ETel API
-     *****************************************************/
-#if defined(_DEBUG)
-    RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestParamsL()"));
-#endif      
     TInt simState = 0;
     TInt lEnable = aEnable;
     TInt err(KErrGeneral);
--- a/securitydialogs/Securitynotifier/Src/SecurityNotifier.cpp	Fri May 14 16:43:26 2010 +0300
+++ b/securitydialogs/Securitynotifier/Src/SecurityNotifier.cpp	Thu May 27 13:44:17 2010 +0300
@@ -226,40 +226,30 @@
 void CSecurityNotifier::GetParamsL(const TDesC8& aBuffer, TInt aReturnVal, const RMessagePtr2& aMessage)
     {
 	#if defined(_DEBUG)
-	RDebug::Printf( "%s %s (%u) searching for autolock.exe =%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x0 );
+	RDebug::Printf( "%s %s (%u) searching for autolocksrv.exe =%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x0 );
 	#endif
-	
-   // Start Dirty and quick hack    
-   #include <PSVariables.h>   // Property values
-   #include <coreapplicationuisdomainpskeys.h>
-   _LIT_SECURITY_POLICY_PASS(KReadPolicy);
-   _LIT_SECURITY_POLICY_C1(KWritePolicy, ECapabilityWriteDeviceData);
-   int ret = RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, RProperty::EInt, KReadPolicy, KWritePolicy);
-   RDebug::Printf( "%s %s (%u) EAutolockOff=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
-   RProperty::Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, 1);
-   // End Dirty and quick hack
 		
-	
 	TApaTaskList taskList( CCoeEnv::Static()->WsSession() );
 	const TUid KAutolockUid = { 0x100059B5 };
-	TApaTask task( taskList.FindApp( KAutolockUid ) );
+	//TApaTask task( taskList.FindApp( KAutolockUid ) );
+	TApaTask task( taskList.FindApp( _L("autolocksrv.exe" )) );
 	if ( !task.Exists() )
 		{
 		#if defined(_DEBUG)
-		RDebug::Printf( "%s %s (%u) autolock.exe not running. Starting now=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x1 );
+		RDebug::Printf( "%s %s (%u) sutolocksrv.exe not running. Starting now=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x1 );
 		#endif
 		RApaLsSession ls;                   
 		User::LeaveIfError(ls.Connect());   
 		CleanupClosePushL(ls);         
 		
 		CApaCommandLine* commandLine = CApaCommandLine::NewLC();
-		commandLine->SetExecutableNameL( _L("autolock.exe" ) );     
+		commandLine->SetExecutableNameL( _L("autolockarv.exe" ) );     
 		commandLine->SetCommandL( EApaCommandRun );
 		
 		// Try to launch the application.        
 		User::LeaveIfError(ls.StartApp(*commandLine));
 		#if defined(_DEBUG)
-		RDebug::Printf( "%s %s (%u) autolock.exe created=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x2 );
+		RDebug::Printf( "%s %s (%u) autolocksrv.exe created=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x2 );
 		#endif
 		
 		CleanupStack::PopAndDestroy(2); // commandLine, ls
--- a/securitydialogs/lockapp/pubsub/SecurityUIsPrivatePSKeys.h	Fri May 14 16:43:26 2010 +0300
+++ b/securitydialogs/lockapp/pubsub/SecurityUIsPrivatePSKeys.h	Thu May 27 13:44:17 2010 +0300
@@ -67,6 +67,25 @@
 const TUint32 KSecurityUIsLockInitiatorTimeLow  = 0x00000305;
 
 /**
+ * Used by Autolock to tell the status of screensaver 
+ */    
+const TUint32 KSecurityUIsScreenSaverStatus  = 0x00000306;
+enum TSecurityUIsScreenSaverValues
+    {
+    ESecurityUIsScreenSaverUninitialized = 0,
+    ESecurityUIsScreenSaverOn,
+    ESecurityUIsScreenSaverOff,
+    ESecurityUIsScreenSaverOffWhileUnguardQuery,
+    ESecurityUIsScreenSaverOffWhileUnlockQuery,
+    ESecurityUIsScreenSaverLastValue
+    };
+
+/**
+ * Used by any applicattion, to send a Code for Secui
+ */    
+const TUint32 KSecurityUIsTestCode  = 0x00000307;
+
+/**
  * Used to tell SysAp to switch-on the lights.
  */    
 const TUint32 KSecurityUIsLights  = 0x00000308;
@@ -79,6 +98,19 @@
     ESecurityUIsLightsLastValue
     };
 
+/**
+ * Used by Autolock to tell the dialog to dismiss. In fact, any app can do this.
+ */    
+const TUint32 KSecurityUIsDismissDialog  = 0x00000309;
+enum TSecurityUIsDismissDialogValues
+    {
+    ESecurityUIsDismissDialogUninitialized = 0,
+    ESecurityUIsDismissDialogOn,
+    ESecurityUIsDismissDialogProcessing,
+    ESecurityUIsDismissDialogDone,
+    ESecurityUIsDismissDialogLastValue
+    };
+
 #endif // SECURITYUISPRIVATEPSKEYS_H
 
 // End of File
--- a/securitydialogs/lockapp/src/lockappappui.cpp	Fri May 14 16:43:26 2010 +0300
+++ b/securitydialogs/lockapp/src/lockappappui.cpp	Thu May 27 13:44:17 2010 +0300
@@ -33,10 +33,7 @@
 // ---------------------------------------------------------------------------
 void CLockAppAppUi::ConstructL( )
     {
-    	RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x8 );
-    	    
-   // default appui constructor has to be called
-    BaseConstructL( );    	    
+    //	RDebug::Printf( "%s %s (%u) 1 value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x8 );
     	    
     TInt use_old_autolock=1;
     if(use_old_autolock)
@@ -44,7 +41,7 @@
 			// start autolock instead of lockapp . This is a backup solution to use in case that not all SysAp and Avkon changes are implemented
 	 	  RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x1 );
 	    TApaTaskList taskList( iCoeEnv->WsSession() );
-	    TApaTask task( taskList.FindApp( _L("autolock.exe" )) );
+	    TApaTask task( taskList.FindApp( _L("autolocksrv.exe" )) );
 	    if ( !task.Exists() )
 	        {
 	        RApaLsSession ls;                   
@@ -52,19 +49,25 @@
 	        CleanupClosePushL(ls);         
 	        
 	        CApaCommandLine* commandLine = CApaCommandLine::NewLC();
-	        commandLine->SetExecutableNameL( _L("autolock.exe" ) );     
+	        commandLine->SetExecutableNameL( _L("autolocksrv.exe" ) );     
 	        commandLine->SetCommandL( EApaCommandRun );
 	        
 		    // Try to launch the application.        
 	        User::LeaveIfError(ls.StartApp(*commandLine));
-	    	  RDebug::Printf( "%s %s (%u) autolock.exe created=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x7 );
+	    	  RDebug::Printf( "%s %s (%u) Start: autolocksrv.exe created=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0x7 );
 	        
 	        CleanupStack::PopAndDestroy(2); // commandLine, ls
 			}
-	    Exit();
 	  }
 
     INFO( "CLockAppAppUi::ConstructL started" );
+   // default appui constructor has to be called
+    BaseConstructL( );  
+    if(use_old_autolock)
+    	{  	    
+	    Exit();
+	  }
+    	    
 
     // start the server with the specified name
 	iLockServer = CLockAppServer::NewL( KLockAppServerName );
--- a/securitydialogs/secuinotifications/secuinotificationdialogplugin/inc/secuinotificationdialog.h	Fri May 14 16:43:26 2010 +0300
+++ b/securitydialogs/secuinotifications/secuinotificationdialogplugin/inc/secuinotificationdialog.h	Thu May 27 13:44:17 2010 +0300
@@ -18,12 +18,23 @@
 #ifndef SECUINOTIFICATIONDIALOG_H
 #define SECUINOTIFICATIONDIALOG_H
 
+// #define RDEBUG( x, y ) RDebug::Printf( "%s %s (%u) %s=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, x, y );
+#define RDEBUG( x, y )
+
 #include <hbdialog.h>                   // HbDialog
 #include <hbdevicedialoginterface.h>    // HbDeviceDialogInterface
 #include <hbwidget.h>       // HbWidget
 #include <hblineedit.h>       // HbWidget
 #include <hblabel.h>
 
+#include <qmobilityglobal.h>
+
+QTM_BEGIN_NAMESPACE
+    class QValueSpacePublisher;
+    class QValueSpaceSubscriber;
+QTM_END_NAMESPACE
+QTM_USE_NAMESPACE
+
 /**
  * SW Install notification widget class.
  */
@@ -65,6 +76,8 @@
 		void handlebut2Changed();
 		void handlebut3Changed();
 
+public slots:    
+    void subscriberKSecurityUIsDismissDialogChanged();
 private:
     Q_DISABLE_COPY(SecUiNotificationDialog)
 
@@ -82,6 +95,7 @@
     int queryDual;
     int lEmergencySupported;
     int isEmergency;
+    QValueSpaceSubscriber *subscriberKSecurityUIsDismissDialog;
 };
 
 #endif // SECUINOTIFICATIONDIALOG_H
--- a/securitydialogs/secuinotifications/secuinotificationdialogplugin/secuinotificationdialogplugin.pro	Fri May 14 16:43:26 2010 +0300
+++ b/securitydialogs/secuinotifications/secuinotificationdialogplugin/secuinotificationdialogplugin.pro	Thu May 27 13:44:17 2010 +0300
@@ -19,6 +19,8 @@
 CONFIG += plugin
 
 CONFIG += hb
+CONFIG += mobility
+MOBILITY = publishsubscribe
 
 # directories
 INCLUDEPATH += .
@@ -45,6 +47,9 @@
     pluginstub.sources = secuinotificationdialogplugin.dll
     pluginstub.path = /resource/plugins/devicedialogs
     DEPLOYMENT += pluginstub
+    crml.sources = secuinotificationdialogplugin.qcrml
+    crml.path = c:/resource/qt/crml
+    DEPLOYMENT += crml
 }
 BLD_INF_RULES.prj_exports += \
   "$${LITERAL_HASH}include <platform_paths.hrh>" \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/securitydialogs/secuinotifications/secuinotificationdialogplugin/secuinotificationdialogplugin.qcrml	Thu May 27 13:44:17 2010 +0300
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<repository target="RProperty" uidValue="0x100059b5">
+    <key int="0x00000309"  ref="/KPSUidSecurityUIs/KSecurityUIsDismissDialog"></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/secuinotifications/secuinotificationdialogplugin/src/secuinotificationcontentwidget.cpp	Fri May 14 16:43:26 2010 +0300
+++ b/securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationcontentwidget.cpp	Thu May 27 13:44:17 2010 +0300
@@ -209,7 +209,17 @@
 
         connect(codeTop, SIGNAL(textChanged(const QString &)), this, SIGNAL(codeTopChanged(const QString &)));
         connect(codeTop, SIGNAL(contentsChanged()), this, SIGNAL(codeTopContentChanged()));
+
+				if (parameters.contains(KDefaultCode)) {	// this is done in this step so that the OK becomes valid (if rules are fulfilled)
+					qDebug() << "SecUiNotificationContentWidget::KDefaultCode";
+  	      QString defaultCode = parameters.value(KDefaultCode).toString();
+    	    qDebug() << defaultCode;
+					codeTop->setText(defaultCode);
+					}
+				qDebug() << "SecUiNotificationContentWidget::KCodeTop 4";
+
     		mainLayout->addItem(codeTop);
+    		// double-query
     		if (parameters.contains(KCodeBottom))
     			{
     			queryDual=1;
@@ -228,7 +238,7 @@
 	 		    if (queryType & ESecUiAlphaSupported)
 			    	{
 			    	qDebug() << "SecUiNotificationContentWidget::KCodeBottom setUpAsLatinAlphabetOnlyEditor";
-	 	    		codeTop->setInputMethodHints(Qt::ImhNone);
+	 	    		codeBottom->setInputMethodHints(Qt::ImhNone);
 			  		}
 					qDebug() << "SecUiNotificationContentWidget::KCodeBottom 3";
 	        connect(codeBottom, SIGNAL(textChanged(const QString &)), this, SIGNAL(codeBottomChanged(const QString &)));
@@ -251,7 +261,7 @@
 
         mainLayout->addItem(mainLayoutButtons);
         
-        codeTop->setFocus();
+        codeTop->setFocus();	// this should open the VKB
 
     }
 
--- a/securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationdialog.cpp	Fri May 14 16:43:26 2010 +0300
+++ b/securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationdialog.cpp	Thu May 27 13:44:17 2010 +0300
@@ -23,10 +23,16 @@
 #include <hbaction.h>
 #include <QDebug>
 #include <e32debug.h>
-#include <CPhCltEmergencyCall.h>
+#include <cphcltemergencycall.h>
 #include <SCPServerInterface.h>	// for TARM error codes while validating new lock code
 #include <QString>
 #include <QDialogButtonBox>
+#include <e32property.h>
+
+QTM_USE_NAMESPACE
+
+#include <qvaluespacesubscriber.h>
+#include <qvaluespacepublisher.h>
 
 #define ESecUiCancelSupported  0x1000000
 #define ESecUiCancelNotSupported  0x0000000
@@ -50,6 +56,9 @@
 
 #define ESecUiTypeMaskLock			0x00F00000
 
+const TUid KPSUidSecurityUIs = { 0x100059b5 };
+const TUint32 KSecurityUIsDismissDialog  = 0x00000309;
+
 // ----------------------------------------------------------------------------
 // SecUiNotificationDialog::SecUiNotificationDialog()
 // ----------------------------------------------------------------------------
@@ -97,8 +106,9 @@
 void SecUiNotificationDialog::closeDeviceDialog(bool byClient)
 {
     Q_UNUSED(byClient);
+		qDebug() << "SecUiNotificationDialog::closeDeviceDialog 0";
     close();
-		qDebug() << "SecUiNotificationDialog::closeDeviceDialog";
+		qDebug() << "SecUiNotificationDialog::closeDeviceDialog 1";
 
     // 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.
@@ -135,6 +145,33 @@
 {
 		qDebug() << "SecUiNotificationDialog::showEvent";
     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
+			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;
+			if(value>0 && mShowEventReceived==false)	// show happens 2 times. Dialog can be closed only the second.
+				{
+				QString myString = "";
+				myString += QString("%1").arg(value);
+				qDebug() << "SecUiNotificationDialog::faking myString=" << myString;
+		    codeTop->setText( myString );
+		    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
+				}
+			}
     mShowEventReceived = true;
 }
 
@@ -148,6 +185,7 @@
     setTimeout(HbPopup::NoTimeout);
     setDismissPolicy(HbPopup::NoDismiss);
     setModal(true);
+    mShowEventReceived = false;
 
     // Title
     if (parameters.contains(KDialogTitle)) {
@@ -207,8 +245,7 @@
 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode ???";
 	        	// nothing to do
 	        	}
-/*
-	        if(invalidNumber==EDeviceLockAutolockperiod)
+			if(invalidNumber==EDeviceLockAutolockperiod)
 	        	{
 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockAutolockperiod";
 	        	title->setPlainText("EDeviceLockAutolockperiod");
@@ -298,7 +335,6 @@
 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDevicelockTotalPolicies";
 	        	title->setPlainText("EDevicelockTotalPolicies");
 	        	}
-	        	*/
 	        // always keep OK valid.
    				return true;
 	    }
@@ -343,6 +379,17 @@
     // setAction(cancelAction, QDialogButtonBox::RejectRole);		// it's supposed to use this, when deprecated
     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);
+    subscriberKSecurityUIsDismissDialog = new QValueSpaceSubscriber(
+            "/KPSUidSecurityUIs/KSecurityUIsDismissDialog", this);
+    connect(subscriberKSecurityUIsDismissDialog, SIGNAL(contentsChanged()), this,
+            SLOT(subscriberKSecurityUIsDismissDialogChanged()));
+	qDebug() << "subscribed to KSecurityUIsDismissDialog";
+	
 		qDebug() << "SecUiNotificationDialog check Cancel";
     if ((queryType & ESecUiCancelSupported)==ESecUiCancelSupported)
     	{
@@ -547,5 +594,42 @@
 //
 void SecUiNotificationDialog::saveFocusWidget(QWidget*,QWidget*)
 {
-		qDebug() << "SecUiNotificationDialog::saveFocusWidget";
+		RDEBUG("0", 0);
 }
+
+// ----------------------------------------------------------------------------
+// SecUiNotificationDialog::subscriberKSecurityUIsDismissDialogChanged()
+// A way for Autolock to dismiss any possible PIN dialog
+// ----------------------------------------------------------------------------
+//
+void SecUiNotificationDialog::subscriberKSecurityUIsDismissDialogChanged()
+    {
+enum TSecurityUIsDismissDialogValues
+    {
+    ESecurityUIsDismissDialogUninitialized = 0,
+    ESecurityUIsDismissDialogOn,
+    ESecurityUIsDismissDialogProcessing,
+    ESecurityUIsDismissDialogDone,
+    ESecurityUIsDismissDialogLastValue
+    };
+
+    TInt ret;
+    RDEBUG("0", 0);
+    TInt aDismissDialog = ESecurityUIsDismissDialogUninitialized;
+    TInt err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsDismissDialog, aDismissDialog );
+    RDEBUG("err", err);
+	RDEBUG("aDismissDialog", aDismissDialog);
+    if( aDismissDialog == ESecurityUIsDismissDialogOn )
+    	{
+		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("emit closeDeviceDialog", 0);
+		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);
+    	}
+	}
\ No newline at end of file
--- a/wim/WimServer/src/WimSatRefreshObserver.cpp	Fri May 14 16:43:26 2010 +0300
+++ b/wim/WimServer/src/WimSatRefreshObserver.cpp	Thu May 27 13:44:17 2010 +0300
@@ -23,8 +23,8 @@
 #include "WimServer.h"
 #include "WimSession.h"
 #include "WimTrace.h"
-#include <RSatRefresh.h>
-#include <RSatSession.h>
+#include <rsatrefresh.h>
+#include <rsatsession.h>
 #include <etelsat.h>
 #if defined SAT_REFRESH_TIMER_TRIGGER
 #include "SatRefreshTimerTrigger.h" // for simulated sat refresh