* 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 "accessible.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"
-
-/*
- * 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 AtkTable *
+get_table (DBusMessage * message)
{
- 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;
+ AtkObject *obj = spi_dbus_get_object (dbus_message_get_path (message));
+ if (!obj)
+ return NULL;
+ return ATK_TABLE (obj);
}
-static void
-table_class_init (TableClass *klass)
+static AtkTable *
+get_table_from_path (const char *path, void *user_data)
{
- 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;
+ AtkObject *obj = spi_dbus_get_object (path);
+ if (!obj || !ATK_IS_TABLE(obj))
+ return NULL;
+ return ATK_TABLE (obj);
}
-static void
-table_init (Table *table)
+static dbus_bool_t
+impl_get_nRows (const char *path, DBusMessageIter * iter, void *user_data)
{
+ 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));
}
-static void
-table_finalize (GObject *obj)
+static dbus_bool_t
+impl_get_nColumns (const char *path, DBusMessageIter * iter, void *user_data)
{
- Table *table = TABLE (obj);
- g_object_unref (table->atko);
- table->atko = 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_columns (table));
}
-Table *
-table_interface_new (AtkObject *obj)
+static dbus_bool_t
+impl_get_caption (const char *path, DBusMessageIter * iter, void *user_data)
{
- Table *new_table =
- TABLE(g_object_new (TABLE_TYPE, NULL));
- new_table->atko = obj;
- g_object_ref (obj);
- return new_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 Accessibility_Accessible
-impl__get_caption (PortableServer_Servant _servant,
- 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_get_caption (ATK_TABLE(table-> atko));
- 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 Accessibility_Accessible
-impl__get_summary (PortableServer_Servant _servant,
- 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));
- AtkObject *atk_object;
- Accessibility_Accessible rv;
-
- atk_object = atk_table_get_summary (ATK_TABLE(table->atko));
- rv = bonobo_object_corba_objref (BONOBO_OBJECT(accessible_new(atk_object)));
- return rv;
+ 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__get_nRows (PortableServer_Servant _servant,
- 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_long)
- atk_table_get_n_rows (ATK_TABLE(table->atko) );
+ 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_long
-impl__get_nColumns (PortableServer_Servant _servant,
- 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_n_columns (ATK_TABLE(table->atko));
+ 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 Accessibility_Accessible
-impl_getAccessibleAt (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));
- AtkObject *atk_object;
- Accessibility_Accessible rv;
-
- atk_object = atk_table_ref_at (ATK_TABLE(table->atko),
- (gint) row, (gint) column);
- rv = bonobo_object_corba_objref (BONOBO_OBJECT(accessible_new(atk_object)));
- return rv;
+ 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 CORBA_long
-impl_getIndexAt (PortableServer_Servant _servant,
- const CORBA_long row, const CORBA_long column,
- CORBA_Environment * ev)
+static DBusMessage *
+impl_getRowAtIndex (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
{
- Table *table = TABLE (bonobo_object_from_servant (_servant));
- return (CORBA_long)
- atk_table_get_index_at (ATK_TABLE(table->atko),
- (gint) row, (gint) column);
+ 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 CORBA_long
-impl_getRowAtIndex (PortableServer_Servant _servant,
- const CORBA_long index,
- CORBA_Environment * ev)
+static DBusMessage *
+impl_getColumnAtIndex (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
{
- Table *table = TABLE (bonobo_object_from_servant (_servant));
- return (CORBA_long)
- atk_table_get_row_at_index (ATK_TABLE(table->atko), (gint) index);
+ 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 CORBA_long
-impl_getColumnAtIndex (PortableServer_Servant _servant,
- const CORBA_long index,
- CORBA_Environment * ev)
+static DBusMessage *
+impl_getRowDescription (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
{
- Table *table = TABLE (bonobo_object_from_servant (_servant));
- return (CORBA_long)
- atk_table_get_column_at_index (ATK_TABLE(table->atko), (gint) index);
+ 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 CORBA_string
-impl_getRowDescription (PortableServer_Servant _servant,
- const CORBA_long row,
- CORBA_Environment * ev)
+static DBusMessage *
+impl_getColumnDescription (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
{
- Table *table = TABLE (bonobo_object_from_servant (_servant));
- CORBA_char *rv;
-
- rv = atk_table_get_row_description (ATK_TABLE(table->atko), (gint) row);
- if (rv)
- return CORBA_string_dup (rv);
- else
- return CORBA_string_dup ("");
+ 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;
}
-
-
-static CORBA_string
-impl_getColumnDescription (PortableServer_Servant _servant,
- const CORBA_long column,
- CORBA_Environment * ev)
+static DBusMessage *
+impl_getRowExtentAt (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
{
- Table *table = TABLE (bonobo_object_from_servant (_servant));
- CORBA_char *rv;
-
- rv = atk_table_get_column_description (ATK_TABLE(table->atko), (gint) column);
- if (rv)
- return CORBA_string_dup (rv);
- else
- return CORBA_string_dup ("");
+ 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;
}
-
-
-static CORBA_long
-impl_getRowExtentAt (PortableServer_Servant _servant,
- const CORBA_long row,
- const CORBA_long column,
- CORBA_Environment * ev)
+static DBusMessage *
+impl_getColumnExtentAt (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
{
- Table *table = TABLE (bonobo_object_from_servant (_servant));
- return (CORBA_long)
- atk_table_get_row_extent_at (ATK_TABLE(table->atko),
- (gint) row, (gint) column);
+ 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;
}
-
-
-static CORBA_long
-impl_getColumnExtentAt (PortableServer_Servant _servant,
- const CORBA_long row,
- const CORBA_long column,
- CORBA_Environment * ev)
+static DBusMessage *
+impl_getRowHeader (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
{
- Table *table = TABLE (bonobo_object_from_servant (_servant));
- return (CORBA_long)
- atk_table_get_column_extent_at (ATK_TABLE(table->atko),
- (gint) row, (gint) column);
+ 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 Accessibility_Table
-impl_getRowHeader (PortableServer_Servant _servant,
- const CORBA_long row,
- CORBA_Environment * ev)
+static DBusMessage *
+impl_getColumnHeader (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 (ATK_TABLE(table->atko), (gint) row);
- rv = bonobo_object_corba_objref (BONOBO_OBJECT(accessible_new(header)));
- return rv;
+ 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 Accessibility_Table
-impl_getColumnHeader (PortableServer_Servant _servant,
- const CORBA_long column,
- CORBA_Environment * ev)
+static DBusMessage *
+impl_getSelectedRows (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 (ATK_TABLE(table->atko), (gint) column);
- rv = bonobo_object_corba_objref (BONOBO_OBJECT(accessible_new(header)));
- return rv;
+ 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 Accessibility_LongSeq *
-impl_getSelectedRows (PortableServer_Servant _servant,
- CORBA_Environment * ev)
+static DBusMessage *
+impl_getSelectedColumns (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 (ATK_TABLE(table->atko), &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);
+ 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 Accessibility_LongSeq *
-impl_getSelectedColumns (PortableServer_Servant _servant,
- CORBA_Environment * ev)
+static DBusMessage *
+impl_isRowSelected (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 (ATK_TABLE(table->atko), &selectedColumns);
-
- 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) selectedColumns[length];
- g_free ((gpointer) selectedColumns);
- return retval;
+ 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 CORBA_boolean
-impl_isRowSelected (PortableServer_Servant _servant,
- const CORBA_long row,
- CORBA_Environment * ev)
+static DBusMessage *
+impl_isColumnSelected (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
{
- Table *table = TABLE (bonobo_object_from_servant (_servant));
- return (CORBA_boolean)
- atk_table_is_row_selected (ATK_TABLE(table->atko), (gint) row);
+ 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 (ATK_TABLE(table->atko), (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 (ATK_TABLE(table->atko),
- (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[] = {
+ {impl_getAccessibleAt, "getAccessibleAt"},
+ {impl_getIndexAt, "getIndexAt"},
+ {impl_getRowAtIndex, "getRowAtIndex"},
+ {impl_getColumnAtIndex, "getColumnAtIndex"},
+ {impl_getRowDescription, "getRowDescription"},
+ {impl_getColumnDescription, "getColumnDescription"},
+ {impl_getRowExtentAt, "getRowExtentAt"},
+ {impl_getColumnExtentAt, "getColumnExtentAt"},
+ {impl_getRowHeader, "getRowHeader"},
+ {impl_getColumnHeader, "getColumnHeader"},
+ {impl_getSelectedRows, "getSelectedRows"},
+ {impl_getSelectedColumns, "getSelectedColumns"},
+ {impl_isRowSelected, "isRowSelected"},
+ {impl_isColumnSelected, "isColumnSelected"},
+ {impl_isSelected, "isSelected"},
+ {impl_addRowSelection, "addRowSelection"},
+ {impl_addColumnSelection, "addColumnSelection"},
+ {impl_removeRowSelection, "removeRowSelection"},
+ {impl_removeColumnSelection, "removeColumnSelection"},
+ {impl_getRowColumnExtentsAtIndex, "getRowColumnExtentsAtIndex"},
+ {NULL, NULL}
+};
+
+static DRouteProperty properties[] = {
+ {impl_get_nRows, NULL, "nRows"},
+ {impl_get_nColumns, NULL, "nColumns"},
+ {impl_get_caption, NULL, "caption"},
+ {impl_get_summary, NULL, "summary"},
+ {impl_get_nSelectedRows, NULL, "nSelectedRows"},
+ {impl_get_nSelectedColumns, NULL, "nSelectedColumns"},
+ {NULL, NULL, NULL}
+};
+
+void
+spi_initialize_table (DRouteData * data)
+{
+ droute_add_interface (data, "org.freedesktop.atspi.Table", methods,
+ properties,
+ (DRouteGetDatumFunction) get_table_from_path, NULL);
+};