14 #include <type_traits> 16 #include <dbus/dbus.h> 22 template<>
struct ToDBusType<bool> {
static constexpr
int TYPE = DBUS_TYPE_BOOLEAN; };
23 template<>
struct ToDBusType<char*> {
static constexpr
int TYPE = DBUS_TYPE_STRING; };
24 template<>
struct ToDBusType<const char*> {
static constexpr
int TYPE = DBUS_TYPE_STRING; };
25 template<>
struct ToDBusType<
std::uint8_t> {
static constexpr
int TYPE = DBUS_TYPE_BYTE; };
26 template<>
struct ToDBusType<
std::int16_t> {
static constexpr
int TYPE = DBUS_TYPE_INT16; };
27 template<>
struct ToDBusType<
std::uint16_t> {
static constexpr
int TYPE = DBUS_TYPE_UINT16; };
28 template<>
struct ToDBusType<
std::int32_t> {
static constexpr
int TYPE = DBUS_TYPE_INT32; };
29 template<>
struct ToDBusType<
std::uint32_t> {
static constexpr
int TYPE = DBUS_TYPE_UINT32; };
30 template<>
struct ToDBusType<
std::int64_t> {
static constexpr
int TYPE = DBUS_TYPE_INT64; };
31 template<>
struct ToDBusType<
std::uint64_t> {
static constexpr
int TYPE = DBUS_TYPE_UINT64; };
32 template<>
struct ToDBusType<double> {
static constexpr
int TYPE = DBUS_TYPE_DOUBLE; };
39 void operator()(DBusMessage* message)
const;
41 using DBusMessagePtr = std::unique_ptr<DBusMessage, DBusMessageDeleter>;
46 CDBusMessage(
const char *destination,
const char *
object,
const char *interface,
const char *method);
47 CDBusMessage(std::string
const& destination, std::string
const&
object, std::string
const& interface, std::string
const& method);
49 void AppendObjectPath(
const char *
object);
52 void AppendArgument(
const T arg)
56 void AppendArgument(
const char **arrayString,
unsigned int length);
58 template<
typename TFirst>
59 void AppendArguments(
const TFirst first)
61 AppendArgument(first);
64 template<
typename TFirst,
typename... TArgs>
65 void AppendArguments(
const TFirst first,
const TArgs... args)
67 AppendArgument(first);
68 AppendArguments(args...);
71 DBusMessageIter * GetArgumentIter();
91 template<
typename... TArgs>
95 if (!InitializeReplyIter(&iter))
99 return GetReplyArgumentsWithIter(&iter, args...);
102 DBusMessage *SendSystem();
103 DBusMessage *SendSession();
107 bool SendAsyncSystem();
108 bool SendAsyncSession();
110 DBusMessage *Send(DBusBusType type);
111 DBusMessage *Send(DBusBusType type,
CDBusError& error);
112 DBusMessage *Send(DBusConnection *con,
CDBusError& error);
114 void AppendWithType(
int type,
const void* value);
115 bool SendAsync(DBusBusType type);
117 void PrepareArgument();
119 bool InitializeReplyIter(DBusMessageIter* iter);
120 bool CheckTypeAndGetValue(DBusMessageIter* iter,
int expectType,
void* dest);
121 template<
typename TFirst>
122 bool GetReplyArgumentsWithIter(DBusMessageIter* iter, TFirst* first)
127 template<
typename TFirst,
typename... TArgs>
128 bool GetReplyArgumentsWithIter(DBusMessageIter* iter, TFirst* first, TArgs*... args)
136 dbus_message_iter_next(iter);
137 return GetReplyArgumentsWithIter(iter, args...);
140 DBusMessagePtr m_message;
141 DBusMessagePtr m_reply =
nullptr;
142 DBusMessageIter m_args;
147 void CDBusMessage::AppendArgument<bool>(
const bool arg);
149 void CDBusMessage::AppendArgument<std::string>(
const std::string arg);
Definition: DBusMessage.h:21
Definition: DBusUtil.h:60
Definition: DBusMessage.h:37
bool GetReplyArguments(TArgs *... args)
Retrieve simple arguments from DBus reply message.
Definition: DBusMessage.h:92
Definition: DBusMessage.h:43