|
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-FAST PAC File Password Query Dialog implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: 5 % |
|
20 */ |
|
21 |
|
22 // System includes |
|
23 #include <HbTranslator> |
|
24 #include <HbAction> |
|
25 #include <HbParameterLengthLimiter> |
|
26 |
|
27 // User includes |
|
28 #include "eapfastpacfilepwquerydialog.h" |
|
29 #include "OstTraceDefinitions.h" |
|
30 #ifdef OST_TRACE_COMPILER_IN_USE |
|
31 #include "eapfastpacfilepwquerydialogTraces.h" |
|
32 #endif |
|
33 |
|
34 |
|
35 /*! |
|
36 * \class EapFastPacFilePwQueryDialog |
|
37 * \brief Implements EAP-FAST PAC File Password Query Dialog. |
|
38 */ |
|
39 |
|
40 // External function prototypes |
|
41 |
|
42 // Local constants |
|
43 static const uint PacFilePwQueryTimeout = 60000; |
|
44 |
|
45 // ======== LOCAL FUNCTIONS ======== |
|
46 |
|
47 // ======== MEMBER FUNCTIONS ======== |
|
48 |
|
49 /*! |
|
50 * Constructor. |
|
51 * |
|
52 * @param [in] parameters Parameters for the Constructor. |
|
53 */ |
|
54 EapFastPacFilePwQueryDialog::EapFastPacFilePwQueryDialog(const QVariantMap ¶meters) |
|
55 :mEdit(NULL), |
|
56 mTranslator(new HbTranslator("eapprompts")), |
|
57 mClose(false), |
|
58 mOkActionPressed(false) |
|
59 { |
|
60 OstTraceFunctionEntry0( EAPFASTPACFILEQUERYDIALOG_EAPFASTPACFILEQUERYDIALOG_ENTRY ); |
|
61 qDebug("EapFastPacFilePwQueryDialog::EapFastPacFilePwQueryDialog ENTER"); |
|
62 |
|
63 createDialog(parameters); |
|
64 |
|
65 OstTraceFunctionExit0( EAPFASTPACFILEQUERYDIALOG_EAPFASTPACFILEQUERYDIALOG_EXIT ); |
|
66 qDebug("EapFastPacFilePwQueryDialog::EapFastPacFilePwQueryDialog EXIT"); |
|
67 } |
|
68 |
|
69 /*! |
|
70 * The construction of the dialog |
|
71 * |
|
72 * @param [in] parameters Parameters for the Construction of the dialog. |
|
73 */ |
|
74 void EapFastPacFilePwQueryDialog::createDialog(const QVariantMap ¶meters ) |
|
75 { |
|
76 OstTraceFunctionEntry0( EAPFASTPACFILEQUERYDIALOG_CREATEDIALOG_ENTRY ); |
|
77 qDebug("EapFastPacFilePwQueryDialog::createDialog ENTER"); |
|
78 |
|
79 QString filename; |
|
80 QString key("pacfilename"); |
|
81 |
|
82 //Get the filename from parameters |
|
83 if ( parameters.empty() == false ) { |
|
84 if ( parameters.contains(key) ) { |
|
85 QVariant variant = parameters.value(key); |
|
86 filename = variant.toString(); |
|
87 } |
|
88 } |
|
89 |
|
90 QString mainText(HbParameterLengthLimiter( |
|
91 hbTrId("txt_occ_dialog_pac_file_password_for_1").arg(filename))); |
|
92 |
|
93 //Set the dialog to be on the screen for 60 seconds, unless |
|
94 //the user reacts earlier |
|
95 this->setModal(true); |
|
96 this->setTimeout(PacFilePwQueryTimeout); |
|
97 this->setDismissPolicy(HbPopup::NoDismiss); |
|
98 this->setPromptText(mainText, 0); |
|
99 mEdit = this->lineEdit(0); |
|
100 mEdit->setEchoMode(HbLineEdit::Password); |
|
101 |
|
102 //Remove all default actions from the dialog |
|
103 QList<QAction*> action_list = this->actions(); |
|
104 for ( int i = 0; i < action_list.count(); i++ ) { |
|
105 this->removeAction(action_list.at(i)); |
|
106 } |
|
107 |
|
108 //Add a new Ok button action |
|
109 HbAction* actionOk = new HbAction(hbTrId("txt_common_button_ok"),this); |
|
110 this->addAction(actionOk); |
|
111 |
|
112 //Add a new Cancel button action |
|
113 HbAction* actionCancel = new HbAction(hbTrId("txt_common_button_cancel"),this); |
|
114 this->addAction(actionCancel); |
|
115 |
|
116 //Disconnect action Ok from the default SLOT and connect to |
|
117 //a SLOT owned by this class |
|
118 disconnect(actionOk, SIGNAL(triggered()),this, SLOT(close())); |
|
119 bool connected = connect(actionOk, SIGNAL(triggered()), this, SLOT(okPressed())); |
|
120 Q_ASSERT(connected == true); |
|
121 |
|
122 //Disconnect action Cancel from the default SLOT and connect to |
|
123 //a SLOT owned by this class |
|
124 disconnect(actionCancel, SIGNAL(triggered()),this, SLOT(close())); |
|
125 connected = connect(actionCancel, SIGNAL(triggered()), this, SLOT(cancelPressed())); |
|
126 Q_ASSERT(connected == true); |
|
127 |
|
128 // Connect the about to close and hide signals, so that we are able to inform |
|
129 // the caller that the dialog was closed |
|
130 connected = connect(this, SIGNAL(aboutToClose()), this, SLOT(closingDialog())); |
|
131 Q_ASSERT(connected == true); |
|
132 connected = connect(this, SIGNAL(aboutToHide()), this, SLOT(closingDialog())); |
|
133 Q_ASSERT(connected == true); |
|
134 |
|
135 OstTraceFunctionExit0( DUP1_EAPFASTPACFILEQUERYDIALOG_CREATEDIALOG_EXIT ); |
|
136 qDebug("EapFastPacFilePwQueryDialog::createDialog EXIT"); |
|
137 } |
|
138 |
|
139 /*! |
|
140 * Destructor. |
|
141 */ |
|
142 EapFastPacFilePwQueryDialog::~EapFastPacFilePwQueryDialog() |
|
143 { |
|
144 OstTraceFunctionEntry0( EAPFASTPACFILEQUERYDIALOG_DEAPFASTPACFILEQUERYDIALOG_ENTRY ); |
|
145 |
|
146 // The dialog widgets are deleted as the dialog is deleted |
|
147 |
|
148 OstTraceFunctionExit0( EAPFASTPACFILEQUERYDIALOG_DEAPFASTPACFILEQUERYDIALOG_EXIT ); |
|
149 } |
|
150 |
|
151 /*! |
|
152 * Function is called when the Ok Action button is pressed |
|
153 */ |
|
154 void EapFastPacFilePwQueryDialog::okPressed() |
|
155 { |
|
156 OstTraceFunctionEntry0( EAPFASTPACFILEQUERYDIALOG_FIRSTBUTTONPRESSED_ENTRY ); |
|
157 qDebug("EapFastPacFilePwQueryDialog::okPressed ENTER"); |
|
158 |
|
159 if ( mOkActionPressed == false ) { |
|
160 |
|
161 mOkActionPressed = true; |
|
162 |
|
163 QVariantMap data; |
|
164 |
|
165 data["password"] = mEdit->text(); |
|
166 |
|
167 qDebug("EapFastPacFilePwQueryDialog::okPressed: emit deviceDialogData"); |
|
168 |
|
169 emit deviceDialogData(data); |
|
170 closeDeviceDialog(true); |
|
171 } |
|
172 OstTraceFunctionExit0( EAPFASTPACFILEQUERYDIALOG_FIRSTBUTTONPRESSED_EXIT ); |
|
173 qDebug("EapFastPacFilePwQueryDialog::okPressed EXIT"); |
|
174 } |
|
175 |
|
176 /*! |
|
177 * Function is called when the Cancel Action button is pressed |
|
178 */ |
|
179 void EapFastPacFilePwQueryDialog::cancelPressed() |
|
180 { |
|
181 OstTraceFunctionEntry0( EAPFASTPACFILEQUERYDIALOG_CANCELPRESSED_ENTRY ); |
|
182 qDebug("EapFastPacFilePwQueryDialog::cancelPressed ENTER"); |
|
183 |
|
184 if (!mClose) { |
|
185 mClose = true; |
|
186 closeDeviceDialog(true); |
|
187 } |
|
188 qDebug("EapFastPacFilePwQueryDialog::cancelPressed EXIT"); |
|
189 OstTraceFunctionExit0( EAPFASTPACFILEQUERYDIALOG_CANCELPRESSED_EXIT ); |
|
190 } |
|
191 |
|
192 /*! |
|
193 * Function is called when the dialog is about to close |
|
194 */ |
|
195 void EapFastPacFilePwQueryDialog::closingDialog() |
|
196 { |
|
197 OstTraceFunctionEntry0( EAPFASTPACFILEQUERYDIALOG_CLOSINGDIALOG_ENTRY ); |
|
198 qDebug("EapFastPacFilePwQueryDialog::closingDialog ENTER"); |
|
199 |
|
200 qDebug("EapFastPacFilePwQueryDialog::closingDialog EXIT"); |
|
201 OstTraceFunctionExit0( EAPFASTPACFILEQUERYDIALOG_CLOSINGDIALOG_EXIT ); |
|
202 } |
|
203 |
|
204 /*! |
|
205 * Device dialog parameters to be set while dialog is displayed. |
|
206 * Not supported. |
|
207 * |
|
208 * @param [in] parameters NOT USED |
|
209 * @return true always. |
|
210 */ |
|
211 bool EapFastPacFilePwQueryDialog::setDeviceDialogParameters |
|
212 (const QVariantMap ¶meters) |
|
213 { |
|
214 OstTraceFunctionEntry0( EAPFASTPACFILEQUERYDIALOG_SETDEVICEDIALOGPARAMETERS_ENTRY ); |
|
215 |
|
216 Q_UNUSED(parameters) |
|
217 // changing the dialog after presenting it is not supported. |
|
218 |
|
219 OstTraceFunctionExit0( EAPFASTPACFILEQUERYDIALOG_SETDEVICEDIALOGPARAMETERS_EXIT ); |
|
220 return true; |
|
221 } |
|
222 |
|
223 /*! |
|
224 * Not supported |
|
225 * |
|
226 * @return 0 always returned. |
|
227 */ |
|
228 int EapFastPacFilePwQueryDialog::deviceDialogError() const |
|
229 { |
|
230 OstTraceFunctionEntry0( EAPFASTPACFILEQUERYDIALOG_DEVICEDIALOGERROR_ENTRY ); |
|
231 OstTraceFunctionExit0( EAPFASTPACFILEQUERYDIALOG_DEVICEDIALOGERROR_EXIT); |
|
232 return 0; |
|
233 } |
|
234 |
|
235 /*! |
|
236 * Dialog is closed and the signal about closing is emitted |
|
237 * |
|
238 * @param [in] byClient indicates when the user closes the dialog |
|
239 */ |
|
240 void EapFastPacFilePwQueryDialog::closeDeviceDialog(bool byClient) |
|
241 { |
|
242 OstTraceFunctionEntry0( EAPFASTPACFILEQUERYDIALOG_CLOSEDEVICEDIALOG_ENTRY ); |
|
243 qDebug("EapFastPacFilePwQueryDialog::closeDeviceDialog ENTER"); |
|
244 |
|
245 //If the user closes the dialog, then the deviceDialogClosed is emitted |
|
246 if ( byClient == true ) |
|
247 { |
|
248 qDebug("EapFastPacFilePwQueryDialog::closeDeviceDialog: emit deviceDialogClosed"); |
|
249 emit deviceDialogClosed(); |
|
250 } |
|
251 |
|
252 qDebug("EapFastPacFilePwQueryDialog::closeDeviceDialog EXIT"); |
|
253 OstTraceFunctionExit0( EAPFASTPACFILEQUERYDIALOG_CLOSEDEVICEDIALOG_EXIT ); |
|
254 } |
|
255 |
|
256 /*! |
|
257 * This dialog widget is returned to the caller |
|
258 * |
|
259 * @return this dialog widget |
|
260 */ |
|
261 HbPopup *EapFastPacFilePwQueryDialog::deviceDialogWidget() const |
|
262 { |
|
263 OstTraceFunctionEntry0( EAPFASTPACFILEQUERYDIALOG_DEVICEDIALOGWIDGET_ENTRY ); |
|
264 OstTraceFunctionExit0( EAPFASTPACFILEQUERYDIALOG_DEVICEDIALOGWIDGET_EXIT ); |
|
265 |
|
266 return const_cast<EapFastPacFilePwQueryDialog*>(this); |
|
267 } |
|
268 |