phonesettings/cpphonesettingsplugins/divertplugin/src/cpdivertplugingroup.h
branchRCL_3
changeset 61 41a7f70b3818
equal deleted inserted replaced
58:40a3f856b14d 61:41a7f70b3818
       
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:  
       
    15  *
       
    16  */
       
    17 #ifndef CPDIVERTPLUGINGROUP_H
       
    18 #define CPDIVERTPLUGINGROUP_H
       
    19 
       
    20 #include <QMap>
       
    21 #include <QString>
       
    22 #include <QQueue>
       
    23 #include <hbdevicemessagebox.h>
       
    24 #include <cpsettingformitemdata.h>
       
    25 #include <psetcalldivertingwrapper.h>
       
    26 #include "cptelephonyutilsdefs.h"
       
    27 #include "cppluginlogging.h"
       
    28 
       
    29 
       
    30 class HbDataFormViewItem; 
       
    31 class PSetWrapper;
       
    32 class SsSettingsWrapper;
       
    33 class HbComboBox;
       
    34 class PSCallDivertingCommand;
       
    35 class HbListWidget;
       
    36 class CpDivertItemData;
       
    37 class QEventLoop; 
       
    38 class HbLineEdit; 
       
    39 class HbDataFormModelItem;
       
    40 
       
    41 using namespace CpTelephonyUtils;
       
    42 
       
    43 /*!
       
    44     \class CpDivertPluginGroup
       
    45     \brief The class CpDivertPluginGroup defines items shown on UI. 
       
    46  */
       
    47 class CpDivertPluginGroup : public CpSettingFormItemData
       
    48 {
       
    49     Q_OBJECT
       
    50 
       
    51     enum DivertRequest{
       
    52         ActivateDivert = 0, 
       
    53         DeactivateDivert, 
       
    54         CheckDivertStatus
       
    55     };  
       
    56 
       
    57     class CpDivertRequestQueueItem
       
    58     {
       
    59     public:
       
    60         DivertRequest request;
       
    61         CpDivertItemData *item;
       
    62     };
       
    63     
       
    64     // Activate divert phases
       
    65     enum ActivateDivertPhases
       
    66     {
       
    67         NonePhase,
       
    68         PopUpVoiceNumberListQueryPhase,
       
    69         PopUpTimerQueryPhase
       
    70     };
       
    71     
       
    72 public:
       
    73 
       
    74     explicit CpDivertPluginGroup(CpItemDataHelper &helper);
       
    75     
       
    76     ~CpDivertPluginGroup();
       
    77 
       
    78 public slots:
       
    79     
       
    80     // PSetCallDivertingWrapper signal handling
       
    81     /**
       
    82      Set info request results
       
    83      */
       
    84     void handleDivertingChanged(
       
    85             const PSCallDivertingCommand& aSetting, 
       
    86             bool aPlural);
       
    87     
       
    88     /**
       
    89      Get info request results
       
    90      */
       
    91     void handleDivertingStatus(
       
    92         QList<PSCallDivertingStatus*>& divertList, 
       
    93         bool plural);
       
    94     
       
    95     /**
       
    96      Request failed.
       
    97      */
       
    98     void handleDivertingError(int aReason);
       
    99 
       
   100     /**
       
   101      Adaptation has handled previous request.
       
   102      */
       
   103     void divertRequestProcessed();
       
   104     
       
   105     /**
       
   106      Slot which handles change requests according UI.
       
   107      */
       
   108     void changeDivertingStateRequested(CpDivertItemData &item);
       
   109 
       
   110     /**
       
   111      Slot which handles item updating when it is needed.
       
   112      */
       
   113     void itemShown(const QModelIndex& item);
       
   114     
       
   115     void voiceNumberListQueryClosed(HbAction* action);
       
   116     void popUpNumberEditorClosed(HbAction* action);
       
   117     void popUpTimerQueryClosed(HbAction* action);
       
   118     
       
   119 private:     
       
   120     
       
   121     /**
       
   122      Creates group items.
       
   123      */
       
   124     void createVoiceCallItems(CpSettingFormItemData *group);
       
   125 
       
   126     /**
       
   127      Creates group items.
       
   128      */
       
   129     void createVideoCallItems(CpSettingFormItemData *parent);
       
   130     
       
   131     /**
       
   132      Creates single item.
       
   133      */
       
   134     CpDivertItemData *createDivertItem(
       
   135             PsCallDivertingCondition condition,
       
   136             PsServiceGroup serviceGroup,
       
   137             const QString &label,
       
   138             const QString &queryLabel,
       
   139             bool needTimeoutInfo,
       
   140             CpSettingFormItemData *parent = 0);
       
   141     
       
   142     /**
       
   143      Show to user divert number query list.
       
   144      */
       
   145     void popUpVoiceNumberListQuery(
       
   146             const QString& heading, PsServiceGroup serviceGroup);
       
   147     
       
   148     /**
       
   149      Show to user number query.
       
   150      */
       
   151     void popUpNumberEditor(
       
   152             const QString& heading);
       
   153     
       
   154     
       
   155     /**
       
   156      Send comand to psetwrappercalldiverting.
       
   157      */
       
   158     void setCallDiverting(PSCallDivertingCommand& command);
       
   159     
       
   160     /**
       
   161      Show to user divert time out query list.
       
   162      */
       
   163     void popUpTimerQuery();
       
   164     
       
   165     /**
       
   166      Desides which bsc parameters to use.
       
   167      */
       
   168     int bscParam(PsServiceGroup serviceGroup);
       
   169     
       
   170     /**
       
   171      Adds divert data item for wanted parent.
       
   172      */
       
   173     void addDivertDataItem(
       
   174             CpDivertItemData* item, CpSettingFormItemData *parent);
       
   175 
       
   176     /**
       
   177      Process next divert request.
       
   178      */
       
   179     void processDivertingRequestQueue();
       
   180 
       
   181     /**
       
   182      Add new request to divert queue.
       
   183      */
       
   184     void addToDivertingRequestQueue(
       
   185             DivertRequest request, 
       
   186             CpDivertItemData &item);
       
   187     
       
   188     /**
       
   189      Changes divertItemData data.
       
   190      */
       
   191     void changeItemData(
       
   192             PsServiceGroup serviceGroup,
       
   193             PsCallDivertingCondition condition, 
       
   194             PsCallDivertingStatus status,
       
   195             const QString& number, 
       
   196             int timeout);
       
   197     
       
   198     /**
       
   199      Reverts divertItemData data to the last known valid values.
       
   200      */
       
   201     void revertItemData(
       
   202             PsServiceGroup serviceGroup, PsCallDivertingCondition condition);
       
   203 
       
   204     /**
       
   205      Helper function which fetches model item according service and condition.
       
   206      */
       
   207     CpSettingFormItemData* item(
       
   208             PsService service, PsCallDivertingCondition condition);
       
   209 private:
       
   210     
       
   211     /**
       
   212      Creates dialog with default parameters
       
   213      */
       
   214     HbDialog* createDialog( const QString& heading ) const;
       
   215 
       
   216     /**
       
   217      Adds item to given list widget
       
   218      */
       
   219     void addItemToListWidget(HbListWidget* w,
       
   220         const QString& item, const QString& data) const;
       
   221 
       
   222     /**
       
   223      Adds item to given list widget
       
   224      */
       
   225     void addItemToListWidget(HbListWidget* w,
       
   226         const QString& item, const int& data) const;
       
   227 
       
   228     /**
       
   229      Synchronizes content and status of divert options dependent from the 
       
   230      status of some other divert.
       
   231      */
       
   232     void updateDependentDivertOptions(bool fetchFromNetwork = false);
       
   233     void activateDependentDivertOption(CpDivertItemData* item, bool fetchFromNetwork);
       
   234     void deactivateDependentDivertOption(CpDivertItemData* item) const;
       
   235     
       
   236     /**
       
   237      Synchronizes content and status of not available divert option based on
       
   238      statuses of CFB, CFNry and CFNrc.
       
   239      */
       
   240     void updateNotAvailableDivertOption();
       
   241     
       
   242     void nextPhaseForActivateDivert(bool ok);
       
   243     
       
   244     bool isDivertSettingsItem(HbDataFormModelItem* modelItem);
       
   245      
       
   246 private:   // data
       
   247 
       
   248     // Setting wrappers 
       
   249     PSetWrapper *m_pSetWrapper;
       
   250     SsSettingsWrapper *m_ssSettingsWrapper;
       
   251     
       
   252     // Not own
       
   253     PSetCallDivertingWrapper* m_callDivertingWrapper;
       
   254 
       
   255     // Not owned objects
       
   256     CpDivertItemData *m_DataItemVoiceAllCalls;
       
   257     CpDivertItemData *m_DataItemVoiceIfBusy;
       
   258     CpDivertItemData *m_DataItemVoiceIfNotAnswered;
       
   259     CpDivertItemData *m_DataItemVoiceIfOutOfReach;
       
   260     CpDivertItemData *m_DataItemVoiceIfNotAvailable;
       
   261     
       
   262     CpDivertItemData *m_DataItemVideoAllCalls;
       
   263     CpDivertItemData *m_DataItemVideoIfBusy;
       
   264     CpDivertItemData *m_DataItemVideoIfNotAnswered;
       
   265     CpDivertItemData *m_DataItemVideoIfOutOfReach;
       
   266     CpDivertItemData *m_DataItemVideoIfNotAvailable;
       
   267 
       
   268     int m_activeNoteId;
       
   269     int m_activeProgressNoteId;
       
   270 
       
   271     /**
       
   272      Divert request queue
       
   273      */
       
   274     QQueue<CpDivertRequestQueueItem> m_divertRequestQueue;
       
   275 
       
   276     CpItemDataHelper &m_helper;
       
   277     
       
   278     ActivateDivertPhases m_activateDivertPhase;
       
   279     PSCallDivertingCommand m_divertCommand;
       
   280     int m_timerId;
       
   281     HbDialog *m_dialog;
       
   282 
       
   283 };
       
   284 
       
   285 #endif // CPDIVERTPLUGINGROUP_H
       
   286 
       
   287