voiceui/vcommand/src/vcsettingsengine.cpp
branchRCL_3
changeset 19 e36f3802f733
parent 0 bf1d17376201
equal deleted inserted replaced
18:cad71a31b7fc 19:e36f3802f733
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Implementation of CVCSettingsEngine
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <StringLoader.h>
       
    21 #include <aknsoundsystem.h>
       
    22 #include <aknappui.h>
       
    23 
       
    24 #include <vcommand.rsg>
       
    25 #include "vcsettingsengine.h"
       
    26 #include "vcommandconstants.h"
       
    27 
       
    28 
       
    29 // ============================ MEMBER FUNCTIONS ===============================
       
    30 
       
    31 // -----------------------------------------------------------------------------
       
    32 // CVCSettingsEngine::CVCSettingsEngine
       
    33 // C++ default constructor can NOT contain any code, that
       
    34 // might leave.
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 CVCSettingsEngine::CVCSettingsEngine()
       
    38     {
       
    39     }
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CVCSettingsEngine::ConstructL
       
    43 // Symbian 2nd phase constructor can leave.
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 void CVCSettingsEngine::ConstructL()
       
    47     {
       
    48 #ifdef _DEBUG
       
    49     RDebug::Print(_L("[Voice commands] -- CVCSettingsEngine::ConstructL"));
       
    50 #endif
       
    51 
       
    52     iVasDbManager = CNssVASDBMgr::NewL();
       
    53     iVasDbManager->InitializeL();
       
    54     }
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CVCSettingsEngine::NewL
       
    58 // Two-phased constructor.
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 CVCSettingsEngine* CVCSettingsEngine::NewL()
       
    62     {
       
    63     CVCSettingsEngine* self = new( ELeave ) CVCSettingsEngine;
       
    64     
       
    65     CleanupStack::PushL( self );
       
    66     self->ConstructL();
       
    67     CleanupStack::Pop( self );
       
    68 
       
    69     return self;
       
    70     }
       
    71 
       
    72     
       
    73 // Destructor
       
    74 CVCSettingsEngine::~CVCSettingsEngine()
       
    75     {
       
    76     delete iVasDbManager;
       
    77 	iContextManager = NULL;
       
    78     }
       
    79 
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CVCSettingsEngine::ResetAdaptationL
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 void CVCSettingsEngine::ResetAdaptationL()
       
    86     {
       
    87 #ifdef _DEBUG
       
    88     RDebug::Print(_L("[Voice commands] -- CVCSettingsEngine::ResetAdaptationL"));
       
    89 #endif
       
    90 
       
    91     iVasDbManager->ResetFactoryModelsL( this );
       
    92 	iShedulerWait.Start();
       
    93     }
       
    94 
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CVCSettingsEngine::HandleResetComplete
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 void CVCSettingsEngine::HandleResetComplete( TInt aErrorCode )
       
   101     {
       
   102 #ifdef _DEBUG
       
   103     RDebug::Print(_L("[Voice commands] -- CVCSettingsEngine::HandleResetComplete"));
       
   104 #endif
       
   105 
       
   106     if( aErrorCode != KErrNone ) 
       
   107         {
       
   108         return HandleResetFailed();
       
   109         }
       
   110 
       
   111     TRAP_IGNORE( DoHandleResetCompleteL());
       
   112 
       
   113 	if ( iShedulerWait.IsStarted() )
       
   114 		{
       
   115 		iShedulerWait.AsyncStop();
       
   116 		}
       
   117 	}
       
   118 
       
   119  
       
   120 // -----------------------------------------------------------------------------
       
   121 // CVCSettingsEngine::HandleResetComplete
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 void CVCSettingsEngine::DoHandleResetCompleteL()
       
   125     {
       
   126     HBufC* text = StringLoader::LoadLC( R_QTN_VC_CONF_NOTE_RESET );
       
   127     
       
   128     CAknConfirmationNote* dlg = new (ELeave) CAknConfirmationNote( ETrue );
       
   129     dlg->ExecuteLD( *text );
       
   130     
       
   131     CleanupStack::PopAndDestroy( text );  // text
       
   132     }
       
   133 
       
   134 // -----------------------------------------------------------------------------
       
   135 // CVCSettingsEngine::HandleResetFailed
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 void CVCSettingsEngine::HandleResetFailed()
       
   139     {
       
   140 #ifdef _DEBUG
       
   141     RDebug::Print(_L("[Voice commands] -- CVCSettingsEngine::HandleResetFailed"));
       
   142 #endif
       
   143 
       
   144     TRAP_IGNORE( DisplayErrorNoteL());
       
   145 
       
   146 	if ( iShedulerWait.IsStarted() )
       
   147 		{
       
   148 		iShedulerWait.AsyncStop();
       
   149 		}
       
   150     }
       
   151 
       
   152 
       
   153 // -----------------------------------------------------------------------------
       
   154 // CVCSettingsEngine::DisplayErrorNoteL
       
   155 // -----------------------------------------------------------------------------
       
   156 //
       
   157 void CVCSettingsEngine::DisplayErrorNoteL()
       
   158     {
       
   159 #ifdef _DEBUG
       
   160     RDebug::Print(_L("[Voice commands] -- CVCSettingsEngine::DisplayErrorNoteL"));
       
   161 #endif
       
   162 
       
   163     HBufC* text = StringLoader::LoadLC( R_TEXT_VOICE_SYSTEM_ERROR );
       
   164     CAknErrorNote* dlg = new (ELeave) CAknErrorNote( ETrue );
       
   165     dlg->ExecuteLD( *text );
       
   166     PlaySound( EAvkonSIDNameDiallerErrorTone );
       
   167     CleanupStack::PopAndDestroy( text ); // text
       
   168     }
       
   169 
       
   170 
       
   171 // ---------------------------------------------------------
       
   172 // CVCSettingsEngine::PlaySound
       
   173 // ---------------------------------------------------------
       
   174 //
       
   175 void CVCSettingsEngine::PlaySound(TAvkonSystemSID aSound) const
       
   176     {
       
   177     if (GetSoundSystem())
       
   178         {
       
   179         GetSoundSystem()->PlaySound(aSound);
       
   180         }
       
   181     }
       
   182 
       
   183 
       
   184 // ---------------------------------------------------------
       
   185 // CVCSettingsEngine::SoundSystem
       
   186 // ---------------------------------------------------------
       
   187 //
       
   188 CAknKeySoundSystem* CVCSettingsEngine::GetSoundSystem() const
       
   189     {
       
   190 	if (iAvkonAppUiBase)
       
   191 		{
       
   192 		return iAvkonAppUiBase->KeySounds();	// Static access
       
   193 		}
       
   194 
       
   195 	return NULL;
       
   196     }
       
   197 
       
   198 //  End of File