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);
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 validate_unallocated_string (const gchar *str)
207 if (!g_utf8_validate (str, -1, NULL))
209 g_warning ("atk-bridge: received bad UTF-8 string from a table function");
216 impl_GetRowDescription (DBusConnection * bus, DBusMessage * message,
220 AtkTable *table = (AtkTable *) user_data;
221 const gchar *description;
225 g_return_val_if_fail (ATK_IS_TABLE (user_data),
226 droute_not_yet_handled_error (message));
227 dbus_error_init (&error);
228 if (!dbus_message_get_args
229 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
231 return droute_invalid_arguments_error (message);
233 description = atk_table_get_row_description (table, row);
234 description = validate_unallocated_string (description);
235 reply = dbus_message_new_method_return (message);
238 dbus_message_append_args (reply, DBUS_TYPE_STRING, &description,
245 impl_GetColumnDescription (DBusConnection * bus, DBusMessage * message,
248 AtkTable *table = (AtkTable *) user_data;
250 const char *description;
254 g_return_val_if_fail (ATK_IS_TABLE (user_data),
255 droute_not_yet_handled_error (message));
256 dbus_error_init (&error);
257 if (!dbus_message_get_args
258 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
260 return droute_invalid_arguments_error (message);
262 description = atk_table_get_column_description (table, column);
263 description = validate_unallocated_string (description);
264 reply = dbus_message_new_method_return (message);
267 dbus_message_append_args (reply, DBUS_TYPE_STRING, &description,
274 impl_GetRowExtentAt (DBusConnection * bus, DBusMessage * message,
277 AtkTable *table = (AtkTable *) user_data;
278 dbus_int32_t row, column;
283 g_return_val_if_fail (ATK_IS_TABLE (user_data),
284 droute_not_yet_handled_error (message));
285 dbus_error_init (&error);
286 if (!dbus_message_get_args
287 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
290 return droute_invalid_arguments_error (message);
292 extent = atk_table_get_row_extent_at (table, row, column);
293 reply = dbus_message_new_method_return (message);
296 dbus_message_append_args (reply, DBUS_TYPE_INT32, &extent,
303 impl_GetColumnExtentAt (DBusConnection * bus, DBusMessage * message,
306 AtkTable *table = (AtkTable *) user_data;
307 dbus_int32_t row, column;
312 g_return_val_if_fail (ATK_IS_TABLE (user_data),
313 droute_not_yet_handled_error (message));
314 dbus_error_init (&error);
315 if (!dbus_message_get_args
316 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
319 return droute_invalid_arguments_error (message);
321 extent = atk_table_get_column_extent_at (table, row, column);
322 reply = dbus_message_new_method_return (message);
325 dbus_message_append_args (reply, DBUS_TYPE_INT32, &extent,
332 impl_GetRowHeader (DBusConnection * bus, DBusMessage * message,
335 AtkTable *table = (AtkTable *) user_data;
338 AtkObject *obj = NULL;
340 g_return_val_if_fail (ATK_IS_TABLE (user_data),
341 droute_not_yet_handled_error (message));
342 dbus_error_init (&error);
343 if (!dbus_message_get_args
344 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
346 return droute_invalid_arguments_error (message);
348 obj = atk_table_get_row_header (table, row);
349 return spi_object_return_reference (message, obj);
353 impl_GetColumnHeader (DBusConnection * bus, DBusMessage * message,
356 AtkTable *table = (AtkTable *) user_data;
361 g_return_val_if_fail (ATK_IS_TABLE (user_data),
362 droute_not_yet_handled_error (message));
363 dbus_error_init (&error);
364 if (!dbus_message_get_args
365 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
367 return droute_invalid_arguments_error (message);
369 obj = atk_table_get_column_header (table, column);
370 return spi_object_return_reference (message, obj);
374 impl_GetSelectedRows (DBusConnection * bus, DBusMessage * message,
377 AtkTable *table = (AtkTable *) user_data;
378 gint *selected_rows = NULL;
382 g_return_val_if_fail (ATK_IS_TABLE (user_data),
383 droute_not_yet_handled_error (message));
384 count = atk_table_get_selected_rows (table, &selected_rows);
387 reply = dbus_message_new_method_return (message);
390 /* tbd - figure out if this is safe for a 0-length array */
391 dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32,
392 &selected_rows, count, DBUS_TYPE_INVALID);
395 g_free (selected_rows);
400 impl_GetSelectedColumns (DBusConnection * bus, DBusMessage * message,
403 AtkTable *table = (AtkTable *) user_data;
404 gint *selected_columns = NULL;
408 g_return_val_if_fail (ATK_IS_TABLE (user_data),
409 droute_not_yet_handled_error (message));
410 count = atk_table_get_selected_columns (table, &selected_columns);
411 if (!selected_columns)
413 reply = dbus_message_new_method_return (message);
416 /* tbd - figure out if this is safe for a 0-length array */
417 dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32,
418 &selected_columns, count, DBUS_TYPE_INVALID);
420 if (selected_columns)
421 g_free (selected_columns);
426 impl_IsRowSelected (DBusConnection * bus, DBusMessage * message,
429 AtkTable *table = (AtkTable *) user_data;
435 g_return_val_if_fail (ATK_IS_TABLE (user_data),
436 droute_not_yet_handled_error (message));
437 dbus_error_init (&error);
438 if (!dbus_message_get_args
439 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
441 return droute_invalid_arguments_error (message);
443 ret = atk_table_is_row_selected (table, row);
444 reply = dbus_message_new_method_return (message);
447 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
454 impl_IsColumnSelected (DBusConnection * bus, DBusMessage * message,
457 AtkTable *table = (AtkTable *) user_data;
463 g_return_val_if_fail (ATK_IS_TABLE (user_data),
464 droute_not_yet_handled_error (message));
465 dbus_error_init (&error);
466 if (!dbus_message_get_args
467 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
469 return droute_invalid_arguments_error (message);
471 ret = atk_table_is_column_selected (table, column);
472 reply = dbus_message_new_method_return (message);
475 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
482 impl_IsSelected (DBusConnection * bus, DBusMessage * message, void *user_data)
484 AtkTable *table = (AtkTable *) user_data;
485 dbus_int32_t row, column;
490 g_return_val_if_fail (ATK_IS_TABLE (user_data),
491 droute_not_yet_handled_error (message));
492 dbus_error_init (&error);
493 if (!dbus_message_get_args
494 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
497 return droute_invalid_arguments_error (message);
499 ret = atk_table_is_selected (table, row, column);
500 reply = dbus_message_new_method_return (message);
503 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
510 impl_AddRowSelection (DBusConnection * bus, DBusMessage * message,
513 AtkTable *table = (AtkTable *) user_data;
519 g_return_val_if_fail (ATK_IS_TABLE (user_data),
520 droute_not_yet_handled_error (message));
521 dbus_error_init (&error);
522 if (!dbus_message_get_args
523 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
525 return droute_invalid_arguments_error (message);
527 ret = atk_table_add_row_selection (table, row);
528 reply = dbus_message_new_method_return (message);
531 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
538 impl_AddColumnSelection (DBusConnection * bus, DBusMessage * message,
541 AtkTable *table = (AtkTable *) user_data;
547 g_return_val_if_fail (ATK_IS_TABLE (user_data),
548 droute_not_yet_handled_error (message));
549 dbus_error_init (&error);
550 if (!dbus_message_get_args
551 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
553 return droute_invalid_arguments_error (message);
555 ret = atk_table_add_column_selection (table, column);
556 reply = dbus_message_new_method_return (message);
559 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
566 impl_RemoveRowSelection (DBusConnection * bus, DBusMessage * message,
569 AtkTable *table = (AtkTable *) user_data;
575 g_return_val_if_fail (ATK_IS_TABLE (user_data),
576 droute_not_yet_handled_error (message));
577 dbus_error_init (&error);
578 if (!dbus_message_get_args
579 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
581 return droute_invalid_arguments_error (message);
583 ret = atk_table_remove_row_selection (table, row);
584 reply = dbus_message_new_method_return (message);
587 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
594 impl_RemoveColumnSelection (DBusConnection * bus, DBusMessage * message,
597 AtkTable *table = (AtkTable *) user_data;
603 g_return_val_if_fail (ATK_IS_TABLE (user_data),
604 droute_not_yet_handled_error (message));
605 dbus_error_init (&error);
606 if (!dbus_message_get_args
607 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
609 return droute_invalid_arguments_error (message);
611 ret = atk_table_remove_column_selection (table, column);
612 reply = dbus_message_new_method_return (message);
615 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
622 impl_GetRowColumnExtentsAtIndex (DBusConnection * bus, DBusMessage * message,
625 AtkTable *table = (AtkTable *) user_data;
628 dbus_int32_t row, column, row_extents, col_extents;
629 dbus_bool_t is_selected;
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);
650 role = atk_object_get_role (cell);
651 g_object_unref (cell);
652 ret = (role == ATK_ROLE_TABLE_CELL ? TRUE : FALSE);
653 reply = dbus_message_new_method_return (message);
656 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
657 DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32,
658 &column, DBUS_TYPE_INT32, &row_extents,
659 DBUS_TYPE_INT32, &col_extents,
660 DBUS_TYPE_BOOLEAN, &is_selected,
666 static DRouteMethod methods[] = {
667 {impl_GetAccessibleAt, "GetAccessibleAt"},
668 {impl_GetIndexAt, "GetIndexAt"},
669 {impl_GetRowAtIndex, "GetRowAtIndex"},
670 {impl_GetColumnAtIndex, "GetColumnAtIndex"},
671 {impl_GetRowDescription, "GetRowDescription"},
672 {impl_GetColumnDescription, "GetColumnDescription"},
673 {impl_GetRowExtentAt, "GetRowExtentAt"},
674 {impl_GetColumnExtentAt, "GetColumnExtentAt"},
675 {impl_GetRowHeader, "GetRowHeader"},
676 {impl_GetColumnHeader, "GetColumnHeader"},
677 {impl_GetSelectedRows, "GetSelectedRows"},
678 {impl_GetSelectedColumns, "GetSelectedColumns"},
679 {impl_IsRowSelected, "IsRowSelected"},
680 {impl_IsColumnSelected, "IsColumnSelected"},
681 {impl_IsSelected, "IsSelected"},
682 {impl_AddRowSelection, "AddRowSelection"},
683 {impl_AddColumnSelection, "AddColumnSelection"},
684 {impl_RemoveRowSelection, "RemoveRowSelection"},
685 {impl_RemoveColumnSelection, "RemoveColumnSelection"},
686 {impl_GetRowColumnExtentsAtIndex, "GetRowColumnExtentsAtIndex"},
690 static DRouteProperty properties[] = {
691 {impl_get_NRows, NULL, "NRows"},
692 {impl_get_NColumns, NULL, "NColumns"},
693 {impl_get_Caption, NULL, "Caption"},
694 {impl_get_Summary, NULL, "Summary"},
695 {impl_get_NSelectedRows, NULL, "NSelectedRows"},
696 {impl_get_NSelectedColumns, NULL, "NSelectedColumns"},
701 spi_initialize_table (DRoutePath * path)
703 droute_path_add_interface (path,
704 ATSPI_DBUS_INTERFACE_TABLE, spi_org_a11y_atspi_Table, methods, properties);