minor update
authorMatch Grun <match@dimensional.com>
Mon, 24 Sep 2001 05:42:50 +0000 (05:42 +0000)
committerMatch Grun <match@dimensional.com>
Mon, 24 Sep 2001 05:42:50 +0000 (05:42 +0000)
src/addrcache.c
src/addrindex.c
src/addrindex.h

index e221a11c9eb307f835a375cd5618c2cb995accdb..de40b03ea8e6953ded56b6394df58307edf3de3b 100644 (file)
@@ -1020,7 +1020,7 @@ ItemFolder *addrcache_find_root_folder( ItemFolder *folder ) {
 }
 
 /*
 }
 
 /*
-* Get all person visitor function.
+* Get all persons visitor function.
 */
 static void addrcache_get_all_persons_vis( gpointer key, gpointer value, gpointer data ) {
        AddrItemObject *obj = ( AddrItemObject * ) value;
 */
 static void addrcache_get_all_persons_vis( gpointer key, gpointer value, gpointer data ) {
        AddrItemObject *obj = ( AddrItemObject * ) value;
@@ -1049,6 +1049,36 @@ GList *addrcache_get_all_persons( AddressCache *cache ) {
        return list;
 }
 
        return list;
 }
 
+/*
+* Get all groups visitor function.
+*/
+static void addrcache_get_all_groups_vis( gpointer key, gpointer value, gpointer data ) {
+       AddrItemObject *obj = ( AddrItemObject * ) value;
+
+       if( ADDRITEM_TYPE(obj) == ITEMTYPE_GROUP ) {
+               AddressCache *cache = data;
+               cache->tempList = g_list_append( cache->tempList, obj );
+       }
+}
+
+/*
+* Return link list of all groups in address cache.  Note that the list contains
+* references to items. Do *NOT* attempt to use the addrcache_free_xxx() functions...
+* this will destroy the address cache data!
+* Return: List of items, or NULL if none.
+*/
+GList *addrcache_get_all_groups( AddressCache *cache ) {
+       GList *list = NULL;
+
+       g_return_val_if_fail( cache != NULL, NULL );
+
+       cache->tempList = NULL;
+       g_hash_table_foreach( cache->itemHash, addrcache_get_all_groups_vis, cache );
+       list = cache->tempList;
+       cache->tempList = NULL;
+       return list;
+}
+
 /*
 * Remove folder from cache. Children are re-parented to parent folder.
 * param: folder Folder to remove.
 /*
 * Remove folder from cache. Children are re-parented to parent folder.
 * param: folder Folder to remove.
index f1da4bfca0f73278f9696868500917cae8a02a1c..1fa458698c1f177c41dacc3274c2d9baf1a10a38 100644 (file)
@@ -132,6 +132,7 @@ static AddressInterface *addrindex_create_interface( gint type, gchar *name, gch
        iface->getListFolder = NULL;
        iface->getListPerson = NULL;
        iface->getAllPersons = NULL;
        iface->getListFolder = NULL;
        iface->getListPerson = NULL;
        iface->getAllPersons = NULL;
+       iface->getAllGroups  = NULL;
        iface->getName       = NULL;
        iface->listSource = NULL;
        return iface;
        iface->getName       = NULL;
        iface->listSource = NULL;
        return iface;
@@ -1858,6 +1859,22 @@ GList *addrindex_ds_get_all_persons( AddressDataSource *ds ) {
        return retVal;
 }
 
        return retVal;
 }
 
+/*
+ * Return list of all groups for specified data source.
+ */
+GList *addrindex_ds_get_all_groups( AddressDataSource *ds ) {
+       GList *retVal = NULL;
+       AddressInterface *iface;
+
+       if( ds == NULL ) return retVal;
+       iface = ds->interface;
+       if( iface == NULL ) return retVal;
+       if( iface->getAllGroups ) {
+               retVal = ( iface->getAllGroups ) ( ds->rawDataSource );
+       }
+       return retVal;
+}
+
 /*
 * End of Source.
 */
 /*
 * End of Source.
 */
index e2cc4b4d2b41d52b15e5cc2f284d92f4f0848afe..21750bdcd53083ed19370ca5a39f74df63b64921 100644 (file)
@@ -77,6 +77,7 @@ struct _AddressInterface {
        GList *(*getListFolder)( void * );
        GList *(*getListPerson)( void * );
        GList *(*getAllPersons)( void * );
        GList *(*getListFolder)( void * );
        GList *(*getListPerson)( void * );
        GList *(*getAllPersons)( void * );
+       GList *(*getAllGroups)( void * );
        gchar *(*getName) ( void * );
        void (*setAccessFlag)( void *, void * );
 };
        gchar *(*getName) ( void * );
        void (*setAccessFlag)( void *, void * );
 };
@@ -89,37 +90,38 @@ struct _AddressDataSource {
        gpointer rawDataSource;
 };
 
        gpointer rawDataSource;
 };
 
-AddressIndex *addrindex_create_index();
-void addrindex_set_file_path( AddressIndex *addrIndex, const gchar *value );
-void addrindex_set_file_name( AddressIndex *addrIndex, const gchar *value );
-void addrindex_set_dirty( AddressIndex *addrIndex, const gboolean value );
-GList *addrindex_get_interface_list( AddressIndex *addrIndex );
-void addrindex_free_index( AddressIndex *addrIndex );
-void addrindex_print_index( AddressIndex *addrIndex, FILE *stream );
-
-AddressInterface *addrindex_get_interface( AddressIndex *addrIndex, AddressIfType ifType );
-AddressDataSource *addrindex_index_add_datasource( AddressIndex *addrIndex, AddressIfType ifType, gpointer dataSource );
-AddressDataSource *addrindex_index_remove_datasource( AddressIndex *addrIndex, AddressDataSource *dataSource );
-void addrindex_free_datasource( AddressIndex *addrIndex, AddressDataSource *ds );
-
-gint addrindex_read_data( AddressIndex *addrIndex );
-gint addrindex_write_to( AddressIndex *addrIndex, const gchar *newFile );
-gint addrindex_save_data( AddressIndex *addrIndex );
-gint addrindex_create_new_books( AddressIndex *addrIndex );
-gint addrindex_save_all_books( AddressIndex *addrIndex );
-
-gboolean addrindex_ds_get_modify_flag( AddressDataSource *ds );
-gboolean addrindex_ds_get_access_flag( AddressDataSource *ds );
-gboolean addrindex_ds_get_read_flag( AddressDataSource *ds );
-gint addrindex_ds_get_status_code( AddressDataSource *ds );
-gint addrindex_ds_read_data( AddressDataSource *ds );
+AddressIndex *addrindex_create_index   ();
+void addrindex_set_file_path           ( AddressIndex *addrIndex, const gchar *value );
+void addrindex_set_file_name           ( AddressIndex *addrIndex, const gchar *value );
+void addrindex_set_dirty               ( AddressIndex *addrIndex, const gboolean value );
+GList *addrindex_get_interface_list    ( AddressIndex *addrIndex );
+void addrindex_free_index              ( AddressIndex *addrIndex );
+void addrindex_print_index             ( AddressIndex *addrIndex, FILE *stream );
+
+AddressInterface *addrindex_get_interface              ( AddressIndex *addrIndex, AddressIfType ifType );
+AddressDataSource *addrindex_index_add_datasource      ( AddressIndex *addrIndex, AddressIfType ifType, gpointer dataSource );
+AddressDataSource *addrindex_index_remove_datasource   ( AddressIndex *addrIndex, AddressDataSource *dataSource );
+void addrindex_free_datasource         ( AddressIndex *addrIndex, AddressDataSource *ds );
+
+gint addrindex_read_data               ( AddressIndex *addrIndex );
+gint addrindex_write_to                        ( AddressIndex *addrIndex, const gchar *newFile );
+gint addrindex_save_data               ( AddressIndex *addrIndex );
+gint addrindex_create_new_books                ( AddressIndex *addrIndex );
+gint addrindex_save_all_books          ( AddressIndex *addrIndex );
+
+gboolean addrindex_ds_get_modify_flag  ( AddressDataSource *ds );
+gboolean addrindex_ds_get_access_flag  ( AddressDataSource *ds );
+gboolean addrindex_ds_get_read_flag    ( AddressDataSource *ds );
+gint addrindex_ds_get_status_code      ( AddressDataSource *ds );
+gint addrindex_ds_read_data            ( AddressDataSource *ds );
 ItemFolder *addrindex_ds_get_root_folder( AddressDataSource *ds );
 ItemFolder *addrindex_ds_get_root_folder( AddressDataSource *ds );
-GList *addrindex_ds_get_list_folder( AddressDataSource *ds );
-GList *addrindex_ds_get_list_person( AddressDataSource *ds );
-gchar *addrindex_ds_get_name( AddressDataSource *ds );
-void addrindex_ds_set_access_flag( AddressDataSource *ds, gboolean *value );
-gboolean addrindex_ds_get_readonly( AddressDataSource *ds );
-GList *addrindex_ds_get_all_persons( AddressDataSource *ds );
+GList *addrindex_ds_get_list_folder    ( AddressDataSource *ds );
+GList *addrindex_ds_get_list_person    ( AddressDataSource *ds );
+gchar *addrindex_ds_get_name           ( AddressDataSource *ds );
+void addrindex_ds_set_access_flag      ( AddressDataSource *ds, gboolean *value );
+gboolean addrindex_ds_get_readonly     ( AddressDataSource *ds );
+GList *addrindex_ds_get_all_persons    ( AddressDataSource *ds );
+GList *addrindex_ds_get_all_groups     ( AddressDataSource *ds );
 
 #endif /* __ADDRINDEX_H__ */
 
 
 #endif /* __ADDRINDEX_H__ */