tsrc/consoleplayer/common/timercallback.cpp
changeset 35 b0f0be18af85
equal deleted inserted replaced
32:106971a9964d 35:b0f0be18af85
       
     1 /*
       
     2  * Copyright (c) 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:
       
    15  * Source code for handling the timer.
       
    16  * 
       
    17  */
       
    18 
       
    19 #include "timercallback.h"
       
    20 
       
    21 CTimerCallback::CTimerCallback( ITimerCallbackClient& aClient ) : 
       
    22     CActive( EPriorityStandard ),
       
    23     iClient( aClient )
       
    24     {    
       
    25     CActiveScheduler::Add(this);
       
    26     }
       
    27 
       
    28 CTimerCallback::~CTimerCallback()
       
    29     { 
       
    30     Cancel();
       
    31     }
       
    32 
       
    33 void CTimerCallback::Start(TTimeIntervalMicroSeconds32 aInterval)
       
    34     {
       
    35     iInterval = aInterval;
       
    36     
       
    37     if( iTimer.CreateLocal() == KErrNone )
       
    38         {
       
    39         SetActive();
       
    40         iTimer.After( iStatus, 0 );
       
    41         }
       
    42     }
       
    43 
       
    44 // inherited from CActive
       
    45 
       
    46 void CTimerCallback::RunL()
       
    47     {
       
    48     SetActive();
       
    49     iTimer.After( iStatus, iInterval );
       
    50 
       
    51     iClient.TimerCallback();        
       
    52     }
       
    53 
       
    54 void CTimerCallback::DoCancel()
       
    55     {
       
    56     iTimer.Cancel();
       
    57     }
       
    58     
       
    59