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