|
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 // class TScheduledTask |
|
15 // -a task which has been scheduled with a schedule |
|
16 // -maintains non-owning pointer to proxy for client which scheduled it |
|
17 // class CSchedule |
|
18 // -has >=1 entries, >=0 tasks |
|
19 // -when one of its entries is due, all its tasks are due |
|
20 // |
|
21 // |
|
22 |
|
23 #ifndef __SCHEDULE_H__ |
|
24 #define __SCHEDULE_H__ |
|
25 |
|
26 // System includes |
|
27 #include <e32base.h> |
|
28 |
|
29 // Forward Declarations |
|
30 class CFileStore; |
|
31 class TStreamId; |
|
32 class TScheduleEntry; |
|
33 class TScheduleEntryInfo2; |
|
34 class TScheduleInfo; |
|
35 class TScheduledTask; |
|
36 class CScheduledTask; |
|
37 class CClientProxy; |
|
38 class TTaskInfo; |
|
39 class RWriteStream; |
|
40 class CConditionManager; |
|
41 class TTaskSchedulerCondition; |
|
42 |
|
43 //#include <schinfo.h> |
|
44 #include <schinfointernal.h> |
|
45 #include "CSCHCODE.H" //opcodes |
|
46 /** |
|
47 Constants |
|
48 @internalComponent |
|
49 */ |
|
50 const TInt KScheduleIdDifferential=10000; |
|
51 |
|
52 /** |
|
53 @internalComponent |
|
54 */ |
|
55 class TScheduledTask |
|
56 { |
|
57 public: |
|
58 TScheduledTask(CScheduledTask& aTask, CClientProxy& iClient); |
|
59 |
|
60 // ?? |
|
61 void OnDue(const TTsTime& iValidUntil); |
|
62 |
|
63 // Access data |
|
64 const HBufC& Data() const; |
|
65 const TTaskInfo& Info() const; |
|
66 const CClientProxy& Client() const; |
|
67 |
|
68 // Ask client to remove & delete the TTaskInfo member |
|
69 void RemoveInfo(); |
|
70 void DecRepeat(); |
|
71 |
|
72 // For queue support |
|
73 static TInt Offset(); |
|
74 |
|
75 private: |
|
76 CScheduledTask& iTask;//doesn't own this: the client does |
|
77 CClientProxy& iClient;//doesn't own this: CTaskScheduler owns all clients |
|
78 TSglQueLink iLink; |
|
79 }; |
|
80 |
|
81 /** |
|
82 @internalComponent |
|
83 */ |
|
84 NONSHARABLE_CLASS(CSchedule) : public CBase |
|
85 { |
|
86 public: |
|
87 static CSchedule* NewLC(TInt aHandle, |
|
88 const TDesC& aName, |
|
89 TBool aPersists, |
|
90 const CArrayFixFlat<TScheduleEntryInfo2>& aEntries, |
|
91 const TSecurityInfo& aSecurityInfo); |
|
92 static CSchedule* NewLC(TInt aHandle, |
|
93 const TDesC& aName, |
|
94 TBool aPersists, |
|
95 const CArrayFixFlat<TTaskSchedulerCondition>& aEntries, |
|
96 const TTsTime& aDefaultRunTime, |
|
97 const TSecurityInfo& aSecurityInfo); |
|
98 static CSchedule* NewL(CFileStore& aStore, TStreamId& aId); |
|
99 ~CSchedule(); |
|
100 |
|
101 private: |
|
102 void ConstructL(const TDesC& aName, |
|
103 const CArrayFixFlat<TScheduleEntryInfo2>& aEntries); |
|
104 void ConstructL(const TDesC& aName, |
|
105 const CArrayFixFlat<TTaskSchedulerCondition>& aEntries, |
|
106 const TTsTime& aDefaultRunTime); |
|
107 void RestoreL(CFileStore& aStore, TStreamId& aId); |
|
108 CSchedule(); |
|
109 CSchedule(const TSecurityInfo& aSecurityInfo, TInt aHandle, TBool aPersists); |
|
110 |
|
111 private: |
|
112 void AddEntriesL(const CArrayFixFlat<TScheduleEntryInfo2>& aEntries); |
|
113 TTsTime ValidUntil() const; //from base class |
|
114 void AddConditionsL(const CArrayFixFlat<TTaskSchedulerCondition>& aConditions); |
|
115 |
|
116 public: |
|
117 // externalize/internalize |
|
118 void InternalizeL(RReadStream& aReadStream); |
|
119 void ExternalizeL(RWriteStream& aWriteStream) const; |
|
120 //call this whenever schedule becomes due: tells tasks they need to be executed |
|
121 void NotifyTasks(); |
|
122 // called whenever a schedule changes. If aNotFirstTime = ETrue then this means |
|
123 // the schedule has just run so we need a minor modification to the next due time calculation |
|
124 void CalculateDueTime(TBool aNotFirstTime = EFalse); |
|
125 //Time entries |
|
126 void ReplaceEntriesL(const CArrayFixFlat<TScheduleEntryInfo2>& aEntries); |
|
127 void EntriesL(CArrayFixFlat<TScheduleEntryInfo2>& aEntries); |
|
128 void GetInfo(TScheduleInfo& aInfo, TBool aCalculateForConditions); |
|
129 inline const TTsTime& DueTime() const; |
|
130 //Condition entries |
|
131 void ReplaceConditionsL(const CArrayFixFlat<TTaskSchedulerCondition>& aConditions); |
|
132 void ConditionsL(CArrayFixFlat<TTaskSchedulerCondition>& aConditions); |
|
133 const TTsTime& DefaultRunTimeL() const; |
|
134 //editing |
|
135 void AddTask(TScheduledTask& aTask); |
|
136 void RemoveTask(TScheduledTask* aTask); |
|
137 void RemoveTasks(TBool aFromClient); |
|
138 TInt GenerateTaskId(); |
|
139 TScheduledTask* Task(const TInt aTaskId); |
|
140 //accessors |
|
141 void RemoveEntries(); |
|
142 void RemoveConditions(); |
|
143 |
|
144 TBool ClientInSchedule(const TDesC& aClientName); |
|
145 inline TSglQue<TScheduledTask>* Tasks(); |
|
146 void TasksL(CArrayFixFlat<TTaskInfo>& aTasks); |
|
147 inline TInt Id() const; |
|
148 inline const TDesC& Name() const; |
|
149 inline TBool Persists() const; |
|
150 inline TBool Enabled() const; |
|
151 inline void SetEnabled(TBool aEnabled); |
|
152 inline TBool HasTasks() const; |
|
153 inline TScheduleType Type() const; |
|
154 const RArray<TTaskSchedulerCondition>& Conditions() const; |
|
155 |
|
156 //security Info related stuff |
|
157 TBool IsAccessAllowed(const RMessagePtr2& aMessage) const; |
|
158 inline void CheckAccessAllowedL(const RMessagePtr2& aMessage) const; |
|
159 |
|
160 const TSecurityInfo& SecurityInfo() const; |
|
161 //list capability |
|
162 static TInt Offset(); |
|
163 TBool IsUpdatable(); |
|
164 |
|
165 private://data |
|
166 TSglQueLink iLink; //scheduler keeps all schedules in owning queue |
|
167 TInt iId; |
|
168 HBufC* iName; |
|
169 TBool iPersists; |
|
170 TBool iEnabled; |
|
171 TTsTime iDueTime; |
|
172 TTimeIntervalMinutes iValidityPeriod; |
|
173 // list handling |
|
174 RArray<TTaskSchedulerCondition> iConditions; |
|
175 TSglQue<TScheduledTask> iTaskList; //things which happen at those times |
|
176 mutable TSglQue<TScheduleEntry> iEntryList; //list of times at which things happen |
|
177 |
|
178 //Creating process SecurityInfo |
|
179 TSecurityInfo iSecurityInfo; |
|
180 }; |
|
181 |
|
182 #include "SCHEDULE.INL" |
|
183 #endif |