aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/backend
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2002-01-21 23:11:50 +0800
committerChris Lahey <clahey@src.gnome.org>2002-01-21 23:11:50 +0800
commit43c9ba9a203084dc5a341c781593d7d7337e2b9a (patch)
treeb432d469caf6b4356ced3db998df8ab5c9ddca04 /addressbook/backend
parentfa21c59a5f421322ad1b678c6b9328c8c074dc6e (diff)
downloadgsoc2013-evolution-43c9ba9a203084dc5a341c781593d7d7337e2b9a.tar
gsoc2013-evolution-43c9ba9a203084dc5a341c781593d7d7337e2b9a.tar.gz
gsoc2013-evolution-43c9ba9a203084dc5a341c781593d7d7337e2b9a.tar.bz2
gsoc2013-evolution-43c9ba9a203084dc5a341c781593d7d7337e2b9a.tar.lz
gsoc2013-evolution-43c9ba9a203084dc5a341c781593d7d7337e2b9a.tar.xz
gsoc2013-evolution-43c9ba9a203084dc5a341c781593d7d7337e2b9a.tar.zst
gsoc2013-evolution-43c9ba9a203084dc5a341c781593d7d7337e2b9a.zip
Set the number of cards to return to the value specified in the ldap uri,
2002-01-21 Christopher James Lahey <clahey@ximian.com> * backend/pas/pas-backend-ldap.c (ldap_search_handler): Set the number of cards to return to the value specified in the ldap uri, leaving the default at 100. Fixes Ximian bug #13953. * gui/component/addressbook-config.c (addressbook_source_dialog), gui/component/addressbook-config.glade: Added a limit entry here to edit the limit field of the source. * gui/component/addressbook-storage.c, gui/component/addressbook-storage.h (addressbook_storage_init_source_uri): Added a limit field to this class and pass that value through in the uri that's generated. svn path=/trunk/; revision=15415
Diffstat (limited to 'addressbook/backend')
-rw-r--r--addressbook/backend/pas/pas-backend-ldap.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/addressbook/backend/pas/pas-backend-ldap.c b/addressbook/backend/pas/pas-backend-ldap.c
index 1432133fd3..ff5c29168b 100644
--- a/addressbook/backend/pas/pas-backend-ldap.c
+++ b/addressbook/backend/pas/pas-backend-ldap.c
@@ -44,6 +44,8 @@
#include "pas-book.h"
#include "pas-card-cursor.h"
+#include <stdlib.h>
+
#define LDAP_MAX_SEARCH_RESPONSES 100
@@ -69,6 +71,7 @@ struct _PASBackendLDAPPrivate {
gchar *ldap_rootdn;
int ldap_port;
int ldap_scope;
+ int ldap_limit;
GList *book_views;
LDAP *ldap;
@@ -2285,7 +2288,7 @@ ldap_search_handler (PASBackend *backend, LDAPOp *op)
NULL, /* XXX */
NULL, /* XXX */
NULL,
- LDAP_MAX_SEARCH_RESPONSES, &view->search_msgid);
+ bl->priv->ldap_limit, &view->search_msgid);
if (ldap_err != LDAP_SUCCESS) {
pas_book_view_notify_status_message (view->book_view, ldap_err2string(ldap_err));
@@ -2538,10 +2541,39 @@ pas_backend_ldap_load_uri (PASBackend *backend,
PASBackendLDAP *bl = PAS_BACKEND_LDAP (backend);
LDAPURLDesc *lud;
int ldap_error;
+ char **attributes;
+ int i;
+ int limit = 100;
g_assert (bl->priv->connected == FALSE);
- ldap_error = ldap_url_parse ((char*)uri, &lud);
+ attributes = g_strsplit (uri, ";", 0);
+
+ if (attributes[0] == NULL)
+ return FALSE;
+
+ for (i = 1; attributes[i]; i++) {
+ char *equals;
+ char *value;
+ int key_length;
+ equals = strchr (attributes[i], '=');
+ if (equals) {
+ key_length = equals - attributes[i];
+ value = equals + 1;
+ } else {
+ key_length = strlen (attributes[i]);
+ value = NULL;
+ }
+
+ if (key_length == strlen("limit") && !strncmp (attributes[i], "limit", key_length)) {
+ if (value)
+ limit = atoi(value);
+ }
+ }
+
+ ldap_error = ldap_url_parse ((char*)attributes[0], &lud);
+ g_strfreev (attributes);
+
if (ldap_error == LDAP_SUCCESS) {
g_free(bl->priv->uri);
bl->priv->uri = g_strdup (uri);
@@ -2551,6 +2583,7 @@ pas_backend_ldap_load_uri (PASBackend *backend,
if (bl->priv->ldap_port == 0)
bl->priv->ldap_port = LDAP_PORT;
bl->priv->ldap_rootdn = g_strdup(lud->lud_dn);
+ bl->priv->ldap_limit = limit;
bl->priv->ldap_scope = lud->lud_scope;
ldap_free_urldesc(lud);
@@ -2746,6 +2779,7 @@ pas_backend_ldap_init (PASBackendLDAP *backend)
priv = g_new0 (PASBackendLDAPPrivate, 1);
priv->supported_fields = e_list_new ((EListCopyFunc)g_strdup, (EListFreeFunc)g_free, NULL);
+ priv->ldap_limit = 100;
backend->priv = priv;
}