Skip to content

Commit

Permalink
Fix issue with renaming battery to power
Browse files Browse the repository at this point in the history
  • Loading branch information
Eeems committed Sep 9, 2020
1 parent a01a867 commit 42fa95b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions applications/oxide/codes.eeems.oxide.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<allow user="*"/>
<allow send_interface="codes.eeems.oxide1.General" send_path="*" send_member="*"/>
<allow receive_interface="codes.eeems.oxide1.General" receive_path="*" receive_member="*"/>
<allow send_interface="codes.eeems.oxide1.Battery" send_path="*" send_member="*"/>
<allow receive_interface="codes.eeems.oxide1.Battery" receive_path="*" receive_member="*"/>
<allow send_interface="codes.eeems.oxide1.Power" send_path="*" send_member="*"/>
<allow receive_interface="codes.eeems.oxide1.Power" receive_path="*" receive_member="*"/>
<allow send_interface="org.freedesktop.DBus.Properties" send_path="*" send_member="*"/>
<allow receive_interface="org.freedesktop.DBus.Properties" receive_path="*" receive_member="*"/>
</policy>
Expand Down
20 changes: 10 additions & 10 deletions applications/oxide/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,13 @@ void Controller::updateBatteryLevel() {
if(!ui){
qDebug() << "Can't find batteryLevel";
}
auto batteryAPI = (PowerAPI*)dbusService->getAPI("battery");
auto powerAPI = (PowerAPI*)dbusService->getAPI("power");
if(!battery.exists()){
if(!batteryWarning){
qWarning() << "Can't find battery information";
batteryWarning = true;
emit batteryAPI->batteryWarning();
batteryAPI->setBatteryState(PowerAPI::BatteryUnknown);
emit powerAPI->batteryWarning();
powerAPI->setBatteryState(PowerAPI::BatteryUnknown);
updateUI(ui, "warning", true);
}
return;
Expand All @@ -255,8 +255,8 @@ void Controller::updateBatteryLevel() {
if(!batteryWarning){
qWarning() << "Can't find battery information";
batteryWarning = true;
emit batteryAPI->batteryWarning();
batteryAPI->setBatteryState(PowerAPI::BatteryNotPresent);
emit powerAPI->batteryWarning();
powerAPI->setBatteryState(PowerAPI::BatteryNotPresent);
updateUI(ui, "warning", true);
}
return;
Expand All @@ -265,17 +265,17 @@ void Controller::updateBatteryLevel() {
if(batteryLevel != battery_level){
batteryLevel = battery_level;
updateUI(ui, "level", batteryLevel);
batteryAPI->setBatteryLevel(batteryLevel);
powerAPI->setBatteryLevel(batteryLevel);
}
std::string status = battery.strProperty("status");
auto charging = status == "Charging";
if(batteryCharging != charging){
batteryCharging = charging;
updateUI(ui, "charging", batteryCharging);
if(charging){
batteryAPI->setBatteryState(PowerAPI::BatteryCharging);
powerAPI->setBatteryState(PowerAPI::BatteryCharging);
}else{
batteryAPI->setBatteryState(PowerAPI::BatteryDischarging);
powerAPI->setBatteryState(PowerAPI::BatteryDischarging);
}
}
std::string capacityLevel = battery.strProperty("capacity_level");
Expand All @@ -284,15 +284,15 @@ void Controller::updateBatteryLevel() {
batteryAlert = alert;
updateUI(ui, "alert", batteryAlert);
if(alert){
emit batteryAPI->batteryWarning();
emit powerAPI->batteryWarning();
}
}
auto warning = status == "Unknown" || status == "" || capacityLevel == "Unknown";
if(batteryWarning != warning){
batteryWarning = warning;
updateUI(ui, "warning", warning);
if(warning){
emit batteryAPI->batteryWarning();
emit powerAPI->batteryWarning();
}
}
if(showBatteryTemperature()){
Expand Down
2 changes: 1 addition & 1 deletion applications/oxide/dbussettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
#define OXIDE_SERVICE_PATH "/codes/eeems/oxide1"

#define OXIDE_GENERAL_INTERFACE OXIDE_SERVICE ".General"
#define OXIDE_BATTERY_INTERFACE OXIDE_SERVICE ".Power"
#define OXIDE_POWER_INTERFACE OXIDE_SERVICE ".Power"

#endif // DBUSSETTINGS_H
2 changes: 1 addition & 1 deletion applications/oxide/powerapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class PowerAPI : public QObject {
Q_OBJECT
Q_CLASSINFO("Version", "1.0.0")
Q_CLASSINFO("D-Bus Interface", OXIDE_BATTERY_INTERFACE)
Q_CLASSINFO("D-Bus Interface", OXIDE_POWER_INTERFACE)
Q_PROPERTY(int state READ state WRITE setState NOTIFY stateChanged)
Q_PROPERTY(int batteryState READ batteryState NOTIFY batteryStateChanged)
Q_PROPERTY(int batteryLevel READ batteryLevel NOTIFY batteryLevelChanged)
Expand Down

0 comments on commit 42fa95b

Please sign in to comment.