Merge branch 'master' of git+ssh://doffm@git.freedesktop.org/git/at-spi2/at-spi2...
authorMark Doffman <mdoff@silver-wind.(none)>
Thu, 22 Jan 2009 14:38:17 +0000 (14:38 +0000)
committerMark Doffman <mdoff@silver-wind.(none)>
Thu, 22 Jan 2009 14:38:17 +0000 (14:38 +0000)
Conflicts:

atk-adaptor/atk-dbus.c
atk-adaptor/tree.c
registryd/deviceeventcontroller.c

110 files changed:
Makefile.am
atk-adaptor/Makefile.am
atk-adaptor/accessible-adaptor.c [moved from atk-adaptor/accessible.c with 78% similarity]
atk-adaptor/accessible-marshaller.c [new file with mode: 0644]
atk-adaptor/accessible-marshaller.h [moved from atk-adaptor/atk-dbus.h with 63% similarity]
atk-adaptor/accessible-register.c [new file with mode: 0644]
atk-adaptor/accessible-register.h [new file with mode: 0644]
atk-adaptor/accessible.h [deleted file]
atk-adaptor/action-adaptor.c [moved from atk-adaptor/action.c with 73% similarity]
atk-adaptor/action.h [deleted file]
atk-adaptor/adaptors.h [new file with mode: 0644]
atk-adaptor/application-adaptor.c [moved from atk-adaptor/application.c with 83% similarity]
atk-adaptor/application.h [deleted file]
atk-adaptor/atk-dbus.c [deleted file]
atk-adaptor/base.c [deleted file]
atk-adaptor/base.h [deleted file]
atk-adaptor/bridge.c
atk-adaptor/bridge.h
atk-adaptor/collection-adaptor.c [moved from atk-adaptor/collection.c with 96% similarity]
atk-adaptor/collection.h [deleted file]
atk-adaptor/component-adaptor.c [moved from atk-adaptor/component.c with 78% similarity]
atk-adaptor/component.h [deleted file]
atk-adaptor/devicelistener.c [deleted file]
atk-adaptor/devicelistener.h [deleted file]
atk-adaptor/document-adaptor.c [moved from atk-adaptor/document.c with 75% similarity]
atk-adaptor/document.h [deleted file]
atk-adaptor/editabletext-adaptor.c [moved from atk-adaptor/editabletext.c with 79% similarity]
atk-adaptor/editabletext.h [deleted file]
atk-adaptor/event.c
atk-adaptor/event.h [moved from atk-adaptor/spi-private.h with 81% similarity]
atk-adaptor/eventlistener.c [deleted file]
atk-adaptor/eventlistener.h [deleted file]
atk-adaptor/hyperlink-adaptor.c [moved from atk-adaptor/hyperlink.c with 68% similarity]
atk-adaptor/hyperlink.h [deleted file]
atk-adaptor/hypertext-adaptor.c [moved from atk-adaptor/hypertext.c with 73% similarity]
atk-adaptor/hypertext.h [deleted file]
atk-adaptor/image-adaptor.c [moved from atk-adaptor/image.c with 74% similarity]
atk-adaptor/image.h [deleted file]
atk-adaptor/introspectable.c [deleted file]
atk-adaptor/keystrokelistener.h [deleted file]
atk-adaptor/libspi.h [deleted file]
atk-adaptor/listener.c [deleted file]
atk-adaptor/listener.h [deleted file]
atk-adaptor/matchrule.h [deleted file]
atk-adaptor/relation-adaptor.c [moved from atk-adaptor/relation.c with 97% similarity]
atk-adaptor/relation.h [deleted file]
atk-adaptor/remoteobject.c [deleted file]
atk-adaptor/remoteobject.h [deleted file]
atk-adaptor/selection-adaptor.c [moved from atk-adaptor/selection.c with 78% similarity]
atk-adaptor/selection.h [deleted file]
atk-adaptor/streamablecontent-adaptor.c [moved from atk-adaptor/streamablecontent.c with 99% similarity]
atk-adaptor/streamablecontent.h [deleted file]
atk-adaptor/table-adaptor.c [moved from atk-adaptor/table.c with 78% similarity]
atk-adaptor/table.h [deleted file]
atk-adaptor/text-adaptor.c [moved from atk-adaptor/text.c with 85% similarity]
atk-adaptor/text.h [deleted file]
atk-adaptor/tree-adaptor.c [new file with mode: 0644]
atk-adaptor/tree-adaptor.h [moved from atk-adaptor/util.c with 76% similarity]
atk-adaptor/tree.c [deleted file]
atk-adaptor/value-adaptor.c [new file with mode: 0644]
atk-adaptor/value.c [deleted file]
atk-adaptor/value.h [deleted file]
cspi/spi-listener.c
cspi/spi-main.c
cspi/spi-registry.c
dbind/Makefile.am
dbind/dbind-any.c
dbind/dbind-any.h
dbind/dbind.c
dbind/dbind.h
dbind/dbtest.c
droute/Makefile.am
droute/droute-pairhash.c [new file with mode: 0644]
droute/droute-pairhash.h [moved from droute/introspect-loader.h with 69% similarity]
droute/droute-test.c [new file with mode: 0644]
droute/droute-variant.c [new file with mode: 0644]
droute/droute-variant.h [moved from atk-adaptor/matchrule.c with 56% similarity]
droute/droute.c
droute/droute.h
droute/introspect-loader.c [deleted file]
droute/test.interface.One [new file with mode: 0644]
droute/test.interface.Two [new file with mode: 0644]
pyatspi/accessiblecache.py
pyatspi/action.py
pyatspi/application.py
pyatspi/applicationcache.py
pyatspi/base.py
pyatspi/collection.py
pyatspi/component.py
pyatspi/desktop.py
pyatspi/document.py
pyatspi/editabletext.py
pyatspi/hyperlink.py
pyatspi/hypertext.py
pyatspi/image.py
pyatspi/loginhelper.py
pyatspi/registry.py
pyatspi/selection.py
pyatspi/selector.py
pyatspi/streamablecontent.py
pyatspi/table.py
pyatspi/text.py
pyatspi/value.py
registryd/Makefile.am
registryd/deviceeventcontroller.c
registryd/deviceeventcontroller.h
registryd/registry-main.c
registryd/registry.c
registryd/registry.h
xml/org.freedesktop.atspi.Tree.xml

index f485d5a..e40a69d 100644 (file)
@@ -1,4 +1,4 @@
-SUBDIRS=xml tools droute spi-common atk-adaptor registryd dbind cspi pyatspi login-helper tests
+SUBDIRS=xml tools dbind droute spi-common atk-adaptor registryd cspi pyatspi login-helper tests
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libspi-1.0.pc cspi-1.0.pc libloginhelper-1.0.pc
index 51c714f..c47cefc 100644 (file)
@@ -1,7 +1,11 @@
 gtkmoduledir = $(libdir)/$(GTK_MODULE_DIR)
 gtkmodule_LTLIBRARIES = libspiatk.la
 
-libspiatk_la_CFLAGS = $(DBUS_GLIB_CFLAGS) $(ATK_CFLAGS) -I$(top_srcdir)
+libspiatk_la_CFLAGS = $(DBUS_GLIB_CFLAGS)\
+                     $(ATK_CFLAGS)\
+                     -I$(top_srcdir)\
+                     -I$(top_srcdir)/atk-adaptor/adaptors\
+                     -DATSPI_INTROSPECTION_PATH=\"$(pkgdatadir)/$(DEFAULT_ATSPI_INTROSPECTION_PATH)\"
 
 libspiatk_la_LDFLAGS = -no-undefined       \
                       -module             \
@@ -14,27 +18,28 @@ libspiatk_la_LIBADD = $(DBUS_GLIB_LIBS)                     \
                      $(top_builddir)/spi-common/libspicommon.la
 
 libspiatk_la_SOURCES =         \
-       accessible.h            \
-       accessible.c            \
-       action.c                \
-       application.c           \
+       accessible-adaptor.c    \
+       accessible-marshaller.c \
+       accessible-marshaller.h \
+       accessible-register.c   \
+       accessible-register.h   \
+       action-adaptor.c        \
+       adaptor.h               \
+       application-adaptor.c   \
        bridge.c                \
        bridge.h                \
-       collection.c            \
-       component.c             \
-       document.c              \
-       editabletext.c          \
+       collection-adaptor.c    \
+       component-adaptor.c     \
+       document-adaptor.c      \
+       editabletext-adaptor.c  \
        event.c                 \
-       hyperlink.c             \
-       hypertext.c             \
-       atk-dbus.c              \
-       atk-dbus.h              \
-       image.c                 \
-       selection.c             \
-       spi-private.h           \
-       table.c                 \
-       text.c                  \
-       tree.c                  \
-       util.c                  \
-       value.c                 \
-       introspectable.c 
+       event.h                 \
+       hyperlink-adaptor.c     \
+       hypertext-adaptor.c     \
+       image-adaptor.c         \
+       selection-adaptor.c     \
+       table-adaptor.c         \
+       text-adaptor.c          \
+       tree-adaptor.c          \
+       tree-adaptor.h          \
+       value-adaptor.c
similarity index 78%
rename from atk-adaptor/accessible.c
rename to atk-adaptor/accessible-adaptor.c
index 220167e..d93a57f 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
-#include "accessible.h"
+#include <atk/atk.h>
+#include <droute/droute.h>
 
-#define get_object(message) atk_dbus_get_object(dbus_message_get_path(message))
-
-static AtkObject *
-get_object_from_path (const char *path, void *user_data)
-{
-  return atk_dbus_get_object (path);
-}
+#include "spi-common/spi-dbus.h"
+#include "accessible-marshaller.h"
+#include "accessible-register.h"
 
 static dbus_bool_t
-impl_get_name (const char *path, DBusMessageIter * iter, void *user_data)
+impl_get_name (DBusMessageIter *iter, void *user_data)
 {
-  AtkObject *object = atk_dbus_get_object (path);
-  if (!object)
-    return FALSE;
+  AtkObject *object = (AtkObject *) user_data;
+
+  g_return_val_if_fail (ATK_IS_OBJECT (user_data), FALSE);
+
   return droute_return_v_string (iter, atk_object_get_name (object));
 }
 
 static dbus_bool_t
-impl_set_name (const char *path, DBusMessageIter * iter, void *user_data)
+impl_set_name (DBusMessageIter *iter, void *user_data)
 {
-  AtkObject *object = atk_dbus_get_object (path);
+  AtkObject *object = (AtkObject *) user_data;
   const char *name = droute_get_v_string (iter);
+
+  g_return_val_if_fail (ATK_IS_OBJECT (user_data), FALSE);
+
   atk_object_set_name (object, name);
   return TRUE;
 }
 
 static dbus_bool_t
-impl_get_description (const char *path, DBusMessageIter * iter,
-                     void *user_data)
+impl_get_description (DBusMessageIter *iter, void *user_data)
 {
-  AtkObject *object = atk_dbus_get_object (path);
-  if (!object)
-    return FALSE;
+  AtkObject *object = (AtkObject *) user_data;
+
+  g_return_val_if_fail (ATK_IS_OBJECT (user_data), FALSE);
+
   return droute_return_v_string (iter, atk_object_get_description (object));
 }
 
 static dbus_bool_t
-impl_set_description (const char *path, DBusMessageIter * iter,
-                     void *user_data)
+impl_set_description (DBusMessageIter *iter, void *user_data)
 {
-  AtkObject *object = atk_dbus_get_object (path);
+  AtkObject *object = (AtkObject *) user_data;
   const char *description = droute_get_v_string (iter);
+
+  g_return_val_if_fail (ATK_IS_OBJECT (user_data), FALSE);
+
   atk_object_set_description (object, description);
   return TRUE;
 }
 
 static dbus_bool_t
-impl_get_parent (const char *path, DBusMessageIter * iter, void *user_data)
+impl_get_parent (DBusMessageIter *iter, void *user_data)
 {
-  AtkObject *object = atk_dbus_get_object (path);
+  AtkObject *object = (AtkObject *) user_data;
+
+  g_return_val_if_fail (ATK_IS_OBJECT (user_data), FALSE);
 
-  if (!object)
-    return FALSE;
-  return spi_dbus_return_v_object (iter, atk_object_get_parent (object),
-                                  FALSE);
+  return spi_dbus_return_v_object (iter,
+                                   atk_object_get_parent (object),
+                                   FALSE);
 }
 
 static dbus_bool_t
-impl_get_childCount (const char *path, DBusMessageIter * iter,
-                    void *user_data)
+impl_get_childCount (DBusMessageIter *iter, void *user_data)
 {
-  AtkObject *object = atk_dbus_get_object (path);
+  AtkObject *object = (AtkObject *) user_data;
+
+  g_return_val_if_fail (ATK_IS_OBJECT (user_data), FALSE);
 
-  if (!object)
-    return FALSE;
   return droute_return_v_int32 (iter,
-                               atk_object_get_n_accessible_children
-                               (object));
+                                atk_object_get_n_accessible_children
+                                (object));
 }
 
 static DBusMessage *
-impl_getChildAtIndex (DBusConnection * bus, DBusMessage * message,
-                 void *user_data)
+impl_getChildAtIndex (DBusConnection *bus,
+                      DBusMessage *message,
+                      void *user_data)
 {
-  AtkObject *object = get_object (message);
+  AtkObject *object = (AtkObject *) user_data;
+  DBusError error;
   dbus_int32_t i;
   AtkObject *child;
 
-  if (!object)
-    return spi_dbus_general_error (message);
-  if (!dbus_message_get_args (message, NULL, DBUS_TYPE_INT32, &i, DBUS_TYPE_INVALID))
-    return spi_dbus_general_error (message);
+  dbus_error_init (&error);
+  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);
   child = atk_object_ref_accessible_child (object, i);
   return spi_dbus_return_object (message, child, FALSE);
 }
 
 static DBusMessage *
-impl_getChildren (DBusConnection * bus, DBusMessage * message,
-                 void *user_data)
+impl_getChildren (DBusConnection *bus,
+                  DBusMessage *message,
+                  void *user_data)
 {
-  AtkObject *object = get_object (message);
+  AtkObject *object = (AtkObject *) user_data;
   gint i;
   gint count;
   DBusMessage *reply;
   DBusMessageIter iter, iter_array;
 
-  if (!object)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_OBJECT (user_data),
+                        droute_not_yet_handled_error (message));
   count = atk_object_get_n_accessible_children (object);
   reply = dbus_message_new_method_return (message);
   if (!reply) goto oom;
@@ -132,7 +139,7 @@ impl_getChildren (DBusConnection * bus, DBusMessage * message,
   for (i = 0; i < count; i++)
     {
       AtkObject *child = atk_object_ref_accessible_child (object, i);
-      char *path = atk_dbus_get_path (child);
+      char *path = atk_dbus_object_to_path (child);
       if (path)
        {
          dbus_message_iter_append_basic (&iter_array, DBUS_TYPE_OBJECT_PATH,
@@ -151,15 +158,16 @@ oom:
 }
 
 static DBusMessage *
-impl_getIndexInParent (DBusConnection * bus, DBusMessage * message,
-                      void *user_data)
+impl_getIndexInParent (DBusConnection *bus,
+                       DBusMessage *message,
+                       void *user_data)
 {
-  AtkObject *object = get_object (message);
+  AtkObject *object = (AtkObject *) user_data;
   dbus_uint32_t rv;
   DBusMessage *reply;
 
-  if (!object)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_OBJECT (user_data),
+                        droute_not_yet_handled_error (message));
   rv = atk_object_get_index_in_parent (object);
   reply = dbus_message_new_method_return (message);
   if (reply)
@@ -215,18 +223,19 @@ spi_relation_type_from_atk_relation_type (AtkRelationType type)
 }
 
 static DBusMessage *
-impl_getRelationSet (DBusConnection * bus, DBusMessage * message,
-                    void *user_data)
+impl_getRelationSet (DBusConnection *bus,
+                     DBusMessage *message,
+                     void *user_data)
 {
-  AtkObject *object = get_object (message);
+  AtkObject *object = (AtkObject *) user_data;
   DBusMessage *reply;
   AtkRelationSet *set;
   DBusMessageIter iter, iter_array, iter_struct, iter_targets;
   gint count;
   gint i, j;
 
-  if (!object)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_OBJECT (user_data),
+                        droute_not_yet_handled_error (message));
   reply = dbus_message_new_method_return (message);
   if (!reply) return NULL;
   set = atk_object_ref_relation_set (object);
@@ -260,7 +269,7 @@ impl_getRelationSet (DBusConnection * bus, DBusMessage * message,
       AtkObject *obj = target->pdata[j];
       char *path;
       if (!obj) continue;
-      path = atk_dbus_get_path (obj);
+      path = atk_dbus_object_to_path (obj);
       dbus_message_iter_append_basic (&iter_targets, DBUS_TYPE_OBJECT_PATH, &path);
     }
     dbus_message_iter_close_container (&iter_struct, &iter_targets);
@@ -400,15 +409,15 @@ spi_accessible_role_from_atk_role (AtkRole role)
 }
 
 static DBusMessage *
-impl_getRole (DBusConnection * bus, DBusMessage * message, void *user_data)
+impl_getRole (DBusConnection *bus, DBusMessage *message, void *user_data)
 {
-  AtkObject *object = get_object (message);
+  AtkObject *object = (AtkObject *) user_data;
   gint role;
   dbus_uint32_t rv;
   DBusMessage *reply;
 
-  if (!object)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_OBJECT (user_data),
+                        droute_not_yet_handled_error (message));
   role = atk_object_get_role (object);
   rv = spi_accessible_role_from_atk_role (role);
   reply = dbus_message_new_method_return (message);
@@ -430,16 +439,17 @@ impl_get_role_str (void *datum)
 }
 
 static DBusMessage *
-impl_getRoleName (DBusConnection * bus, DBusMessage * message,
-                 void *user_data)
+impl_getRoleName (DBusConnection *bus,
+                  DBusMessage *message,
+                  void *user_data)
 {
-  AtkObject *object = get_object (message);
+  AtkObject *object = (AtkObject *) user_data;
   gint role;
   const char *role_name;
   DBusMessage *reply;
 
-  if (!object)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_OBJECT (user_data),
+                        droute_not_yet_handled_error (message));
   role = atk_object_get_role (object);
   role_name = atk_role_get_name (role);
   if (!role_name)
@@ -454,16 +464,17 @@ impl_getRoleName (DBusConnection * bus, DBusMessage * message,
 }
 
 static DBusMessage *
-impl_getLocalizedRoleName (DBusConnection * bus, DBusMessage * message,
-                          void *user_data)
+impl_getLocalizedRoleName (DBusConnection *bus,
+                           DBusMessage *message,
+                           void *user_data)
 {
-  AtkObject *object = get_object (message);
+  AtkObject *object = (AtkObject *) user_data;
   gint role;
   const char *role_name;
   DBusMessage *reply;
 
-  if (!object)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_OBJECT (user_data),
+                        droute_not_yet_handled_error (message));
   role = atk_object_get_role (object);
   role_name = atk_role_get_localized_name (role);
   if (!role_name)
@@ -478,15 +489,17 @@ impl_getLocalizedRoleName (DBusConnection * bus, DBusMessage * message,
 }
 
 static DBusMessage *
-impl_getState (DBusConnection * bus, DBusMessage * message, void *user_data)
+impl_getState (DBusConnection *bus,
+               DBusMessage *message,
+               void *user_data)
 {
-  AtkObject *object = get_object (message);
+  AtkObject *object = (AtkObject *) user_data;
   dbus_uint32_t rv[2];
   dbus_uint32_t *array = rv;
   DBusMessage *reply;
 
-  if (!object)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_OBJECT (user_data),
+                        droute_not_yet_handled_error (message));
   spi_atk_state_to_dbus_array (object, rv);
   reply = dbus_message_new_method_return (message);
   if (reply)
@@ -498,10 +511,11 @@ impl_getState (DBusConnection * bus, DBusMessage * message, void *user_data)
 }
 
 static DBusMessage *
-impl_getAttributes (DBusConnection * bus, DBusMessage * message,
-                   void *user_data)
+impl_getAttributes (DBusConnection *bus,
+                    DBusMessage *message,
+                    void *user_data)
 {
-  AtkObject *object = get_object (message);
+  AtkObject *object = (AtkObject *) user_data;
   DBusMessage *reply;
   AtkAttributeSet *attributes;
   AtkAttribute *attr = NULL;
@@ -509,8 +523,8 @@ impl_getAttributes (DBusConnection * bus, DBusMessage * message,
   gint n_attributes = 0;
   gint i;
 
-  if (!object)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_OBJECT (user_data),
+                        droute_not_yet_handled_error (message));
 
   attributes = atk_object_get_attributes (object);
   if (attributes)
@@ -538,8 +552,9 @@ impl_getAttributes (DBusConnection * bus, DBusMessage * message,
 }
 
 static DBusMessage *
-impl_getApplication (DBusConnection * bus, DBusMessage * message,
-                    void *user_data)
+impl_getApplication (DBusConnection *bus,
+                     DBusMessage *message,
+                     void *user_data)
 {
   AtkObject *root = atk_get_root ();
   return spi_dbus_return_object (message, root, FALSE);
@@ -568,9 +583,10 @@ static DRouteProperty properties[] = {
 };
 
 void
-spi_initialize_accessible (DRouteData * data)
+spi_initialize_accessible (DRoutePath *path)
 {
-  droute_add_interface (data, SPI_DBUS_INTERFACE_ACCESSIBLE,
-                       methods, properties,
-                       (DRouteGetDatumFunction) get_object_from_path, NULL);
+  droute_path_add_interface (path,
+                             SPI_DBUS_INTERFACE_ACCESSIBLE,
+                             methods,
+                             properties);
 };
diff --git a/atk-adaptor/accessible-marshaller.c b/atk-adaptor/accessible-marshaller.c
new file mode 100644 (file)
index 0000000..6e9de23
--- /dev/null
@@ -0,0 +1,284 @@
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2008 Novell, 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 "spi-common/spi-dbus.h"
+
+#include "accessible-register.h"
+#include "accessible-marshaller.h"
+
+/*---------------------------------------------------------------------------*/
+
+/*
+ * Marshals the D-Bus path of an AtkObject into a D-Bus message.
+ *
+ * Unrefs the AtkObject if unref is true.
+ */
+DBusMessage *
+spi_dbus_return_object (DBusMessage *message, AtkObject *obj, gboolean unref)
+{
+  DBusMessage *reply;
+  gchar *path;
+
+  path = atk_dbus_object_to_path (obj);
+
+  if (unref)
+    g_object_unref (obj);
+
+  reply = dbus_message_new_method_return (message);
+  if (reply)
+    {
+      dbus_message_append_args (reply, DBUS_TYPE_OBJECT_PATH, path,
+                                DBUS_TYPE_INVALID);
+    }
+  return reply;
+}
+
+/*---------------------------------------------------------------------------*/
+
+/*
+ * Marshals a variant containing the D-Bus path of an AtkObject into a D-Bus
+ * message.
+ *
+ * Unrefs the object if unref is true.
+ */
+dbus_bool_t
+spi_dbus_return_v_object (DBusMessageIter *iter, AtkObject *obj, int unref)
+{
+  char *path;
+
+  path = atk_dbus_object_to_path (obj);
+
+  if (unref)
+    g_object_unref (obj);
+
+  return droute_return_v_object (iter, path);
+}
+
+/*---------------------------------------------------------------------------*/
+
+static void
+append_atk_object_interfaces (AtkObject *object, DBusMessageIter *iter)
+{
+  const gchar *itf;
+
+  itf = SPI_DBUS_INTERFACE_ACCESSIBLE;
+  dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf);
+
+  if (ATK_IS_ACTION (object))
+    {
+      itf = SPI_DBUS_INTERFACE_ACTION;
+      dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf);
+    }
+
+  if (ATK_IS_COMPONENT (object))
+    {
+      itf = SPI_DBUS_INTERFACE_COMPONENT;
+      dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf);
+    }
+
+  if (ATK_IS_EDITABLE_TEXT (object))
+    {
+      itf = SPI_DBUS_INTERFACE_EDITABLE_TEXT;
+      dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf);
+    }
+
+  if (ATK_IS_TEXT (object))
+    {
+      itf = SPI_DBUS_INTERFACE_TEXT;
+      dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf);
+    }
+
+  if (ATK_IS_HYPERTEXT (object))
+    {
+      itf = SPI_DBUS_INTERFACE_HYPERTEXT;
+      dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf);
+    }
+
+  if (ATK_IS_IMAGE (object))
+    {
+      itf = SPI_DBUS_INTERFACE_IMAGE;
+      dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf);
+    }
+
+  if (ATK_IS_SELECTION (object))
+    {
+      itf = SPI_DBUS_INTERFACE_SELECTION;
+      dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf);
+    }
+
+  if (ATK_IS_TABLE (object))
+    {
+      itf = SPI_DBUS_INTERFACE_TABLE;
+      dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf);
+    }
+
+  if (ATK_IS_VALUE (object))
+    {
+      itf = SPI_DBUS_INTERFACE_VALUE;
+      dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf);
+    }
+
+  if (ATK_IS_STREAMABLE_CONTENT (object))
+    {
+      itf = "org.freedesktop.atspi.StreamableContent";
+      dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf);
+    }
+
+  if (ATK_IS_DOCUMENT (object))
+    {
+      itf = "org.freedesktop.atspi.Collection";
+      dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf);
+      itf = SPI_DBUS_INTERFACE_DOCUMENT;
+      dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf);
+    }
+
+  if (ATK_IS_HYPERLINK_IMPL (object))
+    {
+      itf = SPI_DBUS_INTERFACE_HYPERLINK;
+      dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &itf);
+    }
+}
+
+/*---------------------------------------------------------------------------*/
+
+/*
+ * Marshals the given AtkObject into the provided D-Bus iterator.
+ *
+ * The object is marshalled including all its client side cache data.
+ * The format of the structure is (ooaoassusau).
+ * This is used in the updateTree signal and the getTree method
+ * of the org.freedesktop.atspi.Tree interface.
+ *
+ * To marshal an object its parent, and all its children must already
+ * be registered with D-Bus and have been given a D-Bus object path.
+ */
+void
+spi_atk_append_accessible(AtkObject *obj, gpointer iter)
+{
+  DBusMessageIter *iter_array;
+  DBusMessageIter iter_struct, iter_sub_array;
+  dbus_int32_t states [2];
+  int count;
+
+  const char *name, *desc;
+  int i;
+  dbus_uint32_t role;
+  GSList *l;
+
+  iter_array = (DBusMessageIter *) iter;
+
+  dbus_message_iter_open_container (iter_array, DBUS_TYPE_STRUCT, NULL, &iter_struct);
+    {
+      AtkObject *parent;
+      gchar *path, *path_parent;
+
+      /* Marshall object path */
+      path = atk_dbus_object_to_path (obj);
+      dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH, &path);
+
+      /* Marshall parent */
+      parent = atk_object_get_parent(obj);
+      if (parent == NULL)
+        {
+          path_parent = atk_dbus_desktop_object_path ();
+        }
+      else
+        {
+          path_parent = atk_dbus_object_to_path (parent);
+          if (!path_parent)
+            {
+              /* This should only happen if a widget is re-parented to
+               * an AtkObject that has not been registered and is then
+               * updated. Ideally objects would be de-registered when
+               * they are removed from a registered tree object, but
+               * this would invalidate a huge amount of cache when
+               * re-parenting.
+               */
+#if SPI_ATK_DEBUG
+              g_warning ("AT-SPI: Registered accessible marshalled when parent not registered");
+#endif
+              path_parent = atk_dbus_desktop_object_path ();
+            }
+        }
+      dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH, &path_parent);
+      g_free(path_parent);
+
+      /* Marshall children */
+      dbus_message_iter_open_container (&iter_struct, DBUS_TYPE_ARRAY, "o", &iter_sub_array);
+        {
+          gint childcount, i;
+
+          childcount = atk_object_get_n_accessible_children (obj);
+          for (i = 0; i < childcount; i++)
+            {
+              AtkObject *child;
+              gchar *child_path;
+
+              child = atk_object_ref_accessible_child (obj, i);
+              child_path = atk_dbus_object_to_path (child);
+              if (child_path)
+                {
+                  dbus_message_iter_append_basic (&iter_sub_array, DBUS_TYPE_OBJECT_PATH, &child_path);
+                  g_free (child_path);
+                }
+              g_object_unref(G_OBJECT(child));
+            }
+        }
+      dbus_message_iter_close_container (&iter_struct, &iter_sub_array);
+
+      /* Marshall interfaces */
+      dbus_message_iter_open_container (&iter_struct, DBUS_TYPE_ARRAY, "s", &iter_sub_array);
+      append_atk_object_interfaces (obj, &iter_sub_array);
+      dbus_message_iter_close_container (&iter_struct, &iter_sub_array);
+
+      /* Marshall name */
+      name = atk_object_get_name (obj);
+      if (!name)
+        name = "";
+      dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &name);
+
+      /* Marshall role */
+      role = spi_accessible_role_from_atk_role (atk_object_get_role (obj));
+      dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_UINT32, &role);
+
+      /* Marshall description */
+      desc = atk_object_get_description (obj);
+      if (!desc)
+        desc = "";
+      dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &desc);
+
+      g_free(path);
+
+      /* Marshall state set */
+      spi_atk_state_to_dbus_array (obj, &states);
+      dbus_message_iter_open_container (&iter_struct, DBUS_TYPE_ARRAY, "u", &iter_sub_array);
+      for (count = 0; count < 2; count++)
+        {
+          dbus_message_iter_append_basic (&iter_sub_array, DBUS_TYPE_UINT32, &states[count]);
+        }
+      dbus_message_iter_close_container (&iter_struct, &iter_sub_array);
+    }
+  dbus_message_iter_close_container (iter_array, &iter_struct);
+}
+
+/*END------------------------------------------------------------------------*/
+
similarity index 63%
rename from atk-adaptor/atk-dbus.h
rename to atk-adaptor/accessible-marshaller.h
index b3b6507..afeeb1b 100644 (file)
@@ -3,6 +3,7 @@
  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
  *
  * Copyright 2008 Novell, Inc.
+ * Copyright 2008, 2009 Codethink Ltd.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
  * Boston, MA 02111-1307, USA.
  */
 
-#ifndef __ATK_DBUS__
-#define __ATK_DBUS__
+#ifndef ACCESSIBLE_MARSHALLER
+#define ACCESSIBLE_MARSHALLER
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "accessible.h"
-
-void
-atk_dbus_foreach_registered(GHFunc func, gpointer data);
-
-void
-atk_dbus_foreach_update_list(GHFunc func, gpointer data);
-
-void
-atk_dbus_foreach_remove_list(GHFunc func, gpointer data);
-
-void 
-atk_dbus_notify_change(AtkObject *accessible);
-
-AtkObject *
-atk_dbus_get_object (const char *path);
-
-gchar *
-atk_dbus_get_path_from_ref(guint ref);
-
-gchar *
-atk_dbus_get_path (AtkObject *accessible);
-
-guint
-atk_dbus_register_subtree(AtkObject *accessible);
+#include <dbus/dbus.h>
+#include <atk/atk.h>
 
 DBusMessage *
 spi_dbus_return_object (DBusMessage *message, AtkObject *obj, gboolean unref);
@@ -60,6 +34,6 @@ dbus_bool_t
 spi_dbus_return_v_object (DBusMessageIter *iter, AtkObject *obj, int unref);
 
 void
-atk_dbus_initialize (DRouteData * data);
+spi_atk_append_accessible(AtkObject *obj, gpointer iter);
 
-#endif /* __ATK_DBUS__ */
+#endif /* ACCESSIBLE_MARSHALLER */
diff --git a/atk-adaptor/accessible-register.c b/atk-adaptor/accessible-register.c
new file mode 100644 (file)
index 0000000..af9f752
--- /dev/null
@@ -0,0 +1,542 @@
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2008 Novell, Inc.
+ * Copyright 2008, 2009 Codethink Ltd.
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "bridge.h"
+#include "accessible-register.h"
+
+/*
+ * This module is responsible for keeping track of all the AtkObjects in
+ * the application, so that they can be accessed remotely and placed in
+ * a client side cache.
+ *
+ * To access an AtkObject remotely we need to provide a D-Bus object 
+ * path for it. The D-Bus object paths used have a standard prefix
+ * (SPI_ATK_OBJECT_PATH_PREFIX). Appended to this prefix is a string
+ * representation of an integer reference. So to access an AtkObject 
+ * remotely we keep a Hashtable that maps the given reference to 
+ * the AtkObject pointer. An object in this hash table is said to be 'registered'.
+ *
+ * The architecture of AT-SPI dbus is such that AtkObjects are not
+ * remotely reference counted. This means that we need to keep track of
+ * object destruction. When an object is destroyed it must be 'deregistered'
+ * To do this lookup we keep a dbus-id attribute on each AtkObject.
+ *
+ * In addition to accessing the objects remotely we must be able to update
+ * the client side cache. This is done using the 'update' signal of the 
+ * org.freedesktop.atspi.Tree interface. The update signal should send out
+ * all of the cacheable data for an Accessible object.
+ *
+ */
+
+/*
+ * FIXME
+ *
+ * This code seems very brittle.
+ * I would prefer changes to be made to
+ * gail and the ATK interface so that all Accessible
+ * objects are registered with an exporting module.
+ *
+ * This is the same system as Qt has with the QAccessibleBridge
+ * and QAccessibleBridgePlugin. It entails some rather
+ * large structural changes to ATK though:
+ *
+ * Removing infinite spaces (Child access no longer references child).
+ * Removing lazy creation of accessible objects.
+ */
+
+#define SPI_ATK_OBJECT_PATH_PREFIX  "/org/freedesktop/atspi/accessible"
+#define SPI_ATK_OBJECT_PATH_DESKTOP "/root"
+
+#define SPI_ATK_PATH_PREFIX_LENGTH 33
+#define SPI_ATK_OBJECT_REFERENCE_TEMPLATE SPI_ATK_OBJECT_PATH_PREFIX "/%d"
+
+
+static GHashTable *ref2ptr = NULL; /* Used for converting a D-Bus path (Reference) to the object pointer */
+
+static guint counter = 1;
+
+static GStaticRecMutex registration_mutex = G_STATIC_REC_MUTEX_INIT;
+
+/*---------------------------------------------------------------------------*/
+
+static GStaticMutex   recursion_check_guard = G_STATIC_MUTEX_INIT;
+static gboolean       recursion_check = FALSE;
+
+static gboolean
+recursion_check_and_set ()
+{
+  gboolean ret;
+  g_static_mutex_lock   (&recursion_check_guard);
+  ret = recursion_check;
+  recursion_check = TRUE;
+  g_static_mutex_unlock (&recursion_check_guard);
+  return ret;
+}
+
+static void
+recursion_check_unset ()
+{
+  g_static_mutex_lock   (&recursion_check_guard);
+  recursion_check = FALSE;
+  g_static_mutex_unlock (&recursion_check_guard);
+}
+
+/*---------------------------------------------------------------------------*/
+
+/*
+ * Each AtkObject must be asssigned a D-Bus path (Reference)
+ *
+ * This function provides an integer reference for a new
+ * AtkObject.
+ */
+static guint
+assign_reference(void)
+{
+  counter++;
+  /* Reference of 0 not allowed as used as direct key in hash table */
+  if (counter == 0)
+    counter++;
+}
+
+/*
+ * Returns the reference of the object, or 0 if it is not registered.
+ */
+static guint
+object_to_ref (AtkObject *accessible)
+{
+  return GPOINTER_TO_INT(g_object_get_data (G_OBJECT (accessible), "dbus-id"));
+}
+
+/*
+ * Converts the Accessible object reference to its D-Bus object path
+ */
+static gchar *
+ref_to_path (guint ref)
+{
+  return g_strdup_printf(SPI_ATK_OBJECT_REFERENCE_TEMPLATE, ref);
+}
+
+/*---------------------------------------------------------------------------*/
+
+/*
+ * Callback for when a registered AtkObject is destroyed.
+ *
+ * Removes the AtkObject from the reference lookup tables, meaning
+ * it is no longer exposed over D-Bus.
+ */
+static void
+deregister_accessible (gpointer data, GObject *accessible)
+{
+  guint ref;
+  g_assert (ATK_IS_OBJECT (accessible));
+
+  ref = object_to_ref (ATK_OBJECT(accessible));
+  if (ref != 0)
+    {
+      g_hash_table_remove(ref2ptr, GINT_TO_POINTER(ref));
+    }
+}
+
+/*
+ * Called to register an AtkObject with AT-SPI and expose it over D-Bus.
+ */
+static void
+register_accessible (AtkObject *accessible)
+{
+  guint ref;
+  g_assert(ATK_IS_OBJECT(accessible));
+
+  ref = assign_reference();
+
+  g_hash_table_insert (ref2ptr, GINT_TO_POINTER(ref), accessible);
+  g_object_set_data (G_OBJECT(accessible), "dbus-id", GINT_TO_POINTER(ref));
+  g_object_weak_ref(G_OBJECT(accessible), deregister_accessible, NULL);
+}
+
+/*---------------------------------------------------------------------------*/
+
+#ifdef SPI_ATK_DEBUG
+/*
+ * This function checks that the ref-count of an accessible
+ * is greater than 1.
+ *
+ * There is not currently any remote reference counting
+ * in AT-SPI D-Bus so objects that are remotely owned are not
+ * allowed.
+ *
+ * TODO Add debug wrapper
+ */
+static gboolean
+non_owned_accessible (AtkObject *accessible)
+{
+   if ((G_OBJECT (accessible))->ref_count <= 1)
+     {
+       g_warning ("AT-SPI: Child referenced that is not owned by its parent");
+       return TRUE;
+     }
+   else
+     {
+       return FALSE;
+     }
+}
+#endif /* SPI_ATK_DEBUG */
+
+/*---------------------------------------------------------------------------*/
+
+static gboolean
+has_manages_descendants (AtkObject *accessible)
+{
+   AtkStateSet *state;
+   gboolean result = FALSE;
+
+   /* This is dangerous, refing the state set
+    * seems to do wierd things to the tree & cause recursion
+    * by modifying the tree alot.
+    */
+   state = atk_object_ref_state_set (accessible);
+   if (atk_state_set_contains_state (state, ATK_STATE_MANAGES_DESCENDANTS))
+     {
+#ifdef SPI_ATK_DEBUG
+       g_warning ("AT-SPI: Object with 'Manages descendants' states not currently handled by AT-SPI");
+#endif
+       result = TRUE;
+     }
+   g_object_unref (state);
+
+   return result;
+}
+
+/*
+ * Registers a subtree of accessible objects
+ * rooted at the accessible object provided.
+ *
+ * The leaf nodes do not have their children
+ * registered. A node is considered a leaf
+ * if it has the state "manages-descendants"
+ * or if it has already been registered.
+ */
+void
+register_subtree (AtkObject *accessible)
+{
+  AtkObject *current, *tmp;
+  GQueue    *stack;
+  guint      i;
+  gboolean   recurse;
+
+
+  current = g_object_ref (accessible);
+  if (has_manages_descendants (current))
+    {
+      g_object_unref (current);
+      return;
+    }
+
+  stack = g_queue_new ();
+
+  register_accessible (current);
+  g_queue_push_head (stack, GINT_TO_POINTER (0));
+
+  /*
+   * The index held on the stack is the next child node
+   * that needs processing at the corresponding level in the tree.
+   */
+  while (!g_queue_is_empty (stack))
+    {
+      /* Find the next child node that needs processing */
+
+      i = GPOINTER_TO_INT(g_queue_peek_head (stack));
+      recurse = FALSE;
+
+      while (i < atk_object_get_n_accessible_children (current) &&
+             recurse == FALSE)
+        {
+          tmp = atk_object_ref_accessible_child (current, i);
+
+#ifdef SPI_ATK_DEBUG
+          non_owned_accessible (tmp);
+#endif
+
+          if (object_to_ref (tmp))
+            {
+              /* If its already registered, just update */
+              spi_emit_cache_update (tmp, atk_adaptor_app_data->bus);
+            }
+          else if (has_manages_descendants (tmp))
+            {
+              /* If it has manages descendants, just register and update */
+              register_accessible (tmp);
+              spi_emit_cache_update (tmp, atk_adaptor_app_data->bus);
+            }
+          else
+            {
+              recurse = TRUE;
+            }
+
+          if (!recurse)
+            {
+              g_object_unref (G_OBJECT (tmp));
+            }
+
+          i++;
+        }
+
+      if (recurse)
+        {
+          /* Push onto stack */
+          current = tmp;
+          register_accessible (current);
+
+          g_queue_peek_head_link (stack)->data = GINT_TO_POINTER (i);
+          g_queue_push_head (stack, GINT_TO_POINTER (0));
+        }
+      else
+        {
+          /* Pop from stack */
+          spi_emit_cache_update (current, atk_adaptor_app_data->bus);
+          tmp = current;
+          current = atk_object_get_parent (current);
+          g_object_unref (G_OBJECT (tmp));
+          g_queue_pop_head (stack);
+        }
+    }
+    g_queue_free (stack);
+}
+
+/*---------------------------------------------------------------------------*/
+
+/*
+ * Called when an already registered object is updated in such a
+ * way that client side cache needs to be updated.
+ */
+static void
+update_accessible (AtkObject *accessible)
+{
+  guint  ref = 0;
+  g_assert(ATK_IS_OBJECT(accessible));
+
+  ref = object_to_ref (accessible);
+  if (ref)
+    {
+      spi_emit_cache_update (accessible, atk_adaptor_app_data->bus);
+    }
+}
+
+/*---------------------------------------------------------------------------*/
+
+void
+atk_dbus_foreach_registered(GHFunc func, gpointer data)
+{
+  g_hash_table_foreach(ref2ptr, func, data);
+}
+
+/*
+ * Used to lookup an AtkObject from its D-Bus path.
+ */
+AtkObject *
+atk_dbus_path_to_object (const char *path)
+{
+  guint index;
+  void *data;
+
+  g_assert (path);
+
+  if (strncmp(path, SPI_ATK_OBJECT_PATH_PREFIX, SPI_ATK_PATH_PREFIX_LENGTH) != 0)
+    return NULL;
+
+  path += SPI_ATK_PATH_PREFIX_LENGTH; /* Skip over the prefix */
+
+  if (!g_strcmp0 (SPI_ATK_OBJECT_PATH_DESKTOP, path))
+     return atk_get_root();
+  if (path[0] != '/')
+     return NULL;
+
+  path++;
+  index = atoi (path);
+  data = g_hash_table_lookup (ref2ptr, GINT_TO_POINTER(index));
+  if (data)
+    return ATK_OBJECT (data);
+  else
+    return NULL;
+}
+
+/*
+ * Used to lookup a D-Bus path from the AtkObject.
+ */
+gchar *
+atk_dbus_object_to_path (AtkObject *accessible)
+{
+  guint ref;
+
+  ref = object_to_ref (accessible);
+  if (!ref)
+      return NULL;
+  else
+      return ref_to_path (ref);
+}
+
+gchar *
+atk_dbus_desktop_object_path ()
+{
+  return g_strdup (SPI_ATK_OBJECT_PATH_PREFIX SPI_ATK_OBJECT_PATH_DESKTOP);
+}
+
+/*---------------------------------------------------------------------------*/
+
+/*
+ * Events are not evaluated for non-registered accessibles.
+ *
+ * When a property change is made on a registered accessible
+ * the client side cache should be updated.
+ *
+ * When a parent is changed the subtree is de-registered
+ * if the parent is not attached to the root accessible.
+ */
+static gboolean
+tree_update_listener (GSignalInvocationHint *signal_hint,
+                      guint                  n_param_values,
+                      const GValue          *param_values,
+                      gpointer               data)
+{
+  AtkObject *accessible;
+  AtkPropertyValues *values;
+  const gchar *pname = NULL;
+
+  g_static_rec_mutex_lock (&registration_mutex);
+
+  /* Ensure that only registered accessibles
+   * have their signals processed.
+   */
+  accessible = g_value_get_object (&param_values[0]);
+  g_assert (ATK_IS_OBJECT (accessible));
+
+  if (object_to_ref (accessible))
+    {
+#ifdef SPI_ATK_DEBUG
+      if (recursion_check_and_set ())
+          g_warning ("AT-SPI: Recursive use of registration module");
+#endif
+
+      values = (AtkPropertyValues*) g_value_get_pointer (&param_values[1]);
+      pname = values[0].property_name;
+      if (strcmp (pname, "accessible-name") == 0 ||
+          strcmp (pname, "accessible-description") == 0)
+        {
+          update_accessible (accessible);
+        }
+      /* Parent value us updated by child-add signal of parent object */
+
+      recursion_check_unset ();
+    }
+
+  g_static_rec_mutex_unlock (&registration_mutex);
+
+  return TRUE;
+}
+
+/*
+ * Events are not evaluated for non registered accessibles.
+ *
+ * When the children of a registered accessible are changed
+ * the subtree, rooted at the child is registered.
+ */
+static gboolean
+tree_update_children_listener (GSignalInvocationHint *signal_hint,
+                               guint                  n_param_values,
+                               const GValue          *param_values,
+                               gpointer               data)
+{
+  AtkObject *accessible;
+  const gchar *detail = NULL;
+  AtkObject *child;
+
+  g_static_rec_mutex_lock (&registration_mutex);
+
+  /* Ensure that only registered accessibles
+   * have their signals processed.
+   */
+  accessible = g_value_get_object (&param_values[0]);
+  g_assert (ATK_IS_OBJECT (accessible));
+
+  if (object_to_ref (accessible))
+    {
+#ifdef SPI_ATK_DEBUG
+      if (recursion_check_and_set ())
+          g_warning ("AT-SPI: Recursive use of registration module");
+#endif
+
+      if (signal_hint->detail)
+          detail = g_quark_to_string (signal_hint->detail);
+
+      if (!strcmp (detail, "add"))
+        {
+          gpointer child;
+          int index = g_value_get_uint (param_values + 1);
+          child = g_value_get_pointer (param_values + 2);
+
+          if (!ATK_IS_OBJECT (child))
+            {
+              child = atk_object_ref_accessible_child (accessible, index);
+#ifdef SPI_ATK_DEBUG
+              non_owned_accessible (child);
+#endif
+            }
+          register_subtree (child);
+        }
+
+      recursion_check_unset ();
+    }
+
+  g_static_rec_mutex_unlock (&registration_mutex);
+
+  return TRUE;
+}
+
+/*
+ * Initializes required global data. The update and removal lists
+ * and the reference lookup tables.
+ *
+ * Initializes all of the required D-Bus interfaces.
+ */
+void
+atk_dbus_initialize (AtkObject *root)
+{
+  if (!ref2ptr)
+    ref2ptr = g_hash_table_new(g_direct_hash, g_direct_equal);
+
+#ifdef SPI_ATK_DEBUG
+  if (g_thread_supported ())
+      g_message ("AT-SPI: Threads enabled");
+#endif
+
+  register_subtree (root);
+
+  atk_add_global_event_listener (tree_update_listener, "Gtk:AtkObject:property-change");
+  atk_add_global_event_listener (tree_update_children_listener, "Gtk:AtkObject:children-changed");
+}
+
+/*END------------------------------------------------------------------------*/
+
diff --git a/atk-adaptor/accessible-register.h b/atk-adaptor/accessible-register.h
new file mode 100644 (file)
index 0000000..a594413
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2008 Novell, Inc.
+ * Copyright 2008, 2009 Codethink Ltd.
+ *
+ * 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.
+ */
+
+#ifndef ACCESSIBLE_REGISTER
+#define ACCESSIBLE_REGISTER
+
+#include <atk/atk.h>
+#include <glib.h>
+
+void
+atk_dbus_foreach_registered(GHFunc func, gpointer data);
+
+/*---------------------------------------------------------------------------*/
+
+AtkObject *
+atk_dbus_path_to_object (const char *path);
+
+gchar *
+atk_dbus_object_to_path (AtkObject *accessible);
+
+gchar *
+atk_dbus_desktop_object_path ();
+
+#endif /* ACCESSIBLE_REGISTER */
diff --git a/atk-adaptor/accessible.h b/atk-adaptor/accessible.h
deleted file mode 100644 (file)
index ce904aa..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-#ifndef SPI_ACCESSIBLE_H_
-#define SPI_ACCESSIBLE_H_
-
-#include <droute/droute.h>
-#include <spi-common/spi-dbus.h>
-#include <spi-common/spi-types.h>
-
-#include "atk/atk.h"
-
-G_BEGIN_DECLS
-
-Accessibility_Role spi_accessible_role_from_atk_role (AtkRole role);
-
-void spi_initialize_accessible(DRouteData *data);
-void spi_initialize_action(DRouteData *data);
-void spi_initialize_application(DRouteData *data);
-void spi_initialize_collection(DRouteData *data);
-void spi_initialize_component(DRouteData *data);
-void spi_initialize_document(DRouteData *data);
-void spi_initialize_editabletext(DRouteData *data);
-void spi_initialize_hyperlink(DRouteData *data);
-void spi_initialize_hypertext(DRouteData *data);
-void spi_initialize_image(DRouteData *data);
-void spi_initialize_selection(DRouteData *data);
-void spi_initialize_table(DRouteData *data);
-void spi_initialize_text(DRouteData *data);
-void spi_initialize_value(DRouteData *data);
-void spi_initialize_introspectable(DRouteData *data, DRouteGetDatumFunction verify_object);
-
-/* tree.c */
-void spi_register_tree_object(DBusConnection *bus, DRouteData *data, const char *path);
-
-dbus_bool_t spi_dbus_append_tree (DBusMessage * message, AtkObject * obj, DRouteData * data);
-
-void
-atk_tree_cache_needs_update(void);
-
-#include "atk-dbus.h"
-
-G_END_DECLS
-
-#endif /* SPI_ACCESSIBLE_H_ */
similarity index 73%
rename from atk-adaptor/action.c
rename to atk-adaptor/action-adaptor.c
index 693a9a4..e9da657 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
-#include "accessible.h"
+#include <atk/atk.h>
+#include <droute/droute.h>
 
-static AtkAction *
-get_action (DBusMessage * message)
-{
-  AtkObject *obj = atk_dbus_get_object (dbus_message_get_path (message));
-  if (!obj)
-    return NULL;
-  return ATK_ACTION (obj);
-}
-
-static AtkAction *
-get_action_from_path (const char *path, void *user_data)
-{
-  AtkObject *obj = atk_dbus_get_object (path);
-  if (!obj || !ATK_IS_ACTION(obj))
-    return NULL;
-  return ATK_ACTION (obj);
-}
+#include "spi-common/spi-dbus.h"
 
 static dbus_bool_t
-impl_get_nActions (const char *path, DBusMessageIter *iter, void *user_data)
+impl_get_nActions (DBusMessageIter *iter, void *user_data)
 {
-  AtkAction *action = get_action_from_path (path, user_data);
-  if (!action)
-    return FALSE;
+  AtkAction *action = (AtkAction *) user_data;
+
+  g_return_val_if_fail (ATK_IS_ACTION (user_data), FALSE);
   return droute_return_v_int32 (iter, atk_action_get_n_actions (action));
 }
 
 static DBusMessage *
 impl_get_description (DBusConnection *bus, DBusMessage *message, void *user_data)
 {
+  AtkAction *action = (AtkAction *) user_data;
+  DBusError error;
   DBusMessage *reply;
   dbus_int32_t index;
   const char *desc;
-  AtkAction *action = get_action (message);
 
-  if (!action) return spi_dbus_general_error (message);
-  if (!dbus_message_get_args (message, NULL, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
+  dbus_error_init (&error);
+  g_return_val_if_fail (ATK_IS_ACTION (user_data),
+                        droute_not_yet_handled_error (message));
+  if (!dbus_message_get_args (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
   {
     return spi_dbus_general_error (message);
   }
@@ -78,12 +66,15 @@ static DBusMessage *
 impl_get_name (DBusConnection *bus, DBusMessage *message, void *user_data)
 {
   DBusMessage *reply;
+  DBusError error;
   dbus_int32_t index;
   const char *name;
-  AtkAction *action = get_action (message);
+  AtkAction *action = (AtkAction *) user_data;
 
-  if (!action) return spi_dbus_general_error (message);
-  if (!dbus_message_get_args (message, NULL, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
+  dbus_error_init (&error);
+  g_return_val_if_fail (ATK_IS_ACTION (user_data),
+                        droute_not_yet_handled_error (message));
+  if (!dbus_message_get_args (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
   {
     return spi_dbus_general_error (message);
   }
@@ -101,12 +92,15 @@ static DBusMessage *
 impl_get_keybinding (DBusConnection *bus, DBusMessage *message, void *user_data)
 {
   DBusMessage *reply;
+  DBusError error;
   dbus_int32_t index;
   const char *kb;
-  AtkAction *action = get_action (message);
+  AtkAction *action = (AtkAction *) user_data;
 
-  if (!action) return spi_dbus_general_error (message);
-  if (!dbus_message_get_args (message, NULL, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
+  dbus_error_init (&error);
+  g_return_val_if_fail (ATK_IS_ACTION (user_data),
+                        droute_not_yet_handled_error (message));
+  if (!dbus_message_get_args (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
   {
     return spi_dbus_general_error (message);
   }
@@ -122,14 +116,14 @@ impl_get_keybinding (DBusConnection *bus, DBusMessage *message, void *user_data)
 
 static DBusMessage *impl_getActions(DBusConnection *bus, DBusMessage *message, void *user_data)
 {
-  AtkAction *action = get_action(message);
+  AtkAction *action = (AtkAction *) user_data;
   DBusMessage *reply;
   gint count;
   gint i;
   DBusMessageIter iter, iter_array, iter_struct;
 
-  if (!action)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_ACTION (user_data),
+                        droute_not_yet_handled_error (message));
   count = atk_action_get_n_actions(action);
   reply = dbus_message_new_method_return (message);
   if (!reply) goto oom;
@@ -161,14 +155,14 @@ oom:
 
 static DBusMessage *impl_doAction(DBusConnection *bus, DBusMessage *message, void *user_data)
 {
-  AtkAction *action = get_action(message);
+  AtkAction *action = (AtkAction *) user_data;
   DBusError error;
   dbus_int32_t index;
   dbus_bool_t rv;
   DBusMessage *reply;
 
-  if (!action)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_ACTION (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
@@ -201,10 +195,10 @@ static DRouteProperty properties[] =
 };
 
 void
-spi_initialize_action (DRouteData * data)
+spi_initialize_action (DRoutePath *path)
 {
-  droute_add_interface (data, SPI_DBUS_INTERFACE_ACTION,
-                       methods, properties,
-                       (DRouteGetDatumFunction) get_action_from_path,
-                       NULL);
+  droute_path_add_interface (path,
+                             SPI_DBUS_INTERFACE_ACTION,
+                             methods,
+                             properties);
 };
diff --git a/atk-adaptor/action.h b/atk-adaptor/action.h
deleted file mode 100644 (file)
index 37daadc..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-#ifndef SPI_ACTION_H_
-#define SPI_ACTION_H_
-
-#include <libspi/base.h>
-
-G_BEGIN_DECLS
-
-#define SPI_ACTION_TYPE        (spi_action_get_type ())
-#define SPI_ACTION(obj)          (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_ACTION_TYPE, SpiAction))
-#define SPI_ACTION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), SPI_ACTION_TYPE, SpiActionClass))
-#define SPI_IS_ACTION(obj)       (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SPI_ACTION_TYPE))
-#define SPI_IS_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SPI_ACTION_TYPE))
-
-typedef struct _Action SpiAction;
-typedef struct _ActionClass SpiActionClass;
-
-struct _Action {
-  SpiBase parent;
-};
-
-struct _ActionClass {
-  SpiBaseClass parent_class;
-  POA_Accessibility_Action__epv epv;
-};
-
-GType      spi_action_get_type      (void);
-SpiAction *spi_action_interface_new (AtkObject *obj);
-
-G_END_DECLS
-
-#endif /* SPI_ACTION_H_ */
diff --git a/atk-adaptor/adaptors.h b/atk-adaptor/adaptors.h
new file mode 100644 (file)
index 0000000..d871a7b
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * 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.
+ */
+
+#ifndef ADAPTORS_H
+#define ADAPTORS_H
+
+#include <atk/atk.h>
+#include <droute/droute.h>
+
+Accessibility_Role spi_accessible_role_from_atk_role (AtkRole role);
+
+void spi_initialize_accessible      (DRoutePath *path);
+void spi_initialize_action          (DRoutePath *path);
+void spi_initialize_application     (DRoutePath *path);
+void spi_initialize_collection      (DRoutePath *path);
+void spi_initialize_component       (DRoutePath *path);
+void spi_initialize_document        (DRoutePath *path);
+void spi_initialize_editabletext    (DRoutePath *path);
+void spi_initialize_hyperlink       (DRoutePath *path);
+void spi_initialize_hypertext       (DRoutePath *path);
+void spi_initialize_image           (DRoutePath *path);
+void spi_initialize_selection       (DRoutePath *path);
+void spi_initialize_table           (DRoutePath *path);
+void spi_initialize_text            (DRoutePath *path);
+void spi_initialize_value           (DRoutePath *path);
+void spi_initialize_tree            (DRoutePath *path);
+
+#endif /* ADAPTORS_H */
similarity index 83%
rename from atk-adaptor/application.c
rename to atk-adaptor/application-adaptor.c
index ccaa6c2..cf6b689 100644 (file)
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  */
-#include "accessible.h"
 
+#include <atk/atk.h>
+#include <droute/droute.h>
+
+#include "spi-common/spi-dbus.h"
 
 static dbus_bool_t
-impl_get_toolkitName (const char *path, DBusMessageIter * iter,
+impl_get_toolkitName (DBusMessageIter * iter,
                      void *user_data)
 {
   return droute_return_v_string (iter, atk_get_toolkit_name ());
 }
 
 static dbus_bool_t
-impl_get_version (const char *path, DBusMessageIter * iter, void *user_data)
+impl_get_version (DBusMessageIter * iter, void *user_data)
 {
   return droute_return_v_string (iter, atk_get_toolkit_version ());
 }
@@ -40,13 +43,13 @@ impl_get_version (const char *path, DBusMessageIter * iter, void *user_data)
 static dbus_int32_t id;
 
 static dbus_bool_t
-impl_get_id (const char *path, DBusMessageIter * iter, void *user_data)
+impl_get_id (DBusMessageIter * iter, void *user_data)
 {
   return droute_return_v_int32 (iter, id);
 }
 
 static dbus_bool_t
-impl_set_id (const char *path, DBusMessageIter * iter, void *user_data)
+impl_set_id (DBusMessageIter * iter, void *user_data)
 {
   id = droute_get_v_int32 (iter);
   return TRUE;
@@ -100,17 +103,18 @@ static DRouteProperty properties[] = {
   {NULL, NULL, NULL}
 };
 
-static long
+/*static long
 obj_is_root (const char *path, void *user_data)
 {
   AtkObject *obj = atk_dbus_get_object (path);
   return (obj == atk_get_root ());
-}
+}*/
 
 void
-spi_initialize_application (DRouteData * data)
+spi_initialize_application (DRoutePath *path)
 {
-  droute_add_interface (data, SPI_DBUS_INTERFACE_APPLICATION,
-                       methods, properties,
-                       (DRouteGetDatumFunction) obj_is_root, NULL);
+  droute_path_add_interface (path,
+                             SPI_DBUS_INTERFACE_APPLICATION,
+                             methods,
+                             properties);
 };
diff --git a/atk-adaptor/application.h b/atk-adaptor/application.h
deleted file mode 100644 (file)
index 3903b3f..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-#ifndef SPI_APPLICATION_H_
-#define SPI_APPLICATION_H_
-
-#include <libspi/accessible.h>
-
-G_BEGIN_DECLS
-
-#define SPI_APPLICATION_TYPE        (spi_application_get_type ())
-#define SPI_APPLICATION(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_APPLICATION_TYPE, SpiApplication))
-#define SPI_APPLICATION_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), SPI_APPLICATION_TYPE, SpiApplicationClass))
-#define SPI_IS_APPLICATION(o)       (G_TYPE_CHECK__INSTANCE_TYPE ((o), SPI_APPLICATION_TYPE))
-#define SPI_IS_APPLICATION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SPI_APPLICATION_TYPE))
-
-typedef struct {
-        SpiAccessible parent;
-        long id;
-       GList *toolkit_listeners;
-} SpiApplication;
-
-typedef struct {
-        SpiAccessibleClass parent_class;
-        POA_Accessibility_Application__epv epv;
-       GHashTable *toolkit_event_names;
-       GHashTable *generic_event_names;
-} SpiApplicationClass;
-
-GType           spi_application_get_type (void);
-SpiApplication *spi_application_new      (AtkObject    *app_root);
-void            spi_emit_eventv          (GObject      *gobject,
-                                         unsigned long detail1,
-                                         unsigned long detail2,
-                                         const char   *format, ...);
-
-G_END_DECLS
-
-#endif /* SPI_APPLICATION_H_ */
diff --git a/atk-adaptor/atk-dbus.c b/atk-adaptor/atk-dbus.c
deleted file mode 100644 (file)
index f444918..0000000
+++ /dev/null
@@ -1,393 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * Copyright 2008 Novell, 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "accessible.h"
-
-/* TODO 
- * Need to add concurrency support.
- */
-
-#define ATK_BRIDGE_OBJECT_PATH_PREFIX "/org/freedesktop/atspi/accessible"
-#define ATK_BRIDGE_OBJECT_REFERENCE_TEMPLATE ATK_BRIDGE_OBJECT_PATH_PREFIX "/%d"
-#define ATK_BRIDGE_PATH_PREFIX_LENGTH 33
-
-/*
- * This module is responsible for keeping track of all the AtkObjects in
- * the application, so that they can be accessed remotely and placed in
- * a client side cache.
- *
- * To access an AtkObject remotely we need to provide a D-Bus object 
- * path for it. The D-Bus object paths used have a standard prefix
- * (ATK_BRIDGE_OBJECT_PATH_PREFIX). Appended to this prefix is a string
- * representation of an integer reference. So to access an AtkObject 
- * remotely we keep a Hashtable that maps the given reference to 
- * the AtkObject pointer. An object in this hash table is said to be 'registered'.
- *
- * The architecture of AT-SPI dbus is such that AtkObjects are not
- * remotely reference counted. This means that we need to keep track of
- * object destruction. When an object is destroyed it must be 'deregistered'
- * To do this lookup we keep a dbus-id attribute on each AtkObject.
- *
- * In addition to accessing the objects remotely we must be able to update
- * the client side cache. This is done using the 'update' signal of the 
- * org.freedesktop.atspi.Tree interface. The update signal should send out
- * all of the cacheable data for each AtkObject that has changed since the
- * last update. It should also provide a list of objects that have been
- * removed since the last update.
- * 
- * To enbale this two hash tables are kept. One keeps a list of AtkObjects
- * that have been updated. The other a list of objects that have been
- * removed since the last 'update' signal. The reason they are
- * stored as hash tables is to ensure that if an AtkObject is removed
- * and then added between update signals then the object is easy to delete
- * from the 'update' list without doing a costly lookup.
- *
- * The mappings will be called 'reference lookup tables'
- * The hashtable containing AtkObjects that need updating in the client side
- * cache will be called the 'update list'
- * The hashtable containing the AtkObjects that need removing from the client
- * side cache will be called the 'removal list'
- */
-
-GHashTable *ref2ptr = NULL; /* Used for converting a D-Bus path (Reference) to the object pointer */
-
-GHashTable *update_list = NULL; /* Stores the objects that need a client side cache update */
-GHashTable *remove_list = NULL; /* Stores the objects that need to be removed from the client side cache */
-
-static guint counter = 1;
-
-/*---------------------------------------------------------------------------*/
-
-/*
- * Each AtkObject must be asssigned a D-Bus path (Reference)
- *
- * This function provides an integer reference for a new
- * AtkObject.
- */
-static guint
-assign_reference(void)
-{
-  counter++;
-  /* Reference of 0 not allowed as used as direct key in hash table */
-  if (counter == 0)
-    counter++;
-    return counter;
-}
-
-/*---------------------------------------------------------------------------*/
-
-/*
- * Called when a registered AtkObject is deleted.
- *
- * Removes the AtkObject from the reference lookup tables.
- * Adds the reference of the object to the removal list.
- */
-static void
-deregister_accessible(gpointer data, GObject *accessible)
-{
-  guint ref;
-
-  g_assert(ATK_IS_OBJECT(accessible));
-
-
-  ref = GPOINTER_TO_INT(g_object_get_data (accessible, "dbus-id"));
-
-  /* Remove from update list */
-  g_hash_table_remove(update_list, GINT_TO_POINTER(ref));
-
-  if (ref != 0)
-    {
-      g_hash_table_remove(ref2ptr, GINT_TO_POINTER(ref));
-      /* Add to removal list */
-      /* 
-       * TODO
-       * Pyatspi client side exceptions have occured indicating
-       * that an object has been removed twice.
-       * This should not be possible and needs investigation.
-       */
-      g_hash_table_insert(remove_list, GINT_TO_POINTER(ref), NULL);
-    }
-
-  atk_tree_cache_needs_update();
-}
-
-/*---------------------------------------------------------------------------*/
-
-/*
- * Registers a new AtkObject.
- *
- * Adds the AtkObject to the reference lookup tables.
- * Adds the AtkObject to the update list.
- */
-static guint
-register_accessible (AtkObject *accessible)
-{
-  guint reference;
-
-  g_assert(ATK_IS_OBJECT(accessible));
-
-  reference = assign_reference();
-
-  g_hash_table_insert (ref2ptr, GINT_TO_POINTER(reference), accessible);
-  g_object_set_data (G_OBJECT(accessible), "dbus-id", GINT_TO_POINTER(reference));
-  g_object_weak_ref(G_OBJECT(accessible), deregister_accessible, NULL);
-
-  /* Add to update list */
-  g_hash_table_insert (update_list, GINT_TO_POINTER(reference), accessible);
-
-  atk_tree_cache_needs_update();
-
-  return reference;
-}
-
-/*---------------------------------------------------------------------------*/
-
-/* TODO Turn these into an iterator API - Think about the locking */
-
-void
-atk_dbus_foreach_registered(GHFunc func, gpointer data)
-{
-  g_hash_table_foreach(ref2ptr, func, data);
-}
-
-/*---------------------------------------------------------------------------*/
-
-void
-atk_dbus_foreach_update_list(GHFunc func, gpointer data)
-{
-  g_hash_table_foreach(update_list, func, data);
-  g_hash_table_remove_all(update_list);
-}
-
-/*---------------------------------------------------------------------------*/
-
-void
-atk_dbus_foreach_remove_list(GHFunc func, gpointer data)
-{
-  g_hash_table_foreach(remove_list, func, data);
-  g_hash_table_remove_all(remove_list);
-}
-
-/*---------------------------------------------------------------------------*/
-
-/* 
- * Called on an AtkObject when it has changed in such a way
- * that the client side cache of the object will need updating.
- */
-void 
-atk_dbus_notify_change(AtkObject *accessible)
-{
-  guint ref;
-  g_assert(ATK_IS_OBJECT(accessible));
-  
-  if (!g_object_get_data (G_OBJECT (accessible), "dbus-id"))
-    {
-      register_accessible(accessible);
-    }
-  else
-    {
-      ref = g_object_get_data (G_OBJECT (accessible), "dbus-id");
-      g_hash_table_insert (update_list, ref, accessible);
-      atk_tree_cache_needs_update();
-    }
-}
-
-/*---------------------------------------------------------------------------*/
-
-/*
- * Used to lookup an AtkObject from its D-Bus path.
- */
-AtkObject *
-atk_dbus_get_object (const char *path)
-{
-  guint index;
-  void *data;
-
-  g_assert (path);
-  if (strncmp(path, ATK_BRIDGE_OBJECT_PATH_PREFIX, ATK_BRIDGE_PATH_PREFIX_LENGTH) != 0) 
-    return NULL;
-
-  path += ATK_BRIDGE_PATH_PREFIX_LENGTH; /* Skip over the prefix */
-
-  if (path[0] == '\0')
-     return atk_get_root();
-  if (path[0] != '/')
-     return NULL;
-
-  path++;
-  index = atoi (path);
-  data = g_hash_table_lookup (ref2ptr, GINT_TO_POINTER(index));
-  if (data)
-    return ATK_OBJECT (data);
-  else
-    return NULL;
-}
-
-/*---------------------------------------------------------------------------*/
-
-gchar *
-atk_dbus_get_path_from_ref(guint ref)
-{
-  return g_strdup_printf(ATK_BRIDGE_OBJECT_REFERENCE_TEMPLATE, ref);
-}
-
-/*---------------------------------------------------------------------------*/
-
-/*
- * Used to lookup a D-Bus path from the AtkObject.
- *
- * Objects without a path are registered and provided with one.
- */
-gchar *
-atk_dbus_get_path (AtkObject *accessible)
-{
-  guint index;
-
-  g_assert (accessible);
-
-  index = GPOINTER_TO_INT(g_object_get_data (G_OBJECT (accessible), "dbus-id"));
-  if (!index)
-    index = register_accessible(G_OBJECT(accessible));
-
-  return g_strdup_printf(ATK_BRIDGE_OBJECT_REFERENCE_TEMPLATE, index);
-}
-
-/*---------------------------------------------------------------------------*/
-
-/*
- * Used to recursively register accessibles.
- *
- * When children are added to an accessible we need to 
- * iterate over the new subtree provided to register new accessibles.
- */
-guint
-atk_dbus_register_subtree(AtkObject *accessible)
-{
-  AtkObject *child;
-  guint i, n_children;
-  guint ref;
-
-  ref = GPOINTER_TO_INT(g_object_get_data (G_OBJECT (accessible), "dbus-id"));
-  if (!ref)
-     ref = register_accessible(accessible);
-
-  n_children = atk_object_get_n_accessible_children(accessible);
-  for (i=0; i < n_children; i++)
-    {
-      child = atk_object_ref_accessible_child(accessible, i);
-      atk_dbus_register_subtree(child);
-    } 
-  return ref;
-} 
-
-/*---------------------------------------------------------------------------*/
-
-/* 
- * Marshals a single object into a D-Bus message.
- *
- * Unrefs the AtkObject if unref is true.
- */
-DBusMessage *
-spi_dbus_return_object (DBusMessage *message, AtkObject *obj, gboolean unref)
-{
-  DBusMessage *reply;
-  gchar *path;
-  
-  path = atk_dbus_get_path (obj);
-
-  if (unref)
-    g_object_unref (obj);
-
-  reply = dbus_message_new_method_return (message);
-  if (reply)
-    {
-      dbus_message_append_args (reply, DBUS_TYPE_OBJECT_PATH, path,
-                               DBUS_TYPE_INVALID);
-    }
-  return reply;
-}
-
-/*---------------------------------------------------------------------------*/
-
-/*
- * Marshals a variant containing the object reference into the message iter
- * provided.
- *
- * Unrefs the object if unref is true.
- */
-dbus_bool_t
-spi_dbus_return_v_object (DBusMessageIter *iter, AtkObject *obj, int unref)
-{
-  char *path;
-  
-  path = atk_dbus_get_path (obj);
-
-  if (unref)
-    g_object_unref (obj);
-
-  return droute_return_v_object (iter, path);
-}
-
-/*---------------------------------------------------------------------------*/
-
-/*
- * Initializes required global data. The update and removal lists
- * and the reference lookup tables.
- *
- * Initializes all of the required D-Bus interfaces.
- */
-void
-atk_dbus_initialize (DRouteData * data)
-{
-  if (!ref2ptr)
-    ref2ptr = g_hash_table_new(g_direct_hash, g_direct_equal);
-  if (!update_list)
-    update_list = g_hash_table_new(g_direct_hash, g_direct_equal);
-  if (!remove_list)
-    remove_list = g_hash_table_new(g_direct_hash, g_direct_equal);
-
-  /* Get the root accessible and add */
-  atk_dbus_register_subtree(atk_get_root());
-
-  spi_initialize_accessible (data);
-  spi_initialize_action(data);
-  spi_initialize_collection (data);
-  spi_initialize_component (data);
-  spi_initialize_document (data);
-  spi_initialize_editabletext (data);
-  spi_initialize_hyperlink (data);
-  spi_initialize_hypertext (data);
-  spi_initialize_image (data);
-  spi_initialize_selection (data);
-  spi_initialize_table (data);
-  spi_initialize_text (data);
-  spi_initialize_value (data);
-  spi_initialize_introspectable(data, (DRouteGetDatumFunction) atk_dbus_get_object);
-}
-
-/*END------------------------------------------------------------------------*/
-
diff --git a/atk-adaptor/base.c b/atk-adaptor/base.c
deleted file mode 100644 (file)
index 25bd4b3..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * Copyright 2001 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.
- */
-
-/* base.c: the base object managing an AtkObject proxy */
-
-#include <config.h>
-#include <stdio.h>
-#include <libspi/libspi.h>
-
-/* Our parent Gtk object type  */
-#define PARENT_TYPE BONOBO_TYPE_OBJECT
-
-/* A pointer to our parent object class */
-static GObjectClass *spi_base_parent_class;
-
-/*
- * Implemented GObject::dispose
- */
-static void
-spi_base_object_dispose (GObject *gobject)
-{
-  SpiBase *object = SPI_BASE (gobject);
-
-  if (object->gobj)
-    {
-      g_assert (G_IS_OBJECT (object->gobj));
-      g_object_unref (object->gobj);
-      object->gobj = NULL;
-    }
-
-  spi_base_parent_class->dispose (gobject);
-}
-
-static void
-spi_base_class_init (SpiBaseClass *klass)
-{
-        GObjectClass * object_class = (GObjectClass *) klass;
-
-        spi_base_parent_class = g_type_class_peek_parent (klass);
-
-        object_class->dispose = spi_base_object_dispose;
-}
-
-static void
-spi_base_init (SpiBase *object)
-{
-       object->gobj = NULL;
-}
-
-BONOBO_TYPE_FUNC (SpiBase, PARENT_TYPE, spi_base)
-
-void
-spi_base_construct (SpiBase *object, GObject *gobject)
-{
- g_return_if_fail (G_IS_OBJECT (gobject));
- object->gobj = g_object_ref (gobject);
-}
-
-void
-spi_base_construct_default (SpiBase *object)
-{
-  object->gobj = g_object_new (G_TYPE_OBJECT, NULL);
-}
-
-GObject *
-spi_base_get_gobject (SpiBase *object)
-{
-  return object->gobj;
-}
diff --git a/atk-adaptor/base.h b/atk-adaptor/base.h
deleted file mode 100644 (file)
index bfe5860..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-#ifndef SPI_BASE_H_
-#define SPI_BASE_H_
-
-#include <glib/gmacros.h>
-#include <atk/atkobject.h>
-#include <bonobo/bonobo-object.h>
-#include <libspi/Accessibility.h>
-
-G_BEGIN_DECLS
-
-#define SPI_TYPE_BASE        (spi_base_get_type ())
-#define SPI_BASE(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_TYPE_BASE, SpiBase))
-#define SPI_BASE_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), SPI_TYPE_BASE, SpiBaseClass))
-#define SPI_IS_BASE(o)       (G_TYPE_CHECK__INSTANCE_TYPE ((o), SPI_TYPE_BASE))
-#define SPI_IS_BASE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SPI_TYPE_BASE))
-
-typedef struct {
-        BonoboObject parent;
-        GObject *gobj;
-} SpiBase;
-
-typedef struct {
-        BonoboObjectClass parent_class;
-} SpiBaseClass;
-
-GType      spi_base_get_type          (void);
-void       spi_base_construct         (SpiBase   *base,
-                                      GObject   *gobject);
-void       spi_base_construct_default (SpiBase   *base);
-GObject   *spi_base_get_gobject       (SpiBase   *base);
-
-G_END_DECLS
-
-#endif /* SPI_BASE_H_ */
index 3e5fba4..a63539e 100644 (file)
@@ -2,7 +2,7 @@
  * AT-SPI - Assistive Technology Service Provider Interface
  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
  *
- * Copyright 2008             Codethink Ltd.
+ * Copyright 2008, 2009 Codethink Ltd.
  * Copyright 2001, 2002, 2003 Sun Microsystems Inc.,
  * Copyright 2001, 2002, 2003 Ximian, Inc.
  *
 
 #include <X11/Xlib.h>
 #include <X11/Xatom.h>
-#include <string.h>
-#include <stdio.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdarg.h>
 #include <atk/atk.h>
-#include <atk/atkobject.h>
-#include <atk/atknoopobject.h>
-#include "accessible.h"
+
+#include <droute/droute.h>
+
 #include "bridge.h"
-#include "atk-dbus.h"
+#include "event.h"
+#include "accessible-register.h"
+#include "adaptors.h"
 
-void spi_atk_register_event_listeners   (void);
-void spi_atk_deregister_event_listeners (void);
-void spi_atk_tidy_windows               (void);
+#include "spi-common/spi-dbus.h"
+
+/*
+ * Provides the path for the introspection directory.
+ */
+#if !defined ATSPI_INTROSPECTION_PATH
+    #error "No introspection XML directory defined"
+#endif
 
 /*---------------------------------------------------------------------------*/
 
-SpiAppData *app_data = NULL;
+SpiAppData *atk_adaptor_app_data = NULL;
 
 static const AtkMisc *atk_misc = NULL;
 
@@ -146,11 +151,11 @@ register_application (SpiAppData *app)
                                           "registerApplication");
   dbus_message_set_no_reply (message, TRUE);
 
-  uname = dbus_bus_get_unique_name(app->droute.bus);
+  uname = dbus_bus_get_unique_name(app->bus);
 
   dbus_message_iter_init_append(message, &iter);
   dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &uname);
-  dbus_connection_send (app->droute.bus, message, NULL);
+  dbus_connection_send (app->bus, message, NULL);
   if (message) dbus_message_unref (message);
 }
 
@@ -172,11 +177,11 @@ deregister_application (SpiAppData *app)
                                           "deregisterApplication");
   dbus_message_set_no_reply (message, TRUE);
 
-  uname = dbus_bus_get_unique_name(app->droute.bus);
+  uname = dbus_bus_get_unique_name(app->bus);
 
   dbus_message_iter_init_append(message, &iter);
   dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &uname);
-  dbus_connection_send (app->droute.bus, message, NULL);
+  dbus_connection_send (app->bus, message, NULL);
   if (message) dbus_message_unref (message);
 }
 
@@ -185,17 +190,17 @@ deregister_application (SpiAppData *app)
 static void
 exit_func (void)
 {
-  if (!app_data)
+  if (!atk_adaptor_app_data)
     {
       return;
     }
 
   spi_atk_tidy_windows ();
   spi_atk_deregister_event_listeners();
-  deregister_application (app_data);
+  deregister_application (atk_adaptor_app_data);
 
-  g_free(app_data);
-  app_data = NULL;
+  g_free(atk_adaptor_app_data);
+  atk_adaptor_app_data = NULL;
 
   /* Not currently creating an XDisplay */
 #if 0
@@ -206,13 +211,6 @@ exit_func (void)
 
 /*---------------------------------------------------------------------------*/
 
-static DBusObjectPathVTable droute_vtable =
-{
-  NULL,
-  &droute_message,
-  NULL, NULL, NULL, NULL
-};
-
 static gchar *atspi_dbus_name;
 static gboolean atspi_no_register;
 
@@ -239,9 +237,10 @@ adaptor_init (gint *argc, gchar **argv[])
   GOptionContext *opt;
   GError *err = NULL;
   DBusError error;
+  DBusConnection *bus;
+  gchar *introspection_directory;
 
-  if (app_data != NULL)
-     return 0;
+  DRoutePath *treepath, *accpath;
 
   /* Parse command line options */
   opt = g_option_context_new(NULL);
@@ -251,51 +250,70 @@ adaptor_init (gint *argc, gchar **argv[])
       g_warning("AT-SPI Option parsing failed: %s\n", err->message);
 
   /* Allocate global data and do ATK initializations */
-  app_data = g_new0 (SpiAppData, 1);
+  atk_adaptor_app_data = g_new0 (SpiAppData, 1);
   atk_misc = atk_misc_get_instance ();
+  atk_adaptor_app_data->root = atk_get_root();
 
-  /* Get D-Bus connection, register D-Bus name*/
+  /* Set up D-Bus connection and register bus name */
   dbus_error_init (&error);
-  app_data->root = atk_get_root();
-  app_data->droute.bus = dbus_bus_get (DBUS_BUS_SESSION, &error);
-  if (!app_data->droute.bus)
+  atk_adaptor_app_data->bus = dbus_bus_get (DBUS_BUS_SESSION, &error);
+  if (!atk_adaptor_app_data->bus)
   {
     g_warning ("AT-SPI Couldn't connect to D-Bus: %s\n", error.message);
-    g_free(app_data);
-    app_data = NULL;
+    g_free(atk_adaptor_app_data);
+    atk_adaptor_app_data = NULL;
     return 0;
   }
   if (atspi_dbus_name != NULL &&
-      dbus_bus_request_name(app_data->droute.bus, atspi_dbus_name, 0, &error))
+      dbus_bus_request_name(atk_adaptor_app_data->bus, atspi_dbus_name, 0, &error))
   {
     g_print("AT-SPI Recieved D-Bus name - %s\n", atspi_dbus_name);
   }
 
-  /* Finish setting up D-Bus */
-  dbus_connection_setup_with_g_main(app_data->droute.bus, g_main_context_default());
+  dbus_connection_setup_with_g_main(atk_adaptor_app_data->bus, g_main_context_default());
+
+  /* Get D-Bus introspection directory */
+  introspection_directory = (char *) g_getenv("ATSPI_INTROSPECTION_PATH");
+  if (introspection_directory == NULL)
+      introspection_directory = ATSPI_INTROSPECTION_PATH;
 
   /* Register droute for routing AT-SPI messages */
-  spi_register_tree_object(app_data->droute.bus, &app_data->droute, "/org/freedesktop/atspi/tree");
+  atk_adaptor_app_data->droute = droute_new (atk_adaptor_app_data->bus, introspection_directory);
 
-  if (!dbus_connection_register_fallback (app_data->droute.bus,
-                                          "/org/freedesktop/atspi/accessible",
-                                          &droute_vtable,
-                                          &app_data->droute))
-  {
-    g_warning("AT-SPI Couldn't register droute.\n");
-    g_free(app_data);
-    app_data = NULL;
-    return 0;
-  }
+  treepath = droute_add_one (atk_adaptor_app_data->droute,
+                             "/org/freedesktop/atspi/tree",
+                             NULL);
+
+  accpath = droute_add_many (atk_adaptor_app_data->droute,
+                             "/org/freedesktop/atspi/accessible",
+                             NULL,
+                             (DRouteGetDatumFunction) atk_dbus_path_to_object);
 
   /* Register all interfaces with droute and set up application accessible db */
-  atk_dbus_initialize (&app_data->droute);
+  spi_initialize_tree (treepath);
+
+  spi_initialize_accessible (accpath);
+  spi_initialize_action(accpath);
+  spi_initialize_collection (accpath);
+  spi_initialize_component (accpath);
+  spi_initialize_document (accpath);
+  spi_initialize_editabletext (accpath);
+  spi_initialize_hyperlink (accpath);
+  spi_initialize_hypertext (accpath);
+  spi_initialize_image (accpath);
+  spi_initialize_selection (accpath);
+  spi_initialize_table (accpath);
+  spi_initialize_text (accpath);
+  spi_initialize_value (accpath);
 
   /* Register methods to send D-Bus signals on certain ATK events */
   spi_atk_register_event_listeners ();
 
+  /* Initialize the AtkObject registration */
+  atk_dbus_initialize (atk_adaptor_app_data->root);
+
   /* Register this app by sending a signal out to AT-SPI registry daemon */
-  register_application (app_data);
+  register_application (atk_adaptor_app_data);
 
   g_atexit (exit_func);
 
index b2bfc51..3e41531 100644 (file)
@@ -4,6 +4,7 @@
  *
  * Copyright 2001, 2002, 2003 Sun Microsystems Inc.,
  * Copyright 2001, 2002, 2003 Ximian, Inc.
+ * Copyright 2008, 2009 Codethink Ltd.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
  * Boston, MA 02111-1307, USA.
  */
 
+#ifndef BRIDGE_H
+#define BRIDGE_H
+
+#include <atk/atk.h>
+#include <droute/droute.h>
+
 typedef struct _SpiAppData SpiAppData;
 struct _SpiAppData
 {
-  AtkObject *root;
-  DRouteData droute;
+    AtkObject      *root;
+
+    DBusConnection *bus;
+    DRouteContext  *droute;
 };
+
+extern SpiAppData *atk_adaptor_app_data;
+
+#endif /* BRIDGE_H */
similarity index 96%
rename from atk-adaptor/collection.c
rename to atk-adaptor/collection-adaptor.c
index 317e147..749198f 100644 (file)
 
 /* collection.c: implements the Collection interface */
 
-#include "accessible.h"
-#include "spi-common/bitarray.h"
 #include <string.h>
 
-#define get_object(message) atk_dbus_get_object(dbus_message_get_path(message))
+#include <atk/atk.h>
+#include <droute/droute.h>
+
+#include "accessible-register.h"
+#include "accessible-marshaller.h"
+
+#include "spi-common/bitarray.h"
+#include "spi-common/spi-dbus.h"
 
 typedef struct _MatchRulePrivate MatchRulePrivate;
 struct _MatchRulePrivate
@@ -671,7 +676,7 @@ return_and_free_list(DBusMessage *message, GList *ls)
   if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "o", &iter_array)) goto oom;
   for (item = ls; item; item = g_list_next(item))
   {
-    char *path = spi_dbus_get_path((AtkObject *)item->data);
+      char *path = (char *) spi_dbus_object_to_path ((AtkObject *)item->data);
       dbus_message_iter_append_basic(&iter_array, DBUS_TYPE_OBJECT_PATH, &path);
       g_free(path);
   }
@@ -788,7 +793,7 @@ getMatchesInOrder (DBusMessage *message,
 
   ls = g_list_append (ls, current_object);
 
-  obj = atk_dbus_get_object (dbus_message_get_path (message));
+  obj = atk_dbus_path_to_object (dbus_message_get_path (message));
   
   kount = inorder (obj, mrp, ls, 0, count, 
                    current_object, TRUE, NULL, traverse);
@@ -820,7 +825,7 @@ getMatchesInBackOrder (DBusMessage *message,
 
   ls = g_list_append (ls, current_object);
 
-  collection = atk_dbus_get_object (dbus_message_get_path (message));
+  collection = atk_dbus_path_to_object (dbus_message_get_path (message));
 
   kount = sort_order_rev_canonical (mrp, ls, 0, count, current_object, 
                                    FALSE, collection);
@@ -856,7 +861,7 @@ getMatchesTo (DBusMessage *message,
                          obj, 0, TRUE, current_object, TRUE, traverse);
   }
   else{ 
-    obj = atk_dbus_get_object (dbus_message_get_path (message));
+    obj = atk_dbus_path_to_object (dbus_message_get_path (message));
     kount = query_exec (mrp,  sortby, ls, 0, count,
                         obj, 0, TRUE, current_object, TRUE, traverse); 
 
@@ -886,7 +891,7 @@ impl_getMatchesFrom (DBusConnection *bus, DBusMessage *message, void *user_data)
 
   dbus_message_iter_init(message, &iter);
   dbus_message_iter_get_basic (&iter, current_object_path);
-  current_object = atk_dbus_get_object (current_object_path);
+  current_object = atk_dbus_path_to_object (current_object_path);
   if (!current_object)
   {
     // TODO: object-not-found error
@@ -939,7 +944,7 @@ impl_getMatchesTo (DBusConnection *bus, DBusMessage *message, void *user_data)
 
   dbus_message_iter_init(message, &iter);
   dbus_message_iter_get_basic (&iter, current_object_path);
-  current_object = atk_dbus_get_object (current_object_path);
+  current_object = atk_dbus_path_to_object (current_object_path);
   if (!current_object)
   {
     // TODO: object-not-found error
@@ -981,7 +986,7 @@ impl_getMatchesTo (DBusConnection *bus, DBusMessage *message, void *user_data)
 static DBusMessage *
 impl_getMatches(DBusConnection *bus, DBusMessage *message, void *user_data)
 {
-  AtkObject *obj = get_object(message);
+  AtkObject *obj = path_to_object (message);
   DBusMessageIter iter;
   MatchRulePrivate rule;
   dbus_uint16_t sortby;
@@ -1014,13 +1019,15 @@ impl_getMatches(DBusConnection *bus, DBusMessage *message, void *user_data)
 static DRouteMethod methods[] = {
   { impl_getMatchesFrom, "getMatchesFrom" },
   { impl_getMatchesTo, "getMatchesTo" },
-  {impl_getMatches, "getMatches" },
+  { impl_getMatches, "getMatches" },
   {NULL, NULL}
 };
 
 void
-spi_initialize_collection (DRouteData * data)
+spi_initialize_collection (DRoutePath *path)
 {
-  droute_add_interface (data, SPI_DBUS_INTERFACE_COLLECTION,
-                       methods, NULL, NULL, NULL);
+  droute_path_add_interface (path,
+                             SPI_DBUS_INTERFACE_COLLECTION,
+                             methods,
+                             NULL);
 };
diff --git a/atk-adaptor/collection.h b/atk-adaptor/collection.h
deleted file mode 100644 (file)
index abcc350..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * Copyright 2007 IBM Corp.
- *
- * 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.
- */
-
-#ifndef SPI_COLLECTION_H_
-#define SPI_COLLECTION_H_
-
-#include <libspi/base.h>
-
-G_BEGIN_DECLS
-
-#define SPI_COLLECTION_TYPE         (spi_collection_get_type ())
-#define SPI_COLLECTION(obj)         (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_COLLECTION_TYPE, SpiCollection))
-#define SPI_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SPI_COLLECTION_TYPE, SpiCollectionClass))
-#define IS_COLLECTION(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SPI_COLLECTION_TYPE))
-#define IS_COLLECTION_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), SPI_COLLECTION_TYPE))
-
-typedef struct _MatchRulePrivate MatchRulePrivate;
-
-struct _MatchRulePrivate {
-
-     Accessibility_StateSet states; 
-     Accessibility_Collection_MatchType statematchtype;
-     Accessibility_AttributeSet  *attributes;
-     Accessibility_Collection_MatchType attributematchtype;
-     Accessibility_RoleSet *roles;
-     Accessibility_Collection_MatchType rolematchtype;
-     CORBA_char *interfaces;
-     Accessibility_Collection_MatchType interfacematchtype;
-     gboolean invert;
-
-};
-
-typedef struct _SpiCollection SpiCollection;
-typedef struct _SpiCollectionClass SpiCollectionClass;
-
-struct _SpiCollection {
-  SpiBase parent;
-  MatchRulePrivate *_mrp;
-
-};
-
-struct _SpiCollectionClass {
-  SpiBaseClass parent_class;
-  POA_Accessibility_Collection__epv epv;
-};
-
-GType        spi_collection_get_type       (void);
-
-void         spi_collection_construct      (SpiCollection *collection);
-                                           
-SpiCollection *spi_collection_interface_new  (AtkObject *obj);
-
-G_END_DECLS
-
-#endif /* SPI_COLLECTION_H_ */
-
-
similarity index 78%
rename from atk-adaptor/component.c
rename to atk-adaptor/component-adaptor.c
index fdfaaee..25e44c2 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
-#include "accessible.h"
+#include <atk/atk.h>
+#include <droute/droute.h>
 
-static AtkComponent *
-get_component (DBusMessage * message)
-{
-  AtkObject *obj = atk_dbus_get_object (dbus_message_get_path (message));
-  if (!obj)
-    return NULL;
-  return ATK_COMPONENT (obj);
-}
-
-static AtkComponent *
-get_component_from_path (const char *path, void *user_data)
-{
-  AtkObject *obj = atk_dbus_get_object (path);
-  if (!obj || !ATK_IS_COMPONENT(obj))
-    return NULL;
-  return ATK_COMPONENT (obj);
-}
+#include "accessible-marshaller.h"
+#include "spi-common/spi-dbus.h"
 
 static DBusMessage *
 impl_contains (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
-  AtkComponent *component = get_component (message);
+  AtkComponent *component = (AtkComponent *) user_data;
   dbus_int32_t x, y;
   dbus_int16_t coord_type;
   DBusError error;
   dbus_bool_t retval;
   DBusMessage *reply;
 
-  if (!component)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
+                        droute_not_yet_handled_error (message));
+
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y,
@@ -76,14 +63,15 @@ static DBusMessage *
 impl_getAccessibleAtPoint (DBusConnection * bus, DBusMessage * message,
                           void *user_data)
 {
-  AtkComponent *component = get_component (message);
+  AtkComponent *component = (AtkComponent *) user_data;
   dbus_int32_t x, y;
   dbus_int16_t coord_type;
   DBusError error;
   AtkObject *child;
 
-  if (!component)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
+                        droute_not_yet_handled_error (message));
+
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y,
@@ -100,13 +88,14 @@ impl_getAccessibleAtPoint (DBusConnection * bus, DBusMessage * message,
 static DBusMessage *
 impl_getExtents (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
-  AtkComponent *component = get_component (message);
+  AtkComponent *component = (AtkComponent *) user_data;
   DBusError error;
   dbus_int16_t coord_type;
   gint ix, iy, iwidth, iheight;
 
-  if (!component)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
+                        droute_not_yet_handled_error (message));
+
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT16, &coord_type, DBUS_TYPE_INVALID))
@@ -122,15 +111,16 @@ static DBusMessage *
 impl_getPosition (DBusConnection * bus, DBusMessage * message,
                  void *user_data)
 {
-  AtkComponent *component = get_component (message);
+  AtkComponent *component = (AtkComponent *) user_data;
   DBusError error;
   dbus_int16_t coord_type;
   gint ix = 0, iy = 0;
   dbus_int32_t x, y;
   DBusMessage *reply;
 
-  if (!component)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
+                        droute_not_yet_handled_error (message));
+
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT16, &coord_type, DBUS_TYPE_INVALID))
@@ -152,13 +142,14 @@ impl_getPosition (DBusConnection * bus, DBusMessage * message,
 static DBusMessage *
 impl_getSize (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
-  AtkComponent *component = get_component (message);
+  AtkComponent *component = (AtkComponent *) user_data;
   gint iwidth = 0, iheight = 0;
   dbus_int32_t width, height;
   DBusMessage *reply;
 
-  if (!component)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
+                        droute_not_yet_handled_error (message));
+
   atk_component_get_size (component, &iwidth, &iheight);
   width = iwidth;
   height = iheight;
@@ -174,13 +165,14 @@ impl_getSize (DBusConnection * bus, DBusMessage * message, void *user_data)
 static DBusMessage *
 impl_getLayer (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
-  AtkComponent *component = get_component (message);
+  AtkComponent *component = (AtkComponent *) user_data;
   AtkLayer atklayer;
   dbus_uint32_t rv;
   DBusMessage *reply;
 
-  if (!component)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
+                        droute_not_yet_handled_error (message));
+
   atklayer = atk_component_get_layer (component);
 
   switch (atklayer)
@@ -223,12 +215,13 @@ static DBusMessage *
 impl_getMDIZOrder (DBusConnection * bus, DBusMessage * message,
                   void *user_data)
 {
-  AtkComponent *component = get_component (message);
+  AtkComponent *component = (AtkComponent *) user_data;
   dbus_int16_t rv;
   DBusMessage *reply;
 
-  if (!component)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
+                        droute_not_yet_handled_error (message));
+
   rv = atk_component_get_mdi_zorder (component);
   reply = dbus_message_new_method_return (message);
   if (reply)
@@ -241,12 +234,13 @@ impl_getMDIZOrder (DBusConnection * bus, DBusMessage * message,
 static DBusMessage *
 impl_grabFocus (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
-  AtkComponent *component = get_component (message);
+  AtkComponent *component = (AtkComponent *) user_data;
   dbus_bool_t rv;
   DBusMessage *reply;
 
-  if (!component)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
+                        droute_not_yet_handled_error (message));
+
   rv = atk_component_grab_focus (component);
   reply = dbus_message_new_method_return (message);
   if (reply)
@@ -274,12 +268,13 @@ impl_deregisterFocusHandler (DBusConnection * bus, DBusMessage * message,
 static DBusMessage *
 impl_getAlpha (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
-  AtkComponent *component = get_component (message);
+  AtkComponent *component = (AtkComponent *) user_data;
   double rv;
   DBusMessage *reply;
 
-  if (!component)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
+                        droute_not_yet_handled_error (message));
+
   rv = atk_component_get_alpha (component);
   reply = dbus_message_new_method_return (message);
   if (reply)
@@ -306,10 +301,10 @@ static DRouteMethod methods[] = {
 };
 
 void
-spi_initialize_component (DRouteData * data)
+spi_initialize_component (DRoutePath *path)
 {
-  droute_add_interface (data, SPI_DBUS_INTERFACE_COMPONENT,
-                       methods, NULL,
-                       (DRouteGetDatumFunction) get_component_from_path,
-                       NULL);
+  droute_path_add_interface (path,
+                             SPI_DBUS_INTERFACE_COMPONENT,
+                             methods,
+                             NULL);
 };
diff --git a/atk-adaptor/component.h b/atk-adaptor/component.h
deleted file mode 100644 (file)
index e86b8fb..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-#ifndef SPI_COMPONENT_H_
-#define SPI_COMPONENT_H_
-
-#include <libspi/base.h>
-#include <atk/atkcomponent.h>
-
-G_BEGIN_DECLS
-
-#define SPI_COMPONENT_TYPE        (spi_component_get_type ())
-#define SPI_COMPONENT(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_COMPONENT_TYPE, SpiComponent))
-#define SPI_COMPONENT_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), SPI_COMPONENT_TYPE, SpiComponentClass))
-#define SPI_IS_COMPONENT(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), SPI_COMPONENT_TYPE))
-#define SPI_IS_COMPONENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SPI_COMPONENT_TYPE))
-
-typedef struct {
-        SpiBase parent;
-} SpiComponent;
-
-typedef struct {
-        SpiBaseClass parent_class;
-        POA_Accessibility_Component__epv epv;
-} SpiComponentClass;
-
-GType         spi_component_get_type      (void);
-SpiComponent *spi_component_interface_new (AtkObject *o);
-
-G_END_DECLS
-
-#endif /* SPI_COMPONENT_H_ */
diff --git a/atk-adaptor/devicelistener.c b/atk-adaptor/devicelistener.c
deleted file mode 100644 (file)
index 526cb4d..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-/* devicelistener.c: implement the DeviceListener interface */
-
-#include <config.h>
-#ifdef SPI_DEBUG
-#  include <stdio.h>
-#endif
-#include <libspi/listener.h>
-#include <libspi/devicelistener.h>
-
-/* Our parent Gtk object type  */
-#define PARENT_TYPE BONOBO_TYPE_OBJECT
-
-enum {
-       DEVICE_EVENT,
-       LAST_SIGNAL
-};
-static guint signals [LAST_SIGNAL];
-
-/*
- * CORBA Accessibility::DeviceListener::keyEvent method implementation
- */
-static CORBA_boolean
-impl_device_event (PortableServer_Servant           servant,
-                  const Accessibility_DeviceEvent *key,
-                  CORBA_Environment               *ev)
-{
-  gboolean was_consumed = FALSE;
-  SpiDeviceListener *listener = SPI_DEVICE_LISTENER (
-         bonobo_object_from_servant (servant));
-
-  g_signal_emit (G_OBJECT (listener), signals [DEVICE_EVENT], 0, key, &was_consumed);
-
-  return was_consumed;
-}
-
-static gboolean
-boolean_handled_accumulator (GSignalInvocationHint *ihint,
-                            GValue                *return_accu,
-                            const GValue          *handler_return,
-                            gpointer               dummy)
-{
-  gboolean continue_emission;
-  gboolean signal_handled;
-  
-  signal_handled = g_value_get_boolean (handler_return);
-  g_value_set_boolean (return_accu, signal_handled);
-  continue_emission = !signal_handled;
-  
-  return continue_emission;
-}
-
-void
-marshal_BOOLEAN__POINTER (GClosure     *closure,
-                         GValue       *return_value,
-                         guint         n_param_values,
-                         const GValue *param_values,
-                         gpointer      invocation_hint,
-                         gpointer      marshal_data)
-{
-  typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer     data1,
-                                                     gpointer     arg_1,
-                                                     gpointer     data2);
-  register GMarshalFunc_BOOLEAN__POINTER callback;
-  register GCClosure *cc = (GCClosure*) closure;
-  register gpointer data1, data2;
-  gboolean v_return;
-
-  g_return_if_fail (return_value != NULL);
-  g_return_if_fail (n_param_values == 2);
-
-  if (G_CCLOSURE_SWAP_DATA (closure))
-    {
-      data1 = closure->data;
-      data2 = g_value_peek_pointer (param_values + 0);
-    }
-  else
-    {
-      data1 = g_value_peek_pointer (param_values + 0);
-      data2 = closure->data;
-    }
-  callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback);
-
-  v_return = callback (data1,
-                       g_value_get_pointer (param_values + 1),
-                       data2);
-
-  g_value_set_boolean (return_value, v_return);
-}
-
-static void
-spi_device_listener_class_init (SpiDeviceListenerClass *klass)
-{
-  POA_Accessibility_DeviceEventListener__epv *epv = &klass->epv;
-  
-  signals [DEVICE_EVENT] = g_signal_new (
-    "device_event",
-    G_TYPE_FROM_CLASS (klass),
-    G_SIGNAL_RUN_LAST,
-    G_STRUCT_OFFSET (SpiDeviceListenerClass, device_event),
-    boolean_handled_accumulator, NULL,
-    marshal_BOOLEAN__POINTER,
-    G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
-  
-  epv->notifyEvent = impl_device_event;
-}
-
-static void
-spi_device_listener_init (SpiDeviceListener *device_listener)
-{
-}
-
-BONOBO_TYPE_FUNC_FULL (SpiDeviceListener,
-                      Accessibility_DeviceEventListener,
-                      BONOBO_TYPE_OBJECT,
-                      spi_device_listener)
-
-SpiDeviceListener *
-spi_device_listener_new (void)
-{
-    SpiDeviceListener *retval = g_object_new (
-           SPI_DEVICE_LISTENER_TYPE, NULL);
-    return retval;
-}
diff --git a/atk-adaptor/devicelistener.h b/atk-adaptor/devicelistener.h
deleted file mode 100644 (file)
index 8446d22..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-#ifndef SPI_DEVICE_LISTENER_H_
-#define SPI_DEVICE_LISTENER_H_
-
-#include <bonobo/bonobo-object.h>
-#include <atk/atkobject.h>
-#include <libspi/Accessibility.h>
-#include <spi-common/keymasks.h>
-
-G_BEGIN_DECLS
-
-#define SPI_DEVICE_LISTENER_TYPE        (spi_device_listener_get_type ())
-#define SPI_DEVICE_LISTENER(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_DEVICE_LISTENER_TYPE, SpiDeviceListener))
-#define SPI_DEVICE_LISTENER_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), SPI_DEVICE_LISTENER_TYPE, SpiDeviceListenerClass))
-#define SPI_IS_DEVICE_LISTENER(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), SPI_DEVICE_LISTENER_TYPE))
-#define SPI_IS_DEVICE_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SPI_DEVICE_LISTENER_TYPE))
-
-typedef struct _SpiDeviceListener SpiDeviceListener;
-
-struct _SpiDeviceListener {
-        BonoboObject parent;
-};
-
-typedef struct {
-        BonoboObjectClass parent_class;
-        POA_Accessibility_DeviceEventListener__epv epv;
-
-       gboolean (*device_event) (SpiDeviceListener *listener,
-                                 const Accessibility_DeviceEvent *key);
-} SpiDeviceListenerClass;
-
-GType                  spi_device_listener_get_type        (void);
-SpiDeviceListener     *spi_device_listener_new             (void);
-
-G_END_DECLS
-
-#endif /* DEVICE_SPI_LISTENER_H_ */
similarity index 75%
rename from atk-adaptor/document.c
rename to atk-adaptor/document-adaptor.c
index 302f4ab..91f6313 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
-#include "accessible.h"
+#include <atk/atk.h>
+#include <droute/droute.h>
 
-static AtkDocument *
-get_document (DBusMessage * message)
-{
-  AtkObject *obj = atk_dbus_get_object (dbus_message_get_path (message));
-  if (!obj)
-    return NULL;
-  return ATK_DOCUMENT (obj);
-}
-
-static AtkDocument *
-get_document_from_path (const char *path, void *user_data)
-{
-  AtkObject *obj = atk_dbus_get_object (path);
-  if (!obj || !ATK_IS_DOCUMENT(obj))
-    return NULL;
-  return ATK_DOCUMENT (obj);
-}
+#include "spi-common/spi-dbus.h"
 
 static DBusMessage *
-impl_getLocale (DBusConnection * bus, DBusMessage * message, void *user_data)
+impl_getLocale (DBusConnection *bus,
+                DBusMessage *message,
+                void *user_data)
 {
-  AtkDocument *document = get_document (message);
+  AtkDocument *document = (AtkDocument *) user_data;
   const gchar *lc;
   DBusMessage *reply;
 
-  if (!document)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_DOCUMENT (user_data),
+                        droute_not_yet_handled_error (message));
   lc = atk_document_get_locale (document);
   if (!lc)
     lc = "";
@@ -67,14 +54,14 @@ static DBusMessage *
 impl_getAttributeValue (DBusConnection * bus, DBusMessage * message,
                        void *user_data)
 {
-  AtkDocument *document = get_document (message);
+  AtkDocument *document = (AtkDocument *) user_data;
   DBusError error;
   gchar *attributename;
   const gchar *atr;
   DBusMessage *reply;
 
-  if (!document)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_DOCUMENT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_STRING, &attributename, DBUS_TYPE_INVALID))
@@ -97,7 +84,7 @@ static DBusMessage *
 impl_getAttributes (DBusConnection * bus, DBusMessage * message,
                    void *user_data)
 {
-  AtkDocument *document = get_document (message);
+  AtkDocument *document = (AtkDocument *) user_data;
   DBusMessage *reply;
   AtkAttributeSet *attributes;
   AtkAttribute *attr = NULL;
@@ -105,8 +92,8 @@ impl_getAttributes (DBusConnection * bus, DBusMessage * message,
   gint n_attributes = 0;
   gint i;
 
-  if (!document)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_DOCUMENT (user_data),
+                        droute_not_yet_handled_error (message));
 
   attributes = atk_document_get_attributes (document);
   if (attributes)
@@ -141,10 +128,10 @@ static DRouteMethod methods[] = {
 };
 
 void
-spi_initialize_document (DRouteData * data)
+spi_initialize_document (DRoutePath *path)
 {
-  droute_add_interface (data, SPI_DBUS_INTERFACE_DOCUMENT,
-                       methods, NULL,
-                       (DRouteGetDatumFunction) get_document_from_path,
-                       NULL);
+  droute_path_add_interface (path,
+                             SPI_DBUS_INTERFACE_DOCUMENT,
+                             methods,
+                             NULL);
 };
diff --git a/atk-adaptor/document.h b/atk-adaptor/document.h
deleted file mode 100644 (file)
index 8ed63ec..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-#ifndef SPI_DOCUMENT_H_
-#define SPI_DOCUMENT_H_
-
-#include <libspi/base.h>
-#include <atk/atkdocument.h>
-
-G_BEGIN_DECLS
-
-#define SPI_DOCUMENT_TYPE         (spi_document_get_type ())
-#define SPI_DOCUMENT(obj)         (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_DOCUMENT_TYPE, SpiDocument))
-#define SPI_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SPI_DOCUMENT_TYPE, SpiDocumentClass))
-#define IS_DOCUMENT(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj, SPI_DOCUMENT_TYPE))
-#define IS_DOCUMENT_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), SPI_DOCUMENT_TYPE))
-
-typedef struct _SpiDocument SpiDocument;
-typedef struct _SpiDocumentClass SpiDocumentClass;
-
-struct _SpiDocument {
-  SpiBase parent;
-};
-
-struct _SpiDocumentClass {
-  SpiBaseClass parent_class;
-  POA_Accessibility_Document__epv epv;
-};
-
-GType        spi_document_get_type       (void);
-void         spi_document_construct      (SpiDocument *document,
-                                         AtkObject *obj);
-SpiDocument *spi_document_interface_new  (AtkObject *obj);
-
-G_END_DECLS
-
-#endif /* SPI_DOCUMENT_H_ */
similarity index 79%
rename from atk-adaptor/editabletext.c
rename to atk-adaptor/editabletext-adaptor.c
index 8e16060..76a8866 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
-#include "accessible.h"
+#include <atk/atk.h>
+#include <droute/droute.h>
 
-static AtkEditableText *
-get_editable (DBusMessage * message)
-{
-  AtkObject *obj = atk_dbus_get_object (dbus_message_get_path (message));
-  if (!obj)
-    return NULL;
-  return ATK_EDITABLE_TEXT (obj);
-}
-
-static AtkEditableText *
-get_editable_from_path (const char *path, void *user_data)
-{
-  AtkObject *obj = atk_dbus_get_object (path);
-  if (!obj || !ATK_IS_EDITABLE_TEXT(obj))
-    return NULL;
-  return ATK_EDITABLE_TEXT (obj);
-}
+#include "spi-common/spi-dbus.h"
 
 static DBusMessage *
 impl_setTextContents (DBusConnection * bus, DBusMessage * message,
                      void *user_data)
 {
-  AtkEditableText *editable = get_editable (message);
+  AtkEditableText *editable = (AtkEditableText *) user_data;
   const char *newContents;
   dbus_bool_t rv;
   DBusError error;
   DBusMessage *reply;
 
-  if (!editable)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_STRING, &newContents, DBUS_TYPE_INVALID))
@@ -75,7 +60,7 @@ impl_setTextContents (DBusConnection * bus, DBusMessage * message,
 static DBusMessage *
 impl_insertText (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
-  AtkEditableText *editable = get_editable (message);
+  AtkEditableText *editable = (AtkEditableText *) user_data;
   dbus_int32_t position, length;
   char *text;
   dbus_bool_t rv;
@@ -83,8 +68,8 @@ impl_insertText (DBusConnection * bus, DBusMessage * message, void *user_data)
   DBusMessage *reply;
   gint ip;
 
-  if (!editable)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &position, DBUS_TYPE_STRING, &text,
@@ -109,15 +94,15 @@ static DBusMessage *
 impl_setAttributes (DBusConnection * bus, DBusMessage * message,
                    void *user_data)
 {
-  AtkEditableText *editable = get_editable (message);
+  AtkEditableText *editable = (AtkEditableText *) user_data;
   const char *attributes;
   dbus_int32_t startPos, endPos;
   dbus_bool_t rv;
   DBusError error;
   DBusMessage *reply;
 
-  if (!editable)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_STRING, &attributes, DBUS_TYPE_INT32,
@@ -139,12 +124,12 @@ impl_setAttributes (DBusConnection * bus, DBusMessage * message,
 static DBusMessage *
 impl_copyText (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
-  AtkEditableText *editable = get_editable (message);
+  AtkEditableText *editable = (AtkEditableText *) user_data;
   dbus_int32_t startPos, endPos;
   DBusError error;
 
-  if (!editable)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &startPos, DBUS_TYPE_INT32, &endPos,
@@ -159,14 +144,14 @@ impl_copyText (DBusConnection * bus, DBusMessage * message, void *user_data)
 static DBusMessage *
 impl_cutText (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
-  AtkEditableText *editable = get_editable (message);
+  AtkEditableText *editable = (AtkEditableText *) user_data;
   dbus_int32_t startPos, endPos;
   DBusError error;
   dbus_bool_t rv;
   DBusMessage *reply;
 
-  if (!editable)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &startPos, DBUS_TYPE_INT32, &endPos,
@@ -189,14 +174,14 @@ impl_cutText (DBusConnection * bus, DBusMessage * message, void *user_data)
 static DBusMessage *
 impl_deleteText (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
-  AtkEditableText *editable = get_editable (message);
+  AtkEditableText *editable = (AtkEditableText *) user_data;
   dbus_int32_t startPos, endPos;
   DBusError error;
   dbus_bool_t rv;
   DBusMessage *reply;
 
-  if (!editable)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &startPos, DBUS_TYPE_INT32, &endPos,
@@ -219,14 +204,14 @@ impl_deleteText (DBusConnection * bus, DBusMessage * message, void *user_data)
 static DBusMessage *
 impl_pasteText (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
-  AtkEditableText *editable = get_editable (message);
+  AtkEditableText *editable = (AtkEditableText *) user_data;
   dbus_int32_t position;
   DBusError error;
   dbus_bool_t rv;
   DBusMessage *reply;
 
-  if (!editable)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &position, DBUS_TYPE_INVALID))
@@ -257,10 +242,10 @@ static DRouteMethod methods[] = {
 };
 
 void
-spi_initialize_editabletext (DRouteData * data)
+spi_initialize_editabletext (DRoutePath *path)
 {
-  droute_add_interface (data, SPI_DBUS_INTERFACE_EDITABLE_TEXT,
-                       methods, NULL,
-                       (DRouteGetDatumFunction) get_editable_from_path,
-                       NULL);
+  droute_path_add_interface (path,
+                             SPI_DBUS_INTERFACE_EDITABLE_TEXT,
+                             methods,
+                             NULL);
 };
diff --git a/atk-adaptor/editabletext.h b/atk-adaptor/editabletext.h
deleted file mode 100644 (file)
index 2fc0b1d..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-#ifndef SPI_EDITABLE_TEXT_H_
-#define SPI_EDITABLE_TEXT_H_
-
-#include <libspi/text.h>
-
-G_BEGIN_DECLS
-
-#define SPI_EDITABLE_TEXT_TYPE            (spi_editable_text_get_type ())
-#define SPI_EDITABLE_TEXT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_EDITABLE_TEXT_TYPE, SpiEditableText))
-#define SPI_EDITABLE_TEXT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), SPI_EDITABLE_TEXT_TYPE, SpiEditableText))
-#define SPI_IS_EDITABLE_TEXT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SPI_EDITABLE_TEXT_TYPE))
-#define SPI_IS_EDITABLE_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SPI_EDITABLE_TEXT_TYPE))
-
-typedef struct _SpiEditableText      SpiEditableText;
-typedef struct _SpiEditableTextClass SpiEditableTextClass;
-
-struct _SpiEditableText {
-  SpiText parent;
-};
-
-struct _SpiEditableTextClass {
-  SpiTextClass parent_class;
-  POA_Accessibility_EditableText__epv epv;
-};
-
-GType            spi_editable_text_get_type      (void);
-SpiEditableText *spi_editable_text_interface_new (AtkObject *obj);
-
-G_END_DECLS
-
-#endif /* SPI_EDITABLE_TEXT_H_ */
index 73e13a0..80fb7b8 100644 (file)
@@ -2,7 +2,7 @@
  * AT-SPI - Assistive Technology Service Provider Interface
  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
  *
- * Copyright 2008, Codethink Ltd.
+ * Copyright 2008, 2009, Codethink Ltd.
  * Copyright 2001, 2002, 2003 Sun Microsystems Inc.,
  * Copyright 2001, 2002, 2003 Ximian, Inc.
  *
  * Boston, MA 02111-1307, USA.
  */
 
-#include <atk/atk.h>
 #include <string.h>
-#include "accessible.h"
+
+#include <atk/atk.h>
+#include <droute/droute.h>
+
 #include "bridge.h"
-#include "atk-dbus.h"
+#include "accessible-register.h"
 
-extern SpiAppData *app_data;
+#include "spi-common/spi-dbus.h"
 
 static GArray *listener_ids = NULL;
 
 static gint atk_bridge_key_event_listener_id;
 static gint atk_bridge_focus_tracker_id;
 
-
 /*---------------------------------------------------------------------------*/
 
 #define ITF_EVENT_OBJECT   "org.freedesktop.atspi.Event.Object"
@@ -61,7 +62,7 @@ Accessibility_DeviceEventController_notifyListenersSync(const Accessibility_Devi
   dbus_error_init(&error);
   if (spi_dbus_marshal_deviceEvent(message, key_event))
   {
-    DBusMessage *reply = dbus_connection_send_with_reply_and_block(app_data->droute.bus, message, 1000, &error);
+    DBusMessage *reply = dbus_connection_send_with_reply_and_block(atk_adaptor_app_data->bus, message, 1000, &error);
     if (reply)
     {
       DBusError error;
@@ -170,14 +171,6 @@ provide_defaults(const gint type,
     }
 }
 
-
-/* TODO Should we bother emiting events for objects that have not yet
- * been added to the tree?
- * 
- * This gets difficult. Its entirely possible that an Accessible would have been
- * added to the tree, but not yet reached the clients.
- * In this case we would be wrongly surpressing an event.
- */
 static void 
 emit(AtkObject  *accessible,
      const char *klass,
@@ -192,6 +185,15 @@ emit(AtkObject  *accessible,
   DBusMessageIter iter, sub;
   gchar *path, *cname, *t;
 
+  path = atk_dbus_object_to_path (accessible);
+
+  /* Tough decision here
+   * We won't send events from accessible
+   * objects that have not yet been added to the accessible tree.
+   */
+  if (path == NULL)
+      return;
+
   if (!klass) klass = "";
   if (!major) major = "";
   if (!minor) minor = "";
@@ -204,7 +206,6 @@ emit(AtkObject  *accessible,
   cname = g_strdup(major);
   while ((t = strchr(cname, '-')) != NULL) *t = '_';
 
-  path = atk_dbus_get_path(accessible);
   sig = dbus_message_new_signal(path, klass, cname);
   g_free(cname);
   g_free(path);
@@ -226,7 +227,7 @@ emit(AtkObject  *accessible,
   dbus_message_iter_append_basic(&sub, (int) *type, &val);
   dbus_message_iter_close_container(&iter, &sub);
 
-  dbus_connection_send(app_data->droute.bus, sig, NULL);
+  dbus_connection_send(atk_adaptor_app_data->bus, sig, NULL);
   dbus_message_unref(sig);
 }
 
@@ -248,6 +249,15 @@ emit_rect(AtkObject  *accessible,
   gchar *path, *cname, *t;
   dbus_int32_t dummy = 0;
 
+  path = atk_dbus_object_to_path (accessible);
+
+  /* Tough decision here
+   * We won't send events from accessible
+   * objects that have not yet been added to the accessible tree.
+   */
+  if (path == NULL)
+      return;
+
   if (!klass) klass = "";
   if (!major) major = "";
   if (!minor) minor = "";
@@ -260,7 +270,6 @@ emit_rect(AtkObject  *accessible,
   cname = g_strdup(major);
   while ((t = strchr(cname, '-')) != NULL) *t = '_';
 
-  path = atk_dbus_get_path(accessible);
   sig = dbus_message_new_signal(path, klass, cname);
   g_free(path);
   g_free(cname);
@@ -279,96 +288,7 @@ emit_rect(AtkObject  *accessible,
     dbus_message_iter_close_container (&variant, &sub);
   dbus_message_iter_close_container (&iter, &variant);
 
-  dbus_connection_send(app_data->droute.bus, sig, NULL);
-}
-
-/*---------------------------------------------------------------------------*/
-
-/*
- * The tree update listener handles the following Atk signals:
- *
- * Gtk:AtkObject:property-change
- * 
- * With the folowing property names:
- *
- * accessible-name
- * accessible-description
- * accessible-parent
- *
- * It updates the server side accessible-object database, which
- * will then syncronize with the client-side accessible cache.
- * 
- */
-static gboolean
-tree_update_listener (GSignalInvocationHint *signal_hint,
-                     guint                  n_param_values,
-                     const GValue          *param_values,
-                     gpointer               data)
-{
-  AtkObject *accessible;
-  AtkPropertyValues *values;
-  const gchar *pname = NULL;
-
-  accessible = g_value_get_object (&param_values[0]);
-  values = (AtkPropertyValues*) g_value_get_pointer (&param_values[1]);
-
-  pname = values[0].property_name;
-
-  if (strcmp (pname, "accessible-name") == 0)
-    {
-      atk_dbus_notify_change(accessible);
-    }
-  else if (strcmp (pname, "accessible-description") == 0)
-    {
-      atk_dbus_notify_change(accessible);
-    }
-  else if (strcmp (pname, "accessible-parent") == 0)
-    {
-      atk_dbus_notify_change(accessible);
-    }
-  return TRUE;
-}
-
-/* 
- * Handles the ATK signal 'Gtk:AtkObject:children-changed'.
- *
- * It updates the server side accessible-object database, which
- * will then syncronize with the client-side accessible cache.
- *
- */
-static gboolean
-tree_update_children_listener (GSignalInvocationHint *signal_hint,
-                              guint                  n_param_values,
-                              const GValue          *param_values,
-                              gpointer               data)
-{
-  AtkObject *accessible;
-  const gchar *detail = NULL;
-  AtkObject *child;
-  gboolean child_needs_unref = FALSE;
-
-  if (signal_hint->detail)
-    detail = g_quark_to_string (signal_hint->detail);
-
-  accessible = g_value_get_object (&param_values[0]);
-  if (!strcmp (detail, "add"))
-    {
-      gpointer child;
-      int index = g_value_get_uint (param_values + 1);
-      child = g_value_get_pointer (param_values + 2);
-      if (ATK_IS_OBJECT (child))
-       g_object_ref (child);
-      else
-       child = atk_object_ref_accessible_child (accessible, index);
-      if (ATK_IS_OBJECT (child))
-       {
-         atk_dbus_register_subtree (child);
-         g_object_unref (child);
-       }
-      else
-       atk_dbus_register_subtree(accessible);
-    }
-  return TRUE;
+  dbus_connection_send(atk_adaptor_app_data->bus, sig, NULL);
 }
 
 /*---------------------------------------------------------------------------*/
@@ -421,22 +341,25 @@ property_event_listener (GSignalInvocationHint *signal_hint,
   if (strcmp (pname, "accessible-table-summary") == 0)
     {
       otemp = atk_table_get_summary(ATK_TABLE (accessible));
-      stemp = atk_dbus_get_path(otemp);
-      emit(accessible, ITF_EVENT_OBJECT, PCHANGE, pname, 0, 0, DBUS_TYPE_OBJECT_PATH_AS_STRING, stemp);
+      stemp = atk_dbus_object_to_path (otemp);
+      if (stemp != NULL)
+          emit(accessible, ITF_EVENT_OBJECT, PCHANGE, pname, 0, 0, DBUS_TYPE_OBJECT_PATH_AS_STRING, stemp);
     }
   else if (strcmp (pname, "accessible-table-column-header") == 0)
     {
       i = g_value_get_int (&(values->new_value));
       otemp = atk_table_get_column_header(ATK_TABLE (accessible), i);
-      stemp = atk_dbus_get_path(otemp);
-      emit(accessible, ITF_EVENT_OBJECT, PCHANGE, pname, 0, 0, DBUS_TYPE_OBJECT_PATH_AS_STRING, stemp);
+      stemp = atk_dbus_object_to_path (otemp);
+      if (stemp != NULL)
+          emit(accessible, ITF_EVENT_OBJECT, PCHANGE, pname, 0, 0, DBUS_TYPE_OBJECT_PATH_AS_STRING, stemp);
     }
   else if (strcmp (pname, "accessible-table-row-header") == 0)
     {
       i = g_value_get_int (&(values->new_value));
       otemp = atk_table_get_row_header(ATK_TABLE (accessible), i);
-      stemp = atk_dbus_get_path(otemp);
-      emit(accessible, ITF_EVENT_OBJECT, PCHANGE, pname, 0, 0, DBUS_TYPE_OBJECT_PATH_AS_STRING, stemp);
+      stemp = atk_dbus_object_to_path (otemp);
+      if (stemp != NULL)
+          emit(accessible, ITF_EVENT_OBJECT, PCHANGE, pname, 0, 0, DBUS_TYPE_OBJECT_PATH_AS_STRING, stemp);
     }
   else if (strcmp (pname, "accessible-table-row-description") == 0)
     {
@@ -615,7 +538,12 @@ active_descendant_event_listener (GSignalInvocationHint *signal_hint,
   minor = g_quark_to_string (signal_hint->detail);
 
   detail1 = atk_object_get_index_in_parent (child);
-  s = atk_dbus_get_path(child);
+  s = atk_dbus_object_to_path (child);
+  if (s == NULL)
+    {
+      g_free (s);
+      return TRUE;
+    }
 
   emit(accessible, ITF_EVENT_OBJECT, name, "", detail1, 0, DBUS_TYPE_OBJECT_PATH_AS_STRING, s);
   g_free(s);
@@ -793,9 +721,6 @@ spi_atk_register_event_listeners (void)
 
   atk_bridge_focus_tracker_id = atk_add_focus_tracker (focus_tracker);
 
-  add_signal_listener (tree_update_listener,          "Gtk:AtkObject:property-change");
-  add_signal_listener (tree_update_children_listener, "Gtk:AtkObject:children-changed");
-
   add_signal_listener (property_event_listener,               "Gtk:AtkObject:property-change");
   add_signal_listener (window_event_listener,                 "window:create");
   add_signal_listener (window_event_listener,                 "window:destroy");
similarity index 81%
rename from atk-adaptor/spi-private.h
rename to atk-adaptor/event.h
index aff2ecb..d62f9ce 100644 (file)
@@ -4,6 +4,7 @@
  *
  * Copyright 2001, 2002 Sun Microsystems Inc.,
  * Copyright 2001, 2002 Ximian, Inc.
+ * Copyright 2008, 2009 Codethink Ltd.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
  * Boston, MA 02111-1307, USA.
  */
 
-#ifndef SPI_PRIVATE_H_
-#define SPI_PRIVATE_H_
-
-#include <glib/glist.h>
-#include <atk/atk.h>
+#ifndef EVENT_H
+#define EVENT_H
 
 #include <spi-common/spi-types.h>
 
-G_BEGIN_DECLS
-
-Accessibility_Role spi_role_from_atk_role (AtkRole role);
-G_END_DECLS
+void spi_atk_register_event_listeners   (void);
+void spi_atk_deregister_event_listeners (void);
+void spi_atk_tidy_windows               (void);
 
-#endif /* SPI_PRIVATE_H_ */
+#endif /* EVENT_H */
diff --git a/atk-adaptor/eventlistener.c b/atk-adaptor/eventlistener.c
deleted file mode 100644 (file)
index 6374813..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-/* accessibleeventlistener.c: implementation of SpiListener.idl */
-
-#include <config.h>
-#ifdef SPI_DEBUG
-#include <stdio.h>
-#endif
-#include <libspi/eventlistener.h>
-
-/* Our parent Gtk object type */
-#define PARENT_TYPE SPI_LISTENER_TYPE
-
-enum {
-       EVENT,
-       LAST_SIGNAL
-};
-static guint signals [LAST_SIGNAL];
-
-/*
- * CORBA Accessibility::Listener::notifyEvent method implementation
- */
-static void
-impl_accessible_event_notify_event (PortableServer_Servant     servant,
-                                    const Accessibility_Event *e,
-                                    CORBA_Environment         *ev)
-{
-  SpiEventListener *listener = SPI_EVENT_LISTENER (
-         bonobo_object_from_servant (servant));
-
-  g_signal_emit (G_OBJECT (listener), signals [EVENT], 0, e);
-
-}
-
-static void
-spi_event_listener_class_init (SpiEventListenerClass *klass)
-{
-        SpiListenerClass *spi_listener_class = (SpiListenerClass *) klass;
-        POA_Accessibility_EventListener__epv *epv = &spi_listener_class->epv;
-
-       signals [EVENT] = g_signal_new (
-               "event",
-               G_TYPE_FROM_CLASS (klass),
-               G_SIGNAL_RUN_LAST,
-               G_STRUCT_OFFSET (SpiEventListenerClass, event),
-               NULL, NULL,
-               g_cclosure_marshal_VOID__POINTER,
-               G_TYPE_NONE, 1, G_TYPE_POINTER);
-
-        epv->notifyEvent = impl_accessible_event_notify_event;
-}
-
-static void
-spi_event_listener_init (SpiEventListener *listener)
-{
-}
-
-BONOBO_TYPE_FUNC (SpiEventListener,
-                 PARENT_TYPE,
-                 spi_event_listener)
-
-SpiEventListener *
-spi_event_listener_new (void)
-{
-    SpiEventListener *retval = g_object_new (
-           SPI_EVENT_LISTENER_TYPE, NULL);
-    return retval;
-}
diff --git a/atk-adaptor/eventlistener.h b/atk-adaptor/eventlistener.h
deleted file mode 100644 (file)
index cb1adfe..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-#ifndef SPI_ACCESSIBLE_EVENT_LISTENER_H_
-#define SPI_ACCESSIBLE_EVENT_LISTENER_H_
-
-#include <libspi/listener.h>
-
-G_BEGIN_DECLS
-
-#define SPI_EVENT_LISTENER_TYPE        (spi_event_listener_get_type ())
-#define SPI_EVENT_LISTENER(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_EVENT_LISTENER_TYPE, SpiEventListener))
-#define SPI_EVENT_LISTENER_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), SPI_EVENT_LISTENER_TYPE, SpiEventListenerClass))
-#define SPI_IS_EVENT_LISTENER(o)       (G_TYPE_CHECK__INSTANCE_TYPE ((o), SPI_EVENT_LISTENER_TYPE))
-#define SPI_IS_EVENT_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SPI_EVENT_LISTENER_TYPE))
-
-typedef struct _SpiEventListener SpiEventListener;
-
-struct _SpiEventListener {
-  SpiListener parent;
-};
-
-typedef struct {
-  SpiListenerClass parent_class;
-
-  /* signals */
-  void (*event) (SpiEventListener    *listener,
-                Accessibility_Event *e);
-  
-} SpiEventListenerClass;
-
-GType              spi_event_listener_get_type        (void);
-SpiEventListener  *spi_event_listener_new             (void);
-
-G_END_DECLS
-
-#endif /* SPI_ACCESSIBLE_EVENT_SPI_LISTENER_H_ */
similarity index 68%
rename from atk-adaptor/hyperlink.c
rename to atk-adaptor/hyperlink-adaptor.c
index 42b2096..9634512 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
-#include "accessible.h"
+#include <atk/atk.h>
+#include <droute/droute.h>
 
-static AtkHyperlink *
-get_hyperlink (DBusMessage * message)
-{
-  AtkObject *obj = atk_dbus_get_object (dbus_message_get_path (message));
-  if (!obj)
-    return NULL;
-  return ATK_HYPERLINK (obj);
-}
-
-static AtkHyperlink *
-get_hyperlink_from_path (const char *path, void *user_data)
-{
-  AtkObject *obj = atk_dbus_get_object (path);
-  if (!obj || !ATK_IS_HYPERLINK(obj))
-    return NULL;
-  return ATK_HYPERLINK (obj);
-}
+#include "accessible-marshaller.h"
+#include "spi-common/spi-dbus.h"
 
 static dbus_bool_t
-impl_get_nAnchors (const char *path, DBusMessageIter * iter, void *user_data)
+impl_get_nAnchors (DBusMessageIter * iter, void *user_data)
 {
-  AtkHyperlink *link = get_hyperlink_from_path (path, user_data);
-  if (!link)
-    return FALSE;
+  AtkHyperlink *link = (AtkHyperlink *) user_data;
+  g_return_val_if_fail (ATK_IS_HYPERLINK (user_data), FALSE);
   return droute_return_v_int32 (iter, atk_hyperlink_get_n_anchors (link));
 }
 
 
 static dbus_bool_t
-impl_get_startIndex (const char *path, DBusMessageIter * iter,
+impl_get_startIndex (DBusMessageIter * iter,
                     void *user_data)
 {
-  AtkHyperlink *link = get_hyperlink_from_path (path, user_data);
-  if (!link)
-    return FALSE;
+  AtkHyperlink *link = (AtkHyperlink *) user_data;
+  g_return_val_if_fail (ATK_IS_HYPERLINK (user_data), FALSE);
   return droute_return_v_int32 (iter, atk_hyperlink_get_start_index (link));
 }
 
 static dbus_bool_t
-impl_get_endIndex (const char *path, DBusMessageIter * iter, void *user_data)
+impl_get_endIndex (DBusMessageIter * iter, void *user_data)
 {
-  AtkHyperlink *link = get_hyperlink_from_path (path, user_data);
-  if (!link)
-    return FALSE;
+  AtkHyperlink *link = (AtkHyperlink *) user_data;
+  g_return_val_if_fail (ATK_IS_HYPERLINK (user_data), FALSE);
   return droute_return_v_int32 (iter, atk_hyperlink_get_end_index (link));
 }
 
 static DBusMessage *
 impl_getObject (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
-  AtkHyperlink *link = get_hyperlink (message);
+  AtkHyperlink *link = (AtkHyperlink *) user_data;
   DBusError error;
   dbus_int32_t i;
   AtkObject *atk_object;
 
-  if (!link)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_HYPERLINK (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &i, DBUS_TYPE_INVALID))
@@ -94,14 +77,14 @@ impl_getObject (DBusConnection * bus, DBusMessage * message, void *user_data)
 static DBusMessage *
 impl_getURI (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
-  AtkHyperlink *link = get_hyperlink (message);
+  AtkHyperlink *link = (AtkHyperlink *) user_data;
   dbus_int32_t i;
   DBusError error;
   gchar *rv;
   DBusMessage *reply;
 
-  if (!link)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_HYPERLINK (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &i, DBUS_TYPE_INT32, &i,
@@ -126,12 +109,12 @@ impl_getURI (DBusConnection * bus, DBusMessage * message, void *user_data)
 static DBusMessage *
 impl_isValid (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
-  AtkHyperlink *link = get_hyperlink (message);
+  AtkHyperlink *link = (AtkHyperlink *) user_data;
   dbus_bool_t rv;
   DBusMessage *reply;
 
-  if (!link)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_HYPERLINK (user_data),
+                        droute_not_yet_handled_error (message));
 
   rv = atk_hyperlink_is_valid (link);
   reply = dbus_message_new_method_return (message);
@@ -158,10 +141,10 @@ static DRouteProperty properties[] = {
 };
 
 void
-spi_initialize_hyperlink (DRouteData * data)
+spi_initialize_hyperlink (DRoutePath *path)
 {
-  droute_add_interface (data, SPI_DBUS_INTERFACE_HYPERLINK,
-                       methods, properties,
-                       (DRouteGetDatumFunction) get_hyperlink_from_path,
-                       NULL);
+  droute_path_add_interface (path,
+                             SPI_DBUS_INTERFACE_HYPERLINK,
+                             methods,
+                             properties);
 };
diff --git a/atk-adaptor/hyperlink.h b/atk-adaptor/hyperlink.h
deleted file mode 100644 (file)
index 73bd659..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-#ifndef SPI_HYPERLINK_H_
-#define SPI_HYPERLINK_H_
-
-#include <libspi/base.h>
-#include <atk/atkhyperlink.h>
-#include <atk/atkhyperlinkimpl.h>
-
-G_BEGIN_DECLS
-
-#define SPI_HYPERLINK_TYPE        (spi_hyperlink_get_type ())
-#define SPI_HYPERLINK(obj)          (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_HYPERLINK_TYPE, SpiHyperlink))
-#define SPI_HYPERLINK_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), SPI_HYPERLINK_TYPE, SpiHyperlinkClass))
-#define SPI_IS_HYPERLINK(obj)       (G_TYPE_CHECK__INSTANCE_TYPE ((obj), SPI_HYPERLINK_TYPE))
-#define SPI_IS_HYPERLINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SPI_HYPERLINK_TYPE))
-
-typedef struct _Hyperlink      SpiHyperlink;
-typedef struct _HyperlinkClass SpiHyperlinkClass;
-
-struct _Hyperlink {
-  SpiBase parent;
-};
-
-struct _HyperlinkClass {
-  SpiBaseClass parent_class;
-  POA_Accessibility_Hyperlink__epv epv;
-};
-
-GType         spi_hyperlink_get_type (void);
-SpiHyperlink *spi_hyperlink_new      (AtkHyperlink *object);
-
-G_END_DECLS
-
-#endif /* SPI_HYPERLINK_H_ */
similarity index 73%
rename from atk-adaptor/hypertext.c
rename to atk-adaptor/hypertext-adaptor.c
index 8b5d4d6..a1c2298 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
-#include "accessible.h"
+#include <atk/atk.h>
+#include <droute/droute.h>
 
-static AtkHypertext *
-get_hypertext (DBusMessage * message)
-{
-  AtkObject *obj = atk_dbus_get_object (dbus_message_get_path (message));
-  if (!obj)
-    return NULL;
-  return ATK_HYPERTEXT (obj);
-}
-
-static AtkHypertext *
-get_hypertext_from_path (const char *path, void *user_data)
-{
-  AtkObject *obj = atk_dbus_get_object (path);
-  if (!obj || !ATK_IS_HYPERTEXT(obj))
-    return NULL;
-  return ATK_HYPERTEXT (obj);
-}
+#include "spi-common/spi-dbus.h"
 
 static DBusMessage *
 impl_getNLinks (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
-  AtkHypertext *hypertext = get_hypertext (message);
+  AtkHypertext *hypertext = (AtkHypertext *) user_data;
   gint rv;
   DBusMessage *reply;
 
-  if (!hypertext)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_HYPERTEXT (user_data),
+                        droute_not_yet_handled_error (message));
   rv = atk_hypertext_get_n_links (hypertext);
   reply = dbus_message_new_method_return (message);
   if (reply)
@@ -64,13 +49,13 @@ impl_getNLinks (DBusConnection * bus, DBusMessage * message, void *user_data)
 static DBusMessage *
 impl_getLink (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
-  AtkHypertext *hypertext = get_hypertext (message);
+  AtkHypertext *hypertext = (AtkHypertext *) user_data;
   DBusError error;
   dbus_int32_t linkIndex;
   AtkHyperlink *link;
 
-  if (!hypertext)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_HYPERTEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &linkIndex, DBUS_TYPE_INVALID))
@@ -85,14 +70,14 @@ static DBusMessage *
 impl_getLinkIndex (DBusConnection * bus, DBusMessage * message,
                   void *user_data)
 {
-  AtkHypertext *hypertext = get_hypertext (message);
+  AtkHypertext *hypertext = (AtkHypertext *) user_data;
   DBusError error;
   dbus_int32_t characterIndex;
   dbus_int32_t rv;
   DBusMessage *reply;
 
-  if (!hypertext)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_HYPERTEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &characterIndex, DBUS_TYPE_INVALID))
@@ -117,10 +102,10 @@ static DRouteMethod methods[] = {
 };
 
 void
-spi_initialize_hypertext (DRouteData * data)
+spi_initialize_hypertext (DRoutePath *path)
 {
-  droute_add_interface (data, SPI_DBUS_INTERFACE_HYPERTEXT,
-                       methods, NULL,
-                       (DRouteGetDatumFunction) get_hypertext_from_path,
-                       NULL);
+  droute_path_add_interface (path,
+                             SPI_DBUS_INTERFACE_HYPERTEXT,
+                             methods,
+                             NULL);
 };
diff --git a/atk-adaptor/hypertext.h b/atk-adaptor/hypertext.h
deleted file mode 100644 (file)
index 3113149..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-#ifndef SPI_HYPERTEXT_H_
-#define SPI_HYPERTEXT_H_
-
-#include <libspi/text.h>
-
-G_BEGIN_DECLS
-
-#define SPI_HYPERTEXT_TYPE            (spi_hypertext_get_type ())
-#define SPI_HYPERTEXT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_HYPERTEXT_TYPE, SpiHypertext))
-#define SPI_HYPERTEXT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), SPI_HYPERTEXT_TYPE, SpiHypertextClass))
-#define SPI_IS_HYPERTEXT(obj)         (G_TYPE_CHECK__INSTANCE_TYPE ((obj), SPI_HYPERTEXT_TYPE))
-#define SPI_IS_HYPERTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SPI_HYPERTEXT_TYPE))
-
-typedef struct _SpiHypertext      SpiHypertext;
-typedef struct _SpiHypertextClass SpiHypertextClass;
-
-struct _SpiHypertext {
-  SpiBase parent;
-};
-
-struct _SpiHypertextClass {
-  SpiBaseClass parent_class;
-  POA_Accessibility_Hypertext__epv epv;
-};
-
-GType         spi_hypertext_get_type      (void);
-SpiHypertext *spi_hypertext_interface_new (AtkObject *obj);
-
-G_END_DECLS
-
-#endif /* SPI_HYPERTEXT_H_ */
similarity index 74%
rename from atk-adaptor/image.c
rename to atk-adaptor/image-adaptor.c
index f754749..23bf365 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
-#include "accessible.h"
+#include <atk/atk.h>
+#include <droute/droute.h>
 
-static AtkImage *
-get_image (DBusMessage * message)
-{
-  AtkObject *obj = atk_dbus_get_object (dbus_message_get_path (message));
-  if (!obj)
-    return NULL;
-  return ATK_IMAGE (obj);
-}
-
-static AtkImage *
-get_image_from_path (const char *path, void *user_data)
-{
-  AtkObject *obj = atk_dbus_get_object (path);
-  if (!obj || !ATK_IS_IMAGE(obj))
-    return NULL;
-  return ATK_IMAGE (obj);
-}
+#include "spi-common/spi-dbus.h"
 
 static dbus_bool_t
-impl_get_imageDescription (const char *path, DBusMessageIter * iter,
+impl_get_imageDescription (DBusMessageIter * iter,
                           void *user_data)
 {
-  AtkImage *image = get_image_from_path (path, user_data);
-  if (!image)
-    return FALSE;
+  AtkImage *image = (AtkImage *) user_data;
+  g_return_val_if_fail (ATK_IS_IMAGE (user_data), FALSE);
   return droute_return_v_string (iter,
                                 atk_image_get_image_description (image));
 }
 
 static dbus_bool_t
-impl_get_imageLocale (const char *path, DBusMessageIter * iter,
+impl_get_imageLocale (DBusMessageIter * iter,
                      void *user_data)
 {
-  AtkImage *image = get_image_from_path (path, user_data);
-  if (!image)
-    return FALSE;
+  AtkImage *image = (AtkImage *) user_data;
+  g_return_val_if_fail (ATK_IS_IMAGE (user_data), FALSE);
   return droute_return_v_string (iter, atk_image_get_image_locale (image));
 }
 
@@ -67,13 +50,13 @@ static DBusMessage *
 impl_getImageExtents (DBusConnection * bus, DBusMessage * message,
                      void *user_data)
 {
-  AtkImage *image = get_image (message);
+  AtkImage *image = (AtkImage *) user_data;
   DBusError error;
   dbus_int16_t coordType;
   gint ix, iy, iwidth, iheight;
 
-  if (!image)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_IMAGE (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT16, &coordType, DBUS_TYPE_INVALID))
@@ -89,15 +72,15 @@ static DBusMessage *
 impl_getImagePosition (DBusConnection * bus, DBusMessage * message,
                       void *user_data)
 {
-  AtkImage *image = get_image (message);
+  AtkImage *image = (AtkImage *) user_data;
   DBusError error;
   dbus_int16_t coord_type;
   gint ix = 0, iy = 0;
   dbus_int32_t x, y;
   DBusMessage *reply;
 
-  if (!image)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_IMAGE (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT16, &coord_type, DBUS_TYPE_INVALID))
@@ -120,13 +103,13 @@ static DBusMessage *
 impl_getImageSize (DBusConnection * bus, DBusMessage * message,
                   void *user_data)
 {
-  AtkImage *image = get_image (message);
+  AtkImage *image = (AtkImage *) user_data;
   gint iwidth = 0, iheight = 0;
   dbus_int32_t width, height;
   DBusMessage *reply;
 
-  if (!image)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_IMAGE (user_data),
+                        droute_not_yet_handled_error (message));
   atk_image_get_image_size (image, &iwidth, &iheight);
   width = iwidth;
   height = iheight;
@@ -153,9 +136,10 @@ static DRouteProperty properties[] = {
 };
 
 void
-spi_initialize_image (DRouteData * data)
+spi_initialize_image (DRoutePath *path)
 {
-  droute_add_interface (data, SPI_DBUS_INTERFACE_IMAGE, methods,
-                       properties,
-                       (DRouteGetDatumFunction) get_image_from_path, NULL);
+  droute_path_add_interface (path,
+                             SPI_DBUS_INTERFACE_IMAGE,
+                             methods,
+                             properties);
 };
diff --git a/atk-adaptor/image.h b/atk-adaptor/image.h
deleted file mode 100644 (file)
index 8ffb855..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-#ifndef SPI_IMAGE_H_
-#define SPI_IMAGE_H_
-
-#include <libspi/base.h>
-#include <atk/atkimage.h>
-
-G_BEGIN_DECLS
-
-#define SPI_IMAGE_TYPE            (spi_image_get_type ())
-#define SPI_IMAGE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_IMAGE_TYPE, SpiImage))
-#define SPI_IMAGE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), SPI_IMAGE_TYPE, SpiImageClass))
-#define SPI_IS_IMAGE(obj)         (G_TYPE_CHECK__INSTANCE_TYPE ((obj), SPI_IMAGE_TYPE))
-#define SPI_IS_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SPI_IMAGE_TYPE))
-
-typedef struct _Image SpiImage;
-typedef struct _ImageClass SpiImageClass;
-
-struct _Image {
-  SpiBase parent;
-};
-
-struct _ImageClass {
-  SpiBaseClass parent;
-  POA_Accessibility_Image__epv epv;
-};
-
-GType     spi_image_get_type      (void);
-SpiImage *spi_image_interface_new (AtkObject *obj);
-
-G_END_DECLS
-
-#endif /* SPI_IMAGE_H_ */
diff --git a/atk-adaptor/introspectable.c b/atk-adaptor/introspectable.c
deleted file mode 100644 (file)
index 4781979..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * Copyright 2008 Codethink Ltd.
- *
- * 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 <glib.h>
-#include <accessible.h>
-
-#include <droute/droute.h>
-#include <droute/introspect-loader.h>
-
-/*
- * This file contains an implementation of the D-Bus introspectable interface.
- * For ATK objects.
- */
-
-/*
- * This function finds the names of each interface that the ATK object supports
- * and appends the introspection XML for each interface.
- */
-static DBusMessage *
-impl_introspect (DBusConnection *bus, DBusMessage *message,
-                void *user_data)
-{
-  AtkObject *object;
-  const char *path;
-  GString *output;
-  char *final;
-
-  DBusMessage *reply;
-
-  path = dbus_message_get_path(message);
-  object = spi_dbus_get_object(path);
-
-  output = g_string_new(spi_introspection_header);
-  
-  g_string_append_printf(output, spi_introspection_node_element, path);
-
-  spi_append_interface(output, SPI_DBUS_INTERFACE_ACCESSIBLE);
-
-  if (ATK_IS_ACTION (object))
-      spi_append_interface(output, SPI_DBUS_INTERFACE_ACTION);
-
-  if (ATK_IS_COMPONENT (object))
-      spi_append_interface(output, SPI_DBUS_INTERFACE_COMPONENT);
-
-  if (ATK_IS_EDITABLE_TEXT (object))
-      spi_append_interface(output, SPI_DBUS_INTERFACE_EDITABLE_TEXT);
-
-  if (ATK_IS_TEXT (object))
-      spi_append_interface(output, SPI_DBUS_INTERFACE_TEXT);
-
-  if (ATK_IS_HYPERTEXT (object))
-      spi_append_interface(output, SPI_DBUS_INTERFACE_HYPERTEXT);
-
-  if (ATK_IS_IMAGE (object))
-      spi_append_interface(output, SPI_DBUS_INTERFACE_IMAGE);
-
-  if (ATK_IS_SELECTION (object))
-      spi_append_interface(output, SPI_DBUS_INTERFACE_SELECTION);
-
-  if (ATK_IS_TABLE (object))
-      spi_append_interface(output, SPI_DBUS_INTERFACE_TABLE);
-
-  if (ATK_IS_VALUE (object))
-      spi_append_interface(output, SPI_DBUS_INTERFACE_VALUE);
-
-  if (ATK_IS_STREAMABLE_CONTENT (object))
-      spi_append_interface(output, "org.freedesktop.atspi.StreamableContent");
-
-  if (ATK_IS_DOCUMENT (object))
-    {
-      spi_append_interface(output, "org.freedesktop.atspi.Collection");
-      spi_append_interface(output, SPI_DBUS_INTERFACE_DOCUMENT);
-    }
-
-  if (ATK_IS_HYPERLINK_IMPL (object))
-      spi_append_interface(output, SPI_DBUS_INTERFACE_HYPERLINK);
-
-  g_string_append(output, spi_introspection_footer);
-  final = g_string_free(output, FALSE);
-
-  reply = dbus_message_new_method_return (message);
-  g_assert(reply != NULL);
-  dbus_message_append_args(reply, DBUS_TYPE_STRING, &final,
-                          DBUS_TYPE_INVALID);
-
-  g_free(final);
-  return reply;
-}
-
-static DRouteMethod methods[] = {
-  {impl_introspect, "Introspect"},
-  {NULL, NULL}
-};
-
-/*
- * Adds the introspectable interface to the DRoute object provided
- */
-void
-spi_initialize_introspectable (DRouteData *data, DRouteGetDatumFunction verify_object)
-{
-  droute_add_interface (data, "org.freedesktop.DBus.Introspectable",
-                       methods, NULL,
-                       verify_object, NULL);
-};
diff --git a/atk-adaptor/keystrokelistener.h b/atk-adaptor/keystrokelistener.h
deleted file mode 100644 (file)
index ed2ba45..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-#ifndef SPI_KEYSTROKE_LISTENER_H_
-#define SPI_KEYSTROKE_LISTENER_H_
-
-G_BEGIN_DECLS
-
-#include <libspi/devicelistener.h>
-
-#define SPI_KEYSTROKE_LISTENER_TYPE        SPI_DEVICE_LISTENER_TYPE
-#define SPI_KEYSTROKE_LISTENER(o)          SPI_DEVICE_LISTENER(o)
-#define SPI_KEYSTROKE_LISTENER_CLASS(k)    SPI_DEVICE_LISTENER_CLASS(k)
-#define SPI_IS_KEYSTROKE_LISTENER(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), SPI_KEYSTROKE_LISTENER_TYPE))
-#define SPI_IS_KEYSTROKE_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SPI_KEYSTROKE_LISTENER_TYPE))
-
-typedef struct _SpiDeviceListener SpiKeystrokeListener;
-
-typedef SpiDeviceListenerClass SpiKeystrokeListenerClass;
-
-#define spi_keystroke_listener_get_type spi_device_listener_get_type
-#define spi_keystroke_listener_new      spi_device_listener_new
-
-G_END_DECLS
-
-#endif /* KEYSTROKE_SPI_LISTENER_H_ */
diff --git a/atk-adaptor/libspi.h b/atk-adaptor/libspi.h
deleted file mode 100644 (file)
index ea0fd42..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * Copyright 2001 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.
- *
- * libspi.h: the main include header for libspi.
- */
-#ifndef LIBSPI_H_
-#define LIBSPI_H_
-
-#include <libspi/Accessibility.h>
-#include <libspi/accessible.h>
-#include <libspi/action.h>
-#include <libspi/application.h>
-#include <libspi/collection.h>
-#include <libspi/component.h>
-#include <libspi/document.h>
-#include <libspi/editabletext.h>
-#include <libspi/hyperlink.h>
-#include <libspi/hypertext.h>
-#include <libspi/image.h>
-#include <libspi/relation.h>
-#include <libspi/selection.h>
-#include <libspi/stateset.h>
-#include <libspi/table.h>
-#include <libspi/text.h>
-#include <libspi/value.h>
-#include <libspi/listener.h>
-#include <libspi/eventlistener.h>
-#include <libspi/devicelistener.h>
-#include <spi-common/keymasks.h>
-#include <libspi/remoteobject.h>
-#include <libspi/streamablecontent.h>
-
-#endif /* LIBSPI_H_ */
diff --git a/atk-adaptor/listener.c b/atk-adaptor/listener.c
deleted file mode 100644 (file)
index c969483..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-/* listener.c: implements the Listener interface */
-
-#ifdef SPI_DEBUG
-#include <stdio.h>
-#endif
-
-#include <config.h>
-#include <libspi/listener.h>
-
-/* Our parent Gtk object type */
-#define PARENT_TYPE BONOBO_TYPE_OBJECT
-
-/* A pointer to our parent object class */
-static GObjectClass *spi_listener_parent_class;
-
-/*
- * Implemented GObject::finalize
- */
-static void
-spi_listener_object_finalize (GObject *object)
-{
-/*        SpiListener *listener = SPI_LISTENER (object); */
-
-#ifdef SPI_DEBUG
-        fprintf(stderr, "spi_listener_object_finalize called\n");
-#endif
-        spi_listener_parent_class->finalize (object);
-}
-
-/*
- * CORBA Accessibility::Listener::notifyEvent method implementation
- */
-
-static void
-impl_notify_event (PortableServer_Servant     servant,
-                   const Accessibility_Event *e,
-                   CORBA_Environment         *ev)
-{
-#ifdef SPI_DEBUG
-  fprintf (stderr, "notify %s...\n", e->type);
-  fprintf (stderr, "source name: '%s'\n",
-           Accessibility_Accessible__get_name(e->source, ev));
-  if (ev->_major != CORBA_NO_EXCEPTION) {
-           DBG (2, g_warning ("Accessibility app error: exception during event notification: %s\n"),
-               CORBA_exception_id(ev)));
-  }
-  /*
-  fprintf (stderr, "source is component ? : %s\n",
-           Accessibility_Accessible_queryInterface (e->source,
-                                                    "IDL:Accessibility/Component:1.0",
-                                                    ev)
-           ? "yes" : "no");
-  */
-#endif
-  if (e->source != CORBA_OBJECT_NIL)
-    {
-      Accessibility_Accessible_unref (e->source, ev);
-    }
-}
-
-static void
-spi_listener_class_init (SpiListenerClass *klass)
-{
-        GObjectClass * object_class = (GObjectClass *) klass;
-        POA_Accessibility_EventListener__epv *epv = &klass->epv;
-        spi_listener_parent_class = g_type_class_peek_parent (klass);
-
-        object_class->finalize = spi_listener_object_finalize;
-
-        epv->notifyEvent = impl_notify_event;
-}
-
-static void
-spi_listener_init (SpiListener *listener)
-{
-}
-
-BONOBO_TYPE_FUNC_FULL (SpiListener,
-                      Accessibility_EventListener,
-                      PARENT_TYPE,
-                      spi_listener)
-
-SpiListener *
-spi_listener_new (void)
-{
-    SpiListener *retval = g_object_new (SPI_LISTENER_TYPE, NULL);
-    return retval;
-}
diff --git a/atk-adaptor/listener.h b/atk-adaptor/listener.h
deleted file mode 100644 (file)
index 3ed3dcf..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-#ifndef SPI_LISTENER_H_
-#define SPI_LISTENER_H_
-
-#include <bonobo/bonobo-object.h>
-#include <atk/atkobject.h>
-#include <libspi/Accessibility.h>
-
-G_BEGIN_DECLS
-
-#define SPI_LISTENER_TYPE        (spi_listener_get_type ())
-#define SPI_LISTENER(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_LISTENER_TYPE, SpiListener))
-#define SPI_LISTENER_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), SPI_LISTENER_TYPE, SpiListenerClass))
-#define SPI_IS_LISTENER(o)       (G_TYPE_CHECK__INSTANCE_TYPE ((o), SPI_LISTENER_TYPE))
-#define SPI_IS_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SPI_LISTENER_TYPE))
-
-typedef struct {
-        BonoboObject parent;
-} SpiListener;
-
-typedef struct {
-        BonoboObjectClass parent_class;
-        POA_Accessibility_EventListener__epv epv;
-} SpiListenerClass;
-
-GType        spi_listener_get_type (void);
-SpiListener *spi_listener_new      (void);
-
-G_END_DECLS
-
-#endif /* SPI_LISTENER_H_ */
diff --git a/atk-adaptor/matchrule.h b/atk-adaptor/matchrule.h
deleted file mode 100644 (file)
index 26125fa..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * Copyright 2007 IBM Corp.
- *
- * 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.
- */
-
-#ifndef SPI_MATCHRULE_H_
-#define SPI_MATCHRULE_H_
-
-#include <libspi/base.h>
-
-G_BEGIN_DECLS
-
-#define SPI_MATCHRULE_TYPE         (spi_matchrule_get_type ())
-#define SPI_MATCHRULE(obj)         (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_MATCHRULE_TYPE, SpiMatchrule))
-#define SPI_MATCHRULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SPI_MATCHRULE_TYPE, SpiMatchruleClass))
-#define IS_MATCHRULE(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj, SPI_MATCHRULE_TYPE))
-#define IS_MATCHRULE_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), SPI_MATCHRULE_TYPE))
-
-typedef struct _SpiMatchrule SpiMatchrule;
-typedef struct _SpiMatchruleClass SpiMatchruleClass;
-
-struct _SpiMatchrule {
-     SpiBase parent;
-
-};
-
-struct _SpiMatchruleClass {
-  SpiBaseClass parent_class;
-  POA_Accessibility_MatchRule__epv epv;
-};
-
-GType        spi_matchrule_get_type       (void);
-void         spi_matchrule_construct      (SpiMatchrule *matchrule);
-                                           
-SpiMatchrule *spi_matchrule_interface_new  (void);
-
-G_END_DECLS
-
-#endif /* SPI_MATCHRULE_H_ */
similarity index 97%
rename from atk-adaptor/relation.c
rename to atk-adaptor/relation-adaptor.c
index 6d487d4..12edc7a 100644 (file)
 
 #include <config.h>
 #include <stdio.h>
-#include <libspi/accessible.h>
-#include <libspi/relation.h>
 
+#include <atk/atk.h>
+#include <droute/droute.h>
+
+#include "spi-common/spi-types.h"
+#include "spi-common/spi-dbus.h"
 
 static gboolean
 spi_init_relation_type_table (Accessibility_RelationType *types)
diff --git a/atk-adaptor/relation.h b/atk-adaptor/relation.h
deleted file mode 100644 (file)
index 36feb25..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-#ifndef SPI_RELATION_H_
-#define SPI_RELATION_H_
-
-#include <libspi/base.h>
-#include <atk/atkrelation.h>
-
-G_BEGIN_DECLS
-
-#define SPI_RELATION_TYPE            (spi_relation_get_type ())
-#define SPI_RELATION(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_RELATION_TYPE, SpiRelation))
-#define SPI_RELATION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), SPI_RELATION_TYPE, SpiRelationClass))
-#define SPI_IS_RELATION(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SPI_RELATION_TYPE))
-#define SPI_IS_RELATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SPI_RELATION_TYPE))
-
-typedef struct _SpiRelation SpiRelation;
-typedef struct _SpiRelationClass SpiRelationClass;
-
-struct _SpiRelation {
-  SpiBase parent;
-};
-
-struct _SpiRelationClass {
-  SpiBaseClass parent_class;
-  POA_Accessibility_Relation__epv epv;
-};
-
-GType        spi_relation_get_type (void);
-SpiRelation *spi_relation_new      (AtkRelation *relation);
-
-G_END_DECLS
-
-#endif /* SPI_RELATION_H_ */
diff --git a/atk-adaptor/remoteobject.c b/atk-adaptor/remoteobject.c
deleted file mode 100644 (file)
index b38ff19..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/* AT-SPI : Assistive Technology Service Provider Interface
- * 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 <config.h>
-#include "remoteobject.h"
-
-Accessibility_Accessible
-spi_remote_object_get_accessible (SpiRemoteObject *remote)
-{
-  SpiRemoteObjectIface *iface; 
-
-  g_return_val_if_fail (SPI_IS_REMOTE_OBJECT (remote), CORBA_OBJECT_NIL);
-  
-  iface = SPI_REMOTE_OBJECT_GET_IFACE (remote);
-
-  if (!iface->get_accessible)
-    return CORBA_OBJECT_NIL;
-
-  return iface->get_accessible (remote);
-}
-
-GType
-spi_remote_object_get_type (void)
-{
-  static GType type = 0;
-
-  if (!type)
-    {
-      static const GTypeInfo typeInfo =
-      {
-        sizeof (SpiRemoteObjectIface),
-        (GBaseInitFunc) NULL,
-        (GBaseFinalizeFunc) NULL,
-        (GClassInitFunc) NULL,
-        (GClassFinalizeFunc) NULL,
-        NULL, 0, 0,
-        (GInstanceInitFunc) NULL,
-      };
-
-      type = g_type_register_static (G_TYPE_INTERFACE, "SpiRemoteObject", &typeInfo, 0) ;
-    }
-
-  return type;
-}
diff --git a/atk-adaptor/remoteobject.h b/atk-adaptor/remoteobject.h
deleted file mode 100644 (file)
index 915478c..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-#ifndef SPI_REMOTE_OBJECT_H_
-#define SPI_REMOTE_OBJECT_H_
-
-#include <glib-object.h>
-#include <libspi/Accessibility.h>
-
-G_BEGIN_DECLS
-
-#define SPI_TYPE_REMOTE_OBJECT         (spi_remote_object_get_type ())
-#define SPI_IS_REMOTE_OBJECT(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), SPI_TYPE_REMOTE_OBJECT))
-#define SPI_REMOTE_OBJECT(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_TYPE_REMOTE_OBJECT, SpiRemoteObject))
-#define SPI_REMOTE_OBJECT_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), SPI_TYPE_REMOTE_OBJECT, SpiRemoteObjectIface))
-
-typedef struct _SpiRemoteObject      SpiRemoteObject;
-typedef struct _SpiRemoteObjectIface SpiRemoteObjectIface;
-
-struct _SpiRemoteObjectIface {
-        GTypeInterface           base_iface;
-
-       Accessibility_Accessible (*get_accessible) (SpiRemoteObject *o);
-};
-
-GType                    spi_remote_object_get_type       (void);
-Accessibility_Accessible spi_remote_object_get_accessible (SpiRemoteObject   *o);
-
-G_END_DECLS
-
-#endif /* SPI_REMOTE_OBJECT_H_ */
-
similarity index 78%
rename from atk-adaptor/selection.c
rename to atk-adaptor/selection-adaptor.c
index d7c9b2f..3cae386 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
-#include "accessible.h"
+#include <atk/atk.h>
+#include <droute/droute.h>
 
-static AtkSelection *
-get_selection (DBusMessage * message)
-{
-  AtkObject *obj = atk_dbus_get_object (dbus_message_get_path (message));
-  if (!obj)
-    return NULL;
-  return ATK_SELECTION (obj);
-}
-
-static AtkSelection *
-get_selection_from_path (const char *path, void *user_data)
-{
-  AtkObject *obj = atk_dbus_get_object (path);
-  if (!obj || ~ATK_IS_SELECTION(obj))
-    return NULL;
-  return ATK_SELECTION (obj);
-}
+#include "spi-common/spi-dbus.h"
 
 static dbus_bool_t
-impl_get_nSelectedChildren (const char *path, DBusMessageIter * iter,
+impl_get_nSelectedChildren (DBusMessageIter * iter,
                            void *user_data)
 {
-  AtkSelection *selection = get_selection_from_path (path, user_data);
-  if (!selection)
-    return FALSE;
+  AtkSelection *selection = (AtkSelection *) user_data;
+  g_return_val_if_fail (ATK_IS_SELECTION (user_data), FALSE);
   return droute_return_v_int32 (iter,
                                atk_selection_get_selection_count
                                (selection));
 }
 
-static char *
+/*static char *
 impl_get_nSelectedChildren_str (void *datum)
 {
   g_assert (ATK_IS_HYPERLINK (datum));
   return g_strdup_printf ("%d",
                          atk_selection_get_selection_count ((AtkSelection *)
                                                             datum));
-}
+}*/
 
 static DBusMessage *
 impl_getSelectedChild (DBusConnection * bus, DBusMessage * message,
                       void *user_data)
 {
-  AtkSelection *selection = get_selection (message);
+  AtkSelection *selection = (AtkSelection *) user_data;
   DBusError error;
   dbus_int32_t selectedChildIndex;
   AtkObject *atk_object;
 
-  if (!selection)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_SELECTION (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &selectedChildIndex,
@@ -89,14 +73,14 @@ static DBusMessage *
 impl_selectChild (DBusConnection * bus, DBusMessage * message,
                  void *user_data)
 {
-  AtkSelection *selection = get_selection (message);
+  AtkSelection *selection = (AtkSelection *) user_data;
   DBusError error;
   dbus_int32_t childIndex;
   dbus_bool_t rv;
   DBusMessage *reply;
 
-  if (!selection)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_SELECTION (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &childIndex, DBUS_TYPE_INVALID))
@@ -117,14 +101,14 @@ static DBusMessage *
 impl_deselectSelectedChild (DBusConnection * bus, DBusMessage * message,
                            void *user_data)
 {
-  AtkSelection *selection = get_selection (message);
+  AtkSelection *selection = (AtkSelection *) user_data;
   DBusError error;
   dbus_int32_t selectedChildIndex;
   dbus_bool_t rv;
   DBusMessage *reply;
 
-  if (!selection)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_SELECTION (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &selectedChildIndex,
@@ -146,14 +130,14 @@ static DBusMessage *
 impl_isChildSelected (DBusConnection * bus, DBusMessage * message,
                      void *user_data)
 {
-  AtkSelection *selection = get_selection (message);
+  AtkSelection *selection = (AtkSelection *) user_data;
   DBusError error;
   dbus_int32_t childIndex;
   dbus_bool_t rv;
   DBusMessage *reply;
 
-  if (!selection)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_SELECTION (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &childIndex, DBUS_TYPE_INVALID))
@@ -173,12 +157,12 @@ impl_isChildSelected (DBusConnection * bus, DBusMessage * message,
 static DBusMessage *
 impl_selectAll (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
-  AtkSelection *selection = get_selection (message);
+  AtkSelection *selection = (AtkSelection *) user_data;
   dbus_bool_t rv;
   DBusMessage *reply;
 
-  if (!selection)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_SELECTION (user_data),
+                        droute_not_yet_handled_error (message));
   rv = atk_selection_select_all_selection (selection);
   reply = dbus_message_new_method_return (message);
   if (reply)
@@ -193,12 +177,12 @@ static DBusMessage *
 impl_clearSelection (DBusConnection * bus, DBusMessage * message,
                     void *user_data)
 {
-  AtkSelection *selection = get_selection (message);
+  AtkSelection *selection = (AtkSelection *) user_data;
   dbus_bool_t rv;
   DBusMessage *reply;
 
-  if (!selection)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_SELECTION (user_data),
+                        droute_not_yet_handled_error (message));
   rv = atk_selection_clear_selection (selection);
   reply = dbus_message_new_method_return (message);
   if (reply)
@@ -213,15 +197,15 @@ static DBusMessage *
 impl_deselectChild (DBusConnection * bus, DBusMessage * message,
                    void *user_data)
 {
-  AtkSelection *selection = get_selection (message);
+  AtkSelection *selection = (AtkSelection *) user_data;
   DBusError error;
   dbus_int32_t selectedChildIndex;
   dbus_bool_t rv = FALSE;
   gint i, nselected;
   DBusMessage *reply;
 
-  if (!selection)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_SELECTION (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &selectedChildIndex,
@@ -267,10 +251,10 @@ static DRouteProperty properties[] = {
 };
 
 void
-spi_initialize_selection (DRouteData * data)
+spi_initialize_selection (DRoutePath *path)
 {
-  droute_add_interface (data, SPI_DBUS_INTERFACE_SELECTION,
-                       methods, properties,
-                       (DRouteGetDatumFunction) get_selection_from_path,
-                       NULL);
+  droute_path_add_interface (path,
+                             SPI_DBUS_INTERFACE_SELECTION,
+                             methods,
+                             properties);
 };
diff --git a/atk-adaptor/selection.h b/atk-adaptor/selection.h
deleted file mode 100644 (file)
index f888cb3..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-#ifndef SPI_SELECTION_H_
-#define SPI_SELECTION_H_
-
-#include <libspi/base.h>
-#include <atk/atkselection.h>
-
-G_BEGIN_DECLS
-
-#define SPI_SELECTION_TYPE            (spi_selection_get_type ())
-#define SPI_SELECTION(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_SELECTION_TYPE, SpiSelection))
-#define SPI_SELECTION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), SPI_SELECTION_TYPE, SpiSelectionClass))
-#define SPI_IS_SELECTION(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SPI_SELECTION_TYPE))
-#define SPI_IS_SELECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SPI_SELECTION_TYPE))
-
-typedef struct _SpiSelection      SpiSelection;
-typedef struct _SpiSelectionClass SpiSelectionClass;
-
-struct _SpiSelection {
-  SpiBase parent;
-};
-
-struct _SpiSelectionClass {
-  SpiBaseClass parent_class;
-  POA_Accessibility_Selection__epv epv;
-};
-
-GType         spi_selection_get_type      (void);
-SpiSelection *spi_selection_interface_new (AtkObject *obj);
-
-G_END_DECLS
-
-#endif /* SPI_SELECTION_H_ */
similarity index 99%
rename from atk-adaptor/streamablecontent.c
rename to atk-adaptor/streamablecontent-adaptor.c
index cbe0686..8b3d40b 100644 (file)
@@ -25,7 +25,7 @@
 #include <config.h>
 #include <stdio.h>
 #include <string.h>
-#include <libspi/accessible.h>
+
 #include <libspi/component.h>
 #include <libspi/streamablecontent.h>
 
diff --git a/atk-adaptor/streamablecontent.h b/atk-adaptor/streamablecontent.h
deleted file mode 100644 (file)
index 666652a..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-#ifndef SPI_STREAMABLECONTENT_H_
-#define SPI_STREAMABLECONTENT_H_
-
-#include <libspi/base.h>
-#include <atk/atkstreamablecontent.h>
-
-G_BEGIN_DECLS
-
-#define SPI_STREAMABLE_TYPE        (spi_streamable_get_type ())
-#define SPI_STREAMABLE(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_STREAMABLE_TYPE, SpiStreamable))
-#define SPI_STREAMABLE_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), SPI_STREAMABLE_TYPE, SpiStreamableClass))
-#define SPI_IS_STREAMABLE(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), SPI_STREAMABLE_TYPE))
-#define SPI_IS_STREAMABLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SPI_STREAMABLE_TYPE))
-
-typedef struct {
-        SpiBase parent;
-} SpiStreamable;
-
-typedef struct {
-        SpiBaseClass parent_class;
-        POA_Accessibility_StreamableContent__epv epv;
-} SpiStreamableClass;
-
-GType         spi_streamable_get_type      (void);
-SpiStreamable *spi_streamable_interface_new (AtkObject *o);
-
-G_END_DECLS
-
-#endif /* SPI_STREAMABLECONTENT_H_ */
similarity index 78%
rename from atk-adaptor/table.c
rename to atk-adaptor/table-adaptor.c
index 868ae1f..cc8cfbe 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
-#include "accessible.h"
+#include <atk/atk.h>
+#include <droute/droute.h>
 
-static AtkTable *
-get_table (DBusMessage * message)
-{
-  AtkObject *obj = atk_dbus_get_object (dbus_message_get_path (message));
-  if (!obj)
-    return NULL;
-  return ATK_TABLE (obj);
-}
-
-static AtkTable *
-get_table_from_path (const char *path, void *user_data)
-{
-  AtkObject *obj = atk_dbus_get_object (path);
-  if (!obj || !ATK_IS_TABLE(obj))
-    return NULL;
-  return ATK_TABLE (obj);
-}
+#include "accessible-marshaller.h"
+#include "spi-common/spi-dbus.h"
 
 static dbus_bool_t
-impl_get_nRows (const char *path, DBusMessageIter * iter, void *user_data)
+impl_get_nRows (DBusMessageIter * iter, void *user_data)
 {
-  AtkTable *table = get_table_from_path (path, user_data);
-  if (!table)
-    return FALSE;
+  AtkTable *table = (AtkTable *) user_data;
+  g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
   return droute_return_v_int32 (iter, atk_table_get_n_rows (table));
 }
 
 static dbus_bool_t
-impl_get_nColumns (const char *path, DBusMessageIter * iter, void *user_data)
+impl_get_nColumns (DBusMessageIter * iter, void *user_data)
 {
-  AtkTable *table = get_table_from_path (path, user_data);
-  if (!table)
-    return FALSE;
+  AtkTable *table = (AtkTable *) user_data;
+  g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
   return droute_return_v_int32 (iter, atk_table_get_n_columns (table));
 }
 
 static dbus_bool_t
-impl_get_caption (const char *path, DBusMessageIter * iter, void *user_data)
+impl_get_caption (DBusMessageIter * iter, void *user_data)
 {
-  AtkTable *table = get_table_from_path (path, user_data);
-  if (!table)
-    return FALSE;
+  AtkTable *table = (AtkTable *) user_data;
+  g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
   return spi_dbus_return_v_object (iter, atk_table_get_caption (table),
                                   FALSE);
 }
 
 static dbus_bool_t
-impl_get_summary (const char *path, DBusMessageIter * iter, void *user_data)
+impl_get_summary (DBusMessageIter * iter, void *user_data)
 {
-  AtkTable *table = get_table_from_path (path, user_data);
-  if (!table)
-    return FALSE;
+  AtkTable *table = (AtkTable *) user_data;
+  g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
   return spi_dbus_return_v_object (iter, atk_table_get_summary (table),
                                   FALSE);
 }
 
 static dbus_bool_t
-impl_get_nSelectedRows (const char *path, DBusMessageIter * iter,
+impl_get_nSelectedRows (DBusMessageIter * iter,
                        void *user_data)
 {
-  AtkTable *table = get_table_from_path (path, user_data);
+  AtkTable *table = (AtkTable *) user_data;
   gint *selected_rows = NULL;
   int count;
-  if (!table)
-    return FALSE;
+  g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
   count = atk_table_get_selected_rows (table, &selected_rows);
   if (selected_rows)
     g_free (selected_rows);
@@ -96,14 +77,13 @@ impl_get_nSelectedRows (const char *path, DBusMessageIter * iter,
 }
 
 static dbus_bool_t
-impl_get_nSelectedColumns (const char *path, DBusMessageIter * iter,
+impl_get_nSelectedColumns (DBusMessageIter * iter,
                           void *user_data)
 {
-  AtkTable *table = get_table_from_path (path, user_data);
+  AtkTable *table = (AtkTable *) user_data;
   gint *selected_columns = NULL;
   int count;
-  if (!table)
-    return FALSE;
+  g_return_val_if_fail (ATK_IS_TABLE (user_data), FALSE);
   count = atk_table_get_selected_columns (table, &selected_columns);
   if (selected_columns)
     g_free (selected_columns);
@@ -114,13 +94,13 @@ static DBusMessage *
 impl_getAccessibleAt (DBusConnection * bus, DBusMessage * message,
                      void *user_data)
 {
-  AtkTable *table = get_table (message);
+  AtkTable *table = (AtkTable *) user_data;
   dbus_int32_t row, column;
   DBusError error;
   AtkObject *obj;
 
-  if (!table)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TABLE (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
@@ -135,14 +115,14 @@ impl_getAccessibleAt (DBusConnection * bus, DBusMessage * message,
 static DBusMessage *
 impl_getIndexAt (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
-  AtkTable *table = get_table (message);
+  AtkTable *table = (AtkTable *) user_data;
   dbus_int32_t row, column;
   dbus_int32_t index;
   DBusError error;
   DBusMessage *reply;
 
-  if (!table)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TABLE (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
@@ -164,14 +144,14 @@ static DBusMessage *
 impl_getRowAtIndex (DBusConnection * bus, DBusMessage * message,
                    void *user_data)
 {
-  AtkTable *table = get_table (message);
+  AtkTable *table = (AtkTable *) user_data;
   dbus_int32_t index;
   dbus_int32_t row;
   DBusError error;
   DBusMessage *reply;
 
-  if (!table)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TABLE (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
@@ -192,14 +172,14 @@ static DBusMessage *
 impl_getColumnAtIndex (DBusConnection * bus, DBusMessage * message,
                       void *user_data)
 {
-  AtkTable *table = get_table (message);
+  AtkTable *table = (AtkTable *) user_data;
   dbus_int32_t index;
   dbus_int32_t column;
   DBusError error;
   DBusMessage *reply;
 
-  if (!table)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TABLE (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
@@ -220,14 +200,14 @@ static DBusMessage *
 impl_getRowDescription (DBusConnection * bus, DBusMessage * message,
                        void *user_data)
 {
-  AtkTable *table = get_table (message);
   dbus_int32_t row;
+  AtkTable *table = (AtkTable *) user_data;
   const gchar *description;
   DBusError error;
   DBusMessage *reply;
 
-  if (!table)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TABLE (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
@@ -250,14 +230,14 @@ static DBusMessage *
 impl_getColumnDescription (DBusConnection * bus, DBusMessage * message,
                           void *user_data)
 {
-  AtkTable *table = get_table (message);
+  AtkTable *table = (AtkTable *) user_data;
   dbus_int32_t column;
   const char *description;
   DBusError error;
   DBusMessage *reply;
 
-  if (!table)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TABLE (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
@@ -280,14 +260,14 @@ static DBusMessage *
 impl_getRowExtentAt (DBusConnection * bus, DBusMessage * message,
                     void *user_data)
 {
-  AtkTable *table = get_table (message);
+  AtkTable *table = (AtkTable *) user_data;
   dbus_int32_t row, column;
   dbus_int32_t extent;
   DBusError error;
   DBusMessage *reply;
 
-  if (!table)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TABLE (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
@@ -309,14 +289,14 @@ static DBusMessage *
 impl_getColumnExtentAt (DBusConnection * bus, DBusMessage * message,
                        void *user_data)
 {
-  AtkTable *table = get_table (message);
+  AtkTable *table = (AtkTable *) user_data;
   dbus_int32_t row, column;
   dbus_int32_t extent;
   DBusError error;
   DBusMessage *reply;
 
-  if (!table)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TABLE (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
@@ -338,13 +318,13 @@ static DBusMessage *
 impl_getRowHeader (DBusConnection * bus, DBusMessage * message,
                   void *user_data)
 {
-  AtkTable *table = get_table (message);
+  AtkTable *table = (AtkTable *) user_data;
   dbus_int32_t row;
   DBusError error;
   AtkObject *obj;
 
-  if (!table)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TABLE (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
@@ -359,13 +339,13 @@ static DBusMessage *
 impl_getColumnHeader (DBusConnection * bus, DBusMessage * message,
                      void *user_data)
 {
-  AtkTable *table = get_table (message);
+  AtkTable *table = (AtkTable *) user_data;
   dbus_int32_t column;
   DBusError error;
   AtkObject *obj;
 
-  if (!table)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TABLE (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
@@ -380,13 +360,13 @@ static DBusMessage *
 impl_getSelectedRows (DBusConnection * bus, DBusMessage * message,
                      void *user_data)
 {
-  AtkTable *table = get_table (message);
+  AtkTable *table = (AtkTable *) user_data;
   gint *selected_rows = NULL;
   gint count;
   DBusMessage *reply;
 
-  if (!table)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TABLE (user_data),
+                        droute_not_yet_handled_error (message));
   count = atk_table_get_selected_rows (table, &selected_rows);
   if (!selected_rows)
     count = 0;
@@ -406,13 +386,13 @@ static DBusMessage *
 impl_getSelectedColumns (DBusConnection * bus, DBusMessage * message,
                         void *user_data)
 {
-  AtkTable *table = get_table (message);
+  AtkTable *table = (AtkTable *) user_data;
   gint *selected_columns = NULL;
   gint count;
   DBusMessage *reply;
 
-  if (!table)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TABLE (user_data),
+                        droute_not_yet_handled_error (message));
   count = atk_table_get_selected_columns (table, &selected_columns);
   if (!selected_columns)
     count = 0;
@@ -432,14 +412,14 @@ static DBusMessage *
 impl_isRowSelected (DBusConnection * bus, DBusMessage * message,
                    void *user_data)
 {
-  AtkTable *table = get_table (message);
+  AtkTable *table = (AtkTable *) user_data;
   dbus_int32_t row;
   DBusError error;
   DBusMessage *reply;
   dbus_bool_t ret;
 
-  if (!table)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TABLE (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
@@ -460,14 +440,14 @@ static DBusMessage *
 impl_isColumnSelected (DBusConnection * bus, DBusMessage * message,
                       void *user_data)
 {
-  AtkTable *table = get_table (message);
+  AtkTable *table = (AtkTable *) user_data;
   dbus_int32_t column;
   DBusError error;
   DBusMessage *reply;
   dbus_bool_t ret;
 
-  if (!table)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TABLE (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
@@ -487,14 +467,14 @@ impl_isColumnSelected (DBusConnection * bus, DBusMessage * message,
 static DBusMessage *
 impl_isSelected (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
-  AtkTable *table = get_table (message);
+  AtkTable *table = (AtkTable *) user_data;
   dbus_int32_t row, column;
   DBusError error;
   DBusMessage *reply;
   dbus_bool_t ret;
 
-  if (!table)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TABLE (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INT32, &column,
@@ -516,14 +496,14 @@ static DBusMessage *
 impl_addRowSelection (DBusConnection * bus, DBusMessage * message,
                      void *user_data)
 {
-  AtkTable *table = get_table (message);
+  AtkTable *table = (AtkTable *) user_data;
   dbus_int32_t row;
   DBusError error;
   DBusMessage *reply;
   dbus_bool_t ret;
 
-  if (!table)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TABLE (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
@@ -544,14 +524,14 @@ static DBusMessage *
 impl_addColumnSelection (DBusConnection * bus, DBusMessage * message,
                         void *user_data)
 {
-  AtkTable *table = get_table (message);
+  AtkTable *table = (AtkTable *) user_data;
   dbus_int32_t column;
   DBusError error;
   DBusMessage *reply;
   dbus_bool_t ret;
 
-  if (!table)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TABLE (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
@@ -572,14 +552,14 @@ static DBusMessage *
 impl_removeRowSelection (DBusConnection * bus, DBusMessage * message,
                         void *user_data)
 {
-  AtkTable *table = get_table (message);
+  AtkTable *table = (AtkTable *) user_data;
   dbus_int32_t row;
   DBusError error;
   DBusMessage *reply;
   dbus_bool_t ret;
 
-  if (!table)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TABLE (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &row, DBUS_TYPE_INVALID))
@@ -600,14 +580,14 @@ static DBusMessage *
 impl_removeColumnSelection (DBusConnection * bus, DBusMessage * message,
                            void *user_data)
 {
-  AtkTable *table = get_table (message);
+  AtkTable *table = (AtkTable *) user_data;
   dbus_int32_t column;
   DBusError error;
   DBusMessage *reply;
   dbus_bool_t ret;
 
-  if (!table)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TABLE (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &column, DBUS_TYPE_INVALID))
@@ -628,7 +608,7 @@ static DBusMessage *
 impl_getRowColumnExtentsAtIndex (DBusConnection * bus, DBusMessage * message,
                                 void *user_data)
 {
-  AtkTable *table = get_table (message);
+  AtkTable *table = (AtkTable *) user_data;
   dbus_int32_t index;
   DBusError error;
   dbus_int32_t row, column, row_extents, col_extents;
@@ -639,8 +619,8 @@ impl_getRowColumnExtentsAtIndex (DBusConnection * bus, DBusMessage * message,
   AtkObject *cell;
   AtkRole role;
 
-  if (!table)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TABLE (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
@@ -703,9 +683,10 @@ static DRouteProperty properties[] = {
 };
 
 void
-spi_initialize_table (DRouteData * data)
+spi_initialize_table (DRoutePath *path)
 {
-  droute_add_interface (data, SPI_DBUS_INTERFACE_TABLE, methods,
-                       properties,
-                       (DRouteGetDatumFunction) get_table_from_path, NULL);
+  droute_path_add_interface (path,
+                             SPI_DBUS_INTERFACE_TABLE,
+                             methods,
+                             properties);
 };
diff --git a/atk-adaptor/table.h b/atk-adaptor/table.h
deleted file mode 100644 (file)
index ce597a1..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-#ifndef SPI_TABLE_H_
-#define SPI_TABLE_H_
-
-#include <libspi/base.h>
-
-G_BEGIN_DECLS
-
-#define SPI_TABLE_TYPE         (spi_table_get_type ())
-#define SPI_TABLE(obj)         (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_TABLE_TYPE, SpiTable))
-#define SPI_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SPI_TABLE_TYPE, SpiTableClass))
-#define IS_TABLE(obj)          (G_TYPE_CHECK__INSTANCE_TYPE ((obj), SPI_TABLE_TYPE))
-#define IS_TABLE_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), SPI_TABLE_TYPE))
-
-typedef struct _SpiTable      SpiTable;
-typedef struct _SpiTableClass SpiTableClass;
-
-struct _SpiTable {
-  SpiBase parent;
-};
-
-struct _SpiTableClass {
-  SpiBaseClass parent_class;
-  POA_Accessibility_Table__epv epv;
-};
-
-GType     spi_table_get_type      (void);
-SpiTable *spi_table_interface_new (AtkObject *obj);
-
-G_END_DECLS
-
-#endif /* SPI_TABLE_H_ */
similarity index 85%
rename from atk-adaptor/text.c
rename to atk-adaptor/text-adaptor.c
index 451a92b..7c88211 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
-#include "accessible.h"
 #include <string.h>
 
-static AtkText *
-get_text (DBusMessage * message)
-{
-  AtkObject *obj = atk_dbus_get_object (dbus_message_get_path (message));
-  if (!obj)
-    return NULL;
-  return ATK_TEXT (obj);
-}
+#include <atk/atk.h>
+#include <droute/droute.h>
 
-static AtkText *
-get_text_from_path (const char *path, void *user_data)
-{
-  AtkObject *obj = atk_dbus_get_object (path);
-  if (!obj || !ATK_IS_TEXT(obj))
-    return NULL;
-  return ATK_TEXT (obj);
-}
+#include "spi-common/spi-dbus.h"
 
 static dbus_bool_t
-impl_get_characterCount (const char *path, DBusMessageIter * iter,
+impl_get_characterCount (DBusMessageIter * iter,
                         void *user_data)
 {
-  AtkText *text = get_text_from_path (path, user_data);
-  if (!text)
-    return FALSE;
+  AtkText *text = (AtkText *) user_data;
+  g_return_val_if_fail (ATK_IS_TEXT (user_data), FALSE);
   return droute_return_v_int32 (iter, atk_text_get_character_count (text));
 }
 
 static dbus_bool_t
-impl_get_caretOffset (const char *path, DBusMessageIter * iter,
+impl_get_caretOffset (DBusMessageIter * iter,
                      void *user_data)
 {
-  AtkText *text = get_text_from_path (path, user_data);
-  if (!text)
-    return FALSE;
+  AtkText *text = (AtkText *) user_data;
+  g_return_val_if_fail (ATK_IS_TEXT (user_data), FALSE);
   return droute_return_v_int32 (iter, atk_text_get_caret_offset (text));
 }
 
 static DBusMessage *
 impl_getText (DBusConnection * bus, DBusMessage * message, void *user_data)
 {
-  AtkText *text = get_text (message);
+  AtkText *text = (AtkText *) user_data;
   dbus_int32_t startOffset, endOffset;
   gchar *txt;
   DBusError error;
   DBusMessage *reply;
 
-  if (!text)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &startOffset, DBUS_TYPE_INT32,
@@ -98,14 +82,14 @@ static DBusMessage *
 impl_setCaretOffset (DBusConnection * bus, DBusMessage * message,
                     void *user_data)
 {
-  AtkText *text = get_text (message);
+  AtkText *text = (AtkText *) user_data;
   dbus_int32_t offset;
   dbus_bool_t rv;
   DBusError error;
   DBusMessage *reply;
 
-  if (!text)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_INVALID))
@@ -126,7 +110,7 @@ static DBusMessage *
 impl_getTextBeforeOffset (DBusConnection * bus, DBusMessage * message,
                          void *user_data)
 {
-  AtkText *text = get_text (message);
+  AtkText *text = (AtkText *) user_data;
   dbus_int32_t offset;
   dbus_uint32_t type;
   gchar *txt;
@@ -135,8 +119,8 @@ impl_getTextBeforeOffset (DBusConnection * bus, DBusMessage * message,
   DBusError error;
   DBusMessage *reply;
 
-  if (!text)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_UINT32, &type,
@@ -166,7 +150,7 @@ static DBusMessage *
 impl_getTextAtOffset (DBusConnection * bus, DBusMessage * message,
                      void *user_data)
 {
-  AtkText *text = get_text (message);
+  AtkText *text = (AtkText *) user_data;
   dbus_int32_t offset, type;
   gchar *txt;
   dbus_int32_t startOffset, endOffset;
@@ -174,8 +158,8 @@ impl_getTextAtOffset (DBusConnection * bus, DBusMessage * message,
   DBusError error;
   DBusMessage *reply;
 
-  if (!text)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_UINT32, &type,
@@ -205,7 +189,7 @@ static DBusMessage *
 impl_getTextAfterOffset (DBusConnection * bus, DBusMessage * message,
                         void *user_data)
 {
-  AtkText *text = get_text (message);
+  AtkText *text = (AtkText *) user_data;
   dbus_int32_t offset;
   dbus_uint32_t type;
   gchar *txt;
@@ -214,8 +198,8 @@ impl_getTextAfterOffset (DBusConnection * bus, DBusMessage * message,
   DBusError error;
   DBusMessage *reply;
 
-  if (!text)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_UINT32, &type,
@@ -245,14 +229,14 @@ static DBusMessage *
 impl_getCharacterAtOffset (DBusConnection * bus, DBusMessage * message,
                         void *user_data)
 {
-  AtkText *text = get_text (message);
+  AtkText *text = (AtkText *) user_data;
   dbus_int32_t offset;
   dbus_int32_t ch;
   DBusError error;
   DBusMessage *reply;
 
-  if (!text)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_INVALID))
@@ -272,7 +256,7 @@ static DBusMessage *
 impl_getAttributeValue (DBusConnection * bus, DBusMessage * message,
                        void *user_data)
 {
-  AtkText *text = get_text (message);
+  AtkText *text = (AtkText *) user_data;
   dbus_int32_t offset;
   char *attributeName;
   dbus_int32_t startOffset, endOffset;
@@ -285,8 +269,8 @@ impl_getAttributeValue (DBusConnection * bus, DBusMessage * message,
   GSList *cur_attr;
   AtkAttribute *at;
 
-  if (!text)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_STRING,
@@ -355,7 +339,7 @@ static DBusMessage *
 impl_getAttributes (DBusConnection * bus, DBusMessage * message,
                    void *user_data)
 {
-  AtkText *text = get_text (message);
+  AtkText *text = (AtkText *) user_data;
   dbus_int32_t offset;
   dbus_int32_t startOffset, endOffset;
   gint intstart_offset, intend_offset;
@@ -364,8 +348,8 @@ impl_getAttributes (DBusConnection * bus, DBusMessage * message,
   DBusMessage *reply;
   AtkAttributeSet *set;
 
-  if (!text)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_INVALID))
@@ -395,14 +379,14 @@ static DBusMessage *
 impl_getDefaultAttributes (DBusConnection * bus, DBusMessage * message,
                           void *user_data)
 {
-  AtkText *text = get_text (message);
+  AtkText *text = (AtkText *) user_data;
   char *rv;
   DBusError error;
   DBusMessage *reply;
   AtkAttributeSet *set;
 
-  if (!text)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
 
   set = atk_text_get_default_attributes (text);
@@ -422,7 +406,7 @@ static DBusMessage *
 impl_getCharacterExtents (DBusConnection * bus, DBusMessage * message,
                          void *user_data)
 {
-  AtkText *text = get_text (message);
+  AtkText *text = (AtkText *) user_data;
   dbus_int32_t offset;
   dbus_int16_t coordType;
   dbus_int32_t x, y, width, height;
@@ -430,8 +414,8 @@ impl_getCharacterExtents (DBusConnection * bus, DBusMessage * message,
   DBusError error;
   DBusMessage *reply;
 
-  if (!text)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_INT16, &coordType,
@@ -459,15 +443,15 @@ static DBusMessage *
 impl_getOffsetAtPoint (DBusConnection * bus, DBusMessage * message,
                       void *user_data)
 {
-  AtkText *text = get_text (message);
+  AtkText *text = (AtkText *) user_data;
   dbus_int32_t x, y;
   dbus_int16_t coordType;
   dbus_int32_t rv;
   DBusError error;
   DBusMessage *reply;
 
-  if (!text)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y,
@@ -489,12 +473,12 @@ static DBusMessage *
 impl_getNSelections (DBusConnection * bus, DBusMessage * message,
                     void *user_data)
 {
-  AtkText *text = get_text (message);
+  AtkText *text = (AtkText *) user_data;
   dbus_int32_t rv;
   DBusMessage *reply;
 
-  if (!text)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   rv = atk_text_get_n_selections (text);
   reply = dbus_message_new_method_return (message);
   if (reply)
@@ -509,15 +493,15 @@ static DBusMessage *
 impl_getSelection (DBusConnection * bus, DBusMessage * message,
                   void *user_data)
 {
-  AtkText *text = get_text (message);
+  AtkText *text = (AtkText *) user_data;
   dbus_int32_t selectionNum;
   dbus_int32_t startOffset, endOffset;
   gint intstart_offset = 0, intend_offset = 0;
   DBusError error;
   DBusMessage *reply;
 
-  if (!text)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &selectionNum, DBUS_TYPE_INVALID))
@@ -543,14 +527,14 @@ static DBusMessage *
 impl_addSelection (DBusConnection * bus, DBusMessage * message,
                   void *user_data)
 {
-  AtkText *text = get_text (message);
+  AtkText *text = (AtkText *) user_data;
   dbus_int32_t startOffset, endOffset;
   dbus_bool_t rv;
   DBusError error;
   DBusMessage *reply;
 
-  if (!text)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &startOffset, DBUS_TYPE_INT32,
@@ -572,14 +556,14 @@ static DBusMessage *
 impl_removeSelection (DBusConnection * bus, DBusMessage * message,
                      void *user_data)
 {
-  AtkText *text = get_text (message);
+  AtkText *text = (AtkText *) user_data;
   dbus_int32_t selectionNum;
   dbus_bool_t rv;
   DBusError error;
   DBusMessage *reply;
 
-  if (!text)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &selectionNum, DBUS_TYPE_INVALID))
@@ -600,14 +584,14 @@ static DBusMessage *
 impl_setSelection (DBusConnection * bus, DBusMessage * message,
                   void *user_data)
 {
-  AtkText *text = get_text (message);
+  AtkText *text = (AtkText *) user_data;
   dbus_int32_t selectionNum, startOffset, endOffset;
   dbus_bool_t rv;
   DBusError error;
   DBusMessage *reply;
 
-  if (!text)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &selectionNum, DBUS_TYPE_INT32,
@@ -629,7 +613,7 @@ static DBusMessage *
 impl_getRangeExtents (DBusConnection * bus, DBusMessage * message,
                      void *user_data)
 {
-  AtkText *text = get_text (message);
+  AtkText *text = (AtkText *) user_data;
   dbus_int32_t startOffset, endOffset;
   dbus_int16_t coordType;
   AtkTextRectangle rect;
@@ -637,8 +621,8 @@ impl_getRangeExtents (DBusConnection * bus, DBusMessage * message,
   DBusError error;
   DBusMessage *reply;
 
-  if (!text)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &startOffset, DBUS_TYPE_INT32,
@@ -669,7 +653,7 @@ static DBusMessage *
 impl_getBoundedRanges (DBusConnection * bus, DBusMessage * message,
                       void *user_data)
 {
-  AtkText *text = get_text (message);
+  AtkText *text = (AtkText *) user_data;
   dbus_int32_t x, y, width, height;
   dbus_int16_t coordType, xClipType, yClipType;
   DBusError error;
@@ -678,8 +662,8 @@ impl_getBoundedRanges (DBusConnection * bus, DBusMessage * message,
   DBusMessage *reply;
   DBusMessageIter iter, array, struc, variant;
 
-  if (!text)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y,
@@ -743,7 +727,7 @@ impl_getAttributeRun (DBusConnection * bus, DBusMessage * message,
                      void *user_data)
 {
   DBusError error;
-  AtkText *text = get_text (message);
+  AtkText *text = (AtkText *) user_data;
   dbus_int32_t offset;
   dbus_bool_t includeDefaults;
   dbus_int32_t startOffset, endOffset;
@@ -755,8 +739,8 @@ impl_getAttributeRun (DBusConnection * bus, DBusMessage * message,
   gint n_attributes = 0, total_attributes = 0, n_default_attributes = 0;
   gint i, j;
 
-  if (!text)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
   dbus_error_init (&error);
   if (!dbus_message_get_args
       (message, &error, DBUS_TYPE_INT32, &offset, DBUS_TYPE_BOOLEAN,
@@ -821,7 +805,7 @@ static DBusMessage *
 impl_getDefaultAttributeSet (DBusConnection * bus, DBusMessage * message,
                             void *user_data)
 {
-  AtkText *text = get_text (message);
+  AtkText *text = (AtkText *) user_data;
   DBusMessage *reply;
   AtkAttributeSet *attributes;
   AtkAttribute *attr = NULL;
@@ -829,8 +813,8 @@ impl_getDefaultAttributeSet (DBusConnection * bus, DBusMessage * message,
   gint n_attributes = 0;
   gint i;
 
-  if (!text)
-    return spi_dbus_general_error (message);
+  g_return_val_if_fail (ATK_IS_TEXT (user_data),
+                        droute_not_yet_handled_error (message));
 
   attributes = atk_text_get_default_attributes (text);
   if (attributes)
@@ -888,9 +872,10 @@ static DRouteProperty properties[] = {
 };
 
 void
-spi_initialize_text (DRouteData * data)
+spi_initialize_text (DRoutePath *path)
 {
-  droute_add_interface (data, SPI_DBUS_INTERFACE_TEXT, methods,
-                       properties,
-                       (DRouteGetDatumFunction) get_text_from_path, NULL);
+  droute_path_add_interface (path,
+                             SPI_DBUS_INTERFACE_TEXT,
+                             methods,
+                             properties);
 };
diff --git a/atk-adaptor/text.h b/atk-adaptor/text.h
deleted file mode 100644 (file)
index fb87b31..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-#ifndef SPI_TEXT_H_
-#define SPI_TEXT_H_
-
-#include <libspi/base.h>
-
-G_BEGIN_DECLS
-
-#define SPI_TEXT_TYPE         (spi_text_get_type ())
-#define SPI_TEXT(obj)         (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_TEXT_TYPE, SpiText))
-#define SPI_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SPI_TEXT_TYPE, SpiTextClass))
-#define IS_TEXT(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SPI_TEXT_TYPE))
-#define IS_TEXT_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), SPI_TEXT_TYPE))
-
-typedef struct _SpiText      SpiText;
-typedef struct _SpiTextClass SpiTextClass;
-
-struct _SpiText {
-  SpiBase parent;
-};
-
-struct _SpiTextClass {
-  SpiBaseClass parent_class;
-  POA_Accessibility_Text__epv epv;
-};
-
-GType    spi_text_get_type      (void);
-void     spi_text_construct     (SpiText   *text,
-                                AtkObject *obj);
-SpiText *spi_text_interface_new (AtkObject *obj);
-
-G_END_DECLS
-
-#endif /* SPI_TEXT_H_ */
diff --git a/atk-adaptor/tree-adaptor.c b/atk-adaptor/tree-adaptor.c
new file mode 100644 (file)
index 0000000..c031d43
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * 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.
+ * Copyright 2008, 2009 Codethink Ltd.
+ *
+ * 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 <string.h>
+
+#include <atk/atk.h>
+#include <droute/droute.h>
+
+#include "bridge.h"
+#include "accessible-register.h"
+#include "accessible-marshaller.h"
+#include "spi-common/spi-dbus.h"
+
+/*---------------------------------------------------------------------------*/
+
+/* For use as a GHFunc */
+static void
+append_accessible_hf (gpointer key, gpointer obj_data, gpointer iter)
+{
+  spi_atk_append_accessible (ATK_OBJECT(obj_data), iter);
+}
+
+/*---------------------------------------------------------------------------*/
+
+void
+spi_emit_cache_removal (guint ref,  DBusConnection *bus)
+{
+  DBusMessage *message;
+  DBusMessageIter iter;
+  gchar *path;
+
+  message = dbus_message_new_signal ("/org/freedesktop/atspi/tree", SPI_DBUS_INTERFACE_TREE, "removeAccessible");
+
+  dbus_message_iter_init_append (message, &iter);
+
+  path = atk_dbus_ref_to_path (ref);
+  dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &path);
+
+  dbus_connection_send(bus, message, NULL);
+}
+
+void
+spi_emit_cache_update (AtkObject *accessible, DBusConnection *bus)
+{
+   DBusMessage *message;
+   DBusMessageIter iter;
+   message = dbus_message_new_signal ("/org/freedesktop/atspi/tree", SPI_DBUS_INTERFACE_TREE, "updateAccessible");
+
+   dbus_message_iter_init_append (message, &iter);
+   spi_atk_append_accessible (accessible, &iter);
+
+   dbus_connection_send(bus, message, NULL);
+}
+
+
+/*---------------------------------------------------------------------------*/
+
+static DBusMessage *
+impl_getRoot (DBusConnection *bus, DBusMessage *message, void *user_data)
+{
+  AtkObject *root = atk_get_root();
+  char *path;
+  DBusMessage *reply;
+
+  if (!root)
+      return spi_dbus_general_error (message);
+  path = atk_dbus_object_to_path (root);
+  if (!path)
+      return spi_dbus_general_error (message);
+  reply = dbus_message_new_method_return (message);
+  dbus_message_append_args (reply, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID);
+  g_free (path);
+  return reply;
+}
+
+/*---------------------------------------------------------------------------*/
+
+static DBusMessage *
+impl_getTree (DBusConnection *bus, DBusMessage *message, void *user_data)
+{
+  DBusMessage *reply;
+  DBusMessageIter iter, iter_array;
+
+  reply = dbus_message_new_method_return (message);
+
+  dbus_message_iter_init_append (reply, &iter);
+  dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(ooaoassusau)", &iter_array);
+  atk_dbus_foreach_registered(append_accessible_hf, &iter_array);
+  dbus_message_iter_close_container(&iter, &iter_array);
+  return reply;
+}
+
+/*---------------------------------------------------------------------------*/
+
+static DRouteMethod methods[] = {
+  {impl_getRoot, "getRoot"},
+  {impl_getTree, "getTree"},
+  {NULL, NULL}
+};
+
+void
+spi_initialize_tree (DRoutePath *path)
+{
+  droute_path_add_interface (path,
+                             SPI_DBUS_INTERFACE_TREE,
+                             methods,
+                             NULL);
+};
+
+/*END------------------------------------------------------------------------*/
similarity index 76%
rename from atk-adaptor/util.c
rename to atk-adaptor/tree-adaptor.h
index 27d6f93..b0c99df 100644 (file)
@@ -4,6 +4,7 @@
  *
  * Copyright 2001, 2002 Sun Microsystems Inc.,
  * Copyright 2001, 2002 Ximian, Inc.
+ * Copyright 2008, 2009 Codethink Ltd.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
  * Boston, MA 02111-1307, USA.
  */
 
-#include <config.h>
-#include <spi-common/spi-types.h>
+#ifndef TREE_ADAPTOR_H
+#define TREE_ADAPTOR_H
 
-#include "spi-private.h"
+#include <atk/atk.h>
+#include <dbus/dbus.h>
 
-Accessibility_Role spi_accessible_role_from_atk_role (AtkRole role);
+void
+spi_emit_cache_update  (AtkObject *accessible, DBusConnection *bus);
 
-Accessibility_Role
-spi_role_from_atk_role (AtkRole role)
-{
-    return spi_accessible_role_from_atk_role (role);
-}
+void
+spi_emit_cache_removal (guint ref, DBusConnection *bus);
+
+#endif /* TREE_ADAPTOR_H */
diff --git a/atk-adaptor/tree.c b/atk-adaptor/tree.c
deleted file mode 100644 (file)
index 639d519..0000000
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- * 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 <string.h>
-#include <droute/introspect-loader.h>
-
-#include "accessible.h"
-#include "bridge.h"
-
-extern SpiAppData *app_data;
-static gboolean update_pending = FALSE;
-
-/*---------------------------------------------------------------------------*/
-
-static const char *dumm = "/APath/1";
-
-/*
- * Marshals the given AtkObject into the provided D-Bus iterator.
- *
- * The object is marshalled including all its client side cache data.
- * The format of the structure is (ooaoassusau).
- * This is used in the updateTree signal and the getTree method
- * of the org.freedesktop.atspi.Tree interface.
- */
-static void
-append_accessible(gpointer ref, gpointer obj_data, gpointer iter)
-{
-  AtkObject *obj;
-  DBusMessageIter *iter_array;
-  DBusMessageIter iter_struct, iter_sub_array;
-  DRouteData *data;
-  dbus_int32_t states [2];
-  int count;
-
-  const char *name, *desc;
-  int i;
-  dbus_uint32_t role;
-  GSList *l;
-
-  obj = ATK_OBJECT(obj_data);
-  iter_array = (DBusMessageIter *) iter;
-  data = &(app_data->droute);
-
-  dbus_message_iter_open_container (iter_array, DBUS_TYPE_STRUCT, NULL, &iter_struct);
-    {
-      AtkObject *parent;
-      gchar *path, *path_parent;
-
-      path = atk_dbus_get_path (obj_data);
-      dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH, &path);
-
-      parent = atk_object_get_parent(obj);
-      if (parent == NULL)
-        path_parent = g_strdup("/");
-      else
-        path_parent = atk_dbus_get_path (parent);
-      dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH, &path_parent);
-      g_free(path_parent);
-
-      dbus_message_iter_open_container (&iter_struct, DBUS_TYPE_ARRAY, "o", &iter_sub_array);
-        {
-          gint childcount, i;
-
-          childcount = atk_object_get_n_accessible_children (obj);
-          for (i = 0; i < childcount; i++)
-            {
-              AtkObject *child;
-              gchar *child_path;
-             
-              child = atk_object_ref_accessible_child (obj, i);
-             child_path = atk_dbus_get_path (child);
-             g_object_unref(G_OBJECT(child));
-             dbus_message_iter_append_basic (&iter_sub_array, DBUS_TYPE_OBJECT_PATH, &child_path);
-             g_free (child_path);
-           }
-        }
-      dbus_message_iter_close_container (&iter_struct, &iter_sub_array);
-
-      dbus_message_iter_open_container (&iter_struct, DBUS_TYPE_ARRAY, "s", &iter_sub_array);
-        {
-          for (l = data->interfaces; l; l = g_slist_next (l))
-            {
-              DRouteInterface *iface_def = (DRouteInterface *) l->data;
-              void *datum = NULL;
-
-              if (iface_def->get_datum)
-               {
-                 datum = (*iface_def->get_datum) (path, data->user_data);
-                 if (!datum)
-                   continue;
-               }
-              dbus_message_iter_append_basic (&iter_sub_array, DBUS_TYPE_STRING, &iface_def->name);
-              if (iface_def->free_datum)
-               (*iface_def->free_datum) (datum);
-            }
-        }
-      dbus_message_iter_close_container (&iter_struct, &iter_sub_array);
-
-      name = atk_object_get_name (obj);
-      if (!name)
-        name = "";
-      dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &name);
-
-      role = spi_accessible_role_from_atk_role (atk_object_get_role (obj));
-      dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_UINT32, &role);
-
-      desc = atk_object_get_description (obj);
-      if (!desc)
-        desc = "";
-      dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &desc);
-
-      g_free(path);
-    }      
-  spi_atk_state_to_dbus_array (obj, &states);
-      dbus_message_iter_open_container (&iter_struct, DBUS_TYPE_ARRAY, "u", &iter_sub_array);
-  for (count = 0; count < 2; count++)
-    dbus_message_iter_append_basic (&iter_sub_array, DBUS_TYPE_UINT32, &states[count]);
-      dbus_message_iter_close_container (&iter_struct, &iter_sub_array);
-  dbus_message_iter_close_container (iter_array, &iter_struct);
-}
-
-/*---------------------------------------------------------------------------*/
-
-/*
- * Used to marshal array of objects to remove.
- * Marshalls an object path onto the iter provided.
- */
-static void
-append_accessible_path(gpointer ref_data, gpointer null, gpointer data)
-{
-  guint ref;
-  gchar *path;
-  DBusMessageIter *iter_array;
-
-  iter_array = (DBusMessageIter *) data;
-  ref = GPOINTER_TO_INT(ref_data);
-  path = atk_dbus_get_path_from_ref(ref);
-  dbus_message_iter_append_basic (iter_array, DBUS_TYPE_OBJECT_PATH, &path);
-  g_free(path);
-}
-
-/*---------------------------------------------------------------------------*/
-
-static gboolean
-send_cache_update(gpointer d)
-{
-  DBusMessage *message;
-  DBusMessageIter iter;
-  DBusMessageIter iter_array;
-  DRouteData *data;
-
-  data = &(app_data->droute);
-
-  message = dbus_message_new_signal ("/org/freedesktop/atspi/tree", SPI_DBUS_INTERFACE_TREE, "updateTree");
-
-  dbus_message_iter_init_append (message, &iter);
-
-  dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "(ooaoassusau)", &iter_array);
-  atk_dbus_foreach_update_list(append_accessible, &iter_array);
-  dbus_message_iter_close_container(&iter, &iter_array);
-
-  dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "o", &iter_array);
-  atk_dbus_foreach_remove_list(append_accessible_path, &iter_array);
-  dbus_message_iter_close_container(&iter, &iter_array);
-
-  dbus_connection_send(data->bus, message, NULL);
-  update_pending = FALSE;
-
-  return FALSE;
-}
-
-/*---------------------------------------------------------------------------*/
-
-void
-atk_tree_cache_needs_update(void)
-{
-  if (!update_pending)
-    {
-      g_idle_add(send_cache_update, NULL);
-      update_pending = TRUE;
-    }
-}
-
-/*---------------------------------------------------------------------------*/
-
-static DBusMessage *
-impl_getRoot (DBusConnection *bus, DBusMessage *message, void *user_data)
-{
-  AtkObject *root = atk_get_root();
-  char *path;
-  DBusMessage *reply;
-
-  if (root) path = atk_dbus_get_path(root);
-  if (!root || !path)
-    return spi_dbus_general_error (message);
-  reply = dbus_message_new_method_return (message);
-  dbus_message_append_args (reply, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID);
-  g_free (path);
-  return reply;
-}
-
-/*---------------------------------------------------------------------------*/
-
-static DBusMessage *
-impl_getTree (DBusConnection *bus, DBusMessage *message, void *user_data)
-{
-  DBusMessage *reply;
-  DBusMessageIter iter, iter_array;
-  AtkObject *root = atk_get_root();
-
-  if (!root) 
-     return spi_dbus_general_error(message);
-  reply = dbus_message_new_method_return (message);
-
-  dbus_message_iter_init_append (reply, &iter);
-  dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(ooaoassusau)", &iter_array);
-  atk_dbus_foreach_registered(append_accessible, &iter_array);
-  dbus_message_iter_close_container(&iter, &iter_array);
-  return reply;
-}
-
-/*---------------------------------------------------------------------------*/
-
-static DBusMessage *
-impl_introspect (DBusConnection *bus, DBusMessage *message, void *user_data)
-{
-  const char *path;
-  GString *output;
-  char *final;
-
-  DBusMessage *reply;
-
-  path = dbus_message_get_path(message);
-
-  output = g_string_new(spi_introspection_header);
-  
-  g_string_append_printf(output, spi_introspection_node_element, path);
-
-  spi_append_interface(output, SPI_DBUS_INTERFACE_TREE);
-
-  g_string_append(output, spi_introspection_footer);
-  final = g_string_free(output, FALSE);
-
-  reply = dbus_message_new_method_return (message);
-  g_assert(reply != NULL);
-  dbus_message_append_args(reply, DBUS_TYPE_STRING, &final,
-                          DBUS_TYPE_INVALID);
-
-  g_free(final);
-  return reply;
-}
-
-/*---------------------------------------------------------------------------*/
-
-static DBusHandlerResult
-message_handler (DBusConnection *bus, DBusMessage *message, void *user_data)
-{
-  const char *iface = dbus_message_get_interface (message);
-  const char *member = dbus_message_get_member (message);
-
-  DBusMessage *reply = NULL;
-
-  g_return_val_if_fail(iface != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
-  
-  if (!strcmp(iface, SPI_DBUS_INTERFACE_TREE))
-    {
-      if (!strcmp(member, "getRoot"))
-       {
-         reply = impl_getRoot(bus, message, user_data);
-       }
-
-      if (!strcmp(member, "getTree"))
-       {
-         reply = impl_getTree(bus, message, user_data);
-       }
-    }
-
-  if (!strcmp(iface, "org.freedesktop.DBus.Introspectable"))
-    {
-      if (!strcmp(member, "Introspect"))
-       {
-         reply = impl_introspect(bus, message, user_data);
-       }
-    }
-
-  if (reply)
-    {
-      dbus_connection_send (bus, reply, NULL);
-      dbus_message_unref (reply);
-    }
-
-  return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-/*---------------------------------------------------------------------------*/
-
-static DBusObjectPathVTable tree_vtable =
-{
-  NULL,
-  &message_handler,
-  NULL, NULL, NULL, NULL
-};
-
-/*---------------------------------------------------------------------------*/
-
-void
-spi_register_tree_object(DBusConnection *bus,
-                        DRouteData *data,
-                        const char *path)
-{
-  dbus_bool_t mem = FALSE;
-  mem = dbus_connection_register_object_path(bus, path, &tree_vtable, data);
-  g_assert(mem == TRUE);
-}
-
-/*END------------------------------------------------------------------------*/
diff --git a/atk-adaptor/value-adaptor.c b/atk-adaptor/value-adaptor.c
new file mode 100644 (file)
index 0000000..4c0c8d8
--- /dev/null
@@ -0,0 +1,179 @@
+/*
+ * 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 <math.h>
+
+#include <atk/atk.h>
+#include <droute/droute.h>
+
+#include "spi-common/spi-dbus.h"
+
+static dbus_bool_t
+impl_get_minimumValue (DBusMessageIter * iter,
+                       void *user_data)
+{
+  AtkValue *value = (AtkValue *) user_data;
+  GValue src = {0};
+  GValue dest = {0};
+  gdouble dub;
+
+  g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
+
+  atk_value_get_minimum_value (value, &src);
+  g_value_init (&dest, G_TYPE_DOUBLE);
+
+  if (g_value_transform (&src, &dest))
+    {
+      dub = g_value_get_double (&dest);
+      dbus_message_iter_append_basic (iter, DBUS_TYPE_DOUBLE, &dub);
+      return TRUE;
+    }
+  else
+    {
+      return FALSE;
+    }
+}
+
+static dbus_bool_t
+impl_get_maximumValue (DBusMessageIter * iter,
+                       void *user_data)
+{
+  AtkValue *value = (AtkValue *) user_data;
+  GValue src = {0};
+  GValue dest = {0};
+  gdouble dub;
+
+  g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
+
+  atk_value_get_maximum_value (value, &src);
+  g_value_init (&dest, G_TYPE_DOUBLE);
+
+  if (g_value_transform (&src, &dest))
+    {
+      dub = g_value_get_double (&dest);
+      dbus_message_iter_append_basic (iter, DBUS_TYPE_DOUBLE, &dub);
+      return TRUE;
+    }
+  else
+    {
+      return FALSE;
+    }
+}
+
+static dbus_bool_t
+impl_get_minimumIncrement (DBusMessageIter * iter,
+                           void *user_data)
+{
+  AtkValue *value = (AtkValue *) user_data;
+  GValue src = {0};
+  GValue dest = {0};
+  gdouble dub;
+
+  g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
+
+  atk_value_get_minimum_increment (value, &src);
+  g_value_init (&dest, G_TYPE_DOUBLE);
+
+  if (g_value_transform (&src, &dest))
+    {
+      dub = g_value_get_double (&dest);
+      dbus_message_iter_append_basic (iter, DBUS_TYPE_DOUBLE, &dub);
+      return TRUE;
+    }
+  else
+    {
+      return FALSE;
+    }
+}
+
+static dbus_bool_t
+impl_get_currentValue (DBusMessageIter * iter,
+                       void *user_data)
+{
+  AtkValue *value = (AtkValue *) user_data;
+  GValue src = {0};
+  GValue dest = {0};
+  gdouble dub;
+
+  g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
+
+  atk_value_get_current_value (value, &src);
+  g_value_init (&dest, G_TYPE_DOUBLE);
+
+  if (g_value_transform (&src, &dest))
+    {
+      dub = g_value_get_double (&dest);
+      dbus_message_iter_append_basic (iter, DBUS_TYPE_DOUBLE, &dub);
+      return TRUE;
+    }
+  else
+    {
+      return FALSE;
+    }
+}
+
+static dbus_bool_t
+impl_set_currentValue (DBusMessageIter * iter,
+                       void *user_data)
+{
+  AtkValue *value = (AtkValue *) user_data;
+  GValue src = {0};
+  GValue dest = {0};
+  gdouble dub;
+
+  g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
+
+  dbus_message_iter_get_basic (iter, &dub);
+  g_value_init (&src, G_TYPE_DOUBLE);
+  g_value_set_double (&src, dub);
+
+  atk_value_get_current_value (value, &dest);
+
+  if (g_value_transform (&src, &dest))
+    {
+      atk_value_set_current_value (value, &dest);
+      return TRUE;
+    }
+  else
+    {
+      return FALSE;
+    }
+}
+
+static DRouteProperty properties[] = {
+  {impl_get_minimumValue, NULL, "minimumValue"},
+  {impl_get_maximumValue, NULL, "maximumValue"},
+  {impl_get_minimumIncrement, NULL, "minimumIncrement"},
+  {impl_get_currentValue, impl_set_currentValue, "currentValue"},
+  {NULL, NULL, NULL}
+};
+
+void
+spi_initialize_value (DRoutePath *path)
+{
+  droute_path_add_interface (path,
+                             SPI_DBUS_INTERFACE_VALUE,
+                             NULL,
+                             properties);
+};
diff --git a/atk-adaptor/value.c b/atk-adaptor/value.c
deleted file mode 100644 (file)
index 33b67c7..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * 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 "accessible.h"
-#include <math.h>
-
-static AtkValue *
-get_value_from_path (const char *path, void *user_data)
-{
-  AtkObject *obj = atk_dbus_get_object (path);
-  if (!obj || !ATK_IS_VALUE(obj))
-    return NULL;
-  return ATK_VALUE (obj);
-}
-
-static double
-get_double_from_gvalue (GValue * gvalue)
-{
-  double retval = 0;
-  if (G_TYPE_IS_FUNDAMENTAL (G_VALUE_TYPE (gvalue)))
-    {
-      switch (gvalue->g_type)
-       {
-       case G_TYPE_DOUBLE:
-         retval = g_value_get_double (gvalue);
-         break;
-       case G_TYPE_FLOAT:
-         retval = g_value_get_float (gvalue);
-         break;
-       case G_TYPE_ULONG:
-         retval = g_value_get_ulong (gvalue);
-         break;
-       case G_TYPE_LONG:
-         retval = g_value_get_long (gvalue);
-         break;
-       case G_TYPE_UINT:
-         retval = g_value_get_uint (gvalue);
-         break;
-       case G_TYPE_INT:
-         retval = g_value_get_int (gvalue);
-         break;
-       case G_TYPE_UCHAR:
-         retval = g_value_get_uchar (gvalue);
-         break;
-       case G_TYPE_CHAR:
-         retval = g_value_get_char (gvalue);
-         break;
-       case G_TYPE_BOOLEAN:
-         retval = g_value_get_boolean (gvalue);
-         break;
-       }
-    }
-  else
-    {
-      g_warning ("SpiValue requested from a non-fundamental type\n");
-    }
-  return retval;
-}
-
-static gboolean
-get_double_from_variant (DBusMessageIter * iter, double *out)
-{
-  DBusMessageIter sub;
-
-  dbus_message_iter_recurse (iter, &sub);
-  switch (dbus_message_iter_get_arg_type (&sub))
-    {
-    case DBUS_TYPE_DOUBLE:
-      {
-       dbus_message_iter_get_basic (&sub, out);
-       return TRUE;
-      }
-    case DBUS_TYPE_UINT32:
-      {
-       dbus_uint32_t v;
-       dbus_message_iter_get_basic (&sub, &v);
-       *out = (double) v;
-       return TRUE;
-      }
-    case DBUS_TYPE_INT32:
-      {
-       dbus_int32_t v;
-       dbus_message_iter_get_basic (&sub, &v);
-       *out = (double) v;
-       return TRUE;
-      }
-    case DBUS_TYPE_UINT16:
-      {
-       dbus_uint16_t v;
-       dbus_message_iter_get_basic (&sub, &v);
-       *out = (double) v;
-       return TRUE;
-      }
-    case DBUS_TYPE_INT16:
-      {
-       dbus_int16_t v;
-       dbus_message_iter_get_basic (&sub, &v);
-       *out = (double) v;
-       return TRUE;
-      }
-    case DBUS_TYPE_BYTE:
-      {
-       char v;
-       dbus_message_iter_get_basic (&sub, &v);
-       *out = (double) v;
-       return TRUE;
-      }
-    case DBUS_TYPE_BOOLEAN:
-      {
-       dbus_bool_t v;
-       dbus_message_iter_get_basic (&sub, &v);
-       *out = (double) v;
-       return TRUE;
-      }
-    default:
-      return FALSE;
-    }
-}
-
-static void
-gvalue_set_from_double (GValue * gvalue, double value)
-{
-  if (G_TYPE_IS_FUNDAMENTAL (G_VALUE_TYPE (gvalue)))
-    {
-      switch (gvalue->g_type)
-       {
-       case G_TYPE_DOUBLE:
-         g_value_set_double (gvalue, value);
-         break;
-       case G_TYPE_FLOAT:
-         g_value_set_float (gvalue, value);
-         break;
-       case G_TYPE_ULONG:
-         g_value_set_ulong (gvalue, value);
-         break;
-       case G_TYPE_LONG:
-         g_value_set_long (gvalue, value);
-         break;
-       case G_TYPE_UINT:
-         g_value_set_uint (gvalue, value);
-         break;
-       case G_TYPE_INT:
-         g_value_set_int (gvalue, value);
-         break;
-       case G_TYPE_UCHAR:
-         g_value_set_uchar (gvalue, value);
-         break;
-       case G_TYPE_CHAR:
-         g_value_set_char (gvalue, value);
-         break;
-       case G_TYPE_BOOLEAN:
-         g_value_set_boolean (gvalue, ((fabs (value) > 0.5) ? 1 : 0));
-         break;
-       }
-    }
-  else
-    {
-      g_warning ("SpiValue change requested for a non-fundamental type\n");
-    }
-}
-
-static dbus_bool_t
-impl_get_minimumValue (const char *path, DBusMessageIter * iter,
-                      void *user_data)
-{
-  AtkValue *value = get_value_from_path (path, user_data);
-  GValue gvalue = { 0, };
-  if (!value)
-    return FALSE;
-  atk_value_get_minimum_value (value, &gvalue);
-  return droute_return_v_double (iter, get_double_from_gvalue (&gvalue));
-}
-
-static dbus_bool_t
-impl_get_maximumValue (const char *path, DBusMessageIter * iter,
-                      void *user_data)
-{
-  AtkValue *value = get_value_from_path (path, user_data);
-  GValue gvalue = { 0, };
-  if (!value)
-    return FALSE;
-  atk_value_get_maximum_value (value, &gvalue);
-  return droute_return_v_double (iter, get_double_from_gvalue (&gvalue));
-}
-
-static dbus_bool_t
-impl_get_minimumIncrement (const char *path, DBusMessageIter * iter,
-                          void *user_data)
-{
-  AtkValue *value = get_value_from_path (path, user_data);
-  GValue gvalue = { 0, };
-  if (!value)
-    return FALSE;
-  atk_value_get_minimum_value (value, &gvalue);
-  return droute_return_v_double (iter, get_double_from_gvalue (&gvalue));
-}
-
-static dbus_bool_t
-impl_get_currentValue (const char *path, DBusMessageIter * iter,
-                      void *user_data)
-{
-  AtkValue *value = get_value_from_path (path, user_data);
-  GValue gvalue = { 0, };
-  if (!value)
-    return FALSE;
-  atk_value_get_current_value (value, &gvalue);
-  return droute_return_v_double (iter, get_double_from_gvalue (&gvalue));
-}
-
-static dbus_bool_t
-impl_set_currentValue (const char *path, DBusMessageIter * iter,
-                      void *user_data)
-{
-  AtkValue *value = get_value_from_path (path, user_data);
-  GValue gvalue = { 0, };
-  double dbl;
-
-  if (!value)
-    return FALSE;
-  if (!get_double_from_variant (iter, &dbl))
-    return FALSE;
-  atk_value_get_current_value (value, &gvalue);
-  gvalue_set_from_double (&gvalue, dbl);
-  return TRUE;
-}
-
-static DRouteProperty properties[] = {
-  {impl_get_minimumValue, NULL, "minimumValue"},
-  {impl_get_maximumValue, NULL, "maximumValue"},
-  {impl_get_minimumIncrement, NULL, "minimumIncrement"},
-  {impl_get_currentValue, impl_set_currentValue, "currentValue"},
-  {NULL, NULL, NULL}
-};
-
-void
-spi_initialize_value (DRouteData * data)
-{
-  droute_add_interface (data, SPI_DBUS_INTERFACE_VALUE, NULL,
-                       properties,
-                       (DRouteGetDatumFunction) get_value_from_path, NULL);
-};
diff --git a/atk-adaptor/value.h b/atk-adaptor/value.h
deleted file mode 100644 (file)
index 94e9378..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * 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.
- */
-
-#ifndef SPI_VALUE_H_
-#define SPI_VALUE_H_
-
-#include <libspi/base.h>
-#include <atk/atkvalue.h>
-
-G_BEGIN_DECLS
-
-#define SPI_VALUE_TYPE            (spi_value_get_type ())
-#define SPI_VALUE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPI_VALUE_TYPE, SpiValue))
-#define SPI_VALUE_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST((klass), SPI_VALUE_TYPE, SpiValueClass))
-#define SPI_IS_VALUE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SPI_VALUE_TYPE))
-#define SPI_IS_VALUE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SPI_VALUE_TYPE))
-
-typedef struct _Value SpiValue;
-typedef struct _ValueClass SpiValueClass;
-
-struct _Value {
-  SpiBase parent;
-};
-
-struct _ValueClass {
-  SpiBaseClass parent_class;
-  POA_Accessibility_Value__epv epv;
-};
-
-GType     spi_value_get_type      (void);
-SpiValue *spi_value_interface_new (AtkObject *obj);
-
-G_END_DECLS
-
-#endif /* SPI_VALUE_H_ */
index 57f0bfb..e314999 100644 (file)
@@ -388,7 +388,7 @@ cspi_dbus_handle_deviceEvent (DBusConnection *bus, DBusMessage *message, void *d
     goto done;
   }
   dbus_message_iter_init (message, &iter);
-  dbind_any_demarshal (iter, &deviceEvent_type, &p);
+  dbind_any_demarshal (&iter, (char **) &deviceEvent_type, &p);
   klass = CSPI_DEVICE_LISTENER_GET_CLASS (listener);
   if (klass->device_event)
   {
index 1bf7753..aeda398 100644 (file)
@@ -415,7 +415,7 @@ add_app_to_desktop (Accessible *a, const char *bus_name)
   char *root_path;
 
   dbus_error_init (&error);
-  if (dbind_connection_method_call (bus, bus_name, "/org/freedesktop/atspi/tree", spi_interface_tree, "getRoot", &error, "=>o", &root_path))
+  if (dbind_method_call_reentrant (bus, bus_name, "/org/freedesktop/atspi/tree", spi_interface_tree, "getRoot", &error, "=>o", &root_path))
   {
     Accessible *obj = cspi_ref_accessible (bus_name, root_path);
     if (obj)
@@ -507,7 +507,7 @@ ref_accessible_desktop (CSpiApplication *app)
   desktop->ref_count = 2;      /* one for the caller, one for the hash */
   desktop->name = g_strdup ("");
   dbus_error_init (&error);
-  if (!dbind_connection_method_call (bus, spi_bus_registry, spi_path_registry, spi_interface_registry, "getApplications", &error, "=>as", &apps))
+  if (!dbind_method_call_reentrant (bus, spi_bus_registry, spi_path_registry, spi_interface_registry, "getApplications", &error, "=>as", &apps))
   {
     g_error ("Couldn't get application list: %s", error.message);
   }
@@ -522,7 +522,7 @@ ref_accessible_desktop (CSpiApplication *app)
     CSpiApplication *app = cspi_get_application (app_name);
     additions = NULL;
     dbus_error_init (&error);
-    dbind_connection_method_call (bus, app_name, "/org/freedesktop/atspi/tree", spi_interface_tree, "getTree", &error, "=>a(ooaoassusau)", &additions);
+    dbind_method_call_reentrant (bus, app_name, "/org/freedesktop/atspi/tree", spi_interface_tree, "getTree", &error, "=>a(ooaoassusau)", &additions);
     if (error.message)
     {
       g_warning ("getTree (%s): %s", app_name, error.message);
@@ -1039,7 +1039,7 @@ cspi_dbus_call (Accessible *obj, const char *interface, const char *method, DBus
   if (!error) error = &err;
   dbus_error_init (error);
   va_start (args, type);
-  retval = dbind_connection_method_call_va (SPI_bus(), obj->app->bus_name, path, interface, method, error, type, args);
+  retval = dbind_method_call_reentrant_va (SPI_bus(), obj->app->bus_name, path, interface, method, error, type, args);
   va_end (args);
   g_free (path);
   if (dbus_error_is_set (error))
index 6e432ec..d920cf0 100644 (file)
@@ -210,7 +210,7 @@ SPI_registerAccessibleKeystrokeListener (AccessibleKeystrokeListener  *listener,
          (dbus_bool_t) ((sync_type & SPI_KEYLISTENER_ALL_WINDOWS)!=0);
 
     dbus_error_init (&error);
-    dbind_connection_method_call (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "registerKeystrokeListener", &error, "oa(iisi)uu(bbb)=>b", path, key_set, controller_event_mask, key_set, &listener_mode, &retval);
+    dbind_method_call_reentrant (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "registerKeystrokeListener", &error, "oa(iisi)uu(bbb)=>b", path, key_set, controller_event_mask, key_set, &listener_mode, &retval);
 
   g_array_free (key_set, TRUE);
   g_free (path);
@@ -249,7 +249,7 @@ SPI_deregisterAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener
   controller_event_mask = (dbus_uint32_t) modmask;
 
       key_set = g_array_sized_new (FALSE, TRUE, sizeof (Accessibility_KeyDefinition), 0);
-    dbind_connection_method_call (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "deregisterKeystrokeListener", &error, "oa(iisi)uu", path, &key_set, key_events, controller_event_mask);
+    dbind_method_call_reentrant (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "deregisterKeystrokeListener", &error, "oa(iisi)uu", path, &key_set, key_events, controller_event_mask);
   g_free (path);
   return TRUE;
 }
@@ -294,7 +294,7 @@ SPI_registerDeviceEventListener (AccessibleDeviceListener  *listener,
     }
 
   dbus_error_init (&error);
-    dbind_connection_method_call (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "registerDeviceEventListener", &error, "ou=>b", path, event_types, &retval);
+    dbind_method_call_reentrant (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "registerDeviceEventListener", &error, "ou=>b", path, event_types, &retval);
   g_free (path);
   return retval;
 }
@@ -327,7 +327,7 @@ SPI_deregisterDeviceEventListener (AccessibleDeviceListener *listener,
   event_types |= (1 << Accessibility_BUTTON_RELEASED_EVENT);
 
   dbus_error_init (&error);
-    dbind_connection_method_call (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "deregisterDeviceEventListener", &error, "ou", path, event_types);
+    dbind_method_call_reentrant (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "deregisterDeviceEventListener", &error, "ou", path, event_types);
   g_free (path);
   return TRUE;
 }
@@ -383,7 +383,7 @@ SPI_generateKeyboardEvent (long int keyval,
 
   if (!keystring) keystring = "";
   dbus_error_init (&error);
-    dbind_connection_method_call (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "generateKeyboardEvent", &error, "isu", keycode, keystring, keysynth_type);
+    dbind_method_call_reentrant (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "generateKeyboardEvent", &error, "isu", keycode, keystring, keysynth_type);
 
   return TRUE;
 }
@@ -411,7 +411,7 @@ SPI_generateMouseEvent (long x, long y, char *name)
   DBusError error;
 
   dbus_error_init (&error);
-    dbind_connection_method_call (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "generateMouseEvent", &error, "iis", x, y, name);
+    dbind_method_call_reentrant (SPI_bus(), spi_bus_registry, spi_path_dec, spi_interface_dec, "generateMouseEvent", &error, "iis", x, y, name);
   return TRUE;
 }
 
index 97365b8..cc2849e 100644 (file)
@@ -1,6 +1,6 @@
 lib_LTLIBRARIES = libdbind.la
 
-INCLUDES = \
+AM_CPPFLAGS = \
        -DG_LOG_DOMAIN=\"dbind\" \
        -I$(top_srcdir) \
        $(WARN_CFLAGS) \
@@ -21,4 +21,4 @@ TESTS = dbtest
 
 check_PROGRAMS = dbtest
 dbtest_SOURCES = dbtest.c
-dbtest_LDFLAGS = libdbind.la
\ No newline at end of file
+dbtest_LDFLAGS = libdbind.la
index 1f784e5..83a87ba 100644 (file)
@@ -1,9 +1,9 @@
 /* type driven marshalling */
-#include "config.h"
-#include "dbind-config.h"
-#define DBUS_API_SUBJECT_TO_CHANGE
 #include <stdio.h>
 #include <glib.h>
+
+#include "config.h"
+#include "dbind-config.h"
 #include "dbind-any.h"
 
 #undef DEBUG
   ((gpointer)ALIGN_VALUE(this, boundary))
 
 #define PTR_PLUS(ptr, offset) \
-       ((gpointer) (((guchar *)(ptr)) + (offset)))
+        ((gpointer) (((guchar *)(ptr)) + (offset)))
+
+#define DBIND_POD_CASES \
+         DBUS_TYPE_BYTE: \
+    case DBUS_TYPE_INT16: \
+    case DBUS_TYPE_UINT16: \
+    case DBUS_TYPE_INT32: \
+    case DBUS_TYPE_UINT32: \
+    case DBUS_TYPE_BOOLEAN: \
+    case DBUS_TYPE_INT64: \
+    case DBUS_TYPE_UINT64: \
+    case DBUS_TYPE_DOUBLE
 
-unsigned int dbind_find_c_alignment_r (char **type);
-unsigned int dbind_find_c_alignment   (char  *type);
+/*---------------------------------------------------------------------------*/
 
 static void
 warn_braces ()
@@ -36,26 +46,87 @@ warn_braces ()
              " an explicit type member of 'struct'\n");
 }
 
+/*---------------------------------------------------------------------------*/
+
+static unsigned int
+dbind_find_c_alignment_r (char **type)
+{
+        unsigned int retval = 1;
+
+    char t = **type;
+    (*type)++;
+
+#ifdef DEBUG
+    fprintf (stderr, "\tfind align for %c (0x%x)\n", t, t);
+#endif
+
+        switch (t) {
+    case DBUS_TYPE_BYTE:
+        return DBIND_ALIGNOF_CHAR;
+    case DBUS_TYPE_BOOLEAN:
+        return DBIND_ALIGNOF_DBUS_BOOL_T;
+    case DBUS_TYPE_INT16:
+    case DBUS_TYPE_UINT16:
+        return DBIND_ALIGNOF_DBUS_INT16_T;
+    case DBUS_TYPE_INT32:
+    case DBUS_TYPE_UINT32:
+        return DBIND_ALIGNOF_DBUS_INT32_T;
+    case DBUS_TYPE_INT64:
+    case DBUS_TYPE_UINT64:
+        return DBIND_ALIGNOF_DBUS_INT64_T;
+    case DBUS_TYPE_DOUBLE:
+        return DBIND_ALIGNOF_DOUBLE;
+    /* ptr types */
+    case DBUS_TYPE_STRING:
+    case DBUS_TYPE_OBJECT_PATH:
+    case DBUS_TYPE_SIGNATURE:
+    case DBUS_TYPE_ARRAY:
+        return DBIND_ALIGNOF_DBIND_POINTER;
+        case DBUS_STRUCT_BEGIN_CHAR:
+#if DBIND_ALIGNOF_DBIND_STRUCT > 1
+                retval = MAX (retval, DBIND_ALIGNOF_DBIND_STRUCT);
+#endif
+        while (**type != DBUS_STRUCT_END_CHAR) {
+            int elem_align = dbind_find_c_alignment_r (type);
+                        retval = MAX (retval, elem_align);
+        }
+        (*type)++;
+                return retval;
+    case DBUS_TYPE_STRUCT:
+    case DBUS_TYPE_DICT_ENTRY:
+        warn_braces ();
+        return DBIND_ALIGNOF_DBIND_POINTER;
+    case '\0':
+        g_assert_not_reached();
+        break;
+        default:
+                return 1;
+        }
+}
+
+/*---------------------------------------------------------------------------*/
+
 /* gather immediate allocation information for this type */
-size_t dbind_gather_alloc_info_r (char **type)
+static size_t
+dbind_gather_alloc_info_r (char **type)
 {
     char t = **type;
     (*type)++;
     if (t == DBUS_TYPE_ARRAY) {
-       switch (**type) {
-           case DBUS_STRUCT_BEGIN_CHAR:
-               while (**type != DBUS_STRUCT_END_CHAR && **type != '\0') (*type)++;
-               if (**type != '\0') (*type)++;
-               break;
-           case '\0':
-               break;
-           default:
-               (*type)++;
-               break;
-           }
-       }
-
-       switch (t) {
+        switch (**type) {
+            case DBUS_STRUCT_BEGIN_CHAR:
+                while (**type != DBUS_STRUCT_END_CHAR && **type != '\0') (*type)++;
+                if (**type != '\0') (*type)++;
+                break;
+            case '\0':
+                break;
+            default:
+                (*type)++;
+                break;
+            }
+        }
+
+        switch (t) {
     case DBUS_TYPE_BYTE:
         return sizeof (char);
     case DBUS_TYPE_BOOLEAN:
@@ -78,106 +149,114 @@ size_t dbind_gather_alloc_info_r (char **type)
     case DBUS_TYPE_ARRAY:
         return sizeof (void *);
     case DBUS_STRUCT_BEGIN_CHAR: {
-               int sum = 0, stralign;
+                int sum = 0, stralign;
 
         stralign = dbind_find_c_alignment (*type - 1);
 
         while (**type != DBUS_STRUCT_END_CHAR) {
-                       sum = ALIGN_VALUE (sum, dbind_find_c_alignment (*type));
-                       sum += dbind_gather_alloc_info_r (type);
+                        sum = ALIGN_VALUE (sum, dbind_find_c_alignment (*type));
+                        sum += dbind_gather_alloc_info_r (type);
         }
-               sum = ALIGN_VALUE (sum, stralign);
+                sum = ALIGN_VALUE (sum, stralign);
 
         g_assert (**type == DBUS_STRUCT_END_CHAR);
         (*type)++;
 
-               return sum;
+                return sum;
     }
     case DBUS_TYPE_STRUCT:
     case DBUS_TYPE_DICT_ENTRY:
         warn_braces ();
-       default:
-               return 0;
-       }
+        default:
+                return 0;
+        }
 }
 
-size_t dbind_gather_alloc_info (char *type)
+static size_t
+dbind_gather_alloc_info (char *type)
 {
     return dbind_gather_alloc_info_r (&type);
 }
 
-unsigned int
-dbind_find_c_alignment_r (char **type)
-{
-       unsigned int retval = 1;
+/*---------------------------------------------------------------------------*/
 
-    char t = **type;
-    (*type)++;
+static void
+dbind_any_free_r (char **type, void **data)
+{
+    size_t len;
 
 #ifdef DEBUG
-    fprintf (stderr, "\tfind align for %c (0x%x)\n", t, t);
+    fprintf (stderr, "any free '%c' to %p\n", **type, *data);
 #endif
 
-       switch (t) {
-    case DBUS_TYPE_BYTE:
-        return DBIND_ALIGNOF_CHAR;
-    case DBUS_TYPE_BOOLEAN:
-        return DBIND_ALIGNOF_DBUS_BOOL_T;
-    case DBUS_TYPE_INT16:
-    case DBUS_TYPE_UINT16:
-        return DBIND_ALIGNOF_DBUS_INT16_T;
-    case DBUS_TYPE_INT32:
-    case DBUS_TYPE_UINT32:
-        return DBIND_ALIGNOF_DBUS_INT32_T;
-    case DBUS_TYPE_INT64:
-    case DBUS_TYPE_UINT64:
-        return DBIND_ALIGNOF_DBUS_INT64_T;
-    case DBUS_TYPE_DOUBLE:
-        return DBIND_ALIGNOF_DOUBLE;
-    /* ptr types */
+    switch (**type) {
+    case DBIND_POD_CASES:
+        *data = ((guchar *)*data) + dbind_gather_alloc_info (*type);
+        (*type)++;
+        break;
     case DBUS_TYPE_STRING:
     case DBUS_TYPE_OBJECT_PATH:
     case DBUS_TYPE_SIGNATURE:
-    case DBUS_TYPE_ARRAY:
-        return DBIND_ALIGNOF_DBIND_POINTER;
-       case DBUS_STRUCT_BEGIN_CHAR:
-#if DBIND_ALIGNOF_DBIND_STRUCT > 1
-               retval = MAX (retval, DBIND_ALIGNOF_DBIND_STRUCT);
+#ifdef DEBUG
+        fprintf (stderr, "string free %p\n", **(void ***)data);
 #endif
+        g_free (**(void ***)data);
+        *data = ((guchar *)*data) + dbind_gather_alloc_info (*type);
+        (*type)++;
+        break;
+    case DBUS_TYPE_ARRAY: {
+        int i;
+        GArray *vals = **(void ***)data;
+        size_t elem_size, elem_align;
+        char *saved_child_type, *child_type_string;
+
+        (*type)++;
+        saved_child_type = *type;
+
+        elem_size = dbind_gather_alloc_info (*type);
+        elem_align = dbind_find_c_alignment_r (type); 
+
+        for (i = 0; i < vals->len; i++) {
+            void *ptr = vals->data + elem_size * i;
+            *type = saved_child_type; /* rewind type info */
+            ptr = ALIGN_ADDRESS (ptr, elem_align);
+            dbind_any_free_r (type, &ptr);
+        }
+        g_array_free (vals, TRUE);
+        break;
+    }
+    case DBUS_STRUCT_BEGIN_CHAR: {
+                gconstpointer data0 = *data;
+                int offset = 0, stralign;
+
+        stralign = dbind_find_c_alignment (*type);
+        (*type)++;
+
+        offset = 0 ;
         while (**type != DBUS_STRUCT_END_CHAR) {
-            int elem_align = dbind_find_c_alignment_r (type);
-                       retval = MAX (retval, elem_align);
+            char *subt = *type;
+                        offset = ALIGN_VALUE (offset, dbind_find_c_alignment (*type));
+                        *data = PTR_PLUS (data0, offset);
+            dbind_any_free_r (type, data);
+            offset += dbind_gather_alloc_info (subt);
         }
+
+                offset = ALIGN_VALUE (offset, stralign);
+                *data = PTR_PLUS (data0, offset);
+
+        g_assert (**type == DBUS_STRUCT_END_CHAR);
         (*type)++;
-               return retval;
+
+        break;
+    }
     case DBUS_TYPE_STRUCT:
     case DBUS_TYPE_DICT_ENTRY:
         warn_braces ();
-        return DBIND_ALIGNOF_DBIND_POINTER;
-    case '\0':
-        g_assert_not_reached();
         break;
-       default:
-               return 1;
-       }
+    }
 }
 
-unsigned int
-dbind_find_c_alignment (char *type)
-{
-    return dbind_find_c_alignment_r (&type);
-}
-
-#define DBIND_POD_CASES \
-         DBUS_TYPE_BYTE: \
-    case DBUS_TYPE_INT16: \
-    case DBUS_TYPE_UINT16: \
-    case DBUS_TYPE_INT32: \
-    case DBUS_TYPE_UINT32: \
-    case DBUS_TYPE_BOOLEAN: \
-    case DBUS_TYPE_INT64: \
-    case DBUS_TYPE_UINT64: \
-    case DBUS_TYPE_DOUBLE
+/*---------------------------------------------------------------------------*/
 
 void
 dbind_any_marshal (DBusMessageIter *iter,
@@ -215,7 +294,7 @@ dbind_any_marshal (DBusMessageIter *iter,
 
         /* wow this part of the API sucks too ... */
         child_type_string = g_strndup (saved_child_type, *type - saved_child_type);
-/*        fprintf (stderr, "array child type '%s'\n", child_type_string); */
+        /* fprintf (stderr, "array child type '%s'\n", child_type_string); */
         dbus_message_iter_open_container (iter, DBUS_TYPE_ARRAY,
                                           child_type_string, &sub);
         for (i = 0; i < vals->len; i++) {
@@ -230,8 +309,8 @@ dbind_any_marshal (DBusMessageIter *iter,
         break;
     }
     case DBUS_STRUCT_BEGIN_CHAR: {
-               gconstpointer data0 = *data;
-               int offset = 0, stralign;
+                gconstpointer data0 = *data;
+                int offset = 0, stralign;
         DBusMessageIter sub;
 
         stralign = dbind_find_c_alignment (*type);
@@ -243,14 +322,14 @@ dbind_any_marshal (DBusMessageIter *iter,
         offset = 0 ;
         while (**type != DBUS_STRUCT_END_CHAR) {
             char *subt = *type;
-                       offset = ALIGN_VALUE (offset, dbind_find_c_alignment (*type));
-                       *data = PTR_PLUS (data0, offset);
+                        offset = ALIGN_VALUE (offset, dbind_find_c_alignment (*type));
+                        *data = PTR_PLUS (data0, offset);
             dbind_any_marshal (&sub, type, data);
             offset += dbind_gather_alloc_info (subt);
         }
 
-               offset = ALIGN_VALUE (offset, stralign);
-               *data = PTR_PLUS (data0, offset);
+                offset = ALIGN_VALUE (offset, stralign);
+                *data = PTR_PLUS (data0, offset);
 
         dbus_message_iter_close_container (iter, &sub);
 
@@ -266,6 +345,73 @@ dbind_any_marshal (DBusMessageIter *iter,
     }
 }
 
+/*---------------------------------------------------------------------------*/
+
+void
+dbind_any_marshal_va (DBusMessageIter *iter,
+                      char           **arg_types,
+                      va_list          args)
+{
+    char *p = *arg_types;
+    {
+        /* special case base-types since we need to walk the stack worse-luck */
+        for (;*p != '\0' && *p != '=';) {
+            int intarg;
+            void *ptrarg;
+            double doublearg;
+            dbus_int64_t int64arg;
+            void *arg = NULL;
+
+            switch (*p) {
+            case DBUS_TYPE_BYTE:
+            case DBUS_TYPE_BOOLEAN:
+            case DBUS_TYPE_INT16:
+            case DBUS_TYPE_UINT16:
+            case DBUS_TYPE_INT32:
+            case DBUS_TYPE_UINT32:
+                intarg = va_arg (args, int);
+                arg = &intarg;
+                break;
+            case DBUS_TYPE_INT64:
+            case DBUS_TYPE_UINT64:
+                int64arg = va_arg (args, dbus_int64_t);
+                arg = &int64arg;
+                break;
+            case DBUS_TYPE_DOUBLE:
+                doublearg = va_arg (args, double);
+                arg = &doublearg;
+                break;
+            /* ptr types */
+            case DBUS_TYPE_STRING:
+            case DBUS_TYPE_OBJECT_PATH:
+            case DBUS_TYPE_SIGNATURE:
+            case DBUS_TYPE_ARRAY:
+            case DBUS_TYPE_DICT_ENTRY:
+                ptrarg = va_arg (args, void *);
+                arg = &ptrarg;
+                break;
+            case DBUS_STRUCT_BEGIN_CHAR:
+                ptrarg = va_arg (args, void *);
+                arg = ptrarg;
+                break;
+
+            case DBUS_TYPE_VARIANT:
+                fprintf (stderr, "No variant support yet - very toolkit specific\n");
+                ptrarg = va_arg (args, void *);
+                arg = &ptrarg;
+                break;
+            default:
+                fprintf (stderr, "Unknown / invalid arg type %c\n", *p);
+                break;
+            }
+            if (arg != NULL)
+                dbind_any_marshal (iter, &p, &arg);
+            }
+    }
+}
+
+/*---------------------------------------------------------------------------*/
+
 void
 dbind_any_demarshal (DBusMessageIter *iter,
                      char           **type,
@@ -305,13 +451,13 @@ dbind_any_demarshal (DBusMessageIter *iter,
 
         (*type)++;
         stored_child_type = *type;
-        
+
         elem_size = dbind_gather_alloc_info (*type);
         elem_align = dbind_find_c_alignment_r (type);
         vals = g_array_new (FALSE, FALSE, elem_size);
         (**(void ***)data) = vals;
         *data = ((guchar *)*data) + sizeof (void *);
-        
+
         i = 0;
         dbus_message_iter_recurse (iter, &child);
         while (dbus_message_iter_get_arg_type (&child) != DBUS_TYPE_INVALID) {
@@ -326,8 +472,8 @@ dbind_any_demarshal (DBusMessageIter *iter,
         break;
     }
     case DBUS_STRUCT_BEGIN_CHAR: {
-               gconstpointer data0 = *data;
-               int offset = 0, stralign;
+                gconstpointer data0 = *data;
+                int offset = 0, stralign;
         DBusMessageIter child;
 
         stralign = dbind_find_c_alignment (*type);
@@ -338,14 +484,14 @@ dbind_any_demarshal (DBusMessageIter *iter,
 
         while (**type != DBUS_STRUCT_END_CHAR) {
             char *subt = *type;
-                       offset = ALIGN_VALUE (offset, dbind_find_c_alignment (*type));
-                       *data = PTR_PLUS (data0, offset);
+                        offset = ALIGN_VALUE (offset, dbind_find_c_alignment (*type));
+                        *data = PTR_PLUS (data0, offset);
             dbind_any_demarshal (&child, type, data);
             offset += dbind_gather_alloc_info (subt);
         }
 
-               offset = ALIGN_VALUE (offset, stralign);
-               *data = PTR_PLUS (data0, offset);
+                offset = ALIGN_VALUE (offset, stralign);
+                *data = PTR_PLUS (data0, offset);
 
         g_assert (**type == DBUS_STRUCT_END_CHAR);
         (*type)++;
@@ -360,82 +506,22 @@ dbind_any_demarshal (DBusMessageIter *iter,
     dbus_message_iter_next (iter);
 }
 
-static void
-dbind_any_free_r (char **type, void **data)
-{
-    size_t len;
-
-#ifdef DEBUG
-    fprintf (stderr, "any free '%c' to %p\n", **type, *data);
-#endif
-
-    switch (**type) {
-    case DBIND_POD_CASES:
-        *data = ((guchar *)*data) + dbind_gather_alloc_info (*type);
-        (*type)++;
-        break;
-    case DBUS_TYPE_STRING:
-    case DBUS_TYPE_OBJECT_PATH:
-    case DBUS_TYPE_SIGNATURE:
-#ifdef DEBUG
-        fprintf (stderr, "string free %p\n", **(void ***)data);
-#endif
-        g_free (**(void ***)data);
-        *data = ((guchar *)*data) + dbind_gather_alloc_info (*type);
-        (*type)++;
-        break;
-    case DBUS_TYPE_ARRAY: {
-        int i;
-        GArray *vals = **(void ***)data;
-        size_t elem_size, elem_align;
-        char *saved_child_type, *child_type_string;
-
-        (*type)++;
-        saved_child_type = *type;
-
-        elem_size = dbind_gather_alloc_info (*type);
-        elem_align = dbind_find_c_alignment_r (type); 
-
-        for (i = 0; i < vals->len; i++) {
-            void *ptr = vals->data + elem_size * i;
-            *type = saved_child_type; /* rewind type info */
-            ptr = ALIGN_ADDRESS (ptr, elem_align);
-            dbind_any_free_r (type, &ptr);
-        }
-        g_array_free (vals, TRUE);
-        break;
-    }
-    case DBUS_STRUCT_BEGIN_CHAR: {
-               gconstpointer data0 = *data;
-               int offset = 0, stralign;
+/*---------------------------------------------------------------------------*/
 
-        stralign = dbind_find_c_alignment (*type);
-        (*type)++;
-
-        offset = 0 ;
-        while (**type != DBUS_STRUCT_END_CHAR) {
-            char *subt = *type;
-                       offset = ALIGN_VALUE (offset, dbind_find_c_alignment (*type));
-                       *data = PTR_PLUS (data0, offset);
-            dbind_any_free_r (type, data);
-            offset += dbind_gather_alloc_info (subt);
-        }
-
-               offset = ALIGN_VALUE (offset, stralign);
-               *data = PTR_PLUS (data0, offset);
-
-        g_assert (**type == DBUS_STRUCT_END_CHAR);
-        (*type)++;
-
-        break;
-    }
-    case DBUS_TYPE_STRUCT:
-    case DBUS_TYPE_DICT_ENTRY:
-        warn_braces ();
-        break;
+void
+dbind_any_demarshal_va (DBusMessageIter *iter,
+                        char           **arg_types,
+                        va_list          args)
+{
+    char *p = *arg_types;
+    for (;*p != '\0';) {
+        void *arg = va_arg (args, void *);
+        dbind_any_demarshal (iter, &p, &arg);
     }
 }
 
+/*---------------------------------------------------------------------------*/
+
 /* nice deep free ... */
 void
 dbind_any_free (char *type,
@@ -450,3 +536,13 @@ dbind_any_free_ptr (char *type, void *ptr)
 {
     dbind_any_free (type, &ptr);
 }
+
+/*---------------------------------------------------------------------------*/
+
+unsigned int
+dbind_find_c_alignment (char *type)
+{
+    return dbind_find_c_alignment_r (&type);
+}
+
+/*END------------------------------------------------------------------------*/
index ce6482e..975b244 100644 (file)
@@ -1,17 +1,30 @@
 #ifndef _DBIND_ANY_H_
 #define _DBIND_ANY_H_
 
+#define DBUS_API_SUBJECT_TO_CHANGE
 #include <dbus/dbus.h>
 
-size_t dbind_gather_alloc_info (char            *type);
+unsigned int dbind_find_c_alignment (char *type);
+
 void   dbind_any_marshal       (DBusMessageIter *iter,
                                 char           **type,
                                 void           **val);
+
+void   dbind_any_marshal_va    (DBusMessageIter *iter,
+                                char           **arg_types,
+                                va_list          args);
+
 void   dbind_any_demarshal     (DBusMessageIter *iter,
                                 char           **type,
                                 void           **val);
+
+void   dbind_any_demarshal_va  (DBusMessageIter *iter,
+                                char           **arg_types,
+                                va_list          args);
+
 void   dbind_any_free          (char            *type,
                                 void            *ptr_to_ptr);
+
 void   dbind_any_free_ptr      (char            *type,
                                 void            *ptr);
 
index 1bbf0b0..0103b4b 100644 (file)
-#include "config.h"
+
+
 #include <stdio.h>
-#define DBUS_API_SUBJECT_TO_CHANGE
-#include <dbind/dbind.h>
-#include <dbind/dbind-any.h>
-#include <glib.h>
 #include <stdarg.h>
+#include <glib.h>
+
+#include "config.h"
+#include "dbind/dbind.h"
 
 /*
  * FIXME: compare types - to ensure they match &
  *        do dynamic padding of structures etc.
  */
 
-struct _DBindContext {
-    DBusConnection *cnx;
-};
+/*---------------------------------------------------------------------------*/
 
-DBindContext *
-dbind_create_context (DBusBusType type, DBusError *opt_error)
+static void
+set_reply (DBusPendingCall *pending, void *user_data)
 {
-    DBindContext *ctx = NULL;
-    DBusConnection *cnx;
+    void **replyptr = (void **)user_data;
+
+    *replyptr = dbus_pending_call_steal_reply (pending);
+}
+
+static DBusMessage *
+send_and_allow_reentry (DBusConnection *bus, DBusMessage *message, DBusError *error)
+{
+    DBusPendingCall *pending;
+    DBusMessage *reply = NULL;
+
+    if (!dbus_connection_send_with_reply (bus, message, &pending, -1))
+    {
+        return NULL;
+    }
+    dbus_pending_call_set_notify (pending, set_reply, (void *)&reply, NULL);
+    while (!reply)
+    {
+      if (!dbus_connection_read_write_dispatch (bus, -1)) return NULL;
+    }
+    return reply;
+}
+
+dbus_bool_t
+dbind_method_call_reentrant_va (DBusConnection *cnx,
+                                const char     *bus_name,
+                                const char     *path,
+                                const char     *interface,
+                                const char     *method,
+                                DBusError      *opt_error,
+                                const char     *arg_types,
+                                va_list         args)
+{
+    dbus_bool_t success = FALSE;
+    DBusMessage *msg = NULL, *reply = NULL;
+    DBusMessageIter iter;
     DBusError *err, real_err;
-    
+    char *p;
+
     if (opt_error)
         err = opt_error;
     else {
         dbus_error_init (&real_err);
         err = &real_err;
     }
-   
-    cnx = dbus_bus_get (DBUS_BUS_SESSION, err);
-    if (!cnx)
-        goto out;
-
-    ctx = g_new0 (DBindContext, 1);
-    ctx->cnx = cnx;
 
-out:
-    if (err == &real_err)
-        dbus_error_free (err);
+    msg = dbus_message_new_method_call (bus_name, path, interface, method);
+    if (!msg)
+        goto out;
 
-    return ctx;
-}
+    p = arg_types;
+    dbus_message_iter_init (msg, &iter);
+    dbind_any_marshal_va (&iter, &p, args);
 
-void
-dbind_context_free (DBindContext *ctx)
-{
-    if (!ctx)
-        return;
-    dbus_connection_unref (ctx->cnx);
-    g_free (ctx);
-}
+    reply = send_and_allow_reentry (cnx, msg, err);
+    if (!reply)
+        goto out;
 
-dbus_bool_t
-dbind_context_method_call (DBindContext *ctx,
-                           const char *bus_name,
-                           const char *path,
-                           const char *interface,
-                           const char *method,
-                           DBusError *opt_error,
-                           const char *arg_types,
-                           ...)
-{
-    dbus_bool_t success;
-    va_list args;
+    if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR)
+    {
+      const char *name = dbus_message_get_error_name (reply);
+      dbus_set_error (err, name, g_strdup (""));
+      goto out;
+    }
+    /* demarshal */
+    if (p[0] == '=' && p[1] == '>')
+    {
+        DBusMessageIter iter;
+        p += 2;
+        dbus_message_iter_init (reply, &iter);
+        dbind_any_demarshal_va (&iter, &p, args);
+    }
 
-    va_start (args, arg_types);
+    success = TRUE;
+out:
+    if (msg)
+        dbus_message_unref (msg);
 
-    success = dbind_connection_method_call_va
-        (ctx->cnx, bus_name, path, interface, method, opt_error, arg_types, args);
+    if (reply)
+        dbus_message_unref (reply);
 
-    va_end (args);
+    if (err == &real_err)
+        dbus_error_free (err);
 
     return success;
 }
 
+/**
+ * dbind_method_call_reentrant:
+ *
+ * @cnx:       A D-Bus Connection used to make the method call.
+ * @bus_name:  The D-Bus bus name of the program where the method call should
+ *             be made.
+ * @path:      The D-Bus object path that should handle the method.
+ * @interface: The D-Bus interface used to scope the method name.
+ * @method:    Method to be invoked.
+ * @opt_error: D-Bus error.
+ * @arg_types: Variable length arguments interleaving D-Bus argument types
+ *             and pointers to argument data.
+ *
+ * Makes a D-Bus method call using the supplied location data, method name and
+ * argument data.This function is re-entrant. It continuously reads from the D-Bus
+ * bus and dispatches messages until a reply has been recieved.
+ **/
 dbus_bool_t
-dbind_connection_method_call (DBusConnection *cnx,
-                              const char *bus_name,
-                              const char *path,
-                              const char *interface,
-                              const char *method,
-                              DBusError *opt_error,
-                              const char *arg_types,
-                              ...)
+dbind_method_call_reentrant (DBusConnection *cnx,
+                             const char     *bus_name,
+                             const char     *path,
+                             const char     *interface,
+                             const char     *method,
+                             DBusError      *opt_error,
+                             const char     *arg_types,
+                             ...)
 {
-    dbus_bool_t success;
+    dbus_bool_t success = FALSE;
     va_list args;
 
     va_start (args, arg_types);
-
-    success = dbind_connection_method_call_va
-        (cnx, bus_name, path, interface, method, opt_error, arg_types, args);
-
+    success = dbind_method_call_reentrant_va (cnx,
+                                              bus_name,
+                                              path,
+                                              interface,
+                                              method,
+                                              opt_error,
+                                              arg_types,
+                                              args);
     va_end (args);
 
     return success;
 }
 
-static void set_reply (DBusPendingCall *pending, void *user_data)
-{
-  void **replyptr = (void **)user_data;
-
-  *replyptr = dbus_pending_call_steal_reply (pending);
-}
-
-static DBusMessage *
-send_and_allow_reentry (DBusConnection *bus, DBusMessage *message, int timeout, DBusError *error)
-{
-  DBusPendingCall *pending;
-  DBusMessage *reply = NULL;
-
-  if (!dbus_connection_send_with_reply (bus, message, &pending, timeout))
-  {
-    return NULL;
-  }
-  dbus_pending_call_set_notify (pending, set_reply, (void *)&reply, NULL);
-  while (!reply)
-  {
-    if (!dbus_connection_read_write_dispatch (bus, timeout)) return NULL;
-  }
-  return reply;
-}
-
+/*---------------------------------------------------------------------------*/
+
+/**
+ * dbind_emit_signal:
+ *
+ * @cnx:       A D-Bus Connection used to make the method call.
+ * @path:      The D-Bus object path that this signal is emitted from.
+ * @interface: The D-Bus interface used to scope the method name.
+ * @signal:    Name of signal to emit.
+ * @opt_error: D-Bus error.
+ * @arg_types: Variable length arguments interleaving D-Bus argument types
+ *             and pointers to argument data.
+ *
+ * Emits a D-Bus signal  using the supplied signal name and argument data.
+ **/
 dbus_bool_t
-dbind_connection_method_call_va (DBusConnection *cnx,
-                                 const char *bus_name,
-                                 const char *path,
-                                 const char *interface,
-                                 const char *method,
-                                 DBusError *opt_error,
-                                 const char *arg_types,
-                                 va_list     args)
+dbind_emit_signal (DBusConnection *cnx,
+                   const char     *path,
+                   const char     *interface,
+                   const char     *signal,
+                   DBusError      *opt_error,
+                   const char     *arg_types,
+                   ...)
 {
     dbus_bool_t success = FALSE;
-    DBusMessage *msg = NULL, *reply = NULL;
+    DBusMessage *msg = NULL;
+    DBusMessageIter iter;
     DBusError *err, real_err;
     char *p;
-    char *dest;
+    va_list args;
+
+    va_start (args, arg_types);
 
     if (opt_error)
         err = opt_error;
@@ -146,117 +188,27 @@ dbind_connection_method_call_va (DBusConnection *cnx,
         err = &real_err;
     }
 
-    msg = dbus_message_new_method_call (bus_name, path, interface, method);
+    msg = dbus_message_new_signal (path, interface, signal);
     if (!msg)
         goto out;
-    dbus_message_set_auto_start (msg, TRUE);
 
-    /* marshal */
-    p = (char *)arg_types;
-    {
-        DBusMessageIter iter;
-        
-        dbus_message_iter_init_append (msg, &iter);
-        /* special case base-types since we need to walk the stack worse-luck */
-        for (;*p != '\0' && *p != '=';) {
-            int intarg;
-            void *ptrarg;
-            double doublearg;
-            dbus_int64_t int64arg;
-            void *arg = NULL;
-
-            switch (*p) {
-            case DBUS_TYPE_BYTE:
-            case DBUS_TYPE_BOOLEAN:
-            case DBUS_TYPE_INT16:
-            case DBUS_TYPE_UINT16:
-            case DBUS_TYPE_INT32:
-            case DBUS_TYPE_UINT32:
-                intarg = va_arg (args, int);
-                arg = &intarg;
-                break;
-            case DBUS_TYPE_INT64:
-            case DBUS_TYPE_UINT64:
-                int64arg = va_arg (args, dbus_int64_t);
-                arg = &int64arg;
-                break;
-            case DBUS_TYPE_DOUBLE:
-                doublearg = va_arg (args, double);
-                arg = &doublearg;
-                break;
-            /* ptr types */
-            case DBUS_TYPE_STRING:
-            case DBUS_TYPE_OBJECT_PATH:
-            case DBUS_TYPE_SIGNATURE:
-            case DBUS_TYPE_ARRAY:
-            case DBUS_TYPE_DICT_ENTRY:
-                ptrarg = va_arg (args, void *);
-                arg = &ptrarg;
-                break;
-            case DBUS_STRUCT_BEGIN_CHAR:
-                ptrarg = va_arg (args, void *);
-                arg = ptrarg;
-                break;
-
-            case DBUS_TYPE_VARIANT:
-                fprintf (stderr, "No variant support yet - very toolkit specific\n");
-                ptrarg = va_arg (args, void *);
-                arg = &ptrarg;
-                break;
-            default:
-                fprintf (stderr, "Unknown / invalid arg type %c\n", *p);
-                break;
-            }
-            if (arg != NULL)
-                dbind_any_marshal (&iter, &p, &arg);
-            }
-    }
+    dbus_message_iter_init (msg, &iter);
+    dbind_any_marshal_va (&iter, &p, args);
 
-    dest = dbus_message_get_destination(msg);
-    if (!dest)
-        goto out;
-    if (!strcmp (dbus_bus_get_unique_name(cnx), dest))
-    {
-      /* Can't use dbus_message_send_with_reply_and_block because it will
-       * not pass messages on to the provider side, causing deadlock */
-      reply = send_and_allow_reentry (cnx, msg, -1, err);
-    }
-    else
-    {
-      reply = dbus_connection_send_with_reply_and_block (cnx, msg, -1, err);
-    }
-    if (!reply)
-        goto out;
-
-    if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR)
-    {
-      char *name = dbus_message_get_error_name (reply);
-      dbus_set_error (err, name, g_strdup (""));
-      goto out;
-    }
-    /* demarshal */
-    if (p[0] == '=' && p[1] == '>')
-    {
-        DBusMessageIter iter;
-        p += 2;
-        dbus_message_iter_init (reply, &iter);
-        for (;*p != '\0';) {
-            void *arg = va_arg (args, void *);
-            dbind_any_demarshal (&iter, &p, &arg);
-        }
-    }
+    if (!dbus_connection_send (cnx, msg, NULL))
+       goto out;
 
     success = TRUE;
 out:
+    va_end (args);
+
     if (msg)
         dbus_message_unref (msg);
 
-    if (reply)
-        dbus_message_unref (reply);
-
     if (err == &real_err)
         dbus_error_free (err);
 
     return success;
 }
 
+/*END------------------------------------------------------------------------*/
index 4e66359..c3e1d56 100644 (file)
@@ -1,39 +1,37 @@
 #ifndef _DBIND_H_
 #define _DBIND_H_
 
-
 #define DBUS_API_SUBJECT_TO_CHANGE
 #include <dbus/dbus.h>
+#include <dbind/dbind-any.h>
 
-typedef struct _DBindContext DBindContext;
+dbus_bool_t
+dbind_method_call_reentrant_va (DBusConnection *cnx,
+                                const char     *bus_name,
+                                const char     *path,
+                                const char     *interface,
+                                const char     *method,
+                                DBusError      *opt_error,
+                                const char     *arg_types,
+                                va_list         args);
 
-DBindContext *dbind_create_context         (DBusBusType type, DBusError *opt_error);
-void          dbind_context_free           (DBindContext *ctx);
-dbus_bool_t   dbind_context_method_call    (DBindContext *ctx,
-                                            const char *bus_name,
-                                            const char *path,
-                                            const char *interface,
-                                            const char *method,
-                                            DBusError *opt_error,
-                                            const char *arg_types,
-                                            ...);
+dbus_bool_t
+dbind_method_call_reentrant (DBusConnection *cnx,
+                             const char     *bus_name,
+                             const char     *path,
+                             const char     *interface,
+                             const char     *method,
+                             DBusError      *opt_error,
+                             const char     *arg_types,
+                             ...);
 
-/* dbus connection variants */
-dbus_bool_t   dbind_connection_method_call    (DBusConnection *cnx,
-                                               const char *bus_name,
-                                               const char *path,
-                                               const char *interface,
-                                               const char *method,
-                                               DBusError *opt_error,
-                                               const char *arg_types,
-                                               ...);
-dbus_bool_t   dbind_connection_method_call_va (DBusConnection *cnx,
-                                               const char *bus_name,
-                                               const char *path,
-                                               const char *interface,
-                                               const char *method,
-                                               DBusError *opt_error,
-                                               const char *arg_types,
-                                               va_list     args);
+dbus_bool_t
+dbind_emit_signal (DBusConnection *cnx,
+                   const char     *path,
+                   const char     *interface,
+                   const char     *signal,
+                   DBusError      *opt_error,
+                   const char     *arg_types,
+                   ...);
 
 #endif /* _DBIND_H_ */
index 9a3ae86..8203c27 100644 (file)
@@ -1,9 +1,7 @@
 #include <stdio.h>
 #include <glib.h>
 #include <string.h>
-#define DBUS_API_SUBJECT_TO_CHANGE
 #include <dbind/dbind.h>
-#include <dbind/dbind-any.h>
 
 /* Wow! dbus is unpleasant to use */
 
@@ -341,7 +339,7 @@ void test_marshalling ()
     fprintf (stderr, "Marshalling ok\n");
 }
 
-void test_teamspaces (DBindContext *ctx)
+void test_teamspaces (DBusConnection *bus)
 {
     GArray *spaces;
     DBusError error;
@@ -353,9 +351,14 @@ void test_teamspaces (DBindContext *ctx)
     } TeamSpace;
 
     dbus_error_init (&error);
-    if (!dbind_context_method_call (ctx, NULL, DESKICE_PATH, DESKICE_NAMESPACE,
-                                    "GetTeamList", &error,
-                                    "=>a(sss)", &spaces)) {
+    if (!dbind_method_call_reentrant (bus,
+                                      NULL,
+                                      DESKICE_PATH,
+                                      DESKICE_NAMESPACE,
+                                      "GetTeamList",
+                                      &error,
+                                      "=>a(sss)",
+                                      &spaces)) {
         fprintf (stderr, "Error getting team spaces %s: %s\n",
                  error.name, error.message);
         dbus_error_free (&error);
@@ -375,8 +378,6 @@ void test_teamspaces (DBindContext *ctx)
     dbind_any_free_ptr ("a(sss)", spaces);
 }
 
-extern dbind_find_c_alignment (char *type);
-
 void test_helpers ()
 {
     dbind_find_c_alignment ("(sss)");
@@ -387,17 +388,14 @@ void test_helpers ()
 
 int main (int argc, char **argv)
 {
-    DBindContext *ctx;
+    DBusConnection *bus;
+    DBusError err;
 
-    ctx = dbind_create_context (DBUS_BUS_SESSION, NULL);
-    if (!ctx)
-        return 1;
+    bus = dbus_bus_get (DBUS_BUS_SESSION, &err);
 
     test_helpers ();
     test_marshalling ();
-    test_teamspaces (ctx);
-
-    dbind_context_free (ctx);
+    test_teamspaces (bus);
 
     return 0;
 }
index 2071b8f..9ce04f1 100644 (file)
@@ -1,12 +1,34 @@
 noinst_LTLIBRARIES = libdroute.la
 
-libdroute_la_CFLAGS = $(DBUS_GLIB_CFLAGS) $(ATK_CFLAGS)\
-                    -DATSPI_INTROSPECTION_PATH=\"$(pkgdatadir)/$(DEFAULT_ATSPI_INTROSPECTION_PATH)\"\
-                    -I$(top_builddir)\
-                    -I$(top_srcdir)
-
-libdroute_la_SOURCES =         \
-       droute.c                \
-       droute.h                \
-       introspect-loader.c     \
-       introspect-loader.h
+libdroute_la_CFLAGS = $(DBUS_GLIB_CFLAGS) \
+                      -DATSPI_INTROSPECTION_PATH=\"$(pkgdatadir)/$(DEFAULT_ATSPI_INTROSPECTION_PATH)\"\
+                      -I$(top_builddir)\
+                      -I$(top_srcdir)
+
+libdrouteinclude_HEADERS = \
+               droute.h
+               droute-variant.h
+libdrouteincludedir=$(includedir)/dbind-0.1
+
+libdroute_la_SOURCES =\
+               droute.c\
+               droute.h\
+               droute-variant.c\
+               droute-variant.h\
+               droute-pairhash.c\
+               droute-pairhash.h
+
+TESTS = droute-test
+
+droute_test_CFLAGS = $(DBUS_GLIB_CFLAGS) \
+                     -I$(top_builddir)
+
+check_PROGRAMS = droute-test
+droute_test_SOURCES  = droute-test.c
+droute_test_CPPFLAGS = $(DBUS_GLIB_CFLAGS) \
+                      -I$(top_builddir)\
+                      -DTEST_INTROSPECTION_DIRECTORY=\"$(top_srcdir)/droute\"
+
+droute_test_LDFLAGS  = $(top_builddir)/dbind/libdbind.la\
+                      libdroute.la\
+                      $(DBUS_GLIB_LIBS)
diff --git a/droute/droute-pairhash.c b/droute/droute-pairhash.c
new file mode 100644 (file)
index 0000000..0c4ace5
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2008 Codethink Ltd.
+ *
+ * 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 "droute-pairhash.h"
+
+/*---------------------------------------------------------------------------*/
+
+static guint
+str_hash (guint32 h, const signed char *p)
+{
+  for (p += 1; *p != '\0'; p++)
+      h = (h << 5) - h + *p;
+
+  return h;
+}
+
+/*---------------------------------------------------------------------------*/
+
+StrPair *
+str_pair_new (const gchar *one, const gchar *two)
+{
+    StrPair *pair;
+
+    pair = g_new (StrPair, 1);
+    pair->one = one;
+    pair->two = two;
+    return pair;
+}
+
+gint
+str_pair_hash (gconstpointer key)
+{
+    StrPair *pair = (StrPair *) key;
+    guint hash = 0;
+
+    /*g_return_val_if_fail (pair      != NULL, 0);
+    g_return_val_if_fail (pair->one != NULL, 0);
+    g_return_val_if_fail (pair->two != NULL, 0);
+    */
+
+    if (*(pair->two) != '\0')
+      {
+        hash = *(pair->two);
+        hash = str_hash (hash, ++(pair->two));
+        hash = str_hash (hash, pair->one);
+      }
+
+    return hash;
+}
+
+gboolean
+str_pair_equal (gconstpointer a, gconstpointer b)
+{
+    StrPair *ap = (StrPair *) a;
+    StrPair *bp = (StrPair *) b;
+
+    if (g_str_equal (ap->one, bp->one) &&
+        g_str_equal (ap->two, bp->two))
+      {
+        return TRUE;
+      }
+    else
+      {
+        return FALSE;
+      }
+}
+
+/*END------------------------------------------------------------------------*/
similarity index 69%
rename from droute/introspect-loader.h
rename to droute/droute-pairhash.h
index bfea0b7..50d4b34 100644 (file)
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  */
-
-#ifndef SPI_INTROSPECT_LOADER_H_
-#define SPI_INTROSPECT_LOADER_H_
+#ifndef _DROUTE_PAIRHASH_H
+#define _DROUTE_PAIRHASH_H
 
 #include <glib.h>
 
-extern const char *spi_introspection_header;
-
-extern const char *spi_introspection_node_element;
+typedef struct _StrPair StrPair;
+struct _StrPair
+{
+    const gchar *one;
+    const gchar *two;
+};
 
-extern const char *spi_introspection_footer;
+StrPair *str_pair_new     (const gchar *one,
+                           const gchar *two);
 
-void
-spi_append_interface (GString *str, const char *interface);
+gint     str_pair_hash    (gconstpointer key);
+gboolean str_pair_equal   (gconstpointer a,
+                           gconstpointer b);
 
-#endif /* SPI_INTROSPECT_LOADER_H_ */
+#endif /* _DROUTE_PAIRHASH_H */
diff --git a/droute/droute-test.c b/droute/droute-test.c
new file mode 100644 (file)
index 0000000..1895fb6
--- /dev/null
@@ -0,0 +1,246 @@
+#include <stdio.h>
+#include <glib.h>
+#include <string.h>
+#include <droute/droute.h>
+
+#include "dbus/dbus-glib-lowlevel.h"
+
+#define TEST_OBJECT_PATH    "/test/object"
+#define TEST_INTERFACE_ONE  "test.interface.One"
+#define TEST_INTERFACE_TWO  "test.interface.Two"
+
+#define OBJECT_ONE "ObjectOne";
+#define OBJECT_TWO "ObjectTwo";
+
+#if !defined TEST_INTROSPECTION_DIRECTORY
+    #error "No introspection XML directory defined"
+#endif
+
+#define STRING_ONE "StringOne"
+#define STRING_TWO "StringTwo"
+
+#define INT_ONE 0
+#define INT_TWO 456
+
+#define NONE_REPLY_STRING "NoneMethod"
+
+typedef struct _AnObject
+{
+    gchar *astring;
+    guint *anint;
+} AnObject;
+
+static DBusConnection *bus;
+static GMainLoop      *main_loop;
+static gboolean       success = TRUE;
+
+static DBusMessage *
+impl_null (DBusConnection *bus, DBusMessage *message, void *user_data)
+{
+    AnObject    *object = (AnObject *) user_data;
+    DBusMessage *reply;
+    DBusError    error;
+
+    reply = dbus_message_new_method_return (message);
+    return reply;
+}
+
+static DBusMessage *
+impl_getInt (DBusConnection *bus, DBusMessage *message, void *user_data)
+{
+    AnObject    *object = (AnObject *) user_data;
+    DBusMessage *reply;
+    DBusError    error;
+
+    dbus_error_init (&error);
+
+    reply = dbus_message_new_method_return (message);
+    dbus_message_append_args (reply, DBUS_TYPE_INT32, &(object->anint), DBUS_TYPE_INVALID);
+    return reply;
+}
+
+static DBusMessage *
+impl_setInt (DBusConnection *bus, DBusMessage *message, void *user_data)
+{
+    AnObject    *object = (AnObject *) user_data;
+    DBusMessage *reply;
+    DBusError    error;
+
+    dbus_error_init (&error);
+
+    dbus_message_get_args (message, &error, DBUS_TYPE_INT32, &(object->anint), DBUS_TYPE_INVALID);
+
+    reply = dbus_message_new_method_return (message);
+    return reply;
+}
+
+static DBusMessage *
+impl_getString (DBusConnection *bus, DBusMessage *message, void *user_data)
+{
+    AnObject    *object = (AnObject *) user_data;
+    DBusMessage *reply;
+    DBusError    error;
+
+    dbus_error_init (&error);
+
+    reply = dbus_message_new_method_return (message);
+    dbus_message_append_args (reply, DBUS_TYPE_STRING, &(object->astring), DBUS_TYPE_INVALID);
+    return reply;
+}
+
+static DBusMessage *
+impl_setString (DBusConnection *bus, DBusMessage *message, void *user_data)
+{
+    AnObject    *object = (AnObject *) user_data;
+    DBusMessage *reply;
+    DBusError    error;
+
+    dbus_error_init (&error);
+
+    g_free (object->astring);
+    dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &(object->astring), DBUS_TYPE_INVALID);
+
+    reply = dbus_message_new_method_return (message);
+    return reply;
+}
+
+static DBusMessage *
+impl_getInterfaceOne (DBusConnection *bus, DBusMessage *message, void *user_data)
+{
+    AnObject    *object = (AnObject *) user_data;
+    DBusMessage *reply;
+    DBusError    error;
+    gchar       *itf = TEST_INTERFACE_ONE;
+
+    dbus_error_init (&error);
+
+    reply = dbus_message_new_method_return (message);
+    dbus_message_append_args (reply, DBUS_TYPE_STRING, &itf, DBUS_TYPE_INVALID);
+    return reply;
+}
+
+static DBusMessage *
+impl_getInterfaceTwo (DBusConnection *bus, DBusMessage *message, void *user_data)
+{
+    AnObject    *object = (AnObject *) user_data;
+    DBusMessage *reply;
+    DBusError    error;
+    gchar       *itf = TEST_INTERFACE_TWO;
+
+    dbus_error_init (&error);
+
+    reply = dbus_message_new_method_return (message);
+    dbus_message_append_args (reply, DBUS_TYPE_STRING, &itf, DBUS_TYPE_INVALID);
+    return reply;
+}
+
+static DRouteMethod test_methods_one[] = {
+    {impl_null,            "null"},
+    {impl_getInt,          "getInt"},
+    {impl_setInt,          "setInt"},
+    {impl_getString,       "getString"},
+    {impl_setString,       "setString"},
+    {impl_getInterfaceOne, "getInterfaceOne"},
+    {NULL, NULL}
+};
+
+static DRouteMethod test_methods_two[] = {
+    {impl_null,            "null"},
+    {impl_getInt,          "getInt"},
+    {impl_setInt,          "setInt"},
+    {impl_getString,       "getString"},
+    {impl_setString,       "setString"},
+    {impl_getInterfaceTwo, "getInterfaceTwo"},
+    {NULL, NULL}
+};
+
+static DRouteProperty test_properties[] = {
+    {NULL, NULL, NULL}
+};
+
+gboolean
+do_tests_func (gpointer data)
+{
+    DBusError  error;
+    gchar     *bus_name;
+
+    gchar     *expected_string;
+    gchar     *result_string;
+
+    dbus_error_init (&error);
+    bus_name = dbus_bus_get_unique_name (bus);
+
+    /* --------------------------------------------------------*/
+
+    dbind_method_call_reentrant (bus,
+                                 bus_name,
+                                 TEST_OBJECT_PATH,
+                                 TEST_INTERFACE_ONE,
+                                 "null",
+                                 NULL,
+                                 "");
+
+    /* --------------------------------------------------------*/
+
+    expected_string = TEST_INTERFACE_ONE;
+    result_string = NULL;
+    dbind_method_call_reentrant (bus,
+                                 bus_name,
+                                 TEST_OBJECT_PATH,
+                                 TEST_INTERFACE_ONE,
+                                 "getInterfaceOne",
+                                 NULL,
+                                 "=>s",
+                                 &result_string);
+    if (g_strcmp0(expected_string, result_string))
+    {
+            g_print ("Failed: reply to getInterfaceOne not as expected\n");
+            goto out;
+    }
+
+    /* --------------------------------------------------------*/
+
+out:
+    g_main_loop_quit (main_loop);
+    return FALSE;
+}
+
+
+int main (int argc, char **argv)
+{
+    DRouteContext  *cnx;
+    DRoutePath     *path;
+    AnObject       *object;
+    DBusError       error;
+
+    /* Setup some server object */
+
+    object = g_new0(AnObject, 1);
+    object->astring = g_strdup (STRING_ONE);
+    object->anint = INT_ONE;
+
+    dbus_error_init (&error);
+    main_loop = g_main_loop_new(NULL, FALSE);
+    bus = dbus_bus_get (DBUS_BUS_SESSION, &error);
+    dbus_connection_setup_with_g_main(bus, g_main_context_default());
+
+    cnx = droute_new (bus, TEST_INTROSPECTION_DIRECTORY);
+    path = droute_add_one (cnx, TEST_OBJECT_PATH, object);
+
+    droute_path_add_interface (path,
+                               TEST_INTERFACE_ONE,
+                               test_methods_one,
+                               test_properties);
+
+    droute_path_add_interface (path,
+                               TEST_INTERFACE_TWO,
+                               test_methods_two,
+                               test_properties);
+
+    g_idle_add (do_tests_func, NULL);
+    g_main_run(main_loop);
+    if (success)
+            return 0;
+    else
+            return 1;
+}
diff --git a/droute/droute-variant.c b/droute/droute-variant.c
new file mode 100644 (file)
index 0000000..d4b5ca6
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2008 Novell, 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 <stdlib.h>
+#include <string.h>
+
+#include "droute-variant.h"
+
+/*---------------------------------------------------------------------------*/
+
+dbus_bool_t
+droute_return_v_int32 (DBusMessageIter *iter, dbus_int32_t val)
+{
+    DBusMessageIter sub;
+
+    if (!dbus_message_iter_open_container
+        (iter, DBUS_TYPE_VARIANT, DBUS_TYPE_INT32_AS_STRING, &sub))
+      {
+        return FALSE;
+      }
+    dbus_message_iter_append_basic (&sub, DBUS_TYPE_INT32, &val);
+    dbus_message_iter_close_container (iter, &sub);
+    return TRUE;
+}
+
+dbus_bool_t
+droute_return_v_double (DBusMessageIter *iter, double val)
+{
+    DBusMessageIter sub;
+
+    if (!dbus_message_iter_open_container
+        (iter, DBUS_TYPE_VARIANT, DBUS_TYPE_DOUBLE_AS_STRING, &sub))
+      {
+        return FALSE;
+      }
+    dbus_message_iter_append_basic (&sub, DBUS_TYPE_DOUBLE, &val);
+    dbus_message_iter_close_container (iter, &sub);
+    return TRUE;
+}
+
+dbus_bool_t
+droute_return_v_string (DBusMessageIter *iter, const char *val)
+{
+    DBusMessageIter sub;
+
+    if (!val)
+      val = "";
+    if (!dbus_message_iter_open_container
+        (iter, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &sub))
+      {
+        return FALSE;
+      }
+    dbus_message_iter_append_basic (&sub, DBUS_TYPE_STRING, &val);
+    dbus_message_iter_close_container (iter, &sub);
+    return TRUE;
+}
+
+dbus_bool_t
+droute_return_v_object (DBusMessageIter *iter, const char *path)
+{
+    DBusMessageIter sub;
+
+    if (!dbus_message_iter_open_container
+        (iter, DBUS_TYPE_VARIANT, DBUS_TYPE_OBJECT_PATH_AS_STRING, &sub))
+      {
+        return FALSE;
+      }
+    dbus_message_iter_append_basic (&sub, DBUS_TYPE_OBJECT_PATH, &path);
+    dbus_message_iter_close_container (iter, &sub);
+    return TRUE;
+}
+
+/*---------------------------------------------------------------------------*/
+
+dbus_int32_t
+droute_get_v_int32 (DBusMessageIter *iter)
+{
+    DBusMessageIter sub;
+    dbus_int32_t rv;
+
+    // TODO- ensure we have the correct type
+    dbus_message_iter_recurse (iter, &sub);
+    dbus_message_iter_get_basic (&sub, &rv);
+    return rv;
+}
+
+const char *
+droute_get_v_string (DBusMessageIter *iter)
+{
+    DBusMessageIter sub;
+    char *rv;
+
+    // TODO- ensure we have the correct type
+    dbus_message_iter_recurse (iter, &sub);
+    dbus_message_iter_get_basic (&sub, &rv);
+    return rv;
+}
+
+/*END------------------------------------------------------------------------*/
similarity index 56%
rename from atk-adaptor/matchrule.c
rename to droute/droute-variant.h
index c62b8bd..47feb96 100644 (file)
@@ -2,7 +2,7 @@
  * AT-SPI - Assistive Technology Service Provider Interface
  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
  *
- * Copyright 2007 IBM Corp.
+ * Copyright 2008 Novell, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  */
+#ifndef _DROUTE_VARIANT_H
+#define _DROUTE_VARIANT_H
 
-/* matchrule.c: implements the Matchrule interface */
+#include <dbus/dbus.h>
 
+dbus_bool_t  droute_return_v_int32  (DBusMessageIter *iter, dbus_int32_t val);
+dbus_bool_t  droute_return_v_double (DBusMessageIter *iter, double val);
+dbus_bool_t  droute_return_v_string (DBusMessageIter *iter, const char *val);
+dbus_bool_t  droute_return_v_object (DBusMessageIter *iter, const char *path);
 
-#include <config.h>
-#include <stdio.h>
-#include <bonobo/bonobo-exception.h>
-#include <libspi/matchrule.h> 
-#include <libspi/spi-private.h>
-
-SpiMatchrule *
-spi_matchrule_interface_new ()
-{
-
-     SpiMatchrule *new_matchrule = g_object_new (SPI_MATCHRULE_TYPE, NULL);
-
-     spi_base_construct_default (SPI_BASE (new_matchrule));
-
-     return new_matchrule;
-
-}
-
-static void
-spi_matchrule_class_init (SpiMatchruleClass *klass)
-{
-}
-
-static void
-spi_matchrule_init (SpiMatchrule *matchrule)
-{
-}
-
-BONOBO_TYPE_FUNC_FULL (SpiMatchrule,
-                     Accessibility_MatchRule,
-                     SPI_TYPE_BASE,
-                     spi_matchrule)
-
+dbus_int32_t droute_get_v_int32     (DBusMessageIter *iter);
+const char  *droute_get_v_string    (DBusMessageIter *iter);
 
+#endif /* _DROUTE_VARIANT_H */
index e4c1f91..06ec2bd 100644 (file)
@@ -3,6 +3,7 @@
  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
  *
  * Copyright 2008 Novell, Inc.
+ * Copyright 2008 Codethink Ltd.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 #include <string.h>
 
 #include "droute.h"
+#include "droute-pairhash.h"
 
-static DRouteInterface *
-find_iface (DRouteData * data, const char *name)
+#define CHUNKS_DEFAULT (512)
+
+#define oom() g_error ("D-Bus out of memory, this message will fail anyway")
+
+#if defined DROUTE_DEBUG
+    #define _DROUTE_DEBUG(format, args...) g_print (format , ## args)
+#else
+    #define _DROUTE_DEBUG
+#endif
+
+struct _DRouteContext
 {
-  GSList *l;
-
-  for (l = data->interfaces; l; l = g_slist_next (l))
-    {
-      DRouteInterface *iface = (DRouteInterface *) l->data;
-      if (iface && iface->name && !strcmp (iface->name, name))
-       return iface;
-    }
-  return NULL;
-}
+    DBusConnection       *bus;
+    GPtrArray            *registered_paths;
+
+    gchar                *introspect_dir;
+};
+
+struct _DRoutePath
+{
+    DRouteContext        *cnx;
+    GStringChunk         *chunks;
+    GPtrArray            *interfaces;
+    GHashTable           *methods;
+    GHashTable           *properties;
+
+    void                   *user_data;
+    DRouteGetDatumFunction  get_datum;
+};
+
+/*---------------------------------------------------------------------------*/
+
+typedef struct PropertyPair
+{
+    DRoutePropertyFunction get;
+    DRoutePropertyFunction set;
+} PropertyPair;
+
+/*---------------------------------------------------------------------------*/
 
 static DBusHandlerResult
-prop_get_all (DBusConnection * bus, DBusMessage * message, DRouteData * data)
+handle_message (DBusConnection *bus, DBusMessage *message, void *user_data);
+
+/*---------------------------------------------------------------------------*/
+
+static DRoutePath *
+path_new (DRouteContext *cnx,
+          void    *user_data,
+          DRouteGetDatumFunction get_datum)
+{
+    DRoutePath *new_path;
+
+    new_path = g_new0 (DRoutePath, 1);
+    new_path->cnx = cnx;
+    new_path->chunks = g_string_chunk_new (CHUNKS_DEFAULT);
+    new_path->interfaces = g_ptr_array_new ();
+
+    new_path->methods = g_hash_table_new_full ((GHashFunc)str_pair_hash,
+                                               str_pair_equal,
+                                               g_free,
+                                               NULL);
+
+    new_path->properties = g_hash_table_new_full ((GHashFunc)str_pair_hash,
+                                                  str_pair_equal,
+                                                  g_free,
+                                                  NULL);
+
+    new_path->user_data = user_data;
+    new_path->get_datum = get_datum;
+
+    return new_path;
+}
+
+static void
+path_free (DRoutePath *path, gpointer user_data)
+{
+    g_string_chunk_free  (path->chunks);
+    g_ptr_array_free     (path->interfaces, TRUE);
+    g_hash_table_destroy (path->methods);
+    g_hash_table_destroy (path->properties);
+}
+
+static void *
+path_get_datum (DRoutePath *path, const gchar *pathstr)
+{
+    if (path->get_datum != NULL)
+        return (path->get_datum) (pathstr, path->user_data);
+    else
+        return path->user_data;
+}
+
+/*---------------------------------------------------------------------------*/
+
+DRouteContext *
+droute_new (DBusConnection *bus, const char *introspect_dir)
 {
-  DRouteInterface *iface_def;
-  DRouteProperty *prop;
-  DBusError error;
-  const char *iface;
-  const char *path = dbus_message_get_path (message);
-  DBusMessage *reply;
-  DBusMessageIter iter, iter_dict, iter_dict_entry;
-
-  dbus_error_init (&error);
-  if (!dbus_message_get_args
-      (message, &error, DBUS_TYPE_STRING, &iface, DBUS_TYPE_INVALID))
-    {
-      return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-    }
-  reply = dbus_message_new_method_return (message);
-  /* tbd: replace tbd with todo? */
-  if (!reply)
-    goto oom;
-  dbus_message_iter_init_append (reply, &iter);
-  if (!dbus_message_iter_open_container
-      (&iter, DBUS_TYPE_ARRAY, "{sv}", &iter_dict))
-    goto oom;
-  iface_def = find_iface (data, iface);
-  if (!iface_def)
-    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-  if (iface_def->properties)
-    for (prop = iface_def->properties; prop->name; prop++)
+    DRouteContext *cnx;
+
+    cnx = g_new0 (DRouteContext, 1);
+    cnx->bus = bus;
+    cnx->registered_paths = g_ptr_array_new ();
+    cnx->introspect_dir = g_strdup(introspect_dir);
+}
+
+void
+droute_free (DRouteContext *cnx)
+{
+    g_ptr_array_foreach (cnx->registered_paths, (GFunc) path_free, NULL);
+    g_free (cnx->introspect_dir);
+    g_free (cnx);
+}
+
+/*---------------------------------------------------------------------------*/
+
+DBusConnection *
+droute_get_bus (DRouteContext *cnx)
+{
+    return cnx->bus;
+}
+
+/*---------------------------------------------------------------------------*/
+
+static DBusObjectPathVTable droute_vtable =
+{
+  NULL,
+  &handle_message,
+  NULL, NULL, NULL, NULL
+};
+
+DRoutePath *
+droute_add_one (DRouteContext *cnx,
+                const char    *path,
+                const void    *data)
+{
+    DRoutePath *new_path;
+
+    new_path = path_new (cnx, (void *) data, NULL);
+
+    if (!dbus_connection_register_object_path (cnx->bus, path, &droute_vtable, new_path))
+        oom();
+
+    g_ptr_array_add (cnx->registered_paths, new_path);
+    return new_path;
+}
+
+DRoutePath *
+droute_add_many (DRouteContext *cnx,
+                 const char    *path,
+                 const void    *data,
+                 const DRouteGetDatumFunction get_datum)
+{
+    DRoutePath *new_path;
+
+    new_path = path_new (cnx, (void *) data, get_datum);
+
+    if (!dbus_connection_register_fallback (cnx->bus, path, &droute_vtable, new_path))
+        oom();
+
+    g_ptr_array_add (cnx->registered_paths, new_path);
+    return new_path;
+}
+
+/*---------------------------------------------------------------------------*/
+
+void
+droute_path_add_interface(DRoutePath *path,
+                          const char *name,
+                          const DRouteMethod   *methods,
+                          const DRouteProperty *properties)
+{
+    gchar *itf;
+
+    g_return_if_fail (name != NULL);
+
+    itf = g_string_chunk_insert (path->chunks, name);
+    g_ptr_array_add (path->interfaces, itf);
+
+    for (; methods != NULL && methods->name != NULL; methods++)
       {
-       if (!prop->get)
-         continue;
-       if (!dbus_message_iter_open_container
-           (&iter_dict, DBUS_TYPE_DICT_ENTRY, NULL, &iter_dict_entry))
-         goto oom;
-       dbus_message_iter_append_basic (&iter_dict_entry, DBUS_TYPE_STRING,
-                                       &prop->name);
-       (*prop->get) (path, &iter_dict_entry, data->user_data);
-       if (!dbus_message_iter_close_container (&iter_dict, &iter_dict_entry))
-         goto oom;
+        gchar *meth;
+
+        meth = g_string_chunk_insert (path->chunks, methods->name);
+        g_hash_table_insert (path->methods, str_pair_new (itf, meth), methods->func);
+      }
+
+    for (; properties != NULL && properties->name != NULL; properties++)
+      {
+        gchar *prop;
+        PropertyPair *pair;
+
+        prop = g_string_chunk_insert (path->chunks, properties->name);
+        pair = g_new (PropertyPair, 1);
+        pair->get = properties->get;
+        pair->set = properties->set;
+        g_hash_table_insert (path->properties, str_pair_new (itf, prop), pair);
       }
-  if (!dbus_message_iter_close_container (&iter, &iter_dict))
-    goto oom;
-  dbus_connection_send (bus, reply, NULL);
-  dbus_message_unref (reply);
-  return DBUS_HANDLER_RESULT_HANDLED;
-oom:
-  /* tbd: return a standard out-of-memory error */
-  return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 }
 
-static DBusHandlerResult
-prop (DBusConnection * bus, DBusMessage * message, DRouteData * data)
+/*---------------------------------------------------------------------------*/
+
+/* The data structures don't support an efficient implementation of GetAll
+ * and I don't really care.
+ */
+static DBusMessage *
+impl_prop_GetAll (DBusMessage *message,
+                  DRoutePath  *path,
+                  const char  *pathstr)
 {
-  const char *mode = dbus_message_get_member (message);
-  const char *iface, *member;
-  const char *path = dbus_message_get_path (message);
-  int set;
-  DBusMessage *reply;
-  DBusMessageIter iter;
-  DRouteInterface *iface_def;
-  DRouteProperty *prop = NULL;
-
-  if (!strcmp (mode, "Set"))
-    set = 1;
-  else if (!strcmp (mode, "Get"))
-    set = 0;
-  else
-    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-  reply = dbus_message_new_method_return (message);
-  dbus_message_iter_init (message, &iter);
-  dbus_message_iter_get_basic (&iter, &iface);
-  dbus_message_iter_next (&iter);
-  dbus_message_iter_get_basic (&iter, &member);
-  if (!set)
+    DBusMessageIter iter, iter_dict, iter_dict_entry;
+    DBusMessage *reply;
+    DBusError error;
+    GHashTableIter prop_iter;
+
+    StrPair *key;
+    PropertyPair *value;
+    gchar *iface;
+
+    void  *datum = path_get_datum (path, pathstr);
+
+    dbus_error_init (&error);
+    if (!dbus_message_get_args
+                (message, &error, DBUS_TYPE_STRING, &iface, DBUS_TYPE_INVALID))
+        return dbus_message_new_error (message, DBUS_ERROR_FAILED, error.message);
+
+    reply = dbus_message_new_method_return (message);
+    if (!reply)
+        oom ();
+
     dbus_message_iter_init_append (reply, &iter);
-  iface_def = find_iface (data, iface);
-  if (!iface_def)
-    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-  if (iface_def->properties)
-    for (prop = iface_def->properties;
-        prop->name && strcmp (prop->name, member); prop++)
-      if (!prop || !prop->name)
-       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-  if (set)
-    {
-      if (!prop->set)
-       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-      (*prop->set) (path, &iter, data->user_data);
-    }
-  else
-    {
-      if (!prop->get)
-       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-      (*prop->get) (path, &iter, data->user_data);
-    }
-  dbus_connection_send (bus, reply, NULL);
-  dbus_message_unref (reply);
-  return DBUS_HANDLER_RESULT_HANDLED;
-}
+    if (!dbus_message_iter_open_container
+                (&iter, DBUS_TYPE_ARRAY, "{sv}", &iter_dict))
+        oom ();
 
-DBusHandlerResult
-droute_message (DBusConnection * bus, DBusMessage * message, void *user_data)
-{
-  DRouteData *data = (DRouteData *) user_data;
-  DRouteInterface *iface_def;
-  DRouteMethod *method;
-  const char *iface = dbus_message_get_interface (message);
-  const char *member = dbus_message_get_member (message);
-  int type;
-  DBusError error;
-  DBusMessage *reply;
-
-  dbus_error_init (&error);
-  if (!member)
-    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-  if (iface && !strcmp (iface, "org.freedesktop.DBus.Properties"))
-    {
-      if (!strcmp (member, "GetAll"))
-       return prop_get_all (bus, message, data);
-      return prop (bus, message, data);
-    }
-  if (iface)
-    {
-      iface_def = find_iface (data, iface);
-      if (!iface_def)
-       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-      if (iface_def->methods)
-       for (method = iface_def->methods; method->func; method++)
-         {
-           if (!strcmp (method->name, member))
-             {
-               reply =
-                 (*method->func) (bus, message,
-                                  (method->wants_droute_data ? data : data->
-                                   user_data));
-               if (reply)
-                 {
-                   dbus_connection_send (bus, reply, NULL);
-                   dbus_message_unref (reply);
-                 }
-               return DBUS_HANDLER_RESULT_HANDLED;
-             }
-         }
-    }
-  else
-    {
-      GSList *l;
-      if (type == DBUS_MESSAGE_TYPE_SIGNAL)
-       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-      for (l = data->interfaces; l; l = g_slist_next (l))
-       {
-         iface_def = (DRouteInterface *) l->data;
-         if (iface_def->methods)
-           for (method = iface_def->methods; method->func; method++)
-             {
-               if (!strcmp (method->name, member))
-                 {
-                   reply = (*method->func) (bus, message, data->user_data);
-                   if (reply)
-                     {
-                       dbus_connection_send (bus, reply, NULL);
-                       dbus_message_unref (reply);
-                     }
-                   return DBUS_HANDLER_RESULT_HANDLED;
-                 }
-             }
-       }
-    }
-  return DBUS_HANDLER_RESULT_HANDLED;
+    g_hash_table_iter_init (&prop_iter, path->properties);
+    while (g_hash_table_iter_next (&prop_iter, (gpointer*)&key, (gpointer*)&value))
+      {
+        if (!g_strcmp0 (key->one, iface))
+         {
+           if (!value->get)
+              continue;
+           if (!dbus_message_iter_open_container
+                        (&iter_dict, DBUS_TYPE_DICT_ENTRY, NULL, &iter_dict_entry))
+              oom ();
+           dbus_message_iter_append_basic (&iter_dict_entry, DBUS_TYPE_STRING,
+                                           key->two);
+           (value->get) (&iter_dict_entry, datum);
+           if (!dbus_message_iter_close_container (&iter_dict, &iter_dict_entry))
+               oom ();
+         }
+      }
+
+    if (!dbus_message_iter_close_container (&iter, &iter_dict))
+        oom ();
+    return reply;
 }
 
-dbus_bool_t
-droute_return_v_int32 (DBusMessageIter * iter, dbus_int32_t val)
+static DBusMessage *
+impl_prop_GetSet (DBusMessage *message,
+                  DRoutePath  *path,
+                  const char  *pathstr,
+                  gboolean     get)
 {
-  DBusMessageIter sub;
-
-  if (!dbus_message_iter_open_container
-      (iter, DBUS_TYPE_VARIANT, DBUS_TYPE_INT32_AS_STRING, &sub))
-    {
-      return FALSE;
-    }
-  dbus_message_iter_append_basic (&sub, DBUS_TYPE_INT32, &val);
-  dbus_message_iter_close_container (iter, &sub);
-  return TRUE;
+    DBusMessage *reply = NULL;
+    DBusError error;
+
+    StrPair pair;
+    PropertyPair *prop_funcs = NULL;
+
+
+    dbus_error_init (&error);
+    if (!dbus_message_get_args (message,
+                                &error,
+                                DBUS_TYPE_STRING,
+                                &(pair.one),
+                                DBUS_TYPE_STRING,
+                                &(pair.two),
+                                DBUS_TYPE_INVALID))
+        return dbus_message_new_error (message, DBUS_ERROR_FAILED, error.message);
+
+    prop_funcs = (PropertyPair *) g_hash_table_lookup (path->properties, &pair);
+    if (!prop_funcs)
+        return dbus_message_new_error (message, DBUS_ERROR_FAILED, "Property unavailable");
+
+    if (get && prop_funcs->get)
+      {
+        void *datum = path_get_datum (path, pathstr);
+        DBusMessageIter iter;
+
+        _DROUTE_DEBUG ("DRoute (handle prop Get): %s|%s on %s\n", pair.one, pair.two, pathstr);
+
+        reply = dbus_message_new_method_return (message);
+        dbus_message_iter_init_append (reply, &iter);
+        (prop_funcs->get) (&iter, datum);
+      }
+    else if (!get && prop_funcs->set)
+      {
+        void *datum = path_get_datum (path, pathstr);
+        DBusMessageIter iter;
+
+        _DROUTE_DEBUG ("DRoute (handle prop Get): %s|%s on %s\n", pair.one, pair.two, pathstr);
+
+        dbus_message_iter_init_append (message, &iter);
+        /* Skip the interface and property name */
+        dbus_message_iter_next(&iter);
+        dbus_message_iter_next(&iter);
+        (prop_funcs->set) (&iter, datum);
+
+        reply = dbus_message_new_method_return (message);
+      }
+    else
+      {
+        reply = dbus_message_new_error (message, DBUS_ERROR_FAILED, "Getter or setter unavailable");
+      }
+
+    return reply;
 }
 
-dbus_bool_t
-droute_return_v_double (DBusMessageIter * iter, double val)
+static DBusHandlerResult
+handle_properties (DBusConnection *bus,
+                   DBusMessage    *message,
+                   DRoutePath     *path,
+                   const gchar    *iface,
+                   const gchar    *member,
+                   const gchar    *pathstr)
 {
-  DBusMessageIter sub;
-
-  if (!dbus_message_iter_open_container
-      (iter, DBUS_TYPE_VARIANT, DBUS_TYPE_DOUBLE_AS_STRING, &sub))
-    {
-      return FALSE;
-    }
-  dbus_message_iter_append_basic (&sub, DBUS_TYPE_DOUBLE, &val);
-  dbus_message_iter_close_container (iter, &sub);
-  return TRUE;
+    DBusMessage *reply;
+    DBusHandlerResult result = DBUS_HANDLER_RESULT_HANDLED;
+
+    if (!g_strcmp0(member, "GetAll"))
+       reply = impl_prop_GetAll (message, path, pathstr);
+    else if (!g_strcmp0 (member, "Get"))
+       reply = impl_prop_GetSet (message, path, pathstr, TRUE);
+    else if (!g_strcmp0 (member, "Set"))
+       reply = impl_prop_GetSet (message, path, pathstr, FALSE);
+    else
+       result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+    if (reply)
+      {
+        dbus_connection_send (bus, reply, NULL);
+        dbus_message_unref (reply);
+      }
+
+    return result;
 }
 
-/* Return a string in a variant
- * will return an empty string if passed a NULL value */
-dbus_bool_t
-droute_return_v_string (DBusMessageIter * iter, const char *val)
+/*---------------------------------------------------------------------------*/
+
+static const char *introspection_header =
+"<?xml version=\"1.0\"?>\n";
+
+static const char *introspection_node_element =
+"<node name=\"%s\">\n";
+
+static const char *introspection_footer =
+"</node>";
+
+static void
+append_interface (GString     *str,
+                  const gchar *interface,
+                  const gchar *directory)
 {
-  DBusMessageIter sub;
-
-  if (!val)
-    val = "";
-  if (!dbus_message_iter_open_container
-      (iter, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &sub))
-    {
-      return FALSE;
-    }
-  dbus_message_iter_append_basic (&sub, DBUS_TYPE_STRING, &val);
-  dbus_message_iter_close_container (iter, &sub);
-  return TRUE;
+    gchar *filename;
+    gchar *contents;
+    gsize len;
+
+    GError *err = NULL;
+
+    filename = g_build_filename (directory, interface, NULL);
+
+    if (g_file_get_contents (filename, &contents, &len, &err))
+      {
+        g_string_append_len (str, contents, len);
+      }
+    else
+      {
+        g_warning ("AT-SPI: Cannot find introspection XML file %s - %s",
+                   filename, err->message);
+        g_error_free (err);
+      }
+
+    g_string_append (str, "\n");
+    g_free (filename);
+    g_free (contents);
 }
 
-dbus_int32_t
-droute_get_v_int32 (DBusMessageIter * iter)
+static DBusHandlerResult
+handle_introspection (DBusConnection *bus,
+                      DBusMessage    *message,
+                      DRoutePath     *path,
+                      const gchar    *iface,
+                      const gchar    *member,
+                      const gchar    *pathstr)
 {
-  DBusMessageIter sub;
-  dbus_int32_t rv;
+    GString *output;
+    gchar *final;
+    gint i;
+
+    DBusMessage *reply;
+
+    _DROUTE_DEBUG ("DRoute (handle introspection): %s\n", pathstr);
 
-  // TODO- ensure we have the correct type
-  dbus_message_iter_recurse (iter, &sub);
-  dbus_message_iter_get_basic (&sub, &rv);
-  return rv;
+    if (g_strcmp0 (member, "Introspect"))
+        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+    output = g_string_new(introspection_header);
+
+    g_string_append_printf(output, introspection_node_element, pathstr);
+
+    for (i=0; i < path->interfaces->len; i++)
+      {
+        gchar *interface = (gchar *) g_ptr_array_index (path->interfaces, i);
+        append_interface(output, interface, path->cnx->introspect_dir);
+      }
+
+    g_string_append(output, introspection_footer);
+    final = g_string_free(output, FALSE);
+
+    reply = dbus_message_new_method_return (message);
+    if (!reply)
+        oom ();
+    dbus_message_append_args(reply, DBUS_TYPE_STRING, &final,
+                             DBUS_TYPE_INVALID);
+    dbus_connection_send (bus, reply, NULL);
+
+    dbus_message_unref (reply);
+    g_free(final);
+    return DBUS_HANDLER_RESULT_HANDLED;
 }
 
-const char *
-droute_get_v_string (DBusMessageIter * iter)
+/*---------------------------------------------------------------------------*/
+
+static DBusHandlerResult
+handle_other (DBusConnection *bus,
+              DBusMessage    *message,
+              DRoutePath     *path,
+              const gchar    *iface,
+              const gchar    *member,
+              const gchar    *pathstr)
 {
-  DBusMessageIter sub;
-  char *rv;
+    gint result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+    StrPair pair;
+    DRouteFunction func;
+    DBusMessage *reply;
+
+    pair.one = iface;
+    pair.two = member;
 
-  // TODO- ensure we have the correct type
-  dbus_message_iter_recurse (iter, &sub);
-  dbus_message_iter_get_basic (&sub, &rv);
-  return rv;
+    _DROUTE_DEBUG ("DRoute (handle other): %s|%s on %s\n", member, iface, pathstr);
+
+    func = (DRouteFunction) g_hash_table_lookup (path->methods, &pair);
+    if (func != NULL)
+      {
+        void *datum = path_get_datum (path, pathstr);
+
+        reply = (func) (bus, message, datum);
+
+        if (reply)
+          {
+            dbus_connection_send (bus, reply, NULL);
+            dbus_message_unref (reply);
+          }
+        result = DBUS_HANDLER_RESULT_HANDLED;
+      }
+    return result;
 }
 
-dbus_bool_t
-droute_return_v_object (DBusMessageIter * iter, const char *path)
+/*---------------------------------------------------------------------------*/
+
+static DBusHandlerResult
+handle_message (DBusConnection *bus, DBusMessage *message, void *user_data)
 {
-  DBusMessageIter sub;
-
-  if (!dbus_message_iter_open_container
-      (iter, DBUS_TYPE_VARIANT, DBUS_TYPE_OBJECT_PATH_AS_STRING, &sub))
-    {
-      return FALSE;
-    }
-  dbus_message_iter_append_basic (&sub, DBUS_TYPE_OBJECT_PATH, &path);
-  dbus_message_iter_close_container (iter, &sub);
-  return TRUE;
+    DRoutePath *path = (DRoutePath *) user_data;
+    const gchar *iface   = dbus_message_get_interface (message);
+    const gchar *member  = dbus_message_get_member (message);
+    const gint   type    = dbus_message_get_type (message);
+    const gchar *pathstr = dbus_message_get_path (message);
+
+    /* Check for basic reasons not to handle */
+    if (type   != DBUS_MESSAGE_TYPE_METHOD_CALL ||
+        member == NULL ||
+        iface  == NULL)
+        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+    if (!strcmp (iface, "org.freedesktop.DBus.Properties"))
+        return handle_properties (bus, message, path, iface, member, pathstr);
+
+    if (!strcmp (iface, "org.freedesktop.DBus.Introspectable"))
+        return handle_introspection (bus, message, path, iface, member, pathstr);
+
+    return handle_other (bus, message, path, iface, member, pathstr);
 }
 
-dbus_bool_t
-droute_add_interface (DRouteData * data, const char *name,
-                     DRouteMethod * methods, DRouteProperty * properties,
-                     DRouteGetDatumFunction get_datum,
-                     DRouteFreeDatumFunction free_datum)
+/*---------------------------------------------------------------------------*/
+
+DBusMessage *
+droute_not_yet_handled_error (DBusMessage *message)
 {
-  DRouteInterface *iface =
-    (DRouteInterface *) malloc (sizeof (DRouteInterface));
-  GSList *new_list;
-
-  if (!iface)
-    return FALSE;
-  iface->name = strdup (name);
-  if (!iface->name)
-    {
-      free (iface);
-      return FALSE;
-    }
-  iface->methods = methods;
-  iface->properties = properties;
-  iface->get_datum = get_datum;
-  iface->free_datum = free_datum;
-  new_list = g_slist_append (data->interfaces, iface);
-  if (!new_list)
-    {
-      free (iface->name);
-      free (iface);
-      return FALSE;
-    }
-  data->interfaces = new_list;
-  return TRUE;
+    DBusMessage *reply;
+    gchar       *errmsg;
+
+    errmsg= g_strdup_printf (
+            "Method \"%s\" with signature \"%s\" on interface \"%s\" doesn't exist\n",
+            dbus_message_get_member (message),
+            dbus_message_get_signature (message),
+            dbus_message_get_interface (message));
+    reply = dbus_message_new_error (message,
+                                    DBUS_ERROR_UNKNOWN_METHOD,
+                                    errmsg);
+    g_free (errmsg);
+    return reply;
 }
+
+/*END------------------------------------------------------------------------*/
index c3006cc..3943178 100644 (file)
@@ -3,6 +3,7 @@
  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
  *
  * Copyright 2008 Novell, Inc.
+ * Copyright 2008 Codethink Ltd.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 #define _DROUTE_H
 
 #include <dbus/dbus.h>
-#include "glib.h"      /* needed for GString */
+#include <glib.h>
 
-#define DROUTE_METHOD   0
-#define DROUTE_SIGNAL   1
+#include <droute/droute-variant.h>
 
-typedef DBusMessage *(*DRouteFunction)(DBusConnection *, DBusMessage *, void *);
-typedef dbus_bool_t (*DRoutePropertyFunction)(const char *, DBusMessageIter *, void *);
+
+typedef DBusMessage *(*DRouteFunction)         (DBusConnection *, DBusMessage *, void *);
+typedef dbus_bool_t  (*DRoutePropertyFunction) (DBusMessageIter *, void *);
+
+typedef void        *(*DRouteGetDatumFunction) (const char *, void *);
 
 typedef struct _DRouteMethod DRouteMethod;
 struct _DRouteMethod
 {
-  DRouteFunction func;
-  const char *name;
-  dbus_bool_t wants_droute_data;
+    DRouteFunction func;
+    const char *name;
 };
 
 typedef struct _DRouteProperty DRouteProperty;
 struct _DRouteProperty
 {
-  DRoutePropertyFunction get;
-  DRoutePropertyFunction set;
-  const char *name;
+    DRoutePropertyFunction get;
+    DRoutePropertyFunction set;
+    const char *name;
 };
 
-  typedef void *(*DRouteGetDatumFunction)(const char *, void *);
-  typedef void (*DRouteFreeDatumFunction)(void *);
+/*---------------------------------------------------------------------------*/
 
-typedef struct _DRouteInterface DRouteInterface;
-struct _DRouteInterface
-{
-  DRouteMethod *methods;
-  DRouteProperty *properties;
-  DRouteGetDatumFunction get_datum;
-  DRouteFreeDatumFunction free_datum;
-  char *name;
-};
+typedef struct _DRouteContext DRouteContext;
 
-typedef struct _DRouteData DRouteData;
-struct _DRouteData
-{
-  DBusConnection *bus;
-  GSList *interfaces;
-  char (*introspect_children)(const char *, GString *, void *);
-  void *user_data;
-};
+typedef struct _DRoutePath    DRoutePath;
+
+/*---------------------------------------------------------------------------*/
+
+DRouteContext *
+droute_new      (DBusConnection *bus,
+                 const char *introspect_dir);
+void
+droute_free     (DRouteContext *cnx);
+
+DRoutePath *
+droute_add_one  (DRouteContext *cnx,
+                 const char    *path,
+                 const void    *data);
+
+DRoutePath *
+droute_add_many (DRouteContext *cnx,
+                 const char    *path,
+                 const void    *data,
+                 const DRouteGetDatumFunction get_datum);
+
+void
+droute_path_add_interface (DRoutePath *path,
+                           const char *name,
+                           const DRouteMethod   *methods,
+                           const DRouteProperty *properties);
 
-DBusHandlerResult droute_message(DBusConnection *bus, DBusMessage *message, void *user_data);
+DBusMessage *
+droute_not_yet_handled_error (DBusMessage *message);
 
-dbus_bool_t droute_return_v_int32(DBusMessageIter *iter, dbus_int32_t val);
-dbus_bool_t droute_return_v_double(DBusMessageIter *iter, double val);
-dbus_bool_t droute_return_v_string(DBusMessageIter *iter, const char *val);
-dbus_int32_t droute_get_v_int32(DBusMessageIter *iter);
-const char *droute_get_v_string(DBusMessageIter *iter);
-dbus_bool_t droute_return_v_object(DBusMessageIter *iter, const char *path);
+DBusConnection *
+droute_get_bus (DRouteContext *cnx);
 
-dbus_bool_t droute_add_interface(DRouteData *data, const char *name, DRouteMethod *methods, DRouteProperty *properties, DRouteGetDatumFunction get_datum, DRouteFreeDatumFunction free_datum);
-#endif /* _DROUTE_H */
+#endif /* _DROUTE_H */
diff --git a/droute/introspect-loader.c b/droute/introspect-loader.c
deleted file mode 100644 (file)
index 723d3d6..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * Copyright 2008 Codethink Ltd.
- *
- * 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 <glib.h>
-
-/*
- * This file contains utilities for loading introspection XML
- * from the local file system.
- *
- * There is an installation directory with files containing introspection xml.
- * Each file is named after the interface it describes.
- */
-
-/*
- * Provides the path for the introspection directory.
- */
-#if !defined ATSPI_INTROSPECTION_PATH
-    #error "No introspection XML directory defined"
-#endif
-
-const char *spi_introspection_header =
-"<?xml version=\"1.0\"?>\n";
-
-const char *spi_introspection_node_element =
-"<node name=\"%s\">\n";
-
-const char *spi_introspection_footer =
-"</node>";
-
-void
-spi_append_interface (GString *str, const char *interface)
-{
-  char *filename;
-  char *contents;
-  char *introspection_directory;
-  gsize len;
-
-  GError *err = NULL;
-
-  introspection_directory = (char *) g_getenv("ATSPI_INTROSPECTION_PATH");
-  if (introspection_directory == NULL)
-      introspection_directory = ATSPI_INTROSPECTION_PATH;
-
-  filename = g_build_filename(introspection_directory, interface, NULL);
-
-  if (g_file_get_contents(filename, &contents, &len, &err))
-    {
-      g_string_append_len(str, contents, len);
-    }
-  else
-    {
-      g_warning("AT-SPI: Cannot find introspection XML file %s - %s",
-               filename, err->message);
-      g_error_free(err);
-    }
-
-  g_string_append(str, "\n");
-  g_free(filename);
-  g_free(contents);
-}
diff --git a/droute/test.interface.One b/droute/test.interface.One
new file mode 100644 (file)
index 0000000..a8e2206
--- /dev/null
@@ -0,0 +1,15 @@
+<interface name="test.interface.One">
+  <method name="null"/>
+  <method name="getInt">
+    <arg direction="out" type="o"/>
+  </method>
+  <method name="setInt">
+    <arg direction="in" type="o"/>
+  </method>
+  <method name="getString">
+    <arg direction="out" type="s"/>
+  </method>
+  <method name="setString">
+    <arg direction="in" type="s"/>
+  </method>
+</interface>
diff --git a/droute/test.interface.Two b/droute/test.interface.Two
new file mode 100644 (file)
index 0000000..ca661ec
--- /dev/null
@@ -0,0 +1,15 @@
+<interface name="test.interface.Two">
+  <method name="null"/>
+  <method name="getInt">
+    <arg direction="out" type="o"/>
+  </method>
+  <method name="setInt">
+    <arg direction="in" type="o"/>
+  </method>
+  <method name="getString">
+    <arg direction="out" type="s"/>
+  </method>
+  <method name="setString">
+    <arg direction="in" type="s"/>
+  </method>
+</interface>
index fd35b85..3a87c15 100644 (file)
@@ -20,6 +20,7 @@ from event import Event as _Event
 
 class _CacheData(object):
         __slots__ = [
+                        'path',
                         'parent',
                         'interfaces',
                         'children',
@@ -33,15 +34,14 @@ class _CacheData(object):
                 self._update(data)
 
         def _update(self, data):
-                #Don't cache the path here, used as lookup in cache object dict.
-                (path,
-                self.parent,
-                self.children,
-                self.interfaces,
-                self.name,
-                self.role,
-                self.description,
-                self.state) = data
+                (self.path,
+                 self.parent,
+                 self.children,
+                 self.interfaces,
+                 self.name,
+                 self.role,
+                 self.description,
+                 self.state) = data
 
 #------------------------------------------------------------------------------
 
@@ -75,7 +75,8 @@ class AccessibleCache(object):
         _PATH = '/org/freedesktop/atspi/tree'
         _INTERFACE = 'org.freedesktop.atspi.Tree'
         _GET_METHOD = 'getTree'
-        _UPDATE_SIGNAL = 'updateTree'
+        _UPDATE_SIGNAL = 'updateAccessible'
+        _REMOVE_SIGNAL = 'removeAccessible'
 
         def __init__(self, registry, connection, bus_name):
                 """
@@ -96,7 +97,8 @@ class AccessibleCache(object):
                 get_method = itf.get_dbus_method(self._GET_METHOD)
                 self._update_objects(get_method())
 
-                self._signalMatch = itf.connect_to_signal(self._UPDATE_SIGNAL, self._update_handler)
+                self._updateMatch = itf.connect_to_signal(self._UPDATE_SIGNAL, self._update_single)
+                self._removeMatch = itf.connect_to_signal(self._REMOVE_SIGNAL, self._remove_object)
 
                 obj = connection.get_object(self._bus_name, self._PATH, introspect=False)
                 itf = _dbus.Interface(obj, self._INTERFACE)
@@ -111,8 +113,8 @@ class AccessibleCache(object):
 
         def _dispatch_event(self, olddata, newdata):
                 if olddata.name != newdata.name:
-                        event = _Event(self._registry._cache,
-                                       path,
+                        event = _Event(self._registry.cache,
+                                       newdata.path,
                                        self._bus_name,
                                        "org.freedesktop.atspi.Event.Object",
                                        "property-change",
@@ -120,8 +122,8 @@ class AccessibleCache(object):
                         self._registry._notifyNameChange(event)
 
                 if olddata.description != newdata.description:
-                        event = _Event(self._registry._cache,
-                                       path,
+                        event = _Event(self._registry.cache,
+                                       newdata.path,
                                        self._bus_name,
                                        "org.freedesktop.atspi.Event.Object",
                                        "property-change",
@@ -129,8 +131,8 @@ class AccessibleCache(object):
                         self._registry._notifyDescriptionChange(event)
 
                 if olddata.parent != newdata.parent:
-                        event = _Event(self._registry._cache,
-                                       path,
+                        event = _Event(self._registry.cache,
+                                       newdata.path,
                                        self._bus_name,
                                        "org.freedesktop.atspi.Event.Object",
                                        "property-change",
@@ -140,8 +142,8 @@ class AccessibleCache(object):
                 added, removed = _list_items_added_removed (olddata.children, newdata.children)
 
                 if added:
-                        event = _Event(self._registry._cache,
-                                       path,
+                        event = _Event(self._registry.cache,
+                                       newdata.path,
                                        self._bus_name,
                                        "org.freedesktop.atspi.Event.Object",
                                        "children-changed",
@@ -149,17 +151,17 @@ class AccessibleCache(object):
                         self._registry._notifyChildrenChange(event)
 
                 if removed:
-                        event = _Event(self._registry._cache,
-                                       path,
+                        event = _Event(self._registry.cache,
+                                       newdata.path,
                                        self._bus_name,
                                        "org.freedesktop.atspi.Event.Object",
                                        "children-changed",
                                        ("remove", 0, 0, ""))
                         self._registry._notifyChildrenChange(event)
 
-        def _update_handler(self, update, remove):
-                self._remove_objects(remove)
-                self._update_objects(update)
+        # TODO This should be the other way around. Single is more common than many.
+        def _update_single(self, object):
+                self._update_objects ([object])
 
         def _update_objects(self, objects):
                 cache_update_objects = []
@@ -176,15 +178,14 @@ class AccessibleCache(object):
                 for old, new in cache_update_objects:
                         self._dispatch_event(old, new)
 
-        def _remove_objects(self, paths):
-                for path in paths:
-                        # TODO I'm squashing a possible error here
-                        # I've seen things appear to be deleted twice
-                        # which needs investigation
-                        try:
-                                del(self._objects[path])
-                        except KeyError:
-                                pass
+        def _remove_object(self, paths):
+                # TODO I'm squashing a possible error here
+                # I've seen things appear to be deleted twice
+                # which needs investigation
+                try:
+                        del(self._objects[path])
+                except KeyError:
+                        pass
 
         def _get_root(self):
                 return self._root
index 9ed4f19..796e6a2 100644 (file)
@@ -12,8 +12,8 @@
 #along with this program; if not, write to the Free Software
 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-import interfaces
-from base import BaseProxy
+from interfaces import *
+from accessible import Accessible
 from factory import accessible_factory
 
 __all__ = [
@@ -22,7 +22,7 @@ __all__ = [
 
 #------------------------------------------------------------------------------
 
-class Action(BaseProxy):
+class Action(Accessible):
         """
         An interface through which a user-actionable user interface component
         can be manipulated. Components which react to mouse or keyboard
@@ -42,7 +42,7 @@ class Action(BaseProxy):
                 Causes the object to perform the specified action.
                 @return : a boolean indicating success or failure.
                 """
-                func = self.get_dbus_method("doAction")
+                func = self.get_dbus_method("doAction", dbus_interface=ATSPI_ACTION)
                 return func(index)
 
         def getDescription(self, index):
@@ -56,7 +56,7 @@ class Action(BaseProxy):
                 @return : a string containing the description of the specified
                 action.
                 """
-                func = self.get_dbus_method("getDescription")
+                func = self.get_dbus_method("getDescription", dbus_interface=ATSPI_ACTION)
                 return func(index)
 
         def getKeyBinding(self, index):
@@ -68,7 +68,7 @@ class Action(BaseProxy):
                 @return : a string containing the key binding for the specified
                 action, or an empty string ("") if none exists.
                 """
-                func = self.get_dbus_method("getKeyBinding")
+                func = self.get_dbus_method("getKeyBinding", dbus_interface=ATSPI_ACTION)
                 return func(index)
 
         def getName(self, index):
@@ -81,7 +81,7 @@ class Action(BaseProxy):
                 the result of invoking the action.
                 @return : a string containing the name of the specified action.
                 """
-                func = self.get_dbus_method("getName")
+                func = self.get_dbus_method("getName", dbus_interface=ATSPI_ACTION)
                 return func(index)
 
         def get_nActions(self):
@@ -96,6 +96,6 @@ class Action(BaseProxy):
         nActions = property(fget=get_nActions, fset=set_nActions, doc=_nActionsDoc)
 
 # Register the accessible class with the factory.
-accessible_factory.register_accessible_class(interfaces.ATSPI_ACTION, Action)
+accessible_factory.register_accessible_class(ATSPI_ACTION, Action)
 
 #END----------------------------------------------------------------------------
index d545143..a72693b 100644 (file)
 #along with this program; if not, write to the Free Software
 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-import interfaces
-from base import BaseProxy
+from interfaces import *
 from factory import accessible_factory
 from accessible import Accessible
 
 __all__ = [
-                   "Application",
-                  ]
+                  "Application",
+          ]
 
 #------------------------------------------------------------------------------
 
@@ -40,7 +39,7 @@ class Application(Accessible):
                 @return a string compliant with the POSIX standard for locale
                 description.
                 """
-                func = self.get_dbus_method("getLocale")
+                func = self.get_dbus_method("getLocale", dbus_interface=ATSPI_APPLICATION)
                 return func(*args, **kwargs)
 
         def pause(self, *args, **kwargs):
@@ -50,7 +49,7 @@ class Application(Accessible):
                 loop.
                 @return : true if the request succeeded, false otherwise.
                 """
-                func = self.get_dbus_method("pause")
+                func = self.get_dbus_method("pause", dbus_interface=ATSPI_APPLICATION)
                 return func(*args, **kwargs)
 
         def registerObjectEventListener(self, *args, **kwargs):
@@ -63,7 +62,7 @@ class Application(Accessible):
                 being requested. Register with this application toolkit for "Accessibility::Accessible"
                 event notifications.
                 """
-                func = self.get_dbus_method("registerObjectEventListener")
+                func = self.get_dbus_method("registerObjectEventListener", dbus_interface=ATSPI_APPLICATION)
                 return func(*args, **kwargs)
 
         def registerToolkitEventListener(self, *args, **kwargs):
@@ -78,7 +77,7 @@ class Application(Accessible):
                 Register with this application's toolkit for "toolkit-specific"
                 event notifications.
                 """
-                func = self.get_dbus_method("registerToolkitEventListener")
+                func = self.get_dbus_method("registerToolkitEventListener", dbus_interface=ATSPI_APPLICATION)
                 return func(*args, **kwargs)
 
         def resume(self, *args, **kwargs):
@@ -86,7 +85,7 @@ class Application(Accessible):
                 Request that the application resume sending events.
                 @return : True if the request succeeded, False otherwise.
                 """
-                func = self.get_dbus_method("resume")
+                func = self.get_dbus_method("resume", dbus_interface=ATSPI_APPLICATION)
                 return func(*args, **kwargs)
 
         def get_id(self):
@@ -122,6 +121,6 @@ class Application(Accessible):
         version = property(fget=get_version, fset=set_version, doc=_versionDoc)
 
 # Register the accessible class with the factory.
-accessible_factory.register_accessible_class(interfaces.ATSPI_APPLICATION, Application)
+accessible_factory.register_accessible_class(ATSPI_APPLICATION, Application)
 
 #END----------------------------------------------------------------------------
index a50c51b..6381188 100644 (file)
@@ -29,6 +29,8 @@ __all__ = [
 #------------------------------------------------------------------------------
 
 class TestApplicationCache(object):
+        _DESKTOP_PATH = '/org/freedesktop/atspi/accessible/desktop'
+
         """
         Test application store, accesses a single application.
 
@@ -82,7 +84,7 @@ class TestApplicationCache(object):
                               provided here so that another one is not created.
                 """
                 # An acc_path of '/' implies the desktop object, whatever the app_name.
-                if acc_path == '/':
+                if acc_path == TestApplicationCache._DESKTOP_PATH:
                         return Desktop(self)
                 else:
                         cls = accessible_factory.get_accessible_class(interface)
@@ -115,7 +117,7 @@ class ApplicationCache(object):
         """
 
         # An accessible path of '/' implies the desktop object, whatever the application name.
-        _DESKTOP_PATH = '/'
+        _DESKTOP_PATH = '/org/freedesktop/atspi/accessible/root'
 
         _APPLICATIONS_ADD = 1
         _APPLICATIONS_REMOVE = 0
index 0c62530..ae097d1 100644 (file)
@@ -115,11 +115,13 @@ class BaseProxy(object):
         def __eq__(self, other):
                 if other is None:
                         return False
-
-                if self._app_name == other._app_name and \
-                   self._acc_path == other._acc_path:
-                        return True
-                else:
+                try:
+                        if self._app_name == other._app_name and \
+                           self._acc_path == other._acc_path:
+                                return True
+                        else:
+                                return False
+                except AttributeError:
                         return False
 
         def __ne__(self, other):
index e9aed2b..a5be820 100644 (file)
@@ -12,8 +12,9 @@
 #along with this program; if not, write to the Free Software
 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-import interfaces
-from base import BaseProxy, Enum
+from interfaces import *
+from base import Enum
+from accessible import Accessible
 from factory import accessible_factory
 
 __all__ = [
@@ -22,34 +23,34 @@ __all__ = [
 
 #------------------------------------------------------------------------------
 
-class Collection(BaseProxy):
+class Collection(Accessible):
 
         def createMatchRule(self, *args, **kwargs):
-                func = self.get_dbus_method("createMatchRule")
+                func = self.get_dbus_method("createMatchRule", dbus_interface=ATSPI_COLLECTION)
                 return func(*args, **kwargs)
 
         def freeMatchRule(self, *args, **kwargs):
-                func = self.get_dbus_method("freeMatchRule")
+                func = self.get_dbus_method("freeMatchRule", dbus_interface=ATSPI_COLLECTION)
                 return func(*args, **kwargs)
 
         def getActiveDescendant(self, *args, **kwargs):
-                func = self.get_dbus_method("getActiveDescendant")
+                func = self.get_dbus_method("getActiveDescendant", dbus_interface=ATSPI_COLLECTION)
                 return func(*args, **kwargs)
 
         def getMatches(self, *args, **kwargs):
-                func = self.get_dbus_method("getMatches")
+                func = self.get_dbus_method("getMatches", dbus_interface=ATSPI_COLLECTION)
                 return func(*args, **kwargs)
 
         def getMatchesFrom(self, *args, **kwargs):
-                func = self.get_dbus_method("getMatchesFrom")
+                func = self.get_dbus_method("getMatchesFrom", dbus_interface=ATSPI_COLLECTION)
                 return func(*args, **kwargs)
 
         def getMatchesTo(self, *args, **kwargs):
-                func = self.get_dbus_method("getMatchesTo")
+                func = self.get_dbus_method("getMatchesTo", dbus_interface=ATSPI_COLLECTION)
                 return func(*args, **kwargs)
 
         def isAncestorOf(self, *args, **kwargs):
-                func = self.get_dbus_method("isAncestorOf")
+                func = self.get_dbus_method("isAncestorOf", dbus_interface=ATSPI_COLLECTION)
                 return func(*args, **kwargs)
 
         class MatchType(Enum):
@@ -104,6 +105,6 @@ class Collection(BaseProxy):
         TREE_RESTRICT_SIBLING = TreeTraversalType(1)
 
 # Register the accessible class with the factory.
-accessible_factory.register_accessible_class(interfaces.ATSPI_COLLECTION, Collection)
+accessible_factory.register_accessible_class(ATSPI_COLLECTION, Collection)
 
 #END----------------------------------------------------------------------------
index 1b740c2..cd606db 100644 (file)
 #along with this program; if not, write to the Free Software
 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-import interfaces
-from base import BaseProxy, Enum
+from interfaces import *
+from base import Enum
 from factory import accessible_factory
-from accessible import BoundingBox
+from accessible import BoundingBox, Accessible
 
 from dbus.types import Int16
 
@@ -74,7 +74,7 @@ LAYER_WINDOW = ComponentLayer(7)
 
 #------------------------------------------------------------------------------
 
-class Component(BaseProxy):
+class Component(Accessible):
         """
         The Component interface is implemented by objects which occupy
         on-screen space, e.g. objects which have onscreen visual representations.
@@ -92,7 +92,7 @@ class Component(BaseProxy):
                 @return True if the specified point lies within the Component's
                 bounding box, False otherwise.
                 """
-                func = self.get_dbus_method("contains")
+                func = self.get_dbus_method("contains", dbus_interface=ATSPI_COMPONENT)
                 return func(*args, **kwargs)
 
         def deregisterFocusHandler(self, *args, **kwargs):
@@ -100,7 +100,7 @@ class Component(BaseProxy):
                 Request that an EventListener registered via registerFocusHandler
                 no longer be notified when this object receives keyboard focus.
                 """
-                func = self.get_dbus_method("deregisterFocusHandler")
+                func = self.get_dbus_method("deregisterFocusHandler", dbus_interface=ATSPI_COMPONENT)
                 return func(*args, **kwargs)
 
         def getAccessibleAtPoint(self, *args, **kwargs):
@@ -109,7 +109,7 @@ class Component(BaseProxy):
                 specified point.
                 """
                 #TODO this needs a real implementation
-                func = self.get_dbus_method("getAccessibleAtPoint")
+                func = self.get_dbus_method("getAccessibleAtPoint", dbus_interface=ATSPI_COMPONENT)
                 return func(*args, **kwargs)
 
         def getAlpha(self, *args, **kwargs):
@@ -119,7 +119,7 @@ class Component(BaseProxy):
                 alpha value of 0.0 indicates that the object is fully transparent.
                 Negative alpha values have no defined meaning at this time.
                 """
-                func = self.get_dbus_method("getAlpha")
+                func = self.get_dbus_method("getAlpha", dbus_interface=ATSPI_COMPONENT)
                 return func(*args, **kwargs)
 
         def getExtents(self, coord_type):
@@ -130,7 +130,7 @@ class Component(BaseProxy):
                 @return a BoundingBox which entirely contains the object's onscreen
                 visual representation.
                 """
-                func = self.get_dbus_method("getExtents")
+                func = self.get_dbus_method("getExtents", dbus_interface=ATSPI_COMPONENT)
                 extents = func(Int16(coord_type))
                 return BoundingBox(*extents)
 
@@ -138,7 +138,7 @@ class Component(BaseProxy):
                 """
                 @return the ComponentLayer in which this object resides.
                 """
-                func = self.get_dbus_method("getLayer")
+                func = self.get_dbus_method("getLayer", dbus_interface=ATSPI_COMPONENT)
                 return ComponentLayer(func(*args, **kwargs))
 
         def getMDIZOrder(self):
@@ -150,7 +150,7 @@ class Component(BaseProxy):
                 @return an integer indicating the object's place in the stacking
                 order.
                 """
-                func = self.get_dbus_method("getMDIZOrder")
+                func = self.get_dbus_method("getMDIZOrder", dbus_interface=ATSPI_COMPONENT)
                 return func()
 
         def getPosition(self, coord_type):
@@ -165,7 +165,7 @@ class Component(BaseProxy):
                 an out parameter which will be back-filled with the returned
                 y coordinate.
                 """
-                func = self.get_dbus_method("getPosition")
+                func = self.get_dbus_method("getPosition", dbus_interface=ATSPI_COMPONENT)
                 return func(Int16(coord_type))
 
         def getSize(self, *args, **kwargs):
@@ -178,7 +178,7 @@ class Component(BaseProxy):
                 @param : height
                 the object's vertical extents in the specified coordinate system.
                 """
-                func = self.get_dbus_method("getSize")
+                func = self.get_dbus_method("getSize", dbus_interface=ATSPI_COMPONENT)
                 return func(*args, **kwargs)
 
         def grabFocus(self, *args, **kwargs):
@@ -187,7 +187,7 @@ class Component(BaseProxy):
                 @return True if keyboard focus was successfully transferred to
                 the Component.
                 """
-                func = self.get_dbus_method("grabFocus")
+                func = self.get_dbus_method("grabFocus", dbus_interface=ATSPI_COMPONENT)
                 return func(*args, **kwargs)
 
         def registerFocusHandler(self, *args, **kwargs):
@@ -195,10 +195,10 @@ class Component(BaseProxy):
                 Register an EventListener for notification when this object receives
                 keyboard focus.
                 """
-                func = self.get_dbus_method("registerFocusHandler")
+                func = self.get_dbus_method("registerFocusHandler", dbus_interface=ATSPI_COMPONENT)
                 return func(*args, **kwargs)
 
 # Register the accessible class with the factory.
-accessible_factory.register_accessible_class(interfaces.ATSPI_COMPONENT, Component)
+accessible_factory.register_accessible_class(ATSPI_COMPONENT, Component)
 
 #END----------------------------------------------------------------------------
index 0a2e0e2..4101ae0 100644 (file)
@@ -12,7 +12,7 @@
 #along with this program; if not, write to the Free Software
 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-import interfaces
+from interfaces import *
 from base import BaseProxyMeta
 from accessible import BoundingBox
 from state import StateSet
@@ -185,11 +185,13 @@ class Desktop(object):
         def __eq__(self, other):
                 if other is None:
                         return False
-
-                if self._app_name == other._app_name and \
-                   self._acc_path == other._acc_path:
-                        return True
-                else:
+                try:
+                        if self._app_name == other._app_name and \
+                           self._acc_path == other._acc_path:
+                                return True
+                        else:
+                                return False
+                except AttributeError:
                         return False
 
         def __ne__(self, other):
@@ -345,7 +347,7 @@ class Desktop(object):
 
         @property
         def interfaces(self):
-                return [interfaces.ATSPI_ACCESSIBLE, interfaces.ATSPI_COMPONENT]
+                return [ATSPI_ACCESSIBLE, ATSPI_COMPONENT]
 
         def queryInterface(self, interface):
                 """
@@ -353,9 +355,9 @@ class Desktop(object):
                 or raises a NotImplemented error if the given interface
                 is not supported.
                 """
-                if interface == interfaces.ATSPI_ACCESSIBLE:
+                if interface == ATSPI_ACCESSIBLE:
                                 return self
-                elif interface == interfaces.ATSPI_COMPONENT:
+                elif interface == ATSPI_COMPONENT:
                                 return DesktopComponent()
                 else:
                                 raise NotImplementedError(
index 12e2671..be256b6 100644 (file)
@@ -12,8 +12,8 @@
 #along with this program; if not, write to the Free Software
 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-import interfaces
-from base import BaseProxy
+from interfaces import *
+from accessible import Accessible
 from factory import accessible_factory
 
 __all__ = [
@@ -22,7 +22,7 @@ __all__ = [
 
 #------------------------------------------------------------------------------
 
-class Document(BaseProxy):
+class Document(Accessible):
         """
         Primarily a 'tagging' interface which indicates the start of
         document content in the Accessibility hierarchy. Accessible objects
@@ -44,7 +44,7 @@ class Document(BaseProxy):
                 attribute, or an empty string if the attribute is unspecified
                 for the object.
                 """
-                func = self.get_dbus_method("getAttributeValue")
+                func = self.get_dbus_method("getAttributeValue", dbus_interface=ATSPI_DOCUMENT)
                 return func(*args, **kwargs)
 
         def getAttributes(self, *args, **kwargs):
@@ -55,7 +55,7 @@ class Document(BaseProxy):
                 @return an AttributeSet containing the attributes of the document,
                 as name-value pairs.
                 """
-                func = self.get_dbus_method("getAttributes")
+                func = self.get_dbus_method("getAttributes", dbus_interface=ATSPI_DOCUMENT)
                 return func(*args, **kwargs)
 
         def getLocale(self, *args, **kwargs):
@@ -65,10 +65,10 @@ class Document(BaseProxy):
                 @return a string compliant with the POSIX standard for locale
                 description.
                 """
-                func = self.get_dbus_method("getLocale")
+                func = self.get_dbus_method("getLocale", dbus_interface=ATSPI_DOCUMENT)
                 return func(*args, **kwargs)
 
 # Register the accessible class with the factory.
-accessible_factory.register_accessible_class(interfaces.ATSPI_DOCUMENT, Document)
+accessible_factory.register_accessible_class(ATSPI_DOCUMENT, Document)
 
 #END----------------------------------------------------------------------------
index 084840f..8c9d6a9 100644 (file)
@@ -12,8 +12,7 @@
 #along with this program; if not, write to the Free Software
 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-import interfaces
-from base import BaseProxy
+from interfaces import *
 from factory import accessible_factory
 from text import *
 
@@ -41,7 +40,7 @@ class EditableText(Text):
                 the offset of the first character past the end of the range of
                 text being copied.
                 """
-                func = self.get_dbus_method("copyText")
+                func = self.get_dbus_method("copyText", dbus_interface=ATSPI_EDITABLE_TEXT)
                 return func(*args, **kwargs)
 
         def cutText(self, *args, **kwargs):
@@ -56,7 +55,7 @@ class EditableText(Text):
                 text being cut. 
                 @return True if the text was successfully cut, False otherwise.
                 """
-                func = self.get_dbus_method("cutText")
+                func = self.get_dbus_method("cutText", dbus_interface=ATSPI_EDITABLE_TEXT)
                 return func(*args, **kwargs)
 
         def deleteText(self, *args, **kwargs):
@@ -71,7 +70,7 @@ class EditableText(Text):
                 text being deleted. 
                 @return True if the text was successfully deleted, False otherwise.
                 """
-                func = self.get_dbus_method("deleteText")
+                func = self.get_dbus_method("deleteText", dbus_interface=ATSPI_EDITABLE_TEXT)
                 return func(*args, **kwargs)
 
         def insertText(self, *args, **kwargs):
@@ -91,7 +90,7 @@ class EditableText(Text):
                 @return True if the text content was successfully inserted, False
                 otherwise.
                 """
-                func = self.get_dbus_method("insertText")
+                func = self.get_dbus_method("insertText", dbus_interface=ATSPI_EDITABLE_TEXT)
                 return func(*args, **kwargs)
 
         def pasteText(self, *args, **kwargs):
@@ -103,7 +102,7 @@ class EditableText(Text):
                 @return True if the text was successfully pasted into the Text
                 object, False otherwise.
                 """
-                func = self.get_dbus_method("pasteText")
+                func = self.get_dbus_method("pasteText", dbus_interface=ATSPI_EDITABLE_TEXT)
                 return func(*args, **kwargs)
 
         def setAttributes(self, *args, **kwargs):
@@ -112,7 +111,7 @@ class EditableText(Text):
                 @return True if the text attributes were successfully modified,
                 False otherwise.
                 """
-                func = self.get_dbus_method("setAttributes")
+                func = self.get_dbus_method("setAttributes", dbus_interface=ATSPI_EDITABLE_TEXT)
                 return func(*args, **kwargs)
 
         def setTextContents(self, *args, **kwargs):
@@ -125,10 +124,10 @@ class EditableText(Text):
                 @return True if the text content was successfully changed, False
                 otherwise.
                 """
-                func = self.get_dbus_method("setTextContents")
+                func = self.get_dbus_method("setTextContents", dbus_interface=ATSPI_EDITABLE_TEXT)
                 return func(*args, **kwargs)
 
 # Register the accessible class with the factory.
-accessible_factory.register_accessible_class(interfaces.ATSPI_EDITABLE_TEXT, EditableText)
+accessible_factory.register_accessible_class(ATSPI_EDITABLE_TEXT, EditableText)
 
 #END----------------------------------------------------------------------------
index 143984b..a57f646 100644 (file)
@@ -12,8 +12,8 @@
 #along with this program; if not, write to the Free Software
 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-import interfaces
-from base import BaseProxy
+from interfaces import *
+from accessible import Accessible
 from factory import accessible_factory
 
 __all__ = [
@@ -22,7 +22,7 @@ __all__ = [
 
 #------------------------------------------------------------------------------
 
-class Hyperlink(BaseProxy):
+class Hyperlink(Accessible):
         """
         Instances of Hyperlink are returned by Hypertext objects, and
         are the means by which end users and clients interact with linked,
@@ -48,7 +48,7 @@ class Hyperlink(BaseProxy):
                 ith anchor, or through which the content associated with the
                 ith anchor can be accessed.
                 """
-                func = self.get_dbus_method("getObject")
+                func = self.get_dbus_method("getObject", dbus_interface=ATSPI_HYPERLINK)
                 return func(*args, **kwargs)
 
         def getURI(self, *args, **kwargs):
@@ -58,7 +58,7 @@ class Hyperlink(BaseProxy):
                 @return a string corresponding to the URI of the Hyperlink's
                 'ith' anchor, if one exists, or a NIL string otherwise.
                 """
-                func = self.get_dbus_method("getURI")
+                func = self.get_dbus_method("getURI", dbus_interface=ATSPI_HYPERLINK)
                 return func(*args, **kwargs)
 
         def isValid(self, *args, **kwargs):
@@ -69,7 +69,7 @@ class Hyperlink(BaseProxy):
                 the hyperlink's URI is invalid, or a connection to the resource
                 can not be established.
                 """
-                func = self.get_dbus_method("isValid")
+                func = self.get_dbus_method("isValid", dbus_interface=ATSPI_HYPERLINK)
                 return func(*args, **kwargs)
 
         def get_endIndex(self):
@@ -107,6 +107,6 @@ class Hyperlink(BaseProxy):
         startIndex = property(fget=get_startIndex, fset=set_startIndex, doc=_startIndexDoc)
 
 # Register the accessible class with the factory.
-accessible_factory.register_accessible_class(interfaces.ATSPI_HYPERLINK, Hyperlink)
+accessible_factory.register_accessible_class(ATSPI_HYPERLINK, Hyperlink)
 
 #END----------------------------------------------------------------------------
index f8e428e..27aebff 100644 (file)
@@ -12,8 +12,8 @@
 #along with this program; if not, write to the Free Software
 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-import interfaces
-from base import BaseProxy
+from interfaces import *
+from accessible import Accessible
 from factory import accessible_factory
 
 __all__ = [
@@ -22,7 +22,7 @@ __all__ = [
 
 #------------------------------------------------------------------------------
 
-class Hypertext(BaseProxy):
+class Hypertext(Accessible):
         """
         An interface used for objects which implement linking between
         multiple resource or content locations, or multiple 'markers'
@@ -39,7 +39,7 @@ class Hypertext(BaseProxy):
                 an integer from 0 to getNLinks() - 1. 
                 @return the Hyperlink in this Hypertext object.
                 """
-                func = self.get_dbus_method("getLink")
+                func = self.get_dbus_method("getLink", dbus_interface=ATSPI_HYPERTEXT)
                 return func(*args, **kwargs)
 
         def getLinkIndex(self, *args, **kwargs):
@@ -52,7 +52,7 @@ class Hypertext(BaseProxy):
                 offset characterIndex, or -1 if no Hyperlink is associated with
                 that character offset.
                 """
-                func = self.get_dbus_method("getLinkIndex")
+                func = self.get_dbus_method("getLinkIndex", dbus_interface=ATSPI_HYPERTEXT)
                 return func(*args, **kwargs)
 
         def getNLinks(self, *args, **kwargs):
@@ -61,10 +61,10 @@ class Hypertext(BaseProxy):
                 @return the number of Hyperlinks associated with this Hypertext
                 object, as a long integer.
                 """
-                func = self.get_dbus_method("getNLinks")
+                func = self.get_dbus_method("getNLinks", dbus_interface=ATSPI_HYPERTEXT)
                 return func(*args, **kwargs)
 
 # Register the accessible class with the factory.
-accessible_factory.register_accessible_class(interfaces.ATSPI_HYPERTEXT, Hypertext)
+accessible_factory.register_accessible_class(ATSPI_HYPERTEXT, Hypertext)
 
 #END----------------------------------------------------------------------------
index 6911692..49c4095 100644 (file)
@@ -13,8 +13,8 @@
 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 import dbus
-import interfaces
-from base import BaseProxy
+from interfaces import *
+from accessible import Accessible
 from factory import accessible_factory
 from accessible import BoundingBox
 
@@ -24,7 +24,7 @@ __all__ = [
 
 #------------------------------------------------------------------------------
 
-class Image(BaseProxy):
+class Image(Accessible):
         """
         An interface implemented by objects which render image data or
         pictorial information to the screen. When onscreen components
@@ -48,7 +48,7 @@ class Image(BaseProxy):
                 to the containing window. 
                 @return a BoundingBox enclosing the image's onscreen representation.
                 """
-                func = self.get_dbus_method("getImageExtents")
+                func = self.get_dbus_method("getImageExtents", dbus_interface=ATSPI_IMAGE)
                 return BoundingBox(*func(dbus.Int16(coordType)))
 
         def getImagePosition(self, *args, **kwargs):
@@ -65,7 +65,7 @@ class Image(BaseProxy):
                 to the screen; if 1, they are returned relative to the containing
                 window.
                 """
-                func = self.get_dbus_method("getImagePosition")
+                func = self.get_dbus_method("getImagePosition", dbus_interface=ATSPI_IMAGE)
                 return func(*args, **kwargs)
 
         def getImageSize(self, *args, **kwargs):
@@ -81,7 +81,7 @@ class Image(BaseProxy):
                 Back-filled with the y extents of the onscreen image (i.e. the
                 image height in pixels)
                 """
-                func = self.get_dbus_method("getImageSize")
+                func = self.get_dbus_method("getImageSize", dbus_interface=ATSPI_IMAGE)
                 return func(*args, **kwargs)
 
         def get_imageDescription(self):
@@ -107,6 +107,6 @@ class Image(BaseProxy):
         imageLocale = property(fget=get_imageLocale, fset=set_imageLocale, doc=_imageLocaleDoc)
 
 # Register the accessible class with the factory.
-accessible_factory.register_accessible_class(interfaces.ATSPI_IMAGE, Image)
+accessible_factory.register_accessible_class(ATSPI_IMAGE, Image)
 
 #END----------------------------------------------------------------------------
index 13e17bb..a8b5183 100644 (file)
@@ -12,8 +12,9 @@
 #along with this program; if not, write to the Free Software
 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-import interfaces
-from base import BaseProxy, Enum
+from interfaces import *
+from base import Enum
+from accessible import Accessible
 from factory import accessible_factory
 
 __all__ = [
@@ -22,7 +23,7 @@ __all__ = [
 
 #------------------------------------------------------------------------------
 
-class LoginHelper(BaseProxy):
+class LoginHelper(Accessible):
         """
         An interface for use by assistive technologies by which they
         can access system information and services on a 'need to know'
@@ -67,7 +68,7 @@ class LoginHelper(BaseProxy):
                 device I/O required in order to facilitate end-user access to
                 the system.
                 """
-                func = self.get_dbus_method("getDeviceReqs")
+                func = self.get_dbus_method("getDeviceReqs", dbus_interface=ATSPI_LOGIN_HELPER)
                 return func(*args, **kwargs)
 
         def getRaiseWindows(self, *args, **kwargs):
@@ -79,7 +80,7 @@ class LoginHelper(BaseProxy):
                 order for the LoginHelper to facilitate end-user access to the
                 system.
                 """
-                func = self.get_dbus_method("getRaiseWindows")
+                func = self.get_dbus_method("getRaiseWindows", dbus_interface=ATSPI_LOGIN_HELPER)
                 return func(*args, **kwargs)
 
         def setSafe(self, *args, **kwargs):
@@ -98,7 +99,7 @@ class LoginHelper(BaseProxy):
                 when in "safe" mode.
                 @return : whether the LoginHelper is now "safe" or not.
                 """
-                func = self.get_dbus_method("setSafe")
+                func = self.get_dbus_method("setSafe", dbus_interface=ATSPI_LOGIN_HELPER)
                 return func(*args, **kwargs)
 
         class DeviceReq(Enum):
@@ -141,6 +142,6 @@ class LoginHelper(BaseProxy):
                 winID = property(fget=_get_winID, fset=_set_winID)
 
 # Register the accessible class with the factory.
-accessible_factory.register_accessible_class(interfaces.ATSPI_LOGIN_HELPER, LoginHelper)
+accessible_factory.register_accessible_class(ATSPI_LOGIN_HELPER, LoginHelper)
 
 #END----------------------------------------------------------------------------
index 2c73cf1..71ab550 100644 (file)
@@ -80,10 +80,10 @@ class _Registry(object):
                         app_name = _os.environ["ATSPI_TEST_APP_NAME"]
 
                 if app_name:
-                        self._appcache = TestApplicationCache(self, self._bus, app_name)
+                        self._app_cache = TestApplicationCache(self, self._bus, app_name)
                         self.dev = _TestDeviceEventController()
                 else:
-                        self._appcache = ApplicationCache(self, self._bus)
+                        self._app_cache = ApplicationCache(self, self._bus)
                         self.dev = DeviceEventController(self._bus)
 
                 self._event_listeners = {}
@@ -110,6 +110,14 @@ class _Registry(object):
                 """
                 return self
 
+        @property
+        def cache (self):
+                """
+                This is the accessible application cache through which
+                all accessible objects are accessed.
+                """
+                return self._app_cache
+
         def start(self, async=False, gil=True):
                 """
                 Enter the main loop to start receiving and dispatching events.
@@ -152,7 +160,7 @@ class _Registry(object):
                 @return: Desktop reference
                 @rtype: Accessibility.Desktop
                 """
-                return _Desktop(self._appcache)
+                return _Desktop(self._app_cache)
 
         def _callClients(self, register, event):
                 for client in register.keys():
@@ -238,7 +246,7 @@ class _Registry(object):
                 for name in names:
                         new_type = _EventType(name)
                         registered.append((new_type.name,
-                                           _event_type_to_signal_reciever(self._bus, self._appcache, client, new_type)))
+                                           _event_type_to_signal_reciever(self._bus, self._app_cache, client, new_type)))
 
                 self._registerFake(self._name_type, self._name_listeners, client, *names)
                 self._registerFake(self._description_type, self._description_listeners, client, *names)
index 6a201a8..de665db 100644 (file)
@@ -12,8 +12,8 @@
 #along with this program; if not, write to the Free Software
 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-import interfaces
-from base import BaseProxy
+from interfaces import *
+from accessible import Accessible
 from factory import accessible_factory
 
 __all__ = [
@@ -22,7 +22,7 @@ __all__ = [
 
 #------------------------------------------------------------------------------
 
-class Selection(BaseProxy):
+class Selection(Accessible):
         """
         An interface which indicates that an object exposes a 'selection'
         model, allowing the selection of one or more of its children.
@@ -41,7 +41,7 @@ class Selection(BaseProxy):
                 @return True if the selections were successfully cleared, False
                 otherwise.
                 """
-                func = self.get_dbus_method("clearSelection")
+                func = self.get_dbus_method("clearSelection", dbus_interface=ATSPI_SELECTION)
                 return func(*args, **kwargs)
 
         def deselectChild(self, *args, **kwargs):
@@ -54,7 +54,7 @@ class Selection(BaseProxy):
                 to be selected.
                 @return True if the child was successfully selected, False otherwise.
                 """
-                func = self.get_dbus_method("deselectChild")
+                func = self.get_dbus_method("deselectChild", dbus_interface=ATSPI_SELECTION)
                 return func(*args, **kwargs)
 
         def deselectSelectedChild(self, *args, **kwargs):
@@ -68,7 +68,7 @@ class Selection(BaseProxy):
                 @return True if the child was successfully deselected, False
                 otherwise.
                 """
-                func = self.get_dbus_method("deselectSelectedChild")
+                func = self.get_dbus_method("deselectSelectedChild", dbus_interface=ATSPI_SELECTION)
                 return func(*args, **kwargs)
 
         def getSelectedChild(self, *args, **kwargs):
@@ -80,7 +80,7 @@ class Selection(BaseProxy):
                 @return a pointer to a selected Accessible child object, specified
                 by selectedChildIndex.
                 """
-                func = self.get_dbus_method("getSelectedChild")
+                func = self.get_dbus_method("getSelectedChild", dbus_interface=ATSPI_SELECTION)
                 return func(*args, **kwargs)
 
         def isChildSelected(self, *args, **kwargs):
@@ -93,7 +93,7 @@ class Selection(BaseProxy):
                 @return True if the specified child is currently selected, False
                 otherwise.
                 """
-                func = self.get_dbus_method("isChildSelected")
+                func = self.get_dbus_method("isChildSelected", dbus_interface=ATSPI_SELECTION)
                 return func(*args, **kwargs)
 
         def selectAll(self, *args, **kwargs):
@@ -104,7 +104,7 @@ class Selection(BaseProxy):
                 support this operation).
                 @return True if successful, False otherwise.
                 """
-                func = self.get_dbus_method("selectAll")
+                func = self.get_dbus_method("selectAll", dbus_interface=ATSPI_SELECTION)
                 return func(*args, **kwargs)
 
         def selectChild(self, *args, **kwargs):
@@ -115,7 +115,7 @@ class Selection(BaseProxy):
                 be selected.
                 @return True if the child was successfully selected, False otherwise.
                 """
-                func = self.get_dbus_method("selectChild")
+                func = self.get_dbus_method("selectChild", dbus_interface=ATSPI_SELECTION)
                 return func(*args, **kwargs)
 
         def get_nSelectedChildren(self):
@@ -130,6 +130,6 @@ class Selection(BaseProxy):
         nSelectedChildren = property(fget=get_nSelectedChildren, fset=set_nSelectedChildren, doc=_nSelectedChildrenDoc)
 
 # Register the accessible class with the factory.
-accessible_factory.register_accessible_class(interfaces.ATSPI_SELECTION, Selection)
+accessible_factory.register_accessible_class(ATSPI_SELECTION, Selection)
 
 #END----------------------------------------------------------------------------
index ceed7ff..a4916c0 100644 (file)
@@ -12,8 +12,9 @@
 #along with this program; if not, write to the Free Software
 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-import interfaces
+from interfaces import *
 from base import BaseProxy, Enum
+from accessible import Accessible
 from factory import accessible_factory
 
 __all__ = [
@@ -58,12 +59,12 @@ class CommandListener(BaseProxy):
                 The newly-available list of Command objects which may be invoked
                 by the listener.
                 """
-                func = self.get_dbus_method("notifyCommands")
+                func = self.get_dbus_method("notifyCommands", dbus_interface=ATSPI_COMMAND_LISTENER)
                 return func(*args, **kwargs)
 
 #------------------------------------------------------------------------------
 
-class Selector(BaseProxy):
+class Selector(Accessible):
         """
         This interface is intended for use by assistive technologies
         and related user-agents. Via this interface, an assistive technology
@@ -85,7 +86,7 @@ class Selector(BaseProxy):
                 and the reason for failure if the Command could not be activated
                 or invoked.
                 """
-                func = self.get_dbus_method("activateCommand")
+                func = self.get_dbus_method("activateCommand", dbus_interface=ATSPI_SELECTOR)
                 return func(*args, **kwargs)
 
         def deregisterChangeListener(self, *args, **kwargs):
@@ -95,7 +96,7 @@ class Selector(BaseProxy):
                 @param : listener
                 the CommandListener to remove from the notification list.
                 """
-                func = self.get_dbus_method("deregisterChangeListener")
+                func = self.get_dbus_method("deregisterChangeListener", dbus_interface=ATSPI_SELECTOR)
                 return func(*args, **kwargs)
 
         def getCommands(self, *args, **kwargs):
@@ -103,7 +104,7 @@ class Selector(BaseProxy):
                 Query the Selector for the current CommandList.
                 @return the currently available CommandList
                 """
-                func = self.get_dbus_method("getCommands")
+                func = self.get_dbus_method("getCommands", dbus_interface=ATSPI_SELECTOR)
                 return func(*args, **kwargs)
 
         def refreshCommands(self, *args, **kwargs):
@@ -111,7 +112,7 @@ class Selector(BaseProxy):
                 Ask the Selector to re-calculate its CommandList. 
                 @return TRUE if the CommandList changed.
                 """
-                func = self.get_dbus_method("refreshCommands")
+                func = self.get_dbus_method("refreshCommands", dbus_interface=ATSPI_SELECTOR)
                 return func(*args, **kwargs)
 
         def registerChangeListener(self, *args, **kwargs):
@@ -121,7 +122,7 @@ class Selector(BaseProxy):
                 @param : listener
                 the CommandListener to be notified of changes.
                 """
-                func = self.get_dbus_method("registerChangeListener")
+                func = self.get_dbus_method("registerChangeListener", dbus_interface=ATSPI_SELECTOR)
                 return func(*args, **kwargs)
 
         def replaceCommands(self, *args, **kwargs):
@@ -129,7 +130,7 @@ class Selector(BaseProxy):
                 @return TRUE if the replacement request was successful, FALSE
                 if the request could not be honored.
                 """
-                func = self.get_dbus_method("replaceCommands")
+                func = self.get_dbus_method("replaceCommands", dbus_interface=ATSPI_SELECTOR)
                 return func(*args, **kwargs)
 
         def get_supportsReplace(self):
@@ -163,6 +164,6 @@ class Selector(BaseProxy):
         COMMAND_RESULT_SUCCESS = CommandResult(1)
 
 # Register the accessible class with the factory.
-accessible_factory.register_accessible_class(interfaces.ATSPI_SELECTOR, Selector)
+accessible_factory.register_accessible_class(ATSPI_SELECTOR, Selector)
 
 #END----------------------------------------------------------------------------
index 70c5004..1a52bc4 100644 (file)
@@ -12,8 +12,9 @@
 #along with this program; if not, write to the Free Software
 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-import interfaces
+from interfaces import *
 from base import BaseProxy, Enum
+from accessible import Accessible
 from factory import accessible_factory
 
 __all__ = [
@@ -35,7 +36,7 @@ class ContentStream(BaseProxy):
                 not perform further operations on a StreamableContent::Stream
                 object after closing it.
                 """
-                func = self.get_dbus_method("close")
+                func = self.get_dbus_method("close", dbus_interface=ATSPI_STREAMABLE_CONTENT)
                 return func(*args, **kwargs)
 
         def read(self, *args, **kwargs):
@@ -43,7 +44,7 @@ class ContentStream(BaseProxy):
                 Request/read a specified amount of data from a Stream. 
                 @return the number of bytes actually read into the client buffer.
                 """
-                func = self.get_dbus_method("read")
+                func = self.get_dbus_method("read", dbus_interface=ATSPI_STREAMABLE_CONTENT)
                 return func(*args, **kwargs)
 
         def seek(self, *args, **kwargs):
@@ -59,7 +60,7 @@ class ContentStream(BaseProxy):
                 exception will be raised. 
                 @return the actual resulting offset, if no exception was raised.
                 """
-                func = self.get_dbus_method("seek")
+                func = self.get_dbus_method("seek", dbus_interface=ATSPI_STREAMABLE_CONTENT)
                 return func(*args, **kwargs)
 
         class IOError(Exception):
@@ -90,7 +91,7 @@ class ContentStream(BaseProxy):
 
 #------------------------------------------------------------------------------
 
-class StreamableContent(BaseProxy):
+class StreamableContent(Accessible):
         """
         An interface whereby an object allows its backing content to
         be streamed to clients. Negotiation of content type is allowed.
@@ -103,7 +104,7 @@ class StreamableContent(BaseProxy):
                 """
                 DEPRECATED, use getStream instead.
                 """
-                func = self.get_dbus_method("getContent")
+                func = self.get_dbus_method("getContent", dbus_interface=ATSPI_STREAMABLE_CONTENT)
                 return func(*args, **kwargs)
 
         def getContentTypes(self, *args, **kwargs):
@@ -111,7 +112,7 @@ class StreamableContent(BaseProxy):
                 getContentTypes: 
                 @return the list of available mimetypes for this object's content.
                 """
-                func = self.get_dbus_method("getContentTypes")
+                func = self.get_dbus_method("getContentTypes", dbus_interface=ATSPI_STREAMABLE_CONTENT)
                 return func(*args, **kwargs)
 
         def getStream(self, *args, **kwargs):
@@ -123,7 +124,7 @@ class StreamableContent(BaseProxy):
                 @return a Stream whose mimetype matches contentType, if available,
                 or NIL.
                 """
-                func = self.get_dbus_method("getStream")
+                func = self.get_dbus_method("getStream", dbus_interface=ATSPI_STREAMABLE_CONTENT)
                 return func(*args, **kwargs)
 
         def getURI(self, *args, **kwargs):
@@ -138,10 +139,10 @@ class StreamableContent(BaseProxy):
                 @return a string which constitutes a URI for a stream of the
                 specified content type, or NULL if no such URI can be obtained.
                 """
-                func = self.get_dbus_method("getURI")
+                func = self.get_dbus_method("getURI", dbus_interface=ATSPI_STREAMABLE_CONTENT)
                 return func(*args, **kwargs)
 
 # Register the accessible class with the factory.
-accessible_factory.register_accessible_class(interfaces.ATSPI_STREAMABLE_CONTENT, StreamableContent)
+accessible_factory.register_accessible_class(ATSPI_STREAMABLE_CONTENT, StreamableContent)
 
 #END----------------------------------------------------------------------------
index 549b54e..7034e4d 100644 (file)
@@ -12,8 +12,8 @@
 #along with this program; if not, write to the Free Software
 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-import interfaces
-from base import BaseProxy
+from interfaces import *
+from accessible import Accessible
 from factory import accessible_factory
 
 __all__ = [
@@ -22,7 +22,7 @@ __all__ = [
 
 #------------------------------------------------------------------------------
 
-class Table(BaseProxy):
+class Table(Accessible):
         """
         An interface used by containers whose contained data is arranged
         in a "tabular" (i.e. row-column) fashion. Tables may resemble
@@ -46,7 +46,7 @@ class Table(BaseProxy):
                 @return True if the specified column was successfully selected,
                 False if not.
                 """
-                func = self.get_dbus_method("addColumnSelection")
+                func = self.get_dbus_method("addColumnSelection", dbus_interface=ATSPI_TABLE)
                 return func(*args, **kwargs)
 
         def addRowSelection(self, *args, **kwargs):
@@ -57,7 +57,7 @@ class Table(BaseProxy):
                 @return True if the specified row was successfully selected,
                 False if not.
                 """
-                func = self.get_dbus_method("addRowSelection")
+                func = self.get_dbus_method("addRowSelection", dbus_interface=ATSPI_TABLE)
                 return func(*args, **kwargs)
 
         def getAccessibleAt(self, *args, **kwargs):
@@ -70,7 +70,7 @@ class Table(BaseProxy):
                 @return an Accessible object representing the specified table
                 cell.
                 """
-                func = self.get_dbus_method("getAccessibleAt")
+                func = self.get_dbus_method("getAccessibleAt", dbus_interface=ATSPI_TABLE)
                 return func(*args, **kwargs)
 
         def getColumnAtIndex(self, *args, **kwargs):
@@ -82,7 +82,7 @@ class Table(BaseProxy):
                 @return a long integer indicating the first column spanned by
                 the child of a table, at the specified 1-D (zero-offset) index.
                 """
-                func = self.get_dbus_method("getColumnAtIndex")
+                func = self.get_dbus_method("getColumnAtIndex", dbus_interface=ATSPI_TABLE)
                 return func(*args, **kwargs)
 
         def getColumnDescription(self, *args, **kwargs):
@@ -94,7 +94,7 @@ class Table(BaseProxy):
                 @return a UTF-8 string describing the specified table column,
                 if available.
                 """
-                func = self.get_dbus_method("getColumnDescription")
+                func = self.get_dbus_method("getColumnDescription", dbus_interface=ATSPI_TABLE)
                 return func(*args, **kwargs)
 
         def getColumnExtentAt(self, *args, **kwargs):
@@ -109,7 +109,7 @@ class Table(BaseProxy):
                 @return a long integer indicating the number of columns spanned
                 by the specified cell.
                 """
-                func = self.get_dbus_method("getColumnExtentAt")
+                func = self.get_dbus_method("getColumnExtentAt", dbus_interface=ATSPI_TABLE)
                 return func(*args, **kwargs)
 
         def getColumnHeader(self, *args, **kwargs):
@@ -122,7 +122,7 @@ class Table(BaseProxy):
                 @return an Accessible representatin of the specified table column,
                 if available.
                 """
-                func = self.get_dbus_method("getColumnHeader")
+                func = self.get_dbus_method("getColumnHeader", dbus_interface=ATSPI_TABLE)
                 return func(*args, **kwargs)
 
         def getIndexAt(self, *args, **kwargs):
@@ -136,7 +136,7 @@ class Table(BaseProxy):
                 @return a long integer which serves as the index of a specified
                 cell in the table, in a form usable by Accessible::getChildAtIndex.
                 """
-                func = self.get_dbus_method("getIndexAt")
+                func = self.get_dbus_method("getIndexAt", dbus_interface=ATSPI_TABLE)
                 return func(*args, **kwargs)
 
         def getRowAtIndex(self, *args, **kwargs):
@@ -148,7 +148,7 @@ class Table(BaseProxy):
                 @return a long integer indicating the first row spanned by the
                 child of a table, at the specified 1-D (zero-offset) index.
                 """
-                func = self.get_dbus_method("getRowAtIndex")
+                func = self.get_dbus_method("getRowAtIndex", dbus_interface=ATSPI_TABLE)
                 return func(*args, **kwargs)
 
         def getRowColumnExtentsAtIndex(self, *args, **kwargs):
@@ -187,7 +187,7 @@ class Table(BaseProxy):
                 False if the index does not correspond to a cell. If False is
                 returned, the values of the out parameters are undefined.
                 """
-                func = self.get_dbus_method("getRowColumnExtentsAtIndex")
+                func = self.get_dbus_method("getRowColumnExtentsAtIndex", dbus_interface=ATSPI_TABLE)
                 return func(*args, **kwargs)
 
         def getRowDescription(self, *args, **kwargs):
@@ -199,7 +199,7 @@ class Table(BaseProxy):
                 @return a UTF-8 string describing the specified table row, if
                 available.
                 """
-                func = self.get_dbus_method("getRowDescription")
+                func = self.get_dbus_method("getRowDescription", dbus_interface=ATSPI_TABLE)
                 return func(*args, **kwargs)
 
         def getRowExtentAt(self, *args, **kwargs):
@@ -214,7 +214,7 @@ class Table(BaseProxy):
                 @return a long integer indicating the number of rows spanned
                 by the specified cell.
                 """
-                func = self.get_dbus_method("getRowExtentAt")
+                func = self.get_dbus_method("getRowExtentAt", dbus_interface=ATSPI_TABLE)
                 return func(*args, **kwargs)
 
         def getRowHeader(self, *args, **kwargs):
@@ -226,7 +226,7 @@ class Table(BaseProxy):
                 @return an Accessible representatin of the specified table row,
                 if available.
                 """
-                func = self.get_dbus_method("getRowHeader")
+                func = self.get_dbus_method("getRowHeader", dbus_interface=ATSPI_TABLE)
                 return func(*args, **kwargs)
 
         def getSelectedColumns(self, *args, **kwargs):
@@ -235,7 +235,7 @@ class Table(BaseProxy):
                 @return a sequence of integers comprising the indices of columns
                 currently selected.
                 """
-                func = self.get_dbus_method("getSelectedColumns")
+                func = self.get_dbus_method("getSelectedColumns", dbus_interface=ATSPI_TABLE)
                 return func(*args, **kwargs)
 
         def getSelectedRows(self, *args, **kwargs):
@@ -244,7 +244,7 @@ class Table(BaseProxy):
                 @return a sequence of integers comprising the indices of rows
                 currently selected.
                 """
-                func = self.get_dbus_method("getSelectedRows")
+                func = self.get_dbus_method("getSelectedRows", dbus_interface=ATSPI_TABLE)
                 return func(*args, **kwargs)
 
         def isColumnSelected(self, *args, **kwargs):
@@ -255,7 +255,7 @@ class Table(BaseProxy):
                 @return True if the specified column is currently selected, False
                 if not.
                 """
-                func = self.get_dbus_method("isColumnSelected")
+                func = self.get_dbus_method("isColumnSelected", dbus_interface=ATSPI_TABLE)
                 return func(*args, **kwargs)
 
         def isRowSelected(self, *args, **kwargs):
@@ -266,7 +266,7 @@ class Table(BaseProxy):
                 @return True if the specified row is currently selected, False
                 if not.
                 """
-                func = self.get_dbus_method("isRowSelected")
+                func = self.get_dbus_method("isRowSelected", dbus_interface=ATSPI_TABLE)
                 return func(*args, **kwargs)
 
         def isSelected(self, *args, **kwargs):
@@ -279,7 +279,7 @@ class Table(BaseProxy):
                 @return True if the specified cell is currently selected, False
                 if not.
                 """
-                func = self.get_dbus_method("isSelected")
+                func = self.get_dbus_method("isSelected", dbus_interface=ATSPI_TABLE)
                 return func(*args, **kwargs)
 
         def removeColumnSelection(self, *args, **kwargs):
@@ -290,7 +290,7 @@ class Table(BaseProxy):
                 @return True if the specified column was successfully de-selected,
                 False if not.
                 """
-                func = self.get_dbus_method("removeColumnSelection")
+                func = self.get_dbus_method("removeColumnSelection", dbus_interface=ATSPI_TABLE)
                 return func(*args, **kwargs)
 
         def removeRowSelection(self, *args, **kwargs):
@@ -301,7 +301,7 @@ class Table(BaseProxy):
                 @return True if the specified row was successfully de-selected,
                 False if not.
                 """
-                func = self.get_dbus_method("removeRowSelection")
+                func = self.get_dbus_method("removeRowSelection", dbus_interface=ATSPI_TABLE)
                 return func(*args, **kwargs)
 
         def get_caption(self):
@@ -374,6 +374,6 @@ class Table(BaseProxy):
         summary = property(fget=get_summary, fset=set_summary, doc=_summaryDoc)
 
 # Register the accessible class with the factory.
-accessible_factory.register_accessible_class(interfaces.ATSPI_TABLE, Table)
+accessible_factory.register_accessible_class(ATSPI_TABLE, Table)
 
 #END----------------------------------------------------------------------------
index ed6c5f5..ef22f88 100644 (file)
@@ -14,8 +14,9 @@
 
 import dbus
 
-import interfaces
-from base import BaseProxy, Enum
+from interfaces import *
+from accessible import Accessible
+from base import Enum
 from factory import accessible_factory
 
 __all__ = [
@@ -73,7 +74,7 @@ TEXT_CLIP_NONE = TEXT_CLIP_TYPE(0)
 
 #------------------------------------------------------------------------------
 
-class Text(BaseProxy):
+class Text(Accessible):
         """
         The text interface should be implemented by objects which place
         textual information onscreen as character strings or glyphs.
@@ -112,7 +113,7 @@ class Text(BaseProxy):
                 other reasons (for instance if the user does not have permission
                 to copy the text into the relevant selection buffer).
                 """
-                func = self.get_dbus_method("addSelection")
+                func = self.get_dbus_method("addSelection", dbus_interface=ATSPI_TEXT)
                 return func(*args, **kwargs)
 
         def getAttributeRun(self, *args, **kwargs):
@@ -164,7 +165,7 @@ class Text(BaseProxy):
                 @return the AttributeSet defined at offset, optionally including
                 the 'default' attributes.
                 """
-                func = self.get_dbus_method("getAttributeRun")
+                func = self.get_dbus_method("getAttributeRun", dbus_interface=ATSPI_TEXT)
                 return func(*args, **kwargs)
 
         def getAttributeValue(self, *args, **kwargs):
@@ -189,7 +190,7 @@ class Text(BaseProxy):
                 @return the value of attribute (name-value pair) corresponding
                 to "name", if defined.
                 """
-                func = self.get_dbus_method("getAttributeValue")
+                func = self.get_dbus_method("getAttributeValue", dbus_interface=ATSPI_TEXT)
                 return func(*args, **kwargs)
 
         def getAttributes(self, offset):
@@ -198,7 +199,7 @@ class Text(BaseProxy):
                 @return the attributes at offset, as a semicolon-delimited set
                 of colon-delimited name-value pairs.
                 """
-                func = self.get_dbus_method("getAttributes")
+                func = self.get_dbus_method("getAttributes", dbus_interface=ATSPI_TEXT)
                 return func(dbus.Int32(offset))
 
         def getBoundedRanges(self, *args, **kwargs):
@@ -229,7 +230,7 @@ class Text(BaseProxy):
                 determines whether text which intersects the bounding box in
                 the y direction is included.
                 """
-                func = self.get_dbus_method("getBoundedRanges")
+                func = self.get_dbus_method("getBoundedRanges", dbus_interface=ATSPI_TEXT)
                 return func(*args, **kwargs)
 
         def getCharacterAtOffset(self, *args, **kwargs):
@@ -238,7 +239,7 @@ class Text(BaseProxy):
                 UCS-4 representation of the character at the specified text offset,
                 or 0 if offset is out of range.
                 """
-                func = self.get_dbus_method("getCharacterAtOffset")
+                func = self.get_dbus_method("getCharacterAtOffset", dbus_interface=ATSPI_TEXT)
                 return func(*args, **kwargs)
 
         def getCharacterExtents(self, *args, **kwargs):
@@ -272,7 +273,7 @@ class Text(BaseProxy):
                 window, with the x axis pointing right and the y axis pointing
                 down.
                 """
-                func = self.get_dbus_method("getCharacterExtents")
+                func = self.get_dbus_method("getCharacterExtents", dbus_interface=ATSPI_TEXT)
                 return func(*args, **kwargs)
 
         def getDefaultAttributeSet(self, *args, **kwargs):
@@ -286,7 +287,7 @@ class Text(BaseProxy):
                 whereas an object whose text weight is inspecified may report
                 the default or implied text weight in the default AttributeSet.
                 """
-                func = self.get_dbus_method("getDefaultAttributeSet")
+                func = self.get_dbus_method("getDefaultAttributeSet", dbus_interface=ATSPI_TEXT)
                 return func(*args, **kwargs)
 
         def getDefaultAttributes(self, *args, **kwargs):
@@ -295,7 +296,7 @@ class Text(BaseProxy):
                 @return the attributes which apply to the entire text content,
                 but which were not explicitly specified by the content creator.
                 """
-                func = self.get_dbus_method("getDefaultAttributes")
+                func = self.get_dbus_method("getDefaultAttributes", dbus_interface=ATSPI_TEXT)
                 return func(*args, **kwargs)
 
         def getNSelections(self, *args, **kwargs):
@@ -310,7 +311,7 @@ class Text(BaseProxy):
                 @return the number of contiguous selections in the current Text
                 object.
                 """
-                func = self.get_dbus_method("getNSelections")
+                func = self.get_dbus_method("getNSelections", dbus_interface=ATSPI_TEXT)
                 return func(*args, **kwargs)
 
         def getOffsetAtPoint(self, *args, **kwargs):
@@ -328,7 +329,7 @@ class Text(BaseProxy):
                 of the glyph whose onscreen bounds contain the point x,y, or
                 -1 if the point is outside the bounds of any glyph.
                 """
-                func = self.get_dbus_method("getOffsetAtPoint")
+                func = self.get_dbus_method("getOffsetAtPoint", dbus_interface=ATSPI_TEXT)
                 return func(*args, **kwargs)
 
         def getRangeExtents(self, *args, **kwargs):
@@ -359,7 +360,7 @@ class Text(BaseProxy):
                 corner of the screen; if 1, the coordinates are reported relative
                 to the corner of the containing toplevel window.
                 """
-                func = self.get_dbus_method("getRangeExtents")
+                func = self.get_dbus_method("getRangeExtents", dbus_interface=ATSPI_TEXT)
                 return func(*args, **kwargs)
 
         def getSelection(self, *args, **kwargs):
@@ -368,7 +369,7 @@ class Text(BaseProxy):
                 (i.e. for a selection which does not exist) is not strictly defined,
                 but should set endOffset equal to startOffset.
                 """
-                func = self.get_dbus_method("getSelection")
+                func = self.get_dbus_method("getSelection", dbus_interface=ATSPI_TEXT)
                 return func(*args, **kwargs)
 
         def getText(self, startOffset, endOffset):
@@ -380,7 +381,7 @@ class Text(BaseProxy):
                 startOffset (inclusive) up to but not including the character
                 at endOffset.
                 """
-                func = self.get_dbus_method("getText")
+                func = self.get_dbus_method("getText", dbus_interface=ATSPI_TEXT)
                 if not endOffset:
                         endOffset = -1
                 return func(dbus.Int32(startOffset), dbus.Int32(endOffset))
@@ -410,7 +411,7 @@ class Text(BaseProxy):
                 @return a string which is a substring of the text content of
                 the object, delimited by the specified boundary condition.
                 """
-                func = self.get_dbus_method("getTextAfterOffset")
+                func = self.get_dbus_method("getTextAfterOffset", dbus_interface=ATSPI_TEXT)
                 return func(*args, **kwargs)
 
         def getTextAtOffset(self, *args, **kwargs):
@@ -437,7 +438,7 @@ class Text(BaseProxy):
                 @return a string which is a substring of the text content of
                 the object, delimited by the specified boundary condition.
                 """
-                func = self.get_dbus_method("getTextAtOffset")
+                func = self.get_dbus_method("getTextAtOffset", dbus_interface=ATSPI_TEXT)
                 return func(*args, **kwargs)
 
         def getTextBeforeOffset(self, *args, **kwargs):
@@ -464,7 +465,7 @@ class Text(BaseProxy):
                 @return a string which is a substring of the text content of
                 the object, delimited by the specified boundary condition.
                 """
-                func = self.get_dbus_method("getTextBeforeOffset")
+                func = self.get_dbus_method("getTextBeforeOffset", dbus_interface=ATSPI_TEXT)
                 return func(*args, **kwargs)
 
         def removeSelection(self, *args, **kwargs):
@@ -475,7 +476,7 @@ class Text(BaseProxy):
                 @return True if the selection was successfully removed, False
                 otherwise.
                 """
-                func = self.get_dbus_method("removeSelection")
+                func = self.get_dbus_method("removeSelection", dbus_interface=ATSPI_TEXT)
                 return func(*args, **kwargs)
 
         def setCaretOffset(self, *args, **kwargs):
@@ -489,7 +490,7 @@ class Text(BaseProxy):
                 @return TRUE if the request was carried out, or FALSE if the
                 caret could not be moved to the requested position.
                 """
-                func = self.get_dbus_method("setCaretOffset")
+                func = self.get_dbus_method("setCaretOffset", dbus_interface=ATSPI_TEXT)
                 return func(*args, **kwargs)
 
         def setSelection(self, *args, **kwargs):
@@ -508,7 +509,7 @@ class Text(BaseProxy):
                 @return True if the selection corresponding to selectionNum is
                 successfully modified, False otherwise.
                 """
-                func = self.get_dbus_method("setSelection")
+                func = self.get_dbus_method("setSelection", dbus_interface=ATSPI_TEXT)
                 return func(*args, **kwargs)
 
         def get_caretOffset(self):
@@ -565,6 +566,6 @@ class Text(BaseProxy):
                 data = property(fget=_get_data, fset=_set_data)
 
 # Register the accessible class with the factory.
-accessible_factory.register_accessible_class(interfaces.ATSPI_TEXT, Text)
+accessible_factory.register_accessible_class(ATSPI_TEXT, Text)
 
 #END----------------------------------------------------------------------------
index 73dcd39..32c51fe 100644 (file)
@@ -12,8 +12,8 @@
 #along with this program; if not, write to the Free Software
 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-import interfaces
-from base import BaseProxy
+from interfaces import *
+from accessible import Accessible
 from factory import accessible_factory
 
 __all__ = [
@@ -22,7 +22,7 @@ __all__ = [
 
 #------------------------------------------------------------------------------
 
-class Value(BaseProxy):
+class Value(Accessible):
         """
         An interface supporting controls which allow a one-dimensional,
         scalar quantity to be modified or which reflect a scalar quantity.
@@ -73,6 +73,6 @@ class Value(BaseProxy):
         minimumValue = property(fget=get_minimumValue, fset=set_minimumValue, doc=_minimumValueDoc)
 
 # Register the accessible class with the factory.
-accessible_factory.register_accessible_class(interfaces.ATSPI_VALUE, Value)
+accessible_factory.register_accessible_class(ATSPI_VALUE, Value)
 
 #END----------------------------------------------------------------------------
index fe657e0..19b745b 100644 (file)
@@ -4,7 +4,8 @@ at_spi_registryd_CFLAGS = $(DBUS_GLIB_CFLAGS)   \
                          $(GOBJ_CFLAGS)        \
                          $(ATK_CFLAGS)         \
                          $(GDK_CFLAGS)         \
-                         -I$(top_srcdir) 
+                         -I$(top_srcdir)       \
+                         -DATSPI_INTROSPECTION_PATH=\"$(pkgdatadir)/$(DEFAULT_ATSPI_INTROSPECTION_PATH)\"
 
 at_spi_registryd_LDADD = $(DBUS_GLIB_LIBS)     \
                         $(GOBJ_CFLAGS)         \
index f61e69d..bdc5816 100644 (file)
 #include <gdk/gdkkeysyms.h>
 #include <gdk/gdkwindow.h>
 
-#include <atk-adaptor/spi-private.h>
 #include <spi-common/keymasks.h>
-#include <droute/droute.h>
-#include <droute/introspect-loader.h>
 #include <spi-common/spi-dbus.h>
 #include <spi-common/spi-types.h>
 
+#include <droute/droute.h>
+
 #include "deviceeventcontroller.h"
 #include "reentrant-list.h"
 
@@ -342,25 +341,14 @@ spi_dec_clear_unlatch_pending (SpiDEController *controller)
     g_object_get_qdata (G_OBJECT (controller), spi_dec_private_quark);
   priv->xkb_latch_mask = 0;
 }
-static void emit(SpiDEController *controller, const char *interface, const char *name, const char *detail, int detail1, int detail2)
-{
-  DBusMessage *sig;
-  DBusMessageIter iter, iter_variant;
-
-  sig = dbus_message_new_signal(SPI_DBUS_PATH_DEC, interface, name);
-  if (!sig) return;
-  dbus_message_iter_init_append (sig, &iter);
-  if (!detail) detail = "";
-  dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &detail);
-  dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &detail1);
-  dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &detail2);
-  dbus_message_iter_open_container (&iter, DBUS_TYPE_VARIANT, "u", &iter_variant);
-  /* append dummy value */
-  dbus_message_iter_append_basic (&iter_variant, DBUS_TYPE_UINT32, &detail1);
-  dbus_message_iter_close_container (&iter, &iter_variant);
-  dbus_connection_send(controller->droute->bus, sig, NULL);
-  dbus_message_unref(sig);
+
+static void emit(SpiDEController *controller, const char *name, int first_type, ...)
+{
+  va_list arg;
+
+  va_start(arg, first_type);
+  spi_dbus_emit_valist(controller->bus, SPI_DBUS_PATH_DEC, SPI_DBUS_INTERFACE_DEC, name, first_type, arg);
+  va_end(arg);
 }
 
 static gboolean
@@ -924,7 +912,7 @@ spi_controller_register_device_listener (SpiDEController      *controller,
 
       controller->key_listeners = g_list_prepend (controller->key_listeners,
                                                  key_listener);
-      spi_dbus_add_disconnect_match (controller->droute->bus, key_listener->listener.bus_name);
+      spi_dbus_add_disconnect_match (controller->bus, key_listener->listener.bus_name);
       if (key_listener->mode->global)
         {
          return spi_controller_register_global_keygrabs (controller, key_listener);    
@@ -934,7 +922,7 @@ spi_controller_register_device_listener (SpiDEController      *controller,
       break;
   case SPI_DEVICE_TYPE_MOUSE:
       controller->mouse_listeners = g_list_prepend (controller->mouse_listeners, listener);
-      spi_dbus_add_disconnect_match (controller->droute->bus, listener->bus_name);
+      spi_dbus_add_disconnect_match (controller->bus, listener->bus_name);
       break;
   default:
       break;
@@ -957,7 +945,7 @@ Accessibility_DeviceEventListener_notifyEvent(SpiDEController *controller,
   {
     // TODO: Evaluate performance: perhaps rework this whole architecture
     // to avoid blocking calls
-    DBusMessage *reply = dbus_connection_send_with_reply_and_block(controller->droute->bus, message, 1000, &error);
+    DBusMessage *reply = dbus_connection_send_with_reply_and_block(controller->bus, message, 1000, &error);
     if (reply)
     {
       DBusError error;
@@ -1926,7 +1914,7 @@ spi_controller_deregister_device_listener (SpiDEController            *controlle
 {
   RemoveListenerClosure  ctx;
 
-  ctx.bus = controller->droute->bus;
+  ctx.bus = controller->bus;
   ctx.listener = listener;
 
   spi_re_entrant_list_foreach (&controller->mouse_listeners,
@@ -1939,7 +1927,7 @@ spi_deregister_controller_key_listener (SpiDEController            *controller,
 {
   RemoveListenerClosure  ctx;
 
-  ctx.bus = controller->droute->bus;
+  ctx.bus = controller->bus;
   ctx.listener = (DEControllerListener *) key_listener;
 
   /* special case, copy keyset from existing controller list entry */
@@ -2698,36 +2686,6 @@ static void wait_for_release_event (XEvent          *event,
   check_release_handler = g_timeout_add (CHECK_RELEASE_DELAY, check_release, &pressed_event);
 }
 
-static DBusMessage *
-impl_introspect (DBusConnection *bus, DBusMessage *message,
-                 void *user_data)
-{
-  const char *path;
-  GString *output;
-  char *final;
-
-  DBusMessage *reply;
-
-  path = dbus_message_get_path(message);
-
-  output = g_string_new(spi_introspection_header);
-
-  g_string_append_printf(output, spi_introspection_node_element, path);
-
-  spi_append_interface(output, SPI_DBUS_INTERFACE_DEC);
-
-  g_string_append(output, spi_introspection_footer);
-  final = g_string_free(output, FALSE);
-
-  reply = dbus_message_new_method_return (message);
-  g_assert(reply != NULL);
-  dbus_message_append_args(reply, DBUS_TYPE_STRING, &final,
-                           DBUS_TYPE_INVALID);
-
-  g_free(final);
-  return reply;
-}
-
 static DRouteMethod dev_methods[] =
 {
   { impl_register_keystroke_listener, "registerKeystrokeListener" },
@@ -2741,27 +2699,23 @@ static DRouteMethod dev_methods[] =
   { NULL, NULL }
 };
 
-static DRouteMethod intro_methods[] = {
-  {impl_introspect, "Introspect"},
-  {NULL, NULL}
-};
-
 SpiDEController *
-spi_registry_dec_new (SpiRegistry *reg, DRouteData *droute)
+spi_registry_dec_new (SpiRegistry *reg, DBusConnection *bus, DRouteContext *droute)
 {
   SpiDEController *dec = g_object_new (SPI_DEVICE_EVENT_CONTROLLER_TYPE, NULL);
+  DRoutePath *path;
 
   dec->registry = g_object_ref (reg);
-  dec->droute = droute;
-
-  droute_add_interface (droute,
-                        SPI_DBUS_INTERFACE_DEC,
-                        dev_methods,
-                        NULL, NULL, NULL);
-  droute_add_interface (droute,
-                        "org.freedesktop.DBus.Introspectable",
-                        intro_methods,
-                        NULL, NULL, NULL);
+  dec->bus = bus;
+
+  path = droute_add_one (droute,
+                         "/org/freedesktop/atspi/registry/deviceeventcontroller",
+                         dec);
+
+  droute_path_add_interface (path,
+                             SPI_DBUS_INTERFACE_DEC,
+                             dev_methods,
+                             NULL);
 
   spi_dec_init_mouse_listener (dec);
   /* TODO: kill mouse listener on finalize */
index c42fe24..fb00a37 100644 (file)
@@ -43,13 +43,12 @@ G_BEGIN_DECLS
 
 struct _SpiDEController {
        GObject parent;
-       
-       SpiRegistry *registry;
-        DRouteData  *droute;
-       GList       *key_listeners;
-       GList       *mouse_listeners;
-       GList       *keygrabs_list;
-       Display     *xevie_display;
+       DBusConnection *bus;
+       SpiRegistry    *registry;
+       GList          *key_listeners;
+       GList          *mouse_listeners;
+       GList          *keygrabs_list;
+       Display        *xevie_display;
 };
 
 typedef struct {
@@ -57,7 +56,9 @@ typedef struct {
 } SpiDEControllerClass;
 
 GType            spi_device_event_controller_get_type (void);
-SpiDEController *spi_device_event_controller_new      (SpiRegistry *registry);
+SpiDEController *spi_device_event_controller_new      (SpiRegistry    *registry,
+                                                       DBusConnection *bus,
+                                                       DRouteContext  *droute);
 
 void spi_remove_device_listeners (SpiDEController *controller, const char *bus_name);
 
index 4559fd7..3b738af 100644 (file)
 #include "registry.h"
 #include "deviceeventcontroller.h"
 
+#if !defined ATSPI_INTROSPECTION_PATH
+    #error "No introspection XML directory defined"
+#endif
+
 static gchar *dbus_name = NULL;
 
 static GOptionEntry optentries[] =
@@ -40,19 +44,13 @@ static GOptionEntry optentries[] =
   {NULL}
 };
 
-static DBusObjectPathVTable droute_vtable =
-{
-  NULL,
-  &droute_message,
-  NULL, NULL, NULL, NULL
-};
-
 int
 main (int argc, char **argv)
 {
   SpiRegistry *registry;
   SpiDEController *dec;
-  DRouteData droute;
+  DRouteContext *droute;
+  gchar *introspection_directory;
 
   GMainLoop *mainloop;
   DBusConnection *bus;
@@ -80,7 +78,6 @@ main (int argc, char **argv)
 
   dbus_error_init (&error);
   bus = dbus_bus_get(DBUS_BUS_SESSION, &error);
-  droute.bus = bus;
   if (!bus)
   {
     g_warning("Couldn't connect to dbus: %s\n", error.message);
@@ -99,20 +96,16 @@ main (int argc, char **argv)
       g_print ("SpiRegistry daemon is running with well-known name - %s\n", dbus_name);
     }
 
+  /* Get D-Bus introspection directory */
+  introspection_directory = (char *) g_getenv("ATSPI_INTROSPECTION_PATH");
+  if (introspection_directory == NULL)
+      introspection_directory = ATSPI_INTROSPECTION_PATH;
+
   /* Set up D-Route for use by the dec */
-  droute.interfaces = NULL;
-  if (!dbus_connection_register_object_path (droute.bus,
-                                             "/org/freedesktop/atspi/registry/deviceeventcontroller",
-                                             &droute_vtable,
-                                             &droute))
-  {
-    g_error("AT-SPI Registry daemon: Couldn't register droute.\n");
-    return 0;
-  }
+  droute = droute_new (bus, introspection_directory);
 
-  registry = spi_registry_new (bus);
-  dec = spi_registry_dec_new (registry, &droute);
-  droute.user_data = dec;
+  registry = spi_registry_new (bus, droute);
+  dec = spi_registry_dec_new (registry, bus, droute);
 
   g_main_loop_run (mainloop);
   return 0;
index 60b77a0..a15c673 100644 (file)
@@ -230,39 +230,6 @@ handle_disconnection (DBusConnection *bus, DBusMessage *message, void *user_data
 /*---------------------------------------------------------------------------*/
 
 static DBusHandlerResult
-message_handler (DBusConnection *bus, DBusMessage *message, void *user_data)
-{
-  DBusMessage *reply = NULL;
-  guint res = DBUS_HANDLER_RESULT_HANDLED;
-
-  int mtype;
-  const char *itf;
-  const char *name;
-
-  mtype = dbus_message_get_type (message);
-  itf = dbus_message_get_interface (message);
-  name = dbus_message_get_member (message);
-
-  if (dbus_message_is_method_call (message, SPI_DBUS_INTERFACE_REGISTRY, "getApplications"))
-      reply = impl_getApplications (bus, message, user_data);
-  else if (dbus_message_is_method_call (message, SPI_DBUS_INTERFACE_REGISTRY, "registerApplication"))
-      impl_registerApplication (bus, message, user_data);
-  else if (dbus_message_is_method_call (message, SPI_DBUS_INTERFACE_REGISTRY, "deregisterApplication"))
-      impl_deregisterApplication (bus, message, user_data);
-  else
-      res = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-
-  if (reply)
-    {
-      dbus_connection_send (bus, reply, NULL);
-      dbus_message_unref (reply);
-    }
-  return res;
-}
-
-/*---------------------------------------------------------------------------*/
-
-static DBusHandlerResult
 signal_filter (DBusConnection *bus, DBusMessage *message, void *user_data)
 {
   SpiRegistry *registry = SPI_REGISTRY (user_data);
@@ -283,25 +250,34 @@ signal_filter (DBusConnection *bus, DBusMessage *message, void *user_data)
 static gchar *app_sig_match_name_owner =
        "type='signal', interface='org.freedesktop.DBus', member='NameOwnerChanged'";
 
-static DBusObjectPathVTable reg_vtable =
+static DRouteMethod dev_methods[] =
 {
-  NULL,
-  &message_handler,
-  NULL, NULL, NULL, NULL
+  { impl_getApplications, "getApplications" },
+  { impl_registerApplication, "registerApplication" },
+  { impl_deregisterApplication, "deregisterApplication" },
+  { NULL, NULL }
 };
 
 SpiRegistry *
-spi_registry_new (DBusConnection *bus)
+spi_registry_new (DBusConnection *bus, DRouteContext *droute)
 {
   SpiRegistry *reg = g_object_new (SPI_REGISTRY_TYPE, NULL);
+  DRoutePath *path;
 
   reg->bus = bus;
 
-  dbus_connection_register_object_path(bus, SPI_DBUS_PATH_REGISTRY, &reg_vtable, reg);
-
   dbus_bus_add_match (bus, app_sig_match_name_owner, NULL);
   dbus_connection_add_filter (bus, signal_filter, reg, NULL);
 
+  path = droute_add_one (droute,
+                         SPI_DBUS_PATH_REGISTRY,
+                         reg);
+
+  droute_path_add_interface (path,
+                             SPI_DBUS_INTERFACE_REGISTRY,
+                             dev_methods,
+                             NULL);
+
   return reg;
 }
 
index 87f6bed..68ec403 100644 (file)
@@ -27,6 +27,8 @@
 #include <glib.h>
 #include <glib-object.h>
 
+#include <droute/droute.h>
+
 typedef struct _SpiRegistry SpiRegistry;
 typedef struct _SpiRegistryClass SpiRegistryClass;
 
@@ -50,7 +52,8 @@ struct _SpiRegistryClass {
 };
 
 GType        spi_registry_get_type (void);
-SpiRegistry *spi_registry_new      (DBusConnection *bus);
+SpiRegistry *spi_registry_new      (DBusConnection *bus,
+                                    DRouteContext  *droute);
 
 G_END_DECLS
 
index 23ddb35..65936aa 100644 (file)
@@ -88,7 +88,7 @@
                        </arg>
                </method>
 
-               <signal name="updateTree">
+               <signal name="updateAccessible">
                        <tp:docstring xmlns="http://www.w3.org/1999/xhtml">
                                <p>Updates all mirrors. Re-sends all all the 
                                accessible objects that have changed since the last
                                        <p>Array of Accessible Object proxy structures to be added.</p>
                                </tp:docstring>
                        </arg>
-                       <arg name="nodesRemoved" type="ao">
+               </signal>
+
+               <signal name="removeAccessible">
+                       <arg name="nodeRemoved" type="o">
                                <tp:docstring xmlns="http://www.w3.org/1999/xhtml">
-                                       <p>Array of Accessible Object proxy structures to be removed.</p>
+                                       <p>Accessible Object proxy structure to be removed.</p>
                                </tp:docstring>
                        </arg>
                </signal>