lib/dbus/ObjectManager: use TypeTraits instead of CPP macro
This commit is contained in:
parent
d3793dfe5b
commit
aea6d354b7
|
@ -21,36 +21,29 @@
|
||||||
#define ODBUS_OBJECT_MANAGER_HXX
|
#define ODBUS_OBJECT_MANAGER_HXX
|
||||||
|
|
||||||
#include "ReadIter.hxx"
|
#include "ReadIter.hxx"
|
||||||
|
#include "Types.hxx"
|
||||||
|
|
||||||
#include <dbus/dbus.h>
|
#include <dbus/dbus.h>
|
||||||
|
|
||||||
#define DBUS_OM_INTERFACE "org.freedesktop.DBus.ObjectManager"
|
#define DBUS_OM_INTERFACE "org.freedesktop.DBus.ObjectManager"
|
||||||
|
|
||||||
#define DBUS_OM_PROPERTIES_SIGNATURE \
|
|
||||||
DBUS_TYPE_ARRAY_AS_STRING \
|
|
||||||
DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING \
|
|
||||||
DBUS_TYPE_STRING_AS_STRING \
|
|
||||||
DBUS_TYPE_VARIANT_AS_STRING \
|
|
||||||
DBUS_DICT_ENTRY_END_CHAR_AS_STRING
|
|
||||||
|
|
||||||
#define DBUS_OM_INTERFACES_SIGNATURE \
|
|
||||||
DBUS_TYPE_ARRAY_AS_STRING \
|
|
||||||
DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING \
|
|
||||||
DBUS_TYPE_STRING_AS_STRING \
|
|
||||||
DBUS_OM_PROPERTIES_SIGNATURE \
|
|
||||||
DBUS_DICT_ENTRY_END_CHAR_AS_STRING
|
|
||||||
|
|
||||||
#define DBUS_OM_INTERFACES_ADDED_SIGNATURE \
|
|
||||||
DBUS_TYPE_OBJECT_PATH_AS_STRING \
|
|
||||||
DBUS_OM_INTERFACES_SIGNATURE
|
|
||||||
|
|
||||||
#define DBUS_OM_INTERFACES_REMOVED_SIGNATURE \
|
|
||||||
DBUS_TYPE_OBJECT_PATH_AS_STRING \
|
|
||||||
DBUS_TYPE_ARRAY_AS_STRING \
|
|
||||||
DBUS_TYPE_STRING_AS_STRING
|
|
||||||
|
|
||||||
namespace ODBus {
|
namespace ODBus {
|
||||||
|
|
||||||
|
using PropertiesType =
|
||||||
|
ArrayTypeTraits<DictEntryTypeTraits<StringTypeTraits,
|
||||||
|
VariantTypeTraits>>;
|
||||||
|
|
||||||
|
using InterfacesType =
|
||||||
|
ArrayTypeTraits<DictEntryTypeTraits<StringTypeTraits,
|
||||||
|
PropertiesType>>;
|
||||||
|
|
||||||
|
using InterfacesAddedType =
|
||||||
|
ConcatTypeAsString<ObjectPathTypeTraits,
|
||||||
|
InterfacesType>;
|
||||||
|
|
||||||
|
using InterfacesRemovedType = ConcatTypeAsString<ObjectPathTypeTraits,
|
||||||
|
ArrayTypeTraits<StringTypeTraits>>;
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
inline void
|
inline void
|
||||||
RecurseInterfaceDictEntry(ReadMessageIter &&i, F &&f)
|
RecurseInterfaceDictEntry(ReadMessageIter &&i, F &&f)
|
||||||
|
|
|
@ -353,7 +353,7 @@ UdisksNeighborExplorer::HandleMessage(DBusConnection *, DBusMessage *message) no
|
||||||
|
|
||||||
if (dbus_message_is_signal(message, DBUS_OM_INTERFACE,
|
if (dbus_message_is_signal(message, DBUS_OM_INTERFACE,
|
||||||
"InterfacesAdded") &&
|
"InterfacesAdded") &&
|
||||||
dbus_message_has_signature(message, DBUS_OM_INTERFACES_ADDED_SIGNATURE)) {
|
dbus_message_has_signature(message, InterfacesAddedType::value)) {
|
||||||
RecurseInterfaceDictEntry(ReadMessageIter(*message), [this](const char *path, auto &&i){
|
RecurseInterfaceDictEntry(ReadMessageIter(*message), [this](const char *path, auto &&i){
|
||||||
UdisksObject o(path);
|
UdisksObject o(path);
|
||||||
if (ParseObject(o, std::move(i)) && o.IsValid())
|
if (ParseObject(o, std::move(i)) && o.IsValid())
|
||||||
|
@ -363,7 +363,7 @@ UdisksNeighborExplorer::HandleMessage(DBusConnection *, DBusMessage *message) no
|
||||||
return DBUS_HANDLER_RESULT_HANDLED;
|
return DBUS_HANDLER_RESULT_HANDLED;
|
||||||
} else if (dbus_message_is_signal(message, DBUS_OM_INTERFACE,
|
} else if (dbus_message_is_signal(message, DBUS_OM_INTERFACE,
|
||||||
"InterfacesRemoved") &&
|
"InterfacesRemoved") &&
|
||||||
dbus_message_has_signature(message, DBUS_OM_INTERFACES_REMOVED_SIGNATURE)) {
|
dbus_message_has_signature(message, InterfacesRemovedType::value)) {
|
||||||
Remove(ReadMessageIter(*message).GetString());
|
Remove(ReadMessageIter(*message).GetString());
|
||||||
return DBUS_HANDLER_RESULT_HANDLED;
|
return DBUS_HANDLER_RESULT_HANDLED;
|
||||||
} else
|
} else
|
||||||
|
|
Loading…
Reference in New Issue