mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Use sdbus-c++ glue proxies for device info.
This commit is contained in:
@@ -7,49 +7,64 @@
|
||||
|
||||
#include <sdbus-c++/IConnection.h>
|
||||
#include <sdbus-c++/IProxy.h>
|
||||
#include <systemd/sd-login.h>
|
||||
|
||||
#include "internal/platform/implementation/device_info.h"
|
||||
#include "internal/platform/implementation/linux/dbus.h"
|
||||
#include "internal/platform/implementation/linux/device_info.h"
|
||||
#include "internal/platform/logging.h"
|
||||
#include "absl/synchronization/mutex.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace linux {
|
||||
void CurrentUserSession::RegisterScreenLockedListener(
|
||||
absl::string_view listener_name,
|
||||
std::function<void(api::DeviceInfo::ScreenStatus)> callback) {
|
||||
absl::MutexLock l(&screen_lock_listeners_mutex_);
|
||||
screen_lock_listeners_[listener_name] = callback;
|
||||
}
|
||||
|
||||
const char *HOSTNAME_DEST = "org.freedesktop.hostname1";
|
||||
const char *HOSTNAME_PATH = "/org/freedesktop/hostname1";
|
||||
const char *HOSTNAME_INTERFACE = "org.freedesktop.hostname1";
|
||||
void
|
||||
CurrentUserSession::UnregisterScreenLockedListener(absl::string_view listener_name)
|
||||
{
|
||||
absl::MutexLock l(&screen_lock_listeners_mutex_);
|
||||
screen_lock_listeners_.erase(listener_name);
|
||||
}
|
||||
|
||||
const char *LOGIN_DEST = "org.freedesktop.login1";
|
||||
const char *LOGIN_PATH = "/org/freedesktop/login1/session/_";
|
||||
const char *LOGIN_INTERFACE = "org.freedesktop.login1.Session";
|
||||
void CurrentUserSession::onLock() {
|
||||
absl::ReaderMutexLock l(&screen_lock_listeners_mutex_);
|
||||
for (auto &[_, callback] : screen_lock_listeners_) {
|
||||
callback(api::DeviceInfo::ScreenStatus::kLocked);
|
||||
}
|
||||
}
|
||||
|
||||
DeviceInfo::DeviceInfo(sdbus::IConnection &system_bus) {
|
||||
hostname_proxy_ =
|
||||
sdbus::createProxy(system_bus, HOSTNAME_DEST, HOSTNAME_PATH);
|
||||
hostname_proxy_->finishRegistration();
|
||||
login_proxy_ = sdbus::createProxy(system_bus, LOGIN_PATH, LOGIN_PATH);
|
||||
login_proxy_->finishRegistration();
|
||||
void CurrentUserSession::onUnlock() {
|
||||
absl::ReaderMutexLock l(&screen_lock_listeners_mutex_);
|
||||
for (auto &[_, callback] : screen_lock_listeners_) {
|
||||
callback(api::DeviceInfo::ScreenStatus::kUnlocked);
|
||||
}
|
||||
}
|
||||
|
||||
DeviceInfo::DeviceInfo(sdbus::IConnection &system_bus)
|
||||
: system_bus_(system_bus),
|
||||
current_user_session_(std::make_unique<CurrentUserSession>(system_bus_)) {
|
||||
}
|
||||
|
||||
std::optional<std::u16string> DeviceInfo::GetOsDeviceName() const {
|
||||
Hostnamed hostnamed(system_bus_);
|
||||
try {
|
||||
std::string hostname = hostname_proxy_->getProperty("PrettyHostname")
|
||||
.onInterface(HOSTNAME_INTERFACE);
|
||||
std::string hostname = hostnamed.PrettyHostname();
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
|
||||
return convert.from_bytes(hostname);
|
||||
} catch (const sdbus::Error &e) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << "Got error '" << e.getName()
|
||||
<< "' with message '" << e.getMessage()
|
||||
<< "' while trying to get PrettyHostname";
|
||||
DBUS_LOG_PROPERTY_GET_ERROR(&hostnamed, "PrettyHostname", e);
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
api::DeviceInfo::DeviceType DeviceInfo::GetDeviceType() const {
|
||||
Hostnamed hostnamed(system_bus_);
|
||||
try {
|
||||
std::string chasis = hostname_proxy_->getProperty("Chasis")
|
||||
.onInterface(HOSTNAME_INTERFACE);
|
||||
std::string chasis = hostnamed.Chassis();
|
||||
api::DeviceInfo::DeviceType device = api::DeviceInfo::DeviceType::kUnknown;
|
||||
if (chasis == "phone") {
|
||||
device = api::DeviceInfo::DeviceType::kPhone;
|
||||
@@ -62,9 +77,7 @@ api::DeviceInfo::DeviceType DeviceInfo::GetDeviceType() const {
|
||||
}
|
||||
return device;
|
||||
} catch (const sdbus::Error &e) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << "Got error '" << e.getName()
|
||||
<< "' with message '" << e.getMessage()
|
||||
<< "' while trying to get PrettyHostname";
|
||||
DBUS_LOG_PROPERTY_GET_ERROR(&hostnamed, "Chasis", e);
|
||||
return api::DeviceInfo::DeviceType::kUnknown;
|
||||
}
|
||||
}
|
||||
@@ -107,7 +120,7 @@ std::optional<std::filesystem::path> DeviceInfo::GetTemporaryPath() const {
|
||||
if (dir == NULL) {
|
||||
return std::filesystem::path("/tmp");
|
||||
}
|
||||
return std::filesystem::path(std::string(dir)) / "com.github.google.nearby";
|
||||
return std::filesystem::path(std::string(dir)) / "Google Nearby";
|
||||
}
|
||||
|
||||
std::optional<std::filesystem::path> DeviceInfo::GetLogPath() const {
|
||||
@@ -115,7 +128,7 @@ std::optional<std::filesystem::path> DeviceInfo::GetLogPath() const {
|
||||
if (dir == NULL) {
|
||||
return std::filesystem::path("/tmp");
|
||||
}
|
||||
return std::filesystem::path(std::string(dir)) / "com.github.google.nearby" /
|
||||
return std::filesystem::path(std::string(dir)) / "Google Nearby" /
|
||||
"logs";
|
||||
}
|
||||
|
||||
@@ -124,31 +137,15 @@ std::optional<std::filesystem::path> DeviceInfo::GetCrashDumpPath() const {
|
||||
if (dir == NULL) {
|
||||
return std::filesystem::path("/tmp");
|
||||
}
|
||||
return std::filesystem::path(std::string(dir)) / "com.github.google.nearby" /
|
||||
return std::filesystem::path(std::string(dir)) / "Google Nearby" /
|
||||
"crashes";
|
||||
}
|
||||
|
||||
bool DeviceInfo::IsScreenLocked() const {
|
||||
char *session = nullptr;
|
||||
if (sd_pid_get_session(getpid(), &session) < 0) {
|
||||
NEARBY_LOGS(ERROR) << __func__
|
||||
<< ": Error getting session for current user";
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string session_path(LOGIN_PATH);
|
||||
session_path += session;
|
||||
free(session);
|
||||
|
||||
try {
|
||||
bool locked =
|
||||
login_proxy_->getProperty("LockedHint").onInterface(LOGIN_INTERFACE);
|
||||
return locked;
|
||||
return current_user_session_->LockedHint();
|
||||
} catch (const sdbus::Error &e) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Got error '" << e.getName()
|
||||
<< "' with message '" << e.getMessage()
|
||||
<< "' while trying to get LockedHint for session "
|
||||
<< session_path;
|
||||
DBUS_LOG_PROPERTY_GET_ERROR(current_user_session_, "LockedHint", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,66 @@
|
||||
#define PLATFORM_IMPL_LINUX_DEVICE_INFO_H_
|
||||
|
||||
#include <optional>
|
||||
#include <sdbus-c++/ProxyInterfaces.h>
|
||||
#include <string>
|
||||
|
||||
#include <sdbus-c++/IConnection.h>
|
||||
#include <sdbus-c++/IProxy.h>
|
||||
|
||||
#include "absl/container/flat_hash_map.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/synchronization/mutex.h"
|
||||
#include "internal/platform/implementation/device_info.h"
|
||||
#include "internal/platform/implementation/linux/hostname_client_glue.h"
|
||||
#include "internal/platform/implementation/linux/login_session_client_glue.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace linux {
|
||||
|
||||
class CurrentUserSession
|
||||
: public sdbus::ProxyInterfaces<org::freedesktop::login1::Session_proxy> {
|
||||
public:
|
||||
CurrentUserSession(sdbus::IConnection &system_bus)
|
||||
: ProxyInterfaces(system_bus, "org.freedesktop.login1",
|
||||
"/org/freedesktop/login1/session/auto") {
|
||||
registerProxy();
|
||||
}
|
||||
~CurrentUserSession() { unregisterProxy(); }
|
||||
|
||||
void RegisterScreenLockedListener(
|
||||
absl::string_view listener_name,
|
||||
std::function<void(api::DeviceInfo::ScreenStatus)> callback)
|
||||
ABSL_LOCKS_EXCLUDED(screen_lock_listeners_mutex_);
|
||||
void UnregisterScreenLockedListener(absl::string_view listener_name)
|
||||
ABSL_LOCKS_EXCLUDED(screen_lock_listeners_mutex_);
|
||||
|
||||
protected:
|
||||
void onPauseDevice(const uint32_t &major, const uint32_t &minor,
|
||||
const std::string &type) override {}
|
||||
void onResumeDevice(const uint32_t &major, const uint32_t &minor,
|
||||
const sdbus::UnixFd &fd) override {}
|
||||
|
||||
void onLock() override ABSL_LOCKS_EXCLUDED(screen_lock_listeners_mutex_);
|
||||
void onUnlock() override ABSL_LOCKS_EXCLUDED(screen_lock_listeners_mutex_);
|
||||
|
||||
private:
|
||||
absl::Mutex screen_lock_listeners_mutex_;
|
||||
absl::flat_hash_map<std::string,
|
||||
std::function<void(api::DeviceInfo::ScreenStatus)>>
|
||||
screen_lock_listeners_ ABSL_GUARDED_BY(screen_lock_listeners_mutex_);
|
||||
};
|
||||
|
||||
class Hostnamed
|
||||
: public sdbus::ProxyInterfaces<org::freedesktop::hostname1_proxy> {
|
||||
public:
|
||||
Hostnamed(sdbus::IConnection &system_bus)
|
||||
: ProxyInterfaces(system_bus, "org.freedesktop.hostname1",
|
||||
"/org/freedesktop/hostname1") {
|
||||
registerProxy();
|
||||
}
|
||||
~Hostnamed() { unregisterProxy(); }
|
||||
};
|
||||
|
||||
class DeviceInfo : public api::DeviceInfo {
|
||||
public:
|
||||
DeviceInfo(sdbus::IConnection &system_bus);
|
||||
@@ -50,8 +99,8 @@ public:
|
||||
UnregisterScreenLockedListener(absl::string_view listener_name) override{};
|
||||
|
||||
private:
|
||||
std::unique_ptr<sdbus::IProxy> hostname_proxy_;
|
||||
std::unique_ptr<sdbus::IProxy> login_proxy_;
|
||||
sdbus::IConnection &system_bus_;
|
||||
std::unique_ptr<CurrentUserSession> current_user_session_;
|
||||
};
|
||||
} // namespace linux
|
||||
} // namespace nearby
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
|
||||
/*
|
||||
* This file was automatically generated by sdbus-c++-xml2cpp; DO NOT EDIT!
|
||||
*/
|
||||
|
||||
#ifndef __sdbuscpp__hostname_client_glue_h__proxy__H__
|
||||
#define __sdbuscpp__hostname_client_glue_h__proxy__H__
|
||||
|
||||
#include <sdbus-c++/sdbus-c++.h>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
namespace org {
|
||||
namespace freedesktop {
|
||||
|
||||
class hostname1_proxy
|
||||
{
|
||||
public:
|
||||
static constexpr const char* INTERFACE_NAME = "org.freedesktop.hostname1";
|
||||
|
||||
protected:
|
||||
hostname1_proxy(sdbus::IProxy& proxy)
|
||||
: proxy_(proxy)
|
||||
{
|
||||
}
|
||||
|
||||
~hostname1_proxy() = default;
|
||||
|
||||
public:
|
||||
void SetHostname(const std::string& hostname, const bool& interactive)
|
||||
{
|
||||
proxy_.callMethod("SetHostname").onInterface(INTERFACE_NAME).withArguments(hostname, interactive);
|
||||
}
|
||||
|
||||
void SetStaticHostname(const std::string& hostname, const bool& interactive)
|
||||
{
|
||||
proxy_.callMethod("SetStaticHostname").onInterface(INTERFACE_NAME).withArguments(hostname, interactive);
|
||||
}
|
||||
|
||||
void SetPrettyHostname(const std::string& hostname, const bool& interactive)
|
||||
{
|
||||
proxy_.callMethod("SetPrettyHostname").onInterface(INTERFACE_NAME).withArguments(hostname, interactive);
|
||||
}
|
||||
|
||||
void SetIconName(const std::string& icon, const bool& interactive)
|
||||
{
|
||||
proxy_.callMethod("SetIconName").onInterface(INTERFACE_NAME).withArguments(icon, interactive);
|
||||
}
|
||||
|
||||
void SetChassis(const std::string& chassis, const bool& interactive)
|
||||
{
|
||||
proxy_.callMethod("SetChassis").onInterface(INTERFACE_NAME).withArguments(chassis, interactive);
|
||||
}
|
||||
|
||||
void SetDeployment(const std::string& deployment, const bool& interactive)
|
||||
{
|
||||
proxy_.callMethod("SetDeployment").onInterface(INTERFACE_NAME).withArguments(deployment, interactive);
|
||||
}
|
||||
|
||||
void SetLocation(const std::string& location, const bool& interactive)
|
||||
{
|
||||
proxy_.callMethod("SetLocation").onInterface(INTERFACE_NAME).withArguments(location, interactive);
|
||||
}
|
||||
|
||||
std::vector<uint8_t> GetProductUUID(const bool& interactive)
|
||||
{
|
||||
std::vector<uint8_t> result;
|
||||
proxy_.callMethod("GetProductUUID").onInterface(INTERFACE_NAME).withArguments(interactive).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string GetHardwareSerial()
|
||||
{
|
||||
std::string result;
|
||||
proxy_.callMethod("GetHardwareSerial").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string Describe()
|
||||
{
|
||||
std::string result;
|
||||
proxy_.callMethod("Describe").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public:
|
||||
std::string Hostname()
|
||||
{
|
||||
return proxy_.getProperty("Hostname").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string StaticHostname()
|
||||
{
|
||||
return proxy_.getProperty("StaticHostname").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string PrettyHostname()
|
||||
{
|
||||
return proxy_.getProperty("PrettyHostname").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string DefaultHostname()
|
||||
{
|
||||
return proxy_.getProperty("DefaultHostname").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string HostnameSource()
|
||||
{
|
||||
return proxy_.getProperty("HostnameSource").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string IconName()
|
||||
{
|
||||
return proxy_.getProperty("IconName").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string Chassis()
|
||||
{
|
||||
return proxy_.getProperty("Chassis").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string Deployment()
|
||||
{
|
||||
return proxy_.getProperty("Deployment").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string Location()
|
||||
{
|
||||
return proxy_.getProperty("Location").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string KernelName()
|
||||
{
|
||||
return proxy_.getProperty("KernelName").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string KernelRelease()
|
||||
{
|
||||
return proxy_.getProperty("KernelRelease").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string KernelVersion()
|
||||
{
|
||||
return proxy_.getProperty("KernelVersion").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string OperatingSystemPrettyName()
|
||||
{
|
||||
return proxy_.getProperty("OperatingSystemPrettyName").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string OperatingSystemCPEName()
|
||||
{
|
||||
return proxy_.getProperty("OperatingSystemCPEName").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
uint64_t OperatingSystemSupportEnd()
|
||||
{
|
||||
return proxy_.getProperty("OperatingSystemSupportEnd").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string HomeURL()
|
||||
{
|
||||
return proxy_.getProperty("HomeURL").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string HardwareVendor()
|
||||
{
|
||||
return proxy_.getProperty("HardwareVendor").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string HardwareModel()
|
||||
{
|
||||
return proxy_.getProperty("HardwareModel").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string FirmwareVersion()
|
||||
{
|
||||
return proxy_.getProperty("FirmwareVersion").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string FirmwareVendor()
|
||||
{
|
||||
return proxy_.getProperty("FirmwareVendor").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
uint64_t FirmwareDate()
|
||||
{
|
||||
return proxy_.getProperty("FirmwareDate").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IProxy& proxy_;
|
||||
};
|
||||
|
||||
}} // namespaces
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,254 @@
|
||||
|
||||
/*
|
||||
* This file was automatically generated by sdbus-c++-xml2cpp; DO NOT EDIT!
|
||||
*/
|
||||
|
||||
#ifndef __sdbuscpp__login_session_client_glue_h__proxy__H__
|
||||
#define __sdbuscpp__login_session_client_glue_h__proxy__H__
|
||||
|
||||
#include <sdbus-c++/sdbus-c++.h>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
namespace org {
|
||||
namespace freedesktop {
|
||||
namespace login1 {
|
||||
|
||||
class Session_proxy
|
||||
{
|
||||
public:
|
||||
static constexpr const char* INTERFACE_NAME = "org.freedesktop.login1.Session";
|
||||
|
||||
protected:
|
||||
Session_proxy(sdbus::IProxy& proxy)
|
||||
: proxy_(proxy)
|
||||
{
|
||||
proxy_.uponSignal("PauseDevice").onInterface(INTERFACE_NAME).call([this](const uint32_t& major, const uint32_t& minor, const std::string& type){ this->onPauseDevice(major, minor, type); });
|
||||
proxy_.uponSignal("ResumeDevice").onInterface(INTERFACE_NAME).call([this](const uint32_t& major, const uint32_t& minor, const sdbus::UnixFd& fd){ this->onResumeDevice(major, minor, fd); });
|
||||
proxy_.uponSignal("Lock").onInterface(INTERFACE_NAME).call([this](){ this->onLock(); });
|
||||
proxy_.uponSignal("Unlock").onInterface(INTERFACE_NAME).call([this](){ this->onUnlock(); });
|
||||
}
|
||||
|
||||
~Session_proxy() = default;
|
||||
|
||||
virtual void onPauseDevice(const uint32_t& major, const uint32_t& minor, const std::string& type) = 0;
|
||||
virtual void onResumeDevice(const uint32_t& major, const uint32_t& minor, const sdbus::UnixFd& fd) = 0;
|
||||
virtual void onLock() = 0;
|
||||
virtual void onUnlock() = 0;
|
||||
|
||||
public:
|
||||
void Terminate()
|
||||
{
|
||||
proxy_.callMethod("Terminate").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
void Activate()
|
||||
{
|
||||
proxy_.callMethod("Activate").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
void Lock()
|
||||
{
|
||||
proxy_.callMethod("Lock").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
void Unlock()
|
||||
{
|
||||
proxy_.callMethod("Unlock").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
void SetIdleHint(const bool& idle)
|
||||
{
|
||||
proxy_.callMethod("SetIdleHint").onInterface(INTERFACE_NAME).withArguments(idle);
|
||||
}
|
||||
|
||||
void SetLockedHint(const bool& locked)
|
||||
{
|
||||
proxy_.callMethod("SetLockedHint").onInterface(INTERFACE_NAME).withArguments(locked);
|
||||
}
|
||||
|
||||
void Kill(const std::string& who, const int32_t& signal_number)
|
||||
{
|
||||
proxy_.callMethod("Kill").onInterface(INTERFACE_NAME).withArguments(who, signal_number);
|
||||
}
|
||||
|
||||
void TakeControl(const bool& force)
|
||||
{
|
||||
proxy_.callMethod("TakeControl").onInterface(INTERFACE_NAME).withArguments(force);
|
||||
}
|
||||
|
||||
void ReleaseControl()
|
||||
{
|
||||
proxy_.callMethod("ReleaseControl").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
void SetType(const std::string& type)
|
||||
{
|
||||
proxy_.callMethod("SetType").onInterface(INTERFACE_NAME).withArguments(type);
|
||||
}
|
||||
|
||||
void SetDisplay(const std::string& display)
|
||||
{
|
||||
proxy_.callMethod("SetDisplay").onInterface(INTERFACE_NAME).withArguments(display);
|
||||
}
|
||||
|
||||
void SetTTY(const sdbus::UnixFd& tty_fd)
|
||||
{
|
||||
proxy_.callMethod("SetTTY").onInterface(INTERFACE_NAME).withArguments(tty_fd);
|
||||
}
|
||||
|
||||
std::tuple<sdbus::UnixFd, bool> TakeDevice(const uint32_t& major, const uint32_t& minor)
|
||||
{
|
||||
std::tuple<sdbus::UnixFd, bool> result;
|
||||
proxy_.callMethod("TakeDevice").onInterface(INTERFACE_NAME).withArguments(major, minor).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void ReleaseDevice(const uint32_t& major, const uint32_t& minor)
|
||||
{
|
||||
proxy_.callMethod("ReleaseDevice").onInterface(INTERFACE_NAME).withArguments(major, minor);
|
||||
}
|
||||
|
||||
void PauseDeviceComplete(const uint32_t& major, const uint32_t& minor)
|
||||
{
|
||||
proxy_.callMethod("PauseDeviceComplete").onInterface(INTERFACE_NAME).withArguments(major, minor);
|
||||
}
|
||||
|
||||
void SetBrightness(const std::string& subsystem, const std::string& name, const uint32_t& brightness)
|
||||
{
|
||||
proxy_.callMethod("SetBrightness").onInterface(INTERFACE_NAME).withArguments(subsystem, name, brightness);
|
||||
}
|
||||
|
||||
public:
|
||||
std::string Id()
|
||||
{
|
||||
return proxy_.getProperty("Id").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
sdbus::Struct<uint32_t, sdbus::ObjectPath> User()
|
||||
{
|
||||
return proxy_.getProperty("User").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string Name()
|
||||
{
|
||||
return proxy_.getProperty("Name").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
uint64_t Timestamp()
|
||||
{
|
||||
return proxy_.getProperty("Timestamp").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
uint64_t TimestampMonotonic()
|
||||
{
|
||||
return proxy_.getProperty("TimestampMonotonic").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
uint32_t VTNr()
|
||||
{
|
||||
return proxy_.getProperty("VTNr").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
sdbus::Struct<std::string, sdbus::ObjectPath> Seat()
|
||||
{
|
||||
return proxy_.getProperty("Seat").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string TTY()
|
||||
{
|
||||
return proxy_.getProperty("TTY").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string Display()
|
||||
{
|
||||
return proxy_.getProperty("Display").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
bool Remote()
|
||||
{
|
||||
return proxy_.getProperty("Remote").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string RemoteHost()
|
||||
{
|
||||
return proxy_.getProperty("RemoteHost").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string RemoteUser()
|
||||
{
|
||||
return proxy_.getProperty("RemoteUser").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string Service()
|
||||
{
|
||||
return proxy_.getProperty("Service").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string Desktop()
|
||||
{
|
||||
return proxy_.getProperty("Desktop").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string Scope()
|
||||
{
|
||||
return proxy_.getProperty("Scope").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
uint32_t Leader()
|
||||
{
|
||||
return proxy_.getProperty("Leader").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
uint32_t Audit()
|
||||
{
|
||||
return proxy_.getProperty("Audit").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string Type()
|
||||
{
|
||||
return proxy_.getProperty("Type").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string Class()
|
||||
{
|
||||
return proxy_.getProperty("Class").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
bool Active()
|
||||
{
|
||||
return proxy_.getProperty("Active").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string State()
|
||||
{
|
||||
return proxy_.getProperty("State").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
bool IdleHint()
|
||||
{
|
||||
return proxy_.getProperty("IdleHint").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
uint64_t IdleSinceHint()
|
||||
{
|
||||
return proxy_.getProperty("IdleSinceHint").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
uint64_t IdleSinceHintMonotonic()
|
||||
{
|
||||
return proxy_.getProperty("IdleSinceHintMonotonic").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
bool LockedHint()
|
||||
{
|
||||
return proxy_.getProperty("LockedHint").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IProxy& proxy_;
|
||||
};
|
||||
|
||||
}}} // namespaces
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,86 @@
|
||||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
|
||||
"https://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||
<node>
|
||||
<interface name="org.freedesktop.hostname1">
|
||||
<property name="Hostname" type="s" access="read">
|
||||
</property>
|
||||
<property name="StaticHostname" type="s" access="read">
|
||||
</property>
|
||||
<property name="PrettyHostname" type="s" access="read">
|
||||
</property>
|
||||
<property name="DefaultHostname" type="s" access="read">
|
||||
</property>
|
||||
<property name="HostnameSource" type="s" access="read">
|
||||
</property>
|
||||
<property name="IconName" type="s" access="read">
|
||||
</property>
|
||||
<property name="Chassis" type="s" access="read">
|
||||
</property>
|
||||
<property name="Deployment" type="s" access="read">
|
||||
</property>
|
||||
<property name="Location" type="s" access="read">
|
||||
</property>
|
||||
<property name="KernelName" type="s" access="read">
|
||||
</property>
|
||||
<property name="KernelRelease" type="s" access="read">
|
||||
</property>
|
||||
<property name="KernelVersion" type="s" access="read">
|
||||
</property>
|
||||
<property name="OperatingSystemPrettyName" type="s" access="read">
|
||||
</property>
|
||||
<property name="OperatingSystemCPEName" type="s" access="read">
|
||||
</property>
|
||||
<property name="OperatingSystemSupportEnd" type="t" access="read">
|
||||
</property>
|
||||
<property name="HomeURL" type="s" access="read">
|
||||
</property>
|
||||
<property name="HardwareVendor" type="s" access="read">
|
||||
</property>
|
||||
<property name="HardwareModel" type="s" access="read">
|
||||
</property>
|
||||
<property name="FirmwareVersion" type="s" access="read">
|
||||
</property>
|
||||
<property name="FirmwareVendor" type="s" access="read">
|
||||
</property>
|
||||
<property name="FirmwareDate" type="t" access="read">
|
||||
</property>
|
||||
<method name="SetHostname">
|
||||
<arg type="s" name="hostname" direction="in"/>
|
||||
<arg type="b" name="interactive" direction="in"/>
|
||||
</method>
|
||||
<method name="SetStaticHostname">
|
||||
<arg type="s" name="hostname" direction="in"/>
|
||||
<arg type="b" name="interactive" direction="in"/>
|
||||
</method>
|
||||
<method name="SetPrettyHostname">
|
||||
<arg type="s" name="hostname" direction="in"/>
|
||||
<arg type="b" name="interactive" direction="in"/>
|
||||
</method>
|
||||
<method name="SetIconName">
|
||||
<arg type="s" name="icon" direction="in"/>
|
||||
<arg type="b" name="interactive" direction="in"/>
|
||||
</method>
|
||||
<method name="SetChassis">
|
||||
<arg type="s" name="chassis" direction="in"/>
|
||||
<arg type="b" name="interactive" direction="in"/>
|
||||
</method>
|
||||
<method name="SetDeployment">
|
||||
<arg type="s" name="deployment" direction="in"/>
|
||||
<arg type="b" name="interactive" direction="in"/>
|
||||
</method>
|
||||
<method name="SetLocation">
|
||||
<arg type="s" name="location" direction="in"/>
|
||||
<arg type="b" name="interactive" direction="in"/>
|
||||
</method>
|
||||
<method name="GetProductUUID">
|
||||
<arg type="b" name="interactive" direction="in"/>
|
||||
<arg type="ay" name="uuid" direction="out"/>
|
||||
</method>
|
||||
<method name="GetHardwareSerial">
|
||||
<arg type="s" name="serial" direction="out"/>
|
||||
</method>
|
||||
<method name="Describe">
|
||||
<arg type="s" name="json" direction="out"/>
|
||||
</method>
|
||||
</interface>
|
||||
</node>
|
||||
@@ -0,0 +1,121 @@
|
||||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
|
||||
"https://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||
<node>
|
||||
<interface name="org.freedesktop.login1.Session">
|
||||
<property name="Id" type="s" access="read">
|
||||
</property>
|
||||
<property name="User" type="(uo)" access="read">
|
||||
</property>
|
||||
<property name="Name" type="s" access="read">
|
||||
</property>
|
||||
<property name="Timestamp" type="t" access="read">
|
||||
</property>
|
||||
<property name="TimestampMonotonic" type="t" access="read">
|
||||
</property>
|
||||
<property name="VTNr" type="u" access="read">
|
||||
</property>
|
||||
<property name="Seat" type="(so)" access="read">
|
||||
</property>
|
||||
<property name="TTY" type="s" access="read">
|
||||
</property>
|
||||
<property name="Display" type="s" access="read">
|
||||
</property>
|
||||
<property name="Remote" type="b" access="read">
|
||||
</property>
|
||||
<property name="RemoteHost" type="s" access="read">
|
||||
</property>
|
||||
<property name="RemoteUser" type="s" access="read">
|
||||
</property>
|
||||
<property name="Service" type="s" access="read">
|
||||
</property>
|
||||
<property name="Desktop" type="s" access="read">
|
||||
</property>
|
||||
<property name="Scope" type="s" access="read">
|
||||
</property>
|
||||
<property name="Leader" type="u" access="read">
|
||||
</property>
|
||||
<property name="Audit" type="u" access="read">
|
||||
</property>
|
||||
<property name="Type" type="s" access="read">
|
||||
</property>
|
||||
<property name="Class" type="s" access="read">
|
||||
</property>
|
||||
<property name="Active" type="b" access="read">
|
||||
</property>
|
||||
<property name="State" type="s" access="read">
|
||||
</property>
|
||||
<property name="IdleHint" type="b" access="read">
|
||||
</property>
|
||||
<property name="IdleSinceHint" type="t" access="read">
|
||||
</property>
|
||||
<property name="IdleSinceHintMonotonic" type="t" access="read">
|
||||
</property>
|
||||
<property name="LockedHint" type="b" access="read">
|
||||
</property>
|
||||
<method name="Terminate">
|
||||
</method>
|
||||
<method name="Activate">
|
||||
</method>
|
||||
<method name="Lock">
|
||||
</method>
|
||||
<method name="Unlock">
|
||||
</method>
|
||||
<method name="SetIdleHint">
|
||||
<arg type="b" name="idle" direction="in"/>
|
||||
</method>
|
||||
<method name="SetLockedHint">
|
||||
<arg type="b" name="locked" direction="in"/>
|
||||
</method>
|
||||
<method name="Kill">
|
||||
<arg type="s" name="who" direction="in"/>
|
||||
<arg type="i" name="signal_number" direction="in"/>
|
||||
</method>
|
||||
<method name="TakeControl">
|
||||
<arg type="b" name="force" direction="in"/>
|
||||
</method>
|
||||
<method name="ReleaseControl">
|
||||
</method>
|
||||
<method name="SetType">
|
||||
<arg type="s" name="type" direction="in"/>
|
||||
</method>
|
||||
<method name="SetDisplay">
|
||||
<arg type="s" name="display" direction="in"/>
|
||||
</method>
|
||||
<method name="SetTTY">
|
||||
<arg type="h" name="tty_fd" direction="in"/>
|
||||
</method>
|
||||
<method name="TakeDevice">
|
||||
<arg type="u" name="major" direction="in"/>
|
||||
<arg type="u" name="minor" direction="in"/>
|
||||
<arg type="h" name="fd" direction="out"/>
|
||||
<arg type="b" name="inactive" direction="out"/>
|
||||
</method>
|
||||
<method name="ReleaseDevice">
|
||||
<arg type="u" name="major" direction="in"/>
|
||||
<arg type="u" name="minor" direction="in"/>
|
||||
</method>
|
||||
<method name="PauseDeviceComplete">
|
||||
<arg type="u" name="major" direction="in"/>
|
||||
<arg type="u" name="minor" direction="in"/>
|
||||
</method>
|
||||
<method name="SetBrightness">
|
||||
<arg type="s" name="subsystem" direction="in"/>
|
||||
<arg type="s" name="name" direction="in"/>
|
||||
<arg type="u" name="brightness" direction="in"/>
|
||||
</method>
|
||||
<signal name="PauseDevice">
|
||||
<arg type="u" name="major"/>
|
||||
<arg type="u" name="minor"/>
|
||||
<arg type="s" name="type"/>
|
||||
</signal>
|
||||
<signal name="ResumeDevice">
|
||||
<arg type="u" name="major"/>
|
||||
<arg type="u" name="minor"/>
|
||||
<arg type="h" name="fd"/>
|
||||
</signal>
|
||||
<signal name="Lock">
|
||||
</signal>
|
||||
<signal name="Unlock">
|
||||
</signal>
|
||||
</interface>
|
||||
</node>
|
||||
Reference in New Issue
Block a user