Remove libxml2 check from configure.ac
[platform/core/uifw/at-spi2-atk.git] / atk-adaptor / event.c
index f9f78f2..69de709 100644 (file)
@@ -39,38 +39,55 @@ static gint atk_bridge_focus_tracker_id;
 
 /*---------------------------------------------------------------------------*/
 
-#define ITF_EVENT_OBJECT   "org.freedesktop.atspi.Event.Object"
-#define ITF_EVENT_WINDOW   "org.freedesktop.atspi.Event.Window"
-#define ITF_EVENT_DOCUMENT "org.freedesktop.atspi.Event.Document"
-#define ITF_EVENT_FOCUS    "org.freedesktop.atspi.Event.Focus"
+#define ITF_EVENT_OBJECT   "org.a11y.atspi.Event.Object"
+#define ITF_EVENT_WINDOW   "org.a11y.atspi.Event.Window"
+#define ITF_EVENT_DOCUMENT "org.a11y.atspi.Event.Document"
+#define ITF_EVENT_FOCUS    "org.a11y.atspi.Event.Focus"
 
 /*---------------------------------------------------------------------------*/
 
+typedef struct _SpiReentrantCallClosure 
+{
+  GMainLoop   *loop;
+  DBusMessage *reply;
+} SpiReentrantCallClosure;
+
 static void
 set_reply (DBusPendingCall * pending, void *user_data)
 {
-  void **replyptr = (void **) user_data;
+  SpiReentrantCallClosure* closure = (SpiReentrantCallClosure *) user_data; 
 
-  *replyptr = dbus_pending_call_steal_reply (pending);
+  closure->reply = dbus_pending_call_steal_reply (pending);
+  g_main_loop_quit (closure->loop);
 }
 
 static DBusMessage *
 send_and_allow_reentry (DBusConnection * bus, DBusMessage * message)
 {
   DBusPendingCall *pending;
-  DBusMessage *reply = NULL;
+  SpiReentrantCallClosure closure;
 
   if (!dbus_connection_send_with_reply (bus, message, &pending, -1))
-    {
       return NULL;
+  dbus_pending_call_set_notify (pending, set_reply, (void *) &closure, NULL);
+  closure.loop = g_main_loop_new (NULL, FALSE);
+
+  if (getenv ("AT_SPI_CLIENT"))
+    {
+      g_main_loop_run  (closure.loop);
     }
-  dbus_pending_call_set_notify (pending, set_reply, (void *) &reply, NULL);
-  while (!reply)
+  else
     {
-      if (!dbus_connection_read_write_dispatch (bus, -1))
-        return NULL;
+      closure.reply = NULL;
+      while (!closure.reply)
+        {
+          if (!dbus_connection_read_write_dispatch (spi_global_app_data->bus, 1000))
+            return NULL;
+        }
     }
-  return reply;
+  
+  g_main_loop_unref (closure.loop);
+  return closure.reply;
 }
 
 /*---------------------------------------------------------------------------*/
@@ -258,6 +275,23 @@ append_object (DBusMessageIter *iter,
   spi_object_append_v_reference (iter, ATK_OBJECT (val));
 }
 
+static gchar *
+signal_name_to_dbus (const gchar *s)
+{
+  gchar *ret = g_strdup (s);
+  gchar *t;
+
+  if (!ret)
+    return NULL;
+  ret [0] = toupper (ret [0]);
+  while ((t = strchr (ret, '-')) != NULL)
+  {
+    memmove (t, t + 1, strlen (t));
+    *t = toupper (*t);
+  }
+  return ret;
+}
+
 /*
  * Emits an AT-SPI event.
  * AT-SPI events names are split into three parts:
@@ -297,19 +331,17 @@ emit_event (AtkObject  *obj,
    * name in D-Bus (Why not??!?) The names need converting
    * on this side, and again on the client side.
    */
-  cname = g_strdup(major);
-  while ((t = strchr(cname, '-')) != NULL) *t = '_';
+  cname = signal_name_to_dbus (major);
   sig = dbus_message_new_signal(path, klass, cname);
   g_free(cname);
 
   dbus_message_iter_init_append(sig, &iter);
 
-  spi_object_append_reference (&iter, spi_global_app_data->root);
   dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &minor);
   dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &detail1);
   dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &detail2);
-
   append_variant (&iter, type, val);
+  spi_object_append_reference (&iter, spi_global_app_data->root);
 
   dbus_connection_send(bus, sig, NULL);
   dbus_message_unref(sig);
@@ -330,7 +362,7 @@ focus_tracker (AtkObject * accessible)
 
 /*---------------------------------------------------------------------------*/
 
-#define PCHANGE "property_change"
+#define PCHANGE "PropertyChange"
 
 /* 
  * This handler handles the following ATK signals and
@@ -369,21 +401,27 @@ property_event_listener (GSignalInvocationHint * signal_hint,
         emit_event (accessible, ITF_EVENT_OBJECT, PCHANGE, pname, 0, 0,
                     DBUS_TYPE_STRING_AS_STRING, s1, append_basic);
     }
-  if (strcmp (pname, "accessible-description") == 0)
+  else if (strcmp (pname, "accessible-description") == 0)
     {
       s1 = atk_object_get_description (accessible);
       if (s1 != NULL)
         emit_event (accessible, ITF_EVENT_OBJECT, PCHANGE, pname, 0, 0,
                     DBUS_TYPE_STRING_AS_STRING, s1, append_basic);
     }
-  if (strcmp (pname, "accessible-parent") == 0)
+  else if (strcmp (pname, "accessible-parent") == 0)
     {
       otemp = atk_object_get_parent (accessible);
       if (otemp != NULL)
         emit_event (accessible, ITF_EVENT_OBJECT, PCHANGE, pname, 0, 0,
                     "(so)", otemp, append_object);
     }
-  if (strcmp (pname, "accessible-table-summary") == 0)
+  else if (strcmp (pname, "accessible-role") == 0)
+    {
+      i = atk_object_get_role (accessible);
+      emit_event (accessible, ITF_EVENT_OBJECT, PCHANGE, pname, 0, 0,
+                    DBUS_TYPE_UINT32_AS_STRING, GINT_TO_POINTER(i), append_basic);
+    }
+  else if (strcmp (pname, "accessible-table-summary") == 0)
     {
       otemp = atk_table_get_summary (ATK_TABLE (accessible));
       if (otemp != NULL)
@@ -575,7 +613,6 @@ active_descendant_event_listener (GSignalInvocationHint * signal_hint,
   AtkObject *child;
   GSignalQuery signal_query;
   const gchar *name, *minor;
-  gchar *s;
   gint detail1;
 
   g_signal_query (signal_hint->signal_id, &signal_query);
@@ -590,7 +627,6 @@ active_descendant_event_listener (GSignalInvocationHint * signal_hint,
 
   emit_event (accessible, ITF_EVENT_OBJECT, name, "", detail1, 0,
               "(so)", child, append_object);
-  g_free (s);
   return TRUE;
 }
 
@@ -703,7 +739,7 @@ text_selection_changed_event_listener (GSignalInvocationHint * signal_hint,
 /*
  * Children changed signal converter and forwarder.
  *
- * Klass (Interface) org.freedesktop.atspi.Event.Object
+ * Klass (Interface) org.a11y.atspi.Event.Object
  * Major is the signal name.
  * Minor is 'add' or 'remove'
  * detail1 is the index.
@@ -719,7 +755,7 @@ children_changed_event_listener (GSignalInvocationHint * signal_hint,
   const gchar *name, *minor;
   gint detail1, detail2 = 0;
 
-  AtkObject *accessible, *ao;
+  AtkObject *accessible, *ao=NULL;
   gpointer child;
 
   g_signal_query (signal_hint->signal_id, &signal_query);
@@ -776,7 +812,7 @@ toplevel_removed_event_listener (AtkObject * accessible,
 /*
  * Generic signal converter and forwarder.
  *
- * Klass (Interface) org.freedesktop.atspi.Event.Object
+ * Klass (Interface) org.a11y.atspi.Event.Object
  * Major is the signal name.
  * Minor is NULL.
  * detail1 is 0.