misc: Simplify code flow in process_deferred_messages
[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 G_BEGIN_DECLS
40
41 typedef struct _AtspiReference AtspiReference;
42 struct _AtspiReference
43 {
44   char *name;
45   char *path;
46 };
47
48 /* externs */
49 extern const char *atspi_path_dec;
50 extern const char *atspi_path_registry;
51 extern const char *atspi_path_root;
52 extern const char *atspi_bus_registry;
53 extern const char *atspi_interface_accessible;
54 extern const char *atspi_interface_action;
55 extern const char *atspi_interface_application;
56 extern const char *atspi_interface_collection;
57 extern const char *atspi_interface_component;
58 extern const char *atspi_interface_dec;
59 extern const char *atspi_interface_device_event_listener;
60 extern const char *atspi_interface_document;
61 extern const char *atspi_interface_editable_text;
62 extern const char *atspi_interface_hyperlink;
63 extern const char *atspi_interface_hypertext;
64 extern const char *atspi_interface_image;
65 extern const char *atspi_interface_registry;
66 extern const char *atspi_interface_selection;
67 extern const char *atspi_interface_table;
68 extern const char *atspi_interface_text;
69 extern const char *atspi_interface_cache;
70 extern const char *atspi_interface_value;
71
72 /* function prototypes */
73 gint _atspi_get_iface_num (const char *iface);
74
75 DBusConnection * _atspi_bus ();
76
77 AtspiAccessible * _atspi_ref_accessible (const char *app, const char *path);
78
79 AtspiAccessible *
80 _atspi_dbus_return_accessible_from_message (DBusMessage *message);
81
82 AtspiAccessible *
83 _atspi_dbus_return_accessible_from_iter (DBusMessageIter *iter);
84
85 AtspiHyperlink *
86 _atspi_dbus_return_hyperlink_from_message (DBusMessage *message);
87
88 AtspiHyperlink *
89 _atspi_dbus_return_hyperlink_from_iter (DBusMessageIter *iter);
90
91 dbus_bool_t _atspi_dbus_call (gpointer obj, const char *interface, const char *method, GError **error, const char *type, ...);
92
93 DBusMessage *_atspi_dbus_call_partial (gpointer obj, const char *interface, const char *method, GError **error, const char *type, ...);
94
95 DBusMessage *_atspi_dbus_call_partial_va (gpointer obj, const char *interface, const char *method, GError **error, const char *type, va_list args);
96
97 dbus_bool_t _atspi_dbus_get_property (gpointer obj, const char *interface, const char *name, GError **error, const char *type, void *data);
98
99 DBusMessage * _atspi_dbus_send_with_reply_and_block (DBusMessage *message, GError **error);
100
101 GHashTable *_atspi_dbus_return_hash_from_message (DBusMessage *message);
102
103 GHashTable *_atspi_dbus_hash_from_iter (DBusMessageIter *iter);
104
105 GArray *_atspi_dbus_return_attribute_array_from_message (DBusMessage *message);
106
107 GArray *_atspi_dbus_attribute_array_from_iter (DBusMessageIter *iter);
108
109 void _atspi_dbus_set_interfaces (AtspiAccessible *accessible, DBusMessageIter *iter);
110
111 void _atspi_dbus_set_state (AtspiAccessible *accessible, DBusMessageIter *iter);
112
113 #define _ATSPI_DBUS_CHECK_SIG(message, type, error, ret) \
114   if (!message) \
115     return (ret); \
116   if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR) \
117   { \
118     const char *err; \
119     dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &err, DBUS_TYPE_INVALID); \
120     if (err) \
121       g_set_error_literal (error, ATSPI_ERROR, ATSPI_ERROR_IPC, err); \
122     dbus_message_unref (message); \
123     return ret; \
124   } \
125   if (strcmp (dbus_message_get_signature (message), type) != 0) \
126   { \
127     g_warning ("at-spi: Expected message signature %s but got %s at %s line %d", type, dbus_message_get_signature (message), __FILE__, __LINE__); \
128     dbus_message_unref (message); \
129     return (ret); \
130   }
131
132
133 /**
134  * ATSPI_ERROR:
135  *
136  * Error domain for AT-SPI IPC failures. Errors in this domain will
137  * be from the #ATSPIAtspiError enumeration. See #GError for information on
138  * error domains.
139  */
140 #define ATSPI_ERROR _atspi_error_quark()
141 GQuark _atspi_error_quark (void);
142
143 /**
144  * AtspiError:
145  * @ATSPI_APPLICATION_NO_LONGER_EXISTS: The application has quit.
146  */
147 typedef enum
148 {
149   ATSPI_ERROR_APPLICATION_GONE,
150   ATSPI_ERROR_IPC
151 } AtspiError;
152
153 extern GMainLoop *atspi_main_loop;
154 extern gboolean atspi_no_cache;
155
156 GHashTable *_atspi_get_live_refs ();
157
158 gchar *_atspi_name_compat (gchar *in);
159 G_END_DECLS
160
161 #endif  /* _ATSPI_MISC_PRIVATE_H_ */