version 1.1.6. Added ref/unref for AccessibleEvents.
[platform/core/uifw/at-spi2-atk.git] / cspi / bonobo / cspi-bonobo.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001, 2002 Sun Microsystems Inc.,
6  * Copyright 2001, 2002 Ximian, Inc.
7  *           2002 Ximian Inc.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Library General Public
11  * License as published by the Free Software Foundation; either
12  * version 2 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Library General Public License for more details.
18  *
19  * You should have received a copy of the GNU Library General Public
20  * License along with this library; if not, write to the
21  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22  * Boston, MA 02111-1307, USA.
23  */
24
25 #include <string.h>
26 #include <libbonobo.h>
27 #include "../cspi-lowlevel.h"
28
29 CORBA_Object
30 cspi_dup_ref (CORBA_Object object)
31 {
32   return bonobo_object_dup_ref (object, cspi_ev ());
33 }
34
35 void
36 cspi_release_unref (CORBA_Object object)
37 {
38   bonobo_object_release_unref (object, NULL);
39 }
40
41 SPIBoolean
42 cspi_check_ev (const char *error_string)
43 {
44   CORBA_Environment *ev = cspi_ev ();
45
46   if (ev->_major != CORBA_NO_EXCEPTION)
47     {
48       char *err;
49
50       err = bonobo_exception_get_text (ev);
51
52       fprintf (stderr, "Warning: AT-SPI error: %s: %s\n",
53                error_string, err);
54
55       g_free (err);
56
57       CORBA_exception_free (ev);
58
59       return FALSE;
60     }
61   else
62     {
63       return TRUE;
64     }
65 }
66
67 char *
68 cspi_exception_get_text (void)
69 {
70   char *ret, *txt;
71
72   txt = bonobo_exception_get_text (cspi_ev ());
73   ret = strdup (txt);
74   g_free (txt);
75
76   return ret;
77 }
78
79 CORBA_Object
80 cspi_init (void)
81 {
82   char *obj_id;
83   CORBA_Object registry;
84   CORBA_Environment ev;
85
86   if (!bonobo_init (0, NULL))
87     {
88       g_error ("Could not initialize Bonobo");
89     }
90
91   obj_id = "OAFIID:Accessibility_Registry:1.0";
92
93   CORBA_exception_init (&ev);
94
95   registry = bonobo_activation_activate_from_id (
96     obj_id, 0, NULL, &ev);
97
98   if (ev._major != CORBA_NO_EXCEPTION)
99     {
100       g_error ("AT-SPI error: during registry activation: %s\n",
101                bonobo_exception_get_text (&ev));
102     }
103
104   if (registry == CORBA_OBJECT_NIL)
105     {
106       g_error ("Could not locate registry");
107     }
108
109   bonobo_activate ();
110
111   return registry;
112 }
113
114 SPIBoolean
115 cspi_ping (CORBA_Object object)
116 {
117         return bonobo_unknown_ping (object, NULL);
118 }
119
120 void
121 cspi_main (void)
122 {
123   bonobo_main ();
124 }
125
126 void
127 cspi_main_quit (void)
128 {
129   bonobo_main_quit ();
130 }