2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2007 IBM Corp.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 /* collection.c: implements the Collection interface */
28 #include <droute/droute.h>
30 #include "accessible-register.h"
31 #include "accessible-marshaller.h"
33 #include "common/bitarray.h"
34 #include "common/spi-dbus.h"
35 #include "common/spi-stateset.h"
37 typedef struct _MatchRulePrivate MatchRulePrivate;
38 struct _MatchRulePrivate
41 Accessibility_Collection_MatchType statematchtype;
42 AtkAttributeSet *attributes;
43 Accessibility_Collection_MatchType attributematchtype;
45 Accessibility_Collection_MatchType rolematchtype;
47 Accessibility_Collection_MatchType interfacematchtype;
52 child_interface_p (AtkObject * child, gchar * repo_id)
54 if (!strcasecmp (repo_id, "action"))
55 return atk_is_action (child);
56 if (!strcasecmp (repo_id, "component"))
57 return atk_is_component (child);
58 if (!strcasecmp (repo_id, "editabletext"))
59 return atk_is_editable_text (child);
60 if (!strcasecmp (repo_id, "text"))
61 return atk_is_text (child);
62 if (!strcasecmp (repo_id, "hypertext"))
63 return atk_is_hypertext (child);
64 if (!strcasecmp (repo_id, "image"))
65 return atk_is_image (child);
66 if (!strcasecmp (repo_id, "selection"))
67 return atk_is_selection (child);
68 if (!strcasecmp (repo_id, "table"))
69 return atk_is_table (child);
70 if (!strcasecmp (repo_id, "value"))
71 return atk_is_value (child);
72 if (!strcasecmp (repo_id, "streamablecontent"))
73 return atk_is_streamable_content (child);
74 if (!strcasecmp (repo_id, "document"))
75 return atk_is_document (child);
79 #define child_collection_p(ch) (TRUE)
82 match_states_all_p (AtkObject * child, gint * set)
91 chs = atk_object_ref_state_set (child);
93 // TODO: use atk-state_set_contains_states; would be more efficient
94 for (i = 0; set[i] != BITARRAY_SEQ_TERM; i++)
96 if (!atk_state_set_contains_state (chs, set[i]))
103 g_object_unref (chs);
108 match_states_any_p (AtkObject * child, gint * set)
112 gboolean ret = FALSE;
117 chs = atk_object_ref_state_set (child);
119 for (i = 0; set[i] != BITARRAY_SEQ_TERM; i++)
121 if (!atk_state_set_contains_state (chs, set[i]))
128 g_object_unref (chs);
133 match_states_none_p (AtkObject * child, gint * set)
142 chs = atk_object_ref_state_set (child);
144 for (i = 0; set[i] != BITARRAY_SEQ_TERM; i++)
146 if (atk_state_set_contains_state (chs, set[i]))
153 g_object_unref (chs);
157 // TODO: need to convert at-spi roles/states to atk roles/states */
159 match_states_lookup (AtkObject * child, MatchRulePrivate * mrp)
161 switch (mrp->statematchtype)
163 case Accessibility_Collection_MATCH_ALL:
164 if (match_states_all_p (child, mrp->states))
168 case Accessibility_Collection_MATCH_ANY:
169 if (match_states_any_p (child, mrp->states))
173 case Accessibility_Collection_MATCH_NONE:
174 if (match_states_none_p (child, mrp->states))
185 // TODO: Map at-spi -> atk roles at mrp creation instead of doing this;
186 // would be more efficient
187 #define spi_get_role(obj) spi_accessible_role_from_atk_role(atk_object_get_role(obj))
190 match_roles_all_p (AtkObject * child, gint * roles)
192 if (roles == NULL || roles[0] == BITARRAY_SEQ_TERM)
194 else if (roles[1] != BITARRAY_SEQ_TERM)
197 return (atk_object_get_role (child) == roles[0]);
202 match_roles_any_p (AtkObject * child, gint * roles)
204 Accessibility_Role role;
207 if (roles == NULL || roles[0] == BITARRAY_SEQ_TERM)
210 role = spi_accessible_role_from_atk_role (atk_object_get_role (child));
212 for (i = 0; roles[i] != BITARRAY_SEQ_TERM; i++)
213 if (role == roles[i])
220 match_roles_none_p (AtkObject * child, gint * roles)
225 if (roles == NULL || roles[0] == BITARRAY_SEQ_TERM)
228 role = atk_object_get_role (child);
230 for (i = 0; roles[i] != BITARRAY_SEQ_TERM; i++)
231 if (role == roles[i])
238 match_roles_lookup (AtkObject * child, MatchRulePrivate * mrp)
240 switch (mrp->rolematchtype)
242 case Accessibility_Collection_MATCH_ALL:
243 if (match_roles_all_p (child, mrp->roles))
247 case Accessibility_Collection_MATCH_ANY:
248 if (match_roles_any_p (child, mrp->roles))
252 case Accessibility_Collection_MATCH_NONE:
253 if (match_roles_none_p (child, mrp->roles))
265 match_interfaces_all_p (AtkObject * obj, gchar ** ifaces)
272 for (i = 0; ifaces[i]; i++)
273 if (!child_interface_p (obj, ifaces[i]))
281 match_interfaces_any_p (AtkObject * obj, gchar ** ifaces)
289 for (i = 0; ifaces[i]; i++)
290 if (child_interface_p (obj, ifaces[i]))
298 match_interfaces_none_p (AtkObject * obj, gchar ** ifaces)
302 for (i = 0; ifaces[i]; i++)
303 if (child_interface_p (obj, ifaces[i]))
310 match_interfaces_lookup (AtkObject * child, MatchRulePrivate * mrp)
312 switch (mrp->interfacematchtype)
315 case Accessibility_Collection_MATCH_ALL:
316 if (match_interfaces_all_p (child, mrp->ifaces))
320 case Accessibility_Collection_MATCH_ANY:
321 if (match_interfaces_any_p (child, mrp->ifaces))
325 case Accessibility_Collection_MATCH_NONE:
326 if (match_interfaces_none_p (child, mrp->ifaces))
337 #define split_attributes(attributes) (g_strsplit (attributes, ";", 0))
340 match_attributes_all_p (AtkObject * child, AtkAttributeSet * attributes)
344 gint length, oa_length;
345 gboolean flag = FALSE;
347 if (attributes == NULL || g_slist_length (attributes) == 0)
350 oa = atk_object_get_attributes (child);
351 length = g_slist_length (attributes);
352 oa_length = g_slist_length (oa);
354 for (i = 0; i < length; i++)
356 AtkAttribute *attr = g_slist_nth_data (attributes, i);
357 for (k = 0; k < oa_length; k++)
359 AtkAttribute *oa_attr = g_slist_nth_data (attributes, i);
360 if (!g_ascii_strcasecmp (oa_attr->name, attr->name) &&
361 !g_ascii_strcasecmp (oa_attr->value, attr->value))
371 atk_attribute_set_free (oa);
375 atk_attribute_set_free (oa);
380 match_attributes_any_p (AtkObject * child, AtkAttributeSet * attributes)
385 gint length, oa_length;
387 length = g_slist_length (attributes);
391 oa = atk_object_get_attributes (child);
392 oa_length = g_slist_length (oa);
394 for (i = 0; i < length; i++)
396 AtkAttribute *attr = g_slist_nth_data (attributes, i);
397 for (k = 0; k < oa_length; k++)
399 AtkAttribute *oa_attr = g_slist_nth_data (attributes, i);
400 if (!g_ascii_strcasecmp (oa_attr->name, attr->name) &&
401 !g_ascii_strcasecmp (oa_attr->value, attr->value))
403 atk_attribute_set_free (oa);
408 atk_attribute_set_free (oa);
413 match_attributes_none_p (AtkObject * child, AtkAttributeSet * attributes)
418 gint length, oa_length;
420 length = g_slist_length (attributes);
424 oa = atk_object_get_attributes (child);
425 oa_length = g_slist_length (oa);
427 for (i = 0; i < length; i++)
429 AtkAttribute *attr = g_slist_nth_data (attributes, i);
430 for (k = 0; k < oa_length; k++)
432 AtkAttribute *oa_attr = g_slist_nth_data (attributes, i);
433 if (!g_ascii_strcasecmp (oa_attr->name, attr->name) &&
434 !g_ascii_strcasecmp (oa_attr->value, attr->value))
436 atk_attribute_set_free (oa);
441 atk_attribute_set_free (oa);
446 match_attributes_lookup (AtkObject * child, MatchRulePrivate * mrp)
448 switch (mrp->attributematchtype)
451 case Accessibility_Collection_MATCH_ALL:
452 if (match_attributes_all_p (child, mrp->attributes))
456 case Accessibility_Collection_MATCH_ANY:
457 if (match_attributes_any_p (child, mrp->attributes))
461 case Accessibility_Collection_MATCH_NONE:
462 if (match_attributes_none_p (child, mrp->attributes))
473 traverse_p (AtkObject * child, const gboolean traverse)
478 return !child_collection_p (child);
482 sort_order_canonical (MatchRulePrivate * mrp, GList * ls,
483 gint kount, gint max,
484 AtkObject * obj, glong index, gboolean flag,
485 AtkObject * pobj, gboolean recurse, gboolean traverse)
488 glong acount = atk_object_get_n_accessible_children (obj);
489 gboolean prev = pobj ? TRUE : FALSE;
491 for (; i < acount && (max == 0 || kount < max); i++)
493 AtkObject *child = atk_object_ref_accessible_child (obj, i);
495 g_object_unref (child);
496 if (prev && child == pobj)
501 if (flag && match_interfaces_lookup (child, mrp)
502 && match_states_lookup (child, mrp)
503 && match_roles_lookup (child, mrp)
504 && match_attributes_lookup (child, mrp))
507 ls = g_list_append (ls, child);
514 if (recurse && traverse_p (child, traverse))
515 kount = sort_order_canonical (mrp, ls, kount,
517 pobj, recurse, traverse);
523 sort_order_rev_canonical (MatchRulePrivate * mrp, GList * ls,
524 gint kount, gint max,
525 AtkObject * obj, gboolean flag, AtkObject * pobj)
531 /* This breaks us out of the recursion. */
532 if (!obj || obj == pobj)
537 /* Add to the list if it matches */
538 if (flag && match_interfaces_lookup (obj, mrp)
539 && match_states_lookup (obj, mrp)
540 && match_roles_lookup (obj, mrp) && match_attributes_lookup (obj, mrp))
542 ls = g_list_append (ls, obj);
549 /* Get the current nodes index in it's parent and the parent object. */
550 indexinparent = atk_object_get_index_in_parent (obj);
551 parent = atk_object_get_parent (obj);
553 if (indexinparent > 0)
555 /* there are still some siblings to visit so get the previous sibling
556 and get it's last descendant.
557 First, get the previous sibling */
558 nextobj = atk_object_ref_accessible_child (parent, indexinparent - 1);
559 g_object_unref (nextobj);
561 /* Now, drill down the right side to the last descendant */
562 while (atk_object_get_n_accessible_children (nextobj) > 0)
564 nextobj = atk_object_ref_accessible_child (nextobj,
565 atk_object_get_n_accessible_children
567 g_object_unref (nextobj);
569 /* recurse with the last descendant */
570 kount = sort_order_rev_canonical (mrp, ls, kount, max,
571 nextobj, TRUE, pobj);
575 /* no more siblings so next node must be the parent */
576 kount = sort_order_rev_canonical (mrp, ls, kount, max,
584 query_exec (MatchRulePrivate * mrp, Accessibility_Collection_SortOrder sortby,
585 GList * ls, gint kount, gint max,
586 AtkObject * obj, glong index,
588 AtkObject * pobj, gboolean recurse, gboolean traverse)
592 case Accessibility_Collection_SORT_ORDER_CANONICAL:
593 kount = sort_order_canonical (mrp, ls, 0, max, obj, index, flag,
594 pobj, recurse, traverse);
596 case Accessibility_Collection_SORT_ORDER_REVERSE_CANONICAL:
597 kount = sort_order_canonical (mrp, ls, 0, max, obj, index, flag,
598 pobj, recurse, traverse);
602 g_warning ("Sort method not implemented yet");
610 bitarray_to_seq (int *array, int array_count, int **ret)
615 int *out = (int *) g_malloc (out_size * sizeof (int));
619 for (i = 0; i < array_count; i++)
621 for (j = 0; j < 32; j++)
623 if (array[i] & (1 << j))
625 if (out_count == out_size - 2)
628 out = (int *) g_realloc (out, out_size * sizeof (int));
632 out[out_count++] = i * 32 + j;
636 out[out_count] = BITARRAY_SEQ_TERM;
643 read_mr (DBusMessageIter * iter, MatchRulePrivate * mrp)
645 DBusMessageIter mrc, arrayc;
646 dbus_uint32_t *array;
647 dbus_int32_t matchType;
652 char *interfaces = NULL;
654 dbus_message_iter_recurse (iter, &mrc);
655 dbus_message_iter_recurse (&mrc, &arrayc);
656 dbus_message_iter_get_fixed_array (&arrayc, &array, &array_count);
657 bitarray_to_seq (array, array_count, &mrp->states);
658 for (i = 0; mrp->states[i] != BITARRAY_SEQ_TERM; i++)
660 mrp->states[i] = spi_atk_state_from_spi_state (mrp->states[i]);
662 dbus_message_iter_next (&mrc);
663 dbus_message_iter_get_basic (&mrc, &matchType);
664 dbus_message_iter_next (&mrc);
665 mrp->statematchtype = matchType;;
667 mrp->attributes = NULL;
668 if (dbus_message_iter_get_arg_type (&mrc) == DBUS_TYPE_STRING)
673 dbus_message_iter_get_basic (&mrc, &str);
674 attributes = g_strsplit (str, "\n", -1);
675 for (pp = attributes; *pp; pp++)
678 attr = g_new (AtkAttribute, 1);
681 int len = strcspn (str, ":");
682 attr->name = g_strndup (str, len);
688 attr->value = g_strdup (str + len);
692 mrp->attributes = g_slist_prepend (mrp->attributes, attr);
695 g_strfreev (attributes);
699 dbus_message_iter_recurse (&mrc, &arrayc);
700 while (dbus_message_iter_get_arg_type (&arrayc) != DBUS_TYPE_INVALID)
702 dbus_message_iter_get_basic (&arrayc, &str);
703 // TODO: remove this print
704 g_print ("Got attribute: %s\n", str);
705 attr = g_new (AtkAttribute, 1);
708 int len = strcspn (str, ":");
709 attr->name = g_strndup (str, len);
715 attr->value = g_strdup (str + len);
719 mrp->attributes = g_slist_prepend (mrp->attributes, attr);
721 dbus_message_iter_next (&arrayc);
724 dbus_message_iter_next (&mrc);
725 dbus_message_iter_get_basic (&mrc, &matchType);
726 mrp->attributematchtype = matchType;;
727 dbus_message_iter_next (&mrc);
728 /* Get roles and role match */
729 dbus_message_iter_recurse (&mrc, &arrayc);
730 dbus_message_iter_get_fixed_array (&arrayc, &array, &array_count);
731 bitarray_to_seq (array, array_count, &mrp->roles);
732 dbus_message_iter_next (&mrc);
733 dbus_message_iter_get_basic (&mrc, &matchType);
734 mrp->rolematchtype = matchType;;
735 dbus_message_iter_next (&mrc);
736 /* Get interfaces and interface match */
737 dbus_message_iter_get_basic (&mrc, &interfaces);
738 dbus_message_iter_next (&mrc);
739 mrp->ifaces = g_strsplit (interfaces, ";", 0);
740 dbus_message_iter_get_basic (&mrc, &matchType);
741 mrp->interfacematchtype = matchType;;
742 dbus_message_iter_next (&mrc);
744 dbus_message_iter_get_basic (&mrc, &mrp->invert);
745 dbus_message_iter_next (iter);
750 return_and_free_list (DBusMessage * message, GList * ls)
753 DBusMessageIter iter, iter_array;
756 reply = dbus_message_new_method_return (message);
759 dbus_message_iter_init_append (reply, &iter);
760 if (!dbus_message_iter_open_container
761 (&iter, DBUS_TYPE_ARRAY, "(so)", &iter_array))
763 for (item = ls; item; item = g_list_next (item))
765 spi_dbus_append_name_and_path (message, &iter_array,
766 ATK_OBJECT (item->data), TRUE, FALSE);
768 if (!dbus_message_iter_close_container (&iter, &iter_array))
773 // TODO: Handle out of memory
779 free_mrp_data (MatchRulePrivate * mrp)
781 g_free (mrp->states);
782 atk_attribute_set_free (mrp->attributes);
784 g_strfreev (mrp->ifaces);
788 GetMatchesFrom (DBusMessage * message,
789 AtkObject * current_object,
790 MatchRulePrivate * mrp,
791 const Accessibility_Collection_SortOrder sortby,
792 const dbus_bool_t isrestrict,
793 dbus_int32_t count, const dbus_bool_t traverse)
797 glong index = atk_object_get_index_in_parent (current_object);
800 ls = g_list_append (ls, current_object);
804 parent = atk_object_get_parent (current_object);
805 kount = query_exec (mrp, sortby, ls, 0, count, parent, index,
806 FALSE, NULL, TRUE, traverse);
809 kount = query_exec (mrp, sortby, ls, 0, count,
810 current_object, 0, FALSE, NULL, TRUE, traverse);
812 ls = g_list_remove (ls, ls->data);
814 if (sortby == Accessibility_Collection_SORT_ORDER_REVERSE_CANONICAL)
815 ls = g_list_reverse (ls);
818 return return_and_free_list (message, ls);
822 inorder traversal from a given object in the hierarchy
826 inorder (AtkObject * collection, MatchRulePrivate * mrp,
827 GList * ls, gint kount, gint max,
829 gboolean flag, AtkObject * pobj, dbus_bool_t traverse)
833 /* First, look through the children recursively. */
834 kount = sort_order_canonical (mrp, ls, kount, max, obj, 0, TRUE,
837 /* Next, we look through the right subtree */
838 while ((max == 0 || kount < max) && obj != collection)
840 AtkObject *parent = atk_object_get_parent (obj);
841 i = atk_object_get_index_in_parent (obj);
842 kount = sort_order_canonical (mrp, ls, kount, max, parent,
843 i + 1, TRUE, FALSE, TRUE, TRUE);
849 kount = sort_order_canonical (mrp, ls, kount, max,
850 obj, i + 1, TRUE, FALSE, TRUE, TRUE);
857 GetMatchesInOrder: get matches from a given object in an inorder traversal.
861 GetMatchesInOrder (DBusMessage * message,
862 AtkObject * current_object,
863 MatchRulePrivate * mrp,
864 const Accessibility_Collection_SortOrder sortby,
865 const dbus_bool_t recurse,
866 dbus_int32_t count, const dbus_bool_t traverse)
872 ls = g_list_append (ls, current_object);
874 obj = atk_dbus_path_to_object (dbus_message_get_path (message));
876 kount = inorder (obj, mrp, ls, 0, count,
877 current_object, TRUE, NULL, traverse);
879 ls = g_list_remove (ls, ls->data);
881 if (sortby == Accessibility_Collection_SORT_ORDER_REVERSE_CANONICAL)
882 ls = g_list_reverse (ls);
885 return return_and_free_list (message, ls);
889 GetMatchesInBackOrder: get matches from a given object in a
890 reverse order traversal.
894 GetMatchesInBackOrder (DBusMessage * message,
895 AtkObject * current_object,
896 MatchRulePrivate * mrp,
897 const Accessibility_Collection_SortOrder sortby,
901 AtkObject *collection;
904 ls = g_list_append (ls, current_object);
906 collection = atk_dbus_path_to_object (dbus_message_get_path (message));
908 kount = sort_order_rev_canonical (mrp, ls, 0, count, current_object,
911 ls = g_list_remove (ls, ls->data);
913 if (sortby == Accessibility_Collection_SORT_ORDER_REVERSE_CANONICAL)
914 ls = g_list_reverse (ls);
917 return return_and_free_list (message, ls);
921 GetMatchesTo (DBusMessage * message,
922 AtkObject * current_object,
923 MatchRulePrivate * mrp,
924 const Accessibility_Collection_SortOrder sortby,
925 const dbus_bool_t recurse,
926 const dbus_bool_t isrestrict,
927 dbus_int32_t count, const dbus_bool_t traverse)
932 ls = g_list_append (ls, current_object);
936 obj = atk_object_get_parent (current_object);
937 kount = query_exec (mrp, sortby, ls, 0, count,
938 obj, 0, TRUE, current_object, TRUE, traverse);
942 obj = atk_dbus_path_to_object (dbus_message_get_path (message));
943 kount = query_exec (mrp, sortby, ls, 0, count,
944 obj, 0, TRUE, current_object, TRUE, traverse);
948 ls = g_list_remove (ls, ls->data);
950 if (sortby != Accessibility_Collection_SORT_ORDER_REVERSE_CANONICAL)
951 ls = g_list_reverse (ls);
954 return return_and_free_list (message, ls);
958 impl_GetMatchesFrom (DBusConnection * bus, DBusMessage * message,
961 char *current_object_path = NULL;
962 AtkObject *current_object;
963 DBusMessageIter iter;
964 MatchRulePrivate rule;
965 dbus_uint32_t sortby;
968 dbus_bool_t traverse;
970 const char *signature;
972 signature = dbus_message_get_signature (message);
973 if (strcmp (signature, "o(aiisiaiisib)uuib") != 0 &&
974 strcmp (signature, "o(aii(as)iaiisib)uuib") != 0)
976 return droute_invalid_arguments_error (message);
979 dbus_message_iter_init (message, &iter);
980 dbus_message_iter_get_basic (&iter, ¤t_object_path);
981 current_object = atk_dbus_path_to_object (current_object_path);
984 // TODO: object-not-found error
985 return spi_dbus_general_error (message);
987 dbus_message_iter_next (&iter);
988 if (!read_mr (&iter, &rule))
990 return spi_dbus_general_error (message);
992 dbus_message_iter_get_basic (&iter, &sortby);
993 dbus_message_iter_next (&iter);
994 dbus_message_iter_get_basic (&iter, &tree);
995 dbus_message_iter_next (&iter);
996 dbus_message_iter_get_basic (&iter, &count);
997 dbus_message_iter_next (&iter);
998 dbus_message_iter_get_basic (&iter, &traverse);
999 dbus_message_iter_next (&iter);
1003 case Accessibility_Collection_TREE_RESTRICT_CHILDREN:
1004 return GetMatchesFrom (message, current_object,
1005 &rule, sortby, TRUE, count, traverse);
1007 case Accessibility_Collection_TREE_RESTRICT_SIBLING:
1008 return GetMatchesFrom (message, current_object,
1009 &rule, sortby, FALSE, count, traverse);
1011 case Accessibility_Collection_TREE_INORDER:
1012 return GetMatchesInOrder (message, current_object,
1013 &rule, sortby, TRUE, count, traverse);
1020 static DBusMessage *
1021 impl_GetMatchesTo (DBusConnection * bus, DBusMessage * message,
1024 char *current_object_path = NULL;
1025 AtkObject *current_object;
1026 DBusMessageIter iter;
1027 MatchRulePrivate rule;
1028 dbus_uint32_t sortby;
1030 dbus_bool_t recurse;
1032 dbus_bool_t traverse;
1034 const char *signature;
1036 signature = dbus_message_get_signature (message);
1037 if (strcmp (signature, "o(aiisiaiisib)uubib") != 0 &&
1038 strcmp (signature, "o(aii(as)iaiisib)uubib") != 0)
1040 return droute_invalid_arguments_error (message);
1043 dbus_message_iter_init (message, &iter);
1044 dbus_message_iter_get_basic (&iter, ¤t_object_path);
1045 current_object = atk_dbus_path_to_object (current_object_path);
1046 if (!current_object)
1048 // TODO: object-not-found error
1049 return spi_dbus_general_error (message);
1051 dbus_message_iter_next (&iter);
1052 if (!read_mr (&iter, &rule))
1054 return spi_dbus_general_error (message);
1056 dbus_message_iter_get_basic (&iter, &sortby);
1057 dbus_message_iter_next (&iter);
1058 dbus_message_iter_get_basic (&iter, &tree);
1059 dbus_message_iter_next (&iter);
1060 dbus_message_iter_get_basic (&iter, &recurse);
1061 dbus_message_iter_next (&iter);
1062 dbus_message_iter_get_basic (&iter, &count);
1063 dbus_message_iter_next (&iter);
1064 dbus_message_iter_get_basic (&iter, &traverse);
1065 dbus_message_iter_next (&iter);
1069 case Accessibility_Collection_TREE_RESTRICT_CHILDREN:
1070 return GetMatchesTo (message, current_object,
1071 &rule, sortby, recurse, TRUE, count, traverse);
1073 case Accessibility_Collection_TREE_RESTRICT_SIBLING:
1074 return GetMatchesTo (message, current_object,
1075 &rule, sortby, recurse, FALSE, count, traverse);
1077 case Accessibility_Collection_TREE_INORDER:
1078 return GetMatchesInBackOrder (message, current_object,
1079 &rule, sortby, count);
1086 static DBusMessage *
1087 impl_GetMatches (DBusConnection * bus, DBusMessage * message, void *user_data)
1089 AtkObject *obj = atk_dbus_path_to_object (dbus_message_get_path (message));
1090 DBusMessageIter iter;
1091 MatchRulePrivate rule;
1092 dbus_uint32_t sortby;
1094 dbus_bool_t traverse;
1096 const char *signature;
1098 signature = dbus_message_get_signature (message);
1099 if (strcmp (signature, "(aiisiaiisib)uib") != 0 &&
1100 strcmp (signature, "(aii(as)iaiisib)uib") != 0)
1102 return droute_invalid_arguments_error (message);
1105 dbus_message_iter_init (message, &iter);
1106 if (!read_mr (&iter, &rule))
1108 return spi_dbus_general_error (message);
1110 dbus_message_iter_get_basic (&iter, &sortby);
1111 dbus_message_iter_next (&iter);
1112 dbus_message_iter_get_basic (&iter, &count);
1113 dbus_message_iter_next (&iter);
1114 dbus_message_iter_get_basic (&iter, &traverse);
1115 dbus_message_iter_next (&iter);
1116 ls = g_list_prepend (ls, obj);
1117 count = query_exec (&rule, sortby, ls, 0, count,
1118 obj, 0, TRUE, NULL, TRUE, traverse);
1119 ls = g_list_remove (ls, ls->data);
1121 if (sortby == Accessibility_Collection_SORT_ORDER_REVERSE_CANONICAL)
1122 ls = g_list_reverse (ls);
1123 free_mrp_data (&rule);
1124 return return_and_free_list (message, ls);
1127 static DRouteMethod methods[] = {
1128 {impl_GetMatchesFrom, "GetMatchesFrom"},
1129 {impl_GetMatchesTo, "GetMatchesTo"},
1130 {impl_GetMatches, "GetMatches"},
1135 spi_initialize_collection (DRoutePath * path)
1137 droute_path_add_interface (path,
1138 SPI_DBUS_INTERFACE_COLLECTION, methods, NULL);