voiceui/voiceuivoicerecognition/src/vuicstate.cpp
branchRCL_3
changeset 19 e36f3802f733
parent 0 bf1d17376201
equal deleted inserted replaced
18:cad71a31b7fc 19:e36f3802f733
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <apgtask.h>
       
    21 #include <coemain.h>
       
    22 
       
    23 #include "vuicstate.h"
       
    24 
       
    25 #include "rubydebug.h"
       
    26 
       
    27 // CONSTANTS
       
    28 const TUid KVoiceUiUid = { 0x101F8543 };
       
    29     
       
    30 // Destructor       
       
    31 CState::~CState()
       
    32     {
       
    33     RUBY_DEBUG0( "CState::~CState START" );
       
    34     
       
    35     StopTimer();
       
    36     
       
    37     RUBY_DEBUG0( "CState::~CState EXIT" );
       
    38     }
       
    39 
       
    40 // ---------------------------------------------------------
       
    41 // CState::CState
       
    42 // ---------------------------------------------------------
       
    43 //              
       
    44 CState::CState(  CDataStorage& aDataStorage, CUiModel& aUiModel )
       
    45  : iDataStorage( &aDataStorage ), iUiModel( &aUiModel )    
       
    46     {
       
    47     }
       
    48     
       
    49 // ---------------------------------------------------------
       
    50 // CState::ConstructL
       
    51 // ---------------------------------------------------------
       
    52 //           
       
    53 void CState::ConstructL()
       
    54     {
       
    55     RUBY_DEBUG_BLOCK( "CState::ConstructL" );
       
    56     }    
       
    57 
       
    58 // ---------------------------------------------------------
       
    59 // CState::DataStorage
       
    60 // ---------------------------------------------------------
       
    61 //     
       
    62 CDataStorage& CState::DataStorage() const
       
    63     {
       
    64     return *iDataStorage;
       
    65     }
       
    66 
       
    67 // ---------------------------------------------------------
       
    68 // CState::UiModel
       
    69 // ---------------------------------------------------------
       
    70 //       
       
    71 CUiModel& CState::UiModel() const
       
    72     {
       
    73     return *iUiModel;
       
    74     }
       
    75     
       
    76 // ---------------------------------------------------------
       
    77 // CState::StartTimerL
       
    78 // Starts timer
       
    79 // ---------------------------------------------------------
       
    80 //
       
    81 void CState::StartTimerL( CState& aEventHandler, TInt aDelay, TInt aInterval )
       
    82     {
       
    83     RUBY_DEBUG0( "CState::StartTimerL START" );
       
    84 
       
    85     StopTimer();
       
    86 
       
    87     iTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
    88     TTimeIntervalMicroSeconds32 delay( aDelay );
       
    89     TTimeIntervalMicroSeconds32 interval( aInterval );
       
    90     iTimer->Start( delay, interval, TCallBack( OnTimedEvent, &aEventHandler ) );
       
    91     
       
    92     RUBY_DEBUG0( "CState::StartTimerL EXIT" );
       
    93     }
       
    94     
       
    95 // ---------------------------------------------------------
       
    96 // CState::StopTimer
       
    97 // Stops timer
       
    98 // ---------------------------------------------------------
       
    99 //
       
   100 void CState::StopTimer()
       
   101     {
       
   102     RUBY_DEBUG0( "CState::StopTimer START" );
       
   103 
       
   104     if ( iTimer )
       
   105         {
       
   106         if ( iTimer->IsActive() )
       
   107             {
       
   108             iTimer->Cancel();
       
   109             }
       
   110         delete iTimer;
       
   111         iTimer = NULL;
       
   112         }
       
   113         
       
   114     RUBY_DEBUG0( "CState::StopTimer EXIT" );
       
   115     }
       
   116     
       
   117 // ---------------------------------------------------------
       
   118 // CState::OnTimedEvent
       
   119 // ---------------------------------------------------------
       
   120 //
       
   121 TInt CState::OnTimedEvent( TAny* aObject )
       
   122    {
       
   123    TRAP_IGNORE( ( (CState*) aObject )->DoTimedEventL() );
       
   124    return KErrNone;
       
   125    }
       
   126    
       
   127 // ---------------------------------------------------------
       
   128 // CState::DoTimedEventL
       
   129 // ---------------------------------------------------------
       
   130 //
       
   131 void CState::DoTimedEventL()
       
   132    {   
       
   133    }
       
   134 
       
   135 // ---------------------------------------------------------
       
   136 // CState::BringToForeground
       
   137 // ---------------------------------------------------------
       
   138 //   
       
   139 void CState::BringToForeground()
       
   140     {
       
   141     TApaTaskList apaTaskList( CCoeEnv::Static()->WsSession() );
       
   142     TApaTask apaTask = apaTaskList.FindApp( KVoiceUiUid );
       
   143     
       
   144     if ( apaTask.Exists() )
       
   145         {
       
   146         apaTask.BringToForeground();
       
   147         }
       
   148     }
       
   149     
       
   150 // End of File
       
   151