static char *generate_description_from_relation_object(AtspiAccessible *obj)
{
- GError *err = NULL;
- char *ret = NULL;
- char trait[TTS_MAX_TEXT_SIZE] = "\0";
+ char trait[TTS_MAX_TEXT_SIZE] = "";
+
char *role_name = generate_role_trait(obj);
- char *description_from_role = generate_description_trait(obj);
- char *state_from_role = generate_state_trait(obj);
- if (role_name && strlen(role_name) > 0)
+ if (role_name) {
strncat(trait, role_name, sizeof(trait) - strlen(trait) - 1);
- if (description_from_role && strlen(description_from_role) > 0) {
+ free(role_name);
+ }
+
+ char *description_from_role = generate_description_trait(obj);
+ if (description_from_role) {
if (strlen(trait) > 0)
strncat(trait, ", ", sizeof(trait) - strlen(trait) - 1);
strncat(trait, description_from_role, sizeof(trait) - strlen(trait) - 1);
+ free(description_from_role);
}
- if (state_from_role && strlen(state_from_role) > 0) {
+
+ char *state_from_role = generate_state_trait(obj);
+ if (state_from_role) {
if (strlen(trait) > 0)
strncat(trait, ", ", sizeof(trait) - strlen(trait) - 1);
strncat(trait, state_from_role, sizeof(trait) - strlen(trait) - 1);
+ free(state_from_role);
}
+ GError *err = NULL;
char *desc = atspi_accessible_get_description(obj, &err);
if (err)
{
g_error_free(err);
g_free(desc);
- return strdup(trait);
}
-
- if (desc && desc[0]!= '\0') {
- if (asprintf(&ret, "%s, %s", desc, trait) < 0)
- ERROR("asprintf failed.");
- return strdup(ret);
+ else if (desc) {
+ if (desc[0] != '\0') {
+ char *ret = NULL;
+ if (asprintf(&ret, "%s, %s", desc, trait) < 0)
+ ERROR("asprintf failed.");
+ g_free(desc);
+ return ret;
+ }
g_free(desc);
}
-
return strdup(trait);
}
static Eina_Bool _do_action(AtspiAccessible *obj, char *expected_action)
{
- AtspiAction *action;
- GError *err = NULL;
- gint i = 0;
- gint number_of_action = 0;
- gchar *action_name = NULL;
- Eina_Bool action_found = EINA_FALSE;
Eina_Bool ret = EINA_FALSE;
- action = atspi_accessible_get_action_iface(obj);
+ DEBUG("looking to execute action %s", expected_action);
+ AtspiAction *action = atspi_accessible_get_action_iface(obj);
if (action) {
- number_of_action = atspi_action_get_n_actions(action, &err);
- GERROR_CHECK(err)
+ GError *err = NULL;
+ gint number_of_actions = atspi_action_get_n_actions(action, &err);
+ GERROR_CHECK(err);
+ DEBUG("Number of available action = %d", number_of_actions);
- while (i < number_of_action && !action_found) {
- action_name = atspi_action_get_name(action, i, &err);
+ gint i = 0;
+ for(i = 0; i < number_of_actions; ++i) {
+ gchar *action_name = atspi_action_get_name(action, i, &err);
GERROR_CHECK(err)
-
- if (action_name && !strcmp(expected_action, action_name)) {
- DEBUG("Expected action %s (index: %d) found!", expected_action, i);
- action_found = EINA_TRUE;
- } else {
- i++;
+ if (action_name) {
+ Eina_Bool execute = !strcmp(expected_action, action_name);
+ g_free(action_name);
+ if (execute) {
+ DEBUG("Expected action %s (index: %d) found!", expected_action, i);
+ ret = atspi_action_do_action(action, i, &err);
+ GERROR_CHECK(err);
+ break;
+ }
}
- g_free(action_name);
- }
-
- if (action_found) {
- ret = atspi_action_do_action(action, i, &err);
- GERROR_CHECK(err)
}
g_object_unref(action);
+ if (i >= number_of_actions)
+ ERROR("Cannot find expected action %s", expected_action);
}
- if (!action_found)
- ERROR("Cannot find expected action %s", expected_action);
-
+ DEBUG("END");
return ret;
}
{
DEBUG("START");
- GError *err = NULL;
- gchar *role_name = NULL;
- AtspiRole role = -1;
-
if (!obj) {
DEBUG("Clearing highlight object");
nd->current_obj = NULL;
if (nd->current_comp) {
+ GError *err = NULL;
atspi_component_clear_highlight(nd->current_comp, &err);
g_object_unref(nd->current_comp);
nd->current_comp = NULL;
AtspiComponent *comp = atspi_accessible_get_component_iface(obj);
if (!comp) {
GError *err = NULL;
- role_name = atspi_accessible_get_role_name(obj, &err);
+ gchar *role_name = atspi_accessible_get_role_name(obj, &err);
ERROR("AtspiComponent *comp NULL, [%s]", role_name);
GERROR_CHECK(err);
g_free(role_name);
return;
}
if (nd->current_comp) {
+ GError *err = NULL;
atspi_component_clear_highlight(nd->current_comp, &err);
+ GERROR_CHECK(err);
}
if (get_sound_feedback(vconf_data)) {
DEBUG("HIGHLIGHT_NOTIFICATION_EVENT");
smart_notification(HIGHLIGHT_NOTIFICATION_EVENT, 0, 0);
}
+ g_object_unref(action);
}
if (get_haptic(vconf_data))
haptic_vibrate_start(HAPTIC_VIBRATE_DURATION, HAPTIC_VIBRATE_INTENSITY, haptic_data);
- role = atspi_accessible_get_role(obj, NULL);
+ AtspiRole role = atspi_accessible_get_role(obj, NULL);
if (role != ATSPI_ROLE_PAGE_TAB && role != ATSPI_ROLE_POPUP_MENU) { /* ctxpopup outline does not show highlight frame */
if (role == ATSPI_ROLE_UNKNOWN) {
/* to support elm_access used for embedded toolkit,
because there could be other ATSPI_ROLE_UNKNOWN. */
_highlight_type_set(obj, h_type);
}
+ GError *err = NULL;
atspi_component_grab_highlight(comp, &err);
+ GERROR_CHECK(err);
}
nd->current_comp = comp;
- GERROR_CHECK(err)
Eina_Bool is_paused = tts_pause_get(tts_data);
if (is_paused) {
void test_debug(AtspiAccessible *current_widget)
{
- int jdx;
- int count_child;
- gchar *role;
GError *err = NULL;
- AtspiAccessible *child_iter = NULL;
AtspiAccessible *parent = atspi_accessible_get_parent(current_widget, &err);
GERROR_CHECK(err)
-
- if (!parent)
- return;
- count_child = atspi_accessible_get_child_count(parent, &err);
- GERROR_CHECK(err)
+ if (parent) {
+ int count_child = atspi_accessible_get_child_count(parent, &err);
+ GERROR_CHECK(err);
DEBUG("Total childs in parent: %d\n", count_child);
- if (!count_child)
- {
- g_object_unref(parent);
- return;
- }
- for (jdx = 0; jdx < count_child; jdx++) {
- child_iter = atspi_accessible_get_child_at_index(parent, jdx, &err);
- GERROR_CHECK(err)
+ int jdx;
+ for (jdx = 0; jdx < count_child; jdx++) {
+ AtspiAccessible *child_iter = atspi_accessible_get_child_at_index(parent, jdx, &err);
+ GERROR_CHECK(err);
+ gchar *role = NULL;
if (current_widget == child_iter) {
- role = atspi_accessible_get_role_name(parent, &err);
- DEBUG("Childen found in parent: %s at index: %d\n", role, jdx);
- } else {
- role = atspi_accessible_get_role_name(parent, &err);
- DEBUG("Childen not found in parent: %s at index: %d\n", role, jdx);
+ role = atspi_accessible_get_role_name(parent, &err);
+ DEBUG("Childen found in parent: %s at index: %d\n", role, jdx);
+ }
+ else {
+ role = atspi_accessible_get_role_name(parent, &err);
+ DEBUG("Childen not found in parent: %s at index: %d\n", role, jdx);
+ }
+ g_free(role);
+ GERROR_CHECK(err);
}
- g_free(role);
- GERROR_CHECK(err)
+ g_object_unref(parent);
}
- g_object_unref(parent);
}
static void _focus_widget(Navigator_Data *nd, Screen_Reader_Vconf_Data_t *vconf_data, Haptic_Data *haptic_data, Screen_Reader_Tts_Data_t *tts_data, Flat_Navi_Context *context, Gesture_Info *info)
static void _caret_move_forward(Navigator_Data *nd, Screen_Reader_Tts_Data_t *tts_data)
{
- AtspiAccessible *current_widget = NULL;
- AtspiText *text_interface;
- gint current_offset;
- gboolean ret;
- int offset_pos;
- gchar *text;
- GError *err = NULL;
if (nd->current_obj == NULL)
return;
AtspiAccessible *relation = flat_navi_get_object_in_relation(nd->current_obj, ATSPI_RELATION_CONTROLLER_FOR);
- if(relation)
- current_widget = relation;
- else
- current_widget = nd->current_obj;
-
- text_interface = atspi_accessible_get_text_iface(current_widget);
+ AtspiAccessible *current_widget = relation ? relation : nd->current_obj;
+ AtspiText *text_interface = atspi_accessible_get_text_iface(current_widget);
if(relation)
g_object_unref(relation);
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) {
- offset_pos = atspi_text_get_caret_offset(text_interface, NULL);
- text = atspi_text_get_text(text_interface, offset_pos, offset_pos + 1, NULL);
+ GError *err = NULL;
+ gint current_offset = atspi_text_get_caret_offset(text_interface, &err);
+ GERROR_CHECK(err);
+ gboolean ret = atspi_text_set_caret_offset(text_interface, current_offset + 1, &err);
+ GERROR_CHECK(err);
+ if (ret) {
+ int offset_pos = atspi_text_get_caret_offset(text_interface, NULL);
+ gchar *text = atspi_text_get_text(text_interface, offset_pos, offset_pos + 1, NULL);
DEBUG("Caret position increment done");
DEBUG("Current caret position:%d", offset_pos);
DEBUG("Current caret offset:%d", current_offset);
static void _caret_move_backward(Navigator_Data *nd, Screen_Reader_Tts_Data_t *tts_data)
{
- AtspiAccessible *current_widget = NULL;
- AtspiText *text_interface;
- gint current_offset;
- int offset_pos;
- gchar *text;
- GError *err = NULL;
- gboolean ret;
-
if (nd->current_obj == NULL)
return;
AtspiAccessible *relation = flat_navi_get_object_in_relation(nd->current_obj, ATSPI_RELATION_CONTROLLER_FOR);
- if(relation)
- current_widget = relation;
- else
- current_widget = nd->current_obj;
-
- GERROR_CHECK(err)
-
- text_interface = atspi_accessible_get_text_iface(current_widget);
-
+ AtspiAccessible *current_widget = relation ? relation : nd->current_obj;
+ AtspiText *text_interface = atspi_accessible_get_text_iface(current_widget);
if(relation)
g_object_unref(relation);
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) {
- offset_pos = atspi_text_get_caret_offset(text_interface, NULL);
- text = atspi_text_get_text(text_interface, offset_pos, offset_pos + 1, NULL);
+ GError *err = NULL;
+ gint current_offset = atspi_text_get_caret_offset(text_interface, &err);
+ GERROR_CHECK(err);
+ gboolean ret = atspi_text_set_caret_offset(text_interface, current_offset - 1, &err);
+ GERROR_CHECK(err);
+ if (ret) {
+ int offset_pos = atspi_text_get_caret_offset(text_interface, NULL);
+ gchar *text = atspi_text_get_text(text_interface, offset_pos, offset_pos + 1, NULL);
DEBUG("Caret position decrement done");
DEBUG("Current caret position:%d", offset_pos);
DEBUG("SPEAK:%s", text);
DEBUG("SPEAK:%s", _("IDS_TEXT_BEGIN"));
tts_speak_customized(_("IDS_TEXT_BEGIN"), EINA_FALSE, EINA_TRUE, nd->current_obj, tts_data);
}
- } else {
- ERROR("Caret position decrement error");
}
+ else
+ ERROR("Caret position decrement error");
g_object_unref(text_interface);
- } else
+ }
+ else
ERROR("No text interface supported!");
return;
}
AtspiValue *value_interface = atspi_accessible_get_value_iface(current_widget);
- if(relation)
+ if (relation)
g_object_unref(relation);
if (value_interface) {
//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 = NULL;
- AtspiAccessible *parent = NULL;
- AtspiStateSet *ss = NULL;
- AtspiSelection *selection = NULL;
- AtspiAction *action;
- AtspiEditableText *edit = NULL;
-
- GError *err = NULL;
- gchar *actionName = NULL;
- gint number = 0;
- gint i = 0;
- gint index = 0;
- Eina_Bool activate_found = EINA_FALSE;
- AtspiRole role = ATSPI_ROLE_INVALID;
if (nd->current_obj == NULL)
return;
}
AtspiAccessible *relation = flat_navi_get_object_in_relation(nd->current_obj, ATSPI_RELATION_CONTROLLER_FOR);
- if(relation)
- current_widget = relation;
- else
- current_widget = nd->current_obj;
-
- role = atspi_accessible_get_role(current_widget, NULL);
+ AtspiAccessible *current_widget = relation ? relation : nd->current_obj;
+ AtspiRole role = atspi_accessible_get_role(current_widget, NULL);
if (role == ATSPI_ROLE_SLIDER) {
if(relation)
g_object_unref(relation);
debug_display_info_about_object(current_widget, false);
- if (get_sound_feedback(vconf_data)) {
+ if (get_sound_feedback(vconf_data))
smart_notification(ACTION_NOTIFICATION_EVENT, 0, 0);
- }
- action = atspi_accessible_get_action_iface(current_widget);
- if (action) {
- number = atspi_action_get_n_actions(action, &err);
- GERROR_CHECK(err);
- activate_found = EINA_FALSE;
- DEBUG("Number of available action = %d\n", number);
- while (i < number && !activate_found) {
- actionName = atspi_action_get_action_name(action, i, &err);
- GERROR_CHECK(err);
- if (actionName && !strcmp("activate", actionName)) {
- DEBUG("There is activate action");
- activate_found = EINA_TRUE;
- } else {
- i++;
- }
- g_free(actionName);
- }
- if (activate_found) {
- DEBUG("PERFORMING ATSPI ACTION NO.%d", i);
- atspi_action_do_action(action, i, &err);
- GERROR_CHECK(err);
- g_object_unref(action);
- //return; //we need to read the current status also.
- } else
- ERROR("There is no activate action inside Action interface");
- g_object_unref(action);
- }
+ _do_action(current_widget, "activate");
- edit = atspi_accessible_get_editable_text_iface(current_widget);
+ AtspiEditableText *edit = atspi_accessible_get_editable_text_iface(current_widget);
if (edit) {
DEBUG("Activated object has editable Interface");
- focus_component = atspi_accessible_get_component_iface(current_widget);
+ AtspiComponent *focus_component = atspi_accessible_get_component_iface(current_widget);
if (focus_component) {
- if (atspi_component_grab_focus(focus_component, &err) == TRUE) {
+ GError *err = NULL;
+ if (atspi_component_grab_focus(focus_component, &err)) {
GERROR_CHECK(err)
- DEBUG("Entry activated\n");
- char *text_to_speak = NULL;
- text_to_speak = generate_what_to_read(current_widget, vconf_data);
+ DEBUG("Entry activated");
+ char *text_to_speak = generate_what_to_read(current_widget, vconf_data);
DEBUG("SPEAK:%s", text_to_speak);
tts_speak(text_to_speak, EINA_TRUE, tts_data);
g_free(text_to_speak);
- g_object_unref(focus_component);
}
+ g_object_unref(focus_component);
}
g_object_unref(edit);
if(relation)
return;
}
- ss = atspi_accessible_get_state_set(current_widget);
- if (atspi_state_set_contains(ss, ATSPI_STATE_SELECTABLE) == EINA_TRUE) {
- DEBUG("OBJECT IS SELECTABLE");
- parent = atspi_accessible_get_parent(current_widget, NULL);
- if (parent) {
- index = atspi_accessible_get_index_in_parent(current_widget, NULL);
- selection = atspi_accessible_get_selection_iface(parent);
- if (selection) {
- if(atspi_state_set_contains(ss, ATSPI_STATE_SELECTED)) {
- atspi_selection_deselect_child (selection, index, NULL);
-
- } else {
- DEBUG("SELECT CHILD NO:%d\n", index);
- atspi_selection_select_child(selection, index, NULL);
+ AtspiStateSet *ss = atspi_accessible_get_state_set(current_widget);
+ if (ss) {
+ if (atspi_state_set_contains(ss, ATSPI_STATE_SELECTABLE) == EINA_TRUE) {
+ DEBUG("OBJECT IS SELECTABLE");
+ AtspiAccessible *parent = atspi_accessible_get_parent(current_widget, NULL);
+ if (parent) {
+ gint index = atspi_accessible_get_index_in_parent(current_widget, NULL);
+ AtspiSelection *selection = atspi_accessible_get_selection_iface(parent);
+ if (selection) {
+ if(atspi_state_set_contains(ss, ATSPI_STATE_SELECTED))
+ atspi_selection_deselect_child (selection, index, NULL);
+ else {
+ DEBUG("SELECT CHILD NO:%d\n", index);
+ atspi_selection_select_child(selection, index, NULL);
+ }
+ g_object_unref(selection);
}
- if(relation)
- g_object_unref(relation);
- g_object_unref(selection);
- g_object_unref(parent);
- g_object_unref(ss);
- return;
- } else
- ERROR("no selection iterface in parent");
+ else
+ ERROR("no selection iterface in parent");
- g_object_unref(parent);
+ g_object_unref(parent);
+ }
}
+ g_object_unref(ss);
}
if(relation)
g_object_unref(relation);
- g_object_unref(ss);
}
static void _quickpanel_change_state(gboolean quickpanel_switch)
void _widget_scroll(Navigator_Data *nd, Screen_Reader_Vconf_Data_t *vconf_data, Haptic_Data *haptic_data, Screen_Reader_Tts_Data_t *tts_data, Flat_Navi_Context *context, Gesture_Info *gi)
{
DEBUG("Recognized gesture state: %d", gi->state);
- int x_diff, y_diff;
if (gi->state == 0) {
DEBUG("save coordinates %d %d", nd->gesture_start_p.x, nd->gesture_start_p.y);
if (!atspi_state_set_contains(ss, ATSPI_STATE_SHOWING)) {
DEBUG("current context do not have visible state, swith to next/prev %d %d", gi->x_end,gi->y_end);
- x_diff = (gi->x_end - nd->gesture_start_p.x);
- y_diff = (gi->y_end - nd->gesture_start_p.y);
+ int x_diff = (gi->x_end - nd->gesture_start_p.x);
+ int y_diff = (gi->y_end - nd->gesture_start_p.y);
DEBUG("%d %d", y_diff, x_diff);
if (abs(y_diff) >= abs(x_diff)) {
if (y_diff > 0) {
{
DEBUG("START");
- Eina_Bool res = EINA_FALSE;
bool pause = tts_pause_get(tts_data);
- res = tts_pause_set(tts_data, !pause);
- if (!res) {
+ Eina_Bool res = tts_pause_set(tts_data, !pause);
+ if (!res)
ERROR("Failed to set pause state");
- }
DEBUG("END");
}
void auto_review_highlight_top(Navigator_Data *nd, Screen_Reader_Vconf_Data_t *vconf_data, Haptic_Data *haptic_data, Screen_Reader_Tts_Data_t *tts_data, Flat_Navi_Context *context)
{
DEBUG("START");
- char *text_to_speak = NULL;
AtspiAccessible *obj = flat_navi_context_current_get(context);
AtspiAccessible *first = flat_navi_context_first(context);
if (first != obj) {
_current_highlight_object_set(nd, vconf_data, haptic_data, tts_data, first, HIGHLIGHT_FIRST);
} else {
- text_to_speak = generate_what_to_read(obj, vconf_data);
+ char *text_to_speak = generate_what_to_read(obj, vconf_data);
DEBUG("Text to speak: %s", text_to_speak);
tts_speak_customized(text_to_speak, EINA_TRUE, EINA_TRUE, obj, tts_data);
free(text_to_speak);
return;
}
- AtspiAccessible *obj = NULL;
- AtspiComponent *comp = NULL;
- AtspiRect *rect = NULL;
- obj = nd->current_obj;
-
+ AtspiAccessible *obj = nd->current_obj;
if (!obj) {
DEBUG("no object");
nd->prepared = false;
smart_notification(LONG_PRESS_NOTIFICATION_EVENT, 0, 0);
if (gi->state == 0) {
- comp = atspi_accessible_get_component_iface(obj);
+ AtspiComponent *comp = atspi_accessible_get_component_iface(obj);
if (!comp) {
ERROR("that slider do not have component interface");
nd->prepared = false;
return;
}
- rect = atspi_component_get_extents(comp, ATSPI_COORD_TYPE_SCREEN, NULL);
+ AtspiRect *rect = atspi_component_get_extents(comp, ATSPI_COORD_TYPE_SCREEN, NULL);
DEBUG("Current object is in:%d %d", rect->x, rect->y);
DEBUG("Current object has size:%d %d", rect->width, rect->height);
-
}
if (gi->state == 1) {
nd->counter++;
DEBUG("SCROLLING but not meet counter:%d", nd->counter);
- if (nd->counter >= GESTURE_LIMIT) {
+ if (nd->counter >= GESTURE_LIMIT) {
nd->counter = 0;
DEBUG("Scroll on point %d %d", gi->x_end, gi->y_end);
if (nd->last_pos.x != -1) {
static int _find_action_index(AtspiAction *action, char *action_name_to_find)
{
int action_num = atspi_action_get_n_actions(action, NULL);
- char *action_name = NULL;
-
int i = 0;
for (i = 0; i < action_num; ++i) {
- action_name = atspi_action_get_action_name(action, i, NULL);
+ char *action_name = atspi_action_get_action_name(action, i, NULL);
- if (!strcmp(action_name_to_find, action_name)) {
+ if (!strcmp(action_name_to_find, action_name))
return i;
- }
}
return -i;
Eina_Bool keyboard_status;
#endif
DEBUG("In _on_gestures_detected callback");
- Gesture_Info *info = calloc(sizeof(Gesture_Info), 1);
- int g_type;
if (!msg) {
DEBUG("Incoming message is empty");
return;
}
+ Gesture_Info *info = calloc(sizeof(Gesture_Info), 1);
+ int g_type;
if (!eldbus_message_arguments_get(msg, "iiiiiiu", &g_type, &info->x_beg,
&info->y_beg, &info->x_end, &info->y_end,
&info->state, &info->event_time)) {
DEBUG("Getting message arguments failed");
+ free(info);
return;
}
info->type = (Gesture)g_type;
DEBUG("Gesture type %d not handled in switch", info->type);
}
dbus_gesture_adapter_emit(info, sd->gesture_adapter_data);
+ free(info);
}
if (release_obj)
g_object_unref(obj);
- return strdup(default_label);
+ return default_label;
}
void navigator_gestures_tracker_register(Navigator_Data *nd, GestureCB gesture_cb, void *data)