gssettingsuis/Gs/GSCallBarringPlugin/Src/GSInternetBarringView.cpp
branchRCL_3
changeset 53 8ee96d21d9bf
parent 51 8bda91a87a00
child 54 7e0eff37aedb
equal deleted inserted replaced
51:8bda91a87a00 53:8ee96d21d9bf
     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:  View for the Internet Barring folder
       
    15 *
       
    16 */
       
    17 
       
    18  
       
    19 // INCLUDE FILES
       
    20 #include "CallBarringPlugin.hrh"    //for enumerations (e.g.TGSInternetBarringSetting)
       
    21 #include "GSInternetBarringView.h"//for CGSSettListInternetBarringView
       
    22 #include "GSInternetBarringContainer.h" //for CGSBaseContainer
       
    23 #include "LocalViewIds.h"         //for KSettListBarringViewId, KGSMainViewId
       
    24 #include "GsLogger.h"
       
    25 
       
    26 
       
    27 #include <e32base.h>
       
    28 #include <featmgr.h>
       
    29 #include <gscallbarringpluginrsc.rsg>      //for resource IDs
       
    30 #include <gscommon.hrh>
       
    31 #include <StringLoader.h>           //for StringLoader
       
    32 #include <aknradiobuttonsettingpage.h>
       
    33 #include <aknViewAppUi.h>
       
    34 #include <aknnotewrappers.h>
       
    35 #include <hlplch.h>                 // For HlpLauncher
       
    36 
       
    37 // CONSTANS
       
    38 const TInt KGSBarringGranularity = 2;
       
    39 
       
    40 // ========================= MEMBER FUNCTIONS ================================
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // 
       
    44 // C++ constructor.
       
    45 // 
       
    46 // ---------------------------------------------------------------------------
       
    47 CGSSettListInternetBarringView::CGSSettListInternetBarringView()
       
    48     {
       
    49     }
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // 
       
    53 // Symbian OS two-phased constructor (second phase)
       
    54 // 
       
    55 // ---------------------------------------------------------------------------
       
    56 void CGSSettListInternetBarringView::ConstructL()
       
    57     {
       
    58     BaseConstructL( R_GS_INTERNET_BARRING_VIEW );
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // CGSSettListInternetBarringView::NewL()
       
    63 // Symbian OS two-phased constructor
       
    64 // 
       
    65 // ---------------------------------------------------------------------------
       
    66 CGSSettListInternetBarringView* CGSSettListInternetBarringView::NewL()
       
    67     {
       
    68     CGSSettListInternetBarringView* self = NewLC();
       
    69     CleanupStack::Pop( self );
       
    70     return self;
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // 
       
    75 // Symbian OS two-phased constructor (first phase)
       
    76 // 
       
    77 // ---------------------------------------------------------------------------
       
    78 CGSSettListInternetBarringView* CGSSettListInternetBarringView::NewLC()
       
    79     {
       
    80     CGSSettListInternetBarringView* self = 
       
    81         new ( ELeave ) CGSSettListInternetBarringView();
       
    82     CleanupStack::PushL( self );
       
    83     self->ConstructL();
       
    84     return self;
       
    85     }
       
    86  
       
    87 // ---------------------------------------------------------------------------
       
    88 // 
       
    89 // C++ destructor
       
    90 // 
       
    91 // ---------------------------------------------------------------------------
       
    92 CGSSettListInternetBarringView::~CGSSettListInternetBarringView()
       
    93     {
       
    94     }
       
    95  
       
    96 // ---------------------------------------------------------------------------
       
    97 // 
       
    98 // Returns Id of the Barring view.
       
    99 // 
       
   100 // ---------------------------------------------------------------------------
       
   101 TUid CGSSettListInternetBarringView::Id() const
       
   102     {
       
   103     return KCallInternetBarringViewId;
       
   104     }
       
   105  
       
   106 // ---------------------------------------------------------------------------
       
   107 // 
       
   108 // Handles other than list box events.
       
   109 // 
       
   110 // ---------------------------------------------------------------------------
       
   111 void CGSSettListInternetBarringView::HandleCommandL( TInt aCommand )
       
   112     {
       
   113     switch ( aCommand )
       
   114         {
       
   115        	case EGSMSKCmdAppChange:
       
   116 			HandleListBoxSelectionL();
       
   117        		break;
       
   118        	case EGSCmdAppChange:
       
   119             ShowSettingPageL();
       
   120             break;
       
   121         case EAknSoftkeyBack:
       
   122             iAppUi->ActivateLocalViewL( KCallMainBarringViewId );
       
   123             break;
       
   124         case EAknCmdHelp:
       
   125             if( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   126                 {
       
   127                 HlpLauncher::LaunchHelpApplicationL(
       
   128                     iEikonEnv->WsSession(), iAppUi->AppHelpContextL() );
       
   129                 }
       
   130             break;
       
   131         default:
       
   132             iAppUi->HandleCommandL( aCommand );
       
   133             break;
       
   134         }
       
   135     }
       
   136   
       
   137 // ---------------------------------------------------------------------------
       
   138 // 
       
   139 // Activates view.
       
   140 // 
       
   141 // ---------------------------------------------------------------------------
       
   142 void CGSSettListInternetBarringView::DoActivateL( const TVwsViewId& aPrevViewId,
       
   143                                           TUid aCustomMessageId,
       
   144                                           const TDesC8& aCustomMessage )
       
   145     {
       
   146     __GSLOGSTRING("[GS]--> CGSSettListInternetBarringView::DoActivateL");
       
   147     CGSLocalBaseView::DoActivateL( aPrevViewId, aCustomMessageId, 
       
   148                                    aCustomMessage );
       
   149 
       
   150     iContainer->iListBox->SetTopItemIndex( iTopItemIndex );
       
   151 
       
   152     if ( iCurrentItem >= 0 && 
       
   153          iCurrentItem < iContainer->iListBox->Model()->NumberOfItems() )
       
   154         {
       
   155         iContainer->iListBox->SetCurrentItemIndexAndDraw( iCurrentItem );
       
   156         }
       
   157     __GSLOGSTRING("[GS]<-- CGSSettListInternetBarringView::DoActivateL");
       
   158     }
       
   159  
       
   160 // ---------------------------------------------------------------------------
       
   161 // 
       
   162 // Deactivates view.
       
   163 // 
       
   164 // ---------------------------------------------------------------------------
       
   165 void CGSSettListInternetBarringView::DoDeactivate()
       
   166     {
       
   167     if ( iContainer )
       
   168         {
       
   169         if ( iContainer->iListBox && iContainer->iListBox->View() )
       
   170             {
       
   171             iCurrentItem = iContainer->iListBox->CurrentItemIndex();
       
   172             iTopItemIndex = iContainer->iListBox->TopItemIndex();
       
   173             }
       
   174         iAppUi->RemoveFromViewStack( *this, iContainer );
       
   175         delete iContainer;
       
   176         iContainer = NULL;
       
   177         }
       
   178     }
       
   179  
       
   180 // ---------------------------------------------------------------------------
       
   181 // 
       
   182 // Before showing a options menu, delete options key specific settings if 
       
   183 // rocker key has been pressed.
       
   184 // ---------------------------------------------------------------------------
       
   185 //
       
   186 void CGSSettListInternetBarringView::DynInitMenuPaneL( TInt aResourceId, 
       
   187                                               CEikMenuPane* aMenuPane )
       
   188     {
       
   189     // show or hide the 'help' menu item when supported
       
   190     if( aResourceId == R_GS_MENU_ITEM_HELP )
       
   191         {
       
   192         User::LeaveIfNull( aMenuPane );
       
   193             
       
   194         if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   195             {
       
   196             aMenuPane->SetItemDimmed( EAknCmdHelp, EFalse );
       
   197             }
       
   198         else
       
   199             {
       
   200             aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue );
       
   201             }
       
   202         }
       
   203     }
       
   204 
       
   205 // ---------------------------------------------------------------------------
       
   206 // 
       
   207 // Creates new iContainer.
       
   208 // 
       
   209 // ---------------------------------------------------------------------------
       
   210 void CGSSettListInternetBarringView::NewContainerL()
       
   211     {
       
   212     iContainer = new (ELeave) CGSSettListInternetBarringContainer;
       
   213     }
       
   214 
       
   215 // ---------------------------------------------------------------------------
       
   216 // 
       
   217 // Handles changing of barring password.
       
   218 // 
       
   219 // ---------------------------------------------------------------------------
       
   220 void CGSSettListInternetBarringView::HandleListBoxSelectionL()
       
   221     {
       
   222     CGSSettListInternetBarringContainer& container = 
       
   223         *static_cast<CGSSettListInternetBarringContainer*>( iContainer );
       
   224     
       
   225     TInt value( KErrNone );
       
   226     container.GetVoIPCallSettingValue( EGSVoIPBarring, value );
       
   227     
       
   228     if ( value == EGSCSCallBarringOff )
       
   229         {
       
   230         container.SetVoIPCallSettingValue( EGSVoIPBarring, EGSCSCallBarringOn );
       
   231         }
       
   232     else
       
   233         {
       
   234         container.SetVoIPCallSettingValue( EGSVoIPBarring, EGSCSCallBarringOff );
       
   235         }
       
   236 
       
   237     if ( iContainer->iListBox )
       
   238         {
       
   239         container.UpdateListBoxL();
       
   240         }
       
   241     
       
   242     // Show SCCP note if needed. 
       
   243     TInt status( KErrNone );
       
   244     container.GetSCCPStatus( status );
       
   245        
       
   246     if ( value == EGSCSCallBarringOff && status == 1 )
       
   247         {
       
   248         HBufC* prompt = 
       
   249             StringLoader::LoadLC( R_QTN_VOIP_SCCP_CALL_BARRING_NOTE );
       
   250         CAknInformationNote* note = new(ELeave) CAknInformationNote( ETrue );
       
   251         note->ExecuteLD( *prompt );
       
   252         CleanupStack::PopAndDestroy( prompt ); 
       
   253         }    
       
   254     }
       
   255 
       
   256 // ---------------------------------------------------------------------------
       
   257 // 
       
   258 // Shows setting page - for ON/OFF setting items
       
   259 // 
       
   260 // ---------------------------------------------------------------------------
       
   261 void CGSSettListInternetBarringView::ShowSettingPageL()
       
   262     {
       
   263     CGSSettListInternetBarringContainer& container = 
       
   264         *static_cast<CGSSettListInternetBarringContainer*>( iContainer );
       
   265     
       
   266     CDesCArrayFlat* items = 
       
   267           new ( ELeave ) CDesCArrayFlat( KGSBarringGranularity );
       
   268     CleanupStack::PushL( items );
       
   269     
       
   270     AppendItemL( *items, R_INTERNET_BARRING_ON );
       
   271     AppendItemL( *items, R_INTERNET_BARRING_OFF );
       
   272     
       
   273     TInt value( KErrNone );
       
   274     container.GetVoIPCallSettingValue( EGSVoIPBarring, value );
       
   275       
       
   276     CAknRadioButtonSettingPage* dlg = new( ELeave ) 
       
   277         CAknRadioButtonSettingPage( 
       
   278         R_GS_INTERNET_BARRING_SETTING_PAGE,
       
   279         value, items );
       
   280      
       
   281     if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ) )
       
   282         {
       
   283         if ( value == EGSCSCallBarringOff )
       
   284             {
       
   285             container.SetVoIPCallSettingValue( 
       
   286                 EGSVoIPBarring, EGSCSCallBarringOff );
       
   287             }
       
   288         else
       
   289             {
       
   290             container.SetVoIPCallSettingValue( 
       
   291                 EGSVoIPBarring, EGSCSCallBarringOn );
       
   292             }
       
   293         }
       
   294         
       
   295     CleanupStack::PopAndDestroy( items );
       
   296     
       
   297     container.UpdateListBoxL();
       
   298     }
       
   299 
       
   300 // ---------------------------------------------------------------------------
       
   301 // 
       
   302 // Appends given item to given list
       
   303 // 
       
   304 // ---------------------------------------------------------------------------
       
   305 void CGSSettListInternetBarringView::AppendItemL( 
       
   306     CDesCArrayFlat& aList, TInt aItem )
       
   307     {
       
   308     HBufC* string = StringLoader::LoadLC( aItem );
       
   309     aList.AppendL( *string );
       
   310     CleanupStack::PopAndDestroy( string );
       
   311     }    
       
   312         
       
   313  // End of file