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

1  2 
cspi/spi-main.c
registryd/deviceeventcontroller.c

diff --combined cspi/spi-main.c
@@@ -93,6 -93,7 +93,7 @@@ static const char *interfaces[] 
    SPI_DBUS_INTERFACE_ACCESSIBLE,
    SPI_DBUS_INTERFACE_ACTION,
    SPI_DBUS_INTERFACE_APPLICATION,
+   SPI_DBUS_INTERFACE_COLLECTION,
    SPI_DBUS_INTERFACE_COMPONENT,
    SPI_DBUS_INTERFACE_DOCUMENT,
    SPI_DBUS_INTERFACE_EDITABLE_TEXT,
@@@ -218,7 -219,8 +219,8 @@@ cspi_object_unref_internal (Accessible 
      {
        g_free (accessible->v.path);
      }
-     spi_state_set_cache_unref (accessible->states);
+     if (accessible->states)
+       spi_state_set_cache_unref (accessible->states);
      g_free (accessible->description);
      g_free (accessible->name);
      g_free(accessible);
@@@ -377,7 -379,7 +379,7 @@@ handle_additions (CSpiApplication*app, 
      a->states = spi_state_set_cache_new (ca->state_bitflags);
      g_array_free (ca->interfaces, TRUE);
      g_array_free (ca->children, TRUE);
-     g_array_free (ca->state_bitflags, TRUE);
+     /* spi_state_set_cache_new frees state_bitflags */
      /* This is a bit of a hack since ref_accessible sets ref_count to 2
       * for a new object, one of the refs being for the cache */
      cspi_object_unref (a);
@@@ -413,7 -415,7 +415,7 @@@ add_app_to_desktop (Accessible *a, cons
    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)
@@@ -505,7 -507,7 +507,7 @@@ ref_accessible_desktop (CSpiApplicatio
    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);
    }
      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);
@@@ -556,7 -558,7 +558,7 @@@ typedef struc
    GArray *removals;
  } CacheSignalData;
  
- static const char *cacheSignalType = "a(ooaoassus)ao";
+ static const char *cacheSignalType = "a(ooaoassusau)ao";
  
  static DBusHandlerResult
  cspi_dbus_handle_update_tree (DBusConnection *bus, DBusMessage *message, void *user_data)
@@@ -631,7 -633,7 +633,7 @@@ cspi_dbus_filter (DBusConnection *bus, 
    char *bus_name;
  
    if (type == DBUS_MESSAGE_TYPE_SIGNAL &&
-       !strcmp (interface, SPI_DBUS_INTERFACE_ACCESSIBLE))
+       !strncmp (interface, "org.freedesktop.atspi.Event.", 28))
    {
      return cspi_dbus_handle_event (bus, message, data);
    }
    {
      return cspi_dbus_handle_update_tree (bus, message, data);
    }
-   if (dbus_message_is_signal (message, spi_interface_tree, "registerApplication"))
+   if (dbus_message_is_method_call (message, spi_interface_registry, "registerApplication"))
    {
      return cspi_dbus_handle_register_application (bus, message, data);
    }
-   if (dbus_message_is_signal (message, spi_interface_registry, "deregisterApplication"))
+   if (dbus_message_is_method_call (message, spi_interface_registry, "deregisterApplication"))
    {
      return cspi_dbus_handle_deregister_application (bus, message, data);
    }
    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
  }
  
+ static const char *signal_interfaces[] =
+ {
+   "org.freedesktop.atspi.Event.Object",
+   "org.freedesktop.atspi.Event.Window",
+   "org.freedesktop.atspi.Event.Mouse",
+   "org.freedesktop.atspi.Event.Terminal",
+   "org.freedesktop.atspi.Event.Document",
+   "org.freedesktop.atspi.Event.Focus",
+   NULL
+ };
  /**
   * SPI_init:
   *
@@@ -666,6 -679,7 +679,7 @@@ SPI_init (void
  {
    DBusError error;
    char *match;
+   int i;
  
    if (SPI_inited)
      {
    dbus_error_init (&error);
    dbus_bus_add_match (bus, match, &error);
    g_free (match);
-   match = g_strdup_printf ("type='signal',interface='%s'", spi_interface_tree);
+   match = g_strdup_printf ("type='method_call',interface='%s'", spi_interface_registry);
    dbus_bus_add_match (bus, match, &error);
    g_free (match);
+   for (i = 0; signal_interfaces[i]; i++)
+   {
+     match = g_strdup_printf ("type='signal',interface='%s'", signal_interfaces[i]);
+     dbus_bus_add_match (bus, match, &error);
+     g_free (match);
+   }
    return 0;
  }
  
@@@ -1019,7 -1039,7 +1039,7 @@@ cspi_dbus_call (Accessible *obj, const 
    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))
  #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"
  
@@@ -341,14 -342,25 +341,14 @@@ spi_dec_clear_unlatch_pending (SpiDECon
      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
@@@ -356,7 -368,7 +356,7 @@@ spi_dec_button_update_and_emit (SpiDECo
                                guint mask_return)
  {
    Accessibility_DeviceEvent mouse_e;
-   gchar event_name[24];
+   gchar event_detail[24];
    gboolean is_consumed = FALSE;
  
    if ((mask_return & mouse_button_mask) !=
        fprintf (stderr, "Button %d %s\n",
                 button_number, (is_down) ? "Pressed" : "Released");
  #endif
-       snprintf (event_name, 22, "mouse:button:%d%c", button_number,
+       snprintf (event_detail, 22, "%d%c", button_number,
                  (is_down) ? 'p' : 'r');
        /* TODO: FIXME distinguish between physical and 
         * logical buttons 
        if (!is_consumed)
          {
            dbus_uint32_t x = last_mouse_pos->x, y = last_mouse_pos->y;
-           emit(controller, event_name, DBUS_TYPE_UINT32, &x, DBUS_TYPE_UINT32, &y, DBUS_TYPE_INVALID);
+           emit(controller, SPI_DBUS_INTERFACE_EVENT_MOUSE, "button", event_detail, x, y);
          }
        else
          spi_dec_set_unlatch_pending (controller, mask_return);
@@@ -499,10 -511,10 +499,10 @@@ spi_dec_mouse_check (SpiDEController *c
      {
        // TODO: combine these two signals?
        dbus_uint32_t ix = *x, iy = *y;
-       emit(controller, "mouse_abs", DBUS_TYPE_UINT32, &ix, DBUS_TYPE_UINT32, &iy, DBUS_TYPE_INVALID);
+       emit(controller, SPI_DBUS_INTERFACE_EVENT_MOUSE, "abs", NULL, ix, iy);
        ix -= last_mouse_pos->x;
        iy -= last_mouse_pos->y;
-       emit(controller, "mouse_rel", DBUS_TYPE_UINT32, &ix, DBUS_TYPE_UINT32, &iy, DBUS_TYPE_INVALID);
+       emit(controller, SPI_DBUS_INTERFACE_EVENT_MOUSE, "rel", NULL, ix, iy);
        last_mouse_pos->x = *x;
        last_mouse_pos->y = *y;
        *moved = True;
@@@ -534,7 -546,7 +534,7 @@@ spi_dec_emit_modifier_event (SpiDEContr
  
    d1 = prev_mask & key_modifier_mask;
    d2 = current_mask & key_modifier_mask;
-       emit(controller, "keyboard_modifiers", DBUS_TYPE_UINT32, &d1, DBUS_TYPE_UINT32, &d2, DBUS_TYPE_INVALID);
+       emit(controller, SPI_DBUS_INTERFACE_EVENT_KEYBOARD, "modifiers", NULL, d1, d2);
  }
  
  static gboolean
@@@ -912,7 -924,7 +912,7 @@@ spi_controller_register_device_listene
  
        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);    
        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;
@@@ -945,7 -957,7 +945,7 @@@ Accessibility_DeviceEventListener_notif
    {
      // 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;
@@@ -1026,7 -1038,7 +1026,7 @@@ spi_device_event_controller_forward_mou
                                                 XEvent *xevent)
  {
    Accessibility_DeviceEvent mouse_e;
-   gchar event_name[24];
+   gchar event_detail[24];
    gboolean is_consumed = FALSE;
    gboolean xkb_mod_unlatch_occurred;
    XButtonEvent *xbutton_event = (XButtonEvent *) xevent;
           (xevent->type == ButtonPress) ? "Press" : "Release",
           mouse_button_state);
  #endif
-   snprintf (event_name, 22, "mouse:button_%d%c", button,
+   snprintf (event_detail, 22, "%d%c", button,
            (xevent->type == ButtonPress) ? 'p' : 'r');
  
    /* TODO: FIXME distinguish between physical and logical buttons */
        ix = last_mouse_pos->x;
        iy = last_mouse_pos->y;
        /* TODO - Work out which part of the spec this emit is fulfilling */
-       //emit(controller, event_name, DBUS_TYPE_UINT32, &ix, DBUS_TYPE_UINT32, &iy, DBUS_TYPE_INVALID);
+       //emit(controller, SPI_DBUS_INTERFACE_EVENT_MOUSE, "button", event_detail, ix, iy);
      }
  
    xkb_mod_unlatch_occurred = (xevent->type == ButtonPress ||
@@@ -1914,7 -1926,7 +1914,7 @@@ spi_controller_deregister_device_listen
  {
    RemoveListenerClosure  ctx;
  
 -  ctx.bus = controller->droute->bus;
 +  ctx.bus = controller->bus;
    ctx.listener = listener;
  
    spi_re_entrant_list_foreach (&controller->mouse_listeners,
@@@ -1927,7 -1939,7 +1927,7 @@@ spi_deregister_controller_key_listener 
  {
    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 */
@@@ -2686,6 -2698,36 +2686,6 @@@ static void wait_for_release_event (XEv
    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" },
    { 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 */