diff -r aad866c37519 -r cc1cea6aabaf securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationdialog.cpp --- a/securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationdialog.cpp Fri Jun 11 14:28:40 2010 +0300 +++ b/securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationdialog.cpp Thu Jun 24 12:46:20 2010 +0300 @@ -15,6 +15,7 @@ * */ +#include "secuinotificationdebug.h" #include "secuinotificationdialog.h" #include "secuinotificationdialogpluginkeys.h" #include "secuinotificationcontentwidget.h" @@ -27,12 +28,17 @@ #include // for TARM error codes while validating new lock code #include #include +#include #include QTM_USE_NAMESPACE #include #include +#define ESecUiBasicTypeText 0x0000000 +#define ESecUiBasicTypeCheck 0x0010000 +#define ESecUiBasicTypeCheckMulti 0x0020000 +#define ESecUiBasicTypeMask 0x00F0000 #define ESecUiCancelSupported 0x1000000 #define ESecUiCancelNotSupported 0x0000000 @@ -59,6 +65,15 @@ const TUid KPSUidSecurityUIs = { 0x100059b5 }; const TUint32 KSecurityUIsDismissDialog = 0x00000309; +enum TSecurityUIsDismissDialogValues + { + ESecurityUIsDismissDialogUninitialized = 0, + ESecurityUIsDismissDialogOn, + ESecurityUIsDismissDialogProcessing, + ESecurityUIsDismissDialogDone, + ESecurityUIsDismissDialogLastValue + }; + // ---------------------------------------------------------------------------- // SecUiNotificationDialog::SecUiNotificationDialog() // ---------------------------------------------------------------------------- @@ -66,7 +81,10 @@ SecUiNotificationDialog::SecUiNotificationDialog( const QVariantMap ¶meters) : HbDialog(), mLastError(KNoError) { - qDebug() << "SecUiNotificationDialog::SecUiNotificationDialog"; + RDEBUG("0", 0); + TTime myTime; + myTime.HomeTime(); + mMyId = I64LOW( myTime.Int64() ); constructDialog(parameters); } @@ -76,6 +94,7 @@ // SecUiNotificationDialog::~SecUiNotificationDialog() { + RDEBUG("0", 0); } // ---------------------------------------------------------------------------- @@ -84,7 +103,7 @@ // bool SecUiNotificationDialog::setDeviceDialogParameters(const QVariantMap ¶meters) { - qDebug() << "SecUiNotificationDialog::setDeviceDialogParameters"; + RDEBUG("0", 0); return constructDialog(parameters); } @@ -94,8 +113,8 @@ // int SecUiNotificationDialog::deviceDialogError() const { - qDebug() << "SecUiNotificationDialog::deviceDialogError"; - qDebug() << mLastError; + RDEBUG("mLastError", mLastError); + RDEBUG("mMyId", mMyId); return mLastError; } @@ -106,15 +125,31 @@ void SecUiNotificationDialog::closeDeviceDialog(bool byClient) { Q_UNUSED(byClient); - qDebug() << "SecUiNotificationDialog::closeDeviceDialog 0"; + RDEBUG("mMyId", mMyId); + RDEBUG("calling close()", 0); close(); - qDebug() << "SecUiNotificationDialog::closeDeviceDialog 1"; + RDEBUG("mShowEventReceived", mShowEventReceived); // If show event has been received, close is signalled from hide event. // If not, hide event does not come and close is signalled from here. if (!mShowEventReceived) { + RDEBUG("emitting deviceDialogClosed", 0); emit deviceDialogClosed(); + if(1==0 && subscriberKSecurityUIsDismissDialog) + { + RDEBUG("disconnect subscriberKSecurityUIsDismissDialog", 0); + disconnect(subscriberKSecurityUIsDismissDialog, SIGNAL(contentsChanged()), this, SLOT(subscriberKSecurityUIsDismissDialogChanged())); + RDEBUG("disconnected subscriberKSecurityUIsDismissDialog", 1); + if(1==1) + { + RDEBUG("deleting subscriberKSecurityUIsDismissDialog", 0); + delete subscriberKSecurityUIsDismissDialog; + subscriberKSecurityUIsDismissDialog = NULL; + RDEBUG("deleted subscriberKSecurityUIsDismissDialog", 1); + } + } } + RDEBUG("0", 0); } // ---------------------------------------------------------------------------- @@ -132,9 +167,29 @@ // void SecUiNotificationDialog::hideEvent(QHideEvent *event) { - qDebug() << "SecUiNotificationDialog::hideEvent"; + RDEBUG("0", 0); HbDialog::hideEvent(event); - emit deviceDialogClosed(); + RDEBUG("mMyId", mMyId); + RDEBUG("calling close()", 0); + close(); + RDEBUG("emitting deviceDialogClosed", 0); + emit deviceDialogClosed(); + RDEBUG("deviceDialogClosed", 1); + if(1==0 && subscriberKSecurityUIsDismissDialog) + { + RDEBUG("disconnect subscriberKSecurityUIsDismissDialog", 0); + disconnect(subscriberKSecurityUIsDismissDialog, SIGNAL(contentsChanged()), this, SLOT(subscriberKSecurityUIsDismissDialogChanged())); + RDEBUG("disconnected subscriberKSecurityUIsDismissDialog", 1); + if(1==1) + { + RDEBUG("deleting subscriberKSecurityUIsDismissDialog", 0); + delete subscriberKSecurityUIsDismissDialog; + subscriberKSecurityUIsDismissDialog = NULL; + RDEBUG("deleted subscriberKSecurityUIsDismissDialog", 1); + } + } + // old method was emit deviceDialogClosed(); + RDEBUG("0", 0); } // ---------------------------------------------------------------------------- @@ -143,23 +198,32 @@ // void SecUiNotificationDialog::showEvent(QShowEvent *event) { - qDebug() << "SecUiNotificationDialog::showEvent"; + RDEBUG("0", 0); + RDEBUG("mMyId", mMyId); HbDialog::showEvent(event); if(!(queryType & ESecUiTypeMaskLock)) { // not for the "lock icon" - qDebug() << "SecUiNotificationDialog::showEvent check default"; - if(codeTop->text().length()>0) // there's a default value. Verify it and (might) enable OK - { - qDebug() << "SecUiNotificationDialog::showEvent checked default"; - handleCodeTopChanged(codeTop->text()); - } - // for automated testing, read a P&S and use this value as if the user typed it + RDEBUG("check default.1", 0); + if(codeTop!=NULL) + { + RDEBUG("check default.2", 0); + if(codeTop->text().length()>0) // there's a default value. Verify it and (might) enable OK + { + RDEBUG("check default.3", 0); + handleCodeTopChanged(codeTop->text()); + } + RDEBUG("setFocus", 0); + codeTop->setFocus(); // this should open the VKB . Doesn't seem to work when it's done on the widget, so it's done here. + + } // codeTop!=NULL + const TUint32 KSecurityUIsTestCode = 0x00000307; TInt value = 0; TInt err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsTestCode, value ); - qDebug() << "SecUiNotificationDialog::faking KSecurityUIsTestCode err=" << err; - qDebug() << "SecUiNotificationDialog::faking value=" << value; + RDEBUG("KSecurityUIsTestCode err", err); + RDEBUG("faking value", value); + RDEBUG("mShowEventReceived", mShowEventReceived); if(value>0 && mShowEventReceived==true) // show happens 2 times. Dialog can be closed only the second. { QString myString = ""; @@ -169,10 +233,11 @@ TInt err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsTestCode, 0 ); // clear after using it qDebug() << "SecUiNotificationDialog::calling handleAccepted=" << myString; emit handleAccepted(); - emit closeDeviceDialog(false); // false means "not by client", although it's not really used + // handleAccepted already emit closeDeviceDialog(false); // false means "not by client", although it's not really used } } mShowEventReceived = true; + RDEBUG("1", 1); } // ---------------------------------------------------------------------------- @@ -181,13 +246,31 @@ // bool SecUiNotificationDialog::constructDialog(const QVariantMap ¶meters) { - qDebug() << "SecUiNotificationDialog::constructDialog"; + RDEBUG("0", 0); + RDEBUG("mMyId", mMyId); setTimeout(HbPopup::NoTimeout); setDismissPolicy(HbPopup::NoDismiss); setModal(true); mShowEventReceived = false; + subscriberKSecurityUIsDismissDialog = NULL; + titleWidget = NULL; + RDEBUG("subscriberKSecurityUIsDismissDialog NULL", 0); + + subscriberKSecurityUIsDismissDialog = new QValueSpaceSubscriber("/KPSUidSecurityUIs/KSecurityUIsDismissDialog", this); + if(subscriberKSecurityUIsDismissDialog) + { + RDEBUG("subscriberKSecurityUIsDismissDialog created", 1); + } + else + { + RDEBUG("subscriberKSecurityUIsDismissDialog not created", 0); + } + connect(subscriberKSecurityUIsDismissDialog, SIGNAL(contentsChanged()), this, SLOT(subscriberKSecurityUIsDismissDialogChanged())); + RDEBUG("subscriberKSecurityUIsDismissDialog", 1); // Title + // this is also done later in the widget + // For now, it only says "Security" if (parameters.contains(KDialogTitle)) { QString titleText = parameters.value(KDialogTitle).toString(); QString titleAttempts = ""; @@ -200,22 +283,24 @@ titleAttempts = titleText.right(titleText.length()-titleText.indexOf('#')-1); qDebug() << "SecUiNotificationDialog::titleAttempts=" << titleAttempts; int nAttempts = titleAttempts.toInt(); - qDebug() << "SecUiNotificationDialog::nAttempts=" << nAttempts; + RDEBUG("nAttempts", nAttempts); titleText = titleText.left(titleText.indexOf('#')); if(nAttempts>0) titleText = titleText + " attempts=" + QString::number(nAttempts); } - title = new HbLabel(titleText); - setHeadingWidget(title); + titleText = "Security Query"; // this is the header, for any potential later error which needs to be displayed + // This is created only if needed (i.e. errors for NewLockCode) + // titleWidget = new HbLabel(titleText); + // setHeadingWidget(titleWidget); } if (parameters.contains(KEmergency)) { - qDebug() << "SecUiNotificationDialog::KEmergency"; + RDEBUG("KEmergency", 1); QString emergencyText = parameters.value(KEmergency).toString(); qDebug() << emergencyText; if(!emergencyText.compare("emergencyYes")) { - qDebug() << "SecUiNotificationDialog::KEmergency emergencyYes"; + RDEBUG("emergencyYes", 1); isEmergency = 1; okAction->setEnabled(true); okAction->setText("Call"); @@ -223,7 +308,7 @@ } if(!emergencyText.compare("emergencyNo")) { - qDebug() << "SecUiNotificationDialog::KEmergency emergencyNo"; + RDEBUG("emergencyNo", 1); isEmergency = 0; okAction->setEnabled(false); // 112 -> 1122 (=password) . This is handled by < lMinLength okAction->setText("Ok"); @@ -232,112 +317,121 @@ } // after TARM validation. if (parameters.contains(KInvalidNewLockCode)) { - qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode"; + RDEBUG("KInvalidNewLockCode", 0); QString invalidText = parameters.value(KInvalidNewLockCode).toString(); qDebug() << invalidText; + QString newTitleText = "Lock Code"; // TODO take from the original one - 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; + RDEBUG("invalidNumber", invalidNumber); if(invalidNumber<0) { - qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode ???"; + RDEBUG("invalidNumber<0", invalidNumber ); // nothing to do } - if(invalidNumber==EDeviceLockAutolockperiod) + if(invalidNumber==EDeviceLockAutolockperiod) { - qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockAutolockperiod"; - title->setPlainText("EDeviceLockAutolockperiod"); + RDEBUG("EDeviceLockAutolockperiod", invalidNumber ); + newTitleText+="EDeviceLockAutolockperiod"; } if(invalidNumber==EDeviceLockMaxAutolockPeriod) { - qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMaxAutolockPeriod"; - title->setPlainText("EDeviceLockMaxAutolockPeriod"); + RDEBUG("EDeviceLockAutolockperiod", invalidNumber ); + newTitleText+="EDeviceLockMaxAutolockPeriod"; } if(invalidNumber==EDeviceLockMinlength) { - qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinlength"; - title->setPlainText("EDeviceLockMinlength"); + RDEBUG("EDeviceLockMinlength", invalidNumber ); + newTitleText+="EDeviceLockMinlength"; } if(invalidNumber==EDeviceLockMaxlength) { - qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMaxlength"; - title->setPlainText("EDeviceLockMaxlength"); + RDEBUG("EDeviceLockMaxlength", invalidNumber ); + newTitleText+="EDeviceLockMaxlength"; } if(invalidNumber==EDeviceLockRequireUpperAndLower) { - qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockRequireUpperAndLower"; - title->setPlainText("EDeviceLockRequireUpperAndLower"); + RDEBUG("EDeviceLockRequireUpperAndLower", invalidNumber ); + newTitleText+="EDeviceLockRequireUpperAndLower"; } if(invalidNumber==EDeviceLockRequireCharsAndNumbers) { - qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockRequireCharsAndNumbers"; - title->setPlainText("EDeviceLockMaxlength"); + RDEBUG("EDeviceLockMaxlength", invalidNumber ); + newTitleText+="EDeviceLockMaxlength"; } if(invalidNumber==EDeviceLockAllowedMaxRepeatedChars) { - qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockAllowedMaxRepeatedChars"; - title->setPlainText("EDeviceLockAllowedMaxRepeatedChars"); + RDEBUG("EDeviceLockAllowedMaxRepeatedChars", invalidNumber ); + newTitleText+="EDeviceLockAllowedMaxRepeatedChars"; } if(invalidNumber==EDeviceLockHistoryBuffer) { - qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockHistoryBuffer"; - title->setPlainText("EDeviceLockHistoryBuffer"); + RDEBUG("EDeviceLockHistoryBuffer", invalidNumber ); + newTitleText+="EDeviceLockHistoryBuffer"; } if(invalidNumber==EDeviceLockPasscodeExpiration) { - qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockPasscodeExpiration"; - title->setPlainText("EDeviceLockPasscodeExpiration"); + RDEBUG("EDeviceLockPasscodeExpiration", invalidNumber ); + newTitleText+="EDeviceLockPasscodeExpiration"; } if(invalidNumber==EDeviceLockMinChangeTolerance) { - qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinChangeTolerance"; - title->setPlainText("EDeviceLockMinChangeTolerance"); + RDEBUG("EDeviceLockMinChangeTolerance", invalidNumber ); + newTitleText+="EDeviceLockMinChangeTolerance"; } if(invalidNumber==EDeviceLockMinChangeInterval) { - qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinChangeInterval"; - title->setPlainText("EDeviceLockMinChangeInterval"); + RDEBUG("EDeviceLockMinChangeInterval", invalidNumber ); + newTitleText+="EDeviceLockMinChangeInterval"; } if(invalidNumber==EDeviceLockDisallowSpecificStrings) { - qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockDisallowSpecificStrings"; - title->setPlainText("EDeviceLockDisallowSpecificStrings"); + RDEBUG("EDeviceLockDisallowSpecificStrings", invalidNumber ); + newTitleText+="EDeviceLockDisallowSpecificStrings"; } if(invalidNumber==EDeviceLockAllowedMaxAtempts) { - qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockAllowedMaxAtempts"; - title->setPlainText("EDeviceLockAllowedMaxAtempts"); + RDEBUG("EDeviceLockAllowedMaxAtempts", invalidNumber ); + newTitleText+="EDeviceLockAllowedMaxAtempts"; } if(invalidNumber==EDeviceLockConsecutiveNumbers) { - qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockConsecutiveNumbers"; - title->setPlainText("EDeviceLockConsecutiveNumbers"); + RDEBUG("EDeviceLockConsecutiveNumbers", invalidNumber ); + newTitleText+="EDeviceLockConsecutiveNumbers"; } if(invalidNumber==EDeviceLockMinSpecialCharacters) { - qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockMinSpecialCharacters"; - title->setPlainText("EDeviceLockMinSpecialCharacters"); + RDEBUG("EDeviceLockMinSpecialCharacters", invalidNumber ); + newTitleText+="EDeviceLockMinSpecialCharacters"; } if(invalidNumber==EDeviceLockSingleCharRepeatNotAllowed) { - qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockSingleCharRepeatNotAllowed"; - title->setPlainText("EDeviceLockSingleCharRepeatNotAllowed"); + RDEBUG("EDeviceLockSingleCharRepeatNotAllowed", invalidNumber ); + newTitleText+="EDeviceLockSingleCharRepeatNotAllowed"; } if(invalidNumber==EDevicelockConsecutiveCharsNotAllowed) { - qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDevicelockConsecutiveCharsNotAllowed"; - title->setPlainText("EDevicelockConsecutiveCharsNotAllowed"); + RDEBUG("EDevicelockConsecutiveCharsNotAllowed", invalidNumber ); + newTitleText+="EDevicelockConsecutiveCharsNotAllowed"; } if(invalidNumber>=EDevicelockTotalPolicies) { - qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDevicelockTotalPolicies"; - title->setPlainText("EDevicelockTotalPolicies"); + RDEBUG("EDevicelockTotalPolicies", invalidNumber ); + newTitleText+="EDevicelockTotalPolicies"; } + if( !titleWidget ) + { + RDEBUG("creating titleWidget", 0 ); + titleWidget = new HbLabel("New lock code"); // it will be changed later + setHeadingWidget(titleWidget); + } + RDEBUG("setPlainText", 0 ); + titleWidget->setPlainText(newTitleText); + if(invalidNumber<0) // everything is ok { - okAction->setEnabled(true); // TODO check this : invalid -> valid. This allows verif ? + okAction->setEnabled(true); // this might fail in the scenario: check this : invalid -> valid. This allows verif ? okAction->setText("Ok"); codeBottom->setEnabled(true); } @@ -360,7 +454,10 @@ queryType = content->queryType; queryDual = content->queryDual; isEmergency = content->isEmergency; + codeTop=NULL; codeTop = content->codeTop; + checkBox = content->checkbox; + listWidget = content->listWidget; codeBottom = content->codeBottom; lMinLength = content->lMinLength; lMaxLength = content->lMaxLength; @@ -372,8 +469,7 @@ connect(content, SIGNAL(but1Changed()), this, SLOT(handlebut1Changed())); connect(content, SIGNAL(but2Changed()), this, SLOT(handlebut2Changed())); connect(content, SIGNAL(but3Changed()), this, SLOT(handlebut3Changed())); - qDebug() << "SecUiNotificationDialog::queryType="; - qDebug() << queryType; + RDEBUG("queryType", queryType); // Buttons if( (queryType & ESecUiTypeMaskLock)) { @@ -382,36 +478,54 @@ } okAction = new HbAction(tr("Ok")); + RDEBUG("created HbAction okAction", 1); okAction->setEnabled(false); // initially the OK is disabled because codeTop is empty + if((queryType & ESecUiBasicTypeMask) ==ESecUiBasicTypeCheck) { + okAction->setEnabled(true); + setHeadingWidget(0); // had to remove this no multiline + } + else if ((queryType & ESecUiBasicTypeMask) ==ESecUiBasicTypeCheckMulti){ + okAction->setEnabled(true); + } + // setAction(okAction, QDialogButtonBox::AcceptRole); // it's supposed to use this, when deprecated - setPrimaryAction(okAction); + // setPrimaryAction(okAction); + addAction(okAction); + disconnect(okAction, SIGNAL(triggered()), this, SLOT(close())); // the close will be done in handleAccepted connect(okAction, SIGNAL(triggered()), this, SLOT(handleAccepted())); cancelAction = new HbAction(tr("Cancel")); // qtTrId("txt_common_button_cancel") + addAction(cancelAction); + disconnect(cancelAction, SIGNAL(triggered()), this, SLOT(close())); // the close will be done in handleCancelled connect(cancelAction, SIGNAL(triggered()), this, SLOT(handleCancelled())); // setAction(cancelAction, QDialogButtonBox::RejectRole); // it's supposed to use this, when deprecated - setSecondaryAction(cancelAction); + // setSecondaryAction(cancelAction); // this should had been set by Autolock, but just to be sure TInt ret = RProperty::Define(KPSUidSecurityUIs, KSecurityUIsDismissDialog, RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass), TSecurityPolicy(TSecurityPolicy::EAlwaysPass)); RDEBUG("defined KSecurityUIsDismissDialog", ret); - subscriberKSecurityUIsDismissDialog = new QValueSpaceSubscriber( - "/KPSUidSecurityUIs/KSecurityUIsDismissDialog", this); - connect(subscriberKSecurityUIsDismissDialog, SIGNAL(contentsChanged()), this, - SLOT(subscriberKSecurityUIsDismissDialogChanged())); - qDebug() << "subscribed to KSecurityUIsDismissDialog"; + TInt aDismissDialog = -1; + ret = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsDismissDialog, aDismissDialog ); + RDEBUG("ret", ret); + RDEBUG("aDismissDialog", aDismissDialog); + if(aDismissDialog==ESecurityUIsDismissDialogOn || aDismissDialog==ESecurityUIsDismissDialogProcessing) + { + RDebug::Printf( "potential error: %s %s (%u) aDismissDialog=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aDismissDialog ); + } - qDebug() << "SecUiNotificationDialog check Cancel"; + RDEBUG("check cancel", 0); if ((queryType & ESecUiCancelSupported)==ESecUiCancelSupported) { // nothing to do. Cancel is enabled by default } else { - qDebug() << "disable Cancel"; + RDEBUG("disable Cancel", 1); cancelAction->setEnabled(false); + cancelAction->setText(""); + cancelAction->setVisible(false); } return true; @@ -423,14 +537,20 @@ // void SecUiNotificationDialog::sendResult(int accepted) { - qDebug() << "SecUiNotificationDialog::sendResult 1.2"; + RDEBUG("0", 0); + RDEBUG("mMyId", mMyId); QVariant acceptedValue(accepted); - qDebug() << "SecUiNotificationDialog::sendResult 2"; + RDEBUG("0", 0); mResultMap.insert(KResultAccepted, acceptedValue); - qDebug() << "SecUiNotificationDialog::sendResult 3"; + RDEBUG("0", 0); qDebug() << mResultMap; - emit deviceDialogData(mResultMap); - qDebug() << "SecUiNotificationDialog::sendResult end"; + RDEBUG("queryType", queryType); + if(!(queryType & ESecUiTypeMaskLock)) + { // the lock-icon should not reply + RDEBUG("emit deviceDialogData", 0); + emit deviceDialogData(mResultMap); + } + RDEBUG("1", 1); } // ---------------------------------------------------------------------------- @@ -439,21 +559,42 @@ // void SecUiNotificationDialog::handleAccepted() { - qDebug() << "SecUiNotificationDialog::handleAccepted"; + RDEBUG("0", 0); // okAction - QString codeTopText; + RDEBUG("mMyId", mMyId); + QString codeTopText=""; if( (queryType & ESecUiTypeMaskLock)) { codeTopText = "Unlock-Request"; } - else + else if( (queryType & ESecUiBasicTypeMask)==ESecUiBasicTypeCheck) + { + codeTopText=(checkBox->isChecked() ? "1":"0"); + mResultMap.insert(KCodeTopIndex, codeTopText); + } + else if( (queryType & ESecUiBasicTypeMask)==ESecUiBasicTypeCheckMulti) { - codeTopText = codeTop->text(); + QItemSelectionModel *selectionModel = listWidget->selectionModel(); + QModelIndexList selectedItems = selectionModel->selectedIndexes(); + QModelIndex index; + codeTopText=""; + foreach(index, selectedItems) { + codeTopText+=QString::number(index.row()); + //could also use if(index.row()!=selectedItems.count()-1) codeTopText+= "|"; + codeTopText+= "|"; + } + mResultMap.insert(KCodeTopIndex, codeTopText); } - // TODO check last time for codeBottom + else + codeTopText = codeTop->text(); + // no need to check last time for codeBottom qDebug() << "codeTopText=" << codeTopText; sendResult(KErrNone); + RDEBUG("calling close()", 0); + close(); // this is needed because Cancel doesn't automatically closes the dialog + RDEBUG("emitting deviceDialogClosed", 0); + emit deviceDialogClosed(); } // ---------------------------------------------------------------------------- @@ -462,8 +603,13 @@ // void SecUiNotificationDialog::handleCancelled() { - qDebug() << "SecUiNotificationDialog::handleCancelled"; + RDEBUG("0", 0); + RDEBUG("mMyId", mMyId); sendResult(KErrCancel); + RDEBUG("callingclose()", 0); + close(); // this is needed because Cancel doesn't automatically closes the dialog + RDEBUG("emitting deviceDialogClosed", 0); + emit deviceDialogClosed(); } // ---------------------------------------------------------------------------- @@ -472,17 +618,17 @@ // void SecUiNotificationDialog::handleMemorySelectionChanged(const QString &text) { - qDebug() << "SecUiNotificationDialog::handleMemorySelectionChanged"; - qDebug() << text; + RDEBUG("0", 0); + RDEBUG("mMyId", mMyId); + qDebug() << text; QVariant memorySelection(text); mResultMap.insert(KSelectedMemoryIndex, memorySelection); - //TODO: do we need emit here, or would it be better to send all data at the end? - //emit deviceDialogData(mResultMap); } void SecUiNotificationDialog::handleCodeTopContentChanged() { - qDebug() << "SecUiNotificationDialog::handleCodeTopContentChanged"; + RDEBUG("0", 0); + RDEBUG("mMyId", mMyId); qDebug() << codeTop->text(); handleCodeTopChanged(codeTop->text()); } @@ -493,7 +639,7 @@ // void SecUiNotificationDialog::handleCodeTopChanged(const QString &text) { - qDebug() << "SecUiNotificationDialog::handleCodeTopChanged"; + RDEBUG("0", 0); qDebug() << "SecUiNotificationDialog::handleCodeTopChanged=" << text ; if(queryDual) { @@ -501,32 +647,32 @@ } if( queryType == 0x1000004 ) // new codeLock { // ChangeSecCodeParamsL change RMobilePhone::ESecurityCodePhonePassword - QVariant codeTop(text); - mResultMap.insert(KCodeTopIndex, codeTop); + QVariant codeTopVar(text); + mResultMap.insert(KCodeTopIndex, codeTopVar); 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 } if(text.length() < lMinLength ) { qDebug() << "SecUiNotificationDialog::handleCodeTopChanged too short:" << text ; okAction->setEnabled(false); - + RDEBUG("lEmergencySupported", lEmergencySupported); 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); + QVariant codeTopVar(text); + mResultMap.insert(KCodeTopIndex, codeTopVar); 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 + // might use a flag to avoid re-setting. But this complicates things if there's another initial verification 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); + QVariant codeTopVar(text); + mResultMap.insert(KCodeTopIndex, codeTopVar); } // ---------------------------------------------------------------------------- // SecUiNotificationDialog::handleCodeBottomChanged() @@ -534,10 +680,9 @@ // void SecUiNotificationDialog::handleCodeBottomChanged(const QString &text) { - qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged"; + RDEBUG("0", 0); qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged" << text ; qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged. codeTop=" << codeTop->text() ; - // TODO compare if(text.length() < lMinLength ) { qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged too short:" << text ; @@ -545,10 +690,11 @@ } else { - // TODO might use a flag to avoid re-setting + // might use a flag to avoid re-setting. But it just complicates things. qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged long enough:" << text ; if(codeTop->text()==text) { + // 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 qDebug() << "SecUiNotificationDialog::handleCodeBottomChanged codes match:" << text ; okAction->setEnabled(true); } @@ -566,8 +712,8 @@ // void SecUiNotificationDialog::handlebut1Changed() { - qDebug() << "SecUiNotificationDialog::handlebut1Changed"; - codeTop->setText("1234"); + RDEBUG("0", 0); + codeTop->setText("1234"); } // ---------------------------------------------------------------------------- // SecUiNotificationDialog::handlebut2Changed() @@ -575,7 +721,7 @@ // void SecUiNotificationDialog::handlebut2Changed() { - qDebug() << "SecUiNotificationDialog::handlebut2Changed"; + RDEBUG("0", 0); QString codeTopText = codeTop->text(); qDebug() << "codeTopText"; qDebug() << codeTopText; @@ -583,6 +729,40 @@ qDebug() << "codeTopText+1"; qDebug() << codeTopText; codeTop->setText(codeTopText); + + RDEBUG("editorInterface", 0); + HbEditorInterface editorInterface(codeTop); + RDEBUG("actions", 0); + QList vkbList = editorInterface.actions(); + RDEBUG("count", 0); + int count = vkbList.count(); + RDEBUG("got count", count); + for (int i = 0; i < count; i++) + { + RDEBUG("i", i); + HbAction *action = static_cast(vkbList[i]); + RDEBUG("action", 0); + } + + RDEBUG("okVKBAction", 0); + okVKBAction = new HbAction(tr("Ok")); + RDEBUG("addAction", 0); + editorInterface.addAction(okVKBAction); + RDEBUG("addAction", 1); + connect(okVKBAction, SIGNAL(triggered()), this, SLOT(handleAccepted())); + RDEBUG("connect", 1); + + QList vkbList2 = editorInterface.actions(); + RDEBUG("count", 0); + int count2 = vkbList2.count(); + RDEBUG("got count2", count2); + for (int i = 0; i < count2; i++) + { + RDEBUG("i", i); + HbAction *action2 = static_cast(vkbList2[i]); + RDEBUG("action2", 0); + } + } // ---------------------------------------------------------------------------- // SecUiNotificationDialog::handlebut3Changed() @@ -613,35 +793,71 @@ // ---------------------------------------------------------------------------- // SecUiNotificationDialog::subscriberKSecurityUIsDismissDialogChanged() // A way for Autolock to dismiss any possible PIN dialog +// This doesn't dismiss the lockIcon because P&S is not connected +// Note: if this changes itself, then it becomes recursive // ---------------------------------------------------------------------------- // void SecUiNotificationDialog::subscriberKSecurityUIsDismissDialogChanged() { -enum TSecurityUIsDismissDialogValues - { - ESecurityUIsDismissDialogUninitialized = 0, - ESecurityUIsDismissDialogOn, - ESecurityUIsDismissDialogProcessing, - ESecurityUIsDismissDialogDone, - ESecurityUIsDismissDialogLastValue - }; RDEBUG("0", 0); + RDEBUG("mMyId", mMyId); TInt aDismissDialog = ESecurityUIsDismissDialogUninitialized; TInt err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsDismissDialog, aDismissDialog ); RDEBUG("err", err); - RDEBUG("aDismissDialog", aDismissDialog); + RDEBUG("aDismissDialog", aDismissDialog); if( aDismissDialog == ESecurityUIsDismissDialogOn ) { - err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogProcessing ); - RDEBUG("err", err); - // TODO perhaps do this only if Cancel is allowed? - RDEBUG("sendResult(KErrDied)", 0); - sendResult(KErrDied); // similar to emit handleCancelled(); - RDEBUG("emit closeDeviceDialog", 0); - emit closeDeviceDialog(false); // false means "not by client", although it's not really used - RDEBUG("all emited", 0); - err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogDone ); // clear after using it - RDEBUG("err", err); + if(subscriberKSecurityUIsDismissDialog) + { + RDEBUG("subscriberKSecurityUIsDismissDialog", 1); + } + else + { + RDEBUG("! subscriberKSecurityUIsDismissDialog", 0); + } + + if(this) + { + RDEBUG("this", 1); + } + else + { + RDEBUG("! this", 0); + } + + + RDEBUG("disconnect subscriberKSecurityUIsDismissDialog", 0); + disconnect(subscriberKSecurityUIsDismissDialog, SIGNAL(contentsChanged()), this, SLOT(subscriberKSecurityUIsDismissDialogChanged())); + // this doesn't really disconnect, because somehow the events are still queued. This is a QtMobility error + RDEBUG("disconnected subscriberKSecurityUIsDismissDialog", 1); + + RDEBUG("not set KSecurityUIsDismissDialog", ESecurityUIsDismissDialogProcessing); + // can't set it because it does recursion + // err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogProcessing ); + RDEBUG("err", err); + // only if Cancel is allowed + if ((queryType & ESecUiCancelSupported)==ESecUiCancelSupported) + { + RDEBUG("sendResult(KErrCancel)", KErrCancel); // another option is KErrDied + sendResult(KErrCancel); // similar to emit handleCancelled(); + RDEBUG("calling close()", 0); + err = close(); + RDEBUG("err", err); + RDEBUG("emitting deviceDialogClosed", 0); + emit deviceDialogClosed(); + // RDEBUG("emit closeDeviceDialog", 0); + // this is old method emit closeDeviceDialog(false); // false means "not by client", although it's not really used + RDEBUG("all emited", 0); + } + RDEBUG("not set KSecurityUIsDismissDialog", ESecurityUIsDismissDialogDone); + // can't set it because it does recursion + // err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogDone ); // clear after using it + RDEBUG("err", err); + + RDEBUG("reconnect subscriberKSecurityUIsDismissDialog", 0); + connect(subscriberKSecurityUIsDismissDialog, SIGNAL(contentsChanged()), this, SLOT(subscriberKSecurityUIsDismissDialogChanged())); + RDEBUG("reconnected subscriberKSecurityUIsDismissDialog", 1); } - } \ No newline at end of file + RDEBUG("1", 1); + }