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;
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 reply = spi_object_return_reference (message, obj);
113 g_object_unref (obj);
119 impl_GetIndexAt (DBusConnection * bus, DBusMessage * message, void *user_data)
121 AtkTable *table = (AtkTable *) user_data;
122 dbus_int32_t row, column;
127 g_return_val_if_fail (ATK_IS_TABLE (user_data),
128 droute_not_yet_handled_error (message));
129 dbus_error_init (&error);
130 if (!dbus_message_get_args
131 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
134 return droute_invalid_arguments_error (message);
136 index = atk_table_get_index_at (table, row, column);
137 reply = dbus_message_new_method_return (message);
140 dbus_message_append_args (reply, DBUS_TYPE_INT32, &index,
147 impl_GetRowAtIndex (DBusConnection * bus, DBusMessage * message,
150 AtkTable *table = (AtkTable *) user_data;
156 g_return_val_if_fail (ATK_IS_TABLE (user_data),
157 droute_not_yet_handled_error (message));
158 dbus_error_init (&error);
159 if (!dbus_message_get_args
160 (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
162 return droute_invalid_arguments_error (message);
164 row = atk_table_get_row_at_index (table, index);
165 reply = dbus_message_new_method_return (message);
168 dbus_message_append_args (reply, DBUS_TYPE_INT32, &row,
175 impl_GetColumnAtIndex (DBusConnection * bus, DBusMessage * message,
178 AtkTable *table = (AtkTable *) user_data;
184 g_return_val_if_fail (ATK_IS_TABLE (user_data),
185 droute_not_yet_handled_error (message));
186 dbus_error_init (&error);
187 if (!dbus_message_get_args
188 (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
190 return droute_invalid_arguments_error (message);
192 column = atk_table_get_column_at_index (table, index);
193 reply = dbus_message_new_method_return (message);
196 dbus_message_append_args (reply, DBUS_TYPE_INT32, &column,
203 impl_GetRowDescription (DBusConnection * bus, DBusMessage * message,
207 AtkTable *table = (AtkTable *) user_data;
208 const gchar *description;
212 g_return_val_if_fail (ATK_IS_TABLE (user_data),
213 droute_not_yet_handled_error (message));
214 dbus_error_init (&error);
215 if (!dbus_message_get_args
216 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
218 return droute_invalid_arguments_error (message);
220 description = atk_table_get_row_description (table, row);
223 reply = dbus_message_new_method_return (message);
226 dbus_message_append_args (reply, DBUS_TYPE_STRING, &description,
233 impl_GetColumnDescription (DBusConnection * bus, DBusMessage * message,
236 AtkTable *table = (AtkTable *) user_data;
238 const char *description;
242 g_return_val_if_fail (ATK_IS_TABLE (user_data),
243 droute_not_yet_handled_error (message));
244 dbus_error_init (&error);
245 if (!dbus_message_get_args
246 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
248 return droute_invalid_arguments_error (message);
250 description = atk_table_get_column_description (table, column);
253 reply = dbus_message_new_method_return (message);
256 dbus_message_append_args (reply, DBUS_TYPE_STRING, &description,
263 impl_GetRowExtentAt (DBusConnection * bus, DBusMessage * message,
266 AtkTable *table = (AtkTable *) user_data;
267 dbus_int32_t row, column;
272 g_return_val_if_fail (ATK_IS_TABLE (user_data),
273 droute_not_yet_handled_error (message));
274 dbus_error_init (&error);
275 if (!dbus_message_get_args
276 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
279 return droute_invalid_arguments_error (message);
281 extent = atk_table_get_row_extent_at (table, row, column);
282 reply = dbus_message_new_method_return (message);
285 dbus_message_append_args (reply, DBUS_TYPE_INT32, &extent,
292 impl_GetColumnExtentAt (DBusConnection * bus, DBusMessage * message,
295 AtkTable *table = (AtkTable *) user_data;
296 dbus_int32_t row, column;
301 g_return_val_if_fail (ATK_IS_TABLE (user_data),
302 droute_not_yet_handled_error (message));
303 dbus_error_init (&error);
304 if (!dbus_message_get_args
305 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
308 return droute_invalid_arguments_error (message);
310 extent = atk_table_get_column_extent_at (table, row, column);
311 reply = dbus_message_new_method_return (message);
314 dbus_message_append_args (reply, DBUS_TYPE_INT32, &extent,
321 impl_GetRowHeader (DBusConnection * bus, DBusMessage * message,
324 AtkTable *table = (AtkTable *) user_data;
327 AtkObject *obj = NULL;
329 g_return_val_if_fail (ATK_IS_TABLE (user_data),
330 droute_not_yet_handled_error (message));
331 dbus_error_init (&error);
332 if (!dbus_message_get_args
333 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
335 return droute_invalid_arguments_error (message);
337 obj = atk_table_get_row_header (table, row);
338 return spi_object_return_reference (message, obj);
342 impl_GetColumnHeader (DBusConnection * bus, DBusMessage * message,
345 AtkTable *table = (AtkTable *) user_data;
350 g_return_val_if_fail (ATK_IS_TABLE (user_data),
351 droute_not_yet_handled_error (message));
352 dbus_error_init (&error);
353 if (!dbus_message_get_args
354 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
356 return droute_invalid_arguments_error (message);
358 obj = atk_table_get_column_header (table, column);
359 return spi_object_return_reference (message, obj);
363 impl_GetSelectedRows (DBusConnection * bus, DBusMessage * message,
366 AtkTable *table = (AtkTable *) user_data;
367 gint *selected_rows = NULL;
371 g_return_val_if_fail (ATK_IS_TABLE (user_data),
372 droute_not_yet_handled_error (message));
373 count = atk_table_get_selected_rows (table, &selected_rows);
376 reply = dbus_message_new_method_return (message);
379 /* tbd - figure out if this is safe for a 0-length array */
380 dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32,
381 &selected_rows, count, DBUS_TYPE_INVALID);
384 g_free (selected_rows);
389 impl_GetSelectedColumns (DBusConnection * bus, DBusMessage * message,
392 AtkTable *table = (AtkTable *) user_data;
393 gint *selected_columns = NULL;
397 g_return_val_if_fail (ATK_IS_TABLE (user_data),
398 droute_not_yet_handled_error (message));
399 count = atk_table_get_selected_columns (table, &selected_columns);
400 if (!selected_columns)
402 reply = dbus_message_new_method_return (message);
405 /* tbd - figure out if this is safe for a 0-length array */
406 dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32,
407 &selected_columns, count, DBUS_TYPE_INVALID);
409 if (selected_columns)
410 g_free (selected_columns);
415 impl_IsRowSelected (DBusConnection * bus, DBusMessage * message,
418 AtkTable *table = (AtkTable *) user_data;
424 g_return_val_if_fail (ATK_IS_TABLE (user_data),
425 droute_not_yet_handled_error (message));
426 dbus_error_init (&error);
427 if (!dbus_message_get_args
428 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
430 return droute_invalid_arguments_error (message);
432 ret = atk_table_is_row_selected (table, row);
433 reply = dbus_message_new_method_return (message);
436 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
443 impl_IsColumnSelected (DBusConnection * bus, DBusMessage * message,
446 AtkTable *table = (AtkTable *) user_data;
452 g_return_val_if_fail (ATK_IS_TABLE (user_data),
453 droute_not_yet_handled_error (message));
454 dbus_error_init (&error);
455 if (!dbus_message_get_args
456 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
458 return droute_invalid_arguments_error (message);
460 ret = atk_table_is_column_selected (table, column);
461 reply = dbus_message_new_method_return (message);
464 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
471 impl_IsSelected (DBusConnection * bus, DBusMessage * message, void *user_data)
473 AtkTable *table = (AtkTable *) user_data;
474 dbus_int32_t row, column;
479 g_return_val_if_fail (ATK_IS_TABLE (user_data),
480 droute_not_yet_handled_error (message));
481 dbus_error_init (&error);
482 if (!dbus_message_get_args
483 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
486 return droute_invalid_arguments_error (message);
488 ret = atk_table_is_selected (table, row, column);
489 reply = dbus_message_new_method_return (message);
492 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
499 impl_AddRowSelection (DBusConnection * bus, DBusMessage * message,
502 AtkTable *table = (AtkTable *) user_data;
508 g_return_val_if_fail (ATK_IS_TABLE (user_data),
509 droute_not_yet_handled_error (message));
510 dbus_error_init (&error);
511 if (!dbus_message_get_args
512 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
514 return droute_invalid_arguments_error (message);
516 ret = atk_table_add_row_selection (table, row);
517 reply = dbus_message_new_method_return (message);
520 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
527 impl_AddColumnSelection (DBusConnection * bus, DBusMessage * message,
530 AtkTable *table = (AtkTable *) user_data;
536 g_return_val_if_fail (ATK_IS_TABLE (user_data),
537 droute_not_yet_handled_error (message));
538 dbus_error_init (&error);
539 if (!dbus_message_get_args
540 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
542 return droute_invalid_arguments_error (message);
544 ret = atk_table_add_column_selection (table, column);
545 reply = dbus_message_new_method_return (message);
548 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
555 impl_RemoveRowSelection (DBusConnection * bus, DBusMessage * message,
558 AtkTable *table = (AtkTable *) user_data;
564 g_return_val_if_fail (ATK_IS_TABLE (user_data),
565 droute_not_yet_handled_error (message));
566 dbus_error_init (&error);
567 if (!dbus_message_get_args
568 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
570 return droute_invalid_arguments_error (message);
572 ret = atk_table_remove_row_selection (table, row);
573 reply = dbus_message_new_method_return (message);
576 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
583 impl_RemoveColumnSelection (DBusConnection * bus, DBusMessage * message,
586 AtkTable *table = (AtkTable *) user_data;
592 g_return_val_if_fail (ATK_IS_TABLE (user_data),
593 droute_not_yet_handled_error (message));
594 dbus_error_init (&error);
595 if (!dbus_message_get_args
596 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
598 return droute_invalid_arguments_error (message);
600 ret = atk_table_remove_column_selection (table, column);
601 reply = dbus_message_new_method_return (message);
604 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
611 impl_GetRowColumnExtentsAtIndex (DBusConnection * bus, DBusMessage * message,
614 AtkTable *table = (AtkTable *) user_data;
617 dbus_int32_t row, column, row_extents, col_extents;
618 dbus_bool_t is_selected;
625 g_return_val_if_fail (ATK_IS_TABLE (user_data),
626 droute_not_yet_handled_error (message));
627 dbus_error_init (&error);
628 if (!dbus_message_get_args
629 (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
631 return droute_invalid_arguments_error (message);
633 column = atk_table_get_column_at_index (table, index);
634 row = atk_table_get_row_at_index (table, index);
635 row_extents = atk_table_get_row_extent_at (table, row, column);
636 col_extents = atk_table_get_column_extent_at (table, row, column);
637 is_selected = atk_table_is_selected (table, row, column);
638 cell = atk_table_ref_at (table, row, column);
639 role = atk_object_get_role (cell);
640 g_object_unref (cell);
641 ret = (role == ATK_ROLE_TABLE_CELL ? TRUE : FALSE);
642 reply = dbus_message_new_method_return (message);
645 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
646 DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32,
647 &column, DBUS_TYPE_INT32, &row_extents,
648 DBUS_TYPE_INT32, &col_extents,
649 DBUS_TYPE_BOOLEAN, &is_selected,
655 static DRouteMethod methods[] = {
656 {impl_GetAccessibleAt, "GetAccessibleAt"},
657 {impl_GetIndexAt, "GetIndexAt"},
658 {impl_GetRowAtIndex, "GetRowAtIndex"},
659 {impl_GetColumnAtIndex, "GetColumnAtIndex"},
660 {impl_GetRowDescription, "GetRowDescription"},
661 {impl_GetColumnDescription, "GetColumnDescription"},
662 {impl_GetRowExtentAt, "GetRowExtentAt"},
663 {impl_GetColumnExtentAt, "GetColumnExtentAt"},
664 {impl_GetRowHeader, "GetRowHeader"},
665 {impl_GetColumnHeader, "GetColumnHeader"},
666 {impl_GetSelectedRows, "GetSelectedRows"},
667 {impl_GetSelectedColumns, "GetSelectedColumns"},
668 {impl_IsRowSelected, "IsRowSelected"},
669 {impl_IsColumnSelected, "IsColumnSelected"},
670 {impl_IsSelected, "IsSelected"},
671 {impl_AddRowSelection, "AddRowSelection"},
672 {impl_AddColumnSelection, "AddColumnSelection"},
673 {impl_RemoveRowSelection, "RemoveRowSelection"},
674 {impl_RemoveColumnSelection, "RemoveColumnSelection"},
675 {impl_GetRowColumnExtentsAtIndex, "GetRowColumnExtentsAtIndex"},
679 static DRouteProperty properties[] = {
680 {impl_get_NRows, NULL, "NRows"},
681 {impl_get_NColumns, NULL, "NColumns"},
682 {impl_get_Caption, NULL, "Caption"},
683 {impl_get_Summary, NULL, "Summary"},
684 {impl_get_NSelectedRows, NULL, "NSelectedRows"},
685 {impl_get_NSelectedColumns, NULL, "NSelectedColumns"},
690 spi_initialize_table (DRoutePath * path)
692 droute_path_add_interface (path,
693 SPI_DBUS_INTERFACE_TABLE, spi_org_a11y_atspi_Table, methods, properties);