genericservices/taskscheduler/SCHSVR/SCHMAN.H
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __SCHMAN_H__
       
    17 #define __SCHMAN_H__
       
    18 
       
    19 // System includes
       
    20 #include <f32file.h>
       
    21 
       
    22 // User includes
       
    23 #include "SCHINFO.H"
       
    24 #include "SchSSAObserver.h"
       
    25 
       
    26 #include <babackup.h>
       
    27 
       
    28 // Classes referenced
       
    29 class CSchedule;
       
    30 class TScheduledTask;
       
    31 class CScheduleCriteriaManager;
       
    32 class CClientProxy;
       
    33 class TScheduleEntryInfo2;
       
    34 class CSchBackupManager;
       
    35 class CEnvironmentChangeNotifier;
       
    36 class CSchLogManager;
       
    37 class TTaskSchedulerCondition;
       
    38 
       
    39 enum TBUROperation
       
    40 	{
       
    41 	EBUROperationNoActivity = 0,
       
    42 	EBUROperationBackup,
       
    43 	EBUROperationRestore
       
    44 	};
       
    45 
       
    46 enum TBUROperationResult
       
    47 	{
       
    48 	EBUROperationAbort = 0,
       
    49 	EBUROperationSuccess
       
    50 	};
       
    51 
       
    52 NONSHARABLE_CLASS(CTaskScheduler) : public CBase, public MSchStartupStateObserver, private MBackupOperationObserver
       
    53 	{
       
    54 public:
       
    55 	static CTaskScheduler* NewL();
       
    56 	static CTaskScheduler* NewLC();
       
    57 	~CTaskScheduler();
       
    58 
       
    59 public: 
       
    60 	// Client, Schedule and Task functions
       
    61 	CClientProxy* AddClientL(const TDesC& aFilename, TInt aPriority);
       
    62 	void AddScheduleL(CSchedule& aSchedule);
       
    63 	void RemoveScheduleL(TInt aHandle);
       
    64 	void EditScheduleL(TInt aScheduleHandle, 
       
    65 					CArrayFixFlat<TScheduleEntryInfo2>& aEntryList);
       
    66 	void EditScheduleL(TInt aScheduleHandle, 
       
    67 					CArrayFixFlat<TTaskSchedulerCondition>& aEntryList,
       
    68 					const TTsTime& aDefaultTime);
       
    69 	void EnableScheduleL(TInt aHandle);
       
    70 	void DisableScheduleL(TInt aHandle);
       
    71 	void ScheduleTaskL(CSchedule& aSchedule,
       
    72 					CClientProxy& aClient);
       
    73 	void DeleteTaskL(TInt aScheduleHandle, TInt aTaskHandle);
       
    74 
       
    75 	TInt GetScheduleRefsL(CArrayFixFlat<TSchedulerItemRef>* aRefArray, 
       
    76 									TScheduleFilter aFilter,
       
    77 									const RMessagePtr2& aMessage);
       
    78 	TInt GetTaskRefsL(CArrayFixFlat<TSchedulerItemRef>* aRefArray, 
       
    79 									TScheduleFilter aScheduleFilter,
       
    80 									TTaskFilter aTaskFilter,
       
    81 									CClientProxy* aClient,
       
    82 									const RMessagePtr2& aMessage);
       
    83 	// Utility functions
       
    84 	CSchedule* FindL(TInt aHandle);
       
    85 	TInt GenerateId();
       
    86 	void DueTaskNotifyL(TInt aScheduleHandle);	//called when some task is due
       
    87 
       
    88 	// from MSchStartupStateObserver
       
    89 	void ProcessSSAEventL(TStartupStateIdentifier aKnownState);
       
    90 	TBool IsScheduleReadyForUpdate(CSchedule& aSchedule);
       
    91 	TBool IsStartupStateNonCritical();
       
    92 
       
    93 	inline TBUROperation BUROperationInProgress() { return iBUROperationInProgress; }
       
    94 
       
    95 	// from MBackupOperationObserver
       
    96 	virtual void HandleBackupOperationEventL(const TBackupOperationAttributes &aBackupOperationAttributes);	
       
    97 
       
    98 private: 
       
    99 	// Construction functions
       
   100 	CTaskScheduler();
       
   101 	void ConstructL();
       
   102 	
       
   103 	//Environment change functions
       
   104 	static TInt EnvironmentChanged(TAny* aScheduler);
       
   105 	void HandleEnvironmentChange();
       
   106 	
       
   107 	// Utility functions
       
   108 	CSchedule* Find(TInt aHandle);
       
   109 	void DoRemoveL(CSchedule* aSchedule);
       
   110 	void ExecuteClients(TBool aUpdateClient=ETrue);
       
   111 	void DoEditScheduleL(CSchedule& aSchedule, 
       
   112 							CArrayFixFlat<TTaskSchedulerCondition>& aConditionList,
       
   113 							const TTsTime& aDefaultTime);
       
   114 	void AddSchedulesToTimerL();
       
   115 	void CleanupScheduledTasksL();
       
   116 	void UpdateClients();
       
   117 
       
   118 	void BURBeginningL(TBUROperation aOperationType); 
       
   119 	void BURCompleteL(TBUROperation aOperationType, TBUROperationResult aBURResult); 
       
   120 
       
   121 private:
       
   122 	RFs iFsSession;
       
   123 	//
       
   124 	TSglQue<CSchedule> iSchedules;
       
   125 	TPriQue<CClientProxy> iClients;
       
   126 	//
       
   127 	CScheduleCriteriaManager* iScheduleCriteriaManager;
       
   128 	CSchBackupManager* iBackupManager;
       
   129 	CEnvironmentChangeNotifier* iNotifier;
       
   130 	CSchLogManager* iSchLogManager;
       
   131 	TBool iStartupStatePassNonCritical;
       
   132 
       
   133 	TBUROperation iBUROperationInProgress;
       
   134 	TBool iTaskExecutedDuringBUR;
       
   135 	CBaBackupSessionWrapper* iBackupNotification;
       
   136 	};
       
   137 
       
   138 #endif