2 * registry.c: test for accessibility implementation
5 #define DEBUG_PRINTSTUFF
6 #ifdef DEBUG_PRINTSTUFF
10 #include <bonobo/Bonobo.h>
13 * This pulls the CORBA definitions for the "Accessibility::Registry" server
18 * This pulls the definition for the BonoboObject (GType)
23 * Our parent GObject type
25 #define PARENT_TYPE LISTENER_TYPE
28 * A pointer to our parent object class
30 static ListenerClass *registry_parent_class;
33 * Implemented GObject::finalize
36 registry_object_finalize (GObject *object)
38 /* Registry *registry = REGISTRY (object); */
39 GObjectClass *object_class = G_OBJECT_GET_CLASS( object);
41 printf("registry_object_finalize called\n");
43 object_class->finalize (object);
47 * registerApplication:
48 * @application: a reference to the requesting @Application
51 * Register a new application with the accessibility broker.
55 impl_accessibility_registry_register_application (PortableServer_Servant servant,
56 const Accessibility_Application application,
57 CORBA_Environment * ev)
59 Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
61 fprintf (stderr, "registering app %p\n", application);
62 registry->desktop->applications = g_list_append (registry->desktop->applications, CORBA_Object_duplicate (application, ev));
64 * TODO: change the implementation below to a WM-aware one;
65 * e.g. don't add all apps to the Desktop
67 /* registry->desktop->applications = registry->applications;*/
71 * deregisterApplication:
72 * @application: a reference to the @Application
76 * De-register an application previously registered with the broker.
80 impl_accessibility_registry_deregister_application (PortableServer_Servant servant,
81 const Accessibility_Application application,
82 CORBA_Environment * ev)
84 Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
85 registry->applications = g_list_remove (registry->applications, application);
89 * CORBA Accessibility::Registry::registerGlobalEventListener method implementation
92 impl_accessibility_registry_register_global_event_listener
93 (PortableServer_Servant servant,
94 Accessibility_EventListener listener,
95 const CORBA_char *event_name,
96 CORBA_Environment *ev)
101 * distinguish between event types
102 * register with app toolkits only for requested event types
103 * maintain list of requested types and number of listeners
104 * find non-strcmp method of matching event types to listeners
108 Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
109 /* fprintf(stderr, "registering %x/%x\n", listener, *listener); */
110 registry->listeners = g_list_append (registry->listeners, CORBA_Object_duplicate(listener, ev));
111 /* fprintf(stderr, "there are now %d listeners registered.\n", g_list_length(registry->listeners)); */
112 /* should use hashtable and CORBA_Object_hash (...) */
116 * CORBA Accessibility::Registry::deregisterGlobalEventListener method implementation
119 impl_accessibility_registry_deregister_global_event_listener
120 (PortableServer_Servant servant,
121 Accessibility_EventListener listener,
122 CORBA_Environment *ev)
124 Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
125 /* TODO: this won't work since 'listener' is a duplicate ref */
126 registry->listeners = g_list_remove (registry->listeners, listener);
127 /* fprintf(stderr, "deregister\n"); */
133 * return values: a short integer indicating the current number of
136 * Get the current number of desktops.
140 impl_accessibility_registry_get_desktop_count (PortableServer_Servant servant,
141 CORBA_Environment * ev)
143 /* TODO: implement support for multiple virtual desktops */
144 CORBA_short n_desktops;
145 n_desktops = (CORBA_short) 1;
151 * @n: the index of the requested @Desktop.
152 * return values: a reference to the requested @Desktop.
154 * Get the nth accessible desktop.
157 static Accessibility_Desktop
158 impl_accessibility_registry_get_desktop (PortableServer_Servant servant,
160 CORBA_Environment * ev)
162 Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
164 /* TODO: implement support for multiple virtual desktops */
167 return (Accessibility_Desktop)
168 CORBA_Object_duplicate (
169 bonobo_object_corba_objref (bonobo_object (registry->desktop)), ev);
173 return (Accessibility_Desktop) CORBA_OBJECT_NIL;
179 * return values: a sequence containing references to
182 * Get a list of accessible desktops.
185 static Accessibility_DesktopSeq *
186 impl_accessibility_registry_get_desktop_list (PortableServer_Servant servant,
187 CORBA_Environment * ev)
189 /* TODO: implement support for multiple virtual desktops */
190 return (Accessibility_DesktopSeq *) NULL;
194 impl_accessibility_registry_get_device_event_controller (PortableServer_Servant servant,
195 CORBA_Environment * ev)
197 /* TODO: not yet implemented! */
198 return CORBA_OBJECT_NIL;
202 impl_registry_notify_event (PortableServer_Servant servant,
203 const Accessibility_Event *e,
204 CORBA_Environment *ev)
208 Registry *registry = REGISTRY (bonobo_object_from_servant (servant));
213 * distinguish between event types
214 * find non-strcmp method of matching event types to listeners
218 len = g_list_length (registry->listeners);
219 /* fprintf(stderr, "%d listeners registered\n", len); */
221 for (n=0; n<len; ++n)
223 /* fprintf(stderr, "notifying listener #%d\n", n);*/
224 /* fprintf(stderr, "event name %s\n", Accessibility_Accessible__get_name(e->target, ev));*/
225 Accessibility_EventListener_notifyEvent (
226 (Accessibility_EventListener) g_list_nth_data (registry->listeners, n),
233 registry_class_init (RegistryClass *klass)
235 GObjectClass * object_class = (GObjectClass *) klass;
236 POA_Accessibility_Registry__epv *epv = &klass->epv;
238 registry_parent_class = g_type_class_ref (LISTENER_TYPE);
240 object_class->finalize = registry_object_finalize;
242 epv->registerApplication = impl_accessibility_registry_register_application;
243 epv->deregisterApplication = impl_accessibility_registry_deregister_application;
244 epv->registerGlobalEventListener = impl_accessibility_registry_register_global_event_listener;
245 epv->deregisterGlobalEventListener = impl_accessibility_registry_deregister_global_event_listener;
246 epv->getDesktopCount = impl_accessibility_registry_get_desktop_count;
247 epv->getDesktop = impl_accessibility_registry_get_desktop;
248 epv->getDesktopList = impl_accessibility_registry_get_desktop_list;
249 epv->getDeviceEventController = impl_accessibility_registry_get_device_event_controller;
250 ((ListenerClass *) klass)->epv.notifyEvent = impl_registry_notify_event;
254 registry_init (Registry *registry)
256 registry->listeners = NULL;
257 registry->applications = NULL;
258 registry->desktop = desktop_new();
262 registry_get_type (void)
264 static GType type = 0;
267 static const GTypeInfo tinfo = {
268 sizeof (RegistryClass),
269 (GBaseInitFunc) NULL,
270 (GBaseFinalizeFunc) NULL,
271 (GClassInitFunc) registry_class_init,
272 (GClassFinalizeFunc) NULL,
273 NULL, /* class data */
276 (GInstanceInitFunc) registry_init,
277 NULL /* value table */
280 * Here we use bonobo_x_type_unique instead of
281 * gtk_type_unique, this auto-generates a load of
282 * CORBA structures for us. All derived types must
283 * use bonobo_x_type_unique.
285 type = bonobo_x_type_unique (
287 POA_Accessibility_Registry__init,
289 G_STRUCT_OFFSET (RegistryClass, epv),
301 REGISTRY (g_object_new (registry_get_type (), NULL));