| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2006-2007 Kevin Ottens <ervin@kde.org> |
| 3 | SPDX-FileCopyrightText: 2012 Lukas Tinkl <ltinkl@redhat.com> |
| 4 | SPDX-FileCopyrightText: 2014 Kai Uwe Broulik <kde@privat.broulik.de> |
| 5 | |
| 6 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
| 7 | */ |
| 8 | |
| 9 | #include "battery.h" |
| 10 | #include "battery_p.h" |
| 11 | |
| 12 | #include "soliddefs_p.h" |
| 13 | #include <solid/devices/ifaces/battery.h> |
| 14 | |
| 15 | Solid::Battery::Battery(QObject *backendObject) |
| 16 | : DeviceInterface(*new BatteryPrivate(), backendObject) |
| 17 | { |
| 18 | connect(sender: backendObject, SIGNAL(presentStateChanged(bool, QString)), receiver: this, SIGNAL(presentStateChanged(bool, QString))); |
| 19 | |
| 20 | connect(sender: backendObject, SIGNAL(chargePercentChanged(int, QString)), receiver: this, SIGNAL(chargePercentChanged(int, QString))); |
| 21 | |
| 22 | connect(sender: backendObject, SIGNAL(capacityChanged(int, QString)), receiver: this, SIGNAL(capacityChanged(int, QString))); |
| 23 | |
| 24 | connect(sender: backendObject, SIGNAL(cycleCountChanged(int, QString)), receiver: this, SIGNAL(cycleCountChanged(int, QString))); |
| 25 | |
| 26 | connect(sender: backendObject, SIGNAL(powerSupplyStateChanged(bool, QString)), receiver: this, SIGNAL(powerSupplyStateChanged(bool, QString))); |
| 27 | |
| 28 | connect(sender: backendObject, SIGNAL(chargeStateChanged(int, QString)), receiver: this, SIGNAL(chargeStateChanged(int, QString))); |
| 29 | |
| 30 | connect(sender: backendObject, SIGNAL(timeToEmptyChanged(qlonglong, QString)), receiver: this, SIGNAL(timeToEmptyChanged(qlonglong, QString))); |
| 31 | |
| 32 | connect(sender: backendObject, SIGNAL(timeToFullChanged(qlonglong, QString)), receiver: this, SIGNAL(timeToFullChanged(qlonglong, QString))); |
| 33 | |
| 34 | connect(sender: backendObject, SIGNAL(energyChanged(double, QString)), receiver: this, SIGNAL(energyChanged(double, QString))); |
| 35 | |
| 36 | connect(sender: backendObject, SIGNAL(energyFullChanged(double, QString)), receiver: this, SIGNAL(energyFullChanged(double, QString))); |
| 37 | |
| 38 | connect(sender: backendObject, SIGNAL(energyFullDesignChanged(double, QString)), receiver: this, SIGNAL(energyFullDesignChanged(double, QString))); |
| 39 | |
| 40 | connect(sender: backendObject, SIGNAL(energyRateChanged(double, QString)), receiver: this, SIGNAL(energyRateChanged(double, QString))); |
| 41 | |
| 42 | connect(sender: backendObject, SIGNAL(voltageChanged(double, QString)), receiver: this, SIGNAL(voltageChanged(double, QString))); |
| 43 | |
| 44 | connect(sender: backendObject, SIGNAL(temperatureChanged(double, QString)), receiver: this, SIGNAL(temperatureChanged(double, QString))); |
| 45 | |
| 46 | connect(sender: backendObject, SIGNAL(remainingTimeChanged(qlonglong, QString)), receiver: this, SIGNAL(remainingTimeChanged(qlonglong, QString))); |
| 47 | } |
| 48 | |
| 49 | Solid::Battery::~Battery() |
| 50 | { |
| 51 | } |
| 52 | |
| 53 | bool Solid::Battery::isPresent() const |
| 54 | { |
| 55 | Q_D(const Battery); |
| 56 | return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), false, isPresent()); |
| 57 | } |
| 58 | |
| 59 | Solid::Battery::BatteryType Solid::Battery::type() const |
| 60 | { |
| 61 | Q_D(const Battery); |
| 62 | return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), UnknownBattery, type()); |
| 63 | } |
| 64 | |
| 65 | int Solid::Battery::chargePercent() const |
| 66 | { |
| 67 | Q_D(const Battery); |
| 68 | return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0, chargePercent()); |
| 69 | } |
| 70 | |
| 71 | int Solid::Battery::capacity() const |
| 72 | { |
| 73 | Q_D(const Battery); |
| 74 | return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 100, capacity()); |
| 75 | } |
| 76 | |
| 77 | int Solid::Battery::cycleCount() const |
| 78 | { |
| 79 | Q_D(const Battery); |
| 80 | return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), -1, cycleCount()); |
| 81 | } |
| 82 | |
| 83 | bool Solid::Battery::isRechargeable() const |
| 84 | { |
| 85 | Q_D(const Battery); |
| 86 | return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), false, isRechargeable()); |
| 87 | } |
| 88 | |
| 89 | bool Solid::Battery::isPowerSupply() const |
| 90 | { |
| 91 | Q_D(const Battery); |
| 92 | return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), true, isPowerSupply()); |
| 93 | } |
| 94 | |
| 95 | Solid::Battery::ChargeState Solid::Battery::chargeState() const |
| 96 | { |
| 97 | Q_D(const Battery); |
| 98 | return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), NoCharge, chargeState()); |
| 99 | } |
| 100 | |
| 101 | qlonglong Solid::Battery::timeToEmpty() const |
| 102 | { |
| 103 | Q_D(const Battery); |
| 104 | return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0, timeToEmpty()); |
| 105 | } |
| 106 | |
| 107 | qlonglong Solid::Battery::timeToFull() const |
| 108 | { |
| 109 | Q_D(const Battery); |
| 110 | return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0, timeToFull()); |
| 111 | } |
| 112 | |
| 113 | Solid::Battery::Technology Solid::Battery::technology() const |
| 114 | { |
| 115 | Q_D(const Battery); |
| 116 | return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), UnknownTechnology, technology()); |
| 117 | } |
| 118 | |
| 119 | double Solid::Battery::energy() const |
| 120 | { |
| 121 | Q_D(const Battery); |
| 122 | return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, energy()); |
| 123 | } |
| 124 | |
| 125 | double Solid::Battery::energyFull() const |
| 126 | { |
| 127 | Q_D(const Battery); |
| 128 | return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, energyFull()); |
| 129 | } |
| 130 | |
| 131 | double Solid::Battery::energyFullDesign() const |
| 132 | { |
| 133 | Q_D(const Battery); |
| 134 | return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, energyFullDesign()); |
| 135 | } |
| 136 | |
| 137 | double Solid::Battery::energyRate() const |
| 138 | { |
| 139 | Q_D(const Battery); |
| 140 | return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, energyRate()); |
| 141 | } |
| 142 | |
| 143 | double Solid::Battery::voltage() const |
| 144 | { |
| 145 | Q_D(const Battery); |
| 146 | return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, voltage()); |
| 147 | } |
| 148 | |
| 149 | double Solid::Battery::temperature() const |
| 150 | { |
| 151 | Q_D(const Battery); |
| 152 | return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, temperature()); |
| 153 | } |
| 154 | |
| 155 | QString Solid::Battery::serial() const |
| 156 | { |
| 157 | Q_D(const Battery); |
| 158 | return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), QString(), serial()); |
| 159 | } |
| 160 | |
| 161 | qlonglong Solid::Battery::remainingTime() const |
| 162 | { |
| 163 | Q_D(const Battery); |
| 164 | return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), -1, remainingTime()); |
| 165 | } |
| 166 | |
| 167 | #include "moc_battery.cpp" |
| 168 | |