2009-07-06 Mark Doffman <mark.doffman@codethink.co.uk>
[platform/core/uifw/at-spi2-atk.git] / atk-adaptor / accessible-adaptor.c
index d93a57f..4f03140 100644 (file)
@@ -25,7 +25,7 @@
 #include <atk/atk.h>
 #include <droute/droute.h>
 
-#include "spi-common/spi-dbus.h"
+#include "common/spi-dbus.h"
 #include "accessible-marshaller.h"
 #include "accessible-register.h"
 
@@ -432,7 +432,7 @@ impl_getRole (DBusConnection *bus, DBusMessage *message, void *user_data)
 static char *
 impl_get_role_str (void *datum)
 {
-  g_assert (ATK_IS_OBJECT (datum));
+  g_return_val_if_fail (ATK_IS_OBJECT (datum), g_strdup (""));
   return g_strdup_printf ("%d",
                          spi_accessible_role_from_atk_role
                          (atk_object_get_role ((AtkObject *) datum)));
@@ -517,37 +517,22 @@ impl_getAttributes (DBusConnection *bus,
 {
   AtkObject *object = (AtkObject *) user_data;
   DBusMessage *reply;
+
   AtkAttributeSet *attributes;
-  AtkAttribute *attr = NULL;
-  char **retval;
-  gint n_attributes = 0;
-  gint i;
+  DBusMessageIter iter;
 
   g_return_val_if_fail (ATK_IS_OBJECT (user_data),
                         droute_not_yet_handled_error (message));
 
   attributes = atk_object_get_attributes (object);
-  if (attributes)
-    n_attributes = g_slist_length (attributes);
 
-  retval = (char **) g_malloc (n_attributes * sizeof (char *));
+  reply = dbus_message_new_method_return (message);
+  dbus_message_iter_init_append (reply, &iter);
+  spi_atk_append_attribute_set (&iter, attributes);
 
-  for (i = 0; i < n_attributes; ++i)
-    {
-      attr = g_slist_nth_data (attributes, i);
-      retval[i] = g_strconcat (attr->name, ":", attr->value, NULL);
-    }
   if (attributes)
     atk_attribute_set_free (attributes);
-  reply = dbus_message_new_method_return (message);
-  if (reply)
-    {
-      dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
-                               &retval, n_attributes, DBUS_TYPE_INVALID);
-    }
-  for (i = 0; i < n_attributes; i++)
-    g_free (retval[i]);
-  g_free (retval);
+
   return reply;
 }