2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2001-2002 Match Grun
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 * General functions for accessing address index file.
24 #ifndef __ADDRINDEX_H__
25 #define __ADDRINDEX_H__
30 #include "addrcache.h"
32 #define ADDRESSBOOK_MAX_IFACE 4
33 #define ADDRESSBOOK_INDEX_FILE "addrbook--index.xml"
34 #define ADDRESSBOOK_OLD_FILE "addressbook.xml"
46 typedef struct _AddressIndex AddressIndex;
47 struct _AddressIndex {
52 gboolean needsConversion;
53 gboolean wasConverted;
54 gboolean conversionError;
55 AddressIfType lastType;
58 GHashTable *hashCache;
61 typedef struct _AddressInterface AddressInterface;
62 struct _AddressInterface {
69 gboolean useInterface;
73 gboolean (*getModifyFlag)( void * );
74 gboolean (*getAccessFlag)( void * );
75 gboolean (*getReadFlag)( void * );
76 gint (*getStatusCode)( void * );
77 gint (*getReadData)( void * );
78 ItemFolder *(*getRootFolder)( void * );
79 GList *(*getListFolder)( void * );
80 GList *(*getListPerson)( void * );
81 GList *(*getAllPersons)( void * );
82 GList *(*getAllGroups)( void * );
83 gchar *(*getName)( void * );
84 void (*setAccessFlag)( void *, void * );
87 typedef struct _AddressDataSource AddressDataSource;
88 struct _AddressDataSource {
91 AddressInterface *interface;
92 gpointer rawDataSource;
95 AddressIndex *addrindex_create_index ( void );
96 void addrindex_set_file_path ( AddressIndex *addrIndex,
98 void addrindex_set_file_name ( AddressIndex *addrIndex,
100 void addrindex_set_dirty ( AddressIndex *addrIndex,
101 const gboolean value );
102 GList *addrindex_get_interface_list ( AddressIndex *addrIndex );
103 void addrindex_free_index ( AddressIndex *addrIndex );
104 void addrindex_print_index ( AddressIndex *addrIndex, FILE *stream );
106 AddressInterface *addrindex_get_interface ( AddressIndex *addrIndex,
107 AddressIfType ifType );
109 AddressDataSource *addrindex_create_datasource ( AddressIfType ifType );
111 AddressDataSource *addrindex_index_add_datasource ( AddressIndex *addrIndex,
112 AddressIfType ifType,
113 gpointer dataSource );
114 AddressDataSource *addrindex_index_remove_datasource ( AddressIndex *addrIndex,
115 AddressDataSource *dataSource );
117 void addrindex_free_datasource ( AddressDataSource *ds );
118 gchar *addrindex_get_cache_id ( AddressIndex *addrIndex,
119 AddressDataSource *ds );
120 AddressDataSource *addrindex_get_datasource ( AddressIndex *addrIndex,
121 const gchar *cacheID );
122 AddressCache *addrindex_get_cache ( AddressIndex *addrIndex,
123 const gchar *cacheID );
125 gint addrindex_read_data ( AddressIndex *addrIndex );
126 gint addrindex_write_to ( AddressIndex *addrIndex,
127 const gchar *newFile );
128 gint addrindex_save_data ( AddressIndex *addrIndex );
129 gint addrindex_create_new_books ( AddressIndex *addrIndex );
130 gint addrindex_save_all_books ( AddressIndex *addrIndex );
132 gboolean addrindex_ds_get_modify_flag ( AddressDataSource *ds );
133 gboolean addrindex_ds_get_access_flag ( AddressDataSource *ds );
134 gboolean addrindex_ds_get_read_flag ( AddressDataSource *ds );
135 gint addrindex_ds_get_status_code ( AddressDataSource *ds );
136 gint addrindex_ds_read_data ( AddressDataSource *ds );
137 ItemFolder *addrindex_ds_get_root_folder( AddressDataSource *ds );
138 GList *addrindex_ds_get_list_folder ( AddressDataSource *ds );
139 GList *addrindex_ds_get_list_person ( AddressDataSource *ds );
140 gchar *addrindex_ds_get_name ( AddressDataSource *ds );
141 void addrindex_ds_set_access_flag ( AddressDataSource *ds,
143 gboolean addrindex_ds_get_readonly ( AddressDataSource *ds );
144 GList *addrindex_ds_get_all_persons ( AddressDataSource *ds );
145 GList *addrindex_ds_get_all_groups ( AddressDataSource *ds );
147 #endif /* __ADDRINDEX_H__ */