* AT-SPI - Assistive Technology Service Provider Interface
* (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
*
- * Copyright 2001 Sun Microsystems Inc.
+ * Copyright 2008 Novell, Inc.
+ * Copyright 2001, 2002 Sun Microsystems Inc.,
+ * Copyright 2001, 2002 Ximian, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* Boston, MA 02111-1307, USA.
*/
-/* image.c : implements the Image interface */
+#include "accessible.h"
-#include <config.h>
-#include <stdio.h>
-#include <libspi/image.h>
-
-
-SpiImage *
-spi_image_interface_new (AtkObject *obj)
+static AtkImage *
+get_image (DBusMessage * message)
{
- SpiImage *new_image = g_object_new (SPI_IMAGE_TYPE, NULL);
-
- spi_base_construct (SPI_BASE (new_image), obj);
-
- return new_image;
+ AtkObject *obj = spi_dbus_get_object (dbus_message_get_path (message));
+ if (!obj)
+ return NULL;
+ return ATK_IMAGE (obj);
}
static AtkImage *
-get_image_from_servant (PortableServer_Servant servant)
+get_image_from_path (const char *path, void *user_data)
{
- SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant));
-
- if (!object)
- {
- return NULL;
- }
-
- return ATK_IMAGE (object->atko);
+ AtkObject *obj = spi_dbus_get_object (path);
+ if (!obj)
+ return NULL;
+ return ATK_IMAGE (obj);
}
-static void
-impl_getImagePosition (PortableServer_Servant servant,
- CORBA_long * x, CORBA_long * y,
- const CORBA_short coordType,
- CORBA_Environment *ev)
+static dbus_bool_t
+impl_get_imageDescription (const char *path, DBusMessageIter * iter,
+ void *user_data)
{
- AtkImage *image = get_image_from_servant (servant);
-
- g_return_if_fail (image != NULL);
-
- atk_image_get_image_position (image,
- (gint *) x, (gint *) y,
- (AtkCoordType) coordType);
+ AtkImage *image = get_image_from_path (path, user_data);
+ if (!image)
+ return FALSE;
+ return droute_return_v_string (iter,
+ atk_image_get_image_description (image));
}
-static void
-impl_getImageSize (PortableServer_Servant servant,
- CORBA_long * width, CORBA_long * height,
- CORBA_Environment *ev)
+static char *
+impl_get_imageDescription_str (void *datum)
{
- AtkImage *image = get_image_from_servant (servant);
-
- g_return_if_fail (image != NULL);
-
- atk_image_get_image_size (image,
- (gint *) width, (gint *) height);
+ AtkImage *image = (AtkImage *) datum;
+ g_assert (ATK_IS_IMAGE (datum));
+ return g_strdup (atk_image_get_image_description (image));
}
-static Accessibility_BoundingBox
-impl_getImageExtents (PortableServer_Servant servant,
- const CORBA_short coordType,
- CORBA_Environment *ev)
+static dbus_bool_t
+impl_get_imageLocale (const char *path, DBusMessageIter * iter,
+ void *user_data)
{
- AtkImage *image;
- gint x, y, width, height;
- Accessibility_BoundingBox bbox;
-
- image = get_image_from_servant (servant);
-
- atk_image_get_image_size (image, &width, &height);
- atk_image_get_image_position (image, &x, &y, coordType);
-
- bbox.x = x;
- bbox.y = y;
- bbox.width = width;
- bbox.height = height;
-
- return bbox;
+ AtkImage *image = get_image_from_path (path, user_data);
+ if (!image)
+ return FALSE;
+ return droute_return_v_string (iter, atk_image_get_image_locale (image));
}
-static CORBA_string
-impl__get_imageDescription (PortableServer_Servant servant,
- CORBA_Environment *ev)
+static char *
+impl_get_imageLocale_str (void *datum)
{
- const char *rv;
- AtkImage *image = get_image_from_servant (servant);
-
- g_return_val_if_fail (image != NULL, CORBA_string_dup (""));
+ AtkImage *image = (AtkImage *) datum;
+ g_assert (ATK_IS_IMAGE (datum));
+ return g_strdup (atk_image_get_image_locale (image));
+}
- rv = atk_image_get_image_description (image);
+static DBusMessage *
+impl_getImageExtents (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
+{
+ AtkImage *image = get_image (message);
+ DBusError error;
+ dbus_uint32_t coordType;
+ gint ix, iy, iwidth, iheight;
+
+ if (!image)
+ return spi_dbus_general_error (message);
+ dbus_error_init (&error);
+ if (!dbus_message_get_args
+ (message, &error, DBUS_TYPE_UINT32, &coordType, DBUS_TYPE_INVALID))
+ {
+ return SPI_DBUS_RETURN_ERROR (message, &error);
+ }
+ atk_image_get_image_size (image, &iwidth, &iheight);
+ atk_image_get_image_position (image, &ix, &iy, (AtkCoordType) coordType);
+ return spi_dbus_return_rect (message, ix, iy, iwidth, iheight);
+}
- if (rv)
+static DBusMessage *
+impl_getImagePosition (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
+{
+ AtkImage *image = get_image (message);
+ DBusError error;
+ dbus_uint32_t coord_type;
+ gint ix = 0, iy = 0;
+ dbus_int32_t x, y;
+ DBusMessage *reply;
+
+ if (!image)
+ return spi_dbus_general_error (message);
+ dbus_error_init (&error);
+ if (!dbus_message_get_args
+ (message, &error, DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
{
- return CORBA_string_dup (rv);
+ return SPI_DBUS_RETURN_ERROR (message, &error);
}
- else
+ atk_image_get_image_position (image, &ix, &iy, (AtkCoordType) coord_type);
+ x = ix;
+ y = iy;
+ reply = dbus_message_new_method_return (message);
+ if (reply)
{
- return CORBA_string_dup ("");
+ dbus_message_append_args (reply, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32,
+ &y, DBUS_TYPE_INVALID);
}
+ return reply;
}
-static void
-spi_image_class_init (SpiImageClass *klass)
+static DBusMessage *
+impl_getImageSize (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
{
- POA_Accessibility_Image__epv *epv = &klass->epv;
-
- /* Initialize epv table */
- epv->getImagePosition = impl_getImagePosition;
- epv->getImageSize = impl_getImageSize;
- epv->getImageExtents = impl_getImageExtents;
- epv->_get_imageDescription = impl__get_imageDescription;
+ AtkImage *image = get_image (message);
+ gint iwidth = 0, iheight = 0;
+ dbus_int32_t width, height;
+ DBusMessage *reply;
+
+ if (!image)
+ return spi_dbus_general_error (message);
+ atk_image_get_image_size (image, &iwidth, &iheight);
+ width = iwidth;
+ height = iheight;
+ reply = dbus_message_new_method_return (message);
+ if (reply)
+ {
+ dbus_message_append_args (reply, DBUS_TYPE_INT32, &width,
+ DBUS_TYPE_INT32, &height, DBUS_TYPE_INVALID);
+ }
+ return reply;
}
-static void
-spi_image_init (SpiImage *image)
+static DRouteMethod methods[] = {
+ {DROUTE_METHOD, impl_getImageExtents, "getImageExtents",
+ "n,coordType,i:(uuuu),,o"},
+ {DROUTE_METHOD, impl_getImagePosition, "getImagePosition",
+ "i,x,o:i,y,o:n,coordType,i"},
+ {DROUTE_METHOD, impl_getImageSize, "getImageSize", "i,width,o:i,height,o"},
+ {0, NULL, NULL, NULL}
+};
+
+static DRouteProperty properties[] = {
+ {impl_get_imageDescription, impl_get_imageDescription_str, NULL, NULL,
+ "imageDescription", "s"},
+ {impl_get_imageLocale, impl_get_imageLocale_str, NULL, NULL, "imageLocale",
+ "s"},
+ {NULL, NULL, NULL, NULL, NULL, NULL}
+};
+
+void
+spi_initialize_image (DRouteData * data)
{
-}
-
-BONOBO_TYPE_FUNC_FULL (SpiImage,
- Accessibility_Image,
- SPI_TYPE_BASE,
- spi_image);
+ droute_add_interface (data, "org.freedesktop.accessibility.Image", methods,
+ properties,
+ (DRouteGetDatumFunction) get_image_from_path, NULL);
+};