2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2001-2003 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"
31 #include "addrquery.h"
33 #define ADDRESSBOOK_MAX_IFACE 4
34 #define ADDRESSBOOK_INDEX_FILE "addrbook--index.xml"
35 #define ADDRESSBOOK_OLD_FILE "addressbook.xml"
47 typedef struct _AddressIndex AddressIndex;
48 struct _AddressIndex {
53 gboolean needsConversion;
54 gboolean wasConverted;
55 gboolean conversionError;
56 AddressIfType lastType;
59 GHashTable *hashCache;
64 typedef struct _AddressInterface AddressInterface;
65 struct _AddressInterface {
72 gboolean useInterface;
76 gboolean (*getModifyFlag)( void * );
77 gboolean (*getAccessFlag)( void * );
78 gboolean (*getReadFlag)( void * );
79 gint (*getStatusCode)( void * );
80 gint (*getReadData)( void * );
81 ItemFolder *(*getRootFolder)( void * );
82 GList *(*getListFolder)( void * );
83 GList *(*getListPerson)( void * );
84 GList *(*getAllPersons)( void * );
85 GList *(*getAllGroups)( void * );
86 gchar *(*getName)( void * );
87 void (*setAccessFlag)( void *, void * );
88 gboolean externalQuery;
90 void (*startSearch)( void * );
91 void (*stopSearch)( void * );
94 typedef struct _AddressDataSource AddressDataSource;
95 struct _AddressDataSource {
98 AddressInterface *interface;
99 gpointer rawDataSource;
102 void addrindex_initialize ( AddressIndex *addrIndex );
103 void addrindex_teardown ( AddressIndex *addrIndex );
105 AddressIndex *addrindex_create_index ( void );
106 void addrindex_set_file_path ( AddressIndex *addrIndex,
107 const gchar *value );
108 void addrindex_set_file_name ( AddressIndex *addrIndex,
109 const gchar *value );
110 void addrindex_set_dirty ( AddressIndex *addrIndex,
111 const gboolean value );
112 gboolean addrindex_get_loaded ( AddressIndex *addrIndex );
114 GList *addrindex_get_interface_list ( AddressIndex *addrIndex );
115 void addrindex_free_index ( AddressIndex *addrIndex );
116 void addrindex_print_index ( AddressIndex *addrIndex, FILE *stream );
118 AddressInterface *addrindex_get_interface ( AddressIndex *addrIndex,
119 AddressIfType ifType );
121 AddressDataSource *addrindex_create_datasource ( AddressIfType ifType );
123 AddressDataSource *addrindex_index_add_datasource ( AddressIndex *addrIndex,
124 AddressIfType ifType,
125 gpointer dataSource );
126 AddressDataSource *addrindex_index_remove_datasource ( AddressIndex *addrIndex,
127 AddressDataSource *dataSource );
129 void addrindex_free_datasource ( AddressDataSource *ds );
130 gchar *addrindex_get_cache_id ( AddressIndex *addrIndex,
131 AddressDataSource *ds );
132 AddressDataSource *addrindex_get_datasource ( AddressIndex *addrIndex,
133 const gchar *cacheID );
134 AddressCache *addrindex_get_cache ( AddressIndex *addrIndex,
135 const gchar *cacheID );
137 gint addrindex_read_data ( AddressIndex *addrIndex );
138 gint addrindex_write_to ( AddressIndex *addrIndex,
139 const gchar *newFile );
140 gint addrindex_save_data ( AddressIndex *addrIndex );
141 gint addrindex_create_new_books ( AddressIndex *addrIndex );
142 gint addrindex_save_all_books ( AddressIndex *addrIndex );
144 gboolean addrindex_ds_get_modify_flag ( AddressDataSource *ds );
145 gboolean addrindex_ds_get_access_flag ( AddressDataSource *ds );
146 gboolean addrindex_ds_get_read_flag ( AddressDataSource *ds );
147 gint addrindex_ds_get_status_code ( AddressDataSource *ds );
148 gint addrindex_ds_read_data ( AddressDataSource *ds );
149 ItemFolder *addrindex_ds_get_root_folder( AddressDataSource *ds );
150 GList *addrindex_ds_get_list_folder ( AddressDataSource *ds );
151 GList *addrindex_ds_get_list_person ( AddressDataSource *ds );
152 gchar *addrindex_ds_get_name ( AddressDataSource *ds );
153 void addrindex_ds_set_access_flag ( AddressDataSource *ds,
155 gboolean addrindex_ds_get_readonly ( AddressDataSource *ds );
156 GList *addrindex_ds_get_all_persons ( AddressDataSource *ds );
157 GList *addrindex_ds_get_all_groups ( AddressDataSource *ds );
160 gint addrindex_setup_search ( AddressIndex *addrIndex,
161 const gchar *searchTerm,
162 const gpointer target,
163 AddrSearchCallbackFunc callBack );
164 gboolean addrindex_start_search ( AddressIndex *addrIndex,
165 const gint queryID );
166 void addrindex_stop_search ( AddressIndex *addrIndex,
167 const gint queryID );
169 void addrindex_read_all ( AddressIndex *addrIndex );
170 gboolean addrindex_load_completion(
171 AddressIndex *addrIndex,
173 ( const gchar *, const gchar *, const gchar * ) );
175 #endif /* __ADDRINDEX_H__ */