2007-08-22 [colin] 2.10.0cvs146
[claws.git] / src / editldap.c
index dea34a11190eace53a34c3730b7230aefddb9ece..00c10a78d58ac259d36c6aa5a4964b0d62804639 100644 (file)
@@ -4,7 +4,7 @@
  *
  * 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
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -13,8 +13,8 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
  */
 
 /*
@@ -97,6 +97,8 @@ static gboolean editldap_validate_criteria( gchar *criteria ) {
        gint i;
        gboolean errorFlag;
 
+       g_return_val_if_fail(criteria != NULL, TRUE);
+
        errorFlag = TRUE;
 
        /* Replace delimiters with spaces */
@@ -106,6 +108,7 @@ static gboolean editldap_validate_criteria( gchar *criteria ) {
                        *ptr = ' ';
                ptr++;
        }
+       debug_print("cleaned criteria list: %s\n", criteria);
 
        /* Parse string */
        splitStr = g_strsplit( criteria, " ", 0 );
@@ -242,6 +245,7 @@ static void edit_ldap_server_check( void ) {
        g_strchomp( sPass ); g_strchug( sPass );
        if( *sHost != '\0' ) {
                /* Test connection to server */
+               debug_print("ldap server: %s\nport: %d\nssl: %d\ntls: %d\nbindDN: %s\n", sHost, iPort, ssl, tls, sBind);
                if( ldaputil_test_connect( sHost, iPort, ssl, tls ) ) {
                        /* Attempt to read base DN */
                        baseDN = ldaputil_read_basedn( sHost, iPort, sBind, sPass, iTime, ssl, tls );
@@ -256,8 +260,10 @@ static void edit_ldap_server_check( void ) {
                                }
                                mgu_free_dlist( baseDN );
                                baseDN = node = NULL;
+                               flg = TRUE;
+                       } else {
+                               flg = FALSE;
                        }
-                       flg = TRUE;
                }
        }
        g_free( sHost );
@@ -266,6 +272,7 @@ static void edit_ldap_server_check( void ) {
 
        if( sBaseDN ) {
                /* Load search DN */
+               debug_print("baseDN: %s\n", sBaseDN);
                gtk_entry_set_text(GTK_ENTRY(ldapedit.entry_baseDN), sBaseDN);
                g_free( sBaseDN );
        }
@@ -299,6 +306,7 @@ static void edit_ldap_basedn_select( void ) {
        g_strchomp( sHost ); g_strchug( sHost );
        g_strchomp( sBind ); g_strchug( sBind );
        g_strchomp( sPass ); g_strchug( sPass );
+       debug_print("ldap server: %s\nport: %d\nssl: %d\ntls: %d\nbindDN: %s\n", sHost, iPort, ssl, tls, sBind);
        selectDN = edit_ldap_basedn_selection( sHost, iPort, sBase, iTime, sBind, sPass, ssl, tls );
        if( selectDN ) {
                gtk_entry_set_text(GTK_ENTRY(ldapedit.entry_baseDN), selectDN);
@@ -311,8 +319,8 @@ static void edit_ldap_basedn_select( void ) {
        g_free( sPass );
 }
 
-static void edit_ldap_search_reset( void ) {
-       gtk_entry_set_text(GTK_ENTRY(ldapedit.entry_criteria), LDAPCTL_DFL_ATTR_LIST );
+static void edit_ldap_search_reset(void) {
+       gtk_entry_set_text(GTK_ENTRY(ldapedit.entry_criteria), LDAPCTL_DFL_ATTR_LIST);
 }
 
 static void addressbook_edit_ldap_dialog_create( gboolean *cancelled ) {
@@ -325,6 +333,7 @@ static void addressbook_edit_ldap_dialog_create( gboolean *cancelled ) {
        GtkWidget *hsbox;
        GtkWidget *statusbar;
 
+       debug_print("creating edit_ldap_dialog\n");
        window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "editldap");
        gtk_widget_set_size_request(window, 450, -1);
        gtk_container_set_border_width(GTK_CONTAINER(window), 0);
@@ -383,6 +392,7 @@ static void editldap_update_port (GtkToggleButton *ssl_btn, gpointer data) {
        gtk_spin_button_set_value(
                GTK_SPIN_BUTTON( ldapedit.spinbtn_port ), 
                        val ? LDAPCTL_DFL_SSL_PORT:LDAPCTL_DFL_PORT );
+       debug_print("Setting port: %d\n", val ? LDAPCTL_DFL_SSL_PORT:LDAPCTL_DFL_PORT);
 }
 
 static void addressbook_edit_ldap_page_basic( gint pageNum, gchar *pageLbl ) {
@@ -878,7 +888,7 @@ static void editldap_parse_criteria( gchar *criteria, LdapControl *ctl ) {
 /**
  * Clear entry fields to reasonable defaults (for a new server entry).
  */
-static void edit_ldap_clear_fields( void ) {
+static void edit_ldap_clear_fields(void) {
        gtk_entry_set_text(
                GTK_ENTRY(ldapedit.entry_name), ADDRESSBOOK_GUESS_LDAP_NAME );
        gtk_entry_set_text(
@@ -893,7 +903,7 @@ static void edit_ldap_clear_fields( void ) {
        gtk_spin_button_set_value(
                GTK_SPIN_BUTTON( ldapedit.spinbtn_maxentry ), LDAPCTL_DFL_TIMEOUT );
        gtk_entry_set_text(
-               GTK_ENTRY(ldapedit.entry_criteria), LDAPCTL_DFL_ATTR_LIST );
+               GTK_ENTRY(ldapedit.entry_criteria), LDAPCTL_DFL_ATTR_LIST);
        gtk_spin_button_set_value(
                GTK_SPIN_BUTTON(ldapedit.spinbtn_queryage), LDAPCTL_DFL_QUERY_AGE );
        gtk_toggle_button_set_active(
@@ -933,8 +943,6 @@ static void edit_ldap_set_fields( LdapServer *server ) {
        if( ctl->bindPass )
                gtk_entry_set_text(
                        GTK_ENTRY(ldapedit.entry_bindPW), ctl->bindPass );
-       gtk_spin_button_set_value(
-               GTK_SPIN_BUTTON(ldapedit.spinbtn_port), ctl->port );
        gtk_spin_button_set_value(
                GTK_SPIN_BUTTON(ldapedit.spinbtn_timeout), ctl->timeOut );
        gtk_spin_button_set_value(
@@ -945,6 +953,8 @@ static void edit_ldap_set_fields( LdapServer *server ) {
        gtk_toggle_button_set_active(
                GTK_TOGGLE_BUTTON(ldapedit.enable_ssl), ctl->enableSSL );
 #endif
+       gtk_spin_button_set_value(
+               GTK_SPIN_BUTTON(ldapedit.spinbtn_port), ctl->port );
        /* Format criteria */
        crit = editldap_build_criteria_list( ctl );
        if( crit ) {
@@ -1038,6 +1048,8 @@ AdapterDSource *addressbook_edit_ldap(
        tls = gtk_toggle_button_get_active(
                        GTK_TOGGLE_BUTTON( ldapedit.enable_tls ) );
 #endif
+       debug_print("saving server config:\nname: %s\nhost: %s\nbase: %s\ncriteria: %s\nbind: %s\nport: %d\ntime: %d\nmax_entries: %d\ntimeout: %d\ndynamic: %d\ncheck_match: %d\n",
+                       sName, sHost, sBase, sCrit, sBind, iPort, iTime, iMaxE, iAge, bSrch, bMatch);
        fin = FALSE;
        if( *sName == '\0' ) fin = TRUE;
        if( *sHost == '\0' ) fin = TRUE;