Code style enforcement.
[platform/core/uifw/at-spi2-atk.git] / atk-adaptor / document-adaptor.c
index 91f6313..de83a0d 100644 (file)
 #include <atk/atk.h>
 #include <droute/droute.h>
 
-#include "spi-common/spi-dbus.h"
+#include "common/spi-dbus.h"
+
+#include "accessible-marshaller.h"
 
 static DBusMessage *
-impl_getLocale (DBusConnection *bus,
-                DBusMessage *message,
-                void *user_data)
+impl_GetLocale (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
   AtkDocument *document = (AtkDocument *) user_data;
   const gchar *lc;
@@ -45,14 +45,14 @@ impl_getLocale (DBusConnection *bus,
   if (reply)
     {
       dbus_message_append_args (reply, DBUS_TYPE_STRING, &lc,
-                               DBUS_TYPE_INVALID);
+                                DBUS_TYPE_INVALID);
     }
   return reply;
 }
 
 static DBusMessage *
-impl_getAttributeValue (DBusConnection * bus, DBusMessage * message,
-                       void *user_data)
+impl_GetAttributeValue (DBusConnection * bus, DBusMessage * message,
+                        void *user_data)
 {
   AtkDocument *document = (AtkDocument *) user_data;
   DBusError error;
@@ -66,7 +66,7 @@ impl_getAttributeValue (DBusConnection * bus, DBusMessage * message,
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_STRING, &attributename, DBUS_TYPE_INVALID))
     {
-      return SPI_DBUS_RETURN_ERROR (message, &error);
+      return droute_invalid_arguments_error (message);
     }
   atr = atk_document_get_attribute_value (document, attributename);
   if (!atr)
@@ -75,63 +75,47 @@ impl_getAttributeValue (DBusConnection * bus, DBusMessage * message,
   if (reply)
     {
       dbus_message_append_args (reply, DBUS_TYPE_STRING, &atr,
-                               DBUS_TYPE_INVALID);
+                                DBUS_TYPE_INVALID);
     }
   return reply;
 }
 
 static DBusMessage *
-impl_getAttributes (DBusConnection * bus, DBusMessage * message,
-                   void *user_data)
+impl_GetAttributes (DBusConnection * bus, DBusMessage * message,
+                    void *user_data)
 {
   AtkDocument *document = (AtkDocument *) 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_DOCUMENT (user_data),
                         droute_not_yet_handled_error (message));
 
   attributes = atk_document_get_attributes (document);
-  if (attributes)
-    n_attributes = g_slist_length (attributes);
-
-  retval = (char **) g_malloc (n_attributes * sizeof (char *));
 
-  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);
+      dbus_message_iter_init_append (reply, &iter);
+      spi_atk_append_attribute_set (&iter, attributes);
     }
-  for (i = 0; i < n_attributes; i++)
-    g_free (retval[i]);
-  g_free (retval);
+
+  if (attributes)
+    atk_attribute_set_free (attributes);
   return reply;
 }
 
 static DRouteMethod methods[] = {
-  {impl_getLocale, "getLocale"},
-  {impl_getAttributeValue, "getAttributeValue"},
-  {impl_getAttributes, "getAttributes"},
+  {impl_GetLocale, "GetLocale"},
+  {impl_GetAttributeValue, "GetAttributeValue"},
+  {impl_GetAttributes, "GetAttributes"},
   {NULL, NULL}
 };
 
 void
-spi_initialize_document (DRoutePath *path)
+spi_initialize_document (DRoutePath * path)
 {
   droute_path_add_interface (path,
-                             SPI_DBUS_INTERFACE_DOCUMENT,
-                             methods,
-                             NULL);
+                             SPI_DBUS_INTERFACE_DOCUMENT, methods, NULL);
 };