***/
 
 #include <glib.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #define DBUS_API_SUBJECT_TO_CHANGE
 #include <dbus/dbus.h>
 #include <dbus/dbus-glib-lowlevel.h>
                dbus_message_get_member (message));
 
     if (dbus_message_is_signal (message,
+#ifdef DBUS_USE_NEW_API
+                               DBUS_INTERFACE_LOCAL,
+#else
                                 DBUS_INTERFACE_ORG_FREEDESKTOP_LOCAL,
+#endif
                                 "Disconnected"))
     {
         /* No, we shouldn't quit, but until we get somewhere
     {
         return do_register (conn, message);
     } else if (dbus_message_is_signal (message,
+#ifdef DBUS_USE_NEW_API
+                                      DBUS_INTERFACE_DBUS,
+#else
                                        DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS,
+#endif
                                        "ServiceAcquired"))
     {
         char *name;
     dbus_connection_setup_with_g_main (bus, NULL);
     dbus_connection_set_exit_on_disconnect (bus, FALSE);
 
+#ifdef DBUS_USE_NEW_API
+    dbus_bus_request_name (bus, DBUS_SERVICE_AVAHI, 0, &error);
+#else
     dbus_bus_acquire_service (bus, DBUS_SERVICE_AVAHI, 0, &error);
+#endif
 
     if (dbus_error_is_set (&error))
     {
 
         esac],
        [ENABLE_DBUS=yes]) dnl Default value
 
+AC_DEFINE(ENABLE_DBUS, 1, [Whether to use DBUS or not])
+
 if test "x$ENABLE_DBUS" = "xyes"; then
         PKG_CHECK_MODULES(DBUS, [ dbus-glib-1 >= 0.23])
         AC_SUBST(DBUS_CFLAGS)
        AC_SUBST(DBUS_LIBS)
+
+       if pkg-config dbus-1 --atleast-version=0.30 ; then
+               AC_DEFINE(DBUS_USE_NEW_API, 1, [Whether to use the new API for DBUS 0.30])
+       fi
 fi
 
 AM_CONDITIONAL(ENABLE_DBUS, test "x$ENABLE_DBUS" = "xyes")