* 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 <stdio.h>
-
-/*
- * This pulls the CORBA definitions for the "Accessibility::SpiAccessible" server
- */
-#include <libspi/Accessibility.h>
-
-/*
- * This pulls the definition for the BonoboObject (Gtk Type)
- */
-#include "component.h"
#include "accessible.h"
-/*
- * Our parent Gtk object type
- */
-#define PARENT_TYPE BONOBO_OBJECT_TYPE
-
-/*
- * A pointer to our parent object class
- */
-static GObjectClass *spi_component_parent_class;
-
-/*
- * Implemented GObject::finalize
- */
-static void
-accessibility_spi_component_object_finalize (GObject *object)
+static AtkComponent *
+get_component (DBusMessage * message)
{
- SpiComponent *component = SPI_COMPONENT (object);
-
- printf("spi_accessible_spi_component_object_finalize called\n");
- g_object_unref (component->atko);
- component->atko = NULL;
+ AtkObject *obj = spi_dbus_get_object (dbus_message_get_path (message));
+ if (!obj)
+ return NULL;
+ return ATK_COMPONENT (obj);
+}
- printf("component atko freed, calling parent finalize\n");
- spi_component_parent_class->finalize (object);
+static AtkComponent *
+get_component_from_path (const char *path, void *user_data)
+{
+ AtkObject *obj = spi_dbus_get_object (path);
+ if (!obj || !ATK_IS_COMPONENT(obj))
+ return NULL;
+ return ATK_COMPONENT (obj);
}
-/*
- * CORBA Accessibility::SpiComponent::contains method implementation
- */
-static CORBA_boolean
-impl_accessibility_spi_component_contains (PortableServer_Servant servant,
- const CORBA_long x,
- const CORBA_long y,
- CORBA_short coord_type,
- CORBA_Environment *ev)
+static DBusMessage *
+impl_contains (DBusConnection * bus, DBusMessage * message, void *user_data)
{
- CORBA_boolean retval;
- BonoboObject *obj;
- SpiComponent *component;
+ AtkComponent *component = get_component (message);
+ dbus_int32_t x, y;
+ dbus_uint32_t coord_type;
+ DBusError error;
+ dbus_bool_t retval;
+ DBusMessage *reply;
- obj = bonobo_object_from_servant (servant);
- g_return_val_if_fail (IS_SPI_COMPONENT(obj), FALSE);
- component = SPI_COMPONENT (obj);
- g_return_val_if_fail (ATK_IS_COMPONENT(component->atko), FALSE);
- retval = atk_component_contains (ATK_COMPONENT (component->atko), (gint) x, (gint) y,
- (AtkCoordType) coord_type);
- return retval;
+ if (!component)
+ return spi_dbus_general_error (message);
+ dbus_error_init (&error);
+ if (!dbus_message_get_args
+ (message, &error, DBUS_TYPE_INT32, &x, DBUS_TYPE_UINT32, &y,
+ DBUS_TYPE_INT32, &coord_type, DBUS_TYPE_INVALID))
+ {
+ return SPI_DBUS_RETURN_ERROR (message, &error);
+ }
+ retval =
+ atk_component_contains (component, x, y, (AtkCoordType) coord_type);
+ reply = dbus_message_new_method_return (message);
+ if (reply)
+ {
+ dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &retval,
+ DBUS_TYPE_INVALID);
+ }
+ return reply;
}
-/*
- * CORBA Accessibility::SpiComponent::getAccessibleAtPoint method implementation
- */
-static Accessibility_SpiAccessible
-impl_accessibility_spi_component_get_accessible_at_point (PortableServer_Servant servant,
- const CORBA_long x,
- const CORBA_long y,
- CORBA_short coord_type,
- CORBA_Environment *ev)
+static DBusMessage *
+impl_getAccessibleAtPoint (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
{
- BonoboObject *obj;
- SpiComponent *component;
- Accessibility_SpiAccessible retval;
+ AtkComponent *component = get_component (message);
+ dbus_int32_t x, y;
+ dbus_uint32_t coord_type;
+ DBusError error;
AtkObject *child;
- obj = bonobo_object_from_servant (servant);
- g_return_val_if_fail (IS_SPI_COMPONENT(obj), CORBA_OBJECT_NIL);
- component = SPI_COMPONENT (obj);
- g_return_val_if_fail (ATK_IS_COMPONENT(component->atko), CORBA_OBJECT_NIL);
+ if (!component)
+ return spi_dbus_general_error (message);
+ dbus_error_init (&error);
+ if (!dbus_message_get_args
+ (message, &error, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y,
+ DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
+ {
+ return SPI_DBUS_RETURN_ERROR (message, &error);
+ }
+ child =
+ atk_component_ref_accessible_at_point (component, x, y,
+ (AtkCoordType) coord_type);
+ return spi_dbus_return_object (message, child, TRUE);
+}
- child = atk_component_ref_accessible_at_point (ATK_COMPONENT (component->atko),
- (gint) x, (gint) y,
- (AtkCoordType) coord_type);
- retval = bonobo_object_corba_objref (bonobo_object (spi_accessible_new (child)));
- return CORBA_Object_duplicate (retval, ev);
+static DBusMessage *
+impl_getExtents (DBusConnection * bus, DBusMessage * message, void *user_data)
+{
+ AtkComponent *component = get_component (message);
+ DBusError error;
+ dbus_uint32_t coord_type;
+ gint ix, iy, iwidth, iheight;
+
+ if (!component)
+ 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_component_get_extents (component, &ix, &iy, &iwidth, &iheight,
+ (AtkCoordType) coord_type);
+ return spi_dbus_return_rect (message, ix, iy, iwidth, iheight);
}
-/*
- * CORBA Accessibility::SpiComponent::getExtents method implementation
- */
-static void
-impl_accessibility_spi_component_get_extents (PortableServer_Servant servant,
- CORBA_long * x,
- CORBA_long * y,
- CORBA_long * width,
- CORBA_long * height,
- const CORBA_short coord_type,
- CORBA_Environment *ev)
+static DBusMessage *
+impl_getPosition (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
{
- BonoboObject *obj;
- SpiComponent *component;
- gint ix, iy, iw, ih;
+ AtkComponent *component = get_component (message);
+ DBusError error;
+ dbus_uint32_t coord_type;
+ gint ix = 0, iy = 0;
+ dbus_int32_t x, y;
+ DBusMessage *reply;
- obj = bonobo_object_from_servant (servant);
- g_return_if_fail (IS_SPI_COMPONENT(obj));
- component = SPI_COMPONENT (obj);
- g_return_if_fail (ATK_IS_COMPONENT (component->atko));
+ if (!component)
+ 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_component_get_position (component, &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;
+}
- atk_component_get_extents (ATK_COMPONENT (component->atko), &ix, &iy, &iw, &ih,
- (AtkCoordType) coord_type);
- *x = (CORBA_long) ix;
- *y = (CORBA_long) iy;
- *width = (CORBA_long) iw;
- *height = (CORBA_long) ih;
+static DBusMessage *
+impl_getSize (DBusConnection * bus, DBusMessage * message, void *user_data)
+{
+ AtkComponent *component = get_component (message);
+ gint iwidth = 0, iheight = 0;
+ dbus_int32_t width, height;
+ DBusMessage *reply;
+
+ if (!component)
+ return spi_dbus_general_error (message);
+ atk_component_get_size (component, &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;
}
-/*
- * CORBA Accessibility::SpiComponent::getPosition method implementation
- */
-static void
-impl_accessibility_spi_component_get_position (PortableServer_Servant servant,
- CORBA_long * x,
- CORBA_long * y,
- const CORBA_short coord_type,
- CORBA_Environment *ev)
+static DBusMessage *
+impl_getLayer (DBusConnection * bus, DBusMessage * message, void *user_data)
{
- BonoboObject *obj = bonobo_object_from_servant (servant);
- SpiComponent *component;
- gint ix, iy;
+ AtkComponent *component = get_component (message);
+ AtkLayer atklayer;
+ dbus_uint32_t rv;
+ DBusMessage *reply;
- g_return_if_fail (IS_SPI_COMPONENT(obj));
- component = SPI_COMPONENT(obj);
- g_return_if_fail (ATK_IS_COMPONENT(component->atko));
+ if (!component)
+ return spi_dbus_general_error (message);
+ atklayer = atk_component_get_layer (component);
- atk_component_get_position (ATK_COMPONENT (component->atko), &ix, &iy,
- (AtkCoordType) coord_type);
- *x = (CORBA_long) ix;
- *y = (CORBA_long) iy;
+ switch (atklayer)
+ {
+ case ATK_LAYER_BACKGROUND:
+ rv = Accessibility_LAYER_BACKGROUND;
+ break;
+ case ATK_LAYER_CANVAS:
+ rv = Accessibility_LAYER_CANVAS;
+ break;
+ case ATK_LAYER_WIDGET:
+ rv = Accessibility_LAYER_WIDGET;
+ break;
+ case ATK_LAYER_MDI:
+ rv = Accessibility_LAYER_MDI;
+ break;
+ case ATK_LAYER_POPUP:
+ rv = Accessibility_LAYER_POPUP;
+ break;
+ case ATK_LAYER_OVERLAY:
+ rv = Accessibility_LAYER_OVERLAY;
+ break;
+ case ATK_LAYER_WINDOW:
+ rv = Accessibility_LAYER_WINDOW;
+ break;
+ default:
+ rv = Accessibility_LAYER_INVALID;
+ break;
+ }
+ reply = dbus_message_new_method_return (message);
+ if (reply)
+ {
+ dbus_message_append_args (reply, DBUS_TYPE_UINT32, &rv,
+ DBUS_TYPE_INVALID);
+ }
+ return reply;
}
-/*
- * CORBA Accessibility::SpiComponent::getSize method implementation
- */
-static void
-impl_accessibility_spi_component_get_size (PortableServer_Servant servant,
- CORBA_long * width,
- CORBA_long * height,
- CORBA_Environment *ev)
+static DBusMessage *
+impl_getMDIZOrder (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
{
- SpiComponent *component;
- BonoboObject *obj = bonobo_object_from_servant (servant);
- gint iw, ih;
+ AtkComponent *component = get_component (message);
+ dbus_int16_t rv;
+ DBusMessage *reply;
- g_return_if_fail (IS_SPI_COMPONENT(obj));
- component = SPI_COMPONENT(obj);
- g_return_if_fail (ATK_IS_COMPONENT(component->atko));
- atk_component_get_size (ATK_COMPONENT (component->atko), &iw, &ih);
- *width = (CORBA_long) iw;
- *height = (CORBA_long) ih;
+ if (!component)
+ return spi_dbus_general_error (message);
+ rv = atk_component_get_mdi_zorder (component);
+ reply = dbus_message_new_method_return (message);
+ if (reply)
+ {
+ dbus_message_append_args (reply, DBUS_TYPE_UINT32, &rv,
+ DBUS_TYPE_INVALID);
+ }
+ return reply;
}
-static void
-accessibility_spi_component_class_init (SpiComponentClass *klass)
+static DBusMessage *
+impl_grabFocus (DBusConnection * bus, DBusMessage * message, void *user_data)
{
- GObjectClass * object_class = (GObjectClass *) klass;
- POA_Accessibility_SpiComponent__epv *epv = &klass->epv;
- spi_component_parent_class = g_type_class_peek_parent (klass);
+ AtkComponent *component = get_component (message);
+ dbus_bool_t rv;
+ DBusMessage *reply;
- object_class->finalize = accessibility_spi_component_object_finalize;
-
- epv->contains = impl_accessibility_spi_component_contains;
- epv->getAccessibleAtPoint = impl_accessibility_spi_component_get_accessible_at_point;
- epv->getExtents = impl_accessibility_spi_component_get_extents;
- epv->getPosition = impl_accessibility_spi_component_get_position;
- epv->getSize = impl_accessibility_spi_component_get_size;
+ if (!component)
+ return spi_dbus_general_error (message);
+ rv = atk_component_grab_focus (component);
+ reply = dbus_message_new_method_return (message);
+ if (reply)
+ {
+ dbus_message_append_args (reply, DBUS_TYPE_UINT32, &rv,
+ DBUS_TYPE_INVALID);
+ }
+ return reply;
}
-static void
-accessibility_spi_component_init (SpiComponent *component)
+#if 0
+static DBusMessage *
+impl_registerFocusHandler (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
{
}
-GType
-accessibility_spi_component_get_type (void)
+static DBusMessage *
+impl_deregisterFocusHandler (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
{
- static GType type = 0;
+}
+#endif
- if (!type) {
- static const GTypeInfo tinfo = {
- sizeof (SpiComponentClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) accessibility_spi_component_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class data */
- sizeof (SpiComponent),
- 0, /* n preallocs */
- (GInstanceInitFunc) accessibility_spi_component_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 (
- PARENT_TYPE,
- POA_Accessibility_SpiComponent__init,
- NULL,
- G_STRUCT_OFFSET (SpiComponentClass, epv),
- &tinfo,
- "SpiAccessibleComponent");
- }
+static DBusMessage *
+impl_getAlpha (DBusConnection * bus, DBusMessage * message, void *user_data)
+{
+ AtkComponent *component = get_component (message);
+ double rv;
+ DBusMessage *reply;
- return type;
+ if (!component)
+ return spi_dbus_general_error (message);
+ rv = atk_component_get_alpha (component);
+ reply = dbus_message_new_method_return (message);
+ if (reply)
+ {
+ dbus_message_append_args (reply, DBUS_TYPE_DOUBLE, &rv,
+ DBUS_TYPE_INVALID);
+ }
+ return reply;
}
-SpiComponent *
-spi_component_interface_new (AtkObject *o)
+static DRouteMethod methods[] = {
+ {impl_contains, "contains"},
+ {impl_getAccessibleAtPoint, "getAccessibleAtPoint"},
+ {impl_getExtents, "getExtents"},
+ {impl_getPosition, "getPosition"},
+ {impl_getSize, "getSize"},
+ {impl_getLayer, "getLayer"},
+ {impl_getMDIZOrder, "getMDIZOrder"},
+ {impl_grabFocus, "grabFocus"},
+ //{impl_registerFocusHandler, "registerFocusHandler"},
+ //{impl_deregisterFocusHandler, "deregisterFocusHandler"},
+ {impl_getAlpha, "getAlpha"},
+ {NULL, NULL}
+};
+
+void
+spi_initialize_component (DRouteData * data)
{
- SpiComponent *retval =
- SPI_COMPONENT (g_object_new (accessibility_spi_component_get_type (), NULL));
- retval->atko = o;
- g_object_ref (o);
- return retval;
-}
+ droute_add_interface (data, "org.freedesktop.atspi.Component",
+ methods, NULL,
+ (DRouteGetDatumFunction) get_component_from_path,
+ NULL);
+};