Always emit children-changed, property-change, and state-changed events
[platform/core/uifw/at-spi2-atk.git] / atk-adaptor / event.c
index d489a13..a616879 100644 (file)
@@ -228,7 +228,7 @@ convert_signal_name (const gchar * s)
 }
 
 static const void *
-replace_null (const gint type,
+validate_for_dbus (const gint type,
               const void *val)
 {
   switch (type)
@@ -237,6 +237,11 @@ replace_null (const gint type,
       case DBUS_TYPE_OBJECT_PATH:
           if (!val)
              return "";
+          else if (!g_utf8_validate (val, -1, NULL))
+             {
+              g_warning ("atk-bridge: Received bad UTF-8 string when emitting event");
+              return "";
+               }
           else
              return val;
       default:
@@ -253,7 +258,7 @@ append_basic (DBusMessageIter *iter,
 
   dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, type, &sub);
 
-    val = replace_null ((int) *type, val);
+    val = validate_for_dbus ((int) *type, val);
     dbus_message_iter_append_basic(&sub, (int) *type, &val);
 
   dbus_message_iter_close_container(iter, &sub);
@@ -358,6 +363,19 @@ signal_is_needed (const gchar *klass, const gchar *major, const gchar *minor)
   data [2] = ensure_proper_format (minor);
   data [3] = NULL;
 
+  /* Hack: Always pass events that update the cache.
+   * TODO: FOr 2.2, have at-spi2-core define a special "cache listener" for
+   * this instead, so that we don't send these if no one is listening */
+  if (!g_strcmp0 (data [1], "ChildrenChanged") ||
+      !g_strcmp0 (data [1], "PropertyChange") ||
+      !g_strcmp0 (data [1], "StateChanged"))
+  {
+    g_free (data [2]);
+    g_free (data [1]);
+    g_free (data [0]);
+    return TRUE;
+  }
+
   /* Hack: events such as "object::text-changed::insert:system" as
      generated by Gecko */
   data [2][strcspn (data [2], ":")] = '\0';
@@ -371,7 +389,9 @@ signal_is_needed (const gchar *klass, const gchar *major, const gchar *minor)
         }
     }
 
-//printf("event: %s %s %s: %d\n", data[0], data[1], data[2], ret);
+#if 0
+  g_print("event: %s %s %s: %d\n", data[0], data[1], data[2], ret);
+#endif
   g_free (data [2]);
   g_free (data [1]);
   g_free (data [0]);