Add navigation helper functions for screen-reader and friends
[platform/upstream/at-spi2-core.git] / atspi / atspi-accessible.c
index b06a36c..a579254 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include "atspi-private.h"
+#include "atspi-accessible-private.h"
 #include <string.h>
 
 static gboolean enable_caching = FALSE;
@@ -74,6 +75,11 @@ atspi_table_interface_init (AtspiTable *table)
 }
 
 static void
+atspi_table_cell_interface_init (AtspiTableCell *cell)
+{
+}
+
+static void
 atspi_text_interface_init (AtspiText *text)
 {
 }
@@ -84,6 +90,7 @@ atspi_value_interface_init (AtspiValue *value)
 }
 
 G_DEFINE_TYPE_WITH_CODE (AtspiAccessible, atspi_accessible, ATSPI_TYPE_OBJECT,
+                         G_ADD_PRIVATE (AtspiAccessible)
                          G_IMPLEMENT_INTERFACE (ATSPI_TYPE_ACTION, atspi_action_interface_init)
                          G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COLLECTION, atspi_collection_interface_init)
                          G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COMPONENT, atspi_component_interface_init)
@@ -93,6 +100,7 @@ G_DEFINE_TYPE_WITH_CODE (AtspiAccessible, atspi_accessible, ATSPI_TYPE_OBJECT,
                          G_IMPLEMENT_INTERFACE (ATSPI_TYPE_IMAGE, atspi_image_interface_init)
                          G_IMPLEMENT_INTERFACE (ATSPI_TYPE_SELECTION, atspi_selection_interface_init)
                          G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TABLE, atspi_table_interface_init)
+                         G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TABLE_CELL, atspi_table_cell_interface_init)
                          G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TEXT, atspi_text_interface_init)
                          G_IMPLEMENT_INTERFACE (ATSPI_TYPE_VALUE, atspi_value_interface_init))
 
@@ -108,6 +116,8 @@ atspi_accessible_init (AtspiAccessible *accessible)
   g_hash_table_insert (_atspi_get_live_refs (), accessible, NULL);
   g_print("at-spi: init: %d objects\n", accessible_count);
 #endif
+
+  accessible->priv = atspi_accessible_get_instance_private (accessible);
 }
 
 static void
@@ -180,6 +190,9 @@ atspi_accessible_finalize (GObject *object)
   if (accessible->attributes)
     g_hash_table_unref (accessible->attributes);
 
+    if (accessible->priv->cache)
+      g_hash_table_destroy (accessible->priv->cache);
+
 #ifdef DEBUG_REF_COUNTS
   accessible_count--;
   g_hash_table_remove (_atspi_get_live_refs (), accessible);
@@ -207,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 *
@@ -224,13 +237,130 @@ atspi_accessible_get_name (AtspiAccessible *obj, GError **error)
   return g_strdup (obj->name);
 }
 
+
+/**
+ * atspi_accessible_get_unique_id:
+ * @obj: a pointer to the #AtspiAccessible object on which to operate.
+ *
+ * Gets the identificator, uniquely identifying object, or NULL if an error occured.
+ *
+ * Returns: a UTF-8 string describing the #AtspiAccessible object
+ * or NULL on exception or NULL object passed.
+ **/
+gchar *
+atspi_accessible_get_unique_id(AtspiAccessible *obj, GError **error)
+{
+  if (!obj) {
+    g_set_error(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "argument is null");
+    return NULL;
+  }
+
+  gchar *id = NULL;
+  gchar *bus_name = atspi_accessible_get_bus_name(obj, error);
+  if (bus_name && bus_name[0]) {
+    gchar *path = atspi_accessible_get_path(obj, error);
+    if (path && path[0])
+      id = g_strdup_printf("%s:%s", bus_name, path);
+         else
+      g_set_error(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "failed to get path");
+    g_free(path);
+  }
+  else
+    g_set_error(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "failed to get bus name");
+  g_free(bus_name);
+  return id;
+}
+
+/**
+ * atspi_accessible_get_bus_name:
+ * @obj: a pointer to the #AtspiAccessible object on which to operate.
+ *
+ * Gets the bus name, where object belongs.
+ *
+ * Returns: a UTF-8 string describing the #AtspiAccessible object's
+ * bus name or empty string on exception or NULL object passed.
+ **/
+gchar *
+atspi_accessible_get_bus_name(AtspiAccessible *obj, GError **error)
+{
+  if (!obj || !obj->parent.app)
+    return g_strdup("");
+  return g_strdup (obj->parent.app->bus_name);
+}
+
+/**
+ * atspi_accessible_get_path:
+ * @obj: a pointer to the #AtspiAccessible object on which to operate.
+ *
+ * Gets the path, uniquely identifying object over its bus name.
+ *
+ * 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_navigable_at_point:
+ * @root: a pointer to the #AtspiAccessible to start search from.
+ * @x: a #gint specifying the x coordinate of the point in question.
+ * @y: a #gint specifying the y coordinate of the point in question.
+ * @ctype: the coordinate system of the point (@x, @y)
+ *         (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
+ *
+ * Finds the accessible element closest to user (highest in z-order), at a given coordinate within an #AtspiAccessible.
+ * This should be the element, that should be picked, when doing mouse click or finger tap at given coordinates.
+ *
+ * Returns: (nullable) (transfer full): a pointer to an
+ *          #AtspiAccessible descendant (of any depth) of the specified component which
+ *          contains the point (@x, @y), or NULL if no descendant contains
+ *          the point.
+ **/
+AtspiAccessible *
+atspi_accessible_get_navigable_at_point (AtspiAccessible *root,
+                                          gint x,
+                                          gint y,
+                                          AtspiCoordType ctype, GError **error)
+{
+  dbus_int32_t d_x = x, d_y = y;
+  dbus_uint32_t d_ctype = ctype;
+  DBusMessage *reply;
+  AtspiAccessible *return_value = NULL;
+  unsigned char recurse = 0;
+
+  g_return_val_if_fail (root != NULL, FALSE);
+  do {
+    reply = _atspi_dbus_call_partial (root, atspi_interface_accessible, "GetNavigableAtPoint", error, "iiu", d_x, d_y, d_ctype);
+
+    AtspiAccessible *tmp = _atspi_dbus_return_accessible_and_recurse_info_from_message (reply, &recurse);
+    if (!tmp) break;
+    if (return_value)
+      g_object_unref(return_value);
+    return_value = root = tmp;
+  } while(recurse);
+  return return_value;
+}
+
 /**
  * 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 *
@@ -257,9 +387,10 @@ const char *str_parent = "Parent";
  *
  * Gets an #AtspiAccessible object's parent container.
  *
- * Returns: (transfer full): a pointer to the #AtspiAccessible object which
- *          contains the given #AtspiAccessible instance, or NULL if the @obj
- *          has no parent container.
+ * Returns: (nullable) (transfer full): a pointer to the
+ *          #AtspiAccessible object which contains the given
+ *          #AtspiAccessible instance, or NULL if the @obj has no
+ *          parent container.
  *
  **/
 AtspiAccessible *
@@ -364,7 +495,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
@@ -414,7 +545,7 @@ typedef struct
  * Gets the set of #AtspiRelation objects which describes this #AtspiAccessible object's
  * relationships with other #AtspiAccessible objects.
  *
- * Returns: (element-type AtspiAccessible*) (transfer full): a #GArray of
+ * Returns: (element-type AtspiRelation*) (transfer full): a #GArray of
  *          #AtspiRelation pointers or NULL on exception.
  **/
 GArray *
@@ -509,12 +640,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.
  *
  **/
@@ -569,7 +700,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);
 }
 
@@ -577,7 +707,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.
@@ -592,6 +722,13 @@ atspi_accessible_get_attributes (AtspiAccessible *obj, GError **error)
 
     g_return_val_if_fail (obj != NULL, NULL);
 
+  if (obj->priv->cache)
+  {
+    GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
+    if (val)
+      return g_value_dup_boxed (val);
+  }
+
   if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ATTRIBUTES))
   {
     message = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
@@ -617,7 +754,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.
@@ -632,15 +769,16 @@ atspi_accessible_get_attributes_as_array (AtspiAccessible *obj, GError **error)
 
     g_return_val_if_fail (obj != NULL, NULL);
 
-  if (_atspi_accessible_get_cache_mask (obj) & ATSPI_CACHE_ATTRIBUTES)
+  if (obj->priv->cache)
   {
-    GArray *array = g_array_new (TRUE, TRUE, sizeof (gchar *));
-    GHashTable *attributes = atspi_accessible_get_attributes (obj, error);
-    if (!attributes)
-      return NULL;
-    g_hash_table_foreach (attributes, add_to_attribute_array, &array);
-    g_hash_table_unref (attributes);
-    return array;
+    GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
+    if (val)
+    {
+      GArray *array = g_array_new (TRUE, TRUE, sizeof (gchar *));
+      GHashTable *attributes = g_value_get_boxed (val);
+      g_hash_table_foreach (attributes, add_to_attribute_array, &array);
+      return array;
+    }
   }
 
   message = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetAttributes", error, "");
@@ -774,7 +912,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
@@ -825,7 +963,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,
@@ -855,7 +993,7 @@ atspi_accessible_is_application (AtspiAccessible *obj)
                              atspi_interface_application);
 }
 
-/**                      
+/**
  * atspi_accessible_is_collection:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
@@ -921,7 +1059,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.
@@ -943,7 +1081,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,
@@ -1008,6 +1146,23 @@ atspi_accessible_is_table (AtspiAccessible *obj)
 }
 
 /**
+ * atspi_accessible_is_table_cell:
+ * @obj: a pointer to the #AtspiAccessible instance to query.
+ *
+ * Query whether the specified #AtspiAccessible implements the
+ * #AtspiTableCell interface.
+ *
+ * Returns: #TRUE if @obj implements the #AtspiTable interface,
+ *          #FALSE otherwise.
+**/
+gboolean
+atspi_accessible_is_table_cell (AtspiAccessible *obj)
+{
+  return _atspi_accessible_is_a (obj,
+                             atspi_interface_table_cell);
+}
+
+/**
  * atspi_accessible_is_streamable_content:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
@@ -1033,7 +1188,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,
@@ -1064,7 +1219,7 @@ atspi_accessible_is_value (AtspiAccessible *obj)
 }
 
 /**
- * atspi_accessible_get_action:
+ * atspi_accessible_get_action: (rename-to atspi_accessible_get_action_iface)
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
  * Gets the #AtspiAction interface for an #AtspiAccessible.
@@ -1073,13 +1228,12 @@ atspi_accessible_is_value (AtspiAccessible *obj)
  *          instance, or NULL if @obj does not implement #AtspiAction.
  *
  * Deprecated: 2.10: Use atspi_accessible_get_action_iface instead.
- * Rename to: atspi_accessible_get_action_iface
  **/
 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);
 }
 
 /**
@@ -1095,11 +1249,11 @@ 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);
 }
 
 /**
- * atspi_accessible_get_collection:
+ * atspi_accessible_get_collection: (rename-to atspi_accessible_get_collection_iface)
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
  * Gets the #AtspiCollection interface for an #AtspiAccessible.
@@ -1108,13 +1262,12 @@ atspi_accessible_get_action_iface (AtspiAccessible *accessible)
  *          instance, or NULL if @obj does not implement #AtspiCollection.
  *
  * Deprecated: 2.10: Use atspi_accessible_get_collection_iface instead.
- * Rename to: atspi_accessible_get_collection_iface
  **/
 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);
 }
 
 /**
@@ -1130,11 +1283,11 @@ 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);
 }
 
 /**
- * atspi_accessible_get_component:
+ * atspi_accessible_get_component: (rename-to atspi_accessible_get_component_iface)
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
  * Gets the #AtspiComponent interface for an #AtspiAccessible.
@@ -1143,7 +1296,6 @@ atspi_accessible_get_collection_iface (AtspiAccessible *accessible)
  *          instance, or NULL if @obj does not implement #AtspiComponent.
  *
  * Deprecated: 2.10: Use atspi_accessible_get_component_iface instead.
- * Rename to: atspi_accessible_get_component_iface
  **/
 AtspiComponent *
 atspi_accessible_get_component (AtspiAccessible *obj)
@@ -1169,7 +1321,7 @@ atspi_accessible_get_component_iface (AtspiAccessible *obj)
 }
 
 /**
- * atspi_accessible_get_document:
+ * atspi_accessible_get_document: (rename-to atspi_accessible_get_document_iface)
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
  * Gets the #AtspiDocument interface for an #AtspiAccessible.
@@ -1178,13 +1330,12 @@ atspi_accessible_get_component_iface (AtspiAccessible *obj)
  *          instance, or NULL if @obj does not implement #AtspiDocument.
  *
  * Deprecated: 2.10: Use atspi_accessible_get_document_iface instead.
- * Rename to: atspi_accessible_get_document_iface
  **/
 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);
 }
 
 /**
@@ -1200,11 +1351,11 @@ 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);
 }
 
 /**
- * atspi_accessible_get_editable_text:
+ * atspi_accessible_get_editable_text: (rename-to atspi_accessible_get_editable_text_iface)
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
  * Gets the #AtspiEditableText interface for an #AtspiAccessible.
@@ -1213,13 +1364,12 @@ atspi_accessible_get_document_iface (AtspiAccessible *accessible)
  *          instance, or NULL if @obj does not implement #AtspiEditableText.
  *
  * Deprecated: 2.10: Use atspi_accessible_get_editable_text_iface instead.
- * Rename to: atspi_accessible_get_editable_text_iface
  **/
 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);
 }
 
 /**
@@ -1235,7 +1385,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);
 }
 
 /**
@@ -1255,7 +1405,7 @@ atspi_accessible_get_hyperlink (AtspiAccessible *accessible)
 }
 
 /**
- * atspi_accessible_get_hypertext:
+ * atspi_accessible_get_hypertext: (rename-to atspi_accessible_get_hypertext_iface)
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
  * Gets the #AtspiHypertext interface for an #AtspiAccessible.
@@ -1264,13 +1414,12 @@ atspi_accessible_get_hyperlink (AtspiAccessible *accessible)
  *          instance, or NULL if @obj does not implement #AtspiHypertext.
  *
  * Deprecated: 2.10: Use atspi_accessible_get_hypertext_iface instead.
- * Rename to: atspi_accessible_get_hypertext_iface
  **/
 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);
 }
 
 /**
@@ -1286,11 +1435,11 @@ 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);
 }
 
 /**
- * atspi_accessible_get_image:
+ * atspi_accessible_get_image: (rename-to atspi_accessible_get_image_iface)
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
  * Gets the #AtspiImage interface for an #AtspiAccessible.
@@ -1299,13 +1448,12 @@ atspi_accessible_get_hypertext_iface (AtspiAccessible *accessible)
  *          NULL if @obj does not implement #AtspiImage.
  *
  * Deprecated: 2.10: Use atspi_accessible_get_image_iface instead.
- * Rename to: atspi_accessible_get_image_iface
  **/
 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);
 }
 
 /**
@@ -1321,11 +1469,11 @@ 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);
 }
 
 /**
- * atspi_accessible_get_selection:
+ * atspi_accessible_get_selection: (rename-to atspi_accessible_get_selection_iface)
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
  * Gets the #AtspiSelection interface for an #AtspiAccessible.
@@ -1334,13 +1482,12 @@ atspi_accessible_get_image_iface (AtspiAccessible *accessible)
  *          instance, or NULL if @obj does not implement #AtspiSelection.
  *
  * Deprecated: 2.10: Use atspi_accessible_get_selection_iface instead.
- * Rename to: atspi_accessible_get_selection_iface
  **/
 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);
 }
 
 /**
@@ -1356,7 +1503,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
@@ -1373,12 +1520,12 @@ AtspiStreamableContent *
 atspi_accessible_get_streamable_content (AtspiAccessible *accessible)
 {
   return (_atspi_accessible_is_a (accessible, atspi_interface_streamable_content) ?
-          accessible : NULL);  
+          accessible : NULL);
 }
 #endif
 
 /**
- * atspi_accessible_get_table:
+ * atspi_accessible_get_table: (rename-to atspi_accessible_get_table_iface)
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
  * Gets the #AtspiTable interface for an #AtspiAccessible.
@@ -1387,13 +1534,12 @@ atspi_accessible_get_streamable_content (AtspiAccessible *accessible)
  *          NULL if @obj does not implement #AtspiTable.
  *
  * Deprecated: 2.10: Use atspi_accessible_get_table_iface instead.
- * Rename to: atspi_accessible_get_table_iface
  **/
 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);
 }
 
 /**
@@ -1409,11 +1555,27 @@ 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);
+}
+
+/**
+ * atspi_accessible_get_table_cell:
+ * @obj: a pointer to the #AtspiAccessible instance to query.
+ *
+ * Gets the #AtspiTableCell interface for an #AtspiAccessible.
+ *
+ * Returns: (transfer full): a pointer to an #AtspiTableCell interface instance,
+ *          or NULL if @obj does not implement #AtspiTable.
+ **/
+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);
 }
 
 /**
- * atspi_accessible_get_text:
+ * atspi_accessible_get_text: (rename-to atspi_accessible_get_text_iface)
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
  * Gets the #AtspiTable interface for an #AtspiAccessible.
@@ -1422,7 +1584,6 @@ atspi_accessible_get_table_iface (AtspiAccessible *obj)
  *          NULL if @obj does not implement #AtspiText.
  *
  * Deprecated: 2.10: Use atspi_accessible_get_text_iface instead.
- * Rename to: atspi_accessible_get_text_iface
  **/
 AtspiText *
 atspi_accessible_get_text (AtspiAccessible *obj)
@@ -1448,7 +1609,7 @@ atspi_accessible_get_text_iface (AtspiAccessible *obj)
 }
 
 /**
- * atspi_accessible_get_value:
+ * atspi_accessible_get_value: (rename-to atspi_accessible_get_value_iface)
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
  * Gets the #AtspiTable interface for an #AtspiAccessible.
@@ -1457,13 +1618,12 @@ atspi_accessible_get_text_iface (AtspiAccessible *obj)
  *          NULL if @obj does not implement #AtspiValue.
  *
  * Deprecated: 2.10: Use atspi_accessible_get_value_iface instead.
- * Rename to: atspi_accessible_get_value_iface
  **/
 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);
 }
 
 /**
@@ -1479,7 +1639,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
@@ -1529,6 +1689,8 @@ atspi_accessible_get_interfaces (AtspiAccessible *obj)
     append_const_val (ret, "Selection");
   if (atspi_accessible_is_table (obj))
     append_const_val (ret, "Table");
+  if (atspi_accessible_is_table_cell (obj))
+    append_const_val (ret, "TableCell");
   if (atspi_accessible_is_text (obj))
     append_const_val (ret, "Text");
   if (atspi_accessible_is_value (obj))
@@ -1537,11 +1699,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);
 
@@ -1598,12 +1760,13 @@ atspi_accessible_clear_cache (AtspiAccessible *accessible)
 /**
  * atspi_accessible_get_process_id:
  * @accessible: The #AtspiAccessible to query.
+ * @error: a pointer to a %NULL #GError pointer
  *
  * Returns the process id associated with the given accessible.  Mainly
  * added for debugging; it is a shortcut to explicitly querying the
  * accessible's app->bus_name and then calling GetConnectionUnixProcessID.
  *
- * Returns: The process ID, or -1 if defunct.
+ * Returns: The process ID or undetermined value if @error is set.
  **/
 guint
 atspi_accessible_get_process_id (AtspiAccessible *accessible, GError **error)
@@ -1614,7 +1777,10 @@ atspi_accessible_get_process_id (AtspiAccessible *accessible, GError **error)
   DBusError d_error;
 
   if (!accessible->parent.app || !accessible->parent.app->bus_name)
-    return -1;
+    {
+      g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
+      return -1;
+    }
 
   message = dbus_message_new_method_call ("org.freedesktop.DBus",
                                           "/org/freedesktop/DBus",
@@ -1634,7 +1800,7 @@ atspi_accessible_get_process_id (AtspiAccessible *accessible, GError **error)
   }
   if (dbus_error_is_set (&d_error))
     {
-      g_warning ("GetConnectionUnixProcessID failed: %s", d_error.message);
+      g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
       dbus_error_free (&d_error);
     }
   return pid;
@@ -1671,7 +1837,8 @@ _atspi_accessible_test_cache (AtspiAccessible *accessible, AtspiCache flag)
   AtspiCache result = accessible->cached_properties & mask & flag;
   if (accessible->states && atspi_state_set_contains (accessible->states, ATSPI_STATE_TRANSIENT))
     return FALSE;
-  return (result != 0 && (atspi_main_loop || enable_caching) &&
+  return (result != 0 && (atspi_main_loop || enable_caching ||
+                          flag == ATSPI_CACHE_INTERFACES) &&
           !atspi_no_cache);
 }
 
@@ -1714,3 +1881,38 @@ atspi_accessible_get_object_locale (AtspiAccessible *accessible, GError **error)
   }
   return locale;
 }
+
+void
+free_value (gpointer data)
+{
+  GValue *value = data;
+
+  g_value_unset (value);
+  g_free (value);
+}
+
+GHashTable *
+_atspi_accessible_ref_cache (AtspiAccessible *accessible)
+{
+  AtspiAccessiblePrivate *priv = accessible->priv;
+
+  priv->cache_ref_count++;
+  if (priv->cache)
+    return g_hash_table_ref (priv->cache);
+  priv->cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
+                                       free_value);
+  return priv->cache;
+}
+
+void
+_atspi_accessible_unref_cache (AtspiAccessible *accessible)
+{
+  AtspiAccessiblePrivate *priv = accessible->priv;
+
+  if (priv->cache)
+  {
+    g_hash_table_unref (priv->cache);
+    if (--priv->cache_ref_count == 0)
+      priv->cache = NULL;
+  }
+}