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