Add a check for lack of memory
[platform/core/uifw/at-spi2-atk.git] / libspi / application.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2008 Novell, Inc.
6  * Copyright 2001, 2002 Sun Microsystems Inc.,
7  * Copyright 2001, 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 #include "accessible.h"
25
26
27 static dbus_bool_t
28 impl_get_toolkitName (const char *path, DBusMessageIter * iter,
29                       void *user_data)
30 {
31   return droute_return_v_string (iter, atk_get_toolkit_name ());
32 }
33
34 static char *
35 impl_get_toolkitName_str (void *datum)
36 {
37   return g_strdup (atk_get_toolkit_name ());
38 }
39
40 static dbus_bool_t
41 impl_get_version (const char *path, DBusMessageIter * iter, void *user_data)
42 {
43   return droute_return_v_string (iter, atk_get_toolkit_version ());
44 }
45
46 static char *
47 impl_get_version_str (void *datum)
48 {
49   return g_strdup (atk_get_toolkit_version ());
50 }
51
52 static dbus_int32_t id;
53
54 static dbus_bool_t
55 impl_get_id (const char *path, DBusMessageIter * iter, void *user_data)
56 {
57   return droute_return_v_int32 (iter, id);
58 }
59
60 static char *
61 impl_get_id_str (void *datum)
62 {
63   return g_strdup_printf ("%d", id);
64 }
65
66 static dbus_bool_t
67 impl_set_id (const char *path, DBusMessageIter * iter, void *user_data)
68 {
69   id = droute_get_v_int32 (iter);
70   return TRUE;
71 }
72
73 static DBusMessage *
74 impl_registerToolkitEventListener (DBusConnection * bus,
75                                    DBusMessage * message, void *user_data)
76 {
77 }
78
79 static DBusMessage *
80 impl_registerObjectEventListener (DBusConnection * bus, DBusMessage * message,
81                                   void *user_data)
82 {
83 }
84
85 static DBusMessage *
86 impl_pause (DBusConnection * bus, DBusMessage * message, void *user_data)
87 {
88 }
89
90 static DBusMessage *
91 impl_resume (DBusConnection * bus, DBusMessage * message, void *user_data)
92 {
93 }
94
95 static DBusMessage *
96 impl_getLocale (DBusConnection * bus, DBusMessage * message, void *user_data)
97 {
98 }
99
100 static DRouteMethod methods[] = {
101   {DROUTE_METHOD, impl_registerToolkitEventListener,
102    "registerToolkitEventListener", "o,listener,i:s,eventName,i"},
103   {DROUTE_METHOD, impl_registerObjectEventListener,
104    "registerObjectEventListener", "o,listener,i:s,eventName,i"},
105   {DROUTE_METHOD, impl_pause, "pause", "b,,o"},
106   {DROUTE_METHOD, impl_resume, "resume", "b,,o"},
107   {DROUTE_METHOD, impl_getLocale, "getLocale", "u,lctype,i:s,,o"},
108   {0, NULL, NULL, NULL}
109 };
110
111 static DRouteProperty properties[] = {
112   {impl_get_toolkitName, impl_get_toolkitName_str, NULL, NULL, "toolkitName",
113    "s"},
114   {impl_get_version, impl_get_version_str, NULL, NULL, "version", "s"},
115   {impl_get_id, impl_get_id_str, impl_set_id, NULL, "id", "i"},
116   {NULL, NULL, NULL, NULL, NULL, NULL}
117 };
118
119 static long
120 obj_is_root (const char *path, void *user_data)
121 {
122   AtkObject *obj = spi_dbus_get_object (path);
123   return (obj == atk_get_root ());
124 }
125
126 void
127 spi_initialize_application (DRouteData * data)
128 {
129   droute_add_interface (data, "org.freedesktop.accessibility.Application",
130                         methods, properties,
131                         (DRouteGetDatumFunction) obj_is_root, NULL);
132 };