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"
28 get_image (DBusMessage * message)
30 AtkObject *obj = spi_dbus_get_object (dbus_message_get_path (message));
33 return ATK_IMAGE (obj);
37 get_image_from_path (const char *path, void *user_data)
39 AtkObject *obj = spi_dbus_get_object (path);
40 if (!obj || !ATK_IS_IMAGE(obj))
42 return ATK_IMAGE (obj);
46 impl_get_imageDescription (const char *path, DBusMessageIter * iter,
49 AtkImage *image = get_image_from_path (path, user_data);
52 return droute_return_v_string (iter,
53 atk_image_get_image_description (image));
57 impl_get_imageDescription_str (void *datum)
59 AtkImage *image = (AtkImage *) datum;
60 g_assert (ATK_IS_IMAGE (datum));
61 return g_strdup (atk_image_get_image_description (image));
65 impl_get_imageLocale (const char *path, DBusMessageIter * iter,
68 AtkImage *image = get_image_from_path (path, user_data);
71 return droute_return_v_string (iter, atk_image_get_image_locale (image));
75 impl_get_imageLocale_str (void *datum)
77 AtkImage *image = (AtkImage *) datum;
78 g_assert (ATK_IS_IMAGE (datum));
79 return g_strdup (atk_image_get_image_locale (image));
83 impl_getImageExtents (DBusConnection * bus, DBusMessage * message,
86 AtkImage *image = get_image (message);
88 dbus_uint32_t coordType;
89 gint ix, iy, iwidth, iheight;
92 return spi_dbus_general_error (message);
93 dbus_error_init (&error);
94 if (!dbus_message_get_args
95 (message, &error, DBUS_TYPE_UINT32, &coordType, DBUS_TYPE_INVALID))
97 return SPI_DBUS_RETURN_ERROR (message, &error);
99 atk_image_get_image_size (image, &iwidth, &iheight);
100 atk_image_get_image_position (image, &ix, &iy, (AtkCoordType) coordType);
101 return spi_dbus_return_rect (message, ix, iy, iwidth, iheight);
105 impl_getImagePosition (DBusConnection * bus, DBusMessage * message,
108 AtkImage *image = get_image (message);
110 dbus_uint32_t coord_type;
116 return spi_dbus_general_error (message);
117 dbus_error_init (&error);
118 if (!dbus_message_get_args
119 (message, &error, DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
121 return SPI_DBUS_RETURN_ERROR (message, &error);
123 atk_image_get_image_position (image, &ix, &iy, (AtkCoordType) coord_type);
126 reply = dbus_message_new_method_return (message);
129 dbus_message_append_args (reply, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32,
130 &y, DBUS_TYPE_INVALID);
136 impl_getImageSize (DBusConnection * bus, DBusMessage * message,
139 AtkImage *image = get_image (message);
140 gint iwidth = 0, iheight = 0;
141 dbus_int32_t width, height;
145 return spi_dbus_general_error (message);
146 atk_image_get_image_size (image, &iwidth, &iheight);
149 reply = dbus_message_new_method_return (message);
152 dbus_message_append_args (reply, DBUS_TYPE_INT32, &width,
153 DBUS_TYPE_INT32, &height, DBUS_TYPE_INVALID);
158 static DRouteMethod methods[] = {
159 {DROUTE_METHOD, impl_getImageExtents, "getImageExtents",
160 "n,coordType,i:(uuuu),,o"},
161 {DROUTE_METHOD, impl_getImagePosition, "getImagePosition",
162 "i,x,o:i,y,o:n,coordType,i"},
163 {DROUTE_METHOD, impl_getImageSize, "getImageSize", "i,width,o:i,height,o"},
164 {0, NULL, NULL, NULL}
167 static DRouteProperty properties[] = {
168 {impl_get_imageDescription, impl_get_imageDescription_str, NULL, NULL,
169 "imageDescription", "s"},
170 {impl_get_imageLocale, impl_get_imageLocale_str, NULL, NULL, "imageLocale",
172 {NULL, NULL, NULL, NULL, NULL, NULL}
176 spi_initialize_image (DRouteData * data)
178 droute_add_interface (data, "org.freedesktop.atspi.Image", methods,
180 (DRouteGetDatumFunction) get_image_from_path, NULL);