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