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>
28 #include "spi-common/spi-dbus.h"
31 impl_setTextContents (DBusConnection * bus, DBusMessage * message,
34 AtkEditableText *editable = (AtkEditableText *) user_data;
35 const char *newContents;
40 g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data),
41 droute_not_yet_handled_error (message));
42 dbus_error_init (&error);
43 if (!dbus_message_get_args
44 (message, &error, DBUS_TYPE_STRING, &newContents, DBUS_TYPE_INVALID))
46 return droute_invalid_arguments_error (message);
48 atk_editable_text_set_text_contents (editable, newContents);
50 // TODO decide if we really need this return value
51 reply = dbus_message_new_method_return (message);
54 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
61 impl_insertText (DBusConnection * bus, DBusMessage * message, void *user_data)
63 AtkEditableText *editable = (AtkEditableText *) user_data;
64 dbus_int32_t position, length;
71 g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data),
72 droute_not_yet_handled_error (message));
73 dbus_error_init (&error);
74 if (!dbus_message_get_args
75 (message, &error, DBUS_TYPE_INT32, &position, DBUS_TYPE_STRING, &text,
76 DBUS_TYPE_INT32, &length, DBUS_TYPE_INVALID))
78 return droute_invalid_arguments_error (message);
81 atk_editable_text_insert_text (editable, text, length, &ip);
83 // TODO decide if we really need this return value
84 reply = dbus_message_new_method_return (message);
87 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
94 impl_setAttributes (DBusConnection * bus, DBusMessage * message,
97 AtkEditableText *editable = (AtkEditableText *) user_data;
98 const char *attributes;
99 dbus_int32_t startPos, endPos;
104 g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data),
105 droute_not_yet_handled_error (message));
106 dbus_error_init (&error);
107 if (!dbus_message_get_args
108 (message, &error, DBUS_TYPE_STRING, &attributes, DBUS_TYPE_INT32,
109 &startPos, DBUS_TYPE_INT32, &endPos, DBUS_TYPE_INVALID))
111 return droute_invalid_arguments_error (message);
115 reply = dbus_message_new_method_return (message);
118 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
125 impl_copyText (DBusConnection * bus, DBusMessage * message, void *user_data)
127 AtkEditableText *editable = (AtkEditableText *) user_data;
128 dbus_int32_t startPos, endPos;
131 g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data),
132 droute_not_yet_handled_error (message));
133 dbus_error_init (&error);
134 if (!dbus_message_get_args
135 (message, &error, DBUS_TYPE_INT32, &startPos, DBUS_TYPE_INT32, &endPos,
138 return droute_invalid_arguments_error (message);
140 atk_editable_text_copy_text (editable, startPos, endPos);
145 impl_cutText (DBusConnection * bus, DBusMessage * message, void *user_data)
147 AtkEditableText *editable = (AtkEditableText *) user_data;
148 dbus_int32_t startPos, endPos;
153 g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data),
154 droute_not_yet_handled_error (message));
155 dbus_error_init (&error);
156 if (!dbus_message_get_args
157 (message, &error, DBUS_TYPE_INT32, &startPos, DBUS_TYPE_INT32, &endPos,
160 return droute_invalid_arguments_error (message);
162 atk_editable_text_cut_text (editable, startPos, endPos);
164 // TODO decide if we really need this return value
165 reply = dbus_message_new_method_return (message);
168 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
175 impl_deleteText (DBusConnection * bus, DBusMessage * message, void *user_data)
177 AtkEditableText *editable = (AtkEditableText *) user_data;
178 dbus_int32_t startPos, endPos;
183 g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data),
184 droute_not_yet_handled_error (message));
185 dbus_error_init (&error);
186 if (!dbus_message_get_args
187 (message, &error, DBUS_TYPE_INT32, &startPos, DBUS_TYPE_INT32, &endPos,
190 return droute_invalid_arguments_error (message);
192 atk_editable_text_delete_text (editable, startPos, endPos);
194 // TODO decide if we really need this return value
195 reply = dbus_message_new_method_return (message);
198 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
205 impl_pasteText (DBusConnection * bus, DBusMessage * message, void *user_data)
207 AtkEditableText *editable = (AtkEditableText *) user_data;
208 dbus_int32_t position;
213 g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data),
214 droute_not_yet_handled_error (message));
215 dbus_error_init (&error);
216 if (!dbus_message_get_args
217 (message, &error, DBUS_TYPE_INT32, &position, DBUS_TYPE_INVALID))
219 return droute_invalid_arguments_error (message);
221 atk_editable_text_paste_text (editable, position);
223 // TODO decide if we really need this return value
224 reply = dbus_message_new_method_return (message);
227 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
233 static DRouteMethod methods[] = {
234 {impl_setTextContents, "setTextContents"},
235 {impl_insertText, "insertText"},
236 {impl_setAttributes, "setAttributes"},
237 {impl_copyText, "copyText"},
238 {impl_cutText, "cutText"},
239 {impl_deleteText, "deleteText"},
240 {impl_pasteText, "pasteText"},
245 spi_initialize_editabletext (DRoutePath *path)
247 droute_path_add_interface (path,
248 SPI_DBUS_INTERFACE_EDITABLE_TEXT,