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