From 8b37292698e8765c4141c19b3e5d14b7ec579c80 Mon Sep 17 00:00:00 2001 From: Lukasz Stanislawski Date: Mon, 27 Apr 2015 10:55:14 +0200 Subject: [PATCH] bus-launcher: integrate launcher with tizen platform. at-spi-bus-launcher is now registered on vconf "db/menu/accessbiility/screen_reader" changes and launches applications registered on "read_screen" operation in application service. Change-Id: I7264004c3358654073829faaebb06f24b0a9b4d7 --- bus/Makefile.am | 4 +- bus/at-spi-bus-launcher.c | 89 +++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 11 ++++++ packaging/at-spi2-core.spec | 4 ++ 4 files changed, 106 insertions(+), 2 deletions(-) diff --git a/bus/Makefile.am b/bus/Makefile.am index 530d231..574e0ad 100644 --- a/bus/Makefile.am +++ b/bus/Makefile.am @@ -7,8 +7,8 @@ libexec_PROGRAMS = at-spi-bus-launcher at_spi_bus_launcher_SOURCES = at-spi-bus-launcher.c at_spi_bus_launcher_CPPFLAGS = -DSYSCONFDIR=\"$(sysconfdir)\" \ -DDBUS_DAEMON=\"$(DBUS_DAEMON)\" -at_spi_bus_launcher_CFLAGS = $(GIO_CFLAGS) -at_spi_bus_launcher_LDADD = $(GIO_LIBS) $(X_LIBS) +at_spi_bus_launcher_CFLAGS = $(GIO_CFLAGS) $(APPSVC_CFLAGS) $(VCONF_CFLAGS) $(AUL_CFLAGS) +at_spi_bus_launcher_LDADD = $(GIO_LIBS) $(X_LIBS) $(APPSVC_LIBS) $(VCONF_LIBS) $(AUL_LIBS) default_sessiondir = $(sysconfdir)/xdg/autostart default_session_DATA = at-spi-dbus-bus.desktop diff --git a/bus/at-spi-bus-launcher.c b/bus/at-spi-bus-launcher.c index b6bd8e8..67e8bed 100644 --- a/bus/at-spi-bus-launcher.c +++ b/bus/at-spi-bus-launcher.c @@ -35,6 +35,12 @@ #include #endif +#define APP_CONTROL_OPERATION_SCREEN_READ "http://tizen.org/appcontrol/operation/read_screen" +#include +#include +#include +#include + typedef enum { A11Y_BUS_STATE_IDLE = 0, A11Y_BUS_STATE_READING_ADDRESS, @@ -51,7 +57,11 @@ typedef struct { GSettings *a11y_schema; GSettings *interface_schema; + gboolean screen_reader_needed; + int pid; + A11yBusState state; + /* -1 == error, 0 == pending, > 0 == running */ int a11y_bus_pid; char *a11y_bus_address; @@ -565,6 +575,70 @@ gsettings_key_changed (GSettings *gsettings, const gchar *key, void *user_data) handle_screen_reader_enabled_change (_global_app, new_val, FALSE); } +static gboolean +_launch_screen_reader(A11yBusLauncher *bl) +{ + bundle *kb = NULL; + gboolean ret = FALSE; + + kb = bundle_create(); + if (kb == NULL) + return FALSE; + + appsvc_set_operation(kb, APP_CONTROL_OPERATION_SCREEN_READ); + + bl->pid = appsvc_usr_run_service(kb, 0, NULL, NULL, getuid()); + if (bl->pid >= 0) { + ret = TRUE; + } + + bundle_free(kb); + return ret; +} + +static gboolean +_terminate_screen_reader(A11yBusLauncher *bl) +{ + int ret; + if (bl->pid <= 0) + return FALSE; + + LOGD("terminate process with pid %d", bl->pid); + if (!aul_terminate_pid(bl->pid)) + { + bl->pid = 0; + return TRUE; + } + + LOGD("Unable to terminate process using aul api. Sending SIGTERM signal"); + ret = kill(bl->pid, SIGTERM); + if (!ret) + { + bl->pid = 0; + return TRUE; + } + + LOGD("Unable to terminate process: %d with api or signal.", bl->pid); + return FALSE; +} + +void screen_reader_cb(keynode_t *node, void *user_data) +{ + A11yBusLauncher *bl = user_data; + int ret; + + ret = vconf_keynode_get_bool(node); + if (ret < 0) + return; + + bl->screen_reader_needed = ret; + + if (!bl->screen_reader_needed && (bl->pid > 0)) + _terminate_screen_reader(bl); + else if (bl->screen_reader_needed && (bl->pid <= 0)) + _launch_screen_reader(bl); +} + int main (int argc, char **argv) @@ -637,6 +711,21 @@ main (int argc, _global_app, NULL); + int ret = vconf_get_bool("db/menu/accessibility/screen_reader", &_global_app->screen_reader_needed); + if (ret != 0) + { + LOGD("Could not read 'db/menu/accessibility/screen_reader' key value.\n"); + return FALSE; + } + ret = vconf_notify_key_changed("db/menu/accessibility/screen_reader", screen_reader_cb, _global_app); + if(ret != 0) + { + LOGD("Could not add information level callback\n"); + return FALSE; + } + if (_global_app->screen_reader_needed) + _launch_screen_reader(_global_app); + g_main_loop_run (_global_app->loop); if (_global_app->a11y_bus_pid > 0) diff --git a/configure.ac b/configure.ac index ebbeb3f..bea395d 100644 --- a/configure.ac +++ b/configure.ac @@ -56,6 +56,17 @@ PKG_CHECK_MODULES(GIO, [gio-2.0 >= 2.28]) AC_SUBST(GIO_LIBS) AC_SUBST(GIO_CFLAGS) +PKG_CHECK_MODULES(APPSVC, [appsvc]) +AC_SUBST(APPSVC_LIBS) +AC_SUBST(APPSVC_CFLAGS) + +PKG_CHECK_MODULES(VCONF, [vconf]) +AC_SUBST(VCONF_LIBS) +AC_SUBST(VCONF_CFLAGS) + +PKG_CHECK_MODULES(AUL, [aul]) +AC_SUBST(AUL_LIBS) +AC_SUBST(AUL_CFLAGS) # -------------------------------------------------------------------- # Find DL functionality diff --git a/packaging/at-spi2-core.spec b/packaging/at-spi2-core.spec index e8808ea..a3ecd8e 100644 --- a/packaging/at-spi2-core.spec +++ b/packaging/at-spi2-core.spec @@ -23,6 +23,10 @@ BuildRequires: libX11-devel BuildRequires: libXtst-devel BuildRequires: libXi-devel %endif +BuildRequires: pkgconfig(vconf) +BuildRequires: pkgconfig(appsvc) +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(aul) %description AT-SPI is a general interface for applications to make use of the -- 2.7.4