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"
32 impl_get_NRows (DBusMessageIter * iter, void *user_data)
34 AtkTable *table = (AtkTable *) user_data;
35 g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
36 return droute_return_v_int32 (iter, atk_table_get_n_rows (table));
40 impl_get_NColumns (DBusMessageIter * iter, void *user_data)
42 AtkTable *table = (AtkTable *) user_data;
43 g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
44 return droute_return_v_int32 (iter, atk_table_get_n_columns (table));
48 impl_get_Caption (DBusMessageIter * iter, void *user_data)
50 AtkTable *table = (AtkTable *) user_data;
51 g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
52 spi_object_append_v_reference (iter, atk_table_get_caption (table));
57 impl_get_Summary (DBusMessageIter * iter, void *user_data)
59 AtkTable *table = (AtkTable *) user_data;
60 g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
61 spi_object_append_v_reference (iter, atk_table_get_summary (table));
66 impl_get_NSelectedRows (DBusMessageIter * iter, void *user_data)
68 AtkTable *table = (AtkTable *) user_data;
69 gint *selected_rows = NULL;
71 g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
72 count = atk_table_get_selected_rows (table, &selected_rows);
74 g_free (selected_rows);
75 return droute_return_v_int32 (iter, count);
79 impl_get_NSelectedColumns (DBusMessageIter * iter, void *user_data)
81 AtkTable *table = (AtkTable *) user_data;
82 gint *selected_columns = NULL;
84 g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
85 count = atk_table_get_selected_columns (table, &selected_columns);
87 g_free (selected_columns);
88 return droute_return_v_int32 (iter, count);
92 impl_GetAccessibleAt (DBusConnection * bus, DBusMessage * message,
95 AtkTable *table = (AtkTable *) user_data;
96 dbus_int32_t row, column;
100 g_return_val_if_fail (ATK_IS_TABLE (user_data),
101 droute_not_yet_handled_error (message));
102 dbus_error_init (&error);
103 if (!dbus_message_get_args
104 (message, &error, 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 return spi_object_return_reference (message, obj);
114 impl_GetIndexAt (DBusConnection * bus, DBusMessage * message, void *user_data)
116 AtkTable *table = (AtkTable *) user_data;
117 dbus_int32_t row, column;
122 g_return_val_if_fail (ATK_IS_TABLE (user_data),
123 droute_not_yet_handled_error (message));
124 dbus_error_init (&error);
125 if (!dbus_message_get_args
126 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
129 return droute_invalid_arguments_error (message);
131 index = atk_table_get_index_at (table, row, column);
132 reply = dbus_message_new_method_return (message);
135 dbus_message_append_args (reply, DBUS_TYPE_INT32, &index,
142 impl_GetRowAtIndex (DBusConnection * bus, DBusMessage * message,
145 AtkTable *table = (AtkTable *) user_data;
151 g_return_val_if_fail (ATK_IS_TABLE (user_data),
152 droute_not_yet_handled_error (message));
153 dbus_error_init (&error);
154 if (!dbus_message_get_args
155 (message, &error, 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;
179 g_return_val_if_fail (ATK_IS_TABLE (user_data),
180 droute_not_yet_handled_error (message));
181 dbus_error_init (&error);
182 if (!dbus_message_get_args
183 (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
185 return droute_invalid_arguments_error (message);
187 column = atk_table_get_column_at_index (table, index);
188 reply = dbus_message_new_method_return (message);
191 dbus_message_append_args (reply, DBUS_TYPE_INT32, &column,
198 impl_GetRowDescription (DBusConnection * bus, DBusMessage * message,
202 AtkTable *table = (AtkTable *) user_data;
203 const gchar *description;
207 g_return_val_if_fail (ATK_IS_TABLE (user_data),
208 droute_not_yet_handled_error (message));
209 dbus_error_init (&error);
210 if (!dbus_message_get_args
211 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
213 return droute_invalid_arguments_error (message);
215 description = atk_table_get_row_description (table, row);
218 reply = dbus_message_new_method_return (message);
221 dbus_message_append_args (reply, DBUS_TYPE_STRING, &description,
228 impl_GetColumnDescription (DBusConnection * bus, DBusMessage * message,
231 AtkTable *table = (AtkTable *) user_data;
233 const char *description;
237 g_return_val_if_fail (ATK_IS_TABLE (user_data),
238 droute_not_yet_handled_error (message));
239 dbus_error_init (&error);
240 if (!dbus_message_get_args
241 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
243 return droute_invalid_arguments_error (message);
245 description = atk_table_get_column_description (table, column);
248 reply = dbus_message_new_method_return (message);
251 dbus_message_append_args (reply, DBUS_TYPE_STRING, &description,
258 impl_GetRowExtentAt (DBusConnection * bus, DBusMessage * message,
261 AtkTable *table = (AtkTable *) user_data;
262 dbus_int32_t row, column;
267 g_return_val_if_fail (ATK_IS_TABLE (user_data),
268 droute_not_yet_handled_error (message));
269 dbus_error_init (&error);
270 if (!dbus_message_get_args
271 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
274 return droute_invalid_arguments_error (message);
276 extent = atk_table_get_row_extent_at (table, row, column);
277 reply = dbus_message_new_method_return (message);
280 dbus_message_append_args (reply, DBUS_TYPE_INT32, &extent,
287 impl_GetColumnExtentAt (DBusConnection * bus, DBusMessage * message,
290 AtkTable *table = (AtkTable *) user_data;
291 dbus_int32_t row, column;
296 g_return_val_if_fail (ATK_IS_TABLE (user_data),
297 droute_not_yet_handled_error (message));
298 dbus_error_init (&error);
299 if (!dbus_message_get_args
300 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
303 return droute_invalid_arguments_error (message);
305 extent = atk_table_get_column_extent_at (table, row, column);
306 reply = dbus_message_new_method_return (message);
309 dbus_message_append_args (reply, DBUS_TYPE_INT32, &extent,
316 impl_GetRowHeader (DBusConnection * bus, DBusMessage * message,
319 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 dbus_error_init (&error);
327 if (!dbus_message_get_args
328 (message, &error, 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;
345 g_return_val_if_fail (ATK_IS_TABLE (user_data),
346 droute_not_yet_handled_error (message));
347 dbus_error_init (&error);
348 if (!dbus_message_get_args
349 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
351 return droute_invalid_arguments_error (message);
353 obj = atk_table_get_column_header (table, column);
354 obj = atk_table_get_column_header (table, column);
355 return spi_object_return_reference (message, obj);
359 impl_GetSelectedRows (DBusConnection * bus, DBusMessage * message,
362 AtkTable *table = (AtkTable *) user_data;
363 gint *selected_rows = NULL;
367 g_return_val_if_fail (ATK_IS_TABLE (user_data),
368 droute_not_yet_handled_error (message));
369 count = atk_table_get_selected_rows (table, &selected_rows);
372 reply = dbus_message_new_method_return (message);
375 /* tbd - figure out if this is safe for a 0-length array */
376 dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32,
377 &selected_rows, count, DBUS_TYPE_INVALID);
380 g_free (selected_rows);
385 impl_GetSelectedColumns (DBusConnection * bus, DBusMessage * message,
388 AtkTable *table = (AtkTable *) user_data;
389 gint *selected_columns = NULL;
393 g_return_val_if_fail (ATK_IS_TABLE (user_data),
394 droute_not_yet_handled_error (message));
395 count = atk_table_get_selected_columns (table, &selected_columns);
396 if (!selected_columns)
398 reply = dbus_message_new_method_return (message);
401 /* tbd - figure out if this is safe for a 0-length array */
402 dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32,
403 &selected_columns, count, DBUS_TYPE_INVALID);
405 if (selected_columns)
406 g_free (selected_columns);
411 impl_IsRowSelected (DBusConnection * bus, DBusMessage * message,
414 AtkTable *table = (AtkTable *) user_data;
420 g_return_val_if_fail (ATK_IS_TABLE (user_data),
421 droute_not_yet_handled_error (message));
422 dbus_error_init (&error);
423 if (!dbus_message_get_args
424 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
426 return droute_invalid_arguments_error (message);
428 ret = atk_table_is_row_selected (table, row);
429 reply = dbus_message_new_method_return (message);
432 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
439 impl_IsColumnSelected (DBusConnection * bus, DBusMessage * message,
442 AtkTable *table = (AtkTable *) user_data;
448 g_return_val_if_fail (ATK_IS_TABLE (user_data),
449 droute_not_yet_handled_error (message));
450 dbus_error_init (&error);
451 if (!dbus_message_get_args
452 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
454 return droute_invalid_arguments_error (message);
456 ret = atk_table_is_column_selected (table, column);
457 reply = dbus_message_new_method_return (message);
460 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
467 impl_IsSelected (DBusConnection * bus, DBusMessage * message, void *user_data)
469 AtkTable *table = (AtkTable *) user_data;
470 dbus_int32_t row, column;
475 g_return_val_if_fail (ATK_IS_TABLE (user_data),
476 droute_not_yet_handled_error (message));
477 dbus_error_init (&error);
478 if (!dbus_message_get_args
479 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
482 return droute_invalid_arguments_error (message);
484 ret = atk_table_is_selected (table, row, column);
485 reply = dbus_message_new_method_return (message);
488 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
495 impl_AddRowSelection (DBusConnection * bus, DBusMessage * message,
498 AtkTable *table = (AtkTable *) user_data;
504 g_return_val_if_fail (ATK_IS_TABLE (user_data),
505 droute_not_yet_handled_error (message));
506 dbus_error_init (&error);
507 if (!dbus_message_get_args
508 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
510 return droute_invalid_arguments_error (message);
512 ret = atk_table_add_row_selection (table, row);
513 reply = dbus_message_new_method_return (message);
516 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
523 impl_AddColumnSelection (DBusConnection * bus, DBusMessage * message,
526 AtkTable *table = (AtkTable *) user_data;
532 g_return_val_if_fail (ATK_IS_TABLE (user_data),
533 droute_not_yet_handled_error (message));
534 dbus_error_init (&error);
535 if (!dbus_message_get_args
536 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
538 return droute_invalid_arguments_error (message);
540 ret = atk_table_add_column_selection (table, column);
541 reply = dbus_message_new_method_return (message);
544 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
551 impl_RemoveRowSelection (DBusConnection * bus, DBusMessage * message,
554 AtkTable *table = (AtkTable *) user_data;
560 g_return_val_if_fail (ATK_IS_TABLE (user_data),
561 droute_not_yet_handled_error (message));
562 dbus_error_init (&error);
563 if (!dbus_message_get_args
564 (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
566 return droute_invalid_arguments_error (message);
568 ret = atk_table_remove_row_selection (table, row);
569 reply = dbus_message_new_method_return (message);
572 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
579 impl_RemoveColumnSelection (DBusConnection * bus, DBusMessage * message,
582 AtkTable *table = (AtkTable *) user_data;
588 g_return_val_if_fail (ATK_IS_TABLE (user_data),
589 droute_not_yet_handled_error (message));
590 dbus_error_init (&error);
591 if (!dbus_message_get_args
592 (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
594 return droute_invalid_arguments_error (message);
596 ret = atk_table_remove_column_selection (table, column);
597 reply = dbus_message_new_method_return (message);
600 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
607 impl_GetRowColumnExtentsAtIndex (DBusConnection * bus, DBusMessage * message,
610 AtkTable *table = (AtkTable *) user_data;
613 dbus_int32_t row, column, row_extents, col_extents;
614 dbus_bool_t is_selected;
621 g_return_val_if_fail (ATK_IS_TABLE (user_data),
622 droute_not_yet_handled_error (message));
623 dbus_error_init (&error);
624 if (!dbus_message_get_args
625 (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
627 return droute_invalid_arguments_error (message);
629 column = atk_table_get_column_at_index (table, index);
630 row = atk_table_get_row_at_index (table, index);
631 row_extents = atk_table_get_row_extent_at (table, row, column);
632 col_extents = atk_table_get_column_extent_at (table, row, column);
633 is_selected = atk_table_is_selected (table, row, column);
634 cell = atk_table_ref_at (table, row, column);
635 role = atk_object_get_role (cell);
636 g_object_unref (cell);
637 ret = (role == ATK_ROLE_TABLE_CELL ? TRUE : FALSE);
638 reply = dbus_message_new_method_return (message);
641 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
642 DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32,
643 &column, DBUS_TYPE_INT32, &row_extents,
644 DBUS_TYPE_INT32, &col_extents,
645 DBUS_TYPE_BOOLEAN, &is_selected,
651 static DRouteMethod methods[] = {
652 {impl_GetAccessibleAt, "GetAccessibleAt"},
653 {impl_GetIndexAt, "GetIndexAt"},
654 {impl_GetRowAtIndex, "GetRowAtIndex"},
655 {impl_GetColumnAtIndex, "GetColumnAtIndex"},
656 {impl_GetRowDescription, "GetRowDescription"},
657 {impl_GetColumnDescription, "GetColumnDescription"},
658 {impl_GetRowExtentAt, "GetRowExtentAt"},
659 {impl_GetColumnExtentAt, "GetColumnExtentAt"},
660 {impl_GetRowHeader, "GetRowHeader"},
661 {impl_GetColumnHeader, "GetColumnHeader"},
662 {impl_GetSelectedRows, "GetSelectedRows"},
663 {impl_GetSelectedColumns, "GetSelectedColumns"},
664 {impl_IsRowSelected, "IsRowSelected"},
665 {impl_IsColumnSelected, "IsColumnSelected"},
666 {impl_IsSelected, "IsSelected"},
667 {impl_AddRowSelection, "AddRowSelection"},
668 {impl_AddColumnSelection, "AddColumnSelection"},
669 {impl_RemoveRowSelection, "RemoveRowSelection"},
670 {impl_RemoveColumnSelection, "RemoveColumnSelection"},
671 {impl_GetRowColumnExtentsAtIndex, "GetRowColumnExtentsAtIndex"},
675 static DRouteProperty properties[] = {
676 {impl_get_NRows, NULL, "NRows"},
677 {impl_get_NColumns, NULL, "NColumns"},
678 {impl_get_Caption, NULL, "Caption"},
679 {impl_get_Summary, NULL, "Summary"},
680 {impl_get_NSelectedRows, NULL, "nSelectedRows"},
681 {impl_get_NSelectedColumns, NULL, "nSelectedColumns"},
686 spi_initialize_table (DRoutePath * path)
688 droute_path_add_interface (path,
689 SPI_DBUS_INTERFACE_TABLE, methods, properties);