INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs REQUIRED
- capi-appfw-application
bundle
+ appcore-efl
+ eldbus
+ elementary
+ ecore
atspi-2
gobject-2.0
+ ecore-x
dlog
vconf
tts
+ capi-media-tone-player
capi-system-device
)
SET(CMAKE_C_FLAGS "${SLP_DEBUG_FLAGS} ${SLP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${SLP_COMPILER_FLAGS}")
SET(CMAKE_CXX_FLAGS "${SLP_DEBUG_FLAGS} ${SLP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${SLP_COMPILER_FLAGS}")
-MESSAGE(${CMAKE_C_FLAGS})
-
ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} ${SLP_LD_PATH_FLAGS} ${SLP_LD_FLAGS} ${SLP_LINKER_FLAGS})
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
INSTALL(DIRECTORY ${RESOURCE_DIR}/icons DESTINATION res)
# Install Manifest File
-INSTALL(FILES org.tizen.screen-reader.xml DESTINATION /usr/share/packages)
+INSTALL(FILES org.tizen.screen-reader.xml DESTINATION /opt/share/packages)
+
ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/tests)
-ADD_TEST(NAME screen_reader_test_suite COMMAND ${CMAKE_SOURCE_DIR}/tests/screen_reader_test_suite)
+ADD_TEST(NAME smart_navi_tests COMMAND ${CMAKE_SOURCE_DIR}/tests/smart_navi_test_suite)
# END OF A FILE
--- /dev/null
+Before running smart navigator extend /usr/lib/systemd/system/pulseaudio.service
+[Service]
+...
+ExecStartPre=/bin/chmod 777 /tmp/pulseaudio
+...
+To give other processes like smart-navigator access to pulseaudio tmp.
+
+Extending service with User=pulse or changing owner ship on /tmp/pulseaudio
+results with malfunction of service.
--- /dev/null
+#ifndef COMMON_HELPERS_H_
+#define COMMON_HELPERS_H_
+
+#include <dlog.h>
+
+#ifdef DEBUG
+ #define PLOG(fmt, ...) \
+ fprintf(stderr, "<D> %s(%d) --> ", __FUNCTION__, __LINE__); \
+ fprintf(stderr, fmt, ##__VA_ARGS__);\
+ fprintf(stderr, "\n");\
+ LOGD(fmt, ##__VA_ARGS__);
+
+ #define PLOGD(fmt, ...) \
+ PLOG(fmt, ##__VA_ARGS__)
+
+ #define PLOGW(fmt, ...) \
+ fprintf(stderr, "<W> %s(%d) --> ", __FUNCTION__, __LINE__); \
+ fprintf(stderr, fmt, ##__VA_ARGS__);\
+ fprintf(stderr, "\n");\
+ LOGD(fmt, ##__VA_ARGS__);
+
+ #define PLOGE(fmt, ...) \
+ fprintf(stderr, "<E> %s(%d) --> ", __FUNCTION__, __LINE__); \
+ fprintf(stderr, fmt, ##__VA_ARGS__);\
+ fprintf(stderr, "\n");\
+ LOGD(fmt, ##__VA_ARGS__);
+
+ #define PLOGI(fmt, ...) \
+ fprintf(stderr, "<I> %s(%d) --> ", __FUNCTION__, __LINE__); \
+ fprintf(stderr, fmt, ##__VA_ARGS__);\
+ fprintf(stderr, "\n");\
+ LOGD(fmt, ##__VA_ARGS__);
+
+#else
+
+ #define PLOG(fmt, ...) \
+ LOGD(fmt, ##__VA_ARGS__);
+
+ #define PLOGD(fmt, ...) \
+ PLOG(fmt, ##__VA_ARGS__);
+
+ #define PLOGW(fmt, ...) \
+ LOGW(fmt, ##__VA_ARGS__);
+
+ #define PLOGE(fmt, ...) \
+ LOGE(fmt, ##__VA_ARGS__);
+
+ #define PLOGI(fmt, ...) \
+ LOGI(fmt, ##__VA_ARGS__);\
+
+#endif
+
+#endif /* COMMON_HELPERS_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DBG_H__
+
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "org.tizen.clientDBusWrapper"
+
+#ifndef _ERR
+#define _ERR(fmt, args...) LOGE("[%s:%d] "fmt"\n", __func__, __LINE__, ##args)
+#endif
+
+#ifndef _DBG
+#define _DBG(fmt, args...) LOGD("[%s:%d] "fmt"\n", __func__, __LINE__, ##args)
+#endif
+
+#ifndef _INFO
+#define _INFO(fmt, args...) LOGI("[%s:%d] "fmt"\n", __func__, __LINE__, ##args)
+#endif
+
+
+#endif /* __DBG_H__ */
--- /dev/null
+#ifndef __ETEST_H__
+#define __ETEST_H__
+
+#include <Elementary.h>
+#include <Ecore_X.h>
+#include <Elementary.h>
+#include <Evas.h>
+
+struct appdata {
+ Evas_Object *win;
+};
+
+#endif
\ No newline at end of file
#define FLAT_NAVI_H_
#include <atspi/atspi.h>
+#include <Eina.h>
typedef struct _FlatNaviContext FlatNaviContext;
*
* @return EINA_TRUE is operation successed, EINA_FALSE otherwise
*/
-gboolean flat_navi_context_current_set(FlatNaviContext *ctx, AtspiAccessible *target);
+Eina_Bool flat_navi_context_current_set(FlatNaviContext *ctx, AtspiAccessible *target);
/**
* Advances to previous line in natural reading order and returns
--- /dev/null
+#include <eldbus-1/Eldbus.h>
+#include <atspi/atspi.h>
+
+/**
+ * @brief Accessibility gestures
+ */
+enum _Gesture {
+ ONE_FINGER_HOVER,
+ TWO_FINGERS_HOVER,
+ ONE_FINGER_FLICK_LEFT,
+ ONE_FINGER_FLICK_RIGHT,
+ ONE_FINGER_FLICK_UP,
+ ONE_FINGER_FLICK_DOWN,
+ THREE_FINGERS_FLICK_LEFT,
+ THREE_FINGERS_FLICK_RIGHT,
+ THREE_FINGERS_FLICK_UP,
+ THREE_FINGERS_FLICK_DOWN,
+ ONE_FINGER_SINGLE_TAP,
+ ONE_FINGER_DOUBLE_TAP,
+ TWO_FINGERS_FLICK_UP,
+ TWO_FINGERS_FLICK_LEFT,
+ TWO_FINGERS_FLICK_RIGHT,
+ TWO_FINGERS_FLICK_DOWN,
+ GESTURES_COUNT,
+};
+typedef enum _Gesture Gesture;
+
+typedef struct {
+ Gesture type; // Type of recognized gesture
+ int x_begin, x_end; // (x,y) coordinates when gesture begin
+ int y_begin, y_end; // (x,y) coordinates when gesture ends
+ int state; // 0 - gesture begins, 1 - continues, 2 - ended
+} Gesture_Info;
+
+
+typedef void (*Gesture_Tracker_Cb) (void *data, Gesture_Info *g);
+void gesture_tracker_init(Eldbus_Connection *conn);
+void gesture_tracker_register(Gesture_Tracker_Cb cb, void *data);
+void gesture_tracker_shutdown(void);
+AtspiAccessible* _get_active_win(void);
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+#ifndef LOGGER_H_
+#define LOGGER_H_
-#ifndef _LOGGER_H_
+#include <eina_log.h>
-#include <dlog.h>
+extern int _eina_log_dom;
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "SmartNavigator"
+int logger_init(void);
+void logger_shutdown(void);
-#ifndef ERROR
-#define ERROR(fmt, arg...) LOGE("[%s:%d]:" fmt, __FILE__, __LINE__, ##arg)
-#endif
+#define INFO(...) EINA_LOG_DOM_INFO(_eina_log_dom, __VA_ARGS__);
+#define DEBUG(...) EINA_LOG_DOM_DBG(_eina_log_dom, __VA_ARGS__);
+#define ERROR(...) EINA_LOG_DOM_ERR(_eina_log_dom, __VA_ARGS__);
+#define WARNING(...) EINA_LOG_DOM_WRN(_eina_log_dom, __VA_ARGS__);
-#ifndef DEBUG
-#define DEBUG(fmt, arg...) LOGD("[%s:%d]:" fmt, __FILE__, __LINE__, ##arg)
-#endif
+#define MEMORY_ERROR "Memory allocation error"
-#ifndef INFO
-#define INFO(fmt, arg...) LOGI("[%s:%d]:" fmt, __FILE__, __LINE__, ##arg)
-#endif
-
-
-#endif /* _LOGGER_H_ */
+#endif /* end of include guard: LOGGER_H_ */
#include <atspi/atspi.h>
/**
- * @brief Heuristic choosing first element of the UI.
+ * @brief Some heuristic choosing candidate to reacieve highlight.
*
* @param win Accessibility search tree object root.
*
#define SMART_NAVI_POSITION_SORT_H_
#include <atspi/atspi.h>
-#include <glib.h>
+#include <Eina.h>
/**
*
* @ret list List of lists
*/
-GList *position_sort(const GList *obj);
+Eina_List *position_sort(const Eina_List *obj);
#endif /* end of include guard: POSITION_SORT_H_ */
#define __screen_reader_H__
#include <atspi/atspi.h>
+#include <Eldbus.h>
#include <tts.h>
#define LAN_NAME 6
#define FOCUS_SIG "focused"
-#define EDITING_STARTED "Editing"
-
#define FOCUS_CHANGED_SIG "object:state-changed:focused"
#define VALUE_CHANGED_SIG "object:property-change:accessible-value"
#define CARET_MOVED_SIG "object:text-caret-moved"
//Set by tts
tts_h tts;
- GList *available_languages;
+ Eina_List *available_languages;
char *text_to_say_info;
char *current_value;
bool update_language_list;
//Set by spi
+ AtspiEventListener *state_changed_listener;
+ AtspiEventListener *value_changed_listener;
+ AtspiEventListener *caret_moved_listener;
AtspiEventListener *spi_listener;
AtspiAccessible *currently_focused;
AtspiAccessible *clicked_widget;
//Set by dbus
+ Eldbus_Proxy *proxy;
char **last_tokens;
char *available_requests;
char **available_apps;
-/*
- * screen_reader_spi.h
- *
- * Created on: Feb 20, 2014
- * Author: m.skorupinsk
- */
-
#ifndef SCREEN_READER_SPI_H_
#define SCREEN_READER_SPI_H_
-/*
- * screen_reader_tts.h
- *
- * Created on: Feb 19, 2014
- * Author: m.skorupinsk
- */
-
#ifndef SCREEN_READER_TTS_H_
#define SCREEN_READER_TTS_H_
bool tts_init(void *data);
void state_changed_cb(tts_h tts, tts_state_e previous, tts_state_e current, void* user_data);
-gboolean tts_speak(char *text_to_speak, gboolean flush_switch);
+Eina_Bool tts_speak(char *text_to_speak, Eina_Bool flush_switch);
void spi_stop(void *data);
#endif /* SCREEN_READER_TTS_H_ */
-/*
- * screen_reader_vconf.h
- *
- * Created on: Feb 19, 2014
- * Author: m.skorupinsk
- */
-
#ifndef SCREEN_READER_VCONF_H_
#define SCREEN_READER_VCONF_H_
* @brief Type of notification events.
*
* @FOCUS_CHAIN_END_NOTIFICATION_EVENT emitted when
- * currnetly focued widget is the last one
+ * currnetly focued or highlighted widget is the last one
* in focus chain for application current view.
*
* @REALIZED_ITEMS_NOTIFICATION_EVENT
<manifest>
- <request>
- <domain name="_"/>
- </request>
+ <define>
+ <domain name="screen-reader" />
+ <permit>
+ <smack permit="dbus" type="rwx" />
+ <smack permit="atspi" type="rwx" />
+ <smack permit="e17" type="rwx" />
+ <smack permit="tts-server" type="rwx" />
+ <smack permit="deviced" type="rwx" />
+ <smack permit="sensord" type="rwx" />
+ <smack permit="media-server" type="rwx" />
+ </permit>
+ <request>
+ <smack request="sdbd" type="rwx" />
+ <smack request="atspi" type="rwx" />
+ <smack request="dbus" type="rwx" />
+ <smack request="xorg" type="rwx" />
+ <smack request="pulseaudio" type="rwxat" />
+ <smack request="pkgmgr::db" type="rwx" />
+ <smack request="device::app_logging" type="rwx" />
+ <smack request="ail::db" type="rwx" />
+ <smack request="system::vconf" type="rwx" />
+ <smack request="system::vconf_setting" type="rwx" />
+ <smack request="system::vconf_system" type="rwx" />
+ <smack request="system::vconf_inhouse" type="rwx" />
+ <smack request="system::vconf_multimedia" type="rwx" />
+ <smack request="system::vconf_misc" type="rwx" />
+ <smack request="isf" type="rwx" />
+ <smack request="system::homedir" type="rwx" />
+ <smack request="system::tmpdir" type="rwx" />
+ <smack request="sys-assert::core" type="rwxat" />
+ <smack request="device::sys_logging" type="rwx" />
+ <smack request="svi-data" type="rwx" />
+ <smack request="e17" type="rwx" />
+ <smack request="tts-server" type="rwx" />
+ <smack request="sound_server" type="rwx" />
+ <smack request="deviced" type="rwx" />
+ <smack request="sensord" type="rwx" />
+ <smack request="media-server" type="rwx" />
+ </request>
+ </define>
+
+<request>
+<domain name="screen-reader"/>
+</request>
</manifest>
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.screen-reader" version="0.1.0" install-location="internal-only">
<label>screen-reader</label>
- <description>SCREEN READER</description>
+ <description>SMART NAVIGATOR</description>
<ui-application appid="org.tizen.screen-reader" exec="/usr/apps/org.tizen.screen-reader/bin/screen-reader" nodisplay="false" multiple="false" type="capp" taskmanage="true">
<label>screen-reader</label>
<icon>/usr/apps/org.tizen.screen-reader/res/icons/screen-reader.png</icon>
+%define AppInstallPath /usr/apps/%{name}
+%define Exec screen-reader
+
+
Name: org.tizen.screen-reader
Summary: Empty app
Version: 0.0.1
Release: 1
-Group: Applications/Core Applications
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
BuildRequires: at-spi2-core
BuildRequires: at-spi2-core-devel
BuildRequires: cmake
-BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(appcore-efl)
+BuildRequires: pkgconfig(ecore)
+BuildRequires: pkgconfig(ecore-x)
+BuildRequires: pkgconfig(eina)
+BuildRequires: pkgconfig(eldbus)
+BuildRequires: pkgconfig(elementary)
+BuildRequires: pkgconfig(capi-media-tone-player)
BuildRequires: pkgconfig(capi-system-device)
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(vconf)
-BuildRequires: pkgconfig(bundle)
BuildRequires: tts
BuildRequires: tts-devel
BuildRequires: vconf
BuildRequires: pkgconfig(check)
-%define AppInstallPath /usr/apps/%{name}
-%define Exec screen-reader
-
-
%description
An utility library for developers of the menu screen.
%post
/sbin/ldconfig
-vconftool set -t string db/setting/accessibility/language "en_US"
-vconftool set -t int db/setting/accessibility/information_level 2
-vconftool set -t int db/setting/accessibility/voice 1
-vconftool set -t string db/setting/accessibility/tracking_signal "focused"
+vconftool set -t string db/setting/accessibility/language "en_US" -u 5000 -s screen-reader -f
+vconftool set -t int db/setting/accessibility/information_level 2 -u 5000 -s screen-reader -f
+vconftool set -t int db/setting/accessibility/voice 1 -u 5000 -s screen-reader -f
+vconftool set -t string db/setting/accessibility/tracking_signal "focused" -u 5000 -s screen-reader -f
%postun -p /sbin/ldconfig
%manifest org.tizen.screen-reader.manifest
%{AppInstallPath}/bin/screen-reader
%{AppInstallPath}/res/icons/screen-reader.png
-/usr/share/packages/%{name}.xml
+/opt/share/packages/%{name}.xml
#include "position_sort.h"
#include "object_cache.h"
#include "logger.h"
-#include <glib.h>
-#include <stdlib.h>
struct _FlatNaviContext {
AtspiAccessible *root;
- GList *current;
- GList *current_line;
- GList *lines;
- GList *candidates;
+ Eina_List *current;
+ Eina_List *current_line;
+ Eina_List *lines;
+ Eina_List *candidates;
};
static const AtspiStateType required_states[] = {
- ATSPI_STATE_VISIBLE,
- ATSPI_STATE_SHOWING,
ATSPI_STATE_LAST_DEFINED
};
ATSPI_ROLE_COMBO_BOX,
ATSPI_ROLE_DATE_EDITOR,
ATSPI_ROLE_FILE_CHOOSER,
+ ATSPI_ROLE_FILLER,
ATSPI_ROLE_FONT_CHOOSER,
ATSPI_ROLE_HEADER,
ATSPI_ROLE_HEADING,
/**
* @brief Returns a list of all descendants objects
*
- * @return GList of AtspiAccessible* type. List Should be
+ * @return Eina_List of AtspiAccessible* type. List Should be
* be free with _accessible_list_free after usage
*
* @note obj parameter will also be included (in list head)
* @note every obj has increased ref. call g_object_unref on every
* object after usage.
*/
-static GList*
+static Eina_List*
_descendants_list_get(AtspiAccessible *obj)
{
- GList *ret = NULL, *toprocess = NULL;
+ Eina_List *ret = NULL, *toprocess = NULL;
int i;
if (!obj) return NULL;
// to keep all refcounts in ret list +1
g_object_ref(obj);
- toprocess = g_list_append(toprocess, obj);
+ toprocess = eina_list_append(toprocess, obj);
while (toprocess)
{
- AtspiAccessible *obj = toprocess->data;
- toprocess = g_list_delete_link(toprocess, toprocess);
+ AtspiAccessible *obj = eina_list_data_get(toprocess);
+ toprocess = eina_list_remove_list(toprocess, toprocess);
int n = atspi_accessible_get_child_count(obj, NULL);
for (i = 0; i < n; i++)
{
AtspiAccessible *child = atspi_accessible_get_child_at_index(obj, i, NULL);
- if (child) toprocess = g_list_append(toprocess, child);
+ if (child) toprocess = eina_list_append(toprocess, child);
}
- ret = g_list_append(ret, obj);
+ ret = eina_list_append(ret, obj);
}
return ret;
}
static void
-_accessible_list_free(GList *d)
+_accessible_list_free(Eina_List *d)
{
- for (; d != NULL; d = d->next)
- g_object_unref(d->data);
+ AtspiAccessible *obj;
+
+ EINA_LIST_FREE(d, obj)
+ g_object_unref(obj);
}
typedef struct {
- GList *success;
- GList *failure;
+ Eina_List *success;
+ Eina_List *failure;
} FilterResult;
-typedef gboolean (*Filter_Each_Cb)(const void *container, void *data, void *fdata);
-
static FilterResult
-_accessible_list_split_with_filter(GList *list, Filter_Each_Cb cb, void *user_data)
+_accessible_list_split_with_filter(Eina_List *list, Eina_Each_Cb cb, void *user_data)
{
+
+ DEBUG("START");
FilterResult ret = { NULL, NULL};
- GList *l;
+ Eina_List *l, *ln;
AtspiAccessible *obj;
- for (l = list; l; l = l->next)
+ EINA_LIST_FOREACH_SAFE(list, l, ln, obj)
{
- obj = l->data;
- gboolean res = cb(NULL, user_data, obj);
+ Eina_Bool res = cb(NULL, user_data, obj);
if (res)
- ret.success = g_list_append(ret.success, obj);
+ eina_list_move_list(&ret.success, &list, l);
else
- ret.failure = g_list_append(ret.failure, obj);
+ eina_list_move_list(&ret.failure, &list, l);
}
- g_list_free(list);
+ DEBUG("END");
return ret;
}
-static gboolean
+static Eina_Bool
_filter_state_cb(const void *container, void *data, void *fdata)
{
+ DEBUG("START");
+
AtspiStateType *state = data;
- gboolean ret = TRUE;
+ Eina_Bool ret = EINA_TRUE;
AtspiAccessible *obj = fdata;
AtspiStateSet *ss = atspi_accessible_get_state_set(obj);
{
if (!atspi_state_set_contains(ss, *state))
{
- ret = FALSE;
+ ret = EINA_FALSE;
+ DEBUG("BREAK, NO STATES SUIABLE FOR OBJ");
break;
}
state++;
}
g_object_unref(ss);
+ DEBUG("END");
return ret;
}
-static gboolean
+static Eina_Bool
_filter_role_cb(const void *container, void *data, void *fdata)
{
+ DEBUG("START");
AtspiRole *role = data;
- gboolean ret = FALSE;
+ Eina_Bool ret = EINA_FALSE;
AtspiAccessible *obj = fdata;
while (*role != ATSPI_ROLE_LAST_DEFINED)
{
if (atspi_accessible_get_role(obj, NULL) == *role)
{
- ret = TRUE;
+ ret = EINA_TRUE;
+ DEBUG("END");
break;
}
role++;
}
-
+ DEBUG("END WITH FALSE");
return ret;
}
-static inline gboolean
+static inline Eina_Bool
_rectangle_intersect(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2)
{
return !(((y1 + h1) <= y2) || (y1 >= (y2 + h2)) || ((x1 + w1) <= x2) || (x1 >= (x2 + w2)));
}
-static gboolean
+static Eina_Bool
_filter_viewport_cb(const void *container, void *data, void *fdata)
{
const ObjectCache *oc, *ocr = data;
oc = object_cache_get(obj);
if (!oc || !oc->bounds || (oc->bounds->height < 0) || (oc->bounds->width < 0))
- return FALSE;
+ return EINA_FALSE;
// at least one pixel of child have to be in viewport
return _rectangle_intersect(ocr->bounds->x, ocr->bounds->y, ocr->bounds->width, ocr->bounds->height,
oc->bounds->x, oc->bounds->y, oc->bounds->width, oc->bounds->height);
}
-static GList*
+static Eina_List*
_flat_review_candidates_get(AtspiAccessible *root)
{
- GList *desc, *ret = NULL;
+ Eina_List *desc, *ret = NULL;
FilterResult fr0;
desc = _descendants_list_get(root);
- DEBUG("Descendants: %d", g_list_length(desc));
-
+ DEBUG("All descendants: %d", eina_list_count(desc));
+ Eina_List *l, *ln;
+ AtspiAccessible *obj;
+ AtspiStateSet *st = NULL;
+ GArray *states = NULL;
+ int a;
+
+/*
+ DEBUG("Przed lista");
+ EINA_LIST_FOREACH_SAFE(desc, l, ln, obj) {
+ DEBUG("Role: %s, Name:%s", atspi_accessible_get_name(obj, NULL), atspi_accessible_get_role_name(obj, NULL));
+ st = atspi_accessible_get_state_set (obj);
+ states = atspi_state_set_get_states (st);
+ DEBUG("Has states:%d", states->len);
+ for (a = 0; a < states->len; ++a) {
+ DEBUG("%d", g_array_index (states, AtspiStateType, a));
+ }
+
+ }
+ DEBUG("Po liscie");
+*/
// remove object that are not in root's viewport
const ObjectCache *oc = object_cache_get(root);
if (!oc || !oc->bounds || (oc->bounds->height < 0) || (oc->bounds->width < 0))
// get 'interesting' objects
FilterResult fr2 = _accessible_list_split_with_filter(fr1.success, _filter_role_cb, (void*)interesting_roles);
- ret = g_list_concat(ret, fr2.success);
+ ret = eina_list_merge(ret, fr2.success);
_accessible_list_free(fr2.failure);
- DEBUG("Candidates: %d", g_list_length(ret));
+ DEBUG("Candidates: %d", eina_list_count(ret));
+ EINA_LIST_FOREACH_SAFE(ret, l, ln, obj) {
+ DEBUG("Role: %s, Name:%s", atspi_accessible_get_name(obj, NULL), atspi_accessible_get_role_name(obj, NULL));
+ st = atspi_accessible_get_state_set (obj);
+ states = atspi_state_set_get_states (st);
+ DEBUG("Has states:%d", states->len);
+ for (a = 0; a < states->len; ++a) {
+ DEBUG("%d", g_array_index (states, AtspiStateType, a));
+ }
+
+ }
return ret;
}
static void
debug(FlatNaviContext *ctx)
{
- GList *l1, *l2, *line;
+ Eina_List *l1, *l2, *line;
AtspiAccessible *obj;
int i, l = 0;
DEBUG("===============================");
- for (l1 = ctx->lines; l1 != NULL; l1 = l1->next)
+ EINA_LIST_FOREACH(ctx->lines, l1, line)
{
- line = l1->data;
i = 0;
DEBUG("==== Line %d ====", l);
- for (l2 = line; l2 != NULL; l2 = l2->next)
+ EINA_LIST_FOREACH(line, l2, obj)
{
- obj = l2->data;
char *name = atspi_accessible_get_name(obj, NULL);
char *role = atspi_accessible_get_role_name(obj, NULL);
const ObjectCache *oc = object_cache_get(obj);
- if (oc) {
DEBUG("%d %s %s, (%d %d %d %d)", i++, name, role,
oc->bounds->x, oc->bounds->y, oc->bounds->width, oc->bounds->height);
- }
if (name) g_free(name);
if (role) g_free(role);
}
ret->candidates = _flat_review_candidates_get(root);
ret->lines = position_sort(ret->candidates);
ret->current_line = ret->lines;
- ret->current = ret->current_line ? ret->current_line->data : NULL;
+ ret->current = eina_list_data_get(ret->current_line);
debug(ret);
void flat_navi_context_free(FlatNaviContext *ctx)
{
- GList *l;
- for (l = ctx->lines; l != NULL; l = l->next)
- g_list_free((GList*)l->data);
+ Eina_List *l;
+ EINA_LIST_FREE(ctx->lines, l)
+ eina_list_free(l);
_accessible_list_free(ctx->candidates);
free(ctx);
}
AtspiAccessible *flat_navi_context_current_get(FlatNaviContext *ctx)
{
- if (!ctx || !ctx->lines) return NULL;
- return ctx->current->data;
+ if(!ctx) return NULL;
+
+ return eina_list_data_get(ctx->current);
}
-gboolean flat_navi_context_current_set(FlatNaviContext *ctx, AtspiAccessible *target)
+Eina_Bool flat_navi_context_current_set(FlatNaviContext *ctx, AtspiAccessible *target)
{
- if(!ctx || !target) return FALSE;
+ if(!ctx || !target) return EINA_FALSE;
- GList *l, *l2, *line;
+ Eina_List *l, *l2, *line;
AtspiAccessible *obj;
- gboolean found = FALSE;
+ Eina_Bool found = EINA_FALSE;
- for (l = ctx->lines; l; l = l->next)
+ EINA_LIST_FOREACH(ctx->lines, l, line)
{
- line = l->data;
- for (l2 = line; l2; l2 = l2->next)
- {
- obj = l2->data;
- if (obj == target)
- {
- found = TRUE;
- break;
- }
- }
+ EINA_LIST_FOREACH(line, l2, obj)
+ if (obj == target)
+ {
+ found = EINA_TRUE;
+ break;
+ }
if (found)
{
ctx->current_line = l;
AtspiAccessible *flat_navi_context_next(FlatNaviContext *ctx)
{
- if (!ctx || !ctx->lines) return NULL;
- GList *ret = ctx->current->next;
+ if(!ctx) return NULL;
+
+ Eina_List *ret = eina_list_next(ctx->current);
if (ret)
{
ctx->current = ret;
- return ctx->current->data;
+ return eina_list_data_get(ctx->current);
}
return NULL;
}
AtspiAccessible *flat_navi_context_prev(FlatNaviContext *ctx)
{
- if (!ctx || !ctx->lines) return NULL;
- GList *ret = ctx->current->prev;
+ if(!ctx) return NULL;
+
+ Eina_List *ret = eina_list_prev(ctx->current);
if (ret)
{
ctx->current = ret;
- return ctx->current->data;
+ return eina_list_data_get(ctx->current);
}
return NULL;
}
AtspiAccessible *flat_navi_context_first(FlatNaviContext *ctx)
{
- if (!ctx || !ctx->lines) return NULL;
- GList *ret = ctx->current_line->data;
+ if(!ctx) return NULL;
+
+ Eina_List *ret = eina_list_data_get(ctx->current_line);
if (ret)
{
ctx->current = ret;
- return ctx->current->data;
+ return eina_list_data_get(ctx->current);
}
return NULL;
}
AtspiAccessible *flat_navi_context_last(FlatNaviContext *ctx)
{
- if (!ctx || !ctx->lines) return NULL;
- GList *ret = g_list_last(ctx->current);
+ if(!ctx) return NULL;
+
+ Eina_List *ret = eina_list_last(ctx->current);
if (ret)
{
ctx->current = ret;
- return ctx->current->data;
+ return eina_list_data_get(ctx->current);
}
return NULL;
}
AtspiAccessible *flat_navi_context_line_next(FlatNaviContext *ctx)
{
- if (!ctx || !ctx->lines) return NULL;
+ if(!ctx) return NULL;
- GList *ret = ctx->current_line->next;
+ Eina_List *ret = eina_list_next(ctx->current_line);
if (!ret) return NULL;
ctx->current_line = ret;
- ctx->current = ctx->current_line->data;
+ ctx->current = eina_list_data_get(ctx->current_line);
- return ctx->current->data;
+ return eina_list_data_get(ctx->current);
}
AtspiAccessible *flat_navi_context_line_prev(FlatNaviContext *ctx)
{
- if (!ctx || !ctx->lines) return NULL;
+ if(!ctx) return NULL;
- GList *ret = ctx->current_line->prev;
+ Eina_List *ret = eina_list_prev(ctx->current_line);
if (!ret) return NULL;
ctx->current_line = ret;
- ctx->current = ctx->current_line->data;
+ ctx->current = eina_list_data_get(ctx->current_line);
- return ctx->current->data;
+ return eina_list_data_get(ctx->current);
}
AtspiAccessible *flat_navi_context_line_first(FlatNaviContext *ctx)
{
- if (!ctx || !ctx->lines) return NULL;
+ if(!ctx) return NULL;
+
+ Eina_List *ret = ctx->lines;
- ctx->current_line = ctx->lines;
- ctx->current = ctx->current_line->data;
+ ctx->current_line = ret;
+ ctx->current = eina_list_data_get(ctx->current_line);
- return ctx->current->data;
+ return eina_list_data_get(ctx->current);
}
AtspiAccessible *flat_navi_context_line_last(FlatNaviContext *ctx)
{
- if (!ctx || !ctx->lines) return NULL;
+ if(!ctx) return NULL;
- ctx->current_line = g_list_last(ctx->current_line);
- ctx->current = ctx->current_line->data;
+ Eina_List *ret = eina_list_last(ctx->current_line);
+
+ ctx->current_line = ret;
+ ctx->current = eina_list_data_get(ctx->current_line);
- return ctx->current->data;
+ return eina_list_data_get(ctx->current);
}
--- /dev/null
+#include <string.h>
+#include "gesture_tracker.h"
+#include "logger.h"
+
+#define BUS "com.samsung.EModule"
+#define INTERFACE "com.samsung.GestureNavigation"
+#define PATH "/com/samsung/GestureNavigation"
+#define SIGNAL "GestureDetected"
+
+static Eldbus_Connection *a11y_conn;
+static Eldbus_Object *object;
+static Eldbus_Proxy *man;
+static Gesture_Tracker_Cb user_cb;
+static void *user_data;
+
+static Gesture gesture_name_to_enum (const char *gesture_name)
+{
+ if(!gesture_name)
+ return GESTURES_COUNT;
+
+ DEBUG("Dbus incoming gesture: %s", gesture_name);
+
+ if(!strcmp("OneFingerHover", gesture_name))
+ return ONE_FINGER_HOVER;
+
+ if(!strcmp("TwoFingersHover", gesture_name))
+ return TWO_FINGERS_HOVER;
+
+ if(!strcmp("OneFingerFlickLeft", gesture_name))
+ return ONE_FINGER_FLICK_LEFT;
+
+ if(!strcmp("OneFingerFlickRight", gesture_name))
+ return ONE_FINGER_FLICK_RIGHT;
+
+ if(!strcmp("OneFingerFlickUp", gesture_name))
+ return ONE_FINGER_FLICK_UP;
+
+ if(!strcmp("OneFingerFlickDown", gesture_name))
+ return ONE_FINGER_FLICK_DOWN;
+
+ if(!strcmp("ThreeFingersFlickLeft", gesture_name))
+ return THREE_FINGERS_FLICK_LEFT;
+
+ if(!strcmp("ThreeFingersFlickRight", gesture_name))
+ return THREE_FINGERS_FLICK_RIGHT;
+
+ if(!strcmp("ThreeFingersFlickUp", gesture_name))
+ return THREE_FINGERS_FLICK_UP;
+
+ if(!strcmp("ThreeFingersFlickDown", gesture_name))
+ return THREE_FINGERS_FLICK_DOWN;
+
+ if(!strcmp("OneFingerSingleTap", gesture_name))
+ return ONE_FINGER_SINGLE_TAP;
+
+ if(!strcmp("OneFingerDoubleTap", gesture_name))
+ return ONE_FINGER_DOUBLE_TAP;
+
+ if(!strcmp("TwoFingersFlickLeft", gesture_name))
+ return TWO_FINGERS_FLICK_LEFT;
+
+ if(!strcmp("TwoFingersFlickRight", gesture_name))
+ return TWO_FINGERS_FLICK_RIGHT;
+
+ if(!strcmp("TwoFingersFlickUp", gesture_name))
+ return TWO_FINGERS_FLICK_UP;
+
+ if(!strcmp("TwoFingersFlickDown", gesture_name))
+ return TWO_FINGERS_FLICK_DOWN;
+
+ return GESTURES_COUNT;
+}
+
+static void on_gesture_detected(void *context EINA_UNUSED, const Eldbus_Message *msg)
+{
+ const char *gesture_name;
+ int x_s, y_s, x_e, y_e, state;
+
+ if(!eldbus_message_arguments_get(msg, "siiiiu", &gesture_name, &x_s, &y_s, &x_e, &y_e, &state))
+ ERROR("error geting arguments on_gesture_detected");
+
+ Gesture_Info g;
+ g.type = gesture_name_to_enum(gesture_name);
+ g.x_begin = x_s;
+ g.y_begin = y_s;
+ g.x_end = x_e;
+ g.y_end = y_e;
+ g.state = state;
+
+ if(user_cb)
+ user_cb(user_data, &g);
+}
+
+void gesture_tracker_init(Eldbus_Connection *conn)
+{
+ DEBUG("START");
+ a11y_conn = conn;
+ eldbus_connection_ref(conn);
+ object = eldbus_object_get(conn, BUS, PATH);
+ man = eldbus_proxy_get(object, INTERFACE);
+ eldbus_proxy_signal_handler_add(man, SIGNAL, on_gesture_detected, NULL);
+}
+
+void gesture_tracker_register(Gesture_Tracker_Cb cb, void *data)
+{
+ user_cb = cb;
+ user_data = data;
+}
+
+void gesture_tracker_shutdown(void)
+{
+ eldbus_proxy_unref(man);
+ eldbus_object_unref(object);
+ eldbus_connection_unref(a11y_conn);
+}
--- /dev/null
+#include "logger.h"
+
+int _eina_log_dom;
+
+int logger_init(void)
+{
+ if (!_eina_log_dom)
+ {
+ _eina_log_dom = eina_log_domain_register("screen-reader", NULL);
+ if (_eina_log_dom < 0)
+ {
+ fprintf(stderr, "Unable to register screen-reader log domain");
+ return -1;
+ }
+ }
+ return 0;
+}
+
+void logger_shutdown(void)
+{
+ if (_eina_log_dom)
+ {
+ eina_log_domain_unregister(_eina_log_dom);
+ _eina_log_dom = 0;
+ }
+}
+
-#include <app.h>
+#include <appcore-efl.h>
+#include <eldbus-1/Eldbus.h>
#include "navigator.h"
#include "window_tracker.h"
+#include "gesture_tracker.h"
#include "logger.h"
#include "screen_reader.h"
+#define A11Y_BUS "org.a11y.Bus"
+#define A11Y_INTERFACE "org.a11y.Bus"
+#define A11Y_PATH "/org/a11y/bus"
+#define A11Y_GET_ADDRESS "GetAddress"
-static bool app_create(void *data)
+Eldbus_Connection *a11y_conn;
+
+static void _init_modules(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
+{
+ printf("START:%s", __func__);
+ const char *a11y_bus_address = NULL;
+
+ logger_init();
+ if(!eldbus_message_arguments_get(msg, "s", &a11y_bus_address))
+ ERROR("error geting arguments _init_modules");
+ Eldbus_Connection *a11y_conn = eldbus_address_connection_get(a11y_bus_address);
+
+ gesture_tracker_init(a11y_conn);
+ navigator_init();
+}
+
+static int app_create(void *data)
{
- atspi_init();
- navigator_init();
+ printf("START:%s", __func__);
+ eldbus_init();
+ elm_init(0, NULL);
+
+ Eldbus_Connection *session_conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION);
+ Eldbus_Object *a11y_obj = eldbus_object_get(session_conn, A11Y_BUS, A11Y_PATH);
+ Eldbus_Proxy *manager = eldbus_proxy_get(a11y_obj, A11Y_INTERFACE);
+ eldbus_proxy_call(manager, A11Y_GET_ADDRESS, _init_modules, data, -1, "");
+
screen_reader_create_service(data);
- return true;
+ return 0;
}
-static void app_terminate(void *data)
+static int app_terminate(void *data)
{
+ printf("START:%s", __func__);
screen_reader_terminate_service(data);
+
+ eldbus_connection_unref(a11y_conn);
+ gesture_tracker_shutdown();
navigator_shutdown();
+ eldbus_shutdown();
+ logger_shutdown();
+ return 0;
}
int main(int argc, char **argv)
{
- app_create(get_pointer_to_service_data_struct());
+ DEBUG("Screen Reader Main Function Start");
+ unsetenv("ELM_ATSPI_MODE");
- GMainLoop *ml = g_main_loop_new(NULL, FALSE);
- g_main_loop_run (ml);
+ struct appcore_ops ops =
+ {
+ .create = app_create,
+ .terminate = app_terminate,
+ .pause = NULL,
+ .resume = NULL,
+ .reset = NULL
+ };
- app_terminate(get_pointer_to_service_data_struct());
+ ops.data = get_pointer_to_service_data_struct();
- return 0;
+ return appcore_efl_main("Smart Navigation", &argc, &argv, &ops);
}
+#include <Ecore_X.h>
+#include <Ecore.h>
#include <math.h>
#include <atspi/atspi.h>
#include "logger.h"
#include "navigator.h"
+#include "gesture_tracker.h"
#include "window_tracker.h"
#include "keyboard_tracker.h"
#include "pivot_chooser.h"
error = NULL;\
}
+typedef struct
+{
+ int x,y;
+} last_focus_t;
+
+static last_focus_t last_focus = {-1,-1};
+static AtspiAccessible *current_obj;
static AtspiAccessible *top_window;
-static gboolean _window_cache_builded;
+//static AtspiScrollable *scrolled_obj;
+static Eina_Bool _window_cache_builded;
static FlatNaviContext *context;
static void
_current_highlight_object_set(AtspiAccessible *obj)
{
- //TODO
- //speak virtually focused widget
+ DEBUG("START");
+ GError *err = NULL;
+ if (!obj)
+ {
+ DEBUG("Clearing focus object");
+ current_obj = NULL;
+ return;
+ }
+ if (current_obj == obj)
+ {
+ DEBUG("Object already focuseded");
+ DEBUG("Object name:%s", atspi_accessible_get_name(obj, NULL));
+ return;
+ }
+ if (obj && ATSPI_IS_COMPONENT(obj))
+ {
+ AtspiComponent *comp = atspi_accessible_get_component(obj);
+ if (!comp)
+ {
+ GError *err = NULL;
+ gchar *role = atspi_accessible_get_role_name(obj, &err);
+ ERROR("AtspiComponent *comp NULL, [%s]", role);
+ GERROR_CHECK(err);
+ g_free(role);
+ return;
+ }
+ atspi_component_grab_focus(comp, &err);
+ GERROR_CHECK(err)
+ gchar *name;
+ gchar *role;
+
+
+ current_obj = obj;
+ const ObjectCache *oc = object_cache_get(obj);
+
+ if (oc) {
+ name = atspi_accessible_get_name(obj, &err);
+ GERROR_CHECK(err)
+ role = atspi_accessible_get_role_name(obj, &err);
+ GERROR_CHECK(err)
+ DEBUG("New focused object: %s, role: %s, (%d %d %d %d)",
+ role,
+ name,
+ oc->bounds->x, oc->bounds->y, oc->bounds->width, oc->bounds->height);
+ haptic_vibrate_start();
+ }
+ else {
+ name = atspi_accessible_get_name(obj, &err);
+ GERROR_CHECK(err)
+ role = atspi_accessible_get_role_name(obj, &err);
+ GERROR_CHECK(err)
+ DEBUG("New focused object: %s, role: %s",
+ name,
+ role
+ );
+ haptic_vibrate_start();
+ }
+ g_free(role);
+ g_free(name);
+ }
+ else
+ DEBUG("Unable to focus on object");
+ DEBUG("END");
}
void test_debug(AtspiAccessible *current_widget)
}
}
+#if 0
+static void object_get_x_y(AtspiAccessible * accessibleObject, int* x, int* y)
+{
+ GError * error = NULL;
+
+ if ( ATSPI_IS_COMPONENT(accessibleObject) )
+ {
+ AtspiComponent * component = ATSPI_COMPONENT(accessibleObject);
+ AtspiPoint *position = atspi_component_get_position (component, ATSPI_COORD_TYPE_SCREEN, &error);
+ if ( error != NULL )
+ {
+ g_error_free(error);
+ }
+ if ( position != NULL )
+ {
+ *x = position->x;
+ *y = position->y;
+ g_free ( position );
+ }
+ }
+}
+
+static void object_get_wh(AtspiAccessible * accessibleObject, int* width, int* height)
+{
+ GError * error = NULL;
+
+ if ( ATSPI_IS_COMPONENT(accessibleObject) )
+ {
+ AtspiComponent * component = ATSPI_COMPONENT(accessibleObject);
+ AtspiPoint * size = atspi_component_get_size (component, &error);
+ if ( error != NULL )
+ {
+ g_error_free(error);
+ }
+ if ( size != NULL )
+ {
+ *width = size->x;
+ *height = size->y;
+ g_free ( size );
+ }
+ }
+}
+
+static void find_objects(AtspiAccessible* parent, gint x, gint y, gint radius, double* distance, AtspiAccessible **find_app)
+{
+ AtspiAccessible* app = NULL;
+ GError* err = NULL;
+ int jdx, kdx;
+
+ int count_child = atspi_accessible_get_child_count(parent, &err);
+
+ for(jdx = 0; jdx < count_child; jdx++)
+ {
+ app = atspi_accessible_get_child_at_index(parent, jdx, &err);
+
+ AtspiStateSet* state_set = atspi_accessible_get_state_set (app);
+ AtspiStateType state = ATSPI_STATE_VISIBLE;
+
+ int height = 0, width = 0, xpos1 = 0, ypos1 = 0, xpos2 = 0, ypos2 = 0;
+
+ object_get_wh(app, &width, &height); object_get_x_y(app, &xpos1, &ypos1);
+
+ gboolean is_visile = atspi_state_set_contains(state_set, state);
+
+ if(is_visile == TRUE && width > 0 && height > 0)
+ {
+ xpos2 = xpos1 + width;
+ ypos2 = ypos1 + height;
+
+ double set_distance[DISTANCE_NB] = {0};
+ double min_distance = DBL_MAX;
+
+ set_distance[0] = pow((x - xpos1), 2) + pow((y - ypos1), 2);
+ set_distance[1] = pow((x - xpos2), 2) + pow((y - ypos1), 2);
+ set_distance[2] = pow((x - xpos1), 2) + pow((y - ypos2), 2);
+ set_distance[3] = pow((x - xpos2), 2) + pow((y - ypos2), 2);
+ set_distance[4] = DBL_MAX;
+ set_distance[5] = DBL_MAX;
+ set_distance[6] = DBL_MAX;
+ set_distance[7] = DBL_MAX;
+
+ if(x >= fmin(xpos1, xpos2) && x <= fmax(xpos1, xpos2))
+ {
+ set_distance[4] = pow((y - ypos1), 2);
+ set_distance[5] = pow((y - ypos2), 2);
+ }
+
+ if(y >= fmin(ypos1, ypos2) && y <= fmax(ypos1, ypos2))
+ {
+ set_distance[6] = pow((x - xpos1), 2);
+ set_distance[7] = pow((x - xpos2), 2);
+ }
+
+ for(kdx = 0; kdx < DISTANCE_NB; kdx++)
+ {
+ if(set_distance[kdx] < min_distance)
+ min_distance = set_distance[kdx];
+ }
+
+ if(min_distance <= *distance && (radius < 0 || (radius >= 0 && min_distance <= radius)))
+ {
+ *distance = min_distance;
+ *find_app = app;
+ }
+ find_objects(app, x, y, radius, distance, find_app);
+ }
+ }
+}
+
+static AtspiAccessible *get_nearest_widget(AtspiAccessible* app_obj, gint x_cord, gint y_cord, gint radius)
+{
+ int xn = 0, yn = 0;
+ GError *err = NULL;
+ AtspiAccessible* f_app_obj = app_obj;
+ double distance = DBL_MAX;
+ int jdx = 0;
+
+ int count_child = atspi_accessible_get_child_count(app_obj, &err);
+
+ find_objects(app_obj, x_cord, y_cord, radius, &distance, &f_app_obj);
+
+ return f_app_obj;
+}
+#endif
+
+static void _focus_widget(Gesture_Info *info)
+{
+ DEBUG("START");
+ AtspiAccessible *target_widget;
+ AtspiComponent *window_component;
+ GError *err = NULL;
+
+ window_component = atspi_accessible_get_component(top_window);
+ if(!window_component)
+ return;
+ if ((last_focus.x == info->x_begin) && (last_focus.y == info->y_begin))
+ return;
+
+ target_widget = atspi_component_get_accessible_at_point(window_component, info->x_begin, info->y_begin, ATSPI_COORD_TYPE_WINDOW, &err);
+ GERROR_CHECK(err)
+ if (target_widget) {
+ DEBUG("WIDGET FOUND:%s", atspi_accessible_get_name(target_widget, NULL));
+ if (flat_navi_context_current_set(context, target_widget))
+ {
+ _current_highlight_object_set(target_widget);
+ last_focus.x = info->x_begin;
+ last_focus.y = info->y_begin;
+ }
+ else
+ ERROR("Hoveed object not found in window context[%dx%d][%s]", info->x_begin, info->y_begin, atspi_accessible_get_role_name(top_window, &err));
+ }
+ else
+ DEBUG("NO widget under (%d, %d) found",
+ info->x_begin, info->y_begin);
+ DEBUG("END");
+}
+
static void _focus_next(void)
{
+ DEBUG("START");
AtspiAccessible *obj;
if (!context)
{
_current_highlight_object_set(obj);
else
DEBUG("Next widget not found. Abort");
+ DEBUG("END");
}
static void _focus_prev(void)
DEBUG("Previous widget not found. Abort");
}
+static void _value_inc_widget(void)
+{
+ AtspiAccessible* current_widget = NULL;
+ AtspiText *text_interface;
+ gint current_offset;
+ gboolean ret;
+ GError *err = NULL;
+ gchar *role;
+
+ if(!current_obj)
+ return;
+
+ current_widget = current_obj;
+
+ role = atspi_accessible_get_role_name(current_widget, &err);
+ GERROR_CHECK(err)
+ if(!strcmp(role, "entry"))
+ {
+ text_interface = atspi_accessible_get_text(current_widget);
+ if(text_interface)
+ {
+ current_offset = atspi_text_get_caret_offset(text_interface, &err);
+ GERROR_CHECK(err)
+ ret = atspi_text_set_caret_offset(text_interface, current_offset + 1, &err);
+ GERROR_CHECK(err)
+ if(ret)
+ {
+ ERROR("Caret position increment done");
+ }
+ else
+ {
+ ERROR("Caret position increment error");
+ }
+ }
+ else
+ ERROR("No text interface supported!");
+ g_free(role);
+ return;
+ }
+ g_free(role);
+ AtspiValue *value_interface = atspi_accessible_get_value(current_widget);
+ if(value_interface)
+ {
+ ERROR("Value interface supported!\n");
+ gdouble current_val = atspi_value_get_current_value(value_interface, &err);
+ GERROR_CHECK(err)
+ ERROR("Current value: %f\n ", (double)current_val);
+ gdouble minimum_inc = atspi_value_get_minimum_increment(value_interface, &err);
+ ERROR("Minimum increment: %f\n ", (double)minimum_inc);
+ GERROR_CHECK(err)
+ atspi_value_set_current_value(value_interface, current_val + minimum_inc, &err);
+ GERROR_CHECK(err)
+ }
+ else
+ ERROR("No value interface supported!\n");
+}
+
+static void _value_dec_widget(void)
+{
+ AtspiAccessible* current_widget = NULL;
+ AtspiText *text_interface;
+ gint current_offset;
+ GError *err = NULL;
+ gboolean ret;
+ gchar *role;
+
+ if(!current_obj)
+ return;
+ current_widget = current_obj;
+
+ role = atspi_accessible_get_role_name(current_widget, &err);
+ GERROR_CHECK(err)
+ if(!strcmp(role, "entry"))
+ {
+ text_interface = atspi_accessible_get_text(current_widget);
+ if(text_interface)
+ {
+ current_offset = atspi_text_get_caret_offset(text_interface, &err);
+ GERROR_CHECK(err)
+ ret = atspi_text_set_caret_offset(text_interface, current_offset - 1, &err);
+ GERROR_CHECK(err)
+ if(ret)
+ {
+ ERROR("Caret position decrement done");
+ }
+ else
+ {
+ ERROR("Caret position decrement error");
+ }
+ }
+ else
+ ERROR("No text interface supported!");
+ g_free(role);
+ return;
+ }
+ g_free(role);
+
+ AtspiValue *value_interface = atspi_accessible_get_value(current_widget);
+ if(value_interface)
+ {
+ ERROR("Value interface supported!\n");
+ gdouble current_val = atspi_value_get_current_value(value_interface, &err);
+ GERROR_CHECK(err)
+ ERROR("Current value: %f\n ", (double)current_val);
+ gdouble minimum_inc = atspi_value_get_minimum_increment(value_interface, &err);
+ GERROR_CHECK(err)
+ ERROR("Minimum increment: %f\n ", (double)minimum_inc);
+ atspi_value_set_current_value(value_interface, current_val - minimum_inc, &err);
+ GERROR_CHECK(err)
+ }
+ else
+ ERROR("No value interface supported!\n");
+}
+
+static void _activate_widget(void)
+{
+ //activate the widget
+ //only if activate mean click
+ //special behavior for entry, caret should move from first/last last/first
+ DEBUG("START");
+ AtspiAccessible *current_widget = NULL;
+ AtspiComponent *focus_component;
+ GError *err = NULL;
+
+ if(!current_obj)
+ return;
+
+ current_widget = current_obj;
+
+ gchar *roleName;
+ gchar *actionName;
+ roleName = atspi_accessible_get_role_name(current_widget, &err);
+ GERROR_CHECK(err)
+ ERROR("Widget role prev: %s\n", roleName);
+
+ if(!strcmp(roleName, "entry"))
+ {
+ focus_component = atspi_accessible_get_component(current_widget);
+ if (focus_component != NULL)
+ {
+ if (atspi_component_grab_focus(focus_component, &err) == TRUE)
+ {
+ ERROR("Entry activated\n");
+ GERROR_CHECK(err)
+ }
+ g_free(roleName);
+ return;
+ }
+ }
+ g_free(roleName);
+
+ AtspiAction *action;
+ gint number;
+ int i;
+ int k;
+
+ action = atspi_accessible_get_action(current_widget);
+
+ if(!action)
+ {
+ ERROR("Action null");
+ return;
+ }
+ number = atspi_action_get_n_actions(action, &err);
+ ERROR("Number of available action = %d\n", number);
+ GERROR_CHECK(err)
+ GArray *array = atspi_accessible_get_interfaces(current_widget);
+ ERROR("TAB LEN = %d \n", array->len);
+
+ for (k=0; k < array->len; k++)
+ ERROR("Interface = %s\n", g_array_index( array, gchar *, k ));
+
+ for (i=0; i<number; i++)
+ {
+ actionName = atspi_action_get_name(action, i, &err);
+ ERROR("Action name = %s\n", actionName);
+ GERROR_CHECK(err)
+
+ if (actionName && !strcmp("click", actionName))
+ {
+ atspi_action_do_action(action, 0, &err);
+ GERROR_CHECK(err)
+ }
+ g_free(actionName);
+ }
+
+}
+
+static void _quickpanel_change_state(gboolean quickpanel_switch)
+{
+ DEBUG("START");
+ Ecore_X_Window xwin = 0;
+
+ ERROR(quickpanel_switch ? "QUICKPANEL STATE ON" : "QUICKPANEL STATE OFF");
+
+ Ecore_X_Illume_Quickpanel_State state;
+
+
+
+ ecore_x_window_prop_xid_get(ecore_x_window_root_first_get(),
+ ECORE_X_ATOM_NET_ACTIVE_WINDOW,
+ ECORE_X_ATOM_WINDOW,
+ &xwin, 1);
+
+ state = quickpanel_switch ? ECORE_X_ILLUME_QUICKPANEL_STATE_ON : ECORE_X_ILLUME_QUICKPANEL_STATE_OFF;
+
+ ecore_x_e_illume_quickpanel_state_set(xwin, state);
+
+ ecore_x_e_illume_quickpanel_state_send(ecore_x_e_illume_zone_get(xwin), state);
+
+ ecore_main_loop_iterate();
+}
+
+/**
+ * @brief Gets 'deepest' Scrollable accessible containing (x,y) point
+ */
+/*
+static AtspiScrollable*
+_find_scrollable_ancestor_at_xy(int x, int y)
+{
+ AtspiAccessible *ret = NULL;
+ AtspiRect *rect;
+ GError *err = NULL;
+
+ if (!top_window || !ATSPI_IS_COMPONENT(top_window))
+ {
+ DEBUG("No active window detected or no AtspiComponent interface available");
+ return NULL;
+ }
+
+ rect = atspi_component_get_extents(ATSPI_COMPONENT(top_window), ATSPI_COORD_TYPE_SCREEN, &err);
+ GERROR_CHECK(err)
+ if (!rect)
+ {
+ ERROR("Unable to fetch window screen coordinates");
+ return NULL;
+ }
+
+ // Scroll must originate within window borders
+ if ((x < rect->x) || (x > rect->x + rect->width) ||
+ (y < rect->y) || (y > rect->y + rect->height))
+ {
+ DEBUG("Scroll don't start within active window borders");
+ g_free(rect);
+ return NULL;
+ }
+
+ ret = atspi_component_get_accessible_at_point(ATSPI_COMPONENT(top_window), x, y, ATSPI_COORD_TYPE_SCREEN, &err);
+ GERROR_CHECK(err)
+ if (!ret)
+ {
+ ERROR("Unable to get accessible objct at (%d, %d) screen coordinates.", x, y);
+ return NULL;
+ }
+gchar *name;
+gchar *role;
+ // find accessible object with Scrollable interface
+ while (ret && (ret != top_window))
+ {
+ name = atspi_accessible_get_name(ret, &err);
+ GERROR_CHECK(err)
+ role = atspi_accessible_get_role_name(ret, &err);
+ GERROR_CHECK(err)
+ DEBUG("Testing for scrollability: %s %s",
+ name, role);
+ if (atspi_accessible_get_scrollable(ret))
+ {
+ DEBUG("Scrollable widget found at (%d, %d), name: %s, role: %s", x, y,
+ name ,role);
+ g_free(name);
+ g_free(role);
+ return ATSPI_SCROLLABLE(ret);
+ }
+ g_free(name);
+ g_free(role);
+ ret = atspi_accessible_get_parent(ret, &err);
+ if (err)
+ {
+ ERROR("Unable to fetch AT-SPI parent");
+ GERROR_CHECK(err)
+ return NULL;
+ }
+ }
+
+ return NULL;
+}
+
+static void _widget_scroll_begin(Gesture_Info *gi)
+{
+ GError *err = NULL;
+
+ if (scrolled_obj)
+ {
+ ERROR("Scrolling context active when initializing new scrolling context! This should never happen.");
+ ERROR("Force reset of current scrolling context...");
+ atspi_scrollable_scroll_after_pointer(scrolled_obj, ATSPI_SCROLL_POINTER_END, gi->x_begin, gi->y_begin, &err);
+ if (err)
+ {
+ ERROR("Failed to reset scroll context.");
+ GERROR_CHECK(err)
+ scrolled_obj = NULL;
+ }
+ }
+
+ scrolled_obj = _find_scrollable_ancestor_at_xy(gi->x_begin, gi->y_begin);
+
+ if (!scrolled_obj)
+ {
+ DEBUG("No scrollable widget found at (%d, %d) coordinates", gi->x_begin, gi->y_begin);
+ return;
+ }
+
+ atspi_scrollable_scroll_after_pointer(scrolled_obj, ATSPI_SCROLL_POINTER_START, gi->x_begin, gi->y_begin, &err);
+ if (err)
+ {
+ ERROR("Failed to initialize scroll operation");
+ GERROR_CHECK(err)
+ scrolled_obj = NULL;
+ }
+}
+
+static void _widget_scroll_continue(Gesture_Info *gi)
+{
+ GError *err = NULL;
+ if (!scrolled_obj)
+ {
+ DEBUG("Scrolling context not initialized!");
+ return;
+ }
+ atspi_scrollable_scroll_after_pointer(scrolled_obj, ATSPI_SCROLL_POINTER_CONTINUE, gi->x_begin, gi->y_begin, &err);
+ GERROR_CHECK(err)
+}
+
+static void _widget_scroll_end(Gesture_Info *gi)
+{
+ GError *err = NULL;
+ if (!scrolled_obj)
+ {
+ ERROR("Scrolling context not initialized!");
+ return;
+ }
+
+ atspi_scrollable_scroll_after_pointer(scrolled_obj, ATSPI_SCROLL_POINTER_END, gi->x_begin, gi->y_begin, &err);
+ scrolled_obj = NULL;
+ GERROR_CHECK(err)
+}
+*/
+#if 0
+// part of structural navigation
+static void _goto_children_widget(void)
+{
+ AtspiAccessible *obj;
+ if (!current_obj)
+ {
+ DEBUG("No current object is set. Aborting diving into children structure");
+ return;
+ }
+ obj = structural_navi_level_down(current_obj);
+ if (obj)
+ _current_highlight_object_set(obj);
+ else
+ DEBUG("Unable to find hihglightable children widget");
+}
+
+static void _escape_children_widget(void)
+{
+ AtspiAccessible *obj;
+ if (!current_obj)
+ {
+ DEBUG("No current object is set. Aborting escaping from children structure");
+ return;
+ }
+ obj = structural_navi_level_up(current_obj);
+ if (obj)
+ _current_highlight_object_set(obj);
+ else
+ DEBUG("Unable to find hihglightable parent widget");
+}
+#endif
+/*
+static void _widget_scroll(Gesture_Info *gi)
+{
+ switch (gi->state)
+ {
+ case 0:
+ _widget_scroll_begin(gi);
+ break;
+ case 1:
+ _widget_scroll_continue(gi);
+ break;
+ case 2:
+ _widget_scroll_end(gi);
+ break;
+ default:
+ ERROR("Unrecognized gesture state: %d", gi->state);
+ }
+}
+*/
+static void on_gesture_detected(void *data, Gesture_Info *info)
+{
+ switch(info->type)
+ {
+ case ONE_FINGER_HOVER:
+ _focus_widget(info);
+ break;
+ case TWO_FINGERS_HOVER:
+// _widget_scroll(info);
+ break;
+ case ONE_FINGER_FLICK_LEFT:
+ _focus_prev();
+ break;
+ case ONE_FINGER_FLICK_RIGHT:
+ _focus_next();
+ break;
+ case ONE_FINGER_FLICK_UP:
+ _value_inc_widget();
+ break;
+ case ONE_FINGER_FLICK_DOWN:
+ _value_dec_widget();
+ break;
+ case ONE_FINGER_SINGLE_TAP:
+ _focus_widget(info);
+ break;
+ case ONE_FINGER_DOUBLE_TAP:
+ _activate_widget();
+ break;
+ case THREE_FINGERS_FLICK_DOWN:
+ _quickpanel_change_state(QUICKPANEL_DOWN);
+ break;
+ case THREE_FINGERS_FLICK_UP:
+ _quickpanel_change_state(QUICKPANEL_UP);
+ break;
+ default:
+ DEBUG("Gesture type %d not handled in switch", info->type);
+ }
+}
+
static void
_on_cache_builded(void *data)
{
DEBUG("Cache building");
- _window_cache_builded = TRUE;
+ _window_cache_builded = EINA_TRUE;
AtspiAccessible *pivot = NULL;
if (context)
{
_view_content_changed(AppTrackerEventType type, void *user_data)
{
DEBUG("View content changed");
- _window_cache_builded = FALSE;
+ _window_cache_builded = EINA_FALSE;
if (top_window)
object_cache_build_async(top_window, 5, _on_cache_builded, NULL);
}
static void on_window_activate(void *data, AtspiAccessible *window)
{
- gchar *name;
- DEBUG("... on window activate ...");
+ gchar *name;
+ ERROR("... on window activate ...");
- app_tracker_callback_unregister(top_window, APP_TRACKER_EVENT_VIEW_CHANGED, _view_content_changed, NULL);
+ app_tracker_callback_unregister(top_window, APP_TRACKER_EVENT_VIEW_CHANGED, _view_content_changed, NULL);
- if(window)
- {
- app_tracker_callback_register(window, APP_TRACKER_EVENT_VIEW_CHANGED, _view_content_changed, NULL);
- name = atspi_accessible_get_name(window, NULL);
- DEBUG("Window name: %s", name);
- _window_cache_builded = FALSE;
- object_cache_build_async(window, 5, _on_cache_builded, NULL);
- g_free(name);
- }
- else
- {
- ERROR("No top window found!");
- }
- top_window = window;
+ if(window)
+ {
+ app_tracker_callback_register(window, APP_TRACKER_EVENT_VIEW_CHANGED, _view_content_changed, NULL);
+ name = atspi_accessible_get_name(window, NULL);
+ ERROR("Window name: %s", name);
+ _window_cache_builded = EINA_FALSE;
+ object_cache_build_async(window, 5, _on_cache_builded, NULL);
+ g_free(name);
+ }
+ else
+ {
+ ERROR("No top window found!");
+// scrolled_obj = NULL;
+ }
+ top_window = window;
}
void kb_tracker (void *data, Key k)
void navigator_init(void)
{
+ DEBUG("START");
+ // register on gesture_getected
+ gesture_tracker_register(on_gesture_detected, NULL);
+ // register on active_window
window_tracker_init();
window_tracker_register(on_window_activate, NULL);
window_tracker_active_window_request();
void navigator_shutdown(void)
{
+ GError *err = NULL;
+ if (current_obj)
+ {
+ AtspiComponent *comp = atspi_accessible_get_component(current_obj);
+ if (comp)
+ {
+ GERROR_CHECK(err);
+ }
+ }
if (context)
{
flat_navi_context_free(context);
+#include <Eina.h>
+#include <Ecore.h>
+
#include "object_cache.h"
#include "logger.h"
-#include <glib.h>
-
-static GHashTable *cache;
-static int idler = -1;
-static GList *toprocess;
+static Eina_Hash *cache;
+static Ecore_Idler *idler;
+static Eina_List *toprocess;
static void *user_data;
static ObjectCacheReadyCb callback;
static int bulk;
static void
-_cache_item_free_cb(gpointer data)
+_cache_item_free_cb(void *data)
{
- if (!data) return;
ObjectCache *co = data;
g_free(co->bounds);
- g_free(co);
+ free(co);
}
static void
-_list_obj_unref_and_free(GList *toprocess)
+_list_obj_unref_and_free(Eina_List *toprocess)
{
- for (; toprocess; toprocess = toprocess->next)
- g_object_unref(toprocess->data);
+ AtspiAccessible *obj;
+ EINA_LIST_FREE(toprocess, obj)
+ g_object_unref(obj);
}
static void
_object_cache_free_internal(void)
{
- if (idler > 0)
+ if (idler)
{
- g_source_remove(idler);
- idler = -1;
+ ecore_idler_del(idler);
+ idler = NULL;
}
if (toprocess)
{
}
if (cache)
{
- g_hash_table_destroy(cache);
+ eina_hash_free(cache);
cache = NULL;
}
}
/**
* Returnes a list of all accessible object implementing AtkCompoment interface
- * GList should be free with g_list_Free function.
+ * Eina_List should be free with eina_list_free function.
* Every AtspiAccessible in list should be unrefed with g_object_unref.
*/
-static GList*
+static Eina_List*
_cache_candidates_list_prepare(AtspiAccessible *root)
{
- GList *toprocess = NULL, *ret = NULL;
+ Eina_List *toprocess = NULL, *ret = NULL;
int n, i;
if (!root) return NULL;
// Keep ref counter +1 on every object in returned list
g_object_ref(root);
- toprocess = g_list_append(toprocess, root);
+ toprocess = eina_list_append(toprocess, root);
while (toprocess)
{
- AtspiAccessible *obj = toprocess->data;
- toprocess = g_list_delete_link(toprocess, toprocess);
+ AtspiAccessible *obj = eina_list_data_get(toprocess);
+ toprocess = eina_list_remove_list(toprocess, toprocess);
if (!obj)
continue;
n = atspi_accessible_get_child_count(obj, NULL);
{
AtspiAccessible *cand = atspi_accessible_get_child_at_index(obj, i, NULL);
if(cand)
- toprocess = g_list_append(toprocess, cand);
+ toprocess = eina_list_append(toprocess, cand);
}
- ret = g_list_append(ret, obj);
+ ret = eina_list_append(ret, obj);
}
return ret;
if (!obj)
return NULL;
- ret = g_new0(ObjectCache, 1);
+ ret = calloc(1, sizeof(ObjectCache));
if (!ret)
{
ERROR("out-of memory");
return ret;
}
-static GList*
-_cache_item_n_cache(GList *objs, int count)
+static Eina_List*
+_cache_item_n_cache(Eina_List *objs, int count)
{
int i = 0;
- GList *ret = objs;
+ Eina_List *ret = objs;
ObjectCache *oc;
AtspiAccessible *obj;
for (i = 0; (i < count) && ret; i++)
{
- obj = ret->data;
- ret = g_list_delete_link(ret, ret);
+ obj = eina_list_data_get(ret);
+ ret = eina_list_remove_list(ret, ret);
oc = _cache_item_construct(obj);
if (!oc) break;
- g_hash_table_insert (cache, obj, oc);
-
+ eina_hash_add(cache, &obj, oc);
g_object_unref(obj);
}
return ret;
}
-static GHashTable*
+static Eina_Hash*
_object_cache_new(void)
{
- return g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, _cache_item_free_cb);
+ return eina_hash_pointer_new(_cache_item_free_cb);
}
void
object_cache_build(AtspiAccessible *root)
{
- GList *objs;
+ Eina_List *objs;
_object_cache_free_internal();
cache = _object_cache_new();
}
objs = _cache_candidates_list_prepare(root);
- _cache_item_n_cache(objs, g_list_length(objs));
+ _cache_item_n_cache(objs, eina_list_count(objs));
return;
}
-static gboolean
+static Eina_Bool
_do_cache(void *data)
{
toprocess = _cache_item_n_cache(toprocess, bulk);
- idler = -1;
+ idler = NULL;
if (toprocess)
- idler = g_idle_add(_do_cache, NULL);
+ idler = ecore_idler_add(_do_cache, NULL);
else if (callback) callback(user_data);
- return FALSE;
+ return EINA_FALSE;
}
void
}
toprocess = _cache_candidates_list_prepare(root);
- idler = g_idle_add(_do_cache, NULL);
+ idler = ecore_idler_add(_do_cache, NULL);
return;
}
object_cache_get(AtspiAccessible *obj)
{
ObjectCache *ret = NULL;
- if (idler > 0)
+ if (idler)
{
ERROR("Invalid usage. Async cache build is ongoing...");
return NULL;
}
}
- ret = g_hash_table_lookup(cache, obj);
+ ret = eina_hash_find(cache, &obj);
if (!ret)
{
// fallback to blocking d-bus call
ret = _cache_item_construct(obj);
- g_hash_table_insert(cache, obj, ret);
+ eina_hash_add(cache, &obj, ret);
}
return ret;
#include <atspi/atspi.h>
#include "logger.h"
+#include <Eina.h>
+
/**
* @brief Finds first leaf in object hierarchy with given states,
static AtspiAccessible*
_pivot_with_state_flat_find(AtspiAccessible *parent, AtspiStateType type)
{
- GList *candidates = NULL, *queue = NULL;
+ Eina_List *candidates = NULL, *queue = NULL;
// ref object to keep same ref count
g_object_ref(parent);
- queue = g_list_append(queue, parent);
+ queue = eina_list_append(queue, parent);
while (queue)
{
- AtspiAccessible *obj = queue->data;
- queue = g_list_delete_link(queue, queue);
+ AtspiAccessible *obj = eina_list_data_get(queue);
+ queue = eina_list_remove_list(queue, queue);
int n = atspi_accessible_get_child_count(obj, NULL);
if (n == 0)
- candidates = g_list_append(candidates, obj);
+ candidates = eina_list_append(candidates, obj);
else
{
int i;
{
AtspiAccessible *child = atspi_accessible_get_child_at_index(obj, i, NULL);
if (child)
- queue = g_list_append(queue, child);
+ queue = eina_list_append(queue, child);
}
g_object_unref(obj);
}
// FIXME sort by (x,y) first ??
while (candidates)
{
- AtspiAccessible *obj = candidates->data;
- candidates = g_list_delete_link(candidates, candidates);
+ AtspiAccessible *obj = eina_list_data_get(candidates);
+ candidates = eina_list_remove_list(candidates, candidates);
AtspiStateSet *states = atspi_accessible_get_state_set(obj);
if (states && atspi_state_set_contains(states, type))
{
g_object_unref(states);
g_object_unref(obj);
- g_list_free(candidates);
+ eina_list_free(candidates);
return obj;
}
return -1;
}
-static GList*
-_get_zones(const GList *objs)
+static Eina_List*
+_get_zones(const Eina_List *objs)
{
- GList *candidates = NULL;
- const GList *l;
+ Eina_List *candidates = NULL;
+ const Eina_List *l;
AtspiAccessible *obj;
AtspiComponent *comp;
const ObjectCache *oc;
- for (l = objs; l; l = l->next)
+ EINA_LIST_FOREACH(objs, l, obj)
{
- obj = l->data;
if ((comp = atspi_accessible_get_component(obj)) != NULL)
{
oc = object_cache_get(obj);
atspi_accessible_get_role_name(obj, NULL));
continue;
}
- candidates = g_list_append(candidates, obj);
+ candidates = eina_list_append(candidates, obj);
}
else
DEBUG("No component interface: skipping %s %s",
}
// Sort object by y - coordinate
- return g_list_sort(candidates, _sort_vertically);
+ return eina_list_sort(candidates, 0, _sort_vertically);
}
-static GList*
-_get_lines(const GList *objs)
+static Eina_List*
+_get_lines(const Eina_List *objs)
{
- GList *line = NULL, *lines = NULL;
- const GList *l;
+ Eina_List *line = NULL, *lines = NULL;
+ const Eina_List *l;
AtspiAccessible *obj;
const ObjectCache *line_beg;
- for (l = objs; l; l = l->next)
+ EINA_LIST_FOREACH(objs, l, obj)
{
- obj = l->data;
if (!line) {
// set first object in line
- line = g_list_append(line, obj);
+ line = eina_list_append(line, obj);
line_beg = object_cache_get(obj);
continue;
}
if ((line_beg->bounds->y + (int)(0.25 * (double)line_beg->bounds->height)) >
oc->bounds->y)
{
- line = g_list_append(line, obj);
+ line = eina_list_append(line, obj);
continue;
}
else
{
//finish line & set new line leader
- lines = g_list_append(lines, line);
+ lines = eina_list_append(lines, line);
line = NULL;
- line = g_list_append(line, obj);
+ line = eina_list_append(line, obj);
line_beg = object_cache_get(obj);
}
}
// finish last line
- if (line) lines = g_list_append(lines, line);
+ if (line) lines = eina_list_append(lines, line);
return lines;
}
-GList *position_sort(const GList *objs)
+Eina_List *position_sort(const Eina_List *objs)
{
- GList *l, *line, *zones, *lines = NULL;
+ Eina_List *l, *line, *zones, *lines = NULL;
int i = 0;
// Get list of objects occupying place on the screen
- DEBUG("PositionSort: Candidates; %d", g_list_length((GList*)objs));
+ DEBUG("PositionSort: Candidates; %d", eina_list_count(objs));
zones = _get_zones(objs);
// Cluster all zones into lines - verticaly
- DEBUG("PositionSort: Zones; %d", g_list_length(zones));
+ DEBUG("PositionSort: Zones; %d", eina_list_count(zones));
lines = _get_lines(zones);
// sort all zones in line - horizontaly
- DEBUG("PositionSort: Lines; %d", g_list_length(lines));
- for (l = lines; l; l = l->next)
+ DEBUG("PositionSort: Lines; %d", eina_list_count(lines));
+ EINA_LIST_FOREACH(lines, l, line)
{
- line = l->data;
- DEBUG("PositionSort: Line %d: %d items", i++, g_list_length(line));
- line = g_list_sort(line, _sort_horizontally);
- l->data = line;
+ DEBUG("PositionSort: Line %d: %d items", i++, eina_list_count(line));
+ line = eina_list_sort(line, 0, _sort_horizontally);
+ eina_list_data_set(l, line);
}
- if (zones) g_list_free(zones);
+ if (zones) eina_list_free(zones);
return lines;
}
int screen_reader_create_service(void *data)
{
- DEBUG("Service Create Callback \n");
+ printf("\n\n\nService Create:%s\n\n\n", __func__);
Service_Data *service_data = data;
- tts_init(service_data);
vconf_init(service_data);
spi_init(service_data);
+ tts_init(service_data);
/* XML TEST */
Service_Data *service_data = data;
- int vconf_ret = vconf_set_bool("db/setting/accessibility/screen_reader", FALSE);
+ int vconf_ret = vconf_set_bool("db/setting/accessibility/screen_reader", EINA_FALSE);
if(vconf_ret == 0)
{
DEBUG("TTS key set to false");
}
- vconf_ret = vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, FALSE);
+ vconf_ret = vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, EINA_FALSE);
if(vconf_ret == 0)
{
DEBUG("TTS key set to false");
#ifdef RUN_IPC_TEST_SUIT
#include "test_suite/test_suite.h"
#endif
-#include <stdlib.h>
-#define MEMORY_ERROR "Memory allocation failed"
#define NO_VALUE_INTERFACE "No value interface present"
#define NO_TEXT_INTERFACE "No text interface present"
DEBUG("--------------------------------------------------------");
}
-gboolean double_click_timer_cb(void *data)
+Eina_Bool double_click_timer_cb(void *data)
{
Service_Data *sd = data;
sd->clicked_widget = NULL;
- return FALSE;
+ return EINA_FALSE;
}
bool allow_recursive_name(AtspiAccessible *obj)
{
AtspiRole r = atspi_accessible_get_role(obj, NULL);
if (r == ATSPI_ROLE_FILLER)
- return true;
+ return true;
return false;
}
char *generate_description_for_subtree(AtspiAccessible *obj)
{
+ DEBUG("START");
if (!allow_recursive_name(obj))
return strdup("");
+
if (!obj)
return strdup("");
int child_count = atspi_accessible_get_child_count(obj, NULL);
+ DEBUG("There is %d children inside this filler", child_count);
if (!child_count)
return strdup("");
char ret[256] = "\0";
AtspiAccessible *child = NULL;
for (i=0; i < child_count; i++) {
- child = atspi_accessible_get_child_at_index(obj, i, NULL);
- name = atspi_accessible_get_name(child, NULL);
- if (strncmp(name, "\0", 1)) {
- strncat(ret, name, sizeof(ret) - strlen(ret) - 1);
- }
- strncat(ret, " ", 1);
- below = generate_description_for_subtree(child);
- if (strncmp(below, "\0", 1)) {
- strncat(ret, below, sizeof(ret) - strlen(ret) - 1);
- }
- g_object_unref(child);
- free(below);
- free(name);
+ child = atspi_accessible_get_child_at_index(obj, i, NULL);
+ name = atspi_accessible_get_name(child, NULL);
+ DEBUG("%d child name:%s", i, name);
+ if (strncmp(name, "\0", 1)) {
+ strncat(ret, name, sizeof(ret) - strlen(ret) - 1);
+ }
+ strncat(ret, " ", 1);
+ below = generate_description_for_subtree(child);
+ if (strncmp(below, "\0", 1)) {
+ strncat(ret, below, sizeof(ret) - strlen(ret) - 1);
+ }
+ g_object_unref(child);
+ free(below);
+ free(name);
}
return strdup(ret);
}
-static char *spi_get_atspi_accessible_basic_text_description(AtspiAccessible *obj)
+static char *spi_on_state_changed_get_text(AtspiEvent *event, void *user_data)
{
- if(!obj) return NULL;
-
+ Service_Data *sd = (Service_Data*)user_data;
char *name;
char *description;
char *role_name;
char *other;
char *return_text = NULL;
+ sd->currently_focused = event->source;
+
+ description = atspi_accessible_get_description(sd->currently_focused, NULL);
+ name = atspi_accessible_get_name(sd->currently_focused, NULL);
+ role_name = atspi_accessible_get_role_name(sd->currently_focused, NULL);
+ other = generate_description_for_subtree(sd->currently_focused);
- description = atspi_accessible_get_description(obj, NULL);
- name = atspi_accessible_get_name(obj, NULL);
- role_name = atspi_accessible_get_role_name(obj, NULL);
- other = generate_description_for_subtree(obj);
+ DEBUG("->->->->->-> WIDGET GAINED FOCUS: %s <-<-<-<-<-<-<-", name);
+ DEBUG("->->->->->-> FROM SUBTREE HAS NAME: %s <-<-<-<-<-<-<-", other);
if (strncmp(description, "\0", 1))
return_text = strdup(description);
else if (strncmp(name, "\0", 1))
return_text = strdup(name);
else if (strncmp(other, "\0", 1))
- return_text = strdup(other);
+ return_text = strdup(name);
else
return_text = strdup(role_name);
return return_text;
}
-static char *spi_on_state_changed_get_text(AtspiEvent *event, void *user_data)
-{
- Service_Data *sd = (Service_Data*)user_data;
- char *return_text = NULL;
- sd->currently_focused = event->source;
-
- DEBUG("->->->->->-> WIDGET GAINED HIGHLIGHT <-<-<-<-<-<-<-");
- return_text = spi_get_atspi_accessible_basic_text_description(sd->currently_focused);
-
- return return_text;
-}
-
static char *spi_on_caret_move_get_text(AtspiEvent *event, void *user_data)
{
Service_Data *sd = (Service_Data*)user_data;
return text_to_read;
}
-static void spi_object_append_relations_to_text_to_read(AtspiAccessible *obj,
- char **text_to_read)
-{
- if(!obj || !text_to_read || !*text_to_read)
- {
- ERROR("Invalid parameter");
- return;
- }
-
- GError *error = NULL;
-
- GArray *relations = atspi_accessible_get_relation_set(obj, &error);
- if(error != NULL)
- {
- ERROR("Can not get atspi object relations: %s", error->message);
- g_error_free(error);
- return;
- }
-
- if(!relations)
- {
- ERROR("Can not get accessible object relations");
- return;
- }
-
- int i = 0;
- for(; i < relations->len; ++i)
- {
- AtspiRelation *relation = g_array_index(relations, AtspiRelation*, i);
- if(!relation) continue;
-
- AtspiRelationType relation_type = atspi_relation_get_relation_type(relation);
- if(relation_type == ATSPI_RELATION_LABEL_FOR ||
- relation_type == ATSPI_RELATION_LABELLED_BY)
- {
- int relation_objects = atspi_relation_get_n_targets(relation);
- int j;
- for(j = 0; j < relation_objects; ++j)
- {
- AtspiAccessible *relation_object = atspi_relation_get_target(relation, j);
- if(!relation_object || obj == relation_object) continue;
-
- char *relation_obj_text = spi_get_atspi_accessible_basic_text_description(relation_object);
-
- char *text = NULL;
- if(asprintf(&text, "%s %s", *text_to_read, relation_obj_text) == -1)
- continue;
- free(relation_obj_text);
- free(*text_to_read);
- *text_to_read = text;
- g_object_unref(relation_object);
- }
- }
- }
-
- g_array_free(relations, TRUE);
-}
-
char *spi_event_get_text_to_read(AtspiEvent *event, void *user_data)
{
+ DEBUG("START");
+
Service_Data *sd = (Service_Data*)user_data;
char *text_to_read;
+ DEBUG("TRACK SIGNAL:%s", sd->tracking_signal_name);
+ DEBUG("WENT EVENT:%s", event->type);
+
if(!sd->tracking_signal_name)
{
ERROR("Invalid tracking signal name");
}
else
{
- DEBUG("Unhandled event type: %s %d:%d", event->type, event->detail1, event->detail2);
+ ERROR("Unknown event type");
return NULL;
}
- spi_object_append_relations_to_text_to_read(sd->currently_focused, &text_to_read);
- DEBUG("%p %s", sd->currently_focused, text_to_read);
-
return text_to_read;
}
void spi_event_listener_cb(AtspiEvent *event, void *user_data)
{
+ DEBUG("START")
+
display_info(event);
if(!user_data)
ERROR("Can not prepare text to read");
return;
}
- tts_speak(text_to_read, FALSE);
+ DEBUG("SPEAK:%s", text_to_read)
+ tts_speak(text_to_read, EINA_FALSE);
free(text_to_read);
+ DEBUG("END")
}
/**
sd->spi_listener = atspi_event_listener_new(spi_event_listener_cb, service_data, NULL);
if(sd->spi_listener == NULL)
{
- DEBUG("FAILED TO CREATE spi state changed listener");
+ DEBUG("FAILED TO CREATE spi state changed listener")
}
// ---------------------------------------------------------------------------------------------------
+ DEBUG("TRACKING SIGNAL:%s", sd->tracking_signal_name);
+
gboolean ret1 = atspi_event_listener_register(sd->spi_listener, sd->tracking_signal_name, NULL);
if(ret1 == false)
{
DEBUG("FAILED TO REGISTER spi value changed listener");
}
-
if(ret1 == true && ret2 == true && ret3 == true)
{
DEBUG("spi listener REGISTERED");
if(status == DEVICE_BATTERY_LEVEL_LOW)
{
- tts_speak(BATTERY_LOW, TRUE);
+ tts_speak(BATTERY_LOW, EINA_TRUE);
}
else if(status == DEVICE_BATTERY_LEVEL_CRITICAL)
{
- tts_speak(BATTERY_CRITICAL, TRUE);
+ tts_speak(BATTERY_CRITICAL, EINA_TRUE);
}
else if(status == DEVICE_BATTERY_LEVEL_FULL)
{
- tts_speak(BATTERY_FULL, TRUE);
+ tts_speak(BATTERY_FULL, EINA_TRUE);
}
}
else if(type == DEVICE_CALLBACK_BATTERY_CHARGING)
if(charging)
{
- tts_speak(CHARGING, FALSE);
+ tts_speak(CHARGING, EINA_FALSE);
}
else
{
- tts_speak(NOT_CHARGING, FALSE);
+ tts_speak(NOT_CHARGING, EINA_FALSE);
}
}
else if(type == DEVICE_CALLBACK_DISPLAY_STATE)
if(state == DISPLAY_STATE_NORMAL)
{
- tts_speak(SCREEN_ON, FALSE);
+ tts_speak(SCREEN_ON, EINA_FALSE);
}
else if(state == DISPLAY_STATE_SCREEN_OFF)
{
- tts_speak(SCREEN_OFF, FALSE);
+ tts_speak(SCREEN_OFF, EINA_FALSE);
}
}
}
#define _GNU_SOURCE
+#include <Ecore.h>
#include "screen_reader_tts.h"
#include "logger.h"
-#include <stdlib.h>
-#include <stdio.h>
-#define MEMORY_ERROR "Memory allocation failed"
// ---------------------------- DEBUG HELPERS ------------------------------
#define FLUSH_LIMIT 1
static int last_utt_id;
-static gboolean pause_state = FALSE;
-static gboolean flush_flag = FALSE;
+static Eina_Bool pause_state = EINA_FALSE;
+static Eina_Bool flush_flag = EINA_FALSE;
static char * get_tts_error( int r )
{
{
free(vi);
ERROR(MEMORY_ERROR);
- return FALSE;
+ return ECORE_CALLBACK_CANCEL;
}
vi->voice_type = voice_type;
- sd->available_languages = g_list_append(sd->available_languages, vi);
+ sd->available_languages = eina_list_append(sd->available_languages, vi);
- return TRUE;
+ return ECORE_CALLBACK_RENEW;
}
static void __tts_test_utt_started_cb(tts_h tts, int utt_id, void* user_data)
{
DEBUG("Utterance completed : utt id(%d) \n", utt_id);
if(last_utt_id - utt_id > FLUSH_LIMIT)
- flush_flag = TRUE;
+ flush_flag = EINA_TRUE;
else
{
if(flush_flag)
- flush_flag = FALSE;
+ flush_flag = EINA_FALSE;
}
return;
}
bool tts_init(void *data)
{
+ printf( "--------------------- TTS_init START ---------------------");
DEBUG( "--------------------- TTS_init START ---------------------");
Service_Data *sd = data;
return true;
}
-gboolean tts_pause_set(gboolean pause_switch)
+Eina_Bool tts_pause_set(Eina_Bool pause_switch)
{
Service_Data *sd = get_pointer_to_service_data_struct();
if(!sd)
- return FALSE;
+ return EINA_FALSE;
if(pause_switch)
{
if(!tts_pause(sd->tts))
- pause_state = TRUE;
+ pause_state = EINA_TRUE;
else
- return FALSE;
+ return EINA_FALSE;
}
else if(!pause_switch)
{
if(!tts_play(sd->tts))
- pause_state = FALSE;
+ pause_state = EINA_FALSE;
else
- return FALSE;
+ return EINA_FALSE;
}
- return TRUE;
+ return EINA_TRUE;
}
-gboolean tts_speak(char *text_to_speak, gboolean flush_switch)
+Eina_Bool tts_speak(char *text_to_speak, Eina_Bool flush_switch)
{
Service_Data *sd = get_pointer_to_service_data_struct();
int speak_id;
if(!sd)
- return FALSE;
+ return EINA_FALSE;
if(flush_flag || flush_switch)
tts_stop(sd->tts);
DEBUG( "tts_speak\n");
DEBUG( "text to say:%s\n", text_to_speak);
- if ( !text_to_speak ) return FALSE;
- if ( !text_to_speak[0] ) return FALSE;
+ if ( !text_to_speak ) return EINA_FALSE;
+ if ( !text_to_speak[0] ) return EINA_FALSE;
if(tts_add_text( sd->tts, text_to_speak, sd->language, TTS_VOICE_TYPE_AUTO, TTS_SPEED_AUTO, &speak_id))
- return FALSE;
+ return EINA_FALSE;
DEBUG("added id to:%d\n", speak_id);
last_utt_id = speak_id;
- return TRUE;
+ return EINA_TRUE;
}
-gboolean update_supported_voices(void *data)
+Eina_Bool update_supported_voices(void *data)
{
DEBUG("START");
tts_state_e state;
if(res != TTS_ERROR_NONE)
{
DEBUG("CANNOT RETRIVE STATE");
- return FALSE;
+ return EINA_FALSE;
}
if(state == TTS_STATE_READY)
}
else
{
- sd->update_language_list = TRUE;
+ sd->update_language_list = EINA_TRUE;
}
- DEBUG("END");
- return TRUE;
+ DEBUG("END")
+ return EINA_TRUE;
}
void state_changed_cb(tts_h tts, tts_state_e previous, tts_state_e current, void* user_data)
+#include <Elementary.h>
#include <vconf.h>
#include "screen_reader_vconf.h"
#include "screen_reader_spi.h"
#include "logger.h"
-#include <stdio.h>
#ifdef RUN_IPC_TEST_SUIT
#include "test_suite/test_suite.h"
{
DEBUG("START");
- GList *l;
+ Eina_List *l;
Voice_Info *vi;
if(strncmp(sd->language, new_language, LAN_NAME - 1) == 0 && sd->voice_type == new_voice)
return true;
}
- for (l = sd->available_languages; l; l = l->next)
+ EINA_LIST_FOREACH(sd->available_languages, l, vi)
{
- vi = l->data;
DEBUG("foreach %s <- %s", vi->language, new_language);
if(strncmp(vi->language, new_language, LAN_NAME - 1) == 0 &&
vi->voice_type == new_voice)
{
return FOCUS_CHANGED_SIG;
}
- return NULL;
+ return NULL;
}
bool set_tracking_listener(Service_Data *sd, const char *signal_name)
{
- DEBUG("START: %s", sd->tracking_signal_name);
+ DEBUG("START");
char *new_tracking_signal;
gboolean ret1 = atspi_event_listener_register(sd->spi_listener, sd->tracking_signal_name, NULL);
if(ret1 == false)
{
- DEBUG("FAILED TO REGISTER spi focus listener");
+ DEBUG("FAILED TO REGISTER spi focus/highlight listener");
return false;
}
else
void information_level_cb(keynode_t *node, void *user_data)
{
DEBUG("START");
- DEBUG("Information level set: %d", vconf_keynode_get_int(node));
+ DEBUG("Information level set: %d", node->value.i);
Service_Data *service_data = user_data;
- service_data->information_level = vconf_keynode_get_int(node);
+ service_data->information_level = node->value.i;
DEBUG("END");
}
void app_termination_cb(keynode_t *node, void *user_data)
{
DEBUG("START");
- DEBUG("Application terminate %d", !vconf_keynode_get_int(node));
+ DEBUG("Application terminate %d", !node->value.i);
Service_Data *service_data = user_data;
- service_data->run_service = vconf_keynode_get_int(node);
+ service_data->run_service = node->value.i;
if(service_data->run_service == 0)
{
- atspi_exit();
+ elm_exit();
}
DEBUG("END");
void language_cb(keynode_t *node, void *user_data)
{
DEBUG("START");
- DEBUG("Trying to set language to: %s", vconf_keynode_get_str(node));
+ DEBUG("Trying to set language to: %s", node->value.s);
Service_Data *sd = user_data;
int voice_type;
vconf_get_int("db/setting/accessibility/voice", (int*)(&voice_type));
- set_langauge(sd, vconf_keynode_get_str(node), voice_type);
+ set_langauge(sd, node->value.s, voice_type);
DEBUG("END");
}
void voice_cb(keynode_t *node, void *user_data)
{
DEBUG("START");
- DEBUG("Voice set to: %d", vconf_keynode_get_int(node));
+ DEBUG("Voice set to: %d", node->value.i);
Service_Data *sd = user_data;
const char *lang = vconf_get_str("db/setting/accessibility/language");
- set_langauge(sd, lang, vconf_keynode_get_int(node));
+ set_langauge(sd, lang, (int)node->value.i);
DEBUG("END");
}
void reading_speed_cb(keynode_t *node, void *user_data)
{
DEBUG("START");
- DEBUG("Reading speed set to: %d", vconf_keynode_get_int(node));
+ DEBUG("Reading speed set to: %d", node->value.i);
Service_Data *service_data = user_data;
- service_data->reading_speed = vconf_keynode_get_int(node);
+ service_data->reading_speed = node->value.i;
DEBUG("END");
}
void tracking_signal_changed_cb(keynode_t *node, void *user_data)
{
DEBUG("START");
- DEBUG("Tracking signal set to: %s", vconf_keynode_get_str(node));
+ DEBUG("Tracking signal set to: %s", node->value.s);
Service_Data *sd = user_data;
const char *tracking_signal = vconf_get_str("db/setting/accessibility/tracking_signal");
bool vconf_init(Service_Data *service_data)
{
DEBUG( "--------------------- VCONF_init START ---------------------");
+ printf( "--------------------- VCONF_init START ---------------------");
int ret = 0;
//TODO: Remove when adequate keys in the settings(control?) panel are added
vconf_keylist_add_int(keys, "db/setting/accessibility/information_level", 2);
vconf_keylist_add_str(keys, "db/setting/accessibility/language", "en_US");
vconf_keylist_add_int(keys, "db/setting/accessibility/voice", 1);
- vconf_keylist_add_str(keys, "db/setting/accessibility/tracking_signal", FOCUS_SIG);
+ vconf_keylist_add_str(keys, "db/setting/accessibility/tracking_signal", FOCUS_CHANGED_SIG);
//-----------------------------------------------------------------------------------
//vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, EINA_TRUE);
+#include <Ecore.h>
+#include <Ecore_Evas.h>
+#include <Evas.h>
#include <atspi/atspi.h>
-#include <stdio.h>
+#include <tone_player.h>
#include "logger.h"
#include "screen_reader_tts.h"
#include "screen_reader_haptic.h"
#define ITEMS_NOTIFICATION "Visible items from %d to %d"
-static gboolean status = FALSE;
+static Eina_Bool status = EINA_FALSE;
static void _smart_notification_focus_chain_end(void);
static void _smart_notification_realized_items(int start_idx, int end_idx);
*/
void smart_notification(Notification_Type nt, int start_index, int end_index)
{
+ DEBUG("START");
if(!status)
return;
*/
void get_realized_items_count(AtspiAccessible *scrollable_object, int *start_idx, int *end_idx)
{
+ DEBUG("START");
int count_child, jdx;
AtspiAccessible *child_iter;
AtspiStateType state = ATSPI_STATE_SHOWING;
* @param event AtspiEvent
* @param user_data UNUSED
*/
+
static void
-_scroll_event_cb(AtspiEvent *event, void *user_data)
+_scroll_event_cb(AtspiEvent *event, gpointer user_data)
{
if(!status)
return;
start_index = 0;
end_index = 0;
- DEBUG("Event: %s: %d, obj: %p: role: %s\n", event->type, event->detail1, event->source,
- atspi_accessible_get_role_name(event->source, NULL));
+ fprintf(stderr, "Event: %s: %d, obj: %p: role: %s\n", event->type, event->detail1, event->source,
+ atspi_accessible_get_role_name(event->source, NULL));
if (!strcmp(event->type, "object:scroll-start"))
{
DEBUG("Scrolling started");
- tts_speak("Scrolling started", TRUE);
+ tts_speak("Scrolling started", EINA_TRUE);
}
else if (!strcmp(event->type, "object:scroll-end"))
{
DEBUG("Scrolling finished");
- tts_speak("Scrolling finished", FALSE);
+ tts_speak("Scrolling finished", EINA_FALSE);
get_realized_items_count((AtspiAccessible *)event->source, &start_index, &end_index);
_smart_notification_realized_items(start_index, end_index);
}
haptic_module_init();
- status = TRUE;
+ status = EINA_TRUE;
}
/**
*/
void smart_notification_shutdown(void)
{
- status = FALSE;
+ status = EINA_FALSE;
}
/**
return;
DEBUG(RED"Smart notification - FOCUS CHAIN END"RESET);
+
+ tone_player_stop(0);
+ tone_player_start(TONE_TYPE_SUP_CONFIRM, SOUND_TYPE_MEDIA, 200, NULL);
}
/**
snprintf(buf, sizeof(buf), ITEMS_NOTIFICATION, start_idx, end_idx);
- tts_speak(strdup(buf), FALSE);
+ tts_speak(strdup(buf), EINA_FALSE);
}
#include "position_sort.h"
#include "logger.h"
-static GList*
+static Eina_List*
_atspi_children_list_get(AtspiAccessible *parent)
{
- GList *ret = NULL;
+ Eina_List *ret = NULL;
int count = atspi_accessible_get_child_count(parent, NULL);
int i;
for (i = 0; i < count; i++)
{
AtspiAccessible *child = atspi_accessible_get_child_at_index(parent, i, NULL);
- if (child) ret = g_list_append(ret, child);
+ if (child) ret = eina_list_append(ret, child);
}
return ret;
}
static void
-_atspi_children_list_free(GList *children)
+_atspi_children_list_free(Eina_List *children)
{
- for (; children; children = children->next)
- g_object_unref(children->data);
+ AtspiAccessible *obj;
+
+ EINA_LIST_FREE(children, obj)
+ g_object_unref(obj);
}
-static GList*
-_flat_review_get(GList *tosort)
+static Eina_List*
+_flat_review_get(Eina_List *tosort)
{
- GList *ret = NULL, *lines, *l, *line;
+ Eina_List *ret = NULL, *lines, *l, *line;
lines = position_sort(tosort);
- for (l = lines; l; l = l->next)
+ EINA_LIST_FOREACH(lines, l, line)
{
- line = l->data;
- ret = g_list_concat(ret, line);
+ ret = eina_list_merge(ret, line);
}
- g_list_free(lines);
+ eina_list_free(lines);
return ret;
}
AtspiAccessible *structural_navi_same_level_next(AtspiAccessible *current)
{
- AtspiAccessible *parent, *ret = NULL;
+ AtspiAccessible *parent;
AtspiRole role;
parent = atspi_accessible_get_parent(current, NULL);
role = atspi_accessible_get_role(parent, NULL);
if (role != ATSPI_ROLE_DESKTOP_FRAME)
{
- GList *children = _atspi_children_list_get(parent);
- GList *sorted = _flat_review_get(children);
- GList *me = g_list_find(sorted, current);
- if (me)
- ret = me->next ? me->next->data : NULL;
+ Eina_List *children = _atspi_children_list_get(parent);
+ Eina_List *me = eina_list_data_find_list(children, current);
+ Eina_List *sorted = _flat_review_get(children);
+ me = eina_list_data_find_list(sorted, current);
+ AtspiAccessible *ret = eina_list_data_get(eina_list_next(me));
- if (sorted) g_list_free(sorted);
+ eina_list_free(sorted);
_atspi_children_list_free(children);
return ret;
AtspiAccessible *structural_navi_same_level_prev(AtspiAccessible *current)
{
- AtspiAccessible *parent, *ret = NULL;
+ AtspiAccessible *parent;
AtspiRole role;
parent = atspi_accessible_get_parent(current, NULL);
role = atspi_accessible_get_role(parent, NULL);
if (role != ATSPI_ROLE_DESKTOP_FRAME)
{
- GList *children = _atspi_children_list_get(parent);
- GList *sorted = _flat_review_get(children);
- GList *me = g_list_find(sorted, current);
- if (me)
- ret = me->prev ? me->prev->data : NULL;
+ Eina_List *children = _atspi_children_list_get(parent);
+ Eina_List *sorted = _flat_review_get(children);
+ Eina_List *me = eina_list_data_find_list(sorted, current);
+ AtspiAccessible *ret = eina_list_data_get(eina_list_prev(me));
- if (sorted) g_list_free(sorted);
+ eina_list_free(sorted);
_atspi_children_list_free(children);
return ret;
{
AtspiAccessible *ret;
- GList *children = _atspi_children_list_get(current);
- GList *sorted = _flat_review_get(children);
+ Eina_List *children = _atspi_children_list_get(current);
+ Eina_List *sorted = _flat_review_get(children);
- ret = sorted ? sorted->data : NULL;
+ ret = eina_list_data_get(sorted);
- if (sorted) g_list_free(sorted);
+ eina_list_free(sorted);
_atspi_children_list_free(children);
return ret;
static void
_on_atspi_window_cb(const AtspiEvent *event)
{
+ DEBUG("START");
+ DEBUG("%s", event->type);
if (!strcmp(event->type, "window:activate") ||
- !strcmp(event->type, "window:restore"))
+ !strcmp(event->type, "window:restore") ||
+ !strcmp(event->type, "window:create"))
{
if (last_active_win != event->source)
{
int i, j;
last_active_win = NULL;
AtspiAccessible *desktop = atspi_get_desktop(0);
+ DEBUG("START");
+ if (desktop) {
+ DEBUG("DESKTOP FOUND");
+ }
+ else {
+ ERROR("DESKTOP NOT FOUND");
+ }
for (i = 0; i < atspi_accessible_get_child_count(desktop, NULL); i++) {
AtspiAccessible *app = atspi_accessible_get_child_at_index(desktop, i, NULL);
void window_tracker_init(void)
{
+ DEBUG("START");
listener = atspi_event_listener_new_simple(_on_atspi_window_cb, NULL);
atspi_event_listener_register(listener, "window:activate", NULL);
+ atspi_event_listener_register(listener, "window:create", NULL);
atspi_event_listener_register(listener, "window:deactivate", NULL);
atspi_event_listener_register(listener, "window:restore", NULL);
atspi_event_listener_register(listener, "window:destroy", NULL);
void window_tracker_shutdown(void)
{
atspi_event_listener_deregister(listener, "window:activate", NULL);
+ atspi_event_listener_deregister(listener, "window:create", NULL);
atspi_event_listener_deregister(listener, "window:deactivate", NULL);
atspi_event_listener_deregister(listener, "window:restore", NULL);
atspi_event_listener_deregister(listener, "window:destroy", NULL);
void window_tracker_active_window_request(void)
{
+ DEBUG("START");
_get_active_win();
if (user_cb) user_cb(user_data, last_active_win);
}
## PROJECT NAME
-PROJECT(smart-navigator-tests C)
+PROJECT(screen-reader-tests C)
## INCLUDES
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
gobject-2.0
dlog
dbus-1
+ ecore
+ eldbus
+ eina
tts
check
vconf
+ elementary
)
FOREACH(flag ${tests_CFLAGS})
${CMAKE_SOURCE_DIR}/src/screen_reader_vconf.c
${CMAKE_SOURCE_DIR}/src/screen_reader_spi.c
${CMAKE_SOURCE_DIR}/src/screen_reader_tts.c
+ ${CMAKE_SOURCE_DIR}/src/logger.c
${CMAKE_SOURCE_DIR}/src/flat_navi.c
${CMAKE_SOURCE_DIR}/src/position_sort.c
${CMAKE_SOURCE_DIR}/src/object_cache.c)
-ADD_EXECUTABLE(screen_reader_test_suite screen_reader_test_suite.c ${TESTED_SRCS})
-TARGET_LINK_LIBRARIES(screen_reader_test_suite atspi ${tests_LDFLAGS} ${SLP_LD_PATH_FLAGS} ${SLP_LD_FLAGS} ${SLP_LINKER_FLAGS})
+ADD_EXECUTABLE(smart_navi_test_suite smart_navi_suite.c ${TESTED_SRCS})
+TARGET_LINK_LIBRARIES(smart_navi_test_suite atspi ${tests_LDFLAGS} ${SLP_LD_PATH_FLAGS} ${SLP_LD_FLAGS} ${SLP_LINKER_FLAGS})
#include "flat_navi.h"
#include <check.h>
#include <stdio.h>
-#include <stdlib.h>
#include <atspi/atspi.h>
+#include <Eina.h>
static AtspiAccessible *root;
static AtspiAccessible *child1;
data->run_service = 1;
data->voice_type = TTS_VOICE_TYPE_FEMALE;
data->reading_speed = 2;
- data->tracking_signal_name = "test_event";
+ data->tracking_signal_name = FOCUS_CHANGED_SIG;
//Set by tts
data->tts = NULL;
atspi_accessible_add_child(root, child2);
atspi_accessible_add_child(root, child3);
atspi_accessible_add_child(root, child4);
+ eina_init();
atspi_alloc_memory();
ctx = flat_navi_context_create(root);
}
{
flat_navi_context_free(ctx);
atspi_free_memory();
+ eina_shutdown();
atspi_delete_accessible(root);
teardown();
}
{
Service_Data *sd = get_pointer_to_service_data_struct();
AtspiEvent event;
- AtspiAccessible *accessible = atspi_create_accessible();
+ AtspiAccessible accessible;
event.type = "test_event";
sd->tracking_signal_name = "test_event";
event.detail1 = 1;
- accessible->name = "test_name";
- event.source = accessible;
+ accessible.name = "test_name";
+ accessible.description = NULL;
+ event.source = &accessible;
char *return_value = spi_event_get_text_to_read(&event, sd);
fail_if(!return_value || strcmp(return_value, "test_name"));
free(return_value);
- atspi_delete_accessible(accessible);
}
END_TEST
-START_TEST(spi_on_state_change_name_tree)
-{
- Service_Data *sd = get_pointer_to_service_data_struct();
- AtspiEvent event;
- AtspiAccessible *accessible = atspi_create_accessible();
- AtspiAccessible *child1 = atspi_create_accessible();
- AtspiAccessible *child11 = atspi_create_accessible();
- AtspiAccessible *child12 = atspi_create_accessible();
- AtspiAccessible *child2 = atspi_create_accessible();
- accessible->role = ATSPI_ROLE_FILLER;
- child1->role = ATSPI_ROLE_FILLER;
- child11->role = ATSPI_ROLE_FILLER;
- child12->role = ATSPI_ROLE_FILLER;
- child2->role = ATSPI_ROLE_FILLER;
- child1->name = "one";
- child11->name = "two";
- child12->name = "two1";
- child2->name = "three";
- atspi_accessible_add_child(accessible, child1);
- atspi_accessible_add_child(child1, child11);
- atspi_accessible_add_child(child1, child12);
- atspi_accessible_add_child(accessible, child2);
- event.type = "test_event";
- sd->tracking_signal_name = "test_event";
- event.detail1 = 1;
- event.source = accessible;
- char *return_value = spi_event_get_text_to_read(&event, sd);
- fail_if(!return_value || strcmp(return_value, "one two two1 three "));
- free(return_value);
- atspi_delete_accessible(accessible);
-}
-END_TEST
START_TEST(spi_on_state_change_description)
{
Service_Data *sd = get_pointer_to_service_data_struct();
AtspiEvent event;
- AtspiAccessible *accessible = atspi_create_accessible();
+ AtspiAccessible accessible;
event.type = "test_event";
sd->tracking_signal_name = "test_event";
event.detail1 = 1;
- accessible->name = "test_name";
- accessible->description = "test description";
- event.source = accessible;
+ accessible.name = "test_name";
+ accessible.description = "test description";
+ event.source = &accessible;
char *return_value = spi_event_get_text_to_read(&event, sd);
fail_if(!return_value || strcmp(return_value, "test description"));
free(return_value);
- atspi_delete_accessible(accessible);
}
END_TEST
{
Service_Data *sd = get_pointer_to_service_data_struct();
AtspiEvent event;
- AtspiAccessible *accessible = atspi_create_accessible();
+ AtspiAccessible accessible;
event.type = "test_event";
sd->tracking_signal_name = "test_event";
event.detail1 = 1;
- accessible->role = ATSPI_ROLE_ICON;
- accessible->name = NULL;
- accessible->description = NULL;
- event.source = accessible;
+ accessible.role = ATSPI_ROLE_ICON;
+ accessible.name = NULL;
+ accessible.description = NULL;
+ event.source = &accessible;
char *return_value = spi_event_get_text_to_read(&event, sd);
- fail_if(!return_value || strcmp(return_value, atspi_accessible_get_role_name(accessible, NULL)));
+ fail_if(!return_value || strcmp(return_value, atspi_accessible_get_role_name(&accessible, NULL)));
free(return_value);
- atspi_delete_accessible(accessible);
}
END_TEST
{
Service_Data *sd = get_pointer_to_service_data_struct();
AtspiEvent event;
- AtspiAccessible *accessible = atspi_create_accessible();
+ AtspiAccessible accessible;
event.type = "object:text-caret-moved";
- accessible->name = "test_name";
- event.source = accessible;
+ accessible.name = "test_name";
+ event.source = &accessible;
atspi_alloc_memory();
char *return_value = spi_event_get_text_to_read(&event, sd);
atspi_free_memory();
fail_if(!return_value || strcmp(return_value, "AtspiText text"));
free(return_value);
- atspi_delete_accessible(accessible);
}
END_TEST
START_TEST(spi_on_value_changed)
{
- Service_Data *sd = get_pointer_to_service_data_struct();
+Service_Data *sd = get_pointer_to_service_data_struct();
AtspiEvent event;
- AtspiAccessible *accessible = atspi_create_accessible();
+ AtspiAccessible accessible;
event.type = VALUE_CHANGED_SIG;
- accessible->name = "test_name";
- event.source = accessible;
+ accessible.name = "test_name";
+ event.source = &accessible;
atspi_alloc_memory();
char *return_value = spi_event_get_text_to_read(&event, sd);
atspi_free_memory();
fail_if(!return_value || strcmp(return_value, "1.00"));
free(return_value);
- atspi_delete_accessible(accessible);
-}
-END_TEST
-
-START_TEST(spi_on_editing)
-{
- Service_Data *sd = get_pointer_to_service_data_struct();
- AtspiEvent event;
- AtspiAccessible *accessible = atspi_create_accessible();
- event.type = FOCUS_CHANGED_SIG;
- accessible->name = "test_name";
- event.source = accessible;
- atspi_alloc_memory();
- char *return_value = spi_event_get_text_to_read(&event, sd);
- atspi_free_memory();
- fail_if(!return_value || strcmp(return_value, EDITING_STARTED));
- free(return_value);
- atspi_delete_accessible(accessible);
}
END_TEST
START_TEST(spi_flat_navi_context_current_set_null_parameters)
{
- gboolean ret = flat_navi_context_current_set(NULL, NULL);
- fail_if(ret != FALSE);
+ Eina_Bool ret = flat_navi_context_current_set(NULL, NULL);
+ fail_if(ret != EINA_FALSE);
ret = flat_navi_context_current_set(ctx, NULL);
- fail_if(ret != FALSE);
+ fail_if(ret != EINA_FALSE);
AtspiAccessible *last = flat_navi_context_last(ctx);
ret = flat_navi_context_current_set(NULL, last);
- fail_if(ret != FALSE);
+ fail_if(ret != EINA_FALSE);
}
END_TEST
START_TEST(spi_flat_navi_context_current_set_valid_parameters)
{
AtspiAccessible *last = flat_navi_context_last(ctx);
- gboolean ret = flat_navi_context_current_set(ctx, last);
+ Eina_Bool ret = flat_navi_context_current_set(ctx, last);
AtspiAccessible *current = flat_navi_context_current_get(ctx);
- fail_if(ret != TRUE || current != last);
+ fail_if(ret != EINA_TRUE || current != last);
}
END_TEST
TCase *tc_spi_screen_reader_on_state_changed;
TCase *tc_spi_screen_reader_on_caret_move;
TCase *tc_spi_screen_reader_on_access_value;
- TCase *tc_spi_screen_reader_on_editing;
TCase *tc_spi_screen_reader_flat_navi;
s = suite_create("Screen reader");
tc_spi_screen_reader_on_state_changed = tcase_create("tc_spi_screen_reader_on_state_changed");
tc_spi_screen_reader_on_caret_move = tcase_create("tc_spi_screen_reader_on_caret_move");
tc_spi_screen_reader_on_access_value = tcase_create("tc_spi_screen_reader_on_access_value");
- tc_spi_screen_reader_on_editing = tcase_create("tc_spi_screen_reader_on_editing");
tc_spi_screen_reader_flat_navi = tcase_create("tc_scpi_screen_reader_flat_navi");
tcase_add_checked_fixture(tc_spi_screen_reader_init, setup, teardown);
tcase_add_checked_fixture(tc_spi_screen_reader_on_state_changed, setup, teardown);
tcase_add_checked_fixture(tc_spi_screen_reader_on_caret_move, setup, teardown);
tcase_add_checked_fixture(tc_spi_screen_reader_on_access_value, setup, teardown);
- tcase_add_checked_fixture(tc_spi_screen_reader_on_editing, setup, teardown);
-
tcase_add_checked_fixture(tc_spi_screen_reader_flat_navi, setup_flat_navi, teardown_flat_navi);
tcase_add_test(tc_spi_screen_reader_init, spi_init_null_parameter);
tcase_add_test(tc_spi_screen_reader_init, spi_init_service_data_parameter);
tcase_add_test(tc_spi_screen_reader_on_state_changed, spi_on_state_change_name);
- tcase_add_test(tc_spi_screen_reader_on_state_changed, spi_on_state_change_name_tree);
tcase_add_test(tc_spi_screen_reader_on_state_changed, spi_on_state_change_description);
tcase_add_test(tc_spi_screen_reader_on_state_changed, spi_on_state_change_role);
tcase_add_test(tc_spi_screen_reader_on_caret_move, spi_on_caret_move);
tcase_add_test(tc_spi_screen_reader_on_access_value, spi_on_value_changed);
- tcase_add_test(tc_spi_screen_reader_on_editing, spi_on_editing);
- tcase_add_test(tc_spi_screen_reader_flat_navi, spi_flat_navi_context_create_null_parameter);
- tcase_add_test(tc_spi_screen_reader_flat_navi, spi_flat_navi_context_create_valid_parameter);
- tcase_add_test(tc_spi_screen_reader_flat_navi, spi_flat_navi_context_get_current_null_parameter);
- tcase_add_test(tc_spi_screen_reader_flat_navi, spi_flat_navi_context_get_current_valid_parameter);
- tcase_add_test(tc_spi_screen_reader_flat_navi, spi_flat_navi_context_next_null_parameter);
- tcase_add_test(tc_spi_screen_reader_flat_navi, spi_flat_navi_context_next_valid_parameter);
- tcase_add_test(tc_spi_screen_reader_flat_navi, spi_flat_navi_context_prev_null_parameter);
- tcase_add_test(tc_spi_screen_reader_flat_navi, spi_flat_navi_context_prev_valid_parameter);
- tcase_add_test(tc_spi_screen_reader_flat_navi, spi_flat_navi_context_last_null_parameter);
- tcase_add_test(tc_spi_screen_reader_flat_navi, spi_flat_navi_context_last_valid_parameter);
- tcase_add_test(tc_spi_screen_reader_flat_navi, spi_flat_navi_context_first_null_parameter);
- tcase_add_test(tc_spi_screen_reader_flat_navi, spi_flat_navi_context_first_valid_parameter);
- tcase_add_test(tc_spi_screen_reader_flat_navi, spi_flat_navi_context_current_set_null_parameters);
- tcase_add_test(tc_spi_screen_reader_flat_navi, spi_flat_navi_context_current_set_valid_parameters);
- tcase_add_test(tc_spi_screen_reader_flat_navi, spi_flat_navi_context_line_prev_null_parameter);
- tcase_add_test(tc_spi_screen_reader_flat_navi, spi_flat_navi_context_line_prev_valid_parameter);
- tcase_add_test(tc_spi_screen_reader_flat_navi, spi_flat_navi_context_line_next_null_parameter);
- tcase_add_test(tc_spi_screen_reader_flat_navi, spi_flat_navi_context_line_next_valid_parameter);
- tcase_add_test(tc_spi_screen_reader_flat_navi, spi_flat_navi_context_line_first_null_parameter);
- tcase_add_test(tc_spi_screen_reader_flat_navi, spi_flat_navi_context_line_first_valid_parameter);
- tcase_add_test(tc_spi_screen_reader_flat_navi, spi_flat_navi_context_line_last_null_parameter);
- tcase_add_test(tc_spi_screen_reader_flat_navi, spi_flat_navi_context_line_last_valid_parameter);
suite_add_tcase(s, tc_spi_screen_reader_init);
suite_add_tcase(s, tc_spi_screen_reader_on_state_changed);