From c5f078cefdda19b9b4a5e450c9e96855d2f12893 Mon Sep 17 00:00:00 2001 From: Mark Doffman Date: Mon, 12 Jan 2009 11:49:58 +0000 Subject: 2009-01-12 Mark Doffman * atk-adaptors/ Large code-structure refactor. D-Bus adaptors have been renamed to *-adaptor.c. atk-dbus.c has been renamed to accessible-register.c to better indicate its function. The marshalling code has been split out. --- atk-adaptor/Makefile.am | 46 +- atk-adaptor/accessible-adaptor.c | 591 ++++++++++++++++++ atk-adaptor/accessible-marshaller.c | 75 +++ atk-adaptor/accessible-marshaller.h | 36 ++ atk-adaptor/accessible-register.c | 337 ++++++++++ atk-adaptor/accessible-register.h | 55 ++ atk-adaptor/accessible.c | 591 ------------------ atk-adaptor/accessible.h | 36 -- atk-adaptor/action-adaptor.c | 204 ++++++ atk-adaptor/action.c | 204 ------ atk-adaptor/adaptors.h | 48 ++ atk-adaptor/application-adaptor.c | 120 ++++ atk-adaptor/application.c | 120 ---- atk-adaptor/atk-dbus.c | 393 ------------ atk-adaptor/atk-dbus.h | 73 --- atk-adaptor/bridge.c | 9 +- atk-adaptor/bridge.h | 29 +- atk-adaptor/collection-adaptor.c | 1033 +++++++++++++++++++++++++++++++ atk-adaptor/collection.c | 1032 ------------------------------ atk-adaptor/component-adaptor.c | 310 ++++++++++ atk-adaptor/component.c | 310 ---------- atk-adaptor/document-adaptor.c | 137 ++++ atk-adaptor/document.c | 137 ---- atk-adaptor/editabletext-adaptor.c | 251 ++++++++ atk-adaptor/editabletext.c | 251 -------- atk-adaptor/event.c | 11 +- atk-adaptor/event.h | 12 +- atk-adaptor/hyperlink-adaptor.c | 150 +++++ atk-adaptor/hyperlink.c | 150 ----- atk-adaptor/hypertext-adaptor.c | 111 ++++ atk-adaptor/hypertext.c | 111 ---- atk-adaptor/image-adaptor.c | 145 +++++ atk-adaptor/image.c | 145 ----- atk-adaptor/relation-adaptor.c | 169 +++++ atk-adaptor/relation.c | 169 ----- atk-adaptor/selection-adaptor.c | 260 ++++++++ atk-adaptor/selection.c | 260 -------- atk-adaptor/streamablecontent-adaptor.c | 316 ++++++++++ atk-adaptor/streamablecontent.c | 316 ---------- atk-adaptor/table-adaptor.c | 692 +++++++++++++++++++++ atk-adaptor/table.c | 692 --------------------- atk-adaptor/text-adaptor.c | 881 ++++++++++++++++++++++++++ atk-adaptor/text.c | 881 -------------------------- atk-adaptor/tree-adaptor.c | 316 ++++++++++ atk-adaptor/tree-adaptor.h | 37 ++ atk-adaptor/tree.c | 315 ---------- atk-adaptor/tree.h | 41 -- atk-adaptor/value-adaptor.c | 253 ++++++++ atk-adaptor/value.c | 253 -------- 49 files changed, 6568 insertions(+), 6546 deletions(-) create mode 100644 atk-adaptor/accessible-adaptor.c create mode 100644 atk-adaptor/accessible-marshaller.c create mode 100644 atk-adaptor/accessible-marshaller.h create mode 100644 atk-adaptor/accessible-register.c create mode 100644 atk-adaptor/accessible-register.h delete mode 100644 atk-adaptor/accessible.c delete mode 100644 atk-adaptor/accessible.h create mode 100644 atk-adaptor/action-adaptor.c delete mode 100644 atk-adaptor/action.c create mode 100644 atk-adaptor/adaptors.h create mode 100644 atk-adaptor/application-adaptor.c delete mode 100644 atk-adaptor/application.c delete mode 100644 atk-adaptor/atk-dbus.c delete mode 100644 atk-adaptor/atk-dbus.h create mode 100644 atk-adaptor/collection-adaptor.c delete mode 100644 atk-adaptor/collection.c create mode 100644 atk-adaptor/component-adaptor.c delete mode 100644 atk-adaptor/component.c create mode 100644 atk-adaptor/document-adaptor.c delete mode 100644 atk-adaptor/document.c create mode 100644 atk-adaptor/editabletext-adaptor.c delete mode 100644 atk-adaptor/editabletext.c create mode 100644 atk-adaptor/hyperlink-adaptor.c delete mode 100644 atk-adaptor/hyperlink.c create mode 100644 atk-adaptor/hypertext-adaptor.c delete mode 100644 atk-adaptor/hypertext.c create mode 100644 atk-adaptor/image-adaptor.c delete mode 100644 atk-adaptor/image.c create mode 100644 atk-adaptor/relation-adaptor.c delete mode 100644 atk-adaptor/relation.c create mode 100644 atk-adaptor/selection-adaptor.c delete mode 100644 atk-adaptor/selection.c create mode 100644 atk-adaptor/streamablecontent-adaptor.c delete mode 100644 atk-adaptor/streamablecontent.c create mode 100644 atk-adaptor/table-adaptor.c delete mode 100644 atk-adaptor/table.c create mode 100644 atk-adaptor/text-adaptor.c delete mode 100644 atk-adaptor/text.c create mode 100644 atk-adaptor/tree-adaptor.c create mode 100644 atk-adaptor/tree-adaptor.h delete mode 100644 atk-adaptor/tree.c delete mode 100644 atk-adaptor/tree.h create mode 100644 atk-adaptor/value-adaptor.c delete mode 100644 atk-adaptor/value.c diff --git a/atk-adaptor/Makefile.am b/atk-adaptor/Makefile.am index 944681f..c47cefc 100644 --- a/atk-adaptor/Makefile.am +++ b/atk-adaptor/Makefile.am @@ -1,7 +1,10 @@ gtkmoduledir = $(libdir)/$(GTK_MODULE_DIR) gtkmodule_LTLIBRARIES = libspiatk.la -libspiatk_la_CFLAGS = $(DBUS_GLIB_CFLAGS) $(ATK_CFLAGS) -I$(top_srcdir)\ +libspiatk_la_CFLAGS = $(DBUS_GLIB_CFLAGS)\ + $(ATK_CFLAGS)\ + -I$(top_srcdir)\ + -I$(top_srcdir)/atk-adaptor/adaptors\ -DATSPI_INTROSPECTION_PATH=\"$(pkgdatadir)/$(DEFAULT_ATSPI_INTROSPECTION_PATH)\" libspiatk_la_LDFLAGS = -no-undefined \ @@ -15,25 +18,28 @@ libspiatk_la_LIBADD = $(DBUS_GLIB_LIBS) \ $(top_builddir)/spi-common/libspicommon.la libspiatk_la_SOURCES = \ - accessible.h \ - accessible.c \ - action.c \ - application.c \ + accessible-adaptor.c \ + accessible-marshaller.c \ + accessible-marshaller.h \ + accessible-register.c \ + accessible-register.h \ + action-adaptor.c \ + adaptor.h \ + application-adaptor.c \ bridge.c \ bridge.h \ - collection.c \ - component.c \ - document.c \ - editabletext.c \ + collection-adaptor.c \ + component-adaptor.c \ + document-adaptor.c \ + editabletext-adaptor.c \ event.c \ - hyperlink.c \ - hypertext.c \ - atk-dbus.c \ - atk-dbus.h \ - image.c \ - selection.c \ - table.c \ - text.c \ - tree.c \ - tree.h \ - value.c + event.h \ + hyperlink-adaptor.c \ + hypertext-adaptor.c \ + image-adaptor.c \ + selection-adaptor.c \ + table-adaptor.c \ + text-adaptor.c \ + tree-adaptor.c \ + tree-adaptor.h \ + value-adaptor.c diff --git a/atk-adaptor/accessible-adaptor.c b/atk-adaptor/accessible-adaptor.c new file mode 100644 index 0000000..fd3df3c --- /dev/null +++ b/atk-adaptor/accessible-adaptor.c @@ -0,0 +1,591 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2008 Novell, Inc. + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include + +#include "spi-common/spi-dbus.h" +#include "accessible-marshaller.h" + +static dbus_bool_t +impl_get_name (DBusMessageIter *iter, void *user_data) +{ + AtkObject *object = (AtkObject *) user_data; + + g_return_val_if_fail (ATK_IS_OBJECT (user_data), FALSE); + + return droute_return_v_string (iter, atk_object_get_name (object)); +} + +static dbus_bool_t +impl_set_name (DBusMessageIter *iter, void *user_data) +{ + AtkObject *object = (AtkObject *) user_data; + const char *name = droute_get_v_string (iter); + + g_return_val_if_fail (ATK_IS_OBJECT (user_data), FALSE); + + atk_object_set_name (object, name); + return TRUE; +} + +static dbus_bool_t +impl_get_description (DBusMessageIter *iter, void *user_data) +{ + AtkObject *object = (AtkObject *) user_data; + + g_return_val_if_fail (ATK_IS_OBJECT (user_data), FALSE); + + return droute_return_v_string (iter, atk_object_get_description (object)); +} + +static dbus_bool_t +impl_set_description (DBusMessageIter *iter, void *user_data) +{ + AtkObject *object = (AtkObject *) user_data; + const char *description = droute_get_v_string (iter); + + g_return_val_if_fail (ATK_IS_OBJECT (user_data), FALSE); + + atk_object_set_description (object, description); + return TRUE; +} + +static dbus_bool_t +impl_get_parent (DBusMessageIter *iter, void *user_data) +{ + AtkObject *object = (AtkObject *) user_data; + + g_return_val_if_fail (ATK_IS_OBJECT (user_data), FALSE); + + return spi_dbus_return_v_object (iter, + atk_object_get_parent (object), + FALSE); +} + +static dbus_bool_t +impl_get_childCount (DBusMessageIter *iter, void *user_data) +{ + AtkObject *object = (AtkObject *) user_data; + + g_return_val_if_fail (ATK_IS_OBJECT (user_data), FALSE); + + return droute_return_v_int32 (iter, + atk_object_get_n_accessible_children + (object)); +} + +static DBusMessage * +impl_getChildAtIndex (DBusConnection *bus, + DBusMessage *message, + void *user_data) +{ + AtkObject *object = (AtkObject *) user_data; + DBusError error; + dbus_int32_t i; + AtkObject *child; + + dbus_error_init (&error); + g_return_val_if_fail (ATK_IS_OBJECT (user_data), + droute_not_yet_handled_error (message)); + if (!dbus_message_get_args (message, &error, DBUS_TYPE_INT32, &i, DBUS_TYPE_INVALID)) + return spi_dbus_general_error (message); + child = atk_object_ref_accessible_child (object, i); + return spi_dbus_return_object (message, child, FALSE); +} + +static DBusMessage * +impl_getChildren (DBusConnection *bus, + DBusMessage *message, + void *user_data) +{ + AtkObject *object = (AtkObject *) user_data; + gint i; + gint count; + DBusMessage *reply; + DBusMessageIter iter, iter_array; + + g_return_val_if_fail (ATK_IS_OBJECT (user_data), + droute_not_yet_handled_error (message)); + count = atk_object_get_n_accessible_children (object); + reply = dbus_message_new_method_return (message); + if (!reply) goto oom; + dbus_message_iter_init_append (reply, &iter); + if (!dbus_message_iter_open_container + (&iter, DBUS_TYPE_ARRAY, "o", &iter_array)) + goto oom; + for (i = 0; i < count; i++) + { + AtkObject *child = atk_object_ref_accessible_child (object, i); + char *path = atk_dbus_object_to_path (child); + if (path) + { + dbus_message_iter_append_basic (&iter_array, DBUS_TYPE_OBJECT_PATH, + &path); + g_free (path); + } + if (child) + g_object_unref (child); + } + if (!dbus_message_iter_close_container (&iter, &iter_array)) + goto oom; + return reply; +oom: + // TODO: handle out-of-memory + return reply; +} + +static DBusMessage * +impl_getIndexInParent (DBusConnection *bus, + DBusMessage *message, + void *user_data) +{ + AtkObject *object = (AtkObject *) user_data; + dbus_uint32_t rv; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_OBJECT (user_data), + droute_not_yet_handled_error (message)); + rv = atk_object_get_index_in_parent (object); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_UINT32, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static gboolean +spi_init_relation_type_table (Accessibility_RelationType *types) +{ + gint i; + + for (i = 0; i < ATK_RELATION_LAST_DEFINED; i++) + types[i] = Accessibility_RELATION_NULL; + + types[ATK_RELATION_CONTROLLED_BY] = Accessibility_RELATION_CONTROLLED_BY; + types[ATK_RELATION_CONTROLLER_FOR] = Accessibility_RELATION_CONTROLLER_FOR; + types[ATK_RELATION_LABEL_FOR] = Accessibility_RELATION_LABEL_FOR; + types[ATK_RELATION_LABELLED_BY] = Accessibility_RELATION_LABELLED_BY; + types[ATK_RELATION_MEMBER_OF] = Accessibility_RELATION_MEMBER_OF; + types[ATK_RELATION_NODE_CHILD_OF] = Accessibility_RELATION_NODE_CHILD_OF; + types[ATK_RELATION_FLOWS_TO] = Accessibility_RELATION_FLOWS_TO; + types[ATK_RELATION_FLOWS_FROM] = Accessibility_RELATION_FLOWS_FROM; + types[ATK_RELATION_SUBWINDOW_OF] = Accessibility_RELATION_SUBWINDOW_OF; + types[ATK_RELATION_EMBEDS] = Accessibility_RELATION_EMBEDS; + types[ATK_RELATION_EMBEDDED_BY] = Accessibility_RELATION_EMBEDDED_BY; + types[ATK_RELATION_POPUP_FOR] = Accessibility_RELATION_POPUP_FOR; + types[ATK_RELATION_PARENT_WINDOW_OF] = Accessibility_RELATION_PARENT_WINDOW_OF; + types[ATK_RELATION_DESCRIPTION_FOR] = Accessibility_RELATION_DESCRIPTION_FOR; + types[ATK_RELATION_DESCRIBED_BY] = Accessibility_RELATION_DESCRIBED_BY; + + return TRUE; +} + +static Accessibility_RelationType +spi_relation_type_from_atk_relation_type (AtkRelationType type) +{ + static gboolean is_initialized = FALSE; + static Accessibility_RelationType spi_relation_type_table [ATK_RELATION_LAST_DEFINED]; + Accessibility_RelationType spi_type; + + if (!is_initialized) + is_initialized = spi_init_relation_type_table (spi_relation_type_table); + + if (type > ATK_RELATION_NULL && type < ATK_RELATION_LAST_DEFINED) + spi_type = spi_relation_type_table[type]; + else + spi_type = Accessibility_RELATION_EXTENDED; + return spi_type; +} + +static DBusMessage * +impl_getRelationSet (DBusConnection *bus, + DBusMessage *message, + void *user_data) +{ + AtkObject *object = (AtkObject *) user_data; + DBusMessage *reply; + AtkRelationSet *set; + DBusMessageIter iter, iter_array, iter_struct, iter_targets; + gint count; + gint i, j; + + g_return_val_if_fail (ATK_IS_OBJECT (user_data), + droute_not_yet_handled_error (message)); + reply = dbus_message_new_method_return (message); + if (!reply) return NULL; + set = atk_object_ref_relation_set (object); + dbus_message_iter_init_append (reply, &iter); + if (!dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "(uao)", &iter_array)) + { + goto oom; + } + count = atk_relation_set_get_n_relations (set); + for (i = 0; i < count; i++) + { + AtkRelation *r = atk_relation_set_get_relation (set, i); + AtkRelationType rt; + GPtrArray *target; + dbus_uint32_t type; + if (!r) continue; + rt= atk_relation_get_relation_type (r); + type = spi_relation_type_from_atk_relation_type (rt); + target = atk_relation_get_target (r); + if (!dbus_message_iter_open_container (&iter_array, DBUS_TYPE_STRUCT, NULL, &iter_struct)) + { + goto oom; + } + dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_UINT32, &type); + if (!dbus_message_iter_open_container (&iter_struct, DBUS_TYPE_ARRAY, "o", &iter_targets)) + { + goto oom; + } + for (j = 0; j < target->len; j++) + { + AtkObject *obj = target->pdata[j]; + char *path; + if (!obj) continue; + path = atk_dbus_object_to_path (obj); + dbus_message_iter_append_basic (&iter_targets, DBUS_TYPE_OBJECT_PATH, &path); + } + dbus_message_iter_close_container (&iter_struct, &iter_targets); + dbus_message_iter_close_container (&iter_array, &iter_struct); + } + dbus_message_iter_close_container (&iter, &iter_array); +oom: + // TODO: handle out of memory */ + return reply; +} + +static gboolean +spi_init_role_lookup_table (Accessibility_Role * role_table) +{ + int i; + /* if it's not in the list below, dunno what it is */ + for (i = 0; i < ATK_ROLE_LAST_DEFINED; ++i) + { + role_table[i] = Accessibility_ROLE_UNKNOWN; + } + + role_table[ATK_ROLE_INVALID] = Accessibility_ROLE_INVALID; + role_table[ATK_ROLE_ACCEL_LABEL] = Accessibility_ROLE_ACCELERATOR_LABEL; + role_table[ATK_ROLE_ALERT] = Accessibility_ROLE_ALERT; + role_table[ATK_ROLE_ANIMATION] = Accessibility_ROLE_ANIMATION; + role_table[ATK_ROLE_ARROW] = Accessibility_ROLE_ARROW; + role_table[ATK_ROLE_CALENDAR] = Accessibility_ROLE_CALENDAR; + role_table[ATK_ROLE_CANVAS] = Accessibility_ROLE_CANVAS; + role_table[ATK_ROLE_CHECK_BOX] = Accessibility_ROLE_CHECK_BOX; + role_table[ATK_ROLE_CHECK_MENU_ITEM] = Accessibility_ROLE_CHECK_MENU_ITEM; + role_table[ATK_ROLE_COLOR_CHOOSER] = Accessibility_ROLE_COLOR_CHOOSER; + role_table[ATK_ROLE_COLUMN_HEADER] = Accessibility_ROLE_COLUMN_HEADER; + role_table[ATK_ROLE_COMBO_BOX] = Accessibility_ROLE_COMBO_BOX; + role_table[ATK_ROLE_DATE_EDITOR] = Accessibility_ROLE_DATE_EDITOR; + role_table[ATK_ROLE_DESKTOP_ICON] = Accessibility_ROLE_DESKTOP_ICON; + role_table[ATK_ROLE_DESKTOP_FRAME] = Accessibility_ROLE_DESKTOP_FRAME; + role_table[ATK_ROLE_DIAL] = Accessibility_ROLE_DIAL; + role_table[ATK_ROLE_DIALOG] = Accessibility_ROLE_DIALOG; + role_table[ATK_ROLE_DIRECTORY_PANE] = Accessibility_ROLE_DIRECTORY_PANE; + role_table[ATK_ROLE_DRAWING_AREA] = Accessibility_ROLE_DRAWING_AREA; + role_table[ATK_ROLE_FILE_CHOOSER] = Accessibility_ROLE_FILE_CHOOSER; + role_table[ATK_ROLE_FILLER] = Accessibility_ROLE_FILLER; + role_table[ATK_ROLE_FONT_CHOOSER] = Accessibility_ROLE_FONT_CHOOSER; + role_table[ATK_ROLE_FRAME] = Accessibility_ROLE_FRAME; + role_table[ATK_ROLE_GLASS_PANE] = Accessibility_ROLE_GLASS_PANE; + role_table[ATK_ROLE_HTML_CONTAINER] = Accessibility_ROLE_HTML_CONTAINER; + role_table[ATK_ROLE_ICON] = Accessibility_ROLE_ICON; + role_table[ATK_ROLE_IMAGE] = Accessibility_ROLE_IMAGE; + role_table[ATK_ROLE_INTERNAL_FRAME] = Accessibility_ROLE_INTERNAL_FRAME; + role_table[ATK_ROLE_LABEL] = Accessibility_ROLE_LABEL; + role_table[ATK_ROLE_LAYERED_PANE] = Accessibility_ROLE_LAYERED_PANE; + role_table[ATK_ROLE_LIST] = Accessibility_ROLE_LIST; + role_table[ATK_ROLE_LIST_ITEM] = Accessibility_ROLE_LIST_ITEM; + role_table[ATK_ROLE_MENU] = Accessibility_ROLE_MENU; + role_table[ATK_ROLE_MENU_BAR] = Accessibility_ROLE_MENU_BAR; + role_table[ATK_ROLE_MENU_ITEM] = Accessibility_ROLE_MENU_ITEM; + role_table[ATK_ROLE_OPTION_PANE] = Accessibility_ROLE_OPTION_PANE; + role_table[ATK_ROLE_PAGE_TAB] = Accessibility_ROLE_PAGE_TAB; + role_table[ATK_ROLE_PAGE_TAB_LIST] = Accessibility_ROLE_PAGE_TAB_LIST; + role_table[ATK_ROLE_PANEL] = Accessibility_ROLE_PANEL; + role_table[ATK_ROLE_PASSWORD_TEXT] = Accessibility_ROLE_PASSWORD_TEXT; + role_table[ATK_ROLE_POPUP_MENU] = Accessibility_ROLE_POPUP_MENU; + role_table[ATK_ROLE_PROGRESS_BAR] = Accessibility_ROLE_PROGRESS_BAR; + role_table[ATK_ROLE_PUSH_BUTTON] = Accessibility_ROLE_PUSH_BUTTON; + role_table[ATK_ROLE_RADIO_BUTTON] = Accessibility_ROLE_RADIO_BUTTON; + role_table[ATK_ROLE_RADIO_MENU_ITEM] = Accessibility_ROLE_RADIO_MENU_ITEM; + role_table[ATK_ROLE_ROOT_PANE] = Accessibility_ROLE_ROOT_PANE; + role_table[ATK_ROLE_ROW_HEADER] = Accessibility_ROLE_ROW_HEADER; + role_table[ATK_ROLE_SCROLL_BAR] = Accessibility_ROLE_SCROLL_BAR; + role_table[ATK_ROLE_SCROLL_PANE] = Accessibility_ROLE_SCROLL_PANE; + role_table[ATK_ROLE_SEPARATOR] = Accessibility_ROLE_SEPARATOR; + role_table[ATK_ROLE_SLIDER] = Accessibility_ROLE_SLIDER; + role_table[ATK_ROLE_SPIN_BUTTON] = Accessibility_ROLE_SPIN_BUTTON; + role_table[ATK_ROLE_SPLIT_PANE] = Accessibility_ROLE_SPLIT_PANE; + role_table[ATK_ROLE_STATUSBAR] = Accessibility_ROLE_STATUS_BAR; + role_table[ATK_ROLE_TABLE] = Accessibility_ROLE_TABLE; + role_table[ATK_ROLE_TABLE_CELL] = Accessibility_ROLE_TABLE_CELL; + role_table[ATK_ROLE_TABLE_COLUMN_HEADER] = + Accessibility_ROLE_TABLE_COLUMN_HEADER; + role_table[ATK_ROLE_TABLE_ROW_HEADER] = Accessibility_ROLE_TABLE_ROW_HEADER; + role_table[ATK_ROLE_TEAR_OFF_MENU_ITEM] = + Accessibility_ROLE_TEAROFF_MENU_ITEM; + role_table[ATK_ROLE_TERMINAL] = Accessibility_ROLE_TERMINAL; + role_table[ATK_ROLE_TEXT] = Accessibility_ROLE_TEXT; + role_table[ATK_ROLE_TOGGLE_BUTTON] = Accessibility_ROLE_TOGGLE_BUTTON; + role_table[ATK_ROLE_TOOL_BAR] = Accessibility_ROLE_TOOL_BAR; + role_table[ATK_ROLE_TOOL_TIP] = Accessibility_ROLE_TOOL_TIP; + role_table[ATK_ROLE_TREE] = Accessibility_ROLE_TREE; + role_table[ATK_ROLE_TREE_TABLE] = Accessibility_ROLE_TREE_TABLE; + role_table[ATK_ROLE_UNKNOWN] = Accessibility_ROLE_UNKNOWN; + role_table[ATK_ROLE_VIEWPORT] = Accessibility_ROLE_VIEWPORT; + role_table[ATK_ROLE_WINDOW] = Accessibility_ROLE_WINDOW; + role_table[ATK_ROLE_HEADER] = Accessibility_ROLE_HEADER; + role_table[ATK_ROLE_FOOTER] = Accessibility_ROLE_FOOTER; + role_table[ATK_ROLE_PARAGRAPH] = Accessibility_ROLE_PARAGRAPH; + role_table[ATK_ROLE_RULER] = Accessibility_ROLE_RULER; + role_table[ATK_ROLE_APPLICATION] = Accessibility_ROLE_APPLICATION; + role_table[ATK_ROLE_AUTOCOMPLETE] = Accessibility_ROLE_AUTOCOMPLETE; + role_table[ATK_ROLE_EDITBAR] = Accessibility_ROLE_EDITBAR; + role_table[ATK_ROLE_EMBEDDED] = Accessibility_ROLE_EMBEDDED; + role_table[ATK_ROLE_ENTRY] = Accessibility_ROLE_ENTRY; + role_table[ATK_ROLE_CHART] = Accessibility_ROLE_CHART; + role_table[ATK_ROLE_CAPTION] = Accessibility_ROLE_CAPTION; + role_table[ATK_ROLE_DOCUMENT_FRAME] = Accessibility_ROLE_DOCUMENT_FRAME; + role_table[ATK_ROLE_HEADING] = Accessibility_ROLE_HEADING; + role_table[ATK_ROLE_PAGE] = Accessibility_ROLE_PAGE; + role_table[ATK_ROLE_SECTION] = Accessibility_ROLE_SECTION; + role_table[ATK_ROLE_FORM] = Accessibility_ROLE_FORM; + role_table[ATK_ROLE_REDUNDANT_OBJECT] = Accessibility_ROLE_REDUNDANT_OBJECT; + role_table[ATK_ROLE_LINK] = Accessibility_ROLE_LINK; + role_table[ATK_ROLE_INPUT_METHOD_WINDOW] = + Accessibility_ROLE_INPUT_METHOD_WINDOW; + return TRUE; +} + +Accessibility_Role +spi_accessible_role_from_atk_role (AtkRole role) +{ + static gboolean is_initialized = FALSE; + static Accessibility_Role spi_role_table[ATK_ROLE_LAST_DEFINED]; + Accessibility_Role spi_role; + + if (!is_initialized) + { + is_initialized = spi_init_role_lookup_table (spi_role_table); + } + + if (role >= 0 && role < ATK_ROLE_LAST_DEFINED) + { + spi_role = spi_role_table[role]; + } + else + { + spi_role = Accessibility_ROLE_EXTENDED; + } + return spi_role; +} + +static DBusMessage * +impl_getRole (DBusConnection *bus, DBusMessage *message, void *user_data) +{ + AtkObject *object = (AtkObject *) user_data; + gint role; + dbus_uint32_t rv; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_OBJECT (user_data), + droute_not_yet_handled_error (message)); + role = atk_object_get_role (object); + rv = spi_accessible_role_from_atk_role (role); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_UINT32, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static char * +impl_get_role_str (void *datum) +{ + g_assert (ATK_IS_OBJECT (datum)); + return g_strdup_printf ("%d", + spi_accessible_role_from_atk_role + (atk_object_get_role ((AtkObject *) datum))); +} + +static DBusMessage * +impl_getRoleName (DBusConnection *bus, + DBusMessage *message, + void *user_data) +{ + AtkObject *object = (AtkObject *) user_data; + gint role; + const char *role_name; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_OBJECT (user_data), + droute_not_yet_handled_error (message)); + role = atk_object_get_role (object); + role_name = atk_role_get_name (role); + if (!role_name) + role_name = ""; + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_STRING, &role_name, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getLocalizedRoleName (DBusConnection *bus, + DBusMessage *message, + void *user_data) +{ + AtkObject *object = (AtkObject *) user_data; + gint role; + const char *role_name; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_OBJECT (user_data), + droute_not_yet_handled_error (message)); + role = atk_object_get_role (object); + role_name = atk_role_get_localized_name (role); + if (!role_name) + role_name = ""; + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_STRING, &role_name, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getState (DBusConnection *bus, + DBusMessage *message, + void *user_data) +{ + AtkObject *object = (AtkObject *) user_data; + dbus_uint32_t rv[2]; + dbus_uint32_t *array = rv; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_OBJECT (user_data), + droute_not_yet_handled_error (message)); + spi_atk_state_to_dbus_array (object, rv); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &array, + 2, DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getAttributes (DBusConnection *bus, + DBusMessage *message, + void *user_data) +{ + AtkObject *object = (AtkObject *) user_data; + DBusMessage *reply; + AtkAttributeSet *attributes; + AtkAttribute *attr = NULL; + char **retval; + gint n_attributes = 0; + gint i; + + g_return_val_if_fail (ATK_IS_OBJECT (user_data), + droute_not_yet_handled_error (message)); + + attributes = atk_object_get_attributes (object); + if (attributes) + n_attributes = g_slist_length (attributes); + + retval = (char **) g_malloc (n_attributes * sizeof (char *)); + + for (i = 0; i < n_attributes; ++i) + { + attr = g_slist_nth_data (attributes, i); + retval[i] = g_strconcat (attr->name, ":", attr->value, NULL); + } + if (attributes) + atk_attribute_set_free (attributes); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, + &retval, n_attributes, DBUS_TYPE_INVALID); + } + for (i = 0; i < n_attributes; i++) + g_free (retval[i]); + g_free (retval); + return reply; +} + +static DBusMessage * +impl_getApplication (DBusConnection *bus, + DBusMessage *message, + void *user_data) +{ + AtkObject *root = atk_get_root (); + return spi_dbus_return_object (message, root, FALSE); +} + +static DRouteMethod methods[] = { + {impl_getChildAtIndex, "getChildAtIndex"}, + {impl_getChildren, "getChildren"}, + {impl_getIndexInParent, "getIndexInParent"}, + {impl_getRelationSet, "getRelationSet"}, + {impl_getRole, "getRole"}, + {impl_getRoleName, "getRoleName"}, + {impl_getLocalizedRoleName, "getLocalizedRoleName"}, + {impl_getState, "getState"}, + {impl_getAttributes, "getAttributes"}, + {impl_getApplication, "getApplication"}, + {NULL, NULL} +}; + +static DRouteProperty properties[] = { + {impl_get_name, impl_set_name, "name"}, + {impl_get_description, impl_set_description, "description"}, + {impl_get_parent, NULL, "parent"}, + {impl_get_childCount, NULL, "childCount"}, + {NULL, NULL, NULL} +}; + +void +spi_initialize_accessible (DRoutePath *path) +{ + droute_path_add_interface (path, + SPI_DBUS_INTERFACE_ACCESSIBLE, + methods, + properties); +}; diff --git a/atk-adaptor/accessible-marshaller.c b/atk-adaptor/accessible-marshaller.c new file mode 100644 index 0000000..a60f2c8 --- /dev/null +++ b/atk-adaptor/accessible-marshaller.c @@ -0,0 +1,75 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2008 Novell, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "accessible-register.h" +#include "accessible-marshaller.h" + +/*---------------------------------------------------------------------------*/ + +/* + * Marshals the D-Bus path of an AtkObject into a D-Bus message. + * + * Unrefs the AtkObject if unref is true. + */ +DBusMessage * +spi_dbus_return_object (DBusMessage *message, AtkObject *obj, gboolean unref) +{ + DBusMessage *reply; + gchar *path; + + path = atk_dbus_object_to_path (obj); + + if (unref) + g_object_unref (obj); + + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_OBJECT_PATH, path, + DBUS_TYPE_INVALID); + } + return reply; +} + +/*---------------------------------------------------------------------------*/ + +/* + * Marshals a variant containing the D-Bus path of an AtkObject into a D-Bus + * message. + * + * Unrefs the object if unref is true. + */ +dbus_bool_t +spi_dbus_return_v_object (DBusMessageIter *iter, AtkObject *obj, int unref) +{ + char *path; + + path = atk_dbus_object_to_path (obj); + + if (unref) + g_object_unref (obj); + + return droute_return_v_object (iter, path); +} + +/*END------------------------------------------------------------------------*/ + diff --git a/atk-adaptor/accessible-marshaller.h b/atk-adaptor/accessible-marshaller.h new file mode 100644 index 0000000..b133abc --- /dev/null +++ b/atk-adaptor/accessible-marshaller.h @@ -0,0 +1,36 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2008 Novell, Inc. + * Copyright 2008, 2009 Codethink Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __ACCESSIBLE_MARSHALLER__ +#define __ACCESSIBLE_MARSHALLER__ + +#include +#include + +DBusMessage * +spi_dbus_return_object (DBusMessage *message, AtkObject *obj, gboolean unref); + +dbus_bool_t +spi_dbus_return_v_object (DBusMessageIter *iter, AtkObject *obj, int unref); + +#endif /* __ACCESSIBLE_MARSHALLER__ */ diff --git a/atk-adaptor/accessible-register.c b/atk-adaptor/accessible-register.c new file mode 100644 index 0000000..61521e6 --- /dev/null +++ b/atk-adaptor/accessible-register.c @@ -0,0 +1,337 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2008 Novell, Inc. + * Copyright 2008, 2009 Codethink Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include +#include + +#include "bridge.h" +#include "accessible-register.h" + +/* TODO + * Need to add concurrency support. + */ + +#define ATK_BRIDGE_OBJECT_PATH_PREFIX "/org/freedesktop/atspi/accessible" +#define ATK_BRIDGE_OBJECT_REFERENCE_TEMPLATE ATK_BRIDGE_OBJECT_PATH_PREFIX "/%d" +#define ATK_BRIDGE_PATH_PREFIX_LENGTH 33 + +/* + * This module is responsible for keeping track of all the AtkObjects in + * the application, so that they can be accessed remotely and placed in + * a client side cache. + * + * To access an AtkObject remotely we need to provide a D-Bus object + * path for it. The D-Bus object paths used have a standard prefix + * (ATK_BRIDGE_OBJECT_PATH_PREFIX). Appended to this prefix is a string + * representation of an integer reference. So to access an AtkObject + * remotely we keep a Hashtable that maps the given reference to + * the AtkObject pointer. An object in this hash table is said to be 'registered'. + * + * The architecture of AT-SPI dbus is such that AtkObjects are not + * remotely reference counted. This means that we need to keep track of + * object destruction. When an object is destroyed it must be 'deregistered' + * To do this lookup we keep a dbus-id attribute on each AtkObject. + * + * In addition to accessing the objects remotely we must be able to update + * the client side cache. This is done using the 'update' signal of the + * org.freedesktop.atspi.Tree interface. The update signal should send out + * all of the cacheable data for each AtkObject that has changed since the + * last update. It should also provide a list of objects that have been + * removed since the last update. + */ + +GHashTable *ref2ptr = NULL; /* Used for converting a D-Bus path (Reference) to the object pointer */ + +static guint counter = 1; + +/*---------------------------------------------------------------------------*/ + +/* + * Each AtkObject must be asssigned a D-Bus path (Reference) + * + * This function provides an integer reference for a new + * AtkObject. + */ +static guint +assign_reference(void) +{ + counter++; + /* Reference of 0 not allowed as used as direct key in hash table */ + if (counter == 0) + counter++; +} + +/*---------------------------------------------------------------------------*/ + +void +atk_dbus_foreach_registered(GHFunc func, gpointer data) +{ + g_hash_table_foreach(ref2ptr, func, data); +} + +/*---------------------------------------------------------------------------*/ + +/* + * Called when a registered AtkObject is deleted. + * Removes the AtkObject from the reference lookup tables. + * Sets the client side cache to be updated. + */ +static void +deregister_accessible(gpointer data, GObject *accessible) +{ + guint ref; + gchar *path; + + g_assert(ATK_IS_OBJECT(accessible)); + + + ref = atk_dbus_object_to_ref (ATK_OBJECT(accessible)); + + if (ref != 0) + { + g_hash_table_remove(ref2ptr, GINT_TO_POINTER(ref)); + /* + * TODO + * Pyatspi client side exceptions have occured indicating + * that an object has been removed twice. + * This should not be possible and needs investigation. + */ + spi_emit_cache_removal (ref, atk_adaptor_app_data->bus); + } +} + +/*---------------------------------------------------------------------------*/ + +/* + * This function registers the object so that it is exported + * over D-Bus and schedules an update to client side cache. + */ +static guint +export (GList **uplist, AtkObject *accessible) +{ + guint ref; + gchar *path; + + g_assert(ATK_IS_OBJECT(accessible)); + + ref = assign_reference(); + + g_hash_table_insert (ref2ptr, GINT_TO_POINTER(ref), accessible); + g_object_set_data (G_OBJECT(accessible), "dbus-id", GINT_TO_POINTER(ref)); + g_object_weak_ref(G_OBJECT(accessible), deregister_accessible, NULL); + + *uplist = g_list_prepend (*uplist, accessible); + + return ref; +} + +/* + * This does a depth first traversal of a subtree of AtkObject + * and exports them as Accessible objects if they are not exported + * already. + */ +static guint +export_subtree (AtkObject *accessible) +{ + AtkObject *current, *tmp; + GQueue *stack; + GList *uplist = NULL; + guint i, ref; + gboolean recurse; + + stack = g_queue_new (); + + current = g_object_ref (accessible); + ref = export (&uplist, current); + g_queue_push_head (stack, GINT_TO_POINTER (0)); + + /* + * The index held on the stack is the next child node + * that needs processing at the corresponding level in the tree. + */ + while (!g_queue_is_empty (stack)) + { + /* This while loop finds the next node that needs processing, + * if one exists. + */ + i = GPOINTER_TO_INT(g_queue_peek_head (stack)); + recurse = FALSE; + while (i < atk_object_get_n_accessible_children (current) && + recurse == FALSE) + { + tmp = atk_object_ref_accessible_child (current, i); + if (!atk_dbus_object_to_ref (tmp)) + { + recurse = TRUE; + } + else + { + i++; + g_object_unref (G_OBJECT (tmp)); + } + } + if (recurse) + { + /* Still children to process */ + current = tmp; + export (&uplist, current); + /* Update parent nodes next child index */ + g_queue_peek_head_link (stack)->data = GINT_TO_POINTER (i+1); + /* Push a new child index for the current node */ + g_queue_push_head (stack, GINT_TO_POINTER (0)); + } + else + { + /* No more children, move to parent */ + tmp = current; + current = atk_object_get_parent (current); + g_object_unref (G_OBJECT (tmp)); + g_queue_pop_head (stack); + } + } + spi_emit_cache_update (uplist, atk_adaptor_app_data->bus); + g_list_free (uplist); + return ref; +} + +/*---------------------------------------------------------------------------*/ + +/* Called to register an AtkObject with AT-SPI and expose it over D-Bus. */ +guint +atk_dbus_register_accessible (AtkObject *accessible) +{ + guint ref; + g_assert(ATK_IS_OBJECT(accessible)); + + ref = atk_dbus_object_to_ref (accessible); + if (!ref) + return export_subtree (accessible); + else + return ref; +} + +/* Called when an already registered object is updated in such a + * way that client side cache needs to be updated. + */ +guint +atk_dbus_update_accessible (AtkObject *accessible) +{ + guint ref = 0; + g_assert(ATK_IS_OBJECT(accessible)); + + ref = atk_dbus_object_to_ref (accessible); + if (ref) + { + spi_emit_cache_update (accessible, atk_adaptor_app_data->bus); + } + return ref; +} + +/*---------------------------------------------------------------------------*/ + +/* + * Returns the reference of the object, or 0 if it is not exported over D-Bus. + */ +guint +atk_dbus_object_to_ref (AtkObject *accessible) +{ + return GPOINTER_TO_INT(g_object_get_data (G_OBJECT (accessible), "dbus-id")); +} + +/* + * Converts the Accessible object reference to its D-Bus object path + */ +gchar * +atk_dbus_ref_to_path (guint ref) +{ + return g_strdup_printf(ATK_BRIDGE_OBJECT_REFERENCE_TEMPLATE, ref); +} + +/* + * Used to lookup an AtkObject from its D-Bus path. + */ +AtkObject * +atk_dbus_path_to_object (const char *path) +{ + guint index; + void *data; + + g_assert (path); + + if (strncmp(path, ATK_BRIDGE_OBJECT_PATH_PREFIX, ATK_BRIDGE_PATH_PREFIX_LENGTH) != 0) + return NULL; + + path += ATK_BRIDGE_PATH_PREFIX_LENGTH; /* Skip over the prefix */ + + if (path[0] == '\0') + return atk_get_root(); + if (path[0] != '/') + return NULL; + + path++; + index = atoi (path); + data = g_hash_table_lookup (ref2ptr, GINT_TO_POINTER(index)); + if (data) + return ATK_OBJECT (data); + else + return NULL; +} + + +/* + * Used to lookup a D-Bus path from the AtkObject. + */ +gchar * +atk_dbus_object_to_path (AtkObject *accessible) +{ + guint ref; + g_assert(ATK_IS_OBJECT(accessible)); + + ref = atk_dbus_object_to_ref (accessible); + if (!ref) + return NULL; + else + return atk_dbus_ref_to_path (ref); +} + +/*---------------------------------------------------------------------------*/ + +/* + * Initializes required global data. The update and removal lists + * and the reference lookup tables. + * + * Initializes all of the required D-Bus interfaces. + */ +void +atk_dbus_initialize (AtkObject *root) +{ + if (!ref2ptr) + ref2ptr = g_hash_table_new(g_direct_hash, g_direct_equal); + + /* Get the root accessible and add */ + atk_dbus_register_accessible (root); +} + +/*END------------------------------------------------------------------------*/ + diff --git a/atk-adaptor/accessible-register.h b/atk-adaptor/accessible-register.h new file mode 100644 index 0000000..89c7780 --- /dev/null +++ b/atk-adaptor/accessible-register.h @@ -0,0 +1,55 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2008 Novell, Inc. + * Copyright 2008, 2009 Codethink Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef ACCESSIBLE_REGISTER +#define ACCESSIBLE_REGISTER + +#include +#include + +void +atk_dbus_foreach_registered(GHFunc func, gpointer data); + +/*---------------------------------------------------------------------------*/ + +guint +atk_dbus_register_accessible (AtkObject *accessible); + +guint +atk_dbus_update_accessible (AtkObject *accessible); + +/*---------------------------------------------------------------------------*/ + +guint +atk_dbus_object_to_ref (AtkObject *accessible); + +gchar * +atk_dbus_ref_to_path (guint ref); + +AtkObject * +atk_dbus_path_to_object (const char *path); + +gchar * +atk_dbus_object_to_path (AtkObject *accessible); + +#endif /* ACCESSIBLE_REGISTER */ diff --git a/atk-adaptor/accessible.c b/atk-adaptor/accessible.c deleted file mode 100644 index e1e34aa..0000000 --- a/atk-adaptor/accessible.c +++ /dev/null @@ -1,591 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) - * - * Copyright 2008 Novell, Inc. - * Copyright 2001, 2002 Sun Microsystems Inc., - * Copyright 2001, 2002 Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include - -#include "atk-dbus.h" -#include "spi-common/spi-dbus.h" - -static dbus_bool_t -impl_get_name (DBusMessageIter *iter, void *user_data) -{ - AtkObject *object = (AtkObject *) user_data; - - g_return_val_if_fail (ATK_IS_OBJECT (user_data), FALSE); - - return droute_return_v_string (iter, atk_object_get_name (object)); -} - -static dbus_bool_t -impl_set_name (DBusMessageIter *iter, void *user_data) -{ - AtkObject *object = (AtkObject *) user_data; - const char *name = droute_get_v_string (iter); - - g_return_val_if_fail (ATK_IS_OBJECT (user_data), FALSE); - - atk_object_set_name (object, name); - return TRUE; -} - -static dbus_bool_t -impl_get_description (DBusMessageIter *iter, void *user_data) -{ - AtkObject *object = (AtkObject *) user_data; - - g_return_val_if_fail (ATK_IS_OBJECT (user_data), FALSE); - - return droute_return_v_string (iter, atk_object_get_description (object)); -} - -static dbus_bool_t -impl_set_description (DBusMessageIter *iter, void *user_data) -{ - AtkObject *object = (AtkObject *) user_data; - const char *description = droute_get_v_string (iter); - - g_return_val_if_fail (ATK_IS_OBJECT (user_data), FALSE); - - atk_object_set_description (object, description); - return TRUE; -} - -static dbus_bool_t -impl_get_parent (DBusMessageIter *iter, void *user_data) -{ - AtkObject *object = (AtkObject *) user_data; - - g_return_val_if_fail (ATK_IS_OBJECT (user_data), FALSE); - - return spi_dbus_return_v_object (iter, - atk_object_get_parent (object), - FALSE); -} - -static dbus_bool_t -impl_get_childCount (DBusMessageIter *iter, void *user_data) -{ - AtkObject *object = (AtkObject *) user_data; - - g_return_val_if_fail (ATK_IS_OBJECT (user_data), FALSE); - - return droute_return_v_int32 (iter, - atk_object_get_n_accessible_children - (object)); -} - -static DBusMessage * -impl_getChildAtIndex (DBusConnection *bus, - DBusMessage *message, - void *user_data) -{ - AtkObject *object = (AtkObject *) user_data; - DBusError error; - dbus_int32_t i; - AtkObject *child; - - dbus_error_init (&error); - g_return_val_if_fail (ATK_IS_OBJECT (user_data), - droute_not_yet_handled_error (message)); - if (!dbus_message_get_args (message, &error, DBUS_TYPE_INT32, &i, DBUS_TYPE_INVALID)) - return spi_dbus_general_error (message); - child = atk_object_ref_accessible_child (object, i); - return spi_dbus_return_object (message, child, FALSE); -} - -static DBusMessage * -impl_getChildren (DBusConnection *bus, - DBusMessage *message, - void *user_data) -{ - AtkObject *object = (AtkObject *) user_data; - gint i; - gint count; - DBusMessage *reply; - DBusMessageIter iter, iter_array; - - g_return_val_if_fail (ATK_IS_OBJECT (user_data), - droute_not_yet_handled_error (message)); - count = atk_object_get_n_accessible_children (object); - reply = dbus_message_new_method_return (message); - if (!reply) goto oom; - dbus_message_iter_init_append (reply, &iter); - if (!dbus_message_iter_open_container - (&iter, DBUS_TYPE_ARRAY, "o", &iter_array)) - goto oom; - for (i = 0; i < count; i++) - { - AtkObject *child = atk_object_ref_accessible_child (object, i); - char *path = atk_dbus_object_to_path (child); - if (path) - { - dbus_message_iter_append_basic (&iter_array, DBUS_TYPE_OBJECT_PATH, - &path); - g_free (path); - } - if (child) - g_object_unref (child); - } - if (!dbus_message_iter_close_container (&iter, &iter_array)) - goto oom; - return reply; -oom: - // TODO: handle out-of-memory - return reply; -} - -static DBusMessage * -impl_getIndexInParent (DBusConnection *bus, - DBusMessage *message, - void *user_data) -{ - AtkObject *object = (AtkObject *) user_data; - dbus_uint32_t rv; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_OBJECT (user_data), - droute_not_yet_handled_error (message)); - rv = atk_object_get_index_in_parent (object); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_UINT32, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static gboolean -spi_init_relation_type_table (Accessibility_RelationType *types) -{ - gint i; - - for (i = 0; i < ATK_RELATION_LAST_DEFINED; i++) - types[i] = Accessibility_RELATION_NULL; - - types[ATK_RELATION_CONTROLLED_BY] = Accessibility_RELATION_CONTROLLED_BY; - types[ATK_RELATION_CONTROLLER_FOR] = Accessibility_RELATION_CONTROLLER_FOR; - types[ATK_RELATION_LABEL_FOR] = Accessibility_RELATION_LABEL_FOR; - types[ATK_RELATION_LABELLED_BY] = Accessibility_RELATION_LABELLED_BY; - types[ATK_RELATION_MEMBER_OF] = Accessibility_RELATION_MEMBER_OF; - types[ATK_RELATION_NODE_CHILD_OF] = Accessibility_RELATION_NODE_CHILD_OF; - types[ATK_RELATION_FLOWS_TO] = Accessibility_RELATION_FLOWS_TO; - types[ATK_RELATION_FLOWS_FROM] = Accessibility_RELATION_FLOWS_FROM; - types[ATK_RELATION_SUBWINDOW_OF] = Accessibility_RELATION_SUBWINDOW_OF; - types[ATK_RELATION_EMBEDS] = Accessibility_RELATION_EMBEDS; - types[ATK_RELATION_EMBEDDED_BY] = Accessibility_RELATION_EMBEDDED_BY; - types[ATK_RELATION_POPUP_FOR] = Accessibility_RELATION_POPUP_FOR; - types[ATK_RELATION_PARENT_WINDOW_OF] = Accessibility_RELATION_PARENT_WINDOW_OF; - types[ATK_RELATION_DESCRIPTION_FOR] = Accessibility_RELATION_DESCRIPTION_FOR; - types[ATK_RELATION_DESCRIBED_BY] = Accessibility_RELATION_DESCRIBED_BY; - - return TRUE; -} - -static Accessibility_RelationType -spi_relation_type_from_atk_relation_type (AtkRelationType type) -{ - static gboolean is_initialized = FALSE; - static Accessibility_RelationType spi_relation_type_table [ATK_RELATION_LAST_DEFINED]; - Accessibility_RelationType spi_type; - - if (!is_initialized) - is_initialized = spi_init_relation_type_table (spi_relation_type_table); - - if (type > ATK_RELATION_NULL && type < ATK_RELATION_LAST_DEFINED) - spi_type = spi_relation_type_table[type]; - else - spi_type = Accessibility_RELATION_EXTENDED; - return spi_type; -} - -static DBusMessage * -impl_getRelationSet (DBusConnection *bus, - DBusMessage *message, - void *user_data) -{ - AtkObject *object = (AtkObject *) user_data; - DBusMessage *reply; - AtkRelationSet *set; - DBusMessageIter iter, iter_array, iter_struct, iter_targets; - gint count; - gint i, j; - - g_return_val_if_fail (ATK_IS_OBJECT (user_data), - droute_not_yet_handled_error (message)); - reply = dbus_message_new_method_return (message); - if (!reply) return NULL; - set = atk_object_ref_relation_set (object); - dbus_message_iter_init_append (reply, &iter); - if (!dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "(uao)", &iter_array)) - { - goto oom; - } - count = atk_relation_set_get_n_relations (set); - for (i = 0; i < count; i++) - { - AtkRelation *r = atk_relation_set_get_relation (set, i); - AtkRelationType rt; - GPtrArray *target; - dbus_uint32_t type; - if (!r) continue; - rt= atk_relation_get_relation_type (r); - type = spi_relation_type_from_atk_relation_type (rt); - target = atk_relation_get_target (r); - if (!dbus_message_iter_open_container (&iter_array, DBUS_TYPE_STRUCT, NULL, &iter_struct)) - { - goto oom; - } - dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_UINT32, &type); - if (!dbus_message_iter_open_container (&iter_struct, DBUS_TYPE_ARRAY, "o", &iter_targets)) - { - goto oom; - } - for (j = 0; j < target->len; j++) - { - AtkObject *obj = target->pdata[j]; - char *path; - if (!obj) continue; - path = atk_dbus_object_to_path (obj); - dbus_message_iter_append_basic (&iter_targets, DBUS_TYPE_OBJECT_PATH, &path); - } - dbus_message_iter_close_container (&iter_struct, &iter_targets); - dbus_message_iter_close_container (&iter_array, &iter_struct); - } - dbus_message_iter_close_container (&iter, &iter_array); -oom: - // TODO: handle out of memory */ - return reply; -} - -static gboolean -spi_init_role_lookup_table (Accessibility_Role * role_table) -{ - int i; - /* if it's not in the list below, dunno what it is */ - for (i = 0; i < ATK_ROLE_LAST_DEFINED; ++i) - { - role_table[i] = Accessibility_ROLE_UNKNOWN; - } - - role_table[ATK_ROLE_INVALID] = Accessibility_ROLE_INVALID; - role_table[ATK_ROLE_ACCEL_LABEL] = Accessibility_ROLE_ACCELERATOR_LABEL; - role_table[ATK_ROLE_ALERT] = Accessibility_ROLE_ALERT; - role_table[ATK_ROLE_ANIMATION] = Accessibility_ROLE_ANIMATION; - role_table[ATK_ROLE_ARROW] = Accessibility_ROLE_ARROW; - role_table[ATK_ROLE_CALENDAR] = Accessibility_ROLE_CALENDAR; - role_table[ATK_ROLE_CANVAS] = Accessibility_ROLE_CANVAS; - role_table[ATK_ROLE_CHECK_BOX] = Accessibility_ROLE_CHECK_BOX; - role_table[ATK_ROLE_CHECK_MENU_ITEM] = Accessibility_ROLE_CHECK_MENU_ITEM; - role_table[ATK_ROLE_COLOR_CHOOSER] = Accessibility_ROLE_COLOR_CHOOSER; - role_table[ATK_ROLE_COLUMN_HEADER] = Accessibility_ROLE_COLUMN_HEADER; - role_table[ATK_ROLE_COMBO_BOX] = Accessibility_ROLE_COMBO_BOX; - role_table[ATK_ROLE_DATE_EDITOR] = Accessibility_ROLE_DATE_EDITOR; - role_table[ATK_ROLE_DESKTOP_ICON] = Accessibility_ROLE_DESKTOP_ICON; - role_table[ATK_ROLE_DESKTOP_FRAME] = Accessibility_ROLE_DESKTOP_FRAME; - role_table[ATK_ROLE_DIAL] = Accessibility_ROLE_DIAL; - role_table[ATK_ROLE_DIALOG] = Accessibility_ROLE_DIALOG; - role_table[ATK_ROLE_DIRECTORY_PANE] = Accessibility_ROLE_DIRECTORY_PANE; - role_table[ATK_ROLE_DRAWING_AREA] = Accessibility_ROLE_DRAWING_AREA; - role_table[ATK_ROLE_FILE_CHOOSER] = Accessibility_ROLE_FILE_CHOOSER; - role_table[ATK_ROLE_FILLER] = Accessibility_ROLE_FILLER; - role_table[ATK_ROLE_FONT_CHOOSER] = Accessibility_ROLE_FONT_CHOOSER; - role_table[ATK_ROLE_FRAME] = Accessibility_ROLE_FRAME; - role_table[ATK_ROLE_GLASS_PANE] = Accessibility_ROLE_GLASS_PANE; - role_table[ATK_ROLE_HTML_CONTAINER] = Accessibility_ROLE_HTML_CONTAINER; - role_table[ATK_ROLE_ICON] = Accessibility_ROLE_ICON; - role_table[ATK_ROLE_IMAGE] = Accessibility_ROLE_IMAGE; - role_table[ATK_ROLE_INTERNAL_FRAME] = Accessibility_ROLE_INTERNAL_FRAME; - role_table[ATK_ROLE_LABEL] = Accessibility_ROLE_LABEL; - role_table[ATK_ROLE_LAYERED_PANE] = Accessibility_ROLE_LAYERED_PANE; - role_table[ATK_ROLE_LIST] = Accessibility_ROLE_LIST; - role_table[ATK_ROLE_LIST_ITEM] = Accessibility_ROLE_LIST_ITEM; - role_table[ATK_ROLE_MENU] = Accessibility_ROLE_MENU; - role_table[ATK_ROLE_MENU_BAR] = Accessibility_ROLE_MENU_BAR; - role_table[ATK_ROLE_MENU_ITEM] = Accessibility_ROLE_MENU_ITEM; - role_table[ATK_ROLE_OPTION_PANE] = Accessibility_ROLE_OPTION_PANE; - role_table[ATK_ROLE_PAGE_TAB] = Accessibility_ROLE_PAGE_TAB; - role_table[ATK_ROLE_PAGE_TAB_LIST] = Accessibility_ROLE_PAGE_TAB_LIST; - role_table[ATK_ROLE_PANEL] = Accessibility_ROLE_PANEL; - role_table[ATK_ROLE_PASSWORD_TEXT] = Accessibility_ROLE_PASSWORD_TEXT; - role_table[ATK_ROLE_POPUP_MENU] = Accessibility_ROLE_POPUP_MENU; - role_table[ATK_ROLE_PROGRESS_BAR] = Accessibility_ROLE_PROGRESS_BAR; - role_table[ATK_ROLE_PUSH_BUTTON] = Accessibility_ROLE_PUSH_BUTTON; - role_table[ATK_ROLE_RADIO_BUTTON] = Accessibility_ROLE_RADIO_BUTTON; - role_table[ATK_ROLE_RADIO_MENU_ITEM] = Accessibility_ROLE_RADIO_MENU_ITEM; - role_table[ATK_ROLE_ROOT_PANE] = Accessibility_ROLE_ROOT_PANE; - role_table[ATK_ROLE_ROW_HEADER] = Accessibility_ROLE_ROW_HEADER; - role_table[ATK_ROLE_SCROLL_BAR] = Accessibility_ROLE_SCROLL_BAR; - role_table[ATK_ROLE_SCROLL_PANE] = Accessibility_ROLE_SCROLL_PANE; - role_table[ATK_ROLE_SEPARATOR] = Accessibility_ROLE_SEPARATOR; - role_table[ATK_ROLE_SLIDER] = Accessibility_ROLE_SLIDER; - role_table[ATK_ROLE_SPIN_BUTTON] = Accessibility_ROLE_SPIN_BUTTON; - role_table[ATK_ROLE_SPLIT_PANE] = Accessibility_ROLE_SPLIT_PANE; - role_table[ATK_ROLE_STATUSBAR] = Accessibility_ROLE_STATUS_BAR; - role_table[ATK_ROLE_TABLE] = Accessibility_ROLE_TABLE; - role_table[ATK_ROLE_TABLE_CELL] = Accessibility_ROLE_TABLE_CELL; - role_table[ATK_ROLE_TABLE_COLUMN_HEADER] = - Accessibility_ROLE_TABLE_COLUMN_HEADER; - role_table[ATK_ROLE_TABLE_ROW_HEADER] = Accessibility_ROLE_TABLE_ROW_HEADER; - role_table[ATK_ROLE_TEAR_OFF_MENU_ITEM] = - Accessibility_ROLE_TEAROFF_MENU_ITEM; - role_table[ATK_ROLE_TERMINAL] = Accessibility_ROLE_TERMINAL; - role_table[ATK_ROLE_TEXT] = Accessibility_ROLE_TEXT; - role_table[ATK_ROLE_TOGGLE_BUTTON] = Accessibility_ROLE_TOGGLE_BUTTON; - role_table[ATK_ROLE_TOOL_BAR] = Accessibility_ROLE_TOOL_BAR; - role_table[ATK_ROLE_TOOL_TIP] = Accessibility_ROLE_TOOL_TIP; - role_table[ATK_ROLE_TREE] = Accessibility_ROLE_TREE; - role_table[ATK_ROLE_TREE_TABLE] = Accessibility_ROLE_TREE_TABLE; - role_table[ATK_ROLE_UNKNOWN] = Accessibility_ROLE_UNKNOWN; - role_table[ATK_ROLE_VIEWPORT] = Accessibility_ROLE_VIEWPORT; - role_table[ATK_ROLE_WINDOW] = Accessibility_ROLE_WINDOW; - role_table[ATK_ROLE_HEADER] = Accessibility_ROLE_HEADER; - role_table[ATK_ROLE_FOOTER] = Accessibility_ROLE_FOOTER; - role_table[ATK_ROLE_PARAGRAPH] = Accessibility_ROLE_PARAGRAPH; - role_table[ATK_ROLE_RULER] = Accessibility_ROLE_RULER; - role_table[ATK_ROLE_APPLICATION] = Accessibility_ROLE_APPLICATION; - role_table[ATK_ROLE_AUTOCOMPLETE] = Accessibility_ROLE_AUTOCOMPLETE; - role_table[ATK_ROLE_EDITBAR] = Accessibility_ROLE_EDITBAR; - role_table[ATK_ROLE_EMBEDDED] = Accessibility_ROLE_EMBEDDED; - role_table[ATK_ROLE_ENTRY] = Accessibility_ROLE_ENTRY; - role_table[ATK_ROLE_CHART] = Accessibility_ROLE_CHART; - role_table[ATK_ROLE_CAPTION] = Accessibility_ROLE_CAPTION; - role_table[ATK_ROLE_DOCUMENT_FRAME] = Accessibility_ROLE_DOCUMENT_FRAME; - role_table[ATK_ROLE_HEADING] = Accessibility_ROLE_HEADING; - role_table[ATK_ROLE_PAGE] = Accessibility_ROLE_PAGE; - role_table[ATK_ROLE_SECTION] = Accessibility_ROLE_SECTION; - role_table[ATK_ROLE_FORM] = Accessibility_ROLE_FORM; - role_table[ATK_ROLE_REDUNDANT_OBJECT] = Accessibility_ROLE_REDUNDANT_OBJECT; - role_table[ATK_ROLE_LINK] = Accessibility_ROLE_LINK; - role_table[ATK_ROLE_INPUT_METHOD_WINDOW] = - Accessibility_ROLE_INPUT_METHOD_WINDOW; - return TRUE; -} - -Accessibility_Role -spi_accessible_role_from_atk_role (AtkRole role) -{ - static gboolean is_initialized = FALSE; - static Accessibility_Role spi_role_table[ATK_ROLE_LAST_DEFINED]; - Accessibility_Role spi_role; - - if (!is_initialized) - { - is_initialized = spi_init_role_lookup_table (spi_role_table); - } - - if (role >= 0 && role < ATK_ROLE_LAST_DEFINED) - { - spi_role = spi_role_table[role]; - } - else - { - spi_role = Accessibility_ROLE_EXTENDED; - } - return spi_role; -} - -static DBusMessage * -impl_getRole (DBusConnection *bus, DBusMessage *message, void *user_data) -{ - AtkObject *object = (AtkObject *) user_data; - gint role; - dbus_uint32_t rv; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_OBJECT (user_data), - droute_not_yet_handled_error (message)); - role = atk_object_get_role (object); - rv = spi_accessible_role_from_atk_role (role); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_UINT32, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static char * -impl_get_role_str (void *datum) -{ - g_assert (ATK_IS_OBJECT (datum)); - return g_strdup_printf ("%d", - spi_accessible_role_from_atk_role - (atk_object_get_role ((AtkObject *) datum))); -} - -static DBusMessage * -impl_getRoleName (DBusConnection *bus, - DBusMessage *message, - void *user_data) -{ - AtkObject *object = (AtkObject *) user_data; - gint role; - const char *role_name; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_OBJECT (user_data), - droute_not_yet_handled_error (message)); - role = atk_object_get_role (object); - role_name = atk_role_get_name (role); - if (!role_name) - role_name = ""; - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_STRING, &role_name, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getLocalizedRoleName (DBusConnection *bus, - DBusMessage *message, - void *user_data) -{ - AtkObject *object = (AtkObject *) user_data; - gint role; - const char *role_name; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_OBJECT (user_data), - droute_not_yet_handled_error (message)); - role = atk_object_get_role (object); - role_name = atk_role_get_localized_name (role); - if (!role_name) - role_name = ""; - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_STRING, &role_name, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getState (DBusConnection *bus, - DBusMessage *message, - void *user_data) -{ - AtkObject *object = (AtkObject *) user_data; - dbus_uint32_t rv[2]; - dbus_uint32_t *array = rv; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_OBJECT (user_data), - droute_not_yet_handled_error (message)); - spi_atk_state_to_dbus_array (object, rv); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &array, - 2, DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getAttributes (DBusConnection *bus, - DBusMessage *message, - void *user_data) -{ - AtkObject *object = (AtkObject *) user_data; - DBusMessage *reply; - AtkAttributeSet *attributes; - AtkAttribute *attr = NULL; - char **retval; - gint n_attributes = 0; - gint i; - - g_return_val_if_fail (ATK_IS_OBJECT (user_data), - droute_not_yet_handled_error (message)); - - attributes = atk_object_get_attributes (object); - if (attributes) - n_attributes = g_slist_length (attributes); - - retval = (char **) g_malloc (n_attributes * sizeof (char *)); - - for (i = 0; i < n_attributes; ++i) - { - attr = g_slist_nth_data (attributes, i); - retval[i] = g_strconcat (attr->name, ":", attr->value, NULL); - } - if (attributes) - atk_attribute_set_free (attributes); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, - &retval, n_attributes, DBUS_TYPE_INVALID); - } - for (i = 0; i < n_attributes; i++) - g_free (retval[i]); - g_free (retval); - return reply; -} - -static DBusMessage * -impl_getApplication (DBusConnection *bus, - DBusMessage *message, - void *user_data) -{ - AtkObject *root = atk_get_root (); - return spi_dbus_return_object (message, root, FALSE); -} - -static DRouteMethod methods[] = { - {impl_getChildAtIndex, "getChildAtIndex"}, - {impl_getChildren, "getChildren"}, - {impl_getIndexInParent, "getIndexInParent"}, - {impl_getRelationSet, "getRelationSet"}, - {impl_getRole, "getRole"}, - {impl_getRoleName, "getRoleName"}, - {impl_getLocalizedRoleName, "getLocalizedRoleName"}, - {impl_getState, "getState"}, - {impl_getAttributes, "getAttributes"}, - {impl_getApplication, "getApplication"}, - {NULL, NULL} -}; - -static DRouteProperty properties[] = { - {impl_get_name, impl_set_name, "name"}, - {impl_get_description, impl_set_description, "description"}, - {impl_get_parent, NULL, "parent"}, - {impl_get_childCount, NULL, "childCount"}, - {NULL, NULL, NULL} -}; - -void -spi_initialize_accessible (DRoutePath *path) -{ - droute_path_add_interface (path, - SPI_DBUS_INTERFACE_ACCESSIBLE, - methods, - properties); -}; diff --git a/atk-adaptor/accessible.h b/atk-adaptor/accessible.h deleted file mode 100644 index f15b397..0000000 --- a/atk-adaptor/accessible.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) - * - * Copyright 2001, 2002 Sun Microsystems Inc., - * Copyright 2001, 2002 Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef SPI_ACCESSIBLE_H_ -#define SPI_ACCESSIBLE_H_ - -#include -#include - -G_BEGIN_DECLS - -Accessibility_Role spi_accessible_role_from_atk_role (AtkRole role); - -G_END_DECLS - -#endif /* SPI_ACCESSIBLE_H_ */ diff --git a/atk-adaptor/action-adaptor.c b/atk-adaptor/action-adaptor.c new file mode 100644 index 0000000..e9da657 --- /dev/null +++ b/atk-adaptor/action-adaptor.c @@ -0,0 +1,204 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2008 Novell, Inc. + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include + +#include "spi-common/spi-dbus.h" + +static dbus_bool_t +impl_get_nActions (DBusMessageIter *iter, void *user_data) +{ + AtkAction *action = (AtkAction *) user_data; + + g_return_val_if_fail (ATK_IS_ACTION (user_data), FALSE); + return droute_return_v_int32 (iter, atk_action_get_n_actions (action)); +} + +static DBusMessage * +impl_get_description (DBusConnection *bus, DBusMessage *message, void *user_data) +{ + AtkAction *action = (AtkAction *) user_data; + DBusError error; + DBusMessage *reply; + dbus_int32_t index; + const char *desc; + + dbus_error_init (&error); + g_return_val_if_fail (ATK_IS_ACTION (user_data), + droute_not_yet_handled_error (message)); + if (!dbus_message_get_args (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID)) + { + return spi_dbus_general_error (message); + } + desc = atk_action_get_description(action, index); + if (!desc) desc = ""; + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_STRING, &desc, DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_get_name (DBusConnection *bus, DBusMessage *message, void *user_data) +{ + DBusMessage *reply; + DBusError error; + dbus_int32_t index; + const char *name; + AtkAction *action = (AtkAction *) user_data; + + dbus_error_init (&error); + g_return_val_if_fail (ATK_IS_ACTION (user_data), + droute_not_yet_handled_error (message)); + if (!dbus_message_get_args (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID)) + { + return spi_dbus_general_error (message); + } + name = atk_action_get_name(action, index); + if (!name) name = ""; + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_get_keybinding (DBusConnection *bus, DBusMessage *message, void *user_data) +{ + DBusMessage *reply; + DBusError error; + dbus_int32_t index; + const char *kb; + AtkAction *action = (AtkAction *) user_data; + + dbus_error_init (&error); + g_return_val_if_fail (ATK_IS_ACTION (user_data), + droute_not_yet_handled_error (message)); + if (!dbus_message_get_args (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID)) + { + return spi_dbus_general_error (message); + } + kb = atk_action_get_keybinding(action, index); + if (!kb) kb = ""; + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_STRING, &kb, DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage *impl_getActions(DBusConnection *bus, DBusMessage *message, void *user_data) +{ + AtkAction *action = (AtkAction *) user_data; + DBusMessage *reply; + gint count; + gint i; + DBusMessageIter iter, iter_array, iter_struct; + + g_return_val_if_fail (ATK_IS_ACTION (user_data), + droute_not_yet_handled_error (message)); + count = atk_action_get_n_actions(action); + reply = dbus_message_new_method_return (message); + if (!reply) goto oom; + dbus_message_iter_init_append (reply, &iter); + if (!dbus_message_iter_open_container + (&iter, DBUS_TYPE_ARRAY, "(sss)", &iter_array)) + goto oom; + for (i = 0; i < count; i++) + { + const char *name = atk_action_get_name(action, i); + const char *desc = atk_action_get_description(action, i); + const char *kb = atk_action_get_keybinding(action, i); + if (!name) name = ""; + if (!desc) desc = ""; + if (!kb) kb = ""; + if (!dbus_message_iter_open_container(&iter_array, DBUS_TYPE_STRUCT, NULL, &iter_struct)) goto oom; + dbus_message_iter_append_basic(&iter_struct, DBUS_TYPE_STRING, &name); + dbus_message_iter_append_basic(&iter_struct, DBUS_TYPE_STRING, &desc); + dbus_message_iter_append_basic(&iter_struct, DBUS_TYPE_STRING, &kb); + if (!dbus_message_iter_close_container(&iter_array, &iter_struct)) goto oom; + } + if (!dbus_message_iter_close_container (&iter, &iter_array)) + goto oom; + return reply; +oom: + // TODO: handle out-of-memory + return reply; +} + +static DBusMessage *impl_doAction(DBusConnection *bus, DBusMessage *message, void *user_data) +{ + AtkAction *action = (AtkAction *) user_data; + DBusError error; + dbus_int32_t index; + dbus_bool_t rv; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_ACTION (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + rv = atk_action_do_action(action, index); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, DBUS_TYPE_INVALID); + } + return reply; +} + +DRouteMethod methods[] = +{ + { impl_get_description, "getDescription" }, + { impl_get_name, "getName" }, + { impl_get_keybinding, "getKeyBinding" }, + {impl_getActions, "getActions"}, + {impl_doAction, "doAction"}, + {NULL, NULL } +}; + +static DRouteProperty properties[] = +{ + { impl_get_nActions, NULL, "nActions" }, + { NULL, NULL } +}; + +void +spi_initialize_action (DRoutePath *path) +{ + droute_path_add_interface (path, + SPI_DBUS_INTERFACE_ACTION, + methods, + properties); +}; diff --git a/atk-adaptor/action.c b/atk-adaptor/action.c deleted file mode 100644 index e9da657..0000000 --- a/atk-adaptor/action.c +++ /dev/null @@ -1,204 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) - * - * Copyright 2008 Novell, Inc. - * Copyright 2001, 2002 Sun Microsystems Inc., - * Copyright 2001, 2002 Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include - -#include "spi-common/spi-dbus.h" - -static dbus_bool_t -impl_get_nActions (DBusMessageIter *iter, void *user_data) -{ - AtkAction *action = (AtkAction *) user_data; - - g_return_val_if_fail (ATK_IS_ACTION (user_data), FALSE); - return droute_return_v_int32 (iter, atk_action_get_n_actions (action)); -} - -static DBusMessage * -impl_get_description (DBusConnection *bus, DBusMessage *message, void *user_data) -{ - AtkAction *action = (AtkAction *) user_data; - DBusError error; - DBusMessage *reply; - dbus_int32_t index; - const char *desc; - - dbus_error_init (&error); - g_return_val_if_fail (ATK_IS_ACTION (user_data), - droute_not_yet_handled_error (message)); - if (!dbus_message_get_args (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID)) - { - return spi_dbus_general_error (message); - } - desc = atk_action_get_description(action, index); - if (!desc) desc = ""; - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_STRING, &desc, DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_get_name (DBusConnection *bus, DBusMessage *message, void *user_data) -{ - DBusMessage *reply; - DBusError error; - dbus_int32_t index; - const char *name; - AtkAction *action = (AtkAction *) user_data; - - dbus_error_init (&error); - g_return_val_if_fail (ATK_IS_ACTION (user_data), - droute_not_yet_handled_error (message)); - if (!dbus_message_get_args (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID)) - { - return spi_dbus_general_error (message); - } - name = atk_action_get_name(action, index); - if (!name) name = ""; - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_get_keybinding (DBusConnection *bus, DBusMessage *message, void *user_data) -{ - DBusMessage *reply; - DBusError error; - dbus_int32_t index; - const char *kb; - AtkAction *action = (AtkAction *) user_data; - - dbus_error_init (&error); - g_return_val_if_fail (ATK_IS_ACTION (user_data), - droute_not_yet_handled_error (message)); - if (!dbus_message_get_args (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID)) - { - return spi_dbus_general_error (message); - } - kb = atk_action_get_keybinding(action, index); - if (!kb) kb = ""; - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_STRING, &kb, DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage *impl_getActions(DBusConnection *bus, DBusMessage *message, void *user_data) -{ - AtkAction *action = (AtkAction *) user_data; - DBusMessage *reply; - gint count; - gint i; - DBusMessageIter iter, iter_array, iter_struct; - - g_return_val_if_fail (ATK_IS_ACTION (user_data), - droute_not_yet_handled_error (message)); - count = atk_action_get_n_actions(action); - reply = dbus_message_new_method_return (message); - if (!reply) goto oom; - dbus_message_iter_init_append (reply, &iter); - if (!dbus_message_iter_open_container - (&iter, DBUS_TYPE_ARRAY, "(sss)", &iter_array)) - goto oom; - for (i = 0; i < count; i++) - { - const char *name = atk_action_get_name(action, i); - const char *desc = atk_action_get_description(action, i); - const char *kb = atk_action_get_keybinding(action, i); - if (!name) name = ""; - if (!desc) desc = ""; - if (!kb) kb = ""; - if (!dbus_message_iter_open_container(&iter_array, DBUS_TYPE_STRUCT, NULL, &iter_struct)) goto oom; - dbus_message_iter_append_basic(&iter_struct, DBUS_TYPE_STRING, &name); - dbus_message_iter_append_basic(&iter_struct, DBUS_TYPE_STRING, &desc); - dbus_message_iter_append_basic(&iter_struct, DBUS_TYPE_STRING, &kb); - if (!dbus_message_iter_close_container(&iter_array, &iter_struct)) goto oom; - } - if (!dbus_message_iter_close_container (&iter, &iter_array)) - goto oom; - return reply; -oom: - // TODO: handle out-of-memory - return reply; -} - -static DBusMessage *impl_doAction(DBusConnection *bus, DBusMessage *message, void *user_data) -{ - AtkAction *action = (AtkAction *) user_data; - DBusError error; - dbus_int32_t index; - dbus_bool_t rv; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_ACTION (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - rv = atk_action_do_action(action, index); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, DBUS_TYPE_INVALID); - } - return reply; -} - -DRouteMethod methods[] = -{ - { impl_get_description, "getDescription" }, - { impl_get_name, "getName" }, - { impl_get_keybinding, "getKeyBinding" }, - {impl_getActions, "getActions"}, - {impl_doAction, "doAction"}, - {NULL, NULL } -}; - -static DRouteProperty properties[] = -{ - { impl_get_nActions, NULL, "nActions" }, - { NULL, NULL } -}; - -void -spi_initialize_action (DRoutePath *path) -{ - droute_path_add_interface (path, - SPI_DBUS_INTERFACE_ACTION, - methods, - properties); -}; diff --git a/atk-adaptor/adaptors.h b/atk-adaptor/adaptors.h new file mode 100644 index 0000000..d871a7b --- /dev/null +++ b/atk-adaptor/adaptors.h @@ -0,0 +1,48 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef ADAPTORS_H +#define ADAPTORS_H + +#include +#include + +Accessibility_Role spi_accessible_role_from_atk_role (AtkRole role); + +void spi_initialize_accessible (DRoutePath *path); +void spi_initialize_action (DRoutePath *path); +void spi_initialize_application (DRoutePath *path); +void spi_initialize_collection (DRoutePath *path); +void spi_initialize_component (DRoutePath *path); +void spi_initialize_document (DRoutePath *path); +void spi_initialize_editabletext (DRoutePath *path); +void spi_initialize_hyperlink (DRoutePath *path); +void spi_initialize_hypertext (DRoutePath *path); +void spi_initialize_image (DRoutePath *path); +void spi_initialize_selection (DRoutePath *path); +void spi_initialize_table (DRoutePath *path); +void spi_initialize_text (DRoutePath *path); +void spi_initialize_value (DRoutePath *path); +void spi_initialize_tree (DRoutePath *path); + +#endif /* ADAPTORS_H */ diff --git a/atk-adaptor/application-adaptor.c b/atk-adaptor/application-adaptor.c new file mode 100644 index 0000000..cf6b689 --- /dev/null +++ b/atk-adaptor/application-adaptor.c @@ -0,0 +1,120 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2008 Novell, Inc. + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include + +#include "spi-common/spi-dbus.h" + +static dbus_bool_t +impl_get_toolkitName (DBusMessageIter * iter, + void *user_data) +{ + return droute_return_v_string (iter, atk_get_toolkit_name ()); +} + +static dbus_bool_t +impl_get_version (DBusMessageIter * iter, void *user_data) +{ + return droute_return_v_string (iter, atk_get_toolkit_version ()); +} + +static dbus_int32_t id; + +static dbus_bool_t +impl_get_id (DBusMessageIter * iter, void *user_data) +{ + return droute_return_v_int32 (iter, id); +} + +static dbus_bool_t +impl_set_id (DBusMessageIter * iter, void *user_data) +{ + id = droute_get_v_int32 (iter); + return TRUE; +} + +static DBusMessage * +impl_registerToolkitEventListener (DBusConnection * bus, + DBusMessage * message, void *user_data) +{ + return NULL; +} + +static DBusMessage * +impl_registerObjectEventListener (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + return NULL; +} + +static DBusMessage * +impl_pause (DBusConnection * bus, DBusMessage * message, void *user_data) +{ + return NULL; +} + +static DBusMessage * +impl_resume (DBusConnection * bus, DBusMessage * message, void *user_data) +{ + return NULL; +} + +static DBusMessage * +impl_getLocale (DBusConnection * bus, DBusMessage * message, void *user_data) +{ + return NULL; +} + +static DRouteMethod methods[] = { + {impl_registerToolkitEventListener, "registerToolkitEventListener"}, + {impl_registerObjectEventListener, "registerObjectEventListener"}, + {impl_pause, "pause"}, + {impl_resume, "resume"}, + {impl_getLocale, "getLocale"}, + {NULL, NULL} +}; + +static DRouteProperty properties[] = { + {impl_get_toolkitName, NULL, "toolkitName"}, + {impl_get_version, NULL, "version"}, + {impl_get_id, impl_set_id, "id"}, + {NULL, NULL, NULL} +}; + +/*static long +obj_is_root (const char *path, void *user_data) +{ + AtkObject *obj = atk_dbus_get_object (path); + return (obj == atk_get_root ()); +}*/ + +void +spi_initialize_application (DRoutePath *path) +{ + droute_path_add_interface (path, + SPI_DBUS_INTERFACE_APPLICATION, + methods, + properties); +}; diff --git a/atk-adaptor/application.c b/atk-adaptor/application.c deleted file mode 100644 index cf6b689..0000000 --- a/atk-adaptor/application.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) - * - * Copyright 2008 Novell, Inc. - * Copyright 2001, 2002 Sun Microsystems Inc., - * Copyright 2001, 2002 Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include - -#include "spi-common/spi-dbus.h" - -static dbus_bool_t -impl_get_toolkitName (DBusMessageIter * iter, - void *user_data) -{ - return droute_return_v_string (iter, atk_get_toolkit_name ()); -} - -static dbus_bool_t -impl_get_version (DBusMessageIter * iter, void *user_data) -{ - return droute_return_v_string (iter, atk_get_toolkit_version ()); -} - -static dbus_int32_t id; - -static dbus_bool_t -impl_get_id (DBusMessageIter * iter, void *user_data) -{ - return droute_return_v_int32 (iter, id); -} - -static dbus_bool_t -impl_set_id (DBusMessageIter * iter, void *user_data) -{ - id = droute_get_v_int32 (iter); - return TRUE; -} - -static DBusMessage * -impl_registerToolkitEventListener (DBusConnection * bus, - DBusMessage * message, void *user_data) -{ - return NULL; -} - -static DBusMessage * -impl_registerObjectEventListener (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - return NULL; -} - -static DBusMessage * -impl_pause (DBusConnection * bus, DBusMessage * message, void *user_data) -{ - return NULL; -} - -static DBusMessage * -impl_resume (DBusConnection * bus, DBusMessage * message, void *user_data) -{ - return NULL; -} - -static DBusMessage * -impl_getLocale (DBusConnection * bus, DBusMessage * message, void *user_data) -{ - return NULL; -} - -static DRouteMethod methods[] = { - {impl_registerToolkitEventListener, "registerToolkitEventListener"}, - {impl_registerObjectEventListener, "registerObjectEventListener"}, - {impl_pause, "pause"}, - {impl_resume, "resume"}, - {impl_getLocale, "getLocale"}, - {NULL, NULL} -}; - -static DRouteProperty properties[] = { - {impl_get_toolkitName, NULL, "toolkitName"}, - {impl_get_version, NULL, "version"}, - {impl_get_id, impl_set_id, "id"}, - {NULL, NULL, NULL} -}; - -/*static long -obj_is_root (const char *path, void *user_data) -{ - AtkObject *obj = atk_dbus_get_object (path); - return (obj == atk_get_root ()); -}*/ - -void -spi_initialize_application (DRoutePath *path) -{ - droute_path_add_interface (path, - SPI_DBUS_INTERFACE_APPLICATION, - methods, - properties); -}; diff --git a/atk-adaptor/atk-dbus.c b/atk-adaptor/atk-dbus.c deleted file mode 100644 index 956fb29..0000000 --- a/atk-adaptor/atk-dbus.c +++ /dev/null @@ -1,393 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) - * - * Copyright 2008 Novell, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include -#include - -#include "bridge.h" -#include "accessible.h" -#include "atk-dbus.h" - -/* TODO - * Need to add concurrency support. - */ - -#define ATK_BRIDGE_OBJECT_PATH_PREFIX "/org/freedesktop/atspi/accessible" -#define ATK_BRIDGE_OBJECT_REFERENCE_TEMPLATE ATK_BRIDGE_OBJECT_PATH_PREFIX "/%d" -#define ATK_BRIDGE_PATH_PREFIX_LENGTH 33 - -/* - * This module is responsible for keeping track of all the AtkObjects in - * the application, so that they can be accessed remotely and placed in - * a client side cache. - * - * To access an AtkObject remotely we need to provide a D-Bus object - * path for it. The D-Bus object paths used have a standard prefix - * (ATK_BRIDGE_OBJECT_PATH_PREFIX). Appended to this prefix is a string - * representation of an integer reference. So to access an AtkObject - * remotely we keep a Hashtable that maps the given reference to - * the AtkObject pointer. An object in this hash table is said to be 'registered'. - * - * The architecture of AT-SPI dbus is such that AtkObjects are not - * remotely reference counted. This means that we need to keep track of - * object destruction. When an object is destroyed it must be 'deregistered' - * To do this lookup we keep a dbus-id attribute on each AtkObject. - * - * In addition to accessing the objects remotely we must be able to update - * the client side cache. This is done using the 'update' signal of the - * org.freedesktop.atspi.Tree interface. The update signal should send out - * all of the cacheable data for each AtkObject that has changed since the - * last update. It should also provide a list of objects that have been - * removed since the last update. - */ - -/* Amazingly the ATK event callbacks dont have a user - * data parameter. Instead, with great sadness, we use - * some global data. Data is declared and initialized - * in bridge.c. - */ - -GHashTable *ref2ptr = NULL; /* Used for converting a D-Bus path (Reference) to the object pointer */ - -static guint counter = 1; - -extern SpiAppData *atk_adaptor_app_data; - -/*---------------------------------------------------------------------------*/ - -/* - * Each AtkObject must be asssigned a D-Bus path (Reference) - * - * This function provides an integer reference for a new - * AtkObject. - */ -static guint -assign_reference(void) -{ - counter++; - /* Reference of 0 not allowed as used as direct key in hash table */ - if (counter == 0) - counter++; -} - -/*---------------------------------------------------------------------------*/ - -void -atk_dbus_foreach_registered(GHFunc func, gpointer data) -{ - g_hash_table_foreach(ref2ptr, func, data); -} - -/*---------------------------------------------------------------------------*/ - -/* - * Called when a registered AtkObject is deleted. - * Removes the AtkObject from the reference lookup tables. - * Sets the client side cache to be updated. - */ -static void -deregister_accessible(gpointer data, GObject *accessible) -{ - guint ref; - gchar *path; - - g_assert(ATK_IS_OBJECT(accessible)); - - - ref = atk_dbus_object_to_ref (ATK_OBJECT(accessible)); - - if (ref != 0) - { - g_hash_table_remove(ref2ptr, GINT_TO_POINTER(ref)); - /* - * TODO - * Pyatspi client side exceptions have occured indicating - * that an object has been removed twice. - * This should not be possible and needs investigation. - */ - spi_emit_cache_removal (ref, atk_adaptor_app_data->bus); - } -} - -/*---------------------------------------------------------------------------*/ - -/* - * This function registers the object so that it is exported - * over D-Bus and schedules an update to client side cache. - */ -static guint -export (GList **uplist, AtkObject *accessible) -{ - guint ref; - gchar *path; - - g_assert(ATK_IS_OBJECT(accessible)); - - ref = assign_reference(); - - g_hash_table_insert (ref2ptr, GINT_TO_POINTER(ref), accessible); - g_object_set_data (G_OBJECT(accessible), "dbus-id", GINT_TO_POINTER(ref)); - g_object_weak_ref(G_OBJECT(accessible), deregister_accessible, NULL); - - *uplist = g_list_prepend (*uplist, accessible); - - return ref; -} - -/* - * This does a depth first traversal of a subtree of AtkObject - * and exports them as Accessible objects if they are not exported - * already. - */ -static guint -export_subtree (AtkObject *accessible) -{ - AtkObject *current, *tmp; - GQueue *stack; - GList *uplist = NULL; - guint i, ref; - gboolean recurse; - - stack = g_queue_new (); - - current = g_object_ref (accessible); - ref = export (&uplist, current); - g_queue_push_head (stack, GINT_TO_POINTER (0)); - - /* - * The index held on the stack is the next child node - * that needs processing at the corresponding level in the tree. - */ - while (!g_queue_is_empty (stack)) - { - /* This while loop finds the next node that needs processing, - * if one exists. - */ - i = GPOINTER_TO_INT(g_queue_peek_head (stack)); - recurse = FALSE; - while (i < atk_object_get_n_accessible_children (current) && - recurse == FALSE) - { - tmp = atk_object_ref_accessible_child (current, i); - if (!atk_dbus_object_to_ref (tmp)) - { - recurse = TRUE; - } - else - { - i++; - g_object_unref (G_OBJECT (tmp)); - } - } - if (recurse) - { - /* Still children to process */ - current = tmp; - export (&uplist, current); - /* Update parent nodes next child index */ - g_queue_peek_head_link (stack)->data = GINT_TO_POINTER (i+1); - /* Push a new child index for the current node */ - g_queue_push_head (stack, GINT_TO_POINTER (0)); - } - else - { - /* No more children, move to parent */ - tmp = current; - current = atk_object_get_parent (current); - g_object_unref (G_OBJECT (tmp)); - g_queue_pop_head (stack); - } - } - spi_emit_cache_update (uplist, atk_adaptor_app_data->bus); - g_list_free (uplist); - return ref; -} - -/*---------------------------------------------------------------------------*/ - -/* Called to register an AtkObject with AT-SPI and expose it over D-Bus. */ -guint -atk_dbus_register_accessible (AtkObject *accessible) -{ - guint ref; - g_assert(ATK_IS_OBJECT(accessible)); - - ref = atk_dbus_object_to_ref (accessible); - if (!ref) - return export_subtree (accessible); - else - return ref; -} - -/* Called when an already registered object is updated in such a - * way that client side cache needs to be updated. - */ -guint -atk_dbus_update_accessible (AtkObject *accessible) -{ - guint ref = 0; - g_assert(ATK_IS_OBJECT(accessible)); - - ref = atk_dbus_object_to_ref (accessible); - if (ref) - { - spi_emit_cache_update (accessible, atk_adaptor_app_data->bus); - } - return ref; -} - -/*---------------------------------------------------------------------------*/ - -/* - * Returns the reference of the object, or 0 if it is not exported over D-Bus. - */ -guint -atk_dbus_object_to_ref (AtkObject *accessible) -{ - return GPOINTER_TO_INT(g_object_get_data (G_OBJECT (accessible), "dbus-id")); -} - -/* - * Converts the Accessible object reference to its D-Bus object path - */ -gchar * -atk_dbus_ref_to_path (guint ref) -{ - return g_strdup_printf(ATK_BRIDGE_OBJECT_REFERENCE_TEMPLATE, ref); -} - -/* - * Used to lookup an AtkObject from its D-Bus path. - */ -AtkObject * -atk_dbus_path_to_object (const char *path) -{ - guint index; - void *data; - - g_assert (path); - - if (strncmp(path, ATK_BRIDGE_OBJECT_PATH_PREFIX, ATK_BRIDGE_PATH_PREFIX_LENGTH) != 0) - return NULL; - - path += ATK_BRIDGE_PATH_PREFIX_LENGTH; /* Skip over the prefix */ - - if (path[0] == '\0') - return atk_get_root(); - if (path[0] != '/') - return NULL; - - path++; - index = atoi (path); - data = g_hash_table_lookup (ref2ptr, GINT_TO_POINTER(index)); - if (data) - return ATK_OBJECT (data); - else - return NULL; -} - - -/* - * Used to lookup a D-Bus path from the AtkObject. - */ -gchar * -atk_dbus_object_to_path (AtkObject *accessible) -{ - guint ref; - g_assert(ATK_IS_OBJECT(accessible)); - - ref = atk_dbus_object_to_ref (accessible); - if (!ref) - return NULL; - else - return atk_dbus_ref_to_path (ref); -} - -/*---------------------------------------------------------------------------*/ - -/* - * Marshals a single object into a D-Bus message. - * - * Unrefs the AtkObject if unref is true. - */ -DBusMessage * -spi_dbus_return_object (DBusMessage *message, AtkObject *obj, gboolean unref) -{ - DBusMessage *reply; - gchar *path; - - path = atk_dbus_object_to_path (obj); - - if (unref) - g_object_unref (obj); - - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_OBJECT_PATH, path, - DBUS_TYPE_INVALID); - } - return reply; -} - -/*---------------------------------------------------------------------------*/ - -/* - * Marshals a variant containing the object reference into the message iter - * provided. - * - * Unrefs the object if unref is true. - */ -dbus_bool_t -spi_dbus_return_v_object (DBusMessageIter *iter, AtkObject *obj, int unref) -{ - char *path; - - path = atk_dbus_object_to_path (obj); - - if (unref) - g_object_unref (obj); - - return droute_return_v_object (iter, path); -} - -/*---------------------------------------------------------------------------*/ - -/* - * Initializes required global data. The update and removal lists - * and the reference lookup tables. - * - * Initializes all of the required D-Bus interfaces. - */ -void -atk_dbus_initialize (AtkObject *root) -{ - if (!ref2ptr) - ref2ptr = g_hash_table_new(g_direct_hash, g_direct_equal); - - /* Get the root accessible and add */ - atk_dbus_register_accessible (root); -} - -/*END------------------------------------------------------------------------*/ - diff --git a/atk-adaptor/atk-dbus.h b/atk-adaptor/atk-dbus.h deleted file mode 100644 index 17dc50d..0000000 --- a/atk-adaptor/atk-dbus.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) - * - * Copyright 2008 Novell, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __ATK_DBUS__ -#define __ATK_DBUS__ - -#include -#include -#include -#include - -void -atk_dbus_foreach_registered(GHFunc func, gpointer data); - -void -atk_dbus_foreach_update_list(GHFunc func, gpointer data); - -void -atk_dbus_foreach_remove_list(GHFunc func, gpointer data); - -/*---------------------------------------------------------------------------*/ - -guint -atk_dbus_register_accessible (AtkObject *accessible); - -guint -atk_dbus_update_accessible (AtkObject *accessible); - -/*---------------------------------------------------------------------------*/ - -guint -atk_dbus_object_to_ref (AtkObject *accessible); - -gchar * -atk_dbus_ref_to_path (guint ref); - -AtkObject * -atk_dbus_path_to_object (const char *path); - -gchar * -atk_dbus_ref_to_path (guint ref); - -gchar * -atk_dbus_object_to_path (AtkObject *accessible); - -/*---------------------------------------------------------------------------*/ - -DBusMessage * -spi_dbus_return_object (DBusMessage *message, AtkObject *obj, gboolean unref); - -dbus_bool_t -spi_dbus_return_v_object (DBusMessageIter *iter, AtkObject *obj, int unref); - -#endif /* __ATK_DBUS__ */ diff --git a/atk-adaptor/bridge.c b/atk-adaptor/bridge.c index 80d8a5b..a63539e 100644 --- a/atk-adaptor/bridge.c +++ b/atk-adaptor/bridge.c @@ -2,7 +2,7 @@ * AT-SPI - Assistive Technology Service Provider Interface * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) * - * Copyright 2008 Codethink Ltd. + * Copyright 2008, 2009 Codethink Ltd. * Copyright 2001, 2002, 2003 Sun Microsystems Inc., * Copyright 2001, 2002, 2003 Ximian, Inc. * @@ -27,20 +27,17 @@ #include #include -#include -#include #include #include #include #include -#include -#include #include #include "bridge.h" #include "event.h" -#include "atk-dbus.h" +#include "accessible-register.h" +#include "adaptors.h" #include "spi-common/spi-dbus.h" diff --git a/atk-adaptor/bridge.h b/atk-adaptor/bridge.h index 6b8829b..3e41531 100644 --- a/atk-adaptor/bridge.h +++ b/atk-adaptor/bridge.h @@ -4,6 +4,7 @@ * * Copyright 2001, 2002, 2003 Sun Microsystems Inc., * Copyright 2001, 2002, 2003 Ximian, Inc. + * Copyright 2008, 2009 Codethink Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -21,39 +22,21 @@ * Boston, MA 02111-1307, USA. */ -#ifndef SPI_BRIDGE_H_ -#define SPI_BRIDGE_H_ +#ifndef BRIDGE_H +#define BRIDGE_H #include #include -G_BEGIN_DECLS - typedef struct _SpiAppData SpiAppData; struct _SpiAppData { AtkObject *root; + DBusConnection *bus; DRouteContext *droute; }; -void spi_initialize_accessible (DRoutePath *path); -void spi_initialize_action (DRoutePath *path); -void spi_initialize_application (DRoutePath *path); -void spi_initialize_collection (DRoutePath *path); -void spi_initialize_component (DRoutePath *path); -void spi_initialize_document (DRoutePath *path); -void spi_initialize_editabletext (DRoutePath *path); -void spi_initialize_hyperlink (DRoutePath *path); -void spi_initialize_hypertext (DRoutePath *path); -void spi_initialize_image (DRoutePath *path); -void spi_initialize_selection (DRoutePath *path); -void spi_initialize_table (DRoutePath *path); -void spi_initialize_text (DRoutePath *path); -void spi_initialize_value (DRoutePath *path); - -void spi_initialize_tree (DRoutePath *path); - -G_END_DECLS +extern SpiAppData *atk_adaptor_app_data; -#endif /* SPI_BRIDGE_H_ */ +#endif /* BRIDGE_H */ diff --git a/atk-adaptor/collection-adaptor.c b/atk-adaptor/collection-adaptor.c new file mode 100644 index 0000000..749198f --- /dev/null +++ b/atk-adaptor/collection-adaptor.c @@ -0,0 +1,1033 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2007 IBM Corp. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* collection.c: implements the Collection interface */ + +#include + +#include +#include + +#include "accessible-register.h" +#include "accessible-marshaller.h" + +#include "spi-common/bitarray.h" +#include "spi-common/spi-dbus.h" + +typedef struct _MatchRulePrivate MatchRulePrivate; +struct _MatchRulePrivate +{ + gint *states; + Accessibility_Collection_MatchType statematchtype; + AtkAttributeSet *attributes; + Accessibility_Collection_MatchType attributematchtype; + gint *roles; + Accessibility_Collection_MatchType rolematchtype; + gchar **ifaces; + Accessibility_Collection_MatchType interfacematchtype; + gboolean invert; +}; + +static gboolean +child_interface_p (AtkObject *child, + gchar *repo_id) +{ + if (!strcasecmp(repo_id, "action")) return atk_is_action(child); + if (!strcasecmp(repo_id, "component")) return atk_is_component(child); + if (!strcasecmp(repo_id, "editabletext")) return atk_is_editable_text(child); + if (!strcasecmp(repo_id, "text")) return atk_is_text(child); + if (!strcasecmp(repo_id, "hypertext")) return atk_is_hypertext(child); + if (!strcasecmp(repo_id, "image")) return atk_is_image(child); + if (!strcasecmp(repo_id, "selection")) return atk_is_selection(child); + if (!strcasecmp(repo_id, "table")) return atk_is_table(child); + if (!strcasecmp(repo_id, "value")) return atk_is_value(child); + if (!strcasecmp(repo_id, "streamablecontent")) return atk_is_streamable_content(child); + if (!strcasecmp(repo_id, "document")) return atk_is_document(child); + return FALSE; +} + +#define child_collection_p(ch) (TRUE) + +static gboolean +match_states_all_p (AtkObject *child, + gint *set) +{ + AtkStateSet *chs; + gint i; + gboolean ret = TRUE; + + if (set == NULL) + return TRUE; + + chs = atk_object_ref_state_set (child); + + // TODO: use atk-state_set_contains_states; would be more efficient + for (i = 0; set[i] != BITARRAY_SEQ_TERM; i++) + { + if (!atk_state_set_contains_state(chs, set[i])) + { + ret = FALSE; + break; + } + } + + g_object_unref(chs); + return ret; +} + +static gboolean +match_states_any_p (AtkObject *child, + gint *set) +{ + AtkStateSet *chs; + gint i; + gboolean ret = FALSE; + + if (set == NULL) + return TRUE; + + chs = atk_object_ref_state_set (child); + + for (i = 0; set[i] != BITARRAY_SEQ_TERM; i++) + { + if (!atk_state_set_contains_state(chs, set[i])) + { + ret = TRUE; + break; + } + } + + g_object_unref(chs); + return ret; +} + +static gboolean +match_states_none_p (AtkObject *child, + gint *set) +{ + AtkStateSet *chs; + gint i; + gboolean ret = TRUE; + + if (set == NULL) + return TRUE; + + chs = atk_object_ref_state_set (child); + + for (i = 0; set[i] != BITARRAY_SEQ_TERM; i++) + { + if (atk_state_set_contains_state(chs, set[i])) + { + ret = FALSE; + break; + } + } + + g_object_unref(chs); + return ret; +} + +// TODO: need to convert at-spi roles/states to atk roles/states */ +static gboolean +match_states_lookup (AtkObject *child, + MatchRulePrivate *mrp) +{ + switch (mrp->statematchtype){ + case Accessibility_Collection_MATCH_ALL : + if (match_states_all_p (child, mrp->states)) + return TRUE; + break; + + case Accessibility_Collection_MATCH_ANY : + if (match_states_any_p (child, mrp->states)) + return TRUE; + break; + + case Accessibility_Collection_MATCH_NONE : + if (match_states_none_p (child, mrp->states)) + return TRUE; + break; + + default : break; + } + + return FALSE; +} + +// TODO: Map at-spi -> atk roles at mrp creation instead of doing this; +// would be more efficient +#define spi_get_role(obj) spi_accessible_role_from_atk_role(atk_object_get_role(obj)) + +static gboolean +match_roles_all_p (AtkObject *child, + gint *roles) +{ + Accessibility_Role role; + + if (roles == NULL || roles[0] == BITARRAY_SEQ_TERM) return TRUE; + else if (roles[1] != BITARRAY_SEQ_TERM) return FALSE; + + return (atk_object_get_role(child) == roles[0]); + +} + +static gboolean +match_roles_any_p (AtkObject *child, + gint *roles) +{ + AtkRole role; + int i; + + if (roles == NULL || roles[0] == BITARRAY_SEQ_TERM) return TRUE; + + role = atk_object_get_role(child); + + for (i = 0; roles[i] != BITARRAY_SEQ_TERM; i++) + if (role == roles[i]) + return TRUE; + + return FALSE; +} + +static gboolean +match_roles_none_p (AtkObject *child, + gint *roles) +{ + AtkRole role; + int i; + + if (roles == NULL || roles[0] == BITARRAY_SEQ_TERM) return TRUE; + + role = atk_object_get_role(child); + + for (i = 0; roles[i] != BITARRAY_SEQ_TERM; i++) + if (role == roles[i]) + return FALSE; + + return TRUE; +} + +static gboolean +match_roles_lookup (AtkObject *child, + MatchRulePrivate *mrp) +{ + switch (mrp->rolematchtype){ + case Accessibility_Collection_MATCH_ALL : + if (match_roles_all_p (child, mrp->roles)) + return TRUE; + break; + + case Accessibility_Collection_MATCH_ANY : + if (match_roles_any_p (child, mrp->roles)) + return TRUE; + break; + + case Accessibility_Collection_MATCH_NONE : + if (match_roles_none_p (child, mrp->roles)) + return TRUE; + break; + + default : break; + + } + return FALSE; +} + +static gboolean +match_interfaces_all_p (AtkObject *obj, + gchar **ifaces) +{ + gint i; + + if (ifaces == NULL) + return TRUE; + + for (i = 0; ifaces[i]; i++) + if (!child_interface_p (obj, ifaces [i])){ + return FALSE; + } + return TRUE; +} + +static gboolean +match_interfaces_any_p (AtkObject *obj, + gchar **ifaces) +{ + gint i; + + if (ifaces == NULL) + return TRUE; + + + for (i = 0; ifaces[i]; i++) + if (child_interface_p (obj, ifaces [i])){ + return TRUE; + } + return FALSE; +} + +static gboolean +match_interfaces_none_p (AtkObject *obj, + gchar **ifaces) +{ + gint i; + + for (i = 0; ifaces[i]; i++) + if (child_interface_p (obj, ifaces [i])) + return FALSE; + + return TRUE; +} + +static gboolean +match_interfaces_lookup (AtkObject *child, + MatchRulePrivate *mrp) +{ + switch (mrp->interfacematchtype){ + + case Accessibility_Collection_MATCH_ALL : + if (match_interfaces_all_p (child, mrp->ifaces)) + return TRUE; + break; + + case Accessibility_Collection_MATCH_ANY : + if (match_interfaces_any_p (child, mrp->ifaces)) + return TRUE; + break; + + case Accessibility_Collection_MATCH_NONE : + if (match_interfaces_none_p (child, mrp->ifaces)) + return TRUE; + break; + + default : break; + } + + return FALSE; +} + +#define split_attributes(attributes) (g_strsplit (attributes, ";", 0)) + +static gboolean +match_attributes_all_p (AtkObject *child, + AtkAttributeSet *attributes) +{ + int i, k; + AtkAttributeSet *oa; + gint length, oa_length; + gboolean flag = FALSE; + + if (attributes == NULL || g_slist_length (attributes) == 0) + return TRUE; + + oa = atk_object_get_attributes(child); + length = g_slist_length(attributes); + oa_length = g_slist_length(oa); + + for (i = 0; i < length; i++) { + AtkAttribute *attr = g_slist_nth_data(attributes, i); + for (k = 0; k < oa_length; k++) { + AtkAttribute *oa_attr = g_slist_nth_data(attributes, i); + if (!g_ascii_strcasecmp (oa_attr->name, attr->name) && + !g_ascii_strcasecmp (oa_attr->value, attr->value)){ + flag = TRUE; + break; + } + else + flag = FALSE; + } + if (!flag) { + atk_attribute_set_free(oa); + return FALSE; + } + } + atk_attribute_set_free(oa); + return TRUE; +} + +static gboolean +match_attributes_any_p (AtkObject *child, + AtkAttributeSet *attributes) +{ + int i, k; + + AtkAttributeSet *oa; + gint length, oa_length; + + length = g_slist_length(attributes); + if (length == 0) + return TRUE; + + oa = atk_object_get_attributes(child); + oa_length = g_slist_length(oa); + + for (i = 0; i < length; i++){ + AtkAttribute *attr = g_slist_nth_data(attributes, i); + for (k = 0; k < oa_length; k++){ + AtkAttribute *oa_attr = g_slist_nth_data(attributes, i); + if (!g_ascii_strcasecmp (oa_attr->name, attr->name) && + !g_ascii_strcasecmp (oa_attr->value, attr->value)){ + atk_attribute_set_free(oa); + return TRUE; + } + } + } + atk_attribute_set_free(oa); + return FALSE; +} + +static gboolean +match_attributes_none_p (AtkObject *child, + AtkAttributeSet *attributes) +{ + int i, k; + + AtkAttributeSet *oa; + gint length, oa_length; + + length = g_slist_length(attributes); + if (length == 0) + return TRUE; + + oa = atk_object_get_attributes(child); + oa_length = g_slist_length(oa); + + for (i = 0; i < length; i++){ + AtkAttribute *attr = g_slist_nth_data(attributes, i); + for (k = 0; k < oa_length; k++){ + AtkAttribute *oa_attr = g_slist_nth_data(attributes, i); + if (!g_ascii_strcasecmp (oa_attr->name, attr->name) && + !g_ascii_strcasecmp (oa_attr->value, attr->value)){ + atk_attribute_set_free(oa); + return FALSE; + } + } + } + atk_attribute_set_free(oa); + return TRUE; +} + +static gboolean +match_attributes_lookup (AtkObject *child, MatchRulePrivate *mrp) +{ + switch (mrp->attributematchtype){ + + case Accessibility_Collection_MATCH_ALL : + if (match_attributes_all_p (child, mrp->attributes)) + return TRUE; + break; + + case Accessibility_Collection_MATCH_ANY : + if (match_attributes_any_p (child, mrp->attributes)) + return TRUE; + break; + + case Accessibility_Collection_MATCH_NONE : + if (match_attributes_none_p (child, mrp->attributes)) + return TRUE; + break; + + default : break; + } + return FALSE; +} + +static gboolean +traverse_p (AtkObject *child, + const gboolean traverse) +{ + if (traverse) + return TRUE; + else return !child_collection_p (child); +} + +static int +sort_order_canonical (MatchRulePrivate *mrp, GList *ls, + gint kount, gint max, + AtkObject *obj, glong index, gboolean flag, + AtkObject *pobj, gboolean recurse, + gboolean traverse) +{ + gint i = index; + glong acount = atk_object_get_n_accessible_children (obj); + gboolean prev = pobj? TRUE : FALSE; + + for (; i < acount && (max == 0 || kount < max); i++){ + AtkObject *child = + atk_object_ref_accessible_child(obj, i); + + g_object_unref(child); + if (prev && child == pobj){ + return kount; + } + + if (flag && match_interfaces_lookup (child, mrp) + && match_states_lookup (child, mrp) + && match_roles_lookup (child, mrp) + && match_attributes_lookup (child, mrp) + ){ + + ls = g_list_append (ls, child); + kount++; + } + + if (!flag) + flag = TRUE; + + if (recurse && traverse_p (child, traverse)) + kount = sort_order_canonical (mrp, ls, kount, + max, child, 0, TRUE, + pobj, recurse, traverse); + } + return kount; +} + +static int +sort_order_rev_canonical (MatchRulePrivate *mrp, GList *ls, + gint kount, gint max, + AtkObject *obj, gboolean flag, + AtkObject *pobj) +{ + AtkObject *nextobj; + AtkObject *parent; + glong indexinparent; + + /* This breaks us out of the recursion. */ + if (!obj || obj == pobj) + { + return kount; + } + + /* Add to the list if it matches */ + if (flag && match_interfaces_lookup (obj, mrp) + && match_states_lookup (obj, mrp) + && match_roles_lookup (obj, mrp) + && match_attributes_lookup (obj, mrp)) + { + ls = g_list_append (ls, obj); + kount++; + } + + if(!flag) flag = TRUE; + + /* Get the current nodes index in it's parent and the parent object. */ + indexinparent = atk_object_get_index_in_parent (obj); + parent = atk_object_get_parent(obj); + + if(indexinparent > 0) + { + /* there are still some siblings to visit so get the previous sibling + and get it's last descendant. + First, get the previous sibling */ + nextobj = atk_object_ref_accessible_child (parent, + indexinparent-1); + g_object_unref(nextobj); + + /* Now, drill down the right side to the last descendant */ + while(atk_object_get_n_accessible_children (nextobj) > 0) + { + nextobj = atk_object_ref_accessible_child(nextobj, + atk_object_get_n_accessible_children (nextobj)-1); + g_object_unref (nextobj); + } + /* recurse with the last descendant */ + kount = sort_order_rev_canonical (mrp, ls, kount, max, + nextobj, TRUE, pobj); + } + else + { + /* no more siblings so next node must be the parent */ + kount = sort_order_rev_canonical (mrp, ls, kount, max, + parent, TRUE, pobj); + + } + return kount; +} + +static int +query_exec (MatchRulePrivate *mrp, Accessibility_Collection_SortOrder sortby, + GList *ls, gint kount, gint max, + AtkObject *obj, glong index, + gboolean flag, + AtkObject *pobj, + gboolean recurse, gboolean traverse) +{ + switch (sortby) { + case Accessibility_Collection_SORT_ORDER_CANONICAL : + kount = sort_order_canonical(mrp, ls, 0, max, obj, index, flag, + pobj, recurse, traverse); + break; + case Accessibility_Collection_SORT_ORDER_REVERSE_CANONICAL : + kount = sort_order_canonical(mrp, ls, 0, max, obj, index, flag, + pobj, recurse, traverse); + break; + default: + kount = 0; + g_warning ("Sort method not implemented yet"); + break; + } + + return kount; +} + +static dbus_bool_t +read_mr(DBusMessageIter *iter, MatchRulePrivate *mrp) +{ + DBusMessageIter mrc, arrayc; + dbus_uint32_t *array; + dbus_int32_t matchType; + int array_count; + char *str; + AtkAttribute *attr; + int i; + char *interfaces = NULL; + + // TODO: error checking + dbus_message_iter_recurse(iter, &mrc); + dbus_message_iter_recurse(&mrc, &arrayc); + dbus_message_iter_get_fixed_array(&arrayc, &array, &array_count); + bitarray_to_seq(array, array_count, &mrp->states); + for (i = 0; mrp->states[i] != BITARRAY_SEQ_TERM; i++) + { + mrp->states[i] = spi_atk_state_from_spi_state (mrp->states[i]); + } + dbus_message_iter_next(&mrc); + dbus_message_iter_read_basic(&mrc, &matchType); + dbus_message_iter_next(&mrc); + mrp->statematchtype = matchType;; + /* attributes */ + dbus_message_iter_recurse(&mrc, &arrayc); + mrp->attributes = NULL; + while (dbus_message_iter_get_arg_type(&arrayc) != DBUS_TYPE_INVALID) + { + dbus_message_iter_get_basic(&arrayc, &str); + // TODO: remove this print + g_print("Got attribute: %s\n", str); + attr = g_new (AtkAttribute, 1); + if (attr) + { + int len = strcspn(str, ":"); + attr->name = g_strndup(str, len); + if (str[len] == ':') + { + len++; + if (str[len] == ' ') len++; + attr->value = g_strdup(str + len); + } + else attr->value = NULL; + mrp->attributes = g_slist_prepend(mrp->attributes, attr); + } + dbus_message_iter_next(&arrayc); + } + dbus_message_iter_next(&mrc); + dbus_message_iter_read_basic(&mrc, &matchType); + mrp->attributematchtype = matchType;; + dbus_message_iter_next(&mrc); + /* Get roles and role match */ + dbus_message_iter_recurse(&mrc, &arrayc); + dbus_message_iter_get_fixed_array(&arrayc, &array, &array_count); + bitarray_to_seq(array, array_count, &mrp->roles); + dbus_message_iter_next(&mrc); + dbus_message_iter_read_basic(&mrc, &matchType); + mrp->rolematchtype = matchType;; + dbus_message_iter_next(&mrc); + /* Get interfaces and interface match */ + dbus_message_iter_read_basic(&mrc, &interfaces); + dbus_message_iter_next(&mrc); + mrp->ifaces = g_strsplit(interfaces, ";", 0); + dbus_message_iter_read_basic(&mrc, &matchType); + mrp->interfacematchtype = matchType;; + dbus_message_iter_next(&mrc); + /* get invert */ + dbus_message_iter_read_basic(&mrc, &mrp->invert); + dbus_message_iter_next(iter); + return TRUE; +} + +static DBusMessage * +return_and_free_list(DBusMessage *message, GList *ls) +{ + DBusMessage *reply; + DBusMessageIter iter, iter_array; + GList *item; + + reply = dbus_message_new_method_return(message); + if (!reply) return NULL; + dbus_message_iter_init_append(reply, &iter); + if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "o", &iter_array)) goto oom; + for (item = ls; item; item = g_list_next(item)) + { + char *path = (char *) spi_dbus_object_to_path ((AtkObject *)item->data); + dbus_message_iter_append_basic(&iter_array, DBUS_TYPE_OBJECT_PATH, &path); + g_free(path); + } + if (!dbus_message_iter_close_container(&iter, &iter_array)) goto oom; + g_list_free (ls); + return reply; +oom: + // TODO: Handle out of memory + g_list_free (ls); + return reply; +} + +static void free_mrp_data(MatchRulePrivate *mrp) +{ + g_free(mrp->states); + atk_attribute_set_free(mrp->attributes); + g_free(mrp->roles); + g_strfreev(mrp->ifaces); +} + +static DBusMessage * +getMatchesFrom (DBusMessage *message, + AtkObject *current_object, + MatchRulePrivate *mrp, + const Accessibility_Collection_SortOrder sortby, + const dbus_bool_t isrestrict, + dbus_int32_t count, + const dbus_bool_t traverse) +{ + GList *ls = NULL; + AtkObject *parent; + glong index = + atk_object_get_index_in_parent (current_object); + gint kount = 0; + + ls = g_list_append (ls, current_object); + + if (!isrestrict) + { + parent = atk_object_get_parent (current_object); + kount = query_exec (mrp, sortby, ls, 0, count, parent, index, + FALSE, NULL, TRUE, traverse); + } + else + kount = query_exec (mrp, sortby, ls, 0, count, + current_object, 0, FALSE, NULL, + TRUE, traverse); + + ls = g_list_remove (ls, ls->data); + + if (sortby == Accessibility_Collection_SORT_ORDER_REVERSE_CANONICAL) + ls = g_list_reverse (ls); + + free_mrp_data (mrp); + return return_and_free_list (message, ls); +} + +/* + inorder traversal from a given object in the hierarchy +*/ + +static int +inorder (AtkObject *collection, MatchRulePrivate *mrp, + GList *ls, gint kount, gint max, + AtkObject *obj, + gboolean flag, + AtkObject *pobj, + dbus_bool_t traverse) +{ + int i = 0; + + /* First, look through the children recursively. */ + kount = sort_order_canonical (mrp, ls, kount, max, obj, 0, TRUE, + NULL, TRUE, TRUE); + + /* Next, we look through the right subtree */ + while ((max == 0 || kount < max) + && obj != collection) + { + AtkObject *parent = + atk_object_get_parent (obj); + i = atk_object_get_index_in_parent (obj); + kount = sort_order_canonical (mrp, ls, kount, max, parent, + i+1, TRUE, FALSE, TRUE, TRUE); + obj = parent; + } + + if (kount < max) + { + kount = sort_order_canonical (mrp, ls, kount, max, + obj, i + 1, TRUE, FALSE, + TRUE, TRUE); + } + + return kount; +} + +/* + GetMatchesInOrder: get matches from a given object in an inorder traversal. +*/ + +static DBusMessage * +getMatchesInOrder (DBusMessage *message, + AtkObject *current_object, + MatchRulePrivate *mrp, + const Accessibility_Collection_SortOrder sortby, + const dbus_bool_t recurse, + dbus_int32_t count, + const dbus_bool_t traverse) +{ + GList *ls = NULL; + AtkObject *obj; + gint kount = 0; + + ls = g_list_append (ls, current_object); + + obj = atk_dbus_path_to_object (dbus_message_get_path (message)); + + kount = inorder (obj, mrp, ls, 0, count, + current_object, TRUE, NULL, traverse); + + ls = g_list_remove (ls, ls->data); + + if (sortby == Accessibility_Collection_SORT_ORDER_REVERSE_CANONICAL) + ls = g_list_reverse (ls); + + free_mrp_data (mrp); + return return_and_free_list (message, ls); +} + +/* + GetMatchesInBackOrder: get matches from a given object in a + reverse order traversal. +*/ + +static DBusMessage * +getMatchesInBackOrder (DBusMessage *message, + AtkObject *current_object, + MatchRulePrivate *mrp, + const Accessibility_Collection_SortOrder sortby, + dbus_int32_t count) +{ + GList *ls = NULL; + AtkObject *collection; + gint kount = 0; + + ls = g_list_append (ls, current_object); + + collection = atk_dbus_path_to_object (dbus_message_get_path (message)); + + kount = sort_order_rev_canonical (mrp, ls, 0, count, current_object, + FALSE, collection); + + ls = g_list_remove (ls, ls->data); + + if (sortby == Accessibility_Collection_SORT_ORDER_REVERSE_CANONICAL) + ls = g_list_reverse (ls); + + free_mrp_data (mrp); + return return_and_free_list (message, ls); +} + +static DBusMessage * +getMatchesTo (DBusMessage *message, + AtkObject *current_object, + MatchRulePrivate *mrp, + const Accessibility_Collection_SortOrder sortby, + const dbus_bool_t recurse, + const dbus_bool_t isrestrict, + dbus_int32_t count, + const dbus_bool_t traverse) +{ + GList *ls = NULL; + AtkObject *obj; + gint kount = 0; + + ls = g_list_append (ls, current_object); + + if (recurse){ + obj = atk_object_get_parent (current_object); + kount = query_exec (mrp, sortby, ls, 0, count, + obj, 0, TRUE, current_object, TRUE, traverse); + } + else{ + obj = atk_dbus_path_to_object (dbus_message_get_path (message)); + kount = query_exec (mrp, sortby, ls, 0, count, + obj, 0, TRUE, current_object, TRUE, traverse); + + } + + ls = g_list_remove (ls, ls->data); + + if (sortby != Accessibility_Collection_SORT_ORDER_REVERSE_CANONICAL) + ls = g_list_reverse (ls); + + free_mrp_data (mrp); + return return_and_free_list (message, ls); +} + +static DBusMessage * +impl_getMatchesFrom (DBusConnection *bus, DBusMessage *message, void *user_data) +{ + char *current_object_path = NULL; + AtkObject *current_object; + DBusMessageIter iter; + MatchRulePrivate rule; + dbus_uint16_t sortby; + dbus_uint16_t tree; + dbus_int32_t count; + dbus_bool_t traverse; + GList *ls = NULL; + + dbus_message_iter_init(message, &iter); + dbus_message_iter_get_basic (&iter, current_object_path); + current_object = atk_dbus_path_to_object (current_object_path); + if (!current_object) + { + // TODO: object-not-found error + return spi_dbus_general_error (message); + } + dbus_message_iter_next (&iter); + if (!read_mr(&iter, &rule)) + { + return spi_dbus_general_error (message); + } + dbus_message_iter_get_basic(&iter, &sortby); + dbus_message_iter_next(&iter); + dbus_message_iter_get_basic(&iter, &tree); + dbus_message_iter_next(&iter); + dbus_message_iter_get_basic(&iter, &count); + dbus_message_iter_next(&iter); + dbus_message_iter_get_basic(&iter, &traverse); + dbus_message_iter_next(&iter); + + switch (tree){ + case Accessibility_Collection_TREE_RESTRICT_CHILDREN : + return getMatchesFrom (message, current_object, + &rule, sortby, TRUE, count, traverse); + break; + case Accessibility_Collection_TREE_RESTRICT_SIBLING : + return getMatchesFrom (message, current_object, + &rule, sortby, FALSE, count, traverse); + break; + case Accessibility_Collection_TREE_INORDER : + return getMatchesInOrder (message, current_object, + &rule, sortby, TRUE, count, traverse); + break; + default : return NULL; + } +} + +static DBusMessage * +impl_getMatchesTo (DBusConnection *bus, DBusMessage *message, void *user_data) +{ + char *current_object_path = NULL; + AtkObject *current_object; + DBusMessageIter iter; + MatchRulePrivate rule; + dbus_uint16_t sortby; + dbus_uint16_t tree; + dbus_bool_t recurse; + dbus_int32_t count; + dbus_bool_t traverse; + GList *ls = NULL; + + dbus_message_iter_init(message, &iter); + dbus_message_iter_get_basic (&iter, current_object_path); + current_object = atk_dbus_path_to_object (current_object_path); + if (!current_object) + { + // TODO: object-not-found error + return spi_dbus_general_error (message); + } + dbus_message_iter_next (&iter); + if (!read_mr(&iter, &rule)) + { + return spi_dbus_general_error (message); + } + dbus_message_iter_get_basic(&iter, &sortby); + dbus_message_iter_next(&iter); + dbus_message_iter_get_basic(&iter, &tree); + dbus_message_iter_next(&iter); + dbus_message_iter_get_basic(&iter, &recurse); + dbus_message_iter_next(&iter); + dbus_message_iter_get_basic(&iter, &count); + dbus_message_iter_next(&iter); + dbus_message_iter_get_basic(&iter, &traverse); + dbus_message_iter_next(&iter); + + switch (tree){ + case Accessibility_Collection_TREE_RESTRICT_CHILDREN : + return getMatchesTo (message, current_object, + &rule, sortby, recurse, TRUE, count, traverse); + break; + case Accessibility_Collection_TREE_RESTRICT_SIBLING : + return getMatchesTo (message, current_object, + &rule, sortby, recurse, FALSE, count, traverse); + break; + case Accessibility_Collection_TREE_INORDER : + return getMatchesInBackOrder (message, current_object, + &rule, sortby, count); + break; + default : return NULL; + } +} + +static DBusMessage * +impl_getMatches(DBusConnection *bus, DBusMessage *message, void *user_data) +{ + AtkObject *obj = path_to_object (message); + DBusMessageIter iter; + MatchRulePrivate rule; + dbus_uint16_t sortby; + dbus_int32_t count; + dbus_bool_t traverse; + GList *ls = NULL; + + dbus_message_iter_init(message, &iter); + if (!read_mr(&iter, &rule)) + { + return spi_dbus_general_error (message); + } + dbus_message_iter_get_basic(&iter, &sortby); + dbus_message_iter_next(&iter); + dbus_message_iter_get_basic(&iter, &count); + dbus_message_iter_next(&iter); + dbus_message_iter_get_basic(&iter, &traverse); + dbus_message_iter_next(&iter); + ls = g_list_prepend (ls, obj); + count = query_exec (&rule, sortby, ls, 0, count, + obj, 0, TRUE, NULL, TRUE, traverse); + ls = g_list_remove (ls, ls->data); + + if (sortby == Accessibility_Collection_SORT_ORDER_REVERSE_CANONICAL) + ls = g_list_reverse (ls); + free_mrp_data (&rule); + return return_and_free_list (message, ls); +} + +static DRouteMethod methods[] = { + { impl_getMatchesFrom, "getMatchesFrom" }, + { impl_getMatchesTo, "getMatchesTo" }, + { impl_getMatches, "getMatches" }, + {NULL, NULL} +}; + +void +spi_initialize_collection (DRoutePath *path) +{ + droute_path_add_interface (path, + SPI_DBUS_INTERFACE_COLLECTION, + methods, + NULL); +}; diff --git a/atk-adaptor/collection.c b/atk-adaptor/collection.c deleted file mode 100644 index c5fe2c0..0000000 --- a/atk-adaptor/collection.c +++ /dev/null @@ -1,1032 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) - * - * Copyright 2007 IBM Corp. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* collection.c: implements the Collection interface */ - -#include - -#include -#include - -#include "atk-dbus.h" - -#include "spi-common/bitarray.h" -#include "spi-common/spi-dbus.h" - -typedef struct _MatchRulePrivate MatchRulePrivate; -struct _MatchRulePrivate -{ - gint *states; - Accessibility_Collection_MatchType statematchtype; - AtkAttributeSet *attributes; - Accessibility_Collection_MatchType attributematchtype; - gint *roles; - Accessibility_Collection_MatchType rolematchtype; - gchar **ifaces; - Accessibility_Collection_MatchType interfacematchtype; - gboolean invert; -}; - -static gboolean -child_interface_p (AtkObject *child, - gchar *repo_id) -{ - if (!strcasecmp(repo_id, "action")) return atk_is_action(child); - if (!strcasecmp(repo_id, "component")) return atk_is_component(child); - if (!strcasecmp(repo_id, "editabletext")) return atk_is_editable_text(child); - if (!strcasecmp(repo_id, "text")) return atk_is_text(child); - if (!strcasecmp(repo_id, "hypertext")) return atk_is_hypertext(child); - if (!strcasecmp(repo_id, "image")) return atk_is_image(child); - if (!strcasecmp(repo_id, "selection")) return atk_is_selection(child); - if (!strcasecmp(repo_id, "table")) return atk_is_table(child); - if (!strcasecmp(repo_id, "value")) return atk_is_value(child); - if (!strcasecmp(repo_id, "streamablecontent")) return atk_is_streamable_content(child); - if (!strcasecmp(repo_id, "document")) return atk_is_document(child); - return FALSE; -} - -#define child_collection_p(ch) (TRUE) - -static gboolean -match_states_all_p (AtkObject *child, - gint *set) -{ - AtkStateSet *chs; - gint i; - gboolean ret = TRUE; - - if (set == NULL) - return TRUE; - - chs = atk_object_ref_state_set (child); - - // TODO: use atk-state_set_contains_states; would be more efficient - for (i = 0; set[i] != BITARRAY_SEQ_TERM; i++) - { - if (!atk_state_set_contains_state(chs, set[i])) - { - ret = FALSE; - break; - } - } - - g_object_unref(chs); - return ret; -} - -static gboolean -match_states_any_p (AtkObject *child, - gint *set) -{ - AtkStateSet *chs; - gint i; - gboolean ret = FALSE; - - if (set == NULL) - return TRUE; - - chs = atk_object_ref_state_set (child); - - for (i = 0; set[i] != BITARRAY_SEQ_TERM; i++) - { - if (!atk_state_set_contains_state(chs, set[i])) - { - ret = TRUE; - break; - } - } - - g_object_unref(chs); - return ret; -} - -static gboolean -match_states_none_p (AtkObject *child, - gint *set) -{ - AtkStateSet *chs; - gint i; - gboolean ret = TRUE; - - if (set == NULL) - return TRUE; - - chs = atk_object_ref_state_set (child); - - for (i = 0; set[i] != BITARRAY_SEQ_TERM; i++) - { - if (atk_state_set_contains_state(chs, set[i])) - { - ret = FALSE; - break; - } - } - - g_object_unref(chs); - return ret; -} - -// TODO: need to convert at-spi roles/states to atk roles/states */ -static gboolean -match_states_lookup (AtkObject *child, - MatchRulePrivate *mrp) -{ - switch (mrp->statematchtype){ - case Accessibility_Collection_MATCH_ALL : - if (match_states_all_p (child, mrp->states)) - return TRUE; - break; - - case Accessibility_Collection_MATCH_ANY : - if (match_states_any_p (child, mrp->states)) - return TRUE; - break; - - case Accessibility_Collection_MATCH_NONE : - if (match_states_none_p (child, mrp->states)) - return TRUE; - break; - - default : break; - } - - return FALSE; -} - -// TODO: Map at-spi -> atk roles at mrp creation instead of doing this; -// would be more efficient -#define spi_get_role(obj) spi_accessible_role_from_atk_role(atk_object_get_role(obj)) - -static gboolean -match_roles_all_p (AtkObject *child, - gint *roles) -{ - Accessibility_Role role; - - if (roles == NULL || roles[0] == BITARRAY_SEQ_TERM) return TRUE; - else if (roles[1] != BITARRAY_SEQ_TERM) return FALSE; - - return (atk_object_get_role(child) == roles[0]); - -} - -static gboolean -match_roles_any_p (AtkObject *child, - gint *roles) -{ - AtkRole role; - int i; - - if (roles == NULL || roles[0] == BITARRAY_SEQ_TERM) return TRUE; - - role = atk_object_get_role(child); - - for (i = 0; roles[i] != BITARRAY_SEQ_TERM; i++) - if (role == roles[i]) - return TRUE; - - return FALSE; -} - -static gboolean -match_roles_none_p (AtkObject *child, - gint *roles) -{ - AtkRole role; - int i; - - if (roles == NULL || roles[0] == BITARRAY_SEQ_TERM) return TRUE; - - role = atk_object_get_role(child); - - for (i = 0; roles[i] != BITARRAY_SEQ_TERM; i++) - if (role == roles[i]) - return FALSE; - - return TRUE; -} - -static gboolean -match_roles_lookup (AtkObject *child, - MatchRulePrivate *mrp) -{ - switch (mrp->rolematchtype){ - case Accessibility_Collection_MATCH_ALL : - if (match_roles_all_p (child, mrp->roles)) - return TRUE; - break; - - case Accessibility_Collection_MATCH_ANY : - if (match_roles_any_p (child, mrp->roles)) - return TRUE; - break; - - case Accessibility_Collection_MATCH_NONE : - if (match_roles_none_p (child, mrp->roles)) - return TRUE; - break; - - default : break; - - } - return FALSE; -} - -static gboolean -match_interfaces_all_p (AtkObject *obj, - gchar **ifaces) -{ - gint i; - - if (ifaces == NULL) - return TRUE; - - for (i = 0; ifaces[i]; i++) - if (!child_interface_p (obj, ifaces [i])){ - return FALSE; - } - return TRUE; -} - -static gboolean -match_interfaces_any_p (AtkObject *obj, - gchar **ifaces) -{ - gint i; - - if (ifaces == NULL) - return TRUE; - - - for (i = 0; ifaces[i]; i++) - if (child_interface_p (obj, ifaces [i])){ - return TRUE; - } - return FALSE; -} - -static gboolean -match_interfaces_none_p (AtkObject *obj, - gchar **ifaces) -{ - gint i; - - for (i = 0; ifaces[i]; i++) - if (child_interface_p (obj, ifaces [i])) - return FALSE; - - return TRUE; -} - -static gboolean -match_interfaces_lookup (AtkObject *child, - MatchRulePrivate *mrp) -{ - switch (mrp->interfacematchtype){ - - case Accessibility_Collection_MATCH_ALL : - if (match_interfaces_all_p (child, mrp->ifaces)) - return TRUE; - break; - - case Accessibility_Collection_MATCH_ANY : - if (match_interfaces_any_p (child, mrp->ifaces)) - return TRUE; - break; - - case Accessibility_Collection_MATCH_NONE : - if (match_interfaces_none_p (child, mrp->ifaces)) - return TRUE; - break; - - default : break; - } - - return FALSE; -} - -#define split_attributes(attributes) (g_strsplit (attributes, ";", 0)) - -static gboolean -match_attributes_all_p (AtkObject *child, - AtkAttributeSet *attributes) -{ - int i, k; - AtkAttributeSet *oa; - gint length, oa_length; - gboolean flag = FALSE; - - if (attributes == NULL || g_slist_length (attributes) == 0) - return TRUE; - - oa = atk_object_get_attributes(child); - length = g_slist_length(attributes); - oa_length = g_slist_length(oa); - - for (i = 0; i < length; i++) { - AtkAttribute *attr = g_slist_nth_data(attributes, i); - for (k = 0; k < oa_length; k++) { - AtkAttribute *oa_attr = g_slist_nth_data(attributes, i); - if (!g_ascii_strcasecmp (oa_attr->name, attr->name) && - !g_ascii_strcasecmp (oa_attr->value, attr->value)){ - flag = TRUE; - break; - } - else - flag = FALSE; - } - if (!flag) { - atk_attribute_set_free(oa); - return FALSE; - } - } - atk_attribute_set_free(oa); - return TRUE; -} - -static gboolean -match_attributes_any_p (AtkObject *child, - AtkAttributeSet *attributes) -{ - int i, k; - - AtkAttributeSet *oa; - gint length, oa_length; - - length = g_slist_length(attributes); - if (length == 0) - return TRUE; - - oa = atk_object_get_attributes(child); - oa_length = g_slist_length(oa); - - for (i = 0; i < length; i++){ - AtkAttribute *attr = g_slist_nth_data(attributes, i); - for (k = 0; k < oa_length; k++){ - AtkAttribute *oa_attr = g_slist_nth_data(attributes, i); - if (!g_ascii_strcasecmp (oa_attr->name, attr->name) && - !g_ascii_strcasecmp (oa_attr->value, attr->value)){ - atk_attribute_set_free(oa); - return TRUE; - } - } - } - atk_attribute_set_free(oa); - return FALSE; -} - -static gboolean -match_attributes_none_p (AtkObject *child, - AtkAttributeSet *attributes) -{ - int i, k; - - AtkAttributeSet *oa; - gint length, oa_length; - - length = g_slist_length(attributes); - if (length == 0) - return TRUE; - - oa = atk_object_get_attributes(child); - oa_length = g_slist_length(oa); - - for (i = 0; i < length; i++){ - AtkAttribute *attr = g_slist_nth_data(attributes, i); - for (k = 0; k < oa_length; k++){ - AtkAttribute *oa_attr = g_slist_nth_data(attributes, i); - if (!g_ascii_strcasecmp (oa_attr->name, attr->name) && - !g_ascii_strcasecmp (oa_attr->value, attr->value)){ - atk_attribute_set_free(oa); - return FALSE; - } - } - } - atk_attribute_set_free(oa); - return TRUE; -} - -static gboolean -match_attributes_lookup (AtkObject *child, MatchRulePrivate *mrp) -{ - switch (mrp->attributematchtype){ - - case Accessibility_Collection_MATCH_ALL : - if (match_attributes_all_p (child, mrp->attributes)) - return TRUE; - break; - - case Accessibility_Collection_MATCH_ANY : - if (match_attributes_any_p (child, mrp->attributes)) - return TRUE; - break; - - case Accessibility_Collection_MATCH_NONE : - if (match_attributes_none_p (child, mrp->attributes)) - return TRUE; - break; - - default : break; - } - return FALSE; -} - -static gboolean -traverse_p (AtkObject *child, - const gboolean traverse) -{ - if (traverse) - return TRUE; - else return !child_collection_p (child); -} - -static int -sort_order_canonical (MatchRulePrivate *mrp, GList *ls, - gint kount, gint max, - AtkObject *obj, glong index, gboolean flag, - AtkObject *pobj, gboolean recurse, - gboolean traverse) -{ - gint i = index; - glong acount = atk_object_get_n_accessible_children (obj); - gboolean prev = pobj? TRUE : FALSE; - - for (; i < acount && (max == 0 || kount < max); i++){ - AtkObject *child = - atk_object_ref_accessible_child(obj, i); - - g_object_unref(child); - if (prev && child == pobj){ - return kount; - } - - if (flag && match_interfaces_lookup (child, mrp) - && match_states_lookup (child, mrp) - && match_roles_lookup (child, mrp) - && match_attributes_lookup (child, mrp) - ){ - - ls = g_list_append (ls, child); - kount++; - } - - if (!flag) - flag = TRUE; - - if (recurse && traverse_p (child, traverse)) - kount = sort_order_canonical (mrp, ls, kount, - max, child, 0, TRUE, - pobj, recurse, traverse); - } - return kount; -} - -static int -sort_order_rev_canonical (MatchRulePrivate *mrp, GList *ls, - gint kount, gint max, - AtkObject *obj, gboolean flag, - AtkObject *pobj) -{ - AtkObject *nextobj; - AtkObject *parent; - glong indexinparent; - - /* This breaks us out of the recursion. */ - if (!obj || obj == pobj) - { - return kount; - } - - /* Add to the list if it matches */ - if (flag && match_interfaces_lookup (obj, mrp) - && match_states_lookup (obj, mrp) - && match_roles_lookup (obj, mrp) - && match_attributes_lookup (obj, mrp)) - { - ls = g_list_append (ls, obj); - kount++; - } - - if(!flag) flag = TRUE; - - /* Get the current nodes index in it's parent and the parent object. */ - indexinparent = atk_object_get_index_in_parent (obj); - parent = atk_object_get_parent(obj); - - if(indexinparent > 0) - { - /* there are still some siblings to visit so get the previous sibling - and get it's last descendant. - First, get the previous sibling */ - nextobj = atk_object_ref_accessible_child (parent, - indexinparent-1); - g_object_unref(nextobj); - - /* Now, drill down the right side to the last descendant */ - while(atk_object_get_n_accessible_children (nextobj) > 0) - { - nextobj = atk_object_ref_accessible_child(nextobj, - atk_object_get_n_accessible_children (nextobj)-1); - g_object_unref (nextobj); - } - /* recurse with the last descendant */ - kount = sort_order_rev_canonical (mrp, ls, kount, max, - nextobj, TRUE, pobj); - } - else - { - /* no more siblings so next node must be the parent */ - kount = sort_order_rev_canonical (mrp, ls, kount, max, - parent, TRUE, pobj); - - } - return kount; -} - -static int -query_exec (MatchRulePrivate *mrp, Accessibility_Collection_SortOrder sortby, - GList *ls, gint kount, gint max, - AtkObject *obj, glong index, - gboolean flag, - AtkObject *pobj, - gboolean recurse, gboolean traverse) -{ - switch (sortby) { - case Accessibility_Collection_SORT_ORDER_CANONICAL : - kount = sort_order_canonical(mrp, ls, 0, max, obj, index, flag, - pobj, recurse, traverse); - break; - case Accessibility_Collection_SORT_ORDER_REVERSE_CANONICAL : - kount = sort_order_canonical(mrp, ls, 0, max, obj, index, flag, - pobj, recurse, traverse); - break; - default: - kount = 0; - g_warning ("Sort method not implemented yet"); - break; - } - - return kount; -} - -static dbus_bool_t -read_mr(DBusMessageIter *iter, MatchRulePrivate *mrp) -{ - DBusMessageIter mrc, arrayc; - dbus_uint32_t *array; - dbus_int32_t matchType; - int array_count; - char *str; - AtkAttribute *attr; - int i; - char *interfaces = NULL; - - // TODO: error checking - dbus_message_iter_recurse(iter, &mrc); - dbus_message_iter_recurse(&mrc, &arrayc); - dbus_message_iter_get_fixed_array(&arrayc, &array, &array_count); - bitarray_to_seq(array, array_count, &mrp->states); - for (i = 0; mrp->states[i] != BITARRAY_SEQ_TERM; i++) - { - mrp->states[i] = spi_atk_state_from_spi_state (mrp->states[i]); - } - dbus_message_iter_next(&mrc); - dbus_message_iter_read_basic(&mrc, &matchType); - dbus_message_iter_next(&mrc); - mrp->statematchtype = matchType;; - /* attributes */ - dbus_message_iter_recurse(&mrc, &arrayc); - mrp->attributes = NULL; - while (dbus_message_iter_get_arg_type(&arrayc) != DBUS_TYPE_INVALID) - { - dbus_message_iter_get_basic(&arrayc, &str); - // TODO: remove this print - g_print("Got attribute: %s\n", str); - attr = g_new (AtkAttribute, 1); - if (attr) - { - int len = strcspn(str, ":"); - attr->name = g_strndup(str, len); - if (str[len] == ':') - { - len++; - if (str[len] == ' ') len++; - attr->value = g_strdup(str + len); - } - else attr->value = NULL; - mrp->attributes = g_slist_prepend(mrp->attributes, attr); - } - dbus_message_iter_next(&arrayc); - } - dbus_message_iter_next(&mrc); - dbus_message_iter_read_basic(&mrc, &matchType); - mrp->attributematchtype = matchType;; - dbus_message_iter_next(&mrc); - /* Get roles and role match */ - dbus_message_iter_recurse(&mrc, &arrayc); - dbus_message_iter_get_fixed_array(&arrayc, &array, &array_count); - bitarray_to_seq(array, array_count, &mrp->roles); - dbus_message_iter_next(&mrc); - dbus_message_iter_read_basic(&mrc, &matchType); - mrp->rolematchtype = matchType;; - dbus_message_iter_next(&mrc); - /* Get interfaces and interface match */ - dbus_message_iter_read_basic(&mrc, &interfaces); - dbus_message_iter_next(&mrc); - mrp->ifaces = g_strsplit(interfaces, ";", 0); - dbus_message_iter_read_basic(&mrc, &matchType); - mrp->interfacematchtype = matchType;; - dbus_message_iter_next(&mrc); - /* get invert */ - dbus_message_iter_read_basic(&mrc, &mrp->invert); - dbus_message_iter_next(iter); - return TRUE; -} - -static DBusMessage * -return_and_free_list(DBusMessage *message, GList *ls) -{ - DBusMessage *reply; - DBusMessageIter iter, iter_array; - GList *item; - - reply = dbus_message_new_method_return(message); - if (!reply) return NULL; - dbus_message_iter_init_append(reply, &iter); - if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "o", &iter_array)) goto oom; - for (item = ls; item; item = g_list_next(item)) - { - char *path = (char *) spi_dbus_object_to_path ((AtkObject *)item->data); - dbus_message_iter_append_basic(&iter_array, DBUS_TYPE_OBJECT_PATH, &path); - g_free(path); - } - if (!dbus_message_iter_close_container(&iter, &iter_array)) goto oom; - g_list_free (ls); - return reply; -oom: - // TODO: Handle out of memory - g_list_free (ls); - return reply; -} - -static void free_mrp_data(MatchRulePrivate *mrp) -{ - g_free(mrp->states); - atk_attribute_set_free(mrp->attributes); - g_free(mrp->roles); - g_strfreev(mrp->ifaces); -} - -static DBusMessage * -getMatchesFrom (DBusMessage *message, - AtkObject *current_object, - MatchRulePrivate *mrp, - const Accessibility_Collection_SortOrder sortby, - const dbus_bool_t isrestrict, - dbus_int32_t count, - const dbus_bool_t traverse) -{ - GList *ls = NULL; - AtkObject *parent; - glong index = - atk_object_get_index_in_parent (current_object); - gint kount = 0; - - ls = g_list_append (ls, current_object); - - if (!isrestrict) - { - parent = atk_object_get_parent (current_object); - kount = query_exec (mrp, sortby, ls, 0, count, parent, index, - FALSE, NULL, TRUE, traverse); - } - else - kount = query_exec (mrp, sortby, ls, 0, count, - current_object, 0, FALSE, NULL, - TRUE, traverse); - - ls = g_list_remove (ls, ls->data); - - if (sortby == Accessibility_Collection_SORT_ORDER_REVERSE_CANONICAL) - ls = g_list_reverse (ls); - - free_mrp_data (mrp); - return return_and_free_list (message, ls); -} - -/* - inorder traversal from a given object in the hierarchy -*/ - -static int -inorder (AtkObject *collection, MatchRulePrivate *mrp, - GList *ls, gint kount, gint max, - AtkObject *obj, - gboolean flag, - AtkObject *pobj, - dbus_bool_t traverse) -{ - int i = 0; - - /* First, look through the children recursively. */ - kount = sort_order_canonical (mrp, ls, kount, max, obj, 0, TRUE, - NULL, TRUE, TRUE); - - /* Next, we look through the right subtree */ - while ((max == 0 || kount < max) - && obj != collection) - { - AtkObject *parent = - atk_object_get_parent (obj); - i = atk_object_get_index_in_parent (obj); - kount = sort_order_canonical (mrp, ls, kount, max, parent, - i+1, TRUE, FALSE, TRUE, TRUE); - obj = parent; - } - - if (kount < max) - { - kount = sort_order_canonical (mrp, ls, kount, max, - obj, i + 1, TRUE, FALSE, - TRUE, TRUE); - } - - return kount; -} - -/* - GetMatchesInOrder: get matches from a given object in an inorder traversal. -*/ - -static DBusMessage * -getMatchesInOrder (DBusMessage *message, - AtkObject *current_object, - MatchRulePrivate *mrp, - const Accessibility_Collection_SortOrder sortby, - const dbus_bool_t recurse, - dbus_int32_t count, - const dbus_bool_t traverse) -{ - GList *ls = NULL; - AtkObject *obj; - gint kount = 0; - - ls = g_list_append (ls, current_object); - - obj = atk_dbus_path_to_object (dbus_message_get_path (message)); - - kount = inorder (obj, mrp, ls, 0, count, - current_object, TRUE, NULL, traverse); - - ls = g_list_remove (ls, ls->data); - - if (sortby == Accessibility_Collection_SORT_ORDER_REVERSE_CANONICAL) - ls = g_list_reverse (ls); - - free_mrp_data (mrp); - return return_and_free_list (message, ls); -} - -/* - GetMatchesInBackOrder: get matches from a given object in a - reverse order traversal. -*/ - -static DBusMessage * -getMatchesInBackOrder (DBusMessage *message, - AtkObject *current_object, - MatchRulePrivate *mrp, - const Accessibility_Collection_SortOrder sortby, - dbus_int32_t count) -{ - GList *ls = NULL; - AtkObject *collection; - gint kount = 0; - - ls = g_list_append (ls, current_object); - - collection = atk_dbus_path_to_object (dbus_message_get_path (message)); - - kount = sort_order_rev_canonical (mrp, ls, 0, count, current_object, - FALSE, collection); - - ls = g_list_remove (ls, ls->data); - - if (sortby == Accessibility_Collection_SORT_ORDER_REVERSE_CANONICAL) - ls = g_list_reverse (ls); - - free_mrp_data (mrp); - return return_and_free_list (message, ls); -} - -static DBusMessage * -getMatchesTo (DBusMessage *message, - AtkObject *current_object, - MatchRulePrivate *mrp, - const Accessibility_Collection_SortOrder sortby, - const dbus_bool_t recurse, - const dbus_bool_t isrestrict, - dbus_int32_t count, - const dbus_bool_t traverse) -{ - GList *ls = NULL; - AtkObject *obj; - gint kount = 0; - - ls = g_list_append (ls, current_object); - - if (recurse){ - obj = atk_object_get_parent (current_object); - kount = query_exec (mrp, sortby, ls, 0, count, - obj, 0, TRUE, current_object, TRUE, traverse); - } - else{ - obj = atk_dbus_path_to_object (dbus_message_get_path (message)); - kount = query_exec (mrp, sortby, ls, 0, count, - obj, 0, TRUE, current_object, TRUE, traverse); - - } - - ls = g_list_remove (ls, ls->data); - - if (sortby != Accessibility_Collection_SORT_ORDER_REVERSE_CANONICAL) - ls = g_list_reverse (ls); - - free_mrp_data (mrp); - return return_and_free_list (message, ls); -} - -static DBusMessage * -impl_getMatchesFrom (DBusConnection *bus, DBusMessage *message, void *user_data) -{ - char *current_object_path = NULL; - AtkObject *current_object; - DBusMessageIter iter; - MatchRulePrivate rule; - dbus_uint16_t sortby; - dbus_uint16_t tree; - dbus_int32_t count; - dbus_bool_t traverse; - GList *ls = NULL; - - dbus_message_iter_init(message, &iter); - dbus_message_iter_get_basic (&iter, current_object_path); - current_object = atk_dbus_path_to_object (current_object_path); - if (!current_object) - { - // TODO: object-not-found error - return spi_dbus_general_error (message); - } - dbus_message_iter_next (&iter); - if (!read_mr(&iter, &rule)) - { - return spi_dbus_general_error (message); - } - dbus_message_iter_get_basic(&iter, &sortby); - dbus_message_iter_next(&iter); - dbus_message_iter_get_basic(&iter, &tree); - dbus_message_iter_next(&iter); - dbus_message_iter_get_basic(&iter, &count); - dbus_message_iter_next(&iter); - dbus_message_iter_get_basic(&iter, &traverse); - dbus_message_iter_next(&iter); - - switch (tree){ - case Accessibility_Collection_TREE_RESTRICT_CHILDREN : - return getMatchesFrom (message, current_object, - &rule, sortby, TRUE, count, traverse); - break; - case Accessibility_Collection_TREE_RESTRICT_SIBLING : - return getMatchesFrom (message, current_object, - &rule, sortby, FALSE, count, traverse); - break; - case Accessibility_Collection_TREE_INORDER : - return getMatchesInOrder (message, current_object, - &rule, sortby, TRUE, count, traverse); - break; - default : return NULL; - } -} - -static DBusMessage * -impl_getMatchesTo (DBusConnection *bus, DBusMessage *message, void *user_data) -{ - char *current_object_path = NULL; - AtkObject *current_object; - DBusMessageIter iter; - MatchRulePrivate rule; - dbus_uint16_t sortby; - dbus_uint16_t tree; - dbus_bool_t recurse; - dbus_int32_t count; - dbus_bool_t traverse; - GList *ls = NULL; - - dbus_message_iter_init(message, &iter); - dbus_message_iter_get_basic (&iter, current_object_path); - current_object = atk_dbus_path_to_object (current_object_path); - if (!current_object) - { - // TODO: object-not-found error - return spi_dbus_general_error (message); - } - dbus_message_iter_next (&iter); - if (!read_mr(&iter, &rule)) - { - return spi_dbus_general_error (message); - } - dbus_message_iter_get_basic(&iter, &sortby); - dbus_message_iter_next(&iter); - dbus_message_iter_get_basic(&iter, &tree); - dbus_message_iter_next(&iter); - dbus_message_iter_get_basic(&iter, &recurse); - dbus_message_iter_next(&iter); - dbus_message_iter_get_basic(&iter, &count); - dbus_message_iter_next(&iter); - dbus_message_iter_get_basic(&iter, &traverse); - dbus_message_iter_next(&iter); - - switch (tree){ - case Accessibility_Collection_TREE_RESTRICT_CHILDREN : - return getMatchesTo (message, current_object, - &rule, sortby, recurse, TRUE, count, traverse); - break; - case Accessibility_Collection_TREE_RESTRICT_SIBLING : - return getMatchesTo (message, current_object, - &rule, sortby, recurse, FALSE, count, traverse); - break; - case Accessibility_Collection_TREE_INORDER : - return getMatchesInBackOrder (message, current_object, - &rule, sortby, count); - break; - default : return NULL; - } -} - -static DBusMessage * -impl_getMatches(DBusConnection *bus, DBusMessage *message, void *user_data) -{ - AtkObject *obj = path_to_object (message); - DBusMessageIter iter; - MatchRulePrivate rule; - dbus_uint16_t sortby; - dbus_int32_t count; - dbus_bool_t traverse; - GList *ls = NULL; - - dbus_message_iter_init(message, &iter); - if (!read_mr(&iter, &rule)) - { - return spi_dbus_general_error (message); - } - dbus_message_iter_get_basic(&iter, &sortby); - dbus_message_iter_next(&iter); - dbus_message_iter_get_basic(&iter, &count); - dbus_message_iter_next(&iter); - dbus_message_iter_get_basic(&iter, &traverse); - dbus_message_iter_next(&iter); - ls = g_list_prepend (ls, obj); - count = query_exec (&rule, sortby, ls, 0, count, - obj, 0, TRUE, NULL, TRUE, traverse); - ls = g_list_remove (ls, ls->data); - - if (sortby == Accessibility_Collection_SORT_ORDER_REVERSE_CANONICAL) - ls = g_list_reverse (ls); - free_mrp_data (&rule); - return return_and_free_list (message, ls); -} - -static DRouteMethod methods[] = { - { impl_getMatchesFrom, "getMatchesFrom" }, - { impl_getMatchesTo, "getMatchesTo" }, - { impl_getMatches, "getMatches" }, - {NULL, NULL} -}; - -void -spi_initialize_collection (DRoutePath *path) -{ - droute_path_add_interface (path, - SPI_DBUS_INTERFACE_COLLECTION, - methods, - NULL); -}; diff --git a/atk-adaptor/component-adaptor.c b/atk-adaptor/component-adaptor.c new file mode 100644 index 0000000..25e44c2 --- /dev/null +++ b/atk-adaptor/component-adaptor.c @@ -0,0 +1,310 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2008 Novell, Inc. + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include + +#include "accessible-marshaller.h" +#include "spi-common/spi-dbus.h" + +static DBusMessage * +impl_contains (DBusConnection * bus, DBusMessage * message, void *user_data) +{ + AtkComponent *component = (AtkComponent *) user_data; + dbus_int32_t x, y; + dbus_int16_t coord_type; + DBusError error; + dbus_bool_t retval; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_COMPONENT (user_data), + droute_not_yet_handled_error (message)); + + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y, + DBUS_TYPE_INT16, &coord_type, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + retval = + atk_component_contains (component, x, y, (AtkCoordType) coord_type); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &retval, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getAccessibleAtPoint (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkComponent *component = (AtkComponent *) user_data; + dbus_int32_t x, y; + dbus_int16_t coord_type; + DBusError error; + AtkObject *child; + + g_return_val_if_fail (ATK_IS_COMPONENT (user_data), + droute_not_yet_handled_error (message)); + + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y, + DBUS_TYPE_INT16, &coord_type, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + child = + atk_component_ref_accessible_at_point (component, x, y, + (AtkCoordType) coord_type); + return spi_dbus_return_object (message, child, TRUE); +} + +static DBusMessage * +impl_getExtents (DBusConnection * bus, DBusMessage * message, void *user_data) +{ + AtkComponent *component = (AtkComponent *) user_data; + DBusError error; + dbus_int16_t coord_type; + gint ix, iy, iwidth, iheight; + + g_return_val_if_fail (ATK_IS_COMPONENT (user_data), + droute_not_yet_handled_error (message)); + + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT16, &coord_type, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + atk_component_get_extents (component, &ix, &iy, &iwidth, &iheight, + (AtkCoordType) coord_type); + return spi_dbus_return_rect (message, ix, iy, iwidth, iheight); +} + +static DBusMessage * +impl_getPosition (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkComponent *component = (AtkComponent *) user_data; + DBusError error; + dbus_int16_t coord_type; + gint ix = 0, iy = 0; + dbus_int32_t x, y; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_COMPONENT (user_data), + droute_not_yet_handled_error (message)); + + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT16, &coord_type, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + atk_component_get_position (component, &ix, &iy, (AtkCoordType) coord_type); + x = ix; + y = iy; + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, + &y, DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getSize (DBusConnection * bus, DBusMessage * message, void *user_data) +{ + AtkComponent *component = (AtkComponent *) user_data; + gint iwidth = 0, iheight = 0; + dbus_int32_t width, height; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_COMPONENT (user_data), + droute_not_yet_handled_error (message)); + + atk_component_get_size (component, &iwidth, &iheight); + width = iwidth; + height = iheight; + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &width, + DBUS_TYPE_INT32, &height, DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getLayer (DBusConnection * bus, DBusMessage * message, void *user_data) +{ + AtkComponent *component = (AtkComponent *) user_data; + AtkLayer atklayer; + dbus_uint32_t rv; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_COMPONENT (user_data), + droute_not_yet_handled_error (message)); + + atklayer = atk_component_get_layer (component); + + switch (atklayer) + { + case ATK_LAYER_BACKGROUND: + rv = Accessibility_LAYER_BACKGROUND; + break; + case ATK_LAYER_CANVAS: + rv = Accessibility_LAYER_CANVAS; + break; + case ATK_LAYER_WIDGET: + rv = Accessibility_LAYER_WIDGET; + break; + case ATK_LAYER_MDI: + rv = Accessibility_LAYER_MDI; + break; + case ATK_LAYER_POPUP: + rv = Accessibility_LAYER_POPUP; + break; + case ATK_LAYER_OVERLAY: + rv = Accessibility_LAYER_OVERLAY; + break; + case ATK_LAYER_WINDOW: + rv = Accessibility_LAYER_WINDOW; + break; + default: + rv = Accessibility_LAYER_INVALID; + break; + } + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_UINT32, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getMDIZOrder (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkComponent *component = (AtkComponent *) user_data; + dbus_int16_t rv; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_COMPONENT (user_data), + droute_not_yet_handled_error (message)); + + rv = atk_component_get_mdi_zorder (component); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT16, &rv, DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_grabFocus (DBusConnection * bus, DBusMessage * message, void *user_data) +{ + AtkComponent *component = (AtkComponent *) user_data; + dbus_bool_t rv; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_COMPONENT (user_data), + droute_not_yet_handled_error (message)); + + rv = atk_component_grab_focus (component); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_UINT32, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +#if 0 +static DBusMessage * +impl_registerFocusHandler (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ +} + +static DBusMessage * +impl_deregisterFocusHandler (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ +} +#endif + +static DBusMessage * +impl_getAlpha (DBusConnection * bus, DBusMessage * message, void *user_data) +{ + AtkComponent *component = (AtkComponent *) user_data; + double rv; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_COMPONENT (user_data), + droute_not_yet_handled_error (message)); + + rv = atk_component_get_alpha (component); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_DOUBLE, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DRouteMethod methods[] = { + {impl_contains, "contains"}, + {impl_getAccessibleAtPoint, "getAccessibleAtPoint"}, + {impl_getExtents, "getExtents"}, + {impl_getPosition, "getPosition"}, + {impl_getSize, "getSize"}, + {impl_getLayer, "getLayer"}, + {impl_getMDIZOrder, "getMDIZOrder"}, + {impl_grabFocus, "grabFocus"}, + //{impl_registerFocusHandler, "registerFocusHandler"}, + //{impl_deregisterFocusHandler, "deregisterFocusHandler"}, + {impl_getAlpha, "getAlpha"}, + {NULL, NULL} +}; + +void +spi_initialize_component (DRoutePath *path) +{ + droute_path_add_interface (path, + SPI_DBUS_INTERFACE_COMPONENT, + methods, + NULL); +}; diff --git a/atk-adaptor/component.c b/atk-adaptor/component.c deleted file mode 100644 index cd132da..0000000 --- a/atk-adaptor/component.c +++ /dev/null @@ -1,310 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) - * - * Copyright 2008 Novell, Inc. - * Copyright 2001, 2002 Sun Microsystems Inc., - * Copyright 2001, 2002 Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include - -#include "atk-dbus.h" -#include "spi-common/spi-dbus.h" - -static DBusMessage * -impl_contains (DBusConnection * bus, DBusMessage * message, void *user_data) -{ - AtkComponent *component = (AtkComponent *) user_data; - dbus_int32_t x, y; - dbus_int16_t coord_type; - DBusError error; - dbus_bool_t retval; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_COMPONENT (user_data), - droute_not_yet_handled_error (message)); - - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y, - DBUS_TYPE_INT16, &coord_type, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - retval = - atk_component_contains (component, x, y, (AtkCoordType) coord_type); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &retval, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getAccessibleAtPoint (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkComponent *component = (AtkComponent *) user_data; - dbus_int32_t x, y; - dbus_int16_t coord_type; - DBusError error; - AtkObject *child; - - g_return_val_if_fail (ATK_IS_COMPONENT (user_data), - droute_not_yet_handled_error (message)); - - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y, - DBUS_TYPE_INT16, &coord_type, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - child = - atk_component_ref_accessible_at_point (component, x, y, - (AtkCoordType) coord_type); - return spi_dbus_return_object (message, child, TRUE); -} - -static DBusMessage * -impl_getExtents (DBusConnection * bus, DBusMessage * message, void *user_data) -{ - AtkComponent *component = (AtkComponent *) user_data; - DBusError error; - dbus_int16_t coord_type; - gint ix, iy, iwidth, iheight; - - g_return_val_if_fail (ATK_IS_COMPONENT (user_data), - droute_not_yet_handled_error (message)); - - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT16, &coord_type, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - atk_component_get_extents (component, &ix, &iy, &iwidth, &iheight, - (AtkCoordType) coord_type); - return spi_dbus_return_rect (message, ix, iy, iwidth, iheight); -} - -static DBusMessage * -impl_getPosition (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkComponent *component = (AtkComponent *) user_data; - DBusError error; - dbus_int16_t coord_type; - gint ix = 0, iy = 0; - dbus_int32_t x, y; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_COMPONENT (user_data), - droute_not_yet_handled_error (message)); - - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT16, &coord_type, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - atk_component_get_position (component, &ix, &iy, (AtkCoordType) coord_type); - x = ix; - y = iy; - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, - &y, DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getSize (DBusConnection * bus, DBusMessage * message, void *user_data) -{ - AtkComponent *component = (AtkComponent *) user_data; - gint iwidth = 0, iheight = 0; - dbus_int32_t width, height; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_COMPONENT (user_data), - droute_not_yet_handled_error (message)); - - atk_component_get_size (component, &iwidth, &iheight); - width = iwidth; - height = iheight; - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT32, &width, - DBUS_TYPE_INT32, &height, DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getLayer (DBusConnection * bus, DBusMessage * message, void *user_data) -{ - AtkComponent *component = (AtkComponent *) user_data; - AtkLayer atklayer; - dbus_uint32_t rv; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_COMPONENT (user_data), - droute_not_yet_handled_error (message)); - - atklayer = atk_component_get_layer (component); - - switch (atklayer) - { - case ATK_LAYER_BACKGROUND: - rv = Accessibility_LAYER_BACKGROUND; - break; - case ATK_LAYER_CANVAS: - rv = Accessibility_LAYER_CANVAS; - break; - case ATK_LAYER_WIDGET: - rv = Accessibility_LAYER_WIDGET; - break; - case ATK_LAYER_MDI: - rv = Accessibility_LAYER_MDI; - break; - case ATK_LAYER_POPUP: - rv = Accessibility_LAYER_POPUP; - break; - case ATK_LAYER_OVERLAY: - rv = Accessibility_LAYER_OVERLAY; - break; - case ATK_LAYER_WINDOW: - rv = Accessibility_LAYER_WINDOW; - break; - default: - rv = Accessibility_LAYER_INVALID; - break; - } - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_UINT32, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getMDIZOrder (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkComponent *component = (AtkComponent *) user_data; - dbus_int16_t rv; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_COMPONENT (user_data), - droute_not_yet_handled_error (message)); - - rv = atk_component_get_mdi_zorder (component); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT16, &rv, DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_grabFocus (DBusConnection * bus, DBusMessage * message, void *user_data) -{ - AtkComponent *component = (AtkComponent *) user_data; - dbus_bool_t rv; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_COMPONENT (user_data), - droute_not_yet_handled_error (message)); - - rv = atk_component_grab_focus (component); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_UINT32, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -#if 0 -static DBusMessage * -impl_registerFocusHandler (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ -} - -static DBusMessage * -impl_deregisterFocusHandler (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ -} -#endif - -static DBusMessage * -impl_getAlpha (DBusConnection * bus, DBusMessage * message, void *user_data) -{ - AtkComponent *component = (AtkComponent *) user_data; - double rv; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_COMPONENT (user_data), - droute_not_yet_handled_error (message)); - - rv = atk_component_get_alpha (component); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_DOUBLE, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DRouteMethod methods[] = { - {impl_contains, "contains"}, - {impl_getAccessibleAtPoint, "getAccessibleAtPoint"}, - {impl_getExtents, "getExtents"}, - {impl_getPosition, "getPosition"}, - {impl_getSize, "getSize"}, - {impl_getLayer, "getLayer"}, - {impl_getMDIZOrder, "getMDIZOrder"}, - {impl_grabFocus, "grabFocus"}, - //{impl_registerFocusHandler, "registerFocusHandler"}, - //{impl_deregisterFocusHandler, "deregisterFocusHandler"}, - {impl_getAlpha, "getAlpha"}, - {NULL, NULL} -}; - -void -spi_initialize_component (DRoutePath *path) -{ - droute_path_add_interface (path, - SPI_DBUS_INTERFACE_COMPONENT, - methods, - NULL); -}; diff --git a/atk-adaptor/document-adaptor.c b/atk-adaptor/document-adaptor.c new file mode 100644 index 0000000..91f6313 --- /dev/null +++ b/atk-adaptor/document-adaptor.c @@ -0,0 +1,137 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2008 Novell, Inc. + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include + +#include "spi-common/spi-dbus.h" + +static DBusMessage * +impl_getLocale (DBusConnection *bus, + DBusMessage *message, + void *user_data) +{ + AtkDocument *document = (AtkDocument *) user_data; + const gchar *lc; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_DOCUMENT (user_data), + droute_not_yet_handled_error (message)); + lc = atk_document_get_locale (document); + if (!lc) + lc = ""; + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_STRING, &lc, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getAttributeValue (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkDocument *document = (AtkDocument *) user_data; + DBusError error; + gchar *attributename; + const gchar *atr; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_DOCUMENT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_STRING, &attributename, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + atr = atk_document_get_attribute_value (document, attributename); + if (!atr) + atr = ""; + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_STRING, &atr, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getAttributes (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkDocument *document = (AtkDocument *) user_data; + DBusMessage *reply; + AtkAttributeSet *attributes; + AtkAttribute *attr = NULL; + char **retval; + gint n_attributes = 0; + gint i; + + g_return_val_if_fail (ATK_IS_DOCUMENT (user_data), + droute_not_yet_handled_error (message)); + + attributes = atk_document_get_attributes (document); + if (attributes) + n_attributes = g_slist_length (attributes); + + retval = (char **) g_malloc (n_attributes * sizeof (char *)); + + for (i = 0; i < n_attributes; ++i) + { + attr = g_slist_nth_data (attributes, i); + retval[i] = g_strconcat (attr->name, ":", attr->value, NULL); + } + if (attributes) + atk_attribute_set_free (attributes); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, + &retval, n_attributes, DBUS_TYPE_INVALID); + } + for (i = 0; i < n_attributes; i++) + g_free (retval[i]); + g_free (retval); + return reply; +} + +static DRouteMethod methods[] = { + {impl_getLocale, "getLocale"}, + {impl_getAttributeValue, "getAttributeValue"}, + {impl_getAttributes, "getAttributes"}, + {NULL, NULL} +}; + +void +spi_initialize_document (DRoutePath *path) +{ + droute_path_add_interface (path, + SPI_DBUS_INTERFACE_DOCUMENT, + methods, + NULL); +}; diff --git a/atk-adaptor/document.c b/atk-adaptor/document.c deleted file mode 100644 index 91f6313..0000000 --- a/atk-adaptor/document.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) - * - * Copyright 2008 Novell, Inc. - * Copyright 2001, 2002 Sun Microsystems Inc., - * Copyright 2001, 2002 Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include - -#include "spi-common/spi-dbus.h" - -static DBusMessage * -impl_getLocale (DBusConnection *bus, - DBusMessage *message, - void *user_data) -{ - AtkDocument *document = (AtkDocument *) user_data; - const gchar *lc; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_DOCUMENT (user_data), - droute_not_yet_handled_error (message)); - lc = atk_document_get_locale (document); - if (!lc) - lc = ""; - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_STRING, &lc, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getAttributeValue (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkDocument *document = (AtkDocument *) user_data; - DBusError error; - gchar *attributename; - const gchar *atr; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_DOCUMENT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_STRING, &attributename, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - atr = atk_document_get_attribute_value (document, attributename); - if (!atr) - atr = ""; - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_STRING, &atr, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getAttributes (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkDocument *document = (AtkDocument *) user_data; - DBusMessage *reply; - AtkAttributeSet *attributes; - AtkAttribute *attr = NULL; - char **retval; - gint n_attributes = 0; - gint i; - - g_return_val_if_fail (ATK_IS_DOCUMENT (user_data), - droute_not_yet_handled_error (message)); - - attributes = atk_document_get_attributes (document); - if (attributes) - n_attributes = g_slist_length (attributes); - - retval = (char **) g_malloc (n_attributes * sizeof (char *)); - - for (i = 0; i < n_attributes; ++i) - { - attr = g_slist_nth_data (attributes, i); - retval[i] = g_strconcat (attr->name, ":", attr->value, NULL); - } - if (attributes) - atk_attribute_set_free (attributes); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, - &retval, n_attributes, DBUS_TYPE_INVALID); - } - for (i = 0; i < n_attributes; i++) - g_free (retval[i]); - g_free (retval); - return reply; -} - -static DRouteMethod methods[] = { - {impl_getLocale, "getLocale"}, - {impl_getAttributeValue, "getAttributeValue"}, - {impl_getAttributes, "getAttributes"}, - {NULL, NULL} -}; - -void -spi_initialize_document (DRoutePath *path) -{ - droute_path_add_interface (path, - SPI_DBUS_INTERFACE_DOCUMENT, - methods, - NULL); -}; diff --git a/atk-adaptor/editabletext-adaptor.c b/atk-adaptor/editabletext-adaptor.c new file mode 100644 index 0000000..76a8866 --- /dev/null +++ b/atk-adaptor/editabletext-adaptor.c @@ -0,0 +1,251 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2008 Novell, Inc. + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include + +#include "spi-common/spi-dbus.h" + +static DBusMessage * +impl_setTextContents (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkEditableText *editable = (AtkEditableText *) user_data; + const char *newContents; + dbus_bool_t rv; + DBusError error; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_STRING, &newContents, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + atk_editable_text_set_text_contents (editable, newContents); + rv = TRUE; + // TODO decide if we really need this return value + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_insertText (DBusConnection * bus, DBusMessage * message, void *user_data) +{ + AtkEditableText *editable = (AtkEditableText *) user_data; + dbus_int32_t position, length; + char *text; + dbus_bool_t rv; + DBusError error; + DBusMessage *reply; + gint ip; + + g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &position, DBUS_TYPE_STRING, &text, + DBUS_TYPE_INT32, &length, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + ip = position; + atk_editable_text_insert_text (editable, text, length, &ip); + rv = TRUE; + // TODO decide if we really need this return value + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_setAttributes (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkEditableText *editable = (AtkEditableText *) user_data; + const char *attributes; + dbus_int32_t startPos, endPos; + dbus_bool_t rv; + DBusError error; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_STRING, &attributes, DBUS_TYPE_INT32, + &startPos, DBUS_TYPE_INT32, &endPos, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + // TODO implement + rv = FALSE; + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_copyText (DBusConnection * bus, DBusMessage * message, void *user_data) +{ + AtkEditableText *editable = (AtkEditableText *) user_data; + dbus_int32_t startPos, endPos; + DBusError error; + + g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &startPos, DBUS_TYPE_INT32, &endPos, + DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + atk_editable_text_copy_text (editable, startPos, endPos); + return NULL; +} + +static DBusMessage * +impl_cutText (DBusConnection * bus, DBusMessage * message, void *user_data) +{ + AtkEditableText *editable = (AtkEditableText *) user_data; + dbus_int32_t startPos, endPos; + DBusError error; + dbus_bool_t rv; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &startPos, DBUS_TYPE_INT32, &endPos, + DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + atk_editable_text_cut_text (editable, startPos, endPos); + rv = TRUE; + // TODO decide if we really need this return value + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_deleteText (DBusConnection * bus, DBusMessage * message, void *user_data) +{ + AtkEditableText *editable = (AtkEditableText *) user_data; + dbus_int32_t startPos, endPos; + DBusError error; + dbus_bool_t rv; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &startPos, DBUS_TYPE_INT32, &endPos, + DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + atk_editable_text_delete_text (editable, startPos, endPos); + rv = TRUE; + // TODO decide if we really need this return value + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_pasteText (DBusConnection * bus, DBusMessage * message, void *user_data) +{ + AtkEditableText *editable = (AtkEditableText *) user_data; + dbus_int32_t position; + DBusError error; + dbus_bool_t rv; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &position, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + atk_editable_text_paste_text (editable, position); + rv = TRUE; + // TODO decide if we really need this return value + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DRouteMethod methods[] = { + {impl_setTextContents, "setTextContents"}, + {impl_insertText, "insertText"}, + {impl_setAttributes, "setAttributes"}, + {impl_copyText, "copyText"}, + {impl_cutText, "cutText"}, + {impl_deleteText, "deleteText"}, + {impl_pasteText, "pasteText"}, + {NULL, NULL} +}; + +void +spi_initialize_editabletext (DRoutePath *path) +{ + droute_path_add_interface (path, + SPI_DBUS_INTERFACE_EDITABLE_TEXT, + methods, + NULL); +}; diff --git a/atk-adaptor/editabletext.c b/atk-adaptor/editabletext.c deleted file mode 100644 index 76a8866..0000000 --- a/atk-adaptor/editabletext.c +++ /dev/null @@ -1,251 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) - * - * Copyright 2008 Novell, Inc. - * Copyright 2001, 2002 Sun Microsystems Inc., - * Copyright 2001, 2002 Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include - -#include "spi-common/spi-dbus.h" - -static DBusMessage * -impl_setTextContents (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkEditableText *editable = (AtkEditableText *) user_data; - const char *newContents; - dbus_bool_t rv; - DBusError error; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_STRING, &newContents, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - atk_editable_text_set_text_contents (editable, newContents); - rv = TRUE; - // TODO decide if we really need this return value - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_insertText (DBusConnection * bus, DBusMessage * message, void *user_data) -{ - AtkEditableText *editable = (AtkEditableText *) user_data; - dbus_int32_t position, length; - char *text; - dbus_bool_t rv; - DBusError error; - DBusMessage *reply; - gint ip; - - g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &position, DBUS_TYPE_STRING, &text, - DBUS_TYPE_INT32, &length, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - ip = position; - atk_editable_text_insert_text (editable, text, length, &ip); - rv = TRUE; - // TODO decide if we really need this return value - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_setAttributes (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkEditableText *editable = (AtkEditableText *) user_data; - const char *attributes; - dbus_int32_t startPos, endPos; - dbus_bool_t rv; - DBusError error; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_STRING, &attributes, DBUS_TYPE_INT32, - &startPos, DBUS_TYPE_INT32, &endPos, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - // TODO implement - rv = FALSE; - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_copyText (DBusConnection * bus, DBusMessage * message, void *user_data) -{ - AtkEditableText *editable = (AtkEditableText *) user_data; - dbus_int32_t startPos, endPos; - DBusError error; - - g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &startPos, DBUS_TYPE_INT32, &endPos, - DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - atk_editable_text_copy_text (editable, startPos, endPos); - return NULL; -} - -static DBusMessage * -impl_cutText (DBusConnection * bus, DBusMessage * message, void *user_data) -{ - AtkEditableText *editable = (AtkEditableText *) user_data; - dbus_int32_t startPos, endPos; - DBusError error; - dbus_bool_t rv; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &startPos, DBUS_TYPE_INT32, &endPos, - DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - atk_editable_text_cut_text (editable, startPos, endPos); - rv = TRUE; - // TODO decide if we really need this return value - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_deleteText (DBusConnection * bus, DBusMessage * message, void *user_data) -{ - AtkEditableText *editable = (AtkEditableText *) user_data; - dbus_int32_t startPos, endPos; - DBusError error; - dbus_bool_t rv; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &startPos, DBUS_TYPE_INT32, &endPos, - DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - atk_editable_text_delete_text (editable, startPos, endPos); - rv = TRUE; - // TODO decide if we really need this return value - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_pasteText (DBusConnection * bus, DBusMessage * message, void *user_data) -{ - AtkEditableText *editable = (AtkEditableText *) user_data; - dbus_int32_t position; - DBusError error; - dbus_bool_t rv; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &position, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - atk_editable_text_paste_text (editable, position); - rv = TRUE; - // TODO decide if we really need this return value - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DRouteMethod methods[] = { - {impl_setTextContents, "setTextContents"}, - {impl_insertText, "insertText"}, - {impl_setAttributes, "setAttributes"}, - {impl_copyText, "copyText"}, - {impl_cutText, "cutText"}, - {impl_deleteText, "deleteText"}, - {impl_pasteText, "pasteText"}, - {NULL, NULL} -}; - -void -spi_initialize_editabletext (DRoutePath *path) -{ - droute_path_add_interface (path, - SPI_DBUS_INTERFACE_EDITABLE_TEXT, - methods, - NULL); -}; diff --git a/atk-adaptor/event.c b/atk-adaptor/event.c index cc03daf..e4991c3 100644 --- a/atk-adaptor/event.c +++ b/atk-adaptor/event.c @@ -2,7 +2,7 @@ * AT-SPI - Assistive Technology Service Provider Interface * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) * - * Copyright 2008, Codethink Ltd. + * Copyright 2008, 2009, Codethink Ltd. * Copyright 2001, 2002, 2003 Sun Microsystems Inc., * Copyright 2001, 2002, 2003 Ximian, Inc. * @@ -28,7 +28,7 @@ #include #include "bridge.h" -#include "atk-dbus.h" +#include "accessible-register.h" #include "spi-common/spi-dbus.h" @@ -37,13 +37,6 @@ static GArray *listener_ids = NULL; static gint atk_bridge_key_event_listener_id; static gint atk_bridge_focus_tracker_id; -/* Amazingly the ATK event callbacks dont have a user - * data parameter. Instead, with great sadness, we use - * some global data. Data is declared and initialized - * in bridge.c. - */ -extern SpiAppData *atk_adaptor_app_data; - /*---------------------------------------------------------------------------*/ #define ITF_EVENT_OBJECT "org.freedesktop.atspi.Event.Object" diff --git a/atk-adaptor/event.h b/atk-adaptor/event.h index d40567d..d62f9ce 100644 --- a/atk-adaptor/event.h +++ b/atk-adaptor/event.h @@ -4,6 +4,7 @@ * * Copyright 2001, 2002 Sun Microsystems Inc., * Copyright 2001, 2002 Ximian, Inc. + * Copyright 2008, 2009 Codethink Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -21,18 +22,13 @@ * Boston, MA 02111-1307, USA. */ -#ifndef SPI_EVENT_H_ -#define SPI_EVENT_H_ +#ifndef EVENT_H +#define EVENT_H -#include #include -G_BEGIN_DECLS - void spi_atk_register_event_listeners (void); void spi_atk_deregister_event_listeners (void); void spi_atk_tidy_windows (void); -G_END_DECLS - -#endif /* SPI_EVENT_H_ */ +#endif /* EVENT_H */ diff --git a/atk-adaptor/hyperlink-adaptor.c b/atk-adaptor/hyperlink-adaptor.c new file mode 100644 index 0000000..9634512 --- /dev/null +++ b/atk-adaptor/hyperlink-adaptor.c @@ -0,0 +1,150 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2008 Novell, Inc. + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include + +#include "accessible-marshaller.h" +#include "spi-common/spi-dbus.h" + +static dbus_bool_t +impl_get_nAnchors (DBusMessageIter * iter, void *user_data) +{ + AtkHyperlink *link = (AtkHyperlink *) user_data; + g_return_val_if_fail (ATK_IS_HYPERLINK (user_data), FALSE); + return droute_return_v_int32 (iter, atk_hyperlink_get_n_anchors (link)); +} + + +static dbus_bool_t +impl_get_startIndex (DBusMessageIter * iter, + void *user_data) +{ + AtkHyperlink *link = (AtkHyperlink *) user_data; + g_return_val_if_fail (ATK_IS_HYPERLINK (user_data), FALSE); + return droute_return_v_int32 (iter, atk_hyperlink_get_start_index (link)); +} + +static dbus_bool_t +impl_get_endIndex (DBusMessageIter * iter, void *user_data) +{ + AtkHyperlink *link = (AtkHyperlink *) user_data; + g_return_val_if_fail (ATK_IS_HYPERLINK (user_data), FALSE); + return droute_return_v_int32 (iter, atk_hyperlink_get_end_index (link)); +} + +static DBusMessage * +impl_getObject (DBusConnection * bus, DBusMessage * message, void *user_data) +{ + AtkHyperlink *link = (AtkHyperlink *) user_data; + DBusError error; + dbus_int32_t i; + AtkObject *atk_object; + + g_return_val_if_fail (ATK_IS_HYPERLINK (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &i, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + atk_object = atk_hyperlink_get_object (link, i); + return spi_dbus_return_object (message, atk_object, FALSE); +} + +static DBusMessage * +impl_getURI (DBusConnection * bus, DBusMessage * message, void *user_data) +{ + AtkHyperlink *link = (AtkHyperlink *) user_data; + dbus_int32_t i; + DBusError error; + gchar *rv; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_HYPERLINK (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &i, DBUS_TYPE_INT32, &i, + DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + + rv = atk_hyperlink_get_uri (link, i); + if (!rv) + rv = g_strdup (""); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_STRING, &rv, + DBUS_TYPE_INVALID); + } + g_free (rv); + return reply; +} + +static DBusMessage * +impl_isValid (DBusConnection * bus, DBusMessage * message, void *user_data) +{ + AtkHyperlink *link = (AtkHyperlink *) user_data; + dbus_bool_t rv; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_HYPERLINK (user_data), + droute_not_yet_handled_error (message)); + + rv = atk_hyperlink_is_valid (link); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DRouteMethod methods[] = { + {impl_getObject, "getObject"}, + {impl_getURI, "getURI"}, + {impl_isValid, "isValid"}, + {NULL, NULL} +}; + +static DRouteProperty properties[] = { + {impl_get_nAnchors, NULL, "nAnchors"}, + {impl_get_startIndex, NULL, "startIndex"}, + {impl_get_endIndex, NULL, "endIndex"}, + {NULL, NULL, NULL} +}; + +void +spi_initialize_hyperlink (DRoutePath *path) +{ + droute_path_add_interface (path, + SPI_DBUS_INTERFACE_HYPERLINK, + methods, + properties); +}; diff --git a/atk-adaptor/hyperlink.c b/atk-adaptor/hyperlink.c deleted file mode 100644 index 39264d5..0000000 --- a/atk-adaptor/hyperlink.c +++ /dev/null @@ -1,150 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) - * - * Copyright 2008 Novell, Inc. - * Copyright 2001, 2002 Sun Microsystems Inc., - * Copyright 2001, 2002 Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include - -#include "atk-dbus.h" -#include "spi-common/spi-dbus.h" - -static dbus_bool_t -impl_get_nAnchors (DBusMessageIter * iter, void *user_data) -{ - AtkHyperlink *link = (AtkHyperlink *) user_data; - g_return_val_if_fail (ATK_IS_HYPERLINK (user_data), FALSE); - return droute_return_v_int32 (iter, atk_hyperlink_get_n_anchors (link)); -} - - -static dbus_bool_t -impl_get_startIndex (DBusMessageIter * iter, - void *user_data) -{ - AtkHyperlink *link = (AtkHyperlink *) user_data; - g_return_val_if_fail (ATK_IS_HYPERLINK (user_data), FALSE); - return droute_return_v_int32 (iter, atk_hyperlink_get_start_index (link)); -} - -static dbus_bool_t -impl_get_endIndex (DBusMessageIter * iter, void *user_data) -{ - AtkHyperlink *link = (AtkHyperlink *) user_data; - g_return_val_if_fail (ATK_IS_HYPERLINK (user_data), FALSE); - return droute_return_v_int32 (iter, atk_hyperlink_get_end_index (link)); -} - -static DBusMessage * -impl_getObject (DBusConnection * bus, DBusMessage * message, void *user_data) -{ - AtkHyperlink *link = (AtkHyperlink *) user_data; - DBusError error; - dbus_int32_t i; - AtkObject *atk_object; - - g_return_val_if_fail (ATK_IS_HYPERLINK (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &i, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - atk_object = atk_hyperlink_get_object (link, i); - return spi_dbus_return_object (message, atk_object, FALSE); -} - -static DBusMessage * -impl_getURI (DBusConnection * bus, DBusMessage * message, void *user_data) -{ - AtkHyperlink *link = (AtkHyperlink *) user_data; - dbus_int32_t i; - DBusError error; - gchar *rv; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_HYPERLINK (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &i, DBUS_TYPE_INT32, &i, - DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - - rv = atk_hyperlink_get_uri (link, i); - if (!rv) - rv = g_strdup (""); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_STRING, &rv, - DBUS_TYPE_INVALID); - } - g_free (rv); - return reply; -} - -static DBusMessage * -impl_isValid (DBusConnection * bus, DBusMessage * message, void *user_data) -{ - AtkHyperlink *link = (AtkHyperlink *) user_data; - dbus_bool_t rv; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_HYPERLINK (user_data), - droute_not_yet_handled_error (message)); - - rv = atk_hyperlink_is_valid (link); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DRouteMethod methods[] = { - {impl_getObject, "getObject"}, - {impl_getURI, "getURI"}, - {impl_isValid, "isValid"}, - {NULL, NULL} -}; - -static DRouteProperty properties[] = { - {impl_get_nAnchors, NULL, "nAnchors"}, - {impl_get_startIndex, NULL, "startIndex"}, - {impl_get_endIndex, NULL, "endIndex"}, - {NULL, NULL, NULL} -}; - -void -spi_initialize_hyperlink (DRoutePath *path) -{ - droute_path_add_interface (path, - SPI_DBUS_INTERFACE_HYPERLINK, - methods, - properties); -}; diff --git a/atk-adaptor/hypertext-adaptor.c b/atk-adaptor/hypertext-adaptor.c new file mode 100644 index 0000000..a1c2298 --- /dev/null +++ b/atk-adaptor/hypertext-adaptor.c @@ -0,0 +1,111 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2008 Novell, Inc. + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include + +#include "spi-common/spi-dbus.h" + +static DBusMessage * +impl_getNLinks (DBusConnection * bus, DBusMessage * message, void *user_data) +{ + AtkHypertext *hypertext = (AtkHypertext *) user_data; + gint rv; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_HYPERTEXT (user_data), + droute_not_yet_handled_error (message)); + rv = atk_hypertext_get_n_links (hypertext); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getLink (DBusConnection * bus, DBusMessage * message, void *user_data) +{ + AtkHypertext *hypertext = (AtkHypertext *) user_data; + DBusError error; + dbus_int32_t linkIndex; + AtkHyperlink *link; + + g_return_val_if_fail (ATK_IS_HYPERTEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &linkIndex, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + link = atk_hypertext_get_link (hypertext, linkIndex); + return spi_dbus_return_object (message, ATK_OBJECT (link), FALSE); +} + +static DBusMessage * +impl_getLinkIndex (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkHypertext *hypertext = (AtkHypertext *) user_data; + DBusError error; + dbus_int32_t characterIndex; + dbus_int32_t rv; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_HYPERTEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &characterIndex, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + rv = atk_hypertext_get_link_index (hypertext, characterIndex); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DRouteMethod methods[] = { + {impl_getNLinks, "getNLinks"}, + {impl_getLink, "getLink"}, + {impl_getLinkIndex, "getLinkIndex"}, + {NULL, NULL} +}; + +void +spi_initialize_hypertext (DRoutePath *path) +{ + droute_path_add_interface (path, + SPI_DBUS_INTERFACE_HYPERTEXT, + methods, + NULL); +}; diff --git a/atk-adaptor/hypertext.c b/atk-adaptor/hypertext.c deleted file mode 100644 index a1c2298..0000000 --- a/atk-adaptor/hypertext.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) - * - * Copyright 2008 Novell, Inc. - * Copyright 2001, 2002 Sun Microsystems Inc., - * Copyright 2001, 2002 Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include - -#include "spi-common/spi-dbus.h" - -static DBusMessage * -impl_getNLinks (DBusConnection * bus, DBusMessage * message, void *user_data) -{ - AtkHypertext *hypertext = (AtkHypertext *) user_data; - gint rv; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_HYPERTEXT (user_data), - droute_not_yet_handled_error (message)); - rv = atk_hypertext_get_n_links (hypertext); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT32, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getLink (DBusConnection * bus, DBusMessage * message, void *user_data) -{ - AtkHypertext *hypertext = (AtkHypertext *) user_data; - DBusError error; - dbus_int32_t linkIndex; - AtkHyperlink *link; - - g_return_val_if_fail (ATK_IS_HYPERTEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &linkIndex, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - link = atk_hypertext_get_link (hypertext, linkIndex); - return spi_dbus_return_object (message, ATK_OBJECT (link), FALSE); -} - -static DBusMessage * -impl_getLinkIndex (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkHypertext *hypertext = (AtkHypertext *) user_data; - DBusError error; - dbus_int32_t characterIndex; - dbus_int32_t rv; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_HYPERTEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &characterIndex, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - rv = atk_hypertext_get_link_index (hypertext, characterIndex); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT32, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DRouteMethod methods[] = { - {impl_getNLinks, "getNLinks"}, - {impl_getLink, "getLink"}, - {impl_getLinkIndex, "getLinkIndex"}, - {NULL, NULL} -}; - -void -spi_initialize_hypertext (DRoutePath *path) -{ - droute_path_add_interface (path, - SPI_DBUS_INTERFACE_HYPERTEXT, - methods, - NULL); -}; diff --git a/atk-adaptor/image-adaptor.c b/atk-adaptor/image-adaptor.c new file mode 100644 index 0000000..23bf365 --- /dev/null +++ b/atk-adaptor/image-adaptor.c @@ -0,0 +1,145 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2008 Novell, Inc. + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include + +#include "spi-common/spi-dbus.h" + +static dbus_bool_t +impl_get_imageDescription (DBusMessageIter * iter, + void *user_data) +{ + AtkImage *image = (AtkImage *) user_data; + g_return_val_if_fail (ATK_IS_IMAGE (user_data), FALSE); + return droute_return_v_string (iter, + atk_image_get_image_description (image)); +} + +static dbus_bool_t +impl_get_imageLocale (DBusMessageIter * iter, + void *user_data) +{ + AtkImage *image = (AtkImage *) user_data; + g_return_val_if_fail (ATK_IS_IMAGE (user_data), FALSE); + return droute_return_v_string (iter, atk_image_get_image_locale (image)); +} + +static DBusMessage * +impl_getImageExtents (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkImage *image = (AtkImage *) user_data; + DBusError error; + dbus_int16_t coordType; + gint ix, iy, iwidth, iheight; + + g_return_val_if_fail (ATK_IS_IMAGE (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT16, &coordType, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + atk_image_get_image_size (image, &iwidth, &iheight); + atk_image_get_image_position (image, &ix, &iy, (AtkCoordType) coordType); + return spi_dbus_return_rect (message, ix, iy, iwidth, iheight); +} + +static DBusMessage * +impl_getImagePosition (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkImage *image = (AtkImage *) user_data; + DBusError error; + dbus_int16_t coord_type; + gint ix = 0, iy = 0; + dbus_int32_t x, y; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_IMAGE (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT16, &coord_type, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + atk_image_get_image_position (image, &ix, &iy, (AtkCoordType) coord_type); + x = ix; + y = iy; + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, + &y, DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getImageSize (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkImage *image = (AtkImage *) user_data; + gint iwidth = 0, iheight = 0; + dbus_int32_t width, height; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_IMAGE (user_data), + droute_not_yet_handled_error (message)); + atk_image_get_image_size (image, &iwidth, &iheight); + width = iwidth; + height = iheight; + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &width, + DBUS_TYPE_INT32, &height, DBUS_TYPE_INVALID); + } + return reply; +} + +static DRouteMethod methods[] = { + {impl_getImageExtents, "getImageExtents"}, + {impl_getImagePosition, "getImagePosition"}, + {impl_getImageSize, "getImageSize"}, + {NULL, NULL} +}; + +static DRouteProperty properties[] = { + {impl_get_imageDescription, NULL, "imageDescription"}, + {impl_get_imageLocale, NULL, "imageLocale"}, + {NULL, NULL, NULL} +}; + +void +spi_initialize_image (DRoutePath *path) +{ + droute_path_add_interface (path, + SPI_DBUS_INTERFACE_IMAGE, + methods, + properties); +}; diff --git a/atk-adaptor/image.c b/atk-adaptor/image.c deleted file mode 100644 index 23bf365..0000000 --- a/atk-adaptor/image.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) - * - * Copyright 2008 Novell, Inc. - * Copyright 2001, 2002 Sun Microsystems Inc., - * Copyright 2001, 2002 Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include - -#include "spi-common/spi-dbus.h" - -static dbus_bool_t -impl_get_imageDescription (DBusMessageIter * iter, - void *user_data) -{ - AtkImage *image = (AtkImage *) user_data; - g_return_val_if_fail (ATK_IS_IMAGE (user_data), FALSE); - return droute_return_v_string (iter, - atk_image_get_image_description (image)); -} - -static dbus_bool_t -impl_get_imageLocale (DBusMessageIter * iter, - void *user_data) -{ - AtkImage *image = (AtkImage *) user_data; - g_return_val_if_fail (ATK_IS_IMAGE (user_data), FALSE); - return droute_return_v_string (iter, atk_image_get_image_locale (image)); -} - -static DBusMessage * -impl_getImageExtents (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkImage *image = (AtkImage *) user_data; - DBusError error; - dbus_int16_t coordType; - gint ix, iy, iwidth, iheight; - - g_return_val_if_fail (ATK_IS_IMAGE (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT16, &coordType, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - atk_image_get_image_size (image, &iwidth, &iheight); - atk_image_get_image_position (image, &ix, &iy, (AtkCoordType) coordType); - return spi_dbus_return_rect (message, ix, iy, iwidth, iheight); -} - -static DBusMessage * -impl_getImagePosition (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkImage *image = (AtkImage *) user_data; - DBusError error; - dbus_int16_t coord_type; - gint ix = 0, iy = 0; - dbus_int32_t x, y; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_IMAGE (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT16, &coord_type, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - atk_image_get_image_position (image, &ix, &iy, (AtkCoordType) coord_type); - x = ix; - y = iy; - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, - &y, DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getImageSize (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkImage *image = (AtkImage *) user_data; - gint iwidth = 0, iheight = 0; - dbus_int32_t width, height; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_IMAGE (user_data), - droute_not_yet_handled_error (message)); - atk_image_get_image_size (image, &iwidth, &iheight); - width = iwidth; - height = iheight; - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT32, &width, - DBUS_TYPE_INT32, &height, DBUS_TYPE_INVALID); - } - return reply; -} - -static DRouteMethod methods[] = { - {impl_getImageExtents, "getImageExtents"}, - {impl_getImagePosition, "getImagePosition"}, - {impl_getImageSize, "getImageSize"}, - {NULL, NULL} -}; - -static DRouteProperty properties[] = { - {impl_get_imageDescription, NULL, "imageDescription"}, - {impl_get_imageLocale, NULL, "imageLocale"}, - {NULL, NULL, NULL} -}; - -void -spi_initialize_image (DRoutePath *path) -{ - droute_path_add_interface (path, - SPI_DBUS_INTERFACE_IMAGE, - methods, - properties); -}; diff --git a/atk-adaptor/relation-adaptor.c b/atk-adaptor/relation-adaptor.c new file mode 100644 index 0000000..12edc7a --- /dev/null +++ b/atk-adaptor/relation-adaptor.c @@ -0,0 +1,169 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* relation.c : implements the Relation interface */ + +#include +#include + +#include +#include + +#include "spi-common/spi-types.h" +#include "spi-common/spi-dbus.h" + +static gboolean +spi_init_relation_type_table (Accessibility_RelationType *types) +{ + gint i; + + for (i = 0; i < ATK_RELATION_LAST_DEFINED; i++) + types[i] = Accessibility_RELATION_NULL; + + types[ATK_RELATION_CONTROLLED_BY] = Accessibility_RELATION_CONTROLLED_BY; + types[ATK_RELATION_CONTROLLER_FOR] = Accessibility_RELATION_CONTROLLER_FOR; + types[ATK_RELATION_LABEL_FOR] = Accessibility_RELATION_LABEL_FOR; + types[ATK_RELATION_LABELLED_BY] = Accessibility_RELATION_LABELLED_BY; + types[ATK_RELATION_MEMBER_OF] = Accessibility_RELATION_MEMBER_OF; + types[ATK_RELATION_NODE_CHILD_OF] = Accessibility_RELATION_NODE_CHILD_OF; + types[ATK_RELATION_FLOWS_TO] = Accessibility_RELATION_FLOWS_TO; + types[ATK_RELATION_FLOWS_FROM] = Accessibility_RELATION_FLOWS_FROM; + types[ATK_RELATION_SUBWINDOW_OF] = Accessibility_RELATION_SUBWINDOW_OF; + types[ATK_RELATION_EMBEDS] = Accessibility_RELATION_EMBEDS; + types[ATK_RELATION_EMBEDDED_BY] = Accessibility_RELATION_EMBEDDED_BY; + types[ATK_RELATION_POPUP_FOR] = Accessibility_RELATION_POPUP_FOR; + types[ATK_RELATION_PARENT_WINDOW_OF] = Accessibility_RELATION_PARENT_WINDOW_OF; + types[ATK_RELATION_DESCRIPTION_FOR] = Accessibility_RELATION_DESCRIPTION_FOR; + types[ATK_RELATION_DESCRIBED_BY] = Accessibility_RELATION_DESCRIBED_BY; + + return TRUE; +} + + + +static Accessibility_RelationType +spi_relation_type_from_atk_relation_type (AtkRelationType type) +{ + static gboolean is_initialized = FALSE; + static Accessibility_RelationType spi_relation_type_table [ATK_RELATION_LAST_DEFINED]; + Accessibility_RelationType spi_type; + + if (!is_initialized) + is_initialized = spi_init_relation_type_table (spi_relation_type_table); + + if (type > ATK_RELATION_NULL && type < ATK_RELATION_LAST_DEFINED) + spi_type = spi_relation_type_table[type]; + else + spi_type = Accessibility_RELATION_EXTENDED; + return spi_type; +} + + + +static AtkRelation * +get_relation_from_servant (PortableServer_Servant servant) +{ + SpiBase *base = SPI_BASE (bonobo_object_from_servant(servant)); + + g_return_val_if_fail (base, NULL); + return ATK_RELATION(base->gobj); +} + + + +static Accessibility_RelationType +impl_getRelationType (PortableServer_Servant servant, + CORBA_Environment * ev) +{ + AtkRelation *relation = get_relation_from_servant (servant); + AtkRelationType type; + + g_return_val_if_fail (relation != NULL, 0); + type = atk_relation_get_relation_type (relation); + return spi_relation_type_from_atk_relation_type (type); +} + + +static CORBA_short +impl_getNTargets (PortableServer_Servant servant, + CORBA_Environment * ev) +{ + AtkRelation *relation = get_relation_from_servant(servant); + g_return_val_if_fail (relation != NULL, 0); + + return relation->target ? relation->target->len : 0; +} + + +static CORBA_Object +impl_getTarget (PortableServer_Servant servant, + const CORBA_short index, + CORBA_Environment * ev) +{ + AtkObject *atk_object; + AtkRelation *relation = get_relation_from_servant (servant); + g_return_val_if_fail (relation, NULL); + + if (!relation->target || + index < 0 || + index >= relation->target->len) + return CORBA_OBJECT_NIL; + + atk_object = g_ptr_array_index (relation->target, index); + if (!atk_object) + return CORBA_OBJECT_NIL; + + return spi_accessible_new_return (atk_object, FALSE, ev); +} + + +SpiRelation * +spi_relation_new (AtkRelation *obj) +{ + SpiRelation *new_relation = g_object_new (SPI_RELATION_TYPE, NULL); + spi_base_construct (SPI_BASE (new_relation), G_OBJECT (obj)); + return new_relation; +} + + +static void +spi_relation_class_init (SpiRelationClass *klass) +{ + POA_Accessibility_Relation__epv *epv = &klass->epv; + + epv->getRelationType = impl_getRelationType; + epv->getNTargets = impl_getNTargets; + epv->getTarget = impl_getTarget; +} + + +static void +spi_relation_init (SpiRelation *relation) +{ +} + + +BONOBO_TYPE_FUNC_FULL (SpiRelation, + Accessibility_Relation, + SPI_TYPE_BASE, + spi_relation) diff --git a/atk-adaptor/relation.c b/atk-adaptor/relation.c deleted file mode 100644 index 12edc7a..0000000 --- a/atk-adaptor/relation.c +++ /dev/null @@ -1,169 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) - * - * Copyright 2001, 2002 Sun Microsystems Inc., - * Copyright 2001, 2002 Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* relation.c : implements the Relation interface */ - -#include -#include - -#include -#include - -#include "spi-common/spi-types.h" -#include "spi-common/spi-dbus.h" - -static gboolean -spi_init_relation_type_table (Accessibility_RelationType *types) -{ - gint i; - - for (i = 0; i < ATK_RELATION_LAST_DEFINED; i++) - types[i] = Accessibility_RELATION_NULL; - - types[ATK_RELATION_CONTROLLED_BY] = Accessibility_RELATION_CONTROLLED_BY; - types[ATK_RELATION_CONTROLLER_FOR] = Accessibility_RELATION_CONTROLLER_FOR; - types[ATK_RELATION_LABEL_FOR] = Accessibility_RELATION_LABEL_FOR; - types[ATK_RELATION_LABELLED_BY] = Accessibility_RELATION_LABELLED_BY; - types[ATK_RELATION_MEMBER_OF] = Accessibility_RELATION_MEMBER_OF; - types[ATK_RELATION_NODE_CHILD_OF] = Accessibility_RELATION_NODE_CHILD_OF; - types[ATK_RELATION_FLOWS_TO] = Accessibility_RELATION_FLOWS_TO; - types[ATK_RELATION_FLOWS_FROM] = Accessibility_RELATION_FLOWS_FROM; - types[ATK_RELATION_SUBWINDOW_OF] = Accessibility_RELATION_SUBWINDOW_OF; - types[ATK_RELATION_EMBEDS] = Accessibility_RELATION_EMBEDS; - types[ATK_RELATION_EMBEDDED_BY] = Accessibility_RELATION_EMBEDDED_BY; - types[ATK_RELATION_POPUP_FOR] = Accessibility_RELATION_POPUP_FOR; - types[ATK_RELATION_PARENT_WINDOW_OF] = Accessibility_RELATION_PARENT_WINDOW_OF; - types[ATK_RELATION_DESCRIPTION_FOR] = Accessibility_RELATION_DESCRIPTION_FOR; - types[ATK_RELATION_DESCRIBED_BY] = Accessibility_RELATION_DESCRIBED_BY; - - return TRUE; -} - - - -static Accessibility_RelationType -spi_relation_type_from_atk_relation_type (AtkRelationType type) -{ - static gboolean is_initialized = FALSE; - static Accessibility_RelationType spi_relation_type_table [ATK_RELATION_LAST_DEFINED]; - Accessibility_RelationType spi_type; - - if (!is_initialized) - is_initialized = spi_init_relation_type_table (spi_relation_type_table); - - if (type > ATK_RELATION_NULL && type < ATK_RELATION_LAST_DEFINED) - spi_type = spi_relation_type_table[type]; - else - spi_type = Accessibility_RELATION_EXTENDED; - return spi_type; -} - - - -static AtkRelation * -get_relation_from_servant (PortableServer_Servant servant) -{ - SpiBase *base = SPI_BASE (bonobo_object_from_servant(servant)); - - g_return_val_if_fail (base, NULL); - return ATK_RELATION(base->gobj); -} - - - -static Accessibility_RelationType -impl_getRelationType (PortableServer_Servant servant, - CORBA_Environment * ev) -{ - AtkRelation *relation = get_relation_from_servant (servant); - AtkRelationType type; - - g_return_val_if_fail (relation != NULL, 0); - type = atk_relation_get_relation_type (relation); - return spi_relation_type_from_atk_relation_type (type); -} - - -static CORBA_short -impl_getNTargets (PortableServer_Servant servant, - CORBA_Environment * ev) -{ - AtkRelation *relation = get_relation_from_servant(servant); - g_return_val_if_fail (relation != NULL, 0); - - return relation->target ? relation->target->len : 0; -} - - -static CORBA_Object -impl_getTarget (PortableServer_Servant servant, - const CORBA_short index, - CORBA_Environment * ev) -{ - AtkObject *atk_object; - AtkRelation *relation = get_relation_from_servant (servant); - g_return_val_if_fail (relation, NULL); - - if (!relation->target || - index < 0 || - index >= relation->target->len) - return CORBA_OBJECT_NIL; - - atk_object = g_ptr_array_index (relation->target, index); - if (!atk_object) - return CORBA_OBJECT_NIL; - - return spi_accessible_new_return (atk_object, FALSE, ev); -} - - -SpiRelation * -spi_relation_new (AtkRelation *obj) -{ - SpiRelation *new_relation = g_object_new (SPI_RELATION_TYPE, NULL); - spi_base_construct (SPI_BASE (new_relation), G_OBJECT (obj)); - return new_relation; -} - - -static void -spi_relation_class_init (SpiRelationClass *klass) -{ - POA_Accessibility_Relation__epv *epv = &klass->epv; - - epv->getRelationType = impl_getRelationType; - epv->getNTargets = impl_getNTargets; - epv->getTarget = impl_getTarget; -} - - -static void -spi_relation_init (SpiRelation *relation) -{ -} - - -BONOBO_TYPE_FUNC_FULL (SpiRelation, - Accessibility_Relation, - SPI_TYPE_BASE, - spi_relation) diff --git a/atk-adaptor/selection-adaptor.c b/atk-adaptor/selection-adaptor.c new file mode 100644 index 0000000..3cae386 --- /dev/null +++ b/atk-adaptor/selection-adaptor.c @@ -0,0 +1,260 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2008 Novell, Inc. + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include + +#include "spi-common/spi-dbus.h" + +static dbus_bool_t +impl_get_nSelectedChildren (DBusMessageIter * iter, + void *user_data) +{ + AtkSelection *selection = (AtkSelection *) user_data; + g_return_val_if_fail (ATK_IS_SELECTION (user_data), FALSE); + return droute_return_v_int32 (iter, + atk_selection_get_selection_count + (selection)); +} + +/*static char * +impl_get_nSelectedChildren_str (void *datum) +{ + g_assert (ATK_IS_HYPERLINK (datum)); + return g_strdup_printf ("%d", + atk_selection_get_selection_count ((AtkSelection *) + datum)); +}*/ + +static DBusMessage * +impl_getSelectedChild (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkSelection *selection = (AtkSelection *) user_data; + DBusError error; + dbus_int32_t selectedChildIndex; + AtkObject *atk_object; + + g_return_val_if_fail (ATK_IS_SELECTION (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &selectedChildIndex, + DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + atk_object = atk_selection_ref_selection (selection, selectedChildIndex); + return spi_dbus_return_object (message, atk_object, TRUE); +} + +static DBusMessage * +impl_selectChild (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkSelection *selection = (AtkSelection *) user_data; + DBusError error; + dbus_int32_t childIndex; + dbus_bool_t rv; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_SELECTION (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &childIndex, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + rv = atk_selection_add_selection (selection, childIndex); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_deselectSelectedChild (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkSelection *selection = (AtkSelection *) user_data; + DBusError error; + dbus_int32_t selectedChildIndex; + dbus_bool_t rv; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_SELECTION (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &selectedChildIndex, + DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + rv = atk_selection_remove_selection (selection, selectedChildIndex); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_isChildSelected (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkSelection *selection = (AtkSelection *) user_data; + DBusError error; + dbus_int32_t childIndex; + dbus_bool_t rv; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_SELECTION (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &childIndex, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + rv = atk_selection_is_child_selected (selection, childIndex); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_selectAll (DBusConnection * bus, DBusMessage * message, void *user_data) +{ + AtkSelection *selection = (AtkSelection *) user_data; + dbus_bool_t rv; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_SELECTION (user_data), + droute_not_yet_handled_error (message)); + rv = atk_selection_select_all_selection (selection); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_clearSelection (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkSelection *selection = (AtkSelection *) user_data; + dbus_bool_t rv; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_SELECTION (user_data), + droute_not_yet_handled_error (message)); + rv = atk_selection_clear_selection (selection); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_deselectChild (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkSelection *selection = (AtkSelection *) user_data; + DBusError error; + dbus_int32_t selectedChildIndex; + dbus_bool_t rv = FALSE; + gint i, nselected; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_SELECTION (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &selectedChildIndex, + DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + nselected = atk_selection_get_selection_count (selection); + for (i = 0; i < nselected; ++i) + { + AtkObject *selected_obj = atk_selection_ref_selection (selection, i); + if (atk_object_get_index_in_parent (selected_obj) == selectedChildIndex) + { + g_object_unref (G_OBJECT (selected_obj)); + rv = atk_selection_remove_selection (selection, i); + break; + } + g_object_unref (G_OBJECT (selected_obj)); + } + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DRouteMethod methods[] = { + {impl_getSelectedChild, "getSelectedChild"}, + {impl_selectChild, "selectChild"}, + {impl_deselectSelectedChild, "deselectSelectedChild"}, + {impl_isChildSelected, "isChildSelected"}, + {impl_selectAll, "selectAll"}, + {impl_clearSelection, "clearSelection"}, + {impl_deselectChild, "deselectChild"}, + {NULL, NULL} +}; + +static DRouteProperty properties[] = { + {impl_get_nSelectedChildren, NULL, "nSelectedChildren"}, + {NULL, NULL, NULL} +}; + +void +spi_initialize_selection (DRoutePath *path) +{ + droute_path_add_interface (path, + SPI_DBUS_INTERFACE_SELECTION, + methods, + properties); +}; diff --git a/atk-adaptor/selection.c b/atk-adaptor/selection.c deleted file mode 100644 index 3cae386..0000000 --- a/atk-adaptor/selection.c +++ /dev/null @@ -1,260 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) - * - * Copyright 2008 Novell, Inc. - * Copyright 2001, 2002 Sun Microsystems Inc., - * Copyright 2001, 2002 Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include - -#include "spi-common/spi-dbus.h" - -static dbus_bool_t -impl_get_nSelectedChildren (DBusMessageIter * iter, - void *user_data) -{ - AtkSelection *selection = (AtkSelection *) user_data; - g_return_val_if_fail (ATK_IS_SELECTION (user_data), FALSE); - return droute_return_v_int32 (iter, - atk_selection_get_selection_count - (selection)); -} - -/*static char * -impl_get_nSelectedChildren_str (void *datum) -{ - g_assert (ATK_IS_HYPERLINK (datum)); - return g_strdup_printf ("%d", - atk_selection_get_selection_count ((AtkSelection *) - datum)); -}*/ - -static DBusMessage * -impl_getSelectedChild (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkSelection *selection = (AtkSelection *) user_data; - DBusError error; - dbus_int32_t selectedChildIndex; - AtkObject *atk_object; - - g_return_val_if_fail (ATK_IS_SELECTION (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &selectedChildIndex, - DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - atk_object = atk_selection_ref_selection (selection, selectedChildIndex); - return spi_dbus_return_object (message, atk_object, TRUE); -} - -static DBusMessage * -impl_selectChild (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkSelection *selection = (AtkSelection *) user_data; - DBusError error; - dbus_int32_t childIndex; - dbus_bool_t rv; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_SELECTION (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &childIndex, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - rv = atk_selection_add_selection (selection, childIndex); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_deselectSelectedChild (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkSelection *selection = (AtkSelection *) user_data; - DBusError error; - dbus_int32_t selectedChildIndex; - dbus_bool_t rv; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_SELECTION (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &selectedChildIndex, - DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - rv = atk_selection_remove_selection (selection, selectedChildIndex); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_isChildSelected (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkSelection *selection = (AtkSelection *) user_data; - DBusError error; - dbus_int32_t childIndex; - dbus_bool_t rv; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_SELECTION (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &childIndex, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - rv = atk_selection_is_child_selected (selection, childIndex); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_selectAll (DBusConnection * bus, DBusMessage * message, void *user_data) -{ - AtkSelection *selection = (AtkSelection *) user_data; - dbus_bool_t rv; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_SELECTION (user_data), - droute_not_yet_handled_error (message)); - rv = atk_selection_select_all_selection (selection); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_clearSelection (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkSelection *selection = (AtkSelection *) user_data; - dbus_bool_t rv; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_SELECTION (user_data), - droute_not_yet_handled_error (message)); - rv = atk_selection_clear_selection (selection); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_deselectChild (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkSelection *selection = (AtkSelection *) user_data; - DBusError error; - dbus_int32_t selectedChildIndex; - dbus_bool_t rv = FALSE; - gint i, nselected; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_SELECTION (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &selectedChildIndex, - DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - nselected = atk_selection_get_selection_count (selection); - for (i = 0; i < nselected; ++i) - { - AtkObject *selected_obj = atk_selection_ref_selection (selection, i); - if (atk_object_get_index_in_parent (selected_obj) == selectedChildIndex) - { - g_object_unref (G_OBJECT (selected_obj)); - rv = atk_selection_remove_selection (selection, i); - break; - } - g_object_unref (G_OBJECT (selected_obj)); - } - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DRouteMethod methods[] = { - {impl_getSelectedChild, "getSelectedChild"}, - {impl_selectChild, "selectChild"}, - {impl_deselectSelectedChild, "deselectSelectedChild"}, - {impl_isChildSelected, "isChildSelected"}, - {impl_selectAll, "selectAll"}, - {impl_clearSelection, "clearSelection"}, - {impl_deselectChild, "deselectChild"}, - {NULL, NULL} -}; - -static DRouteProperty properties[] = { - {impl_get_nSelectedChildren, NULL, "nSelectedChildren"}, - {NULL, NULL, NULL} -}; - -void -spi_initialize_selection (DRoutePath *path) -{ - droute_path_add_interface (path, - SPI_DBUS_INTERFACE_SELECTION, - methods, - properties); -}; diff --git a/atk-adaptor/streamablecontent-adaptor.c b/atk-adaptor/streamablecontent-adaptor.c new file mode 100644 index 0000000..8b3d40b --- /dev/null +++ b/atk-adaptor/streamablecontent-adaptor.c @@ -0,0 +1,316 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) * + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* streamablecontent.c : implements the StreamableContent interface */ + +#include +#include +#include + +#include +#include + +/* Our parent Gtk object type */ +#define PARENT_TYPE SPI_TYPE_BASE + +/* A pointer to our parent object class */ +static GObjectClass *spi_streamable_parent_class; + +#define SPI_CONTENT_STREAM_TYPE (spi_content_stream_get_type ()) +#define SPI_CONTENT_STREAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_CONTENT_STREAM_TYPE, SpiContentStream)) +#define SPI_CONTENT_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SPI_CONTENT_STREAM_TYPE, SpiContentStreamClass)) +#define SPI_IS_CONTENT_STREAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SPI_CONTENT_STREAM_TYPE)) +#define SPI_IS_CONTENT_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SPI_CONTENT_STREAM_TYPE)) + +typedef struct _SpiContentStream SpiContentStream; +typedef struct _SpiContentStreamClass SpiContentStreamClass; + +struct _SpiContentStream { + BonoboObject parent; + GIOChannel *gio; +}; + +struct _SpiContentStreamClass { + BonoboObjectClass parent_class; + POA_Accessibility_ContentStream__epv epv; +}; + +GType spi_content_stream_get_type (void); + +static SpiContentStream* +spi_content_stream_new (GIOChannel *gio) +{ + SpiContentStream *new_stream = g_object_new (SPI_CONTENT_STREAM_TYPE, NULL); + new_stream->gio = gio; + return new_stream; +} + +static void +spi_content_stream_dispose (GObject *o) +{ + if (SPI_IS_CONTENT_STREAM (o)) + { + SpiContentStream *stream = SPI_CONTENT_STREAM (o); + if (stream->gio) g_io_channel_unref (stream->gio); + } +} + +static CORBA_long +impl_content_stream_seek (PortableServer_Servant servant, + const CORBA_long offset, + const Accessibility_ContentStream_SeekType whence, + CORBA_Environment *ev) +{ + SpiContentStream *stream = SPI_CONTENT_STREAM (bonobo_object_from_servant(servant)); + if (stream && stream->gio) + { + GError *err; + GSeekType seektype = G_SEEK_SET; + switch (whence) { + case Accessibility_ContentStream_SEEK_CURRENT: + seektype = G_SEEK_CUR; + break; + case Accessibility_ContentStream_SEEK_END: + seektype = G_SEEK_END; + break; + } + if (g_io_channel_seek_position (stream->gio, (gint64) offset, + seektype, &err) == G_IO_STATUS_NORMAL) + return offset; + else + return -1; + } + else + return -1; +} + +static CORBA_long +impl_content_stream_read (PortableServer_Servant servant, + const CORBA_long count, + Accessibility_ContentStream_iobuf** buffer, + CORBA_Environment *ev) +{ + SpiContentStream *stream = SPI_CONTENT_STREAM (bonobo_object_from_servant(servant)); + CORBA_long realcount = 0; + + if (stream && stream->gio) + { + gchar *gbuf = NULL; + GIOStatus status; + GError *err = NULL; + + /* read the giochannel and determine the actual bytes read...*/ + if (count != -1) { + gbuf = g_malloc (count+1); + status = g_io_channel_read_chars (stream->gio, gbuf, count, &realcount, &err); + } + else + status = g_io_channel_read_to_end (stream->gio, &gbuf, &realcount, &err); + + if (status == G_IO_STATUS_NORMAL || status == G_IO_STATUS_EOF) + { + *buffer = Bonobo_Stream_iobuf__alloc (); + CORBA_sequence_set_release (*buffer, TRUE); + + (*buffer)->_buffer = CORBA_sequence_CORBA_octet_allocbuf (realcount); + (*buffer)->_length = realcount; + + g_memmove ((*buffer)->_buffer, gbuf, realcount); + } + + g_free (gbuf); + } + + return realcount; +} + +static void +impl_content_stream_close (PortableServer_Servant servant, + CORBA_Environment *ev) +{ + GIOStatus status; + GError *err; + SpiContentStream *stream = SPI_CONTENT_STREAM (bonobo_object_from_servant(servant)); + if (stream && stream->gio) { + status = g_io_channel_shutdown (stream->gio, TRUE, &err); + g_io_channel_unref (stream->gio); + } + if (err) g_free (err); +} + +static void +spi_content_stream_class_init (SpiContentStreamClass *klass) +{ + POA_Accessibility_ContentStream__epv *epv = &klass->epv; + GObjectClass * object_class = (GObjectClass *) klass; + + epv->seek = impl_content_stream_seek; + epv->read = impl_content_stream_read; + epv->close = impl_content_stream_close; + + object_class->dispose = spi_content_stream_dispose; +} + + +static void +spi_content_stream_init (SpiContentStream *stream) +{ +} + + +BONOBO_TYPE_FUNC_FULL (SpiContentStream, + Accessibility_ContentStream, + BONOBO_TYPE_OBJECT, + spi_content_stream) + +static AtkStreamableContent * +get_streamable_from_servant (PortableServer_Servant servant) +{ + SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant)); + g_return_val_if_fail (object != NULL, NULL); + g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT(object->gobj), NULL); + return ATK_STREAMABLE_CONTENT (object->gobj); +} + +/* + * CORBA Accessibility::StreamableContent::getContentTypes method implementation + */ +static Accessibility_StringSeq* +impl_accessibility_streamable_get_content_types (PortableServer_Servant servant, + CORBA_Environment *ev) +{ + Accessibility_StringSeq *typelist = Accessibility_StringSeq__alloc (); + AtkStreamableContent *streamable = get_streamable_from_servant (servant); + int n_types, i; + + typelist->_length = typelist->_maximum = 0; + + g_return_val_if_fail (streamable != NULL, typelist); + + n_types = atk_streamable_content_get_n_mime_types (streamable); + + if (n_types) + { + typelist->_length = typelist->_maximum = n_types; + typelist->_buffer = Accessibility_StringSeq_allocbuf (n_types); + for (i = 0; i < n_types; ++i) { + const gchar *mimetype = atk_streamable_content_get_mime_type (streamable, i); + typelist->_buffer[i] = CORBA_string_dup (mimetype ? mimetype : ""); + } + } + return typelist; +} + +/* + * CORBA Accessibility::StreamableContent::getContent method implementation + */ +static Bonobo_Stream +impl_accessibility_streamable_get_content (PortableServer_Servant servant, + const CORBA_char * content_type, + CORBA_Environment *ev) +{ + Bonobo_Stream stream; + AtkStreamableContent *streamable = get_streamable_from_servant (servant); + GIOChannel *gio; + + g_return_val_if_fail (streamable != NULL, NULL); + + gio = atk_streamable_content_get_stream (streamable, content_type); + + stream = CORBA_OBJECT_NIL; /* deprecated, + * and it was never implemented, + * so don't bother fixing this + */ + return stream; +} + +/* + * CORBA Accessibility::StreamableContent::getStream method implementation + */ +static Accessibility_ContentStream +impl_accessibility_streamable_get_stream (PortableServer_Servant servant, + const CORBA_char * content_type, + CORBA_Environment *ev) +{ + SpiContentStream *stream; + AtkStreamableContent *streamable = get_streamable_from_servant (servant); + GIOChannel *gio; + + g_return_val_if_fail (streamable != NULL, NULL); + + gio = atk_streamable_content_get_stream (streamable, content_type); + + stream = spi_content_stream_new (gio); + + return bonobo_object_dup_ref (BONOBO_OBJREF (stream), ev); +} + +/* + * CORBA Accessibility::StreamableContent::getURI method implementation + */ +static CORBA_string +impl_accessibility_streamable_get_uri (PortableServer_Servant servant, + const CORBA_char * content_type, + CORBA_Environment *ev) +{ + gchar *uri; + AtkStreamableContent *streamable = get_streamable_from_servant (servant); + + g_return_val_if_fail (streamable != NULL, NULL); + + uri = atk_streamable_content_get_uri (streamable, content_type); + + return (uri != NULL ? CORBA_string_dup (uri) : CORBA_string_dup ("")); +} + +static void +spi_streamable_class_init (SpiStreamableClass *klass) +{ + POA_Accessibility_StreamableContent__epv *epv = &klass->epv; + spi_streamable_parent_class = g_type_class_peek_parent (klass); + + epv->getContentTypes = impl_accessibility_streamable_get_content_types; + epv->getContent = impl_accessibility_streamable_get_content; + epv->getStream = impl_accessibility_streamable_get_stream; + epv->getURI = impl_accessibility_streamable_get_uri; +} + +static void +spi_streamable_init (SpiStreamable *streamable) +{ +} + + +SpiStreamable * +spi_streamable_interface_new (AtkObject *o) +{ + SpiStreamable *retval = g_object_new (SPI_STREAMABLE_TYPE, NULL); + + spi_base_construct (SPI_BASE (retval), G_OBJECT(o)); + + return retval; +} + +BONOBO_TYPE_FUNC_FULL (SpiStreamable, + Accessibility_StreamableContent, + PARENT_TYPE, + spi_streamable) diff --git a/atk-adaptor/streamablecontent.c b/atk-adaptor/streamablecontent.c deleted file mode 100644 index cbe0686..0000000 --- a/atk-adaptor/streamablecontent.c +++ /dev/null @@ -1,316 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) * - * Copyright 2001, 2002 Sun Microsystems Inc., - * Copyright 2001, 2002 Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* streamablecontent.c : implements the StreamableContent interface */ - -#include -#include -#include -#include -#include -#include - -/* Our parent Gtk object type */ -#define PARENT_TYPE SPI_TYPE_BASE - -/* A pointer to our parent object class */ -static GObjectClass *spi_streamable_parent_class; - -#define SPI_CONTENT_STREAM_TYPE (spi_content_stream_get_type ()) -#define SPI_CONTENT_STREAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_CONTENT_STREAM_TYPE, SpiContentStream)) -#define SPI_CONTENT_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SPI_CONTENT_STREAM_TYPE, SpiContentStreamClass)) -#define SPI_IS_CONTENT_STREAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SPI_CONTENT_STREAM_TYPE)) -#define SPI_IS_CONTENT_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SPI_CONTENT_STREAM_TYPE)) - -typedef struct _SpiContentStream SpiContentStream; -typedef struct _SpiContentStreamClass SpiContentStreamClass; - -struct _SpiContentStream { - BonoboObject parent; - GIOChannel *gio; -}; - -struct _SpiContentStreamClass { - BonoboObjectClass parent_class; - POA_Accessibility_ContentStream__epv epv; -}; - -GType spi_content_stream_get_type (void); - -static SpiContentStream* -spi_content_stream_new (GIOChannel *gio) -{ - SpiContentStream *new_stream = g_object_new (SPI_CONTENT_STREAM_TYPE, NULL); - new_stream->gio = gio; - return new_stream; -} - -static void -spi_content_stream_dispose (GObject *o) -{ - if (SPI_IS_CONTENT_STREAM (o)) - { - SpiContentStream *stream = SPI_CONTENT_STREAM (o); - if (stream->gio) g_io_channel_unref (stream->gio); - } -} - -static CORBA_long -impl_content_stream_seek (PortableServer_Servant servant, - const CORBA_long offset, - const Accessibility_ContentStream_SeekType whence, - CORBA_Environment *ev) -{ - SpiContentStream *stream = SPI_CONTENT_STREAM (bonobo_object_from_servant(servant)); - if (stream && stream->gio) - { - GError *err; - GSeekType seektype = G_SEEK_SET; - switch (whence) { - case Accessibility_ContentStream_SEEK_CURRENT: - seektype = G_SEEK_CUR; - break; - case Accessibility_ContentStream_SEEK_END: - seektype = G_SEEK_END; - break; - } - if (g_io_channel_seek_position (stream->gio, (gint64) offset, - seektype, &err) == G_IO_STATUS_NORMAL) - return offset; - else - return -1; - } - else - return -1; -} - -static CORBA_long -impl_content_stream_read (PortableServer_Servant servant, - const CORBA_long count, - Accessibility_ContentStream_iobuf** buffer, - CORBA_Environment *ev) -{ - SpiContentStream *stream = SPI_CONTENT_STREAM (bonobo_object_from_servant(servant)); - CORBA_long realcount = 0; - - if (stream && stream->gio) - { - gchar *gbuf = NULL; - GIOStatus status; - GError *err = NULL; - - /* read the giochannel and determine the actual bytes read...*/ - if (count != -1) { - gbuf = g_malloc (count+1); - status = g_io_channel_read_chars (stream->gio, gbuf, count, &realcount, &err); - } - else - status = g_io_channel_read_to_end (stream->gio, &gbuf, &realcount, &err); - - if (status == G_IO_STATUS_NORMAL || status == G_IO_STATUS_EOF) - { - *buffer = Bonobo_Stream_iobuf__alloc (); - CORBA_sequence_set_release (*buffer, TRUE); - - (*buffer)->_buffer = CORBA_sequence_CORBA_octet_allocbuf (realcount); - (*buffer)->_length = realcount; - - g_memmove ((*buffer)->_buffer, gbuf, realcount); - } - - g_free (gbuf); - } - - return realcount; -} - -static void -impl_content_stream_close (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - GIOStatus status; - GError *err; - SpiContentStream *stream = SPI_CONTENT_STREAM (bonobo_object_from_servant(servant)); - if (stream && stream->gio) { - status = g_io_channel_shutdown (stream->gio, TRUE, &err); - g_io_channel_unref (stream->gio); - } - if (err) g_free (err); -} - -static void -spi_content_stream_class_init (SpiContentStreamClass *klass) -{ - POA_Accessibility_ContentStream__epv *epv = &klass->epv; - GObjectClass * object_class = (GObjectClass *) klass; - - epv->seek = impl_content_stream_seek; - epv->read = impl_content_stream_read; - epv->close = impl_content_stream_close; - - object_class->dispose = spi_content_stream_dispose; -} - - -static void -spi_content_stream_init (SpiContentStream *stream) -{ -} - - -BONOBO_TYPE_FUNC_FULL (SpiContentStream, - Accessibility_ContentStream, - BONOBO_TYPE_OBJECT, - spi_content_stream) - -static AtkStreamableContent * -get_streamable_from_servant (PortableServer_Servant servant) -{ - SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant)); - g_return_val_if_fail (object != NULL, NULL); - g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT(object->gobj), NULL); - return ATK_STREAMABLE_CONTENT (object->gobj); -} - -/* - * CORBA Accessibility::StreamableContent::getContentTypes method implementation - */ -static Accessibility_StringSeq* -impl_accessibility_streamable_get_content_types (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - Accessibility_StringSeq *typelist = Accessibility_StringSeq__alloc (); - AtkStreamableContent *streamable = get_streamable_from_servant (servant); - int n_types, i; - - typelist->_length = typelist->_maximum = 0; - - g_return_val_if_fail (streamable != NULL, typelist); - - n_types = atk_streamable_content_get_n_mime_types (streamable); - - if (n_types) - { - typelist->_length = typelist->_maximum = n_types; - typelist->_buffer = Accessibility_StringSeq_allocbuf (n_types); - for (i = 0; i < n_types; ++i) { - const gchar *mimetype = atk_streamable_content_get_mime_type (streamable, i); - typelist->_buffer[i] = CORBA_string_dup (mimetype ? mimetype : ""); - } - } - return typelist; -} - -/* - * CORBA Accessibility::StreamableContent::getContent method implementation - */ -static Bonobo_Stream -impl_accessibility_streamable_get_content (PortableServer_Servant servant, - const CORBA_char * content_type, - CORBA_Environment *ev) -{ - Bonobo_Stream stream; - AtkStreamableContent *streamable = get_streamable_from_servant (servant); - GIOChannel *gio; - - g_return_val_if_fail (streamable != NULL, NULL); - - gio = atk_streamable_content_get_stream (streamable, content_type); - - stream = CORBA_OBJECT_NIL; /* deprecated, - * and it was never implemented, - * so don't bother fixing this - */ - return stream; -} - -/* - * CORBA Accessibility::StreamableContent::getStream method implementation - */ -static Accessibility_ContentStream -impl_accessibility_streamable_get_stream (PortableServer_Servant servant, - const CORBA_char * content_type, - CORBA_Environment *ev) -{ - SpiContentStream *stream; - AtkStreamableContent *streamable = get_streamable_from_servant (servant); - GIOChannel *gio; - - g_return_val_if_fail (streamable != NULL, NULL); - - gio = atk_streamable_content_get_stream (streamable, content_type); - - stream = spi_content_stream_new (gio); - - return bonobo_object_dup_ref (BONOBO_OBJREF (stream), ev); -} - -/* - * CORBA Accessibility::StreamableContent::getURI method implementation - */ -static CORBA_string -impl_accessibility_streamable_get_uri (PortableServer_Servant servant, - const CORBA_char * content_type, - CORBA_Environment *ev) -{ - gchar *uri; - AtkStreamableContent *streamable = get_streamable_from_servant (servant); - - g_return_val_if_fail (streamable != NULL, NULL); - - uri = atk_streamable_content_get_uri (streamable, content_type); - - return (uri != NULL ? CORBA_string_dup (uri) : CORBA_string_dup ("")); -} - -static void -spi_streamable_class_init (SpiStreamableClass *klass) -{ - POA_Accessibility_StreamableContent__epv *epv = &klass->epv; - spi_streamable_parent_class = g_type_class_peek_parent (klass); - - epv->getContentTypes = impl_accessibility_streamable_get_content_types; - epv->getContent = impl_accessibility_streamable_get_content; - epv->getStream = impl_accessibility_streamable_get_stream; - epv->getURI = impl_accessibility_streamable_get_uri; -} - -static void -spi_streamable_init (SpiStreamable *streamable) -{ -} - - -SpiStreamable * -spi_streamable_interface_new (AtkObject *o) -{ - SpiStreamable *retval = g_object_new (SPI_STREAMABLE_TYPE, NULL); - - spi_base_construct (SPI_BASE (retval), G_OBJECT(o)); - - return retval; -} - -BONOBO_TYPE_FUNC_FULL (SpiStreamable, - Accessibility_StreamableContent, - PARENT_TYPE, - spi_streamable) diff --git a/atk-adaptor/table-adaptor.c b/atk-adaptor/table-adaptor.c new file mode 100644 index 0000000..cc8cfbe --- /dev/null +++ b/atk-adaptor/table-adaptor.c @@ -0,0 +1,692 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2008 Novell, Inc. + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include + +#include "accessible-marshaller.h" +#include "spi-common/spi-dbus.h" + +static dbus_bool_t +impl_get_nRows (DBusMessageIter * iter, void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE); + return droute_return_v_int32 (iter, atk_table_get_n_rows (table)); +} + +static dbus_bool_t +impl_get_nColumns (DBusMessageIter * iter, void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE); + return droute_return_v_int32 (iter, atk_table_get_n_columns (table)); +} + +static dbus_bool_t +impl_get_caption (DBusMessageIter * iter, void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE); + return spi_dbus_return_v_object (iter, atk_table_get_caption (table), + FALSE); +} + +static dbus_bool_t +impl_get_summary (DBusMessageIter * iter, void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE); + return spi_dbus_return_v_object (iter, atk_table_get_summary (table), + FALSE); +} + +static dbus_bool_t +impl_get_nSelectedRows (DBusMessageIter * iter, + void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + gint *selected_rows = NULL; + int count; + g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE); + count = atk_table_get_selected_rows (table, &selected_rows); + if (selected_rows) + g_free (selected_rows); + return droute_return_v_int32 (iter, count); +} + +static dbus_bool_t +impl_get_nSelectedColumns (DBusMessageIter * iter, + void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + gint *selected_columns = NULL; + int count; + g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE); + count = atk_table_get_selected_columns (table, &selected_columns); + if (selected_columns) + g_free (selected_columns); + return droute_return_v_int32 (iter, count); +} + +static DBusMessage * +impl_getAccessibleAt (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + dbus_int32_t row, column; + DBusError error; + AtkObject *obj; + + g_return_val_if_fail (ATK_IS_TABLE (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column, + DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + obj = atk_table_ref_at (table, row, column); + return spi_dbus_return_object (message, obj, TRUE); +} + +static DBusMessage * +impl_getIndexAt (DBusConnection * bus, DBusMessage * message, void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + dbus_int32_t row, column; + dbus_int32_t index; + DBusError error; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TABLE (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column, + DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + index = atk_table_get_index_at (table, row, column); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &index, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getRowAtIndex (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + dbus_int32_t index; + dbus_int32_t row; + DBusError error; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TABLE (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + row = atk_table_get_row_at_index (table, index); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &row, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getColumnAtIndex (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + dbus_int32_t index; + dbus_int32_t column; + DBusError error; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TABLE (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + column = atk_table_get_column_at_index (table, index); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &column, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getRowDescription (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + dbus_int32_t row; + AtkTable *table = (AtkTable *) user_data; + const gchar *description; + DBusError error; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TABLE (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + description = atk_table_get_row_description (table, row); + if (!description) + description = ""; + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_STRING, &description, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getColumnDescription (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + dbus_int32_t column; + const char *description; + DBusError error; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TABLE (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + description = atk_table_get_column_description (table, column); + if (!description) + description = ""; + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_STRING, &description, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getRowExtentAt (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + dbus_int32_t row, column; + dbus_int32_t extent; + DBusError error; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TABLE (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column, + DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + extent = atk_table_get_row_extent_at (table, row, column); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &extent, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getColumnExtentAt (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + dbus_int32_t row, column; + dbus_int32_t extent; + DBusError error; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TABLE (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column, + DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + extent = atk_table_get_column_extent_at (table, row, column); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &extent, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getRowHeader (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + dbus_int32_t row; + DBusError error; + AtkObject *obj; + + g_return_val_if_fail (ATK_IS_TABLE (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + obj = atk_table_get_row_header (table, row); + return spi_dbus_return_object (message, obj, FALSE); +} + +static DBusMessage * +impl_getColumnHeader (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + dbus_int32_t column; + DBusError error; + AtkObject *obj; + + g_return_val_if_fail (ATK_IS_TABLE (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + obj = atk_table_get_column_header (table, column); + return spi_dbus_return_object (message, obj, FALSE); +} + +static DBusMessage * +impl_getSelectedRows (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + gint *selected_rows = NULL; + gint count; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TABLE (user_data), + droute_not_yet_handled_error (message)); + count = atk_table_get_selected_rows (table, &selected_rows); + if (!selected_rows) + count = 0; + reply = dbus_message_new_method_return (message); + if (reply) + { + /* tbd - figure out if this is safe for a 0-length array */ + dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, + &selected_rows, count, DBUS_TYPE_INVALID); + } + if (selected_rows) + g_free (selected_rows); + return reply; +} + +static DBusMessage * +impl_getSelectedColumns (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + gint *selected_columns = NULL; + gint count; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TABLE (user_data), + droute_not_yet_handled_error (message)); + count = atk_table_get_selected_columns (table, &selected_columns); + if (!selected_columns) + count = 0; + reply = dbus_message_new_method_return (message); + if (reply) + { + /* tbd - figure out if this is safe for a 0-length array */ + dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, + &selected_columns, count, DBUS_TYPE_INVALID); + } + if (selected_columns) + g_free (selected_columns); + return reply; +} + +static DBusMessage * +impl_isRowSelected (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + dbus_int32_t row; + DBusError error; + DBusMessage *reply; + dbus_bool_t ret; + + g_return_val_if_fail (ATK_IS_TABLE (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + ret = atk_table_is_row_selected (table, row); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_isColumnSelected (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + dbus_int32_t column; + DBusError error; + DBusMessage *reply; + dbus_bool_t ret; + + g_return_val_if_fail (ATK_IS_TABLE (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + ret = atk_table_is_column_selected (table, column); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_isSelected (DBusConnection * bus, DBusMessage * message, void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + dbus_int32_t row, column; + DBusError error; + DBusMessage *reply; + dbus_bool_t ret; + + g_return_val_if_fail (ATK_IS_TABLE (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column, + DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + ret = atk_table_is_selected (table, row, column); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_addRowSelection (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + dbus_int32_t row; + DBusError error; + DBusMessage *reply; + dbus_bool_t ret; + + g_return_val_if_fail (ATK_IS_TABLE (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + ret = atk_table_add_row_selection (table, row); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_addColumnSelection (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + dbus_int32_t column; + DBusError error; + DBusMessage *reply; + dbus_bool_t ret; + + g_return_val_if_fail (ATK_IS_TABLE (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + ret = atk_table_add_column_selection (table, column); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_removeRowSelection (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + dbus_int32_t row; + DBusError error; + DBusMessage *reply; + dbus_bool_t ret; + + g_return_val_if_fail (ATK_IS_TABLE (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + ret = atk_table_remove_row_selection (table, row); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_removeColumnSelection (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + dbus_int32_t column; + DBusError error; + DBusMessage *reply; + dbus_bool_t ret; + + g_return_val_if_fail (ATK_IS_TABLE (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + ret = atk_table_remove_column_selection (table, column); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getRowColumnExtentsAtIndex (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkTable *table = (AtkTable *) user_data; + dbus_int32_t index; + DBusError error; + dbus_int32_t row, column, row_extents, col_extents; + dbus_bool_t is_selected; + dbus_bool_t ret; + DBusMessage *reply; + + AtkObject *cell; + AtkRole role; + + g_return_val_if_fail (ATK_IS_TABLE (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + column = atk_table_get_column_at_index (table, index); + row = atk_table_get_row_at_index (table, index); + row_extents = atk_table_get_row_extent_at (table, row, column); + col_extents = atk_table_get_column_extent_at (table, row, column); + is_selected = atk_table_is_selected (table, row, column); + cell = atk_table_ref_at (table, row, column); + role = atk_object_get_role (cell); + g_object_unref (cell); + ret = (role == ATK_ROLE_TABLE_CELL ? TRUE : FALSE); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, row, DBUS_TYPE_INT32, + column, DBUS_TYPE_INT32, row_extents, + DBUS_TYPE_INT32, col_extents, + DBUS_TYPE_BOOLEAN, is_selected, + DBUS_TYPE_BOOLEAN, &ret, DBUS_TYPE_INVALID); + } + return reply; +} + +static DRouteMethod methods[] = { + {impl_getAccessibleAt, "getAccessibleAt"}, + {impl_getIndexAt, "getIndexAt"}, + {impl_getRowAtIndex, "getRowAtIndex"}, + {impl_getColumnAtIndex, "getColumnAtIndex"}, + {impl_getRowDescription, "getRowDescription"}, + {impl_getColumnDescription, "getColumnDescription"}, + {impl_getRowExtentAt, "getRowExtentAt"}, + {impl_getColumnExtentAt, "getColumnExtentAt"}, + {impl_getRowHeader, "getRowHeader"}, + {impl_getColumnHeader, "getColumnHeader"}, + {impl_getSelectedRows, "getSelectedRows"}, + {impl_getSelectedColumns, "getSelectedColumns"}, + {impl_isRowSelected, "isRowSelected"}, + {impl_isColumnSelected, "isColumnSelected"}, + {impl_isSelected, "isSelected"}, + {impl_addRowSelection, "addRowSelection"}, + {impl_addColumnSelection, "addColumnSelection"}, + {impl_removeRowSelection, "removeRowSelection"}, + {impl_removeColumnSelection, "removeColumnSelection"}, + {impl_getRowColumnExtentsAtIndex, "getRowColumnExtentsAtIndex"}, + {NULL, NULL} +}; + +static DRouteProperty properties[] = { + {impl_get_nRows, NULL, "nRows"}, + {impl_get_nColumns, NULL, "nColumns"}, + {impl_get_caption, NULL, "caption"}, + {impl_get_summary, NULL, "summary"}, + {impl_get_nSelectedRows, NULL, "nSelectedRows"}, + {impl_get_nSelectedColumns, NULL, "nSelectedColumns"}, + {NULL, NULL, NULL} +}; + +void +spi_initialize_table (DRoutePath *path) +{ + droute_path_add_interface (path, + SPI_DBUS_INTERFACE_TABLE, + methods, + properties); +}; diff --git a/atk-adaptor/table.c b/atk-adaptor/table.c deleted file mode 100644 index c0c6b0f..0000000 --- a/atk-adaptor/table.c +++ /dev/null @@ -1,692 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) - * - * Copyright 2008 Novell, Inc. - * Copyright 2001, 2002 Sun Microsystems Inc., - * Copyright 2001, 2002 Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include - -#include "atk-dbus.h" -#include "spi-common/spi-dbus.h" - -static dbus_bool_t -impl_get_nRows (DBusMessageIter * iter, void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE); - return droute_return_v_int32 (iter, atk_table_get_n_rows (table)); -} - -static dbus_bool_t -impl_get_nColumns (DBusMessageIter * iter, void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE); - return droute_return_v_int32 (iter, atk_table_get_n_columns (table)); -} - -static dbus_bool_t -impl_get_caption (DBusMessageIter * iter, void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE); - return spi_dbus_return_v_object (iter, atk_table_get_caption (table), - FALSE); -} - -static dbus_bool_t -impl_get_summary (DBusMessageIter * iter, void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE); - return spi_dbus_return_v_object (iter, atk_table_get_summary (table), - FALSE); -} - -static dbus_bool_t -impl_get_nSelectedRows (DBusMessageIter * iter, - void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - gint *selected_rows = NULL; - int count; - g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE); - count = atk_table_get_selected_rows (table, &selected_rows); - if (selected_rows) - g_free (selected_rows); - return droute_return_v_int32 (iter, count); -} - -static dbus_bool_t -impl_get_nSelectedColumns (DBusMessageIter * iter, - void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - gint *selected_columns = NULL; - int count; - g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE); - count = atk_table_get_selected_columns (table, &selected_columns); - if (selected_columns) - g_free (selected_columns); - return droute_return_v_int32 (iter, count); -} - -static DBusMessage * -impl_getAccessibleAt (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - dbus_int32_t row, column; - DBusError error; - AtkObject *obj; - - g_return_val_if_fail (ATK_IS_TABLE (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column, - DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - obj = atk_table_ref_at (table, row, column); - return spi_dbus_return_object (message, obj, TRUE); -} - -static DBusMessage * -impl_getIndexAt (DBusConnection * bus, DBusMessage * message, void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - dbus_int32_t row, column; - dbus_int32_t index; - DBusError error; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_TABLE (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column, - DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - index = atk_table_get_index_at (table, row, column); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT32, &index, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getRowAtIndex (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - dbus_int32_t index; - dbus_int32_t row; - DBusError error; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_TABLE (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - row = atk_table_get_row_at_index (table, index); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT32, &row, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getColumnAtIndex (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - dbus_int32_t index; - dbus_int32_t column; - DBusError error; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_TABLE (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - column = atk_table_get_column_at_index (table, index); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT32, &column, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getRowDescription (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - dbus_int32_t row; - AtkTable *table = (AtkTable *) user_data; - const gchar *description; - DBusError error; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_TABLE (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - description = atk_table_get_row_description (table, row); - if (!description) - description = ""; - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_STRING, &description, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getColumnDescription (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - dbus_int32_t column; - const char *description; - DBusError error; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_TABLE (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - description = atk_table_get_column_description (table, column); - if (!description) - description = ""; - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_STRING, &description, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getRowExtentAt (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - dbus_int32_t row, column; - dbus_int32_t extent; - DBusError error; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_TABLE (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column, - DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - extent = atk_table_get_row_extent_at (table, row, column); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT32, &extent, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getColumnExtentAt (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - dbus_int32_t row, column; - dbus_int32_t extent; - DBusError error; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_TABLE (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column, - DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - extent = atk_table_get_column_extent_at (table, row, column); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT32, &extent, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getRowHeader (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - dbus_int32_t row; - DBusError error; - AtkObject *obj; - - g_return_val_if_fail (ATK_IS_TABLE (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - obj = atk_table_get_row_header (table, row); - return spi_dbus_return_object (message, obj, FALSE); -} - -static DBusMessage * -impl_getColumnHeader (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - dbus_int32_t column; - DBusError error; - AtkObject *obj; - - g_return_val_if_fail (ATK_IS_TABLE (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - obj = atk_table_get_column_header (table, column); - return spi_dbus_return_object (message, obj, FALSE); -} - -static DBusMessage * -impl_getSelectedRows (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - gint *selected_rows = NULL; - gint count; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_TABLE (user_data), - droute_not_yet_handled_error (message)); - count = atk_table_get_selected_rows (table, &selected_rows); - if (!selected_rows) - count = 0; - reply = dbus_message_new_method_return (message); - if (reply) - { - /* tbd - figure out if this is safe for a 0-length array */ - dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, - &selected_rows, count, DBUS_TYPE_INVALID); - } - if (selected_rows) - g_free (selected_rows); - return reply; -} - -static DBusMessage * -impl_getSelectedColumns (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - gint *selected_columns = NULL; - gint count; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_TABLE (user_data), - droute_not_yet_handled_error (message)); - count = atk_table_get_selected_columns (table, &selected_columns); - if (!selected_columns) - count = 0; - reply = dbus_message_new_method_return (message); - if (reply) - { - /* tbd - figure out if this is safe for a 0-length array */ - dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, - &selected_columns, count, DBUS_TYPE_INVALID); - } - if (selected_columns) - g_free (selected_columns); - return reply; -} - -static DBusMessage * -impl_isRowSelected (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - dbus_int32_t row; - DBusError error; - DBusMessage *reply; - dbus_bool_t ret; - - g_return_val_if_fail (ATK_IS_TABLE (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - ret = atk_table_is_row_selected (table, row); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_isColumnSelected (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - dbus_int32_t column; - DBusError error; - DBusMessage *reply; - dbus_bool_t ret; - - g_return_val_if_fail (ATK_IS_TABLE (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - ret = atk_table_is_column_selected (table, column); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_isSelected (DBusConnection * bus, DBusMessage * message, void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - dbus_int32_t row, column; - DBusError error; - DBusMessage *reply; - dbus_bool_t ret; - - g_return_val_if_fail (ATK_IS_TABLE (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column, - DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - ret = atk_table_is_selected (table, row, column); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_addRowSelection (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - dbus_int32_t row; - DBusError error; - DBusMessage *reply; - dbus_bool_t ret; - - g_return_val_if_fail (ATK_IS_TABLE (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - ret = atk_table_add_row_selection (table, row); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_addColumnSelection (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - dbus_int32_t column; - DBusError error; - DBusMessage *reply; - dbus_bool_t ret; - - g_return_val_if_fail (ATK_IS_TABLE (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - ret = atk_table_add_column_selection (table, column); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_removeRowSelection (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - dbus_int32_t row; - DBusError error; - DBusMessage *reply; - dbus_bool_t ret; - - g_return_val_if_fail (ATK_IS_TABLE (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - ret = atk_table_remove_row_selection (table, row); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_removeColumnSelection (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - dbus_int32_t column; - DBusError error; - DBusMessage *reply; - dbus_bool_t ret; - - g_return_val_if_fail (ATK_IS_TABLE (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - ret = atk_table_remove_column_selection (table, column); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getRowColumnExtentsAtIndex (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkTable *table = (AtkTable *) user_data; - dbus_int32_t index; - DBusError error; - dbus_int32_t row, column, row_extents, col_extents; - dbus_bool_t is_selected; - dbus_bool_t ret; - DBusMessage *reply; - - AtkObject *cell; - AtkRole role; - - g_return_val_if_fail (ATK_IS_TABLE (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - column = atk_table_get_column_at_index (table, index); - row = atk_table_get_row_at_index (table, index); - row_extents = atk_table_get_row_extent_at (table, row, column); - col_extents = atk_table_get_column_extent_at (table, row, column); - is_selected = atk_table_is_selected (table, row, column); - cell = atk_table_ref_at (table, row, column); - role = atk_object_get_role (cell); - g_object_unref (cell); - ret = (role == ATK_ROLE_TABLE_CELL ? TRUE : FALSE); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT32, row, DBUS_TYPE_INT32, - column, DBUS_TYPE_INT32, row_extents, - DBUS_TYPE_INT32, col_extents, - DBUS_TYPE_BOOLEAN, is_selected, - DBUS_TYPE_BOOLEAN, &ret, DBUS_TYPE_INVALID); - } - return reply; -} - -static DRouteMethod methods[] = { - {impl_getAccessibleAt, "getAccessibleAt"}, - {impl_getIndexAt, "getIndexAt"}, - {impl_getRowAtIndex, "getRowAtIndex"}, - {impl_getColumnAtIndex, "getColumnAtIndex"}, - {impl_getRowDescription, "getRowDescription"}, - {impl_getColumnDescription, "getColumnDescription"}, - {impl_getRowExtentAt, "getRowExtentAt"}, - {impl_getColumnExtentAt, "getColumnExtentAt"}, - {impl_getRowHeader, "getRowHeader"}, - {impl_getColumnHeader, "getColumnHeader"}, - {impl_getSelectedRows, "getSelectedRows"}, - {impl_getSelectedColumns, "getSelectedColumns"}, - {impl_isRowSelected, "isRowSelected"}, - {impl_isColumnSelected, "isColumnSelected"}, - {impl_isSelected, "isSelected"}, - {impl_addRowSelection, "addRowSelection"}, - {impl_addColumnSelection, "addColumnSelection"}, - {impl_removeRowSelection, "removeRowSelection"}, - {impl_removeColumnSelection, "removeColumnSelection"}, - {impl_getRowColumnExtentsAtIndex, "getRowColumnExtentsAtIndex"}, - {NULL, NULL} -}; - -static DRouteProperty properties[] = { - {impl_get_nRows, NULL, "nRows"}, - {impl_get_nColumns, NULL, "nColumns"}, - {impl_get_caption, NULL, "caption"}, - {impl_get_summary, NULL, "summary"}, - {impl_get_nSelectedRows, NULL, "nSelectedRows"}, - {impl_get_nSelectedColumns, NULL, "nSelectedColumns"}, - {NULL, NULL, NULL} -}; - -void -spi_initialize_table (DRoutePath *path) -{ - droute_path_add_interface (path, - SPI_DBUS_INTERFACE_TABLE, - methods, - properties); -}; diff --git a/atk-adaptor/text-adaptor.c b/atk-adaptor/text-adaptor.c new file mode 100644 index 0000000..7c88211 --- /dev/null +++ b/atk-adaptor/text-adaptor.c @@ -0,0 +1,881 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2008 Novell, Inc. + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include + +#include +#include + +#include "spi-common/spi-dbus.h" + +static dbus_bool_t +impl_get_characterCount (DBusMessageIter * iter, + void *user_data) +{ + AtkText *text = (AtkText *) user_data; + g_return_val_if_fail (ATK_IS_TEXT (user_data), FALSE); + return droute_return_v_int32 (iter, atk_text_get_character_count (text)); +} + +static dbus_bool_t +impl_get_caretOffset (DBusMessageIter * iter, + void *user_data) +{ + AtkText *text = (AtkText *) user_data; + g_return_val_if_fail (ATK_IS_TEXT (user_data), FALSE); + return droute_return_v_int32 (iter, atk_text_get_caret_offset (text)); +} + +static DBusMessage * +impl_getText (DBusConnection * bus, DBusMessage * message, void *user_data) +{ + AtkText *text = (AtkText *) user_data; + dbus_int32_t startOffset, endOffset; + gchar *txt; + DBusError error; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &startOffset, DBUS_TYPE_INT32, + &endOffset, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + txt = atk_text_get_text (text, startOffset, endOffset); + if (!txt) + txt = g_strdup (""); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_STRING, &txt, + DBUS_TYPE_INVALID); + } + g_free (txt); + return reply; +} + +static DBusMessage * +impl_setCaretOffset (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkText *text = (AtkText *) user_data; + dbus_int32_t offset; + dbus_bool_t rv; + DBusError error; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + rv = atk_text_set_caret_offset (text, offset); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getTextBeforeOffset (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkText *text = (AtkText *) user_data; + dbus_int32_t offset; + dbus_uint32_t type; + gchar *txt; + dbus_int32_t startOffset, endOffset; + gint intstart_offset = 0, intend_offset = 0; + DBusError error; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_UINT32, &type, + DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + txt = + atk_text_get_text_before_offset (text, offset, (AtkTextBoundary) type, + &intstart_offset, &intend_offset); + startOffset = intstart_offset; + endOffset = intend_offset; + if (!txt) + txt = g_strdup (""); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &startOffset, + DBUS_TYPE_INT32, &endOffset, DBUS_TYPE_STRING, + &txt, DBUS_TYPE_INVALID); + } + g_free (txt); + return reply; +} + +static DBusMessage * +impl_getTextAtOffset (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkText *text = (AtkText *) user_data; + dbus_int32_t offset, type; + gchar *txt; + dbus_int32_t startOffset, endOffset; + gint intstart_offset = 0, intend_offset = 0; + DBusError error; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_UINT32, &type, + DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + txt = + atk_text_get_text_at_offset (text, offset, (AtkTextBoundary) type, + &intstart_offset, &intend_offset); + startOffset = intstart_offset; + endOffset = intend_offset; + if (!txt) + txt = g_strdup (""); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &startOffset, + DBUS_TYPE_INT32, &endOffset, DBUS_TYPE_STRING, + &txt, DBUS_TYPE_INVALID); + } + g_free (txt); + return reply; +} + +static DBusMessage * +impl_getTextAfterOffset (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkText *text = (AtkText *) user_data; + dbus_int32_t offset; + dbus_uint32_t type; + gchar *txt; + dbus_int32_t startOffset, endOffset; + gint intstart_offset = 0, intend_offset = 0; + DBusError error; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_UINT32, &type, + DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + txt = + atk_text_get_text_after_offset (text, offset, (AtkTextBoundary) type, + &intstart_offset, &intend_offset); + startOffset = intstart_offset; + endOffset = intend_offset; + if (!txt) + txt = g_strdup (""); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &startOffset, + DBUS_TYPE_INT32, &endOffset, DBUS_TYPE_STRING, + &txt, DBUS_TYPE_INVALID); + } + g_free (txt); + return reply; +} + +static DBusMessage * +impl_getCharacterAtOffset (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkText *text = (AtkText *) user_data; + dbus_int32_t offset; + dbus_int32_t ch; + DBusError error; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + ch = atk_text_get_character_at_offset (text, offset); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &ch, DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getAttributeValue (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkText *text = (AtkText *) user_data; + dbus_int32_t offset; + char *attributeName; + dbus_int32_t startOffset, endOffset; + dbus_bool_t defined; + gint intstart_offset = 0, intend_offset = 0; + char *rv; + DBusError error; + DBusMessage *reply; + AtkAttributeSet *set; + GSList *cur_attr; + AtkAttribute *at; + + g_return_val_if_fail (ATK_IS_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_STRING, + &attributeName, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + + set = atk_text_get_run_attributes (text, offset, + &intstart_offset, &intend_offset); + startOffset = intstart_offset; + endOffset = intend_offset; + defined = FALSE; + cur_attr = (GSList *) set; + while (cur_attr) + { + at = (AtkAttribute *) cur_attr->data; + if (!strcmp (at->name, attributeName)) + { + rv = at->value; + defined = TRUE; + break; + } + cur_attr = cur_attr->next; + } + if (!rv) + rv = ""; + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &startOffset, + DBUS_TYPE_INT32, &endOffset, + DBUS_TYPE_BOOLEAN, &defined, DBUS_TYPE_STRING, + &rv, DBUS_TYPE_INVALID); + } + atk_attribute_set_free (set); + return reply; +} + +static char * +_string_from_attribute_set (AtkAttributeSet * set) +{ + gchar *attributes, *tmp, *tmp2; + GSList *cur_attr; + AtkAttribute *at; + + attributes = g_strdup (""); + cur_attr = (GSList *) set; + while (cur_attr) + { + at = (AtkAttribute *) cur_attr->data; + tmp = g_strdup_printf ("%s%s:%s%s", + ((GSList *) (set) == cur_attr) ? "" : " ", + at->name, at->value, + (cur_attr->next) ? ";" : ""); + tmp2 = g_strconcat (attributes, tmp, NULL); + g_free (tmp); + g_free (attributes); + attributes = tmp2; + cur_attr = cur_attr->next; + } + return attributes; +} + +static DBusMessage * +impl_getAttributes (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkText *text = (AtkText *) user_data; + dbus_int32_t offset; + dbus_int32_t startOffset, endOffset; + gint intstart_offset, intend_offset; + char *rv; + DBusError error; + DBusMessage *reply; + AtkAttributeSet *set; + + g_return_val_if_fail (ATK_IS_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + + set = atk_text_get_run_attributes (text, offset, + &intstart_offset, &intend_offset); + + rv = _string_from_attribute_set (set); + + startOffset = intstart_offset; + endOffset = intend_offset; + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_STRING, &rv, DBUS_TYPE_INT32, &startOffset, + DBUS_TYPE_INT32, &endOffset, DBUS_TYPE_INVALID); + } + atk_attribute_set_free (set); + g_free(rv); + return reply; +} + +static DBusMessage * +impl_getDefaultAttributes (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkText *text = (AtkText *) user_data; + char *rv; + DBusError error; + DBusMessage *reply; + AtkAttributeSet *set; + + g_return_val_if_fail (ATK_IS_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + + set = atk_text_get_default_attributes (text); + rv = _string_from_attribute_set (set); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_STRING, &rv, + DBUS_TYPE_INVALID); + } + g_free (rv); + atk_attribute_set_free (set); + return reply; +} + +static DBusMessage * +impl_getCharacterExtents (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkText *text = (AtkText *) user_data; + dbus_int32_t offset; + dbus_int16_t coordType; + dbus_int32_t x, y, width, height; + gint ix = 0, iy = 0, iw = 0, ih = 0; + DBusError error; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_INT16, &coordType, + DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + atk_text_get_character_extents (text, offset, &ix, &iy, &iw, &ih, + (AtkCoordType) coordType); + x = ix; + y = iy; + width = iw; + height = ih; + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, + &y, DBUS_TYPE_INT32, &width, DBUS_TYPE_INT32, + &height, DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getOffsetAtPoint (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkText *text = (AtkText *) user_data; + dbus_int32_t x, y; + dbus_int16_t coordType; + dbus_int32_t rv; + DBusError error; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y, + DBUS_TYPE_INT16, &coordType, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + rv = atk_text_get_offset_at_point (text, x, y, coordType); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getNSelections (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkText *text = (AtkText *) user_data; + dbus_int32_t rv; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TEXT (user_data), + droute_not_yet_handled_error (message)); + rv = atk_text_get_n_selections (text); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getSelection (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkText *text = (AtkText *) user_data; + dbus_int32_t selectionNum; + dbus_int32_t startOffset, endOffset; + gint intstart_offset = 0, intend_offset = 0; + DBusError error; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &selectionNum, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + /* atk_text_get_selection returns gchar * which we discard */ + g_free (atk_text_get_selection + (text, selectionNum, &intstart_offset, &intend_offset)); + startOffset = intstart_offset; + endOffset = intend_offset; + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &startOffset, + DBUS_TYPE_INT32, &endOffset, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_addSelection (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkText *text = (AtkText *) user_data; + dbus_int32_t startOffset, endOffset; + dbus_bool_t rv; + DBusError error; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &startOffset, DBUS_TYPE_INT32, + &endOffset, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + rv = atk_text_add_selection (text, startOffset, endOffset); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_removeSelection (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkText *text = (AtkText *) user_data; + dbus_int32_t selectionNum; + dbus_bool_t rv; + DBusError error; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &selectionNum, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + rv = atk_text_remove_selection (text, selectionNum); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_setSelection (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkText *text = (AtkText *) user_data; + dbus_int32_t selectionNum, startOffset, endOffset; + dbus_bool_t rv; + DBusError error; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &selectionNum, DBUS_TYPE_INT32, + &startOffset, DBUS_TYPE_INT32, &endOffset, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + rv = atk_text_set_selection (text, selectionNum, startOffset, endOffset); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, + DBUS_TYPE_INVALID); + } + return reply; +} + +static DBusMessage * +impl_getRangeExtents (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkText *text = (AtkText *) user_data; + dbus_int32_t startOffset, endOffset; + dbus_int16_t coordType; + AtkTextRectangle rect; + dbus_int32_t x, y, width, height; + DBusError error; + DBusMessage *reply; + + g_return_val_if_fail (ATK_IS_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &startOffset, DBUS_TYPE_INT32, + &endOffset, DBUS_TYPE_INT16, &coordType, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + memset (&rect, 0, sizeof (rect)); + atk_text_get_range_extents (text, startOffset, endOffset, + (AtkCoordType) coordType, &rect); + x = rect.x; + y = rect.y; + width = rect.width; + height = rect.height; + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, + &y, DBUS_TYPE_INT32, &width, DBUS_TYPE_INT32, + &height, DBUS_TYPE_INVALID); + } + return reply; +} + +#define MAXRANGELEN 512 + +static DBusMessage * +impl_getBoundedRanges (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkText *text = (AtkText *) user_data; + dbus_int32_t x, y, width, height; + dbus_int16_t coordType, xClipType, yClipType; + DBusError error; + AtkTextRange **range_list = NULL; + AtkTextRectangle rect; + DBusMessage *reply; + DBusMessageIter iter, array, struc, variant; + + g_return_val_if_fail (ATK_IS_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y, + DBUS_TYPE_INT32, &height, DBUS_TYPE_INT32, &width, DBUS_TYPE_INT32, + &coordType, DBUS_TYPE_INT32, &xClipType, DBUS_TYPE_INT32, &yClipType, + DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + rect.x = x; + rect.y = y; + rect.width = width; + rect.height = height; + + range_list = + atk_text_get_bounded_ranges (text, &rect, (AtkCoordType) coordType, + (AtkTextClipType) xClipType, + (AtkTextClipType) yClipType); + reply = dbus_message_new_method_return (message); + if (!reply) + return NULL; + /* This isn't pleasant. */ + dbus_message_iter_init_append (reply, &iter); + if (dbus_message_iter_open_container + (&iter, DBUS_TYPE_ARRAY, "(iisv)", &array)) + { + int len; + for (len = 0; len < MAXRANGELEN && range_list[len]; ++len) + { + if (dbus_message_iter_open_container + (&array, DBUS_TYPE_STRUCT, NULL, &struc)) + { + dbus_int32_t val; + val = range_list[len]->start_offset; + dbus_message_iter_append_basic (&struc, DBUS_TYPE_INT32, &val); + val = range_list[len]->end_offset; + dbus_message_iter_append_basic (&struc, DBUS_TYPE_INT32, &val); + dbus_message_iter_append_basic (&struc, DBUS_TYPE_STRING, + &range_list[len]->content); + /* The variant is unimplemented in atk, but I don't want to + * unilaterally muck with the spec and remove it, so I'll just + * throw in a dummy value */ + if (dbus_message_iter_open_container + (&array, DBUS_TYPE_VARIANT, "i", &variant)) + { + dbus_uint32_t dummy = 0; + dbus_message_iter_append_basic (&variant, DBUS_TYPE_INT32, + &dummy); + dbus_message_iter_close_container (&struc, &variant); + } + dbus_message_iter_close_container (&array, &struc); + } + } + dbus_message_iter_close_container (&iter, &array); + } + return reply; +} + +static DBusMessage * +impl_getAttributeRun (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + DBusError error; + AtkText *text = (AtkText *) user_data; + dbus_int32_t offset; + dbus_bool_t includeDefaults; + dbus_int32_t startOffset, endOffset; + gint intstart_offset = 0, intend_offset = 0; + DBusMessage *reply; + AtkAttributeSet *attributes, *default_attributes = NULL; + AtkAttribute *attr = NULL; + char **retval; + gint n_attributes = 0, total_attributes = 0, n_default_attributes = 0; + gint i, j; + + g_return_val_if_fail (ATK_IS_TEXT (user_data), + droute_not_yet_handled_error (message)); + dbus_error_init (&error); + if (!dbus_message_get_args + (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_BOOLEAN, + &includeDefaults, DBUS_TYPE_INVALID)) + { + return SPI_DBUS_RETURN_ERROR (message, &error); + } + + attributes = + atk_text_get_run_attributes (text, offset, &intstart_offset, + &intend_offset); + + if (attributes) + total_attributes = n_attributes = g_slist_length (attributes); + + if (includeDefaults) + { + default_attributes = atk_text_get_default_attributes (text); + if (default_attributes) + n_default_attributes = g_slist_length (default_attributes); + total_attributes += n_default_attributes; + } + + startOffset = intstart_offset; + endOffset = intend_offset; + + retval = (char **) g_malloc (total_attributes * sizeof (char *)); + + if (total_attributes) + { + for (i = 0; i < n_attributes; ++i) + { + attr = g_slist_nth_data (attributes, i); + retval[i] = g_strconcat (attr->name, ":", attr->value, NULL); + } + + for (j = 0; j < n_default_attributes; ++i, ++j) + { + attr = g_slist_nth_data (default_attributes, j); + retval[i] = g_strconcat (attr->name, ":", attr->value, NULL); + } + + atk_attribute_set_free (attributes); + if (default_attributes) + atk_attribute_set_free (default_attributes); + } + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_INT32, &startOffset, + DBUS_TYPE_INT32, &endOffset, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING, &retval, total_attributes, + DBUS_TYPE_INVALID); + } + for (i = 0; i < total_attributes; i++) + g_free (retval[i]); + g_free (retval); + return reply; +} + +static DBusMessage * +impl_getDefaultAttributeSet (DBusConnection * bus, DBusMessage * message, + void *user_data) +{ + AtkText *text = (AtkText *) user_data; + DBusMessage *reply; + AtkAttributeSet *attributes; + AtkAttribute *attr = NULL; + char **retval; + gint n_attributes = 0; + gint i; + + g_return_val_if_fail (ATK_IS_TEXT (user_data), + droute_not_yet_handled_error (message)); + + attributes = atk_text_get_default_attributes (text); + if (attributes) + n_attributes = g_slist_length (attributes); + + retval = g_new (char *, n_attributes); + + for (i = 0; i < n_attributes; ++i) + { + attr = g_slist_nth_data (attributes, i); + retval[i] = g_strconcat (attr->name, ":", attr->value, NULL); + } + if (attributes) + atk_attribute_set_free (attributes); + reply = dbus_message_new_method_return (message); + if (reply) + { + dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, + &retval, n_attributes, DBUS_TYPE_INVALID); + } + for (i = 0; i < n_attributes; i++) + g_free (retval[i]); + g_free (retval); + return reply; +} + +static DRouteMethod methods[] = { + {impl_getText, "getText"}, + {impl_setCaretOffset, "setCaretOffset"}, + {impl_getTextBeforeOffset, "getTextBeforeOffset"}, + {impl_getTextAtOffset, "getTextAtOffset"}, + {impl_getTextAfterOffset, "getTextAfterOffset"}, + {impl_getCharacterAtOffset, "getCharacterAtOffset"}, + {impl_getAttributeValue, "getAttributeValue"}, + {impl_getAttributes, "getAttributes"}, + {impl_getDefaultAttributes, "getDefaultAttributes"}, + {impl_getCharacterExtents, "getCharacterExtents"}, + {impl_getOffsetAtPoint, "getOffsetAtPoint"}, + {impl_getNSelections, "getNSelections"}, + {impl_getSelection, "getSelection"}, + {impl_addSelection, "addSelection"}, + {impl_removeSelection, "removeSelection"}, + {impl_setSelection, "setSelection"}, + {impl_getRangeExtents, "getRangeExtents"}, + {impl_getBoundedRanges, "getBoundedRanges"}, + {impl_getAttributeRun, "getAttributeRun"}, + {impl_getDefaultAttributeSet, "getDefaultAttributeSet"}, + {NULL, NULL} +}; + +static DRouteProperty properties[] = { + {impl_get_characterCount, NULL, "characterCount"}, + {impl_get_caretOffset, NULL, "caretOffset"}, + {NULL, NULL, NULL} +}; + +void +spi_initialize_text (DRoutePath *path) +{ + droute_path_add_interface (path, + SPI_DBUS_INTERFACE_TEXT, + methods, + properties); +}; diff --git a/atk-adaptor/text.c b/atk-adaptor/text.c deleted file mode 100644 index 7c88211..0000000 --- a/atk-adaptor/text.c +++ /dev/null @@ -1,881 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) - * - * Copyright 2008 Novell, Inc. - * Copyright 2001, 2002 Sun Microsystems Inc., - * Copyright 2001, 2002 Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include - -#include -#include - -#include "spi-common/spi-dbus.h" - -static dbus_bool_t -impl_get_characterCount (DBusMessageIter * iter, - void *user_data) -{ - AtkText *text = (AtkText *) user_data; - g_return_val_if_fail (ATK_IS_TEXT (user_data), FALSE); - return droute_return_v_int32 (iter, atk_text_get_character_count (text)); -} - -static dbus_bool_t -impl_get_caretOffset (DBusMessageIter * iter, - void *user_data) -{ - AtkText *text = (AtkText *) user_data; - g_return_val_if_fail (ATK_IS_TEXT (user_data), FALSE); - return droute_return_v_int32 (iter, atk_text_get_caret_offset (text)); -} - -static DBusMessage * -impl_getText (DBusConnection * bus, DBusMessage * message, void *user_data) -{ - AtkText *text = (AtkText *) user_data; - dbus_int32_t startOffset, endOffset; - gchar *txt; - DBusError error; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &startOffset, DBUS_TYPE_INT32, - &endOffset, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - txt = atk_text_get_text (text, startOffset, endOffset); - if (!txt) - txt = g_strdup (""); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_STRING, &txt, - DBUS_TYPE_INVALID); - } - g_free (txt); - return reply; -} - -static DBusMessage * -impl_setCaretOffset (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkText *text = (AtkText *) user_data; - dbus_int32_t offset; - dbus_bool_t rv; - DBusError error; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - rv = atk_text_set_caret_offset (text, offset); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getTextBeforeOffset (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkText *text = (AtkText *) user_data; - dbus_int32_t offset; - dbus_uint32_t type; - gchar *txt; - dbus_int32_t startOffset, endOffset; - gint intstart_offset = 0, intend_offset = 0; - DBusError error; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_UINT32, &type, - DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - txt = - atk_text_get_text_before_offset (text, offset, (AtkTextBoundary) type, - &intstart_offset, &intend_offset); - startOffset = intstart_offset; - endOffset = intend_offset; - if (!txt) - txt = g_strdup (""); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT32, &startOffset, - DBUS_TYPE_INT32, &endOffset, DBUS_TYPE_STRING, - &txt, DBUS_TYPE_INVALID); - } - g_free (txt); - return reply; -} - -static DBusMessage * -impl_getTextAtOffset (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkText *text = (AtkText *) user_data; - dbus_int32_t offset, type; - gchar *txt; - dbus_int32_t startOffset, endOffset; - gint intstart_offset = 0, intend_offset = 0; - DBusError error; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_UINT32, &type, - DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - txt = - atk_text_get_text_at_offset (text, offset, (AtkTextBoundary) type, - &intstart_offset, &intend_offset); - startOffset = intstart_offset; - endOffset = intend_offset; - if (!txt) - txt = g_strdup (""); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT32, &startOffset, - DBUS_TYPE_INT32, &endOffset, DBUS_TYPE_STRING, - &txt, DBUS_TYPE_INVALID); - } - g_free (txt); - return reply; -} - -static DBusMessage * -impl_getTextAfterOffset (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkText *text = (AtkText *) user_data; - dbus_int32_t offset; - dbus_uint32_t type; - gchar *txt; - dbus_int32_t startOffset, endOffset; - gint intstart_offset = 0, intend_offset = 0; - DBusError error; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_UINT32, &type, - DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - txt = - atk_text_get_text_after_offset (text, offset, (AtkTextBoundary) type, - &intstart_offset, &intend_offset); - startOffset = intstart_offset; - endOffset = intend_offset; - if (!txt) - txt = g_strdup (""); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT32, &startOffset, - DBUS_TYPE_INT32, &endOffset, DBUS_TYPE_STRING, - &txt, DBUS_TYPE_INVALID); - } - g_free (txt); - return reply; -} - -static DBusMessage * -impl_getCharacterAtOffset (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkText *text = (AtkText *) user_data; - dbus_int32_t offset; - dbus_int32_t ch; - DBusError error; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - ch = atk_text_get_character_at_offset (text, offset); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT32, &ch, DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getAttributeValue (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkText *text = (AtkText *) user_data; - dbus_int32_t offset; - char *attributeName; - dbus_int32_t startOffset, endOffset; - dbus_bool_t defined; - gint intstart_offset = 0, intend_offset = 0; - char *rv; - DBusError error; - DBusMessage *reply; - AtkAttributeSet *set; - GSList *cur_attr; - AtkAttribute *at; - - g_return_val_if_fail (ATK_IS_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_STRING, - &attributeName, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - - set = atk_text_get_run_attributes (text, offset, - &intstart_offset, &intend_offset); - startOffset = intstart_offset; - endOffset = intend_offset; - defined = FALSE; - cur_attr = (GSList *) set; - while (cur_attr) - { - at = (AtkAttribute *) cur_attr->data; - if (!strcmp (at->name, attributeName)) - { - rv = at->value; - defined = TRUE; - break; - } - cur_attr = cur_attr->next; - } - if (!rv) - rv = ""; - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT32, &startOffset, - DBUS_TYPE_INT32, &endOffset, - DBUS_TYPE_BOOLEAN, &defined, DBUS_TYPE_STRING, - &rv, DBUS_TYPE_INVALID); - } - atk_attribute_set_free (set); - return reply; -} - -static char * -_string_from_attribute_set (AtkAttributeSet * set) -{ - gchar *attributes, *tmp, *tmp2; - GSList *cur_attr; - AtkAttribute *at; - - attributes = g_strdup (""); - cur_attr = (GSList *) set; - while (cur_attr) - { - at = (AtkAttribute *) cur_attr->data; - tmp = g_strdup_printf ("%s%s:%s%s", - ((GSList *) (set) == cur_attr) ? "" : " ", - at->name, at->value, - (cur_attr->next) ? ";" : ""); - tmp2 = g_strconcat (attributes, tmp, NULL); - g_free (tmp); - g_free (attributes); - attributes = tmp2; - cur_attr = cur_attr->next; - } - return attributes; -} - -static DBusMessage * -impl_getAttributes (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkText *text = (AtkText *) user_data; - dbus_int32_t offset; - dbus_int32_t startOffset, endOffset; - gint intstart_offset, intend_offset; - char *rv; - DBusError error; - DBusMessage *reply; - AtkAttributeSet *set; - - g_return_val_if_fail (ATK_IS_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - - set = atk_text_get_run_attributes (text, offset, - &intstart_offset, &intend_offset); - - rv = _string_from_attribute_set (set); - - startOffset = intstart_offset; - endOffset = intend_offset; - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_STRING, &rv, DBUS_TYPE_INT32, &startOffset, - DBUS_TYPE_INT32, &endOffset, DBUS_TYPE_INVALID); - } - atk_attribute_set_free (set); - g_free(rv); - return reply; -} - -static DBusMessage * -impl_getDefaultAttributes (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkText *text = (AtkText *) user_data; - char *rv; - DBusError error; - DBusMessage *reply; - AtkAttributeSet *set; - - g_return_val_if_fail (ATK_IS_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - - set = atk_text_get_default_attributes (text); - rv = _string_from_attribute_set (set); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_STRING, &rv, - DBUS_TYPE_INVALID); - } - g_free (rv); - atk_attribute_set_free (set); - return reply; -} - -static DBusMessage * -impl_getCharacterExtents (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkText *text = (AtkText *) user_data; - dbus_int32_t offset; - dbus_int16_t coordType; - dbus_int32_t x, y, width, height; - gint ix = 0, iy = 0, iw = 0, ih = 0; - DBusError error; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_INT16, &coordType, - DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - atk_text_get_character_extents (text, offset, &ix, &iy, &iw, &ih, - (AtkCoordType) coordType); - x = ix; - y = iy; - width = iw; - height = ih; - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, - &y, DBUS_TYPE_INT32, &width, DBUS_TYPE_INT32, - &height, DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getOffsetAtPoint (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkText *text = (AtkText *) user_data; - dbus_int32_t x, y; - dbus_int16_t coordType; - dbus_int32_t rv; - DBusError error; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y, - DBUS_TYPE_INT16, &coordType, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - rv = atk_text_get_offset_at_point (text, x, y, coordType); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT32, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getNSelections (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkText *text = (AtkText *) user_data; - dbus_int32_t rv; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_TEXT (user_data), - droute_not_yet_handled_error (message)); - rv = atk_text_get_n_selections (text); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT32, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getSelection (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkText *text = (AtkText *) user_data; - dbus_int32_t selectionNum; - dbus_int32_t startOffset, endOffset; - gint intstart_offset = 0, intend_offset = 0; - DBusError error; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &selectionNum, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - /* atk_text_get_selection returns gchar * which we discard */ - g_free (atk_text_get_selection - (text, selectionNum, &intstart_offset, &intend_offset)); - startOffset = intstart_offset; - endOffset = intend_offset; - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT32, &startOffset, - DBUS_TYPE_INT32, &endOffset, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_addSelection (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkText *text = (AtkText *) user_data; - dbus_int32_t startOffset, endOffset; - dbus_bool_t rv; - DBusError error; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &startOffset, DBUS_TYPE_INT32, - &endOffset, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - rv = atk_text_add_selection (text, startOffset, endOffset); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_removeSelection (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkText *text = (AtkText *) user_data; - dbus_int32_t selectionNum; - dbus_bool_t rv; - DBusError error; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &selectionNum, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - rv = atk_text_remove_selection (text, selectionNum); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_setSelection (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkText *text = (AtkText *) user_data; - dbus_int32_t selectionNum, startOffset, endOffset; - dbus_bool_t rv; - DBusError error; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &selectionNum, DBUS_TYPE_INT32, - &startOffset, DBUS_TYPE_INT32, &endOffset, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - rv = atk_text_set_selection (text, selectionNum, startOffset, endOffset); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, - DBUS_TYPE_INVALID); - } - return reply; -} - -static DBusMessage * -impl_getRangeExtents (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkText *text = (AtkText *) user_data; - dbus_int32_t startOffset, endOffset; - dbus_int16_t coordType; - AtkTextRectangle rect; - dbus_int32_t x, y, width, height; - DBusError error; - DBusMessage *reply; - - g_return_val_if_fail (ATK_IS_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &startOffset, DBUS_TYPE_INT32, - &endOffset, DBUS_TYPE_INT16, &coordType, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - memset (&rect, 0, sizeof (rect)); - atk_text_get_range_extents (text, startOffset, endOffset, - (AtkCoordType) coordType, &rect); - x = rect.x; - y = rect.y; - width = rect.width; - height = rect.height; - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, - &y, DBUS_TYPE_INT32, &width, DBUS_TYPE_INT32, - &height, DBUS_TYPE_INVALID); - } - return reply; -} - -#define MAXRANGELEN 512 - -static DBusMessage * -impl_getBoundedRanges (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkText *text = (AtkText *) user_data; - dbus_int32_t x, y, width, height; - dbus_int16_t coordType, xClipType, yClipType; - DBusError error; - AtkTextRange **range_list = NULL; - AtkTextRectangle rect; - DBusMessage *reply; - DBusMessageIter iter, array, struc, variant; - - g_return_val_if_fail (ATK_IS_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y, - DBUS_TYPE_INT32, &height, DBUS_TYPE_INT32, &width, DBUS_TYPE_INT32, - &coordType, DBUS_TYPE_INT32, &xClipType, DBUS_TYPE_INT32, &yClipType, - DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - rect.x = x; - rect.y = y; - rect.width = width; - rect.height = height; - - range_list = - atk_text_get_bounded_ranges (text, &rect, (AtkCoordType) coordType, - (AtkTextClipType) xClipType, - (AtkTextClipType) yClipType); - reply = dbus_message_new_method_return (message); - if (!reply) - return NULL; - /* This isn't pleasant. */ - dbus_message_iter_init_append (reply, &iter); - if (dbus_message_iter_open_container - (&iter, DBUS_TYPE_ARRAY, "(iisv)", &array)) - { - int len; - for (len = 0; len < MAXRANGELEN && range_list[len]; ++len) - { - if (dbus_message_iter_open_container - (&array, DBUS_TYPE_STRUCT, NULL, &struc)) - { - dbus_int32_t val; - val = range_list[len]->start_offset; - dbus_message_iter_append_basic (&struc, DBUS_TYPE_INT32, &val); - val = range_list[len]->end_offset; - dbus_message_iter_append_basic (&struc, DBUS_TYPE_INT32, &val); - dbus_message_iter_append_basic (&struc, DBUS_TYPE_STRING, - &range_list[len]->content); - /* The variant is unimplemented in atk, but I don't want to - * unilaterally muck with the spec and remove it, so I'll just - * throw in a dummy value */ - if (dbus_message_iter_open_container - (&array, DBUS_TYPE_VARIANT, "i", &variant)) - { - dbus_uint32_t dummy = 0; - dbus_message_iter_append_basic (&variant, DBUS_TYPE_INT32, - &dummy); - dbus_message_iter_close_container (&struc, &variant); - } - dbus_message_iter_close_container (&array, &struc); - } - } - dbus_message_iter_close_container (&iter, &array); - } - return reply; -} - -static DBusMessage * -impl_getAttributeRun (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - DBusError error; - AtkText *text = (AtkText *) user_data; - dbus_int32_t offset; - dbus_bool_t includeDefaults; - dbus_int32_t startOffset, endOffset; - gint intstart_offset = 0, intend_offset = 0; - DBusMessage *reply; - AtkAttributeSet *attributes, *default_attributes = NULL; - AtkAttribute *attr = NULL; - char **retval; - gint n_attributes = 0, total_attributes = 0, n_default_attributes = 0; - gint i, j; - - g_return_val_if_fail (ATK_IS_TEXT (user_data), - droute_not_yet_handled_error (message)); - dbus_error_init (&error); - if (!dbus_message_get_args - (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_BOOLEAN, - &includeDefaults, DBUS_TYPE_INVALID)) - { - return SPI_DBUS_RETURN_ERROR (message, &error); - } - - attributes = - atk_text_get_run_attributes (text, offset, &intstart_offset, - &intend_offset); - - if (attributes) - total_attributes = n_attributes = g_slist_length (attributes); - - if (includeDefaults) - { - default_attributes = atk_text_get_default_attributes (text); - if (default_attributes) - n_default_attributes = g_slist_length (default_attributes); - total_attributes += n_default_attributes; - } - - startOffset = intstart_offset; - endOffset = intend_offset; - - retval = (char **) g_malloc (total_attributes * sizeof (char *)); - - if (total_attributes) - { - for (i = 0; i < n_attributes; ++i) - { - attr = g_slist_nth_data (attributes, i); - retval[i] = g_strconcat (attr->name, ":", attr->value, NULL); - } - - for (j = 0; j < n_default_attributes; ++i, ++j) - { - attr = g_slist_nth_data (default_attributes, j); - retval[i] = g_strconcat (attr->name, ":", attr->value, NULL); - } - - atk_attribute_set_free (attributes); - if (default_attributes) - atk_attribute_set_free (default_attributes); - } - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_INT32, &startOffset, - DBUS_TYPE_INT32, &endOffset, DBUS_TYPE_ARRAY, - DBUS_TYPE_STRING, &retval, total_attributes, - DBUS_TYPE_INVALID); - } - for (i = 0; i < total_attributes; i++) - g_free (retval[i]); - g_free (retval); - return reply; -} - -static DBusMessage * -impl_getDefaultAttributeSet (DBusConnection * bus, DBusMessage * message, - void *user_data) -{ - AtkText *text = (AtkText *) user_data; - DBusMessage *reply; - AtkAttributeSet *attributes; - AtkAttribute *attr = NULL; - char **retval; - gint n_attributes = 0; - gint i; - - g_return_val_if_fail (ATK_IS_TEXT (user_data), - droute_not_yet_handled_error (message)); - - attributes = atk_text_get_default_attributes (text); - if (attributes) - n_attributes = g_slist_length (attributes); - - retval = g_new (char *, n_attributes); - - for (i = 0; i < n_attributes; ++i) - { - attr = g_slist_nth_data (attributes, i); - retval[i] = g_strconcat (attr->name, ":", attr->value, NULL); - } - if (attributes) - atk_attribute_set_free (attributes); - reply = dbus_message_new_method_return (message); - if (reply) - { - dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, - &retval, n_attributes, DBUS_TYPE_INVALID); - } - for (i = 0; i < n_attributes; i++) - g_free (retval[i]); - g_free (retval); - return reply; -} - -static DRouteMethod methods[] = { - {impl_getText, "getText"}, - {impl_setCaretOffset, "setCaretOffset"}, - {impl_getTextBeforeOffset, "getTextBeforeOffset"}, - {impl_getTextAtOffset, "getTextAtOffset"}, - {impl_getTextAfterOffset, "getTextAfterOffset"}, - {impl_getCharacterAtOffset, "getCharacterAtOffset"}, - {impl_getAttributeValue, "getAttributeValue"}, - {impl_getAttributes, "getAttributes"}, - {impl_getDefaultAttributes, "getDefaultAttributes"}, - {impl_getCharacterExtents, "getCharacterExtents"}, - {impl_getOffsetAtPoint, "getOffsetAtPoint"}, - {impl_getNSelections, "getNSelections"}, - {impl_getSelection, "getSelection"}, - {impl_addSelection, "addSelection"}, - {impl_removeSelection, "removeSelection"}, - {impl_setSelection, "setSelection"}, - {impl_getRangeExtents, "getRangeExtents"}, - {impl_getBoundedRanges, "getBoundedRanges"}, - {impl_getAttributeRun, "getAttributeRun"}, - {impl_getDefaultAttributeSet, "getDefaultAttributeSet"}, - {NULL, NULL} -}; - -static DRouteProperty properties[] = { - {impl_get_characterCount, NULL, "characterCount"}, - {impl_get_caretOffset, NULL, "caretOffset"}, - {NULL, NULL, NULL} -}; - -void -spi_initialize_text (DRoutePath *path) -{ - droute_path_add_interface (path, - SPI_DBUS_INTERFACE_TEXT, - methods, - properties); -}; diff --git a/atk-adaptor/tree-adaptor.c b/atk-adaptor/tree-adaptor.c new file mode 100644 index 0000000..a4411d0 --- /dev/null +++ b/atk-adaptor/tree-adaptor.c @@ -0,0 +1,316 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2008 Novell, Inc. + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc. + * Copyright 2008, 2009 Codethink Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include + +#include +#include + +#include "bridge.h" +#include "accessible-register.h" +#include "spi-common/spi-dbus.h" + +/*---------------------------------------------------------------------------*/ + +static void +append_atk_object_interfaces (AtkObject *object, DBusMessageIter *iter) +{ + const gchar *itf; + + itf = SPI_DBUS_INTERFACE_ACCESSIBLE; + dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); + + if (ATK_IS_ACTION (object)) + { + itf = SPI_DBUS_INTERFACE_ACTION; + dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); + } + + if (ATK_IS_COMPONENT (object)) + { + itf = SPI_DBUS_INTERFACE_COMPONENT; + dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); + } + + if (ATK_IS_EDITABLE_TEXT (object)) + { + itf = SPI_DBUS_INTERFACE_EDITABLE_TEXT; + dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); + } + + if (ATK_IS_TEXT (object)) + { + itf = SPI_DBUS_INTERFACE_TEXT; + dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); + } + + if (ATK_IS_HYPERTEXT (object)) + { + itf = SPI_DBUS_INTERFACE_HYPERTEXT; + dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); + } + + if (ATK_IS_IMAGE (object)) + { + itf = SPI_DBUS_INTERFACE_IMAGE; + dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); + } + + if (ATK_IS_SELECTION (object)) + { + itf = SPI_DBUS_INTERFACE_SELECTION; + dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); + } + + if (ATK_IS_TABLE (object)) + { + itf = SPI_DBUS_INTERFACE_TABLE; + dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); + } + + if (ATK_IS_VALUE (object)) + { + itf = SPI_DBUS_INTERFACE_VALUE; + dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); + } + + if (ATK_IS_STREAMABLE_CONTENT (object)) + { + itf = "org.freedesktop.atspi.StreamableContent"; + dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); + } + + if (ATK_IS_DOCUMENT (object)) + { + itf = "org.freedesktop.atspi.Collection"; + dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); + itf = SPI_DBUS_INTERFACE_DOCUMENT; + dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); + } + + if (ATK_IS_HYPERLINK_IMPL (object)) + { + itf = SPI_DBUS_INTERFACE_HYPERLINK; + dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); + } +} + +/*---------------------------------------------------------------------------*/ + +static const char *dumm = "/APath/1"; + + +/* + * Marshals the given AtkObject into the provided D-Bus iterator. + * + * The object is marshalled including all its client side cache data. + * The format of the structure is (ooaoassusau). + * This is used in the updateTree signal and the getTree method + * of the org.freedesktop.atspi.Tree interface. + */ +static void +append_accessible(gpointer obj_data, gpointer iter) +{ + AtkObject *obj; + DBusMessageIter *iter_array; + DBusMessageIter iter_struct, iter_sub_array; + dbus_int32_t states [2]; + int count; + + const char *name, *desc; + int i; + dbus_uint32_t role; + GSList *l; + + obj = ATK_OBJECT(obj_data); + iter_array = (DBusMessageIter *) iter; + + dbus_message_iter_open_container (iter_array, DBUS_TYPE_STRUCT, NULL, &iter_struct); + { + AtkObject *parent; + gchar *path, *path_parent; + + path = atk_dbus_object_to_path (obj); + dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH, &path); + + parent = atk_object_get_parent(obj); + if (parent == NULL) + path_parent = g_strdup("/"); + else + path_parent = atk_dbus_object_to_path (parent); + dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH, &path_parent); + g_free(path_parent); + + dbus_message_iter_open_container (&iter_struct, DBUS_TYPE_ARRAY, "o", &iter_sub_array); + { + gint childcount, i; + + childcount = atk_object_get_n_accessible_children (obj); + for (i = 0; i < childcount; i++) + { + AtkObject *child; + gchar *child_path; + + child = atk_object_ref_accessible_child (obj, i); + child_path = atk_dbus_object_to_path (child); + g_object_unref(G_OBJECT(child)); + if (G_LIKELY (child_path)) + { + dbus_message_iter_append_basic (&iter_sub_array, DBUS_TYPE_OBJECT_PATH, &child_path); + } + else + { + g_critical ("AT-SPI: Child object exists in accessible tree but has not been registered"); + g_free (child_path); + } + } + } + dbus_message_iter_close_container (&iter_struct, &iter_sub_array); + + dbus_message_iter_open_container (&iter_struct, DBUS_TYPE_ARRAY, "s", &iter_sub_array); + append_atk_object_interfaces (obj, &iter_sub_array); + dbus_message_iter_close_container (&iter_struct, &iter_sub_array); + + name = atk_object_get_name (obj); + if (!name) + name = ""; + dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &name); + + role = spi_accessible_role_from_atk_role (atk_object_get_role (obj)); + dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_UINT32, &role); + + desc = atk_object_get_description (obj); + if (!desc) + desc = ""; + dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &desc); + + g_free(path); + } + spi_atk_state_to_dbus_array (obj, &states); + dbus_message_iter_open_container (&iter_struct, DBUS_TYPE_ARRAY, "u", &iter_sub_array); + for (count = 0; count < 2; count++) + dbus_message_iter_append_basic (&iter_sub_array, DBUS_TYPE_UINT32, &states[count]); + dbus_message_iter_close_container (&iter_struct, &iter_sub_array); + dbus_message_iter_close_container (iter_array, &iter_struct); +} + +/* For use as a GHFunc */ +static void +append_accessible_hf (gpointer key, gpointer obj_data, gpointer iter) +{ + append_accessible (obj_data, iter); +} + +/*---------------------------------------------------------------------------*/ + +void +spi_emit_cache_removal (guint ref, DBusConnection *bus) +{ + DBusMessage *message; + DBusMessageIter iter; + gchar *path; + + message = dbus_message_new_signal ("/org/freedesktop/atspi/tree", SPI_DBUS_INTERFACE_TREE, "removeAccessible"); + + dbus_message_iter_init_append (message, &iter); + + path = atk_dbus_ref_to_path (ref); + dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &path); + + dbus_connection_send(bus, message, NULL); +} + +void +spi_emit_cache_update (const GList *accessibles, DBusConnection *bus) +{ + DBusMessage *message; + DBusMessageIter iter; + DBusMessageIter iter_array; + message = dbus_message_new_signal ("/org/freedesktop/atspi/tree", SPI_DBUS_INTERFACE_TREE, "updateAccessible"); + + dbus_message_iter_init_append (message, &iter); + dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "(ooaoassusau)", &iter_array); + g_list_foreach ((GList *)accessibles, append_accessible, &iter_array); + dbus_message_iter_close_container(&iter, &iter_array); + + dbus_connection_send(bus, message, NULL); +} + + +/*---------------------------------------------------------------------------*/ + +static DBusMessage * +impl_getRoot (DBusConnection *bus, DBusMessage *message, void *user_data) +{ + AtkObject *root = atk_get_root(); + char *path; + DBusMessage *reply; + + if (!root) + return spi_dbus_general_error (message); + path = atk_dbus_object_to_path (root); + if (!path) + return spi_dbus_general_error (message); + reply = dbus_message_new_method_return (message); + dbus_message_append_args (reply, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID); + g_free (path); + return reply; +} + +/*---------------------------------------------------------------------------*/ + +static DBusMessage * +impl_getTree (DBusConnection *bus, DBusMessage *message, void *user_data) +{ + DBusMessage *reply; + DBusMessageIter iter, iter_array; + + reply = dbus_message_new_method_return (message); + + dbus_message_iter_init_append (reply, &iter); + dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(ooaoassusau)", &iter_array); + atk_dbus_foreach_registered(append_accessible_hf, &iter_array); + dbus_message_iter_close_container(&iter, &iter_array); + return reply; +} + +/*---------------------------------------------------------------------------*/ + +static DRouteMethod methods[] = { + {impl_getRoot, "getRoot"}, + {impl_getTree, "getTree"}, + {NULL, NULL} +}; + +void +spi_initialize_tree (DRoutePath *path) +{ + droute_path_add_interface (path, + SPI_DBUS_INTERFACE_TREE, + methods, + NULL); +}; + +/*END------------------------------------------------------------------------*/ diff --git a/atk-adaptor/tree-adaptor.h b/atk-adaptor/tree-adaptor.h new file mode 100644 index 0000000..b0c99df --- /dev/null +++ b/atk-adaptor/tree-adaptor.h @@ -0,0 +1,37 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc. + * Copyright 2008, 2009 Codethink Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef TREE_ADAPTOR_H +#define TREE_ADAPTOR_H + +#include +#include + +void +spi_emit_cache_update (AtkObject *accessible, DBusConnection *bus); + +void +spi_emit_cache_removal (guint ref, DBusConnection *bus); + +#endif /* TREE_ADAPTOR_H */ diff --git a/atk-adaptor/tree.c b/atk-adaptor/tree.c deleted file mode 100644 index ddac5e3..0000000 --- a/atk-adaptor/tree.c +++ /dev/null @@ -1,315 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) - * - * Copyright 2008 Novell, Inc. - * Copyright 2001, 2002 Sun Microsystems Inc., - * Copyright 2001, 2002 Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include - -#include -#include - -#include "atk-dbus.h" -#include "spi-common/spi-dbus.h" -#include "bridge.h" - -/*---------------------------------------------------------------------------*/ - -static void -append_atk_object_interfaces (AtkObject *object, DBusMessageIter *iter) -{ - const gchar *itf; - - itf = SPI_DBUS_INTERFACE_ACCESSIBLE; - dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); - - if (ATK_IS_ACTION (object)) - { - itf = SPI_DBUS_INTERFACE_ACTION; - dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); - } - - if (ATK_IS_COMPONENT (object)) - { - itf = SPI_DBUS_INTERFACE_COMPONENT; - dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); - } - - if (ATK_IS_EDITABLE_TEXT (object)) - { - itf = SPI_DBUS_INTERFACE_EDITABLE_TEXT; - dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); - } - - if (ATK_IS_TEXT (object)) - { - itf = SPI_DBUS_INTERFACE_TEXT; - dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); - } - - if (ATK_IS_HYPERTEXT (object)) - { - itf = SPI_DBUS_INTERFACE_HYPERTEXT; - dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); - } - - if (ATK_IS_IMAGE (object)) - { - itf = SPI_DBUS_INTERFACE_IMAGE; - dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); - } - - if (ATK_IS_SELECTION (object)) - { - itf = SPI_DBUS_INTERFACE_SELECTION; - dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); - } - - if (ATK_IS_TABLE (object)) - { - itf = SPI_DBUS_INTERFACE_TABLE; - dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); - } - - if (ATK_IS_VALUE (object)) - { - itf = SPI_DBUS_INTERFACE_VALUE; - dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); - } - - if (ATK_IS_STREAMABLE_CONTENT (object)) - { - itf = "org.freedesktop.atspi.StreamableContent"; - dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); - } - - if (ATK_IS_DOCUMENT (object)) - { - itf = "org.freedesktop.atspi.Collection"; - dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); - itf = SPI_DBUS_INTERFACE_DOCUMENT; - dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); - } - - if (ATK_IS_HYPERLINK_IMPL (object)) - { - itf = SPI_DBUS_INTERFACE_HYPERLINK; - dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf); - } -} - -/*---------------------------------------------------------------------------*/ - -static const char *dumm = "/APath/1"; - - -/* - * Marshals the given AtkObject into the provided D-Bus iterator. - * - * The object is marshalled including all its client side cache data. - * The format of the structure is (ooaoassusau). - * This is used in the updateTree signal and the getTree method - * of the org.freedesktop.atspi.Tree interface. - */ -static void -append_accessible(gpointer obj_data, gpointer iter) -{ - AtkObject *obj; - DBusMessageIter *iter_array; - DBusMessageIter iter_struct, iter_sub_array; - dbus_int32_t states [2]; - int count; - - const char *name, *desc; - int i; - dbus_uint32_t role; - GSList *l; - - obj = ATK_OBJECT(obj_data); - iter_array = (DBusMessageIter *) iter; - - dbus_message_iter_open_container (iter_array, DBUS_TYPE_STRUCT, NULL, &iter_struct); - { - AtkObject *parent; - gchar *path, *path_parent; - - path = atk_dbus_object_to_path (obj); - dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH, &path); - - parent = atk_object_get_parent(obj); - if (parent == NULL) - path_parent = g_strdup("/"); - else - path_parent = atk_dbus_object_to_path (parent); - dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH, &path_parent); - g_free(path_parent); - - dbus_message_iter_open_container (&iter_struct, DBUS_TYPE_ARRAY, "o", &iter_sub_array); - { - gint childcount, i; - - childcount = atk_object_get_n_accessible_children (obj); - for (i = 0; i < childcount; i++) - { - AtkObject *child; - gchar *child_path; - - child = atk_object_ref_accessible_child (obj, i); - child_path = atk_dbus_object_to_path (child); - g_object_unref(G_OBJECT(child)); - if (G_LIKELY (child_path)) - { - dbus_message_iter_append_basic (&iter_sub_array, DBUS_TYPE_OBJECT_PATH, &child_path); - } - else - { - g_critical ("AT-SPI: Child object exists in accessible tree but has not been registered"); - g_free (child_path); - } - } - } - dbus_message_iter_close_container (&iter_struct, &iter_sub_array); - - dbus_message_iter_open_container (&iter_struct, DBUS_TYPE_ARRAY, "s", &iter_sub_array); - append_atk_object_interfaces (obj, &iter_sub_array); - dbus_message_iter_close_container (&iter_struct, &iter_sub_array); - - name = atk_object_get_name (obj); - if (!name) - name = ""; - dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &name); - - role = spi_accessible_role_from_atk_role (atk_object_get_role (obj)); - dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_UINT32, &role); - - desc = atk_object_get_description (obj); - if (!desc) - desc = ""; - dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &desc); - - g_free(path); - } - spi_atk_state_to_dbus_array (obj, &states); - dbus_message_iter_open_container (&iter_struct, DBUS_TYPE_ARRAY, "u", &iter_sub_array); - for (count = 0; count < 2; count++) - dbus_message_iter_append_basic (&iter_sub_array, DBUS_TYPE_UINT32, &states[count]); - dbus_message_iter_close_container (&iter_struct, &iter_sub_array); - dbus_message_iter_close_container (iter_array, &iter_struct); -} - -/* For use as a GHFunc */ -static void -append_accessible_hf (gpointer key, gpointer obj_data, gpointer iter) -{ - append_accessible (obj_data, iter); -} - -/*---------------------------------------------------------------------------*/ - -void -spi_emit_cache_removal (guint ref, DBusConnection *bus) -{ - DBusMessage *message; - DBusMessageIter iter; - gchar *path; - - message = dbus_message_new_signal ("/org/freedesktop/atspi/tree", SPI_DBUS_INTERFACE_TREE, "removeAccessible"); - - dbus_message_iter_init_append (message, &iter); - - path = atk_dbus_ref_to_path (ref); - dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &path); - - dbus_connection_send(bus, message, NULL); -} - -void -spi_emit_cache_update (const GList *accessibles, DBusConnection *bus) -{ - DBusMessage *message; - DBusMessageIter iter; - DBusMessageIter iter_array; - message = dbus_message_new_signal ("/org/freedesktop/atspi/tree", SPI_DBUS_INTERFACE_TREE, "updateAccessible"); - - dbus_message_iter_init_append (message, &iter); - dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "(ooaoassusau)", &iter_array); - g_list_foreach ((GList *)accessibles, append_accessible, &iter_array); - dbus_message_iter_close_container(&iter, &iter_array); - - dbus_connection_send(bus, message, NULL); -} - - -/*---------------------------------------------------------------------------*/ - -static DBusMessage * -impl_getRoot (DBusConnection *bus, DBusMessage *message, void *user_data) -{ - AtkObject *root = atk_get_root(); - char *path; - DBusMessage *reply; - - if (!root) - return spi_dbus_general_error (message); - path = atk_dbus_object_to_path (root); - if (!path) - return spi_dbus_general_error (message); - reply = dbus_message_new_method_return (message); - dbus_message_append_args (reply, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID); - g_free (path); - return reply; -} - -/*---------------------------------------------------------------------------*/ - -static DBusMessage * -impl_getTree (DBusConnection *bus, DBusMessage *message, void *user_data) -{ - DBusMessage *reply; - DBusMessageIter iter, iter_array; - - reply = dbus_message_new_method_return (message); - - dbus_message_iter_init_append (reply, &iter); - dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(ooaoassusau)", &iter_array); - atk_dbus_foreach_registered(append_accessible_hf, &iter_array); - dbus_message_iter_close_container(&iter, &iter_array); - return reply; -} - -/*---------------------------------------------------------------------------*/ - -static DRouteMethod methods[] = { - {impl_getRoot, "getRoot"}, - {impl_getTree, "getTree"}, - {NULL, NULL} -}; - -void -spi_initialize_tree (DRoutePath *path) -{ - droute_path_add_interface (path, - SPI_DBUS_INTERFACE_TREE, - methods, - NULL); -}; - -/*END------------------------------------------------------------------------*/ diff --git a/atk-adaptor/tree.h b/atk-adaptor/tree.h deleted file mode 100644 index cdd2b56..0000000 --- a/atk-adaptor/tree.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) - * - * Copyright 2001, 2002 Sun Microsystems Inc., - * Copyright 2001, 2002 Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef SPI_TREE_H_ -#define SPI_TREE_H_ - -#include -#include -#include - -G_BEGIN_DECLS - -void -spi_emit_cache_update (AtkObject *accessible, DBusConnection *bus); - -void -spi_emit_cache_removal (guint ref, DBusConnection *bus); - -G_END_DECLS - -#endif /* SPI_ACCESSIBLE_H_ */ diff --git a/atk-adaptor/value-adaptor.c b/atk-adaptor/value-adaptor.c new file mode 100644 index 0000000..5618e61 --- /dev/null +++ b/atk-adaptor/value-adaptor.c @@ -0,0 +1,253 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2008 Novell, Inc. + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include + +#include +#include + +#include "spi-common/spi-dbus.h" + +static double +get_double_from_gvalue (GValue * gvalue) +{ + double retval = 0; + if (G_TYPE_IS_FUNDAMENTAL (G_VALUE_TYPE (gvalue))) + { + switch (gvalue->g_type) + { + case G_TYPE_DOUBLE: + retval = g_value_get_double (gvalue); + break; + case G_TYPE_FLOAT: + retval = g_value_get_float (gvalue); + break; + case G_TYPE_ULONG: + retval = g_value_get_ulong (gvalue); + break; + case G_TYPE_LONG: + retval = g_value_get_long (gvalue); + break; + case G_TYPE_UINT: + retval = g_value_get_uint (gvalue); + break; + case G_TYPE_INT: + retval = g_value_get_int (gvalue); + break; + case G_TYPE_UCHAR: + retval = g_value_get_uchar (gvalue); + break; + case G_TYPE_CHAR: + retval = g_value_get_char (gvalue); + break; + case G_TYPE_BOOLEAN: + retval = g_value_get_boolean (gvalue); + break; + } + } + else + { + g_warning ("SpiValue requested from a non-fundamental type\n"); + } + return retval; +} + +static gboolean +get_double_from_variant (DBusMessageIter * iter, double *out) +{ + DBusMessageIter sub; + + dbus_message_iter_recurse (iter, &sub); + switch (dbus_message_iter_get_arg_type (&sub)) + { + case DBUS_TYPE_DOUBLE: + { + dbus_message_iter_get_basic (&sub, out); + return TRUE; + } + case DBUS_TYPE_UINT32: + { + dbus_uint32_t v; + dbus_message_iter_get_basic (&sub, &v); + *out = (double) v; + return TRUE; + } + case DBUS_TYPE_INT32: + { + dbus_int32_t v; + dbus_message_iter_get_basic (&sub, &v); + *out = (double) v; + return TRUE; + } + case DBUS_TYPE_UINT16: + { + dbus_uint16_t v; + dbus_message_iter_get_basic (&sub, &v); + *out = (double) v; + return TRUE; + } + case DBUS_TYPE_INT16: + { + dbus_int16_t v; + dbus_message_iter_get_basic (&sub, &v); + *out = (double) v; + return TRUE; + } + case DBUS_TYPE_BYTE: + { + char v; + dbus_message_iter_get_basic (&sub, &v); + *out = (double) v; + return TRUE; + } + case DBUS_TYPE_BOOLEAN: + { + dbus_bool_t v; + dbus_message_iter_get_basic (&sub, &v); + *out = (double) v; + return TRUE; + } + default: + return FALSE; + } +} + +static void +gvalue_set_from_double (GValue * gvalue, double value) +{ + if (G_TYPE_IS_FUNDAMENTAL (G_VALUE_TYPE (gvalue))) + { + switch (gvalue->g_type) + { + case G_TYPE_DOUBLE: + g_value_set_double (gvalue, value); + break; + case G_TYPE_FLOAT: + g_value_set_float (gvalue, value); + break; + case G_TYPE_ULONG: + g_value_set_ulong (gvalue, value); + break; + case G_TYPE_LONG: + g_value_set_long (gvalue, value); + break; + case G_TYPE_UINT: + g_value_set_uint (gvalue, value); + break; + case G_TYPE_INT: + g_value_set_int (gvalue, value); + break; + case G_TYPE_UCHAR: + g_value_set_uchar (gvalue, value); + break; + case G_TYPE_CHAR: + g_value_set_char (gvalue, value); + break; + case G_TYPE_BOOLEAN: + g_value_set_boolean (gvalue, ((fabs (value) > 0.5) ? 1 : 0)); + break; + } + } + else + { + g_warning ("SpiValue change requested for a non-fundamental type\n"); + } +} + +static dbus_bool_t +impl_get_minimumValue (DBusMessageIter * iter, + void *user_data) +{ + AtkValue *value = (AtkValue *) user_data; + GValue gvalue = { 0, }; + g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE); + atk_value_get_minimum_value (value, &gvalue); + return droute_return_v_double (iter, get_double_from_gvalue (&gvalue)); +} + +static dbus_bool_t +impl_get_maximumValue (DBusMessageIter * iter, + void *user_data) +{ + AtkValue *value = (AtkValue *) user_data; + GValue gvalue = { 0, }; + g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE); + atk_value_get_maximum_value (value, &gvalue); + return droute_return_v_double (iter, get_double_from_gvalue (&gvalue)); +} + +static dbus_bool_t +impl_get_minimumIncrement (DBusMessageIter * iter, + void *user_data) +{ + AtkValue *value = (AtkValue *) user_data; + GValue gvalue = { 0, }; + g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE); + atk_value_get_minimum_value (value, &gvalue); + return droute_return_v_double (iter, get_double_from_gvalue (&gvalue)); +} + +static dbus_bool_t +impl_get_currentValue (DBusMessageIter * iter, + void *user_data) +{ + AtkValue *value = (AtkValue *) user_data; + GValue gvalue = { 0, }; + g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE); + atk_value_get_current_value (value, &gvalue); + return droute_return_v_double (iter, get_double_from_gvalue (&gvalue)); +} + +static dbus_bool_t +impl_set_currentValue (DBusMessageIter * iter, + void *user_data) +{ + AtkValue *value = (AtkValue *) user_data; + GValue gvalue = { 0, }; + double dbl; + + g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE); + if (!get_double_from_variant (iter, &dbl)) + return FALSE; + atk_value_get_current_value (value, &gvalue); + gvalue_set_from_double (&gvalue, dbl); + return TRUE; +} + +static DRouteProperty properties[] = { + {impl_get_minimumValue, NULL, "minimumValue"}, + {impl_get_maximumValue, NULL, "maximumValue"}, + {impl_get_minimumIncrement, NULL, "minimumIncrement"}, + {impl_get_currentValue, impl_set_currentValue, "currentValue"}, + {NULL, NULL, NULL} +}; + +void +spi_initialize_value (DRoutePath *path) +{ + droute_path_add_interface (path, + SPI_DBUS_INTERFACE_VALUE, + NULL, + properties); +}; diff --git a/atk-adaptor/value.c b/atk-adaptor/value.c deleted file mode 100644 index 5618e61..0000000 --- a/atk-adaptor/value.c +++ /dev/null @@ -1,253 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) - * - * Copyright 2008 Novell, Inc. - * Copyright 2001, 2002 Sun Microsystems Inc., - * Copyright 2001, 2002 Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include - -#include -#include - -#include "spi-common/spi-dbus.h" - -static double -get_double_from_gvalue (GValue * gvalue) -{ - double retval = 0; - if (G_TYPE_IS_FUNDAMENTAL (G_VALUE_TYPE (gvalue))) - { - switch (gvalue->g_type) - { - case G_TYPE_DOUBLE: - retval = g_value_get_double (gvalue); - break; - case G_TYPE_FLOAT: - retval = g_value_get_float (gvalue); - break; - case G_TYPE_ULONG: - retval = g_value_get_ulong (gvalue); - break; - case G_TYPE_LONG: - retval = g_value_get_long (gvalue); - break; - case G_TYPE_UINT: - retval = g_value_get_uint (gvalue); - break; - case G_TYPE_INT: - retval = g_value_get_int (gvalue); - break; - case G_TYPE_UCHAR: - retval = g_value_get_uchar (gvalue); - break; - case G_TYPE_CHAR: - retval = g_value_get_char (gvalue); - break; - case G_TYPE_BOOLEAN: - retval = g_value_get_boolean (gvalue); - break; - } - } - else - { - g_warning ("SpiValue requested from a non-fundamental type\n"); - } - return retval; -} - -static gboolean -get_double_from_variant (DBusMessageIter * iter, double *out) -{ - DBusMessageIter sub; - - dbus_message_iter_recurse (iter, &sub); - switch (dbus_message_iter_get_arg_type (&sub)) - { - case DBUS_TYPE_DOUBLE: - { - dbus_message_iter_get_basic (&sub, out); - return TRUE; - } - case DBUS_TYPE_UINT32: - { - dbus_uint32_t v; - dbus_message_iter_get_basic (&sub, &v); - *out = (double) v; - return TRUE; - } - case DBUS_TYPE_INT32: - { - dbus_int32_t v; - dbus_message_iter_get_basic (&sub, &v); - *out = (double) v; - return TRUE; - } - case DBUS_TYPE_UINT16: - { - dbus_uint16_t v; - dbus_message_iter_get_basic (&sub, &v); - *out = (double) v; - return TRUE; - } - case DBUS_TYPE_INT16: - { - dbus_int16_t v; - dbus_message_iter_get_basic (&sub, &v); - *out = (double) v; - return TRUE; - } - case DBUS_TYPE_BYTE: - { - char v; - dbus_message_iter_get_basic (&sub, &v); - *out = (double) v; - return TRUE; - } - case DBUS_TYPE_BOOLEAN: - { - dbus_bool_t v; - dbus_message_iter_get_basic (&sub, &v); - *out = (double) v; - return TRUE; - } - default: - return FALSE; - } -} - -static void -gvalue_set_from_double (GValue * gvalue, double value) -{ - if (G_TYPE_IS_FUNDAMENTAL (G_VALUE_TYPE (gvalue))) - { - switch (gvalue->g_type) - { - case G_TYPE_DOUBLE: - g_value_set_double (gvalue, value); - break; - case G_TYPE_FLOAT: - g_value_set_float (gvalue, value); - break; - case G_TYPE_ULONG: - g_value_set_ulong (gvalue, value); - break; - case G_TYPE_LONG: - g_value_set_long (gvalue, value); - break; - case G_TYPE_UINT: - g_value_set_uint (gvalue, value); - break; - case G_TYPE_INT: - g_value_set_int (gvalue, value); - break; - case G_TYPE_UCHAR: - g_value_set_uchar (gvalue, value); - break; - case G_TYPE_CHAR: - g_value_set_char (gvalue, value); - break; - case G_TYPE_BOOLEAN: - g_value_set_boolean (gvalue, ((fabs (value) > 0.5) ? 1 : 0)); - break; - } - } - else - { - g_warning ("SpiValue change requested for a non-fundamental type\n"); - } -} - -static dbus_bool_t -impl_get_minimumValue (DBusMessageIter * iter, - void *user_data) -{ - AtkValue *value = (AtkValue *) user_data; - GValue gvalue = { 0, }; - g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE); - atk_value_get_minimum_value (value, &gvalue); - return droute_return_v_double (iter, get_double_from_gvalue (&gvalue)); -} - -static dbus_bool_t -impl_get_maximumValue (DBusMessageIter * iter, - void *user_data) -{ - AtkValue *value = (AtkValue *) user_data; - GValue gvalue = { 0, }; - g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE); - atk_value_get_maximum_value (value, &gvalue); - return droute_return_v_double (iter, get_double_from_gvalue (&gvalue)); -} - -static dbus_bool_t -impl_get_minimumIncrement (DBusMessageIter * iter, - void *user_data) -{ - AtkValue *value = (AtkValue *) user_data; - GValue gvalue = { 0, }; - g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE); - atk_value_get_minimum_value (value, &gvalue); - return droute_return_v_double (iter, get_double_from_gvalue (&gvalue)); -} - -static dbus_bool_t -impl_get_currentValue (DBusMessageIter * iter, - void *user_data) -{ - AtkValue *value = (AtkValue *) user_data; - GValue gvalue = { 0, }; - g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE); - atk_value_get_current_value (value, &gvalue); - return droute_return_v_double (iter, get_double_from_gvalue (&gvalue)); -} - -static dbus_bool_t -impl_set_currentValue (DBusMessageIter * iter, - void *user_data) -{ - AtkValue *value = (AtkValue *) user_data; - GValue gvalue = { 0, }; - double dbl; - - g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE); - if (!get_double_from_variant (iter, &dbl)) - return FALSE; - atk_value_get_current_value (value, &gvalue); - gvalue_set_from_double (&gvalue, dbl); - return TRUE; -} - -static DRouteProperty properties[] = { - {impl_get_minimumValue, NULL, "minimumValue"}, - {impl_get_maximumValue, NULL, "maximumValue"}, - {impl_get_minimumIncrement, NULL, "minimumIncrement"}, - {impl_get_currentValue, impl_set_currentValue, "currentValue"}, - {NULL, NULL, NULL} -}; - -void -spi_initialize_value (DRoutePath *path) -{ - droute_path_add_interface (path, - SPI_DBUS_INTERFACE_VALUE, - NULL, - properties); -}; -- cgit v1.2.1