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
32 #include <bonobo/Bonobo.h>
35 * This pulls the CORBA definitions for the "Accessibility::Registry" server
37 #include <libspi/Accessibility.h>
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));
84 fprintf (stderr, "registering app %p\n", application);
87 registry->desktop->applications = g_list_append (registry->desktop->applications, CORBA_Object_duplicate (application, ev));
89 * TODO: change the implementation below to a WM-aware one;
90 * e.g. don't add all apps to the Desktop
92 /* registry->desktop->applications = registry->applications;*/
96 * deregisterApplication:
97 * @application: a reference to the @Application
101 * De-register an application previously registered with the broker.
105 impl_accessibility_registry_deregister_application (PortableServer_Servant servant,
106 const Accessibility_Application application,
107 CORBA_Environment * ev)
109 Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
110 registry->applications = g_list_remove (registry->applications, application);
114 * CORBA Accessibility::Registry::registerGlobalEventListener method implementation
117 impl_accessibility_registry_register_global_event_listener
118 (PortableServer_Servant servant,
119 Accessibility_EventListener listener,
120 const CORBA_char *event_name,
121 CORBA_Environment *ev)
126 * distinguish between event types
127 * register with app toolkits only for requested event types
128 * maintain list of requested types and number of listeners
129 * find non-strcmp method of matching event types to listeners
133 Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
134 /* fprintf(stderr, "registering %x/%x\n", listener, *listener); */
135 registry->listeners = g_list_append (registry->listeners, CORBA_Object_duplicate(listener, ev));
136 /* fprintf(stderr, "there are now %d listeners registered.\n", g_list_length(registry->listeners)); */
137 /* should use hashtable and CORBA_Object_hash (...) */
141 * CORBA Accessibility::Registry::deregisterGlobalEventListener method implementation
144 impl_accessibility_registry_deregister_global_event_listener
145 (PortableServer_Servant servant,
146 Accessibility_EventListener listener,
147 CORBA_Environment *ev)
149 Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
150 /* TODO: this won't work since 'listener' is a duplicate ref */
151 registry->listeners = g_list_remove (registry->listeners, listener);
152 /* fprintf(stderr, "deregister\n"); */
158 * return values: a short integer indicating the current number of
161 * Get the current number of desktops.
165 impl_accessibility_registry_get_desktop_count (PortableServer_Servant servant,
166 CORBA_Environment * ev)
168 /* TODO: implement support for multiple virtual desktops */
169 CORBA_short n_desktops;
170 n_desktops = (CORBA_short) 1;
176 * @n: the index of the requested @Desktop.
177 * return values: a reference to the requested @Desktop.
179 * Get the nth accessible desktop.
182 static Accessibility_Desktop
183 impl_accessibility_registry_get_desktop (PortableServer_Servant servant,
185 CORBA_Environment * ev)
187 Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
189 /* TODO: implement support for multiple virtual desktops */
192 return (Accessibility_Desktop)
193 CORBA_Object_duplicate (
194 bonobo_object_corba_objref (bonobo_object (registry->desktop)), ev);
198 return (Accessibility_Desktop) CORBA_OBJECT_NIL;
204 * return values: a sequence containing references to
207 * Get a list of accessible desktops.
210 static Accessibility_DesktopSeq *
211 impl_accessibility_registry_get_desktop_list (PortableServer_Servant servant,
212 CORBA_Environment * ev)
214 /* TODO: implement support for multiple virtual desktops */
215 return (Accessibility_DesktopSeq *) NULL;
219 impl_accessibility_registry_get_device_event_controller (PortableServer_Servant servant,
220 CORBA_Environment * ev)
222 /* TODO: not yet implemented! */
223 return CORBA_OBJECT_NIL;
227 impl_registry_notify_event (PortableServer_Servant servant,
228 const Accessibility_Event *e,
229 CORBA_Environment *ev)
233 Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
238 * distinguish between event types
239 * find non-strcmp method of matching event types to listeners
243 len = g_list_length (registry->listeners);
244 /* fprintf(stderr, "%d listeners registered\n", len); */
246 for (n=0; n<len; ++n)
249 fprintf(stderr, "notifying listener #%d\n", n);
250 fprintf(stderr, "event name %s\n", Accessibility_Accessible__get_name(e->target, ev));
252 Accessibility_EventListener_notifyEvent (
253 (Accessibility_EventListener) g_list_nth_data (registry->listeners, n),
260 registry_class_init (RegistryClass *klass)
262 GObjectClass * object_class = (GObjectClass *) klass;
263 POA_Accessibility_Registry__epv *epv = &klass->epv;
265 registry_parent_class = g_type_class_ref (LISTENER_TYPE);
267 object_class->finalize = registry_object_finalize;
269 epv->registerApplication = impl_accessibility_registry_register_application;
270 epv->deregisterApplication = impl_accessibility_registry_deregister_application;
271 epv->registerGlobalEventListener = impl_accessibility_registry_register_global_event_listener;
272 epv->deregisterGlobalEventListener = impl_accessibility_registry_deregister_global_event_listener;
273 epv->getDesktopCount = impl_accessibility_registry_get_desktop_count;
274 epv->getDesktop = impl_accessibility_registry_get_desktop;
275 epv->getDesktopList = impl_accessibility_registry_get_desktop_list;
276 epv->getDeviceEventController = impl_accessibility_registry_get_device_event_controller;
277 ((ListenerClass *) klass)->epv.notifyEvent = impl_registry_notify_event;
281 registry_init (Registry *registry)
283 registry->listeners = NULL;
284 registry->applications = NULL;
285 registry->desktop = desktop_new();
289 registry_get_type (void)
291 static GType type = 0;
294 static const GTypeInfo tinfo = {
295 sizeof (RegistryClass),
296 (GBaseInitFunc) NULL,
297 (GBaseFinalizeFunc) NULL,
298 (GClassInitFunc) registry_class_init,
299 (GClassFinalizeFunc) NULL,
300 NULL, /* class data */
303 (GInstanceInitFunc) registry_init,
304 NULL /* value table */
307 * Here we use bonobo_x_type_unique instead of
308 * gtk_type_unique, this auto-generates a load of
309 * CORBA structures for us. All derived types must
310 * use bonobo_x_type_unique.
312 type = bonobo_type_unique (
314 POA_Accessibility_Registry__init,
316 G_STRUCT_OFFSET (RegistryClass, epv),
328 REGISTRY (g_object_new (registry_get_type (), NULL));