4 #ifndef SWIFT_SIM_XSWIFTBUS_DBUSSERVER_H
5 #define SWIFT_SIM_XSWIFTBUS_DBUSSERVER_H
11 #include <dbus/dbus.h>
12 #include <event2/event.h>
17 #include <unordered_map>
20 #include "dbuscallbacks.h"
21 #include "dbusdispatcher.h"
22 #include "dbuserror.h"
23 #include "dbusmessage.h"
46 bool listen(
const std::string &address);
63 void onNewConnection(DBusServer *server, DBusConnection *conn);
64 static void onNewConnection(DBusServer *server, DBusConnection *conn,
void *data);
66 struct DBusServerDeleter
68 void operator()(DBusServer *obj)
const { dbus_server_unref(obj); }
71 CDBusDispatcher *m_dispatcher =
nullptr;
72 std::unique_ptr<DBusServer, DBusServerDeleter> m_server;
73 CDBusError m_lastError;
CDBusError lastError() const
Get the last error.
void close()
Close connection.
virtual ~CDBusServer()
Destructor.
bool listen(const std::string &address)
Connect to bus.
std::function< void(std::shared_ptr< CDBusConnection >)> NewConnectionFunc
New connection handler function.
void dispatch()
Dispatch execution method.
void setNewConnectionFunc(const NewConnectionFunc &func)
Set the function to be used for handling new connections.
void setDispatcher(CDBusDispatcher *dispatcher)
Set the dispatcher.
CDBusServer()
Constructor.
bool isConnected() const
Is connected?
Plugin loaded by X-Plane which publishes a DBus service.