mmsharing/livecommsui/lcui/tsrc/dummymusengineplugin/src/svptimer.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 31 Aug 2010 15:12:07 +0300
branchRCL_3
changeset 22 73a1feb507fb
permissions -rw-r--r--
Revision: 201032 Kit: 201035

/*
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Timer service for SVP     
*
*/


#include "svptimer.h"
#include "svptimerobserver.h"


const TInt KMicroSecondsCoefficient = 1000;


// ---------------------------------------------------------------------------
// CSVPTimer::CSVPTimer
// ---------------------------------------------------------------------------
//
CSVPTimer::CSVPTimer( MSVPTimerObserver& aObserver, TInt aTimerId ): 
    CTimer( EPriorityHigh ),
    iObserver( aObserver ),
    iId( aTimerId )
    {
    CActiveScheduler::Add( this );
    }

// ---------------------------------------------------------------------------
// CSVPTimer::CSVPTimer
// ---------------------------------------------------------------------------
//
void CSVPTimer::ConstructL()
    {
    CTimer::ConstructL();
    }

// ---------------------------------------------------------------------------
// CSVPTimer::CSVPTimer
// ---------------------------------------------------------------------------
//
CSVPTimer* CSVPTimer::NewL( MSVPTimerObserver& aObserver,
                            TInt aTimerId )
    {
    CSVPTimer* self = new (ELeave) CSVPTimer( aObserver, aTimerId );
    
    CleanupStack::PushL( self );
    self->ConstructL();
    CleanupStack::Pop( self );

    return self;
    }

// ---------------------------------------------------------------------------
// CSVPTimer::~CSVPTimer
// ---------------------------------------------------------------------------
//  
CSVPTimer::~CSVPTimer()
    {
    Cancel();
    }

// ---------------------------------------------------------------------------
// CSVPTimer::RunL
// ---------------------------------------------------------------------------
//  
void CSVPTimer::RunL()
    {
    iObserver.TimedOut( iId );
    }

// ---------------------------------------------------------------------------
// CSVPTimer::SetTime
// ---------------------------------------------------------------------------
//  
void CSVPTimer::SetTime( TInt aMilliSeconds )
    {    
    // Milliseconds to microseconds conversion
    const TTimeIntervalMicroSeconds32 time(
        KMicroSecondsCoefficient * aMilliSeconds );
    
    CTimer::After( time ); // NB, CTimer::After calls SetActive
    }

// ---------------------------------------------------------------------------
// CSVPTimer::Stop
// ---------------------------------------------------------------------------
//  
void CSVPTimer::Stop()
    {
    Cancel(); 
    }

// ---------------------------------------------------------------------------
// CSVPTimer::Id
// ---------------------------------------------------------------------------
//  
TInt CSVPTimer::Id() const
    {
    return iId;
    }

//  End of File