bus-launcher: integrate launcher with tizen platform. 75/38775/2 tizen_3.0.2015.q2_common accepted/tizen/common/20150511.125639 accepted/tizen/mobile/20150511.133110 accepted/tizen/tv/20150512.050320 accepted/tizen/wearable/20150511.132711 submit/tizen/20150511.014801
authorLukasz Stanislawski <l.stanislaws@samsung.com>
Mon, 27 Apr 2015 08:55:14 +0000 (10:55 +0200)
committerLukasz Stanislawski <l.stanislaws@samsung.com>
Tue, 28 Apr 2015 09:24:47 +0000 (11:24 +0200)
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
bus/at-spi-bus-launcher.c
configure.ac
packaging/at-spi2-core.spec

index 530d231..574e0ad 100644 (file)
@@ -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
index b6bd8e8..67e8bed 100644 (file)
 #include <X11/Xatom.h>
 #endif
 
+#define APP_CONTROL_OPERATION_SCREEN_READ "http://tizen.org/appcontrol/operation/read_screen"
+#include <appsvc.h>
+#include <vconf.h>
+#include <dlog.h>
+#include <aul.h>
+
 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)
index ebbeb3f..bea395d 100644 (file)
@@ -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
 
index e8808ea..a3ecd8e 100644 (file)
@@ -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