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