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;
101 g_return_val_if_fail (ATK_IS_TABLE (user_data),
102 droute_not_yet_handled_error (message));
103 if (!dbus_message_get_args
104 (message, NULL, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
107 return droute_invalid_arguments_error (message);
109 obj = atk_table_ref_at (table, row, column);
110 reply = spi_object_return_reference (message, obj);
112 g_object_unref (obj);
118 impl_GetIndexAt (DBusConnection * bus, DBusMessage * message, void *user_data)
120 AtkTable *table = (AtkTable *) user_data;
121 dbus_int32_t row, column;
125 g_return_val_if_fail (ATK_IS_TABLE (user_data),
126 droute_not_yet_handled_error (message));
127 if (!dbus_message_get_args
128 (message, NULL, 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;
152 g_return_val_if_fail (ATK_IS_TABLE (user_data),
153 droute_not_yet_handled_error (message));
154 if (!dbus_message_get_args
155 (message, NULL, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
157 return droute_invalid_arguments_error (message);
159 row = atk_table_get_row_at_index (table, index);
160 reply = dbus_message_new_method_return (message);
163 dbus_message_append_args (reply, DBUS_TYPE_INT32, &row,
170 impl_GetColumnAtIndex (DBusConnection * bus, DBusMessage * message,
173 AtkTable *table = (AtkTable *) user_data;
178 g_return_val_if_fail (ATK_IS_TABLE (user_data),
179 droute_not_yet_handled_error (message));
180 if (!dbus_message_get_args
181 (message, NULL, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
183 return droute_invalid_arguments_error (message);
185 column = atk_table_get_column_at_index (table, index);
186 reply = dbus_message_new_method_return (message);
189 dbus_message_append_args (reply, DBUS_TYPE_INT32, &column,
196 validate_unallocated_string (const gchar *str)
200 if (!g_utf8_validate (str, -1, NULL))
202 g_warning ("atk-bridge: received bad UTF-8 string from a table function");
209 impl_GetRowDescription (DBusConnection * bus, DBusMessage * message,
213 AtkTable *table = (AtkTable *) user_data;
214 const gchar *description;
217 g_return_val_if_fail (ATK_IS_TABLE (user_data),
218 droute_not_yet_handled_error (message));
219 if (!dbus_message_get_args
220 (message, NULL, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
222 return droute_invalid_arguments_error (message);
224 description = atk_table_get_row_description (table, row);
225 description = validate_unallocated_string (description);
226 reply = dbus_message_new_method_return (message);
229 dbus_message_append_args (reply, DBUS_TYPE_STRING, &description,
236 impl_GetColumnDescription (DBusConnection * bus, DBusMessage * message,
239 AtkTable *table = (AtkTable *) user_data;
241 const char *description;
244 g_return_val_if_fail (ATK_IS_TABLE (user_data),
245 droute_not_yet_handled_error (message));
246 if (!dbus_message_get_args
247 (message, NULL, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
249 return droute_invalid_arguments_error (message);
251 description = atk_table_get_column_description (table, column);
252 description = validate_unallocated_string (description);
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;
271 g_return_val_if_fail (ATK_IS_TABLE (user_data),
272 droute_not_yet_handled_error (message));
273 if (!dbus_message_get_args
274 (message, NULL, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
277 return droute_invalid_arguments_error (message);
279 extent = atk_table_get_row_extent_at (table, row, column);
280 reply = dbus_message_new_method_return (message);
283 dbus_message_append_args (reply, DBUS_TYPE_INT32, &extent,
290 impl_GetColumnExtentAt (DBusConnection * bus, DBusMessage * message,
293 AtkTable *table = (AtkTable *) user_data;
294 dbus_int32_t row, column;
298 g_return_val_if_fail (ATK_IS_TABLE (user_data),
299 droute_not_yet_handled_error (message));
300 if (!dbus_message_get_args
301 (message, NULL, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
304 return droute_invalid_arguments_error (message);
306 extent = atk_table_get_column_extent_at (table, row, column);
307 reply = dbus_message_new_method_return (message);
310 dbus_message_append_args (reply, DBUS_TYPE_INT32, &extent,
317 impl_GetRowHeader (DBusConnection * bus, DBusMessage * message,
320 AtkTable *table = (AtkTable *) user_data;
322 AtkObject *obj = NULL;
324 g_return_val_if_fail (ATK_IS_TABLE (user_data),
325 droute_not_yet_handled_error (message));
326 if (!dbus_message_get_args
327 (message, NULL, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
329 return droute_invalid_arguments_error (message);
331 obj = atk_table_get_row_header (table, row);
332 return spi_object_return_reference (message, obj);
336 impl_GetColumnHeader (DBusConnection * bus, DBusMessage * message,
339 AtkTable *table = (AtkTable *) user_data;
343 g_return_val_if_fail (ATK_IS_TABLE (user_data),
344 droute_not_yet_handled_error (message));
345 if (!dbus_message_get_args
346 (message, NULL, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
348 return droute_invalid_arguments_error (message);
350 obj = atk_table_get_column_header (table, column);
351 return spi_object_return_reference (message, obj);
355 impl_GetSelectedRows (DBusConnection * bus, DBusMessage * message,
358 AtkTable *table = (AtkTable *) user_data;
359 gint *selected_rows = NULL;
363 g_return_val_if_fail (ATK_IS_TABLE (user_data),
364 droute_not_yet_handled_error (message));
365 count = atk_table_get_selected_rows (table, &selected_rows);
368 reply = dbus_message_new_method_return (message);
371 /* tbd - figure out if this is safe for a 0-length array */
372 dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32,
373 &selected_rows, count, DBUS_TYPE_INVALID);
376 g_free (selected_rows);
381 impl_GetSelectedColumns (DBusConnection * bus, DBusMessage * message,
384 AtkTable *table = (AtkTable *) user_data;
385 gint *selected_columns = NULL;
389 g_return_val_if_fail (ATK_IS_TABLE (user_data),
390 droute_not_yet_handled_error (message));
391 count = atk_table_get_selected_columns (table, &selected_columns);
392 if (!selected_columns)
394 reply = dbus_message_new_method_return (message);
397 /* tbd - figure out if this is safe for a 0-length array */
398 dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32,
399 &selected_columns, count, DBUS_TYPE_INVALID);
401 if (selected_columns)
402 g_free (selected_columns);
407 impl_IsRowSelected (DBusConnection * bus, DBusMessage * message,
410 AtkTable *table = (AtkTable *) user_data;
415 g_return_val_if_fail (ATK_IS_TABLE (user_data),
416 droute_not_yet_handled_error (message));
417 if (!dbus_message_get_args
418 (message, NULL, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
420 return droute_invalid_arguments_error (message);
422 ret = atk_table_is_row_selected (table, row);
423 reply = dbus_message_new_method_return (message);
426 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
433 impl_IsColumnSelected (DBusConnection * bus, DBusMessage * message,
436 AtkTable *table = (AtkTable *) user_data;
441 g_return_val_if_fail (ATK_IS_TABLE (user_data),
442 droute_not_yet_handled_error (message));
443 if (!dbus_message_get_args
444 (message, NULL, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
446 return droute_invalid_arguments_error (message);
448 ret = atk_table_is_column_selected (table, column);
449 reply = dbus_message_new_method_return (message);
452 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
459 impl_IsSelected (DBusConnection * bus, DBusMessage * message, void *user_data)
461 AtkTable *table = (AtkTable *) user_data;
462 dbus_int32_t row, column;
466 g_return_val_if_fail (ATK_IS_TABLE (user_data),
467 droute_not_yet_handled_error (message));
468 if (!dbus_message_get_args
469 (message, NULL, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
472 return droute_invalid_arguments_error (message);
474 ret = atk_table_is_selected (table, row, column);
475 reply = dbus_message_new_method_return (message);
478 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
485 impl_AddRowSelection (DBusConnection * bus, DBusMessage * message,
488 AtkTable *table = (AtkTable *) user_data;
493 g_return_val_if_fail (ATK_IS_TABLE (user_data),
494 droute_not_yet_handled_error (message));
495 if (!dbus_message_get_args
496 (message, NULL, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
498 return droute_invalid_arguments_error (message);
500 ret = atk_table_add_row_selection (table, row);
501 reply = dbus_message_new_method_return (message);
504 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
511 impl_AddColumnSelection (DBusConnection * bus, DBusMessage * message,
514 AtkTable *table = (AtkTable *) user_data;
519 g_return_val_if_fail (ATK_IS_TABLE (user_data),
520 droute_not_yet_handled_error (message));
521 if (!dbus_message_get_args
522 (message, NULL, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
524 return droute_invalid_arguments_error (message);
526 ret = atk_table_add_column_selection (table, column);
527 reply = dbus_message_new_method_return (message);
530 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
537 impl_RemoveRowSelection (DBusConnection * bus, DBusMessage * message,
540 AtkTable *table = (AtkTable *) user_data;
545 g_return_val_if_fail (ATK_IS_TABLE (user_data),
546 droute_not_yet_handled_error (message));
547 if (!dbus_message_get_args
548 (message, NULL, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
550 return droute_invalid_arguments_error (message);
552 ret = atk_table_remove_row_selection (table, row);
553 reply = dbus_message_new_method_return (message);
556 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
563 impl_RemoveColumnSelection (DBusConnection * bus, DBusMessage * message,
566 AtkTable *table = (AtkTable *) user_data;
571 g_return_val_if_fail (ATK_IS_TABLE (user_data),
572 droute_not_yet_handled_error (message));
573 if (!dbus_message_get_args
574 (message, NULL, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
576 return droute_invalid_arguments_error (message);
578 ret = atk_table_remove_column_selection (table, column);
579 reply = dbus_message_new_method_return (message);
582 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
589 impl_GetRowColumnExtentsAtIndex (DBusConnection * bus, DBusMessage * message,
592 AtkTable *table = (AtkTable *) user_data;
594 dbus_int32_t row, column, row_extents, col_extents;
595 dbus_bool_t is_selected;
599 AtkRole role = ATK_ROLE_INVALID;
601 g_return_val_if_fail (ATK_IS_TABLE (user_data),
602 droute_not_yet_handled_error (message));
603 if (!dbus_message_get_args
604 (message, NULL, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
606 return droute_invalid_arguments_error (message);
608 column = atk_table_get_column_at_index (table, index);
609 row = atk_table_get_row_at_index (table, index);
610 row_extents = atk_table_get_row_extent_at (table, row, column);
611 col_extents = atk_table_get_column_extent_at (table, row, column);
612 is_selected = atk_table_is_selected (table, row, column);
613 cell = atk_table_ref_at (table, row, column);
616 role = atk_object_get_role (cell);
617 g_object_unref (cell);
619 ret = (role == ATK_ROLE_TABLE_CELL ? TRUE : FALSE);
620 reply = dbus_message_new_method_return (message);
623 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
624 DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32,
625 &column, DBUS_TYPE_INT32, &row_extents,
626 DBUS_TYPE_INT32, &col_extents,
627 DBUS_TYPE_BOOLEAN, &is_selected,
633 static DRouteMethod methods[] = {
634 {impl_GetAccessibleAt, "GetAccessibleAt"},
635 {impl_GetIndexAt, "GetIndexAt"},
636 {impl_GetRowAtIndex, "GetRowAtIndex"},
637 {impl_GetColumnAtIndex, "GetColumnAtIndex"},
638 {impl_GetRowDescription, "GetRowDescription"},
639 {impl_GetColumnDescription, "GetColumnDescription"},
640 {impl_GetRowExtentAt, "GetRowExtentAt"},
641 {impl_GetColumnExtentAt, "GetColumnExtentAt"},
642 {impl_GetRowHeader, "GetRowHeader"},
643 {impl_GetColumnHeader, "GetColumnHeader"},
644 {impl_GetSelectedRows, "GetSelectedRows"},
645 {impl_GetSelectedColumns, "GetSelectedColumns"},
646 {impl_IsRowSelected, "IsRowSelected"},
647 {impl_IsColumnSelected, "IsColumnSelected"},
648 {impl_IsSelected, "IsSelected"},
649 {impl_AddRowSelection, "AddRowSelection"},
650 {impl_AddColumnSelection, "AddColumnSelection"},
651 {impl_RemoveRowSelection, "RemoveRowSelection"},
652 {impl_RemoveColumnSelection, "RemoveColumnSelection"},
653 {impl_GetRowColumnExtentsAtIndex, "GetRowColumnExtentsAtIndex"},
657 static DRouteProperty properties[] = {
658 {impl_get_NRows, NULL, "NRows"},
659 {impl_get_NColumns, NULL, "NColumns"},
660 {impl_get_Caption, NULL, "Caption"},
661 {impl_get_Summary, NULL, "Summary"},
662 {impl_get_NSelectedRows, NULL, "NSelectedRows"},
663 {impl_get_NSelectedColumns, NULL, "NSelectedColumns"},
668 spi_initialize_table (DRoutePath * path)
670 droute_path_add_interface (path,
671 ATSPI_DBUS_INTERFACE_TABLE, spi_org_a11y_atspi_Table, methods, properties);