13 * |
13 * |
14 * Description: Software install notification plugin class. |
14 * Description: Software install notification plugin class. |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "sifuidialog.h" |
18 #include "sifuidialog.h" // SifUiDialog |
19 #include "sifuidialogtitlewidget.h" |
19 #include "sifuidialogtitlewidget.h" // SifUiDialogTitleWidget |
20 #include "sifuidialogcontentwidget.h" |
20 #include "sifuidialogcontentwidget.h" // SifUiDialogContentWidget |
|
21 #include "sifuidialoggrantcapabilities.h" // SifUiDialogGrantCapabilities |
21 #include "sifuiinstallindicatorparams.h" |
22 #include "sifuiinstallindicatorparams.h" |
22 #include <QFile> |
23 #include <QFile> |
23 #include <hblabel.h> |
24 #include <hblabel.h> |
24 #include <hbaction.h> |
25 #include <hbaction.h> |
25 #include <hbindicator.h> |
26 #include <hbindicator.h> |
42 // ---------------------------------------------------------------------------- |
43 // ---------------------------------------------------------------------------- |
43 // |
44 // |
44 SifUiDialog::SifUiDialog(const QVariantMap ¶meters) : HbDialog(), |
45 SifUiDialog::SifUiDialog(const QVariantMap ¶meters) : HbDialog(), |
45 mCommonTranslator(0), mSifUITranslator(0), mLastDialogError(KErrNone), |
46 mCommonTranslator(0), mSifUITranslator(0), mLastDialogError(KErrNone), |
46 mShowEventReceived(false), mDialogType(SifUiUnspecifiedDialog), |
47 mShowEventReceived(false), mDialogType(SifUiUnspecifiedDialog), |
47 mTitle(0), mContent(0), mPrimaryAction(0), mSecondaryAction(0), |
48 mTitle(0), mContent(0), mErrorDetails(), mErrorCode(KErrNone), |
|
49 mExtendedErrorCode(KErrNone), mPrimaryAction(0), mSecondaryAction(0), |
48 mResultMap(), mIndicator(0), mSubscriber(0) |
50 mResultMap(), mIndicator(0), mSubscriber(0) |
49 { |
51 { |
50 mCommonTranslator = new HbTranslator(KTranslationsPath, KCommonTranslationsFile); |
52 mCommonTranslator = new HbTranslator(KTranslationsPath, KCommonTranslationsFile); |
51 mSifUITranslator = new HbTranslator(KTranslationsPath, KSifUiTranslationsFile); |
53 mSifUITranslator = new HbTranslator(KTranslationsPath, KSifUiTranslationsFile); |
52 constructDialog(parameters); |
54 constructDialog(parameters); |
198 // ---------------------------------------------------------------------------- |
200 // ---------------------------------------------------------------------------- |
199 // |
201 // |
200 bool SifUiDialog::updateFromParameters(const QVariantMap ¶meters) |
202 bool SifUiDialog::updateFromParameters(const QVariantMap ¶meters) |
201 { |
203 { |
202 SifUiDeviceDialogType prevDialogType = mDialogType; |
204 SifUiDeviceDialogType prevDialogType = mDialogType; |
203 mDialogType = dialogType(parameters); |
205 if (!displayAdditionalQuery(parameters)) { |
204 if (mTitle) |
206 mDialogType = dialogType(parameters); |
205 { |
207 if (mTitle) |
206 mTitle->updateFromParameters(parameters); |
208 { |
|
209 mTitle->updateFromParameters(parameters); |
|
210 } |
|
211 if (mContent) |
|
212 { |
|
213 mContent->updateFromParameters(parameters); |
|
214 } |
|
215 if (prevDialogType != mDialogType) { |
|
216 updateButtons(parameters); |
207 } |
217 } |
208 if (mContent) |
218 prepareForErrorDetails(parameters); |
209 { |
|
210 mContent->updateFromParameters(parameters); |
|
211 } |
|
212 if (prevDialogType != mDialogType) { |
|
213 updateButtons(parameters); |
|
214 } |
|
215 if (parameters.contains(KSifUiErrorCode)) { |
|
216 bool ok = false; |
|
217 int errorCode = parameters.value(KSifUiErrorCode).toInt(&ok); |
|
218 if (ok) { |
|
219 mInstallError = errorCode; |
|
220 } |
|
221 } |
219 } |
222 return true; |
220 return true; |
223 } |
221 } |
224 |
222 |
225 // ---------------------------------------------------------------------------- |
223 // ---------------------------------------------------------------------------- |
298 break; |
296 break; |
299 } |
297 } |
300 } |
298 } |
301 |
299 |
302 // ---------------------------------------------------------------------------- |
300 // ---------------------------------------------------------------------------- |
|
301 // SifUiDialog::prepareForErrorDetails() |
|
302 // ---------------------------------------------------------------------------- |
|
303 // |
|
304 void SifUiDialog::prepareForErrorDetails(const QVariantMap ¶meters) |
|
305 { |
|
306 if (parameters.contains(KSifUiErrorDetails)) { |
|
307 mErrorDetails = parameters.value(KSifUiErrorDetails).toString(); |
|
308 } |
|
309 if (parameters.contains(KSifUiErrorCode)) { |
|
310 bool ok = false; |
|
311 int errorCode = parameters.value(KSifUiErrorCode).toInt(&ok); |
|
312 if (ok) { |
|
313 mErrorCode = errorCode; |
|
314 } |
|
315 } |
|
316 if (parameters.contains(KSifUiErrorCodeExtended)) { |
|
317 bool ok = false; |
|
318 int errorCode = parameters.value(KSifUiErrorCodeExtended).toInt(&ok); |
|
319 if (ok) { |
|
320 mExtendedErrorCode = errorCode; |
|
321 } |
|
322 } |
|
323 } |
|
324 |
|
325 // ---------------------------------------------------------------------------- |
|
326 // SifUiDialog::displayAdditionalQuery() |
|
327 // ---------------------------------------------------------------------------- |
|
328 // |
|
329 bool SifUiDialog::displayAdditionalQuery(const QVariantMap ¶meters) |
|
330 { |
|
331 if (parameters.contains(KSifUiGrantCapabilities)) { |
|
332 SifUiDialogGrantCapabilities *dlg = new SifUiDialogGrantCapabilities( |
|
333 mContent->applicationName(), parameters.value(KSifUiGrantCapabilities)); |
|
334 connect(dlg, SIGNAL(accepted()), this, SLOT(handleCapabilitiesGranted())); |
|
335 connect(dlg, SIGNAL(declined()), this, SLOT(handleCapabilitiesDenied())); |
|
336 dlg->setAttribute(Qt::WA_DeleteOnClose, true); |
|
337 dlg->open(); |
|
338 return true; |
|
339 } |
|
340 return false; |
|
341 } |
|
342 |
|
343 // ---------------------------------------------------------------------------- |
303 // SifUiDialog::sendResult() |
344 // SifUiDialog::sendResult() |
304 // ---------------------------------------------------------------------------- |
345 // ---------------------------------------------------------------------------- |
305 // |
346 // |
306 void SifUiDialog::sendResult(SifUiDeviceDialogReturnValue value) |
347 void SifUiDialog::sendResult(SifUiDeviceDialogReturnValue value) |
307 { |
348 { |
361 XQAiwRequest *request = applicationManager.create(openRecentView); |
402 XQAiwRequest *request = applicationManager.create(openRecentView); |
362 if (request) { |
403 if (request) { |
363 bool result = request->send(); |
404 bool result = request->send(); |
364 if (result) { |
405 if (result) { |
365 closeDeviceDialog(false); |
406 closeDeviceDialog(false); |
366 } else { |
407 } // else error silently ignored |
367 // TODO: proper error handling |
408 delete request; |
368 int error = request->lastError(); |
409 } |
369 QString messageText = tr("Unable to open AppLib. Error %1").arg(error); |
410 |
370 HbMessageBox::warning(messageText); |
411 close(); |
|
412 } |
|
413 |
|
414 // ---------------------------------------------------------------------------- |
|
415 // SifUiDialog::handleErrorDetails() |
|
416 // ---------------------------------------------------------------------------- |
|
417 // |
|
418 void SifUiDialog::handleErrorDetails() |
|
419 { |
|
420 QString messageText = mErrorDetails; |
|
421 |
|
422 if (QFile::exists(KSwiErrorsFile)) { |
|
423 messageText.append(KSwiErrorFormat.arg(mErrorCode)); |
|
424 if (mExtendedErrorCode) { |
|
425 messageText.append(KSwiErrorFormat.arg(mExtendedErrorCode)); |
371 } |
426 } |
372 delete request; |
427 } |
373 } |
428 |
374 |
|
375 close(); |
|
376 } |
|
377 |
|
378 // ---------------------------------------------------------------------------- |
|
379 // SifUiDialog::handleErrorDetails() |
|
380 // ---------------------------------------------------------------------------- |
|
381 // |
|
382 void SifUiDialog::handleErrorDetails() |
|
383 { |
|
384 // TODO: show proper error details dialog |
|
385 QString messageText; |
|
386 messageText = tr("Error code %1").arg(mInstallError); |
|
387 |
|
388 if (QFile::exists(KSwiErrorsFile)) { |
|
389 messageText.append(KSwiErrorFormat.arg(mInstallError)); |
|
390 } |
|
391 HbMessageBox::warning(messageText); |
429 HbMessageBox::warning(messageText); |
392 } |
430 } |
393 |
431 |
|
432 // ---------------------------------------------------------------------------- |
|
433 // SifUiDialog::handleCapabilitiesGranted() |
|
434 // ---------------------------------------------------------------------------- |
|
435 // |
|
436 void SifUiDialog::handleCapabilitiesGranted() |
|
437 { |
|
438 sendResult(SifUiContinue); |
|
439 } |
|
440 |
|
441 // ---------------------------------------------------------------------------- |
|
442 // SifUiDialog::handleCapabilitiesDenied() |
|
443 // ---------------------------------------------------------------------------- |
|
444 // |
|
445 void SifUiDialog::handleCapabilitiesDenied() |
|
446 { |
|
447 sendResult(SifUiCancel); |
|
448 } |
|
449 |