securitysettings/qtconfigutils/eapqtconfiginterface/src/eapqtvalidatorpacstorepassword.cpp
changeset 49 43351a4f2da3
parent 34 ad1f037f1ac2
equal deleted inserted replaced
47:712b4ffd76bb 49:43351a4f2da3
    15  *   EAP-FAST PAC store password format validator
    15  *   EAP-FAST PAC store password format validator
    16  *
    16  *
    17  */
    17  */
    18 
    18 
    19 /*
    19 /*
    20  * %version: 6 %
    20  * %version: 8 %
    21  */
    21  */
    22 
    22 
    23 // System includes
    23 // System includes
    24 #include <HbEditorInterface>
    24 #include <HbEditorInterface>
    25 #include <HbLineEdit>
    25 #include <HbLineEdit>
    34  */
    34  */
    35 
    35 
    36 // External function prototypes
    36 // External function prototypes
    37 
    37 
    38 // Local constants
    38 // Local constants
       
    39 static const unsigned int MinPacStorePasswordSize = 6;
    39 
    40 
    40 // ======== LOCAL FUNCTIONS ========
    41 // ======== LOCAL FUNCTIONS ========
    41 
    42 
    42 // ======== MEMBER FUNCTIONS ========
    43 // ======== MEMBER FUNCTIONS ========
    43 
    44 
    49 EapQtValidatorPacStorePassword::~EapQtValidatorPacStorePassword()
    50 EapQtValidatorPacStorePassword::~EapQtValidatorPacStorePassword()
    50 {
    51 {
    51     // nothing to do
    52     // nothing to do
    52 }
    53 }
    53 
    54 
    54 EapQtValidator::Status EapQtValidatorPacStorePassword::validate(const QVariant& /* value */)
    55 EapQtValidator::Status EapQtValidatorPacStorePassword::validate(const QVariant& value)
    55 {
    56 {
    56     qDebug("EapQtValidatorPacStorePassword::validate()");
    57     Status status(StatusOk);
    57     // not supported
    58     const QString str = value.toString();
    58     return EapQtValidator::StatusInvalidCharacters;
    59 
       
    60     // input must be of correct type
       
    61     if (value.type() != QVariant::String) {
       
    62         status = StatusInvalid;
       
    63     }
       
    64     // check minimum length
       
    65     else if (str.length() < MinPacStorePasswordSize) {
       
    66         status = StatusTooShort;
       
    67     }
       
    68     // check maximum length
       
    69     else if (str.length() > EapQtConfigInterfacePrivate::PacPasswordMaxLength) {
       
    70         status = StatusTooLong;
       
    71     }
       
    72 
       
    73     // any character is ok for passwords
       
    74     qDebug("EapQtValidatorPacStorePassword::validate - return status: %d", status);
       
    75 
       
    76     return status;
    59 }
    77 }
    60 
    78 
    61 void EapQtValidatorPacStorePassword::updateEditor(HbLineEdit* const edit)
    79 void EapQtValidatorPacStorePassword::updateEditor(HbLineEdit* const edit)
    62 {
    80 {
    63     qDebug("EapQtValidatorPacStorePassword::updateEditor()");
    81     qDebug("EapQtValidatorPacStorePassword::updateEditor()");
    64 
    82 
    65     Q_ASSERT(edit);
    83     Q_ASSERT(edit);
    66 
    84 
    67     edit->setMaxLength(EapQtConfigInterfacePrivate::StringMaxLength);
    85     edit->setMaxLength(EapQtConfigInterfacePrivate::PacPasswordMaxLength);
    68     edit->setInputMethodHints(Qt::ImhNoAutoUppercase | Qt::ImhPreferLowercase
    86     edit->setInputMethodHints(Qt::ImhNoAutoUppercase | Qt::ImhPreferLowercase
    69         | Qt::ImhNoPredictiveText);
    87         | Qt::ImhNoPredictiveText);
    70 
    88 
    71     // do not set editor class or auto completing since they might leak the pwd
    89     // do not set editor class or auto completing since they might leak the pwd
    72     HbEditorInterface editInterface(edit);
    90     HbEditorInterface editInterface(edit);