2001-08-24 Mark McLoughlin <mark@skynet.ie>
[platform/core/uifw/at-spi2-atk.git] / libspi / listener.c
index 785eaa9..9dcdb1b 100644 (file)
@@ -1,14 +1,37 @@
 /*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2001 Sun Microsystems 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.
+ */
+
+/*
  * listener.c: test for accessibility implementation
  *
  */
-#define DEBUG_PRINTSTUFF
-#ifdef DEBUG_PRINTSTUFF
+
+#ifdef SPI_DEBUG
 #include <stdio.h>
 #endif
+
 #include <config.h>
 #include <bonobo/Bonobo.h>
-#include <Accessible.h>
+#include <libspi/Accessibility.h>
 
 /*
  * This pulls the definition for the BonoboObject (GType)
@@ -18,7 +41,7 @@
 /*
  * Our parent Gtk object type
  */
-#define PARENT_TYPE BONOBO_X_OBJECT_TYPE
+#define PARENT_TYPE BONOBO_OBJECT_TYPE
 
 /*
  * A pointer to our parent object class
@@ -33,8 +56,9 @@ listener_object_finalize (GObject *object)
 {
 /*        Listener *listener = LISTENER (object); */
 
-        printf("listener_object_finalize called\n");
-
+#ifdef SPI_DEBUG
+        fprintf(stderr, "listener_object_finalize called\n");
+#endif
         listener_parent_class->finalize (object);
 }
 
@@ -47,9 +71,26 @@ impl_notify_event (PortableServer_Servant     servant,
                    const Accessibility_Event *e,
                    CORBA_Environment         *ev)
 {
-  fprintf (stderr, "notify...\n");
+#ifdef SPI_DEBUG
+  fprintf (stderr, "notify %s...\n", e->type);
   fprintf (stderr, "source name: '%s'\n",
-          Accessibility_Accessible__get_name(e->target, ev));
+           Accessibility_Accessible__get_name(e->source, ev));
+  if (ev->_major != CORBA_NO_EXCEPTION) {
+    fprintf(stderr,
+            ("Accessibility app error: exception during event notification: %s\n"),
+            CORBA_exception_id(ev));
+    exit(-1);
+  }
+  /*
+  fprintf (stderr, "source is component ? : %s\n",
+           Accessibility_Accessible_queryInterface (e->source,
+                                                    "IDL:Accessibility/Component:1.0",
+                                                    ev)
+           ? "yes" : "no");
+  */
+  /* TODO: free/deref the returned interface! */
+#endif
+  Bonobo_Unknown_unref (e->source, ev);
 }
 
 static void
@@ -57,7 +98,7 @@ listener_class_init (ListenerClass *klass)
 {
         GObjectClass * object_class = (GObjectClass *) klass;
         POA_Accessibility_EventListener__epv *epv = &klass->epv;
-        listener_parent_class = g_type_class_ref (BONOBO_X_OBJECT_TYPE);
+        listener_parent_class = g_type_class_ref (BONOBO_OBJECT_TYPE);
 
         object_class->finalize = listener_object_finalize;
 
@@ -88,12 +129,12 @@ listener_get_type (void)
                         NULL /* value table */
                 };
                 /*
-                 *   Here we use bonobo_x_type_unique instead of
+                 *   Here we use bonobo_type_unique instead of
                  * gtk_type_unique, this auto-generates a load of
                  * CORBA structures for us. All derived types must
-                 * use bonobo_x_type_unique.
+                 * use bonobo_type_unique.
                  */
-                type = bonobo_x_type_unique (
+                type = bonobo_type_unique (
                         PARENT_TYPE,
                         POA_Accessibility_EventListener__init,
                         NULL,