2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2008 Novell, Inc.
6 * Copyright 2001, 2002 Sun Microsystems Inc.,
7 * Copyright 2001, 2002 Ximian, Inc.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
25 #include "accessible.h"
28 get_table (DBusMessage * message)
30 AtkObject *obj = spi_dbus_get_object (dbus_message_get_path (message));
33 return ATK_TABLE (obj);
37 get_table_from_path (const char *path, void *user_data)
39 AtkObject *obj = spi_dbus_get_object (path);
40 if (!obj || !ATK_IS_TABLE(obj))
42 return ATK_TABLE (obj);
46 impl_get_nRows (const char *path, DBusMessageIter * iter, void *user_data)
48 AtkTable *table = get_table_from_path (path, user_data);
51 return droute_return_v_int32 (iter, atk_table_get_n_rows (table));
55 impl_get_nColumns (const char *path, DBusMessageIter * iter, void *user_data)
57 AtkTable *table = get_table_from_path (path, user_data);
60 return droute_return_v_int32 (iter, atk_table_get_n_columns (table));
64 impl_get_caption (const char *path, DBusMessageIter * iter, void *user_data)
66 AtkTable *table = get_table_from_path (path, user_data);
69 return spi_dbus_return_v_object (iter, atk_table_get_caption (table),
74 impl_get_summary (const char *path, DBusMessageIter * iter, void *user_data)
76 AtkTable *table = get_table_from_path (path, user_data);
79 return spi_dbus_return_v_object (iter, atk_table_get_summary (table),
84 impl_get_nSelectedRows (const char *path, DBusMessageIter * iter,
87 AtkTable *table = get_table_from_path (path, user_data);
88 gint *selected_rows = NULL;
92 count = atk_table_get_selected_rows (table, &selected_rows);
94 g_free (selected_rows);
95 return droute_return_v_int32 (iter, count);
99 impl_get_nSelectedColumns (const char *path, DBusMessageIter * iter,
102 AtkTable *table = get_table_from_path (path, user_data);
103 gint *selected_columns = NULL;
107 count = atk_table_get_selected_columns (table, &selected_columns);
108 if (selected_columns)
109 g_free (selected_columns);
110 return droute_return_v_int32 (iter, count);
114 impl_getAccessibleAt (DBusConnection * bus, DBusMessage * message,
117 AtkTable *table = get_table (message);
118 dbus_int32_t row, column;
123 return spi_dbus_general_error (message);
124 dbus_error_init (&error);
125 if (!dbus_message_get_args
126 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
129 return SPI_DBUS_RETURN_ERROR (message, &error);
131 obj = atk_table_ref_at (table, row, column);
132 return spi_dbus_return_object (message, obj, TRUE);
136 impl_getIndexAt (DBusConnection * bus, DBusMessage * message, void *user_data)
138 AtkTable *table = get_table (message);
139 dbus_int32_t row, column;
145 return spi_dbus_general_error (message);
146 dbus_error_init (&error);
147 if (!dbus_message_get_args
148 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
151 return SPI_DBUS_RETURN_ERROR (message, &error);
153 index = atk_table_get_index_at (table, row, column);
154 reply = dbus_message_new_method_return (message);
157 dbus_message_append_args (reply, DBUS_TYPE_INT32, &index,
164 impl_getRowAtIndex (DBusConnection * bus, DBusMessage * message,
167 AtkTable *table = get_table (message);
174 return spi_dbus_general_error (message);
175 dbus_error_init (&error);
176 if (!dbus_message_get_args
177 (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
179 return SPI_DBUS_RETURN_ERROR (message, &error);
181 row = atk_table_get_row_at_index (table, index);
182 reply = dbus_message_new_method_return (message);
185 dbus_message_append_args (reply, DBUS_TYPE_INT32, &row,
192 impl_getColumnAtIndex (DBusConnection * bus, DBusMessage * message,
195 AtkTable *table = get_table (message);
202 return spi_dbus_general_error (message);
203 dbus_error_init (&error);
204 if (!dbus_message_get_args
205 (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
207 return SPI_DBUS_RETURN_ERROR (message, &error);
209 column = atk_table_get_column_at_index (table, index);
210 reply = dbus_message_new_method_return (message);
213 dbus_message_append_args (reply, DBUS_TYPE_INT32, &column,
220 impl_getRowDescription (DBusConnection * bus, DBusMessage * message,
223 AtkTable *table = get_table (message);
225 const gchar *description;
230 return spi_dbus_general_error (message);
231 dbus_error_init (&error);
232 if (!dbus_message_get_args
233 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
235 return SPI_DBUS_RETURN_ERROR (message, &error);
237 description = atk_table_get_row_description (table, row);
240 reply = dbus_message_new_method_return (message);
243 dbus_message_append_args (reply, DBUS_TYPE_STRING, &description,
250 impl_getColumnDescription (DBusConnection * bus, DBusMessage * message,
253 AtkTable *table = get_table (message);
255 const char *description;
260 return spi_dbus_general_error (message);
261 dbus_error_init (&error);
262 if (!dbus_message_get_args
263 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
265 return SPI_DBUS_RETURN_ERROR (message, &error);
267 description = atk_table_get_column_description (table, column);
270 reply = dbus_message_new_method_return (message);
273 dbus_message_append_args (reply, DBUS_TYPE_STRING, &description,
280 impl_getRowExtentAt (DBusConnection * bus, DBusMessage * message,
283 AtkTable *table = get_table (message);
284 dbus_int32_t row, column;
290 return spi_dbus_general_error (message);
291 dbus_error_init (&error);
292 if (!dbus_message_get_args
293 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
296 return SPI_DBUS_RETURN_ERROR (message, &error);
298 extent = atk_table_get_row_extent_at (table, row, column);
299 reply = dbus_message_new_method_return (message);
302 dbus_message_append_args (reply, DBUS_TYPE_INT32, &extent,
309 impl_getColumnExtentAt (DBusConnection * bus, DBusMessage * message,
312 AtkTable *table = get_table (message);
313 dbus_int32_t row, column;
319 return spi_dbus_general_error (message);
320 dbus_error_init (&error);
321 if (!dbus_message_get_args
322 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
325 return SPI_DBUS_RETURN_ERROR (message, &error);
327 extent = atk_table_get_column_extent_at (table, row, column);
328 reply = dbus_message_new_method_return (message);
331 dbus_message_append_args (reply, DBUS_TYPE_INT32, &extent,
338 impl_getRowHeader (DBusConnection * bus, DBusMessage * message,
341 AtkTable *table = get_table (message);
347 return spi_dbus_general_error (message);
348 dbus_error_init (&error);
349 if (!dbus_message_get_args
350 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
352 return SPI_DBUS_RETURN_ERROR (message, &error);
354 obj = atk_table_get_row_header (table, row);
355 return spi_dbus_return_object (message, obj, FALSE);
359 impl_getColumnHeader (DBusConnection * bus, DBusMessage * message,
362 AtkTable *table = get_table (message);
368 return spi_dbus_general_error (message);
369 dbus_error_init (&error);
370 if (!dbus_message_get_args
371 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
373 return SPI_DBUS_RETURN_ERROR (message, &error);
375 obj = atk_table_get_column_header (table, column);
376 return spi_dbus_return_object (message, obj, FALSE);
380 impl_getSelectedRows (DBusConnection * bus, DBusMessage * message,
383 AtkTable *table = get_table (message);
384 gint *selected_rows = NULL;
389 return spi_dbus_general_error (message);
390 count = atk_table_get_selected_rows (table, &selected_rows);
393 reply = dbus_message_new_method_return (message);
396 /* tbd - figure out if this is safe for a 0-length array */
397 dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32,
398 &selected_rows, count, DBUS_TYPE_INVALID);
401 g_free (selected_rows);
406 impl_getSelectedColumns (DBusConnection * bus, DBusMessage * message,
409 AtkTable *table = get_table (message);
410 gint *selected_columns = NULL;
415 return spi_dbus_general_error (message);
416 count = atk_table_get_selected_columns (table, &selected_columns);
417 if (!selected_columns)
419 reply = dbus_message_new_method_return (message);
422 /* tbd - figure out if this is safe for a 0-length array */
423 dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32,
424 &selected_columns, count, DBUS_TYPE_INVALID);
426 if (selected_columns)
427 g_free (selected_columns);
432 impl_isRowSelected (DBusConnection * bus, DBusMessage * message,
435 AtkTable *table = get_table (message);
442 return spi_dbus_general_error (message);
443 dbus_error_init (&error);
444 if (!dbus_message_get_args
445 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
447 return SPI_DBUS_RETURN_ERROR (message, &error);
449 ret = atk_table_is_row_selected (table, row);
450 reply = dbus_message_new_method_return (message);
453 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
460 impl_isColumnSelected (DBusConnection * bus, DBusMessage * message,
463 AtkTable *table = get_table (message);
470 return spi_dbus_general_error (message);
471 dbus_error_init (&error);
472 if (!dbus_message_get_args
473 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
475 return SPI_DBUS_RETURN_ERROR (message, &error);
477 ret = atk_table_is_column_selected (table, column);
478 reply = dbus_message_new_method_return (message);
481 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
488 impl_isSelected (DBusConnection * bus, DBusMessage * message, void *user_data)
490 AtkTable *table = get_table (message);
491 dbus_int32_t row, column;
497 return spi_dbus_general_error (message);
498 dbus_error_init (&error);
499 if (!dbus_message_get_args
500 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
503 return SPI_DBUS_RETURN_ERROR (message, &error);
505 ret = atk_table_is_selected (table, row, column);
506 reply = dbus_message_new_method_return (message);
509 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
516 impl_addRowSelection (DBusConnection * bus, DBusMessage * message,
519 AtkTable *table = get_table (message);
526 return spi_dbus_general_error (message);
527 dbus_error_init (&error);
528 if (!dbus_message_get_args
529 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
531 return SPI_DBUS_RETURN_ERROR (message, &error);
533 ret = atk_table_add_row_selection (table, row);
534 reply = dbus_message_new_method_return (message);
537 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
544 impl_addColumnSelection (DBusConnection * bus, DBusMessage * message,
547 AtkTable *table = get_table (message);
554 return spi_dbus_general_error (message);
555 dbus_error_init (&error);
556 if (!dbus_message_get_args
557 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
559 return SPI_DBUS_RETURN_ERROR (message, &error);
561 ret = atk_table_add_column_selection (table, column);
562 reply = dbus_message_new_method_return (message);
565 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
572 impl_removeRowSelection (DBusConnection * bus, DBusMessage * message,
575 AtkTable *table = get_table (message);
582 return spi_dbus_general_error (message);
583 dbus_error_init (&error);
584 if (!dbus_message_get_args
585 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
587 return SPI_DBUS_RETURN_ERROR (message, &error);
589 ret = atk_table_remove_row_selection (table, row);
590 reply = dbus_message_new_method_return (message);
593 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
600 impl_removeColumnSelection (DBusConnection * bus, DBusMessage * message,
603 AtkTable *table = get_table (message);
610 return spi_dbus_general_error (message);
611 dbus_error_init (&error);
612 if (!dbus_message_get_args
613 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
615 return SPI_DBUS_RETURN_ERROR (message, &error);
617 ret = atk_table_remove_column_selection (table, column);
618 reply = dbus_message_new_method_return (message);
621 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
628 impl_getRowColumnExtentsAtIndex (DBusConnection * bus, DBusMessage * message,
631 AtkTable *table = get_table (message);
634 dbus_int32_t row, column, row_extents, col_extents;
635 dbus_bool_t is_selected;
643 return spi_dbus_general_error (message);
644 dbus_error_init (&error);
645 if (!dbus_message_get_args
646 (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
648 return SPI_DBUS_RETURN_ERROR (message, &error);
650 column = atk_table_get_column_at_index (table, index);
651 row = atk_table_get_row_at_index (table, index);
652 row_extents = atk_table_get_row_extent_at (table, row, column);
653 col_extents = atk_table_get_column_extent_at (table, row, column);
654 is_selected = atk_table_is_selected (table, row, column);
655 cell = atk_table_ref_at (table, row, column);
656 role = atk_object_get_role (cell);
657 g_object_unref (cell);
658 ret = (role == ATK_ROLE_TABLE_CELL ? TRUE : FALSE);
659 reply = dbus_message_new_method_return (message);
662 dbus_message_append_args (reply, DBUS_TYPE_INT32, row, DBUS_TYPE_INT32,
663 column, DBUS_TYPE_INT32, row_extents,
664 DBUS_TYPE_INT32, col_extents,
665 DBUS_TYPE_BOOLEAN, is_selected,
666 DBUS_TYPE_BOOLEAN, &ret, DBUS_TYPE_INVALID);
671 static DRouteMethod methods[] = {
672 {impl_getAccessibleAt, "getAccessibleAt"},
673 {impl_getIndexAt, "getIndexAt"},
674 {impl_getRowAtIndex, "getRowAtIndex"},
675 {impl_getColumnAtIndex, "getColumnAtIndex"},
676 {impl_getRowDescription, "getRowDescription"},
677 {impl_getColumnDescription, "getColumnDescription"},
678 {impl_getRowExtentAt, "getRowExtentAt"},
679 {impl_getColumnExtentAt, "getColumnExtentAt"},
680 {impl_getRowHeader, "getRowHeader"},
681 {impl_getColumnHeader, "getColumnHeader"},
682 {impl_getSelectedRows, "getSelectedRows"},
683 {impl_getSelectedColumns, "getSelectedColumns"},
684 {impl_isRowSelected, "isRowSelected"},
685 {impl_isColumnSelected, "isColumnSelected"},
686 {impl_isSelected, "isSelected"},
687 {impl_addRowSelection, "addRowSelection"},
688 {impl_addColumnSelection, "addColumnSelection"},
689 {impl_removeRowSelection, "removeRowSelection"},
690 {impl_removeColumnSelection, "removeColumnSelection"},
691 {impl_getRowColumnExtentsAtIndex, "getRowColumnExtentsAtIndex"},
695 static DRouteProperty properties[] = {
696 {impl_get_nRows, NULL, "nRows"},
697 {impl_get_nColumns, NULL, "nColumns"},
698 {impl_get_caption, NULL, "caption"},
699 {impl_get_summary, NULL, "summary"},
700 {impl_get_nSelectedRows, NULL, "nSelectedRows"},
701 {impl_get_nSelectedColumns, NULL, "nSelectedColumns"},
706 spi_initialize_table (DRouteData * data)
708 droute_add_interface (data, "org.freedesktop.atspi.Table", methods,
710 (DRouteGetDatumFunction) get_table_from_path, NULL);