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