2008-11-28 Mike Gorse <mgorse@novell.com>
authorMike Gorse <mgorse@boston.site>
Fri, 28 Nov 2008 22:48:43 +0000 (16:48 -0600)
committerMike Gorse <mgorse@boston.site>
Fri, 28 Nov 2008 22:48:43 +0000 (16:48 -0600)
* atk-adaptor/tree.c, cspi/spi-accessible.c, cspi/spi-main.c,
  cspi/spi-private.h: Changes for caching state set.

atk-adaptor/tree.c
cspi/spi-accessible.c
cspi/spi-main.c
cspi/spi-private.h

index 8652f77..65528cf 100644 (file)
@@ -39,7 +39,7 @@ static const char *dumm = "/APath/1";
  * Marshals the given AtkObject into the provided D-Bus iterator.
  *
  * The object is marshalled including all its client side cache data.
- * The format of the strucuture is (ooaoassus).
+ * The format of the structure is (ooaoassusau).
  * This is used in the updateTree signal and the getTree method
  * of the org.freedesktop.atspi.Tree interface.
  */
@@ -50,6 +50,8 @@ append_accessible(gpointer ref, gpointer obj_data, gpointer iter)
   DBusMessageIter *iter_array;
   DBusMessageIter iter_struct, iter_sub_array;
   DRouteData *data;
+  dbus_int32_t *states;
+  int count;
 
   const char *name, *desc;
   int i;
@@ -130,6 +132,11 @@ append_accessible(gpointer ref, gpointer obj_data, gpointer iter)
 
       g_free(path);
     }      
+  spi_atk_state_to_dbus_array (obj, &states);
+      dbus_message_iter_open_container (&iter_struct, DBUS_TYPE_ARRAY, "u", &iter_sub_array);
+  for (count = 0; states[count]; count++)
+    dbus_message_iter_append_basic (&iter_sub_array, DBUS_TYPE_UINT32, &states[count]);
+      dbus_message_iter_close_container (&iter_struct, &iter_sub_array);
   dbus_message_iter_close_container (iter_array, &iter_struct);
 }
 
@@ -169,7 +176,7 @@ send_cache_update(gpointer d)
 
   dbus_message_iter_init_append (message, &iter);
 
-  dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "(ooaoassus)", &iter_array);
+  dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "(ooaoassusau)", &iter_array);
   atk_dbus_foreach_update_list(append_accessible, &iter_array);
   dbus_message_iter_close_container(&iter, &iter_array);
 
@@ -227,7 +234,7 @@ impl_getTree (DBusConnection *bus, DBusMessage *message, void *user_data)
   reply = dbus_message_new_method_return (message);
 
   dbus_message_iter_init_append (reply, &iter);
-  dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(ooaoassus)", &iter_array);
+  dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(ooaoassusau)", &iter_array);
   atk_dbus_foreach_registered(append_accessible, &iter_array);
   dbus_message_iter_close_container(&iter, &iter_array);
   return reply;
index 7e324fa..62aa594 100644 (file)
@@ -557,19 +557,7 @@ Accessible_getLocalizedRoleName (Accessible *obj)
 AccessibleStateSet *
 Accessible_getStateSet (Accessible *obj)
 {
-  GArray *state_bitflags;
-  AccessibleStateSet *retval;
-
-  cspi_return_val_if_fail (obj != NULL, NULL);
-
-  cspi_dbus_call (obj, spi_interface_accessible, "getStateSet", NULL, "=>au", &state_bitflags);
-  cspi_return_val_if_ev ("getState", NULL);
-
-  retval = spi_state_set_cache_new (state_bitflags);
-
-  g_array_free (state_bitflags, TRUE);
-
-  return retval;
+  return obj->states;
 }
 
 /**
index 4b0dd93..3485a5a 100644 (file)
@@ -218,6 +218,9 @@ cspi_object_unref_internal (Accessible *accessible, gboolean defunct)
     {
       g_free (accessible->v.path);
     }
+    spi_state_set_cache_unref (accessible->states);
+    g_free (accessible->description);
+    g_free (accessible->name);
     g_free(accessible);
   }
 }
@@ -319,6 +322,7 @@ typedef struct
   char *name;
   dbus_uint32_t role;
   char *description;
+  GArray *state_bitflags;
 } CACHE_ADDITION;
 
 /* Update the cache with added/modified objects and free the array */
@@ -370,8 +374,10 @@ handle_additions (CSpiApplication*app, GArray *additions)
     a->role = ca->role;
     if (a->description) g_free (a->description);
     a->description = ca->description;
+    a->states = spi_state_set_cache_new (ca->state_bitflags);
     g_array_free (ca->interfaces, TRUE);
     g_array_free (ca->children, TRUE);
+    g_array_free (ca->state_bitflags, TRUE);
     /* This is a bit of a hack since ref_accessible sets ref_count to 2
      * for a new object, one of the refs being for the cache */
     cspi_object_unref (a);
@@ -514,7 +520,7 @@ ref_accessible_desktop (CSpiApplication *app)
     CSpiApplication *app = cspi_get_application (app_name);
     additions = NULL;
     dbus_error_init (&error);
-    dbind_connection_method_call (bus, app_name, "/org/freedesktop/atspi/tree", spi_interface_tree, "getTree", &error, "=>a(ooaoassus)", &additions);
+    dbind_connection_method_call (bus, app_name, "/org/freedesktop/atspi/tree", spi_interface_tree, "getTree", &error, "=>a(ooaoassusau)", &additions);
     if (error.message)
     {
       g_warning ("getTree (%s): %s", app_name, error.message);
index 57df3fc..c7197cb 100644 (file)
 
 /* Private internal implementation details of at-spi. */
 
-#include <spi-common/spi-dbus.h>
-#include <cspi/spi.h>
-#include <string.h>
+#include "spi-common/spi-dbus.h"
+#include "cspi/spi.h"
+#include "string.h"
 #include "cspi/cspi-lowlevel.h"
 #include "cspi/spi-listener.h"
 #include "dbind/dbind.h"
 #include <glib-object.h>
+#include "spi-common/spi-stateset.h"
 
 typedef struct _CSpiApplication CSpiApplication;
 struct _CSpiApplication
@@ -56,11 +57,7 @@ struct _Accessible {
   gint interfaces : 24;
   char *name;
   char *description;
-};
-
-struct _AccessibleStateSet {
-       guint   ref_count;
-       GArray *states;
+  AtkStateSet *states;
 };
 
 #define SPI_INTERNAL_EVENT_MAGIC 0xc3