commsconfig/cscsettingsui/src/cscsettingsuimaincontainer.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 CSCSettingsUiMainContainer methods
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <aknlists.h>
       
    20 #include <coecntrl.h>
       
    21 #include <cchclient.h>
       
    22 #include <cmmanagerext.h>
       
    23 #include <StringLoader.h>
       
    24 #include <spdefinitions.h>
       
    25 #include <cscsettingsui.rsg>
       
    26 #include <aknlistquerydialog.h>
       
    27 #include <cvimpstsettingsstore.h>
       
    28 #include <csxhelp/voip.hlp.hrh>
       
    29 #include <csc.rsg>
       
    30 #include <aknnotedialog.h>
       
    31 
       
    32 #include "cscconstants.h"
       
    33 #include "cscsettingsui.hrh"
       
    34 #include "cscsettingsuimodel.h"
       
    35 #include "cscsettingsuilogger.h"
       
    36 #include "cscengservicehandler.h"
       
    37 #include "cscsettingsuiconstants.h"
       
    38 #include "cscengdestinationshandler.h"
       
    39 #include "cipapputilsaddressresolver.h"
       
    40 #include "cscsettingsuimaincontainer.h"
       
    41 #include "cscengservicepluginhandler.h"
       
    42 #include "cscnoteutilities.h"
       
    43 #include "cscengsettingscleanupplugininterface.h"
       
    44 
       
    45 // Format of the setting item.
       
    46 _LIT( KCSCSettingsUiListItemTextFormat, "\t%S\t\t%S" );
       
    47 
       
    48 _LIT( KDoubleBackSlash, "\\" );
       
    49 _LIT( KEmptyPassword, "*****" );
       
    50 
       
    51 // ======== MEMBER FUNCTIONS ========
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 CCSCSettingsUiMainContainer::CCSCSettingsUiMainContainer(
       
    57     CCSCSettingsUiModel& aModel )
       
    58     : iModel( aModel )
       
    59     {
       
    60     }
       
    61 
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 void CCSCSettingsUiMainContainer::ConstructL(
       
    67     const TRect& aRect)
       
    68     {
       
    69     CSCSETUIDEBUG( "CCSCSettingsUiMainContainer::ConstructL - begin" );
       
    70 
       
    71     CreateWindowL();
       
    72     ConstructListBoxL();
       
    73     SetRect( aRect );
       
    74     ActivateL();
       
    75 
       
    76     CSCSETUIDEBUG( "CCSCSettingsUiMainContainer::ConstructL - end" );
       
    77     }
       
    78 
       
    79 
       
    80 // ---------------------------------------------------------------------------
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 CCSCSettingsUiMainContainer::~CCSCSettingsUiMainContainer()
       
    84     {
       
    85     CSCSETUIDEBUG( 
       
    86        "CCSCSettingsUiMainContainer::~CCSCSettingsUiMainContainer - begin" );
       
    87     
       
    88     iListBoxItemArray.Reset();
       
    89     iListBoxItemArray.Close();
       
    90     
       
    91     if ( iCaption )
       
    92         {
       
    93         delete iCaption;
       
    94         }
       
    95     
       
    96     delete iListBox;
       
    97     
       
    98     CSCSETUIDEBUG( 
       
    99        "CCSCSettingsUiMainContainer::~CCSCSettingsUiMainContainer - end" );
       
   100     }
       
   101 
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // CCSCSettingsUiMainContainer::UpdateContainerL
       
   105 // Updates container and redraws listbox items.
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 void CCSCSettingsUiMainContainer::UpdateContainerL()
       
   109     {
       
   110     CSCSETUIDEBUG( "CCSCSettingsUiMainContainer::UpdateContainerL - begin" );
       
   111 
       
   112     // Get listbox items from model.
       
   113     CTextListBoxModel* model = iListBox->Model();
       
   114     MDesCArray* textArray = model->ItemTextArray();
       
   115     CDesCArray* listBoxItems = static_cast<CDesCArray*>( textArray );
       
   116     listBoxItems->Reset();
       
   117     iListBoxItemArray.Reset();
       
   118 
       
   119     // Initialize setting items.
       
   120     InitializeSettingItemsL();
       
   121 
       
   122     CSCSETUIDEBUG( "CCSCSettingsUiMainContainer::UpdateContainerL - end" );
       
   123     }
       
   124 
       
   125 // ---------------------------------------------------------------------------
       
   126 // CCSCSettingsUiMainContainer::HandoverNotificationToneQueryL
       
   127 // Shows a query which changes handover notification tone setting for service.
       
   128 // ---------------------------------------------------------------------------
       
   129 //
       
   130 void CCSCSettingsUiMainContainer::HandoverNotificationToneQueryL()
       
   131     {    
       
   132     CDesCArrayFlat* items = new ( ELeave ) CDesCArrayFlat( 2 );   
       
   133     CleanupStack::PushL( items );
       
   134 
       
   135     HBufC* onItem =  StringLoader::LoadLC( 
       
   136             R_CSCSETTINGSUI_SETTING_HANDOVER_NOTIF_TONE_ON );
       
   137     items->AppendL( *onItem );
       
   138     CleanupStack::PopAndDestroy( onItem );
       
   139 
       
   140     HBufC* offItem =  StringLoader::LoadLC( 
       
   141             R_CSCSETTINGSUI_SETTING_HANDOVER_NOTIF_TONE_OFF );
       
   142     items->AppendL( *offItem );
       
   143     CleanupStack::PopAndDestroy( offItem );
       
   144 
       
   145     TInt index( 0 );
       
   146     CAknListQueryDialog* dialog = 
       
   147         new ( ELeave ) CAknListQueryDialog( &index );
       
   148 
       
   149     dialog->PrepareLC( R_CSCSETTINGSUI_HANDOVER_NOTIFICATION_TONE_QUERY );
       
   150     dialog->SetItemTextArray( items );
       
   151     dialog->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   152 
       
   153     if ( dialog->RunLD() )
       
   154         {
       
   155         // Update setting according user selection
       
   156         if ( 0 == index )
       
   157             {   
       
   158             // Set handover notification tone setting value on
       
   159             iModel.SettingsHandler().SetHandoverNotifTonePrefL( 
       
   160                 iModel.CurrentSPEntryId(), EOn );
       
   161             }
       
   162         else if ( 1 == index )
       
   163             {
       
   164             // Set handover notification tone setting value off
       
   165             iModel.SettingsHandler().SetHandoverNotifTonePrefL( 
       
   166                 iModel.CurrentSPEntryId(), EOff );
       
   167             }
       
   168         else
       
   169             {
       
   170             // invalid index
       
   171             User::Leave( KErrGeneral );
       
   172             }
       
   173         }
       
   174     else
       
   175         {        
       
   176         // cancelled
       
   177         }
       
   178 
       
   179     CleanupStack::PopAndDestroy( items );
       
   180     UpdateContainerL();
       
   181     }
       
   182 
       
   183 // ---------------------------------------------------------------------------
       
   184 // CCSCSettingsUiMainContainer::PresenceReqPrefQueryL
       
   185 // Shows a query which changes presence request preference for service.
       
   186 // ---------------------------------------------------------------------------
       
   187 //
       
   188 void CCSCSettingsUiMainContainer::PresenceReqPrefQueryL()
       
   189     {    
       
   190     CDesCArrayFlat* items = new ( ELeave ) CDesCArrayFlat( 2 );   
       
   191     CleanupStack::PushL( items );
       
   192 
       
   193     HBufC* alwaysAskItem =  StringLoader::LoadLC( 
       
   194             R_CSCSETTINGSUI_PRES_PREF_ALWAYS_ASK );
       
   195     items->AppendL( *alwaysAskItem );
       
   196     CleanupStack::PopAndDestroy( alwaysAskItem );
       
   197 
       
   198     HBufC* autoAcceptItem =  StringLoader::LoadLC( 
       
   199             R_CSCSETTINGSUI_PRES_PREF_ACCEPT_AUTOMATICALLY );
       
   200     items->AppendL( *autoAcceptItem );
       
   201     CleanupStack::PopAndDestroy( autoAcceptItem );
       
   202 
       
   203     TInt index( 0 );
       
   204     CAknListQueryDialog* dialog = 
       
   205         new ( ELeave ) CAknListQueryDialog( &index );
       
   206 
       
   207     dialog->PrepareLC( R_CSCSETTINGSUI_PRESENCE_REQUEST_PREF_QUERY );
       
   208     dialog->SetItemTextArray( items );
       
   209     dialog->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   210 
       
   211     if ( dialog->RunLD() )
       
   212         {
       
   213         // Update setting according user selection
       
   214         if ( 0 == index )
       
   215             {   
       
   216             // Set presence request preference setting value
       
   217             iModel.SettingsHandler().SetPresenceReqPrefL( 
       
   218                 iModel.CurrentSPEntryId(), EOff );
       
   219             }
       
   220         else if ( 1 == index )
       
   221             {
       
   222             // Set presence request preference setting value
       
   223             iModel.SettingsHandler().SetPresenceReqPrefL( 
       
   224                 iModel.CurrentSPEntryId(), EOn );
       
   225             }
       
   226         else
       
   227             {
       
   228             // invalid index
       
   229             User::Leave( KErrGeneral );
       
   230             }
       
   231         }
       
   232     else
       
   233         {        
       
   234         // canceled
       
   235         }
       
   236 
       
   237     CleanupStack::PopAndDestroy( items );
       
   238     UpdateContainerL();
       
   239     }
       
   240 
       
   241 // ---------------------------------------------------------------------------
       
   242 // CCSCSettingsUiMainContainer::SaveImTonePathL
       
   243 // Saves Im tone path to permanent storage.
       
   244 // ---------------------------------------------------------------------------
       
   245 //
       
   246 void CCSCSettingsUiMainContainer::SaveImTonePathL( const TDesC& aTonePath )
       
   247     { 
       
   248     MVIMPSTSettingsStore* settings = CVIMPSTSettingsStore::NewLC();
       
   249 
       
   250     User::LeaveIfError( settings->SetL( 
       
   251         iModel.CurrentSPEntryId(), EServiceToneFileName, aTonePath ) );
       
   252 
       
   253     CleanupStack::PopAndDestroy();
       
   254     }
       
   255 
       
   256 // ---------------------------------------------------------------------------
       
   257 // CCSCSettingsUiMainContainer::ListBox
       
   258 // Returns handle to the listbox.
       
   259 // ---------------------------------------------------------------------------
       
   260 //    
       
   261 CAknSettingStyleListBox* CCSCSettingsUiMainContainer::ListBox()
       
   262     {
       
   263     return iListBox;
       
   264     }
       
   265 
       
   266 // ---------------------------------------------------------------------------
       
   267 // CCSCSettingsUiMainContainer::CurrentItemIndex
       
   268 // Returns index of selected listbox item. 
       
   269 // ---------------------------------------------------------------------------
       
   270 //
       
   271 TMainListBoxItem CCSCSettingsUiMainContainer::CurrentItem() const
       
   272     {
       
   273     TInt currentItemIndex( iListBox->CurrentItemIndex() );
       
   274     return iListBoxItemArray[ currentItemIndex ];
       
   275     }
       
   276 
       
   277 // ---------------------------------------------------------------------------
       
   278 // From class CoeControl
       
   279 // CCSCSettingsUiMainContainer::ComponentControl
       
   280 // ---------------------------------------------------------------------------
       
   281 //
       
   282 CCoeControl* CCSCSettingsUiMainContainer::ComponentControl( 
       
   283     TInt /*aIndex*/ ) const
       
   284     {
       
   285     return iListBox;
       
   286     }
       
   287 
       
   288 // -----------------------------------------------------------------------------
       
   289 // From class CoeControl
       
   290 // For getting help context
       
   291 // -----------------------------------------------------------------------------
       
   292 //
       
   293 void CCSCSettingsUiMainContainer::GetHelpContext( 
       
   294     TCoeHelpContext& aContext ) const
       
   295     {
       
   296     aContext.iMajor = KCscHelpUid;
       
   297     aContext.iContext = KSERVTAB_HLP_SETTINGS;
       
   298     }
       
   299 
       
   300 // ---------------------------------------------------------------------------
       
   301 // From class CoeControl
       
   302 // CCSCSettingsUiMainContainer::OfferKeyEventL
       
   303 // ---------------------------------------------------------------------------
       
   304 //
       
   305 TKeyResponse CCSCSettingsUiMainContainer::OfferKeyEventL( 
       
   306     const TKeyEvent& aKeyEvent, TEventCode aType )
       
   307     {
       
   308     TKeyResponse response = EKeyWasNotConsumed;
       
   309     response = iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   310 
       
   311     if ( EKeyUpArrow == aKeyEvent.iCode ||  
       
   312         EKeyDownArrow == aKeyEvent.iCode  )
       
   313         {
       
   314         iModel.UpdateSoftkeys();
       
   315         }
       
   316 
       
   317     return response;
       
   318     }
       
   319 
       
   320 
       
   321 // ---------------------------------------------------------------------------
       
   322 // From class CoeControl
       
   323 // CCSCSettingsUiMainContainer::HandleResourceChange
       
   324 // ---------------------------------------------------------------------------
       
   325 //
       
   326 void CCSCSettingsUiMainContainer::HandleResourceChange( TInt aType )
       
   327     {
       
   328     if( aType == KAknsMessageSkinChange ||
       
   329         aType == KEikDynamicLayoutVariantSwitch )
       
   330         {
       
   331         TRect mainPaneRect;
       
   332         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, 
       
   333                                            mainPaneRect );
       
   334         SetRect( mainPaneRect );
       
   335         DrawNow();
       
   336         }
       
   337 
       
   338     CCoeControl::HandleResourceChange( aType );
       
   339     }
       
   340 
       
   341 
       
   342 // ---------------------------------------------------------------------------
       
   343 // CCSCSettingsUiMainContainer::ConstructListBoxL
       
   344 // Creates listbox item for setting items.
       
   345 // ---------------------------------------------------------------------------
       
   346 //
       
   347 void CCSCSettingsUiMainContainer::ConstructListBoxL()
       
   348     {
       
   349     CSCSETUIDEBUG( "CCSCSettingsUiMainContainer::ConstructListBoxL - begin" );
       
   350 
       
   351     // Create listbox and array for listbox items.
       
   352     iListBox = new( ELeave ) CAknSettingStyleListBox;
       
   353     iListBox->ConstructL( this, EAknListBoxSelectionList );    
       
   354     iListBox->CreateScrollBarFrameL( ETrue );
       
   355     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   356         CEikScrollBarFrame::EOff, 
       
   357         CEikScrollBarFrame::EAuto );
       
   358     iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );
       
   359     CDesCArrayFlat* itemsArray = 
       
   360         new ( ELeave ) CDesCArrayFlat( KCSCSettingsUiArrayGranularity );  
       
   361     iListBox->Model()->SetItemTextArray( itemsArray );
       
   362 
       
   363     // Initialize setting items.
       
   364     InitializeSettingItemsL();
       
   365 
       
   366     CSCSETUIDEBUG( "CCSCSettingsUiMainContainer::ConstructListBoxL - end" );
       
   367     }
       
   368 
       
   369 
       
   370 // ---------------------------------------------------------------------------
       
   371 // CCSCSettingsUiMainContainer::InitializeSettingItemsL
       
   372 // Draws setting items at the first time after the initialization is completed
       
   373 // ---------------------------------------------------------------------------
       
   374 //
       
   375 void CCSCSettingsUiMainContainer::InitializeSettingItemsL()
       
   376     {
       
   377     CSCSETUIDEBUG( 
       
   378         "CCSCSettingsUiMainContainer::InitializeSettingItemsL - begin" );
       
   379 
       
   380     // Get supported subservices
       
   381     TSupportedSubServices supSubServices;
       
   382     iModel.CCHHandler().SupportedSubServicesL( 
       
   383             iModel.CurrentSPEntryId(), supSubServices );
       
   384 
       
   385     // Make username setting
       
   386     MakeSettingItemL ( TMainListBoxItem::EUsername );
       
   387 
       
   388     // Make password setting
       
   389     MakeSettingItemL ( TMainListBoxItem::EPassword );
       
   390 
       
   391     // Make preferred service setting item if voip subservice is supported
       
   392     if ( supSubServices.iVoIP )
       
   393         {
       
   394         TBool isSipVoip( EFalse );     
       
   395         TRAPD( err, isSipVoip = iModel.SettingsHandler().IsSipVoIPL(
       
   396             iModel.CurrentSPEntryId() ) );
       
   397            
       
   398         if ( !err )
       
   399             {
       
   400             if ( isSipVoip && iModel.SettingsHandler().IsVccSupportedL( 
       
   401                 iModel.CurrentSPEntryId() ) )
       
   402                 {
       
   403                 // If VCC is supported make vcc preferred setting item
       
   404                 // and handover notification tone setting item
       
   405                 MakeSettingItemL ( TMainListBoxItem::EVccPreferredService );
       
   406                 MakeSettingItemL ( TMainListBoxItem::EHandoverNotifTone );
       
   407                 }
       
   408             else
       
   409                 {
       
   410                 // If VCC is not supported make just preferred service setting
       
   411                 MakeSettingItemL ( TMainListBoxItem::EPreferredService );
       
   412                 }
       
   413             }
       
   414         }
       
   415 
       
   416     // Make setting item if IM is supported by service
       
   417     if ( supSubServices.iIm )
       
   418         {
       
   419         // IM tone setting.
       
   420         MakeSettingItemL( TMainListBoxItem::EImTone );
       
   421         }
       
   422 
       
   423     // Make setting item if presence is supported by service
       
   424     if ( supSubServices.iPresence )
       
   425         {
       
   426         // Presence request preference
       
   427         MakeSettingItemL( TMainListBoxItem::EAutoacceptInv );
       
   428         }
       
   429 
       
   430     // Connectivity setting (cannot be changed)
       
   431     MakeSettingItemL( TMainListBoxItem::EServiceConn );
       
   432 
       
   433     CSCSETUIDEBUG( 
       
   434         "CCSCSettingsUiMainContainer::InitializeSettingItemsL - end" );
       
   435     }
       
   436 
       
   437 // ---------------------------------------------------------------------------
       
   438 // CCSCSettingsUiMainContainer::MakeSettingItemL
       
   439 // Constructs setting list items.
       
   440 // ---------------------------------------------------------------------------
       
   441 //
       
   442 void CCSCSettingsUiMainContainer::MakeSettingItemL(
       
   443     TMainListBoxItem::TSettingItems aItem )
       
   444     {
       
   445     CSCSETUIDEBUG( 
       
   446         "CCSCSettingsUiMainContainer::MakeSettingItemL - begin" );
       
   447 
       
   448     // Get listbox items from model.
       
   449     CTextListBoxModel* model = iListBox->Model();
       
   450     MDesCArray* textArray = model->ItemTextArray();
       
   451     CDesCArray* listBoxItems = static_cast<CDesCArray*>( textArray );
       
   452 
       
   453     TBuf<KCSCSettingsUiItemLength> listBoxItemText ( KNullDesC );
       
   454 
       
   455     TMainListBoxItem listBoxItem;
       
   456     listBoxItem.iItem = aItem;
       
   457 
       
   458     RBuf value;
       
   459     CleanupClosePushL( value );
       
   460 
       
   461     value.CreateL( 1 );
       
   462     value.Copy( KNullDesC );
       
   463 
       
   464     switch ( aItem  )
       
   465         {
       
   466         case TMainListBoxItem::EUsername:
       
   467             {
       
   468             GetUsernameL( value );
       
   469             break;
       
   470             }
       
   471         case TMainListBoxItem::EPassword:
       
   472             {
       
   473             value.ReAllocL( KEmptyPassword().Length() );
       
   474             value.Copy( KEmptyPassword );
       
   475             break;
       
   476             }
       
   477         case TMainListBoxItem::EPreferredService:
       
   478             {
       
   479             GetPreferredServiceSettingL( value );
       
   480             break;
       
   481             }
       
   482         case TMainListBoxItem::EVccPreferredService:
       
   483             {
       
   484             GetVccPreferredServiceSettingL( value );
       
   485             break;
       
   486             }
       
   487         case TMainListBoxItem::EHandoverNotifTone:
       
   488             {
       
   489             GetHandoverNotificationTonePrefL( value );
       
   490             break;
       
   491             }
       
   492         case TMainListBoxItem::EImTone:
       
   493             {
       
   494             GetImToneSettingL( value );
       
   495             break;
       
   496             }
       
   497         case TMainListBoxItem::EAutoacceptInv:
       
   498             {
       
   499             GetPresencePrefSettingL( value );
       
   500             break;
       
   501             }
       
   502         case TMainListBoxItem::EServiceConn:
       
   503             {
       
   504             TRAP_IGNORE( GetSnapSettingL( value ) );
       
   505             break;
       
   506             }
       
   507         default:
       
   508             User::Leave( KErrArgument );
       
   509             break;
       
   510         }
       
   511 
       
   512     listBoxItemText.Format(
       
   513             KCSCSettingsUiListItemTextFormat,
       
   514             GetCaptionL( aItem ),
       
   515             &value );
       
   516 
       
   517     CleanupStack::PopAndDestroy( &value );
       
   518 
       
   519     // Add to listbox
       
   520     iListBoxItemArray.Append( listBoxItem );
       
   521     listBoxItems->AppendL( listBoxItemText );
       
   522     iListBox->HandleItemAdditionL();
       
   523 
       
   524     CSCSETUIDEBUG( 
       
   525         "CCSCSettingsUiMainContainer::MakeSettingItemL - end" );
       
   526     }
       
   527 
       
   528 // ---------------------------------------------------------------------------
       
   529 // CCSCSettingsUiMainContainer::GetCaptionL
       
   530 // Constructs setting list items.
       
   531 // ---------------------------------------------------------------------------
       
   532 //
       
   533 HBufC* CCSCSettingsUiMainContainer::GetCaptionL( 
       
   534     TMainListBoxItem::TSettingItems aItem )
       
   535     {
       
   536     if ( iCaption != NULL )
       
   537         {
       
   538         delete iCaption;
       
   539         iCaption = NULL;
       
   540         }
       
   541 
       
   542     switch ( aItem  )
       
   543         {
       
   544         case TMainListBoxItem::EUsername:
       
   545             {
       
   546             iCaption = StringLoader::LoadL(
       
   547                 R_CSCSETTINGSUI_SETTING_USERNAME_TITLE );
       
   548             break;
       
   549             }
       
   550         case TMainListBoxItem::EPassword:
       
   551             {
       
   552             iCaption = StringLoader::LoadL(
       
   553                 R_CSCSETTINGSUI_SETTING_PASSWORD_TITLE );
       
   554             break;
       
   555             }
       
   556         case TMainListBoxItem::EPreferredService:
       
   557             {
       
   558             iCaption = StringLoader::LoadL(
       
   559                 R_CSCSETTINGSUI_SETTING_PREFERRED_SERVICE_TITLE );
       
   560             break;
       
   561             }
       
   562         case TMainListBoxItem::EVccPreferredService:
       
   563             {
       
   564             iCaption = StringLoader::LoadL(
       
   565                 R_CSCSETTINGSUI_SETTING_VCC_PREFERRED_SERVICE_TITLE );
       
   566             break;
       
   567             }
       
   568         case TMainListBoxItem::EHandoverNotifTone:
       
   569             {
       
   570             iCaption = StringLoader::LoadL(
       
   571                 R_CSCSETTINGSUI_SETTING_HANDOVER_NOTIF_TONE_TITLE );
       
   572             break;
       
   573             }
       
   574         case TMainListBoxItem::EImTone:
       
   575             {
       
   576             iCaption = StringLoader::LoadL( 
       
   577                 R_CSCSETTINGSUI_SETTING_IM_TONE_TITLE );
       
   578             break;
       
   579             }
       
   580         case TMainListBoxItem::EAutoacceptInv:
       
   581             {
       
   582             iCaption = StringLoader::LoadL( 
       
   583                 R_CSCSETTINGSUI_PRESENCE_REQUEST_PREF_TEXT );
       
   584             break;
       
   585             }
       
   586         case TMainListBoxItem::EServiceConn:
       
   587             {
       
   588             iCaption = StringLoader::LoadL( 
       
   589                 R_CSCSETTINGSUI_SERVICE_CONNECTIVITY_TEXT );
       
   590             break;
       
   591             }
       
   592         default:
       
   593             User::Leave( KErrArgument );
       
   594             break;
       
   595         }
       
   596 
       
   597     return iCaption;
       
   598     }
       
   599  
       
   600 // ---------------------------------------------------------------------------
       
   601 // CCSCSettingsUiMainContainer::GetUsername
       
   602 // ---------------------------------------------------------------------------
       
   603 //
       
   604 void CCSCSettingsUiMainContainer::GetUsernameL( RBuf& aUsername )
       
   605     {
       
   606     aUsername.ReAllocL( KCCHMaxUsernameLength );
       
   607     User::LeaveIfError( iModel.CCHHandler().GetConnectionParameter( 
       
   608         iModel.CurrentSPEntryId(), ECchUsername, aUsername ) );
       
   609     }
       
   610 
       
   611 // ---------------------------------------------------------------------------
       
   612 // CCSCSettingsUiMainContainer::GetPresencePrefSettingL
       
   613 // ---------------------------------------------------------------------------
       
   614 //
       
   615 void CCSCSettingsUiMainContainer::GetPreferredServiceSettingL( RBuf& aValue )
       
   616     {
       
   617     // Select text resource for the current pref telephony value
       
   618     TInt resource = ( iModel.SettingsHandler().IsPreferredTelephonyVoip() &&
       
   619         iModel.SettingsHandler().IsPreferredService(
       
   620         iModel.CurrentSPEntryId() ) ) ?
       
   621         R_CSCSETTINGSUI_SETTING_PREFERRED_SERVICE_ON :
       
   622         R_CSCSETTINGSUI_SETTING_PREFERRED_SERVICE_OFF;
       
   623 
       
   624     HBufC* value = StringLoader::LoadLC( resource );
       
   625     aValue.ReAllocL( value->Length() );
       
   626     aValue.Copy( value->Des() );
       
   627     CleanupStack::PopAndDestroy( value );
       
   628     }
       
   629 
       
   630 // ---------------------------------------------------------------------------
       
   631 // CCSCSettingsUiMainContainer::GetVccPreferredServiceSettingL
       
   632 // ---------------------------------------------------------------------------
       
   633 //
       
   634 void CCSCSettingsUiMainContainer::GetVccPreferredServiceSettingL( RBuf& aValue )
       
   635     {
       
   636     // Select text resource for the current pref telephony value
       
   637     TInt resource = ( iModel.SettingsHandler().IsPreferredTelephonyVoip() &&
       
   638         iModel.SettingsHandler().IsPreferredService(
       
   639         iModel.CurrentSPEntryId() ) ) ?
       
   640         R_CSCSETTINGSUI_SETTING_VCC_PREFERRED_SERVICE_ON :
       
   641         R_CSCSETTINGSUI_SETTING_VCC_PREFERRED_SERVICE_OFF;
       
   642 
       
   643     HBufC* value = StringLoader::LoadLC( resource );
       
   644     aValue.ReAllocL( value->Length() );
       
   645     aValue.Copy( value->Des() );
       
   646     CleanupStack::PopAndDestroy( value );
       
   647     }
       
   648 
       
   649 // ---------------------------------------------------------------------------
       
   650 // CCSCSettingsUiMainContainer::GetHandoverNotificationToneL
       
   651 // ---------------------------------------------------------------------------
       
   652 //
       
   653 void CCSCSettingsUiMainContainer::GetHandoverNotificationTonePrefL( 
       
   654     RBuf& aValue )
       
   655     {
       
   656     HBufC* value = NULL;
       
   657     TOnOff onOff = EOff;
       
   658 
       
   659     TRAPD( err, onOff = iModel.SettingsHandler().HandoverNotifTonePrefL( 
       
   660         iModel.CurrentSPEntryId() ) );
       
   661 
       
   662     if ( KErrNotFound == err )
       
   663         {
       
   664         iModel.SettingsHandler().SetHandoverNotifTonePrefL( 
       
   665             iModel.CurrentSPEntryId(), EOff );
       
   666         }
       
   667     else if ( err )
       
   668         {
       
   669         User::Leave( err );    
       
   670         }
       
   671     else
       
   672         {
       
   673         // nothing to do
       
   674         }
       
   675 
       
   676     if ( EOff == onOff )
       
   677         {
       
   678         value = StringLoader::LoadLC( 
       
   679             R_CSCSETTINGSUI_SETTING_HANDOVER_NOTIF_TONE_OFF );
       
   680         }
       
   681     else if ( EOn == onOff)
       
   682         {            
       
   683         value = StringLoader::LoadLC( 
       
   684             R_CSCSETTINGSUI_SETTING_HANDOVER_NOTIF_TONE_ON );
       
   685         }
       
   686     else if ( EOONotSet == onOff )
       
   687         {            
       
   688         iModel.SettingsHandler().SetHandoverNotifTonePrefL( 
       
   689             iModel.CurrentSPEntryId(), EOff );
       
   690         
       
   691         value = StringLoader::LoadLC( 
       
   692             R_CSCSETTINGSUI_SETTING_HANDOVER_NOTIF_TONE_OFF );
       
   693         }
       
   694     else
       
   695         {
       
   696         User::Leave( KErrGeneral );     
       
   697         }
       
   698 
       
   699     aValue.ReAllocL( value->Length() );
       
   700     aValue.Copy( value->Des() );
       
   701 
       
   702     CleanupStack::PopAndDestroy( value );
       
   703     }
       
   704 
       
   705 // ---------------------------------------------------------------------------
       
   706 // CCSCSettingsUiMainContainer::GetImToneSettingL
       
   707 // ---------------------------------------------------------------------------
       
   708 //
       
   709 void CCSCSettingsUiMainContainer::GetImToneSettingL( RBuf& aValue )
       
   710     {
       
   711     aValue.ReAllocL( KCSCMaxImToneLength );
       
   712 
       
   713     MVIMPSTSettingsStore* settings = CVIMPSTSettingsStore::NewLC();
       
   714 
       
   715     TInt err = settings->GetL( 
       
   716         iModel.CurrentSPEntryId(), EServiceToneFileName, aValue );
       
   717 
       
   718     // If tone path is not found from settings, set Off text
       
   719     if ( KErrNotFound == err || aValue.Length() < 2 )
       
   720         {
       
   721         HBufC* noToneSelected = StringLoader::LoadLC( 
       
   722             R_CSCSETTINGSUI_IM_TONE_OFF );
       
   723 
       
   724         User::LeaveIfError( settings->SetL( 
       
   725             iModel.CurrentSPEntryId(), EServiceToneFileName, *noToneSelected ) );       
       
   726 
       
   727         // Get tone.
       
   728         User::LeaveIfError( settings->GetL( 
       
   729             iModel.CurrentSPEntryId(), EServiceToneFileName, aValue ) );
       
   730 
       
   731         CleanupStack::PopAndDestroy( noToneSelected );
       
   732         }
       
   733     else if ( err )
       
   734         {        
       
   735         User::Leave( err );
       
   736         }
       
   737     else
       
   738         {
       
   739         // KErrNone -> do nothing
       
   740         }
       
   741 
       
   742     TInt pos( 0 );    
       
   743     while ( KErrNotFound != pos )
       
   744         {
       
   745         pos = aValue.Find( KDoubleBackSlash );
       
   746         aValue.Delete( 0, pos+1 );
       
   747         }
       
   748 
       
   749     CleanupStack::PopAndDestroy();
       
   750     }
       
   751 
       
   752 // ---------------------------------------------------------------------------
       
   753 // CCSCSettingsUiMainContainer::GetPresencePrefSettingL
       
   754 // ---------------------------------------------------------------------------
       
   755 //
       
   756 void CCSCSettingsUiMainContainer::GetPresencePrefSettingL( RBuf& aValue )
       
   757     {
       
   758     HBufC* value = NULL;
       
   759     TOnOff onOff = EOff;
       
   760 
       
   761     TRAPD( err, onOff = iModel.SettingsHandler().PresenceReqPrefL( 
       
   762             iModel.CurrentSPEntryId() ) );
       
   763 
       
   764     if ( KErrNotFound == err )
       
   765         {
       
   766         iModel.SettingsHandler().SetPresenceReqPrefL( 
       
   767                 iModel.CurrentSPEntryId(), EOff );
       
   768         }
       
   769     else if ( err )
       
   770         {
       
   771         User::Leave( err );    
       
   772         }
       
   773     else
       
   774         {
       
   775         // nothing to do
       
   776         }
       
   777 
       
   778     if ( EOff == onOff )
       
   779         {
       
   780         value = StringLoader::LoadLC( 
       
   781             R_CSCSETTINGSUI_PRES_PREF_ALWAYS_ASK );
       
   782         }
       
   783     else if ( EOn == onOff)
       
   784         {            
       
   785         value = StringLoader::LoadLC( 
       
   786             R_CSCSETTINGSUI_PRES_PREF_ACCEPT_AUTOMATICALLY );
       
   787         }
       
   788     else if ( EOONotSet == onOff )
       
   789         {            
       
   790         // Set presence request preference setting default value "off"
       
   791         iModel.SettingsHandler().SetPresenceReqPrefL( 
       
   792             iModel.CurrentSPEntryId(), EOff );
       
   793         
       
   794         value = StringLoader::LoadLC( 
       
   795             R_CSCSETTINGSUI_PRES_PREF_ALWAYS_ASK );
       
   796         }
       
   797     else
       
   798         {
       
   799         User::Leave( KErrGeneral );     
       
   800         }
       
   801 
       
   802     aValue.ReAllocL( value->Length() );
       
   803     aValue.Copy( value->Des() );
       
   804 
       
   805     CleanupStack::PopAndDestroy( value ); 
       
   806     }
       
   807 
       
   808 // ---------------------------------------------------------------------------
       
   809 // CCSCSettingsUiMainContainer::GetSnapSettingL
       
   810 // ---------------------------------------------------------------------------
       
   811 //
       
   812 void CCSCSettingsUiMainContainer::GetSnapSettingL( RBuf& aValue )
       
   813     {
       
   814     // Get Snap name
       
   815     HBufC* snapName = NULL;
       
   816     TInt snapId( 0 );
       
   817     TInt err = iModel.CCHHandler().GetConnectionParameter( 
       
   818        iModel.CurrentSPEntryId(), ECchSnapId, snapId );       
       
   819 
       
   820     // If no error, try to get snap name.
       
   821     if ( KErrNone == err )
       
   822         {
       
   823         snapName = iModel.DestinationsHandler().SnapNameL( snapId );
       
   824         
       
   825         if ( snapName )
       
   826            {
       
   827            CleanupStack::PushL( snapName );
       
   828            aValue.ReAllocL( snapName->Length() );
       
   829            aValue.Copy( snapName->Des() );
       
   830            CleanupStack::PopAndDestroy( snapName );
       
   831            }
       
   832         }
       
   833     }
       
   834 
       
   835 // ---------------------------------------------------------------------------
       
   836 // From class CoeControl
       
   837 // CCSCSettingsUiMainContainer::CountComponentControls
       
   838 // ---------------------------------------------------------------------------
       
   839 //
       
   840 TInt CCSCSettingsUiMainContainer::CountComponentControls() const
       
   841     {
       
   842     return 1;
       
   843     }
       
   844 
       
   845 // ---------------------------------------------------------------------------
       
   846 // From class CoeControl
       
   847 // CCSCSettingsUiMainContainer::SizeChanged
       
   848 // ---------------------------------------------------------------------------
       
   849 //
       
   850 void CCSCSettingsUiMainContainer::SizeChanged()
       
   851     {
       
   852     iListBox->SetRect( Rect() );
       
   853     }
       
   854 
       
   855 // ---------------------------------------------------------------------------
       
   856 // From class CoeControl
       
   857 // CCSCSettingsUiMainContainer::FocusChanged
       
   858 // ---------------------------------------------------------------------------
       
   859 //
       
   860 void CCSCSettingsUiMainContainer::FocusChanged( 
       
   861     TDrawNow aDrawNow )
       
   862     {
       
   863     CCoeControl::FocusChanged( aDrawNow );
       
   864 
       
   865     if ( iListBox )
       
   866         {
       
   867         iListBox->SetFocus( IsFocused() );
       
   868         }
       
   869     }
       
   870 
       
   871 // ---------------------------------------------------------------------------
       
   872 // Deletes service.
       
   873 // ---------------------------------------------------------------------------
       
   874 //
       
   875 TBool CCSCSettingsUiMainContainer::DeleteServiceL()
       
   876     {
       
   877     CSCSETUIDEBUG( "CCSCSettingsUiMainContainer::DeleteServiceL - begin" );
       
   878 
       
   879     // Show confirmation query for service deletion.
       
   880     // Create confirmation query dialog.
       
   881     TBool isDelete( EFalse );
       
   882     HBufC* string = NULL;
       
   883     CAknQueryDialog* query = 
       
   884         new( ELeave ) CAknQueryDialog( CAknQueryDialog::ENoTone );
       
   885 
       
   886     CleanupStack::PushL( query );
       
   887     query->PrepareLC( R_CSC_DELETE_SERVICE_QUERY );
       
   888     string = StringLoader::LoadLC( 
       
   889         R_QTN_CSC_DELETE_SERVICE_QUERY, 
       
   890         iModel.SettingsHandler().ServiceNameL( iModel.CurrentSPEntryId() ) );
       
   891     query->SetPromptL( *string );
       
   892     CleanupStack::PopAndDestroy( string );
       
   893     CleanupStack::Pop( query );
       
   894     if ( query->RunLD() )
       
   895         {
       
   896         // First check if there is a service plugin UID.
       
   897         TInt count = iModel.ServicePluginHandler().PluginCount( 
       
   898             CCSCEngServicePluginHandler::EInitialized );
       
   899 
       
   900         TRAPD( err, LaunchCleanupPluginL( iModel.CurrentSPEntryId() ) );
       
   901         if ( KErrNone != err )
       
   902             {
       
   903             iModel.SettingsHandler().DeleteServiceL( 
       
   904                 iModel.CurrentSPEntryId() );
       
   905             }
       
   906         isDelete = ETrue;
       
   907         }
       
   908 
       
   909     CSCSETUIDEBUG( "CCSCSettingsUiMainContainer::DeleteServiceL - end" );
       
   910     return isDelete;
       
   911     }
       
   912 
       
   913 // ---------------------------------------------------------------------------
       
   914 // Launches cleanup plugin to remove settings.
       
   915 // ---------------------------------------------------------------------------
       
   916 //
       
   917 void CCSCSettingsUiMainContainer::LaunchCleanupPluginL( 
       
   918     TUint aServiceId ) const
       
   919     {
       
   920     CSCSETUIDEBUG( 
       
   921         "CCSCSettingsUiMainContainer::LaunchCleanupPluginL - begin" );
       
   922 
       
   923     RImplInfoPtrArray implInfoArray;
       
   924     CleanupStack::PushL( TCleanupItem( 
       
   925         ResetAndDestroy, &implInfoArray ) );
       
   926 
       
   927     REComSession::ListImplementationsL(
       
   928         KCSCSettingsCleanupPluginInterfaceUid,
       
   929         implInfoArray );
       
   930 
       
   931     for ( TInt i( 0 ) ; i < implInfoArray.Count() ; i++ )
       
   932         {                    
       
   933         CCSCEngSettingsCleanupPluginInterface* plugin = 
       
   934             CCSCEngSettingsCleanupPluginInterface::NewL( 
       
   935                 implInfoArray[i]->ImplementationUid() );
       
   936 
       
   937         CleanupStack::PushL( plugin );
       
   938 
       
   939         if ( CCSCEngSettingsCleanupPluginInterface::ESipVoIPCleanupPlugin 
       
   940             == plugin->PluginType() )
       
   941             {
       
   942             plugin->RemoveSettingsL( aServiceId );
       
   943             }
       
   944 
       
   945         CleanupStack::PopAndDestroy( plugin );
       
   946         }
       
   947 
       
   948     CleanupStack::PopAndDestroy( &implInfoArray );
       
   949     REComSession::FinalClose();
       
   950 
       
   951     CSCSETUIDEBUG(
       
   952         "CCSCSettingsUiMainContainer::LaunchCleanupPluginL - end" );
       
   953     }
       
   954  
       
   955 // ---------------------------------------------------------------------------
       
   956 // CCSCSettingsUiMainContainer::ResetAndDestroy
       
   957 // ---------------------------------------------------------------------------
       
   958 //
       
   959 void CCSCSettingsUiMainContainer::ResetAndDestroy( TAny* aArray )
       
   960      {
       
   961      if ( aArray )
       
   962          {
       
   963          RImplInfoPtrArray* array = 
       
   964              reinterpret_cast<RImplInfoPtrArray*>( aArray );
       
   965          array->ResetAndDestroy();
       
   966          }
       
   967      }
       
   968 
       
   969 // End of file.
       
   970