libedataserver: Make ECategories thread safe

Previously it was not, and could potentially be used from multiple
threads simultaneously (e.g. the main UI thread, plus a contacts backend
thread).

Introduce a static global lock on the categories variables, which
prevents most race conditions. Two functions are inherently unsafe, due
to returning pointers to internal data structures. These functions have
been deprecated and replacements introduced.

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