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-MSCHAPv2 New Password Input Dialog implementation |
|
16 * |
|
17 */ |
|
18 |
|
19 /* |
|
20 * %version: 6 % |
|
21 */ |
|
22 |
|
23 // System includes |
|
24 #include <HbAction> |
|
25 #include <HbLineEdit> |
|
26 #include <HbTranslator> |
|
27 #include <HbMessageBox> |
|
28 #include <eapqtvalidator.h> |
|
29 #include <eapqtexpandedeaptype.h> |
|
30 #include <eapqtconfiginterface.h> |
|
31 #include <eapqtconfig.h> |
|
32 |
|
33 // User includes |
|
34 #include "eapmschapv2newpwddialog.h" |
|
35 #include "OstTraceDefinitions.h" |
|
36 #ifdef OST_TRACE_COMPILER_IN_USE |
|
37 #include "eapmschapv2newpwddialogTraces.h" |
|
38 #endif |
|
39 |
|
40 /*! |
|
41 * \class EapMschapv2NewPwdDialog |
|
42 * \brief Implements EAP-MSCHAPv2 New Password Input Dialog. |
|
43 */ |
|
44 |
|
45 // External function prototypes |
|
46 |
|
47 // Local constants |
|
48 |
|
49 // ======== LOCAL FUNCTIONS ======== |
|
50 |
|
51 // ======== MEMBER FUNCTIONS ======== |
|
52 |
|
53 /*! |
|
54 * Constructor. |
|
55 * |
|
56 * @param [in] parameters Parameters for the Constructor. |
|
57 */ |
|
58 EapMschapv2NewPwdDialog::EapMschapv2NewPwdDialog(const QVariantMap ¶meters) |
|
59 :mEdit1(NULL), |
|
60 mEdit2(NULL), |
|
61 mPwdValidator(NULL), |
|
62 mTranslator(new HbTranslator("eapprompts")), |
|
63 mErrMsgTranslator(new HbTranslator("cpdestinationplugin")), |
|
64 mClose(false) |
|
65 { |
|
66 OstTraceFunctionEntry0( EAPMSCHAPV2NEWPWDDIALOG_EAPMSCHAPV2NEWPWDDIALOG_ENTRY ); |
|
67 qDebug("EapMschapv2NewPwdDialog::EapMschapv2NewPwdDialog ENTER"); |
|
68 |
|
69 createDialog(parameters); |
|
70 |
|
71 OstTraceFunctionExit0( EAPMSCHAPV2NEWPWDDIALOG_EAPMSCHAPV2NEWPWDDIALOG_EXIT ); |
|
72 qDebug("EapMschapv2NewPwdDialog::EapMschapv2NewPwdDialog EXIT"); |
|
73 } |
|
74 |
|
75 /*! |
|
76 * The construction of the dialog |
|
77 * |
|
78 * @param [in] parameters Parameters for the Construction of the dialog. |
|
79 */ |
|
80 void EapMschapv2NewPwdDialog::createDialog(const QVariantMap ¶meters ) |
|
81 { |
|
82 OstTraceFunctionEntry0( EAPMSCHAPV2NEWPWDDIALOG_CREATEDIALOG_ENTRY ); |
|
83 qDebug("EapMschapv2NewPwdDialog::createDialog ENTER"); |
|
84 |
|
85 Q_UNUSED(parameters) |
|
86 |
|
87 QString labelText1(hbTrId("txt_occ_dialog_new_eapmschapv2_password")); |
|
88 QString labelText2(hbTrId("txt_occ_dialog_verify_password")); |
|
89 |
|
90 //Set the dialog to be on the screen until user reacts |
|
91 //by pressing any of the Action buttons |
|
92 this->setModal(true); |
|
93 this->setTimeout(HbPopup::NoTimeout); |
|
94 this->setDismissPolicy(HbPopup::NoDismiss); |
|
95 this->setAdditionalRowVisible(true); |
|
96 |
|
97 //Set the first Line Edit to be on the screen |
|
98 this->setPromptText(labelText1, 0); |
|
99 mEdit1 = this->lineEdit(0); |
|
100 mEdit1->setEchoMode(HbLineEdit::Password); |
|
101 |
|
102 //Set the second Line Edit to be on the screen also |
|
103 this->setPromptText(labelText2, 1); |
|
104 mEdit2 = this->lineEdit(1); |
|
105 mEdit2->setEchoMode(HbLineEdit::Password); |
|
106 |
|
107 EapQtConfigInterface eapConfigIf; |
|
108 |
|
109 mPwdValidator.reset( eapConfigIf.validatorEap(EapQtExpandedEapType::TypeEapMschapv2, |
|
110 EapQtConfig::Password ) ); |
|
111 Q_ASSERT( mPwdValidator.isNull() == false ); |
|
112 |
|
113 mPwdValidator->updateEditor(mEdit1); |
|
114 |
|
115 //Remove all default actions from the dialog |
|
116 QList<QAction*> action_list = this->actions(); |
|
117 for ( int i = 0; i < action_list.count(); i++ ) { |
|
118 this->removeAction(action_list.at(i)); |
|
119 } |
|
120 |
|
121 //Add a new Ok button action |
|
122 HbAction* actionOk = new HbAction(hbTrId("txt_common_button_ok"),this); |
|
123 this->addAction(actionOk); |
|
124 |
|
125 //Add a new Cancel button action |
|
126 HbAction* actionCancel = new HbAction(hbTrId("txt_common_button_cancel"),this); |
|
127 this->addAction(actionCancel); |
|
128 |
|
129 //Disconnect action Ok from the default SLOT and connect to |
|
130 //a SLOT owned by this class |
|
131 disconnect(actionOk, SIGNAL(triggered()),this, SLOT(close())); |
|
132 bool connected = connect(actionOk, SIGNAL(triggered()), this, SLOT(okPressed())); |
|
133 Q_ASSERT(connected == true); |
|
134 |
|
135 //Disconnect action Cancel from the default SLOT and connect to |
|
136 //a SLOT owned by this class |
|
137 disconnect(actionCancel, SIGNAL(triggered()),this, SLOT(close())); |
|
138 connected = connect(actionCancel, SIGNAL(triggered()), this, SLOT(cancelPressed())); |
|
139 Q_ASSERT(connected == true); |
|
140 |
|
141 //Connect the about to close and hide signals, so that we are able to inform |
|
142 //the caller that the dialog was closed |
|
143 connected = connect(this, SIGNAL(aboutToClose()), this, SLOT(closingDialog())); |
|
144 Q_ASSERT(connected == true); |
|
145 connected = connect(this, SIGNAL(aboutToHide()), this, SLOT(closingDialog())); |
|
146 Q_ASSERT(connected == true); |
|
147 |
|
148 OstTraceFunctionExit0( DUP1_EAPMSCHAPV2NEWPWDDIALOG_CREATEDIALOG_EXIT ); |
|
149 qDebug("EapMschapv2NewPwdDialog::createDialog EXIT"); |
|
150 } |
|
151 |
|
152 /*! |
|
153 * Destructor. |
|
154 */ |
|
155 EapMschapv2NewPwdDialog::~EapMschapv2NewPwdDialog() |
|
156 { |
|
157 OstTraceFunctionEntry0( EAPMSCHAPV2NEWPWDDIALOG_DEAPMSCHAPV2NEWPWDDIALOG_ENTRY ); |
|
158 qDebug("EapMschapv2NewPwdDialog::~EapMschapv2NewPwdDialog"); |
|
159 |
|
160 //The dialog widgets are deleted as the dialog is deleted |
|
161 //mPwdValidator: scoped pointer deleted automatically |
|
162 |
|
163 OstTraceFunctionExit0( EAPMSCHAPV2NEWPWDDIALOG_DEAPMSCHAPV2NEWPWDDIALOG_EXIT ); |
|
164 } |
|
165 |
|
166 /*! |
|
167 * Line edit validator |
|
168 * |
|
169 * @return true if content is valid. |
|
170 */ |
|
171 bool EapMschapv2NewPwdDialog::validate() const |
|
172 { |
|
173 qDebug("EapMschapv2NewPwdDialog::validate ENTER"); |
|
174 |
|
175 bool valid = false; |
|
176 |
|
177 if ( mPwdValidator->validate(mEdit1->text())== EapQtValidator::StatusOk && |
|
178 mEdit1->text() == mEdit2->text()) { |
|
179 qDebug("EapMschapv2NewPwdDialog::validate: ret val: TRUE"); |
|
180 valid = true; |
|
181 } |
|
182 qDebug("EapPasswordQueryDialog::validate EXIT"); |
|
183 return valid; |
|
184 } |
|
185 |
|
186 /*! |
|
187 * Function is called when the Ok Action button is pressed |
|
188 */ |
|
189 void EapMschapv2NewPwdDialog::okPressed() |
|
190 { |
|
191 OstTraceFunctionEntry0( EAPMSCHAPV2NEWPWDDIALOG_OKPRESSED_ENTRY ); |
|
192 qDebug("EapMschapv2NewPwdDialog::okPressed ENTER"); |
|
193 |
|
194 if ( validate() == true ) { |
|
195 |
|
196 QVariantMap data; |
|
197 |
|
198 data["password"] = mEdit1->text(); |
|
199 |
|
200 qDebug("EapMschapv2NewPwdDialog::okPressed: emit deviceDialogData"); |
|
201 |
|
202 emit deviceDialogData(data); |
|
203 closeDeviceDialog(true); |
|
204 } |
|
205 else { |
|
206 HbMessageBox* box = new HbMessageBox(hbTrId("txt_occ_info_passwords_do_not_match_try_again"), |
|
207 HbMessageBox::MessageTypeInformation); |
|
208 |
|
209 box->setAttribute(Qt::WA_DeleteOnClose); |
|
210 box->open(); |
|
211 } |
|
212 OstTraceFunctionExit0( EAPMSCHAPV2NEWPWDDIALOG_OKPRESSED_EXIT ); |
|
213 qDebug("EapMschapv2NewPwdDialog::okPressed EXIT"); |
|
214 } |
|
215 |
|
216 /*! |
|
217 * Function is called when the Cancel Action button is pressed |
|
218 */ |
|
219 void EapMschapv2NewPwdDialog::cancelPressed() |
|
220 { |
|
221 OstTraceFunctionEntry0( EAPMSCHAPV2NEWPWDDIALOG_CANCELPRESSED_ENTRY ); |
|
222 qDebug("EapMschapv2NewPwdDialog::cancelPressed ENTER"); |
|
223 |
|
224 if (!mClose) { |
|
225 mClose = true; |
|
226 closeDeviceDialog(true); |
|
227 } |
|
228 qDebug("EapMschapv2NewPwdDialog::cancelPressed EXIT"); |
|
229 OstTraceFunctionExit0( EAPMSCHAPV2NEWPWDDIALOG_CANCELPRESSED_EXIT ); |
|
230 } |
|
231 |
|
232 /*! |
|
233 * Function is called when the dialog is about to close |
|
234 */ |
|
235 void EapMschapv2NewPwdDialog::closingDialog() |
|
236 { |
|
237 OstTraceFunctionEntry0( EAPMSCHAPV2NEWPWDDIALOG_CLOSINGDIALOG_ENTRY ); |
|
238 qDebug("EapMschapv2NewPwdDialog::closingDialog ENTER"); |
|
239 |
|
240 qDebug("EapMschapv2NewPwdDialog::closingDialog EXIT"); |
|
241 OstTraceFunctionExit0( EAPMSCHAPV2NEWPWDDIALOG_CLOSINGDIALOG_EXIT ); |
|
242 } |
|
243 |
|
244 /*! |
|
245 * Device dialog parameters to be set while dialog is displayed. |
|
246 * Not supported. |
|
247 * |
|
248 * @param [in] parameters NOT USED |
|
249 * @return true always. |
|
250 */ |
|
251 bool EapMschapv2NewPwdDialog::setDeviceDialogParameters |
|
252 (const QVariantMap ¶meters) |
|
253 { |
|
254 OstTraceFunctionEntry0( EAPMSCHAPV2NEWPWDDIALOG_SETDEVICEDIALOGPARAMETERS_ENTRY ); |
|
255 |
|
256 Q_UNUSED(parameters) |
|
257 // changing the dialog after presenting it is not supported. |
|
258 |
|
259 OstTraceFunctionExit0( EAPMSCHAPV2NEWPWDDIALOG_SETDEVICEDIALOGPARAMETERS_EXIT ); |
|
260 return true; |
|
261 } |
|
262 |
|
263 /*! |
|
264 * Not supported |
|
265 * |
|
266 * @return 0 always returned. |
|
267 */ |
|
268 int EapMschapv2NewPwdDialog::deviceDialogError() const |
|
269 { |
|
270 OstTraceFunctionEntry0( EAPMSCHAPV2NEWPWDDIALOG_DEVICEDIALOGERROR_ENTRY ); |
|
271 OstTraceFunctionExit0( EAPMSCHAPV2NEWPWDDIALOG_DEVICEDIALOGERROR_EXIT); |
|
272 return 0; |
|
273 } |
|
274 |
|
275 /*! |
|
276 * Dialog is closed and the signal about closing is emitted |
|
277 * |
|
278 * @param [in] byClient indicates when the user closes the dialog |
|
279 */ |
|
280 void EapMschapv2NewPwdDialog::closeDeviceDialog(bool byClient) |
|
281 { |
|
282 OstTraceFunctionEntry0( EAPMSCHAPV2NEWPWDDIALOG_CLOSEDEVICEDIALOG_ENTRY ); |
|
283 qDebug("EapMschapv2NewPwdDialog::closeDeviceDialog ENTER"); |
|
284 |
|
285 //If the user closes the dialog, then the deviceDialogClosed is emitted |
|
286 if( byClient == true ) { |
|
287 qDebug("EapMschapv2NewPwdDialog::closeDeviceDialog: emit deviceDialogClosed"); |
|
288 emit deviceDialogClosed(); |
|
289 } |
|
290 |
|
291 qDebug("EapMschapv2NewPwdDialog::closeDeviceDialog EXIT"); |
|
292 OstTraceFunctionExit0( EAPMSCHAPV2NEWPWDDIALOG_CLOSEDEVICEDIALOG_EXIT ); |
|
293 } |
|
294 |
|
295 /*! |
|
296 * This dialog widget is returned to the caller |
|
297 * |
|
298 * @return this dialog widget |
|
299 */ |
|
300 HbPopup *EapMschapv2NewPwdDialog::deviceDialogWidget() const |
|
301 { |
|
302 OstTraceFunctionEntry0( EAPMSCHAPV2NEWPWDDIALOG_DEVICEDIALOGWIDGET_ENTRY ); |
|
303 OstTraceFunctionExit0( EAPMSCHAPV2NEWPWDDIALOG_DEVICEDIALOGWIDGET_EXIT ); |
|
304 |
|
305 return const_cast<EapMschapv2NewPwdDialog*>(this); |
|
306 } |
|
307 |
|