securitysettings/qtconfigutils/eapqtconfiginterface/src/eapqtvalidatorpassword.cpp
changeset 34 ad1f037f1ac2
parent 27 9660a5eb236f
child 49 43351a4f2da3
equal deleted inserted replaced
31:372d2d6c5cf9 34:ad1f037f1ac2
     1 /*
     1 /*
     2  * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3  * All rights reserved.
     3  * All rights reserved.
     4  * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5  * under the terms of the License "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6  * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8  *
     8  *
     9  * Initial Contributors:
     9  * Initial Contributors:
    10  * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11  *
    11  *
    12  * Contributors:
    12  * Contributors:
    13  *
    13  *
    14  * Description: 
    14  * Description: 
    15  *   EAP method validator: password
    15  *   EAP method password format validator
    16  *
    16  *
    17  */
    17  */
    18 
    18 
    19 /*
    19 /*
    20  * %version: 7 %
    20  * %version: 9 %
    21  */
    21  */
    22 
    22 
       
    23 // System includes
    23 #include <HbEditorInterface>
    24 #include <HbEditorInterface>
    24 #include <HbLineEdit>
    25 #include <HbLineEdit>
    25 
    26 
       
    27 // User includes
    26 #include "eapqtvalidatorpassword.h"
    28 #include "eapqtvalidatorpassword.h"
    27 #include "eapqtconfiginterface_p.h"
    29 #include "eapqtconfiginterface_p.h"
    28 
    30 
    29 EapQtValidatorPassword::EapQtValidatorPassword(EapQtExpandedEapType type) :
    31 /*!
       
    32  *  \class EapQtValidatorPassword
       
    33  *  \brief EAP method password format validator
       
    34  */
       
    35 
       
    36 // External function prototypes
       
    37 
       
    38 // Local constants
       
    39 
       
    40 // ======== LOCAL FUNCTIONS ========
       
    41 
       
    42 // ======== MEMBER FUNCTIONS ========
       
    43 
       
    44 EapQtValidatorPassword::EapQtValidatorPassword(const EapQtExpandedEapType& type) :
    30     mEapType(type)
    45     mEapType(type)
    31 {
    46 {
    32     qDebug("EapQtValidatorPassword::EapQtValidatorPassword()");
       
    33 }
    47 }
    34 
    48 
    35 EapQtValidatorPassword::~EapQtValidatorPassword()
    49 EapQtValidatorPassword::~EapQtValidatorPassword()
    36 {
    50 {
    37     qDebug("EapQtValidatorPassword::~EapQtValidatorPassword()");
       
    38 }
    51 }
    39 
    52 
    40 EapQtValidator::Status EapQtValidatorPassword::validate(QVariant value)
    53 EapQtValidator::Status EapQtValidatorPassword::validate(const QVariant& value)
    41 {
    54 {
       
    55     qDebug("EapQtValidatorPassword::validate()");
       
    56 
    42     Status status(StatusOk);
    57     Status status(StatusOk);
    43 
    58 
    44     switch (mEapType.type()) {
    59     switch (mEapType.type()) {
    45     case EapQtExpandedEapType::TypeEapGtc:
    60     case EapQtExpandedEapType::TypeEapGtc:
    46     case EapQtExpandedEapType::TypeEapMschapv2:
    61     case EapQtExpandedEapType::TypeEapMschapv2:
    55     }
    70     }
    56 
    71 
    57     return status;
    72     return status;
    58 }
    73 }
    59 
    74 
    60 EapQtValidator::Status EapQtValidatorPassword::validateGeneral(QVariant value)
    75 EapQtValidator::Status EapQtValidatorPassword::validateGeneral(const QVariant& value)
    61 {
    76 {
    62     Status status(StatusOk);
    77     Status status(StatusOk);
    63     QString str = value.toString();
    78     QString str = value.toString();
    64 
    79 
    65     // input must be of correct type
    80     // input must be of correct type
    66     if (value.type() != QVariant::String) {
    81     if (value.type() != QVariant::String) {
    67         status = StatusInvalid;
    82         status = StatusInvalid;
    68     }
    83     }
    69     // zero length password is not ok
    84     // zero length password is not ok
    70     else if (str.length() == 0) {
    85     else if (str.length() <= 0) {
    71         status = StatusTooShort;
    86         status = StatusTooShort;
    72     }
    87     }
    73     // check maximum length
    88     // check maximum length
    74     else if (str.length() > EapQtConfigInterfacePrivate::StringMaxLength) {
    89     else if (str.length() > EapQtConfigInterfacePrivate::StringMaxLength) {
    75         status = StatusTooLong;
    90         status = StatusTooLong;
    79     qDebug("EapQtValidatorPassword::validateGeneral - return status: %d", status);
    94     qDebug("EapQtValidatorPassword::validateGeneral - return status: %d", status);
    80 
    95 
    81     return status;
    96     return status;
    82 }
    97 }
    83 
    98 
    84 void EapQtValidatorPassword::updateEditor(HbLineEdit *edit)
    99 void EapQtValidatorPassword::updateEditor(HbLineEdit* const edit)
    85 {
   100 {
       
   101     qDebug("EapQtValidatorPassword::updateEditor()");
       
   102 
    86     Q_ASSERT(edit);
   103     Q_ASSERT(edit);
    87     if(edit == NULL) {
   104     if(edit == NULL) {
    88         return;
   105         return;
    89     }
   106     }
    90 
   107 
   100         // nothing for methods that do not have a password
   117         // nothing for methods that do not have a password
   101         break;
   118         break;
   102     }
   119     }
   103 }
   120 }
   104 
   121 
   105 void EapQtValidatorPassword::updateEditorGeneral(HbLineEdit *edit)
   122 void EapQtValidatorPassword::updateEditorGeneral(HbLineEdit* const edit)
   106 {
   123 {
   107     qDebug("EapQtValidatorPassword::updateEditorGeneral()");
   124     qDebug("EapQtValidatorPassword::updateEditorGeneral()");
   108 
   125 
   109     Q_ASSERT(edit);
   126     Q_ASSERT(edit);
   110 
   127