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.
28 #include <droute/droute.h>
30 #include "common/spi-dbus.h"
31 #include "introspection.h"
34 impl_get_MinimumValue (DBusMessageIter * iter, void *user_data)
36 AtkValue *value = (AtkValue *) user_data;
41 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
43 atk_value_get_minimum_value (value, &src);
44 g_value_init (&dest, G_TYPE_DOUBLE);
46 if (g_value_transform (&src, &dest))
48 dub = g_value_get_double (&dest);
49 return droute_return_v_double (iter, dub);
58 impl_get_MaximumValue (DBusMessageIter * iter, void *user_data)
60 AtkValue *value = (AtkValue *) user_data;
65 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
67 atk_value_get_maximum_value (value, &src);
68 g_value_init (&dest, G_TYPE_DOUBLE);
70 if (g_value_transform (&src, &dest))
72 dub = g_value_get_double (&dest);
74 return droute_return_v_double (iter, dub);
78 impl_get_MinimumIncrement (DBusMessageIter * iter, void *user_data)
80 AtkValue *value = (AtkValue *) user_data;
85 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
87 atk_value_get_minimum_increment (value, &src);
88 g_value_init (&dest, G_TYPE_DOUBLE);
90 if (g_value_transform (&src, &dest))
92 dub = g_value_get_double (&dest);
94 return droute_return_v_double (iter, dub);
98 impl_get_CurrentValue (DBusMessageIter * iter, void *user_data)
100 AtkValue *value = (AtkValue *) user_data;
105 g_return_val_if_fail (ATK_IS_VALUE (user_data), FALSE);
107 atk_value_get_current_value (value, &src);
108 g_value_init (&dest, G_TYPE_DOUBLE);
110 if (g_value_transform (&src, &dest))
112 dub = g_value_get_double (&dest);
114 return droute_return_v_double (iter, dub);
118 impl_set_CurrentValue (DBusConnection * bus, DBusMessage * message,
121 AtkValue *value = (AtkValue *) user_data;
126 GValue new_value = { 0 };
128 g_return_val_if_fail (ATK_IS_VALUE (value),
129 droute_not_yet_handled_error (message));
131 dbus_error_init (&error);
132 if (!dbus_message_get_args
133 (message, &error, DBUS_TYPE_DOUBLE, &dub, DBUS_TYPE_INVALID))
135 return droute_invalid_arguments_error (message);
138 g_value_init (&new_value, G_TYPE_DOUBLE);
139 g_value_set_double (&new_value, dub);
140 rv = atk_value_set_current_value (value, &new_value);
142 reply = dbus_message_new_method_return (message);
145 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
151 static DRouteMethod methods[] = {
152 {impl_set_CurrentValue, "SetCurrentValue"},
156 static DRouteProperty properties[] = {
157 {impl_get_MinimumValue, NULL, "MinimumValue"},
158 {impl_get_MaximumValue, NULL, "MaximumValue"},
159 {impl_get_MinimumIncrement, NULL, "MinimumIncrement"},
160 {impl_get_CurrentValue, NULL, "CurrentValue"},
165 spi_initialize_value (DRoutePath * path)
167 droute_path_add_interface (path,
168 SPI_DBUS_INTERFACE_VALUE, spi_org_a11y_atspi_Value, methods, properties);