emailservices/emailstore/base_plugin/inc/baseplugindelayedops.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 11 May 2010 15:57:15 +0300
branchRCL_3
changeset 16 b5fbb9b25d57
parent 8 e1b6206813b4
child 24 d189ee25cf9d
permissions -rw-r--r--
Revision: 201017 Kit: 201019

/*
* 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: Support for executing asynchronously certain plugin
* operations.
*/


#ifndef __BASEPLUGINDELAYEDOPS_H__
#define __BASEPLUGINDELAYEDOPS_H__


#include <e32base.h>
#include "cfsmailcommon.h"
#include "baseplugin.h"
#include "debuglogmacros.h"


class CBasePlugin;
class CDelayedOp;


/**
 * The interface to the delayed operations manager implementation. Plugins
 * must talk to the manager only through this interface.
 */
class MDelayedOpsManager
    {

public:

    /**
     * 
     */
    virtual ~MDelayedOpsManager() {};
    
    /**
     * @param aOp ownership is transferred 
     */
    virtual void EnqueueOpL( CDelayedOp* aOp ) = 0;
            
    /**
     * @param aOp the caller must delete the operation
     */
    virtual void DequeueOp( const CDelayedOp& aOp ) = 0;

    /**
     * API for future extensions.
     */
    virtual TInt Extension1(
        TUint aExtensionId, TAny*& a0, TAny* a1 ) = 0;
    
    };



/**
 * The base class for the delayed operations. All of the delayed operations must
 * derive from it.
 */
class CDelayedOp : public CActive
    {

public:

    IMPORT_C virtual ~CDelayedOp();
    
    IMPORT_C void SetContext(
        CBasePlugin& aPlugin,
        MDelayedOpsManager& aManager );

    IMPORT_C void StartOp();

    /**
     * Derived classes must implement their asynchronous processing in this
     * method. The GetPlugin method can only be used from within this method.
     * Returns boolean: ETrue if op is yielding and needs to be called again, or EFalse if op is done.
     */
    virtual TBool ExecuteOpL() = 0;

protected:
    
    IMPORT_C CDelayedOp();
    
    /**
     * Returns the plugin instance associated with this operation. Available
     * only from within the ExecuteOpL method.
     */
    IMPORT_C CBasePlugin& GetPlugin();
    
    
private:
    
    IMPORT_C virtual void RunL();
    IMPORT_C virtual void DoCancel();

private:
    MDelayedOpsManager* iManager;   //not owned
    CBasePlugin* iPlugin;           //not owned
    
    __LOG_DECLARATION
    };

#endif // __BASEPLUGINDELAYEDOPS_H__