* 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.
*/
-/* hypertext.c : implements the HyperText interface */
+#include "accessible.h"
-#include <config.h>
-#include <stdio.h>
-#include <libspi/hyperlink.h>
-#include <libspi/hypertext.h>
-
-/* Static function declarations */
-
-static GObjectClass *parent_class;
-
-static void
-spi_hypertext_finalize (GObject *obj)
+static AtkHypertext *
+get_hypertext (DBusMessage * message)
{
- SpiHypertext *hypertext = SPI_HYPERTEXT(obj);
- g_object_unref (hypertext->atko);
- hypertext->atko = NULL;
- parent_class->finalize (obj);
+ AtkObject *obj = spi_dbus_get_object (dbus_message_get_path (message));
+ if (!obj)
+ return NULL;
+ return ATK_HYPERTEXT (obj);
}
-SpiHypertext *
-spi_hypertext_interface_new (AtkObject *obj)
+static AtkHypertext *
+get_hypertext_from_path (const char *path, void *user_data)
{
- SpiHypertext *new_hypertext = g_object_new (SPI_HYPERTEXT_TYPE, NULL);
- new_hypertext->atko = obj;
- g_object_ref (obj);
- return new_hypertext;
+ AtkObject *obj = spi_dbus_get_object (path);
+ if (!obj)
+ return NULL;
+ return ATK_HYPERTEXT (obj);
}
-
-
-static CORBA_long
-impl_getNLinks (PortableServer_Servant _servant,
- CORBA_Environment * ev)
+static DBusMessage *
+impl_getNLinks (DBusConnection * bus, DBusMessage * message, void *user_data)
{
- SpiHypertext *hypertext = SPI_HYPERTEXT(bonobo_object_from_servant(_servant));
- return (CORBA_long)
- atk_hypertext_get_n_links (ATK_HYPERTEXT(hypertext->atko));
+ 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 Accessibility_Hyperlink
-impl_getLink (PortableServer_Servant servant,
- const CORBA_long linkIndex,
- CORBA_Environment *ev)
+static DBusMessage *
+impl_getLink (DBusConnection * bus, DBusMessage * message, void *user_data)
{
+ AtkHypertext *hypertext = get_hypertext (message);
+ DBusError error;
+ dbus_int32_t linkIndex;
AtkHyperlink *link;
- SpiHypertext *hypertext;
- Accessibility_Hyperlink rv;
-
- hypertext = SPI_HYPERTEXT (bonobo_object_from_servant (servant));
-
- link = atk_hypertext_get_link (
- ATK_HYPERTEXT (hypertext->atko), linkIndex);
-
- rv = bonobo_object_corba_objref (BONOBO_OBJECT (
- spi_hyperlink_new (ATK_OBJECT (link))));
- return rv;
+ 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 CORBA_long
-impl_getLinkIndex (PortableServer_Servant _servant,
- const CORBA_long characterIndex,
- CORBA_Environment * ev)
+static DBusMessage *
+impl_getLinkIndex (DBusConnection * bus, DBusMessage * message,
+ void *user_data)
{
- SpiHypertext *hypertext = SPI_HYPERTEXT(bonobo_object_from_servant(_servant));
- return (CORBA_long)
- atk_hypertext_get_link_index (ATK_HYPERTEXT(hypertext->atko),
- (gint) characterIndex);
+ 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 void
-spi_hypertext_class_init (SpiHypertextClass *klass)
-{
- GObjectClass * object_class = (GObjectClass *) klass;
- POA_Accessibility_Hypertext__epv *epv = &klass->epv;
- parent_class = g_type_class_peek_parent (klass);
-
- object_class->finalize = spi_hypertext_finalize;
-
- /* Initialize epv table */
+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}
+};
- epv->getNLinks = impl_getNLinks;
- epv->getLink = impl_getLink;
- epv->getLinkIndex = impl_getLinkIndex;
-}
-
-static void
-spi_hypertext_init (SpiHypertext *hypertext)
+void
+spi_initialize_hypertext (DRouteData * data)
{
-}
-
-BONOBO_TYPE_FUNC_FULL (SpiHypertext,
- Accessibility_Hypertext,
- BONOBO_TYPE_OBJECT,
- spi_hypertext);
+ droute_add_interface (data, "org.freedesktop.accessibility.Hypertext",
+ methods, NULL,
+ (DRouteGetDatumFunction) get_hypertext_from_path,
+ NULL);
+};