2007-02-23 [wwp] 2.7.2cvs66
authorTristan Chabredier <wwp@claws-mail.org>
Fri, 23 Feb 2007 14:15:55 +0000 (14:15 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Fri, 23 Feb 2007 14:15:55 +0000 (14:15 +0000)
* src/addressbook.c
* src/addrindex.c
Address completion fixes: fix addressbook_peek_folder_exists() in
which the algorithm was ridiculously over-obfuscated and broken.
Fix addrindex_load_completion() as well, to load addresses in
completion list with regards to what addressbook_peek_folder_exists()
returns now.

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

index 90cf40d9dfbcc1fbdfa1ffd6376255f2f19cfdaa..f5cdf51038b9c720012c8841b38ba2b1442b5be7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-02-23 [wwp]       2.7.2cvs66
+
+       * src/addressbook.c
+       * src/addrindex.c
+               Address completion fixes: fix addressbook_peek_folder_exists() in
+               which the algorithm was ridiculously over-obfuscated and broken.
+               Fix addrindex_load_completion() as well, to load addresses in
+               completion list with regards to what addressbook_peek_folder_exists()
+               returns now.
+
 2007-02-23 [wwp]       2.7.2cvs65
 
        * src/addr_compl.c
index 8f4865c164f1661f6c4b8b9b51e8a6e7a8892e88..ebd509a5bbc80b15fdcb60d7a9d36579e368a0a6 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.1.2.20 -r 1.1.2.21 src/plugins/pgpcore/prefs_gpg.c;  cvs diff -u -r 1.1.2.8 -r 1.1.2.9 src/plugins/pgpcore/prefs_gpg.h;  cvs diff -u -r 1.1.2.42 -r 1.1.2.43 src/plugins/pgpcore/sgpgme.c;  cvs diff -u -r 1.1.2.30 -r 1.1.2.31 src/plugins/pgpinline/pgpinline.c;  cvs diff -u -r 1.1.2.46 -r 1.1.2.47 src/plugins/pgpmime/pgpmime.c;  ) > 2.7.2cvs63.patchset
 ( cvs diff -u -r 1.1.2.25 -r 1.1.2.26 src/plugins/pgpcore/passphrase.c;  ) > 2.7.2cvs64.patchset
 ( cvs diff -u -r 1.27.2.28 -r 1.27.2.29 src/addr_compl.c;  ) > 2.7.2cvs65.patchset
+( cvs diff -u -r 1.60.2.81 -r 1.60.2.82 src/addressbook.c;  cvs diff -u -r 1.28.2.23 -r 1.28.2.24 src/addrindex.c;  ) > 2.7.2cvs66.patchset
index 14d5bbc64e16bf8d8d247c606c54019b2bfcb52f..574625467d2b1974d807321463dcf8b5da2dcfa9 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=7
 MICRO_VERSION=2
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=65
+EXTRA_VERSION=66
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index d832631fd5402674e458e48a9e37f860c9ec2c7c..f227e89bca25b3a8c440eada314d695f7f7b5504 100644 (file)
@@ -4786,6 +4786,10 @@ static void addressbook_peek_subfolder_exists_load_folder( ItemFolder *parentFol
 /*
  * This function is used by to check if a matcher book/folder path corresponds to an
    existing addressbook book/folder ("" or "Any" are considered as valid, NULL invalid).
+   Caution: returned book and folder pointers can be NULL even when returning TRUE:
+   if book AND folder are NULL this means that folderpath was empty or Any.
+   If folderpath is a simple book name (without folder), book will not be NULL and folder
+   will be NULL. It's not expected to return book as NULL and folder as non NULL.
  */
 
 gboolean addressbook_peek_folder_exists( gchar *folderpath,
@@ -4798,7 +4802,6 @@ gboolean addressbook_peek_folder_exists( gchar *folderpath,
        AddressBookFile *abf;
        FolderInfo *fi;
        FolderPathMatch folder_path_match = { NULL, FALSE, 0, NULL, NULL };
-       FolderPathMatch *nextmatch;
 
        if ( book )
                *book = NULL;
@@ -4814,13 +4817,15 @@ gboolean addressbook_peek_folder_exists( gchar *folderpath,
        /* split the folder path we've received, we'll try to match this path, subpath by
           subpath against the book/folder structure in order */
        folder_path_match.folder_path = g_strsplit( folderpath, "/", 256 );
+       if (!folder_path_match.folder_path)
+               return FALSE;
 
        list = addrindex_get_interface_list( _addressIndex_ );
-       while ( list ) {
+       while ( list && !folder_path_match.matched ) {
                AddressInterface *interface = list->data;
                if ( interface->type == ADDR_IF_BOOK ) {
                        nodeDS = interface->listSource;
-                       while ( nodeDS ) {
+                       while ( nodeDS && !folder_path_match.matched ) {
                                ds = nodeDS->data;
 
                                /* Read address book */
@@ -4831,29 +4836,31 @@ gboolean addressbook_peek_folder_exists( gchar *folderpath,
                                /* Add node for address book */
                                abf = ds->rawDataSource;
 
-                               /* try to match subfolders if this book is the right book
-                                       (and if there's smth to match, and not yet matched) */
-                               nextmatch = NULL;
-                               if ( folder_path_match.folder_path != NULL &&
-                                        folder_path_match.matched == FALSE &&
-                                        strcmp(folder_path_match.folder_path[0], abf->fileName) == 0 ) {
+                               /* match book name */
+                               if ( strcmp(folder_path_match.folder_path[0], abf->fileName) == 0 ) {
+
                                        debug_print("matched book name '%s'\n", abf->fileName);
-                                       folder_path_match.index = 1;
-                                       if ( folder_path_match.folder_path[folder_path_match.index] == NULL ) {
-                                               /* we've matched all elements */
+                                       folder_path_match.book = ds;
+
+                                       if ( folder_path_match.folder_path[1] == NULL ) {
+                                               /* no folder part to match */
+
                                                folder_path_match.matched = TRUE;
-                                               folder_path_match.book = ds;
+                                               folder_path_match.folder = NULL;
                                                debug_print("book path matched!\n");
+
                                        } else {
-                                               /* keep on matching */
-                                               nextmatch = &folder_path_match;
-                                       }
-                               }
+                                               /* match folder part */
 
-                               fi = addressbook_peek_subfolder_exists_create_folderinfo( abf, NULL );
+                                               fi = addressbook_peek_subfolder_exists_create_folderinfo( abf, NULL );
+                                               rootFolder = addrindex_ds_get_root_folder( ds );
 
-                               rootFolder = addrindex_ds_get_root_folder( ds );
-                               addressbook_peek_subfolder_exists_load_folder( rootFolder, fi, nextmatch );
+                                               /* prepare for recursive call */
+                                               folder_path_match.index = 1;
+                                               /* this call will set folder_path_match.matched and folder_path_match.folder */
+                                               addressbook_peek_subfolder_exists_load_folder( rootFolder, fi, &folder_path_match );
+                                       }
+                               }
 
                                nodeDS = g_list_next( nodeDS );
                        }
index 87c9d4b7963e9083380946722d6c8cb842a73e04..ab86a65a1da1f123ae19653bf8782bc2e36507cc 100644 (file)
@@ -2836,50 +2836,52 @@ gboolean addrindex_load_completion(
                        return FALSE;
                }
 
-               if( book != NULL ) {
-                       AddressBookFile *abf = book->rawDataSource;
+               if( folder != NULL ) {
 
-                       debug_print("addrindex_load_completion: book %p '%s'\n", book, abf->fileName);
+                       GList *items;
+                       GList *nodeM;
+                       gchar *sName;
+                       ItemPerson *person;
 
-                       addrindex_load_completion_load_persons( callBackFunc, book );
+                       debug_print("addrindex_load_completion: folder %p '%s'\n", folder, folder->obj.name);
 
-                       return TRUE;
+                       /* Load email addresses */
+                       items = addritem_folder_get_person_list( folder );
+                       for( ; items != NULL; items = g_list_next( items ) ) {
+                               person = items->data;
+                               nodeM = person->listEMail;
 
-               } else {
+                               /* Figure out name to use */
+                               sName = ADDRITEM_NAME(person);
+                               if( sName == NULL || *sName == '\0' ) {
+                                       sName = person->nickName;
+                               }
 
-                       if( folder != NULL ) {
-                               GList *items;
-                               GList *nodeM;
-                               gchar *sName;
-                               ItemPerson *person;
+                               /* Process each E-Mail address */
+                               while( nodeM ) {
+                                       ItemEMail *email = nodeM->data;
 
-                               debug_print("addrindex_load_completion: folder %p '%s'\n", folder, folder->obj.name);
+                                       callBackFunc( sName, email->address, person->nickName, 
+                                                         ADDRITEM_NAME(email), NULL );
 
-                               /* Load email addresses */
-                               items = addritem_folder_get_person_list( folder );
-                               for( ; items != NULL; items = g_list_next( items ) ) {
-                                       person = items->data;
-                                       nodeM = person->listEMail;
+                                       nodeM = g_list_next( nodeM );
+                               }
+                       }
+                       /* Free up the list */
+                       mgu_clear_list( items );
+                       g_list_free( items );
 
-                                       /* Figure out name to use */
-                                       sName = ADDRITEM_NAME(person);
-                                       if( sName == NULL || *sName == '\0' ) {
-                                               sName = person->nickName;
-                                       }
+                       return TRUE;
 
-                                       /* Process each E-Mail address */
-                                       while( nodeM ) {
-                                               ItemEMail *email = nodeM->data;
+               } else {
 
-                                               callBackFunc( sName, email->address, person->nickName, 
-                                                                 ADDRITEM_NAME(email), NULL );
+                       if( book != NULL ) {
 
-                                               nodeM = g_list_next( nodeM );
-                                       }
-                               }
-                               /* Free up the list */
-                               mgu_clear_list( items );
-                               g_list_free( items );
+                               AddressBookFile *abf = book->rawDataSource;
+
+                               debug_print("addrindex_load_completion: book %p '%s'\n", book, abf->fileName);
+
+                               addrindex_load_completion_load_persons( callBackFunc, book );
 
                                return TRUE;