[evolution-mapi/gal-ldap: 3/3] GAL LDAP : Enable cache + Fixes (Srini)
- From: Johnny Jacob <jjohnny src gnome org>
- To: svn-commits-list gnome org
- Subject: [evolution-mapi/gal-ldap: 3/3] GAL LDAP : Enable cache + Fixes (Srini)
- Date: Tue, 16 Jun 2009 00:31:48 -0400 (EDT)
commit 15102a4bc91f1ed4e36dbacbf672b75eed01185e
Author: Johnny Jacob <jjohnny novell com>
Date: Tue Jun 16 10:00:19 2009 +0530
GAL LDAP : Enable cache + Fixes (Srini)
src/galldap/Makefile.am | 4 ++-
src/galldap/e-book-backend-galldap.c | 55 ++++++++++++++++-----------------
2 files changed, 30 insertions(+), 29 deletions(-)
---
diff --git a/src/galldap/Makefile.am b/src/galldap/Makefile.am
index 69b7655..9481f85 100644
--- a/src/galldap/Makefile.am
+++ b/src/galldap/Makefile.am
@@ -30,6 +30,7 @@ extension_LTLIBRARIES = libebookbackendgalldap.la
libebookbackendgalldap_la_SOURCES = \
e-book-backend-galldap-factory.c \
e-book-backend-galldap.c \
+ e-book-backend-db-cache.c \
e-book-backend-galldap.h
libebookbackendgalldap_la_LIBADD = \
@@ -39,7 +40,8 @@ libebookbackendgalldap_la_LIBADD = \
$(LIBEBOOK_LIBS) \
$(LIBEDATABOOK_LIBS) \
$(EVOLUTION_PLUGIN_LIBS) \
- $(LDAP_LIBS)
+ $(LDAP_LIBS) \
+ -ldb
libebookbackendgalldap_la_LDFLAGS = \
-module -avoid-version $(NO_UNDEFINED)
diff --git a/src/galldap/e-book-backend-galldap.c b/src/galldap/e-book-backend-galldap.c
index 95f0290..08088cc 100644
--- a/src/galldap/e-book-backend-galldap.c
+++ b/src/galldap/e-book-backend-galldap.c
@@ -70,7 +70,7 @@
#endif
/* FIXME: Without this, build breaks */
-#define ENABLE_CACHE 0
+#define ENABLE_CACHE 1
#if ENABLE_CACHE
#include <libedata-book/e-book-backend-db-cache.h>
@@ -157,7 +157,7 @@ static gboolean poll_ldap (EBookBackendGALLDAP *bl);
static EContact *build_contact_from_entry (EBookBackendGALLDAP *bl, LDAPMessage *e, GList **existing_objectclasses);
-static void manager_populate (EContact *contact, char **values, EBookBackendGALLDAP *bl, E2kOperation *op);
+static void manager_populate (EContact *contact, struct berval **values, EBookBackendGALLDAP *bl, E2kOperation *op);
static void member_populate (EContact *contact, char **values, EBookBackendGALLDAP *bl, E2kOperation *op);
@@ -571,7 +571,7 @@ get_contact (EBookBackend *backend,
case GNOME_Evolution_Addressbook_MODE_LOCAL:
#if ENABLE_CACHE
if (bl->priv->marked_for_offline && bl->priv->file_db) {
- EContact *contact = e_book_backend_db_cache_get_contact (bl->priv->file_db, id);
+ EContact *contact = e_book_backend_mdb_cache_get_contact (bl->priv->file_db, id);
gchar *vcard_str;
if (!contact) {
@@ -597,7 +597,7 @@ get_contact (EBookBackend *backend,
#if ENABLE_CACHE
printf("Mode:Remote\n");
if (bl->priv->marked_for_offline && bl->priv->file_db) {
- EContact *contact = e_book_backend_db_cache_get_contact (bl->priv->file_db, id);
+ EContact *contact = e_book_backend_mdb_cache_get_contact (bl->priv->file_db, id);
gchar *vcard_str ;
if (!contact) {
e_data_book_respond_get_contact (book, opid, GNOME_Evolution_Addressbook_OtherError, "");
@@ -779,7 +779,7 @@ get_contact_list (EBookBackend *backend,
GList *vcard_strings = NULL;
GList *l;
- contacts = e_book_backend_db_cache_get_contacts (bl->priv->file_db, query);
+ contacts = e_book_backend_mdb_cache_get_contacts (bl->priv->file_db, query);
for (l = contacts; l; l = g_list_next (l)) {
EContact *contact = l->data;
@@ -805,7 +805,7 @@ get_contact_list (EBookBackend *backend,
GList *vcard_strings = NULL;
GList *l;
- contacts = e_book_backend_db_cache_get_contacts (bl->priv->file_db, query);
+ contacts = e_book_backend_mdb_cache_get_contacts (bl->priv->file_db, query);
for (l = contacts; l ;l = g_list_next (l)) {
EContact *contact = l->data;
@@ -1177,7 +1177,7 @@ build_query (EBookBackendGALLDAP *bl, const char *query, char **ldap_query)
ESExp *sexp;
ESExpResult *r;
int i, retval;
- printf("%s(%d):%s: \n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
+ printf("%s(%d):%s: %s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, query);
sexp = e_sexp_new();
for(i=0;i<sizeof(symbols)/sizeof(symbols[0]);i++) {
@@ -1189,7 +1189,7 @@ build_query (EBookBackendGALLDAP *bl, const char *query, char **ldap_query)
e_sexp_parse (sexp);
r = e_sexp_eval (sexp);
-
+
if (r->type == ESEXP_RES_STRING) {
if (!strcmp (r->value.string, "(mail=*)")) {
/* If the query is empty,
@@ -1222,7 +1222,7 @@ build_query (EBookBackendGALLDAP *bl, const char *query, char **ldap_query)
}
static void
-manager_populate(EContact *contact, char **values, EBookBackendGALLDAP *bl, E2kOperation *op)
+manager_populate(EContact *contact, struct berval **values, EBookBackendGALLDAP *bl, E2kOperation *op)
{
E2kGlobalCatalogEntry *entry;
E2kGlobalCatalogStatus status;
@@ -1230,7 +1230,7 @@ manager_populate(EContact *contact, char **values, EBookBackendGALLDAP *bl, E2kO
status = e2k_global_catalog_lookup (bl->priv->gc,
op,
E2K_GLOBAL_CATALOG_LOOKUP_BY_DN,
- values[0], 0, &entry);
+ values[0]->bv_val, 0, &entry);
if (status != E2K_GLOBAL_CATALOG_OK)
return;
@@ -1254,7 +1254,7 @@ member_populate (EContact *contact, char **values, EBookBackendGALLDAP *bl, E2kO
for (i=0; values[i]; i++) {
EVCardAttribute *attr;
- member_info = g_strsplit (values [i], ";", -1);
+ member_info = g_strsplit (values[i], ";", -1);
attr = e_vcard_attribute_new (NULL, EVC_EMAIL);
e_vcard_attribute_add_param_with_value (attr, e_vcard_attribute_param_new (EVC_X_DEST_EMAIL), member_info [0]);
e_vcard_attribute_add_param_with_value (attr, e_vcard_attribute_param_new (EVC_X_DEST_CONTACT_UID), member_info [1]);
@@ -1338,7 +1338,7 @@ build_contact_from_entry (EBookBackendGALLDAP *bl, LDAPMessage *e, GList **exist
gboolean is_group = FALSE;
dn = ldap_get_dn(ldap, e);
- printf("%s(%d):%s: \n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
+ printf("%s(%d):%s: %s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, dn);
e_contact_set (contact, E_CONTACT_UID, dn);
ldap_memfree (dn);
@@ -1403,7 +1403,7 @@ build_contact_from_entry (EBookBackendGALLDAP *bl, LDAPMessage *e, GList **exist
d(printf ("value = %s %s\n", e_contact_field_name(info->field_id), values[0]->bv_val));
/* if it's a normal property just set the string */
if (values[0])
- e_contact_set (contact, info->field_id, values[0]);
+ e_contact_set (contact, info->field_id, values[0]->bv_val);
}
else if (info->prop_type & PROP_TYPE_COMPLEX) {
/* if it's a list call the contact-populate function,
@@ -1411,7 +1411,7 @@ build_contact_from_entry (EBookBackendGALLDAP *bl, LDAPMessage *e, GList **exist
/* FIXME: This portion needs to be re-written to suit
* the non-deprecated stuff in OpenLDAP
*/
- /*info->populate_contact_func(contact, values, bl, NULL);*/
+ info->populate_contact_func(contact, values, bl, NULL);
}
else if (info->prop_type & PROP_TYPE_GROUP) {
char *grpattrs[3];
@@ -1605,7 +1605,6 @@ ldap_search_handler (LDAPOp *op, LDAPMessage *res)
while (NULL != e) {
EContact *contact = build_contact_from_entry (bl, e, NULL);
-
e_data_book_view_notify_update (view, contact);
g_object_unref (contact);
@@ -1682,7 +1681,7 @@ get_contacts_from_cache (EBookBackendGALLDAP *ebg,
EContact *contact =
- e_book_backend_db_cache_get_contact (ebg->priv->file_db, uid);
+ e_book_backend_mdb_cache_get_contact (ebg->priv->file_db, uid);
if (contact) {
e_data_book_view_notify_update (book_view, contact);
g_object_unref (contact);
@@ -1715,7 +1714,7 @@ start_book_view (EBookBackend *backend,
return;
}
- contacts = e_book_backend_db_cache_get_contacts (bl->priv->file_db,
+ contacts = e_book_backend_mdb_cache_get_contacts (bl->priv->file_db,
e_data_book_view_get_card_query (view));
for (l = contacts; l; l = g_list_next (l)) {
@@ -1756,12 +1755,12 @@ start_book_view (EBookBackend *backend,
if (ids && ids->len > 0) {
get_contacts_from_cache (bl, query, ids, view);
g_ptr_array_free (ids, TRUE);
- }
+ }
return;
}
- contacts = e_book_backend_db_cache_get_contacts (bl->priv->file_db,
+ contacts = e_book_backend_mdb_cache_get_contacts (bl->priv->file_db,
e_data_book_view_get_card_query (view));
for (l = contacts; l ;l = g_list_next (l)) {
EContact *contact = l->data;
@@ -2075,7 +2074,8 @@ static int dosearch(
case LDAP_RES_SEARCH_ENTRY:
count ++;
contact = build_contact_from_entry (bl, msg, NULL);
- e_book_backend_db_cache_add_contact (bl->priv->file_db, contact);
+
+ e_book_backend_mdb_cache_add_contact (bl->priv->file_db, contact);
e_book_backend_summary_add_contact (bl->priv->summary, contact);
g_object_unref (contact);
break;
@@ -2167,10 +2167,10 @@ getNextPage:
/* Set the cache to populated and thaw the changes */
- e_book_backend_db_cache_set_populated (priv->file_db);
+ e_book_backend_mdb_cache_set_populated (priv->file_db);
t1 = time (NULL);
g_sprintf (t," %d", (int)t1);
- e_book_backend_db_cache_set_time (priv->file_db, t);
+ e_book_backend_mdb_cache_set_time (priv->file_db, t);
priv->is_summary_ready = TRUE;
book_backend_gal->priv->file_db->sync (book_backend_gal->priv->file_db, 0);
@@ -2210,7 +2210,6 @@ authenticate_user (EBookBackend *backend,
return;
case GNOME_Evolution_Addressbook_MODE_REMOTE:
-
e2k_global_catalog_set_password (be->priv->gc, password);
res = gal_connect (be);
if (res != GNOME_Evolution_Addressbook_Success) {
@@ -2219,14 +2218,14 @@ authenticate_user (EBookBackend *backend,
}
printf("Cache is %d\n", ENABLE_CACHE);
#if ENABLE_CACHE
- if (be->priv->marked_for_offline) {
- char *t = e_book_backend_db_cache_get_time (be->priv->file_db);
+ if (be->priv->marked_for_offline && be->priv->file_db) {
+ char *t = e_book_backend_mdb_cache_get_time (be->priv->file_db);
if (t) {
time_t t1, t2;
int diff;
- char *cache_time = e_book_backend_db_cache_get_time (be->priv->file_db);
+ char *cache_time = e_book_backend_mdb_cache_get_time (be->priv->file_db);
printf("Cache is populated, check if refresh is required \n");
if (cache_time && *cache_time)
t1 = atoi (cache_time);
@@ -2568,7 +2567,7 @@ load_source (EBookBackend *backend,
}
bl->priv->file_db = db;
-
+ printf("created DB\n");
if (db_error != 0 || bl->priv->file_db == NULL) {
g_free (filename);
@@ -2576,7 +2575,7 @@ load_source (EBookBackend *backend,
return GNOME_Evolution_Addressbook_OtherError;
}
- e_book_backend_db_cache_set_filename (bl->priv->file_db, filename);
+ e_book_backend_mdb_cache_set_filename (bl->priv->file_db, filename);
g_free (filename);
g_free (dirname);
g_free (uri);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]