diff -r 000000000000 -r a4daefaec16c voipplugins/accountcreationplugin/src/acptimer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/voipplugins/accountcreationplugin/src/acptimer.cpp Mon Jan 18 20:12:36 2010 +0200 @@ -0,0 +1,122 @@ +/* +* Copyright (c) 2009 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: Class for timer handling +* +*/ + + +#include "acptimer.h" +#include "macptimerobserver.h" + +const TInt KPhonebookStartupDelay = 5000000; // 5 seconds + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// +CAcpTimer::CAcpTimer( MAcpTimerObserver& aObserver ) + : CTimer( EPriorityStandard ), iObserver( aObserver ) + { + } + + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// +void CAcpTimer::ConstructL() + { + CActiveScheduler::Add( this ); + CTimer::ConstructL(); + } + + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// +CAcpTimer* CAcpTimer::NewL( MAcpTimerObserver& aObserver ) + { + CAcpTimer* self = new ( ELeave ) CAcpTimer( aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// +CAcpTimer::~CAcpTimer() + { + CTimer::Cancel(); + } + + +// --------------------------------------------------------------------------- +// Start timer. +// --------------------------------------------------------------------------- +// +TInt CAcpTimer::StartTimer( TTimerType aTimerType ) + { + TInt error ( KErrNone ); + + if ( CTimer::IsActive() ) + { + CTimer::Cancel(); + } + + if ( EPhonebookStartupDelayTimer == aTimerType ) + { + CTimer::After( KPhonebookStartupDelay ); + } + else + { + error = KErrArgument; + } + + return error; + } + + +// --------------------------------------------------------------------------- +// Stop timer. +// --------------------------------------------------------------------------- +// +void CAcpTimer::StopTimer() + { + if ( CTimer::IsActive() ) + { + CTimer::Cancel(); + } + } + +// --------------------------------------------------------------------------- +// IsActive +// --------------------------------------------------------------------------- +// +TBool CAcpTimer::IsActive() + { + return CTimer::IsActive(); + } + + +// --------------------------------------------------------------------------- +// CAcpTimer::RunL +// --------------------------------------------------------------------------- +// +void CAcpTimer::RunL() + { + iObserver.TimerExpired(); + }