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), mResultMap(), mPrimaryAction(0), |
48 mTitle(0), mContent(0), mErrorDetails(), mErrorCode(KErrNone), |
48 mSecondaryAction(0), mIndicator(0), mSubscriber(0) |
49 mExtendedErrorCode(KErrNone), mPrimaryAction(0), mSecondaryAction(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); |
53 } |
55 } |
181 mTitle->constructFromParameters(parameters); |
183 mTitle->constructFromParameters(parameters); |
182 setHeadingWidget(mTitle); |
184 setHeadingWidget(mTitle); |
183 |
185 |
184 Q_ASSERT(mContent == 0); |
186 Q_ASSERT(mContent == 0); |
185 mContent = new SifUiDialogContentWidget(this); |
187 mContent = new SifUiDialogContentWidget(this); |
186 mContent->constructFromParameters(parameters); |
|
187 connect(mContent, SIGNAL(memorySelectionChanged(const QChar &)), |
188 connect(mContent, SIGNAL(memorySelectionChanged(const QChar &)), |
188 this, SLOT(handleMemorySelectionChanged(const QChar &))); |
189 this, SLOT(handleMemorySelectionChanged(const QChar &))); |
|
190 mContent->constructFromParameters(parameters); |
189 setContentWidget(mContent); |
191 setContentWidget(mContent); |
190 |
192 |
191 updateButtons(parameters); |
193 updateButtons(parameters); |
192 |
194 |
193 return true; |
195 return true; |
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 { |
308 QVariant returnValue(value); |
349 mResultMap[KSifUiQueryReturnValue] = QVariant(value); |
309 mResultMap.insert(KSifUiQueryReturnValue, returnValue); |
|
310 emit deviceDialogData(mResultMap); |
350 emit deviceDialogData(mResultMap); |
311 } |
351 } |
312 |
352 |
313 // ---------------------------------------------------------------------------- |
353 // ---------------------------------------------------------------------------- |
314 // SifUiDialog::handleAccepted() |
354 // SifUiDialog::handleAccepted() |
334 // SifUiDialog::handleMemorySelectionChanged() |
374 // SifUiDialog::handleMemorySelectionChanged() |
335 // ---------------------------------------------------------------------------- |
375 // ---------------------------------------------------------------------------- |
336 // |
376 // |
337 void SifUiDialog::handleMemorySelectionChanged(const QChar &driveLetter) |
377 void SifUiDialog::handleMemorySelectionChanged(const QChar &driveLetter) |
338 { |
378 { |
339 QVariant memorySelection(driveLetter); |
379 mResultMap[KSifUiSelectedMemory] = QVariant(driveLetter); |
340 mResultMap.insert(KSifUiSelectedMemory, memorySelection); |
380 emit deviceDialogData(mResultMap); |
341 } |
381 } |
342 |
382 |
343 // ---------------------------------------------------------------------------- |
383 // ---------------------------------------------------------------------------- |
344 // SifUiDialog::handleHidePressed() |
384 // SifUiDialog::handleHidePressed() |
345 // ---------------------------------------------------------------------------- |
385 // ---------------------------------------------------------------------------- |
362 XQAiwRequest *request = applicationManager.create(openRecentView); |
402 XQAiwRequest *request = applicationManager.create(openRecentView); |
363 if (request) { |
403 if (request) { |
364 bool result = request->send(); |
404 bool result = request->send(); |
365 if (result) { |
405 if (result) { |
366 closeDeviceDialog(false); |
406 closeDeviceDialog(false); |
367 } else { |
407 } // else error silently ignored |
368 // TODO: proper error handling |
408 delete request; |
369 int error = request->lastError(); |
409 } |
370 QString messageText = tr("Unable to open AppLib. Error %1").arg(error); |
410 |
371 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)); |
372 } |
426 } |
373 delete request; |
427 } |
374 } |
428 |
375 |
|
376 close(); |
|
377 } |
|
378 |
|
379 // ---------------------------------------------------------------------------- |
|
380 // SifUiDialog::handleErrorDetails() |
|
381 // ---------------------------------------------------------------------------- |
|
382 // |
|
383 void SifUiDialog::handleErrorDetails() |
|
384 { |
|
385 // TODO: show proper error details dialog |
|
386 QString messageText; |
|
387 messageText = tr("Error code %1").arg(mInstallError); |
|
388 |
|
389 if (QFile::exists(KSwiErrorsFile)) { |
|
390 messageText.append(KSwiErrorFormat.arg(mInstallError)); |
|
391 } |
|
392 HbMessageBox::warning(messageText); |
429 HbMessageBox::warning(messageText); |
393 } |
430 } |
394 |
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 |