diff options
author | Chris Toshok <toshok@src.gnome.org> | 2000-04-12 13:34:59 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2000-04-12 13:34:59 +0800 |
commit | dd437a8dff10d4c9a1ce40d39ce1071ae5867ae3 (patch) | |
tree | 4933c8ab8df87cc0e610fd542c03a78378137792 /addressbook | |
parent | 969fb39532b112c2464dac3052e3650b6a72d1b2 (diff) | |
download | gsoc2013-evolution-dd437a8dff10d4c9a1ce40d39ce1071ae5867ae3.tar gsoc2013-evolution-dd437a8dff10d4c9a1ce40d39ce1071ae5867ae3.tar.gz gsoc2013-evolution-dd437a8dff10d4c9a1ce40d39ce1071ae5867ae3.tar.bz2 gsoc2013-evolution-dd437a8dff10d4c9a1ce40d39ce1071ae5867ae3.tar.lz gsoc2013-evolution-dd437a8dff10d4c9a1ce40d39ce1071ae5867ae3.tar.xz gsoc2013-evolution-dd437a8dff10d4c9a1ce40d39ce1071ae5867ae3.tar.zst gsoc2013-evolution-dd437a8dff10d4c9a1ce40d39ce1071ae5867ae3.zip |
delay the setting of the ldap variable until we've ensured we were
* addressbook/backend/pas/pas-backend-ldap.c
(pas_backend_ldap_build_all_cards_list): delay the setting of the
ldap variable until we've ensured we were connected. Also, set
the search limit to LDAP_MAX_SEARCH_RESPONSES (we'll eventually
want a user setting here i assume.)
(pas_backend_ldap_search): same here, and also send back lists of
CARDS_PER_VIEW_NOTIFICATION length in each
pas_book_view_notify_add call. also, don't call ber_free if there
was a decoding error, since the ldap library frees it for us.
svn path=/trunk/; revision=2406
Diffstat (limited to 'addressbook')
-rw-r--r-- | addressbook/backend/pas/pas-backend-ldap.c | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/addressbook/backend/pas/pas-backend-ldap.c b/addressbook/backend/pas/pas-backend-ldap.c index c80fbd388b..61396d257d 100644 --- a/addressbook/backend/pas/pas-backend-ldap.c +++ b/addressbook/backend/pas/pas-backend-ldap.c @@ -20,6 +20,9 @@ #include <e-sexp.h> #include <e-card.h> +#define LDAP_MAX_SEARCH_RESPONSES 500 +#define CARDS_PER_VIEW_NOTIFICATION 10 + static PASBackendClass *pas_backend_ldap_parent_class; typedef struct _PASBackendLDAPCursorPrivate PASBackendLDAPCursorPrivate; typedef struct _PASBackendLDAPBookView PASBackendLDAPBookView; @@ -180,17 +183,22 @@ pas_backend_ldap_build_all_cards_list(PASBackend *backend, PASBackendLDAPCursorPrivate *cursor_data) { PASBackendLDAP *bl = PAS_BACKEND_LDAP (backend); - LDAP *ldap = bl->priv->ldap; + LDAP *ldap; int ldap_error; LDAPMessage *res, *e; + pas_backend_ldap_ensure_connected(bl); + + ldap = bl->priv->ldap; + + ldap->ld_sizelimit = LDAP_MAX_SEARCH_RESPONSES; if (ldap_search_s (ldap, NULL, LDAP_SCOPE_ONELEVEL, "(objectclass=*)", NULL, 0, &res) == -1) { - ldap_perror (ldap, "ldap_search"); + g_warning ("ldap error '%s' in pas_backend_ldap_build_all_cards_list\n", ldap_err2string(ldap_error)); } cursor_data->elements = NULL; @@ -563,18 +571,22 @@ pas_backend_ldap_search (PASBackendLDAP *bl, GList *cards = NULL; if (ldap_query != NULL) { - LDAP *ldap = bl->priv->ldap; + LDAP *ldap; int ldap_error; LDAPMessage *res, *e; pas_backend_ldap_ensure_connected(bl); + ldap = bl->priv->ldap; + + ldap->ld_sizelimit = LDAP_MAX_SEARCH_RESPONSES; + if ((ldap_error = ldap_search_s (ldap, NULL, LDAP_SCOPE_ONELEVEL, ldap_query, NULL, 0, &res)) != LDAP_SUCCESS) { - ldap_perror (ldap, "ldap_search"); + g_warning ("ldap error '%s' in pas_backend_ldap_search\n", ldap_err2string(ldap_error)); } e = ldap_first_entry(ldap, res); @@ -584,7 +596,8 @@ pas_backend_ldap_search (PASBackendLDAP *bl, char *dn = ldap_get_dn(ldap, e); char *attr, *prop; BerElement *ber = NULL; - + int card_count = 0; + e_card_set_id (card, dn); /* XXX needs a bit of work here */ @@ -602,28 +615,35 @@ pas_backend_ldap_search (PASBackendLDAP *bl, } } - if (ber) + if (ldap->ld_errno != LDAP_DECODING_ERROR && ber) ber_free (ber, 0); cards = g_list_append(cards, e_card_get_vcard(card)); + card_count ++; + if (card_count == CARDS_PER_VIEW_NOTIFICATION) { + card_count = 0; + pas_book_view_notify_add (view->book_view, cards); + + g_list_foreach (cards, (GFunc)g_free, NULL); + g_list_free (cards); + cards = NULL; + } gtk_object_unref (GTK_OBJECT(card)); e = ldap_next_entry(ldap, e); } - ldap_msgfree(res); - + /* send any straglers */ if (cards) { pas_book_view_notify_add (view->book_view, cards); - /* - ** It's fine to do this now since the data has been handed off. - */ g_list_foreach (cards, (GFunc)g_free, NULL); g_list_free (cards); + cards = NULL; } + ldap_msgfree(res); } } |