summaryrefslogtreecommitdiff
path: root/atspi/atspi-misc-private.h
blob: e386a241c642f73293ef9db223ec12435f472e3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*
 * AT-SPI - Assistive Technology Service Provider Interface
 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
 *
 * Copyright 2002 Ximian, Inc.
 *           2002 Sun Microsystems Inc.
 * Copyright 2010, 2011 Novell, Inc.
 *
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef _ATSPI_MISC_PRIVATE_H_
#define _ATSPI_MISC_PRIVATE_H_

/* Private internal implementation details of at-spi. */

#include <string.h>

#include "atspi.h"

#include "dbus/dbus.h"

#include "dbind/dbind.h"

G_BEGIN_DECLS

typedef struct _AtspiReference AtspiReference;
struct _AtspiReference
{
  char *name;
  char *path;
};

/* externs */
extern const char *atspi_path_dec;
extern const char *atspi_path_registry;
extern const char *atspi_path_root;
extern const char *atspi_bus_registry;
extern const char *atspi_interface_accessible;
extern const char *atspi_interface_action;
extern const char *atspi_interface_application;
extern const char *atspi_interface_collection;
extern const char *atspi_interface_component;
extern const char *atspi_interface_dec;
extern const char *atspi_interface_device_event_listener;
extern const char *atspi_interface_document;
extern const char *atspi_interface_editable_text;
extern const char *atspi_interface_hyperlink;
extern const char *atspi_interface_hypertext;
extern const char *atspi_interface_image;
extern const char *atspi_interface_registry;
extern const char *atspi_interface_selection;
extern const char *atspi_interface_table;
extern const char *atspi_interface_table_cell;
extern const char *atspi_interface_text;
extern const char *atspi_interface_cache;
extern const char *atspi_interface_value;

/* function prototypes */
gint _atspi_get_iface_num (const char *iface);

DBusConnection *_atspi_bus ();

AtspiAccessible *_atspi_ref_accessible (const char *app, const char *path);

AtspiAccessible *
_atspi_dbus_return_accessible_from_message (DBusMessage *message);

AtspiAccessible *
_atspi_dbus_consume_accessible (DBusMessageIter *iter);

AtspiHyperlink *
_atspi_dbus_return_hyperlink_from_message (DBusMessage *message);

AtspiHyperlink *
_atspi_dbus_return_hyperlink_from_iter (DBusMessageIter *iter);

dbus_bool_t _atspi_dbus_call (gpointer obj, const char *interface, const char *method, GError **error, const char *type, ...);

DBusMessage *_atspi_dbus_call_partial (gpointer obj, const char *interface, const char *method, GError **error, const char *type, ...);

DBusMessage *_atspi_dbus_call_partial_va (gpointer obj, const char *interface, const char *method, GError **error, const char *type, va_list args);

dbus_bool_t _atspi_dbus_get_property (gpointer obj, const char *interface, const char *name, GError **error, const char *type, void *data);

DBusMessage *_atspi_dbus_send_with_reply_and_block (DBusMessage *message, GError **error);

GHashTable *_atspi_dbus_return_hash_from_message (DBusMessage *message);

GHashTable *_atspi_dbus_hash_from_iter (DBusMessageIter *iter);

GArray *_atspi_dbus_return_attribute_array_from_message (DBusMessage *message);

GArray *_atspi_dbus_attribute_array_from_iter (DBusMessageIter *iter);

void _atspi_dbus_set_interfaces (AtspiAccessible *accessible, DBusMessageIter *iter);

void _atspi_dbus_set_state (AtspiAccessible *accessible, DBusMessageIter *iter);

#define _ATSPI_DBUS_CHECK_SIG(message, type, error, ret)                                                                                            \
  if (!message)                                                                                                                                     \
    return (ret);                                                                                                                                   \
  if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR)                                                                                   \
    {                                                                                                                                               \
      const char *err;                                                                                                                              \
      dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &err, DBUS_TYPE_INVALID);                                                             \
      if (err)                                                                                                                                      \
        g_set_error_literal (error, ATSPI_ERROR, ATSPI_ERROR_IPC, err);                                                                             \
      dbus_message_unref (message);                                                                                                                 \
      return ret;                                                                                                                                   \
    }                                                                                                                                               \
  if (strcmp (dbus_message_get_signature (message), type) != 0)                                                                                     \
    {                                                                                                                                               \
      g_warning ("AT-SPI: Expected message signature %s but got %s at %s line %d", type, dbus_message_get_signature (message), __FILE__, __LINE__); \
      dbus_message_unref (message);                                                                                                                 \
      return (ret);                                                                                                                                 \
    }

/**
 * ATSPI_ERROR:
 *
 * Error domain for AT-SPI IPC failures. Errors in this domain will
 * be from the #ATSPIAtspiError enumeration. See #GError for information on
 * error domains.
 */
#define ATSPI_ERROR _atspi_error_quark ()
GQuark _atspi_error_quark (void);

/**
 * AtspiError:
 * @ATSPI_APPLICATION_NO_LONGER_EXISTS: The application has quit.
 */
typedef enum
{
  ATSPI_ERROR_APPLICATION_GONE,
  ATSPI_ERROR_IPC,
} AtspiError;

extern GMainLoop *atspi_main_loop;
extern gboolean atspi_no_cache;

GHashTable *_atspi_get_live_refs ();

gchar *_atspi_name_compat (gchar *in);

GHashTable *_atspi_dbus_update_cache_from_dict (AtspiAccessible *accessible, DBusMessageIter *iter);

gboolean _atspi_prepare_screen_reader_interface ();

gchar *_atspi_strdup_and_adjust_for_dbus (const char *s);
G_END_DECLS

#endif /* _ATSPI_MISC_PRIVATE_H_ */