Add navigation helper functions for screen-reader and friends
[platform/upstream/at-spi2-core.git] / atspi / atspi-accessible.c
index 9e5c503..a579254 100644 (file)
@@ -4,6 +4,7 @@
  *
  * Copyright 2001, 2002 Sun Microsystems Inc.,
  * Copyright 2001, 2002 Ximian, 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
  */
 
 #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)
 {
@@ -44,6 +49,7 @@ atspi_document_interface_init (AtspiDocument *document)
 {
 }
 
+static void
 atspi_editable_text_interface_init (AtspiEditableText *editable_text)
 {
 }
@@ -69,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)
 {
 }
@@ -79,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)
@@ -88,20 +100,107 @@ 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))
 
+#ifdef DEBUG_REF_COUNTS
+static gint accessible_count = 0;
+#endif
+
 static void
 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);
+}
+
+static void
+atspi_accessible_dispose (GObject *object)
+{
+  AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
+  AtspiEvent e;
+  AtspiAccessible *parent;
+  GList *children;
+  GList *l;
+
+  /* TODO: Only fire if object not already marked defunct */
+  memset (&e, 0, sizeof (e));
+  e.type = "object:state-changed:defunct";
+  e.source = accessible;
+  e.detail1 = 1;
+  e.detail2 = 0;
+  _atspi_send_event (&e);
+
+  if (accessible->states)
+  {
+    g_object_unref (accessible->states);
+    accessible->states = NULL;
+  }
+
+  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;
+  }
+
+  children = accessible->children;
+  accessible->children = NULL;
+  for (l = children; l; l = l->next)
+  {
+    AtspiAccessible *child = l->data;
+    if (child && child->accessible_parent == accessible)
+    {
+      g_object_unref (accessible);
+      child->accessible_parent = NULL;
+    }
+    g_object_unref (child);
+  }
+  g_list_free (children);
+
+  G_OBJECT_CLASS (atspi_accessible_parent_class) ->dispose (object);
 }
 
 static void
-atspi_accessible_finalize (GObject *obj)
+atspi_accessible_finalize (GObject *object)
 {
-  /*AtspiAccessible *accessible = ATSPI_ACCESSIBLE (obj); */
+  AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
+
+    g_free (accessible->description);
+    g_free (accessible->name);
+  if (accessible->attributes)
+    g_hash_table_unref (accessible->attributes);
 
-  /* TODO: Unref parent/children, etc. */
+    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);
 }
 
 static void
@@ -109,169 +208,173 @@ atspi_accessible_class_init (AtspiAccessibleClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
+  object_class->dispose = atspi_accessible_dispose;
   object_class->finalize = atspi_accessible_finalize;
-}
 
-/* TODO: Generate following from spec? */
-static const char *role_names [] =
-{
-  "invalid",
-  "accel-label",
-  "alert",
-  "animation",
-  "arrow",
-  "calendar",
-  "canvas",
-  "check-box",
-  "check-menu-item",
-  "color-chooser",
-  "column-header",
-  "combo-box",
-  "date-editor",
-  "desktop-icon",
-  "desktop-frame",
-  "dial",
-  "dialog",
-  "directory-pane",
-  "drawing-area",
-  "file-chooser",
-  "filler",
-  "font-chooser",
-  "frame",
-  "glass-pane",
-  "html-container",
-  "icon",
-  "image",
-  "internalframe",
-  "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",
-  "fooler",
-  "paragraph",
-  "ruler",
-  "application",
-  "autocomplete",
-  "editbar",
-  "embedded",
-  "entry",
-  "chart",
-  "caption",
-  "document_frame",
-  "heading",
-  "page",
-  "section",
-  "form",
-  "redundant object",
-  "link",
-  "input method window"
-};
-
-#define MAX_ROLES (sizeof (role_names) / sizeof (char *))
-
-/**
- * atspi_role_get_name
- * @role: an #AtspiAccessibleRole object to query.
- *
- * Get a localizeable string that indicates the name of an #AtspiAccessibleRole.
- * <em>DEPRECATED.</em>
- *
- * Returns: a localizable string name for an #AtspiAccessibleRole 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");
 }
 
 /**
  * atspi_accessible_get_name:
  * @obj: a pointer to the #AtspiAccessible object on which to operate.
  *
- * Get the name of an #AtspiAccessible object.
+ * Gets the name of an #AtspiAccessible object.
  *
- * Returns: a UTF-8 string indicating the name of the #AtspiAccessible object.
- * or NULL on exception
+ * Returns: a UTF-8 string indicating the name of the #AtspiAccessible object
+ * or NULL on exception.
  **/
 gchar *
 atspi_accessible_get_name (AtspiAccessible *obj, GError **error)
 {
   g_return_val_if_fail (obj != NULL, g_strdup (""));
-  if (!(obj->cached_properties & ATSPI_CACHE_NAME))
+  if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_NAME))
   {
     if (!_atspi_dbus_get_property (obj, atspi_interface_accessible, "Name", error,
                                    "s", &obj->name))
       return g_strdup ("");
-    obj->cached_properties |= ATSPI_CACHE_NAME;
+    _atspi_accessible_add_cache (obj, ATSPI_CACHE_NAME);
   }
   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.
  *
- * Get the description of an #AtspiAccessible object.
+ * Gets the description of an #AtspiAccessible object.
  *
- * Returns: a UTF-8 string describing the #AtspiAccessible object.
- * or NULL on exception
+ * Returns: a UTF-8 string describing the #AtspiAccessible object
+ * or NULL on exception.
  **/
 gchar *
 atspi_accessible_get_description (AtspiAccessible *obj, GError **error)
 {
   g_return_val_if_fail (obj != NULL, g_strdup (""));
 
-  if (!(obj->cached_properties & ATSPI_CACHE_DESCRIPTION))
+  if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_DESCRIPTION))
   {
-    if (!_atspi_dbus_call (obj, atspi_interface_accessible, "GetDescription", NULL, "=>s", &obj->description))
+    if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
+                                   "Description", error, "s",
+                                   &obj->description))
       return g_strdup ("");
-    obj->cached_properties |= ATSPI_CACHE_DESCRIPTION;
+    _atspi_accessible_add_cache (obj, ATSPI_CACHE_DESCRIPTION);
   }
   return g_strdup (obj->description);
 }
@@ -282,11 +385,12 @@ const char *str_parent = "Parent";
  * atspi_accessible_get_parent:
  * @obj: a pointer to the #AtspiAccessible object to query.
  *
- * Get an #AtspiAccessible object's parent container.
+ * 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 *
@@ -294,7 +398,8 @@ atspi_accessible_get_parent (AtspiAccessible *obj, GError **error)
 {
   g_return_val_if_fail (obj != NULL, NULL);
 
-  if (!(obj->cached_properties & ATSPI_CACHE_PARENT))
+  if (obj->parent.app &&
+      !_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT))
   {
     DBusMessage *message, *reply;
     DBusMessageIter iter, iter_variant;
@@ -306,15 +411,19 @@ atspi_accessible_get_parent (AtspiAccessible *obj, GError **error)
     dbus_message_append_args (message, DBUS_TYPE_STRING, &atspi_interface_accessible,
                                DBUS_TYPE_STRING, &str_parent,
                               DBUS_TYPE_INVALID);
-    reply = _atspi_dbus_send_with_reply_and_block (message);
-    if (!reply ||
-       (strcmp (dbus_message_get_signature (reply), "v") != 0))
+    reply = _atspi_dbus_send_with_reply_and_block (message, error);
+    if (!reply)
+      return NULL;
+    if (strcmp (dbus_message_get_signature (reply), "v") != 0)
+    {
+      dbus_message_unref (reply);
       return NULL;
+    }
     dbus_message_iter_init (reply, &iter);
     dbus_message_iter_recurse (&iter, &iter_variant);
     obj->accessible_parent = _atspi_dbus_return_accessible_from_iter (&iter_variant);
     dbus_message_unref (reply);
-    obj->cached_properties |= ATSPI_CACHE_PARENT;
+    _atspi_accessible_add_cache (obj, ATSPI_CACHE_PARENT);
   }
   if (!obj->accessible_parent)
     return NULL;
@@ -325,10 +434,10 @@ atspi_accessible_get_parent (AtspiAccessible *obj, GError **error)
  * atspi_accessible_get_child_count:
  * @obj: a pointer to the #AtspiAccessible object on which to operate.
  *
- * Get the number of children contained by an #AtspiAccessible object.
+ * Gets the number of children contained by an #AtspiAccessible object.
  *
  * Returns: a #long indicating the number of #AtspiAccessible children
- *          contained by an #AtspiAccessible object. or -1 on exception
+ *          contained by an #AtspiAccessible object or -1 on exception.
  *
  **/
 gint
@@ -336,7 +445,7 @@ atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error)
 {
   g_return_val_if_fail (obj != NULL, -1);
 
-  if (!(obj->cached_properties & ATSPI_CACHE_CHILDREN))
+  if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
   {
     dbus_int32_t ret;
     if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
@@ -353,10 +462,10 @@ atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error)
  * @obj: a pointer to the #AtspiAccessible object on which to operate.
  * @child_index: a #long indicating which child is specified.
  *
- * Get the #AtspiAccessible child of an #AtspiAccessible object at a given index.
+ * Gets the #AtspiAccessible child of an #AtspiAccessible object at a given index.
  *
  * Returns: (transfer full): a pointer to the #AtspiAccessible child object at
- * index @child_index. or NULL on exception
+ * index @child_index or NULL on exception.
  **/
 AtspiAccessible *
 atspi_accessible_get_child_at_index (AtspiAccessible *obj,
@@ -367,7 +476,7 @@ atspi_accessible_get_child_at_index (AtspiAccessible *obj,
 
   g_return_val_if_fail (obj != NULL, NULL);
 
-  if (!(obj->cached_properties & ATSPI_CACHE_CHILDREN))
+  if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
   {
     DBusMessage *reply;
     reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
@@ -383,13 +492,14 @@ atspi_accessible_get_child_at_index (AtspiAccessible *obj,
 }
 
 /**
- * atspi_accessible_get_index_in_parent
+ * atspi_accessible_get_index_in_parent:
  * @obj: a pointer to the #AtspiAccessible object on which to operate.
  *
- * Get the index of an #AtspiAccessible object in its containing #AtspiAccessible.
+ * Gets the index of an #AtspiAccessible object within its parent's
+ * #AtspiAccessible children list.
  *
  * Returns: a #glong indicating the index of the #AtspiAccessible object
- *          in its parent (i.e. containing) #AtspiAccessible instance,
+ *          in its parent,
  *          or -1 if @obj has no containing parent or on exception.
  **/
 gint
@@ -399,12 +509,16 @@ atspi_accessible_get_index_in_parent (AtspiAccessible *obj, GError **error)
   gint i = 0;
 
   g_return_val_if_fail (obj != NULL, -1);
-  if (!obj->accessible_parent) return -1;
-  if (!(obj->accessible_parent->cached_properties & ATSPI_CACHE_CHILDREN))
+  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))
   {
-    dbus_uint32_t ret = -1;
+    dbus_int32_t ret = -1;
     _atspi_dbus_call (obj, atspi_interface_accessible,
-                      "GetIndexInParent", NULL, "=>u", &ret);
+                      "GetIndexInParent", NULL, "=>i", &ret);
     return ret;
   }
 
@@ -428,11 +542,11 @@ typedef struct
  * atspi_accessible_get_relation_set:
  * @obj: a pointer to the #AtspiAccessible object on which to operate.
  *
- * Get the set of #AtspiRelation objects which describe this #AtspiAccessible object's
- *       relationships with other #AtspiAccessible objects.
+ * Gets the set of #AtspiRelation objects which describes this #AtspiAccessible object's
+ * relationships with other #AtspiAccessible objects.
  *
- * Returns: (element-type AtspiAccessible*) (transfer full): an array of
- *          #AtspiAccessibleRelation pointers. or NULL on exception
+ * Returns: (element-type AtspiRelation*) (transfer full): a #GArray of
+ *          #AtspiRelation pointers or NULL on exception.
  **/
 GArray *
 atspi_accessible_get_relation_set (AtspiAccessible *obj, GError **error)
@@ -444,21 +558,21 @@ atspi_accessible_get_relation_set (AtspiAccessible *obj, GError **error)
   g_return_val_if_fail (obj != NULL, NULL);
 
   reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetRelationSet", error, "");
-  _ATSPI_DBUS_CHECK_SIG (reply, "a(ua(so))", NULL);
+  if (!reply)
+    return NULL;
+  _ATSPI_DBUS_CHECK_SIG (reply, "a(ua(so))", error, NULL);
 
   ret = g_array_new (TRUE, TRUE, sizeof (AtspiRelation *));
   dbus_message_iter_init (reply, &iter);
   dbus_message_iter_recurse (&iter, &iter_array);
   while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
   {
-    GArray *new_array;
     AtspiRelation *relation;
     relation = _atspi_relation_new_from_iter (&iter_array);
-    new_array = g_array_append_val (ret, relation);
-    if (new_array)
-      ret = new_array;
+    ret = g_array_append_val (ret, relation);
     dbus_message_iter_next (&iter_array);
   }
+  dbus_message_unref (reply);
   return ret;
 }
 
@@ -466,10 +580,10 @@ atspi_accessible_get_relation_set (AtspiAccessible *obj, GError **error)
  * atspi_accessible_get_role:
  * @obj: a pointer to the #AtspiAccessible object on which to operate.
  *
- * Get the UI role of an #AtspiAccessible object.
- * A UTF-8 string describing this role can be obtained via atspi_accessible_getRoleName ().
+ * Gets the UI role played by an #AtspiAccessible object.
+ * This role's name can be obtained via atspi_accessible_get_role_name ().
  *
- * Returns: the #AtspiRole of the object.
+ * Returns: the #AtspiRole of an #AtspiAccessible object.
  *
  **/
 AtspiRole
@@ -477,14 +591,14 @@ atspi_accessible_get_role (AtspiAccessible *obj, GError **error)
 {
   g_return_val_if_fail (obj != NULL, ATSPI_ROLE_INVALID);
 
-  if (!(obj->cached_properties & ATSPI_CACHE_ROLE))
+  if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ROLE))
   {
     dbus_uint32_t role;
     /* TODO: Make this a property */
-    if (_atspi_dbus_call (obj, atspi_interface_accessible, "GetRole", NULL, "=>u", &role))
+    if (_atspi_dbus_call (obj, atspi_interface_accessible, "GetRole", error, "=>u", &role))
     {
-      obj->cached_properties |= ATSPI_CACHE_ROLE;
       obj->role = role;
+    _atspi_accessible_add_cache (obj, ATSPI_CACHE_ROLE);
     }
   }
   return obj->role;
@@ -494,20 +608,26 @@ atspi_accessible_get_role (AtspiAccessible *obj, GError **error)
  * atspi_accessible_get_role_name:
  * @obj: a pointer to the #AtspiAccessible object on which to operate.
  *
- * Get a UTF-8 string describing the role this object plays in the UI.
+ * Gets a UTF-8 string corresponding to the name of the role played by an object.
  * This method will return useful values for roles that fall outside the
- * enumeration used in atspi_accessible_getRole ().
+ * enumeration used in atspi_accessible_get_role ().
  *
- * Returns: a UTF-8 string specifying the role of this #AtspiAccessible object.
+ * Returns: a UTF-8 string specifying the type of UI role played by an
+ * #AtspiAccessible object.
  *
  **/
 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 < ATSPI_ROLE_COUNT && role != ATSPI_ROLE_EXTENDED)
+    return atspi_role_get_name (role);
+
   _atspi_dbus_call (obj, atspi_interface_accessible, "GetRoleName", error, "=>s", &retval);
 
   if (!retval)
@@ -520,11 +640,13 @@ 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.
  *
- * Get a UTF-8 string describing the (localized) role this object plays in the UI.
+ * 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 UTF-8 string specifying the role of this #AtspiAccessible object.
+ * Returns: a localized, UTF-8 string specifying the type of UI role played
+ * by an #AtspiAccessible object.
  *
  **/
 gchar *
@@ -542,30 +664,42 @@ atspi_accessible_get_localized_role_name (AtspiAccessible *obj, GError **error)
   return retval;
 }
 
+static AtspiStateSet *
+defunct_set ()
+{
+  AtspiStateSet *set = atspi_state_set_new (NULL);
+  atspi_state_set_add (set, ATSPI_STATE_DEFUNCT);
+  return set;
+}
+
 /**
  * atspi_accessible_get_state_set:
  * @obj: a pointer to the #AtspiAccessible object on which to operate.
  *
- * Gets the current state of an object.
+ * Gets the states currently held by an object.
  *
- * Returns: (transfer full): a pointer to an #AtspiStateSet representing the
- *          object's current state.
+ * Returns: (transfer full): a pointer to an #AtspiStateSet representing an
+ * object's current state set.
  **/
 AtspiStateSet *
 atspi_accessible_get_state_set (AtspiAccessible *obj)
 {
-  if (!(obj->cached_properties & ATSPI_CACHE_STATES))
+  /* TODO: Should take a GError **, but would be an API break */
+  if (!obj->parent.app || !obj->parent.app->bus)
+    return defunct_set ();
+
+  if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_STATES))
   {
     DBusMessage *reply;
     DBusMessageIter iter;
     reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
                                       "GetState", NULL, "");
-    _ATSPI_DBUS_CHECK_SIG (reply, "au", NULL);
+    _ATSPI_DBUS_CHECK_SIG (reply, "au", NULL, defunct_set ());
     dbus_message_iter_init (reply, &iter);
     _atspi_dbus_set_state (obj, &iter);
     dbus_message_unref (reply);
+    _atspi_accessible_add_cache (obj, ATSPI_CACHE_STATES);
   }
-
   return g_object_ref (obj->states);
 }
 
@@ -573,33 +707,54 @@ atspi_accessible_get_state_set (AtspiAccessible *obj)
  * atspi_accessible_get_attributes:
  * @obj: The #AtspiAccessible being queried.
  *
- * Get 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.
  *
  * Returns: (element-type gchar* gchar*) (transfer full): The name-value-pair
- *          attributes assigned to this object.
+ * attributes assigned to this object.
  */
 GHashTable *
 atspi_accessible_get_attributes (AtspiAccessible *obj, GError **error)
 {
   DBusMessage *message;
-  GHashTable *ret;
 
     g_return_val_if_fail (obj != NULL, NULL);
 
-  message = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetAttributes", error, "");
-  ret = _atspi_dbus_hash_from_message (message);
-  dbus_message_unref (message);
-  return ret;
+  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,
+                                        "GetAttributes", error, "");
+    obj->attributes = _atspi_dbus_return_hash_from_message (message);
+    _atspi_accessible_add_cache (obj, ATSPI_CACHE_ATTRIBUTES);
+  }
+
+  if (!obj->attributes)
+    return NULL;
+  return g_hash_table_ref (obj->attributes);
+}
+
+static void
+add_to_attribute_array (gpointer key, gpointer value, gpointer data)
+{
+  GArray **array = (GArray **)data;
+  gchar *str = g_strconcat (key, ":", value, NULL);
+  *array = g_array_append_val (*array, str);
 }
 
 /**
  * atspi_accessible_get_attributes_as_array:
  * @obj: The #AtspiAccessible being queried.
  *
- * Get the #AttributeSet 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.
@@ -611,24 +766,32 @@ GArray *
 atspi_accessible_get_attributes_as_array (AtspiAccessible *obj, GError **error)
 {
   DBusMessage *message;
-  GArray *ret;
 
     g_return_val_if_fail (obj != NULL, NULL);
 
+  if (obj->priv->cache)
+  {
+    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, "");
-  ret = _atspi_dbus_attribute_array_from_message (message);
-  if (message)
-    dbus_message_unref (message);
-  return ret;
+  return _atspi_dbus_return_attribute_array_from_message (message);
 }
 
 /**
  * atspi_accessible_get_application:
  * @obj: The #AtspiAccessible being queried.
  *
- * Get the containing #AtspiApplication for an object.
+ * Gets the containing #AtspiApplication for an object.
  *
- * Returns: (transfer full): the containing AtspiApplication instance for
+ * Returns: (transfer full): the containing #AtspiApplication instance for
  *          this object.
  */
 AtspiAccessible *
@@ -636,68 +799,172 @@ atspi_accessible_get_application (AtspiAccessible *obj, GError **error)
 {
   AtspiAccessible *parent;
 
+  g_object_ref (obj);
   for (;;)
   {
     parent = atspi_accessible_get_parent (obj, NULL);
+    if (!parent && obj->parent.app &&
+        atspi_accessible_get_role (obj, NULL) != ATSPI_ROLE_APPLICATION)
+    {
+      AtspiAccessible *root = g_object_ref (obj->parent.app->root);
+      if (root)
+      {
+        g_object_unref (obj);
+        if (atspi_accessible_get_role (root, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
+        {
+          g_object_unref (root);
+          return NULL;
+        }
+        return root;
+      }
+    }
     if (!parent || parent == obj ||
         atspi_accessible_get_role (parent, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
-    return g_object_ref (obj);
+  {
+    if (parent)
+      g_object_unref (parent);
+    return obj;
+  }
+    g_object_unref (obj);
     obj = parent;
   }
 }
 
-/* Applicatio-specific methods */
+/* Application-specific methods */
 
 /**
  * atspi_accessible_get_toolkit_name:
  * @obj: a pointer to the #AtspiAccessible object on which to operate.
  *
- * Get the toolkit for a #AtspiAccessible object.
+ * Gets the toolkit name for an #AtspiAccessible object.
  * Only works on application root objects.
  *
- * Returns: a UTF-8 string indicating the toolkit name for the #AtspiAccessible object.
- * or NULL on exception
+ * Returns: a UTF-8 string indicating the toolkit name for the #AtspiAccessible object or NULL on exception.
  **/
 gchar *
 atspi_accessible_get_toolkit_name (AtspiAccessible *obj, GError **error)
 {
-  gchar *ret = NULL;
-
   g_return_val_if_fail (obj != NULL, NULL);
 
-  if (!_atspi_dbus_get_property (obj, atspi_interface_application, "ToolkitName", error, "s", &ret))
-      return NULL;
-  return g_strdup (ret);
+  if (!obj->parent.app)
+    return NULL;
+
+  if (!obj->parent.app->toolkit_name)
+    _atspi_dbus_get_property (obj, atspi_interface_application, "ToolkitName",
+                              error, "s", &obj->parent.app->toolkit_name);
+
+  return g_strdup (obj->parent.app->toolkit_name);
 }
 
 /**
  * atspi_accessible_get_toolkit_version:
  * @obj: a pointer to the #AtspiAccessible object on which to operate.
  *
- * Get the toolkit version for a #AtspiAccessible object.
+ * Gets the toolkit version for an #AtspiAccessible object.
  * Only works on application root objects.
  *
- * Returns: a UTF-8 string indicating the toolkit ersion for the #AtspiAccessible object.
- * or NULL on exception
+ * Returns: a UTF-8 string indicating the toolkit version for the #AtspiAccessible object or NULL on exception.
  **/
 gchar *
 atspi_accessible_get_toolkit_version (AtspiAccessible *obj, GError **error)
 {
-  gchar *ret = NULL;
+  g_return_val_if_fail (obj != NULL, NULL);
+
+  if (!obj->parent.app)
+    return NULL;
+
+  if (!obj->parent.app->toolkit_version)
+    _atspi_dbus_get_property (obj, atspi_interface_application, "Version",
+                              error, "s", &obj->parent.app->toolkit_version);
 
+  return g_strdup (obj->parent.app->toolkit_version);
+}
+
+/**
+ * atspi_accessible_get_atspi_version:
+ * @obj: a pointer to the #AtspiAccessible object on which to operate.
+ *
+ * Gets the AT-SPI IPC specification version supported by the application
+ * pointed to by the #AtspiAccessible object.
+ * Only works on application root objects.
+ *
+ * Returns: a UTF-8 string indicating the AT-SPI version for the #AtspiAccessible object or NULL on exception.
+ **/
+gchar *
+atspi_accessible_get_atspi_version (AtspiAccessible *obj, GError **error)
+{
   g_return_val_if_fail (obj != NULL, NULL);
 
-  if (!_atspi_dbus_get_property (obj, atspi_interface_application, "ToolkitVersion", error, "s", &ret))
-      return NULL;
-  return g_strdup (ret);
+  if (!obj->parent.app)
+    return NULL;
+
+  if (!obj->parent.app->atspi_version)
+    _atspi_dbus_get_property (obj, atspi_interface_application, "AtspiVersion",
+                              error, "s", &obj->parent.app->atspi_version);
+
+  return g_strdup (obj->parent.app->atspi_version);
+}
+
+/**
+ * atspi_accessible_get_id:
+ * @obj: a pointer to the #AtspiAccessible object on which to operate.
+ *
+ * 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
+ * or -1 on exception.
+ **/
+gint
+atspi_accessible_get_id (AtspiAccessible *obj, GError **error)
+{
+  gint ret = -1;
+
+  g_return_val_if_fail (obj != NULL, -1);
+
+  if (!_atspi_dbus_get_property (obj, atspi_interface_application, "Id", error, "i", &ret))
+      return -1;
+  return ret;
 }
+
+
 /* Interface query methods */
 
+static gboolean
+_atspi_accessible_is_a (AtspiAccessible *accessible,
+                     const char *interface_name)
+{
+  int n;
+
+  if (accessible == NULL)
+    {
+      return FALSE;
+    }
+
+  if (!_atspi_accessible_test_cache (accessible, ATSPI_CACHE_INTERFACES))
+  {
+    DBusMessage *reply;
+    DBusMessageIter iter;
+    reply = _atspi_dbus_call_partial (accessible, atspi_interface_accessible,
+                                      "GetInterfaces", NULL, "");
+    _ATSPI_DBUS_CHECK_SIG (reply, "as", NULL, FALSE);
+    dbus_message_iter_init (reply, &iter);
+    _atspi_dbus_set_interfaces (accessible, &iter);
+    dbus_message_unref (reply);
+    _atspi_accessible_add_cache (accessible, ATSPI_CACHE_INTERFACES);
+  }
+
+  n = _atspi_get_iface_num (interface_name);
+  if (n == -1) return FALSE;
+  return (gboolean) ((accessible->interfaces & (1 << n))? TRUE: FALSE);
+}
+
 /**
  * atspi_accessible_is_action:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Query whether the specified #AtspiAccessible implements #AtspiAction.
+ * Query whether the specified #AtspiAccessible implements the
+ * #AtspiAction interface.
  *
  * Returns: #TRUE if @obj implements the #AtspiAction interface,
  *          #FALSE otherwise.
@@ -713,7 +980,8 @@ atspi_accessible_is_action (AtspiAccessible *obj)
  * atspi_accessible_is_application:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Query whether the specified #AtspiAccessible implements #AtspiApplication.
+ * Query whether the specified #AtspiAccessible implements the
+ * #AtspiApplication interface.
  *
  * Returns: #TRUE if @obj implements the #AtspiApplication interface,
  *          #FALSE otherwise.
@@ -725,23 +993,21 @@ atspi_accessible_is_application (AtspiAccessible *obj)
                              atspi_interface_application);
 }
 
-/**                      
- * atspi_accessible_is_collection:                                                                                                                                                                          * @obj: a pointer to the #AtspiAccessible instance to query.                                                                                                                                          
- *                          
- * Query whether the specified #AtspiAccessible implements #AtspiCollection.    
- * Returns: #TRUE if @obj implements the #AtspiCollection interface,                                                                                                               
+/**
+ * atspi_accessible_is_collection:
+ * @obj: a pointer to the #AtspiAccessible instance to query.
+ *
+ * Query whether the specified #AtspiAccessible implements the
+ * #AtspiCollection interface.
+ *
+ * Returns: #TRUE if @obj implements the #AtspiCollection interface,
  *          #FALSE otherwise.
  **/
 gboolean
 atspi_accessible_is_collection (AtspiAccessible *obj)
 {
-#if 0
-     g_warning ("Collections not implemented");
      return _atspi_accessible_is_a (obj,
                              atspi_interface_collection);
-#else
-     return FALSE;
-#endif
 }
 
 /**
@@ -764,7 +1030,8 @@ atspi_accessible_is_component (AtspiAccessible *obj)
  * atspi_accessible_is_document:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Query whether the specified #AtspiAccessible implements #AtspiDocument.
+ * Query whether the specified #AtspiAccessible implements the
+ * #AtspiDocument interface.
  *
  * Returns: #TRUE if @obj implements the #AtspiDocument interface,
  *          #FALSE otherwise.
@@ -780,7 +1047,8 @@ atspi_accessible_is_document (AtspiAccessible *obj)
  * atspi_accessible_is_editable_text:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Query whether the specified #AtspiAccessible implements #AtspiEditableText.
+ * Query whether the specified #AtspiAccessible implements the
+ * #AtspiEditableText interface.
  *
  * Returns: #TRUE if @obj implements the #AtspiEditableText interface,
  *          #FALSE otherwise.
@@ -791,12 +1059,13 @@ 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.
  *
- * Query whether the specified #AtspiAccessible implements #AtspiHypertext.
+ * Query whether the specified #AtspiAccessible implements the
+ * #AtspiHypertext interface.
  *
  * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
  *          #FALSE otherwise.
@@ -809,10 +1078,28 @@ 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
+ * #AtspiHyperlink interface.
+ *
+ * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
+ *          #FALSE otherwise.
+ **/
+gboolean
+atspi_accessible_is_hyperlink (AtspiAccessible *obj)
+{
+  return _atspi_accessible_is_a (obj,
+                             atspi_interface_hyperlink);
+}
+
+/**
  * atspi_accessible_is_image:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Query whether the specified #AtspiAccessible implements #AtspiImage.
+ * Query whether the specified #AtspiAccessible implements the
+ * #AtspiImage interface.
  *
  * Returns: #TRUE if @obj implements the #AtspiImage interface,
  *          #FALSE otherwise.
@@ -828,7 +1115,8 @@ atspi_accessible_is_image (AtspiAccessible *obj)
  * atspi_accessible_is_selection:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Query whether the specified #AtspiAccessible implements #AtspiSelection.
+ * Query whether the specified #AtspiAccessible implements the
+ * #AtspiSelection interface.
  *
  * Returns: #TRUE if @obj implements the #AtspiSelection interface,
  *          #FALSE otherwise.
@@ -844,7 +1132,8 @@ atspi_accessible_is_selection (AtspiAccessible *obj)
  * atspi_accessible_is_table:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Query whether the specified #AtspiAccessible implements #AtspiTable.
+ * Query whether the specified #AtspiAccessible implements the
+ * #AtspiTable interface.
  *
  * Returns: #TRUE if @obj implements the #AtspiTable interface,
  *          #FALSE otherwise.
@@ -857,11 +1146,28 @@ 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.
  *
- * Query whether the specified #AtspiAccessible implements
- *          #AtspiStreamableContent.
+ * Query whether the specified #AtspiAccessible implements the
+ * #AtspiStreamableContent interface.
  *
  * Returns: #TRUE if @obj implements the #AtspiStreamableContent interface,
  *          #FALSE otherwise.
@@ -882,7 +1188,8 @@ 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 #AtspiText.
+ * Query whether the specified #AtspiAccessible implements the
+ * #AtspiText interface.
  *
  * Returns: #TRUE if @obj implements the #AtspiText interface,
  *          #FALSE otherwise.
@@ -898,7 +1205,8 @@ atspi_accessible_is_text (AtspiAccessible *obj)
  * atspi_accessible_is_value:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Query whether the specified #AtspiAccessible implements #AtspiValue.
+ * Query whether the specified #AtspiAccessible implements the
+ * #AtspiValue interface.
  *
  * Returns: #TRUE if @obj implements the #AtspiValue interface,
  *          #FALSE otherwise.
@@ -911,47 +1219,85 @@ 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.
  *
- * Get the #AtspiAction interface for an #AtspiAccessible.
+ * 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)
 {
   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_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:
+ * atspi_accessible_get_collection: (rename-to atspi_accessible_get_collection_iface)
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Get the #AtspiCollection interface for an #AtspiAccessible.
+ * 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)
 {
   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_collection_iface:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Get the #AtspiComponent interface for an #AtspiAccessible.
+ * Gets the #AtspiCollection interface for an #AtspiAccessible.
  *
- * Returns: (transfer full): a pointer to an #AtspiComponent interface
- *          instance, or NULL if @obj does not implement #AtspiComponent.
+ * Returns: (transfer full): a pointer to an #AtspiCollection interface
+ *          instance, or NULL if @obj does not implement #AtspiCollection.
  **/
-AtspiComponent *
+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)
 {
   return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
@@ -959,43 +1305,94 @@ 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.
  *
- * Get the #AtspiDocument interface for an #AtspiAccessible.
+ * 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)
 {
   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_document_iface:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Get the #AtspiEditableText interface for an #AtspiAccessible.
+ * 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)
 {
   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);
+}
+
+/**
+ * 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:
- * @accessible: a pointer to the #AtspiAccessible object on which to operate.
+ * @obj: a pointer to the #AtspiAccessible object on which to operate.
  *
- * Get the #AtspiHyperlink associated with the given #AtspiAccessible, if
- * supported.
+ * Gets the #AtspiHyperlink interface for an #AtspiAccessible.
  *
  * Returns: (transfer full): the #AtspiHyperlink object associated with
  *          the given #AtspiAccessible, or NULL if not supported.
@@ -1004,55 +1401,109 @@ AtspiHyperlink *
 atspi_accessible_get_hyperlink (AtspiAccessible *accessible)
 {
   return (_atspi_accessible_is_a (accessible, atspi_interface_hyperlink) ?
-          atspi_hyperlink_new (accessible->parent.app, accessible->parent.path) : NULL);
+          _atspi_hyperlink_new (accessible->parent.app, accessible->parent.path) : NULL);
 }
 
 /**
- * atspi_accessible_get_hypertext:
+ * atspi_accessible_get_hypertext: (rename-to atspi_accessible_get_hypertext_iface)
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Get the #AtspiHypertext interface for an #AtspiAccessible.
+ * 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)
 {
   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_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:
+ * atspi_accessible_get_image: (rename-to atspi_accessible_get_image_iface)
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Get the #AtspiImage interface for an #AtspiAccessible.
+ * 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)
 {
   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_image_iface:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Get the #AtspiSelection interface for an #AtspiAccessible.
+ * 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)
 {
   return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
-          g_object_ref (ATSPI_SELECTION (accessible)) : NULL);  
+          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
@@ -1060,7 +1511,7 @@ atspi_accessible_get_selection (AtspiAccessible *accessible)
  * atspi_accessible_get_streamable_content:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Get the #AtspiStreamableContent interface for an #AtspiAccessible.
+ * Gets the #AtspiStreamableContent interface for an #AtspiAccessible.
  *
  * Returns: (transfer full): a pointer to an #AtspiStreamableContent interface
  *          instance, or NULL if @obj does not implement #AtspiStreamableContent.
@@ -1069,485 +1520,399 @@ 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.
  *
- * Get the #AtspiTable interface for an #AtspiAccessible.
+ * 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)
 {
   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_text:
+ * atspi_accessible_get_table_iface:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Get the #AtspiTable interface for an #AtspiAccessible.
+ * Gets the #AtspiTable interface for an #AtspiAccessible.
  *
- * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
+ * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
  *          NULL if @obj does not implement #AtspiTable.
  **/
-AtspiText *
-atspi_accessible_get_text (AtspiAccessible *obj)
+AtspiTable *
+atspi_accessible_get_table_iface (AtspiAccessible *obj)
 {
-  return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
-          g_object_ref (ATSPI_TEXT (obj)) : NULL);
+  return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
+          g_object_ref (ATSPI_TABLE (obj)) : NULL);
 }
 
 /**
- * atspi_accessible_get_value:
+ * atspi_accessible_get_table_cell:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Get the #AtspiTable interface for an #AtspiAccessible.
+ * Gets the #AtspiTableCell interface for an #AtspiAccessible.
  *
- * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
- *          NULL if @obj does not implement #AtspiValue.
+ * Returns: (transfer full): a pointer to an #AtspiTableCell interface instance,
+ *          or NULL if @obj does not implement #AtspiTable.
  **/
-AtspiValue *
-atspi_accessible_get_value (AtspiAccessible *accessible)
+AtspiTableCell *
+atspi_accessible_get_table_cell (AtspiAccessible *obj)
 {
-  return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
-          g_object_ref (ATSPI_VALUE (accessible)) : NULL);  
+  return (_atspi_accessible_is_a (obj, atspi_interface_table_cell) ?
+          g_object_ref (ATSPI_TABLE_CELL (obj)) : NULL);
 }
 
-#if 0
-static gboolean
-cspi_init_relation_type_table (AccessibleRelationType *relation_type_table)
-{
-  int i;
-  for (i = 0; i < Accessibility_RELATION_LAST_DEFINED; ++i)
-    {
-      relation_type_table [i] = SPI_RELATION_NULL;
-    }
-  relation_type_table [Accessibility_RELATION_NULL] = SPI_RELATION_NULL;
-  relation_type_table [Accessibility_RELATION_LABEL_FOR] = SPI_RELATION_LABEL_FOR;
-  relation_type_table [Accessibility_RELATION_LABELLED_BY] = SPI_RELATION_LABELED_BY;
-  relation_type_table [Accessibility_RELATION_CONTROLLER_FOR] = SPI_RELATION_CONTROLLER_FOR;
-  relation_type_table [Accessibility_RELATION_CONTROLLED_BY] = SPI_RELATION_CONTROLLED_BY;
-  relation_type_table [Accessibility_RELATION_MEMBER_OF] = SPI_RELATION_MEMBER_OF;
-  relation_type_table [Accessibility_RELATION_TOOLTIP_FOR] = SPI_RELATION_NULL;
-  relation_type_table [Accessibility_RELATION_NODE_CHILD_OF] = SPI_RELATION_NODE_CHILD_OF;
-  relation_type_table [Accessibility_RELATION_EXTENDED] = SPI_RELATION_EXTENDED;
-  relation_type_table [Accessibility_RELATION_FLOWS_TO] = SPI_RELATION_FLOWS_TO;
-  relation_type_table [Accessibility_RELATION_FLOWS_FROM] = SPI_RELATION_FLOWS_FROM;
-  relation_type_table [Accessibility_RELATION_SUBWINDOW_OF] = SPI_RELATION_SUBWINDOW_OF;
-  relation_type_table [Accessibility_RELATION_EMBEDS] = SPI_RELATION_EMBEDS;
-  relation_type_table [Accessibility_RELATION_EMBEDDED_BY] = SPI_RELATION_EMBEDDED_BY;
-  relation_type_table [Accessibility_RELATION_POPUP_FOR] = SPI_RELATION_POPUP_FOR;
-  relation_type_table [Accessibility_RELATION_PARENT_WINDOW_OF] = SPI_RELATION_PARENT_WINDOW_OF;
-  relation_type_table [Accessibility_RELATION_DESCRIBED_BY] = SPI_RELATION_DESCRIBED_BY;
-  relation_type_table [Accessibility_RELATION_DESCRIPTION_FOR] = SPI_RELATION_DESCRIPTION_FOR;
-  return TRUE;
-}
-
-static AccessibleRelationType
-cspi_relation_type_from_spi_relation_type (Accessibility_RelationType type)
-{
-  /* array is sized according to IDL RelationType because IDL RelationTypes are the index */   
-  static AccessibleRelationType cspi_relation_type_table [Accessibility_RELATION_LAST_DEFINED];
-  static gboolean is_initialized = FALSE;
-  AccessibleRelationType cspi_type;
-  if (!is_initialized)
-    {
-      is_initialized = cspi_init_relation_type_table (cspi_relation_type_table);           
-    }
-  if (type >= 0 && type < Accessibility_RELATION_LAST_DEFINED)
-    {
-      cspi_type = cspi_relation_type_table [type];         
-    }
-  else
-    {
-      cspi_type = SPI_RELATION_NULL;
-    }
-  return cspi_type; 
-}
 /**
- * AccessibleRelation_getRelationType:
- * @obj: a pointer to the #AtspiAccessibleRelation object to query.
+ * atspi_accessible_get_text: (rename-to atspi_accessible_get_text_iface)
+ * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Get the type of relationship represented by an #AtspiAccessibleRelation.
+ * Gets the #AtspiTable interface for an #AtspiAccessible.
  *
- * Returns: an #AtspiAccessibleRelationType indicating the type of relation
- *         encapsulated in this #AtspiAccessibleRelation object.
+ * 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.
  **/
-AccessibleRelationType
-AccessibleRelation_getRelationType (AccessibleRelation *obj)
+AtspiText *
+atspi_accessible_get_text (AtspiAccessible *obj)
 {
-  cspi_return_val_if_fail (obj, SPI_RELATION_NULL);
-  return cspi_relation_type_from_spi_relation_type (obj->type);
+  return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
+          g_object_ref (ATSPI_TEXT (obj)) : NULL);
 }
 
 /**
- * AccessibleRelation_getNTargets:
- * @obj: a pointer to the #AtspiAccessibleRelation object to query.
+ * atspi_accessible_get_text_iface:
+ * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Get the number of objects which this relationship has as its
- *       target objects (the subject is the #AtspiAccessible from which this
- *       #AtspiAccessibleRelation originated).
+ * Gets the #AtspiTable interface for an #AtspiAccessible.
  *
- * Returns: a short integer indicating how many target objects which the
- *       originating #AtspiAccessible object has the #AtspiAccessibleRelation
- *       relationship with.
+ * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
+ *          NULL if @obj does not implement #AtspiText.
  **/
-int
-AccessibleRelation_getNTargets (AccessibleRelation *obj)
+AtspiText *
+atspi_accessible_get_text_iface (AtspiAccessible *obj)
 {
-  cspi_return_val_if_fail (obj, -1);
-  return obj->targets->len;
+  return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
+          g_object_ref (ATSPI_TEXT (obj)) : NULL);
 }
 
 /**
- * AccessibleRelation_getTarget:
- * @obj: a pointer to the #AtspiAccessibleRelation object to query.
- * @i: a (zero-index) integer indicating which (of possibly several) target is requested.
+ * atspi_accessible_get_value: (rename-to atspi_accessible_get_value_iface)
+ * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Get the @i-th target of a specified #AtspiAccessibleRelation relationship.
+ * Gets the #AtspiTable interface for an #AtspiAccessible.
  *
- * Returns: an #AtspiAccessible which is the @i-th object with which the
- *      originating #AtspiAccessible has relationship specified in the
- *      #AtspiAccessibleRelation object.
+ * 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.
  **/
-Accessible *
-AccessibleRelation_getTarget (AccessibleRelation *obj, int i)
+AtspiValue *
+atspi_accessible_get_value (AtspiAccessible *accessible)
 {
-  cspi_return_val_if_fail (obj, NULL);
-
-  if (i < 0 || i >= obj->targets->len) return NULL;
-  return cspi_object_add (
-                        g_array_index (obj->targets, Accessible *, i));
+  return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
+          g_object_ref (ATSPI_VALUE (accessible)) : NULL);
 }
 
 /**
- * AccessibleStateSet_ref:
- * @obj: a pointer to the #AtspiAccessibleStateSet object on which to operate.
+ * atspi_accessible_get_value_iface:
+ * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Increment the reference count for an #AtspiAccessibleStateSet object.
+ * 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.
  **/
-void
-AccessibleStateSet_ref (AccessibleStateSet *obj)
+AtspiValue *
+atspi_accessible_get_value_iface (AtspiAccessible *accessible)
 {
-  spi_state_set_cache_ref (obj);
+  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)
+{
+  gchar *dup = g_strdup (val);
+
+  if (dup)
+    g_array_append_val (array, dup);
 }
 
 /**
- * AccessibleStateSet_unref:
- * @obj: a pointer to the #AtspiAccessibleStateSet object on which to operate.
+ * atspi_accessible_get_interfaces:
+ * @obj: The #AtspiAccessible to query.
  *
- * Decrement the reference count for an #AtspiAccessibleStateSet object.
+ * A set of pointers to all interfaces supported by an #AtspiAccessible.
  *
+ * Returns: (element-type gchar*) (transfer full): A #GArray of strings
+ *          describing the interfaces supported by the object.  Interfaces are
+ *          denoted in short-hand (i.e. "Component", "Text" etc.).
  **/
-void
-AccessibleStateSet_unref (AccessibleStateSet *obj)
+GArray *
+atspi_accessible_get_interfaces (AtspiAccessible *obj)
 {
-  spi_state_set_cache_unref (obj);
+  GArray *ret = g_array_new (TRUE, TRUE, sizeof (gchar *));
+
+  g_return_val_if_fail (obj != NULL, NULL);
+
+  append_const_val (ret, "Accessible");
+  if (atspi_accessible_is_action (obj))
+    append_const_val (ret, "Action");
+  if (atspi_accessible_is_collection (obj))
+    append_const_val (ret, "Collection");
+  if (atspi_accessible_is_component (obj))
+    append_const_val (ret, "Component");
+  if (atspi_accessible_is_document (obj))
+    append_const_val (ret, "Document");
+  if (atspi_accessible_is_editable_text (obj))
+    append_const_val (ret, "EditableText");
+  if (atspi_accessible_is_hypertext (obj))
+    append_const_val (ret, "Hypertext");
+  if (atspi_accessible_is_hyperlink (obj))
+    append_const_val (ret, "Hyperlink");
+  if (atspi_accessible_is_image (obj))
+    append_const_val (ret, "Image");
+  if (atspi_accessible_is_selection (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))
+    append_const_val (ret, "Value");
+
+  return ret;
 }
 
-static Accessibility_StateType
-spi_state_to_dbus (AccessibleState state)
+AtspiAccessible *
+_atspi_accessible_new (AtspiApplication *app, const gchar *path)
 {
-#define MAP_STATE(a) \
-  case SPI_STATE_##a: \
-    return Accessibility_STATE_##a
+  AtspiAccessible *accessible;
 
-  switch (state)
-    {
-      MAP_STATE (INVALID);
-      MAP_STATE (ACTIVE);
-      MAP_STATE (ARMED);
-      MAP_STATE (BUSY);
-      MAP_STATE (CHECKED);
-      MAP_STATE (DEFUNCT);
-      MAP_STATE (EDITABLE);
-      MAP_STATE (ENABLED);
-      MAP_STATE (EXPANDABLE);
-      MAP_STATE (EXPANDED);
-      MAP_STATE (FOCUSABLE);
-      MAP_STATE (FOCUSED);
-      MAP_STATE (HORIZONTAL);
-      MAP_STATE (ICONIFIED);
-      MAP_STATE (MODAL);
-      MAP_STATE (MULTI_LINE);
-      MAP_STATE (MULTISELECTABLE);
-      MAP_STATE (OPAQUE);
-      MAP_STATE (PRESSED);
-      MAP_STATE (RESIZABLE);
-      MAP_STATE (SELECTABLE);
-      MAP_STATE (SELECTED);
-      MAP_STATE (SENSITIVE);
-      MAP_STATE (SHOWING);
-      MAP_STATE (SINGLE_LINE);
-      MAP_STATE (STALE);
-      MAP_STATE (TRANSIENT);
-      MAP_STATE (VERTICAL);
-      MAP_STATE (VISIBLE);
-      MAP_STATE (MANAGES_DESCENDANTS);
-      MAP_STATE (INDETERMINATE);
-      MAP_STATE (TRUNCATED);
-      MAP_STATE (REQUIRED);
-      MAP_STATE (INVALID_ENTRY);
-      MAP_STATE (SUPPORTS_AUTOCOMPLETION);
-      MAP_STATE (SELECTABLE_TEXT);
-      MAP_STATE (IS_DEFAULT);
-      MAP_STATE (VISITED);
-    default:
-      return Accessibility_STATE_INVALID;
-  }
-#undef MAP_STATE
-}            
+  accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
+  g_return_val_if_fail (accessible != NULL, NULL);
 
-/**
- * AccessibleStateSet_contains:
- * @obj: a pointer to the #AtspiAccessibleStateSet object on which to operate.
- * @state: an #AtspiAccessibleState for which the specified #AtspiAccessibleStateSet
- *       will be queried.
- *
- * Determine whether a given #AtspiAccessibleStateSet includes a given state; that is,
- *       whether @state is true for the stateset in question.
- *
- * Returns: #TRUE if @state is true/included in the given #AtspiAccessibleStateSet,
- *          otherwise #FALSE.
- *
- **/
-gboolean
-AccessibleStateSet_contains (AccessibleStateSet *obj,
-                            AccessibleState state)
-{
-  return spi_state_set_cache_contains (obj, spi_state_to_dbus (state));
+  accessible->parent.app = g_object_ref (app);
+  accessible->parent.path = g_strdup (path);
+
+  return accessible;
 }
 
 /**
- * AccessibleStateSet_add:
- * @obj: a pointer to the #AtspiAccessibleStateSet object on which to operate.
- * @state: an #AtspiAccessibleState to be added to the specified #AtspiAccessibleStateSet
- *
- * Add a particular #AtspiAccessibleState to an #AtspiAccessibleStateSet (i.e. set the
- *       given state to #TRUE in the stateset.
- *
+ * atspi_accessible_set_cache_mask:
+ * @accessible: The #AtspiAccessible to operate on.  Must be the desktop or
+ *             the root of an application.
+ * @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,
+ * then the desktop's cache flag will be used.
+ * If the desktop's cache flag is also undefined, then all possible data will
+ * be cached.
+ * This function is intended to work around bugs in toolkits where the proper
+ * events are not raised / to aid in testing for such bugs.
  **/
 void
-AccessibleStateSet_add (AccessibleStateSet *obj,
-                       AccessibleState state)
+atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask)
 {
-  spi_state_set_cache_add (obj, spi_state_to_dbus (state));
+  g_return_if_fail (accessible != NULL);
+  g_return_if_fail (accessible->parent.app != NULL);
+  g_return_if_fail (accessible == accessible->parent.app->root);
+  accessible->parent.app->cache = mask;
+  enable_caching = TRUE;
 }
 
 /**
- * AccessibleStateSet_remove:
- * @obj: a pointer to the #AtspiAccessibleStateSet object on which to operate.
- * @state: an #AtspiAccessibleState to be removed from the specified #AtspiAccessibleStateSet
- *
- * Remove a particular #AtspiAccessibleState to an #AtspiAccessibleStateSet (i.e. set the
- *       given state to #FALSE in the stateset.)
+ * atspi_accessible_clear_cache:
+ * @accessible: The #AtspiAccessible whose cache to clear.
  *
- **/
+ * Clears the cached information for the given accessible and all of its
+ * descendants.
+ */
 void
-AccessibleStateSet_remove (AccessibleStateSet *obj,
-                          AccessibleState state)
+atspi_accessible_clear_cache (AtspiAccessible *accessible)
 {
-  spi_state_set_cache_remove (obj, spi_state_to_dbus (state));
+  GList *l;
+
+  if (accessible)
+  {
+    accessible->cached_properties = ATSPI_CACHE_NONE;
+    for (l = accessible->children; l; l = l->next)
+      atspi_accessible_clear_cache (l->data);
+  }
 }
 
 /**
- * AccessibleStateSet_equals:
- * @obj: a pointer to the first #AtspiAccessibleStateSet object on which to operate.
- * @obj2: a pointer to the second #AtspiAccessibleStateSet object on which to operate.
- *
- * Determine whether two instances of #AtspiAccessibleStateSet are equivalent (i.e.
- *         consist of the same #AtspiAccessibleStates).  Useful for checking multiple
- *         state variables at once; construct the target state then compare against it.
- *
- * @see AccessibleStateSet_compare().
+ * atspi_accessible_get_process_id:
+ * @accessible: The #AtspiAccessible to query.
+ * @error: a pointer to a %NULL #GError pointer
  *
- * Returns: #TRUE if the two #AtspiAccessibleStateSets are equivalent,
- *          otherwise #FALSE.
+ * 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 undetermined value if @error is set.
  **/
-gboolean
-AccessibleStateSet_equals (AccessibleStateSet *obj,
-                           AccessibleStateSet *obj2)
+guint
+atspi_accessible_get_process_id (AtspiAccessible *accessible, GError **error)
 {
-  gboolean   eq;
-  AtkStateSet *cmp;
+  DBusMessage *message, *reply;
+  DBusConnection *bus = _atspi_bus ();
+  dbus_uint32_t pid = -1;
+  DBusError d_error;
 
-  if (obj == obj2)
+  if (!accessible->parent.app || !accessible->parent.app->bus_name)
     {
-      return TRUE;
+      g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
+      return -1;
     }
 
-  cmp = spi_state_set_cache_xor (obj, obj2);
-  eq = spi_state_set_cache_is_empty (cmp);
-  spi_state_set_cache_unref (cmp);
-
-  return eq;
-}
-
-/**
- * AccessibleStateSet_compare:
- * @obj: a pointer to the first #AtspiAccessibleStateSet object on which to operate.
- * @obj2: a pointer to the second #AtspiAccessibleStateSet object on which to operate.
- *
- * Determine the differences between two instances of #AtspiAccessibleStateSet.
- * Not Yet Implemented.
- *.
- * @see AccessibleStateSet_equals().
- *
- * Returns: an #AtspiAccessibleStateSet object containing all states contained on one of
- *          the two sets but not the other.
- *
- **/
-AccessibleStateSet *
-AccessibleStateSet_compare (AccessibleStateSet *obj,
-                            AccessibleStateSet *obj2)
-{
-  return spi_state_set_cache_xor (obj, obj2);
-}
-
-/**
- * AccessibleStateSet_isEmpty:
- * @obj: a pointer to the #AtspiAccessibleStateSet object on which to operate.
- *
- * Determine whether a given #AtspiAccessibleStateSet is the empty set.
- *
- * Returns: #TRUE if the given #AtspiAccessibleStateSet contains no (true) states,
- *          otherwise #FALSE.
- *
- **/
-gboolean
-AccessibleStateSet_isEmpty (AccessibleStateSet *obj)
-{
-  return spi_state_set_cache_is_empty (obj);
+  message = dbus_message_new_method_call ("org.freedesktop.DBus",
+                                          "/org/freedesktop/DBus",
+                                          "org.freedesktop.DBus",
+                                          "GetConnectionUnixProcessID");
+  dbus_message_append_args (message, DBUS_TYPE_STRING,
+                            &accessible->parent.app->bus_name,
+                            DBUS_TYPE_INVALID);
+  dbus_error_init (&d_error);
+  reply = dbus_connection_send_with_reply_and_block (bus, message, -1, &d_error);
+  dbus_message_unref (message);
+  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_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
+      dbus_error_free (&d_error);
+    }
+  return pid;
 }
-#endif
 
-gboolean
-_atspi_accessible_is_a (AtspiAccessible *accessible,
-                     const char *interface_name)
+AtspiCache
+_atspi_accessible_get_cache_mask (AtspiAccessible *accessible)
 {
-  int n;
+  AtspiCache mask;
 
-  if (accessible == NULL)
-    {
-      return FALSE;
-    }
+  if (!accessible->parent.app)
+    return ATSPI_CACHE_NONE;
 
-  if (!(accessible->cached_properties & ATSPI_CACHE_INTERFACES))
+ mask = accessible->parent.app->cache;
+  if (mask == ATSPI_CACHE_UNDEFINED &&
+      accessible->parent.app->root &&
+      accessible->parent.app->root->accessible_parent)
   {
-    DBusMessage *reply;
-    DBusMessageIter iter;
-    reply = _atspi_dbus_call_partial (accessible, atspi_interface_accessible,
-                                      "GetInterfaces", NULL, "");
-    _ATSPI_DBUS_CHECK_SIG (reply, "as", FALSE);
-    dbus_message_iter_init (reply, &iter);
-    _atspi_dbus_set_interfaces (accessible, &iter);
-    dbus_message_unref (reply);
+    AtspiAccessible *desktop = atspi_get_desktop (0);
+    mask = desktop->parent.app->cache;
+    g_object_unref (desktop);
   }
 
-  n = _atspi_get_iface_num (interface_name);
-  if (n == -1) return FALSE;
-  return (gboolean) ((accessible->interfaces & (1 << n))? TRUE: FALSE);
+  if (mask == ATSPI_CACHE_UNDEFINED)
+    mask = ATSPI_CACHE_DEFAULT;
+
+  return mask;
 }
 
-static void
-append_const_val (GArray *array, const gchar *val)
+gboolean
+_atspi_accessible_test_cache (AtspiAccessible *accessible, AtspiCache flag)
 {
-  gchar *dup = g_strdup (val);
+  AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
+  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 ||
+                          flag == ATSPI_CACHE_INTERFACES) &&
+          !atspi_no_cache);
+}
 
-  if (dup)
-    g_array_append_val (array, dup);
+void
+_atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag)
+{
+  AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
+
+  accessible->cached_properties |= flag & mask;
 }
 
 /**
- * atspi_accessible_get_interfaces:
+ * atspi_accessible_get_locale:
+ * @accessible: an #AtspiAccessible
  *
- * #obj: The #AtspiAccessible to query.
+ * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
+ * of @accessible.
  *
- * Returns: (element-type gchar*) (transfer full): A #GArray of strings
- *          describing the interfaces supported by the object.  Interfaces are
- *          denoted in short-hand (ie, "Component", "Text", etc.)
+ * Since: 2.7.91
+ *
+ * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
+ *          locale of @accessible.
  **/
-GArray *
-atspi_accessible_get_interfaces (AtspiAccessible *obj)
+const gchar*
+atspi_accessible_get_object_locale (AtspiAccessible *accessible, GError **error)
 {
-  GArray *ret = g_array_new (TRUE, TRUE, sizeof (gchar *));
+  gchar *locale;
 
-  if (!ret)
-    return NULL;
-
-  g_return_val_if_fail (obj != NULL, NULL);
-
-  if (atspi_accessible_is_action (obj))
-    append_const_val (ret, "Action");
-  if (atspi_accessible_is_collection (obj))
-    append_const_val (ret, "Collection");
-  if (atspi_accessible_is_component (obj))
-    append_const_val (ret, "Component");
-  if (atspi_accessible_is_document (obj))
-    append_const_val (ret, "Document");
-  if (atspi_accessible_is_editable_text (obj))
-    append_const_val (ret, "EditableText");
-  if (atspi_accessible_is_hypertext (obj))
-    append_const_val (ret, "Hypertext");
-  if (atspi_accessible_is_image (obj))
-    append_const_val (ret, "Image");
-  if (atspi_accessible_is_selection (obj))
-    append_const_val (ret, "Selection");
-  if (atspi_accessible_is_table (obj))
-    append_const_val (ret, "Table");
-  if (atspi_accessible_is_text (obj))
-    append_const_val (ret, "Text");
-  if (atspi_accessible_is_value (obj))
-    append_const_val (ret, "Value");
+  g_return_val_if_fail (accessible != NULL, NULL);
 
-  return ret;
+  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;
 }
 
-/* TODO: Move to a finalizer */
-static void
-cspi_object_destroyed (AtspiAccessible *accessible)
+void
+free_value (gpointer data)
 {
-  gboolean cached;
-  AtspiEvent e;
+  GValue *value = data;
 
-  /* TODO: Only fire if object not already marked defunct */
-  memset (&e, 0, sizeof (e));
-  e.type = "object:state-change:defunct";
-  e.source = accessible;
-  e.detail1 = 1;
-  e.detail2 = 0;
-  _atspi_send_event (&e);
+  g_value_unset (value);
+  g_free (value);
+}
 
-    g_free (accessible->parent.path);
+GHashTable *
+_atspi_accessible_ref_cache (AtspiAccessible *accessible)
+{
+  AtspiAccessiblePrivate *priv = accessible->priv;
 
-    if (accessible->states)
-      g_object_unref (accessible->states);
-    g_free (accessible->description);
-    g_free (accessible->name);
+  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;
 }
 
-AtspiAccessible *
-atspi_accessible_new (AtspiApplication *app, const gchar *path)
+void
+_atspi_accessible_unref_cache (AtspiAccessible *accessible)
 {
-  AtspiAccessible *accessible;
-  
-  accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
-  g_return_val_if_fail (accessible != NULL, NULL);
-
-  accessible->parent.app = g_object_ref (app);
-  accessible->parent.path = g_strdup (path);
+  AtspiAccessiblePrivate *priv = accessible->priv;
 
-  return accessible;
+  if (priv->cache)
+  {
+    g_hash_table_unref (priv->cache);
+    if (--priv->cache_ref_count == 0)
+      priv->cache = NULL;
+  }
 }