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: Common Username & password query. |
|
16 * |
|
17 */ |
|
18 |
|
19 // System includes |
|
20 #include <HbDocumentLoader> |
|
21 #include <HbMainWindow> |
|
22 #include <HbWidget> |
|
23 #include <HbLineEdit> |
|
24 #include <HbLabel> |
|
25 #include <HbEditorInterface> |
|
26 #include <HbParameterLengthLimiter> |
|
27 #include <eapqtexpandedeaptype.h> |
|
28 #include <eapqtpluginhandle.h> |
|
29 #include <eapqtconfiginterface.h> |
|
30 #include <eapqtvalidator.h> |
|
31 |
|
32 // User includes |
|
33 #include "wlanwizardhelper.h" |
|
34 #include "eapwizardpageusernamepassword.h" |
|
35 #include "eapwizard_p.h" |
|
36 #include "OstTraceDefinitions.h" |
|
37 #ifdef OST_TRACE_COMPILER_IN_USE |
|
38 #include "eapwizardpageusernamepasswordTraces.h" |
|
39 #endif |
|
40 |
|
41 |
|
42 /*! |
|
43 \class EapWizardPageUsernamePassword |
|
44 \brief Implements EAP wizard page: Generic Username & Password page |
|
45 */ |
|
46 |
|
47 // External function prototypes |
|
48 |
|
49 // Local constants |
|
50 |
|
51 // ======== LOCAL FUNCTIONS ======== |
|
52 |
|
53 // ======== MEMBER FUNCTIONS ======== |
|
54 |
|
55 |
|
56 /*! |
|
57 Constructor. |
|
58 |
|
59 @param [in] parent Pointer to EAP Wizard private implementation. |
|
60 */ |
|
61 EapWizardPageUsernamePassword::EapWizardPageUsernamePassword( |
|
62 EapWizardPrivate* parent) : |
|
63 EapWizardPage(parent), |
|
64 mDocumentLoader(NULL), |
|
65 mValidatorUsername(NULL), |
|
66 mValidatorPassword(NULL), |
|
67 mWidget(NULL), |
|
68 mEditUsername(NULL), |
|
69 mEditPassword(NULL), |
|
70 mTitleUsername(NULL), |
|
71 mTitlePassword(NULL) |
|
72 { |
|
73 OstTraceFunctionEntry0( EAPWIZARDPAGEUSERNAMEPASSWORD_EAPWIZARDPAGEUSERNAMEPASSWORD_ENTRY ); |
|
74 OstTraceFunctionExit0( EAPWIZARDPAGEUSERNAMEPASSWORD_EAPWIZARDPAGEUSERNAMEPASSWORD_EXIT ); |
|
75 } |
|
76 |
|
77 /*! |
|
78 Destructor. |
|
79 */ |
|
80 EapWizardPageUsernamePassword::~EapWizardPageUsernamePassword() |
|
81 { |
|
82 OstTraceFunctionEntry0( DUP1_EAPWIZARDPAGEUSERNAMEPASSWORD_EAPWIZARDPAGEUSERNAMEPASSWORD_ENTRY ); |
|
83 OstTraceFunctionExit0( DUP1_EAPWIZARDPAGEUSERNAMEPASSWORD_EAPWIZARDPAGEUSERNAMEPASSWORD_EXIT ); |
|
84 } |
|
85 |
|
86 /*! |
|
87 See WlanWizardPage. |
|
88 */ |
|
89 HbWidget* EapWizardPageUsernamePassword::initializePage() |
|
90 { |
|
91 OstTraceFunctionEntry0( EAPWIZARDPAGEUSERNAMEPASSWORD_INITIALIZEPAGE_ENTRY ); |
|
92 if (!mWidget) { |
|
93 bool ok = true; |
|
94 mDocumentLoader.reset( |
|
95 new HbDocumentLoader(mWizard->wizardHelper()->mainWindow())); |
|
96 mDocumentLoader->load(":/docml/occ_eap_wizard_05_07.docml", &ok); |
|
97 Q_ASSERT(ok); |
|
98 loadDocmlSection(mWizard->wizardHelper()->mainWindow()->orientation()); |
|
99 |
|
100 mWidget = qobject_cast<HbWidget*> (mDocumentLoader->findWidget("view")); |
|
101 Q_ASSERT(mWidget); |
|
102 |
|
103 mTitleUsername = qobject_cast<HbLabel*> (mDocumentLoader->findWidget("setlabel_55")); |
|
104 Q_ASSERT(mTitleUsername); |
|
105 |
|
106 mTitlePassword = qobject_cast<HbLabel*> (mDocumentLoader->findWidget("setlabel_56")); |
|
107 Q_ASSERT(mTitlePassword); |
|
108 |
|
109 mEditUsername = qobject_cast<HbLineEdit*> (mDocumentLoader->findWidget("lineEditUsername")); |
|
110 Q_ASSERT(mEditUsername); |
|
111 |
|
112 mEditPassword = qobject_cast<HbLineEdit*> (mDocumentLoader->findWidget("lineEditPassword")); |
|
113 Q_ASSERT(mEditPassword); |
|
114 |
|
115 mTitlePassword->setPlainText(hbTrId("txt_occ_setlabel_eap_password")); |
|
116 |
|
117 ok = connect( |
|
118 mWizard->wizardHelper()->mainWindow(), |
|
119 SIGNAL(orientationChanged(Qt::Orientation)), |
|
120 this, |
|
121 SLOT(loadDocmlSection(Qt::Orientation))); |
|
122 Q_ASSERT(ok); |
|
123 |
|
124 ok = connect( |
|
125 mEditUsername, SIGNAL(textChanged(const QString &)), |
|
126 this, SLOT(textChanged(const QString &))); |
|
127 Q_ASSERT(ok); |
|
128 |
|
129 ok = connect( |
|
130 mEditPassword, SIGNAL(textChanged(const QString &)), |
|
131 this, SLOT(textChanged(const QString &))); |
|
132 Q_ASSERT(ok); |
|
133 } |
|
134 |
|
135 int eapType = mWizard->configurations(EapWizardPrivate::OuterType).toInt(); |
|
136 |
|
137 if (eapType != EapQtPluginHandle::PluginLeap) { |
|
138 eapType = mWizard->configurations(EapWizardPrivate::InnerType).toInt(); |
|
139 } |
|
140 |
|
141 EapQtPluginHandle plugin(static_cast<EapQtPluginHandle::Plugin>(eapType)); |
|
142 |
|
143 mValidatorUsername.reset( |
|
144 mWizard->eapConfigurationInterface()->validatorEap( |
|
145 plugin.type(), |
|
146 EapQtConfig::Username)); |
|
147 Q_ASSERT(mValidatorUsername.data()); |
|
148 mValidatorUsername->updateEditor(mEditUsername); |
|
149 |
|
150 mValidatorPassword.reset( |
|
151 mWizard->eapConfigurationInterface()->validatorEap( |
|
152 plugin.type(), |
|
153 EapQtConfig::Password)); |
|
154 Q_ASSERT(mValidatorPassword.data()); |
|
155 mValidatorPassword->updateEditor(mEditPassword); |
|
156 |
|
157 mTitleUsername->setPlainText( |
|
158 HbParameterLengthLimiter("txt_occ_setlabel_user_name_for_1").arg( |
|
159 mWizard->eapTypeToString(eapType))); |
|
160 |
|
161 OstTraceFunctionExit0( EAPWIZARDPAGEUSERNAMEPASSWORD_INITIALIZEPAGE_EXIT ); |
|
162 return mWidget; |
|
163 } |
|
164 |
|
165 /*! |
|
166 Loads the required orientation of docml. |
|
167 |
|
168 @param [in] orientation Orientation to be loaded. |
|
169 */ |
|
170 void EapWizardPageUsernamePassword::loadDocmlSection(Qt::Orientation orientation) |
|
171 { |
|
172 OstTraceFunctionEntry0( EAPWIZARDPAGEUSERNAMEPASSWORD_LOADDOCMLSECTION_ENTRY ); |
|
173 EapWizardPage::loadDocmlSection( |
|
174 mDocumentLoader.data(), |
|
175 orientation, |
|
176 ":/docml/occ_eap_wizard_05_07.docml", |
|
177 "portrait_section", |
|
178 "landscape_section"); |
|
179 OstTraceFunctionExit0( EAPWIZARDPAGEUSERNAMEPASSWORD_LOADDOCMLSECTION_EXIT ); |
|
180 } |
|
181 |
|
182 /*! |
|
183 See WlanWizardPage. |
|
184 |
|
185 Validates the content of the page. |
|
186 |
|
187 @return true if content is valid. |
|
188 */ |
|
189 bool EapWizardPageUsernamePassword::showPage() |
|
190 { |
|
191 OstTraceFunctionEntry0( EAPWIZARDPAGEUSERNAMEPASSWORD_SHOWPAGE_ENTRY ); |
|
192 bool valid = false; |
|
193 if (mValidatorUsername->validate(mEditUsername->text()) == |
|
194 EapQtValidator::StatusOk && |
|
195 mValidatorPassword->validate(mEditPassword->text()) == |
|
196 EapQtValidator::StatusOk) { |
|
197 valid = true; |
|
198 } |
|
199 OstTraceFunctionExit0( EAPWIZARDPAGEUSERNAMEPASSWORD_SHOWPAGE_EXIT ); |
|
200 return valid; |
|
201 } |
|
202 |
|
203 /*! |
|
204 See WlanWizardPage. |
|
205 |
|
206 @return next wizard page: EapWizardPage::PageProcessSettings |
|
207 */ |
|
208 int EapWizardPageUsernamePassword::nextId() const |
|
209 { |
|
210 OstTraceFunctionEntry0( EAPWIZARDPAGEUSERNAMEPASSWORD_NEXTID_ENTRY ); |
|
211 mWizard->setConfigurations(EapWizardPrivate::Username, mEditUsername->text()); |
|
212 mWizard->setConfigurations(EapWizardPrivate::Password, mEditPassword->text()); |
|
213 OstTraceFunctionExit0( EAPWIZARDPAGEUSERNAMEPASSWORD_NEXTID_EXIT ); |
|
214 return EapWizardPage::PageProcessSettings; |
|
215 } |
|
216 |
|
217 /*! |
|
218 Slot for textChanged() signal from HbLineEdit. |
|
219 |
|
220 @param [in] text NOT USED. |
|
221 */ |
|
222 void EapWizardPageUsernamePassword::textChanged(const QString & text ) |
|
223 { |
|
224 OstTraceFunctionEntry0( EAPWIZARDPAGEUSERNAMEPASSWORD_TEXTCHANGED_ENTRY ); |
|
225 Q_UNUSED(text); |
|
226 mWizard->wizardHelper()->enableNextButton(showPage()); |
|
227 OstTraceFunctionExit0( EAPWIZARDPAGEUSERNAMEPASSWORD_TEXTCHANGED_EXIT ); |
|
228 } |
|