PipeWire  0.3.66
dbus.h
Go to the documentation of this file.
1 /* Simple Plugin API */
2 /* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3 /* SPDX-License-Identifier: MIT */
4 
5 #ifndef SPA_DBUS_H
6 #define SPA_DBUS_H
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 #include <spa/support/loop.h>
13 
23 #define SPA_TYPE_INTERFACE_DBus SPA_TYPE_INFO_INTERFACE_BASE "DBus"
24 
25 #define SPA_VERSION_DBUS 0
26 struct spa_dbus { struct spa_interface iface; };
27 
28 enum spa_dbus_type {
32 };
33 
34 #define SPA_DBUS_CONNECTION_EVENT_DESTROY 0
35 #define SPA_DBUS_CONNECTION_EVENT_DISCONNECTED 1
36 #define SPA_DBUS_CONNECTION_EVENT_NUM 2
37 
39 #define SPA_VERSION_DBUS_CONNECTION_EVENTS 0
40  uint32_t version;
41 
42  /* a connection is destroyed */
43  void (*destroy) (void *data);
44 
45  /* a connection disconnected */
46  void (*disconnected) (void *data);
47 };
48 
49 struct spa_dbus_connection {
50 #define SPA_VERSION_DBUS_CONNECTION 1
51  uint32_t version;
63  void *(*get) (struct spa_dbus_connection *conn);
69  void (*destroy) (struct spa_dbus_connection *conn);
70 
76  void (*add_listener) (struct spa_dbus_connection *conn,
77  struct spa_hook *listener,
78  const struct spa_dbus_connection_events *events,
79  void *data);
80 };
81 
82 #define spa_dbus_connection_call(c,method,vers,...) \
83 ({ \
84  if (SPA_LIKELY(SPA_CALLBACK_CHECK(c,method,vers))) \
85  c->method((c), ## __VA_ARGS__); \
86 })
87 
88 #define spa_dbus_connection_call_vp(c,method,vers,...) \
89 ({ \
90  void *_res = NULL; \
91  if (SPA_LIKELY(SPA_CALLBACK_CHECK(c,method,vers))) \
92  _res = c->method((c), ## __VA_ARGS__); \
93  _res; \
94 })
95 
98 #define spa_dbus_connection_get(c) spa_dbus_connection_call_vp(c,get,0)
101 #define spa_dbus_connection_destroy(c) spa_dbus_connection_call(c,destroy,0)
104 #define spa_dbus_connection_add_listener(c,...) spa_dbus_connection_call(c,add_listener,1,__VA_ARGS__)
105 
106 struct spa_dbus_methods {
107 #define SPA_VERSION_DBUS_METHODS 0
108  uint32_t version;
109 
122  struct spa_dbus_connection * (*get_connection) (void *object,
123  enum spa_dbus_type type);
124 };
125 
129 static inline struct spa_dbus_connection *
130 spa_dbus_get_connection(struct spa_dbus *dbus, enum spa_dbus_type type)
131 {
132  struct spa_dbus_connection *res = NULL;
134  struct spa_dbus_methods, res,
135  get_connection, 0, type);
136  return res;
137 }
138 
143 #ifdef __cplusplus
144 } /* extern "C" */
145 #endif
146 
147 #endif /* SPA_DBUS_H */
spa_dbus_type
Definition: dbus.h:35
static struct spa_dbus_connection * spa_dbus_get_connection(struct spa_dbus *dbus, enum spa_dbus_type type)
Get a new connection wrapper for the given bus type.
Definition: dbus.h:143
@ SPA_DBUS_TYPE_SESSION
The login session bus.
Definition: dbus.h:36
@ SPA_DBUS_TYPE_STARTER
The bus that started us, if any.
Definition: dbus.h:38
@ SPA_DBUS_TYPE_SYSTEM
The systemwide bus.
Definition: dbus.h:37
#define spa_interface_call_res(iface, method_type, res, method, vers,...)
Invoke method named method in the callbacks on the given interface object.
Definition: hook.h:235
spa/support/loop.h
Definition: dbus.h:48
void(* destroy)(void *data)
Definition: dbus.h:54
uint32_t version
Definition: dbus.h:51
void(* disconnected)(void *data)
Definition: dbus.h:57
Definition: dbus.h:60
void(* destroy)(struct spa_dbus_connection *conn)
Destroy a dbus connection wrapper.
Definition: dbus.h:81
void(* add_listener)(struct spa_dbus_connection *conn, struct spa_hook *listener, const struct spa_dbus_connection_events *events, void *data)
Add a listener for events.
Definition: dbus.h:88
Definition: dbus.h:118
uint32_t version
Definition: dbus.h:121
Definition: dbus.h:33
struct spa_interface iface
Definition: dbus.h:33
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:331
Definition: hook.h:138