securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationdialog.cpp
changeset 37 7bad16cccaca
parent 26 aad866c37519
child 38 e0432375ea67
--- a/securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationdialog.cpp	Fri Jun 11 14:28:40 2010 +0300
+++ b/securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationdialog.cpp	Wed Jun 23 19:10:54 2010 +0300
@@ -33,6 +33,10 @@
 
 #include <qvaluespacesubscriber.h>
 #include <qvaluespacepublisher.h>
+#define ESecUiBasicTypeText    0x0000000
+#define ESecUiBasicTypeCheck   0x0010000
+#define ESecUiBasicTypeCheckMulti   0x0020000
+#define ESecUiBasicTypeMask    0x00F0000
 
 #define ESecUiCancelSupported  0x1000000
 #define ESecUiCancelNotSupported  0x0000000
@@ -59,6 +63,15 @@
 const TUid KPSUidSecurityUIs = { 0x100059b5 };
 const TUint32 KSecurityUIsDismissDialog  = 0x00000309;
 
+enum TSecurityUIsDismissDialogValues
+    {
+    ESecurityUIsDismissDialogUninitialized = 0,
+    ESecurityUIsDismissDialogOn,
+    ESecurityUIsDismissDialogProcessing,
+    ESecurityUIsDismissDialogDone,
+    ESecurityUIsDismissDialogLastValue
+    };
+
 // ----------------------------------------------------------------------------
 // SecUiNotificationDialog::SecUiNotificationDialog()
 // ----------------------------------------------------------------------------
@@ -66,7 +79,7 @@
 SecUiNotificationDialog::SecUiNotificationDialog(
         const QVariantMap &parameters) : HbDialog(), mLastError(KNoError)
 {
-		qDebug() << "SecUiNotificationDialog::SecUiNotificationDialog";
+		RDEBUG("0", 0);
     constructDialog(parameters);
 }
 
@@ -84,7 +97,7 @@
 //
 bool SecUiNotificationDialog::setDeviceDialogParameters(const QVariantMap &parameters)
 {
-		qDebug() << "SecUiNotificationDialog::setDeviceDialogParameters";
+	 RDEBUG("0", 0);
    return constructDialog(parameters);
 }
 
@@ -94,8 +107,7 @@
 //
 int SecUiNotificationDialog::deviceDialogError() const
 {
-		qDebug() << "SecUiNotificationDialog::deviceDialogError";
-		qDebug() << mLastError;
+		RDEBUG("mLastError", mLastError);
     return mLastError;
 }
 
@@ -106,9 +118,9 @@
 void SecUiNotificationDialog::closeDeviceDialog(bool byClient)
 {
     Q_UNUSED(byClient);
-		qDebug() << "SecUiNotificationDialog::closeDeviceDialog 0";
+		RDEBUG("0", 0);
     close();
-		qDebug() << "SecUiNotificationDialog::closeDeviceDialog 1";
+		RDEBUG("mShowEventReceived", mShowEventReceived);
 
     // If show event has been received, close is signalled from hide event.
     // If not, hide event does not come and close is signalled from here.
@@ -132,9 +144,14 @@
 //
 void SecUiNotificationDialog::hideEvent(QHideEvent *event)
 {
-		qDebug() << "SecUiNotificationDialog::hideEvent";
+		RDEBUG("0", 0);
     HbDialog::hideEvent(event);
-    emit deviceDialogClosed();
+		RDEBUG("close", 0);
+		close();
+		RDEBUG("deviceDialogClosed", 0);
+		emit deviceDialogClosed();
+		RDEBUG("deviceDialogClosed", 1);
+    // old method was   emit deviceDialogClosed();
 }
 
 // ----------------------------------------------------------------------------
@@ -143,23 +160,27 @@
 //
 void SecUiNotificationDialog::showEvent(QShowEvent *event)
 {
-		qDebug() << "SecUiNotificationDialog::showEvent";
+		RDEBUG("0", 0);
     HbDialog::showEvent(event);
 
 		if(!(queryType & ESecUiTypeMaskLock))
 			{	// not for the "lock icon"
-			qDebug() << "SecUiNotificationDialog::showEvent check default";
-			if(codeTop->text().length()>0)	// there's a default value. Verify it and (might) enable OK
-				{
-				qDebug() << "SecUiNotificationDialog::showEvent checked default";
-				handleCodeTopChanged(codeTop->text());
-				}
-			// for automated testing, read a P&S and use this value as if the user typed it
+			RDEBUG("check default.1", 0);
+			if(codeTop!=NULL)
+            {
+                RDEBUG("check default.2", 0);
+                if(codeTop->text().length()>0)	// there's a default value. Verify it and (might) enable OK
+                {
+                RDEBUG("check default.3", 0);
+                handleCodeTopChanged(codeTop->text());
+                }
+            
+            }
 			const TUint32 KSecurityUIsTestCode  = 0x00000307;
 			TInt value = 0;
 			TInt err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsTestCode, value );
-			qDebug() << "SecUiNotificationDialog::faking KSecurityUIsTestCode err=" << err;
-			qDebug() << "SecUiNotificationDialog::faking value=" << value;
+			RDEBUG("KSecurityUIsTestCode err", err);
+			RDEBUG("faking value", value);
 			if(value>0 && mShowEventReceived==true)	// show happens 2 times. Dialog can be closed only the second.
 				{
 				QString myString = "";
@@ -169,7 +190,7 @@
 		    TInt err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsTestCode, 0 );	// clear after using it
 				qDebug() << "SecUiNotificationDialog::calling handleAccepted=" << myString;
 		    emit handleAccepted();
-				emit closeDeviceDialog(false);	// false means "not by client", although it's not really used
+				// handleAccepted already   emit closeDeviceDialog(false);	// false means "not by client", although it's not really used
 				}
 			}
     mShowEventReceived = true;
@@ -181,7 +202,7 @@
 //
 bool SecUiNotificationDialog::constructDialog(const QVariantMap &parameters)
     {
-		qDebug() << "SecUiNotificationDialog::constructDialog";
+		RDEBUG("0", 0);
     setTimeout(HbPopup::NoTimeout);
     setDismissPolicy(HbPopup::NoDismiss);
     setModal(true);
@@ -200,7 +221,7 @@
     				titleAttempts = titleText.right(titleText.length()-titleText.indexOf('#')-1);
     				qDebug() << "SecUiNotificationDialog::titleAttempts=" << titleAttempts;
     				int nAttempts = titleAttempts.toInt();
-    				qDebug() << "SecUiNotificationDialog::nAttempts=" << nAttempts;
+    				RDEBUG("nAttempts", nAttempts);
     				titleText = titleText.left(titleText.indexOf('#'));
     				if(nAttempts>0)
     					titleText = titleText + " attempts=" + QString::number(nAttempts);
@@ -210,12 +231,12 @@
     }
 
 	    if (parameters.contains(KEmergency)) {
-					qDebug() << "SecUiNotificationDialog::KEmergency";
+					RDEBUG("KEmergency", 1);
 	        QString emergencyText = parameters.value(KEmergency).toString();
 	        qDebug() << emergencyText;
 	        if(!emergencyText.compare("emergencyYes"))
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KEmergency emergencyYes";
+	        	RDEBUG("emergencyYes", 1);
 	        	isEmergency = 1;
 	        	okAction->setEnabled(true);
 	        	okAction->setText("Call");
@@ -223,7 +244,7 @@
 	        	}
 	        if(!emergencyText.compare("emergencyNo"))
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KEmergency emergencyNo";
+	        	RDEBUG("emergencyNo", 1);
 	        	isEmergency = 0;
 	        	okAction->setEnabled(false);	// 112 -> 1122 (=password) . This is handled by   < lMinLength 
 	        	okAction->setText("Ok");
@@ -232,107 +253,107 @@
 	    }
 	    // after TARM validation.
 	    if (parameters.contains(KInvalidNewLockCode)) {
-					qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode";
+					RDEBUG("KInvalidNewLockCode", 0);
 	        QString invalidText = parameters.value(KInvalidNewLockCode).toString();
 	        qDebug() << invalidText;
 
 	        title->setPlainText("Lock Code");	// TODO take from the original one
 	        QString invalidStr = invalidText.right(invalidText.length()-invalidText.indexOf('#')-1);
 	        int invalidNumber = invalidStr.toInt();
-	        qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode invalidNumber" << invalidNumber;
+	        RDEBUG("invalidNumber", invalidNumber);
 	        if(invalidNumber<0)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode ???";
+	        	RDEBUG("invalidNumber<0", invalidNumber );
 	        	// nothing to do
 	        	}
-			if(invalidNumber==EDeviceLockAutolockperiod)
+				if(invalidNumber==EDeviceLockAutolockperiod)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockAutolockperiod";
+	        	RDEBUG("EDeviceLockAutolockperiod", invalidNumber );
 	        	title->setPlainText("EDeviceLockAutolockperiod");
 	        	}
 	        if(invalidNumber==EDeviceLockMaxAutolockPeriod)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMaxAutolockPeriod";
+	        	RDEBUG("EDeviceLockAutolockperiod", invalidNumber );
 	        	title->setPlainText("EDeviceLockMaxAutolockPeriod");
 	        	}
 	        if(invalidNumber==EDeviceLockMinlength)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinlength";
+	        	RDEBUG("EDeviceLockMinlength", invalidNumber );
 	        	title->setPlainText("EDeviceLockMinlength");
 	        	}
 	        if(invalidNumber==EDeviceLockMaxlength)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMaxlength";
+	        	RDEBUG("EDeviceLockMaxlength", invalidNumber );
 	        	title->setPlainText("EDeviceLockMaxlength");
 	        	}
 	        if(invalidNumber==EDeviceLockRequireUpperAndLower)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockRequireUpperAndLower";
+	        	RDEBUG("EDeviceLockRequireUpperAndLower", invalidNumber );
 	        	title->setPlainText("EDeviceLockRequireUpperAndLower");
 	        	}
 	        if(invalidNumber==EDeviceLockRequireCharsAndNumbers)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockRequireCharsAndNumbers";
+	        	RDEBUG("EDeviceLockMaxlength", invalidNumber );
 	        	title->setPlainText("EDeviceLockMaxlength");
 	        	}
 	        if(invalidNumber==EDeviceLockAllowedMaxRepeatedChars)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockAllowedMaxRepeatedChars";
+	        	RDEBUG("EDeviceLockAllowedMaxRepeatedChars", invalidNumber );
 	        	title->setPlainText("EDeviceLockAllowedMaxRepeatedChars");
 	        	}
 	        if(invalidNumber==EDeviceLockHistoryBuffer)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockHistoryBuffer";
+	        	RDEBUG("EDeviceLockHistoryBuffer", invalidNumber );
 	        	title->setPlainText("EDeviceLockHistoryBuffer");
 	        	}
 	        if(invalidNumber==EDeviceLockPasscodeExpiration)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockPasscodeExpiration";
+	        	RDEBUG("EDeviceLockPasscodeExpiration", invalidNumber );
 	        	title->setPlainText("EDeviceLockPasscodeExpiration");
 	        	}
 	        if(invalidNumber==EDeviceLockMinChangeTolerance)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinChangeTolerance";
+	        	RDEBUG("EDeviceLockMinChangeTolerance", invalidNumber );
 	        	title->setPlainText("EDeviceLockMinChangeTolerance");
 	        	}
 	        if(invalidNumber==EDeviceLockMinChangeInterval)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinChangeInterval";
+	        	RDEBUG("EDeviceLockMinChangeInterval", invalidNumber );
 	        	title->setPlainText("EDeviceLockMinChangeInterval");
 	        	}
 	        if(invalidNumber==EDeviceLockDisallowSpecificStrings)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockDisallowSpecificStrings";
+	        	RDEBUG("EDeviceLockDisallowSpecificStrings", invalidNumber );
 	        	title->setPlainText("EDeviceLockDisallowSpecificStrings");
 	        	}
 	        if(invalidNumber==EDeviceLockAllowedMaxAtempts)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockAllowedMaxAtempts";
+	        	RDEBUG("EDeviceLockAllowedMaxAtempts", invalidNumber );
 	        	title->setPlainText("EDeviceLockAllowedMaxAtempts");
 	        	}
 	        if(invalidNumber==EDeviceLockConsecutiveNumbers)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockConsecutiveNumbers";
+	        	RDEBUG("EDeviceLockConsecutiveNumbers", invalidNumber );
 	        	title->setPlainText("EDeviceLockConsecutiveNumbers");
 	        	}
 	        if(invalidNumber==EDeviceLockMinSpecialCharacters)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinSpecialCharacters";
+	        	RDEBUG("EDeviceLockMinSpecialCharacters", invalidNumber );
 	        	title->setPlainText("EDeviceLockMinSpecialCharacters");
 	        	}
 	        if(invalidNumber==EDeviceLockSingleCharRepeatNotAllowed)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockSingleCharRepeatNotAllowed";
+	        	RDEBUG("EDeviceLockSingleCharRepeatNotAllowed", invalidNumber );
 	        	title->setPlainText("EDeviceLockSingleCharRepeatNotAllowed");
 	        	}
 	        if(invalidNumber==EDevicelockConsecutiveCharsNotAllowed)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDevicelockConsecutiveCharsNotAllowed";
+	        	RDEBUG("EDevicelockConsecutiveCharsNotAllowed", invalidNumber );
 	        	title->setPlainText("EDevicelockConsecutiveCharsNotAllowed");
 	        	}
 	        if(invalidNumber>=EDevicelockTotalPolicies)
 	        	{
-	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDevicelockTotalPolicies";
+	        	RDEBUG("EDevicelockTotalPolicies", invalidNumber );
 	        	title->setPlainText("EDevicelockTotalPolicies");
 	        	}
 	        if(invalidNumber<0)	// everything is ok
@@ -360,7 +381,10 @@
 		queryType = content->queryType;
 		queryDual = content->queryDual;
 		isEmergency = content->isEmergency;
+    codeTop=NULL;
 		codeTop = content->codeTop;
+    checkBox = content->checkbox;
+    listWidget = content->listWidget;
 		codeBottom = content->codeBottom;
 		lMinLength = content->lMinLength;
 		lMaxLength = content->lMaxLength;
@@ -372,8 +396,7 @@
     connect(content, SIGNAL(but1Changed()), this, SLOT(handlebut1Changed()));
     connect(content, SIGNAL(but2Changed()), this, SLOT(handlebut2Changed()));
     connect(content, SIGNAL(but3Changed()), this, SLOT(handlebut3Changed()));
-		qDebug() << "SecUiNotificationDialog::queryType=";
-		qDebug() << queryType;
+		RDEBUG("queryType", queryType);
     // Buttons
     if( (queryType & ESecUiTypeMaskLock))
     	{
@@ -382,35 +405,56 @@
     	}
 
     okAction = new HbAction(tr("Ok"));
+    RDEBUG("created HbAction okAction", 1);
     okAction->setEnabled(false);	// initially the OK is disabled because codeTop is empty
+    if((queryType & ESecUiBasicTypeMask) ==ESecUiBasicTypeCheck) {
+        okAction->setEnabled(true);
+        setHeadingWidget(0); // had to remove this no multiline
+    }
+    else if ((queryType & ESecUiBasicTypeMask) ==ESecUiBasicTypeCheckMulti){
+        okAction->setEnabled(true);
+    }
+
     // setAction(okAction, QDialogButtonBox::AcceptRole);	// it's supposed to use this, when deprecated
-    setPrimaryAction(okAction);
+    // setPrimaryAction(okAction);
+    addAction(okAction);
+    disconnect(okAction, SIGNAL(triggered()), this, SLOT(close()));	// the close will be done in handleAccepted
     connect(okAction, SIGNAL(triggered()), this, SLOT(handleAccepted()));
     
     cancelAction = new HbAction(tr("Cancel"));    // qtTrId("txt_common_button_cancel")
+    addAction(cancelAction);
+    disconnect(cancelAction, SIGNAL(triggered()), this, SLOT(close()));	// the close will be done in handleCancelled
     connect(cancelAction, SIGNAL(triggered()), this, SLOT(handleCancelled()));
     // setAction(cancelAction, QDialogButtonBox::RejectRole);		// it's supposed to use this, when deprecated
-    setSecondaryAction(cancelAction);
+    // setSecondaryAction(cancelAction);
 
 		// this should had been set by Autolock, but just to be sure
     TInt ret = RProperty::Define(KPSUidSecurityUIs, KSecurityUIsDismissDialog,
             RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass),
             TSecurityPolicy(TSecurityPolicy::EAlwaysPass));
     RDEBUG("defined KSecurityUIsDismissDialog", ret);
+    TInt aDismissDialog = -1;
+    ret = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsDismissDialog, aDismissDialog );
+    RDEBUG("ret", ret);
+    RDEBUG("aDismissDialog", aDismissDialog);
+    if(aDismissDialog==ESecurityUIsDismissDialogOn || aDismissDialog==ESecurityUIsDismissDialogProcessing)
+    	{
+    	RDebug::Printf( "potential error: %s %s (%u) aDismissDialog=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aDismissDialog );
+    	}
     subscriberKSecurityUIsDismissDialog = new QValueSpaceSubscriber(
             "/KPSUidSecurityUIs/KSecurityUIsDismissDialog", this);
     connect(subscriberKSecurityUIsDismissDialog, SIGNAL(contentsChanged()), this,
             SLOT(subscriberKSecurityUIsDismissDialogChanged()));
-	qDebug() << "subscribed to KSecurityUIsDismissDialog";
+		RDEBUG("subscriberKSecurityUIsDismissDialog", 1);
 	
-		qDebug() << "SecUiNotificationDialog check Cancel";
+		RDEBUG("check cancel", 0);
     if ((queryType & ESecUiCancelSupported)==ESecUiCancelSupported)
     	{
     		// nothing to do. Cancel is enabled by default
     	}
   	else
   		{
-				qDebug() << "disable Cancel";
+				RDEBUG("disable Cancel", 1);
   			cancelAction->setEnabled(false);
   		}
     
@@ -423,14 +467,14 @@
 //
 void SecUiNotificationDialog::sendResult(int accepted)
 {
-		qDebug() << "SecUiNotificationDialog::sendResult 1.2";
+		RDEBUG("0", 0);
     QVariant acceptedValue(accepted);
-		qDebug() << "SecUiNotificationDialog::sendResult 2";
+		RDEBUG("0", 0);
     mResultMap.insert(KResultAccepted, acceptedValue);
-		qDebug() << "SecUiNotificationDialog::sendResult 3";
+		RDEBUG("0", 0);
 		qDebug() << mResultMap;
     emit deviceDialogData(mResultMap);
-		qDebug() << "SecUiNotificationDialog::sendResult end";
+		RDEBUG("0", 0);
 }
 
 // ----------------------------------------------------------------------------
@@ -439,21 +483,40 @@
 //
 void SecUiNotificationDialog::handleAccepted()
 {
-		qDebug() << "SecUiNotificationDialog::handleAccepted";
+		RDEBUG("0", 0);
 		// okAction
-		QString codeTopText;
+		QString codeTopText="";
 
 		if( (queryType & ESecUiTypeMaskLock))
     	{
     	codeTopText = "Unlock-Request";
     	}
-    else
+    else if( (queryType & ESecUiBasicTypeMask)==ESecUiBasicTypeCheck)
+    	{
+        codeTopText=(checkBox->isChecked() ?  "1":"0");
+        mResultMap.insert(KCodeTopIndex,  codeTopText);
+    	}
+    else if( (queryType & ESecUiBasicTypeMask)==ESecUiBasicTypeCheckMulti)
     	{
-    	codeTopText = codeTop->text();
+        QItemSelectionModel *selectionModel = listWidget->selectionModel();
+        QModelIndexList selectedItems = selectionModel->selectedIndexes();
+        QModelIndex index;
+        codeTopText="";
+         foreach(index, selectedItems) { 
+		 		 codeTopText+=QString::number(index.row());
+                //could also use  if(index.row()!=selectedItems.count()-1) codeTopText+= "|";
+                codeTopText+= "|";
+                }
+         mResultMap.insert(KCodeTopIndex,  codeTopText);
     	}
+    else
+        codeTopText = codeTop->text();
     // TODO check last time for codeBottom
    	qDebug() << "codeTopText=" << codeTopText;
     sendResult(KErrNone);
+    close();	// this is needed because Cancel doesn't automatically closes the dialog
+		RDEBUG("close", 0);
+		emit deviceDialogClosed();
 }
 
 // ----------------------------------------------------------------------------
@@ -462,8 +525,11 @@
 //
 void SecUiNotificationDialog::handleCancelled()
 {
-		qDebug() << "SecUiNotificationDialog::handleCancelled";
+		RDEBUG("0", 0);
     sendResult(KErrCancel);
+    close();	// this is needed because Cancel doesn't automatically closes the dialog
+		RDEBUG("close", 0);
+		emit deviceDialogClosed();
 }
 
 // ----------------------------------------------------------------------------
@@ -472,7 +538,7 @@
 //
 void SecUiNotificationDialog::handleMemorySelectionChanged(const QString &text)
     {
-    	qDebug() << "SecUiNotificationDialog::handleMemorySelectionChanged";
+		RDEBUG("0", 0);
     	qDebug() << text;
     QVariant memorySelection(text);
     mResultMap.insert(KSelectedMemoryIndex, memorySelection);
@@ -482,7 +548,7 @@
 
 void SecUiNotificationDialog::handleCodeTopContentChanged()
     {
-    	qDebug() << "SecUiNotificationDialog::handleCodeTopContentChanged";
+		RDEBUG("0", 0);
     	qDebug() << codeTop->text();
     	handleCodeTopChanged(codeTop->text());
     }
@@ -493,7 +559,7 @@
 //
 void SecUiNotificationDialog::handleCodeTopChanged(const QString &text)
     {
-    	qDebug() << "SecUiNotificationDialog::handleCodeTopChanged";
+		RDEBUG("0", 0);
     	qDebug() << "SecUiNotificationDialog::handleCodeTopChanged=" << text ;
     	if(queryDual)
     		{
@@ -501,19 +567,19 @@
     		}
     	if( queryType == 0x1000004 )	// new codeLock
     		{	// ChangeSecCodeParamsL change RMobilePhone::ESecurityCodePhonePassword
-			    QVariant codeTop(text);
-			    mResultMap.insert(KCodeTopIndex, codeTop);
+			    QVariant codeTopVar(text);
+			    mResultMap.insert(KCodeTopIndex, codeTopVar);
 					sendResult(KErrCompletion);	// send the current password back to the client for further TARM validation. This is done on any key-press, not in the OK
     		}
     	if(text.length() < lMinLength )
     		{
     		qDebug() << "SecUiNotificationDialog::handleCodeTopChanged too short:" << text ;
     		okAction->setEnabled(false);
-
+				RDEBUG("lEmergencySupported", lEmergencySupported);
 				if( lEmergencySupported && text.length() > 2 )	// emergency numbers need at least 3 digits
 					{	// check whether it's a emergency number
-					QVariant codeTop(text);
-  				mResultMap.insert(KCodeTopIndex, codeTop);
+					QVariant codeTopVar(text);
+  				mResultMap.insert(KCodeTopIndex, codeTopVar);
 					sendResult(KErrAbort);	// send the current password back to the client. Perhaps it's an emergency number and decides to Ok->Call
 					}
     		}
@@ -525,8 +591,8 @@
     		if(queryDual==0)	// only if Bottom is not used
     			okAction->setEnabled(true);
     		}
-    QVariant codeTop(text);
-    mResultMap.insert(KCodeTopIndex, codeTop);
+    QVariant codeTopVar(text);
+    mResultMap.insert(KCodeTopIndex, codeTopVar);
     }
 // ----------------------------------------------------------------------------
 // SecUiNotificationDialog::handleCodeBottomChanged()
@@ -534,7 +600,7 @@
 //
 void SecUiNotificationDialog::handleCodeBottomChanged(const QString &text)
     {
-    	qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged";
+		RDEBUG("0", 0);
     	qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged" << text ;
     	qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged. codeTop=" << codeTop->text() ;
     	// TODO compare 
@@ -566,7 +632,7 @@
 //
 void SecUiNotificationDialog::handlebut1Changed()
     {
-    	qDebug() << "SecUiNotificationDialog::handlebut1Changed";
+		RDEBUG("0", 0);
     	codeTop->setText("1234");
     }
 // ----------------------------------------------------------------------------
@@ -575,7 +641,7 @@
 //
 void SecUiNotificationDialog::handlebut2Changed()
     {
-    	qDebug() << "SecUiNotificationDialog::handlebut2Changed";
+		RDEBUG("0", 0);
     	QString codeTopText = codeTop->text();
     	qDebug() << "codeTopText";
     	qDebug() << codeTopText;
@@ -617,14 +683,6 @@
 //
 void SecUiNotificationDialog::subscriberKSecurityUIsDismissDialogChanged()
     {
-enum TSecurityUIsDismissDialogValues
-    {
-    ESecurityUIsDismissDialogUninitialized = 0,
-    ESecurityUIsDismissDialogOn,
-    ESecurityUIsDismissDialogProcessing,
-    ESecurityUIsDismissDialogDone,
-    ESecurityUIsDismissDialogLastValue
-    };
 
     RDEBUG("0", 0);
     TInt aDismissDialog = ESecurityUIsDismissDialogUninitialized;
@@ -636,10 +694,14 @@
 		err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogProcessing );
 		RDEBUG("err", err);
 		// TODO perhaps do this only if Cancel is allowed?
-		RDEBUG("sendResult(KErrDied)", 0);
-		sendResult(KErrDied);	// similar to     emit handleCancelled();
+		RDEBUG("sendResult(KErrCancel)", KErrCancel);	// another option is KErrDied
+		sendResult(KErrCancel);	// similar to     emit handleCancelled();
+		RDEBUG("close", 0);
+		close();
 		RDEBUG("emit closeDeviceDialog", 0);
-		emit closeDeviceDialog(false);	// false means "not by client", although it's not really used
+		emit deviceDialogClosed();
+		// RDEBUG("emit closeDeviceDialog", 0);
+		// this is old method    emit closeDeviceDialog(false);	// false means "not by client", although it's not really used
 		RDEBUG("all emited", 0);
 		err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogDone );	// clear after using it
 		RDEBUG("err", err);