phonesettings/cpphonesettingsplugins/divertplugin/src/cpdivertplugingroup.h
changeset 36 2eacb6118286
parent 30 ebdbd102c78a
child 37 ba76fc04e6c2
equal deleted inserted replaced
30:ebdbd102c78a 36:2eacb6118286
     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 
       
    40 using namespace CpTelephonyUtils;
       
    41 
       
    42 /*!
       
    43     \class CpDivertPluginGroup
       
    44     \brief The class CpDivertPluginGroup defines items shown on UI. 
       
    45  */
       
    46 class CpDivertPluginGroup : public CpSettingFormItemData
       
    47 {
       
    48     Q_OBJECT
       
    49 
       
    50     enum DivertRequest{
       
    51         ActivateDivert = 0, 
       
    52         DeactivateDivert, 
       
    53         CheckDivertStatus
       
    54     };  
       
    55 
       
    56     class CpDivertRequestQueueItem
       
    57     {
       
    58     public:
       
    59         DivertRequest request;
       
    60         CpDivertItemData *item;
       
    61     };
       
    62     
       
    63     
       
    64 public:
       
    65 
       
    66     explicit CpDivertPluginGroup(CpItemDataHelper &helper);
       
    67     
       
    68     ~CpDivertPluginGroup();
       
    69 
       
    70 public slots:
       
    71     
       
    72     // PSetCallDivertingWrapper signal handling
       
    73     /**
       
    74      Set info request results
       
    75      */
       
    76     void handleDivertingChanged(
       
    77             const PSCallDivertingCommand& aSetting, 
       
    78             bool aPlural);
       
    79     
       
    80     /**
       
    81      Get info request results
       
    82      */
       
    83     void handleDivertingStatus(
       
    84         QList<PSCallDivertingStatus*>& divertList, 
       
    85         bool plural);
       
    86     
       
    87     /**
       
    88      Request failed.
       
    89      */
       
    90     void handleDivertingError(int aReason);
       
    91 
       
    92     /**
       
    93      Adaptation has handled previous request.
       
    94      */
       
    95     void divertRequestProcessed();
       
    96     
       
    97     /**
       
    98      Slot which handles change requests according UI.
       
    99      */
       
   100     void changeDivertingStateRequested(CpDivertItemData &item);
       
   101 
       
   102     /**
       
   103      Slot which handles item updating when it is needed.
       
   104      */
       
   105     void itemShown(const QModelIndex& item);
       
   106     
       
   107     void voiceNumberListQueryClosed(HbAction* action);
       
   108     void popUpNumberEditorClosed(HbAction* action);
       
   109     void popUpTimerQueryClosed(HbAction* action);
       
   110     
       
   111 private:     
       
   112     
       
   113     /**
       
   114      Creates group items.
       
   115      */
       
   116     void createVoiceCallItems(CpSettingFormItemData *group);
       
   117 
       
   118     /**
       
   119      Creates group items.
       
   120      */
       
   121     void createVideoCallItems(CpSettingFormItemData *parent);
       
   122     
       
   123     /**
       
   124      Creates single item.
       
   125      */
       
   126     CpDivertItemData *createDivertItem(
       
   127             PsCallDivertingCondition condition,
       
   128             PsServiceGroup serviceGroup,
       
   129             const QString &label,
       
   130             const QString &queryLabel,
       
   131             bool needTimeoutInfo,
       
   132             CpSettingFormItemData *parent = 0);
       
   133     
       
   134     /**
       
   135      Show to user divert number query list.
       
   136      */
       
   137     bool popUpVoiceNumberListQuery(
       
   138             const QString& heading, QString& result, PsServiceGroup serviceGroup);
       
   139     
       
   140     /**
       
   141      Show to user number query.
       
   142      */
       
   143     void popUpNumberEditor(
       
   144             const QString& heading, QString& result);
       
   145     
       
   146     
       
   147     /**
       
   148      Send comand to psetwrappercalldiverting.
       
   149      */
       
   150     void setCallDiverting(PSCallDivertingCommand& command);
       
   151     
       
   152     /**
       
   153      Show to user divert time out query list.
       
   154      */
       
   155     bool popUpTimerQuery(int &timeout);
       
   156     
       
   157     /**
       
   158      Desides which bsc parameters to use.
       
   159      */
       
   160     int bscParam(PsServiceGroup serviceGroup);
       
   161     
       
   162     /**
       
   163      Adds divert data item for wanted parent.
       
   164      */
       
   165     void addDivertDataItem(
       
   166             CpDivertItemData* item, CpSettingFormItemData *parent);
       
   167 
       
   168     /**
       
   169      Process next divert request.
       
   170      */
       
   171     void processDivertingRequestQueue();
       
   172 
       
   173     /**
       
   174      Add new request to divert queue.
       
   175      */
       
   176     void addToDivertingRequestQueue(
       
   177             DivertRequest request, 
       
   178             CpDivertItemData &item);
       
   179     
       
   180     /**
       
   181      Changes divertItemData data.
       
   182      */
       
   183     void changeItemData(
       
   184             PsServiceGroup serviceGroup,
       
   185             PsCallDivertingCondition condition, 
       
   186             PsCallDivertingStatus status,
       
   187             const QString& number, 
       
   188             int timeout);
       
   189     
       
   190     /**
       
   191      Reverts divertItemData data to the last known valid values.
       
   192      */
       
   193     void revertItemData(
       
   194             PsServiceGroup serviceGroup, PsCallDivertingCondition condition);
       
   195 
       
   196     /**
       
   197      Helper function which fetches model item according service and condition.
       
   198      */
       
   199     CpSettingFormItemData* item(
       
   200             PsService service, PsCallDivertingCondition condition);
       
   201 private:
       
   202     
       
   203     /**
       
   204      Creates dialog with default parameters
       
   205      */
       
   206     HbDialog* createDialog( const QString& heading ) const;
       
   207 
       
   208     /**
       
   209      Adds item to given list widget
       
   210      */
       
   211     void addItemToListWidget(HbListWidget* w,
       
   212         const QString& item, const QString& data) const;
       
   213 
       
   214     /**
       
   215      Adds item to given list widget
       
   216      */
       
   217     void addItemToListWidget(HbListWidget* w,
       
   218         const QString& item, const int& data) const;
       
   219 
       
   220     /**
       
   221      Synchronizes content and status of divert options dependent from the 
       
   222      status of some other divert.
       
   223      */
       
   224     void updateDependentDivertOptions(bool fetchFromNetwork = false);
       
   225     void activateDependentDivertOption(CpDivertItemData* item, bool fetchFromNetwork);
       
   226     void deActivateDependentDivertOption(CpDivertItemData* item) const;
       
   227     
       
   228     /**
       
   229      Synchronizes content and status of not available divert option based on
       
   230      statuses of CFB, CFNry and CFNrc.
       
   231      */
       
   232     void updateNotAvailableDivertOption();
       
   233     
       
   234 private:   // data
       
   235 
       
   236     // Setting wrappers 
       
   237     PSetWrapper *m_pSetWrapper;
       
   238     SsSettingsWrapper *m_ssSettingsWrapper;
       
   239     
       
   240     // Not own
       
   241     PSetCallDivertingWrapper* m_callDivertingWrapper;
       
   242 
       
   243     // Not owned objects
       
   244     CpDivertItemData *m_DataItemVoiceAllCalls;
       
   245     CpDivertItemData *m_DataItemVoiceIfBusy;
       
   246     CpDivertItemData *m_DataItemVoiceIfNotAnswered;
       
   247     CpDivertItemData *m_DataItemVoiceIfOutOfReach;
       
   248     CpDivertItemData *m_DataItemVoiceIfNotAvailable;
       
   249     
       
   250     CpDivertItemData *m_DataItemVideoAllCalls;
       
   251     CpDivertItemData *m_DataItemVideoIfBusy;
       
   252     CpDivertItemData *m_DataItemVideoIfNotAnswered;
       
   253     CpDivertItemData *m_DataItemVideoIfOutOfReach;
       
   254     CpDivertItemData *m_DataItemVideoIfNotAvailable;
       
   255 
       
   256     int m_activeNoteId;
       
   257     int m_activeProgressNoteId;
       
   258 
       
   259     // To prevent adding vmbx number to defaultlist
       
   260     bool m_divertToVoiceMailBox;
       
   261 
       
   262     /**
       
   263      Divert request queue
       
   264      */
       
   265     QQueue<CpDivertRequestQueueItem> m_divertRequestQueue;
       
   266 
       
   267     CpItemDataHelper &m_helper;
       
   268     
       
   269     int m_divertTimeout;
       
   270     
       
   271     HbListWidget *m_voiceNumberList;
       
   272     HbListWidget *m_popupTimerList; 
       
   273     QString m_divertNumber; 
       
   274     HbLineEdit *m_voiceNumberEditor; 
       
   275     QEventLoop *m_eventLoop; 
       
   276     
       
   277 };
       
   278 
       
   279 #endif // CPDIVERTPLUGINGROUP_H
       
   280 
       
   281