Merge branch 'bind' of git://github.com/neheb/MPD into master

This commit is contained in:
Max Kellermann 2020-11-10 16:02:34 +01:00
commit a9714e73c8
3 changed files with 17 additions and 20 deletions

View File

@ -120,19 +120,20 @@ static void
ParseInterface(Object &o, const char *interface, ParseInterface(Object &o, const char *interface,
ODBus::ReadMessageIter &&i) noexcept ODBus::ReadMessageIter &&i) noexcept
{ {
using namespace std::placeholders;
if (StringIsEqual(interface, "org.freedesktop.UDisks2.Drive")) { if (StringIsEqual(interface, "org.freedesktop.UDisks2.Drive")) {
i.ForEachProperty(std::bind(ParseDriveDictEntry, i.ForEachProperty([&](auto n, auto v) {
std::ref(o), _1, _2)); return ParseDriveDictEntry(o, n, std::move(v));
});
} else if (StringIsEqual(interface, "org.freedesktop.UDisks2.Block")) { } else if (StringIsEqual(interface, "org.freedesktop.UDisks2.Block")) {
i.ForEachProperty(std::bind(ParseBlockDictEntry, i.ForEachProperty([&](auto n, auto v) {
std::ref(o), _1, _2)); return ParseBlockDictEntry(o, n, std::move(v));
});
} else if (StringIsEqual(interface, "org.freedesktop.UDisks2.Filesystem")) { } else if (StringIsEqual(interface, "org.freedesktop.UDisks2.Filesystem")) {
o.is_filesystem = true; o.is_filesystem = true;
i.ForEachProperty(std::bind(ParseFileesystemDictEntry, i.ForEachProperty([&](auto n, auto v) {
std::ref(o), _1, _2)); return ParseFileesystemDictEntry(o, n, std::move(v));
});
} }
} }

View File

@ -128,9 +128,9 @@ UdisksNeighborExplorer::DoOpen()
UDISKS2_PATH, UDISKS2_PATH,
DBUS_OM_INTERFACE, DBUS_OM_INTERFACE,
"GetManagedObjects"); "GetManagedObjects");
list_request.Send(connection, *msg.Get(), list_request.Send(connection, *msg.Get(), [this](auto o) {
std::bind(&UdisksNeighborExplorer::OnListNotify, return OnListNotify(std::move(o));
this, std::placeholders::_1)); });
} catch (...) { } catch (...) {
dbus_connection_remove_filter(connection, dbus_connection_remove_filter(connection,
HandleMessage, HandleMessage,
@ -229,9 +229,8 @@ inline void
UdisksNeighborExplorer::OnListNotify(ODBus::Message reply) noexcept UdisksNeighborExplorer::OnListNotify(ODBus::Message reply) noexcept
{ {
try{ try{
ParseObjects(reply, UDisks2::ParseObjects(reply,
std::bind(&UdisksNeighborExplorer::Insert, [this](auto p) { return Insert(std::move(p)); });
this, std::placeholders::_1));
} catch (...) { } catch (...) {
LogError(std::current_exception(), LogError(std::current_exception(),
"Failed to parse GetManagedObjects reply"); "Failed to parse GetManagedObjects reply");

View File

@ -227,8 +227,7 @@ try {
DBUS_OM_INTERFACE, DBUS_OM_INTERFACE,
"GetManagedObjects"); "GetManagedObjects");
list_request.Send(connection, *msg.Get(), list_request.Send(connection, *msg.Get(),
std::bind(&UdisksStorage::OnListReply, [this](auto o) { return OnListReply(std::move(o)); });
this, std::placeholders::_1));
return; return;
} }
@ -239,8 +238,7 @@ try {
AppendMessageIter(*msg.Get()).AppendEmptyArray<DictEntryTypeTraits<StringTypeTraits, VariantTypeTraits>>(); AppendMessageIter(*msg.Get()).AppendEmptyArray<DictEntryTypeTraits<StringTypeTraits, VariantTypeTraits>>();
mount_request.Send(connection, *msg.Get(), mount_request.Send(connection, *msg.Get(),
std::bind(&UdisksStorage::OnMountNotify, [this](auto o) { return OnMountNotify(std::move(o)); });
this, std::placeholders::_1));
} catch (...) { } catch (...) {
const std::lock_guard<Mutex> lock(mutex); const std::lock_guard<Mutex> lock(mutex);
mount_error = std::current_exception(); mount_error = std::current_exception();
@ -297,8 +295,7 @@ try {
AppendMessageIter(*msg.Get()).AppendEmptyArray<DictEntryTypeTraits<StringTypeTraits, VariantTypeTraits>>(); AppendMessageIter(*msg.Get()).AppendEmptyArray<DictEntryTypeTraits<StringTypeTraits, VariantTypeTraits>>();
mount_request.Send(connection, *msg.Get(), mount_request.Send(connection, *msg.Get(),
std::bind(&UdisksStorage::OnUnmountNotify, [this](auto u) { return OnUnmountNotify(std::move(u)); });
this, std::placeholders::_1));
} catch (...) { } catch (...) {
const std::lock_guard<Mutex> lock(mutex); const std::lock_guard<Mutex> lock(mutex);
mount_error = std::current_exception(); mount_error = std::current_exception();