[bugfixes] Many fixes

This commit includes many fixes, like building libsocialcache
before building the QML plugin (fix a build error), and some
bugfixes for calendar database and image database.