securitysettings/qtconfigutils/eapqtconfiginterface/src/eapqtvalidatorpacstorepasswordconfirm.cpp
--- a/securitysettings/qtconfigutils/eapqtconfiginterface/src/eapqtvalidatorpacstorepasswordconfirm.cpp Fri Sep 03 09:22:44 2010 +0300
+++ b/securitysettings/qtconfigutils/eapqtconfiginterface/src/eapqtvalidatorpacstorepasswordconfirm.cpp Thu Sep 16 13:07:04 2010 +0300
@@ -17,16 +17,18 @@
*/
/*
- * %version: 5 %
+ * %version: 7 %
*/
// System includes
#include <HbEditorInterface>
#include <HbLineEdit>
+#include <QDebug>
// User includes
#include "eapqtvalidatorpacstorepasswordconfirm.h"
#include "eapqtconfiginterface_p.h"
+#include "EapFastPacStore.h"
/*!
* \class EapQtValidatorPacStorePasswordConfirm
@@ -42,21 +44,74 @@
// ======== MEMBER FUNCTIONS ========
-EapQtValidatorPacStorePasswordConfirm::EapQtValidatorPacStorePasswordConfirm()
+EapQtValidatorPacStorePasswordConfirm::EapQtValidatorPacStorePasswordConfirm() :
+ mPacStoreIf(NULL)
{
- // nothing to do
+ qDebug("EapQtValidatorPacStorePasswordConfirm() - starts");
+
+ // try to create PAC store instance,
+ // this will throw if EAP-FAST is not supported
+ CEapFastPacStore* tmpPacStoreIf = NULL;
+ QT_TRAP_THROWING(tmpPacStoreIf = CEapFastPacStore::NewL());
+
+ Q_ASSERT(tmpPacStoreIf);
+
+ // move the result to scoped member pointer
+ mPacStoreIf.reset(tmpPacStoreIf);
+
+ qDebug("EapQtValidatorPacStorePasswordConfirm() - ends");
}
EapQtValidatorPacStorePasswordConfirm::~EapQtValidatorPacStorePasswordConfirm()
{
- // nothing to do
+ qDebug("~EapQtValidatorPacStorePasswordConfirm()");
+ // mPacStoreIf deleted automatically
}
-EapQtValidator::Status EapQtValidatorPacStorePasswordConfirm::validate(const QVariant& /* value */)
+EapQtValidator::Status EapQtValidatorPacStorePasswordConfirm::validate(const QVariant& value)
{
qDebug("EapQtValidatorPacStorePasswordConfirm::validate()");
- // not supported
- return EapQtValidator::StatusInvalid;
+
+ Status status(StatusOk);
+ const QString str = value.toString();
+
+ // input must be of correct type
+ if (value.type() != QVariant::String) {
+ status = StatusInvalid;
+ }
+ else if (str.length() > EapQtConfigInterfacePrivate::PacPasswordMaxLength) {
+ status = StatusTooLong;
+ }
+ else {
+ TBool match(EFalse);
+ // TBufC8 must be twice as long as QString
+ TBufC8<EapQtConfigInterfacePrivate::StringMaxLength> tmpPassword;
+ QByteArray tmp = str.toUtf8();
+
+ // Convert to suitable format
+ tmpPassword.Des().Copy(reinterpret_cast<const TUint8*> (tmp.data()), tmp.count());
+
+ // check if given password can be used to open the PAC store,
+ // this will fail in all other cases except if PAC store exists
+ // and the password can open it
+ TRAPD(err, match = mPacStoreIf->IsMasterKeyAndPasswordMatchingL(tmpPassword));
+
+ qDebug() << "EapQtValidatorPacStorePasswordConfirm::validate() -"
+ << "IsMasterKeyAndPasswordMatchingL trap returned:" << err;
+
+ if (err == KErrNone && match != EFalse) {
+ qDebug() << "EapQtValidatorPacStorePasswordConfirm::validate() - password matches";
+ status = StatusOk;
+ }
+ else {
+ qDebug()
+ << "EapQtValidatorPacStorePasswordConfirm::validate() - password does not match";
+ status = StatusInvalid;
+ }
+ }
+
+ qDebug("EapQtValidatorPacStorePasswordConfirm::validate - return status: %d", status);
+ return status;
}
void EapQtValidatorPacStorePasswordConfirm::updateEditor(HbLineEdit* const edit)
@@ -65,7 +120,7 @@
Q_ASSERT(edit);
- edit->setMaxLength(EapQtConfigInterfacePrivate::StringMaxLength);
+ edit->setMaxLength(EapQtConfigInterfacePrivate::PacPasswordMaxLength);
edit->setInputMethodHints(Qt::ImhNoAutoUppercase | Qt::ImhPreferLowercase
| Qt::ImhNoPredictiveText);