serviceproviders/sapi_contacts_vpbk/contactservice/src/syncbehaviour.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 31 Aug 2010 16:06:03 +0300
branchRCL_3
changeset 44 0b68a1b0c15e
parent 5 989d2f495d90
permissions -rw-r--r--
Revision: 201033 Kit: 201035

/*
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "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:  Sync behaviour implemetation for getlist iterator.
*
*/




#include "syncbehaviour.h"

//------------------------------------
// Adds itself to the active scheduler
//------------------------------------
CContactSyncIter::CContactSyncIter():CActive(0)
    {
    CActiveScheduler::Add(this);
    }

//---------------------
// RunL() calls Signal()
//----------------------
void CContactSyncIter::RunL()
    {
    Signal();
    }

void CContactSyncIter::DoCancel()
    {
    	
    }

//------------------------------------
// Stops the scheduler and does cleanup
//------------------------------------
void CContactSyncIter::Signal()
    {
    iWaitScheduler->AsyncStop();    	
    }

//------------------------------------
// Sets the status of the Scheduler 
// and starts it
//------------------------------------
void CContactSyncIter::Wait()
    {
    if(!IsActive()) 
    	{
    	iStatus = KRequestPending;
    	SetActive();
    	}
    iWaitScheduler->Start();
    }

//----------------------------------
// NewL() Method
//----------------------------------
CContactSyncIter* CContactSyncIter::NewL()
    {
    CContactSyncIter* self = new( ELeave ) CContactSyncIter( );
    CleanupStack::PushL( self );
    self->ConstructL();
    CleanupStack::Pop( self );
    return self;

    }

//----------------------------------------------------
// ConstructL method - 
// Installs the active scheduler if not already installed
//----------------------------------------------------
void CContactSyncIter::ConstructL()
{
/*
   iInstalled = 0;
   if(!CActiveScheduler::Current())
   {
   		iNewscheduler = new (ELeave) CActiveScheduler(); 
   		CActiveScheduler::Install(iNewscheduler);
		iInstalled = 1;
   }
*/   
   iWaitScheduler = new (ELeave) CActiveSchedulerWait;
}

CContactSyncIter::~CContactSyncIter()
{
	delete iNewscheduler;
	delete iWaitScheduler;
}