[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498
Maximiliano Curia
maxy at moszumanska.debian.org
Fri Oct 14 14:27:10 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=e77a2af
The following commit has been merged in the master branch:
commit e77a2af07bec550d8ce025693003d8b04613b31f
Author: Mauro Panzeri <damonhill82 at gmail.com>
Date: Thu Nov 14 16:32:16 2013 +0100
The battery percentage for low battery level is now signaled by the device
Added a field "thresholdEvent" to battery network packages.
REVIEW: 113835
---
kded/plugins/battery/README | 6 ++++++
kded/plugins/battery/batteryplugin.cpp | 28 +++++++++++-----------------
kded/plugins/battery/batteryplugin.h | 8 ++++++++
3 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/kded/plugins/battery/README b/kded/plugins/battery/README
index b7f1ddd..8812ba1 100644
--- a/kded/plugins/battery/README
+++ b/kded/plugins/battery/README
@@ -4,6 +4,12 @@ following fields:
isCharging (boolean): If the battery of the peer device is charging
currentCharge (int): The charge % of the peer device
+thresholdEvent (int) [optional when = 0, see below]:
+ means that a battery threshold event were fired on the remote device:
+ 0 := no event. generally not transmitted.
+ 1 := battery entered in low state
+ This is an int so in the future we'll be able to subscribe to more events.
+ (see BatteryPlugin.ThresholdBatteryEvent)
<TODO>
Symmetrically, it sends its own battery information in packages with the same
diff --git a/kded/plugins/battery/batteryplugin.cpp b/kded/plugins/battery/batteryplugin.cpp
index 2f5314a..074acdf 100644
--- a/kded/plugins/battery/batteryplugin.cpp
+++ b/kded/plugins/battery/batteryplugin.cpp
@@ -60,27 +60,21 @@ bool BatteryPlugin::receivePackage(const NetworkPackage& np)
{
bool isCharging = np.get<bool>("isCharging");
int currentCharge = np.get<int>("currentCharge");
+ int thresholdEvent = np.get<int>("thresholdEvent", (int)ThresholdNone);
if (batteryDbusInterface->isCharging() != currentCharge
- || batteryDbusInterface->isCharging() != isCharging) {
-
+ || batteryDbusInterface->isCharging() != isCharging
+ ) {
batteryDbusInterface->updateValues(isCharging, currentCharge);
+ }
- //FIXME: Where's that 14 coming from?
- //TODO: Decouple the protocol from Android
- /*TODO: Look into the following android interfaces
- android.intent.action.BATTERY_LOW
- android.intent.action.BATTERY_OKAY
- */
- if (currentCharge == 14 && !isCharging) {
- KNotification* notification = new KNotification("batteryLow");
- notification->setPixmap(KIcon("battery-040").pixmap(48, 48));
- notification->setComponentData(KComponentData("kdeconnect", "kdeconnect"));
- notification->setTitle(i18nc("device name: low battery", "%1: low battery",device()->name()));
- notification->setText(i18n("Battery at 14%"));
- notification->sendEvent();
- }
-
+ if ( thresholdEvent == ThresholdBatteryLow && !isCharging ) {
+ KNotification* notification = new KNotification("batteryLow");
+ notification->setPixmap(KIcon("battery-040").pixmap(48, 48));
+ notification->setComponentData(KComponentData("kdeconnect", "kdeconnect"));
+ notification->setTitle(i18nc("device name: low battery", "%1: low battery", device()->name()));
+ notification->setText(i18n("Battery at %1%", currentCharge));
+ notification->sendEvent();
}
return true;
diff --git a/kded/plugins/battery/batteryplugin.h b/kded/plugins/battery/batteryplugin.h
index 3288980..0902913 100644
--- a/kded/plugins/battery/batteryplugin.h
+++ b/kded/plugins/battery/batteryplugin.h
@@ -41,6 +41,14 @@ public Q_SLOTS:
virtual void connected();
private:
+ // Keep these values in sync with THRESHOLD* constants in
+ // kdeconnect-android:BatteryPlugin.java
+ // see README for their meaning
+ enum ThresholdBatteryEvent {
+ ThresholdNone = 0,
+ ThresholdBatteryLow = 1
+ };
+
BatteryDbusInterface* batteryDbusInterface;
};
--
kdeconnect packaging
More information about the pkg-kde-commits
mailing list