projects
/
platform
/
upstream
/
at-spi2-core.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
at_spi2_tool: Apply ASLR to executable files.
[platform/upstream/at-spi2-core.git]
/
atspi
/
atspi-device-listener.c
diff --git
a/atspi/atspi-device-listener.c
b/atspi/atspi-device-listener.c
index
235d6b2
..
3ac4451
100644
(file)
--- a/
atspi/atspi-device-listener.c
+++ b/
atspi/atspi-device-listener.c
@@
-4,6
+4,7
@@
*
* Copyright 2002 Ximian Inc.
* Copyright 2002 Sun Microsystems, Inc.
*
* Copyright 2002 Ximian Inc.
* Copyright 2002 Sun Microsystems, Inc.
+ * Copyright 2010, 2011 Novell, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@
-22,6
+23,7
@@
*/
#include "atspi-private.h"
*/
#include "atspi-private.h"
+#include <stdio.h>
typedef struct
{
typedef struct
{
@@
-32,8
+34,6
@@
typedef struct
GObjectClass *device_parent_class;
GObjectClass *device_parent_class;
-static guint32 _e_id = 0;
-
/*
* Misc. helpers.
*/
/*
* Misc. helpers.
*/
@@
-114,18
+114,10
@@
id_is_free (guint id)
return TRUE;
}
return TRUE;
}
-static void
-remove_listener (GObject *obj, gpointer data)
-{
- device_listeners = g_list_remove (device_listeners, obj);
-}
-
static AtspiDeviceEvent *
static AtspiDeviceEvent *
-atspi_device_event_copy (AtspiDeviceEvent *src)
+atspi_device_event_copy (
const
AtspiDeviceEvent *src)
{
AtspiDeviceEvent *dst = g_new0 (AtspiDeviceEvent, 1);
{
AtspiDeviceEvent *dst = g_new0 (AtspiDeviceEvent, 1);
- if (!dst)
- return NULL;
dst->type = src->type;
dst->id = src->id;
dst->hw_code = src->hw_code;
dst->type = src->type;
dst->id = src->id;
dst->hw_code = src->hw_code;
@@
-172,14
+164,12
@@
atspi_device_event_dispatch (AtspiDeviceListener *listener,
static void
atspi_device_listener_init (AtspiDeviceListener *listener)
{
static void
atspi_device_listener_init (AtspiDeviceListener *listener)
{
- GList *new_list;
do
{
listener->id = listener_id++;
} while (!id_is_free (listener->id));
do
{
listener->id = listener_id++;
} while (!id_is_free (listener->id));
- new_list = g_list_append (device_listeners, listener);
- if (new_list) device_listeners = new_list;
+ device_listeners = g_list_append (device_listeners, listener);
}
static void
}
static void
@@
-214,22
+204,22
@@
G_DEFINE_TYPE (AtspiDeviceListener, atspi_device_listener,
/**
* atspi_device_listener_new:
/**
* atspi_device_listener_new:
- * @callback: (scope notif
y
): an #AtspiDeviceListenerCB callback function,
+ * @callback: (scope notif
ied
): an #AtspiDeviceListenerCB callback function,
* or NULL.
* or NULL.
- * @callback_destroyed: A #GDestroyNotify called when the listener is freed
- * and data associated with the callback should be freed. Can be NULL.
* @user_data: (closure): a pointer to data which will be passed to the
* callback when invoked.
* @user_data: (closure): a pointer to data which will be passed to the
* callback when invoked.
+ * @callback_destroyed: A #GDestroyNotify called when the listener is freed
+ * and data associated with the callback should be freed. It can be NULL.
*
*
- * Create a new #AtspiDeviceListener with a specified callback function.
+ * Create
s
a new #AtspiDeviceListener with a specified callback function.
*
*
- * Returns: a pointer to a newly-created #AtspiDeviceListener.
+ * Returns:
(transfer full):
a pointer to a newly-created #AtspiDeviceListener.
*
**/
AtspiDeviceListener *
atspi_device_listener_new (AtspiDeviceListenerCB callback,
*
**/
AtspiDeviceListener *
atspi_device_listener_new (AtspiDeviceListenerCB callback,
-
GDestroyNotify callback_destroyed
,
-
void *user_data
)
+
void *user_data
,
+
GDestroyNotify callback_destroyed
)
{
AtspiDeviceListener *listener = g_object_new (atspi_device_listener_get_type (), NULL);
{
AtspiDeviceListener *listener = g_object_new (atspi_device_listener_get_type (), NULL);
@@
-240,14
+230,15
@@
atspi_device_listener_new (AtspiDeviceListenerCB callback,
}
/**
}
/**
- * atspi_device_listener_new_simple:
- * @callback: (scope notif
y
): an #AtspiDeviceListenerCB callback function,
+ * atspi_device_listener_new_simple:
(skip)
+ * @callback: (scope notif
ied
): an #AtspiDeviceListenerCB callback function,
* or NULL.
* @callback_destroyed: A #GDestroyNotify called when the listener is freed
* or NULL.
* @callback_destroyed: A #GDestroyNotify called when the listener is freed
- * and data associated with the callback should be freed.
C
an be NULL.
+ * and data associated with the callback should be freed.
It
an be NULL.
*
*
- * Create a new #AtspiDeviceListener with a specified callback function.
- * Like atspi_device_listener_new, but callback takes no user data.
+ * Creates a new #AtspiDeviceListener with a specified callback function.
+ * This method is similar to #atspi_device_listener_new, but callback
+ * takes no user data.
*
* Returns: a pointer to a newly-created #AtspiDeviceListener.
*
*
* Returns: a pointer to a newly-created #AtspiDeviceListener.
*
@@
-256,19
+247,19
@@
AtspiDeviceListener *
atspi_device_listener_new_simple (AtspiDeviceListenerSimpleCB callback,
GDestroyNotify callback_destroyed)
{
atspi_device_listener_new_simple (AtspiDeviceListenerSimpleCB callback,
GDestroyNotify callback_destroyed)
{
- return atspi_device_listener_new (device_remove_datum, callback
_destroyed, callback
);
+ return atspi_device_listener_new (device_remove_datum, callback
, callback_destroyed
);
}
/**
* atspi_device_listener_add_callback:
* @listener: the #AtspiDeviceListener instance to modify.
}
/**
* atspi_device_listener_add_callback:
* @listener: the #AtspiDeviceListener instance to modify.
- * @callback: (scope notify): an #AtspiDeviceListenerCB function pointer.
- * @user_data: (closure): a pointer to data which will be passed to the
- * callback when invoked.
+ * @callback: (scope notified): an #AtspiDeviceListenerCB function pointer.
* @callback_destroyed: A #GDestroyNotify called when the listener is freed
* @callback_destroyed: A #GDestroyNotify called when the listener is freed
- * and data associated with the callback should be freed. Can be NULL.
+ * and data associated with the callback should be freed. It can be NULL.
+ * @user_data: (closure): a pointer to data which will be passed to the
+ * callback when invoked.
*
*
- * Add an in-process callback function to an existing #AtspiDeviceListener.
+ * Add
s
an in-process callback function to an existing #AtspiDeviceListener.
*
* Returns: #TRUE if successful, otherwise #FALSE.
*
*
* Returns: #TRUE if successful, otherwise #FALSE.
*
@@
-285,13
+276,7
@@
atspi_device_listener_add_callback (AtspiDeviceListener *listener,
new_handler = device_event_handler_new (callback,
callback_destroyed, user_data);
new_handler = device_event_handler_new (callback,
callback_destroyed, user_data);
- if (new_handler)
- {
- GList *new_list;
- new_list = g_list_prepend (listener->callbacks, new_handler);
- if (new_list)
- listener->callbacks = new_list;
- }
+ listener->callbacks = g_list_prepend (listener->callbacks, new_handler);
}
/**
}
/**
@@
-299,7
+284,8
@@
atspi_device_listener_add_callback (AtspiDeviceListener *listener,
* @listener: the #AtspiDeviceListener instance to modify.
* @callback: (scope call): an #AtspiDeviceListenerCB function pointer.
*
* @listener: the #AtspiDeviceListener instance to modify.
* @callback: (scope call): an #AtspiDeviceListenerCB function pointer.
*
- * Remove an in-process callback function from an existing #AtspiDeviceListener.
+ * Removes an in-process callback function from an existing
+ * #AtspiDeviceListener.
*
* Returns: #TRUE if successful, otherwise #FALSE.
*
*
* Returns: #TRUE if successful, otherwise #FALSE.
*
@@
-313,17
+299,14
@@
atspi_device_listener_remove_callback (AtspiDeviceListener *listener,
listener->callbacks = event_list_remove_by_cb (listener->callbacks, (void *) callback);
}
listener->callbacks = event_list_remove_by_cb (listener->callbacks, (void *) callback);
}
-static const char *device_event_type = "(uinnisb)";
-
static void
read_device_event_from_iter (DBusMessageIter *iter, AtspiDeviceEvent *event)
{
dbus_uint32_t type;
dbus_int32_t id;
static void
read_device_event_from_iter (DBusMessageIter *iter, AtspiDeviceEvent *event)
{
dbus_uint32_t type;
dbus_int32_t id;
- dbus_int
16
_t hw_code;
- dbus_int
16
_t modifiers;
+ dbus_int
32
_t hw_code;
+ dbus_int
32
_t modifiers;
dbus_int32_t timestamp;
dbus_int32_t timestamp;
- char *event_string;
dbus_bool_t is_text;
DBusMessageIter iter_struct;
dbus_bool_t is_text;
DBusMessageIter iter_struct;
@@
-337,12
+320,13
@@
read_device_event_from_iter (DBusMessageIter *iter, AtspiDeviceEvent *event)
event->id = id;
dbus_message_iter_next (&iter_struct);
event->id = id;
dbus_message_iter_next (&iter_struct);
+ /* TODO: Remove cast from next two on ABI break */
dbus_message_iter_get_basic (&iter_struct, &hw_code);
dbus_message_iter_get_basic (&iter_struct, &hw_code);
- event->hw_code = hw_code;
+ event->hw_code =
(gushort)
hw_code;
dbus_message_iter_next (&iter_struct);
dbus_message_iter_get_basic (&iter_struct, &modifiers);
dbus_message_iter_next (&iter_struct);
dbus_message_iter_get_basic (&iter_struct, &modifiers);
- event->modifiers = modifiers;
+ event->modifiers =
(gushort)
modifiers;
dbus_message_iter_next (&iter_struct);
dbus_message_iter_get_basic (&iter_struct, ×tamp);
dbus_message_iter_next (&iter_struct);
dbus_message_iter_get_basic (&iter_struct, ×tamp);
@@
-356,11
+340,8
@@
read_device_event_from_iter (DBusMessageIter *iter, AtspiDeviceEvent *event)
event->is_text = is_text;
}
event->is_text = is_text;
}
-/*
- * atspi_dbus_handle_DeviceEvent: (skip)
- */
DBusHandlerResult
DBusHandlerResult
-atspi_dbus_handle_DeviceEvent (DBusConnection *bus, DBusMessage *message, void *data)
+
_
atspi_dbus_handle_DeviceEvent (DBusConnection *bus, DBusMessage *message, void *data)
{
const char *path = dbus_message_get_path (message);
int id;
{
const char *path = dbus_message_get_path (message);
int id;
@@
-371,9
+352,8
@@
atspi_dbus_handle_DeviceEvent (DBusConnection *bus, DBusMessage *message, void *
dbus_bool_t retval = FALSE;
GList *l;
DBusMessage *reply;
dbus_bool_t retval = FALSE;
GList *l;
DBusMessage *reply;
- void *p = &event;
- if (strcmp (dbus_message_get_signature (message), "(ui
nn
isb)") != 0)
+ if (strcmp (dbus_message_get_signature (message), "(ui
uu
isb)") != 0)
{
g_warning ("Atspi: Unknown signature for an event");
goto done;
{
g_warning ("Atspi: Unknown signature for an event");
goto done;
@@
-401,6
+381,11
@@
atspi_dbus_handle_DeviceEvent (DBusConnection *bus, DBusMessage *message, void *
if (klass->device_event)
{
retval = (*klass->device_event) (listener, &event);
if (klass->device_event)
{
retval = (*klass->device_event) (listener, &event);
+ if (retval != 0 && retval != 1)
+ {
+ g_warning ("at-spi: device event handler returned %d; should be 0 or 1", retval);
+ retval = 0;
+ }
}
done:
reply = dbus_message_new_method_return (message);
}
done:
reply = dbus_message_new_method_return (message);
@@
-415,8
+400,7
@@
done:
gchar *
_atspi_device_listener_get_path (AtspiDeviceListener *listener)
gchar *
_atspi_device_listener_get_path (AtspiDeviceListener *listener)
-{
- return g_strdup_printf ("/org/a11y/atspi/listeners/%d", listener->id);
+{ return g_strdup_printf ("/org/a11y/atspi/listeners/%d", listener->id);
}
G_DEFINE_BOXED_TYPE (AtspiDeviceEvent,
}
G_DEFINE_BOXED_TYPE (AtspiDeviceEvent,