Improvements to geoclue2 plugin


Relies on automatic service activation:
https://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-starting-services

This means that the service isn't explicitly started but gets started
automatically when a request to the service is made. It's also possible
that the geoclue2 service gets shutdown during runtime (for example when
no client is requesting updates for some time). Automatic service
activation ensures, that the service gets (re)started whenever needed.

Create the manager interface right in the constructor as there's no
benefit in creating it lazily. Also, since automatic service activation
is used, m_manager->isValid() can't be used, because it always returns
false until the service has been (automatically) started.

Always return correct values from supportedPositioningMethods(). The use
of the m_manager->availableAccuracyLevel() shorthand helper doesn't tell
the difference between an invalid property (for example if geoclue2
isn't available at all) and GCLUE_ACCURACY_LEVEL_NONE since both return
0. Getting the QVariant of the property is needed to distinguish those
cases. An invalid QVariant means that we couldn't communicate to
geoclue2. A QVariant that can be turned into 0 means
GCLUE_ACCURACY_LEVEL_NONE. In this commit GCLUE_ACCURACY_LEVEL_NONE is
also correctly turned into NoPositioningMethods.

If client doesn't exist when startClient() is called, create a client
first. It's also possible that a client is crerated more than once
during runtime. For example, when the above mentioned automatic geoclue2
service shutdown takes place, the old client is no longer usable. Now
in this case the old client gets discarded and a new client is created.

Call startClient() in startUpdates() – because otherwise startUpdates()
wouldn't really work.

Remove the warning message from the beginning of configureClient(). It's
quite OK that configureClient() gets called before m_client exists (it
just doesn't do anything then). This was probably in place with the
assumption that setUpdateInterval(), setPreferredPositioningMethods()
and startUpdates() would get called in some specific order. But no such
assumptions can be made.

Delete client interface object once it's not usable anymore (either
gives an error or is explicitly stopped). This way, a new client gets
created once a client is needed again.

Other minor changes:
- In startClient(), check whether starting the client is needed before
  doing it. This removes the need to do any checks before calling this
  function.
- In stopClient(), check whether stopping the client is OK before doing
  it. This removes the need to do any checks before calling this
  function.
- Use QPointer for the D-Bus interface objects -> no need to set the
  pointers to nullptr after deletion.
- Add explicit casts to few places that gave implicit signedness change
  warnings.

Change-Id: If9db25775710fe64f272db222030e481533d9732
Reviewed-by: Volker Krause <volker.krause@kdab.com>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
commit4ef6b50278c041336f794cef20dd7e30fe8fbec0
parentb5615f571396365a07f123695a05be66c572f622
authorAki Koskinen <qt@akikoskinen.info>
committerAki Koskinen <qt@akikoskinen.info>
commit timeMon, 17 Sep 2018 15:47:13 +0000