|
|
gboolean is_cache_ready; | gboolean is_cache_ready; |
gboolean marked_for_offline; | gboolean marked_for_offline; |
| |
GMutex *create_mutex; |
GMutex *cache_lock; |
| |
EBookBackendSummary *summary; | EBookBackendSummary *summary; |
EBookBackendCache *cache; | EBookBackendCache *cache; |
}; | }; |
| |
|
#define LOCK(x) g_mutex_lock (x->cache_lock) |
|
#define UNLOCK(x) g_mutex_unlock (x->cache_lock) |
|
|
typedef struct PropMapping PropMapping; | typedef struct PropMapping PropMapping; |
| |
static void subscription_notify (E2kContext *ctx, const char *uri, E2kContextChangeType type, gpointer user_data); | static void subscription_notify (E2kContext *ctx, const char *uri, E2kContextChangeType type, gpointer user_data); |
|
|
field_names, n_field_names, | field_names, n_field_names, |
bepriv->base_rn, NULL, TRUE); | bepriv->base_rn, NULL, TRUE); |
| |
|
LOCK (bepriv); |
e_file_cache_freeze_changes (E_FILE_CACHE (bepriv->cache)); | e_file_cache_freeze_changes (E_FILE_CACHE (bepriv->cache)); |
while ((result = e2k_result_iter_next (iter))) { | while ((result = e2k_result_iter_next (iter))) { |
contact = e_contact_from_props (be, result); | contact = e_contact_from_props (be, result); |
|
|
e_book_backend_cache_set_populated (bepriv->cache); | e_book_backend_cache_set_populated (bepriv->cache); |
bepriv->is_cache_ready=TRUE; | bepriv->is_cache_ready=TRUE; |
e_file_cache_thaw_changes (E_FILE_CACHE (bepriv->cache)); | e_file_cache_thaw_changes (E_FILE_CACHE (bepriv->cache)); |
|
UNLOCK (bepriv); |
return NULL; | return NULL; |
} | } |
| |
|
|
field_names, n_field_names, | field_names, n_field_names, |
bepriv->base_rn, NULL, TRUE); | bepriv->base_rn, NULL, TRUE); |
| |
|
LOCK (bepriv); |
e_file_cache_freeze_changes (E_FILE_CACHE (bepriv->cache)); | e_file_cache_freeze_changes (E_FILE_CACHE (bepriv->cache)); |
while ((result = e2k_result_iter_next (iter))) { | while ((result = e2k_result_iter_next (iter))) { |
contact = e_contact_from_props (be, result); | contact = e_contact_from_props (be, result); |
|
|
e_book_backend_cache_set_populated (bepriv->cache); | e_book_backend_cache_set_populated (bepriv->cache); |
bepriv->is_cache_ready=TRUE; | bepriv->is_cache_ready=TRUE; |
e_file_cache_thaw_changes (E_FILE_CACHE (bepriv->cache)); | e_file_cache_thaw_changes (E_FILE_CACHE (bepriv->cache)); |
|
UNLOCK (bepriv); |
return TRUE; | return TRUE; |
} | } |
| |
|
|
| |
d(printf("ebbe_create_contact(%p, %p, %s)\n", backend, book, vcard)); | d(printf("ebbe_create_contact(%p, %p, %s)\n", backend, book, vcard)); |
| |
g_mutex_lock (bepriv->create_mutex); |
LOCK (bepriv); |
| |
switch (bepriv->mode) { | switch (bepriv->mode) { |
| |
case GNOME_Evolution_Addressbook_MODE_LOCAL: | case GNOME_Evolution_Addressbook_MODE_LOCAL: |
*contact = NULL; | *contact = NULL; |
g_mutex_unlock (bepriv->create_mutex); |
UNLOCK (bepriv); |
return GNOME_Evolution_Addressbook_RepositoryOffline; | return GNOME_Evolution_Addressbook_RepositoryOffline; |
| |
case GNOME_Evolution_Addressbook_MODE_REMOTE: | case GNOME_Evolution_Addressbook_MODE_REMOTE: |
|
|
state = e_book_backend_exchange_connect (be); | state = e_book_backend_exchange_connect (be); |
if ( state != GNOME_Evolution_Addressbook_Success) { | if ( state != GNOME_Evolution_Addressbook_Success) { |
d(printf("Returning status %d while creating contact\n", state)); | d(printf("Returning status %d while creating contact\n", state)); |
|
UNLOCK (bepriv); |
return state; | return state; |
} | } |
} | } |
|
|
e_book_backend_summary_add_contact (bepriv->summary, | e_book_backend_summary_add_contact (bepriv->summary, |
*contact); | *contact); |
e_book_backend_cache_add_contact (bepriv->cache, *contact); | e_book_backend_cache_add_contact (bepriv->cache, *contact); |
g_mutex_unlock (bepriv->create_mutex); |
UNLOCK (bepriv); |
return GNOME_Evolution_Addressbook_Success; | return GNOME_Evolution_Addressbook_Success; |
} else { | } else { |
g_object_unref (*contact); | g_object_unref (*contact); |
*contact = NULL; | *contact = NULL; |
g_mutex_unlock (bepriv->create_mutex); |
UNLOCK (bepriv); |
return http_status_to_pas (status); | return http_status_to_pas (status); |
} | } |
default: | default: |
break; | break; |
} | } |
g_mutex_unlock (bepriv->create_mutex); |
UNLOCK (bepriv); |
return GNOME_Evolution_Addressbook_Success; | return GNOME_Evolution_Addressbook_Success; |
} | } |
| |
|
|
e2k_results_free (results, nresults); | e2k_results_free (results, nresults); |
| |
if (E2K_HTTP_STATUS_IS_SUCCESSFUL (status)) { | if (E2K_HTTP_STATUS_IS_SUCCESSFUL (status)) { |
|
LOCK (bepriv); |
e_book_backend_summary_remove_contact (bepriv->summary, | e_book_backend_summary_remove_contact (bepriv->summary, |
uri); | uri); |
e_book_backend_summary_add_contact (bepriv->summary, | e_book_backend_summary_add_contact (bepriv->summary, |
*contact); | *contact); |
e_book_backend_cache_remove_contact (bepriv->cache, uri); | e_book_backend_cache_remove_contact (bepriv->cache, uri); |
e_book_backend_cache_add_contact (bepriv->cache, *contact); | e_book_backend_cache_add_contact (bepriv->cache, *contact); |
|
UNLOCK (bepriv); |
return GNOME_Evolution_Addressbook_Success; | return GNOME_Evolution_Addressbook_Success; |
} else { | } else { |
g_object_unref (*contact); | g_object_unref (*contact); |
|
|
uri = l->data; | uri = l->data; |
status = e2k_context_delete (bepriv->ctx, NULL, uri); | status = e2k_context_delete (bepriv->ctx, NULL, uri); |
if (E2K_HTTP_STATUS_IS_SUCCESSFUL (status)) { | if (E2K_HTTP_STATUS_IS_SUCCESSFUL (status)) { |
|
LOCK (bepriv); |
e_book_backend_summary_remove_contact ( | e_book_backend_summary_remove_contact ( |
bepriv->summary, uri); | bepriv->summary, uri); |
e_book_backend_cache_remove_contact (bepriv->cache, uri); | e_book_backend_cache_remove_contact (bepriv->cache, uri); |
*removed_ids = g_list_append ( | *removed_ids = g_list_append ( |
*removed_ids, g_strdup (uri)); | *removed_ids, g_strdup (uri)); |
|
UNLOCK (bepriv); |
} else | } else |
ret_status = http_status_to_pas (status); | ret_status = http_status_to_pas (status); |
} | } |
|
|
if (be->priv->cache) | if (be->priv->cache) |
g_object_unref (be->priv->cache); | g_object_unref (be->priv->cache); |
| |
if (be->priv->create_mutex) |
if (be->priv->cache_lock) |
g_mutex_free (be->priv->create_mutex); |
g_mutex_free (be->priv->cache_lock); |
| |
| |
g_free (be->priv); | g_free (be->priv); |
|
|
priv->original_uri = NULL; | priv->original_uri = NULL; |
priv->is_writable = TRUE; | priv->is_writable = TRUE; |
| |
priv->create_mutex = g_mutex_new (); |
priv->cache_lock = g_mutex_new (); |
| |
backend->priv = priv; | backend->priv = priv; |
} | } |