47
|
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 |
|
52
|
18 |
|
47
|
19 |
#include <hbdocumentloader.h>
|
|
20 |
#include <hbdialog.h>
|
|
21 |
#include <hblabel.h>
|
|
22 |
#include <hbmessagebox.h>
|
52
|
23 |
#include <hbaction.h>
|
|
24 |
#include <e32property.h>
|
|
25 |
#include <qdebug.h>
|
|
26 |
#include <hblistview.h>
|
47
|
27 |
#include <hbpushbutton.h>
|
|
28 |
#include <e32math.h>
|
|
29 |
#include <QStandardItemModel>
|
52
|
30 |
#include <devicedialogsymbian.h>
|
|
31 |
#include "devicemanagementnotifierutils.h"
|
|
32 |
#include "fotadevicedialogs.h"
|
|
33 |
#include "pnputillogger.h"
|
47
|
34 |
|
|
35 |
|
|
36 |
// ---------------------------------------------------------------------------
|
|
37 |
// fotadevicedialogs::fotadevicedialogs
|
|
38 |
// Constructor for fota related device dialogs
|
|
39 |
// ---------------------------------------------------------------------------
|
|
40 |
//
|
|
41 |
|
|
42 |
fotadevicedialogs::fotadevicedialogs(const QVariantMap ¶meters)
|
|
43 |
//: devicemanagementnotifierwidget(parameters)
|
|
44 |
{
|
|
45 |
qDebug("devicemanagementnotifierutils fotadevicedialogs");
|
|
46 |
QTranslator *translator = new QTranslator();
|
|
47 |
QString lang = QLocale::system().name();
|
|
48 |
QString path = "Z:/resource/qt/translations/";
|
|
49 |
bool fine = translator->load("deviceupdates_" + lang, path);
|
|
50 |
if (fine)
|
|
51 |
qApp->installTranslator(translator);
|
|
52 |
|
|
53 |
QTranslator *commontranslator = new QTranslator();
|
|
54 |
fine = commontranslator->load("common_" + lang, path);/*finally required once localisation available*/
|
|
55 |
if(fine)
|
|
56 |
qApp->installTranslator(commontranslator);
|
|
57 |
else
|
|
58 |
qDebug("device dialog common translator loading failed");
|
|
59 |
|
|
60 |
|
|
61 |
launchFotaDialog(parameters);
|
|
62 |
}
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
// ---------------------------------------------------------------------------
|
|
67 |
// fotadevicedialogs::launchFotaDialog
|
|
68 |
// This function lauches is called to lauch the specific dialog based on the
|
|
69 |
// dialogID passed to it.
|
|
70 |
// ---------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
void fotadevicedialogs::launchFotaDialog(const QVariantMap ¶meters)
|
|
73 |
{
|
|
74 |
|
|
75 |
QVariantMap::const_iterator i = parameters.constBegin();
|
|
76 |
qDebug("devicemanagementnotifierutils fotadevicedialogs launchDialog");
|
|
77 |
TFwUpdNoteTypes aType = EFwUpdDeviceBusy;
|
|
78 |
|
|
79 |
//QString temp = QString::fromUtf8(reinterpret_cast<const char*>(url.Ptr()), url.Length());
|
|
80 |
//TDesC8 * tempStr = KKeyDialog;
|
|
81 |
//const QString temp = QString::fromUtf8(reinterpret_cast<const char*>(tempStr.Ptr()), tempStr.Length());
|
|
82 |
i = parameters.find(keydialog);
|
|
83 |
if(i != parameters.end())
|
|
84 |
aType = (TFwUpdNoteTypes)i.value().toInt();
|
|
85 |
|
|
86 |
|
|
87 |
if(aType == EFwUpdRebootNote)
|
|
88 |
{
|
|
89 |
createfotainformativedialog(aType,parameters);
|
|
90 |
}
|
|
91 |
else if(aType == EFwUpdResumeDownload || aType == EFwUpdResumeUpdate)
|
|
92 |
{
|
|
93 |
createfotaconfirmationdialog(aType,parameters);
|
|
94 |
//createfotainformativedialog();
|
|
95 |
}
|
|
96 |
else if(aType == EFwDLNeedMoreMemory || aType == EFwDLConnectionFailure || aType == EFwDLGeneralFailure ||
|
|
97 |
aType == EFwUpdNotEnoughBattery || aType == EFwUpdDeviceBusy || aType == EFwUpdSuccess || aType == EFwUpdNotCompatible
|
|
98 |
|| aType == EFwDLNonResumableFailure)
|
|
99 |
{
|
|
100 |
//createfotamessagedialog();
|
|
101 |
createfotamessagedialog(aType,parameters);
|
|
102 |
}
|
|
103 |
}
|
|
104 |
|
|
105 |
|
|
106 |
// ---------------------------------------------------------------------------
|
|
107 |
// fotadevicedialogs::createfotainformativedialog
|
|
108 |
// This function is called to show the informative dialog of FOTA
|
|
109 |
// ---------------------------------------------------------------------------
|
|
110 |
//
|
|
111 |
void fotadevicedialogs::createfotainformativedialog(TFwUpdNoteTypes aType,const QVariantMap ¶meters)
|
|
112 |
{
|
|
113 |
qDebug("createserveralertinformative start");
|
|
114 |
LOGSTRING("createserveralertinformative start");
|
|
115 |
HbDocumentLoader loader;
|
|
116 |
bool ok = false;
|
|
117 |
loader.load(":/xml/resources/fotainformativedialog.docml", &ok);
|
|
118 |
if (!ok)
|
|
119 |
{
|
|
120 |
return;
|
|
121 |
}
|
|
122 |
HbDialog *dialog = qobject_cast<HbDialog *> (loader.findWidget("dialog"));
|
|
123 |
|
|
124 |
HbLabel *content = qobject_cast<HbLabel *> (loader.findWidget(
|
|
125 |
"lblContent"));
|
|
126 |
|
|
127 |
// No translations required
|
|
128 |
//content->setPlainText("Testing");
|
|
129 |
|
|
130 |
dialog->setTimeout(3000);
|
|
131 |
|
|
132 |
if (dialog)
|
|
133 |
dialog->show();
|
|
134 |
|
|
135 |
QObject::connect(dialog, SIGNAL(aboutToClose()), this, SLOT(okSelected()));
|
|
136 |
|
|
137 |
qDebug("createserveralertinformative end");
|
|
138 |
|
|
139 |
}
|
|
140 |
|
|
141 |
|
|
142 |
|
|
143 |
// ---------------------------------------------------------------------------
|
|
144 |
// fotadevicedialogs::createfotaconfirmationdialog
|
|
145 |
// This function is called to show the confirmation dialog of FOTA.
|
|
146 |
// ---------------------------------------------------------------------------
|
|
147 |
//
|
|
148 |
void fotadevicedialogs::createfotaconfirmationdialog(TFwUpdNoteTypes aType,const QVariantMap ¶meters)
|
|
149 |
{
|
|
150 |
qDebug("createserveralertinformative start");
|
|
151 |
LOGSTRING("createserveralertinformative start");
|
|
152 |
|
|
153 |
QVariantMap::const_iterator i;
|
|
154 |
HbDocumentLoader loader;
|
|
155 |
bool ok = false;
|
|
156 |
HbDialog *dialog = NULL;
|
|
157 |
|
|
158 |
QString param1;
|
|
159 |
QString param2;
|
|
160 |
TInt size = 0;
|
|
161 |
TBool postpone = 0;
|
|
162 |
|
|
163 |
i = parameters.find(keyparam1);
|
|
164 |
if(i != parameters.end())
|
|
165 |
size = i.value().toInt();
|
|
166 |
|
|
167 |
i = parameters.find(keyparam2);
|
|
168 |
if(i != parameters.end())
|
|
169 |
param1 = i.value().toString();
|
|
170 |
i = parameters.find(keyparam3);
|
|
171 |
if(i != parameters.end())
|
|
172 |
param2 = i.value().toString();
|
|
173 |
i = parameters.find(keyparam4);
|
|
174 |
if(i != parameters.end())
|
|
175 |
postpone = i.value().toBool();
|
|
176 |
|
|
177 |
|
|
178 |
switch(aType)
|
|
179 |
{
|
|
180 |
case EFwUpdResumeDownload:
|
|
181 |
{
|
|
182 |
loader.load(":/xml/resources/fotasoftkeysdialog.docml", &ok);
|
|
183 |
if (!ok)
|
|
184 |
{
|
|
185 |
return;
|
|
186 |
}
|
|
187 |
dialog = qobject_cast<HbDialog *> (loader.findWidget("dialog"));
|
|
188 |
|
|
189 |
HbLabel *headingString = qobject_cast<HbLabel *> (loader.findWidget(
|
|
190 |
"lblDialogHeading"));
|
|
191 |
|
|
192 |
headingString->setPlainText(hbTrId("txt_device_update_title_device_update"));
|
|
193 |
|
|
194 |
HbLabel *contentString = qobject_cast<HbLabel *> (loader.findWidget(
|
|
195 |
"lblDialogContent"));
|
|
196 |
|
|
197 |
TReal sizeRounded = 0;
|
|
198 |
TReal sizeKB = size / 1024;
|
|
199 |
if(sizeKB > 1024)
|
|
200 |
{
|
|
201 |
TReal sizeMB = sizeKB / 1024;
|
|
202 |
Math::Round(sizeRounded,sizeMB,2);
|
|
203 |
QString str = hbTrId("txt_device_update_info_the_last_updte_incomp_dwnld_Mb")
|
|
204 |
//.arg(param1).arg(param2).arg(sizeMB);
|
|
205 |
.arg(param2).arg(param1).arg(sizeRounded);
|
|
206 |
contentString->setPlainText(str);//HACK
|
|
207 |
}
|
|
208 |
else
|
|
209 |
{
|
|
210 |
Math::Round(sizeRounded,sizeKB,2);
|
|
211 |
contentString->setPlainText(hbTrId("txt_device_update_info_the_last_update_incomplete_dwnld_kb")
|
|
212 |
.arg(param1).arg(param2).arg(sizeRounded));
|
|
213 |
}
|
|
214 |
//HbAction *primaryAction = dialog->primaryAction();
|
|
215 |
HbAction *primaryAction = (HbAction *) dialog->actions().first();
|
|
216 |
primaryAction->setText(hbTrId("txt_common_button_continue_dialog"));
|
|
217 |
|
|
218 |
//HbAction *secondaryAction = dialog->secondaryAction();
|
|
219 |
HbAction *secondaryAction = (HbAction *) dialog->actions().at(1);
|
|
220 |
secondaryAction->setText(hbTrId("txt_device_update_button_resume_later"));
|
|
221 |
if(!postpone)
|
|
222 |
secondaryAction->setEnabled(postpone);
|
|
223 |
|
|
224 |
dialog->setTimeout(HbPopup::NoTimeout);
|
|
225 |
dialog->setDismissPolicy(HbPopup::NoDismiss);
|
|
226 |
|
|
227 |
QObject::connect(primaryAction, SIGNAL(triggered()), this,
|
|
228 |
SLOT(fotaLSK()));
|
|
229 |
|
|
230 |
QObject::connect(secondaryAction, SIGNAL(triggered()), this,
|
|
231 |
SLOT(fotaRSK()));
|
|
232 |
break;
|
|
233 |
}
|
|
234 |
case EFwUpdResumeUpdate:
|
|
235 |
{
|
|
236 |
bool ok = false;
|
|
237 |
loader.load(":/xml/resources/fotaresumeupdate.docml", &ok);
|
|
238 |
if (!ok)
|
|
239 |
{
|
|
240 |
return;
|
|
241 |
}
|
|
242 |
|
|
243 |
dialog = qobject_cast<HbDialog *> (loader.findWidget("dialog"));
|
|
244 |
|
|
245 |
dialog->setTimeout(HbPopup::NoTimeout);
|
|
246 |
dialog->setDismissPolicy(HbPopup::NoDismiss);
|
|
247 |
|
|
248 |
HbLabel *headingString = qobject_cast<HbLabel *> (loader.findWidget(
|
|
249 |
"lblHeading"));
|
|
250 |
headingString->setPlainText(hbTrId("txt_device_update_title_device_update"));
|
|
251 |
|
|
252 |
|
|
253 |
//HbAction *primaryAction = dialog->primaryAction();
|
|
254 |
HbAction *primaryAction = (HbAction *) dialog->actions().first();
|
|
255 |
primaryAction->setText(hbTrId("txt_common_button_continue_dialog"));
|
|
256 |
|
|
257 |
//HbAction *secondaryAction = dialog->secondaryAction();
|
|
258 |
HbAction *secondaryAction = (HbAction *) dialog->actions().at(1);
|
|
259 |
secondaryAction->setText(hbTrId("txt_device_update_button_resume_later"));
|
|
260 |
if(!postpone)
|
|
261 |
secondaryAction->setEnabled(postpone);
|
|
262 |
|
|
263 |
HbLabel *contentSwDetails = qobject_cast<HbLabel *> (loader.findWidget(
|
|
264 |
"label"));
|
|
265 |
TReal sizeRounded = 0;
|
|
266 |
TReal sizeKB = size / 1024;
|
|
267 |
|
|
268 |
QString content;
|
|
269 |
if(sizeKB > 1024)
|
|
270 |
{
|
|
271 |
TReal sizeMB = sizeKB / 1024;
|
|
272 |
Math::Round(sizeRounded,sizeMB,2);
|
|
273 |
contentSwDetails->setPlainText(hbTrId("txt_device_update_info_the_last_update_incomp_instal_Mb")
|
|
274 |
.arg(param1).arg(param2).arg(sizeRounded));
|
|
275 |
}
|
|
276 |
else
|
|
277 |
{
|
|
278 |
Math::Round(sizeRounded,sizeKB,2);
|
|
279 |
contentSwDetails->setPlainText(hbTrId("txt_device_update_info_the_last_update_incomp_instal_kb")
|
|
280 |
.arg(param1).arg(param2).arg(sizeRounded));
|
|
281 |
}
|
|
282 |
|
|
283 |
HbLabel *contentCharger = qobject_cast<HbLabel *> (loader.findWidget(
|
|
284 |
"label_3"));
|
|
285 |
contentCharger->setPlainText(hbTrId("txt_device_update_info_it_is_recommended_to_connec"));
|
|
286 |
|
|
287 |
HbLabel *contentInstall = qobject_cast<HbLabel *> (loader.findWidget(
|
|
288 |
"label_2"));
|
|
289 |
contentInstall->setPlainText(hbTrId("txt_device_update_info_after_the_installation_the"));
|
|
290 |
|
|
291 |
HbLabel *contentEmergency = qobject_cast<HbLabel *> (loader.findWidget(
|
|
292 |
"label_1"));
|
|
293 |
contentEmergency->setPlainText(hbTrId("txt_device_update_info_during_the_installation_the"));
|
|
294 |
|
|
295 |
dialog->setTimeout(HbPopup::NoTimeout);
|
|
296 |
|
|
297 |
QObject::connect(primaryAction, SIGNAL(triggered()), this,
|
|
298 |
SLOT(fotaLSK()));
|
|
299 |
|
|
300 |
QObject::connect(secondaryAction, SIGNAL(triggered()), this,
|
|
301 |
SLOT(fotaRSK()));
|
|
302 |
}
|
|
303 |
break;
|
|
304 |
default:
|
|
305 |
{
|
|
306 |
break;
|
|
307 |
}
|
|
308 |
}
|
|
309 |
|
|
310 |
if (dialog)
|
|
311 |
dialog->show();
|
|
312 |
|
|
313 |
qDebug("createserveralertinformative end");
|
|
314 |
|
|
315 |
}
|
|
316 |
|
|
317 |
|
|
318 |
// ---------------------------------------------------------------------------
|
|
319 |
// fotadevicedialogs::createfotamessagedialog
|
|
320 |
// This function is called to show the message dialog of FOTA
|
|
321 |
// ---------------------------------------------------------------------------
|
|
322 |
//
|
|
323 |
void fotadevicedialogs::createfotamessagedialog(TFwUpdNoteTypes aType,const QVariantMap ¶meters)
|
|
324 |
{
|
|
325 |
QVariantMap::const_iterator i;
|
|
326 |
qDebug("createserveralertinformative start");
|
|
327 |
LOGSTRING("createserveralertinformative start");
|
|
328 |
HbDocumentLoader loader;
|
|
329 |
bool ok = false;
|
|
330 |
loader.load(":/xml/resources/fotasoftkeydialog.docml", &ok);
|
|
331 |
if (!ok)
|
|
332 |
{
|
|
333 |
return;
|
|
334 |
}
|
|
335 |
HbDialog *dialog = qobject_cast<HbDialog *> (loader.findWidget("dialog"));
|
|
336 |
|
|
337 |
HbLabel *headingString = qobject_cast<HbLabel *> (loader.findWidget(
|
|
338 |
"lblHeaind"));
|
|
339 |
headingString->setPlainText(hbTrId("txt_device_update_title_device_update"));
|
|
340 |
|
|
341 |
HbLabel *contentString = qobject_cast<HbLabel *> (loader.findWidget(
|
|
342 |
"lblContent"));
|
|
343 |
|
|
344 |
dialog->setTimeout(HbPopup::NoTimeout);
|
|
345 |
dialog->setDismissPolicy(HbPopup::NoDismiss);
|
|
346 |
|
|
347 |
//HbAction *primaryAction = dialog->primaryAction();
|
|
348 |
HbAction *primaryAction = (HbAction *) dialog->actions().first();
|
|
349 |
primaryAction->setText(hbTrId("txt_common_button_ok_single_dialog"));
|
|
350 |
|
|
351 |
QObject::connect(primaryAction, SIGNAL(triggered()), this,
|
|
352 |
SLOT(fotaLSK()));
|
|
353 |
|
|
354 |
|
|
355 |
switch(aType)
|
|
356 |
{
|
|
357 |
case EFwDLNeedMoreMemory:
|
|
358 |
{
|
|
359 |
QString content;
|
|
360 |
TInt aMemNeeded = 0;
|
|
361 |
i = parameters.find(keyparam1);
|
|
362 |
if(i != parameters.end())
|
|
363 |
aMemNeeded = i.value().toInt();
|
|
364 |
TInt aMemNeededKB = aMemNeeded / 1024;
|
|
365 |
if(aMemNeededKB <= 1024)
|
|
366 |
{
|
|
367 |
content = hbTrId("txt_de_info_l1_kb_free_memory_needed_for_update").arg(aMemNeededKB);
|
|
368 |
}
|
|
369 |
else
|
|
370 |
{
|
|
371 |
TInt aMemNeededMB = aMemNeededKB / 1024;
|
|
372 |
content = hbTrId("txt_de_info_l1_Mb_free_memory_needed_for_update").arg(aMemNeededMB);
|
|
373 |
}
|
|
374 |
contentString->setPlainText(content);
|
|
375 |
break;
|
|
376 |
}
|
|
377 |
case EFwDLConnectionFailure:
|
|
378 |
{
|
|
379 |
contentString->setPlainText(hbTrId("txt_device_update_info_connection_lost_while_do"));
|
|
380 |
break;
|
|
381 |
}
|
|
382 |
case EFwDLGeneralFailure:
|
|
383 |
{
|
|
384 |
contentString->setPlainText(hbTrId("txt_device_update_info_an_error_occurred_during_do"));
|
|
385 |
break;
|
|
386 |
}
|
|
387 |
case EFwDLNonResumableFailure:
|
|
388 |
{
|
|
389 |
contentString->setPlainText(hbTrId("txt_device_update_info_an_error_occurred_update_stop"));
|
|
390 |
break;
|
|
391 |
}
|
|
392 |
case EFwUpdDeviceBusy:
|
|
393 |
{
|
|
394 |
contentString->setPlainText(hbTrId("txt_device_update_info_FS_warning_device_memory_is_b"));
|
|
395 |
break;
|
|
396 |
}
|
|
397 |
case EFwUpdSuccess:
|
|
398 |
{
|
|
399 |
headingString->setPlainText(hbTrId("txt_device_update_title_phone_uptodate"));
|
|
400 |
contentString->setPlainText(hbTrId("txt_device_update_info_your_phone_is_now_updated_w"));
|
|
401 |
break;
|
|
402 |
}
|
|
403 |
case EFwUpdNotCompatible:
|
|
404 |
{
|
|
405 |
contentString->setPlainText(hbTrId("txt_device_update_info_the_phone_was_not_updated"));
|
|
406 |
break;
|
|
407 |
}
|
|
408 |
case EFwUpdNotEnoughBattery:
|
|
409 |
{
|
|
410 |
contentString->setPlainText(hbTrId("txt_device_update_info_you_will_be_notified_once_t"));
|
|
411 |
break;
|
|
412 |
}
|
|
413 |
default:
|
|
414 |
{
|
|
415 |
break;
|
|
416 |
}
|
|
417 |
}
|
|
418 |
|
|
419 |
if (dialog)
|
|
420 |
dialog->show();
|
|
421 |
|
|
422 |
qDebug("createserveralertinformative end");
|
|
423 |
|
|
424 |
}
|
|
425 |
|
|
426 |
|
|
427 |
// ---------------------------------------------------------------------------
|
|
428 |
// fotadevicedialogs::fotaLSK
|
|
429 |
// This slot is called when LSK is pressed in device dialog.
|
|
430 |
// ---------------------------------------------------------------------------
|
|
431 |
//
|
|
432 |
void fotadevicedialogs::fotaLSK()
|
|
433 |
{
|
|
434 |
qDebug("ok selected");
|
|
435 |
QVariantMap resultMap;
|
|
436 |
resultMap.insert(returnkey, EHbLSK);
|
|
437 |
emit deviceDialogData(resultMap);
|
|
438 |
}
|
|
439 |
|
|
440 |
|
|
441 |
|
|
442 |
// ---------------------------------------------------------------------------
|
|
443 |
// CFotaDownloadNotifHandler::aboutToClose
|
|
444 |
// This slot is called when RSK is pressed in device dialog.
|
|
445 |
// ---------------------------------------------------------------------------
|
|
446 |
//
|
|
447 |
void fotadevicedialogs::fotaRSK()
|
|
448 |
{
|
|
449 |
qDebug("cancel selected");
|
|
450 |
QVariantMap resultMap;
|
|
451 |
resultMap.insert(returnkey, EHbRSK);
|
|
452 |
emit deviceDialogData(resultMap);
|
|
453 |
}
|
|
454 |
|
|
455 |
|
|
456 |
|
|
457 |
// Set parameters
|
|
458 |
bool fotadevicedialogs::setDeviceDialogParameters(
|
|
459 |
const QVariantMap ¶meters)
|
|
460 |
{
|
|
461 |
|
|
462 |
return true;
|
|
463 |
}
|
|
464 |
|
|
465 |
// Get error
|
|
466 |
int fotadevicedialogs::deviceDialogError() const
|
|
467 |
{
|
|
468 |
|
|
469 |
return 0;
|
|
470 |
}
|
|
471 |
|
|
472 |
|
|
473 |
// Close device dialog
|
|
474 |
// ---------------------------------------------------------------------------
|
|
475 |
// fotadevicedialogs::closeDeviceDialog
|
|
476 |
// This slot is called when device dialog is closed due to errors.
|
|
477 |
// ---------------------------------------------------------------------------
|
|
478 |
//
|
|
479 |
|
|
480 |
void fotadevicedialogs::closeDeviceDialog(bool byClient)
|
|
481 |
{
|
|
482 |
qDebug("cancel selected");
|
|
483 |
emit deviceDialogClosed();
|
|
484 |
}
|
|
485 |
|
|
486 |
|
|
487 |
// Return display widget
|
|
488 |
HbDialog *fotadevicedialogs::deviceDialogWidget() const
|
|
489 |
{
|
|
490 |
|
|
491 |
return const_cast<fotadevicedialogs*>(this);
|
|
492 |
//return const_cast<devicemanagementnotifierwidget*>(this);
|
|
493 |
}
|