2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001 Sun Microsystems Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
24 * registry.c: test for accessibility implementation
27 #define DEBUG_PRINTSTUFF
28 #ifdef DEBUG_PRINTSTUFF
32 #include <bonobo/Bonobo.h>
35 * This pulls the CORBA definitions for the "Accessibility::Registry" server
40 * This pulls the definition for the BonoboObject (GType)
45 * Our parent GObject type
47 #define PARENT_TYPE LISTENER_TYPE
50 * A pointer to our parent object class
52 static ListenerClass *registry_parent_class;
55 * Implemented GObject::finalize
58 registry_object_finalize (GObject *object)
60 /* Registry *registry = REGISTRY (object); */
61 GObjectClass *object_class = G_OBJECT_GET_CLASS( object);
63 printf("registry_object_finalize called\n");
65 object_class->finalize (object);
69 * registerApplication:
70 * @application: a reference to the requesting @Application
73 * Register a new application with the accessibility broker.
77 impl_accessibility_registry_register_application (PortableServer_Servant servant,
78 const Accessibility_Application application,
79 CORBA_Environment * ev)
81 Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
83 fprintf (stderr, "registering app %p\n", application);
84 registry->desktop->applications = g_list_append (registry->desktop->applications, CORBA_Object_duplicate (application, ev));
86 * TODO: change the implementation below to a WM-aware one;
87 * e.g. don't add all apps to the Desktop
89 /* registry->desktop->applications = registry->applications;*/
93 * deregisterApplication:
94 * @application: a reference to the @Application
98 * De-register an application previously registered with the broker.
102 impl_accessibility_registry_deregister_application (PortableServer_Servant servant,
103 const Accessibility_Application application,
104 CORBA_Environment * ev)
106 Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
107 registry->applications = g_list_remove (registry->applications, application);
111 * CORBA Accessibility::Registry::registerGlobalEventListener method implementation
114 impl_accessibility_registry_register_global_event_listener
115 (PortableServer_Servant servant,
116 Accessibility_EventListener listener,
117 const CORBA_char *event_name,
118 CORBA_Environment *ev)
123 * distinguish between event types
124 * register with app toolkits only for requested event types
125 * maintain list of requested types and number of listeners
126 * find non-strcmp method of matching event types to listeners
130 Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
131 /* fprintf(stderr, "registering %x/%x\n", listener, *listener); */
132 registry->listeners = g_list_append (registry->listeners, CORBA_Object_duplicate(listener, ev));
133 /* fprintf(stderr, "there are now %d listeners registered.\n", g_list_length(registry->listeners)); */
134 /* should use hashtable and CORBA_Object_hash (...) */
138 * CORBA Accessibility::Registry::deregisterGlobalEventListener method implementation
141 impl_accessibility_registry_deregister_global_event_listener
142 (PortableServer_Servant servant,
143 Accessibility_EventListener listener,
144 CORBA_Environment *ev)
146 Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
147 /* TODO: this won't work since 'listener' is a duplicate ref */
148 registry->listeners = g_list_remove (registry->listeners, listener);
149 /* fprintf(stderr, "deregister\n"); */
155 * return values: a short integer indicating the current number of
158 * Get the current number of desktops.
162 impl_accessibility_registry_get_desktop_count (PortableServer_Servant servant,
163 CORBA_Environment * ev)
165 /* TODO: implement support for multiple virtual desktops */
166 CORBA_short n_desktops;
167 n_desktops = (CORBA_short) 1;
173 * @n: the index of the requested @Desktop.
174 * return values: a reference to the requested @Desktop.
176 * Get the nth accessible desktop.
179 static Accessibility_Desktop
180 impl_accessibility_registry_get_desktop (PortableServer_Servant servant,
182 CORBA_Environment * ev)
184 Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
186 /* TODO: implement support for multiple virtual desktops */
189 return (Accessibility_Desktop)
190 CORBA_Object_duplicate (
191 bonobo_object_corba_objref (bonobo_object (registry->desktop)), ev);
195 return (Accessibility_Desktop) CORBA_OBJECT_NIL;
201 * return values: a sequence containing references to
204 * Get a list of accessible desktops.
207 static Accessibility_DesktopSeq *
208 impl_accessibility_registry_get_desktop_list (PortableServer_Servant servant,
209 CORBA_Environment * ev)
211 /* TODO: implement support for multiple virtual desktops */
212 return (Accessibility_DesktopSeq *) NULL;
216 impl_accessibility_registry_get_device_event_controller (PortableServer_Servant servant,
217 CORBA_Environment * ev)
219 /* TODO: not yet implemented! */
220 return CORBA_OBJECT_NIL;
224 impl_registry_notify_event (PortableServer_Servant servant,
225 const Accessibility_Event *e,
226 CORBA_Environment *ev)
230 Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
235 * distinguish between event types
236 * find non-strcmp method of matching event types to listeners
240 len = g_list_length (registry->listeners);
241 /* fprintf(stderr, "%d listeners registered\n", len); */
243 for (n=0; n<len; ++n)
245 /* fprintf(stderr, "notifying listener #%d\n", n);*/
246 /* fprintf(stderr, "event name %s\n", Accessibility_Accessible__get_name(e->target, ev));*/
247 Accessibility_EventListener_notifyEvent (
248 (Accessibility_EventListener) g_list_nth_data (registry->listeners, n),
255 registry_class_init (RegistryClass *klass)
257 GObjectClass * object_class = (GObjectClass *) klass;
258 POA_Accessibility_Registry__epv *epv = &klass->epv;
260 registry_parent_class = g_type_class_ref (LISTENER_TYPE);
262 object_class->finalize = registry_object_finalize;
264 epv->registerApplication = impl_accessibility_registry_register_application;
265 epv->deregisterApplication = impl_accessibility_registry_deregister_application;
266 epv->registerGlobalEventListener = impl_accessibility_registry_register_global_event_listener;
267 epv->deregisterGlobalEventListener = impl_accessibility_registry_deregister_global_event_listener;
268 epv->getDesktopCount = impl_accessibility_registry_get_desktop_count;
269 epv->getDesktop = impl_accessibility_registry_get_desktop;
270 epv->getDesktopList = impl_accessibility_registry_get_desktop_list;
271 epv->getDeviceEventController = impl_accessibility_registry_get_device_event_controller;
272 ((ListenerClass *) klass)->epv.notifyEvent = impl_registry_notify_event;
276 registry_init (Registry *registry)
278 registry->listeners = NULL;
279 registry->applications = NULL;
280 registry->desktop = desktop_new();
284 registry_get_type (void)
286 static GType type = 0;
289 static const GTypeInfo tinfo = {
290 sizeof (RegistryClass),
291 (GBaseInitFunc) NULL,
292 (GBaseFinalizeFunc) NULL,
293 (GClassInitFunc) registry_class_init,
294 (GClassFinalizeFunc) NULL,
295 NULL, /* class data */
298 (GInstanceInitFunc) registry_init,
299 NULL /* value table */
302 * Here we use bonobo_x_type_unique instead of
303 * gtk_type_unique, this auto-generates a load of
304 * CORBA structures for us. All derived types must
305 * use bonobo_x_type_unique.
307 type = bonobo_x_type_unique (
309 POA_Accessibility_Registry__init,
311 G_STRUCT_OFFSET (RegistryClass, epv),
323 REGISTRY (g_object_new (registry_get_type (), NULL));