*/
#include <string.h>
+#include <ctype.h>
#include <atk/atk.h>
#include <droute/droute.h>
+#include <atspi/atspi.h>
#include "bridge.h"
#include "accessible-register.h"
#include "common/spi-dbus.h"
+#include "event.h"
+#include "object.h"
static GArray *listener_ids = NULL;
static void
switch_main_context (GMainContext *cnx)
{
-#ifndef DISABLE_P2P
-/* This code won't work on dbus-glib earlier than 0.9.0 because of FDO#30574 */
GList *list;
- dbus_server_setup_with_g_main (spi_global_app_data->server, cnx);
- dbus_connection_setup_with_g_main (spi_global_app_data->bus, cnx);
- for (list = spi_global_app_data->direct_connections; list; list = list->next)
- dbus_connection_setup_with_g_main (list->data, cnx);
+#ifndef DISABLE_P2P
+ atspi_dbus_server_setup_with_g_main (spi_global_app_data->server, cnx);
#endif
+ atspi_dbus_connection_setup_with_g_main (spi_global_app_data->bus, cnx);
+ for (list = spi_global_app_data->direct_connections; list; list = list->next)
+ atspi_dbus_connection_setup_with_g_main (list->data, cnx);
}
static void
}
static const void *
-replace_null (const gint type,
+validate_for_dbus (const gint type,
const void *val)
{
switch (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:
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);
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';
}
}
+#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]);
void (*append_variant) (DBusMessageIter *, const char *, const void *))
{
DBusConnection *bus = spi_global_app_data->bus;
- const char *path = spi_register_object_to_path (spi_global_register,
- G_OBJECT (obj));
+ const char *path;
gchar *cname, *t;
DBusMessage *sig;
if (!signal_is_needed (klass, major, minor))
return;
+ path = spi_register_object_to_path (spi_global_register, G_OBJECT (obj));
+
/*
* This is very annoying, but as '-' isn't a legal signal
* name in D-Bus (Why not??!?) The names need converting
spi_object_lease_if_needed (G_OBJECT (obj));
g_free(cname);
+ g_free (path);
}
/*---------------------------------------------------------------------------*/
/*
* Handles the ATK signal 'Gtk:AtkText:text-changed' and
* converts it to the AT-SPI signal - 'object:text-changed'
+ * This signal is deprecated by Gtk:AtkText:text-insert
+ * and Gtk:AtkText:text-remove
*
*/
static gboolean
emit_event (accessible, ITF_EVENT_OBJECT, name, minor, detail1, detail2,
DBUS_TYPE_STRING_AS_STRING, selected, append_basic);
+ g_free (selected);
+
+ return TRUE;
+}
+
+/*
+ * Handles the ATK signal 'Gtk:AtkText:text-insert' and
+ * converts it to the AT-SPI signal - 'object:text-changed'
+ *
+ */
+static gboolean
+text_insert_event_listener (GSignalInvocationHint * signal_hint,
+ guint n_param_values,
+ const GValue * param_values, gpointer data)
+{
+ AtkObject *accessible;
+ guint text_changed_signal_id;
+ GSignalQuery signal_query;
+ const gchar *name;
+ gchar *minor, *text;
+ gint detail1, detail2;
+
+ accessible = ATK_OBJECT (g_value_get_object (¶m_values[0]));
+ /* Get signal name for 'Gtk:AtkText:text-changed' so
+ * we convert it to the AT-SPI signal - 'object:text-changed'
+ */
+ text_changed_signal_id = g_signal_lookup ("text-changed", G_OBJECT_TYPE (accessible));
+ g_signal_query (text_changed_signal_id, &signal_query);
+ name = signal_query.signal_name;
+
+
+ /* Add the insert and keep any detail coming from atk */
+ minor = g_quark_to_string (signal_hint->detail);
+ if (minor)
+ minor = g_strconcat ("insert:", minor, NULL);
+ else
+ minor = g_strdup ("insert");
+
+ if (G_VALUE_TYPE (¶m_values[1]) == G_TYPE_INT)
+ detail1 = g_value_get_int (¶m_values[1]);
+
+ if (G_VALUE_TYPE (¶m_values[2]) == G_TYPE_INT)
+ detail2 = g_value_get_int (¶m_values[2]);
+
+ if (G_VALUE_TYPE (¶m_values[3]) == G_TYPE_STRING)
+ text = g_value_get_string (¶m_values[3]);
+
+ emit_event (accessible, ITF_EVENT_OBJECT, name, minor, detail1, detail2,
+ DBUS_TYPE_STRING_AS_STRING, text, append_basic);
+ g_free (minor);
return TRUE;
}
+/*
+ * Handles the ATK signal 'Gtk:AtkText:text-remove' and
+ * converts it to the AT-SPI signal - 'object:text-changed'
+ *
+ */
+static gboolean
+text_remove_event_listener (GSignalInvocationHint * signal_hint,
+ guint n_param_values,
+ const GValue * param_values, gpointer data)
+{
+ AtkObject *accessible;
+ guint text_changed_signal_id;
+ GSignalQuery signal_query;
+ const gchar *name;
+ gchar *minor, *text;
+ gint detail1, detail2;
+
+ accessible = ATK_OBJECT (g_value_get_object (¶m_values[0]));
+ /* Get signal name for 'Gtk:AtkText:text-changed' so
+ * we convert it to the AT-SPI signal - 'object:text-changed'
+ */
+ text_changed_signal_id = g_signal_lookup ("text-changed", G_OBJECT_TYPE (accessible));
+ g_signal_query (text_changed_signal_id, &signal_query);
+ name = signal_query.signal_name;
+
+ minor = g_quark_to_string (signal_hint->detail);
+
+ /* Add the delete and keep any detail coming from atk */
+ minor = g_quark_to_string (signal_hint->detail);
+ if (minor)
+ minor = g_strconcat ("delete:", minor, NULL);
+ else
+ minor = g_strdup ("delete");
+
+ if (G_VALUE_TYPE (¶m_values[1]) == G_TYPE_INT)
+ detail1 = g_value_get_int (¶m_values[1]);
+
+ if (G_VALUE_TYPE (¶m_values[2]) == G_TYPE_INT)
+ detail2 = g_value_get_int (¶m_values[2]);
+
+ if (G_VALUE_TYPE (¶m_values[3]) == G_TYPE_STRING)
+ text = g_value_get_string (¶m_values[3]);
+
+ emit_event (accessible, ITF_EVENT_OBJECT, name, minor, detail1, detail2,
+ DBUS_TYPE_STRING_AS_STRING, text, append_basic);
+ g_free (minor);
+ return TRUE;
+}
+
+
/*---------------------------------------------------------------------------*/
/*
"Gtk:AtkText:text-selection-changed");
add_signal_listener (text_changed_event_listener,
"Gtk:AtkText:text-changed");
+ add_signal_listener (text_insert_event_listener,
+ "Gtk:AtkText:text-insert");
+ add_signal_listener (text_remove_event_listener,
+ "Gtk:AtkText:text-remove");
add_signal_listener (link_selected_event_listener,
"Gtk:AtkHypertext:link-selected");
add_signal_listener (generic_event_listener,