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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __ASSHDALARM_H__
17 #define __ASSHDALARM_H__
25 #include <asshddefs.h>
27 ///////////////////////////////////////////////////////////////////////////////////////
28 // ----> TASShdAlarm (header)
29 ///////////////////////////////////////////////////////////////////////////////////////
31 /** The Alarm publish and subscribe category
35 const TUid KAlarmServerPubSubCategory = { 0x101f5027 };
37 /** Used for subcribing missed alarms or time zone changes
41 const TUint KMissingAlarmPubSubKey = 100;
43 /** The publish and subscribe data for KMissingAlarmPubSubKey
47 struct TMissedAlarmPubSubData
49 /** The value indicating the changes.
50 1 - Time zone has been changes but there are no missed alarms
51 2 - Some alarms have been missed after system time or time zone has changed.
55 /** The time that system time change took place, in universal (UTC) time */
56 TTime iTimeOfChangeUtc;
59 /** Used for subscribing to data used when searching for instances in Calendar
63 const TUint KSkippedAlarmInstancesPubSubKey = 101;
65 /** The publish and subscribe data for KMissingAlarmInstancesPubSubKey
69 struct TASShdAlarmedInstanceParams
71 /** The start of the time range in local time. */
72 TTime iLocalStartTime;
74 /** The end of the time range in local time. */
77 /** The alarm time types to include. */
78 TASShdAlarmTimeType iTimeType;
83 /** A client-side alarm object.
85 It contains all of the information needed to create an alarm in
91 ///////////////////////////////////////////////////////////////////////////////////////
93 ///////////////////////////////////////////////////////////////////////////////////////
95 IMPORT_C TASShdAlarm();
97 ///////////////////////////////////////////////////////////////////////////////////////
98 public: // INTERNALIZE / EXTERNALIZE
99 ///////////////////////////////////////////////////////////////////////////////////////
101 IMPORT_C void InternalizeL(RReadStream& aStream);
103 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
105 ///////////////////////////////////////////////////////////////////////////////////////
106 public: // READ-ONLY ACCESS
107 ///////////////////////////////////////////////////////////////////////////////////////
109 inline TAlarmStatus Status() const
110 /** Returns the alarm status.
112 @return Alarm status. */
115 inline TAlarmState State() const
116 /** Returns the alarm state.
118 @return Alarm state. */
121 inline TBool HasAssociatedData() const;
123 inline TBool HasOwningSession() const;
125 inline TBool HasBecomeOrphaned() const;
127 ///////////////////////////////////////////////////////////////////////////////////////
128 public: // READ-ONLY & MODIFIABLE
129 ///////////////////////////////////////////////////////////////////////////////////////
131 IMPORT_C void Reset();
133 inline TAlarmId& Id()
134 /** Returns a writable version of the alarm's unique identifier.
136 @return Reference to the unique identifier. */
139 inline TAlarmId Id() const
140 /** Return the alarm's unique identifier.
142 @return The unique identifier. */
145 //The Secure ID is only used in the secured platform
147 // adds a SID to the alarms private field
148 inline void SetSid(const TSecureId& aSecureID)
149 {iTASShdAlarmSID = aSecureID;}
151 // returns the SID of the alarm's creator
152 inline TSecureId GetSid() const
153 {return iTASShdAlarmSID;}
155 inline TTime& NextDueTime()
156 /** Returns a writable version of the next time the alarm is scheduled to expire.
158 @return Next expiry time. */
159 { return iNextDueTime; }
161 inline const TTime& NextDueTime() const
162 /** Returns the next time that the alarm is scheduled to expire.
164 @return Next expiry time. */
165 { return iNextDueTime; }
167 inline TTime& OriginalExpiryTime()
168 /** Returns a writable version of the alarm's original expiry time.
170 @return Original expiry time. */
171 { return iOriginalExpiryTime; }
173 inline const TTime& OriginalExpiryTime() const
174 /** Returns the alarm's original expiry time.
176 The original expiry time is the same as the next due time, unless the alarm
177 has been snoozed. In that case, the original expiry time is the time when
178 the alarm first expired, and the next due time is when it is to re-awaken
181 @return Original expiry time. */
182 { return iOriginalExpiryTime; }
184 inline TAlarmCategory& Category()
185 /** Returns a writable version of the alarm's category.
187 Clients can use the category to tag each alarm with a specific code. This
188 allows clients to identify all related alarms, such as all alarms associated
189 with a particular application or application engine.
191 @return Alarm category. */
192 { return iCategory; }
194 inline TAlarmCategory Category() const
195 /** Return this alarm's category.
197 @return Alarm category. */
198 { return iCategory; }
200 inline TAlarmCharacteristicsFlags& Characteristics()
201 /** Returns a writable version of the alarm's characteristics.
203 @return Alarm characteristics bit flags. */
204 { return iCharacteristics; }
206 inline TAlarmCharacteristicsFlags Characteristics() const
207 /** Returns the alarm's characteristics
209 @return Alarm characteristics bit flags. */
210 { return iCharacteristics; }
212 inline TAlarmRepeatDefinition& RepeatDefinition()
213 /** Returns a writable version of the alarm's repeat definition.
215 The repeat definition controls the alarm's behaviour after it has expired.
216 For example, you can set the repeat definition so that the server automatically
217 queues the alarm to expire again in exactly 24 hours time.
219 @return Alarm repeat definition. */
220 { return iRepeatDefinition; }
222 inline TAlarmRepeatDefinition RepeatDefinition() const
223 /** Returns the repeat definition for the alarm.
225 @return The alarm's repeat definition. */
226 { return iRepeatDefinition; }
228 inline TAlarmMessage& Message()
229 /** Returns a writable version of the alarm's message.
231 The message is usually displayed in the application UI
232 when the alarm expires.
234 @return Reference to the alarm's associated message. */
237 inline const TAlarmMessage& Message() const
238 /** Returns the alarm's message.
240 The message is usually displayed in the application UI when the alarm expires.
242 @return Reference to the alarm's associated message. */
245 inline TAlarmSoundName& SoundName()
246 /** Return a writable version of the alarm sound's filename.
248 @return Reference to the alarm's sound filename. */
249 { return iSoundName; }
251 inline const TAlarmSoundName& SoundName() const
252 /** Returns the alarm's sound filename.
254 @return Sound filename. */
255 { return iSoundName; }
257 inline TAlarmDayOrTimed DayOrTimed() const
258 /** Returns the alarm session type.
260 @return Alarm session type. */
261 { return iDayOrTimed; }
264 inline TAlarmDayOrTimed& DayOrTimed()
265 /** Returns a writable version of the alarm type, i.e. day, timed
267 @return iDayOrTimed. */
268 { return iDayOrTimed; }
271 IMPORT_C void SetUtcNextDueTime(TTime aUtcTime);
273 IMPORT_C void SetDeQueueIfDueTimeInPast();
275 IMPORT_C TInt SetAlarmDays(TUint8 aAlarmDays);
276 IMPORT_C TUint8 AlarmDays() const;
277 IMPORT_C void SetContinuous(TBool aContinuous);
278 IMPORT_C TBool Continuous();
280 ///////////////////////////////////////////////////////////////////////////////////////
281 public: // CLIENT DATA ACCESS
282 ///////////////////////////////////////////////////////////////////////////////////////
284 inline TBitFlags16& ClientFlags()
285 /** Returns a writable version of the alarm's client flags.
287 The client flags may be used for any client-specific data -
288 the alarm server does not use them.
290 @return Reference to the alarm's bit flags. */
291 { return iClientFlags; }
293 inline TBitFlags16 ClientFlags() const
294 /** Returns this alarm's client flags.
296 @return Reference to the alarm's bit flags. */
297 { return iClientFlags; }
299 inline TInt ClientData1() const
300 /** Returns the client data from slot 1 for this alarm.
302 @return The first client-specific integer. */
303 { return iClientData1; }
305 inline TInt& ClientData1()
306 /** Returns a writable version of the client data from slot 1 for this alarm.
308 @return Reference to the first client-specific integer. */
309 { return iClientData1; }
311 inline TInt ClientData2() const
312 /** Returns the client data from slot 2 for this alarm.
314 @return The second client-specific integer. */
315 { return iClientData2; }
317 inline TInt& ClientData2()
318 /** Returns the client data from slot 2 for this alarm.
320 @return The second client-specific integer. */
321 { return iClientData2; }
323 inline TBool IsFloating() const
324 /** Tests whether the alarm is floating.
326 Floating alarms expire at a given wall-clock time regardless of the current locale and
327 whether any daylight saving time rules are in force.
329 @return True if the alarm is floating.
331 { return iCharacteristics.IsClear(EAlarmCharacteristicsIsFixed); }
337 ///////////////////////////////////////////////////////////////////////////////////////
338 protected: // INTERNAL FLAGS
339 ///////////////////////////////////////////////////////////////////////////////////////
344 enum TASShdAlarmFlags
350 EASShdAlarmFlagsHasAssociatedData = 0,
355 EASShdAlarmFlagsHasOwningSession = 1,
360 EASShdAlarmFlagsHasBecomeOrphaned = 2,
363 * @internalAll Set if alarm is disabled manually so that can not be enabled when
366 EASShdAlarmFlagsPermanentDisabled = 4
374 enum TASShdAlarmFlags2
376 EASShdAlarmFlag2Wakeup = 0,
379 enum TASShdAlarmFlags2AlarmRepeatExtensions
381 EASShdAlarmFlag2AlarmDayMonday = 1,
382 EASShdAlarmFlag2AlarmDayTuesday = 2,
383 EASShdAlarmFlag2AlarmDayWednesday = 3,
384 EASShdAlarmFlag2AlarmDayThursday = 4,
385 EASShdAlarmFlag2AlarmDayFriday = 5,
386 EASShdAlarmFlag2AlarmDaySaturday = 6,
387 EASShdAlarmFlag2AlarmDaySunday = 7,
388 EASShdAlarmFlag2Continuous = 8
392 ///////////////////////////////////////////////////////////////////////////////////////
393 protected: // MEMBER DATA
394 ///////////////////////////////////////////////////////////////////////////////////////
397 * Various flags - used internally by the alarm object
402 * This represents the desired behaviour for a given alarm.
403 * The Alarm Server uses this information to control the
404 * behaviour of the alarm.
406 * @see TAlarmCharacteristics
408 TAlarmCharacteristicsFlags iCharacteristics;
411 * The unique identifier assoicated with each alarm maintained
412 * by the alarm world server.
417 * The status of this alarm (e.g. enabled, disabled)
419 TAlarmStatus iStatus;
422 * The state of this alarm (e.g. queued, notifying, notified, snoozed etc)
427 * The type of this alarm (e.g. day, timed)
429 TAlarmDayOrTimed iDayOrTimed;
432 * Controls how the alarm repeats after it has expired. Note that
433 * session alarms are not allowed to repeat (they must be "once
436 TAlarmRepeatDefinition iRepeatDefinition;
439 * This UID is supplied by the client and is used to indicate
440 * the category that this alarm is part of. The Alarm Server
441 * is category-agnostic, that is, this information is for
442 * the client's use only
444 TAlarmCategory iCategory;
447 * The date and time at which this alarm is next due. For alarms
448 * that haven't been snoozed, then this is the original due time.
450 * For alarms that have been snoozed, this is the time at which
451 * the alarm will reawaken.
456 * This attribute is only used in the instance whereby an alarm
457 * is snoozed. It represents the time at which the alarm first
460 TTime iOriginalExpiryTime;
463 * The message associated with this alarm, typically used
464 * in an application UI to inform the user as to the reason
467 TAlarmMessage iMessage;
470 * A descriptor which holds the name of the sound file which
471 * should be played when the alarm expires.
473 TAlarmSoundName iSoundName;
475 ///////////////////////////////////////////////////////////////////////////////////////
476 protected: // CLIENT SPECIFIC DATA
477 ///////////////////////////////////////////////////////////////////////////////////////
480 * Flags for use by any particular client. These will
481 * only be relevant to a client who can interpret them.
483 TBitFlags16 iClientFlags;
486 * For arbitrary client data 1
491 * For arbitrary client data 2
495 ///////////////////////////////////////////////////////////////////////////////////////
496 private: // BC PROOFING
497 ///////////////////////////////////////////////////////////////////////////////////////
498 TSecureId iTASShdAlarmSID;
500 * Various flags - used internally by the alarm object
503 TUint16 iTASShdAlarm_2;
504 TAny* iTASShdAlarm_3;
508 ///////////////////////////////////////////////////////////////////////////////////////
509 // ----> TASShdAlarm (inline)
510 ///////////////////////////////////////////////////////////////////////////////////////
513 /** Tests whether the alarm has any associated data.
515 @return True if the alarm has associated data. */
516 inline TBool TASShdAlarm::HasAssociatedData() const
519 return iFlags.IsSet(EASShdAlarmFlagsHasAssociatedData);
523 /** Tests whether the alarm has an active owning session.
525 @return True if the alarm has an active owning session. */
526 inline TBool TASShdAlarm::HasOwningSession() const
529 return iFlags.IsSet(EASShdAlarmFlagsHasOwningSession);
532 inline TBool TASShdAlarm::HasBecomeOrphaned() const
533 /** Tests whether the alarm is orphaned.
535 An alarm is ophaned if it used to have an owning session, but no longer does.
536 If an alarm is owned by a session, it is removed from the queue when the session
537 disconnects. However, orphaned alarms stay in the queue.
539 @return True if the alarm has becomed orphaned. */
541 return iFlags.IsSet(EASShdAlarmFlagsHasBecomeOrphaned);
546 #endif // #ifndef __ASSHDALARM_H__