vala.m4: don't keep generated files in git

This is automatically taken during autogen from the vala install.  This
file was recently updated and having our own copy prevents the updated
version from being used.

https://bugzilla.gnome.org/show_bug.cgi?id=724339
eds: Add debugging information to PersonaStore._commit_modified_property()
tests: Add private copy of GTestDBus

This is due to the suggested deprecation of GTestDBus, and the refusal
of upstream to accept patches which add system bus support. Those
patches are a requirement for folks to use GTestDBus to test its BlueZ
backend.

Ideally, folks could be ported to some other D-Bus mocking framework,
but a lot of work has been invested in the GTestDBus approach, and it’s
currently bit rotting something horrible. I just don’t have time at the
moment to port it all over to something else; so copying the GTestDBus
sources locally and modifying them is the most pragmatic approach.

gtestdbus.[ch] are licensed under LGPLv2.1+ (same as libfolks), and the
copyright is held by:
 • Copyright © 2008–2010 Red Hat, Inc.
 • Copyright © 2012 Collabora Ltd.
Authors:
 • David Zeuthen <davidz@redhat.com>
 • Xavier Claessens <xavier.claessens@collabora.co.uk>
tests: Fix build errors in gtestdbus.c

This changes the pristine GLib-copied version of the file to something
which compiles locally, and renames it to FolksTestDBus.
tests: Switch from GTestDBus to FolksTestDBus

The functionality should be equivalent at this point.
tests: Add support for starting isolated system buses

Add a new FOLKS_TEST_DBUS_SYSTEM_BUS flag which can be passed to
folks_test_dbus_new() to create a system bus instead of a session bus. This
handles setting the correct environment variables, and ensures that the
bus’ security policy is completely permissive.

This is a tweaked version of the patch from
bug: https://bugzilla.gnome.org/show_bug.cgi?id=712148
tests: Selectively unset D-Bus environment variables

Don’t always unset all D-Bus environment variables when starting up or
shutting down an isolated bus, as to do so might trample on other
FolksTestDBus instances for other kinds of bus (e.g. session vs. system).

Instead, always unset a few common environment variables (like DISPLAY),
but only unset the DBUS_*_BUS_ADDRESS variable corresponding to the type
of bus being start up or shut down.

This is a tweaked version of the patch from
bug: https://bugzilla.gnome.org/show_bug.cgi?id=712148
tests: Unset the DBUS_SESSION_BUS_[PID|WINDOWID] variables

Might as well do a complete job when unsetting environment variables
which are associated with D-Bus.

This is a tweaked version of the patch from
bug: https://bugzilla.gnome.org/show_bug.cgi?id=712148
tests: Add a FOLKS_TEST_DBUS_SESSION_BUS flag

This mirrors the FOLKS_TEST_DBUS_SYSTEM_BUS flag, and can be used to clarify
which bus is expected to be created. The default behaviour (if
FOLKS_TEST_DBUS_SYSTEM_BUS isn’t specified) is to create a session bus,
however, so setting this flag isn’t at all required.

This is a tweaked version of the patch from
bug: https://bugzilla.gnome.org/show_bug.cgi?id=712148
tests: Add support for an isolated system bus

In addition to an isolated session bus, the tests are now run with an
isolated system bus as well. This is needed for the BlueZ backend, which
uses the org.bluez service on the system bus.

This depends on the GLib.TestDBus changes here:
https://bugzilla.gnome.org/show_bug.cgi?id=712148

https://bugzilla.gnome.org/show_bug.cgi?id=712274
tests: Add python-dbusmock support to the base TestCase class

This allows derived test cases to easily use python-dbusmock to mock up
D-Bus services which are used by the code under test. The derived code
simply needs to call:
    this.create_dbusmock_service (BusType.SESSION, "org.foo", "foo")
to allow instantiation of the ‘org.foo’ service using the ‘foo’
python-dbusmock template.

https://bugzilla.gnome.org/show_bug.cgi?id=712274
bluez: Add a test suite

This adds a test suite for the BlueZ backend, using a python-dbusmock
mock up of the BlueZ and OBEX D-Bus services.

This requires the latest version of python-dbusmock, plus up-to-date
versions of GLib and Vala for binding updates. The use of the second and
third arguments to AM_PROG_VALAC in configure.ac also necessitates use
of automake 1.12 or newer.

Only a few test cases have been added so far, covering vCard parsing and
general set up of PersonaStores. Using python-dbusmock it should be easy
to add more tests covering advanced Bluetooth device
appearance/disappearance situations in future.

https://bugzilla.gnome.org/show_bug.cgi?id=712274
bluez: Remove BluezBackendFactory class

It was utterly pointless.

https://bugzilla.gnome.org/show_bug.cgi?id=712274
core: Unprepare all backends when destroying the BackendStore

This helps free up some reference cycles (particularly in the BlueZ
backend) and hence ensure no memory is leaked.

https://bugzilla.gnome.org/show_bug.cgi?id=712274
bluez: Add some more debug output

https://bugzilla.gnome.org/show_bug.cgi?id=712274
bluez: Handle the optional Filename property of BlueZ

Previously the code assumed that Filename was always set, but it’s
actually an optional property. Gracefully handle it not existing.

https://bugzilla.gnome.org/show_bug.cgi?id=712274
bluez: Don’t warn about the store being offline

If the Bluetooth device is disconnected by the user between updates of
the contact metadata, the code previously printed a warning when the
next update attempt failed. Instead, just gracefully and silently fail
and schedule the next update.

https://bugzilla.gnome.org/show_bug.cgi?id=712274
bluez: Fix removal of a Map element while iterating over the Map

https://bugzilla.gnome.org/show_bug.cgi?id=712274
bluez: Reimplement vCard parsing when updating Personas

This completely re-implements parsing of the vCards returned from the
Bluetooth device, with the following aims:
 • Improve efficiency.
 • Correctly support multi-instance attributes (such as TEL and EMAIL).
 • Fix comparison of new and old values to reduce property notification
   spew.

Previously, the code was calling E.VCard.get_attribute() for each
attribute it expected, which iterates over the vCard’s entire attribute
list every time. Now, the code iterates over the attribute list once and
checks for the attributes it expects. This also means that unsupported
attributes can be detected. The performance improvement from this should
come from reduced iteration and better cache utilisation, although it
has not been measured. If further performance improvements are needed,
the attribute name strings could be interned and pointer comparisons
used instead of lots of strcmp()s.

The code was also previously using E.VCardAttribute.get_values() to get
the values of TEL, EMAIL and URL attributes, which is incorrect, as
those attributes are single-valued but may exist several times in the
vCard. Consequently, the code previously only parsed the first telephone
number, e-mail address and phone number in the vCard and ignored the
rest. This has now been fixed.

Finally, the code was doing pointer comparisons of elements in the
phone, e-mail and URI sets, and hence was always detecting them as
different (even if strcmp() comparison would have yielded equality).
This was causing excess property notification spew. This has been fixed
by correctly specifying the hash and equality functions to use for the
Sets.

Additionally, the code has been ported to use SmallSet instead of
HashSet. The memory and performance improvements of this change have not
been measured.

https://bugzilla.gnome.org/show_bug.cgi?id=712274
bluez: Calculate Persona IID checksums without the vCard PHOTO attribute

Persona IIDs can come from two places:
 • the vCard UID attribute (preferred); or
 • a checksum of the vCard’s string representation.
Previously, the checksum was calculated over all fields in the vCard,
which interacted very badly with download_photos mode. When downloading
photos, only the PHOTO and UID attributes would be downloaded;
otherwise, all attributes except PHOTO would be downloaded. Obviously,
this meant that it was impossible to calculate the same checksum for a
Persona in download_photos and non-download_photos mode. This meant that
matching the photos up to the existing Personas was impossible. Sad
times.

Now, when in download_photos mode, download all vCard attributes
(including the PHOTO) but calculate the IID checksum over all the
attributes except the PHOTO. This should yield the same checksum as from
non-download_photos mode, unless one of the other vCard properties has
changed between downloads; a new checksum would be produced then, which
is the expected behaviour.

https://bugzilla.gnome.org/show_bug.cgi?id=712274