Add atspi_accessible_get_reading_material 33/136233/1
authorShinwoo Kim <cinoo.kim@samsung.com>
Fri, 26 May 2017 13:03:26 +0000 (22:03 +0900)
committerShinwoo Kim <cinoo.kim@samsung.com>
Wed, 28 Jun 2017 23:59:14 +0000 (08:59 +0900)
To get reading material to be used screen-reader side. This is not stable.
You have to handle all alocated memory as below on screen-reader side.

AtspiAccessibleReadingMaterial *rm
g_object_unref(rm->parent);
g_object_unref(rm->described_by_accessible);
g_hash_table_unref(rm->attributes);
free(rm->name);
free(rm->labeled_by_name);
free(rm->text_interface_name);
free(rm->localized_role_name);
free(rm->description);
free(rm);

Related patch set:
https://review.tizen.org/gerrit/#/c/131358/ (this one, at-spi2-core)
https://review.tizen.org/gerrit/#/c/131359/ (elementary)
https://review.tizen.org/gerrit/#/c/131511/ (at-spi2-atk)
https://review.tizen.org/gerrit/#/c/131714/ (screen-reader)

Change-Id: I968b058098162efe1cbec309411492ca29f696c8

atspi/atspi-accessible.c
atspi/atspi-accessible.h
atspi/atspi-types.h

index 71fd816..02a526c 100644 (file)
@@ -354,6 +354,186 @@ atspi_accessible_get_navigable_at_point (AtspiAccessible *root,
   return return_value;
 }
 
+/**
+ * atspi_accessible_get_reading_material:
+ * @obj: a pointer to the #AtspiAccessible object on which to operate.
+ *
+ * Gets reading material
+ *
+ * Returns: reading material to be used screen-reader side. This is not stable.
+ * You have to handle all alocated memory as below on screen-reader side.
+ *
+ * AtspiAccessibleReadingMaterial *rm
+ * g_object_unref(rm->parent);
+ * g_object_unref(rm->described_by_accessible);
+ * g_hash_table_unref(rm->attributes);
+ * free(rm->name);
+ * free(rm->labeled_by_name);
+ * free(rm->text_interface_name);
+ * free(rm->localized_role_name);
+ * free(rm->description);
+ * free(rm);
+ **/
+AtspiAccessibleReadingMaterial *
+atspi_accessible_get_reading_material (AtspiAccessible *obj, GError **error)
+{
+  AtspiAccessible *parent;
+  AtspiAccessibleReadingMaterial *reading_material = NULL;
+  const char *name;
+  double current_value;
+  gint count;
+  guint64 val;
+  DBusMessage *reply;
+  DBusMessageIter iter;
+  DBusMessageIter iter_array;
+  dbus_uint32_t role;
+  dbus_uint32_t *states;
+  dbus_int32_t index_in_parent;
+  dbus_int32_t child_count;
+  dbus_bool_t is_selected;
+
+  g_return_val_if_fail (obj != NULL, NULL);
+
+  reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetReadingMaterial", error, "");
+
+  _ATSPI_DBUS_CHECK_SIG (reply, "a{ss}sssuausiddddsibbii(so)auiui(so)", NULL, NULL);
+
+  reading_material = calloc(1, sizeof(AtspiAccessibleReadingMaterial));
+  if (!reading_material)
+  {
+    return reading_material;
+  }
+
+  dbus_message_iter_init (reply, &iter);
+
+  /* get attributes */
+  reading_material->attributes =  _atspi_dbus_hash_from_iter (&iter);
+  dbus_message_iter_next (&iter);
+
+  /* get name */
+  dbus_message_iter_get_basic (&iter, &name);
+  reading_material->name = g_strdup (name);
+  dbus_message_iter_next (&iter);
+
+  /* get name of relation LABELED_BY */
+  dbus_message_iter_get_basic (&iter, &name);
+  reading_material->labeled_by_name = g_strdup (name);
+  dbus_message_iter_next (&iter);
+
+  /* get name of text interface */
+  dbus_message_iter_get_basic (&iter, &name);
+  reading_material->text_interface_name = g_strdup (name);
+  dbus_message_iter_next (&iter);
+
+  /* get role */
+  dbus_message_iter_get_basic (&iter, &role);
+  reading_material->role = role;
+  dbus_message_iter_next (&iter);
+
+  /* get state set */
+  dbus_message_iter_recurse (&iter, &iter_array);
+  dbus_message_iter_get_fixed_array (&iter_array, &states, &count);
+  val = ((guint64)states [1]) << 32;
+  val += states [0];
+  reading_material->states = val;
+  dbus_message_iter_next (&iter);
+
+  /* get localized role name */
+  dbus_message_iter_get_basic (&iter, &name);
+  reading_material->localized_role_name = g_strdup (name);
+  dbus_message_iter_next (&iter);
+
+  /* get child count */
+  dbus_message_iter_get_basic (&iter, &child_count);
+  reading_material->child_count = child_count;
+  dbus_message_iter_next (&iter);
+
+  /* get current value */
+  dbus_message_iter_get_basic (&iter, &current_value);
+  reading_material->value = current_value;
+  dbus_message_iter_next (&iter);
+
+  /* get minimum increment */
+  dbus_message_iter_get_basic (&iter, &current_value);
+  reading_material->increment = current_value;
+  dbus_message_iter_next (&iter);
+
+  /* get maximum value */
+  dbus_message_iter_get_basic (&iter, &current_value);
+  reading_material->upper = current_value;
+  dbus_message_iter_next (&iter);
+
+  /* get minimum value */
+  dbus_message_iter_get_basic (&iter, &current_value);
+  reading_material->lower = current_value;
+  dbus_message_iter_next (&iter);
+
+  /* get description */
+  dbus_message_iter_get_basic (&iter, &name);
+  reading_material->description = g_strdup (name);
+  dbus_message_iter_next (&iter);
+
+  /* get index in parent */
+  dbus_message_iter_get_basic (&iter, &index_in_parent);
+  reading_material->index_in_parent = index_in_parent;
+  dbus_message_iter_next (&iter);
+
+  /* get selected in parent */
+  dbus_message_iter_get_basic (&iter, &is_selected);
+  reading_material->is_selected_in_parent = is_selected;
+  dbus_message_iter_next (&iter);
+
+  /* get has checkbox child */
+  dbus_message_iter_get_basic (&iter, &is_selected);
+  reading_material->has_checkbox_child = is_selected;
+  dbus_message_iter_next (&iter);
+
+  /* get list children count */
+  dbus_message_iter_get_basic (&iter, &child_count);
+  reading_material->list_children_count = child_count;
+  dbus_message_iter_next (&iter);
+
+  /* get first selected child index */
+  dbus_message_iter_get_basic (&iter, &index_in_parent);
+  reading_material->first_selected_child_index = index_in_parent;
+  dbus_message_iter_next (&iter);
+
+  ////////////////
+  /* get parent */
+  parent =  _atspi_dbus_return_accessible_from_iter (&iter);
+  reading_material->parent = parent;
+
+  /* parent states */
+  dbus_message_iter_recurse (&iter, &iter_array);
+  dbus_message_iter_get_fixed_array (&iter_array, &states, &count);
+  val = ((guint64)states [1]) << 32;
+  val += states [0];
+  reading_material->parent_states = val;
+  dbus_message_iter_next (&iter);
+
+  /* get parent child count */
+  dbus_message_iter_get_basic (&iter, &child_count);
+  reading_material->parent_child_count = child_count;
+  dbus_message_iter_next (&iter);
+
+  /* get parent role */
+  dbus_message_iter_get_basic (&iter, &role);
+  reading_material->parent_role = role;
+  dbus_message_iter_next (&iter);
+
+  /* get parent selected child count */
+  dbus_message_iter_get_basic (&iter, &child_count);
+  reading_material->parent_selected_child_count = child_count;
+  dbus_message_iter_next (&iter);
+
+  ////////////////////////////////////////
+  /* get relation object - DESCRIBED_BY */
+  parent =  _atspi_dbus_return_accessible_from_iter (&iter);
+  reading_material->described_by_accessible = parent;
+
+  return reading_material;
+}
+
 static unsigned char are_objects_on_the_same_bus(AtspiAccessible *obj1, AtspiAccessible *obj2)
 {
   const char *bus_name_1 = obj1->parent.app->bus_name;
index 293946b..0b5152b 100644 (file)
@@ -45,6 +45,34 @@ G_BEGIN_DECLS
 
 typedef struct _AtspiAccessiblePrivate AtspiAccessiblePrivate;
 
+struct _AtspiAccessibleReadingMaterial
+{
+  AtspiAccessible *parent;
+  AtspiAccessible *described_by_accessible;
+  GHashTable *attributes;
+  AtspiRole role;
+  AtspiRole parent_role;
+  char *name;
+  char *labeled_by_name;
+  char *text_interface_name;
+  char *localized_role_name;
+  char *description;
+  gdouble value;
+  gdouble increment;
+  gdouble lower;
+  gdouble upper;
+  gint64 states;
+  gint64 parent_states;
+  gint child_count;
+  gint index_in_parent;
+  gint list_children_count;
+  gint first_selected_child_index;
+  gint parent_child_count;
+  gint parent_selected_child_count;
+  gboolean is_selected_in_parent;
+  gboolean has_checkbox_child;
+};
+
 struct _AtspiAccessible
 {
   AtspiObject parent;
@@ -85,6 +113,8 @@ AtspiAccessible *atspi_accessible_get_navigable_at_point (AtspiAccessible *root,
 
 AtspiAccessible *atspi_accessible_get_neighbor (AtspiAccessible *root, AtspiAccessible *start, AtspiNeighborSearchDirection direction, GError **error);
 
+AtspiAccessibleReadingMaterial *atspi_accessible_get_reading_material (AtspiAccessible *obj, GError **error);
+
 AtspiAccessible * atspi_accessible_get_parent (AtspiAccessible *obj, GError **error);
 
 gint atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error);
index e458a8e..45b815c 100644 (file)
@@ -43,6 +43,7 @@ typedef struct _AtspiTable AtspiTable;
 typedef struct _AtspiTableCell AtspiTableCell;
 typedef struct _AtspiText AtspiText;
 typedef struct _AtspiValue AtspiValue;
+typedef struct _AtspiAccessibleReadingMaterial AtspiAccessibleReadingMaterial;
 
 typedef guint AtspiControllerEventMask;