cleaner messages, no popup if required
[claws.git] / src / addrindex.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 2001-2002 Match Grun
4  *
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.
9  *
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.
14  *
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.
18  */
19
20 /*
21  * General functions for accessing address index file.
22  */
23
24 #ifndef __ADDRINDEX_H__
25 #define __ADDRINDEX_H__
26
27 #include <stdio.h>
28 #include <glib.h>
29 #include "addritem.h"
30 #include "addrcache.h"
31
32 #define ADDRESSBOOK_MAX_IFACE  4
33 #define ADDRESSBOOK_INDEX_FILE "addrbook--index.xml"
34 #define ADDRESSBOOK_OLD_FILE   "addressbook.xml"
35
36 typedef enum {
37         ADDR_IF_NONE,
38         ADDR_IF_BOOK,
39         ADDR_IF_VCARD,
40         ADDR_IF_JPILOT,
41         ADDR_IF_LDAP,
42         ADDR_IF_COMMON,
43         ADDR_IF_PERSONAL
44 } AddressIfType;
45
46 typedef struct _AddressIndex AddressIndex;
47 struct _AddressIndex {
48         AddrItemObject obj;
49         gchar *filePath;
50         gchar *fileName;
51         gint  retVal;
52         gboolean needsConversion;
53         gboolean wasConverted;
54         gboolean conversionError;
55         AddressIfType lastType;
56         gboolean dirtyFlag;
57         GList *interfaceList;
58         GHashTable *hashCache;
59 };
60
61 typedef struct _AddressInterface AddressInterface;
62 struct _AddressInterface {
63         AddrItemObject obj;
64         AddressIfType type;
65         gchar *name;
66         gchar *listTag;
67         gchar *itemTag;
68         gboolean legacyFlag;
69         gboolean useInterface;
70         gboolean haveLibrary;
71         gboolean readOnly;
72         GList *listSource;
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 * );
85 };
86
87 typedef struct _AddressDataSource AddressDataSource;
88 struct _AddressDataSource {
89         AddrItemObject obj;
90         AddressIfType type;
91         AddressInterface *interface;
92         gpointer rawDataSource;
93 };
94
95 AddressIndex *addrindex_create_index    ( void );
96 void addrindex_set_file_path            ( AddressIndex *addrIndex,
97                                           const gchar *value );
98 void addrindex_set_file_name            ( AddressIndex *addrIndex,
99                                           const gchar *value );
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 );
105
106 AddressInterface *addrindex_get_interface       ( AddressIndex *addrIndex,
107                                                   AddressIfType ifType );
108
109 AddressDataSource *addrindex_create_datasource  ( AddressIfType ifType );
110
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 );
116
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 );
124
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 );
131
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,
142                                           gboolean *value );
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 );
146
147 #endif /* __ADDRINDEX_H__ */
148
149 /*
150 * End of Source.
151 */