Initial commit.
[platform/core/uifw/at-spi2-atk.git] / libspi / table.c
index 98c704c..3c7a213 100644 (file)
@@ -2,7 +2,9 @@
  * AT-SPI - Assistive Technology Service Provider Interface
  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
  *
- * Copyright 2001 Sun Microsystems Inc.
+ * Copyright 2008 Novell, Inc.
+ * Copyright 2001, 2002 Sun Microsystems Inc.,
+ * Copyright 2001, 2002 Ximian, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
  * Boston, MA 02111-1307, USA.
  */
 
-/*
- * component.c : bonobo wrapper for accessible component implementation
- *
- */
-#include <config.h>
-#include <bonobo/Bonobo.h>
-
-#include <stdio.h>
-
-/*
- * This pulls the CORBA definitions for the "Accessibility::Accessible" server
- */
-#include <libspi/Accessibility.h>
-
-/*
- * This pulls the definition of the Table bonobo object
- */
-#include "table.h"
+#include "accessible.h"
 
-/*
- * Static function declarations
- */
-
-static void
-table_class_init (TableClass *klass);
-static void
-table_init (Table *table);
-static void
-table_finalize (GObject *obj);
-static Accessibility_Accessible
-impl__get_caption (PortableServer_Servant _servant,
-                  CORBA_Environment * ev);
-static Accessibility_Accessible
-impl__get_summary (PortableServer_Servant _servant,
-                  CORBA_Environment * ev);
-static CORBA_long
-impl__get_nRows (PortableServer_Servant _servant,
-                CORBA_Environment * ev);
-static CORBA_long
-impl__get_nRows (PortableServer_Servant _servant,
-                CORBA_Environment * ev);
-static CORBA_long
-impl__get_nColumns (PortableServer_Servant _servant,
-                   CORBA_Environment * ev);
-static Accessibility_Accessible
-impl_getAccessibleAt (PortableServer_Servant _servant,
-                     const CORBA_long row,
-                     const CORBA_long column,
-                     CORBA_Environment * ev);
-static CORBA_long
-impl_getIndexAt (PortableServer_Servant _servant,
-                const CORBA_long row, const CORBA_long column,
-                CORBA_Environment * ev);
-static CORBA_long
-impl_getRowAtIndex (PortableServer_Servant _servant,
-                   const CORBA_long index,
-                   CORBA_Environment * ev);
-static CORBA_long
-impl_getColumnAtIndex (PortableServer_Servant _servant,
-                      const CORBA_long index,
-                      CORBA_Environment * ev);
-static CORBA_string
-impl_getRowDescription (PortableServer_Servant _servant,
-                       const CORBA_long row,
-                       CORBA_Environment * ev);
-static CORBA_string
-impl_getColumnDescription (PortableServer_Servant _servant,
-                          const CORBA_long column,
-                          CORBA_Environment * ev);
-static CORBA_long
-impl_getRowExtentAt (PortableServer_Servant _servant,
-                    const CORBA_long row,
-                    const CORBA_long column,
-                    CORBA_Environment * ev);
-static CORBA_long
-impl_getColumnExtentAt (PortableServer_Servant _servant,
-                       const CORBA_long row,
-                       const CORBA_long column,
-                       CORBA_Environment * ev);
-static Accessibility_Table
-impl_getRowHeader (PortableServer_Servant _servant,
-                  const CORBA_long row,
-                  CORBA_Environment * ev);
-static        Accessibility_Table
-impl_getColumnHeader (PortableServer_Servant _servant,
-                     const CORBA_long column,
-                     CORBA_Environment * ev);
-static Accessibility_LongSeq *
-impl_getSelectedRows (PortableServer_Servant _servant,
-                     CORBA_Environment * ev);
-static Accessibility_LongSeq *
-impl_getSelectedColumns (PortableServer_Servant _servant,
-                        CORBA_Environment * ev);
-static CORBA_boolean
-impl_isRowSelected (PortableServer_Servant _servant,
-                   const CORBA_long row,
-                   CORBA_Environment * ev);
-static CORBA_boolean
-impl_isColumnSelected (PortableServer_Servant _servant,
-                      const CORBA_long column,
-                      CORBA_Environment * ev);
-static CORBA_boolean
-impl_isSelected (PortableServer_Servant _servant,
-                const CORBA_long row,
-                const CORBA_long column,
-                CORBA_Environment * ev);
-
-
-static GObjectClass *parent_class;
-
-GType
-table_get_type (void)
-{
-  static GType type = 0;
-
-  if (!type) {
-    static const GTypeInfo tinfo = {
-      sizeof (TableClass),
-      (GBaseInitFunc) NULL,
-      (GBaseFinalizeFunc) NULL,
-      (GClassInitFunc) table_class_init,
-      (GClassFinalizeFunc) NULL,
-      NULL, /* class data */
-      sizeof (Table),
-      0, /* n preallocs */
-      (GInstanceInitFunc) table_init,
-                        NULL /* value table */
-    };
-
-    /*
-     * Bonobo_type_unique auto-generates a load of
-     * CORBA structures for us. All derived types must
-     * use bonobo_type_unique.
-     */
-    type = bonobo_type_unique (
-                              BONOBO_OBJECT_TYPE,
-                              POA_Accessibility_Table__init,
-                              NULL,
-                              G_STRUCT_OFFSET (TableClass, epv),
-                              &tinfo,
-                              "AccessibleTable");
-  }
-
-  return type;
-}
-
-static void
-table_class_init (TableClass *klass)
-{
-  GObjectClass * object_class = (GObjectClass *) klass;
-  POA_Accessibility_Table__epv *epv = &klass->epv;
-  parent_class = g_type_class_peek_parent (klass);
-
-  object_class->finalize = table_finalize;
-
-
-  /* Initialize epv table */
-
-  epv->_get_caption = impl__get_caption;
-  epv->_get_summary = impl__get_summary;
-  epv->_get_nRows = impl__get_nRows;
-  epv->_get_nColumns = impl__get_nColumns;
-  epv->getAccessibleAt = impl_getAccessibleAt;
-  epv->getIndexAt = impl_getIndexAt;
-  epv->getRowAtIndex = impl_getRowAtIndex;
-  epv->getColumnAtIndex = impl_getColumnAtIndex;
-  epv->getRowDescription = impl_getRowDescription;
-  epv->getColumnDescription = impl_getColumnDescription;
-  epv->getRowExtentAt = impl_getRowExtentAt;
-  epv->getColumnExtentAt = impl_getColumnExtentAt;
-  epv->getRowHeader = impl_getRowHeader;
-  epv->getColumnHeader = impl_getColumnHeader;
-  epv->getSelectedRows = impl_getSelectedRows;
-  epv->getSelectedColumns = impl_getSelectedColumns;
-  epv->isRowSelected = impl_isRowSelected;
-  epv->isColumnSelected = impl_isColumnSelected;
-  epv->isSelected = impl_isSelected;
+static AtkTable *
+get_table (DBusMessage * message)
+{
+  AtkObject *obj = spi_dbus_get_object (dbus_message_get_path (message));
+  if (!obj)
+    return NULL;
+  return ATK_TABLE (obj);
 }
 
-static void
-table_init (Table *table)
+static AtkTable *
+get_table_from_path (const char *path, void *user_data)
 {
+  AtkObject *obj = spi_dbus_get_object (path);
+  if (!obj)
+    return NULL;
+  return ATK_TABLE (obj);
 }
 
-static void
-table_finalize (GObject *obj)
+static dbus_bool_t
+impl_get_nRows (const char *path, DBusMessageIter * iter, void *user_data)
 {
-  Table *table = TABLE (obj);
-  table->atk_table = NULL;
-  parent_class->finalize (obj);
+  AtkTable *table = get_table_from_path (path, user_data);
+  if (!table)
+    return FALSE;
+  return droute_return_v_int32 (iter, atk_table_get_n_rows (table));
 }
 
-Table *
-table_new (AtkTable *table)
+static char *
+impl_get_nRows_str (void *datum)
 {
-  Table *new_table =
-    TABLE(g_object_new (TABLE_TYPE, NULL));
-  new_table->atk_table = table;
-  return new_table;
+  g_assert (ATK_IS_TABLE (datum));
+  return g_strdup_printf ("%d", atk_table_get_n_rows ((AtkTable *) datum));
 }
 
-
-
-static Accessibility_Accessible
-impl__get_caption (PortableServer_Servant _servant,
-                  CORBA_Environment * ev)
+static dbus_bool_t
+impl_get_nColumns (const char *path, DBusMessageIter * iter, void *user_data)
 {
-  Table *table = TABLE (bonobo_object_from_servant (_servant));
-  AtkObject *atk_object;
-  Accessibility_Accessible rv;
-
-  atk_object = g_object_new (ATK_TYPE_OBJECT, NULL);
-  atk_object_set_name (atk_object, atk_table_get_caption (table->atk_table));
-  rv = bonobo_object_corba_objref (BONOBO_OBJECT(accessible_new(atk_object)));
-  return rv;
+  AtkTable *table = get_table_from_path (path, user_data);
+  if (!table)
+    return FALSE;
+  return droute_return_v_int32 (iter, atk_table_get_n_columns (table));
 }
 
-
-
-static Accessibility_Accessible
-impl__get_summary (PortableServer_Servant _servant,
-                  CORBA_Environment * ev)
+static char *
+impl_get_nColumns_str (void *datum)
 {
-  Table *table = TABLE (bonobo_object_from_servant (_servant));
-  AtkObject *atk_object;
-  Accessibility_Accessible rv;
-
-  atk_object = atk_table_get_summary (table->atk_table);
-  rv = bonobo_object_corba_objref (BONOBO_OBJECT(accessible_new(atk_object)));
-  return rv;
+  g_assert (ATK_IS_TABLE (datum));
+  return g_strdup_printf ("%d", atk_table_get_n_columns ((AtkTable *) datum));
 }
 
-
-
-static CORBA_long
-impl__get_nRows (PortableServer_Servant _servant,
-                CORBA_Environment * ev)
+static dbus_bool_t
+impl_get_caption (const char *path, DBusMessageIter * iter, void *user_data)
 {
-  Table *table = TABLE (bonobo_object_from_servant (_servant));
-  return (CORBA_long)
-    atk_table_get_n_rows (table->atk_table);
+  AtkTable *table = get_table_from_path (path, user_data);
+  if (!table)
+    return FALSE;
+  return spi_dbus_return_v_object (iter, atk_table_get_caption (table),
+                                  FALSE);
 }
 
-
-
-static CORBA_long
-impl__get_nColumns (PortableServer_Servant _servant,
-                   CORBA_Environment * ev)
+static char *
+impl_get_caption_str (void *datum)
 {
-  Table *table = TABLE (bonobo_object_from_servant (_servant));
-  return (CORBA_long)
-    atk_table_get_n_columns (table->atk_table);
+  AtkTable *table = (AtkTable *) datum;
+  g_assert (ATK_IS_TABLE (datum));
+  return spi_dbus_get_path (atk_table_get_caption (table));
 }
 
-
-
-static Accessibility_Accessible
-impl_getAccessibleAt (PortableServer_Servant _servant,
-                     const CORBA_long row,
-                     const CORBA_long column,
-                     CORBA_Environment * ev)
+static dbus_bool_t
+impl_get_summary (const char *path, DBusMessageIter * iter, void *user_data)
 {
-  Table *table = TABLE (bonobo_object_from_servant (_servant));
-  AtkObject *atk_object;
-  Accessibility_Accessible rv;
-
-  atk_object = atk_table_ref_at (table->atk_table,
-                                            (gint) row, (gint) column);
-  rv = bonobo_object_corba_objref (BONOBO_OBJECT(accessible_new(atk_object)));
-  return rv;
+  AtkTable *table = get_table_from_path (path, user_data);
+  if (!table)
+    return FALSE;
+  return spi_dbus_return_v_object (iter, atk_table_get_summary (table),
+                                  FALSE);
 }
 
-
-
-static CORBA_long
-impl_getIndexAt (PortableServer_Servant _servant,
-                const CORBA_long row, const CORBA_long column,
-                CORBA_Environment * ev)
+static char *
+impl_get_summary_str (void *datum)
 {
-  Table *table = TABLE (bonobo_object_from_servant (_servant));
-  return (CORBA_long)
-    atk_table_get_index_at (table->atk_table,
-                           (gint) row, (gint) column);
+  AtkTable *table = (AtkTable *) datum;
+  g_assert (ATK_IS_TABLE (datum));
+  return spi_dbus_get_path (atk_table_get_summary (table));
 }
 
-
-
-static CORBA_long
-impl_getRowAtIndex (PortableServer_Servant _servant,
-                   const CORBA_long index,
-                   CORBA_Environment * ev)
+static dbus_bool_t
+impl_get_nSelectedRows (const char *path, DBusMessageIter * iter,
+                       void *user_data)
 {
-  Table *table = TABLE (bonobo_object_from_servant (_servant));
-  return (CORBA_long)
-    atk_table_get_row_at_index (table->atk_table, (gint) index);
+  AtkTable *table = get_table_from_path (path, user_data);
+  gint *selected_rows = NULL;
+  int count;
+  if (!table)
+    return FALSE;
+  count = atk_table_get_selected_rows (table, &selected_rows);
+  if (selected_rows)
+    g_free (selected_rows);
+  return droute_return_v_int32 (iter, count);
 }
 
-
-
-static CORBA_long
-impl_getColumnAtIndex (PortableServer_Servant _servant,
-                      const CORBA_long index,
-                      CORBA_Environment * ev)
+static char *
+impl_get_nSelectedRows_str (void *datum)
 {
-  Table *table = TABLE (bonobo_object_from_servant (_servant));
-  return (CORBA_long)
-    atk_table_get_column_at_index (table->atk_table, (gint) index);
+  gint count;
+  gint *selected_rows = NULL;
+  g_assert (ATK_IS_TABLE (datum));
+  count = atk_table_get_selected_rows ((AtkTable *) datum, &selected_rows);
+  if (selected_rows)
+    g_free (selected_rows);
+  return g_strdup_printf ("%d", count);
 }
 
-
-
-static CORBA_string
-impl_getRowDescription (PortableServer_Servant _servant,
-                       const CORBA_long row,
-                       CORBA_Environment * ev)
+static dbus_bool_t
+impl_get_nSelectedColumns (const char *path, DBusMessageIter * iter,
+                          void *user_data)
 {
-  Table *table = TABLE (bonobo_object_from_servant (_servant));
-  return CORBA_string_dup (
-                          atk_table_get_row_description (table->atk_table, (gint) row));
+  AtkTable *table = get_table_from_path (path, user_data);
+  gint *selected_columns = NULL;
+  int count;
+  if (!table)
+    return FALSE;
+  count = atk_table_get_selected_columns (table, &selected_columns);
+  if (selected_columns)
+    g_free (selected_columns);
+  return droute_return_v_int32 (iter, count);
 }
 
-
-
-static CORBA_string
-impl_getColumnDescription (PortableServer_Servant _servant,
-                          const CORBA_long column,
-                          CORBA_Environment * ev)
+static char *
+impl_get_nSelectedColumns_str (void *datum)
 {
-  Table *table = TABLE (bonobo_object_from_servant (_servant));
-  return CORBA_string_dup (
-                          atk_table_get_column_description (table->atk_table, (gint) column));
+  gint count;
+  gint *selected_columns = NULL;
+  g_assert (ATK_IS_TABLE (datum));
+  count =
+    atk_table_get_selected_columns ((AtkTable *) datum, &selected_columns);
+  if (selected_columns)
+    g_free (selected_columns);
+  return g_strdup_printf ("%d", count);
 }
 
 
-
-static CORBA_long
-impl_getRowExtentAt (PortableServer_Servant _servant,
-                    const CORBA_long row,
-                    const CORBA_long column,
-                    CORBA_Environment * ev)
+static DBusMessage *
+impl_getAccessibleAt (DBusConnection * bus, DBusMessage * message,
+                     void *user_data)
 {
-  Table *table = TABLE (bonobo_object_from_servant (_servant));
-  return (CORBA_long)
-    atk_table_get_row_extent_at (table->atk_table,
-                                (gint) row, (gint) column);
+  AtkTable *table = get_table (message);
+  dbus_int32_t row, column;
+  DBusError error;
+  AtkObject *obj;
+
+  if (!table)
+    return spi_dbus_general_error (message);
+  dbus_error_init (&error);
+  if (!dbus_message_get_args
+      (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
+       DBUS_TYPE_INVALID))
+    {
+      return SPI_DBUS_RETURN_ERROR (message, &error);
+    }
+  obj = atk_table_ref_at (table, row, column);
+  return spi_dbus_return_object (message, obj, TRUE);
 }
 
-
-
-static CORBA_long
-impl_getColumnExtentAt (PortableServer_Servant _servant,
-                       const CORBA_long row,
-                       const CORBA_long column,
-                       CORBA_Environment * ev)
+static DBusMessage *
+impl_getIndexAt (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
-  Table *table = TABLE (bonobo_object_from_servant (_servant));
-  return (CORBA_long)
-    atk_table_get_column_extent_at (table->atk_table,
-                                (gint) row, (gint) column);
+  AtkTable *table = get_table (message);
+  dbus_int32_t row, column;
+  dbus_int32_t index;
+  DBusError error;
+  DBusMessage *reply;
+
+  if (!table)
+    return spi_dbus_general_error (message);
+  dbus_error_init (&error);
+  if (!dbus_message_get_args
+      (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
+       DBUS_TYPE_INVALID))
+    {
+      return SPI_DBUS_RETURN_ERROR (message, &error);
+    }
+  index = atk_table_get_index_at (table, row, column);
+  reply = dbus_message_new_method_return (message);
+  if (reply)
+    {
+      dbus_message_append_args (reply, DBUS_TYPE_INT32, &index,
+                               DBUS_TYPE_INVALID);
+    }
+  return reply;
 }
 
-
-
-static Accessibility_Table
-impl_getRowHeader (PortableServer_Servant _servant,
-                  const CORBA_long row,
-                  CORBA_Environment * ev)
+static DBusMessage *
+impl_getRowAtIndex (DBusConnection * bus, DBusMessage * message,
+                   void *user_data)
 {
-  Table *table = TABLE (bonobo_object_from_servant (_servant));
-  AtkObject *header;
-  Accessibility_Table rv;
-
-  header = atk_table_get_row_header (table->atk_table, (gint) row);
-  rv = bonobo_object_corba_objref (BONOBO_OBJECT(accessible_new(header)));
-  return rv;
+  AtkTable *table = get_table (message);
+  dbus_int32_t index;
+  dbus_int32_t row;
+  DBusError error;
+  DBusMessage *reply;
+
+  if (!table)
+    return spi_dbus_general_error (message);
+  dbus_error_init (&error);
+  if (!dbus_message_get_args
+      (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
+    {
+      return SPI_DBUS_RETURN_ERROR (message, &error);
+    }
+  row = atk_table_get_row_at_index (table, index);
+  reply = dbus_message_new_method_return (message);
+  if (reply)
+    {
+      dbus_message_append_args (reply, DBUS_TYPE_INT32, &row,
+                               DBUS_TYPE_INVALID);
+    }
+  return reply;
 }
 
-
-
-static        Accessibility_Table
-impl_getColumnHeader (PortableServer_Servant _servant,
-                     const CORBA_long column,
-                     CORBA_Environment * ev)
+static DBusMessage *
+impl_getColumnAtIndex (DBusConnection * bus, DBusMessage * message,
+                      void *user_data)
 {
-  Table *table = TABLE (bonobo_object_from_servant (_servant));
-  AtkObject *header;
-  Accessibility_Table rv;
-
-  header = atk_table_get_column_header (table->atk_table, (gint) column);
-  rv = bonobo_object_corba_objref (BONOBO_OBJECT(accessible_new(header)));
-  return rv;
+  AtkTable *table = get_table (message);
+  dbus_int32_t index;
+  dbus_int32_t column;
+  DBusError error;
+  DBusMessage *reply;
+
+  if (!table)
+    return spi_dbus_general_error (message);
+  dbus_error_init (&error);
+  if (!dbus_message_get_args
+      (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
+    {
+      return SPI_DBUS_RETURN_ERROR (message, &error);
+    }
+  column = atk_table_get_column_at_index (table, index);
+  reply = dbus_message_new_method_return (message);
+  if (reply)
+    {
+      dbus_message_append_args (reply, DBUS_TYPE_INT32, &column,
+                               DBUS_TYPE_INVALID);
+    }
+  return reply;
 }
 
-
-
-static Accessibility_LongSeq *
-impl_getSelectedRows (PortableServer_Servant _servant,
-                     CORBA_Environment * ev)
+static DBusMessage *
+impl_getRowDescription (DBusConnection * bus, DBusMessage * message,
+                       void *user_data)
 {
-  Table *table = TABLE (bonobo_object_from_servant (_servant));
-  gint *selectedRows;
-  gint length;
-  Accessibility_LongSeq *retval;
-
-  length = atk_table_get_selected_rows (table->atk_table, &selectedRows);
-
-  g_return_val_if_fail (length, NULL);
-  retval = Accessibility_LongSeq__alloc ();
-  retval->_maximum = retval->_length = (CORBA_long) length;
-  retval->_buffer = Accessibility_LongSeq_allocbuf (length);
-
-  while (--length)
-    retval->_buffer[length] = (CORBA_long) selectedRows[length];
-  g_free ((gpointer) selectedRows);
-  return retval;
+  AtkTable *table = get_table (message);
+  dbus_int32_t row;
+  const gchar *description;
+  DBusError error;
+  DBusMessage *reply;
+
+  if (!table)
+    return spi_dbus_general_error (message);
+  dbus_error_init (&error);
+  if (!dbus_message_get_args
+      (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
+    {
+      return SPI_DBUS_RETURN_ERROR (message, &error);
+    }
+  description = atk_table_get_row_description (table, row);
+  if (!description)
+    description = "";
+  reply = dbus_message_new_method_return (message);
+  if (reply)
+    {
+      dbus_message_append_args (reply, DBUS_TYPE_STRING, &description,
+                               DBUS_TYPE_INVALID);
+    }
+  return reply;
 }
 
-
-
-static Accessibility_LongSeq *
-impl_getSelectedColumns (PortableServer_Servant _servant,
-                        CORBA_Environment * ev)
+static DBusMessage *
+impl_getColumnDescription (DBusConnection * bus, DBusMessage * message,
+                          void *user_data)
 {
-  Table *table = TABLE (bonobo_object_from_servant (_servant));
-  gint *selectedColumns;
-  gint length;
-  Accessibility_LongSeq *retval;
-
-  length = atk_table_get_selected_columns (table->atk_table, &selectedColumns);
+  AtkTable *table = get_table (message);
+  dbus_int32_t column;
+  const char *description;
+  DBusError error;
+  DBusMessage *reply;
+
+  if (!table)
+    return spi_dbus_general_error (message);
+  dbus_error_init (&error);
+  if (!dbus_message_get_args
+      (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
+    {
+      return SPI_DBUS_RETURN_ERROR (message, &error);
+    }
+  description = atk_table_get_column_description (table, column);
+  if (!description)
+    description = "";
+  reply = dbus_message_new_method_return (message);
+  if (reply)
+    {
+      dbus_message_append_args (reply, DBUS_TYPE_STRING, &description,
+                               DBUS_TYPE_INVALID);
+    }
+  return reply;
+}
 
-  g_return_val_if_fail (length, NULL);
+static DBusMessage *
+impl_getRowExtentAt (DBusConnection * bus, DBusMessage * message,
+                    void *user_data)
+{
+  AtkTable *table = get_table (message);
+  dbus_int32_t row, column;
+  dbus_int32_t extent;
+  DBusError error;
+  DBusMessage *reply;
+
+  if (!table)
+    return spi_dbus_general_error (message);
+  dbus_error_init (&error);
+  if (!dbus_message_get_args
+      (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
+       DBUS_TYPE_INVALID))
+    {
+      return SPI_DBUS_RETURN_ERROR (message, &error);
+    }
+  extent = atk_table_get_row_extent_at (table, row, column);
+  reply = dbus_message_new_method_return (message);
+  if (reply)
+    {
+      dbus_message_append_args (reply, DBUS_TYPE_INT32, &extent,
+                               DBUS_TYPE_INVALID);
+    }
+  return reply;
+}
 
-  retval = Accessibility_LongSeq__alloc ();
-  retval->_maximum = retval->_length = (CORBA_long) length;
-  retval->_buffer = Accessibility_LongSeq_allocbuf (length);
+static DBusMessage *
+impl_getColumnExtentAt (DBusConnection * bus, DBusMessage * message,
+                       void *user_data)
+{
+  AtkTable *table = get_table (message);
+  dbus_int32_t row, column;
+  dbus_int32_t extent;
+  DBusError error;
+  DBusMessage *reply;
+
+  if (!table)
+    return spi_dbus_general_error (message);
+  dbus_error_init (&error);
+  if (!dbus_message_get_args
+      (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
+       DBUS_TYPE_INVALID))
+    {
+      return SPI_DBUS_RETURN_ERROR (message, &error);
+    }
+  extent = atk_table_get_column_extent_at (table, row, column);
+  reply = dbus_message_new_method_return (message);
+  if (reply)
+    {
+      dbus_message_append_args (reply, DBUS_TYPE_INT32, &extent,
+                               DBUS_TYPE_INVALID);
+    }
+  return reply;
+}
 
-  while (--length)
-    retval->_buffer[length] = (CORBA_long) selectedColumns[length];
-  g_free ((gpointer) selectedColumns);
-  return retval;
+static DBusMessage *
+impl_getRowHeader (DBusConnection * bus, DBusMessage * message,
+                  void *user_data)
+{
+  AtkTable *table = get_table (message);
+  dbus_int32_t row;
+  DBusError error;
+  AtkObject *obj;
+
+  if (!table)
+    return spi_dbus_general_error (message);
+  dbus_error_init (&error);
+  if (!dbus_message_get_args
+      (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
+    {
+      return SPI_DBUS_RETURN_ERROR (message, &error);
+    }
+  obj = atk_table_get_row_header (table, row);
+  return spi_dbus_return_object (message, obj, FALSE);
 }
 
+static DBusMessage *
+impl_getColumnHeader (DBusConnection * bus, DBusMessage * message,
+                     void *user_data)
+{
+  AtkTable *table = get_table (message);
+  dbus_int32_t column;
+  DBusError error;
+  AtkObject *obj;
+
+  if (!table)
+    return spi_dbus_general_error (message);
+  dbus_error_init (&error);
+  if (!dbus_message_get_args
+      (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
+    {
+      return SPI_DBUS_RETURN_ERROR (message, &error);
+    }
+  obj = atk_table_get_column_header (table, column);
+  return spi_dbus_return_object (message, obj, FALSE);
+}
 
+static DBusMessage *
+impl_getSelectedRows (DBusConnection * bus, DBusMessage * message,
+                     void *user_data)
+{
+  AtkTable *table = get_table (message);
+  gint *selected_rows = NULL;
+  gint count;
+  DBusMessage *reply;
+
+  if (!table)
+    return spi_dbus_general_error (message);
+  count = atk_table_get_selected_rows (table, &selected_rows);
+  if (!selected_rows)
+    count = 0;
+  reply = dbus_message_new_method_return (message);
+  if (reply)
+    {
+      /* tbd - figure out if this is safe for a 0-length array */
+      dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32,
+                               &selected_rows, count, DBUS_TYPE_INVALID);
+    }
+  if (selected_rows)
+    g_free (selected_rows);
+  return reply;
+}
 
-static CORBA_boolean
-impl_isRowSelected (PortableServer_Servant _servant,
-                   const CORBA_long row,
-                   CORBA_Environment * ev)
+static DBusMessage *
+impl_getSelectedColumns (DBusConnection * bus, DBusMessage * message,
+                        void *user_data)
 {
-  Table *table = TABLE (bonobo_object_from_servant (_servant));
-  return (CORBA_boolean)
-    atk_table_is_row_selected (table->atk_table, (gint) row);
+  AtkTable *table = get_table (message);
+  gint *selected_columns = NULL;
+  gint count;
+  DBusMessage *reply;
+
+  if (!table)
+    return spi_dbus_general_error (message);
+  count = atk_table_get_selected_columns (table, &selected_columns);
+  if (!selected_columns)
+    count = 0;
+  reply = dbus_message_new_method_return (message);
+  if (reply)
+    {
+      /* tbd - figure out if this is safe for a 0-length array */
+      dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32,
+                               &selected_columns, count, DBUS_TYPE_INVALID);
+    }
+  if (selected_columns)
+    g_free (selected_columns);
+  return reply;
 }
 
+static DBusMessage *
+impl_isRowSelected (DBusConnection * bus, DBusMessage * message,
+                   void *user_data)
+{
+  AtkTable *table = get_table (message);
+  dbus_int32_t row;
+  DBusError error;
+  DBusMessage *reply;
+  dbus_bool_t ret;
+
+  if (!table)
+    return spi_dbus_general_error (message);
+  dbus_error_init (&error);
+  if (!dbus_message_get_args
+      (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
+    {
+      return SPI_DBUS_RETURN_ERROR (message, &error);
+    }
+  ret = atk_table_is_row_selected (table, row);
+  reply = dbus_message_new_method_return (message);
+  if (reply)
+    {
+      dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
+                               DBUS_TYPE_INVALID);
+    }
+  return reply;
+}
 
+static DBusMessage *
+impl_isColumnSelected (DBusConnection * bus, DBusMessage * message,
+                      void *user_data)
+{
+  AtkTable *table = get_table (message);
+  dbus_int32_t column;
+  DBusError error;
+  DBusMessage *reply;
+  dbus_bool_t ret;
+
+  if (!table)
+    return spi_dbus_general_error (message);
+  dbus_error_init (&error);
+  if (!dbus_message_get_args
+      (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
+    {
+      return SPI_DBUS_RETURN_ERROR (message, &error);
+    }
+  ret = atk_table_is_column_selected (table, column);
+  reply = dbus_message_new_method_return (message);
+  if (reply)
+    {
+      dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
+                               DBUS_TYPE_INVALID);
+    }
+  return reply;
+}
 
-static CORBA_boolean
-impl_isColumnSelected (PortableServer_Servant _servant,
-                      const CORBA_long column,
-                      CORBA_Environment * ev)
+static DBusMessage *
+impl_isSelected (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
-  Table *table = TABLE (bonobo_object_from_servant (_servant));
-  return (CORBA_boolean)
-    atk_table_is_column_selected (table->atk_table, (gint) column);
+  AtkTable *table = get_table (message);
+  dbus_int32_t row, column;
+  DBusError error;
+  DBusMessage *reply;
+  dbus_bool_t ret;
+
+  if (!table)
+    return spi_dbus_general_error (message);
+  dbus_error_init (&error);
+  if (!dbus_message_get_args
+      (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
+       DBUS_TYPE_INVALID))
+    {
+      return SPI_DBUS_RETURN_ERROR (message, &error);
+    }
+  ret = atk_table_is_selected (table, row, column);
+  reply = dbus_message_new_method_return (message);
+  if (reply)
+    {
+      dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
+                               DBUS_TYPE_INVALID);
+    }
+  return reply;
 }
 
+static DBusMessage *
+impl_addRowSelection (DBusConnection * bus, DBusMessage * message,
+                     void *user_data)
+{
+  AtkTable *table = get_table (message);
+  dbus_int32_t row;
+  DBusError error;
+  DBusMessage *reply;
+  dbus_bool_t ret;
+
+  if (!table)
+    return spi_dbus_general_error (message);
+  dbus_error_init (&error);
+  if (!dbus_message_get_args
+      (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
+    {
+      return SPI_DBUS_RETURN_ERROR (message, &error);
+    }
+  ret = atk_table_add_row_selection (table, row);
+  reply = dbus_message_new_method_return (message);
+  if (reply)
+    {
+      dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
+                               DBUS_TYPE_INVALID);
+    }
+  return reply;
+}
 
+static DBusMessage *
+impl_addColumnSelection (DBusConnection * bus, DBusMessage * message,
+                        void *user_data)
+{
+  AtkTable *table = get_table (message);
+  dbus_int32_t column;
+  DBusError error;
+  DBusMessage *reply;
+  dbus_bool_t ret;
+
+  if (!table)
+    return spi_dbus_general_error (message);
+  dbus_error_init (&error);
+  if (!dbus_message_get_args
+      (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
+    {
+      return SPI_DBUS_RETURN_ERROR (message, &error);
+    }
+  ret = atk_table_add_column_selection (table, column);
+  reply = dbus_message_new_method_return (message);
+  if (reply)
+    {
+      dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
+                               DBUS_TYPE_INVALID);
+    }
+  return reply;
+}
 
-static CORBA_boolean
-impl_isSelected (PortableServer_Servant _servant,
-                const CORBA_long row,
-                const CORBA_long column,
-                CORBA_Environment * ev)
+static DBusMessage *
+impl_removeRowSelection (DBusConnection * bus, DBusMessage * message,
+                        void *user_data)
 {
-  Table *table = TABLE (bonobo_object_from_servant (_servant));
-  return (CORBA_boolean)
-    atk_table_is_selected (table->atk_table,
-                          (gint) row, (gint) column);
+  AtkTable *table = get_table (message);
+  dbus_int32_t row;
+  DBusError error;
+  DBusMessage *reply;
+  dbus_bool_t ret;
+
+  if (!table)
+    return spi_dbus_general_error (message);
+  dbus_error_init (&error);
+  if (!dbus_message_get_args
+      (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
+    {
+      return SPI_DBUS_RETURN_ERROR (message, &error);
+    }
+  ret = atk_table_remove_row_selection (table, row);
+  reply = dbus_message_new_method_return (message);
+  if (reply)
+    {
+      dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
+                               DBUS_TYPE_INVALID);
+    }
+  return reply;
 }
 
+static DBusMessage *
+impl_removeColumnSelection (DBusConnection * bus, DBusMessage * message,
+                           void *user_data)
+{
+  AtkTable *table = get_table (message);
+  dbus_int32_t column;
+  DBusError error;
+  DBusMessage *reply;
+  dbus_bool_t ret;
+
+  if (!table)
+    return spi_dbus_general_error (message);
+  dbus_error_init (&error);
+  if (!dbus_message_get_args
+      (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
+    {
+      return SPI_DBUS_RETURN_ERROR (message, &error);
+    }
+  ret = atk_table_remove_column_selection (table, column);
+  reply = dbus_message_new_method_return (message);
+  if (reply)
+    {
+      dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
+                               DBUS_TYPE_INVALID);
+    }
+  return reply;
+}
 
+static DBusMessage *
+impl_getRowColumnExtentsAtIndex (DBusConnection * bus, DBusMessage * message,
+                                void *user_data)
+{
+  AtkTable *table = get_table (message);
+  dbus_int32_t index;
+  DBusError error;
+  dbus_int32_t row, column, row_extents, col_extents;
+  dbus_bool_t is_selected;
+  dbus_bool_t ret;
+  DBusMessage *reply;
+
+  AtkObject *cell;
+  AtkRole role;
+
+  if (!table)
+    return spi_dbus_general_error (message);
+  dbus_error_init (&error);
+  if (!dbus_message_get_args
+      (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
+    {
+      return SPI_DBUS_RETURN_ERROR (message, &error);
+    }
+  column = atk_table_get_column_at_index (table, index);
+  row = atk_table_get_row_at_index (table, index);
+  row_extents = atk_table_get_row_extent_at (table, row, column);
+  col_extents = atk_table_get_column_extent_at (table, row, column);
+  is_selected = atk_table_is_selected (table, row, column);
+  cell = atk_table_ref_at (table, row, column);
+  role = atk_object_get_role (cell);
+  g_object_unref (cell);
+  ret = (role == ATK_ROLE_TABLE_CELL ? TRUE : FALSE);
+  reply = dbus_message_new_method_return (message);
+  if (reply)
+    {
+      dbus_message_append_args (reply, DBUS_TYPE_INT32, row, DBUS_TYPE_INT32,
+                               column, DBUS_TYPE_INT32, row_extents,
+                               DBUS_TYPE_INT32, col_extents,
+                               DBUS_TYPE_BOOLEAN, is_selected,
+                               DBUS_TYPE_BOOLEAN, &ret, DBUS_TYPE_INVALID);
+    }
+  return reply;
+}
 
+static DRouteMethod methods[] = {
+  {DROUTE_METHOD, impl_getAccessibleAt, "getAccessibleAt",
+   "i,row,i:i,column,i:o,,o"},
+  {DROUTE_METHOD, impl_getIndexAt, "getIndexAt", "i,row,i:i,column,i:i,,o"},
+  {DROUTE_METHOD, impl_getRowAtIndex, "getRowAtIndex", "i,index,i:i,,o"},
+  {DROUTE_METHOD, impl_getColumnAtIndex, "getColumnAtIndex",
+   "i,index,i:i,,o"},
+  {DROUTE_METHOD, impl_getRowDescription, "getRowDescription",
+   "i,row,i:s,,o"},
+  {DROUTE_METHOD, impl_getColumnDescription, "getColumnDescription",
+   "i,column,i:s,,o"},
+  {DROUTE_METHOD, impl_getRowExtentAt, "getRowExtentAt",
+   "i,row,i:i,column,i:i,,o"},
+  {DROUTE_METHOD, impl_getColumnExtentAt, "getColumnExtentAt",
+   "i,row,i:i,column,i:i,,o"},
+  {DROUTE_METHOD, impl_getRowHeader, "getRowHeader", "i,row,i:o,,o"},
+  {DROUTE_METHOD, impl_getColumnHeader, "getColumnHeader", "i,column,i:o,,o"},
+  {DROUTE_METHOD, impl_getSelectedRows, "getSelectedRows", "ai,,o"},
+  {DROUTE_METHOD, impl_getSelectedColumns, "getSelectedColumns", "ai,,o"},
+  {DROUTE_METHOD, impl_isRowSelected, "isRowSelected", "i,row,i:b,,o"},
+  {DROUTE_METHOD, impl_isColumnSelected, "isColumnSelected",
+   "i,column,i:b,,o"},
+  {DROUTE_METHOD, impl_isSelected, "isSelected", "i,row,i:i,column,i:b,,o"},
+  {DROUTE_METHOD, impl_addRowSelection, "addRowSelection", "i,row,i:b,,o"},
+  {DROUTE_METHOD, impl_addColumnSelection, "addColumnSelection",
+   "i,column,i:b,,o"},
+  {DROUTE_METHOD, impl_removeRowSelection, "removeRowSelection",
+   "i,row,i:b,,o"},
+  {DROUTE_METHOD, impl_removeColumnSelection, "removeColumnSelection",
+   "i,column,i:b,,o"},
+  {DROUTE_METHOD, impl_getRowColumnExtentsAtIndex,
+   "getRowColumnExtentsAtIndex",
+   "i,index,i:i,row,o:i,col,o:i,row_extents,o:i,col_extents,o:b,is_selected,o:b,,o"},
+  {0, NULL, NULL, NULL}
+};
+
+static DRouteProperty properties[] = {
+  {impl_get_nRows, impl_get_nRows_str, NULL, NULL, "nRows", "i"},
+  {impl_get_nColumns, impl_get_nColumns_str, NULL, NULL, "nColumns", "i"},
+  {impl_get_caption, impl_get_caption_str, NULL, NULL, "caption", "o"},
+  {impl_get_summary, impl_get_summary_str, NULL, NULL, "summary", "o"},
+  {impl_get_nSelectedRows, impl_get_nSelectedRows_str, NULL, NULL,
+   "nSelectedRows", "i"},
+  {impl_get_nSelectedColumns, impl_get_nSelectedColumns_str, NULL, NULL,
+   "nSelectedColumns", "i"},
+  {NULL, NULL, NULL, NULL, NULL, NULL}
+};
+
+void
+spi_initialize_table (DRouteData * data)
+{
+  droute_add_interface (data, "org.freedesktop.accessibility.Table", methods,
+                       properties,
+                       (DRouteGetDatumFunction) get_table_from_path, NULL);
+};