2001-12-11 Michael Meeks <michael@ximian.com>
[platform/core/uifw/at-spi2-atk.git] / cspi / bonobo / cspi-bonobo.c
1 #include <string.h>
2 #include <libbonobo.h>
3 #include "../cspi-lowlevel.h"
4
5 void
6 cspi_dup_ref (CORBA_Object object)
7 {
8   bonobo_object_dup_ref (object, NULL);
9 }
10
11 void
12 cspi_release_unref (CORBA_Object object)
13 {
14   bonobo_object_release_unref (object, NULL);
15 }
16
17 SPIBoolean
18 cspi_check_ev (const char *error_string)
19 {
20   CORBA_Environment *ev = cspi_ev ();
21
22   if (ev->_major != CORBA_NO_EXCEPTION)
23     {
24       char *err;
25
26       err = bonobo_exception_get_text (ev);
27
28       fprintf (stderr, "Warning: AT-SPI error: %s: %s\n",
29                error_string, err);
30
31       g_free (err);
32
33       CORBA_exception_free (ev);
34
35       return FALSE;
36     }
37   else
38     {
39       return TRUE;
40     }
41 }
42
43 char *
44 cspi_exception_get_text (void)
45 {
46   char *ret, *txt;
47
48   txt = bonobo_exception_get_text (cspi_ev ());
49   ret = strdup (txt);
50   g_free (txt);
51
52   return ret;
53 }
54
55 CORBA_Object
56 cspi_init (void)
57 {
58   char *obj_id;
59   CORBA_Object registry;
60   CORBA_Environment ev;
61
62   if (!bonobo_init (0, NULL))
63     {
64       g_error ("Could not initialize Bonobo");
65     }
66
67   obj_id = "OAFIID:Accessibility_Registry:proto0.1";
68
69   CORBA_exception_init (&ev);
70
71   registry = bonobo_activation_activate_from_id (
72     obj_id, 0, NULL, &ev);
73
74   if (ev._major != CORBA_NO_EXCEPTION)
75     {
76       g_error ("AT-SPI error: during registry activation: %s\n",
77                bonobo_exception_get_text (&ev));
78     }
79
80   if (registry == CORBA_OBJECT_NIL)
81     {
82       g_error ("Could not locate registry");
83     }
84
85   bonobo_activate ();
86
87   return registry;
88 }
89
90 void
91 cspi_main (void)
92 {
93   bonobo_main ();
94 }
95
96 void
97 cspi_main_quit (void)
98 {
99   bonobo_main_quit ();
100 }