|
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: New PAC store password |
|
16 * |
|
17 */ |
|
18 |
|
19 // System includes |
|
20 #include <HbDocumentLoader> |
|
21 #include <HbMainWindow> |
|
22 #include <HbWidget> |
|
23 #include <HbLineEdit> |
|
24 #include <HbLabel> |
|
25 #include <eapqtexpandedeaptype.h> |
|
26 #include <eapqtconfiginterface.h> |
|
27 #include <eapqtconfig.h> |
|
28 #include <eapqtvalidator.h> |
|
29 |
|
30 // User includes |
|
31 #include "wlanwizardhelper.h" |
|
32 #include "eapwizardpagepacstorepasswordconfirm.h" |
|
33 #include "eapwizard_p.h" |
|
34 |
|
35 /*! |
|
36 \class EapWizardPagePacStorePasswordConfirm |
|
37 \brief Implements EAP wizard page: Confirm PAC store password |
|
38 */ |
|
39 |
|
40 // External function prototypes |
|
41 |
|
42 // Local constants |
|
43 |
|
44 // ======== LOCAL FUNCTIONS ======== |
|
45 |
|
46 // ======== MEMBER FUNCTIONS ======== |
|
47 |
|
48 |
|
49 /*! |
|
50 Constructor. |
|
51 |
|
52 @param [in] parent Pointer to EAP Wizard private implementation. |
|
53 */ |
|
54 EapWizardPagePacStorePasswordConfirm::EapWizardPagePacStorePasswordConfirm( |
|
55 EapWizardPrivate* parent) : |
|
56 EapWizardPage(parent), |
|
57 mDocumentLoader(NULL), |
|
58 mValidator(NULL), |
|
59 mWidget(NULL), |
|
60 mEditPasswordConfirm(NULL), |
|
61 mLabelError(NULL) |
|
62 { |
|
63 } |
|
64 |
|
65 /*! |
|
66 Destructor. |
|
67 */ |
|
68 EapWizardPagePacStorePasswordConfirm::~EapWizardPagePacStorePasswordConfirm() |
|
69 { |
|
70 } |
|
71 |
|
72 /*! |
|
73 See WlanWizardPage. |
|
74 */ |
|
75 HbWidget* EapWizardPagePacStorePasswordConfirm::initializePage() |
|
76 { |
|
77 if (!mWidget) { |
|
78 bool ok; |
|
79 mDocumentLoader.reset( |
|
80 new HbDocumentLoader(mWizard->wizardHelper()->mainWindow())); |
|
81 mDocumentLoader->load(":/docml/occ_eap_wizard_08.docml", &ok); |
|
82 Q_ASSERT(ok); |
|
83 |
|
84 loadDocmlSection(mWizard->wizardHelper()->mainWindow()->orientation()); |
|
85 |
|
86 mWidget = qobject_cast<HbWidget*> (mDocumentLoader->findWidget("view")); |
|
87 Q_ASSERT(mWidget); |
|
88 |
|
89 mEditPasswordConfirm = qobject_cast<HbLineEdit*> (mDocumentLoader->findWidget( |
|
90 "lineEditPasswordConfirm")); |
|
91 Q_ASSERT(mEditPasswordConfirm); |
|
92 |
|
93 mLabelError = qobject_cast<HbLabel*> (mDocumentLoader->findWidget("labelError")); |
|
94 Q_ASSERT(mLabelError); |
|
95 |
|
96 mValidator.reset( |
|
97 mWizard->eapConfigurationInterface()->validatorPacStore( |
|
98 EapQtPacStoreConfig::PacStorePasswordConfirmation)); |
|
99 Q_ASSERT(mValidator.data()); |
|
100 |
|
101 mLabelError->setPlainText(""); |
|
102 // Configurate editor properties and configurations |
|
103 mValidator->updateEditor(mEditPasswordConfirm); |
|
104 |
|
105 mEditPasswordConfirm->installEventFilter(this); |
|
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 |
|
115 return mWidget; |
|
116 } |
|
117 |
|
118 |
|
119 /*! |
|
120 Loads the required orientation of docml. |
|
121 |
|
122 @param [in] orientation Orientation to be loaded. |
|
123 */ |
|
124 void EapWizardPagePacStorePasswordConfirm::loadDocmlSection(Qt::Orientation orientation) |
|
125 { |
|
126 EapWizardPage::loadDocmlSection( |
|
127 mDocumentLoader.data(), |
|
128 orientation, |
|
129 ":/docml/occ_eap_wizard_08.docml", |
|
130 "portrait_section", |
|
131 "landscape_section"); |
|
132 } |
|
133 |
|
134 /*! |
|
135 See WlanWizardPage. |
|
136 |
|
137 @return next wizard page: |
|
138 - EapWizardPage::PageUsernamePassword: When password is ok |
|
139 - WlanWizardPage::PageNone: When password is not ok |
|
140 */ |
|
141 int EapWizardPagePacStorePasswordConfirm::nextId() const |
|
142 { |
|
143 int id; |
|
144 if (mValidator->validate(mEditPasswordConfirm->text()) == |
|
145 EapQtValidator::StatusOk) { |
|
146 |
|
147 mWizard->setConfigurations( |
|
148 EapWizardPrivate::PacStorePassword, |
|
149 mEditPasswordConfirm->text()); |
|
150 |
|
151 id = EapWizardPage::PageUsernamePassword; |
|
152 } else { |
|
153 id = WlanWizardPage::PageNone; |
|
154 mLabelError->setPlainText(hbTrId("txt_occ_info_incorrect_password")); |
|
155 } |
|
156 |
|
157 return id; |
|
158 } |
|
159 |
|
160 /*! |
|
161 See WlanWizardPage::showPage(). |
|
162 |
|
163 Sets the focus to line editor, opens virtual keyboard. |
|
164 |
|
165 @return true, content is valid always. |
|
166 */ |
|
167 bool EapWizardPagePacStorePasswordConfirm::showPage() |
|
168 { |
|
169 mEditPasswordConfirm->setFocus(); |
|
170 return true; |
|
171 } |
|
172 |
|
173 /*! |
|
174 Event filter for HbLineEdit. When editor gets focus a possible error text |
|
175 is cleared. |
|
176 |
|
177 @param [in] obj Pointer to object to where the event is sent |
|
178 @param [in] event Event |
|
179 */ |
|
180 bool EapWizardPagePacStorePasswordConfirm::eventFilter( |
|
181 QObject *obj, QEvent *event) |
|
182 { |
|
183 if (obj == mEditPasswordConfirm && event->type() == QEvent::FocusIn) { |
|
184 mLabelError->setPlainText(""); |
|
185 } |
|
186 return false; |
|
187 } |