+static AtkPlugClass *plug_class;
+static AtkSocketClass *socket_class;
+
+static gchar *
+get_plug_id (AtkPlug * plug)
+{
+ const char *uname = dbus_bus_get_unique_name (spi_global_app_data->bus);
+ gchar *path;
+ GString *str = g_string_new (NULL);
+
+ path = spi_register_object_to_path (spi_global_register, G_OBJECT (plug));
+ 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);
+ gchar *plug_name, *plug_path;
+
+ /* Force registration */
+ gchar *path = spi_register_object_to_path (spi_global_register, G_OBJECT (accessible));
+ /* 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, 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);
+ }
+ g_free (plug_name);
+ g_free (path);
+}