phonesettings/cpphonesettingsplugins/divertplugin/src/cpdivertplugingroup.cpp
changeset 65 2a5d4ab426d3
parent 50 377c906a8701
child 74 d1c62c765e48
equal deleted inserted replaced
60:1eef62f5c541 65:2a5d4ab426d3
    15  *
    15  *
    16  */
    16  */
    17 
    17 
    18 #include <hbdataformmodel.h>
    18 #include <hbdataformmodel.h>
    19 #include <hbdataformmodelitem.h>
    19 #include <hbdataformmodelitem.h>
    20 #include <hblineedit.h>
       
    21 #include <hbinputeditorinterface.h>
       
    22 #include <hbcombobox.h>
       
    23 #include <hbdeviceprogressdialog.h>
       
    24 #include <sssettingswrapper.h>
    20 #include <sssettingswrapper.h>
    25 #include <psetwrapper.h>
    21 #include <psetwrapper.h>
    26 #include <hbaction.h>
       
    27 #include <hblistwidget.h>
       
    28 #include <hblistwidgetitem.h>
       
    29 #include <hblabel.h>
       
    30 #include <hbparameterlengthlimiter.h>
       
    31 #include <cpitemdatahelper.h>
    22 #include <cpitemdatahelper.h>
    32 #include <psuinotes.h>
    23 #include <psuinotes.h>
    33 #include "cpdivertplugingroup.h"
    24 #include "cpdivertplugingroup.h"
    34 #include "cpplugincommon.h"
    25 #include "cpplugincommon.h"
    35 #include "cppluginlogging.h"
    26 #include "cppluginlogging.h"
    36 #include "cpdivertitemdata.h"
    27 #include "cpdivertitemdata.h"
       
    28 #include "cpdivertquery.h"
    37 
    29 
    38 Q_DECLARE_METATYPE(PsCallDivertingCondition)
    30 Q_DECLARE_METATYPE(PsCallDivertingCondition)
    39 Q_DECLARE_METATYPE(PsServiceGroup)
    31 Q_DECLARE_METATYPE(PsServiceGroup)
    40 
       
    41 // CONSTANTS 
       
    42 const QString KOtherNumber("otherNumber");
       
    43 
    32 
    44 /*!
    33 /*!
    45   CpDivertPluginGroup::CpDivertPluginGroup.
    34   CpDivertPluginGroup::CpDivertPluginGroup.
    46  */
    35  */
    47 CpDivertPluginGroup::CpDivertPluginGroup(CpItemDataHelper &helper)
    36 CpDivertPluginGroup::CpDivertPluginGroup(CpItemDataHelper &helper)
    58        m_DataItemVideoIfOutOfReach(NULL),
    47        m_DataItemVideoIfOutOfReach(NULL),
    59        m_DataItemVideoIfNotAvailable(NULL),
    48        m_DataItemVideoIfNotAvailable(NULL),
    60        m_activeNoteId(0),
    49        m_activeNoteId(0),
    61        m_activeProgressNoteId(0),
    50        m_activeProgressNoteId(0),
    62        m_helper(helper),
    51        m_helper(helper),
    63        m_activateDivertPhase(NonePhase),
    52        m_activateDivertPopUp(0)
    64        m_dialog(NULL)
       
    65 {
    53 {
    66     DPRINT << ": IN";
    54     DPRINT << ": IN";
    67     
    55     
    68     // Registration needed, because PsCallDivertingCondition and PsServiceGroup
    56     // Registration needed, because PsCallDivertingCondition and PsServiceGroup
    69     // is used as a custom meta information for barring items.
    57     // is used as a custom meta information for barring items.
   100         m_callDivertingWrapper, 
    88         m_callDivertingWrapper, 
   101         SIGNAL(requestDone()),
    89         SIGNAL(requestDone()),
   102         this,
    90         this,
   103         SLOT(divertRequestProcessed()));
    91         SLOT(divertRequestProcessed()));
   104     
    92     
       
    93     m_activateDivertPopUp = new CpDivertQuery(*m_callDivertingWrapper);
       
    94     QObject::connect(
       
    95         m_activateDivertPopUp, 
       
    96         SIGNAL(result(PSCallDivertingCommand &)),
       
    97         this,
       
    98         SLOT(divertQueryOk(PSCallDivertingCommand &)));
       
    99     
       
   100     QObject::connect(
       
   101         m_activateDivertPopUp, 
       
   102         SIGNAL(cancelled(PSCallDivertingCommand &)),
       
   103         this,
       
   104         SLOT(divertQueryCancelled(PSCallDivertingCommand &)));
       
   105 
       
   106     QObject::connect(
       
   107         m_activateDivertPopUp, 
       
   108         SIGNAL(handleDivertingError(int)),
       
   109         this, 
       
   110         SLOT(handleDivertingError(int)));
       
   111     
   105     // Listen form item visibility change
   112     // Listen form item visibility change
   106     m_helper.connectToForm(
   113     m_helper.connectToForm(
   107             SIGNAL(itemShown(QModelIndex)), this, SLOT(itemShown(QModelIndex)));
   114             SIGNAL(itemShown(QModelIndex)), this, SLOT(itemShown(QModelIndex)));
   108     
   115     
   109     // Create grouped setting items
   116     // Create grouped setting items
   110     createVoiceCallItems(this);
   117     createVoiceCallItems(this);
   111     createVideoCallItems(this);
   118     createVideoCallItems(this);
   112         
   119 
   113     DPRINT << ": OUT";
   120     DPRINT << ": OUT";
   114 }
   121 }
   115 
   122 
   116 /*!
   123 /*!
   117   CpDivertPluginGroup::~CpDivertPluginGroup.
   124   CpDivertPluginGroup::~CpDivertPluginGroup.
   118  */
   125  */
   119 CpDivertPluginGroup::~CpDivertPluginGroup()
   126 CpDivertPluginGroup::~CpDivertPluginGroup()
   120 {
   127 {
   121     DPRINT << ": IN";
   128     DPRINT << ": IN";
   122 
   129     delete m_activateDivertPopUp;
   123     delete m_pSetWrapper;
   130     delete m_pSetWrapper;
   124     delete m_ssSettingsWrapper;
   131     delete m_ssSettingsWrapper;
   125     
   132     
   126     DPRINT << ": OUT";
   133     DPRINT << ": OUT";
   127 }
   134 }
   133 {
   140 {
   134     DPRINT << ": IN";
   141     DPRINT << ": IN";
   135     CpSettingFormItemData *page = new CpSettingFormItemData(
   142     CpSettingFormItemData *page = new CpSettingFormItemData(
   136                 HbDataFormModelItem::GroupPageItem,
   143                 HbDataFormModelItem::GroupPageItem,
   137                 hbTrId("txt_phone_setlabel_service_val_voice_divert"),
   144                 hbTrId("txt_phone_setlabel_service_val_voice_divert"),
   138                 this);
   145                 parent);
   139     page->setObjectName("voiceCallSettingsGroupItem");
   146     page->setObjectName("voiceCallSettingsGroupItem");
   140 
   147 
   141     m_DataItemVoiceAllCalls = createDivertItem(
   148     m_DataItemVoiceAllCalls = createDivertItem(
   142             DivertConditionUnconditional,
   149             DivertConditionUnconditional,
   143             ServiceGroupVoice,
   150             ServiceGroupVoice,
   174             DivertConditionAllConditionalCases,
   181             DivertConditionAllConditionalCases,
   175             ServiceGroupVoice,
   182             ServiceGroupVoice,
   176             hbTrId("txt_phone_setlabel_if_not_available"),
   183             hbTrId("txt_phone_setlabel_if_not_available"),
   177             hbTrId("txt_phone_setlabel_if_not_available"), true,
   184             hbTrId("txt_phone_setlabel_if_not_available"), true,
   178             page);
   185             page);
       
   186     
   179     m_DataItemVoiceIfNotAvailable->setObjectName("voiceIfNotAvailableDataItem");
   187     m_DataItemVoiceIfNotAvailable->setObjectName("voiceIfNotAvailableDataItem");
   180 
   188 
   181     DPRINT << ": OUT";
   189     DPRINT << ": OUT";
   182 }
   190 }
   183 
   191 
   189     DPRINT << ": IN";
   197     DPRINT << ": IN";
   190     
   198     
   191     CpSettingFormItemData *page = new CpSettingFormItemData(
   199     CpSettingFormItemData *page = new CpSettingFormItemData(
   192             HbDataFormModelItem::GroupPageItem,
   200             HbDataFormModelItem::GroupPageItem,
   193             hbTrId("txt_phone_setlabel_service_val_video_divert"),
   201             hbTrId("txt_phone_setlabel_service_val_video_divert"),
   194             this);
   202             parent);
   195     page->setObjectName("videoCallSettingsGroupItem"); 
   203     page->setObjectName("videoCallSettingsGroupItem"); 
   196     
   204     
   197     m_DataItemVideoAllCalls = createDivertItem(
   205     m_DataItemVideoAllCalls = createDivertItem(
   198             DivertConditionUnconditional,
   206             DivertConditionUnconditional,
   199             ServiceGroupData,
   207             ServiceGroupData,
   230             DivertConditionAllConditionalCases,
   238             DivertConditionAllConditionalCases,
   231             ServiceGroupData,
   239             ServiceGroupData,
   232             hbTrId("txt_phone_setlabel_if_not_available"),
   240             hbTrId("txt_phone_setlabel_if_not_available"),
   233             hbTrId("txt_phone_setlabel_if_not_available"), true,
   241             hbTrId("txt_phone_setlabel_if_not_available"), true,
   234             page);
   242             page);
       
   243     
   235     m_DataItemVideoIfNotAvailable->setObjectName("videoIfNotAvailableDataItem");
   244     m_DataItemVideoIfNotAvailable->setObjectName("videoIfNotAvailableDataItem");
   236     
   245     
   237     DPRINT << ": OUT";
   246     DPRINT << ": OUT";
   238 }
   247 }
   239 
   248 
   301     }
   310     }
   302     
   311     
   303     DPRINT << ": OUT";
   312     DPRINT << ": OUT";
   304 }
   313 }
   305 
   314 
       
   315 
       
   316 /*!
       
   317   CpDivertPluginGroup::divertQueryOk.
       
   318  */
       
   319 void CpDivertPluginGroup::divertQueryOk(PSCallDivertingCommand &command)
       
   320 {
       
   321     DPRINT << ": IN";
       
   322     setCallDiverting(command);
       
   323     DPRINT << ": OUT";
       
   324 }
       
   325 
       
   326 /*!
       
   327   CpDivertPluginGroup::divertQueryCancelled.
       
   328  */
       
   329 void CpDivertPluginGroup::divertQueryCancelled(PSCallDivertingCommand &command)
       
   330 {
       
   331     DPRINT << ": IN";
       
   332     revertItemData(command.iServiceGroup, command.iCondition);
       
   333     divertRequestProcessed();
       
   334     DPRINT << ": OUT";
       
   335 }
       
   336 
   306 /*!
   337 /*!
   307   CpDivertPluginGroup::addToDivertingRequestQueue.
   338   CpDivertPluginGroup::addToDivertingRequestQueue.
   308  */
   339  */
   309 void CpDivertPluginGroup::addToDivertingRequestQueue(
   340 void CpDivertPluginGroup::addToDivertingRequestQueue(
   310         DivertRequest request, CpDivertItemData &item)
   341         DivertRequest request, CpDivertItemData &item)
   316     i.item = &item;
   347     i.item = &item;
   317     m_divertRequestQueue.enqueue(i);
   348     m_divertRequestQueue.enqueue(i);
   318 
   349 
   319     if (m_divertRequestQueue.count() == 1) {
   350     if (m_divertRequestQueue.count() == 1) {
   320         // Process if first item was added, process other later
   351         // Process if first item was added, process other later
       
   352 		disableDivertItems();
   321         processDivertingRequestQueue();
   353         processDivertingRequestQueue();
   322     }
   354     }
   323 
   355 
   324     DPRINT << ": OUT";
   356     DPRINT << ": OUT";
   325 }
   357 }
   328   CpDivertPluginGroup::divertRequestProcessed.
   360   CpDivertPluginGroup::divertRequestProcessed.
   329  */
   361  */
   330 void CpDivertPluginGroup::divertRequestProcessed()
   362 void CpDivertPluginGroup::divertRequestProcessed()
   331 {
   363 {
   332     DPRINT << ": IN";
   364     DPRINT << ": IN";
   333     
       
   334     // Remove previous request and process next one
   365     // Remove previous request and process next one
   335     if (!m_divertRequestQueue.isEmpty()) {
   366     if (!m_divertRequestQueue.isEmpty()) {
   336         m_divertRequestQueue.dequeue();
   367         m_divertRequestQueue.dequeue();
   337         processDivertingRequestQueue();
   368         processDivertingRequestQueue();
   338     }
   369     }
   339 
   370 
   340     if (m_divertRequestQueue.isEmpty()) {
   371     if (m_divertRequestQueue.isEmpty()) {
   341         // Queue empty so cancel process note
   372         // Queue empty so cancel process note
   342         PsUiNotes::instance()->cancelNote(m_activeProgressNoteId);
   373         PsUiNotes::instance()->cancelNote(m_activeProgressNoteId);
       
   374         m_activeProgressNoteId = 0;
       
   375         enableDivertItems();
       
   376         updateDependentDivertOptions();
   343     }
   377     }
   344     
   378     
   345     DPRINT << ": OUT";
   379     DPRINT << ": OUT";
   346 }
   380 }
   347 
   381 
   398                 } else {
   432                 } else {
   399                     itemData->setDescription("");
   433                     itemData->setDescription("");
   400                 }
   434                 }
   401             }
   435             }
   402             itemData->setContentWidgetData("checkState", itemState);
   436             itemData->setContentWidgetData("checkState", itemState);
   403             itemData->setEnabled(true);
       
   404         }
   437         }
   405         
   438         
   406         if (serviceGroup & ServiceGroupData) {
   439         if (serviceGroup & ServiceGroupData) {
   407             CpSettingFormItemData* itemData = item(ServiceGroupData, condition);
   440             CpSettingFormItemData* itemData = item(ServiceGroupData, condition);
   408             itemData->setContentWidgetData("text", numberValue);
   441             itemData->setContentWidgetData("text", numberValue);
   413                 } else {
   446                 } else {
   414                     itemData->setDescription("");
   447                     itemData->setDescription("");
   415                 }
   448                 }
   416             }
   449             }
   417             itemData->setContentWidgetData("checkState", itemState);
   450             itemData->setContentWidgetData("checkState", itemState);
   418             itemData->setEnabled(true);
       
   419         }
   451         }
   420         
   452         
   421         break;
   453         break;
   422     case DivertConditionAllCalls:
   454     case DivertConditionAllCalls:
   423     case DivertConditionUnknown:
   455     case DivertConditionUnknown:
   510     DPRINT << ": OUT";
   542     DPRINT << ": OUT";
   511     return ret;
   543     return ret;
   512 }
   544 }
   513 
   545 
   514 /*!
   546 /*!
       
   547   CpDivertPluginGroup::disableDivertItems.
       
   548  */
       
   549 void CpDivertPluginGroup::disableDivertItems(){
       
   550     DPRINT << ": IN";
       
   551     
       
   552     m_DataItemVoiceAllCalls->setEnabled(false);
       
   553     m_DataItemVoiceIfBusy->setEnabled(false);
       
   554     m_DataItemVoiceIfNotAnswered->setEnabled(false);
       
   555     m_DataItemVoiceIfOutOfReach->setEnabled(false);
       
   556     m_DataItemVoiceIfNotAvailable->setEnabled(false);
       
   557     
       
   558     m_DataItemVideoAllCalls->setEnabled(false);
       
   559     m_DataItemVideoIfBusy->setEnabled(false);
       
   560     m_DataItemVideoIfNotAnswered->setEnabled(false);
       
   561     m_DataItemVideoIfOutOfReach->setEnabled(false);
       
   562     m_DataItemVideoIfNotAvailable->setEnabled(false);
       
   563     
       
   564     DPRINT << ": OUT";
       
   565 }
       
   566 
       
   567 /*!
       
   568   CpDivertPluginGroup::enableDivertItems.
       
   569  */
       
   570 void CpDivertPluginGroup::enableDivertItems(){
       
   571     DPRINT << ": IN";
       
   572     
       
   573     // all calls divert activation deactivates automatically other diverts
       
   574     QVariant itemState = m_DataItemVoiceAllCalls->contentWidgetData("checkState");
       
   575     if ((itemState.isValid()) && 
       
   576         (itemState.toInt() == Qt::Checked) &&
       
   577                 (m_DataItemVoiceAllCalls->contentWidgetData("text") != "")) {
       
   578         m_DataItemVoiceAllCalls->setEnabled(true);
       
   579         deactivateDependentDivertOption(m_DataItemVoiceIfBusy);
       
   580         deactivateDependentDivertOption(m_DataItemVoiceIfNotAnswered);
       
   581         deactivateDependentDivertOption(m_DataItemVoiceIfOutOfReach);
       
   582         deactivateDependentDivertOption(m_DataItemVoiceIfNotAvailable);
       
   583     }else{
       
   584         m_DataItemVoiceAllCalls->setEnabled(true);
       
   585         m_DataItemVoiceIfBusy->setEnabled(true);
       
   586         m_DataItemVoiceIfNotAnswered->setEnabled(true);
       
   587         m_DataItemVoiceIfOutOfReach->setEnabled(true);
       
   588         m_DataItemVoiceIfNotAvailable->setEnabled(true);
       
   589     }
       
   590     
       
   591     // all calls divert activation deactivates automatically other diverts
       
   592     itemState = m_DataItemVideoAllCalls->contentWidgetData("checkState");
       
   593     if ((itemState.isValid()) && 
       
   594             (itemState.toInt() == Qt::Checked) &&
       
   595                     (m_DataItemVideoAllCalls->contentWidgetData("text") != "")) {
       
   596         m_DataItemVideoAllCalls->setEnabled(true);
       
   597         deactivateDependentDivertOption(m_DataItemVideoIfBusy);
       
   598         deactivateDependentDivertOption(m_DataItemVideoIfNotAnswered);
       
   599         deactivateDependentDivertOption(m_DataItemVideoIfOutOfReach);
       
   600         deactivateDependentDivertOption(m_DataItemVideoIfNotAvailable);
       
   601     }else{
       
   602         m_DataItemVideoAllCalls->setEnabled(true);
       
   603         m_DataItemVideoIfBusy->setEnabled(true);
       
   604         m_DataItemVideoIfNotAnswered->setEnabled(true);
       
   605         m_DataItemVideoIfOutOfReach->setEnabled(true);
       
   606         m_DataItemVideoIfNotAvailable->setEnabled(true);
       
   607     }
       
   608     
       
   609     DPRINT << ": OUT";
       
   610 }
       
   611 
       
   612 /*!
   515   CpDivertPluginGroup::processDivertingRequestQueue.
   613   CpDivertPluginGroup::processDivertingRequestQueue.
   516  */
   614  */
   517 void CpDivertPluginGroup::processDivertingRequestQueue()
   615 void CpDivertPluginGroup::processDivertingRequestQueue()
   518 {
   616 {
   519     DPRINT << ": IN";
   617     DPRINT << ": IN";
   521         DPRINT << "queue empty : OUT";
   619         DPRINT << "queue empty : OUT";
   522         return;
   620         return;
   523     }
   621     }
   524     CpDivertRequestQueueItem request = m_divertRequestQueue.head();
   622     CpDivertRequestQueueItem request = m_divertRequestQueue.head();
   525     // Command param
   623     // Command param
   526     m_divertCommand.iServiceGroup = qvariant_cast<PsServiceGroup>(
   624     PSCallDivertingCommand command;
       
   625     command.iServiceGroup = qvariant_cast<PsServiceGroup>(
   527             request.item->property("serviceGroup"));
   626             request.item->property("serviceGroup"));
   528     m_divertCommand.iCondition = qvariant_cast<PsCallDivertingCondition>(
   627     command.iCondition = qvariant_cast<PsCallDivertingCondition>(
   529             request.item->property("condition"));
   628             request.item->property("condition"));
   530     m_divertCommand.iStatus = DivertingStatusUnknown;
   629     command.iStatus = DivertingStatusUnknown;
   531     m_divertCommand.iNumber = "";
   630     command.iNumber = "";
   532     m_divertCommand.iNoReplyTimer = 0;
   631     command.iNoReplyTimer = 0;
   533 
   632 
   534     switch (request.request) {
   633     switch (request.request) {
   535         case ActivateDivert: {
   634         case ActivateDivert: {
   536             DPRINT << "activate";
   635             DPRINT << "activate";
   537             m_divertCommand.iSetting = RegisterDiverting;
   636             command.iSetting = RegisterDiverting;
   538             m_activateDivertPhase = PopUpVoiceNumberListQueryPhase;
   637             m_activateDivertPopUp->show(
   539             popUpVoiceNumberListQuery(
   638                     request.item->property("queryLabel").toString(),
   540                 request.item->property("queryLabel").toString(),
   639                     command,
   541                         m_divertCommand.iServiceGroup);
   640                     request.item->property("needTimeoutInfo").toBool());
   542         }
   641         }
   543             break;
   642             break;
   544         case DeactivateDivert: {
   643         case DeactivateDivert: {
   545             DPRINT << "deactivate";
   644             DPRINT << "deactivate";
   546             m_divertCommand.iSetting = EraseDiverting;
   645             command.iSetting = EraseDiverting;
   547             setCallDiverting(m_divertCommand);
   646             setCallDiverting(command);
   548         }
   647         }
   549             break;
   648             break;
   550         case CheckDivertStatus: {
   649         case CheckDivertStatus: {
   551             DPRINT << "check status";
   650             DPRINT << "check status";
   552             m_callDivertingWrapper->getCallDivertingStatus(
   651             m_callDivertingWrapper->getCallDivertingStatus(
   553                 m_divertCommand.iServiceGroup,
   652                 command.iServiceGroup,
   554                 m_divertCommand.iCondition,
   653                 command.iCondition,
   555                 bscParam(m_divertCommand.iServiceGroup) );
   654                 bscParam(command.iServiceGroup) );
   556             
   655             if (!m_activeProgressNoteId && !PsUiNotes::instance()->noteShowing()) {
   557             if (!PsUiNotes::instance()->noteShowing()) {
       
   558                 PsUiNotes::instance()->showGlobalProgressNote(
   656                 PsUiNotes::instance()->showGlobalProgressNote(
   559                         m_activeProgressNoteId, 
   657                         m_activeProgressNoteId, 
   560                         hbTrId("txt_common_info_requesting"));
   658                         hbTrId("txt_common_info_requesting"));
   561             }
   659             }
   562         }
   660         }
   688   CpDivertPluginGroup::handleDivertingError.
   786   CpDivertPluginGroup::handleDivertingError.
   689  */
   787  */
   690 void CpDivertPluginGroup::handleDivertingError(int aReason)
   788 void CpDivertPluginGroup::handleDivertingError(int aReason)
   691 {
   789 {
   692     DPRINT << ": IN : aReason:" << aReason;
   790     DPRINT << ": IN : aReason:" << aReason;
   693     
   791 
   694     // Update view item for failed request
   792     // Update view item for failed request
   695     if (m_divertRequestQueue.count()) {
   793     if (m_divertRequestQueue.count()) {
   696         revertItemData(
   794         revertItemData(
   697             qvariant_cast<PsServiceGroup>(
   795             qvariant_cast<PsServiceGroup>(
   698                     m_divertRequestQueue.head().item->property("serviceGroup")),
   796                     m_divertRequestQueue.head().item->property("serviceGroup")),
   707     PsUiNotes::instance()->cancelNote(m_activeNoteId);
   805     PsUiNotes::instance()->cancelNote(m_activeNoteId);
   708         
   806         
   709     // Show error note
   807     // Show error note
   710     PsUiNotes::instance()->showGlobalErrorNote(m_activeNoteId, aReason);
   808     PsUiNotes::instance()->showGlobalErrorNote(m_activeNoteId, aReason);
   711     
   809     
   712     DPRINT << ": OUT";
   810     divertRequestProcessed();
   713 }
   811     
   714 
   812     DPRINT << ": OUT";
   715 /*!
   813 }
   716   CpDivertPluginGroup::popUpVoiceNumberListQuery.
   814 
   717  */
       
   718 void CpDivertPluginGroup::popUpVoiceNumberListQuery(
       
   719         const QString& heading, PsServiceGroup serviceGroup)
       
   720 {
       
   721     DPRINT << ": IN";
       
   722     if (m_dialog) {
       
   723         m_dialog->deleteLater();
       
   724         m_dialog = NULL;
       
   725     }
       
   726 
       
   727     m_divertCommand.iNumber.clear();
       
   728     QStringList defNumbers;
       
   729     QScopedPointer<HbDialog> dialog(createDialog(heading));
       
   730     HbListWidget *list = new HbListWidget(dialog.data());
       
   731     
       
   732     QString vmbxNumber;
       
   733     int vmbxErr = 0;
       
   734     if (serviceGroup == ServiceGroupVoice) {
       
   735         vmbxErr = m_callDivertingWrapper->getVoiceMailBoxNumber(
       
   736                 vmbxNumber, ServiceGroupVoice);
       
   737         
       
   738     } else if(serviceGroup == ServiceGroupData) {
       
   739         vmbxErr = m_callDivertingWrapper->getVoiceMailBoxNumber(
       
   740                 vmbxNumber, ServiceGroupData);
       
   741         
       
   742     } else {
       
   743         vmbxErr = -1;
       
   744         // Skip
       
   745     }
       
   746     
       
   747     if (!vmbxErr) {
       
   748         if (serviceGroup == ServiceGroupVoice) {
       
   749             addItemToListWidget(
       
   750                 list, 
       
   751                 hbTrId("txt_phone_setlabel_voice_mbx"), 
       
   752                 vmbxNumber );
       
   753                 
       
   754         } else {
       
   755             addItemToListWidget(
       
   756                 list, 
       
   757                 hbTrId("txt_phone_setlabel_video_mbx"), 
       
   758                 vmbxNumber );
       
   759         }
       
   760     }
       
   761 
       
   762     // Add "old" divert number to list
       
   763     m_callDivertingWrapper->getDefaultNumbers(defNumbers);
       
   764     int count(defNumbers.count());
       
   765     for (int i = 0; i < count; i++) {
       
   766         addItemToListWidget(list, defNumbers[i], defNumbers[i]);
       
   767     }
       
   768     addItemToListWidget(
       
   769             list, 
       
   770             hbTrId("txt_phone_list_enter_number_manually"), 
       
   771             KOtherNumber );
       
   772     dialog->setContentWidget(list);
       
   773     
       
   774     // Connect list item activation signal to close the popup
       
   775     QObject::connect(list, 
       
   776             SIGNAL(activated(HbListWidgetItem*)), 
       
   777             dialog.data(), 
       
   778             SLOT(close()), 
       
   779             Qt::UniqueConnection);
       
   780     
       
   781     // Sets the "Cancel"-action/button
       
   782     HbAction *cancelAction = new HbAction(hbTrId(
       
   783             "txt_common_button_cancel"), 
       
   784             dialog.data());
       
   785     dialog->addAction(cancelAction);
       
   786     QObject::connect(cancelAction, 
       
   787             SIGNAL(triggered(bool)), 
       
   788             dialog.data(), 
       
   789             SLOT(close()));
       
   790     
       
   791     dialog->open(this, SLOT(voiceNumberListQueryClosed(HbAction *)));
       
   792     m_dialog = dialog.take();
       
   793     DPRINT << ": OUT";
       
   794 }
       
   795 
       
   796 /*!
       
   797     CpDivertPluginGroup::voiceNumberListQueryClosed()
       
   798 */
       
   799 void CpDivertPluginGroup::voiceNumberListQueryClosed(HbAction* action)
       
   800 {
       
   801     DPRINT << ": IN";
       
   802     HbListWidget *list(NULL);
       
   803     m_divertCommand.iNumber.clear();
       
   804     bool processNextPhase(true);
       
   805     
       
   806     if (m_dialog) {
       
   807         bool err = QObject::disconnect(m_dialog->contentWidget(), 
       
   808             SIGNAL(activated(HbListWidgetItem*)), 
       
   809             m_dialog, 
       
   810             SLOT(close()));
       
   811         list = qobject_cast<HbListWidget*>(m_dialog->contentWidget());
       
   812         m_dialog->deleteLater();
       
   813         m_dialog = NULL;
       
   814     }
       
   815     
       
   816     // Enter if cancel wasn't selected 
       
   817     if (!action && list) {
       
   818         // Update the view with selected text
       
   819         QString data = list->currentItem()->data().toString();
       
   820         QString text = list->currentItem()->text();
       
   821 
       
   822         DPRINT << ": data: " << data; 
       
   823         DPRINT << ": text: " << text; 
       
   824 
       
   825         if (data == KOtherNumber) {
       
   826             DPRINT << ": open popUpNumberEditor";
       
   827             processNextPhase = false;
       
   828             popUpNumberEditor(hbTrId("txt_phone_info_number"));
       
   829         } else if (text == hbTrId("txt_phone_setlabel_voice_mbx")) {
       
   830             DPRINT << ": get voicemailboxnumber";
       
   831             m_callDivertingWrapper->getVoiceMailBoxNumber(
       
   832                 m_divertCommand.iNumber, ServiceGroupVoice);
       
   833             if (m_divertCommand.iNumber.isEmpty()) {
       
   834                 DPRINT << ": voicemailboxnumber query";
       
   835                 m_callDivertingWrapper->queryVoiceMailBoxNumber(
       
   836                     m_divertCommand.iNumber, ServiceGroupVoice);
       
   837             }
       
   838         } else if (text == hbTrId("txt_phone_setlabel_video_mbx")) {
       
   839             DPRINT << ": get videomailboxnumber";
       
   840             m_callDivertingWrapper->getVoiceMailBoxNumber(
       
   841                 m_divertCommand.iNumber, ServiceGroupData);
       
   842             if (m_divertCommand.iNumber.isEmpty()) {
       
   843                 DPRINT << ": videomailboxnumber query";
       
   844                 m_callDivertingWrapper->queryVoiceMailBoxNumber(
       
   845                     m_divertCommand.iNumber, ServiceGroupData);
       
   846             }
       
   847         }  else {
       
   848             //TODO if matched contact name not work
       
   849             DPRINT << ": else";
       
   850             m_divertCommand.iNumber = data;
       
   851         }        
       
   852     }
       
   853     DPRINT << ": processNextPhase: " << processNextPhase; 
       
   854     DPRINT << ": m_divertCommand.iNumber: " << m_divertCommand.iNumber; 
       
   855     if (processNextPhase) {
       
   856         if (m_divertCommand.iNumber.isEmpty()) {
       
   857             nextPhaseForActivateDivert(false);
       
   858         } else {
       
   859             nextPhaseForActivateDivert(true);
       
   860         }
       
   861     }
       
   862     
       
   863     DPRINT << ": OUT";
       
   864 }
       
   865 
       
   866 /*!
       
   867   CpDivertPluginGroup::popUpNumberEditor.
       
   868  */
       
   869 void CpDivertPluginGroup::popUpNumberEditor(
       
   870         const QString& heading)
       
   871 {
       
   872     DPRINT << ": IN";
       
   873 
       
   874     if (m_dialog) {
       
   875         m_dialog->deleteLater();
       
   876         m_dialog = NULL;
       
   877     }
       
   878     QScopedPointer<HbDialog> dialog(createDialog(heading));
       
   879 
       
   880     HbLineEdit *editor = new HbLineEdit(dialog.data());
       
   881     editor->setInputMethodHints(Qt::ImhDialableCharactersOnly);    
       
   882     //Ownership is transferred
       
   883     dialog->setContentWidget(editor);
       
   884     
       
   885     HbAction *okAction = new HbAction(
       
   886             hbTrId("txt_common_button_ok"), 
       
   887             dialog.data());
       
   888     dialog->addAction(okAction);
       
   889     
       
   890     HbAction *cancelAction = new HbAction(
       
   891             hbTrId("txt_common_button_cancel"), 
       
   892             dialog.data());
       
   893     dialog->addAction(cancelAction);
       
   894     dialog->open(this, SLOT(popUpNumberEditorClosed(HbAction*)));
       
   895     m_dialog = dialog.take();
       
   896     DPRINT << ": OUT";
       
   897 }
       
   898 
       
   899 /*!
       
   900   CpDivertPluginGroup::popUpNumberEditorClosed.
       
   901  */
       
   902 void CpDivertPluginGroup::popUpNumberEditorClosed(HbAction* action)
       
   903 {
       
   904     DPRINT << ": IN";
       
   905     bool cancelled(true); 
       
   906     if (action) {
       
   907         if (action->text() == hbTrId("txt_common_button_ok")) {
       
   908             cancelled = false;  
       
   909             DPRINT << ": ok selected";
       
   910         }
       
   911     }
       
   912     
       
   913     if (!cancelled) {
       
   914         HbLineEdit *editor = qobject_cast<HbLineEdit *>(m_dialog->contentWidget());
       
   915         if (editor) {
       
   916             m_divertCommand.iNumber = editor->text();
       
   917         }
       
   918         
       
   919         DPRINT << ": m_divertCommand.iNumber "
       
   920             << m_divertCommand.iNumber;
       
   921         if (m_divertCommand.iNumber.isEmpty()) {
       
   922             PsUiNotes::instance()->showNotificationDialog(hbTrId("txt_phone_info_invalid_phone_number"));
       
   923         }
       
   924     }
       
   925     if (m_dialog) {
       
   926         m_dialog->deleteLater();
       
   927         m_dialog = NULL;
       
   928     }
       
   929     
       
   930     nextPhaseForActivateDivert(!cancelled);
       
   931     
       
   932     DPRINT << ": OUT";
       
   933 }
       
   934 
   815 
   935 /*!
   816 /*!
   936   CpDivertPluginGroup::setCallDiverting.
   817   CpDivertPluginGroup::setCallDiverting.
   937  */
   818  */
   938 void CpDivertPluginGroup::setCallDiverting(PSCallDivertingCommand& command)
   819 void CpDivertPluginGroup::setCallDiverting(PSCallDivertingCommand& command)
   956         handleDivertingError(result);
   837         handleDivertingError(result);
   957     }
   838     }
   958     
   839     
   959     DPRINT << ": OUT ";
   840     DPRINT << ": OUT ";
   960 }
   841 }
   961 
       
   962 /*!
       
   963   CpDivertPluginGroup::popUpTimerQuery.
       
   964  */
       
   965 void CpDivertPluginGroup::popUpTimerQuery() 
       
   966 {
       
   967     DPRINT << ": IN";
       
   968     
       
   969     m_divertCommand.iNoReplyTimer = 0; 
       
   970     
       
   971     QScopedPointer<HbDialog> dialog(createDialog(hbTrId("txt_phone_title_delay")));
       
   972     HbListWidget *list = new HbListWidget(dialog.data());
       
   973     
       
   974     HbParameterLengthLimiter pluralLimiter;
       
   975     pluralLimiter = HbParameterLengthLimiter("txt_phone_list_ln_seconds", 5);
       
   976     addItemToListWidget(list, pluralLimiter, 5 );
       
   977     pluralLimiter = HbParameterLengthLimiter("txt_phone_list_ln_seconds", 10);
       
   978     addItemToListWidget(list, pluralLimiter, 10);
       
   979     pluralLimiter = HbParameterLengthLimiter("txt_phone_list_ln_seconds", 15);
       
   980     addItemToListWidget(list, pluralLimiter, 15);
       
   981     pluralLimiter = HbParameterLengthLimiter("txt_phone_list_ln_seconds", 20);
       
   982     addItemToListWidget(list, pluralLimiter, 20);
       
   983     pluralLimiter = HbParameterLengthLimiter("txt_phone_list_ln_seconds", 25);
       
   984     addItemToListWidget(list, pluralLimiter, 25);
       
   985     pluralLimiter = HbParameterLengthLimiter("txt_phone_list_ln_seconds", 30);
       
   986     addItemToListWidget(list, pluralLimiter, 30);
       
   987     
       
   988     // Connect list item activation signal to close the popup
       
   989     QObject::connect(
       
   990             list, SIGNAL(activated(HbListWidgetItem*)), 
       
   991             dialog.data(), SLOT(close()), 
       
   992             Qt::UniqueConnection);
       
   993     
       
   994     // Sets the "Cancel"-action/button
       
   995     HbAction *cancelAction = new HbAction(hbTrId("txt_common_button_cancel"));
       
   996     dialog->addAction(cancelAction);
       
   997     dialog->setContentWidget(list);
       
   998 
       
   999     dialog->open(this, SLOT(popUpTimerQueryClosed(HbAction *)));
       
  1000     if (m_dialog) {
       
  1001         m_dialog->deleteLater();
       
  1002         m_dialog = NULL;
       
  1003     }
       
  1004     m_dialog = dialog.take();
       
  1005     
       
  1006     DPRINT << ": OUT";
       
  1007 }
       
  1008 
       
  1009 /*!
       
  1010   CpDivertPluginGroup::popUpTimerQueryClosed.
       
  1011  */
       
  1012 void CpDivertPluginGroup::popUpTimerQueryClosed(HbAction* action)
       
  1013 {
       
  1014     DPRINT << ": IN";
       
  1015     
       
  1016     // If not cancel action selected 
       
  1017     bool cancelled(true);
       
  1018     if (!action) {
       
  1019         cancelled = false;
       
  1020         // Update the view with selected text
       
  1021         HbListWidget *list = qobject_cast<HbListWidget*>(m_dialog->contentWidget());
       
  1022         if (list && list->currentItem()) {
       
  1023             m_divertCommand.iNoReplyTimer = 
       
  1024                     list->currentItem()->data().toInt();
       
  1025         }
       
  1026     }
       
  1027     
       
  1028     if (m_dialog) {
       
  1029         m_dialog->deleteLater();
       
  1030         m_dialog = NULL;
       
  1031     }
       
  1032     
       
  1033     nextPhaseForActivateDivert(!cancelled);
       
  1034 
       
  1035     DPRINT << ": OUT: timeout: " << m_divertCommand.iNoReplyTimer;
       
  1036 }
       
  1037 
       
  1038 
   842 
  1039 /*!
   843 /*!
  1040   CpDivertPluginGroup::bscParam.
   844   CpDivertPluginGroup::bscParam.
  1041  */
   845  */
  1042 int CpDivertPluginGroup::bscParam(PsServiceGroup serviceGroup)
   846 int CpDivertPluginGroup::bscParam(PsServiceGroup serviceGroup)
  1069     DPRINT << ": OUT : bsc :" << bsc;
   873     DPRINT << ": OUT : bsc :" << bsc;
  1070     return bsc;
   874     return bsc;
  1071 }
   875 }
  1072 
   876 
  1073 /*!
   877 /*!
  1074   CpDivertPluginGroup::createDialog.
       
  1075  */
       
  1076 HbDialog* CpDivertPluginGroup::createDialog( const QString& heading ) const
       
  1077 {
       
  1078     DPRINT << ": IN";
       
  1079  
       
  1080     HbDialog *dialog = new HbDialog();
       
  1081     dialog->setDismissPolicy(HbDialog::NoDismiss);
       
  1082     dialog->setTimeout(HbDialog::NoTimeout);
       
  1083     dialog->setHeadingWidget(new HbLabel(heading));
       
  1084     
       
  1085     DPRINT << ": OUT";
       
  1086     return dialog;
       
  1087 }
       
  1088 
       
  1089 /*!
       
  1090   CpDivertPluginGroup::addItemToListWidget.
       
  1091  */
       
  1092 void CpDivertPluginGroup::addItemToListWidget(HbListWidget* w,
       
  1093         const QString& item, const QString& data) const
       
  1094 {
       
  1095     DPRINT << ": IN";
       
  1096  
       
  1097     HbListWidgetItem* o = new HbListWidgetItem();
       
  1098     o->setText(item);
       
  1099     o->setData(data);
       
  1100     w->addItem(o);
       
  1101     
       
  1102     DPRINT << ": OUT";
       
  1103 }
       
  1104 
       
  1105 /*!
       
  1106   CpDivertPluginGroup::addItemToListWidget.
       
  1107  */
       
  1108 void CpDivertPluginGroup::addItemToListWidget(HbListWidget* w,
       
  1109         const QString& item, const int& data) const
       
  1110 {
       
  1111     DPRINT << ": IN";
       
  1112  
       
  1113     HbListWidgetItem* o = new HbListWidgetItem();
       
  1114     o->setText(item);
       
  1115     o->setData(data);
       
  1116     w->addItem(o);
       
  1117     
       
  1118     DPRINT << ": OUT";
       
  1119 }
       
  1120 
       
  1121 /*!
       
  1122   CpDivertPluginGroup::updateDependentDivertOptions.
   878   CpDivertPluginGroup::updateDependentDivertOptions.
  1123   Updates statuses of diverts which are dependent from the status of some
   879   Updates statuses of diverts which are dependent from the status of some
  1124   other divert. Logic for dependent changes are:
   880   other divert. Logic for dependent changes are:
  1125   1. Activation of all calls divert deactivates other diverts/puts them 
   881   1. Activation of all calls divert deactivates other diverts/puts them 
  1126   into quiescent state.
   882   into quiescent state.
  1134     DPRINT << ": IN";
   890     DPRINT << ": IN";
  1135     
   891     
  1136     // all calls divert activation deactivates automatically other diverts
   892     // all calls divert activation deactivates automatically other diverts
  1137     QVariant itemState = m_DataItemVoiceAllCalls->contentWidgetData("checkState");
   893     QVariant itemState = m_DataItemVoiceAllCalls->contentWidgetData("checkState");
  1138     if ((itemState.isValid()) && 
   894     if ((itemState.isValid()) && 
  1139         (itemState.toInt() == Qt::Checked)) {
   895         (itemState.toInt() == Qt::Checked) &&
       
   896         (m_DataItemVoiceAllCalls->contentWidgetData("text") != "")) {
  1140         deactivateDependentDivertOption(m_DataItemVoiceIfBusy);
   897         deactivateDependentDivertOption(m_DataItemVoiceIfBusy);
  1141         deactivateDependentDivertOption(m_DataItemVoiceIfNotAnswered);
   898         deactivateDependentDivertOption(m_DataItemVoiceIfNotAnswered);
  1142         deactivateDependentDivertOption(m_DataItemVoiceIfOutOfReach);
   899         deactivateDependentDivertOption(m_DataItemVoiceIfOutOfReach);
  1143     } else {
   900     } else {
  1144         // Must query data for diverts depending on all calls divert, because 
   901         // Must query data for diverts depending on all calls divert, because 
  1150     }
   907     }
  1151     
   908     
  1152     // all calls divert activation deactivates automatically other diverts
   909     // all calls divert activation deactivates automatically other diverts
  1153     itemState = m_DataItemVideoAllCalls->contentWidgetData("checkState");
   910     itemState = m_DataItemVideoAllCalls->contentWidgetData("checkState");
  1154     if ((itemState.isValid()) && 
   911     if ((itemState.isValid()) && 
  1155         (itemState.toInt() == Qt::Checked)) {
   912         (itemState.toInt() == Qt::Checked) &&
       
   913         (m_DataItemVideoAllCalls->contentWidgetData("text") != "")) {
  1156         deactivateDependentDivertOption(m_DataItemVideoIfBusy);
   914         deactivateDependentDivertOption(m_DataItemVideoIfBusy);
  1157         deactivateDependentDivertOption(m_DataItemVideoIfNotAnswered);
   915         deactivateDependentDivertOption(m_DataItemVideoIfNotAnswered);
  1158         deactivateDependentDivertOption(m_DataItemVideoIfOutOfReach);
   916         deactivateDependentDivertOption(m_DataItemVideoIfOutOfReach);
  1159     } else {
   917     } else {
  1160         // Must query data for diverts depending on all calls divert, because 
   918         // Must query data for diverts depending on all calls divert, because 
  1203     
   961     
  1204     if ((Qt::Unchecked == item->contentWidgetData("checkState").toInt()) &&
   962     if ((Qt::Unchecked == item->contentWidgetData("checkState").toInt()) &&
  1205             fetchFromNetwork) {
   963             fetchFromNetwork) {
  1206         addToDivertingRequestQueue(CheckDivertStatus, *item);
   964         addToDivertingRequestQueue(CheckDivertStatus, *item);
  1207     }
   965     }
  1208     item->setEnabled(true);
       
  1209     
   966     
  1210     DPRINT << ": OUT";
   967     DPRINT << ": OUT";
  1211 }
   968 }
  1212 
   969 
  1213 /*!
   970 /*!
  1287             m_DataItemVideoIfOutOfReach->isEnabled()); 
  1044             m_DataItemVideoIfOutOfReach->isEnabled()); 
  1288     
  1045     
  1289     DPRINT << ": OUT";
  1046     DPRINT << ": OUT";
  1290 }
  1047 }
  1291 
  1048 
  1292 void CpDivertPluginGroup::nextPhaseForActivateDivert(bool ok)
       
  1293 {
       
  1294     DPRINT << ": IN";
       
  1295     
       
  1296     if (ok) {
       
  1297         switch (m_activateDivertPhase) {
       
  1298             case PopUpVoiceNumberListQueryPhase: {
       
  1299                 CpDivertRequestQueueItem request = m_divertRequestQueue.head();
       
  1300                 if (request.item->property("needTimeoutInfo").toBool()) {
       
  1301                     m_activateDivertPhase = PopUpTimerQueryPhase;
       
  1302                     popUpTimerQuery();
       
  1303                 } else {
       
  1304                     m_activateDivertPhase = NonePhase;
       
  1305                     setCallDiverting(m_divertCommand);
       
  1306                     }
       
  1307             }
       
  1308                 break;
       
  1309             case PopUpTimerQueryPhase: {
       
  1310                 m_activateDivertPhase = NonePhase;
       
  1311                 setCallDiverting(m_divertCommand);
       
  1312             }
       
  1313                 break;
       
  1314             default:
       
  1315                 DPRINT << "Error: unknown enum value";
       
  1316                 break;
       
  1317         }
       
  1318     } else {
       
  1319         // Query was cancelled
       
  1320         revertItemData(
       
  1321             m_divertCommand.iServiceGroup, 
       
  1322             m_divertCommand.iCondition);
       
  1323         m_divertRequestQueue.clear();
       
  1324         m_activateDivertPhase = NonePhase;
       
  1325     }
       
  1326     
       
  1327     DPRINT << ": OUT";
       
  1328 }
       
  1329 
  1049 
  1330 /*!
  1050 /*!
  1331   CpDivertPluginGroup::itemShown.
  1051   CpDivertPluginGroup::itemShown.
  1332  */
  1052  */
  1333 bool CpDivertPluginGroup::isDivertSettingsItem(HbDataFormModelItem* modelItem) {
  1053 bool CpDivertPluginGroup::isDivertSettingsItem(HbDataFormModelItem* modelItem) {