From: Mike Gorse Date: Mon, 12 May 2008 16:17:37 +0000 (-0400) Subject: Add some accessibility structures into accessible.h (for now, anyway; we really shoul... X-Git-Tag: AT_SPI2_CORE_0_1_3~263 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5d941f2c748b33c0179a31de7f978cb78caae71e;p=platform%2Fupstream%2Fat-spi2-core.git Add some accessibility structures into accessible.h (for now, anyway; we really should auto-generate them) Add spi_dbus_message_iter_get_struct, spi_dbus_message_iter_append_struct, spi_dbus_marshall_deviceevent, and spi_dbus_demarshall_deviceevent Remove dbus.h; combine with accessible.h --- diff --git a/libspi/accessible.h b/libspi/accessible.h index b624317..55df3b3 100644 --- a/libspi/accessible.h +++ b/libspi/accessible.h @@ -24,7 +24,6 @@ #ifndef SPI_ACCESSIBLE_H_ #define SPI_ACCESSIBLE_H_ -#include #include #include "Accessibility.h" #include "atk/atk.h" @@ -50,6 +49,62 @@ void spi_initialize_value(DRouteData *data); dbus_bool_t spi_dbus_append_tree (DBusMessage * message, AtkObject * obj, DRouteData * data); +typedef unsigned long Accessibility_ControllerEventMask; + +// TODO: auto-generate the below structs +typedef struct _Accessibility_DeviceEvent Accessibility_DeviceEvent; +struct _Accessibility_DeviceEvent +{ + Accessibility_EventType type; + dbus_uint32_t id; +dbus_uint16_t hw_code; + dbus_uint16_t modifiers; + dbus_uint32_t timestamp; + char * event_string; + dbus_bool_t is_text; +}; + +typedef struct _Accessibility_EventListenerMode Accessibility_EventListenerMode; +struct _Accessibility_EventListenerMode +{ + dbus_bool_t synchronous; + dbus_bool_t preemptive; + dbus_bool_t global; +}; + +typedef struct _Accessibility_KeyDefinition Accessibility_KeyDefinition; +struct _Accessibility_KeyDefinition +{ + dbus_int32_t keycode; + dbus_int32_t keysym; + char *keystring; + dbus_int32_t unused; +}; + +#define SPI_DBUS_NAME_REGISTRY "org.freedesktop.atspi.registry" +#define SPI_DBUS_PATH_REGISTRY "/org/freedesktop/atspi/registry" + +AtkObject *spi_dbus_get_object(const char *path); + +gchar *spi_dbus_get_path(AtkObject *obj); +DBusMessage *spi_dbus_general_error(DBusMessage *message); +DBusMessage *spi_dbus_return_rect(DBusMessage *message, gint ix, gint iy, gint iwidth, gint iheight); +DBusMessage *spi_dbus_return_object(DBusMessage *message, AtkObject *obj, int unref); +dbus_bool_t spi_dbus_return_v_object(DBusMessageIter *iter, AtkObject *obj, int unref); + +#define SPI_DBUS_RETURN_ERROR(m, e) dbus_message_new_error(m, (e)->name, (e)->message) + +void spi_dbus_initialize(DRouteData *data); +dbus_bool_t spi_dbus_message_iter_get_struct(DBusMessageIter *iter, ...); +dbus_bool_t spi_dbus_message_iter_append_struct(DBusMessageIter *iter, ...); +dbus_bool_t spi_dbus_marshall_deviceEvent(DBusMessage *message, const Accessibility_DeviceEvent *e); +dbus_bool_t spi_dbus_demarshall_deviceEvent(DBusMessage *message, Accessibility_DeviceEvent *e); + +/* tree.c */ +void spi_dbus_notify_change(AtkObject *obj, gboolean new, DRouteData *data); +void spi_dbus_notify_remove(AtkObject *obj, DRouteData *data); +gboolean spi_dbus_update_cache(DRouteData *data); +gboolean spi_dbus_object_is_known(AtkObject *obj); G_END_DECLS #endif /* SPI_ACCESSIBLE_H_ */ diff --git a/libspi/dbus.c b/libspi/dbus.c index a2cfbce..a8e12d1 100644 --- a/libspi/dbus.c +++ b/libspi/dbus.c @@ -24,7 +24,6 @@ #include #include #include -#include "dbus.h" static GHashTable *path2ptr; static guint objindex; @@ -232,3 +231,68 @@ spi_get_tree (AtkObject * obj, GString * str, DRouteData * data) str = g_string_append (str, "\n"); return str; } + +dbus_bool_t spi_dbus_message_iter_get_struct(DBusMessageIter *iter, ...) +{ + va_list args; + DBusMessageIter iter_struct; + int type; + void *ptr; + + dbus_message_iter_recurse(iter, &iter_struct); + va_start(args, iter); + for (;;) + { + type = va_arg(args, int); + if (type == DBUS_TYPE_INVALID) break; + if (type != dbus_message_iter_get_arg_type(&iter_struct)) + { + va_end(args); + return FALSE; + } + ptr = va_arg(args, void *); + dbus_message_iter_get_basic(&iter_struct, ptr); + dbus_message_iter_next(&iter_struct); + } + dbus_message_iter_next(iter); + va_end(args); + return TRUE; +} + +dbus_bool_t spi_dbus_message_iter_append_struct(DBusMessageIter *iter, ...) +{ + va_list args; + DBusMessageIter iter_struct; + int type; + void *ptr; + + if (!dbus_message_iter_open_container(iter, &iter_struct)) return FALSE; + va_start(args, iter); + for (;;) + { + type = va_arg(args, int); + if (type == DBUS_TYPE_INVALID) break; + ptr = va_arg(args, void *); + dbus_message_iter_append_basic(&iter_struct, type, ptr); + } + if (!dbus_message_iter_close_container(iter, &iter_struct)) return FALSE; + va_end(args); + return TRUE; +} + +dbus_bool_t spi_dbus_marshall_deviceEvent(DBusMessage *message, const Accessibility_DeviceEvent *e) +{ + DBusMessageIter iter; + + if (!message) return FALSE; + dbus_message_iter_init_append(message, &iter); + return spi_dbus_message_iter_append_struct(&iter, DBUS_TYPE_UINT32, &e->type, DBUS_TYPE_INT32, &e->id, DBUS_TYPE_INT16, &e->hw_code, DBUS_TYPE_INT16, &e->modifiers, DBUS_TYPE_INT32, &e->timestamp, DBUS_TYPE_STRING, &e->event_string, DBUS_TYPE_BOOLEAN, &e->is_text, DBUS_TYPE_INVALID); +} + +dbus_bool_t spi_dbus_demarshall_deviceEvent(DBusMessage *message, Accessibility_DeviceEvent *e) +{ + DBusMessageIter iter; + + dbus_message_iter_init(message, &iter); + return spi_dbus_message_iter_get_struct(&iter, DBUS_TYPE_UINT32, &e->type, DBUS_TYPE_INT32, &e->id, DBUS_TYPE_INT16, &e->hw_code, DBUS_TYPE_INT16, &e->modifiers, DBUS_TYPE_INT32, &e->timestamp, DBUS_TYPE_STRING, &e->event_string, DBUS_TYPE_BOOLEAN, &e->is_text, DBUS_TYPE_INVALID); +} diff --git a/libspi/dbus.h b/libspi/dbus.h deleted file mode 100644 index e794645..0000000 --- a/libspi/dbus.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * AT-SPI - Assistive Technology Service Provider Interface - * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) - * - * Copyright 2008 Novell, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _ATSPI_DBUS_H -#define _ATSPI_DBUS_H - -#include -#include -#include - -#include "droute.h" - -AtkObject *spi_dbus_get_object(const char *path); - -gchar *spi_dbus_get_path(AtkObject *obj); -DBusMessage *spi_dbus_general_error(DBusMessage *message); -DBusMessage *spi_dbus_return_rect(DBusMessage *message, gint ix, gint iy, gint iwidth, gint iheight); -DBusMessage *spi_dbus_return_object(DBusMessage *message, AtkObject *obj, int unref); -dbus_bool_t spi_dbus_return_v_object(DBusMessageIter *iter, AtkObject *obj, int unref); - -#define SPI_DBUS_RETURN_ERROR(m, e) dbus_message_new_error(m, (e)->name, (e)->message) - -void spi_dbus_initialize(DRouteData *data); - -/* tree.c */ -void spi_dbus_notify_change(AtkObject *obj, gboolean new, DRouteData *data); -void spi_dbus_notify_remove(AtkObject *obj, DRouteData *data); -gboolean spi_dbus_update_cache(DRouteData *data); -gboolean spi_dbus_object_is_known(AtkObject *obj); -#endif /* _ATSPI_DBUS_H */