[evolution-ews] Bug #687877 - Trying to search GAL with the "Any field contains" option fails
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews] Bug #687877 - Trying to search GAL with the "Any field contains" option fails
- Date: Thu, 8 Nov 2012 11:36:20 +0000 (UTC)
commit 82c13012e2e30767127728614d30b00559fc2505
Author: Milan Crha <mcrha redhat com>
Date: Thu Nov 8 12:34:34 2012 +0100
Bug #687877 - Trying to search GAL with the "Any field contains" option fails
src/addressbook/Makefile.am | 18 -
src/addressbook/e-book-backend-ews.c | 126 +-
src/addressbook/ews-book-backend-sqlitedb-test.c | 225 ---
src/addressbook/ews-book-backend-sqlitedb.c | 2194 ----------------------
src/addressbook/ews-book-backend-sqlitedb.h | 223 ---
src/addressbook/ews-oab-decoder.c | 16 +-
6 files changed, 74 insertions(+), 2728 deletions(-)
---
diff --git a/src/addressbook/Makefile.am b/src/addressbook/Makefile.am
index 36d1b82..261fb5e 100644
--- a/src/addressbook/Makefile.am
+++ b/src/addressbook/Makefile.am
@@ -22,8 +22,6 @@ libebookbackendews_la_CPPFLAGS = \
$(NULL)
libebookbackendews_la_SOURCES = \
- ews-book-backend-sqlitedb.c \
- ews-book-backend-sqlitedb.h \
ews-oab-props.h \
ews-oab-decoder.c \
ews-oab-decoder.h \
@@ -49,20 +47,4 @@ libebookbackendews_la_LIBADD = \
libebookbackendews_la_LDFLAGS = \
-module -avoid-version $(NO_UNDEFINED)
-noinst_PROGRAMS = ews-book-backend-sqlitedb-test
-
-ews_book_backend_sqlitedb_test_CPPFLAGS = \
- $(libebookbackendews_la_CPPFLAGS) \
- $(NULL)
-
-ews_book_backend_sqlitedb_test_SOURCES = \
- ews-book-backend-sqlitedb-test.c \
- ews-book-backend-sqlitedb.c \
- ews-book-backend-sqlitedb.h \
- $(NULL)
-
-ews_book_backend_sqlitedb_test_LDADD = \
- $(libebookbackendews_la_LIBADD) \
- $(NULL)
-
-include $(top_srcdir)/git.mk
diff --git a/src/addressbook/e-book-backend-ews.c b/src/addressbook/e-book-backend-ews.c
index ab0fd24..39f3e25 100644
--- a/src/addressbook/e-book-backend-ews.c
+++ b/src/addressbook/e-book-backend-ews.c
@@ -38,7 +38,7 @@
#include <glib/gstdio.h>
#include <glib/gi18n-lib.h>
-/*#include <libedata-book/libedata-book.h>*/
+#include <libedata-book/libedata-book.h>
#include "lzx/ews-oal-decompress.h"
@@ -51,7 +51,6 @@
#include "utils/e-ews-query-to-restriction.h"
#include "e-book-backend-ews.h"
-#include "ews-book-backend-sqlitedb.h"
#include "ews-oab-decoder.h"
#define d(x) x
@@ -73,7 +72,7 @@ struct _EBookBackendEwsPrivate {
gchar *oab_url;
gchar *folder_name;
- EwsBookBackendSqliteDB *ebsdb;
+ EBookBackendSqliteDB *summary;
gboolean only_if_exists;
gboolean is_writable;
@@ -927,7 +926,7 @@ ews_create_contact_cb (GObject *object,
/* get a list of ids from server (single item) */
e_ews_connection_create_items_finish (cnc, res, &items, &error);
- g_return_if_fail (ebews->priv->ebsdb != NULL);
+ g_return_if_fail (ebews->priv->summary != NULL);
if (error == NULL) {
EEwsItem *item = (EEwsItem *) items->data;
@@ -937,7 +936,7 @@ ews_create_contact_cb (GObject *object,
e_contact_set (create_contact->contact, E_CONTACT_UID, item_id->id);
e_contact_set (create_contact->contact, E_CONTACT_REV, item_id->change_key);
- ews_book_backend_sqlitedb_add_contact (ebews->priv->ebsdb, ebews->priv->folder_id, create_contact->contact, FALSE, &error);
+ e_book_backend_sqlitedb_add_contact (ebews->priv->summary, ebews->priv->folder_id, create_contact->contact, FALSE, &error);
if (error == NULL) {
GSList *contacts;
@@ -1060,10 +1059,10 @@ ews_book_remove_contact_cb (GObject *object,
simple = G_SIMPLE_ASYNC_RESULT (res);
- g_return_if_fail (priv->ebsdb != NULL);
+ g_return_if_fail (priv->summary != NULL);
if (!g_simple_async_result_propagate_error (simple, &error))
- deleted = ews_book_backend_sqlitedb_remove_contacts (priv->ebsdb, priv->folder_id, remove_contact->sl_ids, &error);
+ deleted = e_book_backend_sqlitedb_remove_contacts (priv->summary, priv->folder_id, remove_contact->sl_ids, &error);
if (deleted)
e_data_book_respond_remove_contacts (remove_contact->book, remove_contact->opid, EDB_ERROR (SUCCESS), remove_contact->sl_ids);
@@ -1162,7 +1161,7 @@ ews_modify_contact_cb (GObject *object,
e_ews_connection_update_items_finish (cnc, res, &items, &error);
- g_return_if_fail (priv->ebsdb != NULL);
+ g_return_if_fail (priv->summary != NULL);
if (error == NULL) {
EEwsItem *item = (EEwsItem *) items->data;
@@ -1175,8 +1174,8 @@ ews_modify_contact_cb (GObject *object,
id = e_contact_get (modify_contact->old_contact, E_CONTACT_UID);
- ews_book_backend_sqlitedb_remove_contact (priv->ebsdb, priv->folder_id, id, &error);
- ews_book_backend_sqlitedb_add_contact (ebews->priv->ebsdb, ebews->priv->folder_id, modify_contact->new_contact, FALSE, &error);
+ e_book_backend_sqlitedb_remove_contact (priv->summary, priv->folder_id, id, &error);
+ e_book_backend_sqlitedb_add_contact (ebews->priv->summary, ebews->priv->folder_id, modify_contact->new_contact, FALSE, &error);
if (error == NULL) {
GSList *new_contacts;
@@ -1292,7 +1291,7 @@ e_book_backend_ews_modify_contacts (EBookBackend *backend,
return;
}
- g_return_if_fail (priv->ebsdb != NULL);
+ g_return_if_fail (priv->summary != NULL);
contact = e_contact_new_from_vcard (vcards->data);
@@ -1308,8 +1307,8 @@ e_book_backend_ews_modify_contacts (EBookBackend *backend,
return;
}
- old_contact = ews_book_backend_sqlitedb_get_contact (
- priv->ebsdb, priv->folder_id,
+ old_contact = e_book_backend_sqlitedb_get_contact (
+ priv->summary, priv->folder_id,
id->id, NULL, NULL, &error);
if (!old_contact) {
g_object_unref (contact);
@@ -1374,14 +1373,14 @@ e_book_backend_ews_get_contact_list (EBookBackend *backend,
priv = ebews->priv;
if (!e_backend_get_online (E_BACKEND (backend))) {
- if (priv->ebsdb && ews_book_backend_sqlitedb_get_is_populated (priv->ebsdb, priv->folder_id, NULL)) {
- list = ews_book_backend_sqlitedb_search (priv->ebsdb, priv->folder_id, query, NULL, NULL, NULL, &error);
+ if (priv->summary && e_book_backend_sqlitedb_get_is_populated (priv->summary, priv->folder_id, NULL)) {
+ list = e_book_backend_sqlitedb_search (priv->summary, priv->folder_id, query, NULL, NULL, NULL, &error);
l = list;
while (l) {
- EwsSdbSearchData *s_data = (EwsSdbSearchData *) l->data;
+ EbSdbSearchData *s_data = (EbSdbSearchData *) l->data;
vcard_list = g_slist_append (vcard_list, g_strdup (s_data->vcard));
- ews_book_backend_sqlitedb_search_data_free (s_data);
+ e_book_backend_sqlitedb_search_data_free (s_data);
l = l->next;
}
convert_error_to_edb_error (&error);
@@ -1401,14 +1400,14 @@ e_book_backend_ews_get_contact_list (EBookBackend *backend,
return;
}
- if (priv->ebsdb && ews_book_backend_sqlitedb_get_is_populated (priv->ebsdb, priv->folder_id, NULL)) {
- list = ews_book_backend_sqlitedb_search (priv->ebsdb, priv->folder_id, query, NULL, NULL, NULL, &error);
+ if (priv->summary && e_book_backend_sqlitedb_get_is_populated (priv->summary, priv->folder_id, NULL)) {
+ list = e_book_backend_sqlitedb_search (priv->summary, priv->folder_id, query, NULL, NULL, NULL, &error);
l = list;
while (l) {
- EwsSdbSearchData *s_data = (EwsSdbSearchData *) l->data;
+ EbSdbSearchData *s_data = (EbSdbSearchData *) l->data;
vcard_list = g_slist_append (vcard_list, g_strdup (s_data->vcard));
- ews_book_backend_sqlitedb_search_data_free (s_data);
+ e_book_backend_sqlitedb_search_data_free (s_data);
l = l->next;
}
@@ -1666,10 +1665,10 @@ ews_gal_needs_update (EBookBackendEws *cbews,
gboolean ret = FALSE;
gchar *tmp;
- if (!priv->ebsdb)
+ if (!priv->summary)
return FALSE;
- tmp = ews_book_backend_sqlitedb_get_key_value (priv->ebsdb, priv->folder_id, "seq", error);
+ tmp = e_book_backend_sqlitedb_get_key_value (priv->summary, priv->folder_id, "seq", error);
if (error)
goto exit;
@@ -1744,10 +1743,10 @@ ews_remove_old_gal_file (EBookBackendEws *cbews,
EBookBackendEwsPrivate *priv = cbews->priv;
gchar *filename;
- if (!priv->ebsdb)
+ if (!priv->summary)
return FALSE;
- filename = ews_book_backend_sqlitedb_get_key_value (priv->ebsdb, priv->folder_id, "oab-filename", error);
+ filename = e_book_backend_sqlitedb_get_key_value (priv->summary, priv->folder_id, "oab-filename", error);
if (*error)
return FALSE;
@@ -1774,7 +1773,7 @@ ews_gal_store_contact (EContact *contact,
struct _db_data *data = (struct _db_data *) user_data;
EBookBackendEwsPrivate *priv = data->cbews->priv;
- g_return_if_fail (priv->ebsdb != NULL);
+ g_return_if_fail (priv->summary != NULL);
data->contact_collector = g_slist_prepend (data->contact_collector, g_object_ref (contact));
data->collected_length += 1;
@@ -1790,7 +1789,7 @@ ews_gal_store_contact (EContact *contact,
g_free (status_message);
data->contact_collector = g_slist_reverse (data->contact_collector);
- ews_book_backend_sqlitedb_add_contacts (priv->ebsdb, priv->folder_id, data->contact_collector, FALSE, error);
+ e_book_backend_sqlitedb_add_contacts (priv->summary, priv->folder_id, data->contact_collector, FALSE, error);
for (l = data->contact_collector; l != NULL; l = g_slist_next (l))
e_book_backend_notify_update (E_BOOK_BACKEND (data->cbews), E_CONTACT (l->data));
@@ -1816,14 +1815,19 @@ ews_replace_gal_in_db (EBookBackendEws *cbews,
gboolean ret = TRUE;
struct _db_data data;
- g_return_val_if_fail (priv->ebsdb != NULL, FALSE);
+ g_return_val_if_fail (priv->summary != NULL, FALSE);
/* remove the old address-book and create a new one in db */
- if (ews_book_backend_sqlitedb_get_is_populated (priv->ebsdb, priv->folder_id, NULL)) {
- ret = ews_book_backend_sqlitedb_delete_addressbook (priv->ebsdb, priv->folder_id, error);
+ if (e_book_backend_sqlitedb_get_is_populated (priv->summary, priv->folder_id, NULL)) {
+ GSList *uids;
+
+ uids = e_book_backend_sqlitedb_search_uids (priv->summary, priv->folder_id, NULL, NULL, NULL);
+ if (uids) {
+ e_book_backend_sqlitedb_remove_contacts (priv->summary, priv->folder_id, uids, NULL);
+ g_slist_free_full (uids, g_free);
+ }
+
ews_remove_attachments (priv->attachment_dir);
- if (ret)
- ret = ews_book_backend_sqlitedb_create_addressbook (priv->ebsdb, priv->folder_id, priv->folder_name, TRUE, error);
}
if (!ret)
@@ -1842,7 +1846,7 @@ ews_replace_gal_in_db (EBookBackendEws *cbews,
return ret;
/* mark the db as populated */
- ret = ews_book_backend_sqlitedb_set_is_populated (priv->ebsdb, priv->folder_id, TRUE, error);
+ ret = e_book_backend_sqlitedb_set_is_populated (priv->summary, priv->folder_id, TRUE, error);
return ret;
}
@@ -1880,8 +1884,8 @@ ebews_start_gal_sync (gpointer data)
goto exit;
}
- g_warn_if_fail (priv->ebsdb != NULL);
- if (!priv->ebsdb)
+ g_warn_if_fail (priv->summary != NULL);
+ if (!priv->summary)
goto exit;
if (full_l == NULL)
@@ -1889,7 +1893,7 @@ ebews_start_gal_sync (gpointer data)
full = (EwsOALDetails *) full_l->data;
/* TODO fetch differential updates if available instead of downloading the whole GAL */
- if (!ews_book_backend_sqlitedb_get_is_populated (priv->ebsdb, priv->folder_id, NULL) || ews_gal_needs_update (cbews, full, &error)) {
+ if (!e_book_backend_sqlitedb_get_is_populated (priv->summary, priv->folder_id, NULL) || ews_gal_needs_update (cbews, full, &error)) {
gchar *seq;
d (printf ("Ewsgal: Downloading full gal \n");)
@@ -1912,11 +1916,11 @@ ebews_start_gal_sync (gpointer data)
goto exit;
seq = g_strdup_printf ("%"G_GUINT32_FORMAT, full->seq);
- ret = ews_book_backend_sqlitedb_set_key_value (priv->ebsdb, priv->folder_id, "seq", seq, &error);
+ ret = e_book_backend_sqlitedb_set_key_value (priv->summary, priv->folder_id, "seq", seq, &error);
g_free (seq);
if (!ret) {
- ews_book_backend_sqlitedb_delete_addressbook (priv->ebsdb, priv->folder_id, &error);
+ e_book_backend_sqlitedb_delete_addressbook (priv->summary, priv->folder_id, &error);
goto exit;
}
}
@@ -1964,14 +1968,14 @@ ebews_sync_deleted_items (EBookBackendEws *ebews,
priv = ebews->priv;
- g_return_if_fail (priv->ebsdb != NULL);
+ g_return_if_fail (priv->summary != NULL);
for (l = deleted_ids; l != NULL; l = g_slist_next (l)) {
gchar *id = (gchar *) l->data;
gboolean partial_content;
- if (ews_book_backend_sqlitedb_has_contact (priv->ebsdb, priv->folder_id, id, &partial_content, NULL))
- ews_book_backend_sqlitedb_remove_contact (priv->ebsdb, priv->folder_id, id, error);
+ if (e_book_backend_sqlitedb_has_contact (priv->summary, priv->folder_id, id, &partial_content, NULL))
+ e_book_backend_sqlitedb_remove_contact (priv->summary, priv->folder_id, id, error);
e_book_backend_notify_remove (E_BOOK_BACKEND (ebews), id);
}
@@ -1990,7 +1994,7 @@ ebews_store_contact_items (EBookBackendEws *ebews,
priv = ebews->priv;
- g_return_if_fail (priv->ebsdb != NULL);
+ g_return_if_fail (priv->summary != NULL);
for (l = new_items; l != NULL; l = g_slist_next (l)) {
EContact *contact;
@@ -2021,7 +2025,7 @@ ebews_store_contact_items (EBookBackendEws *ebews,
/* store display_name, fileas, item id */
}
- ews_book_backend_sqlitedb_add_contact (priv->ebsdb, priv->folder_id, contact, FALSE, error);
+ e_book_backend_sqlitedb_add_contact (priv->summary, priv->folder_id, contact, FALSE, error);
e_book_backend_notify_update (E_BOOK_BACKEND (ebews), contact);
g_object_unref (item);
@@ -2079,7 +2083,7 @@ ebews_store_distribution_list_items (EBookBackendEws *ebews,
GSList *l;
EContact *contact;
- g_return_if_fail (ebews->priv->ebsdb != NULL);
+ g_return_if_fail (ebews->priv->summary != NULL);
contact = e_contact_new ();
e_contact_set (contact, E_CONTACT_UID, id->id);
@@ -2113,7 +2117,7 @@ ebews_store_distribution_list_items (EBookBackendEws *ebews,
}
g_slist_free (members);
- ews_book_backend_sqlitedb_add_contact (ebews->priv->ebsdb, ebews->priv->folder_id, contact, FALSE, error);
+ e_book_backend_sqlitedb_add_contact (ebews->priv->summary, ebews->priv->folder_id, contact, FALSE, error);
e_book_backend_notify_update (E_BOOK_BACKEND (ebews), contact);
g_object_unref (contact);
@@ -2295,7 +2299,7 @@ ebews_start_sync (gpointer data)
ebews = (EBookBackendEws *) data;
priv = ebews->priv;
- g_return_val_if_fail (priv->ebsdb != NULL, FALSE);
+ g_return_val_if_fail (priv->summary != NULL, FALSE);
/* Not connected? Try again later */
if (!priv->cnc)
@@ -2305,7 +2309,7 @@ ebews_start_sync (gpointer data)
e_book_backend_foreach_view (E_BOOK_BACKEND (ebews), book_view_notify_status, status_message);
g_free (status_message);
- sync_state = ews_book_backend_sqlitedb_get_sync_data (priv->ebsdb, priv->folder_id, NULL);
+ sync_state = e_book_backend_sqlitedb_get_sync_data (priv->summary, priv->folder_id, NULL);
do
{
GSList *items_created = NULL, *items_updated = NULL;
@@ -2343,11 +2347,11 @@ ebews_start_sync (gpointer data)
if (error)
break;
- ews_book_backend_sqlitedb_set_sync_data (priv->ebsdb, priv->folder_id, sync_state, &error);
+ e_book_backend_sqlitedb_set_sync_data (priv->summary, priv->folder_id, sync_state, &error);
} while (!error && !includes_last_item);
if (!error)
- ews_book_backend_sqlitedb_set_is_populated (priv->ebsdb, priv->folder_id, TRUE, &error);
+ e_book_backend_sqlitedb_set_is_populated (priv->summary, priv->folder_id, TRUE, &error);
g_free (sync_state);
@@ -2456,17 +2460,17 @@ fetch_from_offline (EBookBackendEws *ews,
return;
}
- g_return_if_fail (priv->ebsdb != NULL);
+ g_return_if_fail (priv->summary != NULL);
- contacts = ews_book_backend_sqlitedb_search (priv->ebsdb, priv->folder_id, query, NULL, NULL, NULL, &error);
+ contacts = e_book_backend_sqlitedb_search (priv->summary, priv->folder_id, query, NULL, NULL, NULL, &error);
for (l = contacts; l != NULL; l = g_slist_next (l)) {
- EwsSdbSearchData *s_data = (EwsSdbSearchData *) l->data;
+ EbSdbSearchData *s_data = (EbSdbSearchData *) l->data;
/* reset vcard to NULL as it would be free'ed in prefiltered_vcard function */
e_data_book_view_notify_update_prefiltered_vcard (book_view, s_data->uid, s_data->vcard);
s_data->vcard = NULL;
- ews_book_backend_sqlitedb_search_data_free (s_data);
+ e_book_backend_sqlitedb_search_data_free (s_data);
}
if (contacts)
@@ -2506,7 +2510,7 @@ e_book_backend_ews_start_view (EBookBackend *backend,
e_data_book_view_notify_progress (book_view, -1, _("Searching..."));
if (!e_backend_get_online (E_BACKEND (backend))) {
- if (priv->ebsdb && ews_book_backend_sqlitedb_get_is_populated (priv->ebsdb, priv->folder_id, NULL)) {
+ if (priv->summary && e_book_backend_sqlitedb_get_is_populated (priv->summary, priv->folder_id, NULL)) {
fetch_from_offline (ebews, book_view, query, error);
return;
}
@@ -2537,8 +2541,8 @@ e_book_backend_ews_start_view (EBookBackend *backend,
ebews_start_refreshing (ebews);
- if (priv->ebsdb &&
- ews_book_backend_sqlitedb_get_is_populated (priv->ebsdb, priv->folder_id, NULL)) {
+ if (priv->summary &&
+ e_book_backend_sqlitedb_get_is_populated (priv->summary, priv->folder_id, NULL)) {
fetch_from_offline (ebews, book_view, query, error);
return;
}
@@ -2679,11 +2683,11 @@ e_book_backend_ews_load_source (EBookBackend *backend,
priv->folder_id = e_source_ews_folder_dup_id (
E_SOURCE_EWS_FOLDER (extension));
- priv->ebsdb = ews_book_backend_sqlitedb_new (
+ priv->summary = e_book_backend_sqlitedb_new (
cache_dir, email, priv->folder_id,
display_name, TRUE, perror);
- if (priv->ebsdb == NULL)
+ if (priv->summary == NULL)
return;
priv->marked_for_offline = FALSE;
@@ -2910,9 +2914,9 @@ e_book_backend_ews_dispose (GObject *object)
priv->dthread = NULL;
}
- if (priv->ebsdb) {
- g_object_unref (priv->ebsdb);
- priv->ebsdb = NULL;
+ if (priv->summary) {
+ g_object_unref (priv->summary);
+ priv->summary = NULL;
}
g_rec_mutex_clear (&priv->rec_mutex);
diff --git a/src/addressbook/ews-oab-decoder.c b/src/addressbook/ews-oab-decoder.c
index 75c5e41..8bea126 100644
--- a/src/addressbook/ews-oab-decoder.c
+++ b/src/addressbook/ews-oab-decoder.c
@@ -29,6 +29,7 @@
#include <glib/gstdio.h>
#include <libebook/libebook.h>
+#include <libedata-book/libedata-book.h>
#include "ews-oab-decoder.h"
#include "ews-oab-props.h"
@@ -1064,12 +1065,12 @@ ews_oab_decoder_get_contact_from_offset (EwsOabDecoder *eod,
return contact;
}
-#include "ews-book-backend-sqlitedb.h"
+#ifdef TEST_BUILD
struct _db_data {
GSList *contact_collector;
guint collected_length;
- EwsBookBackendSqliteDB *ebsdb;
+ EBookBackendSqliteDB *summary;
const gchar *folderid;
};
@@ -1087,7 +1088,7 @@ ews_test_store_contact (EContact *contact,
if (data->collected_length == 1000 || percent >= 100) {
data->contact_collector = g_slist_reverse (data->contact_collector);
- ews_book_backend_sqlitedb_add_contacts (data->ebsdb, data->folderid, data->contact_collector, FALSE, error);
+ e_book_backend_sqlitedb_add_contacts (data->summary, data->folderid, data->contact_collector, FALSE, error);
g_print ("percent complete %d \n", percent);
g_slist_foreach (data->contact_collector, (GFunc) g_object_unref, NULL);
@@ -1101,7 +1102,7 @@ gint
main (gint argc,
gchar *argv[])
{
- EwsBookBackendSqliteDB *ebsdb;
+ EBookBackendSqliteDB *summary;
EwsOabDecoder *eod;
GError *err = NULL;
GTimer *timer;
@@ -1114,12 +1115,12 @@ main (gint argc,
return -1;
}
- ebsdb = ews_book_backend_sqlitedb_new (argv[2], "dum", "de", "dum", TRUE, NULL);
+ summary = e_book_backend_sqlitedb_new (argv[2], "dum", "de", "dum", TRUE, NULL);
eod = ews_oab_decoder_new (argv[1], argv[2], &err);
data.contact_collector = NULL;
data.collected_length = 0;
- data.ebsdb = ebsdb;
+ data.summary = summary;
data.folderid = "de";
timer = g_timer_new ();
@@ -1134,7 +1135,8 @@ main (gint argc,
g_clear_error (&err);
g_object_unref (eod);
- g_object_unref (ebsdb);
+ g_object_unref (summary);
return 0;
}
+#endif /* TEST_BUILD */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]