Changes to introspection generation to remove DOCTYPE and XML
[platform/core/uifw/at-spi2-atk.git] / test / app.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  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <libbonobo.h>
27 #include <bonobo-activation/bonobo-activation.h>
28 #include <atk/atkobject.h>
29 #include <libspi/Accessibility.h>
30 #include <libspi/accessible.h>
31 #include <libspi/application.h>
32
33 #define APP_STATIC_BUFF_SZ 30
34
35 int
36 main(int argc, char **argv)
37 {
38         CORBA_Environment ev;
39         CORBA_Object oclient;
40         AtkObject *atko;
41         char *obj_id;
42         char sbuf[APP_STATIC_BUFF_SZ];
43
44         Accessibility_Registry registry;
45         Accessibility_Event e;
46         SpiAccessible *accessible;
47         SpiApplication *app;
48
49         CORBA_exception_init(&ev);
50
51         if (!bonobo_init (&argc, argv))
52           {
53             g_error ("Could not initialize Bonobo");
54           }
55
56         /* Create the accesssible application server object */
57         g_snprintf(sbuf, APP_STATIC_BUFF_SZ, "application-%s", argv[0]);
58
59         atko = g_object_new (atk_object_get_type(), NULL);
60         atk_object_set_name (atko, sbuf);
61         atk_object_set_description( atko, "test application for accessibility SPI");
62         app = spi_application_new(atko);
63
64         /* Create the SpiAccessible 'source' for the event */
65         accessible = spi_accessible_new (atko);
66         fprintf(stderr, "accessible created.\n");
67
68         e.source = bonobo_object_corba_objref ( bonobo_object (accessible));
69         e.type = CORBA_string_dup ("focus:");
70
71         obj_id = "OAFIID:Accessibility_Registry:1.0";
72
73         oclient = bonobo_activation_activate_from_id (obj_id, 0, NULL, &ev);
74         if (ev._major != CORBA_NO_EXCEPTION) {
75                 fprintf(stderr,
76                 ("Accessibility app error: exception during registry activation from id: %s\n"),
77                         CORBA_exception_id(&ev));
78                 CORBA_exception_free(&ev);
79                 exit(-1);
80         }
81
82         if (CORBA_Object_is_nil (oclient, &ev))
83           {
84             g_error ("Could not locate registry");
85           }
86
87         registry = (Accessibility_Registry) oclient;
88
89         Accessibility_Registry_registerApplication (registry,
90                                                     bonobo_object_corba_objref (bonobo_object (app)),
91                                                     &ev);
92         fprintf(stderr, "registerApplication has been called.\n");
93
94         Accessibility_Registry_notifyEvent (registry, &e, &ev);
95         fprintf (stderr, "notify event has been called.\n");
96
97         bonobo_main (); /* needed when app becomes a server ? */
98         exit(0);
99 }