voiceui/vcommand/src/vcsettingslist.cpp
branchRCL_3
changeset 19 e36f3802f733
parent 0 bf1d17376201
equal deleted inserted replaced
18:cad71a31b7fc 19:e36f3802f733
       
     1 /*
       
     2 * Copyright (c) 2006-2008 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:  Settings list class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <featmgr.h>
       
    21 
       
    22 #include <vcommand.rsg>
       
    23 #include "vcsettingslist.h"
       
    24 #include "vcsettingsengine.h"
       
    25 #include "vcommand.hrh"
       
    26 #include "vcappui.h"
       
    27 #include "vcommandconstants.h"
       
    28 
       
    29 #include <vcommanddomaincrkeys.h>
       
    30 #include <srsfdomaincrkeys.h>
       
    31 #include <centralrepository.h>
       
    32 #include <StringLoader.h>
       
    33 #include <AknQueryDialog.h>
       
    34 #include <aknnotewrappers.h>
       
    35 
       
    36 
       
    37 
       
    38 // ========================= MEMBER FUNCTIONS ================================
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // CVCSettingsList::CVCSettingsList
       
    42 // C++ constructor
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 CVCSettingsList::CVCSettingsList()
       
    46     {
       
    47     }
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // CVCSettingsList::ConstructL
       
    51 // Symbian OS 2nd phase constructor
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 void CVCSettingsList::ConstructL()
       
    55     {
       
    56     LoadSettingsL();
       
    57     ConstructFromResourceL( R_VC_SETTING_ITEM_LIST );
       
    58     }
       
    59 
       
    60 
       
    61 // ----------------------------------------------------------------------------
       
    62 // CVCSettingsList::~CVCSettingsList
       
    63 // ----------------------------------------------------------------------------
       
    64 //
       
    65 CVCSettingsList::~CVCSettingsList()
       
    66     {
       
    67     }
       
    68 
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // CVCSettingsList::CreateSettingItemL
       
    72 // From CAknSettingItemList Handles creating setting items
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 CAknSettingItem* CVCSettingsList::CreateSettingItemL( TInt aIdentifier )
       
    76     {
       
    77     CAknSettingItem* settingItem = NULL;
       
    78 
       
    79     switch ( aIdentifier )
       
    80         {
       
    81         case EVCSynthesizerItem:
       
    82             {
       
    83             settingItem = new ( ELeave ) CAknBinaryPopupSettingItem( aIdentifier, iSynthesizer );
       
    84             break;
       
    85             }
       
    86     
       
    87         case EVCVolumeItem:
       
    88             {
       
    89             settingItem = new ( ELeave ) CAknVolumeSettingItem( aIdentifier, iVolumeValue );
       
    90             break;
       
    91             }
       
    92  
       
    93         case EVCRejectionItem: 
       
    94             {
       
    95             settingItem = new ( ELeave ) CAknSliderSettingItem( aIdentifier, iRejectionValue );
       
    96             break;
       
    97             } 
       
    98             
       
    99         case EVCVerificationItem:
       
   100             {
       
   101             settingItem = new ( ELeave ) CAknEnumeratedTextPopupSettingItem( aIdentifier, iVerification );
       
   102             break;
       
   103             }
       
   104     
       
   105           case EVCResetItem:
       
   106             {
       
   107             settingItem = new ( ELeave ) CAknBigSettingItemBase( aIdentifier );
       
   108             break;
       
   109             }
       
   110         
       
   111         default:
       
   112             {
       
   113             break;
       
   114             }
       
   115         }
       
   116 
       
   117     return settingItem;
       
   118     }
       
   119 
       
   120  
       
   121 // ---------------------------------------------------------------------------
       
   122 // CVCSettingsList::LoadSettingsL
       
   123 // ---------------------------------------------------------------------------
       
   124 //
       
   125 void CVCSettingsList::LoadSettingsL()
       
   126     {
       
   127     CRepository* client = CRepository::NewLC( KCRUidVCommandSettings );
       
   128     iSynthesizer = ETrue;
       
   129     iVolumeValue = KSettingsVolume;
       
   130     iRejectionValue = KSettingsRejection;
       
   131     iVerification = KSettingsVerification;
       
   132 
       
   133     User::LeaveIfError( client->Get( KVCSynthesizer, iSynthesizer ) );
       
   134     User::LeaveIfError( client->Get( KVCVerification, iVerification ) );
       
   135     CleanupStack::PopAndDestroy( client ); // client
       
   136     
       
   137     client = CRepository::NewLC( KCRUidSRSFSettings );
       
   138     User::LeaveIfError( client->Get( KSRSFPlaybackVolume, iVolumeValue ) );
       
   139     User::LeaveIfError( client->Get( KSRSFRejection, iRejectionValue ) );
       
   140     CleanupStack::PopAndDestroy( client );    // client
       
   141     }
       
   142 
       
   143 
       
   144 // ---------------------------------------------------------------------------
       
   145 // CVCSettingsList::SaveSettingsL
       
   146 // Apply settings to CCcorController.
       
   147 // ---------------------------------------------------------------------------
       
   148 //
       
   149 void CVCSettingsList::SaveSettingsL()
       
   150     {
       
   151     StoreSettingsL();
       
   152 
       
   153     CRepository* client = CRepository::NewLC( KCRUidVCommandSettings );
       
   154     User::LeaveIfError( client->Set( KVCSynthesizer, iSynthesizer ) );
       
   155     User::LeaveIfError( client->Set( KVCVerification, iVerification ) );
       
   156     CleanupStack::PopAndDestroy( client );
       
   157     
       
   158     client = CRepository::NewLC( KCRUidSRSFSettings );
       
   159     User::LeaveIfError( client->Set( KSRSFPlaybackVolume, iVolumeValue ) );
       
   160     User::LeaveIfError( client->Set( KSRSFRejection, iRejectionValue ) );
       
   161     CleanupStack::PopAndDestroy( client );
       
   162     }
       
   163 
       
   164 
       
   165 // ---------------------------------------------------------------------------
       
   166 // CVCSettingsList::EditItemL
       
   167 // Launch the setting page for the current item by calling
       
   168 // EditItemL on it.
       
   169 // ---------------------------------------------------------------------------
       
   170 //
       
   171 void CVCSettingsList::EditItemL( TInt aIndex, TBool aCalledFromMenu )
       
   172     {
       
   173     CAknSettingItemArray* itemArray = SettingItemArray();
       
   174     TInt itemIndex = itemArray->ItemIndexFromVisibleIndex( aIndex );
       
   175     CAknSettingItem* settingItem = itemArray->At( itemIndex );
       
   176     TInt itemIdentifier = settingItem->Identifier();
       
   177     
       
   178     switch( itemIdentifier )
       
   179         {
       
   180         case EVCSynthesizerItem:
       
   181             {
       
   182             CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu );
       
   183             StoreSettingsL();
       
   184             
       
   185             if( iSynthesizer == ESynthesizerOff )
       
   186                 {
       
   187                 // Disable voice verification
       
   188                 if( iVerification == EVoice )
       
   189                     {                    
       
   190                     itemIndex = itemArray->ItemIndexFromVisibleIndex( EVCVerificationItem );
       
   191                     settingItem = itemArray->At( itemIndex );
       
   192                     // Change the setting
       
   193                     iVerification = EAutomatic;
       
   194                     settingItem->LoadL();
       
   195                     // Update the view
       
   196                     HandleChangeInItemArrayOrVisibilityL();
       
   197                     
       
   198                     // Display a note
       
   199                     VoiceVerificationDisabledNoteL();
       
   200                     }
       
   201                 }
       
   202             
       
   203             break;
       
   204             }
       
   205             
       
   206         case EVCVolumeItem:
       
   207         case EVCRejectionItem:
       
   208             {
       
   209             // ETrue for always opening the settings view 
       
   210             CAknSettingItemList::EditItemL( aIndex, ETrue );
       
   211             break;            
       
   212             }
       
   213             
       
   214         case EVCVerificationItem:
       
   215             {
       
   216             // ETrue for always opening the settings view 
       
   217             CAknSettingItemList::EditItemL( aIndex, ETrue );
       
   218             StoreSettingsL();
       
   219             
       
   220             if( iVerification == EVoice )
       
   221                 {
       
   222                 // Enable synthesizer
       
   223                 if( iSynthesizer == ESynthesizerOff )
       
   224                     {                    
       
   225                     // Binary setting item, so we can just choose to the other one
       
   226                     EditItemL( EVCSynthesizerItem, EFalse );
       
   227                     
       
   228                     // Update the view
       
   229                     HandleChangeInItemArrayOrVisibilityL();
       
   230                     
       
   231                     // Display a note
       
   232                     SynthesizerEnabledNoteL();
       
   233                     }
       
   234                 }
       
   235             
       
   236             break;            
       
   237             }
       
   238         
       
   239         default:
       
   240             {
       
   241             break;
       
   242             }
       
   243         }
       
   244 
       
   245     SaveSettingsL();
       
   246     }
       
   247 
       
   248 // ---------------------------------------------------------------------------
       
   249 // CVCSettingsList::SizeChanged
       
   250 // Set the size and position of component controls.
       
   251 // ---------------------------------------------------------------------------
       
   252 //
       
   253 void CVCSettingsList::SizeChanged()
       
   254     {
       
   255     CAknSettingItemList::SizeChanged();
       
   256 
       
   257     CEikListBox* lb = ListBox();
       
   258     if( lb )
       
   259         {
       
   260         lb->SetRect( Rect() );  // Set container's rect to listbox
       
   261         }
       
   262     }
       
   263     
       
   264 // ----------------------------------------------------------------------------
       
   265 // CVCSettingsList::CommandTooShortNoteL
       
   266 // ----------------------------------------------------------------------------
       
   267 //
       
   268 void CVCSettingsList::SynthesizerEnabledNoteL()
       
   269     {
       
   270     HBufC* text = StringLoader::LoadLC( R_QTN_VC_INFO_NOTE_SYNTHESIZER_ON );
       
   271     CAknInformationNote* note = new( ELeave ) CAknInformationNote( ETrue );
       
   272     note->ExecuteLD( *text );
       
   273     CleanupStack::PopAndDestroy( text );
       
   274     }
       
   275     
       
   276 // ----------------------------------------------------------------------------
       
   277 // CVCSettingsList::VoiceVerificationDisabledNoteL
       
   278 // ----------------------------------------------------------------------------
       
   279 //
       
   280 void CVCSettingsList::VoiceVerificationDisabledNoteL()
       
   281     {
       
   282     HBufC* text = StringLoader::LoadLC( R_QTN_VC_INFO_NOTE_VOICE_VERIFICATION_OFF );
       
   283     CAknInformationNote* note = new( ELeave ) CAknInformationNote( ETrue );
       
   284     note->ExecuteLD( *text );
       
   285     CleanupStack::PopAndDestroy( text );
       
   286     }
       
   287     
       
   288 // End of File