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