summaryrefslogtreecommitdiff
path: root/src/up-daemon.c
AgeCommit message (Collapse)AuthorFilesLines
2014-12-03daemon: fix ulong/gulong typoHEADmasterPeter Wu1-1/+1
Regression in 4221835fae97f875a23d0ce449e955f2ea488bbc ("daemon: properly disconnect signals, stop memleak"). https://bugs.freedesktop.org/show_bug.cgi?id=82659 Signed-off-by: Richard Hughes <richard@hughsie.com>
2014-11-26daemon: release resources at shutdownPeter Wu1-0/+18
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-26daemon: fix various reference leaksPeter Wu1-2/+9
up_daemon_get_daemon takes a reference on UpDaemon, so it must be properly dereferenced. Similar for up_daemon_get_devices_list which references an UpDeviceList. The display device was allocated in init, but never released either. https://bugs.freedesktop.org/show_bug.cgi?id=82659
2014-11-26daemon: properly disconnect signals, stop memleakPeter Wu1-2/+18
Whenever the daemon is polling on a device, a new signal is connected to the object. This signal was not disconnected when polling stops which resulted in a memory leak. Furthermore, whenever the "warning-level" property is updated, the signal would result in an exponentially raising call count (this happens when the battery percentage changes for example). https://bugs.freedesktop.org/show_bug.cgi?id=82659 Reported-by: Alexander Jesner <alexander@jesner.eu> Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2014-11-26daemon: fix memleak in queue_changed_propertyPeter Wu1-1/+3
The control of value is transferred to up_daemon_queue_changed_property, let it release the memory when an error occurs. https://bugs.freedesktop.org/show_bug.cgi?id=82659
2014-11-18daemon: remove unused variablePeter Wu1-1/+0
Introduced in 2e87407eb91407e64f3d23de07b9dc91735a6a49 https://bugs.freedesktop.org/show_bug.cgi?id=86144
2014-11-14daemon: Use new warning update helper functionBastien Nocera1-6/+1
Rather than the copy/paste code in commit: b9bd275890387fb35c185f37ec0ea1f2aa857818 This makes sure that the AC status is updated. https://bugs.freedesktop.org/show_bug.cgi?id=86144
2014-11-14daemon: Update display device when battery is removedBastien Nocera1-0/+3
When removing a battery, make sure to go through the batteries, and update the display device status. https://bugs.freedesktop.org/show_bug.cgi?id=86144
2014-11-14daemon: Split out updating on_battery and warning_levelBastien Nocera1-11/+18
So that we can reuse this code. https://bugs.freedesktop.org/show_bug.cgi?id=86144
2014-10-08daemon: Update aggregate device on battery removalEvangelos Foutras1-0/+7
https://bugs.freedesktop.org/show_bug.cgi?id=84345 Signed-off-by: Richard Hughes <richard@hughsie.com>
2014-10-08all: convert value from g_get_real_time() to secondsEvangelos Foutras1-2/+2
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-09-24daemon: Set update-time on the aggregate deviceBastien Nocera1-1/+5
2014-08-18Free the obtained device list array after useAlexander Jesner1-0/+2
Signed-off-by: Richard Hughes <richard@hughsie.com>
2014-07-14Remove polkit dependencyEric Koegel1-4/+0
With the removal of the suspend/hibernate code, there's no longer a need for upower to depend on polkit. This patch removes the old polkit code. Signed-off-by: Richard Hughes <richard@hughsie.com>
2014-05-07all: Remove IsDocked propertyBastien Nocera1-12/+0
Removes the deprecated (for not very long) property, before we do a 1.0 release. https://bugs.freedesktop.org/show_bug.cgi?id=78380
2014-05-07daemon: Deprecate "IsDocked" propertyBastien Nocera1-16/+1
The IsDocked property has been incorrect for a number of laptops for a while, as it thought that laptops with hybrid graphics cards were always docked. The alternative would have been to use the platform/dock_station devices, but those are only exported for ACPI docking stations. Instead, whether an external display is attached (which isn't really docking) should be checked in the same place where the policy depending on the value should be applied, such as gnome-settings-daemon. https://bugs.freedesktop.org/show_bug.cgi?id=36818
2014-04-23daemon: Fix shutdown on boot on some machinesBastien Nocera1-3/+10
On the Lenovo A600 all-in-one, there's a HCI/HID dual-mode Broadcom device which will try to get the battery level of the supplied mouse and keyboard, but will usually fail to do so. So we have a battery of type "battery" (it's not either a mouse or a keyboard, as it's supposed to handle both) but our display device battery code doesn't check whether those batteries are power supplies or not, using this "empty" (0% after the check timed out) battery in the shutdown policy. Check better for power supply devices, not all the "battery" types are power supply batteries, they might be non-power supply ones from unknown device types.
2013-10-28daemon: Add poll helper functionsBastien Nocera1-0/+136
To be used by all polling backends. This changes the defaults to poll every 120 seconds when a warning level isn't reached, and switch automatically to 30 seconds poll when the battery level is low.
2013-10-26daemon: Better timeout source namingBastien Nocera1-0/+1
Matching the work done in glib, gtk+, etc. This also differentiates the unknown and normal timeouts in the Linux power supply driver.
2013-10-26daemon: Let the backends do the pollingBastien Nocera1-66/+1
When the AC state changes, let the backends poll for battery changes. They know better what's _really_ happening (whether the real state is unknown even if they present a fully-charged battery), etc. This is only possible because we fixed the Linux backend to poll as it should always have.
2013-10-20daemon: Fix time to empty with multiple batteriesBastien Nocera1-2/+2
If one battery is draining and the other one isn't, the time to empty wouldn't be zero, but it would only match the time to empty for the single battery. Instead, ignore the accumulated time to empty/time to full for multiple batteries and recalculate it. https://bugzilla.gnome.org/show_bug.cgi?id=710344
2013-10-18daemon: Differentiate 2 warningsBastien Nocera1-2/+2
No way to know which one was being called otherwise
2013-10-18daemon: Fix WarningLevel for devices with no "time to empty"Bastien Nocera1-1/+3
As can happen with missing metadata, we might not have a time to empty, so rely on the percentage instead.
2013-10-17daemon: Remove dead code from up_daemon_device_changed_cb()Bastien Nocera1-11/+0
2013-10-17all: Remove *changed signalsBastien Nocera1-25/+2
Now that we send out PropertiesChanged signals (on the daemon side) and "notify" signals (on the client side), there's no need for the all encompassing DeviceChanged and Changed signals. They would have woken up any client, even if they were not interested in receiving the signals.
2013-10-17power: Work-around batteries that are slow to notice chargeBastien Nocera1-0/+5
This is a hack that was in gnome-settings-daemon's power plugin. We would check whether we were on AC before saying for certain that batteries had a low-level, and raising the warning-level.
2013-10-17all: Add GetCriticalAction daemon methodBastien Nocera1-0/+11
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-17all: Remove WarningLevel from the daemon propertiesBastien Nocera1-15/+1
The WarningLevel property just replicated the warning level on the display device, or at least should have. So we fix the latter to remove the former.
2013-10-17daemon: Indentation in UpDaemon structBastien Nocera1-9/+9
2013-10-16daemon: Minimise WarningLevel signalsBastien Nocera1-0/+4
When it doesn't actually change, don't send out signals.
2013-10-16daemon: Only modify display device when it changesBastien Nocera1-1/+11
When none of the properties of the display device change, do not modify it.
2013-10-16daemon: Add GetDisplayDevice methodBastien Nocera1-0/+33
And export a DisplayDevice object which can be used by desktop shells to show/hide the status icon.
2013-10-16daemon: Set the display device type when on batteryBastien Nocera1-0/+1
When on battery only, we weren't setting the display device type properly.
2013-10-16daemon: Remove spurious linefeedBastien Nocera1-1/+0
2013-10-15daemon: Add support for more types for PropertiesChangedBastien Nocera1-0/+16
Add code to transform strings, doubles, uint64s, and int64s.
2013-10-15daemon: Coalesce PropertiesChanged signals togetherBastien Nocera1-40/+98
Instead of sending one changed signal at a time, coalesce them together to reduce wakeups. We also export up_daemon_emit_properties_changed() for UpDevice to use.
2013-10-15daemon: Calculate global WarningLevel correctlyBastien Nocera1-17/+137
By using the state of all the combined batteries, rather than each one (eg. 2 batteries of the same type at 15% shouldn't trigger the "low" warning level). This introduces code to calculate the state of a "display" device, which is either a UPS, or a combination of all batteries.
2013-10-15daemon: Register on the Bus after coldplugBastien Nocera1-45/+34
Both for the daemon and devices, so as to avoid D-Bus changes storms on startup.
2013-10-14daemon: Don't emit changed signal in coldplugBastien Nocera1-5/+7
We weren't emitting GObject signals in coldplug, no need to send out D-Bus signals either.
2013-10-14daemon: Sort the UpDaemon struct memberBastien Nocera1-4/+7
2013-10-14daemon: Add new WarningLevel "Discharging"Bastien Nocera1-2/+5
When UPSes are discharging, we should have a warning already, as it means that mains power has been lost to the UPS (though not to the computer).
2013-10-14daemon: Move all computations of warning level to daemonBastien Nocera1-5/+9
There's no reason why the state check should be done in the UpDevice implementation, and the state will be needed to add a new warning level for UPSes.
2013-10-14daemon: Require newer GLibBastien Nocera1-2/+0
And remove ifdef's.
2013-10-14daemon: Add CriticalPowerActionBastien Nocera1-0/+28
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-14daemon: Emit the PropertiesChanged signalBastien Nocera1-7/+52
Use raw D-Bus. https://bugs.freedesktop.org/show_bug.cgi?id=43001
2013-10-14daemon: Emit the "Changed" signal without going through notifyBastien Nocera1-25/+25
There's no need to use the "notify" signal to capture when the properties are changed, we're the ones sending the notify signals in the first place.
2013-10-14daemon: Device* signals send out object pathsBastien Nocera1-6/+6
Not strings, so correct the signal definitions to match the XML service definition.
2013-10-14daemon: Add small hack for keyboards and miceBastien Nocera1-4/+18
Imported from gnome-settings-daemon, itself from gnome-power-manager.
2013-10-14daemon: Replace "on-low-battery" propertyBastien Nocera1-39/+50
With "warning-level" property.
2013-10-14daemon: Add WarningLevel device propertyBastien Nocera1-0/+31