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 Install PAC 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 "eapfastinstallpacquerydialog.h" |
|
29 #include "OstTraceDefinitions.h" |
|
30 #ifdef OST_TRACE_COMPILER_IN_USE |
|
31 #include "eapfastinstallpacquerydialogTraces.h" |
|
32 #endif |
|
33 |
|
34 /*! |
|
35 * \class EapFastInstallPacQueryDialog |
|
36 * \brief Implements EAP-FAST Install PAC Query Dialog. |
|
37 */ |
|
38 |
|
39 // External function prototypes |
|
40 |
|
41 // Local constants |
|
42 |
|
43 //! The index numbers of the button of the dialog |
|
44 static const int yesButtonIndex = 1; |
|
45 |
|
46 // ======== LOCAL FUNCTIONS ======== |
|
47 |
|
48 // ======== MEMBER FUNCTIONS ======== |
|
49 |
|
50 /*! |
|
51 * Constructor. |
|
52 * |
|
53 * @param [in] parameters Parameters for the Constructor. |
|
54 */ |
|
55 EapFastInstallPacQueryDialog::EapFastInstallPacQueryDialog(const QVariantMap ¶meters) |
|
56 :HbMessageBox(HbMessageBox::MessageTypeQuestion), |
|
57 mTranslator(new HbTranslator("eapprompts")), |
|
58 mClose(false), |
|
59 mYesActionPressed(false) |
|
60 { |
|
61 OstTraceFunctionEntry0( EAPGTCQUERYDIALOG_EAPGTCQUERYDIALOG_ENTRY ); |
|
62 qDebug("EapFastInstallPacQueryDialog::EapFastInstallPacQueryDialog ENTER"); |
|
63 |
|
64 createDialog( parameters ); |
|
65 |
|
66 OstTraceFunctionExit0( EAPGTCQUERYDIALOG_EAPGTCQUERYDIALOG_EXIT ); |
|
67 qDebug("EapFastInstallPacQueryDialog::EapFastInstallPacQueryDialog EXIT"); |
|
68 } |
|
69 |
|
70 /*! |
|
71 * The construction of the dialog |
|
72 * |
|
73 * @param [in] parameters Parameters for the Construction of the dialog. |
|
74 */ |
|
75 void EapFastInstallPacQueryDialog::createDialog(const QVariantMap ¶meters ) |
|
76 { |
|
77 OstTraceFunctionEntry0( EAPGTCQUERYDIALOG_CREATEDIALOG_ENTRY ); |
|
78 qDebug("EapFastInstallPacQueryDialog::createDialog ENTER"); |
|
79 |
|
80 QString servername; |
|
81 QString key("pacservername"); |
|
82 |
|
83 //Get the server name from parameters |
|
84 if ( parameters.empty() == false ) { |
|
85 if ( parameters.contains(key) ) { |
|
86 QVariant variant = parameters.value(key); |
|
87 servername = variant.toString(); |
|
88 } |
|
89 } |
|
90 |
|
91 QString mainText(HbParameterLengthLimiter( |
|
92 hbTrId("txt_occ_info_install_pac_from_server_1").arg(servername))); |
|
93 |
|
94 //Set the dialog to be on the screen until user reacts |
|
95 //by pressing any of the Action buttons |
|
96 this->setModal(true); |
|
97 this->setTimeout(HbPopup::NoTimeout); |
|
98 this->setDismissPolicy(HbPopup::NoDismiss); |
|
99 |
|
100 this->setText(mainText); |
|
101 this->setIconVisible(true); |
|
102 |
|
103 //Remove all default actions from the dialog |
|
104 QList<QAction*> action_list = this->actions(); |
|
105 for ( int i = 0; i < action_list.count(); i++ ) { |
|
106 this->removeAction(action_list.at(i)); |
|
107 } |
|
108 |
|
109 //Add a new Yes button action |
|
110 HbAction* actionYes = new HbAction(hbTrId("txt_common_button_yes"),this); |
|
111 this->addAction(actionYes); |
|
112 |
|
113 //Add a new No button action |
|
114 HbAction* actionNo = new HbAction(hbTrId("txt_common_button_no"),this); |
|
115 this->addAction(actionNo); |
|
116 |
|
117 //Disconnect action Yes from the default SLOT and connect to |
|
118 //a SLOT owned by this class |
|
119 disconnect(actionYes, SIGNAL(triggered()),this, SLOT(close())); |
|
120 bool connected = connect(actionYes, SIGNAL(triggered()), this, SLOT(yesPressed())); |
|
121 Q_ASSERT(connected == true); |
|
122 |
|
123 //Disconnect action No from the default SLOT and connect to |
|
124 //a SLOT owned by this class |
|
125 disconnect(actionNo, SIGNAL(triggered()),this, SLOT(close())); |
|
126 connected = connect(actionNo, SIGNAL(triggered()), this, SLOT(noPressed())); |
|
127 Q_ASSERT(connected == true); |
|
128 |
|
129 // Connect the about to close and hide signals, so that we are able to inform |
|
130 // the caller that the dialog was closed |
|
131 connected = connect(this, SIGNAL(aboutToClose()), this, SLOT(closingDialog())); |
|
132 Q_ASSERT(connected == true); |
|
133 connected = connect(this, SIGNAL(aboutToHide()), this, SLOT(closingDialog())); |
|
134 Q_ASSERT(connected == true); |
|
135 |
|
136 OstTraceFunctionExit0( DUP1_EAPGTCQUERYDIALOG_CREATEDIALOG_EXIT ); |
|
137 qDebug("EapFastInstallPacQueryDialog::createDialog EXIT"); |
|
138 } |
|
139 |
|
140 /*! |
|
141 * Destructor. |
|
142 */ |
|
143 EapFastInstallPacQueryDialog::~EapFastInstallPacQueryDialog() |
|
144 { |
|
145 OstTraceFunctionEntry0( EAPGTCQUERYDIALOG_DEAPGTCQUERYDIALOG_ENTRY ); |
|
146 |
|
147 // The dialog widgets are deleted as the dialog is deleted |
|
148 |
|
149 OstTraceFunctionExit0( EAPGTCQUERYDIALOG_DEAPGTCQUERYDIALOG_EXIT ); |
|
150 } |
|
151 |
|
152 /*! |
|
153 * Function is called when the Yes Action button is pressed |
|
154 */ |
|
155 void EapFastInstallPacQueryDialog::yesPressed() |
|
156 { |
|
157 OstTraceFunctionEntry0( EAPFASTINSTALLPACQUERYDIALOG_YESBUTTONPRESSED_ENTRY ); |
|
158 qDebug("EapFastInstallPacQueryDialog::yesPressed ENTER"); |
|
159 |
|
160 if ( mYesActionPressed == false ) { |
|
161 |
|
162 mYesActionPressed = true; |
|
163 |
|
164 QVariantMap data; |
|
165 data["yesbutton"] = yesButtonIndex; |
|
166 |
|
167 // emit the data of the selected button and close the dialog |
|
168 qDebug("EapFastInstallPacQueryDialog::yesPressed: emit deviceDialogData"); |
|
169 emit deviceDialogData(data); |
|
170 closeDeviceDialog(true); |
|
171 } |
|
172 OstTraceFunctionExit0( EAPFASTINSTALLPACQUERYDIALOG_YESBUTTONPRESSED_EXIT ); |
|
173 qDebug("EapFastInstallPacQueryDialog::yesPressed EXIT"); |
|
174 } |
|
175 |
|
176 /*! |
|
177 * Function is called when the No Action button is pressed |
|
178 */ |
|
179 void EapFastInstallPacQueryDialog::noPressed() |
|
180 { |
|
181 OstTraceFunctionEntry0( EAPFASTINSTALLPACQUERYDIALOG_NOPRESSED_ENTRY ); |
|
182 qDebug("EapFastInstallPacQueryDialog::noPressed ENTER"); |
|
183 |
|
184 if (!mClose) { |
|
185 mClose = true; |
|
186 closeDeviceDialog(true); |
|
187 } |
|
188 qDebug("EapFastInstallPacQueryDialog::noPressed EXIT"); |
|
189 OstTraceFunctionExit0( EAPFASTINSTALLPACQUERYDIALOG_NOPRESSED_EXIT ); |
|
190 } |
|
191 |
|
192 /*! |
|
193 * Function is called when the dialog is about to close |
|
194 */ |
|
195 void EapFastInstallPacQueryDialog::closingDialog() |
|
196 { |
|
197 OstTraceFunctionEntry0( EAPFASTINSTALLPACQUERYDIALOG_CLOSINGDIALOG_ENTRY ); |
|
198 qDebug("EapFastInstallPacQueryDialog::closingDialog ENTER"); |
|
199 |
|
200 qDebug("EapFastInstallPacQueryDialog::closingDialog EXIT"); |
|
201 OstTraceFunctionExit0( EAPFASTINSTALLPACQUERYDIALOG_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 EapFastInstallPacQueryDialog::setDeviceDialogParameters |
|
212 (const QVariantMap ¶meters) |
|
213 { |
|
214 OstTraceFunctionEntry0( EAPFASTINSTALLPACQUERYDIALOG_SETDEVICEDIALOGPARAMETERS_ENTRY ); |
|
215 |
|
216 Q_UNUSED(parameters) |
|
217 // changing the dialog after presenting it is not supported. |
|
218 |
|
219 OstTraceFunctionExit0( EAPFASTINSTALLPACQUERYDIALOG_SETDEVICEDIALOGPARAMETERS_EXIT ); |
|
220 return true; |
|
221 } |
|
222 |
|
223 /*! |
|
224 * Not supported |
|
225 * |
|
226 * @return 0 always returned. |
|
227 */ |
|
228 int EapFastInstallPacQueryDialog::deviceDialogError() const |
|
229 { |
|
230 OstTraceFunctionEntry0( EAPFASTINSTALLPACQUERYDIALOG_DEVICEDIALOGERROR_ENTRY ); |
|
231 OstTraceFunctionExit0( EAPFASTINSTALLPACQUERYDIALOG_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 EapFastInstallPacQueryDialog::closeDeviceDialog(bool byClient) |
|
241 { |
|
242 OstTraceFunctionEntry0( EAPFASTINSTALLPACQUERYDIALOG_CLOSEDEVICEDIALOG_ENTRY ); |
|
243 qDebug("EapFastInstallPacQueryDialog::closeDeviceDialog ENTER"); |
|
244 |
|
245 //If the user closes the dialog, then the deviceDialogClosed is emitted |
|
246 if ( byClient == true ) |
|
247 { |
|
248 qDebug("EapFastInstallPacQueryDialog::closeDeviceDialog: emit deviceDialogClosed"); |
|
249 emit deviceDialogClosed(); |
|
250 } |
|
251 |
|
252 qDebug("EapFastInstallPacQueryDialog::closeDeviceDialog EXIT"); |
|
253 OstTraceFunctionExit0( EAPFASTINSTALLPACQUERYDIALOG_CLOSEDEVICEDIALOG_EXIT ); |
|
254 } |
|
255 |
|
256 /*! |
|
257 * This dialog widget is returned to the caller |
|
258 * |
|
259 * @return this dialog widget |
|
260 */ |
|
261 HbPopup *EapFastInstallPacQueryDialog::deviceDialogWidget() const |
|
262 { |
|
263 OstTraceFunctionEntry0( EAPFASTINSTALLPACQUERYDIALOG_DEVICEDIALOGWIDGET_ENTRY ); |
|
264 qDebug("EapFastInstallPacQueryDialog::deviceDialogWidget ENTER"); |
|
265 |
|
266 qDebug("EapFastInstallPacQueryDialog::deviceDialogWidget EXIT"); |
|
267 OstTraceFunctionExit0( EAPFASTINSTALLPACQUERYDIALOG_DEVICEDIALOGWIDGET_EXIT ); |
|
268 |
|
269 return const_cast<EapFastInstallPacQueryDialog*>(this); |
|
270 } |
|
271 |
|