atspi_application_dispose: clear root accessible's ref to the app
[platform/upstream/at-spi2-core.git] / atspi / atspi-accessible.c
index 6732d1c..4547ef7 100644 (file)
  */
 
 #include "atspi-private.h"
+#include "atspi-accessible-private.h"
 #include <string.h>
 
 static gboolean enable_caching = FALSE;
+static guint quark_locale;
 
 static void
 atspi_action_interface_init (AtspiAction *action)
@@ -73,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)
 {
 }
@@ -83,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)
@@ -92,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))
 
@@ -104,8 +113,13 @@ atspi_accessible_init (AtspiAccessible *accessible)
 {
 #ifdef DEBUG_REF_COUNTS
   accessible_count++;
+  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);
+
+  accessible->children = g_ptr_array_new_with_free_func (g_object_unref);
 }
 
 static void
@@ -114,8 +128,7 @@ atspi_accessible_dispose (GObject *object)
   AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
   AtspiEvent e;
   AtspiAccessible *parent;
-  GList *children;
-  GList *l;
+  gint i;
 
   /* TODO: Only fire if object not already marked defunct */
   memset (&e, 0, sizeof (e));
@@ -125,45 +138,32 @@ atspi_accessible_dispose (GObject *object)
   e.detail2 = 0;
   _atspi_send_event (&e);
 
-  if (accessible->states)
-  {
-    g_object_unref (accessible->states);
-    accessible->states = NULL;
-  }
+  g_clear_object (&accessible->states);
 
   parent = accessible->accessible_parent;
-  if (parent && parent->children)
-  {
-    GList*ls = g_list_find (parent->children, accessible);
-    if(ls)
-    {
-      gboolean replace = (ls == parent->children);
-      ls = g_list_remove (ls, accessible);
-      if (replace)
-        parent->children = ls;
-      g_object_unref (object);
-    }
-  }
-
   if (parent)
   {
-    g_object_unref (parent);
     accessible->accessible_parent = NULL;
+    if (parent->children)
+      g_ptr_array_remove (parent->children, accessible);
+    g_object_unref (parent);
   }
 
-  children = accessible->children;
-  accessible->children = NULL;
-  for (l = children; l; l = l->next)
+  if (accessible->children) for (i = accessible->children->len - 1; i >= 0; i--)
   {
-    AtspiAccessible *child = l->data;
+    AtspiAccessible *child = g_ptr_array_index (accessible->children, i);
     if (child && child->accessible_parent == accessible)
     {
-      g_object_unref (accessible);
       child->accessible_parent = NULL;
+      g_object_unref (accessible);
     }
-    g_object_unref (child);
   }
-  g_list_free (children);
+
+  if (accessible->children)
+  {
+    g_ptr_array_free (accessible->children, TRUE);
+    accessible->children = NULL;
+  }
 
   G_OBJECT_CLASS (atspi_accessible_parent_class) ->dispose (object);
 }
@@ -178,13 +178,16 @@ 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);
   g_print ("at-spi: finalize: %d objects\n", accessible_count);
 #endif
 
-  G_OBJECT_CLASS (atspi_accessible_parent_class)
-    ->finalize (object);
+  G_OBJECT_CLASS (atspi_accessible_parent_class)->finalize (object);
 }
 
 static void
@@ -194,138 +197,8 @@ atspi_accessible_class_init (AtspiAccessibleClass *klass)
 
   object_class->dispose = atspi_accessible_dispose;
   object_class->finalize = atspi_accessible_finalize;
-}
-
-/* TODO: Generate following from spec? */
-static const char *role_names [] =
-{
-  "invalid",
-  "accelerator label",
-  "alert",
-  "animation",
-  "arrow",
-  "calendar",
-  "canvas",
-  "check box",
-  "check menu item",
-  "color chooser",
-  "column header",
-  "combo box",
-  "dateeditor",
-  "desktop icon",
-  "desktop frame",
-  "dial",
-  "dialog",
-  "directory pane",
-  "drawing area",
-  "file chooser",
-  "filler",
-  "focus traversable",
-  "fontchooser",
-  "frame",
-  "glass pane",
-  "html container",
-  "icon",
-  "image",
-  "internal frame",
-  "label",
-  "layered pane",
-  "list",
-  "list item",
-  "menu",
-  "menu bar",
-  "menu item",
-  "option pane",
-  "page tab",
-  "page tab list",
-  "panel",
-  "password text",
-  "popup menu",
-  "progress bar",
-  "push button",
-  "radio button",
-  "radio menu item",
-  "root pane",
-  "row header",
-  "scroll bar",
-  "scroll pane",
-  "separator",
-  "slider",
-  "spin button",
-  "split pane",
-  "statusbar",
-  "table",
-  "table cell",
-  "table column header",
-  "table row header",
-  "tear off menu item",
-  "terminal",
-  "text",
-  "toggle button",
-  "tool bar",
-  "tool tip",
-  "tree",
-  "tree table",
-  "unknown",
-  "viewport",
-  "window",
-  NULL,
-  "header",
-  "footer",
-  "paragraph",
-  "ruler",
-  "application",
-  "autocomplete",
-  "editbar",
-  "embedded component",
-  "entry",
-  "chart",
-  "caption",
-  "document frame",
-  "heading",
-  "page",
-  "section",
-  "redundant object",
-  "form",
-  "link",
-  "input method window",
-  "table row",
-  "tree item",
-  "document spreadsheet",
-  "document presentation",
-  "document text",
-  "document web",
-  "document email",
-  "comment",
-  "list box",
-  "grouping",
-  "image map",
-  "notification",
-  "info bar"
-};
-
-#define MAX_ROLES (sizeof (role_names) / sizeof (char *))
 
-/**
- * atspi_role_get_name:
- * @role: an #AtspiRole object to query.
- *
- * Gets a localizable string that indicates the name of an #AtspiRole.
- * <em>DEPRECATED.</em>
- *
- * Returns: a localizable string name for an #AtspiRole enumerated type.
- **/
-gchar *
-atspi_role_get_name (AtspiRole role)
-{
-  if (role < MAX_ROLES && role_names [(int) role])
-    {
-      return g_strdup (role_names [(int) role]);
-    }
-  else
-    {
-      return g_strdup ("");
-    }
+  quark_locale = g_quark_from_string ("accessible-locale");
 }
 
 /**
@@ -384,9 +257,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 *
@@ -450,7 +324,10 @@ atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error)
     return ret;
   }
 
-  return g_list_length (obj->children);
+  if (!obj->children)
+    return 0;  /* assume it's disposed */
+
+  return obj->children->len;
 }
 
 /**
@@ -469,22 +346,34 @@ atspi_accessible_get_child_at_index (AtspiAccessible *obj,
                             GError **error)
 {
   AtspiAccessible *child;
+  DBusMessage *reply;
 
   g_return_val_if_fail (obj != NULL, NULL);
 
-  if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
+  if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
   {
-    DBusMessage *reply;
-    reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
-                                     "GetChildAtIndex", error, "i",
-                                     child_index);
-    return _atspi_dbus_return_accessible_from_message (reply);
+    if (!obj->children)
+      return NULL;     /* assume disposed */
+
+    child = g_ptr_array_index (obj->children, child_index);
+    if (child)
+      return g_object_ref (child);
   }
 
-  child = g_list_nth_data (obj->children, child_index);
+  reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
+                                   "GetChildAtIndex", error, "i", child_index);
+  child = _atspi_dbus_return_accessible_from_message (reply);
+
   if (!child)
     return NULL;
-  return g_object_ref (child);
+
+  if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
+  {
+      if (child_index >= obj->children->len)
+        g_ptr_array_set_size (obj->children, child_index + 1);
+    g_ptr_array_index (obj->children, child_index) = g_object_ref (child);
+  }
+  return child;
 }
 
 /**
@@ -501,31 +390,27 @@ atspi_accessible_get_child_at_index (AtspiAccessible *obj,
 gint
 atspi_accessible_get_index_in_parent (AtspiAccessible *obj, GError **error)
 {
-  GList *l;
   gint i = 0;
+  dbus_int32_t ret = -1;
 
   g_return_val_if_fail (obj != NULL, -1);
-  if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT) &&
-      !obj->accessible_parent)
-    return -1;
-  if (!obj->accessible_parent ||
-      !_atspi_accessible_test_cache (obj->accessible_parent,
-                                     ATSPI_CACHE_CHILDREN))
+  if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT))
   {
-    dbus_int32_t ret = -1;
-    _atspi_dbus_call (obj, atspi_interface_accessible,
-                      "GetIndexInParent", NULL, "=>i", &ret);
-    return ret;
-  }
+    if (!obj->accessible_parent)
+      return -1;
 
-  l = obj->accessible_parent->children;
-  while (l)
-  {
-    if (l->data == obj) return i;
-    l = g_list_next (l);
-    i++;
+    if (!_atspi_accessible_test_cache (obj->accessible_parent, ATSPI_CACHE_CHILDREN) || !obj->accessible_parent->children)
+        goto dbus;
+
+    for (i = 0; i < obj->accessible_parent->children->len; i++)
+      if (g_ptr_array_index (obj->accessible_parent->children, i) == obj)
+        return i;
   }
-  return -1;
+
+dbus:
+  _atspi_dbus_call (obj, atspi_interface_accessible,
+                    "GetIndexInParent", NULL, "=>i", &ret);
+  return ret;
 }
 
 typedef struct
@@ -541,7 +426,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 *
@@ -615,14 +500,14 @@ atspi_accessible_get_role (AtspiAccessible *obj, GError **error)
 gchar *
 atspi_accessible_get_role_name (AtspiAccessible *obj, GError **error)
 {
-  char *retval = NULL;
+  gchar *retval = NULL;
   AtspiRole role;
 
   g_return_val_if_fail (obj != NULL, NULL);
 
   role = atspi_accessible_get_role (obj, error);
-  if (role >= 0 && role < MAX_ROLES && role != ATSPI_ROLE_EXTENDED)
-    return g_strdup (role_names [role]);
+  if (role >= 0 && role < ATSPI_ROLE_COUNT && role != ATSPI_ROLE_EXTENDED)
+    return atspi_role_get_name (role);
 
   _atspi_dbus_call (obj, atspi_interface_accessible, "GetRoleName", error, "=>s", &retval);
 
@@ -719,6 +604,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,
@@ -759,15 +651,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, "");
@@ -809,7 +702,11 @@ atspi_accessible_get_application (AtspiAccessible *obj, GError **error)
     }
     if (!parent || parent == obj ||
         atspi_accessible_get_role (parent, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
+  {
+    if (parent)
+      g_object_unref (parent);
     return obj;
+  }
     g_object_unref (obj);
     obj = parent;
   }
@@ -1131,6 +1028,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.
  *
@@ -1187,13 +1101,15 @@ 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.
  *
  * Returns: (transfer full): a pointer to an #AtspiAction interface
  *          instance, or NULL if @obj does not implement #AtspiAction.
+ *
+ * Deprecated: 2.10: Use atspi_accessible_get_action_iface instead.
  **/
 AtspiAction *
 atspi_accessible_get_action (AtspiAccessible *accessible)
@@ -1203,13 +1119,31 @@ atspi_accessible_get_action (AtspiAccessible *accessible)
 }
 
 /**
- * atspi_accessible_get_collection:
+ * atspi_accessible_get_action_iface:
+ * @obj: a pointer to the #AtspiAccessible instance to query.
+ *
+ * Gets the #AtspiAction interface for an #AtspiAccessible.
+ *
+ * Returns: (transfer full): a pointer to an #AtspiAction interface
+ *          instance, or NULL if @obj does not implement #AtspiAction.
+ **/
+AtspiAction *
+atspi_accessible_get_action_iface (AtspiAccessible *accessible)
+{
+  return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
+          g_object_ref (ATSPI_ACTION (accessible)) : NULL);  
+}
+
+/**
+ * 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.
  *
  * Returns: (transfer full): a pointer to an #AtspiCollection interface
  *          instance, or NULL if @obj does not implement #AtspiCollection.
+ *
+ * Deprecated: 2.10: Use atspi_accessible_get_collection_iface instead.
  **/
 AtspiCollection *
 atspi_accessible_get_collection (AtspiAccessible *accessible)
@@ -1219,13 +1153,31 @@ atspi_accessible_get_collection (AtspiAccessible *accessible)
 }
 
 /**
- * atspi_accessible_get_component:
+ * atspi_accessible_get_collection_iface:
+ * @obj: a pointer to the #AtspiAccessible instance to query.
+ *
+ * Gets the #AtspiCollection interface for an #AtspiAccessible.
+ *
+ * Returns: (transfer full): a pointer to an #AtspiCollection interface
+ *          instance, or NULL if @obj does not implement #AtspiCollection.
+ **/
+AtspiCollection *
+atspi_accessible_get_collection_iface (AtspiAccessible *accessible)
+{
+  return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
+          g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);  
+}
+
+/**
+ * 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.
  *
  * Returns: (transfer full): a pointer to an #AtspiComponent interface
  *          instance, or NULL if @obj does not implement #AtspiComponent.
+ *
+ * Deprecated: 2.10: Use atspi_accessible_get_component_iface instead.
  **/
 AtspiComponent *
 atspi_accessible_get_component (AtspiAccessible *obj)
@@ -1235,13 +1187,31 @@ atspi_accessible_get_component (AtspiAccessible *obj)
 }
 
 /**
- * atspi_accessible_get_document:
+ * atspi_accessible_get_component_iface:
+ * @obj: a pointer to the #AtspiAccessible instance to query.
+ *
+ * Gets the #AtspiComponent interface for an #AtspiAccessible.
+ *
+ * Returns: (transfer full): a pointer to an #AtspiComponent interface
+ *          instance, or NULL if @obj does not implement #AtspiComponent.
+ **/
+AtspiComponent *
+atspi_accessible_get_component_iface (AtspiAccessible *obj)
+{
+  return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
+          g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
+}
+
+/**
+ * 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.
  *
  * Returns: (transfer full): a pointer to an #AtspiDocument interface
  *          instance, or NULL if @obj does not implement #AtspiDocument.
+ *
+ * Deprecated: 2.10: Use atspi_accessible_get_document_iface instead.
  **/
 AtspiDocument *
 atspi_accessible_get_document (AtspiAccessible *accessible)
@@ -1251,13 +1221,31 @@ atspi_accessible_get_document (AtspiAccessible *accessible)
 }
 
 /**
- * atspi_accessible_get_editable_text:
+ * atspi_accessible_get_document_iface:
+ * @obj: a pointer to the #AtspiAccessible instance to query.
+ *
+ * Gets the #AtspiDocument interface for an #AtspiAccessible.
+ *
+ * Returns: (transfer full): a pointer to an #AtspiDocument interface
+ *          instance, or NULL if @obj does not implement #AtspiDocument.
+ **/
+AtspiDocument *
+atspi_accessible_get_document_iface (AtspiAccessible *accessible)
+{
+  return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
+          g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);  
+}
+
+/**
+ * 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.
  *
  * Returns: (transfer full): a pointer to an #AtspiEditableText interface
  *          instance, or NULL if @obj does not implement #AtspiEditableText.
+ *
+ * Deprecated: 2.10: Use atspi_accessible_get_editable_text_iface instead.
  **/
 AtspiEditableText *
 atspi_accessible_get_editable_text (AtspiAccessible *accessible)
@@ -1267,6 +1255,22 @@ atspi_accessible_get_editable_text (AtspiAccessible *accessible)
 }
 
 /**
+ * atspi_accessible_get_editable_text_iface:
+ * @obj: a pointer to the #AtspiAccessible instance to query.
+ *
+ * Gets the #AtspiEditableText interface for an #AtspiAccessible.
+ *
+ * Returns: (transfer full): a pointer to an #AtspiEditableText interface
+ *          instance, or NULL if @obj does not implement #AtspiEditableText.
+ **/
+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);  
+}
+
+/**
  * atspi_accessible_get_hyperlink:
  * @obj: a pointer to the #AtspiAccessible object on which to operate.
  *
@@ -1283,13 +1287,15 @@ 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.
  *
  * Returns: (transfer full): a pointer to an #AtspiHypertext interface
  *          instance, or NULL if @obj does not implement #AtspiHypertext.
+ *
+ * Deprecated: 2.10: Use atspi_accessible_get_hypertext_iface instead.
  **/
 AtspiHypertext *
 atspi_accessible_get_hypertext (AtspiAccessible *accessible)
@@ -1299,13 +1305,31 @@ atspi_accessible_get_hypertext (AtspiAccessible *accessible)
 }
 
 /**
- * atspi_accessible_get_image:
+ * atspi_accessible_get_hypertext_iface:
+ * @obj: a pointer to the #AtspiAccessible instance to query.
+ *
+ * Gets the #AtspiHypertext interface for an #AtspiAccessible.
+ *
+ * Returns: (transfer full): a pointer to an #AtspiHypertext interface
+ *          instance, or NULL if @obj does not implement #AtspiHypertext.
+ **/
+AtspiHypertext *
+atspi_accessible_get_hypertext_iface (AtspiAccessible *accessible)
+{
+  return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
+          g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);  
+}
+
+/**
+ * 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.
  *
  * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
  *          NULL if @obj does not implement #AtspiImage.
+ *
+ * Deprecated: 2.10: Use atspi_accessible_get_image_iface instead.
  **/
 AtspiImage *
 atspi_accessible_get_image (AtspiAccessible *accessible)
@@ -1315,13 +1339,31 @@ atspi_accessible_get_image (AtspiAccessible *accessible)
 }
 
 /**
- * atspi_accessible_get_selection:
+ * atspi_accessible_get_image_iface:
+ * @obj: a pointer to the #AtspiAccessible instance to query.
+ *
+ * Gets the #AtspiImage interface for an #AtspiAccessible.
+ *
+ * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
+ *          NULL if @obj does not implement #AtspiImage.
+ **/
+AtspiImage *
+atspi_accessible_get_image_iface (AtspiAccessible *accessible)
+{
+  return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
+          g_object_ref (ATSPI_IMAGE (accessible)) : NULL);  
+}
+
+/**
+ * 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.
  *
  * Returns: (transfer full): a pointer to an #AtspiSelection interface
  *          instance, or NULL if @obj does not implement #AtspiSelection.
+ *
+ * Deprecated: 2.10: Use atspi_accessible_get_selection_iface instead.
  **/
 AtspiSelection *
 atspi_accessible_get_selection (AtspiAccessible *accessible)
@@ -1330,6 +1372,22 @@ atspi_accessible_get_selection (AtspiAccessible *accessible)
           g_object_ref (ATSPI_SELECTION (accessible)) : NULL);  
 }
 
+/**
+ * atspi_accessible_get_selection_iface:
+ * @obj: a pointer to the #AtspiAccessible instance to query.
+ *
+ * Gets the #AtspiSelection interface for an #AtspiAccessible.
+ *
+ * Returns: (transfer full): a pointer to an #AtspiSelection interface
+ *          instance, or NULL if @obj does not implement #AtspiSelection.
+ **/
+AtspiSelection *
+atspi_accessible_get_selection_iface (AtspiAccessible *accessible)
+{
+  return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
+          g_object_ref (ATSPI_SELECTION (accessible)) : NULL);  
+}
+
 #if 0
 /**
  * atspi_accessible_get_streamable_content:
@@ -1349,13 +1407,15 @@ atspi_accessible_get_streamable_content (AtspiAccessible *accessible)
 #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.
  *
  * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
  *          NULL if @obj does not implement #AtspiTable.
+ *
+ * Deprecated: 2.10: Use atspi_accessible_get_table_iface instead.
  **/
 AtspiTable *
 atspi_accessible_get_table (AtspiAccessible *obj)
@@ -1365,13 +1425,47 @@ atspi_accessible_get_table (AtspiAccessible *obj)
 }
 
 /**
- * atspi_accessible_get_text:
+ * atspi_accessible_get_table_iface:
+ * @obj: a pointer to the #AtspiAccessible instance to query.
+ *
+ * Gets the #AtspiTable interface for an #AtspiAccessible.
+ *
+ * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
+ *          NULL if @obj does not implement #AtspiTable.
+ **/
+AtspiTable *
+atspi_accessible_get_table_iface (AtspiAccessible *obj)
+{
+  return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
+          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: (rename-to atspi_accessible_get_text_iface)
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
  * Gets the #AtspiTable interface for an #AtspiAccessible.
  *
  * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
  *          NULL if @obj does not implement #AtspiText.
+ *
+ * Deprecated: 2.10: Use atspi_accessible_get_text_iface instead.
  **/
 AtspiText *
 atspi_accessible_get_text (AtspiAccessible *obj)
@@ -1381,13 +1475,31 @@ atspi_accessible_get_text (AtspiAccessible *obj)
 }
 
 /**
- * atspi_accessible_get_value:
+ * atspi_accessible_get_text_iface:
+ * @obj: a pointer to the #AtspiAccessible instance to query.
+ *
+ * Gets the #AtspiTable interface for an #AtspiAccessible.
+ *
+ * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
+ *          NULL if @obj does not implement #AtspiText.
+ **/
+AtspiText *
+atspi_accessible_get_text_iface (AtspiAccessible *obj)
+{
+  return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
+          g_object_ref (ATSPI_TEXT (obj)) : NULL);
+}
+
+/**
+ * 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.
  *
  * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
  *          NULL if @obj does not implement #AtspiValue.
+ *
+ * Deprecated: 2.10: Use atspi_accessible_get_value_iface instead.
  **/
 AtspiValue *
 atspi_accessible_get_value (AtspiAccessible *accessible)
@@ -1396,6 +1508,22 @@ atspi_accessible_get_value (AtspiAccessible *accessible)
           g_object_ref (ATSPI_VALUE (accessible)) : NULL);  
 }
 
+/**
+ * atspi_accessible_get_value_iface:
+ * @obj: a pointer to the #AtspiAccessible instance to query.
+ *
+ * Gets the #AtspiTable interface for an #AtspiAccessible.
+ *
+ * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
+ *          NULL if @obj does not implement #AtspiValue.
+ **/
+AtspiValue *
+atspi_accessible_get_value_iface (AtspiAccessible *accessible)
+{
+  return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
+          g_object_ref (ATSPI_VALUE (accessible)) : NULL);  
+}
+
 static void
 append_const_val (GArray *array, const gchar *val)
 {
@@ -1443,6 +1571,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))
@@ -1469,7 +1599,7 @@ _atspi_accessible_new (AtspiApplication *app, const gchar *path)
  * atspi_accessible_set_cache_mask:
  * @accessible: The #AtspiAccessible to operate on.  Must be the desktop or
  *             the root of an application.
- * @mask: (type int): An #AtspiCache specifying a bit mask of the types of data to cache.
+ * @mask: An #AtspiCache specifying a bit mask of the types of data to cache.
  *
  * Sets the type of data to cache for accessibles.
  * If this is not set for an application or is reset to ATSPI_CACHE_UNDEFINED,
@@ -1491,33 +1621,35 @@ atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask)
 
 /**
  * atspi_accessible_clear_cache:
- * @accessible: The #AtspiAccessible whose cache to clear.
+ * @obj: The #AtspiAccessible whose cache to clear.
  *
  * Clears the cached information for the given accessible and all of its
  * descendants.
  */
 void
-atspi_accessible_clear_cache (AtspiAccessible *accessible)
+atspi_accessible_clear_cache (AtspiAccessible *obj)
 {
-  GList *l;
+  gint i;
 
-  if (accessible)
+  if (obj)
   {
-    accessible->cached_properties = ATSPI_CACHE_NONE;
-    for (l = accessible->children; l; l = l->next)
-      atspi_accessible_clear_cache (l->data);
+    obj->cached_properties = ATSPI_CACHE_NONE;
+    if (obj->children)
+      for (i = 0; i < obj->children->len; i++)
+        atspi_accessible_clear_cache (g_ptr_array_index (obj->children, i));
   }
 }
 
 /**
  * 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)
@@ -1528,7 +1660,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",
@@ -1540,11 +1675,15 @@ atspi_accessible_get_process_id (AtspiAccessible *accessible, GError **error)
   dbus_error_init (&d_error);
   reply = dbus_connection_send_with_reply_and_block (bus, message, -1, &d_error);
   dbus_message_unref (message);
-  dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &pid, DBUS_TYPE_INVALID);
-  dbus_message_unref (reply);
+  if (reply)
+  {
+    if (!strcmp (dbus_message_get_signature (reply), "u"))
+      dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &pid, DBUS_TYPE_INVALID);
+    dbus_message_unref (reply);
+  }
   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;
@@ -1581,7 +1720,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);
 }
 
@@ -1592,3 +1732,70 @@ _atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag)
 
   accessible->cached_properties |= flag & mask;
 }
+
+/**
+ * atspi_accessible_get_locale:
+ * @accessible: an #AtspiAccessible
+ *
+ * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
+ * of @accessible.
+ *
+ * Since: 2.7.91
+ *
+ * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
+ *          locale of @accessible.
+ **/
+const gchar*
+atspi_accessible_get_object_locale (AtspiAccessible *accessible, GError **error)
+{
+  gchar *locale;
+
+  g_return_val_if_fail (accessible != NULL, NULL);
+
+  locale = g_object_get_qdata (G_OBJECT (accessible), quark_locale);
+  if (!locale)
+  {
+    if (!_atspi_dbus_get_property (accessible, atspi_interface_accessible,
+                                   "Locale", error, "s", &locale))
+      return NULL;
+    if (locale)
+      g_object_set_qdata_full (G_OBJECT (accessible), quark_locale, locale,
+                               g_free);
+  }
+  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;
+  }
+}