securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationdialog.cpp
changeset 30 cc1cea6aabaf
parent 26 aad866c37519
child 35 f1030a78d563
equal deleted inserted replaced
26:aad866c37519 30:cc1cea6aabaf
    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>
    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>
    30 #include <e32property.h>
    32 #include <e32property.h>
    31 
    33 
    32 QTM_USE_NAMESPACE
    34 QTM_USE_NAMESPACE
    33 
    35 
    34 #include <qvaluespacesubscriber.h>
    36 #include <qvaluespacesubscriber.h>
    35 #include <qvaluespacepublisher.h>
    37 #include <qvaluespacepublisher.h>
       
    38 #define ESecUiBasicTypeText    0x0000000
       
    39 #define ESecUiBasicTypeCheck   0x0010000
       
    40 #define ESecUiBasicTypeCheckMulti   0x0020000
       
    41 #define ESecUiBasicTypeMask    0x00F0000
    36 
    42 
    37 #define ESecUiCancelSupported  0x1000000
    43 #define ESecUiCancelSupported  0x1000000
    38 #define ESecUiCancelNotSupported  0x0000000
    44 #define ESecUiCancelNotSupported  0x0000000
    39 
    45 
    40 #define ESecUiEmergencySupported  0x2000000
    46 #define ESecUiEmergencySupported  0x2000000
    57 #define ESecUiTypeMaskLock			0x00F00000
    63 #define ESecUiTypeMaskLock			0x00F00000
    58 
    64 
    59 const TUid KPSUidSecurityUIs = { 0x100059b5 };
    65 const TUid KPSUidSecurityUIs = { 0x100059b5 };
    60 const TUint32 KSecurityUIsDismissDialog  = 0x00000309;
    66 const TUint32 KSecurityUIsDismissDialog  = 0x00000309;
    61 
    67 
       
    68 enum TSecurityUIsDismissDialogValues
       
    69     {
       
    70     ESecurityUIsDismissDialogUninitialized = 0,
       
    71     ESecurityUIsDismissDialogOn,
       
    72     ESecurityUIsDismissDialogProcessing,
       
    73     ESecurityUIsDismissDialogDone,
       
    74     ESecurityUIsDismissDialogLastValue
       
    75     };
       
    76 
    62 // ----------------------------------------------------------------------------
    77 // ----------------------------------------------------------------------------
    63 // SecUiNotificationDialog::SecUiNotificationDialog()
    78 // SecUiNotificationDialog::SecUiNotificationDialog()
    64 // ----------------------------------------------------------------------------
    79 // ----------------------------------------------------------------------------
    65 //
    80 //
    66 SecUiNotificationDialog::SecUiNotificationDialog(
    81 SecUiNotificationDialog::SecUiNotificationDialog(
    67         const QVariantMap &parameters) : HbDialog(), mLastError(KNoError)
    82         const QVariantMap &parameters) : HbDialog(), mLastError(KNoError)
    68 {
    83 {
    69 		qDebug() << "SecUiNotificationDialog::SecUiNotificationDialog";
    84 		RDEBUG("0", 0);
       
    85 		TTime myTime;
       
    86     myTime.HomeTime();
       
    87 		mMyId = I64LOW( myTime.Int64() );
    70     constructDialog(parameters);
    88     constructDialog(parameters);
    71 }
    89 }
    72 
    90 
    73 // ----------------------------------------------------------------------------
    91 // ----------------------------------------------------------------------------
    74 // SecUiNotificationDialog::~SecUiNotificationDialog()
    92 // SecUiNotificationDialog::~SecUiNotificationDialog()
    75 // ----------------------------------------------------------------------------
    93 // ----------------------------------------------------------------------------
    76 //
    94 //
    77 SecUiNotificationDialog::~SecUiNotificationDialog()
    95 SecUiNotificationDialog::~SecUiNotificationDialog()
    78 {
    96 {
       
    97 	RDEBUG("0", 0);
    79 }
    98 }
    80 
    99 
    81 // ----------------------------------------------------------------------------
   100 // ----------------------------------------------------------------------------
    82 // SecUiNotificationDialog::setDeviceDialogParameters()
   101 // SecUiNotificationDialog::setDeviceDialogParameters()
    83 // ----------------------------------------------------------------------------
   102 // ----------------------------------------------------------------------------
    84 //
   103 //
    85 bool SecUiNotificationDialog::setDeviceDialogParameters(const QVariantMap &parameters)
   104 bool SecUiNotificationDialog::setDeviceDialogParameters(const QVariantMap &parameters)
    86 {
   105 {
    87 		qDebug() << "SecUiNotificationDialog::setDeviceDialogParameters";
   106 	 RDEBUG("0", 0);
    88    return constructDialog(parameters);
   107    return constructDialog(parameters);
    89 }
   108 }
    90 
   109 
    91 // ----------------------------------------------------------------------------
   110 // ----------------------------------------------------------------------------
    92 // SecUiNotificationDialog::deviceDialogError()
   111 // SecUiNotificationDialog::deviceDialogError()
    93 // ----------------------------------------------------------------------------
   112 // ----------------------------------------------------------------------------
    94 //
   113 //
    95 int SecUiNotificationDialog::deviceDialogError() const
   114 int SecUiNotificationDialog::deviceDialogError() const
    96 {
   115 {
    97 		qDebug() << "SecUiNotificationDialog::deviceDialogError";
   116 		RDEBUG("mLastError", mLastError);
    98 		qDebug() << mLastError;
   117 		RDEBUG("mMyId", mMyId);
    99     return mLastError;
   118     return mLastError;
   100 }
   119 }
   101 
   120 
   102 // ----------------------------------------------------------------------------
   121 // ----------------------------------------------------------------------------
   103 // SecUiNotificationDialog::closeDeviceDialog
   122 // SecUiNotificationDialog::closeDeviceDialog
   104 // ----------------------------------------------------------------------------
   123 // ----------------------------------------------------------------------------
   105 //
   124 //
   106 void SecUiNotificationDialog::closeDeviceDialog(bool byClient)
   125 void SecUiNotificationDialog::closeDeviceDialog(bool byClient)
   107 {
   126 {
   108     Q_UNUSED(byClient);
   127     Q_UNUSED(byClient);
   109 		qDebug() << "SecUiNotificationDialog::closeDeviceDialog 0";
   128 		RDEBUG("mMyId", mMyId);
       
   129 		RDEBUG("calling close()", 0);
   110     close();
   130     close();
   111 		qDebug() << "SecUiNotificationDialog::closeDeviceDialog 1";
   131 		RDEBUG("mShowEventReceived", mShowEventReceived);
   112 
   132 
   113     // 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.
   114     // 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.
   115     if (!mShowEventReceived) {
   135     if (!mShowEventReceived) {
       
   136     		RDEBUG("emitting deviceDialogClosed", 0);
   116         emit deviceDialogClosed();
   137         emit deviceDialogClosed();
   117     }
   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);
   118 }
   153 }
   119 
   154 
   120 // ----------------------------------------------------------------------------
   155 // ----------------------------------------------------------------------------
   121 // SecUiNotificationDialog::deviceDialogWidget
   156 // SecUiNotificationDialog::deviceDialogWidget
   122 // ----------------------------------------------------------------------------
   157 // ----------------------------------------------------------------------------
   130 // SecUiNotificationDialog::hideEvent
   165 // SecUiNotificationDialog::hideEvent
   131 // ----------------------------------------------------------------------------
   166 // ----------------------------------------------------------------------------
   132 //
   167 //
   133 void SecUiNotificationDialog::hideEvent(QHideEvent *event)
   168 void SecUiNotificationDialog::hideEvent(QHideEvent *event)
   134 {
   169 {
   135 		qDebug() << "SecUiNotificationDialog::hideEvent";
   170 		RDEBUG("0", 0);
   136     HbDialog::hideEvent(event);
   171     HbDialog::hideEvent(event);
   137     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);
   138 }
   193 }
   139 
   194 
   140 // ----------------------------------------------------------------------------
   195 // ----------------------------------------------------------------------------
   141 // SecUiNotificationDialog::showEvent
   196 // SecUiNotificationDialog::showEvent
   142 // ----------------------------------------------------------------------------
   197 // ----------------------------------------------------------------------------
   143 //
   198 //
   144 void SecUiNotificationDialog::showEvent(QShowEvent *event)
   199 void SecUiNotificationDialog::showEvent(QShowEvent *event)
   145 {
   200 {
   146 		qDebug() << "SecUiNotificationDialog::showEvent";
   201 		RDEBUG("0", 0);
       
   202 		RDEBUG("mMyId", mMyId);
   147     HbDialog::showEvent(event);
   203     HbDialog::showEvent(event);
   148 
   204 
   149 		if(!(queryType & ESecUiTypeMaskLock))
   205 		if(!(queryType & ESecUiTypeMaskLock))
   150 			{	// not for the "lock icon"
   206 			{	// not for the "lock icon"
   151 			qDebug() << "SecUiNotificationDialog::showEvent check default";
   207 			RDEBUG("check default.1", 0);
   152 			if(codeTop->text().length()>0)	// there's a default value. Verify it and (might) enable OK
   208 			if(codeTop!=NULL)
   153 				{
   209             {
   154 				qDebug() << "SecUiNotificationDialog::showEvent checked default";
   210             RDEBUG("check default.2", 0);
   155 				handleCodeTopChanged(codeTop->text());
   211             if(codeTop->text().length()>0)	// there's a default value. Verify it and (might) enable OK
   156 				}
   212                 {
   157 			// for automated testing, read a P&S and use this value as if the user typed it
   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             
   158 			const TUint32 KSecurityUIsTestCode  = 0x00000307;
   221 			const TUint32 KSecurityUIsTestCode  = 0x00000307;
   159 			TInt value = 0;
   222 			TInt value = 0;
   160 			TInt err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsTestCode, value );
   223 			TInt err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsTestCode, value );
   161 			qDebug() << "SecUiNotificationDialog::faking KSecurityUIsTestCode err=" << err;
   224 			RDEBUG("KSecurityUIsTestCode err", err);
   162 			qDebug() << "SecUiNotificationDialog::faking value=" << value;
   225 			RDEBUG("faking value", value);
       
   226 			RDEBUG("mShowEventReceived", mShowEventReceived);
   163 			if(value>0 && mShowEventReceived==true)	// show happens 2 times. Dialog can be closed only the second.
   227 			if(value>0 && mShowEventReceived==true)	// show happens 2 times. Dialog can be closed only the second.
   164 				{
   228 				{
   165 				QString myString = "";
   229 				QString myString = "";
   166 				myString += QString("%1").arg(value);
   230 				myString += QString("%1").arg(value);
   167 				qDebug() << "SecUiNotificationDialog::faking myString=" << myString;
   231 				qDebug() << "SecUiNotificationDialog::faking myString=" << myString;
   168 		    codeTop->setText( myString );
   232 		    codeTop->setText( myString );
   169 		    TInt err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsTestCode, 0 );	// clear after using it
   233 		    TInt err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsTestCode, 0 );	// clear after using it
   170 				qDebug() << "SecUiNotificationDialog::calling handleAccepted=" << myString;
   234 				qDebug() << "SecUiNotificationDialog::calling handleAccepted=" << myString;
   171 		    emit handleAccepted();
   235 		    emit handleAccepted();
   172 				emit closeDeviceDialog(false);	// false means "not by client", although it's not really used
   236 				// handleAccepted already   emit closeDeviceDialog(false);	// false means "not by client", although it's not really used
   173 				}
   237 				}
   174 			}
   238 			}
   175     mShowEventReceived = true;
   239     mShowEventReceived = true;
       
   240     RDEBUG("1", 1);
   176 }
   241 }
   177 
   242 
   178 // ----------------------------------------------------------------------------
   243 // ----------------------------------------------------------------------------
   179 // SecUiNotificationDialog::constructDialog()
   244 // SecUiNotificationDialog::constructDialog()
   180 // ----------------------------------------------------------------------------
   245 // ----------------------------------------------------------------------------
   181 //
   246 //
   182 bool SecUiNotificationDialog::constructDialog(const QVariantMap &parameters)
   247 bool SecUiNotificationDialog::constructDialog(const QVariantMap &parameters)
   183     {
   248     {
   184 		qDebug() << "SecUiNotificationDialog::constructDialog";
   249 		RDEBUG("0", 0);
       
   250 		RDEBUG("mMyId", mMyId);
   185     setTimeout(HbPopup::NoTimeout);
   251     setTimeout(HbPopup::NoTimeout);
   186     setDismissPolicy(HbPopup::NoDismiss);
   252     setDismissPolicy(HbPopup::NoDismiss);
   187     setModal(true);
   253     setModal(true);
   188     mShowEventReceived = false;
   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);
   189 
   270 
   190     // Title
   271     // Title
       
   272     // this is also done later in the widget
       
   273     // For now, it only says "Security"
   191     if (parameters.contains(KDialogTitle)) {
   274     if (parameters.contains(KDialogTitle)) {
   192         QString titleText = parameters.value(KDialogTitle).toString();
   275         QString titleText = parameters.value(KDialogTitle).toString();
   193         QString titleAttempts = "";
   276         QString titleAttempts = "";
   194    			if(titleText.indexOf('|')>0)
   277    			if(titleText.indexOf('|')>0)
   195     				{	// if separator, take only first part
   278     				{	// if separator, take only first part
   198    			if(titleText.indexOf('#')>0)
   281    			if(titleText.indexOf('#')>0)
   199     				{	// if separator, take only first part
   282     				{	// if separator, take only first part
   200     				titleAttempts = titleText.right(titleText.length()-titleText.indexOf('#')-1);
   283     				titleAttempts = titleText.right(titleText.length()-titleText.indexOf('#')-1);
   201     				qDebug() << "SecUiNotificationDialog::titleAttempts=" << titleAttempts;
   284     				qDebug() << "SecUiNotificationDialog::titleAttempts=" << titleAttempts;
   202     				int nAttempts = titleAttempts.toInt();
   285     				int nAttempts = titleAttempts.toInt();
   203     				qDebug() << "SecUiNotificationDialog::nAttempts=" << nAttempts;
   286     				RDEBUG("nAttempts", nAttempts);
   204     				titleText = titleText.left(titleText.indexOf('#'));
   287     				titleText = titleText.left(titleText.indexOf('#'));
   205     				if(nAttempts>0)
   288     				if(nAttempts>0)
   206     					titleText = titleText + " attempts=" + QString::number(nAttempts);
   289     					titleText = titleText + " attempts=" + QString::number(nAttempts);
   207     				}
   290     				}
   208         title = new HbLabel(titleText);
   291     		titleText = "Security Query";	// this is the header, for any potential later error which needs to be displayed
   209         setHeadingWidget(title);
   292         // This is created only if needed (i.e. errors for NewLockCode)
       
   293         // titleWidget = new HbLabel(titleText);
       
   294         // setHeadingWidget(titleWidget);
   210     }
   295     }
   211 
   296 
   212 	    if (parameters.contains(KEmergency)) {
   297 	    if (parameters.contains(KEmergency)) {
   213 					qDebug() << "SecUiNotificationDialog::KEmergency";
   298 					RDEBUG("KEmergency", 1);
   214 	        QString emergencyText = parameters.value(KEmergency).toString();
   299 	        QString emergencyText = parameters.value(KEmergency).toString();
   215 	        qDebug() << emergencyText;
   300 	        qDebug() << emergencyText;
   216 	        if(!emergencyText.compare("emergencyYes"))
   301 	        if(!emergencyText.compare("emergencyYes"))
   217 	        	{
   302 	        	{
   218 	        	qDebug() << "SecUiNotificationDialog::KEmergency emergencyYes";
   303 	        	RDEBUG("emergencyYes", 1);
   219 	        	isEmergency = 1;
   304 	        	isEmergency = 1;
   220 	        	okAction->setEnabled(true);
   305 	        	okAction->setEnabled(true);
   221 	        	okAction->setText("Call");
   306 	        	okAction->setText("Call");
   222     				return true;
   307     				return true;
   223 	        	}
   308 	        	}
   224 	        if(!emergencyText.compare("emergencyNo"))
   309 	        if(!emergencyText.compare("emergencyNo"))
   225 	        	{
   310 	        	{
   226 	        	qDebug() << "SecUiNotificationDialog::KEmergency emergencyNo";
   311 	        	RDEBUG("emergencyNo", 1);
   227 	        	isEmergency = 0;
   312 	        	isEmergency = 0;
   228 	        	okAction->setEnabled(false);	// 112 -> 1122 (=password) . This is handled by   < lMinLength 
   313 	        	okAction->setEnabled(false);	// 112 -> 1122 (=password) . This is handled by   < lMinLength 
   229 	        	okAction->setText("Ok");
   314 	        	okAction->setText("Ok");
   230     				return true;
   315     				return true;
   231 	        	}
   316 	        	}
   232 	    }
   317 	    }
   233 	    // after TARM validation.
   318 	    // after TARM validation.
   234 	    if (parameters.contains(KInvalidNewLockCode)) {
   319 	    if (parameters.contains(KInvalidNewLockCode)) {
   235 					qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode";
   320 					RDEBUG("KInvalidNewLockCode", 0);
   236 	        QString invalidText = parameters.value(KInvalidNewLockCode).toString();
   321 	        QString invalidText = parameters.value(KInvalidNewLockCode).toString();
   237 	        qDebug() << invalidText;
   322 	        qDebug() << invalidText;
   238 
   323 	        QString newTitleText = "Lock Code";	// TODO take from the original one
   239 	        title->setPlainText("Lock Code");	// TODO take from the original one
   324 
   240 	        QString invalidStr = invalidText.right(invalidText.length()-invalidText.indexOf('#')-1);
   325 	        QString invalidStr = invalidText.right(invalidText.length()-invalidText.indexOf('#')-1);
   241 	        int invalidNumber = invalidStr.toInt();
   326 	        int invalidNumber = invalidStr.toInt();
   242 	        qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode invalidNumber" << invalidNumber;
   327 	        RDEBUG("invalidNumber", invalidNumber);
   243 	        if(invalidNumber<0)
   328 	        if(invalidNumber<0)
   244 	        	{
   329 	        	{
   245 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode ???";
   330 	        	RDEBUG("invalidNumber<0", invalidNumber );
   246 	        	// nothing to do
   331 	        	// nothing to do
   247 	        	}
   332 	        	}
   248 			if(invalidNumber==EDeviceLockAutolockperiod)
   333 				if(invalidNumber==EDeviceLockAutolockperiod)
   249 	        	{
   334 	        	{
   250 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockAutolockperiod";
   335 	        	RDEBUG("EDeviceLockAutolockperiod", invalidNumber );
   251 	        	title->setPlainText("EDeviceLockAutolockperiod");
   336 	        	newTitleText+="EDeviceLockAutolockperiod";
   252 	        	}
   337 	        	}
   253 	        if(invalidNumber==EDeviceLockMaxAutolockPeriod)
   338 	        if(invalidNumber==EDeviceLockMaxAutolockPeriod)
   254 	        	{
   339 	        	{
   255 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMaxAutolockPeriod";
   340 	        	RDEBUG("EDeviceLockAutolockperiod", invalidNumber );
   256 	        	title->setPlainText("EDeviceLockMaxAutolockPeriod");
   341 	        	newTitleText+="EDeviceLockMaxAutolockPeriod";
   257 	        	}
   342 	        	}
   258 	        if(invalidNumber==EDeviceLockMinlength)
   343 	        if(invalidNumber==EDeviceLockMinlength)
   259 	        	{
   344 	        	{
   260 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinlength";
   345 	        	RDEBUG("EDeviceLockMinlength", invalidNumber );
   261 	        	title->setPlainText("EDeviceLockMinlength");
   346 	        	newTitleText+="EDeviceLockMinlength";
   262 	        	}
   347 	        	}
   263 	        if(invalidNumber==EDeviceLockMaxlength)
   348 	        if(invalidNumber==EDeviceLockMaxlength)
   264 	        	{
   349 	        	{
   265 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMaxlength";
   350 	        	RDEBUG("EDeviceLockMaxlength", invalidNumber );
   266 	        	title->setPlainText("EDeviceLockMaxlength");
   351 	        	newTitleText+="EDeviceLockMaxlength";
   267 	        	}
   352 	        	}
   268 	        if(invalidNumber==EDeviceLockRequireUpperAndLower)
   353 	        if(invalidNumber==EDeviceLockRequireUpperAndLower)
   269 	        	{
   354 	        	{
   270 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockRequireUpperAndLower";
   355 	        	RDEBUG("EDeviceLockRequireUpperAndLower", invalidNumber );
   271 	        	title->setPlainText("EDeviceLockRequireUpperAndLower");
   356 	        	newTitleText+="EDeviceLockRequireUpperAndLower";
   272 	        	}
   357 	        	}
   273 	        if(invalidNumber==EDeviceLockRequireCharsAndNumbers)
   358 	        if(invalidNumber==EDeviceLockRequireCharsAndNumbers)
   274 	        	{
   359 	        	{
   275 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockRequireCharsAndNumbers";
   360 	        	RDEBUG("EDeviceLockMaxlength", invalidNumber );
   276 	        	title->setPlainText("EDeviceLockMaxlength");
   361 	        	newTitleText+="EDeviceLockMaxlength";
   277 	        	}
   362 	        	}
   278 	        if(invalidNumber==EDeviceLockAllowedMaxRepeatedChars)
   363 	        if(invalidNumber==EDeviceLockAllowedMaxRepeatedChars)
   279 	        	{
   364 	        	{
   280 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockAllowedMaxRepeatedChars";
   365 	        	RDEBUG("EDeviceLockAllowedMaxRepeatedChars", invalidNumber );
   281 	        	title->setPlainText("EDeviceLockAllowedMaxRepeatedChars");
   366 	        	newTitleText+="EDeviceLockAllowedMaxRepeatedChars";
   282 	        	}
   367 	        	}
   283 	        if(invalidNumber==EDeviceLockHistoryBuffer)
   368 	        if(invalidNumber==EDeviceLockHistoryBuffer)
   284 	        	{
   369 	        	{
   285 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockHistoryBuffer";
   370 	        	RDEBUG("EDeviceLockHistoryBuffer", invalidNumber );
   286 	        	title->setPlainText("EDeviceLockHistoryBuffer");
   371 	        	newTitleText+="EDeviceLockHistoryBuffer";
   287 	        	}
   372 	        	}
   288 	        if(invalidNumber==EDeviceLockPasscodeExpiration)
   373 	        if(invalidNumber==EDeviceLockPasscodeExpiration)
   289 	        	{
   374 	        	{
   290 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockPasscodeExpiration";
   375 	        	RDEBUG("EDeviceLockPasscodeExpiration", invalidNumber );
   291 	        	title->setPlainText("EDeviceLockPasscodeExpiration");
   376 	        	newTitleText+="EDeviceLockPasscodeExpiration";
   292 	        	}
   377 	        	}
   293 	        if(invalidNumber==EDeviceLockMinChangeTolerance)
   378 	        if(invalidNumber==EDeviceLockMinChangeTolerance)
   294 	        	{
   379 	        	{
   295 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinChangeTolerance";
   380 	        	RDEBUG("EDeviceLockMinChangeTolerance", invalidNumber );
   296 	        	title->setPlainText("EDeviceLockMinChangeTolerance");
   381 	        	newTitleText+="EDeviceLockMinChangeTolerance";
   297 	        	}
   382 	        	}
   298 	        if(invalidNumber==EDeviceLockMinChangeInterval)
   383 	        if(invalidNumber==EDeviceLockMinChangeInterval)
   299 	        	{
   384 	        	{
   300 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinChangeInterval";
   385 	        	RDEBUG("EDeviceLockMinChangeInterval", invalidNumber );
   301 	        	title->setPlainText("EDeviceLockMinChangeInterval");
   386 	        	newTitleText+="EDeviceLockMinChangeInterval";
   302 	        	}
   387 	        	}
   303 	        if(invalidNumber==EDeviceLockDisallowSpecificStrings)
   388 	        if(invalidNumber==EDeviceLockDisallowSpecificStrings)
   304 	        	{
   389 	        	{
   305 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockDisallowSpecificStrings";
   390 	        	RDEBUG("EDeviceLockDisallowSpecificStrings", invalidNumber );
   306 	        	title->setPlainText("EDeviceLockDisallowSpecificStrings");
   391 	        	newTitleText+="EDeviceLockDisallowSpecificStrings";
   307 	        	}
   392 	        	}
   308 	        if(invalidNumber==EDeviceLockAllowedMaxAtempts)
   393 	        if(invalidNumber==EDeviceLockAllowedMaxAtempts)
   309 	        	{
   394 	        	{
   310 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockAllowedMaxAtempts";
   395 	        	RDEBUG("EDeviceLockAllowedMaxAtempts", invalidNumber );
   311 	        	title->setPlainText("EDeviceLockAllowedMaxAtempts");
   396 	        	newTitleText+="EDeviceLockAllowedMaxAtempts";
   312 	        	}
   397 	        	}
   313 	        if(invalidNumber==EDeviceLockConsecutiveNumbers)
   398 	        if(invalidNumber==EDeviceLockConsecutiveNumbers)
   314 	        	{
   399 	        	{
   315 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockConsecutiveNumbers";
   400 	        	RDEBUG("EDeviceLockConsecutiveNumbers", invalidNumber );
   316 	        	title->setPlainText("EDeviceLockConsecutiveNumbers");
   401 	        	newTitleText+="EDeviceLockConsecutiveNumbers";
   317 	        	}
   402 	        	}
   318 	        if(invalidNumber==EDeviceLockMinSpecialCharacters)
   403 	        if(invalidNumber==EDeviceLockMinSpecialCharacters)
   319 	        	{
   404 	        	{
   320 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinSpecialCharacters";
   405 	        	RDEBUG("EDeviceLockMinSpecialCharacters", invalidNumber );
   321 	        	title->setPlainText("EDeviceLockMinSpecialCharacters");
   406 	        	newTitleText+="EDeviceLockMinSpecialCharacters";
   322 	        	}
   407 	        	}
   323 	        if(invalidNumber==EDeviceLockSingleCharRepeatNotAllowed)
   408 	        if(invalidNumber==EDeviceLockSingleCharRepeatNotAllowed)
   324 	        	{
   409 	        	{
   325 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockSingleCharRepeatNotAllowed";
   410 	        	RDEBUG("EDeviceLockSingleCharRepeatNotAllowed", invalidNumber );
   326 	        	title->setPlainText("EDeviceLockSingleCharRepeatNotAllowed");
   411 	        	newTitleText+="EDeviceLockSingleCharRepeatNotAllowed";
   327 	        	}
   412 	        	}
   328 	        if(invalidNumber==EDevicelockConsecutiveCharsNotAllowed)
   413 	        if(invalidNumber==EDevicelockConsecutiveCharsNotAllowed)
   329 	        	{
   414 	        	{
   330 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDevicelockConsecutiveCharsNotAllowed";
   415 	        	RDEBUG("EDevicelockConsecutiveCharsNotAllowed", invalidNumber );
   331 	        	title->setPlainText("EDevicelockConsecutiveCharsNotAllowed");
   416 	        	newTitleText+="EDevicelockConsecutiveCharsNotAllowed";
   332 	        	}
   417 	        	}
   333 	        if(invalidNumber>=EDevicelockTotalPolicies)
   418 	        if(invalidNumber>=EDevicelockTotalPolicies)
   334 	        	{
   419 	        	{
   335 	        	qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDevicelockTotalPolicies";
   420 	        	RDEBUG("EDevicelockTotalPolicies", invalidNumber );
   336 	        	title->setPlainText("EDevicelockTotalPolicies");
   421 	        	newTitleText+="EDevicelockTotalPolicies";
   337 	        	}
   422 	        	}
       
   423 	        if( !titleWidget )
       
   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 	        
   338 	        if(invalidNumber<0)	// everything is ok
   432 	        if(invalidNumber<0)	// everything is ok
   339 	        	{
   433 	        	{
   340 	        	okAction->setEnabled(true);	// TODO check this : invalid -> valid. This allows verif ?
   434 	        	okAction->setEnabled(true);	// this might fail in the scenario: check this : invalid -> valid. This allows verif ?
   341 	        	okAction->setText("Ok");
   435 	        	okAction->setText("Ok");
   342 	        	codeBottom->setEnabled(true);
   436 	        	codeBottom->setEnabled(true);
   343 	        	}
   437 	        	}
   344 	        else
   438 	        else
   345 	        	{
   439 	        	{
   358     setContentWidget(content);
   452     setContentWidget(content);
   359 
   453 
   360 		queryType = content->queryType;
   454 		queryType = content->queryType;
   361 		queryDual = content->queryDual;
   455 		queryDual = content->queryDual;
   362 		isEmergency = content->isEmergency;
   456 		isEmergency = content->isEmergency;
       
   457     codeTop=NULL;
   363 		codeTop = content->codeTop;
   458 		codeTop = content->codeTop;
       
   459     checkBox = content->checkbox;
       
   460     listWidget = content->listWidget;
   364 		codeBottom = content->codeBottom;
   461 		codeBottom = content->codeBottom;
   365 		lMinLength = content->lMinLength;
   462 		lMinLength = content->lMinLength;
   366 		lMaxLength = content->lMaxLength;
   463 		lMaxLength = content->lMaxLength;
   367 		lEmergencySupported = content->lEmergencySupported;
   464 		lEmergencySupported = content->lEmergencySupported;
   368 
   465 
   370     connect(content, SIGNAL(codeBottomChanged(const QString &)), this, SLOT(handleCodeBottomChanged(const QString &)));
   467     connect(content, SIGNAL(codeBottomChanged(const QString &)), this, SLOT(handleCodeBottomChanged(const QString &)));
   371     connect(content, SIGNAL(codeTopContentChanged()), this, SLOT(handleCodeTopContentChanged()));
   468     connect(content, SIGNAL(codeTopContentChanged()), this, SLOT(handleCodeTopContentChanged()));
   372     connect(content, SIGNAL(but1Changed()), this, SLOT(handlebut1Changed()));
   469     connect(content, SIGNAL(but1Changed()), this, SLOT(handlebut1Changed()));
   373     connect(content, SIGNAL(but2Changed()), this, SLOT(handlebut2Changed()));
   470     connect(content, SIGNAL(but2Changed()), this, SLOT(handlebut2Changed()));
   374     connect(content, SIGNAL(but3Changed()), this, SLOT(handlebut3Changed()));
   471     connect(content, SIGNAL(but3Changed()), this, SLOT(handlebut3Changed()));
   375 		qDebug() << "SecUiNotificationDialog::queryType=";
   472 		RDEBUG("queryType", queryType);
   376 		qDebug() << queryType;
       
   377     // Buttons
   473     // Buttons
   378     if( (queryType & ESecUiTypeMaskLock))
   474     if( (queryType & ESecUiTypeMaskLock))
   379     	{
   475     	{
   380     	// no need to create OK or Cancel
   476     	// no need to create OK or Cancel
   381     	return true;
   477     	return true;
   382     	}
   478     	}
   383 
   479 
   384     okAction = new HbAction(tr("Ok"));
   480     okAction = new HbAction(tr("Ok"));
       
   481     RDEBUG("created HbAction okAction", 1);
   385     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 
   386     // 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
   387     setPrimaryAction(okAction);
   492     // setPrimaryAction(okAction);
       
   493     addAction(okAction);
       
   494     disconnect(okAction, SIGNAL(triggered()), this, SLOT(close()));	// the close will be done in handleAccepted
   388     connect(okAction, SIGNAL(triggered()), this, SLOT(handleAccepted()));
   495     connect(okAction, SIGNAL(triggered()), this, SLOT(handleAccepted()));
   389     
   496     
   390     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
   391     connect(cancelAction, SIGNAL(triggered()), this, SLOT(handleCancelled()));
   500     connect(cancelAction, SIGNAL(triggered()), this, SLOT(handleCancelled()));
   392     // 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
   393     setSecondaryAction(cancelAction);
   502     // setSecondaryAction(cancelAction);
   394 
   503 
   395 		// this should had been set by Autolock, but just to be sure
   504 		// this should had been set by Autolock, but just to be sure
   396     TInt ret = RProperty::Define(KPSUidSecurityUIs, KSecurityUIsDismissDialog,
   505     TInt ret = RProperty::Define(KPSUidSecurityUIs, KSecurityUIsDismissDialog,
   397             RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass),
   506             RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass),
   398             TSecurityPolicy(TSecurityPolicy::EAlwaysPass));
   507             TSecurityPolicy(TSecurityPolicy::EAlwaysPass));
   399     RDEBUG("defined KSecurityUIsDismissDialog", ret);
   508     RDEBUG("defined KSecurityUIsDismissDialog", ret);
   400     subscriberKSecurityUIsDismissDialog = new QValueSpaceSubscriber(
   509     TInt aDismissDialog = -1;
   401             "/KPSUidSecurityUIs/KSecurityUIsDismissDialog", this);
   510     ret = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsDismissDialog, aDismissDialog );
   402     connect(subscriberKSecurityUIsDismissDialog, SIGNAL(contentsChanged()), this,
   511     RDEBUG("ret", ret);
   403             SLOT(subscriberKSecurityUIsDismissDialogChanged()));
   512     RDEBUG("aDismissDialog", aDismissDialog);
   404 	qDebug() << "subscribed to KSecurityUIsDismissDialog";
   513     if(aDismissDialog==ESecurityUIsDismissDialogOn || aDismissDialog==ESecurityUIsDismissDialogProcessing)
       
   514     	{
       
   515     	RDebug::Printf( "potential error: %s %s (%u) aDismissDialog=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aDismissDialog );
       
   516     	}
   405 	
   517 	
   406 		qDebug() << "SecUiNotificationDialog check Cancel";
   518 		RDEBUG("check cancel", 0);
   407     if ((queryType & ESecUiCancelSupported)==ESecUiCancelSupported)
   519     if ((queryType & ESecUiCancelSupported)==ESecUiCancelSupported)
   408     	{
   520     	{
   409     		// nothing to do. Cancel is enabled by default
   521     		// nothing to do. Cancel is enabled by default
   410     	}
   522     	}
   411   	else
   523   	else
   412   		{
   524   		{
   413 				qDebug() << "disable Cancel";
   525 				RDEBUG("disable Cancel", 1);
   414   			cancelAction->setEnabled(false);
   526   			cancelAction->setEnabled(false);
       
   527   			cancelAction->setText("");
       
   528   			cancelAction->setVisible(false);
   415   		}
   529   		}
   416     
   530     
   417     return true;
   531     return true;
   418 }
   532 }
   419 
   533 
   421 // SecUiNotificationDialog::sendResult()
   535 // SecUiNotificationDialog::sendResult()
   422 // ----------------------------------------------------------------------------
   536 // ----------------------------------------------------------------------------
   423 //
   537 //
   424 void SecUiNotificationDialog::sendResult(int accepted)
   538 void SecUiNotificationDialog::sendResult(int accepted)
   425 {
   539 {
   426 		qDebug() << "SecUiNotificationDialog::sendResult 1.2";
   540 		RDEBUG("0", 0);
       
   541 		RDEBUG("mMyId", mMyId);
   427     QVariant acceptedValue(accepted);
   542     QVariant acceptedValue(accepted);
   428 		qDebug() << "SecUiNotificationDialog::sendResult 2";
   543 		RDEBUG("0", 0);
   429     mResultMap.insert(KResultAccepted, acceptedValue);
   544     mResultMap.insert(KResultAccepted, acceptedValue);
   430 		qDebug() << "SecUiNotificationDialog::sendResult 3";
   545 		RDEBUG("0", 0);
   431 		qDebug() << mResultMap;
   546 		qDebug() << mResultMap;
   432     emit deviceDialogData(mResultMap);
   547 		RDEBUG("queryType", queryType);
   433 		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);
   434 }
   554 }
   435 
   555 
   436 // ----------------------------------------------------------------------------
   556 // ----------------------------------------------------------------------------
   437 // SecUiNotificationDialog::handleAccepted()
   557 // SecUiNotificationDialog::handleAccepted()
   438 // ----------------------------------------------------------------------------
   558 // ----------------------------------------------------------------------------
   439 //
   559 //
   440 void SecUiNotificationDialog::handleAccepted()
   560 void SecUiNotificationDialog::handleAccepted()
   441 {
   561 {
   442 		qDebug() << "SecUiNotificationDialog::handleAccepted";
   562 		RDEBUG("0", 0);
   443 		// okAction
   563 		// okAction
   444 		QString codeTopText;
   564 		RDEBUG("mMyId", mMyId);
       
   565 		QString codeTopText="";
   445 
   566 
   446 		if( (queryType & ESecUiTypeMaskLock))
   567 		if( (queryType & ESecUiTypeMaskLock))
   447     	{
   568     	{
   448     	codeTopText = "Unlock-Request";
   569     	codeTopText = "Unlock-Request";
   449     	}
   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     	}
   450     else
   589     else
   451     	{
   590         codeTopText = codeTop->text();
   452     	codeTopText = codeTop->text();
   591     // no need to check last time for codeBottom
   453     	}
       
   454     // TODO check last time for codeBottom
       
   455    	qDebug() << "codeTopText=" << codeTopText;
   592    	qDebug() << "codeTopText=" << codeTopText;
   456     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();
   457 }
   598 }
   458 
   599 
   459 // ----------------------------------------------------------------------------
   600 // ----------------------------------------------------------------------------
   460 // SecUiNotificationDialog::handleCancelled()
   601 // SecUiNotificationDialog::handleCancelled()
   461 // ----------------------------------------------------------------------------
   602 // ----------------------------------------------------------------------------
   462 //
   603 //
   463 void SecUiNotificationDialog::handleCancelled()
   604 void SecUiNotificationDialog::handleCancelled()
   464 {
   605 {
   465 		qDebug() << "SecUiNotificationDialog::handleCancelled";
   606 		RDEBUG("0", 0);
       
   607 		RDEBUG("mMyId", mMyId);
   466     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();
   467 }
   613 }
   468 
   614 
   469 // ----------------------------------------------------------------------------
   615 // ----------------------------------------------------------------------------
   470 // SecUiNotificationDialog::handleMemorySelectionChanged()
   616 // SecUiNotificationDialog::handleMemorySelectionChanged()
   471 // ----------------------------------------------------------------------------
   617 // ----------------------------------------------------------------------------
   472 //
   618 //
   473 void SecUiNotificationDialog::handleMemorySelectionChanged(const QString &text)
   619 void SecUiNotificationDialog::handleMemorySelectionChanged(const QString &text)
   474     {
   620     {
   475     	qDebug() << "SecUiNotificationDialog::handleMemorySelectionChanged";
   621 		RDEBUG("0", 0);
   476     	qDebug() << text;
   622 		RDEBUG("mMyId", mMyId);
       
   623     qDebug() << text;
   477     QVariant memorySelection(text);
   624     QVariant memorySelection(text);
   478     mResultMap.insert(KSelectedMemoryIndex, memorySelection);
   625     mResultMap.insert(KSelectedMemoryIndex, memorySelection);
   479     //TODO: do we need emit here, or would it be better to send all data at the end?
       
   480     //emit deviceDialogData(mResultMap);
       
   481     }
   626     }
   482 
   627 
   483 void SecUiNotificationDialog::handleCodeTopContentChanged()
   628 void SecUiNotificationDialog::handleCodeTopContentChanged()
   484     {
   629     {
   485     	qDebug() << "SecUiNotificationDialog::handleCodeTopContentChanged";
   630 		RDEBUG("0", 0);
       
   631 		RDEBUG("mMyId", mMyId);
   486     	qDebug() << codeTop->text();
   632     	qDebug() << codeTop->text();
   487     	handleCodeTopChanged(codeTop->text());
   633     	handleCodeTopChanged(codeTop->text());
   488     }
   634     }
   489 
   635 
   490 // ----------------------------------------------------------------------------
   636 // ----------------------------------------------------------------------------
   491 // SecUiNotificationDialog::handleCodeTopChanged()
   637 // SecUiNotificationDialog::handleCodeTopChanged()
   492 // ----------------------------------------------------------------------------
   638 // ----------------------------------------------------------------------------
   493 //
   639 //
   494 void SecUiNotificationDialog::handleCodeTopChanged(const QString &text)
   640 void SecUiNotificationDialog::handleCodeTopChanged(const QString &text)
   495     {
   641     {
   496     	qDebug() << "SecUiNotificationDialog::handleCodeTopChanged";
   642 		RDEBUG("0", 0);
   497     	qDebug() << "SecUiNotificationDialog::handleCodeTopChanged=" << text ;
   643     	qDebug() << "SecUiNotificationDialog::handleCodeTopChanged=" << text ;
   498     	if(queryDual)
   644     	if(queryDual)
   499     		{
   645     		{
   500     		codeBottom->setText("");	// any change resets the verification.
   646     		codeBottom->setText("");	// any change resets the verification.
   501     		}
   647     		}
   502     	if( queryType == 0x1000004 )	// new codeLock
   648     	if( queryType == 0x1000004 )	// new codeLock
   503     		{	// ChangeSecCodeParamsL change RMobilePhone::ESecurityCodePhonePassword
   649     		{	// ChangeSecCodeParamsL change RMobilePhone::ESecurityCodePhonePassword
   504 			    QVariant codeTop(text);
   650 			    QVariant codeTopVar(text);
   505 			    mResultMap.insert(KCodeTopIndex, codeTop);
   651 			    mResultMap.insert(KCodeTopIndex, codeTopVar);
   506 					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
   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
   507     		}
   653     		}
   508     	if(text.length() < lMinLength )
   654     	if(text.length() < lMinLength )
   509     		{
   655     		{
   510     		qDebug() << "SecUiNotificationDialog::handleCodeTopChanged too short:" << text ;
   656     		qDebug() << "SecUiNotificationDialog::handleCodeTopChanged too short:" << text ;
   511     		okAction->setEnabled(false);
   657     		okAction->setEnabled(false);
   512 
   658 				RDEBUG("lEmergencySupported", lEmergencySupported);
   513 				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
   514 					{	// check whether it's a emergency number
   660 					{	// check whether it's a emergency number
   515 					QVariant codeTop(text);
   661 					QVariant codeTopVar(text);
   516   				mResultMap.insert(KCodeTopIndex, codeTop);
   662   				mResultMap.insert(KCodeTopIndex, codeTopVar);
   517 					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
   518 					}
   664 					}
   519     		}
   665     		}
   520     	else if (text.length() >= lMinLength)
   666     	else if (text.length() >= lMinLength)
   521     		{
   667     		{
   522     		// 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
   523     		qDebug() << "SecUiNotificationDialog::handleCodeTopChanged long enough:" << text ;
   669     		qDebug() << "SecUiNotificationDialog::handleCodeTopChanged long enough:" << text ;
   524     		okAction->setText("Ok");
   670     		okAction->setText("Ok");
   525     		if(queryDual==0)	// only if Bottom is not used
   671     		if(queryDual==0)	// only if Bottom is not used
   526     			okAction->setEnabled(true);
   672     			okAction->setEnabled(true);
   527     		}
   673     		}
   528     QVariant codeTop(text);
   674     QVariant codeTopVar(text);
   529     mResultMap.insert(KCodeTopIndex, codeTop);
   675     mResultMap.insert(KCodeTopIndex, codeTopVar);
   530     }
   676     }
   531 // ----------------------------------------------------------------------------
   677 // ----------------------------------------------------------------------------
   532 // SecUiNotificationDialog::handleCodeBottomChanged()
   678 // SecUiNotificationDialog::handleCodeBottomChanged()
   533 // ----------------------------------------------------------------------------
   679 // ----------------------------------------------------------------------------
   534 //
   680 //
   535 void SecUiNotificationDialog::handleCodeBottomChanged(const QString &text)
   681 void SecUiNotificationDialog::handleCodeBottomChanged(const QString &text)
   536     {
   682     {
   537     	qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged";
   683 		RDEBUG("0", 0);
   538     	qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged" << text ;
   684     	qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged" << text ;
   539     	qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged. codeTop=" << codeTop->text() ;
   685     	qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged. codeTop=" << codeTop->text() ;
   540     	// TODO compare 
       
   541     	if(text.length() < lMinLength )
   686     	if(text.length() < lMinLength )
   542     		{
   687     		{
   543     		qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged too short:" << text ;
   688     		qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged too short:" << text ;
   544     		okAction->setEnabled(false);
   689     		okAction->setEnabled(false);
   545     		}
   690     		}
   546     	else
   691     	else
   547     		{
   692     		{
   548     		// TODO might use a flag to avoid re-setting
   693     		// might use a flag to avoid re-setting. But it just complicates things.
   549     		qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged long enough:" << text ;
   694     		qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged long enough:" << text ;
   550     		if(codeTop->text()==text)
   695     		if(codeTop->text()==text)
   551     			{
   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
   552     			qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged codes match:" << text ;
   698     			qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged codes match:" << text ;
   553 	    		okAction->setEnabled(true);
   699 	    		okAction->setEnabled(true);
   554 	    		}
   700 	    		}
   555 	    	else
   701 	    	else
   556 	    		{
   702 	    		{
   564 // SecUiNotificationDialog::handlebut1Changed()
   710 // SecUiNotificationDialog::handlebut1Changed()
   565 // ----------------------------------------------------------------------------
   711 // ----------------------------------------------------------------------------
   566 //
   712 //
   567 void SecUiNotificationDialog::handlebut1Changed()
   713 void SecUiNotificationDialog::handlebut1Changed()
   568     {
   714     {
   569     	qDebug() << "SecUiNotificationDialog::handlebut1Changed";
   715 		RDEBUG("0", 0);
   570     	codeTop->setText("1234");
   716     codeTop->setText("1234");
   571     }
   717     }
   572 // ----------------------------------------------------------------------------
   718 // ----------------------------------------------------------------------------
   573 // SecUiNotificationDialog::handlebut2Changed()
   719 // SecUiNotificationDialog::handlebut2Changed()
   574 // ----------------------------------------------------------------------------
   720 // ----------------------------------------------------------------------------
   575 //
   721 //
   576 void SecUiNotificationDialog::handlebut2Changed()
   722 void SecUiNotificationDialog::handlebut2Changed()
   577     {
   723     {
   578     	qDebug() << "SecUiNotificationDialog::handlebut2Changed";
   724 		RDEBUG("0", 0);
   579     	QString codeTopText = codeTop->text();
   725     	QString codeTopText = codeTop->text();
   580     	qDebug() << "codeTopText";
   726     	qDebug() << "codeTopText";
   581     	qDebug() << codeTopText;
   727     	qDebug() << codeTopText;
   582     	codeTopText = codeTopText + "1" ;
   728     	codeTopText = codeTopText + "1" ;
   583     	qDebug() << "codeTopText+1";
   729     	qDebug() << "codeTopText+1";
   584     	qDebug() << codeTopText;
   730     	qDebug() << codeTopText;
   585     	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     
   586     }
   766     }
   587 // ----------------------------------------------------------------------------
   767 // ----------------------------------------------------------------------------
   588 // SecUiNotificationDialog::handlebut3Changed()
   768 // SecUiNotificationDialog::handlebut3Changed()
   589 // ----------------------------------------------------------------------------
   769 // ----------------------------------------------------------------------------
   590 //
   770 //
   611 }
   791 }
   612 
   792 
   613 // ----------------------------------------------------------------------------
   793 // ----------------------------------------------------------------------------
   614 // SecUiNotificationDialog::subscriberKSecurityUIsDismissDialogChanged()
   794 // SecUiNotificationDialog::subscriberKSecurityUIsDismissDialogChanged()
   615 // A way for Autolock to dismiss any possible PIN dialog
   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
   616 // ----------------------------------------------------------------------------
   798 // ----------------------------------------------------------------------------
   617 //
   799 //
   618 void SecUiNotificationDialog::subscriberKSecurityUIsDismissDialogChanged()
   800 void SecUiNotificationDialog::subscriberKSecurityUIsDismissDialogChanged()
   619     {
   801     {
   620 enum TSecurityUIsDismissDialogValues
       
   621     {
       
   622     ESecurityUIsDismissDialogUninitialized = 0,
       
   623     ESecurityUIsDismissDialogOn,
       
   624     ESecurityUIsDismissDialogProcessing,
       
   625     ESecurityUIsDismissDialogDone,
       
   626     ESecurityUIsDismissDialogLastValue
       
   627     };
       
   628 
   802 
   629     RDEBUG("0", 0);
   803     RDEBUG("0", 0);
       
   804 		RDEBUG("mMyId", mMyId);
   630     TInt aDismissDialog = ESecurityUIsDismissDialogUninitialized;
   805     TInt aDismissDialog = ESecurityUIsDismissDialogUninitialized;
   631     TInt err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsDismissDialog, aDismissDialog );
   806     TInt err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsDismissDialog, aDismissDialog );
   632     RDEBUG("err", err);
   807     RDEBUG("err", err);
   633 	RDEBUG("aDismissDialog", aDismissDialog);
   808 		RDEBUG("aDismissDialog", aDismissDialog);
   634     if( aDismissDialog == ESecurityUIsDismissDialogOn )
   809     if( aDismissDialog == ESecurityUIsDismissDialogOn )
   635     	{
   810     	{
   636 		err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogProcessing );
   811     	if(subscriberKSecurityUIsDismissDialog)
   637 		RDEBUG("err", err);
   812     		{
   638 		// TODO perhaps do this only if Cancel is allowed?
   813     		RDEBUG("subscriberKSecurityUIsDismissDialog", 1);
   639 		RDEBUG("sendResult(KErrDied)", 0);
   814     		}
   640 		sendResult(KErrDied);	// similar to     emit handleCancelled();
   815     	else
   641 		RDEBUG("emit closeDeviceDialog", 0);
   816     		{
   642 		emit closeDeviceDialog(false);	// false means "not by client", although it's not really used
   817     		RDEBUG("! subscriberKSecurityUIsDismissDialog", 0);
   643 		RDEBUG("all emited", 0);
   818     		}
   644 		err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogDone );	// clear after using it
   819 
   645 		RDEBUG("err", err);
   820     	if(this)
   646     	}
   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);
   647 	}
   863 	}