os/ossrv/genericservices/taskscheduler/SCHSVR/SCHEDULE.H
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericservices/taskscheduler/SCHSVR/SCHEDULE.H	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,183 @@
     1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// class TScheduledTask
    1.18 +// -a task which has been scheduled with a schedule
    1.19 +// -maintains non-owning pointer to proxy for client which scheduled it
    1.20 +// class CSchedule
    1.21 +// -has >=1 entries, >=0 tasks
    1.22 +// -when one of its entries is due, all its tasks are due
    1.23 +// 
    1.24 +//
    1.25 +
    1.26 +#ifndef __SCHEDULE_H__
    1.27 +#define __SCHEDULE_H__
    1.28 +
    1.29 +// System includes
    1.30 +#include <e32base.h>
    1.31 +
    1.32 +// Forward Declarations
    1.33 +class CFileStore;
    1.34 +class TStreamId;
    1.35 +class TScheduleEntry;
    1.36 +class TScheduleEntryInfo2;
    1.37 +class TScheduleInfo;
    1.38 +class TScheduledTask;
    1.39 +class CScheduledTask;
    1.40 +class CClientProxy;
    1.41 +class TTaskInfo;
    1.42 +class RWriteStream;
    1.43 +class CConditionManager;
    1.44 +class TTaskSchedulerCondition;
    1.45 +
    1.46 +//#include <schinfo.h>
    1.47 +#include <schinfointernal.h>
    1.48 +#include "CSCHCODE.H"	//opcodes
    1.49 +/**
    1.50 +Constants
    1.51 +@internalComponent
    1.52 +*/
    1.53 +const TInt KScheduleIdDifferential=10000;
    1.54 +
    1.55 +/**
    1.56 +@internalComponent
    1.57 +*/
    1.58 +class TScheduledTask
    1.59 +	{
    1.60 +public:
    1.61 +	TScheduledTask(CScheduledTask& aTask, CClientProxy& iClient);
    1.62 +
    1.63 +	// ?? 
    1.64 +	void OnDue(const TTsTime& iValidUntil);
    1.65 +
    1.66 +	// Access data
    1.67 +	const HBufC& Data() const;
    1.68 +	const TTaskInfo& Info() const;
    1.69 +	const CClientProxy& Client() const;
    1.70 +	
    1.71 +	// Ask client to remove & delete the TTaskInfo member
    1.72 +	void RemoveInfo();
    1.73 +	void DecRepeat();
    1.74 +
    1.75 +	// For queue support
    1.76 +	static TInt Offset();
    1.77 +
    1.78 +private:
    1.79 +	CScheduledTask& iTask;//doesn't own this: the client does
    1.80 +	CClientProxy& iClient;//doesn't own this: CTaskScheduler owns all clients
    1.81 +	TSglQueLink iLink;
    1.82 +	};
    1.83 +
    1.84 +/**
    1.85 +@internalComponent
    1.86 +*/
    1.87 +NONSHARABLE_CLASS(CSchedule) : public CBase
    1.88 +	{
    1.89 +public:
    1.90 +	static CSchedule* NewLC(TInt aHandle, 
    1.91 +						const TDesC& aName, 
    1.92 +						TBool aPersists,  
    1.93 +						const CArrayFixFlat<TScheduleEntryInfo2>& aEntries,
    1.94 +						const TSecurityInfo& aSecurityInfo);
    1.95 +	static CSchedule* NewLC(TInt aHandle, 
    1.96 +						const TDesC& aName, 
    1.97 +						TBool aPersists,  
    1.98 +						const CArrayFixFlat<TTaskSchedulerCondition>& aEntries,
    1.99 +						const TTsTime& aDefaultRunTime,
   1.100 +						const TSecurityInfo& aSecurityInfo);
   1.101 +	static CSchedule* NewL(CFileStore& aStore, TStreamId& aId);
   1.102 +	~CSchedule();
   1.103 +
   1.104 +private: 
   1.105 +	void ConstructL(const TDesC& aName,
   1.106 +					const CArrayFixFlat<TScheduleEntryInfo2>& aEntries);
   1.107 +	void ConstructL(const TDesC& aName,
   1.108 +					const CArrayFixFlat<TTaskSchedulerCondition>& aEntries,
   1.109 +					const TTsTime& aDefaultRunTime);
   1.110 +	void RestoreL(CFileStore& aStore, TStreamId& aId);
   1.111 +	CSchedule();
   1.112 +	CSchedule(const TSecurityInfo& aSecurityInfo, TInt aHandle, TBool aPersists);
   1.113 +
   1.114 +private:
   1.115 +	void AddEntriesL(const CArrayFixFlat<TScheduleEntryInfo2>& aEntries);
   1.116 +	TTsTime ValidUntil() const; //from base class
   1.117 +	void AddConditionsL(const CArrayFixFlat<TTaskSchedulerCondition>& aConditions);
   1.118 +
   1.119 +public:
   1.120 +	// externalize/internalize
   1.121 +	void InternalizeL(RReadStream& aReadStream);
   1.122 +	void ExternalizeL(RWriteStream& aWriteStream) const;
   1.123 +	//call this whenever schedule becomes due: tells tasks they need to be executed 
   1.124 +	void NotifyTasks();
   1.125 +	// called whenever a schedule changes.  If aNotFirstTime = ETrue then this means
   1.126 +	// the schedule has just run so we need a minor modification to the next due time calculation
   1.127 +	void CalculateDueTime(TBool aNotFirstTime = EFalse);
   1.128 +	//Time entries
   1.129 +	void ReplaceEntriesL(const CArrayFixFlat<TScheduleEntryInfo2>& aEntries);
   1.130 +	void EntriesL(CArrayFixFlat<TScheduleEntryInfo2>& aEntries);
   1.131 +	void GetInfo(TScheduleInfo& aInfo, TBool aCalculateForConditions);
   1.132 +	inline const TTsTime& DueTime() const;
   1.133 +	//Condition entries
   1.134 +	void ReplaceConditionsL(const CArrayFixFlat<TTaskSchedulerCondition>& aConditions);
   1.135 +	void ConditionsL(CArrayFixFlat<TTaskSchedulerCondition>& aConditions);
   1.136 +	const TTsTime& DefaultRunTimeL() const;
   1.137 +	//editing
   1.138 +	void AddTask(TScheduledTask& aTask);
   1.139 +	void RemoveTask(TScheduledTask* aTask);
   1.140 +	void RemoveTasks(TBool aFromClient);
   1.141 +	TInt GenerateTaskId();
   1.142 +	TScheduledTask* Task(const TInt aTaskId);
   1.143 +	//accessors
   1.144 +	void RemoveEntries();
   1.145 +	void RemoveConditions();
   1.146 +	
   1.147 +	TBool ClientInSchedule(const TDesC& aClientName);
   1.148 +	inline TSglQue<TScheduledTask>* Tasks();
   1.149 +	void TasksL(CArrayFixFlat<TTaskInfo>& aTasks);
   1.150 +	inline TInt Id() const;
   1.151 +	inline const TDesC& Name() const;
   1.152 +	inline TBool Persists() const;
   1.153 +	inline TBool Enabled() const;
   1.154 +	inline void SetEnabled(TBool aEnabled);
   1.155 +	inline TBool HasTasks() const;
   1.156 +	inline TScheduleType Type() const;
   1.157 +	const RArray<TTaskSchedulerCondition>& Conditions() const;
   1.158 +	
   1.159 +	//security Info related stuff
   1.160 +	TBool IsAccessAllowed(const RMessagePtr2& aMessage) const;
   1.161 +	inline void CheckAccessAllowedL(const RMessagePtr2& aMessage) const;
   1.162 +	
   1.163 +	const TSecurityInfo& SecurityInfo() const;
   1.164 +	//list capability
   1.165 +	static TInt Offset();
   1.166 +	TBool IsUpdatable();
   1.167 +
   1.168 +private://data
   1.169 +	TSglQueLink iLink;			//scheduler keeps all schedules in owning queue
   1.170 +	TInt iId;
   1.171 +	HBufC* iName;
   1.172 +	TBool iPersists;
   1.173 +	TBool iEnabled;
   1.174 +	TTsTime iDueTime;
   1.175 +	TTimeIntervalMinutes iValidityPeriod;
   1.176 +	// list handling
   1.177 +	RArray<TTaskSchedulerCondition> iConditions;
   1.178 +	TSglQue<TScheduledTask> iTaskList;		//things which happen at those times	
   1.179 +	mutable TSglQue<TScheduleEntry> iEntryList;	//list of times at which things happen
   1.180 +	
   1.181 +	//Creating process SecurityInfo
   1.182 +	TSecurityInfo iSecurityInfo;
   1.183 +	};
   1.184 +	
   1.185 +#include "SCHEDULE.INL"
   1.186 +#endif