09d9be97cfc656c290884654047cce90cdfc25e0
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_main.c
1 /* #include <libbonobo.h> */
2 #include <stdio.h>
3 #include "spi.h"
4
5 static CORBA_Environment ev;
6 static Accessibility_Registry registry;
7
8 Accessible *
9 Obj_Add (Accessible object)
10 {
11   /* TODO: keep list of live object refs */
12   Accessible *oref = g_malloc (sizeof (Accessible));
13   *oref = object;
14   return oref;
15 }
16
17 /*
18  *
19  * Basic SPI initialization and event loop function prototypes
20  *
21  */
22
23 int
24 SPI_init (void)
25 {
26   int argc = 0;
27   CORBA_exception_init(&ev);
28   CORBA_Object oclient;
29   char *obj_id;
30
31   if (!bonobo_init (&argc, NULL))
32     {
33       g_error ("Could not initialize Bonobo");
34     }
35
36   obj_id = "OAFIID:Accessibility_Registry:proto0.1";
37
38   oclient = bonobo_activation_activate_from_id (obj_id, 0, NULL, &ev);
39   if (ev._major != CORBA_NO_EXCEPTION) {
40     fprintf (stderr,
41             ("AT-SPI error: during registry activation: %s\n"),
42             CORBA_exception_id(&ev));
43     CORBA_exception_free(&ev);
44     exit(-1);
45   }
46
47   if (CORBA_Object_is_nil (oclient, &ev))
48     {
49       g_error ("Could not locate registry");
50       exit(-1);
51     }
52
53   registry = (Accessibility_Registry) oclient;
54
55   bonobo_activate ();
56
57   return 0;
58 }
59
60 void
61 SPI_event_main (boolean isGNOMEApp)
62 {
63   if (isGNOMEApp) bonobo_main();
64   else CORBA_ORB_run (bonobo_orb(), &ev);
65 }
66
67 /* Not Yet Implemented */
68 boolean
69 SPI_eventIsReady ()
70 {
71   return FALSE;
72 }
73
74 /* Not Yet Implemented */
75 AccessibleEvent *
76 SPI_nextEvent (boolean waitForEvent)
77 {
78   return NULL;
79 }
80
81 void
82 SPI_exit (void)
83 {
84   exit(0);
85 }
86
87 /*
88  *
89  * Global functions serviced by the registry
90  *
91  */
92
93 boolean
94 RegisterGlobalEventListener (AccessibleEventListener *listener,
95                              char *eventType)
96 {
97   Accessibility_Registry_registerGlobalEventListener (
98                          registry,
99                          *listener,
100                          eventType,
101                          &ev);
102
103   if (ev._major != CORBA_NO_EXCEPTION)
104     {
105     return FALSE;
106     }
107   else
108     {
109       return TRUE;
110     }
111 }
112
113 int
114 GetDesktopCount ()
115 {
116   return Accessibility_Registry_getDesktopCount (registry, &ev);
117 }
118
119 Accessible
120 *getDesktop (int n)
121 {
122   return Obj_Add (Accessibility_Registry_getDesktop (registry, n, &ev));
123 }
124
125 int
126 getDesktopList (Accessible **list)
127 {
128   *list = NULL;
129   return 0;
130 }
131
132 /* Not Yet Implemented */
133 void
134 registerKeystrokeListener (KeystrokeListener *listener)
135 {
136   ;
137 }
138
139 /* Not Yet Implemented */
140 void
141 generateKeyEvent (long keyCode, long meta)
142 {
143   ;
144 }
145
146 /* Not Yet Implemented */
147 void
148 generateMouseEvent (long x, long y, char *name)
149 {
150   ;
151 }
152
153 /*
154  *
155  * Accessible function prototypes
156  *
157  */
158
159 int
160 Accessible_ref (Accessible *obj)
161 {
162   return Accessibility_Accessible_ref (*obj, &ev);
163 }
164
165
166 int
167 Accessible_unref (Accessible *obj)
168 {
169   return Accessibility_Accessible_unref (*obj, &ev);
170 }
171
172 char *
173 Accessible_getName (Accessible *obj)
174 {
175   return Accessibility_Accessible__get_name (*obj, &ev);
176 }
177
178 char *
179 Accessible_getDescription (Accessible *obj)
180 {
181   return Accessibility_Accessible__get_description (*obj, &ev);
182 }
183
184 Accessible *
185 Accessible_getParent (Accessible *obj)
186 {
187   return Obj_Add (Accessibility_Accessible__get_parent (*obj, &ev));
188 }
189
190 long
191 Accessible_getChildCount (Accessible *obj)
192 {
193   return Accessibility_Accessible_getChildCount (*obj, &ev);
194 }
195
196 Accessible *
197 Accessible_getChildAtIndex (Accessible *obj,
198                             long childIndex)
199 {
200   return Obj_Add (Accessibility_Accessible_getChildAtIndex (*obj, childIndex, &ev));
201 }
202
203 long
204 Accessible_getIndexInParent (Accessible *obj)
205 {
206   return Accessibility_Accessible_getIndexInParent (*obj, &ev);
207 }
208
209 /* Not Yet Implemented */
210 AccessibleRelation **
211 Accessible_getRelationSet (Accessible *obj)
212 {
213   return NULL;
214 }
215
216 /* Not Yet Implemented */
217 char *
218 Accessible_getRole (Accessible *obj)
219 {
220   return "";
221 }
222
223 /* Not Yet Implemented */
224 AccessibleStateSet *
225 Accessible_getStateSet (Accessible *obj)
226 {
227   return NULL;
228 }
229
230
231 /*
232  *
233  * AccessibleApplication function prototypes
234  *
235  */
236
237 int
238 AccessibleApplication_ref (AccessibleApplication *obj)
239 {
240   return Accessibility_Application_ref (*obj, &ev);
241 }
242
243 int
244 AccessibleApplication_unref (AccessibleApplication *obj)
245 {
246   return Accessibility_Application_unref (*obj, &ev);
247 }
248
249 char *
250 AccessibleApplication_getToolkitName (AccessibleApplication *obj)
251 {
252   return Accessibility_Application__getToolkitName (*obj, &ev);
253 }
254
255 char *
256 AccessibleApplication_getVersion (AccessibleApplication *obj)
257 {
258   return Accessibility_Application__getVersion (*obj, &ev);
259 }
260
261 long
262 AccessibleApplication_getID (AccessibleApplication *obj)
263 {
264   return Accessibility_Application__getID (*obj, &ev);
265 }
266
267 /* Not Yet Implemented */
268 boolean
269 AccessibleApplication_pause (AccessibleApplication *obj)
270 {
271   return FALSE;
272 }
273
274 /* Not Yet Implemented */
275 boolean
276 AccessibleApplication_resume (AccessibleApplication *obj)
277 {
278   return FALSE;
279 }
280