2007-04-17 [wwp] 2.9.0cvs5
authorTristan Chabredier <wwp@claws-mail.org>
Tue, 17 Apr 2007 13:03:57 +0000 (13:03 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Tue, 17 Apr 2007 13:03:57 +0000 (13:03 +0000)
* src/addressadd.c
* src/addressbook.c
* src/addrindex.c
* src/ldapupdate.c
Fix --disable-ldap build,
fix some LDAP annoyances on
searches, thanks to Colin.

ChangeLog
PATCHSETS
configure.ac
src/addressadd.c
src/addressbook.c
src/addrindex.c
src/ldapupdate.c

index f63372690ab6ae86dba2f3bd149e4d22e7184f0e..0824b4d8fce333d87d8598be3221ab666aea2c47 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-04-17 [wwp]       2.9.0cvs5
+
+       * src/addressadd.c
+       * src/addressbook.c
+       * src/addrindex.c
+       * src/ldapupdate.c
+               Fix --disable-ldap build,
+               fix some LDAP annoyances on 
+               searches, thanks to Colin.
+
 2007-04-17 [wwp]       2.9.0cvs4
 
        * src/ldapupdate.c
index da4c37574a6a3192462eeb4d835d3196c4946da4..19804d8c16553dbec763ab08e53cfbd5e269425b 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.382.2.369 -r 1.382.2.370 src/compose.c;  ) > 2.9.0cvs2.patchset
 ( cvs diff -u -r 1.155.2.60 -r 1.155.2.61 src/Makefile.am;  cvs diff -u -r 1.9.2.13 -r 1.9.2.14 src/addressadd.c;  cvs diff -u -r 1.60.2.84 -r 1.60.2.85 src/addressbook.c;  cvs diff -u -r 1.28.2.25 -r 1.28.2.26 src/addrindex.c;  cvs diff -u -r 1.13.2.10 -r 1.13.2.11 src/addritem.c;  cvs diff -u -r 1.12.2.8 -r 1.12.2.9 src/addritem.h;  cvs diff -u -r 1.14.2.23 -r 1.14.2.24 src/editaddress.c;  cvs diff -u -r 1.2.2.8 -r 1.2.2.9 src/ldapctrl.c;  cvs diff -u -r 1.1.4.9 -r 1.1.4.10 src/ldapctrl.h;  cvs diff -u -r 1.3.2.17 -r 1.3.2.18 src/ldapquery.c;  cvs diff -u -r 1.4.2.8 -r 1.4.2.9 src/ldapserver.c;  cvs diff -u -r 1.2.2.7 -r 1.2.2.8 src/ldapserver.h;  diff -u /dev/null src/ldapupdate.c;  diff -u /dev/null src/ldapupdate.h;  ) > 2.9.0cvs3.patchset
 ( cvs diff -u -r 1.1.2.1 -r 1.1.2.2 src/ldapupdate.c;  ) > 2.9.0cvs4.patchset
+( cvs diff -u -r 1.9.2.14 -r 1.9.2.15 src/addressadd.c;  cvs diff -u -r 1.60.2.85 -r 1.60.2.86 src/addressbook.c;  cvs diff -u -r 1.28.2.26 -r 1.28.2.27 src/addrindex.c;  cvs diff -u -r 1.1.2.2 -r 1.1.2.3 src/ldapupdate.c;  ) > 2.9.0cvs5.patchset
index a1958030d3834d6b994e051d1fa0f0dfb4da56e9..382be9a1e6b725d4674f2500ba223d190b41cf0f 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=4
+EXTRA_VERSION=5
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 8631a0541c45c1da3368727dd02426159ef94337..712da6c1fa223ca5ba40e12d135f2a3d5c6343f9 100644 (file)
@@ -421,6 +421,7 @@ gboolean addressadd_selection( AddressIndex *addrIndex, const gchar *name, const
                                                        address, 
                                                        returned_remarks);
                        person->status = ADD_ENTRY;
+#ifdef USE_LDAP
                        if (fi->book->type == ADBOOKTYPE_LDAP) {
                                LdapServer *server = (LdapServer *) fi->book;
                                ldapsvr_set_modified(server, TRUE);
@@ -432,6 +433,7 @@ gboolean addressadd_selection( AddressIndex *addrIndex, const gchar *name, const
                                        return server->retVal;
                                }
                        }
+#endif
                        g_free(returned_name);
                        g_free(returned_remarks);
                        if( person ) retVal = TRUE;
index eb6d0c9fdaf3723a48429a7b5b5eb8f7abd5ac29..eacbc6aa9e22118680f620ef0f8069109c951185 100644 (file)
@@ -1466,11 +1466,13 @@ static void addressbook_del_clicked(GtkButton *button, gpointer data)
                                if (pobj->type == ADDR_ITEM_FOLDER)
                                        addritem_folder_remove_person(ADAPTER_FOLDER(pobj)->itemFolder, item);
                                item = addrbook_remove_person( abf, item );
+#ifdef USE_LDAP
                                if (ds->type == ADDR_IF_LDAP) {
                                        LdapServer *server = ds->rawDataSource;
                                        ldapsvr_set_modified(server, TRUE);
                                        ldapsvr_update_book(server, item);
                                }
+#endif
                                if( item ) {
                                        addritem_free_item_person( item );
                                }
@@ -1904,6 +1906,8 @@ static void addressbook_list_menu_setup( void ) {
        else if( pobj->type != ADDR_INTERFACE ) {
                /* Parent object is not an interface */
                ds = addressbook_find_datasource( addrbook.treeSelected );
+               if (!ds)
+                       return;
                iface = ds->interface;
                if( ! iface->readOnly ) {
                        /* Folder or group */
@@ -2883,6 +2887,104 @@ static void addressbook_new_address_from_folder_post_cb( ItemPerson *person )
        addressbook_address_list_set_focus();
 }
 
+/**
+ * Label (a format string) that is used to name each folder.
+ */
+static gchar *_queryFolderLabel_ = N_( "Search '%s'" );
+
+/**
+ * Search ctree widget callback function.
+ * \param  pA Pointer to node.
+ * \param  pB Pointer to data item being sought.
+ * \return Zero (0) if folder found.
+ */
+static int addressbook_treenode_find_folder_cb( gconstpointer pA, gconstpointer pB ) {
+       AddressObject *aoA;
+
+       aoA = ( AddressObject * ) pA;
+       if( aoA->type == ADDR_ITEM_FOLDER ) {
+               ItemFolder *folder, *fld;
+
+               fld = ADAPTER_FOLDER(aoA)->itemFolder;
+               folder = ( ItemFolder * ) pB;
+               if( fld == folder ) return 0;   /* Found folder */
+       }
+       return 1;
+}
+
+static ItemFolder * addressbook_setup_subf(
+               AddressDataSource *ds, gchar *title,
+               GtkCTreeNode *pNode )
+{
+       AddrBookBase *adbase;
+       AddressCache *cache;
+       ItemFolder *folder;
+       GtkCTree *ctree;
+       GtkCTreeNode *nNode;
+       gchar *name;
+       AddressObjectType aoType = ADDR_NONE;
+       GList *children;
+       /* Setup a query */
+       if( *title == '\0' || strlen( title ) < 1 ) return NULL;
+
+       if( ds->type == ADDR_IF_LDAP ) {
+#if USE_LDAP
+               aoType = ADDR_LDAP_QUERY;
+#endif
+       }
+       else {
+               return NULL;
+       }
+
+       ctree = GTK_CTREE(addrbook.ctree);
+       /* Get reference to address cache */    
+       adbase = ( AddrBookBase * ) ds->rawDataSource;
+       cache = adbase->addressCache;
+       
+       if ((children = addrcache_get_list_folder(cache)) != NULL) {
+               GList *cur = children;
+               for (; cur; cur = cur->next) {
+                       ItemFolder *child = (ItemFolder *) cur->data;
+                       if (!strcmp2(ADDRITEM_NAME(child), title)) {
+                               nNode = gtk_ctree_find_by_row_data_custom(
+                                       ctree, NULL, child,
+                                       addressbook_treenode_find_folder_cb );
+                               if( nNode ) {
+                                       addrindex_remove_results( ds, child );
+                                       while( child->listPerson ) {
+                                               ItemPerson *item = ( ItemPerson * ) child->listPerson->data;
+                                               item = addrcache_remove_person( cache, item );
+                                               if( item ) {
+                                                       addritem_free_item_person( item );
+                                                       item = NULL;
+                                               }
+                                       }
+                                       gtk_sctree_select( GTK_SCTREE(ctree), nNode );
+                                       addrbook.treeSelected = nNode;
+                               }       
+                               return child;
+                       }
+               }
+       }
+       
+       /* Create a folder */
+       folder = addrcache_add_new_folder( cache, NULL );
+       name = g_strdup_printf( "%s", title );
+       addritem_folder_set_name( folder, name );
+       addritem_folder_set_remarks( folder, "" );
+       g_free( name );
+
+       /* Now let's see the folder */
+       nNode = addressbook_node_add_folder( pNode, ds, folder, aoType );
+       gtk_ctree_expand( ctree, pNode );
+       if( nNode ) {
+               gtk_sctree_select( GTK_SCTREE(ctree), nNode );
+               addrbook.treeSelected = nNode;
+               return folder;
+       }
+       return NULL;
+}
+
 static void addressbook_new_address_cb( gpointer data, guint action, GtkWidget *widget ) {
        AddressObject *pobj = NULL;
        AddressDataSource *ds = NULL;
@@ -2908,11 +3010,36 @@ static void addressbook_new_address_cb( gpointer data, guint action, GtkWidget *
        if( pobj->type == ADDR_DATASOURCE ) {
                if (ADAPTER_DSOURCE(pobj)->subType == ADDR_BOOK ||
                    ADAPTER_DSOURCE(pobj)->subType == ADDR_LDAP) {
-                       /* New address */
-                       ItemPerson *person = addressbook_edit_person( abf, NULL, NULL, FALSE,
+                       ItemPerson *person;
+                       ItemFolder *folder = NULL;
+#ifdef USE_LDAP
+                       if (abf->type == ADDR_IF_LDAP) {
+                               GtkCTreeNode *parentNode;
+                               ds = addressbook_find_datasource( GTK_CTREE_NODE( addrbook.treeSelected ) );
+                               if( ds == NULL ) return;
+
+                               /* We must have a datasource that is an external interface */
+                               if( ! ds->interface->haveLibrary ) return;
+                               if( ! ds->interface->externalQuery ) return;
+
+                               if( pobj->type == ADDR_ITEM_FOLDER ) {
+                                       parentNode = GTK_CTREE_ROW(GTK_CTREE_NODE( addrbook.treeSelected ) )->parent;
+                               }
+                               else {
+                                       parentNode = GTK_CTREE_NODE( addrbook.treeSelected );
+                               }
+                               folder = addressbook_setup_subf( ds, _("New Contacts"), parentNode );
+
+                               pobj = gtk_ctree_node_get_row_data(GTK_CTREE(addrbook.ctree), addrbook.treeSelected);
+                               ds = addressbook_find_datasource( GTK_CTREE_NODE(addrbook.treeSelected) );
+                               abf = ds->rawDataSource;
+                       }
+#endif
+                       person = addressbook_edit_person( abf, folder, NULL, FALSE,
                                                                  addrbook.editaddress_vbox,
                                                                  addressbook_new_address_from_book_post_cb,
                                                                  TRUE );
+#ifdef USE_LDAP
                        if (abf->type == ADDR_IF_LDAP) {
                                LdapServer *server = ds->rawDataSource;
                                ldapsvr_set_modified(server, TRUE);
@@ -2924,6 +3051,7 @@ static void addressbook_new_address_cb( gpointer data, guint action, GtkWidget *
                                        return;
                                }
                        }
+#endif
                        if (prefs_common.addressbook_use_editaddress_dialog)
                                addressbook_new_address_from_book_post_cb( person );
                }
@@ -2931,10 +3059,36 @@ static void addressbook_new_address_cb( gpointer data, guint action, GtkWidget *
        else if( pobj->type == ADDR_ITEM_FOLDER ) {
                /* New address */
                ItemFolder *folder = ADAPTER_FOLDER(pobj)->itemFolder;
-               ItemPerson *person = addressbook_edit_person( abf, folder, NULL, FALSE,
+               ItemPerson *person;
+#ifdef USE_LDAP
+               if (abf->type == ADDR_IF_LDAP) {
+                       GtkCTreeNode *parentNode;
+                       ds = addressbook_find_datasource( GTK_CTREE_NODE( addrbook.treeSelected ) );
+                       if( ds == NULL ) return;
+
+                       /* We must have a datasource that is an external interface */
+                       if( ! ds->interface->haveLibrary ) return;
+                       if( ! ds->interface->externalQuery ) return;
+
+                       if( pobj->type == ADDR_ITEM_FOLDER ) {
+                               parentNode = GTK_CTREE_ROW(GTK_CTREE_NODE( addrbook.treeSelected ) )->parent;
+                       }
+                       else {
+                               parentNode = GTK_CTREE_NODE( addrbook.treeSelected );
+                       }
+                       folder = addressbook_setup_subf( ds, _("New Contacts"), parentNode );
+                       if (!folder)
+                               return;
+                       pobj = gtk_ctree_node_get_row_data(GTK_CTREE(addrbook.ctree), addrbook.treeSelected);
+                       ds = addressbook_find_datasource( GTK_CTREE_NODE(addrbook.treeSelected) );
+                       abf = ds->rawDataSource;
+               }
+#endif
+               person = addressbook_edit_person( abf, folder, NULL, FALSE,
                                                          addrbook.editaddress_vbox,
                                                          addressbook_new_address_from_folder_post_cb,
                                                          TRUE );
+#ifdef USE_LDAP
                if (abf->type == ADDR_IF_LDAP) {
                        LdapServer *server = ds->rawDataSource;
                        ldapsvr_set_modified(server, TRUE);
@@ -2946,6 +3100,7 @@ static void addressbook_new_address_cb( gpointer data, guint action, GtkWidget *
                                return;
                        }
                }
+#endif
                if (prefs_common.addressbook_use_editaddress_dialog)
                        addressbook_new_address_from_folder_post_cb( person );
        }
@@ -3106,10 +3261,12 @@ static void addressbook_edit_address( gpointer data, guint action, GtkWidget *wi
                                                                                   addressbook_edit_address_post_cb,
                                                                                   (prefs_common.addressbook_use_editaddress_dialog||force_focus) )
                                  != NULL ) { 
+#ifdef USE_LDAP
                                if (abf->type == ADDR_IF_LDAP) {
                                        ldapsvr_set_modified( (LdapServer *) abf, TRUE );
                                        person->status = UPDATE_ENTRY;
                                }
+#endif
                                if (prefs_common.addressbook_use_editaddress_dialog)
                                        addressbook_edit_address_post_cb( person );
                        }
@@ -3123,10 +3280,12 @@ static void addressbook_edit_address( gpointer data, guint action, GtkWidget *wi
                                                                          addressbook_edit_address_post_cb,
                                                                          (prefs_common.addressbook_use_editaddress_dialog||force_focus) )
                        != NULL ) {
+#ifdef USE_LDAP
                                if (abf->type == ADDR_IF_LDAP) {
                                        ldapsvr_set_modified( (LdapServer *) abf, TRUE );
                                        person->status = UPDATE_ENTRY;
                                }
+#endif
                                if (prefs_common.addressbook_use_editaddress_dialog)
                                        addressbook_edit_address_post_cb( person );
                }
@@ -3420,26 +3579,6 @@ static int addressbook_treenode_find_group_cb( gconstpointer pA, gconstpointer p
        return 1;
 }
 
-/**
- * Search ctree widget callback function.
- * \param  pA Pointer to node.
- * \param  pB Pointer to data item being sought.
- * \return Zero (0) if folder found.
- */
-static int addressbook_treenode_find_folder_cb( gconstpointer pA, gconstpointer pB ) {
-       AddressObject *aoA;
-
-       aoA = ( AddressObject * ) pA;
-       if( aoA->type == ADDR_ITEM_FOLDER ) {
-               ItemFolder *folder, *fld;
-
-               fld = ADAPTER_FOLDER(aoA)->itemFolder;
-               folder = ( ItemFolder * ) pB;
-               if( fld == folder ) return 0;   /* Found folder */
-       }
-       return 1;
-}
-
 /*
 * Remove folder and group nodes from tree widget for items contained ("cut")
 * in clipboard.
@@ -4167,11 +4306,6 @@ static void addressbook_search_callback_end(
        addrindex_stop_search( queryID );
 }
 
-/**
- * Label (a format string) that is used to name each folder.
- */
-static gchar *_queryFolderLabel_ = N_( "Search '%s'" );
-
 /**
  * Perform search.
  *
@@ -4186,12 +4320,12 @@ static void addressbook_perform_search(
        AddrBookBase *adbase;
        AddressCache *cache;
        ItemFolder *folder;
-       GtkCTree *ctree;
-       GtkCTreeNode *nNode;
        gchar *name;
        gint queryID;
        guint idleID;
+#ifdef USE_LDAP
        AddressObjectType aoType = ADDR_NONE;
+#endif
 
        /* Setup a query */
        if( *searchTerm == '\0' || strlen( searchTerm ) < 1 ) return;
@@ -4204,27 +4338,15 @@ static void addressbook_perform_search(
        else {
                return;
        }
-
        /* Get reference to address cache */    
        adbase = ( AddrBookBase * ) ds->rawDataSource;
        cache = adbase->addressCache;
 
        /* Create a folder for the search results */
-       folder = addrcache_add_new_folder( cache, NULL );
        name = g_strdup_printf( _queryFolderLabel_, searchTerm );
-       addritem_folder_set_name( folder, name );
-       addritem_folder_set_remarks( folder, "" );
+       folder = addressbook_setup_subf(ds, name, pNode);
        g_free( name );
 
-       /* Now let's see the folder */
-       ctree = GTK_CTREE(addrbook.ctree);
-       nNode = addressbook_node_add_folder( pNode, ds, folder, aoType );
-       gtk_ctree_expand( ctree, pNode );
-       if( nNode ) {
-               gtk_sctree_select( GTK_SCTREE(ctree), nNode );
-               addrbook.treeSelected = nNode;
-       }
-
        /* Setup the search */
        queryID = addrindex_setup_explicit_search(
                ds, searchTerm, folder, addressbook_search_callback_end, NULL );
index e2955ef0dd7782cbb4fd9cddae29f84c8d894fac..ffec71c30603aeb96fe9cedd8bf412b401f164e7 100644 (file)
@@ -1721,6 +1721,7 @@ gint addrindex_save_data( AddressIndex *addrIndex ) {
        g_return_val_if_fail( addrIndex != NULL, -1 );
        nodeIf = addrIndex->interfaceList;
 
+#ifdef USE_LDAP
        /* save LDAP interfaces */
        while ( nodeIf ) {
                AddressInterface *iface = nodeIf->data;
@@ -1749,7 +1750,7 @@ gint addrindex_save_data( AddressIndex *addrIndex ) {
                }
                nodeIf = g_list_next( nodeIf );
        }
-
+#endif
        addrIndex->retVal = MGU_NO_FILE;
        if( addrIndex->fileName == NULL || *addrIndex->fileName == '\0' ) return addrIndex->retVal;
        if( addrIndex->filePath == NULL || *addrIndex->filePath == '\0' ) return addrIndex->retVal;
index 15c984baf709f5ea0f2c091ddf0b3ed717478bdd..f5c33b5b4b516f85b18fd5078c322df813a6aa45 100644 (file)
@@ -883,9 +883,6 @@ void ldapsvr_update_book(LdapServer *server, ItemPerson *item) {
        else {
                ItemFolder *folder = server->addressCache->rootFolder;
                node = folder->listFolder;
-               if (node)
-                       node = g_list_copy(node);
-               node = g_list_prepend(node, server->addressCache->rootFolder);
                if (node) {
                        while (node) {
                                AddrItemObject *aio = node->data;
@@ -919,7 +916,6 @@ void ldapsvr_update_book(LdapServer *server, ItemPerson *item) {
                                }
                                node = g_list_next(node);
                        }
-                       g_list_free(node);
                }
        }
        head = contacts;