|
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 "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 realm format validator |
|
16 * |
|
17 */ |
|
18 |
|
19 /* |
|
20 * %version: 8 % |
|
21 */ |
|
22 |
|
23 // System includes |
|
24 #include <HbEditorInterface> |
|
25 #include <HbLineEdit> |
|
26 |
|
27 // User includes |
|
28 #include "eapqtvalidatorrealm.h" |
|
29 #include "eapqtconfiginterface_p.h" |
|
30 |
|
31 /*! |
|
32 * \class EapQtValidatorRealm |
|
33 * \brief EAP method realm format validator |
|
34 */ |
|
35 |
|
36 // External function prototypes |
|
37 |
|
38 // Local constants |
|
39 |
|
40 // ======== LOCAL FUNCTIONS ======== |
|
41 |
|
42 // ======== MEMBER FUNCTIONS ======== |
|
43 |
|
44 EapQtValidatorRealm::EapQtValidatorRealm(const EapQtExpandedEapType& type) : |
|
45 mEapType(type) |
|
46 { |
|
47 } |
|
48 |
|
49 EapQtValidatorRealm::~EapQtValidatorRealm() |
|
50 { |
|
51 } |
|
52 |
|
53 EapQtValidator::Status EapQtValidatorRealm::validate(const QVariant& value) |
|
54 { |
|
55 qDebug("EapQtValidatorRealm::validate()"); |
|
56 |
|
57 Status status(StatusOk); |
|
58 |
|
59 switch (mEapType.type()) { |
|
60 case EapQtExpandedEapType::TypeEapAka: |
|
61 case EapQtExpandedEapType::TypeEapFast: |
|
62 case EapQtExpandedEapType::TypeEapGtc: |
|
63 case EapQtExpandedEapType::TypeEapMschapv2: |
|
64 case EapQtExpandedEapType::TypeEapSim: |
|
65 case EapQtExpandedEapType::TypeEapTls: |
|
66 case EapQtExpandedEapType::TypeEapTtls: |
|
67 case EapQtExpandedEapType::TypeLeap: |
|
68 case EapQtExpandedEapType::TypePeap: |
|
69 status = validateGeneral(value); |
|
70 break; |
|
71 default: |
|
72 // for methods that do not have a realm |
|
73 status = StatusInvalid; |
|
74 } |
|
75 |
|
76 return status; |
|
77 } |
|
78 |
|
79 EapQtValidator::Status EapQtValidatorRealm::validateGeneral(const QVariant& value) |
|
80 { |
|
81 Status status(StatusOk); |
|
82 QString str = value.toString(); |
|
83 |
|
84 // input must be of correct type |
|
85 if (value.type() != QVariant::String) { |
|
86 status = StatusInvalid; |
|
87 } |
|
88 // zero length realm is ok |
|
89 else if (str.length() > EapQtConfigInterfacePrivate::StringMaxLength) { |
|
90 status = StatusTooLong; |
|
91 } |
|
92 // username and realm are separated with @, not allowed to be part of realm |
|
93 else if (str.contains(QChar('@'), Qt::CaseInsensitive)) { |
|
94 status = StatusInvalidCharacters; |
|
95 } |
|
96 |
|
97 qDebug("EapQtValidatorRealm::validateGeneral - return status: %d", status); |
|
98 |
|
99 return status; |
|
100 } |
|
101 |
|
102 void EapQtValidatorRealm::updateEditor(HbLineEdit* const edit) |
|
103 { |
|
104 qDebug("EapQtValidatorRealm::updateEditor()"); |
|
105 |
|
106 Q_ASSERT(edit); |
|
107 if(edit == NULL) { |
|
108 return; |
|
109 } |
|
110 |
|
111 switch (mEapType.type()) { |
|
112 case EapQtExpandedEapType::TypeEapAka: |
|
113 case EapQtExpandedEapType::TypeEapFast: |
|
114 case EapQtExpandedEapType::TypeEapGtc: |
|
115 case EapQtExpandedEapType::TypeEapMschapv2: |
|
116 case EapQtExpandedEapType::TypeEapSim: |
|
117 case EapQtExpandedEapType::TypeEapTls: |
|
118 case EapQtExpandedEapType::TypeEapTtls: |
|
119 case EapQtExpandedEapType::TypeLeap: |
|
120 case EapQtExpandedEapType::TypePeap: |
|
121 updateEditorGeneral(edit); |
|
122 // falls through on purpose |
|
123 default: |
|
124 // no realm for other types |
|
125 break; |
|
126 } |
|
127 } |
|
128 |
|
129 void EapQtValidatorRealm::updateEditorGeneral(HbLineEdit* const edit) |
|
130 { |
|
131 qDebug("EapQtValidatorRealm::updateEditorGeneral()"); |
|
132 |
|
133 Q_ASSERT(edit); |
|
134 |
|
135 edit->setMaxLength(EapQtConfigInterfacePrivate::StringMaxLength); |
|
136 edit->setInputMethodHints(Qt::ImhNoAutoUppercase | Qt::ImhPreferLowercase |
|
137 | Qt::ImhNoPredictiveText); |
|
138 |
|
139 HbEditorInterface editInterface(edit); |
|
140 editInterface.setEditorClass(HbInputEditorClassNetworkDomain); |
|
141 |
|
142 HbEditorConstraints constraints = HbEditorConstraintAutoCompletingField; |
|
143 editInterface.setInputConstraints(constraints); |
|
144 |
|
145 // no smileys :) |
|
146 editInterface.setSmileyTheme(HbSmileyTheme()); |
|
147 } |