* 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.
*/
-/*
- * component.c : bonobo wrapper for accessible component implementation
- *
- */
-#include <config.h>
-#include <bonobo/Bonobo.h>
+#include "accessible.h"
-#include <stdio.h>
-
-/*
- * This pulls the CORBA definitions for the "Accessibility::Accessible" server
- */
-#include <libspi/Accessibility.h>
-
-/*
- * This pulls the definition of the image bonobo object
- */
-#include "image.h"
-
-/*
- * Static function declarations
- */
-
-static void
-image_class_init (ImageClass *klass);
-static void
-image_init (Image *image);
-static void
-image_finalize (GObject *obj);
-static void
-impl_getImagePosition (PortableServer_Servant _servant,
- CORBA_long * x, CORBA_long * y,
- const CORBA_short coordType,
- CORBA_Environment * ev);
-static void
-impl_getImageSize (PortableServer_Servant _servant,
- CORBA_long * width, CORBA_long * height,
- CORBA_Environment * ev);
-static CORBA_string
-impl__get_imageDescription (PortableServer_Servant _servant,
- CORBA_Environment * ev);
-
-
-static GObjectClass *parent_class;
-
-GType
-image_get_type (void)
+static AtkImage *
+get_image (DBusMessage * message)
{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo tinfo = {
- sizeof (ImageClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) image_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class data */
- sizeof (Image),
- 0, /* n preallocs */
- (GInstanceInitFunc) image_init,
- NULL /* value table */
- };
-
- /*
- * Bonobo_type_unique auto-generates a load of
- * CORBA structures for us. All derived types must
- * use bonobo_type_unique.
- */
- type = bonobo_type_unique (
- BONOBO_OBJECT_TYPE,
- POA_Accessibility_Image__init,
- NULL,
- G_STRUCT_OFFSET (ImageClass, epv),
- &tinfo,
- "AccessibleImage");
- }
-
- return type;
+ AtkObject *obj = spi_dbus_get_object (dbus_message_get_path (message));
+ if (!obj)
+ return NULL;
+ return ATK_IMAGE (obj);
}
-static void
-image_class_init (ImageClass *klass)
+static AtkImage *
+get_image_from_path (const char *path, void *user_data)
{
- GObjectClass * object_class = (GObjectClass *) klass;
- POA_Accessibility_Image__epv *epv = &klass->epv;
- parent_class = g_type_class_peek_parent (klass);
-
- object_class->finalize = image_finalize;
-
-
- /* Initialize epv table */
-
- epv->getImagePosition = impl_getImagePosition;
- epv->getImageSize = impl_getImageSize;
- epv->_get_imageDescription = impl__get_imageDescription;
+ AtkObject *obj = spi_dbus_get_object (path);
+ if (!obj || !ATK_IS_IMAGE(obj))
+ return NULL;
+ return ATK_IMAGE (obj);
}
-static void
-image_init (Image *image)
+static dbus_bool_t
+impl_get_imageDescription (const char *path, DBusMessageIter * iter,
+ void *user_data)
{
+ 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
-image_finalize (GObject *obj)
+static dbus_bool_t
+impl_get_imageLocale (const char *path, DBusMessageIter * iter,
+ void *user_data)
{
- Image *image = IMAGE (obj);
- image->atk_image = NULL;
- parent_class->finalize (obj);
+ 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));
}
-Image *
-image_new (AtkImage *image)
+static DBusMessage *
+impl_getImageExtents (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
{
- Image *new_image =
- IMAGE(g_object_new (IMAGE_TYPE, NULL));
- new_image->atk_image = image;
- return new_image;
+ 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);
}
-
-
-static void
-impl_getImagePosition (PortableServer_Servant _servant,
- CORBA_long * x, CORBA_long * y,
- const CORBA_short coordType,
- CORBA_Environment * ev)
+static DBusMessage *
+impl_getImagePosition (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
{
- Image *image = IMAGE (bonobo_object_from_servant(_servant));
- atk_image_get_image_position (image->atk_image,
- (gint *) x, (gint *) y,
- (AtkCoordType) coordType);
+ 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 SPI_DBUS_RETURN_ERROR (message, &error);
+ }
+ atk_image_get_image_position (image, &ix, &iy, (AtkCoordType) coord_type);
+ x = ix;
+ y = iy;
+ reply = dbus_message_new_method_return (message);
+ if (reply)
+ {
+ dbus_message_append_args (reply, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32,
+ &y, DBUS_TYPE_INVALID);
+ }
+ return reply;
}
-
-
-static void
-impl_getImageSize (PortableServer_Servant _servant,
- CORBA_long * width, CORBA_long * height,
- CORBA_Environment * ev)
+static DBusMessage *
+impl_getImageSize (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
{
- Image *image = IMAGE (bonobo_object_from_servant(_servant));
- atk_image_get_image_size (image->atk_image,
- (gint *) width, (gint *) height);
+ 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 CORBA_string
-impl__get_imageDescription (PortableServer_Servant _servant,
- CORBA_Environment * ev)
+static DRouteMethod methods[] = {
+ {impl_getImageExtents, "getImageExtents"},
+ {impl_getImagePosition, "getImagePosition"},
+ {impl_getImageSize, "getImageSize"},
+ {NULL, NULL}
+};
+
+static DRouteProperty properties[] = {
+ {impl_get_imageDescription, NULL, "imageDescription"},
+ {impl_get_imageLocale, NULL, "imageLocale"},
+ {NULL, NULL, NULL}
+};
+
+void
+spi_initialize_image (DRouteData * data)
{
- Image *image = IMAGE (bonobo_object_from_servant(_servant));
- return CORBA_string_dup (
- atk_image_get_image_description (image->atk_image));
-}
-
-
-
+ droute_add_interface (data, "org.freedesktop.atspi.Image", methods,
+ properties,
+ (DRouteGetDatumFunction) get_image_from_path, NULL);
+};