8c91e83cd868af28b120ede040123b70ee5842d8
[platform/upstream/at-spi2-core.git] / atspi / atspi-misc-private.h
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2002 Ximian, Inc.
6  *           2002 Sun Microsystems Inc.
7  * Copyright 2010, 2011 Novell, Inc.
8  *           
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Library General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Library General Public License for more details.
19  *
20  * You should have received a copy of the GNU Library General Public
21  * License along with this library; if not, write to the
22  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23  * Boston, MA 02111-1307, USA.
24  */
25
26 #ifndef _ATSPI_MISC_PRIVATE_H_
27 #define _ATSPI_MISC_PRIVATE_H_
28
29 /* Private internal implementation details of at-spi. */
30
31 #include <string.h>
32
33 #include "atspi.h"
34
35 #include "dbus/dbus.h"
36
37 #include "dbind/dbind.h"
38
39 typedef struct _AtspiReference AtspiReference;
40 struct _AtspiReference
41 {
42   char *name;
43   char *path;
44 };
45
46 /* constants */
47 #define ATSPI_DBUS_NAME_REGISTRY "org.a11y.atspi.Registry"
48 #define ATSPI_DBUS_PATH_REGISTRY "/org/a11y/atspi/registry"
49 #define ATSPI_DBUS_INTERFACE_REGISTRY "org.a11y.atspi.Registry"
50
51 #define ATSPI_DBUS_PATH_NULL "/org/a11y/atspi/null"
52 #define ATSPI_DBUS_PATH_ROOT "/org/a11y/atspi/accessible/root"
53
54 #define ATSPI_DBUS_PATH_DEC "/org/a11y/atspi/registry/deviceeventcontroller"
55 #define ATSPI_DBUS_INTERFACE_DEC "org.a11y.atspi.DeviceEventController"
56 #define ATSPI_DBUS_INTERFACE_DEVICE_EVENT_LISTENER "org.a11y.atspi.DeviceEventListener"
57
58 #define ATSPI_DBUS_INTERFACE_CACHE "org.a11y.atspi.Cache"
59 #define ATSPI_DBUS_INTERFACE_ACCESSIBLE "org.a11y.atspi.Accessible"
60 #define ATSPI_DBUS_INTERFACE_ACTION "org.a11y.atspi.Action"
61 #define ATSPI_DBUS_INTERFACE_APPLICATION "org.a11y.atspi.Application"
62 #define ATSPI_DBUS_INTERFACE_COLLECTION "org.a11y.atspi.Collection"
63 #define ATSPI_DBUS_INTERFACE_COMPONENT "org.a11y.atspi.Component"
64 #define ATSPI_DBUS_INTERFACE_DOCUMENT "org.a11y.atspi.Document"
65 #define ATSPI_DBUS_INTERFACE_EDITABLE_TEXT "org.a11y.atspi.EditableText"
66 #define ATSPI_DBUS_INTERFACE_EVENT_KEYBOARD "org.a11y.atspi.Event.Keyboard"
67 #define ATSPI_DBUS_INTERFACE_EVENT_MOUSE "org.a11y.atspi.Event.Mouse"
68 #define ATSPI_DBUS_INTERFACE_EVENT_OBJECT "org.a11y.atspi.Event.Object"
69 #define ATSPI_DBUS_INTERFACE_HYPERLINK "org.a11y.atspi.Hyperlink"
70 #define ATSPI_DBUS_INTERFACE_HYPERTEXT "org.a11y.atspi.Hypertext"
71 #define ATSPI_DBUS_INTERFACE_IMAGE "org.a11y.atspi.Image"
72 #define ATSPI_DBUS_INTERFACE_SELECTION "org.a11y.atspi.Selection"
73 #define ATSPI_DBUS_INTERFACE_TABLE "org.a11y.atspi.Table"
74 #define ATSPI_DBUS_INTERFACE_TEXT "org.a11y.atspi.Text"
75 #define ATSPI_DBUS_INTERFACE_VALUE "org.a11y.atspi.Value"
76 #define ATSPI_DBUS_INTERFACE_SOCKET "org.a11y.atspi.Socket"
77
78 /* externs */
79 extern const char *atspi_path_dec;
80 extern const char *atspi_path_registry;
81 extern const char *atspi_path_root;
82 extern const char *atspi_bus_registry;
83 extern const char *atspi_interface_accessible;
84 extern const char *atspi_interface_action;
85 extern const char *atspi_interface_application;
86 extern const char *atspi_interface_collection;
87 extern const char *atspi_interface_component;
88 extern const char *atspi_interface_dec;
89 extern const char *atspi_interface_device_event_listener;
90 extern const char *atspi_interface_document;
91 extern const char *atspi_interface_editable_text;
92 extern const char *atspi_interface_hyperlink;
93 extern const char *atspi_interface_hypertext;
94 extern const char *atspi_interface_image;
95 extern const char *atspi_interface_registry;
96 extern const char *atspi_interface_selection;
97 extern const char *atspi_interface_table;
98 extern const char *atspi_interface_text;
99 extern const char *atspi_interface_cache;
100 extern const char *atspi_interface_value;
101
102 /* function prototypes */
103 gint _atspi_get_iface_num (const char *iface);
104
105 DBusConnection * _atspi_bus ();
106
107 AtspiAccessible * _atspi_ref_accessible (const char *app, const char *path);
108
109 AtspiAccessible *
110 _atspi_dbus_return_accessible_from_message (DBusMessage *message);
111
112 AtspiAccessible *
113 _atspi_dbus_return_accessible_from_iter (DBusMessageIter *iter);
114
115 AtspiHyperlink *
116 _atspi_dbus_return_hyperlink_from_message (DBusMessage *message);
117
118 AtspiHyperlink *
119 _atspi_dbus_return_hyperlink_from_iter (DBusMessageIter *iter);
120
121 dbus_bool_t _atspi_dbus_call (gpointer obj, const char *interface, const char *method, GError **error, const char *type, ...);
122
123 DBusMessage *_atspi_dbus_call_partial (gpointer obj, const char *interface, const char *method, GError **error, const char *type, ...);
124
125 DBusMessage *_atspi_dbus_call_partial_va (gpointer obj, const char *interface, const char *method, GError **error, const char *type, va_list args);
126
127 dbus_bool_t _atspi_dbus_get_property (gpointer obj, const char *interface, const char *name, GError **error, const char *type, void *data);
128
129 DBusMessage * _atspi_dbus_send_with_reply_and_block (DBusMessage *message, GError **error);
130
131 GHashTable *_atspi_dbus_return_hash_from_message (DBusMessage *message);
132
133 GHashTable *_atspi_dbus_hash_from_iter (DBusMessageIter *iter);
134
135 GArray *_atspi_dbus_return_attribute_array_from_message (DBusMessage *message);
136
137 GArray *_atspi_dbus_attribute_array_from_iter (DBusMessageIter *iter);
138
139 gboolean _atspi_process_deferred_messages (gpointer data);
140
141 void _atspi_dbus_set_interfaces (AtspiAccessible *accessible, DBusMessageIter *iter);
142
143 void _atspi_dbus_set_state (AtspiAccessible *accessible, DBusMessageIter *iter);
144
145 #define _ATSPI_DBUS_CHECK_SIG(message, type, error, ret) \
146   if (!message) { \
147     g_warning ("at-spi: Got no message at %s line %d\n", __FILE__, __LINE__); \
148     return (ret); \
149   } \
150   if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR) \
151   { \
152     const char *err; \
153     dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &err, DBUS_TYPE_INVALID); \
154     if (err) \
155       g_set_error_literal (error, ATSPI_ERROR, ATSPI_ERROR_IPC, err); \
156     dbus_message_unref (message); \
157     return ret; \
158   } \
159   if (strcmp (dbus_message_get_signature (message), type) != 0) \
160   { \
161     g_warning ("at-spi: Expected message signature %s but got %s at %s line %d", type, dbus_message_get_signature (message), __FILE__, __LINE__); \
162     dbus_message_unref (message); \
163     return (ret); \
164   }
165
166
167 /**
168  * ATSPI_ERROR:
169  *
170  * Error domain for AT-SPI IPC failures. Errors in this domain will
171  * be from the #ATSPIAtspiError enumeration. See #GError for information on
172  * error domains.
173  */
174 #define ATSPI_ERROR atspi_error_quark()
175 GQuark atspi_error_quark (void);
176
177 /**
178  * AtspiError:
179  * @ATSPI_APPLICATION_NO_LONGER_EXISTS: The application has quit.
180  */
181 typedef enum
182 {
183   ATSPI_ERROR_APPLICATION_GONE,
184   ATSPI_ERROR_IPC
185 } AtspiError;
186
187 extern GMainLoop *atspi_main_loop;
188 #endif  /* _ATSPI_MISC_PRIVATE_H_ */