2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2002 Ximian Inc.
6 * Copyright 2002 Sun Microsystems, Inc.
7 * Copyright 2010, 2011 Novell, Inc.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
25 #include "atspi-private.h"
26 #include "atspi-accessible-private.h"
32 AtspiEventListenerCB callback;
34 GDestroyNotify callback_destroyed;
42 G_DEFINE_TYPE (AtspiEventListener, atspi_event_listener, G_TYPE_OBJECT)
45 atspi_event_listener_init (AtspiEventListener *listener)
50 atspi_event_listener_class_init (AtspiEventListenerClass *klass)
55 remove_datum (AtspiEvent *event, void *user_data)
57 AtspiEventListenerSimpleCB cb = user_data;
64 GDestroyNotify callback_destroyed;
67 static GHashTable *callbacks;
70 callback_ref (void *callback, GDestroyNotify callback_destroyed)
76 callbacks = g_hash_table_new (g_direct_hash, g_direct_equal);
81 info = g_hash_table_lookup (callbacks, callback);
84 info = g_new (CallbackInfo, 1);
85 info->callback = callback;
86 info->callback_destroyed = callback_destroyed;
88 g_hash_table_insert (callbacks, callback, info);
95 callback_unref (gpointer callback)
101 info = g_hash_table_lookup (callbacks, callback);
104 g_warning ("Atspi: Dereferencing invalid callback %p\n", callback);
108 if (info->ref_count == 0)
111 /* TODO: Figure out why this seg faults from Python */
112 if (info->callback_destroyed)
113 (*info->callback_destroyed) (info->callback);
116 g_hash_table_remove (callbacks, callback);
121 * atspi_event_listener_new:
122 * @callback: (scope notified): An #AtspiEventListenerCB to be called
123 * when an event is fired.
124 * @user_data: (closure): data to pass to the callback.
125 * @callback_destroyed: A #GDestroyNotify called when the listener is freed
126 * and data associated with the callback should be freed. Can be NULL.
128 * Creates a new #AtspiEventListener associated with a specified @callback.
130 * Returns: (transfer full): A new #AtspiEventListener.
133 atspi_event_listener_new (AtspiEventListenerCB callback,
135 GDestroyNotify callback_destroyed)
137 AtspiEventListener *listener = g_object_new (ATSPI_TYPE_EVENT_LISTENER, NULL);
138 listener->callback = callback;
139 callback_ref (callback, callback_destroyed);
140 listener->user_data = user_data;
141 listener->cb_destroyed = callback_destroyed;
146 * atspi_event_listener_new_simple: (skip)
147 * @callback: (scope notified): An #AtspiEventListenerSimpleCB to be called
148 * when an event is fired.
149 * @callback_destroyed: A #GDestroyNotify called when the listener is freed
150 * and data associated with the callback should be freed. Can be NULL.
152 * Creates a new #AtspiEventListener associated with a specified @callback.
153 * Returns: (transfer full): A new #AtspiEventListener.
156 atspi_event_listener_new_simple (AtspiEventListenerSimpleCB callback,
157 GDestroyNotify callback_destroyed)
159 AtspiEventListener *listener = g_object_new (ATSPI_TYPE_EVENT_LISTENER, NULL);
160 listener->callback = remove_datum;
161 callback_ref (remove_datum, callback_destroyed);
162 listener->user_data = callback;
163 listener->cb_destroyed = callback_destroyed;
167 static GList *event_listeners = NULL;
170 convert_name_from_dbus (const char *name, gboolean path_hack)
172 gchar *ret = g_malloc (g_utf8_strlen (name, -1) * 2 + 1);
173 const char *p = name;
185 *q++ = tolower (*p++);
187 else if (path_hack && *p == '/')
200 cache_process_children_changed (AtspiEvent *event)
202 AtspiAccessible *child;
204 if (!G_VALUE_HOLDS (&event->any_data, ATSPI_TYPE_ACCESSIBLE) ||
205 !(event->source->cached_properties & ATSPI_CACHE_CHILDREN) ||
206 atspi_state_set_contains (event->source->states, ATSPI_STATE_MANAGES_DESCENDANTS))
209 child = g_value_get_object (&event->any_data);
211 if (!strncmp (event->type, "object:children-changed:add", 27))
213 if (g_list_find (event->source->children, child))
215 event->source->children = g_list_insert (event->source->children,
216 g_object_ref (child),
219 else if (g_list_find (event->source->children, child))
221 event->source->children = g_list_remove (event->source->children, child);
222 if (child == child->parent.app->root)
223 g_object_run_dispose (G_OBJECT (child->parent.app));
224 g_object_unref (child);
229 cache_process_property_change (AtspiEvent *event)
231 if (!strcmp (event->type, "object:property-change:accessible-parent"))
233 if (event->source->accessible_parent)
234 g_object_unref (event->source->accessible_parent);
235 if (G_VALUE_HOLDS (&event->any_data, ATSPI_TYPE_ACCESSIBLE))
237 event->source->accessible_parent = g_value_dup_object (&event->any_data);
238 _atspi_accessible_add_cache (event->source, ATSPI_CACHE_PARENT);
242 event->source->accessible_parent = NULL;
243 event->source->cached_properties &= ~ATSPI_CACHE_PARENT;
246 else if (!strcmp (event->type, "object:property-change:accessible-name"))
248 if (event->source->name)
249 g_free (event->source->name);
250 if (G_VALUE_HOLDS_STRING (&event->any_data))
252 event->source->name = g_value_dup_string (&event->any_data);
253 _atspi_accessible_add_cache (event->source, ATSPI_CACHE_NAME);
257 event->source->name = NULL;
258 event->source->cached_properties &= ~ATSPI_CACHE_NAME;
261 else if (!strcmp (event->type, "object:property-change:accessible-description"))
263 if (event->source->description)
264 g_free (event->source->description);
265 if (G_VALUE_HOLDS_STRING (&event->any_data))
267 event->source->description = g_value_dup_string (&event->any_data);
268 _atspi_accessible_add_cache (event->source, ATSPI_CACHE_DESCRIPTION);
272 event->source->description = NULL;
273 event->source->cached_properties &= ~ATSPI_CACHE_DESCRIPTION;
276 else if (!strcmp (event->type, "object:property-change:accessible-role"))
278 if (G_VALUE_HOLDS_INT (&event->any_data))
280 event->source->role = g_value_get_int (&event->any_data);
281 _atspi_accessible_add_cache (event->source, ATSPI_CACHE_ROLE);
285 event->source->cached_properties &= ~ATSPI_CACHE_ROLE;
291 cache_process_state_changed (AtspiEvent *event)
293 if (event->source->states)
294 atspi_state_set_set_by_name (event->source->states, event->type + 21,
299 demarshal_rect (DBusMessageIter *iter, AtspiRect *rect)
301 dbus_int32_t x, y, width, height;
302 DBusMessageIter iter_struct;
304 dbus_message_iter_recurse (iter, &iter_struct);
305 if (dbus_message_iter_get_arg_type (&iter_struct) != DBUS_TYPE_INT32) return FALSE;
306 dbus_message_iter_get_basic (&iter_struct, &x);
307 dbus_message_iter_next (&iter_struct);
308 if (dbus_message_iter_get_arg_type (&iter_struct) != DBUS_TYPE_INT32) return FALSE;
309 dbus_message_iter_get_basic (&iter_struct, &y);
310 dbus_message_iter_next (&iter_struct);
311 if (dbus_message_iter_get_arg_type (&iter_struct) != DBUS_TYPE_INT32) return FALSE;
312 dbus_message_iter_get_basic (&iter_struct, &width);
313 dbus_message_iter_next (&iter_struct);
314 if (dbus_message_iter_get_arg_type (&iter_struct) != DBUS_TYPE_INT32) return FALSE;
315 dbus_message_iter_get_basic (&iter_struct, &height);
319 rect->height = height;
324 strdup_and_adjust_for_dbus (const char *s)
326 gchar *d = g_strdup (s);
337 memmove (p, p + 1, g_utf8_strlen (p, -1));
345 p [1] = toupper (p [1]);
349 d [0] = toupper (d [0]);
354 convert_event_type_to_dbus (const char *eventType, char **categoryp, char **namep, char **detailp, GPtrArray **matchrule_array)
356 gchar *tmp = strdup_and_adjust_for_dbus (eventType);
357 char *category = NULL, *name = NULL, *detail = NULL;
358 char *saveptr = NULL;
360 if (tmp == NULL) return FALSE;
361 category = strtok_r (tmp, ":", &saveptr);
362 if (category) category = g_strdup (category);
363 name = strtok_r (NULL, ":", &saveptr);
366 name = g_strdup (name);
367 detail = strtok_r (NULL, ":", &saveptr);
368 if (detail) detail = g_strdup (detail);
373 matchrule = g_strdup_printf ("type='signal',interface='org.a11y.atspi.Event.%s'", category);
374 if (name && name [0])
376 gchar *new_str = g_strconcat (matchrule, ",member='", name, "'", NULL);
380 (*matchrule_array) = g_ptr_array_new ();
381 if (detail && detail [0])
383 gchar *new_str = g_strconcat (matchrule, ",arg0='", detail, "'", NULL);
384 g_ptr_array_add (*matchrule_array, new_str);
385 new_str = g_strconcat (matchrule, ",arg0path='", detail, "/'", NULL);
386 g_ptr_array_add (*matchrule_array, new_str);
390 g_ptr_array_add (*matchrule_array, matchrule);
392 if (categoryp) *categoryp = category;
393 else g_free (category);
394 if (namep) *namep = name;
395 else if (name) g_free (name);
396 if (detailp) *detailp = detail;
397 else if (detail) g_free (detail);
403 listener_entry_free (EventListenerEntry *e)
405 gpointer callback = (e->callback == remove_datum ? (gpointer)e->user_data : (gpointer)e->callback);
406 g_free (e->event_type);
407 g_free (e->category);
409 if (e->detail) g_free (e->detail);
410 callback_unref (callback);
415 * atspi_event_listener_register:
416 * @listener: The #AtspiEventListener to register against an event type.
417 * @event_type: a character string indicating the type of events for which
418 * notification is requested. Format is
419 * EventClass:major_type:minor_type:detail
420 * where all subfields other than EventClass are optional.
421 * EventClasses include "object", "window", "mouse",
422 * and toolkit events (e.g. "Gtk", "AWT").
423 * Examples: "focus:", "Gtk:GtkWidget:button_press_event".
425 * Adds an in-process callback function to an existing #AtspiEventListener.
427 * Legal object event types:
429 * (property change events)
431 * object:property-change
432 * object:property-change:accessible-name
433 * object:property-change:accessible-description
434 * object:property-change:accessible-parent
435 * object:property-change:accessible-value
436 * object:property-change:accessible-role
437 * object:property-change:accessible-table-caption
438 * object:property-change:accessible-table-column-description
439 * object:property-change:accessible-table-column-header
440 * object:property-change:accessible-table-row-description
441 * object:property-change:accessible-table-row-header
442 * object:property-change:accessible-table-summary
444 * (other object events)
446 * object:state-changed
447 * object:children-changed
448 * object:visible-data-changed
449 * object:selection-changed
450 * object:text-selection-changed
451 * object:text-changed
452 * object:text-caret-moved
453 * object:row-inserted
454 * object:row-reordered
456 * object:column-inserted
457 * object:column-reordered
458 * object:column-deleted
459 * object:model-changed
460 * object:active-descendant-changed
470 * window:desktop-create
471 * window:desktop-destroy
494 * NOTE: this character string may be UTF-8, but should not contain byte
496 * (ascii ':'), except as a delimiter, since non-UTF-8 string
497 * delimiting functions are used internally.
498 * In general, listening to
499 * toolkit-specific events is not recommended.
502 * Returns: #TRUE if successful, otherwise #FALSE.
505 atspi_event_listener_register (AtspiEventListener *listener,
506 const gchar *event_type,
509 /* TODO: Keep track of which events have been registered, so that we
510 * deregister all of them when the event listener is destroyed */
512 return atspi_event_listener_register_from_callback (listener->callback,
514 listener->cb_destroyed,
519 * atspi_event_listener_register_full:
520 * @listener: The #AtspiEventListener to register against an event type.
521 * @event_type: a character string indicating the type of events for which
522 * notification is requested. See #atspi_event_listener_register
523 * for a description of the format and legal event types.
524 * @properties: (element-type gchar*) (transfer none) (allow-none): a list of
525 * properties that should be sent along with the event. The
526 * properties are valued for the duration of the event callback.k
529 * Adds an in-process callback function to an existing #AtspiEventListener.
531 * Returns: #TRUE if successful, otherwise #FALSE.
534 atspi_event_listener_register_full (AtspiEventListener *listener,
535 const gchar *event_type,
539 /* TODO: Keep track of which events have been registered, so that we
540 * deregister all of them when the event listener is destroyed */
542 return atspi_event_listener_register_from_callback_full (listener->callback,
544 listener->cb_destroyed,
551 notify_event_registered (EventListenerEntry *e)
555 dbind_method_call_reentrant (_atspi_bus (), atspi_bus_registry,
557 atspi_interface_registry,
559 NULL, "sas", e->event_type,
562 dbind_method_call_reentrant (_atspi_bus (), atspi_bus_registry,
564 atspi_interface_registry,
566 NULL, "s", e->event_type);
572 * atspi_event_listener_register_from_callback:
573 * @callback: (scope notified): the #AtspiEventListenerCB to be registered
574 * against an event type.
575 * @user_data: (closure): User data to be passed to the callback.
576 * @callback_destroyed: A #GDestroyNotify called when the callback is destroyed.
577 * @event_type: a character string indicating the type of events for which
578 * notification is requested. See #atspi_event_listener_register
579 * for a description of the format.
581 * Registers an #AtspiEventListenerCB against an @event_type.
583 * Returns: #TRUE if successfull, otherwise #FALSE.
587 atspi_event_listener_register_from_callback (AtspiEventListenerCB callback,
589 GDestroyNotify callback_destroyed,
590 const gchar *event_type,
593 return atspi_event_listener_register_from_callback_full (callback,
601 copy_event_properties (GArray *src)
605 GArray *dst = g_array_new (FALSE, FALSE, sizeof (char *));
609 for (i = 0; i < src->len; i++)
611 gchar *dup = g_strdup (g_array_index (src, char *, i));
612 g_array_append_val (dst, dup);
618 atspi_event_listener_register_from_callback_full (AtspiEventListenerCB callback,
620 GDestroyNotify callback_destroyed,
621 const gchar *event_type,
625 EventListenerEntry *e;
627 GPtrArray *matchrule_array;
637 g_warning ("called atspi_event_listener_register_from_callback with a NULL event_type");
641 e = g_new (EventListenerEntry, 1);
642 e->event_type = g_strdup (event_type);
643 e->callback = callback;
644 e->user_data = user_data;
645 e->callback_destroyed = callback_destroyed;
646 callback_ref (callback == remove_datum ? (gpointer)user_data : (gpointer)callback,
648 if (!convert_event_type_to_dbus (event_type, &e->category, &e->name, &e->detail, &matchrule_array))
653 e->properties = copy_event_properties (properties);
654 event_listeners = g_list_prepend (event_listeners, e);
655 for (i = 0; i < matchrule_array->len; i++)
657 char *matchrule = g_ptr_array_index (matchrule_array, i);
658 dbus_error_init (&d_error);
659 dbus_bus_add_match (_atspi_bus(), matchrule, &d_error);
660 if (dbus_error_is_set (&d_error))
662 g_warning ("Atspi: Adding match: %s", d_error.message);
663 dbus_error_free (&d_error);
664 /* TODO: Set error */
669 g_ptr_array_free (matchrule_array, TRUE);
671 notify_event_registered (e);
676 _atspi_reregister_event_listeners ()
679 EventListenerEntry *e;
681 for (l = event_listeners; l; l = l->next)
684 notify_event_registered (e);
689 * atspi_event_listener_register_no_data: (skip)
690 * @callback: (scope notified): the #AtspiEventListenerSimpleCB to be
691 * registered against an event type.
692 * @callback_destroyed: A #GDestroyNotify called when the callback is destroyed.
693 * @event_type: a character string indicating the type of events for which
694 * notification is requested. Format is
695 * EventClass:major_type:minor_type:detail
696 * where all subfields other than EventClass are optional.
697 * EventClasses include "object", "window", "mouse",
698 * and toolkit events (e.g. "Gtk", "AWT").
699 * Examples: "focus:", "Gtk:GtkWidget:button_press_event".
701 * Registers an #AtspiEventListenetSimpleCB. The method is similar to
702 * #atspi_event_listener_register, but @callback takes no user_data.
704 * Returns: #TRUE if successfull, otherwise #FALSE.
707 atspi_event_listener_register_no_data (AtspiEventListenerSimpleCB callback,
708 GDestroyNotify callback_destroyed,
709 const gchar *event_type,
712 return atspi_event_listener_register_from_callback (remove_datum, callback,
718 is_superset (const gchar *super, const gchar *sub)
720 if (!super || !super [0])
722 return (strcmp (super, sub) == 0);
726 * atspi_event_listener_deregister:
727 * @listener: The #AtspiEventListener to deregister.
728 * @event_type: a string specifying the event type for which this
729 * listener is to be deregistered.
731 * Deregisters an #AtspiEventListener from the registry, for a specific
734 * Returns: #TRUE if successful, otherwise #FALSE.
737 atspi_event_listener_deregister (AtspiEventListener *listener,
738 const gchar *event_type,
741 return atspi_event_listener_deregister_from_callback (listener->callback,
747 * atspi_event_listener_deregister_from_callback:
748 * @callback: (scope call): the #AtspiEventListenerCB registered against an
750 * @user_data: (closure): User data that was passed in for this callback.
751 * @event_type: a string specifying the event type for which this
752 * listener is to be deregistered.
754 * Deregisters an #AtspiEventListenerCB from the registry, for a specific
757 * Returns: #TRUE if successful, otherwise #FALSE.
760 atspi_event_listener_deregister_from_callback (AtspiEventListenerCB callback,
762 const gchar *event_type,
765 char *category, *name, *detail;
766 GPtrArray *matchrule_array;
769 gboolean result = TRUE;
771 if (!convert_event_type_to_dbus (event_type, &category, &name, &detail, &matchrule_array))
780 for (l = event_listeners; l;)
782 EventListenerEntry *e = l->data;
783 if (e->callback == callback &&
784 e->user_data == user_data &&
785 is_superset (category, e->category) &&
786 is_superset (name, e->name) &&
787 is_superset (detail, e->detail))
789 gboolean need_replace;
790 DBusMessage *message, *reply;
791 need_replace = (l == event_listeners);
792 l = g_list_remove (l, e);
795 for (i = 0; i < matchrule_array->len; i++)
797 char *matchrule = g_ptr_array_index (matchrule_array, i);
798 dbus_bus_remove_match (_atspi_bus(), matchrule, NULL);
800 message = dbus_message_new_method_call (atspi_bus_registry,
802 atspi_interface_registry,
808 dbus_message_append_args (message, DBUS_TYPE_STRING, &event_type, DBUS_TYPE_INVALID);
809 reply = _atspi_dbus_send_with_reply_and_block (message, error);
811 dbus_message_unref (reply);
813 listener_entry_free (e);
815 else l = g_list_next (l);
819 if (detail) g_free (detail);
820 for (i = 0; i < matchrule_array->len; i++)
821 g_free (g_ptr_array_index (matchrule_array, i));
822 g_ptr_array_free (matchrule_array, TRUE);
827 * atspi_event_listener_deregister_no_data: (skip)
828 * @callback: (scope call): the #AtspiEventListenerSimpleCB registered against
830 * @event_type: a string specifying the event type for which this
831 * listener is to be deregistered.
833 * deregisters an #AtspiEventListenerSimpleCB from the registry, for a specific
836 * Returns: #TRUE if successful, otherwise #FALSE.
839 atspi_event_listener_deregister_no_data (AtspiEventListenerSimpleCB callback,
840 const gchar *event_type,
843 return atspi_event_listener_deregister_from_callback (remove_datum, callback,
849 atspi_event_copy (AtspiEvent *src)
851 AtspiEvent *dst = g_new0 (AtspiEvent, 1);
852 dst->type = g_strdup (src->type);
853 dst->source = g_object_ref (src->source);
854 dst->detail1 = src->detail1;
855 dst->detail2 = src->detail2;
856 g_value_init (&dst->any_data, G_VALUE_TYPE (&src->any_data));
857 g_value_copy (&src->any_data, &dst->any_data);
862 atspi_event_free (AtspiEvent *event)
864 g_object_unref (event->source);
865 g_free (event->type);
866 g_value_unset (&event->any_data);
871 detail_matches_listener (const char *event_detail, const char *listener_detail)
873 if (!listener_detail)
879 return !(listener_detail [strcspn (listener_detail, ":")] == '\0'
880 ? strncmp (listener_detail, event_detail,
881 strcspn (event_detail, ":"))
882 : strcmp (listener_detail, event_detail));
886 _atspi_send_event (AtspiEvent *e)
888 char *category, *name, *detail;
890 GList *called_listeners = NULL;
892 /* Ensure that the value is set to avoid a Python exception */
893 /* TODO: Figure out how to do this without using a private field */
894 if (e->any_data.g_type == 0)
896 g_value_init (&e->any_data, G_TYPE_INT);
897 g_value_set_int (&e->any_data, 0);
900 if (!convert_event_type_to_dbus (e->type, &category, &name, &detail, NULL))
902 g_warning ("Atspi: Couldn't parse event: %s\n", e->type);
905 for (l = event_listeners; l; l = g_list_next (l))
907 EventListenerEntry *entry = l->data;
908 if (!strcmp (category, entry->category) &&
909 (entry->name == NULL || !strcmp (name, entry->name)) &&
910 detail_matches_listener (detail, entry->detail))
913 for (l2 = called_listeners; l2; l2 = l2->next)
915 EventListenerEntry *e2 = l2->data;
916 if (entry->callback == e2->callback && entry->user_data == e2->user_data)
921 entry->callback (atspi_event_copy (e), entry->user_data);
922 called_listeners = g_list_prepend (called_listeners, entry);
926 if (detail) g_free (detail);
929 g_list_free (called_listeners);
933 _atspi_dbus_handle_event (DBusConnection *bus, DBusMessage *message, void *data)
936 const char *category = dbus_message_get_interface (message);
937 const char *member = dbus_message_get_member (message);
938 const char *signature = dbus_message_get_signature (message);
940 gchar *converted_type;
941 DBusMessageIter iter, iter_variant;
942 dbus_message_iter_init (message, &iter);
944 dbus_int32_t detail1, detail2;
946 GHashTable *cache = NULL;
948 if (strcmp (signature, "siiv(so)") != 0 &&
949 strcmp (signature, "siiva{sv}") != 0)
951 g_warning ("Got invalid signature %s for signal %s from interface %s\n", signature, member, category);
952 return DBUS_HANDLER_RESULT_HANDLED;
955 memset (&e, 0, sizeof (e));
960 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
963 category = g_utf8_strrchr (category, -1, '.');
964 if (category == NULL)
967 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
971 dbus_message_iter_get_basic (&iter, &detail);
972 dbus_message_iter_next (&iter);
973 dbus_message_iter_get_basic (&iter, &detail1);
975 dbus_message_iter_next (&iter);
976 dbus_message_iter_get_basic (&iter, &detail2);
978 dbus_message_iter_next (&iter);
980 converted_type = convert_name_from_dbus (category, FALSE);
981 name = convert_name_from_dbus (member, FALSE);
982 detail = convert_name_from_dbus (detail, TRUE);
984 if (strcasecmp (category, name) != 0)
986 p = g_strconcat (converted_type, ":", name, NULL);
987 g_free (converted_type);
990 else if (detail [0] == '\0')
992 p = g_strconcat (converted_type, ":", NULL);
993 g_free (converted_type);
997 if (detail[0] != '\0')
999 p = g_strconcat (converted_type, ":", detail, NULL);
1000 g_free (converted_type);
1003 e.type = converted_type;
1004 e.source = _atspi_ref_accessible (dbus_message_get_sender(message), dbus_message_get_path(message));
1005 if (e.source == NULL)
1007 g_warning ("Got no valid source accessible for signal for signal %s from interface %s\n", member, category);
1008 g_free (converted_type);
1011 return DBUS_HANDLER_RESULT_HANDLED;
1014 dbus_message_iter_recurse (&iter, &iter_variant);
1015 switch (dbus_message_iter_get_arg_type (&iter_variant))
1017 case DBUS_TYPE_STRUCT:
1020 if (demarshal_rect (&iter_variant, &rect))
1022 g_value_init (&e.any_data, ATSPI_TYPE_RECT);
1023 g_value_set_boxed (&e.any_data, &rect);
1027 AtspiAccessible *accessible;
1028 accessible = _atspi_dbus_return_accessible_from_iter (&iter_variant);
1029 g_value_init (&e.any_data, ATSPI_TYPE_ACCESSIBLE);
1030 g_value_set_instance (&e.any_data, accessible);
1032 g_object_unref (accessible); /* value now owns it */
1036 case DBUS_TYPE_STRING:
1038 dbus_message_iter_get_basic (&iter_variant, &p);
1039 g_value_init (&e.any_data, G_TYPE_STRING);
1040 g_value_set_string (&e.any_data, p);
1047 dbus_message_iter_next (&iter);
1048 if (dbus_message_iter_get_arg_type (&iter) == DBUS_TYPE_ARRAY)
1050 /* new form -- parse properties sent with event */
1051 cache = _atspi_dbus_update_cache_from_dict (e.source, &iter);
1054 if (!strncmp (e.type, "object:children-changed", 23))
1056 cache_process_children_changed (&e);
1058 else if (!strncmp (e.type, "object:property-change", 22))
1060 cache_process_property_change (&e);
1062 else if (!strncmp (e.type, "object:state-changed", 20))
1064 cache_process_state_changed (&e);
1066 else if (!strncmp (e.type, "focus", 5))
1068 /* BGO#663992 - TODO: figure out the real problem */
1069 e.source->cached_properties &= ~(ATSPI_CACHE_STATES);
1072 _atspi_send_event (&e);
1075 _atspi_accessible_unref_cache (e.source);
1077 g_free (converted_type);
1080 g_object_unref (e.source);
1081 g_value_unset (&e.any_data);
1082 return DBUS_HANDLER_RESULT_HANDLED;
1085 G_DEFINE_BOXED_TYPE (AtspiEvent, atspi_event, atspi_event_copy, atspi_event_free)