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 
Battery(QObject * backendObject)15 Solid::Battery::Battery(QObject *backendObject)
16     : DeviceInterface(*new BatteryPrivate(), backendObject)
17 {
18     connect(backendObject, SIGNAL(presentStateChanged(bool, QString)), this, SIGNAL(presentStateChanged(bool, QString)));
19 
20     connect(backendObject, SIGNAL(chargePercentChanged(int, QString)), this, SIGNAL(chargePercentChanged(int, QString)));
21 
22     connect(backendObject, SIGNAL(capacityChanged(int, QString)), this, SIGNAL(capacityChanged(int, QString)));
23 
24     connect(backendObject, SIGNAL(powerSupplyStateChanged(bool, QString)), this, SIGNAL(powerSupplyStateChanged(bool, QString)));
25 
26     connect(backendObject, SIGNAL(chargeStateChanged(int, QString)), this, SIGNAL(chargeStateChanged(int, QString)));
27 
28     connect(backendObject, SIGNAL(timeToEmptyChanged(qlonglong, QString)), this, SIGNAL(timeToEmptyChanged(qlonglong, QString)));
29 
30     connect(backendObject, SIGNAL(timeToFullChanged(qlonglong, QString)), this, SIGNAL(timeToFullChanged(qlonglong, QString)));
31 
32     connect(backendObject, SIGNAL(energyChanged(double, QString)), this, SIGNAL(energyChanged(double, QString)));
33 
34     connect(backendObject, SIGNAL(energyFullChanged(double, QString)), this, SIGNAL(energyFullChanged(double, QString)));
35 
36     connect(backendObject, SIGNAL(energyFullDesignChanged(double, QString)), this, SIGNAL(energyFullDesignChanged(double, QString)));
37 
38     connect(backendObject, SIGNAL(energyRateChanged(double, QString)), this, SIGNAL(energyRateChanged(double, QString)));
39 
40     connect(backendObject, SIGNAL(voltageChanged(double, QString)), this, SIGNAL(voltageChanged(double, QString)));
41 
42     connect(backendObject, SIGNAL(temperatureChanged(double, QString)), this, SIGNAL(temperatureChanged(double, QString)));
43 
44     connect(backendObject, SIGNAL(remainingTimeChanged(qlonglong, QString)), this, SIGNAL(remainingTimeChanged(qlonglong, QString)));
45 }
46 
~Battery()47 Solid::Battery::~Battery()
48 {
49 }
50 
isPresent() const51 bool Solid::Battery::isPresent() const
52 {
53     Q_D(const Battery);
54     return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), false, isPresent());
55 }
56 
type() const57 Solid::Battery::BatteryType Solid::Battery::type() const
58 {
59     Q_D(const Battery);
60     return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), UnknownBattery, type());
61 }
62 
chargePercent() const63 int Solid::Battery::chargePercent() const
64 {
65     Q_D(const Battery);
66     return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0, chargePercent());
67 }
68 
capacity() const69 int Solid::Battery::capacity() const
70 {
71     Q_D(const Battery);
72     return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 100, capacity());
73 }
74 
isRechargeable() const75 bool Solid::Battery::isRechargeable() const
76 {
77     Q_D(const Battery);
78     return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), false, isRechargeable());
79 }
80 
isPowerSupply() const81 bool Solid::Battery::isPowerSupply() const
82 {
83     Q_D(const Battery);
84     return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), true, isPowerSupply());
85 }
86 
chargeState() const87 Solid::Battery::ChargeState Solid::Battery::chargeState() const
88 {
89     Q_D(const Battery);
90     return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), NoCharge, chargeState());
91 }
92 
timeToEmpty() const93 qlonglong Solid::Battery::timeToEmpty() const
94 {
95     Q_D(const Battery);
96     return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0, timeToEmpty());
97 }
98 
timeToFull() const99 qlonglong Solid::Battery::timeToFull() const
100 {
101     Q_D(const Battery);
102     return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0, timeToFull());
103 }
104 
technology() const105 Solid::Battery::Technology Solid::Battery::technology() const
106 {
107     Q_D(const Battery);
108     return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), UnknownTechnology, technology());
109 }
110 
energy() const111 double Solid::Battery::energy() const
112 {
113     Q_D(const Battery);
114     return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, energy());
115 }
116 
energyFull() const117 double Solid::Battery::energyFull() const
118 {
119     Q_D(const Battery);
120     return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, energyFull());
121 }
122 
energyFullDesign() const123 double Solid::Battery::energyFullDesign() const
124 {
125     Q_D(const Battery);
126     return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, energyFullDesign());
127 }
128 
energyRate() const129 double Solid::Battery::energyRate() const
130 {
131     Q_D(const Battery);
132     return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, energyRate());
133 }
134 
voltage() const135 double Solid::Battery::voltage() const
136 {
137     Q_D(const Battery);
138     return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, voltage());
139 }
140 
temperature() const141 double Solid::Battery::temperature() const
142 {
143     Q_D(const Battery);
144     return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, temperature());
145 }
146 
isRecalled() const147 bool Solid::Battery::isRecalled() const
148 {
149     Q_D(const Battery);
150     return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), false, isRecalled());
151 }
152 
recallVendor() const153 QString Solid::Battery::recallVendor() const
154 {
155     Q_D(const Battery);
156     return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), QString(), recallVendor());
157 }
158 
recallUrl() const159 QString Solid::Battery::recallUrl() const
160 {
161     Q_D(const Battery);
162     return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), QString(), recallUrl());
163 }
164 
serial() const165 QString Solid::Battery::serial() const
166 {
167     Q_D(const Battery);
168     return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), QString(), serial());
169 }
170 
remainingTime() const171 qlonglong Solid::Battery::remainingTime() const
172 {
173     Q_D(const Battery);
174     return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), -1, remainingTime());
175 }
176