26
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
* EAP method validator: password
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
/*
|
|
20 |
* %version: 6 %
|
|
21 |
*/
|
|
22 |
|
|
23 |
#include <HbEditorInterface>
|
|
24 |
#include <HbLineEdit>
|
|
25 |
|
|
26 |
#include "eapqtvalidatorpassword.h"
|
|
27 |
#include "eapqtconfiginterface_p.h"
|
|
28 |
|
|
29 |
EapQtValidatorPassword::EapQtValidatorPassword(EapQtExpandedEapType type) :
|
|
30 |
mEapType(type)
|
|
31 |
{
|
|
32 |
qDebug("EapQtValidatorPassword::EapQtValidatorPassword()");
|
|
33 |
}
|
|
34 |
|
|
35 |
EapQtValidatorPassword::~EapQtValidatorPassword()
|
|
36 |
{
|
|
37 |
qDebug("EapQtValidatorPassword::~EapQtValidatorPassword()");
|
|
38 |
}
|
|
39 |
|
|
40 |
EapQtValidator::Status EapQtValidatorPassword::validate(QVariant value)
|
|
41 |
{
|
|
42 |
Status status(StatusOk);
|
|
43 |
|
|
44 |
switch (mEapType.type()) {
|
|
45 |
case EapQtExpandedEapType::TypeEapGtc:
|
|
46 |
case EapQtExpandedEapType::TypeEapMschapv2:
|
|
47 |
case EapQtExpandedEapType::TypeLeap:
|
|
48 |
case EapQtExpandedEapType::TypePap:
|
|
49 |
case EapQtExpandedEapType::TypePlainMschapv2:
|
|
50 |
status = validateGeneral(value);
|
|
51 |
break;
|
|
52 |
default:
|
|
53 |
// for methods that do not have a password
|
|
54 |
status = StatusInvalid;
|
|
55 |
}
|
|
56 |
|
|
57 |
return status;
|
|
58 |
}
|
|
59 |
|
|
60 |
EapQtValidator::Status EapQtValidatorPassword::validateGeneral(QVariant value)
|
|
61 |
{
|
|
62 |
Status status(StatusOk);
|
|
63 |
QString str = value.toString();
|
|
64 |
|
|
65 |
// input must be of correct type
|
|
66 |
if (value.type() != QVariant::String) {
|
|
67 |
status = StatusInvalid;
|
|
68 |
}
|
|
69 |
// zero length password is not ok
|
|
70 |
else if (str.length() == 0) {
|
|
71 |
status = StatusTooShort;
|
|
72 |
}
|
|
73 |
// check maximum length
|
|
74 |
else if (str.length() > EapQtConfigInterfacePrivate::StringMaxLength) {
|
|
75 |
status = StatusTooLong;
|
|
76 |
}
|
|
77 |
|
|
78 |
// any character is ok for passwords
|
|
79 |
qDebug("EapQtValidatorPassword::validateGeneral - return status: %d", status);
|
|
80 |
|
|
81 |
return status;
|
|
82 |
}
|
|
83 |
|
|
84 |
void EapQtValidatorPassword::updateEditor(HbLineEdit *edit)
|
|
85 |
{
|
|
86 |
switch (mEapType.type()) {
|
|
87 |
case EapQtExpandedEapType::TypeEapGtc:
|
|
88 |
case EapQtExpandedEapType::TypeEapMschapv2:
|
|
89 |
case EapQtExpandedEapType::TypeLeap:
|
|
90 |
case EapQtExpandedEapType::TypePap:
|
|
91 |
case EapQtExpandedEapType::TypePlainMschapv2:
|
|
92 |
updateEditorGeneral(edit);
|
|
93 |
// falls through on purpose
|
|
94 |
default:
|
|
95 |
// nothing for methods that do not have a password
|
|
96 |
break;
|
|
97 |
}
|
|
98 |
}
|
|
99 |
|
|
100 |
void EapQtValidatorPassword::updateEditorGeneral(HbLineEdit *edit)
|
|
101 |
{
|
|
102 |
qDebug("EapQtValidatorPassword::updateEditorGeneral()");
|
|
103 |
|
|
104 |
edit->setMaxLength(EapQtConfigInterfacePrivate::StringMaxLength);
|
|
105 |
edit->setInputMethodHints(Qt::ImhNoAutoUppercase | Qt::ImhPreferLowercase
|
|
106 |
| Qt::ImhNoPredictiveText);
|
|
107 |
|
|
108 |
// do not set editor class or auto completing since they might leak the pwd
|
|
109 |
HbEditorInterface editInterface(edit);
|
|
110 |
editInterface.setSmileyTheme(HbSmileyTheme());
|
|
111 |
}
|