From: Mike Gorse Date: Mon, 21 Mar 2011 18:48:21 +0000 (-0700) Subject: Use libatspi to get the accessibility bus and handle main loop integration X-Git-Tag: AT_SPI2_ATK_2_12_0~248 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fat-spi2-atk.git;a=commitdiff_plain;h=ff4004bdb88bd2a6c4edfb2858188a9880dabb92 Use libatspi to get the accessibility bus and handle main loop integration Remove function to get the accessibility bus, since it was duplicating code in at-spi2-core and should be modified for BGO#644851. Also, use atspi_dbus_*_setup_with_g_main instead of depending on dbus-glib, so that FDO#35115 doesn't show up and we don't need to disable p2p if an old version of dbus-glib is installed. Note that at-spi2-atk now depends on libatspi where previously it did not. --- diff --git a/atk-adaptor/Makefile.include b/atk-adaptor/Makefile.include index e448cd0..b2ef66f 100644 --- a/atk-adaptor/Makefile.include +++ b/atk-adaptor/Makefile.include @@ -1,7 +1,8 @@ gtkmodule_LTLIBRARIES = libatk-bridge.la -libatk_bridge_la_CFLAGS = $(DBUS_GLIB_CFLAGS) \ +libatk_bridge_la_CFLAGS = $(DBUS_CFLAGS) \ $(ATK_CFLAGS) \ + $(ATSPI_CFLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/atk-adaptor/adaptors \ $(P2P_CFLAGS) \ @@ -12,9 +13,11 @@ libatk_bridge_la_LDFLAGS = -no-undefined \ -avoid-version \ -rpath $(gtkmoduledir) -libatk_bridge_la_LIBADD = $(DBUS_GLIB_LIBS) \ +libatk_bridge_la_LIBADD = $(DBUS_LIBS) \ + $(DBUS_LIBS) \ $(GMODULE_LIBS) \ $(ATK_LIBS) \ + $(ATSPI_LIBS) \ $(X_LIBS) \ $(top_builddir)/droute/libdroute.la \ $(top_builddir)/common/libspicommon.la \ diff --git a/atk-adaptor/adaptors/Makefile.am b/atk-adaptor/adaptors/Makefile.am index 6bba900..e34870c 100644 --- a/atk-adaptor/adaptors/Makefile.am +++ b/atk-adaptor/adaptors/Makefile.am @@ -1,14 +1,14 @@ noinst_LTLIBRARIES = libatk-bridge-adaptors.la libatk_bridge_adaptors_la_CFLAGS =\ - $(DBUS_GLIB_CFLAGS) \ + $(DBUS_CFLAGS) \ $(ATK_CFLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/atk-adaptor \ $(P2P_CFLAGS) libatk_bridge_adaptors_la_LIBADD =\ - $(DBUS_GLIB_LIBS) \ + $(DBUS_LIBS) \ $(ATK_LIBS) \ $(X_LIBS) diff --git a/atk-adaptor/bridge.c b/atk-adaptor/bridge.c index 940d244..11ee047 100644 --- a/atk-adaptor/bridge.c +++ b/atk-adaptor/bridge.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "bridge.h" #include "event.h" @@ -101,79 +102,6 @@ spi_display_name (void) /*---------------------------------------------------------------------------*/ -/* - * Gets the IOR from the XDisplay. - * Not currently used in D-Bus version, but something similar - * may be employed in the future for accessing the registry daemon - * bus name. - */ - -static DBusConnection * -spi_atk_bridge_get_bus (void) -{ - Atom AT_SPI_BUS; - Atom actual_type; - Display *bridge_display; - int actual_format; - unsigned char *data = NULL; - unsigned long nitems; - unsigned long leftover; - - DBusConnection *bus = NULL; - DBusError error; - - bridge_display = XOpenDisplay (spi_display_name ()); - if (!bridge_display) - { - g_warning ("AT_SPI: Could not get the display\n"); - return NULL; - } - - AT_SPI_BUS = XInternAtom (bridge_display, "AT_SPI_BUS", False); - XGetWindowProperty (bridge_display, - XDefaultRootWindow (bridge_display), - AT_SPI_BUS, 0L, - (long) BUFSIZ, False, - (Atom) 31, &actual_type, &actual_format, - &nitems, &leftover, &data); - XCloseDisplay (bridge_display); - - dbus_error_init (&error); - - if (data == NULL) - { - g_warning - ("AT-SPI: Accessibility bus not found - Using session bus.\n"); - bus = dbus_bus_get (DBUS_BUS_SESSION, &error); - if (!bus) - { - g_warning ("AT-SPI: Couldn't connect to bus: %s\n", error.message); - return NULL; - } - } - else - { - bus = dbus_connection_open (data, &error); - XFree (data); - if (!bus) - { - g_warning ("AT-SPI: Couldn't connect to bus: %s\n", error.message); - return NULL; - } - else - { - if (!dbus_bus_register (bus, &error)) - { - g_warning ("AT-SPI: Couldn't register with bus: %s\n", error.message); - return NULL; - } - dbus_connection_set_exit_on_disconnect (bus, FALSE); - } - } - - return bus; -} - static void set_reply (DBusPendingCall *pending, void *user_data) { @@ -559,7 +487,7 @@ new_connection_cb (DBusServer *server, DBusConnection *con, void *data) dbus_connection_set_unix_user_function (con, user_check, NULL, NULL); dbus_connection_ref(con); - dbus_connection_setup_with_g_main(con, NULL); + atspi_dbus_connection_setup_with_g_main(con, NULL); droute_intercept_dbus (con); droute_context_register (spi_global_app_data->droute, con); @@ -587,7 +515,7 @@ setup_bus (void) return -1; } - dbus_server_setup_with_g_main(server, NULL); + atspi_dbus_server_setup_with_g_main(server, NULL); dbus_server_set_new_connection_function(server, new_connection_cb, NULL, NULL); spi_global_app_data->server = server; @@ -757,7 +685,7 @@ adaptor_init (gint * argc, gchar ** argv[]) /* Set up D-Bus connection and register bus name */ dbus_error_init (&error); - spi_global_app_data->bus = spi_atk_bridge_get_bus (); + spi_global_app_data->bus = atspi_get_a11y_bus (); if (!spi_global_app_data->bus) { g_free (spi_global_app_data); @@ -787,7 +715,7 @@ adaptor_init (gint * argc, gchar ** argv[]) spi_global_app_data->main_context = NULL; #endif - dbus_connection_setup_with_g_main (spi_global_app_data->bus, NULL); + atspi_dbus_connection_setup_with_g_main (spi_global_app_data->bus, NULL); /* Hook our plug-and socket functions */ install_plug_hooks (); diff --git a/atk-adaptor/event.c b/atk-adaptor/event.c index 2253ec0..3889e75 100644 --- a/atk-adaptor/event.c +++ b/atk-adaptor/event.c @@ -27,6 +27,7 @@ #include #include +#include #include "bridge.h" #include "accessible-register.h" @@ -65,10 +66,10 @@ switch_main_context (GMainContext *cnx) GList *list; - dbus_server_setup_with_g_main (spi_global_app_data->server, cnx); - dbus_connection_setup_with_g_main (spi_global_app_data->bus, cnx); + atspi_dbus_server_setup_with_g_main (spi_global_app_data->server, cnx); + atspi_dbus_connection_setup_with_g_main (spi_global_app_data->bus, cnx); for (list = spi_global_app_data->direct_connections; list; list = list->next) - dbus_connection_setup_with_g_main (list->data, cnx); + atspi_dbus_connection_setup_with_g_main (list->data, cnx); } static void diff --git a/common/Makefile.am b/common/Makefile.am index 066c30c..2732a3d 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -1,12 +1,12 @@ noinst_LTLIBRARIES = libspicommon.la -libspicommon_la_CFLAGS = $(DBUS_GLIB_CFLAGS)\ +libspicommon_la_CFLAGS = $(DBUS_CFLAGS)\ $(ATK_CFLAGS) \ -DATSPI_INTROSPECTION_PATH=\"$(DEFAULT_ATSPI_INTROSPECTION_PATH)\"\ -I$(top_builddir)\ -I$(top_srcdir) -libspicommon_la_LIBADD = $(DBUS_GLIB_LIBS) +libspicommon_la_LIBADD = $(DBUS_LIBS) libspicommon_la_SOURCES = \ bitarray.h \ diff --git a/configure.ac b/configure.ac index f5149ba..cf47a18 100644 --- a/configure.ac +++ b/configure.ac @@ -43,13 +43,6 @@ PKG_CHECK_MODULES(GLIB, [glib-2.0]) AC_SUBST(GLIB_LIBS) AC_SUBST(GLIB_CFLAGS) -PKG_CHECK_MODULES(DBUS_GLIB, dbus-glib-1 >= 0.90, dbus_glib=yes, dbus_glib=no) -if test "x$dbus_glib" = "xno"; then - PKG_CHECK_MODULES(DBUS_GLIB, dbus-glib-1 >= 0.7.0, dbus_glib_old=yes) -fi -AC_SUBST(DBUS_GLIB_LIBS) -AC_SUBST(DBUS_GLIB_CFLAGS) - PKG_CHECK_MODULES(GOBJ, [gobject-2.0 >= 2.0.0]) AC_SUBST(GOBJ_LIBS) AC_SUBST(GOBJ_CFLAGS) @@ -62,6 +55,10 @@ PKG_CHECK_MODULES(ATK, [atk >= 1.29.3]) AC_SUBST(ATK_LIBS) AC_SUBST(ATK_CFLAGS) +PKG_CHECK_MODULES(ATSPI, [atspi-2 >= 1.91.92]) +AC_SUBST(ATSPI_LIBS) +AC_SUBST(ATSPI_CFLAGS) + AC_PATH_XTRA if test x$no_x = xyes ; then @@ -102,10 +99,6 @@ DBIND_CHECK_ALIGNOF(dbind_pointer) DBIND_CHECK_ALIGNOF(dbind_struct) CPPFLAGS=$orig_CPPFLAGS -if test "x$dbus_glib_old" = "xyes"; then - P2P_CFLAGS=-DDISABLE_P2P -fi - if test "x$enable_p2p" = "xno"; then P2P_CFLAGS=-DDISABLE_P2P fi @@ -126,8 +119,3 @@ AC_CONFIG_FILES([Makefile ]) AC_OUTPUT - -if test "x$dbus_glib_old" = "xyes"; then - P2P_CFLAGS=-DDISABLE_P2P - AC_MSG_WARN([found dbus-glib older than 0.90; disabling peer-to-peer support]) -fi diff --git a/droute/Makefile.am b/droute/Makefile.am index 39d6645..38e6b09 100644 --- a/droute/Makefile.am +++ b/droute/Makefile.am @@ -1,6 +1,7 @@ noinst_LTLIBRARIES = libdroute.la -libdroute_la_CFLAGS = $(DBUS_GLIB_CFLAGS) \ +libdroute_la_CFLAGS = $(DBUS_CFLAGS) \ + $(GLIB_CFLAGS) \ -I$(top_builddir)\ -I$(top_srcdir) \ -Werror=implicit-function-declaration @@ -12,16 +13,17 @@ libdroute_la_SOURCES =\ droute-variant.h\ droute-pairhash.c\ droute-pairhash.h -libdroute_la_LIBADD = $(DBUS_GLIB_LIBS) +libdroute_la_LIBADD = $(DBUS_LIBS) TESTS = droute-test check_PROGRAMS = droute-test droute_test_SOURCES = droute-test.c -droute_test_CFLAGS = $(DBUS_GLIB_CFLAGS) \ +droute_test_CFLAGS = $(DBUS_CFLAGS) \ -I$(top_builddir)\ -I$(top_srcdir) droute_test_LDFLAGS = $(top_builddir)/dbind/libdbind.la\ libdroute.la\ - $(DBUS_GLIB_LIBS) + $(DBUS_LIBS) \ + $(ATSPI_LIBS) diff --git a/droute/droute-test.c b/droute/droute-test.c index 33766a2..8701517 100644 --- a/droute/droute-test.c +++ b/droute/droute-test.c @@ -249,7 +249,7 @@ int main (int argc, char **argv) dbus_error_init (&error); main_loop = g_main_loop_new(NULL, FALSE); bus = dbus_bus_get (DBUS_BUS_SESSION, &error); - dbus_connection_setup_with_g_main(bus, g_main_context_default()); + atspi_dbus_connection_setup_with_g_main(bus, g_main_context_default()); cnx = droute_new (bus); path = droute_add_one (cnx, TEST_OBJECT_PATH, object);