3
(******************************************************************************
5
* Copyright (c) 1995-2000 Palm, Inc. or its subsidiaries.
10
* Release: Palm OS SDK 4.0 (63220)
13
* Include file for Alarm Manager
16
* 4/11/95 VMK - Created by Vitaly Kruglikov
18
*****************************************************************************)
24
uses palmos, coretraps, errorbase;
26
(************************************************************
27
* Alarm Manager result codes
28
* (almErrorClass is defined in ErrorBase)
29
*************************************************************)
32
almErrMemory = almErrorClass or 1; // ran out of memory
33
almErrFull = almErrorClass or 2; // alarm table is full
35
(********************************************************************
36
* Alarm Manager Structures
37
********************************************************************)
39
// Structure passed with the sysAppLaunchCmdAlarmTriggered action code:
41
// This is a notification that an alarm set by the creator has
42
// gone off. The action code handler should not do anything time-
43
// consuming here. The intended use is to set the next alarm and/or
44
// to perform some quick maintenance task. Particularly, this action code
45
// handler is not allowed to display any UI(dialogs, etc.) -- this would delay
46
// notification for alarms set by others. This action code may be ignored.
49
SysAlarmTriggeredParamType = record
50
ref: UInt32; // --> alarm reference value passed by caller;
51
alarmSeconds: UInt32; // --> alarm date/time in seconds since 1/1/1904;
53
purgeAlarm: Boolean; // <-- if set to true on return, this alarm
54
// will be removed from the alarm table and the
55
// display notification will NOT be generated for it
59
// Structure passed with the sysAppLaunchCmdDisplayAlarm action code:
61
// This is a notification to display an alarm. This action code
62
// will be called sometime after the app receives a sysAppLaunchCmdAlarmTriggered
63
// notification(perhaps after a significant delay). It is possible that this
64
// notification will not be sent at all in the event the alarm table becomes full and
65
// the alarm table entry is used to hold a new alarm (this does NOT apply to the
66
// sysAppLaunchCmdAlarmTriggered notification). This action code may be ignored.
68
SysDisplayAlarmParamType = record
69
ref: UInt32; // alarm reference value passed by caller;
70
alarmSeconds: UInt32; // alarm date/time in seconds since 1/1/1904;
71
soundAlarm: Boolean; // non-zero if alarm needs to be sounded;
75
(************************************************************
78
* New PalmOS 3.2 support for procedure alarms. These alarms
79
* are designed to call a procedure pointer rather than send
80
* an action code to an application.
82
* They are set using the AlmSetProcAlarm() macro. The caller
83
* passes a pointer to a procedure of type AlmAlarmProc and
84
* this procedure will be called when the alarm goes off.
86
* When the alarm fires, the alarm proc will be called with
87
* an almProcCmd of almProcCmdTriggered and paramP containing
88
* to the alarm parameters.
90
* When a system time or date change occurs, the alarm proc will
91
* be called with a almProcCmdReschedule cmd. The alarm proc should
92
* reschedule itself at this time using AlmSetProcAlarm().
94
* The almProcCmd's at almProcCmdCustom are available for custom
95
* use by the alarm proc as it sees fit.
97
*************************************************************)
100
AlmProcCmdEnum = WordEnum;
103
almProcCmdTriggered = 0; // Alarm triggered
104
almProcCmdReschedule = Succ(almProcCmdTriggered); // Reschedule (usually as a result of time change)
106
// Alarm manager reserves all enums up to almProcCmdCustom
107
almProcCmdCustom = $8000;
110
AlmAlarmProc = procedure({AlmProcCmdEnum} almProcCmd: UInt16; var paramP: SysAlarmTriggeredParamType);
113
almProcAlarmCardNo = $8000; // passed in cardNo to AlmSetAlarm
116
(********************************************************************
117
* Alarm Manager Routines
118
* These are define as syscall calls only under emulation mode or
119
* under native mode from the module that actually installs the trap
121
********************************************************************)
123
//-------------------------------------------------------------------
125
//-------------------------------------------------------------------
129
// 1. Is the Alarms Database always on Card 0 ?
131
// A: We will store alarm info on the dynamic heap. Upon reset and
132
// time change, apps will be notified via action code and will re-
133
// submit their alarms.
135
// 2. Should a semaphore be used by the Alarm Manager ?
137
// A: No. Present implementation does not require it. May add one
138
// in the future to ensure data integrity between tasks.
140
// 3. Pilot will need to go back to sleep even if the alarms dialog box is
141
// not closed after some interval.
143
// A: This will happen in GetNextEvent.
145
// 4. We will need to sound the alarm for all newly triggered alarms
146
// even while another alarm dialog box is on-screen.
148
// A: Yes. We will keep a flag in our globals to indicate when the
149
// alarm manager is displaying an alarm. This way we do not hog
150
// stack and dynamic heap memory with additional alarm boxes.
152
// 5. Should the alarm dialog box be system-modal ?
154
// A: Yes -- by swallowing the "QUIT" (and/or others) message in the alarm dialog's
161
// Initializes the Alarm Manager.
163
// Create the Alarm Globals.
166
function AlmInit: Err; syscall sysTrapAlmInit;
168
//-------------------------------------------------------------------
170
//-------------------------------------------------------------------
174
// Sets an alarm for the given application. If an alarm for that
175
// application had been previously set, it will be replaced. Passing
176
// a zero for alarmSeconds cancels the current alarm for the application.
179
function AlmSetAlarm(cardNo: UInt16; dbID: LocalID; ref, alarmSeconds: UInt32; quiet: Boolean): Err; syscall sysTrapAlmSetAlarm;
183
// Gets the alarm seconds for a given app.
184
// Zero is returned if there is no alarm setting for the app.
186
function AlmGetAlarm(cardNo: UInt16; dbID: LocalID; var refP: UInt32): UInt32; syscall sysTrapAlmGetAlarm;
188
// AlmEnableNotification
190
// Enables/disables Alarm Manager's notification mechanism. For example,
191
// the HotSync application disables Alarm notifications during the sync
192
// to ensure that apps do not try to access their data database until
193
// the DesktopLink server had a chance to notify the apps whose databases
194
// were modified during the session. This also prevents the alarm dialogs from
195
// blocking the HotSync UI. A call to disable MUST always
196
// precede the call to enable.
199
procedure AlmEnableNotification(enable: Boolean); syscall sysTrapAlmEnableNotification;
203
// Displays any alarms that have gone off.
205
// This function is called by the Event Manager executing on some app's
206
// thread. This permits us to access resources and execute system calls
207
// which would not be possible at interrupt time.
208
// 12/8/98 jb Added return code.
210
function AlmDisplayAlarm(okToDisplay: Boolean): Boolean; syscall sysTrapAlmDisplayAlarm;
214
// Cancels all alarms managed by the Alarm Manager. This
215
// function is presently called by the Time Manager to cancel all alarms
216
// when the user changes date/time.
219
procedure AlmCancelAll; syscall sysTrapAlmCancelAll;
221
// AlmAlarmCallback()
223
// This function is called at interrupt time by the Time Manager when
224
// an alarm goes off.
227
procedure AlmAlarmCallback; syscall sysTrapAlmAlarmCallback;
231
// This function gets called by TimSetSeconds() and gives the alarm manager
232
// a chance to notify all procedure alarms of the time change.
235
procedure AlmTimeChange; syscall sysTrapAlmTimeChange;
237
procedure AlmSetProcAlarm(procP: AlmAlarmProc; ref, alarmSeconds: UInt32);
239
function AlmGetProcAlarm(procP: AlmAlarmProc; var refP: UInt32): UInt32;
245
procedure AlmSetProcAlarm(procP: AlmAlarmProc; ref, alarmSeconds: UInt32);
247
AlmSetAlarm(almProcAlarmCardNo, LocalID(procP), ref, alarmSeconds, True);
250
function AlmGetProcAlarm(procP: AlmAlarmProc; var refP: UInt32): UInt32;
252
AlmGetProcAlarm := AlmGetAlarm(almProcAlarmCardNo, LocalID(procP), refP);
b'\\ No newline at end of file'