1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2016 Intel Corporation.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5//
6// W A R N I N G
7// -------------
8//
9// This file is not part of the public API. This header file may
10// change from version to version without notice, or even be
11// removed.
12//
13// We mean it.
14//
15//
16
17#ifndef QDBUS_SYMBOLS_P_H
18#define QDBUS_SYMBOLS_P_H
19
20#include <QtDBus/private/qtdbusglobal_p.h>
21
22#ifndef QT_NO_DBUS
23
24#ifdef QT_LINKED_LIBDBUS
25# include <dbus/dbus.h>
26#else
27# include "dbus_minimal_p.h"
28#endif
29
30#ifdef interface
31# undef interface
32#endif
33
34QT_BEGIN_NAMESPACE
35
36#if !defined QT_LINKED_LIBDBUS
37
38void (*qdbus_resolve_conditionally(const char *name))(); // doesn't print a warning
39void (*qdbus_resolve_me(const char *name))(); // prints a warning
40bool qdbus_loadLibDBus();
41
42//# define TRACE_DBUS_CALLS
43# ifdef TRACE_DBUS_CALLS
44namespace QtDBusCallTracing {
45struct TraceDBusCall
46{
47 struct ThreadData {
48 TraceDBusCall *ptr;
49 int level;
50 bool finishedPrinted;
51 };
52
53 static inline ThreadData &td()
54 {
55 Q_CONSTINIT static thread_local ThreadData value;
56 return value;
57 }
58
59 ThreadData savedData;
60 QDebug s;
61 TraceDBusCall(QDebug s, const char *fname)
62 : savedData(td()), s(s.nospace() << QByteArray(savedData.level * 3, ' ').constData() << fname)
63 {
64 if (savedData.ptr && !savedData.finishedPrinted) {
65 savedData.ptr->s << " ...unfinished";
66 savedData.ptr->s = qDebug().nospace() << QByteArray(savedData.level * 3 - 3, ' ').constData();
67 savedData.finishedPrinted = true;
68 }
69 ThreadData &data = td();
70 data.ptr = this;
71 data.level++;
72 data.finishedPrinted = false;
73 }
74 ~TraceDBusCall()
75 {
76 td() = savedData;
77 }
78
79 void operator()() { s << ")"; }
80 template <typename... Args> void operator()(const char *arg1, Args &&... args)
81 {
82 s << '"' << arg1 << '"';
83 if (sizeof...(args))
84 s << ", ";
85 operator()(args...);
86 }
87 template <typename Arg1, typename... Args> void operator()(Arg1 &&arg1, Args &&... args)
88 {
89 s << arg1;
90 if (sizeof...(args))
91 s << ", ";
92 operator()(args...);
93 }
94};
95template <typename T> T operator,(TraceDBusCall &&tc, T &&ret)
96{
97 tc.s << " = " << ret;
98 return ret;
99}
100inline const char *operator,(TraceDBusCall &&tc, const char *ret)
101{
102 tc.s << " = \"" << ret << '"';
103 return ret;
104}
105
106template <typename T> struct TraceReturn { typedef TraceDBusCall Type; };
107template <> struct TraceReturn<void> { typedef void Type; };
108}
109
110# define DEBUGCALL(name, argcall) QtDBusCallTracing::TraceDBusCall tc(qDebug(), name "("); tc argcall
111# define DEBUGRET(ret) (QtDBusCallTracing::TraceReturn<ret>::Type) tc ,
112# else
113# define DEBUGCALL(name, argcall)
114# define DEBUGRET(ret)
115# endif
116
117# define DEFINEFUNC(ret, func, args, argcall, funcret) \
118 typedef ret (* _q_PTR_##func) args; \
119 static inline ret q_##func args \
120 { \
121 static _q_PTR_##func ptr; \
122 DEBUGCALL(#func, argcall); \
123 if (!ptr) \
124 ptr = (_q_PTR_##func) qdbus_resolve_me(#func); \
125 funcret DEBUGRET(ret) ptr argcall; \
126 }
127
128# define DEFINEFUNC_CONDITIONALLY(ret, func, args, argcall, funcret, failret) \
129 typedef ret (* _q_PTR_##func) args; \
130 static inline ret q_##func args \
131 { \
132 static _q_PTR_##func ptr; \
133 DEBUGCALL(#func, argcall); \
134 if (!ptr) \
135 ptr = (_q_PTR_##func) qdbus_resolve_conditionally(#func); \
136 if (!ptr) \
137 failret; \
138 funcret DEBUGRET(ret) ptr argcall; \
139 }
140
141#else // defined QT_LINKED_LIBDBUS
142
143inline bool qdbus_loadLibDBus() { return true; }
144
145# define DEFINEFUNC(ret, func, args, argcall, funcret) \
146 static inline ret q_##func args { funcret func argcall; }
147
148#endif // defined QT_LINKED_LIBDBUS
149
150/* dbus-bus.h */
151DEFINEFUNC(void, dbus_bus_add_match, (DBusConnection *connection,
152 const char *rule,
153 DBusError *error),
154 (connection, rule, error), )
155DEFINEFUNC(void, dbus_bus_remove_match, (DBusConnection *connection,
156 const char *rule,
157 DBusError *error),
158 (connection, rule, error), )
159DEFINEFUNC(dbus_bool_t, dbus_bus_register,(DBusConnection *connection,
160 DBusError *error),
161 (connection, error), return)
162DEFINEFUNC(DBusConnection *, dbus_bus_get_private, (DBusBusType type,
163 DBusError *error),
164 (type, error), return)
165DEFINEFUNC(const char*, dbus_bus_get_unique_name, (DBusConnection *connection),
166 (connection), return)
167
168/* dbus-connection.h */
169DEFINEFUNC(dbus_bool_t , dbus_connection_add_filter, (DBusConnection *connection,
170 DBusHandleMessageFunction function,
171 void *user_data,
172 DBusFreeFunction free_data_function),
173 (connection, function, user_data, free_data_function), return)
174DEFINEFUNC(void , dbus_connection_close, (DBusConnection *connection),
175 (connection), return)
176DEFINEFUNC(DBusDispatchStatus , dbus_connection_dispatch, (DBusConnection *connection),
177 (connection), return)
178DEFINEFUNC(DBusDispatchStatus , dbus_connection_get_dispatch_status, (DBusConnection *connection),
179 (connection), return)
180DEFINEFUNC(dbus_bool_t, dbus_connection_get_is_authenticated, (DBusConnection * connection),
181 (connection), return )
182DEFINEFUNC(dbus_bool_t , dbus_connection_get_is_connected, (DBusConnection *connection),
183 (connection), return)
184DEFINEFUNC(DBusConnection* , dbus_connection_open_private, (const char *address,
185 DBusError *error),
186 (address, error), return)
187DEFINEFUNC(DBusConnection* , dbus_connection_ref, (DBusConnection *connection),
188 (connection), return)
189DEFINEFUNC(dbus_bool_t , dbus_connection_send, (DBusConnection *connection,
190 DBusMessage *message,
191 dbus_uint32_t *client_serial),
192 (connection, message, client_serial), return)
193DEFINEFUNC(dbus_bool_t , dbus_connection_send_with_reply, (DBusConnection *connection,
194 DBusMessage *message,
195 DBusPendingCall **pending_return,
196 int timeout_milliseconds),
197 (connection, message, pending_return, timeout_milliseconds), return)
198DEFINEFUNC(void , dbus_connection_set_exit_on_disconnect, (DBusConnection *connection,
199 dbus_bool_t exit_on_disconnect),
200 (connection, exit_on_disconnect), )
201DEFINEFUNC(dbus_bool_t , dbus_connection_set_timeout_functions, (DBusConnection *connection,
202 DBusAddTimeoutFunction add_function,
203 DBusRemoveTimeoutFunction remove_function,
204 DBusTimeoutToggledFunction toggled_function,
205 void *data,
206 DBusFreeFunction free_data_function),
207 (connection, add_function, remove_function, toggled_function, data, free_data_function), return)
208DEFINEFUNC(dbus_bool_t , dbus_connection_set_watch_functions, (DBusConnection *connection,
209 DBusAddWatchFunction add_function,
210 DBusRemoveWatchFunction remove_function,
211 DBusWatchToggledFunction toggled_function,
212 void *data,
213 DBusFreeFunction free_data_function),
214 (connection, add_function, remove_function, toggled_function, data, free_data_function), return)
215DEFINEFUNC(void , dbus_connection_set_wakeup_main_function, (DBusConnection *connection,
216 DBusWakeupMainFunction wakeup_main_function,
217 void *data,
218 DBusFreeFunction free_data_function),
219 (connection, wakeup_main_function, data, free_data_function), )
220DEFINEFUNC(void , dbus_connection_set_dispatch_status_function, (DBusConnection *connection,
221 DBusDispatchStatusFunction function,
222 void *data,
223 DBusFreeFunction free_data_function),
224 (connection, function, data, free_data_function), )
225
226DEFINEFUNC(void , dbus_connection_unref, (DBusConnection *connection),
227 (connection), )
228DEFINEFUNC(dbus_bool_t , dbus_timeout_get_enabled, (DBusTimeout *timeout),
229 (timeout), return)
230DEFINEFUNC(int , dbus_timeout_get_interval, (DBusTimeout *timeout),
231 (timeout), return)
232DEFINEFUNC(dbus_bool_t , dbus_timeout_handle, (DBusTimeout *timeout),
233 (timeout), return)
234
235DEFINEFUNC(dbus_bool_t , dbus_watch_get_enabled, (DBusWatch *watch),
236 (watch), return)
237DEFINEFUNC(int , dbus_watch_get_unix_fd, (DBusWatch *watch),
238 (watch), return)
239DEFINEFUNC(unsigned int , dbus_watch_get_flags, (DBusWatch *watch),
240 (watch), return)
241DEFINEFUNC(dbus_bool_t , dbus_watch_handle, (DBusWatch *watch,
242 unsigned int flags),
243 (watch, flags), return)
244DEFINEFUNC(void , dbus_connection_set_allow_anonymous, (DBusConnection *connection,
245 dbus_bool_t value),
246 (connection, value), return)
247
248/* dbus-errors.h */
249DEFINEFUNC(void , dbus_error_free, (DBusError *error),
250 (error), )
251DEFINEFUNC(void , dbus_error_init, (DBusError *error),
252 (error), )
253DEFINEFUNC(dbus_bool_t , dbus_error_is_set, (const DBusError *error),
254 (error), return)
255
256/* dbus-memory.h */
257DEFINEFUNC(void , dbus_free, (void *memory), (memory), )
258
259/* dbus-message.h */
260DEFINEFUNC(DBusMessage* , dbus_message_copy, (const DBusMessage *message),
261 (message), return)
262DEFINEFUNC(dbus_bool_t , dbus_message_get_auto_start, (DBusMessage *message),
263 (message), return)
264DEFINEFUNC(const char* , dbus_message_get_error_name, (DBusMessage *message),
265 (message), return)
266DEFINEFUNC(const char* , dbus_message_get_interface, (DBusMessage *message),
267 (message), return)
268DEFINEFUNC(const char* , dbus_message_get_member, (DBusMessage *message),
269 (message), return)
270DEFINEFUNC(dbus_bool_t , dbus_message_get_no_reply, (DBusMessage *message),
271 (message), return)
272DEFINEFUNC(const char* , dbus_message_get_path, (DBusMessage *message),
273 (message), return)
274DEFINEFUNC(const char* , dbus_message_get_sender, (DBusMessage *message),
275 (message), return)
276DEFINEFUNC(dbus_uint32_t , dbus_message_get_serial, (DBusMessage *message),
277 (message), return)
278DEFINEFUNC(const char* , dbus_message_get_signature, (DBusMessage *message),
279 (message), return)
280DEFINEFUNC(int , dbus_message_get_type, (DBusMessage *message),
281 (message), return)
282
283#if !defined QT_LINKED_LIBDBUS
284
285DEFINEFUNC_CONDITIONALLY(dbus_bool_t , dbus_message_get_allow_interactive_authorization, (DBusMessage *message),
286 (message), return, return false)
287
288#else // defined QT_LINKED_LIBDBUS
289
290static inline dbus_bool_t q_dbus_message_get_allow_interactive_authorization(DBusMessage *message)
291{
292#ifdef DBUS_HEADER_FLAG_ALLOW_INTERACTIVE_AUTHORIZATION
293 return dbus_message_get_allow_interactive_authorization(message);
294#else
295 Q_UNUSED(message);
296 return false;
297#endif
298}
299
300#endif // defined QT_LINKED_LIBDBUS
301
302DEFINEFUNC(dbus_bool_t , dbus_message_iter_append_basic, (DBusMessageIter *iter,
303 int type,
304 const void *value),
305 (iter, type, value), return)
306DEFINEFUNC(dbus_bool_t , dbus_message_iter_append_fixed_array, (DBusMessageIter *iter,
307 int element_type,
308 const void *value,
309 int n_elements),
310 (iter, element_type, value, n_elements), return)
311DEFINEFUNC(dbus_bool_t , dbus_message_iter_close_container, (DBusMessageIter *iter,
312 DBusMessageIter *sub),
313 (iter, sub), return)
314DEFINEFUNC(int , dbus_message_iter_get_arg_type, (DBusMessageIter *iter),
315 (iter), return)
316DEFINEFUNC(void , dbus_message_iter_get_basic, (DBusMessageIter *iter,
317 void *value),
318 (iter, value), )
319DEFINEFUNC(int , dbus_message_iter_get_element_type, (DBusMessageIter *iter),
320 (iter), return)
321DEFINEFUNC(void , dbus_message_iter_get_fixed_array, (DBusMessageIter *iter,
322 void *value,
323 int *n_elements),
324 (iter, value, n_elements), return)
325DEFINEFUNC(char* , dbus_message_iter_get_signature, (DBusMessageIter *iter),
326 (iter), return)
327DEFINEFUNC(dbus_bool_t , dbus_message_iter_init, (DBusMessage *message,
328 DBusMessageIter *iter),
329 (message, iter), return)
330DEFINEFUNC(void , dbus_message_iter_init_append, (DBusMessage *message,
331 DBusMessageIter *iter),
332 (message, iter), return)
333DEFINEFUNC(dbus_bool_t , dbus_message_iter_next, (DBusMessageIter *iter),
334 (iter), return)
335DEFINEFUNC(dbus_bool_t , dbus_message_iter_open_container, (DBusMessageIter *iter,
336 int type,
337 const char *contained_signature,
338 DBusMessageIter *sub),
339 (iter, type, contained_signature, sub), return)
340DEFINEFUNC(void , dbus_message_iter_recurse, (DBusMessageIter *iter,
341 DBusMessageIter *sub),
342 (iter, sub), )
343DEFINEFUNC(DBusMessage* , dbus_message_new, (int message_type),
344 (message_type), return)
345DEFINEFUNC(DBusMessage* , dbus_message_new_method_call, (const char *bus_name,
346 const char *path,
347 const char *interface,
348 const char *method),
349 (bus_name, path, interface, method), return)
350DEFINEFUNC(DBusMessage* , dbus_message_new_signal, (const char *path,
351 const char *interface,
352 const char *name),
353 (path, interface, name), return)
354DEFINEFUNC(DBusMessage* , dbus_message_ref, (DBusMessage *message),
355 (message), return)
356DEFINEFUNC(void , dbus_message_set_auto_start, (DBusMessage *message,
357 dbus_bool_t auto_start),
358 (message, auto_start), return)
359DEFINEFUNC(dbus_bool_t , dbus_message_set_destination, (DBusMessage *message,
360 const char *destination),
361 (message, destination), return)
362DEFINEFUNC(dbus_bool_t , dbus_message_set_error_name, (DBusMessage *message,
363 const char *name),
364 (message, name), return)
365DEFINEFUNC(void , dbus_message_set_no_reply, (DBusMessage *message,
366 dbus_bool_t no_reply),
367 (message, no_reply), return)
368DEFINEFUNC(dbus_bool_t , dbus_message_set_path, (DBusMessage *message,
369 const char *object_path),
370 (message, object_path), return)
371DEFINEFUNC(dbus_bool_t , dbus_message_set_reply_serial, (DBusMessage *message,
372 dbus_uint32_t reply_serial),
373 (message, reply_serial), return)
374DEFINEFUNC(dbus_bool_t , dbus_message_set_sender, (DBusMessage *message,
375 const char *sender),
376 (message, sender), return)
377DEFINEFUNC(void , dbus_message_unref, (DBusMessage *message),
378 (message), )
379
380#if !defined QT_LINKED_LIBDBUS
381
382DEFINEFUNC_CONDITIONALLY(void, dbus_message_set_allow_interactive_authorization,
383 (DBusMessage *message, dbus_bool_t allow), (message, allow), return, return)
384
385
386#else // defined QT_LINKED_LIBDBUS
387
388static inline void q_dbus_message_set_allow_interactive_authorization(DBusMessage *message, dbus_bool_t allow)
389{
390#ifdef DBUS_HEADER_FLAG_ALLOW_INTERACTIVE_AUTHORIZATION
391 dbus_message_set_allow_interactive_authorization(message, allow);
392#else
393 Q_UNUSED(message);
394 Q_UNUSED(allow);
395#endif
396}
397
398#endif // defined QT_LINKED_LIBDBUS
399
400/* dbus-misc.h */
401DEFINEFUNC(char* , dbus_get_local_machine_id , (void), (), return)
402
403DEFINEFUNC(void , dbus_get_version , (int *major_version, int *minor_version, int *micro_version)
404 , (major_version, minor_version, micro_version)
405 , return)
406
407
408/* dbus-pending-call.h */
409DEFINEFUNC(dbus_bool_t , dbus_pending_call_set_notify, (DBusPendingCall *pending,
410 DBusPendingCallNotifyFunction function,
411 void *user_data,
412 DBusFreeFunction free_user_data),
413 (pending, function, user_data, free_user_data), return)
414DEFINEFUNC(void , dbus_pending_call_block, (DBusPendingCall *pending),
415 (pending), )
416DEFINEFUNC(void , dbus_pending_call_cancel, (DBusPendingCall *pending),
417 (pending), )
418DEFINEFUNC(dbus_bool_t , dbus_pending_call_get_completed, (DBusPendingCall *pending),
419 (pending), return)
420DEFINEFUNC(DBusMessage* , dbus_pending_call_steal_reply, (DBusPendingCall *pending),
421 (pending), return)
422DEFINEFUNC(void , dbus_pending_call_unref, (DBusPendingCall *pending),
423 (pending), return)
424
425/* dbus-server.h */
426DEFINEFUNC(dbus_bool_t , dbus_server_allocate_data_slot, (dbus_int32_t *slot_p),
427 (slot_p), return)
428DEFINEFUNC(void , dbus_server_free_data_slot, (dbus_int32_t *slot_p),
429 (slot_p), return)
430DEFINEFUNC(void , dbus_server_disconnect, (DBusServer *server),
431 (server), )
432DEFINEFUNC(char* , dbus_server_get_address, (DBusServer *server),
433 (server), return)
434DEFINEFUNC(dbus_bool_t , dbus_server_get_is_connected, (DBusServer *server),
435 (server), return)
436DEFINEFUNC(DBusServer* , dbus_server_listen, (const char *address,
437 DBusError *error),
438 (address, error), return)
439DEFINEFUNC(dbus_bool_t , dbus_server_set_data, (DBusServer *server,
440 int slot,
441 void *data,
442 DBusFreeFunction free_data_func),
443 (server, slot, data, free_data_func), return)
444DEFINEFUNC(void , dbus_server_set_new_connection_function, (DBusServer *server,
445 DBusNewConnectionFunction function,
446 void *data,
447 DBusFreeFunction free_data_function),
448 (server, function, data, free_data_function), )
449DEFINEFUNC(dbus_bool_t , dbus_server_set_timeout_functions, (DBusServer *server,
450 DBusAddTimeoutFunction add_function,
451 DBusRemoveTimeoutFunction remove_function,
452 DBusTimeoutToggledFunction toggled_function,
453 void *data,
454 DBusFreeFunction free_data_function),
455 (server, add_function, remove_function, toggled_function, data, free_data_function), return)
456DEFINEFUNC(dbus_bool_t , dbus_server_set_watch_functions, (DBusServer *server,
457 DBusAddWatchFunction add_function,
458 DBusRemoveWatchFunction remove_function,
459 DBusWatchToggledFunction toggled_function,
460 void *data,
461 DBusFreeFunction free_data_function),
462 (server, add_function, remove_function, toggled_function, data, free_data_function), return)
463DEFINEFUNC(void , dbus_server_unref, (DBusServer *server),
464 (server), )
465
466/* dbus-thread.h */
467DEFINEFUNC(dbus_bool_t , dbus_threads_init_default, (), (), return)
468
469QT_END_NAMESPACE
470
471#endif // QT_NO_DBUS
472#endif // QDBUS_SYMBOLS_P_H
473

source code of qtbase/src/dbus/qdbus_symbols_p.h