neighbor/udisks: move struct UdisksObject to UDisks2.hxx

This commit is contained in:
Max Kellermann
2018-06-04 17:08:04 +02:00
parent a92c694f1b
commit 640de5518b
2 changed files with 46 additions and 38 deletions

View File

@@ -20,7 +20,38 @@
#ifndef UDISKS2_HXX
#define UDISKS2_HXX
#include <string>
#define UDISKS2_PATH "/org/freedesktop/UDisks2"
#define UDISKS2_INTERFACE "org.freedesktop.UDisks2"
namespace UDisks2 {
struct Object {
const std::string path;
std::string drive_id, block_id;
bool is_filesystem = false;
explicit Object(const char *_path) noexcept
:path(_path) {}
bool IsValid() const noexcept {
return is_filesystem &&
(!drive_id.empty() || !block_id.empty());
}
std::string GetUri() const noexcept {
if (!drive_id.empty())
return "udisks://" + drive_id;
else if (!block_id.empty())
return "udisks://" + block_id;
else
return {};
}
};
} // namespace UDisks2
#endif