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.
26 #include <droute/droute.h>
28 #include "common/spi-dbus.h"
30 #include "introspection.h"
33 impl_get_NRows (DBusMessageIter * iter, void *user_data)
35 AtkTable *table = (AtkTable *) user_data;
36 g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
37 return droute_return_v_int32 (iter, atk_table_get_n_rows (table));
41 impl_get_NColumns (DBusMessageIter * iter, void *user_data)
43 AtkTable *table = (AtkTable *) user_data;
44 g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
45 return droute_return_v_int32 (iter, atk_table_get_n_columns (table));
49 impl_get_Caption (DBusMessageIter * iter, void *user_data)
51 AtkTable *table = (AtkTable *) user_data;
52 g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
53 spi_object_append_v_reference (iter, atk_table_get_caption (table));
58 impl_get_Summary (DBusMessageIter * iter, void *user_data)
60 AtkTable *table = (AtkTable *) user_data;
61 g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
62 spi_object_append_v_reference (iter, atk_table_get_summary (table));
67 impl_get_NSelectedRows (DBusMessageIter * iter, void *user_data)
69 AtkTable *table = (AtkTable *) user_data;
70 gint *selected_rows = NULL;
72 g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
73 count = atk_table_get_selected_rows (table, &selected_rows);
75 g_free (selected_rows);
76 return droute_return_v_int32 (iter, count);
80 impl_get_NSelectedColumns (DBusMessageIter * iter, void *user_data)
82 AtkTable *table = (AtkTable *) user_data;
83 gint *selected_columns = NULL;
85 g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
86 count = atk_table_get_selected_columns (table, &selected_columns);
88 g_free (selected_columns);
89 return droute_return_v_int32 (iter, count);
93 impl_GetAccessibleAt (DBusConnection * bus, DBusMessage * message,
96 AtkTable *table = (AtkTable *) user_data;
97 dbus_int32_t row, column;
101 g_return_val_if_fail (ATK_IS_TABLE (user_data),
102 droute_not_yet_handled_error (message));
103 dbus_error_init (&error);
104 if (!dbus_message_get_args
105 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
108 return droute_invalid_arguments_error (message);
110 obj = atk_table_ref_at (table, row, column);
111 return spi_object_return_reference (message, obj);
115 impl_GetIndexAt (DBusConnection * bus, DBusMessage * message, void *user_data)
117 AtkTable *table = (AtkTable *) user_data;
118 dbus_int32_t row, column;
123 g_return_val_if_fail (ATK_IS_TABLE (user_data),
124 droute_not_yet_handled_error (message));
125 dbus_error_init (&error);
126 if (!dbus_message_get_args
127 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
130 return droute_invalid_arguments_error (message);
132 index = atk_table_get_index_at (table, row, column);
133 reply = dbus_message_new_method_return (message);
136 dbus_message_append_args (reply, DBUS_TYPE_INT32, &index,
143 impl_GetRowAtIndex (DBusConnection * bus, DBusMessage * message,
146 AtkTable *table = (AtkTable *) user_data;
152 g_return_val_if_fail (ATK_IS_TABLE (user_data),
153 droute_not_yet_handled_error (message));
154 dbus_error_init (&error);
155 if (!dbus_message_get_args
156 (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
158 return droute_invalid_arguments_error (message);
160 row = atk_table_get_row_at_index (table, index);
161 reply = dbus_message_new_method_return (message);
164 dbus_message_append_args (reply, DBUS_TYPE_INT32, &row,
171 impl_GetColumnAtIndex (DBusConnection * bus, DBusMessage * message,
174 AtkTable *table = (AtkTable *) user_data;
180 g_return_val_if_fail (ATK_IS_TABLE (user_data),
181 droute_not_yet_handled_error (message));
182 dbus_error_init (&error);
183 if (!dbus_message_get_args
184 (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
186 return droute_invalid_arguments_error (message);
188 column = atk_table_get_column_at_index (table, index);
189 reply = dbus_message_new_method_return (message);
192 dbus_message_append_args (reply, DBUS_TYPE_INT32, &column,
199 impl_GetRowDescription (DBusConnection * bus, DBusMessage * message,
203 AtkTable *table = (AtkTable *) user_data;
204 const gchar *description;
208 g_return_val_if_fail (ATK_IS_TABLE (user_data),
209 droute_not_yet_handled_error (message));
210 dbus_error_init (&error);
211 if (!dbus_message_get_args
212 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
214 return droute_invalid_arguments_error (message);
216 description = atk_table_get_row_description (table, row);
219 reply = dbus_message_new_method_return (message);
222 dbus_message_append_args (reply, DBUS_TYPE_STRING, &description,
229 impl_GetColumnDescription (DBusConnection * bus, DBusMessage * message,
232 AtkTable *table = (AtkTable *) user_data;
234 const char *description;
238 g_return_val_if_fail (ATK_IS_TABLE (user_data),
239 droute_not_yet_handled_error (message));
240 dbus_error_init (&error);
241 if (!dbus_message_get_args
242 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
244 return droute_invalid_arguments_error (message);
246 description = atk_table_get_column_description (table, column);
249 reply = dbus_message_new_method_return (message);
252 dbus_message_append_args (reply, DBUS_TYPE_STRING, &description,
259 impl_GetRowExtentAt (DBusConnection * bus, DBusMessage * message,
262 AtkTable *table = (AtkTable *) user_data;
263 dbus_int32_t row, column;
268 g_return_val_if_fail (ATK_IS_TABLE (user_data),
269 droute_not_yet_handled_error (message));
270 dbus_error_init (&error);
271 if (!dbus_message_get_args
272 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
275 return droute_invalid_arguments_error (message);
277 extent = atk_table_get_row_extent_at (table, row, column);
278 reply = dbus_message_new_method_return (message);
281 dbus_message_append_args (reply, DBUS_TYPE_INT32, &extent,
288 impl_GetColumnExtentAt (DBusConnection * bus, DBusMessage * message,
291 AtkTable *table = (AtkTable *) user_data;
292 dbus_int32_t row, column;
297 g_return_val_if_fail (ATK_IS_TABLE (user_data),
298 droute_not_yet_handled_error (message));
299 dbus_error_init (&error);
300 if (!dbus_message_get_args
301 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
304 return droute_invalid_arguments_error (message);
306 extent = atk_table_get_column_extent_at (table, row, column);
307 reply = dbus_message_new_method_return (message);
310 dbus_message_append_args (reply, DBUS_TYPE_INT32, &extent,
317 impl_GetRowHeader (DBusConnection * bus, DBusMessage * message,
320 AtkTable *table = (AtkTable *) user_data;
323 AtkObject *obj = NULL;
325 g_return_val_if_fail (ATK_IS_TABLE (user_data),
326 droute_not_yet_handled_error (message));
327 dbus_error_init (&error);
328 if (!dbus_message_get_args
329 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
331 return droute_invalid_arguments_error (message);
333 obj = atk_table_get_row_header (table, row);
334 return spi_object_return_reference (message, obj);
338 impl_GetColumnHeader (DBusConnection * bus, DBusMessage * message,
341 AtkTable *table = (AtkTable *) user_data;
346 g_return_val_if_fail (ATK_IS_TABLE (user_data),
347 droute_not_yet_handled_error (message));
348 dbus_error_init (&error);
349 if (!dbus_message_get_args
350 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
352 return droute_invalid_arguments_error (message);
354 obj = atk_table_get_column_header (table, column);
355 return spi_object_return_reference (message, obj);
359 impl_GetSelectedRows (DBusConnection * bus, DBusMessage * message,
362 AtkTable *table = (AtkTable *) user_data;
363 gint *selected_rows = NULL;
367 g_return_val_if_fail (ATK_IS_TABLE (user_data),
368 droute_not_yet_handled_error (message));
369 count = atk_table_get_selected_rows (table, &selected_rows);
372 reply = dbus_message_new_method_return (message);
375 /* tbd - figure out if this is safe for a 0-length array */
376 dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32,
377 &selected_rows, count, DBUS_TYPE_INVALID);
380 g_free (selected_rows);
385 impl_GetSelectedColumns (DBusConnection * bus, DBusMessage * message,
388 AtkTable *table = (AtkTable *) user_data;
389 gint *selected_columns = NULL;
393 g_return_val_if_fail (ATK_IS_TABLE (user_data),
394 droute_not_yet_handled_error (message));
395 count = atk_table_get_selected_columns (table, &selected_columns);
396 if (!selected_columns)
398 reply = dbus_message_new_method_return (message);
401 /* tbd - figure out if this is safe for a 0-length array */
402 dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32,
403 &selected_columns, count, DBUS_TYPE_INVALID);
405 if (selected_columns)
406 g_free (selected_columns);
411 impl_IsRowSelected (DBusConnection * bus, DBusMessage * message,
414 AtkTable *table = (AtkTable *) user_data;
420 g_return_val_if_fail (ATK_IS_TABLE (user_data),
421 droute_not_yet_handled_error (message));
422 dbus_error_init (&error);
423 if (!dbus_message_get_args
424 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
426 return droute_invalid_arguments_error (message);
428 ret = atk_table_is_row_selected (table, row);
429 reply = dbus_message_new_method_return (message);
432 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
439 impl_IsColumnSelected (DBusConnection * bus, DBusMessage * message,
442 AtkTable *table = (AtkTable *) user_data;
448 g_return_val_if_fail (ATK_IS_TABLE (user_data),
449 droute_not_yet_handled_error (message));
450 dbus_error_init (&error);
451 if (!dbus_message_get_args
452 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
454 return droute_invalid_arguments_error (message);
456 ret = atk_table_is_column_selected (table, column);
457 reply = dbus_message_new_method_return (message);
460 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
467 impl_IsSelected (DBusConnection * bus, DBusMessage * message, void *user_data)
469 AtkTable *table = (AtkTable *) user_data;
470 dbus_int32_t row, column;
475 g_return_val_if_fail (ATK_IS_TABLE (user_data),
476 droute_not_yet_handled_error (message));
477 dbus_error_init (&error);
478 if (!dbus_message_get_args
479 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
482 return droute_invalid_arguments_error (message);
484 ret = atk_table_is_selected (table, row, column);
485 reply = dbus_message_new_method_return (message);
488 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
495 impl_AddRowSelection (DBusConnection * bus, DBusMessage * message,
498 AtkTable *table = (AtkTable *) user_data;
504 g_return_val_if_fail (ATK_IS_TABLE (user_data),
505 droute_not_yet_handled_error (message));
506 dbus_error_init (&error);
507 if (!dbus_message_get_args
508 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
510 return droute_invalid_arguments_error (message);
512 ret = atk_table_add_row_selection (table, row);
513 reply = dbus_message_new_method_return (message);
516 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
523 impl_AddColumnSelection (DBusConnection * bus, DBusMessage * message,
526 AtkTable *table = (AtkTable *) user_data;
532 g_return_val_if_fail (ATK_IS_TABLE (user_data),
533 droute_not_yet_handled_error (message));
534 dbus_error_init (&error);
535 if (!dbus_message_get_args
536 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
538 return droute_invalid_arguments_error (message);
540 ret = atk_table_add_column_selection (table, column);
541 reply = dbus_message_new_method_return (message);
544 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
551 impl_RemoveRowSelection (DBusConnection * bus, DBusMessage * message,
554 AtkTable *table = (AtkTable *) user_data;
560 g_return_val_if_fail (ATK_IS_TABLE (user_data),
561 droute_not_yet_handled_error (message));
562 dbus_error_init (&error);
563 if (!dbus_message_get_args
564 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
566 return droute_invalid_arguments_error (message);
568 ret = atk_table_remove_row_selection (table, row);
569 reply = dbus_message_new_method_return (message);
572 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
579 impl_RemoveColumnSelection (DBusConnection * bus, DBusMessage * message,
582 AtkTable *table = (AtkTable *) user_data;
588 g_return_val_if_fail (ATK_IS_TABLE (user_data),
589 droute_not_yet_handled_error (message));
590 dbus_error_init (&error);
591 if (!dbus_message_get_args
592 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
594 return droute_invalid_arguments_error (message);
596 ret = atk_table_remove_column_selection (table, column);
597 reply = dbus_message_new_method_return (message);
600 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
607 impl_GetRowColumnExtentsAtIndex (DBusConnection * bus, DBusMessage * message,
610 AtkTable *table = (AtkTable *) user_data;
613 dbus_int32_t row, column, row_extents, col_extents;
614 dbus_bool_t is_selected;
621 g_return_val_if_fail (ATK_IS_TABLE (user_data),
622 droute_not_yet_handled_error (message));
623 dbus_error_init (&error);
624 if (!dbus_message_get_args
625 (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
627 return droute_invalid_arguments_error (message);
629 column = atk_table_get_column_at_index (table, index);
630 row = atk_table_get_row_at_index (table, index);
631 row_extents = atk_table_get_row_extent_at (table, row, column);
632 col_extents = atk_table_get_column_extent_at (table, row, column);
633 is_selected = atk_table_is_selected (table, row, column);
634 cell = atk_table_ref_at (table, row, column);
635 role = atk_object_get_role (cell);
636 g_object_unref (cell);
637 ret = (role == ATK_ROLE_TABLE_CELL ? TRUE : FALSE);
638 reply = dbus_message_new_method_return (message);
641 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
642 DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32,
643 &column, DBUS_TYPE_INT32, &row_extents,
644 DBUS_TYPE_INT32, &col_extents,
645 DBUS_TYPE_BOOLEAN, &is_selected,
651 static DRouteMethod methods[] = {
652 {impl_GetAccessibleAt, "GetAccessibleAt"},
653 {impl_GetIndexAt, "GetIndexAt"},
654 {impl_GetRowAtIndex, "GetRowAtIndex"},
655 {impl_GetColumnAtIndex, "GetColumnAtIndex"},
656 {impl_GetRowDescription, "GetRowDescription"},
657 {impl_GetColumnDescription, "GetColumnDescription"},
658 {impl_GetRowExtentAt, "GetRowExtentAt"},
659 {impl_GetColumnExtentAt, "GetColumnExtentAt"},
660 {impl_GetRowHeader, "GetRowHeader"},
661 {impl_GetColumnHeader, "GetColumnHeader"},
662 {impl_GetSelectedRows, "GetSelectedRows"},
663 {impl_GetSelectedColumns, "GetSelectedColumns"},
664 {impl_IsRowSelected, "IsRowSelected"},
665 {impl_IsColumnSelected, "IsColumnSelected"},
666 {impl_IsSelected, "IsSelected"},
667 {impl_AddRowSelection, "AddRowSelection"},
668 {impl_AddColumnSelection, "AddColumnSelection"},
669 {impl_RemoveRowSelection, "RemoveRowSelection"},
670 {impl_RemoveColumnSelection, "RemoveColumnSelection"},
671 {impl_GetRowColumnExtentsAtIndex, "GetRowColumnExtentsAtIndex"},
675 static DRouteProperty properties[] = {
676 {impl_get_NRows, NULL, "NRows"},
677 {impl_get_NColumns, NULL, "NColumns"},
678 {impl_get_Caption, NULL, "Caption"},
679 {impl_get_Summary, NULL, "Summary"},
680 {impl_get_NSelectedRows, NULL, "NSelectedRows"},
681 {impl_get_NSelectedColumns, NULL, "NSelectedColumns"},
686 spi_initialize_table (DRoutePath * path)
688 droute_path_add_interface (path,
689 SPI_DBUS_INTERFACE_TABLE, spi_org_a11y_atspi_Table, methods, properties);