Add support for Unix fd D-Bus type

This commit is contained in:
sangelovic
2019-06-08 21:35:22 +02:00
committed by Stanislav Angelovič
parent efe799ef3f
commit 57c840637c
13 changed files with 125 additions and 2 deletions

View File

@@ -210,7 +210,15 @@ Message& Message::operator<<(const ObjectPath &item)
Message& Message::operator<<(const Signature &item)
{
auto r = sd_bus_message_append_basic((sd_bus_message*)msg_, SD_BUS_TYPE_SIGNATURE, item.c_str());
SDBUS_THROW_ERROR_IF(r < 0, "Failed to serialize an Signature value", -r);
SDBUS_THROW_ERROR_IF(r < 0, "Failed to serialize a Signature value", -r);
return *this;
}
Message& Message::operator<<(const UnixFd &item)
{
auto r = sd_bus_message_append_basic((sd_bus_message*)msg_, SD_BUS_TYPE_UNIX_FD, &item.fd_);
SDBUS_THROW_ERROR_IF(r < 0, "Failed to serialize a UnixFd value", -r);
return *this;
}
@@ -383,6 +391,17 @@ Message& Message::operator>>(Signature &item)
return *this;
}
Message& Message::operator>>(UnixFd &item)
{
auto r = sd_bus_message_read_basic((sd_bus_message*)msg_, SD_BUS_TYPE_UNIX_FD, &item.fd_);
if (r == 0)
ok_ = false;
SDBUS_THROW_ERROR_IF(r < 0, "Failed to deserialize a UnixFd value", -r);
return *this;
}
Message& Message::openContainer(const std::string& signature)
{