Commit graph

68 commits

Author SHA1 Message Date
Eric Koegel
77239cc447 bsd: Add critical action support for *BSD
This patch adds support for using ConsoleKit2's DBUS API to
implement the critical action for FreeBSD and OpenBSD. It does so
by creating a common backend file both can use to implement the
API calls.

https://bugs.freedesktop.org/show_bug.cgi?id=85242
2015-07-07 17:10:38 +02:00
Peter Wu
90994b0d81 daemon: release resources at shutdown
This makes it easier to find real memory leaks with valgrind. After
calling the up_backend_unplug functions, you cannot restart it with
up_backend_coldplug since the lists are cleared.

Tested with Linux only (not on *BSD; dummy compiles).

https://bugs.freedesktop.org/show_bug.cgi?id=82659
2014-11-26 11:56:16 +00:00
Evangelos Foutras
bbe15b14de all: convert value from g_get_real_time() to seconds
Commit 5ddfe0d (all: Use g_get_real_time() when possible) replaced calls
to g_get_current_time() with g_get_real_time(), however, we also need to
convert the return value from microseconds to seconds.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2014-10-08 19:32:05 +01:00
Bastien Nocera
5ddfe0dba1 all: Use g_get_real_time() when possible
Instead of a call to g_get_current_time().
2014-09-24 15:16:11 +02:00
Fabian Raetz
d1bb06985f openbsd: Expose "capacity" and "energy-full-design" properties
https://bugs.freedesktop.org/show_bug.cgi?id=80707
2014-06-30 12:09:19 +02:00
Jasper Lievisse Adriaanse
4bed9c99c1 Update lid status when updating ac status.
Signed-off-by: Richard Hughes <richard@hughsie.com>
2014-04-22 11:41:56 +01:00
Bastien Nocera
db31456921 all: Add GetCriticalAction daemon method
This allows desktop front-ends to get which action will
actually be taken when we hit critical battery.

This is not a property as availability of actions might
change over the course of the run of the system, and
we didn't want to make unnecessary D-Bus calls on startup.
2013-10-17 09:04:03 +02:00
Bastien Nocera
68b9975ad9 daemon: Add CriticalPowerAction
Paraphrasing from the configuration option:
The action to take when "TimeAction" or "PercentageAction" above has
been reached for the batteries (UPS or laptop batteries) supplying
the computer.

This is done 20 seconds after the warning-level variable got set
to UP_DEVICE_LEVEL_ACTION has been set, to give the opportunity
to front-ends to display a (short) warning.

This is only implemented for the Linux backend, using logind.
2013-10-14 11:06:53 +02:00
Bastien Nocera
bd3a57fe04 daemon: Replace "on-low-battery" property
With "warning-level" property.
2013-10-14 10:42:56 +02:00
Bastien Nocera
91df125e39 daemon: Remove unneeded reset of priv struct members
It's already done by GObject.
2013-10-14 10:42:56 +02:00
Bastien Nocera
1ee642e705 daemon: Remove obsolete features 2013-10-14 10:42:55 +02:00
Bastien Nocera
5f26bc5caa daemon: Simplify _new() functions 2013-10-14 10:36:34 +02:00
Landry Breuil
a1b772af16 openbsd: Use g_thread_try_new()
Instead of deprecated g_thread_create()

https://bugs.freedesktop.org/show_bug.cgi?id=70071
2013-10-14 10:14:41 +02:00
Jasper Lievisse Adriaanse
3a9bd43450 openbsd: recognize when battery is absent or fully charged
https://bugs.freedesktop.org/show_bug.cgi?id=70064
2013-10-14 10:13:40 +02:00
Richard Hughes
ee0a71dd7d openbsd: Do not call g_thread_init() 2013-09-18 08:42:40 +01:00
Richard Hughes
5be743c910 Don't use the deprecated INCLUDES in Makefile.am 2013-01-14 09:21:30 +00:00
Matthias Clasen
44189f8129 Use systemd for suspend and hibernate
When running under systemd, call into systemd for suspend and
hibernate instead of pm-utils. To capture resume events, install
a small script that gets executed by systemd after resume and
sends a dbus signal back to upower.

To make this work, the upower backends gain a new signal, ::resuming,
that they can optionally emit to signal that a resume happened.
Backends opt in to this by returning TRUE from up_backend_emits_resuming().
In this case, upower doesn't assume the sleep command to block until
resume, but instead waits for the ::resuming signal from the backend.

The only backend that uses this mechanism is the linux backend when
built with systemd support.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-07-11 18:11:39 +01:00
Landry Breuil
336f8bd222 openbsd: Properly initialize update-time when creating devices
Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-06-27 08:39:44 +01:00
Landry Breuil
4f3150fb27 openbsd: set powersave command to apm -C/-A
Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-01-06 13:40:50 +00:00
Landry Breuil
1f412fe279 openbsd: no need to pass the fd around
better access it where needed through the singleton.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-01-06 13:40:50 +00:00
Landry Breuil
7cd8465811 openbsd: handle case where minutes_left might be negative
might not be useful since apm_fd is accessed through the singleton..

Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-01-06 13:40:50 +00:00
Landry Breuil
3dfc0598f8 openbsd: improve logic wrt sensor type
in case some sensors are in AMPHOUR/AMPS and others in WATTHOUR/WATTS,
don't assume they are all the same type. As a benefit, shrinks the
code a bit.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-01-06 13:40:50 +00:00
Landry Breuil
37ff0d4ddb openbsd: fix energy-rate calculation
since acpibat.c r1.59, bst_rate type is SENSOR_AMPS or SENSOR_WATTS
and value has been corrected. Tweak accordingly.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-01-06 13:40:50 +00:00
Landry Breuil
60e474ead5 openbsd: use a singleton pattern to access /dev/apm
up_apm_get_fd() opens /dev/apm  only if it's not already opened.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-01-06 13:40:50 +00:00
Landry Breuil
6c15694dbb openbsd: Fix history by not trying to refresh if /dev/apm wasn't opened yet
Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-01-06 13:40:46 +00:00
Richard Hughes
b19fca9637 Use git.mk and remove the manual .gitignore files 2011-07-19 12:40:21 +01:00
Landry Breuil
fed9c33910 Add openbsd missing includes for close() and strcmp() 2011-05-31 11:07:52 +01:00
Landry Breuil
e495d53661 Silence some openbsd warnings about unused vars and bad return values 2011-05-31 11:07:21 +01:00
Richard Hughes
abfb19d472 Ensure up-apm-native.h gets shipped in the tarball 2011-05-17 08:23:55 +01:00
Landry Breuil
3787531096 openbsd: fix warning, and set lid-present to no
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:40:25 +00:00
Landry Breuil
883da76819 openbsd: Add licence headers..
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:40:23 +00:00
Landry Breuil
08227a6416 openbsd: handle case when power is reported directly as Wh
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:40:21 +00:00
Landry Breuil
83e1e56938 openbsd: Add up_apm_device_refresh callback to device class
- move apm_fd to a global var atm, needs to be passed to a private native class
- propagate more error codes through some booleans
- history now works!

Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:40:19 +00:00
Landry Breuil
53ba669490 openbsd: wip on acpibat_state, need to sort wh/ah units
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:40:16 +00:00
Landry Breuil
6dd2e35d6f openbsd: add up_backend_update_acpibat_state() and call it if acpibat0 device is found
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:40:15 +00:00
Landry Breuil
a65fdfc156 trivial: move #includes
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:40:13 +00:00
Landry Breuil
20a3759ab9 openbsd: rename get_sensor() to get_sensordev() for the sake of clarity
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:40:12 +00:00
Landry Breuil
1017f7399b openbsd: rename has_sensor() to get_sensor() and use it to grab the sensordev struct
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:40:09 +00:00
Landry Breuil
5e69186399 openbsd: add up_native_has_sensor() and use it in is_laptop()
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:40:07 +00:00
Landry Breuil
d51953c305 openbsd: assign callbacks to ac/batt device class
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:57 +00:00
Landry Breuil
8e84a6dbb4 openbsd: rip of get_on_battery/get_low_battery/get_online from freebsd backend
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:55 +00:00
Landry Breuil
08d46e4b90 trivial: fix indent
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:51 +00:00
Landry Breuil
164ac63f8d openbsd: time-to-empty is in seconds
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:49 +00:00
Landry Breuil
0d7b9fe1d5 trivial: silence warnings
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:48 +00:00
Landry Breuil
55408490d0 trivial: return NULL, shouldnt be reached anyway
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:26 +00:00
Landry Breuil
b03290f11d openbsd: Declare prototypes for get_power_info/get_battery_state_value
Pass struct apm_power_info ptr as argument instead of returning it

Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:24 +00:00
Landry Breuil
564d1c47ad openbsd: cast NULL to void* to silence missing sentinel gcc warnings
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:23 +00:00
Landry Breuil
2533e75e77 openbsd: dont initialize props we wont likely set atm
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:22 +00:00
Landry Breuil
631869fdd5 openbsd: Update battery properties only if they really changed
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:20 +00:00
Landry Breuil
89c929d442 openbsd: update ac state only if state really changed
Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-03-21 18:39:19 +00:00