4 #ifndef SWIFT_SIM_XSWIFTBUS_DBUSSERVER_H
5 #define SWIFT_SIM_XSWIFTBUS_DBUSSERVER_H
8 #include <event2/event.h>
13 #include <unordered_map>
16 #include "dbuscallbacks.h"
17 #include "dbusdispatcher.h"
18 #include "dbuserror.h"
19 #include "dbusmessage.h"
42 bool listen(
const std::string &address);
59 void onNewConnection(DBusServer *server, DBusConnection *conn);
60 static void onNewConnection(DBusServer *server, DBusConnection *conn,
void *data);
62 struct DBusServerDeleter
64 void operator()(DBusServer *obj)
const { dbus_server_unref(obj); }
67 CDBusDispatcher *m_dispatcher =
nullptr;
68 std::unique_ptr<DBusServer, DBusServerDeleter> m_server;
69 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.