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