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>
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);
114 g_object_unref (obj);
120 impl_GetIndexAt (DBusConnection * bus, DBusMessage * message, void *user_data)
122 AtkTable *table = (AtkTable *) user_data;
123 dbus_int32_t row, column;
128 g_return_val_if_fail (ATK_IS_TABLE (user_data),
129 droute_not_yet_handled_error (message));
130 dbus_error_init (&error);
131 if (!dbus_message_get_args
132 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
135 return droute_invalid_arguments_error (message);
137 index = atk_table_get_index_at (table, row, column);
138 reply = dbus_message_new_method_return (message);
141 dbus_message_append_args (reply, DBUS_TYPE_INT32, &index,
148 impl_GetRowAtIndex (DBusConnection * bus, DBusMessage * message,
151 AtkTable *table = (AtkTable *) user_data;
157 g_return_val_if_fail (ATK_IS_TABLE (user_data),
158 droute_not_yet_handled_error (message));
159 dbus_error_init (&error);
160 if (!dbus_message_get_args
161 (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
163 return droute_invalid_arguments_error (message);
165 row = atk_table_get_row_at_index (table, index);
166 reply = dbus_message_new_method_return (message);
169 dbus_message_append_args (reply, DBUS_TYPE_INT32, &row,
176 impl_GetColumnAtIndex (DBusConnection * bus, DBusMessage * message,
179 AtkTable *table = (AtkTable *) user_data;
185 g_return_val_if_fail (ATK_IS_TABLE (user_data),
186 droute_not_yet_handled_error (message));
187 dbus_error_init (&error);
188 if (!dbus_message_get_args
189 (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
191 return droute_invalid_arguments_error (message);
193 column = atk_table_get_column_at_index (table, index);
194 reply = dbus_message_new_method_return (message);
197 dbus_message_append_args (reply, DBUS_TYPE_INT32, &column,
204 validate_unallocated_string (const gchar *str)
208 if (!g_utf8_validate (str, -1, NULL))
210 g_warning ("atk-bridge: received bad UTF-8 string from a table function");
217 impl_GetRowDescription (DBusConnection * bus, DBusMessage * message,
221 AtkTable *table = (AtkTable *) user_data;
222 const gchar *description;
226 g_return_val_if_fail (ATK_IS_TABLE (user_data),
227 droute_not_yet_handled_error (message));
228 dbus_error_init (&error);
229 if (!dbus_message_get_args
230 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
232 return droute_invalid_arguments_error (message);
234 description = atk_table_get_row_description (table, row);
235 description = validate_unallocated_string (description);
236 reply = dbus_message_new_method_return (message);
239 dbus_message_append_args (reply, DBUS_TYPE_STRING, &description,
246 impl_GetColumnDescription (DBusConnection * bus, DBusMessage * message,
249 AtkTable *table = (AtkTable *) user_data;
251 const char *description;
255 g_return_val_if_fail (ATK_IS_TABLE (user_data),
256 droute_not_yet_handled_error (message));
257 dbus_error_init (&error);
258 if (!dbus_message_get_args
259 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
261 return droute_invalid_arguments_error (message);
263 description = atk_table_get_column_description (table, column);
264 description = validate_unallocated_string (description);
265 reply = dbus_message_new_method_return (message);
268 dbus_message_append_args (reply, DBUS_TYPE_STRING, &description,
275 impl_GetRowExtentAt (DBusConnection * bus, DBusMessage * message,
278 AtkTable *table = (AtkTable *) user_data;
279 dbus_int32_t row, column;
284 g_return_val_if_fail (ATK_IS_TABLE (user_data),
285 droute_not_yet_handled_error (message));
286 dbus_error_init (&error);
287 if (!dbus_message_get_args
288 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
291 return droute_invalid_arguments_error (message);
293 extent = atk_table_get_row_extent_at (table, row, column);
294 reply = dbus_message_new_method_return (message);
297 dbus_message_append_args (reply, DBUS_TYPE_INT32, &extent,
304 impl_GetColumnExtentAt (DBusConnection * bus, DBusMessage * message,
307 AtkTable *table = (AtkTable *) user_data;
308 dbus_int32_t row, column;
313 g_return_val_if_fail (ATK_IS_TABLE (user_data),
314 droute_not_yet_handled_error (message));
315 dbus_error_init (&error);
316 if (!dbus_message_get_args
317 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
320 return droute_invalid_arguments_error (message);
322 extent = atk_table_get_column_extent_at (table, row, column);
323 reply = dbus_message_new_method_return (message);
326 dbus_message_append_args (reply, DBUS_TYPE_INT32, &extent,
333 impl_GetRowHeader (DBusConnection * bus, DBusMessage * message,
336 AtkTable *table = (AtkTable *) user_data;
339 AtkObject *obj = NULL;
341 g_return_val_if_fail (ATK_IS_TABLE (user_data),
342 droute_not_yet_handled_error (message));
343 dbus_error_init (&error);
344 if (!dbus_message_get_args
345 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
347 return droute_invalid_arguments_error (message);
349 obj = atk_table_get_row_header (table, row);
350 return spi_object_return_reference (message, obj);
354 impl_GetColumnHeader (DBusConnection * bus, DBusMessage * message,
357 AtkTable *table = (AtkTable *) user_data;
362 g_return_val_if_fail (ATK_IS_TABLE (user_data),
363 droute_not_yet_handled_error (message));
364 dbus_error_init (&error);
365 if (!dbus_message_get_args
366 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
368 return droute_invalid_arguments_error (message);
370 obj = atk_table_get_column_header (table, column);
371 return spi_object_return_reference (message, obj);
375 impl_GetSelectedRows (DBusConnection * bus, DBusMessage * message,
378 AtkTable *table = (AtkTable *) user_data;
379 gint *selected_rows = NULL;
383 g_return_val_if_fail (ATK_IS_TABLE (user_data),
384 droute_not_yet_handled_error (message));
385 count = atk_table_get_selected_rows (table, &selected_rows);
388 reply = dbus_message_new_method_return (message);
391 /* tbd - figure out if this is safe for a 0-length array */
392 dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32,
393 &selected_rows, count, DBUS_TYPE_INVALID);
396 g_free (selected_rows);
401 impl_GetSelectedColumns (DBusConnection * bus, DBusMessage * message,
404 AtkTable *table = (AtkTable *) user_data;
405 gint *selected_columns = NULL;
409 g_return_val_if_fail (ATK_IS_TABLE (user_data),
410 droute_not_yet_handled_error (message));
411 count = atk_table_get_selected_columns (table, &selected_columns);
412 if (!selected_columns)
414 reply = dbus_message_new_method_return (message);
417 /* tbd - figure out if this is safe for a 0-length array */
418 dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32,
419 &selected_columns, count, DBUS_TYPE_INVALID);
421 if (selected_columns)
422 g_free (selected_columns);
427 impl_IsRowSelected (DBusConnection * bus, DBusMessage * message,
430 AtkTable *table = (AtkTable *) user_data;
436 g_return_val_if_fail (ATK_IS_TABLE (user_data),
437 droute_not_yet_handled_error (message));
438 dbus_error_init (&error);
439 if (!dbus_message_get_args
440 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
442 return droute_invalid_arguments_error (message);
444 ret = atk_table_is_row_selected (table, row);
445 reply = dbus_message_new_method_return (message);
448 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
455 impl_IsColumnSelected (DBusConnection * bus, DBusMessage * message,
458 AtkTable *table = (AtkTable *) user_data;
464 g_return_val_if_fail (ATK_IS_TABLE (user_data),
465 droute_not_yet_handled_error (message));
466 dbus_error_init (&error);
467 if (!dbus_message_get_args
468 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
470 return droute_invalid_arguments_error (message);
472 ret = atk_table_is_column_selected (table, column);
473 reply = dbus_message_new_method_return (message);
476 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
483 impl_IsSelected (DBusConnection * bus, DBusMessage * message, void *user_data)
485 AtkTable *table = (AtkTable *) user_data;
486 dbus_int32_t row, column;
491 g_return_val_if_fail (ATK_IS_TABLE (user_data),
492 droute_not_yet_handled_error (message));
493 dbus_error_init (&error);
494 if (!dbus_message_get_args
495 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
498 return droute_invalid_arguments_error (message);
500 ret = atk_table_is_selected (table, row, column);
501 reply = dbus_message_new_method_return (message);
504 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
511 impl_AddRowSelection (DBusConnection * bus, DBusMessage * message,
514 AtkTable *table = (AtkTable *) user_data;
520 g_return_val_if_fail (ATK_IS_TABLE (user_data),
521 droute_not_yet_handled_error (message));
522 dbus_error_init (&error);
523 if (!dbus_message_get_args
524 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
526 return droute_invalid_arguments_error (message);
528 ret = atk_table_add_row_selection (table, row);
529 reply = dbus_message_new_method_return (message);
532 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
539 impl_AddColumnSelection (DBusConnection * bus, DBusMessage * message,
542 AtkTable *table = (AtkTable *) user_data;
548 g_return_val_if_fail (ATK_IS_TABLE (user_data),
549 droute_not_yet_handled_error (message));
550 dbus_error_init (&error);
551 if (!dbus_message_get_args
552 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
554 return droute_invalid_arguments_error (message);
556 ret = atk_table_add_column_selection (table, column);
557 reply = dbus_message_new_method_return (message);
560 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
567 impl_RemoveRowSelection (DBusConnection * bus, DBusMessage * message,
570 AtkTable *table = (AtkTable *) user_data;
576 g_return_val_if_fail (ATK_IS_TABLE (user_data),
577 droute_not_yet_handled_error (message));
578 dbus_error_init (&error);
579 if (!dbus_message_get_args
580 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
582 return droute_invalid_arguments_error (message);
584 ret = atk_table_remove_row_selection (table, row);
585 reply = dbus_message_new_method_return (message);
588 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
595 impl_RemoveColumnSelection (DBusConnection * bus, DBusMessage * message,
598 AtkTable *table = (AtkTable *) user_data;
604 g_return_val_if_fail (ATK_IS_TABLE (user_data),
605 droute_not_yet_handled_error (message));
606 dbus_error_init (&error);
607 if (!dbus_message_get_args
608 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
610 return droute_invalid_arguments_error (message);
612 ret = atk_table_remove_column_selection (table, column);
613 reply = dbus_message_new_method_return (message);
616 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
623 impl_GetRowColumnExtentsAtIndex (DBusConnection * bus, DBusMessage * message,
626 AtkTable *table = (AtkTable *) user_data;
629 dbus_int32_t row, column, row_extents, col_extents;
630 dbus_bool_t is_selected;
634 AtkRole role = ATK_ROLE_INVALID;
636 g_return_val_if_fail (ATK_IS_TABLE (user_data),
637 droute_not_yet_handled_error (message));
638 dbus_error_init (&error);
639 if (!dbus_message_get_args
640 (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
642 return droute_invalid_arguments_error (message);
644 column = atk_table_get_column_at_index (table, index);
645 row = atk_table_get_row_at_index (table, index);
646 row_extents = atk_table_get_row_extent_at (table, row, column);
647 col_extents = atk_table_get_column_extent_at (table, row, column);
648 is_selected = atk_table_is_selected (table, row, column);
649 cell = atk_table_ref_at (table, row, column);
652 role = atk_object_get_role (cell);
653 g_object_unref (cell);
655 ret = (role == ATK_ROLE_TABLE_CELL ? TRUE : FALSE);
656 reply = dbus_message_new_method_return (message);
659 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
660 DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32,
661 &column, DBUS_TYPE_INT32, &row_extents,
662 DBUS_TYPE_INT32, &col_extents,
663 DBUS_TYPE_BOOLEAN, &is_selected,
669 static DRouteMethod methods[] = {
670 {impl_GetAccessibleAt, "GetAccessibleAt"},
671 {impl_GetIndexAt, "GetIndexAt"},
672 {impl_GetRowAtIndex, "GetRowAtIndex"},
673 {impl_GetColumnAtIndex, "GetColumnAtIndex"},
674 {impl_GetRowDescription, "GetRowDescription"},
675 {impl_GetColumnDescription, "GetColumnDescription"},
676 {impl_GetRowExtentAt, "GetRowExtentAt"},
677 {impl_GetColumnExtentAt, "GetColumnExtentAt"},
678 {impl_GetRowHeader, "GetRowHeader"},
679 {impl_GetColumnHeader, "GetColumnHeader"},
680 {impl_GetSelectedRows, "GetSelectedRows"},
681 {impl_GetSelectedColumns, "GetSelectedColumns"},
682 {impl_IsRowSelected, "IsRowSelected"},
683 {impl_IsColumnSelected, "IsColumnSelected"},
684 {impl_IsSelected, "IsSelected"},
685 {impl_AddRowSelection, "AddRowSelection"},
686 {impl_AddColumnSelection, "AddColumnSelection"},
687 {impl_RemoveRowSelection, "RemoveRowSelection"},
688 {impl_RemoveColumnSelection, "RemoveColumnSelection"},
689 {impl_GetRowColumnExtentsAtIndex, "GetRowColumnExtentsAtIndex"},
693 static DRouteProperty properties[] = {
694 {impl_get_NRows, NULL, "NRows"},
695 {impl_get_NColumns, NULL, "NColumns"},
696 {impl_get_Caption, NULL, "Caption"},
697 {impl_get_Summary, NULL, "Summary"},
698 {impl_get_NSelectedRows, NULL, "NSelectedRows"},
699 {impl_get_NSelectedColumns, NULL, "NSelectedColumns"},
704 spi_initialize_table (DRoutePath * path)
706 droute_path_add_interface (path,
707 ATSPI_DBUS_INTERFACE_TABLE, spi_org_a11y_atspi_Table, methods, properties);