2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2008 Novell, Inc.
6 * Copyright 2001, 2002 Sun Microsystems Inc.,
7 * Copyright 2001, 2002 Ximian, 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.
26 #include <droute/droute.h>
31 #include "introspection.h"
34 impl_get_NActions (DBusMessageIter * iter, void *user_data)
36 AtkAction *action = (AtkAction *) user_data;
38 g_return_val_if_fail (ATK_IS_ACTION (user_data), FALSE);
39 return droute_return_v_int32 (iter, atk_action_get_n_actions (action));
43 impl_get_description (DBusConnection * bus, DBusMessage * message,
46 AtkAction *action = (AtkAction *) user_data;
51 g_return_val_if_fail (ATK_IS_ACTION (user_data),
52 droute_not_yet_handled_error (message));
53 if (!dbus_message_get_args
54 (message, NULL, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
56 return droute_invalid_arguments_error (message);
58 desc = atk_action_get_description (action, index);
61 reply = dbus_message_new_method_return (message);
64 dbus_message_append_args (reply, DBUS_TYPE_STRING, &desc,
71 impl_get_name (DBusConnection * bus, DBusMessage * message, void *user_data)
76 AtkAction *action = (AtkAction *) user_data;
78 g_return_val_if_fail (ATK_IS_ACTION (user_data),
79 droute_not_yet_handled_error (message));
80 if (!dbus_message_get_args
81 (message, NULL, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
83 return droute_invalid_arguments_error (message);
85 name = atk_action_get_name (action, index);
88 reply = dbus_message_new_method_return (message);
91 dbus_message_append_args (reply, DBUS_TYPE_STRING, &name,
98 impl_get_localized_name (DBusConnection * bus, DBusMessage * message, void *user_data)
103 AtkAction *action = (AtkAction *) user_data;
105 g_return_val_if_fail (ATK_IS_ACTION (user_data),
106 droute_not_yet_handled_error (message));
107 if (!dbus_message_get_args
108 (message, NULL, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
110 return droute_invalid_arguments_error (message);
112 name = atk_action_get_localized_name (action, index);
115 reply = dbus_message_new_method_return (message);
118 dbus_message_append_args (reply, DBUS_TYPE_STRING, &name,
125 impl_get_keybinding (DBusConnection * bus, DBusMessage * message,
131 AtkAction *action = (AtkAction *) user_data;
133 g_return_val_if_fail (ATK_IS_ACTION (user_data),
134 droute_not_yet_handled_error (message));
135 if (!dbus_message_get_args
136 (message, NULL, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
138 return droute_invalid_arguments_error (message);
140 kb = atk_action_get_keybinding (action, index);
143 reply = dbus_message_new_method_return (message);
146 dbus_message_append_args (reply, DBUS_TYPE_STRING, &kb,
153 impl_GetActions (DBusConnection * bus, DBusMessage * message, void *user_data)
155 AtkAction *action = (AtkAction *) user_data;
159 DBusMessageIter iter, iter_array, iter_struct;
161 g_return_val_if_fail (ATK_IS_ACTION (user_data),
162 droute_not_yet_handled_error (message));
163 count = atk_action_get_n_actions (action);
164 reply = dbus_message_new_method_return (message);
167 dbus_message_iter_init_append (reply, &iter);
168 if (!dbus_message_iter_open_container
169 (&iter, DBUS_TYPE_ARRAY, "(sss)", &iter_array))
171 for (i = 0; i < count; i++)
173 const char *name = atk_action_get_name (action, i);
174 const char *lname = atk_action_get_localized_name (action, i);
175 const char *desc = atk_action_get_description (action, i);
176 const char *kb = atk_action_get_keybinding (action, i);
185 if (!dbus_message_iter_open_container
186 (&iter_array, DBUS_TYPE_STRUCT, NULL, &iter_struct))
188 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &name);
189 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &lname);
190 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &desc);
191 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &kb);
192 if (!dbus_message_iter_close_container (&iter_array, &iter_struct))
195 if (!dbus_message_iter_close_container (&iter, &iter_array))
199 // TODO: handle out-of-memory
204 impl_DoAction (DBusConnection * bus, DBusMessage * message, void *user_data)
206 AtkAction *action = (AtkAction *) user_data;
208 dbus_bool_t rv = TRUE;
211 g_return_val_if_fail (ATK_IS_ACTION (user_data),
212 droute_not_yet_handled_error (message));
213 if (!dbus_message_get_args
214 (message, NULL, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
216 return droute_invalid_arguments_error (message);
218 reply = dbus_message_new_method_return (message);
221 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
224 dbus_connection_send (bus, reply, NULL);
225 dbus_message_unref (reply);
226 atk_action_do_action (action, index);
230 DRouteMethod methods[] = {
231 {impl_get_description, "GetDescription"}
233 {impl_get_name, "GetName"}
235 {impl_get_localized_name, "GetLocalizedName"}
237 {impl_get_keybinding, "GetKeyBinding"}
239 {impl_GetActions, "GetActions"}
241 {impl_DoAction, "DoAction"}
246 static DRouteProperty properties[] = {
247 {impl_get_NActions, NULL, "NActions"},
252 spi_initialize_action (DRoutePath * path)
254 spi_atk_add_interface (path,
255 ATSPI_DBUS_INTERFACE_ACTION,
256 spi_org_a11y_atspi_Action, methods, properties);