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.
25 #include "accessible.h"
27 static AtkEditableText *
28 get_editable (DBusMessage * message)
30 AtkObject *obj = spi_dbus_get_object (dbus_message_get_path (message));
33 return ATK_EDITABLE_TEXT (obj);
36 static AtkEditableText *
37 get_editable_from_path (const char *path, void *user_data)
39 AtkObject *obj = spi_dbus_get_object (path);
40 if (!obj || !ATK_IS_EDITABLE_TEXT(obj))
42 return ATK_EDITABLE_TEXT (obj);
46 impl_setTextContents (DBusConnection * bus, DBusMessage * message,
49 AtkEditableText *editable = get_editable (message);
50 const char *newContents;
56 return spi_dbus_general_error (message);
57 dbus_error_init (&error);
58 if (!dbus_message_get_args
59 (message, &error, DBUS_TYPE_STRING, &newContents, DBUS_TYPE_INVALID))
61 return SPI_DBUS_RETURN_ERROR (message, &error);
63 atk_editable_text_set_text_contents (editable, newContents);
65 // TODO decide if we really need this return value
66 reply = dbus_message_new_method_return (message);
69 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
76 impl_insertText (DBusConnection * bus, DBusMessage * message, void *user_data)
78 AtkEditableText *editable = get_editable (message);
79 dbus_int32_t position, length;
87 return spi_dbus_general_error (message);
88 dbus_error_init (&error);
89 if (!dbus_message_get_args
90 (message, &error, DBUS_TYPE_INT32, &position, DBUS_TYPE_STRING, &text,
91 DBUS_TYPE_INT32, &length, DBUS_TYPE_INVALID))
93 return SPI_DBUS_RETURN_ERROR (message, &error);
96 atk_editable_text_insert_text (editable, text, length, &ip);
98 // TODO decide if we really need this return value
99 reply = dbus_message_new_method_return (message);
102 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
109 impl_setAttributes (DBusConnection * bus, DBusMessage * message,
112 AtkEditableText *editable = get_editable (message);
113 const char *attributes;
114 dbus_int32_t startPos, endPos;
120 return spi_dbus_general_error (message);
121 dbus_error_init (&error);
122 if (!dbus_message_get_args
123 (message, &error, DBUS_TYPE_STRING, &attributes, DBUS_TYPE_INT32,
124 &startPos, DBUS_TYPE_INT32, &endPos, DBUS_TYPE_INVALID))
126 return SPI_DBUS_RETURN_ERROR (message, &error);
130 reply = dbus_message_new_method_return (message);
133 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
140 impl_copyText (DBusConnection * bus, DBusMessage * message, void *user_data)
142 AtkEditableText *editable = get_editable (message);
143 dbus_int32_t startPos, endPos;
147 return spi_dbus_general_error (message);
148 dbus_error_init (&error);
149 if (!dbus_message_get_args
150 (message, &error, DBUS_TYPE_INT32, &startPos, DBUS_TYPE_INT32, &endPos,
153 return SPI_DBUS_RETURN_ERROR (message, &error);
155 atk_editable_text_copy_text (editable, startPos, endPos);
160 impl_cutText (DBusConnection * bus, DBusMessage * message, void *user_data)
162 AtkEditableText *editable = get_editable (message);
163 dbus_int32_t startPos, endPos;
169 return spi_dbus_general_error (message);
170 dbus_error_init (&error);
171 if (!dbus_message_get_args
172 (message, &error, DBUS_TYPE_INT32, &startPos, DBUS_TYPE_INT32, &endPos,
175 return SPI_DBUS_RETURN_ERROR (message, &error);
177 atk_editable_text_cut_text (editable, startPos, endPos);
179 // TODO decide if we really need this return value
180 reply = dbus_message_new_method_return (message);
183 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
190 impl_deleteText (DBusConnection * bus, DBusMessage * message, void *user_data)
192 AtkEditableText *editable = get_editable (message);
193 dbus_int32_t startPos, endPos;
199 return spi_dbus_general_error (message);
200 dbus_error_init (&error);
201 if (!dbus_message_get_args
202 (message, &error, DBUS_TYPE_INT32, &startPos, DBUS_TYPE_INT32, &endPos,
205 return SPI_DBUS_RETURN_ERROR (message, &error);
207 atk_editable_text_delete_text (editable, startPos, endPos);
209 // TODO decide if we really need this return value
210 reply = dbus_message_new_method_return (message);
213 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
220 impl_pasteText (DBusConnection * bus, DBusMessage * message, void *user_data)
222 AtkEditableText *editable = get_editable (message);
223 dbus_int32_t position;
229 return spi_dbus_general_error (message);
230 dbus_error_init (&error);
231 if (!dbus_message_get_args
232 (message, &error, DBUS_TYPE_INT32, &position, DBUS_TYPE_INVALID))
234 return SPI_DBUS_RETURN_ERROR (message, &error);
236 atk_editable_text_paste_text (editable, position);
238 // TODO decide if we really need this return value
239 reply = dbus_message_new_method_return (message);
242 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
248 static DRouteMethod methods[] = {
249 {impl_setTextContents, "setTextContents"},
250 {impl_insertText, "insertText"},
251 {impl_setAttributes, "setAttributes"},
252 {impl_copyText, "copyText"},
253 {impl_cutText, "cutText"},
254 {impl_deleteText, "deleteText"},
255 {impl_pasteText, "pasteText"},
260 spi_initialize_editabletext (DRouteData * data)
262 droute_add_interface (data, "org.freedesktop.atspi.EditableText",
264 (DRouteGetDatumFunction) get_editable_from_path,