7b219b0fcfe2a75c39e8183d593ddfa4c483487a
[platform/core/uifw/at-spi2-atk.git] / cspi / spi-application.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 /*
25  *
26  * AccessibleApplication function prototypes
27  *
28  */
29
30 #include <cspi/spi-private.h>
31 #include <locale.h>
32
33 /**
34  * AccessibleApplication_ref:
35  * @obj: a pointer to the #AccessibleApplication on which to operate.
36  *
37  * Increment the reference count for an #AccessibleApplication.
38  **/
39 void
40 AccessibleApplication_ref (AccessibleApplication *obj)
41 {
42   cspi_object_ref (obj);
43 }
44
45 /**
46  * AccessibleApplication_unref:
47  * @obj: a pointer to the #AccessibleApplication object on which to operate.
48  *
49  * Decrement the reference count for an #AccessibleApplication.
50  **/
51 void
52 AccessibleApplication_unref (AccessibleApplication *obj)
53 {
54   cspi_object_unref (obj);
55 }
56
57 /**
58  * AccessibleApplication_getToolkitName:
59  * @obj: a pointer to the #AccessibleApplication to query.
60  *
61  * Get the name of the UI toolkit used by an #AccessibleApplication.
62  *
63  * Returns: a UTF-8 string indicating which UI toolkit is
64  *          used by an application.
65  **/
66 char *
67 AccessibleApplication_getToolkitName (AccessibleApplication *obj)
68 {
69   char *retval;
70
71   cspi_return_val_if_fail (obj != NULL, NULL);
72
73   cspi_dbus_get_property (obj, spi_interface_application, "tooklitName", NULL, "s", &retval);
74
75   cspi_return_val_if_ev ("toolkitName", NULL);
76
77   return retval;
78 }
79
80 /**
81  * AccessibleApplication_getVersion:
82  * @obj: a pointer to the #AccessibleApplication being queried.
83  *
84  * Get the version of the at-spi bridge exported by an
85  *      #AccessibleApplication instance.
86  *
87  * Returns: a UTF-8 string indicating the application's
88  *          at-spi version.
89  **/
90 char *
91 AccessibleApplication_getVersion (AccessibleApplication *obj)
92 {
93   char *retval;
94
95   cspi_return_val_if_fail (obj != NULL, NULL);
96
97   cspi_dbus_get_property (obj, spi_interface_application, "version", NULL, "s", &retval);
98
99   cspi_return_val_if_ev ("version", NULL);
100
101   return retval;
102 }
103
104 /**
105  * AccessibleApplication_getID:
106  * @obj: a pointer to the #AccessibleApplication being queried.
107  *
108  * Get the unique ID assigned by the Registry to an
109  *      #AccessibleApplication instance.
110  * (Not Yet Implemented by the registry).
111  *
112  * Returns: a unique #long integer associated with the application
113  *          by the Registry, or 0 if the application is not registered.
114  **/
115 long
116 AccessibleApplication_getID (AccessibleApplication *obj)
117 {
118   dbus_int32_t retval;
119
120   cspi_return_val_if_fail (obj != NULL, 0);
121
122   cspi_dbus_get_property (obj, spi_interface_application, "id", NULL, "u", &retval);
123
124   cspi_return_val_if_ev ("id", 0);
125
126   return retval;
127 }
128
129 /**
130  * AccessibleApplication_getLocale:
131  * @obj: a pointer to the #AccessibleApplication being queried.
132  * @lc_category: one of the POSIX LC_TYPE enumeration, for instance
133  * LC_MESSAGES.
134  *
135  * Get a POSIX-compliant string describing the application's current
136  * locale setting for a particular @lctype category.
137  *
138  * @Since: AT-SPI 1.4
139  *
140  * Returns: a POSIX-compliant locale string, e.g. "C", "pt_BR", "sr@latn", etc.
141  **/
142 char *
143 AccessibleApplication_getLocale (AccessibleApplication *obj, int lc_category)
144 {
145   gchar *retval;
146   dbus_uint32_t lctype;
147
148   cspi_return_val_if_fail (obj != NULL, g_strdup (""));
149
150   switch (lc_category) 
151   {
152   case LC_COLLATE:
153     lctype = Accessibility_LOCALE_TYPE_COLLATE;
154     break;
155   case LC_CTYPE:
156     lctype = Accessibility_LOCALE_TYPE_CTYPE;
157     break;
158   case LC_NUMERIC:
159     lctype = Accessibility_LOCALE_TYPE_NUMERIC;
160     break;
161   case LC_MONETARY:
162     lctype = Accessibility_LOCALE_TYPE_MONETARY;
163     break;
164   case LC_MESSAGES:
165   default:
166     lctype = Accessibility_LOCALE_TYPE_MESSAGES;
167     break;
168   }
169
170   cspi_dbus_call (obj, spi_interface_application, "getLocale", NULL, "u=>s", lctype, &retval);
171
172   cspi_return_val_if_ev ("id", g_strdup (""));
173
174   return g_strdup (retval);
175 }
176
177 /**
178  * AccessibleApplication_pause:
179  * @obj: a pointer to the #Accessible object on which to operate.
180  *
181  * Attempt to pause the application (used when client event queue is
182  *  over-full).
183  * Not Yet Implemented.
184  *
185  * Returns: #TRUE if the application was paused successfully, #FALSE otherwise.
186  *
187  **/
188 SPIBoolean
189 AccessibleApplication_pause (AccessibleApplication *obj)
190 {
191   return FALSE;
192 }
193
194 /**
195  * AccessibleApplication_resume:
196  * @obj: a pointer to the #Accessible object on which to operate.
197  *
198  * Attempt to resume the application (used after #AccessibleApplication_pause).
199  * Not Yet Implemented.
200  *
201  * Returns: #TRUE if application processing resumed successfully, #FALSE otherwise.
202  *
203  **/
204 SPIBoolean
205 AccessibleApplication_resume (AccessibleApplication *obj)
206 {
207   return FALSE;
208 }