2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2008 Novell, Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
25 #include <glib-object.h>
26 #include <dbus/dbus.h>
30 dbus_bool_t spi_dbus_message_iter_get_struct(DBusMessageIter *iter, ...)
33 DBusMessageIter iter_struct;
37 dbus_message_iter_recurse(iter, &iter_struct);
41 type = va_arg(args, int);
42 if (type == DBUS_TYPE_INVALID) break;
43 if (type != dbus_message_iter_get_arg_type(&iter_struct))
48 ptr = va_arg(args, void *);
49 dbus_message_iter_get_basic(&iter_struct, ptr);
50 dbus_message_iter_next(&iter_struct);
52 dbus_message_iter_next(iter);
57 dbus_bool_t spi_dbus_message_iter_append_struct(DBusMessageIter *iter, ...)
60 DBusMessageIter iter_struct;
64 if (!dbus_message_iter_open_container(iter, DBUS_TYPE_STRUCT, NULL, &iter_struct)) return FALSE;
68 type = va_arg(args, int);
69 if (type == DBUS_TYPE_INVALID) break;
70 ptr = va_arg(args, void *);
71 dbus_message_iter_append_basic(&iter_struct, type, ptr);
73 if (!dbus_message_iter_close_container(iter, &iter_struct)) return FALSE;
78 dbus_bool_t spi_dbus_marshal_deviceEvent(DBusMessage *message, const Accessibility_DeviceEvent *e)
82 if (!message) return FALSE;
83 dbus_message_iter_init_append(message, &iter);
84 return spi_dbus_message_iter_append_struct(&iter, DBUS_TYPE_UINT32, &e->type, DBUS_TYPE_INT32, &e->id, DBUS_TYPE_UINT32, &e->hw_code, DBUS_TYPE_UINT32, &e->modifiers, DBUS_TYPE_INT32, &e->timestamp, DBUS_TYPE_STRING, &e->event_string, DBUS_TYPE_BOOLEAN, &e->is_text, DBUS_TYPE_INVALID);
87 dbus_bool_t spi_dbus_demarshal_deviceEvent(DBusMessage *message, Accessibility_DeviceEvent *e)
90 dbus_uint16_t hw_code;
91 dbus_uint16_t modifiers;
93 dbus_message_iter_init(message, &iter);
94 if (spi_dbus_message_iter_get_struct(&iter, DBUS_TYPE_UINT32, &e->type, DBUS_TYPE_INT32, &e->id, DBUS_TYPE_INT32, &e->hw_code, DBUS_TYPE_INT32, &e->modifiers, DBUS_TYPE_INT32, &e->timestamp, DBUS_TYPE_STRING, &e->event_string, DBUS_TYPE_BOOLEAN, &e->is_text, DBUS_TYPE_INVALID))
96 /* TODO: Perhaps remove the below code for 2.1 */
97 if (!spi_dbus_message_iter_get_struct(&iter, DBUS_TYPE_UINT32, &e->type, DBUS_TYPE_INT32, &e->id, DBUS_TYPE_INT16, &hw_code, DBUS_TYPE_INT16, &modifiers, DBUS_TYPE_INT32, &e->timestamp, DBUS_TYPE_STRING, &e->event_string, DBUS_TYPE_BOOLEAN, &e->is_text, DBUS_TYPE_INVALID))
100 e->modifiers = modifiers;