2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2007 IBM Corp.
6 * Copyright 2010, 2011 Novell, Inc.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
24 #include "atspi-private.h"
26 /* TODO: Improve documentation and implement some missing functions */
29 * atspi_collection_is_ancestor_of:
31 * @collection: A pointer to the #AtspiCollection to test against.
32 * @test: The #AtspiAccessible to test.
34 * Not yet implemented.
36 * Returns: TRUE if @collection is an ancestor of @test; FALSE otherwise.
40 atspi_collection_is_ancestor_of (AtspiCollection *collection,
41 AtspiAccessible *test,
44 g_warning ("Atspi: TODO: Implement is_ancestor_of");
49 new_message (AtspiCollection *collection, char *method)
51 AtspiAccessible *accessible;
56 accessible = ATSPI_ACCESSIBLE (collection);
57 return dbus_message_new_method_call (accessible->parent.app->bus_name,
58 accessible->parent.path,
59 atspi_interface_collection,
64 append_match_rule (DBusMessage *message, AtspiMatchRule *rule)
68 dbus_message_iter_init_append (message, &iter);
69 return _atspi_match_rule_marshal (rule, &iter);
73 append_accessible (DBusMessage *message, AtspiAccessible *accessible)
77 dbus_message_iter_init_append (message, &iter);
78 dbus_message_iter_append_basic (&iter, DBUS_TYPE_OBJECT_PATH,
79 &accessible->parent.path);
80 return TRUE; /* TODO: Check for out-of-memory */
84 return_accessibles (DBusMessage *message)
86 DBusMessageIter iter, iter_array;
87 GArray *ret = g_array_new (TRUE, TRUE, sizeof (AtspiAccessible *));
89 _ATSPI_DBUS_CHECK_SIG (message, "a(so)", NULL, NULL);
91 dbus_message_iter_init (message, &iter);
92 dbus_message_iter_recurse (&iter, &iter_array);
94 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
96 AtspiAccessible *accessible;
98 accessible = _atspi_dbus_return_accessible_from_iter (&iter_array);
99 new_array = g_array_append_val (ret, accessible);
102 /* Iter was moved already, so no need to call dbus_message_iter_next */
104 dbus_message_unref (message);
109 * atspi_collection_get_matches:
111 * @collection: A pointer to the #AtspiCollection to query.
112 * @rule: An #AtspiMatchRule describing the match criteria.
113 * @sortby: An #AtspiCollectionSortOrder specifying the way the results are to
115 * @count: The maximum number of results to return, or 0 for no limit.
118 * Returns: (element-type AtspiAccessible*) (transfer full): A #GArray of
119 * #AtspiAccessibles matching the given match rule.
122 atspi_collection_get_matches (AtspiCollection *collection,
123 AtspiMatchRule *rule,
124 AtspiCollectionSortOrder sortby,
129 DBusMessage *message = new_message (collection, "GetMatches");
131 dbus_int32_t d_sortby = sortby;
132 dbus_int32_t d_count = count;
133 dbus_bool_t d_traverse = traverse;
138 if (!append_match_rule (message, rule))
140 dbus_message_append_args (message, DBUS_TYPE_UINT32, &d_sortby,
141 DBUS_TYPE_INT32, &d_count,
142 DBUS_TYPE_BOOLEAN, &d_traverse,
144 reply = _atspi_dbus_send_with_reply_and_block (message, error);
147 return return_accessibles (reply);
151 * atspi_collection_get_matches_to:
153 * @collection: A pointer to the #AtspiCollection to query.
154 * @current_object: The object at which to start searching.
155 * @rule: An #AtspiMatchRule describing the match criteria.
156 * @sortby: An #AtspiCollectionSortOrder specifying the way the results are to
158 * @tree: An #AtspiCollectionTreeTraversalType specifying restrictions on
159 * the objects to be traversed.
161 * @count: The maximum number of results to return, or 0 for no limit.
164 * Returns: (element-type AtspiAccessible*) (transfer full): A #GArray of
165 * #AtspiAccessibles matching the given match rule after
169 atspi_collection_get_matches_to (AtspiCollection *collection,
170 AtspiAccessible *current_object,
171 AtspiMatchRule *rule,
172 AtspiCollectionSortOrder sortby,
173 AtspiCollectionTreeTraversalType tree,
179 DBusMessage *message = new_message (collection, "GetMatchesTo");
181 dbus_int32_t d_sortby = sortby;
182 dbus_int32_t d_tree = tree;
183 dbus_bool_t d_recurse = recurse;
184 dbus_int32_t d_count = count;
185 dbus_bool_t d_traverse = traverse;
190 if (!append_accessible (message, current_object))
192 if (!append_match_rule (message, rule))
194 dbus_message_append_args (message, DBUS_TYPE_UINT32, &d_sortby,
195 DBUS_TYPE_UINT32, &d_tree,
196 DBUS_TYPE_BOOLEAN, &d_recurse,
197 DBUS_TYPE_INT32, &d_count,
198 DBUS_TYPE_BOOLEAN, &d_traverse,
200 reply = _atspi_dbus_send_with_reply_and_block (message, error);
203 return return_accessibles (reply);
207 * atspi_collection_get_matches_from:
209 * @collection: A pointer to the #AtspiCollection to query.
210 * @current_object: Upon reaching this object, searching should stop.
211 * @rule: An #AtspiMatchRule describing the match criteria.
212 * @sortby: An #AtspiCollectionSortOrder specifying the way the results are to
214 * @tree: An #AtspiCollectionTreeTraversalType specifying restrictions on
215 * the objects to be traversed.
216 * @count: The maximum number of results to return, or 0 for no limit.
219 * Returns: (element-type AtspiAccessible*) (transfer full): A #GArray of
220 * #AtspiAccessibles matching the given match rule that preceed
224 atspi_collection_get_matches_from (AtspiCollection *collection,
225 AtspiAccessible *current_object,
226 AtspiMatchRule *rule,
227 AtspiCollectionSortOrder sortby,
228 AtspiCollectionTreeTraversalType tree,
233 DBusMessage *message = new_message (collection, "GetMatchesFrom");
235 dbus_int32_t d_sortby = sortby;
236 dbus_int32_t d_tree = tree;
237 dbus_int32_t d_count = count;
238 dbus_bool_t d_traverse = traverse;
243 if (!append_accessible (message, current_object))
245 if (!append_match_rule (message, rule))
247 dbus_message_append_args (message, DBUS_TYPE_UINT32, &d_sortby,
248 DBUS_TYPE_UINT32, &d_tree,
249 DBUS_TYPE_INT32, &d_count,
250 DBUS_TYPE_BOOLEAN, &d_traverse,
252 reply = _atspi_dbus_send_with_reply_and_block (message, error);
255 return return_accessibles (reply);
259 * atspi_collection_get_active_descendant:
261 @collection: A pointer to the #AtspiCollection to query.
263 * Returns: (transfer full): The active descendant of #collection.
265 * Not yet implemented.
268 atspi_collection_get_active_descendant (AtspiCollection *collection, GError **error)
270 g_warning ("atspi: TODO: Implement get_active_descendants");
275 atspi_collection_base_init (AtspiCollection *klass)
280 atspi_collection_get_type (void)
282 static GType type = 0;
285 static const GTypeInfo tinfo =
287 sizeof (AtspiCollection),
288 (GBaseInitFunc) atspi_collection_base_init,
289 (GBaseFinalizeFunc) NULL,
292 type = g_type_register_static (G_TYPE_INTERFACE, "AtspiCollection", &tinfo, 0);