An example

Suppose that you want to write a screensaver application. You could define a screensaver interface that allows you to write addons containing screensaver functionality. Each addon would have a known interface that the application would use to start, stop, and set options for that particular screensaver. To write such an application, you must perform these general steps with the Addon Interfaces Library:

  1. Determine the mandatory functionality for the application. For each screensaver addon, you need a function that creates and populates an options pane. You may also want a function that initializes the addon and another to uninitialize it to restore any resources acquired during initialization.
  2. Next, you need a function to start and stop the screensaver display. Your interface might look like this:
    typedef struct
        int32_t Initialize(void);
        int32_t Uninitialize(void);
        int32_t *Options(void);
        int32_t Start(void);
        int32_t Stop(void);
    } ScreenSaver;
  3. In your addon, you must declare the available interfaces to allow the AOI library to discover and use them:
    AOInterface_t interfaces[] =
        { "Name", 0, "my_screensaver" },
        { "ScreenSaver", SS_VERSION, &SS2 },
        { "ScreenSaverPrefs", SS_PREFSVERSION, &SSP2 }
        { 0,0,0 }
  4. Your application can use the AOI library to find the available addons (which are loaded DLLs containing the screensavers) that have this set of interfaces. It can then allow the user to select a screensaver (and options for that screensaver) to use.
  5. A screensaver addon might have user-set preferences. In this case, the addon would have a "preferences" interface. The application would display preferences for only those screensavers with a "ScreenSaverPrefs" interface, which might look like this:
    typedef struct
        int32_t LoadPrefs(void);
        int32_t SavePrefs(void);
    } ScreenSaverPrefs;