dosservices/dosserver/src/dosasyncexecbase.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 02 Feb 2010 00:53:00 +0200
changeset 0 4e1aa6a622a0
permissions -rw-r--r--
Revision: 201003

/*
* Copyright (c) 2002 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: 
*    Implementation of the CDosAsyncExecBase class.
*
*/


#include "dosasyncexecbase.h"

//
// ---------------------------------------------------------
// CDosAsyncExecBase Constructor
// ---------------------------------------------------------
//  

EXPORT_C CDosAsyncExecBase::CDosAsyncExecBase(const RMessagePtr2 aMessage) : CActive(EPriorityStandard), iMessage(aMessage)
{
	CActiveScheduler::Add(this);
}

//
// ---------------------------------------------------------
// CDosAsyncExecBase Desctructor
// ---------------------------------------------------------
//  

EXPORT_C  CDosAsyncExecBase::~CDosAsyncExecBase()
{
	Cancel();
}

//
// ---------------------------------------------------------
// CDosAsyncExecBase::RunL
//
// Inherited from CActive.
// ---------------------------------------------------------
//  

EXPORT_C void CDosAsyncExecBase::RunL()
{
	TBool autoDestroy = ETrue;
	TBool complete = ETrue;

	BeforeComplete(complete);
	if(complete)
	{
		iMessage.Complete(iStatus.Int());
		AfterComplete(autoDestroy);
		if(autoDestroy)
		{
			delete this;
		}
	}
}

//
// ---------------------------------------------------------
// CDosAsyncExecBase::BeforeComplete
//
// Default empty implementation. A derived class can override
// this.
// ---------------------------------------------------------
//  

EXPORT_C void CDosAsyncExecBase::BeforeComplete(TBool& /*aComplete*/)
{
}

//
// ---------------------------------------------------------
// CDosAsyncExecBase::AfterComplete
//
// Default empty implementation. A derived class can override
// this.
// ---------------------------------------------------------
//  

EXPORT_C void CDosAsyncExecBase::AfterComplete(TBool& /*aAutoDestroy*/)
{
}

//
// ---------------------------------------------------------
// CDosAsyncExecBase::DoCancel
//
// Inherited from CActive.
// ---------------------------------------------------------
//  

EXPORT_C void CDosAsyncExecBase::DoCancel()
{
	TRequestStatus* status = &iStatus;
	User::RequestComplete(status,KErrCancel);
}