From f1a2efb77a4dd365d65ed4634d16c2eb4fded680 Mon Sep 17 00:00:00 2001 From: Tristan Chabredier Date: Fri, 23 Feb 2007 14:15:55 +0000 Subject: [PATCH] 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. --- ChangeLog | 10 +++++++ PATCHSETS | 1 + configure.ac | 2 +- src/addressbook.c | 47 ++++++++++++++++++-------------- src/addrindex.c | 68 ++++++++++++++++++++++++----------------------- 5 files changed, 74 insertions(+), 54 deletions(-) diff --git a/ChangeLog b/ChangeLog index 90cf40d9d..f5cdf5103 100644 --- 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 diff --git a/PATCHSETS b/PATCHSETS index 8f4865c16..ebd509a5b 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -2383,3 +2383,4 @@ ( 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 diff --git a/configure.ac b/configure.ac index 14d5bbc64..574625467 100644 --- a/configure.ac +++ b/configure.ac @@ -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= diff --git a/src/addressbook.c b/src/addressbook.c index d832631fd..f227e89bc 100644 --- a/src/addressbook.c +++ b/src/addressbook.c @@ -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 ); } diff --git a/src/addrindex.c b/src/addrindex.c index 87c9d4b79..ab86a65a1 100644 --- a/src/addrindex.c +++ b/src/addrindex.c @@ -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; -- 2.25.1