[at-spi2-atk/p2p: 1/5] enable peer to peer comunication for at-spi2
- From: Mike Gorse <mgorse src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [at-spi2-atk/p2p: 1/5] enable peer to peer comunication for at-spi2
- Date: Tue, 31 Aug 2010 01:18:54 +0000 (UTC)
commit 04e3cb2489a765fee0e24f92f9ba2048f81edf81
Author: Trevor Saunders <trev saunders gmail com>
Date: Sat Jul 31 01:08:37 2010 -0400
enable peer to peer comunication for at-spi2
Each application will setup a dbus server listening on a unix socket in
/tmp/at-spi2/xxxxxx. A getApplicationBusAddress method is added to
atk-adaptors/adaptors/application-adaptor.c so that clients of at-spi2
can get the address of the socket on which to contact the application
server. This method returns a string which is a dbus address so it can
be passed directly to dbus_connection_open.
atk-adaptor/adaptors/application-adaptor.c | 15 +++++++++++
atk-adaptor/bridge.c | 37 ++++++++++++++++++++++++++++
atk-adaptor/bridge.h | 1 +
3 files changed, 53 insertions(+), 0 deletions(-)
---
diff --git a/atk-adaptor/adaptors/application-adaptor.c b/atk-adaptor/adaptors/application-adaptor.c
index 71f146b..bc8c431 100644
--- a/atk-adaptor/adaptors/application-adaptor.c
+++ b/atk-adaptor/adaptors/application-adaptor.c
@@ -28,6 +28,9 @@
#include "common/spi-dbus.h"
#include "introspection.h"
+/* for spi_global_app_data is there a better way? */
+#include "../bridge.h"
+
static dbus_bool_t
impl_get_ToolkitName (DBusMessageIter * iter, void *user_data)
{
@@ -87,12 +90,24 @@ impl_GetLocale (DBusConnection * bus, DBusMessage * message, void *user_data)
return NULL;
}
+static DBusMessage *
+impl_get_app_bus(DBusConnection *bus, DBusMessage *msg, void *data)
+{
+DBusMessage *reply;
+
+reply = dbus_message_new_method_return(msg);
+if(reply) dbus_message_append_args(reply, DBUS_TYPE_STRING, &(spi_global_app_data->app_bus_addr), DBUS_TYPE_INVALID);
+
+return reply;
+}
+
static DRouteMethod methods[] = {
{impl_registerToolkitEventListener, "registerToolkitEventListener"},
{impl_registerObjectEventListener, "registerObjectEventListener"},
{impl_pause, "pause"},
{impl_resume, "resume"},
{impl_GetLocale, "GetLocale"},
+ {impl_get_app_bus, "getApplicationBusAddress"},
{NULL, NULL}
};
diff --git a/atk-adaptor/bridge.c b/atk-adaptor/bridge.c
index f7c3fa8..356b5fc 100644
--- a/atk-adaptor/bridge.c
+++ b/atk-adaptor/bridge.c
@@ -330,6 +330,16 @@ register_application (SpiBridge * app)
if (message)
dbus_message_unref (message);
+/* could this be better, we accept some amount of race in getting the temp name*/
+/* make sure the directory exists */
+mkdir("/tmp/at-spi2/", 0);
+app->app_bus_addr = mktmp("/tmp/at-spi2/app-socket-xxxxxx");
+ }
+ else
+ {
+ g_warning ("AT-SPI: Could not embed inside desktop: %s\n", error.message);
+ return FALSE;
+ }
return TRUE;
}
@@ -506,6 +516,30 @@ install_plug_hooks ()
socket_class->embed = socket_embed_hook;
}
+static void new_connection_cb(DBusServer *server, DBusConnection *con, void *data)
+{
+dbus_connection_ref(con);
+dbus_connection_setup_with_g_main(con, NULL);
+}
+
+static int setup_bus(void)
+{
+DBusServer *server;
+DBusError err;
+
+dbus_error_init(&err);
+ server = dbus_server_listen(spi_global_app_data->app_bus_addr, &err);
+
+/* is there a better way to handle this */
+if(server == NULL) return -1;
+
+dbus_server_setup_with_g_main(server, NULL);
+dbus_server_set_new_connection_function(server, new_connection_cb, NULL, NULL);
+
+return 0;
+}
+
+
gchar *atspi_dbus_name = NULL;
static gboolean atspi_no_register = FALSE;
@@ -620,6 +654,7 @@ signal_filter (DBusConnection *bus, DBusMessage *message, void *user_data)
*
* - DRoute for routing message to their accessible objects.
* - Event handlers for emmitting signals on specific ATK events.
+ * - setup the bus for p2p communication
* - Application registration with the AT-SPI registry.
*
*/
@@ -755,6 +790,8 @@ adaptor_init (gint * argc, gchar ** argv[])
else
get_registered_event_listeners (spi_global_app_data);
+ setup_bus();
+
g_atexit (exit_func);
return 0;
diff --git a/atk-adaptor/bridge.h b/atk-adaptor/bridge.h
index 05fa56a..7410235 100644
--- a/atk-adaptor/bridge.h
+++ b/atk-adaptor/bridge.h
@@ -56,6 +56,7 @@ struct _SpiBridge
*/
gchar *desktop_name;
gchar *desktop_path;
+char *app_bus_addr;
GList *events;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]