File indexing completed on 2024-06-09 04:00:42

0001 /*
0002     SPDX-FileCopyrightText: 2010 Michael Zanetti <mzanetti@kde.org>
0003     SPDX-FileCopyrightText: 2010 Lukas Tinkl <ltinkl@redhat.com>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006 
0007 */
0008 
0009 #ifndef UPOWERDEVICE_H
0010 #define UPOWERDEVICE_H
0011 
0012 #include <ifaces/device.h>
0013 #include <solid/deviceinterface.h>
0014 
0015 namespace Solid
0016 {
0017 namespace Backends
0018 {
0019 namespace UPower
0020 {
0021 class UPowerDevice : public Solid::Ifaces::Device
0022 {
0023     Q_OBJECT
0024 public:
0025     UPowerDevice(const QString &udi);
0026     ~UPowerDevice() override;
0027 
0028     QObject *createDeviceInterface(const Solid::DeviceInterface::Type &type) override;
0029     bool queryDeviceInterface(const Solid::DeviceInterface::Type &type) const override;
0030     QString description() const override;
0031     QStringList emblems() const override;
0032     QString icon() const override;
0033     QString product() const override;
0034     QString vendor() const override;
0035     QString udi() const override;
0036     QString parentUdi() const override;
0037 
0038     QVariant prop(const QString &key) const;
0039     bool propertyExists(const QString &key) const;
0040     QMap<QString, QVariant> allProperties() const;
0041 
0042 Q_SIGNALS:
0043     void propertyChanged(const QMap<QString, int> &changes);
0044 
0045 private Q_SLOTS:
0046     void onPropertiesChanged(const QString &ifaceName, const QVariantMap &changedProps, const QStringList &invalidatedProps);
0047     void login1Resuming(bool active);
0048 
0049 private:
0050     QString batteryTechnology() const;
0051     QString m_udi;
0052     mutable QVariantMap m_cache;
0053     mutable QStringList m_negativeCache;
0054     mutable bool m_cacheComplete = false;
0055 
0056     void checkCache(const QString &key) const;
0057     void loadCache() const;
0058 };
0059 
0060 }
0061 }
0062 }
0063 
0064 #endif // UPOWERDEVICE_H