securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationdialog.cpp
--- a/securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationdialog.cpp Fri Apr 16 15:53:24 2010 +0300
+++ b/securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationdialog.cpp Mon May 03 13:20:16 2010 +0300
@@ -22,6 +22,11 @@
#include <hblabel.h>
#include <hbaction.h>
#include <QDebug>
+#include <e32debug.h>
+#include <CPhCltEmergencyCall.h>
+#include <SCPServerInterface.h> // for TARM error codes while validating new lock code
+#include <QString>
+#include <QDialogButtonBox>
#define ESecUiCancelSupported 0x1000000
#define ESecUiCancelNotSupported 0x0000000
@@ -29,6 +34,19 @@
#define ESecUiEmergencySupported 0x2000000
#define ESecUiEmergencyNotSupported 0x0000000
+#define ESecUiAlphaSupported 0x4000000
+#define ESecUiAlphaNotSupported 0x0000000
+
+#define ESecUiMaskFlags 0xFF000000
+#define ESecUiMaskType 0x00FFFFFF
+
+#define ESecUiTypeDeviceLock 0x00100000
+#define ESecUiTypeKeyguard 0x00200000
+#define ESecUiTypeClock 0x00300000
+#define ESecUiTypeScreensaver 0x00400000
+
+#define ESecUiTypeMaskLock 0x00F00000
+
// ----------------------------------------------------------------------------
// SecUiNotificationDialog::SecUiNotificationDialog()
// ----------------------------------------------------------------------------
@@ -131,32 +149,198 @@
// Title
if (parameters.contains(KDialogTitle)) {
QString titleText = parameters.value(KDialogTitle).toString();
- HbLabel *title = new HbLabel(titleText);
+ QString titleAttempts = "";
+ if(titleText.indexOf('|')>0)
+ { // if separator, take only first part
+ titleText = titleText.left(titleText.indexOf('|'));
+ }
+ if(titleText.indexOf('#')>0)
+ { // if separator, take only first part
+ titleAttempts = titleText.right(titleText.length()-titleText.indexOf('#')-1);
+ qDebug() << "SecUiNotificationDialog::titleAttempts=" << titleAttempts;
+ int nAttempts = titleAttempts.toInt();
+ qDebug() << "SecUiNotificationDialog::nAttempts=" << nAttempts;
+ titleText = titleText.left(titleText.indexOf('#'));
+ if(nAttempts>0)
+ titleText = titleText + " attempts=" + QString::number(nAttempts);
+ }
+ title = new HbLabel(titleText);
setHeadingWidget(title);
}
+ if (parameters.contains(KEmergency)) {
+ qDebug() << "SecUiNotificationDialog::KEmergency";
+ QString emergencyText = parameters.value(KEmergency).toString();
+ qDebug() << emergencyText;
+ if(!emergencyText.compare("emergencyYes"))
+ {
+ qDebug() << "SecUiNotificationDialog::KEmergency emergencyYes";
+ isEmergency = 1;
+ okAction->setEnabled(true);
+ okAction->setText("Call");
+ return true;
+ }
+ if(!emergencyText.compare("emergencyNo"))
+ {
+ qDebug() << "SecUiNotificationDialog::KEmergency emergencyNo";
+ isEmergency = 0;
+ okAction->setEnabled(false); // 112 -> 1122 (=password) . This is handled by < lMinLength
+ okAction->setText("Ok");
+ return true;
+ }
+ }
+
+ if (parameters.contains(KInvalidNewLockCode)) {
+ qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode";
+ QString invalidText = parameters.value(KInvalidNewLockCode).toString();
+ qDebug() << invalidText;
+
+ title->setPlainText("Lock Code"); // TODO take from the original one
+ QString invalidStr = invalidText.right(invalidText.length()-invalidText.indexOf('#')-1);
+ int invalidNumber = invalidStr.toInt();
+ qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode invalidNumber" << invalidNumber;
+ if(invalidNumber<0)
+ {
+ qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode ???";
+ // nothing to do
+ }
+/*
+ if(invalidNumber==EDeviceLockAutolockperiod)
+ {
+ qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockAutolockperiod";
+ title->setPlainText("EDeviceLockAutolockperiod");
+ }
+ if(invalidNumber==EDeviceLockMaxAutolockPeriod)
+ {
+ qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMaxAutolockPeriod";
+ title->setPlainText("EDeviceLockMaxAutolockPeriod");
+ }
+ if(invalidNumber==EDeviceLockMinlength)
+ {
+ qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinlength";
+ title->setPlainText("EDeviceLockMinlength");
+ }
+ if(invalidNumber==EDeviceLockMaxlength)
+ {
+ qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMaxlength";
+ title->setPlainText("EDeviceLockMaxlength");
+ }
+ if(invalidNumber==EDeviceLockRequireUpperAndLower)
+ {
+ qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockRequireUpperAndLower";
+ title->setPlainText("EDeviceLockRequireUpperAndLower");
+ }
+ if(invalidNumber==EDeviceLockRequireCharsAndNumbers)
+ {
+ qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockRequireCharsAndNumbers";
+ title->setPlainText("EDeviceLockMaxlength");
+ }
+ if(invalidNumber==EDeviceLockAllowedMaxRepeatedChars)
+ {
+ qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockAllowedMaxRepeatedChars";
+ title->setPlainText("EDeviceLockAllowedMaxRepeatedChars");
+ }
+ if(invalidNumber==EDeviceLockHistoryBuffer)
+ {
+ qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockHistoryBuffer";
+ title->setPlainText("EDeviceLockHistoryBuffer");
+ }
+ if(invalidNumber==EDeviceLockPasscodeExpiration)
+ {
+ qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockPasscodeExpiration";
+ title->setPlainText("EDeviceLockPasscodeExpiration");
+ }
+ if(invalidNumber==EDeviceLockMinChangeTolerance)
+ {
+ qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinChangeTolerance";
+ title->setPlainText("EDeviceLockMinChangeTolerance");
+ }
+ if(invalidNumber==EDeviceLockMinChangeInterval)
+ {
+ qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinChangeInterval";
+ title->setPlainText("EDeviceLockMinChangeInterval");
+ }
+ if(invalidNumber==EDeviceLockDisallowSpecificStrings)
+ {
+ qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockDisallowSpecificStrings";
+ title->setPlainText("EDeviceLockDisallowSpecificStrings");
+ }
+ if(invalidNumber==EDeviceLockAllowedMaxAtempts)
+ {
+ qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockAllowedMaxAtempts";
+ title->setPlainText("EDeviceLockAllowedMaxAtempts");
+ }
+ if(invalidNumber==EDeviceLockConsecutiveNumbers)
+ {
+ qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockConsecutiveNumbers";
+ title->setPlainText("EDeviceLockConsecutiveNumbers");
+ }
+ if(invalidNumber==EDeviceLockMinSpecialCharacters)
+ {
+ qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinSpecialCharacters";
+ title->setPlainText("EDeviceLockMinSpecialCharacters");
+ }
+ if(invalidNumber==EDeviceLockSingleCharRepeatNotAllowed)
+ {
+ qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockSingleCharRepeatNotAllowed";
+ title->setPlainText("EDeviceLockSingleCharRepeatNotAllowed");
+ }
+ if(invalidNumber==EDevicelockConsecutiveCharsNotAllowed)
+ {
+ qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDevicelockConsecutiveCharsNotAllowed";
+ title->setPlainText("EDevicelockConsecutiveCharsNotAllowed");
+ }
+ if(invalidNumber>=EDevicelockTotalPolicies)
+ {
+ qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDevicelockTotalPolicies";
+ title->setPlainText("EDevicelockTotalPolicies");
+ }
+ */
+ // always keep OK valid.
+ return true;
+ }
+
// Content
SecUiNotificationContentWidget *content = new SecUiNotificationContentWidget();
content->constructFromParameters(parameters);
setContentWidget(content);
+
+ queryType = content->queryType;
+ queryDual = content->queryDual;
+ isEmergency = content->isEmergency;
+ codeTop = content->codeTop;
+ codeBottom = content->codeBottom;
+ lMinLength = content->lMinLength;
+ lMaxLength = content->lMaxLength;
+ lEmergencySupported = content->lEmergencySupported;
+
connect(content, SIGNAL(codeTopChanged(const QString &)), this, SLOT(handleCodeTopChanged(const QString &)));
+ connect(content, SIGNAL(codeBottomChanged(const QString &)), this, SLOT(handleCodeBottomChanged(const QString &)));
connect(content, SIGNAL(but1Changed()), this, SLOT(handlebut1Changed()));
connect(content, SIGNAL(but2Changed()), this, SLOT(handlebut2Changed()));
connect(content, SIGNAL(but3Changed()), this, SLOT(handlebut3Changed()));
- codeTop = content->codeTop;
- queryType = content->queryType;
qDebug() << "SecUiNotificationDialog::queryType=";
qDebug() << queryType;
// Buttons
- okAction = new HbAction(tr("Ok")); // qtTrId("txt_common_button_ok")
+ if( (queryType & ESecUiTypeMaskLock))
+ {
+ // no need to create OK or Cancel
+ return true;
+ }
+
+ okAction = new HbAction(tr("Ok"));
+ okAction->setEnabled(false); // initially the OK is disabled because codeTop is empty
+ // setAction(okAction, QDialogButtonBox::AcceptRole); // it's supposed to use this, when deprecated
setPrimaryAction(okAction);
connect(okAction, SIGNAL(triggered()), this, SLOT(handleAccepted()));
+
cancelAction = new HbAction(tr("Cancel")); // qtTrId("txt_common_button_cancel")
connect(cancelAction, SIGNAL(triggered()), this, SLOT(handleCancelled()));
+ // setAction(cancelAction, QDialogButtonBox::RejectRole); // it's supposed to use this, when deprecated
setSecondaryAction(cancelAction);
qDebug() << "SecUiNotificationDialog check Cancel";
- if (queryType & ESecUiCancelSupported)
+ if ((queryType & ESecUiCancelSupported)==ESecUiCancelSupported)
{
// nothing to do. Cancel is enabled by default
}
@@ -173,7 +357,7 @@
// SecUiNotificationDialog::sendResult()
// ----------------------------------------------------------------------------
//
-void SecUiNotificationDialog::sendResult(bool accepted)
+void SecUiNotificationDialog::sendResult(int accepted)
{
qDebug() << "SecUiNotificationDialog::sendResult 1.2";
QVariant acceptedValue(accepted);
@@ -193,15 +377,19 @@
{
qDebug() << "SecUiNotificationDialog::handleAccepted";
// okAction
- QString codeTopText = codeTop->text();
- qDebug() << "codeTopText";
- qDebug() << codeTopText;
- if(!codeTopText.compare("1234111"))
- {
- qDebug() << "codeTopText is 1234111. Not exit";
- return;
- }
- sendResult(true);
+ QString codeTopText;
+
+ if( (queryType & ESecUiTypeMaskLock))
+ {
+ codeTopText = "Unlock-Request";
+ }
+ else
+ {
+ codeTopText = codeTop->text();
+ }
+ // TODO check last time for codeBottom
+ qDebug() << "codeTopText=" << codeTopText;
+ sendResult(KErrNone);
}
// ----------------------------------------------------------------------------
@@ -211,7 +399,7 @@
void SecUiNotificationDialog::handleCancelled()
{
qDebug() << "SecUiNotificationDialog::handleCancelled";
- sendResult(false);
+ sendResult(KErrCancel);
}
// ----------------------------------------------------------------------------
@@ -235,11 +423,73 @@
void SecUiNotificationDialog::handleCodeTopChanged(const QString &text)
{
qDebug() << "SecUiNotificationDialog::handleCodeTopChanged";
- qDebug() << "SecUiNotificationDialog::handleCodeTopChanged" << text ;
+ qDebug() << "SecUiNotificationDialog::handleCodeTopChanged=" << text ;
+ if(queryDual)
+ {
+ codeBottom->setText(""); // any change resets the verification.
+ }
+ if( queryType == 0x1000004 )
+ { // ChangeSecCodeParamsL change RMobilePhone::ESecurityCodePhonePassword
+ QVariant codeTop(text);
+ mResultMap.insert(KCodeTopIndex, codeTop);
+ sendResult(KErrCompletion); // send the current password back to the client for further TARM validation
+ }
+ if(text.length() < lMinLength )
+ {
+ qDebug() << "SecUiNotificationDialog::handleCodeTopChanged too short:" << text ;
+ okAction->setEnabled(false);
+
+ if( lEmergencySupported && text.length() > 2 ) // emergency numbers need at least 3 digits
+ { // check whether it's a emergency number
+ QVariant codeTop(text);
+ mResultMap.insert(KCodeTopIndex, codeTop);
+ sendResult(KErrAbort); // send the current password back to the client. Perhaps it's an emergency number and decides to Ok->Call
+ }
+ }
+ else if (text.length() >= lMinLength)
+ {
+ // TODO might use a flag to avoid re-setting
+ qDebug() << "SecUiNotificationDialog::handleCodeTopChanged long enough:" << text ;
+ okAction->setText("Ok");
+ if(queryDual==0) // only if Bottom is not used
+ okAction->setEnabled(true);
+ }
QVariant codeTop(text);
mResultMap.insert(KCodeTopIndex, codeTop);
}
// ----------------------------------------------------------------------------
+// SecUiNotificationDialog::handleCodeBottomChanged()
+// ----------------------------------------------------------------------------
+//
+void SecUiNotificationDialog::handleCodeBottomChanged(const QString &text)
+ {
+ qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged";
+ qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged" << text ;
+ qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged. codeTop=" << codeTop->text() ;
+ // TODO compare
+ if(text.length() < lMinLength )
+ {
+ qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged too short:" << text ;
+ okAction->setEnabled(false);
+ }
+ else
+ {
+ // TODO might use a flag to avoid re-setting
+ qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged long enough:" << text ;
+ if(codeTop->text()==text)
+ {
+ qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged codes match:" << text ;
+ okAction->setEnabled(true);
+ }
+ else
+ {
+ qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged codes not match:" << text ;
+ okAction->setEnabled(false);
+ }
+ }
+ // verification is not sent
+ }
+// ----------------------------------------------------------------------------
// SecUiNotificationDialog::handlebut1Changed()
// ----------------------------------------------------------------------------
//