appinstaller/AppinstUi/Plugin/TaskManager/Src/TaskManager.cpp
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2002-2008 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 module contains the implementation of CTaskManager class 
       
    15 *                member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 
       
    22 #include "SWInstTaskManager.h"
       
    23 #include "SWInstTask.h"
       
    24 #include "TaskManagerImpl.h"
       
    25 
       
    26 using namespace SwiUI;
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CTaskManager::CTaskManager
       
    32 // C++ default constructor can NOT contain any code, that
       
    33 // might leave.
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CTaskManager::CTaskManager()
       
    37     {
       
    38     }
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // CTaskManager::ConstructL
       
    42 // Symbian 2nd phase constructor can leave.
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 void CTaskManager::ConstructL()
       
    46     {
       
    47     if ( !Dll::Tls() )
       
    48         {
       
    49         Dll::SetTls( CTaskManagerImpl::NewL() );
       
    50         }
       
    51     
       
    52     // Increase the client count
       
    53     iImpl = Impl();
       
    54     iImpl->IncreaseClientCount();
       
    55     }
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CTaskManager::NewL
       
    59 // Two-phased constructor.
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 EXPORT_C CTaskManager* CTaskManager::NewL()
       
    63     {
       
    64     CTaskManager* self = new( ELeave ) CTaskManager();
       
    65     CleanupStack::PushL( self );
       
    66     self->ConstructL();
       
    67     CleanupStack::Pop( self );
       
    68     return self;    
       
    69     }
       
    70 
       
    71 // Destructor
       
    72 EXPORT_C CTaskManager::~CTaskManager()
       
    73     {
       
    74     // Decrease the client count
       
    75     iImpl->DecreaseClientCount();
       
    76 
       
    77     // Check if no more clients so that TLS can be freed.
       
    78     if ( iImpl->CanBeFreed() )
       
    79         {
       
    80         delete iImpl;
       
    81         Dll::SetTls( NULL );
       
    82         }    
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // TaskManager::AddTaskL
       
    87 // Adds a task to the task list.
       
    88 // (other items were commented in a header).
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 EXPORT_C void CTaskManager::AddTaskL( CTask* aTask )
       
    92     {
       
    93     if ( aTask == NULL  )
       
    94         {
       
    95         User::Leave( KErrArgument );    
       
    96         }    
       
    97     
       
    98     iImpl->AddTaskL( aTask );
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // TaskManager::RemoveTaskL
       
   103 // Removes a task from the task list.
       
   104 // (other items were commented in a header).
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 EXPORT_C void CTaskManager::RemoveTaskL( CTask* aTask )
       
   108     {
       
   109     if ( aTask == NULL  )
       
   110         {
       
   111         User::Leave( KErrArgument );    
       
   112         }    
       
   113     
       
   114     iImpl->RemoveTaskL( aTask );
       
   115     }
       
   116      
       
   117 // -----------------------------------------------------------------------------
       
   118 // TaskManager::FlushTasks
       
   119 // Removes tasks from task list without executing them.
       
   120 // (other items were commented in a header).
       
   121 // -----------------------------------------------------------------------------
       
   122 //             
       
   123 EXPORT_C void CTaskManager::FlushTasks()
       
   124     {
       
   125     iImpl->FlushTasks();    
       
   126     }
       
   127           
       
   128 // -----------------------------------------------------------------------------
       
   129 // TaskManager::ExecutePendingTasksL
       
   130 // Executes all pending tasks that are added to the task list within the 
       
   131 // lifetime of this thread.
       
   132 // (other items were commented in a header).
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 EXPORT_C void CTaskManager::ExecutePendingTasksL()
       
   136     {
       
   137     iImpl->ExecutePendingTasksL();
       
   138     }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // TaskManager::ExecuteRecoveryTasksL
       
   142 // Executes all tasks from non persistent and persistent memory.
       
   143 // (other items were commented in a header).
       
   144 // -----------------------------------------------------------------------------
       
   145 //
       
   146 EXPORT_C void CTaskManager::ExecuteRecoveryTasksL()
       
   147     {
       
   148     iImpl->ExecuteRecoveryTasksL();    
       
   149     }
       
   150 
       
   151 // -----------------------------------------------------------------------------
       
   152 // TaskManager::CommitL
       
   153 // Writes all persistent tasks from the task list to a persistent storage.
       
   154 // (other items were commented in a header).
       
   155 // -----------------------------------------------------------------------------
       
   156 //
       
   157 EXPORT_C void CTaskManager::CommitL()
       
   158     {
       
   159     iImpl->CommitL();    
       
   160     }
       
   161 
       
   162 // -----------------------------------------------------------------------------
       
   163 // TaskManager::Impl
       
   164 // Return pointer to TaskManager implementation.
       
   165 // (other items were commented in a header).
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 CTaskManagerImpl* CTaskManager::Impl()
       
   169     {
       
   170     return static_cast<CTaskManagerImpl*> (Dll::Tls());
       
   171     }
       
   172 
       
   173 //  End of File