NotifyMgr.h
declares the API that this chapter describes. For more information on the notification manager, see the section "Notifications" in the "Palm System Features" chapter of the Palm OS Programmer's Companion.
SleepEventParamType
struct is used in notifications of type sysNotifySleepRequestEvent
to indicate why the system is going to sleep and whether sleep should be deferred.
typedef struct {
    UInt16 reason;
    UInt16 deferSleep;
} SleepEventParamType;
SysNotifyDisplayChangeDetailsType
struct is used in notifications of type sysNotifyDisplayChangeEvent
to indicate how the bit depth changed. If the two values in the struct are equal, it means that the color palette has changed instead of the bit depth.
typedef struct {
    UInt32 oldDepth;
    UInt32 newDepth;
} SysNotifyDisplayChangeDetailsType;
SysNotifyParamType
struct defines a notification event. This struct is sent along with the
sysAppLaunchCmdNotify
launch code or is passed as a parameter to the notification callback function.
typedef struct SysNotifyParamType {
    UInt32 notifyType;
    UInt32 broadcaster;
    void * notifyDetailsP;
    void * userDataP;
    Boolean handled;
    UInt8 reserved2;
} SysNotifyParamType;
notifyType
| The type of event that occurred. See Notification Manager Event Constants. |
broadcaster
|
The creator ID of the application that broadcast the notification (the application that called SysNotifyBroadcast or SysNotifyBroadcastDeferred ), or sysNotifyBroadcasterCode if the system broadcast the event.
|
notifyDetailsP
| Pointer to data specific to this notification. Most notifications do not use this parameter. See Notification Manager Event Constants for the specific instances where this parameter is used. |
userDataP
|
Pointer to custom data that your notification handler requires. You create this data and pass its pointer to SysNotifyRegister .
|
handled
|
true if event is handled yet; false otherwise. In some cases, notification handlers can set this field to true to indicate that they have handled an event. See Notification Manager Event Constants.
|
reserved2
| Reserved for future use. |
Constant | Description |
---|---|
sysNotifyAntennaRaisedEvent
|
Sent during SysHandleEvent when the antenna is raised on a Palm VII series device.
|
sysNotifyDisplayChangeEvent
|
Sent just after the color table has been set to use a specific palette or just after WinScreenMode has changed the bit depth.
|
sysNotifyEarlyWakeupEvent
|
Sent during SysHandleEvent immediately after the system has finished sleeping. The screen may still be turned off, and the system may quickly go back to sleep after handling a procedure alarm or charger event.
|
sysNotifyForgotPasswordEvent
| Sent if the user taps the Lost Password button in the Security application. The notification is sent after the user has confirmed that all private records should be deleted but before the deletion actually occurs. |
sysNotifyLateWakeupEvent
|
Sent during SysHandleEvent immediately after the device has finished waking up. This is sent at the late stage of wakeup, after the screen has been turned on.
|
sysNotifyMenuCmdBarOpenEvent
|
Sent during MenuHandleEvent when it is about to display the menu shortcut command bar.
|
sysNotifyResetFinishedEvent
| Sent immediately after the system has finished a reset. |
sysNotifySleepNotifyEvent
|
Sent during SysHandleEvent immediately before the system is put to sleep. After the broadcast is complete, the system is put to sleep.
|
sysNotifySleepRequestEvent
|
Sent during SysHandleEvent processing when the system has decided to go to sleep.
|
sysNotifySyncFinishEvent
| Sent immediately after a HotSync® operation is complete. |
sysNotifySyncStartEvent
| Sent immediately before a HotSync operation is begun. |
sysNotifyTimeChangeEvent
|
Sent just after the system time has been changed using TimSetSeconds .
|
Constant | Value | Description |
---|---|---|
sysNotifyBroadcasterCode
|
'psys'
| Value passed as the creator ID of the broadcaster for notifications broadcast by the system. |
sysNotifyDefaultQueueSize
| 15 | Maximum number of nested broadcasts allowed. |
sysNotifyNormalPriority
| 0 | Typical priority value used when registering for notifications. |
sysNotifyVersionNum
| 1 |
Current notification manager version. This number is stored in the system feature sysFtrNumNotifyMgrVersion .
|
Err SysNotifyBroadcast (SysNotifyParamType *notify)
  |
|
No error. |
  |
|
The broadcast stack limit has already been reached. |
  |
|
The background thread is broadcasting the notification and the notify parameter is NULL . |
  |
|
There is not enough space on the stack for the notification. |
SysNotifyBroadcast
call returns. This notification occurs in priority order.
sysNotifyDefaultQueueSize
specifies how many levels of nested notification are allowed. If you reach this limit, the error sysNotifyErrBroadcastBusy
is returned and your notification is not broadcast. To avoid reaching the limit, use
SysNotifyBroadcastDeferred
instead of
SysNotifyBroadcast
in your notification handlers. This ensures that the notification will not be broadcast until the top of the event loop.
WARNING!Do not callSysNotifyBroadcast
from code that might be called from a background task (such as a trap patch) with the memory semaphore reserved. UseSysNotifyBroadcastDeferred
instead.
Err SysNotifyBroadcastDeferred (SysNotifyParamType *notify, Int16 paramSize)
  |
<-> |
The notification to enqueue. See SysNotifyParamType . |
  |
-> |
Size of the data pointed to by the field notify->notifyDetailsP . |
  |
|
No error. |
  |
|
There is not enough memory to allocate a new notification entry in the queue. |
  |
|
paramSize is a negative number. |
  |
|
The queue has reached its maximum number of entries. |
SysNotifyBroadcast
except that the broadcast does not take place until the top of the event loop (specifically, the next time
EvtGetEvent
is called). The system copies the notify
structure to a new memory chunk, which is disposed of upon completion of the broadcast. (The paramSize
parameter is used when copying the notifyDetailsP
portion of the notify
structure.)
Err SysNotifyRegister (UInt16 cardNo, LocalID dbID, UInt32 notifyType, SysNotifyProcPtr callbackP, Int8 priority, void *userDataP)
  |
-> |
Number of the storage card on which the application or code resource resides. |
  |
-> |
Local ID of the application or code resource. |
  |
-> |
The event that the application wants to receive notifications about. See Notification Manager Event Constants. |
  |
-> |
NULL to receive the notification as an application launch code. If your code does not have a PilotMain function (for example, if it is a shared library), pass a pointer to a function that should be called when the notification is broadcast. See SysNotifyProcPtr . |
  |
-> |
The priority with which the application should receive the event. Most applications and other code resources should always use sysNotifyNormalPriority . In rare circumstances, you may need to ensure that your code is notified toward the beginning or toward the end of the notification sequence. If so, specify a value between -15 and +15. The smaller the priority, the earlier your code is notified. |
  |
-> |
Caller-defined data to pass to the notification handler. |
SysNotifyUnregister
.
NULL
as the callbackP
parameter. In this case, the system notifies your application by sending it the
sysAppLaunchCmdNotify
launch code. This launch code's parameter block points to a
SysNotifyParamType
structure containing details about the notification.
callbackP
. This callback should follow the prototype shown in
SysNotifyProcPtr
. Note that you should always supply a card number and database ID to SysNotifyRegister
, even if you specify a callback function.
IMPORTANT: Because thecallbackP
pointer is used to directly call the function, the pointer must remain valid from the timeSysNotifyRegister
is called to the time the notification is broadcast. If the function is in a shared library, you must keep the library open. If the function is in a separately loaded code resource, the resource must remain locked while registered for the notification. When you close a library or unlock a resource, you must first unregister for any notifications. If you don't, the system will crash when the notification is broadcast.
sysAppLaunchCmdNotify
or uses the callback function, the notification handler may perform any processing necessary. As with most launch codes, it's not possible to access global variables. If the handler needs access to any particular value to respond to the notification, pass a pointer to that value in the userDataP
parameter. The system passes this pointer back to your application or callback function in the launch code's parameter block.
SysNotifyBroadcastDeferred
to do this so as not to overflow the broadcast stack.
SysHandleEvent
, which means your application event loop might not have progressed to the point where it is possible for you to display a user interface, or you may overflow the stack by displaying a user interface at this stage. See Notification Manager Event Constants to learn which notifications are broadcast during SysHandleEvent
.
Err SysNotifyUnregister(UInt16 cardNo, LocalID dbID, UInt32 notifyType, Int8 priority)
  |
-> |
Number of the storage card on which the application or code resource resides. |
  |
-> |
Local ID of the application or code resource. |
  |
-> |
The event to unregister for. See Notification Manager Event Constants. |
  |
-> |
The priority value you passed as part of SysNotifyRegister . |
Err (*SysNotifyProcPtr) (SysNotifyParamType *notifyParamsP)
  |
-> |
Pointer to a structure that contains the notification event that occurred and any other information about it. See SysNotifyParamType . |
SysNotifyRegister
when registering code that does not have a PilotMain
for a notification. See the description of
SysNotifyRegister
for advice on writing a notification handler.
IMPORTANT: Because thecallbackP
pointer is used to directly call the function, the pointer must remain valid from the timeSysNotifyRegister
is called to the time the notification is broadcast. If the function is in a shared library, you must keep the library open. If the function is in a separately loaded code resource, the resource must remain locked while registered for the notification. When you close a library or unlock a resource, you must first unregister for any notifications. If you don't, the system will crash when the notification is broadcast.
  |   |