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 "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_CopyText (DBusConnection * bus, DBusMessage * message, void *user_data)
96 AtkEditableText *editable = (AtkEditableText *) user_data;
97 dbus_int32_t startPos, endPos;
100 g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data),
101 droute_not_yet_handled_error (message));
102 dbus_error_init (&error);
103 if (!dbus_message_get_args
104 (message, &error, DBUS_TYPE_INT32, &startPos, DBUS_TYPE_INT32, &endPos,
107 return droute_invalid_arguments_error (message);
109 atk_editable_text_copy_text (editable, startPos, endPos);
110 return dbus_message_new_method_return (message);
114 impl_CutText (DBusConnection * bus, DBusMessage * message, void *user_data)
116 AtkEditableText *editable = (AtkEditableText *) user_data;
117 dbus_int32_t startPos, endPos;
122 g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data),
123 droute_not_yet_handled_error (message));
124 dbus_error_init (&error);
125 if (!dbus_message_get_args
126 (message, &error, DBUS_TYPE_INT32, &startPos, DBUS_TYPE_INT32, &endPos,
129 return droute_invalid_arguments_error (message);
131 atk_editable_text_cut_text (editable, startPos, endPos);
133 // TODO decide if we really need this return value
134 reply = dbus_message_new_method_return (message);
137 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
144 impl_DeleteText (DBusConnection * bus, DBusMessage * message, void *user_data)
146 AtkEditableText *editable = (AtkEditableText *) user_data;
147 dbus_int32_t startPos, endPos;
152 g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data),
153 droute_not_yet_handled_error (message));
154 dbus_error_init (&error);
155 if (!dbus_message_get_args
156 (message, &error, DBUS_TYPE_INT32, &startPos, DBUS_TYPE_INT32, &endPos,
159 return droute_invalid_arguments_error (message);
161 atk_editable_text_delete_text (editable, startPos, endPos);
163 // TODO decide if we really need this return value
164 reply = dbus_message_new_method_return (message);
167 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
174 impl_PasteText (DBusConnection * bus, DBusMessage * message, void *user_data)
176 AtkEditableText *editable = (AtkEditableText *) user_data;
177 dbus_int32_t position;
182 g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data),
183 droute_not_yet_handled_error (message));
184 dbus_error_init (&error);
185 if (!dbus_message_get_args
186 (message, &error, DBUS_TYPE_INT32, &position, DBUS_TYPE_INVALID))
188 return droute_invalid_arguments_error (message);
190 atk_editable_text_paste_text (editable, position);
192 // TODO decide if we really need this return value
193 reply = dbus_message_new_method_return (message);
196 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
202 static DRouteMethod methods[] = {
203 {impl_SetTextContents, "SetTextContents"},
204 {impl_InsertText, "InsertText"},
205 {impl_CopyText, "CopyText"},
206 {impl_CutText, "CutText"},
207 {impl_DeleteText, "DeleteText"},
208 {impl_PasteText, "PasteText"},
213 spi_initialize_editabletext (DRoutePath * path)
215 droute_path_add_interface (path,
216 SPI_DBUS_INTERFACE_EDITABLE_TEXT, methods, NULL);