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 |
/*
|
49
|
20 |
* %version: 7 %
|
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
|
44
|
37 |
#include "eapusernamepwddialogTraces.h"
|
26
|
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);
|
49
|
113 |
this->setDismissPolicy(HbPopup::NoDismiss);
|
|
114 |
this->setDismissOnAction(false);
|
26
|
115 |
this->setAdditionalRowVisible(true);
|
|
116 |
|
36
|
117 |
//Set the first Line Edit (user name) to be on the screen
|
26
|
118 |
this->setPromptText(labelText1, 0);
|
|
119 |
mEdit1 = this->lineEdit(0);
|
36
|
120 |
//Set default user name string
|
26
|
121 |
mEdit1->setText(unamestr);
|
|
122 |
|
36
|
123 |
//Set the second Line Edit (password) to be on the screen also
|
26
|
124 |
this->setPromptText(labelText2, 1);
|
|
125 |
mEdit2 = this->lineEdit(1);
|
34
|
126 |
|
|
127 |
//Get the EAP type for the Line Edits (Validator)
|
26
|
128 |
QByteArray ba;
|
|
129 |
if ( parameters.contains(keyeaptype) ) {
|
|
130 |
QVariant variant = parameters.value(keyeaptype);
|
|
131 |
ba = variant.toByteArray();
|
|
132 |
}
|
34
|
133 |
Q_ASSERT( ba.isEmpty() == false );
|
26
|
134 |
EapQtExpandedEapType e_type(ba);
|
|
135 |
EapQtConfigInterface eap_config_if;
|
|
136 |
|
34
|
137 |
mUnameValidator.reset(eap_config_if.validatorEap(e_type,
|
|
138 |
EapQtConfig::Username));
|
|
139 |
Q_ASSERT( mUnameValidator.isNull() == false );
|
|
140 |
|
26
|
141 |
mUnameValidator->updateEditor(mEdit1);
|
|
142 |
|
34
|
143 |
mPwdValidator.reset(eap_config_if.validatorEap(e_type,
|
|
144 |
EapQtConfig::Password));
|
|
145 |
Q_ASSERT( mPwdValidator.isNull() == false );
|
|
146 |
|
26
|
147 |
mPwdValidator->updateEditor(mEdit2);
|
34
|
148 |
|
|
149 |
//Remove all default actions from the dialog
|
|
150 |
QList<QAction*> action_list = this->actions();
|
26
|
151 |
for ( int i = 0; i < action_list.count(); i++ ) {
|
|
152 |
this->removeAction(action_list.at(i));
|
|
153 |
}
|
|
154 |
|
34
|
155 |
//Add a new Ok button action
|
26
|
156 |
HbAction* actionOk = new HbAction(hbTrId("txt_common_button_ok"),this);
|
|
157 |
this->addAction(actionOk);
|
34
|
158 |
//Add a new Cancel button action
|
26
|
159 |
HbAction* actionCancel = new HbAction(hbTrId("txt_common_button_cancel"),this);
|
|
160 |
this->addAction( actionCancel );
|
34
|
161 |
|
49
|
162 |
//Connect to a SLOT owned by this class
|
26
|
163 |
bool connected = connect(actionOk, SIGNAL(triggered()), this, SLOT(okPressed()));
|
|
164 |
Q_ASSERT(connected == true);
|
|
165 |
|
49
|
166 |
//Connect to a SLOT owned by this class
|
26
|
167 |
connected = connect(actionCancel, SIGNAL(triggered()), this, SLOT(cancelPressed()));
|
|
168 |
Q_ASSERT(connected == true);
|
|
169 |
|
|
170 |
// Connect the about to close and hide signals, so that we are able to inform
|
|
171 |
// the caller that the dialog was closed
|
|
172 |
connected = connect(this, SIGNAL(aboutToClose()), this, SLOT(closingDialog()));
|
|
173 |
Q_ASSERT(connected == true);
|
|
174 |
connected = connect(this, SIGNAL(aboutToHide()), this, SLOT(closingDialog()));
|
|
175 |
Q_ASSERT(connected == true);
|
|
176 |
|
|
177 |
OstTraceFunctionExit0( DUP1_EAPUSERNAMEPWDDIALOG_CREATEDIALOG_EXIT );
|
|
178 |
qDebug("EapUsernamePwdDialog::createDialog EXIT");
|
|
179 |
}
|
|
180 |
|
36
|
181 |
/*!
|
26
|
182 |
* Destructor
|
|
183 |
*/
|
|
184 |
EapUsernamePwdDialog::~EapUsernamePwdDialog()
|
|
185 |
{
|
|
186 |
OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_DEAPUSERNAMEPWDDIALOG_ENTRY );
|
|
187 |
qDebug("EapUsernamePwdDialog::~EapUsernamePwdDialog");
|
|
188 |
|
|
189 |
//The dialog widgets are deleted as the dialog is deleted
|
34
|
190 |
// mPwdValidator: scoped pointer deleted automatically
|
|
191 |
// mUnameValidator: scoped pointer deleted automatically
|
26
|
192 |
|
|
193 |
OstTraceFunctionExit0( EAPUSERNAMEPWDDIALOG_DEAPUSERNAMEPWDDIALOG_EXIT );
|
|
194 |
}
|
|
195 |
|
36
|
196 |
/*!
|
|
197 |
* Line edit validator
|
|
198 |
*
|
|
199 |
* @return true if content is valid.
|
26
|
200 |
*/
|
|
201 |
bool EapUsernamePwdDialog::validate() const
|
|
202 |
{
|
|
203 |
qDebug("EapUsernamePwdDialog::validate ENTER");
|
|
204 |
|
|
205 |
bool valid = false;
|
|
206 |
|
|
207 |
if ( mUnameValidator->validate(mEdit1->text())== EapQtValidator::StatusOk &&
|
|
208 |
mPwdValidator->validate(mEdit2->text()) == EapQtValidator::StatusOk ) {
|
|
209 |
|
|
210 |
qDebug("EapUsernamePwdDialog::validate(): returns TRUE");
|
|
211 |
valid = true;
|
|
212 |
}
|
|
213 |
|
|
214 |
qDebug("EapUsernamePwdDialog::validate EXIT");
|
|
215 |
return valid;
|
|
216 |
}
|
|
217 |
|
36
|
218 |
/*!
|
26
|
219 |
* Function is called when the Ok Action button is pressed
|
|
220 |
*/
|
|
221 |
void EapUsernamePwdDialog::okPressed()
|
|
222 |
{
|
|
223 |
OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_OKPRESSED_ENTRY );
|
|
224 |
qDebug("EapUsernamePwdDialog::okPressed ENTER");
|
|
225 |
|
|
226 |
if ( validate() == true && mOkActionPressed == false ) {
|
|
227 |
|
|
228 |
mOkActionPressed = true;
|
|
229 |
|
|
230 |
QVariantMap data;
|
34
|
231 |
|
|
232 |
data["username"] = mEdit1->text();
|
|
233 |
data["password"] = mEdit2->text();
|
26
|
234 |
|
|
235 |
qDebug("EapUsernamePwdDialog::okPressed: emit deviceDialogData");
|
|
236 |
|
|
237 |
emit deviceDialogData(data);
|
|
238 |
closeDeviceDialog(true);
|
|
239 |
}
|
|
240 |
OstTraceFunctionExit0( EAPUSERNAMEPWDDIALOG_OKPRESSED_EXIT );
|
|
241 |
qDebug("EapUsernamePwdDialog::okPressed EXIT");
|
|
242 |
}
|
|
243 |
|
36
|
244 |
/*!
|
26
|
245 |
* Function is called when the Cancel Action button is pressed
|
|
246 |
*/
|
|
247 |
void EapUsernamePwdDialog::cancelPressed()
|
|
248 |
{
|
|
249 |
OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_CANCELPRESSED_ENTRY );
|
|
250 |
qDebug("EapUsernamePwdDialog::cancelPressed ENTER");
|
|
251 |
|
|
252 |
if (!mClose) {
|
|
253 |
mClose = true;
|
|
254 |
closeDeviceDialog(true);
|
|
255 |
}
|
|
256 |
qDebug("EapUsernamePwdDialog::cancelPressed EXIT");
|
|
257 |
OstTraceFunctionExit0( EAPUSERNAMEPWDDIALOG_CANCELPRESSED_EXIT );
|
|
258 |
}
|
|
259 |
|
36
|
260 |
/*!
|
26
|
261 |
* Function is called when the dialog is about to close
|
|
262 |
*/
|
|
263 |
void EapUsernamePwdDialog::closingDialog()
|
|
264 |
{
|
|
265 |
OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_CLOSINGDIALOG_ENTRY );
|
|
266 |
qDebug("EapUsernamePwdDialog::closingDialog ENTER");
|
34
|
267 |
|
26
|
268 |
qDebug("EapUsernamePwdDialog::closingDialog EXIT");
|
|
269 |
OstTraceFunctionExit0( EAPUSERNAMEPWDDIALOG_CLOSINGDIALOG_EXIT );
|
|
270 |
}
|
|
271 |
|
36
|
272 |
/*!
|
|
273 |
* Device dialog parameters to be set while dialog is displayed.
|
|
274 |
* Not supported.
|
|
275 |
*
|
|
276 |
* @param [in] parameters NOT USED
|
|
277 |
* @return true always.
|
|
278 |
*/
|
26
|
279 |
bool EapUsernamePwdDialog::setDeviceDialogParameters
|
|
280 |
(const QVariantMap ¶meters)
|
|
281 |
{
|
|
282 |
OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_SETDEVICEDIALOGPARAMETERS_ENTRY );
|
|
283 |
|
|
284 |
Q_UNUSED(parameters)
|
|
285 |
// changing the dialog after presenting it is not supported.
|
|
286 |
|
|
287 |
OstTraceFunctionExit0( EAPUSERNAMEPWDDIALOG_SETDEVICEDIALOGPARAMETERS_EXIT );
|
|
288 |
return true;
|
|
289 |
}
|
|
290 |
|
36
|
291 |
/*!
|
|
292 |
* Not supported
|
|
293 |
*
|
|
294 |
* @return 0 always returned.
|
26
|
295 |
*/
|
|
296 |
int EapUsernamePwdDialog::deviceDialogError() const
|
|
297 |
{
|
|
298 |
OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_DEVICEDIALOGERROR_ENTRY );
|
|
299 |
OstTraceFunctionExit0( EAPUSERNAMEPWDDIALOG_DEVICEDIALOGERROR_EXIT);
|
|
300 |
return 0;
|
|
301 |
}
|
|
302 |
|
36
|
303 |
/*!
|
26
|
304 |
* Dialog is closed and the signal about closing is emitted
|
36
|
305 |
*
|
|
306 |
* @param [in] byClient indicates when the user closes the dialog
|
26
|
307 |
*/
|
|
308 |
void EapUsernamePwdDialog::closeDeviceDialog(bool byClient)
|
|
309 |
{
|
|
310 |
OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_CLOSEDEVICEDIALOG_ENTRY );
|
|
311 |
qDebug("EapUsernamePwdDialog::closeDeviceDialog ENTER");
|
|
312 |
|
|
313 |
//If the user closes the dialog, then the deviceDialogClosed is emitted
|
|
314 |
if ( byClient == true )
|
|
315 |
{
|
|
316 |
qDebug("EapUsernamePwdDialog::closeDeviceDialog: emit deviceDialogClosed");
|
|
317 |
emit deviceDialogClosed();
|
|
318 |
}
|
|
319 |
|
|
320 |
qDebug("EapUsernamePwdDialog::closeDeviceDialog EXIT");
|
|
321 |
OstTraceFunctionExit0( EAPUSERNAMEPWDDIALOG_CLOSEDEVICEDIALOG_EXIT );
|
|
322 |
}
|
|
323 |
|
36
|
324 |
/*!
|
26
|
325 |
* This dialog widget is returned to the caller
|
36
|
326 |
*
|
|
327 |
* @return this dialog widget
|
26
|
328 |
*/
|
|
329 |
HbPopup *EapUsernamePwdDialog::deviceDialogWidget() const
|
|
330 |
{
|
|
331 |
OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_DEVICEDIALOGWIDGET_ENTRY );
|
|
332 |
OstTraceFunctionExit0( EAPUSERNAMEPWDDIALOG_DEVICEDIALOGWIDGET_EXIT );
|
|
333 |
|
|
334 |
return const_cast<EapUsernamePwdDialog*>(this);
|
|
335 |
}
|
|
336 |
|