radioapp/radioenginewrapper/tsrc/src/t_schedulerstartandstoptimer.cpp
branchRCL_3
changeset 20 93c594350b9a
parent 19 cce62ebc198e
equal deleted inserted replaced
19:cce62ebc198e 20:93c594350b9a
     1 /*
       
     2 * Copyright (c) 2009 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 a timer interface.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "t_schedulerstartandstoptimer.h"
       
    21 #include "trace.h"
       
    22 
       
    23 
       
    24 // ======== LOCAL FUNCTIONS ========
       
    25 
       
    26 
       
    27 // ======== MEMBER FUNCTIONS ========
       
    28 
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CAccSrvResetInactivityTimeTimer::NewL
       
    32 // Two-phased constructor.
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 CSchedulerStopAndStartTimer* CSchedulerStopAndStartTimer::NewL(
       
    36         MSchedulerStartAndStopTimerObserver& aSchedulerStartAndStopTimerObserver )
       
    37     {
       
    38     FUNC_LOG;
       
    39 
       
    40     CSchedulerStopAndStartTimer* self = new ( ELeave ) CSchedulerStopAndStartTimer(
       
    41             aSchedulerStartAndStopTimerObserver );
       
    42     CleanupStack::PushL( self );
       
    43     self->ConstructL();
       
    44     CleanupStack::Pop( self );
       
    45     return self;
       
    46     }
       
    47 
       
    48 
       
    49 // Destructor
       
    50 CSchedulerStopAndStartTimer::~CSchedulerStopAndStartTimer()
       
    51     {
       
    52     FUNC_LOG;
       
    53     Cancel();
       
    54     }
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CSchedulerStopAndStartTimer::StartTimer
       
    58 // .
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 void CSchedulerStopAndStartTimer::StartTimer(
       
    62         TInt aTime,
       
    63         TUint aTimerId  )
       
    64     {
       
    65     FUNC_LOG;
       
    66     INFO_2( "Timer Id: %d, Time: %d", aTimerId, aTime)
       
    67     iTime = aTime;
       
    68     iTimerId = aTimerId;
       
    69 
       
    70     if ( ETimerIdRunMUT == iTimerId )
       
    71         {
       
    72         After( ( TTimeIntervalMicroSeconds32 ) iTime );
       
    73         }
       
    74     else
       
    75         {
       
    76         After( ( TTimeIntervalMicroSeconds32 ) 1 );
       
    77         }
       
    78     CActiveScheduler::Start();
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CSchedulerStopAndStartTimer::RunL
       
    83 // 
       
    84 // (other items were commented in a header).
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 void CSchedulerStopAndStartTimer::RunL()
       
    88     {
       
    89     FUNC_LOG;
       
    90     if ( ETimerIdCreateMUT == iTimerId )
       
    91         {
       
    92         iSchedulerStartAndStopTimerObserver.CreateMUT();
       
    93         iTimerId = ETimerIdRunMUT;
       
    94         After( ( TTimeIntervalMicroSeconds32 ) iTime );        
       
    95         }
       
    96     else if ( ETimerIdDeleteMUT == iTimerId )
       
    97         {
       
    98         iSchedulerStartAndStopTimerObserver.DeleteMUT();
       
    99         CActiveScheduler::Stop();
       
   100         }
       
   101     else
       
   102         {
       
   103         CActiveScheduler::Stop();
       
   104         iSchedulerStartAndStopTimerObserver.Timeout( iTimerId );        
       
   105         }
       
   106     }
       
   107 
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // CSchedulerStopAndStartTimer::RunError
       
   111 // Returns KErrNone
       
   112 // (other items were commented in a header).
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 TInt CSchedulerStopAndStartTimer::RunError( TInt aError )
       
   116     {
       
   117     FUNC_LOG;
       
   118      // Avoid Panic in CActiveScheduler
       
   119     aError = KErrNone;
       
   120     return aError;
       
   121     }
       
   122 
       
   123 
       
   124 // -----------------------------------------------------------------------------
       
   125 // CSchedulerStopAndStartTimer::CSchedulerStopAndStartTimer
       
   126 // C++ default constructor can NOT contain any code, that
       
   127 // might leave.
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 CSchedulerStopAndStartTimer::CSchedulerStopAndStartTimer(
       
   131         MSchedulerStartAndStopTimerObserver& aSchedulerStartAndStopTimerObserver) : 
       
   132     CTimer( CActive::EPriorityStandard ),
       
   133     iSchedulerStartAndStopTimerObserver( aSchedulerStartAndStopTimerObserver )
       
   134     {
       
   135     FUNC_LOG;
       
   136     }
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 // CAccSrvProcessCommandTimer::ConstructL
       
   140 // Symbian 2nd phase constructor can leave.
       
   141 // -----------------------------------------------------------------------------
       
   142 //
       
   143 void CSchedulerStopAndStartTimer::ConstructL()
       
   144     {
       
   145     FUNC_LOG;
       
   146     CTimer::ConstructL();
       
   147     CActiveScheduler* AS = CActiveScheduler::Current();
       
   148     CActiveScheduler::Add( this );
       
   149     }
       
   150 
       
   151 
       
   152 // ======== GLOBAL FUNCTIONS ========
       
   153