39
|
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"
|
43
|
38 |
#include "OstTraceDefinitions.h"
|
|
39 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
40 |
#include "eapwizardpageidentityTraces.h"
|
|
41 |
#endif
|
|
42 |
|
39
|
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.
|
43
|
60 |
|
39
|
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 |
{
|
43
|
76 |
OstTraceFunctionEntry0( EAPWIZARDPAGEIDENTITY_EAPWIZARDPAGEIDENTITY_ENTRY );
|
|
77 |
OstTraceFunctionExit0( EAPWIZARDPAGEIDENTITY_EAPWIZARDPAGEIDENTITY_EXIT );
|
39
|
78 |
}
|
|
79 |
|
|
80 |
/*!
|
|
81 |
Destructor.
|
|
82 |
*/
|
|
83 |
EapWizardPageIdentity::~EapWizardPageIdentity()
|
|
84 |
{
|
43
|
85 |
OstTraceFunctionEntry0( DUP1_EAPWIZARDPAGEIDENTITY_EAPWIZARDPAGEIDENTITY_ENTRY );
|
|
86 |
OstTraceFunctionExit0( DUP1_EAPWIZARDPAGEIDENTITY_EAPWIZARDPAGEIDENTITY_EXIT );
|
39
|
87 |
}
|
|
88 |
|
|
89 |
/*!
|
|
90 |
See WlanWizardPage.
|
|
91 |
*/
|
|
92 |
HbWidget* EapWizardPageIdentity::initializePage()
|
|
93 |
{
|
43
|
94 |
OstTraceFunctionEntry0( EAPWIZARDPAGEIDENTITY_INITIALIZEPAGE_ENTRY );
|
39
|
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());
|
43
|
103 |
|
39
|
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);
|
43
|
118 |
|
39
|
119 |
mLabelUsername = qobject_cast<HbLabel*> (mDocumentLoader->findWidget("setlabel_53"));
|
|
120 |
Q_ASSERT(mLabelUsername);
|
43
|
121 |
|
39
|
122 |
mLabelRealm = qobject_cast<HbLabel*> (mDocumentLoader->findWidget("setlabel_54"));
|
|
123 |
Q_ASSERT(mLabelRealm);
|
43
|
124 |
|
39
|
125 |
ok = connect(
|
|
126 |
mWizard->wizardHelper()->mainWindow(),
|
|
127 |
SIGNAL(orientationChanged(Qt::Orientation)),
|
|
128 |
this,
|
|
129 |
SLOT(loadDocmlSection(Qt::Orientation)));
|
|
130 |
Q_ASSERT(ok);
|
43
|
131 |
|
39
|
132 |
ok = connect(
|
|
133 |
mEditUsername, SIGNAL(textChanged(const QString &)),
|
|
134 |
this, SLOT(textChanged(const QString &)));
|
|
135 |
Q_ASSERT(ok);
|
43
|
136 |
|
39
|
137 |
ok = connect(
|
|
138 |
mEditRealm, SIGNAL(textChanged(const QString &)),
|
|
139 |
this, SLOT(textChanged(const QString &)));
|
|
140 |
Q_ASSERT(ok);
|
43
|
141 |
|
39
|
142 |
ok = connect(
|
|
143 |
mCheckUsername, SIGNAL(stateChanged(int)),
|
|
144 |
this, SLOT(stateChanged(int)));
|
|
145 |
Q_ASSERT(ok);
|
43
|
146 |
|
39
|
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(
|
|
158 |
hbTrId("txt_occ_setlabel_user_name_for_1")).arg(
|
|
159 |
mWizard->eapTypeToString(plugin.pluginId())));
|
43
|
160 |
|
39
|
161 |
// Configure editors properties
|
|
162 |
mValidatorUsername.reset(
|
|
163 |
mWizard->eapConfigurationInterface()->validatorEap(
|
|
164 |
plugin.type(),
|
|
165 |
EapQtConfig::Username) );
|
|
166 |
Q_ASSERT(mValidatorUsername.data());
|
|
167 |
mValidatorUsername->updateEditor(mEditUsername);
|
|
168 |
|
|
169 |
mValidatorRealm.reset(
|
|
170 |
mWizard->eapConfigurationInterface()->validatorEap(
|
|
171 |
plugin.type(),
|
|
172 |
EapQtConfig::Realm) );
|
|
173 |
Q_ASSERT(mValidatorRealm.data());
|
|
174 |
mValidatorRealm->updateEditor(mEditRealm);
|
|
175 |
|
43
|
176 |
OstTraceFunctionExit0( EAPWIZARDPAGEIDENTITY_INITIALIZEPAGE_EXIT );
|
39
|
177 |
return mWidget;
|
|
178 |
}
|
|
179 |
|
|
180 |
/*!
|
|
181 |
Loads the required orientation of docml.
|
43
|
182 |
|
39
|
183 |
@param [in] orientation Orientation to be loaded.
|
|
184 |
*/
|
|
185 |
void EapWizardPageIdentity::loadDocmlSection(Qt::Orientation orientation)
|
|
186 |
{
|
43
|
187 |
OstTraceFunctionEntry0( EAPWIZARDPAGEIDENTITY_LOADDOCMLSECTION_ENTRY );
|
39
|
188 |
EapWizardPage::loadDocmlSection(
|
|
189 |
mDocumentLoader.data(),
|
|
190 |
orientation,
|
|
191 |
":/docml/occ_eap_wizard_03.docml",
|
|
192 |
"portrait_section",
|
|
193 |
"landscape_section");
|
43
|
194 |
OstTraceFunctionExit0( EAPWIZARDPAGEIDENTITY_LOADDOCMLSECTION_EXIT );
|
39
|
195 |
}
|
|
196 |
|
|
197 |
/*!
|
|
198 |
See WlanWizardPage.
|
43
|
199 |
|
39
|
200 |
@return next wizard page:
|
|
201 |
- WlanWizardPage::PageProcessSettings: For EAP-TLS
|
|
202 |
- EapWizardPage::PageInnerTypeEapTtls: For EAP-TTLS
|
|
203 |
- EapWizardPage::PageInnerTypePeap: For PEAP
|
|
204 |
*/
|
|
205 |
int EapWizardPageIdentity::nextId() const
|
|
206 |
{
|
43
|
207 |
OstTraceFunctionEntry0( EAPWIZARDPAGEIDENTITY_NEXTID_ENTRY );
|
39
|
208 |
int id = WlanWizardPage::PageNone;
|
|
209 |
bool ok;
|
|
210 |
int type = mWizard->configurations(EapWizardPrivate::OuterType).toInt(&ok);
|
|
211 |
Q_ASSERT(ok);
|
|
212 |
|
|
213 |
switch (type) {
|
|
214 |
case EapQtPluginHandle::PluginEapTls:
|
|
215 |
id = WlanWizardPage::PageProcessSettings;
|
|
216 |
break;
|
43
|
217 |
|
39
|
218 |
case EapQtPluginHandle::PluginEapTtls:
|
|
219 |
id = EapWizardPage::PageInnerTypeEapTtls;
|
|
220 |
break;
|
43
|
221 |
|
39
|
222 |
case EapQtPluginHandle::PluginPeap:
|
|
223 |
id = EapWizardPage::PageInnerTypePeap;
|
|
224 |
break;
|
|
225 |
}
|
|
226 |
|
|
227 |
mWizard->setConfigurations(EapWizardPrivate::TunnelUsernameAutomatic,
|
|
228 |
mCheckUsername->isChecked());
|
43
|
229 |
|
39
|
230 |
mWizard->setConfigurations(
|
|
231 |
EapWizardPrivate::TunnelUsername, mEditUsername->text());
|
43
|
232 |
|
39
|
233 |
mWizard->setConfigurations(
|
|
234 |
EapWizardPrivate::TunnelRealmAutomatic, mCheckRealm->isChecked());
|
43
|
235 |
|
39
|
236 |
mWizard->setConfigurations(EapWizardPrivate::TunnelRealm, mEditRealm->text());
|
|
237 |
|
43
|
238 |
OstTraceFunctionExit0( EAPWIZARDPAGEIDENTITY_NEXTID_EXIT );
|
39
|
239 |
return id;
|
|
240 |
}
|
|
241 |
|
|
242 |
/*!
|
|
243 |
See WlanWizardPage.
|
43
|
244 |
|
39
|
245 |
Validates the content of the page.
|
43
|
246 |
|
39
|
247 |
@return true if content is valid.
|
|
248 |
*/
|
|
249 |
bool EapWizardPageIdentity::showPage()
|
|
250 |
{
|
43
|
251 |
OstTraceFunctionEntry0( EAPWIZARDPAGEIDENTITY_SHOWPAGE_ENTRY );
|
39
|
252 |
bool valid = false;
|
|
253 |
|
|
254 |
if (validateGroup(mEditUsername, mCheckUsername, mValidatorUsername.data()) &&
|
|
255 |
validateGroup(mEditRealm, mCheckRealm, mValidatorRealm.data())) {
|
|
256 |
valid = true;
|
|
257 |
}
|
|
258 |
|
43
|
259 |
OstTraceFunctionExit0( EAPWIZARDPAGEIDENTITY_SHOWPAGE_EXIT );
|
39
|
260 |
return valid;
|
|
261 |
}
|
|
262 |
|
|
263 |
/*!
|
|
264 |
Slot for textChanged() signal from HbLineEdit.
|
43
|
265 |
|
39
|
266 |
@param [in] text NOT USED.
|
|
267 |
*/
|
|
268 |
void EapWizardPageIdentity::textChanged(const QString & text)
|
|
269 |
{
|
43
|
270 |
OstTraceFunctionEntry0( EAPWIZARDPAGEIDENTITY_TEXTCHANGED_ENTRY );
|
39
|
271 |
Q_UNUSED(text);
|
|
272 |
mWizard->wizardHelper()->enableNextButton(showPage());
|
43
|
273 |
OstTraceFunctionExit0( EAPWIZARDPAGEIDENTITY_TEXTCHANGED_EXIT );
|
39
|
274 |
}
|
|
275 |
|
|
276 |
/*!
|
|
277 |
Slot for stateChanged() signal from HbCheckBox.
|
43
|
278 |
|
39
|
279 |
@param [in] state NOT USED.
|
|
280 |
*/
|
|
281 |
void EapWizardPageIdentity::stateChanged(int state )
|
|
282 |
{
|
43
|
283 |
OstTraceFunctionEntry0( EAPWIZARDPAGEIDENTITY_STATECHANGED_ENTRY );
|
39
|
284 |
Q_UNUSED(state);
|
|
285 |
mEditUsername->setEnabled(!mCheckUsername->isChecked());
|
|
286 |
mEditRealm->setEnabled(!mCheckRealm->isChecked());
|
|
287 |
mWizard->wizardHelper()->enableNextButton(showPage());
|
43
|
288 |
OstTraceFunctionExit0( EAPWIZARDPAGEIDENTITY_STATECHANGED_EXIT );
|
39
|
289 |
}
|
|
290 |
|
|
291 |
/*!
|
|
292 |
Validates the settings group, that is line edit and checkbox using
|
|
293 |
given validator.
|
43
|
294 |
|
39
|
295 |
@param [in] edit pointer to line edit to which content must be validated
|
|
296 |
@param [in] checkBox pointer to checkbox
|
|
297 |
@param [in] validator pointer to validator which is used to validate the content
|
|
298 |
of the line editor.
|
43
|
299 |
|
39
|
300 |
@return true if validation is ok, false otherwise.
|
|
301 |
*/
|
|
302 |
bool EapWizardPageIdentity::validateGroup(
|
|
303 |
HbLineEdit *edit,
|
|
304 |
HbCheckBox *checkBox,
|
|
305 |
EapQtValidator *validator) const
|
|
306 |
{
|
43
|
307 |
OstTraceFunctionEntry0( EAPWIZARDPAGEIDENTITY_VALIDATEGROUP_ENTRY );
|
39
|
308 |
bool status = false;
|
|
309 |
if (checkBox->isChecked() ||
|
|
310 |
checkBox->isChecked() == false &&
|
|
311 |
EapQtValidator::StatusOk == validator->validate(edit->text())) {
|
|
312 |
status = true;
|
|
313 |
}
|
43
|
314 |
OstTraceFunctionExit0( EAPWIZARDPAGEIDENTITY_VALIDATEGROUP_EXIT );
|
39
|
315 |
return status;
|
|
316 |
}
|