File indexing completed on 2024-03-24 04:59:47
0001 /** 0002 * SPDX-FileCopyrightText: 2013 Albert Vaca <albertvaka@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #pragma once 0008 0009 #include <core/kdeconnectplugin.h> 0010 0011 #define PACKET_TYPE_BATTERY QStringLiteral("kdeconnect.battery") 0012 0013 class BatteryPlugin : public KdeConnectPlugin 0014 { 0015 Q_OBJECT 0016 Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.battery") 0017 Q_PROPERTY(int charge READ charge NOTIFY refreshed) 0018 Q_PROPERTY(bool isCharging READ isCharging NOTIFY refreshed) 0019 0020 public: 0021 explicit BatteryPlugin(QObject *parent, const QVariantList &args); 0022 0023 void receivePacket(const NetworkPacket &np) override; 0024 void connected() override; 0025 QString dbusPath() const override; 0026 0027 int charge() const; 0028 bool isCharging() const; 0029 0030 Q_SIGNALS: 0031 Q_SCRIPTABLE void refreshed(bool isCharging, int charge); 0032 0033 private: 0034 void slotChargeChanged(); 0035 0036 // Keep these values in sync with THRESHOLD* constants in 0037 // kdeconnect-android:BatteryPlugin.java 0038 // see README for their meaning 0039 enum ThresholdBatteryEvent { ThresholdNone = 0, ThresholdBatteryLow = 1 }; 0040 0041 int m_charge = -1; 0042 bool m_isCharging = false; 0043 };