sl@0: /* sl@0: * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: #include "ActiveCallbackBase.h" sl@0: sl@0: CActiveCallbackBase::CActiveCallbackTimer* CActiveCallbackBase::CActiveCallbackTimer::NewL(CActive& aActive, TInt aPriority) sl@0: { sl@0: CActiveCallbackTimer* self=new (ELeave) CActiveCallbackTimer(aActive, aPriority); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CActiveScheduler::Add(self); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: CActiveCallbackBase::CActiveCallbackTimer::CActiveCallbackTimer(CActive& aActive, TInt aPriority) sl@0: : CTimer(aPriority) sl@0: , iActive(aActive) sl@0: { sl@0: } sl@0: sl@0: void CActiveCallbackBase::CActiveCallbackTimer::RunL() sl@0: { sl@0: if ( iStatus.Int()==KErrNone ) sl@0: { sl@0: // Timer termiated without error sl@0: if ( iActive.IsActive() ) sl@0: { sl@0: iActive.Cancel(); sl@0: } sl@0: } sl@0: } sl@0: sl@0: CActiveCallbackBase* CActiveCallbackBase::NewLC(CDataWrapperBase& aDataWrapperBase, TInt aPriority) sl@0: { sl@0: CActiveCallbackBase* self=new(ELeave) CActiveCallbackBase(aDataWrapperBase, aPriority); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: return self; sl@0: } sl@0: sl@0: CActiveCallbackBase* CActiveCallbackBase::NewL(CDataWrapperBase& aDataWrapperBase, TInt aPriority) sl@0: { sl@0: CActiveCallbackBase* self=CActiveCallbackBase::NewLC(aDataWrapperBase, aPriority); sl@0: CleanupStack::Pop(); sl@0: return self; sl@0: } sl@0: sl@0: CActiveCallbackBase::CActiveCallbackBase(CDataWrapperBase& aDataWrapperBase, TInt aPriority) sl@0: : CActiveCallback(aDataWrapperBase, aPriority) sl@0: , iDataWrapperBase(aDataWrapperBase) sl@0: , iTimer(NULL) sl@0: { sl@0: } sl@0: sl@0: void CActiveCallbackBase::ConstructL() sl@0: { sl@0: CActiveCallback::ConstructL(); sl@0: iTimer=CActiveCallbackTimer::NewL(*this); sl@0: } sl@0: sl@0: CActiveCallbackBase::~CActiveCallbackBase() sl@0: /** sl@0: * Public destructor sl@0: */ sl@0: { sl@0: delete iTimer; sl@0: iTimer=NULL; sl@0: } sl@0: sl@0: void CActiveCallbackBase::Activate(TInt aIndex, TInt aTimeout) sl@0: { sl@0: CActiveCallback::Activate(aIndex); sl@0: if ( aTimeout!=0 ) sl@0: { sl@0: iTimer->After(aTimeout); sl@0: } sl@0: } sl@0: sl@0: void CActiveCallbackBase::KillTimer() sl@0: { sl@0: if ( iTimer->IsActive() ) sl@0: { sl@0: iDataWrapperBase.INFO_PRINTF1(_L("CActiveCallbackBase::KillTimer")); sl@0: iTimer->Cancel(); sl@0: } sl@0: }