spi_dbus_initialize (&ad->droute);
/* Below line for testing -- it should be removed once at-spi-registryd is working */
if (dbus_bus_request_name(ad->droute.bus, "test.atspi.tree", 0, &error)) printf("Got test name.\n");
- if (!dbus_connection_try_register_fallback (ad->droute.bus, "/org/freedesktop/atspi", &droute_vtable, &ad->droute, &error))
+ spi_register_tree_object(ad->droute.bus, "/org/freedesktop/atspi/tree");
+ if (!dbus_connection_try_register_fallback (ad->droute.bus, "/org/freedesktop/atspi/accessible/", &droute_vtable, &ad->droute, &error))
{
g_warning("Couldn't register droute.\n");
}
$(X_CFLAGS)
libspi_la_LDFLAGS = @LT_VERSION_INFO@ -no-undefined
+libspi_la_CFLAGS = -DATSPI_DBUS_INTROSPECTION_DIRECTORY="\"$(datadir)/at-spi/dbus\""
libspi_la_LIBADD = $(LIBSPI_LIBS) $(XTST_LIBS)
libspiincludedir = $(includedir)/at-spi-1.0/libspi
accessible.h \
bitarray.h \
dbus.h \
- droute.h
+ droute.h \
+ introspect-loader.h
BUILT_SOURCES = Accessibility.h
CLEANFILES = Accessibility.h
libspi_la_SOURCES = \
- Accessibility.h \
+ Accessibility.h \
accessible.c \
- action.c \
+ action.c \
application.c \
component.c \
- dbus.c \
+ dbus.c \
document.c \
- droute.c \
+ droute.c \
editabletext.c \
hyperlink.c \
hypertext.c \
selection.c \
table.c \
text.c \
- tree.c \
- value.c
+ tree.c \
+ value.c \
+ introspect-loader.c \
+ introspectable.c
Accessibility.h: ../xml/spec.xml ../tools/c-constants-generator.xsl
xsltproc --stringparam mixed-case-prefix Accessibility_ ../tools/c-constants-generator.xsl $< >$@
void spi_initialize_image(DRouteData *data);
void spi_initialize_selection(DRouteData *data);
void spi_initialize_table(DRouteData *data);
-void spi_initialize_tree(DRouteData *data);
void spi_initialize_text(DRouteData *data);
void spi_initialize_value(DRouteData *data);
+void spi_initialize_introspectable(DRouteData *data);
+
+void spi_register_tree_object(DBusConnection *bus, const char *path);
dbus_bool_t spi_dbus_append_tree (DBusMessage * message, AtkObject * obj, DRouteData * data);
spi_initialize_image (data);
spi_initialize_selection (data);
spi_initialize_table (data);
- spi_initialize_tree (data);
spi_initialize_text (data);
spi_initialize_value (data);
+ spi_initialize_introspectable(data);
}
static GString *
#include <dbus.h>
#include "droute.h"
+#include "introspect-loader.h"
/*
* This file contains an implementation of the D-Bus introspectable interface.
*/
/*
- * Provides the dist install path for the introspection directory.
- */
-#if !defined ATSPI_DBUS_INTROSPECTION_DIRECTORY
- #error "No introspection XML directory defined"
-#endif
-
-char *spi_introspection_directory = ATSPI_DBUS_INTROSPECTION_DIRECTORY;
-
-static const char *introspection_header =
-"<?xml version=\"1.0\"?>\n";
-
-static const char *introspection_node_element =
-"<node name=\"%s\">\n";
-
-static const char *introspection_footer =
-"</node>";
-
-void
-spi_initialize_introspectable (DRouteData *data);
-
-static void
-append_interface (GString *str, const char *interface)
-{
- char *filename;
- char *contents;
- gsize len;
-
- GError *err = NULL;
-
- filename = g_build_filename(spi_introspection_directory, interface, NULL);
-
- if (g_file_get_contents(filename, &contents, &len, &err))
- {
- g_string_append_len(str, contents, len);
- }
- else
- {
- g_warning("AT-SPI: Cannot find introspection XML file %s - %s",
- filename, err->message);
- g_error_free(err);
- }
-
- g_string_append(str, "\n");
- g_free(filename);
- g_free(contents);
-}
-
-/*
- * There is an installation directory with files containing introspection xml.
- * Each file is named after the interface it describes.
- *
* This function finds the names of each interface that the ATK object supports
- * and mem copies the introspection data from the file into the message.
- *
- * TODO - There could be some wicked caching here, but probably not neccessary.
+ * and appends the introspection XML for each interface.
*/
static DBusMessage *
impl_introspect (DBusConnection *bus, DBusMessage *message,
path = dbus_message_get_path(message);
object = spi_dbus_get_object(path);
- output = g_string_new(introspection_header);
+ output = g_string_new(spi_introspection_header);
- g_string_append_printf(output, introspection_node_element, path);
+ g_string_append_printf(output, spi_introspection_node_element, path);
if (ATK_IS_ACTION (object))
- append_interface(output, "org.freedesktop.atspi.Action");
+ spi_append_interface(output, "org.freedesktop.atspi.Action");
if (ATK_IS_COMPONENT (object))
- append_interface(output, "org.freedesktop.atspi.Component");
+ spi_append_interface(output, "org.freedesktop.atspi.Component");
if (ATK_IS_EDITABLE_TEXT (object))
- append_interface(output, "org.freedesktop.atspi.EditableText");
+ spi_append_interface(output, "org.freedesktop.atspi.EditableText");
else if (ATK_IS_TEXT (object))
- append_interface(output, "org.freedesktop.atspi.Text");
+ spi_append_interface(output, "org.freedesktop.atspi.Text");
if (ATK_IS_HYPERTEXT (object))
- append_interface(output, "org.freedesktop.atspi.Hypertext");
+ spi_append_interface(output, "org.freedesktop.atspi.Hypertext");
if (ATK_IS_IMAGE (object))
- append_interface(output, "org.freedesktop.atspi.Image");
+ spi_append_interface(output, "org.freedesktop.atspi.Image");
if (ATK_IS_SELECTION (object))
- append_interface(output, "org.freedesktop.atspi.Selection");
+ spi_append_interface(output, "org.freedesktop.atspi.Selection");
if (ATK_IS_TABLE (object))
- append_interface(output, "org.freedesktop.atspi.Table");
+ spi_append_interface(output, "org.freedesktop.atspi.Table");
if (ATK_IS_VALUE (object))
- append_interface(output, "org.freedesktop.atspi.Value");
+ spi_append_interface(output, "org.freedesktop.atspi.Value");
if (ATK_IS_STREAMABLE_CONTENT (object))
- append_interface(output, "org.freedesktop.atspi.StreamableContent");
+ spi_append_interface(output, "org.freedesktop.atspi.StreamableContent");
if (ATK_IS_DOCUMENT (object))
{
- append_interface(output, "org.freedesktop.atspi.Collection");
- append_interface(output, "org.freedesktop.atspi.Document");
+ spi_append_interface(output, "org.freedesktop.atspi.Collection");
+ spi_append_interface(output, "org.freedesktop.atspi.Document");
}
if (ATK_IS_HYPERLINK_IMPL (object))
- append_interface(output, "org.freedesktop.atspi.Hyperlink");
+ spi_append_interface(output, "org.freedesktop.atspi.Hyperlink");
- g_string_append(output, introspection_footer);
+ g_string_append(output, spi_introspection_footer);
final = g_string_free(output, FALSE);
reply = dbus_message_new_method_return (message);
void
spi_initialize_introspectable (DRouteData *data)
{
- droute_add_interface (data, "org.freedesktop.atspi.Accessible",
+ droute_add_interface (data, "org.freedesktop.atspi.Introspectable",
methods, NULL,
(DRouteGetDatumFunction) spi_dbus_get_path, NULL);
};
* Boston, MA 02111-1307, USA.
*/
+#include <string.h>
+
#include "accessible.h"
+#include "introspect-loader.h"
#define get_object(message) spi_dbus_get_object(dbus_message_get_path(message))
return reply;
}
-static DRouteMethod methods[] = {
- {impl_getRoot, "getRoot"},
- {impl_getTree, "getTree", TRUE},
- {NULL, NULL}
+static DBusMessage *
+impl_introspect (DBusConnection *bus, DBusMessage *message, void *user_data)
+{
+ const char *path;
+ GString *output;
+ char *final;
+
+ DBusMessage *reply;
+
+ path = dbus_message_get_path(message);
+
+ output = g_string_new(spi_introspection_header);
+
+ g_string_append_printf(output, spi_introspection_node_element, path);
+
+ spi_append_interface(output, "org.freedesktop.atspi.Tree");
+
+ g_string_append(output, spi_introspection_footer);
+ final = g_string_free(output, FALSE);
+
+ reply = dbus_message_new_method_return (message);
+ g_assert(reply != NULL);
+ dbus_message_append_args(reply, DBUS_TYPE_STRING, &final,
+ DBUS_TYPE_INVALID);
+
+ g_free(final);
+ return reply;
+}
+
+static DBusHandlerResult
+message_handler (DBusConnection *bus, DBusMessage *message, void *user_data)
+{
+ const char *iface = dbus_message_get_interface (message);
+ const char *member = dbus_message_get_member (message);
+
+ DBusMessage *reply = NULL;
+
+ if (!strcmp(iface, "org.freedesktop.atspi.Tree"))
+ {
+ if (!strcmp(member, "getRoot"))
+ {
+ reply = impl_getRoot(bus, message, user_data);
+ }
+
+ if (!strcmp(member, "getTree"))
+ {
+ reply = impl_getTree(bus, message, user_data);
+ }
+ }
+
+ if (!strcmp(iface, "org.freedesktop.DBus.Introspectable"))
+ {
+ if (!strcmp(member, "Introspect"))
+ {
+ reply = impl_introspect(bus, message, user_data);
+ }
+ }
+
+ if (reply)
+ {
+ dbus_connection_send (bus, reply, NULL);
+ dbus_message_unref (reply);
+ }
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+}
+
+static DBusObjectPathVTable tree_vtable =
+{
+ NULL,
+ &message_handler,
+ NULL, NULL, NULL, NULL
};
void
-spi_initialize_tree (DRouteData * data)
+spi_register_tree_object(DBusConnection *bus,
+ const char *path)
{
- droute_add_interface (data, "org.freedesktop.atspi.Tree",
- methods, NULL, NULL, NULL);
-};
+ dbus_bool_t mem = FALSE;
+ mem = dbus_connection_register_object_path(bus, path, &tree_vtable, NULL);
+ g_assert(mem == TRUE);
+}
static GHashTable *cache_list;
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Array of Accessible Object proxy structures to be added.</p>
</tp:docstring>
+ </arg>
<arg name="nodesRemoved" type="ao">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Array of Accessible Object proxy structures to be removed.</p>
--- /dev/null
+ <interface name="org.freedesktop.atspi.Tree">
+ <method name="getRoot">
+ <arg name="root" type="o" direction="out"/>
+ </method>
+ <method name="getTree">
+ <arg name="nodes" type="a(ooaoassus)" direction="out"/>
+ </method>
+ <signal name="updateTree">
+ <arg name="nodesAdded" type="a(ooaoassus)"/>
+ <arg name="nodesRemoved" type="ao"/>
+ </signal>
+ </interface>