securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationdialog.cpp
changeset 35 f1030a78d563
parent 30 cc1cea6aabaf
child 42 82671cd8994b
equal deleted inserted replaced
33:3aa774c655ac 35:f1030a78d563
    22 // #include <hbpopupbase.h>        // HbPopupBase::NoTimeout
    22 // #include <hbpopupbase.h>        // HbPopupBase::NoTimeout
    23 #include <hblabel.h>
    23 #include <hblabel.h>
    24 #include <hbaction.h>
    24 #include <hbaction.h>
    25 #include <QDebug>
    25 #include <QDebug>
    26 #include <e32debug.h>
    26 #include <e32debug.h>
       
    27 #include <hbtranslator.h>
    27 #include <cphcltemergencycall.h>
    28 #include <cphcltemergencycall.h>
    28 #include <SCPServerInterface.h>	// for TARM error codes while validating new lock code
    29 #include <SCPServerInterface.h>	// for TARM error codes while validating new lock code
    29 #include <QString>
    30 #include <QString>
    30 #include <QDialogButtonBox>
    31 #include <QDialogButtonBox>
    31 #include <HbEditorInterface>
    32 #include <HbEditorInterface>
    32 #include <e32property.h>
    33 #include <e32property.h>
    33 
    34 
    34 QTM_USE_NAMESPACE
    35 QTM_USE_NAMESPACE
    35 
    36 
       
    37 const QString KTranslationsPath = "/resource/qt/translations/";
       
    38 const QString KSecUiNotificationTranslationsFile = "secui";
       
    39 const QString KCommonTranslationsFile = "common";
       
    40 
    36 #include <qvaluespacesubscriber.h>
    41 #include <qvaluespacesubscriber.h>
    37 #include <qvaluespacepublisher.h>
    42 #include <qvaluespacepublisher.h>
    38 #define ESecUiBasicTypeText    0x0000000
    43 #define ESecUiBasicTypeText    0x0000000
    39 #define ESecUiBasicTypeCheck   0x0010000
    44 #define ESecUiBasicTypeCheck   0x0010000
    40 #define ESecUiBasicTypeCheckMulti   0x0020000
    45 #define ESecUiBasicTypeCheckMulti   0x0020000
    77 // ----------------------------------------------------------------------------
    82 // ----------------------------------------------------------------------------
    78 // SecUiNotificationDialog::SecUiNotificationDialog()
    83 // SecUiNotificationDialog::SecUiNotificationDialog()
    79 // ----------------------------------------------------------------------------
    84 // ----------------------------------------------------------------------------
    80 //
    85 //
    81 SecUiNotificationDialog::SecUiNotificationDialog(
    86 SecUiNotificationDialog::SecUiNotificationDialog(
    82         const QVariantMap &parameters) : HbDialog(), mLastError(KNoError)
    87         const QVariantMap &parameters) : HbDialog(), mCommonTranslator(0), mSecUiNotificationTranslator(0), mLastError(KNoError)
    83 {
    88 {
    84 		RDEBUG("0", 0);
    89 		RDEBUG("0", 0);
    85 		TTime myTime;
    90 		TTime myTime;
    86     myTime.HomeTime();
    91     myTime.HomeTime();
    87 		mMyId = I64LOW( myTime.Int64() );
    92 		mMyId = I64LOW( myTime.Int64() );
       
    93     mCommonTranslator = new HbTranslator(KTranslationsPath, KCommonTranslationsFile);
       
    94     mSecUiNotificationTranslator = new HbTranslator(KTranslationsPath, KSecUiNotificationTranslationsFile);
    88     constructDialog(parameters);
    95     constructDialog(parameters);
    89 }
    96 }
    90 
    97 
    91 // ----------------------------------------------------------------------------
    98 // ----------------------------------------------------------------------------
    92 // SecUiNotificationDialog::~SecUiNotificationDialog()
    99 // SecUiNotificationDialog::~SecUiNotificationDialog()
    93 // ----------------------------------------------------------------------------
   100 // ----------------------------------------------------------------------------
    94 //
   101 //
    95 SecUiNotificationDialog::~SecUiNotificationDialog()
   102 SecUiNotificationDialog::~SecUiNotificationDialog()
    96 {
   103 {
    97 	RDEBUG("0", 0);
   104 		RDEBUG("0", 0);
       
   105     delete mSecUiNotificationTranslator;
       
   106     delete mCommonTranslator;
       
   107 		RDEBUG("0", 0);
       
   108     // TODO what about subscriberKSecurityUIsDismissDialog
       
   109     // and codeTop
       
   110 		RDEBUG("1", 1);
    98 }
   111 }
    99 
   112 
   100 // ----------------------------------------------------------------------------
   113 // ----------------------------------------------------------------------------
   101 // SecUiNotificationDialog::setDeviceDialogParameters()
   114 // SecUiNotificationDialog::setDeviceDialogParameters()
   102 // ----------------------------------------------------------------------------
   115 // ----------------------------------------------------------------------------
   213                 RDEBUG("check default.3", 0);
   226                 RDEBUG("check default.3", 0);
   214                 handleCodeTopChanged(codeTop->text());
   227                 handleCodeTopChanged(codeTop->text());
   215                 }
   228                 }
   216             RDEBUG("setFocus", 0);
   229             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.
   230       			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
   231             }	// codeTop!=NULL
   220             
   232             
   221 			const TUint32 KSecurityUIsTestCode  = 0x00000307;
   233 			const TUint32 KSecurityUIsTestCode  = 0x00000307;
   222 			TInt value = 0;
   234 			TInt value = 0;
   223 			TInt err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsTestCode, value );
   235 			TInt err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsTestCode, value );
   224 			RDEBUG("KSecurityUIsTestCode err", err);
   236 			RDEBUG("KSecurityUIsTestCode err", err);
   225 			RDEBUG("faking value", value);
   237 			RDEBUG("faking value", value);
   226 			RDEBUG("mShowEventReceived", mShowEventReceived);
   238 			RDEBUG("mShowEventReceived", mShowEventReceived);
   227 			if(value>0 && mShowEventReceived==true)	// show happens 2 times. Dialog can be closed only the second.
   239 			if(value>0 && value<1000000 && mShowEventReceived==true)	// show happens 2 times. Dialog can be closed only the second.
   228 				{
   240 				{
   229 				QString myString = "";
   241 				QString myString = "";
   230 				myString += QString("%1").arg(value);
   242 				myString += QString("%1").arg(value);
   231 				qDebug() << "SecUiNotificationDialog::faking myString=" << myString;
   243 				RDEBUGQT("myString", myString);
   232 		    codeTop->setText( myString );
   244 		    codeTop->setText( myString );
   233 		    TInt err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsTestCode, 0 );	// clear after using it
   245 		    TInt err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsTestCode, 0 );	// clear after using it
   234 				qDebug() << "SecUiNotificationDialog::calling handleAccepted=" << myString;
   246 		    RDEBUGQT("calling handleAccepted myString", myString);
   235 		    emit handleAccepted();
   247 		    emit handleAccepted();
   236 				// handleAccepted already   emit closeDeviceDialog(false);	// false means "not by client", although it's not really used
   248 				// handleAccepted already   emit closeDeviceDialog(false);	// false means "not by client", although it's not really used
   237 				}
   249 				}
   238 			}
   250 			}
   239     mShowEventReceived = true;
   251     mShowEventReceived = true;
   276         QString titleAttempts = "";
   288         QString titleAttempts = "";
   277    			if(titleText.indexOf('|')>0)
   289    			if(titleText.indexOf('|')>0)
   278     				{	// if separator, take only first part
   290     				{	// if separator, take only first part
   279     				titleText = titleText.left(titleText.indexOf('|'));
   291     				titleText = titleText.left(titleText.indexOf('|'));
   280     				}
   292     				}
   281    			if(titleText.indexOf('#')>0)
   293    			if(titleText.indexOf('$')>0)
   282     				{	// if separator, take only first part
   294     				{	// if separator, take only first part
   283     				titleAttempts = titleText.right(titleText.length()-titleText.indexOf('#')-1);
   295     				titleAttempts = titleText.right(titleText.length()-titleText.indexOf('$')-1);
   284     				qDebug() << "SecUiNotificationDialog::titleAttempts=" << titleAttempts;
   296     				RDEBUGQT("titleAttempts", titleAttempts);
   285     				int nAttempts = titleAttempts.toInt();
   297     				int nAttempts = titleAttempts.toInt();
   286     				RDEBUG("nAttempts", nAttempts);
   298     				RDEBUG("nAttempts", nAttempts);
   287     				titleText = titleText.left(titleText.indexOf('#'));
   299     				titleText = titleText.left(titleText.indexOf('$'));
   288     				if(nAttempts>0)
   300     				if(nAttempts>0)
   289     					titleText = titleText + " attempts=" + QString::number(nAttempts);
   301     					titleText = titleText + " attempts=" + QString::number(nAttempts);
   290     				}
   302     				}
   291     		titleText = "Security Query";	// this is the header, for any potential later error which needs to be displayed
   303     		titleText = hbTrId("Security Query");	// this is the header, for any potential later error which needs to be displayed
   292         // This is created only if needed (i.e. errors for NewLockCode)
   304         // This is created only if needed (i.e. errors for NewLockCode)
   293         // titleWidget = new HbLabel(titleText);
   305         // titleWidget = new HbLabel(titleText);
   294         // setHeadingWidget(titleWidget);
   306         // setHeadingWidget(titleWidget);
   295     }
   307     }
   296 
   308 
   297 	    if (parameters.contains(KEmergency)) {
   309 	    if (parameters.contains(KEmergency)) {
   298 					RDEBUG("KEmergency", 1);
   310 					RDEBUG("KEmergency", 1);
   299 	        QString emergencyText = parameters.value(KEmergency).toString();
   311 	        QString emergencyText = parameters.value(KEmergency).toString();
   300 	        qDebug() << emergencyText;
   312 	        RDEBUGQT("emergencyText", emergencyText);
   301 	        if(!emergencyText.compare("emergencyYes"))
   313 	        if(!emergencyText.compare("emergencyYes"))
   302 	        	{
   314 	        	{
   303 	        	RDEBUG("emergencyYes", 1);
   315 	        	RDEBUG("emergencyYes", 1);
   304 	        	isEmergency = 1;
   316 	        	isEmergency = 1;
   305 	        	okAction->setEnabled(true);
   317 	        	okAction->setEnabled(true);
   306 	        	okAction->setText("Call");
   318 	        	okAction->setText(hbTrId("Call"));
   307     				return true;
   319     				return true;
   308 	        	}
   320 	        	}
   309 	        if(!emergencyText.compare("emergencyNo"))
   321 	        if(!emergencyText.compare("emergencyNo"))
   310 	        	{
   322 	        	{
   311 	        	RDEBUG("emergencyNo", 1);
   323 	        	RDEBUG("emergencyNo", 1);
   312 	        	isEmergency = 0;
   324 	        	isEmergency = 0;
   313 	        	okAction->setEnabled(false);	// 112 -> 1122 (=password) . This is handled by   < lMinLength 
   325 	        	okAction->setEnabled(false);	// 112 -> 1122 (=password) . This is handled by   < lMinLength 
   314 	        	okAction->setText("Ok");
   326 	        	okAction->setText(hbTrId("Ok"));
   315     				return true;
   327     				return true;
   316 	        	}
   328 	        	}
   317 	    }
   329 	    }
   318 	    // after TARM validation.
   330 	    // after TARM validation.
   319 	    if (parameters.contains(KInvalidNewLockCode)) {
   331 	    if (parameters.contains(KInvalidNewLockCode)) {
   320 					RDEBUG("KInvalidNewLockCode", 0);
   332 					RDEBUG("KInvalidNewLockCode", 0);
   321 	        QString invalidText = parameters.value(KInvalidNewLockCode).toString();
   333 	        QString invalidText = parameters.value(KInvalidNewLockCode).toString();
   322 	        qDebug() << invalidText;
   334 	        RDEBUGQT("invalidText", invalidText);
   323 	        QString newTitleText = "Lock Code";	// TODO take from the original one
   335 	        QString newTitleText = "Lock Code";	// TODO take from the original one
   324 
   336 
   325 	        QString invalidStr = invalidText.right(invalidText.length()-invalidText.indexOf('#')-1);
   337 	        QString invalidStr = invalidText.right(invalidText.length()-invalidText.indexOf('$')-1);
   326 	        int invalidNumber = invalidStr.toInt();
   338 	        int invalidNumber = invalidStr.toInt();
   327 	        RDEBUG("invalidNumber", invalidNumber);
   339 	        RDEBUG("invalidNumber", invalidNumber);
   328 	        if(invalidNumber<0)
   340 	        if(invalidNumber<0)	// that is, -1
   329 	        	{
   341 	        	{
   330 	        	RDEBUG("invalidNumber<0", invalidNumber );
   342 	        	RDEBUG("invalidNumber<0", invalidNumber );
   331 	        	// nothing to do
   343 	        	// nothing to do
   332 	        	}
   344 	        	}
   333 				if(invalidNumber==EDeviceLockAutolockperiod)
   345 				if(invalidNumber==EDeviceLockAutolockperiod)
   334 	        	{
   346 	        	{
   335 	        	RDEBUG("EDeviceLockAutolockperiod", invalidNumber );
   347 	        	RDEBUG("EDeviceLockAutolockperiod", invalidNumber );
   336 	        	newTitleText+="EDeviceLockAutolockperiod";
   348 	        	newTitleText+=hbTrId("EDeviceLockAutolockperiod");
   337 	        	}
   349 	        	}
   338 	        if(invalidNumber==EDeviceLockMaxAutolockPeriod)
   350 	        if(invalidNumber==EDeviceLockMaxAutolockPeriod)
   339 	        	{
   351 	        	{
   340 	        	RDEBUG("EDeviceLockAutolockperiod", invalidNumber );
   352 	        	RDEBUG("EDeviceLockAutolockperiod", invalidNumber );
   341 	        	newTitleText+="EDeviceLockMaxAutolockPeriod";
   353 	        	newTitleText+=hbTrId("EDeviceLockMaxAutolockPeriod");
   342 	        	}
   354 	        	}
   343 	        if(invalidNumber==EDeviceLockMinlength)
   355 	        if(invalidNumber==EDeviceLockMinlength)
   344 	        	{
   356 	        	{
   345 	        	RDEBUG("EDeviceLockMinlength", invalidNumber );
   357 	        	RDEBUG("EDeviceLockMinlength", invalidNumber );
   346 	        	newTitleText+="EDeviceLockMinlength";
   358 	        	newTitleText+=hbTrId("EDeviceLockMinlength");
   347 	        	}
   359 	        	}
   348 	        if(invalidNumber==EDeviceLockMaxlength)
   360 	        if(invalidNumber==EDeviceLockMaxlength)
   349 	        	{
   361 	        	{
   350 	        	RDEBUG("EDeviceLockMaxlength", invalidNumber );
   362 	        	RDEBUG("EDeviceLockMaxlength", invalidNumber );
   351 	        	newTitleText+="EDeviceLockMaxlength";
   363 	        	newTitleText+=hbTrId("EDeviceLockMaxlength");
   352 	        	}
   364 	        	}
   353 	        if(invalidNumber==EDeviceLockRequireUpperAndLower)
   365 	        if(invalidNumber==EDeviceLockRequireUpperAndLower)
   354 	        	{
   366 	        	{
   355 	        	RDEBUG("EDeviceLockRequireUpperAndLower", invalidNumber );
   367 	        	RDEBUG("EDeviceLockRequireUpperAndLower", invalidNumber );
   356 	        	newTitleText+="EDeviceLockRequireUpperAndLower";
   368 	        	newTitleText+=hbTrId("EDeviceLockRequireUpperAndLower");
   357 	        	}
   369 	        	}
   358 	        if(invalidNumber==EDeviceLockRequireCharsAndNumbers)
   370 	        if(invalidNumber==EDeviceLockRequireCharsAndNumbers)
   359 	        	{
   371 	        	{
   360 	        	RDEBUG("EDeviceLockMaxlength", invalidNumber );
   372 	        	RDEBUG("EDeviceLockMaxlength", invalidNumber );
   361 	        	newTitleText+="EDeviceLockMaxlength";
   373 	        	newTitleText+=hbTrId("EDeviceLockMaxlength");
   362 	        	}
   374 	        	}
   363 	        if(invalidNumber==EDeviceLockAllowedMaxRepeatedChars)
   375 	        if(invalidNumber==EDeviceLockAllowedMaxRepeatedChars)
   364 	        	{
   376 	        	{
   365 	        	RDEBUG("EDeviceLockAllowedMaxRepeatedChars", invalidNumber );
   377 	        	RDEBUG("EDeviceLockAllowedMaxRepeatedChars", invalidNumber );
   366 	        	newTitleText+="EDeviceLockAllowedMaxRepeatedChars";
   378 	        	newTitleText+=hbTrId("EDeviceLockAllowedMaxRepeatedChars");
   367 	        	}
   379 	        	}
   368 	        if(invalidNumber==EDeviceLockHistoryBuffer)
   380 	        if(invalidNumber==EDeviceLockHistoryBuffer)
   369 	        	{
   381 	        	{
   370 	        	RDEBUG("EDeviceLockHistoryBuffer", invalidNumber );
   382 	        	RDEBUG("EDeviceLockHistoryBuffer", invalidNumber );
   371 	        	newTitleText+="EDeviceLockHistoryBuffer";
   383 	        	newTitleText+=hbTrId("EDeviceLockHistoryBuffer");
   372 	        	}
   384 	        	}
   373 	        if(invalidNumber==EDeviceLockPasscodeExpiration)
   385 	        if(invalidNumber==EDeviceLockPasscodeExpiration)
   374 	        	{
   386 	        	{
   375 	        	RDEBUG("EDeviceLockPasscodeExpiration", invalidNumber );
   387 	        	RDEBUG("EDeviceLockPasscodeExpiration", invalidNumber );
   376 	        	newTitleText+="EDeviceLockPasscodeExpiration";
   388 	        	newTitleText+=hbTrId("EDeviceLockPasscodeExpiration");
   377 	        	}
   389 	        	}
   378 	        if(invalidNumber==EDeviceLockMinChangeTolerance)
   390 	        if(invalidNumber==EDeviceLockMinChangeTolerance)
   379 	        	{
   391 	        	{
   380 	        	RDEBUG("EDeviceLockMinChangeTolerance", invalidNumber );
   392 	        	RDEBUG("EDeviceLockMinChangeTolerance", invalidNumber );
   381 	        	newTitleText+="EDeviceLockMinChangeTolerance";
   393 	        	newTitleText+=hbTrId("EDeviceLockMinChangeTolerance");
   382 	        	}
   394 	        	}
   383 	        if(invalidNumber==EDeviceLockMinChangeInterval)
   395 	        if(invalidNumber==EDeviceLockMinChangeInterval)
   384 	        	{
   396 	        	{
   385 	        	RDEBUG("EDeviceLockMinChangeInterval", invalidNumber );
   397 	        	RDEBUG("EDeviceLockMinChangeInterval", invalidNumber );
   386 	        	newTitleText+="EDeviceLockMinChangeInterval";
   398 	        	newTitleText+=hbTrId("EDeviceLockMinChangeInterval");
   387 	        	}
   399 	        	}
   388 	        if(invalidNumber==EDeviceLockDisallowSpecificStrings)
   400 	        if(invalidNumber==EDeviceLockDisallowSpecificStrings)
   389 	        	{
   401 	        	{
   390 	        	RDEBUG("EDeviceLockDisallowSpecificStrings", invalidNumber );
   402 	        	RDEBUG("EDeviceLockDisallowSpecificStrings", invalidNumber );
   391 	        	newTitleText+="EDeviceLockDisallowSpecificStrings";
   403 	        	newTitleText+=hbTrId("EDeviceLockDisallowSpecificStrings");
   392 	        	}
   404 	        	}
   393 	        if(invalidNumber==EDeviceLockAllowedMaxAtempts)
   405 	        if(invalidNumber==EDeviceLockAllowedMaxAtempts)
   394 	        	{
   406 	        	{
   395 	        	RDEBUG("EDeviceLockAllowedMaxAtempts", invalidNumber );
   407 	        	RDEBUG("EDeviceLockAllowedMaxAtempts", invalidNumber );
   396 	        	newTitleText+="EDeviceLockAllowedMaxAtempts";
   408 	        	newTitleText+=hbTrId("EDeviceLockAllowedMaxAtempts");
   397 	        	}
   409 	        	}
   398 	        if(invalidNumber==EDeviceLockConsecutiveNumbers)
   410 	        if(invalidNumber==EDeviceLockConsecutiveNumbers)
   399 	        	{
   411 	        	{
   400 	        	RDEBUG("EDeviceLockConsecutiveNumbers", invalidNumber );
   412 	        	RDEBUG("EDeviceLockConsecutiveNumbers", invalidNumber );
   401 	        	newTitleText+="EDeviceLockConsecutiveNumbers";
   413 	        	newTitleText+=hbTrId("EDeviceLockConsecutiveNumbers");
   402 	        	}
   414 	        	}
   403 	        if(invalidNumber==EDeviceLockMinSpecialCharacters)
   415 	        if(invalidNumber==EDeviceLockMinSpecialCharacters)
   404 	        	{
   416 	        	{
   405 	        	RDEBUG("EDeviceLockMinSpecialCharacters", invalidNumber );
   417 	        	RDEBUG("EDeviceLockMinSpecialCharacters", invalidNumber );
   406 	        	newTitleText+="EDeviceLockMinSpecialCharacters";
   418 	        	newTitleText+=hbTrId("EDeviceLockMinSpecialCharacters");
   407 	        	}
   419 	        	}
   408 	        if(invalidNumber==EDeviceLockSingleCharRepeatNotAllowed)
   420 	        if(invalidNumber==EDeviceLockSingleCharRepeatNotAllowed)
   409 	        	{
   421 	        	{
   410 	        	RDEBUG("EDeviceLockSingleCharRepeatNotAllowed", invalidNumber );
   422 	        	RDEBUG("EDeviceLockSingleCharRepeatNotAllowed", invalidNumber );
   411 	        	newTitleText+="EDeviceLockSingleCharRepeatNotAllowed";
   423 	        	newTitleText+=hbTrId("EDeviceLockSingleCharRepeatNotAllowed");
   412 	        	}
   424 	        	}
   413 	        if(invalidNumber==EDevicelockConsecutiveCharsNotAllowed)
   425 	        if(invalidNumber==EDevicelockConsecutiveCharsNotAllowed)
   414 	        	{
   426 	        	{
   415 	        	RDEBUG("EDevicelockConsecutiveCharsNotAllowed", invalidNumber );
   427 	        	RDEBUG("EDevicelockConsecutiveCharsNotAllowed", invalidNumber );
   416 	        	newTitleText+="EDevicelockConsecutiveCharsNotAllowed";
   428 	        	newTitleText+=hbTrId("EDevicelockConsecutiveCharsNotAllowed");
   417 	        	}
   429 	        	}
   418 	        if(invalidNumber>=EDevicelockTotalPolicies)
   430 	        if(invalidNumber>=EDevicelockTotalPolicies)
   419 	        	{
   431 	        	{
   420 	        	RDEBUG("EDevicelockTotalPolicies", invalidNumber );
   432 	        	RDEBUG("EDevicelockTotalPolicies", invalidNumber );
   421 	        	newTitleText+="EDevicelockTotalPolicies";
   433 	        	newTitleText+=hbTrId("EDevicelockTotalPolicies");
   422 	        	}
   434 	        	}
   423 	        if( !titleWidget )
   435 	        if( !titleWidget )
   424 	        	{
   436 	        	{
   425 	        	RDEBUG("creating titleWidget", 0 );
   437 	        	RDEBUG("creating titleWidget", 0 );
   426 	        	titleWidget = new HbLabel("New lock code");	// it will be changed later
   438 	        	titleWidget = new HbLabel(hbTrId("New lock code"));	// it will be changed later
   427           	setHeadingWidget(titleWidget);
   439           	setHeadingWidget(titleWidget);
   428           	}
   440           	}
   429           RDEBUG("setPlainText", 0 );
   441           RDEBUG("setPlainText", 0 );
   430 	        titleWidget->setPlainText(newTitleText);
   442 	        titleWidget->setPlainText(newTitleText);
   431 	        
   443 	        
   432 	        if(invalidNumber<0)	// everything is ok
   444 	        if(invalidNumber<0)	// everything is ok
   433 	        	{
   445 	        	{
   434 	        	okAction->setEnabled(true);	// this might fail in the scenario: check this : invalid -> valid. This allows verif ?
   446 	        	okAction->setEnabled(true);	// this might fail in the scenario: check this : invalid -> valid. This allows verif ?
   435 	        	okAction->setText("Ok");
   447 	        	okAction->setText(hbTrId("Ok"));
   436 	        	codeBottom->setEnabled(true);
   448 	        	codeBottom->setEnabled(true);
   437 	        	}
   449 	        	}
   438 	        else
   450 	        else
   439 	        	{
   451 	        	{
   440 	        	okAction->setEnabled(false);
   452 	        	okAction->setEnabled(false);
   441 	        	codeBottom->setEnabled(false);
   453 	        	codeBottom->setEnabled(false);
   442 	        	codeBottom->setText("");
   454 	        	codeBottom->setText("");
   443 	        	okAction->setText("Ok");
   455 	        	okAction->setText(hbTrId("Ok"));
   444 	        	}
   456 	        	}
   445 	        // need to return because all objects are already created
   457 	        // need to return because all objects are already created
   446    				return true;
   458    				return true;
   447 	    }
   459 	    }
   448 	
   460 	
   475     	{
   487     	{
   476     	// no need to create OK or Cancel
   488     	// no need to create OK or Cancel
   477     	return true;
   489     	return true;
   478     	}
   490     	}
   479 
   491 
   480     okAction = new HbAction(tr("Ok"));
   492     okAction = new HbAction(hbTrId("Ok"));
   481     RDEBUG("created HbAction okAction", 1);
   493     RDEBUG("created HbAction okAction", 1);
   482     okAction->setEnabled(false);	// initially the OK is disabled because codeTop is empty
   494     okAction->setEnabled(false);	// initially the OK is disabled because codeTop is empty
   483     if((queryType & ESecUiBasicTypeMask) ==ESecUiBasicTypeCheck) {
   495     if((queryType & ESecUiBasicTypeMask) ==ESecUiBasicTypeCheck) {
   484         okAction->setEnabled(true);
   496         okAction->setEnabled(true);
   485         setHeadingWidget(0); // had to remove this no multiline
   497         setHeadingWidget(0); // had to remove this no multiline
   492     // setPrimaryAction(okAction);
   504     // setPrimaryAction(okAction);
   493     addAction(okAction);
   505     addAction(okAction);
   494     disconnect(okAction, SIGNAL(triggered()), this, SLOT(close()));	// the close will be done in handleAccepted
   506     disconnect(okAction, SIGNAL(triggered()), this, SLOT(close()));	// the close will be done in handleAccepted
   495     connect(okAction, SIGNAL(triggered()), this, SLOT(handleAccepted()));
   507     connect(okAction, SIGNAL(triggered()), this, SLOT(handleAccepted()));
   496     
   508     
   497     cancelAction = new HbAction(tr("Cancel"));    // qtTrId("txt_common_button_cancel")
   509     cancelAction = new HbAction(hbTrId("Cancel"));    // qtTrId("txt_common_button_cancel")
   498     addAction(cancelAction);
   510     addAction(cancelAction);
   499     disconnect(cancelAction, SIGNAL(triggered()), this, SLOT(close()));	// the close will be done in handleCancelled
   511     disconnect(cancelAction, SIGNAL(triggered()), this, SLOT(close()));	// the close will be done in handleCancelled
   500     connect(cancelAction, SIGNAL(triggered()), this, SLOT(handleCancelled()));
   512     connect(cancelAction, SIGNAL(triggered()), this, SLOT(handleCancelled()));
   501     // setAction(cancelAction, QDialogButtonBox::RejectRole);		// it's supposed to use this, when deprecated
   513     // setAction(cancelAction, QDialogButtonBox::RejectRole);		// it's supposed to use this, when deprecated
   502     // setSecondaryAction(cancelAction);
   514     // setSecondaryAction(cancelAction);
   541 		RDEBUG("mMyId", mMyId);
   553 		RDEBUG("mMyId", mMyId);
   542     QVariant acceptedValue(accepted);
   554     QVariant acceptedValue(accepted);
   543 		RDEBUG("0", 0);
   555 		RDEBUG("0", 0);
   544     mResultMap.insert(KResultAccepted, acceptedValue);
   556     mResultMap.insert(KResultAccepted, acceptedValue);
   545 		RDEBUG("0", 0);
   557 		RDEBUG("0", 0);
   546 		qDebug() << mResultMap;
   558 		RDEBUGQT("mResultMap", mResultMap);
   547 		RDEBUG("queryType", queryType);
   559 		RDEBUG("queryType", queryType);
   548 		if(!(queryType & ESecUiTypeMaskLock))
   560 		if(!(queryType & ESecUiTypeMaskLock))
   549 			{	// the lock-icon should not reply
   561 			{	// the lock-icon should not reply
   550 			RDEBUG("emit deviceDialogData", 0);
   562 			RDEBUG("emit deviceDialogData", 0);
   551     	emit deviceDialogData(mResultMap);
   563     	emit deviceDialogData(mResultMap);
   579         QModelIndexList selectedItems = selectionModel->selectedIndexes();
   591         QModelIndexList selectedItems = selectionModel->selectedIndexes();
   580         QModelIndex index;
   592         QModelIndex index;
   581         codeTopText="";
   593         codeTopText="";
   582          foreach(index, selectedItems) { 
   594          foreach(index, selectedItems) { 
   583 		 		 codeTopText+=QString::number(index.row());
   595 		 		 codeTopText+=QString::number(index.row());
   584                 //could also use  if(index.row()!=selectedItems.count()-1) codeTopText+= "|";
   596                 // could also use  if(index.row()!=selectedItems.count()-1) codeTopText+= "|";
   585                 codeTopText+= "|";
   597                 codeTopText+= "|";
   586                 }
   598                 }
   587          mResultMap.insert(KCodeTopIndex,  codeTopText);
   599          mResultMap.insert(KCodeTopIndex,  codeTopText);
   588     	}
   600     	}
   589     else
   601     else
   590         codeTopText = codeTop->text();
   602         codeTopText = codeTop->text();
   591     // no need to check last time for codeBottom
   603     // no need to check last time for codeBottom
   592    	qDebug() << "codeTopText=" << codeTopText;
   604    	RDEBUGQT("codeTopText", codeTopText);
   593     sendResult(KErrNone);
   605     sendResult(KErrNone);
   594     RDEBUG("calling close()", 0);
   606     RDEBUG("calling close()", 0);
   595     close();	// this is needed because Cancel doesn't automatically closes the dialog
   607     close();	// this is needed because Cancel doesn't automatically closes the dialog
   596 		RDEBUG("emitting deviceDialogClosed", 0);
   608 		RDEBUG("emitting deviceDialogClosed", 0);
   597 		emit deviceDialogClosed();
   609 		emit deviceDialogClosed();
   618 //
   630 //
   619 void SecUiNotificationDialog::handleMemorySelectionChanged(const QString &text)
   631 void SecUiNotificationDialog::handleMemorySelectionChanged(const QString &text)
   620     {
   632     {
   621 		RDEBUG("0", 0);
   633 		RDEBUG("0", 0);
   622 		RDEBUG("mMyId", mMyId);
   634 		RDEBUG("mMyId", mMyId);
   623     qDebug() << text;
   635     RDEBUGQT("text", text);
   624     QVariant memorySelection(text);
   636     QVariant memorySelection(text);
   625     mResultMap.insert(KSelectedMemoryIndex, memorySelection);
   637     mResultMap.insert(KSelectedMemoryIndex, memorySelection);
   626     }
   638     }
   627 
   639 
   628 void SecUiNotificationDialog::handleCodeTopContentChanged()
   640 void SecUiNotificationDialog::handleCodeTopContentChanged()
   629     {
   641     {
   630 		RDEBUG("0", 0);
   642 		RDEBUG("0", 0);
   631 		RDEBUG("mMyId", mMyId);
   643 		RDEBUG("mMyId", mMyId);
   632     	qDebug() << codeTop->text();
   644     	RDEBUGQT("codeTop->text()", codeTop->text());
   633     	handleCodeTopChanged(codeTop->text());
   645     	handleCodeTopChanged(codeTop->text());
   634     }
   646     }
   635 
   647 
   636 // ----------------------------------------------------------------------------
   648 // ----------------------------------------------------------------------------
   637 // SecUiNotificationDialog::handleCodeTopChanged()
   649 // SecUiNotificationDialog::handleCodeTopChanged()
   638 // ----------------------------------------------------------------------------
   650 // ----------------------------------------------------------------------------
   639 //
   651 //
   640 void SecUiNotificationDialog::handleCodeTopChanged(const QString &text)
   652 void SecUiNotificationDialog::handleCodeTopChanged(const QString &text)
   641     {
   653     {
   642 		RDEBUG("0", 0);
   654 		RDEBUG("0", 0);
   643     	qDebug() << "SecUiNotificationDialog::handleCodeTopChanged=" << text ;
   655     	RDEBUGQT("text", text);
   644     	if(queryDual)
   656     	if(queryDual)
   645     		{
   657     		{
   646     		codeBottom->setText("");	// any change resets the verification.
   658     		codeBottom->setText("");	// any change resets the verification.
       
   659 	    	if( (queryType & ESecUiMaskType) == 0x000004  )	// new codeLock
       
   660 	    		{	// ChangeSecCodeParamsL change RMobilePhone::ESecurityCodePhonePassword
       
   661 				    QVariant codeTopVar(text);
       
   662 				    mResultMap.insert(KCodeTopIndex, codeTopVar);
       
   663 						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
       
   664 	    		}
   647     		}
   665     		}
   648     	if( queryType == 0x1000004 )	// new codeLock
   666     	else if(text.length() < lMinLength )
   649     		{	// ChangeSecCodeParamsL change RMobilePhone::ESecurityCodePhonePassword
       
   650 			    QVariant codeTopVar(text);
       
   651 			    mResultMap.insert(KCodeTopIndex, codeTopVar);
       
   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
       
   653     		}
       
   654     	if(text.length() < lMinLength )
       
   655     		{
   667     		{
   656     		qDebug() << "SecUiNotificationDialog::handleCodeTopChanged too short:" << text ;
   668     		RDEBUGQT("too short text", text);
   657     		okAction->setEnabled(false);
   669     		okAction->setEnabled(false);
   658 				RDEBUG("lEmergencySupported", lEmergencySupported);
   670 				RDEBUG("lEmergencySupported", lEmergencySupported);
   659 				if( lEmergencySupported && text.length() > 2 )	// emergency numbers need at least 3 digits
   671 				if( lEmergencySupported && text.length() > 2 )	// emergency numbers need at least 3 digits
   660 					{	// check whether it's a emergency number
   672 					{	// check whether it's a emergency number
   661 					QVariant codeTopVar(text);
   673 					QVariant codeTopVar(text);
   664 					}
   676 					}
   665     		}
   677     		}
   666     	else if (text.length() >= lMinLength)
   678     	else if (text.length() >= lMinLength)
   667     		{
   679     		{
   668     		// might use a flag to avoid re-setting. But this complicates things if there's another initial verification
   680     		// might use a flag to avoid re-setting. But this complicates things if there's another initial verification
   669     		qDebug() << "SecUiNotificationDialog::handleCodeTopChanged long enough:" << text ;
   681     		RDEBUGQT("long enough text", text);
   670     		okAction->setText("Ok");
   682     		okAction->setText(hbTrId("Ok"));
   671     		if(queryDual==0)	// only if Bottom is not used
   683     		if(queryDual==0)	// only if Bottom is not used
   672     			okAction->setEnabled(true);
   684     			okAction->setEnabled(true);
   673     		}
   685     		}
   674     QVariant codeTopVar(text);
   686     QVariant codeTopVar(text);
   675     mResultMap.insert(KCodeTopIndex, codeTopVar);
   687     mResultMap.insert(KCodeTopIndex, codeTopVar);
   679 // ----------------------------------------------------------------------------
   691 // ----------------------------------------------------------------------------
   680 //
   692 //
   681 void SecUiNotificationDialog::handleCodeBottomChanged(const QString &text)
   693 void SecUiNotificationDialog::handleCodeBottomChanged(const QString &text)
   682     {
   694     {
   683 		RDEBUG("0", 0);
   695 		RDEBUG("0", 0);
   684     	qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged" << text ;
   696     	RDEBUGQT("text", text);
   685     	qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged. codeTop=" << codeTop->text() ;
   697     	RDEBUGQT("codeTop->text()", codeTop->text());
   686     	if(text.length() < lMinLength )
   698     	if(text.length() < lMinLength )
   687     		{
   699     		{
   688     		qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged too short:" << text ;
   700     		RDEBUGQT("too short text", text);
   689     		okAction->setEnabled(false);
   701     		okAction->setEnabled(false);
   690     		}
   702     		}
   691     	else
   703     	else
   692     		{
   704     		{
   693     		// might use a flag to avoid re-setting. But it just complicates things.
   705     		// might use a flag to avoid re-setting. But it just complicates things.
   694     		qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged long enough:" << text ;
   706     		RDEBUGQT("long enough text", text);
   695     		if(codeTop->text()==text)
   707     		if(codeTop->text()==text)
   696     			{
   708     			{
   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
   709     			// 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
   698     			qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged codes match:" << text ;
   710     			RDEBUGQT("codes match", text);
   699 	    		okAction->setEnabled(true);
   711 	    		okAction->setEnabled(true);
   700 	    		}
   712 	    		}
   701 	    	else
   713 	    	else
   702 	    		{
   714 	    		{
   703     			qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged codes not match:" << text ;
   715     			RDEBUGQT("codes don't match", text);
   704 					okAction->setEnabled(false);
   716 					okAction->setEnabled(false);
   705 	    		}
   717 	    		}
   706     		}
   718     		}
   707 		// verification is not sent
   719 		// verification is not sent
   708     }
   720     }
   721 //
   733 //
   722 void SecUiNotificationDialog::handlebut2Changed()
   734 void SecUiNotificationDialog::handlebut2Changed()
   723     {
   735     {
   724 		RDEBUG("0", 0);
   736 		RDEBUG("0", 0);
   725     	QString codeTopText = codeTop->text();
   737     	QString codeTopText = codeTop->text();
   726     	qDebug() << "codeTopText";
   738     	RDEBUGQT("codeTopText", codeTopText);
   727     	qDebug() << codeTopText;
       
   728     	codeTopText = codeTopText + "1" ;
   739     	codeTopText = codeTopText + "1" ;
   729     	qDebug() << "codeTopText+1";
   740     	RDEBUGQT("codeTopText+1", codeTopText);
   730     	qDebug() << codeTopText;
       
   731     	codeTop->setText(codeTopText);
   741     	codeTop->setText(codeTopText);
   732     	
   742     	
   733     	      RDEBUG("editorInterface", 0);
   743     	      RDEBUG("editorInterface", 0);
   734       			HbEditorInterface editorInterface(codeTop);
   744       			HbEditorInterface editorInterface(codeTop);
   735       			RDEBUG("actions", 0);
   745       			RDEBUG("actions", 0);
   768 // SecUiNotificationDialog::handlebut3Changed()
   778 // SecUiNotificationDialog::handlebut3Changed()
   769 // ----------------------------------------------------------------------------
   779 // ----------------------------------------------------------------------------
   770 //
   780 //
   771 void SecUiNotificationDialog::handlebut3Changed()
   781 void SecUiNotificationDialog::handlebut3Changed()
   772     {
   782     {
   773     	qDebug() << "SecUiNotificationDialog::handlebut3Changed";
   783     	RDEBUG("0", 0);
   774     	QString codeTopText = codeTop->text();
   784     	QString codeTopText = codeTop->text();
   775     	qDebug() << "codeTopText";
   785     	RDEBUG("codeTopText", 0);
   776     	qDebug() << codeTopText;
   786     	RDEBUGQT("codeTopText", codeTopText);
   777     	codeTopText = codeTopText + "5" ;
   787     	codeTopText = codeTopText + "5" ;
   778     	qDebug() << "codeTopText+5";
   788     	RDEBUGQT("codeTopText+5", codeTopText);
   779     	codeTop->setEchoMode(HbLineEdit::PasswordEchoOnEdit);
   789     	codeTop->setEchoMode(HbLineEdit::PasswordEchoOnEdit);
   780     	qDebug() << codeTopText;
   790     	RDEBUGQT("codeTopText", codeTopText);
   781     	codeTop->setText(codeTopText);
   791     	codeTop->setText(codeTopText);
       
   792     	RDEBUG("setFocus", 0);
       
   793     	codeTop->setFocus();
       
   794     	RDEBUG("1", 1);
   782     }
   795     }
   783 
   796 
   784 // ----------------------------------------------------------------------------
   797 // ----------------------------------------------------------------------------
   785 // SecUiNotificationDialog::saveFocusWidget(QWidget*,QWidget*)
   798 // SecUiNotificationDialog::saveFocusWidget(QWidget*,QWidget*)
   786 // ----------------------------------------------------------------------------
   799 // ----------------------------------------------------------------------------