gssettingsuis/Gs/GSCallBarringPlugin/Src/GSInternetBarringContainer.cpp
changeset 0 8c5d936e5675
child 25 3b47783fdf16
equal deleted inserted replaced
-1:000000000000 0:8c5d936e5675
       
     1 /*
       
     2 * Copyright (c) 2005 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:  Container for the Internet Barring folder
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <aknlists.h>
       
    21 #include <StringLoader.h>
       
    22 #include <GSCallBarringPluginRsc.rsg>
       
    23 #include <csxhelp/cp.hlp.hrh>
       
    24 #include <gsfwviewuids.h>
       
    25 #include <generalsettingsvariant.hrh>
       
    26 #include <PSVariables.h>  //PubSub 
       
    27 #include <settingsinternalcrkeys.h>
       
    28 #include <LogsDomainCRKeys.h>
       
    29 #include "GSInternetBarringContainer.h"
       
    30 #include "gslistbox.h"              //for listbox clases
       
    31 
       
    32 // ========================= MEMBER FUNCTIONS ================================
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // 
       
    36 // Symbian OS two phased constructor
       
    37 // 
       
    38 // ---------------------------------------------------------------------------
       
    39 void CGSSettListInternetBarringContainer::ConstructL( const TRect& aRect )
       
    40     {
       
    41     iListBox = new ( ELeave ) CAknSettingStyleListBox;
       
    42 		iRichCallRepository = CRepository::NewL( KCRUidRichCallSettings );
       
    43 		iTelephonyRepository = CRepository::NewL( KCRUidTelephonySettings );
       
    44     BaseConstructL( aRect, 
       
    45                     R_GS_INTERNET_BARRING_VIEW_TITLE, 
       
    46                     R_INTERNET_BARRING_LBX );
       
    47     }
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // 
       
    51 // Destructor
       
    52 //  
       
    53 // ---------------------------------------------------------------------------
       
    54 CGSSettListInternetBarringContainer::~CGSSettListInternetBarringContainer()
       
    55     {
       
    56     if ( iItems )
       
    57         {
       
    58         delete iItems;
       
    59         }
       
    60     if ( iListboxItemArray )
       
    61         {
       
    62         delete iListboxItemArray;
       
    63         }
       
    64     if ( iTelephonyRepository )
       
    65         {
       
    66         delete iTelephonyRepository;
       
    67         iTelephonyRepository = NULL;
       
    68         }
       
    69     if ( iRichCallRepository )
       
    70         {
       
    71         delete iRichCallRepository;
       
    72         iRichCallRepository = NULL;
       
    73         }
       
    74     }
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // 
       
    78 // Creates list box
       
    79 //  
       
    80 // ---------------------------------------------------------------------------
       
    81 void CGSSettListInternetBarringContainer::ConstructListBoxL( TInt aResLbxId )
       
    82     {        
       
    83     iListBox->ConstructL( this, EAknListBoxSelectionList); 
       
    84        
       
    85     iListboxItemArray = CGSListBoxItemTextArray::NewL( aResLbxId, 
       
    86         *iListBox, *iCoeEnv );        
       
    87     iListBox->Model()->SetItemTextArray( iListboxItemArray );
       
    88     iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
    89     
       
    90     // Create items  
       
    91     iItems = iCoeEnv->ReadDesC16ArrayResourceL( 
       
    92                         R_GS_INTERNET_BARRING_SETTING_PAGE_LBX );
       
    93     
       
    94     CreateListBoxItemsL();
       
    95     }
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // 
       
    99 // Creates List box items
       
   100 //  
       
   101 // ---------------------------------------------------------------------------
       
   102 void CGSSettListInternetBarringContainer::CreateListBoxItemsL()
       
   103     {    
       
   104     MakeAnonymousItemL();
       
   105     }
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // CGSSettListInternetBarringContainer::GetHelpContext
       
   109 // Gets Help Context
       
   110 //  
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 void CGSSettListInternetBarringContainer::GetHelpContext(
       
   114     TCoeHelpContext& aContext ) const
       
   115     {
       
   116     aContext.iMajor = KUidGS;
       
   117     aContext.iContext = KDIV_HLP_CALL_FORW_VOIP;
       
   118     }
       
   119 
       
   120 // ---------------------------------------------------------------------------
       
   121 // CGSSettListInternetBarringContainer::MakeAnonymousItemL
       
   122 //  
       
   123 // ---------------------------------------------------------------------------
       
   124 //
       
   125 void CGSSettListInternetBarringContainer::MakeAnonymousItemL()
       
   126     {
       
   127     TInt value( KErrNone );
       
   128     GetVoIPCallSettingValue( EGSVoIPBarring, value );
       
   129     
       
   130     HBufC* dynamicText = HBufC::NewLC( KGSSettingItemLength );
       
   131     TPtr ptrBuffer ( dynamicText->Des() );
       
   132 
       
   133     ptrBuffer = ( *iItems )[ value ];
       
   134     
       
   135     // Finally, set the dynamic text
       
   136     iListboxItemArray->SetDynamicTextL( EGSCBAnonymous, ptrBuffer );
       
   137     iListboxItemArray->SetItemVisibilityL( EGSCBAnonymous, 
       
   138         CGSListBoxItemTextArray::EVisible );    
       
   139     
       
   140     CleanupStack::PopAndDestroy( dynamicText );  
       
   141     }
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 // CGSSettListInternetBarringContainer::UpdateListBoxL
       
   145 //  
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 void CGSSettListInternetBarringContainer::UpdateListBoxL()
       
   149     {
       
   150     MakeAnonymousItemL();     
       
   151     iListBox->HandleItemAdditionL();
       
   152     }
       
   153 
       
   154 
       
   155 // ----------------------------------------------------------------------------
       
   156 // CGSSettListInternetBarringContainer::GetVoIPCallSettingValue
       
   157 // Gets one of the VoIP call related values (send my Int. call id, 
       
   158 // Internet call waiting, preferred call type, do not disturb or 
       
   159 // Internet call barring) from Central Repository
       
   160 // ----------------------------------------------------------------------------
       
   161 //
       
   162 TInt CGSSettListInternetBarringContainer::GetVoIPCallSettingValue( 
       
   163     const TGSVoIPSetting aVoipSettingId, TInt& aVoipId ) 
       
   164     {
       
   165     TInt ret( KErrNone );
       
   166    
       
   167     switch ( aVoipSettingId )
       
   168         {
       
   169         case EGSVoIPSendIntCallId:
       
   170             ret = iRichCallRepository->Get( KRCSEClir, aVoipId );
       
   171             break;
       
   172         case EGSVoIPCW:
       
   173             ret = iRichCallRepository->Get( KRCSPSCallWaiting, aVoipId );
       
   174             break;
       
   175         case EGSVoIPPreType:
       
   176             ret = iRichCallRepository->Get( KRCSEPreferredTelephony, aVoipId );
       
   177             break;
       
   178         case EGSVoIPDnd:
       
   179             ret = iRichCallRepository->Get( KRCSEDoNotDisturb, aVoipId );
       
   180             break;
       
   181         case EGSVoIPBarring:
       
   182             ret = iRichCallRepository->Get( KRCSEAnonymousCallBlockRule, aVoipId );
       
   183             SwitchValue( aVoipId );
       
   184             break;
       
   185         default:
       
   186             break;
       
   187         }
       
   188     
       
   189     return ret;
       
   190     }
       
   191 
       
   192 // ----------------------------------------------------------------------------
       
   193 // CGSSettListInternetBarringContainer::SetVoIPCallSettingValue
       
   194 // Sets one of the VoIP call related values (send my Int. call id, 
       
   195 // Internet call waiting, preferred call type, do not disturb or 
       
   196 // Internet call barring) from Central Repository
       
   197 // ----------------------------------------------------------------------------
       
   198 //
       
   199 TInt CGSSettListInternetBarringContainer::SetVoIPCallSettingValue( 
       
   200     const TGSVoIPSetting aVoipSettingId, TInt aVoipId )
       
   201     {
       
   202     TInt ret( KErrNone );
       
   203     
       
   204     switch( aVoipSettingId )
       
   205         {
       
   206         case EGSVoIPSendIntCallId:
       
   207             ret = iRichCallRepository->Set( KRCSEClir, aVoipId );
       
   208             break;
       
   209         case EGSVoIPCW:
       
   210             ret = iRichCallRepository->Set( KRCSPSCallWaiting, aVoipId );
       
   211             break;
       
   212         case EGSVoIPPreType:
       
   213             ret = iRichCallRepository->Set( KRCSEPreferredTelephony, aVoipId );
       
   214             break;
       
   215         case EGSVoIPDnd:
       
   216             ret = iRichCallRepository->Set( KRCSEDoNotDisturb, aVoipId );
       
   217             break;
       
   218         case EGSVoIPBarring:
       
   219             SwitchValue( aVoipId );
       
   220             ret = iRichCallRepository->Set( KRCSEAnonymousCallBlockRule, aVoipId );
       
   221             break;
       
   222         default:
       
   223             break;
       
   224         }
       
   225         
       
   226     return ret;    
       
   227     }
       
   228     
       
   229 // ----------------------------------------------------------------------------
       
   230 // CGSSettListInternetBarringContainer::GetSCCPStatus
       
   231 // Gets SCCP status from Central Repository
       
   232 // ----------------------------------------------------------------------------
       
   233 //
       
   234 TInt CGSSettListInternetBarringContainer::GetSCCPStatus( TInt& aStatus )
       
   235     {
       
   236     TInt ret( KErrNone );
       
   237     ret = iTelephonyRepository->Get( KSCCPinstallUpgrade, aStatus );
       
   238     return ret;
       
   239     }
       
   240 
       
   241 // ----------------------------------------------------------------------------
       
   242 // CGSSettListInternetBarringContainer::SwitchValue
       
   243 //
       
   244 // Switching value from 1 to 0 and back
       
   245 // ----------------------------------------------------------------------------
       
   246 //
       
   247 void CGSSettListInternetBarringContainer::SwitchValue( TInt& aValue )
       
   248     {
       
   249     switch( aValue )
       
   250         {
       
   251         case KGSSettingOff: //0
       
   252             aValue = KGSIndexOff; //1
       
   253             break;
       
   254         case KGSSettingOn: //1
       
   255             aValue = KGSIndexOn; //0
       
   256             break;
       
   257         default:
       
   258             break;
       
   259         }
       
   260     }
       
   261 // End of File
       
   262