atk-adaptor library codebase.
+SUBDIRS=adaptors
+
if RELOCATE
gtkmoduledir = $(libdir)/gtk-2.0/modules/at-spi-dbus/modules
else
libatk_bridge_la_CFLAGS = $(DBUS_GLIB_CFLAGS) \
$(ATK_CFLAGS) \
- $(DBIND_CFLAGS) \
- $(DROUTE_CFLAGS) \
-I$(top_srcdir) \
+ -I$(top_srcdir)/atk-adaptor/adaptors \
-DATSPI_INTROSPECTION_PATH=\"$(datarootdir)/$(DEFAULT_ATSPI_INTROSPECTION_PATH)\"
libatk_bridge_la_LDFLAGS = -no-undefined \
libatk_bridge_la_LIBADD = $(DBUS_GLIB_LIBS) \
$(ATK_LIBS) \
- $(DBIND_LIBS) \
- $(DROUTE_LIBS) \
$(X_LIBS) \
$(top_builddir)/droute/libdroute.la \
$(top_builddir)/dbind/libdbind.la \
- $(top_builddir)/common/libspicommon.la
+ $(top_builddir)/common/libspicommon.la \
+ $(top_builddir)/atk-adaptor/adaptors/libatk-bridge-adaptors.la
libatk_bridge_la_SOURCES = \
- accessible-adaptor.c \
- accessible-marshaller.c \
- accessible-marshaller.h \
accessible-register.c \
accessible-register.h \
- action-adaptor.c \
- adaptors.h \
- application-adaptor.c \
bridge.c \
bridge.h \
- collection-adaptor.c \
- component-adaptor.c \
- document-adaptor.c \
- editabletext-adaptor.c \
event.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
+ event.h
if RELOCATE
gtkpathdir = $(gtkmoduledir)/..
+++ /dev/null
-/*
- * 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 <atk/atk.h>
-#include <droute/droute.h>
-
-#include "common/spi-dbus.h"
-#include "common/spi-stateset.h"
-#include "accessible-marshaller.h"
-#include "accessible-register.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 droute_invalid_arguments_error (message);
- }
- child = atk_object_ref_accessible_child (object, i);
- return spi_dbus_return_object (message, child, TRUE, TRUE);
-}
-
-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, FALSE);
- 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, "(ua(so))", &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, "(so)", &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, FALSE);
- if (!path)
- {
- g_warning ("Unknown object in relation type %d\n", type);
- continue;
- }
- spi_dbus_append_name_and_path_inner (&iter_targets, NULL, 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_return_val_if_fail (ATK_IS_OBJECT (datum), g_strdup (""));
- 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;
-
- DBusMessage *reply = NULL;
- DBusMessageIter iter, iter_array;
-
- dbus_uint32_t states[2];
-
- guint count;
-
- g_return_val_if_fail (ATK_IS_OBJECT (user_data),
- droute_not_yet_handled_error (message));
-
- reply = dbus_message_new_method_return (message);
- dbus_message_iter_init_append (reply, &iter);
-
- spi_atk_state_to_dbus_array (object, states);
- dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "u", &iter_array);
- for (count = 0; count < 2; count++)
- {
- dbus_message_iter_append_basic (&iter_array, DBUS_TYPE_UINT32,
- &states[count]);
- }
- dbus_message_iter_close_container (&iter, &iter_array);
- return reply;
-}
-
-static DBusMessage *
-impl_GetAttributes (DBusConnection * bus,
- DBusMessage * message, void *user_data)
-{
- AtkObject *object = (AtkObject *) user_data;
- DBusMessage *reply = NULL;
-
- AtkAttributeSet *attributes;
- DBusMessageIter iter;
-
- g_return_val_if_fail (ATK_IS_OBJECT (user_data),
- droute_not_yet_handled_error (message));
-
- attributes = atk_object_get_attributes (object);
-
- reply = dbus_message_new_method_return (message);
- dbus_message_iter_init_append (reply, &iter);
- spi_atk_append_attribute_set (&iter, attributes);
-
- if (attributes)
- atk_attribute_set_free (attributes);
-
- 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, FALSE);
-}
-
-static DBusMessage *
-impl_GetInterfaces (DBusConnection * bus,
- DBusMessage * message, void *user_data)
-{
- AtkObject *object = (AtkObject *) user_data;
- gint role;
- const char *role_name;
- DBusMessage *reply;
- DBusMessageIter iter, iter_array;
-
- 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)
- {
- dbus_message_iter_init_append (reply, &iter);
- dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "s",
- &iter_array);
- append_atk_object_interfaces (object, &iter_array);
- dbus_message_iter_close_container (&iter, &iter_array);
- }
- return reply;
-}
-
-static DBusMessage *
-impl_Embedded (DBusConnection *bus,
- DBusMessage *message,
- void *user_data)
-{
- AtkObject *object = (AtkObject *) user_data;
- char *path;
- gchar *id;
-
- if (!dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &path, DBUS_TYPE_INVALID))
- {
- return droute_invalid_arguments_error (message);
- }
- id = g_object_get_data (G_OBJECT (object), "dbus-plug-parent");
- if (id)
- g_free (id);
- id = g_strconcat (dbus_message_get_sender (message), ":", path, NULL);
- g_object_set_data (G_OBJECT (object), "dbus-plug-parent", id);
- return dbus_message_new_method_return (message);
-}
-
-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"},
- {impl_GetInterfaces, "GetInterfaces"},
- {impl_Embedded, "Embedded"},
- {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);
-};
+++ /dev/null
-/*
- * 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 <droute/droute.h>
-
-#include "common/spi-dbus.h"
-#include "common/spi-stateset.h"
-
-#include "accessible-register.h"
-#include "accessible-marshaller.h"
-#include "bridge.h"
-
-#include "adaptors.h"
-
-/*---------------------------------------------------------------------------*/
-
-void
-spi_dbus_append_name_and_path_inner (DBusMessageIter * iter,
- const char *bus_name, const char *path)
-{
- DBusMessageIter iter_struct;
-
- if (!bus_name)
- bus_name = "";
- if (!path)
- path = SPI_DBUS_PATH_NULL;
-
- dbus_message_iter_open_container (iter, DBUS_TYPE_STRUCT, NULL,
- &iter_struct);
- dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &bus_name);
- dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH, &path);
- dbus_message_iter_close_container (iter, &iter_struct);
-}
-
-extern gchar *atspi_dbus_name;
-
-void
-spi_dbus_append_name_and_path (DBusMessage * message, DBusMessageIter * iter,
- AtkObject * obj, gboolean do_register,
- gboolean unref)
-{
- gchar *path;
- DBusMessageIter iter_struct;
-
- path = atk_dbus_object_to_path (obj, do_register);
-
- spi_dbus_append_name_and_path_inner (iter, atspi_dbus_name, path);
-
- g_free (path);
- if (obj && unref)
- g_object_unref (obj);
-}
-
-/*
- * 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 do_register, gboolean unref)
-{
- DBusMessage *reply;
- reply = dbus_message_new_method_return (message);
- if (reply)
- {
- DBusMessageIter iter;
- dbus_message_iter_init_append (reply, &iter);
- spi_dbus_append_name_and_path (message, &iter, obj, do_register, unref);
- }
-
- return reply;
-}
-
-DBusMessage *
-spi_dbus_return_hyperlink (DBusMessage * message, AtkHyperlink * link,
- AtkObject * container, gboolean unref)
-{
- return spi_dbus_return_sub_object (message, G_OBJECT (link),
- G_OBJECT (container), unref);
-}
-
-DBusMessage *
-spi_dbus_return_sub_object (DBusMessage * message, GObject * sub,
- GObject * container, gboolean unref)
-{
- DBusMessage *reply;
- gchar *path;
-
- path = atk_dbus_sub_object_to_path (sub, container);
-
- if (sub && unref)
- g_object_unref (sub);
-
- if (!path)
- path = g_strdup (SPI_DBUS_PATH_NULL);
-
- reply = dbus_message_new_method_return (message);
- if (reply)
- {
- dbus_message_append_args (reply, DBUS_TYPE_OBJECT_PATH, &path,
- DBUS_TYPE_INVALID);
- }
-
- g_free (path);
-
- 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)
-{
- DBusMessageIter iter_variant;
- char *path;
-
- path = atk_dbus_object_to_path (obj, FALSE);
-
- if (!path)
- path = g_strdup (SPI_DBUS_PATH_NULL);
-
- if (unref)
- g_object_unref (obj);
-
- dbus_message_iter_open_container (iter, DBUS_TYPE_VARIANT, "(so)",
- &iter_variant);
- spi_dbus_append_name_and_path_inner (&iter_variant, NULL, path);
- dbus_message_iter_close_container (iter, &iter_variant);
- return TRUE;
-}
-
-/*---------------------------------------------------------------------------*/
-
-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);
- }
-}
-
-/*---------------------------------------------------------------------------*/
-
-/*
- * 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 (o(so)a(so)assusau).
- * This is used in the updateTree signal and the GetTree method
- * of the org.freedesktop.atspi.Tree interface.
- *
- * To marshal an object its parent, and all its children must already
- * be registered with D-Bus and have been given a D-Bus object path.
- */
-void
-spi_atk_append_accessible (AtkObject * obj, gpointer data)
-{
- DBusMessageIter iter_struct, iter_sub_array;
- dbus_uint32_t states[2];
- int count;
- AtkStateSet *set;
- DBusMessageIter *iter_array = (DBusMessageIter *) data;
-
- const char *name, *desc;
- dbus_uint32_t role;
-
- set = atk_object_ref_state_set (obj);
- {
- AtkObject *parent;
- gchar *path;
- gchar *bus_parent = NULL, *path_parent;
-
- /* Marshall object path */
- path = atk_dbus_object_to_path (obj, FALSE);
-
- role = spi_accessible_role_from_atk_role (atk_object_get_role (obj));
-
- /* Marshall parent */
- parent = atk_object_get_parent (obj);
- if (parent == NULL)
- {
- /* TODO: Support getting parent of an AtkPlug */
-#ifdef __ATK_PLUG_H__
- if (ATK_IS_PLUG (obj))
- {
- char *id = g_object_get_data (G_OBJECT (obj), "dbus-plug-parent");
- if (id)
- bus_parent = g_strdup (id);
- if (bus_parent && (path_parent = g_utf8_strchr (bus_parent + 1, -1, ':')))
- {
- *(path_parent++) = '\0';
- /* path_parent is going to be freed, so dup it */
- path_parent = g_strdup (path_parent);
- }
- }
- else if (role != Accessibility_ROLE_APPLICATION)
-#else
- if (role != Accessibility_ROLE_APPLICATION)
-#endif
- path_parent = g_strdup (SPI_DBUS_PATH_NULL);
- else
- path_parent = atk_dbus_desktop_object_path ();
- }
- else
- {
- path_parent = atk_dbus_object_to_path (parent, FALSE);
- if (!path_parent)
- {
- /* This should only happen if a widget is re-parented to
- * an AtkObject that has not been registered and is then
- * updated. Ideally objects would be de-registered when
- * they are removed from a registered tree object, but
- * this would invalidate a huge amount of cache when
- * re-parenting.
- */
-#if SPI_ATK_DEBUG
- g_warning
- ("AT-SPI: Registered accessible marshalled when parent not registered");
-#endif
- path_parent = atk_dbus_desktop_object_path ();
- }
- }
-
- dbus_message_iter_open_container (iter_array, DBUS_TYPE_STRUCT, NULL,
- &iter_struct);
- dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH,
- &path);
- spi_dbus_append_name_and_path_inner (&iter_struct, bus_parent,
- path_parent);
- g_free (path_parent);
- g_free (bus_parent);
-
- /* Marshall children */
- dbus_message_iter_open_container (&iter_struct, DBUS_TYPE_ARRAY, "(so)",
- &iter_sub_array);
- if (!atk_state_set_contains_state (set, ATK_STATE_MANAGES_DESCENDANTS))
- {
- 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, FALSE);
- if (child_path)
- {
- spi_dbus_append_name_and_path_inner (&iter_sub_array, NULL,
- child_path);
- g_free (child_path);
- }
- g_object_unref (G_OBJECT (child));
- }
- }
-#ifdef __ATK_PLUG_H__
- if (ATK_IS_SOCKET (obj) && atk_socket_is_occupied (ATK_SOCKET (obj)))
- {
- AtkSocket *socket = ATK_SOCKET (obj);
- gchar *child_name, *child_path;
- child_name = g_strdup (socket->embedded_plug_id);
- child_path = g_utf8_strchr (child_name + 1, -1, ':');
- if (child_path)
- {
- *(child_path++) = '\0';
- spi_dbus_append_name_and_path_inner (&iter_sub_array, child_name,
- child_path);
- }
- g_free (child_name);
- }
-#endif
-
- dbus_message_iter_close_container (&iter_struct, &iter_sub_array);
-
- /* Marshall interfaces */
- 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);
-
- /* Marshall name */
- name = atk_object_get_name (obj);
- if (!name)
- name = "";
- dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &name);
-
- /* Marshall role */
- dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_UINT32, &role);
-
- /* Marshall description */
- desc = atk_object_get_description (obj);
- if (!desc)
- desc = "";
- dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &desc);
-
- g_free (path);
-
- /* Marshall state set */
- spi_atk_state_set_to_dbus_array (set, 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);
- g_object_unref (set);
-}
-
-void
-spi_atk_append_attribute_set (DBusMessageIter * iter, AtkAttributeSet * attr)
-{
- DBusMessageIter dictIter;
-
- dbus_message_iter_open_container (iter, DBUS_TYPE_ARRAY, "{ss}", &dictIter);
- spi_atk_append_attribute_set_inner (&dictIter, attr);
- dbus_message_iter_close_container (iter, &dictIter);
-}
-
-void
-spi_atk_append_attribute_set_inner (DBusMessageIter * iter,
- AtkAttributeSet * attr)
-{
- DBusMessageIter dictEntryIter;
-
- while (attr)
- {
- AtkAttribute *attribute = (AtkAttribute *) attr->data;
- dbus_message_iter_open_container (iter, DBUS_TYPE_DICT_ENTRY, NULL,
- &dictEntryIter);
- dbus_message_iter_append_basic (&dictEntryIter, DBUS_TYPE_STRING,
- &attribute->name);
- dbus_message_iter_append_basic (&dictEntryIter, DBUS_TYPE_STRING,
- &attribute->value);
- dbus_message_iter_close_container (iter, &dictEntryIter);
- attr = g_slist_next (attr);
- }
-}
-
-/*END------------------------------------------------------------------------*/
+++ /dev/null
-/*
- * 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 <dbus/dbus.h>
-#include <atk/atk.h>
-
-void
-spi_dbus_append_name_and_path_inner (DBusMessageIter * iter,
- const char *bus_name, const char *path);
-
-void
-spi_dbus_append_name_and_path (DBusMessage * message, DBusMessageIter * iter,
- AtkObject * obj, gboolean do_register,
- gboolean unref);
-
-DBusMessage *spi_dbus_return_object (DBusMessage * message, AtkObject * obj,
- gboolean do_register, gboolean unref);
-
-DBusMessage *spi_dbus_return_hyperlink (DBusMessage * message,
- AtkHyperlink * link,
- AtkObject * container,
- gboolean unref);
-
-DBusMessage *spi_dbus_return_sub_object (DBusMessage * message, GObject * sub,
- GObject * container, gboolean unref);
-
-dbus_bool_t
-spi_dbus_return_v_object (DBusMessageIter * iter, AtkObject * obj, int unref);
-
-void spi_atk_append_accessible (AtkObject * obj, gpointer iter);
-
-void
-spi_atk_append_attribute_set (DBusMessageIter * iter, AtkAttributeSet * attr);
-
-void
-spi_atk_append_attribute_set_inner (DBusMessageIter * iter,
- AtkAttributeSet * attr);
-
-void
-append_atk_object_interfaces (AtkObject * object, DBusMessageIter * iter);
-#endif /* ACCESSIBLE_MARSHALLER */
+++ /dev/null
-/*
- * 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 <atk/atk.h>
-#include <droute/droute.h>
-
-#include "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 droute_invalid_arguments_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 droute_invalid_arguments_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 droute_invalid_arguments_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 droute_invalid_arguments_error (message);
- }
- 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);
-};
+++ /dev/null
-/*
- * 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 <atk/atk.h>
-#include <droute/droute.h>
-
-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 */
--- /dev/null
+noinst_LTLIBRARIES = libatk-bridge-adaptors.la
+
+libatk_bridge_adaptors_la_CFLAGS =\
+ $(DBUS_GLIB_CFLAGS) \
+ $(ATK_CFLAGS) \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/atk-adaptor\
+ -DATSPI_INTROSPECTION_PATH=\"$(datarootdir)/$(DEFAULT_ATSPI_INTROSPECTION_PATH)\"
+
+libatk_bridge_adaptors_la_LIBADD =\
+ $(DBUS_GLIB_LIBS) \
+ $(ATK_LIBS) \
+ $(X_LIBS)
+
+libatk_bridge_adaptors_la_SOURCES =\
+ accessible-adaptor.c \
+ accessible-marshaller.c \
+ accessible-marshaller.h \
+ action-adaptor.c \
+ adaptors.h \
+ application-adaptor.c \
+ collection-adaptor.c \
+ component-adaptor.c \
+ document-adaptor.c \
+ editabletext-adaptor.c \
+ 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
--- /dev/null
+/*
+ * 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 <atk/atk.h>
+#include <droute/droute.h>
+
+#include "common/spi-dbus.h"
+#include "common/spi-stateset.h"
+#include "accessible-marshaller.h"
+#include "accessible-register.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 droute_invalid_arguments_error (message);
+ }
+ child = atk_object_ref_accessible_child (object, i);
+ return spi_dbus_return_object (message, child, TRUE, TRUE);
+}
+
+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, FALSE);
+ 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, "(ua(so))", &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, "(so)", &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, FALSE);
+ if (!path)
+ {
+ g_warning ("Unknown object in relation type %d\n", type);
+ continue;
+ }
+ spi_dbus_append_name_and_path_inner (&iter_targets, NULL, 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_return_val_if_fail (ATK_IS_OBJECT (datum), g_strdup (""));
+ 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;
+
+ DBusMessage *reply = NULL;
+ DBusMessageIter iter, iter_array;
+
+ dbus_uint32_t states[2];
+
+ guint count;
+
+ g_return_val_if_fail (ATK_IS_OBJECT (user_data),
+ droute_not_yet_handled_error (message));
+
+ reply = dbus_message_new_method_return (message);
+ dbus_message_iter_init_append (reply, &iter);
+
+ spi_atk_state_to_dbus_array (object, states);
+ dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "u", &iter_array);
+ for (count = 0; count < 2; count++)
+ {
+ dbus_message_iter_append_basic (&iter_array, DBUS_TYPE_UINT32,
+ &states[count]);
+ }
+ dbus_message_iter_close_container (&iter, &iter_array);
+ return reply;
+}
+
+static DBusMessage *
+impl_GetAttributes (DBusConnection * bus,
+ DBusMessage * message, void *user_data)
+{
+ AtkObject *object = (AtkObject *) user_data;
+ DBusMessage *reply = NULL;
+
+ AtkAttributeSet *attributes;
+ DBusMessageIter iter;
+
+ g_return_val_if_fail (ATK_IS_OBJECT (user_data),
+ droute_not_yet_handled_error (message));
+
+ attributes = atk_object_get_attributes (object);
+
+ reply = dbus_message_new_method_return (message);
+ dbus_message_iter_init_append (reply, &iter);
+ spi_atk_append_attribute_set (&iter, attributes);
+
+ if (attributes)
+ atk_attribute_set_free (attributes);
+
+ 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, FALSE);
+}
+
+static DBusMessage *
+impl_GetInterfaces (DBusConnection * bus,
+ DBusMessage * message, void *user_data)
+{
+ AtkObject *object = (AtkObject *) user_data;
+ gint role;
+ const char *role_name;
+ DBusMessage *reply;
+ DBusMessageIter iter, iter_array;
+
+ 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)
+ {
+ dbus_message_iter_init_append (reply, &iter);
+ dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "s",
+ &iter_array);
+ append_atk_object_interfaces (object, &iter_array);
+ dbus_message_iter_close_container (&iter, &iter_array);
+ }
+ return reply;
+}
+
+static DBusMessage *
+impl_Embedded (DBusConnection *bus,
+ DBusMessage *message,
+ void *user_data)
+{
+ AtkObject *object = (AtkObject *) user_data;
+ char *path;
+ gchar *id;
+
+ if (!dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &path, DBUS_TYPE_INVALID))
+ {
+ return droute_invalid_arguments_error (message);
+ }
+ id = g_object_get_data (G_OBJECT (object), "dbus-plug-parent");
+ if (id)
+ g_free (id);
+ id = g_strconcat (dbus_message_get_sender (message), ":", path, NULL);
+ g_object_set_data (G_OBJECT (object), "dbus-plug-parent", id);
+ return dbus_message_new_method_return (message);
+}
+
+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"},
+ {impl_GetInterfaces, "GetInterfaces"},
+ {impl_Embedded, "Embedded"},
+ {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);
+};
--- /dev/null
+/*
+ * 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 <droute/droute.h>
+
+#include "common/spi-dbus.h"
+#include "common/spi-stateset.h"
+
+#include "accessible-register.h"
+#include "accessible-marshaller.h"
+#include "bridge.h"
+
+#include "adaptors.h"
+
+/*---------------------------------------------------------------------------*/
+
+void
+spi_dbus_append_name_and_path_inner (DBusMessageIter * iter,
+ const char *bus_name, const char *path)
+{
+ DBusMessageIter iter_struct;
+
+ if (!bus_name)
+ bus_name = "";
+ if (!path)
+ path = SPI_DBUS_PATH_NULL;
+
+ dbus_message_iter_open_container (iter, DBUS_TYPE_STRUCT, NULL,
+ &iter_struct);
+ dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &bus_name);
+ dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH, &path);
+ dbus_message_iter_close_container (iter, &iter_struct);
+}
+
+extern gchar *atspi_dbus_name;
+
+void
+spi_dbus_append_name_and_path (DBusMessage * message, DBusMessageIter * iter,
+ AtkObject * obj, gboolean do_register,
+ gboolean unref)
+{
+ gchar *path;
+ DBusMessageIter iter_struct;
+
+ path = atk_dbus_object_to_path (obj, do_register);
+
+ spi_dbus_append_name_and_path_inner (iter, atspi_dbus_name, path);
+
+ g_free (path);
+ if (obj && unref)
+ g_object_unref (obj);
+}
+
+/*
+ * 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 do_register, gboolean unref)
+{
+ DBusMessage *reply;
+ reply = dbus_message_new_method_return (message);
+ if (reply)
+ {
+ DBusMessageIter iter;
+ dbus_message_iter_init_append (reply, &iter);
+ spi_dbus_append_name_and_path (message, &iter, obj, do_register, unref);
+ }
+
+ return reply;
+}
+
+DBusMessage *
+spi_dbus_return_hyperlink (DBusMessage * message, AtkHyperlink * link,
+ AtkObject * container, gboolean unref)
+{
+ return spi_dbus_return_sub_object (message, G_OBJECT (link),
+ G_OBJECT (container), unref);
+}
+
+DBusMessage *
+spi_dbus_return_sub_object (DBusMessage * message, GObject * sub,
+ GObject * container, gboolean unref)
+{
+ DBusMessage *reply;
+ gchar *path;
+
+ path = atk_dbus_sub_object_to_path (sub, container);
+
+ if (sub && unref)
+ g_object_unref (sub);
+
+ if (!path)
+ path = g_strdup (SPI_DBUS_PATH_NULL);
+
+ reply = dbus_message_new_method_return (message);
+ if (reply)
+ {
+ dbus_message_append_args (reply, DBUS_TYPE_OBJECT_PATH, &path,
+ DBUS_TYPE_INVALID);
+ }
+
+ g_free (path);
+
+ 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)
+{
+ DBusMessageIter iter_variant;
+ char *path;
+
+ path = atk_dbus_object_to_path (obj, FALSE);
+
+ if (!path)
+ path = g_strdup (SPI_DBUS_PATH_NULL);
+
+ if (unref)
+ g_object_unref (obj);
+
+ dbus_message_iter_open_container (iter, DBUS_TYPE_VARIANT, "(so)",
+ &iter_variant);
+ spi_dbus_append_name_and_path_inner (&iter_variant, NULL, path);
+ dbus_message_iter_close_container (iter, &iter_variant);
+ return TRUE;
+}
+
+/*---------------------------------------------------------------------------*/
+
+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);
+ }
+}
+
+/*---------------------------------------------------------------------------*/
+
+/*
+ * 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 (o(so)a(so)assusau).
+ * This is used in the updateTree signal and the GetTree method
+ * of the org.freedesktop.atspi.Tree interface.
+ *
+ * To marshal an object its parent, and all its children must already
+ * be registered with D-Bus and have been given a D-Bus object path.
+ */
+void
+spi_atk_append_accessible (AtkObject * obj, gpointer data)
+{
+ DBusMessageIter iter_struct, iter_sub_array;
+ dbus_uint32_t states[2];
+ int count;
+ AtkStateSet *set;
+ DBusMessageIter *iter_array = (DBusMessageIter *) data;
+
+ const char *name, *desc;
+ dbus_uint32_t role;
+
+ set = atk_object_ref_state_set (obj);
+ {
+ AtkObject *parent;
+ gchar *path;
+ gchar *bus_parent = NULL, *path_parent;
+
+ /* Marshall object path */
+ path = atk_dbus_object_to_path (obj, FALSE);
+
+ role = spi_accessible_role_from_atk_role (atk_object_get_role (obj));
+
+ /* Marshall parent */
+ parent = atk_object_get_parent (obj);
+ if (parent == NULL)
+ {
+ /* TODO: Support getting parent of an AtkPlug */
+#ifdef __ATK_PLUG_H__
+ if (ATK_IS_PLUG (obj))
+ {
+ char *id = g_object_get_data (G_OBJECT (obj), "dbus-plug-parent");
+ if (id)
+ bus_parent = g_strdup (id);
+ if (bus_parent && (path_parent = g_utf8_strchr (bus_parent + 1, -1, ':')))
+ {
+ *(path_parent++) = '\0';
+ /* path_parent is going to be freed, so dup it */
+ path_parent = g_strdup (path_parent);
+ }
+ }
+ else if (role != Accessibility_ROLE_APPLICATION)
+#else
+ if (role != Accessibility_ROLE_APPLICATION)
+#endif
+ path_parent = g_strdup (SPI_DBUS_PATH_NULL);
+ else
+ path_parent = atk_dbus_desktop_object_path ();
+ }
+ else
+ {
+ path_parent = atk_dbus_object_to_path (parent, FALSE);
+ if (!path_parent)
+ {
+ /* This should only happen if a widget is re-parented to
+ * an AtkObject that has not been registered and is then
+ * updated. Ideally objects would be de-registered when
+ * they are removed from a registered tree object, but
+ * this would invalidate a huge amount of cache when
+ * re-parenting.
+ */
+#if SPI_ATK_DEBUG
+ g_warning
+ ("AT-SPI: Registered accessible marshalled when parent not registered");
+#endif
+ path_parent = atk_dbus_desktop_object_path ();
+ }
+ }
+
+ dbus_message_iter_open_container (iter_array, DBUS_TYPE_STRUCT, NULL,
+ &iter_struct);
+ dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH,
+ &path);
+ spi_dbus_append_name_and_path_inner (&iter_struct, bus_parent,
+ path_parent);
+ g_free (path_parent);
+ g_free (bus_parent);
+
+ /* Marshall children */
+ dbus_message_iter_open_container (&iter_struct, DBUS_TYPE_ARRAY, "(so)",
+ &iter_sub_array);
+ if (!atk_state_set_contains_state (set, ATK_STATE_MANAGES_DESCENDANTS))
+ {
+ 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, FALSE);
+ if (child_path)
+ {
+ spi_dbus_append_name_and_path_inner (&iter_sub_array, NULL,
+ child_path);
+ g_free (child_path);
+ }
+ g_object_unref (G_OBJECT (child));
+ }
+ }
+#ifdef __ATK_PLUG_H__
+ if (ATK_IS_SOCKET (obj) && atk_socket_is_occupied (ATK_SOCKET (obj)))
+ {
+ AtkSocket *socket = ATK_SOCKET (obj);
+ gchar *child_name, *child_path;
+ child_name = g_strdup (socket->embedded_plug_id);
+ child_path = g_utf8_strchr (child_name + 1, -1, ':');
+ if (child_path)
+ {
+ *(child_path++) = '\0';
+ spi_dbus_append_name_and_path_inner (&iter_sub_array, child_name,
+ child_path);
+ }
+ g_free (child_name);
+ }
+#endif
+
+ dbus_message_iter_close_container (&iter_struct, &iter_sub_array);
+
+ /* Marshall interfaces */
+ 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);
+
+ /* Marshall name */
+ name = atk_object_get_name (obj);
+ if (!name)
+ name = "";
+ dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &name);
+
+ /* Marshall role */
+ dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_UINT32, &role);
+
+ /* Marshall description */
+ desc = atk_object_get_description (obj);
+ if (!desc)
+ desc = "";
+ dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &desc);
+
+ g_free (path);
+
+ /* Marshall state set */
+ spi_atk_state_set_to_dbus_array (set, 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);
+ g_object_unref (set);
+}
+
+void
+spi_atk_append_attribute_set (DBusMessageIter * iter, AtkAttributeSet * attr)
+{
+ DBusMessageIter dictIter;
+
+ dbus_message_iter_open_container (iter, DBUS_TYPE_ARRAY, "{ss}", &dictIter);
+ spi_atk_append_attribute_set_inner (&dictIter, attr);
+ dbus_message_iter_close_container (iter, &dictIter);
+}
+
+void
+spi_atk_append_attribute_set_inner (DBusMessageIter * iter,
+ AtkAttributeSet * attr)
+{
+ DBusMessageIter dictEntryIter;
+
+ while (attr)
+ {
+ AtkAttribute *attribute = (AtkAttribute *) attr->data;
+ dbus_message_iter_open_container (iter, DBUS_TYPE_DICT_ENTRY, NULL,
+ &dictEntryIter);
+ dbus_message_iter_append_basic (&dictEntryIter, DBUS_TYPE_STRING,
+ &attribute->name);
+ dbus_message_iter_append_basic (&dictEntryIter, DBUS_TYPE_STRING,
+ &attribute->value);
+ dbus_message_iter_close_container (iter, &dictEntryIter);
+ attr = g_slist_next (attr);
+ }
+}
+
+/*END------------------------------------------------------------------------*/
--- /dev/null
+/*
+ * 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 <dbus/dbus.h>
+#include <atk/atk.h>
+
+void
+spi_dbus_append_name_and_path_inner (DBusMessageIter * iter,
+ const char *bus_name, const char *path);
+
+void
+spi_dbus_append_name_and_path (DBusMessage * message, DBusMessageIter * iter,
+ AtkObject * obj, gboolean do_register,
+ gboolean unref);
+
+DBusMessage *spi_dbus_return_object (DBusMessage * message, AtkObject * obj,
+ gboolean do_register, gboolean unref);
+
+DBusMessage *spi_dbus_return_hyperlink (DBusMessage * message,
+ AtkHyperlink * link,
+ AtkObject * container,
+ gboolean unref);
+
+DBusMessage *spi_dbus_return_sub_object (DBusMessage * message, GObject * sub,
+ GObject * container, gboolean unref);
+
+dbus_bool_t
+spi_dbus_return_v_object (DBusMessageIter * iter, AtkObject * obj, int unref);
+
+void spi_atk_append_accessible (AtkObject * obj, gpointer iter);
+
+void
+spi_atk_append_attribute_set (DBusMessageIter * iter, AtkAttributeSet * attr);
+
+void
+spi_atk_append_attribute_set_inner (DBusMessageIter * iter,
+ AtkAttributeSet * attr);
+
+void
+append_atk_object_interfaces (AtkObject * object, DBusMessageIter * iter);
+#endif /* ACCESSIBLE_MARSHALLER */
--- /dev/null
+/*
+ * 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 <atk/atk.h>
+#include <droute/droute.h>
+
+#include "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 droute_invalid_arguments_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 droute_invalid_arguments_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 droute_invalid_arguments_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 droute_invalid_arguments_error (message);
+ }
+ 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);
+};
--- /dev/null
+/*
+ * 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 <atk/atk.h>
+#include <droute/droute.h>
+
+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 */
--- /dev/null
+/*
+ * 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 <atk/atk.h>
+#include <droute/droute.h>
+
+#include "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);
+};
--- /dev/null
+/*
+ * 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 <string.h>
+
+#include <atk/atk.h>
+#include <droute/droute.h>
+
+#include "accessible-register.h"
+#include "accessible-marshaller.h"
+
+#include "common/bitarray.h"
+#include "common/spi-dbus.h"
+#include "common/spi-stateset.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)
+{
+ 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)
+{
+ Accessibility_Role role;
+ int i;
+
+ if (roles == NULL || roles[0] == BITARRAY_SEQ_TERM)
+ return TRUE;
+
+ role = spi_accessible_role_from_atk_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 gboolean
+bitarray_to_seq (int *array, int array_count, int **ret)
+{
+ int out_size = 4;
+ int out_count = 0;
+ int i, j;
+ int *out = (int *) g_malloc (out_size * sizeof (int));
+
+ if (!out)
+ return FALSE;
+ for (i = 0; i < array_count; i++)
+ {
+ for (j = 0; j < 32; j++)
+ {
+ if (array[i] & (1 << j))
+ {
+ if (out_count == out_size - 2)
+ {
+ out_size <<= 1;
+ out = (int *) g_realloc (out, out_size * sizeof (int));
+ if (!out)
+ return FALSE;
+ }
+ out[out_count++] = i * 32 + j;
+ }
+ }
+ }
+ out[out_count] = BITARRAY_SEQ_TERM;
+ *ret = out;
+ return TRUE;
+}
+
+
+static dbus_bool_t
+read_mr (DBusMessageIter * iter, MatchRulePrivate * mrp)
+{
+ DBusMessageIter mrc, arrayc;
+ dbus_uint32_t *array;
+ dbus_int32_t matchType;
+ int array_count;
+ AtkAttribute *attr;
+ int i;
+ const char *str;
+ char *interfaces = NULL;
+
+ 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_get_basic (&mrc, &matchType);
+ dbus_message_iter_next (&mrc);
+ mrp->statematchtype = matchType;;
+ /* attributes */
+ mrp->attributes = NULL;
+ if (dbus_message_iter_get_arg_type (&mrc) == DBUS_TYPE_STRING)
+ {
+ char *str;
+ gchar **attributes;
+ gchar **pp;
+ dbus_message_iter_get_basic (&mrc, &str);
+ attributes = g_strsplit (str, "\n", -1);
+ for (pp = attributes; *pp; pp++)
+ {
+ str = *pp;
+ 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);
+ }
+ }
+ g_strfreev (attributes);
+ }
+ else
+ {
+ dbus_message_iter_recurse (&mrc, &arrayc);
+ 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_get_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_get_basic (&mrc, &matchType);
+ mrp->rolematchtype = matchType;;
+ dbus_message_iter_next (&mrc);
+ /* Get interfaces and interface match */
+ dbus_message_iter_get_basic (&mrc, &interfaces);
+ dbus_message_iter_next (&mrc);
+ mrp->ifaces = g_strsplit (interfaces, ";", 0);
+ dbus_message_iter_get_basic (&mrc, &matchType);
+ mrp->interfacematchtype = matchType;;
+ dbus_message_iter_next (&mrc);
+ /* get invert */
+ dbus_message_iter_get_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, "(so)", &iter_array))
+ goto oom;
+ for (item = ls; item; item = g_list_next (item))
+ {
+ spi_dbus_append_name_and_path (message, &iter_array,
+ ATK_OBJECT (item->data), TRUE, FALSE);
+ }
+ 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_uint32_t sortby;
+ dbus_uint32_t tree;
+ dbus_int32_t count;
+ dbus_bool_t traverse;
+ GList *ls = NULL;
+ const char *signature;
+
+ signature = dbus_message_get_signature (message);
+ if (strcmp (signature, "o(aiisiaiisib)uuib") != 0 &&
+ strcmp (signature, "o(aii(as)iaiisib)uuib") != 0)
+ {
+ return droute_invalid_arguments_error (message);
+ }
+
+ dbus_message_iter_init (message, &iter);
+ dbus_message_iter_get_basic (&iter, ¤t_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_uint32_t sortby;
+ dbus_uint32_t tree;
+ dbus_bool_t recurse;
+ dbus_int32_t count;
+ dbus_bool_t traverse;
+ GList *ls = NULL;
+ const char *signature;
+
+ signature = dbus_message_get_signature (message);
+ if (strcmp (signature, "o(aiisiaiisib)uubib") != 0 &&
+ strcmp (signature, "o(aii(as)iaiisib)uubib") != 0)
+ {
+ return droute_invalid_arguments_error (message);
+ }
+
+ dbus_message_iter_init (message, &iter);
+ dbus_message_iter_get_basic (&iter, ¤t_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 = atk_dbus_path_to_object (dbus_message_get_path (message));
+ DBusMessageIter iter;
+ MatchRulePrivate rule;
+ dbus_uint32_t sortby;
+ dbus_int32_t count;
+ dbus_bool_t traverse;
+ GList *ls = NULL;
+ const char *signature;
+
+ signature = dbus_message_get_signature (message);
+ if (strcmp (signature, "(aiisiaiisib)uib") != 0 &&
+ strcmp (signature, "(aii(as)iaiisib)uib") != 0)
+ {
+ return droute_invalid_arguments_error (message);
+ }
+
+ 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);
+};
--- /dev/null
+/*
+ * 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 <atk/atk.h>
+#include <droute/droute.h>
+
+#include "accessible-marshaller.h"
+#include "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_uint32_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_UINT32, &coord_type, DBUS_TYPE_INVALID))
+ {
+ return droute_invalid_arguments_error (message);
+ }
+ 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_uint32_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_UINT32, &coord_type, DBUS_TYPE_INVALID))
+ {
+ return droute_invalid_arguments_error (message);
+ }
+ child =
+ atk_component_ref_accessible_at_point (component, x, y,
+ (AtkCoordType) coord_type);
+ return spi_dbus_return_object (message, child, TRUE, TRUE);
+}
+
+static DBusMessage *
+impl_GetExtents (DBusConnection * bus, DBusMessage * message, void *user_data)
+{
+ AtkComponent *component = (AtkComponent *) user_data;
+ DBusError error;
+ dbus_uint32_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_UINT32, &coord_type, DBUS_TYPE_INVALID))
+ {
+ return droute_invalid_arguments_error (message);
+ }
+ 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_uint32_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_UINT32, &coord_type, DBUS_TYPE_INVALID))
+ {
+ return droute_invalid_arguments_error (message);
+ }
+ 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);
+};
--- /dev/null
+/*
+ * 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 <atk/atk.h>
+#include <droute/droute.h>
+
+#include "common/spi-dbus.h"
+
+#include "accessible-marshaller.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 droute_invalid_arguments_error (message);
+ }
+ 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;
+ DBusMessageIter iter;
+
+ g_return_val_if_fail (ATK_IS_DOCUMENT (user_data),
+ droute_not_yet_handled_error (message));
+
+ attributes = atk_document_get_attributes (document);
+
+ reply = dbus_message_new_method_return (message);
+ if (reply)
+ {
+ dbus_message_iter_init_append (reply, &iter);
+ spi_atk_append_attribute_set (&iter, attributes);
+ }
+
+ if (attributes)
+ atk_attribute_set_free (attributes);
+ 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);
+};
--- /dev/null
+/*
+ * 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 <atk/atk.h>
+#include <droute/droute.h>
+
+#include "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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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_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 droute_invalid_arguments_error (message);
+ }
+ atk_editable_text_copy_text (editable, startPos, endPos);
+ return dbus_message_new_method_return (message);
+}
+
+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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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_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);
+};
--- /dev/null
+/*
+ * 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 <atk/atk.h>
+#include <droute/droute.h>
+
+#include "accessible-marshaller.h"
+#include "common/spi-dbus.h"
+
+static AtkHyperlink *
+get_hyperlink (void *user_data)
+{
+ if (ATK_IS_HYPERLINK (user_data))
+ return ATK_HYPERLINK (user_data);
+ if (ATK_IS_HYPERLINK_IMPL (user_data))
+ return atk_hyperlink_impl_get_hyperlink (ATK_HYPERLINK_IMPL (user_data));
+ return NULL;
+}
+
+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 = get_hyperlink (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 = get_hyperlink (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 = get_hyperlink (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 droute_invalid_arguments_error (message);
+ }
+ atk_object = atk_hyperlink_get_object (link, i);
+ return spi_dbus_return_sub_object (message, G_OBJECT (atk_object),
+ G_OBJECT (link), FALSE);
+}
+
+static DBusMessage *
+impl_GetURI (DBusConnection * bus, DBusMessage * message, void *user_data)
+{
+ AtkHyperlink *link = get_hyperlink (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_INVALID))
+ {
+ return droute_invalid_arguments_error (message);
+ }
+
+ 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 = get_hyperlink (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);
+};
--- /dev/null
+/*
+ * 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 <atk/atk.h>
+#include <droute/droute.h>
+
+#include "common/spi-dbus.h"
+#include "accessible-marshaller.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 droute_invalid_arguments_error (message);
+ }
+ link = atk_hypertext_get_link (hypertext, linkIndex);
+ return spi_dbus_return_hyperlink (message, link, ATK_OBJECT (hypertext),
+ TRUE);
+}
+
+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 droute_invalid_arguments_error (message);
+ }
+ 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);
+};
--- /dev/null
+/*
+ * 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 <atk/atk.h>
+#include <droute/droute.h>
+
+#include "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_uint32_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_UINT32, &coordType, DBUS_TYPE_INVALID))
+ {
+ return droute_invalid_arguments_error (message);
+ }
+ 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_uint32_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_UINT32, &coord_type, DBUS_TYPE_INVALID))
+ {
+ return droute_invalid_arguments_error (message);
+ }
+ 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);
+};
--- /dev/null
+/*
+ * 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 <config.h>
+#include <stdio.h>
+
+#include <atk/atk.h>
+#include <droute/droute.h>
+
+#include "common/spi-types.h"
+#include "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_NODE_PARENT_OF] = Accessibility_RELATION_NODE_PARENT_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)
--- /dev/null
+/*
+ * 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 <atk/atk.h>
+#include <droute/droute.h>
+
+#include "common/spi-dbus.h"
+#include "accessible-marshaller.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_return_val_if_fail (ATK_IS_SELECTION (user_data), FALSE);
+ 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 droute_invalid_arguments_error (message);
+ }
+ atk_object = atk_selection_ref_selection (selection, selectedChildIndex);
+ return spi_dbus_return_object (message, atk_object, TRUE, 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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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);
+};
--- /dev/null
+/*
+ * 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 <config.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <libspi/component.h>
+#include <libspi/streamablecontent.h>
+
+/* 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)
--- /dev/null
+/*
+ * 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 <atk/atk.h>
+#include <droute/droute.h>
+
+#include "accessible-marshaller.h"
+#include "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 droute_invalid_arguments_error (message);
+ }
+ obj = atk_table_ref_at (table, row, column);
+ return spi_dbus_return_object (message, obj, TRUE, 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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ obj = atk_table_get_row_header (table, row);
+ obj = atk_table_get_row_header (table, row);
+ return spi_dbus_return_object (message, obj, TRUE, 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 droute_invalid_arguments_error (message);
+ }
+ obj = atk_table_get_column_header (table, column);
+ obj = atk_table_get_column_header (table, column);
+ return spi_dbus_return_object (message, obj, TRUE, 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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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_BOOLEAN, &ret,
+ 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_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);
+};
--- /dev/null
+/*
+ * 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 <string.h>
+
+#include <atk/atk.h>
+#include <droute/droute.h>
+
+#include "common/spi-dbus.h"
+
+#include "accessible-marshaller.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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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_STRING, &txt,
+ DBUS_TYPE_INT32, &startOffset,
+ DBUS_TYPE_INT32, &endOffset,
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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_STRING, &txt,
+ DBUS_TYPE_INT32, &startOffset,
+ DBUS_TYPE_INT32, &endOffset,
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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_STRING, &txt,
+ DBUS_TYPE_INT32, &startOffset,
+ DBUS_TYPE_INT32, &endOffset,
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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 = NULL;
+ 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 droute_invalid_arguments_error (message);
+ }
+
+ 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_STRING, &rv, DBUS_TYPE_INT32,
+ &startOffset, DBUS_TYPE_INT32, &endOffset,
+ DBUS_TYPE_BOOLEAN, &defined,
+ 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;
+ DBusError error;
+ DBusMessage *reply;
+ AtkAttributeSet *set;
+ DBusMessageIter iter;
+
+ 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 droute_invalid_arguments_error (message);
+ }
+
+ set = atk_text_get_run_attributes (text, offset,
+ &intstart_offset, &intend_offset);
+
+ startOffset = intstart_offset;
+ endOffset = intend_offset;
+ reply = dbus_message_new_method_return (message);
+ if (reply)
+ {
+ dbus_message_iter_init_append (reply, &iter);
+ spi_atk_append_attribute_set (&iter, set);
+ dbus_message_append_args (reply, DBUS_TYPE_INT32, &startOffset,
+ DBUS_TYPE_INT32, &endOffset,
+ DBUS_TYPE_INVALID);
+ }
+ atk_attribute_set_free (set);
+ return reply;
+}
+
+static DBusMessage *
+impl_GetDefaultAttributes (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
+{
+ AtkText *text = (AtkText *) user_data;
+ DBusError error;
+ DBusMessage *reply;
+ AtkAttributeSet *set;
+ DBusMessageIter iter;
+
+ 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);
+ reply = dbus_message_new_method_return (message);
+ if (reply)
+ {
+ dbus_message_iter_init_append (reply, &iter);
+ spi_atk_append_attribute_set (&iter, set);
+ }
+ 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_uint32_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_UINT32,
+ &coordType, DBUS_TYPE_INVALID))
+ {
+ return droute_invalid_arguments_error (message);
+ }
+ 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_uint32_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_UINT32, &coordType, DBUS_TYPE_INVALID))
+ {
+ return droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ /* 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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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 droute_invalid_arguments_error (message);
+ }
+ 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_uint32_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_UINT32, &coordType, DBUS_TYPE_INVALID))
+ {
+ return droute_invalid_arguments_error (message);
+ }
+ 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_uint32_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_UINT32,
+ &coordType, DBUS_TYPE_UINT32, &xClipType, DBUS_TYPE_UINT32, &yClipType,
+ DBUS_TYPE_INVALID))
+ {
+ return droute_invalid_arguments_error (message);
+ }
+ 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
+ (&struc, 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;
+ DBusMessageIter iter, iterArray;
+
+ 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 droute_invalid_arguments_error (message);
+ }
+
+ attributes =
+ atk_text_get_run_attributes (text, offset, &intstart_offset,
+ &intend_offset);
+
+ reply = dbus_message_new_method_return (message);
+ if (!reply)
+ return NULL;
+
+ dbus_message_iter_init_append (reply, &iter);
+ dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "{ss}",
+ &iterArray);
+ spi_atk_append_attribute_set_inner (&iterArray, attributes);
+ if (includeDefaults)
+ {
+ default_attributes = atk_text_get_default_attributes (text);
+ spi_atk_append_attribute_set_inner (&iterArray, default_attributes);
+ }
+ dbus_message_iter_close_container (&iter, &iterArray);
+
+ startOffset = intstart_offset;
+ endOffset = intend_offset;
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &startOffset);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &endOffset);
+
+ atk_attribute_set_free (attributes);
+ if (default_attributes)
+ atk_attribute_set_free (default_attributes);
+
+ return reply;
+}
+
+static DBusMessage *
+impl_GetDefaultAttributeSet (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
+{
+ AtkText *text = (AtkText *) user_data;
+ DBusMessage *reply;
+ DBusMessageIter iter;
+ AtkAttributeSet *attributes;
+
+ g_return_val_if_fail (ATK_IS_TEXT (user_data),
+ droute_not_yet_handled_error (message));
+
+ attributes = atk_text_get_default_attributes (text);
+
+ reply = dbus_message_new_method_return (message);
+ if (reply)
+ {
+ dbus_message_iter_init_append (reply, &iter);
+ spi_atk_append_attribute_set (&iter, attributes);
+ }
+
+ if (attributes)
+ atk_attribute_set_free (attributes);
+
+ 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);
+};
--- /dev/null
+/*
+ * 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 <string.h>
+
+#include <atk/atk.h>
+#include <droute/droute.h>
+
+#include "bridge.h"
+#include "accessible-register.h"
+#include "accessible-marshaller.h"
+#include "common/spi-dbus.h"
+
+/*---------------------------------------------------------------------------*/
+
+/* For use as a GHFunc */
+static void
+append_accessible_hf (gpointer key, gpointer obj_data, gpointer data)
+{
+ /* Make sure it isn't a hyperlink */
+ if (ATK_IS_OBJECT (obj_data))
+ spi_atk_append_accessible (ATK_OBJECT (obj_data), data);
+}
+
+/*---------------------------------------------------------------------------*/
+
+void
+spi_emit_cache_removal (guint ref, DBusConnection * bus)
+{
+ DBusMessage *message;
+
+ if ((message = dbus_message_new_signal ("/org/freedesktop/atspi/tree",
+ SPI_DBUS_INTERFACE_TREE,
+ "RemoveAccessible")))
+ {
+ DBusMessageIter iter;
+ gchar *path;
+
+ 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);
+
+ dbus_message_unref (message);
+ }
+}
+
+void
+spi_emit_cache_update (AtkObject * accessible, DBusConnection * bus)
+{
+ DBusMessage *message;
+
+ if ((message = dbus_message_new_signal ("/org/freedesktop/atspi/tree",
+ SPI_DBUS_INTERFACE_TREE,
+ "UpdateAccessible")))
+ {
+ DBusMessageIter iter;
+
+ dbus_message_iter_init_append (message, &iter);
+ spi_atk_append_accessible (accessible, &iter);
+
+ dbus_connection_send (bus, message, NULL);
+
+ dbus_message_unref (message);
+ }
+}
+
+
+/*---------------------------------------------------------------------------*/
+
+static DBusMessage *
+impl_GetRoot (DBusConnection * bus, DBusMessage * message, void *user_data)
+{
+ AtkObject *root = atk_get_root ();
+ char *path;
+ DBusMessage *reply;
+ gchar *errmsg;
+
+ if (!root)
+ {
+ reply = dbus_message_new_error (message,
+ DBUS_ERROR_FAILED,
+ "No root accessible available");
+ }
+ path = atk_dbus_object_to_path (root, FALSE);
+ if (!path)
+ {
+ reply = dbus_message_new_error (message,
+ DBUS_ERROR_FAILED,
+ "No root accessible available");
+ }
+ 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,
+ "(o(so)a(so)assusau)", &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------------------------------------------------------------------------*/
--- /dev/null
+/*
+ * 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 <atk/atk.h>
+#include <dbus/dbus.h>
+
+void spi_emit_cache_update (AtkObject * accessible, DBusConnection * bus);
+
+void spi_emit_cache_removal (guint ref, DBusConnection * bus);
+
+#endif /* TREE_ADAPTOR_H */
--- /dev/null
+/*
+ * 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 <math.h>
+
+#include <atk/atk.h>
+#include <droute/droute.h>
+
+#include "common/spi-dbus.h"
+
+static dbus_bool_t
+impl_get_MinimumValue (DBusMessageIter * iter, void *user_data)
+{
+ AtkValue *value = (AtkValue *) user_data;
+ GValue src = { 0 };
+ GValue dest = { 0 };
+ gdouble dub;
+
+ g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
+
+ atk_value_get_minimum_value (value, &src);
+ g_value_init (&dest, G_TYPE_DOUBLE);
+
+ if (g_value_transform (&src, &dest))
+ {
+ dub = g_value_get_double (&dest);
+ return droute_return_v_double (iter, dub);
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+static dbus_bool_t
+impl_get_MaximumValue (DBusMessageIter * iter, void *user_data)
+{
+ AtkValue *value = (AtkValue *) user_data;
+ GValue src = { 0 };
+ GValue dest = { 0 };
+ gdouble dub;
+
+ g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
+
+ atk_value_get_maximum_value (value, &src);
+ g_value_init (&dest, G_TYPE_DOUBLE);
+
+ if (g_value_transform (&src, &dest))
+ {
+ dub = g_value_get_double (&dest);
+ return droute_return_v_double (iter, dub);
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+static dbus_bool_t
+impl_get_MinimumIncrement (DBusMessageIter * iter, void *user_data)
+{
+ AtkValue *value = (AtkValue *) user_data;
+ GValue src = { 0 };
+ GValue dest = { 0 };
+ gdouble dub;
+
+ g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
+
+ atk_value_get_minimum_increment (value, &src);
+ g_value_init (&dest, G_TYPE_DOUBLE);
+
+ if (g_value_transform (&src, &dest))
+ {
+ dub = g_value_get_double (&dest);
+ return droute_return_v_double (iter, dub);
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+static dbus_bool_t
+impl_get_CurrentValue (DBusMessageIter * iter, void *user_data)
+{
+ AtkValue *value = (AtkValue *) user_data;
+ GValue src = { 0 };
+ GValue dest = { 0 };
+ gdouble dub;
+
+ g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
+
+ atk_value_get_current_value (value, &src);
+ g_value_init (&dest, G_TYPE_DOUBLE);
+
+ if (g_value_transform (&src, &dest))
+ {
+ dub = g_value_get_double (&dest);
+ return droute_return_v_double (iter, dub);
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+static dbus_bool_t
+impl_set_currentValue (DBusMessageIter * iter, void *user_data)
+{
+ AtkValue *value = (AtkValue *) user_data;
+ GValue src = { 0 };
+ GValue dest = { 0 };
+ gdouble dub;
+ DBusMessageIter iter_variant;
+
+ g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
+
+ dbus_message_iter_recurse (iter, &iter_variant);
+ if (dbus_message_iter_get_arg_type (&iter_variant) != DBUS_TYPE_DOUBLE)
+ {
+ g_warning ("TODO: Support setting value from a non-double");
+ return FALSE;
+ }
+ dbus_message_iter_get_basic (&iter_variant, &dub);
+ g_value_init (&src, G_TYPE_DOUBLE);
+ g_value_set_double (&src, dub);
+
+ atk_value_get_current_value (value, &dest);
+
+ if (g_value_transform (&src, &dest))
+ {
+ atk_value_set_current_value (value, &dest);
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+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);
+};
+++ /dev/null
-/*
- * 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 <atk/atk.h>
-#include <droute/droute.h>
-
-#include "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);
-};
+++ /dev/null
-/*
- * 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 <string.h>
-
-#include <atk/atk.h>
-#include <droute/droute.h>
-
-#include "accessible-register.h"
-#include "accessible-marshaller.h"
-
-#include "common/bitarray.h"
-#include "common/spi-dbus.h"
-#include "common/spi-stateset.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)
-{
- 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)
-{
- Accessibility_Role role;
- int i;
-
- if (roles == NULL || roles[0] == BITARRAY_SEQ_TERM)
- return TRUE;
-
- role = spi_accessible_role_from_atk_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 gboolean
-bitarray_to_seq (int *array, int array_count, int **ret)
-{
- int out_size = 4;
- int out_count = 0;
- int i, j;
- int *out = (int *) g_malloc (out_size * sizeof (int));
-
- if (!out)
- return FALSE;
- for (i = 0; i < array_count; i++)
- {
- for (j = 0; j < 32; j++)
- {
- if (array[i] & (1 << j))
- {
- if (out_count == out_size - 2)
- {
- out_size <<= 1;
- out = (int *) g_realloc (out, out_size * sizeof (int));
- if (!out)
- return FALSE;
- }
- out[out_count++] = i * 32 + j;
- }
- }
- }
- out[out_count] = BITARRAY_SEQ_TERM;
- *ret = out;
- return TRUE;
-}
-
-
-static dbus_bool_t
-read_mr (DBusMessageIter * iter, MatchRulePrivate * mrp)
-{
- DBusMessageIter mrc, arrayc;
- dbus_uint32_t *array;
- dbus_int32_t matchType;
- int array_count;
- AtkAttribute *attr;
- int i;
- const char *str;
- char *interfaces = NULL;
-
- 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_get_basic (&mrc, &matchType);
- dbus_message_iter_next (&mrc);
- mrp->statematchtype = matchType;;
- /* attributes */
- mrp->attributes = NULL;
- if (dbus_message_iter_get_arg_type (&mrc) == DBUS_TYPE_STRING)
- {
- char *str;
- gchar **attributes;
- gchar **pp;
- dbus_message_iter_get_basic (&mrc, &str);
- attributes = g_strsplit (str, "\n", -1);
- for (pp = attributes; *pp; pp++)
- {
- str = *pp;
- 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);
- }
- }
- g_strfreev (attributes);
- }
- else
- {
- dbus_message_iter_recurse (&mrc, &arrayc);
- 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_get_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_get_basic (&mrc, &matchType);
- mrp->rolematchtype = matchType;;
- dbus_message_iter_next (&mrc);
- /* Get interfaces and interface match */
- dbus_message_iter_get_basic (&mrc, &interfaces);
- dbus_message_iter_next (&mrc);
- mrp->ifaces = g_strsplit (interfaces, ";", 0);
- dbus_message_iter_get_basic (&mrc, &matchType);
- mrp->interfacematchtype = matchType;;
- dbus_message_iter_next (&mrc);
- /* get invert */
- dbus_message_iter_get_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, "(so)", &iter_array))
- goto oom;
- for (item = ls; item; item = g_list_next (item))
- {
- spi_dbus_append_name_and_path (message, &iter_array,
- ATK_OBJECT (item->data), TRUE, FALSE);
- }
- 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_uint32_t sortby;
- dbus_uint32_t tree;
- dbus_int32_t count;
- dbus_bool_t traverse;
- GList *ls = NULL;
- const char *signature;
-
- signature = dbus_message_get_signature (message);
- if (strcmp (signature, "o(aiisiaiisib)uuib") != 0 &&
- strcmp (signature, "o(aii(as)iaiisib)uuib") != 0)
- {
- return droute_invalid_arguments_error (message);
- }
-
- dbus_message_iter_init (message, &iter);
- dbus_message_iter_get_basic (&iter, ¤t_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_uint32_t sortby;
- dbus_uint32_t tree;
- dbus_bool_t recurse;
- dbus_int32_t count;
- dbus_bool_t traverse;
- GList *ls = NULL;
- const char *signature;
-
- signature = dbus_message_get_signature (message);
- if (strcmp (signature, "o(aiisiaiisib)uubib") != 0 &&
- strcmp (signature, "o(aii(as)iaiisib)uubib") != 0)
- {
- return droute_invalid_arguments_error (message);
- }
-
- dbus_message_iter_init (message, &iter);
- dbus_message_iter_get_basic (&iter, ¤t_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 = atk_dbus_path_to_object (dbus_message_get_path (message));
- DBusMessageIter iter;
- MatchRulePrivate rule;
- dbus_uint32_t sortby;
- dbus_int32_t count;
- dbus_bool_t traverse;
- GList *ls = NULL;
- const char *signature;
-
- signature = dbus_message_get_signature (message);
- if (strcmp (signature, "(aiisiaiisib)uib") != 0 &&
- strcmp (signature, "(aii(as)iaiisib)uib") != 0)
- {
- return droute_invalid_arguments_error (message);
- }
-
- 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);
-};
+++ /dev/null
-/*
- * 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 <atk/atk.h>
-#include <droute/droute.h>
-
-#include "accessible-marshaller.h"
-#include "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_uint32_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_UINT32, &coord_type, DBUS_TYPE_INVALID))
- {
- return droute_invalid_arguments_error (message);
- }
- 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_uint32_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_UINT32, &coord_type, DBUS_TYPE_INVALID))
- {
- return droute_invalid_arguments_error (message);
- }
- child =
- atk_component_ref_accessible_at_point (component, x, y,
- (AtkCoordType) coord_type);
- return spi_dbus_return_object (message, child, TRUE, TRUE);
-}
-
-static DBusMessage *
-impl_GetExtents (DBusConnection * bus, DBusMessage * message, void *user_data)
-{
- AtkComponent *component = (AtkComponent *) user_data;
- DBusError error;
- dbus_uint32_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_UINT32, &coord_type, DBUS_TYPE_INVALID))
- {
- return droute_invalid_arguments_error (message);
- }
- 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_uint32_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_UINT32, &coord_type, DBUS_TYPE_INVALID))
- {
- return droute_invalid_arguments_error (message);
- }
- 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);
-};
+++ /dev/null
-/*
- * 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 <atk/atk.h>
-#include <droute/droute.h>
-
-#include "common/spi-dbus.h"
-
-#include "accessible-marshaller.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 droute_invalid_arguments_error (message);
- }
- 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;
- DBusMessageIter iter;
-
- g_return_val_if_fail (ATK_IS_DOCUMENT (user_data),
- droute_not_yet_handled_error (message));
-
- attributes = atk_document_get_attributes (document);
-
- reply = dbus_message_new_method_return (message);
- if (reply)
- {
- dbus_message_iter_init_append (reply, &iter);
- spi_atk_append_attribute_set (&iter, attributes);
- }
-
- if (attributes)
- atk_attribute_set_free (attributes);
- 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);
-};
+++ /dev/null
-/*
- * 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 <atk/atk.h>
-#include <droute/droute.h>
-
-#include "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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- 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_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 droute_invalid_arguments_error (message);
- }
- atk_editable_text_copy_text (editable, startPos, endPos);
- return dbus_message_new_method_return (message);
-}
-
-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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- 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_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);
-};
+++ /dev/null
-/*
- * 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 <atk/atk.h>
-#include <droute/droute.h>
-
-#include "accessible-marshaller.h"
-#include "common/spi-dbus.h"
-
-static AtkHyperlink *
-get_hyperlink (void *user_data)
-{
- if (ATK_IS_HYPERLINK (user_data))
- return ATK_HYPERLINK (user_data);
- if (ATK_IS_HYPERLINK_IMPL (user_data))
- return atk_hyperlink_impl_get_hyperlink (ATK_HYPERLINK_IMPL (user_data));
- return NULL;
-}
-
-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 = get_hyperlink (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 = get_hyperlink (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 = get_hyperlink (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 droute_invalid_arguments_error (message);
- }
- atk_object = atk_hyperlink_get_object (link, i);
- return spi_dbus_return_sub_object (message, G_OBJECT (atk_object),
- G_OBJECT (link), FALSE);
-}
-
-static DBusMessage *
-impl_GetURI (DBusConnection * bus, DBusMessage * message, void *user_data)
-{
- AtkHyperlink *link = get_hyperlink (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_INVALID))
- {
- return droute_invalid_arguments_error (message);
- }
-
- 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 = get_hyperlink (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);
-};
+++ /dev/null
-/*
- * 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 <atk/atk.h>
-#include <droute/droute.h>
-
-#include "common/spi-dbus.h"
-#include "accessible-marshaller.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 droute_invalid_arguments_error (message);
- }
- link = atk_hypertext_get_link (hypertext, linkIndex);
- return spi_dbus_return_hyperlink (message, link, ATK_OBJECT (hypertext),
- TRUE);
-}
-
-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 droute_invalid_arguments_error (message);
- }
- 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);
-};
+++ /dev/null
-/*
- * 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 <atk/atk.h>
-#include <droute/droute.h>
-
-#include "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_uint32_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_UINT32, &coordType, DBUS_TYPE_INVALID))
- {
- return droute_invalid_arguments_error (message);
- }
- 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_uint32_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_UINT32, &coord_type, DBUS_TYPE_INVALID))
- {
- return droute_invalid_arguments_error (message);
- }
- 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);
-};
+++ /dev/null
-/*
- * 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 <config.h>
-#include <stdio.h>
-
-#include <atk/atk.h>
-#include <droute/droute.h>
-
-#include "common/spi-types.h"
-#include "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_NODE_PARENT_OF] = Accessibility_RELATION_NODE_PARENT_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)
+++ /dev/null
-/*
- * 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 <atk/atk.h>
-#include <droute/droute.h>
-
-#include "common/spi-dbus.h"
-#include "accessible-marshaller.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_return_val_if_fail (ATK_IS_SELECTION (user_data), FALSE);
- 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 droute_invalid_arguments_error (message);
- }
- atk_object = atk_selection_ref_selection (selection, selectedChildIndex);
- return spi_dbus_return_object (message, atk_object, TRUE, 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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- 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);
-};
+++ /dev/null
-/*
- * 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 <config.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <libspi/component.h>
-#include <libspi/streamablecontent.h>
-
-/* 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)
+++ /dev/null
-/*
- * 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 <atk/atk.h>
-#include <droute/droute.h>
-
-#include "accessible-marshaller.h"
-#include "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 droute_invalid_arguments_error (message);
- }
- obj = atk_table_ref_at (table, row, column);
- return spi_dbus_return_object (message, obj, TRUE, 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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- obj = atk_table_get_row_header (table, row);
- obj = atk_table_get_row_header (table, row);
- return spi_dbus_return_object (message, obj, TRUE, 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 droute_invalid_arguments_error (message);
- }
- obj = atk_table_get_column_header (table, column);
- obj = atk_table_get_column_header (table, column);
- return spi_dbus_return_object (message, obj, TRUE, 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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- 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_BOOLEAN, &ret,
- 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_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);
-};
+++ /dev/null
-/*
- * 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 <string.h>
-
-#include <atk/atk.h>
-#include <droute/droute.h>
-
-#include "common/spi-dbus.h"
-
-#include "accessible-marshaller.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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- 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_STRING, &txt,
- DBUS_TYPE_INT32, &startOffset,
- DBUS_TYPE_INT32, &endOffset,
- 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 droute_invalid_arguments_error (message);
- }
- 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_STRING, &txt,
- DBUS_TYPE_INT32, &startOffset,
- DBUS_TYPE_INT32, &endOffset,
- 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 droute_invalid_arguments_error (message);
- }
- 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_STRING, &txt,
- DBUS_TYPE_INT32, &startOffset,
- DBUS_TYPE_INT32, &endOffset,
- 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 droute_invalid_arguments_error (message);
- }
- 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 = NULL;
- 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 droute_invalid_arguments_error (message);
- }
-
- 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_STRING, &rv, DBUS_TYPE_INT32,
- &startOffset, DBUS_TYPE_INT32, &endOffset,
- DBUS_TYPE_BOOLEAN, &defined,
- 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;
- DBusError error;
- DBusMessage *reply;
- AtkAttributeSet *set;
- DBusMessageIter iter;
-
- 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 droute_invalid_arguments_error (message);
- }
-
- set = atk_text_get_run_attributes (text, offset,
- &intstart_offset, &intend_offset);
-
- startOffset = intstart_offset;
- endOffset = intend_offset;
- reply = dbus_message_new_method_return (message);
- if (reply)
- {
- dbus_message_iter_init_append (reply, &iter);
- spi_atk_append_attribute_set (&iter, set);
- dbus_message_append_args (reply, DBUS_TYPE_INT32, &startOffset,
- DBUS_TYPE_INT32, &endOffset,
- DBUS_TYPE_INVALID);
- }
- atk_attribute_set_free (set);
- return reply;
-}
-
-static DBusMessage *
-impl_GetDefaultAttributes (DBusConnection * bus, DBusMessage * message,
- void *user_data)
-{
- AtkText *text = (AtkText *) user_data;
- DBusError error;
- DBusMessage *reply;
- AtkAttributeSet *set;
- DBusMessageIter iter;
-
- 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);
- reply = dbus_message_new_method_return (message);
- if (reply)
- {
- dbus_message_iter_init_append (reply, &iter);
- spi_atk_append_attribute_set (&iter, set);
- }
- 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_uint32_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_UINT32,
- &coordType, DBUS_TYPE_INVALID))
- {
- return droute_invalid_arguments_error (message);
- }
- 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_uint32_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_UINT32, &coordType, DBUS_TYPE_INVALID))
- {
- return droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- /* 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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- 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 droute_invalid_arguments_error (message);
- }
- 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_uint32_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_UINT32, &coordType, DBUS_TYPE_INVALID))
- {
- return droute_invalid_arguments_error (message);
- }
- 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_uint32_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_UINT32,
- &coordType, DBUS_TYPE_UINT32, &xClipType, DBUS_TYPE_UINT32, &yClipType,
- DBUS_TYPE_INVALID))
- {
- return droute_invalid_arguments_error (message);
- }
- 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
- (&struc, 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;
- DBusMessageIter iter, iterArray;
-
- 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 droute_invalid_arguments_error (message);
- }
-
- attributes =
- atk_text_get_run_attributes (text, offset, &intstart_offset,
- &intend_offset);
-
- reply = dbus_message_new_method_return (message);
- if (!reply)
- return NULL;
-
- dbus_message_iter_init_append (reply, &iter);
- dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "{ss}",
- &iterArray);
- spi_atk_append_attribute_set_inner (&iterArray, attributes);
- if (includeDefaults)
- {
- default_attributes = atk_text_get_default_attributes (text);
- spi_atk_append_attribute_set_inner (&iterArray, default_attributes);
- }
- dbus_message_iter_close_container (&iter, &iterArray);
-
- startOffset = intstart_offset;
- endOffset = intend_offset;
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &startOffset);
- dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &endOffset);
-
- atk_attribute_set_free (attributes);
- if (default_attributes)
- atk_attribute_set_free (default_attributes);
-
- return reply;
-}
-
-static DBusMessage *
-impl_GetDefaultAttributeSet (DBusConnection * bus, DBusMessage * message,
- void *user_data)
-{
- AtkText *text = (AtkText *) user_data;
- DBusMessage *reply;
- DBusMessageIter iter;
- AtkAttributeSet *attributes;
-
- g_return_val_if_fail (ATK_IS_TEXT (user_data),
- droute_not_yet_handled_error (message));
-
- attributes = atk_text_get_default_attributes (text);
-
- reply = dbus_message_new_method_return (message);
- if (reply)
- {
- dbus_message_iter_init_append (reply, &iter);
- spi_atk_append_attribute_set (&iter, attributes);
- }
-
- if (attributes)
- atk_attribute_set_free (attributes);
-
- 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);
-};
+++ /dev/null
-/*
- * 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 <string.h>
-
-#include <atk/atk.h>
-#include <droute/droute.h>
-
-#include "bridge.h"
-#include "accessible-register.h"
-#include "accessible-marshaller.h"
-#include "common/spi-dbus.h"
-
-/*---------------------------------------------------------------------------*/
-
-/* For use as a GHFunc */
-static void
-append_accessible_hf (gpointer key, gpointer obj_data, gpointer data)
-{
- /* Make sure it isn't a hyperlink */
- if (ATK_IS_OBJECT (obj_data))
- spi_atk_append_accessible (ATK_OBJECT (obj_data), data);
-}
-
-/*---------------------------------------------------------------------------*/
-
-void
-spi_emit_cache_removal (guint ref, DBusConnection * bus)
-{
- DBusMessage *message;
-
- if ((message = dbus_message_new_signal ("/org/freedesktop/atspi/tree",
- SPI_DBUS_INTERFACE_TREE,
- "RemoveAccessible")))
- {
- DBusMessageIter iter;
- gchar *path;
-
- 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);
-
- dbus_message_unref (message);
- }
-}
-
-void
-spi_emit_cache_update (AtkObject * accessible, DBusConnection * bus)
-{
- DBusMessage *message;
-
- if ((message = dbus_message_new_signal ("/org/freedesktop/atspi/tree",
- SPI_DBUS_INTERFACE_TREE,
- "UpdateAccessible")))
- {
- DBusMessageIter iter;
-
- dbus_message_iter_init_append (message, &iter);
- spi_atk_append_accessible (accessible, &iter);
-
- dbus_connection_send (bus, message, NULL);
-
- dbus_message_unref (message);
- }
-}
-
-
-/*---------------------------------------------------------------------------*/
-
-static DBusMessage *
-impl_GetRoot (DBusConnection * bus, DBusMessage * message, void *user_data)
-{
- AtkObject *root = atk_get_root ();
- char *path;
- DBusMessage *reply;
- gchar *errmsg;
-
- if (!root)
- {
- reply = dbus_message_new_error (message,
- DBUS_ERROR_FAILED,
- "No root accessible available");
- }
- path = atk_dbus_object_to_path (root, FALSE);
- if (!path)
- {
- reply = dbus_message_new_error (message,
- DBUS_ERROR_FAILED,
- "No root accessible available");
- }
- 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,
- "(o(so)a(so)assusau)", &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------------------------------------------------------------------------*/
+++ /dev/null
-/*
- * 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 <atk/atk.h>
-#include <dbus/dbus.h>
-
-void spi_emit_cache_update (AtkObject * accessible, DBusConnection * bus);
-
-void spi_emit_cache_removal (guint ref, DBusConnection * bus);
-
-#endif /* TREE_ADAPTOR_H */
+++ /dev/null
-/*
- * 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 <math.h>
-
-#include <atk/atk.h>
-#include <droute/droute.h>
-
-#include "common/spi-dbus.h"
-
-static dbus_bool_t
-impl_get_MinimumValue (DBusMessageIter * iter, void *user_data)
-{
- AtkValue *value = (AtkValue *) user_data;
- GValue src = { 0 };
- GValue dest = { 0 };
- gdouble dub;
-
- g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
-
- atk_value_get_minimum_value (value, &src);
- g_value_init (&dest, G_TYPE_DOUBLE);
-
- if (g_value_transform (&src, &dest))
- {
- dub = g_value_get_double (&dest);
- return droute_return_v_double (iter, dub);
- }
- else
- {
- return FALSE;
- }
-}
-
-static dbus_bool_t
-impl_get_MaximumValue (DBusMessageIter * iter, void *user_data)
-{
- AtkValue *value = (AtkValue *) user_data;
- GValue src = { 0 };
- GValue dest = { 0 };
- gdouble dub;
-
- g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
-
- atk_value_get_maximum_value (value, &src);
- g_value_init (&dest, G_TYPE_DOUBLE);
-
- if (g_value_transform (&src, &dest))
- {
- dub = g_value_get_double (&dest);
- return droute_return_v_double (iter, dub);
- }
- else
- {
- return FALSE;
- }
-}
-
-static dbus_bool_t
-impl_get_MinimumIncrement (DBusMessageIter * iter, void *user_data)
-{
- AtkValue *value = (AtkValue *) user_data;
- GValue src = { 0 };
- GValue dest = { 0 };
- gdouble dub;
-
- g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
-
- atk_value_get_minimum_increment (value, &src);
- g_value_init (&dest, G_TYPE_DOUBLE);
-
- if (g_value_transform (&src, &dest))
- {
- dub = g_value_get_double (&dest);
- return droute_return_v_double (iter, dub);
- }
- else
- {
- return FALSE;
- }
-}
-
-static dbus_bool_t
-impl_get_CurrentValue (DBusMessageIter * iter, void *user_data)
-{
- AtkValue *value = (AtkValue *) user_data;
- GValue src = { 0 };
- GValue dest = { 0 };
- gdouble dub;
-
- g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
-
- atk_value_get_current_value (value, &src);
- g_value_init (&dest, G_TYPE_DOUBLE);
-
- if (g_value_transform (&src, &dest))
- {
- dub = g_value_get_double (&dest);
- return droute_return_v_double (iter, dub);
- }
- else
- {
- return FALSE;
- }
-}
-
-static dbus_bool_t
-impl_set_currentValue (DBusMessageIter * iter, void *user_data)
-{
- AtkValue *value = (AtkValue *) user_data;
- GValue src = { 0 };
- GValue dest = { 0 };
- gdouble dub;
- DBusMessageIter iter_variant;
-
- g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
-
- dbus_message_iter_recurse (iter, &iter_variant);
- if (dbus_message_iter_get_arg_type (&iter_variant) != DBUS_TYPE_DOUBLE)
- {
- g_warning ("TODO: Support setting value from a non-double");
- return FALSE;
- }
- dbus_message_iter_get_basic (&iter_variant, &dub);
- g_value_init (&src, G_TYPE_DOUBLE);
- g_value_set_double (&src, dub);
-
- atk_value_get_current_value (value, &dest);
-
- if (g_value_transform (&src, &dest))
- {
- atk_value_set_current_value (value, &dest);
- return TRUE;
- }
- else
- {
- return FALSE;
- }
-}
-
-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);
-};
dbind/dbind-config.h
common/Makefile
atk-adaptor/Makefile
+ atk-adaptor/adaptors/Makefile
tests/Makefile
])