devencdiskutils/DevEncStarter/inc/DevEncStarterMemoryEntity.h
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2007 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: 
       
    15 *     Class for managing different types of memory on a very abstract level.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef DEVENCSTARTER_MEMORYENTITY_H
       
    21 #define DEVENCSTARTER_MEMORYENTITY_H
       
    22 
       
    23 #include <e32base.h>
       
    24 
       
    25 #include <DevEncConstants.h>
       
    26 #include "DevEncUiMemInfoObserver.h"
       
    27 #include <DevEncDiskStatusObserver.h>
       
    28 
       
    29 class CDevEncSession;
       
    30 class CDevEncUiInfoObserver;
       
    31 
       
    32 class CDevEncStarterMemoryEntity : public CBase,
       
    33                                    public MDiskStatusObserver
       
    34     {
       
    35     public:
       
    36         /**
       
    37          * Constructs the CDevEncStarterMemoryEntity using the NewLC method, popping
       
    38          * the constructed object from the CleanupStack before returning it.
       
    39          *
       
    40          * @return The newly constructed CDevEncStarterMemoryEntity
       
    41          */
       
    42     	static CDevEncStarterMemoryEntity* NewL( TDevEncUiMemoryType aType );
       
    43 
       
    44         /**
       
    45          * Constructs the CDevEncStarterMemoryEntity using the constructor and ConstructL
       
    46          * method, leaving the constructed object on the CleanupStack before returning it.
       
    47          *
       
    48          * @return The newly constructed CDevEncStarterMemoryEntity
       
    49          */
       
    50     	static CDevEncStarterMemoryEntity* NewLC( TDevEncUiMemoryType aType );
       
    51 
       
    52     	/**
       
    53          * Adds an observer to this object's list of observers.
       
    54          * @param aInfoObserver The observer to add
       
    55          * @leave Symbian error code
       
    56          */
       
    57         void AddObserverL( MDevEncUiMemInfoObserver* aInfoObserver );
       
    58 
       
    59         /**
       
    60          * Removes an observer from this object's list of observers.
       
    61          * Any errors are ignored.
       
    62          * @param aInfoObserver The observer to remove
       
    63          */
       
    64         void RemoveObserver( MDevEncUiMemInfoObserver* aInfoObserver );
       
    65 
       
    66         /**
       
    67          * Called periodically. Not intended for use by other classes.
       
    68          * @param aPtr Pointer to an instance of this class.
       
    69          */
       
    70         static TInt ProgressTick( TAny* aPtr );
       
    71 
       
    72         /**
       
    73          * Called periodically. Not intended for use by other classes.
       
    74          * @param aPtr Pointer to an instance of this class.
       
    75          */
       
    76         static TInt PollTick( TAny* aPtr );
       
    77         
       
    78         /**
       
    79         * Destructor.
       
    80         */
       
    81         virtual ~CDevEncStarterMemoryEntity();
       
    82 
       
    83         void Cancel();
       
    84 
       
    85         /**
       
    86          * Gets the state of this memory entity.
       
    87          * @return the current state
       
    88          */
       
    89         TUint State() const;
       
    90         
       
    91         /**
       
    92          * Sets the internal state and calls UpdateMemoryInfo()
       
    93          * @param aState the new state
       
    94          **/
       
    95         virtual void SetState( TUint aState );
       
    96 
       
    97         /**
       
    98          * Sends the current memory state information to all observers.
       
    99          * @return none
       
   100          */
       
   101         virtual void UpdateMemoryInfo();
       
   102         
       
   103         /*
       
   104          * From MDiskStatusObserver
       
   105          */
       
   106         void DiskStatusChangedL( TInt aStatus );
       
   107 
       
   108     private:
       
   109     // functions
       
   110 
       
   111         /**
       
   112          * C++ Constructor
       
   113          **/
       
   114         CDevEncStarterMemoryEntity( TDevEncUiMemoryType aType );
       
   115 
       
   116         /**
       
   117          * Second-phase constructor
       
   118          **/
       
   119         virtual void ConstructL();
       
   120 
       
   121         /**
       
   122          * Starts a timer to periodically update the memory state in the UI
       
   123          * @param aInterval the polling interval
       
   124          **/
       
   125         void StartPolling( TTimeIntervalMicroSeconds32 aInterval );
       
   126 
       
   127         /**
       
   128          * Starts a timer to periodically update the memory state in the UI
       
   129          * @param aInterval the polling interval
       
   130          **/
       
   131         void DoStartPollingL( TTimeIntervalMicroSeconds32 aInterval );
       
   132 
       
   133         /**
       
   134          * Fetches the encryption state and progress. Called periodically.
       
   135          **/
       
   136         virtual void CheckProgress();
       
   137 
       
   138         /**
       
   139          * Performs periodical processing of timeouts. Calls CheckProgress().
       
   140          **/
       
   141         virtual void DoProgressTick();
       
   142 
       
   143         /**
       
   144          * Performs periodical processing of timeouts.
       
   145          * Checks if the encryption status has changed.
       
   146          **/
       
   147         virtual void DoPollTick();
       
   148 
       
   149     // Data
       
   150 
       
   151         /** Owned */
       
   152         CPeriodic* iPeriodic;
       
   153 
       
   154         /** Owned */
       
   155         RArray<MDevEncUiMemInfoObserver*> iObservers;
       
   156 
       
   157         /** Owned */
       
   158         CDevEncSession* iSession;
       
   159         
       
   160         /** Owned */
       
   161         CDiskStatusObserver* iDiskStatusObserver;
       
   162 
       
   163         TUint iState;
       
   164         TUint iPrevState;
       
   165         const TDevEncUiMemoryType iType;
       
   166         TInt iPercentDone;
       
   167         TInt iPrevPercentDone;
       
   168     };
       
   169 
       
   170 #endif	// DEVENCSTARTER_MEMORYENTITY_H