LDAP *ldap;
struct timeval timeout;
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
ldap = bl->priv->ldap;
if (!ldap) {
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
return;
}
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
if (!bl->priv->schema_dn)
return;
g_get_current_time (&start);
}
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
if (!bl->priv->ldap) {
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
if (enable_debug)
printf ("e_book_backend_ldap_reconnect ... ldap handler is NULL\n");
return FALSE;
}
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
/* we need to reconnect if we were previously connected */
if (bl->priv->connected && ldap_status == LDAP_SERVER_DOWN) {
if (bl->priv->ldap)
ldap_abandon (bl->priv->ldap, op->id);
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
-
- op->dtor (op);
+
+ if (op->dtor)
+ op->dtor (op);
bl->priv->active_ops--;
int ldap_error;
int response;
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
ldap = bl->priv->ldap;
if (!ldap) {
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
e_data_book_respond_create (op->book,
op->opid,
GNOME_Evolution_Addressbook_OtherError,
NULL);
ldap_op_finished (op);
- }
- else {
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
+ return;
}
if (LDAP_RES_ADD != ldap_msgtype (res)) {
ldap_mods = (LDAPMod**)mod_array->pdata;
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
ldap = bl->priv->ldap;
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
do {
book_view_notify_status (book_view, _("Adding contact to LDAP server..."));
int ldap_error;
GList *ids = NULL;
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
if (!bl->priv->ldap) {
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
e_data_book_respond_remove_contacts (op->book, op->opid, GNOME_Evolution_Addressbook_OtherError, NULL);
ldap_op_finished (op);
return;
}
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
if (LDAP_RES_DELETE != ldap_msgtype (res)) {
g_warning ("incorrect msg type %d passed to remove_contact_handler", ldap_msgtype (res));
g_free (remove_op);
return;
case GNOME_Evolution_Addressbook_MODE_REMOTE :
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
if (!bl->priv->ldap) {
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
e_data_book_respond_remove_contacts (book, opid, GNOME_Evolution_Addressbook_OtherError, NULL);
g_free (remove_op);
return;
}
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
book_view = find_book_view (bl);
char *ldap_error_msg;
int ldap_error;
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
ldap = bl->priv->ldap;
if (!ldap) {
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
e_data_book_respond_modify (op->book,
op->opid,
GNOME_Evolution_Addressbook_OtherError,
ldap_op_finished (op);
return;
}
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
if (LDAP_RES_MODIFY != ldap_msgtype (res)) {
g_warning ("incorrect msg type %d passed to modify_contact_handler", ldap_msgtype (res));
LDAP *ldap;
int msg_type;
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
ldap = bl->priv->ldap;
if (!ldap) {
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
e_data_book_respond_modify (op->book, op->opid,
GNOME_Evolution_Addressbook_OtherError, NULL);
ldap_op_finished (op);
return;
}
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
/* if it's successful, we should get called with a
RES_SEARCH_ENTRY and a RES_SEARCH_RESULT. if it's
msg_type = ldap_msgtype (res);
if (msg_type == LDAP_RES_SEARCH_ENTRY) {
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
LDAPMessage *e = ldap_first_entry(ldap, res);
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
if (!e) {
g_warning ("uh, this shouldn't happen");
return;
}
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
modify_op->current_contact = build_contact_from_entry (bl, e,
&modify_op->existing_objectclasses);
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
}
else if (msg_type == LDAP_RES_SEARCH_RESULT) {
char *ldap_error_msg;
e_data_book_respond_modify(book, opid, GNOME_Evolution_Addressbook_RepositoryOffline, NULL);
return;
case GNOME_Evolution_Addressbook_MODE_REMOTE :
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
if (!bl->priv->ldap) {
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
e_data_book_respond_modify (book, opid, GNOME_Evolution_Addressbook_OtherError, NULL);
g_free (modify_op);
return;
}
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
book_view = find_book_view (bl);
modify_op->contact = e_contact_new_from_vcard (vcard);
modify_op->id = e_contact_get_const (modify_op->contact, E_CONTACT_UID);
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
ldap = bl->priv->ldap;
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
do {
book_view_notify_status (book_view, _("Modifying contact from LDAP server..."));
g_get_current_time (&start);
}
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
if (!bl->priv->ldap) {
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
e_data_book_respond_get_contact (op->book, op->opid, GNOME_Evolution_Addressbook_OtherError, "");
ldap_op_finished (op);
if (enable_debug)
printf ("get_contact_handler... ldap handler is NULL \n");
return;
}
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
/* the msg_type will be either SEARCH_ENTRY (if we're
successful) or SEARCH_RESULT (if we're not), so we finish
the op after either */
msg_type = ldap_msgtype (res);
if (msg_type == LDAP_RES_SEARCH_ENTRY) {
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
LDAPMessage *e = ldap_first_entry (bl->priv->ldap, res);
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
EContact *contact;
char *vcard;
return;
}
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
contact = build_contact_from_entry (bl, e, NULL);
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30);
e_data_book_respond_get_contact (op->book,
printf("e_book_backend_ldap_get_contact ... \n");
g_get_current_time (&start);
}
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
ldap = bl->priv->ldap;
if (!ldap) {
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
e_data_book_respond_get_contact (book, opid, GNOME_Evolution_Addressbook_OtherError, "");
if (enable_debug)
printf("e_book_backend_ldap_get_contact ... ldap handler is NULL\n");
return;
}
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
get_contact_op = g_new0 (LDAPGetContactOp, 1);
book_view = find_book_view (bl);
if (enable_debug)
printf ("contact_list_handler ...\n");
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
ldap = bl->priv->ldap;
if (!ldap) {
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
e_data_book_respond_get_contact_list (op->book, op->opid, GNOME_Evolution_Addressbook_OtherError, NULL);
ldap_op_finished (op);
if (enable_debug)
printf ("contact_list_handler ... ldap handler is NULL \n");
return;
}
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
msg_type = ldap_msgtype (res);
if (msg_type == LDAP_RES_SEARCH_ENTRY) {
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
e = ldap_first_entry (ldap, res);
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
while (NULL != e) {
EContact *contact;
char *vcard;
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
contact = build_contact_from_entry (bl, e, NULL);
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30);
g_object_unref (contact);
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
e = ldap_next_entry(ldap, e);
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
}
}
else if (msg_type == LDAP_RES_SEARCH_RESULT) {
return;
case GNOME_Evolution_Addressbook_MODE_REMOTE:
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
ldap = bl->priv->ldap;
if (!ldap) {
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
e_data_book_respond_get_contact_list (book, opid, GNOME_Evolution_Addressbook_OtherError, NULL);
if (enable_debug)
printf ("e_book_backend_ldap_get_contact_list... ldap handler is NULL\n");
return;
}
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
contact_list_op = g_new0 (LDAPGetContactListOp, 1);
book_view = find_book_view (bl);
struct timeval timeout;
const char *ldap_timeout_string;
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
ldap = bl->priv->ldap;
if (!ldap) {
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
bl->priv->poll_timeout = -1;
return FALSE;
}
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
if (!bl->priv->active_ops) {
g_warning ("poll_ldap being called for backend with no active operations");
else
timeout.tv_usec = LDAP_RESULT_TIMEOUT_MILLIS * 1000;
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
rc = ldap_result (ldap, LDAP_RES_ANY, 0, &timeout, &res);
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
if (rc != 0) {/* rc == 0 means timeout exceeded */
if (rc == -1) {
EDataBookView *book_view = find_book_view (bl);
d(printf ("looked up msgid %d, got op %p\n", msgid, op));
- if (op)
+ if (op && op->handler)
op->handler (op, res);
else
g_warning ("unknown operation, msgid = %d", msgid);
if (enable_debug)
g_get_current_time(&start);
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
ldap = bl->priv->ldap;
if (!ldap) {
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
e_data_book_view_notify_complete (view, GNOME_Evolution_Addressbook_OtherError);
ldap_op_finished (op);
if (enable_debug)
printf ("ldap_search_handler... ldap handler is NULL \n");
return;
}
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
if (!search_op->notified_receiving_results) {
search_op->notified_receiving_results = TRUE;
msg_type = ldap_msgtype (res);
if (msg_type == LDAP_RES_SEARCH_ENTRY) {
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
e = ldap_first_entry (ldap, res);
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
while (NULL != e) {
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
EContact *contact = build_contact_from_entry (bl, e, NULL);
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
e_data_book_view_notify_update (view, contact);
g_object_unref (contact);
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
e = ldap_next_entry(ldap, e);
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
}
}
else if (msg_type == LDAP_RES_SEARCH_RESULT) {
case GNOME_Evolution_Addressbook_MODE_REMOTE :
ldap_query = e_book_backend_ldap_build_query (bl, e_data_book_view_get_card_query (view));
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
if (ldap_query != NULL && bl->priv->ldap) {
LDAP *ldap;
int ldap_err;
int search_msgid;
int view_limit;
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
view_limit = e_data_book_view_get_max_results (view);
if (view_limit == -1 || view_limit > bl->priv->ldap_limit)
view_limit = bl->priv->ldap_limit;
printf ("searching server using filter: %s (expecting max %d results)\n", ldap_query,
view_limit);
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
ldap = bl->priv->ldap;
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
do {
book_view_notify_status (view, _("Searching..."));
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
ldap_err = ldap_search_ext (ldap, bl->priv->ldap_rootdn,
bl->priv->ldap_scope,
ldap_query,
NULL, /* XXX */
NULL, /* XXX timeout */
view_limit, &search_msgid);
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
} while (e_book_backend_ldap_reconnect (bl, view, ldap_err));
g_free (ldap_query);
GNOME_Evolution_Addressbook_InvalidQuery);
*/
/* Ignore NULL query */
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
e_data_book_view_notify_complete (view,
GNOME_Evolution_Addressbook_Success);
return;
printf ("generate_cache_handler ... \n");
g_get_current_time (&start);
}
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
ldap = bl->priv->ldap;
if (!ldap) {
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
ldap_op_finished (op);
if (enable_debug)
printf ("generate_cache_handler ... ldap handler is NULL \n");
return;
}
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
book_view = find_book_view (bl);
g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
while (e != NULL) {
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
EContact *contact = build_contact_from_entry (bl, e, NULL);
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
contact_list_op->contacts = g_list_prepend (contact_list_op->contacts, contact);
priv = book_backend_ldap->priv;
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
if (!priv->ldap) {
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
g_free (contact_list_op);
if (enable_debug)
printf ("generating offline cache failed ... ldap handler is NULL\n");
return;
}
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
ldap_query = e_book_backend_ldap_build_query (book_backend_ldap,
"(beginswith \"file_as\" \"\")");
do {
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
ldap_error = ldap_search_ext (priv->ldap,
priv->ldap_rootdn,
priv->ldap_scope,
NULL, 0, NULL, NULL,
NULL, /* XXX timeout */
LDAP_NO_LIMIT, &contact_list_msgid);
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
} while (e_book_backend_ldap_reconnect (book_backend_ldap, NULL, ldap_error));
g_free (ldap_query);
int status;
char *dn = NULL;
+ if (enable_debug)
+ printf ("e_book_backend_ldap_authenticate_user ... \n");
+
if (bl->priv->mode == GNOME_Evolution_Addressbook_MODE_LOCAL) {
e_book_backend_notify_writable (backend, FALSE);
e_book_backend_notify_connection_status (backend, FALSE);
return;
}
- g_static_rec_mutex_lock (&eds_ldap_handler_lock);
if (!bl->priv->connected || !bl->priv->ldap) {
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
status = e_book_backend_ldap_connect (bl);
if (status != GNOME_Evolution_Addressbook_Success) {
}
}
- else {
- g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
- }
if (!g_ascii_strncasecmp (auth_method, LDAP_SIMPLE_PREFIX, strlen (LDAP_SIMPLE_PREFIX))) {