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>
30 #include "introspection.h"
33 impl_get_NActions (DBusMessageIter * iter, void *user_data)
35 AtkAction *action = (AtkAction *) user_data;
37 g_return_val_if_fail (ATK_IS_ACTION (user_data), FALSE);
38 return droute_return_v_int32 (iter, atk_action_get_n_actions (action));
42 impl_get_description (DBusConnection * bus, DBusMessage * message,
45 AtkAction *action = (AtkAction *) user_data;
50 g_return_val_if_fail (ATK_IS_ACTION (user_data),
51 droute_not_yet_handled_error (message));
52 if (!dbus_message_get_args
53 (message, NULL, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
55 return droute_invalid_arguments_error (message);
57 desc = atk_action_get_description (action, index);
60 reply = dbus_message_new_method_return (message);
63 dbus_message_append_args (reply, DBUS_TYPE_STRING, &desc,
70 impl_get_name (DBusConnection * bus, DBusMessage * message, void *user_data)
75 AtkAction *action = (AtkAction *) user_data;
77 g_return_val_if_fail (ATK_IS_ACTION (user_data),
78 droute_not_yet_handled_error (message));
79 if (!dbus_message_get_args
80 (message, NULL, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
82 return droute_invalid_arguments_error (message);
84 name = atk_action_get_name (action, index);
87 reply = dbus_message_new_method_return (message);
90 dbus_message_append_args (reply, DBUS_TYPE_STRING, &name,
97 impl_get_localized_name (DBusConnection * bus, DBusMessage * message, void *user_data)
102 AtkAction *action = (AtkAction *) user_data;
104 g_return_val_if_fail (ATK_IS_ACTION (user_data),
105 droute_not_yet_handled_error (message));
106 if (!dbus_message_get_args
107 (message, NULL, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
109 return droute_invalid_arguments_error (message);
111 name = atk_action_get_localized_name (action, index);
114 reply = dbus_message_new_method_return (message);
117 dbus_message_append_args (reply, DBUS_TYPE_STRING, &name,
124 impl_get_keybinding (DBusConnection * bus, DBusMessage * message,
130 AtkAction *action = (AtkAction *) user_data;
132 g_return_val_if_fail (ATK_IS_ACTION (user_data),
133 droute_not_yet_handled_error (message));
134 if (!dbus_message_get_args
135 (message, NULL, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
137 return droute_invalid_arguments_error (message);
139 kb = atk_action_get_keybinding (action, index);
142 reply = dbus_message_new_method_return (message);
145 dbus_message_append_args (reply, DBUS_TYPE_STRING, &kb,
152 impl_GetActions (DBusConnection * bus, DBusMessage * message, void *user_data)
154 AtkAction *action = (AtkAction *) user_data;
158 DBusMessageIter iter, iter_array, iter_struct;
160 g_return_val_if_fail (ATK_IS_ACTION (user_data),
161 droute_not_yet_handled_error (message));
162 count = atk_action_get_n_actions (action);
163 reply = dbus_message_new_method_return (message);
166 dbus_message_iter_init_append (reply, &iter);
167 if (!dbus_message_iter_open_container
168 (&iter, DBUS_TYPE_ARRAY, "(sss)", &iter_array))
170 for (i = 0; i < count; i++)
172 const char *name = atk_action_get_name (action, i);
173 const char *lname = atk_action_get_localized_name (action, i);
174 const char *desc = atk_action_get_description (action, i);
175 const char *kb = atk_action_get_keybinding (action, i);
184 if (!dbus_message_iter_open_container
185 (&iter_array, DBUS_TYPE_STRUCT, NULL, &iter_struct))
187 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &name);
188 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &lname);
189 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &desc);
190 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &kb);
191 if (!dbus_message_iter_close_container (&iter_array, &iter_struct))
194 if (!dbus_message_iter_close_container (&iter, &iter_array))
198 // TODO: handle out-of-memory
203 impl_DoAction (DBusConnection * bus, DBusMessage * message, void *user_data)
205 AtkAction *action = (AtkAction *) user_data;
207 dbus_bool_t rv = TRUE;
210 g_return_val_if_fail (ATK_IS_ACTION (user_data),
211 droute_not_yet_handled_error (message));
212 if (!dbus_message_get_args
213 (message, NULL, DBUS_TYPE_INT32, &index, DBUS_TYPE_INVALID))
215 return droute_invalid_arguments_error (message);
217 reply = dbus_message_new_method_return (message);
220 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
223 dbus_connection_send (bus, reply, NULL);
224 dbus_message_unref (reply);
225 atk_action_do_action (action, index);
229 DRouteMethod methods[] = {
230 {impl_get_description, "GetDescription"}
232 {impl_get_name, "GetName"}
234 {impl_get_localized_name, "GetLocalizedName"}
236 {impl_get_keybinding, "GetKeyBinding"}
238 {impl_GetActions, "GetActions"}
240 {impl_DoAction, "DoAction"}
245 static DRouteProperty properties[] = {
246 {impl_get_NActions, NULL, "NActions"},
251 spi_initialize_action (DRoutePath * path)
253 droute_path_add_interface (path,
254 ATSPI_DBUS_INTERFACE_ACTION,
255 spi_org_a11y_atspi_Action, methods, properties);