static void e_book_backend_webdav_get_contact (EBookBackend *backend, EDataBook *book, guint32 opid, GCancellable *cancellable, const gchar *uid) { EBookBackendWebdav *webdav = E_BOOK_BACKEND_WEBDAV (backend); EBookBackendWebdavPrivate *priv = webdav->priv; EContact *contact; gchar *vcard; if (!e_backend_get_online (E_BACKEND (backend))) { g_mutex_lock (&priv->cache_lock); contact = e_book_backend_cache_get_contact (priv->cache, uid); g_mutex_unlock (&priv->cache_lock); } else { contact = download_contact (webdav, uid, cancellable); /* update cache as we possibly have changes */ if (contact != NULL) { g_mutex_lock (&priv->cache_lock); e_book_backend_cache_remove_contact (priv->cache, uid); e_book_backend_cache_add_contact (priv->cache, contact); g_mutex_unlock (&priv->cache_lock); } } if (contact == NULL) { e_data_book_respond_get_contact (book, opid, EDB_ERROR (CONTACT_NOT_FOUND), NULL); return; } vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30); e_data_book_respond_get_contact (book, opid, EDB_ERROR (SUCCESS), vcard); g_free (vcard); g_object_unref (contact); }
static void _e_book_backend_get_contact (EBookBackend *backend, EDataBook *book, guint32 opid, const gchar *id) { GError *error = NULL; gchar *vcard = NULL; e_book_backend_sync_get_contact (E_BOOK_BACKEND_SYNC (backend), book, opid, id, &vcard, &error); e_data_book_respond_get_contact (book, opid, error, vcard); if (vcard) g_free (vcard); }