Merge branch 'enum-types'
[platform/upstream/at-spi2-core.git] / atspi / atspi-accessible.c
index 9461ece..fc2b48f 100644 (file)
@@ -25,6 +25,9 @@
 #include "atspi-private.h"
 #include <string.h>
 
+static gboolean enable_caching = FALSE;
+static guint quark_locale;
+
 static void
 atspi_action_interface_init (AtspiAction *action)
 {
@@ -102,7 +105,8 @@ atspi_accessible_init (AtspiAccessible *accessible)
 {
 #ifdef DEBUG_REF_COUNTS
   accessible_count++;
-  printf("at-spi: init: %d objects\n", accessible_count);
+  g_hash_table_insert (_atspi_get_live_refs (), accessible, NULL);
+  g_print("at-spi: init: %d objects\n", accessible_count);
 #endif
 }
 
@@ -112,10 +116,12 @@ 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-change:defunct";
+  e.type = "object:state-changed:defunct";
   e.source = accessible;
   e.detail1 = 1;
   e.detail2 = 0;
@@ -147,6 +153,20 @@ atspi_accessible_dispose (GObject *object)
     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);
 }
 
@@ -162,6 +182,7 @@ atspi_accessible_finalize (GObject *object)
 
 #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
 
@@ -176,17 +197,18 @@ atspi_accessible_class_init (AtspiAccessibleClass *klass)
 
   object_class->dispose = atspi_accessible_dispose;
   object_class->finalize = atspi_accessible_finalize;
-}
 
+  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)
@@ -206,10 +228,10 @@ atspi_accessible_get_name (AtspiAccessible *obj, GError **error)
  * 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)
@@ -233,7 +255,7 @@ 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
@@ -281,10 +303,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
@@ -309,10 +331,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,
@@ -339,13 +361,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
@@ -355,13 +378,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 (!_atspi_accessible_test_cache (obj->accessible_parent,
+  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;
   }
 
@@ -385,11 +411,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 AtspiAccessible*) (transfer full): a #GArray of
+ *          #AtspiRelation pointers or NULL on exception.
  **/
 GArray *
 atspi_accessible_get_relation_set (AtspiAccessible *obj, GError **error)
@@ -423,10 +449,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
@@ -451,11 +477,12 @@ 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 *
@@ -478,9 +505,7 @@ atspi_accessible_get_role_name (AtspiAccessible *obj, GError **error)
     }
 
   if (retval)
-    return g_strdup (retval);
-
-  g_return_val_if_fail (obj != NULL, NULL);
+    return _atspi_name_compat (g_strdup (retval));
 
   _atspi_dbus_call (obj, atspi_interface_accessible, "GetRoleName", error, "=>s", &retval);
 
@@ -494,11 +519,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 *
@@ -528,18 +555,18 @@ defunct_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)
 {
+  /* 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;
@@ -560,13 +587,13 @@ 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)
@@ -600,7 +627,7 @@ add_to_attribute_array (gpointer key, gpointer value, gpointer data)
  * 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.
@@ -634,9 +661,9 @@ atspi_accessible_get_attributes_as_array (AtspiAccessible *obj, GError **error)
  * 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 *
@@ -655,6 +682,7 @@ atspi_accessible_get_application (AtspiAccessible *obj, GError **error)
       if (root)
       {
         g_object_unref (obj);
+        g_object_unref (parent);
         if (atspi_accessible_get_role (root, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
         {
           g_object_unref (root);
@@ -665,7 +693,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;
   }
@@ -677,11 +709,10 @@ atspi_accessible_get_application (AtspiAccessible *obj, GError **error)
  * 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)
@@ -702,11 +733,10 @@ atspi_accessible_get_toolkit_name (AtspiAccessible *obj, GError **error)
  * 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)
@@ -727,12 +757,11 @@ atspi_accessible_get_toolkit_version (AtspiAccessible *obj, GError **error)
  * atspi_accessible_get_atspi_version:
  * @obj: a pointer to the #AtspiAccessible object on which to operate.
  *
- * Get the AT-SPI IPC specification version supported by the application
+ * 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 ersion for the #AtspiAccessible object.
- * or NULL on exception
+ * 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)
@@ -750,14 +779,14 @@ atspi_accessible_get_atspi_version (AtspiAccessible *obj, GError **error)
 }
 
 /**
- * atspi_accessible_get_toolkit_version:
+ * atspi_accessible_get_id:
  * @obj: a pointer to the #AtspiAccessible object on which to operate.
  *
- * Get the application id for a #AtspiAccessible object.
+ * Gets the application id for a #AtspiAccessible object.
  * Only works on application root objects.
  *
- * Returns: a gint indicating the id for the #AtspiAccessible object.
- * or -1 on exception
+ * Returns: a positive #gint indicating the id for the #AtspiAccessible object 
+ * or -1 on exception.
  **/
 gint
 atspi_accessible_get_id (AtspiAccessible *obj, GError **error)
@@ -807,7 +836,8 @@ _atspi_accessible_is_a (AtspiAccessible *accessible,
  * atspi_accessible_is_action:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Query whether the specified #AtspiAccessible implements #AtspiAction.
+ * Query whether the specified #AtspiAccessible implements the 
+ * #AtspiAction interface.
  *
  * Returns: #TRUE if @obj implements the #AtspiAction interface,
  *          #FALSE otherwise.
@@ -823,7 +853,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.
@@ -836,10 +867,13 @@ atspi_accessible_is_application (AtspiAccessible *obj)
 }
 
 /**                      
- * 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
@@ -869,7 +903,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.
@@ -885,7 +920,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.
@@ -901,7 +937,8 @@ atspi_accessible_is_editable_text (AtspiAccessible *obj)
  * 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.
@@ -917,7 +954,8 @@ 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 #AtspiHyperlink.
+ * Query whether the specified #AtspiAccessible implements the 
+ * #AtspiHyperlink interface.
  *
  * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
  *          #FALSE otherwise.
@@ -933,7 +971,8 @@ atspi_accessible_is_hyperlink (AtspiAccessible *obj)
  * 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.
@@ -949,7 +988,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.
@@ -965,7 +1005,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.
@@ -981,8 +1022,8 @@ atspi_accessible_is_table (AtspiAccessible *obj)
  * 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.
@@ -1003,7 +1044,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.
@@ -1019,7 +1061,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.
@@ -1035,7 +1078,7 @@ atspi_accessible_is_value (AtspiAccessible *obj)
  * atspi_accessible_get_action:
  * @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.
@@ -1051,7 +1094,7 @@ atspi_accessible_get_action (AtspiAccessible *accessible)
  * atspi_accessible_get_collection:
  * @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.
@@ -1067,7 +1110,7 @@ atspi_accessible_get_collection (AtspiAccessible *accessible)
  * atspi_accessible_get_component:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Get the #AtspiComponent interface for an #AtspiAccessible.
+ * 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.
@@ -1083,7 +1126,7 @@ atspi_accessible_get_component (AtspiAccessible *obj)
  * atspi_accessible_get_document:
  * @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.
@@ -1099,7 +1142,7 @@ atspi_accessible_get_document (AtspiAccessible *accessible)
  * atspi_accessible_get_editable_text:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Get the #AtspiEditableText interface for an #AtspiAccessible.
+ * 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.
@@ -1115,8 +1158,7 @@ atspi_accessible_get_editable_text (AtspiAccessible *accessible)
  * atspi_accessible_get_hyperlink:
  * @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.
@@ -1125,14 +1167,14 @@ 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:
  * @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.
@@ -1148,7 +1190,7 @@ atspi_accessible_get_hypertext (AtspiAccessible *accessible)
  * atspi_accessible_get_image:
  * @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.
@@ -1164,7 +1206,7 @@ atspi_accessible_get_image (AtspiAccessible *accessible)
  * atspi_accessible_get_selection:
  * @obj: a pointer to the #AtspiAccessible instance to query.
  *
- * Get the #AtspiSelection interface for an #AtspiAccessible.
+ * 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.
@@ -1181,7 +1223,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.
@@ -1198,7 +1240,7 @@ atspi_accessible_get_streamable_content (AtspiAccessible *accessible)
  * atspi_accessible_get_table:
  * @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.
@@ -1214,7 +1256,7 @@ atspi_accessible_get_table (AtspiAccessible *obj)
  * atspi_accessible_get_text:
  * @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
  *          NULL if @obj does not implement #AtspiText.
@@ -1230,7 +1272,7 @@ atspi_accessible_get_text (AtspiAccessible *obj)
  * atspi_accessible_get_value:
  * @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 #AtspiValue interface instance, or
  *          NULL if @obj does not implement #AtspiValue.
@@ -1253,12 +1295,13 @@ append_const_val (GArray *array, const gchar *val)
 
 /**
  * atspi_accessible_get_interfaces:
+ * @obj: The #AtspiAccessible to query.
  *
- * #obj: The #AtspiAccessible to query.
+ * 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 (ie, "Component", "Text", etc.)
+ *          denoted in short-hand (i.e. "Component", "Text" etc.).
  **/
 GArray *
 atspi_accessible_get_interfaces (AtspiAccessible *obj)
@@ -1296,8 +1339,8 @@ atspi_accessible_get_interfaces (AtspiAccessible *obj)
   return ret;
 }
 
-AtspiAccessible *
-atspi_accessible_new (AtspiApplication *app, const gchar *path)
+AtspiAccessible * 
+_atspi_accessible_new (AtspiApplication *app, const gchar *path)
 {
   AtspiAccessible *accessible;
   
@@ -1312,7 +1355,6 @@ 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: An #AtspiCache specifying a bit mask of the types of data to cache.
@@ -1332,6 +1374,7 @@ atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask)
   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;
 }
 
 /**
@@ -1354,6 +1397,47 @@ atspi_accessible_clear_cache (AtspiAccessible *accessible)
   }
 }
 
+/**
+ * atspi_accessible_get_process_id:
+ * @accessible: The #AtspiAccessible to query.
+ *
+ * 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.
+ **/
+guint
+atspi_accessible_get_process_id (AtspiAccessible *accessible, GError **error)
+{
+  DBusMessage *message, *reply;
+  DBusConnection *bus = _atspi_bus ();
+  dbus_uint32_t pid = -1;
+  DBusError d_error;
+
+  if (!accessible->parent.app || !accessible->parent.app->bus_name)
+    return -1;
+
+  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);
+  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);
+      dbus_error_free (&d_error);
+    }
+  return pid;
+}
+
 AtspiCache
 _atspi_accessible_get_cache_mask (AtspiAccessible *accessible)
 {
@@ -1383,7 +1467,10 @@ _atspi_accessible_test_cache (AtspiAccessible *accessible, AtspiCache flag)
 {
   AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
   AtspiCache result = accessible->cached_properties & mask & flag;
-  return (result != 0 && atspi_main_loop && !atspi_no_cache);
+  if (accessible->states && atspi_state_set_contains (accessible->states, ATSPI_STATE_TRANSIENT))
+    return FALSE;
+  return (result != 0 && (atspi_main_loop || enable_caching) &&
+          !atspi_no_cache);
 }
 
 void
@@ -1393,3 +1480,35 @@ _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;
+}