4 #include "dbusserver.h"
11 #include "dbusobject.h"
23 dbus_error_init(&error);
24 m_server.reset(dbus_server_listen(address.c_str(), &error));
28 ERROR_LOG(
"DBus failed to listen for new connections on given address: " + std::string(error.message));
31 dbus_server_set_new_connection_function(m_server.get(), onNewConnection,
this,
nullptr);
39 if (m_server) { dbus_server_disconnect(m_server.get()); }
47 m_dispatcher = dispatcher;
49 dbus_server_set_watch_functions(m_server.get(), dispatcher->m_watchCallbacks.add,
50 dispatcher->m_watchCallbacks.remove, dispatcher->m_watchCallbacks.toggled,
51 &dispatcher->m_watchCallbacks,
nullptr);
53 dbus_server_set_timeout_functions(m_server.get(), dispatcher->m_timeoutCallbacks.add,
54 dispatcher->m_timeoutCallbacks.remove, dispatcher->m_timeoutCallbacks.toggled,
55 &dispatcher->m_timeoutCallbacks,
nullptr);
58 void CDBusServer::onNewConnection(DBusServer *, DBusConnection *conn)
62 auto dbusConnection = std::make_shared<CDBusConnection>(conn);
63 m_newConnectionFunc(dbusConnection);
66 void CDBusServer::onNewConnection(DBusServer *server, DBusConnection *conn,
void *data)
69 obj->onNewConnection(server, conn);
void close()
Close connection.
virtual ~CDBusServer()
Destructor.
bool listen(const std::string &address)
Connect to bus.
void setDispatcher(CDBusDispatcher *dispatcher)
Set the dispatcher.
CDBusServer()
Constructor.
bool isConnected() const
Is connected?
Plugin loaded by X-Plane which publishes a DBus service.
#define ERROR_LOG(msg)
Logger convenience macros.
#define INFO_LOG(msg)
Logger convenience macros.