Chapter 6. Notification

Table of Contents

Some applications may do work in the background while other applications are running in the foreground. For instance, an email client might regularly download new emails even while you are using the web browser. These applications may wish to inform the user about interesting events. For instance, the email application might wish to inform the user that a new email has arrived.

Your application can do this by using the Hildon::Notification class, available in the libhildon-notifymm. It's based on the widely-used libnotify library and standard.

Header files and linking

To use libhildon-notifymm, you must specify hildon-notifymm in the PKG_CHECK_MODULES check in your configure.ac file, just as you already check for hildonmm, for instance. You can then include the hildon-notifymm.h header. See the main Header files and linking section for general details about these techniques.

Your main() function must do some extra initialization before using the Hildon::Notification class. You must call Hildon::notify_init() and it is currently also necessary to initialize D-Bus, as follows:

Hildon::notify_init("Notification example");

DBusConnection* conn = dbus_bus_get (DBUS_BUS_SESSION, NULL);
dbus_connection_setup_with_g_main (conn, NULL);