convergedcallengine/csplugin/src/csptimer.cpp
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:15:03 +0100
branchRCL_3
changeset 20 987c9837762f
parent 0 ff3b6d0fd310
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201033 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
*
*/

#include "csptimer.h"
#include "mcsptimerobserver.h"
#include "csppanic.pan"

// ---------------------------------------------------------------------------
// Static constructor
// ---------------------------------------------------------------------------
//
CSPTimer* CSPTimer::NewL()
    {
    CSPTimer* self = CSPTimer::NewLC();
    CleanupStack::Pop( self );
    return self;
    }

// ---------------------------------------------------------------------------
// Static constructor
// ---------------------------------------------------------------------------
//
CSPTimer* CSPTimer::NewLC()
    {
    CSPTimer* self = new( ELeave ) CSPTimer;
    CleanupStack::PushL( self );
    self->ConstructL();
    return self;
    }

// ---------------------------------------------------------------------------
// Destructor
// ---------------------------------------------------------------------------
//
CSPTimer::~CSPTimer()
    {
    Cancel(); 
    }

// ---------------------------------------------------------------------------
// Starts notify request
// ---------------------------------------------------------------------------
//
void CSPTimer::NotifyAfter( TInt aTimeout, 
        MCSPTimerObserver& aTimerObserver )
    {
    __ASSERT_ALWAYS( !IsNotifyOngoing(), Panic( ECSPPanicTimerAlreadyActive ) );
    After( aTimeout );
    iObserver = &aTimerObserver;
    }

// ---------------------------------------------------------------------------
// Cancels the outstancing request.
// ---------------------------------------------------------------------------
//
void CSPTimer::CancelNotify()
    {
    Cancel();
    }

// ---------------------------------------------------------------------------
// Determines if there is active request outstanding.
// ---------------------------------------------------------------------------
//
TBool CSPTimer::IsNotifyOngoing()
    {
    return IsActive();
    }

// ---------------------------------------------------------------------------
// From class CActive
// Notifies the observer about request.
// ---------------------------------------------------------------------------
//
void CSPTimer::RunL()
    {
    if( iObserver ) 
        {
        iObserver->TimerEvent();
        }
    }
    
// ---------------------------------------------------------------------------
// Constructor
// ---------------------------------------------------------------------------
//
CSPTimer::CSPTimer() : 
    CTimer( CActive::EPriorityStandard )
    {
    CActiveScheduler::Add( this );
    }

// ---------------------------------------------------------------------------
// Second phase constructor
// ---------------------------------------------------------------------------
//
void CSPTimer::ConstructL()
    {
    CTimer::ConstructL();
    }

// End of File