Renamed SpiAccessibleEventListener to (just) SpiEventListener.
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_main.c
1
2 /*
3  *
4  * Basic SPI initialization and event loop function prototypes
5  *
6  */
7
8 /**
9  * SPI_init:
10  *
11  * Connects to the accessibility registry and initializes the SPI.
12  *
13  * Returns: 0 on success, otherwise an integer error code.
14  **/
15 int
16 SPI_init (void)
17 {
18   int argc = 0;
19   CORBA_Object oclient;
20   char *obj_id;
21
22   CORBA_exception_init(&ev);
23
24   if (!bonobo_init (&argc, NULL))
25     {
26       g_error ("Could not initialize Bonobo");
27     }
28
29   obj_id = "OAFIID:Accessibility_Registry:proto0.1";
30
31   oclient = bonobo_activation_activate_from_id (obj_id, 0, NULL, &ev);
32   if (ev._major != CORBA_NO_EXCEPTION) {
33     fprintf (stderr,
34             ("AT-SPI error: during registry activation: %s\n"),
35             CORBA_exception_id(&ev));
36     CORBA_exception_free(&ev);
37     exit(-1);
38   }
39
40   if (CORBA_Object_is_nil (oclient, &ev))
41     {
42       g_error ("Could not locate registry");
43       exit(-1);
44     }
45
46   registry = (Accessibility_Registry) oclient;
47
48   bonobo_activate ();
49
50   return 0;
51 }
52
53 /**
54  * SPI_event_main:
55  * @isGNOMEApp: a #boolean indicating whether the client of the SPI
56  *              will use the Gnome event loop or not.  Clients that have
57  *              their own GUIS will usually specify #TRUE here, and must
58  *              do so if they use Gnome GUI components.
59  *
60  * Starts/enters the main event loop for the SPI services.
61  *
62  * (NOTE: This method does not return control, it is exited via a call to exit()
63  * from within an event handler).
64  *
65  **/
66 void
67 SPI_event_main (boolean isGNOMEApp)
68 {
69   if (isGNOMEApp) {       
70     g_atexit(SPI_exit);
71     bonobo_main();
72   }
73   else {
74     /* TODO: install signal handlers to do cleanup */
75     CORBA_ORB_run (bonobo_orb(), &ev);
76     fprintf (stderr, "orb loop exited...\n");
77   }
78 }
79
80 /**
81  * SPI_eventIsReady:
82  *
83  * Checks to see if an SPI event is waiting in the event queue.
84  * Used by clients that don't wish to use SPI_event_main().
85  *
86  * Not Yet Implemented.
87  *
88  * Returns: #TRUE if an event is waiting, otherwise #FALSE.
89  *
90  **/
91 boolean
92 SPI_eventIsReady ()
93 {
94   return FALSE;
95 }
96
97 /**
98  * SPI_nextEvent:
99  * @waitForEvent: a #boolean indicating whether to block or not.
100  *
101  * Gets the next event in the SPI event queue; blocks if no event
102  * is pending and @waitForEvent is #TRUE.
103  * Used by clients that don't wish to use SPI_event_main().
104  *
105  * Not Yet Implemented.
106  *
107  * Returns: the next #AccessibleEvent in the SPI event queue.
108  *
109  **/
110 AccessibleEvent *
111 SPI_nextEvent (boolean waitForEvent)
112 {
113   return NULL;
114 }
115
116 /**
117  * SPI_exit:
118  *
119  * Disconnects from the Accessibility Registry and releases resources.
120  *
121  **/
122 void
123 SPI_exit (void)
124 {
125   fprintf (stderr, "bye-bye!\n");       
126   exit(0);
127 }
128