Added initial implementations of DeviceEventController and KeystrokeListener.
[platform/core/uifw/at-spi2-atk.git] / registryd / deviceeventcontroller.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001 Sun Microsystems Inc.
6  *
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.
11  *
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.
16  *
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.
21  */
22
23 /*
24  * listener.c: test for accessibility implementation
25  *
26  */
27
28 #ifdef SPI_DEBUG
29 #include <stdio.h>
30 #endif
31
32 #include <config.h>
33 #include <bonobo/Bonobo.h>
34 #include <libspi/Accessibility.h>
35
36 /*
37  * This pulls the definition for the BonoboObject (GType)
38  */
39 #include "deviceeventcontroller.h"
40
41 /*
42  * Our parent Gtk object type
43  */
44 #define PARENT_TYPE BONOBO_OBJECT_TYPE
45
46 /*
47  * A pointer to our parent object class
48  */
49 static GObjectClass *device_event_controller_parent_class;
50
51 /*
52  * Implemented GObject::finalize
53  */
54 static void
55 device_event_controller_object_finalize (GObject *object)
56 {
57
58 #ifdef SPI_DEBUG
59         fprintf(stderr, "device_event_controller_object_finalize called\n");
60 #endif
61         device_event_controller_parent_class->finalize (object);
62 }
63
64 /*
65  * CORBA Accessibility::DeviceEventController::registerKeystrokeListener
66  *     method implementation
67  */
68 static void
69 impl_register_keystroke_listener (PortableServer_Servant     servant,
70                                   const Accessibility_KeystrokeListener l,
71                                   CORBA_Environment         *ev)
72 {
73 #ifdef SPI_DEBUG
74         fprintf (stderr, "registering keystroke listener %p\n", l);
75 #endif
76 }
77 /*
78  * CORBA Accessibility::DeviceEventController::registerMouseListener
79  *     method implementation
80  */
81 /*
82 static void
83 impl_register_mouse_listener (PortableServer_Servant     servant,
84                               const Accessibility_MouseListener *l,
85                               CORBA_Environment         *ev)
86 {
87 #ifdef SPI_DEBUG
88         fprintf (stderr, "registering mouse listener %p\n", l);
89 #endif
90 }
91 */
92
93 /*
94  * CORBA Accessibility::DeviceEventController::registerKeystrokeListener
95  *     method implementation
96  */
97 static void
98 impl_generate_key_event (PortableServer_Servant     servant,
99                          const CORBA_long           keyEventID,
100                          CORBA_Environment         *ev)
101 {
102 #ifdef SPI_DEBUG
103         fprintf (stderr, "synthesizing keystroke %ld\n", keyEventID);
104 #endif
105 }
106
107 /*
108  * CORBA Accessibility::DeviceEventController::generateMouseEvent
109  *     method implementation
110  */
111 static void
112 impl_generate_mouse_event (PortableServer_Servant     servant,
113                            const CORBA_long x,
114                            const CORBA_long y,
115                            const CORBA_char * eventName,
116                            CORBA_Environment         *ev)
117 {
118 #ifdef SPI_DEBUG
119         fprintf (stderr, "generating mouse %s event at %ld, %ld\n", eventName, x, y);
120 #endif
121 }
122
123 static void
124 device_event_controller_class_init (DeviceEventControllerClass *klass)
125 {
126         GObjectClass * object_class = (GObjectClass *) klass;
127         POA_Accessibility_DeviceEventController__epv *epv = &klass->epv;
128         device_event_controller_parent_class = g_type_class_ref (BONOBO_OBJECT_TYPE);
129
130         object_class->finalize = device_event_controller_object_finalize;
131
132         epv->registerKeystrokeListener = impl_register_keystroke_listener;
133 /*        epv->registerMouseListener = impl_register_mouse_listener; */
134         epv->generateKeyEvent = impl_generate_key_event;
135         epv->generateMouseEvent = impl_generate_mouse_event;
136 }
137
138 static void
139 device_event_controller_init (DeviceEventController *device_event_controller)
140 {
141 }
142
143 GType
144 device_event_controller_get_type (void)
145 {
146         static GType type = 0;
147
148         if (!type) {
149                 static const GTypeInfo tinfo = {
150                         sizeof (DeviceEventControllerClass),
151                         (GBaseInitFunc) NULL,
152                         (GBaseFinalizeFunc) NULL,
153                         (GClassInitFunc) device_event_controller_class_init,
154                         (GClassFinalizeFunc) NULL,
155                         NULL, /* class data */
156                         sizeof (DeviceEventController),
157                         0, /* n preallocs */
158                         (GInstanceInitFunc) device_event_controller_init,
159                         NULL /* value table */
160                 };
161                 /*
162                  *   Here we use bonobo_type_unique instead of
163                  * gtk_type_unique, this auto-generates a load of
164                  * CORBA structures for us. All derived types must
165                  * use bonobo_type_unique.
166                  */
167                 type = bonobo_type_unique (
168                         PARENT_TYPE,
169                         POA_Accessibility_DeviceEventController__init,
170                         NULL,
171                         G_STRUCT_OFFSET (DeviceEventControllerClass, epv),
172                         &tinfo,
173                         "DeviceEventController");
174         }
175
176         return type;
177 }
178