securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationdialog.cpp
branchGCC_SURGE
changeset 40 604cd42065d1
parent 38 e0432375ea67
child 45 5d3e34b7618a
equal deleted inserted replaced
29:b63e8c2d8cff 40:604cd42065d1
    13 *
    13 *
    14 * Description: SecUi notification plugin class.
    14 * Description: SecUi notification plugin class.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
       
    18 #include "secuinotificationdebug.h"
    18 #include "secuinotificationdialog.h"
    19 #include "secuinotificationdialog.h"
    19 #include "secuinotificationdialogpluginkeys.h"
    20 #include "secuinotificationdialogpluginkeys.h"
    20 #include "secuinotificationcontentwidget.h"
    21 #include "secuinotificationcontentwidget.h"
    21 // #include <hbpopupbase.h>        // HbPopupBase::NoTimeout
    22 // #include <hbpopupbase.h>        // HbPopupBase::NoTimeout
    22 #include <hblabel.h>
    23 #include <hblabel.h>
    23 #include <hbaction.h>
    24 #include <hbaction.h>
    24 #include <QDebug>
    25 #include <QDebug>
    25 #include <e32debug.h>
    26 #include <e32debug.h>
    26 #include <CPhCltEmergencyCall.h>
    27 #include <cphcltemergencycall.h>
    27 #include <SCPServerInterface.h>	// for TARM error codes while validating new lock code
    28 #include <SCPServerInterface.h>	// for TARM error codes while validating new lock code
    28 #include <QString>
    29 #include <QString>
    29 #include <QDialogButtonBox>
    30 #include <QDialogButtonBox>
       
    31 #include <HbEditorInterface>
       
    32 #include <e32property.h>
       
    33 
       
    34 QTM_USE_NAMESPACE
       
    35 
       
    36 #include <qvaluespacesubscriber.h>
       
    37 #include <qvaluespacepublisher.h>
       
    38 #define ESecUiBasicTypeText    0x0000000
       
    39 #define ESecUiBasicTypeCheck   0x0010000
       
    40 #define ESecUiBasicTypeCheckMulti   0x0020000
       
    41 #define ESecUiBasicTypeMask    0x00F0000
    30 
    42 
    31 #define ESecUiCancelSupported  0x1000000
    43 #define ESecUiCancelSupported  0x1000000
    32 #define ESecUiCancelNotSupported  0x0000000
    44 #define ESecUiCancelNotSupported  0x0000000
    33 
    45 
    34 #define ESecUiEmergencySupported  0x2000000
    46 #define ESecUiEmergencySupported  0x2000000
    48 #define ESecUiTypeClock  				0x00300000
    60 #define ESecUiTypeClock  				0x00300000
    49 #define ESecUiTypeScreensaver		0x00400000
    61 #define ESecUiTypeScreensaver		0x00400000
    50 
    62 
    51 #define ESecUiTypeMaskLock			0x00F00000
    63 #define ESecUiTypeMaskLock			0x00F00000
    52 
    64 
       
    65 const TUid KPSUidSecurityUIs = { 0x100059b5 };
       
    66 const TUint32 KSecurityUIsDismissDialog  = 0x00000309;
       
    67 
       
    68 enum TSecurityUIsDismissDialogValues
       
    69     {
       
    70     ESecurityUIsDismissDialogUninitialized = 0,
       
    71     ESecurityUIsDismissDialogOn,
       
    72     ESecurityUIsDismissDialogProcessing,
       
    73     ESecurityUIsDismissDialogDone,
       
    74     ESecurityUIsDismissDialogLastValue
       
    75     };
       
    76 
    53 // ----------------------------------------------------------------------------
    77 // ----------------------------------------------------------------------------
    54 // SecUiNotificationDialog::SecUiNotificationDialog()
    78 // SecUiNotificationDialog::SecUiNotificationDialog()
    55 // ----------------------------------------------------------------------------
    79 // ----------------------------------------------------------------------------
    56 //
    80 //
    57 SecUiNotificationDialog::SecUiNotificationDialog(
    81 SecUiNotificationDialog::SecUiNotificationDialog(
    58         const QVariantMap &parameters) : HbDialog(), mLastError(KNoError)
    82         const QVariantMap &parameters) : HbDialog(), mLastError(KNoError)
    59 {
    83 {
    60 		qDebug() << "SecUiNotificationDialog::SecUiNotificationDialog";
    84 		RDEBUG("0", 0);
       
    85 		TTime myTime;
       
    86     myTime.HomeTime();
       
    87 		mMyId = I64LOW( myTime.Int64() );
    61     constructDialog(parameters);
    88     constructDialog(parameters);
    62 }
    89 }
    63 
    90 
    64 // ----------------------------------------------------------------------------
    91 // ----------------------------------------------------------------------------
    65 // SecUiNotificationDialog::~SecUiNotificationDialog()
    92 // SecUiNotificationDialog::~SecUiNotificationDialog()
    66 // ----------------------------------------------------------------------------
    93 // ----------------------------------------------------------------------------
    67 //
    94 //
    68 SecUiNotificationDialog::~SecUiNotificationDialog()
    95 SecUiNotificationDialog::~SecUiNotificationDialog()
    69 {
    96 {
       
    97 	RDEBUG("0", 0);
    70 }
    98 }
    71 
    99 
    72 // ----------------------------------------------------------------------------
   100 // ----------------------------------------------------------------------------
    73 // SecUiNotificationDialog::setDeviceDialogParameters()
   101 // SecUiNotificationDialog::setDeviceDialogParameters()
    74 // ----------------------------------------------------------------------------
   102 // ----------------------------------------------------------------------------
    75 //
   103 //
    76 bool SecUiNotificationDialog::setDeviceDialogParameters(const QVariantMap &parameters)
   104 bool SecUiNotificationDialog::setDeviceDialogParameters(const QVariantMap &parameters)
    77 {
   105 {
    78 		qDebug() << "SecUiNotificationDialog::setDeviceDialogParameters";
   106 	 RDEBUG("0", 0);
    79    return constructDialog(parameters);
   107    return constructDialog(parameters);
    80 }
   108 }
    81 
   109 
    82 // ----------------------------------------------------------------------------
   110 // ----------------------------------------------------------------------------
    83 // SecUiNotificationDialog::deviceDialogError()
   111 // SecUiNotificationDialog::deviceDialogError()
    84 // ----------------------------------------------------------------------------
   112 // ----------------------------------------------------------------------------
    85 //
   113 //
    86 int SecUiNotificationDialog::deviceDialogError() const
   114 int SecUiNotificationDialog::deviceDialogError() const
    87 {
   115 {
    88 		qDebug() << "SecUiNotificationDialog::deviceDialogError";
   116 		RDEBUG("mLastError", mLastError);
    89 		qDebug() << mLastError;
   117 		RDEBUG("mMyId", mMyId);
    90     return mLastError;
   118     return mLastError;
    91 }
   119 }
    92 
   120 
    93 // ----------------------------------------------------------------------------
   121 // ----------------------------------------------------------------------------
    94 // SecUiNotificationDialog::closeDeviceDialog
   122 // SecUiNotificationDialog::closeDeviceDialog
    95 // ----------------------------------------------------------------------------
   123 // ----------------------------------------------------------------------------
    96 //
   124 //
    97 void SecUiNotificationDialog::closeDeviceDialog(bool byClient)
   125 void SecUiNotificationDialog::closeDeviceDialog(bool byClient)
    98 {
   126 {
    99     Q_UNUSED(byClient);
   127     Q_UNUSED(byClient);
       
   128 		RDEBUG("mMyId", mMyId);
       
   129 		RDEBUG("calling close()", 0);
   100     close();
   130     close();
   101 		qDebug() << "SecUiNotificationDialog::closeDeviceDialog";
   131 		RDEBUG("mShowEventReceived", mShowEventReceived);
   102 
   132 
   103     // If show event has been received, close is signalled from hide event.
   133     // If show event has been received, close is signalled from hide event.
   104     // If not, hide event does not come and close is signalled from here.
   134     // If not, hide event does not come and close is signalled from here.
   105     if (!mShowEventReceived) {
   135     if (!mShowEventReceived) {
       
   136     		RDEBUG("emitting deviceDialogClosed", 0);
   106         emit deviceDialogClosed();
   137         emit deviceDialogClosed();
   107     }
   138 				if(1==0 && subscriberKSecurityUIsDismissDialog)
       
   139 					{
       
   140 						RDEBUG("disconnect subscriberKSecurityUIsDismissDialog", 0);
       
   141 						disconnect(subscriberKSecurityUIsDismissDialog, SIGNAL(contentsChanged()), this, SLOT(subscriberKSecurityUIsDismissDialogChanged()));
       
   142 						RDEBUG("disconnected subscriberKSecurityUIsDismissDialog", 1);
       
   143 						if(1==1)
       
   144 							{
       
   145 							RDEBUG("deleting subscriberKSecurityUIsDismissDialog", 0);
       
   146 							delete subscriberKSecurityUIsDismissDialog;
       
   147 							subscriberKSecurityUIsDismissDialog = NULL;
       
   148 							RDEBUG("deleted subscriberKSecurityUIsDismissDialog", 1);
       
   149 							}
       
   150 				 }
       
   151     }
       
   152     RDEBUG("0", 0);
   108 }
   153 }
   109 
   154 
   110 // ----------------------------------------------------------------------------
   155 // ----------------------------------------------------------------------------
   111 // SecUiNotificationDialog::deviceDialogWidget
   156 // SecUiNotificationDialog::deviceDialogWidget
   112 // ----------------------------------------------------------------------------
   157 // ----------------------------------------------------------------------------
   120 // SecUiNotificationDialog::hideEvent
   165 // SecUiNotificationDialog::hideEvent
   121 // ----------------------------------------------------------------------------
   166 // ----------------------------------------------------------------------------
   122 //
   167 //
   123 void SecUiNotificationDialog::hideEvent(QHideEvent *event)
   168 void SecUiNotificationDialog::hideEvent(QHideEvent *event)
   124 {
   169 {
   125 		qDebug() << "SecUiNotificationDialog::hideEvent";
   170 		RDEBUG("0", 0);
   126     HbDialog::hideEvent(event);
   171     HbDialog::hideEvent(event);
   127     emit deviceDialogClosed();
   172 		RDEBUG("mMyId", mMyId);
       
   173 		RDEBUG("calling close()", 0);
       
   174 		close();
       
   175 		RDEBUG("emitting deviceDialogClosed", 0);
       
   176 		emit deviceDialogClosed();
       
   177 		RDEBUG("deviceDialogClosed", 1);
       
   178 		if(1==0 && subscriberKSecurityUIsDismissDialog)
       
   179 			{
       
   180 				RDEBUG("disconnect subscriberKSecurityUIsDismissDialog", 0);
       
   181 				disconnect(subscriberKSecurityUIsDismissDialog, SIGNAL(contentsChanged()), this, SLOT(subscriberKSecurityUIsDismissDialogChanged()));
       
   182 				RDEBUG("disconnected subscriberKSecurityUIsDismissDialog", 1);
       
   183 				if(1==1)
       
   184 					{ 
       
   185 					RDEBUG("deleting subscriberKSecurityUIsDismissDialog", 0);
       
   186 					delete subscriberKSecurityUIsDismissDialog;
       
   187 					subscriberKSecurityUIsDismissDialog = NULL;
       
   188 					RDEBUG("deleted subscriberKSecurityUIsDismissDialog", 1);
       
   189 					}
       
   190 			}
       
   191     // old method was   emit deviceDialogClosed();
       
   192    RDEBUG("0", 0);
   128 }
   193 }
   129 
   194 
   130 // ----------------------------------------------------------------------------
   195 // ----------------------------------------------------------------------------
   131 // SecUiNotificationDialog::showEvent
   196 // SecUiNotificationDialog::showEvent
   132 // ----------------------------------------------------------------------------
   197 // ----------------------------------------------------------------------------
   133 //
   198 //
   134 void SecUiNotificationDialog::showEvent(QShowEvent *event)
   199 void SecUiNotificationDialog::showEvent(QShowEvent *event)
   135 {
   200 {
   136 		qDebug() << "SecUiNotificationDialog::showEvent";
   201 		RDEBUG("0", 0);
       
   202 		RDEBUG("mMyId", mMyId);
   137     HbDialog::showEvent(event);
   203     HbDialog::showEvent(event);
       
   204 
       
   205 		if(!(queryType & ESecUiTypeMaskLock))
       
   206 			{	// not for the "lock icon"
       
   207 			RDEBUG("check default.1", 0);
       
   208 			if(codeTop!=NULL)
       
   209             {
       
   210             RDEBUG("check default.2", 0);
       
   211             if(codeTop->text().length()>0)	// there's a default value. Verify it and (might) enable OK
       
   212                 {
       
   213                 RDEBUG("check default.3", 0);
       
   214                 handleCodeTopChanged(codeTop->text());
       
   215                 }
       
   216             RDEBUG("setFocus", 0);
       
   217       			codeTop->setFocus();	// this should open the VKB . Doesn't seem to work when it's done on the widget, so it's done here.
       
   218 
       
   219             }	// codeTop!=NULL
       
   220             
       
   221 			const TUint32 KSecurityUIsTestCode  = 0x00000307;
       
   222 			TInt value = 0;
       
   223 			TInt err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsTestCode, value );
       
   224 			RDEBUG("KSecurityUIsTestCode err", err);
       
   225 			RDEBUG("faking value", value);
       
   226 			RDEBUG("mShowEventReceived", mShowEventReceived);
       
   227 			if(value>0 && mShowEventReceived==true)	// show happens 2 times. Dialog can be closed only the second.
       
   228 				{
       
   229 				QString myString = "";
       
   230 				myString += QString("%1").arg(value);
       
   231 				qDebug() << "SecUiNotificationDialog::faking myString=" << myString;
       
   232 		    codeTop->setText( myString );
       
   233 		    TInt err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsTestCode, 0 );	// clear after using it
       
   234 				qDebug() << "SecUiNotificationDialog::calling handleAccepted=" << myString;
       
   235 		    emit handleAccepted();
       
   236 				// handleAccepted already   emit closeDeviceDialog(false);	// false means "not by client", although it's not really used
       
   237 				}
       
   238 			}
   138     mShowEventReceived = true;
   239     mShowEventReceived = true;
       
   240     RDEBUG("1", 1);
   139 }
   241 }
   140 
   242 
   141 // ----------------------------------------------------------------------------
   243 // ----------------------------------------------------------------------------
   142 // SecUiNotificationDialog::constructDialog()
   244 // SecUiNotificationDialog::constructDialog()
   143 // ----------------------------------------------------------------------------
   245 // ----------------------------------------------------------------------------
   144 //
   246 //
   145 bool SecUiNotificationDialog::constructDialog(const QVariantMap &parameters)
   247 bool SecUiNotificationDialog::constructDialog(const QVariantMap &parameters)
   146     {
   248     {
   147 		qDebug() << "SecUiNotificationDialog::constructDialog";
   249 		RDEBUG("0", 0);
       
   250 		RDEBUG("mMyId", mMyId);
   148     setTimeout(HbPopup::NoTimeout);
   251     setTimeout(HbPopup::NoTimeout);
   149     setDismissPolicy(HbPopup::NoDismiss);
   252     setDismissPolicy(HbPopup::NoDismiss);
   150     setModal(true);
   253     setModal(true);
       
   254     mShowEventReceived = false;
       
   255     subscriberKSecurityUIsDismissDialog = NULL;
       
   256     titleWidget = NULL;
       
   257 		RDEBUG("subscriberKSecurityUIsDismissDialog NULL", 0);
       
   258 
       
   259     subscriberKSecurityUIsDismissDialog = new QValueSpaceSubscriber("/KPSUidSecurityUIs/KSecurityUIsDismissDialog", this);
       
   260     if(subscriberKSecurityUIsDismissDialog)
       
   261     	{
       
   262     	RDEBUG("subscriberKSecurityUIsDismissDialog created", 1);
       
   263     	}
       
   264     else
       
   265     	{
       
   266     	RDEBUG("subscriberKSecurityUIsDismissDialog not created", 0);
       
   267     	}
       
   268     connect(subscriberKSecurityUIsDismissDialog, SIGNAL(contentsChanged()), this, SLOT(subscriberKSecurityUIsDismissDialogChanged()));
       
   269 		RDEBUG("subscriberKSecurityUIsDismissDialog", 1);
   151 
   270 
   152     // Title
   271     // Title
       
   272     // this is also done later in the widget
       
   273     // For now, it only says "Security"
   153     if (parameters.contains(KDialogTitle)) {
   274     if (parameters.contains(KDialogTitle)) {
   154         QString titleText = parameters.value(KDialogTitle).toString();
   275         QString titleText = parameters.value(KDialogTitle).toString();
   155         QString titleAttempts = "";
   276         QString titleAttempts = "";
   156    			if(titleText.indexOf('|')>0)
   277    			if(titleText.indexOf('|')>0)
   157     				{	// if separator, take only first part
   278     				{	// if separator, take only first part
   160    			if(titleText.indexOf('#')>0)
   281    			if(titleText.indexOf('#')>0)
   161     				{	// if separator, take only first part
   282     				{	// if separator, take only first part
   162     				titleAttempts = titleText.right(titleText.length()-titleText.indexOf('#')-1);
   283     				titleAttempts = titleText.right(titleText.length()-titleText.indexOf('#')-1);
   163     				qDebug() << "SecUiNotificationDialog::titleAttempts=" << titleAttempts;
   284     				qDebug() << "SecUiNotificationDialog::titleAttempts=" << titleAttempts;
   164     				int nAttempts = titleAttempts.toInt();
   285     				int nAttempts = titleAttempts.toInt();
   165     				qDebug() << "SecUiNotificationDialog::nAttempts=" << nAttempts;
   286     				RDEBUG("nAttempts", nAttempts);
   166     				titleText = titleText.left(titleText.indexOf('#'));
   287     				titleText = titleText.left(titleText.indexOf('#'));
   167     				if(nAttempts>0)
   288     				if(nAttempts>0)
   168     					titleText = titleText + " attempts=" + QString::number(nAttempts);
   289     					titleText = titleText + " attempts=" + QString::number(nAttempts);
   169     				}
   290     				}
   170         title = new HbLabel(titleText);
   291     		titleText = "Security Query";	// this is the header, for any potential later error which needs to be displayed
   171         setHeadingWidget(title);
   292         // This is created only if needed (i.e. errors for NewLockCode)
       
   293         // titleWidget = new HbLabel(titleText);
       
   294         // setHeadingWidget(titleWidget);
   172     }
   295     }
   173 
   296 
   174 	    if (parameters.contains(KEmergency)) {
   297 	    if (parameters.contains(KEmergency)) {
   175 					qDebug() << "SecUiNotificationDialog::KEmergency";
   298 					RDEBUG("KEmergency", 1);
   176 	        QString emergencyText = parameters.value(KEmergency).toString();
   299 	        QString emergencyText = parameters.value(KEmergency).toString();
   177 	        qDebug() << emergencyText;
   300 	        qDebug() << emergencyText;
   178 	        if(!emergencyText.compare("emergencyYes"))
   301 	        if(!emergencyText.compare("emergencyYes"))
   179 	        	{
   302 	        	{
   180 	        	qDebug() << "SecUiNotificationDialog::KEmergency emergencyYes";
   303 	        	RDEBUG("emergencyYes", 1);
   181 	        	isEmergency = 1;
   304 	        	isEmergency = 1;
   182 	        	okAction->setEnabled(true);
   305 	        	okAction->setEnabled(true);
   183 	        	okAction->setText("Call");
   306 	        	okAction->setText("Call");
   184     				return true;
   307     				return true;
   185 	        	}
   308 	        	}
   186 	        if(!emergencyText.compare("emergencyNo"))
   309 	        if(!emergencyText.compare("emergencyNo"))
   187 	        	{
   310 	        	{
   188 	        	qDebug() << "SecUiNotificationDialog::KEmergency emergencyNo";
   311 	        	RDEBUG("emergencyNo", 1);
   189 	        	isEmergency = 0;
   312 	        	isEmergency = 0;
   190 	        	okAction->setEnabled(false);	// 112 -> 1122 (=password) . This is handled by   < lMinLength 
   313 	        	okAction->setEnabled(false);	// 112 -> 1122 (=password) . This is handled by   < lMinLength 
   191 	        	okAction->setText("Ok");
   314 	        	okAction->setText("Ok");
   192     				return true;
   315     				return true;
   193 	        	}
   316 	        	}
   194 	    }
   317 	    }
   195 	    
   318 	    // after TARM validation.
   196 	    if (parameters.contains(KInvalidNewLockCode)) {
   319 	    if (parameters.contains(KInvalidNewLockCode)) {
   197 					qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode";
   320 					RDEBUG("KInvalidNewLockCode", 0);
   198 	        QString invalidText = parameters.value(KInvalidNewLockCode).toString();
   321 	        QString invalidText = parameters.value(KInvalidNewLockCode).toString();
   199 	        qDebug() << invalidText;
   322 	        qDebug() << invalidText;
   200 
   323 	        QString newTitleText = "Lock Code";	// TODO take from the original one
   201 	        title->setPlainText("Lock Code");	// TODO take from the original one
   324 
   202 	        QString invalidStr = invalidText.right(invalidText.length()-invalidText.indexOf('#')-1);
   325 	        QString invalidStr = invalidText.right(invalidText.length()-invalidText.indexOf('#')-1);
   203 	        int invalidNumber = invalidStr.toInt();
   326 	        int invalidNumber = invalidStr.toInt();
   204 	        qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode invalidNumber" << invalidNumber;
   327 	        RDEBUG("invalidNumber", invalidNumber);
   205 	        if(invalidNumber<0)
   328 	        if(invalidNumber<0)
   206 	        	{
   329 	        	{
   207 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode ???";
   330 	        	RDEBUG("invalidNumber<0", invalidNumber );
   208 	        	// nothing to do
   331 	        	// nothing to do
   209 	        	}
   332 	        	}
   210 /*
   333 				if(invalidNumber==EDeviceLockAutolockperiod)
   211 	        if(invalidNumber==EDeviceLockAutolockperiod)
   334 	        	{
   212 	        	{
   335 	        	RDEBUG("EDeviceLockAutolockperiod", invalidNumber );
   213 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockAutolockperiod";
   336 	        	newTitleText+="EDeviceLockAutolockperiod";
   214 	        	title->setPlainText("EDeviceLockAutolockperiod");
       
   215 	        	}
   337 	        	}
   216 	        if(invalidNumber==EDeviceLockMaxAutolockPeriod)
   338 	        if(invalidNumber==EDeviceLockMaxAutolockPeriod)
   217 	        	{
   339 	        	{
   218 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMaxAutolockPeriod";
   340 	        	RDEBUG("EDeviceLockAutolockperiod", invalidNumber );
   219 	        	title->setPlainText("EDeviceLockMaxAutolockPeriod");
   341 	        	newTitleText+="EDeviceLockMaxAutolockPeriod";
   220 	        	}
   342 	        	}
   221 	        if(invalidNumber==EDeviceLockMinlength)
   343 	        if(invalidNumber==EDeviceLockMinlength)
   222 	        	{
   344 	        	{
   223 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinlength";
   345 	        	RDEBUG("EDeviceLockMinlength", invalidNumber );
   224 	        	title->setPlainText("EDeviceLockMinlength");
   346 	        	newTitleText+="EDeviceLockMinlength";
   225 	        	}
   347 	        	}
   226 	        if(invalidNumber==EDeviceLockMaxlength)
   348 	        if(invalidNumber==EDeviceLockMaxlength)
   227 	        	{
   349 	        	{
   228 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMaxlength";
   350 	        	RDEBUG("EDeviceLockMaxlength", invalidNumber );
   229 	        	title->setPlainText("EDeviceLockMaxlength");
   351 	        	newTitleText+="EDeviceLockMaxlength";
   230 	        	}
   352 	        	}
   231 	        if(invalidNumber==EDeviceLockRequireUpperAndLower)
   353 	        if(invalidNumber==EDeviceLockRequireUpperAndLower)
   232 	        	{
   354 	        	{
   233 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockRequireUpperAndLower";
   355 	        	RDEBUG("EDeviceLockRequireUpperAndLower", invalidNumber );
   234 	        	title->setPlainText("EDeviceLockRequireUpperAndLower");
   356 	        	newTitleText+="EDeviceLockRequireUpperAndLower";
   235 	        	}
   357 	        	}
   236 	        if(invalidNumber==EDeviceLockRequireCharsAndNumbers)
   358 	        if(invalidNumber==EDeviceLockRequireCharsAndNumbers)
   237 	        	{
   359 	        	{
   238 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockRequireCharsAndNumbers";
   360 	        	RDEBUG("EDeviceLockMaxlength", invalidNumber );
   239 	        	title->setPlainText("EDeviceLockMaxlength");
   361 	        	newTitleText+="EDeviceLockMaxlength";
   240 	        	}
   362 	        	}
   241 	        if(invalidNumber==EDeviceLockAllowedMaxRepeatedChars)
   363 	        if(invalidNumber==EDeviceLockAllowedMaxRepeatedChars)
   242 	        	{
   364 	        	{
   243 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockAllowedMaxRepeatedChars";
   365 	        	RDEBUG("EDeviceLockAllowedMaxRepeatedChars", invalidNumber );
   244 	        	title->setPlainText("EDeviceLockAllowedMaxRepeatedChars");
   366 	        	newTitleText+="EDeviceLockAllowedMaxRepeatedChars";
   245 	        	}
   367 	        	}
   246 	        if(invalidNumber==EDeviceLockHistoryBuffer)
   368 	        if(invalidNumber==EDeviceLockHistoryBuffer)
   247 	        	{
   369 	        	{
   248 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockHistoryBuffer";
   370 	        	RDEBUG("EDeviceLockHistoryBuffer", invalidNumber );
   249 	        	title->setPlainText("EDeviceLockHistoryBuffer");
   371 	        	newTitleText+="EDeviceLockHistoryBuffer";
   250 	        	}
   372 	        	}
   251 	        if(invalidNumber==EDeviceLockPasscodeExpiration)
   373 	        if(invalidNumber==EDeviceLockPasscodeExpiration)
   252 	        	{
   374 	        	{
   253 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockPasscodeExpiration";
   375 	        	RDEBUG("EDeviceLockPasscodeExpiration", invalidNumber );
   254 	        	title->setPlainText("EDeviceLockPasscodeExpiration");
   376 	        	newTitleText+="EDeviceLockPasscodeExpiration";
   255 	        	}
   377 	        	}
   256 	        if(invalidNumber==EDeviceLockMinChangeTolerance)
   378 	        if(invalidNumber==EDeviceLockMinChangeTolerance)
   257 	        	{
   379 	        	{
   258 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinChangeTolerance";
   380 	        	RDEBUG("EDeviceLockMinChangeTolerance", invalidNumber );
   259 	        	title->setPlainText("EDeviceLockMinChangeTolerance");
   381 	        	newTitleText+="EDeviceLockMinChangeTolerance";
   260 	        	}
   382 	        	}
   261 	        if(invalidNumber==EDeviceLockMinChangeInterval)
   383 	        if(invalidNumber==EDeviceLockMinChangeInterval)
   262 	        	{
   384 	        	{
   263 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinChangeInterval";
   385 	        	RDEBUG("EDeviceLockMinChangeInterval", invalidNumber );
   264 	        	title->setPlainText("EDeviceLockMinChangeInterval");
   386 	        	newTitleText+="EDeviceLockMinChangeInterval";
   265 	        	}
   387 	        	}
   266 	        if(invalidNumber==EDeviceLockDisallowSpecificStrings)
   388 	        if(invalidNumber==EDeviceLockDisallowSpecificStrings)
   267 	        	{
   389 	        	{
   268 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockDisallowSpecificStrings";
   390 	        	RDEBUG("EDeviceLockDisallowSpecificStrings", invalidNumber );
   269 	        	title->setPlainText("EDeviceLockDisallowSpecificStrings");
   391 	        	newTitleText+="EDeviceLockDisallowSpecificStrings";
   270 	        	}
   392 	        	}
   271 	        if(invalidNumber==EDeviceLockAllowedMaxAtempts)
   393 	        if(invalidNumber==EDeviceLockAllowedMaxAtempts)
   272 	        	{
   394 	        	{
   273 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockAllowedMaxAtempts";
   395 	        	RDEBUG("EDeviceLockAllowedMaxAtempts", invalidNumber );
   274 	        	title->setPlainText("EDeviceLockAllowedMaxAtempts");
   396 	        	newTitleText+="EDeviceLockAllowedMaxAtempts";
   275 	        	}
   397 	        	}
   276 	        if(invalidNumber==EDeviceLockConsecutiveNumbers)
   398 	        if(invalidNumber==EDeviceLockConsecutiveNumbers)
   277 	        	{
   399 	        	{
   278 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockConsecutiveNumbers";
   400 	        	RDEBUG("EDeviceLockConsecutiveNumbers", invalidNumber );
   279 	        	title->setPlainText("EDeviceLockConsecutiveNumbers");
   401 	        	newTitleText+="EDeviceLockConsecutiveNumbers";
   280 	        	}
   402 	        	}
   281 	        if(invalidNumber==EDeviceLockMinSpecialCharacters)
   403 	        if(invalidNumber==EDeviceLockMinSpecialCharacters)
   282 	        	{
   404 	        	{
   283 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinSpecialCharacters";
   405 	        	RDEBUG("EDeviceLockMinSpecialCharacters", invalidNumber );
   284 	        	title->setPlainText("EDeviceLockMinSpecialCharacters");
   406 	        	newTitleText+="EDeviceLockMinSpecialCharacters";
   285 	        	}
   407 	        	}
   286 	        if(invalidNumber==EDeviceLockSingleCharRepeatNotAllowed)
   408 	        if(invalidNumber==EDeviceLockSingleCharRepeatNotAllowed)
   287 	        	{
   409 	        	{
   288 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockSingleCharRepeatNotAllowed";
   410 	        	RDEBUG("EDeviceLockSingleCharRepeatNotAllowed", invalidNumber );
   289 	        	title->setPlainText("EDeviceLockSingleCharRepeatNotAllowed");
   411 	        	newTitleText+="EDeviceLockSingleCharRepeatNotAllowed";
   290 	        	}
   412 	        	}
   291 	        if(invalidNumber==EDevicelockConsecutiveCharsNotAllowed)
   413 	        if(invalidNumber==EDevicelockConsecutiveCharsNotAllowed)
   292 	        	{
   414 	        	{
   293 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDevicelockConsecutiveCharsNotAllowed";
   415 	        	RDEBUG("EDevicelockConsecutiveCharsNotAllowed", invalidNumber );
   294 	        	title->setPlainText("EDevicelockConsecutiveCharsNotAllowed");
   416 	        	newTitleText+="EDevicelockConsecutiveCharsNotAllowed";
   295 	        	}
   417 	        	}
   296 	        if(invalidNumber>=EDevicelockTotalPolicies)
   418 	        if(invalidNumber>=EDevicelockTotalPolicies)
   297 	        	{
   419 	        	{
   298 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDevicelockTotalPolicies";
   420 	        	RDEBUG("EDevicelockTotalPolicies", invalidNumber );
   299 	        	title->setPlainText("EDevicelockTotalPolicies");
   421 	        	newTitleText+="EDevicelockTotalPolicies";
   300 	        	}
   422 	        	}
   301 	        	*/
   423 	        if( !titleWidget )
   302 	        // always keep OK valid.
   424 	        	{
       
   425 	        	RDEBUG("creating titleWidget", 0 );
       
   426 	        	titleWidget = new HbLabel("New lock code");	// it will be changed later
       
   427           	setHeadingWidget(titleWidget);
       
   428           	}
       
   429           RDEBUG("setPlainText", 0 );
       
   430 	        titleWidget->setPlainText(newTitleText);
       
   431 	        
       
   432 	        if(invalidNumber<0)	// everything is ok
       
   433 	        	{
       
   434 	        	okAction->setEnabled(true);	// this might fail in the scenario: check this : invalid -> valid. This allows verif ?
       
   435 	        	okAction->setText("Ok");
       
   436 	        	codeBottom->setEnabled(true);
       
   437 	        	}
       
   438 	        else
       
   439 	        	{
       
   440 	        	okAction->setEnabled(false);
       
   441 	        	codeBottom->setEnabled(false);
       
   442 	        	codeBottom->setText("");
       
   443 	        	okAction->setText("Ok");
       
   444 	        	}
       
   445 	        // need to return because all objects are already created
   303    				return true;
   446    				return true;
   304 	    }
   447 	    }
   305 	
   448 	
   306     // Content
   449     // Content
   307     SecUiNotificationContentWidget *content = new SecUiNotificationContentWidget();
   450     SecUiNotificationContentWidget *content = new SecUiNotificationContentWidget();
   309     setContentWidget(content);
   452     setContentWidget(content);
   310 
   453 
   311 		queryType = content->queryType;
   454 		queryType = content->queryType;
   312 		queryDual = content->queryDual;
   455 		queryDual = content->queryDual;
   313 		isEmergency = content->isEmergency;
   456 		isEmergency = content->isEmergency;
       
   457     codeTop=NULL;
   314 		codeTop = content->codeTop;
   458 		codeTop = content->codeTop;
       
   459     checkBox = content->checkbox;
       
   460     listWidget = content->listWidget;
   315 		codeBottom = content->codeBottom;
   461 		codeBottom = content->codeBottom;
   316 		lMinLength = content->lMinLength;
   462 		lMinLength = content->lMinLength;
   317 		lMaxLength = content->lMaxLength;
   463 		lMaxLength = content->lMaxLength;
   318 		lEmergencySupported = content->lEmergencySupported;
   464 		lEmergencySupported = content->lEmergencySupported;
   319 
   465 
   321     connect(content, SIGNAL(codeBottomChanged(const QString &)), this, SLOT(handleCodeBottomChanged(const QString &)));
   467     connect(content, SIGNAL(codeBottomChanged(const QString &)), this, SLOT(handleCodeBottomChanged(const QString &)));
   322     connect(content, SIGNAL(codeTopContentChanged()), this, SLOT(handleCodeTopContentChanged()));
   468     connect(content, SIGNAL(codeTopContentChanged()), this, SLOT(handleCodeTopContentChanged()));
   323     connect(content, SIGNAL(but1Changed()), this, SLOT(handlebut1Changed()));
   469     connect(content, SIGNAL(but1Changed()), this, SLOT(handlebut1Changed()));
   324     connect(content, SIGNAL(but2Changed()), this, SLOT(handlebut2Changed()));
   470     connect(content, SIGNAL(but2Changed()), this, SLOT(handlebut2Changed()));
   325     connect(content, SIGNAL(but3Changed()), this, SLOT(handlebut3Changed()));
   471     connect(content, SIGNAL(but3Changed()), this, SLOT(handlebut3Changed()));
   326 		qDebug() << "SecUiNotificationDialog::queryType=";
   472 		RDEBUG("queryType", queryType);
   327 		qDebug() << queryType;
       
   328     // Buttons
   473     // Buttons
   329     if( (queryType & ESecUiTypeMaskLock))
   474     if( (queryType & ESecUiTypeMaskLock))
   330     	{
   475     	{
   331     	// no need to create OK or Cancel
   476     	// no need to create OK or Cancel
   332     	return true;
   477     	return true;
   333     	}
   478     	}
   334 
   479 
   335     okAction = new HbAction(tr("Ok"));
   480     okAction = new HbAction(tr("Ok"));
       
   481     RDEBUG("created HbAction okAction", 1);
   336     okAction->setEnabled(false);	// initially the OK is disabled because codeTop is empty
   482     okAction->setEnabled(false);	// initially the OK is disabled because codeTop is empty
       
   483     if((queryType & ESecUiBasicTypeMask) ==ESecUiBasicTypeCheck) {
       
   484         okAction->setEnabled(true);
       
   485         setHeadingWidget(0); // had to remove this no multiline
       
   486     }
       
   487     else if ((queryType & ESecUiBasicTypeMask) ==ESecUiBasicTypeCheckMulti){
       
   488         okAction->setEnabled(true);
       
   489     }
       
   490 
   337     // setAction(okAction, QDialogButtonBox::AcceptRole);	// it's supposed to use this, when deprecated
   491     // setAction(okAction, QDialogButtonBox::AcceptRole);	// it's supposed to use this, when deprecated
   338     setPrimaryAction(okAction);
   492     // setPrimaryAction(okAction);
       
   493     addAction(okAction);
       
   494     disconnect(okAction, SIGNAL(triggered()), this, SLOT(close()));	// the close will be done in handleAccepted
   339     connect(okAction, SIGNAL(triggered()), this, SLOT(handleAccepted()));
   495     connect(okAction, SIGNAL(triggered()), this, SLOT(handleAccepted()));
   340     
   496     
   341     cancelAction = new HbAction(tr("Cancel"));    // qtTrId("txt_common_button_cancel")
   497     cancelAction = new HbAction(tr("Cancel"));    // qtTrId("txt_common_button_cancel")
       
   498     addAction(cancelAction);
       
   499     disconnect(cancelAction, SIGNAL(triggered()), this, SLOT(close()));	// the close will be done in handleCancelled
   342     connect(cancelAction, SIGNAL(triggered()), this, SLOT(handleCancelled()));
   500     connect(cancelAction, SIGNAL(triggered()), this, SLOT(handleCancelled()));
   343     // setAction(cancelAction, QDialogButtonBox::RejectRole);		// it's supposed to use this, when deprecated
   501     // setAction(cancelAction, QDialogButtonBox::RejectRole);		// it's supposed to use this, when deprecated
   344     setSecondaryAction(cancelAction);
   502     // setSecondaryAction(cancelAction);
   345 
   503 
   346 		qDebug() << "SecUiNotificationDialog check Cancel";
   504 		// this should had been set by Autolock, but just to be sure
       
   505     TInt ret = RProperty::Define(KPSUidSecurityUIs, KSecurityUIsDismissDialog,
       
   506             RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass),
       
   507             TSecurityPolicy(TSecurityPolicy::EAlwaysPass));
       
   508     RDEBUG("defined KSecurityUIsDismissDialog", ret);
       
   509     TInt aDismissDialog = -1;
       
   510     ret = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsDismissDialog, aDismissDialog );
       
   511     RDEBUG("ret", ret);
       
   512     RDEBUG("aDismissDialog", aDismissDialog);
       
   513     if(aDismissDialog==ESecurityUIsDismissDialogOn || aDismissDialog==ESecurityUIsDismissDialogProcessing)
       
   514     	{
       
   515     	RDebug::Printf( "potential error: %s %s (%u) aDismissDialog=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aDismissDialog );
       
   516     	}
       
   517 	
       
   518 		RDEBUG("check cancel", 0);
   347     if ((queryType & ESecUiCancelSupported)==ESecUiCancelSupported)
   519     if ((queryType & ESecUiCancelSupported)==ESecUiCancelSupported)
   348     	{
   520     	{
   349     		// nothing to do. Cancel is enabled by default
   521     		// nothing to do. Cancel is enabled by default
   350     	}
   522     	}
   351   	else
   523   	else
   352   		{
   524   		{
   353 				qDebug() << "disable Cancel";
   525 				RDEBUG("disable Cancel", 1);
   354   			cancelAction->setEnabled(false);
   526   			cancelAction->setEnabled(false);
       
   527   			cancelAction->setText("");
       
   528   			cancelAction->setVisible(false);
   355   		}
   529   		}
   356     
   530     
   357     return true;
   531     return true;
   358 }
   532 }
   359 
   533 
   361 // SecUiNotificationDialog::sendResult()
   535 // SecUiNotificationDialog::sendResult()
   362 // ----------------------------------------------------------------------------
   536 // ----------------------------------------------------------------------------
   363 //
   537 //
   364 void SecUiNotificationDialog::sendResult(int accepted)
   538 void SecUiNotificationDialog::sendResult(int accepted)
   365 {
   539 {
   366 		qDebug() << "SecUiNotificationDialog::sendResult 1.2";
   540 		RDEBUG("0", 0);
       
   541 		RDEBUG("mMyId", mMyId);
   367     QVariant acceptedValue(accepted);
   542     QVariant acceptedValue(accepted);
   368 		qDebug() << "SecUiNotificationDialog::sendResult 2";
   543 		RDEBUG("0", 0);
   369     mResultMap.insert(KResultAccepted, acceptedValue);
   544     mResultMap.insert(KResultAccepted, acceptedValue);
   370 		qDebug() << "SecUiNotificationDialog::sendResult 3";
   545 		RDEBUG("0", 0);
   371 		qDebug() << mResultMap;
   546 		qDebug() << mResultMap;
   372     emit deviceDialogData(mResultMap);
   547 		RDEBUG("queryType", queryType);
   373 		qDebug() << "SecUiNotificationDialog::sendResult end";
   548 		if(!(queryType & ESecUiTypeMaskLock))
       
   549 			{	// the lock-icon should not reply
       
   550 			RDEBUG("emit deviceDialogData", 0);
       
   551     	emit deviceDialogData(mResultMap);
       
   552     	}
       
   553 		RDEBUG("1", 1);
   374 }
   554 }
   375 
   555 
   376 // ----------------------------------------------------------------------------
   556 // ----------------------------------------------------------------------------
   377 // SecUiNotificationDialog::handleAccepted()
   557 // SecUiNotificationDialog::handleAccepted()
   378 // ----------------------------------------------------------------------------
   558 // ----------------------------------------------------------------------------
   379 //
   559 //
   380 void SecUiNotificationDialog::handleAccepted()
   560 void SecUiNotificationDialog::handleAccepted()
   381 {
   561 {
   382 		qDebug() << "SecUiNotificationDialog::handleAccepted";
   562 		RDEBUG("0", 0);
   383 		// okAction
   563 		// okAction
   384 		QString codeTopText;
   564 		RDEBUG("mMyId", mMyId);
       
   565 		QString codeTopText="";
   385 
   566 
   386 		if( (queryType & ESecUiTypeMaskLock))
   567 		if( (queryType & ESecUiTypeMaskLock))
   387     	{
   568     	{
   388     	codeTopText = "Unlock-Request";
   569     	codeTopText = "Unlock-Request";
   389     	}
   570     	}
       
   571     else if( (queryType & ESecUiBasicTypeMask)==ESecUiBasicTypeCheck)
       
   572     	{
       
   573         codeTopText=(checkBox->isChecked() ?  "1":"0");
       
   574         mResultMap.insert(KCodeTopIndex,  codeTopText);
       
   575     	}
       
   576     else if( (queryType & ESecUiBasicTypeMask)==ESecUiBasicTypeCheckMulti)
       
   577     	{
       
   578         QItemSelectionModel *selectionModel = listWidget->selectionModel();
       
   579         QModelIndexList selectedItems = selectionModel->selectedIndexes();
       
   580         QModelIndex index;
       
   581         codeTopText="";
       
   582          foreach(index, selectedItems) { 
       
   583 		 		 codeTopText+=QString::number(index.row());
       
   584                 //could also use  if(index.row()!=selectedItems.count()-1) codeTopText+= "|";
       
   585                 codeTopText+= "|";
       
   586                 }
       
   587          mResultMap.insert(KCodeTopIndex,  codeTopText);
       
   588     	}
   390     else
   589     else
   391     	{
   590         codeTopText = codeTop->text();
   392     	codeTopText = codeTop->text();
   591     // no need to check last time for codeBottom
   393     	}
       
   394     // TODO check last time for codeBottom
       
   395    	qDebug() << "codeTopText=" << codeTopText;
   592    	qDebug() << "codeTopText=" << codeTopText;
   396     sendResult(KErrNone);
   593     sendResult(KErrNone);
       
   594     RDEBUG("calling close()", 0);
       
   595     close();	// this is needed because Cancel doesn't automatically closes the dialog
       
   596 		RDEBUG("emitting deviceDialogClosed", 0);
       
   597 		emit deviceDialogClosed();
   397 }
   598 }
   398 
   599 
   399 // ----------------------------------------------------------------------------
   600 // ----------------------------------------------------------------------------
   400 // SecUiNotificationDialog::handleCancelled()
   601 // SecUiNotificationDialog::handleCancelled()
   401 // ----------------------------------------------------------------------------
   602 // ----------------------------------------------------------------------------
   402 //
   603 //
   403 void SecUiNotificationDialog::handleCancelled()
   604 void SecUiNotificationDialog::handleCancelled()
   404 {
   605 {
   405 		qDebug() << "SecUiNotificationDialog::handleCancelled";
   606 		RDEBUG("0", 0);
       
   607 		RDEBUG("mMyId", mMyId);
   406     sendResult(KErrCancel);
   608     sendResult(KErrCancel);
       
   609 		RDEBUG("callingclose()", 0);
       
   610     close();	// this is needed because Cancel doesn't automatically closes the dialog
       
   611 		RDEBUG("emitting deviceDialogClosed", 0);
       
   612 		emit deviceDialogClosed();
   407 }
   613 }
   408 
   614 
   409 // ----------------------------------------------------------------------------
   615 // ----------------------------------------------------------------------------
   410 // SecUiNotificationDialog::handleMemorySelectionChanged()
   616 // SecUiNotificationDialog::handleMemorySelectionChanged()
   411 // ----------------------------------------------------------------------------
   617 // ----------------------------------------------------------------------------
   412 //
   618 //
   413 void SecUiNotificationDialog::handleMemorySelectionChanged(const QString &text)
   619 void SecUiNotificationDialog::handleMemorySelectionChanged(const QString &text)
   414     {
   620     {
   415     	qDebug() << "SecUiNotificationDialog::handleMemorySelectionChanged";
   621 		RDEBUG("0", 0);
   416     	qDebug() << text;
   622 		RDEBUG("mMyId", mMyId);
       
   623     qDebug() << text;
   417     QVariant memorySelection(text);
   624     QVariant memorySelection(text);
   418     mResultMap.insert(KSelectedMemoryIndex, memorySelection);
   625     mResultMap.insert(KSelectedMemoryIndex, memorySelection);
   419     //TODO: do we need emit here, or would it be better to send all data at the end?
       
   420     //emit deviceDialogData(mResultMap);
       
   421     }
   626     }
   422 
   627 
   423 void SecUiNotificationDialog::handleCodeTopContentChanged()
   628 void SecUiNotificationDialog::handleCodeTopContentChanged()
   424     {
   629     {
   425     	qDebug() << "SecUiNotificationDialog::handleCodeTopContentChanged";
   630 		RDEBUG("0", 0);
       
   631 		RDEBUG("mMyId", mMyId);
   426     	qDebug() << codeTop->text();
   632     	qDebug() << codeTop->text();
   427     	handleCodeTopChanged(codeTop->text());
   633     	handleCodeTopChanged(codeTop->text());
   428     }
   634     }
   429 
   635 
   430 // ----------------------------------------------------------------------------
   636 // ----------------------------------------------------------------------------
   431 // SecUiNotificationDialog::handleCodeTopChanged()
   637 // SecUiNotificationDialog::handleCodeTopChanged()
   432 // ----------------------------------------------------------------------------
   638 // ----------------------------------------------------------------------------
   433 //
   639 //
   434 void SecUiNotificationDialog::handleCodeTopChanged(const QString &text)
   640 void SecUiNotificationDialog::handleCodeTopChanged(const QString &text)
   435     {
   641     {
   436     	qDebug() << "SecUiNotificationDialog::handleCodeTopChanged";
   642 		RDEBUG("0", 0);
   437     	qDebug() << "SecUiNotificationDialog::handleCodeTopChanged=" << text ;
   643     	qDebug() << "SecUiNotificationDialog::handleCodeTopChanged=" << text ;
   438     	if(queryDual)
   644     	if(queryDual)
   439     		{
   645     		{
   440     		codeBottom->setText("");	// any change resets the verification.
   646     		codeBottom->setText("");	// any change resets the verification.
   441     		}
   647     		}
   442     	if( queryType == 0x1000004 )
   648     	if( queryType == 0x1000004 )	// new codeLock
   443     		{	// ChangeSecCodeParamsL change RMobilePhone::ESecurityCodePhonePassword
   649     		{	// ChangeSecCodeParamsL change RMobilePhone::ESecurityCodePhonePassword
   444 			    QVariant codeTop(text);
   650 			    QVariant codeTopVar(text);
   445 			    mResultMap.insert(KCodeTopIndex, codeTop);
   651 			    mResultMap.insert(KCodeTopIndex, codeTopVar);
   446 					sendResult(KErrCompletion);	// send the current password back to the client for further TARM validation
   652 					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
   447     		}
   653     		}
   448     	if(text.length() < lMinLength )
   654     	if(text.length() < lMinLength )
   449     		{
   655     		{
   450     		qDebug() << "SecUiNotificationDialog::handleCodeTopChanged too short:" << text ;
   656     		qDebug() << "SecUiNotificationDialog::handleCodeTopChanged too short:" << text ;
   451     		okAction->setEnabled(false);
   657     		okAction->setEnabled(false);
   452 
   658 				RDEBUG("lEmergencySupported", lEmergencySupported);
   453 				if( lEmergencySupported && text.length() > 2 )	// emergency numbers need at least 3 digits
   659 				if( lEmergencySupported && text.length() > 2 )	// emergency numbers need at least 3 digits
   454 					{	// check whether it's a emergency number
   660 					{	// check whether it's a emergency number
   455 					QVariant codeTop(text);
   661 					QVariant codeTopVar(text);
   456   				mResultMap.insert(KCodeTopIndex, codeTop);
   662   				mResultMap.insert(KCodeTopIndex, codeTopVar);
   457 					sendResult(KErrAbort);	// send the current password back to the client. Perhaps it's an emergency number and decides to Ok->Call
   663 					sendResult(KErrAbort);	// send the current password back to the client. Perhaps it's an emergency number and decides to Ok->Call
   458 					}
   664 					}
   459     		}
   665     		}
   460     	else if (text.length() >= lMinLength)
   666     	else if (text.length() >= lMinLength)
   461     		{
   667     		{
   462     		// TODO might use a flag to avoid re-setting
   668     		// might use a flag to avoid re-setting. But this complicates things if there's another initial verification
   463     		qDebug() << "SecUiNotificationDialog::handleCodeTopChanged long enough:" << text ;
   669     		qDebug() << "SecUiNotificationDialog::handleCodeTopChanged long enough:" << text ;
   464     		okAction->setText("Ok");
   670     		okAction->setText("Ok");
   465     		if(queryDual==0)	// only if Bottom is not used
   671     		if(queryDual==0)	// only if Bottom is not used
   466     			okAction->setEnabled(true);
   672     			okAction->setEnabled(true);
   467     		}
   673     		}
   468     QVariant codeTop(text);
   674     QVariant codeTopVar(text);
   469     mResultMap.insert(KCodeTopIndex, codeTop);
   675     mResultMap.insert(KCodeTopIndex, codeTopVar);
   470     }
   676     }
   471 // ----------------------------------------------------------------------------
   677 // ----------------------------------------------------------------------------
   472 // SecUiNotificationDialog::handleCodeBottomChanged()
   678 // SecUiNotificationDialog::handleCodeBottomChanged()
   473 // ----------------------------------------------------------------------------
   679 // ----------------------------------------------------------------------------
   474 //
   680 //
   475 void SecUiNotificationDialog::handleCodeBottomChanged(const QString &text)
   681 void SecUiNotificationDialog::handleCodeBottomChanged(const QString &text)
   476     {
   682     {
   477     	qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged";
   683 		RDEBUG("0", 0);
   478     	qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged" << text ;
   684     	qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged" << text ;
   479     	qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged. codeTop=" << codeTop->text() ;
   685     	qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged. codeTop=" << codeTop->text() ;
   480     	// TODO compare 
       
   481     	if(text.length() < lMinLength )
   686     	if(text.length() < lMinLength )
   482     		{
   687     		{
   483     		qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged too short:" << text ;
   688     		qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged too short:" << text ;
   484     		okAction->setEnabled(false);
   689     		okAction->setEnabled(false);
   485     		}
   690     		}
   486     	else
   691     	else
   487     		{
   692     		{
   488     		// TODO might use a flag to avoid re-setting
   693     		// might use a flag to avoid re-setting. But it just complicates things.
   489     		qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged long enough:" << text ;
   694     		qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged long enough:" << text ;
   490     		if(codeTop->text()==text)
   695     		if(codeTop->text()==text)
   491     			{
   696     			{
       
   697     			// unless both codes match, don't allow OK. Note that the first field doesn't allow exit until the validations (i.e. NewLockCode) as succesfull
   492     			qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged codes match:" << text ;
   698     			qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged codes match:" << text ;
   493 	    		okAction->setEnabled(true);
   699 	    		okAction->setEnabled(true);
   494 	    		}
   700 	    		}
   495 	    	else
   701 	    	else
   496 	    		{
   702 	    		{
   504 // SecUiNotificationDialog::handlebut1Changed()
   710 // SecUiNotificationDialog::handlebut1Changed()
   505 // ----------------------------------------------------------------------------
   711 // ----------------------------------------------------------------------------
   506 //
   712 //
   507 void SecUiNotificationDialog::handlebut1Changed()
   713 void SecUiNotificationDialog::handlebut1Changed()
   508     {
   714     {
   509     	qDebug() << "SecUiNotificationDialog::handlebut1Changed";
   715 		RDEBUG("0", 0);
   510     	codeTop->setText("1234");
   716     codeTop->setText("1234");
   511     }
   717     }
   512 // ----------------------------------------------------------------------------
   718 // ----------------------------------------------------------------------------
   513 // SecUiNotificationDialog::handlebut2Changed()
   719 // SecUiNotificationDialog::handlebut2Changed()
   514 // ----------------------------------------------------------------------------
   720 // ----------------------------------------------------------------------------
   515 //
   721 //
   516 void SecUiNotificationDialog::handlebut2Changed()
   722 void SecUiNotificationDialog::handlebut2Changed()
   517     {
   723     {
   518     	qDebug() << "SecUiNotificationDialog::handlebut2Changed";
   724 		RDEBUG("0", 0);
   519     	QString codeTopText = codeTop->text();
   725     	QString codeTopText = codeTop->text();
   520     	qDebug() << "codeTopText";
   726     	qDebug() << "codeTopText";
   521     	qDebug() << codeTopText;
   727     	qDebug() << codeTopText;
   522     	codeTopText = codeTopText + "1" ;
   728     	codeTopText = codeTopText + "1" ;
   523     	qDebug() << "codeTopText+1";
   729     	qDebug() << "codeTopText+1";
   524     	qDebug() << codeTopText;
   730     	qDebug() << codeTopText;
   525     	codeTop->setText(codeTopText);
   731     	codeTop->setText(codeTopText);
       
   732     	
       
   733     	      RDEBUG("editorInterface", 0);
       
   734       			HbEditorInterface editorInterface(codeTop);
       
   735       			RDEBUG("actions", 0);
       
   736       			QList<HbAction *> vkbList = editorInterface.actions();
       
   737       			RDEBUG("count", 0);
       
   738       			int count = vkbList.count();
       
   739       			RDEBUG("got count", count);
       
   740 		        for (int i = 0; i < count; i++)
       
   741 		        		{
       
   742 		        		RDEBUG("i", i);
       
   743 		            HbAction *action = static_cast<HbAction *>(vkbList[i]);
       
   744 		            RDEBUG("action", 0);
       
   745 		          	}
       
   746 		          	
       
   747 		        RDEBUG("okVKBAction", 0);
       
   748 		        okVKBAction = new HbAction(tr("Ok"));
       
   749 		        RDEBUG("addAction", 0);
       
   750 		        editorInterface.addAction(okVKBAction);
       
   751 		        RDEBUG("addAction", 1);
       
   752 		        connect(okVKBAction, SIGNAL(triggered()), this, SLOT(handleAccepted()));
       
   753 		        RDEBUG("connect", 1);
       
   754 
       
   755       			QList<HbAction *> vkbList2 = editorInterface.actions();
       
   756       			RDEBUG("count", 0);
       
   757       			int count2 = vkbList2.count();
       
   758       			RDEBUG("got count2", count2);
       
   759 		        for (int i = 0; i < count2; i++)
       
   760 		        		{
       
   761 		        		RDEBUG("i", i);
       
   762 		            HbAction *action2 = static_cast<HbAction *>(vkbList2[i]);
       
   763 		            RDEBUG("action2", 0);
       
   764 		          	}
       
   765     
   526     }
   766     }
   527 // ----------------------------------------------------------------------------
   767 // ----------------------------------------------------------------------------
   528 // SecUiNotificationDialog::handlebut3Changed()
   768 // SecUiNotificationDialog::handlebut3Changed()
   529 // ----------------------------------------------------------------------------
   769 // ----------------------------------------------------------------------------
   530 //
   770 //
   545 // SecUiNotificationDialog::saveFocusWidget(QWidget*,QWidget*)
   785 // SecUiNotificationDialog::saveFocusWidget(QWidget*,QWidget*)
   546 // ----------------------------------------------------------------------------
   786 // ----------------------------------------------------------------------------
   547 //
   787 //
   548 void SecUiNotificationDialog::saveFocusWidget(QWidget*,QWidget*)
   788 void SecUiNotificationDialog::saveFocusWidget(QWidget*,QWidget*)
   549 {
   789 {
   550 		qDebug() << "SecUiNotificationDialog::saveFocusWidget";
   790 		RDEBUG("0", 0);
   551 }
   791 }
       
   792 
       
   793 // ----------------------------------------------------------------------------
       
   794 // SecUiNotificationDialog::subscriberKSecurityUIsDismissDialogChanged()
       
   795 // A way for Autolock to dismiss any possible PIN dialog
       
   796 // This doesn't dismiss the lockIcon because P&S is not connected
       
   797 // Note: if this changes itself, then it becomes recursive
       
   798 // ----------------------------------------------------------------------------
       
   799 //
       
   800 void SecUiNotificationDialog::subscriberKSecurityUIsDismissDialogChanged()
       
   801     {
       
   802 
       
   803     RDEBUG("0", 0);
       
   804 		RDEBUG("mMyId", mMyId);
       
   805     TInt aDismissDialog = ESecurityUIsDismissDialogUninitialized;
       
   806     TInt err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsDismissDialog, aDismissDialog );
       
   807     RDEBUG("err", err);
       
   808 		RDEBUG("aDismissDialog", aDismissDialog);
       
   809     if( aDismissDialog == ESecurityUIsDismissDialogOn )
       
   810     	{
       
   811     	if(subscriberKSecurityUIsDismissDialog)
       
   812     		{
       
   813     		RDEBUG("subscriberKSecurityUIsDismissDialog", 1);
       
   814     		}
       
   815     	else
       
   816     		{
       
   817     		RDEBUG("! subscriberKSecurityUIsDismissDialog", 0);
       
   818     		}
       
   819 
       
   820     	if(this)
       
   821     		{
       
   822     		RDEBUG("this", 1);
       
   823     		}
       
   824     	else
       
   825     		{
       
   826     		RDEBUG("! this", 0);
       
   827     		}
       
   828 
       
   829 
       
   830 			RDEBUG("disconnect subscriberKSecurityUIsDismissDialog", 0);
       
   831 			disconnect(subscriberKSecurityUIsDismissDialog, SIGNAL(contentsChanged()), this, SLOT(subscriberKSecurityUIsDismissDialogChanged()));
       
   832 			// this doesn't really disconnect, because somehow the events are still queued. This is a QtMobility error
       
   833 			RDEBUG("disconnected subscriberKSecurityUIsDismissDialog", 1);
       
   834 			
       
   835 			RDEBUG("not set KSecurityUIsDismissDialog", ESecurityUIsDismissDialogProcessing);
       
   836 			// can't set it because it does recursion
       
   837 			// err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogProcessing );
       
   838 			RDEBUG("err", err);
       
   839 			// only if Cancel is allowed
       
   840 			if ((queryType & ESecUiCancelSupported)==ESecUiCancelSupported)
       
   841 				{
       
   842 				RDEBUG("sendResult(KErrCancel)", KErrCancel);	// another option is KErrDied
       
   843 				sendResult(KErrCancel);	// similar to     emit handleCancelled();
       
   844 				RDEBUG("calling close()", 0);
       
   845 				err = close();
       
   846 				RDEBUG("err", err);
       
   847 				RDEBUG("emitting deviceDialogClosed", 0);
       
   848 				emit deviceDialogClosed();
       
   849 				// RDEBUG("emit closeDeviceDialog", 0);
       
   850 				// this is old method    emit closeDeviceDialog(false);	// false means "not by client", although it's not really used
       
   851 				RDEBUG("all emited", 0);
       
   852 				}
       
   853 			RDEBUG("not set KSecurityUIsDismissDialog", ESecurityUIsDismissDialogDone);
       
   854 			// can't set it because it does recursion
       
   855 			// err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogDone );	// clear after using it
       
   856 			RDEBUG("err", err);
       
   857 
       
   858 			RDEBUG("reconnect subscriberKSecurityUIsDismissDialog", 0);
       
   859 			connect(subscriberKSecurityUIsDismissDialog, SIGNAL(contentsChanged()), this, SLOT(subscriberKSecurityUIsDismissDialogChanged()));
       
   860 			RDEBUG("reconnected subscriberKSecurityUIsDismissDialog", 1);
       
   861     	}
       
   862     RDEBUG("1", 1);
       
   863 	}