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 "accessible-marshaller.h"
29 #include "common/spi-dbus.h"
32 impl_get_NRows (DBusMessageIter * iter, void *user_data)
34 AtkTable *table = (AtkTable *) user_data;
35 g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
36 return droute_return_v_int32 (iter, atk_table_get_n_rows (table));
40 impl_get_NColumns (DBusMessageIter * iter, void *user_data)
42 AtkTable *table = (AtkTable *) user_data;
43 g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
44 return droute_return_v_int32 (iter, atk_table_get_n_columns (table));
48 impl_get_Caption (DBusMessageIter * iter, void *user_data)
50 AtkTable *table = (AtkTable *) user_data;
51 g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
52 return spi_dbus_return_v_object (iter, atk_table_get_caption (table),
57 impl_get_Summary (DBusMessageIter * iter, void *user_data)
59 AtkTable *table = (AtkTable *) user_data;
60 g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
61 return spi_dbus_return_v_object (iter, atk_table_get_summary (table),
66 impl_get_NSelectedRows (DBusMessageIter * iter,
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,
83 AtkTable *table = (AtkTable *) user_data;
84 gint *selected_columns = NULL;
86 g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
87 count = atk_table_get_selected_columns (table, &selected_columns);
89 g_free (selected_columns);
90 return droute_return_v_int32 (iter, count);
94 impl_GetAccessibleAt (DBusConnection * bus, DBusMessage * message,
97 AtkTable *table = (AtkTable *) user_data;
98 dbus_int32_t row, column;
102 g_return_val_if_fail (ATK_IS_TABLE (user_data),
103 droute_not_yet_handled_error (message));
104 dbus_error_init (&error);
105 if (!dbus_message_get_args
106 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
109 return droute_invalid_arguments_error (message);
111 obj = atk_table_ref_at (table, row, column);
112 return spi_dbus_return_object (message, obj, TRUE, TRUE);
116 impl_GetIndexAt (DBusConnection * bus, DBusMessage * message, void *user_data)
118 AtkTable *table = (AtkTable *) user_data;
119 dbus_int32_t row, column;
124 g_return_val_if_fail (ATK_IS_TABLE (user_data),
125 droute_not_yet_handled_error (message));
126 dbus_error_init (&error);
127 if (!dbus_message_get_args
128 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
131 return droute_invalid_arguments_error (message);
133 index = atk_table_get_index_at (table, row, column);
134 reply = dbus_message_new_method_return (message);
137 dbus_message_append_args (reply, DBUS_TYPE_INT32, &index,
144 impl_GetRowAtIndex (DBusConnection * bus, DBusMessage * message,
147 AtkTable *table = (AtkTable *) user_data;
153 g_return_val_if_fail (ATK_IS_TABLE (user_data),
154 droute_not_yet_handled_error (message));
155 dbus_error_init (&error);
156 if (!dbus_message_get_args
157 (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
159 return droute_invalid_arguments_error (message);
161 row = atk_table_get_row_at_index (table, index);
162 reply = dbus_message_new_method_return (message);
165 dbus_message_append_args (reply, DBUS_TYPE_INT32, &row,
172 impl_GetColumnAtIndex (DBusConnection * bus, DBusMessage * message,
175 AtkTable *table = (AtkTable *) user_data;
181 g_return_val_if_fail (ATK_IS_TABLE (user_data),
182 droute_not_yet_handled_error (message));
183 dbus_error_init (&error);
184 if (!dbus_message_get_args
185 (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
187 return droute_invalid_arguments_error (message);
189 column = atk_table_get_column_at_index (table, index);
190 reply = dbus_message_new_method_return (message);
193 dbus_message_append_args (reply, DBUS_TYPE_INT32, &column,
200 impl_GetRowDescription (DBusConnection * bus, DBusMessage * message,
204 AtkTable *table = (AtkTable *) user_data;
205 const gchar *description;
209 g_return_val_if_fail (ATK_IS_TABLE (user_data),
210 droute_not_yet_handled_error (message));
211 dbus_error_init (&error);
212 if (!dbus_message_get_args
213 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
215 return droute_invalid_arguments_error (message);
217 description = atk_table_get_row_description (table, row);
220 reply = dbus_message_new_method_return (message);
223 dbus_message_append_args (reply, DBUS_TYPE_STRING, &description,
230 impl_GetColumnDescription (DBusConnection * bus, DBusMessage * message,
233 AtkTable *table = (AtkTable *) user_data;
235 const char *description;
239 g_return_val_if_fail (ATK_IS_TABLE (user_data),
240 droute_not_yet_handled_error (message));
241 dbus_error_init (&error);
242 if (!dbus_message_get_args
243 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
245 return droute_invalid_arguments_error (message);
247 description = atk_table_get_column_description (table, column);
250 reply = dbus_message_new_method_return (message);
253 dbus_message_append_args (reply, DBUS_TYPE_STRING, &description,
260 impl_GetRowExtentAt (DBusConnection * bus, DBusMessage * message,
263 AtkTable *table = (AtkTable *) user_data;
264 dbus_int32_t row, column;
269 g_return_val_if_fail (ATK_IS_TABLE (user_data),
270 droute_not_yet_handled_error (message));
271 dbus_error_init (&error);
272 if (!dbus_message_get_args
273 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
276 return droute_invalid_arguments_error (message);
278 extent = atk_table_get_row_extent_at (table, row, column);
279 reply = dbus_message_new_method_return (message);
282 dbus_message_append_args (reply, DBUS_TYPE_INT32, &extent,
289 impl_GetColumnExtentAt (DBusConnection * bus, DBusMessage * message,
292 AtkTable *table = (AtkTable *) user_data;
293 dbus_int32_t row, column;
298 g_return_val_if_fail (ATK_IS_TABLE (user_data),
299 droute_not_yet_handled_error (message));
300 dbus_error_init (&error);
301 if (!dbus_message_get_args
302 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
305 return droute_invalid_arguments_error (message);
307 extent = atk_table_get_column_extent_at (table, row, column);
308 reply = dbus_message_new_method_return (message);
311 dbus_message_append_args (reply, DBUS_TYPE_INT32, &extent,
318 impl_GetRowHeader (DBusConnection * bus, DBusMessage * message,
321 AtkTable *table = (AtkTable *) user_data;
326 g_return_val_if_fail (ATK_IS_TABLE (user_data),
327 droute_not_yet_handled_error (message));
328 dbus_error_init (&error);
329 if (!dbus_message_get_args
330 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
332 return droute_invalid_arguments_error (message);
334 obj = atk_table_get_row_header (table, row);
335 obj = atk_table_get_row_header (table, row);
336 return spi_dbus_return_object (message, obj, TRUE, FALSE);
340 impl_GetColumnHeader (DBusConnection * bus, DBusMessage * message,
343 AtkTable *table = (AtkTable *) user_data;
348 g_return_val_if_fail (ATK_IS_TABLE (user_data),
349 droute_not_yet_handled_error (message));
350 dbus_error_init (&error);
351 if (!dbus_message_get_args
352 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
354 return droute_invalid_arguments_error (message);
356 obj = atk_table_get_column_header (table, column);
357 obj = atk_table_get_column_header (table, column);
358 return spi_dbus_return_object (message, obj, TRUE, FALSE);
362 impl_GetSelectedRows (DBusConnection * bus, DBusMessage * message,
365 AtkTable *table = (AtkTable *) user_data;
366 gint *selected_rows = NULL;
370 g_return_val_if_fail (ATK_IS_TABLE (user_data),
371 droute_not_yet_handled_error (message));
372 count = atk_table_get_selected_rows (table, &selected_rows);
375 reply = dbus_message_new_method_return (message);
378 /* tbd - figure out if this is safe for a 0-length array */
379 dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32,
380 &selected_rows, count, DBUS_TYPE_INVALID);
383 g_free (selected_rows);
388 impl_GetSelectedColumns (DBusConnection * bus, DBusMessage * message,
391 AtkTable *table = (AtkTable *) user_data;
392 gint *selected_columns = NULL;
396 g_return_val_if_fail (ATK_IS_TABLE (user_data),
397 droute_not_yet_handled_error (message));
398 count = atk_table_get_selected_columns (table, &selected_columns);
399 if (!selected_columns)
401 reply = dbus_message_new_method_return (message);
404 /* tbd - figure out if this is safe for a 0-length array */
405 dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32,
406 &selected_columns, count, DBUS_TYPE_INVALID);
408 if (selected_columns)
409 g_free (selected_columns);
414 impl_IsRowSelected (DBusConnection * bus, DBusMessage * message,
417 AtkTable *table = (AtkTable *) user_data;
423 g_return_val_if_fail (ATK_IS_TABLE (user_data),
424 droute_not_yet_handled_error (message));
425 dbus_error_init (&error);
426 if (!dbus_message_get_args
427 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
429 return droute_invalid_arguments_error (message);
431 ret = atk_table_is_row_selected (table, row);
432 reply = dbus_message_new_method_return (message);
435 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
442 impl_IsColumnSelected (DBusConnection * bus, DBusMessage * message,
445 AtkTable *table = (AtkTable *) user_data;
451 g_return_val_if_fail (ATK_IS_TABLE (user_data),
452 droute_not_yet_handled_error (message));
453 dbus_error_init (&error);
454 if (!dbus_message_get_args
455 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
457 return droute_invalid_arguments_error (message);
459 ret = atk_table_is_column_selected (table, column);
460 reply = dbus_message_new_method_return (message);
463 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
470 impl_IsSelected (DBusConnection * bus, DBusMessage * message, void *user_data)
472 AtkTable *table = (AtkTable *) user_data;
473 dbus_int32_t row, column;
478 g_return_val_if_fail (ATK_IS_TABLE (user_data),
479 droute_not_yet_handled_error (message));
480 dbus_error_init (&error);
481 if (!dbus_message_get_args
482 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
485 return droute_invalid_arguments_error (message);
487 ret = atk_table_is_selected (table, row, column);
488 reply = dbus_message_new_method_return (message);
491 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
498 impl_AddRowSelection (DBusConnection * bus, DBusMessage * message,
501 AtkTable *table = (AtkTable *) user_data;
507 g_return_val_if_fail (ATK_IS_TABLE (user_data),
508 droute_not_yet_handled_error (message));
509 dbus_error_init (&error);
510 if (!dbus_message_get_args
511 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
513 return droute_invalid_arguments_error (message);
515 ret = atk_table_add_row_selection (table, row);
516 reply = dbus_message_new_method_return (message);
519 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
526 impl_AddColumnSelection (DBusConnection * bus, DBusMessage * message,
529 AtkTable *table = (AtkTable *) user_data;
535 g_return_val_if_fail (ATK_IS_TABLE (user_data),
536 droute_not_yet_handled_error (message));
537 dbus_error_init (&error);
538 if (!dbus_message_get_args
539 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
541 return droute_invalid_arguments_error (message);
543 ret = atk_table_add_column_selection (table, column);
544 reply = dbus_message_new_method_return (message);
547 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
554 impl_RemoveRowSelection (DBusConnection * bus, DBusMessage * message,
557 AtkTable *table = (AtkTable *) user_data;
563 g_return_val_if_fail (ATK_IS_TABLE (user_data),
564 droute_not_yet_handled_error (message));
565 dbus_error_init (&error);
566 if (!dbus_message_get_args
567 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
569 return droute_invalid_arguments_error (message);
571 ret = atk_table_remove_row_selection (table, row);
572 reply = dbus_message_new_method_return (message);
575 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
582 impl_RemoveColumnSelection (DBusConnection * bus, DBusMessage * message,
585 AtkTable *table = (AtkTable *) user_data;
591 g_return_val_if_fail (ATK_IS_TABLE (user_data),
592 droute_not_yet_handled_error (message));
593 dbus_error_init (&error);
594 if (!dbus_message_get_args
595 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
597 return droute_invalid_arguments_error (message);
599 ret = atk_table_remove_column_selection (table, column);
600 reply = dbus_message_new_method_return (message);
603 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
610 impl_GetRowColumnExtentsAtIndex (DBusConnection * bus, DBusMessage * message,
613 AtkTable *table = (AtkTable *) user_data;
616 dbus_int32_t row, column, row_extents, col_extents;
617 dbus_bool_t is_selected;
624 g_return_val_if_fail (ATK_IS_TABLE (user_data),
625 droute_not_yet_handled_error (message));
626 dbus_error_init (&error);
627 if (!dbus_message_get_args
628 (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
630 return droute_invalid_arguments_error (message);
632 column = atk_table_get_column_at_index (table, index);
633 row = atk_table_get_row_at_index (table, index);
634 row_extents = atk_table_get_row_extent_at (table, row, column);
635 col_extents = atk_table_get_column_extent_at (table, row, column);
636 is_selected = atk_table_is_selected (table, row, column);
637 cell = atk_table_ref_at (table, row, column);
638 role = atk_object_get_role (cell);
639 g_object_unref (cell);
640 ret = (role == ATK_ROLE_TABLE_CELL ? TRUE : FALSE);
641 reply = dbus_message_new_method_return (message);
644 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
645 DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32,
646 &column, DBUS_TYPE_INT32, &row_extents,
647 DBUS_TYPE_INT32, &col_extents,
648 DBUS_TYPE_BOOLEAN, &is_selected,
654 static DRouteMethod methods[] = {
655 {impl_GetAccessibleAt, "GetAccessibleAt"},
656 {impl_GetIndexAt, "GetIndexAt"},
657 {impl_GetRowAtIndex, "GetRowAtIndex"},
658 {impl_GetColumnAtIndex, "GetColumnAtIndex"},
659 {impl_GetRowDescription, "GetRowDescription"},
660 {impl_GetColumnDescription, "GetColumnDescription"},
661 {impl_GetRowExtentAt, "GetRowExtentAt"},
662 {impl_GetColumnExtentAt, "GetColumnExtentAt"},
663 {impl_GetRowHeader, "GetRowHeader"},
664 {impl_GetColumnHeader, "GetColumnHeader"},
665 {impl_GetSelectedRows, "GetSelectedRows"},
666 {impl_GetSelectedColumns, "GetSelectedColumns"},
667 {impl_IsRowSelected, "IsRowSelected"},
668 {impl_IsColumnSelected, "IsColumnSelected"},
669 {impl_IsSelected, "IsSelected"},
670 {impl_AddRowSelection, "AddRowSelection"},
671 {impl_AddColumnSelection, "AddColumnSelection"},
672 {impl_RemoveRowSelection, "RemoveRowSelection"},
673 {impl_RemoveColumnSelection, "RemoveColumnSelection"},
674 {impl_GetRowColumnExtentsAtIndex, "GetRowColumnExtentsAtIndex"},
678 static DRouteProperty properties[] = {
679 {impl_get_NRows, NULL, "NRows"},
680 {impl_get_NColumns, NULL, "NColumns"},
681 {impl_get_Caption, NULL, "Caption"},
682 {impl_get_Summary, NULL, "Summary"},
683 {impl_get_NSelectedRows, NULL, "nSelectedRows"},
684 {impl_get_NSelectedColumns, NULL, "nSelectedColumns"},
689 spi_initialize_table (DRoutePath *path)
691 droute_path_add_interface (path,
692 SPI_DBUS_INTERFACE_TABLE,