|
Packit |
8b6d7a |
/*
|
|
Packit |
8b6d7a |
* AT-SPI - Assistive Technology Service Provider Interface
|
|
Packit |
8b6d7a |
* (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
|
|
Packit |
8b6d7a |
*
|
|
Packit |
8b6d7a |
* Copyright 2008 Novell, Inc.
|
|
Packit |
8b6d7a |
*
|
|
Packit |
8b6d7a |
* This library is free software; you can redistribute it and/or
|
|
Packit |
8b6d7a |
* modify it under the terms of the GNU Library General Public
|
|
Packit |
8b6d7a |
* License as published by the Free Software Foundation; either
|
|
Packit |
8b6d7a |
* version 2 of the License, or (at your option) any later version.
|
|
Packit |
8b6d7a |
*
|
|
Packit |
8b6d7a |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
8b6d7a |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
8b6d7a |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
8b6d7a |
* Library General Public License for more details.
|
|
Packit |
8b6d7a |
*
|
|
Packit |
8b6d7a |
* You should have received a copy of the GNU Library General Public
|
|
Packit |
8b6d7a |
* License along with this library; if not, write to the
|
|
Packit |
8b6d7a |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
Packit |
8b6d7a |
* Boston, MA 02111-1307, USA.
|
|
Packit |
8b6d7a |
*/
|
|
Packit |
8b6d7a |
|
|
Packit |
8b6d7a |
#include <stdlib.h>
|
|
Packit |
8b6d7a |
#include <glib.h>
|
|
Packit |
8b6d7a |
#include <glib-object.h>
|
|
Packit |
8b6d7a |
#include <dbus/dbus.h>
|
|
Packit |
8b6d7a |
|
|
Packit |
8b6d7a |
#include "de-types.h"
|
|
Packit |
8b6d7a |
|
|
Packit |
8b6d7a |
dbus_bool_t spi_dbus_message_iter_get_struct(DBusMessageIter *iter, ...)
|
|
Packit |
8b6d7a |
{
|
|
Packit |
8b6d7a |
va_list args;
|
|
Packit |
8b6d7a |
DBusMessageIter iter_struct;
|
|
Packit |
8b6d7a |
int type;
|
|
Packit |
8b6d7a |
void *ptr;
|
|
Packit |
8b6d7a |
|
|
Packit |
8b6d7a |
dbus_message_iter_recurse(iter, &iter_struct);
|
|
Packit |
8b6d7a |
va_start(args, iter);
|
|
Packit |
8b6d7a |
for (;;)
|
|
Packit |
8b6d7a |
{
|
|
Packit |
8b6d7a |
type = va_arg(args, int);
|
|
Packit |
8b6d7a |
if (type == DBUS_TYPE_INVALID) break;
|
|
Packit |
8b6d7a |
if (type != dbus_message_iter_get_arg_type(&iter_struct))
|
|
Packit |
8b6d7a |
{
|
|
Packit |
8b6d7a |
va_end(args);
|
|
Packit |
8b6d7a |
return FALSE;
|
|
Packit |
8b6d7a |
}
|
|
Packit |
8b6d7a |
ptr = va_arg(args, void *);
|
|
Packit |
8b6d7a |
dbus_message_iter_get_basic(&iter_struct, ptr);
|
|
Packit |
8b6d7a |
dbus_message_iter_next(&iter_struct);
|
|
Packit |
8b6d7a |
}
|
|
Packit |
8b6d7a |
dbus_message_iter_next(iter);
|
|
Packit |
8b6d7a |
va_end(args);
|
|
Packit |
8b6d7a |
return TRUE;
|
|
Packit |
8b6d7a |
}
|
|
Packit |
8b6d7a |
|
|
Packit |
8b6d7a |
dbus_bool_t spi_dbus_message_iter_append_struct(DBusMessageIter *iter, ...)
|
|
Packit |
8b6d7a |
{
|
|
Packit |
8b6d7a |
va_list args;
|
|
Packit |
8b6d7a |
DBusMessageIter iter_struct;
|
|
Packit |
8b6d7a |
int type;
|
|
Packit |
8b6d7a |
void *ptr;
|
|
Packit |
8b6d7a |
|
|
Packit |
8b6d7a |
if (!dbus_message_iter_open_container(iter, DBUS_TYPE_STRUCT, NULL, &iter_struct)) return FALSE;
|
|
Packit |
8b6d7a |
va_start(args, iter);
|
|
Packit |
8b6d7a |
for (;;)
|
|
Packit |
8b6d7a |
{
|
|
Packit |
8b6d7a |
type = va_arg(args, int);
|
|
Packit |
8b6d7a |
if (type == DBUS_TYPE_INVALID) break;
|
|
Packit |
8b6d7a |
ptr = va_arg(args, void *);
|
|
Packit |
8b6d7a |
dbus_message_iter_append_basic(&iter_struct, type, ptr);
|
|
Packit |
8b6d7a |
}
|
|
Packit |
8b6d7a |
if (!dbus_message_iter_close_container(iter, &iter_struct)) return FALSE;
|
|
Packit |
8b6d7a |
va_end(args);
|
|
Packit |
8b6d7a |
return TRUE;
|
|
Packit |
8b6d7a |
}
|
|
Packit |
8b6d7a |
|
|
Packit |
8b6d7a |
dbus_bool_t spi_dbus_marshal_deviceEvent(DBusMessage *message, const Accessibility_DeviceEvent *e)
|
|
Packit |
8b6d7a |
{
|
|
Packit |
8b6d7a |
DBusMessageIter iter;
|
|
Packit |
8b6d7a |
|
|
Packit |
8b6d7a |
if (!message) return FALSE;
|
|
Packit |
8b6d7a |
dbus_message_iter_init_append(message, &iter);
|
|
Packit |
8b6d7a |
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);
|
|
Packit |
8b6d7a |
}
|
|
Packit |
8b6d7a |
|
|
Packit |
8b6d7a |
dbus_bool_t spi_dbus_demarshal_deviceEvent(DBusMessage *message, Accessibility_DeviceEvent *e)
|
|
Packit |
8b6d7a |
{
|
|
Packit |
8b6d7a |
DBusMessageIter iter;
|
|
Packit |
8b6d7a |
dbus_uint16_t hw_code;
|
|
Packit |
8b6d7a |
dbus_uint16_t modifiers;
|
|
Packit |
8b6d7a |
|
|
Packit |
8b6d7a |
dbus_message_iter_init(message, &iter);
|
|
Packit |
8b6d7a |
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))
|
|
Packit |
8b6d7a |
return TRUE;
|
|
Packit |
8b6d7a |
/* TODO: Perhaps remove the below code for 2.1 */
|
|
Packit |
8b6d7a |
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))
|
|
Packit |
8b6d7a |
return FALSE;
|
|
Packit |
8b6d7a |
e->hw_code = hw_code;
|
|
Packit |
8b6d7a |
e->modifiers = modifiers;
|
|
Packit |
8b6d7a |
return TRUE;
|
|
Packit |
8b6d7a |
}
|