Tidy up, fix memory leak.
authorMatch Grun <match@dimensional.com>
Sat, 16 Mar 2002 06:10:46 +0000 (06:10 +0000)
committerMatch Grun <match@dimensional.com>
Sat, 16 Mar 2002 06:10:46 +0000 (06:10 +0000)
17 files changed:
src/addrbook.c
src/addrbook.h
src/addrcache.c
src/addrcache.h
src/addressbook.c
src/addressbook.h
src/addrindex.c
src/editbook.c
src/importldif.c
src/importmutt.c
src/jpilot.c
src/jpilot.h
src/main.c
src/syldap.c
src/syldap.h
src/vcard.c
src/vcard.h

index 7db21ab..605771f 100644 (file)
@@ -18,7 +18,7 @@
  */
 
 /*
- * General functions for accessing external address book files.
+ * General functions for accessing address book files.
  */
 
 #include <glib.h>
@@ -56,15 +56,13 @@ AddressBookFile *addrbook_create_book() {
        book = g_new0( AddressBookFile, 1 );
        book->type = ADBOOKTYPE_BOOK;
        book->addressCache = addrcache_create();
-       book->accessFlag = FALSE;
        book->retVal = MGU_SUCCESS;
        book->path = NULL;
        book->fileName = NULL;
        book->maxValue = 0;
        book->tempList = NULL;
        book->tempHash = NULL;
-       book->readFlag = FALSE;
-       book->modifyFlag = TRUE;
+       book->addressCache->modified = TRUE;
        return book;
 }
 
@@ -89,21 +87,29 @@ void addrbook_set_file( AddressBookFile *book, const gchar *value ) {
        book->fileName = mgu_replace_string( book->fileName, value );
        addrcache_set_dirty( book->addressCache, TRUE );
 }
-void addrbook_set_accessed( AddressBookFile *book, const gboolean value ) {
-       g_return_if_fail( book != NULL );
-       book->accessFlag = value;
-}
 gboolean addrbook_get_modified( AddressBookFile *book ) {
        g_return_val_if_fail( book != NULL, FALSE );
-       return book->modifyFlag;
+       return book->addressCache->modified;
+}
+void addrbook_set_modified( AddressBookFile *book, const gboolean value ) {
+       g_return_if_fail( book != NULL );
+       book->addressCache->modified = value;
 }
 gboolean addrbook_get_accessed( AddressBookFile *book ) {
        g_return_val_if_fail( book != NULL, FALSE );
-       return book->accessFlag;
+       return book->addressCache->accessFlag;
+}
+void addrbook_set_accessed( AddressBookFile *book, const gboolean value ) {
+       g_return_if_fail( book != NULL );
+       book->addressCache->accessFlag = value;
 }
 gboolean addrbook_get_read_flag( AddressBookFile *book ) {
        g_return_val_if_fail( book != NULL, FALSE );
-       return book->readFlag;
+       return book->addressCache->dataRead;
+}
+void addrbook_set_read_flag( AddressBookFile *book, const gboolean value ) {
+       g_return_if_fail( book != NULL );
+       book->addressCache->dataRead = value;
 }
 gint addrbook_get_status( AddressBookFile *book ) {
        g_return_val_if_fail( book != NULL, -1 );
@@ -144,9 +150,9 @@ void addrbook_empty_book( AddressBookFile *book ) {
        /* Reset to initial state */
        book->tempList = NULL;
        book->tempHash = NULL;
-       book->readFlag = FALSE;
-       book->modifyFlag = FALSE;
-       book->accessFlag = FALSE;
+       book->addressCache->dataRead = FALSE;
+       book->addressCache->modified = FALSE;
+       book->addressCache->accessFlag = FALSE;
        book->retVal = MGU_SUCCESS;
 }
 
@@ -159,7 +165,6 @@ void addrbook_free_book( AddressBookFile *book ) {
        /* Clear cache */
        addrcache_clear( book->addressCache );
        addrcache_free( book->addressCache );
-       addrcache_set_dirty( book->addressCache, FALSE );
 
        /* Free up internal objects */
        g_free( book->path );
@@ -171,12 +176,9 @@ void addrbook_free_book( AddressBookFile *book ) {
        book->maxValue = 0;
        book->tempList = NULL;
        book->tempHash = NULL;
-       book->readFlag = FALSE;
-       book->modifyFlag = FALSE;
 
        book->type = ADBOOKTYPE_NONE;
        book->addressCache = NULL;
-       book->accessFlag = FALSE;
        book->retVal = MGU_SUCCESS;
 
        g_free( book );
@@ -847,10 +849,16 @@ gint addrbook_read_data( AddressBookFile *book ) {
 
        g_return_val_if_fail( book != NULL, -1 );
 
+       /*
+       printf( "...addrbook_read_data :%s:\t:%s:\n", book->fileName,
+               addrcache_get_name( book->addressCache ) );
+       */
+
        fileSpec = g_strconcat( book->path, G_DIR_SEPARATOR_S, book->fileName, NULL );
        book->retVal = MGU_OPEN_FILE;
-       book->accessFlag = FALSE;
-       book->modifyFlag = FALSE;
+       addrcache_clear( book->addressCache );
+       book->addressCache->modified = FALSE;
+       book->addressCache->accessFlag = FALSE;
        file = xml_open_file( fileSpec );
        g_free( fileSpec );
        if( file ) {
@@ -867,7 +875,8 @@ gint addrbook_read_data( AddressBookFile *book ) {
                /* Resolve folder items */
                addrbook_resolve_folder_items( book );
                book->tempList = NULL;
-               book->readFlag = TRUE;
+               book->addressCache->modified = FALSE;
+               book->addressCache->dataRead = TRUE;
                addrcache_set_dirty( book->addressCache, FALSE );
        }
        return book->retVal;
@@ -1987,6 +1996,28 @@ ItemPerson *addrbook_add_contact( AddressBookFile *book, ItemFolder *folder, con
        return addrcache_add_contact( book->addressCache, folder, name, address, remarks );
 }
 
+/*
+ * Return file name for next address book file.
+ * Enter:  book Address book.
+ * Return: File name, or NULL if could not create. This should be g_free()
+ *         when done.
+ */
+gchar *addrbook_guess_next_file( AddressBookFile *book ) {
+       gchar *newFile = NULL;
+       GList *fileList = NULL;
+       gint fileNum = 1;
+       fileList = addrbook_get_bookfile_list( book );
+       if( fileList ) {
+               fileNum = 1 + book->maxValue;
+       }
+       newFile = addrbook_gen_new_file_name( fileNum );
+       g_list_free( fileList );
+       fileList = NULL;
+       return newFile;
+}
+
 /*
 * End of Source.
 */
+
+
index c584100..84d8cd3 100644 (file)
@@ -38,15 +38,12 @@ typedef struct _AddressBookFile AddressBookFile;
 struct _AddressBookFile {
        AddressBookType type;
        AddressCache *addressCache;
-       gboolean   accessFlag;
        gint       retVal;
        gchar      *path;
        gchar      *fileName;
        gint       maxValue;
        GList      *tempList;
        GHashTable *tempHash;
-       gboolean   readFlag;
-       gboolean   modifyFlag;
        jmp_buf    jumper;
 };
 
@@ -61,10 +58,12 @@ void addrbook_dump_book                     ( AddressBookFile *book, FILE *stream );
 void addrbook_set_name                 ( AddressBookFile *book, const gchar *value );
 void addrbook_set_path                 ( AddressBookFile *book, const gchar *value );
 void addrbook_set_file                 ( AddressBookFile *book, const gchar *value );
-void addrbook_set_accessed             ( AddressBookFile *book, const gboolean value );
 gboolean addrbook_get_modified         ( AddressBookFile *book );
+void addrbook_set_modified             ( AddressBookFile *book, const gboolean value );
 gboolean addrbook_get_accessed         ( AddressBookFile *book );
+void addrbook_set_accessed             ( AddressBookFile *book, const gboolean value );
 gboolean addrbook_get_read_flag                ( AddressBookFile *book );
+void addrbook_set_read_flag            ( AddressBookFile *book, const gboolean value );
 gint addrbook_get_status               ( AddressBookFile *book );
 ItemFolder *addrbook_get_root_folder   ( AddressBookFile *book );
 GList *addrbook_get_list_folder                ( AddressBookFile *book );
@@ -97,8 +96,10 @@ ItemGroup *addrbook_add_group_list   ( AddressBookFile *book, ItemFolder *folder,
                                          GList *listEMail );
 ItemFolder *addrbook_add_new_folder    ( AddressBookFile *book, ItemFolder *parent );
 
-void addrbook_update_attrib_list       ( AddressBookFile *book, ItemPerson *person, GList *listAttrib );
-void addrbook_add_attrib_list          ( AddressBookFile *book, ItemPerson *person, GList *listAttrib );
+void addrbook_update_attrib_list       ( AddressBookFile *book, ItemPerson *person,
+                                         GList *listAttrib );
+void addrbook_add_attrib_list          ( AddressBookFile *book, ItemPerson *person,
+                                         GList *listAttrib );
 
 ItemFolder *addrbook_remove_folder     ( AddressBookFile *book, ItemFolder *folder );
 ItemFolder *addrbook_remove_folder_delete( AddressBookFile *book, ItemFolder *folder );
@@ -113,4 +114,6 @@ ItemPerson *addrbook_add_contact    ( AddressBookFile *book, ItemFolder *folder,
                                          const gchar *name, const gchar *address,
                                          const gchar *remarks );
 
+gchar *addrbook_guess_next_file                ( AddressBookFile *book );
+
 #endif /* __ADDRBOOK_H__ */
index e692754..bd60b08 100644 (file)
@@ -21,9 +21,7 @@
  * Functions to maintain address cache.
  */
 
-#include <glib.h>
 #include <stdio.h>
-#include <string.h>
 #include <sys/stat.h>
 
 #include "mgutils.h"
@@ -63,6 +61,7 @@ AddressCache *addrcache_create() {
        cache->dataRead = FALSE;
        cache->modified = FALSE;
        cache->dirtyFlag = FALSE;
+       cache->accessFlag = FALSE;
        cache->name = NULL;
        cache->modifyTime = 0;
 
@@ -103,6 +102,30 @@ void addrcache_set_dirty( AddressCache *cache, const gboolean value ) {
        g_return_if_fail( cache != NULL );
        cache->dirtyFlag = value;
 }
+gboolean addrcache_get_modified( AddressCache *cache ) {
+       g_return_val_if_fail( cache != NULL, FALSE );
+       return cache->modified;
+}
+void addrcache_set_modified( AddressCache *cache, const gboolean value ) {
+       g_return_if_fail( cache != NULL );
+       cache->modified = value;
+}
+gboolean addrcache_get_read_flag( AddressCache *cache ) {
+       g_return_val_if_fail( cache != NULL, FALSE );
+       return cache->dataRead;
+}
+void addrcache_set_read_flag( AddressCache *cache, const gboolean value ) {
+       g_return_if_fail( cache != NULL );
+       cache->dataRead = value;
+}
+gboolean addrcache_get_accessed( AddressCache *cache ) {
+       g_return_val_if_fail( cache != NULL, FALSE );
+       return cache->accessFlag;
+}
+void addrcache_set_accessed( AddressCache *cache, const gboolean value ) {
+       g_return_if_fail( cache != NULL );
+       cache->accessFlag = value;
+}
 gchar *addrcache_get_name( AddressCache *cache ) {
        g_return_val_if_fail( cache != NULL, NULL );
        return cache->name;
@@ -128,6 +151,7 @@ void addrcache_next_id( AddressCache *cache ) {
 void addrcache_refresh( AddressCache *cache ) {
        cache->dataRead = FALSE;
        cache->modified = TRUE;
+       cache->accessFlag = FALSE;
        cache->modifyTime = 0;
 }
 
@@ -186,6 +210,7 @@ static void addrcache_free_all_folders( ItemFolder *parent ) {
 void addrcache_clear( AddressCache *cache ) {
        g_return_if_fail( cache != NULL );
 
+       /* printf( "...addrcache_clear :%s:\n", cache->name ); */
        /* Free up folders and hash table */
        addrcache_free_all_folders( cache->rootFolder );
        addrcache_free_item_hash( cache->itemHash );
index cfb7877..754e104 100644 (file)
@@ -42,6 +42,7 @@ struct _AddressCache {
        ItemFolder *rootFolder;
        gchar      *cacheID;
        gboolean   dirtyFlag;
+       gboolean   accessFlag;
        gchar      *name;
 };
 
@@ -53,6 +54,15 @@ GList *addrcache_get_list_person     ( AddressCache *cache );
 gboolean addrcache_get_dirty           ( AddressCache *cache );
 void addrcache_set_dirty               ( AddressCache *cache,
                                          const gboolean value );
+gboolean addrcache_get_modified                ( AddressCache *cache );
+void addrcache_set_modified            ( AddressCache *cache,
+                                         const gboolean value );
+gboolean addrcache_get_read_flag       ( AddressCache *cache );
+void addrcache_set_read_flag           ( AddressCache *cache,
+                                         const gboolean value );
+gboolean addrcache_get_accessed                ( AddressCache *cache );
+void addrcache_set_accessed            ( AddressCache *cache,
+                                         const gboolean value );
 gchar *addrcache_get_name              ( AddressCache *cache );
 void addrcache_set_name                        ( AddressCache *cache,
                                          const gchar *value );
index 2451e8d..1d50e2b 100644 (file)
 #include "addrselect.h"
 #include "addrclip.h"
 
-/*
-#include "pixmaps/dir-close.xpm"
-#include "pixmaps/dir-open.xpm"
-#include "pixmaps/group.xpm"
-#include "pixmaps/interface.xpm"
-#include "pixmaps/book.xpm"
-#include "pixmaps/address.xpm"
-#include "pixmaps/vcard.xpm"
-#include "pixmaps/jpilot.xpm"
-#include "pixmaps/category.xpm"
-#include "pixmaps/ldap.xpm"
-*/
-
 typedef enum
 {
        COL_NAME        = 0,
@@ -455,6 +442,22 @@ void addressbook_open(Compose *target)
        addressbook_set_target_compose(target);
 }
 
+void addressbook_destroy() {
+       /* Free up address stuff */
+       if( _addressSelect_ != NULL ) {
+               addrselect_list_free( _addressSelect_ );
+       }
+       if( _clipBoard_ != NULL ) {
+               addrclip_free( _clipBoard_ );
+       }
+       if( _addressIndex_ != NULL ) {
+              addrindex_free_index( _addressIndex_ );
+       }
+       _addressSelect_ = NULL;
+       _clipBoard_ = NULL;
+       _addressIndex_ = NULL;
+}
+
 void addressbook_set_target_compose(Compose *target)
 {
        addrbook.target_compose = target;
@@ -1237,7 +1240,6 @@ static void addressbook_tree_selected(GtkCTree *ctree, GtkCTreeNode *node,
        addressbook_menuitem_set_sensitive( obj, node );
 
        addressbook_list_select_clear();
-
 }
 
 /*
@@ -1934,6 +1936,10 @@ static gchar *addressbook_edit_datasource( AddressObject *obj, GtkCTreeNode *nod
        if( ! iface->haveLibrary ) return NULL;
 
        /* Read data from data source */
+       if( addrindex_ds_get_modify_flag( ds ) ) {
+               addrindex_ds_read_data( ds );
+       }
+
        if( ! addrindex_ds_get_read_flag( ds ) ) {
                addrindex_ds_read_data( ds );
        }
@@ -3767,7 +3773,6 @@ gboolean addressbook_add_contact( const gchar *name, const gchar *address, const
 * Return: TRUE if data loaded, FALSE if address index not loaded.
 */
 gboolean addressbook_load_completion( gint (*callBackFunc) ( const gchar *, const gchar * ) ) {
-       /* AddressInterface *interface; */
        AddressDataSource *ds;
        GList *nodeIf, *nodeDS;
        GList *listP, *nodeP;
@@ -3786,6 +3791,10 @@ gboolean addressbook_load_completion( gint (*callBackFunc) ( const gchar *, cons
                        ds = nodeDS->data;
 
                        /* Read address book */
+                       if( addrindex_ds_get_modify_flag( ds ) ) {
+                               addrindex_ds_read_data( ds );
+                       }
+
                        if( ! addrindex_ds_get_read_flag( ds ) ) {
                                addrindex_ds_read_data( ds );
                        }
@@ -3853,12 +3862,19 @@ static void addressbook_import_ldif_cb() {
                if( adapter->treeNode ) {
                        abf = addressbook_imp_ldif( _addressIndex_ );
                        if( abf ) {
-                               ds = addrindex_index_add_datasource( _addressIndex_, ADDR_IF_BOOK, abf );
-                               ads = addressbook_create_ds_adapter( ds, ADDR_BOOK, NULL );
-                               addressbook_ads_set_name( ads, addrbook_get_name( abf ) );
-                               newNode = addressbook_add_object( adapter->treeNode, ADDRESS_OBJECT(ads) );
+                               ds = addrindex_index_add_datasource(
+                                       _addressIndex_, ADDR_IF_BOOK, abf );
+                               ads = addressbook_create_ds_adapter(
+                                       ds, ADDR_BOOK, NULL );
+                               addressbook_ads_set_name(
+                                       ads, addrbook_get_name( abf ) );
+                               newNode = addressbook_add_object(
+                                       adapter->treeNode,
+                                       ADDRESS_OBJECT(ads) );
                                if( newNode ) {
-                                       gtk_ctree_select( GTK_CTREE(addrbook.ctree), newNode );
+                                       gtk_ctree_select(
+                                               GTK_CTREE(addrbook.ctree),
+                                               newNode );
                                        addrbook.treeSelected = newNode;
                                }
 
@@ -3867,7 +3883,6 @@ static void addressbook_import_ldif_cb() {
                        }
                }
        }
-
 }
 
 /*
@@ -3885,12 +3900,19 @@ static void addressbook_import_mutt_cb() {
                if( adapter->treeNode ) {
                        abf = addressbook_imp_mutt( _addressIndex_ );
                        if( abf ) {
-                               ds = addrindex_index_add_datasource( _addressIndex_, ADDR_IF_BOOK, abf );
-                               ads = addressbook_create_ds_adapter( ds, ADDR_BOOK, NULL );
-                               addressbook_ads_set_name( ads, addrbook_get_name( abf ) );
-                               newNode = addressbook_add_object( adapter->treeNode, ADDRESS_OBJECT(ads) );
+                               ds = addrindex_index_add_datasource(
+                                       _addressIndex_, ADDR_IF_BOOK, abf );
+                               ads = addressbook_create_ds_adapter(
+                                       ds, ADDR_BOOK, NULL );
+                               addressbook_ads_set_name(
+                                       ads, addrbook_get_name( abf ) );
+                               newNode = addressbook_add_object(
+                                       adapter->treeNode,
+                                       ADDRESS_OBJECT(ads) );
                                if( newNode ) {
-                                       gtk_ctree_select( GTK_CTREE(addrbook.ctree), newNode );
+                                       gtk_ctree_select(
+                                               GTK_CTREE(addrbook.ctree),
+                                               newNode );
                                        addrbook.treeSelected = newNode;
                                }
 
@@ -3899,7 +3921,6 @@ static void addressbook_import_mutt_cb() {
                        }
                }
        }
-
 }
 
 /*
index 59512d5..7677478 100644 (file)
@@ -32,13 +32,7 @@ void addressbook_read_file           (void);
 void addressbook_export_to_file                (void);
 gint addressbook_obj_name_compare      (gconstpointer   a,
                                         gconstpointer   b);
-/* static gint addressbook_obj_name_compare(gconstpointer       a,
-                                        gconstpointer   b); */
-
-/* provisional API for accessing the address book */
-
-void addressbook_access (void);
-void addressbook_unaccess (void);
+void addressbook_destroy               ( void );
 
 gboolean addressbook_add_contact       ( const gchar   *name,
                                          const gchar   *address,
index d35c262..17610ed 100644 (file)
@@ -440,7 +440,6 @@ static addrindex_hash_add_cache( AddressIndex *addrIndex, AddressDataSource *ds
 * Free hash table callback function.
 */
 static gboolean addrindex_free_cache_cb( gpointer key, gpointer value, gpointer data ) {
-       printf( "free cache db: %s\n", key );
        g_free( key );
        key = NULL;
        value = NULL;
@@ -1232,7 +1231,7 @@ gint addrindex_save_all_books( AddressIndex *addrIndex ) {
                                AddressDataSource *ds = nodeDS->data;
                                AddressBookFile *abf = ds->rawDataSource;
                                if( addrbook_get_dirty( abf ) ) {
-                                       if( abf->readFlag ) {
+                                       if( addrbook_get_read_flag( abf ) ) {
                                                addrbook_save_data( abf );
                                                if( abf->retVal != MGU_SUCCESS ) {
                                                        retVal = abf->retVal;
index 0fa4f4e..5184005 100644 (file)
@@ -129,20 +129,6 @@ static void edit_book_name_focus( GtkWidget *widget, GdkEventFocus *event, gpoin
        edit_book_status_show( "" );
 }
 
-static gchar *edit_book_guess_file( AddressBookFile *abf ) {
-       gchar *newFile = NULL;
-       GList *fileList = NULL;
-       gint fileNum = 1;
-       fileList = addrbook_get_bookfile_list( abf );
-       if( fileList ) {
-               fileNum = 1 + abf->maxValue;
-       }
-       newFile = addrbook_gen_new_file_name( fileNum );
-       g_list_free( fileList );
-       fileList = NULL;
-       return newFile;
-}
-
 static void addressbook_edit_book_create( gboolean *cancelled ) {
        GtkWidget *window;
        GtkWidget *vbox;
@@ -285,7 +271,7 @@ AdapterDSource *addressbook_edit_book( AddressIndex *addrIndex, AdapterDSource *
                addrbook_set_path( abf, addrIndex->filePath );
 
                /* Take initial guess at file name */
-               newFile = edit_book_guess_file( abf );
+               newFile = addrbook_guess_next_file( abf );
                if( newFile ) {
                        tmp = g_strdup_printf( "<%s>", newFile );
                        gtk_label_set_text(GTK_LABEL(addrbookedit_dlg.file_label), tmp );
@@ -324,7 +310,7 @@ AdapterDSource *addressbook_edit_book( AddressIndex *addrIndex, AdapterDSource *
        else {
                if( newBook ) {
                        /* Get final file name in case it changed */
-                       newFile = edit_book_guess_file( abf );
+                       newFile = addrbook_guess_next_file( abf );
                        addrbook_set_file( abf, newFile );
                        g_free( newFile );
                        ds = addrindex_index_add_datasource( addrIndex, ADDR_IF_BOOK, abf );
index eb35d6a..ae6a96a 100644 (file)
@@ -18,7 +18,7 @@
  */
 
 /*
- * Edit VCard address book data.
+ * Import LDIF address book data.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -125,20 +125,6 @@ static void imp_ldif_message( void ) {
        imp_ldif_status_show( sMsg );
 }
 
-static gchar *imp_ldif_guess_file( AddressBookFile *abf ) {
-       gchar *newFile = NULL;
-       GList *fileList = NULL;
-       gint fileNum = 1;
-       fileList = addrbook_get_bookfile_list( abf );
-       if( fileList ) {
-               fileNum = 1 + abf->maxValue;
-       }
-       newFile = addrbook_gen_new_file_name( fileNum );
-       g_list_free( fileList );
-       fileList = NULL;
-       return newFile;
-}
-
 static void imp_ldif_update_row( GtkCList *clist ) {
        Ldif_FieldRec *rec;
        gchar *text[ FIELDS_N_COLS ];
@@ -264,7 +250,7 @@ static gboolean imp_ldif_field_move() {
        abf = addrbook_create_book();
        addrbook_set_path( abf, _imp_addressIndex_->filePath );
        addrbook_set_name( abf, impldif_dlg.nameBook );
-       newFile = imp_ldif_guess_file( abf );
+       newFile = addrbook_guess_next_file( abf );
        addrbook_set_file( abf, newFile );
        g_free( newFile );
 
index f0017f5..cb01074 100644 (file)
@@ -74,20 +74,6 @@ void imp_mutt_status_show( gchar *msg ) {
        }
 }
 
-static gchar *imp_mutt_guess_file( AddressBookFile *abf ) {
-       gchar *newFile = NULL;
-       GList *fileList = NULL;
-       gint fileNum = 1;
-       fileList = addrbook_get_bookfile_list( abf );
-       if( fileList ) {
-               fileNum = 1 + abf->maxValue;
-       }
-       newFile = addrbook_gen_new_file_name( fileNum );
-       g_list_free( fileList );
-       fileList = NULL;
-       return newFile;
-}
-
 static gboolean imp_mutt_import_file( gchar *sName, gchar *sFile ) {
        gboolean retVal = FALSE;
        gchar *newFile;
@@ -101,7 +87,7 @@ static gboolean imp_mutt_import_file( gchar *sName, gchar *sFile ) {
        abf = addrbook_create_book();
        addrbook_set_path( abf, _imp_addressIndex_->filePath );
        addrbook_set_name( abf, sName );
-       newFile = imp_mutt_guess_file( abf );
+       newFile = addrbook_guess_next_file( abf );
        addrbook_set_file( abf, newFile );
        g_free( newFile );
 
index a443bab..2d70524 100644 (file)
@@ -155,7 +155,6 @@ JPilotFile *jpilot_create() {
        pilotFile = g_new0( JPilotFile, 1 );
        pilotFile->type = ADBOOKTYPE_JPILOT;
        pilotFile->addressCache = addrcache_create();
-       pilotFile->accessFlag = FALSE;
        pilotFile->retVal = MGU_SUCCESS;
 
        pilotFile->file = NULL;
@@ -193,7 +192,7 @@ void jpilot_set_file( JPilotFile* pilotFile, const gchar *value ) {
 }
 void jpilot_set_accessed( JPilotFile *pilotFile, const gboolean value ) {
        g_return_if_fail( pilotFile != NULL );
-       pilotFile->accessFlag = value;
+       pilotFile->addressCache->accessFlag = value;
 }
 
 gint jpilot_get_status( JPilotFile *pilotFile ) {
@@ -372,11 +371,16 @@ static gboolean jpilot_check_files( JPilotFile *pilotFile ) {
 */
 gboolean jpilot_get_modified( JPilotFile *pilotFile ) {
        g_return_val_if_fail( pilotFile != NULL, FALSE );
-       return jpilot_check_files( pilotFile );
+       pilotFile->addressCache->modified = jpilot_check_files( pilotFile );
+       return pilotFile->addressCache->modified;
+}
+void jpilot_set_modified( JPilotFile *pilotFile, const gboolean value ) {
+       g_return_if_fail( pilotFile != NULL );
+       pilotFile->addressCache->modified = value;
 }
 gboolean jpilot_get_accessed( JPilotFile *pilotFile ) {
        g_return_val_if_fail( pilotFile != NULL, FALSE );
-       return pilotFile->accessFlag;
+       return pilotFile->addressCache->accessFlag;
 }
 
 /*
@@ -403,7 +407,6 @@ void jpilot_free( JPilotFile *pilotFile ) {
 
        pilotFile->type = ADBOOKTYPE_NONE;
        pilotFile->addressCache = NULL;
-       pilotFile->accessFlag = FALSE;
        pilotFile->retVal = MGU_SUCCESS;
 
        /* Now release file object */
@@ -941,7 +944,7 @@ static gint jpilot_read_db_files( JPilotFile *pilotFile, GList **records ) {
        /* Read the PC3 file, if present */
        pcFile = jpilot_get_pc3_file( pilotFile );
        if( pcFile == NULL ) return MGU_SUCCESS;
-       pc_in = fopen( pcFile, "rb");
+       pc_in = fopen( pcFile, "rb" );
        g_free( pcFile );
 
        if( pc_in == NULL ) {
@@ -1437,8 +1440,7 @@ gint jpilot_read_data( JPilotFile *pilotFile ) {
        g_return_val_if_fail( pilotFile != NULL, -1 );
 
        pilotFile->retVal = MGU_SUCCESS;
-       pilotFile->accessFlag = FALSE;
-
+       pilotFile->addressCache->accessFlag = FALSE;
        if( jpilot_check_files( pilotFile ) ) {
                addrcache_clear( pilotFile->addressCache );
                jpilot_read_metadata( pilotFile );
@@ -1562,7 +1564,7 @@ gchar *jpilot_find_pilotdb( void ) {
        strcat( str, JPILOT_DBHOME_FILE );
 
        /* Attempt to open */
-       if( ( fp = fopen( str, "rb" ) ) != NULL ) {
+       if( ( fp = fopen( str, "r" ) ) != NULL ) {
                fclose( fp );
        }
        else {
index ea432d5..95b4a9f 100644 (file)
@@ -50,7 +50,6 @@ typedef struct _JPilotFile JPilotFile;
 struct _JPilotFile {
        AddressBookType type;
        AddressCache *addressCache;
-       gboolean accessFlag;
        gint     retVal;
        FILE     *file;
        gchar    *path;
@@ -79,6 +78,7 @@ void jpilot_set_file                  ( JPilotFile* pilotFile, const gchar *value );
 void jpilot_free                       ( JPilotFile *pilotFile );
 gint jpilot_get_status                 ( JPilotFile *pilotFile );
 gboolean jpilot_get_modified           ( JPilotFile *pilotFile );
+void jpilot_set_modified               ( JPilotFile *pilotFile, const gboolean value );
 gboolean jpilot_get_accessed           ( JPilotFile *pilotFile );
 void jpilot_set_accessed               ( JPilotFile *pilotFile, const gboolean value );
 gboolean jpilot_get_read_flag          ( JPilotFile *pilotFile );
index 2fd6d1a..ff36dbf 100644 (file)
@@ -322,6 +322,8 @@ int main(int argc, char *argv[])
 
        gtk_main();
 
+       addressbook_destroy();
+
 #if USE_PSPELL       
        gtkpspell_checkers_delete();
 #endif
index f844bfe..bf7711a 100644 (file)
@@ -54,7 +54,6 @@ SyldapServer *syldap_create() {
        ldapServer = g_new0( SyldapServer, 1 );
        ldapServer->type = ADBOOKTYPE_LDAP;
        ldapServer->addressCache = addrcache_create();
-       ldapServer->accessFlag = FALSE;
        ldapServer->retVal = MGU_SUCCESS;
        ldapServer->hostName = NULL;
        ldapServer->port = SYLDAP_DFL_PORT;
@@ -185,11 +184,6 @@ void syldap_set_callback( SyldapServer *ldapServer, void *func ) {
        ldapServer->callBack = func;
 }
 
-void syldap_set_accessed( SyldapServer *ldapServer, const gboolean value ) {
-       g_return_if_fail( ldapServer != NULL );
-       ldapServer->accessFlag = value;
-}
-
 /*
 * Refresh internal variables to force a file read.
 */
@@ -215,7 +209,22 @@ gchar *syldap_get_name( SyldapServer *ldapServer ) {
 
 gboolean syldap_get_accessed( SyldapServer *ldapServer ) {
        g_return_val_if_fail( ldapServer != NULL, FALSE );
-       return ldapServer->accessFlag;
+       return ldapServer->addressCache->accessFlag;
+}
+
+void syldap_set_accessed( SyldapServer *ldapServer, const gboolean value ) {
+       g_return_if_fail( ldapServer != NULL );
+       ldapServer->addressCache->accessFlag = value;
+}
+
+gboolean syldap_get_modified( SyldapServer *ldapServer ) {
+       g_return_val_if_fail( ldapServer != NULL, FALSE );
+       return ldapServer->addressCache->modified;
+}
+
+void syldap_set_modified( SyldapServer *ldapServer, const gboolean value ) {
+       g_return_if_fail( ldapServer != NULL );
+       ldapServer->addressCache->modified = value;
 }
 
 /*
@@ -261,7 +270,6 @@ void syldap_free( SyldapServer *ldapServer ) {
 
        ldapServer->type = ADBOOKTYPE_NONE;
        ldapServer->addressCache = NULL;
-       ldapServer->accessFlag = FALSE;
        ldapServer->retVal = MGU_SUCCESS;
 
        /* Now release LDAP object */
@@ -656,7 +664,7 @@ static gint syldap_display_search_results(SyldapServer *ldapServer)
 gint syldap_read_data( SyldapServer *ldapServer ) {
        g_return_val_if_fail( ldapServer != NULL, -1 );
 
-       ldapServer->accessFlag = FALSE;
+       ldapServer->addressCache->accessFlag = FALSE;
        pthread_detach( pthread_self() );
        if( ldapServer->newSearch ) {
                /* Read data into the list */
@@ -665,7 +673,7 @@ gint syldap_read_data( SyldapServer *ldapServer ) {
                /* Mark cache */
                ldapServer->addressCache->modified = FALSE;
                ldapServer->addressCache->dataRead = TRUE;
-               ldapServer->accessFlag = FALSE;
+               ldapServer->addressCache->accessFlag = FALSE;
        }
 
        /* Callback */
index 2729c83..9e79a96 100644 (file)
@@ -49,7 +49,6 @@ typedef struct _SyldapServer SyldapServer;
 struct _SyldapServer {
        AddressBookType type;
        AddressCache *addressCache;
-       gboolean  accessFlag;
        gint      retVal;
        gchar     *hostName;
        gint      port;
@@ -87,6 +86,8 @@ void syldap_free              ( SyldapServer *ldapServer );
 gint syldap_get_status         ( SyldapServer *ldapServer );
 gboolean syldap_get_accessed   ( SyldapServer *ldapServer );
 gchar *syldap_get_name         ( SyldapServer *ldapServer );
+gboolean syldap_get_modified   ( SyldapServer *ldapServer );
+void syldap_set_modified       ( SyldapServer *ldapServer, const gboolean value );
 
 void syldap_print_data         ( SyldapServer *ldapServer, FILE *stream );
 gboolean syldap_check_search   ( SyldapServer *ldapServer );
@@ -94,7 +95,6 @@ gint syldap_read_data         ( SyldapServer *ldapServer );
 gint syldap_read_data_th       ( SyldapServer *ldapServer );
 void syldap_cancel_read                ( SyldapServer *ldapServer );
 
-/* GList *syldap_get_address_list      ( const SyldapServer *ldapServer ); */
 ItemFolder *syldap_get_root_folder     ( SyldapServer *ldapServer );
 GList *syldap_get_list_person  ( SyldapServer *ldapServer );
 GList *syldap_get_list_folder  ( SyldapServer *ldapServer );
index 6f6b883..43d71a7 100644 (file)
@@ -48,7 +48,6 @@ VCardFile *vcard_create() {
        cardFile = g_new0( VCardFile, 1 );
        cardFile->type = ADBOOKTYPE_VCARD;
        cardFile->addressCache = addrcache_create();
-       cardFile->accessFlag = FALSE;
        cardFile->retVal = MGU_SUCCESS;
 
        cardFile->file = NULL;
@@ -72,29 +71,35 @@ void vcard_set_file( VCardFile* cardFile, const gchar *value ) {
 }
 void vcard_set_accessed( VCardFile *cardFile, const gboolean value ) {
        g_return_if_fail( cardFile != NULL );
-       cardFile->accessFlag = value;
+       cardFile->addressCache->accessFlag = value;
 }
 
 /*
 * Test whether file was modified since last access.
 * Return: TRUE if file was modified.
 */
-gboolean vcard_get_modified( VCardFile *vcardFile ) {
-       g_return_val_if_fail( vcardFile != NULL, FALSE );
-       return addrcache_check_file( vcardFile->addressCache, vcardFile->path );
+gboolean vcard_get_modified( VCardFile *cardFile ) {
+       g_return_val_if_fail( cardFile != NULL, FALSE );
+       cardFile->addressCache->modified =
+               addrcache_check_file( cardFile->addressCache, cardFile->path );
+       return cardFile->addressCache->modified;
 }
-gboolean vcard_get_accessed( VCardFile *vcardFile ) {
-       g_return_val_if_fail( vcardFile != NULL, FALSE );
-       return addrcache_check_file( vcardFile->addressCache, vcardFile->path );
+gboolean vcard_get_accessed( VCardFile *cardFile ) {
+       g_return_val_if_fail( cardFile != NULL, FALSE );
+       return cardFile->addressCache->accessFlag;
 }
 
 /*
 * Test whether file was read.
 * Return: TRUE if file was read.
 */
-gboolean vcard_get_read_flag( VCardFile *vcardFile ) {
-       g_return_val_if_fail( vcardFile != NULL, FALSE );
-       return vcardFile->addressCache->dataRead;
+gboolean vcard_get_read_flag( VCardFile *cardFile ) {
+       g_return_val_if_fail( cardFile != NULL, FALSE );
+       return cardFile->addressCache->dataRead;
+}
+void vcard_set_read_flag( VCardFile *cardFile, const gboolean value ) {
+       g_return_if_fail( cardFile != NULL );
+       cardFile->addressCache->dataRead = value;
 }
 
 /*
@@ -155,7 +160,6 @@ void vcard_free( VCardFile *cardFile ) {
 
        cardFile->type = ADBOOKTYPE_NONE;
        cardFile->addressCache = NULL;
-       cardFile->accessFlag = FALSE;
        cardFile->retVal = MGU_SUCCESS;
 
        /* Now release file object */
@@ -558,7 +562,7 @@ gint vcard_read_data( VCardFile *cardFile ) {
        g_return_val_if_fail( cardFile != NULL, -1 );
 
        cardFile->retVal = MGU_SUCCESS;
-       cardFile->accessFlag = FALSE;
+       cardFile->addressCache->accessFlag = FALSE;
        if( addrcache_check_file( cardFile->addressCache, cardFile->path ) ) {
                addrcache_clear( cardFile->addressCache );
                vcard_open_file( cardFile );
index 5b93d79..c177f1b 100644 (file)
@@ -72,7 +72,6 @@ typedef struct _VCardFile VCardFile;
 struct _VCardFile {
        AddressBookType type;
        AddressCache *addressCache;
-       gboolean accessFlag;
        gint     retVal;
        FILE     *file;
        gchar    *path;
@@ -85,11 +84,12 @@ VCardFile *vcard_create                     ( void );
 VCardFile *vcard_create_path           ( const gchar *path );
 void vcard_set_name                    ( VCardFile* cardFile, const gchar *value );
 void vcard_set_file                    ( VCardFile* cardFile, const gchar *value );
-void vcard_set_modified                        ( VCardFile *vcardFile, const gboolean value );
-void vcard_set_accessed                        ( VCardFile *vcardFile, const gboolean value );
-gboolean vcard_get_modified            ( VCardFile *vcardFile );
-gboolean vcard_get_accessed            ( VCardFile *vcardFile );
-gboolean vcard_get_read_flag           ( VCardFile *vcardFile );
+void vcard_set_modified                        ( VCardFile *cardFile, const gboolean value );
+void vcard_set_accessed                        ( VCardFile *cardFile, const gboolean value );
+gboolean vcard_get_modified            ( VCardFile *cardFile );
+gboolean vcard_get_accessed            ( VCardFile *cardFile );
+gboolean vcard_get_read_flag           ( VCardFile *cardFile );
+void vcard_set_read_flag               ( VCardFile *cardFile, const gboolean value );
 gint vcard_get_status                  ( VCardFile *cardFile );
 ItemFolder *vcard_get_root_folder      ( VCardFile *cardFile );
 gchar *vcard_get_name                  ( VCardFile *cardFile );