[at-spi2-atk] Fix parents of plugs



commit 01fb83c0ba436a54fd5450c04b8511b2409b90e2
Author: Mike Gorse <mgorse novell com>
Date:   Wed Jan 6 09:35:19 2010 -0500

    Fix parents of plugs

 atk-adaptor/accessible-adaptor.c    |   26 +++++++++++++++++++++++++-
 atk-adaptor/accessible-marshaller.c |   21 ++++++++++++++++-----
 atk-adaptor/bridge.c                |   19 +++++++++++++++++++
 3 files changed, 60 insertions(+), 6 deletions(-)
---
diff --git a/atk-adaptor/accessible-adaptor.c b/atk-adaptor/accessible-adaptor.c
index 124a702..74a15fe 100644
--- a/atk-adaptor/accessible-adaptor.c
+++ b/atk-adaptor/accessible-adaptor.c
@@ -112,7 +112,9 @@ impl_GetChildAtIndex (DBusConnection *bus,
   g_return_val_if_fail (ATK_IS_OBJECT (user_data),
                         droute_not_yet_handled_error (message));
   if (!dbus_message_get_args (message, &error, DBUS_TYPE_INT32, &i, DBUS_TYPE_INVALID))
-      return spi_dbus_general_error (message);
+    {
+      return droute_invalid_arguments_error (message);
+    }
   child = atk_object_ref_accessible_child (object, i);
   return spi_dbus_return_object (message, child, TRUE, TRUE);
 }
@@ -583,6 +585,27 @@ 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"},
@@ -595,6 +618,7 @@ static DRouteMethod methods[] = {
   {impl_GetAttributes, "GetAttributes"},
   {impl_GetApplication, "GetApplication"},
   {impl_GetInterfaces, "GetInterfaces"},
+  {impl_Embedded, "Embedded"},
   {NULL, NULL}
 };
 
diff --git a/atk-adaptor/accessible-marshaller.c b/atk-adaptor/accessible-marshaller.c
index bccd089..b715e03 100644
--- a/atk-adaptor/accessible-marshaller.c
+++ b/atk-adaptor/accessible-marshaller.c
@@ -40,6 +40,8 @@ spi_dbus_append_name_and_path_inner (DBusMessageIter *iter, const char *bus_name
 
   if (!bus_name)
     bus_name = "";
+  if (!path)
+    path = SPI_DBUS_PATH_NULL;
 
   dbus_message_iter_open_container (iter, DBUS_TYPE_STRUCT, NULL, &iter_struct);
   dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &bus_name);
@@ -57,9 +59,6 @@ spi_dbus_append_name_and_path (DBusMessage *message, DBusMessageIter *iter, AtkO
 
   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);
@@ -261,7 +260,7 @@ spi_atk_append_accessible(AtkObject *obj, gpointer data)
     {
       AtkObject *parent;
       gchar *path;
-      gchar *bus_parent = NULL, *path_parent;
+      gchar *bus_parent = NULL, *path_parent = NULL;
 
       /* Marshall object path */
       path = atk_dbus_object_to_path (obj, FALSE);
@@ -274,7 +273,19 @@ spi_atk_append_accessible(AtkObject *obj, gpointer data)
         {
           /* TODO: Support getting parent of an AtkPlug */
 #ifdef __ATK_PLUG_H__
-          if (role != Accessibility_ROLE_APPLICATION && !ATK_IS_PLUG (obj))
+          if (ATK_IS_PLUG (obj))
+            {
+              char *id = g_object_get_data (G_OBJECT (obj), "dbus-plug-parent");
+              if (id)
+                bus_parent = g_strdup (id);
+              if (bus_parent && (path_parent = g_utf8_strchr (bus_parent + 1, -1, ':')))
+                {
+                  *(path_parent++) = '\0';
+                  /* path_parent is going to be freed, so dup it */
+                  path_parent = g_strdup (path_parent);
+                }
+            }
+          else if (role != Accessibility_ROLE_APPLICATION)
 #else
           if (role != Accessibility_ROLE_APPLICATION)
 #endif
diff --git a/atk-adaptor/bridge.c b/atk-adaptor/bridge.c
index 25bf8f3..08288fd 100644
--- a/atk-adaptor/bridge.c
+++ b/atk-adaptor/bridge.c
@@ -260,9 +260,28 @@ static void
 socket_embed_hook (AtkSocket *socket, gchar *plug_id)
 {
   AtkObject *accessible = ATK_OBJECT(socket);
+  gchar *plug_name, *plug_path;
+
   /* Force registration */
   gchar *path = atk_dbus_object_to_path (accessible, TRUE);
   spi_emit_cache_update (accessible, atk_adaptor_app_data->bus);
+  /* Let the plug know that it has been embedded */
+  plug_name = g_strdup (plug_id);
+  if (!plug_name)
+    {
+      g_free (path);
+      return;
+    }
+  plug_path = g_utf8_strchr (plug_name + 1, -1, ':');
+  if (plug_path)
+    {
+      DBusMessage *message;
+      *(plug_path++) = '\0';
+      message = dbus_message_new_method_call (plug_name, plug_path, "org.freedesktop.atspi.Accessible", "Embedded");
+      dbus_message_append_args (message, DBUS_TYPE_STRING, &path, DBUS_TYPE_INVALID);
+      dbus_connection_send (atk_adaptor_app_data->bus, message, NULL);
+    }
+  g_free (plug_name);
   g_free (path);
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]