42 : |
39 : |
43 CpSettingFormItemData( |
40 CpSettingFormItemData( |
44 HbDataFormModelItem::GroupItem, |
41 HbDataFormModelItem::GroupItem, |
45 hbTrId("txt_phone_subhead_call_barring"), 0), |
42 hbTrId("txt_phone_subhead_call_barring"), 0), |
46 m_helper(helper), |
43 m_helper(helper), |
47 m_translator(0), |
|
48 m_pSetWrapper(0), |
44 m_pSetWrapper(0), |
49 m_barringWrapper(0), |
45 m_barringWrapper(0), |
50 m_editBarringPasswordItem(0), |
46 m_editBarringPasswordItem(0), |
51 m_barringStatusRequestOngoing(false), |
47 m_barringStatusRequestOngoing(false), |
52 m_activeNoteId(0), |
48 m_activeNoteId(0), |
53 m_phoneNotes(0), |
49 m_phoneNotes(0), |
54 m_barringPasswordValidator(0), |
50 m_barringPasswordValidator(0), |
55 m_delayedBarringActivationNote(false) |
51 m_delayedBarringActivationNote(false), |
|
52 m_clickedBarringItem(NULL), |
|
53 m_changeBarringPasswordPhase(NonePhase), |
|
54 m_verifyPasswordValidator(NULL), |
|
55 m_model(0) |
56 { |
56 { |
57 DPRINT << ": IN"; |
57 DPRINT << ": IN"; |
58 |
58 |
59 // Registration needed, because BarringType is used as a custom meta |
59 // Registration needed, because BarringType is used as a custom meta |
60 // information for barring items. |
60 // information for barring items. |
61 qRegisterMetaType<PSetCallBarringWrapper::BarringType>( |
61 qRegisterMetaType<PSetCallBarringWrapper::BarringType>( |
62 "PSetCallBarringWrapper::BarringType"); |
62 "PSetCallBarringWrapper::BarringType"); |
63 |
63 |
64 setupLocalization(); |
|
65 |
|
66 m_pSetWrapper.reset(new PSetWrapper(NULL)); |
64 m_pSetWrapper.reset(new PSetWrapper(NULL)); |
67 m_barringWrapper = &m_pSetWrapper->callBarringWrapper(); |
65 m_barringWrapper = &m_pSetWrapper->callBarringWrapper(); |
68 setupConnectionsToWrapper(); |
66 setupConnectionsToWrapper(); |
69 |
67 |
70 // itemShown signal is used to trigger barring status query process |
68 // itemShown signal is used to trigger barring status query process |
496 CpBarringPluginGroup::changeBarringStateRequested. |
475 CpBarringPluginGroup::changeBarringStateRequested. |
497 */ |
476 */ |
498 void CpBarringPluginGroup::changeBarringStateRequested(int checkState) |
477 void CpBarringPluginGroup::changeBarringStateRequested(int checkState) |
499 { |
478 { |
500 DPRINT << ": IN"; |
479 DPRINT << ": IN"; |
501 |
480 Q_UNUSED(checkState) |
502 // find form item for which user has requested barring status change |
481 // find form item for which user has requested barring status change |
503 QObject *signalSender = sender(); |
482 QObject *signalSender = sender(); |
504 HbDataFormModel *formModel = qobject_cast<HbDataFormModel*>(model()); |
483 |
505 CpSettingFormItemData* barringItem = NULL; |
|
506 int numOfChilds = childCount(); |
484 int numOfChilds = childCount(); |
507 for (int i = 0; (i < numOfChilds) && (barringItem == NULL); i++) { |
485 for (int i = 0; (i < numOfChilds) && (m_clickedBarringItem == NULL); i++) { |
508 HbDataFormModelItem* itemCandidate = childAt(i); |
486 HbDataFormModelItem* itemCandidate = childAt(i); |
509 QModelIndex modelIndex = formModel->indexFromItem(itemCandidate); |
487 QModelIndex modelIndex = m_model->indexFromItem(itemCandidate); |
510 if (signalSender == m_helper.widgetFromModelIndex(modelIndex)) { |
488 if (signalSender == m_helper.widgetFromModelIndex(modelIndex)) { |
511 barringItem = static_cast<CpSettingFormItemData*>(itemCandidate); |
489 m_clickedBarringItem = static_cast<CpSettingFormItemData*>(itemCandidate); |
512 } |
490 } |
513 } |
491 } |
514 |
492 |
515 if (NULL != barringItem) { |
493 if (NULL != m_clickedBarringItem) { |
516 QString barringPasswordQueryDialogTitle( |
494 QString barringPasswordQueryDialogTitle( |
517 hbTrId("txt_phone_info_barring_password")); |
495 hbTrId("txt_phone_info_barring_password")); |
518 QString barringPassword; |
496 |
519 bool okPressed = false; |
497 QObject::connect( |
|
498 m_phoneNotes, SIGNAL(passwordQueryCompleted(QString, bool)), |
|
499 this, SLOT(completeBarringStateChangeRequestHandling(QString, bool))); |
520 m_phoneNotes->showPasswordQueryDialog( |
500 m_phoneNotes->showPasswordQueryDialog( |
521 barringPasswordQueryDialogTitle, *m_barringPasswordValidator, |
501 barringPasswordQueryDialogTitle, *m_barringPasswordValidator, |
522 KMaxPasswordLength, barringPassword, okPressed); |
502 KMaxPasswordLength); |
523 if (!okPressed) { |
503 } |
524 revertCheckStateOfItem(barringItem); |
504 |
525 return; |
505 DPRINT << ": OUT"; |
526 } |
506 } |
527 |
507 |
528 if (Qt::Checked == checkState) { |
508 /*! |
|
509 CpBarringPluginGroup::completeBarringStateChangeRequestHandling. |
|
510 */ |
|
511 void CpBarringPluginGroup::completeBarringStateChangeRequestHandling( |
|
512 QString barringPassword, |
|
513 bool okPressed) |
|
514 { |
|
515 DPRINT << ": IN"; |
|
516 |
|
517 QObject::disconnect( |
|
518 m_phoneNotes, SIGNAL(passwordQueryCompleted(QString, bool)), |
|
519 this, SLOT(completeBarringStateChangeRequestHandling(QString, bool))); |
|
520 if (okPressed) { |
|
521 QVariant checkState = m_clickedBarringItem->contentWidgetData("checkState"); |
|
522 if (Qt::Checked == checkState.toInt()) { |
529 m_barringWrapper->enableBarring( |
523 m_barringWrapper->enableBarring( |
530 ServiceGroupVoice, |
524 ServiceGroupVoice, |
531 qvariant_cast<PSetCallBarringWrapper::BarringType>( |
525 qvariant_cast<PSetCallBarringWrapper::BarringType>( |
532 barringItem->property("barringType")), |
526 m_clickedBarringItem->property("barringType")), |
533 barringPassword); |
527 barringPassword); |
534 } else { |
528 } else { |
535 m_barringWrapper->disableBarring( |
529 m_barringWrapper->disableBarring( |
536 ServiceGroupVoice, |
530 ServiceGroupVoice, |
537 qvariant_cast<PSetCallBarringWrapper::BarringType>( |
531 qvariant_cast<PSetCallBarringWrapper::BarringType>( |
538 barringItem->property("barringType")), |
532 m_clickedBarringItem->property("barringType")), |
539 barringPassword); |
533 barringPassword); |
540 } |
534 } |
541 |
535 |
542 m_barringRequestQueue.enqueue(barringItem); |
536 m_barringRequestQueue.enqueue(m_clickedBarringItem); |
543 m_phoneNotes->showGlobalProgressNote( |
537 m_phoneNotes->showGlobalProgressNote( |
544 m_activeNoteId, hbTrId("txt_phone_info_requesting")); |
538 m_activeNoteId, hbTrId("txt_phone_info_requesting")); |
545 } |
539 } else { |
546 |
540 revertCheckStateOfItem(m_clickedBarringItem); |
547 DPRINT << ": OUT"; |
541 } |
548 } |
542 m_clickedBarringItem = NULL; |
549 |
543 |
|
544 DPRINT << ": OUT"; |
|
545 } |
550 |
546 |
551 /*! |
547 /*! |
552 CpBarringPluginGroup::changeBarringPasswordRequested. |
548 CpBarringPluginGroup::changeBarringPasswordRequested. |
553 */ |
549 */ |
554 void CpBarringPluginGroup::changeBarringPasswordRequested(bool checked) |
550 void CpBarringPluginGroup::changeBarringPasswordRequested(bool checked) |
555 { |
551 { |
556 DPRINT << ": IN"; |
552 DPRINT << ": IN"; |
557 Q_UNUSED(checked) |
553 Q_UNUSED(checked) |
558 |
554 |
559 bool okPressed = false; |
555 m_changeBarringPasswordPhase = CurrentPasswordPhase; |
560 |
|
561 QString currentPassword; |
|
562 QString currentPasswordQueryDialogTitle( |
556 QString currentPasswordQueryDialogTitle( |
563 hbTrId("txt_phone_info_current_password")); |
557 hbTrId("txt_phone_info_current_password")); |
|
558 QObject::connect( |
|
559 m_phoneNotes, SIGNAL(passwordQueryCompleted(QString, bool)), |
|
560 this, SLOT(changeBarringPasswordPhasesHandling(QString, bool))); |
564 m_phoneNotes->showPasswordQueryDialog( |
561 m_phoneNotes->showPasswordQueryDialog( |
565 currentPasswordQueryDialogTitle, *m_barringPasswordValidator, |
562 currentPasswordQueryDialogTitle, |
566 KMaxPasswordLength, currentPassword, okPressed); |
563 *m_barringPasswordValidator, |
567 if (!okPressed) { |
564 KMaxPasswordLength); |
568 return; |
565 |
569 } |
566 DPRINT << ": OUT"; |
570 |
567 } |
571 QString newPassword; |
568 |
572 QString newPasswordQueryDialogTitle( |
569 /*! |
573 hbTrId("txt_phone_info_new_password")); |
570 CpBarringPluginGroup::changeBarringPasswordPhasesHandling. |
574 m_phoneNotes->showPasswordQueryDialog( |
571 */ |
575 newPasswordQueryDialogTitle, *m_barringPasswordValidator, |
572 void CpBarringPluginGroup::changeBarringPasswordPhasesHandling( |
576 KMaxPasswordLength, newPassword, okPressed); |
573 QString barringPassword, |
577 if (!okPressed) { |
574 bool okPressed) |
578 return; |
575 { |
579 } |
576 DPRINT << ": IN"; |
580 |
577 |
581 QString newPasswordVerifyDialogTitle( |
|
582 hbTrId("txt_phone_info_verify_new_password")); |
|
583 QString newPasswordVerified; |
|
584 QRegExp regExpression(newPassword); |
|
585 QScopedPointer<QValidator> verifyPasswordValidator( |
|
586 new QRegExpValidator(regExpression, NULL)); |
|
587 m_phoneNotes->showPasswordQueryDialog( |
|
588 newPasswordVerifyDialogTitle, *verifyPasswordValidator.data(), |
|
589 KMaxPasswordLength, newPasswordVerified, okPressed); |
|
590 |
|
591 if (okPressed) { |
578 if (okPressed) { |
592 m_barringWrapper->changeBarringPassword( |
579 switch (m_changeBarringPasswordPhase) { |
593 currentPassword, |
580 case CurrentPasswordPhase: { |
594 newPassword, |
581 m_changeBarringPasswordPhase = NewPasswordPhase; |
595 newPasswordVerified); |
582 m_currentPassword = barringPassword; |
596 |
583 QString newPasswordQueryDialogTitle( |
597 m_phoneNotes->showGlobalProgressNote( |
584 hbTrId("txt_phone_info_new_password")); |
598 m_activeNoteId, hbTrId("txt_phone_info_requesting")); |
585 m_phoneNotes->showPasswordQueryDialog( |
599 } |
586 newPasswordQueryDialogTitle, |
600 |
587 *m_barringPasswordValidator, |
|
588 KMaxPasswordLength); |
|
589 } |
|
590 break; |
|
591 case NewPasswordPhase: { |
|
592 m_changeBarringPasswordPhase = VerifyNewPasswordPhase; |
|
593 m_newPassword = barringPassword; |
|
594 QString newPasswordVerifyDialogTitle( |
|
595 hbTrId("txt_phone_info_verify_new_password")); |
|
596 QRegExp regExpression(m_newPassword); |
|
597 if(m_verifyPasswordValidator) { |
|
598 delete m_verifyPasswordValidator; |
|
599 m_verifyPasswordValidator = NULL; |
|
600 } |
|
601 m_verifyPasswordValidator = new QRegExpValidator(regExpression, NULL); |
|
602 m_phoneNotes->showPasswordQueryDialog( |
|
603 newPasswordVerifyDialogTitle, |
|
604 *m_verifyPasswordValidator, |
|
605 KMaxPasswordLength); |
|
606 } |
|
607 break; |
|
608 case VerifyNewPasswordPhase: { |
|
609 m_changeBarringPasswordPhase = NonePhase; |
|
610 m_newPasswordVerified = barringPassword; |
|
611 m_barringWrapper->changeBarringPassword( |
|
612 m_currentPassword, |
|
613 m_newPassword, |
|
614 m_newPasswordVerified); |
|
615 m_phoneNotes->showGlobalProgressNote( |
|
616 m_activeNoteId, |
|
617 hbTrId("txt_phone_info_requesting")); |
|
618 QObject::disconnect( |
|
619 m_phoneNotes, SIGNAL(passwordQueryCompleted(QString, bool)), |
|
620 this, SLOT(changeBarringPasswordPhasesHandling(QString, bool))); |
|
621 } |
|
622 break; |
|
623 default: |
|
624 DPRINT << "Error: unknown enum value"; |
|
625 break; |
|
626 } |
|
627 } |
|
628 else { |
|
629 QObject::disconnect( |
|
630 m_phoneNotes, SIGNAL(passwordQueryCompleted(QString, bool)), |
|
631 this, SLOT(changeBarringPasswordPhasesHandling(QString, bool))); |
|
632 m_changeBarringPasswordPhase = NonePhase; |
|
633 } |
|
634 |
601 DPRINT << ": OUT"; |
635 DPRINT << ": OUT"; |
602 } |
636 } |
603 |
637 |
604 |
638 |
605 /*! |
639 /*! |