Removed the extra boolean parameter added to know when to unref the
[platform/core/uifw/at-spi2-atk.git] / atk-adaptor / event.c
index 0a523af..3babc2f 100644 (file)
@@ -39,10 +39,10 @@ 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"
 
 /*---------------------------------------------------------------------------*/
 
@@ -72,7 +72,19 @@ send_and_allow_reentry (DBusConnection * bus, DBusMessage * message)
   dbus_pending_call_set_notify (pending, set_reply, (void *) &closure, NULL);
   closure.loop = g_main_loop_new (NULL, FALSE);
 
-  g_main_loop_run  (closure.loop);
+  if (getenv ("AT_SPI_CLIENT"))
+    {
+      g_main_loop_run  (closure.loop);
+    }
+  else
+    {
+      closure.reply = NULL;
+      while (!closure.reply)
+        {
+          if (!dbus_connection_read_write_dispatch (spi_global_app_data->bus, 1000))
+            return NULL;
+        }
+    }
   
   g_main_loop_unref (closure.loop);
   return closure.reply;
@@ -325,15 +337,17 @@ emit_event (AtkObject  *obj,
 
   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);
+
+  if (g_strcmp0 (cname, "ChildrenChanged") != 0)
+    spi_object_lease_if_needed (G_OBJECT (obj));
 }
 
 /*---------------------------------------------------------------------------*/
@@ -351,7 +365,7 @@ focus_tracker (AtkObject * accessible)
 
 /*---------------------------------------------------------------------------*/
 
-#define PCHANGE "property_change"
+#define PCHANGE "PropertyChange"
 
 /* 
  * This handler handles the following ATK signals and
@@ -390,21 +404,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)
@@ -596,7 +616,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);
@@ -611,7 +630,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;
 }
 
@@ -724,7 +742,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.
@@ -740,7 +758,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);
@@ -797,7 +815,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.