| 63 | }; |
| 64 | |
| 65 | LightSensorSubscription::LightSensorSubscription() |
| 66 | : m_sensorProperties(std::make_unique<OrgFreedesktopDBusPropertiesInterface>(serviceName(), objectPath(), QDBusConnection::systemBus())) |
| 67 | , m_sensorInterface(std::make_unique<NetHadessSensorProxyInterface>(serviceName(), objectPath(), QDBusConnection::systemBus())) |
| 68 | { |
| 69 | connect(m_sensorProperties.get(), &OrgFreedesktopDBusPropertiesInterface::PropertiesChanged, this, &LightSensorSubscription::onPropertiesChanged); |
| 70 | |
| 71 | intoFuture<void>(m_sensorInterface->ClaimLight()).then([](const std::expected<void, QDBusError> &result) { |
| 72 | if (!result) { |
| 73 | qCWarning(KWIN_CORE) << "net.hadess.SensorProxy.ClaimLight() failed:" << result.error(); |
| 74 | } |
| 75 | }); |
| 76 | |
| 77 | intoFuture<QVariant>(m_sensorProperties->Get(m_sensorInterface->interface(), QStringLiteral("LightLevelUnit"))).then(this, [this](const std::expected<QVariant, QDBusError> &result) { |
| 78 | if (result.has_value()) { |
| 79 | setUnit(result->toString()); |
| 80 | } else { |
| 81 | qCWarning(KWIN_CORE) << "Failed to fetch net.hadess.SensorProxy.LightLevelUnit property:" << result.error(); |
| 82 | } |
| 83 | }); |
| 84 | |
| 85 | intoFuture<QVariant>(m_sensorProperties->Get(m_sensorInterface->interface(), QStringLiteral("LightLevel"))).then(this, [this](const std::expected<QVariant, QDBusError> &result) { |
| 86 | if (result.has_value()) { |
| 87 | setReading(result->toDouble()); |
| 88 | } else { |
| 89 | qCWarning(KWIN_CORE) << "Failed to fetch net.hadess.SensorProxy.LightLevel property:" << result.error(); |
| 90 | } |
| 91 | }); |
| 92 | } |
| 93 | |
| 94 | LightSensorSubscription::~LightSensorSubscription() |
| 95 | { |
nothing calls this directly
no test coverage detected