phonesettings/cpphonesettingsplugins/barringplugin/src/cpbarringplugingroup.cpp
branchGCC_SURGE
changeset 51 f39ed5e045e0
parent 30 ebdbd102c78a
parent 45 6b911d05207e
equal deleted inserted replaced
40:bab96b7ed1a4 51:f39ed5e045e0
   104     DPRINT << ": IN";
   104     DPRINT << ": IN";
   105     
   105     
   106     CpSettingFormItemData* formItem = 
   106     CpSettingFormItemData* formItem = 
   107         static_cast<CpSettingFormItemData*>(
   107         static_cast<CpSettingFormItemData*>(
   108             qobject_cast<const HbDataFormModel*>(item.model())->itemFromIndex(item));
   108             qobject_cast<const HbDataFormModel*>(item.model())->itemFromIndex(item));
   109     
   109 
   110     if (!formItem->property("barringType").isValid()) {
   110     if (!formItem->contentWidgetData("barringType").isValid()) {
   111         // Shown item does not belong to the barring settings group.
   111         // Shown item does not belong to the barring settings group.
   112         return;
   112         return;
   113         }
   113         }
   114     
   114     
   115     m_model = const_cast<HbDataFormModel*>(qobject_cast<const HbDataFormModel*>(item.model()));
   115     m_model = const_cast<HbDataFormModel*>(qobject_cast<const HbDataFormModel*>(item.model()));
   268     barringItem->setContentWidgetData("text", QVariant(widgetTextData));
   268     barringItem->setContentWidgetData("text", QVariant(widgetTextData));
   269     barringItem->setEnabled(false);
   269     barringItem->setEnabled(false);
   270     
   270     
   271     QVariant value;
   271     QVariant value;
   272     value.setValue(barringType);
   272     value.setValue(barringType);
   273     barringItem->setProperty("barringType", value);
   273     barringItem->setContentWidgetData("barringType", value);
   274     
   274     
   275     appendChild(barringItem.data());
   275     appendChild(barringItem.data());
   276     DPRINT << ": OUT";
   276     DPRINT << ": OUT";
   277     return barringItem.take();
   277     return barringItem.take();
   278 }
   278 }
   299         m_phoneNotes->cancelNote(m_activeNoteId);
   299         m_phoneNotes->cancelNote(m_activeNoteId);
   300         m_phoneNotes->showGlobalErrorNote(m_activeNoteId, result);
   300         m_phoneNotes->showGlobalErrorNote(m_activeNoteId, result);
   301         m_barringRequestQueue.clear();
   301         m_barringRequestQueue.clear();
   302         return;
   302         return;
   303     }
   303     }
   304     
   304 
   305     CpSettingFormItemData *itemForCompletedRequest = 
   305     if (!m_barringRequestQueue.isEmpty()) {
   306         m_barringRequestQueue.dequeue();
   306         CpSettingFormItemData *itemForCompletedRequest = 
   307     
   307             m_barringRequestQueue.dequeue();
   308     if (!itemForCompletedRequest->isEnabled()) {
   308     
   309         // After enabling setting item here status query will not be started 
   309         if (!itemForCompletedRequest->isEnabled()) {
   310         // again for the item when user collapses and expands the barring 
   310             // After enabling setting item here status query will not be started 
   311         // settings group again.
   311             // again for the item when user collapses and expands the barring 
   312         itemForCompletedRequest->setEnabled(true);
   312             // settings group again.
   313         // start to observe user initiated state changes
   313             itemForCompletedRequest->setEnabled(true);
   314         m_helper.addConnection(
   314             // start to observe user initiated state changes
   315             itemForCompletedRequest, SIGNAL(stateChanged(int)),
   315             m_helper.addConnection(
   316             this, SLOT(changeBarringStateRequested(int)));
   316                 itemForCompletedRequest, SIGNAL(stateChanged(int)),
   317     }
   317                 this, SLOT(changeBarringStateRequested(int)));
   318     
   318         }
   319     Qt::CheckState checkState = 
   319     
   320         (PSetCallBarringWrapper::BarringStatusActive == status) 
   320         Qt::CheckState checkState = 
   321             ? Qt::Checked 
   321             (PSetCallBarringWrapper::BarringStatusActive == status) 
   322             : Qt::Unchecked;
   322                 ? Qt::Checked 
   323     updateCheckStateOfItem(*itemForCompletedRequest, checkState);
   323                 : Qt::Unchecked;
   324     
   324         updateCheckStateOfItem(*itemForCompletedRequest, checkState);
       
   325     }
   325     if (m_barringRequestQueue.isEmpty()) {
   326     if (m_barringRequestQueue.isEmpty()) {
   326         m_phoneNotes->cancelNote(m_activeNoteId);
   327         m_phoneNotes->cancelNote(m_activeNoteId);
   327         if (m_delayedBarringActivationNote) {
   328         if (m_delayedBarringActivationNote) {
   328             m_delayedBarringActivationNote = false;
   329             m_delayedBarringActivationNote = false;
   329             m_phoneNotes->showGlobalNote(
   330             m_phoneNotes->showNotificationDialog(hbTrId("txt_phone_info_barring_activated"));
   330                 m_activeNoteId, 
       
   331                 hbTrId("txt_phone_info_barring_activated"),
       
   332                 HbMessageBox::MessageTypeInformation);
       
   333         }
   331         }
   334         
   332         
   335         // Password editing is enabled only after all barring statuses are 
   333         // Password editing is enabled only after all barring statuses are 
   336         // queried. Otherwise user may be able to issue two requests 
   334         // queried. Otherwise user may be able to issue two requests 
   337         // simultaneously by hiding status query progress note and clicking 
   335         // simultaneously by hiding status query progress note and clicking 
   338         // edit password.
   336         // edit password.
   339         if (!m_editBarringPasswordItem->isEnabled()) {
   337         if (!m_editBarringPasswordItem->isEnabled()) {
   340             m_editBarringPasswordItem->setEnabled(true);
   338             m_editBarringPasswordItem->setEnabled(true);
   341             m_helper.addConnection(
   339             m_helper.addConnection(
   342                 m_editBarringPasswordItem, SIGNAL(clicked(bool)),
   340                 m_editBarringPasswordItem, SIGNAL(valueChanged(QPersistentModelIndex, QVariant)),
   343                 this, SLOT(changeBarringPasswordRequested(bool)));
   341                 this, SLOT(changeBarringPasswordRequested()));
   344         }
   342         }
   345     } else {
   343     } else {
   346         processBarringStatusRequestQueue();
   344         processBarringStatusRequestQueue();
   347     }
   345     }
   348     
   346     
   363         << "barringStatus:" << barringStatus << "plural:" << plural;
   361         << "barringStatus:" << barringStatus << "plural:" << plural;
   364     Q_UNUSED(barringType)
   362     Q_UNUSED(barringType)
   365     Q_UNUSED(barringStatus)
   363     Q_UNUSED(barringStatus)
   366     Q_UNUSED(plural)
   364     Q_UNUSED(plural)
   367     
   365     
   368     CpSettingFormItemData *barringItem = m_barringRequestQueue.dequeue();
   366     if (!m_barringRequestQueue.isEmpty()) {
   369     if (PSetCallBarringWrapper::BarringErrorNone == result) {
   367         CpSettingFormItemData *barringItem = m_barringRequestQueue.dequeue();
   370         if (updateDependentBarringProgramStatuses(*barringItem)) {
   368         if (PSetCallBarringWrapper::BarringErrorNone == result) {
   371             // Indicate barring activation completion only when dependent 
   369             if (updateDependentBarringProgramStatuses(*barringItem)) {
   372             // barring items are also updated.
   370                 // Indicate barring activation completion only when dependent 
   373             m_delayedBarringActivationNote = true;
   371                 // barring items are also updated.
       
   372                 m_delayedBarringActivationNote = true;
       
   373             } else {
       
   374                 m_phoneNotes->cancelNote(m_activeNoteId);
       
   375                 m_phoneNotes->showNotificationDialog(hbTrId("txt_phone_info_barring_activated"));
       
   376             }
   374         } else {
   377         } else {
       
   378             revertCheckStateOfItem(barringItem);
       
   379         
   375             m_phoneNotes->cancelNote(m_activeNoteId);
   380             m_phoneNotes->cancelNote(m_activeNoteId);
   376             m_phoneNotes->showGlobalNote(
   381             m_phoneNotes->showGlobalErrorNote(m_activeNoteId, result);
   377                 m_activeNoteId, 
   382         }
   378                 hbTrId("txt_phone_info_barring_activated"),
       
   379                 HbMessageBox::MessageTypeInformation);
       
   380         }
       
   381     } else {
       
   382         revertCheckStateOfItem(barringItem);
       
   383         
       
   384         m_phoneNotes->cancelNote(m_activeNoteId);
       
   385         m_phoneNotes->showGlobalErrorNote(m_activeNoteId, result);
       
   386     }
   383     }
   387     
   384     
   388     DPRINT << ": OUT";
   385     DPRINT << ": OUT";
   389 }
   386 }
   390 
   387 
   404     Q_UNUSED(barringStatus)
   401     Q_UNUSED(barringStatus)
   405     Q_UNUSED(plural)
   402     Q_UNUSED(plural)
   406     
   403     
   407     m_phoneNotes->cancelNote(m_activeNoteId);
   404     m_phoneNotes->cancelNote(m_activeNoteId);
   408     
   405     
   409     CpSettingFormItemData *barringItem = m_barringRequestQueue.dequeue();
       
   410     if (PSetCallBarringWrapper::BarringErrorNone == result) {
   406     if (PSetCallBarringWrapper::BarringErrorNone == result) {
   411         m_phoneNotes->showGlobalNote(
   407         m_phoneNotes->showNotificationDialog(hbTrId("txt_phone_info_barring_deactivated"));
   412             m_activeNoteId, 
       
   413             hbTrId("txt_phone_info_barring_deactivated"),
       
   414             HbMessageBox::MessageTypeInformation);
       
   415     } else {
   408     } else {
   416         revertCheckStateOfItem(barringItem);
   409         if (!m_barringRequestQueue.isEmpty()) {
       
   410             CpSettingFormItemData *barringItem = m_barringRequestQueue.dequeue();
       
   411             revertCheckStateOfItem(barringItem);
       
   412         }
   417         
   413         
   418         m_phoneNotes->showGlobalErrorNote(m_activeNoteId, result);
   414         m_phoneNotes->showGlobalErrorNote(m_activeNoteId, result);
   419     }
   415     }
   420     
   416     
   421     DPRINT << ": OUT";
   417     DPRINT << ": OUT";
   430     DPRINT << ": IN: result:" << result;
   426     DPRINT << ": IN: result:" << result;
   431     
   427     
   432     m_phoneNotes->cancelNote(m_activeNoteId);
   428     m_phoneNotes->cancelNote(m_activeNoteId);
   433     
   429     
   434     if (PSetCallBarringWrapper::BarringErrorNone == result) {
   430     if (PSetCallBarringWrapper::BarringErrorNone == result) {
   435         m_phoneNotes->showGlobalNote(
   431         m_phoneNotes->showNotificationDialog(hbTrId("txt_phone_info_password_changed"));
   436             m_activeNoteId, 
       
   437             hbTrId("txt_phone_info_password_changed"),
       
   438             HbMessageBox::MessageTypeInformation);
       
   439     } else {
   432     } else {
   440         m_phoneNotes->showGlobalErrorNote(m_activeNoteId, result);
   433         m_phoneNotes->showGlobalErrorNote(m_activeNoteId, result);
   441     }
   434     }
   442 }
   435 }
   443 
   436 
   453         (!m_barringRequestQueue.isEmpty())) {
   446         (!m_barringRequestQueue.isEmpty())) {
   454         
   447         
   455         CpSettingFormItemData *item = m_barringRequestQueue.head();
   448         CpSettingFormItemData *item = m_barringRequestQueue.head();
   456         PSetCallBarringWrapper::BarringType barringType =
   449         PSetCallBarringWrapper::BarringType barringType =
   457             qvariant_cast<PSetCallBarringWrapper::BarringType>(
   450             qvariant_cast<PSetCallBarringWrapper::BarringType>(
   458                 item->property("barringType"));
   451                 item->contentWidgetData("barringType"));
   459         m_barringWrapper->barringStatus(ServiceGroupVoice, barringType);
   452         m_barringWrapper->barringStatus(ServiceGroupVoice, barringType);
   460         
   453         
   461         m_barringStatusRequestOngoing = true;
   454         m_barringStatusRequestOngoing = true;
   462         
   455         
   463         if (!m_phoneNotes->noteShowing()) {
   456         if (!m_phoneNotes->noteShowing()) {
   464             // Launch progress note only once for status update.
   457             // Launch progress note only once for status update.
   465             m_phoneNotes->showGlobalProgressNote(
   458             m_phoneNotes->showGlobalProgressNote(
   466                 m_activeNoteId, hbTrId("txt_phone_info_requesting"));
   459                 m_activeNoteId, hbTrId("txt_common_info_requesting"));
   467         }
   460         }
   468     }
   461     }
   469     
   462     
   470     DPRINT << ": OUT";
   463     DPRINT << ": OUT";
   471 }
   464 }
   515     DPRINT << ": IN";
   508     DPRINT << ": IN";
   516     
   509     
   517 	QObject::disconnect(
   510 	QObject::disconnect(
   518         m_phoneNotes, SIGNAL(passwordQueryCompleted(QString, bool)),
   511         m_phoneNotes, SIGNAL(passwordQueryCompleted(QString, bool)),
   519         this, SLOT(completeBarringStateChangeRequestHandling(QString, bool)));
   512         this, SLOT(completeBarringStateChangeRequestHandling(QString, bool)));
   520     if (okPressed) {
   513     if (okPressed && m_clickedBarringItem) {
   521         QVariant checkState = m_clickedBarringItem->contentWidgetData("checkState");
   514         QVariant checkState = m_clickedBarringItem->contentWidgetData("checkState");
   522         if (Qt::Checked == checkState.toInt()) {
   515         if (Qt::Checked == checkState.toInt()) {
   523             m_barringWrapper->enableBarring(
   516             m_barringWrapper->enableBarring(
   524                 ServiceGroupVoice,
   517                 ServiceGroupVoice,
   525                 qvariant_cast<PSetCallBarringWrapper::BarringType>(
   518                 qvariant_cast<PSetCallBarringWrapper::BarringType>(
   526                     m_clickedBarringItem->property("barringType")), 
   519                     m_clickedBarringItem->contentWidgetData("barringType")),
   527                 barringPassword);
   520                 barringPassword);
   528         } else {
   521         } else {
   529             m_barringWrapper->disableBarring(
   522             m_barringWrapper->disableBarring(
   530                 ServiceGroupVoice,
   523                 ServiceGroupVoice,
   531                 qvariant_cast<PSetCallBarringWrapper::BarringType>(
   524                 qvariant_cast<PSetCallBarringWrapper::BarringType>(
   532                     m_clickedBarringItem->property("barringType")), 
   525                     m_clickedBarringItem->contentWidgetData("barringType")),
   533                 barringPassword);
   526                 barringPassword);
   534         }
   527         }
   535         
   528         
   536         m_barringRequestQueue.enqueue(m_clickedBarringItem);
   529         m_barringRequestQueue.enqueue(m_clickedBarringItem);
   537         m_phoneNotes->showGlobalProgressNote(
   530         m_phoneNotes->showGlobalProgressNote(
   538             m_activeNoteId, hbTrId("txt_phone_info_requesting"));
   531             m_activeNoteId, hbTrId("txt_common_info_requesting"));
   539     } else {
   532     } else if (m_clickedBarringItem) {
   540         revertCheckStateOfItem(m_clickedBarringItem);
   533         revertCheckStateOfItem(m_clickedBarringItem);
   541     }
   534     }
   542     m_clickedBarringItem = NULL;
   535     m_clickedBarringItem = NULL;
   543         
   536         
   544     DPRINT << ": OUT";
   537     DPRINT << ": OUT";
   545 }
   538 }
   546 
   539 
   547 /*!
   540 /*!
   548   CpBarringPluginGroup::changeBarringPasswordRequested.
   541   CpBarringPluginGroup::changeBarringPasswordRequested.
   549  */
   542  */
   550 void CpBarringPluginGroup::changeBarringPasswordRequested(bool checked)
   543 void CpBarringPluginGroup::changeBarringPasswordRequested()
   551 {
   544 {
   552     DPRINT << ": IN";
   545     DPRINT << ": IN";
   553     Q_UNUSED(checked)
       
   554     
   546     
   555     m_changeBarringPasswordPhase = CurrentPasswordPhase;
   547     m_changeBarringPasswordPhase = CurrentPasswordPhase;
   556     QString currentPasswordQueryDialogTitle(
   548     QString currentPasswordQueryDialogTitle(
   557         hbTrId("txt_phone_info_current_password"));
   549         hbTrId("txt_phone_info_current_password"));
   558     QObject::connect(
   550     QObject::connect(
   612                     m_currentPassword,
   604                     m_currentPassword,
   613                     m_newPassword,
   605                     m_newPassword,
   614                     m_newPasswordVerified);
   606                     m_newPasswordVerified);
   615                 m_phoneNotes->showGlobalProgressNote(
   607                 m_phoneNotes->showGlobalProgressNote(
   616                     m_activeNoteId, 
   608                     m_activeNoteId, 
   617                     hbTrId("txt_phone_info_requesting"));
   609                     hbTrId("txt_common_info_requesting"));
   618                 QObject::disconnect(
   610                 QObject::disconnect(
   619                     m_phoneNotes, SIGNAL(passwordQueryCompleted(QString, bool)),
   611                     m_phoneNotes, SIGNAL(passwordQueryCompleted(QString, bool)),
   620                     this, SLOT(changeBarringPasswordPhasesHandling(QString, bool)));
   612                     this, SLOT(changeBarringPasswordPhasesHandling(QString, bool)));
   621                 }
   613                 }
   622                 break;
   614                 break;
   649     DPRINT << ": IN";
   641     DPRINT << ": IN";
   650     
   642     
   651     CpSettingFormItemData* barringItem = NULL;
   643     CpSettingFormItemData* barringItem = NULL;
   652     PSetCallBarringWrapper::BarringType barringType =
   644     PSetCallBarringWrapper::BarringType barringType =
   653         qvariant_cast<PSetCallBarringWrapper::BarringType>(
   645         qvariant_cast<PSetCallBarringWrapper::BarringType>(
   654             changedBarringItem.property("barringType"));
   646             changedBarringItem.contentWidgetData("barringType"));
   655     QList<CpSettingFormItemData*> itemCandidatesForUpdate;
   647     QList<CpSettingFormItemData*> itemCandidatesForUpdate;
   656     switch (barringType) {
   648     switch (barringType) {
   657         case PSetCallBarringWrapper::BarringTypeAllOutgoing:
   649         case PSetCallBarringWrapper::BarringTypeAllOutgoing:
   658         {
   650         {
   659             barringItem = &barringItemByProgram(
   651             barringItem = &barringItemByProgram(
   748     for (int childInd = 0; (childInd < numOfChilds) && (!item); childInd++) {
   740     for (int childInd = 0; (childInd < numOfChilds) && (!item); childInd++) {
   749         CpSettingFormItemData *itemCandidate = 
   741         CpSettingFormItemData *itemCandidate = 
   750             static_cast<CpSettingFormItemData*>(childAt(childInd));
   742             static_cast<CpSettingFormItemData*>(childAt(childInd));
   751         PSetCallBarringWrapper::BarringType candidateBarringProgram =
   743         PSetCallBarringWrapper::BarringType candidateBarringProgram =
   752             qvariant_cast<PSetCallBarringWrapper::BarringType>(
   744             qvariant_cast<PSetCallBarringWrapper::BarringType>(
   753                 itemCandidate->property("barringType"));
   745                 itemCandidate->contentWidgetData("barringType"));
   754         if (candidateBarringProgram == barringProgram) {
   746         if (candidateBarringProgram == barringProgram) {
   755             item = itemCandidate;
   747             item = itemCandidate;
   756         }
   748         }
   757     }
   749     }
   758     
   750