2002-08-12 Michael Meeks <michael@ximian.com>
[platform/core/uifw/at-spi2-atk.git] / cspi / bonobo / cspi-bonobo.c
index 891b029..ff239f9 100644 (file)
@@ -1,11 +1,34 @@
-#include "../cspi-lowlevel.h"
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2001 Sun Microsystems Inc.
+ *           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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
 
+#include <string.h>
 #include <libbonobo.h>
+#include "../cspi-lowlevel.h"
 
-void
+CORBA_Object
 cspi_dup_ref (CORBA_Object object)
 {
-  bonobo_object_dup_ref (object, NULL);
+  return bonobo_object_dup_ref (object, NULL);
 }
 
 void
@@ -40,3 +63,67 @@ cspi_check_ev (const char *error_string)
     }
 }
 
+char *
+cspi_exception_get_text (void)
+{
+  char *ret, *txt;
+
+  txt = bonobo_exception_get_text (cspi_ev ());
+  ret = strdup (txt);
+  g_free (txt);
+
+  return ret;
+}
+
+CORBA_Object
+cspi_init (void)
+{
+  char *obj_id;
+  CORBA_Object registry;
+  CORBA_Environment ev;
+
+  if (!bonobo_init (0, NULL))
+    {
+      g_error ("Could not initialize Bonobo");
+    }
+
+  obj_id = "OAFIID:Accessibility_Registry:1.0";
+
+  CORBA_exception_init (&ev);
+
+  registry = bonobo_activation_activate_from_id (
+    obj_id, 0, NULL, &ev);
+
+  if (ev._major != CORBA_NO_EXCEPTION)
+    {
+      g_error ("AT-SPI error: during registry activation: %s\n",
+              bonobo_exception_get_text (&ev));
+    }
+
+  if (registry == CORBA_OBJECT_NIL)
+    {
+      g_error ("Could not locate registry");
+    }
+
+  bonobo_activate ();
+
+  return registry;
+}
+
+SPIBoolean
+cspi_ping (CORBA_Object object)
+{
+       return bonobo_unknown_ping (object, NULL);
+}
+
+void
+cspi_main (void)
+{
+  bonobo_main ();
+}
+
+void
+cspi_main_quit (void)
+{
+  bonobo_main_quit ();
+}