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