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