70 } |
70 } |
71 // zero length username is ok |
71 // zero length username is ok |
72 else if (str.length() > EapQtConfigInterfacePrivate::StringMaxLength) { |
72 else if (str.length() > EapQtConfigInterfacePrivate::StringMaxLength) { |
73 status = StatusTooLong; |
73 status = StatusTooLong; |
74 } |
74 } |
75 // username and realm are separated with @, not allowed to be part of username |
75 else if (!validateCharacters(str)) { |
76 else if (str.contains(QChar('@'), Qt::CaseInsensitive)) { |
|
77 status = StatusInvalidCharacters; |
76 status = StatusInvalidCharacters; |
78 } |
77 } |
79 |
78 |
80 qDebug("EapQtValidatorUsername::validateGeneral - return status: %d", status); |
79 qDebug("EapQtValidatorUsername::validateGeneral - return status: %d", status); |
81 |
80 |
82 return status; |
81 return status; |
83 } |
82 } |
84 |
83 |
|
84 bool EapQtValidatorUsername::validateCharacters(QString& str) |
|
85 { |
|
86 bool ret(true); |
|
87 |
|
88 switch (mEapType.type()) { |
|
89 case EapQtExpandedEapType::TypeEapAka: |
|
90 case EapQtExpandedEapType::TypeEapFast: |
|
91 case EapQtExpandedEapType::TypeEapSim: |
|
92 case EapQtExpandedEapType::TypeEapTls: |
|
93 case EapQtExpandedEapType::TypeEapTtls: |
|
94 case EapQtExpandedEapType::TypePeap: |
|
95 // these methods have a separate UI setting for realm, |
|
96 // hence @ is not allowed in username field |
|
97 ret = !(str.contains(QChar('@'), Qt::CaseInsensitive)); |
|
98 break; |
|
99 default: |
|
100 // username field can contain realm separated with @ |
|
101 break; |
|
102 } |
|
103 |
|
104 return ret; |
|
105 } |
|
106 |
85 void EapQtValidatorUsername::updateEditor(HbLineEdit *edit) |
107 void EapQtValidatorUsername::updateEditor(HbLineEdit *edit) |
86 { |
108 { |
|
109 Q_ASSERT(edit); |
|
110 if(edit == NULL) { |
|
111 return; |
|
112 } |
|
113 |
87 switch (mEapType.type()) { |
114 switch (mEapType.type()) { |
88 case EapQtExpandedEapType::TypeEapAka: |
115 case EapQtExpandedEapType::TypeEapAka: |
89 case EapQtExpandedEapType::TypeEapFast: |
116 case EapQtExpandedEapType::TypeEapFast: |
90 case EapQtExpandedEapType::TypeEapGtc: |
117 case EapQtExpandedEapType::TypeEapGtc: |
91 case EapQtExpandedEapType::TypeEapMschapv2: |
118 case EapQtExpandedEapType::TypeEapMschapv2: |
104 |
131 |
105 void EapQtValidatorUsername::updateEditorGeneral(HbLineEdit *edit) |
132 void EapQtValidatorUsername::updateEditorGeneral(HbLineEdit *edit) |
106 { |
133 { |
107 qDebug("EapQtValidatorUsername::updateEditorGeneral()"); |
134 qDebug("EapQtValidatorUsername::updateEditorGeneral()"); |
108 |
135 |
|
136 Q_ASSERT(edit); |
|
137 |
109 edit->setMaxLength(EapQtConfigInterfacePrivate::StringMaxLength); |
138 edit->setMaxLength(EapQtConfigInterfacePrivate::StringMaxLength); |
110 edit->setInputMethodHints(Qt::ImhNoAutoUppercase | Qt::ImhPreferLowercase |
139 edit->setInputMethodHints(Qt::ImhNoAutoUppercase | Qt::ImhPreferLowercase |
111 | Qt::ImhNoPredictiveText); |
140 | Qt::ImhNoPredictiveText); |
112 |
141 |
113 HbEditorInterface editInterface(edit); |
142 HbEditorInterface editInterface(edit); |