~ubuntu-branches/ubuntu/dapper/fpc/dapper

« back to all changes in this revision

Viewing changes to packages/extra/palmunits/alarmmgr.pp

  • Committer: Bazaar Package Importer
  • Author(s): Carlos Laviola
  • Date: 2004-08-12 16:29:37 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040812162937-moo8ulvysp1ln771
Tags: 1.9.4-5
fp-compiler: needs ld, adding dependency on binutils.  (Closes: #265265)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{$MACRO ON}
 
2
 
 
3
(******************************************************************************
 
4
 *
 
5
 * Copyright (c) 1995-2000 Palm, Inc. or its subsidiaries.
 
6
 * All rights reserved.
 
7
 *
 
8
 * File: AlarmMgr.h
 
9
 *
 
10
 * Release: Palm OS SDK 4.0 (63220)
 
11
 *
 
12
 * Description:
 
13
 *    Include file for Alarm Manager
 
14
 *
 
15
 * History:
 
16
 *    4/11/95  VMK - Created by Vitaly Kruglikov
 
17
 *
 
18
 *****************************************************************************)
 
19
 
 
20
unit alarmmgr;
 
21
 
 
22
interface
 
23
 
 
24
uses  palmos, coretraps, errorbase;
 
25
 
 
26
(************************************************************
 
27
 * Alarm Manager result codes
 
28
 * (almErrorClass is defined in ErrorBase)
 
29
 *************************************************************)
 
30
 
 
31
const
 
32
  almErrMemory = almErrorClass or 1; // ran out of memory
 
33
  almErrFull   = almErrorClass or 2; // alarm table is full
 
34
 
 
35
(********************************************************************
 
36
 * Alarm Manager Structures
 
37
 ********************************************************************)
 
38
 
 
39
// Structure passed with the sysAppLaunchCmdAlarmTriggered action code:
 
40
//
 
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.
 
47
 
 
48
type
 
49
  SysAlarmTriggeredParamType = record
 
50
    ref: UInt32;          // --> alarm reference value passed by caller;
 
51
    alarmSeconds: UInt32; // --> alarm date/time in seconds since 1/1/1904;
 
52
 
 
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
 
56
    padding: UInt8;
 
57
  end;
 
58
 
 
59
// Structure passed with the sysAppLaunchCmdDisplayAlarm action code:
 
60
//
 
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.
 
67
 
 
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;
 
72
    padding: UInt8;
 
73
  end;
 
74
 
 
75
(************************************************************
 
76
 * <chg 4-1-98 RM>
 
77
 *
 
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.
 
81
 *
 
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.
 
85
 *
 
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.
 
89
 *
 
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().
 
93
 *
 
94
 * The almProcCmd's at almProcCmdCustom are available for custom
 
95
 * use by the alarm proc as it sees fit.
 
96
 *
 
97
 *************************************************************)
 
98
 
 
99
type
 
100
  AlmProcCmdEnum = WordEnum;
 
101
 
 
102
const
 
103
  almProcCmdTriggered = 0; // Alarm triggered
 
104
  almProcCmdReschedule = Succ(almProcCmdTriggered); // Reschedule (usually as a result of time change)
 
105
 
 
106
  // Alarm manager reserves all enums up to almProcCmdCustom
 
107
  almProcCmdCustom = $8000;
 
108
 
 
109
type
 
110
  AlmAlarmProc = procedure({AlmProcCmdEnum} almProcCmd: UInt16; var paramP: SysAlarmTriggeredParamType);
 
111
 
 
112
const
 
113
  almProcAlarmCardNo = $8000; // passed in cardNo to AlmSetAlarm
 
114
                              //  and AlmGetAlarm
 
115
 
 
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
 
120
 *  vectors
 
121
 ********************************************************************)
 
122
 
 
123
//-------------------------------------------------------------------
 
124
// Initialization
 
125
//-------------------------------------------------------------------
 
126
 
 
127
//
 
128
// ISSUES:
 
129
//      1.  Is the Alarms Database always on Card 0 ?
 
130
//
 
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.
 
134
//
 
135
//      2.  Should a semaphore be used by the Alarm Manager ?
 
136
//
 
137
//      A:  No.  Present implementation does not require it.  May add one
 
138
//          in the future to ensure data integrity between tasks.
 
139
//
 
140
//      3.  Pilot will need to go back to sleep even if the alarms dialog box is
 
141
//          not closed after some interval.
 
142
//
 
143
//      A:  This will happen in GetNextEvent.
 
144
//
 
145
//      4.  We will need to sound the alarm for all newly triggered alarms
 
146
//          even while another alarm dialog box is on-screen.
 
147
//
 
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.
 
151
//
 
152
//      5.  Should the alarm dialog box be system-modal ?
 
153
//
 
154
//      A:  Yes -- by swallowing the "QUIT" (and/or others) message in the alarm dialog's
 
155
//          event loop.
 
156
//
 
157
 
 
158
 
 
159
// AlmInit()
 
160
//
 
161
// Initializes the Alarm Manager.
 
162
//
 
163
// Create the Alarm Globals.
 
164
//
 
165
 
 
166
function AlmInit: Err; syscall sysTrapAlmInit;
 
167
 
 
168
//-------------------------------------------------------------------
 
169
// API
 
170
//-------------------------------------------------------------------
 
171
 
 
172
// AlmSetAlarm()
 
173
//
 
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.
 
177
//
 
178
 
 
179
function AlmSetAlarm(cardNo: UInt16; dbID: LocalID; ref, alarmSeconds: UInt32; quiet: Boolean): Err; syscall sysTrapAlmSetAlarm;
 
180
 
 
181
// AlmGetAlarm()
 
182
//
 
183
// Gets the alarm seconds for a given app.
 
184
// Zero is returned if there is no alarm setting for the app.
 
185
 
 
186
function AlmGetAlarm(cardNo: UInt16; dbID: LocalID; var refP: UInt32): UInt32; syscall sysTrapAlmGetAlarm;
 
187
 
 
188
// AlmEnableNotification
 
189
//
 
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.
 
197
//
 
198
 
 
199
procedure AlmEnableNotification(enable: Boolean); syscall sysTrapAlmEnableNotification;
 
200
 
 
201
// AlmDisplayAlarm()
 
202
//
 
203
// Displays any alarms that have gone off.
 
204
//
 
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.
 
209
 
 
210
function AlmDisplayAlarm(okToDisplay: Boolean): Boolean; syscall sysTrapAlmDisplayAlarm;
 
211
 
 
212
// AlmCancelAll()
 
213
//
 
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.
 
217
//
 
218
 
 
219
procedure AlmCancelAll; syscall sysTrapAlmCancelAll;
 
220
 
 
221
// AlmAlarmCallback()
 
222
//
 
223
// This function is called at interrupt time by the Time Manager when
 
224
// an alarm goes off.
 
225
//
 
226
 
 
227
procedure AlmAlarmCallback; syscall sysTrapAlmAlarmCallback;
 
228
 
 
229
// AlmTimeChange()
 
230
//
 
231
// This function gets called by TimSetSeconds() and gives the alarm manager
 
232
//  a chance to notify all procedure alarms of the time change.
 
233
//
 
234
 
 
235
procedure AlmTimeChange; syscall sysTrapAlmTimeChange;
 
236
 
 
237
procedure AlmSetProcAlarm(procP: AlmAlarmProc; ref, alarmSeconds: UInt32);
 
238
 
 
239
function AlmGetProcAlarm(procP: AlmAlarmProc; var refP: UInt32): UInt32;
 
240
 
 
241
implementation
 
242
 
 
243
// macros
 
244
 
 
245
procedure AlmSetProcAlarm(procP: AlmAlarmProc; ref, alarmSeconds: UInt32);
 
246
begin
 
247
  AlmSetAlarm(almProcAlarmCardNo, LocalID(procP), ref, alarmSeconds, True);
 
248
end;
 
249
 
 
250
function AlmGetProcAlarm(procP: AlmAlarmProc; var refP: UInt32): UInt32;
 
251
begin
 
252
  AlmGetProcAlarm := AlmGetAlarm(almProcAlarmCardNo, LocalID(procP), refP);
 
253
end;  
 
254
 
 
255
end.
 
 
b'\\ No newline at end of file'