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