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