* 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::Accessible" server
- */
-#include <libspi/Accessibility.h>
-
-/*
- * This pulls the definition of the hypertext bonobo object
- */
-#include "hypertext.h"
-
-/*
- * Static function declarations
- */
-
-static void
-hypertext_class_init (HypertextClass *klass);
-static void
-hypertext_init (Hypertext *hypertext);
-static void
-hypertext_finalize (GObject *obj);
-static CORBA_short
-impl__get_n_anchors (PortableServer_Servant _servant,
- CORBA_Environment * ev);
-static CORBA_string
-impl__get_uri (PortableServer_Servant _servant,
- CORBA_Environment * ev);
-static CORBA_long
-impl__get_startIndex (PortableServer_Servant _servant,
- CORBA_Environment * ev);
-static CORBA_long
-impl__get_endIndex (PortableServer_Servant _servant,
- CORBA_Environment * ev);
-static Accessibility_Accessible
-impl_getAnchor (PortableServer_Servant _servant,
- const CORBA_long i,
- CORBA_Environment * ev);
-static Accessibility_Accessible
-impl_getObject (PortableServer_Servant _servant,
- const CORBA_long i,
- CORBA_Environment * ev);
-static CORBA_long
-impl_getNLinks (PortableServer_Servant _servant,
- CORBA_Environment * ev);
-static Accessibility_Hyperlink
-impl_getLink (PortableServer_Servant _servant,
- const CORBA_long linkIndex,
- CORBA_Environment * ev);
-static CORBA_long
-impl_getLinkIndex (PortableServer_Servant _servant,
- const CORBA_long characterIndex,
- CORBA_Environment * ev);
+#include "accessible.h"
-static GObjectClass *parent_class;
-
-GType
-hypertext_get_type (void)
+static AtkHypertext *
+get_hypertext (DBusMessage * message)
{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo tinfo = {
- sizeof (HypertextClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) hypertext_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class data */
- sizeof (Hypertext),
- 0, /* n preallocs */
- (GInstanceInitFunc) hypertext_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_Hypertext__init,
- NULL,
- G_STRUCT_OFFSET (HypertextClass, epv),
- &tinfo,
- "AccessibleHypertext");
- }
-
- return type;
+ AtkObject *obj = spi_dbus_get_object (dbus_message_get_path (message));
+ if (!obj)
+ return NULL;
+ return ATK_HYPERTEXT (obj);
}
-static void
-hypertext_class_init (HypertextClass *klass)
+static AtkHypertext *
+get_hypertext_from_path (const char *path, void *user_data)
{
- GObjectClass * object_class = (GObjectClass *) klass;
- POA_Accessibility_Hypertext__epv *epv = &klass->epv;
- parent_class = g_type_class_peek_parent (klass);
-
- object_class->finalize = hypertext_finalize;
-
- /* Initialize epv table */
-
- epv->getNLinks = impl_getNLinks;
- epv->getLink = impl_getLink;
- epv->getLinkIndex = impl_getLinkIndex;
+ AtkObject *obj = spi_dbus_get_object (path);
+ if (!obj)
+ return NULL;
+ return ATK_HYPERTEXT (obj);
}
-static void
-hypertext_init (Hypertext *hypertext)
+static DBusMessage *
+impl_getNLinks (DBusConnection * bus, DBusMessage * message, void *user_data)
{
+ AtkHypertext *hypertext = get_hypertext (message);
+ gint rv;
+ DBusMessage *reply;
+
+ if (!hypertext)
+ return spi_dbus_general_error (message);
+ rv = atk_hypertext_get_n_links (hypertext);
+ reply = dbus_message_new_method_return (message);
+ if (reply)
+ {
+ dbus_message_append_args (reply, DBUS_TYPE_INT32, &rv,
+ DBUS_TYPE_INVALID);
+ }
+ return reply;
}
-static void
-hypertext_finalize (GObject *obj)
+static DBusMessage *
+impl_getLink (DBusConnection * bus, DBusMessage * message, void *user_data)
{
- Hypertext *hypertext = HYPERTEXT(obj);
- hypertext->atk_hypertext = NULL;
- parent_class->finalize (obj);
-}
-
-Hypertext *
-hypertext_new (AtkHypertext *hypertext)
-{
- Hypertext *new_hypertext =
- HYPERTEXT(g_object_new (HYPERTEXT_TYPE, NULL));
- new_hypertext->atk_hypertext = hypertext;
- return new_hypertext;
-}
-
-
+ AtkHypertext *hypertext = get_hypertext (message);
+ DBusError error;
+ dbus_int32_t linkIndex;
+ AtkHyperlink *link;
-static CORBA_long
-impl_getNLinks (PortableServer_Servant _servant,
- CORBA_Environment * ev)
-{
- Hypertext *hypertext = HYPERTEXT(bonobo_object_from_servant(_servant));
- return (CORBA_long)
- atk_hypertext_get_n_links (hypertext->atk_hypertext);
+ if (!hypertext)
+ return spi_dbus_general_error (message);
+ dbus_error_init (&error);
+ if (!dbus_message_get_args
+ (message, &error, DBUS_TYPE_INT32, &linkIndex, DBUS_TYPE_INVALID))
+ {
+ return SPI_DBUS_RETURN_ERROR (message, &error);
+ }
+ link = atk_hypertext_get_link (hypertext, linkIndex);
+ return spi_dbus_return_object (message, ATK_OBJECT (link), FALSE);
}
-
-
-static Accessibility_Hyperlink
-impl_getLink (PortableServer_Servant _servant,
- const CORBA_long linkIndex,
- CORBA_Environment * ev)
+static DBusMessage *
+impl_getLinkIndex (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
{
- AtkHyperlink *link;
- Hypertext *hypertext = HYPERTEXT(bonobo_object_from_servant(_servant));
- Accessibility_Hyperlink rv;
-
- link = atk_hypertext_get_link (hypertext->atk_hypertext,
- (gint) linkIndex);
- rv = bonobo_object_corba_objref (BONOBO_OBJECT(hyperlink_new(link)));
- return rv;
+ AtkHypertext *hypertext = get_hypertext (message);
+ DBusError error;
+ dbus_int32_t characterIndex;
+ dbus_int32_t rv;
+ DBusMessage *reply;
+
+ if (!hypertext)
+ return spi_dbus_general_error (message);
+ dbus_error_init (&error);
+ if (!dbus_message_get_args
+ (message, &error, DBUS_TYPE_INT32, &characterIndex, DBUS_TYPE_INVALID))
+ {
+ return SPI_DBUS_RETURN_ERROR (message, &error);
+ }
+ rv = atk_hypertext_get_link_index (hypertext, characterIndex);
+ reply = dbus_message_new_method_return (message);
+ if (reply)
+ {
+ dbus_message_append_args (reply, DBUS_TYPE_INT32, &rv,
+ DBUS_TYPE_INVALID);
+ }
+ return reply;
}
+static DRouteMethod methods[] = {
+ {DROUTE_METHOD, impl_getNLinks, "getNLinks", "i,,o"},
+ {DROUTE_METHOD, impl_getLink, "getLink", "i,linkIndex,i:o,,o"},
+ {DROUTE_METHOD, impl_getLinkIndex, "getLinkIndex",
+ "i,characterIndex,i:i,,o"},
+ {0, NULL, NULL, NULL}
+};
-
-static CORBA_long
-impl_getLinkIndex (PortableServer_Servant _servant,
- const CORBA_long characterIndex,
- CORBA_Environment * ev)
+void
+spi_initialize_hypertext (DRouteData * data)
{
- Hypertext *hypertext = HYPERTEXT(bonobo_object_from_servant(_servant));
- return (CORBA_long)
- atk_hypertext_get_link_index (hypertext->atk_hypertext,
- (gint) characterIndex);
-}
-
+ droute_add_interface (data, "org.freedesktop.accessibility.Hypertext",
+ methods, NULL,
+ (DRouteGetDatumFunction) get_hypertext_from_path,
+ NULL);
+};