/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2001-2009 Match Grun and the Claws Mail team
+ * Copyright (C) 2001-2012 Match Grun and the Claws Mail team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#ifdef HAVE_CONFIG_H
# include "config.h"
+#include "claws-features.h"
#endif
#include "defs.h"
#include "addr_compl.h"
#include "utils.h"
#include "alertpanel.h"
+#include "passwordstore.h"
#ifndef DEV_STANDALONE
#include "prefs_gtk.h"
#include "ldaputil.h"
#endif
+#ifdef G_OS_WIN32
+#undef interface
+#endif
+
#define TAG_ADDRESS_INDEX "addressbook"
#define TAG_IF_ADDRESS_BOOK "book_list"
break;
}
}
- xtag = xtagPrev;
}
/* Build list of search attributes */
gboolean bDynSearch;
gboolean bTLS, bSSL;
gint iMatch;
+ gchar *password = NULL;
/* g_print( "addrindex_parse_ldap\n" ); */
/* Set up some defaults */
ldapctl_set_bind_dn( ctl, value );
}
else if( strcmp( name, ATTAG_LDAP_BIND_PASS ) == 0 ) {
- ldapctl_set_bind_password( ctl, value, FALSE, FALSE );
+ password = value;
}
else if( strcmp( name, ATTAG_LDAP_CRITERIA ) == 0 ) {
g_free( criteria );
attr = g_list_next( attr );
}
+ if (password != NULL)
+ passwd_store_set(PWS_CORE, "LDAP", ctl->hostName, password, TRUE);
+
server = ldapsvr_create_noctl();
ldapsvr_set_name( server, serverName );
ldapsvr_set_search_flag( server, bDynSearch );
ldapctl_set_matching_option( ctl, iMatch );
-#ifdef USE_LDAP_TLS
ldapctl_set_tls( ctl, bTLS );
ldapctl_set_ssl( ctl, bSSL );
-#endif
g_free( serverName );
ldapsvr_set_control( server, ctl );
ds->rawDataSource = server;
return -1;
if (addrindex_write_attr( fp, ATTAG_LDAP_BIND_DN, ctl->bindDN ) < 0)
return -1;
- if (addrindex_write_attr( fp, ATTAG_LDAP_BIND_PASS, ctl->bindPass ) < 0)
- return -1;
sprintf( value, "%d", ctl->maxEntries );
if (addrindex_write_attr( fp, ATTAG_LDAP_MAX_ENTRY, value ) < 0)
* \param file Address index file.
*/
static void addrindex_read_index( AddressIndex *addrIndex, XMLFile *file ) {
- guint prev_level;
XMLTag *xtag;
AddressInterface *iface = NULL, *dsIFace = NULL;
AddressDataSource *ds;
addrIndex->loadedFlag = FALSE;
for (;;) {
- prev_level = file->level;
rc = xml_parse_next_tag( file );
- if( file->level == 0 ) return;
+ if( rc < 0 || file->level == 0 ) return;
xtag = xml_get_current_tag( file );
fileSpec = NULL;
return addrIndex->retVal;
fail:
- g_warning("error writing AB index\n");
+ g_warning("error writing AB index");
addrIndex->retVal = MGU_ERROR_WRITE;
if (pfile)
prefs_file_close_revert( pfile );
node->list = g_list_append( node->list, newNode );
}
else {
- /* g_print( "invalid: !!! \n" ); */
- attr = xml_get_current_tag_attr( file );
+ g_warning("Invalid tag");
}
}
}
*/
static void addrindex_consume_tree( XMLFile *file ) {
guint prev_level;
- gchar *element;
- GList *attr;
- XMLTag *xtag;
for (;;) {
prev_level = file->level;
xml_parse_next_tag( file );
- if (file->level < prev_level) return;
+ if (file->level < prev_level)
+ return;
- xtag = xml_get_current_tag( file );
- /* g_print( "tag : %s\n", xtag->tag ); */
- element = xml_get_element( file );
- attr = xml_get_current_tag_attr( file );
- /* show_attribs( attr ); */
- /* g_print( "\ttag value : %s :\n", element ); */
addrindex_consume_tree( file );
}
}
-/*
-* Print temporary tree.
-*/
-static void addrindex_print_node( AddressCvtNode *node, FILE *stream ) {
- GList *list;
-
- fprintf( stream, "Node:\ttype :%d:\n", node->type );
- fprintf( stream, "\tname :%s:\n", node->name );
- fprintf( stream, "\taddr :%s:\n", node->address );
- fprintf( stream, "\trems :%s:\n", node->remarks );
- if( node->list ) {
- fprintf( stream, "\t--list----\n" );
- }
- list = node->list;
- while( list ) {
- AddressCvtNode *lNode = list->data;
- list = g_list_next( list );
- addrindex_print_node( lNode, stream );
- }
- fprintf( stream, "\t==list-%d==\n", node->type );
-}
-
/*
* Free up temporary tree.
*/
*/
static void addrindex_convert_tree( AddressIndex *addrIndex, XMLFile *file ) {
guint prev_level;
- gchar *element;
- GList *attr;
XMLTag *xtag;
/* Process file */
}
return;
}
- element = xml_get_element( file );
- attr = xml_get_current_tag_attr( file );
- /* show_attribs( attr ); */
- /* g_print( "\ttag value : %s :\n", element ); */
addrindex_consume_tree( file );
}
}
*/
void addrindex_remove_results( AddressDataSource *ds, ItemFolder *folder ) {
AddrBookBase *adbase;
- AddressCache *cache;
gint queryID = 0;
/* g_print( "addrindex_remove_results/start\n" ); */
/* g_print( "folder name ::%s::\n", ADDRITEM_NAME(folder) ); */
adbase = ( AddrBookBase * ) ds->rawDataSource;
if( adbase == NULL ) return;
- cache = adbase->addressCache;
/* Hide folder to prevent re-display */
addritem_folder_set_hidden( folder, TRUE );
folderpath must not be empty or NULL */
if( ! addressbook_peek_folder_exists( folderpath, &book, &folder ) ) {
- g_warning("addrindex_load_completion: folder path '%s' doesn't exist\n", folderpath);
+ g_warning("addrindex_load_completion: folder path '%s' doesn't exist", folderpath);
return FALSE;
}
return TRUE;
} else {
- g_warning("addrindex_load_completion: book/folder path is valid but got no pointer\n");
+ g_warning("addrindex_load_completion: book/folder path is valid but got no pointer");
}
}
return FALSE;
return filename;
}
+#ifdef USE_LDAP
+GSList *addrindex_get_password_protected_ldap_servers()
+{
+ AddressInterface *iface;
+ AddressDataSource *ds;
+ GList *nodeIf;
+ GList *nodeDS;
+ GSList *list = NULL;
+ LdapServer *server;
+ LdapControl *ctl;
+
+ nodeIf = _addressIndex_->searchOrder;
+ while (nodeIf) {
+ iface = nodeIf->data;
+ nodeIf = g_list_next(nodeIf);
+
+ if (!iface->useInterface)
+ continue;
+ if (!iface->externalQuery)
+ continue;
+ if (iface->type != ADDR_IF_LDAP)
+ continue;
+
+ nodeDS = iface->listSource;
+ while (nodeDS) {
+ ds = nodeDS->data;
+ nodeDS = g_list_next(nodeDS);
+ server = ds->rawDataSource;
+ if (!server->searchFlag)
+ continue;
+
+ ctl = server->control;
+
+ if (!ctl)
+ continue;
+
+ if (ctl->bindDN != NULL && strlen(ctl->bindDN)) {
+ list = g_slist_append(list, server);
+ }
+ }
+ }
+
+ return list;
+}
+#endif /* USE_LDAP */
+
/*
* End of Source.
*/