2001-12-07 Michael Meeks <michael@ximian.com>
authormichael <michael@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Fri, 7 Dec 2001 16:42:23 +0000 (16:42 +0000)
committermichael <michael@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Fri, 7 Dec 2001 16:42:23 +0000 (16:42 +0000)
* libspi/component.c
(impl_accessibility_component_get_extents): make it match
it's sig.

* libspi/registry.c (_registry_notify_listeners):
re-remove X headers & reconcile conflicts.
(spi_listener_struct_free): bad conflict resolve.
(impl_accessibility_registry_register_application):
more bad merging fixed.
(impl_accessibility_registry_deregister_application): ditto.
(spi_registry_new): ditto.
(spi_registry_init): don't have an applications field.

[ merge fixups2 branch to here ]
2001-12-07  Michael Meeks  <michael@ximian.com>

* test/simple-at.c (report_focus_event),
(report_focussed_accessible): remove g_warning debug.

2001-12-07  Michael Meeks  <michael@ximian.com>

* test/test-simple.c (validate_tree): comment out some checks.
(test_desktop): app now not registered idly - horay.

2001-12-07  Michael Meeks  <michael@ximian.com>

* cspi/spi_registry.c
(registerAccessibleKeystrokeListener): clean, stop it leaking
great swathes of memory, and device event controller references.
ensure we always pass valid sequences.
(deregisterAccessibleKeystrokeListener): ditto.
(generateKeyEvent): upd.

* at-bridge/bridge.c (bridge_key_listener): handle
registry dead exception gracefully.
(bridge_focus_tracker, emit_eventv): free ev.

* test/simple-at.c (report_focus_event): fix polarity.

* libspi/application.c (notify_listeners): kill the ev
argument, and make sure we init the ev we use.
(spi_application_object_event_listener): split out a chunk
(get_atk_object_ref): here & fixup.
(reverse_lookup_name_for_toolkit_event): make const.
(spi_application_toolkit_event_listener): fixup, kill leaks
ref problems etc.

* at-bridge/bridge.c (register_atk_event_listeners):
don't unref the noop object - causes grief.

* libspi/registry.c: remove the X headers.
turn off the debug churn.

* libspi/accessible.c (spi_accessible_new_return): only
release the ref if we are supposed to [doh]

* test/simple-at.c (report_button_press, report_focus_event):
guard vs. unexpected exit.

* at-bridge/bridge.c (gtk_module_init): prune printf.
(bridge_exit_func): fix app unref.

* libspi/Makefile.am: don't install registry or desktop.h

* libspi/*.h: update includes.

* libspi/application.h: don't include ourself, or
other redundant headers.

2001-12-06  Michael Meeks  <michael@ximian.com>

* libspi/accessible.c
(get_accessible_from_servant): impl.
Upd. all CORBA impl.s to use it killing cut and paste.

* cspi/spi_main.c (cspi_cleanup): guard vs. double
invokes.
(SPI_init): register atexit cleanup handler here.

2001-12-06  Michael Meeks  <michael@ximian.com>

* at-bridge/bridge.c (gtk_module_init): g_error on
activation exception

2001-12-06  Michael Meeks  <michael@ximian.com>

* at-bridge/bridge.c (gtk_module_init): some sort of
confusing merge clash - reverted.
(bridge_idle_init): ditto.

* test/test-simple.c (main, utterable_normal_derefs):
merge from Bill - somehow not committed.

2001-12-06  Michael Meeks  <michael@ximian.com>

* libspi/value.c (spi_value_class_init): upd.
(spi_value_finalize): kill.

* libspi/table.c (spi_table_finalize): kill.
(spi_table_interface_new): upd.
(spi_table_class_init): upd.
(get_table_from_servant): impl.
Upd. all CORBA impl.s to use it killing yet more cut and paste.

* libspi/selection.c (spi_selection_finalize): kill.
(spi_selection_interface_new): upd.
(spi_selection_class_init): upd.
(get_selection_from_servant): impl.
Upd. all CORBA impl.s to use it killing yet more cut and paste.

* libspi/relation.c (spi_relation_finalize): kill.
(spi_relation_class_init, spi_relation_new): upd

* libspi/image.c (spi_image_finalize): kill.
(spi_image_class_init): upd.
(spi_image_interface_new): upd.
(get_image_from_servant): impl.
Upd. all CORBA impl.s to use it killing yet more cut and paste.

* libspi/hyperlink.c (spi_hyperlink_class_init): upd.
(spi_hyperlink_finalize): kill.
(spi_hyperlink_new): upd.
(get_hyperlink_from_servant): impl.
Upd. all CORBA impl.s to use it killing yet more cut and paste.

* libspi/hypertext.c (spi_hypertext_interface_new): upd.
(spi_hypertext_finalize): kill.
(spi_hypertext_class_init): upd.
(get_hypertext_from_servant): impl.
Upd. all CORBA impl.s to use it killing yet more cut and paste.

* libspi/editabletext.c (spi_editable_text_finalize): kill.
(spi_editable_text_interface_new): upd.
(get_editable_text_from_servant): impl.
Upd. all CORBA impl.s to use it killing yet more cut and paste.

* libspi/text.c (get_text_from_servant): impl.
All impls - update to use it killing more cut and paste,
also fix bad string returns on duff args ( a somewhat
impossible case to handle - but hey ).
(spi_text_construct): impl.
(spi_text_interface_new): upd.
(spi_text_object_finalize): kill.

* libspi/component.c
(accessibility_component_object_finalize): kill.
(spi_component_class_init): upd.
(get_component_from_servant): impl. helper to kill cut & paste.
(impl_accessibility_component_contains):
(impl_accessibility_component_get_accessible_at_point):
(impl_accessibility_component_get_position):
(impl_accessibility_component_get_extents):
(impl_accessibility_component_get_mdi_z_order):
(impl_accessibility_component_get_layer):
(spi_component_interface_new): upd.

* libspi/action.c (spi_action_finalize): kill.
(spi_action_class_init): upd. inherit from SpiObject.
(spi_action_interface_new): upd.
(get_action_from_servant): impl. helper to reduce cut & paste.
(impl_getKeyBinding, impl_getName, impl_doAction),
(impl_getDescription): Use it everywhere.

* cspi/spi_main.c (get_live_refs): a pointer hash.
(spi_object_hash, spi_object_equal): comment out.
There are issues with CORBA object hashing that need
solving.

* libspi/application.c (spi_application_init),
(spi_application_new): upd.

* libspi/accessible.c (spi_accessible_object_finalize): kill.
(spi_accessible_class_init): upd.
s/accessible/object/ in epv methods.

2001-12-05  Bill Haneman <bill.haneman@sun.com>

* at-bridge/bridge.c:
Reorder the bridge initialization into the bridge gtk_module_init,
an immediate call to bridge_register_app, and an idle_add for
register_atk_event_listeners (the only code that *must* wait until
GTK+ is initialized) via bridge_idle_add. Bridge_register_app does
the activation, creates the application's Accessible object, and
queues the bridge_idle_init function.  Restored call to
Accessibility_Registry_deregisterApplication().
Prior to making this call we obtain a new reference to the
registry, which is a temporary hack that helps us handle apps that
shut down the bonobo mainloop before we get there.

* libspi/registry.c:
Fix string leakage in debug block, and don't segv if a an app
dies before its event notifications have been propagated.

* cpi/spi_util.c:
Modify cspi_check_ev() to call g_warning() rather than g_error(),
as stopgap measure until we get proper exception handling when
objects die during or before interrogation.

* cspi/spi_main.c:
* cspi/spi.h:
Moved use of isGNOMEApp flag from SPI_event_main to SPI_init.
Also changed default value of is_gnome_app to TRUE.

* test/simple-at.c:
* test/keysynth-demo.c:
Changed use of SPI_init and SPI_event_main to reflect API change above.

* test/simple-at.c:
Made report_focus_event check the warning value from getName
before reporting on focussed accessible; simplifies handling of
notifications from dead objects.

* test/test-simple.c: (Changes not in this patch since source is
not in CVS ?)

2001-12-05  Michael Meeks  <michael@ximian.com>

* registryd/registryd.c (main): protect against
bonobo-activation startup race condition.

* cspi/spi_main.c (cspi_object_add_check): cope
with the exception elegantly.

* idl/Accessible.idl: decl. ChildGone

* libspi/desktop.c (spi_desktop_dispose): impl.
(spi_desktop_class_init): upd.
(spi_desktop_add_application),
(spi_desktop_remove_application),
(abnormal_application_termination): impl.
(impl_desktop_get_child_at_index): re-impl.

* libspi/registry.c
(impl_accessibility_registry_deregister_application),
(impl_accessibility_registry_register_application):
kill excessive debug clutter.

* test/test-simple.c (test_misc): test some NULL
tolerance. (main): upd.

* cspi/spi_main.c (cspi_accessible_is_a): a NULL
implements no interfaces - so let's not crash.

* cspi/spi_accessible.c (Accessible_queryInterface): ditto.

* libspi/accessible.c (spi_accessible_new_return): impl.
helper to calm the cut and paste, to cope with
NULL AtkObjects effectively and efficiently, and to kill
the referencing bugs.

* libspi/table.c (impl_getAccessibleAt),
(impl_getRowHeader, impl_getColumnHeader): upd.

* libspi/hyperlink.c (impl_getObject): upd.

* libspi/accessible.c
(impl_accessibility_accessible_get_child_at_index): upd.

* libspi/component.c
(impl_accessibility_component_get_accessible_at_point): upd.

* test/test-simple.c (test_editable_text, test_text): impl.
some simple tests.

* cspi/spi_editabletext.c
(AccessibleEditableText_insertText): constify.

* test/test-simple.c (focus_me): make more robust.

* libspi/accessible.c: remove some printfs in methods that
we test and work fine, so we can get a clean tree dump.

* test/test-simple.c (validate_accessible),
(validate_tree): make tree dumping pretty too.

* at-bridge/bridge.c (bridge_signal_listener): upd. so
it builds without debug on.

* test/test-simple.c (validate_accessible): fix the most
ludicrous bug.

* cspi/spi_main.c (spi_object_release): leave the nicely
blanked memory around if in debug mode.

* cspi/spi-listener-impl.c (cspi_event): use add_check.

[committed to fixups2]
2001-12-05  Michael Meeks  <michael@ximian.com>

* libspi/editabletext.c
(spi_editable_text_class_init): g_type_class_peek_parent,
not interface peek - so we finalize cleanly.

* libspi/accessible.c (spi_accessible_new): kill debug.

* test/test-simple.c (validate_accessible): fix ref.
leak, print strings before freeing them; sigh, comment a
chunk out due to strangeness.
(validate_tree): unref the child after use.

* cspi/spi_component.c (AccessibleComponent_getLayer):
add missing break statement, switch on zlayer not the
uninitialized retval.

* cspi/spi_main.c (cspi_object_add): add assert, local ref
before (possibly re-entering) remote unref.

* test/simple-at.c (main): unref the desktop.

* cspi/spi_accessible.c (cspi_accessible_is_a): move
into:

* cspi/spi_main.c (cspi_accessible_is_a): here to
isolate bonobo API usage more.

* libspi/registry.c (impl_accessibility_registry_register_application):
prune bogus comment.

2001-12-04  Michael Meeks  <michael@ximian.com>

* test/test-simple.c (validate_tree): upd.
IndexInParent check to make it more lucid.
(validate_accessible): dump the tree.

* libspi/accessible.c (de_register_public_ref),
(get_public_refs): impl.
(spi_accessible_new): make more efficient & intuitive.
Now IndexInParent check works.

2001-12-04  Michael Meeks  <michael@ximian.com>

* cspi/spi-util.h: remove.

* cspi/spi.h: move SPI_freeString here

* libspi/component.c (impl_accessibility_component_get_layer):
warning fixage.
(impl_accessibility_component_get_mdi_z_order): ditto,
return -1 on error - is this ok ?

* test/test-simple.c (test_application): impl.

* cspi/spi_accessible.c (Accessible_getApplication),
(Accessible_isApplication): impl.

* libspi/registry.c (spi_listener_struct_free): release
the CORBA reference too.

* libspi/accessible.c
(impl_accessibility_accessible_get_parent): fix ref leak.

* libspi/registry.c (spi_registry_new): make the registry
immortal - we don't want it to go away ever.

* libspi/application.c
(spi_accessible_application_finalize): impl. cleanup.

* cspi/spi_registry.c
(deregisterGlobalEventListenerAll),
(deregisterGlobalEventListener),
(deregisterAccessibleKeystrokeListener): fix ref leak.

* cspi/spi_main.c (SPI_init): remove redundant ref.

* test/test-simple.c (unutterable_horror): impl. to force a
clean shutdown.
(main): use it.

* libspi/registry.c
(impl_accessibility_registry_deregister_application): release
the application when we de-register it.

* at-bridge/bridge.c (bridge_exit_func): comment out shutdown
until we have the infastructure to get it right.

2001-12-03  Michael Meeks  <michael@ximian.com>

* libspi/Makefile.am: only build eventlistener.[ch]

* libspi/accessible.c
(impl_accessibility_accessible_get_child_at_index): don't leak.

* at-bridge/bridge.c (bridge_exit_func): cope with an exit
before we hit the idle handler.

* cspi/spi-util.c (cspi_check_ev): g_error is far nicer for
debugging than exit.

* at-bridge/bridge.c (bridge_focus_tracker): fix ref issue.

* libspi/listener.c (impl_notify_event): check source
not NIL before unref.

* libspi/registry.c (impl_registry_notify_event): ditto.

* libspi/eventlistener.c
(impl_accessible_event_notify_event): unref the source.

* libspi/accessibleeventlistener.c
(impl_accessible_event_notify_event): unref the source.

* idl/Event.idl: remove 'hash_id' attribute - of no
concievable use.

* libspi/application.c (notify_listeners): upd list
iteration & sig.
(spi_application_object_event_listener),
(spi_application_toolkit_event_listener): upd to do correct
CORBA ref counting.

* libspi/registry.c
(_registry_notify_listeners): update.
(parse_event_type): this method also leaks like a sieve.
(impl_accessibility_registry_deregister_global_event_listener):
fix ETYPE_WINDOW case.

* libspi/application.c
(impl_accessibility_application_register_object_event_listener):
kill leak.

* libspi/hyperlink.c (impl_getObject): fix ref mistake.

* libspi/hypertext.c (impl_getLink): ditto.

* cspi/spi_main.c (cspi_object_add): remove
bogus CORBA_Object_duplicate.

* cspi/spi-listener-impl.c (cspi_event): dup/ref
on the object_add.

* cspi/spi_accessible.c
(Accessible_getRelationSet): fix leak / referencing issue.

* cspi/spi_main.c (spi_object_hash, spi_object_equal): impl.
(cspi_object_add, cspi_object_unref): upd.
(spi_object_release, get_live_refs): impl.
(cspi_cleanup): simplify.

* *.[ch]: s/boolean/SpiBoolean/

* cspi/spi_accessible.c (role_names): actualy order so it
corresponds with the enum !

* test/test-simple.c (test_roles): check some role strings
vs. enums to detect offset errors.

2001-12-01  Michael Meeks  <michael@ximian.com>

* cspi/spi_main.c (cspi_object_add_check): impl. helper.

* cspi/spi_accessible.c (Accessible_getChildAtIndex):
check ev before
(Accessible_getChildAtIndex): use cspi_add_check so we
check the ev before using a (possibly) invalid value.

* libspi/accessible.c
(impl_accessibility_accessible_get_parent): don't segv
on a NULL parent.

* at-bridge/bridge.c (gtk_module_init): upd.
(bridge_property_event_listener): don't leak strings
and events !
(bridge_state_event_listener),
(bridge_property_event_listener): don't use a static
buffer in case of recursive event emission &
re-enterancy - split out the swathe of cut and paste
into:
(emit_eventv): and fix 2 ref leaks here & comply to the
coding style.
(bridge_register_app): rename to
(bridge_idle_init): this and kill arg parsing, split
various inits & bonobo-activation registration to module
init time, kill referencing error.
(bridge_exit_func): fix the same leak.
(bridge_focus_tracker): don't leak event structures
and strings.
(bridge_signal_listener): more leakage and cut & paste
fixage.
(bridge_key_listener): return the result - FIXME is
this polarity correct ?
(accessibility_keystroke_from_atk_key_event): rename
(accessibility_init_keystroke_from_atk_key_event): and stop
leakage.
(gtk_module_init): return a value - not that it is checked by
Gtk - but hey.
(bridge_key_listener): register my horror at casting between
IDL defined structs.
(bridge_get_registry): kill - not used.

* cspi/spi_accessible.c (Accessible_getRole): make return const.

* test/test-simple.c (test_roles): impl.
(test_desktop, validate_accessible, validate_tree): impl.

* cspi/spi_accessible.c (role_names): fixup bogus
MAX_ROLES setup, make constants const for efficient linkage
(AccessibleRole_getName): conform to coding style, make
return 'const'

2001-11-30  Michael Meeks  <michael@ximian.com>

* cspi/spi.h: add missing prototype.

* libspi/registry.c (spi_listener_struct_new): fix sig.

* test/Makefile.am: add test-simple

* test/test-simple.c: add

* test/test.sh: add.

* cspi/spi_main.c (SPI_init): make SPI_inited module global,

* at-bridge/bridge.c (gtk_module_init): don't do an idle init,
do it straight - since otherwise we often get an activation race.

[ work before Bill duplicated a chunk of it ... ]
2001-11-30  Michael Meeks  <michael@ximian.com>

* libspi/keystrokelistener.c
(spi_keystroke_listener_class_init): fixup arg
count (doh).

* libspi/eventlistener.c
(spi_event_listener_class_init): ditto.

* tests/test.sh: add.

* cspi/spi-listener-impl.h: update macros.

* cspi/spi-listener-impl.c
(cspi_event_listener_remove_callback): add
correct pre-conditions.

* cspi/spi_main.c (SPI_exit): guard vs. double
exits, exit the mainloop nicely.
(SPI_event_main): make more sense.
(SPI_init): move the atexit evilness here so we
always do it (yuck).
(SPI_event_main): upd.

* test/simple-at.c: update for listener changes.

* registryd/registryd.c (main): prune kruft.

* libspi/libspi.h: upd.

* libspi/eventlistener.[ch]: rename broken macros.

* libspi/accessibleeventlistener.[ch]: remove.

* libspi/*.[ch]: IS_SPI_... -> SPI_IS_...

* test/test-simple.c: Add - automated tests.

* cspi/spi-listener-impl.c (cspi_event),
(cspi_key_event): add user_data to invoke.
(cspi_keystroke_listener_finalize): impl.
(cspi_keystroke_listener_class_init): upd.

* cspi/spi_event.c
(createAccessibleEventListener),
(AccessibleEventListener_addCallback),
(createAccessibleKeystrokeListener),
(AccessibleKeystrokeListener_addCallback): upd.

* libspi/deviceeventcontroller.c
(spi_device_event_controller_check_key_event): add public proto.

* libspi/registry.c
(impl_accessibility_registry_deregister_global_event_listener):
always init listeners.
(_registry_notify_listeners): yes it is.

* cspi/spi-listener-impl.c (cspi_key_event):
move debug to here.
(cspi_event_listener_finalize): impl.
(cspi_event_listener_class_init): hook up.
(event_handler_new, event_handler_free),
(event_list_remove_by_callback): impl.
(cspi_event_listener_remove_callback),
(cspi_keystroke_listener_remove_callback),
(cspi_keystroke_listener_add_callback),
(cspi_event_listener_add_callback): upd.

* libspi/keystrokelistener.c
(keystroke_listener_object_finalize): kill
(spi_keystroke_listener_class_init): upd.
(spi_keystroke_listener_add_callback),
(spi_keystroke_listener_remove_callback): kill,
use signals.
(impl_key_event): prune drasticaly.

* libspi/eventlistener.c
(spi_event_listener_add_callback),
(spi_event_listener_remove_callback): kill, use
signals.
(impl_accessible_event_notify_event): upd.
(spi_event_listener_object_finalize): remove.

* libspi/Makefile.am: use eventlistener.[ch]

git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@145 e2bd861d-eb25-0410-b326-f6ed22b6b98c

.cvsignore
ChangeLog
at-bridge/bridge.c
atk-bridge/bridge.c

index b8f68f4..0101d03 100644 (file)
@@ -24,4 +24,3 @@ oaf.spec.in
 stamp-h
 stamp-h.in
 xml-i18n-*
-at-spi-1.0.pc
index 5feeebe..b9a3a86 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,607 @@
+2001-12-07  Michael Meeks  <michael@ximian.com>
+
+       * libspi/component.c
+       (impl_accessibility_component_get_extents): make it match
+       it's sig.
+
+       * libspi/registry.c (_registry_notify_listeners):
+       re-remove X headers & reconcile conflicts.
+       (spi_listener_struct_free): bad conflict resolve.
+       (impl_accessibility_registry_register_application):
+       more bad merging fixed.
+       (impl_accessibility_registry_deregister_application): ditto.
+       (spi_registry_new): ditto.
+       (spi_registry_init): don't have an applications field.
+
+[ merge fixups2 branch to here ]
+2001-12-07  Michael Meeks  <michael@ximian.com>
+
+       * test/simple-at.c (report_focus_event),
+       (report_focussed_accessible): remove g_warning debug.
+
+2001-12-07  Michael Meeks  <michael@ximian.com>
+
+       * test/test-simple.c (validate_tree): comment out some checks.
+       (test_desktop): app now not registered idly - horay.
+
+2001-12-07  Michael Meeks  <michael@ximian.com>
+
+       * cspi/spi_registry.c
+       (registerAccessibleKeystrokeListener): clean, stop it leaking
+       great swathes of memory, and device event controller references.
+       ensure we always pass valid sequences.
+       (deregisterAccessibleKeystrokeListener): ditto.
+       (generateKeyEvent): upd.
+
+       * at-bridge/bridge.c (bridge_key_listener): handle
+       registry dead exception gracefully.
+       (bridge_focus_tracker, emit_eventv): free ev.
+
+       * test/simple-at.c (report_focus_event): fix polarity.
+
+       * libspi/application.c (notify_listeners): kill the ev
+       argument, and make sure we init the ev we use.
+       (spi_application_object_event_listener): split out a chunk
+       (get_atk_object_ref): here & fixup.
+       (reverse_lookup_name_for_toolkit_event): make const.
+       (spi_application_toolkit_event_listener): fixup, kill leaks
+       ref problems etc.
+
+       * at-bridge/bridge.c (register_atk_event_listeners):
+       don't unref the noop object - causes grief.
+
+       * libspi/registry.c: remove the X headers.
+       turn off the debug churn.
+
+       * libspi/accessible.c (spi_accessible_new_return): only
+       release the ref if we are supposed to [doh]
+
+       * test/simple-at.c (report_button_press, report_focus_event):
+       guard vs. unexpected exit.
+
+       * at-bridge/bridge.c (gtk_module_init): prune printf.
+       (bridge_exit_func): fix app unref.
+
+       * libspi/Makefile.am: don't install registry or desktop.h
+
+       * libspi/*.h: update includes.
+
+       * libspi/application.h: don't include ourself, or
+       other redundant headers.
+
+2001-12-06  Michael Meeks  <michael@ximian.com>
+
+       * libspi/accessible.c
+       (get_accessible_from_servant): impl.
+       Upd. all CORBA impl.s to use it killing cut and paste.
+
+       * cspi/spi_main.c (cspi_cleanup): guard vs. double
+       invokes.
+       (SPI_init): register atexit cleanup handler here.
+
+2001-12-06  Michael Meeks  <michael@ximian.com>
+
+       * at-bridge/bridge.c (gtk_module_init): g_error on
+       activation exception
+
+2001-12-06  Michael Meeks  <michael@ximian.com>
+
+       * at-bridge/bridge.c (gtk_module_init): some sort of
+       confusing merge clash - reverted.
+       (bridge_idle_init): ditto.
+
+       * test/test-simple.c (main, utterable_normal_derefs):
+       merge from Bill - somehow not committed.
+
+2001-12-06  Michael Meeks  <michael@ximian.com>
+
+       * libspi/value.c (spi_value_class_init): upd.
+       (spi_value_finalize): kill.
+
+       * libspi/table.c (spi_table_finalize): kill.
+       (spi_table_interface_new): upd.
+       (spi_table_class_init): upd.
+       (get_table_from_servant): impl.
+       Upd. all CORBA impl.s to use it killing yet more cut and paste.
+
+       * libspi/selection.c (spi_selection_finalize): kill.
+       (spi_selection_interface_new): upd.
+       (spi_selection_class_init): upd.
+       (get_selection_from_servant): impl.
+       Upd. all CORBA impl.s to use it killing yet more cut and paste.
+
+       * libspi/relation.c (spi_relation_finalize): kill.
+       (spi_relation_class_init, spi_relation_new): upd
+
+       * libspi/image.c (spi_image_finalize): kill.
+       (spi_image_class_init): upd.
+       (spi_image_interface_new): upd.
+       (get_image_from_servant): impl.
+       Upd. all CORBA impl.s to use it killing yet more cut and paste.
+
+       * libspi/hyperlink.c (spi_hyperlink_class_init): upd.
+       (spi_hyperlink_finalize): kill.
+       (spi_hyperlink_new): upd.
+       (get_hyperlink_from_servant): impl.
+       Upd. all CORBA impl.s to use it killing yet more cut and paste.
+
+       * libspi/hypertext.c (spi_hypertext_interface_new): upd.
+       (spi_hypertext_finalize): kill.
+       (spi_hypertext_class_init): upd.
+       (get_hypertext_from_servant): impl.
+       Upd. all CORBA impl.s to use it killing yet more cut and paste.
+
+       * libspi/editabletext.c (spi_editable_text_finalize): kill.
+       (spi_editable_text_interface_new): upd.
+       (get_editable_text_from_servant): impl.
+       Upd. all CORBA impl.s to use it killing yet more cut and paste.
+       
+       * libspi/text.c (get_text_from_servant): impl.
+       All impls - update to use it killing more cut and paste,
+       also fix bad string returns on duff args ( a somewhat
+       impossible case to handle - but hey ).
+       (spi_text_construct): impl.
+       (spi_text_interface_new): upd.
+       (spi_text_object_finalize): kill.
+
+       * libspi/component.c
+       (accessibility_component_object_finalize): kill.
+       (spi_component_class_init): upd.
+       (get_component_from_servant): impl. helper to kill cut & paste.
+       (impl_accessibility_component_contains): 
+       (impl_accessibility_component_get_accessible_at_point): 
+       (impl_accessibility_component_get_position): 
+       (impl_accessibility_component_get_extents): 
+       (impl_accessibility_component_get_mdi_z_order): 
+       (impl_accessibility_component_get_layer): 
+       (spi_component_interface_new): upd.
+
+       * libspi/action.c (spi_action_finalize): kill.
+       (spi_action_class_init): upd. inherit from SpiObject.
+       (spi_action_interface_new): upd.
+       (get_action_from_servant): impl. helper to reduce cut & paste.
+       (impl_getKeyBinding, impl_getName, impl_doAction),
+       (impl_getDescription): Use it everywhere.
+
+       * cspi/spi_main.c (get_live_refs): a pointer hash.
+       (spi_object_hash, spi_object_equal): comment out.
+       There are issues with CORBA object hashing that need
+       solving.
+
+       * libspi/application.c (spi_application_init),
+       (spi_application_new): upd.
+
+       * libspi/accessible.c (spi_accessible_object_finalize): kill.
+       (spi_accessible_class_init): upd.
+       s/accessible/object/ in epv methods.
+
+2001-12-05  Bill Haneman <bill.haneman@sun.com>
+
+       * at-bridge/bridge.c:
+       Reorder the bridge initialization into the bridge gtk_module_init,
+       an immediate call to bridge_register_app, and an idle_add for
+       register_atk_event_listeners (the only code that *must* wait until
+       GTK+ is initialized) via bridge_idle_add. Bridge_register_app does
+       the activation, creates the application's Accessible object, and
+       queues the bridge_idle_init function.  Restored call to
+       Accessibility_Registry_deregisterApplication().  
+       Prior to making this call we obtain a new reference to the
+       registry, which is a temporary hack that helps us handle apps that
+       shut down the bonobo mainloop before we get there.
+
+       * libspi/registry.c:
+       Fix string leakage in debug block, and don't segv if a an app
+       dies before its event notifications have been propagated.
+
+       * cpi/spi_util.c:
+       Modify cspi_check_ev() to call g_warning() rather than g_error(),
+       as stopgap measure until we get proper exception handling when 
+       objects die during or before interrogation.  
+
+       * cspi/spi_main.c:
+       * cspi/spi.h:
+       Moved use of isGNOMEApp flag from SPI_event_main to SPI_init.
+       Also changed default value of is_gnome_app to TRUE.
+
+       * test/simple-at.c:
+       * test/keysynth-demo.c:
+       Changed use of SPI_init and SPI_event_main to reflect API change above.
+
+       * test/simple-at.c:
+       Made report_focus_event check the warning value from getName
+       before reporting on focussed accessible; simplifies handling of
+       notifications from dead objects.
+
+       * test/test-simple.c: (Changes not in this patch since source is
+       not in CVS ?)
+       
+2001-12-05  Michael Meeks  <michael@ximian.com>
+
+       * registryd/registryd.c (main): protect against
+       bonobo-activation startup race condition.
+
+       * cspi/spi_main.c (cspi_object_add_check): cope
+       with the exception elegantly.
+
+       * idl/Accessible.idl: decl. ChildGone
+
+       * libspi/desktop.c (spi_desktop_dispose): impl.
+       (spi_desktop_class_init): upd.
+       (spi_desktop_add_application),
+       (spi_desktop_remove_application),
+       (abnormal_application_termination): impl.
+       (impl_desktop_get_child_at_index): re-impl.
+
+       * libspi/registry.c
+       (impl_accessibility_registry_deregister_application),
+       (impl_accessibility_registry_register_application): 
+       kill excessive debug clutter.
+
+       * test/test-simple.c (test_misc): test some NULL
+       tolerance. (main): upd.
+
+       * cspi/spi_main.c (cspi_accessible_is_a): a NULL
+       implements no interfaces - so let's not crash.
+
+       * cspi/spi_accessible.c (Accessible_queryInterface): ditto.
+
+       * libspi/accessible.c (spi_accessible_new_return): impl.
+       helper to calm the cut and paste, to cope with
+       NULL AtkObjects effectively and efficiently, and to kill
+       the referencing bugs.
+
+       * libspi/table.c (impl_getAccessibleAt),
+       (impl_getRowHeader, impl_getColumnHeader): upd.
+
+       * libspi/hyperlink.c (impl_getObject): upd.
+
+       * libspi/accessible.c
+       (impl_accessibility_accessible_get_child_at_index): upd.
+
+       * libspi/component.c
+       (impl_accessibility_component_get_accessible_at_point): upd.
+
+       * test/test-simple.c (test_editable_text, test_text): impl.
+       some simple tests.
+
+       * cspi/spi_editabletext.c
+       (AccessibleEditableText_insertText): constify.
+
+       * test/test-simple.c (focus_me): make more robust.
+
+       * libspi/accessible.c: remove some printfs in methods that
+       we test and work fine, so we can get a clean tree dump.
+
+       * test/test-simple.c (validate_accessible),
+       (validate_tree): make tree dumping pretty too.
+
+       * at-bridge/bridge.c (bridge_signal_listener): upd. so
+       it builds without debug on.
+
+       * test/test-simple.c (validate_accessible): fix the most
+       ludicrous bug.
+
+       * cspi/spi_main.c (spi_object_release): leave the nicely
+       blanked memory around if in debug mode.
+
+       * cspi/spi-listener-impl.c (cspi_event): use add_check.
+
+[committed to fixups2]
+2001-12-05  Michael Meeks  <michael@ximian.com>
+
+       * libspi/editabletext.c
+       (spi_editable_text_class_init): g_type_class_peek_parent,
+       not interface peek - so we finalize cleanly.
+
+       * libspi/accessible.c (spi_accessible_new): kill debug.
+
+       * test/test-simple.c (validate_accessible): fix ref.
+       leak, print strings before freeing them; sigh, comment a
+       chunk out due to strangeness.
+       (validate_tree): unref the child after use.
+
+       * cspi/spi_component.c (AccessibleComponent_getLayer):
+       add missing break statement, switch on zlayer not the
+       uninitialized retval.
+
+       * cspi/spi_main.c (cspi_object_add): add assert, local ref
+       before (possibly re-entering) remote unref.
+
+       * test/simple-at.c (main): unref the desktop.
+
+       * cspi/spi_accessible.c (cspi_accessible_is_a): move 
+       into:
+       
+       * cspi/spi_main.c (cspi_accessible_is_a): here to 
+       isolate bonobo API usage more.
+
+       * libspi/registry.c (impl_accessibility_registry_register_application): 
+       prune bogus comment.
+
+2001-12-04  Michael Meeks  <michael@ximian.com>
+
+       * test/test-simple.c (validate_tree): upd.
+       IndexInParent check to make it more lucid.
+       (validate_accessible): dump the tree.
+
+       * libspi/accessible.c (de_register_public_ref),
+       (get_public_refs): impl.
+       (spi_accessible_new): make more efficient & intuitive.
+       Now IndexInParent check works.
+
+2001-12-04  Michael Meeks  <michael@ximian.com>
+
+       * cspi/spi-util.h: remove.
+
+       * cspi/spi.h: move SPI_freeString here
+
+       * libspi/component.c (impl_accessibility_component_get_layer): 
+       warning fixage.
+       (impl_accessibility_component_get_mdi_z_order): ditto,
+       return -1 on error - is this ok ?
+
+       * test/test-simple.c (test_application): impl.
+
+       * cspi/spi_accessible.c (Accessible_getApplication),
+       (Accessible_isApplication): impl.
+
+       * libspi/registry.c (spi_listener_struct_free): release
+       the CORBA reference too.
+
+       * libspi/accessible.c
+       (impl_accessibility_accessible_get_parent): fix ref leak.
+
+       * libspi/registry.c (spi_registry_new): make the registry
+       immortal - we don't want it to go away ever.
+
+       * libspi/application.c
+       (spi_accessible_application_finalize): impl. cleanup.
+
+       * cspi/spi_registry.c
+       (deregisterGlobalEventListenerAll),
+       (deregisterGlobalEventListener),
+       (deregisterAccessibleKeystrokeListener): fix ref leak.
+
+       * cspi/spi_main.c (SPI_init): remove redundant ref.
+
+       * test/test-simple.c (unutterable_horror): impl. to force a
+       clean shutdown.
+       (main): use it.
+
+       * libspi/registry.c
+       (impl_accessibility_registry_deregister_application): release
+       the application when we de-register it.
+
+       * at-bridge/bridge.c (bridge_exit_func): comment out shutdown
+       until we have the infastructure to get it right.
+
+2001-12-03  Michael Meeks  <michael@ximian.com>
+
+       * libspi/Makefile.am: only build eventlistener.[ch]
+
+       * libspi/accessible.c
+       (impl_accessibility_accessible_get_child_at_index): don't leak.
+
+       * at-bridge/bridge.c (bridge_exit_func): cope with an exit
+       before we hit the idle handler.
+
+       * cspi/spi-util.c (cspi_check_ev): g_error is far nicer for
+       debugging than exit.
+
+       * at-bridge/bridge.c (bridge_focus_tracker): fix ref issue.
+
+       * libspi/listener.c (impl_notify_event): check source
+       not NIL before unref.
+
+       * libspi/registry.c (impl_registry_notify_event): ditto.
+
+       * libspi/eventlistener.c
+       (impl_accessible_event_notify_event): unref the source.
+
+       * libspi/accessibleeventlistener.c
+       (impl_accessible_event_notify_event): unref the source.
+
+       * idl/Event.idl: remove 'hash_id' attribute - of no
+       concievable use.
+
+       * libspi/application.c (notify_listeners): upd list
+       iteration & sig.
+       (spi_application_object_event_listener), 
+       (spi_application_toolkit_event_listener): upd to do correct
+       CORBA ref counting.
+
+       * libspi/registry.c
+       (_registry_notify_listeners): update.
+       (parse_event_type): this method also leaks like a sieve.
+       (impl_accessibility_registry_deregister_global_event_listener): 
+       fix ETYPE_WINDOW case.
+
+       * libspi/application.c
+       (impl_accessibility_application_register_object_event_listener): 
+       kill leak.
+
+       * libspi/hyperlink.c (impl_getObject): fix ref mistake.
+
+       * libspi/hypertext.c (impl_getLink): ditto.
+
+       * cspi/spi_main.c (cspi_object_add): remove
+       bogus CORBA_Object_duplicate.
+
+       * cspi/spi-listener-impl.c (cspi_event): dup/ref
+       on the object_add.
+
+       * cspi/spi_accessible.c
+       (Accessible_getRelationSet): fix leak / referencing issue.
+
+       * cspi/spi_main.c (spi_object_hash, spi_object_equal): impl.
+       (cspi_object_add, cspi_object_unref): upd.
+       (spi_object_release, get_live_refs): impl.
+       (cspi_cleanup): simplify.
+
+       * *.[ch]: s/boolean/SpiBoolean/
+
+       * cspi/spi_accessible.c (role_names): actualy order so it
+       corresponds with the enum !
+
+       * test/test-simple.c (test_roles): check some role strings
+       vs. enums to detect offset errors.
+
+2001-12-01  Michael Meeks  <michael@ximian.com>
+
+       * cspi/spi_main.c (cspi_object_add_check): impl. helper.
+
+       * cspi/spi_accessible.c (Accessible_getChildAtIndex):
+       check ev before 
+       (Accessible_getChildAtIndex): use cspi_add_check so we
+       check the ev before using a (possibly) invalid value.
+
+       * libspi/accessible.c
+       (impl_accessibility_accessible_get_parent): don't segv
+       on a NULL parent.
+
+       * at-bridge/bridge.c (gtk_module_init): upd.
+       (bridge_property_event_listener): don't leak strings
+       and events !
+       (bridge_state_event_listener),
+       (bridge_property_event_listener): don't use a static
+       buffer in case of recursive event emission &
+       re-enterancy - split out the swathe of cut and paste
+       into:
+       (emit_eventv): and fix 2 ref leaks here & comply to the
+       coding style.
+       (bridge_register_app): rename to 
+       (bridge_idle_init): this and kill arg parsing, split
+       various inits & bonobo-activation registration to module
+       init time, kill referencing error.
+       (bridge_exit_func): fix the same leak.
+       (bridge_focus_tracker): don't leak event structures
+       and strings.
+       (bridge_signal_listener): more leakage and cut & paste
+       fixage.
+       (bridge_key_listener): return the result - FIXME is
+       this polarity correct ?
+       (accessibility_keystroke_from_atk_key_event): rename
+       (accessibility_init_keystroke_from_atk_key_event): and stop
+       leakage.
+       (gtk_module_init): return a value - not that it is checked by
+       Gtk - but hey.
+       (bridge_key_listener): register my horror at casting between
+       IDL defined structs.
+       (bridge_get_registry): kill - not used.
+
+       * cspi/spi_accessible.c (Accessible_getRole): make return const.
+
+       * test/test-simple.c (test_roles): impl.
+       (test_desktop, validate_accessible, validate_tree): impl.
+
+       * cspi/spi_accessible.c (role_names): fixup bogus
+       MAX_ROLES setup, make constants const for efficient linkage
+       (AccessibleRole_getName): conform to coding style, make
+       return 'const'
+
+2001-11-30  Michael Meeks  <michael@ximian.com>
+
+       * cspi/spi.h: add missing prototype.
+
+       * libspi/registry.c (spi_listener_struct_new): fix sig.
+
+       * test/Makefile.am: add test-simple
+
+       * test/test-simple.c: add
+
+       * test/test.sh: add.
+
+       * cspi/spi_main.c (SPI_init): make SPI_inited module global,
+
+       * at-bridge/bridge.c (gtk_module_init): don't do an idle init,
+       do it straight - since otherwise we often get an activation race.
+
+[ work before Bill duplicated a chunk of it ... ]
+2001-11-30  Michael Meeks  <michael@ximian.com>
+
+       * libspi/keystrokelistener.c
+       (spi_keystroke_listener_class_init): fixup arg
+       count (doh).
+
+       * libspi/eventlistener.c
+       (spi_event_listener_class_init): ditto.
+
+       * tests/test.sh: add.
+
+       * cspi/spi-listener-impl.h: update macros.
+
+       * cspi/spi-listener-impl.c
+       (cspi_event_listener_remove_callback): add
+       correct pre-conditions.
+
+       * cspi/spi_main.c (SPI_exit): guard vs. double
+       exits, exit the mainloop nicely.
+       (SPI_event_main): make more sense.
+       (SPI_init): move the atexit evilness here so we
+       always do it (yuck).
+       (SPI_event_main): upd.
+
+       * test/simple-at.c: update for listener changes.
+
+       * registryd/registryd.c (main): prune kruft.
+
+       * libspi/libspi.h: upd.
+
+       * libspi/eventlistener.[ch]: rename broken macros.
+
+       * libspi/accessibleeventlistener.[ch]: remove.
+
+       * libspi/*.[ch]: IS_SPI_... -> SPI_IS_...
+
+       * test/test-simple.c: Add - automated tests.
+
+       * cspi/spi-listener-impl.c (cspi_event),
+       (cspi_key_event): add user_data to invoke.
+       (cspi_keystroke_listener_finalize): impl.
+       (cspi_keystroke_listener_class_init): upd.
+
+       * cspi/spi_event.c
+       (createAccessibleEventListener),
+       (AccessibleEventListener_addCallback),
+       (createAccessibleKeystrokeListener),
+       (AccessibleKeystrokeListener_addCallback): upd.
+
+       * libspi/deviceeventcontroller.c
+       (spi_device_event_controller_check_key_event): add public proto.
+
+       * libspi/registry.c
+       (impl_accessibility_registry_deregister_global_event_listener): 
+       always init listeners.
+       (_registry_notify_listeners): yes it is.
+
+       * cspi/spi-listener-impl.c (cspi_key_event): 
+       move debug to here.
+       (cspi_event_listener_finalize): impl.
+       (cspi_event_listener_class_init): hook up.
+       (event_handler_new, event_handler_free),
+       (event_list_remove_by_callback): impl.
+       (cspi_event_listener_remove_callback),
+       (cspi_keystroke_listener_remove_callback),
+       (cspi_keystroke_listener_add_callback),
+       (cspi_event_listener_add_callback): upd.
+
+       * libspi/keystrokelistener.c
+       (keystroke_listener_object_finalize): kill
+       (spi_keystroke_listener_class_init): upd.
+       (spi_keystroke_listener_add_callback),
+       (spi_keystroke_listener_remove_callback): kill,
+       use signals.
+       (impl_key_event): prune drasticaly.
+
+       * libspi/eventlistener.c
+       (spi_event_listener_add_callback),
+       (spi_event_listener_remove_callback): kill, use
+       signals.
+       (impl_accessible_event_notify_event): upd.
+       (spi_event_listener_object_finalize): remove.
+
+       * libspi/Makefile.am: use eventlistener.[ch]
+
 2001-12-04  Bill Haneman  <bill.haneman@sun.com>
 
        * libspi/registry.c (_registry_notify_listeners):
index ba03e8d..937e964 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdarg.h>
 #include <libbonobo.h>
 #include <orbit/orbit.h>
 #include <atk/atk.h>
 #include "accessible.h"
 #include "application.h"
 
-/* #define SPI_BRIDGE_DEBUG 1 */
-
-#define APP_STATIC_BUFF_SZ 64
-
-typedef struct _ArgStruct ArgStruct;
-
-struct _ArgStruct {
-  gint c;
-  char **v;
-};
+#undef SPI_BRIDGE_DEBUG
 
 static CORBA_Environment ev;
 static Accessibility_Registry registry;
-static SpiApplication *this_app;
+static SpiApplication *this_app = NULL;
 
-static gboolean bridge_register_app (gpointer p);
+static gboolean bridge_idle_init (gpointer user_data);
 static void bridge_focus_tracker (AtkObject *object);
-static void bridge_exit_func(void);
-static gboolean bridge_register_event_listener ();
-static void register_atk_event_listeners();
+static void bridge_exit_func (void);
+static void register_atk_event_listeners (void);
 static gboolean bridge_property_event_listener (GSignalInvocationHint *signal_hint,
                                                guint n_param_values,
                                                const GValue *param_values,
@@ -68,77 +59,72 @@ static gint bridge_key_listener (AtkKeyEventStruct *event,
                                 gpointer data);
 
 int
-gtk_module_init(gint *argc, gchar **argv[])
-{
-  ArgStruct *args = (ArgStruct *) g_new0(ArgStruct, 1);
-  args->c = *argc;
-  args->v = *argv;
-  bridge_register_app (args);
-  g_atexit (bridge_exit_func);
-}
-
-static gboolean
-bridge_register_app (gpointer gp)
+gtk_module_init (gint *argc, gchar **argv[])
 {
-  CORBA_Object oclient;
-  AtkObject *atko;
-  char *obj_id;
-  ArgStruct *args = (ArgStruct *)gp;
+  CORBA_Environment ev;
 
-  CORBA_exception_init(&ev);
-
-  if (!bonobo_init (&(args->c), args->v))
+  if (!bonobo_init (argc, *argv))
     {
       g_error ("Could not initialize Bonobo");
     }
 
-  /* Create the accesssible application server object */
-  this_app = spi_application_new(atk_get_root ());
-
-  obj_id = "OAFIID:Accessibility_Registry:proto0.1";
+  CORBA_exception_init(&ev);
 
-  oclient = bonobo_activation_activate_from_id (obj_id, 0, NULL, &ev);
-  if (ev._major != CORBA_NO_EXCEPTION) {
-    fprintf(stderr,
-            ("Accessibility app error: exception during registry activation from id: %s\n"),
-            CORBA_exception_id(&ev));
-    CORBA_exception_free(&ev);
-  }
+  registry = bonobo_activation_activate_from_id (
+         "OAFIID:Accessibility_Registry:proto0.1", 0, NULL, &ev);
+  
+  if (ev._major != CORBA_NO_EXCEPTION)
+    {
+      g_error ("Accessibility app error: exception during "
+              "registry activation from id: %s\n",
+              CORBA_exception_id (&ev));
+      CORBA_exception_free (&ev);
+    }
 
-  if (CORBA_Object_is_nil (oclient, &ev))
+  if (CORBA_Object_is_nil (registry, &ev))
     {
       g_error ("Could not locate registry");
     }
 
-  registry = (Accessibility_Registry) oclient;
+  bonobo_activate ();
 
-  fprintf(stderr, "About to register application\n");
+  /* Create the accessible application server object */
 
-  Accessibility_Registry_ref (registry, &ev);
-  
-  bonobo_activate ();
+  this_app = spi_application_new (atk_get_root ());
+
+  fprintf (stderr, "About to register application\n");
 
   Accessibility_Registry_registerApplication (registry,
-                                              CORBA_Object_duplicate (BONOBO_OBJREF (this_app), &ev),
+                                              BONOBO_OBJREF (this_app),
                                               &ev);
 
+  g_atexit (bridge_exit_func);
+
+  g_idle_add (bridge_idle_init, NULL);
+
+  return 0;
+}
+
+static gboolean
+bridge_idle_init (gpointer user_data)
+{
   register_atk_event_listeners ();
 
+  fprintf (stderr, "Application registered & listening\n");
+
   return FALSE;
 }
 
 static void
-register_atk_event_listeners ()
+register_atk_event_listeners (void)
 {
-  GType t;
-
   /*
    * kludge to make sure the Atk interface types are registered, otherwise
    * the AtkText signal handlers below won't get registered
    */
 
   AtkObject *o = atk_no_op_object_new (g_object_new (ATK_TYPE_OBJECT, NULL));
-
+  
   /* Register for focus event notifications, and register app with central registry  */
 
   atk_add_focus_tracker (bridge_focus_tracker);
@@ -157,27 +143,110 @@ register_atk_event_listeners ()
   atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:column-deleted");
   atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:model-changed");
   atk_add_key_event_listener    (bridge_key_listener, NULL);
+
+/*  g_object_unref (o); */
 }
 
-static void bridge_exit_func()
+static void
+bridge_exit_func (void)
 {
   fprintf (stderr, "exiting bridge\n");
+
+/*
+  FIXME: this may be incorrect for apps that do their own bonobo shutdown,
+  until we can explicitly shutdown to get the ordering right. */
+
+  if (!bonobo_is_initialized ())
+    {
+      g_warning ("Re-initializing bonobo\n");
+      g_assert (bonobo_init (0, NULL));
+      g_assert (bonobo_activate ());
+      registry = bonobo_activation_activate_from_id (
+         "OAFIID:Accessibility_Registry:proto0.1", 0, NULL, &ev);
+      g_assert (registry);
+      g_assert (this_app);
+    }
+  
   Accessibility_Registry_deregisterApplication (registry,
-                                               CORBA_Object_duplicate (BONOBO_OBJREF (this_app), &ev),
+                                               BONOBO_OBJREF (this_app),
                                                &ev);
-  Accessibility_Registry_unref (registry, &ev);
+  
+  bonobo_object_unref (BONOBO_OBJECT (this_app));
   
   fprintf (stderr, "bridge exit func complete.\n");
+
+  bonobo_debug_shutdown ();
 }
 
-static void bridge_focus_tracker (AtkObject *object)
+static void
+bridge_focus_tracker (AtkObject *object)
 {
-  Accessibility_Event *e = Accessibility_Event__alloc();
-  e->type = CORBA_string_dup ("focus:");
-  e->source = CORBA_Object_duplicate (BONOBO_OBJREF (spi_accessible_new (object)), &ev);
-  e->detail1 = 0;
-  e->detail2 = 0;
-  Accessibility_Registry_notifyEvent (registry, e, &ev);
+  SpiAccessible *source;
+  Accessibility_Event e;
+
+  source = spi_accessible_new (object);
+
+  e.type = "focus:";
+  e.source = CORBA_Object_duplicate (BONOBO_OBJREF (source), &ev);
+  e.detail1 = 0;
+  e.detail2 = 0;
+
+  Accessibility_Registry_notifyEvent (registry, &e, &ev);
+
+  CORBA_exception_free (&ev);
+}
+
+static void
+emit_eventv (GObject      *gobject,
+            unsigned long detail1,
+            unsigned long detail2,
+            const char   *format, ...)
+{
+  va_list             args;
+  Accessibility_Event e;
+  SpiAccessible      *source;
+  AtkObject          *aobject;
+
+  va_start (args, format);
+  
+  if (ATK_IS_IMPLEMENTOR (gobject))
+    {
+      aobject = atk_implementor_ref_accessible (ATK_IMPLEMENTOR (gobject));
+      source  = spi_accessible_new (aobject);
+      g_object_unref (G_OBJECT (aobject));
+    }
+  else if (ATK_IS_OBJECT (gobject))
+    {
+      aobject = ATK_OBJECT (gobject);
+      source  = spi_accessible_new (aobject);
+    }
+  else
+    {
+      aobject = NULL;
+      source  = NULL;
+      g_error ("received property-change event from non-AtkImplementor");
+    }
+
+  if (source != NULL)
+    {
+      e.type = g_strdup_vprintf (format, args);
+      e.source = CORBA_Object_duplicate (BONOBO_OBJREF (source), &ev);
+      e.detail1 = detail1;
+      e.detail2 = detail2;
+
+#ifdef SPI_BRIDGE_DEBUG
+      g_warning ("Emitting event '%s' (%d, %d) on %p",
+                e.type, e.detail1, e.detail2, source);
+#endif
+
+      Accessibility_Registry_notifyEvent (registry, &e, &ev);
+
+      CORBA_exception_free (&ev);
+
+      g_free (e.type);
+    }
+
+  va_end (args);
 }
 
 static gboolean
@@ -186,48 +255,25 @@ bridge_property_event_listener (GSignalInvocationHint *signal_hint,
                                const GValue *param_values,
                                gpointer data)
 {
-  Accessibility_Event *e = Accessibility_Event__alloc();
-  Bonobo_Unknown source = NULL;
-  AtkObject *aobject;
   AtkPropertyValues *values;
   GObject *gobject;
+
+#ifdef SPI_BRIDGE_DEBUG
   GSignalQuery signal_query;
-  gchar *name;
-  char sbuf[APP_STATIC_BUFF_SZ];
+  const gchar *name;
   
   g_signal_query (signal_hint->signal_id, &signal_query);
   name = signal_query.signal_name;
-#ifdef SPI_BRIDGE_DEBUG
+
   fprintf (stderr, "Received (property) signal %s:%s\n",
           g_type_name (signal_query.itype), name);
 #endif
+
   gobject = g_value_get_object (param_values + 0);
   values = (AtkPropertyValues*) g_value_get_pointer (param_values + 1);
 
-  /* notify the actual listeners */
-  if (ATK_IS_IMPLEMENTOR (gobject))
-  {
-    aobject = atk_implementor_ref_accessible (ATK_IMPLEMENTOR (gobject));
-    source = CORBA_Object_duplicate (BONOBO_OBJREF (spi_accessible_new (aobject)), &ev);
-    g_object_unref (G_OBJECT(aobject));
-  }
-  else if (ATK_IS_OBJECT (gobject))
-  {
-    aobject = ATK_OBJECT (gobject);
-    source = CORBA_Object_duplicate (BONOBO_OBJREF (spi_accessible_new (aobject)), &ev);
-  }
-  else
-  {
-    g_error("received property-change event from non-AtkImplementor");
-  }
-  
-  snprintf(sbuf, APP_STATIC_BUFF_SZ, "object:property-change:%s", values->property_name);
-  e->type = CORBA_string_dup (sbuf);
-  e->source = source;
-  e->detail1 = 0;
-  e->detail2 = 0;
-  if (source)
-    Accessibility_Registry_notifyEvent (registry, e, &ev);
+  emit_eventv (gobject, 0, 0, "object:property-change:%s", values->property_name);
+
   return TRUE;
 }
 
@@ -237,92 +283,90 @@ bridge_state_event_listener (GSignalInvocationHint *signal_hint,
                             const GValue *param_values,
                             gpointer data)
 {
-  Accessibility_Event *e = Accessibility_Event__alloc();
-  Bonobo_Unknown source = NULL;
-  AtkObject *aobject;
-  AtkPropertyValues *values;
   GObject *gobject;
+  AtkPropertyValues *values;
+#ifdef SPI_BRIDGE_DEBUG
   GSignalQuery signal_query;
-  gchar *name;
-  char sbuf[APP_STATIC_BUFF_SZ];
+  const gchar *name;
   
   g_signal_query (signal_hint->signal_id, &signal_query);
   name = signal_query.signal_name;
-#ifdef SPI_BRIDGE_DEBUG
   fprintf (stderr, "Received (state) signal %s:%s\n",
           g_type_name (signal_query.itype), name);
 #endif
+
   gobject = g_value_get_object (param_values + 0);
   values = (AtkPropertyValues*) g_value_get_pointer (param_values + 1);
 
-  /* notify the actual listeners */
-  if (ATK_IS_IMPLEMENTOR (gobject))
-  {
-    aobject = atk_implementor_ref_accessible (ATK_IMPLEMENTOR (gobject));
-    source = CORBA_Object_duplicate (BONOBO_OBJREF (spi_accessible_new (aobject)), &ev);
-    g_object_unref (G_OBJECT(aobject));
-  }
-  else if (ATK_IS_OBJECT (gobject))
-  {
-    aobject = ATK_OBJECT (gobject);
-    source = CORBA_Object_duplicate (BONOBO_OBJREF (spi_accessible_new (aobject)), &ev);
-  }
-  else
-  {
-    g_error("received property-change event from non-AtkImplementor");
-  }
-  
-  snprintf(sbuf, APP_STATIC_BUFF_SZ, "object:%s:%s", values->property_name, "?");
-  e->type = CORBA_string_dup (sbuf);
-  e->source = source;
-  e->detail1 = (unsigned long) values->old_value.data[0].v_ulong;
-  e->detail2 = (unsigned long) values->new_value.data[0].v_ulong;
-  if (source)
-    Accessibility_Registry_notifyEvent (registry, e, &ev);
+  emit_eventv (gobject, 
+              (unsigned long) values->old_value.data[0].v_ulong,
+              (unsigned long) values->new_value.data[0].v_ulong,
+              "object:%s:?", values->property_name);
+
   return TRUE;
 }
 
-static Accessibility_KeyStroke *
-accessibility_keystroke_from_atk_key_event (AtkKeyEventStruct *event)
+static void
+accessibility_init_keystroke_from_atk_key_event (Accessibility_KeyStroke *keystroke,
+                                                AtkKeyEventStruct       *event)
 {
-  Accessibility_KeyStroke *keystroke;
-  keystroke = Accessibility_KeyStroke__alloc ();
-
 #ifdef SPI_DEBUG
-  if (event) g_print ("event %c (%d)\n", (int) event->keyval, (int) event->keycode);
+  if (event)
+    {
+      g_print ("event %c (%d)\n", (int) event->keyval, (int) event->keycode);
+    }
   else
 #endif
-  if (!event) g_print ("WARNING: NULL key event!");
+  if (!event)
+    {
+      g_print ("WARNING: NULL key event!");
+    }
   
-  keystroke->keyID = (CORBA_long) event->keyval;
-  keystroke->keycode = (CORBA_short) event->keycode;
+  keystroke->keyID     = (CORBA_long) event->keyval;
+  keystroke->keycode   = (CORBA_short) event->keycode;
   keystroke->timestamp = (CORBA_unsigned_long) event->timestamp;
   keystroke->modifiers = (CORBA_unsigned_short) (event->state & 0xFFFF);
 
   switch (event->type)
     {
     case (ATK_KEY_EVENT_PRESS):
-           keystroke->type = Accessibility_KEY_PRESSED;
-           break;
+      keystroke->type = Accessibility_KEY_PRESSED;
+      break;
     case (ATK_KEY_EVENT_RELEASE):
-           keystroke->type = Accessibility_KEY_RELEASED;
-           break;
+      keystroke->type = Accessibility_KEY_RELEASED;
+      break;
     default:
+      keystroke->type = 0;
+      break;
     }
-  
-  return keystroke;
 }
 
 static gint
 bridge_key_listener (AtkKeyEventStruct *event, gpointer data)
 {
-  Accessibility_KeyStroke *key_event = accessibility_keystroke_from_atk_key_event (event);
-  CORBA_boolean result;
+  CORBA_boolean           result;
+  Accessibility_KeyStroke key_event;
   Accessibility_DeviceEventController controller =
-         Accessibility_Registry_getDeviceEventController (registry, &ev);
-  result = Accessibility_DeviceEventController_notifyListenersSync (controller,
-                                                                   (Accessibility_DeviceEvent *) key_event,
-                                                                   &ev);
+    Accessibility_Registry_getDeviceEventController (registry, &ev);
+
+  if (BONOBO_EX (&ev))
+    {
+      CORBA_exception_free (&ev);
+      result = FALSE;
+    }
+  else
+    {
+
+      accessibility_init_keystroke_from_atk_key_event (&key_event, event);
+
+  /* FIXME: this casting is just totaly bogus */
+      result = Accessibility_DeviceEventController_notifyListenersSync (
+        controller, (Accessibility_DeviceEvent *) &key_event, &ev);
+
+      CORBA_exception_free (&ev);
+    }
+
+  return result;
 }
 
 static gboolean
@@ -331,50 +375,22 @@ bridge_signal_listener (GSignalInvocationHint *signal_hint,
                        const GValue *param_values,
                        gpointer data)
 {
-  Accessibility_Event *e = g_new0(Accessibility_Event, 1);
-  AtkObject *aobject;
-  Bonobo_Unknown source;
-  AtkPropertyValues *values;
   GObject *gobject;
   GSignalQuery signal_query;
-  gchar *name;
-  char sbuf[APP_STATIC_BUFF_SZ];
+  const gchar *name;
   
   g_signal_query (signal_hint->signal_id, &signal_query);
+
   name = signal_query.signal_name;
+
 #ifdef SPI_BRIDGE_DEBUG
   fprintf (stderr, "Received signal %s:%s\n",
           g_type_name (signal_query.itype), name);
 #endif
+
   gobject = g_value_get_object (param_values + 0);
 
-  /* notify the actual listeners */
-  if (ATK_IS_IMPLEMENTOR (gobject))
-  {
-    aobject = atk_implementor_ref_accessible (ATK_IMPLEMENTOR (gobject));
-  }
-  else if (ATK_IS_OBJECT (gobject))
-  {
-    aobject = ATK_OBJECT (gobject);
-    g_object_ref (aobject);
-  }
-  else
-  {
-    g_error("received property-change event from non-AtkImplementor");
-  }
-
-  snprintf(sbuf, APP_STATIC_BUFF_SZ, "%s:%s", name, g_type_name (signal_query.itype));
-  source =  CORBA_Object_duplicate (BONOBO_OBJREF (spi_accessible_new (aobject)), &ev);
-  e->type = CORBA_string_dup (sbuf);
-  e->source = source;
-  e->detail1 = 0;
-  e->detail2 = 0;
-  Accessibility_Registry_notifyEvent (registry, e, &ev);
-  g_object_unref (aobject);
-  return TRUE;
-}
+  emit_eventv (gobject, 0, 0, "%s:%s", name, g_type_name (signal_query.itype));
 
-static Accessibility_Registry bridge_get_registry ()
-{
-  return registry;
+  return TRUE;
 }
index ba03e8d..937e964 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdarg.h>
 #include <libbonobo.h>
 #include <orbit/orbit.h>
 #include <atk/atk.h>
 #include "accessible.h"
 #include "application.h"
 
-/* #define SPI_BRIDGE_DEBUG 1 */
-
-#define APP_STATIC_BUFF_SZ 64
-
-typedef struct _ArgStruct ArgStruct;
-
-struct _ArgStruct {
-  gint c;
-  char **v;
-};
+#undef SPI_BRIDGE_DEBUG
 
 static CORBA_Environment ev;
 static Accessibility_Registry registry;
-static SpiApplication *this_app;
+static SpiApplication *this_app = NULL;
 
-static gboolean bridge_register_app (gpointer p);
+static gboolean bridge_idle_init (gpointer user_data);
 static void bridge_focus_tracker (AtkObject *object);
-static void bridge_exit_func(void);
-static gboolean bridge_register_event_listener ();
-static void register_atk_event_listeners();
+static void bridge_exit_func (void);
+static void register_atk_event_listeners (void);
 static gboolean bridge_property_event_listener (GSignalInvocationHint *signal_hint,
                                                guint n_param_values,
                                                const GValue *param_values,
@@ -68,77 +59,72 @@ static gint bridge_key_listener (AtkKeyEventStruct *event,
                                 gpointer data);
 
 int
-gtk_module_init(gint *argc, gchar **argv[])
-{
-  ArgStruct *args = (ArgStruct *) g_new0(ArgStruct, 1);
-  args->c = *argc;
-  args->v = *argv;
-  bridge_register_app (args);
-  g_atexit (bridge_exit_func);
-}
-
-static gboolean
-bridge_register_app (gpointer gp)
+gtk_module_init (gint *argc, gchar **argv[])
 {
-  CORBA_Object oclient;
-  AtkObject *atko;
-  char *obj_id;
-  ArgStruct *args = (ArgStruct *)gp;
+  CORBA_Environment ev;
 
-  CORBA_exception_init(&ev);
-
-  if (!bonobo_init (&(args->c), args->v))
+  if (!bonobo_init (argc, *argv))
     {
       g_error ("Could not initialize Bonobo");
     }
 
-  /* Create the accesssible application server object */
-  this_app = spi_application_new(atk_get_root ());
-
-  obj_id = "OAFIID:Accessibility_Registry:proto0.1";
+  CORBA_exception_init(&ev);
 
-  oclient = bonobo_activation_activate_from_id (obj_id, 0, NULL, &ev);
-  if (ev._major != CORBA_NO_EXCEPTION) {
-    fprintf(stderr,
-            ("Accessibility app error: exception during registry activation from id: %s\n"),
-            CORBA_exception_id(&ev));
-    CORBA_exception_free(&ev);
-  }
+  registry = bonobo_activation_activate_from_id (
+         "OAFIID:Accessibility_Registry:proto0.1", 0, NULL, &ev);
+  
+  if (ev._major != CORBA_NO_EXCEPTION)
+    {
+      g_error ("Accessibility app error: exception during "
+              "registry activation from id: %s\n",
+              CORBA_exception_id (&ev));
+      CORBA_exception_free (&ev);
+    }
 
-  if (CORBA_Object_is_nil (oclient, &ev))
+  if (CORBA_Object_is_nil (registry, &ev))
     {
       g_error ("Could not locate registry");
     }
 
-  registry = (Accessibility_Registry) oclient;
+  bonobo_activate ();
 
-  fprintf(stderr, "About to register application\n");
+  /* Create the accessible application server object */
 
-  Accessibility_Registry_ref (registry, &ev);
-  
-  bonobo_activate ();
+  this_app = spi_application_new (atk_get_root ());
+
+  fprintf (stderr, "About to register application\n");
 
   Accessibility_Registry_registerApplication (registry,
-                                              CORBA_Object_duplicate (BONOBO_OBJREF (this_app), &ev),
+                                              BONOBO_OBJREF (this_app),
                                               &ev);
 
+  g_atexit (bridge_exit_func);
+
+  g_idle_add (bridge_idle_init, NULL);
+
+  return 0;
+}
+
+static gboolean
+bridge_idle_init (gpointer user_data)
+{
   register_atk_event_listeners ();
 
+  fprintf (stderr, "Application registered & listening\n");
+
   return FALSE;
 }
 
 static void
-register_atk_event_listeners ()
+register_atk_event_listeners (void)
 {
-  GType t;
-
   /*
    * kludge to make sure the Atk interface types are registered, otherwise
    * the AtkText signal handlers below won't get registered
    */
 
   AtkObject *o = atk_no_op_object_new (g_object_new (ATK_TYPE_OBJECT, NULL));
-
+  
   /* Register for focus event notifications, and register app with central registry  */
 
   atk_add_focus_tracker (bridge_focus_tracker);
@@ -157,27 +143,110 @@ register_atk_event_listeners ()
   atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:column-deleted");
   atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:model-changed");
   atk_add_key_event_listener    (bridge_key_listener, NULL);
+
+/*  g_object_unref (o); */
 }
 
-static void bridge_exit_func()
+static void
+bridge_exit_func (void)
 {
   fprintf (stderr, "exiting bridge\n");
+
+/*
+  FIXME: this may be incorrect for apps that do their own bonobo shutdown,
+  until we can explicitly shutdown to get the ordering right. */
+
+  if (!bonobo_is_initialized ())
+    {
+      g_warning ("Re-initializing bonobo\n");
+      g_assert (bonobo_init (0, NULL));
+      g_assert (bonobo_activate ());
+      registry = bonobo_activation_activate_from_id (
+         "OAFIID:Accessibility_Registry:proto0.1", 0, NULL, &ev);
+      g_assert (registry);
+      g_assert (this_app);
+    }
+  
   Accessibility_Registry_deregisterApplication (registry,
-                                               CORBA_Object_duplicate (BONOBO_OBJREF (this_app), &ev),
+                                               BONOBO_OBJREF (this_app),
                                                &ev);
-  Accessibility_Registry_unref (registry, &ev);
+  
+  bonobo_object_unref (BONOBO_OBJECT (this_app));
   
   fprintf (stderr, "bridge exit func complete.\n");
+
+  bonobo_debug_shutdown ();
 }
 
-static void bridge_focus_tracker (AtkObject *object)
+static void
+bridge_focus_tracker (AtkObject *object)
 {
-  Accessibility_Event *e = Accessibility_Event__alloc();
-  e->type = CORBA_string_dup ("focus:");
-  e->source = CORBA_Object_duplicate (BONOBO_OBJREF (spi_accessible_new (object)), &ev);
-  e->detail1 = 0;
-  e->detail2 = 0;
-  Accessibility_Registry_notifyEvent (registry, e, &ev);
+  SpiAccessible *source;
+  Accessibility_Event e;
+
+  source = spi_accessible_new (object);
+
+  e.type = "focus:";
+  e.source = CORBA_Object_duplicate (BONOBO_OBJREF (source), &ev);
+  e.detail1 = 0;
+  e.detail2 = 0;
+
+  Accessibility_Registry_notifyEvent (registry, &e, &ev);
+
+  CORBA_exception_free (&ev);
+}
+
+static void
+emit_eventv (GObject      *gobject,
+            unsigned long detail1,
+            unsigned long detail2,
+            const char   *format, ...)
+{
+  va_list             args;
+  Accessibility_Event e;
+  SpiAccessible      *source;
+  AtkObject          *aobject;
+
+  va_start (args, format);
+  
+  if (ATK_IS_IMPLEMENTOR (gobject))
+    {
+      aobject = atk_implementor_ref_accessible (ATK_IMPLEMENTOR (gobject));
+      source  = spi_accessible_new (aobject);
+      g_object_unref (G_OBJECT (aobject));
+    }
+  else if (ATK_IS_OBJECT (gobject))
+    {
+      aobject = ATK_OBJECT (gobject);
+      source  = spi_accessible_new (aobject);
+    }
+  else
+    {
+      aobject = NULL;
+      source  = NULL;
+      g_error ("received property-change event from non-AtkImplementor");
+    }
+
+  if (source != NULL)
+    {
+      e.type = g_strdup_vprintf (format, args);
+      e.source = CORBA_Object_duplicate (BONOBO_OBJREF (source), &ev);
+      e.detail1 = detail1;
+      e.detail2 = detail2;
+
+#ifdef SPI_BRIDGE_DEBUG
+      g_warning ("Emitting event '%s' (%d, %d) on %p",
+                e.type, e.detail1, e.detail2, source);
+#endif
+
+      Accessibility_Registry_notifyEvent (registry, &e, &ev);
+
+      CORBA_exception_free (&ev);
+
+      g_free (e.type);
+    }
+
+  va_end (args);
 }
 
 static gboolean
@@ -186,48 +255,25 @@ bridge_property_event_listener (GSignalInvocationHint *signal_hint,
                                const GValue *param_values,
                                gpointer data)
 {
-  Accessibility_Event *e = Accessibility_Event__alloc();
-  Bonobo_Unknown source = NULL;
-  AtkObject *aobject;
   AtkPropertyValues *values;
   GObject *gobject;
+
+#ifdef SPI_BRIDGE_DEBUG
   GSignalQuery signal_query;
-  gchar *name;
-  char sbuf[APP_STATIC_BUFF_SZ];
+  const gchar *name;
   
   g_signal_query (signal_hint->signal_id, &signal_query);
   name = signal_query.signal_name;
-#ifdef SPI_BRIDGE_DEBUG
+
   fprintf (stderr, "Received (property) signal %s:%s\n",
           g_type_name (signal_query.itype), name);
 #endif
+
   gobject = g_value_get_object (param_values + 0);
   values = (AtkPropertyValues*) g_value_get_pointer (param_values + 1);
 
-  /* notify the actual listeners */
-  if (ATK_IS_IMPLEMENTOR (gobject))
-  {
-    aobject = atk_implementor_ref_accessible (ATK_IMPLEMENTOR (gobject));
-    source = CORBA_Object_duplicate (BONOBO_OBJREF (spi_accessible_new (aobject)), &ev);
-    g_object_unref (G_OBJECT(aobject));
-  }
-  else if (ATK_IS_OBJECT (gobject))
-  {
-    aobject = ATK_OBJECT (gobject);
-    source = CORBA_Object_duplicate (BONOBO_OBJREF (spi_accessible_new (aobject)), &ev);
-  }
-  else
-  {
-    g_error("received property-change event from non-AtkImplementor");
-  }
-  
-  snprintf(sbuf, APP_STATIC_BUFF_SZ, "object:property-change:%s", values->property_name);
-  e->type = CORBA_string_dup (sbuf);
-  e->source = source;
-  e->detail1 = 0;
-  e->detail2 = 0;
-  if (source)
-    Accessibility_Registry_notifyEvent (registry, e, &ev);
+  emit_eventv (gobject, 0, 0, "object:property-change:%s", values->property_name);
+
   return TRUE;
 }
 
@@ -237,92 +283,90 @@ bridge_state_event_listener (GSignalInvocationHint *signal_hint,
                             const GValue *param_values,
                             gpointer data)
 {
-  Accessibility_Event *e = Accessibility_Event__alloc();
-  Bonobo_Unknown source = NULL;
-  AtkObject *aobject;
-  AtkPropertyValues *values;
   GObject *gobject;
+  AtkPropertyValues *values;
+#ifdef SPI_BRIDGE_DEBUG
   GSignalQuery signal_query;
-  gchar *name;
-  char sbuf[APP_STATIC_BUFF_SZ];
+  const gchar *name;
   
   g_signal_query (signal_hint->signal_id, &signal_query);
   name = signal_query.signal_name;
-#ifdef SPI_BRIDGE_DEBUG
   fprintf (stderr, "Received (state) signal %s:%s\n",
           g_type_name (signal_query.itype), name);
 #endif
+
   gobject = g_value_get_object (param_values + 0);
   values = (AtkPropertyValues*) g_value_get_pointer (param_values + 1);
 
-  /* notify the actual listeners */
-  if (ATK_IS_IMPLEMENTOR (gobject))
-  {
-    aobject = atk_implementor_ref_accessible (ATK_IMPLEMENTOR (gobject));
-    source = CORBA_Object_duplicate (BONOBO_OBJREF (spi_accessible_new (aobject)), &ev);
-    g_object_unref (G_OBJECT(aobject));
-  }
-  else if (ATK_IS_OBJECT (gobject))
-  {
-    aobject = ATK_OBJECT (gobject);
-    source = CORBA_Object_duplicate (BONOBO_OBJREF (spi_accessible_new (aobject)), &ev);
-  }
-  else
-  {
-    g_error("received property-change event from non-AtkImplementor");
-  }
-  
-  snprintf(sbuf, APP_STATIC_BUFF_SZ, "object:%s:%s", values->property_name, "?");
-  e->type = CORBA_string_dup (sbuf);
-  e->source = source;
-  e->detail1 = (unsigned long) values->old_value.data[0].v_ulong;
-  e->detail2 = (unsigned long) values->new_value.data[0].v_ulong;
-  if (source)
-    Accessibility_Registry_notifyEvent (registry, e, &ev);
+  emit_eventv (gobject, 
+              (unsigned long) values->old_value.data[0].v_ulong,
+              (unsigned long) values->new_value.data[0].v_ulong,
+              "object:%s:?", values->property_name);
+
   return TRUE;
 }
 
-static Accessibility_KeyStroke *
-accessibility_keystroke_from_atk_key_event (AtkKeyEventStruct *event)
+static void
+accessibility_init_keystroke_from_atk_key_event (Accessibility_KeyStroke *keystroke,
+                                                AtkKeyEventStruct       *event)
 {
-  Accessibility_KeyStroke *keystroke;
-  keystroke = Accessibility_KeyStroke__alloc ();
-
 #ifdef SPI_DEBUG
-  if (event) g_print ("event %c (%d)\n", (int) event->keyval, (int) event->keycode);
+  if (event)
+    {
+      g_print ("event %c (%d)\n", (int) event->keyval, (int) event->keycode);
+    }
   else
 #endif
-  if (!event) g_print ("WARNING: NULL key event!");
+  if (!event)
+    {
+      g_print ("WARNING: NULL key event!");
+    }
   
-  keystroke->keyID = (CORBA_long) event->keyval;
-  keystroke->keycode = (CORBA_short) event->keycode;
+  keystroke->keyID     = (CORBA_long) event->keyval;
+  keystroke->keycode   = (CORBA_short) event->keycode;
   keystroke->timestamp = (CORBA_unsigned_long) event->timestamp;
   keystroke->modifiers = (CORBA_unsigned_short) (event->state & 0xFFFF);
 
   switch (event->type)
     {
     case (ATK_KEY_EVENT_PRESS):
-           keystroke->type = Accessibility_KEY_PRESSED;
-           break;
+      keystroke->type = Accessibility_KEY_PRESSED;
+      break;
     case (ATK_KEY_EVENT_RELEASE):
-           keystroke->type = Accessibility_KEY_RELEASED;
-           break;
+      keystroke->type = Accessibility_KEY_RELEASED;
+      break;
     default:
+      keystroke->type = 0;
+      break;
     }
-  
-  return keystroke;
 }
 
 static gint
 bridge_key_listener (AtkKeyEventStruct *event, gpointer data)
 {
-  Accessibility_KeyStroke *key_event = accessibility_keystroke_from_atk_key_event (event);
-  CORBA_boolean result;
+  CORBA_boolean           result;
+  Accessibility_KeyStroke key_event;
   Accessibility_DeviceEventController controller =
-         Accessibility_Registry_getDeviceEventController (registry, &ev);
-  result = Accessibility_DeviceEventController_notifyListenersSync (controller,
-                                                                   (Accessibility_DeviceEvent *) key_event,
-                                                                   &ev);
+    Accessibility_Registry_getDeviceEventController (registry, &ev);
+
+  if (BONOBO_EX (&ev))
+    {
+      CORBA_exception_free (&ev);
+      result = FALSE;
+    }
+  else
+    {
+
+      accessibility_init_keystroke_from_atk_key_event (&key_event, event);
+
+  /* FIXME: this casting is just totaly bogus */
+      result = Accessibility_DeviceEventController_notifyListenersSync (
+        controller, (Accessibility_DeviceEvent *) &key_event, &ev);
+
+      CORBA_exception_free (&ev);
+    }
+
+  return result;
 }
 
 static gboolean
@@ -331,50 +375,22 @@ bridge_signal_listener (GSignalInvocationHint *signal_hint,
                        const GValue *param_values,
                        gpointer data)
 {
-  Accessibility_Event *e = g_new0(Accessibility_Event, 1);
-  AtkObject *aobject;
-  Bonobo_Unknown source;
-  AtkPropertyValues *values;
   GObject *gobject;
   GSignalQuery signal_query;
-  gchar *name;
-  char sbuf[APP_STATIC_BUFF_SZ];
+  const gchar *name;
   
   g_signal_query (signal_hint->signal_id, &signal_query);
+
   name = signal_query.signal_name;
+
 #ifdef SPI_BRIDGE_DEBUG
   fprintf (stderr, "Received signal %s:%s\n",
           g_type_name (signal_query.itype), name);
 #endif
+
   gobject = g_value_get_object (param_values + 0);
 
-  /* notify the actual listeners */
-  if (ATK_IS_IMPLEMENTOR (gobject))
-  {
-    aobject = atk_implementor_ref_accessible (ATK_IMPLEMENTOR (gobject));
-  }
-  else if (ATK_IS_OBJECT (gobject))
-  {
-    aobject = ATK_OBJECT (gobject);
-    g_object_ref (aobject);
-  }
-  else
-  {
-    g_error("received property-change event from non-AtkImplementor");
-  }
-
-  snprintf(sbuf, APP_STATIC_BUFF_SZ, "%s:%s", name, g_type_name (signal_query.itype));
-  source =  CORBA_Object_duplicate (BONOBO_OBJREF (spi_accessible_new (aobject)), &ev);
-  e->type = CORBA_string_dup (sbuf);
-  e->source = source;
-  e->detail1 = 0;
-  e->detail2 = 0;
-  Accessibility_Registry_notifyEvent (registry, e, &ev);
-  g_object_unref (aobject);
-  return TRUE;
-}
+  emit_eventv (gobject, 0, 0, "%s:%s", name, g_type_name (signal_query.itype));
 
-static Accessibility_Registry bridge_get_registry ()
-{
-  return registry;
+  return TRUE;
 }