|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "fotafullscreendialog.h" |
|
19 |
|
20 #include <HbAction.h> |
|
21 #include <hbprogressbar.h> |
|
22 #include <hbicon.h> |
|
23 #include <hbextendedlocale.h> |
|
24 #include <hbtranslator.h> |
|
25 #include <e32std.h> |
|
26 #include <e32math.h> |
|
27 |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // CFotaDownloadNotifHandler::FotaFullscreenDialog |
|
31 // Constructor of the full screen dialogs, it takes all the widgets from the docml |
|
32 // initializes it and sets the progress bar to zero. |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 |
|
36 |
|
37 FotaFullscreenDialog::FotaFullscreenDialog(CFotaServer* aObserver) |
|
38 { |
|
39 FLOG(_L("FotaFullscreenDialog::FotaFullscreenDialog >>")); |
|
40 bool ok = false; |
|
41 iServer = aObserver; |
|
42 iloader.load(":/xml/data/fullscreendialog.docml", &ok); |
|
43 if (!ok) |
|
44 { |
|
45 return; |
|
46 } |
|
47 iClicked = EFalse; |
|
48 idialog = qobject_cast<HbDialog *> (iloader.findWidget("dialog")); |
|
49 |
|
50 idialog->setTimeout(HbPopup::NoTimeout); |
|
51 |
|
52 iPrimaryAction = qobject_cast<HbPushButton *> (iloader.findWidget( |
|
53 "btnHide")); |
|
54 |
|
55 iSecondaryAction = qobject_cast<HbPushButton *> (iloader.findWidget( |
|
56 "btnResumeLater")); |
|
57 |
|
58 |
|
59 |
|
60 iprogressBar = qobject_cast<HbProgressBar *> (iloader.findWidget( |
|
61 "horizontalProgressBar")); |
|
62 iprogressBar->setProgressValue(0); |
|
63 |
|
64 /*iInstallNote = qobject_cast<HbLabel *> (iloader.findWidget( |
|
65 "lblinstallnote"));*/ |
|
66 iDownloadState = qobject_cast<HbLabel *> (iloader.findWidget( |
|
67 "lblDownloadState")); |
|
68 //iEmergencyIcon = qobject_cast<HbLabel *> (iloader.findWidget( |
|
69 // "icnEmergency")); |
|
70 iChargerIcon = qobject_cast<HbLabel *> (iloader.findWidget("icnCharger")); |
|
71 HbIcon iconCharger; |
|
72 //iconCharger.setIconName(:/icons/qgn_prop_sml_http.svg); |
|
73 //iChargerIcon->setIcon(iconCharger); |
|
74 HbIcon iconEmergency; |
|
75 //iconEmergency.setIconName(:/icons/qgn_prop_sml_http.svg); |
|
76 //iEmergencyIcon->setIcon(iconEmergency); |
|
77 //iEmergencyNote = qobject_cast<HbLabel *> (iloader.findWidget( |
|
78 // "lblEmergency")); |
|
79 //iRestartIcon = qobject_cast<HbLabel *> (iloader.findWidget("icnInstall")); |
|
80 //HbIcon iconRestart; |
|
81 //iconRestart.setIconName(:/icons/qgn_prop_sml_http.svg); |
|
82 //iRestartIcon->setIcon(iconRestart); |
|
83 //iRestartNote = qobject_cast<HbLabel *> (iloader.findWidget( |
|
84 // "lblRestartNote")); |
|
85 //installEventFilter(this); |
|
86 iPrimaryAction->setText(hbTrId("txt_common_button_hide")); |
|
87 iSecondaryAction->setText(hbTrId("txt_device_update_button_resume_later")); |
|
88 iTitle = qobject_cast<HbLabel *> (iloader.findWidget("lblTitle")); |
|
89 iTitle->setPlainText(hbTrId("txt_device_update_title_updating_phone")); |
|
90 iDownloadState->setPlainText(hbTrId("txt_device_update_info_downloading")); |
|
91 //iInstallNote->setPlainText(hbTrId( |
|
92 // "txt_device_update_info_installation_will_proceed_n")); |
|
93 iChargerNote = qobject_cast<HbLabel *> (iloader.findWidget("lblcharger")); |
|
94 iChargerNote->setPlainText(hbTrId( |
|
95 "txt_device_update_info_FS_its_recommended_to_connec")); |
|
96 //iRestartNote->setPlainText(hbTrId( |
|
97 // "txt_device_update_info_FS_after_the_installation_the")); |
|
98 //iEmergencyNote->setPlainText(hbTrId( |
|
99 // "txt_device_update_info_FS_during_the_installation_the")); |
|
100 |
|
101 QObject::connect(iPrimaryAction, SIGNAL(clicked()), this, |
|
102 SLOT(LSKSelected())); |
|
103 QObject::connect(iSecondaryAction, SIGNAL(clicked()), this, |
|
104 SLOT(RSKSelected())); |
|
105 QObject::connect(idialog, SIGNAL(aboutToClose()), this, |
|
106 SLOT(aboutToClose())); |
|
107 |
|
108 RefreshDialog(); |
|
109 FLOG(_L("FotaFullscreenDialog::FotaFullscreenDialog <<")); |
|
110 } |
|
111 |
|
112 |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // CFotaDownloadNotifHandler::refreshDialog |
|
116 // This function is used to refresh the contents of the full screen dialog |
|
117 // once it is changed. |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 |
|
121 |
|
122 void FotaFullscreenDialog::RefreshDialog() |
|
123 { |
|
124 FLOG(_L("FotaFullscreenDialog::RefreshDialog >>")); |
|
125 if (idialog) |
|
126 { |
|
127 FLOG(_L("FotaFullscreenDialog::idialog >>")); |
|
128 iClicked = EFalse; |
|
129 idialog->show(); |
|
130 } |
|
131 FLOG(_L("FotaFullscreenDialog::RefreshDialog <<")); |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // CFotaDownloadNotifHandler::setsoftwaredetails |
|
136 // This function is called to set the details of the software,which is downloaded. |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 |
|
140 void FotaFullscreenDialog::SetSoftwareDetails(int size, |
|
141 const QString version, const QString aName) |
|
142 { |
|
143 //set Sw Details |
|
144 FLOG(_L("FotaFullscreenDialog::RefreshDialog >>")); |
|
145 iSwDetails = qobject_cast<HbLabel *> (iloader.findWidget("lblSwVersion")); |
|
146 QString content; |
|
147 |
|
148 TReal sizeKB = size / 1024; |
|
149 TReal sizeRounded = 0; |
|
150 QString pkgsize; |
|
151 |
|
152 if (sizeKB > 1024) |
|
153 { |
|
154 TReal sizeMB = sizeKB / 1024; |
|
155 Math::Round(sizeRounded,sizeMB,2); |
|
156 content = hbTrId("txt_device_update_info_new_device_software_availab_Mb") .arg(aName) .arg(version).arg(sizeRounded); |
|
157 } |
|
158 else |
|
159 { |
|
160 Math::Round(sizeRounded,sizeKB,2); |
|
161 content = hbTrId("txt_device_update_info_new_device_software_availab_Kb") .arg(aName) .arg(version).arg(sizeRounded); |
|
162 } |
|
163 |
|
164 iSwDetails->setPlainText(content); |
|
165 FLOG(_L("FotaFullscreenDialog::RefreshDialog <<")); |
|
166 } |
|
167 |
|
168 // --------------------------------------------------------------------------- |
|
169 // CFotaDownloadNotifHandler::close |
|
170 // This slot is called to manually close the dialog. |
|
171 // --------------------------------------------------------------------------- |
|
172 // |
|
173 |
|
174 void FotaFullscreenDialog::Close() |
|
175 { |
|
176 FLOG(_L("FotaFullscreenDialog::Close <<")); |
|
177 iClicked = ETrue; |
|
178 if (idialog) |
|
179 idialog->close(); |
|
180 FLOG(_L("FotaFullscreenDialog::Close >>")); |
|
181 } |
|
182 |
|
183 // --------------------------------------------------------------------------- |
|
184 // CFotaDownloadNotifHandler::setwarningdetails |
|
185 // This function is to set the warnings details of the full screen dialog |
|
186 // according to the state of the firmware update. |
|
187 // --------------------------------------------------------------------------- |
|
188 // |
|
189 |
|
190 void FotaFullscreenDialog::SetWarningDetails(TFotaWarningType aType) |
|
191 { |
|
192 FLOG(_L("FotaFullscreenDialog::SetWarningDetails <<")); |
|
193 //set heading content |
|
194 if (aType == EHbFotaDownload) |
|
195 { |
|
196 FLOG(_L("FotaFullscreenDialog::EHbFotaDownload")); |
|
197 idialog->setTimeout(HbPopup::NoTimeout); |
|
198 iInstallNote = qobject_cast<HbLabel *> (iloader.findWidget( |
|
199 "lblinstallnote")); |
|
200 iInstallNote->setPlainText(hbTrId( |
|
201 "txt_device_update_info_installation_will_proceed_n")); |
|
202 //User::After(1000); |
|
203 iInstallNote->setVisible(false); |
|
204 |
|
205 iRestartNote = qobject_cast<HbLabel *> (iloader.findWidget( |
|
206 "lblRestartNote")); |
|
207 iRestartNote->setPlainText(hbTrId( |
|
208 "txt_device_update_info_FS_after_the_installation_the")); |
|
209 //User::After(1000); |
|
210 iRestartNote->setVisible(false); |
|
211 |
|
212 iRestartIcon = qobject_cast<HbLabel *> (iloader.findWidget("icnInstall")); |
|
213 HbIcon iconRestart; |
|
214 //iconRestart.setIconName(:/icons/qgn_prop_sml_http.svg); |
|
215 //iRestartIcon->setIcon(iconRestart); |
|
216 //User::After(1000); |
|
217 iRestartIcon->setVisible(false); |
|
218 |
|
219 iEmergencyNote = qobject_cast<HbLabel *> (iloader.findWidget( |
|
220 "lblEmergency")); |
|
221 iEmergencyNote->setPlainText(hbTrId( |
|
222 "txt_device_update_info_FS_during_the_installation_the")); |
|
223 //User::After(1000); |
|
224 iEmergencyNote->setVisible(false); |
|
225 |
|
226 iEmergencyIcon = qobject_cast<HbLabel *> (iloader.findWidget( |
|
227 "icnEmergency")); |
|
228 HbIcon iconEmergency; |
|
229 //iconEmergency.setIconName(:/icons/qgn_prop_sml_http.svg); |
|
230 //iEmergencyIcon->setIcon(iconEmergency); |
|
231 //User::After(1000); |
|
232 iEmergencyIcon->setVisible(false); |
|
233 |
|
234 } |
|
235 else if (aType == EHbFotaUpdate) |
|
236 { |
|
237 FLOG(_L("FotaFullscreenDialog::EHbFotaUpdate")); |
|
238 idialog->setTimeout(HbPopup::ContextMenuTimeout); |
|
239 HbIcon iconCharger; |
|
240 //iconCharger.setIconName(:/icons/qgn_prop_sml_http.svg); |
|
241 //iChargerIcon->setIcon(iconCharger); |
|
242 HbIcon iconRestart; |
|
243 //iconRestart.setIconName(:/icons/qgn_prop_sml_http.svg); |
|
244 //iRestartIcon->setIcon(iconRestart); |
|
245 iInstallNote->setPlainText(hbTrId( |
|
246 "txt_device_update_info_installation_will_proceed_n")); |
|
247 iChargerNote->setPlainText(hbTrId( |
|
248 "txt_device_update_info_FS_its_recommended_to_connec")); |
|
249 iRestartNote->setPlainText(hbTrId( |
|
250 "txt_device_update_info_FS_after_the_installation_the")); |
|
251 iInstallNote->setVisible(true); |
|
252 iRestartNote->setVisible(true); |
|
253 iRestartIcon->setVisible(true); |
|
254 iEmergencyNote->setVisible(true); |
|
255 iEmergencyIcon->setVisible(true); |
|
256 iDownloadState->setPlainText(hbTrId( |
|
257 "txt_device_update_info_download_complete")); |
|
258 iDownloadState->setVisible(true); |
|
259 iPrimaryAction->setEnabled(ETrue); |
|
260 } |
|
261 else if (aType == EHbFotaLowBattery) |
|
262 { |
|
263 FLOG(_L("FotaFullscreenDialog::EHbFotaLowBattery")); |
|
264 idialog->setTimeout(HbPopup::NoTimeout); |
|
265 HbIcon iconCharger; |
|
266 //iconCharger.setIconName(:/icons/qgn_prop_sml_http.svg); |
|
267 //iChargerIcon->setIcon(iconCharger); |
|
268 HbIcon iconRestart; |
|
269 //iconRestart.setIconName(:/icons/qgn_prop_sml_http.svg); |
|
270 //iRestartIcon->setIcon(iconRestart); |
|
271 iInstallNote->setPlainText(hbTrId( |
|
272 "txt_device_update_info_to_proceed_with_installatio")); |
|
273 iChargerNote->setPlainText(hbTrId( |
|
274 "txt_device_update_info_FS_after_the_installation_the")); |
|
275 iRestartNote->setPlainText(hbTrId( |
|
276 "txt_device_update_info_FS_during_the_installation_the")); |
|
277 //iEmergencyNote->setPlainText(hbTrId("txt_device_update_info_FS_during_the_installation_the")); |
|
278 iInstallNote->setVisible(true); |
|
279 iRestartNote->setVisible(true); |
|
280 iRestartIcon->setVisible(true); |
|
281 iEmergencyNote->setVisible(false); |
|
282 iEmergencyIcon->setVisible(false); |
|
283 iDownloadState->setPlainText(hbTrId( |
|
284 "txt_device_update_info_download_complete")); |
|
285 iDownloadState->setVisible(true); |
|
286 iPrimaryAction->setText(hbTrId("txt_device_update_button_continue")); |
|
287 iSecondaryAction->setText(hbTrId( |
|
288 "txt_device_update_button_install_later")); |
|
289 iPrimaryAction->setEnabled(EFalse); |
|
290 } |
|
291 RefreshDialog(); |
|
292 FLOG(_L("FotaFullscreenDialog::SetWarningDetails >>")); |
|
293 } |
|
294 |
|
295 // --------------------------------------------------------------------------- |
|
296 // CFotaDownloadNotifHandler::updateprogressbar |
|
297 // This function is called to update the progress bar with the download progress details/. |
|
298 // --------------------------------------------------------------------------- |
|
299 // |
|
300 |
|
301 void FotaFullscreenDialog::UpdateProgressBar(TInt aProgress) |
|
302 { |
|
303 FLOG(_L("FotaFullscreenDialog::UpdateProgressBar <<")); |
|
304 iprogressBar->setProgressValue(aProgress); |
|
305 FLOG(_L("FotaFullscreenDialog::UpdateProgressBar >>")); |
|
306 } |
|
307 |
|
308 // --------------------------------------------------------------------------- |
|
309 // CFotaDownloadNotifHandler::DisableRSK |
|
310 // This function is called disable the RSK of the dialog when the postpone limeit expires |
|
311 // --------------------------------------------------------------------------- |
|
312 // |
|
313 |
|
314 void FotaFullscreenDialog::DisableRSK(TBool aVal) |
|
315 { |
|
316 FLOG(_L("FotaFullscreenDialog::DisableRSK <<")); |
|
317 iSecondaryAction->setEnabled(!aVal); |
|
318 FLOG(_L("FotaFullscreenDialog::DisableRSK >>")); |
|
319 } |
|
320 |
|
321 bool FotaFullscreenDialog::IsLSKEnabled() |
|
322 { |
|
323 FLOG(_L("FotaFullscreenDialog::IsLSKEnabled <<")); |
|
324 return (iPrimaryAction->isEnabled()); |
|
325 } |
|
326 |
|
327 // --------------------------------------------------------------------------- |
|
328 // CFotaDownloadNotifHandler::cancelSelected |
|
329 // This slot is called when user presses the left softkey of fullscreen dialog. |
|
330 // --------------------------------------------------------------------------- |
|
331 // |
|
332 |
|
333 void FotaFullscreenDialog::LSKSelected() |
|
334 { |
|
335 FLOG(_L("FotaFullscreenDialog::LSKSelected <<")); |
|
336 iClicked = ETrue; |
|
337 idialog->hide(); |
|
338 iServer->HandleFullScreenDialogResponse(EHbLSK); |
|
339 FLOG(_L("FotaFullscreenDialog::LSKSelected >>")); |
|
340 } |
|
341 |
|
342 |
|
343 // --------------------------------------------------------------------------- |
|
344 // CFotaDownloadNotifHandler::cancelSelected |
|
345 // This slot is called when user presses the right softkey of fullscreen dialog. |
|
346 // --------------------------------------------------------------------------- |
|
347 // |
|
348 |
|
349 void FotaFullscreenDialog::RSKSelected() |
|
350 { |
|
351 FLOG(_L("FotaFullscreenDialog::RSKSelected >>")); |
|
352 iClicked = ETrue; |
|
353 idialog->hide(); |
|
354 iServer->HandleFullScreenDialogResponse(EHbRSK); |
|
355 FLOG(_L("FotaFullscreenDialog::RSKSelected <<")); |
|
356 } |
|
357 |
|
358 // --------------------------------------------------------------------------- |
|
359 // CFotaDownloadNotifHandler::~FotaFullscreenDialog |
|
360 // Destructor which destroys all the widgets |
|
361 // --------------------------------------------------------------------------- |
|
362 // |
|
363 |
|
364 FotaFullscreenDialog::~FotaFullscreenDialog() |
|
365 { |
|
366 FLOG(_L("~ FotaFullscreenDialog <<")); |
|
367 |
|
368 QObject::disconnect(iPrimaryAction, SIGNAL(clicked()), this, |
|
369 SLOT(LSKSelected())); |
|
370 QObject::disconnect(iSecondaryAction, SIGNAL(clicked()), this, |
|
371 SLOT(RSKSelected())); |
|
372 QObject::disconnect(idialog, SIGNAL(aboutToClose()), this, |
|
373 SLOT(aboutToClose())); |
|
374 |
|
375 if (iprogressBar) |
|
376 iprogressBar->deleteLater(); |
|
377 |
|
378 if (iPrimaryAction) |
|
379 delete iPrimaryAction; |
|
380 |
|
381 if (iSecondaryAction) |
|
382 delete iSecondaryAction; |
|
383 |
|
384 if (iTitle) |
|
385 delete iTitle; |
|
386 |
|
387 if (iSwDetails) |
|
388 delete iSwDetails; |
|
389 |
|
390 if (iInstallNote) |
|
391 delete iInstallNote; |
|
392 |
|
393 if (iRestartNote) |
|
394 delete iRestartNote; |
|
395 |
|
396 if (iRestartIcon) |
|
397 delete iRestartIcon; |
|
398 |
|
399 if (iEmergencyNote) |
|
400 delete iEmergencyNote; |
|
401 |
|
402 if (iEmergencyIcon) |
|
403 delete iEmergencyIcon; |
|
404 |
|
405 if (iDownloadState) |
|
406 delete iDownloadState; |
|
407 |
|
408 if (idialog) |
|
409 delete idialog; |
|
410 |
|
411 FLOG(_L("~ FotaFullscreenDialog >>")); |
|
412 } |
|
413 |
|
414 // --------------------------------------------------------------------------- |
|
415 // CFotaDownloadNotifHandler::showUpdateDialog |
|
416 // This function is called when download is complete and update dialog has to be shown. |
|
417 // --------------------------------------------------------------------------- |
|
418 // |
|
419 |
|
420 void FotaFullscreenDialog::ShowUpdateDialog() |
|
421 { |
|
422 FLOG(_L("FotaFullscreenDialog::ShowUpdateDialog <<")); |
|
423 iPrimaryAction->setText(hbTrId("txt_common_button_continue_dialog")); |
|
424 iSecondaryAction->setText( |
|
425 hbTrId("txt_device_update_button_install_later")); |
|
426 SetWarningDetails(EHbFotaUpdate); |
|
427 FLOG(_L("FotaFullscreenDialog::ShowUpdateDialog >>")); |
|
428 } |
|
429 |
|
430 |
|
431 void FotaFullscreenDialog::SetVisible(TBool aVisible) |
|
432 { |
|
433 FLOG(_L("RefreshDialog::SetVisible >>")); |
|
434 RefreshDialog(); |
|
435 FLOG(_L("RefreshDialog::SetVisible <<")); |
|
436 } |
|
437 // --------------------------------------------------------------------------- |
|
438 // CFotaDownloadNotifHandler::aboutToClose |
|
439 // This slot is called when full screen dialogs is cloased during a timeout. |
|
440 // --------------------------------------------------------------------------- |
|
441 // |
|
442 |
|
443 void FotaFullscreenDialog::aboutToClose() |
|
444 { |
|
445 FLOG(_L("FotaFullscreenDialog::aboutToClose <<")); |
|
446 if (!iClicked) |
|
447 { |
|
448 FLOG(_L("Calling fotaserver as timedout...")); |
|
449 iServer->HandleFullScreenDialogResponse(EHbLSK); |
|
450 } |
|
451 iClicked = EFalse; |
|
452 FLOG(_L("FotaFullscreenDialog::aboutToClose >>")); |
|
453 } |
|
454 |
|
455 |