General Change Notification: 3.2 System Notification: Handling System Notification

Up: GEOS SDK TechDocs | Up | Prev: 3.1 Registering for System Notification | Next: 3.3 Removal from a System List
MSG_NOTIFY_FILE_CHANGE, MSG_NOTIFY_DRIVE_CHANGE, MSG_NOTIFY_APP_STARTED, MSG_NOTIFY_APP_EXITED, MSG_NOTIFY_USER_DICT_CHANGE, MSG_NOTIFY_EXPRESS_MENU_CHANGE

When an identified change occurs, either the system (or a library) will call the routine GCNListSend() , passing it the appropriate notification message. This routine scans the list of all GCN lists and dispatches notification to all appropriate objects that had requested knowledge of the specified change. If any additional information relating to the change cannot be included in the message, the system allows GCNListSend() to pass data in a global heap block. For example, additional information about a file change (name of file, etc.) must be passed in a global heap block.

The object or process originally requesting notification of the change should be required to handle the appropriate message. If additional data about the change is passed in a global heap block, the process should access that information with MemLock() and MemUnlock() . You should always call the process's superclass in your message handler to make sure that the global heap block will be automatically freed by MetaClass . Therefore, do not free a global heap block manually in a notification handler.

The system provides several messages which you may want to handle. These messages provide notification of file system changes, application start-up or shut-down, system clock changes, etc. These messages are mentioned with the list they correspond to in Registering for System Notification . Messages which require more detailed explanation are also mentioned below.

The kernel sends MSG_NOTIFY_FILE_CHANGE whenever a change to the file system occurs. All objects signed up on the GCN list GCNSLT_FILE_CHANGE will receive this message.

MSG_NOTIFY_FILE_CHANGE passes a FileChangeNotificationType specifying the change that occurred. Some types indicate the presence of a data block (of type FileChangeNotificationData) containing, if applicable, the name of the file changed, the disk handle of the file changed, and the ID of the affected file.

The notification type should be one of the following:

FCNT_CREATE
This type indicates that a file or directory was created. FCND_ id stores the ID of the containing directory; FCND_ name contains the name of the new file or directory that was created.
FCNT_RENAME
This type indicates that a file or directory was renamed. FCND_ id stores the ID of the file or directory that was renamed; FCND_ name contains its new name.
FCNT_OPEN
This type indicates that a file was opened. FCND_ id stores the ID of the file. FCND_ name is undefined, and may or may not be present. (You can check the size of the block to see if it is indeed present.) This notification type is generated after a call to FileEnableOpenCloseNotification() .
FCNT_DELETE
This type indicates that a file or directory was deleted. FCND_ id stores the ID of the file or directory that was deleted. FCND_ name is undefined and may or may not be present.
FCNT_CONTENTS
This type indicates that a file's contents have changed. FCND_ id stores the ID of the file. FCND_ name is undefined and may or may not be present. This notification type is generated after a call to FileCommit() or FileClose() that results in a file modification.
FCNT_ATTRIBUTES
This type indicates that a file's attributes have changed. FCND_ id stores the ID of the file. FCND_ name is undefined and may or may not be present. This notification type is generated upon completion of all changes in a FileSetAttributes() , FileSetHandleExtAttributes() , or FileSetPathExtAttributes() call.
FCNT_DISK_FORMAT
This type indicates that a disk has been formatted. Both FCND_ id and FCND_ name are undefined and may not be present.
FCNT_CLOSE
This type indicates that a file has been closed. FCND _id stores the identifier of the file. FCND _name is undefined and may not be present. This notification type is generated only after a call to FileEnableOpenCloseNotification() .
FCNT_BATCH
This type indicates that this file change notification is actually a group of notifications batched together. In this case, MSG_NOTIFY_FILE_CHANGE passes the MemHandle of a FileChangeBatchNotificationData block instead. This data block stores a batch of FileChangeBatchNotificationItem structures, each referring to an operation (with its own notification type, disk handle, file name, and file ID). Note that in this batched case, you must assume that all file names and file IDs that are optional (i.e. are undefined) are not present.
FCNT_ADD_SP_DIRECTORY
This type indicates that a directory has been added as a StandardPath . FCND_ disk contains the StandardPath that was added. This notification type is generated after a call to FileAddStandardPathDirectory() .
FCNT_DELETE_SP_DIRECTORY
This type indicates that a directory has been deleted as a StandardPath . FCND_ disk contains the StandardPath that was deleted. This notification type is generated after a call to FileDeleteStandardPathDirectory() .

You may access this data (after locking the block) and perform whatever actions you need within your message handler.

The kernel also sends MSG_NOTIFY_DRIVE_CHANGE to GCN lists of type GCNSLT_FILE_CHANGE. This message passes a GCNDriveChangeNotificationType specifying whether a drive is being created or destroyed and the ID of the affected drive.

The kernel sends MSG_NOTIFY_APP_STARTED whenever any application starts up within the system and MSG_NOTIFY_APP_EXITED whenever an application shuts down. All objects signed up on the GCN list GCNSLT_APPLICATION will receive these messages after the change occurs. MSG_NOTIFY_APP_STARTED passes the MemHandle of the application starting up, which you may access to perform any required actions. In a similar manner, MSG_NOTIFY_APP_EXITED passes the MemHandle of the application shutting down.

The kernel sends MSG_NOTIFY_USER_DICT_CHANGE whenever the system changes the current user dictionary in use. All objects signed up for the GCN list GCNSLT_USER_DICT_CHANGE will receive this message after the change occurs. MSG_NOTIFY_USER_DICT_CHANGED passes the MemHandle of the Spell Box causing the change and the MemHandle of the user dictionary being changed, both of which you may access in your message handler.


Up: GEOS SDK TechDocs | Up | Prev: 3.1 Registering for System Notification | Next: 3.3 Removal from a System List