diff --git a/configure.ac b/configure.ac index 81346803e2..14553b9ec2 100644 --- a/configure.ac +++ b/configure.ac @@ -212,6 +212,9 @@ PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.1 dbus-glib-1 >= 0.94) AC_SUBST(DBUS_CFLAGS) AC_SUBST(DBUS_LIBS) +AC_CHECK_LIB([dbus-glib-1], [dbus_g_method_invocation_get_g_connection], ac_have_gmi_get_con="1", ac_have_gmi_get_con="0") +AC_DEFINE_UNQUOTED(HAVE_DBUS_GLIB_GMI_GET_CONNECTION, $ac_have_gmi_get_con, [Define if you have a dbus-glib with dbus_g_method_invocation_get_g_connection()]) + PKG_CHECK_MODULES(GLIB, gio-unix-2.0 >= 2.32 gmodule-2.0) dnl GLIB_VERSION_MIN_REQUIRED should match the version above. diff --git a/src/nm-dbus-manager.c b/src/nm-dbus-manager.c index 34a2f7f817..eacf6d1252 100644 --- a/src/nm-dbus-manager.c +++ b/src/nm-dbus-manager.c @@ -410,3 +410,18 @@ nm_dbus_manager_unregister_object (NMDBusManager *self, gpointer object) dbus_g_connection_unregister_g_object (priv->g_connection, G_OBJECT (object)); } +#if !HAVE_DBUS_GLIB_GMI_GET_CONNECTION +struct _HACKDBusGMethodInvocation { + DBusGConnection *connection; + /* ... */ +}; + +DBusGConnection * +dbus_g_method_invocation_get_g_connection (DBusGMethodInvocation *context) +{ + /* Evil hack; this method exists in dbus-glib >= 101, but if we don't + * have that, emulate it. + */ + return ((struct _HACKDBusGMethodInvocation *) context)->connection; +} +#endif /* HAVE_DBUS_GLIB_GMI_GET_CONNECTION */ diff --git a/src/nm-dbus-manager.h b/src/nm-dbus-manager.h index 0a27f14522..f6e47e1494 100644 --- a/src/nm-dbus-manager.h +++ b/src/nm-dbus-manager.h @@ -22,6 +22,7 @@ #ifndef __NM_DBUS_MANAGER_H__ #define __NM_DBUS_MANAGER_H__ +#include #include #include #include @@ -81,6 +82,10 @@ void nm_dbus_manager_register_object (NMDBusManager *self, void nm_dbus_manager_unregister_object (NMDBusManager *self, gpointer object); +#if !HAVE_DBUS_GLIB_GMI_GET_CONNECTION +DBusGConnection *dbus_g_method_invocation_get_g_connection (DBusGMethodInvocation *context); +#endif + G_END_DECLS #endif /* __NM_DBUS_MANAGER_H__ */