Loading...
Searching...
No Matches
dbus.h
Go to the documentation of this file.
/* Simple Plugin API */
/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
/* SPDX-License-Identifier: MIT */
#ifndef SPA_DBUS_H
#define SPA_DBUS_H
#include <spa/support/loop.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SPA_API_DBUS
#ifdef SPA_API_IMPL
#define SPA_API_DBUS SPA_API_IMPL
#else
#define SPA_API_DBUS static inline
#endif
#endif
#define SPA_TYPE_INTERFACE_DBus SPA_TYPE_INFO_INTERFACE_BASE "DBus"
#define SPA_VERSION_DBUS 0
struct spa_dbus { struct spa_interface iface; };
enum spa_dbus_type {
SPA_DBUS_TYPE_SESSION,
SPA_DBUS_TYPE_SYSTEM,
SPA_DBUS_TYPE_STARTER
};
#define SPA_DBUS_CONNECTION_EVENT_DESTROY 0
#define SPA_DBUS_CONNECTION_EVENT_DISCONNECTED 1
#define SPA_DBUS_CONNECTION_EVENT_NUM 2
struct spa_dbus_connection_events {
#define SPA_VERSION_DBUS_CONNECTION_EVENTS 0
uint32_t version;
/* a connection is destroyed */
void (*destroy) (void *data);
/* a connection disconnected */
void (*disconnected) (void *data);
};
struct spa_dbus_connection {
#define SPA_VERSION_DBUS_CONNECTION 1
uint32_t version;
*/
void *(*get) (struct spa_dbus_connection *conn);
void (*destroy) (struct spa_dbus_connection *conn);
void (*add_listener) (struct spa_dbus_connection *conn,
struct spa_hook *listener,
const struct spa_dbus_connection_events *events,
void *data);
};
SPA_API_DBUS void *spa_dbus_connection_get(struct spa_dbus_connection *conn)
{
return spa_api_func_r(void *, NULL, conn, get, 0);
}
SPA_API_DBUS void spa_dbus_connection_destroy(struct spa_dbus_connection *conn)
{
spa_api_func_v(conn, destroy, 0);
}
SPA_API_DBUS void spa_dbus_connection_add_listener(struct spa_dbus_connection *conn,
struct spa_hook *listener,
const struct spa_dbus_connection_events *events,
void *data)
{
spa_api_func_v(conn, add_listener, 1, listener, events, data);
}
struct spa_dbus_methods {
#define SPA_VERSION_DBUS_METHODS 0
uint32_t version;
*
* The connection wrapper is completely configured to operate
* in the main context of the handle that manages the spa_dbus
* interface.
*
* \param dbus the dbus manager
* \param type the bus type to wrap
* \param error location for the DBusError
* \return a new dbus connection wrapper or NULL on error
*/
struct spa_dbus_connection * (*get_connection) (void *object,
enum spa_dbus_type type);
};
SPA_API_DBUS struct spa_dbus_connection *
spa_dbus_get_connection(struct spa_dbus *dbus, enum spa_dbus_type type)
{
return spa_api_method_r(struct spa_dbus_connection *, NULL,
spa_dbus, &dbus->iface, get_connection, 0, type);
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* SPA_DBUS_H */
SPA_API_DBUS
#define SPA_API_DBUS
Definition dbus.h:25
spa_dbus_type
spa_dbus_type
Definition dbus.h:45
spa_dbus_connection_destroy
SPA_API_DBUS void spa_dbus_connection_destroy(struct spa_dbus_connection *conn)
Destroy a dbus connection wrapper.
Definition dbus.h:112
spa_dbus_connection_get
SPA_API_DBUS void * spa_dbus_connection_get(struct spa_dbus_connection *conn)
Get the DBusConnection from a wrapper.
Definition dbus.h:106
spa_dbus_get_connection
SPA_API_DBUS 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:151
spa_dbus_connection_add_listener
SPA_API_DBUS void spa_dbus_connection_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:118
SPA_DBUS_TYPE_SESSION
@ SPA_DBUS_TYPE_SESSION
The login session bus.
Definition dbus.h:46
SPA_DBUS_TYPE_STARTER
@ SPA_DBUS_TYPE_STARTER
The bus that started us, if any.
Definition dbus.h:48
SPA_DBUS_TYPE_SYSTEM
@ SPA_DBUS_TYPE_SYSTEM
The systemwide bus.
Definition dbus.h:47
spa_api_func_v
#define spa_api_func_v(o, method, version,...)
Definition hook.h:268
spa_api_method_r
#define spa_api_method_r(rtype, def, type, o, method, version,...)
Definition hook.h:291
spa_api_func_r
#define spa_api_func_r(rtype, def, o, method, version,...)
Definition hook.h:273
loop.h
spa/support/loop.h
spa_dbus_connection_events
Definition dbus.h:58
spa_dbus_connection_events::destroy
void(* destroy)(void *data)
Definition dbus.h:64
spa_dbus_connection_events::version
uint32_t version
Definition dbus.h:61
spa_dbus_connection_events::disconnected
void(* disconnected)(void *data)
Definition dbus.h:67
spa_dbus_connection
Definition dbus.h:70
spa_dbus_connection::destroy
void(* destroy)(struct spa_dbus_connection *conn)
Destroy a dbus connection wrapper.
Definition dbus.h:91
spa_dbus_connection::add_listener
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:98
spa_dbus_connection::get
void *(* get)(struct spa_dbus_connection *conn)
Get the DBusConnection from a wrapper.
Definition dbus.h:85
spa_dbus_methods
Definition dbus.h:126
spa_dbus_methods::version
uint32_t version
Definition dbus.h:129
spa_dbus
Definition dbus.h:43
spa_dbus::iface
struct spa_interface iface
Definition dbus.h:43
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition hook.h:427
spa_interface
Definition hook.h:148