emailservices/emailstore/base_plugin/inc/nestedao.h
changeset 59 16ed8d08d0b1
parent 54 997a02608b3a
child 65 478bc57ad291
equal deleted inserted replaced
54:997a02608b3a 59:16ed8d08d0b1
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Class used to implement nested active object used to handle 
       
    15 * deletion of large number of messages by breaking them into smaller chunks
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef __NESTED_AO_H__
       
    20 #define __NESTED_AO_H__
       
    21 
       
    22 //  Include Files
       
    23 
       
    24 
       
    25 #include <e32base.h>
       
    26 
       
    27 
       
    28 class MDeletionHandler
       
    29     {
       
    30 public:
       
    31     enum TState
       
    32         {
       
    33         EInProgress,
       
    34         EFree
       
    35         };
       
    36     //Deletes messages from aStartIndex KSizeOfChunk at a time
       
    37     virtual TBool DeleteMessagesInChunksL( TInt aStartIndex ) = 0;
       
    38     };
       
    39 //Time interval between issuing 2 requests to delete messages
       
    40 const TInt KWaitIntervalInMicroSecs=500;
       
    41 //Maximum number of messages deleted in one go
       
    42 const TInt KSizeOfChunk=10;
       
    43 
       
    44 NONSHARABLE_CLASS ( CNestedAO ) : public CTimer
       
    45     {
       
    46     public:
       
    47         
       
    48         static CNestedAO* NewL( MDeletionHandler& aDeletionHandler );
       
    49         virtual ~CNestedAO();
       
    50         // --------------------------------------------------------------------------
       
    51         // CNestedAO::DeleteMessagesAsync
       
    52         // Used to delete messages asynchronously 
       
    53         // Deleting a small number of messages at a time
       
    54         // ------------
       
    55         void DeleteMessagesAsync();
       
    56         // --------------------------------------------------------------------------
       
    57         // CNestedAO::Rc
       
    58         // Used to return the iStatus return value
       
    59         // ------------        
       
    60         TInt Rc() { return iRc; }
       
    61         
       
    62     private:
       
    63         CNestedAO( MDeletionHandler& aDeletionHandler );
       
    64         void ConstructL();
       
    65         
       
    66         // inherited from CActive
       
    67         virtual void RunL();
       
    68         virtual void DoCancel();
       
    69         // --------------------------------------------------------------------------
       
    70         // CNestedAO::Stop
       
    71         // Stops the scheduler from running
       
    72         // Called after all messages are processed
       
    73         // or in error condition
       
    74         // ------------           
       
    75         void Stop();
       
    76         
       
    77     private:
       
    78         CActiveSchedulerWait* iNestedWait;
       
    79         MDeletionHandler& iDeletionHandler;
       
    80         TInt iDeletionIndex;
       
    81         TInt iRc;
       
    82     };
       
    83 
       
    84 
       
    85 #endif  //__NESTED_AO_H__