* Boston, MA 02111-1307, USA.
*/
-#include "spi-common/spi-dbus.h"
+#include <droute/droute.h>
+
+#include "common/spi-dbus.h"
+#include "common/spi-stateset.h"
#include "accessible-register.h"
#include "accessible-marshaller.h"
+#include "bridge.h"
+
+#include "adaptors.h"
/*---------------------------------------------------------------------------*/
+void
+spi_dbus_append_name_and_path_inner (DBusMessageIter *iter, const char *bus_name, const char *path)
+{
+ DBusMessageIter iter_struct;
+
+ if (!bus_name)
+ bus_name = "";
+
+ dbus_message_iter_open_container (iter, DBUS_TYPE_STRUCT, NULL, &iter_struct);
+ dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &bus_name);
+ dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH, &path);
+ dbus_message_iter_close_container (iter, &iter_struct);
+}
+
+extern gchar *atspi_dbus_name;
+
+void
+spi_dbus_append_name_and_path (DBusMessage *message, DBusMessageIter *iter, AtkObject *obj, gboolean do_register, gboolean unref)
+{
+ gchar *path;
+ DBusMessageIter iter_struct;
+
+ path = atk_dbus_object_to_path (obj, do_register);
+
+ if (!path)
+ path = g_strdup (SPI_DBUS_PATH_NULL);
+
+ spi_dbus_append_name_and_path_inner (iter, atspi_dbus_name, path);
+
+ g_free (path);
+ if (obj && unref)
+ g_object_unref (obj);
+}
+
/*
* Marshals the D-Bus path of an AtkObject into a D-Bus message.
*
* Unrefs the AtkObject if unref is true.
*/
DBusMessage *
-spi_dbus_return_object (DBusMessage *message, AtkObject *obj, gboolean unref)
+spi_dbus_return_object (DBusMessage *message, AtkObject *obj, gboolean do_register, gboolean unref)
+{
+ DBusMessage *reply;
+ reply = dbus_message_new_method_return (message);
+ if (reply)
+ {
+ DBusMessageIter iter;
+ dbus_message_iter_init_append (reply, &iter);
+ spi_dbus_append_name_and_path (message, &iter, obj, do_register, unref);
+ }
+
+ return reply;
+}
+
+DBusMessage *
+spi_dbus_return_hyperlink (DBusMessage *message, AtkHyperlink *link, AtkObject *container, gboolean unref)
+{
+ return spi_dbus_return_sub_object (message, G_OBJECT (link), G_OBJECT (container), unref);
+}
+
+DBusMessage *
+spi_dbus_return_sub_object (DBusMessage *message, GObject *sub, GObject *container, gboolean unref)
{
DBusMessage *reply;
gchar *path;
- path = atk_dbus_object_to_path (obj);
+ path = atk_dbus_sub_object_to_path (sub, container);
- if (obj && unref)
- g_object_unref (obj);
+ if (sub && unref)
+ g_object_unref (sub);
if (!path)
path = g_strdup (SPI_DBUS_PATH_NULL);
dbus_bool_t
spi_dbus_return_v_object (DBusMessageIter *iter, AtkObject *obj, int unref)
{
+ DBusMessageIter iter_variant;
char *path;
- path = atk_dbus_object_to_path (obj);
+ path = atk_dbus_object_to_path (obj, FALSE);
+
+ if (!path)
+ path = g_strdup (SPI_DBUS_PATH_NULL);
if (unref)
g_object_unref (obj);
- return droute_return_v_object (iter, path);
+ dbus_message_iter_open_container (iter, DBUS_TYPE_VARIANT, "(so)", &iter_variant);
+ spi_dbus_append_name_and_path_inner (&iter_variant, NULL, path);
+ dbus_message_iter_close_container (iter, &iter_variant);
+ return TRUE;
}
/*---------------------------------------------------------------------------*/
-static void
+void
append_atk_object_interfaces (AtkObject *object, DBusMessageIter *iter)
{
const gchar *itf;
* Marshals the given AtkObject into the provided D-Bus iterator.
*
* The object is marshalled including all its client side cache data.
- * The format of the structure is (ooaoassusau).
- * This is used in the updateTree signal and the getTree method
+ * The format of the structure is (o(so)a(so)assusau).
+ * This is used in the updateTree signal and the GetTree method
* of the org.freedesktop.atspi.Tree interface.
*
* To marshal an object its parent, and all its children must already
* be registered with D-Bus and have been given a D-Bus object path.
*/
void
-spi_atk_append_accessible(AtkObject *obj, gpointer iter)
+spi_atk_append_accessible(AtkObject *obj, gpointer data)
{
- DBusMessageIter *iter_array;
DBusMessageIter iter_struct, iter_sub_array;
- dbus_int32_t states [2];
+ dbus_uint32_t states [2];
int count;
+ AtkStateSet *set;
+ DBusMessageIter *iter_array = (DBusMessageIter *)data;
const char *name, *desc;
- int i;
dbus_uint32_t role;
- GSList *l;
- iter_array = (DBusMessageIter *) iter;
-
- dbus_message_iter_open_container (iter_array, DBUS_TYPE_STRUCT, NULL, &iter_struct);
+ set = atk_object_ref_state_set (obj);
{
AtkObject *parent;
- gchar *path, *path_parent;
+ gchar *path;
+ gchar *bus_parent = NULL, *path_parent;
/* Marshall object path */
- path = atk_dbus_object_to_path (obj);
- dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH, &path);
+ path = atk_dbus_object_to_path (obj, FALSE);
+
+ role = spi_accessible_role_from_atk_role (atk_object_get_role (obj));
/* Marshall parent */
parent = atk_object_get_parent(obj);
if (parent == NULL)
{
- path_parent = atk_dbus_desktop_object_path ();
+ /* TODO: Support getting parent of an AtkPlug */
+#ifdef __ATK_PLUG_H__
+ if (role != Accessibility_ROLE_APPLICATION && !ATK_IS_PLUG (obj))
+#else
+ if (role != Accessibility_ROLE_APPLICATION)
+#endif
+ path_parent = g_strdup (SPI_DBUS_PATH_NULL);
+ else
+ path_parent = atk_dbus_desktop_object_path ();
}
else
{
- path_parent = atk_dbus_object_to_path (parent);
+ path_parent = atk_dbus_object_to_path (parent, FALSE);
if (!path_parent)
{
/* This should only happen if a widget is re-parented to
path_parent = atk_dbus_desktop_object_path ();
}
}
- dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH, &path_parent);
+
+ dbus_message_iter_open_container (iter_array, DBUS_TYPE_STRUCT, NULL, &iter_struct);
+ dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH, &path);
+ spi_dbus_append_name_and_path_inner (&iter_struct, bus_parent, path_parent);
g_free(path_parent);
+ g_free (bus_parent);
/* Marshall children */
- dbus_message_iter_open_container (&iter_struct, DBUS_TYPE_ARRAY, "o", &iter_sub_array);
+ dbus_message_iter_open_container (&iter_struct, DBUS_TYPE_ARRAY, "(so)", &iter_sub_array);
+ if (!atk_state_set_contains_state (set, ATK_STATE_MANAGES_DESCENDANTS))
{
gint childcount, i;
gchar *child_path;
child = atk_object_ref_accessible_child (obj, i);
- child_path = atk_dbus_object_to_path (child);
+ child_path = atk_dbus_object_to_path (child, FALSE);
if (child_path)
{
- dbus_message_iter_append_basic (&iter_sub_array, DBUS_TYPE_OBJECT_PATH, &child_path);
+ spi_dbus_append_name_and_path_inner (&iter_sub_array, NULL, child_path);
g_free (child_path);
}
g_object_unref(G_OBJECT(child));
}
}
+#ifdef __ATK_PLUG_H__
+ if (ATK_IS_SOCKET (obj) && atk_socket_is_occupied (ATK_SOCKET(obj)))
+ {
+ AtkSocket *socket = ATK_SOCKET(obj);
+ gchar *child_name, *child_path;
+ child_name = g_strdup (socket->embedded_plug_id);
+ child_path = g_utf8_strchr (child_name + 1, -1, ':');
+ if (child_path)
+ {
+ *(child_path++) = '\0';
+ spi_dbus_append_name_and_path_inner (&iter_sub_array, child_name, child_path);
+ }
+ g_free (child_name);
+ }
+#endif
+
dbus_message_iter_close_container (&iter_struct, &iter_sub_array);
/* Marshall interfaces */
dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &name);
/* Marshall role */
- role = spi_accessible_role_from_atk_role (atk_object_get_role (obj));
dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_UINT32, &role);
/* Marshall description */
g_free(path);
/* Marshall state set */
- spi_atk_state_to_dbus_array (obj, &states);
+ spi_atk_state_set_to_dbus_array (set, states);
dbus_message_iter_open_container (&iter_struct, DBUS_TYPE_ARRAY, "u", &iter_sub_array);
for (count = 0; count < 2; count++)
{
dbus_message_iter_close_container (&iter_struct, &iter_sub_array);
}
dbus_message_iter_close_container (iter_array, &iter_struct);
+ g_object_unref (set);
}
void