Merge branch 'mgorse' into socketplug
authorMike Gorse <mgorse@novell.com>
Wed, 11 Nov 2009 14:24:57 +0000 (09:24 -0500)
committerMike Gorse <mgorse@novell.com>
Wed, 11 Nov 2009 14:24:57 +0000 (09:24 -0500)
atk-adaptor/accessible-marshaller.c
atk-adaptor/bridge.c

index d203430..4d247fc 100644 (file)
@@ -20,6 +20,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
+#include <string.h>
 #include <droute/droute.h>
 
 #include "common/spi-dbus.h"
@@ -315,6 +316,22 @@ spi_atk_append_accessible(AtkObject *obj, gpointer data)
               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 */
index 36d32c7..e1782aa 100644 (file)
@@ -211,6 +211,47 @@ exit_func (void)
 
 /*---------------------------------------------------------------------------*/
 
+#ifdef __ATK_PLUG_H__
+static AtkPlugClass *plug_class;
+static AtkSocketClass *socket_class;
+
+static gchar *
+get_plug_id (AtkPlug *plug)
+{
+  const char *uname = dbus_bus_get_unique_name(atk_adaptor_app_data->bus);
+  gchar *path;
+  GString *str = g_string_new (NULL);
+
+  path = atk_dbus_object_to_path (ATK_OBJECT(plug), TRUE);
+  g_string_printf (str, "%s:%s", uname, path);
+  g_free (path);
+  return g_string_free (str, FALSE);
+}
+
+static void
+socket_embed_hook (AtkSocket *socket, gchar *plug_id)
+{
+  AtkObject *accessible = ATK_OBJECT(socket);
+  /* Force registration */
+  gchar *path = atk_dbus_object_to_path (accessible, TRUE);
+  spi_emit_cache_update (accessible, atk_adaptor_app_data->bus);
+  g_free (path);
+}
+
+static void
+install_plug_hooks ()
+{
+  gpointer data;
+  
+  data = g_type_class_ref (ATK_TYPE_PLUG);
+  plug_class = ATK_PLUG_CLASS (data);
+  data = g_type_class_ref (ATK_TYPE_SOCKET);
+  socket_class = ATK_SOCKET_CLASS (data);
+  plug_class->get_object_id = get_plug_id;
+  socket_class->embed = socket_embed_hook;
+}
+#endif
+
 static gchar *atspi_dbus_name;
 static gboolean atspi_no_register;
 
@@ -323,6 +364,11 @@ adaptor_init (gint *argc, gchar **argv[])
   /* Register methods to send D-Bus signals on certain ATK events */
   spi_atk_register_event_listeners ();
 
+#ifdef __ATK_PLUG_H__
+  /* Hook our plug-and socket functions */
+  install_plug_hooks ();
+#endif
+
   /* Register this app by sending a signal out to AT-SPI registry daemon */
   register_application (atk_adaptor_app_data);