Update addressbook to use ->open_sync()

This allows us to kill off all pretence of supporting the 'only_if_exists'
argument. Which we didn't actually support anyway, and which is going to
be even further from being supportable when I move to using a GInitable to
open the database at instantiation time.

(cherry picked from commit 3bef929cb2d74a8bdce95568e61be018c11b1d03)
Use GInitable to initialise addressbook

We apparently get asked for revision and locale information before it's
actually opened, and clients will crash if we just return NULL. So open
the sqlite database at instantiation time, like the file backend does.

(cherry picked from commit 45e597ebe641989b5f05bcd286de39caecb2333f)
Port addressbook to EBookSqlite

(cherry picked from commit a1a35cfae9714276df1cf13323dcd4dd6bbf7276)
Fix build for oab-decode-test, port it to EBookSqlite

(cherry picked from commit 48b075a457625831f3d294a494fe0be8add27bb3)
Move dset handling inside ews_decode_addressbook_record()

(cherry picked from commit deac467e45902d79d6484219d1ebeb097821c803)
Use (hashed) PidTagEmailAddress for OAB item UID

The PidTagSmtpAddress isn't always unique.

(cherry picked from commit b560d914a59570bd1955db348087ec0053837e91)
Pass GInputStream to decoder functions instead of assuming priv->fis

If we want to optimise the decode a little and also use data twice, we'll
probably want to create a GMemoryInputStream for each record. We're doing
a lot of seeking due to ews_oab_read_upto() already, and it'll only get
worse if we take the SHA1 of each record as well as processing it.

(cherry picked from commit 140d2ba3ad2d27193119de4b81d0b92c09204868)
Use GMemoryInputStream for processing records, calculate SHA1 on each

(cherry picked from commit 1c4efeda352a04d4ee5de6ca07703df1bc5b0389)
Optimise EWS GAL update not to rewrite unchanged records

Store the SHA1 of the binary data in bdata in the sqlite. When processing
the new OAB file, if the bdata already matches then do nothing to the
existing record.

Before starting to process the OAB file, build a GHashTable with all the
UIDs which already exist in the database. Remove them from the GHashTable
as they are seen while processing the OAB file. At the end, any which are
still left in the GHashTable are deleted.

The value in the GHashTable is the SHA1, and is freed either when a
matching record is decoded or at the end when we process the hash table
to remove all remaining entries, with the append_to_list() helper
function.

This should *drastically* improve the performance of the GAL update.

(cherry picked from commit f0e4e8cd6bbf957b1952efe1c7519512388a0b84)
[Change message string back to avoid string changes]
Avoid processing OAB records which already exist

By checking the SHA1 before generating the EContact we can halve the time
taken to process the Intel GAL from about 50s to about 25s.

The extra data is now the key in one GHashTable, and freed with that
hash table. While the uids are the key in the other and freed with that.

(cherry picked from commit 1a493d97cc447a7406e70ab5e83427233e1fc48a)
Fix modify_contacts for EBookSqlite

Oops, old_contact needs to be initialised to NULL when it isn't the return
value from the function. Broke this in the conversion to EBookSqlite.

(cherry picked from commit 8325bea618c21e23d3c1f3dcd05f2ef58f76e74b)
Bug 736257 - Fix cancellation of addressbook lookups

Clean up and unify the return path from e_book_backend_ews_start_view()
somewhat while we're at it. It's good practice to have only a single
exit path and use 'goto' to get there, rather than doing it differently
in various cases — and doing it partly in fetch_from_offline() was
particularly horrid.

(cherry picked from commit 40baf0ccfb9a5d54237106c1340eb435540093a2)
Fix addressbook upgrade from pre-SHA1 versions

(cherry picked from commit 7a104f0714f60064a1d3724f5b2267e8c30c4109)
Reduce addressbook refresh interval to 6 hours

GAL update completed successfully in 19139946 µs. Added: 148, Changed: 2485, Unchanged 235459, Removed: 132

Now it doesn't suck interminably, we can do it more often.

(cherry picked from commit fdea7274a46c7475428645baf60779c767e52b2d)
Avoid using dynamic types for ESourceEwsFolder

If we register the same type from two *different* modules, the type
system gets upset. That's precisely what happens if we enable addressbook
DRA, because the addressbook and camel modules both get loaded into the
same process.

So make it a normal static class. We do have to use g_type_ensure()
though, because e_source_get_extension() will look it up by name,
iterating over the child classes of ESourceExtension.

(cherry picked from commit addd8f6c940b2503fc2237f6c6667de2cb41e9c9)
Add revision support for addressbook

When we add cursor support, it'll depend on this...

(cherry picked from commit c8b18a754f29ab592a25f9f192d998c8f1b8b889)
Add locale support for addressbook

When we add cursor support, it'll depend on this...

(cherry picked from commit 588f1b4478d5f72fc93d15be98a993a04065bc10)
Make ebews_fetch_items() return a list of EContacts not EVCards

... and fix up e_book_backend_ews_get_contact_list() to cope.

We'll actually want to ditch the store_to_cache mode of ebews_fetch_items()
and *always* use it to return EContacts, even from ews_update_items_thread().
That way we can do all the network I/O in advance and then do the database
update in a single transaction.

Fix a crash in the database-query code paths in get_contact_list() too while
we're at it. On converting to EBookSqlite, the 'list' variable needed to be
initialised to NULL.

(cherry picked from commit 8827df5cff93d5faf533466144450767581412c4)
Refactor ews_update_items_thread() to do all database access together

Once we start doing locking, we'll want the whole update to happen in
one transaction, so do all the network access first.

(cherry picked from commit 3effacde896ce194d947d96413d3d7e9e4ae6735)
Kill store_to_cache option for ebews_fetch_items()

We don't use this any more...

(cherry picked from commit 524f291028c29bba1820f6f40076f611357068d6)