Fix test for logind availability

sd_booted() is not an appropriate check for whether we should talk to logind,
test for /run/systemd/seats/ instead.

For details, see:
<https://mail.gnome.org/archives/desktop-devel-list/2013-March/msg00092.html>
Drop --enable-systemd and linking to libsystemd-daemon

logind is now being detected at runtime (see previous commit ff39d23), so we do
not need to link against libsystemd-daemon any more. Drop --enable-systemd
configure option as well.
Find hidraw devices correctly with systemd udev >= v196.

udev v196 libraries changed behaviour of g_udev_device_get_sysfs_attr()
by stopping following symlinks for "device" attribute [1]. That change
broke hiddev finding for unifying devices. Fix that by getting sysfs
path from parent hiddev device.

1. http://cgit.freedesktop.org/systemd/systemd/commit/?id=5ae18ddc0d86673520c0dd6b59ccac8afc8aa605

Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
Detection of version 1 hid++ is not returned to the caller

HID++ version 1 was properly detected but that information wasn't
reaching caller.

Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
Buffer for HIDPP_REFRESH_FLAGS_KIND not big enough

HIDPP_REFRESH_FLAGS_KIND action puts result into 7 bytes buffer and
later tries to access 8th element (with index 7). Make buffer bigger,
so 8th element will fit.

Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
Invalid request/response for HIDPP_REFRESH_FLAGS_BATTERY in hid++1

Version 1 hid++ HIDPP_REFRESH_FLAGS_BATTERY packets were incorrect.

Response packets were incorrectly thrown away as invalid. These
packets have HIDPP_HEADER_REQUEST (and not HIDPP_HEADER_RESPONSE as code
expexted). Fix that by allowing both types.

Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
Add support for HIDPP_REFRESH_FLAGS_MODEL in hid++ v1

Add support for checking device model name for hid++ v1 protocol
version.

Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
Repair vendor handling for Logitech Unifying devices

Set proper vendor via udev rules for unifying devices and handle
that in code.

Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
Add support for Logitech Wireless (NonUnifying) devices

There are Logitech Wireless devices similar to Unifying ones with the
difference that device is paired with single dongle and dongle doesn't
support pairing multiple devices.

Add support for these. Tested with Wireless Mouse M187 and M185/M225.

Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
Better method of figuring out v1 vs v2 protocol version.

Protocol version detection isn't very reliable (especially for
hid++ v1).

Version 1 checking was potentially happening in every hidpp_device_cmd()
call and not only when requested. Improve that to do version checking
and priv->version manipulation only when requested by using
HIDPP_REFRESH_FLAGS_VERSION.

When doing version checking first try v2 protocol command and if it
succeeds assume version 2 device. Otherwise try v1 protocol query
and if that successds assume version 1 device.

v2 devices in unreachable/sleep mode seem to do not respond to v2
queries but they respond to v1 queries! Still we want best protocol
possible. To do that we are rechecking version when current protocol
version is below 2 and we are doing up_device_unifying_refresh() and if
recheck succeeds we upgrade protocol to v2.

Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
hid++v1 detection for unreachable devices and features upgrade

We are back to using HIDPP_FEATURE_ROOT_FN_PING for detecting protocol
since it's the official way described in [1].

Unfortunately unreachable devices ("disconnected" in logitech
terminology) don't respond to this v1 ping query as described in docs.
Seems that docs cover only reachable state reply for version checking.
Thus we have to consider HIDPP_ERROR_CODE_UNSUPPORTED to also be v1
(since we actually got some v1 valid answer - error reply).

Introduce HIDPP_REFRESH_FLAGS_FEATURES for checking features provided
by v2 device. This recheck is triggered when we upgrade from any
protocol to v2 in HIDPP_REFRESH_FLAGS_VERSION. This allows us to
properly upgrade from v0/v1 to v2 and also we don't send v2 queries
when we know that the device is v1.

[1] logitech_hidpp10_specification_for_Unifying_Receivers.doc

Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
Locate non-unifying receiver by looking for hidraw with hiddev exposed.

For non unifying receiver we were trying to locate receiver hiddraw
device by looking into INTERFACES property. This doesn't work well
for non-unifying devices from keyboard+mouse sets (which use single
dongle for 2 devices but are still non-unifying).

The only thing that's different between hiddraw receiver and other
devices (mouse, keyboard etc) is that receiver also exposes hiddev
interface.

Use that fact to reliably locate receiver.

Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
Allow clients to call org.freedesktop.DBus.Peer

This fixes Ping() and GetMachineId() which is needed by systemd.
Update the upower man page with all the current options
Use PIE to better secure installed tools and also use full RELRO in the daemon
trivial: Fix the gitignore files
build: detect udev rules dir

Udev rules may live in either /lib/udev/rules.d or /usr/lib/udev/rules.d depending on the distro.
Remove the heuristic for deciding the dir, use pkgconfig to detect the location and allow it to be
set manually.

v2: fix specifying --with-udevrulesdir

Signed-off-by: Richard Hughes <richard@hughsie.com>
Released UPower 0.9.21
trivial: post release version bump
linux: Fix batteries which report capacity, but not energy/charge

Many Android devices only export charge_full and capacity, but not charge_now
or energy_now. In that case, directly read the percentage (from the capacity
attribute) and calculate current energy from that.

Thanks to Seth Forshee for the original patch!

https://bugs.freedesktop.org/show_bug.cgi?id=68337