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>
31 #include "introspection.h"
34 impl_get_NRows (DBusMessageIter * iter, void *user_data)
36 AtkTable *table = (AtkTable *) user_data;
37 g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
38 return droute_return_v_int32 (iter, atk_table_get_n_rows (table));
42 impl_get_NColumns (DBusMessageIter * iter, void *user_data)
44 AtkTable *table = (AtkTable *) user_data;
45 g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
46 return droute_return_v_int32 (iter, atk_table_get_n_columns (table));
50 impl_get_Caption (DBusMessageIter * iter, void *user_data)
52 AtkTable *table = (AtkTable *) user_data;
53 g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
54 spi_object_append_v_reference (iter, atk_table_get_caption (table));
59 impl_get_Summary (DBusMessageIter * iter, void *user_data)
61 AtkTable *table = (AtkTable *) user_data;
62 g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
63 spi_object_append_v_reference (iter, atk_table_get_summary (table));
68 impl_get_NSelectedRows (DBusMessageIter * iter, void *user_data)
70 AtkTable *table = (AtkTable *) user_data;
71 gint *selected_rows = NULL;
73 g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
74 count = atk_table_get_selected_rows (table, &selected_rows);
76 g_free (selected_rows);
77 return droute_return_v_int32 (iter, count);
81 impl_get_NSelectedColumns (DBusMessageIter * iter, void *user_data)
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 if (!dbus_message_get_args
105 (message, NULL, 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 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;
126 g_return_val_if_fail (ATK_IS_TABLE (user_data),
127 droute_not_yet_handled_error (message));
128 if (!dbus_message_get_args
129 (message, NULL, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
132 return droute_invalid_arguments_error (message);
134 index = atk_table_get_index_at (table, row, column);
135 reply = dbus_message_new_method_return (message);
138 dbus_message_append_args (reply, DBUS_TYPE_INT32, &index,
145 impl_GetRowAtIndex (DBusConnection * bus, DBusMessage * message,
148 AtkTable *table = (AtkTable *) user_data;
153 g_return_val_if_fail (ATK_IS_TABLE (user_data),
154 droute_not_yet_handled_error (message));
155 if (!dbus_message_get_args
156 (message, NULL, 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;
179 g_return_val_if_fail (ATK_IS_TABLE (user_data),
180 droute_not_yet_handled_error (message));
181 if (!dbus_message_get_args
182 (message, NULL, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
184 return droute_invalid_arguments_error (message);
186 column = atk_table_get_column_at_index (table, index);
187 reply = dbus_message_new_method_return (message);
190 dbus_message_append_args (reply, DBUS_TYPE_INT32, &column,
197 validate_unallocated_string (const gchar *str)
201 if (!g_utf8_validate (str, -1, NULL))
203 g_warning ("atk-bridge: received bad UTF-8 string from a table function");
210 impl_GetRowDescription (DBusConnection * bus, DBusMessage * message,
214 AtkTable *table = (AtkTable *) user_data;
215 const gchar *description;
218 g_return_val_if_fail (ATK_IS_TABLE (user_data),
219 droute_not_yet_handled_error (message));
220 if (!dbus_message_get_args
221 (message, NULL, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
223 return droute_invalid_arguments_error (message);
225 description = atk_table_get_row_description (table, row);
226 description = validate_unallocated_string (description);
227 reply = dbus_message_new_method_return (message);
230 dbus_message_append_args (reply, DBUS_TYPE_STRING, &description,
237 impl_GetColumnDescription (DBusConnection * bus, DBusMessage * message,
240 AtkTable *table = (AtkTable *) user_data;
242 const char *description;
245 g_return_val_if_fail (ATK_IS_TABLE (user_data),
246 droute_not_yet_handled_error (message));
247 if (!dbus_message_get_args
248 (message, NULL, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
250 return droute_invalid_arguments_error (message);
252 description = atk_table_get_column_description (table, column);
253 description = validate_unallocated_string (description);
254 reply = dbus_message_new_method_return (message);
257 dbus_message_append_args (reply, DBUS_TYPE_STRING, &description,
264 impl_GetRowExtentAt (DBusConnection * bus, DBusMessage * message,
267 AtkTable *table = (AtkTable *) user_data;
268 dbus_int32_t row, column;
272 g_return_val_if_fail (ATK_IS_TABLE (user_data),
273 droute_not_yet_handled_error (message));
274 if (!dbus_message_get_args
275 (message, NULL, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
278 return droute_invalid_arguments_error (message);
280 extent = atk_table_get_row_extent_at (table, row, column);
281 reply = dbus_message_new_method_return (message);
284 dbus_message_append_args (reply, DBUS_TYPE_INT32, &extent,
291 impl_GetColumnExtentAt (DBusConnection * bus, DBusMessage * message,
294 AtkTable *table = (AtkTable *) user_data;
295 dbus_int32_t row, column;
299 g_return_val_if_fail (ATK_IS_TABLE (user_data),
300 droute_not_yet_handled_error (message));
301 if (!dbus_message_get_args
302 (message, NULL, 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;
323 AtkObject *obj = NULL;
325 g_return_val_if_fail (ATK_IS_TABLE (user_data),
326 droute_not_yet_handled_error (message));
327 if (!dbus_message_get_args
328 (message, NULL, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
330 return droute_invalid_arguments_error (message);
332 obj = atk_table_get_row_header (table, row);
333 return spi_object_return_reference (message, obj);
337 impl_GetColumnHeader (DBusConnection * bus, DBusMessage * message,
340 AtkTable *table = (AtkTable *) user_data;
344 g_return_val_if_fail (ATK_IS_TABLE (user_data),
345 droute_not_yet_handled_error (message));
346 if (!dbus_message_get_args
347 (message, NULL, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
349 return droute_invalid_arguments_error (message);
351 obj = atk_table_get_column_header (table, column);
352 return spi_object_return_reference (message, obj);
356 impl_GetSelectedRows (DBusConnection * bus, DBusMessage * message,
359 AtkTable *table = (AtkTable *) user_data;
360 gint *selected_rows = NULL;
364 g_return_val_if_fail (ATK_IS_TABLE (user_data),
365 droute_not_yet_handled_error (message));
366 count = atk_table_get_selected_rows (table, &selected_rows);
369 reply = dbus_message_new_method_return (message);
372 /* tbd - figure out if this is safe for a 0-length array */
373 dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32,
374 &selected_rows, count, DBUS_TYPE_INVALID);
377 g_free (selected_rows);
382 impl_GetSelectedColumns (DBusConnection * bus, DBusMessage * message,
385 AtkTable *table = (AtkTable *) user_data;
386 gint *selected_columns = NULL;
390 g_return_val_if_fail (ATK_IS_TABLE (user_data),
391 droute_not_yet_handled_error (message));
392 count = atk_table_get_selected_columns (table, &selected_columns);
393 if (!selected_columns)
395 reply = dbus_message_new_method_return (message);
398 /* tbd - figure out if this is safe for a 0-length array */
399 dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32,
400 &selected_columns, count, DBUS_TYPE_INVALID);
402 if (selected_columns)
403 g_free (selected_columns);
408 impl_IsRowSelected (DBusConnection * bus, DBusMessage * message,
411 AtkTable *table = (AtkTable *) user_data;
416 g_return_val_if_fail (ATK_IS_TABLE (user_data),
417 droute_not_yet_handled_error (message));
418 if (!dbus_message_get_args
419 (message, NULL, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
421 return droute_invalid_arguments_error (message);
423 ret = atk_table_is_row_selected (table, row);
424 reply = dbus_message_new_method_return (message);
427 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
434 impl_IsColumnSelected (DBusConnection * bus, DBusMessage * message,
437 AtkTable *table = (AtkTable *) user_data;
442 g_return_val_if_fail (ATK_IS_TABLE (user_data),
443 droute_not_yet_handled_error (message));
444 if (!dbus_message_get_args
445 (message, NULL, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
447 return droute_invalid_arguments_error (message);
449 ret = atk_table_is_column_selected (table, column);
450 reply = dbus_message_new_method_return (message);
453 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
460 impl_IsSelected (DBusConnection * bus, DBusMessage * message, void *user_data)
462 AtkTable *table = (AtkTable *) user_data;
463 dbus_int32_t row, column;
467 g_return_val_if_fail (ATK_IS_TABLE (user_data),
468 droute_not_yet_handled_error (message));
469 if (!dbus_message_get_args
470 (message, NULL, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
473 return droute_invalid_arguments_error (message);
475 ret = atk_table_is_selected (table, row, column);
476 reply = dbus_message_new_method_return (message);
479 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
486 impl_AddRowSelection (DBusConnection * bus, DBusMessage * message,
489 AtkTable *table = (AtkTable *) user_data;
494 g_return_val_if_fail (ATK_IS_TABLE (user_data),
495 droute_not_yet_handled_error (message));
496 if (!dbus_message_get_args
497 (message, NULL, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
499 return droute_invalid_arguments_error (message);
501 ret = atk_table_add_row_selection (table, row);
502 reply = dbus_message_new_method_return (message);
505 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
512 impl_AddColumnSelection (DBusConnection * bus, DBusMessage * message,
515 AtkTable *table = (AtkTable *) user_data;
520 g_return_val_if_fail (ATK_IS_TABLE (user_data),
521 droute_not_yet_handled_error (message));
522 if (!dbus_message_get_args
523 (message, NULL, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
525 return droute_invalid_arguments_error (message);
527 ret = atk_table_add_column_selection (table, column);
528 reply = dbus_message_new_method_return (message);
531 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
538 impl_RemoveRowSelection (DBusConnection * bus, DBusMessage * message,
541 AtkTable *table = (AtkTable *) user_data;
546 g_return_val_if_fail (ATK_IS_TABLE (user_data),
547 droute_not_yet_handled_error (message));
548 if (!dbus_message_get_args
549 (message, NULL, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
551 return droute_invalid_arguments_error (message);
553 ret = atk_table_remove_row_selection (table, row);
554 reply = dbus_message_new_method_return (message);
557 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
564 impl_RemoveColumnSelection (DBusConnection * bus, DBusMessage * message,
567 AtkTable *table = (AtkTable *) user_data;
572 g_return_val_if_fail (ATK_IS_TABLE (user_data),
573 droute_not_yet_handled_error (message));
574 if (!dbus_message_get_args
575 (message, NULL, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
577 return droute_invalid_arguments_error (message);
579 ret = atk_table_remove_column_selection (table, column);
580 reply = dbus_message_new_method_return (message);
583 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
590 impl_GetRowColumnExtentsAtIndex (DBusConnection * bus, DBusMessage * message,
593 AtkTable *table = (AtkTable *) user_data;
595 dbus_int32_t row, column, row_extents, col_extents;
596 dbus_bool_t is_selected;
600 AtkRole role = ATK_ROLE_INVALID;
602 g_return_val_if_fail (ATK_IS_TABLE (user_data),
603 droute_not_yet_handled_error (message));
604 if (!dbus_message_get_args
605 (message, NULL, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
607 return droute_invalid_arguments_error (message);
609 column = atk_table_get_column_at_index (table, index);
610 row = atk_table_get_row_at_index (table, index);
611 row_extents = atk_table_get_row_extent_at (table, row, column);
612 col_extents = atk_table_get_column_extent_at (table, row, column);
613 is_selected = atk_table_is_selected (table, row, column);
614 cell = atk_table_ref_at (table, row, column);
617 role = atk_object_get_role (cell);
618 g_object_unref (cell);
620 ret = (role == ATK_ROLE_TABLE_CELL ? TRUE : FALSE);
621 reply = dbus_message_new_method_return (message);
624 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
625 DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32,
626 &column, DBUS_TYPE_INT32, &row_extents,
627 DBUS_TYPE_INT32, &col_extents,
628 DBUS_TYPE_BOOLEAN, &is_selected,
634 static DRouteMethod methods[] = {
635 {impl_GetAccessibleAt, "GetAccessibleAt"},
636 {impl_GetIndexAt, "GetIndexAt"},
637 {impl_GetRowAtIndex, "GetRowAtIndex"},
638 {impl_GetColumnAtIndex, "GetColumnAtIndex"},
639 {impl_GetRowDescription, "GetRowDescription"},
640 {impl_GetColumnDescription, "GetColumnDescription"},
641 {impl_GetRowExtentAt, "GetRowExtentAt"},
642 {impl_GetColumnExtentAt, "GetColumnExtentAt"},
643 {impl_GetRowHeader, "GetRowHeader"},
644 {impl_GetColumnHeader, "GetColumnHeader"},
645 {impl_GetSelectedRows, "GetSelectedRows"},
646 {impl_GetSelectedColumns, "GetSelectedColumns"},
647 {impl_IsRowSelected, "IsRowSelected"},
648 {impl_IsColumnSelected, "IsColumnSelected"},
649 {impl_IsSelected, "IsSelected"},
650 {impl_AddRowSelection, "AddRowSelection"},
651 {impl_AddColumnSelection, "AddColumnSelection"},
652 {impl_RemoveRowSelection, "RemoveRowSelection"},
653 {impl_RemoveColumnSelection, "RemoveColumnSelection"},
654 {impl_GetRowColumnExtentsAtIndex, "GetRowColumnExtentsAtIndex"},
658 static DRouteProperty properties[] = {
659 {impl_get_NRows, NULL, "NRows"},
660 {impl_get_NColumns, NULL, "NColumns"},
661 {impl_get_Caption, NULL, "Caption"},
662 {impl_get_Summary, NULL, "Summary"},
663 {impl_get_NSelectedRows, NULL, "NSelectedRows"},
664 {impl_get_NSelectedColumns, NULL, "NSelectedColumns"},
669 spi_initialize_table (DRoutePath * path)
671 spi_atk_add_interface (path,
672 ATSPI_DBUS_INTERFACE_TABLE, spi_org_a11y_atspi_Table, methods, properties);