Add ability to retrieve atspi object's path, which uniquely identifies atspi object...
authorRadoslaw Cybulski <r.cybulski@partner.samsung.com>
Tue, 21 Feb 2017 14:55:05 +0000 (15:55 +0100)
committerShinwoo Kim <cinoo.kim@samsung.com>
Tue, 28 Mar 2017 06:58:00 +0000 (15:58 +0900)
Change-Id: I60fba10c202845427f247814db40436f01fe3117

atspi/Makefile.am
atspi/atspi-accessible.c
atspi/atspi-accessible.h
test/at_spi2_tool.c

index a860fcc..9944d44 100644 (file)
@@ -2,7 +2,7 @@ lib_LTLIBRARIES = libatspi.la
 
 libatspi_la_LDFLAGS = @LDFLAGS@ @LT_VERSION_INFO@ @LIBTOOL_EXPORT_OPTIONS@ -no-undefined
 
-libatspi_la_CFLAGS = $(DBUS_CFLAGS) \
+libatspi_la_CFLAGS = $(DBUS_CFLAGS) $(AUL_CFLAGS) \
                    $(DBIND_CFLAGS)     \
                    $(GLIB_CFLAGS)     \
                    -I$(top_srcdir)/registryd \
@@ -10,7 +10,7 @@ libatspi_la_CFLAGS = $(DBUS_CFLAGS) \
                     -I$(top_builddir) \
                     -I$(top_srcdir)
 
-libatspi_la_LIBADD = $(DBUS_LIBS) \
+libatspi_la_LIBADD = $(DBUS_LIBS) $(AUL_LIBS) \
        $(GOBJ_LIBS) \
        $(X_LIBS) \
        $(top_builddir)/dbind/libdbind.la
index 2d77357..c3392bd 100644 (file)
@@ -220,7 +220,7 @@ atspi_accessible_class_init (AtspiAccessibleClass *klass)
  *
  * Gets the name of an #AtspiAccessible object.
  *
- * Returns: a UTF-8 string indicating the name of the #AtspiAccessible object 
+ * Returns: a UTF-8 string indicating the name of the #AtspiAccessible object
  * or NULL on exception.
  **/
 gchar *
@@ -238,12 +238,37 @@ atspi_accessible_get_name (AtspiAccessible *obj, GError **error)
 }
 
 /**
+ * atspi_accessible_get_path:
+ * @obj: a pointer to the #AtspiAccessible object on which to operate.
+ *
+ * Gets the path, uniquely identifying object.
+ *
+ * Returns: a UTF-8 string describing the #AtspiAccessible object
+ * or empty string on exception or NULL object passed.
+ **/
+gchar *
+atspi_accessible_get_path(AtspiAccessible *obj, GError **error)
+{
+  static const char *prefix = "/org/a11y/atspi/accessible/";
+  static int prefix_len = 27;
+
+  if (!obj)
+    return g_strdup("");
+  AtspiObject *o = ATSPI_OBJECT (obj);
+  if (!o)
+    return g_strdup("");
+  if (strncmp(o->path, prefix, prefix_len) == 0)
+    return g_strdup(o->path + prefix_len);
+  return g_strdup (o->path);
+}
+
+/**
  * atspi_accessible_get_description:
  * @obj: a pointer to the #AtspiAccessible object on which to operate.
  *
  * Gets the description of an #AtspiAccessible object.
  *
- * Returns: a UTF-8 string describing the #AtspiAccessible object 
+ * Returns: a UTF-8 string describing the #AtspiAccessible object
  * or NULL on exception.
  **/
 gchar *
@@ -378,7 +403,7 @@ atspi_accessible_get_child_at_index (AtspiAccessible *obj,
  * atspi_accessible_get_index_in_parent:
  * @obj: a pointer to the #AtspiAccessible object on which to operate.
  *
- * Gets the index of an #AtspiAccessible object within its parent's 
+ * Gets the index of an #AtspiAccessible object within its parent's
  * #AtspiAccessible children list.
  *
  * Returns: a #glong indicating the index of the #AtspiAccessible object
@@ -523,12 +548,12 @@ atspi_accessible_get_role_name (AtspiAccessible *obj, GError **error)
  * atspi_accessible_get_localized_role_name:
  * @obj: a pointer to the #AtspiAccessible object on which to operate.
  *
- * Gets a UTF-8 string corresponding to the name of the role played by an 
+ * Gets a UTF-8 string corresponding to the name of the role played by an
  * object, translated to the current locale.
  * This method will return useful values for roles that fall outside the
  * enumeration used in atspi_accessible_getRole ().
  *
- * Returns: a localized, UTF-8 string specifying the type of UI role played 
+ * Returns: a localized, UTF-8 string specifying the type of UI role played
  * by an #AtspiAccessible object.
  *
  **/
@@ -583,7 +608,6 @@ atspi_accessible_get_state_set (AtspiAccessible *obj)
     dbus_message_unref (reply);
     _atspi_accessible_add_cache (obj, ATSPI_CACHE_STATES);
   }
-
   return g_object_ref (obj->states);
 }
 
@@ -591,7 +615,7 @@ atspi_accessible_get_state_set (AtspiAccessible *obj)
  * atspi_accessible_get_attributes:
  * @obj: The #AtspiAccessible being queried.
  *
- * Gets the #AttributeSet representing any assigned 
+ * Gets the #AttributeSet representing any assigned
  * name-value pair attributes or annotations for this object.
  * For typographic, textual, or textually-semantic attributes, see
  * atspi_text_get_attributes instead.
@@ -638,7 +662,7 @@ add_to_attribute_array (gpointer key, gpointer value, gpointer data)
  * atspi_accessible_get_attributes_as_array:
  * @obj: The #AtspiAccessible being queried.
  *
- * Gets a #GArray representing any assigned 
+ * Gets a #GArray representing any assigned
  * name-value pair attributes or annotations for this object.
  * For typographic, textual, or textually-semantic attributes, see
  * atspi_text_get_attributes_as_array instead.
@@ -796,7 +820,7 @@ atspi_accessible_get_atspi_version (AtspiAccessible *obj, GError **error)
  * Gets the application id for a #AtspiAccessible object.
  * Only works on application root objects.
  *
- * Returns: a positive #gint indicating the id for the #AtspiAccessible object 
+ * Returns: a positive #gint indicating the id for the #AtspiAccessible object
  * or -1 on exception.
  **/
 gint
@@ -847,7 +871,7 @@ _atspi_accessible_is_a (AtspiAccessible *accessible,
  * atspi_accessible_is_action:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Query whether the specified #AtspiAccessible implements the 
+ * Query whether the specified #AtspiAccessible implements the
  * #AtspiAction interface.
  *
  * Returns: #TRUE if @obj implements the #AtspiAction interface,
@@ -877,7 +901,7 @@ atspi_accessible_is_application (AtspiAccessible *obj)
                              atspi_interface_application);
 }
 
-/**                      
+/**
  * atspi_accessible_is_collection:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
@@ -943,7 +967,7 @@ atspi_accessible_is_editable_text (AtspiAccessible *obj)
   return _atspi_accessible_is_a (obj,
                              atspi_interface_editable_text);
 }
-                                                                                                                                                                        
+
 /**
  * atspi_accessible_is_hypertext:
  * @obj: a pointer to the #AtspiAccessible instance to query.
@@ -965,7 +989,7 @@ atspi_accessible_is_hypertext (AtspiAccessible *obj)
  * atspi_accessible_is_hyperlink:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Query whether the specified #AtspiAccessible implements the 
+ * Query whether the specified #AtspiAccessible implements the
  * #AtspiHyperlink interface.
  *
  * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
@@ -1072,7 +1096,7 @@ atspi_accessible_is_streamable_content (AtspiAccessible *obj)
  * atspi_accessible_is_text:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Query whether the specified #AtspiAccessible implements the 
+ * Query whether the specified #AtspiAccessible implements the
  * #AtspiText interface.
  *
  * Returns: #TRUE if @obj implements the #AtspiText interface,
@@ -1117,7 +1141,7 @@ AtspiAction *
 atspi_accessible_get_action (AtspiAccessible *accessible)
 {
   return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
-          g_object_ref (ATSPI_ACTION (accessible)) : NULL);  
+          g_object_ref (ATSPI_ACTION (accessible)) : NULL);
 }
 
 /**
@@ -1133,7 +1157,7 @@ AtspiAction *
 atspi_accessible_get_action_iface (AtspiAccessible *accessible)
 {
   return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
-          g_object_ref (ATSPI_ACTION (accessible)) : NULL);  
+          g_object_ref (ATSPI_ACTION (accessible)) : NULL);
 }
 
 /**
@@ -1151,7 +1175,7 @@ AtspiCollection *
 atspi_accessible_get_collection (AtspiAccessible *accessible)
 {
   return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
-          g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);  
+          g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
 }
 
 /**
@@ -1167,7 +1191,7 @@ AtspiCollection *
 atspi_accessible_get_collection_iface (AtspiAccessible *accessible)
 {
   return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
-          g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);  
+          g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
 }
 
 /**
@@ -1219,7 +1243,7 @@ AtspiDocument *
 atspi_accessible_get_document (AtspiAccessible *accessible)
 {
   return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
-          g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);  
+          g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
 }
 
 /**
@@ -1235,7 +1259,7 @@ AtspiDocument *
 atspi_accessible_get_document_iface (AtspiAccessible *accessible)
 {
   return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
-          g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);  
+          g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
 }
 
 /**
@@ -1253,7 +1277,7 @@ AtspiEditableText *
 atspi_accessible_get_editable_text (AtspiAccessible *accessible)
 {
   return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
-          g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);  
+          g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
 }
 
 /**
@@ -1269,7 +1293,7 @@ AtspiEditableText *
 atspi_accessible_get_editable_text_iface (AtspiAccessible *accessible)
 {
   return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
-          g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);  
+          g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
 }
 
 /**
@@ -1303,7 +1327,7 @@ AtspiHypertext *
 atspi_accessible_get_hypertext (AtspiAccessible *accessible)
 {
   return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
-          g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);  
+          g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
 }
 
 /**
@@ -1319,7 +1343,7 @@ AtspiHypertext *
 atspi_accessible_get_hypertext_iface (AtspiAccessible *accessible)
 {
   return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
-          g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);  
+          g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
 }
 
 /**
@@ -1337,7 +1361,7 @@ AtspiImage *
 atspi_accessible_get_image (AtspiAccessible *accessible)
 {
   return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
-          g_object_ref (ATSPI_IMAGE (accessible)) : NULL);  
+          g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
 }
 
 /**
@@ -1353,7 +1377,7 @@ AtspiImage *
 atspi_accessible_get_image_iface (AtspiAccessible *accessible)
 {
   return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
-          g_object_ref (ATSPI_IMAGE (accessible)) : NULL);  
+          g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
 }
 
 /**
@@ -1371,7 +1395,7 @@ AtspiSelection *
 atspi_accessible_get_selection (AtspiAccessible *accessible)
 {
   return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
-          g_object_ref (ATSPI_SELECTION (accessible)) : NULL);  
+          g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
 }
 
 /**
@@ -1387,7 +1411,7 @@ AtspiSelection *
 atspi_accessible_get_selection_iface (AtspiAccessible *accessible)
 {
   return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
-          g_object_ref (ATSPI_SELECTION (accessible)) : NULL);  
+          g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
 }
 
 #if 0
@@ -1404,7 +1428,7 @@ AtspiStreamableContent *
 atspi_accessible_get_streamable_content (AtspiAccessible *accessible)
 {
   return (_atspi_accessible_is_a (accessible, atspi_interface_streamable_content) ?
-          accessible : NULL);  
+          accessible : NULL);
 }
 #endif
 
@@ -1423,7 +1447,7 @@ AtspiTable *
 atspi_accessible_get_table (AtspiAccessible *obj)
 {
   return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
-          g_object_ref (ATSPI_TABLE (obj)) : NULL);  
+          g_object_ref (ATSPI_TABLE (obj)) : NULL);
 }
 
 /**
@@ -1439,7 +1463,7 @@ AtspiTable *
 atspi_accessible_get_table_iface (AtspiAccessible *obj)
 {
   return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
-          g_object_ref (ATSPI_TABLE (obj)) : NULL);  
+          g_object_ref (ATSPI_TABLE (obj)) : NULL);
 }
 
 /**
@@ -1455,7 +1479,7 @@ AtspiTableCell *
 atspi_accessible_get_table_cell (AtspiAccessible *obj)
 {
   return (_atspi_accessible_is_a (obj, atspi_interface_table_cell) ?
-          g_object_ref (ATSPI_TABLE_CELL (obj)) : NULL);  
+          g_object_ref (ATSPI_TABLE_CELL (obj)) : NULL);
 }
 
 /**
@@ -1507,7 +1531,7 @@ AtspiValue *
 atspi_accessible_get_value (AtspiAccessible *accessible)
 {
   return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
-          g_object_ref (ATSPI_VALUE (accessible)) : NULL);  
+          g_object_ref (ATSPI_VALUE (accessible)) : NULL);
 }
 
 /**
@@ -1523,7 +1547,7 @@ AtspiValue *
 atspi_accessible_get_value_iface (AtspiAccessible *accessible)
 {
   return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
-          g_object_ref (ATSPI_VALUE (accessible)) : NULL);  
+          g_object_ref (ATSPI_VALUE (accessible)) : NULL);
 }
 
 static void
@@ -1583,11 +1607,11 @@ atspi_accessible_get_interfaces (AtspiAccessible *obj)
   return ret;
 }
 
-AtspiAccessible * 
+AtspiAccessible *
 _atspi_accessible_new (AtspiApplication *app, const gchar *path)
 {
   AtspiAccessible *accessible;
-  
+
   accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
   g_return_val_if_fail (accessible != NULL, NULL);
 
index 2c3f8cc..f07394e 100644 (file)
@@ -5,7 +5,7 @@
  * Copyright 2002 Ximian, Inc.
  *           2002 Sun Microsystems Inc.
  * Copyright 2010, 2011 Novell, Inc.
- *           
+ *
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -66,7 +66,7 @@ struct _AtspiAccessibleClass
   AtspiObjectClass parent_class;
 };
 
-GType atspi_accessible_get_type (void); 
+GType atspi_accessible_get_type (void);
 
 AtspiAccessible *
 _atspi_accessible_new (AtspiApplication *app, const gchar *path);
@@ -75,6 +75,8 @@ gchar * atspi_accessible_get_name (AtspiAccessible *obj, GError **error);
 
 gchar * atspi_accessible_get_description (AtspiAccessible *obj, GError **error);
 
+gchar * atspi_accessible_get_path (AtspiAccessible *obj, GError **error);
+
 AtspiAccessible * atspi_accessible_get_parent (AtspiAccessible *obj, GError **error);
 
 gint atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error);
index 743b90c..badaaa3 100644 (file)
@@ -287,15 +287,15 @@ static char *_get_attributes(AtspiAccessible *node, int length_limit)
        return result;
 }
 
-static AtspiAccessible *_get_object_in_relation(AtspiAccessible *source, AtspiRelationType search_type)
+static char *_get_object_in_relation(AtspiAccessible *source, AtspiRelationType search_type)
 {
        if (source == NULL)
-               return NULL;
+               return "";
 
        GArray *relations = atspi_accessible_get_relation_set(source, NULL);
 
        if (relations == NULL)
-               return NULL;
+               return "";
 
        AtspiAccessible *ret = NULL;
        for (int i = 0; i < relations->len; ++i) {
@@ -310,7 +310,7 @@ static AtspiAccessible *_get_object_in_relation(AtspiAccessible *source, AtspiRe
 
        g_array_free(relations, TRUE);
 
-       return ret;
+       return ret ? atspi_accessible_get_path(ret, NULL) : g_strdup("");
 }
 
 static char *_get_info(AtspiAccessible *node, int length_limit)
@@ -320,14 +320,15 @@ static char *_get_info(AtspiAccessible *node, int length_limit)
 
        char *node_name = atspi_accessible_get_name(node, NULL);
        char *node_role_name = atspi_accessible_get_role_name(node, NULL);
+       char *path = atspi_accessible_get_path(node, NULL);
 
        char *attributes = _get_attributes(node, length_limit);
        Box_Size *box_size = _get_box_size(node);
        char *states = _get_states(node, length_limit);
 
        char result[SAFE_BUFFER_SIZE];
-       int ret = snprintf(result, SAFE_BUFFER_SIZE, "[[%p],[%s],[%s],[%s,%s,%s,%s],[%s],[%s],[%p,%p]]",
-                                               node,
+       int ret = snprintf(result, SAFE_BUFFER_SIZE, "[[%s],[%s],[%s],[%s,%s,%s,%s],[%s],[%s],[%s,%s]]",
+                                               path,
                                                node_role_name,
                                                attributes,
                                                box_size->x,
@@ -369,7 +370,9 @@ static void _test_atspi_parent_child_relation(AtspiAccessible *obj, AtspiAccessi
                else
                        snprintf(parent_status, NUMBER_WIDTH, "%d", parent_index);
 
-               snprintf(output, CHECK_OUTPUT_WIDTH, "[FAIL<%d,%s><%p,%p>]", parent_candidate_index, parent_status, parent_candidate, parent);
+               snprintf(output, CHECK_OUTPUT_WIDTH, "[FAIL<%d,%s><%s,%s>]", parent_candidate_index, parent_status,
+                               atspi_accessible_get_path(parent_candidate, NULL),
+                               atspi_accessible_get_path(parent, NULL));
 
        } else {
                snprintf(output, CHECK_OUTPUT_WIDTH, "[OK]");