|
1 // Copyright (c) 1999-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 __ASSRVSTATICUTILS_H__ |
|
17 #define __ASSRVSTATICUTILS_H__ |
|
18 |
|
19 // System includes |
|
20 #include <e32base.h> |
|
21 #include <s32strm.h> |
|
22 #include <f32file.h> |
|
23 |
|
24 // User includes |
|
25 #include <asshddefs.h> |
|
26 #include "ASSrvAlarmSoundDetails.h" |
|
27 |
|
28 // Classes referenced |
|
29 class TASSrvAlarm; |
|
30 class TASShdAlarm; |
|
31 |
|
32 // |
|
33 // ----> ASSrvStaticUtils (header) |
|
34 // |
|
35 /** |
|
36 * Global utility functions |
|
37 */ |
|
38 class ASSrvStaticUtils |
|
39 { |
|
40 // |
|
41 public: // PANIC/FAULT ENUMERATIONS |
|
42 // |
|
43 |
|
44 /** |
|
45 * For DEBUG-ONLY panics |
|
46 */ |
|
47 enum TASSrvFault |
|
48 { |
|
49 /** |
|
50 * A default section of a switch statement relating to alarm |
|
51 * states has been hit |
|
52 */ |
|
53 EASSrvFaultAlarmStateNotHandled = 0, |
|
54 |
|
55 /** |
|
56 * Timer event not handled in switch statement |
|
57 */ |
|
58 EASSrvFaultTimerEventNotHandled = 1, |
|
59 |
|
60 /** |
|
61 * The alarm data for the specified alarm couldn't be |
|
62 * found, when it should be available |
|
63 */ |
|
64 EASSrvFaultAlarmDataEntryNotFound = 2, |
|
65 |
|
66 /** |
|
67 * There wasn't any alarm data when there should have been |
|
68 */ |
|
69 EASSrvFaultNoData = 3, |
|
70 |
|
71 /** |
|
72 * Some kind of timing error took place which was unexpected |
|
73 */ |
|
74 EASSrvFaultPhantomErrorReported = 4, |
|
75 |
|
76 /** |
|
77 * An alarm status wasn't handled in a switch statement |
|
78 */ |
|
79 EASSrvFaultAlarmStatusNotHandled = 5, |
|
80 |
|
81 /** |
|
82 * An iterator has attempted to attach itself to itself |
|
83 */ |
|
84 EASSrvFaultCyclicIteratorAttach = 6, |
|
85 |
|
86 /** |
|
87 * The alarm wasn't found when it should have been |
|
88 */ |
|
89 EASSrvFaultAlarmNotFound = 7, |
|
90 |
|
91 /** |
|
92 * The index specified within the sound intervals |
|
93 * list isn't valid |
|
94 */ |
|
95 EASSrvFaultBadSoundIntervalIndex = 8, |
|
96 |
|
97 /** |
|
98 * A facade interface wasn't reimplemented |
|
99 */ |
|
100 EASSrvFaultFacadeInterfaceError = 9, |
|
101 |
|
102 /** |
|
103 * An invalid alarm alert server response was received |
|
104 */ |
|
105 EASSrvFaultInvalidAlarmAlertServerResponse = 10, |
|
106 |
|
107 /** |
|
108 * The alarm alert server response handler already |
|
109 * has an outstanding request with the alarm alert server. |
|
110 */ |
|
111 EASSrvFaultAlarmAlertServerResponseReaderAlreadyActive = 11, |
|
112 |
|
113 /** |
|
114 * A fault condition occurred within the alarm alert |
|
115 * server client code |
|
116 */ |
|
117 EASSrvFaultAlarmAlertServerFault = 12, |
|
118 |
|
119 /** |
|
120 * The flags passed to/from the alarm alert server |
|
121 * are invalid |
|
122 */ |
|
123 EASSrvFaultAlarmAlertSetFlagsWithInappropriateValue = 13, |
|
124 |
|
125 /** |
|
126 * Alarm Queue StartAlarmStoreOperation called with invalid store operation |
|
127 */ |
|
128 EASSrvFaultStartInvalidAlarmStoreOperation = 14, |
|
129 |
|
130 /** |
|
131 * Alarm Queue EndAlarmStoreOperation called with invalid store operation |
|
132 */ |
|
133 EASSrvFaultEndInvalidAlarmStoreOperation = 15, |
|
134 |
|
135 /** |
|
136 * An alarm has sound paused while there is another alarm in notifying state. |
|
137 */ |
|
138 EASSrvFaultInvalidSoundPauseAlarm = 16, |
|
139 |
|
140 /** |
|
141 * Alarm server tries to notify more than max number of allowed alarm. |
|
142 */ |
|
143 EASSrvFaultNotifyAlarmExceedMax = 17, |
|
144 |
|
145 /** |
|
146 * Alarm server has no notifying alarms. |
|
147 */ |
|
148 EASSrvFaultNoNotifyingAlarms = 18, |
|
149 |
|
150 |
|
151 /** |
|
152 * Marker |
|
153 */ |
|
154 EASSrvFaultLast |
|
155 }; |
|
156 |
|
157 /** |
|
158 * For ASSERT-ALWAYS panics |
|
159 */ |
|
160 enum TASSrvPanic |
|
161 { |
|
162 /** |
|
163 * A next alarm for a given iterator |
|
164 * was expected but not available |
|
165 */ |
|
166 EASSrvPanicNoNextAlarmForIterator = 0, |
|
167 |
|
168 /** |
|
169 * The alarm specified by the given id |
|
170 * doesn't exist |
|
171 */ |
|
172 EASSrvPanicNoAlarmForId = 1, |
|
173 |
|
174 /** |
|
175 * The specified queue observer could not be |
|
176 * located |
|
177 */ |
|
178 EASSrvPanicNoMatchingObserver = 2, |
|
179 |
|
180 /** |
|
181 * A iterator chaining function was executed |
|
182 * but no attached iterator was found |
|
183 */ |
|
184 EASSrvPanicNoAttachedIterator = 3, |
|
185 |
|
186 /** |
|
187 * It wasn't possible to update the status |
|
188 * of the given alarm |
|
189 */ |
|
190 EASSrvPanicCannotSetAlarmStatus = 4, |
|
191 |
|
192 /** |
|
193 * An invalid or unexpected repeat definition |
|
194 * was encountered |
|
195 */ |
|
196 EASSrvPanicInvalidAlarmRepeat = 5, |
|
197 |
|
198 /** |
|
199 * The specified alarm wasn't removed from |
|
200 * the alarm server queue |
|
201 */ |
|
202 EASSrvPanicAlarmNotDeQueued = 6, |
|
203 |
|
204 /** |
|
205 * It wasn't possible to start the alarm |
|
206 * server's active scheduler |
|
207 */ |
|
208 EASSrvPanicSchedulerNotStarted = 7, |
|
209 |
|
210 /** |
|
211 * An invalid backup operation was initiated |
|
212 */ |
|
213 EASSrvPanicInvalidBackupOperation = 8, |
|
214 |
|
215 /** |
|
216 * A request to start notifications about |
|
217 * a given alarm do not match that which is |
|
218 * expected. |
|
219 */ |
|
220 EASSrvPanicNotifyingAboutWrongAlarm = 9, |
|
221 |
|
222 /** |
|
223 * An alarm iterator function has |
|
224 * encountered a null alarm id |
|
225 */ |
|
226 EASSrvPanicIteratorAlarmIdNull = 10, |
|
227 |
|
228 /** |
|
229 * An alarm has attempted to notify itself |
|
230 * when it is already in the notifying state. |
|
231 */ |
|
232 EASSrvPanicAlarmRepeatedlyNotifying = 11, |
|
233 |
|
234 /** |
|
235 * The wrong alarm id has been promoted to the |
|
236 * notifying state |
|
237 */ |
|
238 EASSrvPanicNotifyingAlarmIsNotAlertingAlarm = 12, |
|
239 |
|
240 /** |
|
241 * An invalid alarm state was encountered |
|
242 */ |
|
243 EASSrvPanicInvalidAlarmState = 13, |
|
244 |
|
245 /** |
|
246 * It wasn't possible to complete the two-phase idle |
|
247 * construction of the notification co-ordinator |
|
248 */ |
|
249 // EASSrvPanicNotificationCoordinatorConstructionIncomplete = 14, // not used any more |
|
250 |
|
251 /** |
|
252 * An invalid observer event was encountered |
|
253 */ |
|
254 EASSrvPanicInvalidTObserverEvent = 15, |
|
255 |
|
256 /** |
|
257 * An unexpected null alarm id was encountered |
|
258 */ |
|
259 EASSrvPanicQueueAlarmIdNull = 16, |
|
260 |
|
261 /** |
|
262 * The current alarm id managed by the notification |
|
263 * co-ordinator does not match that of the currently |
|
264 * notifying alarm |
|
265 */ |
|
266 EASSrvPanicCurrentAlarmNotNotifyingAlarm = 17, |
|
267 |
|
268 /** |
|
269 * Two or more alarms are trying to notify at |
|
270 * the same time |
|
271 */ |
|
272 EASSrvPanicMoreThanOneAlarmNotifying = 18, |
|
273 |
|
274 /** |
|
275 * An unexpected or invalid TSoundSettings event |
|
276 * was encountered |
|
277 */ |
|
278 EASSrvPanicInvalidTSoundSettingsEvent = 19, |
|
279 |
|
280 /** |
|
281 * A request has been made to delete an alarm |
|
282 * but its id doesn't match the expected value |
|
283 */ |
|
284 EASSrvPanicAttemptingToDequeWrongAlarm = 20, |
|
285 |
|
286 /** |
|
287 * An Internalize() request has been made without |
|
288 * correctly setting the type of request. |
|
289 */ |
|
290 EASSrvPanicInternalizeTypeInvalid = 21, |
|
291 |
|
292 /** |
|
293 * OutOfMemory |
|
294 */ |
|
295 EASSrvPanicOutOfMemory= 22, |
|
296 |
|
297 /** |
|
298 * Alarm server sound controller received an unexpected event while disabled. |
|
299 */ |
|
300 EASSrvPanicUnexpectedEventSoundControllerDisabled = 23, |
|
301 |
|
302 |
|
303 /** |
|
304 * Marker |
|
305 */ |
|
306 EASSrvPanicLast |
|
307 }; |
|
308 |
|
309 // |
|
310 public: // STATIC UTILITY FUNCTIONS |
|
311 // |
|
312 |
|
313 static TInt ValidateAlarm(TASSrvAlarm& aAlarm); |
|
314 |
|
315 static TInt ValidateSoundPlayIntervals(RArray<TASSrvAlarmSoundDetails>& aIntervals); |
|
316 |
|
317 static void Fault(TASSrvFault aFault); |
|
318 |
|
319 static void Panic(TASSrvPanic aPanic); |
|
320 |
|
321 static TInt CompareCategories(const TAlarmCategory& aCategory1, const TAlarmCategory& aCategory2); |
|
322 |
|
323 static TInt CompareAlarmIds(const TAlarmId& aId1, const TAlarmId& aId2); |
|
324 |
|
325 static TInt CompareAlarms(const TASSrvAlarm& aAlarm1, const TASSrvAlarm& aAlarm2); |
|
326 |
|
327 static TBool CompareAlarmsExact(const TASSrvAlarm& aAlarm1, const TASSrvAlarm& aAlarm2); |
|
328 |
|
329 static TVersion ASVersion(); |
|
330 |
|
331 static const TDesC& ASName(); |
|
332 |
|
333 static void RoundTimeDownToTheMinute(TTime& aTime); |
|
334 |
|
335 static void PanicClient(const RMessage2& aMessage, TAlarmServerInitiatedClientPanic aPanic); |
|
336 |
|
337 static TTime UtcTimeNow(); |
|
338 |
|
339 static TTime LocalTimeNow(); |
|
340 |
|
341 static void TodayAtTheSpecifiedTime(const TTime& aTime, TTime& aReturn); |
|
342 |
|
343 static RArray<TASSrvAlarmSoundDetails>* InternalizeSoundPlayIntervalsLC(RReadStream& aStream); |
|
344 |
|
345 static void GetPrivateDirL(RFs& aFsSession, TDes& aDirName); |
|
346 |
|
347 static void GetServerPathL(RFs& aFsSession, TDes& aFileName); |
|
348 |
|
349 static void DaysUntilNextActiveAlarmDay(TTimeIntervalDays& aDaysFromNow, TTimeIntervalDays& aRollOverDays, TDay aCurrentDayInWeek, TUint aActiveDays); |
|
350 |
|
351 static void CalculateNext24HoursRepeat(TASShdAlarm& aAlarm, TTimeIntervalSeconds aAllowableWindow = 0); |
|
352 |
|
353 static void CleanupCloseDeleteAlarmIdArray(TAny* aArray); |
|
354 |
|
355 static void CleanupCloseDeleteCategoryArray(TAny* aArray); |
|
356 |
|
357 static void CleanupCloseDeleteSoundDetailsArray(TAny* aArray); |
|
358 |
|
359 // |
|
360 private: // INTERNAL FUNCTIONS |
|
361 // |
|
362 |
|
363 static TInt CompareSoundPlayIntervalStartTimes(const TASSrvAlarmSoundDetails& aAlarmSound1, const TASSrvAlarmSoundDetails& aAlarmSound2); |
|
364 |
|
365 static TBool SoundPlayIntervalsOverlap(const TASSrvAlarmSoundDetails& aDetails1, const TASSrvAlarmSoundDetails& aDetails2); |
|
366 |
|
367 }; |
|
368 |
|
369 /** |
|
370 * Template classes to call ResetAndDestroy on array classes |
|
371 * automatically, when ::PopAndDestroy'ing from the cleanup stack. |
|
372 */ |
|
373 template <class T> |
|
374 class CleanupResetAndDestroy |
|
375 { |
|
376 public: |
|
377 inline static void PushL(T& aRef); |
|
378 private: |
|
379 static void ResetAndDestroy(TAny *aPtr); |
|
380 }; |
|
381 template <class T> |
|
382 inline void CleanupResetAndDestroyL(T& aRef); |
|
383 |
|
384 // Template class CleanupClose |
|
385 template <class T> |
|
386 inline void CleanupResetAndDestroy<T>::PushL(T& aRef) |
|
387 {CleanupStack::PushL(TCleanupItem(&ResetAndDestroy, &aRef));} |
|
388 template <class T> |
|
389 void CleanupResetAndDestroy<T>::ResetAndDestroy(TAny *aPtr) |
|
390 {static_cast<T*>(aPtr)->ResetAndDestroy();} |
|
391 template <class T> |
|
392 inline void CleanupResetAndDestroyPushL(T& aRef) |
|
393 {CleanupResetAndDestroy<T>::PushL(aRef);} |
|
394 |
|
395 |
|
396 #endif |