appinstaller/AppinstUi/Plugin/TaskManager/Inc/TaskManagerImpl.h
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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:   This file contains the header file of the CTaskManagerImpl class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef SWINSTTASKMANAGERIMPL_H
       
    20 #define SWINSTTASKMANAGERIMPL_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <f32file.h>
       
    25 
       
    26 namespace SwiUI
       
    27 {
       
    28 
       
    29 class CTask;
       
    30 
       
    31 /**
       
    32 * TaskManagerImpl handles persistent and nonpersistent tasks in the subsystem. It
       
    33 * can be used to make sure that critical tasks are executed even in case of
       
    34 * fatal error such as power failure.
       
    35 *
       
    36 * @since 3.0
       
    37 * @lib SWInstTaskManagerImpl.lib
       
    38 */
       
    39 NONSHARABLE_CLASS( CTaskManagerImpl ) : public CBase
       
    40     {
       
    41     public:  // Constructors and destructor
       
    42 
       
    43         /**
       
    44         * Two-phased constructor.
       
    45         */
       
    46         static CTaskManagerImpl* NewL();
       
    47 
       
    48         /**
       
    49         * Destructor.
       
    50         */
       
    51         virtual ~CTaskManagerImpl();
       
    52 
       
    53     public: // New functions
       
    54         
       
    55         /**
       
    56         * Adds a task to the task list.
       
    57         * @since 3.0
       
    58         * @param aTask - Pointer to the CTask object. Transfers ownership to TaskManagerImpl.
       
    59         */
       
    60         void AddTaskL( CTask* aTask );
       
    61 
       
    62         /**
       
    63         * Removes a task from the task list.
       
    64         * @since 3.0
       
    65         * @param aTask - Pointer to the CTask object.
       
    66         */
       
    67         void RemoveTaskL( CTask* aTask );
       
    68 
       
    69         /**
       
    70         * Removes tasks from task list without executing them.
       
    71         * @since 3.0
       
    72         */                
       
    73         void FlushTasks();
       
    74 
       
    75         /**
       
    76         * Executes all pending tasks that are added to the task list within 
       
    77         * the lifetime of this thread.
       
    78         * In order to recover from fatal error, please use ExecutelRecoveryTasksL.
       
    79         * @since 3.0
       
    80         */        
       
    81         void ExecutePendingTasksL();
       
    82 
       
    83         /**
       
    84         * Executes all tasks from non persistent and persistent memory. This
       
    85         * should be used to recover from fatal error e.g. power loss.
       
    86         * @since 3.0
       
    87         */        
       
    88         void ExecuteRecoveryTasksL();
       
    89 
       
    90         /**
       
    91         * Writes all persistent tasks from the task list to a persistent storage.
       
    92         * @since 3.0
       
    93         */                
       
    94         void CommitL();        
       
    95 
       
    96         /**
       
    97         * Increase the count of clients.
       
    98         * @since 3.0       
       
    99         */  
       
   100         void IncreaseClientCount();
       
   101 
       
   102         /**
       
   103         * Decrease the count of clients.
       
   104         * @since 3.0       
       
   105         */
       
   106         void DecreaseClientCount();
       
   107 
       
   108         /**
       
   109         * Indicates if no more clients have open instances and memory can be freed.
       
   110         * @since 3.0       
       
   111         */
       
   112         TBool CanBeFreed();
       
   113 
       
   114     private: // New functions
       
   115         
       
   116         /**
       
   117         * Constructor.
       
   118         */  
       
   119         CTaskManagerImpl();  
       
   120 
       
   121         /**
       
   122         * 2nd phase constructor.
       
   123         */
       
   124         void ConstructL();
       
   125 
       
   126         /**
       
   127         * Removes task from persistent storage.
       
   128         * @since 3.0       
       
   129         * @param aTask - Task to be removed.
       
   130         */
       
   131         void RemovePersistentTask( const CTask& aTask );
       
   132 
       
   133         /**
       
   134         * Deletes all tasks from persistent storage.
       
   135         * @since 3.0             
       
   136         */
       
   137         void DeleteTaskFilesL();
       
   138 
       
   139         /**
       
   140         * Creates the directory where persistent tasks are stored.
       
   141         * @since 3.0       
       
   142         */
       
   143         void CreateTaskDirL();
       
   144 
       
   145         /**
       
   146         * Gets the directory where persistent tasks are stored.
       
   147         * @since 3.0       
       
   148         * @param aFilePath - On return will contain the path.
       
   149         */        
       
   150         void GetTaskDir( TDes& aFilePath );
       
   151 
       
   152         /**
       
   153         * Gets the full path to the persistent task file.
       
   154         * @since 3.0       
       
   155         * @param aFilePath - On return will contain the path.
       
   156         * @param aTaskId - Id of the task.
       
   157         */        
       
   158         void GetTaskFilePath( TDes& aFilePath, TInt aTaskId );
       
   159 
       
   160         /**
       
   161         * Reads all persistent task from storage and populates the task list.
       
   162         * @since 3.0       
       
   163         */        
       
   164         void PopulatePersistentTasksL();
       
   165 
       
   166         /**
       
   167         * Gets the next free id that can be assigned to a task.
       
   168         * @since 3.0       
       
   169         * return Task id.
       
   170         */        
       
   171         TInt GetFreeTaskIdL();
       
   172 
       
   173     private:    // Data
       
   174         
       
   175         RPointerArray<CTask> iTaskList;
       
   176         TUint iClientCount;
       
   177         RFs iRFs;        
       
   178     };
       
   179 }
       
   180 
       
   181 #endif      // SWINSTTASKMANAGER_H   
       
   182             
       
   183 // End of File