[at-spi2-core] Add GetRegisteredEvents and EventListenerRegistered/Deregistered signals
- From: Mike Gorse <mgorse src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [at-spi2-core] Add GetRegisteredEvents and EventListenerRegistered/Deregistered signals
- Date: Mon, 16 Aug 2010 23:29:10 +0000 (UTC)
commit 079dc02743b3c3994afadc6e4f886d06ee8f5faf
Author: Mike Gorse <mgorse novell com>
Date: Mon Aug 16 18:31:37 2010 -0400
Add GetRegisteredEvents and EventListenerRegistered/Deregistered signals
registryd/introspection.c | 30 ++++++++
registryd/introspection.h | 2 +
registryd/paths.h | 2 +-
registryd/registry.c | 177 ++++++++++++++++++++++++++++++++++++++++-----
xml/Accessibility.xml | 1 +
xml/Makefile.am | 1 +
xml/Registry.xml | 30 ++++++++
7 files changed, 224 insertions(+), 19 deletions(-)
---
diff --git a/registryd/introspection.c b/registryd/introspection.c
index 198c241..837b655 100644
--- a/registryd/introspection.c
+++ b/registryd/introspection.c
@@ -731,6 +731,36 @@ const char *spi_org_a11y_atspi_Value =
"</interface>"
"";
+const char *spi_org_a11y_atspi_Registry =
+"<interface name=\"org.a11y.atspi.Registry\" version=\"0.1.7\">"
+""
+" <method name=\"RegisterEvent\">"
+" <arg direction=\"in\" name=\"event\" type=\"s\">"
+" </arg>"
+" </method>"
+""
+" <method name=\"DeregisterEvent\">"
+" <arg direction=\"in\" name=\"event\" type=\"s\">"
+" </arg>"
+" </method>"
+""
+" <method name=\"GetRegisteredEvents\">"
+" <arg direction=\"out\" name=\"events\" type=\"a(ss)\">"
+" </arg>"
+" </method>"
+""
+" <signal name=\"EventListenerRegistered\">"
+" <arg direction=\"out\" name=\"bus\" type=\"s\" />"
+" <arg direction=\"out\" name=\"path\" type=\"s\" />"
+" </signal>"
+""
+" <signal name=\"EventListenerDeregistered\">"
+" <arg direction=\"out\" name=\"bus\" type=\"s\" />"
+" <arg direction=\"out\" name=\"path\" type=\"s\" />"
+" </signal>"
+"</interface>"
+"";
+
const char *spi_org_a11y_atspi_DeviceEventController =
"<interface name=\"org.a11y.atspi.DeviceEventController\" version=\"0.1.7\">"
""
diff --git a/registryd/introspection.h b/registryd/introspection.h
index 8ebd641..7224078 100644
--- a/registryd/introspection.h
+++ b/registryd/introspection.h
@@ -43,6 +43,8 @@ const char *spi_org_a11y_atspi_Cache;
const char *spi_org_a11y_atspi_Value;
+const char *spi_org_a11y_atspi_Registry;
+
const char *spi_org_a11y_atspi_DeviceEventController;
const char *spi_org_a11y_atspi_DeviceEventListener;
diff --git a/registryd/paths.h b/registryd/paths.h
index b0f3f7a..61c79f9 100644
--- a/registryd/paths.h
+++ b/registryd/paths.h
@@ -33,11 +33,11 @@
#define SPI_DBUS_NAME_REGISTRY SPI_DBUS_NAME_PREFIX "Registry"
#define SPI_DBUS_INTERFACE_REGISTRY SPI_DBUS_INTERFACE_PREFIX "Registry"
+#define SPI_DBUS_PATH_REGISTRY SPI_DBUS_PATH_PREFIX "registry"
#define SPI_DBUS_PATH_DEC SPI_DBUS_PATH_PREFIX "registry/deviceeventcontroller"
#define SPI_DBUS_INTERFACE_DEC SPI_DBUS_INTERFACE_PREFIX "DeviceEventController"
#define SPI_DBUS_INTERFACE_DEVICE_EVENT_LISTENER SPI_DBUS_INTERFACE_PREFIX "DeviceEventListener"
-#define SPI_DBUS_INTERFACE_APPLICATION SPI_DBUS_INTERFACE_PREFIX "Application"
#define SPI_DBUS_INTERFACE_ACCESSIBLE SPI_DBUS_INTERFACE_PREFIX "Accessible"
#define SPI_DBUS_INTERFACE_COMPONENT SPI_DBUS_INTERFACE_PREFIX "Component"
diff --git a/registryd/registry.c b/registryd/registry.c
index 3c4ddf5..e292310 100644
--- a/registryd/registry.c
+++ b/registryd/registry.c
@@ -230,6 +230,7 @@ remove_events (SpiRegistry *registry, const char *bus_name, const char *event)
gchar **remove_data;
GList *list;
gboolean mouse_found = FALSE;
+ DBusMessage *signal;
remove_data = g_strsplit (event, ":", 3);
if (!remove_data)
@@ -261,6 +262,14 @@ remove_events (SpiRegistry *registry, const char *bus_name, const char *event)
spi_device_event_controller_stop_poll_mouse ();
g_strfreev (remove_data);
+
+ signal = dbus_message_new_signal (SPI_DBUS_PATH_REGISTRY,
+ SPI_DBUS_INTERFACE_REGISTRY,
+ "EventListenerDeregistered");
+ dbus_message_append_args (signal, DBUS_TYPE_STRING, &bus_name,
+ DBUS_TYPE_STRING, &event, DBUS_TYPE_INVALID);
+ dbus_connection_send (registry->bus, signal, NULL);
+ dbus_message_unref (signal);
}
static void
@@ -295,8 +304,8 @@ handle_disconnection (DBusConnection *bus, DBusMessage *message, void *user_data
}
/*
- * Converts names of th eform "active-descendant-changed" to
- *"ActiveDesendantChanged"
+ * Converts names of the form "active-descendant-changed" to
+ *" ActiveDescendantChanged"
*/
static gchar *
ensure_proper_format (const char *name)
@@ -325,6 +334,7 @@ ensure_proper_format (const char *name)
*p++ = *name;
name++;
}
+ *p = '\0';
return ret;
}
@@ -783,7 +793,7 @@ impl_GetInterfaces (DBusConnection * bus,
* a method call and signal for now.
*/
static DBusMessage *
-impl_register_event_listener (DBusConnection *bus, DBusMessage *message, void *user_data)
+impl_register_event (DBusConnection *bus, DBusMessage *message, void *user_data)
{
SpiRegistry *registry = SPI_REGISTRY (user_data);
const char *orig_name;
@@ -791,6 +801,8 @@ impl_register_event_listener (DBusConnection *bus, DBusMessage *message, void *u
event_data *evdata;
gchar **data;
GList *new_list;
+ DBusMessage *signal;
+ const char *sender = dbus_message_get_sender (message);
if (!dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &orig_name,
DBUS_TYPE_INVALID))
@@ -807,7 +819,11 @@ impl_register_event_listener (DBusConnection *bus, DBusMessage *message, void *u
g_free (evdata);
return;
}
- evdata->bus_name = g_strdup (dbus_message_get_sender (message));
+ if (!data [0])
+ data [1] = NULL;
+ if (!data [1])
+ data [2] = NULL;
+ evdata->bus_name = g_strdup (sender);
evdata->data = data;
new_list = g_list_append (registry->events, evdata);
if (new_list)
@@ -818,30 +834,69 @@ impl_register_event_listener (DBusConnection *bus, DBusMessage *message, void *u
spi_device_event_controller_start_poll_mouse (registry);
}
+ signal = dbus_message_new_signal (SPI_DBUS_PATH_REGISTRY,
+ SPI_DBUS_INTERFACE_REGISTRY,
+ "EventListenerRegistered");
+ dbus_message_append_args (signal, DBUS_TYPE_STRING, &sender,
+ DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID);
+ dbus_connection_send (bus, signal, NULL);
+ dbus_message_unref (signal);
+
g_free (name);
- /* TODO: Send a signal */
return dbus_message_new_method_return (message);
}
static DBusMessage *
-impl_deregister_event_listener (DBusConnection *bus, DBusMessage *message, void *user_data)
+impl_deregister_event (DBusConnection *bus, DBusMessage *message, void *user_data)
{
SpiRegistry *registry = SPI_REGISTRY (user_data);
const char *orig_name;
gchar *name;
+ const char *sender = dbus_message_get_sender (message);
if (!dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &orig_name,
DBUS_TYPE_INVALID))
return;
name = ensure_proper_format (orig_name);
- remove_events (registry, dbus_message_get_sender (message), name);
+ remove_events (registry, sender, name);
- /* TODO: Send a signal */
g_free (name);
return dbus_message_new_method_return (message);
}
+static DBusMessage *
+impl_get_registered_events (DBusConnection *bus, DBusMessage *message, void *user_data)
+{
+ SpiRegistry *registry = SPI_REGISTRY (user_data);
+ event_data *evdata;
+ DBusMessage *reply;
+ DBusMessageIter iter, iter_struct, iter_array;
+ GList *list;
+
+ 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)", &iter_array);
+ for (list = registry->events; list; list = list->next)
+ {
+ gchar *str;
+ evdata = list->data;
+ str = g_strconcat (evdata->data [0],
+ ":", (evdata->data [1]? evdata->data [1]: ""),
+ ":", (evdata->data [2]? evdata->data [2]: ""), NULL);
+ dbus_message_iter_open_container (&iter_array, DBUS_TYPE_STRUCT, NULL, &iter_struct);
+ dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &evdata->bus_name);
+ dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &str);
+ dbus_message_iter_close_container (&iter_array, &iter_struct);
+ g_free (str);
+ }
+ dbus_message_iter_close_container (&iter, &iter_array);
+ return reply;
+}
+
/*---------------------------------------------------------------------------*/
static void
@@ -871,7 +926,7 @@ static const char *introspection_footer =
"</node>";
static DBusMessage *
-impl_Introspect (DBusConnection * bus,
+impl_Introspect_root (DBusConnection * bus,
DBusMessage * message, void *user_data)
{
GString *output;
@@ -899,6 +954,34 @@ impl_Introspect (DBusConnection * bus,
return reply;
}
+static DBusMessage *
+impl_Introspect_registry (DBusConnection * bus,
+ DBusMessage * message, void *user_data)
+{
+ GString *output;
+ gchar *final;
+ gint i;
+
+ const gchar *pathstr = SPI_DBUS_PATH_REGISTRY;
+
+ DBusMessage *reply;
+
+ output = g_string_new(introspection_header);
+
+ g_string_append_printf(output, introspection_node_element, pathstr);
+
+ g_string_append (output, spi_org_a11y_atspi_Registry);
+
+ g_string_append(output, introspection_footer);
+ final = g_string_free(output, FALSE);
+
+ reply = dbus_message_new_method_return (message);
+ dbus_message_append_args(reply, DBUS_TYPE_STRING, &final, DBUS_TYPE_INVALID);
+
+ g_free(final);
+ return reply;
+}
+
/*---------------------------------------------------------------------------*/
/*
@@ -981,7 +1064,7 @@ children_removed_listener (DBusConnection * bus,
/*---------------------------------------------------------------------------*/
static DBusHandlerResult
-handle_method (DBusConnection *bus, DBusMessage *message, void *user_data)
+handle_method_root (DBusConnection *bus, DBusMessage *message, void *user_data)
{
DBusHandlerResult result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -1114,21 +1197,70 @@ handle_method (DBusConnection *bus, DBusMessage *message, void *user_data)
result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
- if (!strcmp (iface, SPI_DBUS_INTERFACE_APPLICATION))
+ if (!strcmp (iface, "org.freedesktop.DBus.Introspectable"))
{
result = DBUS_HANDLER_RESULT_HANDLED;
- if (!strcmp(member, "RegisterEventListener"))
- reply = impl_register_event_listener (bus, message, user_data);
- else if (!strcmp(member, "DeregisterEventListener"))
- reply = impl_deregister_event_listener (bus, message, user_data);
+ if (!strcmp (member, "Introspect"))
+ reply = impl_Introspect_root (bus, message, user_data);
else
result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
+
+ if (result == DBUS_HANDLER_RESULT_HANDLED)
+ {
+ if (!reply)
+ {
+ reply = dbus_message_new_method_return (message);
+ }
+
+ dbus_connection_send (bus, reply, NULL);
+ dbus_message_unref (reply);
+ }
+#if 0
+ else
+ {
+ g_print ("Registry | Unhandled message : %s|%s\n", iface, member);
+ }
+#endif
+
+ return result;
+}
+
+static DBusHandlerResult
+handle_method_registry (DBusConnection *bus, DBusMessage *message, void *user_data)
+{
+ DBusHandlerResult result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+ const gchar *iface = dbus_message_get_interface (message);
+ const gchar *member = dbus_message_get_member (message);
+ const gint type = dbus_message_get_type (message);
+
+ DBusMessage *reply = NULL;
+
+ /* Check for basic reasons not to handle */
+ if (type != DBUS_MESSAGE_TYPE_METHOD_CALL ||
+ member == NULL ||
+ iface == NULL)
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+ if (!strcmp (iface, SPI_DBUS_INTERFACE_REGISTRY))
+ {
+ result = DBUS_HANDLER_RESULT_HANDLED;
+ if (!strcmp(member, "RegisterEvent"))
+ reply = impl_register_event (bus, message, user_data);
+ else if (!strcmp(member, "DeregisterEvent"))
+ reply = impl_deregister_event (bus, message, user_data);
+ else if (!strcmp(member, "GetRegisteredEvents"))
+ reply = impl_get_registered_events (bus, message, user_data);
+ else
+ result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+
if (!strcmp (iface, "org.freedesktop.DBus.Introspectable"))
{
result = DBUS_HANDLER_RESULT_HANDLED;
if (!strcmp (member, "Introspect"))
- reply = impl_Introspect (bus, message, user_data);
+ reply = impl_Introspect_registry (bus, message, user_data);
else
result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
@@ -1155,10 +1287,17 @@ handle_method (DBusConnection *bus, DBusMessage *message, void *user_data)
/*---------------------------------------------------------------------------*/
+static DBusObjectPathVTable root_vtable =
+{
+ NULL,
+ &handle_method_root,
+ NULL, NULL, NULL, NULL
+};
+
static DBusObjectPathVTable registry_vtable =
{
NULL,
- &handle_method,
+ &handle_method_registry,
NULL, NULL, NULL, NULL
};
@@ -1175,7 +1314,9 @@ spi_registry_new (DBusConnection *bus)
dbus_bus_add_match (bus, app_sig_match_name_owner, NULL);
dbus_connection_add_filter (bus, signal_filter, reg, NULL);
- dbus_connection_register_object_path (bus, SPI_DBUS_PATH_ROOT, ®istry_vtable, reg);
+ dbus_connection_register_object_path (bus, SPI_DBUS_PATH_ROOT, &root_vtable, reg);
+
+ dbus_connection_register_object_path (bus, SPI_DBUS_PATH_REGISTRY, ®istry_vtable, reg);
emit_Available (bus);
diff --git a/xml/Accessibility.xml b/xml/Accessibility.xml
index 0475db9..a7ae110 100644
--- a/xml/Accessibility.xml
+++ b/xml/Accessibility.xml
@@ -15,6 +15,7 @@
<xi:include href="EditableText.xml" parse="xml"/>
<xi:include href="Cache.xml" parse="xml"/>
<xi:include href="Value.xml" parse="xml"/>
+ <xi:include href="Registry.xml" parse="xml"/>
<xi:include href="DeviceEventController.xml" parse="xml"/>
<xi:include href="DeviceEventListener.xml" parse="xml"/>
</spec>
diff --git a/xml/Makefile.am b/xml/Makefile.am
index 0b7534a..ff2c17d 100644
--- a/xml/Makefile.am
+++ b/xml/Makefile.am
@@ -15,6 +15,7 @@ EXTRA_DIST = \
Hyperlink.xml \
Hypertext.xml \
Image.xml \
+ Registry.xml \
remove-annotations.xsl \
Selection.xml \
Socket.xml \
diff --git a/xml/Registry.xml b/xml/Registry.xml
new file mode 100644
index 0000000..a3ab93c
--- /dev/null
+++ b/xml/Registry.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<node name="/node">
+<interface name="org.a11y.atspi.Registry">
+
+ <method name="RegisterEvent">
+ <arg direction="in" name="event" type="s">
+ </arg>
+ </method>
+
+ <method name="DeregisterEvent">
+ <arg direction="in" name="event" type="s">
+ </arg>
+ </method>
+
+ <method name="GetRegisteredEvents">
+ <arg direction="out" name="events" type="a(ss)">
+ </arg>
+ </method>
+
+ <signal name="EventListenerRegistered">
+ <arg direction="out" name="bus" type="s"/>
+ <arg direction="out" name="path" type="s"/>
+ </signal>
+
+ <signal name="EventListenerDeregistered">
+ <arg direction="out" name="bus" type="s"/>
+ <arg direction="out" name="path" type="s"/>
+ </signal>
+</interface>
+</node>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]