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

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