commsconfig/cscsettingsui/src/cscsettingsuimainview.cpp
changeset 0 a4daefaec16c
child 8 7117cbf1600a
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     1 /*
       
     2 * Copyright (c) 2007-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:  Implements CSCSettingsUiMainView methods
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <hlplch.h>
       
    20 #include <aknview.h>
       
    21 #include <featmgr.h>
       
    22 #include <akntitle.h>
       
    23 #include <aknlists.h>
       
    24 #include <cchclient.h>
       
    25 #include <e32property.h>
       
    26 #include <aknViewAppUi.h>
       
    27 #include <StringLoader.h>
       
    28 #include <cmsettingsui.h>
       
    29 #include <xSPViewServices.h>
       
    30 #include <aknnotewrappers.h>
       
    31 #include <cscsettingsui.rsg>
       
    32 #include <ctsydomainpskeys.h>
       
    33 #include <akntextsettingpage.h>
       
    34 #include <cvimpstsettingsstore.h>
       
    35 #include <DRMHelper.h>
       
    36 #include <mediafilelist.h>
       
    37 #include <aknpasswordsettingpage.h>
       
    38 #include <aknradiobuttonsettingpage.h>
       
    39 #include <aknnavi.h>
       
    40 #include <aknnavide.h>
       
    41 
       
    42 #include "cscconstants.h"
       
    43 #include "cscsettingsui.hrh"
       
    44 #include "cscsettingsuimodel.h"
       
    45 #include "cscsettingsuilogger.h"
       
    46 #include "cscengservicehandler.h"
       
    47 #include "cscengbrandinghandler.h"
       
    48 #include "cscsettingsuimainview.h"
       
    49 #include "cscsettingsuiconstants.h"
       
    50 #include "cscengservicepluginhandler.h"
       
    51 
       
    52 
       
    53 #define AppUi() (static_cast<CAknViewAppUi*>(iAvkonAppUi) )
       
    54 
       
    55 // Preferred service not set
       
    56 const TInt KPrefServiceNotSet = 0;
       
    57 
       
    58 // ======== MEMBER FUNCTIONS ========
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 CCSCSettingsUiMainView::CCSCSettingsUiMainView( 
       
    64     CCSCSettingsUiModel& aModel )
       
    65     : iModel( aModel )
       
    66     {
       
    67     }
       
    68 
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 void CCSCSettingsUiMainView::ConstructL()
       
    74     {
       
    75     CSCSETUIDEBUG( "CCSCSettingsUiMainView::ConstructL - begin" );
       
    76         
       
    77     BaseConstructL( R_CSCSETTINGSUI_MAINVIEW );
       
    78     
       
    79     // Get handle to titlepane
       
    80     CEikStatusPane* statusPane = StatusPane();   
       
    81     iTitlePane = static_cast<CAknTitlePane*> 
       
    82         ( statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
    83         
       
    84     CSCSETUIDEBUG( "CCSCSettingsUiMainView::ConstructL - end" );
       
    85     }
       
    86 
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // ---------------------------------------------------------------------------
       
    90 //      
       
    91 CCSCSettingsUiMainView* CCSCSettingsUiMainView::NewL( 
       
    92     CCSCSettingsUiModel& aModel )
       
    93     {    
       
    94     CCSCSettingsUiMainView* self = CCSCSettingsUiMainView::NewLC( aModel );
       
    95     CleanupStack::Pop( self );
       
    96     return self;
       
    97     }
       
    98 
       
    99 
       
   100 // ---------------------------------------------------------------------------
       
   101 // ---------------------------------------------------------------------------
       
   102 //
       
   103 CCSCSettingsUiMainView* CCSCSettingsUiMainView::NewLC( 
       
   104     CCSCSettingsUiModel& aModel )
       
   105     {    
       
   106     CCSCSettingsUiMainView* self = 
       
   107         new ( ELeave ) CCSCSettingsUiMainView( aModel );
       
   108     CleanupStack::PushL( self );
       
   109     self->ConstructL();
       
   110     return self;
       
   111     }
       
   112 
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 CCSCSettingsUiMainView::~CCSCSettingsUiMainView()
       
   118     {
       
   119     CSCSETUIDEBUG( 
       
   120         "CCSCSettingsUiMainView::~CCSCSettingsUiMainView - begin" );
       
   121     
       
   122     // Delete container when view is deactivated.
       
   123     if ( iContainer )
       
   124         {
       
   125         AppUi()->RemoveFromViewStack( *this, iContainer );
       
   126         delete iContainer;
       
   127         }
       
   128     
       
   129     delete iNaviDecorator;
       
   130     
       
   131     CSCSETUIDEBUG( "CCSCSettingsUiMainView::~CCSCSettingsUiMainView - end" );
       
   132     }         
       
   133 
       
   134 
       
   135 // ---------------------------------------------------------------------------
       
   136 // CCSCSettingsUiMainView::UpdateSoftkeysL
       
   137 // Processes situation when itīs notified that softkeys need to be changed.
       
   138 // ---------------------------------------------------------------------------
       
   139 //
       
   140 void CCSCSettingsUiMainView::UpdateSoftkeysL( )
       
   141     {
       
   142     // not used
       
   143     }
       
   144 
       
   145 
       
   146 // ---------------------------------------------------------------------------
       
   147 // From CAknView.
       
   148 // CCSCSettingsUiMainView::Id
       
   149 // ---------------------------------------------------------------------------
       
   150 //
       
   151 TUid CCSCSettingsUiMainView::Id() const
       
   152     {
       
   153     return KCSCSettingsUiMainViewId;
       
   154     }
       
   155 
       
   156 // ---------------------------------------------------------------------------
       
   157 // CCSCSettingsUiMainView::SetTitleTextL
       
   158 // Changes given service name to title pane.
       
   159 // ---------------------------------------------------------------------------
       
   160 //
       
   161 void CCSCSettingsUiMainView::SetTitleTextL()
       
   162     {
       
   163     // Create text and set it to titlepane.
       
   164     TBuf<KCSCSettingsUiItemLength> titleText ( KNullDesC );
       
   165     TUint entryId = iModel.CurrentSPEntryId();
       
   166     titleText = iModel.SettingsHandler().ServiceNameL( entryId );
       
   167     HBufC* text = StringLoader::LoadLC( 
       
   168         R_CSCSETTINGSUI_MAINVIEW_TITLE, 
       
   169         titleText );
       
   170     iTitlePane->SetTextL( *text );
       
   171     CleanupStack::PopAndDestroy( text );
       
   172     }
       
   173 
       
   174 // ---------------------------------------------------------------------------
       
   175 // CCSCSettingsUiMainView::IsEditPreferredServiceSettingAllowedL
       
   176 //  For checking if editing of preferred service setting is allowed
       
   177 // ---------------------------------------------------------------------------
       
   178 //
       
   179 TBool CCSCSettingsUiMainView::IsEditPreferredServiceSettingAllowedL()
       
   180     {
       
   181     TBool allowed( EFalse );
       
   182     TInt value( KErrNotFound );
       
   183     
       
   184     User::LeaveIfError( 
       
   185             RProperty::Get( 
       
   186                     KPSUidCtsyCallInformation,
       
   187                     KCTsyCallState,
       
   188                     value ) );
       
   189 
       
   190     // Editing is allowed if no ongoing call.
       
   191     if ( EPSCTsyCallStateNone == value )
       
   192         {
       
   193         allowed = ETrue;
       
   194         }
       
   195     else
       
   196         {
       
   197         // Show unable to change settings note
       
   198         HBufC* string = NULL;
       
   199         string = StringLoader::LoadL( 
       
   200                 R_CSCSETTINGSUI_UNABLE_TO_EDIT_SETTING_NOTE );
       
   201                 
       
   202         if ( string )
       
   203             {
       
   204             // Set text and show note.
       
   205             CleanupStack::PushL( string );   
       
   206             CAknInformationNote* note = 
       
   207             new ( ELeave ) CAknInformationNote( ETrue );
       
   208             note->ExecuteLD( *string );
       
   209             CleanupStack::PopAndDestroy( string );
       
   210             }
       
   211         }
       
   212     
       
   213     return allowed;
       
   214     }
       
   215 
       
   216 // ---------------------------------------------------------------------------
       
   217 // From CEikAppUi
       
   218 // CCSCSettingsUiMainView::HandleCommandL
       
   219 // ---------------------------------------------------------------------------
       
   220 //
       
   221 void CCSCSettingsUiMainView::HandleCommandL( TInt aCommand )
       
   222     {
       
   223     CSCSETUIDEBUG2( "CCSCSettingsUiMainView::HandleCommandL: command=%d",
       
   224          aCommand );
       
   225     
       
   226     TMainListBoxItem listBoxItem = iContainer->CurrentItem();
       
   227     
       
   228     switch ( aCommand )
       
   229         { 
       
   230         case ECSCMSKSettingsUiChange:
       
   231             {
       
   232             HandleMskChangeSelectionL( listBoxItem );
       
   233             break;
       
   234             }
       
   235         case ECSCSettingsUiOpen:
       
   236         case ECSCSettingsUiChange:
       
   237             {
       
   238             HandleListBoxSelectionL();
       
   239             break;
       
   240             }   
       
   241         case EAknCmdHelp:
       
   242             {
       
   243             if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   244                 {
       
   245                 CArrayFix<TCoeHelpContext>* buf = AppUi()->AppHelpContextL();
       
   246                     HlpLauncher::LaunchHelpApplicationL(
       
   247                             iEikonEnv->WsSession(), buf );
       
   248                 }
       
   249             break;
       
   250             }         
       
   251         case EAknSoftkeyBack:
       
   252             {
       
   253             HandleReturnToPreviousViewL();
       
   254             break;
       
   255             }
       
   256         case EEikCmdExit:
       
   257         case EAknSoftkeyExit:
       
   258             {
       
   259             HandleSettingsUiExitL();
       
   260             break;
       
   261             }
       
   262         default:
       
   263             {
       
   264             AppUi()->HandleCommandL( aCommand );
       
   265             break;
       
   266             }
       
   267         }
       
   268     }
       
   269 
       
   270 
       
   271 // ---------------------------------------------------------------------------
       
   272 // From CAknView
       
   273 // CCSCSettingsUiMainView::DoActivateL
       
   274 // ---------------------------------------------------------------------------
       
   275 //
       
   276 void CCSCSettingsUiMainView::DoActivateL( 
       
   277     const TVwsViewId& /*aPrevViewId*/, 
       
   278     TUid /*aCustomMessageId*/,
       
   279     const TDesC8& /*aCustomMessage*/ )
       
   280     {
       
   281     CSCSETUIDEBUG( "CCSCSettingsUiMainView::DoActivateL - begin" );
       
   282     
       
   283     // Create container when view is activated.
       
   284     if ( !iContainer )
       
   285         {
       
   286         iContainer = new ( ELeave ) CCSCSettingsUiMainContainer( iModel );
       
   287         iContainer->SetMopParent( this );
       
   288         iContainer->ConstructL( ClientRect() );
       
   289         AppUi()->AddToStackL( *this, iContainer );
       
   290         iContainer->ListBox()->SetListBoxObserver( this );
       
   291         }
       
   292     
       
   293     SetTitleTextL();
       
   294     UpdateSoftkeysL();
       
   295     iContainer->UpdateContainerL();
       
   296     
       
   297     if (!iNaviPane)
       
   298          {
       
   299          iNaviPane = static_cast<CAknNavigationControlContainer*>(
       
   300              iAvkonAppUi->StatusPane()->ControlL(
       
   301              TUid::Uid(EEikStatusPaneUidNavi)));
       
   302          } 
       
   303      
       
   304      if ( !iNaviDecorator )
       
   305          {
       
   306          iNaviDecorator = iNaviPane->CreateNavigationLabelL();
       
   307          iNaviPane->PushL(*iNaviDecorator);
       
   308          }
       
   309 
       
   310     CSCSETUIDEBUG( "CCSCSettingsUiMainView::DoActivateL - end" );
       
   311     }
       
   312 
       
   313 
       
   314 // ---------------------------------------------------------------------------
       
   315 // From CAknView
       
   316 // CCSCSettingsUiMainView::DoDeactivate()
       
   317 // ---------------------------------------------------------------------------
       
   318 //
       
   319 void CCSCSettingsUiMainView::DoDeactivate()
       
   320     {
       
   321     CSCSETUIDEBUG( "CCSCSettingsUiMainView::DoDeactivate - begin" );
       
   322     
       
   323     if (iNaviPane && iNaviDecorator)
       
   324             {
       
   325             iNaviPane->Pop(iNaviDecorator);
       
   326             }
       
   327    delete iNaviDecorator;
       
   328    iNaviDecorator = NULL;
       
   329     
       
   330     // Delete container when view is deactivated.
       
   331     if ( iContainer )
       
   332         {
       
   333         AppUi()->RemoveFromViewStack( *this, iContainer );
       
   334         delete iContainer;
       
   335         iContainer = NULL;
       
   336         }
       
   337     
       
   338     CSCSETUIDEBUG( "CCSCSettingsUiMainView::DoDeactivate - end" );
       
   339     }
       
   340     
       
   341     
       
   342 // ---------------------------------------------------------------------------
       
   343 // From MEikListBoxObserver
       
   344 // CSCSettingsUiMainView::HandleListBoxEventL
       
   345 // ---------------------------------------------------------------------------
       
   346 //
       
   347 void CCSCSettingsUiMainView::HandleListBoxEventL( 
       
   348     CEikListBox* /*aListBox*/, TListBoxEvent aEventType )
       
   349     {
       
   350     TMainListBoxItem listBoxItem = iContainer->CurrentItem();
       
   351     
       
   352     switch ( aEventType )
       
   353         {
       
   354         case EEventEnterKeyPressed:
       
   355         case EEventItemSingleClicked:
       
   356             {
       
   357             if ( TMainListBoxItem::EPreferredService == listBoxItem.iItem || 
       
   358                  TMainListBoxItem::EVccPreferredService == listBoxItem.iItem ||
       
   359                  TMainListBoxItem::EHandoverNotifTone == listBoxItem.iItem )
       
   360                 {
       
   361                 HandleCommandL( ECSCMSKSettingsUiChange );
       
   362                 }
       
   363             else
       
   364                 {
       
   365                 HandleListBoxSelectionL();
       
   366                 }
       
   367             break;
       
   368             }
       
   369  
       
   370         default:
       
   371            break;
       
   372         }
       
   373     }
       
   374 
       
   375 
       
   376 // ---------------------------------------------------------------------------
       
   377 // From MEikListBoxObserver
       
   378 // CCSCSettingsUiMainView::HandleListBoxSelectionL
       
   379 // ---------------------------------------------------------------------------
       
   380 //
       
   381 void CCSCSettingsUiMainView::HandleListBoxSelectionL() 
       
   382     {        
       
   383     TMainListBoxItem listBoxItem = iContainer->CurrentItem();
       
   384     
       
   385     switch( listBoxItem.iItem )
       
   386         {
       
   387         case TMainListBoxItem::EUsername:
       
   388             ShowUsernameSettingPageL();
       
   389             break;           
       
   390         case TMainListBoxItem::EPassword:
       
   391             ShowPasswordSettingPageL();
       
   392             break;
       
   393         case TMainListBoxItem::EPreferredService:
       
   394             ShowPrefServiceSettingPageL();
       
   395             break;
       
   396         case TMainListBoxItem::EVccPreferredService:
       
   397             ShowVccPrefServiceSettingPageL();
       
   398             break;
       
   399         case TMainListBoxItem::EHandoverNotifTone:
       
   400             iContainer->HandoverNotificationToneQueryL();
       
   401             break;
       
   402         case TMainListBoxItem::EImTone:
       
   403             ShowImToneSelectionListL();
       
   404             break;
       
   405         case TMainListBoxItem::EAutoacceptInv:
       
   406             iContainer->PresenceReqPrefQueryL();
       
   407             break;
       
   408         case TMainListBoxItem::EServiceConn:
       
   409             LaunchCMSettingsUiL();
       
   410             break;
       
   411         default:
       
   412             User::Leave( KErrNotSupported );
       
   413             break;
       
   414         }
       
   415     }
       
   416     
       
   417     
       
   418 // ---------------------------------------------------------------------------
       
   419 // From MEikListBoxObserver
       
   420 // CCSCSettingsUiMainView::DynInitMenuPaneL
       
   421 // ---------------------------------------------------------------------------
       
   422 //
       
   423 void CCSCSettingsUiMainView::DynInitMenuPaneL( 
       
   424     TInt aResourceId, CEikMenuPane* aMenuPane )
       
   425     {
       
   426     CSCSETUIDEBUG( "CCSCSettingsUiMainView::DynInitMenuPaneL - begin" );
       
   427     
       
   428     if ( aMenuPane && R_CSCSETTINGSUI_MAINVIEW_MENU == aResourceId )
       
   429         {
       
   430         TMainListBoxItem listBoxItem = iContainer->CurrentItem();
       
   431     
       
   432         switch( listBoxItem.iItem )
       
   433             {
       
   434             // Hide "Change" and show "Open"
       
   435             case TMainListBoxItem::EServiceConn:
       
   436                 aMenuPane->SetItemDimmed( ECSCSettingsUiChange, ETrue );
       
   437                 aMenuPane->SetItemDimmed( ECSCSettingsUiOpen, EFalse );
       
   438                 break;
       
   439             // Show "Change" and hide "Open"
       
   440             case TMainListBoxItem::EUsername:
       
   441             case TMainListBoxItem::EPassword:
       
   442             case TMainListBoxItem::EPreferredService:
       
   443             case TMainListBoxItem::EVccPreferredService:
       
   444             case TMainListBoxItem::EHandoverNotifTone:
       
   445             case TMainListBoxItem::EAutoacceptInv:     
       
   446             case TMainListBoxItem::EImTone:
       
   447                 aMenuPane->SetItemDimmed( ECSCSettingsUiChange, EFalse );
       
   448                 aMenuPane->SetItemDimmed( ECSCSettingsUiOpen, ETrue );
       
   449                 break;   
       
   450             // Hide both of options. Case should not be possible.       
       
   451             default:
       
   452                  aMenuPane->SetItemDimmed( ECSCSettingsUiChange, ETrue );
       
   453                  aMenuPane->SetItemDimmed( ECSCSettingsUiOpen, ETrue );
       
   454             break;
       
   455             }
       
   456         }
       
   457      
       
   458     CSCSETUIDEBUG( "CCSCSettingsUiMainView::DynInitMenuPaneL - end" );
       
   459     }
       
   460 
       
   461 
       
   462 // ---------------------------------------------------------------------------
       
   463 // CCSCSettingsUiMainView::ShowUsernameSettingPageL()
       
   464 // Shows username setting page - for username input.
       
   465 // ---------------------------------------------------------------------------
       
   466 void CCSCSettingsUiMainView::ShowUsernameSettingPageL()
       
   467     {
       
   468     // Editing is allowed if service is disabled.
       
   469     if ( iModel.CCHHandler().IsServiceDisabled( iModel.CurrentSPEntryId() ) )
       
   470         {
       
   471         RBuf username;
       
   472         CleanupClosePushL( username );
       
   473         username.CreateL( KCCHMaxUsernameLength );
       
   474         
       
   475         User::LeaveIfError( 
       
   476             iModel.CCHHandler().GetConnectionParameter( 
       
   477                     iModel.CurrentSPEntryId(), ECchUsername, username ) );
       
   478             
       
   479         CAknTextSettingPage* dlg = 
       
   480             new(ELeave) CAknTextSettingPage( 
       
   481                 R_CSCSETTINGSUI_USERNAME_SETTING_PAGE, username );
       
   482         
       
   483         if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenAccepted ) )
       
   484             { 
       
   485             // Set username       
       
   486             User::LeaveIfError( 
       
   487                 iModel.CCHHandler().SetConnectionParameter( 
       
   488                     iModel.CurrentSPEntryId(), ECchUsername, username ) );
       
   489             }
       
   490         
       
   491         CleanupStack::PopAndDestroy( &username );
       
   492         
       
   493         iContainer->UpdateContainerL();
       
   494         }
       
   495     else
       
   496         {
       
   497         // Show unable to change settings note
       
   498         HBufC* string = NULL;
       
   499         string = StringLoader::LoadL( 
       
   500                 R_CSCSETTINGSUI_UNABLE_TO_EDIT_WHILE_ONLINE );
       
   501         
       
   502         if ( string )
       
   503             {
       
   504             // Set text and show note.
       
   505             CleanupStack::PushL( string );   
       
   506             CAknInformationNote* note = 
       
   507                 new ( ELeave ) CAknInformationNote( ETrue );
       
   508             note->ExecuteLD( *string );
       
   509             CleanupStack::PopAndDestroy( string );
       
   510             }
       
   511         }
       
   512     }
       
   513 
       
   514 
       
   515 
       
   516 // ---------------------------------------------------------------------------
       
   517 // CCSCSettingsUiMainView::ShowPasswordSettingPageL()
       
   518 // Shows password setting page - for password input.
       
   519 // ---------------------------------------------------------------------------
       
   520 void CCSCSettingsUiMainView::ShowPasswordSettingPageL()
       
   521     {
       
   522     // Editing is allowed if service is disabled.
       
   523     if ( iModel.CCHHandler().IsServiceDisabled( iModel.CurrentSPEntryId() ) )
       
   524         {
       
   525         RBuf password;
       
   526         CleanupClosePushL( password );
       
   527         password.CreateL( KCCHMaxPasswordLength );
       
   528            
       
   529         CAknAlphaPasswordSettingPage* dlg = 
       
   530                 new ( ELeave ) CAknAlphaPasswordSettingPage(
       
   531                         R_CSCSETTINGSUI_PASSWORD_SETTING_PAGE, 
       
   532                         password, 
       
   533                         KNullDesC );
       
   534         
       
   535         if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenAccepted ) )
       
   536             {
       
   537             // Set password
       
   538             User::LeaveIfError( 
       
   539                 iModel.CCHHandler().SetConnectionParameter( 
       
   540                     iModel.CurrentSPEntryId(), ECchPassword, password ) );
       
   541             }
       
   542            
       
   543         CleanupStack::PopAndDestroy( &password );
       
   544         
       
   545         iContainer->UpdateContainerL();
       
   546         }
       
   547     else
       
   548         {
       
   549         // Show unable to change settings note
       
   550         HBufC* string = NULL;
       
   551         string = StringLoader::LoadL( 
       
   552                 R_CSCSETTINGSUI_UNABLE_TO_EDIT_WHILE_ONLINE );
       
   553         
       
   554         if ( string )
       
   555             {
       
   556             // Set text and show note.
       
   557             CleanupStack::PushL( string );   
       
   558             CAknInformationNote* note = 
       
   559                 new ( ELeave ) CAknInformationNote( ETrue );
       
   560             note->ExecuteLD( *string );
       
   561             CleanupStack::PopAndDestroy( string );
       
   562             }
       
   563         }
       
   564     }
       
   565 
       
   566 
       
   567 // ---------------------------------------------------------------------------
       
   568 // CCSCSettingsUiMainView::ShowPrefServiceSettingPageL()
       
   569 // Shows Internet call preferred setting page - for ON/OFF setting items
       
   570 // ---------------------------------------------------------------------------
       
   571 void CCSCSettingsUiMainView::ShowPrefServiceSettingPageL()
       
   572     {
       
   573     CSCSETUIDEBUG( "CCSCSettingsUiMainView::ShowPrefServiceSettingPageL" );
       
   574     
       
   575     if ( IsEditPreferredServiceSettingAllowedL() )
       
   576         {
       
   577         CDesCArrayFlat* items = 
       
   578              new ( ELeave ) CDesCArrayFlat( 2 );
       
   579         CleanupStack::PushL( items );
       
   580            
       
   581         AppendItemL( *items, R_CSCSETTINGSUI_SETTING_PREFERRED_SERVICE_ON );
       
   582         AppendItemL( *items, R_CSCSETTINGSUI_SETTING_PREFERRED_SERVICE_OFF );
       
   583                   
       
   584         // Get current value of the setting
       
   585         TInt value( iModel.SettingsHandler().IsPreferredTelephonyVoip() &&
       
   586                     iModel.SettingsHandler().IsPreferredService( 
       
   587                            iModel.CurrentSPEntryId() ) ? 
       
   588                            ECSCSettingsPrefServiceOn : 
       
   589                            ECSCSettingsPrefServiceOff);
       
   590               
       
   591         CAknRadioButtonSettingPage* dlg = new( ELeave ) 
       
   592             CAknRadioButtonSettingPage( 
       
   593                    R_CSCSETTINGSUI_PREF_SERVICE_SETTING_PAGE,
       
   594                    value, items );
       
   595             
       
   596         if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ) )
       
   597             {
       
   598             // Change value of the preferred telephony setting and set
       
   599             // current preferred service id. If preferred telephony value
       
   600             // is changed as voip then we set this service as preferred
       
   601             // service. Otherwise we set preferred service as not set (=0)
       
   602             TUint serviceId( value == ECSCSettingsPrefServiceOn ? 
       
   603                              iModel.CurrentSPEntryId() : 
       
   604                              KPrefServiceNotSet );
       
   605                
       
   606             iModel.SettingsHandler().SetVoipAsPrefTelephony( 
       
   607                     value == ECSCSettingsPrefServiceOn,
       
   608                     serviceId );
       
   609             }
       
   610                
       
   611         CleanupStack::PopAndDestroy( items );   
       
   612         iContainer->UpdateContainerL();
       
   613         }
       
   614     }
       
   615 
       
   616 
       
   617 // ---------------------------------------------------------------------------
       
   618 // CCSCSettingsUiMainView::ShowVccPrefServiceSettingPageL()
       
   619 // Shows Internet call preferred setting page - for ON/OFF setting items
       
   620 // when VCC is supported
       
   621 // ---------------------------------------------------------------------------
       
   622 void CCSCSettingsUiMainView::ShowVccPrefServiceSettingPageL()
       
   623     {
       
   624     CSCSETUIDEBUG( "CCSCSettingsUiMainView::ShowVccPrefServiceSettingPageL" );
       
   625     
       
   626     if ( IsEditPreferredServiceSettingAllowedL() )
       
   627         {
       
   628         CDesCArrayFlat* items = 
       
   629              new ( ELeave ) CDesCArrayFlat( 2 );
       
   630         CleanupStack::PushL( items );
       
   631            
       
   632         AppendItemL( *items, R_CSCSETTINGSUI_SETTING_VCC_PREFERRED_SERVICE_ON );
       
   633         AppendItemL( *items, R_CSCSETTINGSUI_SETTING_VCC_PREFERRED_SERVICE_OFF );
       
   634                   
       
   635         // Get current value of the setting
       
   636         TInt value( iModel.SettingsHandler().IsPreferredTelephonyVoip() &&
       
   637                     iModel.SettingsHandler().IsPreferredService( 
       
   638                            iModel.CurrentSPEntryId() ) ? 
       
   639                            ECSCSettingsPrefServiceOn : 
       
   640                            ECSCSettingsPrefServiceOff);
       
   641               
       
   642         CAknRadioButtonSettingPage* dlg = new( ELeave ) 
       
   643             CAknRadioButtonSettingPage( 
       
   644                    R_CSCSETTINGSUI_VCC_PREF_SERVICE_SETTING_PAGE,
       
   645                    value, items );
       
   646             
       
   647         if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ) )
       
   648             {
       
   649             // Change value of the preferred telephony setting and set
       
   650             // current preferred service id. If preferred telephony value
       
   651             // is changed as voip then we set this service as preferred
       
   652             // service. Otherwise we set preferred service as not set (=0)
       
   653             TUint serviceId( value == ECSCSettingsPrefServiceOn ? 
       
   654                              iModel.CurrentSPEntryId() : 
       
   655                              KPrefServiceNotSet );
       
   656                
       
   657             iModel.SettingsHandler().SetVoipAsPrefTelephony( 
       
   658                     value == ECSCSettingsPrefServiceOn,
       
   659                     serviceId );
       
   660             }
       
   661                
       
   662         CleanupStack::PopAndDestroy( items );   
       
   663         iContainer->UpdateContainerL();
       
   664         }
       
   665     }
       
   666 
       
   667 
       
   668 // ---------------------------------------------------------------------------
       
   669 // CCSCSettingsUiMainView::ShowImToneSelectionListL()
       
   670 // ---------------------------------------------------------------------------
       
   671 void CCSCSettingsUiMainView::ShowImToneSelectionListL()
       
   672     {    
       
   673     CMediaFileList* list = CMediaFileList::NewL();
       
   674     CleanupStack::PushL( list );
       
   675 
       
   676     HBufC* popupTitle = StringLoader::LoadLC( 
       
   677         R_CSCSETTINGSUI_IM_TONE_POPUP_HEADING );
       
   678     
       
   679     HBufC* noTone = StringLoader::LoadLC( 
       
   680         R_CSCSETTINGSUI_NO_IM_TONE_TEXT );
       
   681         
       
   682     list->SetAttrL( 
       
   683         CMediaFileList::EAttrAutomatedType,
       
   684         CDRMHelper::EAutomatedTypeIMAlert );
       
   685         
       
   686     list->SetNullItemL( 
       
   687         *noTone,
       
   688         KNullDesC, 
       
   689         CMediaFileList::EMediaFileTypeAudio,
       
   690         CMediaFileList::ENullItemIconOff );
       
   691     
       
   692     list->SetAttrL( CMediaFileList::EAttrTitle, *popupTitle );
       
   693 
       
   694     TBuf<KCSCMaxImToneLength> toneName;
       
   695     TInt nullItem = KErrNotFound;    
       
   696     
       
   697     TBool result = list->ShowMediaFileListL(
       
   698         &toneName, &nullItem , NULL, NULL );
       
   699   
       
   700     CleanupStack::PopAndDestroy( noTone );
       
   701     CleanupStack::PopAndDestroy( popupTitle );
       
   702     CleanupStack::PopAndDestroy( list );
       
   703     
       
   704     if ( result )
       
   705         {
       
   706         iContainer->SaveImTonePathL( toneName );
       
   707         }
       
   708     else if( KErrNotFound != nullItem )
       
   709         {
       
   710         iContainer->SaveImTonePathL( KNullDesC );
       
   711         }
       
   712     else
       
   713         {
       
   714         // do nothing
       
   715         }
       
   716     
       
   717     iContainer->UpdateContainerL();
       
   718     }
       
   719 
       
   720 
       
   721 // ---------------------------------------------------------------------------
       
   722 // CCSCSettingsUiMainView::HandleMskChangeSelectionL()
       
   723 // Handles 'change' middle softkey selection.
       
   724 // ---------------------------------------------------------------------------
       
   725 void CCSCSettingsUiMainView::HandleMskChangeSelectionL(
       
   726     TMainListBoxItem aListBoxItem )
       
   727     {
       
   728     switch ( aListBoxItem.iItem )
       
   729         {
       
   730         case TMainListBoxItem::EPreferredService:
       
   731         case TMainListBoxItem::EVccPreferredService:
       
   732             {
       
   733             ChangePrefTelephonyValueL();
       
   734             }
       
   735             break;
       
   736         case TMainListBoxItem::EHandoverNotifTone:
       
   737             {
       
   738             ChangeHandoverNotifToneValueL();
       
   739             }
       
   740             break;
       
   741         default:
       
   742             {
       
   743             User::Leave( KErrArgument );
       
   744             }
       
   745             break;
       
   746         }
       
   747     }
       
   748 
       
   749 // ---------------------------------------------------------------------------
       
   750 // CCSCSettingsUiMainView::ChangePrefTelephonyValueL()
       
   751 // Changes the value of the preferred telephony setting
       
   752 // ---------------------------------------------------------------------------
       
   753 void CCSCSettingsUiMainView::ChangePrefTelephonyValueL()
       
   754     {
       
   755     CSCSETUIDEBUG( "CCSCSettingsUiMainView::ChangePrefTelephonyValueL" );
       
   756     
       
   757     if ( IsEditPreferredServiceSettingAllowedL() )
       
   758         {
       
   759         // Check is this service preferred service
       
   760         TBool prefService( 
       
   761                 iModel.SettingsHandler().IsPreferredTelephonyVoip() &&
       
   762                 iModel.SettingsHandler().IsPreferredService( 
       
   763                 iModel.CurrentSPEntryId() ));
       
   764           
       
   765         // Set preferred service id as not set (=0) if preferred telephony
       
   766         // setting is changed as CS.
       
   767         TUint serviceId( prefService ? KPrefServiceNotSet : 
       
   768                                          iModel.CurrentSPEntryId() );
       
   769           
       
   770         // Set preferred telephony setting value and current preferred
       
   771         // service id
       
   772         iModel.SettingsHandler().SetVoipAsPrefTelephony( 
       
   773               !prefService,
       
   774               serviceId );
       
   775           
       
   776         iContainer->UpdateContainerL();
       
   777         }
       
   778     }
       
   779 
       
   780 // ---------------------------------------------------------------------------
       
   781 // CCSCSettingsUiMainView::ChangeHandoverNotifToneValueL()
       
   782 // Changes the value of the handover notify tone setting.
       
   783 // ---------------------------------------------------------------------------
       
   784 void CCSCSettingsUiMainView::ChangeHandoverNotifToneValueL()
       
   785     {
       
   786     TOnOff onOff = iModel.SettingsHandler().HandoverNotifTonePrefL( 
       
   787         iModel.CurrentSPEntryId() );
       
   788     
       
   789     if ( EOn == onOff )
       
   790         {
       
   791         iModel.SettingsHandler().SetHandoverNotifTonePrefL( 
       
   792             iModel.CurrentSPEntryId(), EOff );
       
   793         }
       
   794     else
       
   795         {
       
   796         iModel.SettingsHandler().SetHandoverNotifTonePrefL( 
       
   797             iModel.CurrentSPEntryId(), EOn );
       
   798         }
       
   799     
       
   800     iContainer->UpdateContainerL();
       
   801     }
       
   802 
       
   803 // -----------------------------------------------------------------------------
       
   804 // CCSCSettingsUiMainView::AppendItemL
       
   805 // Appends resource texts to the des array.
       
   806 // -----------------------------------------------------------------------------
       
   807 //
       
   808 void CCSCSettingsUiMainView::AppendItemL( 
       
   809     CDesCArrayFlat& aList, TInt aItem )
       
   810     {
       
   811     HBufC* string = StringLoader::LoadLC( aItem );
       
   812     aList.AppendL( *string );
       
   813     CleanupStack::PopAndDestroy( string );
       
   814     }    
       
   815 
       
   816 // ---------------------------------------------------------------------------
       
   817 // CCSCSettingsUiMainView::LaunchCMSettingsUiL
       
   818 // Launches Connection Method Settings Ui for editing destinations.
       
   819 // ---------------------------------------------------------------------------
       
   820 //
       
   821 void CCSCSettingsUiMainView::LaunchCMSettingsUiL()
       
   822     {
       
   823     CSCSETUIDEBUG( "CCSCSettingsUiMainView::LaunchCMSettingsUiL" );
       
   824     
       
   825     // Launch Connection Method Settings Ui.
       
   826     CCmSettingsUi* cmSettingsUi = CCmSettingsUi::NewL();
       
   827     CleanupStack::PushL( cmSettingsUi );
       
   828     if ( CCmSettingsUi::EExit == cmSettingsUi->RunSettingsL() )
       
   829         {
       
   830         HandleCommandL( EEikCmdExit );
       
   831         }
       
   832     CleanupStack::PopAndDestroy( cmSettingsUi );
       
   833     iContainer->UpdateContainerL();
       
   834     }
       
   835 
       
   836 // ---------------------------------------------------------------------------
       
   837 // CCSCSettingsUiMainView::HandleReturnToPreviousViewL
       
   838 // Handles returning to previous view where settingsui was launced.
       
   839 // ---------------------------------------------------------------------------
       
   840 //
       
   841 void CCSCSettingsUiMainView::HandleReturnToPreviousViewL()
       
   842     {
       
   843     CSCSETUIDEBUG( 
       
   844         "CCSCSettingsUiMainView::HandleReturnToPreviousViewL - IN" );
       
   845 
       
   846     if ( iModel.ReturnViewId() != KNullUid )
       
   847         {             
       
   848         TUid tabview( KNullUid );
       
   849         TRAPD( err, tabview.iUid = iModel.SettingsHandler().ServiceTabViewIdL( 
       
   850             iModel.CurrentSPEntryId() ) )
       
   851                  
       
   852         if ( tabview.iUid == iModel.ReturnViewId().iUid && !err )
       
   853             {
       
   854             RxSPViewServices viewServices;
       
   855             TInt err = viewServices.Activate( 
       
   856                 KPhoneBookTabUid.iUid, 
       
   857                 iModel.ReturnViewId().iUid );
       
   858               
       
   859             CSCSETUIDEBUG2( "   --> ACTIVATE ERR=%d", err );
       
   860               
       
   861             AppUi()->HandleCommandL( EEikCmdExit );
       
   862             }
       
   863         else
       
   864             { 
       
   865             // Not launched from service tab, activate previsous view
       
   866             AppUi()->ActivateLocalViewL( iModel.ReturnViewId() );
       
   867             }        
       
   868         }
       
   869       
       
   870     CSCSETUIDEBUG( 
       
   871         "CCSCSettingsUiMainView::HandleReturnToPreviousViewL - OUT" );
       
   872     }
       
   873 
       
   874 // ---------------------------------------------------------------------------
       
   875 // CCSCSettingsUiMainView::HandleSettingsUiExitL
       
   876 //  Handles exist from settingsui.
       
   877 // ---------------------------------------------------------------------------
       
   878 //
       
   879 void CCSCSettingsUiMainView::HandleSettingsUiExitL()
       
   880     {
       
   881     CSCSETUIDEBUG( "CCSCSettingsUiMainView::HandleSettingsUiExitL - IN" );
       
   882     
       
   883     if ( iModel.ReturnViewId() != KNullUid )
       
   884         {
       
   885         TUid tabview( KNullUid );
       
   886         TRAPD( err, tabview.iUid = iModel.SettingsHandler().ServiceTabViewIdL( 
       
   887             iModel.CurrentSPEntryId() ) )
       
   888         
       
   889         if ( tabview.iUid == iModel.ReturnViewId().iUid && !err )
       
   890             {
       
   891             // Launched from service tab, go back there
       
   892             RxSPViewServices viewServices;
       
   893             viewServices.Activate( 
       
   894                 KPhoneBookTabUid.iUid, 
       
   895                 iModel.ReturnViewId().iUid );     
       
   896             
       
   897             AppUi()->HandleCommandL( EEikCmdExit );
       
   898             }
       
   899         else
       
   900             { 
       
   901             // Not launched from service tab, just exit
       
   902             AppUi()->HandleCommandL( EEikCmdExit );
       
   903             }        
       
   904         }
       
   905        
       
   906     CSCSETUIDEBUG( "CCSCSettingsUiMainView::HandleSettingsUiExitL - OUT" );
       
   907     }
       
   908