Resources | Resources |



System events

Components may need to receive notification of system events such as:

  • Kernel initialization
  • New environment initialization
  • New Brew shell initialization
  • Network acquisition
  • Initial idle screen reached

No one entity is responsible for all these events. In addition, there may be multiple occurrences of some system events, with different scopes. For example, a new environment is created each time a Brew MP application is launched.

A component can register to receive event notifications using the SysEvent primitive in its CIF. In addition to the CIF entry, the component needs to implement the ISysEvent interface.

When an event occurs, OS Services calls the ISysEvent_Notify() function for each component that is registered for the event, passing it a string containing properties for the event. The properties are specified as name=value pairs. The publisher of the event specifies the content of the string in its header file.

Receiving system events

To register for notifications, a component needs to do the following in its CIF:

  • Require AEESysEvent
  • Add a SysEvent primitive

For example:

require "AEESysEvent"

SysEvent {
  notifier = AEEUID_SysEvt_DynMods,
  notified = AEECLSID_ABCD


  • The notifier field of the SysEvent primitive specifies the UID of the event.

    The publisher of the event defines the event UID in its header file.

  • The notified field of the SysEvent primitive specifies the ClassID that will be notified when the event occurs.

    This class must implement ISysEvent. The ISysEvent_Notify() function provided by this implementation serves as a callback function that handles the event.

Sending system events

A component can also create a new event type and send notifications when that event occurs. To do this, the component must define the following in its IDL or .h file:

  • The UID for the event
  • The content of the event string

For example, defines the UID and string for the AEEUID_SysEvt_DynMods event, as follows:

#define AEEUID_SysEvt_DynMods 0x0108f742

The published event string has the following form:
          is a string that specifies the event type (init or done).
          is a string that specifies the module directory and.
          is an integer that specfies the type of collection.

   The "init" event is published before any collection is loaded and 
   the "done" event is published after the collection is loaded.

To send an event, the component needs to do the following:

  • Create an instance of AEECLSID_SYSEVENT by calling IEnv_CreateInstance().
  • Call ISysEvent_Notify() when the new event occurs.