phonebookengines/contactsmodel/cntsrv/src/CActiveLoop.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 09 Jun 2010 09:26:27 +0300
branchRCL_3
changeset 13 a6539d1e8e43
parent 0 e686773b3f54
permissions -rw-r--r--
Revision: 201021 Kit: 2010123

// Copyright (c) 2005-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:
//

#include "CActiveLoop.h"

void CActiveLoop::Register(MActiveLoopCallBack & aCallBack, TBool aUseTimer)
	{
	iCallBack = &aCallBack;
	if (aUseTimer)
		{ //Timer required for Cancel Asynchronous operation use case.
		After(0);
		}
	else
		{
		CActive::SetActive();
		TRequestStatus* status = &iStatus;
		User::RequestComplete(status, KErrNone);
		}
	}

	
	
void CActiveLoop::RunL()
	{
	if (iCallBack->DoStepL())
		{	
  		CActive::SetActive();
  		TRequestStatus* status = &iStatus;
  		User::RequestComplete(status, KErrNone);
		}
	}
	
CActiveLoop* CActiveLoop::NewL()
	{
	CActiveLoop* active = new (ELeave) CActiveLoop();
	CleanupStack::PushL(active);
	active->ConstructL();
	CleanupStack::Pop(active);
	return active;
	}
	
void CActiveLoop::DoCancel() 
	{
	}	

CActiveLoop::CActiveLoop() :CTimer(EPriorityStandard)
	{
	CActiveScheduler::Add(this);
	}

	
CActiveLoop::~CActiveLoop() 
	{
	Cancel();
	}
	
TInt CActiveLoop::RunError(TInt aError)
	{
	iCallBack->DoError(aError);
	return KErrNone;
	}