|
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 Wizard Page: EAP Identity. |
|
16 * |
|
17 */ |
|
18 |
|
19 // System includes |
|
20 #include <HbDocumentLoader> |
|
21 #include <HbMainWindow> |
|
22 #include <HbWidget> |
|
23 #include <HbCheckBox> |
|
24 #include <HbLineEdit> |
|
25 #include <HbLabel> |
|
26 #include <HbEditorInterface> |
|
27 #include <HbParameterLengthLimiter> |
|
28 #include <eapqtexpandedeaptype.h> |
|
29 #include <eapqtpluginhandle.h> |
|
30 #include <eapqtplugininfo.h> |
|
31 #include <eapqtconfiginterface.h> |
|
32 #include <eapqtvalidator.h> |
|
33 |
|
34 // User includes |
|
35 #include "wlanwizardhelper.h" |
|
36 #include "eapwizardpageidentity.h" |
|
37 #include "eapwizard_p.h" |
|
38 #include "OstTraceDefinitions.h" |
|
39 #ifdef OST_TRACE_COMPILER_IN_USE |
|
40 #include "eapwizardpageidentityTraces.h" |
|
41 #endif |
|
42 |
|
43 |
|
44 /*! |
|
45 \class EapWizardPageIdentity |
|
46 \brief Implements EAP wizard page: Identify for outer EAP type |
|
47 */ |
|
48 |
|
49 // External function prototypes |
|
50 |
|
51 // Local constants |
|
52 |
|
53 // ======== LOCAL FUNCTIONS ======== |
|
54 |
|
55 // ======== MEMBER FUNCTIONS ======== |
|
56 |
|
57 |
|
58 /*! |
|
59 Constructor. |
|
60 |
|
61 @param [in] parent Pointer to EAP Wizard private implementation. |
|
62 */ |
|
63 EapWizardPageIdentity::EapWizardPageIdentity(EapWizardPrivate* parent) : |
|
64 EapWizardPage(parent), |
|
65 mDocumentLoader(NULL), |
|
66 mValidatorRealm(NULL), |
|
67 mValidatorUsername(NULL), |
|
68 mWidget(NULL), |
|
69 mEditUsername(NULL), |
|
70 mEditRealm(NULL), |
|
71 mCheckUsername(NULL), |
|
72 mCheckRealm(NULL), |
|
73 mLabelRealm(NULL), |
|
74 mLabelUsername(NULL) |
|
75 { |
|
76 OstTraceFunctionEntry0( EAPWIZARDPAGEIDENTITY_EAPWIZARDPAGEIDENTITY_ENTRY ); |
|
77 OstTraceFunctionExit0( EAPWIZARDPAGEIDENTITY_EAPWIZARDPAGEIDENTITY_EXIT ); |
|
78 } |
|
79 |
|
80 /*! |
|
81 Destructor. |
|
82 */ |
|
83 EapWizardPageIdentity::~EapWizardPageIdentity() |
|
84 { |
|
85 OstTraceFunctionEntry0( DUP1_EAPWIZARDPAGEIDENTITY_EAPWIZARDPAGEIDENTITY_ENTRY ); |
|
86 OstTraceFunctionExit0( DUP1_EAPWIZARDPAGEIDENTITY_EAPWIZARDPAGEIDENTITY_EXIT ); |
|
87 } |
|
88 |
|
89 /*! |
|
90 See WlanWizardPage. |
|
91 */ |
|
92 HbWidget* EapWizardPageIdentity::initializePage() |
|
93 { |
|
94 OstTraceFunctionEntry0( EAPWIZARDPAGEIDENTITY_INITIALIZEPAGE_ENTRY ); |
|
95 if (!mWidget) { |
|
96 bool ok = true; |
|
97 mDocumentLoader.reset( |
|
98 new HbDocumentLoader(mWizard->wizardHelper()->mainWindow())); |
|
99 mDocumentLoader->load(":/docml/occ_eap_wizard_03.docml", &ok); |
|
100 Q_ASSERT(ok); |
|
101 |
|
102 loadDocmlSection(mWizard->wizardHelper()->mainWindow()->orientation()); |
|
103 |
|
104 mWidget = qobject_cast<HbWidget*> (mDocumentLoader->findWidget("occ_eap_wizard_03")); |
|
105 Q_ASSERT(mWidget); |
|
106 |
|
107 mEditUsername = qobject_cast<HbLineEdit*> (mDocumentLoader->findWidget("lineEditUsername")); |
|
108 Q_ASSERT(mEditUsername); |
|
109 |
|
110 mEditRealm = qobject_cast<HbLineEdit*> (mDocumentLoader->findWidget("lineEditRealm")); |
|
111 Q_ASSERT(mEditRealm); |
|
112 |
|
113 mCheckUsername = qobject_cast<HbCheckBox*> (mDocumentLoader->findWidget("setlabel_53_val")); |
|
114 Q_ASSERT(mCheckUsername); |
|
115 |
|
116 mCheckRealm = qobject_cast<HbCheckBox*> (mDocumentLoader->findWidget("setlabel_54_val")); |
|
117 Q_ASSERT(mCheckRealm); |
|
118 |
|
119 mLabelUsername = qobject_cast<HbLabel*> (mDocumentLoader->findWidget("setlabel_53")); |
|
120 Q_ASSERT(mLabelUsername); |
|
121 |
|
122 mLabelRealm = qobject_cast<HbLabel*> (mDocumentLoader->findWidget("setlabel_54")); |
|
123 Q_ASSERT(mLabelRealm); |
|
124 |
|
125 ok = connect( |
|
126 mWizard->wizardHelper()->mainWindow(), |
|
127 SIGNAL(orientationChanged(Qt::Orientation)), |
|
128 this, |
|
129 SLOT(loadDocmlSection(Qt::Orientation))); |
|
130 Q_ASSERT(ok); |
|
131 |
|
132 ok = connect( |
|
133 mEditUsername, SIGNAL(textChanged(const QString &)), |
|
134 this, SLOT(textChanged(const QString &))); |
|
135 Q_ASSERT(ok); |
|
136 |
|
137 ok = connect( |
|
138 mEditRealm, SIGNAL(textChanged(const QString &)), |
|
139 this, SLOT(textChanged(const QString &))); |
|
140 Q_ASSERT(ok); |
|
141 |
|
142 ok = connect( |
|
143 mCheckUsername, SIGNAL(stateChanged(int)), |
|
144 this, SLOT(stateChanged(int))); |
|
145 Q_ASSERT(ok); |
|
146 |
|
147 ok = connect( |
|
148 mCheckRealm, SIGNAL(stateChanged(int)), |
|
149 this, SLOT(stateChanged(int))); |
|
150 Q_ASSERT(ok); |
|
151 // by default both checkboxes are checked |
|
152 } |
|
153 EapQtPluginHandle plugin((EapQtPluginHandle::Plugin) |
|
154 mWizard->configurations(EapWizardPrivate::OuterType).toInt() ); |
|
155 |
|
156 mLabelUsername->setPlainText( |
|
157 HbParameterLengthLimiter("txt_occ_setlabel_user_name_for_1").arg( |
|
158 mWizard->eapTypeToString(plugin.pluginId()))); |
|
159 |
|
160 // Configure editors properties |
|
161 mValidatorUsername.reset( |
|
162 mWizard->eapConfigurationInterface()->validatorEap( |
|
163 plugin.type(), |
|
164 EapQtConfig::Username) ); |
|
165 Q_ASSERT(mValidatorUsername.data()); |
|
166 mValidatorUsername->updateEditor(mEditUsername); |
|
167 |
|
168 mValidatorRealm.reset( |
|
169 mWizard->eapConfigurationInterface()->validatorEap( |
|
170 plugin.type(), |
|
171 EapQtConfig::Realm) ); |
|
172 Q_ASSERT(mValidatorRealm.data()); |
|
173 mValidatorRealm->updateEditor(mEditRealm); |
|
174 |
|
175 OstTraceFunctionExit0( EAPWIZARDPAGEIDENTITY_INITIALIZEPAGE_EXIT ); |
|
176 return mWidget; |
|
177 } |
|
178 |
|
179 /*! |
|
180 Loads the required orientation of docml. |
|
181 |
|
182 @param [in] orientation Orientation to be loaded. |
|
183 */ |
|
184 void EapWizardPageIdentity::loadDocmlSection(Qt::Orientation orientation) |
|
185 { |
|
186 OstTraceFunctionEntry0( EAPWIZARDPAGEIDENTITY_LOADDOCMLSECTION_ENTRY ); |
|
187 EapWizardPage::loadDocmlSection( |
|
188 mDocumentLoader.data(), |
|
189 orientation, |
|
190 ":/docml/occ_eap_wizard_03.docml", |
|
191 "portrait_section", |
|
192 "landscape_section"); |
|
193 OstTraceFunctionExit0( EAPWIZARDPAGEIDENTITY_LOADDOCMLSECTION_EXIT ); |
|
194 } |
|
195 |
|
196 /*! |
|
197 See WlanWizardPage. |
|
198 |
|
199 @return next wizard page: |
|
200 - WlanWizardPage::PageProcessSettings: For EAP-TLS |
|
201 - EapWizardPage::PageInnerTypeEapTtls: For EAP-TTLS |
|
202 - EapWizardPage::PageInnerTypePeap: For PEAP |
|
203 */ |
|
204 int EapWizardPageIdentity::nextId() const |
|
205 { |
|
206 OstTraceFunctionEntry0( EAPWIZARDPAGEIDENTITY_NEXTID_ENTRY ); |
|
207 int id = WlanWizardPage::PageNone; |
|
208 bool ok; |
|
209 int type = mWizard->configurations(EapWizardPrivate::OuterType).toInt(&ok); |
|
210 Q_ASSERT(ok); |
|
211 |
|
212 switch (type) { |
|
213 case EapQtPluginHandle::PluginEapTls: |
|
214 id = WlanWizardPage::PageProcessSettings; |
|
215 break; |
|
216 |
|
217 case EapQtPluginHandle::PluginEapTtls: |
|
218 id = EapWizardPage::PageInnerTypeEapTtls; |
|
219 break; |
|
220 |
|
221 case EapQtPluginHandle::PluginPeap: |
|
222 id = EapWizardPage::PageInnerTypePeap; |
|
223 break; |
|
224 } |
|
225 |
|
226 mWizard->setConfigurations(EapWizardPrivate::TunnelUsernameAutomatic, |
|
227 mCheckUsername->isChecked()); |
|
228 |
|
229 mWizard->setConfigurations( |
|
230 EapWizardPrivate::TunnelUsername, mEditUsername->text()); |
|
231 |
|
232 mWizard->setConfigurations( |
|
233 EapWizardPrivate::TunnelRealmAutomatic, mCheckRealm->isChecked()); |
|
234 |
|
235 mWizard->setConfigurations(EapWizardPrivate::TunnelRealm, mEditRealm->text()); |
|
236 |
|
237 OstTraceFunctionExit0( EAPWIZARDPAGEIDENTITY_NEXTID_EXIT ); |
|
238 return id; |
|
239 } |
|
240 |
|
241 /*! |
|
242 See WlanWizardPage. |
|
243 |
|
244 Validates the content of the page. |
|
245 |
|
246 @return true if content is valid. |
|
247 */ |
|
248 bool EapWizardPageIdentity::showPage() |
|
249 { |
|
250 OstTraceFunctionEntry0( EAPWIZARDPAGEIDENTITY_SHOWPAGE_ENTRY ); |
|
251 bool valid = false; |
|
252 |
|
253 if (validateGroup(mEditUsername, mCheckUsername, mValidatorUsername.data()) && |
|
254 validateGroup(mEditRealm, mCheckRealm, mValidatorRealm.data())) { |
|
255 valid = true; |
|
256 } |
|
257 |
|
258 OstTraceFunctionExit0( EAPWIZARDPAGEIDENTITY_SHOWPAGE_EXIT ); |
|
259 return valid; |
|
260 } |
|
261 |
|
262 /*! |
|
263 Slot for textChanged() signal from HbLineEdit. |
|
264 |
|
265 @param [in] text NOT USED. |
|
266 */ |
|
267 void EapWizardPageIdentity::textChanged(const QString & text) |
|
268 { |
|
269 OstTraceFunctionEntry0( EAPWIZARDPAGEIDENTITY_TEXTCHANGED_ENTRY ); |
|
270 Q_UNUSED(text); |
|
271 mWizard->wizardHelper()->enableNextButton(showPage()); |
|
272 OstTraceFunctionExit0( EAPWIZARDPAGEIDENTITY_TEXTCHANGED_EXIT ); |
|
273 } |
|
274 |
|
275 /*! |
|
276 Slot for stateChanged() signal from HbCheckBox. |
|
277 |
|
278 @param [in] state NOT USED. |
|
279 */ |
|
280 void EapWizardPageIdentity::stateChanged(int state ) |
|
281 { |
|
282 OstTraceFunctionEntry0( EAPWIZARDPAGEIDENTITY_STATECHANGED_ENTRY ); |
|
283 Q_UNUSED(state); |
|
284 mEditUsername->setEnabled(!mCheckUsername->isChecked()); |
|
285 mEditRealm->setEnabled(!mCheckRealm->isChecked()); |
|
286 mWizard->wizardHelper()->enableNextButton(showPage()); |
|
287 OstTraceFunctionExit0( EAPWIZARDPAGEIDENTITY_STATECHANGED_EXIT ); |
|
288 } |
|
289 |
|
290 /*! |
|
291 Validates the settings group, that is line edit and checkbox using |
|
292 given validator. |
|
293 |
|
294 @param [in] edit pointer to line edit to which content must be validated |
|
295 @param [in] checkBox pointer to checkbox |
|
296 @param [in] validator pointer to validator which is used to validate the content |
|
297 of the line editor. |
|
298 |
|
299 @return true if validation is ok, false otherwise. |
|
300 */ |
|
301 bool EapWizardPageIdentity::validateGroup( |
|
302 HbLineEdit *edit, |
|
303 HbCheckBox *checkBox, |
|
304 EapQtValidator *validator) const |
|
305 { |
|
306 OstTraceFunctionEntry0( EAPWIZARDPAGEIDENTITY_VALIDATEGROUP_ENTRY ); |
|
307 bool status = false; |
|
308 if (checkBox->isChecked() || |
|
309 checkBox->isChecked() == false && |
|
310 EapQtValidator::StatusOk == validator->validate(edit->text())) { |
|
311 status = true; |
|
312 } |
|
313 OstTraceFunctionExit0( EAPWIZARDPAGEIDENTITY_VALIDATEGROUP_EXIT ); |
|
314 return status; |
|
315 } |