GNOME Session Daemon

Yesterday I came into the discussion
about proposing libnotify and notification-daemon for inclusion in GNOME 2.10
specifically to the too
many daemons
. So, after some mail exchange with other people,
I started last night to write (by hand while watching TV) a proposal for an extensible daemon process, and here it
is, now in electronic format.

The Daemon: The number of daemons is starting to grow too much, and if
we don’t do something, we’ll end up having lots of them. So, putting a daemon in gnome-session
that can be extended is a possible solution.

gnome-session itself is always running, but since it is an important process that can’t crash,
it makes no sense to allow dlopen’ed code there. So, my proposal is to have a gnome-session-daemon
process which will:

  • start a D-BUS/CORBA interface for other applications to contact it. Things that can be done
    by this interface include loading/unloading of plug-ins, getting the list of loaded/available
    plug-ins, etc.
  • load all extensions from a list of well known directories (.xml files in them).
  • listen to session changes and call extension plug-ins as appropriate.

Extension plug-ins: Extensions are hooks, which are actions defined to be
run on session events (“session_starting”, “session_closing”). They are shared libraries provided
by 3rd parties, accompanied by a XML configuration file which defines the hook part
(“on_session_starting/closing”) and the entry point in the library to be called for
each of those session events, as well as the priority order of the hook, which defines the order
in which the hook entry point will be called.

Example plug-ins include the current gnome-settings-daemon, the Evolution alarm notification
daemon, and any other daemon-like processes (notification daemon, beagled, etc).

Library: gnome-session will provide a libgnome-session library to be used by
3rd parties. This library will include the needed code for loading/managing the available
plug-ins. One of the classes included is:

        class GnomeSessionHook {
	     gboolean invoke (GnomeClient *client);

This class loads the GModule’s for each plug-in and maps the invoke method
to the entry point in the loaded shared library.

This library will also include several utility functions:

        GList *gnome_session_get_hooks ();

This loads all GModule’s and creates GnomeSessionHook objects for each of them (by calling
a gnome_session_hook_new_from_file function).

We also need the ability for applications to load/unload plug-ins as needed. For instance, there
could be a control-center applet that allows users to configure which plug-ins to load and which
to not load. Thus, functions like the following are also to be included in the library:

        gboolean gnome_session_load_hook ()
	gboolean gnome_session_unload_hook ()