26
|
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 |
*
|
36
|
14 |
* Description:
|
|
15 |
* User authentication Dialog implementation
|
26
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
34
|
19 |
/*
|
36
|
20 |
* %version: 5 %
|
34
|
21 |
*/
|
|
22 |
|
36
|
23 |
// System includes
|
26
|
24 |
#include <eapqtvalidator.h>
|
|
25 |
#include <eapqtexpandedeaptype.h>
|
|
26 |
#include <eapqtconfiginterface.h>
|
|
27 |
#include <eapqtconfig.h>
|
34
|
28 |
#include <HbParameterLengthLimiter>
|
|
29 |
#include <HbTranslator>
|
|
30 |
#include <HbLineEdit>
|
|
31 |
#include <HbAction>
|
36
|
32 |
|
|
33 |
// User includes
|
26
|
34 |
#include "eapusernamepwddialog.h"
|
|
35 |
#include "OstTraceDefinitions.h"
|
|
36 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
37 |
|
|
38 |
#endif
|
|
39 |
|
36
|
40 |
/*!
|
|
41 |
* \class EapUsernamePwdDialog
|
|
42 |
* \brief Implements Username Password Input Dialog.
|
|
43 |
*/
|
|
44 |
|
|
45 |
// External function prototypes
|
|
46 |
|
|
47 |
// Local constants
|
|
48 |
|
|
49 |
// ======== LOCAL FUNCTIONS ========
|
|
50 |
|
|
51 |
// ======== MEMBER FUNCTIONS ========
|
|
52 |
|
|
53 |
/*!
|
|
54 |
* Constructor.
|
|
55 |
*
|
|
56 |
* @param [in] parameters Parameters for the Constructor.
|
26
|
57 |
*/
|
|
58 |
EapUsernamePwdDialog::EapUsernamePwdDialog(const QVariantMap ¶meters)
|
|
59 |
:mEdit1(NULL),
|
|
60 |
mEdit2(NULL),
|
|
61 |
mUnameValidator(NULL),
|
|
62 |
mPwdValidator(NULL),
|
34
|
63 |
mTranslator(new HbTranslator("eapprompts")),
|
|
64 |
mClose(false),
|
|
65 |
mOkActionPressed(false)
|
26
|
66 |
{
|
|
67 |
OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_EAPUSERNAMEPWDDIALOG_ENTRY );
|
|
68 |
qDebug("EapUsernamePwdDialog::EapUsernamePwdDialog ENTER");
|
|
69 |
|
|
70 |
createDialog(parameters);
|
34
|
71 |
|
26
|
72 |
OstTraceFunctionExit0( EAPUSERNAMEPWDDIALOG_EAPUSERNAMEPWDDIALOG_EXIT );
|
|
73 |
qDebug("EapUsernamePwdDialog::EapUsernamePwdDialog EXIT");
|
|
74 |
}
|
|
75 |
|
36
|
76 |
/*!
|
26
|
77 |
* The construction of the dialog
|
36
|
78 |
*
|
|
79 |
* @param [in] parameters Parameters for the Construction of the dialog.
|
26
|
80 |
*/
|
|
81 |
void EapUsernamePwdDialog::createDialog(const QVariantMap ¶meters )
|
|
82 |
{
|
|
83 |
OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_CREATEDIALOG_ENTRY );
|
|
84 |
qDebug("EapUsernamePwdDialog::createDialog ENTER");
|
|
85 |
|
34
|
86 |
QString keyauthmethod("authmethod");
|
|
87 |
QString keyuname("username");
|
|
88 |
QString keyeaptype("eaptype");
|
26
|
89 |
|
34
|
90 |
QString unamestr;
|
|
91 |
QString authMethodstr;
|
|
92 |
|
|
93 |
//Get default username (if exists) and
|
|
94 |
//auth method strings from parameters
|
26
|
95 |
if ( parameters.empty() == false ) {
|
|
96 |
if ( parameters.contains(keyuname) ) {
|
|
97 |
QVariant variant = parameters.value(keyuname);
|
|
98 |
unamestr = variant.toString();
|
|
99 |
}
|
|
100 |
if ( parameters.contains(keyauthmethod) ) {
|
|
101 |
QVariant variant = parameters.value(keyauthmethod);
|
|
102 |
authMethodstr = variant.toString();
|
|
103 |
}
|
|
104 |
}
|
|
105 |
|
34
|
106 |
QString labelText1(HbParameterLengthLimiter(hbTrId("txt_occ_dialog_1_user_name")).arg(authMethodstr));
|
|
107 |
QString labelText2(HbParameterLengthLimiter(hbTrId("txt_occ_dialog_password")));
|
26
|
108 |
|
|
109 |
//Set the dialog to be on the screen until user reacts
|
|
110 |
//by pressing any of the Action buttons
|
|
111 |
this->setModal(true);
|
|
112 |
this->setTimeout(HbPopup::NoTimeout);
|
|
113 |
this->setDismissPolicy(HbPopup::NoDismiss);
|
|
114 |
this->setAdditionalRowVisible(true);
|
|
115 |
|
36
|
116 |
//Set the first Line Edit (user name) to be on the screen
|
26
|
117 |
this->setPromptText(labelText1, 0);
|
|
118 |
mEdit1 = this->lineEdit(0);
|
36
|
119 |
//Set default user name string
|
26
|
120 |
mEdit1->setText(unamestr);
|
|
121 |
|
36
|
122 |
//Set the second Line Edit (password) to be on the screen also
|
26
|
123 |
this->setPromptText(labelText2, 1);
|
|
124 |
mEdit2 = this->lineEdit(1);
|
34
|
125 |
|
|
126 |
//Get the EAP type for the Line Edits (Validator)
|
26
|
127 |
QByteArray ba;
|
|
128 |
if ( parameters.contains(keyeaptype) ) {
|
|
129 |
QVariant variant = parameters.value(keyeaptype);
|
|
130 |
ba = variant.toByteArray();
|
|
131 |
}
|
34
|
132 |
Q_ASSERT( ba.isEmpty() == false );
|
26
|
133 |
EapQtExpandedEapType e_type(ba);
|
|
134 |
EapQtConfigInterface eap_config_if;
|
|
135 |
|
34
|
136 |
mUnameValidator.reset(eap_config_if.validatorEap(e_type,
|
|
137 |
EapQtConfig::Username));
|
|
138 |
Q_ASSERT( mUnameValidator.isNull() == false );
|
|
139 |
|
26
|
140 |
mUnameValidator->updateEditor(mEdit1);
|
|
141 |
|
34
|
142 |
mPwdValidator.reset(eap_config_if.validatorEap(e_type,
|
|
143 |
EapQtConfig::Password));
|
|
144 |
Q_ASSERT( mPwdValidator.isNull() == false );
|
|
145 |
|
26
|
146 |
mPwdValidator->updateEditor(mEdit2);
|
34
|
147 |
|
|
148 |
//Remove all default actions from the dialog
|
|
149 |
QList<QAction*> action_list = this->actions();
|
26
|
150 |
for ( int i = 0; i < action_list.count(); i++ ) {
|
|
151 |
this->removeAction(action_list.at(i));
|
|
152 |
}
|
|
153 |
|
34
|
154 |
//Add a new Ok button action
|
26
|
155 |
HbAction* actionOk = new HbAction(hbTrId("txt_common_button_ok"),this);
|
|
156 |
this->addAction(actionOk);
|
34
|
157 |
//Add a new Cancel button action
|
26
|
158 |
HbAction* actionCancel = new HbAction(hbTrId("txt_common_button_cancel"),this);
|
|
159 |
this->addAction( actionCancel );
|
34
|
160 |
|
|
161 |
//Disconnect action Ok from the default SLOT and connect to
|
|
162 |
//a SLOT owned by this class
|
26
|
163 |
disconnect(actionOk, SIGNAL(triggered()),this, SLOT(close()));
|
|
164 |
bool connected = connect(actionOk, SIGNAL(triggered()), this, SLOT(okPressed()));
|
|
165 |
Q_ASSERT(connected == true);
|
|
166 |
|
34
|
167 |
//Disconnect action Cancel from the default SLOT and connect to
|
|
168 |
//a SLOT owned by this class
|
26
|
169 |
disconnect(actionCancel, SIGNAL(triggered()),this, SLOT(close()));
|
|
170 |
connected = connect(actionCancel, SIGNAL(triggered()), this, SLOT(cancelPressed()));
|
|
171 |
Q_ASSERT(connected == true);
|
|
172 |
|
|
173 |
// Connect the about to close and hide signals, so that we are able to inform
|
|
174 |
// the caller that the dialog was closed
|
|
175 |
connected = connect(this, SIGNAL(aboutToClose()), this, SLOT(closingDialog()));
|
|
176 |
Q_ASSERT(connected == true);
|
|
177 |
connected = connect(this, SIGNAL(aboutToHide()), this, SLOT(closingDialog()));
|
|
178 |
Q_ASSERT(connected == true);
|
|
179 |
|
|
180 |
OstTraceFunctionExit0( DUP1_EAPUSERNAMEPWDDIALOG_CREATEDIALOG_EXIT );
|
|
181 |
qDebug("EapUsernamePwdDialog::createDialog EXIT");
|
|
182 |
}
|
|
183 |
|
36
|
184 |
/*!
|
26
|
185 |
* Destructor
|
|
186 |
*/
|
|
187 |
EapUsernamePwdDialog::~EapUsernamePwdDialog()
|
|
188 |
{
|
|
189 |
OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_DEAPUSERNAMEPWDDIALOG_ENTRY );
|
|
190 |
qDebug("EapUsernamePwdDialog::~EapUsernamePwdDialog");
|
|
191 |
|
|
192 |
//The dialog widgets are deleted as the dialog is deleted
|
34
|
193 |
// mPwdValidator: scoped pointer deleted automatically
|
|
194 |
// mUnameValidator: scoped pointer deleted automatically
|
26
|
195 |
|
|
196 |
OstTraceFunctionExit0( EAPUSERNAMEPWDDIALOG_DEAPUSERNAMEPWDDIALOG_EXIT );
|
|
197 |
}
|
|
198 |
|
36
|
199 |
/*!
|
|
200 |
* Line edit validator
|
|
201 |
*
|
|
202 |
* @return true if content is valid.
|
26
|
203 |
*/
|
|
204 |
bool EapUsernamePwdDialog::validate() const
|
|
205 |
{
|
|
206 |
qDebug("EapUsernamePwdDialog::validate ENTER");
|
|
207 |
|
|
208 |
bool valid = false;
|
|
209 |
|
|
210 |
if ( mUnameValidator->validate(mEdit1->text())== EapQtValidator::StatusOk &&
|
|
211 |
mPwdValidator->validate(mEdit2->text()) == EapQtValidator::StatusOk ) {
|
|
212 |
|
|
213 |
qDebug("EapUsernamePwdDialog::validate(): returns TRUE");
|
|
214 |
valid = true;
|
|
215 |
}
|
|
216 |
|
|
217 |
qDebug("EapUsernamePwdDialog::validate EXIT");
|
|
218 |
return valid;
|
|
219 |
}
|
|
220 |
|
36
|
221 |
/*!
|
26
|
222 |
* Function is called when the Ok Action button is pressed
|
|
223 |
*/
|
|
224 |
void EapUsernamePwdDialog::okPressed()
|
|
225 |
{
|
|
226 |
OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_OKPRESSED_ENTRY );
|
|
227 |
qDebug("EapUsernamePwdDialog::okPressed ENTER");
|
|
228 |
|
|
229 |
if ( validate() == true && mOkActionPressed == false ) {
|
|
230 |
|
|
231 |
mOkActionPressed = true;
|
|
232 |
|
|
233 |
QVariantMap data;
|
34
|
234 |
|
|
235 |
data["username"] = mEdit1->text();
|
|
236 |
data["password"] = mEdit2->text();
|
26
|
237 |
|
|
238 |
qDebug("EapUsernamePwdDialog::okPressed: emit deviceDialogData");
|
|
239 |
|
|
240 |
emit deviceDialogData(data);
|
|
241 |
closeDeviceDialog(true);
|
|
242 |
}
|
|
243 |
OstTraceFunctionExit0( EAPUSERNAMEPWDDIALOG_OKPRESSED_EXIT );
|
|
244 |
qDebug("EapUsernamePwdDialog::okPressed EXIT");
|
|
245 |
}
|
|
246 |
|
36
|
247 |
/*!
|
26
|
248 |
* Function is called when the Cancel Action button is pressed
|
|
249 |
*/
|
|
250 |
void EapUsernamePwdDialog::cancelPressed()
|
|
251 |
{
|
|
252 |
OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_CANCELPRESSED_ENTRY );
|
|
253 |
qDebug("EapUsernamePwdDialog::cancelPressed ENTER");
|
|
254 |
|
|
255 |
if (!mClose) {
|
|
256 |
mClose = true;
|
|
257 |
closeDeviceDialog(true);
|
|
258 |
}
|
|
259 |
qDebug("EapUsernamePwdDialog::cancelPressed EXIT");
|
|
260 |
OstTraceFunctionExit0( EAPUSERNAMEPWDDIALOG_CANCELPRESSED_EXIT );
|
|
261 |
}
|
|
262 |
|
36
|
263 |
/*!
|
26
|
264 |
* Function is called when the dialog is about to close
|
|
265 |
*/
|
|
266 |
void EapUsernamePwdDialog::closingDialog()
|
|
267 |
{
|
|
268 |
OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_CLOSINGDIALOG_ENTRY );
|
|
269 |
qDebug("EapUsernamePwdDialog::closingDialog ENTER");
|
34
|
270 |
|
26
|
271 |
qDebug("EapUsernamePwdDialog::closingDialog EXIT");
|
|
272 |
OstTraceFunctionExit0( EAPUSERNAMEPWDDIALOG_CLOSINGDIALOG_EXIT );
|
|
273 |
}
|
|
274 |
|
36
|
275 |
/*!
|
|
276 |
* Device dialog parameters to be set while dialog is displayed.
|
|
277 |
* Not supported.
|
|
278 |
*
|
|
279 |
* @param [in] parameters NOT USED
|
|
280 |
* @return true always.
|
|
281 |
*/
|
26
|
282 |
bool EapUsernamePwdDialog::setDeviceDialogParameters
|
|
283 |
(const QVariantMap ¶meters)
|
|
284 |
{
|
|
285 |
OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_SETDEVICEDIALOGPARAMETERS_ENTRY );
|
|
286 |
|
|
287 |
Q_UNUSED(parameters)
|
|
288 |
// changing the dialog after presenting it is not supported.
|
|
289 |
|
|
290 |
OstTraceFunctionExit0( EAPUSERNAMEPWDDIALOG_SETDEVICEDIALOGPARAMETERS_EXIT );
|
|
291 |
return true;
|
|
292 |
}
|
|
293 |
|
36
|
294 |
/*!
|
|
295 |
* Not supported
|
|
296 |
*
|
|
297 |
* @return 0 always returned.
|
26
|
298 |
*/
|
|
299 |
int EapUsernamePwdDialog::deviceDialogError() const
|
|
300 |
{
|
|
301 |
OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_DEVICEDIALOGERROR_ENTRY );
|
|
302 |
OstTraceFunctionExit0( EAPUSERNAMEPWDDIALOG_DEVICEDIALOGERROR_EXIT);
|
|
303 |
return 0;
|
|
304 |
}
|
|
305 |
|
36
|
306 |
/*!
|
26
|
307 |
* Dialog is closed and the signal about closing is emitted
|
36
|
308 |
*
|
|
309 |
* @param [in] byClient indicates when the user closes the dialog
|
26
|
310 |
*/
|
|
311 |
void EapUsernamePwdDialog::closeDeviceDialog(bool byClient)
|
|
312 |
{
|
|
313 |
OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_CLOSEDEVICEDIALOG_ENTRY );
|
|
314 |
qDebug("EapUsernamePwdDialog::closeDeviceDialog ENTER");
|
|
315 |
|
|
316 |
//If the user closes the dialog, then the deviceDialogClosed is emitted
|
|
317 |
if ( byClient == true )
|
|
318 |
{
|
|
319 |
qDebug("EapUsernamePwdDialog::closeDeviceDialog: emit deviceDialogClosed");
|
|
320 |
emit deviceDialogClosed();
|
|
321 |
}
|
|
322 |
|
|
323 |
qDebug("EapUsernamePwdDialog::closeDeviceDialog EXIT");
|
|
324 |
OstTraceFunctionExit0( EAPUSERNAMEPWDDIALOG_CLOSEDEVICEDIALOG_EXIT );
|
|
325 |
}
|
|
326 |
|
36
|
327 |
/*!
|
26
|
328 |
* This dialog widget is returned to the caller
|
36
|
329 |
*
|
|
330 |
* @return this dialog widget
|
26
|
331 |
*/
|
|
332 |
HbPopup *EapUsernamePwdDialog::deviceDialogWidget() const
|
|
333 |
{
|
|
334 |
OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_DEVICEDIALOGWIDGET_ENTRY );
|
|
335 |
OstTraceFunctionExit0( EAPUSERNAMEPWDDIALOG_DEVICEDIALOGWIDGET_EXIT );
|
|
336 |
|
|
337 |
return const_cast<EapUsernamePwdDialog*>(this);
|
|
338 |
}
|
|
339 |
|