[Pkg-wmaker-commits] [wmbattery] 133/241: Sync upower backend from sleepd.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Mon Aug 24 23:37:47 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmbattery.

commit 3ab8cec2c7ab9543e4f5f93f9937bbd773333c63
Author: Andrew Shadura <andrew at shadura.me>
Date:   Fri Jul 18 01:14:21 2014 +0200

    Sync upower backend from sleepd.
---
 upower.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/upower.c b/upower.c
index cb988e6..0890908 100644
--- a/upower.c
+++ b/upower.c
@@ -16,35 +16,40 @@ struct context {
 	int needed;
 	guint state;
 	int percentage;
+	gboolean ac;
 	int time;
 };
 
 static void get_devinfo(gpointer device, gpointer result)
 {
-	gboolean is_rechargeable;
+	gboolean online;
 	gdouble percentage;
 	guint state;
+	guint kind;
 	gint64 time_to_empty;
 	gint64 time_to_full;
 	struct context * ctx = result;
 
 	g_object_get(G_OBJECT(device), "percentage", &percentage,
-		"is-rechargeable", &is_rechargeable,
+		"online", &online,
 		"state", &state,
+		"kind", &kind,
 		"time-to-empty", &time_to_empty,
 		"time-to-full", &time_to_full,
 		NULL);
-	if (is_rechargeable) {
+	if (kind == UP_DEVICE_KIND_BATTERY) {
 		if (ctx->current == ctx->needed) {
 			ctx->percentage = (int)percentage;
 			ctx->state = state;
-			if (time_to_full != 0) {
-				ctx->time = time_to_full;
-			} else {
+			if (time_to_empty) {
 				ctx->time = time_to_empty;
+			} else {
+				ctx->time = time_to_full;
 			}
 		}
 		ctx->current++;
+	} else if (kind == UP_DEVICE_KIND_LINE_POWER) {
+		ctx->ac |= online;
 	}
 }
 
@@ -94,18 +99,19 @@ int upower_read(int battery, apm_info *info) {
 	info->battery_flags = 0;
 	info->using_minutes = 0;
 
-	info->ac_line_status = !up_client_get_on_battery(up);
-
 	struct context ctx = {
 		.current = 0,
 		.needed = battery - 1,
 		.state = UP_DEVICE_STATE_UNKNOWN,
 		.percentage = -1,
+		.ac = FALSE,
 		.time = -1
 	};
 
 	g_ptr_array_foreach(devices, &get_devinfo, &ctx);
 
+	info->ac_line_status = ctx.ac;
+
 	/* remaining_time and charge_level.percentage are not a mandatory
 	 * keys, so if not present, -1 will be returned */
 	info->battery_time = ctx.time;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbattery.git



More information about the Pkg-wmaker-commits mailing list