"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/addressbook/backends/file/e-book-backend-file.c" between
evolution-data-server-3.32.4.tar.xz and evolution-data-server-3.34.0.tar.xz

About: Evolution-Data-Server manages access to the calendar, tasks and addressbook information available for Evolution and other applications.

e-book-backend-file.c  (evolution-data-server-3.32.4.tar.xz):e-book-backend-file.c  (evolution-data-server-3.34.0.tar.xz)
skipping to change at line 73 skipping to change at line 73
#define SQLITEDB_FOLDER_ID "folder_id" #define SQLITEDB_FOLDER_ID "folder_id"
#define SQLITE_REVISION_KEY "revision" #define SQLITE_REVISION_KEY "revision"
/* Forward Declarations */ /* Forward Declarations */
static void e_book_backend_file_initable_init static void e_book_backend_file_initable_init
(GInitableIface *iface); (GInitableIface *iface);
G_DEFINE_TYPE_WITH_CODE ( G_DEFINE_TYPE_WITH_CODE (
EBookBackendFile, EBookBackendFile,
e_book_backend_file, e_book_backend_file,
E_TYPE_BOOK_BACKEND, E_TYPE_BOOK_BACKEND_SYNC,
G_IMPLEMENT_INTERFACE ( G_IMPLEMENT_INTERFACE (
G_TYPE_INITABLE, G_TYPE_INITABLE,
e_book_backend_file_initable_init)) e_book_backend_file_initable_init))
struct _EBookBackendFilePrivate { struct _EBookBackendFilePrivate {
gchar *base_directory; gchar *base_directory;
gchar *photo_dirname; gchar *photo_dirname;
gchar *revision; gchar *revision;
gchar *locale; gchar *locale;
volatile gint rev_counter; volatile gint rev_counter;
skipping to change at line 701 skipping to change at line 701
bf->priv->sqlitedb, bf->priv->sqlitedb,
SQLITE_REVISION_KEY, SQLITE_REVISION_KEY,
new_revision, new_revision,
&local_error); &local_error);
if (success) { if (success) {
g_free (bf->priv->revision); g_free (bf->priv->revision);
bf->priv->revision = new_revision; bf->priv->revision = new_revision;
e_book_backend_notify_property_changed (E_BOOK_BACKEND (bf), e_book_backend_notify_property_changed (E_BOOK_BACKEND (bf),
BOOK_BACKEND_PROPERTY_REV ISION, E_BOOK_BACKEND_PROPERTY_R EVISION,
bf->priv->revision); bf->priv->revision);
} else { } else {
g_free (new_revision); g_free (new_revision);
g_warning ( g_warning (
G_STRLOC ": Error setting database revision: %s", G_STRLOC ": Error setting database revision: %s",
local_error->message); local_error->message);
g_propagate_error (error, local_error); g_propagate_error (error, local_error);
} }
return success; return success;
skipping to change at line 800 skipping to change at line 800
/** /**
* This method will return TRUE if all the contacts were properly created. * This method will return TRUE if all the contacts were properly created.
* If at least one contact fails, the method will return FALSE, all * If at least one contact fails, the method will return FALSE, all
* changes will be reverted (the @contacts list will stay empty) and * changes will be reverted (the @contacts list will stay empty) and
* @perror will be set. * @perror will be set.
*/ */
static gboolean static gboolean
do_create (EBookBackendFile *bf, do_create (EBookBackendFile *bf,
const gchar * const *vcards, const gchar * const *vcards,
GQueue *out_contacts, GSList **out_contacts,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
PhotoModifiedStatus status = STATUS_NORMAL; PhotoModifiedStatus status = STATUS_NORMAL;
GQueue queue = G_QUEUE_INIT;
guint ii, length; guint ii, length;
GError *local_error = NULL; GError *local_error = NULL;
length = g_strv_length ((gchar **) vcards); length = g_strv_length ((gchar **) vcards);
for (ii = 0; ii < length; ii++) { for (ii = 0; ii < length; ii++) {
gchar *id; gchar *id;
const gchar *rev; const gchar *rev;
EContact *contact; EContact *contact;
skipping to change at line 834 skipping to change at line 833
rev = e_contact_get_const (contact, E_CONTACT_REV); rev = e_contact_get_const (contact, E_CONTACT_REV);
if (!(rev && *rev)) if (!(rev && *rev))
set_revision (bf, contact); set_revision (bf, contact);
status = maybe_transform_vcard_for_photo (bf, NULL, contact, erro r); status = maybe_transform_vcard_for_photo (bf, NULL, contact, erro r);
if (status != STATUS_ERROR) { if (status != STATUS_ERROR) {
/* Contact was added successfully. */ /* Contact was added successfully. */
g_queue_push_tail (&queue, contact); *out_contacts = g_slist_prepend (*out_contacts, contact);
} else { } else {
/* Contact could not be transformed */ /* Contact could not be transformed */
g_warning ( g_warning (
G_STRLOC ": Error transforming vcard with image d ata %s", G_STRLOC ": Error transforming vcard with image d ata %s",
(error && *error) ? (*error)->message : (error && *error) ? (*error)->message :
"Unknown error transforming vcard"); "Unknown error transforming vcard");
g_object_unref (contact); g_object_unref (contact);
/* Abort as soon as an error occurs */ /* Abort as soon as an error occurs */
break; break;
} }
} }
if (status != STATUS_ERROR) { if (status != STATUS_ERROR) {
GList *tail, *link; GSList *link;
GSList *slist = NULL, *l;
/* EBookSqlite uses GSList. */
tail = g_queue_peek_tail_link (&queue);
for (link = tail; link != NULL; link = g_list_previous (link))
slist = g_slist_prepend (slist, link->data);
if (!e_book_sqlite_add_contacts (bf->priv->sqlitedb, if (!e_book_sqlite_add_contacts (bf->priv->sqlitedb,
slist, NULL, FALSE, *out_contacts, NULL, FALSE,
cancellable, cancellable,
&local_error)) { &local_error)) {
if (g_error_matches (local_error, if (g_error_matches (local_error,
E_BOOK_SQLITE_ERROR, E_BOOK_SQLITE_ERROR,
E_BOOK_SQLITE_ERROR_CONSTRAINT)) { E_BOOK_SQLITE_ERROR_CONSTRAINT)) {
g_set_error ( g_set_error (
error, E_BOOK_CLIENT_ERROR, error, E_BOOK_CLIENT_ERROR,
E_BOOK_CLIENT_ERROR_CONTACT_ID_ALREADY_EX ISTS, E_BOOK_CLIENT_ERROR_CONTACT_ID_ALREADY_EX ISTS,
_("Conflicting UIDs found in added contac ts")); _("Conflicting UIDs found in added contac ts"));
g_clear_error (&local_error); g_clear_error (&local_error);
} else { } else {
g_warning ("Failed to add contacts: %s", local_er ror->message); g_warning ("Failed to add contacts: %s", local_er ror->message);
g_propagate_error (error, local_error); g_propagate_error (error, local_error);
} }
status = STATUS_ERROR; status = STATUS_ERROR;
} }
/* After adding any contacts, notify any cursors that the new con tacts are added */ /* After adding any contacts, notify any cursors that the new con tacts are added */
for (l = slist; l; l = l->next) { for (link = *out_contacts; link; link = g_slist_next (link)) {
cursors_contact_added (bf, E_CONTACT (l->data)); cursors_contact_added (bf, link->data);
} }
g_slist_free (slist);
} }
if (status != STATUS_ERROR && out_contacts != NULL)
e_queue_transfer (&queue, out_contacts);
while (!g_queue_is_empty (&queue))
g_object_unref (g_queue_pop_head (&queue));
return (status != STATUS_ERROR); return (status != STATUS_ERROR);
} }
typedef struct { typedef struct {
EBookBackendFile *bf; EBookBackendFile *bf;
GThread *thread; GThread *thread;
EFlag *running; EFlag *running;
} FileBackendSearchClosure; } FileBackendSearchClosure;
static void static void
skipping to change at line 1114 skipping to change at line 1099
book_backend_file_get_backend_property (EBookBackend *backend, book_backend_file_get_backend_property (EBookBackend *backend,
const gchar *prop_name) const gchar *prop_name)
{ {
EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend); EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend);
g_return_val_if_fail (prop_name != NULL, NULL); g_return_val_if_fail (prop_name != NULL, NULL);
if (g_str_equal (prop_name, CLIENT_BACKEND_PROPERTY_CAPABILITIES)) { if (g_str_equal (prop_name, CLIENT_BACKEND_PROPERTY_CAPABILITIES)) {
return g_strdup ("local,do-initial-query,bulk-adds,bulk-modifies, bulk-removes,contact-lists"); return g_strdup ("local,do-initial-query,bulk-adds,bulk-modifies, bulk-removes,contact-lists");
} else if (g_str_equal (prop_name, BOOK_BACKEND_PROPERTY_REQUIRED_FIELDS) ) { } else if (g_str_equal (prop_name, E_BOOK_BACKEND_PROPERTY_REQUIRED_FIELD S)) {
return g_strdup (e_contact_field_name (E_CONTACT_FILE_AS)); return g_strdup (e_contact_field_name (E_CONTACT_FILE_AS));
} else if (g_str_equal (prop_name, BOOK_BACKEND_PROPERTY_SUPPORTED_FIELDS )) { } else if (g_str_equal (prop_name, E_BOOK_BACKEND_PROPERTY_SUPPORTED_FIEL DS)) {
GString *fields; GString *fields;
gint ii; gint ii;
fields = g_string_sized_new (1024); fields = g_string_sized_new (1024);
/* XXX we need a way to say "we support everything", since the /* XXX we need a way to say "we support everything", since the
* file backend does */ * file backend does */
for (ii = 1; ii < E_CONTACT_FIELD_LAST; ii++) { for (ii = 1; ii < E_CONTACT_FIELD_LAST; ii++) {
if (fields->len > 0) if (fields->len > 0)
g_string_append_c (fields, ','); g_string_append_c (fields, ',');
g_string_append (fields, e_contact_field_name (ii)); g_string_append (fields, e_contact_field_name (ii));
} }
return g_string_free (fields, FALSE); return g_string_free (fields, FALSE);
} else if (g_str_equal (prop_name, BOOK_BACKEND_PROPERTY_REVISION)) { } else if (g_str_equal (prop_name, E_BOOK_BACKEND_PROPERTY_REVISION)) {
gchar *prop_value; gchar *prop_value;
g_rw_lock_reader_lock (&(bf->priv->lock)); g_rw_lock_reader_lock (&(bf->priv->lock));
prop_value = g_strdup (bf->priv->revision); prop_value = g_strdup (bf->priv->revision);
g_rw_lock_reader_unlock (&(bf->priv->lock)); g_rw_lock_reader_unlock (&(bf->priv->lock));
return prop_value; return prop_value;
} }
/* Chain up to parent's get_backend_property() method. */ /* Chain up to parent's method. */
return E_BOOK_BACKEND_CLASS (e_book_backend_file_parent_class)-> return E_BOOK_BACKEND_CLASS (e_book_backend_file_parent_class)->impl_get_
get_backend_property (backend, prop_name); backend_property (backend, prop_name);
} }
static gboolean static gboolean
book_backend_file_open_sync (EBookBackend *backend, book_backend_file_open_sync (EBookBackendSync *backend,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend); EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend);
ESource *source; ESource *source;
ESourceRevisionGuards *guards; ESourceRevisionGuards *guards;
source = e_backend_get_source (E_BACKEND (backend)); source = e_backend_get_source (E_BACKEND (backend));
/* Local source is always connected. */ /* Local source is always connected. */
skipping to change at line 1172 skipping to change at line 1156
g_type_ensure (E_TYPE_SOURCE_REVISION_GUARDS); g_type_ensure (E_TYPE_SOURCE_REVISION_GUARDS);
guards = e_source_get_extension (source, E_SOURCE_EXTENSION_REVISION_GUAR DS); guards = e_source_get_extension (source, E_SOURCE_EXTENSION_REVISION_GUAR DS);
bf->priv->revision_guards = e_source_revision_guards_get_enabled (guards) ; bf->priv->revision_guards = e_source_revision_guards_get_enabled (guards) ;
g_rw_lock_writer_lock (&(bf->priv->lock)); g_rw_lock_writer_lock (&(bf->priv->lock));
if (!bf->priv->revision) { if (!bf->priv->revision) {
e_book_backend_file_load_revision (bf); e_book_backend_file_load_revision (bf);
e_book_backend_notify_property_changed ( e_book_backend_notify_property_changed (
E_BOOK_BACKEND (backend), E_BOOK_BACKEND (backend),
BOOK_BACKEND_PROPERTY_REVISION, E_BOOK_BACKEND_PROPERTY_REVISION,
bf->priv->revision); bf->priv->revision);
} }
g_rw_lock_writer_unlock (&(bf->priv->lock)); g_rw_lock_writer_unlock (&(bf->priv->lock));
e_backend_set_online (E_BACKEND (backend), TRUE); e_backend_set_online (E_BACKEND (backend), TRUE);
e_book_backend_set_writable (E_BOOK_BACKEND (backend), TRUE); e_book_backend_set_writable (E_BOOK_BACKEND (backend), TRUE);
return TRUE; return TRUE;
} }
static gboolean static gboolean
book_backend_file_create_contacts_sync (EBookBackend *backend, book_backend_file_create_contacts_sync (EBookBackendSync *backend,
const gchar * const *vcards, const gchar * const *vcards,
GQueue *out_contacts, guint32 opflags,
GCancellable *cancellable, GSList **out_contacts,
GError **error) GCancellable *cancellable,
GError **error)
{ {
EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend); EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend);
gboolean success = FALSE; gboolean success = FALSE;
g_return_val_if_fail (out_contacts != NULL, FALSE);
*out_contacts = NULL;
g_rw_lock_writer_lock (&(bf->priv->lock)); g_rw_lock_writer_lock (&(bf->priv->lock));
if (!e_book_sqlite_lock (bf->priv->sqlitedb, if (!e_book_sqlite_lock (bf->priv->sqlitedb,
EBSQL_LOCK_WRITE, EBSQL_LOCK_WRITE,
cancellable, error)) { cancellable, error)) {
g_rw_lock_writer_unlock (&(bf->priv->lock)); g_rw_lock_writer_unlock (&(bf->priv->lock));
return FALSE; return FALSE;
} }
success = do_create (bf, vcards, out_contacts, cancellable, error); success = do_create (bf, vcards, out_contacts, cancellable, error);
if (success) {
*out_contacts = g_slist_reverse (*out_contacts);
} else {
g_slist_free_full (*out_contacts, g_object_unref);
*out_contacts = NULL;
}
if (success) if (success)
success = e_book_backend_file_bump_revision (bf, error); success = e_book_backend_file_bump_revision (bf, error);
if (success) if (success)
success = e_book_sqlite_unlock ( success = e_book_sqlite_unlock (
bf->priv->sqlitedb, bf->priv->sqlitedb,
EBSQL_UNLOCK_COMMIT, EBSQL_UNLOCK_COMMIT,
error); error);
else { else {
GError *local_error = NULL; GError *local_error = NULL;
skipping to change at line 1235 skipping to change at line 1231
g_clear_error (&local_error); g_clear_error (&local_error);
} }
} }
g_rw_lock_writer_unlock (&(bf->priv->lock)); g_rw_lock_writer_unlock (&(bf->priv->lock));
return success; return success;
} }
static gboolean static gboolean
book_backend_file_modify_contacts_sync (EBookBackend *backend, book_backend_file_modify_contacts_sync (EBookBackendSync *backend,
const gchar * const *vcards, const gchar * const *vcards,
GQueue *out_contacts, guint32 opflags,
GCancellable *cancellable, GSList **out_contacts,
GError **error) GCancellable *cancellable,
GError **error)
{ {
EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend); EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend);
GSList *ids = NULL; GSList *ids = NULL;
GError *local_error = NULL; GError *local_error = NULL;
PhotoModifiedStatus status = STATUS_NORMAL; PhotoModifiedStatus status = STATUS_NORMAL;
GQueue old_contact_queue = G_QUEUE_INIT; GSList *old_contacts = NULL;
GQueue mod_contact_queue = G_QUEUE_INIT;
guint ii, length; guint ii, length;
length = g_strv_length ((gchar **) vcards); length = g_strv_length ((gchar **) vcards);
g_rw_lock_writer_lock (&(bf->priv->lock)); g_rw_lock_writer_lock (&(bf->priv->lock));
if (!e_book_sqlite_lock (bf->priv->sqlitedb, EBSQL_LOCK_WRITE, cancellabl e, error)) { if (!e_book_sqlite_lock (bf->priv->sqlitedb, EBSQL_LOCK_WRITE, cancellabl e, error)) {
g_rw_lock_writer_unlock (&(bf->priv->lock)); g_rw_lock_writer_unlock (&(bf->priv->lock));
return FALSE; return FALSE;
} }
skipping to change at line 1328 skipping to change at line 1324
g_free (id); g_free (id);
g_object_unref (old_contact); g_object_unref (old_contact);
g_object_unref (mod_contact); g_object_unref (mod_contact);
break; break;
} }
/* update the revision (modified time of contact) */ /* update the revision (modified time of contact) */
set_revision (bf, mod_contact); set_revision (bf, mod_contact);
g_queue_push_tail (&old_contact_queue, old_contact); old_contacts = g_slist_prepend (old_contacts, old_contact);
g_queue_push_tail (&mod_contact_queue, mod_contact); *out_contacts = g_slist_prepend (*out_contacts, mod_contact);
ids = g_slist_prepend (ids, id); ids = g_slist_prepend (ids, id);
} }
if (status != STATUS_ERROR) { if (status != STATUS_ERROR) {
GList *old_link; GSList *old_link, *mod_link;
GList *mod_link;
GSList *slist = NULL;
/* Delete old photo file uris if need be (this will compare the n ew contact /* Delete old photo file uris if need be (this will compare the n ew contact
* with the current copy in the BDB to extract the uris to delete ) */ * with the current copy in the BDB to extract the uris to delete ) */
old_link = g_queue_peek_head_link (&old_contact_queue); old_link = old_contacts;
mod_link = g_queue_peek_head_link (&mod_contact_queue); mod_link = *out_contacts;
while (old_link != NULL && mod_link != NULL) { while (old_link != NULL && mod_link != NULL) {
maybe_delete_unused_uris ( maybe_delete_unused_uris (
bf, bf,
E_CONTACT (old_link->data), E_CONTACT (old_link->data),
E_CONTACT (mod_link->data)); E_CONTACT (mod_link->data));
old_link = g_list_next (old_link); old_link = g_slist_next (old_link);
mod_link = g_list_next (mod_link); mod_link = g_slist_next (mod_link);
}
/* EBookSqlite uses GSList. */
mod_link = g_queue_peek_tail_link (&mod_contact_queue);
while (mod_link != NULL) {
slist = g_slist_prepend (slist, mod_link->data);
mod_link = g_list_previous (mod_link);
} }
/* Update summary as well */ /* Update summary as well */
e_book_sqlite_add_contacts ( e_book_sqlite_add_contacts (
bf->priv->sqlitedb, bf->priv->sqlitedb,
slist, NULL, TRUE, *out_contacts, NULL, TRUE,
cancellable, &local_error); cancellable, &local_error);
if (local_error != NULL) { if (local_error != NULL) {
g_warning ( g_warning (
"Failed to modify contacts: %s", "Failed to modify contacts: %s",
local_error->message); local_error->message);
g_propagate_error (error, local_error); g_propagate_error (error, local_error);
local_error = NULL; local_error = NULL;
status = STATUS_ERROR; status = STATUS_ERROR;
} }
g_slist_free (slist);
} }
/* Bump the revision atomically in the same transaction */ /* Bump the revision atomically in the same transaction */
if (status != STATUS_ERROR) { if (status != STATUS_ERROR) {
if (!e_book_backend_file_bump_revision (bf, error)) if (!e_book_backend_file_bump_revision (bf, error))
status = STATUS_ERROR; status = STATUS_ERROR;
} }
/* Commit or rollback transaction */ /* Commit or rollback transaction */
if (status != STATUS_ERROR) { if (status != STATUS_ERROR) {
skipping to change at line 1412 skipping to change at line 1397
if (local_error != NULL) { if (local_error != NULL) {
g_warning ( g_warning (
"Failed to rollback transaction after " "Failed to rollback transaction after "
"failing to modify contacts: %s", "failing to modify contacts: %s",
local_error->message); local_error->message);
g_clear_error (&local_error); g_clear_error (&local_error);
} }
} }
if (status != STATUS_ERROR) if (status != STATUS_ERROR) {
e_queue_transfer (&mod_contact_queue, out_contacts); *out_contacts = g_slist_reverse (*out_contacts);
} else {
g_slist_free_full (*out_contacts, g_object_unref);
*out_contacts = NULL;
}
/* Now that we've modified the contact(s), /* Now that we've modified the contact(s),
* notify cursors of the changes. */ * notify cursors of the changes. */
if (status != STATUS_ERROR) { if (status != STATUS_ERROR) {
GList *l; GSList *link;
for (l = g_queue_peek_head_link (&old_contact_queue); for (link = old_contacts; link; link = g_slist_next (link)) {
l; l = l->next) { cursors_contact_removed (bf, E_CONTACT (link->data));
cursors_contact_removed (bf, E_CONTACT (l->data));
} }
for (l = g_queue_peek_head_link (&mod_contact_queue); for (link = *out_contacts; link; link = g_slist_next (*out_contac
l; l = l->next) { ts)) {
cursors_contact_added (bf, E_CONTACT (l->data)); cursors_contact_added (bf, E_CONTACT (link->data));
} }
} }
g_rw_lock_writer_unlock (&(bf->priv->lock)); g_rw_lock_writer_unlock (&(bf->priv->lock));
while (!g_queue_is_empty (&old_contact_queue)) g_slist_free_full (old_contacts, g_object_unref);
g_object_unref (g_queue_pop_head (&old_contact_queue)); g_slist_free_full (ids, g_free);
while (!g_queue_is_empty (&mod_contact_queue))
g_object_unref (g_queue_pop_head (&mod_contact_queue));
g_slist_free_full (ids, (GDestroyNotify) g_free);
return (status != STATUS_ERROR); return (status != STATUS_ERROR);
} }
static gboolean static gboolean
book_backend_file_remove_contacts_sync (EBookBackend *backend, book_backend_file_remove_contacts_sync (EBookBackendSync *backend,
const gchar * const *uids, const gchar * const *uids,
GCancellable *cancellable, guint32 opflags,
GError **error) GSList **out_removed_uids,
GCancellable *cancellable,
GError **error)
{ {
EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend); EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend);
GSList *removed_ids = NULL, *removed_contacts = NULL; GSList *removed_ids = NULL, *removed_contacts = NULL;
GError *local_error = NULL; GError *local_error = NULL;
const GSList *l; const GSList *l;
gboolean success = TRUE; gboolean success = TRUE;
guint ii, length; guint ii, length;
g_return_val_if_fail (out_removed_uids != NULL, FALSE);
length = g_strv_length ((gchar **) uids); length = g_strv_length ((gchar **) uids);
g_rw_lock_writer_lock (&(bf->priv->lock)); g_rw_lock_writer_lock (&(bf->priv->lock));
if (!e_book_sqlite_lock (bf->priv->sqlitedb, if (!e_book_sqlite_lock (bf->priv->sqlitedb,
EBSQL_LOCK_WRITE, EBSQL_LOCK_WRITE,
cancellable, error)) { cancellable, error)) {
g_rw_lock_writer_unlock (&(bf->priv->lock)); g_rw_lock_writer_unlock (&(bf->priv->lock));
return FALSE; return FALSE;
} }
skipping to change at line 1543 skipping to change at line 1529
} }
} }
/* After removing any contacts, notify any cursors that the new contacts are added */ /* After removing any contacts, notify any cursors that the new contacts are added */
if (success) { if (success) {
for (l = removed_contacts; l; l = l->next) { for (l = removed_contacts; l; l = l->next) {
cursors_contact_removed (bf, E_CONTACT (l->data)); cursors_contact_removed (bf, E_CONTACT (l->data));
} }
} }
*out_removed_uids = removed_ids;
g_rw_lock_writer_unlock (&(bf->priv->lock)); g_rw_lock_writer_unlock (&(bf->priv->lock));
g_slist_free_full (removed_ids, (GDestroyNotify) g_free);
g_slist_free_full (removed_contacts, (GDestroyNotify) g_object_unref); g_slist_free_full (removed_contacts, (GDestroyNotify) g_object_unref);
return success; return success;
} }
static EContact * static EContact *
book_backend_file_get_contact_sync (EBookBackend *backend, book_backend_file_get_contact_sync (EBookBackendSync *backend,
const gchar *uid, const gchar *uid,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend); EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend);
EContact *contact = NULL; EContact *contact = NULL;
gboolean success; gboolean success;
GError *local_error = NULL; GError *local_error = NULL;
g_rw_lock_reader_lock (&(bf->priv->lock)); g_rw_lock_reader_lock (&(bf->priv->lock));
skipping to change at line 1586 skipping to change at line 1573
_("Contact “%s” not found"), uid); _("Contact “%s” not found"), uid);
g_error_free (local_error); g_error_free (local_error);
} else } else
g_propagate_error (error, local_error); g_propagate_error (error, local_error);
} }
return contact; return contact;
} }
static gboolean static gboolean
book_backend_file_get_contact_list_sync (EBookBackend *backend, book_backend_file_get_contact_list_sync (EBookBackendSync *backend,
const gchar *query, const gchar *query,
GQueue *out_contacts, GSList **out_contacts,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend); EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend);
GSList *summary_list = NULL; GSList *summary_list = NULL;
GSList *link; GSList *link;
gboolean success = TRUE; gboolean success = TRUE;
GError *local_error = NULL; GError *local_error = NULL;
g_return_val_if_fail (out_contacts != NULL, FALSE);
*out_contacts = NULL;
d (printf ("book_backend_file_get_contact_list_sync (%s)\n", query)); d (printf ("book_backend_file_get_contact_list_sync (%s)\n", query));
g_rw_lock_reader_lock (&(bf->priv->lock)); g_rw_lock_reader_lock (&(bf->priv->lock));
success = e_book_sqlite_lock ( success = e_book_sqlite_lock (
bf->priv->sqlitedb, bf->priv->sqlitedb,
EBSQL_LOCK_READ, EBSQL_LOCK_READ,
cancellable, error); cancellable, error);
if (!success) { if (!success) {
g_rw_lock_writer_unlock (&(bf->priv->lock)); g_rw_lock_writer_unlock (&(bf->priv->lock));
skipping to change at line 1659 skipping to change at line 1650
g_warning ("Failed to fetch contact ids: %s", local_error ->message); g_warning ("Failed to fetch contact ids: %s", local_error ->message);
g_propagate_error (error, local_error); g_propagate_error (error, local_error);
} }
} }
for (link = summary_list; link != NULL; link = g_slist_next (link)) { for (link = summary_list; link != NULL; link = g_slist_next (link)) {
EbSqlSearchData *data = link->data; EbSqlSearchData *data = link->data;
EContact *contact; EContact *contact;
contact = e_contact_new_from_vcard (data->vcard); contact = e_contact_new_from_vcard (data->vcard);
g_queue_push_tail (out_contacts, contact); link->data = contact;
e_book_sqlite_search_data_free (data);
} }
g_slist_free_full ( *out_contacts = summary_list;
summary_list, (GDestroyNotify)
e_book_sqlite_search_data_free);
return success; return success;
} }
static gboolean static gboolean
book_backend_file_get_contact_list_uids_sync (EBookBackend *backend, book_backend_file_get_contact_list_uids_sync (EBookBackendSync *backend,
const gchar *query, const gchar *query,
GQueue *out_uids, GSList **out_uids,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend); EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend);
GSList *uids = NULL;
GSList *link;
gboolean success = TRUE; gboolean success = TRUE;
GError *local_error = NULL; GError *local_error = NULL;
g_return_val_if_fail (out_uids != NULL, FALSE);
*out_uids = NULL;
d (printf ("book_backend_file_get_contact_list_sync (%s)\n", query)); d (printf ("book_backend_file_get_contact_list_sync (%s)\n", query));
g_rw_lock_reader_lock (&(bf->priv->lock)); g_rw_lock_reader_lock (&(bf->priv->lock));
success = e_book_sqlite_lock ( success = e_book_sqlite_lock (
bf->priv->sqlitedb, bf->priv->sqlitedb,
EBSQL_LOCK_READ, EBSQL_LOCK_READ,
cancellable, error); cancellable, error);
if (!success) { if (!success) {
g_rw_lock_writer_unlock (&(bf->priv->lock)); g_rw_lock_writer_unlock (&(bf->priv->lock));
return FALSE; return FALSE;
} }
success = e_book_sqlite_search_uids ( success = e_book_sqlite_search_uids (
bf->priv->sqlitedb, bf->priv->sqlitedb,
query, query,
&uids, out_uids,
cancellable, cancellable,
&local_error); &local_error);
e_book_sqlite_unlock ( e_book_sqlite_unlock (
bf->priv->sqlitedb, bf->priv->sqlitedb,
EBSQL_UNLOCK_NONE, EBSQL_UNLOCK_NONE,
success ? &local_error : NULL); success ? &local_error : NULL);
g_rw_lock_reader_unlock (&(bf->priv->lock)); g_rw_lock_reader_unlock (&(bf->priv->lock));
if (!success) { if (!success) {
g_warn_if_fail (uids == NULL); g_warn_if_fail (*out_uids == NULL);
if (g_error_matches (local_error, if (g_error_matches (local_error,
E_BOOK_SQLITE_ERROR, E_BOOK_SQLITE_ERROR,
E_BOOK_SQLITE_ERROR_UNSUPPORTED_QUERY)) { E_BOOK_SQLITE_ERROR_UNSUPPORTED_QUERY)) {
g_set_error ( g_set_error (
error, E_CLIENT_ERROR, error, E_CLIENT_ERROR,
E_CLIENT_ERROR_NOT_SUPPORTED, E_CLIENT_ERROR_NOT_SUPPORTED,
_("Query “%s” not supported"), query); _("Query “%s” not supported"), query);
g_error_free (local_error); g_error_free (local_error);
skipping to change at line 1737 skipping to change at line 1730
g_error_free (local_error); g_error_free (local_error);
} else { } else {
g_warning ( g_warning (
"Failed to fetch contact ids: %s", "Failed to fetch contact ids: %s",
local_error->message); local_error->message);
g_propagate_error (error, local_error); g_propagate_error (error, local_error);
} }
} }
/* Transfer UID strings to the GQueue. */
for (link = uids; link != NULL; link = g_slist_next (link))
g_queue_push_tail (out_uids, link->data);
g_slist_free (uids);
return success; return success;
} }
static void static void
book_backend_file_start_view (EBookBackend *backend, book_backend_file_start_view (EBookBackend *backend,
EDataBookView *book_view) EDataBookView *book_view)
{ {
FileBackendSearchClosure *closure; FileBackendSearchClosure *closure;
closure = init_closure (book_view, E_BOOK_BACKEND_FILE (backend)); closure = init_closure (book_view, E_BOOK_BACKEND_FILE (backend));
skipping to change at line 1829 skipping to change at line 1816
book_backend_file_configure_direct (EBookBackend *backend, book_backend_file_configure_direct (EBookBackend *backend,
const gchar *config) const gchar *config)
{ {
EBookBackendFilePrivate *priv; EBookBackendFilePrivate *priv;
priv = E_BOOK_BACKEND_FILE_GET_PRIVATE (backend); priv = E_BOOK_BACKEND_FILE_GET_PRIVATE (backend);
priv->base_directory = g_strdup (config); priv->base_directory = g_strdup (config);
} }
static void static void
book_backend_file_sync (EBookBackend *backend)
{
EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend);
g_return_if_fail (bf != NULL);
/* FIXME: Tell sqlite to dump NOW ! */
}
static void
book_backend_file_vcard_changed (EbSqlChangeType change_type, book_backend_file_vcard_changed (EbSqlChangeType change_type,
const gchar *uid, const gchar *uid,
const gchar *extra, const gchar *extra,
const gchar *vcard, const gchar *vcard,
gpointer user_data) gpointer user_data)
{ {
EBookBackend *backend = E_BOOK_BACKEND (user_data); EBookBackend *backend = E_BOOK_BACKEND (user_data);
EContact *contact; EContact *contact;
if (change_type == EBSQL_CHANGE_LOCALE_CHANGED) { if (change_type == EBSQL_CHANGE_LOCALE_CHANGED) {
skipping to change at line 2146 skipping to change at line 2123
#endif /* HAVE_LIBDB */ #endif /* HAVE_LIBDB */
return success; return success;
} }
static void static void
e_book_backend_file_class_init (EBookBackendFileClass *class) e_book_backend_file_class_init (EBookBackendFileClass *class)
{ {
GObjectClass *object_class; GObjectClass *object_class;
EBookBackendClass *backend_class; EBookBackendClass *backend_class;
EBookBackendSyncClass *backend_sync_class;
g_type_class_add_private (class, sizeof (EBookBackendFilePrivate)); g_type_class_add_private (class, sizeof (EBookBackendFilePrivate));
object_class = G_OBJECT_CLASS (class); object_class = G_OBJECT_CLASS (class);
object_class->dispose = book_backend_file_dispose; object_class->dispose = book_backend_file_dispose;
object_class->finalize = book_backend_file_finalize; object_class->finalize = book_backend_file_finalize;
backend_sync_class = E_BOOK_BACKEND_SYNC_CLASS (class);
backend_sync_class->open_sync = book_backend_file_open_sync;
backend_sync_class->create_contacts_sync = book_backend_file_create_conta
cts_sync;
backend_sync_class->modify_contacts_sync = book_backend_file_modify_conta
cts_sync;
backend_sync_class->remove_contacts_sync = book_backend_file_remove_conta
cts_sync;
backend_sync_class->get_contact_sync = book_backend_file_get_contact_sync
;
backend_sync_class->get_contact_list_sync = book_backend_file_get_contact
_list_sync;
backend_sync_class->get_contact_list_uids_sync = book_backend_file_get_co
ntact_list_uids_sync;
backend_class = E_BOOK_BACKEND_CLASS (class); backend_class = E_BOOK_BACKEND_CLASS (class);
backend_class->get_backend_property = book_backend_file_get_backend_prope backend_class->impl_get_backend_property = book_backend_file_get_backend_
rty; property;
backend_class->open_sync = book_backend_file_open_sync; backend_class->impl_start_view = book_backend_file_start_view;
backend_class->create_contacts_sync = book_backend_file_create_contacts_s backend_class->impl_stop_view = book_backend_file_stop_view;
ync; backend_class->impl_get_direct_book = book_backend_file_get_direct_book;
backend_class->modify_contacts_sync = book_backend_file_modify_contacts_s backend_class->impl_configure_direct = book_backend_file_configure_direct
ync; ;
backend_class->remove_contacts_sync = book_backend_file_remove_contacts_s backend_class->impl_set_locale = book_backend_file_set_locale;
ync; backend_class->impl_dup_locale = book_backend_file_dup_locale;
backend_class->get_contact_sync = book_backend_file_get_contact_sync; backend_class->impl_create_cursor = book_backend_file_create_cursor;
backend_class->get_contact_list_sync = book_backend_file_get_contact_list backend_class->impl_delete_cursor = book_backend_file_delete_cursor;
_sync;
backend_class->get_contact_list_uids_sync = book_backend_file_get_contact
_list_uids_sync;
backend_class->start_view = book_backend_file_start_view;
backend_class->stop_view = book_backend_file_stop_view;
backend_class->get_direct_book = book_backend_file_get_direct_book;
backend_class->configure_direct = book_backend_file_configure_direct;
backend_class->sync = book_backend_file_sync;
backend_class->set_locale = book_backend_file_set_locale;
backend_class->dup_locale = book_backend_file_dup_locale;
backend_class->create_cursor = book_backend_file_create_cursor;
backend_class->delete_cursor = book_backend_file_delete_cursor;
} }
static void static void
e_book_backend_file_initable_init (GInitableIface *iface) e_book_backend_file_initable_init (GInitableIface *iface)
{ {
iface->init = book_backend_file_initable_init; iface->init = book_backend_file_initable_init;
} }
static void static void
e_book_backend_file_init (EBookBackendFile *backend) e_book_backend_file_init (EBookBackendFile *backend)
 End of changes. 53 change blocks. 
135 lines changed or deleted 118 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)