X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=atk-adaptor%2Faccessible-marshaller.c;h=4d247fc56b0c3fb7ed9bef97fb29d523c0e01758;hb=3e1f56f6e2c63ad90e13214ac13a2dc848e925b5;hp=75c225c7f8f7ea2d92f89b95e3b2dbc4487bcd3d;hpb=8c4d94a38049f87297628cd5e2f561001c432f72;p=platform%2Fcore%2Fuifw%2Fat-spi2-atk.git diff --git a/atk-adaptor/accessible-marshaller.c b/atk-adaptor/accessible-marshaller.c index 75c225c..4d247fc 100644 --- a/atk-adaptor/accessible-marshaller.c +++ b/atk-adaptor/accessible-marshaller.c @@ -20,37 +20,102 @@ * Boston, MA 02111-1307, USA. */ +#include +#include + +#include "common/spi-dbus.h" +#include "common/spi-stateset.h" + #include "accessible-register.h" #include "accessible-marshaller.h" +#include "bridge.h" -#include "spi-common/spi-dbus.h" - -#define INVALID_PATH "/Invalid" +#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); +} + +void +spi_dbus_append_name_and_path (DBusMessage *message, DBusMessageIter *iter, AtkObject *obj, gboolean do_register, gboolean unref) +{ + gchar *path; + DBusMessageIter iter_struct; + const char *bus_name = dbus_bus_get_unique_name (atk_adaptor_app_data->bus); + + 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, bus_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 (unref) - g_object_unref (obj); + if (sub && unref) + g_object_unref (sub); + + if (!path) + path = g_strdup (SPI_DBUS_PATH_NULL); reply = dbus_message_new_method_return (message); if (reply) { - dbus_message_append_args (reply, DBUS_TYPE_OBJECT_PATH, path, + dbus_message_append_args (reply, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID); } + + g_free (path); + return reply; } @@ -65,19 +130,25 @@ spi_dbus_return_object (DBusMessage *message, AtkObject *obj, gboolean unref) 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); } /*---------------------------------------------------------------------------*/ -static void +void append_atk_object_interfaces (AtkObject *object, DBusMessageIter *iter) { const gchar *itf; @@ -166,56 +237,66 @@ append_atk_object_interfaces (AtkObject *object, DBusMessageIter *iter) * 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; + set = atk_object_ref_state_set (obj); dbus_message_iter_open_container (iter_array, DBUS_TYPE_STRUCT, NULL, &iter_struct); { AtkObject *parent; gchar *path, *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); /* Marshall parent */ parent = atk_object_get_parent(obj); if (parent == NULL) { - path_parent = g_strdup("/"); + 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) { - path_parent = g_strdup(INVALID_PATH); + /* This should only happen if a widget is re-parented to + * an AtkObject that has not been registered and is then + * updated. Ideally objects would be de-registered when + * they are removed from a registered tree object, but + * this would invalidate a huge amount of cache when + * re-parenting. + */ +#if SPI_ATK_DEBUG + g_warning ("AT-SPI: Registered accessible marshalled when parent not registered"); +#endif + path_parent = atk_dbus_desktop_object_path (); } } - dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH, &path_parent); + + dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH, &path); + spi_dbus_append_name_and_path_inner (&iter_struct, NULL, path_parent); g_free(path_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; @@ -226,16 +307,31 @@ spi_atk_append_accessible(AtkObject *obj, gpointer iter) gchar *child_path; child = atk_object_ref_accessible_child (obj, i); - child_path = atk_dbus_object_to_path (child); - g_object_unref(G_OBJECT(child)); - if (!G_LIKELY (child_path)) + child_path = atk_dbus_object_to_path (child, FALSE); + if (child_path) { - child_path = g_strdup(INVALID_PATH); + spi_dbus_append_name_and_path_inner (&iter_sub_array, NULL, child_path); + g_free (child_path); } - dbus_message_iter_append_basic (&iter_sub_array, DBUS_TYPE_OBJECT_PATH, &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 = strchr (child_name + 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 */ @@ -262,7 +358,7 @@ spi_atk_append_accessible(AtkObject *obj, gpointer iter) 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++) { @@ -271,6 +367,33 @@ spi_atk_append_accessible(AtkObject *obj, gpointer iter) dbus_message_iter_close_container (&iter_struct, &iter_sub_array); } dbus_message_iter_close_container (iter_array, &iter_struct); + g_object_unref (set); +} + +void +spi_atk_append_attribute_set (DBusMessageIter *iter, AtkAttributeSet *attr) +{ + DBusMessageIter dictIter; + + dbus_message_iter_open_container (iter, DBUS_TYPE_ARRAY, "{ss}", &dictIter); + spi_atk_append_attribute_set_inner (&dictIter, attr); + dbus_message_iter_close_container (iter, &dictIter); +} + +void +spi_atk_append_attribute_set_inner (DBusMessageIter *iter, AtkAttributeSet *attr) +{ + DBusMessageIter dictEntryIter; + + while (attr) + { + AtkAttribute *attribute = (AtkAttribute *) attr->data; + dbus_message_iter_open_container (iter, DBUS_TYPE_DICT_ENTRY, NULL, &dictEntryIter); + dbus_message_iter_append_basic (&dictEntryIter, DBUS_TYPE_STRING, &attribute->name); + dbus_message_iter_append_basic (&dictEntryIter, DBUS_TYPE_STRING, &attribute->value); + dbus_message_iter_close_container (iter, &dictEntryIter); + attr = g_slist_next (attr); + } } /*END------------------------------------------------------------------------*/