[at-spi2-atk] Plug/socket fixes
- From: Mike Gorse <mgorse src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [at-spi2-atk] Plug/socket fixes
- Date: Fri, 9 Apr 2010 20:54:43 +0000 (UTC)
commit c22a02deaa59a6568c989df606cf84b3860933d3
Author: Mike Gorse <mgorse novell com>
Date: Fri Apr 9 16:51:56 2010 -0400
Plug/socket fixes
Override GetExtents, GetSize, and GetPosition for a plug to query the socket.
Do not register an application if the root is an AtkPlug.
Move Embedded method to the Socket interface.
atk-adaptor/adaptors/Makefile.am | 1 +
atk-adaptor/adaptors/accessible-adaptor.c | 22 ---
atk-adaptor/adaptors/socket-adaptor.c | 205 +++++++++++++++++++++++++++++
atk-adaptor/bridge.c | 5 +-
4 files changed, 209 insertions(+), 24 deletions(-)
---
diff --git a/atk-adaptor/adaptors/Makefile.am b/atk-adaptor/adaptors/Makefile.am
index 28991fb..59a6ece 100644
--- a/atk-adaptor/adaptors/Makefile.am
+++ b/atk-adaptor/adaptors/Makefile.am
@@ -25,6 +25,7 @@ libatk_bridge_adaptors_la_SOURCES =\
hypertext-adaptor.c \
image-adaptor.c \
selection-adaptor.c \
+ socket-adaptor.c \
table-adaptor.c \
text-adaptor.c \
value-adaptor.c
diff --git a/atk-adaptor/adaptors/accessible-adaptor.c b/atk-adaptor/adaptors/accessible-adaptor.c
index 818fca4..b40c5f9 100644
--- a/atk-adaptor/adaptors/accessible-adaptor.c
+++ b/atk-adaptor/adaptors/accessible-adaptor.c
@@ -496,27 +496,6 @@ impl_GetInterfaces (DBusConnection * bus,
return reply;
}
-static DBusMessage *
-impl_Embedded (DBusConnection *bus,
- DBusMessage *message,
- void *user_data)
-{
- AtkObject *object = (AtkObject *) user_data;
- char *path;
- gchar *id;
-
- if (!dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &path, DBUS_TYPE_INVALID))
- {
- return droute_invalid_arguments_error (message);
- }
- id = g_object_get_data (G_OBJECT (object), "dbus-plug-parent");
- if (id)
- g_free (id);
- id = g_strconcat (dbus_message_get_sender (message), ":", path, NULL);
- g_object_set_data (G_OBJECT (object), "dbus-plug-parent", id);
- return dbus_message_new_method_return (message);
-}
-
static DRouteMethod methods[] = {
{impl_GetChildAtIndex, "GetChildAtIndex"},
{impl_GetChildren, "GetChildren"},
@@ -529,7 +508,6 @@ static DRouteMethod methods[] = {
{impl_GetAttributes, "GetAttributes"},
{impl_GetApplication, "GetApplication"},
{impl_GetInterfaces, "GetInterfaces"},
- {impl_Embedded, "Embedded"},
{NULL, NULL}
};
diff --git a/atk-adaptor/adaptors/socket-adaptor.c b/atk-adaptor/adaptors/socket-adaptor.c
new file mode 100644
index 0000000..1b57fc6
--- /dev/null
+++ b/atk-adaptor/adaptors/socket-adaptor.c
@@ -0,0 +1,205 @@
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2008 Novell, Inc.
+ * Copyright 2001, 2002 Sun Microsystems Inc.,
+ * Copyright 2001, 2002 Ximian, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <atk/atk.h>
+#include <droute/droute.h>
+
+#include "common/spi-dbus.h"
+#include "common/spi-stateset.h"
+#include "object.h"
+#include "introspection.h"
+#include "bridge.h"
+
+static DBusMessage *
+new_socket_call_message (AtkComponent *component, const char *member)
+{
+ char *id = g_object_get_data (G_OBJECT (component), "dbus-plug-parent");
+ char *bus_parent;
+ char *path_parent;
+
+ if (!id)
+ {
+ g_warning ("new_socket_call_message: no id");
+ return NULL;
+ }
+ bus_parent = g_strdup (id);
+ if (bus_parent && (path_parent = g_utf8_strchr (bus_parent + 1, -1, ':')))
+ {
+ DBusMessage *message;
+ *(path_parent++) = '\0';
+ message = dbus_message_new_method_call (bus_parent, path_parent,
+ SPI_DBUS_INTERFACE_COMPONENT,
+ member);
+ g_free (bus_parent);
+ return message;
+ }
+ return NULL;
+}
+
+static void
+atspi_plug_component_get_extents (AtkComponent *component, gint *x, gint *y,
+ gint *width, gint *height,
+ AtkCoordType coord_type)
+{
+ DBusMessage *message = new_socket_call_message (component, "GetExtents");
+ DBusMessage *reply;
+ dbus_uint32_t coord_type_dbus = coord_type;
+ DBusError error;
+ const char *signature;
+ DBusMessageIter iter, iter_struct;
+ dbus_int32_t tmp;
+
+ dbus_error_init (&error);
+ dbus_message_append_args (message, DBUS_TYPE_UINT32, &coord_type_dbus, DBUS_TYPE_INVALID);
+ reply = dbus_connection_send_with_reply_and_block (spi_global_app_data->bus,
+ message, -1, &error);
+ dbus_message_unref (message);
+ if (!reply)
+ return;
+ signature = dbus_message_get_signature (reply);
+ if (strcmp (signature, "(iiii)") != 0)
+ {
+ g_warning ("Got unexpected signature %s from GetExtents: %s\n", signature);
+ dbus_message_unref (reply);
+ return;
+ }
+ dbus_message_iter_init (reply, &iter);
+ dbus_message_iter_recurse (&iter, &iter_struct);
+ dbus_message_iter_get_basic (&iter_struct, &tmp);
+ *x = tmp;
+ dbus_message_iter_next (&iter_struct);
+ dbus_message_iter_get_basic (&iter_struct, &tmp);
+ *y = tmp;
+ dbus_message_iter_next (&iter_struct);
+ dbus_message_iter_get_basic (&iter_struct, &tmp);
+ *width = tmp;
+ dbus_message_iter_next (&iter_struct);
+ dbus_message_iter_get_basic (&iter_struct, &tmp);
+ *height = tmp;
+ dbus_message_unref (reply);
+}
+
+static void
+atspi_plug_component_get_position (AtkComponent *component, gint *x, gint *y,
+ AtkCoordType coord_type)
+{
+ DBusMessage *message = new_socket_call_message (component, "GetPosition");
+ DBusMessage *reply;
+ dbus_uint32_t coord_type_dbus = coord_type;
+ DBusError error;
+ dbus_int32_t x_dbus, y_dbus;
+
+ dbus_error_init (&error);
+ dbus_message_append_args (message, DBUS_TYPE_UINT32, &coord_type_dbus, DBUS_TYPE_INVALID);
+ reply = dbus_connection_send_with_reply_and_block (spi_global_app_data->bus,
+ message, -1, &error);
+ dbus_message_unref (message);
+ if (!reply)
+ return;
+ if (!dbus_message_get_args (reply, &error, DBUS_TYPE_INT32, &x_dbus,
+ DBUS_TYPE_INT32, &y_dbus, DBUS_TYPE_INVALID))
+ {
+ g_warning ("GetPosition failed: %s", error.message);
+ dbus_error_free (&error);
+ }
+ else
+ {
+ *x = x_dbus;
+ *y = y_dbus;
+ }
+ dbus_message_unref (reply);
+}
+
+static void
+atspi_plug_component_get_size (AtkComponent *component,
+ gint *width, gint *height)
+{
+ DBusMessage *message = new_socket_call_message (component, "GetSize");
+ DBusMessage *reply;
+ DBusError error;
+ dbus_uint32_t width_dbus, height_dbus;
+
+ dbus_error_init (&error);
+ reply = dbus_connection_send_with_reply_and_block (spi_global_app_data->bus,
+ message, -1, &error);
+ dbus_message_unref (message);
+ if (!reply)
+ return;
+ if (!dbus_message_get_args (reply, &error, DBUS_TYPE_INT32, &width_dbus,
+ DBUS_TYPE_INT32, &height_dbus, DBUS_TYPE_INVALID))
+ {
+ g_warning ("GetSize failed: %s", error.message);
+ dbus_error_free (&error);
+ }
+ else
+ {
+ *width = width_dbus;
+ *height = height_dbus;
+ }
+ dbus_message_unref (reply);
+}
+
+static DBusMessage *
+impl_Embedded (DBusConnection *bus,
+ DBusMessage *message,
+ void *user_data)
+{
+ AtkObject *object = (AtkObject *) user_data;
+ char *path;
+ gchar *id;
+
+ if (!dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &path, DBUS_TYPE_INVALID))
+ {
+ return droute_invalid_arguments_error (message);
+ }
+ id = g_object_get_data (G_OBJECT (object), "dbus-plug-parent");
+ if (id)
+ g_free (id);
+ id = g_strconcat (dbus_message_get_sender (message), ":", path, NULL);
+ g_object_set_data (G_OBJECT (object), "dbus-plug-parent", id);
+
+ if (ATK_IS_COMPONENT (object))
+ {
+ AtkComponent *component = ATK_COMPONENT (object);
+ AtkComponentIface *iface = ATK_COMPONENT_GET_IFACE (component);
+ iface->get_extents = atspi_plug_component_get_extents;
+ iface->get_size = atspi_plug_component_get_size;
+ iface->get_position = atspi_plug_component_get_position;
+ }
+ return dbus_message_new_method_return (message);
+}
+
+static DRouteMethod methods[] = {
+ {impl_Embedded, "Embedded"},
+ {NULL, NULL}
+};
+
+void
+spi_initialize_socket (DRoutePath * path)
+{
+ droute_path_add_interface (path,
+ SPI_DBUS_INTERFACE_SOCKET,
+ NULL, /* spi_org_a11y_atspi_Socket, */
+ methods, NULL);
+};
diff --git a/atk-adaptor/bridge.c b/atk-adaptor/bridge.c
index a2ab66c..489f1b1 100644
--- a/atk-adaptor/bridge.c
+++ b/atk-adaptor/bridge.c
@@ -305,7 +305,7 @@ socket_embed_hook (AtkSocket * socket, gchar * plug_id)
{
DBusMessage *message;
*(plug_path++) = '\0';
- message = dbus_message_new_method_call (plug_name, plug_path, "org.a11y.atspi.Accessible", "Embedded");
+ message = dbus_message_new_method_call (plug_name, plug_path, SPI_DBUS_INTERFACE_SOCKET, "Embedded");
dbus_message_append_args (message, DBUS_TYPE_STRING, &path, DBUS_TYPE_INVALID);
dbus_connection_send (spi_global_app_data->bus, message, NULL);
}
@@ -450,6 +450,7 @@ adaptor_init (gint * argc, gchar ** argv[])
spi_initialize_hypertext (accpath);
spi_initialize_image (accpath);
spi_initialize_selection (accpath);
+ spi_initialize_socket (accpath);
spi_initialize_table (accpath);
spi_initialize_text (accpath);
spi_initialize_value (accpath);
@@ -461,7 +462,7 @@ adaptor_init (gint * argc, gchar ** argv[])
install_plug_hooks ();
/* Register this app by sending a signal out to AT-SPI registry daemon */
- if (!atspi_no_register)
+ if (!atspi_no_register && (!root || !ATK_IS_PLUG (root)))
register_application (spi_global_app_data);
g_atexit (exit_func);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]